From a9d8af48e5b225f731844685fcb3c172ce0bb514 Mon Sep 17 00:00:00 2001 From: emil28092005 Date: Wed, 17 Jun 2026 17:31:17 +0300 Subject: [PATCH] fix: enable collision pairs, correct physics shape sizes, lower floor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ObjectLayerPairFilterTable blocks all collisions by default in C# binding; explicitly EnableCollision for all layer pairs (NonMoving/Moving) - BoxShape takes half-extents, not full size: DynamicBox(scale * 0.5f) - Floor visual thickness reduced (scale Y 1→0.5), top at y=0 matching collider - Floor lowered to y=-0.5 - Physics works: cubes and spheres fall and land on floor, no clipping --- src/CortexEngine.App/Program.cs | 4 ++-- src/Engine.Physics/PhysicsWorld.cs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/CortexEngine.App/Program.cs b/src/CortexEngine.App/Program.cs index 9edf2c8..6222143 100644 --- a/src/CortexEngine.App/Program.cs +++ b/src/CortexEngine.App/Program.cs @@ -322,7 +322,7 @@ class Program .Set(new Transform(pos, Quaternion.Identity, new Vector3(scale))) .Set(mesh) .Set(new Material(color, roughness: rough, metallic: metal)) - .Set(RigidBody.DynamicBox(new Vector3(scale), mass: scale * 2f)); + .Set(RigidBody.DynamicBox(new Vector3(scale * 0.5f), mass: scale * 2f)); } var spheres = new (string name, Vector3 pos, Vector3 color, float scale, float rough, float metal)[] @@ -352,7 +352,7 @@ class Program .Set(new Material(new Vector3(0.8f, 0.8f, 0.85f), roughness: 0.4f, metallic: 0.0f, texturePath: "Content/checker.png")); world.Entity("Floor") - .Set(new Transform(new Vector3(0, -0.02f, 0), Quaternion.Identity, new Vector3(20, 1, 20))) + .Set(new Transform(new Vector3(0, -0.5f, 0), Quaternion.Identity, new Vector3(20, 0.5f, 20))) .Set(mesh) .Set(new Material(new Vector3(0.45f, 0.45f, 0.5f), roughness: 0.8f, metallic: 0.0f)) .Set(RigidBody.StaticPlane(20f)); diff --git a/src/Engine.Physics/PhysicsWorld.cs b/src/Engine.Physics/PhysicsWorld.cs index f9edb2f..35c3347 100644 --- a/src/Engine.Physics/PhysicsWorld.cs +++ b/src/Engine.Physics/PhysicsWorld.cs @@ -46,6 +46,11 @@ public sealed class PhysicsWorld : IDisposable _broadPhaseLayerInterface.MapObjectToBroadPhaseLayer(Layers.Moving, new BroadPhaseLayer(1)); _objectLayerPairFilter = new ObjectLayerPairFilterTable(2); + // Explicitly enable all collision pairs + _objectLayerPairFilter.EnableCollision(Layers.NonMoving, Layers.NonMoving); + _objectLayerPairFilter.EnableCollision(Layers.NonMoving, Layers.Moving); + _objectLayerPairFilter.EnableCollision(Layers.Moving, Layers.NonMoving); + _objectLayerPairFilter.EnableCollision(Layers.Moving, Layers.Moving); _objectVsBroadPhaseLayerFilter = new ObjectVsBroadPhaseLayerFilterTable( _broadPhaseLayerInterface, 2, _objectLayerPairFilter, 2);