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

3D draw point generation #70301

Merged
merged 26 commits into from
Dec 22, 2023
Merged

3D draw point generation #70301

merged 26 commits into from
Dec 22, 2023

Conversation

Rewryte
Copy link
Contributor

@Rewryte Rewryte commented Dec 19, 2023

Summary

Bugfixes "3D draw point generation"

Purpose of change

Tiles draw sprites on screen by generating a draw_point for each grid. To handle visibility differences on different z-levels in 3D vision, draw_points recalculate their visibility variables on each z-level. However, there are situations where a grid that should not have a draw_point could inherit a draw_point from the grid above it which would cause the grid to show up as visible when it should not.
Fix #69973

draw_points generation now also includes caching and "occlusion culling" features, replacing my previous code. Doing these during draw_points generation is not only more efficient, but also substantially reduces code clutter.

Describe the solution

  • draw_points are now generated separately for each z-level.
  • draw_points no longer track the lowest level it should draw. If a grid should not be drawn, it would not have a draw_point in the first place.
  • draw_points, overlay_strings and color_blocks are now cached, which will reduce cpu load per draw. Visibility variables are contained in draw_points and are no longer cached separately.

Describe alternatives you've considered

draw_points are stored in a map within a map (std::map<int, std::map<int, std::vector<tile_render_info>>>). Not sure if there is a more efficient way of storing the data.

Testing

Compiles ok.
Confirmed that #69973 is fixed.
Debug overlays work normally.
Up to 13% faster draw time when displaying multiple z-levels.

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) astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Dec 19, 2023
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Dec 19, 2023
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Dec 20, 2023
@Rewryte Rewryte marked this pull request as ready for review December 21, 2023 04:30
Copy link
Contributor

@Qrox Qrox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

src/cata_tiles.cpp Show resolved Hide resolved
src/cata_tiles.cpp Outdated Show resolved Hide resolved
src/cata_tiles.cpp Outdated Show resolved Hide resolved
src/cata_tiles.cpp Outdated Show resolved Hide resolved
src/cata_tiles.cpp Outdated Show resolved Hide resolved
src/handle_action.cpp Show resolved Hide resolved
Rewryte and others added 3 commits December 21, 2023 20:02
Co-Authored-By: Jianxiang Wang (王健翔) <[email protected]>
Co-authored-by: Jianxiang Wang (王健翔) <[email protected]>
Co-authored-by: Jianxiang Wang (王健翔) <[email protected]>
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.

You can see what is on top of rooftops from below with 3D FoV
3 participants