From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 21 May 2025 13:32:46 +0000 (+1000) Subject: Use velocity along normal for shuttle impacts (#37667) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=e00c622d229fa062e880f176aa1bc5626e6a61e8;p=space-station-14.git Use velocity along normal for shuttle impacts (#37667) * Use velocity along normal for shuttle impacts Scrapes shouldn't have the same level of destruction as full-on ramming anymore. Also detecting scrapes should be a lot easier for future stuff. * Update Content.Server/Shuttles/Systems/ShuttleSystem.Impact.cs --- diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.Impact.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.Impact.cs index 771103711a..f165990f1c 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.Impact.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.Impact.cs @@ -107,6 +107,7 @@ public sealed partial class ShuttleSystem var ourXform = Transform(args.OurEntity); var otherXform = Transform(args.OtherEntity); var worldPoints = args.WorldPoints; + var worldNormal = args.WorldNormal; for (var i = 0; i < worldPoints.Length; i++) { @@ -117,7 +118,14 @@ public sealed partial class ShuttleSystem var ourVelocity = _physics.GetLinearVelocity(args.OurEntity, ourPoint.Position, ourBody, ourXform); var otherVelocity = _physics.GetLinearVelocity(args.OtherEntity, otherPoint.Position, otherBody, otherXform); - var jungleDiff = (ourVelocity - otherVelocity).Length(); + var topDiff = (ourVelocity - otherVelocity); + var jungleDiff = topDiff.Length(); + + // Get the velocity in relation to the contact normal + // If this still causes issues see https://box2d.org/posts/2020/06/ghost-collisions/ + // This should only be a potential problem on chunk seams. + var dotProduct = MathF.Abs(Vector2.Dot(topDiff.Normalized(), worldNormal.Normalized())); + jungleDiff *= dotProduct; // this is cursed but makes it so that collisions of small grid with large grid count the inertia as being approximately the small grid's var effectiveInertiaMult = (ourBody.FixturesMass * otherBody.FixturesMass) / (ourBody.FixturesMass + otherBody.FixturesMass);