Skip to content

fix(physics-physx): preserve collision events across shape replacement(生产代码 +87/-2) - #3313

Draft
luzhuang wants to merge 2 commits into
feat/unity-physics-componentsfrom
feat/physx-shape-contact-continuity
Draft

luzhuang wants to merge 2 commits into
feat/unity-physics-componentsfrom
feat/physx-shape-contact-continuity

Conversation

@luzhuang

@luzhuang luzhuang commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

保持同一个 Collider 原位替换 PhysX 形状时的实体碰撞事件连续。

本 PR 基于 #3195。从其原实现中拆出接触状态和两项专项回归,几何替换和 Trigger 派发由 #3195 提供。

可观察行为

  • 创建半径 0.5、总高 4 的静态胶囊,让动态盒子碰到其顶部,再把 capsule.height 设为 1 并推进一个物理步。主分支直接转发原生事件,旧接触缺少退出通知。应用本 PR 后,盒子与缩成的球分离时会收到一次 onCollisionExit。
  • 让动态盒子接触凸网格,再把静态 MeshCollider.convex 设为 false,保持盒子的位置。主分支会再次派发 onCollisionEnter。应用本 PR 后仍相接的 Collider 收到 onCollisionStay。后续分离时正常退出。

实现

  • PhysX 适配层按 Collider ID 记录活跃接触。原位换形时,仅将受影响的旧接触放入待确认集合。重新报告的 Begin 延续为 Stay,原生 End 直接结束该对,步进后仍待确认的旧接触补发一次 Exit。
  • 停用或移除 Collider 会清理对应接触,即使与另一端换形发生在同一物理步。

验证

@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@luzhuang luzhuang changed the title fix(physics-physx): preserve collision events across shape replacement(生产代码 +86/-7) fix(physics-physx): preserve collision events across shape replacement(生产代码 +87/-2) Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant