Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lighting_dirty flag bug #55813

Merged
merged 1 commit into from
Dec 12, 2021
Merged

Conversation

lawnjelly
Copy link
Member

@lawnjelly lawnjelly commented Dec 11, 2021

In rare circumstances, changing the geometry data attached to an instance, there was the opportunity for the lighting_dirty flag to get out of sync, which could lead to access to a stale light RID, and warnings or worse.

This PR fixes the problem by ensuring the lighting is always updated on the instance when first adding GeometryData.

Fixes #41360

Conditions for bug

  • On the same iteration, a light is removed, which unpairs the Light and Geometry data, and sets lighting_dirty to true
  • Before the instance has the opportunity to have its lighting list updated, the GeometryData is deleted and replaced by new GeometryData. The flag defaults to false, and thus the instance lighting is never updated.
  • When the instance lighting list is later hit, it reads the RID for the deleted light, and flags warnings etc.

Notes

  • This was incredibly difficult to find for such a simple bug 😁 ... see the issue for details of the debugging process (a good day and half on this).

Reproduction Project

Run this project before and after the PR (click loads of times with the mouse to add the omni lights):
OmnilightBug_Cutdown4.zip

In rare circumstances, changing the geometry data attached to an instance, there was the opporunity for the lighting_dirty flag to get out of sync, which could lead to access to a stale light RID, and warnings or worse.

This PR fixes the problem by ensuring the lighting is always updated on the instance when first adding GeometryData.
@akien-mga akien-mga merged commit 2e94815 into godotengine:3.x Dec 12, 2021
@akien-mga
Copy link
Member

Thanks!

@lawnjelly lawnjelly deleted the fix_lighting_dirty branch December 13, 2021 07:26
@akien-mga
Copy link
Member

Cherry-picked for 3.4.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants