Facepunch / sbox-sdf

Library providing marching cubes / squares mesh generation
MIT License
14 stars 7 forks source link

if `Trace.Body` hit an SdfWorldEntity, S&box crash #21

Open PolSpock opened 1 year ago

PolSpock commented 1 year ago

Describe the bug

Hi,

If you run a Sandbox.Trace.Body(PhysicsBody, Transform, Vector3) and your Trace hits a SdfWorldEntity who has any SDF collision (like solid, trigger, water or whatever), your s&box will crash.

Unfortunately, s&box doesn't give any other information about the crash

To Reproduce

1) Create any SdfWorld 2D or 3D and initialize it with some surface who have at least one Collision tag. So for example, with the BlobTool.cs, create some blob with the default SDF material default.sdfvol

2) Run a Sandbox.Trace.Body(PhysicsBody, Transform, Vector3), so for example add this code in the Simulate block of BlobTool.cs

if (Game.IsServer)
{
    Trace collisionTrace = Trace.Body( Owner.PhysicsBody, Owner.PhysicsBody.Transform, Owner.Position + Vector3.Down * 32f ).Ignore( Owner );
    Log.Info( collisionTrace.Run() );
}

The crash also occurs when Trace is running Clientside.

3) Walk on the created Sdf Blob with the BlobTool in hand: your s&box will crash

Expected behavior

Running a trace on sdf entity should not crash s&box

Regards