fix(physics): preserve refreshed cell retry state
This commit is contained in:
parent
e5f855ac40
commit
67d1e9b331
3 changed files with 183 additions and 11 deletions
|
|
@ -70,6 +70,7 @@ public sealed class PhysicsEngine
|
|||
/// response coupling.
|
||||
/// </summary>
|
||||
internal Func<
|
||||
Transition,
|
||||
TransitionCellCollisionPhase,
|
||||
uint,
|
||||
TransitionState,
|
||||
|
|
|
|||
|
|
@ -1728,6 +1728,11 @@ public sealed class Transition
|
|||
/// The former flat per-landblock object query is gone.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
internal TransitionState TransitionalInsertForTest(
|
||||
int numAttempts,
|
||||
PhysicsEngine engine)
|
||||
=> TransitionalInsert(numAttempts, engine);
|
||||
|
||||
private TransitionState TransitionalInsert(int numAttempts, PhysicsEngine engine)
|
||||
{
|
||||
if (SpherePath.CheckCellId == 0) return TransitionState.OK;
|
||||
|
|
@ -2133,7 +2138,7 @@ public sealed class Transition
|
|||
TransitionState state = TransitionState.OK;
|
||||
for (int attempt = 0; attempt < numAttempts; attempt++)
|
||||
{
|
||||
state = FindPrimaryCellCollisions(engine, cellId, attempt);
|
||||
state = FindPrimaryCellCollisions(engine, attempt);
|
||||
if (state is TransitionState.OK or TransitionState.Collided)
|
||||
return state;
|
||||
|
||||
|
|
@ -2154,41 +2159,42 @@ public sealed class Transition
|
|||
/// </summary>
|
||||
private TransitionState FindPrimaryCellCollisions(
|
||||
PhysicsEngine engine,
|
||||
uint cellId,
|
||||
int innerAttempt)
|
||||
{
|
||||
TransitionState actualEnvironment = FindEnvCollisions(engine);
|
||||
uint currentCellId = SpherePath.CheckCellId;
|
||||
TransitionState environment = ObservePrimaryCellPhase(
|
||||
engine,
|
||||
TransitionCellCollisionPhase.Environment,
|
||||
cellId,
|
||||
FindEnvCollisions(engine));
|
||||
currentCellId,
|
||||
actualEnvironment);
|
||||
if (environment != TransitionState.OK)
|
||||
return environment;
|
||||
|
||||
TransitionState building = ObservePrimaryCellPhase(
|
||||
engine,
|
||||
TransitionCellCollisionPhase.Building,
|
||||
cellId,
|
||||
FindBuildingCollisions(engine, cellId));
|
||||
currentCellId,
|
||||
FindBuildingCollisions(engine, currentCellId));
|
||||
if (building != TransitionState.OK)
|
||||
return building;
|
||||
|
||||
TransitionState objects = ObservePrimaryCellPhase(
|
||||
engine,
|
||||
TransitionCellCollisionPhase.Objects,
|
||||
cellId,
|
||||
FindObjCollisionsInCell(engine, cellId));
|
||||
currentCellId,
|
||||
FindObjCollisionsInCell(engine, currentCellId));
|
||||
DumpPhase2(innerAttempt, environment, objects);
|
||||
return objects;
|
||||
}
|
||||
|
||||
private static TransitionState ObservePrimaryCellPhase(
|
||||
private TransitionState ObservePrimaryCellPhase(
|
||||
PhysicsEngine engine,
|
||||
TransitionCellCollisionPhase phase,
|
||||
uint cellId,
|
||||
TransitionState actual)
|
||||
=> engine.TransitionCellCollisionTestHook is { } hook
|
||||
? hook(phase, cellId, actual)
|
||||
? hook(this, phase, cellId, actual)
|
||||
: actual;
|
||||
|
||||
private TransitionState EdgeSlideAfterStepDownFailed(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue