Skip to content

perf(view): Cache only latest screen-to-terrain result#2992

Merged
xezon merged 5 commits into
TheSuperHackers:mainfrom
CryoTheRenegade:fix/W3DViewm-locationRequests-single-cache-conversion
Jul 24, 2026
Merged

perf(view): Cache only latest screen-to-terrain result#2992
xezon merged 5 commits into
TheSuperHackers:mainfrom
CryoTheRenegade:fix/W3DViewm-locationRequests-single-cache-conversion

Conversation

@CryoTheRenegade

Copy link
Copy Markdown

Summary

In #2815 I profiled W3DView::m_locationRequests and found that only the newest entry was reused out of the 40 entry cache. The movement (moving camera in replays) test produced 33,590 newest-entry hits, while older cached entries had no hits.

This change replaces the 40 entry cache with a single entry cache that tracks bridge and seismic additions, deletions, and damage-state changes persistently so we can invalidate the entry when a change occurs.

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown

Greptile Summary

This PR changes screen-to-terrain caching to keep only the latest result. The main changes are:

  • Replaces the old multi-entry location cache with a single cached screen/world pair.
  • Adds view invalidation hooks for heightmap and bridge changes.
  • Invalidates the cache from camera, terrain, seismic, and bridge update paths.
  • Removes the now-unused position request typedefs.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Replaces the screen-to-terrain cache and adds invalidation for changed view state.
Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h Stores the latest screen-to-terrain result and clears it when terrain or bridge state changes.
Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp Routes full heightmap update scheduling through a helper that also invalidates the view cache.
Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp Clears the view cache after seismic terrain updates.
Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp Clears the view cache when bridge logic adds, deletes, or updates bridge state.
GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp Mirrors the bridge cache invalidation changes for Zero Hour.

Reviews (3): Last reviewed commit: "refactor(view): Refine screen-to-terrain..." | Re-trigger Greptile

Comment thread Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp
Comment thread GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp
@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Performance Is a performance concern Gen Relates to Generals ZH Relates to Zero Hour labels Jul 22, 2026

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code looks complicated. Would be good to simplify it somehow.

Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Include/GameLogic/TerrainLogic.h Outdated
Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Outdated
Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Outdated
@CryoTheRenegade
CryoTheRenegade requested a review from xezon July 23, 2026 15:51
Comment thread GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp Outdated
Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Outdated
Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Outdated
Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Outdated
Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Outdated
Comment thread Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h Outdated
@CryoTheRenegade
CryoTheRenegade force-pushed the fix/W3DViewm-locationRequests-single-cache-conversion branch from 3e169f4 to b089b42 Compare July 23, 2026 20:04

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Makes sense.

@xezon
xezon merged commit b3d3a06 into TheSuperHackers:main Jul 24, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Performance Is a performance concern ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants