diff options
author | Toni Alatalo <antont@kyperjokki.fi> | 2006-02-08 19:58:12 +0300 |
---|---|---|
committer | Toni Alatalo <antont@kyperjokki.fi> | 2006-02-08 19:58:12 +0300 |
commit | a3d0d456ac84279beffb08da2056a718448639a2 (patch) | |
tree | 407f32cfdca184c9ec3e47f9fed9de00d6315e51 /source/blender/blenkernel | |
parent | 839b338be35dd11d30231d1dee1a3454b952ab55 (diff) |
More things for easying the job of replacing proxy/working armatures in the scenes of Elephants Dream with the final ones: 1) adds removing Fakeusers from Actions to PyAPI, now with a hackish call in the Blender module. Possibility of better ways should be discussed on bf-python. 2) adds BPY Object.copyNLA(otherob) - that was simple 'cause the copy_nla function was nicely in kernel nla.c. 3) Object.convertActionToStrip(), here it gets tricky: the function to convert the active action of an object to a NLA strip was buried inside the respective function in the GUI editnla.c which had also code for reading mouse coordinates and whatnot. So I took the actual copying out of it and moved it to the kernel nla.c as a new function, bActionStrip *convert_action_to_strip (Object *ob). that code used other functions, of which find_stridechannel() was also in editnla.c but free of UI code so i moved it to kernel too. kept things with UI code in editnla.c. tried to be careful with keeping mallocs and the pointer business intact, and tested that this works and after usage Blender gives no memory warnings or anything, so seems ok - but certainly is best reviewed by ppl more active with c coding than me. hopefully this little refactor makes it possible to add this function to the menus too, which was not straightforward earlier when Matt took a look at it.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_nla.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 45 |
2 files changed, 49 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index 9ac6b6ff3af..560e5d5c33c 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -35,11 +35,13 @@ struct bActionStrip; struct ListBase; +struct Object; -void free_actionstrip(struct bActionStrip* strip); +void free_actionstrip (struct bActionStrip* strip); void free_nlastrips (struct ListBase *nlalist); void copy_nlastrips (struct ListBase *dst, struct ListBase *src); void copy_actionstrip (struct bActionStrip **dst, struct bActionStrip **src); - +void find_stridechannel(struct Object *ob, struct bActionStrip *strip); +struct bActionStrip *convert_action_to_strip (struct Object *ob); #endif diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 5fefc41f77c..100f2bb5d72 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -40,7 +40,9 @@ #include "DNA_action_types.h" #include "DNA_ID.h" #include "DNA_ipo_types.h" +#include "DNA_object_types.h" #include "MEM_guardedalloc.h" +#include "BKE_object.h" /* for convert_action_to_strip(ob) */ #ifdef HAVE_CONFIG_H #include <config.h> @@ -88,6 +90,49 @@ void copy_nlastrips (ListBase *dst, ListBase *src) } } +/* from editnla, for convert_action_to_strip -- no UI code so should be ok here.. */ +void find_stridechannel(Object *ob, bActionStrip *strip) +{ + if(ob && ob->pose) { + bPoseChannel *pchan; + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) + if(pchan->flag & POSE_STRIDE) + break; + if(pchan) + BLI_strncpy(strip->stridechannel, pchan->name, 32); + else + strip->stridechannel[0]= 0; + } +} + +//called by convert_nla / bpy api with an object with the action to be converted to a new strip +bActionStrip *convert_action_to_strip (Object *ob) +{ + bActionStrip *nstrip; + + /* Make new actionstrip */ + nstrip = MEM_callocN(sizeof(bActionStrip), "bActionStrip"); + + /* Link the action to the nstrip */ + nstrip->act = ob->action; + id_us_plus(&nstrip->act->id); + calc_action_range(nstrip->act, &nstrip->actstart, &nstrip->actend, 1); + nstrip->start = nstrip->actstart; + nstrip->end = nstrip->actend; + nstrip->flag = ACTSTRIP_SELECT|ACTSTRIP_LOCK_ACTION; + + find_stridechannel(ob, nstrip); + //set_active_strip(ob, nstrip); /* is in editnla as does UI calls */ + + nstrip->repeat = 1.0; + + BLI_addtail(&ob->nlastrips, nstrip); + return nstrip; /* is created, malloced etc. here so is safe to just return the pointer? + this is needed for setting this active in UI, and probably useful for API too */ + +} + + void free_actionstrip(bActionStrip* strip) { |