[Bf-blender-cvs] [5c27c76ed3a] blender2.8: Depsgraph: fix relations for drivers on bone weight in Armature constraint.

Alexander Gavrilov noreply at git.blender.org
Wed Nov 14 12:11:07 CET 2018


Commit: 5c27c76ed3a9683c5d54745add6713eb562996e8
Author: Alexander Gavrilov
Date:   Wed Nov 14 14:01:28 2018 +0300
Branches: blender2.8
https://developer.blender.org/rB5c27c76ed3a9683c5d54745add6713eb562996e8

Depsgraph: fix relations for drivers on bone weight in Armature constraint.

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

M	source/blender/blenkernel/BKE_constraint.h
M	source/blender/blenkernel/intern/constraint.c
M	source/blender/depsgraph/intern/depsgraph.cc
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_constraint.c

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

diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index e7672001a15..bfcdcb68c4a 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -138,7 +138,7 @@ struct bConstraint *BKE_constraints_active_get(struct ListBase *list);
 void                BKE_constraints_active_set(ListBase *list, struct bConstraint *con);
 struct bConstraint *BKE_constraints_find_name(struct ListBase *list, const char *name);
 
-struct bConstraint *BKE_constraint_find_from_target(struct Object *ob, struct bConstraintTarget *tgt);
+struct bConstraint *BKE_constraint_find_from_target(struct Object *ob, struct bConstraintTarget *tgt, struct bPoseChannel **r_pchan);
 
 struct bConstraint *BKE_constraint_add_for_object(struct Object *ob, const char *name, short type);
 struct bConstraint *BKE_constraint_add_for_pose(struct Object *ob, struct bPoseChannel *pchan, const char *name, short type);
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index e16117745c9..8dfb50cd159 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -5058,8 +5058,12 @@ static bConstraint *constraint_list_find_from_target(ListBase *constraints, bCon
 }
 
 /* Finds the constraint that owns the given target within the object. */
-bConstraint *BKE_constraint_find_from_target(Object *ob, bConstraintTarget *tgt)
+bConstraint *BKE_constraint_find_from_target(Object *ob, bConstraintTarget *tgt, bPoseChannel **r_pchan)
 {
+	if (r_pchan != NULL) {
+		*r_pchan = NULL;
+	}
+
 	bConstraint *result = constraint_list_find_from_target(&ob->constraints, tgt);
 
 	if (result != NULL) {
@@ -5071,6 +5075,10 @@ bConstraint *BKE_constraint_find_from_target(Object *ob, bConstraintTarget *tgt)
 			result = constraint_list_find_from_target(&pchan->constraints, tgt);
 
 			if (result != NULL) {
+				if (r_pchan != NULL) {
+					*r_pchan = pchan;
+				}
+
 				return result;
 			}
 		}
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index d3c9560bcb1..7f47dce9f47 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -51,6 +51,7 @@ extern "C" {
 #include "RNA_access.h"
 
 #include "BKE_scene.h"
+#include "BKE_constraint.h"
 }
 
 #include <algorithm>
@@ -183,6 +184,25 @@ static bool pointer_to_component_node_criteria(
 			}
 		}
 	}
+	else if (ELEM(ptr->type, &RNA_ConstraintTarget, &RNA_ConstraintTargetBone)) {
+		Object *object = (Object *)ptr->id.data;
+		bConstraintTarget *tgt = (bConstraintTarget *)ptr->data;
+		/* Check whether is object or bone constraint. */
+		bPoseChannel *pchan = NULL;
+		bConstraint *con = BKE_constraint_find_from_target(object, tgt, &pchan);
+		if (con != NULL) {
+			if (pchan != NULL) {
+				*type = DEG_NODE_TYPE_BONE;
+				*operation_code = DEG_OPCODE_BONE_LOCAL;
+				*subdata = pchan->name;
+			}
+			else {
+				*type = DEG_NODE_TYPE_TRANSFORM;
+				*operation_code = DEG_OPCODE_TRANSFORM_LOCAL;
+			}
+			return true;
+		}
+	}
 	else if (RNA_struct_is_a(ptr->type, &RNA_Modifier)) {
 		*type = DEG_NODE_TYPE_GEOMETRY;
 		return true;
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 2f4d999c4fb..a74479e193c 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -198,6 +198,7 @@ extern StructRNA RNA_CompositorNodeZcombine;
 extern StructRNA RNA_ConsoleLine;
 extern StructRNA RNA_Constraint;
 extern StructRNA RNA_ConstraintTarget;
+extern StructRNA RNA_ConstraintTargetBone;
 extern StructRNA RNA_Context;
 extern StructRNA RNA_ControlFluidSettings;
 extern StructRNA RNA_Controller;
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index d7fd0aae917..898852739eb 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -314,7 +314,7 @@ static bConstraint *rna_constraint_from_target(PointerRNA *ptr)
 	Object *ob = ptr->id.data;
 	bConstraintTarget *tgt = ptr->data;
 
-	return BKE_constraint_find_from_target(ob, tgt);
+	return BKE_constraint_find_from_target(ob, tgt, NULL);
 }
 
 static char *rna_ConstraintTarget_path(PointerRNA *ptr)



More information about the Bf-blender-cvs mailing list