fix(uxassist): auto-cruise leaves every obstacle the mecha is inside

ComputeDirection returned the escape heading of the first obstacle in the
list whose path radius contains the mecha. A mecha standing on a moon close
to its gas giant is inside two path radii at once (the moon's 2200 m and the
giant's 2800 m), and the giant comes first. Taking off from the moon's
giant-facing side, "away from the giant" points into the ground: the mecha
dives right after entering space, drops back under the game's landing rule,
takes off again, and so on.

Sum the inward directions of all obstacles that contain the mecha, each
weighted by how deep the mecha is inside it, and escape from that. The body
right below dominates near its surface. Route blocking is checked only when
the mecha is inside no obstacle, as before for a single obstacle.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Jiesi LuoandClaude Fable 5.2 authored and Soar Qin committed 2026-11-16 09:05:47 +08:00
1 parent a1ba5266bb
commit 5e6cfe7fa5
2 files changed
+27 -3

No files matched your search

+25 -3
View File
@@ -654,6 +654,14 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
return default;
VectorLF3 baseDir = toTarget.normalized;
// The mecha can be inside several path radii at once: a moon close to its gas giant puts a mecha
// on the moon inside both, and the giant comes first in the list. Leaving only the first one
// sends a mecha that takes off from the moon's giant-facing side back into the ground, because
// "away from the giant" points down there. Leave all of them together, each weighted by how deep
// the mecha is inside it, so the body right below dominates.
VectorLF3 inward = default;
bool insideObstacle = false;
foreach (Obstacle obstacle in obstacles)
{
double pathRadius = GetReachablePathRadius(obstacle);
@@ -662,10 +670,24 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
VectorLF3 toObstacle = obstacle.Position - playerPos;
double obstacleDistance = toObstacle.magnitude;
if (obstacleDistance < pathRadius)
return ComputeEscapeDirection(currentDirection, toObstacle, baseDir);
if (obstacleDistance >= pathRadius)
continue;
inward += SafeNorm(toObstacle, baseDir) * (pathRadius - obstacleDistance);
insideObstacle = true;
}
if (insideObstacle)
return ComputeEscapeDirection(currentDirection, inward, baseDir);
foreach (Obstacle obstacle in obstacles)
{
double pathRadius = GetReachablePathRadius(obstacle);
if (pathRadius <= 0.0)
continue;
if (IsSegmentBlocked(playerPos, _targetUniversePosition, obstacle.Position, pathRadius))
return ComputeTangentDirection(currentDirection, toObstacle, pathRadius, baseDir);
return ComputeTangentDirection(currentDirection, obstacle.Position - playerPos, pathRadius, baseDir);
}
return baseDir;