[Bf-blender-cvs] [4c02209] soc-2014-shapekey: Moved Object->shapeflag to Key->pin

Grigory Revzin noreply at git.blender.org
Mon May 19 00:36:27 CEST 2014


Commit: 4c02209769c79d98d5e74dabb3b9c16aac7f43e2
Author: Grigory Revzin
Date:   Mon May 19 01:56:01 2014 +0400
https://developer.blender.org/rB4c02209769c79d98d5e74dabb3b9c16aac7f43e2

Moved Object->shapeflag to Key->pin

Since we aren't going to use the shape key modifier for editmode blending,
Apply Shape Keys in Editmode is now obsolete too, and shapeflag just says
is the key is pinned or not.

Why to do this? In editmode, we want to be able to switch from Blending
shapekeys to pinned shapekeys and this is done in key RNA update handler,
so we want it to be called when pinning changes.

The RNA property was removed from the Object and added to the Key, all
code that referenced Object->shapeflag now references Key->pin.

The UI was updated to accomodate for that.

Unrelated change which I couldn't stage seperately is that there is now
support for temporary mix values from RNA and UI. The user can select
which one to use in Editmode. The value in the UI will automatically
reflect the editmix or the animation mix, transparent for the artist.

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

M	release/scripts/startup/bl_ui/properties_data_mesh.py
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/mesh/editmesh_utils.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 4c2829b..ba89074 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -72,6 +72,16 @@ class MESH_UL_vgroups(UIList):
             layout.label(text="", icon_value=icon)
 
 
+def draw_shape_value(ob, kb, layout, emboss=False, text=""):
+    key = ob.data.shape_keys
+    if (ob.mode == 'EDIT'):
+        if (key.mix_from_animation):
+            layout.prop(kb, "value", emboss=emboss, text=text)
+        else:
+            layout.prop(kb, "edit_mix_value", emboss=emboss, text='Temp ' + text)
+    else:
+        layout.prop(kb, "value", emboss=emboss, text=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)
@@ -82,10 +92,10 @@ class MESH_UL_shape_keys(UIList):
             split = layout.split(0.66, False)
             split.prop(key_block, "name", text="", emboss=False, icon_value=icon)
             row = split.row(align=True)
-            if key_block.mute or (obj.mode == 'EDIT' and not (obj.use_shape_key_edit_mode and obj.type == 'MESH')):
+            if key_block.mute:
                 row.active = False
             if not item.relative_key or index > 0:
-                row.prop(key_block, "value", text="", emboss=False)
+                draw_shape_value(obj, key_block, row)
             else:
                 row.label(text="")
             row.prop(key_block, "mute", text="", emboss=False)
@@ -220,7 +230,6 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
 
             layout.prop(context.tool_settings, "vertex_group_weight", text="Weight")
 
-
 class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
     bl_label = "Shape Keys"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -240,11 +249,6 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
         ts = context.scene.tool_settings
 
         enable_edit = ob.mode != 'EDIT'
-        enable_edit_value = False
-
-        if ob.show_only_shape_key is False:
-            if enable_edit or (ob.type == 'MESH' and ob.use_shape_key_edit_mode):
-                enable_edit_value = True
 
         row = layout.row()
 
@@ -275,16 +279,16 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
             row.enabled = enable_edit
             row.prop(key, "use_relative")
             row = split.row()
-            if ob.mode == 'EDIT':    
+            if ob.mode == 'ED   IT':    
                 row.prop(ts, "kb_auto_commit", text = "Auto-commit")
             row.alignment = 'RIGHT'
             sub = row.row(align=True)
             sub.label()  # XXX, for alignment only
             subsub = sub.row(align=True)
-            #subsub.active = enable_edit_value
-            subsub.prop(ob, "show_only_shape_key", text="")
-
-
+            if not enable_edit:
+                subsub.prop(key, "mix_from_animation", text="")
+            subsub.prop(key, "show_only_shape_key", text="")
+            
             sub = row.row()
             if key.use_relative:
                 sub.operator("object.shape_key_clear", icon='X', text="")
@@ -294,19 +298,18 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
             if key.use_relative:
                 if ob.active_shape_key_index != 0:
                     row = layout.row()
-                    row.active = enable_edit_value
-                    row.prop(kb, "value")
+                    draw_shape_value(ob, kb, row, emboss=True, text="Value")
 
                     split = layout.split()
 
                     col = split.column(align=True)
-                    col.active = enable_edit_value
+                    col.active = ob.mode != 'EDIT'
                     col.label(text="Range:")
                     col.prop(kb, "slider_min", text="Min")
                     col.prop(kb, "slider_max", text="Max")
 
                     col = split.column(align=True)
-                    col.active = enable_edit_value
+                    col.active = ob.mode != 'EDIT'
                     col.label(text="Blend:")
                     col.prop_search(kb, "vertex_group", ob, "vertex_groups", text="")
                     col.prop_search(kb, "relative_key", key, "key_blocks", text="")
@@ -388,3 +391,5 @@ 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/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index ba8fe83..74f4391 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -49,11 +49,13 @@
 #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"
 
@@ -224,6 +226,7 @@ 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
@@ -240,7 +243,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 && (object->shapeflag & OB_SHAPE_LOCK) == 0;
+		deformed |= object->sculpt->kb && (key && key->pin) == 0;
 	}
 
 	return deformed;
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 2157909..2771220 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -2039,6 +2039,7 @@ 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;
 		
@@ -2046,7 +2047,7 @@ static void dag_object_time_update_flags(Main *bmain, Scene *scene, Object *ob)
 			case OB_MESH:
 				me = ob->data;
 				if (me->key) {
-					if (!(ob->shapeflag & OB_SHAPE_LOCK)) {
+					if (!key->pin) {
 						ob->recalc |= OB_RECALC_DATA;
 					}
 				}
@@ -2057,7 +2058,7 @@ static void dag_object_time_update_flags(Main *bmain, Scene *scene, Object *ob)
 			case OB_SURF:
 				cu = ob->data;
 				if (cu->key) {
-					if (!(ob->shapeflag & OB_SHAPE_LOCK)) {
+					if (!key->pin) {
 						ob->recalc |= OB_RECALC_DATA;
 					}
 				}
@@ -2070,7 +2071,7 @@ static void dag_object_time_update_flags(Main *bmain, Scene *scene, Object *ob)
 			case OB_LATTICE:
 				lt = ob->data;
 				if (lt->key) {
-					if (!(ob->shapeflag & OB_SHAPE_LOCK)) {
+					if (!key->pin) {
 						ob->recalc |= OB_RECALC_DATA;
 					}
 				}
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 87e498b..d1f75fd 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -1461,7 +1461,7 @@ float *BKE_key_evaluate_object_ex(Scene *scene, Object *ob, int *r_totelem,
 	/* prevent python from screwing this up? anyhoo, the from pointer could be dropped */
 	key->from = (ID *)ob->data;
 		
-	if (ob->shapeflag & OB_SHAPE_LOCK) {
+	if (key->pin) {
 		/* shape locked, copy the locked shape instead of blending */
 		KeyBlock *kb = BLI_findlink(&key->block, ob->shapenr - 1);
 		
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 5638316..5f8a2e1 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -48,6 +48,7 @@
 #include "DNA_armature_types.h"
 #include "DNA_object_types.h"
 #include "DNA_meshdata_types.h"
+#include "DNA_key_types.h"
 
 #include "BLI_utildefines.h"
 #include "BLI_path_util.h"
@@ -516,10 +517,11 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob, VirtualModifierData *
 			md = &virtualModifierData->lmd.modifier;
 		}
 	}
+	Key* key = BKE_key_from_object(ob);
 
 	/* shape key modifier, not yet for curves */
-	if (ELEM(ob->type, OB_MESH, OB_LATTICE) && BKE_key_from_object(ob)) {
-		if (ob->type == OB_MESH && (ob->shapeflag & OB_SHAPE_EDIT_MODE))
+	if (ELEM(ob->type, OB_MESH, OB_LATTICE) && key) {
+		if (ob->type == OB_MESH && key->pin)
 			virtualModifierData->smd.modifier.mode |= eModifierMode_Editmode | eModifierMode_OnCage;
 		else
 			virtualModifierData->smd.modifier.mode &= ~eModifierMode_Editmode | eModifierMode_OnCage;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index d99086a..c5c8786 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2897,7 +2897,7 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
 			
 			key = BKE_key_from_object(ob);
 			if (key && key->block.first) {
-				if (!(ob->shapeflag & OB_SHAPE_LOCK))
+				if (!key->pin)
 					BKE_animsys_evaluate_animdata(scene, &key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
 			}
 
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 24616d88..411ab8a 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -41,6 +41,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_brush_types.h"
 #include "DNA_space_types.h"
+#include "DNA_key_types.h"
 
 #include "BLI_bitmap.h"
 #include "BLI_utildefines.h"
@@ -546,12 +547,12 @@ static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
 	Mesh *me = (Mesh *)ob->data;
 	MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
 	VirtualModifierData virtualModifierData;
-
+	Key *key = BKE_key_from_object(ob);
 	if (mmd || ob->sculpt->bm)
 		return 0;
 


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list