Skip to content

Commit

Permalink
[Physics] Fix inconsistent box2D collision, see stride3d#1707 and str…
Browse files Browse the repository at this point in the history
  • Loading branch information
Eideren committed Jan 3, 2024
1 parent 1b72c89 commit 934046e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sources/engine/Stride.Physics/Shapes/BoxColliderShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public BoxColliderShape(bool is2D, Vector3 size)

if (is2D) size.Z = 0.001f;

// Note: Creating Convex 2D Shape from (3D) BoxShape, causes weird behaviour,
// better to instantiate Box2DShape directly (see issue #1707)
if (Is2D)
{
InternalShape = new BulletSharp.Box2DShape(size / 2) { LocalScaling = cachedScaling };
// Note that encapsulating a 2D Box goes against bullet's 2D collision example.
// This was found through trial and error as the most stable solution, see issue #1707 and #2019
InternalShape = new BulletSharp.Convex2DShape(new BulletSharp.Box2DShape(size / 2) { LocalScaling = Vector3.One }) { LocalScaling = cachedScaling };
}
else
{
Expand Down

0 comments on commit 934046e

Please sign in to comment.