[Bf-blender-cvs] [63a7fbe] soc-2014-shapekey: Reverting getting rid of Apply Shape Keys in EM

Grigory Revzin noreply at git.blender.org
Thu Jun 5 13:39:44 CEST 2014


Commit: 63a7fbe3a0c500991b2dfacfa0651564a2ffb234
Author: Grigory Revzin
Date:   Thu Jun 5 15:35:26 2014 +0400
https://developer.blender.org/rB63a7fbe3a0c500991b2dfacfa0651564a2ffb234

Reverting getting rid of Apply Shape Keys in EM

This turned out to be a bad idea after all. Now, Apply Shape Keys in
Editmode works as it did before. Shape recalc hasn't been changed.
Key->pin moved back to object->shapeflag.

Apply Shape Keys in Editmode is made to be aware of the alternative
editmode mix and the user can switch between them.

===================================================================

M	release/scripts/startup/bl_ui/properties_data_mesh.py
M	source/blender/blenkernel/BKE_key.h
M	source/blender/blenkernel/intern/cdderivedmesh.c
M	source/blender/blenkernel/intern/depsgraph.c
M	source/blender/blenkernel/intern/key.c
M	source/blender/blenkernel/intern/modifier.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/include/ED_mesh.h
M	source/blender/editors/mesh/editmesh_utils.c
M	source/blender/editors/object/object_shapekey.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/makesdna/DNA_key_types.h
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesrna/intern/rna_key.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/modifiers/intern/MOD_shapekey.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index b3a5fca..b99e8dd 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -61,7 +61,7 @@ class MESH_MT_shape_key_specials(Menu):
 
 class MESH_UL_vgroups(UIList):
     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
-        # assert(isinstance(item, bpy.types.VertexGroup))
+        # assert(isinstance(item, bpy.types.VertexGroup)
         vgroup = item
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
             layout.prop(vgroup, "name", text="", emboss=False, icon_value=icon)
@@ -84,7 +84,7 @@ def draw_shape_value(ob, kb, layout, emboss=False, text=""):
 
 class MESH_UL_shape_keys(UIList):
     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
-        # assert(isinstance(item, bpy.types.ShapeKey))
+        # assert(isinstance(item, bpy.types.ShapeKey)
         obj = active_data
         # key = data
         key_block = item
@@ -106,7 +106,7 @@ class MESH_UL_shape_keys(UIList):
 
 class MESH_UL_uvmaps_vcols(UIList):
     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
-        # assert(isinstance(item, (bpy.types.MeshTexturePolyLayer, bpy.types.MeshLoopColorLayer)))
+        # assert(isinstance(item, (bpy.types.MeshTexturePolyLayer, bpy.types.MeshLoopColorLayer))
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
             layout.prop(item, "name", text="", emboss=False, icon_value=icon)
             icon = 'RESTRICT_RENDER_OFF' if item.active_render else 'RESTRICT_RENDER_ON'
@@ -248,7 +248,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
         kb = ob.active_shape_key
         ts = context.scene.tool_settings
 
-        enable_edit = ob.mode != 'EDIT'
+        in_editmode = ob.mode == 'EDIT'
 
         row = layout.row()
 
@@ -276,7 +276,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
 
             split = layout.split(percentage=0.4)
             row = split.row()
-            row.enabled = enable_edit
+            row.enabled = not in_editmode
             row.prop(key, "use_relative")
             row = split.row()
             if ob.mode == 'ED   IT':    
@@ -285,10 +285,14 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
             sub = row.row(align=True)
             sub.label()  # XXX, for alignment only
             subsub = sub.row(align=True)
-            if not enable_edit:
-                subsub.prop(key, "mix_from_animation", text="")
-            subsub.prop(key, "show_only_shape_key", text="")
-            
+
+            if in_editmode:
+                if ob.type == 'MESH':
+                    subsub.prop(key, "mix_from_animation", text="")
+                    subsub.prop(ob, "use_shape_key_edit_mode", text="")
+            else:
+                subsub.prop(ob, "show_only_shape_key", text="")
+                    
             sub = row.row()
             if key.use_relative:
                 sub.operator("object.shape_key_clear", icon='X', text="")
@@ -317,7 +321,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
             else:
                 layout.prop(kb, "interpolation")
                 row = layout.column()
-                row.active = enable_edit_value
+                row.active = ob.mode != 'EDIT'
                 row.prop(key, "eval_time")
                 row.prop(key, "slurph")
 
@@ -391,5 +395,3 @@ class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, Panel):
 
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)
-
-
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index ce8da7d..e56cba4 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -79,7 +79,7 @@ void      BKE_keyblock_copy_settings(KeyBlock *kb_dst, const KeyBlock *kb_src);
 char     *BKE_keyblock_curval_rnapath_get(Key *key, KeyBlock *kb);
 
 /* returns a pointer to active shape value (mixval/anim-driven val) */
-float    *BKE_keyblock_get_active_value(Key *key, KeyBlock *kb);
+float    *BKE_keyblock_get_active_value(Object *ob, KeyBlock *kb);
 
 /* ==== scratch keyblock ==== */
 
@@ -111,7 +111,7 @@ typedef struct WeightsArrayCache {
 
 float **BKE_keyblock_get_per_block_weights(Object *ob, Key *key, WeightsArrayCache *cache);
 void BKE_keyblock_free_per_block_weights(Key *key, float **per_keyblock_weights, WeightsArrayCache *cache);
-void BKE_key_evaluate_relative(const int start, int end, const int tot, char *basispoin, Key *key, KeyBlock *actkb,
+void BKE_key_evaluate_relative(Object *ob, const int start, int end, const int tot, char *basispoin, Key *key, KeyBlock *actkb,
                                float **per_keyblock_weights, const int mode);
 
 /* conversion functions */
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 2d76af0..9df527e 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -49,13 +49,11 @@
 #include "BKE_paint.h"
 #include "BKE_editmesh.h"
 #include "BKE_curve.h"
-#include "BKE_key.h"
 
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
 #include "DNA_curve_types.h" /* for Curve */
-#include "DNA_key_types.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -226,7 +224,6 @@ static const MeshElemMap *cdDM_getPolyMap(Object *ob, DerivedMesh *dm)
 
 static bool check_sculpt_object_deformed(Object *object, bool for_construction)
 {
-	Key *key = BKE_key_from_object(object);
 	bool deformed = false;
 
 	/* Active modifiers means extra deformation, which can't be handled correct
@@ -243,7 +240,7 @@ static bool check_sculpt_object_deformed(Object *object, bool for_construction)
 		 * PBVH and non-locked keyblock, so also use PBVH only for brushes and
 		 * final DM to give final result to user.
 		 */
-		deformed |= object->sculpt->kb && (key && key->pin) == 0;
+		deformed |= object->sculpt->kb && (object->shapeflag & OB_SHAPE_LOCK) == 0;
 	}
 
 	return deformed;
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 2771220..2157909 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -2039,7 +2039,6 @@ static void dag_object_time_update_flags(Main *bmain, Scene *scene, Object *ob)
 	{
 		AnimData *adt = BKE_animdata_from_id((ID *)ob->data);
 		Mesh *me;
-		Key *key = BKE_key_from_object(ob);
 		Curve *cu;
 		Lattice *lt;
 		
@@ -2047,7 +2046,7 @@ static void dag_object_time_update_flags(Main *bmain, Scene *scene, Object *ob)
 			case OB_MESH:
 				me = ob->data;
 				if (me->key) {
-					if (!key->pin) {
+					if (!(ob->shapeflag & OB_SHAPE_LOCK)) {
 						ob->recalc |= OB_RECALC_DATA;
 					}
 				}
@@ -2058,7 +2057,7 @@ static void dag_object_time_update_flags(Main *bmain, Scene *scene, Object *ob)
 			case OB_SURF:
 				cu = ob->data;
 				if (cu->key) {
-					if (!key->pin) {
+					if (!(ob->shapeflag & OB_SHAPE_LOCK)) {
 						ob->recalc |= OB_RECALC_DATA;
 					}
 				}
@@ -2071,7 +2070,7 @@ static void dag_object_time_update_flags(Main *bmain, Scene *scene, Object *ob)
 			case OB_LATTICE:
 				lt = ob->data;
 				if (lt->key) {
-					if (!key->pin) {
+					if (!(ob->shapeflag & OB_SHAPE_LOCK)) {
 						ob->recalc |= OB_RECALC_DATA;
 					}
 				}
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 153a8e2..03c6422 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -741,7 +741,7 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const
 }
 
 
-void BKE_key_evaluate_relative(const int start, int end, const int tot, char *basispoin, Key *key, KeyBlock *actkb,
+void BKE_key_evaluate_relative(Object *ob, const int start, int end, const int tot, char *basispoin, Key *key, KeyBlock *actkb,
                                float **per_keyblock_weights, const int mode)
 {
 	KeyBlock *kb;
@@ -770,10 +770,9 @@ void BKE_key_evaluate_relative(const int start, int end, const int tot, char *ba
 	cp_key(start, end, tot, basispoin, key, actkb, key->refkey, NULL, mode);
 	
 	/* step 2: do it */
-	
-	for (kb = key->block.first, keyblock_index = 0; kb; kb = kb->next, keyblock_index++) {
+	LISTBASE_ITER_FWD_INDEX(key->block, kb, keyblock_index) {
 		if (kb != key->refkey) {
-			float icuval = kb->curval;
+			float icuval = *BKE_keyblock_get_active_value(ob, kb);
 			
 			/* only with value, and no difference allowed */
 			if (!(kb->flag & KEYBLOCK_MUTE) && icuval != 0.0f && kb->totelem == tot) {
@@ -1219,7 +1218,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int
 			WeightsArrayCache cache = {0, NULL};
 			float **per_keyblock_weights;
 			per_keyblock_weights = BKE_keyblock_get_per_block_weights(ob, key, &cache);
-			BKE_key_evaluate_relative(0, tot, tot, (char *)out, key, actkb, per_keyblock_weights, KEY_MODE_DUMMY);
+			BKE_key_evaluate_relative(ob, 0, tot, tot, (char *)out, key, actkb, per_keyblock_weights, KEY_MODE_DUMMY);
 			BKE_keyblock_free_per_block_weights(key, per_keyblock_weights, &cache);
 		}
 		else {
@@ -1255,19 +1254,20 @@ static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float
 	}
 }
 
-static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, char *out, const int tot)
+static void do_rel_cu_key(Object *ob, Key *key, KeyBlock *actkb, char *out, const int tot)
 {
+	Curve *cu = ob->data;
 	Nurb *nu;
 	int a, step;
 	
 	for (a = 0, nu = cu->nurb.first; nu; nu = nu->next, a += step) {
 		if (nu->bp) {
 			step = nu->pntsu * nu->pntsv;
-			BKE_key_evaluate_relative(a, a + step, tot, out, key, actkb, NULL, KEY_MODE_BPOINT);
+			BKE_key_evaluate_relative(ob, a, a + step, tot, out, key, actkb, NULL, KEY_MODE_BPOINT);
 		}
 		else if (nu->bezt) {
 			step = 3 * nu->pntsu;
-			BKE_key_evaluate_relative(a, a + step, tot, out, key, actkb, NULL, KEY_MODE_BEZTRI

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list