Repository navigation
physics: forces and torques at a point (O10) - #1172
Merged
Merged
Conversation
world::add_force_at(id, force, point) applies a world-frame force at a world-frame point, so off the centre of mass it also torques the body; world::add_torque(id, torque) applies a world-frame torque. Both check that every value is finite and otherwise act as add_force does: through the next step only, waking a sleeping body, refusing an unknown id. New backend_impl calls carry them to Jolt (AddForce at a point, moved to the engine's floating-origin frame, and AddTorque) and to the null backend, which checks the id. pycvc binds both. Tests in physics_world_test check the spin against r x F dt / I, that a force at the centre of mass gives add_force's state hash, that a torque does not translate, that both wake a sleeping body, and the refusals. This is roadmap item D1 of OCEAN-AND-WEATHER-ROADMAP.md.
pycvc's add_force_at refuses a point of None instead of reading it as the world origin. world.h and PHYSICS_API.md say body_state::position is the body's origin, not its centre of mass, which differs for a hull or a vehicle chassis; a new test shows a force at a hull's origin torques it. ForceAtAndTorqueAreChecked now covers a kinematic body, and roadmap 1.2 marks off-centre forces done.
transfix
enabled auto-merge (squash)
November 12, 2026 08:27
#1159 (O7c) kept the last source sea_surface found in a thread_local, so the velocity a fluid field reads after a cell's height at the same point and time did not invert the sideways move again. A thread_local that keeps state between calls is a static cache, which libcvc's no-singletons rule forbids (VOLROVER-LIBRARY-PORTS-ROADMAP.md 1.3, tools/singleton_scan). #1159's release-grpc job, where the scan runs, was cancelled, so the scan never judged it; the next PR that merges master would fail that lane on it. The memo now belongs to the caller: - sea_surface::source_memo, and height() / velocity() overloads that take one. The plain reads share nothing. - fluid_surface::height_with / velocity_with and a surface_memo the caller owns; the defaults ignore it. ocean_surface passes it to the sea. - field_set::apply keeps one memo per cell, for the cell's height and its velocity at the same clipped centre. The memo is keyed on the point, the time and the digest as before, so every value is unchanged.
…ocal The writable-data scan (#1152 made its allowlist a ratchet) refuses process-wide state, and sea_surface::source kept its last source in a thread_local (O7c, #1159), so every PR's package-linux release-grpc lane now fails on master's code. The memo moves into the time's frame, under the mutex the frame already has for its lattice: a frame is the surface at one time, so the point alone is the key, and as a memo of a pure function it changes no value. ocean_sea_test (19, pins unchanged) and physics_field_test (22, goldens unchanged) pass; the exact height-and-velocity pair still costs about what it did (3.8 us, 1.76 us on the lattice).
Owner
Author
|
This branch carried #1193's fix for the sea's source memo, so the writable-data scan would pass. #1193 was closed as superseded by #1181, Joe's pick, so I swapped it:
Until #1181 merges, this PR's diff includes #1181's 10 files. Once #1181 lands they match master, and this PR merges with only its own changes. The other order is safe too: the branch now carries exactly #1181's code, so whichever merges first, the master that results was tested. Physics and ocean tests pass locally on Windows Release. |
transfix
added a commit
that referenced
this pull request
Nov 13, 2026
The one conflict was arigl_web_smoke.mjs. Both sides are kept: - the /apps/up endpoint, with #1200's ISOLATION headers on its replies as on every response; - the settle probe reads out and isolated/sab; - each case runs its before/inject and #1200's isolation check. The headless-Chrome smoke passes 6/6 here, the picked-file upload included. Master since then: #1179, #1174, #1196, #1198, #1178, #1157, #1172, #1200.
transfix
added a commit
that referenced
this pull request
Nov 13, 2026
…erf/threaded-s1b #925 starts ws-open's connect and ws-recv's wait where the transport does not block (the browser without threads), and their callbacks settle the call. Its start paths kept the async_host by reference and posted through it; here they take the host's finisher (host.make_finisher()) and settle_started through it, as http_work and uri_fetch_work do: the callbacks answer later, and an isolated document's group's host may be gone by then. - net_intrinsics.cpp: the conflict kept this branch's providers by kind; have_ws takes master's NetAccess::ws. The any provider's comment says a host's own WebSocket transport must be as thread-safe as the compiled backend. - ariadne_runtime_test: both sides' new L4 cases are kept, plus AStartedWebSocketCallKeepsTheHostItStartedOn, the WebSocket twin of AStartedRequestKeepsTheHostItStartedOn.
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.
O10 in
docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md(section 7, D1): forces and torques at a point, which a boat's propeller and rudder need.The calls
world::add_force_at(id, force, point)applies a world-frame force (N) at a world-frame point (m). A point off the centre of mass also turns the body by (point − com) × force. The point is in world coordinates, not the floating origin's.world::add_torque(id, torque)applies a world-frame torque (N·m) about the centre of mass.add_force:physics_erroris thrown;add_force;BodyInterface::AddForce(id, f, point)andAddTorque, with the default activation asadd_forcehas. The null backend checks the id.AddForceAndTorquepath, because that path never wakes a sleeping body.world.handdocs/PHYSICS_API.mdsay thatbody_state::positionis the body's origin, not its centre of mass. The two differ for a convex hull.physics_world.add_force_atandadd_torque. ANonepoint raises rather than meaning the world origin.Tests
New cases in
physics_world_test:add_force's state hash, bit for bit, over 120 steps.test_pycvc_physics.pygainstest_forces_at_a_point.The existing golden hashes are unchanged.
Checked locally (Windows Release)
Before the review fixes:
physics_world_test: 45 passed, 2 skipped by design;ctest -R Physics: 127 passed, 2 skipped;pycvc_physics: 139 checks.After the fixes, the force and torque tests (7/7, including the golden hash) and pycvc again. An independent review found four low-severity issues, all fixed:
Nonepoint in pycvc;This touches
docs/PHYSICS_API.mdnext to O11a's hull row; whichever merges second needs a one-line merge.