fix crash in light textures example (#20161)

# Objective

scaling the point light to zero caused a crash

## Solution

clamp the scale for all the lights
This commit is contained in:
robtfm 2025-07-16 17:42:40 +01:00 committed by GitHub
parent 3fc49f00c1
commit d28d18e2ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -540,14 +540,16 @@ fn process_scale_input(
for (mut transform, selection) in &mut scale_selections {
if app_status.selection == *selection {
transform.scale *= 1.0 + mouse_motion.delta.x * SCALE_SPEED;
transform.scale = (transform.scale * (1.0 + mouse_motion.delta.x * SCALE_SPEED))
.clamp(Vec3::splat(0.01), Vec3::splat(5.0));
}
}
for (mut spotlight, selection) in &mut spotlight_selections {
if app_status.selection == *selection {
spotlight.outer_angle =
(spotlight.outer_angle * (1.0 + mouse_motion.delta.x * SCALE_SPEED)).min(FRAC_PI_4);
spotlight.outer_angle = (spotlight.outer_angle
* (1.0 + mouse_motion.delta.x * SCALE_SPEED))
.clamp(0.01, FRAC_PI_4);
spotlight.inner_angle = spotlight.outer_angle;
}
}