diff --git a/packages/dev/core/src/Collisions/collider.ts b/packages/dev/core/src/Collisions/collider.ts index c3fb895a1b4..617a07a1b61 100644 --- a/packages/dev/core/src/Collisions/collider.ts +++ b/packages/dev/core/src/Collisions/collider.ts @@ -85,6 +85,11 @@ export class Collider { */ public collidedMesh: Nullable; + /** + * If true, it check for double sided faces and only returns 1 collision instead of 2 + */ + public static DoubleSidedCheck = false; + private _collisionPoint = Vector3.Zero(); private _planeIntersectionPoint = Vector3.Zero(); private _tempVector = Vector3.Zero(); @@ -248,6 +253,12 @@ export class Collider { const signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint); const normalDotVelocity = Vector3.Dot(trianglePlane.normal, this._velocity); + // if DoubleSidedCheck is false(default), a double sided face will be consided 2 times. + // if true, it discard the faces having normal not facing velocity + if (Collider.DoubleSidedCheck && normalDotVelocity > 0.0001) { + return; + } + if (normalDotVelocity == 0) { if (Math.abs(signedDistToTrianglePlane) >= 1.0) { return;