[Bf-blender-cvs] [4a0dea88bf2] blender2.8: WIP: Improved implementation of DEG_get_evaluated_rna_pointer()

Joshua Leung noreply at git.blender.org
Sat May 19 19:54:57 CEST 2018


Commit: 4a0dea88bf2cffdbf298b2e388d7c3698d2b6bad
Author: Joshua Leung
Date:   Sat May 19 19:12:26 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB4a0dea88bf2cffdbf298b2e388d7c3698d2b6bad

WIP: Improved implementation of DEG_get_evaluated_rna_pointer()

This now works by getting the RNA Path from the given PointerRNA to go from the
ID block to the data it points to, then uses this path to find the new data
relative to the COW ID.

Note: This currently still has all the debug prints left in - As can be seen,
I was testing this against the earlier PoseBone hack/special case. We may still
need to bring such special cases back in future, since looking up RNA Paths
like this can be slow.

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

M	source/blender/depsgraph/DEG_depsgraph_query.h
M	source/blender/depsgraph/intern/depsgraph_query.cc

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

diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index e77bf62bab6..99c5d2dc291 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -87,7 +87,7 @@ struct ID *DEG_get_evaluated_id(const struct Depsgraph *depsgraph,
 
 /* Get evaluated version of data pointed to by RNA pointer */
 void DEG_get_evaluated_rna_pointer(const struct Depsgraph *depsgraph,
-                                   const struct PointerRNA *ptr,
+                                   struct PointerRNA *ptr,
                                    struct PointerRNA *r_ptr_eval);
 
 /* Get original version of object for given evaluated one. */
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index 167e9e0e7d2..915668eba35 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -159,7 +159,7 @@ ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
 }
 
 /* Get evaluated version of data pointed to by RNA pointer */
-void DEG_get_evaluated_rna_pointer(const Depsgraph *depsgraph, const PointerRNA *ptr, PointerRNA *r_ptr_eval)
+void DEG_get_evaluated_rna_pointer(const Depsgraph *depsgraph, PointerRNA *ptr, PointerRNA *r_ptr_eval)
 {
 	if ((ptr == NULL) || (r_ptr_eval == NULL)) {
 		return;
@@ -174,20 +174,45 @@ void DEG_get_evaluated_rna_pointer(const Depsgraph *depsgraph, const PointerRNA
 	}
 	else {
 		/* XXX: Hack for common cases... Proper fix needs to be made still... A very tricky problem though! */
+		printf("DEG get evaluated ptr ----------------------\n");
 		if (ptr->type == &RNA_PoseBone) {
 			const Object *ob_eval = (Object *)DEG_get_evaluated_id(depsgraph, (ID *)ptr->id.data);
 			bPoseChannel *pchan = (bPoseChannel *)ptr->data;
 			const bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name);
 			/* XXX: Hack - This is just temporary... but this case must be supported. */
-			r_ptr_eval->id.data = (void *)&ob_eval->id;
-			r_ptr_eval->data = (void *)pchan_eval;
-			r_ptr_eval->type = ptr->type;
+			// r_ptr_eval->id.data = (void *)&ob_eval->id;
+			// r_ptr_eval->data = (void *)pchan_eval;
+			// r_ptr_eval->type = ptr->type;
+			printf("  orig id = %p, pchan = %p   ||  eval id = %p, pchan = %p\n",
+			       ptr->id.data, (void*)pchan, (void*)ob_eval, (void*)pchan_eval);
 		}
 		else {
 			/* FIXME: Maybe we should try resolving paths, or using some kind of depsgraph lookup? */
 			// XXX: For now, just use dirty hack, and hope it doesn't cause nasty issues.
 			*r_ptr_eval = *ptr;
 		}
+		
+		/* For everything else, try to get RNA Path of the BMain-pointer,
+		 * then use that to look up what the COW-domain one should be
+		 * given the COW ID pointer as the new lookup point
+		 */
+		char *path = RNA_path_from_ID_to_struct(ptr);
+		printf("  path  = '%s' (%p)\n", path, path);
+		if (path) {
+			ID *orig_id = (ID *)ptr->id.data;
+			ID *cow_id = DEG_get_evaluated_id(depsgraph, orig_id);
+			PointerRNA cow_id_ptr;
+			RNA_id_pointer_create(cow_id, &cow_id_ptr);
+			if (RNA_path_resolve(&cow_id_ptr, path, r_ptr_eval, NULL)) {
+				printf("  new pointer set - eval id = %p, ptr = %p\n",
+				       r_ptr_eval->id.data, r_ptr_eval->data);
+			}
+			else {
+				printf("  resolve failed\n");
+			}
+		}
+		
+		printf("----------------------------------------------\n");
 	}
 }



More information about the Bf-blender-cvs mailing list