Skip to content
Open
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
8 changes: 4 additions & 4 deletions jme3-core/src/main/java/com/jme3/light/PointLight.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ 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;

// Fix #2566 - Prevent shader overflow with infinite or invalid radius
if (radius == Float.POSITIVE_INFINITY || radius < 0f || Float.isNaN(radius)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to throw an exception on negative or NaN radius, since both are meaningless as radii. Negative radius already throws an exception previously.

radius = Float.MAX_VALUE / 4f; // Safe large value, avoids overflow in shaders
}

this.radius = radius;
if (radius != 0f) {
this.invRadius = 1f / radius;
Expand Down
Loading