Repository navigation
One World OW9b: people float like people (avatar density, body displacement) - #1578
Merged
Merged
Conversation
avatar_body::density (985 kg/m^3, the rules' body: { density: }, published
with the archetypes) sets the share of an avatar's box that displaces water:
mass over density over the box's volume, 0.167 for the default person, so a
person floats head-out (98.5% under) instead of like a cork.
The share is physics::body_desc::displacement and world::set_displacement,
for any dynamic body without a hull; it scales the cells' buoyancy and the
water's damping on them. A vehicle's chassis keeps its wading's share and the
whole damping. Every body defaults to 1, so nothing else changes.
Tests: holon_test APersonFloatsHeadOut, physics_field_test
ADisplacementShareFloatsABodyDeeper, world_rules_test's density key; OW9a's
lake test floats at -1.67 m with no correction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OW9b of the swimming design (docs/roadmap/ARIADNE_WORLDS.md §18.10): people float like people, head-out, instead of like a cork.
The problem
An avatar is a 70 kg box of 0.425 m³, about 165 kg/m³. In water it displaced the whole box and floated with only 0.28 m of its 1.7 m under.
The change
avatar_body::density(kg/m³, default 985, a person's). In the rules it isbody: { density: }; it is checked to be positive and published with the archetypes. The stock worlds and the docs state it.avatar_displacement(body, mass): mass ÷ density ÷ the box's volume, which is 0.167 for the default person. Each dynamic avatar's box gets it when the box is made, and again whenset_masschanges the mass. Contact and prediction still use the box.field_set::mark_avatar. It isphysics::body_desc::displacementandworld::set_displacementinstead, so any dynamic body without a hull can use it.set_displacementvalidates the share and wakes the body.Tests
holon_testHolonPhysicsTest.APersonFloatsHeadOut, 30 s in a still lake:set_mass)physics_field_testADisplacementShareFloatsABodyDeeper: a slab displacing half its volume floats twice as deep. It floats at its own draft again afterset_displacement(1), which wakes it. Bad shares and unknown bodies are refused.world_rules_test:density:is parsed, defaults to 985, a zero is refused, and the room's archetype section round-trips it.All of these pass locally on Windows (Release, Jolt, gRPC, WS):
Not yet