Fix Cut 5b Soul findings (Bastion hills, Desert spacing, OTS camera, Kestrel legs, scavenge target, spectator laser)
This commit is contained in:
parent
dee2e738d8
commit
6ca17fba44
9 changed files with 476 additions and 158 deletions
|
|
@ -726,7 +726,8 @@ public partial class ArenaRenderer : Node3D
|
|||
if (s.Stance != SpectatorStance.Neutral && s.HasTargetLos && target is { Alive: true })
|
||||
{
|
||||
Vector3 start = specPos + new Vector3(0f, s.Grid.Spec.HalfHeight * 0.7f, 0f);
|
||||
Vector3 end = new Vector3(target.X, target.Y + target.Grid.Spec.HalfHeight * 0.3f, target.Z);
|
||||
var (targetPos, _, _) = session.GetInterpolatedContenderPose(target.Id, alpha);
|
||||
Vector3 end = new Vector3(targetPos.X, targetPos.Y + target.Grid.Spec.HalfHeight * 0.3f, targetPos.Z);
|
||||
float dist = start.DistanceTo(end);
|
||||
if (dist > 0.5f)
|
||||
{
|
||||
|
|
|
|||
105
client/Main.cs
105
client/Main.cs
|
|
@ -695,44 +695,33 @@ public partial class Main : Node3D
|
|||
|
||||
// Segment 1: sweep terrain + static Box3D (StableId < ContenderStableIdBase) from pivot along camRight * rightOffset
|
||||
float effectiveRight = rightOffset;
|
||||
if (Session.State.Terrain.Raycast(
|
||||
pivot.X, pivot.Y, pivot.Z,
|
||||
camRight.X, camRight.Y, camRight.Z,
|
||||
rightOffset,
|
||||
out _, out _, out _, out float rightTerrainDist))
|
||||
if (CastStaticCameraRay(pivot, camRight, rightOffset, out float rightHitDist))
|
||||
{
|
||||
effectiveRight = MathF.Min(effectiveRight, MathF.Max(0f, rightTerrainDist - 0.45f));
|
||||
}
|
||||
var rightBoxHit = Session.World.CastRayClosest(
|
||||
(pivot.X, pivot.Y, pivot.Z),
|
||||
(camRight.X * effectiveRight, camRight.Y * effectiveRight, camRight.Z * effectiveRight));
|
||||
if (rightBoxHit.Hit && rightBoxHit.StableId < ArenaSession.ContenderStableIdBase)
|
||||
{
|
||||
var pt = new Vector3(rightBoxHit.Point.X, rightBoxHit.Point.Y, rightBoxHit.Point.Z);
|
||||
effectiveRight = MathF.Min(effectiveRight, MathF.Max(0f, pivot.DistanceTo(pt) - 0.45f));
|
||||
effectiveRight = MathF.Min(effectiveRight, MathF.Max(0f, MathF.Min(rightHitDist - 0.35f, rightHitDist * 0.85f)));
|
||||
}
|
||||
Vector3 shoulderPos = pivot + camRight * effectiveRight;
|
||||
|
||||
// Segment 2: sweep terrain + static Box3D from shoulderPos along -lookDir * backDist
|
||||
float effectiveBack = backDist;
|
||||
if (Session.State.Terrain.Raycast(
|
||||
shoulderPos.X, shoulderPos.Y, shoulderPos.Z,
|
||||
-lookDir.X, -lookDir.Y, -lookDir.Z,
|
||||
backDist,
|
||||
out _, out _, out _, out float backTerrainDist))
|
||||
if (CastStaticCameraRay(shoulderPos, -lookDir, backDist, out float backHitDist))
|
||||
{
|
||||
effectiveBack = MathF.Min(effectiveBack, MathF.Max(0.6f, backTerrainDist - 0.5f));
|
||||
}
|
||||
var backBoxHit = Session.World.CastRayClosest(
|
||||
(shoulderPos.X, shoulderPos.Y, shoulderPos.Z),
|
||||
(-lookDir.X * effectiveBack, -lookDir.Y * effectiveBack, -lookDir.Z * effectiveBack));
|
||||
if (backBoxHit.Hit && backBoxHit.StableId < ArenaSession.ContenderStableIdBase)
|
||||
{
|
||||
var pt = new Vector3(backBoxHit.Point.X, backBoxHit.Point.Y, backBoxHit.Point.Z);
|
||||
effectiveBack = MathF.Min(effectiveBack, MathF.Max(0.6f, shoulderPos.DistanceTo(pt) - 0.5f));
|
||||
effectiveBack = MathF.Min(effectiveBack, SafeCameraPullbackDist(backHitDist));
|
||||
}
|
||||
|
||||
Vector3 camPos = shoulderPos - lookDir * effectiveBack;
|
||||
|
||||
// Segment 3: verify direct pivot -> camPos LOS against static terrain/buildings so stepped wings cannot occlude player
|
||||
Vector3 pivotToCam = camPos - pivot;
|
||||
float pivotToCamDist = pivotToCam.Length();
|
||||
if (pivotToCamDist > 0.05f)
|
||||
{
|
||||
Vector3 pivotToCamDir = pivotToCam / pivotToCamDist;
|
||||
if (CastStaticCameraRay(pivot, pivotToCamDir, pivotToCamDist, out float wingHitDist))
|
||||
{
|
||||
camPos = pivot + pivotToCamDir * SafeCameraPullbackDist(wingHitDist);
|
||||
}
|
||||
}
|
||||
|
||||
float minTerrainY = Session.State.Terrain.SampleHeight(camPos.X, camPos.Z) + 1.2f;
|
||||
if (camPos.Y < minTerrainY)
|
||||
{
|
||||
|
|
@ -743,6 +732,66 @@ public partial class Main : Node3D
|
|||
_camera.LookAt(camPos + lookDir * 60f, Vector3.Up);
|
||||
}
|
||||
|
||||
private static float SafeCameraPullbackDist(float rawDist) =>
|
||||
MathF.Max(MathF.Min(0.05f, rawDist * 0.85f), MathF.Min(rawDist - 0.35f, rawDist * 0.85f));
|
||||
|
||||
private bool CastStaticCameraRay(Vector3 origin, Vector3 dir, float maxDist, out float hitDist)
|
||||
{
|
||||
hitDist = maxDist;
|
||||
if (maxDist <= 0.01f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hasHit = false;
|
||||
if (Session.State.Terrain.Raycast(
|
||||
origin.X, origin.Y, origin.Z,
|
||||
dir.X, dir.Y, dir.Z,
|
||||
maxDist,
|
||||
out _, out _, out _, out float terrainDist))
|
||||
{
|
||||
hitDist = MathF.Min(hitDist, terrainDist);
|
||||
hasHit = true;
|
||||
}
|
||||
|
||||
Vector3 castOrigin = origin;
|
||||
float skipped = 0f;
|
||||
float remaining = hitDist;
|
||||
for (int attempt = 0; attempt < 16 && remaining > 0.05f; attempt++)
|
||||
{
|
||||
var hit = Session.World.CastRayClosest(
|
||||
(castOrigin.X, castOrigin.Y, castOrigin.Z),
|
||||
(dir.X * remaining, dir.Y * remaining, dir.Z * remaining));
|
||||
if (!hit.Hit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var pt = new Vector3(hit.Point.X, hit.Point.Y, hit.Point.Z);
|
||||
float distFromOrigin = origin.DistanceTo(pt);
|
||||
if (hit.StableId < ArenaSession.ContenderStableIdBase)
|
||||
{
|
||||
if (distFromOrigin < hitDist)
|
||||
{
|
||||
hitDist = distFromOrigin;
|
||||
hasHit = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
float nextSkip = MathF.Max(distFromOrigin + 0.15f, skipped + 0.5f);
|
||||
if (nextSkip >= hitDist)
|
||||
{
|
||||
break;
|
||||
}
|
||||
skipped = nextSkip;
|
||||
castOrigin = origin + dir * skipped;
|
||||
remaining = hitDist - skipped;
|
||||
}
|
||||
|
||||
return hasHit;
|
||||
}
|
||||
|
||||
private void OnEquipCargo(int cargoIndex, string hardpointId)
|
||||
{
|
||||
_session?.TryEquipCargo(cargoIndex, hardpointId);
|
||||
|
|
|
|||
Loading…
Reference in a new issue