diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2020-02-28 15:36:17 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2020-03-03 11:48:04 +0300 |
commit | ee7034949fd8a44e906f26cc18bc30af340c2ab9 (patch) | |
tree | f0c3fea9caeeee291d5c04f90cb7e8f04b97edb6 | |
parent | d6fd09249534911aa57df4c529aa81f853dffc38 (diff) |
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
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_armature.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c index 1d0a01d8ff8..537698c7789 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.c +++ b/source/blender/draw/engines/overlay/overlay_armature.c @@ -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; |