Skip to content
This repository was archived by the owner on Mar 19, 2026. It is now read-only.

v0.11 剛体力学の実装#81

Merged
HMasataka merged 14 commits into
mainfrom
feature/v0.11-rigid-body-dynamics
Mar 7, 2026
Merged

v0.11 剛体力学の実装#81
HMasataka merged 14 commits into
mainfrom
feature/v0.11-rigid-body-dynamics

Conversation

@HMasataka
Copy link
Copy Markdown
Owner

概要

roadmap.md v0.11「剛体力学」の全4項目を実装。オブジェクトが物理法則に従って衝突・反発・落下・積み重なり、高速移動体もすり抜けない。

変更内容

PGS拘束ソルバー

  • ContactConstraint構造体 (法線・接線インパルス蓄積)
  • PgsSolver (8イテレーション Sequential Impulse, Baumgarte安定化, 摩擦)
  • ConstraintSolverSystem (ECS統合: NarrowPhaseResult→拘束構築→ソルバー→速度書き戻し+位置補正)

リジッドボディ

  • RigidBodyコンポーネント (Mass, InverseMass, LinearDamping, AngularDamping, GravityScale, IsKinematic)
  • Velocityコンポーネント (Linear, Angular)
  • ForceIntegrationSystem (重力・減衰→速度)
  • IntegrationSystem (速度→位置/回転)

ConvexHullコリジョン

  • ConvexHullShape (64頂点固定バッファ, unsafe)
  • GJK/EPAサポート関数拡張
  • レイキャスト対応

CCD

  • CcdSweep (保守的アドバンスメント + 二分探索TOI)
  • CcdSystem (ECS統合)

その他

  • EPA接触法線の方向修正
  • 物理パイプライン分割 (ForceIntegration / Integration)
  • PGSソルバーのポイントマス近似修正 (慣性テンソル未実装下での安定化)

テスト

  • 全688テストパス、ビルド警告0件
  • 新規テスト: RigidBody(5), Integrator(10+), PgsSolver(7), ConvexHull(10+), CCD(9), GjkEpa非対称(7), パイプライン統合(6)

動作確認

  • dotnet build 成功
  • dotnet test 全688テストパス
  • 動的キューブが大型プラットフォーム上で停止することを確認
  • 同サイズボックス同士の衝突も確認

🤖 Generated with Claude Code

HMasataka and others added 14 commits March 7, 2026 11:32
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Vulkan NDCは+Y=画面下のため、射影行列のM22を負にする必要がある。
FrontFace.Clockwiseは既にY-flip前提で設定済みだった。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3つ目のキューブにRigidBody・Velocityコンポーネントを付与し、
IntegrationSystemを登録して重力落下を確認できるようにした。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
全キューブにColliderComponent(Box)を付与し、物理シングルトン
エンティティ(BroadPhaseResult/NarrowPhaseResult/ConstraintSolverResult)を
作成。静的キューブを落下キューブの直下に配置し衝突・反発を確認可能に。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
IntegrationSystemから重力・減衰の適用を分離し、
ForceIntegrationSystem (力→速度) と IntegrationSystem (速度→位置) に分割。
ConstraintSolver前後で正しいセミインプリシットオイラー積分順序を実現。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
BroadPhase/NarrowPhase/ConstraintSolverの各システムに
全コンポーネント依存を含むスケジューリングクエリを追加。
SystemSchedulerのバッチ構築で正しい実行順序を保証。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
EPAの面法線はMinkowski差分ポリトープの外向きだが、
ContactPointの規約 (BからAへ向く) とは逆方向だった。
法線が反転していたためソルバーが分離中と誤判定し、
衝突応答が効かず物体が貫通していた。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
慣性テンソル未実装下でソルバーが正しく動作するよう修正:
- ComputeEffectiveMass: 角速度項を除去
- ComputeRelativeVelocity: 線速度のみ使用
- ApplyImpulse: 角速度変更を除去
- ConstraintSolverSystemに直接位置補正を追加
- DefaultRestitution: 0.3→0.0 (ポイントマス近似との整合性)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
GjkEpaTests: 小ボックスが大プラットフォームに衝突するケース7件
PhysicsPipelineTests: BroadPhase→NarrowPhase→Solver→Integrationの
エンドツーエンドテスト6件 (落下・停止・衝突検出・ソルバー単体)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CreateCubeEntityにhalfExtentsパラメータ追加、
下部キューブを大型プラットフォーム(2x0.5x2)に変更

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@HMasataka HMasataka merged commit a4806cf into main Mar 7, 2026
3 checks passed
@HMasataka HMasataka deleted the feature/v0.11-rigid-body-dynamics branch March 7, 2026 05:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant