From 76147fc5f745200f4a363f71470fd179819ccb3f Mon Sep 17 00:00:00 2001 From: shadowislord Date: Sun, 1 Jun 2014 14:32:49 -0400 Subject: [PATCH] * Throw exception if the spot light computed cosine angle is not valid --- .../src/main/java/com/jme3/light/SpotLight.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 f566f0dc7..0ede9cd72 100644 --- a/jme3-core/src/main/java/com/jme3/light/SpotLight.java +++ b/jme3-core/src/main/java/com/jme3/light/SpotLight.java @@ -68,15 +68,19 @@ public class SpotLight extends Light implements Savable { } private void computePackedCos() { - float innerCos=FastMath.cos(spotInnerAngle); - float outerCos=FastMath.cos(spotOuterAngle); - packedAngleCos=(int)(innerCos*1000); + float innerCos = FastMath.cos(spotInnerAngle); + float outerCos = FastMath.cos(spotOuterAngle); + packedAngleCos = (int) (innerCos * 1000); //due to approximations, very close angles can give the same cos //here we make sure outer cos is bellow inner cos. - if(((int)packedAngleCos)== ((int)(outerCos*1000)) ){ + if (((int) packedAngleCos) == ((int) (outerCos * 1000))) { outerCos -= 0.001f; } - packedAngleCos+=outerCos; + packedAngleCos += outerCos; + + if (packedAngleCos == 0.0f) { + throw new IllegalArgumentException("Packed angle cosine is invalid"); + } } @Override