Skip to content

Commit 4d76fd8

Browse files
PtaQQclaude
andcommitted
SpringController: name the camera focus point a "focus surface"
Pure rename in preparation for the smooth mesh height tracking rework. The camera focus height and the zoom-distance-to-focus computation are about to stop being plain raw-ground lookups, so route them through GetFocusSurfaceHeight() and DistanceToFocusSurface() wrappers. Behavior is unchanged: both currently forward to the raw ground. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c6fb86e commit 4d76fd8

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

rts/Game/Camera/SpringController.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ float CSpringController::ZoomIn(const float3& curCamPos, const float3& newDir, c
253253
const float zoomAmount = std::min(1.0f - scaledMode, (curDistPre - minDist) / curDistPre);
254254
const float3 wantedPos = curCamPos + cursorVec * zoomAmount;
255255

256-
// figure out how far we will end up from the ground at new wanted point
257-
curDist = DistanceToGround(wantedPos, dir, pos.y);
256+
// figure out how far we will end up from the focus surface at new wanted point
257+
curDist = DistanceToFocusSurface(wantedPos);
258258
pos = wantedPos + dir * curDist;
259259

260260
return 0.25f;
@@ -293,7 +293,7 @@ float CSpringController::ZoomOut(const float3& curCamPos, const float3& newDir,
293293

294294
auto extrapolate_position = [&] (float scale) {
295295
const float3 wantedCamPos = curCamPos + cursorVec * (1.0f - scaledMode) * scale;
296-
const float newDist = DistanceToGround(wantedCamPos, dir, pos.y);
296+
const float newDist = DistanceToFocusSurface(wantedCamPos);
297297
return std::pair{wantedCamPos, newDist};
298298
};
299299

@@ -318,13 +318,26 @@ float CSpringController::ZoomOut(const float3& curCamPos, const float3& newDir,
318318

319319

320320

321+
float CSpringController::GetFocusSurfaceHeight(float x, float z) const
322+
{
323+
RECOIL_DETAILED_TRACY_ZONE;
324+
return CGround::GetHeightReal(x, z, false);
325+
}
326+
327+
float CSpringController::DistanceToFocusSurface(const float3& from) const
328+
{
329+
RECOIL_DETAILED_TRACY_ZONE;
330+
return DistanceToGround(from, dir, pos.y);
331+
}
332+
333+
321334
void CSpringController::Update()
322335
{
323336
RECOIL_DETAILED_TRACY_ZONE;
324337

325338
pos.x = std::clamp(pos.x, 0.01f, mapDims.mapx * SQUARE_SIZE - 0.01f);
326339
pos.z = std::clamp(pos.z, 0.01f, mapDims.mapy * SQUARE_SIZE - 0.01f);
327-
pos.y = CGround::GetHeightReal(pos.x, pos.z, false); // always focus on the ground
340+
pos.y = GetFocusSurfaceHeight(pos.x, pos.z); // always focus on the ground
328341
rot.x = std::clamp(rot.x, math::PI * 0.51f, math::PI * 0.99f);
329342

330343
// camera->SetRot(float3(rot.x, GetAzimuth(), rot.z));

rts/Game/Camera/SpringController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class CSpringController : public CCameraController
4444
inline float ZoomOut(const float3& curCamPos, const float3& dir, const float& curDistPre, const float& scaledMode);
4545

4646
void SmoothCamHeight(const float3& prevPos);
47+
float GetFocusSurfaceHeight(float x, float z) const;
48+
float DistanceToFocusSurface(const float3& from) const;
4749

4850
private:
4951
float3 rot;

0 commit comments

Comments
 (0)