Skip to content

Commit

Permalink
Fix contacr constraints allocs
Browse files Browse the repository at this point in the history
These show up a lot on tumbler but no more.
  • Loading branch information
metalgearsloth committed Nov 19, 2023
1 parent 2459a9d commit 423ce0d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

using System.Numerics;
using Robust.Shared.Maths;
using Robust.Shared.Physics.Collision;

namespace Robust.Shared.Physics.Dynamics.Contacts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

using System.Numerics;
using Robust.Shared.Maths;

namespace Robust.Shared.Physics.Dynamics.Contacts
{
Expand Down
10 changes: 3 additions & 7 deletions Robust.Shared/Physics/Systems/SharedPhysicsSystem.Solver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,8 @@ private void ResetSolver(
velocityConstraint.TangentSpeed = contact.TangentSpeed;
velocityConstraint.IndexA = bodyA.IslandIndex[island.Index];
velocityConstraint.IndexB = bodyB.IslandIndex[island.Index];
velocityConstraint.Points = new VelocityConstraintPoint[2];

for (var j = 0; j < 2; j++)
{
velocityConstraint.Points[j] = new VelocityConstraintPoint();
}
Array.Resize(ref velocityConstraint.Points, 2);
// Don't need to reset point data as it all gets set below.

var (invMassA, invMassB) = GetInvMass(bodyA, bodyB);

Expand All @@ -91,7 +87,7 @@ private void ResetSolver(
(positionConstraint.InvMassA, positionConstraint.InvMassB) = (invMassA, invMassB);
positionConstraint.LocalCenterA = bodyA.LocalCenter;
positionConstraint.LocalCenterB = bodyB.LocalCenter;
positionConstraint.LocalPoints = new Vector2[2];
Array.Resize(ref positionConstraint.LocalPoints, 2);

positionConstraint.InvIA = bodyA.InvI;
positionConstraint.InvIB = bodyB.InvI;
Expand Down

0 comments on commit 423ce0d

Please sign in to comment.