From ab02e9140e6c8b1d8c9169b18fa5025a1fb54377 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 7 Dec 2007 04:24:02 +0000 Subject: == NLA - Scale Setting for Strips == NLA-Strips now have a new setting: Scale. It determines how much the action-range is scaled for each repeat, instead of the scaling being implicitly determined based on repeats + strip-length. One of the instant benefits of this, is that when increasing the number of repeats, the strip length increases by the right amount. Thus, increasing the number of repeats retains a constant speed. Hopefully we can prevent weirdly scaled actions this way. (i.e. 0.00001 frames long action * 10000 or so) Todo: - Transform code needs to be able to set the scale setting (it doesn't yet) - Add a new option to "apply scaling", to fix up problems with old files that have really bad scaling. Situations when this is needed could get indicated in the interface too... (red background for "Scale" field?) --- source/blender/blenloader/intern/readfile.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'source/blender/blenloader/intern') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 43bddc275b7..f6b0c4cb4dc 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7187,11 +7187,36 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 10)) { Object *ob; - + /* dupliface scale */ for(ob= main->object.first; ob; ob= ob->id.next) ob->dupfacesca = 1.0f; } + + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 11)) { + Object *ob; + bActionStrip *strip; + + /* nla-strips - scale */ + for (ob= main->object.first; ob; ob= ob->id.next) { + for (strip= ob->nlastrips.first; strip; strip= strip->next) { + float length, actlength, repeat; + + if (strip->flag & ACTSTRIP_USESTRIDE) + repeat= 1.0f; + else + repeat= strip->repeat; + + length = strip->end-strip->start; + if (length == 0.0f) length= 1.0f; + actlength = strip->actend-strip->actstart; + + // right calculation? + strip->scale = actlength / (length * repeat); + if (strip->scale == 0.0f) strip->scale= 1.0f; + } + } + } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ -- cgit v1.2.3