Fix bone envelopes displaying wrong when armature is scaled

Object Scale was not taken into account.

This lead to reports like T74247 where the user scaled the envelope
distance and radii to the supposedly right values inthe viewport, but
these were actually 'wrong' under the hood. Assigning weights from bone
envelopes seemed like it would fail, but this code would actually take
the armature scaling into account when checking envelope distance and
weight.

ref T74247

Maniphest Tasks: T74247

Differential Revision: https://developer.blender.org/D6964
This commit is contained in:
Philipp Oeser
2020-02-28 13:36:17 +01:00
parent d6fd092495
commit ee7034949f

View File

@@ -413,10 +413,11 @@ static void drw_shgroup_bone_envelope_distance(ArmatureDrawContext *ctx,
mul_m4_v4(ctx->ob->obmat, tail_sph);
mul_m4_v4(ctx->ob->obmat, xaxis);
sub_v3_v3(xaxis, head_sph);
head_sph[3] = *radius_head;
head_sph[3] += *distance;
tail_sph[3] = *radius_tail;
tail_sph[3] += *distance;
float obscale = mat4_to_scale(ctx->ob->obmat);
head_sph[3] = *radius_head * obscale;
head_sph[3] += *distance * obscale;
tail_sph[3] = *radius_tail * obscale;
tail_sph[3] += *distance * obscale;
DRW_buffer_add_entry(ctx->envelope_distance, head_sph, tail_sph, xaxis);
}
}
@@ -438,8 +439,9 @@ static void drw_shgroup_bone_envelope(ArmatureDrawContext *ctx,
mul_m4_v4(ctx->ob->obmat, head_sph);
mul_m4_v4(ctx->ob->obmat, tail_sph);
mul_m4_v4(ctx->ob->obmat, xaxis);
head_sph[3] = *radius_head;
tail_sph[3] = *radius_tail;
float obscale = mat4_to_scale(ctx->ob->obmat);
head_sph[3] = *radius_head * obscale;
tail_sph[3] = *radius_tail * obscale;
if (head_sph[3] < 0.0f || tail_sph[3] < 0.0f) {
BoneInstanceData inst_data;