[Bf-blender-cvs] [3fa0a1a] master: Add real boundbox support to lattice, and update armature one.

Philipp Oeser noreply at git.blender.org
Thu Aug 13 18:16:59 CEST 2015


Commit: 3fa0a1a5bc0ff28328930ee12608497262b25912
Author: Philipp Oeser
Date:   Thu Aug 13 18:12:08 2015 +0200
Branches: master
https://developer.blender.org/rB3fa0a1a5bc0ff28328930ee12608497262b25912

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

===================================================================

M	source/blender/blenkernel/BKE_lattice.h
M	source/blender/blenkernel/intern/armature.c
M	source/blender/blenkernel/intern/lattice.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/editors/space_view3d/view3d_buttons.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index 4ffdb63..e91d0e0 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 27d3d1c..3643aa2 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 8692760..d3f666e 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 6559989..f8bfd46 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 f8af238..f5cce27 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 1f8a69a..1a6bbfe 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);
 		}
 	}




More information about the Bf-blender-cvs mailing list