[Bf-blender-cvs] [7b47eb1] depsgraph_refactor: Depsgraph: Fix for using bones as targets for hook modifier

Joshua Leung noreply at git.blender.org
Mon Jan 12 14:00:46 CET 2015


Commit: 7b47eb1276ad34312977d0c1e2fc1690767d7b2b
Author: Joshua Leung
Date:   Tue Jan 13 01:53:21 2015 +1300
Branches: depsgraph_refactor
https://developer.blender.org/rB7b47eb1276ad34312977d0c1e2fc1690767d7b2b

Depsgraph: Fix for using bones as targets for hook modifier

The hook modifier now depends on the bone component of the relevant bone
instead of the entire pose result. This makes it possible to interleave
relationships where different bones in the same armature depend on the hooked
geometry.

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

M	source/blender/depsgraph/DEG_depsgraph_build.h
M	source/blender/depsgraph/intern/depsgraph_build.cpp
M	source/blender/modifiers/intern/MOD_hook.c

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

diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 69c256b..93a5c77 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -102,6 +102,7 @@ typedef enum eDepsObjectComponentType {
 
 void DEG_add_scene_relation(struct DepsNodeHandle *node, struct Scene *scene, eDepsSceneComponentType component, const char *description);
 void DEG_add_object_relation(struct DepsNodeHandle *node, struct Object *ob, eDepsObjectComponentType component, const char *description);
+void DEG_add_bone_relation(struct DepsNodeHandle *handle, struct Object *ob, const char *bone_name, eDepsObjectComponentType component, const char *description);
 
 /* ************************************************ */
 
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index a99f22a..6917e46 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -144,6 +144,15 @@ void DEG_add_object_relation(DepsNodeHandle *handle, struct Object *ob, eDepsObj
 	handle->builder->add_node_handle_relation(comp_key, handle, DEPSREL_TYPE_GEOMETRY_EVAL, string(description));
 }
 
+void DEG_add_bone_relation(DepsNodeHandle *handle, struct Object *ob, const char *bone_name, eDepsObjectComponentType component, const char *description)
+{
+	eDepsNode_Type type = deg_build_object_component_type(component);
+	ComponentKey comp_key(&ob->id, type, bone_name);
+	
+	// XXX: "Geometry Eval" might not always be true, but this only gets called from modifier building now
+	handle->builder->add_node_handle_relation(comp_key, handle, DEPSREL_TYPE_GEOMETRY_EVAL, string(description));
+}
+
 /* ************************************************* */
 /* Utilities for Builders */
 
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index ed052cb..43f207d 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -127,11 +127,14 @@ static void updateDepsgraph(ModifierData *md,
 {
 	HookModifierData *hmd = (HookModifierData *)md;
 	if (hmd->object != NULL) {
-		if (hmd->subtarget[0])
+		if (hmd->subtarget[0]) {
 			/* TODO(sergey): Hpw do we add relation to bone here? */
-			DEG_add_object_relation(node, hmd->object, DEG_OB_COMP_EVAL_POSE, "Hook Modifier");
-		else
+			//DEG_add_object_relation(node, hmd->object, DEG_OB_COMP_EVAL_POSE, "Hook Modifier");
+			DEG_add_bone_relation(node, hmd->object, hmd->subtarget, DEG_OB_COMP_BONE, "Hook Modifier");
+		}
+		else {
 			DEG_add_object_relation(node, hmd->object, DEG_OB_COMP_TRANSFORM, "Hook Modifier");
+		}
 	}
 }




More information about the Bf-blender-cvs mailing list