A cube falls onto a plane: the box3d Plugin, Rigidbody and Box_Collider lifecycle, and the fixed step (#71) #103
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
crowmaki/cinnabar!103
Loading…
Reference in a new issue
No description provided.
Delete branch "issue-71-box3d-plugin"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #71. Part of #67.
What
plugins/box3d/is thebox3dPlugin. It publishescinnabar.physics/1withfixed_deltaandbody_count, registers theRigidbodyandBox_ColliderSchemas inregister, creates the Box3D world ininitand destroys it inshutdown.Rigidbody.on_addbuilds a dynamic body at the owner's World Transform with the Component Handle as the Body User Tag, sets Wants Destroy on itself when the owner already has aRigidbody, and takes over the Implicit Static Body the owner's colliders hung from.Box_Collider.on_addbuilds a box hull on the owner's body or on an Implicit Static Body shared by every collider on that GameObject and destroyed with the last. Bothon_removehooks destroy what they own and skip what a body's destruction already took.fixed_updatesteps the world with four substeps and writes rotation and translation back throughgameobject_set_world_transform, keeping the scale the transform had. No interpolation.packagesentry, a glossary sentence on Implicit Static Body, and a dated note on ADR-0016.Tests
tests/core/box3d_plugin_test.odin, all Headless: the falling cube rests on the plane; a collider-only plane never moves; removing aRigidbodyor destroying its GameObject lowersbody_countby one at the flush while the other cube keeps falling; a secondRigidbodyhas Wants Destroy set and is gone at the flush; a collider added before itsRigidbodymigrates onto the real body; a scaled GameObject keeps its scale; the Interface reports the fixed delta; two Engines produce bit-identical World Transforms.Deviations from the issue wording
on_addruns after a Scene document's authored values land, so unconditional defaults would clobber every loaded half extent. Consequence: a document cannot authorgravity_scale 0yet.body_typeis always Dynamic, since its zero value is Static; kinematic and static Rigidbodies are follow-up work.Rigidbodyleaves its owner's colliders shapeless rather than re-hanging them on an Implicit Static Body, because the criterion requiresbody_countto drop by one.Verification
just checkpasses. Core suite 360 tests, platform, vulkan_backend, imgui and luau suites all pass. Two shaderc tests fail onmaintoo (locally stale committed shader output); unrelated.