diff options
author | Jacques Lucke <jacques@blender.org> | 2020-11-06 19:33:00 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-11-06 19:33:13 +0300 |
commit | 37ef37711d997899041d84e8c7a17e1fbb4efab9 (patch) | |
tree | e27bdc0042524a585074285360e618c20e00ef9d | |
parent | a3a6443bfd8ac16824bdbf349913696531f348a1 (diff) |
Refactor: move MotionPath .blend I/O to blenkernel
Ref T76372.
-rw-r--r-- | source/blender/blenkernel/BKE_anim_visualization.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim_visualization.c | 31 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 21 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 19 |
4 files changed, 42 insertions, 34 deletions
diff --git a/source/blender/blenkernel/BKE_anim_visualization.h b/source/blender/blenkernel/BKE_anim_visualization.h index fb7875a112e..decb2e0b210 100644 --- a/source/blender/blenkernel/BKE_anim_visualization.h +++ b/source/blender/blenkernel/BKE_anim_visualization.h @@ -32,6 +32,8 @@ struct Scene; struct bAnimVizSettings; struct bMotionPath; struct bPoseChannel; +struct BlendWriter; +struct BlendDataReader; /* ---------------------------------------------------- */ /* Animation Visualization */ @@ -48,6 +50,9 @@ struct bMotionPath *animviz_verify_motionpaths(struct ReportList *reports, struct Object *ob, struct bPoseChannel *pchan); +void animviz_motionpath_blend_write(struct BlendWriter *writer, struct bMotionPath *mpath); +void animviz_motionpath_blend_read_data(struct BlendDataReader *reader, struct bMotionPath *mpath); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/anim_visualization.c b/source/blender/blenkernel/intern/anim_visualization.c index 5452e2513fb..ecd71ec08fe 100644 --- a/source/blender/blenkernel/intern/anim_visualization.c +++ b/source/blender/blenkernel/intern/anim_visualization.c @@ -34,6 +34,8 @@ #include "GPU_batch.h" +#include "BLO_read_write.h" + /* ******************************************************************** */ /* Animation Visualization */ @@ -224,3 +226,32 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, /* return it */ return mpath; } + +void animviz_motionpath_blend_write(BlendWriter *writer, bMotionPath *mpath) +{ + /* sanity checks */ + if (mpath == NULL) { + return; + } + + /* firstly, just write the motionpath struct */ + BLO_write_struct(writer, bMotionPath, mpath); + + /* now write the array of data */ + BLO_write_struct_array(writer, bMotionPathVert, mpath->length, mpath->points); +} + +void animviz_motionpath_blend_read_data(BlendDataReader *reader, bMotionPath *mpath) +{ + /* sanity check */ + if (mpath == NULL) { + return; + } + + /* relink points cache */ + BLO_read_data_address(reader, &mpath->points); + + mpath->points_vbo = NULL; + mpath->batch_line = NULL; + mpath->batch_points = NULL; +} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2b93f5222db..77a1925d444 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -113,6 +113,7 @@ #include "BKE_action.h" #include "BKE_anim_data.h" +#include "BKE_anim_visualization.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_brush.h" @@ -2912,22 +2913,6 @@ static void lib_link_object(BlendLibReader *reader, Object *ob) } } -/* direct data for cache */ -static void direct_link_motionpath(BlendDataReader *reader, bMotionPath *mpath) -{ - /* sanity check */ - if (mpath == NULL) { - return; - } - - /* relink points cache */ - BLO_read_data_address(reader, &mpath->points); - - mpath->points_vbo = NULL; - mpath->batch_line = NULL; - mpath->batch_points = NULL; -} - static void direct_link_pose(BlendDataReader *reader, bPose *pose) { if (!pose) { @@ -2959,7 +2944,7 @@ static void direct_link_pose(BlendDataReader *reader, bPose *pose) BLO_read_data_address(reader, &pchan->mpath); if (pchan->mpath) { - direct_link_motionpath(reader, pchan->mpath); + animviz_motionpath_blend_read_data(reader, pchan->mpath); } BLI_listbase_clear(&pchan->iktree); @@ -3005,7 +2990,7 @@ static void direct_link_object(BlendDataReader *reader, Object *ob) BLO_read_data_address(reader, &ob->mpath); if (ob->mpath) { - direct_link_motionpath(reader, ob->mpath); + animviz_motionpath_blend_read_data(reader, ob->mpath); } BLO_read_list(reader, &ob->defbase); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index ea3c81ba121..d9c629eaf4d 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -129,6 +129,7 @@ #include "BKE_action.h" #include "BKE_anim_data.h" +#include "BKE_anim_visualization.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_blender_version.h" @@ -810,20 +811,6 @@ static void write_userdef(BlendWriter *writer, const UserDef *userdef) } } -static void write_motionpath(BlendWriter *writer, bMotionPath *mpath) -{ - /* sanity checks */ - if (mpath == NULL) { - return; - } - - /* firstly, just write the motionpath struct */ - BLO_write_struct(writer, bMotionPath, mpath); - - /* now write the array of data */ - BLO_write_struct_array(writer, bMotionPathVert, mpath->length, mpath->points); -} - static void write_constraints(BlendWriter *writer, ListBase *conlist) { LISTBASE_FOREACH (bConstraint *, con, conlist) { @@ -895,7 +882,7 @@ static void write_pose(BlendWriter *writer, bPose *pose, bArmature *arm) write_constraints(writer, &chan->constraints); - write_motionpath(writer, chan->mpath); + animviz_motionpath_blend_write(writer, chan->mpath); /* Prevent crashes with autosave, * when a bone duplicated in edit-mode has not yet been assigned to its pose-channel. @@ -980,7 +967,7 @@ static void write_object(BlendWriter *writer, Object *ob, const void *id_address write_defgroups(writer, &ob->defbase); write_fmaps(writer, &ob->fmaps); write_constraints(writer, &ob->constraints); - write_motionpath(writer, ob->mpath); + animviz_motionpath_blend_write(writer, ob->mpath); BLO_write_struct(writer, PartDeflect, ob->pd); if (ob->soft) { |