Skip to content

Commit d1a2703

Browse files
authored
Address Requested Changed from Codex
1 parent 6157277 commit d1a2703

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

jme3-core/src/main/java/com/jme3/light/PointLight.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,13 @@ public final void setRadius(float radius) {
165165
if (radius < 0) {
166166
throw new IllegalArgumentException("Light radius cannot be negative");
167167
}
168-
169-
// Fix #2566 - Prevent shader overflow with infinite or invalid radius
170-
if (radius == Float.POSITIVE_INFINITY || radius < 0f || Float.isNaN(radius)) {
171-
radius = Float.MAX_VALUE / 4f; // Safe large value, avoids overflow in shaders
168+
if(Float.isNaN(radius)){
169+
throw new IllegalArgumentException("Light radius cannot be a NaN (Not a Number) value");
172170
}
171+
// Prevent shader overflow with infinite or invalid radius
172+
if (radius == Float.POSITIVE_INFINITY || radius > Float.MAX_VALUE / 4.0f) {
173+
radius = Float.MAX_VALUE / 4.0f; // Safe large value, avoids overflow in shaders
174+
}
173175
this.radius = radius;
174176
if (radius != 0f) {
175177
this.invRadius = 1f / radius;
@@ -259,3 +261,4 @@ public String toString() {
259261
+ "]";
260262
}
261263
}
264+

0 commit comments

Comments
 (0)