New modifier type: eModifierTypeType_NonGeometrical, for modifiers affecting CustomDa...
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 20 Dec 2011 14:15:59 +0000 (14:15 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 20 Dec 2011 14:15:59 +0000 (14:15 +0000)
Also, allow applying to obdata those modifiers, even with shapekeys, but do not allow applying them *as* shapekey (as shapekeys do not have CD layers).

Fix [#29636] Vertex Weight Mix modifier "apply" button don't work.

Note: applying whit shape keys currently always uses base shape, not current one (for apply to obdata as well as apply to shapekey), but this is another topic...

source/blender/blenkernel/BKE_modifier.h
source/blender/blenkernel/intern/modifier.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/object/object_modifier.c
source/blender/modifiers/intern/MOD_uvproject.c
source/blender/modifiers/intern/MOD_weightvgedit.c
source/blender/modifiers/intern/MOD_weightvgmix.c
source/blender/modifiers/intern/MOD_weightvgproximity.c

index 84f8995b4800a58b6fa73ac78d2632657f583f49..23073a2d8eb82b9ed2e3d87bd4c52ea25146c64e 100644 (file)
@@ -65,6 +65,11 @@ typedef enum {
         * unless it's a mesh and can be exploded -> curve can also emit particles
         */
        eModifierTypeType_DeformOrConstruct,
+
+       /* Like eModifierTypeType_Nonconstructive, but does not affect the geometry
+        * of the object, rather some of its CustomData layers.
+        * E.g. UVProject and WeightVG modifiers. */
+       eModifierTypeType_NonGeometrical,
 } ModifierTypeType;
 
 typedef enum {
@@ -311,6 +316,7 @@ int           modifier_supportsMapping(struct ModifierData *md);
 int           modifier_couldBeCage(struct Scene *scene, struct ModifierData *md);
 int           modifier_isCorrectableDeformed(struct ModifierData *md);
 int                      modifier_sameTopology(ModifierData *md);
+int           modifier_nonGeometrical(ModifierData *md);
 int           modifier_isEnabled(struct Scene *scene, struct ModifierData *md, int required_mode);
 void          modifier_setError(struct ModifierData *md, const char *format, ...)
 #ifdef __GNUC__
index f09be8c34ad220bcd0af4ed2c358c01823ca28f3..5a389019519b64ed8acd39c43dfe6bb130bb3683 100644 (file)
@@ -239,7 +239,14 @@ int modifier_couldBeCage(struct Scene *scene, ModifierData *md)
 int modifier_sameTopology(ModifierData *md)
 {
        ModifierTypeInfo *mti = modifierType_getInfo(md->type);
-       return ( mti->type == eModifierTypeType_OnlyDeform || mti->type == eModifierTypeType_Nonconstructive);
+       return ELEM3(mti->type, eModifierTypeType_OnlyDeform, eModifierTypeType_Nonconstructive,
+                    eModifierTypeType_NonGeometrical);
+}
+
+int modifier_nonGeometrical(ModifierData *md)
+{
+       ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+       return (mti->type == eModifierTypeType_NonGeometrical);
 }
 
 void modifier_setError(ModifierData *md, const char *format, ...)
index 7f01d4f031da5683f6be81c5679b08990e84c75b..49e3ff10f06e183a8914ad0041988afde57b0ae1 100644 (file)
@@ -845,7 +845,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
                                uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
                                uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply"), 0, "apply_as", MODIFIER_APPLY_DATA);
                                
-                               if (modifier_sameTopology(md))
+                               if (modifier_sameTopology(md) && !modifier_nonGeometrical(md))
                                        uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply as Shape"), 0, "apply_as", MODIFIER_APPLY_SHAPE);
                        }
                        
@@ -853,7 +853,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
                        uiBlockSetButLock(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE);
                        
                        if (!ELEM5(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem, eModifierType_Cloth, eModifierType_Smoke))
-                               uiItemO(row, TIP_("Copy"), ICON_NONE, "OBJECT_OT_modifier_copy");
+                               uiItemO(row, IFACE_("Copy"), ICON_NONE, "OBJECT_OT_modifier_copy");
                }
                
                /* result is the layout block inside the box, that we return so that modifier settings can be drawn */
index 240fb8017f2d2272e8e5aa2a4bcc4b39372f8c03..913e5893a779ca58bb6968c430a158494fa3ae63 100644 (file)
@@ -452,7 +452,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M
                Key *key=me->key;
                KeyBlock *kb;
                
-               if(!modifier_sameTopology(md)) {
+               if(!modifier_sameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) {
                        BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to Shapes");
                        return 0;
                }
@@ -500,7 +500,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob,
                Mesh *me = ob->data;
                MultiresModifierData *mmd= find_multires_modifier_before(scene, md);
 
-               if( me->key) {
+               if(me->key && mti->type != eModifierTypeType_NonGeometrical) {
                        BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to Mesh with Shape Keys");
                        return 0;
                }
index 71292c6e5211f17abef3e95f5ce8d8d8d574444c..38c2073b6a5c80f93e447b66eed0ded6eefb2be6 100644 (file)
@@ -407,7 +407,7 @@ ModifierTypeInfo modifierType_UVProject = {
        /* name */              "UVProject",
        /* structName */        "UVProjectModifierData",
        /* structSize */        sizeof(UVProjectModifierData),
-       /* type */              eModifierTypeType_Nonconstructive,
+       /* type */              eModifierTypeType_NonGeometrical,
        /* flags */             eModifierTypeFlag_AcceptsMesh
                                                        | eModifierTypeFlag_SupportsMapping
                                                        | eModifierTypeFlag_SupportsEditmode
index 9721ee042bf88b047a42e741ab6bc2a4e2c3620b..bdd7ab7486bc336a14481f1066bd4d883b444c6a 100644 (file)
@@ -254,7 +254,7 @@ ModifierTypeInfo modifierType_WeightVGEdit = {
        /* name */              "VertexWeightEdit",
        /* structName */        "WeightVGEditModifierData",
        /* structSize */        sizeof(WeightVGEditModifierData),
-       /* type */              eModifierTypeType_Nonconstructive,
+       /* type */              eModifierTypeType_NonGeometrical,
        /* flags */             eModifierTypeFlag_AcceptsMesh
 /*                            |eModifierTypeFlag_SupportsMapping*/
                               |eModifierTypeFlag_SupportsEditmode,
index fd7e47cc4bf13dac069a74baee9f2150e70c3d5e..17316d891dafa6c188e277ce5fbe5ec32cb86386 100644 (file)
@@ -386,7 +386,7 @@ ModifierTypeInfo modifierType_WeightVGMix = {
        /* name */              "VertexWeightMix",
        /* structName */        "WeightVGMixModifierData",
        /* structSize */        sizeof(WeightVGMixModifierData),
-       /* type */              eModifierTypeType_Nonconstructive,
+       /* type */              eModifierTypeType_NonGeometrical,
        /* flags */             eModifierTypeFlag_AcceptsMesh
 /*                            |eModifierTypeFlag_SupportsMapping*/
                               |eModifierTypeFlag_SupportsEditmode,
index 9b5678a3f3b28c06ad48d2b0784f9bb3efd5087d..f67fd907d02b8a09aeb2caa31a23c2d42fdea94b 100644 (file)
@@ -520,7 +520,7 @@ ModifierTypeInfo modifierType_WeightVGProximity = {
        /* name */              "VertexWeightProximity",
        /* structName */        "WeightVGProximityModifierData",
        /* structSize */        sizeof(WeightVGProximityModifierData),
-       /* type */              eModifierTypeType_Nonconstructive,
+       /* type */              eModifierTypeType_NonGeometrical,
        /* flags */             eModifierTypeFlag_AcceptsMesh
 /*                            |eModifierTypeFlag_SupportsMapping*/
                               |eModifierTypeFlag_SupportsEditmode,