Fixes camera constraints by clamping the camera focus point to within the map bounds instead of outside, since the constraints are partially based on terrain height. Should improve scrolling behavior on both circular and square maps. Refs #656, #850
This was SVN commit r11044.
This commit is contained in:
parent
b2fd7a54f0
commit
202a8e17c4
@ -806,14 +806,14 @@ void CGameView::Update(float DeltaTime)
|
||||
float r = pTerrain->GetMaxX() / 2;
|
||||
CVector3D center(r, desiredPivot.Y, r);
|
||||
float dist = (desiredPivot - center).Length();
|
||||
if (dist > r + CAMERA_EDGE_MARGIN)
|
||||
desiredPivot = center + (desiredPivot - center).Normalized() * (r + CAMERA_EDGE_MARGIN);
|
||||
if (dist > r - CAMERA_EDGE_MARGIN)
|
||||
desiredPivot = center + (desiredPivot - center).Normalized() * (r - CAMERA_EDGE_MARGIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clamp to the square edges of the map
|
||||
desiredPivot.X = Clamp(desiredPivot.X, pTerrain->GetMinX() - CAMERA_EDGE_MARGIN, pTerrain->GetMaxX() + CAMERA_EDGE_MARGIN);
|
||||
desiredPivot.Z = Clamp(desiredPivot.Z, pTerrain->GetMinZ() - CAMERA_EDGE_MARGIN, pTerrain->GetMaxZ() + CAMERA_EDGE_MARGIN);
|
||||
desiredPivot.X = Clamp(desiredPivot.X, pTerrain->GetMinX() + CAMERA_EDGE_MARGIN, pTerrain->GetMaxX() - CAMERA_EDGE_MARGIN);
|
||||
desiredPivot.Z = Clamp(desiredPivot.Z, pTerrain->GetMinZ() + CAMERA_EDGE_MARGIN, pTerrain->GetMaxZ() - CAMERA_EDGE_MARGIN);
|
||||
}
|
||||
|
||||
// Update the position so that pivot is within the margin
|
||||
|
Loading…
Reference in New Issue
Block a user