Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Core/GameEngine/Include/GameClient/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ 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) {}; // TheSuperHackers @todo Replace with setDefaultPitch(), setMaxHeightScale()
virtual void setCameraHeightAboveGroundLimitsToDefault(Real heightScale = 1.0f) {};
virtual void setDefaultView(Real pitch, Real angle, Real maxHeight) {};
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 ) {};

Expand All @@ -187,7 +188,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
Expand Down
5 changes: 5 additions & 0 deletions Core/GameEngine/Source/GameClient/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ void View::zoom( Real height )
setHeightAboveGround(getHeightAboveGround() + height);
}

void View::setZoomToMax()
{
setHeightAboveGround(getHeightAboveGround() + m_maxHeightAboveGround);
}
Comment on lines +129 to +132
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: incorrectly adds m_maxHeightAboveGround to current height instead of setting height to max

Suggested change
void View::setZoomToMax()
{
setHeightAboveGround(getHeightAboveGround() + m_maxHeightAboveGround);
}
void View::setZoomToMax()
{
setHeightAboveGround(m_maxHeightAboveGround);
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/GameEngine/Source/GameClient/View.cpp
Line: 129:132

Comment:
**logic:** incorrectly adds `m_maxHeightAboveGround` to current height instead of setting height to max

```suggestion
void View::setZoomToMax()
{
	setHeightAboveGround(m_maxHeightAboveGround);
}
```

How can I resolve this? If you propose a fix, please make it concise.


void View::lockViewUntilFrame(UnsignedInt frame)
{
m_viewLockedUntilFrame = frame;
Expand Down
4 changes: 3 additions & 1 deletion Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,14 @@ class W3DView : public View, public SubsystemInterface
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

Expand Down
38 changes: 35 additions & 3 deletions Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1877,6 +1877,31 @@ void W3DView::setPitchToDefault( void )
m_recalcCamera = true;
}

//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
void W3DView::setCameraHeightAboveGroundLimitsToDefault(Real heightScale)
{
// 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) ));
}
Comment on lines +1889 to +1896
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: unnecessary fabs() wraps expressions that are already positive by construction

Suggested change
if (currentAspectRatio > baseAspectRatio)
{
aspectRatioScale = fabs(( 1 + ( currentAspectRatio - baseAspectRatio) ));
}
else
{
aspectRatioScale = fabs(( 1 - ( baseAspectRatio - currentAspectRatio) ));
}
if (currentAspectRatio > baseAspectRatio)
{
aspectRatioScale = 1 + (currentAspectRatio - baseAspectRatio);
}
else
{
aspectRatioScale = 1 - (baseAspectRatio - currentAspectRatio);
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
Line: 1942:1949

Comment:
**style:** unnecessary `fabs()` wraps expressions that are already positive by construction

```suggestion
	if (currentAspectRatio > baseAspectRatio)
	{
		aspectRatioScale = 1 + (currentAspectRatio - baseAspectRatio);
	}
	else
	{
		aspectRatioScale = 1 - (baseAspectRatio - currentAspectRatio);
	}
```

How can I resolve this? If you propose a fix, please make it concise.


m_maxHeightAboveGround = TheGlobalData->m_maxCameraHeight * aspectRatioScale * heightScale;
m_minHeightAboveGround = TheGlobalData->m_minCameraHeight * aspectRatioScale;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On map Defcon6 with 16:9 resolution, I can see black top edges when scrolling quickly. These are the edges of the rendered height map (a rectangle). Can you also look into scaling the terrain draw area? I do not yet know how this code works exactly but you can start looking around m_drawEntireTerrain, class WorldHeightMap. When zooming out more, it becomes more obvious (there is a Debug Command to zoom out).

If you do not want to do it in this change, then a follow up is also ok.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be possible, i think i have seen it in the camera code elsewhere.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So i have implemented a 1.5x scaling factor to the world height map draw area when a wide aspect ratio is used.
This works all the way up to 32:9 aspect ratios with the camera height scaling code.

I used a fixed scaling factor since when using an aspect ratio based scale it would often increase the draw area well beyond the size of the map itself.


if (m_minHeightAboveGround > m_maxHeightAboveGround)
m_maxHeightAboveGround = m_minHeightAboveGround;
}

//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
void W3DView::setDefaultView(Real pitch, Real angle, Real maxHeight)
Expand Down Expand Up @@ -1927,10 +1952,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);
Expand All @@ -1943,6 +1966,15 @@ void W3DView::setZoomToDefault( void )
m_zoom = desiredZoom;
m_heightAboveGround = m_maxHeightAboveGround;

m_cameraAreaConstraintsValid = false; // recalc it.
m_recalcCamera = true;
}

//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
void W3DView::setZoomToDefault()
{
Comment on lines +1974 to +1976
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default zoom no longer set

W3DView::setZoomToDefault() now only resets scripted-camera state but doesn’t actually set the zoom/height anymore (the zoom-setting logic was moved into setZoomToMax()), while call sites (e.g. game start) still call setZoomToDefault() expecting it to establish the default zoom. As-is, the “default” zoom/height will depend on whatever the previous camera state was unless setZoomToMax() is also invoked at every default-reset site. Either restore zoom/height setup inside setZoomToDefault() (and have setZoomToMax() be a helper) or ensure every setZoomToDefault() call site also calls setZoomToMax().

Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
Line: 1970:1972

Comment:
**Default zoom no longer set**

`W3DView::setZoomToDefault()` now only resets scripted-camera state but doesn’t actually set the zoom/height anymore (the zoom-setting logic was moved into `setZoomToMax()`), while call sites (e.g. game start) still call `setZoomToDefault()` expecting it to establish the default zoom. As-is, the “default” zoom/height will depend on whatever the previous camera state was unless `setZoomToMax()` is also invoked at every default-reset site. Either restore zoom/height setup inside `setZoomToDefault()` (and have `setZoomToMax()` be a helper) or ensure every `setZoomToDefault()` call site also calls `setZoomToMax()`.


How can I resolve this? If you propose a fix, please make it concise.

// default zoom has to be max, otherwise players will just zoom to max always
m_doingMoveCameraOnWaypointPath = false;
m_CameraArrivedAtWaypointOnPathFlag = false;
m_doingRotateCamera = false;
Expand Down
3 changes: 3 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: typo: heighScale should be heightScale

Suggested change
void doCameraSetDefault(Real pitch, Real angle, Real heighScale);
void doCameraSetDefault(Real pitch, Real angle, Real heightScale);
Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptActions.h
Line: 114:114

Comment:
**syntax:** typo: `heighScale` should be `heightScale`

```suggestion
	void doCameraSetDefault(Real pitch, Real angle, Real heightScale);
```

How can I resolve this? If you propose a fix, please make it concise.


void doOversizeTheTerrain(Int amount);
void doMoveCameraAlongWaypointPath(const AsciiString& waypoint, Real sec, Real cameraStutterSec, Real easeIn, Real easeOut);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,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();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ void InGameUI::init( void )
TheTacticalView->setWidth( TheDisplay->getWidth() );
TheTacticalView->setHeight( TheDisplay->getHeight() );
}
TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f);
TheTacticalView->setCameraHeightAboveGroundLimitsToDefault();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing setZoomToMax() call after setCameraHeightAboveGroundLimitsToDefault(). Similar to GameLogic::startNewGame() and OptionsMenu::saveOptions(), this should call setZoomToMax() to actually set the camera height.

Suggested change
TheTacticalView->setCameraHeightAboveGroundLimitsToDefault();
TheTacticalView->setCameraHeightAboveGroundLimitsToDefault();
TheTacticalView->setZoomToMax();
Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
Line: 1380:1380

Comment:
Missing `setZoomToMax()` call after `setCameraHeightAboveGroundLimitsToDefault()`. Similar to `GameLogic::startNewGame()` and `OptionsMenu::saveOptions()`, this should call `setZoomToMax()` to actually set the camera height.

```suggestion
	TheTacticalView->setCameraHeightAboveGroundLimitsToDefault();
	TheTacticalView->setZoomToMax();
```

How can I resolve this? If you propose a fix, please make it concise.


/** @todo this may be the wrong place to create the sidebar, but for now
this is where it lives */
Expand Down Expand Up @@ -2147,7 +2147,7 @@ void InGameUI::reset( void )
// reset the command bar
TheControlBar->reset();

TheTacticalView->setDefaultView(0.0f, 0.0f, 1.0f);
TheTacticalView->setCameraHeightAboveGroundLimitsToDefault();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing setZoomToMax() call after setCameraHeightAboveGroundLimitsToDefault(). Without this, the camera zoom won't be properly initialized during reset.

Suggested change
TheTacticalView->setCameraHeightAboveGroundLimitsToDefault();
TheTacticalView->setCameraHeightAboveGroundLimitsToDefault();
TheTacticalView->setZoomToMax();
Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
Line: 2150:2150

Comment:
Missing `setZoomToMax()` call after `setCameraHeightAboveGroundLimitsToDefault()`. Without this, the camera zoom won't be properly initialized during reset.

```suggestion
	TheTacticalView->setCameraHeightAboveGroundLimitsToDefault();
	TheTacticalView->setZoomToMax();
```

How can I resolve this? If you propose a fix, please make it concise.


ResetInGameChat();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: typo: heighScale should be heightScale

Suggested change
void ScriptActions::doCameraSetDefault(Real pitch, Real angle, Real heighScale)
void ScriptActions::doCameraSetDefault(Real pitch, Real angle, Real heightScale)
Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp
Line: 4611:4611

Comment:
**syntax:** typo: `heighScale` should be `heightScale`

```suggestion
void ScriptActions::doCameraSetDefault(Real pitch, Real angle, Real heightScale)
```

How can I resolve this? If you propose a fix, please make it concise.

{
TheTacticalView->setDefaultView(pitch, angle, maxHeight);
TheTacticalView->setCameraHeightAboveGroundLimitsToDefault(heighScale);
TheTacticalView->setPitch(pitch);
TheTacticalView->setAngle(angle);
}

//-------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2026,9 +2026,12 @@ 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->setAngleToDefault();
TheTacticalView->setPitchToDefault();
TheTacticalView->setZoomToDefault();
TheTacticalView->setZoomToMax();

if( TheRecorder )
TheRecorder->initControls();
Expand Down
Loading