@@ -264,8 +264,8 @@ void W3DView::buildCameraPosition( Vector3& sourcePos, Vector3& targetPos )
264264 // TheSuperHackers @info The default pitch affects the look-at distance to the target.
265265 // This is strange math which would need special attention when changed.
266266 sourcePos.Z = getCameraOffsetZ ();
267- sourcePos.Y = -(sourcePos.Z / tan (TheGlobalData-> m_cameraPitch * (PI / 180.0 ) ));
268- sourcePos.X = -(sourcePos.Y * tan (TheGlobalData-> m_cameraYaw * (PI / 180.0 ) ));
267+ sourcePos.Y = -(sourcePos.Z / tan (ViewDefaultPitchRadians ));
268+ sourcePos.X = -(sourcePos.Y * tan (ViewDefaultYawRadians ));
269269
270270 // set position of camera itself
271271 if (m_useRealZoomCam) // WST 10/10/2002 Real Zoom using FOV
@@ -285,13 +285,15 @@ void W3DView::buildCameraPosition( Vector3& sourcePos, Vector3& targetPos )
285285 targetPos.Y = 0 ;
286286 targetPos.Z = 0 ;
287287
288+ // TheSuperHackers @info Scales the source position later by this much
289+ // to achieve the intended camera height. Must not scale before pitching!
288290 const Real heightScale = 1 .0f - (groundLevel / sourcePos.Z );
289291
290292 // construct a matrix to rotate around the up vector by the given angle
291- const Matrix3D angleTransform ( Vector3 ( 0 .0f , 0 .0f , 1 .0f ), angle );
293+ const Matrix3D angleTransform ( Vector3 ( 0 .0f , 0 .0f , 1 .0f ), angle - ViewDefaultYawRadians );
292294
293295 // construct a matrix to rotate around the left vector by the given angle
294- const Matrix3D pitchTransform ( Vector3 ( -1 .0f , 0 .0f , 0 .0f ), pitch );
296+ const Matrix3D pitchTransform ( Vector3 ( -1 .0f , 0 .0f , 0 .0f ), pitch - ViewDefaultPitchRadians );
295297
296298 // rotate camera position (pitch, then angle)
297299#ifdef ALLOW_TEMPORARIES
@@ -2067,6 +2069,16 @@ void W3DView::setPitch( Real radians )
20672069 m_recalcCamera = true ;
20682070}
20692071
2072+ // -------------------------------------------------------------------------------------------------
2073+ // -------------------------------------------------------------------------------------------------
2074+ void W3DView::setDefaultPitch ( Real radians )
2075+ {
2076+ View::setDefaultPitch ( radians );
2077+
2078+ m_cameraAreaConstraintsValid = false ;
2079+ m_recalcCamera = true ;
2080+ }
2081+
20702082// -------------------------------------------------------------------------------------------------
20712083/* * Set the view angle back to default */
20722084// -------------------------------------------------------------------------------------------------
@@ -2098,7 +2110,7 @@ void W3DView::setDefaultView(Real pitch, Real angle, Real maxHeight)
20982110{
20992111 // MDC - we no longer want to rotate maps (design made all of them right to begin with)
21002112 // m_defaultAngle = angle * M_PI/180.0f;
2101- m_defaultPitch = pitch;
2113+ setDefaultPitch ( pitch) ;
21022114 m_maxHeightAboveGround = TheGlobalData->m_maxCameraHeight *maxHeight;
21032115 if (m_minHeightAboveGround > m_maxHeightAboveGround)
21042116 m_maxHeightAboveGround = m_minHeightAboveGround;
0 commit comments