[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21397] branches/soc-2009-aligorith/source /blender/editors/transform: NLA SoC: Auto-Snapping Fixes (Transform)

Joshua Leung aligorith at gmail.com
Tue Jul 7 08:21:38 CEST 2009


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

Log Message:
-----------
NLA SoC: Auto-Snapping Fixes (Transform) 

Snap to nearest-second works again for NLA and Graph Editors

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
    branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c

Modified: branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c	2009-07-07 06:16:06 UTC (rev 21396)
+++ branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c	2009-07-07 06:21:38 UTC (rev 21397)
@@ -101,16 +101,13 @@
 #include "BKE_context.h"
 #include "BKE_report.h"
 
-//#include "BIF_editaction.h"
 //#include "BIF_editview.h"
 //#include "BIF_editlattice.h"
 //#include "BIF_editconstraint.h"
 //#include "BIF_editmesh.h"
-//#include "BIF_editnla.h"
 //#include "BIF_editsima.h"
 //#include "BIF_editparticle.h"
 #include "BIF_gl.h"
-//#include "BIF_keyframing.h"
 //#include "BIF_poseobject.h"
 //#include "BIF_meshtools.h"
 //#include "BIF_mywindow.h"
@@ -127,6 +124,7 @@
 #include "ED_keyframing.h"
 #include "ED_keyframes_edit.h"
 #include "ED_object.h"
+#include "ED_markers.h"
 #include "ED_mesh.h"
 #include "ED_types.h"
 #include "ED_uvedit.h"
@@ -134,13 +132,7 @@
 
 #include "UI_view2d.h"
 
-//#include "BSE_drawipo.h"
 //#include "BSE_edit.h"
-//#include "BSE_editipo.h"
-//#include "BSE_editipo_types.h"
-//#include "BSE_editaction_types.h"
-
-//#include "BDR_drawaction.h"		// list of keyframes in action
 //#include "BDR_editobject.h"		// reset_slowparents()
 //#include "BDR_gpencil.h"
 
@@ -3671,6 +3663,8 @@
 	SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
 	TransData *td;
 	TransData2D *td2d;
+	Scene *scene= t->scene;
+	double secf= FPS;
 	int a;
 	
 	/* flush to 2d vector from internally used 3d vector */
@@ -3683,8 +3677,11 @@
 		 */
 		if ((td->flag & TD_NOTIMESNAP)==0) {
 			switch (sipo->autosnap) {
-				case SACTSNAP_FRAME: /* snap to nearest frame */
-					td2d->loc[0]= (float)( floor(td2d->loc[0]+0.5f) );
+				case SACTSNAP_FRAME: /* snap to nearest frame (or second if drawing seconds) */
+					if (sipo->flag & SIPO_DRAWTIME)
+						td2d->loc[0]= (float)( floor((td2d->loc[0]/secf) + 0.5f) * secf );
+					else
+						td2d->loc[0]= (float)( floor(td2d->loc[0]+0.5f) );
 					break;
 					
 				case SACTSNAP_MARKER: /* snap to nearest marker */

Modified: branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c	2009-07-07 06:16:06 UTC (rev 21396)
+++ branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c	2009-07-07 06:21:38 UTC (rev 21397)
@@ -341,6 +341,8 @@
 	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 
@@ -431,9 +433,15 @@
 			
 			/* handle auto-snapping */
 			switch (snla->autosnap) {
-				case SACTSNAP_FRAME: /* snap to nearest frame */
-					tdn->h1[0]= (float)( floor(tdn->h1[0]+0.5f) );
-					tdn->h2[0]= (float)( floor(tdn->h2[0]+0.5f) );
+				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;
 					
 				case SACTSNAP_MARKER: /* snap to nearest marker */





More information about the Bf-blender-cvs mailing list