Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/ipo.c')
-rw-r--r--source/blender/blenkernel/intern/ipo.c111
1 files changed, 107 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 54618813a0b..5642e63326f 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -58,6 +58,7 @@
#include "DNA_key_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
+#include "DNA_nla_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h"
#include "DNA_particle_types.h"
@@ -85,6 +86,7 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
+#include "BKE_nla.h"
#include "BKE_object.h"
@@ -1463,6 +1465,87 @@ static void action_to_animdata (ID *id, bAction *act)
action_to_animato(act, &adt->action->groups, &adt->action->curves, &adt->drivers);
}
+/* ------------------------- */
+
+// TODO:
+// - NLA group duplicators info
+// - NLA curve/stride modifiers...
+
+/* Convert NLA-Strip to new system */
+static void nlastrips_to_animdata (ID *id, ListBase *strips)
+{
+ AnimData *adt= BKE_animdata_from_id(id);
+ NlaTrack *nlt = NULL;
+ NlaStrip *strip;
+ bActionStrip *as, *asn;
+
+ /* for each one of the original strips, convert to a new strip and free the old... */
+ for (as= strips->first; as; as= asn) {
+ asn= as->next;
+
+ /* this old strip is only worth something if it had an action... */
+ if (as->act) {
+ /* convert Action data (if not yet converted), storing the results in the same Action */
+ action_to_animato(as->act, &as->act->groups, &as->act->curves, &adt->drivers);
+
+ /* create a new-style NLA-strip which references this Action, then copy over relevant settings */
+ {
+ /* init a new strip, and assign the action to it
+ * - no need to muck around with the user-counts, since this is just
+ * passing over the ref to the new owner, not creating an additional ref
+ */
+ strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip");
+ strip->act= as->act;
+
+ /* endpoints */
+ strip->start= as->start;
+ strip->end= as->end;
+ strip->actstart= as->actstart;
+ strip->actend= as->actend;
+
+ /* action reuse */
+ strip->repeat= as->repeat;
+ strip->scale= as->scale;
+ if (as->flag & ACTSTRIP_LOCK_ACTION) strip->flag |= NLASTRIP_FLAG_SYNC_LENGTH;
+
+ /* blending */
+ strip->blendin= as->blendin;
+ strip->blendout= as->blendout;
+ strip->blendmode= (as->mode==ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD : NLASTRIP_MODE_BLEND;
+ if (as->flag & ACTSTRIP_AUTO_BLENDS) strip->flag |= NLASTRIP_FLAG_AUTO_BLENDS;
+
+ /* assorted setting flags */
+ if (as->flag & ACTSTRIP_SELECT) strip->flag |= NLASTRIP_FLAG_SELECT;
+ if (as->flag & ACTSTRIP_ACTIVE) strip->flag |= NLASTRIP_FLAG_ACTIVE;
+
+ if (as->flag & ACTSTRIP_MUTE) strip->flag |= NLASTRIP_FLAG_MUTED;
+ if (as->flag & ACTSTRIP_REVERSE) strip->flag |= NLASTRIP_FLAG_REVERSE;
+
+ /* by default, we now always extrapolate, while in the past this was optional */
+ if ((as->flag & ACTSTRIP_HOLDLASTFRAME)==0)
+ strip->extendmode= NLASTRIP_EXTEND_NOTHING;
+ }
+
+ /* try to add this strip to the current NLA-Track (i.e. the 'last' one on the stack atm) */
+ if (BKE_nlatrack_add_strip(nlt, strip) == 0) {
+ /* trying to add to the current failed (no space),
+ * so add a new track to the stack, and add to that...
+ */
+ nlt= add_nlatrack(adt, NULL);
+ BKE_nlatrack_add_strip(nlt, strip);
+ }
+ }
+
+ /* modifiers */
+ // FIXME: for now, we just free them...
+ if (as->modifiers.first)
+ BLI_freelistN(&as->modifiers);
+
+ /* free the old strip */
+ BLI_freelinkN(strips, as);
+ }
+}
+
/* *************************************************** */
/* External API - Only Called from do_versions() */
@@ -1509,7 +1592,30 @@ void do_versions_ipos_to_animato(Main *main)
if (G.f & G_DEBUG) printf("\tconverting ob %s \n", id->name+2);
/* check if object has any animation data */
- if ((ob->ipo) || (ob->action) || (ob->nlastrips.first)) {
+ if (ob->nlastrips.first) {
+ /* Add AnimData block */
+ adt= BKE_id_add_animdata(id);
+
+ /* IPO first to take into any non-NLA'd Object Animation */
+ if (ob->ipo) {
+ ipo_to_animdata(id, ob->ipo, NULL, NULL);
+
+ ob->ipo->id.us--;
+ ob->ipo= NULL;
+ }
+
+ /* Action is skipped since it'll be used by some strip in the NLA anyway,
+ * causing errors with evaluation in the new evaluation pipeline
+ */
+ if (ob->action) {
+ ob->action->id.us--;
+ ob->action= NULL;
+ }
+
+ /* finally NLA */
+ nlastrips_to_animdata(id, &ob->nlastrips);
+ }
+ else if ((ob->ipo) || (ob->action)) {
/* Add AnimData block */
adt= BKE_id_add_animdata(id);
@@ -1530,9 +1636,6 @@ void do_versions_ipos_to_animato(Main *main)
ob->ipo->id.us--;
ob->ipo= NULL;
}
-
- /* finally NLA */
- // XXX todo... for now, new NLA code not hooked up yet, so keep old stuff (but not for too long!)
}
/* check PoseChannels for constraints with local data */