Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BoxColliderShape by creating Box2D shape when is2D #1708

Merged
merged 3 commits into from
Jul 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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