diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h index 5ff1ed4039..d209dc8c4b 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h +++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h @@ -186,8 +186,11 @@ class GlobalData : public SubsystemInterface Real m_cameraPitch; Real m_cameraYaw; Real m_cameraHeight; + + // TheSuperHackers @info Max and Min camera height for the original 4:3 view, these are then scaled for other aspect ratios. Real m_maxCameraHeight; Real m_minCameraHeight; + Real m_terrainHeightAtEdgeOfMap; Real m_unitDamagedThresh; Real m_unitReallyDamagedThresh; diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/View.h b/GeneralsMD/Code/GameEngine/Include/GameClient/View.h index 1e0f72fbae..7a33f286ad 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/View.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/View.h @@ -168,7 +168,7 @@ class View : public Snapshot virtual Bool isTimeFrozen(void){ return false;} ///< Freezes time during the next camera movement. virtual Int getTimeMultiplier(void) {return 1;}; ///< Get the time multiplier. virtual void setTimeMultiplier(Int multiple) {}; ///< Set the time multiplier. - virtual void setDefaultView(Real pitch, Real angle, Real maxHeight) {}; + virtual void setCameraHeightAboveGroundLimitsToDefault(Real heightScale = 1.0f) {}; virtual void zoomCamera( Real finalZoom, Int milliseconds, Real easeIn, Real easeOut ) {}; virtual void pitchCamera( Real finalPitch, Int milliseconds, Real easeIn, Real easeOut ) {}; @@ -186,7 +186,8 @@ class View : public Snapshot virtual Real getHeightAboveGround() { return m_heightAboveGround; } virtual void setHeightAboveGround(Real z); virtual void zoom( Real height ); ///< Zoom in/out, closer to the ground, limit to min, or farther away from the ground, limit to max - virtual void setZoomToDefault( void ) { m_zoom = 1.0f; } ///< Set zoom to default value + virtual void setZoomToMax(); + virtual void setZoomToDefault() { m_zoom = 1.0f; } ///< Set zoom to default value virtual void setOkToAdjustHeight( Bool val ) { m_okToAdjustHeight = val; } ///< Set this to adjust camera height // for debugging diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptActions.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptActions.h index c849fb5fa8..0b5498810a 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptActions.h +++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptActions.h @@ -111,7 +111,7 @@ class ScriptActions : public ScriptActionsInterface void doCameraTetherNamed(const AsciiString& unit, Bool snapToUnit, Real play); void doCameraStopTetherNamed(void); - void doCameraSetDefault(Real pitch, Real angle, Real maxHeight); + void doCameraSetDefault(Real pitch, Real angle, Real heighScale); void doOversizeTheTerrain(Int amount); void doMoveCameraAlongWaypointPath(const AsciiString& waypoint, Real sec, Real cameraStutterSec, Real easeIn, Real easeOut); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp index 180dad5cfb..e883e81a09 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -1622,6 +1622,11 @@ static void saveOptions( void ) TheInGameUI->recreateControlBar(); TheInGameUI->refreshCustomUiResources(); + + // TheSuperHackers @info Only update the camera limits and set the zoom to max to not interfere with the scripted camera on the shellmap + // The tactical view gets reset at game start, this is here so the shell map looks correct once the resolution is adjusted + TheTacticalView->setCameraHeightAboveGroundLimitsToDefault(); + TheTacticalView->setZoomToMax(); } } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp index dbd61aa35d..fe1a706d7e 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp @@ -1283,7 +1283,7 @@ void InGameUI::init( void ) TheTacticalView->setWidth( TheDisplay->getWidth() ); TheTacticalView->setHeight( TheDisplay->getHeight() ); } - TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f); + TheTacticalView->setCameraHeightAboveGroundLimitsToDefault(); /** @todo this may be the wrong place to create the sidebar, but for now this is where it lives */ @@ -2051,7 +2051,7 @@ void InGameUI::reset( void ) // reset the command bar TheControlBar->reset(); - TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f); + TheTacticalView->setCameraHeightAboveGroundLimitsToDefault(); ResetInGameChat(); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/View.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/View.cpp index 6e760b2dd3..eec2334dca 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/View.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/View.cpp @@ -129,6 +129,11 @@ void View::zoom( Real height ) setHeightAboveGround(getHeightAboveGround() + height); } +void View::setZoomToMax() +{ + setHeightAboveGround(getHeightAboveGround() + m_maxHeightAboveGround); +} + void View::lockViewUntilFrame(UnsignedInt frame) { m_viewLockedUntilFrame = frame; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp index 753a0d57ce..94934494d8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp @@ -4608,9 +4608,11 @@ void ScriptActions::doCameraStopTetherNamed(void) //------------------------------------------------------------------------------------------------- /** doCameraSetDefault */ //------------------------------------------------------------------------------------------------- -void ScriptActions::doCameraSetDefault(Real pitch, Real angle, Real maxHeight) +void ScriptActions::doCameraSetDefault(Real pitch, Real angle, Real heighScale) { - TheTacticalView->setDefaultView(pitch, angle, maxHeight); + TheTacticalView->setCameraHeightAboveGroundLimitsToDefault(heighScale); + TheTacticalView->setPitch(pitch); + TheTacticalView->setAngle(angle); } //------------------------------------------------------------------------------------------------- diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp index 80f5586059..35738af1b7 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -2077,6 +2077,8 @@ void GameLogic::startNewGame( Bool loadingSaveGame ) // update the loadscreen updateLoadProgress(LOAD_PROGRESS_POST_PRELOAD_ASSETS); + // TheSuperHackers @info Initialize the camera height limits to default if the resolution was changed + TheTacticalView->setCameraHeightAboveGroundLimitsToDefault(); TheTacticalView->setAngleAndPitchToDefault(); TheTacticalView->setZoomToDefault(); diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h index df1dc76879..c9409ab50c 100644 --- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h +++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h @@ -190,13 +190,14 @@ class W3DView : public View, public SubsystemInterface virtual void Add_Camera_Shake(const Coord3D & position,float radius, float duration, float power); //WST 10.18.2002 virtual Int getTimeMultiplier(void) {return m_timeMultiplier;};///< Get the time multiplier. virtual void setTimeMultiplier(Int multiple) {m_timeMultiplier = multiple;}; ///< Set the time multiplier. - virtual void setDefaultView(Real pitch, Real angle, Real maxHeight); + virtual void setCameraHeightAboveGroundLimitsToDefault(Real heightScale = 1.0f); virtual void zoomCamera( Real finalZoom, Int milliseconds, Real easeIn, Real easeOut ); virtual void pitchCamera( Real finalPitch, Int milliseconds, Real easeIn, Real easeOut ); virtual void setHeightAboveGround(Real z); virtual void setZoom(Real z); - virtual void setZoomToDefault( void ); ///< Set zoom to default value + virtual void setZoomToMax(); + virtual void setZoomToDefault(); ///< Set zoom to default value - TheSuperHackers @info This function resets the camera so will cause scripted cameras to halt virtual void setFieldOfView( Real angle ); ///< Set the horizontal field of view angle diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp index 78302052c7..5bc477849a 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp @@ -1923,12 +1923,25 @@ void W3DView::setAngleAndPitchToDefault( void ) //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- -void W3DView::setDefaultView(Real pitch, Real angle, Real maxHeight) +void W3DView::setCameraHeightAboveGroundLimitsToDefault(Real heightScale) { - // MDC - we no longer want to rotate maps (design made all of them right to begin with) - // m_defaultAngle = angle * M_PI/180.0f; - m_defaultPitchAngle = pitch; - m_maxHeightAboveGround = TheGlobalData->m_maxCameraHeight*maxHeight; + // TheSuperHackers @fix Mauller Adjust the camera height to compensate for the screen aspect ratio + Real baseAspectRatio = (Real)DEFAULT_DISPLAY_WIDTH / (Real)DEFAULT_DISPLAY_HEIGHT; + Real currentAspectRatio = (Real)TheTacticalView->getWidth() / (Real)TheTacticalView->getHeight(); + Real aspectRatioScale = 0.0f; + + if (currentAspectRatio > baseAspectRatio) + { + aspectRatioScale = fabs(( 1 + ( currentAspectRatio - baseAspectRatio) )); + } + else + { + aspectRatioScale = fabs(( 1 - ( baseAspectRatio - currentAspectRatio) )); + } + + m_maxHeightAboveGround = TheGlobalData->m_maxCameraHeight * aspectRatioScale * heightScale; + m_minHeightAboveGround = TheGlobalData->m_minCameraHeight * aspectRatioScale; + if (m_minHeightAboveGround > m_maxHeightAboveGround) m_maxHeightAboveGround = m_minHeightAboveGround; } @@ -1971,10 +1984,8 @@ void W3DView::setZoom(Real z) //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- -void W3DView::setZoomToDefault( void ) +void W3DView::setZoomToMax() { - // default zoom has to be max, otherwise players will just zoom to max always - // terrain height + desired height offset == cameraOffset * actual zoom // find best approximation of max terrain height we can see Real terrainHeightMax = getHeightAroundPos(m_pos.x, m_pos.y); @@ -1987,14 +1998,22 @@ void W3DView::setZoomToDefault( void ) m_zoom = desiredZoom; m_heightAboveGround = m_maxHeightAboveGround; + m_cameraConstraintValid = false; // recalc it. + setCameraTransform(); +} + +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +void W3DView::setZoomToDefault() +{ + // default zoom has to be max, otherwise players will just zoom to max always m_doingMoveCameraOnWaypointPath = false; m_CameraArrivedAtWaypointOnPathFlag = false; m_doingRotateCamera = false; m_doingPitchCamera = false; m_doingZoomCamera = false; m_doingScriptedCameraLock = false; - m_cameraConstraintValid = false; // recalc it. - setCameraTransform(); + setZoomToMax(); } //-------------------------------------------------------------------------------------------------