-
Notifications
You must be signed in to change notification settings - Fork 118
fix(view): Adjust default camera height to compensate for screen aspect ratio #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 |
|---|---|---|
|
|
@@ -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; | ||
|
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.
Author
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.
Author
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 +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(); | ||
| } | ||
|
|
||
| //------------------------------------------------------------------------------------------------- | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.