feat: Unity-like object manipulation + physics fixes

- ObjectManipulator: left-click to pick, drag on camera-orthogonal plane
- Screen-space movement (like Unity), not ground-plane
- Skip dragged entity in SyncTransforms so physics doesn't fight drag
- Zero velocity on grab to prevent momentum accumulation
- ImGui selection sync with manipulator
- Floor lowered to y=-0.5, visual thickness corrected
- Physics shape sizes fixed (BoxShape uses half-extents)
- Collision pairs explicitly enabled in ObjectLayerPairFilterTable
This commit is contained in:
emil28092005
2026-06-17 17:59:32 +03:00
parent a9d8af48e5
commit de262732bd
4 changed files with 207 additions and 2 deletions
+6 -1
View File
@@ -121,7 +121,7 @@ public sealed class PhysicsWorld : IDisposable
_physicsSystem.Update(deltaTime, collisionSteps, _jobSystem);
}
public void SyncTransforms(World world)
public void SyncTransforms(World world, Entity? skipEntity = null)
{
// Collect updates first to avoid calling entity.Set() during dictionary iteration
var updates = new List<(Entity entity, Vector3 pos, Quaternion rot)>();
@@ -130,6 +130,9 @@ public sealed class PhysicsWorld : IDisposable
if ((ulong)entity.Id == 0)
continue;
if (skipEntity.HasValue && skipEntity.Value.Id == entity.Id)
continue;
var pos = _bodyInterface.GetPosition(bodyId);
var rot = _bodyInterface.GetRotation(bodyId);
updates.Add((entity, pos, rot));
@@ -154,6 +157,8 @@ public sealed class PhysicsWorld : IDisposable
return;
_bodyInterface.SetPositionAndRotation(bodyId, transform.Position, transform.Rotation, Activation.Activate);
// Zero out velocity so the object doesn't accumulate momentum while being dragged
_bodyInterface.SetLinearAndAngularVelocity(bodyId, Vector3.Zero, Vector3.Zero);
}
private static Shape CreateShape(RigidBody rb)