forked from bartvdbraak/blender
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.
This commit is contained in:
parent
44eb9cc272
commit
bdebaf0fb4
@ -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")
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user