Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-11-20 17:32:46 +0300
committerHans Goudey <h.goudey@me.com>2020-11-20 17:32:46 +0300
commit3736a7cadd77377e3d34a7275c8bfb6608ff16be (patch)
tree2b815dab113278738db343e533adeeb046663298
parent66ea03e9080a1a7e80caf8d331c303d6b3761590 (diff)
Geometry Nodes: Add ability to clear object's active modifier
`object.modifiers.active = None` will just clear the active flag from every modifier.
-rw-r--r--source/blender/blenkernel/intern/object.c13
-rw-r--r--source/blender/makesrna/intern/rna_object.c5
2 files changed, 15 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 57651bb8ef4..6ae8340ce0a 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1274,15 +1274,22 @@ void BKE_object_modifier_gpencil_hook_reset(Object *ob, HookGpencilModifierData
}
}
+/**
+ * Set the object's active modifier.
+ *
+ * \param md: If NULL, only clear the active modifier, otherwise
+ * it must be in the #Object.modifiers list.
+ */
void BKE_object_modifier_set_active(Object *ob, ModifierData *md)
{
- BLI_assert(BLI_findindex(&ob->modifiers, md) != -1);
-
LISTBASE_FOREACH (ModifierData *, md_iter, &ob->modifiers) {
md_iter->flag &= ~eModifierFlag_Active;
}
- md->flag |= eModifierFlag_Active;
+ if (md != NULL) {
+ BLI_assert(BLI_findindex(&ob->modifiers, md) != -1);
+ md->flag |= eModifierFlag_Active;
+ }
}
ModifierData *BKE_object_active_modifier(const Object *ob)
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index a0ae5cc46e7..ee115b74379 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -1624,6 +1624,11 @@ static void rna_Object_active_modifier_set(PointerRNA *ptr, PointerRNA value, Re
Object *ob = (Object *)ptr->owner_id;
ModifierData *md = value.data;
+ if (RNA_pointer_is_null(&value)) {
+ BKE_object_modifier_set_active(ob, NULL);
+ return;
+ }
+
if (BLI_findindex(&ob->modifiers, md) == -1) {
BKE_reportf(
reports, RPT_ERROR, "Modifier \"%s\" is not in the object's modifier list", md->name);