diff options
author | Ton Roosendaal <ton@blender.org> | 2006-06-14 12:50:41 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-06-14 12:50:41 +0400 |
commit | 8988a0de38dcf545447649ac778b145b2fb5e14a (patch) | |
tree | 494955a23de806932ba57a62ddd0585a3a3ad2cf | |
parent | 4ed583ea8ab29bcfd421dbf694737abfad44eac0 (diff) |
Bugfix #4329
New "Dimension" button: when using TAB to cycle over buttons, the dimension
event was sent multiple times, accumulating scaling. The code was also not
prepared to handle multiple changes at one event.
Also: added object_get_boundbox(Object *ob) in BKE_object.h, so the code
now really supports most primitives in Blender.
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 18 | ||||
-rw-r--r-- | source/blender/src/drawobject.c | 13 | ||||
-rw-r--r-- | source/blender/src/drawview.c | 69 |
4 files changed, 50 insertions, 51 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 37398ca3fcb..bbaf42a91b1 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -95,6 +95,7 @@ void where_is_object_simul(struct Object *ob); void what_does_parent(struct Object *ob); struct BoundBox *unit_boundbox(void); void boundbox_set_from_min_max(struct BoundBox *bb, float min[3], float max[3]); +struct BoundBox *object_get_boundbox(struct Object *ob); void minmax_object(struct Object *ob, float *min, float *max); void solve_tracking (struct Object *ob, float targetmat[][4]); void solve_constraints (struct Object *ob, short obtype, void *obdata, float ctime); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index d4aa87ec87a..fdae3ca2667 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1753,6 +1753,22 @@ void boundbox_set_from_min_max(BoundBox *bb, float min[3], float max[3]) bb->vec[1][2]=bb->vec[2][2]=bb->vec[5][2]=bb->vec[6][2]= max[2]; } +BoundBox *object_get_boundbox(Object *ob) +{ + BoundBox *bb= NULL; + + if(ob->type==OB_MESH) { + bb = mesh_get_bb(ob->data); + } + else if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) { + bb= ( (Curve *)ob->data )->bb; + } + else if(ob->type==OB_MBALL) { + bb= ob->bb; + } + return bb; +} + void minmax_object(Object *ob, float *min, float *max) { BoundBox bb; @@ -1768,7 +1784,7 @@ void minmax_object(Object *ob, float *min, float *max) case OB_SURF: cu= ob->data; - if(cu->bb==0) tex_space_curve(cu); + if(cu->bb==NULL) tex_space_curve(cu); bb= *(cu->bb); for(a=0; a<8; a++) { diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index b951aab1ef7..64eccc0598e 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -3346,20 +3346,11 @@ static void draw_box(float vec[8][3]) glEnd(); } +/* uses boundbox, function used by Ketsji */ void get_local_bounds(Object *ob, float *centre, float *size) { - BoundBox *bb= NULL; - /* uses boundbox, function used by Ketsji */ + BoundBox *bb= object_get_boundbox(ob); - if(ob->type==OB_MESH) { - bb = mesh_get_bb(ob->data); - } - else if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) { - bb= ( (Curve *)ob->data )->bb; - } - else if(ob->type==OB_MBALL) { - bb= ob->bb; - } if(bb==NULL) { centre[0]= centre[1]= centre[2]= 0.0; VECCOPY(size, ob->size); diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 6af966c7d12..d50fa3bbed5 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -135,6 +135,8 @@ #include "BIF_transform.h" +#include "RE_pipeline.h" // make_stars + /* Modules used */ #include "radio.h" @@ -1937,6 +1939,7 @@ static void v3d_editmetaball_buts(uiBlock *block, Object *ob, float lim) void do_viewbuts(unsigned short event) { + BoundBox *bb; View3D *vd; Object *ob= OBACT; char *name; @@ -2048,13 +2051,11 @@ void do_viewbuts(unsigned short event) break; case B_OBJECTPANELDIMS: - if(ob && (ob->type==OB_MESH)) { - BoundBox *bb; - float old_dims[3], scale[3], ratio, len[3], tmp, max = 0.0; - + bb= object_get_boundbox(ob); + if(bb) { + float old_dims[3], scale[3], ratio, len[3]; int axis; - bb = mesh_get_bb(ob->data); Mat4ToSize(ob->obmat, scale); len[0] = bb->vec[4][0] - bb->vec[0][0]; @@ -2065,40 +2066,34 @@ void do_viewbuts(unsigned short event) old_dims[1] = fabs(scale[1]) * len[1]; old_dims[2] = fabs(scale[2]) * len[2]; - /* figure out which axis changed */ - axis = 0; - max = fabs(ob_dims[0] - old_dims[0]); - tmp = fabs(ob_dims[1] - old_dims[1]); - if (tmp > max) { - axis = 1; - max = tmp; - } - tmp = fabs(ob_dims[2] - old_dims[2]); - if (tmp > max) { - axis = 2; - max = tmp; - } - - if (old_dims[axis] != ob_dims[axis]) { - if (old_dims[axis] > 0.0) { - ratio = ob_dims[axis] / old_dims[axis]; - if (link_scale) { - ob->size[0] *= ratio; - ob->size[1] *= ratio; - ob->size[2] *= ratio; + /* for each axis changed */ + for (axis = 0; axis<3; axis++) { + if (old_dims[axis] != ob_dims[axis]) { + if (old_dims[axis] > 0.0) { + ratio = ob_dims[axis] / old_dims[axis]; + if (link_scale) { + ob->size[0] *= ratio; + ob->size[1] *= ratio; + ob->size[2] *= ratio; + break; + } + else { + ob->size[axis] *= ratio; + } } else { - ob->size[axis] *= ratio; - } - } - else { - if (len[axis] > 0) { - ob->size[axis] = ob_dims[axis] / len[axis]; + if (len[axis] > 0) { + ob->size[axis] = ob_dims[axis] / len[axis]; + } } } - DAG_object_flush_update(G.scene, ob, OB_RECALC_OB); - allqueue(REDRAWVIEW3D, 1); } + + /* prevent multiple B_OBJECTPANELDIMS events to keep scaling, cycling with TAB on buttons can cause that */ + VECCOPY(ob_dims, old_dims); + + DAG_object_flush_update(G.scene, ob, OB_RECALC_OB); + allqueue(REDRAWVIEW3D, 1); } break; @@ -2286,11 +2281,7 @@ static void view3d_panel_object(short cntrl) // VIEW3D_HANDLER_OBJECT uiDefButS(block, TOG, REDRAWVIEW3D, "Link Scale", 10, 10, 140, 19, &(link_scale), 0, 1, 0, 0, "Size values vary proportionally in all directions"); - if(ob->type==OB_MESH) - bb = mesh_get_bb(ob->data); - else if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) - bb= ( (Curve *)ob->data )->bb; - + bb= object_get_boundbox(ob); if (bb) { float scale[3]; |