Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2018-05-18 21:36:48 +0300
committerJoshua Leung <aligorith@gmail.com>2018-05-19 20:54:47 +0300
commit6ba28ff8b1658d69e2f4c1c92a8eeec230f573ba (patch)
tree003c742d994f8a05d3dba96444d2aac0e7a9cdd5 /source/blender/depsgraph/intern/depsgraph_query.cc
parent06737a82584c6be60a25b5f289e3fcd5c26b7aac (diff)
WIP COW Fix: Insert keyframe operators/api now queries depsgraph for evaluated data
When using copy on write, insert keyframe operators were reading from old bmain data instead of COW data. This meant that inserting keyframes would often read old/stale data, resulting in invalid keyframes getting created (e.g. from last transform operation, instead of actual current state). This commit makes it so that keyframing operators will ask depsgraph for the evaluated copy of the data, so that it can read values from that. It introduces a new function - `DEG_get_evaluated_rna_pointer()`, which when working correctly/fully, should work just like the other `DEG_get_evaluated_*()` functions, except it lets you pass in an RNA Pointer. However, currently, this is only done for Pose Bones (as a dirty hack, since this is an important/pivotal requirement for production) and/or datablock properties directly (since we can just use the DEG_get_evaluated_id() directly). on the datablock. Committing to a branch for now as this all needs more testing. More work to come later at a more sane time of day!
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph_query.cc')
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index fea28736627..167e9e0e7d2 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -33,15 +33,21 @@
#include "MEM_guardedalloc.h"
extern "C" {
+#include <string.h> // XXX: memcpy
+
#include "BLI_utildefines.h"
#include "BKE_idcode.h"
#include "BKE_main.h"
#include "BLI_listbase.h"
+
+#include "BKE_action.h" // XXX: BKE_pose_channel_from_name
} /* extern "C" */
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "RNA_access.h"
+
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@@ -152,6 +158,39 @@ ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
return id_node->id_cow;
}
+/* 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)
+{
+ if ((ptr == NULL) || (r_ptr_eval == NULL)) {
+ return;
+ }
+ if ((ptr->id.data == ptr->data)) {
+ ID *orig_id = (ID *)ptr->id.data;
+ ID *cow_id = DEG_get_evaluated_id(depsgraph, orig_id);
+ /* For ID pointers, it's easy... */
+ r_ptr_eval->id.data = (void *)cow_id;
+ r_ptr_eval->data = (void *)cow_id;
+ r_ptr_eval->type = ptr->type;
+ }
+ else {
+ /* XXX: Hack for common cases... Proper fix needs to be made still... A very tricky problem though! */
+ 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;
+ }
+ 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;
+ }
+ }
+}
+
Object *DEG_get_original_object(Object *object)
{
return (Object *)DEG_get_original_id(&object->id);