Page MenuHome

Fix Modifier header and gain some space
Closed, ResolvedPublicTO DO

Description

Hi,
in interface_templates.c, line 902, we check for "modifier_couldBeCage".
If this condition is false, we add a dummy place holder.

This place holder takes space and should be removed for modifiers, that don't have this "editing cage" at all. (like Mesh Cache, Physics...)
What is the correct flag to check this on? I tried some things, but they always failed for certain modifiers, and the gap was still there then.

Would give us some space :)

Event Timeline

A modifier can potentially be a cage if and only if modifier_supportsMapping(md) returns true, so if you want to show the spacing if the modifier could potentially be a cage after changing settings, then use this.

But there is also the mti->isDisabled callback, which hides the cage button if for example the armature modifier has no armature object, or the subsurf modifier is at level 0. I guess this is the unexpected thing you encountered? If you want to hide the spacing if the modifier is disabled in this way, then you could use this check:

bool modifier_supportsCage(struct Scene *scene, ModifierData *md)
{
    ModifierTypeInfo *mti = modifierType_getInfo(md->type);

    md->scene = scene;

    return ((!mti->isDisabled || !mti->isDisabled(md, 0)) &&
            modifier_supportsMapping(md));
}

The spacing still seems somewhat arbitrary when using this, but not sure how it can be done better. The reason to have the spacing in the first place is to avoid the buttons changing position as you enable the modifier, so you don't misclick if you want to disable it again immediately.

Hi Brecht,
thanks for the input. This works ok and gives us the space in most situations, so I am happy with this already.
One thing that wonders me though, is that modifiers like "Cloth", still show the gap, but I can't find a way to make the button actually appear?

This happens because modifiers like cloth carry the "eModifierTypeType_OnlyDeform" flag and therefore "modifier_supportsMapping()" can be true.

Not sure it's worth to add more exceptions here, but still a bit annoying.

Current patch:

diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 65038c7..3275adf 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -321,6 +321,7 @@ void          modifier_unique_name(struct ListBase *modifiers, struct ModifierDa
 void          modifier_copyData(struct ModifierData *md, struct ModifierData *target);
 bool          modifier_dependsOnTime(struct ModifierData *md);
 bool          modifier_supportsMapping(struct ModifierData *md);
+bool          modifier_supportsCage(struct Scene *scene, struct ModifierData *md);
 bool          modifier_couldBeCage(struct Scene *scene, struct ModifierData *md);
 bool          modifier_isCorrectableDeformed(struct ModifierData *md);
 bool          modifier_isSameTopology(ModifierData *md);
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 4871b9b..c60867c 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -263,6 +263,17 @@ void modifier_copyData(ModifierData *md, ModifierData *target)
 		mti->copyData(md, target);
 }
 
+
+bool modifier_supportsCage(struct Scene *scene, ModifierData *md)
+{
+	ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+
+	md->scene = scene;
+
+	return ((!mti->isDisabled || !mti->isDisabled(md, 0)) &&
+			modifier_supportsMapping(md));
+}
+
 bool modifier_couldBeCage(struct Scene *scene, ModifierData *md)
 {
 	ModifierTypeInfo *mti = modifierType_getInfo(md->type);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index ba82728..f109d97 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -908,7 +908,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
 					uiButSetFlag(but, UI_BUT_DISABLED);
 				uiButSetFunc(but, modifiers_setOnCage, ob, md);
 			}
-			else {
+			else if (modifier_supportsCage(scene, md)) {
 				uiBlockEndAlign(block);
 
 				/* place holder button */
Thomas Dinges (dingto) changed the task status from Unknown Status to Resolved.Dec 13 2013, 8:59 PM
Thomas Dinges (dingto) claimed this task.

Commited, thanks!