MMD rigid-body physics (Bullet) #6

Merged
dev merged 2 commits from devin/1795875194-physics into main 2026-11-28 09:35:45 -05:00
Owner

Adds MMD rigid-body physics (hair, skirts, tails) using Bullet 3.25 (FetchContent; only BulletDynamics, BulletCollision, LinearMath).

  • Loading: PMX display frames are now skipped properly and rigid bodies + joints parsed; PMD rigid bodies/joints parsed after the toon names (PMD body positions are bone-relative). New RigidBody/Joint in Model.h; setRigidBodyFromMmd/setJointFromMmd convert MMD's left-handed Euler angles and joint limits.
  • Simulation (src/physics/PhysicsWorld, part of mr_core so the vtuber fork gets it): mode 0 bodies are kinematic and follow their bone; mode 1 drive their bone; mode 2 drive rotation but stay pinned to the bone position. btGeneric6DofSpringConstraint joints with springs, collision groups/masks, gravity 98 (MMD units), fixed 1/120 s substeps.
  • Poser: after animation/IK, PhysicsWorld::apply overwrites driven bones and non-simulated descendants are recomputed. resetPhysics() snaps bodies to the pose and settles 0.5 s; stepPhysics(dt) queues time.
  • App: steps by real time while editing/playing, exactly 1/30 s per frame during renders; timeline jumps over 2 frames reset physics. Scene panel and View menu toggles, Reset physics, --physics on|off.
  • Test: testPhysics swings a hinged capsule down under gravity and checks it stays attached.

Not yet: collision-shape debug overlay, afterPhysics bone ordering, PMX 2.1 soft bodies.

Adds MMD rigid-body physics (hair, skirts, tails) using Bullet 3.25 (FetchContent; only `BulletDynamics`, `BulletCollision`, `LinearMath`). - **Loading**: PMX display frames are now skipped properly and rigid bodies + joints parsed; PMD rigid bodies/joints parsed after the toon names (PMD body positions are bone-relative). New `RigidBody`/`Joint` in `Model.h`; `setRigidBodyFromMmd`/`setJointFromMmd` convert MMD's left-handed Euler angles and joint limits. - **Simulation** (`src/physics/PhysicsWorld`, part of `mr_core` so the vtuber fork gets it): mode 0 bodies are kinematic and follow their bone; mode 1 drive their bone; mode 2 drive rotation but stay pinned to the bone position. `btGeneric6DofSpringConstraint` joints with springs, collision groups/masks, gravity 98 (MMD units), fixed 1/120 s substeps. - **Poser**: after animation/IK, `PhysicsWorld::apply` overwrites driven bones and non-simulated descendants are recomputed. `resetPhysics()` snaps bodies to the pose and settles 0.5 s; `stepPhysics(dt)` queues time. - **App**: steps by real time while editing/playing, exactly 1/30 s per frame during renders; timeline jumps over 2 frames reset physics. Scene panel and View menu toggles, Reset physics, `--physics on|off`. - **Test**: `testPhysics` swings a hinged capsule down under gravity and checks it stays attached. Not yet: collision-shape debug overlay, `afterPhysics` bone ordering, PMX 2.1 soft bodies.
dev added 2 commits 2026-11-28 09:16:36 -05:00
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
dev merged commit 935203f11a into main 2026-11-28 09:35:45 -05:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dev/3d-model-renderer#6