diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2015-08-13 19:12:08 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-08-13 19:12:08 +0300 |
commit | 3fa0a1a5bc0ff28328930ee12608497262b25912 (patch) | |
tree | ad87ae294bdfbc8e24add38f97dee41222a27ab0 /source | |
parent | d2383ec6c07a298a290b83ba8347618e3b46c9d9 (diff) |
Add real boundbox support to lattice, and update armature one.
* draw lattice boundingboxes in 3dView [if "show_bounds" is used -- an option previously pretty useless for lattices]
* give proper values for lattice objects ".bound_box" in bpy
* give proper values for armature objects ".bound_box" in bpy
* lets users use "Dimensions" [in 3dView Transform panel] on lattices and armatures
* remove redundant calculations in "boundbox_armature()"
Armatures boundingboxes were already drawn in 3dView, if "show_bounds" was used.
Based on report T45735: Lattice's bounding_box doesn't update,
and a comment in code by @campbellbarton ("later we may want to add dimensions for lattice, armature etc too").
Revision: https://developer.blender.org/D1460
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_lattice.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 25 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_buttons.c | 5 |
6 files changed, 41 insertions, 18 deletions
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index 4ffdb632513..e91d0e0ed87 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -80,6 +80,7 @@ void BKE_lattice_modifiers_calc(struct Scene *scene, struct Object *ob); struct MDeformVert *BKE_lattice_deform_verts_get(struct Object *lattice); struct BPoint *BKE_lattice_active_point_get(struct Lattice *lt); +struct BoundBox *BKE_lattice_boundbox_get(struct Object *ob); void BKE_lattice_minmax(struct Lattice *lt, float min[3], float max[3]); void BKE_lattice_center_median(struct Lattice *lt, float cent[3]); void BKE_lattice_center_bounds(struct Lattice *lt, float cent[3]); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 27d3d1c50fb..3643aa23998 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2182,39 +2182,27 @@ static int minmax_armature(Object *ob, float r_min[3], float r_max[3]) return (BLI_listbase_is_empty(&ob->pose->chanbase) == false); } -static void boundbox_armature(Object *ob, float loc[3], float size[3]) +static void boundbox_armature(Object *ob) { BoundBox *bb; float min[3], max[3]; - float mloc[3], msize[3]; if (ob->bb == NULL) - ob->bb = MEM_callocN(sizeof(BoundBox), "Armature boundbox"); + ob->bb = MEM_mallocN(sizeof(BoundBox), "Armature boundbox"); bb = ob->bb; - if (!loc) - loc = mloc; - if (!size) - size = msize; - INIT_MINMAX(min, max); if (!minmax_armature(ob, min, max)) { min[0] = min[1] = min[2] = -1.0f; max[0] = max[1] = max[2] = 1.0f; } - mid_v3_v3v3(loc, min, max); - - size[0] = (max[0] - min[0]) / 2.0f; - size[1] = (max[1] - min[1]) / 2.0f; - size[2] = (max[2] - min[2]) / 2.0f; - BKE_boundbox_init_from_minmax(bb, min, max); } BoundBox *BKE_armature_boundbox_get(Object *ob) { - boundbox_armature(ob, NULL, NULL); + boundbox_armature(ob); return ob->bb; } diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 86927609ff6..d3f666e2109 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -61,6 +61,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_modifier.h" +#include "BKE_object.h" #include "BKE_deform.h" @@ -1138,6 +1139,30 @@ void BKE_lattice_center_median(Lattice *lt, float cent[3]) mul_v3_fl(cent, 1.0f / (float)numVerts); } +static void boundbox_lattice(Object *ob) +{ + BoundBox *bb; + Lattice *lt; + float min[3], max[3]; + + if (ob->bb == NULL) + ob->bb = MEM_mallocN(sizeof(BoundBox), "Lattice boundbox"); + + bb = ob->bb; + lt = ob->data; + + INIT_MINMAX(min, max); + BKE_lattice_minmax(lt, min, max); + BKE_boundbox_init_from_minmax(bb, min, max); +} + +BoundBox *BKE_lattice_boundbox_get(Object *ob) +{ + boundbox_lattice(ob); + + return ob->bb; +} + void BKE_lattice_minmax(Lattice *lt, float min[3], float max[3]) { int i, numVerts; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 65599896f02..f8bfd46bb6e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -114,6 +114,7 @@ #include "BKE_material.h" #include "BKE_camera.h" #include "BKE_image.h" +#include "BKE_lattice.h" #ifdef WITH_MOD_FLUID #include "LBM_fluidsim.h" @@ -2652,6 +2653,12 @@ BoundBox *BKE_object_boundbox_get(Object *ob) else if (ob->type == OB_MBALL) { bb = ob->bb; } + else if (ob->type == OB_LATTICE) { + bb = BKE_lattice_boundbox_get(ob); + } + else if (ob->type == OB_ARMATURE) { + bb = BKE_armature_boundbox_get(ob); + } return bb; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index f8af238de14..f5cce277da1 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -7233,6 +7233,9 @@ static void draw_bounding_volume(Object *ob, char type) else if (ob->type == OB_ARMATURE) { bb = BKE_armature_boundbox_get(ob); } + else if (ob->type == OB_LATTICE) { + bb = BKE_lattice_boundbox_get(ob); + } else { const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f}; bb = &bb_local; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 1f8a69adba0..1a6bbfe77bb 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -992,9 +992,8 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) if (ptr->type == &RNA_Object) { Object *ob = ptr->data; - /* dimensions and material support just happen to be the same checks - * later we may want to add dimensions for lattice, armature etc too */ - if (OB_TYPE_SUPPORT_MATERIAL(ob->type)) { + /* dimensions and editmode just happen to be the same checks */ + if (OB_TYPE_SUPPORT_EDITMODE(ob->type)) { uiItemR(layout, ptr, "dimensions", 0, NULL, ICON_NONE); } } |