Revision: 21838
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21838
Author:   aligorith
Date:     2009-07-24 08:08:03 +0200 (Fri, 24 Jul 2009)

Log Message:
-----------
NLA - Auto-Blending + 'Smarter' Extend Behaviour

* Auto-blending (blend in/out values get determined based on 'overlaps' of 
strips) now occurs after transforming strips. Where islands (continuous chains 
of strips) occur, only the ones on the ends of the islands will get or 
contribute to auto-blending.

* Extend modes (other than 'nothing') now get automatically determined (after 
transforms) so that moving strips will no-longer cause problems.

* Added a new option to hide influence curves in NLA. Also, made the line 
widths for these curves narrower, since the old setting was too ugly.

* Pose copy/paste buffer now gets freed on exit 

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_nla.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/nla.c
    branches/blender2.5/blender/source/blender/editors/space_nla/nla_draw.c
    branches/blender2.5/blender/source/blender/editors/space_nla/nla_header.c
    
branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_space_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_space.c
    
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_init_exit.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_nla.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_nla.h     
2009-07-24 03:28:50 UTC (rev 21837)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_nla.h     
2009-07-24 06:08:03 UTC (rev 21838)
@@ -91,6 +91,8 @@
 short BKE_nlatracks_have_animated_strips(ListBase *tracks);
 void BKE_nlastrip_validate_fcurves(struct NlaStrip *strip);
 
+void BKE_nla_validate_state(struct AnimData *adt);
+
 /* ............ */
 
 void BKE_nla_action_pushdown(struct AnimData *adt);

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/nla.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/nla.c  
2009-07-24 03:28:50 UTC (rev 21837)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/nla.c  
2009-07-24 06:08:03 UTC (rev 21838)
@@ -375,7 +375,7 @@
                        return strip->actend - (repeatsNum * actlength * scale) 
                                        - (fmod(cframe - strip->start, 
actlength*scale) / scale);
                }
-               else {
+               else /* if (mode == NLATIME_CONVERT_EVAL) */{
                        if (IS_EQ(cframe, strip->end) && IS_EQ(strip->repeat, 
((int)strip->repeat))) {
                                /* this case prevents the motion snapping back 
to the first frame at the end of the strip 
                                 * by catching the case where repeats is a 
whole number, which means that the end of the strip
@@ -1229,13 +1229,52 @@
 
 /* ---- */
 
+/* Get strips which overlap the given one at the start/end of its range 
+ *     - strip: strip that we're finding overlaps for
+ *     - track: nla-track that the overlapping strips should be found from
+ *     - start, end: frames for the offending endpoints
+ */
+static void nlastrip_get_endpoint_overlaps (NlaStrip *strip, NlaTrack *track, 
float **start, float **end)
+{
+       NlaStrip *nls;
+       
+       /* find strips that overlap over the start/end of the given strip,
+        * but which don't cover the entire length 
+        */
+       // TODO: this scheme could get quite slow for doing this on many 
strips...
+       for (nls= track->strips.first; nls; nls= nls->next) {
+               /* check if strip overlaps (extends over or exactly on) the 
entire range of the strip we're validating */
+               if ((nls->start <= strip->start) && (nls->end >= strip->end)) {
+                       *start= NULL;
+                       *end= NULL;
+                       return;
+               }
+               
+               /* check if strip doesn't even occur anywhere near... */
+               if (nls->end < strip->start)
+                       continue; /* skip checking this strip... not worthy of 
mention */
+               if (nls->start > strip->end)
+                       return; /* the range we're after has already passed */
+                       
+               /* if this strip is not part of an island of continuous strips, 
it can be used
+                *      - this check needs to be done for each end of the strip 
we try and use...
+                */
+               if ((nls->next == NULL) || IS_EQ(nls->next->start, 
nls->end)==0) {
+                       if ((nls->end > strip->start) && (nls->end < 
strip->end))
+                               *start= &nls->end;
+               }
+               if ((nls->prev == NULL) || IS_EQ(nls->prev->end, 
nls->start)==0) {
+                       if ((nls->start < strip->end) && (nls->start > 
strip->start))
+                               *end= &nls->start;
+               }
+       }
+}
+
 /* Determine auto-blending for the given strip */
 void BKE_nlastrip_validate_autoblends (NlaTrack *nlt, NlaStrip *nls)
 {
-       NlaTrack *track;
-       NlaStrip *strip;
-       //float *ps=NULL, *pe=NULL;
-       //float *ns=NULL, *ne=NULL;
+       float *ps=NULL, *pe=NULL;
+       float *ns=NULL, *ne=NULL;
        
        /* sanity checks */
        if ELEM(NULL, nls, nlt)
@@ -1246,42 +1285,76 @@
                return;
        
        /* get test ranges */
-       if (nlt->prev) {
-               /* find strips that overlap over the start/end of the given 
strip,
-                * but which don't cover the entire length 
-                */
-               track= nlt->prev;
-               for (strip= track->strips.first; strip; strip= strip->next) {
-                       
-               }
+       if (nlt->prev)
+               nlastrip_get_endpoint_overlaps(nls, nlt->prev, &ps, &pe);
+       if (nlt->next)
+               nlastrip_get_endpoint_overlaps(nls, nlt->next, &ns, &ne);
+               
+       /* set overlaps for this strip 
+        *      - don't use the values obtained though if the end in question 
+        *        is directly followed/preceeded by another strip, forming an 
+        *        'island' of continuous strips
+        */
+       if ( (ps || ns) && ((nls->prev == NULL) || IS_EQ(nls->prev->end, 
nls->start)==0) ) 
+       {
+               /* start overlaps - pick the largest overlap */
+               if ( ((ps && ns) && (*ps > *ns)) || (ps) )
+                       nls->blendin= *ps - nls->start;
+               else
+                       nls->blendin= *ns - nls->start;
        }
-       if (nlt->next) {
-               /* find strips that overlap over the start/end of the given 
strip,
-                * but which don't cover the entire length 
-                */
-               track= nlt->next;
-               for (strip= track->strips.first; strip; strip= strip->next) {
-                       
-               }
+       else /* no overlap allowed/needed */
+               nls->blendin= 0.0f;
+               
+       if ( (pe || ne) && ((nls->next == NULL) || IS_EQ(nls->next->start, 
nls->end)==0) ) 
+       {
+               /* end overlaps - pick the largest overlap */
+               if ( ((pe && ne) && (*pe > *ne)) || (pe) )
+                       nls->blendout= nls->end - *pe;
+               else
+                       nls->blendout= nls->end - *ne;
        }
+       else /* no overlap allowed/needed */
+               nls->blendout= 0.0f;
 }
 
 /* Ensure that auto-blending and other settings are set correctly */
 void BKE_nla_validate_state (AnimData *adt)
 {
-       NlaStrip *strip;
+       NlaStrip *strip, *fstrip=NULL;
        NlaTrack *nlt;
        
        /* sanity checks */
        if ELEM(NULL, adt, adt->nla_tracks.first)
                return;
                
-       /* adjust blending values for auto-blending */
+       /* adjust blending values for auto-blending, and also do an initial 
pass to find the earliest strip */
        for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
                for (strip= nlt->strips.first; strip; strip= strip->next) {
+                       /* auto-blending first */
                        BKE_nlastrip_validate_autoblends(nlt, strip);
+                       
+                       /* extend mode - find first strip */
+                       if ((fstrip == NULL) || (strip->start < fstrip->start))
+                               fstrip= strip;
                }
        }
+       
+       /* second pass over the strips to adjust the extend-mode to fix any 
problems */
+       for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
+               for (strip= nlt->strips.first; strip; strip= strip->next) {
+                       /* apart from 'nothing' option which user has to 
explicitly choose, we don't really know if 
+                        * we should be overwriting the extend setting (but 
assume that's what the user wanted)
+                        */
+                       // TODO: 1 solution is to tie this in with 
auto-blending...
+                       if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) {
+                               if (strip == fstrip)
+                                       strip->extendmode= NLASTRIP_EXTEND_HOLD;
+                               else
+                                       strip->extendmode= 
NLASTRIP_EXTEND_HOLD_FORWARD;
+                       }
+               }
+       }
 }
 
 /* Core Tools ------------------------------------------- */

Modified: 
branches/blender2.5/blender/source/blender/editors/space_nla/nla_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_nla/nla_draw.c     
2009-07-24 03:28:50 UTC (rev 21837)
+++ branches/blender2.5/blender/source/blender/editors/space_nla/nla_draw.c     
2009-07-24 06:08:03 UTC (rev 21838)
@@ -252,10 +252,9 @@
        // XXX nasty hacked color for now... which looks quite bad too...
        glColor3f(0.7f, 0.7f, 0.7f);
        
-       /* draw with AA'd line, 2 units thick (it's either 1 or 2 px) */
+       /* draw with AA'd line */
        glEnable(GL_LINE_SMOOTH);
        glEnable(GL_BLEND);
-       glLineWidth(2.0f);
        
        /* influence -------------------------- */
        if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) {
@@ -302,11 +301,10 @@
        /* turn off AA'd lines */
        glDisable(GL_LINE_SMOOTH);
        glDisable(GL_BLEND);
-       glLineWidth(1.0f);
 }
 
 /* main call for drawing a single NLA-strip */
-static void nla_draw_strip (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, 
View2D *v2d, float yminc, float ymaxc)
+static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, 
NlaStrip *strip, View2D *v2d, float yminc, float ymaxc)
 {
        float color[3];
        
@@ -373,8 +371,11 @@
        gl_round_box_shade(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 
0.0, 0.5, 0.1);
        
        
-       /* draw strip's control 'curves' */
-       nla_draw_strip_curves(strip, v2d, yminc, ymaxc);
+       /* draw strip's control 'curves'
+        *      - only if user hasn't hidden them...
+        */
+       if ((snla->flag & SNLA_NOSTRIPCURVES) == 0)
+               nla_draw_strip_curves(strip, v2d, yminc, ymaxc);
        
        /* draw strip outline 
         *      - color used here is to indicate active vs non-active
@@ -527,7 +528,7 @@
                                        for (strip=nlt->strips.first, index=1; 
strip; strip=strip->next, index++) {
                                                if 
(BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, v2d->cur.xmax)) {
                                                        /* draw the 
visualisation of the strip */
-                                                       nla_draw_strip(adt, 
nlt, strip, v2d, yminc, ymaxc);
+                                                       nla_draw_strip(snla, 
adt, nlt, strip, v2d, yminc, ymaxc);
                                                        
                                                        /* add the text for 
this strip to the cache */
                                                        
nla_draw_strip_text(nlt, strip, index, v2d, yminc, ymaxc);

Modified: 
branches/blender2.5/blender/source/blender/editors/space_nla/nla_header.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_nla/nla_header.c   
2009-07-24 03:28:50 UTC (rev 21837)
+++ branches/blender2.5/blender/source/blender/editors/space_nla/nla_header.c   
2009-07-24 06:08:03 UTC (rev 21838)
@@ -21,7 +21,7 @@
  * All rights reserved.
  *
  * 
- * Contributor(s): Blender Foundation
+ * Contributor(s): Blender Foundation, Joshua Leung
  *
  * ***** END GPL LICENSE BLOCK *****
  */
@@ -100,7 +100,9 @@
                uiItemO(layout, "Show Frames", 0, "ANIM_OT_time_toggle");
        else
                uiItemO(layout, "Show Seconds", 0, "ANIM_OT_time_toggle");
-
+       
+       uiItemR(layout, NULL, 0, &spaceptr, "show_strip_curves", 0, 0, 0);
+       
        uiItemS(layout);
        
        uiItemS(layout);

Modified: 
branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
        2009-07-24 03:28:50 UTC (rev 21837)
+++ 
branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
        2009-07-24 06:08:03 UTC (rev 21838)
@@ -4645,34 +4645,34 @@
                SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
                Scene *scene;
                bAnimContext ac;
-
+               
                /* initialise relevant anim-context 'context' data from 
TransInfo data */
                        /* NOTE: sync this with the code in 
ANIM_animdata_get_context() */
                memset(&ac, 0, sizeof(bAnimContext));
-
+               
                scene= ac.scene= t->scene;
                ob= ac.obact= OBACT;
                ac.sa= t->sa;
                ac.ar= t->ar;
                ac.spacetype= (t->sa)? t->sa->spacetype : 0;
                ac.regiontype= (t->ar)? t->ar->regiontype : 0;
-
+               

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to