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 visible tiles revealing invisible tiles below #67997

Merged
merged 11 commits into from
Sep 13, 2023

Conversation

Rewryte
Copy link
Contributor

@Rewryte Rewryte commented Sep 3, 2023

Summary

Bugfixes "Fix visible tiles revealing invisible tiles below"

Purpose of change

The way 3D vision currently handles tile visibility is by calculating visibility variables for the current z-level and have every z-level underneath inherit the same values. In cases where a tile on the current z-level should be visible but the tile underneath should not, the player will be able to see both tiles due to the non-visible tile underneath inheriting the visibility variables of the visible tile above it. Correcting this will fix #66040. Also a prerequisite for the lightmap changes in #67434.

Describe the solution

There are two parts to this solution:

  1. Instead on updating the visibility cache on the current z-level only, we update the z-levels below as well, limited by the 3D vertical range setting.
  2. In the tileset code, pull new variables from the visibility cache on each z-level to determine light level.

Naturally, these make processing visibility somewhat more CPU intensive. To compensate, map cache and visibility cache are no longer calculated every draw. Any event that alters these can simply call map::build_map_cache and map::update_visibility_cache instead. This involves the removal of the temporary fix introduced in #15868. The issues targeted by the fix (#15842 and #15854) are not reproducible.

Overall, these changes have a positive effect on draw performance leading to an 11% decrease in draw times.

Describe alternatives you've considered

Testing

Compiles ok.
Confirmed that invisible tiles no longer show as visible when viewing visible tiles on a higher z-level.

Before:
before
After:
after

Additional context

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) labels Sep 3, 2023
src/map.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot added the json-styled JSON lint passed, label assigned by github actions label Sep 3, 2023
@Rewryte
Copy link
Contributor Author

Rewryte commented Sep 3, 2023

This will be in draft until optimizations are complete. Currently seeing a 57.6% increase in draw times.
Optimizations done. Now decreases draw times by ~11% using a 3D vertical range setting of 4.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 3, 2023
@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Sep 7, 2023
@Rewryte
Copy link
Contributor Author

Rewryte commented Sep 7, 2023

Main post updated with optimization details. Currently fixing visual bugs resulting from the removal of map cache and visibility cache calculations from game::draw

@Maleclypse
Copy link
Member

Is this intended to still be in draft? No stress if yes. It just reads as if it's ready to go possibly.

@Rewryte
Copy link
Contributor Author

Rewryte commented Sep 12, 2023

Is this intended to still be in draft? No stress if yes. It just reads as if it's ready to go possibly.

It's more or less done. Tests are passing on my end (MSYS2). Just pushed out one more fix to prevent cache bloat during tests. I'll likely bring it out of draft soon.

@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 12, 2023
@Rewryte Rewryte marked this pull request as ready for review September 12, 2023 19:35
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 13, 2023
@Maleclypse Maleclypse merged commit f12487c into CleverRaven:master Sep 13, 2023
@ehughsbaird
Copy link
Contributor

FYI, this resulted in a massive increase in test run times #68154.

@KHeket KHeket mentioned this pull request Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3D vision lets you see unseen tiles below
5 participants