bugfix(view): Fix ground level of bookmarks, replay camera and game world microphone#2595
bugfix(view): Fix ground level of bookmarks, replay camera and game world microphone#2595xezon wants to merge 6 commits intoTheSuperHackers:mainfrom
Conversation
|
Generals will fail to compile until replicated. |
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Include/GameClient/View.h | API modernized: pointer-based getPosition/setPosition replaced with reference/value returns; new setPosition2D/getPosition2D helpers added; m_pos.z todo-comment removed now that z is used. |
| Core/GameEngine/Source/GameClient/View.cpp | Position access updated to new API; forceRedraw() safely removed from setLocation since setPitch (called inside) already sets m_recalcCamera and m_cameraAreaConstraintsValid. |
| Core/GameEngine/Source/Common/Audio/GameAudio.cpp | Microphone placement corrected: desiredHeightAbs now accounts for terrain elevation, zScale uses relative height, and cameraPivot.z (smoothed ground level) replaces the explicit getGroundHeight call. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp | Comprehensive replacement of m_groundLevel with m_pos.z throughout; waypoint path now stores ground height in waypoints[].z instead of the removed groundHeight[]; lookAt correctly calls resetPivotToGround after setting position. |
| Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h | m_groundLevel field removed; groundHeight[] array removed from TMoveAlongWaypointPathInfo; m_initialGroundLevel retained for PRESERVE_RETAIL_SCRIPTED_CAMERA path. |
| Core/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp | Debug display updated to use getPosition() directly; getGroundHeight call removed since m_pos.z already carries the smoothed terrain height. |
| Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp | Updated userSetPosition call site to pass by reference, matching the new API signature. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp | Same userSetPosition call-site update as Generals mirror, consistent with the new API. |
Sequence Diagram
sequenceDiagram
participant Game as Game Loop
participant W3DView
participant View as View (base)
participant Audio as AudioManager
participant Terrain as TerrainLogic
Note over W3DView,View: m_pos.z now carries ground level (was m_groundLevel)
Game->>W3DView: movePivotToGround()
W3DView->>Terrain: getGroundHeight(x, y)
Terrain-->>W3DView: terrainZ
W3DView->>View: m_pos.z += delta (smooth adjust toward terrain)
Game->>W3DView: buildCameraPosition()
W3DView->>View: getPosition() → m_pos (x,y,z=groundLevel)
W3DView->>W3DView: heightScale = 1 - (m_pos.z / sourcePos.Z)
W3DView->>W3DView: targetPos.Z = m_pos.z
Game->>Audio: update()
Audio->>W3DView: getPosition() → cameraPivot (z=groundLevel)
Audio->>W3DView: get3DCameraPosition() → cameraPos
Audio->>Audio: groundToCameraVector = cameraPos - cameraPivot
Audio->>Audio: desiredHeightAbs = desiredHeightRel + cameraPivot.z
Audio->>Audio: microphonePos = cameraPivot + scale * groundToCameraVector
Game->>W3DView: getLocation(bookmark)
W3DView->>View: getLocation() → ViewLocation (pos incl z=groundLevel)
Note over View: ViewLocation now stores z (ground level)
Game->>W3DView: setLocation(bookmark)
W3DView->>View: setLocation() → setPosition(pos incl z)
Note over View: Ground level restored from bookmark
Reviews (6): Last reviewed commit: "Replicate in Generals" | Re-trigger Greptile
…orld microphone By merging View::m_groundLevel into View::m_pos::z
3aa88fb to
e5ff233
Compare
Mauller
left a comment
There was a problem hiding this comment.
Looks good, although what greptile brought up might want checking. But i don't see how it changes behaviour.
|
There are cutscene discrepancies in Generals that need looking into. |
This change fixes the ground level of bookmarks, replay camera and the game world microphone by merging
View::m_groundLevelintoView::m_pos::z.View::m_pos::zwas originally unused andView::m_groundLevelwas effectively that. They are now consolidated which automatically adds the ground level into bookmarks and the replay camera throughViewLocation(cool).The game world microphone, used for positional audio, did not calculate the microphone height correctly which was fixed as well.
In
View::lookAtthe pivot is now reset to the ground which corrects behavior as well.TODO