diff options
-rw-r--r-- | source/blender/depsgraph/DEG_depsgraph_query.h | 2 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_query.cc | 33 |
2 files changed, 30 insertions, 5 deletions
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"); } } |