修复physics物理数据计算不正确的问题,同时为物理添加map索引

This commit is contained in:
2026-10-04 18:42:23 +08:00
parent ee5ab8e94e
commit c8a1cd90bf
3 changed files with 26 additions and 21 deletions
@@ -183,6 +183,11 @@ namespace Engine {
std::unordered_map<u32, BodyRecord> m_Bodies; // entity 位模式 → body
// BodyID 序号 → entity 位模式(O(1) 反查;ContactListener 回调用)
// 与 m_Bodies 同生共死:CreateBody 同插,RemoveBody/孤儿清理同 erase。
// 主线程在 SyncScene 写、Step 内 Update 阶段不写 → 回调线程只读,无需加锁
std::unordered_map<u32, u32> m_BodyToEntity;
// ---- 碰撞事件收集(多线程回调入队,主线程消费)----
class ContactListenerImpl; // cpp 定义(JPH::ContactListener 派生)
Scope<ContactListenerImpl> m_ContactListener;