Explorar o código

Fix h3d.Scene.Skin.getBoundsRec not scaling correctly (#974)

Leonardo Jeanteur %!s(int64=4) %!d(string=hai) anos
pai
achega
6534d1ac76
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      h3d/scene/Skin.hx

+ 4 - 2
h3d/scene/Skin.hx

@@ -105,15 +105,17 @@ class Skin extends MultiMaterial {
 		syncJoints();
 		if( skinData.vertexWeights == null )
 			cast(primitive, h3d.prim.HMDModel).loadSkin(skinData);
+		var absScale = getAbsPos().getScale();
+		var scale = Math.max(Math.max(absScale.x, absScale.y), absScale.z);
 		for( j in skinData.allJoints ) {
 			if( j.offsetRay < 0 ) continue;
 			var m = currentPalette[j.bindIndex];
 			var pt = j.offsets.getMin();
 			pt.transform(m);
-			b.addSpherePos(pt.x, pt.y, pt.z, j.offsetRay);
+			b.addSpherePos(pt.x, pt.y, pt.z, j.offsetRay * scale);
 			var pt = j.offsets.getMax();
 			pt.transform(m);
-			b.addSpherePos(pt.x, pt.y, pt.z, j.offsetRay);
+			b.addSpherePos(pt.x, pt.y, pt.z, j.offsetRay * scale);
 		}
 		return b;
 	}