diff --git a/jme3-core/src/main/java/com/jme3/light/PointLight.java b/jme3-core/src/main/java/com/jme3/light/PointLight.java index 1468d1ba1..4b5224c30 100644 --- a/jme3-core/src/main/java/com/jme3/light/PointLight.java +++ b/jme3-core/src/main/java/com/jme3/light/PointLight.java @@ -203,7 +203,7 @@ public class PointLight extends Light { return true; } else { // Sphere v. sphere collision - return sphere.getCenter().subtract(position).lengthSquared() < FastMath.sqr(radius + sphere.getRadius()); + return Intersection.intersect(sphere, position, radius); } } diff --git a/jme3-core/src/main/java/com/jme3/light/SpotLight.java b/jme3-core/src/main/java/com/jme3/light/SpotLight.java index bd1c03c6e..bc1335b5b 100644 --- a/jme3-core/src/main/java/com/jme3/light/SpotLight.java +++ b/jme3-core/src/main/java/com/jme3/light/SpotLight.java @@ -34,6 +34,7 @@ package com.jme3.light; import com.jme3.bounding.BoundingBox; import com.jme3.bounding.BoundingSphere; import com.jme3.bounding.BoundingVolume; +import com.jme3.bounding.Intersection; import com.jme3.export.*; import com.jme3.math.ColorRGBA; import com.jme3.math.FastMath; @@ -189,9 +190,7 @@ public class SpotLight extends Light { if (this.spotRange > 0f) { // Check spot range first. // Sphere v. box collision - if (FastMath.abs(box.getCenter().x - position.x) >= spotRange + box.getXExtent() - || FastMath.abs(box.getCenter().y - position.y) >= spotRange + box.getYExtent() - || FastMath.abs(box.getCenter().z - position.z) >= spotRange + box.getZExtent()) { + if (!Intersection.intersect(box, position, spotRange)) { return false; } } @@ -231,7 +230,7 @@ public class SpotLight extends Light { if (this.spotRange > 0f) { // Check spot range first. // Sphere v. sphere collision - if (sphere.getCenter().subtract(position).lengthSquared() >= FastMath.sqr(spotRange + sphere.getRadius())) { + if (!Intersection.intersect(sphere, position, spotRange)) { return false; } }