Skip to content

Commit 6157277

Browse files
committed
Fix PointLight infinite radius shader overflow(#2566)
Clamps infinite, negative, or Not a Number radius to Float.MAX_VALUE / 4f to prevent type overflow in shaders, as discussed in #2566.
1 parent a63ea7b commit 6157277

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ public final void setRadius(float radius) {
165165
if (radius < 0) {
166166
throw new IllegalArgumentException("Light radius cannot be negative");
167167
}
168-
169-
if (radius == Float.POSITIVE_INFINITY) {
170-
radius = Float.MAX_VALUE;
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
171172
}
172-
173173
this.radius = radius;
174174
if (radius != 0f) {
175175
this.invRadius = 1f / radius;

0 commit comments

Comments
 (0)