svn merge -r39781:39792 https://svn.blender.org/svnroot/bf-blender/trunk/blender...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 1 Sep 2011 00:35:30 +0000 (00:35 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 1 Sep 2011 00:35:30 +0000 (00:35 +0000)
36 files changed:
1  2 
release/scripts/startup/bl_ui/space_info.py
release/scripts/startup/bl_ui/space_view3d.py
source/blender/CMakeLists.txt
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/idcode.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/armature/editarmature.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c
source/blender/editors/object/object_relations.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/makesdna/DNA_object_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_scene.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/gameengine/Converter/BL_BlenderDataConversion.cpp

Simple merge
index b34f3e49a264043bafaeb03b843244e0cb77ed6e,c1797427cc26dfc188c364d39b316a44d556f3f3..9b233db29dd4abd014d296edef06298388563daa
@@@ -223,9 -221,9 +224,10 @@@ set(SR
        BKE_smoke.h
        BKE_softbody.h
        BKE_sound.h
+       BKE_speaker.h
        BKE_subsurf.h
        BKE_suggestions.h
 +      BKE_tessmesh.h
        BKE_text.h
        BKE_texture.h
        BKE_unit.h
index 641eb0b7e762bd45267e39cf1a50c2cbc0d33069,e84a2a04dedb0e3aca8b60d3f87a0e6c292a57f0..f37e05e984268799ac187b54dd09bfe8db7029a1
mode 100755,100644..100755
index 18cafd77b453b5af069b9ce177c4ac96fcaad18b,5212bf32834dccd68704fb7b63d81ec88f6d099d..838523599c5718741ebf31609f61f802148132a3
@@@ -768,6 -770,61 +774,61 @@@ static int group_instance_add_exec(bCon
        return OPERATOR_CANCELLED;
  }
  
 -      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
+ static int object_speaker_add_exec(bContext *C, wmOperator *op)
+ {
+       Object *ob;
+       int enter_editmode;
+       unsigned int layer;
+       float loc[3], rot[3];
+       Scene *scene = CTX_data_scene(C);
+       object_add_generic_invoke_options(C, op);
++      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
+               return OPERATOR_CANCELLED;
+       ob= ED_object_add_type(C, OB_SPEAKER, loc, rot, FALSE, layer);
+       
+       /* to make it easier to start using this immediately in NLA, a default sound clip is created
+        * ready to be moved around to retime the sound and/or make new sound clips
+        */
+       {
+               /* create new data for NLA hierarchy */
+               AnimData *adt = BKE_id_add_animdata(&ob->id);
+               NlaTrack *nlt = add_nlatrack(adt, NULL);
+               NlaStrip *strip = add_nla_soundstrip(CTX_data_scene(C), ob->data);
+               strip->start = CFRA;
+               strip->end += strip->start;
+               
+               /* hook them up */
+               BKE_nlatrack_add_strip(nlt, strip);
+               
+               /* auto-name the strip, and give the track an interesting name  */
+               strcpy(nlt->name, "SoundTrack");
+               BKE_nlastrip_validate_name(adt, strip);
+               
+               WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL);
+       }
+       return OPERATOR_FINISHED;
+ }
+ void OBJECT_OT_speaker_add(wmOperatorType *ot)
+ {
+       /* identifiers */
+       ot->name= "Add Speaker";
+       ot->description = "Add a speaker object to the scene";
+       ot->idname= "OBJECT_OT_speaker_add";
+       /* api callbacks */
+       ot->exec= object_speaker_add_exec;
+       ot->poll= ED_operator_objectmode;
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ED_object_add_generic_props(ot, TRUE);
+ }
  /* only used as menu */
  void OBJECT_OT_group_instance_add(wmOperatorType *ot)
  {
index f7d6f4315b370d8fd92f72d29ce1ace2bb213151,e9418ca9f9f995d2c922b44026b5c7719369a648..b79d355aa2a5b42683a0d82d534a7be232453f0e
@@@ -75,8 -76,8 +76,9 @@@
  #include "BKE_report.h"
  #include "BKE_sca.h"
  #include "BKE_scene.h"
+ #include "BKE_speaker.h"
  #include "BKE_texture.h"
 +#include "BKE_tessmesh.h"
  
  #include "WM_api.h"
  #include "WM_types.h"
index 132350839a9e43a30999391060a7784afe0ada84,ec76bb3ac3592fc8a8b09dc0af7090ccf7fc080b..a7b49fc336faaeda73b45d040927db640e98a2ec
@@@ -324,414 -323,384 +324,385 @@@ static int fcu_test_selected(FCurve *fc
        return 0;
  }
  
- /* called for updating while transform acts, once per redraw */
void recalcData(TransInfo *t)
+ /* helper for recalcData() - for Action Editor transforms */
static void recalcData_actedit(TransInfo *t)
  {
-       Base *base = t->scene->basact;
-       if (t->spacetype==SPACE_NODE) {
-               flushTransNodes(t);
-       }
-       else if (t->spacetype==SPACE_SEQ) {
-               flushTransSeq(t);
+       Scene *scene= t->scene;
+       SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
+       
+       bAnimContext ac= {NULL};
+       ListBase anim_data = {NULL, NULL};
+       bAnimListElem *ale;
+       int filter;
+       
+       /* initialise relevant anim-context 'context' data from TransInfo data */
+               /* NOTE: sync this with the code in ANIM_animdata_get_context() */
+       ac.scene= t->scene;
+       ac.obact= OBACT;
+       ac.sa= t->sa;
+       ac.ar= t->ar;
+       ac.sl= (t->sa)? t->sa->spacedata.first : NULL;
+       ac.spacetype= (t->sa)? t->sa->spacetype : 0;
+       ac.regiontype= (t->ar)? t->ar->regiontype : 0;
+       
+       ANIM_animdata_context_getdata(&ac);
+       
+       /* perform flush */
+       if (ac.datatype == ANIMCONT_GPENCIL) {
+               /* flush transform values back to actual coordinates */
+               flushTransGPactionData(t);
        }
-       else if (t->spacetype == SPACE_ACTION) {
-               Scene *scene= t->scene;
-               SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
-               
-               bAnimContext ac= {NULL};
-               ListBase anim_data = {NULL, NULL};
-               bAnimListElem *ale;
-               int filter;
-               
-               /* initialise relevant anim-context 'context' data from TransInfo data */
-                       /* NOTE: sync this with the code in ANIM_animdata_get_context() */
-               ac.scene= t->scene;
-               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;
-               
-               ANIM_animdata_context_getdata(&ac);
-               
-               /* perform flush */
-               if (ac.datatype == ANIMCONT_GPENCIL) {
-                       /* flush transform values back to actual coordinates */
-                       flushTransGPactionData(t);
-               }
-               else {
-                       /* get animdata blocks visible in editor, assuming that these will be the ones where things changed */
-                       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ANIMDATA);
-                       ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-                       
-                       /* just tag these animdata-blocks to recalc, assuming that some data there changed 
-                        * BUT only do this if realtime updates are enabled
-                        */
-                       if ((saction->flag & SACTION_NOREALTIMEUPDATES) == 0) {
-                               for (ale= anim_data.first; ale; ale= ale->next) {
-                                       /* set refresh tags for objects using this animation */
-                                       ANIM_list_elem_update(t->scene, ale);
-                               }
+       else {
+               /* get animdata blocks visible in editor, assuming that these will be the ones where things changed */
+               filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA);
+               ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+               
+               /* just tag these animdata-blocks to recalc, assuming that some data there changed 
+                * BUT only do this if realtime updates are enabled
+                */
+               if ((saction->flag & SACTION_NOREALTIMEUPDATES) == 0) {
+                       for (ale= anim_data.first; ale; ale= ale->next) {
+                               /* set refresh tags for objects using this animation */
+                               ANIM_list_elem_update(t->scene, ale);
                        }
-                       
-                       /* now free temp channels */
-                       BLI_freelistN(&anim_data);
                }
-       }
-       else if (t->spacetype == SPACE_IPO) {
-               Scene *scene;
-               SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
                
-               ListBase anim_data = {NULL, NULL};
-               bAnimContext ac;
-               int filter;
+               /* now free temp channels */
+               BLI_freelistN(&anim_data);
+       }
+ }
 -
+ /* helper for recalcData() - for Graph Editor transforms */
+ static void recalcData_graphedit(TransInfo *t)
+ {
+       SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
+       Scene *scene;
+       
+       ListBase anim_data = {NULL, NULL};
+       bAnimContext ac= {NULL};
+       int filter;
+       
+       bAnimListElem *ale;
+       int dosort = 0;
+       
+       
+       /* initialise relevant anim-context 'context' data from TransInfo data */
+               /* NOTE: sync this with the code in ANIM_animdata_get_context() */
+       scene= ac.scene= t->scene;
+       ac.obact= OBACT;
+       ac.sa= t->sa;
+       ac.ar= t->ar;
+       ac.sl= (t->sa)? t->sa->spacedata.first : NULL;
+       ac.spacetype= (t->sa)? t->sa->spacetype : 0;
+       ac.regiontype= (t->ar)? t->ar->regiontype : 0;
+       
+       ANIM_animdata_context_getdata(&ac);
+       
+       /* do the flush first */
+       flushTransGraphData(t);
+       
+       /* get curves to check if a re-sort is needed */
+       filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
+       ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+       
+       /* now test if there is a need to re-sort */
+       for (ale= anim_data.first; ale; ale= ale->next) {
+               FCurve *fcu= (FCurve *)ale->key_data;
                
-               bAnimListElem *ale;
-               int dosort = 0;
+               /* ignore unselected fcurves */
+               if (!fcu_test_selected(fcu))
+                       continue;
                
+               // fixme: only do this for selected verts...
+               ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYSEL|ANIM_UNITCONV_SELVERTS|ANIM_UNITCONV_RESTORE);
                
-               /* 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;
-               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;
+               /* watch it: if the time is wrong: do not correct handles yet */
+               if (test_time_fcurve(fcu))
+                       dosort++;
+               else
+                       calchandles_fcurve(fcu);
                
-               ANIM_animdata_context_getdata(&ac);
+               /* set refresh tags for objects using this animation,
+                * BUT only if realtime updates are enabled  
+                */
+               if ((sipo->flag & SIPO_NOREALTIMEUPDATES) == 0)
+                       ANIM_list_elem_update(t->scene, ale);
+       }
+       
+       /* do resort and other updates? */
+       if (dosort) remake_graph_transdata(t, &anim_data);
+       
+       /* now free temp channels */
+       BLI_freelistN(&anim_data);
+ }
+ /* helper for recalcData() - for NLA Editor transforms */
+ static void recalcData_nla(TransInfo *t)
+ {
+       TransDataNla *tdn= (TransDataNla *)t->customData;
+       SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
+       Scene *scene= t->scene;
+       double secf= FPS;
+       int i;
+       
+       /* for each strip we've got, perform some additional validation of the values that got set before
+        * using RNA to set the value (which does some special operations when setting these values to make
+        * sure that everything works ok)
+        */
+       for (i = 0; i < t->total; i++, tdn++) {
+               NlaStrip *strip= tdn->strip;
+               PointerRNA strip_ptr;
+               short pExceeded, nExceeded, iter;
+               int delta_y1, delta_y2;
                
-               /* do the flush first */
-               flushTransGraphData(t);
+               /* if this tdn has no handles, that means it is just a dummy that should be skipped */
+               if (tdn->handle == 0)
+                       continue;
                
-               /* get curves to check if a re-sort is needed */
-               filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_CURVEVISIBLE);
-               ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+               /* set refresh tags for objects using this animation,
+                * BUT only if realtime updates are enabled  
+                */
+               if ((snla->flag & SNLA_NOREALTIMEUPDATES) == 0)
+                       ANIM_id_update(t->scene, tdn->id);
                
-               /* now test if there is a need to re-sort */
-               for (ale= anim_data.first; ale; ale= ale->next) {
-                       FCurve *fcu= (FCurve *)ale->key_data;
+               /* if cancelling transform, just write the values without validating, then move on */
+               if (t->state == TRANS_CANCEL) {
+                       /* clear the values by directly overwriting the originals, but also need to restore
+                        * endpoints of neighboring transition-strips
+                        */
                        
-                       /* ignore unselected fcurves */
-                       if (!fcu_test_selected(fcu))
-                               continue;
+                       /* start */
+                       strip->start= tdn->h1[0];
                        
-                       // fixme: only do this for selected verts...
-                       ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYSEL|ANIM_UNITCONV_SELVERTS|ANIM_UNITCONV_RESTORE);
+                       if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
+                               strip->prev->end= tdn->h1[0];
                        
+                       /* end */
+                       strip->end= tdn->h2[0];
                        
-                       /* watch it: if the time is wrong: do not correct handles yet */
-                       if (test_time_fcurve(fcu))
-                               dosort++;
-                       else
-                               calchandles_fcurve(fcu);
+                       if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION))
+                               strip->next->start= tdn->h2[0];
                        
-                       /* set refresh tags for objects using this animation,
-                        * BUT only if realtime updates are enabled  
-                        */
-                       if ((sipo->flag & SIPO_NOREALTIMEUPDATES) == 0)
-                               ANIM_list_elem_update(t->scene, ale);
+                       /* flush transforms to child strips (since this should be a meta) */
+                       BKE_nlameta_flush_transforms(strip);
+                       
+                       /* restore to original track (if needed) */
+                       if (tdn->oldTrack != tdn->nlt) {
+                               /* just append to end of list for now, since strips get sorted in special_aftertrans_update() */
+                               BLI_remlink(&tdn->nlt->strips, strip);
+                               BLI_addtail(&tdn->oldTrack->strips, strip);
+                       }
+                       
+                       continue;
                }
                
-               /* do resort and other updates? */
-               if (dosort) remake_graph_transdata(t, &anim_data);
-               
-               /* now free temp channels */
-               BLI_freelistN(&anim_data);
-       }
-       else if (t->spacetype == SPACE_NLA) {
-               TransDataNla *tdn= (TransDataNla *)t->customData;
-               SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
-               Scene *scene= t->scene;
-               double secf= FPS;
-               int i;
-               
-               /* for each strip we've got, perform some additional validation of the values that got set before
-                * using RNA to set the value (which does some special operations when setting these values to make
-                * sure that everything works ok)
+               /* firstly, check if the proposed transform locations would overlap with any neighbouring strips
+                * (barring transitions) which are absolute barriers since they are not being moved
+                *
+                * this is done as a iterative procedure (done 5 times max for now)
                 */
-               for (i = 0; i < t->total; i++, tdn++) {
-                       NlaStrip *strip= tdn->strip;
-                       PointerRNA strip_ptr;
-                       short pExceeded, nExceeded, iter;
-                       int delta_y1, delta_y2;
-                       
-                       /* if this tdn has no handles, that means it is just a dummy that should be skipped */
-                       if (tdn->handle == 0)
-                               continue;
-                       
-                       /* set refresh tags for objects using this animation,
-                        * BUT only if realtime updates are enabled  
-                        */
-                       if ((snla->flag & SNLA_NOREALTIMEUPDATES) == 0)
-                               ANIM_id_update(t->scene, tdn->id);
+               for (iter=0; iter < 5; iter++) {
+                       pExceeded= ((strip->prev) && (strip->prev->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h1[0] < strip->prev->end));
+                       nExceeded= ((strip->next) && (strip->next->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h2[0] > strip->next->start));
                        
-                       /* if cancelling transform, just write the values without validating, then move on */
-                       if (t->state == TRANS_CANCEL) {
-                               /* clear the values by directly overwriting the originals, but also need to restore
-                                * endpoints of neighboring transition-strips
+                       if ((pExceeded && nExceeded) || (iter == 4) ) {
+                               /* both endpoints exceeded (or iteration ping-pong'd meaning that we need a compromise)
+                                *      - simply crop strip to fit within the bounds of the strips bounding it
+                                *      - if there were no neighbours, clear the transforms (make it default to the strip's current values)
                                 */
-                               
-                               /* start */
-                               strip->start= tdn->h1[0];
-                               
-                               if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
-                                       strip->prev->end= tdn->h1[0];
-                               
-                               /* end */
-                               strip->end= tdn->h2[0];
-                               
-                               if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION))
-                                       strip->next->start= tdn->h2[0];
-                               
-                               /* flush transforms to child strips (since this should be a meta) */
-                               BKE_nlameta_flush_transforms(strip);
-                               
-                               /* restore to original track (if needed) */
-                               if (tdn->oldTrack != tdn->nlt) {
-                                       /* just append to end of list for now, since strips get sorted in special_aftertrans_update() */
-                                       BLI_remlink(&tdn->nlt->strips, strip);
-                                       BLI_addtail(&tdn->oldTrack->strips, strip);
+                               if (strip->prev && strip->next) {
+                                       tdn->h1[0]= strip->prev->end;
+                                       tdn->h2[0]= strip->next->start;
+                               }
+                               else {
+                                       tdn->h1[0]= strip->start;
+                                       tdn->h2[0]= strip->end;
                                }
-                               
-                               continue;
                        }
-                       
-                       /* firstly, check if the proposed transform locations would overlap with any neighbouring strips
-                        * (barring transitions) which are absolute barriers since they are not being moved
-                        *
-                        * this is done as a iterative procedure (done 5 times max for now)
-                        */
-                       for (iter=0; iter < 5; iter++) {
-                               pExceeded= ((strip->prev) && (strip->prev->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h1[0] < strip->prev->end));
-                               nExceeded= ((strip->next) && (strip->next->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h2[0] > strip->next->start));
+                       else if (nExceeded) {
+                               /* move backwards */
+                               float offset= tdn->h2[0] - strip->next->start;
                                
-                               if ((pExceeded && nExceeded) || (iter == 4) ) {
-                                       /* both endpoints exceeded (or iteration ping-pong'd meaning that we need a compromise)
-                                        *      - simply crop strip to fit within the bounds of the strips bounding it
-                                        *      - if there were no neighbours, clear the transforms (make it default to the strip's current values)
-                                        */
-                                       if (strip->prev && strip->next) {
-                                               tdn->h1[0]= strip->prev->end;
-                                               tdn->h2[0]= strip->next->start;
-                                       }
-                                       else {
-                                               tdn->h1[0]= strip->start;
-                                               tdn->h2[0]= strip->end;
-                                       }
-                               }
-                               else if (nExceeded) {
-                                       /* move backwards */
-                                       float offset= tdn->h2[0] - strip->next->start;
-                                       
-                                       tdn->h1[0] -= offset;
-                                       tdn->h2[0] -= offset;
-                               }
-                               else if (pExceeded) {
-                                       /* more forwards */
-                                       float offset= strip->prev->end - tdn->h1[0];
-                                       
-                                       tdn->h1[0] += offset;
-                                       tdn->h2[0] += offset;
-                               }
-                               else /* all is fine and well */
-                                       break;
+                               tdn->h1[0] -= offset;
+                               tdn->h2[0] -= offset;
                        }
-                       
-                       /* handle auto-snapping */
-                       switch (snla->autosnap) {
-                               case SACTSNAP_FRAME: /* snap to nearest frame/time  */
-                                       if (snla->flag & SNLA_DRAWTIME) {
-                                               tdn->h1[0]= (float)( floor((tdn->h1[0]/secf) + 0.5f) * secf );
-                                               tdn->h2[0]= (float)( floor((tdn->h2[0]/secf) + 0.5f) * secf );
-                                       }
-                                       else {
-                                               tdn->h1[0]= (float)( floor(tdn->h1[0]+0.5f) );
-                                               tdn->h2[0]= (float)( floor(tdn->h2[0]+0.5f) );
-                                       }
-                                       break;
+                       else if (pExceeded) {
+                               /* more forwards */
+                               float offset= strip->prev->end - tdn->h1[0];
                                
-                               case SACTSNAP_MARKER: /* snap to nearest marker */
-                                       tdn->h1[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h1[0]);
-                                       tdn->h2[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h2[0]);
-                                       break;
+                               tdn->h1[0] += offset;
+                               tdn->h2[0] += offset;
                        }
+                       else /* all is fine and well */
+                               break;
+               }
+               
+               /* handle auto-snapping */
+               switch (snla->autosnap) {
+                       case SACTSNAP_FRAME: /* snap to nearest frame/time  */
+                               if (snla->flag & SNLA_DRAWTIME) {
+                                       tdn->h1[0]= (float)( floor((tdn->h1[0]/secf) + 0.5f) * secf );
+                                       tdn->h2[0]= (float)( floor((tdn->h2[0]/secf) + 0.5f) * secf );
+                               }
+                               else {
+                                       tdn->h1[0]= (float)( floor(tdn->h1[0]+0.5f) );
+                                       tdn->h2[0]= (float)( floor(tdn->h2[0]+0.5f) );
+                               }
+                               break;
                        
-                       /* use RNA to write the values... */
-                       // TODO: do we need to write in 2 passes to make sure that no truncation goes on?
-                       RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr);
-                       
-                       RNA_float_set(&strip_ptr, "frame_start", tdn->h1[0]);
-                       RNA_float_set(&strip_ptr, "frame_end", tdn->h2[0]);
-                       
-                       /* flush transforms to child strips (since this should be a meta) */
-                       BKE_nlameta_flush_transforms(strip);
-                       
+                       case SACTSNAP_MARKER: /* snap to nearest marker */
+                               tdn->h1[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h1[0]);
+                               tdn->h2[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h2[0]);
+                               break;
+               }
+               
+               /* use RNA to write the values... */
+               // TODO: do we need to write in 2 passes to make sure that no truncation goes on?
+               RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr);
+               
+               RNA_float_set(&strip_ptr, "frame_start", tdn->h1[0]);
+               RNA_float_set(&strip_ptr, "frame_end", tdn->h2[0]);
+               
+               /* flush transforms to child strips (since this should be a meta) */
+               BKE_nlameta_flush_transforms(strip);
+               
+               
+               /* now, check if we need to try and move track
+                *      - we need to calculate both, as only one may have been altered by transform if only 1 handle moved
+                */
+               delta_y1= ((int)tdn->h1[1] / NLACHANNEL_STEP(snla) - tdn->trackIndex);
+               delta_y2= ((int)tdn->h2[1] / NLACHANNEL_STEP(snla) - tdn->trackIndex);
+               
+               if (delta_y1 || delta_y2) {
+                       NlaTrack *track;
+                       int delta = (delta_y2) ? delta_y2 : delta_y1;
+                       int n;
                        
-                       /* now, check if we need to try and move track
-                        *      - we need to calculate both, as only one may have been altered by transform if only 1 handle moved
+                       /* move in the requested direction, checking at each layer if there's space for strip to pass through,
+                        * stopping on the last track available or that we're able to fit in
                         */
-                       delta_y1= ((int)tdn->h1[1] / NLACHANNEL_STEP - tdn->trackIndex);
-                       delta_y2= ((int)tdn->h2[1] / NLACHANNEL_STEP - tdn->trackIndex);
-                       
-                       if (delta_y1 || delta_y2) {
-                               NlaTrack *track;
-                               int delta = (delta_y2) ? delta_y2 : delta_y1;
-                               int n;
-                               
-                               /* move in the requested direction, checking at each layer if there's space for strip to pass through,
-                                * stopping on the last track available or that we're able to fit in
-                                */
-                               if (delta > 0) {
-                                       for (track=tdn->nlt->next, n=0; (track) && (n < delta); track=track->next, n++) {
-                                               /* check if space in this track for the strip */
-                                               if (BKE_nlatrack_has_space(track, strip->start, strip->end)) {
-                                                       /* move strip to this track */
-                                                       BLI_remlink(&tdn->nlt->strips, strip);
-                                                       BKE_nlatrack_add_strip(track, strip);
-                                                       
-                                                       tdn->nlt= track;
-                                                       tdn->trackIndex++;
-                                               }
-                                               else /* can't move any further */
-                                                       break;
+                       if (delta > 0) {
+                               for (track=tdn->nlt->next, n=0; (track) && (n < delta); track=track->next, n++) {
+                                       /* check if space in this track for the strip */
+                                       if (BKE_nlatrack_has_space(track, strip->start, strip->end)) {
+                                               /* move strip to this track */
+                                               BLI_remlink(&tdn->nlt->strips, strip);
+                                               BKE_nlatrack_add_strip(track, strip);
+                                               
+                                               tdn->nlt= track;
+                                               tdn->trackIndex++;
                                        }
+                                       else /* can't move any further */
+                                               break;
                                }
-                               else {
-                                       /* make delta 'positive' before using it, since we now know to go backwards */
-                                       delta= -delta;
-                                       
-                                       for (track=tdn->nlt->prev, n=0; (track) && (n < delta); track=track->prev, n++) {
-                                               /* check if space in this track for the strip */
-                                               if (BKE_nlatrack_has_space(track, strip->start, strip->end)) {
-                                                       /* move strip to this track */
-                                                       BLI_remlink(&tdn->nlt->strips, strip);
-                                                       BKE_nlatrack_add_strip(track, strip);
-                                                       
-                                                       tdn->nlt= track;
-                                                       tdn->trackIndex--;
-                                               }
-                                               else /* can't move any further */
-                                                       break;
+                       }
+                       else {
+                               /* make delta 'positive' before using it, since we now know to go backwards */
+                               delta= -delta;
+                               
+                               for (track=tdn->nlt->prev, n=0; (track) && (n < delta); track=track->prev, n++) {
+                                       /* check if space in this track for the strip */
+                                       if (BKE_nlatrack_has_space(track, strip->start, strip->end)) {
+                                               /* move strip to this track */
+                                               BLI_remlink(&tdn->nlt->strips, strip);
+                                               BKE_nlatrack_add_strip(track, strip);
+                                               
+                                               tdn->nlt= track;
+                                               tdn->trackIndex--;
                                        }
+                                       else /* can't move any further */
+                                               break;
                                }
                        }
                }
        }
-       else if (t->spacetype == SPACE_IMAGE) {
-               if (t->obedit && t->obedit->type == OB_MESH) {
-                       SpaceImage *sima= t->sa->spacedata.first;
+ }
+ /* helper for recalcData() - for 3d-view transforms */
+ static void recalcData_view3d(TransInfo *t)
+ {
+       Base *base = t->scene->basact;
+       
+       if (t->obedit) {
+               if ELEM(t->obedit->type, OB_CURVE, OB_SURF) {
+                       Curve *cu= t->obedit->data;
+                       ListBase *nurbs= ED_curve_editnurbs(cu);
+                       Nurb *nu= nurbs->first;
                        
-                       flushTransUVs(t);
-                       if(sima->flag & SI_LIVE_UNWRAP)
-                               ED_uvedit_live_unwrap_re_solve();
+                       if(t->state != TRANS_CANCEL) {
+                               clipMirrorModifier(t, t->obedit);
+                               applyProject(t);
+                       }
                        
-                       DAG_id_tag_update(t->obedit->data, 0);
-               }
-       }
-       else if (t->spacetype == SPACE_VIEW3D) {
-               
-               if (t->obedit) {
-                       if ELEM(t->obedit->type, OB_CURVE, OB_SURF) {
-                               Curve *cu= t->obedit->data;
-                               ListBase *nurbs= ED_curve_editnurbs(cu);
-                               Nurb *nu= nurbs->first;
-                               if(t->state != TRANS_CANCEL) {
-                                       clipMirrorModifier(t, t->obedit);
-                                       applyProject(t);
+                       DAG_id_tag_update(t->obedit->data, 0);  /* sets recalc flags */
+                               
+                       if (t->state == TRANS_CANCEL) {
+                               while(nu) {
+                                       calchandlesNurb(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */
+                                       nu= nu->next;
                                }
-                               DAG_id_tag_update(t->obedit->data, 0);  /* sets recalc flags */
-                               if (t->state == TRANS_CANCEL) {
-                                       while(nu) {
-                                               calchandlesNurb(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */
-                                               nu= nu->next;
-                                       }
-                               } else {
-                                       /* Normal updating */
-                                       while(nu) {
-                                               test2DNurb(nu);
-                                               calchandlesNurb(nu);
-                                               nu= nu->next;
-                                       }
 +
+                       } 
+                       else {
+                               /* Normal updating */
+                               while(nu) {
+                                       test2DNurb(nu);
+                                       calchandlesNurb(nu);
+                                       nu= nu->next;
                                }
                        }
-                       else if(t->obedit->type==OB_LATTICE) {
-                               Lattice *la= t->obedit->data;
-                               if(t->state != TRANS_CANCEL) {
-                                       applyProject(t);
-                               }
-                               DAG_id_tag_update(t->obedit->data, 0);  /* sets recalc flags */
-       
-                               if(la->editlatt->latt->flag & LT_OUTSIDE) outside_lattice(la->editlatt->latt);
+               }
+               else if(t->obedit->type==OB_LATTICE) {
+                       Lattice *la= t->obedit->data;
+                       
+                       if(t->state != TRANS_CANCEL) {
+                               applyProject(t);
                        }
-                       else if (t->obedit->type == OB_MESH) {
-                               BMEditMesh *em = ((Mesh*)t->obedit->data)->edit_btmesh;
-                               /* mirror modifier clipping? */
-                               if(t->state != TRANS_CANCEL) {
-                                       /* apply clipping after so we never project past the clip plane [#25423] */
-                                       applyProject(t);
-                                       clipMirrorModifier(t, t->obedit);
-                               }
-                               if((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR))
-                                       editbmesh_apply_to_mirror(t);
-                                       
-                               DAG_id_tag_update(t->obedit->data, 0);  /* sets recalc flags */
+                       
+                       DAG_id_tag_update(t->obedit->data, 0);  /* sets recalc flags */
+                       
+                       if(la->editlatt->latt->flag & LT_OUTSIDE) outside_lattice(la->editlatt->latt);
+               }
+               else if (t->obedit->type == OB_MESH) {
 -                      EditMesh *em = ((Mesh*)t->obedit->data)->edit_mesh;
++                      BMEditMesh *em = ((Mesh*)t->obedit->data)->edit_btmesh;
+                       /* mirror modifier clipping? */
+                       if(t->state != TRANS_CANCEL) {
+                               /* apply clipping after so we never project past the clip plane [#25423] */
+                               applyProject(t);
+                               clipMirrorModifier(t, t->obedit);
+                       }
+                       if((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR))
 -                              editmesh_apply_to_mirror(t);
++                              editbmesh_apply_to_mirror(t);
                                
-                               EDBM_RecalcNormals(em);
-                               BMEdit_RecalcTesselation(em);
+                       DAG_id_tag_update(t->obedit->data, 0);  /* sets recalc flags */
+                       
 -                      recalc_editnormals(em);
++                      EDBM_RecalcNormals(em);
++                      BMEdit_RecalcTesselation(em);
+               }
+               else if(t->obedit->type==OB_ARMATURE) { /* no recalc flag, does pose */
+                       bArmature *arm= t->obedit->data;
+                       ListBase *edbo = arm->edbo;
+                       EditBone *ebo;
+                       TransData *td = t->data;
+                       int i;
+                       
+                       if(t->state != TRANS_CANCEL) {
+                               applyProject(t);
                        }
-                       else if(t->obedit->type==OB_ARMATURE) { /* no recalc flag, does pose */
-                               bArmature *arm= t->obedit->data;
-                               ListBase *edbo = arm->edbo;
-                               EditBone *ebo;
-                               TransData *td = t->data;
-                               int i;
+                       
+                       /* Ensure all bones are correctly adjusted */
+                       for (ebo = edbo->first; ebo; ebo = ebo->next){
                                
-                               if(t->state != TRANS_CANCEL) {
-                                       applyProject(t);
-                               }
-                               /* Ensure all bones are correctly adjusted */
-                               for (ebo = edbo->first; ebo; ebo = ebo->next){
-                                       
-                                       if ((ebo->flag & BONE_CONNECTED) && ebo->parent){
-                                               /* If this bone has a parent tip that has been moved */
-                                               if (ebo->parent->flag & BONE_TIPSEL){
-                                                       VECCOPY (ebo->head, ebo->parent->tail);
-                                                       if(t->mode==TFM_BONE_ENVELOPE) ebo->rad_head= ebo->parent->rad_tail;
-                                               }
-                                               /* If this bone has a parent tip that has NOT been moved */
-                                               else{
-                                                       VECCOPY (ebo->parent->tail, ebo->head);
-                                                       if(t->mode==TFM_BONE_ENVELOPE) ebo->parent->rad_tail= ebo->rad_head;
-                                               }
+                               if ((ebo->flag & BONE_CONNECTED) && ebo->parent){
+                                       /* If this bone has a parent tip that has been moved */
+                                       if (ebo->parent->flag & BONE_TIPSEL){
+                                               VECCOPY (ebo->head, ebo->parent->tail);
+                                               if(t->mode==TFM_BONE_ENVELOPE) ebo->rad_head= ebo->parent->rad_tail;
                                        }
-                                       
-                                       /* on extrude bones, oldlength==0.0f, so we scale radius of points */
-                                       ebo->length= len_v3v3(ebo->head, ebo->tail);
-                                       if(ebo->oldlength==0.0f) {
-                                               ebo->rad_head= 0.25f*ebo->length;
-                                               ebo->rad_tail= 0.10f*ebo->length;
-                                               ebo->dist= 0.25f*ebo->length;
-                                               if(ebo->parent) {
-                                                       if(ebo->rad_head > ebo->parent->rad_tail)
-                                                               ebo->rad_head= ebo->parent->rad_tail;
-                                               }
-                                       }
-                                       else if(t->mode!=TFM_BONE_ENVELOPE) {
-                                               /* if bones change length, lets do that for the deform distance as well */
-                                               ebo->dist*= ebo->length/ebo->oldlength;
-                                               ebo->rad_head*= ebo->length/ebo->oldlength;
-                                               ebo->rad_tail*= ebo->length/ebo->oldlength;
-                                               ebo->oldlength= ebo->length;
+                                       /* If this bone has a parent tip that has NOT been moved */
+                                       else{
+                                               VECCOPY (ebo->parent->tail, ebo->head);
+                                               if(t->mode==TFM_BONE_ENVELOPE) ebo->parent->rad_tail= ebo->rad_head;
                                        }
                                }
                                
Simple merge