Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2009-12-27 21:09:17 +0300
committerMartin Poirier <theeth@yahoo.com>2009-12-27 21:09:17 +0300
commit280a1d09f6cafa5bd9b117b5b39bf90b2d21bdf0 (patch)
tree80c723f366b6d67646ab700460008422e1ffe71d /source
parentd1f1583c7979369d3fcc91ff25aea1b8152dcce7 (diff)
Partial fix for [#20166] Snap to grid issues
Move gridview (the actual drawn grid size, including adaptation to zoom) to RegionView3D from View3D. This solves the transform increment bug but not the Snap Menu bug (context is not set to the correct rv3d when executing operator from menu).
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c14
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c25
-rw-r--r--source/blender/editors/transform/transform.c4
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h9
4 files changed, 28 insertions, 24 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index be607d7ea77..2cef7461e85 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -307,7 +307,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_u
/* Store the smallest drawn grid size units name so users know how big each grid cell is */
if(*grid_unit==NULL) {
*grid_unit= bUnit_GetNameDisplay(usys, i);
- v3d->gridview= (scalar * unit->scale_length);
+ rv3d->gridview= (scalar * unit->scale_length);
}
blend_fac= 1-((GRID_MIN_PX*2)/dx_scalar);
@@ -326,15 +326,15 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_u
short sublines = v3d->gridsubdiv;
if(dx<GRID_MIN_PX) {
- v3d->gridview*= sublines;
+ rv3d->gridview*= sublines;
dx*= sublines;
if(dx<GRID_MIN_PX) {
- v3d->gridview*= sublines;
+ rv3d->gridview*= sublines;
dx*= sublines;
if(dx<GRID_MIN_PX) {
- v3d->gridview*= sublines;
+ rv3d->gridview*= sublines;
dx*=sublines;
if(dx<GRID_MIN_PX);
else {
@@ -360,10 +360,10 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_u
}
else {
if(dx>(GRID_MIN_PX*10)) { // start blending in
- v3d->gridview/= sublines;
+ rv3d->gridview/= sublines;
dx/= sublines;
if(dx>(GRID_MIN_PX*10)) { // start blending in
- v3d->gridview/= sublines;
+ rv3d->gridview/= sublines;
dx/= sublines;
if(dx>(GRID_MIN_PX*10)) {
UI_ThemeColor(TH_GRID);
@@ -2034,7 +2034,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
v3d->zbuf= FALSE;
// needs to be done always, gridview is adjusted in drawgrid() now
- v3d->gridview= v3d->grid;
+ rv3d->gridview= v3d->grid;
if(rv3d->view==0 || rv3d->persp!=0) {
drawfloor(scene, v3d);
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 3147abd499b..b56a853d5b7 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -440,12 +440,12 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
extern float originmat[3][3]; /* XXX object.c */
Object *obedit= CTX_data_edit_object(C);
Scene *scene= CTX_data_scene(C);
- View3D *v3d= CTX_wm_view3d(C);
+ RegionView3D *rv3d= CTX_wm_region_data(C);
TransVert *tv;
float gridf, imat[3][3], bmat[3][3], vec[3];
int a;
- gridf= v3d->gridview;
+ gridf= rv3d->gridview;
if(obedit) {
tottrans= 0;
@@ -463,9 +463,9 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
VECCOPY(vec, tv->loc);
mul_m3_v3(bmat, vec);
add_v3_v3v3(vec, vec, obedit->obmat[3]);
- vec[0]= v3d->gridview*floor(.5+ vec[0]/gridf);
- vec[1]= v3d->gridview*floor(.5+ vec[1]/gridf);
- vec[2]= v3d->gridview*floor(.5+ vec[2]/gridf);
+ vec[0]= gridf*floor(.5+ vec[0]/gridf);
+ vec[1]= gridf*floor(.5+ vec[1]/gridf);
+ vec[2]= gridf*floor(.5+ vec[2]/gridf);
sub_v3_v3v3(vec, vec, obedit->obmat[3]);
mul_m3_v3(imat, vec);
@@ -518,9 +518,9 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
else {
ob->recalc |= OB_RECALC_OB;
- vec[0]= -ob->obmat[3][0]+v3d->gridview*floor(.5+ ob->obmat[3][0]/gridf);
- vec[1]= -ob->obmat[3][1]+v3d->gridview*floor(.5+ ob->obmat[3][1]/gridf);
- vec[2]= -ob->obmat[3][2]+v3d->gridview*floor(.5+ ob->obmat[3][2]/gridf);
+ vec[0]= -ob->obmat[3][0]+gridf*floor(.5+ ob->obmat[3][0]/gridf);
+ vec[1]= -ob->obmat[3][1]+gridf*floor(.5+ ob->obmat[3][1]/gridf);
+ vec[2]= -ob->obmat[3][2]+gridf*floor(.5+ ob->obmat[3][2]/gridf);
if(ob->parent) {
where_is_object(scene, ob);
@@ -696,15 +696,16 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot)
static int snap_curs_to_grid(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
+ RegionView3D *rv3d= CTX_wm_region_data(C);
View3D *v3d= CTX_wm_view3d(C);
float gridf, *curs;
- gridf= v3d->gridview;
+ gridf= rv3d->gridview;
curs= give_cursor(scene, v3d);
- curs[0]= v3d->gridview*floor(.5+curs[0]/gridf);
- curs[1]= v3d->gridview*floor(.5+curs[1]/gridf);
- curs[2]= v3d->gridview*floor(.5+curs[2]/gridf);
+ curs[0]= gridf*floor(.5+curs[0]/gridf);
+ curs[1]= gridf*floor(.5+curs[1]/gridf);
+ curs[2]= gridf*floor(.5+curs[2]/gridf);
WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM, scene); // hrm
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 40db0f7b272..fa435f29773 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -3083,10 +3083,10 @@ void initTranslation(TransInfo *t)
t->ndof.axis = (t->flag & T_2D_EDIT)? 1|2: 1|2|4;
if(t->spacetype == SPACE_VIEW3D) {
- View3D *v3d = t->view;
+ RegionView3D *rv3d = t->ar->regiondata;
t->snap[0] = 0.0f;
- t->snap[1] = v3d->gridview * 1.0f;
+ t->snap[1] = rv3d->gridview * 1.0f;
t->snap[2] = t->snap[1] * 0.1f;
}
else if(t->spacetype == SPACE_IMAGE) {
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 5326c17688d..1ea060c2eea 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -114,8 +114,9 @@ typedef struct RegionView3D {
/* last view */
float lviewquat[4];
short lpersp, lview;
- int pad3;
+ float gridview;
+
} RegionView3D;
/* 3D ViewPort Struct */
@@ -151,8 +152,10 @@ typedef struct View3D {
short pivot_last; /* pivot_last is for rotating around the last edited element */
- float lens, grid, gridview, padf, near, far;
- float ofs[3]; /* XXX depricated */
+ float lens, grid;
+ float gridview; /* XXX deprecated, now in RegionView3D */
+ float padf, near, far;
+ float ofs[3]; /* XXX deprecated */
float cursor[3];
short gridlines, pad4;