[Bf-blender-cvs] [b3fabb6] depsgraph_refactor: Depsgraph: Add support for a few more common datatypes to pointer_to_component_node_criteria()

Joshua Leung noreply at git.blender.org
Tue Jan 13 03:40:18 CET 2015


Commit: b3fabb69ad24e370f76be691a2c7433988a008b0
Author: Joshua Leung
Date:   Tue Jan 13 12:39:41 2015 +1300
Branches: depsgraph_refactor
https://developer.blender.org/rBb3fabb69ad24e370f76be691a2c7433988a008b0

Depsgraph: Add support for a few more common datatypes to pointer_to_component_node_criteria()

This is used by the RNAPathKey lookups, so supporting more types of data here should
ensure more node lookups to work successfully.

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

M	source/blender/depsgraph/intern/depsgraph.cpp

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

diff --git a/source/blender/depsgraph/intern/depsgraph.cpp b/source/blender/depsgraph/intern/depsgraph.cpp
index ea7d747..f6af060 100644
--- a/source/blender/depsgraph/intern/depsgraph.cpp
+++ b/source/blender/depsgraph/intern/depsgraph.cpp
@@ -26,10 +26,18 @@
  * Core routines for how the Depsgraph works
  */
 
+#include <string.h>
+
 #include "MEM_guardedalloc.h"
 
+#include "BLI_listbase.h"
+
 extern "C" {
 #include "DNA_action_types.h"
+#include "DNA_armature_types.h"
+#include "DNA_constraint_types.h"
+#include "DNA_key_types.h"
+#include "DNA_object_types.h"
 #include "DNA_sequence_types.h"
 }
 
@@ -96,16 +104,85 @@ static bool pointer_to_component_node_criteria(const PointerRNA *ptr,
 	/* Handling of commonly known scenarios... */
 	if (ptr->type == &RNA_PoseBone) {
 		bPoseChannel *pchan = (bPoseChannel *)ptr->data;
+		
 		/* Bone - generally, we just want the bone component... */
 		*type = DEPSNODE_TYPE_BONE;
 		*subdata = pchan->name;
+		
+		return true;
+	}
+	else if (ptr->type == &RNA_Bone) {
+		Bone *bone = (Bone *)ptr->data;
+		
+		/* armature-level bone, but it ends up going to bone component anyway */
+		// TODO: the ID in thise case will end up being bArmature, not Object as needed!
+		*type = DEPSNODE_TYPE_BONE;
+		*subdata = bone->name;
+		//*id = ...
+		
+		return true;
+	}
+	else if (RNA_struct_is_a(ptr->type, &RNA_Constraint)) {
+		Object *ob = (Object *)ptr->id.data;
+		bConstraint *con = (bConstraint *)ptr->data;
+		
+		/* object or bone? */
+		if (BLI_findindex(&ob->constraints, con) != -1) {
+			/* object transform */
+			// XXX: for now, we can't address the specific constraint or the constraint stack...
+			*type = DEPSNODE_TYPE_TRANSFORM;
+			return true;
+		}
+		else if (ob->pose) {
+			bPoseChannel *pchan;
+			for (pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+				if (BLI_findindex(&pchan->constraints, con) != -1) {
+					/* bone transforms */
+					*type = DEPSNODE_TYPE_BONE;
+					*subdata = pchan->name;
+					return true;
+				}
+			}
+		}
+	}
+	else if (RNA_struct_is_a(ptr->type, &RNA_Modifier)) {
+		//ModifierData *md = (ModifierData *)ptr->data;
+		
+		/* Modifier */
+		/* NOTE: subdata is not the same as "operation name", 
+		 * so although we have unique ops for modifiers,
+		 * we can't lump them together
+		 */
+		*type = DEPSNODE_TYPE_BONE;
+		//*subdata = md->name;
+		
 		return true;
 	}
 	else if (ptr->type == &RNA_Object) {
-		Object *ob = (Object *)ptr->data;
+		//Object *ob = (Object *)ptr->data;
+		
 		/* Transforms props? */
+		if (prop) {
+			const char *prop_identifier = RNA_property_identifier((PropertyRNA *)prop);
+			
+			if (strstr(prop_identifier, "location") ||
+			    strstr(prop_identifier, "rotation") ||
+			    strstr(prop_identifier, "scale"))
+			{
+				*type = DEPSNODE_TYPE_TRANSFORM;
+				return true;
+			}
+		}
 		// ...
-		(void)ob;  /* Currently ignored. */
+	}
+	else if (ptr->type == &RNA_ShapeKey) {
+		Key *key = (Key *)ptr->id.data;
+		
+		/* ShapeKeys are currently handled as geometry on the geometry that owns it */
+		*id = key->from; // XXX
+		*type = DEPSNODE_TYPE_GEOMETRY;
+		
+		return true;
 	}
 	else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) {
 		Sequence *seq = (Sequence *)ptr->data;
@@ -114,7 +191,8 @@ static bool pointer_to_component_node_criteria(const PointerRNA *ptr,
 		*subdata = seq->name; // xxx?
 		return true;
 	}
-	else if (prop) {
+	
+	if (prop) {
 		/* All unknown data effectively falls under "parameter evaluation" */
 		*type = DEPSNODE_TYPE_PARAMETERS;
 		return true;




More information about the Bf-blender-cvs mailing list