[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45084] trunk/blender: Fix [#30614] ( some Display settings are uneeded for non-geometry/material object types, and armature have no boundbox).

Bastien Montagne montagne29 at wanadoo.fr
Thu Mar 22 14:27:27 CET 2012


Revision: 45084
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45084
Author:   mont29
Date:     2012-03-22 13:27:24 +0000 (Thu, 22 Mar 2012)
Log Message:
-----------
Fix [#30614] (some Display settings are uneeded for non-geometry/material object types, and armature have no boundbox).

This commit:
* Removes the Wire and Color options from the UI for all object types but meshes, curves/surfaces/texts, and metas.
* Adds a basic bounding box drawing (and computing) for armatures.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_object.py
    trunk/blender/source/blender/blenkernel/BKE_armature.h
    trunk/blender/source/blender/blenkernel/intern/armature.c
    trunk/blender/source/blender/editors/space_view3d/drawobject.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_object.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_object.py	2012-03-22 13:22:28 UTC (rev 45083)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_object.py	2012-03-22 13:27:24 UTC (rev 45084)
@@ -211,8 +211,11 @@
         col = split.column()
         col.prop(ob, "show_name", text="Name")
         col.prop(ob, "show_axis", text="Axis")
-        col.prop(ob, "show_wire", text="Wire")
-        col.prop(ob, "color", text="Object Color")
+        if ob.type in {"MESH", "CURVE", "SURFACE", "META", "FONT"}:
+            # Makes no sense for cameras, armtures, etc.!
+            col.prop(ob, "show_wire", text="Wire")
+            # Only useful with object having faces/materials...
+            col.prop(ob, "color", text="Object Color")
 
         col = split.column()
         col.prop(ob, "show_texture_space", text="Texture Space")

Modified: trunk/blender/source/blender/blenkernel/BKE_armature.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_armature.h	2012-03-22 13:22:28 UTC (rev 45083)
+++ trunk/blender/source/blender/blenkernel/BKE_armature.h	2012-03-22 13:27:24 UTC (rev 45084)
@@ -82,6 +82,9 @@
 void make_local_armature(struct bArmature *arm);
 struct bArmature *copy_armature(struct bArmature *arm);
 
+/* Bounding box. */
+struct BoundBox *BKE_armature_get_bb(struct Object *ob);
+
 int bone_autoside_name (char name[64], int strip_number, short axis, float head, float tail);
 
 struct Bone *get_named_bone (struct bArmature *arm, const char *name);

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c	2012-03-22 13:22:28 UTC (rev 45083)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c	2012-03-22 13:27:24 UTC (rev 45084)
@@ -2599,3 +2599,54 @@
 
 	return dg_flags_sel_tot;
 }
+
+/************** Bounding box ********************/
+int minmax_armature(Object *ob, float min[3], float max[3])
+{
+	bPoseChannel *pchan;
+
+	/* For now, we assume where_is_pose has already been called (hence we have valid data in pachan). */
+	for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+		DO_MINMAX(pchan->pose_head, min, max);
+		DO_MINMAX(pchan->pose_tail, min, max);
+	}
+
+	return (ob->pose->chanbase.first != NULL);
+}
+
+void boundbox_armature(Object *ob, float *loc, float *size)
+{
+	BoundBox *bb;
+	float min[3], max[3];
+	float mloc[3], msize[3];
+
+	if (ob->bb == NULL)
+		ob->bb = MEM_callocN(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;
+
+	boundbox_set_from_min_max(bb, min, max);
+}
+
+BoundBox *BKE_armature_get_bb(Object *ob)
+{
+	boundbox_armature(ob, NULL, NULL);
+
+	return ob->bb;
+}

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c	2012-03-22 13:22:28 UTC (rev 45083)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c	2012-03-22 13:27:24 UTC (rev 45084)
@@ -56,6 +56,7 @@
 #include "BLI_utildefines.h"
 
 #include "BKE_anim.h"			//for the where_on_path function
+#include "BKE_armature.h"
 #include "BKE_camera.h"
 #include "BKE_constraint.h" // for the get_constraint_target function
 #include "BKE_curve.h"
@@ -6134,6 +6135,9 @@
 			}
 		}
 	}
+	else if (ob->type == OB_ARMATURE) {
+		bb = BKE_armature_get_bb(ob);
+	}
 	else {
 		drawcube();
 		return;
@@ -6715,10 +6719,20 @@
 			}
 			break;
 		case OB_ARMATURE:
-			if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
-				if (dt>OB_WIRE) GPU_enable_material(0, NULL); // we use default material
-				empty_object= draw_armature(scene, v3d, ar, base, dt, flag, FALSE);
-				if (dt>OB_WIRE) GPU_disable_material();
+			if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+				/* Do not allow boundbox in edit nor pose mode! */
+				if ((dt == OB_BOUNDBOX) && (ob->mode & (OB_MODE_EDIT | OB_MODE_POSE)))
+					dt = OB_WIRE;
+				if (dt == OB_BOUNDBOX) {
+					draw_bounding_volume(scene, ob, ob->boundtype);
+				}
+				else {
+					if (dt>OB_WIRE)
+						GPU_enable_material(0, NULL); /* we use default material */
+					empty_object = draw_armature(scene, v3d, ar, base, dt, flag, FALSE);
+					if (dt>OB_WIRE)
+						GPU_disable_material();
+				}
 			}
 			break;
 		default:




More information about the Bf-blender-cvs mailing list