diff --git a/Core/GameEngine/Include/GameClient/View.h b/Core/GameEngine/Include/GameClient/View.h index 3bfff42c42..20a2e0eff2 100644 --- a/Core/GameEngine/Include/GameClient/View.h +++ b/Core/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=0.0f, Real easeOut=0.0f ) {}; virtual void pitchCamera( Real finalPitch, Int milliseconds, Real easeIn=0.0f, Real easeOut=0.0f ) {}; @@ -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/Core/GameEngine/Source/GameClient/View.cpp b/Core/GameEngine/Source/GameClient/View.cpp index d529ff7255..22846fe82b 100644 --- a/Core/GameEngine/Source/GameClient/View.cpp +++ b/Core/GameEngine/Source/GameClient/View.cpp @@ -126,6 +126,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/Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h b/Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h index 747a916741..d4796dca97 100644 --- a/Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h +++ b/Core/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/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp index efd4c3a4d8..79fce166df 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp @@ -1932,12 +1932,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; } @@ -1980,10 +1993,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); @@ -1996,14 +2007,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(); } //------------------------------------------------------------------------------------------------- diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h index 337477129c..db50a1181d 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/GameLogic/ScriptActions.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptActions.h index f94f20b351..d68546325a 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 45d096faf4..b9ab1230e0 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -1617,6 +1617,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 a737146e27..978f1ae98f 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp @@ -1280,7 +1280,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 */ @@ -2050,7 +2050,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/GameLogic/ScriptEngine/ScriptActions.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp index a40902c767..e5fc57f644 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp @@ -4607,9 +4607,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 569b01943c..45cada07d4 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -2026,6 +2026,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();