Skip to content

feat(terrain): add RenderAllTerrain flag to allow full-map visibility#2260

Open
githubawn wants to merge 1 commit intoTheSuperHackers:mainfrom
githubawn:feature/unlimited-zoom-terrain
Open

feat(terrain): add RenderAllTerrain flag to allow full-map visibility#2260
githubawn wants to merge 1 commit intoTheSuperHackers:mainfrom
githubawn:feature/unlimited-zoom-terrain

Conversation

@githubawn
Copy link

@githubawn githubawn commented Feb 6, 2026

They thought they could hide in the fog of the old world, General. They were wrong. By initializing the RenderAllTerrain protocols, we have stripped away the limits of our vision.

The earth no longer crumbles at the horizon. To hold the world together, we have diverted at least one hundred megabytes of video memory to the display on our large battlefields. Your GPU will feel the weight of this vast landscape, drawing extra power to render the full scale of our battlefield.

But look! The Americans are exposed. From this height, their bases are a joke and their walls are like sand. Command from the heavens, General, and let our wrath fall upon them. Let nothing remain hidden!

Description: This PR fixes visual clipping issues when running the game with the RenderAllTerrain = Yes. Previously, the terrain rendering system would cull geometry based on the standard camera view frustum logic, which caused terrain segments to disappear when zooming out beyond standard limits.

Modified W3DTerrainVisual::load in Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp

Extent Overrides: When RenderAllTerrain is active, the heightmap's DrawWidth and DrawHeight are forced to match the full map extents (getXExtent/getYExtent). This bypasses the standard culling system's calculated values to ensure the entire map remains visible.

Before:
image

After:
image

@greptile-apps
Copy link

greptile-apps bot commented Feb 6, 2026

Greptile Summary

This PR adds a configurable RenderAllTerrain flag that allows rendering the entire terrain map without distance-based culling, fixing visual clipping when zooming out beyond standard limits.

Key Changes:

  • Added m_renderAllTerrain boolean flag to GlobalData (both Generals and Zero Hour variants)
  • When enabled, terrain rendering uses full map extents (getXExtent()/getYExtent()) instead of culled draw dimensions
  • Implementation correctly modifies heightmap draw dimensions before vertex buffer allocation in initHeightData()

Technical Implementation:
The code follows the safe pattern for modifying heightmap dimensions by setting DrawWidth and DrawHeight before calling initHeightData(). This prevents vertex buffer size mismatches and ensures systems like shroud/fog-of-war and dynamic lighting will reinitialize with correct dimensions.

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues
  • The implementation follows established patterns, correctly modifies heightmap dimensions before buffer allocation, includes proper bounds checking via existing setters, and adds the feature consistently across both Generals and Zero Hour codebases. The previous comments about indentation have been addressed - the code now uses tabs consistently with the rest of the file.
  • No files require special attention

Important Files Changed

Filename Overview
Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp Added logic to override heightmap draw dimensions when RenderAllTerrain is enabled, safely done before initHeightData() call
Generals/Code/GameEngine/Include/Common/GlobalData.h Added m_renderAllTerrain boolean field to GlobalData class
Generals/Code/GameEngine/Source/Common/GlobalData.cpp Added INI parser entry for RenderAllTerrain and initialized field to FALSE in constructor
GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h Added m_renderAllTerrain boolean field to GlobalData class (Zero Hour variant)
GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp Added INI parser entry for RenderAllTerrain and initialized field to FALSE in constructor (Zero Hour variant)

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Game Initialization] --> B{Load GlobalData INI}
    B --> C[Parse RenderAllTerrain flag]
    C --> D[W3DTerrainVisual::load]
    D --> E{RenderAllTerrain enabled?}
    E -->|Yes| F[Get full map extents<br/>getXExtent/getYExtent]
    E -->|No| G[Use culled dimensions<br/>getDrawWidth/getDrawHeight]
    F --> H[Override heightMap<br/>setDrawWidth/setDrawHeight]
    G --> I[Use existing dimensions]
    H --> J[initHeightData with full extents]
    I --> J
    J --> K[Allocate vertex buffers<br/>for terrain rendering]
    K --> L[Add render object to scene]
    L --> M{Result}
    M -->|RenderAllTerrain=Yes| N[Full map visible<br/>No distance culling<br/>Higher VRAM usage]
    M -->|RenderAllTerrain=No| O[Standard culled view<br/>Terrain clips at distance<br/>Lower VRAM usage]
Loading

Last reviewed commit: 179cf06

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@githubawn githubawn marked this pull request as draft February 6, 2026 03:07
@githubawn
Copy link
Author

will also review the build errors soon, changed to draft for now, looking forward to feedback

@stephanmeesters
Copy link

Unlimited power.

Would this maybe be good as an INI setting, like is it important to parse this before the engine init?

@tintinhamans
Copy link

tintinhamans commented Feb 6, 2026

Yes, it would be nice if this was an INI setting since it might also be relevant for ultrawide resolutions with normal zoom:

image

@githubawn
Copy link
Author

Ini could be done. Any file i could use for this?

@githubawn githubawn force-pushed the feature/unlimited-zoom-terrain branch from b41c7aa to 179cf06 Compare February 23, 2026 21:14
@githubawn githubawn changed the title feat(terrain): Enable full map rendering when using -unlimitedzoom feat(terrain): add RenderAllTerrain flag to allow full-map visibility Feb 23, 2026
@githubawn
Copy link
Author

Renamed to a more logical "RenderAllTerrain" from "Unlimitedzoom"
Fixed vc6 compilation
Moved away from switches to INI (RenderAllTerrain = yes)

@githubawn githubawn marked this pull request as ready for review February 23, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants