From 3fa0a1a5bc0ff28328930ee12608497262b25912 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Thu, 13 Aug 2015 18:12:08 +0200 Subject: 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 --- source/blender/blenkernel/intern/lattice.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source/blender/blenkernel/intern/lattice.c') 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; -- cgit v1.2.3