[Bf-blender-cvs] [66ea03e9080] geometry-nodes: Geometry Nodes: Add object.modifiers.active to RNA
Hans Goudey
noreply at git.blender.org
Fri Nov 20 15:32:52 CET 2020
Commit: 66ea03e9080a1a7e80caf8d331c303d6b3761590
Author: Hans Goudey
Date: Fri Nov 20 09:25:01 2020 -0500
Branches: geometry-nodes
https://developer.blender.org/rB66ea03e9080a1a7e80caf8d331c303d6b3761590
Geometry Nodes: Add object.modifiers.active to RNA
This is a RNA only pointer property used to set and get the active
modifier without using an operator.
===================================================================
M source/blender/makesrna/intern/rna_object.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 712024d1591..a0ae5cc46e7 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -1612,6 +1612,27 @@ static void rna_Object_modifier_clear(Object *object, bContext *C)
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
}
+static PointerRNA rna_Object_active_modifier_get(PointerRNA *ptr)
+{
+ Object *ob = (Object *)ptr->owner_id;
+ ModifierData *md = BKE_object_active_modifier(ob);
+ return rna_pointer_inherit_refine(ptr, &RNA_Modifier, md);
+}
+
+static void rna_Object_active_modifier_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
+{
+ Object *ob = (Object *)ptr->owner_id;
+ ModifierData *md = value.data;
+
+ if (BLI_findindex(&ob->modifiers, md) == -1) {
+ BKE_reportf(
+ reports, RPT_ERROR, "Modifier \"%s\" is not in the object's modifier list", md->name);
+ return;
+ }
+
+ BKE_object_modifier_set_active(ob, md);
+}
+
bool rna_Object_modifiers_override_apply(Main *bmain,
PointerRNA *ptr_dst,
PointerRNA *ptr_src,
@@ -2283,6 +2304,7 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
FunctionRNA *func;
PropertyRNA *parm;
+ PropertyRNA *prop;
RNA_def_property_srna(cprop, "ObjectModifiers");
srna = RNA_def_struct(brna, "ObjectModifiers", NULL);
@@ -2329,6 +2351,17 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Remove all modifiers from the object");
+
+ /* Active modifier. */
+ prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "Modifier");
+ RNA_def_property_pointer_funcs(
+ prop, "rna_Object_active_modifier_get", "rna_Object_active_modifier_set", NULL, NULL);
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
+ RNA_def_property_ui_text(prop, "Active Modifier", "The active modifier in the list");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
}
/* object.grease_pencil_modifiers */
More information about the Bf-blender-cvs
mailing list