Bugfixes:
authorJoshua Leung <aligorith@gmail.com>
Tue, 6 May 2008 07:10:30 +0000 (07:10 +0000)
committerJoshua Leung <aligorith@gmail.com>
Tue, 6 May 2008 07:10:30 +0000 (07:10 +0000)
* 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

source/blender/blenkernel/intern/action.c
source/blender/src/drawnla.c
source/blender/src/editnla.c

index c4df1db7627b3d9192e5b7bc3f84ea3ce1a314ef..5fb3d6f869a707bedeb4cf14aa1bd4b39257587b 100644 (file)
@@ -489,11 +489,11 @@ static float get_actionstrip_frame(bActionStrip *strip, float cframe, int invert
 {
        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;
index fba55f7f30849237fcb71329e73e009bf1bd880f..c0cd11d27a153a0e12cdfa9d0ab2e4d4e5ee60f4 100644 (file)
@@ -490,39 +490,42 @@ void do_nlabuts(unsigned short event)
                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:
index 6d9adda85d05a66bc443c6ae9537376eb19b83e4..d758f34949a3249ffbde169faf3ce5c8472c3846 100644 (file)
@@ -188,11 +188,16 @@ void shift_nlastrips_down(void) {
 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 @@ void synchronize_action_strips(void)
                }
                
                /* 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;