feat(physics): wire CTransition sphere-sweep into player movement
Replace simple Z-snap PhysicsEngine.Resolve with ResolveWithTransition that uses the ported CTransition sphere-sweep pipeline. Movement is subdivided into sphere-radius steps, terrain collision tested at each step with step-down for ground contact maintenance. Falls back to simple Resolve if transition fails. Player controller now passes pre/post integration positions to the transition system. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6523c7199b
commit
246713e2cc
2 changed files with 66 additions and 22 deletions
|
|
@ -259,4 +259,43 @@ public sealed class PhysicsEngine
|
|||
targetCellId,
|
||||
IsOnGround: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolve movement using the CTransition sphere-sweep system.
|
||||
/// Subdivides movement into sphere-radius steps, tests terrain collision
|
||||
/// at each step, handles step-down for ground contact.
|
||||
/// Falls back to the simple <see cref="Resolve"/> if the transition fails.
|
||||
/// </summary>
|
||||
public ResolveResult ResolveWithTransition(
|
||||
Vector3 currentPos, Vector3 targetPos, uint cellId,
|
||||
float sphereRadius, float sphereHeight,
|
||||
float stepUpHeight, float stepDownHeight,
|
||||
bool isOnGround)
|
||||
{
|
||||
var transition = new Transition();
|
||||
transition.ObjectInfo.StepUpHeight = stepUpHeight;
|
||||
transition.ObjectInfo.StepDownHeight = stepDownHeight;
|
||||
transition.ObjectInfo.StepDown = true;
|
||||
|
||||
if (isOnGround)
|
||||
transition.ObjectInfo.State |= ObjectInfoState.Contact | ObjectInfoState.OnWalkable;
|
||||
|
||||
transition.SpherePath.InitPath(currentPos, targetPos, cellId, sphereRadius, sphereHeight);
|
||||
|
||||
bool ok = transition.FindTransitionalPosition(this);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
var sp = transition.SpherePath;
|
||||
var ci = transition.CollisionInfo;
|
||||
|
||||
bool onGround = ci.ContactPlaneValid
|
||||
|| transition.ObjectInfo.State.HasFlag(ObjectInfoState.OnWalkable);
|
||||
|
||||
return new ResolveResult(sp.CheckPos, sp.CheckCellId, onGround);
|
||||
}
|
||||
|
||||
// Transition failed — fall back to simple resolve.
|
||||
return Resolve(currentPos, cellId, targetPos - currentPos, stepUpHeight);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue