fix(heightmap): Fix up view and heightmap to work better with low camera pitch#2677
fix(heightmap): Fix up view and heightmap to work better with low camera pitch#2677xezon wants to merge 6 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp | Adds low-pitch terrain draw logic in updateTerrain, moves updateCameraClipPlanes to run after terrain update, and rewrites clip plane calculation to use actual terrain bounding box. Minor stale date in comment. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp | New setTerrainDrawSize function centralises draw-size resizing; oversizeTerrain now stores oversize dimensions in m_oversizeDrawWidth/Height; updateCenter splits into a high-pitch frustum path and a fast low-pitch approximation using the camera pivot. m_needFullUpdate now correctly sets the draw area before the full rebuild. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp | Splits setDrawOrg into createDrawArea (pure clamping) + setDrawArea (mutation), making origin/size changes atomic and testable. Clamping logic is preserved and the setDrawOrg wrapper maintains backward compatibility. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp | Adapts updateCenter to new signature and adds no-op setTerrainDrawSize override for the flat map variant. |
| Core/GameEngineDevice/Include/W3DDevice/GameClient/WorldHeightMap.h | Adds DrawArea struct, LOW_ANGLE_DRAW_WIDTH/HEIGHT constants, replaces silent-clamp setDrawWidth/Height with assertion-guarded variants, and declares createDrawArea/setDrawArea. |
| Core/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h | Updates virtual interface: updateCenter gains cameraPivot, oversizeTerrain and new setTerrainDrawSize become pure virtual. |
| Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp | Passes m_cameraTarget as the new cameraPivot argument and explicitly clamps m_partialMapSize to the map extent before calling setDrawWidth/Height. |
| GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp | Mirror of the Generals WorldBuilder fix: same cameraPivot threading and setDrawWidth/Height clamping. |
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp:3710-3714
The comment date `31/12/2025` references a year prior to the current year (2026). Per the team's convention, newly added code comments should reference the current year.
```suggestion
else
{
// TheSuperHackers @tweak xezon 01/01/2026 Increases visible terrain area when lowering the camera pitch.
// Note: The default camera pitch in Generals was 37.5, which we prefer to keep the normal draw size for.
drawWidth = WorldHeightMap::LOW_ANGLE_DRAW_WIDTH;
```
Reviews (5): Last reviewed commit: "fix(heightmap): Properly draw larger ter..." | Re-trigger Greptile
02bc55f to
638dacf
Compare
|
How to check the PR? Do I need GenTool to play with the camera height? |
In Debug build, camera can be pitched with Comma key. |
3a3b654 to
1c499cd
Compare
|
There is a performance degradation in Generals Shell Map which needs looking into. |
too early, only checked the first commit - forgot that there were six
|
There is a bug in Generals where jumping far positions will render the terrain black for 1 frame. Needs looking into. |
| } | ||
|
|
||
| constexpr const Int cellOffset = 1; | ||
| const Real cameraPitch = WWMath::Asin(fabsf(camera->Get_Forward_Dir().Z)); |
There was a problem hiding this comment.
Perhaps use asin(..) as WWMath is looking to become the place for deterministic math. Two times in this PR.
1c499cd to
7321494
Compare
Fixed. |
This problem is already in main branch before this change and is now tracked as an issue. |
…draw size (#2677)
…dateCenter() (#2677)
… has really changed (#2677)
…ze() to set custom draw sizes (#2677)
7321494 to
dbc5175
Compare
Merge with Rebase
This change is quite a bit heavy but is split into 6 commits for ease of review. It fixes and improves several aspects of camera and heightmap:
Aligns the far clip plane with the actual terrain size, unless m_FXPitch is set (used by scripted camera) or the entire terrain is drawn. This is great to only draw as far as really needed: good for performance.
Removes useless logic in function
HeightMapRenderObjClass::updateCenterbecauseif (TheTacticalView->getFieldOfView() != 0)always returns true.The full terrain update is now done after the new terrain origin position has been set, so that it will draw at the correct location straight away. This fixes issues where the terrain was not properly drawn when jumped to from far away.
The terrain now only really updates if the origin position has been changed. Originally this was not guaranteed which could have lead to bad performance issues if an origin point was located far outside the map boundaries.
Implements a new function
HeightMapRenderObjClass::setTerrainDrawSizeto set custom draw sizes needed for the final commit. This function has a bit of a strange contract in relation toHeightMapRenderObjClass::oversizeTerrain, but that is needed to preserve original behavior in scripted mission cinematics.At last, the camera and heightmap now renders a larger terrain area when the camera is pitched below 37 degrees. Tip: Disable whitespace to see a cleaner change diff.
Known issues
The game client might stall when pitching down and passing the threshold of 37 degrees because the heightmap update is expensive and needs improving.
TODO