@@ -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+
321334void 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));
0 commit comments