diff --git a/sources/Directory.Packages.props b/sources/Directory.Packages.props index d67bd5c409..700027eb8f 100644 --- a/sources/Directory.Packages.props +++ b/sources/Directory.Packages.props @@ -4,7 +4,7 @@ - + diff --git a/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/BepuSimulation.cs b/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/BepuSimulation.cs index 48e54b6c70..064213b78a 100644 --- a/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/BepuSimulation.cs +++ b/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/BepuSimulation.cs @@ -366,7 +366,7 @@ public bool ShouldPerformPhysicsTest(CollisionMask mask, CollidableReference col public bool RayCast(in Vector3 origin, in Vector3 dir, float maxDistance, out HitInfo result, CollisionMask collisionMask = CollisionMask.Everything) { var handler = new RayClosestHitHandler(this, collisionMask); - Simulation.RayCast(origin.ToNumeric(), dir.ToNumeric(), maxDistance, ref handler); + Simulation.RayCast(origin.ToNumeric(), dir.ToNumeric(), maxDistance, BufferPool, ref handler); if (handler.HitInformation.HasValue) { result = handler.HitInformation.Value; @@ -397,7 +397,7 @@ public unsafe ConversionEnum RayCastPen fixed (HitInfoStack* ptr = &buffer[0]) { var handler = new RayHitsStackHandler(ptr, buffer.Length, this, collisionMask); - Simulation.RayCast(origin.ToNumeric(), dir.ToNumeric(), maxDistance, ref handler); + Simulation.RayCast(origin.ToNumeric(), dir.ToNumeric(), maxDistance, BufferPool, ref handler); return new (buffer[..handler.Head], new ManagedConverter(this)); } } @@ -414,7 +414,7 @@ public unsafe ConversionEnum RayCastPen public void RayCastPenetrating(in Vector3 origin, in Vector3 dir, float maxDistance, ICollection collection, CollisionMask collisionMask = CollisionMask.Everything) { var handler = new RayHitsCollectionHandler(this, collection, collisionMask); - Simulation.RayCast(origin.ToNumeric(), dir.ToNumeric(), maxDistance, ref handler); + Simulation.RayCast(origin.ToNumeric(), dir.ToNumeric(), maxDistance, BufferPool, ref handler); } /// @@ -622,7 +622,7 @@ private unsafe void OverlapInner(in TShape shape, in SRigidP try { - Simulation.BroadPhase.GetOverlaps(boundingBoxMin, boundingBoxMax, ref broadPhaseEnumerator); + Simulation.BroadPhase.GetOverlaps(boundingBoxMin, boundingBoxMax, BufferPool, ref broadPhaseEnumerator); var batcher = new CollisionBatcher>(BufferPool, Simulation.Shapes, Simulation.NarrowPhase.CollisionTaskRegistry, 0, new() { diff --git a/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/CollidableComponent.cs b/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/CollidableComponent.cs index 5c1ef9bc11..8667552b33 100644 --- a/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/CollidableComponent.cs +++ b/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/CollidableComponent.cs @@ -464,6 +464,6 @@ internal void RayTest( if (ShapeIndex.Exists == false || Simulation is null) return; - Collider.RayTest(Simulation.Simulation.Shapes, ShapeIndex, Pose!.Value, new RayData { Origin = origin, Direction = dir }, ref maximumT, ref hitHandler); + Collider.RayTest(Simulation.Simulation.Shapes, ShapeIndex, Pose!.Value, new RayData { Origin = origin, Direction = dir }, ref maximumT, ref hitHandler, Simulation.BufferPool); } } diff --git a/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/CompoundCollider.cs b/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/CompoundCollider.cs index 442b856237..5123490510 100644 --- a/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/CompoundCollider.cs +++ b/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/CompoundCollider.cs @@ -127,16 +127,16 @@ void ICollider.AppendModel(List buffer, ShapeCacheSystem shape } } - void ICollider.RayTest(Shapes shapes, TypedIndex shapeIndex, in NRigidPose pose, in RayData ray, ref float maximumT, ref TRayHitHandler hitHandler) + void ICollider.RayTest(Shapes shapes, TypedIndex shapeIndex, in NRigidPose pose, in RayData ray, ref float maximumT, ref TRayHitHandler hitHandler, BufferPool pool) { if (shapeIndex.Type == Compound.TypeId) { - shapes.GetShape(shapeIndex.Index).RayTest(pose, in ray, ref maximumT, shapes, ref hitHandler); + shapes.GetShape(shapeIndex.Index).RayTest(pose, in ray, ref maximumT, shapes, pool, ref hitHandler); } else { Debug.Assert(shapeIndex.Type == BigCompound.TypeId); - shapes.GetShape(shapeIndex.Index).RayTest(pose, in ray, ref maximumT, shapes, ref hitHandler); + shapes.GetShape(shapeIndex.Index).RayTest(pose, in ray, ref maximumT, shapes, pool, ref hitHandler); } } } diff --git a/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/EmptyCollider.cs b/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/EmptyCollider.cs index e7761aa8cf..f6663c6c5a 100644 --- a/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/EmptyCollider.cs +++ b/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/EmptyCollider.cs @@ -44,7 +44,7 @@ bool ICollider.TryAttach(Shapes shapes, BufferPool pool, ShapeCacheSystem shapeC return true; } - void ICollider.RayTest(Shapes shapes, TypedIndex shapeIndex, in NRigidPose pose, in RayData ray, ref float maximumT, ref TRayHitHandler hitHandler) + void ICollider.RayTest(Shapes shapes, TypedIndex shapeIndex, in NRigidPose pose, in RayData ray, ref float maximumT, ref TRayHitHandler hitHandler, BufferPool pool) { } } diff --git a/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/ICollider.cs b/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/ICollider.cs index ebbe6fbac1..dce1e2fe73 100644 --- a/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/ICollider.cs +++ b/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/ICollider.cs @@ -33,6 +33,7 @@ internal void RayTest( in NRigidPose pose, in RayData ray, ref float maximumT, - ref TRayHitHandler hitHandler) + ref TRayHitHandler hitHandler, + BufferPool pool) where TRayHitHandler : struct, IShapeRayHitHandler; } diff --git a/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/MeshCollider.cs b/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/MeshCollider.cs index 59bdae0319..57eca8c9a6 100644 --- a/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/MeshCollider.cs +++ b/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Colliders/MeshCollider.cs @@ -118,9 +118,9 @@ void ICollider.AppendModel(List buffer, ShapeCacheSystem shape cacheOut = cache; } - void ICollider.RayTest(Shapes shapes, TypedIndex shapeIndex, in NRigidPose pose, in RayData ray, ref float maximumT, ref TRayHitHandler hitHandler) + void ICollider.RayTest(Shapes shapes, TypedIndex shapeIndex, in NRigidPose pose, in RayData ray, ref float maximumT, ref TRayHitHandler hitHandler, BufferPool pool) { Debug.Assert(shapeIndex.Type == Mesh.TypeId); - shapes.GetShape(shapeIndex.Index).RayTest(pose, in ray, ref maximumT, ref hitHandler); + shapes.GetShape(shapeIndex.Index).RayTest(pose, in ray, ref maximumT, pool, ref hitHandler); } }