From 266c90dc175ec2e8e75cee8fc66eff0c203d9f2f Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 1 Jun 2018 11:55:45 +0200 Subject: COW Fix - Motion paths were not drawing as they weren't getting copied --- source/blender/blenkernel/BKE_anim.h | 2 ++ source/blender/blenkernel/intern/anim.c | 21 +++++++++++++++++++++ source/blender/blenkernel/intern/object.c | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) 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); -- cgit v1.2.3