- 
                Notifications
    You must be signed in to change notification settings 
- Fork 111
fix(view): Adjust default camera height to compensate for screen aspect ratio, reduce camera map limits and increase terrain render distance. #1711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -503,7 +503,8 @@ void W3DView::calcCameraConstraints() | |
| center.x -= bottom.x; | ||
| center.y -= bottom.y; | ||
|  | ||
| Real offset = center.length(); | ||
| // TheSuperHackers @bugfix Mauller 22/10/2025 Halve the camera offset to allow the camera to move closer to the map edges | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removing this for now till after this and your camera extents PR's are done | ||
| Real offset = center.length() * 0.5f; | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested this behavior and I suspect this was done to address #1270. However, the black area that this creates is quite substantial. I have created new change #1752 to address #1270 without extending the constraints area into blackness. There still is merit to experiment with a greater viewable area, for example  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i will revert the offset change for now and we can look at that after this and #1752 are merged. | ||
|  | ||
| if (TheGlobalData->m_debugAI) { | ||
| offset = -1000; // push out the constraints so we can look at staging areas. | ||
|  | @@ -1923,12 +1924,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; | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe 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  If you do not want to do it in this change, then a follow up is also ok. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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; | ||
| } | ||
|  | @@ -1971,10 +1985,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 +1999,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(); | ||
| } | ||
|  | ||
| //------------------------------------------------------------------------------------------------- | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -52,6 +52,8 @@ | |
| #include "W3DDevice/GameClient/TerrainTex.h" | ||
| #include "W3DDevice/GameClient/W3DShadow.h" | ||
|  | ||
| #include "GameClient/view.h" | ||
|  | ||
| #include "Common/file.h" | ||
|  | ||
|  | ||
|  | @@ -534,6 +536,19 @@ WorldHeightMap::WorldHeightMap(ChunkInputStream *pStrm, Bool logicalDataOnly): | |
| m_drawWidthX=m_width; | ||
| m_drawHeightY=m_height; | ||
| } | ||
| else { | ||
| //TheSuperHacker @bugfix Mauller 23/10/2025 Increase the terrain draw area for wide aspect ratios | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this does not work correctly in Shell Map. When changing aspect ratio from 4:3 to wide, then this code is not called. Can we run this after the WorldHeightMap was created? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah i am just looking a bit more into this and it's not very straightforwards, the  Just muddling through a way to cleanly get at the height map inside it all from the terrain logic which has a singleton. | ||
| Real baseAspectRatio = (Real)DEFAULT_DISPLAY_WIDTH / (Real)DEFAULT_DISPLAY_HEIGHT; | ||
| Real currentAspectRatio = (Real)TheTacticalView->getWidth() / (Real)TheTacticalView->getHeight(); | ||
| constexpr Real drawAreaScaleFactor = 1.5f; | ||
|  | ||
| if (currentAspectRatio > baseAspectRatio) | ||
| { | ||
| m_drawWidthX *= drawAreaScaleFactor; | ||
| m_drawHeightY *= drawAreaScaleFactor; | ||
| } | ||
| } | ||
|  | ||
| if (m_drawWidthX > m_width) { | ||
| m_drawWidthX = m_width; | ||
| } | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.