Revision: 14703
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14703
Author:   aligorith
Date:     2008-05-06 09:10:30 +0200 (Tue, 06 May 2008)

Log Message:
-----------
Bugfixes: 

* NLA scaling was being incorrectly handled with fractional values. This was 
caused by clamping to integers instead of floats when making sure the scale 
value was positive. 

* Added checks to help prevent some weird cases that may sometimes occur and 
cause problems

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/action.c
    trunk/blender/source/blender/src/drawnla.c
    trunk/blender/source/blender/src/editnla.c

Modified: trunk/blender/source/blender/blenkernel/intern/action.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/action.c     2008-05-05 
22:08:50 UTC (rev 14702)
+++ trunk/blender/source/blender/blenkernel/intern/action.c     2008-05-06 
07:10:30 UTC (rev 14703)
@@ -489,11 +489,11 @@
 {
        float length, actlength, repeat, scale;
        
-       if(strip->repeat == 0.0f) strip->repeat = 1.0f;
+       if (strip->repeat == 0.0f) strip->repeat = 1.0f;
        repeat = (strip->flag & ACTSTRIP_USESTRIDE) ? (1.0f) : (strip->repeat);
        
-       if(strip->scale == 0.0f) strip->scale= 1.0f;
-       scale = abs(strip->scale); /* scale must be positive (for now) */
+       if (strip->scale == 0.0f) strip->scale= 1.0f;
+       scale = fabs(strip->scale); /* scale must be positive (for now) */
        
        actlength = strip->actend-strip->actstart;
        if (actlength == 0.0f) actlength = 1.0f;

Modified: trunk/blender/source/blender/src/drawnla.c
===================================================================
--- trunk/blender/source/blender/src/drawnla.c  2008-05-05 22:08:50 UTC (rev 
14702)
+++ trunk/blender/source/blender/src/drawnla.c  2008-05-06 07:10:30 UTC (rev 
14703)
@@ -490,39 +490,42 @@
                allqueue (REDRAWNLA, 0);
                allqueue (REDRAWVIEW3D, 0);
                break;
-       case B_NLA_SCALE:
+       case B_NLA_SCALE: /* adjust end-frame when scale is changed */
                {
                        float actlen= strip->actend - strip->actstart;
                        float mapping= strip->scale * strip->repeat;
                        
-                       strip->end = (actlen * mapping) + strip->start; 
+                       if (mapping != 0.0f)
+                               strip->end = (actlen * mapping) + strip->start; 
+                       else
+                               printf("NLA Scale Error: Scale = %0.4f, Repeat 
= %0.4f \n", strip->scale, strip->repeat);
                        
-                       allqueue (REDRAWNLA, 0);
-                       allqueue (REDRAWIPO, 0);
-                       allqueue (REDRAWACTION, 0);
-                       allqueue (REDRAWVIEW3D, 0);
+                       allqueue(REDRAWNLA, 0);
+                       allqueue(REDRAWIPO, 0);
+                       allqueue(REDRAWACTION, 0);
+                       allqueue(REDRAWVIEW3D, 0);
                }
                break;
-       case B_NLA_SCALE2:
+       case B_NLA_SCALE2: /* adjust scale when end-frame is changed */
                {
                        float actlen= strip->actend - strip->actstart;
                        float len= strip->end - strip->start;
                        
                        strip->scale= len / (actlen * strip->repeat);
                        
-                       allqueue (REDRAWNLA, 0);
-                       allqueue (REDRAWIPO, 0);
-                       allqueue (REDRAWACTION, 0);
-                       allqueue (REDRAWVIEW3D, 0);
+                       allqueue(REDRAWNLA, 0);
+                       allqueue(REDRAWIPO, 0);
+                       allqueue(REDRAWACTION, 0);
+                       allqueue(REDRAWVIEW3D, 0);
                }
                break;
        case B_NLA_LOCK:
                synchronize_action_strips();
                
-               allqueue (REDRAWNLA, 0);
-               allqueue (REDRAWIPO, 0);
-               allqueue (REDRAWACTION, 0);
-               allqueue (REDRAWVIEW3D, 0);
+               allqueue(REDRAWNLA, 0);
+               allqueue(REDRAWIPO, 0);
+               allqueue(REDRAWACTION, 0);
+               allqueue(REDRAWVIEW3D, 0);
                break;
                
        case B_NLA_MOD_ADD:

Modified: trunk/blender/source/blender/src/editnla.c
===================================================================
--- trunk/blender/source/blender/src/editnla.c  2008-05-05 22:08:50 UTC (rev 
14702)
+++ trunk/blender/source/blender/src/editnla.c  2008-05-06 07:10:30 UTC (rev 
14703)
@@ -188,11 +188,16 @@
 void synchronize_action_strips(void)
 {
        Base *base;
+       Object *ob;
        bActionStrip *strip;
        
        for (base=G.scene->base.first; base; base=base->next) {
+               /* get object first */
+               ob= base->object;
+               
                /* step 1: adjust strip-lengths */
-               for (strip = base->object->nlastrips.last; strip; 
strip=strip->prev) {
+               //      FIXME: this seems very buggy
+               for (strip = ob->nlastrips.last; strip; strip=strip->prev) {
                        if (strip->flag & ACTSTRIP_LOCK_ACTION) {
                                float actstart, actend;
                                
@@ -212,7 +217,7 @@
                }
                
                /* step 2: adjust blendin/out values for each strip if option 
is turned on */
-               for (strip= base->object->nlastrips.first; strip; 
strip=strip->next) {
+               for (strip= ob->nlastrips.first; strip; strip=strip->next) {
                        if (strip->flag & ACTSTRIP_AUTO_BLENDS) {
                                bActionStrip *prev= strip->prev;
                                bActionStrip *next= strip->next;


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to