Skip to content

Commit d28d18e

Browse files
authored
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
1 parent 3fc49f0 commit d28d18e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

examples/3d/light_textures.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,14 +540,16 @@ fn process_scale_input(
540540

541541
for (mut transform, selection) in &mut scale_selections {
542542
if app_status.selection == *selection {
543-
transform.scale *= 1.0 + mouse_motion.delta.x * SCALE_SPEED;
543+
transform.scale = (transform.scale * (1.0 + mouse_motion.delta.x * SCALE_SPEED))
544+
.clamp(Vec3::splat(0.01), Vec3::splat(5.0));
544545
}
545546
}
546547

547548
for (mut spotlight, selection) in &mut spotlight_selections {
548549
if app_status.selection == *selection {
549-
spotlight.outer_angle =
550-
(spotlight.outer_angle * (1.0 + mouse_motion.delta.x * SCALE_SPEED)).min(FRAC_PI_4);
550+
spotlight.outer_angle = (spotlight.outer_angle
551+
* (1.0 + mouse_motion.delta.x * SCALE_SPEED))
552+
.clamp(0.01, FRAC_PI_4);
551553
spotlight.inner_angle = spotlight.outer_angle;
552554
}
553555
}

0 commit comments

Comments
 (0)