diff --git a/surfaces/blender/docs/kitbash.md b/surfaces/blender/docs/kitbash.md index 8cbd115..4e6f012 100644 --- a/surfaces/blender/docs/kitbash.md +++ b/surfaces/blender/docs/kitbash.md @@ -604,6 +604,93 @@ evaluate, but deleting the copy costs the same whole evaluation (1.44 to 1.54 s included, and the hole cut's temporary objects must be deleted too. So a hull with twenty cutters pays their evaluation once for every `ribs` call; iterate planes on the cage before it is cut, or with its Booleans off. +## Hoses between sockets + +`brokkr_kitbash.hose` routes a bundle of hoses from one socket to another around everything in the scene: + +```json +{"action": "brokkr_kitbash.hose", "object_name": "Feed", "start": "ThighRam:port_cap", "end": "ShinRam:port_cap", + "count": 3, "radius": 0.006, "clearance": 0.005, + "joint": "{\"socket\": \"Shin:end_a_back\", \"standoff\": 0.08, \"range\": [-120, 20]}"} +``` + +**Ends.** `start` and `end` are `Object:socket` on a kit part, a `hose` socket (an actuator's `port_cap` and +`port_rod`) or a `flange`, no narrower than the bundle; or `Object` alone, an empty whose z the hose leaves along. +A fitting keeps a straight lead of 8 radii (a ferrule of 5, then 1.5 outside diameters before any bend), and the +bundle's clearance is not asked of that lead: it stands on its own port. + +**The path.** `route.py` (numpy, no Blender) owns it. Waypoints are each fitting's lead end, each clamp and the +pin point. A leg between two waypoints is searched on a voxel grid of their box plus 0.25 m: a voxel is free when it +stands the bundle's half width, the clearance and half a voxel's diagonal from every other mesh, so every step +between neighbouring free voxels keeps the clearance; a 26-connected wavefront finds a shortest way and it is +pulled taut. The legs joined are one polyline, and each corner is rounded by the largest arc its measured room +allows: the arc stands within `radius * (1 - cos(turn / 2))` of its two tangent segments, so with that much room +beyond the clearance measured along them it keeps the clearance. Where two arcs would overlap on a segment both +shrink in proportion. The floor is `bend` outside diameters for the innermost hose (the centre line's is half the +bundle's spread more); a corner that gets less is refused, naming its point, the radius it got and the floor. The +finished curve is measured once more against every mesh before anything is written. + +A corner that wraps an edge stands about 0.87 of a voxel beyond the clearance, and that is its room: the radius it +can get is `0.87 * step / (1 - cos(turn / 2))`. When a bend round an edge is refused under the floor, raise `step` +(the hose then swings wider), lower `clearance` or `bend`, or give the hose a clamp to steer it. A 90 degree bend +straight out of a fitting needs `0.29 * floor` of room at the lead's end, which a bundle of three at the default +clearance of 0.01 does not have: 0.005 does. + +**Slack.** `sag` (outside diameters, default 1) lowers the middle of each free span's longest segment along world +-z, by less where the span runs steeply, and never by more than half the room measured along it: both halves then +keep the clearance with as much room again for the arc at the middle. A route that the sag would break is made +taut instead; the report's `sag` lists the metres each leg hangs. 0 routes taut. + +**Clamps.** `clamps` is a JSON array of up to 8 `{"socket": "Object:socket"}`, `mount` sockets in order along the +hose. The bundle runs straight along the socket's y through the point its half width, the clearance and one hose +radius above the face, for 2 outside diameters each side, and gets a pad on the face and a strap around it. The +bundle lies flat on the first clamp; its ups are rotation minimising (Wang et al. 2008), so it does not twist +between clamps, and a later clamp's strap follows the bundle as it arrives. + +**A pin.** A hose may cross one pin: a pivot connection between its ends' parts, found from their parent chains. +`joint` names a socket on that pin's axis whose z runs along it (the free end face of the pin: a strut's +`end_a_back`), a `standoff` and the pin's roll `range`. The hose passes through the point `standoff` beyond that +socket, on the axis, as a robot's dress pack does: the straights on each side then move with their own part and +only the bend at that point changes with the roll. Every roll from `lo` to `hi` in steps of 5 degrees is measured +without posing anything: the child's side of the polyline is turned about the axis, the corner at the pin point is +rounded again, and each side is measured against the other side's parts where that roll puts them. A roll that +fails is refused by name (`roll 50: the hose's child's side stands 0.02384 m from the parts on the other side of +the pin`). `lengthChange` is the centre line's longest less its shortest over the range, as each roll rounds the +bend. Two pins between the ends are refused: end the hose on a part between them. + +**What it writes.** One mesh object, a child of the start's object under identity matrices, with no modifier and +no material: each hose, two ferrule collars at each of its ends, and the clamps, all swept by `core.sweep`. +`kit_hose` on it is the request as JSON, a record nothing reads back. Other hoses are obstacles like any mesh, so +route the stiffest first. The hose is a bake of the scene at the call: after a part moves or rolls, run `hose` +again with the same `object_name` and it is rebuilt in place. + +A hose that crosses a pin stays one object. In the exported mesh it is skinned geometry, meant to be weighted +between the bones on either side of the pin, blending near the pin point; the posed shape then comes from the +skin, and the rebuild is for stills and for checking the range. This package writes no weights or vertex groups: +skin weights are `brokkr_rig`'s. + +**Refusals**, each before anything is written: a name taken by an object that is no hose; an end or clamp that +names no object, no such socket, or a socket of the wrong type; a bundle wider than a port, naming both sizes; a +part that is scaled or that Blender does not evaluate; a pin crossed with no `joint`, a `joint` with no pin, two +pins, a `joint` socket off the pin's axis, the current roll outside `range`; a search box over 524288 voxels, +naming a step that fits; an end nearer an obstacle than the bundle needs; no way through; a corner under the +floor; a roll that fails. + +**Cost.** Probes in Blender 5.3 on Starfire, medians of 3 interleaved repetitions: a nearest-face query on a tree of +81,920 faces takes 100 to 123 us uncapped and 3.4 us capped at 0.06 m, so every query is capped; on a grid of +97,061 voxels with a wall and a hole a heap A* took 8.47 s (56,824 pops) and the wavefront 0.26 s (100 waves); on +a knee of five boxes (96,565 voxels at 0.02 m) the occupancy took 0.46 s uncapped, the search 0.19 s, the pull, the +fillet and the verification under 2 ms together, 27 rolls 0.056 s and the sweep of three hoses 4 ms. The live +knee of `tests/live/kitbash_hose.py` (two struts, two actuators and a plate; two legs of 79,488 and 53,406 +voxels at roll 0, timed at roll 10; three hoses of 3,378 faces, 9 rolls) took 0.50 s a call, median of 3 each after one report action: 0.28 s of it +the occupancy (55 percent), 0.05 s the wavefront, 0.04 s the rolls, 0.02 s the fillet and its room, 0.01 s the +pull and the verification, and the rest the trees, the sweep and the write. The same call read 0.47 to 1.1 s +across runs while other Blenders were rendering on the machine. + +`tests/test_route.py` proves the path without Blender (the half-diagonal rule, the fillet's tangency, sharing, room +and floor, the sag's bound, the frames against the double reflection method, the rolls), and +`tests/live/kitbash_hose.py` the action in Blender. + ## Expressions Every numeric field of a shape or socket, and `bevel`, is a number or a string over the part's params: @@ -638,6 +725,7 @@ vertices overflow. | `brokkr_kitbash.apply` | `object_name` | Bakes the evaluated mesh into the kit part and clears its modifiers and the collections its Booleans held. Refuses a part with no modifiers, a mesh another object shares and a part Blender does not evaluate. Reports the part, `faces`, `volume`, `nonManifoldEdges` and the `cutters` it no longer refers to. | | `brokkr_kitbash.ribs` | `object_name` (the cage), `ribs_name`, `planes` (a JSON array of 1 to 64 `{origin, normal}`, up to 16000 characters), `standoff`, `depth`, `thickness`, `step`, `holes`, `posts`, `post_r`, `bridge`, `clearance`, `longerons` (a JSON array of 0 to 16 `{origin, axis, toward}`, up to 8000 characters), `longeron`, `longeron_w`, `longeron_h`, `longeron_t` | Derives ribs, lightening holes, posts and longerons from the cage as it is cut, as one mesh object under it. Refuses before it writes anything, naming the plane or longeron. Reports `object`, `ribs`, `thickness`, `sections: [{plane, chains, pieces, length, open}]`, `posts`, `holes`, `longerons: [{index, stations}]` (trimmed to a receipt, with `longeronsOmitted`), `faces`, `volume` and `nonManifoldEdges`. | | `brokkr_kitbash.shell` | `object_name`, `sheet` (a JSON object `{rings, closed, mirror, creases, rim, flip}`, up to 32000 characters), `thickness`, `offset`, `levels`, `bevel`, `count_folds` | Makes a faceted, hollow armor shell from a loft of rings with crease runs, or rebuilds a shell's cage in place under its cutters and ribs. Refuses before it writes anything, naming the field and index. Reports `object`, `rebuilt`, `rings`, `points`, `cageFaces`, `creases`, `folded` (with `count_folds`, the number of the evaluated wall's inner faces that fold; else null), `corners`, `subdividedFaces`, `facing`, `thickness`, `offset`, `levels` and `children`. | +| `brokkr_kitbash.hose` | `object_name`, `start`, `end`, `count`, `radius`, `spread`, `clearance`, `bend`, `step`, `sag`, `clamps` (a JSON array of up to 8 `{socket}`), `joint` (empty, or a JSON object `{socket, standoff, range}`) | Routes a bundle of hoses between two sockets around every other mesh, over clamps and through a pin's axis across its roll range; on a hose's name, rebuilds it in place. Reports `length`, `lengthChange`, `clearance`, `radii`, `sag`, `voxels`, `rolls`, `worstRoll`, `faces`, `nonManifoldEdges`. | `params` is `name=value; name=value`; a param left out takes the part's default (`place_part`) or keeps its stored value (`set_params`). A value outside its bounds is refused with the bounds in the message. @@ -683,8 +771,8 @@ file holds each report in `hostResult`. `tools/turntable_recipe.py` renders the ## The mechanical kit -`kits/mechanical.v0.json`: eleven parts, each along +z, with socket types `flange` (equal), `mount` (fits) and -`pivot` (equal). +`kits/mechanical.v0.json`: eleven parts, each along +z, with socket types `flange` (equal), `mount` (fits), +`pivot` (equal) and `hose` (fits: a port takes a bundle no wider than its size). | part | params | sockets | | --- | --- | --- | @@ -692,7 +780,7 @@ file holds each report in `hostResult`. `tools/turntable_recipe.py` renders the | `tank` | `radius`, `length`, `segments` | `port_a`, `port_b` (flange), `saddle` (mount), `lug_a`, `lug_b`, `lug_a_back`, `lug_b_back` (mount): a lug on each side (+x, and -x for `_back`) of each strap | | `ribbed_cylinder` | `radius`, `length`, `ribs`, `rib_depth`, `rib_width`, `segments` | `end_a`, `end_b` (flange) | | `strut` | `length`, `width`, `thickness`, `segments` | `end_a`, `end_a_back`, `end_b`, `end_b_back` (pivot): the two end faces of the pin at each end | -| `actuator` | `body_r`, `body_len`, `rod_r`, `extension`, `segments` | `base`, `base_back`, `rod_end`, `rod_end_back` (pivot); the rod end's two move with `extension` | +| `actuator` | `body_r`, `body_len`, `rod_r`, `extension`, `segments` | `base`, `base_back`, `rod_end`, `rod_end_back` (pivot); the rod end's two move with `extension`; `port_cap`, `port_rod` (hose, `0.4*body_r` wide) on the end faces of its two port bosses | | `pipe_fitting` | `pipe_r`, `run`, `branch`, `flange_r`, `flange_t`, `segments` | `a`, `b`, `c` (flange) | | `radiator_stack` | `fins`, `fin_w`, `fin_h`, `fin_t`, `pitch`, `segments` | `base` (mount) | | `vent` | `width`, `height`, `depth`, `slats`, `slat_t`, `tilt` | `back` (mount) | diff --git a/surfaces/blender/tests/live/kitbash.result.json b/surfaces/blender/tests/live/kitbash.result.json index bacf88b..9a852d1 100644 --- a/surfaces/blender/tests/live/kitbash.result.json +++ b/surfaces/blender/tests/live/kitbash.result.json @@ -481,7 +481,8 @@ "brokkr_kitbash.cut_many", "brokkr_kitbash.apply", "brokkr_kitbash.ribs", - "brokkr_kitbash.shell" + "brokkr_kitbash.shell", + "brokkr_kitbash.hose" ], "frame": { "beam_i": { @@ -608,7 +609,9 @@ "base", "base_back", "rod_end", - "rod_end_back" + "rod_end_back", + "port_cap", + "port_rod" ] }, "pipe_fitting": {