diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-06-06 23:47:41 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-06-09 02:15:17 +0300 |
commit | cc31d7bb49090194e13fc4ebe58bb8f7f63f4186 (patch) | |
tree | 14727b9362cca5c15300c1f76dc45240cd9030b4 /source/blender/blenloader | |
parent | 346619159ae39dfb4063f563d498eec32bba13aa (diff) |
Probe: Add new object datablock
We went for a new datablock because blending probe functionality with empties was going to be messy.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 35 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 17 |
2 files changed, 52 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 8e89c61d9f7..dcf0a596779 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -89,6 +89,7 @@ #include "DNA_object_types.h" #include "DNA_packedFile_types.h" #include "DNA_particle_types.h" +#include "DNA_probe_types.h" #include "DNA_property_types.h" #include "DNA_rigidbody_types.h" #include "DNA_text_types.h" @@ -7645,6 +7646,26 @@ static void fix_relpaths_library(const char *basepath, Main *main) } } +/* ************ READ PROBE ***************** */ + +static void lib_link_probe(FileData *fd, Main *main) +{ + for (Probe *prb = main->speaker.first; prb; prb = prb->id.next) { + if (prb->id.tag & LIB_TAG_NEED_LINK) { + IDP_LibLinkProperty(prb->id.properties, fd); + lib_link_animdata(fd, &prb->id, prb->adt); + + prb->id.tag &= ~LIB_TAG_NEED_LINK; + } + } +} + +static void direct_link_probe(FileData *fd, Probe *prb) +{ + prb->adt = newdataadr(fd, prb->adt); + direct_link_animdata(fd, prb->adt); +} + /* ************ READ SPEAKER ***************** */ static void lib_link_speaker(FileData *fd, Main *main) @@ -8260,6 +8281,7 @@ static const char *dataname(short id_code) case ID_VF: return "Data from VF"; case ID_TXT : return "Data from TXT"; case ID_SPK: return "Data from SPK"; + case ID_PRB: return "Data from PRB"; case ID_SO: return "Data from SO"; case ID_NT: return "Data from NT"; case ID_BR: return "Data from BR"; @@ -8492,6 +8514,9 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short case ID_SO: direct_link_sound(fd, (bSound *)id); break; + case ID_PRB: + direct_link_probe(fd, (Probe *)id); + break; case ID_GR: direct_link_group(fd, (Group *)id); break; @@ -8697,6 +8722,7 @@ static void lib_link_all(FileData *fd, Main *main) lib_link_text(fd, main); lib_link_camera(fd, main); lib_link_speaker(fd, main); + lib_link_probe(fd, main); lib_link_sound(fd, main); lib_link_group(fd, main); lib_link_armature(fd, main); @@ -9882,6 +9908,12 @@ static void expand_sound(FileData *fd, Main *mainvar, bSound *snd) expand_doit(fd, mainvar, snd->ipo); // XXX deprecated - old animation system } +static void expand_probe(FileData *fd, Main *mainvar, Probe *prb) +{ + if (prb->adt) + expand_animdata(fd, mainvar, prb->adt); +} + static void expand_movieclip(FileData *fd, Main *mainvar, MovieClip *clip) { if (clip->adt) @@ -10042,6 +10074,9 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) case ID_SO: expand_sound(fd, mainvar, (bSound *)id); break; + case ID_PRB: + expand_probe(fd, mainvar, (Probe *)id); + break; case ID_AR: expand_armature(fd, mainvar, (bArmature *)id); break; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index c1628575398..ace66c97d9a 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -135,6 +135,7 @@ #include "DNA_object_force.h" #include "DNA_packedFile_types.h" #include "DNA_particle_types.h" +#include "DNA_probe_types.h" #include "DNA_property_types.h" #include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" @@ -3201,6 +3202,19 @@ static void write_sound(WriteData *wd, bSound *sound) } } +static void write_probe(WriteData *wd, Probe *prb) +{ + if (prb->id.us > 0 || wd->current) { + /* write LibData */ + writestruct(wd, ID_PRB, Probe, 1, prb); + write_iddata(wd, &prb->id); + + if (prb->adt) { + write_animdata(wd, prb->adt); + } + } +} + static void write_group(WriteData *wd, Group *group) { if (group->id.us > 0 || wd->current) { @@ -3984,6 +3998,9 @@ static bool write_file_handle( case ID_SPK: write_speaker(wd, (Speaker *)id); break; + case ID_PRB: + write_probe(wd, (Probe *)id); + break; case ID_SO: write_sound(wd, (bSound *)id); break; |