fix(view): Introduce PRESERVE_RETAIL_SCRIPTED_CAMERA and fix or improve camera offset and zoom calculations#2524
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp | Core camera logic refactored: offset calc moved into buildCameraPosition, five new helper methods added, m_cameraOffset member removed; contains P2 stale-year comment dates. |
| Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h | Removes m_cameraOffset member, adds m_initialGroundLevel under PRESERVE_RETAIL_SCRIPTED_CAMERA guard, and declares five new private helper methods. |
| Core/GameEngine/Include/Common/GameDefines.h | Adds PRESERVE_RETAIL_SCRIPTED_CAMERA macro definition, consistent with existing PRESERVE_RETAIL_BEHAVIOR pattern. |
| Generals/Code/GameEngine/Include/Common/GlobalData.h | Guards m_cameraHeight member with PRESERVE_RETAIL_SCRIPTED_CAMERA; no other changes. |
| Generals/Code/GameEngine/Source/Common/GlobalData.cpp | Guards CameraHeight INI parse entry and default initializer with PRESERVE_RETAIL_SCRIPTED_CAMERA. |
| GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h | Same m_cameraHeight guard as the Generals counterpart, applied to Zero Hour GlobalData. |
| GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp | Same CameraHeight INI guard as the Generals counterpart, applied to Zero Hour GlobalData. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[buildCameraPosition] --> B[getCameraOffsetZ]
B --> C{m_isUserControlled?}
C -- No / PRESERVE_RETAIL --> D[m_initialGroundLevel + m_cameraHeight]
C -- Yes --> E[m_groundLevel + m_maxCameraHeight]
A --> F[Apply zoom / FOV]
G[setZoom] --> H[getDesiredZoom]
H --> I[getDesiredHeight / getCameraOffsetZ]
J[setZoomToDefault] --> K[getMaxZoom]
K --> L[getMaxHeight / getCameraOffsetZ]
M[initHeightForMap] --> N[Store m_initialGroundLevel]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
Line: 649
Comment:
**Stale dates in new comments**
The newly added comment in `getCameraOffsetZ()` references `04/12/2025` and the comment in `getDesiredHeight()` (line 666) references `06/12/2025`. Both are from 2025, prior to the current year (2026). Please update these to 2026.
**Rule Used:** What: Flag newly created code comments that refere... ([source](https://app.greptile.com/review/custom-context?memory=fd72a556-4fd8-4db4-8b08-8e51516a64ad))
How can I resolve this? If you propose a fix, please make it concise.Reviews (3): Last reviewed commit: "Fix zoom setup mistakes" | Re-trigger Greptile
4e40bc8 to
0ac21f0
Compare
|
Replicated in Generals without conflicts. |
This change is quite a bit complicated.
PRESERVE_RETAIL_SCRIPTED_CAMERA
Introduces a new PRESERVE_RETAIL_SCRIPTED_CAMERA preprocessor macro to preserve the original look of the scripted camera. Most importantly the initial ground level is cached and used during scripted camera movements.
Camera Offset
The camera offset is now freshly calculated inside
W3DView::buildCameraPosition, instead of various other locations, to make sure that it is always correctly built when the camera pitch or angle changes.Camera Zoom
The camera zoom was changed from originally
initialGroundLevel + TheGlobalData->m_cameraHeightto
currentGroundLevel + TheGlobalData->m_maxCameraHeightThis effectively means that the camera zoom range is now 0 to 1. Originally it was 0 to N, where N would generally be 1.33 or higher. This was confusing. The new setup gives a much better expectation for what a zoom value represents. 0.5 now means half way zoomed from max possible height to ground.
Known issues
TODO