From bdebaf0fb49ff05750b283bbd92d21bb57127a19 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 22 Mar 2012 13:27:24 +0000 Subject: 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. --- source/blender/blenkernel/intern/armature.c | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'source/blender/blenkernel/intern/armature.c') 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; +} -- cgit v1.2.3