From f0dcd2db75b488be000a8be310e1c8a65e85227e Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Wed, 25 Oct 2006 23:57:00 +0000 Subject: == Transform == Embryon functionnality for snapping. - Only snaps to grid on translations (grab) - Transform constraints are supported but header display is wrong. - Can be turned on/off in the Object/Mesh header menu under Transform Properties (tentative spot, will have to integrate better and in other object type menus too) - Can be turned on/off during transform with ` (Back Quote, also tentative) This is, of course, very much Work in Progress. This implements part of the structural ideas for the transform cleanup I've been juggling around with. --- source/blender/src/transform_generics.c | 60 +-------------------------------- 1 file changed, 1 insertion(+), 59 deletions(-) (limited to 'source/blender/src/transform_generics.c') diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c index 09ad6e7a788..0ed75810b42 100755 --- a/source/blender/src/transform_generics.c +++ b/source/blender/src/transform_generics.c @@ -480,6 +480,7 @@ void initTrans (TransInfo *t) t->around = V3D_CENTRE; setTransformViewMatrices(t); + resetSnapping(t); } /* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */ @@ -532,65 +533,6 @@ void postTrans (TransInfo *t) } } -static void apply_grid3(TransInfo *t, float *val, int max_index, float fac1, float fac2, float fac3) -{ - /* fac1 is for 'nothing', fac2 for CTRL, fac3 for SHIFT */ - int invert; - int ctrl; - int i; - float asp= 1.0f; - - if(t->mode==TFM_ROTATION || t->mode==TFM_WARP || t->mode==TFM_TILT || t->mode==TFM_TRACKBALL) - invert = U.flag & USER_AUTOROTGRID; - else if(t->mode==TFM_RESIZE || t->mode==TFM_SHEAR || t->mode==TFM_BONESIZE || t->mode==TFM_SHRINKFATTEN || t->mode==TFM_CURVE_SHRINKFATTEN) - invert = U.flag & USER_AUTOSIZEGRID; - else - invert = U.flag & USER_AUTOGRABGRID; - - for (i=0; i<=max_index; i++) { - - /* evil hack - snapping needs to be adapted for image aspect ratio */ - if((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) { - float aspx, aspy; - transform_aspect_ratio_tface_uv(&aspx, &aspy); - if(i==0) asp= aspx; - else asp= aspy; - } - - if(invert) { - if(G.qual & LR_CTRLKEY) ctrl= 0; - else ctrl= 1; - } - else ctrl= (G.qual & LR_CTRLKEY); - - if(ctrl && (G.qual & LR_SHIFTKEY)) { - if(fac3!= 0.0) { - for (i=0; i<=max_index; i++) { - val[i]= fac3*asp*(float)floor(val[i]/(fac3*asp) +.5); - } - } - } - else if(ctrl) { - if(fac2!= 0.0) { - for (i=0; i<=max_index; i++) { - val[i]= fac2*asp*(float)floor(val[i]/(fac2*asp) +.5); - } - } - } - else { - if(fac1!= 0.0) { - for (i=0; i<=max_index; i++) { - val[i]= fac1*asp*(float)floor(val[i]/(fac1*asp) +.5); - } - } - } - } -} - -void snapGrid(TransInfo *t, float *val) { - apply_grid3(t, val, t->idx_max, t->snap[0], t->snap[1], t->snap[2]); -} - void applyTransObjects(TransInfo *t) { TransData *td; -- cgit v1.2.3