fix: enable collision pairs, correct physics shape sizes, lower floor
- 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
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user