Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions jme3-core/src/main/java/com/jme3/light/PointLight.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ public final void setRadius(float radius) {
if (radius < 0) {
throw new IllegalArgumentException("Light radius cannot be negative");
}

if (radius == Float.POSITIVE_INFINITY) {
radius = Float.MAX_VALUE;
if(Float.isNaN(radius)){
throw new IllegalArgumentException("Light radius cannot be a NaN (Not a Number) value");
}

float maxSafeRadius = Float.MAX_VALUE / 4.0f;
radius = Math.min(radius, maxSafeRadius); // Caps radius to a safe large value; avoids overflow in shaders from values reaching max float value

this.radius = radius;
if (radius != 0f) {
Expand Down Expand Up @@ -259,3 +261,5 @@ public String toString() {
+ "]";
}
}