Skip to content

Commit

Permalink
Physics: update BepuPhysics to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
phr00t committed Jan 29, 2020
1 parent 86a5044 commit dd104b0
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 26 deletions.
4 changes: 2 additions & 2 deletions deps/bepuphysics2/BepuPhysics.dll
Git LFS file not shown
4 changes: 2 additions & 2 deletions deps/bepuphysics2/BepuPhysics.pdb
Git LFS file not shown
4 changes: 2 additions & 2 deletions deps/bepuphysics2/BepuUtilities.dll
Git LFS file not shown
4 changes: 2 additions & 2 deletions deps/bepuphysics2/BepuUtilities.pdb
Git LFS file not shown
4 changes: 2 additions & 2 deletions deps/bepuphysics2/Debug/BepuPhysics.dll
Git LFS file not shown
4 changes: 2 additions & 2 deletions deps/bepuphysics2/Debug/BepuPhysics.pdb
Git LFS file not shown
4 changes: 2 additions & 2 deletions deps/bepuphysics2/Debug/BepuUtilities.dll
Git LFS file not shown
4 changes: 2 additions & 2 deletions deps/bepuphysics2/Debug/BepuUtilities.pdb
Git LFS file not shown
29 changes: 25 additions & 4 deletions sources/engine/Xenko.Physics/Bepu/BepuHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,15 +489,36 @@ public static unsafe Xenko.Core.Mathematics.Vector3 ToXenko(System.Numerics.Vect
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe Xenko.Core.Mathematics.Quaternion ToXenko(BepuUtilities.Quaternion q)
public static Xenko.Core.Mathematics.Quaternion ToXenko(System.Numerics.Quaternion q)
{
return *((Xenko.Core.Mathematics.Quaternion*)(void*)&q);
return new Quaternion(q.X, q.Y, q.Z, q.W);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe BepuUtilities.Quaternion ToBepu(Xenko.Core.Mathematics.Quaternion q)
public static System.Numerics.Quaternion ToBepu(Xenko.Core.Mathematics.Quaternion q)
{
return *((BepuUtilities.Quaternion*)(void*)&q);
return new System.Numerics.Quaternion(q.X, q.Y, q.Z, q.W);
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ToXenko(ref System.Numerics.Quaternion qin, ref Xenko.Core.Mathematics.Quaternion qout)
{
qout.X = qin.X;
qout.Y = qin.Y;
qout.Z = qin.Z;
qout.W = qin.W;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ToBepu(ref Xenko.Core.Mathematics.Quaternion qin, ref Xenko.Core.Mathematics.Quaternion qout)
{
qout.X = qin.X;
qout.Y = qin.Y;
qout.Z = qin.Z;
qout.W = qin.W;
}


}
}
4 changes: 2 additions & 2 deletions sources/engine/Xenko.Physics/Bepu/BepuShapeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public bool LoopBody(CollidableReference reference)
/// <param name="queryId">Id to use to refer to this query when the collision batcher finishes processing it.</param>
/// <param name="batcher">Batcher to add the query's tests to.</param>
static private unsafe void RunQuery(int queryShapeType, void* queryShapeData, int queryShapeSize, in Vector3 queryBoundsMin,
in Vector3 queryBoundsMax, Vector3 queryPos, BepuUtilities.Quaternion queryRot,
in Vector3 queryBoundsMax, Vector3 queryPos, System.Numerics.Quaternion queryRot,
ref CollisionBatcher<BatcherCallbacks> batcher, CollisionFilterGroupFlags lookingFor)
{
var broadPhaseEnumerator = new BroadPhaseOverlapEnumerator { components = new List<BepuPhysicsComponent>(), lookingFor = (uint)lookingFor };
Expand Down Expand Up @@ -119,7 +119,7 @@ static public unsafe List<BepuContact> SingleQuery<TShape>(TShape shape, Xenko.C
List<BepuContact> contacts = new List<BepuContact>();
var batcher = new CollisionBatcher<BatcherCallbacks>(BepuSimulation.safeBufferPool, BepuSimulation.instance.internalSimulation.Shapes,
BepuSimulation.instance.internalSimulation.NarrowPhase.CollisionTaskRegistry, 0f, new BatcherCallbacks() { contactList = contacts });
BepuUtilities.Quaternion q = BepuHelpers.ToBepu(rotation);
System.Numerics.Quaternion q = BepuHelpers.ToBepu(rotation);
Vector3 v = BepuHelpers.ToBepu(position);
shape.ComputeBounds(q, out var boundingBoxMin, out var boundingBoxMax);
boundingBoxMin += v;
Expand Down
8 changes: 4 additions & 4 deletions sources/engine/Xenko.Physics/Bepu/BepuSimulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ public void OnHitAtZeroT(ref float maximumT, CollidableReference collidable)
/// <param name="filterFlags">The collision group that this shape sweep can collide with</param>
/// <returns></returns>
/// <exception cref="System.Exception">This kind of shape cannot be used for a ShapeSweep.</exception>
public BepuHitResult ShapeSweep(IConvexShape shape, Vector3 position, Xenko.Core.Mathematics.Quaternion rotation, Vector3 endpoint, CollisionFilterGroupFlags hitGroups = DefaultFlags, bool skipAtZero = false)
public BepuHitResult ShapeSweep<TShape>(TShape shape, Vector3 position, Xenko.Core.Mathematics.Quaternion rotation, Vector3 endpoint, CollisionFilterGroupFlags hitGroups = DefaultFlags, bool skipAtZero = false) where TShape : unmanaged, IConvexShape
{
Vector3 diff = endpoint - position;
float length = diff.Length();
Expand All @@ -777,7 +777,7 @@ public BepuHitResult ShapeSweep(IConvexShape shape, Vector3 position, Xenko.Core
/// <param name="filterFlags">The collision group that this shape sweep can collide with</param>
/// <returns></returns>
/// <exception cref="System.Exception">This kind of shape cannot be used for a ShapeSweep.</exception>
public BepuHitResult ShapeSweep(IConvexShape shape, Vector3 position, Xenko.Core.Mathematics.Quaternion rotation, Vector3 direction, float length, CollisionFilterGroupFlags hitGroups = DefaultFlags, bool skipAtZero = false)
public BepuHitResult ShapeSweep<TShape>(TShape shape, Vector3 position, Xenko.Core.Mathematics.Quaternion rotation, Vector3 direction, float length, CollisionFilterGroupFlags hitGroups = DefaultFlags, bool skipAtZero = false) where TShape : unmanaged, IConvexShape
{
SweepTestFirst sshh = new SweepTestFirst()
{
Expand Down Expand Up @@ -811,7 +811,7 @@ public BepuHitResult ShapeSweep(IConvexShape shape, Vector3 position, Xenko.Core
/// <param name="filterGroup">The collision group of this shape sweep</param>
/// <param name="filterFlags">The collision group that this shape sweep can collide with</param>
/// <exception cref="System.Exception">This kind of shape cannot be used for a ShapeSweep.</exception>
public void ShapeSweepPenetrating(IConvexShape shape, Vector3 position, Xenko.Core.Mathematics.Quaternion rotation, Vector3 endpoint, List<BepuHitResult> output, CollisionFilterGroupFlags hitGroups = DefaultFlags)
public void ShapeSweepPenetrating<TShape>(TShape shape, Vector3 position, Xenko.Core.Mathematics.Quaternion rotation, Vector3 endpoint, List<BepuHitResult> output, CollisionFilterGroupFlags hitGroups = DefaultFlags) where TShape : unmanaged, IConvexShape
{
Vector3 diff = endpoint - position;
float length = diff.Length();
Expand All @@ -832,7 +832,7 @@ public void ShapeSweepPenetrating(IConvexShape shape, Vector3 position, Xenko.Co
/// <param name="filterGroup">The collision group of this shape sweep</param>
/// <param name="filterFlags">The collision group that this shape sweep can collide with</param>
/// <exception cref="System.Exception">This kind of shape cannot be used for a ShapeSweep.</exception>
public void ShapeSweepPenetrating(IConvexShape shape, Vector3 position, Xenko.Core.Mathematics.Quaternion rotation, Vector3 direction, float length, List<BepuHitResult> output, CollisionFilterGroupFlags hitGroups = DefaultFlags)
public void ShapeSweepPenetrating<TShape>(TShape shape, Vector3 position, Xenko.Core.Mathematics.Quaternion rotation, Vector3 direction, float length, List<BepuHitResult> output, CollisionFilterGroupFlags hitGroups = DefaultFlags) where TShape : unmanaged, IConvexShape
{
SweepTestAll sshh = new SweepTestAll()
{
Expand Down

0 comments on commit dd104b0

Please sign in to comment.