Files
RobustToolbox/Robust.Server/Debugging/DebugDrawingManager.cs
T
metalgearslothandGitHub 3ac5552276 Cache more broadphase stuff internally (#2071)
* Don't generate physics contacts for non-predicted bodies

These are all just handled on the server anyway so it's a significant waste of performance on the client for busy scenes.

* Significantly optimise broadphase updates

Cache all of the broadphase data properly now and also save the cache for physics step to boot.

* Fix cross-map broadphases

* Remove unnecessary clear

* fix

* Fixes

* Numerous ray fixes
2021-10-10 14:18:10 +11:00

39 lines
1.1 KiB
C#

using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Network.Messages;
using Robust.Shared.Physics;
namespace Robust.Server.Debugging
{
[UsedImplicitly]
internal class DebugDrawingManager : IDebugDrawingManager, IEntityEventSubscriber
{
[Dependency] private readonly IEntityManager _entManager = default!;
public void Initialize()
{
#if DEBUG
_entManager.EventBus.SubscribeEvent<DebugDrawRayMessage>(EventSource.Local, this, PhysicsOnDebugDrawRay);
#endif
}
private void PhysicsOnDebugDrawRay(DebugDrawRayMessage @event)
{
var data = @event.Data;
var msg = new MsgRay {RayOrigin = data.Ray.Position};
if (data.Results != null)
{
msg.DidHit = true;
msg.RayHit = data.Results.Value.HitPos;
}
else
{
msg.RayHit = data.Ray.Position + data.Ray.Direction * data.MaxLength;
}
_entManager.EventBus.RaiseEvent(EventSource.Network, msg);
}
}
}