Physics: contact enter/exit hysteresis around the 1 cm contact offset

オープン
#323 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
csharp
領域
game-dev

調査の方向性

Start in BepuEventSink (org.mass4.turian.physics.bepu) where solid contacts are reported, and read PhysicsSettings for configuration. Run the Example 12 box rain bench (headless Release) to measure exit rate, and review WakingASleepingBody_KeepsItsRestingContacts test. Done means a jittering pair gives one Enter and no Exit, exits per second fall well below tracked contacts, and new tests pass.

索引モデルが issue の本文から書いたものです。

説明

c:engine p:medium size:S t:enhancement

Current State

The Bepu backend (org.mass4.turian.physics.bepu, BepuEventSink) reports a solid contact once the deepest manifold point is within Unity's default 1 cm contact offset, and reports an exit on the first step a tracked pair is tested without reaching it. There is no hysteresis, so pairs whose separation hovers around -1 cm alternate Enter and Exit every few steps.

Measured in Example 12's box rain (headless, Release, 2026-10-24): about 12,000 exits per second against about 6,000 tracked contacts at 6k boxes. Every exit was between two awake bodies, so they come from this boundary flicker rather than sleeping or waking. That rate makes OnCollisionEnter/OnCollisionExit unusable for gameplay wiring such as damage, sounds or "is grounded" state.

Tasks

  • Choose the policy: an exit grace period (keep a pair touching for N steps or T seconds after it was last found within the offset) or a dual threshold (enter within 1 cm, exit only beyond a larger distance, for example 2–3 cm). Compare against Unity/PhysX contact persistence where documented.
  • Implement it in BepuEventSink for solid contacts; decide whether triggers need the same treatment (they use depth ≥ 0 today).
  • Keep the contact points and impulse of a pair held through the grace period consistent (last real manifold or none).
  • Make the threshold or grace configurable through PhysicsSettings if the choice is not obvious.
  • Add tests: a box resting on the ground with tiny vertical jitter gets one enter and no exit; a box lifted clearly away still exits within the configured bound.
  • Re-measure the rain bench's exit rate; update the physics README and changelog.

Acceptance Criteria

  • A resting or gently jittering pair produces a single Enter, Stays, and no spurious Exit.
  • Real separations still exit within the configured grace period or distance.
  • In the 6k-box rain bench, exits per second fall well below the tracked-contact count (target: an order of magnitude fewer than today).
  • Island sleep/wake keeps resting contacts without exits, as covered by WakingASleepingBody_KeepsItsRestingContacts.

Related

  • #64 (physics backend, rigid bodies and collision)
主要言語
C#
スター
1
フォーク
1
平均マージ
2時間 4分
マージ済み PR(30日)
29

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

MASS4ORG/Turian のほかの issue

MASS4ORG/Turian の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。