diff options
author | Ton Roosendaal <ton@blender.org> | 2005-04-02 17:57:23 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-04-02 17:57:23 +0400 |
commit | bdb86d7c6765724d297e7aa97dec4c0cc7d2bae9 (patch) | |
tree | fd00e10fd560504d58150c8ce13ce9fb11dd5b9a /source/blender/blenloader/intern | |
parent | 02d3ad0b34c88be3cd8b581812a7faa08fa16d1b (diff) |
Integration stage of Softbody project
User level notes are in Wiki here;
http://wiki.blender.org/bin/view.pl/Blenderdev/Softbodies
And will be added in blender3d.org CMS later.
Tech level notes are still pending, but here's the most relevant ones;
- made ob->soft struct SoftBody to hold all settings, and read/save in
files
- added (temporal!) conversion for the old settings. So: read old files
with softbody experiments now, and save over!
- cleaned API calls for softbody, which are only 5 of them now:
sbNew()
sbFree()
sbObjectStep() (animation steps)
sbObjectToSoftbody() (full re-initialize data)
sbObjectReset() (only reset motion)
- API calls accepts time in frames now, within softbody.c it converts
Further, internally code was cleaned some (missing tabs etc). Also tried
to keep a well defined structure with hints how to add support for more
objects. Can write notes about that...
Diffstat (limited to 'source/blender/blenloader/intern')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 30 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 1 |
2 files changed, 30 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6561318cd8b..000a9261d37 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -119,6 +119,7 @@ #include "BKE_object.h" #include "BKE_sca.h" // for init_actuator #include "BKE_scene.h" +#include "BKE_softbody.h" // sbNew() #include "BKE_texture.h" // for open_plugin_tex #include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND @@ -2316,7 +2317,13 @@ static void direct_link_object(FileData *fd, Object *ob) } ob->pd= newdataadr(fd, ob->pd); - ob->soft= NULL; + ob->soft= newdataadr(fd, ob->soft); + if(ob->soft) { + SoftBody *sb= ob->soft; // init all stuff so it gets rebuilt nicely + sb->totpoint= sb->totspring= 0; + sb->bpoint= NULL; + sb->bspring= NULL; + } link_list(fd, &ob->prop); prop= ob->prop.first; @@ -4625,6 +4632,7 @@ static void do_versions(Main *main) } } if(main->versionfile <= 236) { + Object *ob; Scene *sce= main->scene.first; Camera *cam= main->camera.first; bScreen *sc; @@ -4653,6 +4661,26 @@ static void do_versions(Main *main) } } } + /* temporal copy */ + for(ob= main->object.first; ob; ob= ob->id.next) { + if(ob->softflag && ob->soft==NULL) { + SoftBody *sb; + ob->soft=sb= sbNew(); + + sb->goalspring= ob->sb_goalspring; + sb->goalfrict= ob->sb_goalfrict; + sb->inspring= ob->sb_inspring; + sb->infrict= ob->sb_infrict; + sb->nodemass= ob->sb_nodemass; + sb->grav= ob->sb_grav; + sb->mingoal= ob->sb_mingoal; + sb->maxgoal= ob->sb_maxgoal; + sb->mediafrict= ob->sb_mediafrict; + sb->rklimit= ob->softtime; + + ob->softflag |= OB_SB_GOAL|OB_SB_EDGES; + } + } } /* don't forget to set version number in blender.c! */ diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 054024b4d75..00b29f32127 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -683,6 +683,7 @@ static void write_objects(WriteData *wd, ListBase *idbase) write_nlastrips(wd, &ob->nlastrips); writestruct(wd, DATA, "PartDeflect", 1, ob->pd); + writestruct(wd, DATA, "SoftBody", 1, ob->soft); for(hook= ob->hooks.first; hook; hook= hook->next) { writestruct(wd, DATA, "ObHook", 1, hook); |