A cube falls onto a plane: the box3d Plugin, Rigidbody and Box_Collider lifecycle, and the fixed step #71

Closed
opened 2026-09-05 09:36:49 +00:00 by crowmaki · 0 comments
Owner

Parent

Part of #67.

What to build

A GameObject with a Rigidbody and a Box_Collider falls onto a GameObject with only a Box_Collider, and comes to rest, with no Backend or Platform listed. The box3d Plugin publishes cinnabar.physics/1, registers both Schemas in register, creates the world in init, and destroys it in shutdown.

Lifecycle: on_add of Rigidbody sets defaults (Dynamic, gravity scale 1), creates the body at the owner's World Transform rotation and translation, stores the Component Handle as the body user tag, and sets Wants Destroy on itself if the owner already has a Rigidbody. on_add of Box_Collider sets defaults (half extents 0.5, density 1), translates the extents into a Box3D box hull, and attaches it to the owner's body, or to an Implicit Static Body the Plugin creates for a GameObject with no Rigidbody, shared by every collider on it and destroyed with the last. on_remove destroys what the Component owns without double-freeing what a body's destruction already took.

Step: fixed_update steps the world by the fixed delta with a fixed substep count, then walks the dynamic Rigidbodys through Core's dense slice and parallel owner array and writes each body's rotation and translation back with gameobject_set_world_transform, composed with the scale the World Transform already had. No interpolation. Static bodies are set once.

Interface: fixed_delta and body_count are implemented; the rest may report no hit or zero for now and are filled in by the follow-up tickets.

Acceptance criteria

  • A dynamic cube above a static collider plane has a lower Y after one second of fixed steps and, after several seconds, a Y that stops changing and sits between its half extent and its circumscribed radius above the plane.
  • A collider-only GameObject's World Transform is unchanged across many fixed steps.
  • Removing a Rigidbody, or destroying its GameObject, lowers body_count by one after the flush and the remaining bodies keep simulating.
  • A second Rigidbody on one GameObject has Wants Destroy set and is gone at the flush; the first survives.
  • A scaled GameObject keeps its scale after write-back.
  • Two Engines with the same Plugin list and scripted Scene produce bit-identical World Transforms after the same fixed-step sequence.
  • Every test runs Headless in the core suite.

Blocked by

  • #68 Vendor Box3D and build it into .tools/
  • #69 Core declares the physics role
## Parent Part of #67. ## What to build A GameObject with a `Rigidbody` and a `Box_Collider` falls onto a GameObject with only a `Box_Collider`, and comes to rest, with no Backend or Platform listed. The `box3d` Plugin publishes `cinnabar.physics/1`, registers both Schemas in `register`, creates the world in `init`, and destroys it in `shutdown`. Lifecycle: `on_add` of `Rigidbody` sets defaults (Dynamic, gravity scale 1), creates the body at the owner's World Transform rotation and translation, stores the Component Handle as the body user tag, and sets Wants Destroy on itself if the owner already has a `Rigidbody`. `on_add` of `Box_Collider` sets defaults (half extents 0.5, density 1), translates the extents into a Box3D box hull, and attaches it to the owner's body, or to an Implicit Static Body the Plugin creates for a GameObject with no `Rigidbody`, shared by every collider on it and destroyed with the last. `on_remove` destroys what the Component owns without double-freeing what a body's destruction already took. Step: `fixed_update` steps the world by the fixed delta with a fixed substep count, then walks the dynamic `Rigidbody`s through Core's dense slice and parallel owner array and writes each body's rotation and translation back with `gameobject_set_world_transform`, composed with the scale the World Transform already had. No interpolation. Static bodies are set once. Interface: `fixed_delta` and `body_count` are implemented; the rest may report no hit or zero for now and are filled in by the follow-up tickets. ## Acceptance criteria - [ ] A dynamic cube above a static collider plane has a lower Y after one second of fixed steps and, after several seconds, a Y that stops changing and sits between its half extent and its circumscribed radius above the plane. - [ ] A collider-only GameObject's World Transform is unchanged across many fixed steps. - [ ] Removing a `Rigidbody`, or destroying its GameObject, lowers `body_count` by one after the flush and the remaining bodies keep simulating. - [ ] A second `Rigidbody` on one GameObject has Wants Destroy set and is gone at the flush; the first survives. - [ ] A scaled GameObject keeps its scale after write-back. - [ ] Two Engines with the same Plugin list and scripted Scene produce bit-identical World Transforms after the same fixed-step sequence. - [ ] Every test runs Headless in the core suite. ## Blocked by - #68 Vendor Box3D and build it into .tools/ - #69 Core declares the physics role
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
crowmaki/cinnabar#71
No description provided.