diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index 3570feb6f56..3a84517a369 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -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") diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 441d63be764..e4802cfa37f 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -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); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 9bf8de4a2e1..09fd3199915 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -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; +} diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 82dca500737..f18ee9220a9 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -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: