Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(w3ddevice): rebuild the camera's limits when what it can see changes

Olcay Seyganc4f599cbfbe0
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
index d1390d183..2b22a29a4 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
@@ -207,6 +207,9 @@ void W3DView::setHeight(Int height)
// extend View functionality
View::setHeight(height);
+ // the visible area just changed shape - showing or hiding the control bar comes through here
+ m_cameraConstraintValid = false;
+
Vector2 vMin,vMax;
m_3DCamera->Set_Aspect_Ratio((Real)getWidth()/(Real)height);
m_3DCamera->Get_Viewport(vMin,vMax);
@@ -2026,6 +2029,10 @@ void W3DView::setPitch( Real angle )
// call our base class, we are extending functionality
View::setPitch( angle );
+ // how close to the map edge the camera may come depends on the pitch - pitched up it sees
+ // further, so the same position shows more of the world past the border
+ m_cameraConstraintValid = false;
+
m_doingMoveCameraOnWaypointPath = false;
m_doingRotateCamera = false;
@@ -2163,6 +2170,9 @@ void W3DView::setFieldOfView( Real angle )
{
View::setFieldOfView( angle );
+ // a wider field of view sees further past the map edge from the same place
+ m_cameraConstraintValid = false;
+
#if defined(_DEBUG) || defined(_INTERNAL)
// this is only for testing, and recalculating the
// camera every frame is wasteful