diff options
author | Joshua Leung <aligorith@gmail.com> | 2018-06-01 12:55:45 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2018-06-01 12:55:45 +0300 |
commit | 266c90dc175ec2e8e75cee8fc66eff0c203d9f2f (patch) | |
tree | 6d5efbc9dc4c16abf0cbe250d94330fb55f858ee | |
parent | bc4bfef20924d25441170430ebac47435d3ef356 (diff) |
COW Fix - Motion paths were not drawing as they weren't getting copied
-rw-r--r-- | source/blender/blenkernel/BKE_anim.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim.c | 21 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 2 |
3 files changed, 24 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h index 0fb83162459..701be9d44cc 100644 --- a/source/blender/blenkernel/BKE_anim.h +++ b/source/blender/blenkernel/BKE_anim.h @@ -48,6 +48,8 @@ struct Main; void animviz_settings_init(struct bAnimVizSettings *avs); +struct bMotionPath *animviz_copy_motionpath(const struct bMotionPath *mpath_src); + void animviz_free_motionpath_cache(struct bMotionPath *mpath); void animviz_free_motionpath(struct bMotionPath *mpath); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 674cf545ec6..8d420cd2d71 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -141,6 +141,27 @@ void animviz_free_motionpath(bMotionPath *mpath) /* ------------------- */ +/* Make a copy of motionpath data, so that viewing with copy on write works */ +bMotionPath *animviz_copy_motionpath(const bMotionPath *mpath_src) +{ + bMotionPath *mpath_dst; + + if (mpath_src == NULL) + return NULL; + + mpath_dst = MEM_dupallocN(mpath_src); + mpath_dst->points = MEM_dupallocN(mpath_src->points); + + /* should get recreated on draw... */ + mpath_dst->points_vbo = NULL; + mpath_dst->batch_line = NULL; + mpath_dst->batch_points = NULL; + + return mpath_dst; +} + +/* ------------------- */ + /** * Setup motion paths for the given data. * \note Only used when explicitly calculating paths on bones which may/may not be consider already diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 8e50d1b32e1..bd004b9b6a8 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1199,7 +1199,7 @@ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object *ob_ BLI_listbase_clear(&ob_dst->drawdata); BLI_listbase_clear(&ob_dst->pc_ids); - ob_dst->mpath = NULL; + ob_dst->mpath = animviz_copy_motionpath(ob_src->mpath); copy_object_lod(ob_dst, ob_src, flag_subdata); |