Skip to content

feat(physics): implement Physics2D system (RF4.10)#60

Merged
LyeZinho merged 6 commits intomainfrom
33-physics-2d
May 8, 2026
Merged

feat(physics): implement Physics2D system (RF4.10)#60
LyeZinho merged 6 commits intomainfrom
33-physics-2d

Conversation

@LyeZinho
Copy link
Copy Markdown
Member

@LyeZinho LyeZinho commented May 8, 2026

Summary

  • PhysicsComponents2D: RigidBody2D, Collider2D (AABB/Circle), PhysicsMaterial presets (ice, rubber, metal, wood, stone)
  • PhysicsSystem2D: full simulation loop with spatial grid broad phase, AABB/Circle/mixed narrow phase, impulse resolution + Baumgarte positional correction
  • Thread-safe applyForce/applyImpulse (mutex-protected)
  • Sleep system (bodies with near-zero velocity stop being simulated)
  • One-way platforms, trigger zones (OnTrigger2D event)
  • Raycast + overlapCircle + overlapAABB spatial queries
  • OnCollision2D + OnTrigger2D events via EventBus
  • 2 physics sub-steps per frame for stability

Changes

  • src/physics/PhysicsComponents2D.hpp — component types
  • src/physics/PhysicsSystem2D.hpp — full header-only system (~745 lines)
  • tests/test_physics2d.cpp — 26 tests covering all features
  • tests/CMakeLists.txt — added test_physics2d.cpp
  • src/Caffeine.hpp — added physics includes
  • docs/fase4/physics.md — status ✅, API reference updated
  • docs/fase4/README.md — status ✅

Closes #33

- PhysicsComponents2D: RigidBody2D, Collider2D (AABB/Circle), PhysicsMaterial presets
- PhysicsSystem2D: semi-implicit Euler, spatial grid broad phase, AABB/Circle/mixed narrow phase
- Impulse-based resolution with Baumgarte positional correction
- Sleep system, one-way platforms, trigger zones
- Thread-safe applyForce/applyImpulse (mutex-protected)
- Raycast + overlapCircle + overlapAABB spatial queries
- OnCollision2D + OnTrigger2D events via EventBus
- 2 physics sub-steps per frame for stability
- 26 tests covering all major features
@LyeZinho LyeZinho linked an issue May 8, 2026 that may be closed by this pull request
5 tasks
@LyeZinho LyeZinho merged commit a97fb1f into main May 8, 2026
1 check passed
@LyeZinho LyeZinho deleted the 33-physics-2d branch May 8, 2026 14:11
@LyeZinho LyeZinho restored the 33-physics-2d branch May 8, 2026 14:11
@LyeZinho LyeZinho deleted the 33-physics-2d branch May 8, 2026 14:11
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.

Physics 2D

1 participant