RS117 / RLHD

BSD 2-Clause "Simplified" License
150 stars 62 forks source link

Fix incorrect instant transitions between environments #300

Closed aHooder closed 2 years ago

aHooder commented 2 years ago

This should fix #199.

The issue seems to be that the environment instantly transitions (when it shouldn't) from OVERWORLD to WILDERNESS_LOW when loading under certain conditions, then a single frame is rendered before the environment again transitions instantly back to OVERWORLD. The issue with these instant transitions is that the ambient color (among other things) changes completely to the new environment only for that single frame.

The intent seems to have been to only cause new environments to apply instantly whenever the player is teleported to a new area, not when simply walking into a loading line. Because camTarget is stored in local scene coordinates, the coordinates are shifted by 40 tiles when the origin is reset for the newly loaded scene, thus incorrectly triggering an instant change as if the player was just teleported. If the player is running through the loading line from an odd numbered tile, the new camTarget can also be 41 tiles away from the previous, hence the change to 41 instead of 40.

ipkpjersi commented 2 years ago

Can confirm, this does look like it fixes #199. Great job!

sosodev commented 2 years ago

Nice find Hooder. I think it's interesting to note that there was multiple bugs causing #199. Originally the flickering was mostly artifacting in the loading process. With that fixed this scene transition bug became more obvious.