NLA Transform Bugfixes:
[blender.git] / source / blender / src / transform_generics.c
index 1a803bf00a81d2e7ab3f9f730067303d51f2b0df..a0dde01ba8e551bf58165723b1b5478e8b137dd9 100644 (file)
@@ -39,6 +39,7 @@
 #include "DNA_lattice_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_modifier_types.h"
+#include "DNA_nla_types.h"
 #include "DNA_object_types.h"
 #include "DNA_object_force.h"
 #include "DNA_particle_types.h"
@@ -303,10 +304,50 @@ void recalcData(TransInfo *t)
                                
                                if (base->object->recalc) 
                                        base->object->ctime= -1234567.0f;       // eveil! 
+                               
+                               /* recalculate scale of selected nla-strips */
+                               if (base->object->nlastrips.first) {
+                                       Object *bob= base->object;
+                                       bActionStrip *strip;
+                                       
+                                       for (strip= bob->nlastrips.first; strip; strip= strip->next) {
+                                               if (strip->flag & ACTSTRIP_SELECT) {
+                                                       float actlen= strip->actend - strip->actstart;
+                                                       float len= strip->end - strip->start;
+                                                       
+                                                       strip->scale= len / (actlen * strip->repeat);
+                                               }
+                                       }
+                               }
                        }
                        
                        DAG_scene_flush_update(G.scene, screen_view3d_layers(), 0);
                }
+               else {
+                       for (base=G.scene->base.first; base; base=base->next) {
+                               /* recalculate scale of selected nla-strips */
+                               if (base->object->nlastrips.first) {
+                                       Object *bob= base->object;
+                                       bActionStrip *strip;
+                                       
+                                       for (strip= bob->nlastrips.first; strip; strip= strip->next) {
+                                               if (strip->flag & ACTSTRIP_SELECT) {
+                                                       float actlen= strip->actend - strip->actstart;
+                                                       float len= strip->end - strip->start;
+                                                       
+                                                       /* prevent 'negative' scaling */
+                                                       if (len < 0) {
+                                                               SWAP(float, strip->start, strip->end);
+                                                               len= fabs(len);
+                                                       }
+                                                       
+                                                       /* calculate new scale */
+                                                       strip->scale= len / (actlen * strip->repeat);
+                                               }
+                                       }
+                               }
+                       }
+               }
        }
        else if (t->spacetype == SPACE_IPO) {
                EditIpo *ei;