Prevent boundingBox to create new vectors in distanceToEdge thanks to maximusgrey

http://jmonkeyengine.org/groups/graphics/forum/topic/boudingbox-and-vector3fs/#post-140072

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8077 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 13 years ago
parent 9a44e32fb2
commit 943e4c805d
  1. 8
      engine/src/core/com/jme3/bounding/BoundingBox.java

@ -805,7 +805,10 @@ public class BoundingBox extends BoundingVolume {
public float distanceToEdge(Vector3f point) {
// compute coordinates of point in box coordinate system
Vector3f closest = point.subtract(center);
TempVars vars= TempVars.get();
Vector3f closest = vars.vect1;
point.subtract(center,closest);
// project test point onto box
float sqrDistance = 0.0f;
@ -840,7 +843,8 @@ public class BoundingBox extends BoundingVolume {
sqrDistance += delta * delta;
closest.z = zExtent;
}
vars.release();
return FastMath.sqrt(sqrDistance);
}

Loading…
Cancel
Save