Ensure DestroyContacts is called on fixture deletion (#3658)

This commit is contained in:
metalgearsloth
2023-01-19 13:59:43 +11:00
committed by GitHub
parent 884ac75e42
commit 3d039118c6
2 changed files with 8 additions and 12 deletions

View File

@@ -560,7 +560,7 @@ namespace Robust.Shared.GameObjects
var physicsQuery = GetEntityQuery<PhysicsComponent>();
if (oldBroadphase != null && oldBroadphase != newBroadphase)
{
RemoveFromEntityTree(oldBroadphase.Owner, oldBroadphase, ref oldPhysMap, uid, xform, xformQuery, physicsQuery, fixturesQuery);
RemoveFromEntityTree(oldBroadphase.Owner, oldBroadphase, ref oldPhysMap, uid, xform, xformQuery, fixturesQuery);
}
if (newBroadphase == null)
@@ -749,7 +749,7 @@ namespace Robust.Shared.GameObjects
$"Broadphase's map is missing a physics map comp. Broadphase: {ToPrettyString(broadphase.Owner)}");
}
RemoveFromEntityTree(broadphase.Owner, broadphase, ref physMap, uid, xform, xformQuery, physicsQuery, fixturesQuery);
RemoveFromEntityTree(broadphase.Owner, broadphase, ref physMap, uid, xform, xformQuery, fixturesQuery);
}
/// <summary>
@@ -762,7 +762,6 @@ namespace Robust.Shared.GameObjects
EntityUid uid,
TransformComponent xform,
EntityQuery<TransformComponent> xformQuery,
EntityQuery<PhysicsComponent> physicsQuery,
EntityQuery<FixturesComponent> fixturesQuery,
bool recursive = true)
{
@@ -812,7 +811,6 @@ namespace Robust.Shared.GameObjects
child.Value,
xformQuery.GetComponent(child.Value),
xformQuery,
physicsQuery,
fixturesQuery);
}
}

View File

@@ -178,18 +178,16 @@ namespace Robust.Shared.Physics.Systems
return;
}
foreach (var contact in fixture.Contacts.Values.ToArray())
{
_physics.DestroyContact(contact);
}
if (_lookup.TryGetCurrentBroadphase(xform, out var broadphase))
{
var map = Transform(broadphase.Owner).MapUid;
if (TryComp<PhysicsMapComponent>(map, out var physicsMap))
{
foreach (var contact in fixture.Contacts.Values.ToArray())
{
_physics.DestroyContact(contact);
}
}
TryComp<PhysicsMapComponent>(map, out var physicsMap);
_lookup.DestroyProxies(fixture, xform, broadphase, physicsMap);
}
if (updates)