Skip to content

feat: add 2D physics subsystem with rapier2d - #18

Merged
mkh-user merged 1 commit into
mainfrom
feat/physics
Nov 2, 2026
Merged

mkh-user merged 1 commit into
mainfrom
feat/physics

Conversation

@mkh-user

@mkh-user mkh-user commented Nov 2, 2026

Copy link
Copy Markdown
Member

Description

This PR implements a pure-Rust 2D physics subsystem in Pite powered by rapier2d 0.23 (matching workspace MSRV 1.85), covering all roadmap phases:

Phase 1: Core Physics & Nodes

  • Added internal crate pite-physics with PhysicsWorld, BodyKind, and ShapeConfig (Box, Circle, Capsule).
  • Registered new node types in pite-core: StaticBody2D, CharacterBody2D, RigidBody2D, Area2D, CollisionShape2D.
  • Integrated a fixed 60 Hz simulation loop into GameSession (FIXED_STEP = 1.0 / 60.0), dispatching _physics_process(delta) across active scripts.

Phase 2: CharacterBody2D & Area2D Triggers

  • Implemented kinematic character controller with move_and_slide(), sliding collision resolution (ignoring sensor areas), and surface normal floor/wall/ceiling detection.
  • Added Python script bindings on CharacterBody2D (move_and_slide, is_on_floor, is_on_wall, is_on_ceiling, velocity, up_direction).
  • Configured Area2D overlap detection with ActiveCollisionTypes::all() and wired built-in signals (body_entered, body_exited, area_entered, area_exited).

Phase 3: RigidBody2D Dynamics & Spatial Raycasts

  • Implemented dynamic rigid body simulation with mass, forces, impulses, gravity scale, and lock rotation.
  • Added pite.raycast(from, to, mask) query returning hit point, normal, distance, collider node id, and body node id.

Phase 4: Editor Tooling & Overlays

  • Viewport wireframe overlay rendering in pite-editor for box, circle, and capsule collision shapes when not playing.
  • Inspector support with shape combo dropdown (box, circle, capsule) and quick property initializer buttons.
  • Default properties for physics nodes populated on creation in ops::add_node.

Verification

  • cargo fmt --all -- --check
  • cargo build --workspace --locked
  • cargo test --workspace --locked (all crates passing, including new end-to-end physics tests)
  • cargo run --locked -p pite-cli -- check

- add crate pite-physics implementing 2D physics via pure-Rust rapier2d
- support StaticBody2D, CharacterBody2D, RigidBody2D, Area2D, CollisionShape2D
- kinematic character controller with move_and_slide(), floor/wall/ceiling detection
- dynamic rigid body simulation with forces, impulses, gravity scaling, mass
- Area2D trigger zones with body_entered/exited and area_entered/exited signals
- pite.raycast spatial queries returning intersection point, normal, distance, collider
- fixed 60 Hz physics loop in GameSession with _physics_process dispatch
- editor viewport wireframe overlays for box, circle, capsule shapes and inspector support
- comprehensive unit and integration test coverage
@mkh-user mkh-user self-assigned this Nov 2, 2026
@mkh-user
mkh-user merged commit 2367700 into main Nov 2, 2026
6 checks passed
@mkh-user
mkh-user deleted the feat/physics branch November 2, 2026 12:00
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