Fix [#30614] (some Display settings are uneeded for non-geometry/material object...
authorBastien Montagne <montagne29@wanadoo.fr>
Thu, 22 Mar 2012 13:27:24 +0000 (13:27 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Thu, 22 Mar 2012 13:27:24 +0000 (13:27 +0000)
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.

release/scripts/startup/bl_ui/properties_object.py
source/blender/blenkernel/BKE_armature.h
source/blender/blenkernel/intern/armature.c
source/blender/editors/space_view3d/drawobject.c

index 3570feb6f5669e031d7dcf42f43f9e48fce75c36..3a84517a369bb01767c868de7fc9866939d0fe93 100644 (file)
@@ -211,8 +211,11 @@ class OBJECT_PT_display(ObjectButtonsPanel, Panel):
         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")
index 441d63be764947515e92543acb1f98318ba54278..e4802cfa37faef82dbc396a7b6703a7e3d03a374 100644 (file)
@@ -82,6 +82,9 @@ void free_armature(struct bArmature *arm);
 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);
index 9bf8de4a2e110cc1d7f28732abe60ac2f126e10b..09fd3199915ca00cd654919cdacdcf8be3f3ff5c 100644 (file)
@@ -2599,3 +2599,54 @@ int get_selected_defgroups(Object *ob, char *dg_selection, int defbase_tot)
 
        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;
+}
index 82dca5007372fb80462c5e5005f4316e7c874356..f18ee9220a90b6bc83bffcda736c90d37eb25227 100644 (file)
@@ -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 @@ static void draw_bounding_volume(Scene *scene, Object *ob, char type)
                        }
                }
        }
+       else if (ob->type == OB_ARMATURE) {
+               bb = BKE_armature_get_bb(ob);
+       }
        else {
                drawcube();
                return;
@@ -6715,10 +6719,20 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                        }
                        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: