WIP: anim/armature-mode-spheres #106230

Draft
Sybren A. Stüvel wants to merge 2 commits from dr.sybren/blender:anim/armature-mode-spheres into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
8 changed files with 852 additions and 489 deletions

View File

@ -199,6 +199,13 @@ void BKE_armature_bone_hash_free(struct bArmature *arm);
bool BKE_armature_bone_flag_test_recursive(const struct Bone *bone, int flag); bool BKE_armature_bone_flag_test_recursive(const struct Bone *bone, int flag);
/**
* Return whether the armature supports selecting the head and tail separately
* from the bone itself (true) or whether the entire bone is selected as a
* single unit (false).
*/
bool BKE_armature_bone_can_select_headtail(const struct bArmature *arm);
void BKE_armature_refresh_layer_used(struct Depsgraph *depsgraph, struct bArmature *arm); void BKE_armature_refresh_layer_used(struct Depsgraph *depsgraph, struct bArmature *arm);
/** /**

View File

@ -658,6 +658,12 @@ bool BKE_armature_bone_flag_test_recursive(const Bone *bone, int flag)
return false; return false;
} }
bool BKE_armature_bone_can_select_headtail(const bArmature *arm)
{
/* Only 'Spheres' mode needs to select bones entirely, as it only shows the bones' heads. */
return arm->drawtype != ARM_SPHERES;
}
/** \} */ /** \} */
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

File diff suppressed because it is too large Load Diff

View File

@ -223,6 +223,9 @@ typedef struct OVERLAY_ArmatureCallBuffersInner {
DRWCallBuffer *wire; DRWCallBuffer *wire;
DRWCallBuffer *spheres_outline;
DRWCallBuffer *spheres_fill;
DRWShadingGroup *custom_outline; DRWShadingGroup *custom_outline;
DRWShadingGroup *custom_fill; DRWShadingGroup *custom_fill;
DRWShadingGroup *custom_wire; DRWShadingGroup *custom_wire;

View File

@ -131,6 +131,8 @@ static struct DRWShapeCache {
GPUBatch *drw_lightprobe_grid; GPUBatch *drw_lightprobe_grid;
GPUBatch *drw_bone_octahedral; GPUBatch *drw_bone_octahedral;
GPUBatch *drw_bone_octahedral_wire; GPUBatch *drw_bone_octahedral_wire;
GPUBatch *drw_bone_balls;
GPUBatch *drw_bone_balls_wire;
GPUBatch *drw_bone_box; GPUBatch *drw_bone_box;
GPUBatch *drw_bone_box_wire; GPUBatch *drw_bone_box_wire;
GPUBatch *drw_bone_envelope; GPUBatch *drw_bone_envelope;

View File

@ -649,7 +649,8 @@ static EditBone *get_nearest_editbonepoint(
/* find the bone after the current active bone, so as to bump up its chances in selection. /* find the bone after the current active bone, so as to bump up its chances in selection.
* this way overlapping bones will cycle selection state as with objects. */ * this way overlapping bones will cycle selection state as with objects. */
Object *obedit_orig = vc->obedit; Object *obedit_orig = vc->obedit;
EditBone *ebone_active_orig = ((bArmature *)obedit_orig->data)->act_edbone; bArmature *armature = ((bArmature *)obedit_orig->data);
EditBone *ebone_active_orig = armature->act_edbone;
if (ebone_active_orig == NULL) { if (ebone_active_orig == NULL) {
use_cycle = false; use_cycle = false;
} }
@ -846,16 +847,22 @@ cache_end:
if (result->hitresult != -1) { if (result->hitresult != -1) {
*r_base = result->base; *r_base = result->base;
*r_selmask = 0; if (BKE_armature_bone_can_select_headtail(armature)) {
if (result->hitresult & BONESEL_ROOT) { *r_selmask = 0;
*r_selmask |= BONE_ROOTSEL; if (result->hitresult & BONESEL_ROOT) {
*r_selmask |= BONE_ROOTSEL;
}
if (result->hitresult & BONESEL_TIP) {
*r_selmask |= BONE_TIPSEL;
}
if (result->hitresult & BONESEL_BONE) {
*r_selmask |= BONE_SELECTED;
}
} }
if (result->hitresult & BONESEL_TIP) { else {
*r_selmask |= BONE_TIPSEL; *r_selmask = BONE_SELECTED;
}
if (result->hitresult & BONESEL_BONE) {
*r_selmask |= BONE_SELECTED;
} }
MEM_freeN(bases); MEM_freeN(bases);
return result->ebone; return result->ebone;
} }

View File

@ -181,6 +181,7 @@ typedef enum eArmature_Drawtype {
ARM_B_BONE = 2, ARM_B_BONE = 2,
ARM_ENVELOPE = 3, ARM_ENVELOPE = 3,
ARM_WIRE = 4, ARM_WIRE = 4,
ARM_SPHERES = 5,
} eArmature_Drawtype; } eArmature_Drawtype;
/* armature->deformflag */ /* armature->deformflag */

View File

@ -1473,6 +1473,7 @@ static void rna_def_armature(BlenderRNA *brna)
0, 0,
"Wire", "Wire",
"Display bones as thin wires, showing subdivision and B-Splines"}, "Display bones as thin wires, showing subdivision and B-Splines"},
{ARM_SPHERES, "SPHERE", 0, "Sphere", "Display bones as spheres at the joints"},
{0, NULL, 0, NULL, NULL}, {0, NULL, 0, NULL, NULL},
}; };
static const EnumPropertyItem prop_pose_position_items[] = { static const EnumPropertyItem prop_pose_position_items[] = {