[Bf-blender-cvs] [ee7034949fd] master: Fix bone envelopes displaying wrong when armature is scaled

Philipp Oeser noreply at git.blender.org
Tue Mar 3 09:51:12 CET 2020


Commit: ee7034949fd8a44e906f26cc18bc30af340c2ab9
Author: Philipp Oeser
Date:   Fri Feb 28 13:36:17 2020 +0100
Branches: master
https://developer.blender.org/rBee7034949fd8a44e906f26cc18bc30af340c2ab9

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

===================================================================

M	source/blender/draw/engines/overlay/overlay_armature.c

===================================================================

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;



More information about the Bf-blender-cvs mailing list