Skip to content

Commit

Permalink
Fix edge case collision behavior with BoxColliderShape by creating Bo…
Browse files Browse the repository at this point in the history
…x2D shape when is2D (stride3d#1708)
  • Loading branch information
Jklawreszuk authored Jul 8, 2023
1 parent 5b99d71 commit 9d6d379
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions sources/engine/Stride.Physics/Shapes/BoxColliderShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@ public BoxColliderShape(bool is2D, Vector3 size)

if (is2D) size.Z = 0.001f;

var shape = new BulletSharp.BoxShape(size / 2)
{
LocalScaling = cachedScaling,
};

// Note: Creating Convex 2D Shape from (3D) BoxShape, causes weird behaviour,
// better to instantiate Box2DShape directly (see issue #1707)
if (Is2D)
{
InternalShape = new BulletSharp.Convex2DShape(shape) { LocalScaling = cachedScaling };
InternalShape = new BulletSharp.Box2DShape(size / 2) { LocalScaling = cachedScaling };
}
else
{
InternalShape = shape;
InternalShape = new BulletSharp.BoxShape(size / 2) { LocalScaling = cachedScaling };
}

DebugPrimitiveMatrix = Matrix.Scaling(size * DebugScaling);
Expand Down

0 comments on commit 9d6d379

Please sign in to comment.