1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Merge pull request #101110 from clayjohn/light2d-rect-fix

Update Light2D `rect_cache` even when not using shadows.
This commit is contained in:
Rémi Verschelde
2025-01-06 22:49:01 +01:00

View File

@@ -432,7 +432,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
tsize *= cl->scale; tsize *= cl->scale;
Vector2 offset = tsize / 2.0; Vector2 offset = tsize / 2.0;
cl->rect_cache = Rect2(-offset + cl->texture_offset, tsize); Rect2 local_rect = Rect2(-offset + cl->texture_offset, tsize);
if (!RSG::canvas->_interpolation_data.interpolation_enabled || !cl->interpolated) { if (!RSG::canvas->_interpolation_data.interpolation_enabled || !cl->interpolated) {
cl->xform_cache = xf * cl->xform_curr; cl->xform_cache = xf * cl->xform_curr;
@@ -442,25 +442,24 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
cl->xform_cache = xf * cl->xform_cache; cl->xform_cache = xf * cl->xform_cache;
} }
Rect2 temp_rect = cl->xform_cache.xform(cl->rect_cache); cl->rect_cache = cl->xform_cache.xform(local_rect);
if (clip_rect.intersects(temp_rect)) { if (clip_rect.intersects(cl->rect_cache)) {
cl->filter_next_ptr = lights; cl->filter_next_ptr = lights;
lights = cl; lights = cl;
Transform2D scale; Transform2D scale;
scale.scale(cl->rect_cache.size); scale.scale(local_rect.size);
scale.columns[2] = cl->rect_cache.position; scale.columns[2] = local_rect.position;
cl->light_shader_xform = cl->xform_cache * scale; cl->light_shader_xform = cl->xform_cache * scale;
if (cl->use_shadow) { if (cl->use_shadow) {
cl->shadows_next_ptr = lights_with_shadow; cl->shadows_next_ptr = lights_with_shadow;
if (lights_with_shadow == nullptr) { if (lights_with_shadow == nullptr) {
shadow_rect = temp_rect; shadow_rect = cl->rect_cache;
} else { } else {
shadow_rect = shadow_rect.merge(temp_rect); shadow_rect = shadow_rect.merge(cl->rect_cache);
} }
lights_with_shadow = cl; lights_with_shadow = cl;
cl->radius_cache = cl->rect_cache.size.length(); cl->radius_cache = local_rect.size.length();
cl->rect_cache = temp_rect;
} }
} }
} }