Compare commits

..
Author SHA1 Message Date
f8b2893eaa brokkr_kitbash.plate: fit rows part, bolts and step from kits/fittings.v0.json (cut plate-fittings-kit) (#48) 2026-12-03 17:54:30 +00:00
09f2f79ca3 Merge pull request 'plate.inset2d drops an edge that runs backwards; bolts follow (cut plate-inset-edge-event)' (#46) from nibu/plate-inset-edge-event into main 2026-12-03 17:32:09 +00:00
Meta Vens
86b123685e plate.inset2d follows the ring in, edge by edge; NotSimple where it would meet itself; build builds what check passes; any two near bolt heads are one; the tip step stated (cut plate-inset-edge-event, Soul s2)
- build-nonconvex-facet: a facet ring that would meet itself takes no panel, bolts or rim, never a refusal
- heads-overlap-across-ring: the merge reads pairs further apart round the ring after neighbours; 0 overlaps on 3,591 blades
- nonconvex-refusal-both-ways: the tab builds once its end runs out; a neck is refused at half its width, by check and build alike
- tip-jump-at-edge-drop: kitbash.md states the step and a test pins it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 18:02:28 +01:00
Meta Vens
efab6f655d tests/live/kitbash_plates.result.json: the run at the half-plane inset (54 checks, 4 bolts a guard)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 17:25:20 +01:00
Meta Vens
555b6124fa plate.inset2d: half-planes where an edge runs backwards; a sharp corner held only where that is sound; a reflex outline refused; the merge restart held
Soul s1 on cut plate-inset-edge-event:
- clamped-event-bolts-off-plate: the forwards test reads where the lines cross, not the corners held at MITER; an
  edge running backwards gives the outline clipped by every edge's half-plane, so no corner leaves the outline.
  Blade plates (14 to 32 degrees) and 3,000 drawn rings hold it.
- nonconvex-thin-tab-erases-ring: an outline that is not convex with an edge running backwards is refused at
  slab.outline (NotConvex); the oracle test holds the 6 raptor calls c clear of every edge.
- merge-restart-unpinned: three near heads across the ring start are one.
- cut-hard-plate-action.s1.live-test-bolts-literal-pr46: tests/live/kitbash_plates.py reads the bolt polygon count
  off plate.build.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 17:25:20 +01:00
Meta Vens
7cb7d0993b plate.inset2d drops an edge that runs backwards; bolts follow; CROSSED goes
inset2d is the one inset of every ring (slab gap and taper, panel outline, rim, bolt ring). After the corner move
it drops every edge left running backwards, the shortest first, and meets its neighbours on their own moved lines;
nothing left is an empty ring. A panel with no room for its bolt ring has no bolts, heads under two radii apart
are one at their middle, and a rim the chamfer would cost a corner is not chamfered. An equal seed pair is refused.

Tests: every inset2d call of the three fixtures against a half-plane clip (812 calls, 782 with no clamped corner
within 1e-12 m); no panel or bolt ring of any plate at either side turns right or crosses and no heads overlap;
EVENT holds the 31 fixture plates whose bolts or corners changed; every two-sided fixture row on one seed is a
mirrored pair. HASH re-pinned, equal on Starfire and Yggdrasil.

Cut aetheria-release:cut_spec:cut-plate-inset-edge-event.r1.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 17:25:20 +01:00
Meta Vens
677c98297a plates_bastion.json: repaired.how quotes the generator's script and its two edits as code
The repaired truths of Hull.Quarter and Hull.BellySide.R were made by a scratch script; the block now says how to
make them again from the branch at source.sha (Soul s2 Low repaired-truth-script-and-tie-pick).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 17:25:20 +01:00
1f76f4da44 Merge pull request 'brokkr_kitbash follows: a driven joint derived from its driver, by ratio or by closing a loop; joints v2 (cut kit-follows-2)' (#44) from nibu/kit-follows-2 into main 2026-12-03 16:15:34 +00:00
Meta Vens
11764eb0a5 Merge origin/main (hard-plate core and action, PRs 45 and 47) into nibu/kit-follows-2
__init__.py: the follow constants and the plate constants both stay. test_kitbash's seat pin goes from 5 to 6:
plates.stand seats a plate on its own frame, as a cutter, ribs and a hose are seated, and writes no follower
(Self's ruling, under hard-plate-map's boundaries).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 17:10:14 +01:00
Meta Vens
351918a8a2 live: kitbash_pose pins the joints report's key set with manyDrivers; its result file from this run
Finding kitbash-pose-pins-joints-keys. The pin stays an exact set.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 16:48:04 +01:00
270da6998b Merge pull request 'brokkr_kitbash.plates: a plate table written into the scene (cut hard-plate-action)' (#47) from nibu/hard-plate-action into main 2026-12-03 15:35:32 +00:00
Meta Vens
679062ca9a brokkr_kitbash: a loop with a second driver is told by every read of it: follows.holds false, and the joints report's manyDrivers
Which joints are a loop's drivers is read in one place, loop_drivers. one_driver refuses a write by it; follows_report and the joints report read the scene as it stands by it, so a second driver no action wrote (limits widened by hand, a saved file) reads holds false on both followers, naming both drivers, and is listed as {loop, drivers} in manyDrivers beside unlimited and rigid. Finding two-driver-loop-reported-nowhere.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 16:29:16 +01:00
Meta Vens
ea7759344d tests/live/kitbash_plates.py: plates against plate.build under the frame, a roll, a hose between ports, a rebuild, the refusals
54 checks in Blender 5.3 background on Starfire; bounds by the margin rule from fourteen mutants run against it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 16:23:39 +01:00
Meta Vens
cf268b6788 brokkr_kitbash.plates: a plate table written into the scene, rebuilt in place (cut hard-plate-action)
One writer of a hard plate's objects: the mesh on its host, a fit child per material for panels and bolts, an empty
per anchor, their Kit Bevels (12 and 20 degrees through sync_bevel's angle argument), plate_kind and kit_plate.
Refuses before it writes; the action row, its table tests and docs/kitbash.md, The action.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 16:23:38 +01:00
Meta Vens
40232be787 brokkr_kitbash.plate: clad carries bolt_mat and bevel (cut hard-plate-action)
check writes the defaults in (gunmetal, 0.012) and bounds them; build draws nothing from either.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 16:03:25 +01:00
Meta Vens
f91df3253e docs/kitbash.md, install.md, setObjectParent's row: which writes a two-driver loop refuses; the rig generator will read held rows
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 15:57:10 +01:00
Meta Vens
0c0193a171 brokkr_kitbash: the one-driver rule judges the write, not the scene: only the loops a write touches are read
A write touches a loop when a part it writes is the closing follower, the part closed on or the driver, or one
of those hangs from it. A loop that already has a second driver refuses those writes and no others, so a camera,
an empty or a part of another mechanism is posed, resized and given a parent in a scene that holds one
(finding parent-hook-gates-on-scene-not-change). Every asker shares the rule: write_checks, detach, set_params
and brokkr_parent_refusal. An untouched loop costs three stored pointers and a walk up its parents.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 15:57:10 +01:00
845b6336ac Merge pull request 'brokkr_kitbash.plate: hard plates from a plate table, in numpy alone (cut hard-plate-core)' (#45) from nibu/hard-plate-core into main 2026-12-03 14:31:54 +00:00
Meta Vens
2d4943804c brokkr_kitbash.plate: a two-sided row with one seed is a mirrored pair; KNOWN's corner and tie plates held to repaired truths; one hash on two platforms (cut hard-plate-core, Soul s1)
plate.build draws a two-sided row with one seed (or no clad) once, at side +1, and its .L is the mirror of
its .R. A one-sided row at side -1 and a two-sided row with a pair of seeds are drawn on the mirrored solid
as before, as the mech branches' builders do (paladin's left thigh). _longest's docstring says greatest.

tests: Hull.Quarter.R/.L and Hull.BellySide.R are held, solid, facets, panels and bolts, to
plates_bastion.json's "repaired": the branch's builder at eeda8bf in Blender 5.3 with massing.corners'
inside test at 1e-5 m, and with massing.clad cutting from the other of the two tied edges. The panels whose
outline crosses itself are named (Hull.Cheek.R's render difference is one of them, by where Blender starts
its loop). The three fixtures build to one sha256 at 1e-9 m on Starfire and on Yggdrasil.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 15:19:56 +01:00
Meta Vens
a25cec6f27 docs/kitbash.md, install.md, action table: who asks the one-driver rule, a ram's limits and its dead centre, held
The rule is read before every write, by set_params before its mesh and by
setObjectParent; a ram whose limits reach its closed length is refused by the
conditioning bound; a held row is in neither unlimited nor rigid (finding
docs-state-the-old-rule).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 15:07:25 +01:00
Meta Vens
08896d8565 brokkr_kitbash: set_params and setObjectParent ask the one-driver rule before they write; a joints row says held
write_checks is the writer's own checks and the one-driver rule in one call:
write_connections asks it before it writes, and set_params asks it before it
rebuilds a mesh or rewrites kit_params, so its refusal leaves the scene as it
stood (finding set-params-writes-before-the-guard).

Brokkr's setObjectParent asks each enabled add-on that defines
brokkr_parent_refusal(object, parent) before it writes a parent; brokkr_kitbash
answers one_driver over the scene as the new parent would leave it (finding
bridge-reparent-bypasses-the-guard).

A brokkr.joints row carries held: true when its limits are of one value
(finding held-pin-row-is-undistinguished).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 15:07:25 +01:00
Meta Vens
3acd7faddb docs/kitbash.md: Hard plates; plate fixtures one row a line
The section states the brokkr.plates.v0 table (rows, solid forms, clad,
anchors, sides), the hull and facet rules, what build returns, the
refusals, and how the three mech fixtures are held, with the eleven plates
the branches' float32 builders keep apart. The fixtures are rewritten one
table row a line; their content is unchanged.

Cut hard-plate-core.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 14:32:46 +01:00
Meta Vens
ed2ed9eeb8 brokkr_kitbash.plate: hard plates from a plate table, in numpy alone
plate.py turns a brokkr.plates.v0 table into each plate's convex solid (by
faces, slab, sections or points), its seeded detail panels, their corner
bolts and its anchors' frames. The table alone decides the result: the hull
is built here, facets are ordered in the table frame, seeds are data.

Fixtures plates_bastion/paladin/raptor.json hold tables converted from the
three mech branches (eeda8bf, c35e57e, 0c27103) and the truth each branch's
own builder made in Blender 5.3. test_plate.py's KNOWN names the eleven
fixture plates the truth cannot be met on (float32 solves, a corner
bastion's builder lost, one tie Blender's loop order decided).

Cut hard-plate-core (aetheria-release:cut_spec:cut-hard-plate-core.r1).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 14:29:40 +01:00
Meta Vens
2ef289e76b docs/kitbash.md, action table: one driver per loop holds after the loop is stated; a torque link's lug has no travel
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 13:55:42 +01:00
Meta Vens
1be1bfc1e6 brokkr_kitbash: the one-driver rule is read before every write of a connection and before detach
one_driver reads every loop in the scene as the write would leave it. write_connections and detach ask it, so
attach, detach, clearing a follower, widened or cleared limits and any pose refuse a second driver between a
stated loop's ends, naming both. follow's own copy of the rule is gone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 13:55:42 +01:00
24a67302be Merge pull request 'brokkr_reference.block_plate: a plate's first free cage from its named traces across solved views (cut trace-block)' (#43) from nibu/trace-block into main 2026-12-03 12:33:39 +00:00
Meta Vens
21f783b37c docs/kitbash.md: one driver per loop, a ram's dead centre, unlimited in pages; kitbash.result.json carries follow
kitbash_assembly, kitbash_hose and kitbash_pose were run again at this tree and
their result files are unchanged byte for byte.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 13:04:05 +01:00
Meta Vens
56730c0c87 brokkr_kitbash: follow refuses a loop whose ends depend on more than one driver; joints pages unlimited with its rows
follow names the driver and every other input between a loop's two ends: a
follower of another driver, or a joint with travel that follows nothing. A
joint both ends hang from, and one held by limits of one value, are not inputs.
The torque link fixture holds its lug by limits [90, 90]: one row with travel
that nothing drives, nothing unlimited.

joints builds its rows in core.joint_rows; unlimited lists the ids of the rows
a report carries and is counted with them, so a report is never over a receipt
and always carries a row.

Live kitbash_follows: 76 checks; both halves of the loop-ends rule, the two
second-driver refusals, the free lug, a hinge above both ends, and a tree of
264 unlimited joints with 62-character names.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 13:04:04 +01:00
Meta Vens
76a425c0d2 brokkr_kitbash core: a ram's dead centre is read, no solve answers the other assembly; joint_rows; the refusals reach a test
close_loop scales a ram's revolute column by its lever with the slide at 0, so
FOLLOW_SINGULAR reads the ram's lever over its closed lever and fires at the
rod's end on the barrel's pin; an iterate on the other side of the Jacobian's
determinant from its seed is refused as past the dead centre. 120 random rams:
4 wrong-side answers before, 0 after.

core.joint_rows derives the joints report's rows, so mutants J7, J8 and J11 die
in the unit run; J5, J9 and J10 die on ownership patterns. FollowTests reaches
the no-convergence refusal, binds FOLLOW_ITERATIONS to its rule and reads the
closing error FOLLOW_TOLERANCE bounds (the 3e-10 mutant reads 2.5e-10).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 13:04:04 +01:00
Meta Vens
c430a6e464 tests/test_reference.py, docs/reference.md: the rendered roof's bound read where a trace has no outlier, every point as far off the truth's projection: 1.505 with each view moved as one (144 directions), 1.58 and 1.67 searched by stroke and by point, M1 2.865; worst corner <= 2.08 x the worst traced point x the coarser pixel, the geometric mean, on one plate and one pair of views; eight families of takes named (1.11 to 1.33), FAIR 0.2 a point on a plateau 0.1 to 0.3, START's upper reading between 1.22 and 1.23 (cut trace-block, Soul s3)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 13:00:47 +01:00
Meta Vens
5dee3c685a tests/fixtures/spectre_truth.json, test_reference.py, docs/reference.md: the rendered roof's accuracy read from takes searched off the answer (72, six families of seed), stated as what holds: worst corner within 1.18 x the worst traced point x the coarser view's pixel, the test at 1.42; the rms-noise bound dropped; START pinned between a plate that blocks (0.831, 16.5 degrees) and one refused (1.241, 11 degrees) and its comment corrected; FAIR's table with its refused draws (cut trace-block, Soul s2)
bound-premise-seeded-by-truth: the fixture keeps the truth-seeded strokes for the fairness readings and says what
they are; takes are the same search from a seed moved 0.5 to 1.5 px as one or 1 to 3 px a vertex. 62 of 72 block,
no family stands out of the bound: the draws Soul's probe read at 3.5 to 6.5 had grown a side, and the probe read
the vertex after a grown side's inner point as the next corner; by the crown's chains they stand at 0.40 to 0.75
(135 blocked draws of his 168: 1.19 at most).
start-unpinned-and-comment-stale: START 0.6 and 0.8 refuse the 16.5 degree plate, 2.0, 2.6 and 3.3 block the 11.
fair-table-drops-refusals: 19 to 27 of 168 refused, rising with FAIR; Soul's seeds named.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 12:05:51 +01:00
Meta Vens
1b6de62253 docs/kitbash.md: followers, joints version 2, the joint-records drift; live bounds at their readings
Joint records gain the follows row and a Followers section (ratio and loop,
what a loop is solved from, the dead-centre bound, what it gives up). The
joints example is version 2 with driven, unlimited and paging; ShipJoint's
kind and spring are recorded as ruled with the one-to-one map; the false
'next pose is refused' claim goes and a frozen part's actions are complete.
kitbash_follows.py takes its bounds from the F11 and R1 readings and finds
the jump one solve does not survive (cut kit-follows-2, steps 5 and 6).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 11:14:00 +01:00
Meta Vens
e98b6a4da1 tests/live/reference_block.py: MOVED, GAP and GAP_MIRRORED each the geometric mean of the scene's reading and its least mutant's (FAIR 0.05 run through the script in Blender 5.3: 0.0565, 0.0288, 0.0534 against 0.0048, 0.0027, 0.0140); its last run
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 11:11:38 +01:00
Meta Vens
8b702c537e docs/reference.md, brokkr_actions.json: block_plate's depth sources as shipped (the views by metres a pixel, a seam corner by a crossing sight line, the plane and its guard), decided_by read from prior_share for every crown point and each side's inner points, the skirt in shares of the crown; measured against the rendered roof's truth, FAIR's table, and agreement with other fits named as agreement
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 11:11:38 +01:00
Meta Vens
29566492b5 tests/fixtures/raptor_plates.json: RAPTOR's 27 plate marked by eye in the hero and the SIDE view, the hero solved from hull marks (no camera under 25.1 px rms at 50 mm: the sheet's two views do not draw one hull); the plate blocks from its two views 34 to 40 degrees apart, the prior holding 0.17 to 0.20 of each corner; pinned as two views agreeing, not an accuracy (cut trace-block, Soul s1)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 11:03:26 +01:00
Meta Vens
fcf09bfae2 brokkr_reference.block_plate: every crown point says what decided it by its prior share, seam corners and sides' inner points included; a seam corner whose view runs along x = 0 goes to the plane and its guard; the views start a corner by metres a pixel against the prior's scale (START), not by degrees; the skirt in shares of the crown's extent; tests/fixtures/spectre_truth.json, SPECTRE's pass-3 roof built, rendered and traced off the renders: 39.1 mm from the truth as traced, 3.5 x noise x the coarser view's pixel at 1 and 2 px; FAIR 0.2 read against known truth (cut trace-block, Soul s1)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 10:59:44 +01:00
Meta Vens
3bf5d73658 brokkr_kitbash.follow in the action table; tests/live/kitbash_follows.py
The follow row, the joints row as version 2 with its after field, and roll,
aim, reach, slide and joint say what a follower and a driver do. The live test
drives a four-bar, a ram closing on its rocker, ratio followers and a torque
link through run_intent, pages a joints report and reads the joint-records
Lows. follow checks the closure before the parent and leaves the ratio's
limits rule to driven (cut kit-follows-2, steps 5 and 6).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 10:51:07 +01:00
Meta Vens
53eac397c7 brokkr_kitbash: followers derived from their driver; write_connections writes them with it; joints v2
The record gains follows (kit_follows, kit_follows_driver). write_connections
checks every entry before writing any; set_params seats through it, so its
direct seat loop goes and a hand-edited out-of-limit roll or stray slide is
refused. joint_record reads None for what record_refusal would refuse.
pose() refuses a follower and derives a driver's followers (driven: ratio,
then loops by core.close_loop, stepped). brokkr_kitbash.follow states and
clears; detach clears a loop partner. brokkr.joints version 2: driven,
unlimited, after/next, the root's own row (cut kit-follows-2, steps 2 to 4).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 10:42:56 +01:00
Meta Vens
198b79590e brokkr_kitbash core: close_loop solves a two-unknown planar loop; LIMIT_SLACK at its measured midpoint
core.close_loop is Newton on a closure's in-plane error over two joints in
series, with the analytic Jacobian, refusing a loop that is not planar, a dead
centre, no convergence and an axial miss. FollowTests reads it against
ram.pose's four-bar and a barrel-and-rod loop. LIMIT_SLACK moves to 2.4e-7
with cases 1.2 either side (cut kit-follows-2, step 1).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 10:31:07 +01:00
Meta Vens
4779e6cc5c Merge remote-tracking branch 'origin/main' into nibu/trace-block 2026-12-03 10:00:45 +01:00
396f4283d9 Merge pull request 'brokkr_kitbash.shell: Kit Solidify with plain offset, so a narrow plate's wall throws no needle (cut shell-plain-wall)' (#42) from nibu/shell-plain-wall into main 2026-12-03 08:54:29 +00:00
ad615a4f03 Merge pull request 'brokkr_kitbash.ram: zones by the bodies a pin joins, record version 2, Soul s4's Lows (cut kit-ram-lows)' (#38) from nibu/kit-ram-lows into main 2026-12-03 08:48:18 +00:00
Meta Vens
a570eb8478 tests/live/reference_block.py: tolerances round this scene's own readings (a pixel is 5 mm there); its last run
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 09:21:34 +01:00
Meta Vens
643dc599ab tests/fixtures/paladin_plates.json: Paladin's 16 single-view plates from one Blender run of e688951's build, each decided by its agent's plane; the thigh shields as partners are refused (two polygons, not one plate mirrored); a frame's turn is held to 1e-5, what a float32 matrix keeps
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 09:06:31 +01:00
Meta Vens
d4d0872d76 docs/kitbash.md: Thickness at a crease for the plain offset: t x cos(phi) at a crease, folds from (W / 2^levels) / sin(phi), no needle
The flat-facet onset re-measured with the plain offset (31 of 31 readings at 1.00 of the sin figure; Even
Thickness at 1.00 of the tan figure in the same 31), the three seeded lofts' first folds, the narrow plate and
the hexagon with both modes, and the Seraph readings marked as Even Thickness readings.

Cut aetheria-release:cut_spec:cut-shell-plain-wall.r1.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 09:03:15 +01:00
Meta Vens
aeac2e26ad tests/live/kitbash_cage.py: a narrow plate's wall throws no needle and a hexagon's thin wall folds no face
plain-wall-no-needle: a crown-skirt-centre plate 0.13 x 1.2 m, wall 0.04, bevel 0.01, levels 2, stands 0.95
thicknesses beyond its cage's bounds; at even offset (W1) 3.28; bound 1.77.
plain-wall-folds: the 1.2 m hexagon at 0.015 folds 0 of 168 inner faces; W1 20; the count + 1 bounded at 4.6.
W1 in the operator fails both.

Cut aetheria-release:cut_spec:cut-shell-plain-wall.r1.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 09:02:11 +01:00
Meta Vens
29aaf87365 brokkr_kitbash.shell: Kit Solidify with plain offset; the faceted suite's fold onset, wall and volume bounds re-read for it
Even offset divides a crease vertex's move by the cosine of the crease's half-angle: at a pinned corner of a narrow
plate the factor runs away and the wall throws a needle. With it off every inner vertex stands the thickness from
its outer one along the vertex normal.

kitbash_faceted pinned the even wall, so it follows: the wedge folds at (W / 2^levels) / sin(phi), 0.106 (was
tan, 0.075); the wall's distance off the thickness reads 0.0061 behind the creased shoulder (was 0.0001), bound
0.0122 against S6 at 0.024; the volume reads 0.028, S6 0.071, bound 0.0447. fold_lofts.json: seeds 5185 and 5196
fold at 0.0425 and 0.0232 with a plain offset (0.0019 and under 0.0009 with even), so their thickness and holds
stand 1.2 over and under those.

Cut aetheria-release:cut_spec:cut-shell-plain-wall.r1.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 08:59:11 +01:00
Meta Vens
5de5c3b5b1 tests/live/reference_block.py: block_plate through run_intent in Blender 5.3, the sheet built by brokkr_kitbash.shell, fit_shell on its fit_traces, a mirrored plate's seam built where crease_run says
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 08:57:27 +01:00
Meta Vens
e41d51282c brokkr_reference.block_plate: a plate's first free cage from traces naming two consecutive corners, solved by fit_runs with a plane and fairness for its prior (cut trace-block)
fit_runs takes its prior as rows (A, b); fit_sheet passes none, which is the identity it had. triangulate,
plate_sheet and block_plate after fit_sheet; the operator, its action row, docs/reference.md "block_plate",
BlockTests and tests/fixtures/spectre_plates.json.

Where the spec was silent or could not be built as written:
- a mirrored plate's centre stands in the half, not on x = 0: a face of three seam points is its own reflection
  and brokkr_kitbash's parser refuses it. The seam's sides keep their centre faces and lose only the skirt.
- views under 9.7 degrees apart (the geometric mean of 19 and 5) do not start a corner; that is what refuses a
  5 degree plate with no plane.
- block_plate takes the cage's parser as an argument: core imports nothing.
- SPECTRE's traces close no outline; the fixture closes them with edges of the fitted cage, marked.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 08:54:52 +01:00
Meta Vens
ba5672b47f live ram_knee: a turned bar beside a cube is inside out by its volume; welded to it, the part crosses itself and is told where
24 checks ok under Blender 5.3.0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 08:04:54 +01:00
Meta Vens
2ffb3b6460 brokkr_kitbash.ram: inside out is a solid's negative volume, a crossing is refused under its own name, and weld joins at the tolerance and no farther
Verdict cut-kit-ram-lows.s4 and ruling ram-refuses-crossing-not-inverted.

- Inside out: a solid with a turned face whose exact signed volume is
  negative, with a zero bound. A turned 0.2 cube by a 6 m bar and a turned
  plate 1e-5 thick are refused (both passed under THIN). A cavity's inward
  shell has no turned face and passes; a solid the weld closes up to a
  point or a line has no volume to read.
- Crossing: turned faces where no solid's volume is negative, holding THIN
  or more, are refused as "crosses itself" with the region's centre and
  reach, never as inside out. A turned piece welded into a whole solid
  reads so too.
- weld: one grid of the tolerance, each vertex compared with its own cell
  and those about it. A pair 0.99 of the tolerance apart joins and one 1.01
  apart does not, at any placement (the cells of twice the tolerance joined
  pairs up to 2x by where they fell).
- tests: the two s4 constructions; the weld pair at 100 placements; THIN
  pinned on a welded bar (6.75e-5 let, 1.93e-4 refused); Exposed, a stub
  mathutils that kills no-exposed-refusal and zero-area-kept without
  Blender; a cavity beside a let crossing.
- tests/fixtures/ram_meshes.npz: 113 rows. The four crossing parts renamed,
  and ten passing parts of each mech drawn by a seeded generator: 89 pass.

Over the 1,832 mech meshes: 1,790 pass, 21 open, 17 inside out, 4 crossing
(walker GunL/GunR.gunmetal, seraph Torso.LowerInL/R). Kits: 3,224 of 3,224
pass, 3,540 of 3,540 with lows.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 08:04:53 +01:00
Meta Vens
9815bad8d1 brokkr_kitbash.ram: solids welds before it reads edges and signs by the winding before each face; a mirrored shell is placed by its matrix
solids read topology by vertex index and inversion by a solid's volume, and
both failed on real meshes (verdict cut-kit-ram-lows.s3).

- weld: vertices within WELD (3e-4 of the extent) are one vertex to the open
  check, so a seam of coincident vertices is no hole.
- A face is turned where the winding number NUDGE before its centroid is
  under -0.5. The region before the turned faces is measured along their
  normals, and a part is refused where it holds THIN (1.1e-4 of the extent
  cubed) or more. A turned solid welded to a whole one is refused; a cavity
  and a sliver pass.
- placed: a shell may carry its matrix; a mirrored one has its faces turned
  back.
- tests.test_ram.Corpus: every kit part at the corners of its params (316),
  and tests/fixtures/ram_meshes.npz, 33 mech meshes: the 21 refused inside
  out, three open, and the passing parts nearest each bound.
- live ram_knee: a hollow mass and a mirrored shell are read; outside is to
  the nearest face of all; plates 1e-5 of the extent apart are two surfaces;
  a turned cube's faces are all exposed. 24 checks.

Over the 1,832 mech meshes: 1,790 pass, 21 open, 21 inside out (the 17 of
s3, walker's two guns, seraph's two Torso.LowerIn plates). Kits: 3,224 of
3,224 pass.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 06:26:59 +01:00
e141d003b8 Merge pull request 'brokkr_reference.fit_shell: a shell's traced runs fitted through solved cameras, accepted only where the built runs explain every trace (cut trace-fit)' (#41) from nibu/trace-fit into main 2026-12-03 04:58:59 +00:00
Meta Vens
23ebf4dd18 docs/reference.md: the untrimmed 90th percentile at 5.2 px and what it does not separate; m_per_px as a depth sensitivity with the measured hand-trace overshoot; reference_fit's last run
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 05:37:03 +01:00
Meta Vens
0c0dc87e50 brokkr_reference fit: the trim deleted, a trace asked at its untrimmed 90th percentile (tol 5.2); m_per_px stated as a depth sensitivity, not an error bound
No test claimed the trim (hand traces 3.76 against 3.26, the Orchid 0.80 against 0.69). Untrimmed, the traces
to accept read 3.76 at most and the least to refuse 7.27: TOL 5.2, separation 1.39 each side. The clean-stroke
test is named for the sensitivity it reads; fit_runs' docstring states the hand-trace overshoot (13 of 24, up
to 2.45 times).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 05:32:27 +01:00
Meta Vens
272a761892 docs/reference.md: fit_shell's reading of a trace and what it does not separate, depth across the run and the 0.2 line, free cages, and that a spine is decided by its plane
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 05:24:51 +01:00
Meta Vens
54781f45da tests/live/reference_fit.py: a mirrored free cage fitted through fit_shell by its vertex chains, rebuilt by brokkr_kitbash.shell and read against Blender's build
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 05:24:51 +01:00
Meta Vens
5b460c5394 brokkr_reference fit: a trace is asked at its 90th percentile past 5% at each end (tol 5), the reading is depth across the run, and a free cage is fitted by its vertex chains
The gate on a trace's worst point read the Orchid pair's tip (9.20 px) and its least 1% overdraw (9.12) alike;
the trimmed percentile reads them 0.69 and 4.27, and the pair is accepted at the default. TRIM, PART and TOL
are pinned from Soul's 296 fits by lodur:ruling:deterministic-bound-margin (FitTests' docstring states the
sets, and what the default does not separate). m_per_px leaves a point's slide along its own run out: pairs
read 0.080 at most, a single trace's inner points 0.503 and up. fit_sheet takes {verts: [...]} runs on a free
cage through Sheet.mirror_of; miss_px is gone, worst_px is reported beside the reading.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 05:22:49 +01:00
Meta Vens
ff6bf588d5 brokkr_kitbash Sheet.mirror_of: per vertex, the authored vertex it reflects, from the parser that makes the reflections (a loft's and a free cage's)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 05:22:49 +01:00
Meta Vens
f00a5a247d docs/reference.md: fit_shell, what its acceptance and its per-point readings are worth, and what it gives up
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 04:29:15 +01:00
Meta Vens
cad1a69def tests/live/reference_fit.py: fit_shell through run_intent on a mirrored shell, applied by brokkr_kitbash.shell and scored by flow_score
fit_shell's float bounds stand just under the row's (a float property rounds 0.001 and 0.1 up).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 04:29:14 +01:00
Meta Vens
617233f567 brokkr_reference.fit_shell: the action over core.fit_sheet; reads the shell's request through brokkr_kitbash's parser and writes nothing
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 04:22:23 +01:00
Meta Vens
968208fd36 brokkr_reference core: fit_runs and fit_sheet, a shell's traced runs fitted through cameras and refused where a trace is not explained
The cage points of a loft's traced hard runs move until the runs, as crease_run builds them and the cameras draw
them, lie on their traces: analytic Jacobian, Gauss-Newton with LM damping, a prior that holds each point to the
sheet as given. A fit is returned only where every point of every trace lies within tol px of its built run;
otherwise the refusal names the trace and the span. Per moved point the report says metres per pixel along its
sight line and the prior's share of that. Runs crease_run does not build (semi-sharp, a dart end, a point held
partway) and free cages are refused before fitting.

FitTests with the Orchid c09 fixture (camera record, frame, two hand traces, a blocking column; no mesh).
core.seen is pinned against project; _off now serves the explained check (follow-up reference-lift-s5-lows).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 04:21:38 +01:00
eed171efad Merge pull request 'brokkr_kitbash.shell takes a free cage (verts, tri/quad faces, creases, declared poles, mirror seam); cage export and scorer (cut kit-minimal-cage)' (#40) from nibu/kit-minimal-cage into main 2026-12-03 03:16:01 +00:00
a038e05520 brokkr_reference: pair, lift_pair and the lift helpers deleted; PR 36 lands as flow_score and the honest lens band
Camera-solve honesty, flow_score and hiding margin; lift_pair deleted (ruling lift-pair-held-for-redesign).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 03:12:57 +00:00
Meta Vens
1755ffaada brokkr_kitbash free cage: boundary smoothed as a hand-modelled cage's (Sheet.boundary; All on a free cage, Keep Corners on a loft); the seam relative to extent and read before the side; a pinched vertex refused by its fans; flip and the quad's area pinned
cage_export writes vertices as authored (core.sheet owns the seam) and refuses a Subdivision at Keep Corners.
cage_score: distance each way with area-weighted mean and Hausdorff; crease agreement read off the surfaces'
sharp edges (miss, spur) in place of the cage-tag chamfer; cost = fit + complexity after Hoppe et al. 1994.
Live kitbash_cage: the open-plate round trip with its bound, the cost ranking on a creased box, exact wall
counts, bounds compared as they stand (lodur:ruling:deterministic-bound-margin).
Fix batch h2 for aetheria-release:verdict:cut-kit-minimal-cage.s1.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 03:49:11 +01:00
Meta Vens
224eefa57b docs/kitbash.md: A free cage: the form, the mirror seam, the pole gate, triangles, the budget from two hand-modelled cages, and what it gives up
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 02:47:00 +01:00
Meta Vens
739cdb1e6b tools/cage_export.py and cage_score.py: a mesh read as a free cage, and two cages scored through shell (counts, limit distance, silhouette IoU, crease chamfer); core.poles; live proof kitbash_cage with its bounds by the margin rule
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 02:46:57 +01:00
Meta Vens
d80b164026 brokkr_kitbash.shell: the sheet takes a free cage (verts, faces of 3 or 4 sides, creases, corners, declared poles, mirror seam) beside the loft; core.sheet compiles both to one Sheet; report gains cageVerts, triangles, poles, closed
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 02:38:12 +01:00
Meta Vens
18adf73a27 live ram_knee: open and inside-out parts are refused by reason; a buried box does not hide the cube's depth; docs
The open cube's reading is cut for five refusals. The search's seconds are
a reading, stated in docs/kitbash.md as a quiet-machine figure beside the
loaded ones.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 01:35:12 +01:00
Meta Vens
3b56cdec6e brokkr_kitbash.ram: Signed refuses a part that is open or wound inside out, by its solid; the depth is to exposed faces
solids() splits a part into edge-connected solids and refuses one with an
edge no face runs the other way (the count) or of negative volume (the
solid, its first face, the volume). Nothing is repaired. inside() holds the
0.5 bound, pinned in the unit suite on a test-only open cube (0.527 and
0.473 about the hole). Inside, the depth is read from a tree of the faces
whose centroid, set off along the normal, is not inside the part; outside,
from all faces as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 01:35:12 +01:00
Meta Vens
404849a30e brokkr_kitbash.ram: Signed signs by the generalized winding number; the piece split and the rays are cut
Inside is where the winding number of the part's triangles about the point is 0.5 or more (Jacobson, Kavan and
Sorkine-Hornung 2013), the plain sum in numpy. Overlapping solids, welded or not, wind by their count; a
nonconvex prism winds whole; an open cube reads inside up to its hole's plane. _pieces, RAYS, the rays parameter
and the ray fixture's points are gone; ram_rays.json is ram_plates.json and keeps the overlapping bars.
Live ram_knee: 20 checks, search 34.5 s (the parity oracle beside it 34.5 s).

Closes cut-kit-ram-lows.s1 signed-trusts-closed-and-unwelded and rays-three-pinned-by-no-check.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 01:10:24 +01:00
Meta Vens
c4ac06c2dd live ram_knee: no point inside the jointlib plates reads outside (0 of 38,477); the ray count held beside the bars
inside-reads-inside replaces rays-inside: a 0.003 grid inside the four bars
(truth by each bar's face planes) and the fixture's 29 points, all read
inside. Parity over the whole mesh read 1,906 outside.

Read bar by bar, the 24 points between the plates fall outside every bar's
box and one ray no longer miscounts them; ram_rays.json's `points` are now 14
beside the bars that one ray reads inside and three read outside. Two rays,
or a second and third along x and y, read them as three do.

ram_knee.result.json regenerated: 21 checks. docs: the piece-by-piece read.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 01:10:23 +01:00
Meta Vens
7282c02d44 brokkr_kitbash.ram: Signed reads a mesh piece by piece: inside the part is inside any piece
Self's ruling on the fork cut-kit-ram-lows.h1 reported: callers feed joined
meshes such as jointlib's, whose closed pieces overlap. Parity over the whole
mesh reads the overlap as outside, the direction the proof between samples
cannot bear. _pieces splits a mesh into the pieces its faces join; each gets
its own tree and bounding box. Unit test of the split.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 01:10:23 +01:00
Meta Vens
d94dace75f live ram_knee: the inside check reads the oracle as it is made, by Signed's own ray count
The check passed rays=3 itself, so Signed's default at two rays kept it green
(the mutant survived its first run). It now builds the oracle with no count.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 01:10:23 +01:00
Meta Vens
fd1f4ed2c2 docs/kitbash.md: Rams and linkages: a zone's part is of a body its pin joins; the record is version 2; the rays held from inside
Clearance states the body rule and what it gives up (among the joined bodies'
parts a whole-member zone still lets the axis in; a third body's plate is
never zoned; a four-bar's eye is let near no coupler part). The record is
version 2 and holds nothing of a cylinder's settle. Readings: the 29 inside
points and the mutants' counts, and that overlapping closed pieces given as
one shell are mis-signed (1,906 of 38,448) where piece by piece none are.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 01:10:23 +01:00
Meta Vens
3c1344d776 brokkr_kitbash.ram: the record is version 2 and holds no settle block
The reserved block (stiffness, damping, travel; written null, solved by
nothing) leaves the ram record: a load-path cylinder's settle is a slide
joint's, in the joint records (cut kit-joint-records). VERSION is 2; a
version-1 record is refused as another version's, and the key is refused
like any the record does not know.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 01:10:23 +01:00
Meta Vens
2be27f0c0c live ram_knee: the oracle's rays held from inside: 29 points inside the jointlib rocker plates
Soul s4 (ray-fixture-pins-above-one-not-three, crossing-proof-needs-a-sign-
true-oracle): the fixture held only points outside the plates, which two rays
or an axis-aligned pair read as three do. ram_rays.json gains `inside`: points
0.001 or more inside one of the shell's four convex pieces, nine aimed along a
ray, x or y, twenty where a side's two bars overlap. The oracle as made reads
0 outside; two rays 16, one ray 10, the second ray the first 10, the second
and third along x and y 6. The check asks 0 and at least 2.

The fixture's `about` says what this does not show: fed as one shell the
overlap is signed by parity, and three rays read 1,906 of 38,448 inside grid
points outside; with each piece its own shell, none.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 01:10:23 +01:00
Meta Vens
6034831288 test_ram: Soul s4's surviving mutants die; the two off-margin bounds restated by the margin ruling
FINE is read as 64 and the floor's crossover (0.451 of spacing/64) is bounded
at 0.319 and 0.638: FINE 128 (0.2255) and FINE 32 (0.902) each fail, as do 8
and 4096. A bead of the shin before the first sample of a zone about c kills
the left-only pair. A base 0.1 from the rocker's pivot kills the ram's span
taken about the knee's pivot (0.539 against 1.335, bound 0.848).

The -0.9 link_r bounds become deviations from hand values (ZONED), the
>= 0.02 bound a deviation from the nearest sample's reading (BESIDE, against
B1: the proof by the nearer end less the span). Each constant states shipped,
mutant and separation.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 01:10:23 +01:00
Meta Vens
fa64f43a35 brokkr_kitbash.ram: a zone names a part of a body its pin joins (JOINS), or the record is refused
Soul s4 (zone-spans-the-member-and-hides-an-overlap): two zones of 0.51 of
its length cover a member, so no radius bound stops a foreign part being let.
The record can say which bodies a pin joins: a the parent, the rocker's pivot
the parent and rocker, p the rocker and coupler, c the coupler and child, b
the child, d the rocker. Mechanism refuses any other zone before measuring it;
from_record and a search world's answer pass the same loop.

Tests: every (kind, member, pin, body) admitted or refused by a hand table;
Soul's parent capsule under the coupler refused three ways; the wall, bead,
lug and world cases restated on bodies their pins join.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 01:10:23 +01:00
8690a43c77 Merge pull request 'brokkr_kitbash joint records: DOF from the socket type, limits, slide, the joints report; hose reads its range from the pin (cut kit-joint-records)' (#39) from nibu/kit-joint-records into main 2026-12-02 22:39:26 +00:00
Meta Vens
7bc14ecc82 docs/kitbash.md: joint records, the joints report and what it gives up; a pin's range is its connection's limits; ram_barrel and ram_rod
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 23:04:16 +01:00
Meta Vens
66fd7bb644 live: thirteen parts in kitbash.py; the joint frame bound from its mutant; result files of the four kitbash runs
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:57:36 +01:00
Meta Vens
5475a763af live: joint records on the pose scene, the knee's limits before each hose; close and the hose's second reader take the new shapes
kitbash_pose: a rod in its barrel, limits on a pin for roll, aim and reach, the record's refusals,
the joints report under the tank (a toe below a rigid foot reads the hinge as its parent joint),
detach clears the eight keys. kitbash_hose: JOINT drops range; the -20..90 and -10..20 cases are
the knee's limits, 30..60 and -200..200 are the joint action's refusals; a pin without limits and
a hose across a slide are refused.

Fixes two callers the last commit missed: close's mated() tuple and hose.through's crossed().

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:57:36 +01:00
Meta Vens
12e73c9dc3 kitbash: joint records on the connection; joint, slide and joints actions; the hose reads its range from the pin's limits
A connection's DOF kind is its parent socket's type's. write_connection, the one writer, states
kit_slide, kit_min, kit_max, kit_mechanism and kit_compliance, refusing before it writes a record
the DOF may not carry and a value with no representative inside the limits. roll, aim and reach
stay inside a revolute joint's limits; slide poses a prismatic one; joint states the record;
joints reports the tree as brokkr.joints v1 rows with axis and order derived. detach clears the
record.

Deleted with it: the hose's joint.range key, its shape check and its current-roll refusal. A
crossed pin is a revolute connection and its range is that connection's limits; a pin without
limits and a slide between the ends are refused.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:57:35 +01:00
Meta Vens
ed4d7729eb kits: pivot is revolute; a prismatic slide type; ram_barrel and ram_rod cut from the actuator at its gland
Slide 0 is closed and the slide is the extension: a rod of length body_len + 1.1 body_r in its
barrel stands as the actuator does. JointRecordTests: slide, within, limits on aim and reach, dof
across kits; mutants J1 J2 J3 J4 J6 each die there.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:57:09 +01:00
Meta Vens
2439b23af8 kitbash core: a socket type states its dof; mate and residual take a slide; within; aim_roll and reach_roll inside limits
check_kit admits socketTypes[..].dof (revolute | prismatic; absent is rigid). mate is
S_parent @ T(0, 0, slide) @ Rz(roll) @ FLIP @ inv(S_child). within() is the one rule for a value
inside its limits. Two kits mate a type only when match and dof agree.

Cut aetheria-release:cut_spec:cut-kit-joint-records.r1.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:57:08 +01:00
2864e9f3fd Merge pull request 'brokkr_kitbash.freeze and thaw: a finished cut object keeps its evaluated mesh and stops paying for every live Boolean; apply is cut (cut kit-freeze)' (#37) from nibu/kit-freeze into main 2026-12-02 21:54:38 +00:00
Meta Vens
7845b13ed0 brokkr_kitbash freeze: one writer of the frozen state, hold; a deleted frozen object releases its live mesh; importGltf drops kit_* extras (cut kit-freeze, fix batch h3)
hold is the only writer of kit_frozen, kit_kept and a held live mesh's fake user, and it swaps the meshes. It settles
every live mesh after each depsgraph update and before each save: held meshes are kept, kit_kept pointing at the frozen
mesh; a mesh no kit_frozen points at is released unless an object still carries the frozen mesh its kit_kept names.
The bridge's kit_owned is the one test for kit_*: setObjectCustomProperty refuses, importGltf drops and reports.
thaw removes the frozen mesh by user_map, names the kept mesh when kit_frozen was lost; a dirty part is refused as
dirty; the export refusal counts show_render as the report does.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:34:24 +01:00
Meta Vens
6743e5680b brokkr_kitbash freeze: kit_* refused by the bridge's property setter, the held live mesh kept by a fake user, a dirty frozen part reported and refused at export (cut kit-freeze, fix batch h2)
Answers verdict aetheria-release:verdict:cut-kit-freeze.s1.

- setObjectCustomProperty refuses any name starting with kit_: those properties are brokkr_kitbash's state, so
  kit_frozen keeps freeze and thaw as its only writers.
- freeze gives the held live mesh a fake user (marked kit_kept, taken back by the last thaw), so a purge cannot
  delete it when kit_frozen is overwritten by hand; thaw's refusal then names the kept meshes no frozen object holds.
- part_report: faces is the live mesh's count, frozen or not; a frozen part adds evaluated {faces}; a frozen part
  with a modifier shown again reports dirty (the modifiers) and frozen false. freeze reports faces (live) and
  evaluated {faces, volume, nonManifoldEdges}.
- exportGltf with applyModifiers refuses an export that includes a frozen object with a modifier shown.
- Live pins: kitbash_hose freezes a hose and its rebuild is refused; kitbash_assembly pins the setter refusal, the
  purge with an overwritten kit_frozen, the dirty report and the export refusal.
- kitbash_assembly and kitbash_faceted print their wall times and keep them out of the result files.
- docs/kitbash.md: the KESTREL wall-time ratio as a range (about 2.7 to 5.7), the Boolean evaluation counts
  (1035 against 139) as the stable measure.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:13:08 +01:00
Meta Vens
a69bb89374 docs/kitbash.md: freezing, what triggers a live collection Boolean, and what freeze buys on KESTREL (cut kit-freeze)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:13:08 +01:00
Meta Vens
6ea9202555 brokkr_kitbash.freeze and thaw: a cut object carries its evaluated mesh, its live mesh held in kit_frozen, its stack kept and off (cut kit-freeze, 2 of 2)
Blender re-evaluates every live collection Boolean after any datablock removal,
hide or mesh read in the scene. freeze swaps in the evaluated mesh and turns
every modifier off; thaw is its one undo. live() refuses a frozen object in
set_params, boolean, cut, cut_many, ribs, a shell or hose rebuild and freeze.

Live: three cut tanks frozen cost 0.0022 of what they cost live when an orphan
mesh is removed (mutant F1, modifiers left on: 1.5; bound 0.057).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:13:08 +01:00
Meta Vens
8767699767 brokkr_kitbash: cut apply and kit_baked (cut kit-freeze, 1 of 2)
apply's class, action row, docs and tests go, with BAKED and report's baked key.
A destructive bake removed the stack and the collections that say what cuts a
part; freeze and thaw replace it in the next commit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:13:07 +01:00
1c399a2c09 Merge pull request 'brokkr_kitbash.ram: a ram and linkage solver across a hinge: direct, four-bar, bell crank (cut kit-ram-core)' (#34) from nibu/kit-ram-core into main 2026-12-02 21:04:27 +00:00
Meta Vens
f1d479b3a1 docs/kitbash.md: Rams and linkages: a zone's bounds, the proof between samples and what it costs, ram.Signed and the ray count's fixture
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:59:28 +01:00
Meta Vens
f97beab77e live ram_knee: the package's oracle; the ray count held by the jointlib rocker plates; own plates zoned about both pins; parting zones no wider than the member
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:59:27 +01:00
Meta Vens
5726b37692 tests/test_ram: zone bounds in the record, the gate, from_record and a world; a wall of any thickness crossed in a zone; two zones of one pair; a sample at a zone's radius
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:59:27 +01:00
Meta Vens
481690fb5c brokkr_kitbash.ram: a zone is no wider or deeper than its member; between samples in a zone the axis is proved, not sampled; the signed mesh oracle
A zone's radius and depth are refused past the member's pin-to-pin length (by the pins alone) and its depth past
the member's eye on that pin (Ram.eye; at the gate and in from_record, so a world's answer too). Between samples
of which either is in a zone the segment is halved until the readings at its ends prove it holds -depth; at the
floor a part the axis is held outside reads as touched. Signed, three rays by majority, moves here from the
live test.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:59:27 +01:00
Meta Vens
941e146bc6 docs/kitbash.md: Rams and linkages: zones, the strict record, the live knee's readings and costs
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:33:26 +01:00
Meta Vens
bafdb171cd live ram_knee: the R-3 knee on generated meshes under a three-ray signed oracle, zones, moved x, the seated clevis, the search
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:33:26 +01:00
Meta Vens
451f1c4ee2 tests/test_ram: zones end at their radius, a pin stood inside what it stands beside, frames, the barrel's back end, the record's wall, a world's answer
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:33:26 +01:00
Meta Vens
f3d8a73f2a brokkr_kitbash.ram: touch is zones about a member's pins, each a radius and a depth; a strict record; what a world returns is read as a record
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:33:26 +01:00
Meta Vens
2678c09101 docs/kitbash.md: Rams and linkages: parts and touch, the signed oracle, the record, R-3 readings on meshes, costs with their conditions
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:33:26 +01:00
Meta Vens
1da1c213fa tests/test_ram: parts and touch on the R-3 knee at the probe's plate stack, inside a part, a candidate's own links, the record's version wall, bounds with their readings
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:33:26 +01:00
Meta Vens
780b0dae66 brokkr_kitbash.ram: clearance by parts and what a member may touch; a signed oracle; the barrel derived; a versioned record
The record names parts (part -> body) and touch (member -> parts it may touch): the allowed-collision pairs are
skipped whole and every other member-part pair is checked. The end cuts (e_a, 0.4 e_b, 1.5 link_r) and the
own-body exemption are gone; every body owns a part or the gate refuses. Distances are signed, capped outside
only; nan is refused. search takes world(m) -> (parts, touch, distance), so a candidate's own brackets and
links are its parts; a candidate's eye stands at a's place along the axis. barrel_length derives the barrel;
record holds nothing derived, carries schema, version and a reserved compliance block, and from_record refuses
another version, an unknown key or a compliance block whole. Gate refusals name the angle and the pin.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:33:26 +01:00
Meta Vens
048b3b3d7c docs/kitbash.md: Rams and linkages: the model, the three kinds, the gates, the oracle rule, R-3 readings and costs
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:33:26 +01:00
Meta Vens
1b12ef9a08 tests/test_ram: hand cases, loop closure, rates, the R-3 deep knee, the third body, the bell crank clear of every body
test_kitbash's package file list admits ram.py, which puts it under the package's negative patterns.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:33:26 +01:00
Meta Vens
8686a8cc09 brokkr_kitbash.ram: a ram and linkage solver across a hinge (direct, four_bar, bell_crank)
Every pose quantity is a pure function of the record and the hinge angle; rates are closed form; clearance is a
capped distance oracle met in every body's rest frame (cut kit-ram-core).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 20:33:18 +01:00
5b5657977e Merge pull request 'brokkr_kitbash.hose: hoses routed between sockets, clamped, through a pin's axis across its roll range (cut kit-hose)' (#33) from nibu/kit-hose into main 2026-12-02 19:17:19 +00:00
92f6144196 Merge pull request 'brokkr_reference: a reference view's camera solved from marked points (cut reference-camera)' (#35) from nibu/reference-camera into main 2026-12-02 19:07:56 +00:00
Meta Vens
7c95538ea6 docs/reference.md: the refusals of undecidable marks, and the band's step as its resolution
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 19:40:42 +01:00
Meta Vens
317e40e661 brokkr_reference: refuse marks that decide no camera, pin the uncapped band walk, ReferenceFitError
solve() refuses, before any solve and by which they are: fewer than six different world
points or pixels, pixels on one line, world points on one line, and world points in one
plane unless the lens is held and the centre is not solved. A record that is not finite
is refused too. One pixel for every name was a bare ValueError and one world point a
record of NaN (finding degenerate-marks-not-refused).

test_a_wide_band_is_walked_to_its_end kills a walk capped at 20 steps (M13): 4000 mm
shipped, 1177 capped, bound 2170. The lm call count that claims M3 is a bound, 61,
between 34 and 109. ReferenceError, which shadowed the builtin, is ReferenceFitError.
The docstring says a band of [x, x] is narrower than one step, not an exact lens.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 19:40:41 +01:00
Meta Vens
dcd06e9af8 live kitbash_hose: the steps refused at s2 route, seeds named, a port proven too stiff under a wall; docs: a seed refined, what a refusal claims, the pose-only gap's follow-up (cut kit-hose, h3)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 19:21:34 +01:00
Meta Vens
edbd04f1ef brokkr_kitbash.hose: a search's polyline is a seed, refined in continuous space; other grid origins and half the step before a refusal; too stiff only where proven (cut kit-hose, h3)
route.tangents gives each corner its floor's tangent before a neighbour gets more, and the pin's corner the
tangent of its sharpest roll (sharpest_turn, exact over a range; passes sizes a bin's bend by it). route.relax
drops, moves and adds a seed's free vertices until every segment has the straight its corners take (strain),
each change proven clear by the oracle. hose searches each leg on three grid origins and then at half the step,
names what it tried when it refuses, and says too stiff only where route.leaves proves no curve of the floor
radius leaves a port.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 19:21:33 +01:00
Meta Vens
263236ba4d test_reference: say where the unbounded-focal mutant died
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 19:21:12 +01:00
Meta Vens
ae42cf9d8c docs/reference.md: conventions, the action, and what the lens band means
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 19:18:39 +01:00
Meta Vens
3cf4234edb tests/live/reference.py: a known scene rendered, solved through the action, rendered again
1 - IoU of the two silhouettes 0.000168 (0.6489 with shift_y flipped); Blender 5.3.0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 19:18:38 +01:00
Meta Vens
d6b8896e00 brokkr_reference.solve_camera: the host action, its row and its table tests
Points go in as text (world, pixels, box, turned, pivot); with camera_name the
camera is created or updated at the record and the render size set to the box.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 19:18:38 +01:00
Meta Vens
ef806e5777 brokkr_reference.core: a reference view's camera solved from marked points
Ported from round 9's experiments/mechs/camsolve.py (3f45b67). The focal length is
held to 4-4000 mm at the box's width; the record carries lens_band (an equal-error
band, walked to the first miss or the bound) and lens_at_bound; square snaps the yaw
to a quarter turn; solve refuses by ReferenceError naming the cause; camera_of reads
blender() back. Place is solved as a dolly-zoom offset so log f alone is the
distance-lens trade, and a parameter held at a bound sits out of the LM step.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 19:14:45 +01:00
Meta Vens
d3650ce669 live kitbash_hose: a 1 mm plate between two rolls, the coarsest step, a second bundle at the default step, a straight only verify measures; CLEAR and KEPT by the margin rule; docs (cut kit-hose, h2)
CLEAR 0.017: shipped worst 0.032, mutant H4b (verify refuses nothing) 0.0089. KEPT 0.019: shipped 0.028, C1 0.013.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 18:48:37 +01:00
Meta Vens
b21e745d2e brokkr_kitbash.hose: clearance measured between readings, the roll range swept by bins, legs searched with room for their bends (cut kit-hose, h2)
route.measure replaces sampling at half a voxel: a reading answers for its piece less half the piece's length,
pieces are halved to 1 mm, so no plate stands unseen between two readings and no measurement depends on step.
route.passes measures a range, not a list of rolls: each roll answers for a bin by what a point can move within
it (rho x half width), the bend at the pin has one radius through a bin with its dip added to the need, and a bin
that falls short is halved down to 0.3 degrees. A leg is searched and pulled with 0.29 of the floor beyond need
where a way has it: a line pulled at need grazed what it wrapped and left its corner an accidental room that
changed with step. A corner under the floor says what limits it; a refusal names the sagged and the taut attempt;
another hose through the same pin is an obstacle where it stands and is not measured across the rolls as if rigid.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 18:48:37 +01:00
Meta Vens
336f94de54 docs/kitbash.md: hoses between sockets; kitbash live result with the hose row and the actuator's ports (cut kit-hose)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 18:48:37 +01:00
Meta Vens
ee45731e00 brokkr_kitbash.hose: a hose bundle routed between two sockets, clamped, through a pin's axis across its roll range (cut kit-hose)
The action is the bpy around route.py: ends and clamps from kit sockets, the crossed pin from the parent chain,
obstacles from every evaluated mesh as two trees split at the pin, one mesh object swept by core.sweep. Each free
span sags a little, bounded by its measured room, and a hose stays one object across a pin (ruling
hose-slack-and-skinned). Row in brokkr_actions.json; tests/live/kitbash_hose.py and its result.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 18:48:37 +01:00
Meta Vens
305efd541f mechanical kit: socket type hose, and port_cap and port_rod on the actuator's port bosses (cut kit-hose)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 18:48:37 +01:00
Meta Vens
13f60bbff1 brokkr_kitbash/route.py: a hose's path from waypoints and a distance oracle (cut kit-hose)
grid, wavefront, pull and leg search a leg; fillet rounds the polyline by each corner's measured room; sag lowers a
span by half its room (ruling hose-slack-and-skinned); passes turns the child's side through a pin's rolls; frames
are rotation minimising. numpy only; tests/test_route.py.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 18:48:12 +01:00
640e92f331 Merge pull request 'brokkr.kit.v0 extrude shape over core.sweep, wedge and gusset sections, and the frame kit (cut kit-extrude)' (#32) from nibu/kit-extrude into main 2026-12-02 17:14:16 +00:00
Meta Vens
8513bd35e3 live kitbash_ribs: wedge and gusset longerons through the legs' ribs, each its section's area along the run
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 17:42:08 +01:00
Meta Vens
2f374cc4de brokkr.kit.v0 extrude: up is one vector or one per path point; the portal's web stands in its plane
core.sweep already took an up for each point; the extrude shape now passes them through, and refuses an array
that is not one per path point. The frame kit's portal gives each point the in-plane direction toward the
inside of the frame, so its I section's web lies in the xz plane and its flanges run across y.

Tests: the portal's web, extents and feet (kills S9, foot_b on foot_a), each beam's w across x and h along y
(kills S14, box_beam's w and h swapped), the truss's chord ends, per-point ups at the shape. socket_seat reads
a face by Newell's normal and a crossing count, so FrameKitTests' own seat check is gone. SEATED, VOLUME and
PLACED sit at the geometric mean of shipped and least-mutant readings (lodur:ruling:deterministic-bound-margin).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 17:42:06 +01:00
Meta Vens
983dfcdd05 docs/kitbash.md: the extrude shape, its frame rule and seven sections, and the frame kit
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 16:31:49 +01:00
Meta Vens
5bf992ab70 live kitbash: the frame kit's nine parts placed, a truss re-parameterised in place, a box_beam seated on a mechanical bracket
Blender 5.3.0 background, private user dirs: kitbash 91 checks, kitbash_assembly 118, kitbash_pose 46,
kitbash_ribs 49, kitbash_shell 82, kitbash_faceted 34, all ok; only kitbash's result file changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 16:28:03 +01:00
Meta Vens
2d990bf2ea brokkr_kitbash.ribs row: the longeron enum lists PROFILES' seven sections, as the operator's does
The operator's longeron enum is core.PROFILES (__init__.py), and the host refuses a row whose enum differs from
its operator's: with wedge and gusset in PROFILES the whole kitbash table failed to load. The row mirrors the
seven. This file is outside the cut's stated files (cut-kit-extrude.r1 leaves it to kit-hose); the commit stands
alone so it can be dropped for the other answer, an enum of five named in __init__.py.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 16:28:02 +01:00
Meta Vens
1882c9c73b kits/frame.v0.json: beams in five sections, a truss, a portal, a gusset and a wedge, each an extrude
Nine parts over core.sweep and PROFILES; mount and pivot are mechanical's lines, so a frame part seats on a
mechanical one. A truss's diagonals are two repeats a double bay apart (expressions have no floor). FrameKitTests
holds every part at its default, minimum, maximum and 16 draws, with a socket seat that reads a section's
concave cap by Newell's normal and a crossing count.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 16:19:18 +01:00
Meta Vens
19c36b984f brokkr.kit.v0: an extrude shape, a PROFILES section along a polyline through core.sweep; wedge and gusset sections
core.SHAPES gains extrude (section, w, h, t, path, up, loop?, at?, rot?). check_kit refuses a section
PROFILES does not have, a path outside 2 to 64 points (3 with loop), and anything that is not an expression
where one belongs; _extrude builds through profile and sweep and re-raises what either refuses under the
shape's name. PROFILES gains wedge (a right trapezoid) and gusset (a right triangle with its tips cut square).
No sweep, profile or circle signature changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 16:10:21 +01:00
516fb4d1cb Merge pull request 'brokkr_kitbash.shell: a faceted, hollow armor shell from a loft of rings with crease runs, rebuilt in place under its cuts (cut kit-faceted-shell)' (#31) from nibu/kit-faceted-shell into main 2026-12-02 13:25:51 +00:00
Meta Vens
617eb2acbc brokkr_kitbash.shell: count_folds counts the folded faces of the evaluated wall; the cage estimate is gone
The fold receipt read from the cage ({onset, margin, edge, weight}) was no
bound in either direction: seeded lofts fold at 0.03 to 0.44 of it, and it
warned on Seraph plates that do not fold. core.fold_depths and the receipt are
deleted. With count_folds, shell evaluates the wall alone (Kit Subsurf and Kit
Solidify, every other modifier hidden for the reading and shown again) and
reports folded: inner faces with a corner turned to run with their outer
twin's normal. Without it folded is null and nothing is evaluated. Measured:
3.9 ms on a new plate of 1600 subdivided faces; nothing separable on a rebuild
under six cutters (0.94 s against 0.92 s).

Live kitbash_faceted holds the count to its own, face for face, on the wedge,
on three of Soul's seeded lofts (seed 5185 offset -1, 5101 offset 0, 5196
offset 1; tests/fixtures/fold_lofts.json) and on a rebuild under cutters.
Mutants caught there: never folded, all corners for any, stack left hidden.

docs/kitbash.md: folded 0 is not yet a wall an Exact Boolean takes cleanly;
on the Seraph's cap and breast it left open edges from 0.91 of the first
folding thickness, on one hand of a mirrored pair.

Finding: aetheria-release:finding:cut-kit-faceted-shell.s3.fold-receipt-margin-is-not-a-bound

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 13:29:46 +01:00
Meta Vens
d3c68edf79 live kitbash, kitbash_assembly, kitbash_pose, mesh_polish, rig: the checks run inside one try
An error raised between checks is a failed check that names the check before
it; the checks are printed and the result file written whatever happened, and
the exit is 1 with or without --python-exit-code. A rig.py copy with a raise
after 35 checks, launched bare: exit 1, 35 ok and 1 FAIL printed, result file
written (was exit 0 and no CHECK line).

Finding: aetheria-release:finding:cut-kit-faceted-shell.s3.midsuite-raise-hides-checks

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 13:29:46 +01:00
Meta Vens
9556d1337c brokkr_kitbash.shell: the receipt names the thickness at which the cage says the wall folds; live suites print before they write
shell reports fold {onset, margin, edge, weight} from the cage alone (core.fold_depths: every edge between two
quads as a full crease between flat facets, the narrower facet's reach, the wall's share on the edge's concave side
from offset). It reads no evaluated mesh. An estimate: on the Seraph's fourteen creased plates the evaluated wall
first folded at 0.74 to 1.2 of it in thirteen and at 2.6 in one. kitbash_faceted checks it against the evaluated
wall on a wedge of unequal facets (no turned inner face at onset / 1.2, some at onset x 1.2).

docs/kitbash.md: the narrower facet binds; 23 of 23 readings, ridge and valley; the fold receipt.
kitbash_faceted: SOFT sits at 12, between shipped 5.8 and W1's 25, and its comment says W1 is its least mutant.
kitbash, kitbash_assembly, kitbash_pose, mesh_polish, rig: check() takes a detail the result file cannot, and the
CHECK lines are printed before the file is written.
kitbash, kitbash_assembly: the action table is also held against the operators the add-on registered, so a row
lost from the table fails live.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 12:46:53 +01:00
Meta Vens
2e22a58bd7 docs/kitbash.md: the thickness a crease holds, as measured
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 12:10:31 +01:00
Meta Vens
b5b32efe94 live kitbash_faceted: a failed check whose detail is keyed by vertex pairs is written, not a crash; W1 claimed by the edge-for-edge check
json.dumps refused the tuple keys of a failed crease check's detail, so a mutant that broke the crease order ended in a
traceback with no FAIL line. shell's comment says why the weights are looked up by vertex pair: the mesh's edge order
is not core.sheet's.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 12:10:30 +01:00
Meta Vens
dddef79d8d live kitbash, kitbash_assembly: the rows the host must load are the action table's, read from brokkr_actions.json
Both suites listed the kitbash rows by hand, ending at ribs, and failed once shell added a row.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 12:10:30 +01:00
Meta Vens
39a3b7a3dd docs/kitbash.md: a closed loop of crease runs needs point creases at its corners
Found building Seraph's pectoral block: the face's border rounded into a disc.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 11:48:55 +01:00
Meta Vens
09f2ea6a97 docs/kitbash.md: Making a shell
The sheet format with a worked pauldron, the winding rule, crease runs and
rim, what a rebuild keeps, outlines by through cuts, ribs on a shell, the
refusals and the measured costs. The operator count is sixteen.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 11:37:49 +01:00
Meta Vens
1510bac6cf brokkr_kitbash.shell: a faceted, hollow armor shell from a loft of rings
shell writes the cage core.sheet builds, its crease_edge and crease_vert,
Kit Subsurf (creases, corners preserved) and Kit Solidify (even, rim), and
kit_shell, the request. On a shell it rewrites the mesh in place under its
cutters, ribs and Booleans. It evaluates nothing.

The action row, the host and ownership tests, and tests/live/kitbash_faceted.py
with its result: crisp 52 deg on the creased column against 5.8 elsewhere.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 11:36:24 +01:00
Meta Vens
eaf063a120 kitbash core: sheet, the cage and creases of a shell description
Sheet and sheet(document): a loft of rings as quads wound by a stated rule,
crease runs along ring and column edges, a rim weight, a mirror in x.
SheetTests pin the grid, the mirror, the runs and every refusal.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 11:23:23 +01:00
1695bc8caa Merge pull request 'brokkr_kitbash.ribs: ribs, holes, posts and longerons derived from an armor cage as it is cut; the shell-cuts Lows (cut kit-ribs)' (#30) from nibu/kit-ribs into main 2026-12-02 10:18:57 +00:00
Meta Vens
8e6141fa61 brokkr_kitbash.ribs: a Solidify whose faces are not the surface's vertices twice is taken at its thickness; docs/kitbash.md: ribs as built in h3 and what a call costs
A Subsurf after the Solidify remakes the plate's vertices, and the two faces cannot be read off
them: such a cage was refused by the commit before, and is a cage the probes and the renders use.
It is taken as h2 took every cage, the Solidify's thickness behind every face of the designed
surface, and the docs say what that is off by.

docs/kitbash.md, Ribs from a shell: the edge cut from the offset surface, the measure against the
plate, the plate's faces read from the Solidify, where a post starts, and the cost measured on
the pod against 585ece4 (the action's own work 0.66 s and 0.42 s, from 0.31 s and 0.14 s).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 10:37:23 +01:00
Meta Vens
c4717c9293 brokkr_kitbash.ribs: the rib's edge cut from the inner face offset inward, the plate's faces read from its Solidify, posts kept under the outer face
The standoff held only where the plate's lean was constant across the rib's reach: laid off along
the plane from each segment's own lean, it fell short under a tilted plane (0.007 of 0.04 on a
24-sided prism) and on a doubly curved wall (0.020 on a sphere), and at radius 0.6 with a standoff
of 0.01 the rib stood through the inner face (finding cut-kit-ribs.s2.standoff-curved-and-tilted).

- core.inset: the step that takes each vertex of a mesh behind every face it is a corner of, the
  mitre of its faces moved in. ribs offsets the plate's inner face by the standoff with it.
- A rib's outer edge is where its plane cuts that offset surface: points along the section look
  square in for it, corners go where the offset faces meet, and points that measure nearer the
  plate than the standoff (the offset surface folded) are left out. core.band then lays off only
  the rib's half thickness and its depth.
- The finished edge is measured against the inner face and moved in until no vertex is nearer than
  the standoff; a rib that cannot be stood off is refused.
- The plate's two faces are read from the Solidify as Blender evaluates it, so a Solidify that is
  not even (Blender's default) gives the plate it makes, 0.0424 beside a right angle for 0.06
  (finding solidify-default-unbounded). A Solidify whose faces cannot be read is refused.
- A post starts inside the plate, deeper where it leans, and its pad lies flat on the inner face.
- tests/live/kitbash_ribs.py: a tilted plane through a prism, spheres of radius 1 and 0.6 at 60
  degrees, a box with the default Solidify, posts under the outer face, a shallow rib in a crease;
  bounds by lodur:ruling:deterministic-bound-margin, RING now set from L1 (finding
  ring-bound-misses-l1).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 10:29:17 +01:00
Meta Vens
585ece4e4d docs/kitbash.md: ribs as built in h2, and what a ribs call costs and why
The standoff along the plate's normal, the band and its clipping at a crease, the plate
window, a negative Solidify, and that Solidify's even thickness is not even where faces
meet at unequal angles. reeval-per-call: one whole evaluation of the cage a call stays.
Measured on the pod: hiding the shell modifiers tags the cage (1.36 s); a temporary copy
without them links and evaluates in 0.001 s, but deleting any datablock makes Blender 5.3
evaluate the cage again (1.44 to 1.54 s), and the hole cut's temporaries must be deleted.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 08:47:12 +01:00
Meta Vens
e9f53fc3a9 brokkr_kitbash.ribs: the standoff along the plate's normal, ribs that follow a crease, and the s1 Lows
Fix batch h2 of cut-kit-ribs, against verdict aetheria-release:verdict:cut-kit-ribs.s1 and
follow_up ribs-fold-at-crease.

core.band replaces core.cornered and the rib's sweep: the rib is the band beside its
section, each edge the section offset with mitred corners and clipped as a polygon offset
is (core.away, the distance to a polyline less each segment's own distance). Inside a turn
tighter than the rib reaches the edges cut the corner instead of folding, so a creased
shell is ribbed and not refused; a section that leaves no room at all is refused by reason.
Holes stand on the band's clipped centre line; a post that would end outside the rib inside
such a turn is left out. The band does not depend on the section's direction, so the chain
reversal (mutant N3, dead) is gone.

standoff-oblique-sections: a segment's distance is the plate's thickness and the standoff
over the cosine of the plate's lean out of the plane, plus half the rib's thickness times
its tangent. Pinned on cones leaning 0, 30, 45 and 60 degrees and a hipped box (45 against
20): the rib comes the standoff from the plate, 5.3e-08 off, and is the analytic ring.
negative-solidify-thickness: the sign is folded into the offset. planes-string-cap-below-64:
planes 16000 characters, longerons 8000; 64 planes at full precision are taken.
plate-window-unpinned: a recess 0.8 of the plate deep (N5) and a port in a cage whose far
wall stands 3.5 plates behind (N13). figures-do-not-match: FIT is re-measured along the
normal (0.0011, bound 0.002), Manifold is 26 times Exact, not a hundred.

Sixteen mutants die on this tree (O1 O2 O3 S1 N5 N13 P1 C1 V1 M1 T1 D1 G1 A1 live or unit,
L1 W1 unit). 496 unit tests; kitbash_ribs 41 checks.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 08:47:12 +01:00
Meta Vens
3b0096106e docs/kitbash.md: Ribs from a shell, and the ribs row
What ribs makes, how it reads the cage, what it refuses, that the ribs object is a bake, and its cost on the
pod: 1.60 s with holes, posts and longerons and 1.44 s alone, each holding one whole evaluation of the cage
(1.35 s), medians of 3.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 06:38:45 +01:00
Meta Vens
4265443fad brokkr_kitbash.ribs: ribs, lightening holes, posts and longerons derived from an armor cage as it is cut
ribs reads the cage twice: with its Solidify, Bevel and Booleans off (the surface as designed; each plane cuts it
into sections) and whole (the plate as cut: a ray at each section point says whether the plate is there). A rib
is core.sweep of a rectangle along a section, set the standoff behind the plate's inner face; it stops clear of
a port, runs behind a panel break and under a recess. Inward comes from the cage's normals, and a section whose
normals change sides is refused. Posts and longerons are the same sweep; a longeron's stations are where its
half-plane crosses each plane's rib, found by core.crossings. Holes are one Manifold Boolean a plane on that
plane's webs alone, checked (closed, volume gone the holes' own) and refused otherwise; it is the one Manifold
Boolean in the package. Every refusal comes before the ribs object is written; kit_ribs records the request.

core: resample keeps a section's corners and fills between them (points spaced by arc length cut each corner in
two and an inward offset folds between them); cornered says which points a frame is swept through.
tests/live/kitbash_ribs.py pins it; bounds by the margin rule beside each constant. bl_info blender 5.3.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 06:38:45 +01:00
Meta Vens
9440a14b02 brokkr_kitbash core: PROFILES, one mitred sweep, crossings, resample and spans, engine-free
sweep takes a closed outline along a polyline: frames x = y cross t on the bisector tangent, mitred joints,
quads ring to ring, n-gon caps, wound outward; it refuses a short segment, a turn over 150 degrees, an up
along the path and a fold, naming the path point. crossings finds where a chain meets a half-plane whatever
its start or direction. resample spaces a chain by arc length. spans says which runs of a section keep their
frame: an open run under the bridge closes, the rest stand clear by the clearance. Swept carries the fields
write_mesh reads; joined puts shells side by side.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 05:59:32 +01:00
Meta Vens
cc98d36f4e brokkr_kitbash: the shell-cuts Lows: evaluable, fitted receipts, slot floors at the round ends, live checks that name what died
evaluable refuses, before any write, an object the evaluated depsgraph does not hold (disabled in viewports
with nothing depending on it, or in a collection outside the view layer): boolean, cut, cut_many and apply
call it. fitted trims a report's rows to a receipt and counts the rest in <key>Omitted: scene_closures, cut,
cut_many and boolean use it, so place_cutters loses its report hook and cut_many its refusal of a long report.
The slot's floor_l and floor_r move to the centres of its round ends, sized so the three never overlap.

kitbash_shell.py runs inside one try: an uncaught error is a failed check naming its section and the result
file is always written. It pins M1, M3, M6, M7, M16, hidden and unlinked targets, and trimmed receipts.
docs: like-for-like cost (13 cutters: cut_many 6.1 s, 13 cuts 51.3 s, 105 s with hides).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 05:56:08 +01:00
fa1468a1f5 Merge pull request 'brokkr_kitbash: roll, aim and reach pose an attached part in place, solved in closed form (cut kit-roll-aim)' (#29) from nibu/kit-roll-aim into main 2026-12-02 03:53:32 +00:00
Meta Vens
fb3382a923 brokkr_kitbash: aim's floor matched to float32 scenes; reach takes the edge of its circle and refuses a socket on the pin
AIM_FLOOR 1.5e-9 was set against float64 rounding, but a scene's matrices and an action's fields are float32:
the pin's own direction, as the scene holds it or typed at 6 or 4 decimals, was aimed at and swung the part to
an arbitrary roll. The floor is 1e-3, the geometric mean of the 4 decimal reading (6.2e-5) and a direction
1 degree off the pin (0.0175).

reach takes a height up to REACH_EDGE (1e-5 m, HELD) past the top or bottom of the circle as the top or bottom,
so the range a refusal names (now 6 decimals) can be typed back; a socket on the pin, or a direction along it,
is refused instead of dividing by a zero swing. Half a turn is pinned as 180.

Soul's verdict cut-kit-roll-aim.s1: findings aim-floor-below-float32-noise and
reach-exact-edge-refused-and-unpinned; survivors S6, S7, S8.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 04:31:37 +01:00
Meta Vens
c788b9d9b6 kitbash_pose.py: each metric read before its check, bounds by the margin rule; live result files
Bounds set from the shipped readings and nine mutants applied once each to a scratch copy (R1 atan2(A, B), R2 the
farther root, R3 roll without the seat, R4 no closures, R5 no aim floor, R6 left-handed roll_terms, R7 attach's
inline write kept, R8 the dot without its hypot, R9 sockets swapped in write_connection): every one fails a
unit test or a live check by name. kitbash, kitbash_assembly and kitbash_pose result files from Blender 5.3.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 03:55:39 +01:00
Meta Vens
bff51e887f brokkr_kitbash: roll, aim and reach pose an attached part in place, the roll solved in closed form
write_connection is the one writer of a connection (parent, seat, kit_socket, kit_parent_socket, kit_roll);
attach's inline write moves into it. roll states an attached part's roll where it hangs; aim and reach solve
it from core.roll_terms (d . p = A cos + B sin + C): aim_roll = atan2(B, A), reach_roll = atan2(B, A) +- acos,
the root nearer the current roll. Each reports closures as set_params does and never seats one.

PoseTests pin the solves against core.mate; tests/live/kitbash_pose.py exercises the three operators and their
refusals through run_intent. Cut kit-roll-aim (aetheria-release:cut_spec:cut-kit-roll-aim.r1).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 03:53:49 +01:00
ffb5a788e4 Merge pull request 'brokkr_kitbash: cut any mesh at a ray, a cutters kit with floor sockets, one collection Boolean per operation, shared socket types (cut shell-cuts)' (#28) from nibu/shell-cuts into main 2026-12-02 02:52:18 +00:00
72 changed files with 30609 additions and 1912 deletions

View file

@ -29,11 +29,11 @@
{"name": "targetObjectName", "type": "string", "required": true, "doc": "the object's name"},
{"name": "visible", "type": "boolean", "default": true}
]},
{"name": "setObjectParent", "doc": "Parent an object to another.", "changesScene": true, "editModeSafe": false, "fields": [
{"name": "setObjectParent", "doc": "Parent an object to another. Refused, with nothing changed, when an enabled add-on that defines brokkr_parent_refusal(object, parent) answers a reason, which is the message: brokkr_kitbash refuses a parent that would give a loop that follows a second driver, and any parent of a part such a loop hangs from while the loop already has one (both drivers are named; hold the joint, make it follow the driver, or clear the loop first). An object no loop hangs from is not refused.", "changesScene": true, "editModeSafe": false, "fields": [
{"name": "targetObjectName", "type": "string", "required": true, "doc": "the object's name"},
{"name": "parentObjectName", "type": "string", "doc": "empty or absent clears the parent"}
]},
{"name": "setObjectCustomProperty", "doc": "Set one custom property on an object.", "changesScene": true, "editModeSafe": false, "fields": [
{"name": "setObjectCustomProperty", "doc": "Set one custom property on an object. Refuses a name starting with kit_: those are brokkr_kitbash's own state, written by its actions.", "changesScene": true, "editModeSafe": false, "fields": [
{"name": "targetObjectName", "type": "string", "required": true, "doc": "the object's name"},
{"name": "propertyName", "type": "string", "default": "brokkrValue"},
{"name": "value", "type": "any", "required": true, "doc": "any JSON value Blender accepts as a property"}

View file

@ -46,6 +46,9 @@ DEFAULT_DEBUG_MIRROR_ROOT = "//.brokkr/blender-editor-debug"
HOST_SNAPSHOT_SCHEMA = "brokkr.blender.host_snapshot.v0"
HOST_ACTIONS_FILE = "brokkr_actions.json"
HOST_RESULT_LIMIT = 16000 # characters of a host operator's result copied into a receipt
KIT_RESERVED = "kit_" # brokkr_kitbash owns every custom property so named: kit_owned is the one test, setObjectCustomProperty refuses them and importGltf drops them
PARENT_REFUSAL = "brokkr_parent_refusal" # a function(object, parent or None) -> why not, or None, that an enabled add-on may define: setObjectParent asks each before it writes (brokkr_kitbash: its one-driver rule)
KIT_FROZEN = "kit_frozen" # brokkr_kitbash's frozen state (its FROZEN): read here only, to refuse an export that would apply a stack twice
COMMAND_INTENT_SCHEMA = "brokkr.blender.command_intent.v0"
COMMAND_RECEIPT_SCHEMA = "brokkr.blender.command_receipt.v0"
SYNC_SESSION_SCHEMA = "brokkr.sync.session.v0"
@ -932,6 +935,11 @@ class BrokkrBlenderTarget:
if ancestor.name == obj.name:
raise sa.ActionRefused(f"{obj.name!r} cannot be parented to itself or to one of its own children.")
ancestor = getattr(ancestor, "parent", None)
for module in self.bpy.context.preferences.addons.keys(): # an enabled add-on that owns a rule over parents is asked before the write
refusal = getattr(sys.modules.get(module), PARENT_REFUSAL, None)
reason = refusal(obj, parent) if callable(refusal) else None
if reason:
raise sa.ActionRefused(reason)
obj.parent = parent
return self._receipt(command, "accepted", "Blender object parent updated.", obj.name)
@ -944,6 +952,9 @@ class BrokkrBlenderTarget:
property_name = command["propertyName"]
if property_name.startswith("customProperties."):
property_name = property_name[len("customProperties."):]
if kit_owned(property_name):
raise sa.ActionRefused(f"{property_name!r} is brokkr_kitbash's own state ({KIT_RESERVED}*): its actions write it, and a value set "
"here would leave the object and the property disagreeing. Use the brokkr_kitbash action; nothing changed.")
modifier_name = na.drives_modifier_input(obj, property_name)
if modifier_name:
return self._receipt(command, "failed", f"{property_name!r} is an input of Geometry Nodes modifier {modifier_name!r}; "
@ -1003,7 +1014,19 @@ class BrokkrBlenderTarget:
before = set(self.bpy.data.objects.keys())
self.bpy.ops.import_scene.gltf("EXEC_DEFAULT", False, filepath=str(path))
added = sorted(set(self.bpy.data.objects.keys()) - before)
return self._receipt(command, "accepted", f"Imported {len(added)} object(s) from {path.name}.", added[0] if added else "")
# A file's extras become custom properties, and kit_* is brokkr_kitbash's own state, as setObjectCustomProperty
# has it: an imported kit_frozen would make a frozen object with no live mesh to thaw to.
dropped = []
for name in added:
obj = self.bpy.data.objects[name]
for holder in (obj, obj.data):
for key in [key for key in (holder.keys() if holder is not None else ()) if kit_owned(key)]:
del holder[key]
dropped.append(name)
dropped = sorted(set(dropped))
return self._receipt(command, "accepted", f"Imported {len(added)} object(s) from {path.name}." + (
f" Dropped the file's {KIT_RESERVED}* properties from {', '.join(dropped)}: they are brokkr_kitbash's own state and its actions write them." if dropped else ""),
added[0] if added else "")
def _exportGltf(self, context: Any, command: dict[str, Any]) -> dict[str, Any]:
"""Write the scene (or the named objects) as .glb or .gltf under the output directory."""
@ -1027,6 +1050,13 @@ class BrokkrBlenderTarget:
off_layer = [o.name for o in chosen if o.name not in context.view_layer.objects]
if off_layer:
raise sa.ActionRefused(f"Selection object is not in the active view layer: {off_layer[0]}")
if command["applyModifiers"]:
# A frozen object's mesh is already its stack's result: a modifier shown on it again would be applied twice.
dirty = sorted(o.name for o in (chosen or context.view_layer.objects.values())
if o.get(KIT_FROZEN) is not None and any(m.show_viewport or m.show_render for m in o.modifiers))
if dirty:
raise sa.ActionRefused(f"{', '.join(dirty)}: frozen (brokkr_kitbash.freeze) with a modifier shown again, so the export would apply "
"the stack on top of its own result. Thaw it (brokkr_kitbash.thaw), or hide its modifiers in viewports and renders; nothing written.")
# The exporter writes into a fresh staging folder beside the target, never onto the output
# directory: it may also write a .bin and texture files whose names Brokkr does not choose. Only
# after it finishes does every file move into place, each refused if its name is taken, so no
@ -1916,6 +1946,11 @@ def _sync_session(session_id: str, display_name: str, updated_at: str) -> dict[s
}
def kit_owned(property_name: str) -> bool:
"""A custom property brokkr_kitbash owns: no bridge action writes one from outside input."""
return property_name.startswith(KIT_RESERVED)
def _unity_custom_property_path(component_type: str, property_path: str) -> str:
property_path = (property_path or "value").strip()
component_type = (component_type or "").strip()

File diff suppressed because it is too large Load diff

View file

@ -45,7 +45,7 @@
},
{
"name": "brokkr_kitbash.set_params",
"doc": "Change params of a placed kit part and rebuild its mesh in place; modifiers and materials stay, and its connection and the parts attached to it are seated again. Refuses a change that breaks a connection, a baked part, a mesh another object shares and a scaled part. Reports as place_part.",
"doc": "Change params of a placed kit part and rebuild its mesh in place; modifiers and materials stay, and its connection and the parts attached to it are seated again. Refuses a change that breaks a connection, a frozen part, a mesh another object shares and a scaled part. Reports as place_part.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
@ -93,7 +93,7 @@
},
{
"name": "brokkr_kitbash.report",
"doc": "Placed kit parts as the scene has them: kit, part, params, faces, shells, each socket's world 4x4, the connection (parent, sockets, roll, residual, holds) and baked. Evaluates no modifier. Refuses a part scaled in the world: resize with set_params.",
"doc": "Placed kit parts as the scene has them: kit, part, params, faces, shells, each socket's world 4x4, the connection (parent, sockets, roll, residual, holds, and its joint record: dof, slide, limits, mechanism, compliance, within) and frozen. faces counts the live mesh; a frozen part adds evaluated {faces}, and dirty (the modifiers shown again by hand, with frozen false). Evaluates no modifier. Refuses a part scaled in the world: resize with set_params.",
"changesScene": false,
"editModeSafe": true,
"result": "brokkr_mesh_polish_result",
@ -109,7 +109,7 @@
},
{
"name": "brokkr_kitbash.attach",
"doc": "Seat a socket of a kit part on a socket of a part of any kit whose socket types agree and parent it there: origins together, normals opposed. Refuses sockets of different types or sizes that do not match, an occupied socket, a child that has a parent, and a loop. Reports the child with its connection.",
"doc": "Seat a socket of a kit part on a socket of a part of any kit whose socket types agree and parent it there: origins together, normals opposed. Refuses sockets of different types or sizes that do not match, an occupied socket, a child that has a parent, a loop, and a new pin or slide between the two ends of a loop that follows (a second driver: both are named; hold it or clear the loop first). The connection's DOF is its parent socket's type's (revolute, prismatic or rigid); it starts with no joint record: brokkr_kitbash.joint states one. Reports the child with its connection.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
@ -160,7 +160,7 @@
},
{
"name": "brokkr_kitbash.detach",
"doc": "Clear a kit part's connection and the closure it states: it keeps its place in the world and loses its parent; parts attached to it stay attached to it.",
"doc": "Clear a kit part's connection and the closure it states: it keeps its place in the world and loses its parent; parts attached to it stay attached to it. A loop follower's partner stops following with it. Refused, with nothing changed, when it would leave a loop that follows with a second driver: a part between one end of the loop and the part both ends hang from, whose going leaves a joint with travel between the ends (both drivers are named).",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
@ -174,6 +174,239 @@
}
]
},
{
"name": "brokkr_kitbash.roll",
"doc": "Turn an attached kit part to a roll about its parent socket's normal, in place: its parent and both sockets stay, and what is attached to it follows. Refuses a part that is not attached and, on a revolute joint with limits, a roll with no turn of itself inside them (the roll written is the one inside). Refused on a follower (a part whose connection states follows), naming its driver: its value is derived. On a driver, every follower moves with it in the same action, and a follower outside its own limits or a loop that cannot close refuses the pose with nothing changed; the report's followers lists each as {part, value}. Reports the part and closures, every closure in the scene as {part, to, holds}, its own first: a roll can open one and seats none but those of the loops that follow the part.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "object_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "an attached part"
},
{
"name": "roll",
"type": "number",
"required": true,
"minimum": -360,
"maximum": 360,
"doc": "degrees about the parent socket's normal, right-handed; at 0 the two sockets' up axes line up"
}
]
},
{
"name": "brokkr_kitbash.aim",
"doc": "Turn an attached kit part about its pin until one of its own axes points as near a world direction as the pin lets it. The roll is solved exactly, not searched. On a revolute joint with limits the roll stays inside them: where the free roll is outside, the end of the limits that points the axis nearer. Refuses an axis or a direction that lies along the pin (within about 0.06 degrees), and a zero direction. Refused on a follower, and moves a driver's followers, as roll does. Reports the part, aimed: {roll, dot} (dot 1 when the axis reaches the direction) and closures as roll does.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "object_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "an attached part"
},
{
"name": "axis",
"type": "string",
"required": true,
"enum": [
"+x",
"-x",
"+y",
"-y",
"+z",
"-z"
],
"doc": "an axis of the part's own frame"
},
{
"name": "direction_x",
"type": "number",
"minimum": -1000,
"maximum": 1000,
"required": true,
"doc": "the world direction to aim at, any length"
},
{
"name": "direction_y",
"type": "number",
"minimum": -1000,
"maximum": 1000,
"required": true
},
{
"name": "direction_z",
"type": "number",
"minimum": -1000,
"maximum": 1000,
"required": true
}
]
},
{
"name": "brokkr_kitbash.reach",
"doc": "Turn an attached kit part about its pin until one of its sockets' origins stands at a height along a world direction (by default world z): of the two rolls that do it, the one nearer the roll it has. Solved exactly. On a revolute joint with limits only a roll inside them is taken; with neither inside it refuses, naming both rolls and the limits. Refuses a height the socket cannot reach, naming the range it can (either end of the range is taken), and a socket that lies on the pin. Reports the part, reached: {roll, residual} and closures as roll does. Refused on a follower, and moves a driver's followers, as roll does.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "object_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "an attached part"
},
{
"name": "socket",
"type": "string",
"required": true,
"chars": "id",
"minLength": 1,
"maxLength": 32,
"doc": "the socket of the part that is brought to the plane; brokkr_kitbash.report lists a part's sockets"
},
{
"name": "direction_x",
"type": "number",
"minimum": -1000,
"maximum": 1000,
"default": 0,
"doc": "the world direction the height is measured along, any length"
},
{
"name": "direction_y",
"type": "number",
"minimum": -1000,
"maximum": 1000,
"default": 0
},
{
"name": "direction_z",
"type": "number",
"minimum": -1000,
"maximum": 1000,
"default": 1
},
{
"name": "height",
"type": "number",
"required": true,
"minimum": -1000,
"maximum": 1000,
"doc": "metres along the unit direction, in the world"
}
]
},
{
"name": "brokkr_kitbash.joint",
"doc": "State the joint record of an attached kit part's connection. The connection's DOF is its parent socket's type's: revolute (its value is the roll, degrees) or prismatic (the slide, metres). record is a JSON object of any of limits ([lo, hi] or null), mechanism (a label of 1 to 32 a-z, 0-9 and _, or null) and compliance ({\"hertz\": over 0 to 30, \"damping_ratio\": 0 to 2} or null: a slide in the load path that settles under load, a record for a runtime, solved by nothing here); a key left out keeps what is stated and null clears it. Refuses a rigid connection naming its socket type, limits that do not hold the value the joint has, revolute limits spanning over 360 degrees or with an end past 360, prismatic limits with an end past 10 m, and compliance on a revolute joint or without limits. Moves nothing but a roll to its turn inside the limits: a follower keeps its derived value (limits that do not hold it are refused), and a driver's followers are derived again where it stands. Limits cannot be cleared from a driver a ratio follows, nor widened or cleared on a pin that limits of one value hold between the two ends of a loop that follows (it would be a second driver: both are named). Reports the part and closures as roll does.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "object_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "a part attached on a revolute or prismatic socket"
},
{
"name": "record",
"type": "string",
"required": true,
"minLength": 2,
"maxLength": 400,
"doc": "a JSON object of any of limits, mechanism, compliance"
}
]
},
{
"name": "brokkr_kitbash.slide",
"doc": "Slide an attached kit part along its parent socket's normal, in place, on a prismatic connection (a ram_rod in a ram_barrel's bore: slide 0 is closed, the slide is the extension): its parent and both sockets stay, and what is attached to it follows. Refuses a revolute or rigid connection naming its socket type, and a slide outside the joint's limits. Reports the part and closures as roll does. Refused on a follower, and moves a driver's followers, as roll does.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "object_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "a part attached on a prismatic socket"
},
{
"name": "slide",
"type": "number",
"required": true,
"minimum": -10,
"maximum": 10,
"doc": "metres along the parent socket's normal from where the two sockets' origins meet"
}
]
},
{
"name": "brokkr_kitbash.joints",
"doc": "The joints of the tree of kit parts attached under a root part, as {schema: brokkr.joints, version: 2, root, frame, rigid, unlimited, manyDrivers, next, joints}. A row per revolute or prismatic connection, depth first with children by name, so a joint's parent row comes before it; a root that itself states a revolute or prismatic connection has its own row first, parent null: id (the child object), parent (the id of the nearest joint above, or null: rigid connections fold into it and are counted in rigid), part, socket ('Object:socket', the parent socket), kind, axis and origin (that socket's z and origin in the root object's frame: Blender axes, +Z up, metres), value (the roll in degrees or the slide in metres now), limits ([lo, hi] or null), min and max (the limits less the value: the travel either way from this pose), held (true when the limits are of one value: the joint has no travel, as a torque link's lug held at [90, 90], so a rig makes a fixed bone and not a DOF; such a row is in neither unlimited nor rigid), mechanism, compliance and driven (null, or {by: the driver's id, kind: ratio | loop, k, offset}: the value is derived from the driver's, so a rig makes a driven bone and not a DOF). kind is revolute or prismatic: Aetheria's ShipJoint calls them rotate and slide, one to one. unlimited lists the ids of the rows this report carries that are not driven and state no limits: an exporter that needs limits refuses by this one field of each report. manyDrivers lists each loop with more than one driver that has a part in the tree (a limit widened by hand, a saved file: no action writes one), as {loop: the closing part, drivers: [the loop's driver, each other one]}: its driven rows are not a function of one driver, so a rig refuses the tree while the list is not empty; it is of the whole tree and every page carries it. Axis, origin and order are derived at each report from the kits and the parent tree; nothing stores them. Rows a receipt cannot carry are counted in jointsOmitted, and next is then the id of the last row carried (else null): call again with after set to it for the rows that follow and their unlimited ids; a report is never over a receipt and always carries a row. after refuses an id that is no row's. Refuses a connection that cannot be read. Evaluates no modifier.",
"changesScene": false,
"editModeSafe": true,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "object_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "the root: a kit part"
},
{
"name": "after",
"type": "string",
"maxLength": 63,
"default": "",
"doc": "empty, or the next of the report before: the rows after that id"
}
]
},
{
"name": "brokkr_kitbash.follow",
"doc": "State that an attached kit part's joint follows another's: its roll or slide is then derived from the driver's whenever the driver is posed, and roll, aim, reach and slide on it are refused. record is JSON. {\"driver\": name, \"kind\": \"ratio\", \"k\": number, \"offset\": number}: the value is k x the driver's value + offset (a kneecap at k 0.5, a pinion at minus ring over pinion, a crosshead's slide in metres per degree of a roll); the driver states limits, so its value is one number. {\"driver\": name, \"kind\": \"loop\"}: object_name is a part that states a closure that holds; its joint and its parent's are the two unknowns solved so the closure keeps holding (a rocker and coupler closing on a crank; a ram's barrel and rod closing on the part it pushes; a torque link's two arms), and both follow the driver. Exactly one end of the loop, the parent's parent or the part closed on, moves with the driver: it is the driver, follows it, or hangs from one that does. The driver is the one input the two ends depend on: every revolute or prismatic joint between an end and the part both ends hang from is the driver, follows it, or is held by limits of one value (a torque link's lug on its rod: limits [90, 90]). The loop is planar: its pins are parallel. null clears the statement, and a loop partner's with it; it is refused for a follower between the two ends of another loop, which it would leave with a second driver. The one-driver rule is read again before every write of a connection and before detach, so no later attach, detach, clear, limits or pose breaks it. The follower moves at once and the report's followers lists every follower of the driver as {part, value}. Refuses, with nothing changed: a rigid connection; a driver that is the follower, below it, or itself a follower; a follower that already follows or that drives another; a ratio whose driver states no limits; a value outside the follower's own limits; a loop with no closure that holds, with both ends or neither moving with the driver, whose ends depend on more than one driver (another driver's follower, or a joint with travel that follows nothing: both are named), that is not planar, or at or past a dead centre (its two joints in line, a ram's rod end on its barrel's pin, or a step that would take the pair to its other assembly). Nothing stores a pin or a linkage: a loop is solved from the kits' socket frames each time, and no Blender driver or constraint is made.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "object_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "the follower: a part attached on a revolute or prismatic socket; for a loop, the part that states the closure"
},
{
"name": "record",
"type": "string",
"required": true,
"minLength": 4,
"maxLength": 400,
"doc": "{driver, kind: ratio, k, offset}, {driver, kind: loop}, or null"
}
]
},
{
"name": "brokkr_kitbash.close",
"doc": "Close a loop: state that a socket of a kit part meets a socket of a part of any kit whose socket types agree, where attach cannot (the part already has its parent). Accepted only when the two sockets already meet, origins together and normals opposed, any roll; it moves nothing. Attach the parts with the rolls that make them meet first; brokkr_kitbash.report shows the closure and whether it holds.",
@ -219,7 +452,7 @@
},
{
"name": "brokkr_kitbash.boolean",
"doc": "Cut a mesh, a kit part or any other, with another mesh object: the cutter joins the collection of the target's one live Boolean modifier for the operation (Exact, self-intersection on; difference, then union, then intersect, above its Bevel). Evaluates the target once, from a few tenths of a second to a few seconds: reports the result's faces, volume and non-manifold edges. The cutter is not changed; hide it with setObjectVisibility.",
"doc": "Cut a mesh, a kit part or any other, with another mesh object: the cutter joins the collection of the target's one live Boolean modifier for the operation (Exact, self-intersection on; difference, then union, then intersect, above its Bevel). Evaluates the target once, from a few tenths of a second to a few seconds: reports the result's faces, volume and non-manifold edges, and booleans, what cuts the target (rows a receipt has no room for are left off the end and counted in booleansOmitted). Refuses a target Blender does not evaluate (disabled in viewports, or in no collection the view layer shows). The cutter is not changed; hide it with setObjectVisibility.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
@ -254,7 +487,7 @@
},
{
"name": "brokkr_kitbash.cut",
"doc": "Cut a mesh, a kit part or any other, where a ray meets it: places a part of the cutters kit (box, cyl, slot or slab; brokkr_kitbash.describe with kit cutters) on the surface there, parented to the target, and adds it to the target's difference Boolean. The ray is cast at the target without its cuts. The cutter's floor socket (type mount, at the bottom of the recess, facing out) takes a part by brokkr_kitbash.attach; move the cut with setObjectTransform on the cutter, resize it with set_params, hide the cutter with setObjectVisibility. Blender evaluates the changed target after the action: one Boolean evaluation a cut; brokkr_kitbash.cut_many places several cutters for one. Reports the cutter with its sockets, and booleans.",
"doc": "Cut a mesh, a kit part or any other, where a ray meets it: places a part of the cutters kit (box, cyl, slot or slab; brokkr_kitbash.describe with kit cutters) on the surface there, parented to the target, and adds it to the target's difference Boolean. The ray is cast at the target without its cuts. The cutter's floor socket (type mount, at the bottom of the recess, facing out) takes a part by brokkr_kitbash.attach; move the cut with setObjectTransform on the cutter, resize it with set_params, hide the cutter with setObjectVisibility. Blender evaluates the changed target after the action: one Boolean evaluation a cut; brokkr_kitbash.cut_many places several cutters for one. Reports the cutter with its sockets, and booleans (rows a receipt has no room for are counted in booleansOmitted). Refuses a target Blender does not evaluate.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
@ -394,7 +627,7 @@
},
{
"name": "brokkr_kitbash.cut_many",
"doc": "Cut a mesh at several rays in one action, as brokkr_kitbash.cut does at one: all the cutters are placed or none, every ray is cast at the target without its cuts, and Blender evaluates the target's Boolean once after the action instead of once a cut. Reports object, the cutters' names and booleans; brokkr_kitbash.report gives a cutter's sockets.",
"doc": "Cut a mesh at several rays in one action, as brokkr_kitbash.cut does at one: all the cutters are placed or none, every ray is cast at the target without its cuts, and Blender evaluates the target's Boolean once after the action instead of once a cut. Reports object, the cutters' names and booleans (rows a receipt has no room for are counted in booleansOmitted); brokkr_kitbash.report gives a cutter's sockets.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
@ -418,8 +651,8 @@
]
},
{
"name": "brokkr_kitbash.apply",
"doc": "Bake a kit part: its mesh becomes its evaluated mesh, every modifier goes, material slots stay, and it is marked baked (set_params then refuses it). Sockets and connections stay. Refuses a part with no modifiers and a mesh another object shares.",
"name": "brokkr_kitbash.freeze",
"doc": "Freeze a mesh object that has modifiers (a kit part, a shell or any mesh) when its cuts are settled: its mesh becomes its evaluated mesh, its live mesh is held by its kit_frozen property, and every modifier stays in the stack, turned off, with its collections and cutters. Blender re-evaluates a live collection Boolean after any removal, hide or mesh read anywhere in the scene; a frozen object costs nothing there. Sockets, connections and report rows stay. set_params, boolean, cut, cut_many, ribs and a shell or hose rebuild refuse a frozen object: thaw it first. Refuses a frozen object, one with no modifiers, one with a modifier already off (named) and one Blender does not evaluate. Reports object (or the part), frozen, faces (the live mesh's), evaluated {faces, volume, nonManifoldEdges}, modifiers and booleans.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
@ -432,6 +665,392 @@
"maxLength": 63
}
]
},
{
"name": "brokkr_kitbash.thaw",
"doc": "Thaw a frozen object: its live mesh comes back, every modifier is turned on, and the frozen mesh is removed. Evaluates nothing; Blender evaluates the object once afterwards. Refuses an object that is not frozen or whose held mesh is gone. Reports object, frozen false, modifiers and the live mesh's faces.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "object_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63
}
]
},
{
"name": "brokkr_kitbash.ribs",
"doc": "Derive the frame under an armor cage from the cage itself, so it fits the armor by construction: a rib along each plane's section of the cage's surface, set the standoff behind the plate's inner face (along the plate's normal, at any tilt of the plane and any curvature of the wall: its edge is cut from the inner face offset inward, then measured against the plate) and reaching depth inward, clipped inside a crease tighter than that; lightening holes through the ribs; posts that stand the plate off them; longerons through the ribs. The plate's two faces are read from the cage's one Solidify as it evaluates, whatever its thickness mode. A rib stops where the plate is open (a port cut through it), runs behind an opening shorter than bridge (a panel break) and under a recess: openings are read from the cage as it is cut, so cut first. Inward is the side the cage's normals face away from. Makes one mesh object, a child of the cage, baked at this call: after the cage or its cuts change, delete it and run ribs again (its kit_ribs property keeps the request). Every plane and longeron is checked before anything is written. Reports ribs, thickness, sections [{plane, chains, pieces, length, open}], posts, holes, longerons [{index, stations}], faces, volume and nonManifoldEdges.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "object_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "the cage: a mesh whose surface is the plate's designed face, not scaled, its normals facing out of the plate"
},
{
"name": "ribs_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "the new ribs object's name"
},
{
"name": "planes",
"type": "string",
"required": true,
"minLength": 2,
"maxLength": 16000,
"doc": "a JSON array of 1 to 64 planes, each {\"origin\": [x, y, z], \"normal\": [x, y, z]} in the cage's own frame; a rib runs where each cuts the surface"
},
{
"name": "standoff",
"type": "number",
"minimum": 0,
"maximum": 2,
"default": 0.09,
"doc": "metres between the plate's inner face and the ribs, along the plate's own normal"
},
{
"name": "depth",
"type": "number",
"minimum": 0.005,
"maximum": 2,
"default": 0.09,
"doc": "how far a rib reaches inward from there"
},
{
"name": "thickness",
"type": "number",
"minimum": 0.001,
"maximum": 1,
"default": 0.014,
"doc": "a rib's thickness across its plane"
},
{
"name": "step",
"type": "number",
"minimum": 0.002,
"maximum": 1,
"default": 0.01,
"doc": "spacing of the points at which a section asks whether the plate is there"
},
{
"name": "holes",
"type": "number",
"minimum": 0,
"maximum": 10,
"default": 0,
"doc": "pitch of the lightening holes along each rib (radius 0.3 of depth); 0: none"
},
{
"name": "posts",
"type": "number",
"minimum": 0,
"maximum": 10,
"default": 0,
"doc": "pitch of the posts that stand the plate off each rib; 0: none"
},
{
"name": "post_r",
"type": "number",
"minimum": 0.001,
"maximum": 0.5,
"default": 0.011,
"doc": "a post's radius; its pad on the plate is 2.4 times as wide"
},
{
"name": "bridge",
"type": "number",
"minimum": 0,
"maximum": 2,
"default": 0.05,
"doc": "an opening shorter than this along a section is a panel break: the rib runs behind it"
},
{
"name": "clearance",
"type": "number",
"minimum": 0,
"maximum": 2,
"default": 0.02,
"doc": "how far a rib stops short of any other opening"
},
{
"name": "longerons",
"type": "string",
"default": "[]",
"minLength": 2,
"maxLength": 8000,
"doc": "a JSON array of 0 to 16 longerons, each {\"origin\": [x, y, z], \"axis\": [x, y, z], \"toward\": [x, y, z]} in the cage's own frame: the half-plane from the line through origin along axis, on toward's side. The longeron runs through the rib of every plane, in the planes' order, where the half-plane crosses the rib's mid-depth line: exactly once a plane, and not in an opening"
},
{
"name": "longeron",
"type": "string",
"enum": [
"I",
"C",
"T",
"L",
"box",
"wedge",
"gusset"
],
"default": "T",
"doc": "the longerons' section; its up faces the plate"
},
{
"name": "longeron_w",
"type": "number",
"minimum": 0.005,
"maximum": 2,
"default": 0.05,
"doc": "the section's width"
},
{
"name": "longeron_h",
"type": "number",
"minimum": 0.005,
"maximum": 2,
"default": 0.05,
"doc": "the section's height"
},
{
"name": "longeron_t",
"type": "number",
"minimum": 0.001,
"maximum": 1,
"default": 0.008,
"doc": "the section's wall"
}
]
},
{
"name": "brokkr_kitbash.shell",
"doc": "Make a faceted, hollow armor shell: the cage that cut, cut_many and ribs work on. sheet is a JSON object in one of two forms, a loft of rings or a free cage; exactly one of rings and verts. The loft: {\"rings\": 2 to 64 rings of 2 to 64 [x, y, z] points with equal counts, in the shell's own frame; \"closed\": each ring joins back to its first point (false); \"mirror\": each ring is authored from its point 0 on x = 0 toward +x and mirrored across x (false; not with closed); \"creases\": [{\"ring\": i, \"from\": a, \"to\": b, \"weight\": w} | {\"column\": j, \"from\": a, \"to\": b, \"weight\": w} | {\"point\": [i, j], \"weight\": w}], runs of ring or column edges and single points, weights 0 to 1, 1 a hard facet edge; \"rim\": the weight of every boundary edge no run names (1); \"flip\": reverse every face (false)}. Quads lie between neighbouring rings; the surface faces out where, seen from outside, a ring's points run left to right and the rings run upward. The free cage, for a form a few vertices and creases hold: {\"verts\": 4 to 256 [x, y, z]; \"faces\": each 3 or 4 vertex indices, counter-clockwise seen from outside; \"creases\": [[a, b, w]], an edge by its two vertices, weight 0 to 1; \"corners\": [[vertex, w]]; \"poles\": the vertex indices of irregular valence (not 4 off the boundary, not 2 or 3 on it); \"mirror\": every vertex is authored on one side of x = 0, one within 0.005 of the cage's largest extent of it is on the seam (snapped to x = 0 and shared), the others are reflected with their faces, creases, corners and poles (false); \"rim\" and \"flip\" as on the loft}. The pole gate: poles must equal the poles the faces make, or the sheet is refused naming each undeclared pole and each declared vertex that is none, with its valence. A free cage is also refused for a vertex in no face, a repeated index, a duplicate or collapsed face, an edge in three faces, two faces wound against each other, a pinched vertex (its faces meet only at it), a crease on no edge, and a face or shared edge lying on the mirror plane. A triangle subdivides to three quads. The cage is subdivided (Kit Subsurf, creases kept; a loft's boundary keeps its corners, a free cage's is smoothed through every vertex, Boundary Smooth All, so pin a corner with corners) and given a wall (Kit Solidify, rim filled). On an object that is already a shell the cage is rebuilt in place: the object, its cutters, ribs, Booleans and material slots stay, and ribs are stale until run again. A thickness the cage cannot hold is not refused: the wall folds over itself beside a tight crease or rim corner, and a cut there is unsound. count_folds evaluates the wall alone (Kit Subsurf and Kit Solidify, no Boolean; 4 ms on a plate of 1600 subdivided faces) and counts the folded inner faces; nothing else in the report reads an evaluated mesh, and no figure of the cage bounds the fold. Refuses before it writes anything, naming the field and index. Reports object, rebuilt, rings and points (null on a free cage), cageVerts, cageFaces, triangles, creases, poles ({valence: how many vertices}, on the cage as built), closed (no boundary edge), folded (null unless count_folds: then the number of the wall's inner faces that fold over, counted on the evaluated wall; 0 is a wall with no folded face, which an Exact Boolean can still fail on just short of a fold: read nonManifoldEdges after cutting), corners, subdividedFaces, facing, thickness, offset, levels and children.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "object_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "the shell's name: no object's name, or a shell's, which is then rebuilt"
},
{
"name": "sheet",
"type": "string",
"required": true,
"minLength": 2,
"maxLength": 32000,
"doc": "the shell description, a JSON object: a loft (rings, closed, mirror, creases, rim, flip) or a free cage (verts, faces, creases, corners, poles, mirror, rim, flip)"
},
{
"name": "thickness",
"type": "number",
"minimum": 0.001,
"maximum": 1,
"default": 0.05,
"doc": "the wall's thickness"
},
{
"name": "offset",
"type": "number",
"minimum": -1,
"maximum": 1,
"default": -1,
"doc": "-1: the wall grows inward from the designed surface; 1: outward"
},
{
"name": "levels",
"type": "integer",
"minimum": 1,
"maximum": 4,
"default": 3,
"doc": "subdivision levels; the subdivided faces (a quad 4 to the levels, a triangle three quarters of that) may not pass 262144"
},
{
"name": "bevel",
"type": "number",
"minimum": 0,
"maximum": 0.1,
"default": 0,
"doc": "width of the Kit Bevel on the plate's edges; 0: none"
},
{
"name": "count_folds",
"type": "boolean",
"default": false,
"doc": "evaluate the wall (Kit Subsurf and Kit Solidify alone) and report folded, the number of its inner faces that fold over"
}
]
},
{
"name": "brokkr_kitbash.hose",
"doc": "Route a bundle of hoses between two sockets, around every mesh Blender evaluates in the scene. start and end are 'Object:socket' on a kit part (a hose or flange socket no narrower than the bundle) or 'Object' alone, an empty whose z the hose leaves along. A leg runs between each pair of waypoints (a fitting's lead end, each clamp, the pin point): it is searched on a voxel grid of its ends' box plus 0.25 m (at most 524288 voxels), pulled taut with room for its bends where a way has it, and the whole polyline is rounded, each corner by the largest arc its measured room allows. That polyline is a seed: one refused for want of straight between its corners is refined in continuous space (vertices dropped, moved and added, each change proven clear), and before a route is refused the legs are searched again on two more grid origins and at half the step. The refusal then names the steps and origins tried and the first seed's refusal, and says this shows no route was found, not that none exists; it says the bundle is too stiff only where that is proven at a port. The innermost hose's bend radius is at least bend outside diameters, and a fitting keeps a straight of 8 radii (a ferrule, then 1.5 outside diameters). The centre line keeps the bundle's half width plus clearance from every other mesh, other hoses included, outside those leads. sag hangs the middle of each free span by that many outside diameters, never by more than half the room measured along the span; a route the sag breaks is made taut instead (sag in the report reads 0). clamps is a JSON array of up to 8 {\"socket\": \"Object:socket\"}, mount sockets in order along the hose: the bundle runs straight over each, along the socket's y, and gets a pad and a strap. A hose may cross one pin (a revolute connection between its ends' parts, with limits stated by brokkr_kitbash.joint: they are the roll range lo to hi; a pin without limits and a prismatic connection between the ends are refused): joint is then {\"socket\": \"Object:socket\", \"standoff\": metres}, a socket on that pin's axis whose z runs along it; the hose passes through the point standoff beyond it, so each side's straights move with their own part and only the bend at that point changes. The whole range from lo to hi is measured without posing anything, each side against the other side's parts: a roll every 5 degrees answers for the rolls about it by what a point can move within them, and more are measured between where that falls short; another hose through the same pin is kept clear of where it stands, not across the rolls (follow-up aetheria-release:follow_up:hose-motion-clearance-from-skinning owes that check). Every line is measured so that nothing thinner than a spacing can stand between two readings, whatever the step. The hose is one mesh object, a child of the start's object, and a bake of the scene at the call: after a part moves or rolls, run hose again on its name to rebuild it in place. Where it crosses a pin it is meant to be skinned between the bones on either side; no weights are written. Refuses before it writes anything, naming the leg, corner, point or roll. Reports object, rebuilt, hoses, length, lengthChange (over the range, of the centre line as each roll rounds it), floor, clearance (least beyond the bundle, outside the leads; readings stop at capped), voxels per leg, seed {step, offset, refined} (the grid that gave the route, and whether its polyline was refined), sag per leg in metres, rolls (how many were measured), worstRoll, worstClearance (least over the range, each reading less what its point can move within its roll's bin), faces, volume, nonManifoldEdges and radii {least, corners}.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "object_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "the hose's name: no object's name, or a hose's, which is then rebuilt"
},
{
"name": "start",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 96,
"doc": "'Object:socket' (a hose or flange socket of a kit part), or 'Object' (an empty: the hose leaves along its z)"
},
{
"name": "end",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 96,
"doc": "as start"
},
{
"name": "count",
"type": "integer",
"minimum": 1,
"maximum": 8,
"default": 1,
"doc": "hoses in the bundle, side by side"
},
{
"name": "radius",
"type": "number",
"minimum": 0.003,
"maximum": 0.1,
"default": 0.01,
"doc": "a hose's outside radius"
},
{
"name": "spread",
"type": "number",
"minimum": 0,
"maximum": 0.5,
"default": 0,
"doc": "centre to centre between hoses; 0: 2.6 radii"
},
{
"name": "clearance",
"type": "number",
"minimum": 0,
"maximum": 0.5,
"default": 0.01,
"doc": "free space kept between the bundle and every other mesh"
},
{
"name": "bend",
"type": "number",
"minimum": 1,
"maximum": 20,
"default": 4,
"doc": "least bend radius of the innermost hose, in outside diameters"
},
{
"name": "step",
"type": "number",
"minimum": 0.005,
"maximum": 0.2,
"default": 0.02,
"doc": "voxel size of the search; a way narrower than the bundle plus two voxels is not found"
},
{
"name": "sag",
"type": "number",
"minimum": 0,
"maximum": 8,
"default": 1,
"doc": "how far the middle of each free span hangs, in outside diameters; 0: taut"
},
{
"name": "clamps",
"type": "string",
"minLength": 2,
"maxLength": 4000,
"doc": "a JSON array of 0 to 8 {\"socket\": \"Object:socket\"}, mount sockets in order along the hose",
"default": "[]"
},
{
"name": "joint",
"type": "string",
"minLength": 0,
"maxLength": 4000,
"doc": "empty, or a JSON object {\"socket\": \"Object:socket\", \"standoff\": 0 to 10}: the pin the hose crosses; its roll range is that connection's limits",
"default": ""
}
]
},
{
"name": "brokkr_kitbash.plates",
"doc": "Write a table of hard armour plates into the scene. table is a brokkr.plates.v0 document as JSON (docs/kitbash.md, Hard plates): {\"schema\": \"brokkr.plates.v0\", \"plates\": [row, ...]}, each row a convex faceted solid with optional clad (raised panels and their bolts) and fits (anchors on its face, and fittings: parts of the fittings kit, rim bolts and steps). The table's coordinates are metres in frame: a JSON 4x4 of rows in the world, rigid; empty, the host's world matrix, or the world with no host. side 1 builds the table as written and -1 mirrored across its x = 0. Each built plate is a mesh object named prefix + its name (.R and .L on a two-sided row), every face flat, parented to host under an identity parent inverse, with material mat, a Kit Bevel of the row's bevel (angle 12 degrees) and the properties plate_kind \"hard\" and kit_plate (its checked row, a record). Its panels are the child <plate>.fit.<clad mat>, its bolts <plate>.fit.<clad bolt_mat> and each fitting <plate>.fit.<the fit's mat>, one mesh per material, made only when not empty; a child that holds panels carries a Kit Bevel of clad.bevel (angle 20 degrees, one segment). Each anchor is an empty child at the anchor's frame: <plate>.mark.<id> with kit_anchor {kind, id, height}, <plate>.port.<name> with kit_anchor {kind, name}; brokkr_kitbash.hose takes a port empty's name as an end and leaves along its z. An object that carries kit_plate under a made name is rebuilt in place: it keeps its identity, its other children and its modifiers; its fit children are rewritten, made or removed, its anchors moved, and one the row no longer names removed. A plate is no kit part: joints and report do not list it, and a roll of its host carries it. Every material must exist (createMaterial). Refuses before it writes anything: a table the format refuses (the path is named), a missing material (named with its path), a host that is missing, scaled, mirrored or sheared, a frame that is not a rigid 4x4, a made name of over 63 bytes or taken by an object that is not this plate's, a frozen plate or one sharing its mesh, and a report over 16000 characters. Reports plates [{name, rebuilt, corners, facets, panels, bolts, anchors (the empties' names)}], host and side.",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "host",
"type": "string",
"minLength": 0,
"maxLength": 63,
"default": "",
"doc": "the object every plate is parented to; empty: no parent"
},
{
"name": "frame",
"type": "string",
"minLength": 0,
"maxLength": 1000,
"default": "",
"doc": "the table's frame in the world, a JSON array of 4 rows of 4 numbers, rigid; empty: the host's world matrix, or the world with no host"
},
{
"name": "side",
"type": "integer",
"minimum": -1,
"maximum": 1,
"default": 1,
"doc": "1, or -1 for the table mirrored across its x = 0; 0 is refused"
},
{
"name": "prefix",
"type": "string",
"minLength": 0,
"maxLength": 32,
"chars": "id",
"default": "",
"doc": "written before every plate's name: a-z A-Z 0-9 _ . (the action refuses a '-')"
},
{
"name": "table",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 32000,
"doc": "a brokkr.plates.v0 document, as JSON"
}
]
}
]
}

File diff suppressed because it is too large Load diff

View file

@ -43,7 +43,7 @@
},
{
"name": "slot",
"doc": "Round-ended slot, long along x: a visor, a gill, a vent. width must exceed height. Three floor sockets face out of the recess: floor at the frame's centre (between the two middle copies when count is even), floor_l and floor_r a third of the width to each side; each holds one part.",
"doc": "Round-ended slot, long along x: a visor, a gill, a vent. width must exceed height. Three floor sockets face out of the recess: floor at the frame's centre (between the two middle copies when count is even), floor_l and floor_r at the centres of the two round ends; each holds one part and is as large as fits beside the next, min(height, (width-height)/2).",
"params": [
{"name": "width", "type": "number", "min": 0.01, "max": 8, "default": 0.3, "doc": "end to end (x); more than height"},
{"name": "height", "type": "number", "min": 0.005, "max": 4, "default": 0.05, "doc": "across the slot (y); the ends are half-rounds of this diameter"},
@ -58,9 +58,9 @@
{"shape": "repeat", "count": "count", "step": [0, "pitch", 0], "of": {"shape": "tube", "r0": "height/2", "r1": "height/2", "length": "depth+lift", "segments": 32, "at": ["(width-height)/2", "-(count-1)*pitch/2", "-depth"]}}
],
"sockets": [
{"name": "floor", "type": "mount", "size": "height", "at": [0, 0, "-depth"], "z": "+z", "y": "+y"},
{"name": "floor_l", "type": "mount", "size": "height", "at": ["-width/3", 0, "-depth"], "z": "+z", "y": "+y"},
{"name": "floor_r", "type": "mount", "size": "height", "at": ["width/3", 0, "-depth"], "z": "+z", "y": "+y"}
{"name": "floor", "type": "mount", "size": "min(height, (width-height)/2)", "at": [0, 0, "-depth"], "z": "+z", "y": "+y"},
{"name": "floor_l", "type": "mount", "size": "min(height, (width-height)/2)", "at": ["-(width-height)/2", 0, "-depth"], "z": "+z", "y": "+y"},
{"name": "floor_r", "type": "mount", "size": "min(height, (width-height)/2)", "at": ["(width-height)/2", 0, "-depth"], "z": "+z", "y": "+y"}
]
},
{

View file

@ -0,0 +1,144 @@
{
"schema": "brokkr.kit.v0",
"kit": "fittings",
"doc": "What stands on a hard plate's face (brokkr_kitbash.plate's fit rows): each part stands on +z from z = 0 in its own frame, whose origin is the fit's place on the face, z the face's normal and y the face's up; metres. One material a part; no sockets.",
"socketTypes": {},
"parts": [
{
"name": "bolt",
"doc": "A hex head on a washer: a rim bolt, and what a bolts row stands along a slab's outline.",
"params": [
{"name": "r", "type": "number", "min": 0.004, "max": 0.1, "default": 0.017, "doc": "the head's radius to its corners; the washer is 1.55 r"}
],
"shapes": [
{"shape": "tube", "r0": "1.55*r", "r1": "1.55*r", "length": 0.004, "segments": 14, "at": [0, 0, -0.0005], "rot": [0, 0, 90]},
{"shape": "tube", "r0": "r", "r1": "r", "length": "0.7*r", "segments": 6, "at": [0, 0, 0.0035], "rot": [0, 0, 90]}
],
"sockets": []
},
{
"name": "slot",
"doc": "The raised rim of a w by h slot: four bars around the opening. The opening's dark floor is a pit row under it.",
"params": [
{"name": "w", "type": "number", "min": 0.01, "max": 2, "default": 0.2, "doc": "the opening across (x)"},
{"name": "h", "type": "number", "min": 0.005, "max": 2, "default": 0.04, "doc": "the opening along up (y)"}
],
"shapes": [
{"shape": "box", "size": ["w+0.06", 0.032, 0.028], "at": [0, "h/2+0.016", 0.014]},
{"shape": "box", "size": ["w+0.06", 0.032, 0.028], "at": [0, "-h/2-0.016", 0.014]},
{"shape": "box", "size": [0.032, "h", 0.028], "at": ["w/2+0.016", 0, 0.014]},
{"shape": "box", "size": [0.032, "h", 0.028], "at": ["-w/2-0.016", 0, 0.014]}
],
"sockets": []
},
{
"name": "pit",
"doc": "The dark box that reads as the hole under a slot or behind a vent: w by h, depth tall, count of them pitch apart along y, centred. A slot's is 0.012 deep; a vents row's is 0.01 deep with the vents' count and a pitch of 2.7 h.",
"params": [
{"name": "w", "type": "number", "min": 0.005, "max": 2, "default": 0.2, "doc": "across (x)"},
{"name": "h", "type": "number", "min": 0.005, "max": 2, "default": 0.04, "doc": "along up (y)"},
{"name": "depth", "type": "number", "min": 0.001, "max": 0.2, "default": 0.012, "doc": "how far it stands off the face"},
{"name": "count", "type": "integer", "min": 1, "max": 64, "default": 1, "doc": "copies along y, centred"},
{"name": "pitch", "type": "number", "min": 0, "max": 4, "default": 0, "doc": "distance between copies"}
],
"shapes": [
{"shape": "repeat", "count": "count", "step": [0, "pitch", 0], "of": {"shape": "box", "size": ["w", "h", "depth"], "at": [0, "-(count-1)*pitch/2", "depth/2"]}}
],
"sockets": []
},
{
"name": "vents",
"doc": "A stack of louvre lips tilted 28 degrees over w by h openings, 2.7 h apart along y, centred. The openings' dark floors are a pit row under it.",
"params": [
{"name": "w", "type": "number", "min": 0.01, "max": 2, "default": 0.3, "doc": "an opening across (x)"},
{"name": "h", "type": "number", "min": 0.005, "max": 0.5, "default": 0.03, "doc": "an opening along up (y)"},
{"name": "count", "type": "integer", "min": 1, "max": 64, "default": 4, "doc": "lips"}
],
"shapes": [
{"shape": "repeat", "count": "count", "step": [0, "2.7*h", 0], "of": {"shape": "box", "size": ["w+0.04", "0.9*h", 0.012], "at": [0, "0.75*h-(count-1)*2.7*h/2", 0.014], "rot": [-28, 0, 0]}}
],
"sockets": []
},
{
"name": "access_port",
"doc": "A round access port's body: a turned ring of radius r around a sunk cover with a raised boss. Its eight bolts are a port_bolts row at the same place.",
"params": [
{"name": "r", "type": "number", "min": 0.02, "max": 1, "default": 0.12, "doc": "the port's radius"}
],
"shapes": [
{"shape": "lathe", "segments": 28, "profile": [[0, 0], ["r", 0], ["r", 0.035], ["0.82*r", 0.05], ["0.82*r", 0.022], ["0.34*r", 0.022], ["0.34*r", 0.045], [0, 0.045]]}
],
"sockets": []
},
{
"name": "port_bolts",
"doc": "The eight hex heads on an access port's rim, on a circle 0.91 r, standing from the rim's shoulder (z 0.035): a row of its own, so the heads take their own material.",
"params": [
{"name": "r", "type": "number", "min": 0.02, "max": 1, "default": 0.12, "doc": "the port's radius"}
],
"shapes": [
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["0.91*r", 0, 0.035], "rot": [0, 0, 90]},
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["0.6434671708797584*r", "0.6434671708797584*r", 0.035], "rot": [0, 0, 90]},
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": [0, "0.91*r", 0.035], "rot": [0, 0, 90]},
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["-0.6434671708797584*r", "0.6434671708797584*r", 0.035], "rot": [0, 0, 90]},
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["-0.91*r", 0, 0.035], "rot": [0, 0, 90]},
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["-0.6434671708797584*r", "-0.6434671708797584*r", 0.035], "rot": [0, 0, 90]},
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": [0, "-0.91*r", 0.035], "rot": [0, 0, 90]},
{"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["0.6434671708797584*r", "-0.6434671708797584*r", 0.035], "rot": [0, 0, 90]}
],
"sockets": []
},
{
"name": "handle",
"doc": "A grab handle along y: a square bar of side 2 r on two posts, bent over at lift, each post on a washer and a hex foot. Roll 90 lays it along the face's a.",
"params": [
{"name": "length", "type": "number", "min": 0.05, "max": 2, "default": 0.3, "doc": "between the posts"},
{"name": "lift", "type": "number", "min": 0.02, "max": 0.5, "default": 0.065, "doc": "the bar's centre over the face"},
{"name": "r", "type": "number", "min": 0.004, "max": 0.05, "default": 0.016, "doc": "half the bar's side"}
],
"shapes": [
{"shape": "extrude", "section": "box", "w": "2*r", "h": "2*r", "t": "r", "path": [[0, "-length/2", -0.004], [0, "-length/2", "lift-min(0.4*lift,0.2*length)"], [0, "-length/2+0.1339745962155613*min(0.4*lift,0.2*length)", "lift-0.5*min(0.4*lift,0.2*length)"], [0, "-length/2+0.5*min(0.4*lift,0.2*length)", "lift-0.1339745962155613*min(0.4*lift,0.2*length)"], [0, "-length/2+min(0.4*lift,0.2*length)", "lift"], [0, "length/2-min(0.4*lift,0.2*length)", "lift"], [0, "length/2-0.5*min(0.4*lift,0.2*length)", "lift-0.1339745962155613*min(0.4*lift,0.2*length)"], [0, "length/2-0.1339745962155613*min(0.4*lift,0.2*length)", "lift-0.5*min(0.4*lift,0.2*length)"], [0, "length/2", "lift-min(0.4*lift,0.2*length)"], [0, "length/2", -0.004]], "up": [1, 0, 0]},
{"shape": "tube", "r0": "2.3*r", "r1": "2.3*r", "length": 0.008, "segments": 12, "at": [0, "-length/2", 0], "rot": [0, 0, 90]},
{"shape": "tube", "r0": "2.3*r", "r1": "2.3*r", "length": 0.008, "segments": 12, "at": [0, "length/2", 0], "rot": [0, 0, 90]},
{"shape": "tube", "r0": "1.5*r", "r1": "1.5*r", "length": 0.008, "segments": 6, "at": [0, "-length/2", 0.008], "rot": [0, 0, 90]},
{"shape": "tube", "r0": "1.5*r", "r1": "1.5*r", "length": 0.008, "segments": 6, "at": [0, "length/2", 0.008], "rot": [0, 0, 90]}
],
"sockets": []
},
{
"name": "eye",
"doc": "A lifting eye: a bolted pad, a neck, and a ring standing in the plane of y and z.",
"params": [
{"name": "size", "type": "number", "min": 0.03, "max": 0.5, "default": 0.1, "doc": "the ring's outer diameter is 1.1 size"}
],
"shapes": [
{"shape": "box", "size": ["1.1*size", "2*size", 0.012], "at": [0, 0, 0.004]},
{"shape": "tube", "r0": "0.11*size", "r1": "0.11*size", "length": 0.008, "segments": 6, "at": [0, "-0.72*size", 0.01], "rot": [0, 0, 90]},
{"shape": "tube", "r0": "0.11*size", "r1": "0.11*size", "length": 0.008, "segments": 6, "at": [0, "0.72*size", 0.01], "rot": [0, 0, 90]},
{"shape": "box", "size": ["0.34*size", "0.5*size", "0.24*size"], "at": [0, 0, "0.012+0.1*size"]},
{"shape": "lathe", "segments": 20, "loop": true, "profile": [["0.55*size", 0], ["0.5119238815542512*size", "0.09192388155425119*size"], ["0.42*size", "0.13*size"], ["0.3280761184457488*size", "0.09192388155425119*size"], ["0.29*size", 0], ["0.3280761184457488*size", "-0.09192388155425119*size"], ["0.42*size", "-0.13*size"], ["0.5119238815542512*size", "-0.09192388155425119*size"]], "at": [0, 0, "0.012+0.62*size"], "rot": [0, 90, 0]}
],
"sockets": []
},
{
"name": "louvres",
"doc": "A framed bank of n slanted slats, w by h between the frame's middles: x along the slats, y up.",
"params": [
{"name": "w", "type": "number", "min": 0.1, "max": 4, "default": 0.6, "doc": "across (x), between the side bars' middles"},
{"name": "h", "type": "number", "min": 0.1, "max": 4, "default": 0.72, "doc": "along up (y), between the top and bottom bars' middles"},
{"name": "n", "type": "integer", "min": 1, "max": 64, "default": 6, "doc": "slats"},
{"name": "depth", "type": "number", "min": 0.01, "max": 0.5, "default": 0.05, "doc": "how far the frame stands"},
{"name": "frame", "type": "number", "min": 0.01, "max": 0.5, "default": 0.07, "doc": "the frame bars' width, under w and h"},
{"name": "slant", "type": "number", "min": 0, "max": 80, "default": 25, "doc": "degrees a slat is tilted about x"}
],
"shapes": [
{"shape": "box", "size": ["w+frame", "frame", "depth"], "at": [0, "-0.5*h", "0.5*depth"]},
{"shape": "box", "size": ["w+frame", "frame", "depth"], "at": [0, "0.5*h", "0.5*depth"]},
{"shape": "box", "size": ["frame", "h+frame", "depth"], "at": ["-0.5*w", 0, "0.5*depth"]},
{"shape": "box", "size": ["frame", "h+frame", "depth"], "at": ["0.5*w", 0, "0.5*depth"]},
{"shape": "repeat", "count": "n", "step": [0, "(h-frame)/n", 0], "of": {"shape": "box", "size": ["w-frame", "0.75*(h-frame)/n", "0.25*depth"], "at": [0, "-0.5*(h-frame)+0.5*(h-frame)/n", "0.3*depth"], "rot": ["slant", 0, 0]}}
],
"sockets": []
}
]
}

View file

@ -0,0 +1,172 @@
{
"schema": "brokkr.kit.v0",
"kit": "frame",
"doc": "Chassis structure: sectioned beams, a truss, a portal, a gusset and a wedge, each a section swept along a path. Metres.",
"socketTypes": {
"mount": {"match": "fits", "doc": "flat seat; size is the free diameter around the socket"},
"pivot": {"match": "equal", "dof": "revolute", "doc": "pin joint; size is the pin diameter"}
},
"parts": [
{
"name": "beam_i",
"doc": "I beam along +z: two flanges across x joined by a web along y.",
"params": [
{"name": "length", "type": "number", "min": 0.1, "max": 6.0, "default": 1.0, "doc": "end face to end face (z)"},
{"name": "w", "type": "number", "min": 0.03, "max": 0.4, "default": 0.08, "doc": "width (x)"},
{"name": "h", "type": "number", "min": 0.03, "max": 0.4, "default": 0.12, "doc": "height (y)"},
{"name": "t", "type": "number", "min": 0.003, "max": 0.05, "default": 0.01, "doc": "wall thickness; held under 0.45 of the smaller of w and h"}
],
"shapes": [
{"shape": "extrude", "section": "I", "w": "w", "h": "h", "t": "min(t,0.45*min(w,h))", "path": [[0, 0, 0], [0, 0, "length"]], "up": [0, 1, 0]}
],
"sockets": [
{"name": "end_a", "type": "mount", "size": "min(w,h)", "at": [0, 0, 0], "z": "-z", "y": "+y"},
{"name": "end_b", "type": "mount", "size": "min(w,h)", "at": [0, 0, "length"], "z": "+z", "y": "+y"}
]
},
{
"name": "channel",
"doc": "Channel (C section) along +z: the web on -x, the flanges opening toward +x. Its end sockets sit on the web.",
"params": [
{"name": "length", "type": "number", "min": 0.1, "max": 6.0, "default": 1.0, "doc": "end face to end face (z)"},
{"name": "w", "type": "number", "min": 0.03, "max": 0.4, "default": 0.08, "doc": "width (x)"},
{"name": "h", "type": "number", "min": 0.03, "max": 0.4, "default": 0.12, "doc": "height (y)"},
{"name": "t", "type": "number", "min": 0.003, "max": 0.05, "default": 0.01, "doc": "wall thickness; held under 0.45 of the smaller of w and h"}
],
"shapes": [
{"shape": "extrude", "section": "C", "w": "w", "h": "h", "t": "min(t,0.45*min(w,h))", "path": [[0, 0, 0], [0, 0, "length"]], "up": [0, 1, 0]}
],
"sockets": [
{"name": "end_a", "type": "mount", "size": "min(w,h)", "at": ["min(t,0.45*min(w,h))/2-w/2", 0, 0], "z": "-z", "y": "+y"},
{"name": "end_b", "type": "mount", "size": "min(w,h)", "at": ["min(t,0.45*min(w,h))/2-w/2", 0, "length"], "z": "+z", "y": "+y"}
]
},
{
"name": "tee",
"doc": "Tee along +z: the flange across x at +y, the stem down the middle.",
"params": [
{"name": "length", "type": "number", "min": 0.1, "max": 6.0, "default": 1.0, "doc": "end face to end face (z)"},
{"name": "w", "type": "number", "min": 0.03, "max": 0.4, "default": 0.08, "doc": "width (x)"},
{"name": "h", "type": "number", "min": 0.03, "max": 0.4, "default": 0.12, "doc": "height (y)"},
{"name": "t", "type": "number", "min": 0.003, "max": 0.05, "default": 0.01, "doc": "wall thickness; held under 0.45 of the smaller of w and h"}
],
"shapes": [
{"shape": "extrude", "section": "T", "w": "w", "h": "h", "t": "min(t,0.45*min(w,h))", "path": [[0, 0, 0], [0, 0, "length"]], "up": [0, 1, 0]}
],
"sockets": [
{"name": "end_a", "type": "mount", "size": "min(w,h)", "at": [0, 0, 0], "z": "-z", "y": "+y"},
{"name": "end_b", "type": "mount", "size": "min(w,h)", "at": [0, 0, "length"], "z": "+z", "y": "+y"}
]
},
{
"name": "angle",
"doc": "Angle (L section) along +z: one leg along x at -y, one along y at -x. Its end sockets sit on the upright leg.",
"params": [
{"name": "length", "type": "number", "min": 0.1, "max": 6.0, "default": 1.0, "doc": "end face to end face (z)"},
{"name": "w", "type": "number", "min": 0.03, "max": 0.4, "default": 0.08, "doc": "width (x)"},
{"name": "h", "type": "number", "min": 0.03, "max": 0.4, "default": 0.12, "doc": "height (y)"},
{"name": "t", "type": "number", "min": 0.003, "max": 0.05, "default": 0.01, "doc": "wall thickness; held under 0.45 of the smaller of w and h"}
],
"shapes": [
{"shape": "extrude", "section": "L", "w": "w", "h": "h", "t": "min(t,0.45*min(w,h))", "path": [[0, 0, 0], [0, 0, "length"]], "up": [0, 1, 0]}
],
"sockets": [
{"name": "end_a", "type": "mount", "size": "min(w,h)", "at": ["min(t,0.45*min(w,h))/2-w/2", 0, 0], "z": "-z", "y": "+y"},
{"name": "end_b", "type": "mount", "size": "min(w,h)", "at": ["min(t,0.45*min(w,h))/2-w/2", 0, "length"], "z": "+z", "y": "+y"}
]
},
{
"name": "box_beam",
"doc": "Solid rectangular bar along +z.",
"params": [
{"name": "length", "type": "number", "min": 0.1, "max": 6.0, "default": 1.0, "doc": "end face to end face (z)"},
{"name": "w", "type": "number", "min": 0.03, "max": 0.4, "default": 0.08, "doc": "width (x)"},
{"name": "h", "type": "number", "min": 0.03, "max": 0.4, "default": 0.12, "doc": "height (y)"}
],
"shapes": [
{"shape": "extrude", "section": "box", "w": "w", "h": "h", "t": "w", "path": [[0, 0, 0], [0, 0, "length"]], "up": [0, 1, 0]}
],
"sockets": [
{"name": "end_a", "type": "mount", "size": "min(w,h)", "at": [0, 0, 0], "z": "-z", "y": "+y"},
{"name": "end_b", "type": "mount", "size": "min(w,h)", "at": [0, 0, "length"], "z": "+z", "y": "+y"}
]
},
{
"name": "truss",
"doc": "Plane truss along +x in the xz plane: two square chords at z 0 and z height, a vertical at every bay and one diagonal per bay, rising then falling. Bays come in pairs.",
"params": [
{"name": "length", "type": "number", "min": 0.5, "max": 8.0, "default": 2.0, "doc": "first vertical's axis to the last's (x)"},
{"name": "height", "type": "number", "min": 0.1, "max": 1.5, "default": 0.3, "doc": "chord axis to chord axis (z)"},
{"name": "pairs", "type": "integer", "min": 1, "max": 16, "default": 4, "doc": "pairs of bays: a rising diagonal and a falling one"},
{"name": "chord", "type": "number", "min": 0.02, "max": 0.15, "default": 0.05, "doc": "side of the square chords"},
{"name": "web", "type": "number", "min": 0.01, "max": 0.1, "default": 0.03, "doc": "side of the square verticals and diagonals"}
],
"shapes": [
{"shape": "repeat", "count": 2, "step": [0, 0, "height"], "of":
{"shape": "extrude", "section": "box", "w": "chord", "h": "chord", "t": "chord", "path": [["-web/2", 0, 0], ["length+web/2", 0, 0]], "up": [0, 0, 1]}},
{"shape": "repeat", "count": "2*pairs+1", "step": ["length/(2*pairs)", 0, 0], "of":
{"shape": "extrude", "section": "box", "w": "web", "h": "web", "t": "web", "path": [[0, 0, 0], [0, 0, "height"]], "up": [0, 1, 0]}},
{"shape": "repeat", "count": "pairs", "step": ["length/pairs", 0, 0], "of":
{"shape": "extrude", "section": "box", "w": "web", "h": "web", "t": "web", "path": [[0, 0, 0], ["length/(2*pairs)", 0, "height"]], "up": [0, 1, 0]}},
{"shape": "repeat", "count": "pairs", "step": ["length/pairs", 0, 0], "of":
{"shape": "extrude", "section": "box", "w": "web", "h": "web", "t": "web", "path": [["length/(2*pairs)", 0, "height"], ["length/pairs", 0, 0]], "up": [0, 1, 0]}}
],
"sockets": [
{"name": "end_a", "type": "mount", "size": "height", "at": ["-web/2", 0, "height/2"], "z": "-x", "y": "+z"},
{"name": "end_b", "type": "mount", "size": "height", "at": ["length+web/2", 0, "height/2"], "z": "+x", "y": "+z"}
]
},
{
"name": "portal",
"doc": "Portal frame in the xz plane: one I section up a leg, across and down the other, mitred at both corners. Its web stands in the frame's plane; its flanges run across y on the inside and the outside of the frame.",
"params": [
{"name": "width", "type": "number", "min": 0.5, "max": 4.0, "default": 1.2, "doc": "leg axis to leg axis (x)"},
{"name": "height", "type": "number", "min": 0.4, "max": 3.0, "default": 0.9, "doc": "feet to the beam's axis (z)"},
{"name": "w", "type": "number", "min": 0.04, "max": 0.3, "default": 0.1, "doc": "flange width, across the frame's plane (y)"},
{"name": "h", "type": "number", "min": 0.04, "max": 0.3, "default": 0.1, "doc": "section height, flange to flange in the frame's plane"},
{"name": "t", "type": "number", "min": 0.004, "max": 0.04, "default": 0.01, "doc": "wall thickness; held under 0.45 of the smaller of w and h"}
],
"shapes": [
{"shape": "extrude", "section": "I", "w": "w", "h": "h", "t": "min(t,0.45*min(w,h))", "path": [["-width/2", 0, 0], ["-width/2", 0, "height"], ["width/2", 0, "height"], ["width/2", 0, 0]], "up": [[1, 0, 0], [1, 0, -1], [-1, 0, -1], [-1, 0, 0]]}
],
"sockets": [
{"name": "foot_a", "type": "mount", "size": "min(w,h)", "at": ["-width/2", 0, 0], "z": "-z", "y": "+y"},
{"name": "foot_b", "type": "mount", "size": "min(w,h)", "at": ["width/2", 0, 0], "z": "-z", "y": "+y"}
]
},
{
"name": "gusset",
"doc": "Corner plate: a right triangle with its legs along +x and +y from the origin, each acute tip cut square, thickness along +z.",
"params": [
{"name": "w", "type": "number", "min": 0.04, "max": 0.5, "default": 0.15, "doc": "leg along x"},
{"name": "h", "type": "number", "min": 0.04, "max": 0.5, "default": 0.15, "doc": "leg along y"},
{"name": "t", "type": "number", "min": 0.003, "max": 0.05, "default": 0.015, "doc": "flat that cuts each tip; held under 0.45 of the shorter leg"},
{"name": "thickness", "type": "number", "min": 0.003, "max": 0.05, "default": 0.01, "doc": "plate thickness (z)"}
],
"shapes": [
{"shape": "extrude", "section": "gusset", "w": "w", "h": "h", "t": "min(t,0.45*min(w,h))", "path": [[0, 0, 0], [0, 0, "thickness"]], "up": [0, 1, 0], "at": ["w/2", "h/2", 0]}
],
"sockets": [
{"name": "leg_a", "type": "mount", "size": "thickness", "at": ["w/2", 0, "thickness/2"], "z": "-y", "y": "+z"},
{"name": "leg_b", "type": "mount", "size": "thickness", "at": [0, "h/2", "thickness/2"], "z": "-x", "y": "+z"}
]
},
{
"name": "wedge",
"doc": "Wedge (a toe cap, a ramp, a chock) along +x: its base on z 0, its tall back at -y, sloping down to a front lip at +y.",
"params": [
{"name": "length", "type": "number", "min": 0.05, "max": 2.0, "default": 0.3, "doc": "x size"},
{"name": "w", "type": "number", "min": 0.05, "max": 1.0, "default": 0.25, "doc": "base, back to front (y)"},
{"name": "h", "type": "number", "min": 0.03, "max": 0.5, "default": 0.12, "doc": "back height (z)"},
{"name": "t", "type": "number", "min": 0.005, "max": 0.3, "default": 0.03, "doc": "front height; held under 0.9 of h"}
],
"shapes": [
{"shape": "extrude", "section": "wedge", "w": "w", "h": "h", "t": "min(t,0.9*h)", "path": [[0, 0, 0], ["length", 0, 0]], "up": [0, 0, 1], "at": [0, 0, "h/2"]}
],
"sockets": [
{"name": "base", "type": "mount", "size": "min(length,w)", "at": ["length/2", 0, 0], "z": "-z", "y": "+y"},
{"name": "back", "type": "mount", "size": "min(length,h)", "at": ["length/2", "-w/2", "h/2"], "z": "-y", "y": "+z"}
]
}
]
}

View file

@ -5,7 +5,9 @@
"socketTypes": {
"flange": {"match": "equal", "doc": "bolted pipe or duct face; size is the bore diameter"},
"mount": {"match": "fits", "doc": "flat seat; size is the free diameter around the socket"},
"pivot": {"match": "equal", "doc": "pin joint; size is the pin diameter"}
"pivot": {"match": "equal", "dof": "revolute", "doc": "pin joint; size is the pin diameter"},
"slide": {"match": "equal", "dof": "prismatic", "doc": "telescoping bore; size is the bore diameter; the child slides along the socket's z"},
"hose": {"match": "fits", "doc": "hose port; size is the widest bundle it takes"}
},
"parts": [
{
@ -173,7 +175,62 @@
{"name": "base", "type": "pivot", "size": "0.9*body_r", "at": [0, "0.65*body_r", "0.8*body_r"], "z": "+y", "y": "+z"},
{"name": "base_back", "type": "pivot", "size": "0.9*body_r", "at": [0, "-0.65*body_r", "0.8*body_r"], "z": "-y", "y": "+z"},
{"name": "rod_end", "type": "pivot", "size": "0.9*body_r", "at": [0, "0.65*body_r", "3.8*body_r+body_len+extension"], "z": "+y", "y": "+z"},
{"name": "rod_end_back", "type": "pivot", "size": "0.9*body_r", "at": [0, "-0.65*body_r", "3.8*body_r+body_len+extension"], "z": "-y", "y": "+z"}
{"name": "rod_end_back", "type": "pivot", "size": "0.9*body_r", "at": [0, "-0.65*body_r", "3.8*body_r+body_len+extension"], "z": "-y", "y": "+z"},
{"name": "port_cap", "type": "hose", "size": "0.4*body_r", "at": ["1.45*body_r", 0, "1.75*body_r"], "z": "+x", "y": "+z"},
{"name": "port_rod", "type": "hose", "size": "0.4*body_r", "at": ["1.45*body_r", 0, "2.25*body_r+body_len"], "z": "+x", "y": "+z"}
]
},
{
"name": "ram_barrel",
"doc": "The barrel of a tie-rod hydraulic cylinder, the actuator's up to its gland: base eye on a cross pin with a socket on each end face, square caps, barrel, ports, and a bore a ram_rod slides in.",
"params": [
{"name": "body_r", "type": "number", "min": 0.05, "max": 0.12, "default": 0.06, "doc": "barrel radius"},
{"name": "body_len", "type": "number", "min": 0.2, "max": 1.0, "default": 0.4, "doc": "barrel length between caps"},
{"name": "rod_r", "type": "number", "min": 0.01, "max": 0.02, "default": 0.018, "doc": "radius of the rod its gland takes"},
{"name": "segments", "type": "integer", "min": 8, "max": 48, "default": 24, "doc": "sides of every round"}
],
"bevel": "0.04*body_r",
"shapes": [
{"shape": "box", "size": ["1.2*body_r", "0.9*body_r", "1.6*body_r"], "at": [0, 0, "0.8*body_r"]},
{"shape": "tube", "r0": "0.45*body_r", "r1": "0.45*body_r", "length": "1.3*body_r", "segments": "segments", "smooth": true, "rot": [-90, 0, 0], "at": [0, "-0.65*body_r", "0.8*body_r"]},
{"shape": "box", "size": ["2.4*body_r", "2.4*body_r", "0.5*body_r"], "at": [0, 0, "1.75*body_r"]},
{"shape": "tube", "r0": "body_r", "r1": "body_r", "length": "body_len+0.2*body_r", "segments": "segments", "smooth": true, "at": [0, 0, "1.9*body_r"]},
{"shape": "box", "size": ["2.4*body_r", "2.4*body_r", "0.5*body_r"], "at": [0, 0, "2.25*body_r+body_len"]},
{"shape": "repeat", "count": 2, "step": ["1.9*body_r", 0, 0], "of":
{"shape": "tube", "r0": "0.12*body_r", "r1": "0.12*body_r", "length": "body_len+1.3*body_r", "segments": 6, "at": ["-0.95*body_r", "-0.95*body_r", "1.35*body_r"]}},
{"shape": "repeat", "count": 2, "step": ["1.9*body_r", 0, 0], "of":
{"shape": "tube", "r0": "0.12*body_r", "r1": "0.12*body_r", "length": "body_len+1.3*body_r", "segments": 6, "at": ["-0.95*body_r", "0.95*body_r", "1.35*body_r"]}},
{"shape": "repeat", "count": 2, "step": [0, 0, "body_len+0.5*body_r"], "of":
{"shape": "tube", "r0": "0.2*body_r", "r1": "0.2*body_r", "length": "0.45*body_r", "segments": "segments", "smooth": true, "rot": [0, 90, 0], "at": ["body_r", 0, "1.75*body_r"]}},
{"shape": "tube", "r0": "rod_r+0.25*body_r", "r1": "rod_r+0.25*body_r", "length": "0.4*body_r", "segments": "segments", "smooth": true, "at": [0, 0, "2.4*body_r+body_len"]}
],
"sockets": [
{"name": "base", "type": "pivot", "size": "0.9*body_r", "at": [0, "0.65*body_r", "0.8*body_r"], "z": "+y", "y": "+z"},
{"name": "base_back", "type": "pivot", "size": "0.9*body_r", "at": [0, "-0.65*body_r", "0.8*body_r"], "z": "-y", "y": "+z"},
{"name": "bore", "type": "slide", "size": "2*rod_r", "at": [0, 0, "2*body_r"], "z": "+z", "y": "+y"},
{"name": "port_cap", "type": "hose", "size": "0.4*body_r", "at": ["1.45*body_r", 0, "1.75*body_r"], "z": "+x", "y": "+z"},
{"name": "port_rod", "type": "hose", "size": "0.4*body_r", "at": ["1.45*body_r", 0, "2.25*body_r+body_len"], "z": "+x", "y": "+z"}
]
},
{
"name": "ram_rod",
"doc": "The rod of a hydraulic cylinder, the actuator's from its gland: a rod from its piston face to a rod eye on a cross pin with a socket on each end face. Its piston slides in a ram_barrel's bore: slide 0 is closed, the slide is the extension.",
"params": [
{"name": "body_r", "type": "number", "min": 0.05, "max": 0.12, "default": 0.06, "doc": "its barrel's radius: sizes the rod eye"},
{"name": "rod_r", "type": "number", "min": 0.01, "max": 0.02, "default": 0.018, "doc": "rod radius"},
{"name": "length", "type": "number", "min": 0.2, "max": 2.0, "default": 0.466, "doc": "piston face to the rod eye's block; its barrel's body_len + 1.1*body_r stands as the actuator does at extension 0"},
{"name": "segments", "type": "integer", "min": 8, "max": 48, "default": 24, "doc": "sides of every round"}
],
"bevel": "0.04*body_r",
"shapes": [
{"shape": "tube", "r0": "rod_r", "r1": "rod_r", "length": "length+0.2*body_r", "segments": "segments", "smooth": true, "at": [0, 0, 0]},
{"shape": "box", "size": ["1.2*body_r", "0.9*body_r", "1.4*body_r"], "at": [0, 0, "length+0.7*body_r"]},
{"shape": "tube", "r0": "0.45*body_r", "r1": "0.45*body_r", "length": "1.3*body_r", "segments": "segments", "smooth": true, "rot": [-90, 0, 0], "at": [0, "-0.65*body_r", "length+0.7*body_r"]}
],
"sockets": [
{"name": "piston", "type": "slide", "size": "2*rod_r", "at": [0, 0, 0], "z": "-z", "y": "+y"},
{"name": "rod_end", "type": "pivot", "size": "0.9*body_r", "at": [0, "0.65*body_r", "length+0.7*body_r"], "z": "+y", "y": "+z"},
{"name": "rod_end_back", "type": "pivot", "size": "0.9*body_r", "at": [0, "-0.65*body_r", "length+0.7*body_r"], "z": "-y", "y": "+z"}
]
},
{

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,968 @@
"""Rams and linkages across a one-axis hinge: numpy and the standard library only, and nothing from the package, so
a rig, a runtime or a test loads this file alone. Signed, the mesh oracle, asks for Blender's BVH tree when one is
made and not before.
A Mechanism is the record of one hinge's drive: the hinge (pivot, unit axis, lo and hi in degrees, positive
right-handed about the axis), a kind, and pins, each in its own body's rest frame (the pose at angle 0, where
every body's frame is the parent's).
direct the ram runs from a on the parent to b on the child.
four_bar a rocker pinned on the parent at `rocker` (R) carries the pin p; a coupler joins p to c on the child;
the ram runs from a on the parent to d on the rocker, and d is p (the excavator bucket linkage).
bell_crank the same loop with d elsewhere on the rocker.
Every pose quantity is a pure function of (record, angle): pose() holds no solve state. The loop is solved in the
plane across the axis; a pin's coordinate along the axis only says where its member stands: the rocker bars at R's,
the coupler bar at c's, the ram at a's plus each of `offsets`.
pose(m, degrees) every body's rotation, the ram's base and eye, L, dL/dtheta, per angle
length(m, degrees) pin-to-pin ram length
barrel_length(m, ram) the barrel the range's shorter end leaves room for
extension(m, ram, degrees) rod extension from closed
fit(m, ram, ...) the gates over the range: assembly, stroke, arm, load, clearance
clearance(m, ram, degrees, distance) the clearance gate's reading at any angles, per member and part
search(kind, hinge, ram, seats, ...) the best of a seat grid, or the tally and the nearest miss
record(m, ram), from_record the JSON record a rig or runtime drives from
swept(fit, body, ...) points of the swept ram's surface in a body's rest frame
winding(vertices, triangles, points) the generalized winding number of a triangle soup about points
inside(vertices, triangles, points) whether points are inside it: the number is 0.5 or more
weld(vertices, tolerance) the vertex each vertex is read as: those within the tolerance are one
solids(part, vertices, faces) the closed, outward wound solids of a part, or the refusal
placed(vertices, faces, matrix) a local mesh carried by a matrix, turned back where it mirrors
Signed(shells, cap) the distance oracle over meshes, signed by the winding number
Clearance. The record names the mechanism's `parts`, each a piece of one body (part -> the body whose rest frame
it turns with: a thigh's core, the bracket that carries the rocker's pivot, a link's plates, a pin), and `touch`:
for each member of MEMBERS[kind], zones (part, pin, radius, depth). Every member meets every part. A zone lowers
what the member's samples keep from one part, and only within `radius` of the axis of `pin`, one of the member's
own (RIDES), measured across the hinge axis: there a sample may come as near the part as -depth and no nearer.
The part is one of a body that pin joins (JOINS: a the parent; the rocker's pivot the parent and the rocker; p the
rocker and the coupler; c the coupler and the child; b the child; d the rocker), or the record is refused: what a
member meets at a pin is of the bodies pinned there, and a part of any other body is never let near it.
depth is 0 for what is stacked beside the member on the pin (a plate, the bracket or horn the pin stands in: the
member's axis stays outside it, so a pin whose place along the axis is inside the part it claims to stand beside
is refused), the pin's radius for the pin through the member's eye, half the thickness for the member's own plate
or clevis. Beyond the radius the pair is checked like any other; nothing is exempt by a name, a length or the
member's own body. Every body of the kind owns at least one part, or the gate refuses.
A zone is bounded by its member. Its radius and its depth are finite and no more than the member's length from pin
to pin (a bar's between its pins; the ram's at the most its pins allow), which the record refuses by its pins
alone; its depth is no more than the member's eye on that pin (Ram.eye: e_a at the base, e_b at the rod's eye,
link_r on a bar), which from_record and the gate refuse, a world's answer included. Between two samples of which
either is in a zone, the gate does not trust the spacing: it halves the segment until the readings at its ends
prove it holds -depth throughout (see _between), so a part of any thickness that the axis crosses there is read.
The oracle is distance(part, points) -> distances, points (N, 3) in the rest frame of the part's body. A distance
is signed: negative inside the part, by any depth. The oracle may cap what it returns at Ram.reach(spacing),
outside a part only: a point inside reads negative however deep it lies. An oracle that cannot tell inside from
outside (a nearest-surface query on an open mesh) raises instead of answering; nan is refused here. It never reads
more than the true distance: the gate's proof between samples is that a distance changes by no more than the way
between two points.
A RamError of a gate (assembly, stroke, toggle, arm, load, clash) names the angle and the pin; one of the record
or of a call (an unknown kind, a range, a grid over the limit, a version) names the pin or the field it refuses.
"""
import itertools
import math
from dataclasses import dataclass, field, fields, replace
import numpy as np
KINDS = ("direct", "four_bar", "bell_crank")
BODIES = {"direct": ("parent", "child"), "four_bar": ("parent", "child", "rocker", "coupler"),
"bell_crank": ("parent", "child", "rocker", "coupler")}
PINS = {"direct": ("a", "b"), "four_bar": ("a", "rocker", "p", "c", "d"), "bell_crank": ("a", "rocker", "p", "c", "d")}
MEMBERS = {"direct": ("barrel", "rod"), "four_bar": ("barrel", "rod", "rocker", "coupler"),
"bell_crank": ("barrel", "rod", "rocker", "coupler", "rocker arm")}
EYE = {"direct": "b", "four_bar": "d", "bell_crank": "d"} # the pin the rod's eye rides
RIDES = {kind: {"barrel": ("a", EYE[kind]), "rod": ("a", EYE[kind]), "rocker": ("rocker", "p"), "coupler": ("p", "c"), "rocker arm": ("rocker", "d")}
for kind in KINDS} # member -> the pins at its start and its end
JOINS = {kind: {"a": ("parent",), "b": ("child",)} if kind == "direct" else
{"a": ("parent",), "rocker": ("parent", "rocker"), "p": ("rocker", "coupler"), "c": ("coupler", "child"), "d": ("rocker",)}
for kind in KINDS} # pin -> the bodies it joins: only their parts are zoned about it
GATES = ("assembly", "stroke", "toggle", "arm", "load", "clash")
SCHEMA, VERSION = "brokkr.ram", 2
ZONE = ("part", "pin", "radius", "depth") # a zone of `touch`, as the record writes it
BAND = 1e-9 # the loop is refused within this of a dead centre of the rocker and coupler
WELD = 3e-4 # of a part's extent: vertices no farther apart than this along every axis are one vertex to `solids`
NUDGE = 1e-6 # of a part's extent: how far off a face's centroid its two sides are read
THIN = 1.1e-4 # of a part's extent cubed: a region winding -1 where no solid's volume is negative is let be when it holds less
FINE = 64 # in a zone a segment between samples is halved down to spacing / FINE
class RamError(ValueError):
"""A refusal: the mechanism kind, the gate, the angle and the pin it failed at. `fit` holds the readings when
the gates got far enough to take them."""
def __init__(self, kind, gate, message, angle=None, pin=None, fit=None):
where = (f" at {angle:g} deg" if angle is not None else "") + (f" (pin {pin})" if pin else "")
super().__init__(f"{kind} ram: {gate}{where}: {message}")
self.kind, self.gate, self.angle, self.pin, self.fit = kind, gate, angle, pin, fit
def _number(kind, name, value, least=None):
"""A record's number: an int or a float, finite, never a bool, a string or null; above `least` when given."""
if isinstance(value, bool) or not isinstance(value, (int, float)) or not math.isfinite(value):
raise RamError(kind, "record", f"a finite number, got {value!r}", pin=name)
if least is not None and not value > least:
raise RamError(kind, "record", f"a number greater than {least:g}, got {value!r}", pin=name)
return float(value)
@dataclass
class Ram:
"""A ram's proportions. Lengths default from the bore radius. Every one is a finite number and the bore is
greater than 0, or the ram is refused naming the field (as the ram of `any` kind: a ram knows none)."""
bore: float
rod: float = None # rod radius
barrel_r: float = None # barrel outer radius
e_a: float = None # base pin centre to the barrel's back end
e_b: float = None # rod eye centre to the rod's shoulder (what stays out of the barrel, closed)
gland: float = None # piston and gland: barrel length that is not stroke
over: float = None # spare travel at each end of the stroke
tail: float = 0.0 # trunnion mount: barrel behind the base pin (replaces e_a)
min_arm: float = None # least effective arm |dL/dtheta|, length per radian
gap: float = None # least clearance to a body
link_r: float = None # half thickness of a rocker or coupler bar
max_load: float = 3.0 # greatest coupler pin load per unit ram force
def __post_init__(self):
b = self.bore = _number("any", "bore", self.bore, 0.0)
for name, value in (("rod", 0.5 * b), ("barrel_r", 1.25 * b), ("e_a", 1.7 * b), ("e_b", 1.7 * b), ("gland", 1.3 * b),
("over", 0.2 * b), ("min_arm", 1.5 * b), ("gap", 0.15 * b), ("link_r", 0.7 * b)):
if getattr(self, name) is None:
setattr(self, name, value)
for f in fields(self):
setattr(self, f.name, _number("any", f.name, getattr(self, f.name)))
@property
def back(self):
"""Signed distance from the base pin to the barrel's back end along the ram (negative: behind the pin)."""
return -self.tail if self.tail > 0 else self.e_a
def spacing(self, spacing=None):
return self.barrel_r if spacing is None else float(spacing)
def eye(self, member, pin):
"""The radius of a member's eye on one of its pins: the most a zone's depth lets its axis into a part."""
if member in ("barrel", "rod"):
return self.e_a if pin == "a" else self.e_b
return self.link_r
def reach(self, spacing=None):
"""The greatest distance the clearance gate asks of any member: what a distance oracle may cap at."""
return max(self.barrel_r, self.rod, self.link_r) + self.gap + self.spacing(spacing) / 2
def _flat(v, n):
"""v without its part along the unit axis n."""
return v - n * (v @ n)[..., None]
def _rot(v, n, t):
"""v (..., 3) turned about the unit axis n by t radians (Rodrigues); t broadcasts over v's leading shape."""
t = np.asarray(t, dtype=float)[..., None]
return v * np.cos(t) + np.cross(n, v) * np.sin(t) + n * (v @ n)[..., None] * (1.0 - np.cos(t))
def _angle(v0, v, n):
"""Signed angle about n from v0 to v, both across n."""
return np.arctan2(np.cross(v0, v) @ n, v @ v0)
@dataclass
class Mechanism:
kind: str
pivot: np.ndarray
axis: np.ndarray
lo: float
hi: float
a: np.ndarray
b: np.ndarray = None
rocker: np.ndarray = None
p: np.ndarray = None
c: np.ndarray = None
d: np.ndarray = None
offsets: tuple = (0.0,)
parts: dict = field(default_factory=dict) # part -> the body it turns with
touch: dict = field(default_factory=dict) # member -> zones (part, pin, radius, depth)
def __post_init__(self):
if self.kind not in KINDS:
raise RamError(str(self.kind), "record", f"kind is one of {', '.join(KINDS)}")
for name in ("pivot", "axis", "a", "b", "rocker", "p", "c", "d"):
value = getattr(self, name)
if value is not None:
value = np.array(value, dtype=float)
if value.shape != (3,) or not np.isfinite(value).all():
raise RamError(self.kind, "record", "three finite numbers", pin=name)
setattr(self, name, value)
if abs(np.linalg.norm(self.axis) - 1.0) > 1e-6:
raise RamError(self.kind, "record", f"the axis is a unit vector, length {np.linalg.norm(self.axis):.6f}", pin="axis")
self.lo, self.hi = float(self.lo), float(self.hi)
if not self.lo < self.hi or self.hi - self.lo > 360.0:
raise RamError(self.kind, "record", f"lo < hi and hi - lo <= 360, got {self.lo:g}..{self.hi:g}", angle=self.lo)
self.offsets = tuple(float(o) for o in self.offsets)
if not self.offsets:
raise RamError(self.kind, "record", "at least one offset: where the ram stands along the axis from a", pin="a")
self.parts = {str(part): body for part, body in dict(self.parts).items()}
for part, body in self.parts.items():
if body not in BODIES[self.kind]:
raise RamError(self.kind, "record", f"part {part!r} turns with {body!r}; this kind has {', '.join(BODIES[self.kind])}")
for name in ("a", "b", "rocker", "p", "c", "d"):
needed, given = name in PINS[self.kind], getattr(self, name) is not None
if needed != given:
raise RamError(self.kind, "record", "this kind needs the pin" if needed else "this kind has no such pin", pin=name)
touch = {}
for member, zones in dict(self.touch).items():
if member not in MEMBERS[self.kind]:
raise RamError(self.kind, "record", f"touch names {member!r}; this kind's members are {', '.join(MEMBERS[self.kind])}")
touch[member] = []
for zone in zones:
if isinstance(zone, (str, dict)) or len(zone) != 4:
raise RamError(self.kind, "record", f"{member}'s zone is (part, pin, radius, depth), got {zone!r}")
part, pin, radius, depth = zone
if part not in self.parts:
raise RamError(self.kind, "record", f"{member} may touch {part!r}, which is no part of the record")
if pin not in RIDES[self.kind][member]:
raise RamError(self.kind, "record", f"{member} may touch {part!r} about a pin it rides ({', '.join(RIDES[self.kind][member])}), not {pin!r}", pin=str(pin))
radius, depth = _number(self.kind, f"{member} {part} radius", radius, 0.0), _number(self.kind, f"{member} {part} depth", depth)
if depth < 0.0:
raise RamError(self.kind, "record", f"a depth of 0 or more, got {depth!r}", pin=f"{member} {part} depth")
if self.parts[part] not in JOINS[self.kind][pin]:
raise RamError(self.kind, "record", f"{member} may touch about {pin} a part of a body the pin joins ({', '.join(JOINS[self.kind][pin])}); "
f"{part!r} turns with {self.parts[part]}", pin=f"{member} {part} pin")
span = _span(self, member)
for name, value in (("radius", radius), ("depth", depth)):
if value > span:
raise RamError(self.kind, "record", f"a zone no wider or deeper than its member: {member} is at most {span:.4f} from pin to pin, got {value!r}",
pin=f"{member} {part} {name}")
touch[member].append((part, pin, radius, depth))
touch[member] = tuple(touch[member])
self.touch = touch
if self.kind == "direct":
return
n = self.axis
apart = float(np.linalg.norm(self.d - self.p))
if self.kind == "four_bar" and apart > 0.0:
raise RamError(self.kind, "record", f"a four-bar's ram eye is the rocker's coupler pin; d is {apart:.4f} from p", pin="d")
if self.kind == "bell_crank" and apart == 0.0:
raise RamError(self.kind, "record", "a bell crank's ram eye stands off the coupler pin; d on p is a four_bar", pin="d")
self.lr = float(np.linalg.norm(_flat(self.p - self.rocker, n)))
self.lc = float(np.linalg.norm(_flat(self.p - self.c, n)))
side = float(n @ np.cross(_flat(self.c - self.rocker, n), _flat(self.p - self.rocker, n)))
if min(self.lr, self.lc) < BAND or abs(side) < BAND:
raise RamError(self.kind, "assembly", "the rest pose is a dead centre: R, p and c are in line", pin="p")
self.branch = 1.0 if side > 0 else -1.0 # which side of R -> c the pin p keeps, through the whole range
def _span(m, member):
"""The most a member measures from pin to pin, by the pins alone: a bar's length across the axis; for the ram's
two, the base's and the eye's distances from the centre the eye turns about, added."""
if member in ("barrel", "rod"):
centre, eye = m.pivot if m.kind == "direct" else m.rocker, getattr(m, EYE[m.kind])
return float(np.linalg.norm(m.a - centre) + np.linalg.norm(eye - centre))
start, end = RIDES[m.kind][member]
return float(np.linalg.norm(_flat(getattr(m, end) - getattr(m, start), m.axis)))
def _eyes(m, ram):
"""Refuse a zone deeper than its member's eye on its pin."""
for member, zones in m.touch.items():
for part, pin, _, depth in zones:
if depth > ram.eye(member, pin):
raise RamError(m.kind, "record", f"a zone no deeper than its member's eye: {member}'s on {pin} is {ram.eye(member, pin):.4f}, got {depth!r}",
pin=f"{member} {part} depth")
@dataclass
class Pose:
degrees: np.ndarray # (S,)
base: np.ndarray # (S, 3) ram base pin, parent frame, at offset 0
eye: np.ndarray # (S, 3) ram eye
u: np.ndarray # (S, 3) unit vector base -> eye
L: np.ndarray # (S,) pin to pin
dL: np.ndarray # (S,) dL/dtheta, length per radian: the effective arm, signed
phi: np.ndarray = None # (S,) rocker angle from rest, radians, in (-pi, pi]
psi: np.ndarray = None # (S,) coupler angle from rest
dphi: np.ndarray = None # (S,) dphi/dtheta
P: np.ndarray = None # (S, 3) the rocker's coupler pin
C: np.ndarray = None # (S, 3) the child's coupler pin
load: np.ndarray = None # (S,) coupler pin load per unit ram force
mu_c: np.ndarray = None # (S,) transmission angle at c, degrees, folded to 0..90
mu_p: np.ndarray = None # (S,) transmission angle at p
def pose(m, degrees):
"""The mechanism at each of `degrees` (a number or an array): a pure function of the record and the angle."""
deg = np.atleast_1d(np.asarray(degrees, dtype=float))
t, n, O = np.radians(deg), m.axis, m.pivot
if m.kind == "direct":
eye = O + _rot(m.b - O, n, t)
base = np.broadcast_to(m.a, eye.shape)
L = np.linalg.norm(eye - base, axis=1)
u = (eye - base) / np.maximum(L, 1e-12)[:, None]
return Pose(deg, base, eye, u, L, (np.cross(n, eye - O) * u).sum(axis=1))
R = m.rocker
C = O + _rot(m.c - O, n, t)
g = _flat(C - R, n)
dist = np.linalg.norm(g, axis=1)
lo, hi = abs(m.lr - m.lc) + BAND, m.lr + m.lc - BAND
bad = (dist <= lo) | (dist >= hi)
if bad.any():
i = int(np.argmax(bad))
raise RamError(m.kind, "assembly", f"|c - R| is {dist[i]:.4f}, outside ({lo:.4f}, {hi:.4f}): the rocker ({m.lr:.4f}) and coupler "
f"({m.lc:.4f}) cannot close the loop, or reach a dead centre where the branch would change", angle=float(deg[i]), pin="c")
x = (m.lr * m.lr - m.lc * m.lc + dist * dist) / (2.0 * dist)
h = np.sqrt(np.maximum(m.lr * m.lr - x * x, 0.0))
across = g / dist[:, None]
v = across * x[:, None] + m.branch * np.cross(n, across) * h[:, None] # p - R across the axis
phi = _angle(_flat(m.p - R, n), v, n)
P = R + _rot(m.p - R, n, phi)
eye = R + _rot(m.d - R, n, phi)
w = _flat(P - C, n) # the coupler, c -> p
k = w / np.linalg.norm(w, axis=1)[:, None]
psi = _angle(_flat(m.p - m.c, n), w, n)
# the coupler's two ends move equally along it
dphi = (np.cross(n, C - O) * k).sum(axis=1) / (np.cross(n, P - R) * k).sum(axis=1)
base = np.broadcast_to(m.a, eye.shape)
L = np.linalg.norm(eye - base, axis=1)
u = (eye - base) / np.maximum(L, 1e-12)[:, None]
dL = (np.cross(n, eye - R) * u).sum(axis=1) * dphi
crank, link = _flat(O - C, n), _flat(R - P, n)
moment = np.abs(np.cross(-crank, k) @ n)
load = np.abs(dL) / np.maximum(moment, 1e-12)
mu_c = np.degrees(np.arcsin(np.clip(moment / np.linalg.norm(crank, axis=1), 0.0, 1.0)))
mu_p = np.degrees(np.arcsin(np.clip(np.abs(np.cross(link, k) @ n) / np.linalg.norm(link, axis=1), 0.0, 1.0)))
return Pose(deg, base, eye, u, L, dL, phi, psi, dphi, P, C, load, mu_c, mu_p)
def length(m, degrees):
"""Pin-to-pin ram length at each angle."""
return pose(m, degrees).L
def barrel_length(m, ram):
"""The barrel the mechanism leaves room for: the ram's length at the shorter end of the range, less the
overtravel, the base clevis (or nothing, on a trunnion) and the eye. L runs one way over a range that fits
(the toggle gate), so that end is the least. Derived, never stored: a record holds the pins and the ram."""
return _barrel(ram, pose(m, (m.lo, m.hi)).L)
def _barrel(ram, ends):
return float(min(ends[0], ends[-1])) - ram.over - ram.back - ram.e_b
def extension(m, ram, degrees):
"""Rod extension from closed at each angle: L - (back + barrel + e_b)."""
return pose(m, degrees).L - (ram.back + barrel_length(m, ram) + ram.e_b)
def _members(m, ram, barrel, p):
"""(member, label, start (S, 3), end (S, 3), radius, (pin at start, pin at end)) of every member in the parent
frame, each from pin to pin: the barrel from its back end, the rod to the eye, a bar between its pins."""
n, rides = m.axis, RIDES[m.kind]
for off in m.offsets:
base, tip = p.base + off * n, p.eye + off * n
front = base + p.u * (ram.back + max(barrel, 1e-6))
yield "barrel", f"barrel[{off:g}]", base + p.u * ram.back, front, ram.barrel_r, rides["barrel"]
yield "rod", f"rod[{off:g}]", front, tip, ram.rod, rides["rod"]
if m.kind == "direct":
return
R = np.broadcast_to(m.rocker, p.P.shape)
yield "rocker", "rocker", R, p.P - n * ((p.P - R) @ n)[:, None], ram.link_r, rides["rocker"]
yield "coupler", "coupler", p.P - n * ((p.P - p.C) @ n)[:, None], p.C, ram.link_r, rides["coupler"]
if m.kind == "bell_crank":
yield "rocker arm", "rocker arm", R, p.eye - n * ((p.eye - R) @ n)[:, None], ram.link_r, rides["rocker arm"]
def _into(m, p, body, pts):
"""Parent-frame points (S, N, 3) carried into a body's rest frame at each angle."""
n = m.axis
if body == "parent":
return pts
if body == "child":
return m.pivot + _rot(pts - m.pivot, n, -np.radians(p.degrees)[:, None])
if body == "rocker":
return m.rocker + _rot(pts - m.rocker, n, -p.phi[:, None])
return m.p + _rot(pts - p.P[:, None, :], n, -p.psi[:, None])
@dataclass
class Clearance:
margin: np.ndarray # (S,) the least margin of any checked pair at each angle
where: tuple # (angle, member label, part, pin) of the least: the pin is the member's nearer one
pairs: dict # (member label, part) -> (least margin, angle) of every pair: every member, every part
allowed: list # (member label, part) of every pair a zone of the record's `touch` lets near a pin
def clearance(m, ram, degrees, distance, spacing=None):
"""The clearance gate's reading. A member is clear where margin >= 0: each sample of its axis, taken at most
`spacing` apart (default barrel_r), is at least radius + gap + spacing / 2 from every part, measured in the
rest frame of the part's body at that angle. A sample is at most spacing / 2 from any point of the axis, so
the member's surface keeps the gap. Every member meets every part of the record. Inside a zone of `touch`
(within its radius of its pin's axis, across the hinge axis) a sample keeps -depth from the zone's part
instead: the margin there is the distance plus the depth, and the segment to the next sample is proved to
hold -depth throughout (_between). Two zones of one pair that both reach a sample let it the deeper."""
return _clearance(m, ram, barrel_length(m, ram), pose(m, degrees), distance, spacing)
def _between(kind, distance, part, pts, got, keep, zoned, floor):
"""(S,) the least margin found between samples, inf where none is: for each segment between consecutive samples
of which either is in a zone, whether the axis holds -depth (the deeper of its ends') all along it. A distance
changes by no more than the way between two points, so along a segment it is at least (g(a) + g(b) - |ab|) / 2;
where that does not prove the segment it is halved, the midpoint read (its margin is counted), down to `floor`.
A segment still unproved at the floor against a part the axis is held outside (depth 0) reads that bound, so
it is refused: the part is within floor / 2 of the axis there, crossed or touched. Against a part the axis may
enter, the samples' readings stand: a burial is read to floor / 2."""
out = np.full(len(pts), math.inf)
pair = zoned[:, :-1] | zoned[:, 1:]
row = np.nonzero(pair)[0]
a, b, ga, gb = pts[:, :-1][pair], pts[:, 1:][pair], got[:, :-1][pair], got[:, 1:][pair]
hold = np.minimum(keep[:, :-1], keep[:, 1:])[pair]
while len(row):
span = np.linalg.norm(b - a, axis=1)
bound = (ga + gb - span) / 2.0
unproved = (bound < hold) & (np.minimum(ga, gb) >= hold) # an end under its hold is already refused
touched = unproved & (span <= floor) & (hold == 0.0)
np.minimum.at(out, row[touched], bound[touched])
go = unproved & (span > floor)
if not go.any():
break
a, b, ga, gb, hold, row = (x[go] for x in (a, b, ga, gb, hold, row))
mid = (a + b) / 2.0
gm = np.asarray(distance(part, mid), dtype=float)
if np.isnan(gm).any():
raise RamError(kind, "oracle", f"the distance oracle answered nan for part {part!r}")
np.minimum.at(out, row, gm - hold)
a, b, ga, gb = np.concatenate([a, mid]), np.concatenate([mid, b]), np.concatenate([ga, gm]), np.concatenate([gm, gb])
hold, row = np.concatenate([hold, hold]), np.concatenate([row, row])
return out
def _clearance(m, ram, barrel, p, distance, spacing):
_eyes(m, ram)
for body in BODIES[m.kind]:
if body not in m.parts.values():
raise RamError(m.kind, "record", f"no part turns with body {body}: the clearance gate would pass it unseen")
step = ram.spacing(spacing)
out = Clearance(np.full(len(p.degrees), math.inf), None, {}, [])
least = math.inf
at = {"a": p.base, EYE[m.kind]: p.eye, "rocker": m.rocker, "p": p.P, "c": p.C} # each pin over the angles, parent frame
for member, label, start, end, radius, pins in _members(m, ram, barrel, p):
count = max(int(math.ceil(float(np.linalg.norm(end - start, axis=1).max()) / step)) + 1, 2)
pts = start[:, None, :] + (end - start)[:, None, :] * np.linspace(0.0, 1.0, count)[None, :, None]
need = radius + ram.gap + step / 2.0
seen = {}
for part, body in m.parts.items():
if body not in seen:
seen[body] = _into(m, p, body, pts).reshape(-1, 3)
got = np.asarray(distance(part, seen[body]), dtype=float).reshape(len(p.degrees), count)
if np.isnan(got).any():
raise RamError(m.kind, "oracle", f"the distance oracle answered nan for part {part!r}")
keep = np.full(got.shape, need) # what each sample keeps from the part
zoned = np.zeros(got.shape, dtype=bool)
zones = [zone for zone in m.touch.get(member, ()) if zone[0] == part]
for _, pin, reach, depth in zones:
across = np.linalg.norm(_flat(pts - np.broadcast_to(at[pin], start.shape)[:, None, :], m.axis), axis=2)
keep = np.where(across <= reach, np.minimum(keep, -depth), keep)
zoned |= across <= reach
over = got - keep
row = over.min(axis=1)
if zones:
out.allowed.append((label, part))
row = np.minimum(row, _between(m.kind, distance, part, seen[body].reshape(len(p.degrees), count, 3), got, keep, zoned, step / FINE))
out.margin = np.minimum(out.margin, row)
i = int(np.argmin(row))
out.pairs[(label, part)] = (float(row[i]), float(p.degrees[i]))
if row[i] < least:
least = float(row[i])
out.where = (float(p.degrees[i]), label, part, pins[int(np.argmin(over[i])) * 2 >= count])
return out
@dataclass
class Fit:
m: Mechanism
ram: Ram
why: list # (gate, angle, pin, message) of every gate that failed; empty when it fits
degrees: np.ndarray
l_min: float
l_max: float
travel: float # L_max - L_min
barrel: float # barrel length: barrel_length(m, ram)
closed: float # pin to pin with the rod home: back + barrel + e_b
stroke: float # travel the barrel holds
spare: float # stroke - (travel + 2 over): negative when the stroke does not fit
arm_min: float # least |dL/dtheta|
arm_at: float # the angle of it
arm_sign: int # 0 when dL/dtheta changes sign (a dead centre inside the range)
swing: float = 0.0 # the rocker's travel, degrees
load_max: float = 0.0 # greatest coupler pin load per unit ram force
mu_c: float = None # least transmission angle at c, degrees: reported, never gated
mu_p: float = None # least transmission angle at p
clear_min: float = math.inf # least clearance beyond what the gate asks; inf with no oracle
clear_at: tuple = None # (angle, member, part, pin) of it
pairs: dict = field(default_factory=dict) # (member, part) -> (least margin, angle) of every pair
allowed: list = field(default_factory=list) # (member, part) of every pair a zone of `touch` lets near a pin
table: list = field(default_factory=list) # (angle, L, dL/dtheta, clearance margin) per step
@property
def ok(self):
return not self.why
def error(self):
gate, angle, pin, message = self.why[0]
return RamError(self.m.kind, gate, message, angle=angle, pin=pin, fit=self)
def report(self):
"""One line for a log or a sheet."""
state = "OK" if self.ok else "NO (" + "; ".join(f"{g}: {msg}" for g, _, _, msg in self.why) + ")"
links = "" if self.m.kind == "direct" else f", rocker swing {self.swing:.1f}, pin load <= {self.load_max:.2f}, transmission >= {min(self.mu_c, self.mu_p):.1f} deg"
return (f"{state}: L {self.l_min:.3f}..{self.l_max:.3f}, barrel {self.barrel:.3f}, stroke {self.stroke:.3f} for travel {self.travel:.3f} "
f"(spare {self.spare:+.3f}), arm >= {self.arm_min:.3f}{links}, clear {self.clear_min:+.3f}")
def _fit(m, ram, steps=25, distance=None, spacing=None, clear=True):
"""Every gate's reading; raises only where the loop does not assemble or a bell crank's eye crowds its pin."""
if m.kind == "bell_crank" and np.linalg.norm(m.d - m.p) < 2.0 * ram.bore:
raise RamError(m.kind, "pins", f"the ram eye stands at least 2 bore ({2.0 * ram.bore:.4f}) from the coupler pin; d is {np.linalg.norm(m.d - m.p):.4f} from p", pin="d")
if (m.kind != "direct") and not (m.lo <= 0.0 <= m.hi):
pose(m, np.linspace(0.0, m.lo if m.lo > 0.0 else m.hi, steps)) # the branch is carried from rest: no dead centre on the way
p = pose(m, np.linspace(m.lo, m.hi, steps))
l_min, l_max = float(p.L.min()), float(p.L.max())
eye = EYE[m.kind]
travel = l_max - l_min
barrel = _barrel(ram, p.L) # the samples' ends are lo and hi: barrel_length's own two angles
stroke = barrel - ram.gland
spare = stroke - (travel + 2.0 * ram.over)
i = int(np.argmin(np.abs(p.dL)))
arm_min, arm_at = float(abs(p.dL[i])), float(p.degrees[i])
signs = set(np.sign(p.dL[np.abs(p.dL) > 1e-9]).tolist())
arm_sign = int(signs.pop()) if len(signs) == 1 else 0
f = Fit(m, ram, [], p.degrees, l_min, l_max, travel, barrel, ram.back + barrel + ram.e_b, stroke, spare, arm_min, arm_at, arm_sign)
if barrel <= ram.gland or spare < -1e-9:
f.why.append(("stroke", float(p.degrees[int(np.argmin(p.L))]), eye, f"travel {travel:.3f} needs {travel + 3.0 * ram.over + ram.gland + ram.back + ram.e_b:.3f} closed, L_min is {l_min:.3f}"))
if arm_sign == 0:
flip = np.nonzero(np.sign(p.dL[1:]) != np.sign(p.dL[:-1]))[0]
f.why.append(("toggle", float(p.degrees[flip[0] + 1]) if len(flip) else arm_at, eye, "dL/dtheta changes sign: a dead centre inside the range"))
elif arm_min < ram.min_arm:
f.why.append(("arm", arm_at, eye, f"least effective arm {arm_min:.3f} under {ram.min_arm:.3f}"))
if m.kind != "direct":
phi = np.degrees(np.unwrap(p.phi))
j = int(np.argmax(p.load))
f.swing, f.load_max = float(phi.max() - phi.min()), float(p.load[j])
f.mu_c, f.mu_p = float(p.mu_c.min()), float(p.mu_p.min())
if f.load_max > ram.max_load:
f.why.append(("load", float(p.degrees[j]), "c", f"coupler pin load {f.load_max:.2f} x the ram force, over {ram.max_load:.2f}"))
margin = np.full(steps, math.inf)
if distance is not None and clear:
c = _clearance(m, ram, barrel, p, distance, spacing)
margin, f.clear_at, f.pairs, f.allowed = c.margin, c.where, c.pairs, c.allowed
f.clear_min = float(margin.min())
if f.clear_min < 0.0:
angle, member, part, pin = f.clear_at
f.why.append(("clash", angle, pin, f"{member} is {-f.clear_min:.3f} inside the clearance of part {part!r} ({m.parts[part]})"))
f.table = [tuple(row) for row in np.stack([p.degrees, p.L, p.dL, margin], axis=1).tolist()]
return f
def fit(m, ram, steps=25, distance=None, spacing=None):
"""Check one mechanism from lo to hi. Gates, in order, each over all steps at once: assembly; stroke; effective
arm (one sign, and at least min_arm); coupler pin load (linkages); clearance, when a distance oracle is given
(see clearance: the record's parts say what it meets, its touch how near a pin).
Returns the Fit; a failed gate raises RamError, its `fit` holding the readings."""
f = _fit(m, ram, steps, distance, spacing)
if not f.ok:
raise f.error()
return f
@dataclass
class Search:
best: Fit # the winner, or the nearest miss when none fits
found: bool
tried: int
fits: int # candidates that pass every gate but clearance
tally: dict # gate -> candidates it failed (a candidate can fail several)
seat: dict # the winner's or nearest miss's pins
def report(self):
head = f"{self.fits} of {self.tried} candidates pass the gates before clearance" if self.found else f"no candidate of {self.tried} fits"
reasons = ", ".join(f"{k} {v}" for k, v in sorted(self.tally.items()))
return f"{head}{' (failed: ' + reasons + ')' if reasons else ''}; {'best' if self.found else 'nearest'}: {self.best.report() if self.best else 'none assembles'}"
def _polar(n, centre, toward, radii, step):
"""Points about `centre` across the axis n: each radius, every `step` degrees from the direction `toward`."""
e = _flat(np.asarray(toward, dtype=float) - centre, n)
if np.linalg.norm(e) < 1e-9:
e = _flat(np.array([0.0, 0.0, 1.0]) if abs(n[2]) < 0.9 else np.array([1.0, 0.0, 0.0]), n)
e = e / np.linalg.norm(e)
return [centre + r * _rot(e, n, math.radians(turn)) for r in radii for turn in range(0, 360, step)]
def candidates(kind, hinge, seats):
"""The pins of every candidate of a seat grid. direct: seats['a'] x seats['b']. Linkages: seats['rocker'] x
seats['c'] x p on a polar grid about R (lengths seats['link'] = (lo, hi, n), every 15 degrees) x seats['a'],
and for a bell crank x d on a polar grid about R (seats['d'] = (lo, hi, n), every 30 degrees). The ram's eye
(d, and a four-bar's p) stands at a's place along the axis, so the ram runs across it."""
n = np.asarray(hinge["axis"], dtype=float)
if kind == "direct":
return [{"a": a, "b": b} for a in seats["a"] for b in seats["b"]]
out = []
for R in seats["rocker"]:
R = np.asarray(R, dtype=float)
for c in seats["c"]:
for p in _polar(n, R, c, np.linspace(*seats["link"]), 15):
eyes = [p] if kind == "four_bar" else _polar(n, R, p, np.linspace(*seats["d"]), 30)
for a in seats["a"]:
a = np.asarray(a, dtype=float)
for d in eyes:
d = d - n * ((d - a) @ n)
out.append({"a": a, "rocker": R, "p": d if kind == "four_bar" else p, "c": c, "d": d})
return out
def search(kind, hinge, ram, seats, world=None, limit=20000, steps=25, spacing=None):
"""Seat a mechanism from a grid (see candidates). hinge = {pivot, axis, lo, hi, offsets (optional)}. Best
first: every gate but clearance over all candidates, then clearance in order of least arm, greatest first;
the first clear one wins. world(m) -> (parts, touch, distance) builds a candidate's own parts, the brackets
and links its pins place among them, and the oracle that answers for them: a linkage's links are the
candidate's, so no one oracle serves a grid. What it returns is read as a record's: anything but the three,
a part on no body of the kind, a zone that is not (part, pin the member rides, radius, depth) or one wider or
deeper than its member is refused. A grid past `limit` candidates is refused naming the count. A
miss returns the tally and the nearest miss (the least total shortfall: stroke, arm, load excess,
clearance)."""
pins = candidates(kind, hinge, seats)
if len(pins) > limit:
raise RamError(kind, "search", f"{len(pins)} candidates, over the limit of {limit}: thin the seat grid")
tally, passed, miss = {}, [], None
def missed(f, seat):
nonlocal miss
for gate in {g for g, _, _, _ in f.why}:
tally[gate] = tally.get(gate, 0) + 1
short = (max(-f.spare, 0.0) + max(ram.min_arm - f.arm_min, 0.0) + (ram.min_arm if f.arm_sign == 0 else 0.0)
+ max(f.load_max - ram.max_load, 0.0) + (max(-f.clear_min, 0.0) if f.clear_min < math.inf else 0.0))
if miss is None or short < miss[0]:
miss = (short, f, seat)
for seat in pins:
try:
m = Mechanism(kind, hinge["pivot"], hinge["axis"], hinge["lo"], hinge["hi"], offsets=hinge.get("offsets", (0.0,)), **seat)
f = _fit(m, ram, steps, clear=False)
except RamError as refusal:
tally[refusal.gate] = tally.get(refusal.gate, 0) + 1
continue
if f.ok:
passed.append((f, seat))
else:
missed(f, seat)
passed.sort(key=lambda entry: -entry[0].arm_min)
for f, seat in passed:
if world is None:
return Search(f, True, len(pins), len(passed), tally, seat)
made = world(f.m)
if not isinstance(made, tuple) or len(made) != 3 or not callable(made[2]):
raise RamError(kind, "search", f"world(m) returns (parts, touch, distance), got {type(made).__name__}")
parts, touch, distance = made
f = _fit(replace(f.m, parts=parts, touch=touch), ram, steps, distance, spacing)
if f.ok:
return Search(f, True, len(pins), len(passed), tally, seat)
missed(f, seat)
return Search(miss[1] if miss else None, False, len(pins), len(passed), tally, miss[2] if miss else None)
def record(m, ram):
"""The mechanism record: plain JSON types, everything a rig or runtime needs to drive the ram from the hinge
angle (from_record, then length or extension). It holds what is authored and nothing derived from it: barrel,
closed length and link lengths come from the pins and the ram."""
return {"schema": SCHEMA, "version": VERSION, "kind": m.kind,
"hinge": {"pivot": m.pivot.tolist(), "axis": m.axis.tolist(), "lo": m.lo, "hi": m.hi},
"pins": {name: getattr(m, name).tolist() for name in PINS[m.kind]}, "offsets": list(m.offsets),
"ram": {f.name: getattr(ram, f.name) for f in fields(Ram)},
"parts": dict(m.parts),
"touch": {member: [dict(zip(ZONE, zone)) for zone in zones] for member, zones in m.touch.items()}}
def from_record(data):
"""(Mechanism, Ram) of a record. A record of another schema or version (the integer 2: not 2.0, not true), with
a key this version does not know or without one it does, or with a value that is not its field's type (a finite
number, three of them, a name), or with a zone of a body its pin does not join, or wider or deeper than its
member, is refused whole, as a RamError naming the field: nothing is read past and dropped."""
if not isinstance(data, dict):
raise RamError("None", "record", f"a record is an object, got {type(data).__name__}")
kind, version = str(data.get("kind")), data.get("version")
if data.get("schema") != SCHEMA or type(version) is not int or version != VERSION:
raise RamError(kind, "record", f"this reader reads {SCHEMA} version {VERSION}; the record is {data.get('schema')} version {version!r}")
if kind not in KINDS:
raise RamError(kind, "record", f"kind is one of {', '.join(KINDS)}")
def keys(name, given, known):
if not isinstance(given, dict):
raise RamError(kind, "record", f"an object, got {type(given).__name__}", pin=name)
if set(given) != set(known):
raise RamError(kind, "record", f"the {name}'s keys are not version {VERSION}'s: unknown {sorted(set(given) - set(known), key=str)}, missing {sorted(set(known) - set(given))}")
def point(name, value):
if not isinstance(value, list) or len(value) != 3:
raise RamError(kind, "record", f"three finite numbers, got {value!r}", pin=name)
return [_number(kind, name, x) for x in value]
keys("record", data, ("schema", "version", "kind", "hinge", "pins", "offsets", "ram", "parts", "touch"))
hinge, pins, ram = data["hinge"], data["pins"], data["ram"]
keys("hinge", hinge, ("pivot", "axis", "lo", "hi"))
keys("pins", pins, PINS[kind])
keys("ram", ram, [f.name for f in fields(Ram)])
for name, value in ram.items():
_number(kind, name, value, 0.0 if name == "bore" else None)
if not isinstance(data["offsets"], list):
raise RamError(kind, "record", f"a list of numbers, got {data['offsets']!r}", pin="offsets")
if not isinstance(data["parts"], dict) or not all(isinstance(body, str) for body in data["parts"].values()):
raise RamError(kind, "record", "an object of part: body", pin="parts")
if not isinstance(data["touch"], dict):
raise RamError(kind, "record", "an object of member: zones", pin="touch")
touch = {}
for member, zones in data["touch"].items():
if not isinstance(zones, list):
raise RamError(kind, "record", f"{member}'s zones are a list, got {zones!r}", pin="touch")
for zone in zones:
keys(f"{member} zone", zone, ZONE)
touch[member] = [tuple(zone[key] for key in ZONE) for zone in zones]
m = Mechanism(kind, point("pivot", hinge["pivot"]), point("axis", hinge["axis"]), _number(kind, "lo", hinge["lo"]), _number(kind, "hi", hinge["hi"]),
offsets=tuple(_number(kind, "offsets", o) for o in data["offsets"]), parts=data["parts"], touch=touch,
**{name: point(name, value) for name, value in pins.items()})
ram = Ram(**ram)
_eyes(m, ram)
return m, ram
def swept(f, body, margin=0.0, steps=13, around=8):
"""Points on the swept ram's surface in a body's rest frame, the barrel radius grown by `margin`, a trunnion's
tail included: what a recess in that body must clear (their hull or bounding box)."""
m, ram = f.m, f.ram
if body not in BODIES[m.kind]:
raise RamError(m.kind, "swept", f"no body {body!r}; this kind has {', '.join(BODIES[m.kind])}")
p = pose(m, np.linspace(m.lo, m.hi, steps))
side = np.cross(p.u, m.axis)
side = side / np.linalg.norm(side, axis=1)[:, None]
up = np.cross(side, p.u)
turn = np.linspace(0.0, 2.0 * math.pi, around, endpoint=False)
ring = (ram.barrel_r + margin) * (np.cos(turn)[None, :, None] * side[:, None, :] + np.sin(turn)[None, :, None] * up[:, None, :])
pts = []
for off in m.offsets:
for centre in (p.base + off * m.axis + p.u * min(ram.back, 0.0), p.eye + off * m.axis):
pts.append(centre[:, None, :] + ring)
return _into(m, p, body, np.concatenate(pts, axis=1)).reshape(-1, 3)
def winding(vertices, triangles, points):
"""The generalized winding number of a triangle soup about each of `points` (Jacobson, Kavan and Sorkine-Hornung
2013): the triangles' signed solid angles, summed, over 4 pi. A triangle counts positive from the side its normal
points away from (counterclockwise seen from outside). About a closed mesh it is the whole number of times the
surface wraps the point: 0 outside, 1 inside, 2 where two solids of one mesh overlap, whether they share vertices
or cut through one another. About an open mesh it is a fraction that falls off toward the hole (the closed
mesh's number less the missing faces' share of the sphere about the point), and about a mesh wound inside out
it is the negative: neither has an inside to read, and Signed refuses both. The plain sum: a point costs every
triangle. The corners' offsets from the point are taken in double precision and the angles in single (2.4 times
the pace): the number is good to 1e-5 a millimetre off a face and to 1e-2 at 1e-7 off it, and nearer than that
its side of the face is not held."""
v, t, pts = np.asarray(vertices, dtype=float).reshape(-1, 3), np.asarray(triangles, dtype=int).reshape(-1, 3), np.asarray(points, dtype=float).reshape(-1, 3)
A, B, C = (np.ascontiguousarray(v[t[:, k]].T) for k in range(3)) # each (3, F): a corner of every triangle
out, step = np.zeros(len(pts)), max(1, 32768 // max(len(t), 1)) # a block of pairs that stays in cache: 3.1 times the pace of 400,000
for k in range(0, len(pts), step):
p = pts[k:k + step].T[:, :, None]
(ax, ay, az), (bx, by, bz), (cx, cy, cz) = ((corner[:, None, :] - p).astype(np.float32) for corner in (A, B, C))
la, lb, lc = np.sqrt(ax * ax + ay * ay + az * az), np.sqrt(bx * bx + by * by + bz * bz), np.sqrt(cx * cx + cy * cy + cz * cz)
volume = ax * (by * cz - bz * cy) + ay * (bz * cx - bx * cz) + az * (bx * cy - by * cx)
out[k:k + step] = np.arctan2(volume, la * lb * lc + (ax * bx + ay * by + az * bz) * lc + (bx * cx + by * cy + bz * cz) * la + (cx * ax + cy * ay + cz * az) * lb).sum(axis=1, dtype=float)
return out / (2.0 * math.pi)
def inside(vertices, triangles, points):
"""Whether each of `points` is inside the triangle soup: its winding number is 0.5 or more. About the closed,
outward wound solids `solids` passes the number is whole and any bound over 0 and up to 1 reads the same; 0.5
is the bound because it is the middle, the farthest from both whole numbers the single-precision sum rounds
about."""
return winding(vertices, triangles, points) >= 0.5
def weld(vertices, tolerance):
"""The vertex each of `vertices` is read as: one index, the least, for all that stand within `tolerance` of one
another along every axis, and for a chain of such. Two vertices are joined where no coordinate of theirs differs
by more than the tolerance, and only there, wherever the mesh stands: each vertex is compared with those of its
own cell and of the cells about it on one grid of the tolerance, and the grid only finds the pairs."""
v = np.asarray(vertices, dtype=float).reshape(-1, 3)
label = np.arange(len(v))
if not len(v) or not tolerance > 0.0:
return label
cell = np.floor((v - v.min(axis=0)) / (tolerance * (1.0 + 1e-9))).astype(np.int64) # two within the tolerance are in one cell or in two that touch
about = [step for step in itertools.product((-1, 0, 1), repeat=3) if step >= (0, 0, 0)] # a cell and half the 26 about it: each pair of cells once
at = np.unique(np.concatenate([cell + step for step in about]), axis=0, return_inverse=True)[1].reshape(len(about), len(v))
order, count = np.argsort(at[0], kind="stable"), np.bincount(at[0], minlength=int(at.max()) + 1)
start, first, second = np.cumsum(count) - count, [], []
for there in at:
n = count[there]
i = np.repeat(label, n)
j = order[np.repeat(start[there], n) + np.arange(int(n.sum())) - np.repeat(np.cumsum(n) - n, n)]
near = (np.abs(v[i] - v[j]) <= tolerance).all(axis=1)
first.append(i[near])
second.append(j[near])
first, second = np.concatenate(first), np.concatenate(second)
while True:
before, least = label, label.copy()
low = np.minimum(label[first], label[second])
np.minimum.at(least, first, low)
np.minimum.at(least, second, low)
label = least[least]
if (label == before).all():
return label
def _read(part, vertices, faces):
"""`solids`, and with each face's solid the fan of triangles, the faces of some area and the winding number
before each of those: what Signed keeps."""
v = np.asarray(vertices, dtype=float).reshape(-1, 3)
face_of = np.repeat(np.arange(len(faces)), [len(face) - 2 for face in faces])
fan = np.array([(face[0], face[k], face[k + 1]) for face in faces for k in range(1, len(face) - 1)], dtype=int).reshape(-1, 3)
extent = float(np.linalg.norm(np.ptp(v, axis=0))) if len(v) else 0.0
one = weld(v, WELD * extent)
owner, edges, seam = list(range(len(faces))), {}, np.zeros(len(faces), dtype=bool)
def root(k):
while owner[k] != k:
owner[k] = k = owner[owner[k]]
return k
for k, face in enumerate(faces):
face = [int(one[i]) for i in face]
seam[k] = len(set(face)) < 3 # the weld leaves it a point or a line
for i, j in zip(face, face[1:] + face[:1]):
if i != j:
there = edges.setdefault((min(i, j), max(i, j)), [k, 0])
there[1] += 1 if i < j else -1
owner[root(k)] = root(there[0])
of = np.array([root(k) for k in range(len(faces))], dtype=int)
names = {r: n for n, r in enumerate(dict.fromkeys(of.tolist()))} # solids numbered in the order of their first faces
unmatched = {}
for first, balance in edges.values():
if balance:
unmatched[names[of[first]]] = unmatched.get(names[of[first]], 0) + 1
for n, count in sorted(unmatched.items()):
raise RamError("mesh", "signed", f"part {part!r} is open: solid {n} of {len(names)} has {count} edge{'s' if count > 1 else ''} no face runs the other way")
of = np.array([names[r] for r in of.tolist()], dtype=int)
normal = np.zeros((len(faces), 3))
np.add.at(normal, face_of, np.cross(v[fan[:, 1]] - v[fan[:, 0]], v[fan[:, 2]] - v[fan[:, 0]]))
size = np.linalg.norm(normal, axis=1)
flat = np.flatnonzero(size > 0.0) # a face of no area has no side to be read on
centre = np.array([v[list(faces[k])].mean(axis=0) for k in flat]).reshape(-1, 3)
before = winding(v, fan, centre + NUDGE * extent * normal[flat] / size[flat, None])
turned = np.flatnonzero(before < -0.5)
if len(turned):
mid = v.mean(axis=0)
cone = np.einsum("ij,ij->i", v[fan[:, 0]] - mid, np.cross(v[fan[:, 1]] - mid, v[fan[:, 2]] - mid)) / 6.0
for n in dict.fromkeys(of[flat[turned]].tolist()): # the solids with a turned face, in the order of those faces
volume = math.fsum(cone[of[face_of] == n].tolist())
if volume < 0.0 and not seam[of == n].all(): # faces the weld closes up alone hold nothing: their sum is no volume
mine = flat[turned[of[flat[turned]] == n]]
raise RamError("mesh", "signed", f"part {part!r} is wound inside out: solid {n} of {len(names)} has a volume of {volume / extent ** 3:.3g} of the part's extent cubed, and {len(mine)} of its faces, from face {int(mine[0])}, stand before a region that winds {float(before[turned[of[flat[turned]] == n][0]]):.3g}")
unit, rungs = normal[flat[turned]] / size[flat[turned], None], NUDGE * 10.0 ** (np.arange(25) / 4.0) # the nudge to the whole extent, four to a decade
still = winding(v, fan, (centre[turned][:, None, :] + (rungs[1:] * extent)[None, :, None] * unit[:, None, :]).reshape(-1, 3)).reshape(len(turned), -1) < -0.5
held = float((0.5 * size[flat[turned]] * rungs[np.cumprod(still, axis=1).sum(axis=1)]).sum()) / extent ** 2
if held >= THIN:
k, area = int(flat[turned[0]]), size[flat[turned]]
about = (centre[turned] * area[:, None]).sum(axis=0) / area.sum()
reach = float(np.linalg.norm(centre[turned] - about, axis=1).max())
raise RamError("mesh", "signed", f"part {part!r} crosses itself: {len(turned)} faces, from face {k} of solid {int(of[k])} of {len(names)}, stand before a region that winds {float(before[turned[0]]):.3g} and holds {held:.3g} of the part's extent cubed, "
f"about ({about[0]:.4g}, {about[1]:.4g}, {about[2]:.4g}) and within {reach:.3g} of it, and no solid there has a negative volume: its surfaces cut through one another (cutters never joined, a fold), or a turned piece is welded into a whole one")
return of, fan, flat, before
def solids(part, vertices, faces):
"""The solid each face of a part belongs to (faces joined across an edge are one solid), or a RamError where
the part has no inside to sign. Nothing is repaired.
Open. Vertices within WELD of the part's extent (its box's diagonal) of one another along every axis are read
as one (`weld`), so a seam of coincident vertices is no hole. A solid with an edge no face runs the other way (a
boundary edge, or two faces wound against each other across it) is open.
A face is read NUDGE of the extent before its centroid, along its normal. Before a face of a whole solid the
winding number is 0, or more where another solid covers it. A face is turned where the number there is under
-0.5: it stands before a region that winds -1.
Inside out. A solid with a turned face whose signed volume (the sum of a . (b x c) / 6 over its triangles, summed
exactly) is negative is wound inside out, however little it holds: the bound is zero. A solid whose every face
the weld closes up to a point or a line is a seam's leftover and has no volume to read. The turned face tells it
from a cavity cut as its own inward shell, whose volume is negative too but whose faces have the cavity before
them, which winds 0: that passes. So does a sliver, two sheets back to back, with no volume and nothing between
the sheets to wind.
Crossing. Turned faces where no solid's volume is negative stand before a region where the part's surfaces cut
through one another: two cutters taken out of one solid and never joined, a bevel folded over a corner, a
lathe's profile crossing itself, or a turned piece welded into a whole one, which the volume of the one solid
hides. The region is measured: each turned face's area by how far out along its normal the number stays under
-0.5 (the nudge, then four rungs to a decade up to the extent), summed. A part whose region holds THIN of its
extent cubed or more is refused as crossing itself, with the faces, the region and where it lies (the turned
faces' centre by area, in the frame the vertices are given in, and how far the farthest is from it). Less is
let be: there the part reads outside in what its author took for inside."""
return _read(part, vertices, faces)[0]
def placed(vertices, faces, matrix):
"""A local mesh in the frame a 4 by 4 `matrix` carries it to: the vertices carried, and each face turned back
where the matrix mirrors (its determinant is negative), so a part mirrored by a negative scale is wound as its
own mesh is."""
m = np.asarray(matrix, dtype=float).reshape(4, 4)
v = np.asarray(vertices, dtype=float).reshape(-1, 3) @ m[:3, :3].T + m[:3, 3]
return v, [tuple(face)[::-1] if np.linalg.det(m[:3, :3]) < 0.0 else tuple(face) for face in faces]
class Signed:
"""The distance oracle over meshes: distance(part, points) is the distance to the part's surface, negative
where the point is inside the part (its depth), capped at `cap` outside only. shells: part -> [(vertices
(N, 3), faces)], in the rest frame of the part's body. Every solid of a part (`solids`) is closed and wound
counterclockwise seen from outside: a part that is open, wound inside out or crossing itself is refused when
the oracle is made, by a RamError that names the part and the solid with its edge count or its negative volume,
or the turned faces, their region and where it lies. A
shell may be (vertices, faces, matrix), a local mesh and the 4 by 4 that carries it to the body's rest frame:
it is read as `placed` gives it, the faces of a mirrored one (a negative scale) turned back, so a caller hands
a mirrored object's own mesh and its matrix and never a mesh it carried itself. Inside is where `inside`
says, by the winding number of all the part's faces (a face of more than three corners as a fan): solids that
overlap, in one mesh or several, welded or not, read inside wherever any is. The depth is to the nearest
exposed face: one whose centroid, set NUDGE of the part's extent off the face along its normal, is not inside
the part. A face buried in another solid is not the part's surface and is left out. A face that crosses
another solid is taken whole by where its centroid is: left out, the depth by it reads greater than it is;
kept, a point by its buried stretch reads shallower than the part's surface is. Outside, the distance is to
the nearest face of all. An unknown part raises. Needs Blender's mathutils (BVHTree) for the nearest face."""
def __init__(self, shells, cap=None):
from mathutils import Vector
from mathutils.bvhtree import BVHTree
self.cap, self.asked, self.vector, self.parts = cap, 0, Vector, {}
for part, made in shells.items():
verts, faces, at = [], [], 0
for v, f, *matrix in made:
v, f = placed(v, f, *matrix) if matrix else (np.asarray(v, dtype=float).reshape(-1, 3), f)
verts.append(v)
faces += [tuple(at + int(i) for i in face) for face in f]
at += len(v)
verts = np.concatenate(verts)
_, fan, flat, before = _read(part, verts, faces)
exposed = [faces[k] for k in flat[before < 0.5]]
if not exposed:
raise RamError("mesh", "signed", f"part {part!r} has no exposed face")
self.parts[part] = (BVHTree.FromPolygons(verts.tolist(), faces, epsilon=0.0), BVHTree.FromPolygons(verts.tolist(), exposed, epsilon=0.0), verts, fan)
def __call__(self, part, pts):
pts = np.asarray(pts, dtype=float).reshape(-1, 3)
self.asked += len(pts)
tree, surface, verts, fan = self.parts[part]
out = np.full(len(pts), math.inf if self.cap is None else self.cap)
for i in np.flatnonzero(inside(verts, fan, pts)):
out[i] = -surface.find_nearest(self.vector(pts[i]))[3]
for i in np.flatnonzero(out >= 0):
hit = tree.find_nearest(self.vector(pts[i]), self.cap) if self.cap else tree.find_nearest(self.vector(pts[i]))
if hit[0] is not None:
out[i] = hit[3]
return out

View file

@ -0,0 +1,656 @@
"""The path of a hose: from waypoints and a distance oracle to a curve with frames. numpy only, tested without
Blender (tests/test_route.py); brokkr_kitbash.hose is the bpy around it (docs/kitbash.md, Hoses between sockets).
A `distance` is a callable over (N, 3) points that answers how far each stands from the nearest obstacle; the caller
owns what an obstacle is and may cap the answer. `need` is how far a hose's centre line must stay from every
obstacle: the bundle's half width plus its clearance.
A leg between two waypoints is searched on a voxel grid of the box around them (grid, wavefront), then pulled taut
(pull). That polyline is a seed and no more: where its vertices stand follows the grid's lattice, so whether its
corners have straight enough for their bends does too. relax then moves, drops and adds vertices in continuous
space until every segment has the straight its corners' tangents take at the floor radius (strain), each move kept
only if the oracle proves its segments clear; tangents gives every corner its floor's tangent before any corner gets
more. leaves is the one proof of a bundle too stiff: a curve that bends no tighter than the floor cannot get out of
what stands about the end of a fitting's lead. A voxel is free when it stands need plus half a voxel's diagonal from every obstacle: distance changes by at
most the distance moved, so every point of a step between two neighbouring free voxels keeps need. The same bound is
what every measurement of a line rests on (measure): a reading answers for the piece around it, less half the piece's
length, and pieces are halved until that proves need, so nothing thinner than the spacing of some samples can stand
unseen between them; no measurement depends on the search's step. The legs joined are one polyline; fillet rounds its
corners, each by the largest arc its measured room allows, and verify measures the curve. sag lowers the middle of a leg
by what its room allows. passes turns the part of a polyline beyond a point on a pin's axis through the pin's rolls,
each roll answering for the rolls about it by what a point can move within them. frames gives the rotation-minimising ups the tubes are swept
with (Wang, Juettler, Zheng and Liu, "Computation of rotation minimizing frames", ACM TOG 27(1), 2008: the double
reflection method).
Every refusal is a RouteError that names the leg, corner, point or roll.
"""
from __future__ import annotations
import math
from typing import NamedTuple
import numpy as np
class RouteError(ValueError):
"""A route that cannot be made, in words that name where."""
class Blocked(RouteError):
"""A refusal that rests on where a waypoint stands, not on a search: no other grid lifts it."""
NEIGHBOURS = [(i, j, k) for i in (-1, 0, 1) for j in (-1, 0, 1) for k in (-1, 0, 1) if (i, j, k) != (0, 0, 0)]
REACH = math.sqrt(3.0) / 2.0 # of a voxel: how far a point of a step between two neighbouring voxels can stand from the nearer one
STRAIGHT = 1e-9 # radians: a corner that turns less is no corner
HELD = 1e-9 # metres under need that a reading may stand and hold it
FINE = 1e-3 # metres: the shortest piece measure halves to; a line must keep need by half of this to be proven
BEND = 1.0 - math.cos(math.pi / 4.0) # of a radius: how far the arc of a quarter turn stands from its tangent segments
ARC = 24 # arc segments a radian of turn
STIFF = math.radians(170.0) # a turn past this is priced as this one: its tangent at the floor is already 11 floors long
AXES = [np.array(v, dtype=np.float64) for v in ((1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, -1, 0), (0, 0, 1), (0, 0, -1))]
def spot(point) -> str:
return "[" + ", ".join(f"{float(v):.4g}" for v in point) + "]"
def bundle(count: int, radius: float, spread: float, clearance: float, bend: float) -> dict:
"""The sizes a bundle of `count` hoses of `radius` routes by. spread is centre to centre (0: 2.6 radii). width is
across the bundle; envelope its half; need is how far the centre line stays from obstacles; floor the least
radius of the centre line, bend outside diameters for the innermost hose, which runs half the bundle's spread
inside it; lead the straight a fitting keeps: a ferrule of 5 radii, then 1.5 outside diameters before any bend."""
spread = spread if spread > 0.0 else 2.6 * radius
half = (count - 1) / 2.0 * spread
return {"spread": spread, "width": 2.0 * half + 2.0 * radius, "envelope": half + radius, "need": half + radius + clearance,
"floor": bend * 2.0 * radius + half, "lead": 5.0 * radius + 1.5 * 2.0 * radius}
class Grid(NamedTuple):
"""Voxels of a box: free[i, j, k] is the voxel centred at lo + step * (i, j, k)."""
free: np.ndarray
lo: np.ndarray
step: float
def grid(lo, hi, step: float, distance, need: float, limit: int = 2 ** 19) -> Grid:
"""The voxels of the box lo..hi at `step` that stand at least `need` from every obstacle. Refuses a box of more
than `limit` voxels, naming a step that fits."""
lo, hi = np.asarray(lo, dtype=np.float64), np.asarray(hi, dtype=np.float64)
shape = lambda s: np.maximum(1, np.ceil((hi - lo) / s - 1e-9).astype(np.int64) + 1) # noqa: E731
n = shape(step)
if int(n.prod()) > limit:
fits = step
while int(shape(fits).prod()) > limit:
fits *= 1.05
raise RouteError(f"its search box of {spot(hi - lo)} m is {int(n.prod())} voxels at step {step:g}, over {limit}: a step of {math.ceil(fits * 1e4) / 1e4:g} fits")
axes = [lo[i] + step * np.arange(n[i]) for i in range(3)]
points = np.stack(np.meshgrid(*axes, indexing="ij"), axis=-1).reshape(-1, 3)
return Grid(free=(np.asarray(distance(points)) >= need).reshape(n), lo=lo, step=float(step))
def _grow(front: np.ndarray) -> np.ndarray:
"""The 26 neighbours of a front's voxels, by array shifts."""
n, padded, grown = front.shape, np.pad(front, 1), np.zeros(front.shape, dtype=bool)
for i, j, k in NEIGHBOURS:
grown |= padded[1 + i:1 + i + n[0], 1 + j:1 + j + n[1], 1 + k:1 + k + n[2]]
return grown
def wavefront(free: np.ndarray, start, goal) -> list:
"""The voxels of a shortest 26-connected way from start to goal through free voxels, both ends included: a
wavefront grown from the goal by array shifts, then walked down from the start, at each step to the neighbour one
wave nearer that stands nearest the goal. Refuses an end that is not free, and a start no wave reaches."""
start, goal, n = tuple(int(v) for v in start), tuple(int(v) for v in goal), free.shape
for name, voxel in (("start", start), ("end", goal)):
if not free[voxel]:
raise RouteError(f"its {name} voxel is not free")
unreached = np.iinfo(np.int32).max
waves = np.full(n, unreached, dtype=np.int32)
waves[goal] = 0
front = np.zeros(n, dtype=bool)
front[goal] = True
wave = 0
while waves[start] == unreached and front.any():
wave += 1
front = _grow(front) & free & (waves == unreached)
waves[front] = wave
if waves[start] == unreached:
raise RouteError("no free way joins its ends: obstacles close every way through its search box")
way, at = [start], start
while waves[at] > 0:
nearer = [(math.dist(m, goal), m) for m in ((at[0] + i, at[1] + j, at[2] + k) for i, j, k in NEIGHBOURS)
if all(0 <= m[axis] < n[axis] for axis in range(3)) and waves[m] == waves[at] - 1]
at = min(nearer)[1]
way.append(at)
return way
class Measured(NamedTuple):
least: float # the least reading taken; of a measure that fell short, the reading that fell short
where: np.ndarray # the point it was taken at
short: bool # a piece is not proven to keep need
def measure(a, b, distance, need: float, rate: float = 1.0, within: float | None = None) -> Measured:
"""The segments a[i]..b[i] measured so that what stands between two readings is bounded, not sampled. A piece's
middle reads d, and a reading changes by at most `rate` times the distance moved (1 for a distance to obstacles),
so every point of a piece of length L reads at least d - rate x L / 2. A piece whose bound holds need is proven;
one whose middle reads under need falls short; any other is halved, down to FINE, where a piece still unproven
falls short too: a measure that is not short has proven need of every point, and a line that keeps need by under
rate x FINE / 2 is refused with the ones that do not keep it. With `within`, pieces are halved further until each
one's bound is within that much of the least reading (or the piece is FINE long): least less `within` then bounds
every point from below."""
a, b = np.atleast_2d(np.asarray(a, dtype=np.float64)), np.atleast_2d(np.asarray(b, dtype=np.float64))
least, where = math.inf, None
while len(a):
middle, length = (a + b) / 2.0, np.linalg.norm(b - a, axis=1)
reads = np.asarray(distance(middle), dtype=np.float64)
bound = reads - rate * length / 2.0
unproven = bound < need - HELD
short = np.flatnonzero(unproven & ((reads < need - HELD) | (length <= FINE)))
if len(short):
worst = int(short[np.argmin(reads[short])])
return Measured(float(reads[worst]), middle[worst], True)
if reads.min() < least:
least, where = float(reads.min()), middle[int(np.argmin(reads))]
again = unproven if within is None else unproven | ((bound < least - within) & (length > FINE))
a, b = np.concatenate([a[again], middle[again]]), np.concatenate([middle[again], b[again]])
return Measured(least, where, False)
def falls(reading: float, need: float) -> str:
"""How a reading that fell short of need reads in a refusal."""
return (f"under the {need:.4g} m the bundle needs" if reading < need - HELD else
f"too near the {need:.4g} m the bundle needs to prove it of what stands between two readings")
def clear(a, b, distance, need: float, rate: float = 1.0) -> bool:
return not measure(a, b, distance, need, rate).short
def room(a, b, distance, need: float) -> float:
"""What every point of the segment a..b stands beyond need, less what verify needs to prove an arc that uses it
all: the least reading of a measure within FINE, less FINE for its bound and half of FINE more."""
return measure(a, b, distance, -math.inf, within=FINE).least - need - 1.5 * FINE
def span(curve, low: float, high: float) -> np.ndarray:
"""The part of a polyline between two lengths along it; no point when low is not under high."""
curve = np.asarray(curve, dtype=np.float64)
s = np.r_[0.0, np.cumsum(np.linalg.norm(np.diff(curve, axis=0), axis=1))]
low, high = max(low, 0.0), min(high, float(s[-1]))
if not low < high:
return curve[:0]
ends = np.stack([np.interp((low, high), s, curve[:, axis]) for axis in range(3)], axis=1)
return np.vstack([ends[:1], curve[(s > low) & (s < high)], ends[1:]])
def pull(points, distance, need: float, rate: float = 1.0) -> np.ndarray:
"""A polyline pulled taut: from each kept point, the farthest later point in clear sight (the line between them
swept at need); the next point when none is."""
points = np.asarray(points, dtype=np.float64)
kept, i = [points[0]], 0
while i < len(points) - 1:
j = len(points) - 1
while j > i + 1 and not clear(points[i], points[j], distance, need, rate):
j -= 1
kept.append(points[j])
i = j
return np.array(kept)
def leg(a, b, occupancy, distance, need: float, step: float, margin: float, limit: int, name: str, pad: float = 0.0, offset=(0.0, 0.0, 0.0)):
"""(the pulled polyline from a to b, the voxels searched): a grid over the two ends' box plus margin, free where
`occupancy` reads need plus pad plus REACH of a voxel, a wavefront between the free voxels beside the ends, pulled
against `distance`. `pad` is room kept beyond need for the bends the leg's corners will get: a line pulled at
need alone grazes what it wraps, and the corner there has no room for an arc. Within twice pad of an end the pull
asks for half the distance from that end instead, since an end stands where it is given. `offset`, in steps along
each axis, moves the lattice's origin: the polyline is a seed whose vertices follow the lattice, and another origin
gives another seed. Refuses, naming the leg: an end nearer an obstacle than need (Blocked: no grid lifts that), an
end with no free voxel in sight beside it, a box over the limit, and no way through."""
a, b = np.asarray(a, dtype=np.float64), np.asarray(b, dtype=np.float64)
for label, point in (("start", a), ("end", b)):
reads = float(np.asarray(distance(point[None]))[0])
if reads < need - HELD:
raise Blocked(f"{name}: its {label} {spot(point)} stands {reads:.4g} m from an obstacle, under the {need:.4g} m the bundle needs")
try:
cells = grid(np.minimum(a, b) - margin - step * np.asarray(offset, dtype=np.float64), np.maximum(a, b) + margin, step, occupancy, need + pad + REACH * step, limit)
except RouteError as error:
raise RouteError(f"{name}: {error}") from None
ends = []
for label, point in (("start", a), ("end", b)):
middle = np.clip(np.round((point - cells.lo) / step).astype(int), 0, np.array(cells.free.shape) - 1)
beside = [tuple(int(v) for v in middle + np.array(d)) for d in [(0, 0, 0)] + NEIGHBOURS]
beside = [m for m in beside if all(0 <= m[axis] < cells.free.shape[axis] for axis in range(3)) and cells.free[m]]
beside.sort(key=lambda m: float(np.linalg.norm(cells.lo + step * np.array(m) - point)))
seen = [m for m in beside if clear(point, cells.lo + step * np.array(m), distance, need)]
if not seen:
raise RouteError(f"{name}: no free voxel stands in sight of its {label} {spot(point)}: an obstacle is nearer it than {need + pad + REACH * step:.4g} m on every side")
ends.append(seen[0])
try:
way = wavefront(cells.free, ends[0], ends[1])
except RouteError as error:
raise RouteError(f"{name}: {error}") from None
padded = distance if pad <= 0.0 else lambda p: np.asarray(distance(p)) - np.minimum(pad, 0.5 * np.minimum(np.linalg.norm(p - a, axis=1), np.linalg.norm(p - b, axis=1)))
return pull(np.vstack([a[None], cells.lo + step * np.array(way, dtype=np.float64), b[None]]), padded, need, 1.0 if pad <= 0.0 else 1.5), int(cells.free.size)
def sag(points, depth: float, room, down=(0.0, 0.0, -1.0)):
"""(the polyline, the metres it was lowered): the middle of a leg's longest segment lowered by `depth`, less where
the segment runs along `down` (a hanging span sags, a vertical one does not) and never by more than half the room
`room(a, b)` measures along that segment: both halves then stand within that much of the taut segment, so they keep
need with as much room again for the arc at the middle. A segment shorter than 8 times the drop is left taut."""
points = np.asarray(points, dtype=np.float64)
lengths = np.linalg.norm(np.diff(points, axis=0), axis=1)
i = int(np.argmax(lengths))
a, b = points[i], points[i + 1]
across = np.asarray(down, dtype=np.float64) - (b - a) / lengths[i] * float(np.asarray(down) @ (b - a) / lengths[i])
hang = float(np.linalg.norm(across))
if depth <= 0.0 or hang < 1e-6:
return points, 0.0
drop = min(depth, 0.5 * (math.inf if room is None else float(room(a, b)))) * hang
if drop <= 1e-6 or lengths[i] < 8.0 * drop:
return points, 0.0
return np.vstack([points[:i + 1], ((a + b) / 2.0 + across / hang * drop)[None], points[i + 1:]]), drop
def _turns(points):
steps = np.diff(points, axis=0)
lengths = np.linalg.norm(steps, axis=1)
if (lengths < 1e-9).any():
raise RouteError(f"point {int(np.argmax(lengths < 1e-9))} {spot(points[int(np.argmax(lengths < 1e-9))])}: the segment from it is shorter than 1e-9")
unit = steps / lengths[:, None]
return lengths, unit, np.arccos(np.clip(np.einsum("ij,ij->i", unit[:-1], unit[1:]), -1.0, 1.0))
def _kept(count: int, lead: float, keep) -> np.ndarray:
keep = np.zeros(count) if keep is None else np.array(keep, dtype=np.float64)
keep[0] += lead
keep[-1] += lead
return keep
def _radius(point, before, after, turn: float, cap: float, room) -> float:
"""The largest radius of the arc at a corner whose tangent lengths stay within cap and whose room allows it: the
arc stands within radius x (1 - cos(turn / 2)) of its two tangent segments, so with that much room beyond need
measured along them it keeps need (the triangle inequality). The tangent segments grow with the radius, so the
room can only shrink: the largest radius is found by bisection."""
most = max(cap, 0.0) / math.tan(turn / 2.0)
if room is None:
return most
depth = 1.0 - math.cos(turn / 2.0)
def fits(radius: float) -> bool:
t = radius * math.tan(turn / 2.0)
return radius * depth <= min(room(point - before * t, point), room(point, point + after * t))
if fits(most):
return most
low, high = 0.0, most
for _ in range(24):
middle = (low + high) / 2.0
low, high = (middle, high) if fits(middle) else (low, middle)
return low
def _straights(lengths, lead: float, keep, centred):
"""(free, each, centred) of a polyline's segments: the straight a segment has to give its corners' tangents (its
length less what it keeps: `keep`, and `lead` more on the first and last), and what one end of it may take: all of
it, or half on a centred segment, whose kept straight stays in its middle."""
free = np.maximum(lengths - _kept(len(lengths), lead, keep), 0.0)
centred = np.zeros(len(lengths), dtype=bool) if centred is None else np.asarray(centred, dtype=bool)
return free, np.where(centred, free / 2.0, free), centred
def _floors(turn, floor: float, least) -> np.ndarray:
"""The tangent length each corner needs: its turn's at the floor radius, and `least` where that is more (a corner
that will turn further than it does here: the one at a pin)."""
need = floor * np.tan(np.minimum(turn, STIFF) / 2.0)
return need if least is None else np.maximum(need, np.asarray(least, dtype=np.float64))
def tangents(points, room, lead: float, keep=None, centred=None, floor: float = 0.0, least=None) -> np.ndarray:
"""The tangent length of the arc at each interior point of a polyline (0 where it runs straight on). Each corner
first gets the largest radius its room allows (_radius) within the straight its two segments have to give
(_straights). Where two corners' tangents overlap on a segment, each keeps what it needs (_floors: its tangent at
`floor`, or `least`) and what the segment has beyond that is shared in proportion to what each asked beyond its
need; a corner holds its `least` of a segment even where its arc here is shorter. Where the two needs do not fit
the segment both shrink in proportion, and fillet refuses the corner."""
points = np.asarray(points, dtype=np.float64)
lengths, unit, turn = _turns(points)
free, each, _ = _straights(lengths, lead, keep, centred)
t = np.zeros(len(turn))
for c in np.flatnonzero(turn >= STRAIGHT):
t[c] = _radius(points[c + 1], unit[c], unit[c + 1], float(turn[c]), float(min(each[c], each[c + 1])), room) * math.tan(turn[c] / 2.0)
need = _floors(turn, floor, least)
claim = np.maximum(t, need)
held = claim.copy()
for s in range(1, len(lengths) - 1): # segment s, between corners s - 1 and s
both, needs = claim[s - 1] + claim[s], need[s - 1] + need[s]
if both > free[s]:
for c in (s - 1, s):
held[c] = min(held[c], need[c] + (claim[c] - need[c]) * (free[s] - needs) / (both - needs) if needs <= free[s] else claim[c] * free[s] / both)
return np.minimum(t, held)
def strain(points, floor: float, lead: float, keep=None, centred=None, least=None) -> np.ndarray:
"""For each segment of a polyline, the straight its corners' tangents take at the floor radius beyond what the
segment has to give (_straights, _floors); all 0 where every corner has the straight for its bend. What fillet
refuses for want of straight, as lengths relax can lower."""
lengths, _, turn = _turns(np.asarray(points, dtype=np.float64))
free, each, centred = _straights(lengths, lead, keep, centred)
need = _floors(turn, floor, least)
first, last = np.r_[0.0, need], np.r_[need, 0.0] # of the corner a segment starts at, and the one it ends at
return np.where(centred, np.maximum(first - each, 0.0) + np.maximum(last - each, 0.0), np.maximum(first + last - free, 0.0))
def relax(points, tags, cost, clear, reach: float, rounds: int = 64):
"""(points, tags) of a polyline refined in continuous space until `cost(points, tags)`, an amount for each
segment, is all 0 or nothing tried lowers its sum. A vertex whose tag is None is free; the others stay. Each round
tries, about the segments that cost: a free vertex dropped; a free vertex moved by a length (first `reach`) along
each axis and along its two segments; and a vertex added at a segment's middle, moved that length along an axis.
The try that lowers the sum most among those whose changed segments `clear(a, b)` proves is kept; with none, the
length is halved, down to FINE. The oracle alone says what is clear: no lattice is read."""
points, tags = np.asarray(points, dtype=np.float64), list(tags)
def price(p, g):
try:
return float(np.sum(cost(p, g)))
except RouteError: # two vertices on one point
return math.inf
now, delta, most = price(points, tags), float(reach), len(points) + 4
for _ in range(rounds):
if not 0.0 < now < math.inf or delta < FINE:
break
strained = np.flatnonzero(np.asarray(cost(points, tags)) > 0.0)
tries = []
for v in sorted({v for s in strained for v in range(s - 1, s + 3) if 0 < v < len(points) - 1 and tags[v] is None}):
tries.append((np.delete(points, v, axis=0), tags[:v] + tags[v + 1:], (v - 1,)))
along = [(points[v + side] - points[v]) / max(float(np.linalg.norm(points[v + side] - points[v])), 1e-12) for side in (-1, 1)]
for way in AXES + along + [-d for d in along]:
moved = points.copy()
moved[v] += delta * way
tries.append((moved, tags, (v - 1, v)))
if len(points) < most:
for s in sorted({q for s in strained for q in (s - 1, s, s + 1) if 0 <= q < len(points) - 1}):
for way in AXES:
tries.append((np.insert(points, s + 1, (points[s] + points[s + 1]) / 2.0 + delta * way, axis=0), tags[:s + 1] + [None] + tags[s + 1:], (s, s + 1)))
priced = sorted(((price(p, g), index) for index, (p, g, _) in enumerate(tries)), key=lambda row: row[0])
for value, index in priced:
if not value < now - 1e-12:
delta /= 2.0
break
p, g, changed = tries[index]
if all(clear(p[q], p[q + 1]) for q in changed):
now, points, tags = value, p, g
break
else:
delta /= 2.0
return points, tags
def leaves(point, heading, floor: float, distance, need: float, cells: int = 6) -> bool:
"""Whether a curve that bends no tighter than `floor` and keeps need can get 2 floors away from `point`, which it
leaves along `heading`. False is a proof that none can: the bundle is too stiff for the room there.
Until such a curve is pi floors long it stays out of every ball of radius floor that touches its line at the
point and never falls behind the point (it has gone floor x sin(length / floor) along its heading), and by then
it stands at least 2 floors from the point (Schwarz's bound on a curve's chord; Dubins, "On curves of minimal
length with a constraint on average curvature", Amer. J. Math. 79, 1957). So it reaches the sphere of 2 floors
through points that keep need, stand outside those balls and are not behind the point. On voxels of floor / cells
a voxel is open unless its centre reads under need less REACH of a voxel, or stands more than that inside the
balls or behind the point: every point of such a curve then lies in an open voxel, and neighbouring points in neighbouring voxels.
When no open voxel on the sphere is joined to the point's, no curve exists; the grid sets how often the proof is
found, never whether it is true."""
point, heading = np.asarray(point, dtype=np.float64), np.asarray(heading, dtype=np.float64) / np.linalg.norm(heading)
step, n = floor / cells, 4 * cells + 3 # 2 floors and a voxel each way
axis = step * (np.arange(n) - (n - 1) / 2.0)
offsets = np.stack(np.meshgrid(axis, axis, axis, indexing="ij"), axis=-1).reshape(-1, 3)
along = offsets @ heading
inside = floor - np.sqrt((np.linalg.norm(offsets - along[:, None] * heading, axis=1) - floor) ** 2 + along ** 2)
opened = ((np.asarray(distance(point + offsets)) >= need - REACH * step) & (inside <= REACH * step) & (along >= -REACH * step)).reshape(n, n, n)
reached = np.zeros((n, n, n), dtype=bool)
reached[(n - 1) // 2, (n - 1) // 2, (n - 1) // 2] = True
while True:
front = _grow(reached) & opened & ~reached
if not front.any():
break
reached |= front
return bool((reached.reshape(-1) & (np.linalg.norm(offsets, axis=1) >= 2.0 * floor - REACH * step)).any())
def arcs(points, t):
"""(curve, owner): the polyline with the arc of tangent length t[c] at each interior point c + 1, as points
ARC to the radian, and for each curve point the corner whose arc it is on (-1 on the straights' ends). Every arc
is tangent to both its segments."""
points = np.asarray(points, dtype=np.float64)
_, unit, turn = _turns(points)
curve, owner = [points[0]], [-1]
for c in range(len(turn)):
corner, before, after = points[c + 1], unit[c], unit[c + 1]
if turn[c] < STRAIGHT or t[c] < 1e-9:
curve.append(corner)
owner.append(c)
continue
radius = t[c] / math.tan(turn[c] / 2.0)
inward = after - before * float(before @ after)
inward /= np.linalg.norm(inward)
centre = corner - before * t[c] + inward * radius
for angle in np.linspace(0.0, turn[c], max(2, int(math.ceil(turn[c] * ARC))) + 1):
curve.append(centre + radius * (before * math.sin(angle) - inward * math.cos(angle)))
owner.append(c)
curve.append(points[-1])
owner.append(-1)
curve, owner = np.array(curve), np.array(owner)
keep = np.r_[True, np.linalg.norm(np.diff(curve, axis=0), axis=1) > 1e-9]
return curve[keep], owner[keep]
class Filleted(NamedTuple):
curve: np.ndarray # (N, 3)
owner: np.ndarray # (N,) the corner a curve point's arc belongs to, -1 off the arcs
t: np.ndarray # tangent length at each interior point of the polyline
radii: np.ndarray # radius at each interior point, inf where the polyline runs straight on
def fillet(polyline, room, floor: float, lead: float, keep=None, centred=None, least=None) -> Filleted:
"""A polyline with its corners rounded (tangents, arcs). `room(a, b)` is the least obstacle distance along the
segment a..b less need, or None where nothing stands near. `least` is the tangent length a corner holds of its
segments whatever it turns here. Refuses a corner whose radius is under `floor`, naming the corner, its point, the
radius it got, the floor and what this polyline lacks there: it speaks of this polyline, not of every route."""
polyline = np.asarray(polyline, dtype=np.float64)
if len(polyline) < 3:
return Filleted(polyline, np.full(len(polyline), -1), np.zeros(0), np.zeros(0))
t = tangents(polyline, room, lead, keep, centred, floor, least)
turn = _turns(polyline)[2]
radii = np.where(turn >= STRAIGHT, t / np.tan(np.maximum(turn, STRAIGHT) / 2.0), np.inf)
under = np.flatnonzero(radii < floor * (1.0 - 1e-9))
if len(under):
c = int(under[np.argmin(radii[under])])
lengths, unit, _ = _turns(polyline)
each = _straights(lengths, lead, keep, centred)[1]
straight, tangent, depth = float(min(each[c], each[c + 1])), floor * math.tan(turn[c] / 2.0), floor * (1.0 - math.cos(turn[c] / 2.0))
if straight < tangent:
why = (f"the corner's segments leave {straight:.4g} m of straight for the {tangent:.4g} m its tangent takes at the floor "
"(a lower bend, thinner hoses, or ends, clamps and the pin point further apart)")
elif room is not None and _radius(polyline[c + 1], unit[c], unit[c + 1], float(turn[c]), straight, room) < floor * (1.0 - 1e-9):
stands = min(room(polyline[c + 1] - unit[c] * tangent, polyline[c + 1]), room(polyline[c + 1], polyline[c + 1] + unit[c + 1] * tangent))
why = (f"the route passes too near an obstacle to bend here: its segments stand {max(stands, 0.0):.4g} m clear beyond what the bundle needs and the arc at the floor takes {depth:.4g} "
"(a lower bend, more room about the obstacle, or a clamp that leads the hose wide of it)")
else:
why = "it shares a segment with the corner beside it and their tangents do not both fit on it (a lower bend, or the two further apart)"
raise RouteError(f"corner {c + 1} at {spot(polyline[c + 1])} turns {math.degrees(turn[c]):.1f} degrees and gets a bend of radius {radii[c]:.4g} m, under the floor {floor:.4g}: {why}")
return Filleted(*arcs(polyline, t), t, radii)
def verify(curve, distance, need: float, lead: float, name: str = "the hose") -> float:
"""The least distance the curve stands from an obstacle outside its two leads (the first and last `lead` of its
length, where it leaves its own ports), within half of FINE (measure). Refuses a curve not proven to keep need at
every point, naming the point."""
curve = np.asarray(curve, dtype=np.float64)
inside = span(curve, lead, float(np.linalg.norm(np.diff(curve, axis=0), axis=1).sum()) - lead)
if len(inside) < 2:
return math.inf
swept = measure(inside[:-1], inside[1:], distance, need, within=FINE / 2.0)
if swept.short:
raise RouteError(f"{name} stands {swept.least:.4g} m from an obstacle at {spot(swept.where)}, {falls(swept.least, need)}")
return swept.least
def thinned(curve, gap: float) -> np.ndarray:
"""A curve without the points that stand within `gap` of the point kept before them; its two ends stay. Where two
arcs meet tangent to tangent they can leave a straight far shorter than a tube is wide between them, and a
section swept over it would fold; with the short straight gone the two arcs meet at one point."""
curve = np.asarray(curve, dtype=np.float64)
kept = [0]
for index in range(1, len(curve)):
if np.linalg.norm(curve[index] - curve[kept[-1]]) > gap:
kept.append(index)
if kept[-1] != len(curve) - 1:
kept[-1 if len(kept) > 1 else len(kept):] = [len(curve) - 1]
return curve[kept]
def frames(curve, up0) -> np.ndarray:
"""An up for each point of a curve, rotation minimising: the first is up0 projected off the tangent, each next the
last reflected twice (Wang et al. 2008), so the ups do not twist about the curve. Tangents are the unit bisectors
core.sweep stands its sections on. Refuses an up0 along the first tangent."""
curve, up = np.asarray(curve, dtype=np.float64), np.asarray(up0, dtype=np.float64)
steps = np.diff(curve, axis=0)
steps = steps / np.linalg.norm(steps, axis=1)[:, None]
tangent = np.vstack([steps[:1], steps[:-1] + steps[1:], steps[-1:]])
tangent /= np.linalg.norm(tangent, axis=1)[:, None]
r = up - tangent[0] * float(up @ tangent[0])
if not np.linalg.norm(r) > 1e-6 * np.linalg.norm(up):
raise RouteError(f"up {spot(up)} runs along the curve's first tangent (or is zero)")
r = r / np.linalg.norm(r)
ups = [r]
for i in range(len(curve) - 1):
v1 = curve[i + 1] - curve[i]
c1 = float(v1 @ v1)
r_left = r - (2.0 / c1) * float(v1 @ r) * v1
t_left = tangent[i] - (2.0 / c1) * float(v1 @ tangent[i]) * v1
v2 = tangent[i + 1] - t_left
c2 = float(v2 @ v2)
r = r_left - (2.0 / c2) * float(v2 @ r_left) * v2 if c2 > 1e-18 else r_left
ups.append(r)
return np.array(ups)
def turned(points, origin, axis, degrees: float) -> np.ndarray:
"""Points turned `degrees` about the line through origin along axis, right-handed."""
axis = np.asarray(axis, dtype=np.float64) / np.linalg.norm(axis)
p = np.asarray(points, dtype=np.float64) - origin
c, s = math.cos(math.radians(degrees)), math.sin(math.radians(degrees))
return origin + p * c + np.cross(axis, p) * s + axis[None] * (p @ axis)[:, None] * (1.0 - c)
def sharpest_turn(before, after, axis, low: float, high: float) -> float:
"""The largest turn, in radians, from the unit `before` to the unit `after` turned about `axis` by any angle of
low..high degrees. The turn's cosine is a + b cos + c sin of the angle, least at one angle of a full turn: the
largest turn is there where the range holds that angle, and at an end of the range where it does not."""
axis = np.asarray(axis, dtype=np.float64) / np.linalg.norm(axis)
along = axis * float(after @ axis)
a, b, c = float(before @ along), float(before @ (after - along)), float(before @ np.cross(axis, after))
worst = math.degrees(math.atan2(-c, -b))
angles = [low, high] + [worst + 360.0 * k for k in range(-2, 3) if low < worst + 360.0 * k < high]
return max(math.acos(max(-1.0, min(1.0, a + b * math.cos(math.radians(v)) + c * math.sin(math.radians(v))))) for v in angles)
def rolls_of(low: float, high: float, step: float) -> list:
"""low, then every step up to high, and high."""
return [float(v) for v in np.arange(low, high - 1e-9, step)] + [float(high)]
def passes(polyline, t, j: int, origin, axis, rolls, finest: float, current: float, parent, child, need: float, floor: float, lead: float, keep=None) -> dict:
"""A hose through a pin's rolls, every roll between the first and last of `rolls` and not those alone. `polyline`
runs from the parent's side through point j, which stands on the pin's axis (origin, axis), to the child's side;
`t` are its tangent lengths at the roll `current`. The points beyond j turn about the axis with the child's parts
and the straights and bends on each side move with their own part; only the corner at j is rounded again.
Each roll of `rolls` answers for a bin: the rolls nearer it than any other. Within a bin of half width w a point
that stands rho from the axis moves at most rho x w against the other side's parts, so its reading against them
counts for that much less (`parent` and `child` read each side's parts where they stand at `current`; samples are
turned back for the child's). The bend at the pin has one radius through a bin, the largest that fits at the bin's
sharpest turn (sharpest_turn, over the bin's rolls): its arc then stands within radius x (1 - cos(turn / 2)) of its two tangent segments, which are swept
for need and that much more. Everything else outside the leads is swept for need (measure). A bin that falls short
is halved and measured at each half's middle, down to `finest` degrees of half width, where it is refused, naming
the roll, the side, the point and the reading; so is a bin whose bend at the pin has no room for the floor.
{rolls: how many were measured, worstRoll, least: the least reading, each less what its point moves within its
bin, lengthChange, radius}."""
polyline, origin = np.asarray(polyline, dtype=np.float64), np.asarray(origin, dtype=np.float64)
axis = np.asarray(axis, dtype=np.float64) / np.linalg.norm(axis)
c, least, lengths, radius = j - 1, (math.inf, None), [], math.inf
off = float(np.linalg.norm(np.cross(polyline[j] - origin, axis)))
if off > 1e-6: # a point counted wrong (a sag's point before it, say) would turn the hose about a point it does not pass
raise RouteError(f"point {j} {spot(polyline[j])} of the hose stands {off:.4g} m off the pin's axis: the hose passes the pin at a point on it")
kept, sharp = _kept(len(polyline) - 1, lead, keep), np.array(t, dtype=np.float64)
sharp[c] = 0.0
rolls = [float(v) for v in rolls]
edges = [rolls[0]] + [(u + v) / 2.0 for u, v in zip(rolls, rolls[1:])] + [rolls[-1]]
bins = [(edges[k + 1], edges[k], roll) for k, roll in reversed(list(enumerate(rolls)))] # a stack: the lowest roll is measured first
while bins:
high, low, roll = bins.pop()
half = max(high - roll, roll - low)
width = math.radians(half)
posed = np.vstack([polyline[:j + 1], turned(polyline[j + 1:], origin, axis, roll - current)])
back = lambda points, roll=roll: turned(points, origin, axis, current - roll) # noqa: E731
moves = lambda points: np.linalg.norm(np.cross(points - origin, axis), axis=1) * width # noqa: E731
sides = {"parent's side": lambda p: np.minimum(np.asarray(parent(p)), np.asarray(child(back(p))) - moves(p)),
"child's side": lambda p: np.minimum(np.asarray(child(back(p))), np.asarray(parent(p)) - moves(p))}
lengths_, unit, turn = _turns(posed)
corner, sharpest = posed[j], min(sharpest_turn(unit[c], unit[c + 1], axis, low - roll, high - roll), math.pi - 1e-6)
cap = min(lengths_[c] - kept[c] - (sharp[c - 1] if c > 0 else 0.0), lengths_[c + 1] - kept[c + 1] - (sharp[c + 1] if c + 1 < len(sharp) else 0.0))
def fits(bend: float):
"""None, or (side, the measure that fell short, the dip) of the bend's two tangent segments at the bin's sharpest turn."""
reach, depth = bend * math.tan(sharpest / 2.0), bend * (1.0 - math.cos(sharpest / 2.0))
for side, a, b in (("parent's side", corner - unit[c] * reach, corner), ("child's side", corner, corner + unit[c + 1] * reach)):
swept = measure(a, b, sides[side], need + depth, 1.0 + width)
if swept.short:
return side, swept, depth
return None
failed, bend, reach = None, math.inf, 0.0
if sharpest >= STRAIGHT:
most = max(cap, 0.0) / math.tan(sharpest / 2.0)
if most < floor * (1.0 - 1e-9):
failed = (f"the bend at the pin turns up to {math.degrees(sharpest):.1f} degrees and its segments leave room for a radius of {most:.4g} m, under the floor {floor:.4g}", None)
else:
short = fits(floor)
if short is not None:
failed = (f"the bend at the pin turns up to {math.degrees(sharpest):.1f} degrees and at the floor radius {floor:.4g} its arc can dip {short[2]:.4g} m; "
f"the hose's {short[0]} beside it", short[1], need + short[2])
else:
bend, high_ = floor, most
for _ in range(12 if fits(most) is not None else 0):
middle = (bend + high_) / 2.0
bend, high_ = (middle, high_) if fits(middle) is None else (bend, middle)
bend = bend if high_ < most else most
reach = bend * math.tan(sharpest / 2.0)
curve, owner = arcs(posed, sharp)
s = np.r_[0.0, np.cumsum(np.linalg.norm(np.diff(curve, axis=0), axis=1))]
at = float(s[np.flatnonzero(owner == c)[0]])
for side, part in (("parent's side", span(curve, lead, at - reach)), ("child's side", span(curve, at + reach, float(s[-1]) - lead))):
if failed is None and len(part) >= 2:
swept = measure(part[:-1], part[1:], sides[side], need, 1.0 + width)
if swept.short:
failed = (f"the hose's {side}", swept, need)
else:
least = min(least, (swept.least, float(roll)))
if failed is None:
radius = min(radius, bend)
lengths.append(float(s[-1]) + (0.0 if not math.isfinite(bend) else bend * (float(turn[c]) - 2.0 * math.tan(float(turn[c]) / 2.0))))
continue
if half > finest and high > low:
bins += [(high, (low + high) / 2.0, (low + 3.0 * high) / 4.0), ((low + high) / 2.0, low, (3.0 * low + high) / 4.0)]
continue
through = f" through the {half:.3g} degrees either side of it" if half > 0.0 else ""
if failed[1] is None:
raise RouteError(f"roll {roll:.4g}: {failed[0]}{through}")
swept, bar = failed[1], failed[2]
raise RouteError(f"roll {roll:.4g}: {failed[0]} reads {swept.least:.4g} m from the parts about the pin at {spot(swept.where)}, counting the {float(moves(swept.where[None])[0]):.4g} m it can move against the other side's{through}: "
f"{falls(swept.least, bar)}")
return {"rolls": len(lengths), "worstRoll": least[1], "least": least[0], "lengthChange": max(lengths) - min(lengths), "radius": radius}

View file

@ -0,0 +1,336 @@
"""Fit a scene to a reference image: the camera a reference view was drawn through, solved from marked points,
traced lines scored against the edges the camera sees on the build, and a kitbash shell's sheet fitted to traces of
its hard runs.
A host add-on for Brokkr beside brokkr_mesh_polish (it imports that package's operator base, and nothing from
Brokkr): brokkr_actions.json beside this file lists the operators agents may run (docs/reference.md). The
arithmetic is core.py (numpy, tested without Blender); this file is the bpy around it. Every operator writes a
JSON report to WindowManager.brokkr_mesh_polish_result, as the polish operators do.
The camera record core.solve returns is the truth; a Blender camera stood at it is derived by core.blender, and
core.camera_of reads one back (flow_score takes the camera that way, by its object's name). The images, traces
and masks a view is marked on stay with whoever marked them: this package takes points and lines and gives
cameras, scores and a fitted sheet. The edges flow_score reads are computed on each call and kept nowhere.
fit_shell reads a shell's request through brokkr_kitbash (the sheet's one parser) and returns a sheet; it writes
nothing. brokkr_kitbash.shell is the cage's one writer: the caller applies the fitted sheet with it.
block_plate returns a plate's first sheet from traces of its outline, checked by the same parser, and the traces as
fit_shell takes them; it writes nothing either.
"""
bl_info = {"name": "Brokkr Reference", "author": "GameCult", "version": (0, 1, 0), "blender": (4, 2, 0),
"category": "Camera", "description": "Solve a reference view's camera from marked points; agent-callable through Brokkr."}
import json
import math
import time
import bpy
import numpy as np
from mathutils import Matrix, Vector
try:
from brokkr_mesh_polish import RESULT, PolishOperator, Refused
MISSING = None
except ImportError as error: # register() says so; the class below only needs something to subclass
RESULT, PolishOperator, Refused, MISSING = "brokkr_mesh_polish_result", bpy.types.Operator, RuntimeError, error
from . import core
def stand(scene, name, cam, width):
"""Create or update the camera object `name` at a camera record, the frame being the record's box at `width`
pixels across, and set the scene's render size to that frame: a pixel of the render is then the image's pixel
less the box's corner, times width over the box's width (core.in_frame). Returns core.blender's params."""
params = core.blender(cam, width)
obj = bpy.data.objects.get(name)
if obj is None:
obj = bpy.data.objects.new(name, bpy.data.cameras.new(name))
scene.collection.objects.link(obj)
data = obj.data
data.type, data.sensor_fit, data.sensor_width = "PERSP", params["sensor_fit"], params["sensor_width"]
data.lens, data.shift_x, data.shift_y = params["lens"], params["shift_x"], params["shift_y"]
data.clip_end = max(data.clip_end, 4 * cam["distance"])
obj.matrix_world = Matrix(params["matrix_world"])
scene.render.resolution_x, scene.render.resolution_y = params["resolution"]
return params
class BROKKR_REFERENCE_OT_solve_camera(PolishOperator):
"""Solve the camera a reference view was drawn through from points known in the world and marked on the
image, and optionally stand a scene camera there"""
bl_idname = "brokkr_reference.solve_camera"
bl_label = "Solve Reference Camera"
world: bpy.props.StringProperty(name="World", maxlen=4000, description="name=x,y,z; name=x,y,z ... points in the world, metres")
pixels: bpy.props.StringProperty(name="Pixels", maxlen=4000, description="name=u,v; name=u,v ... where the image draws each, v down; six or more names shared with World")
box: bpy.props.StringProperty(name="Box", maxlen=120, description="u0,v0,u1,v1: the view's box on the image, in the pixels the points were marked in")
model: bpy.props.EnumProperty(name="Model", default="auto", description="What the camera may do beyond standing, turning and zooming",
items=[("auto", "Auto", "Upright, rolled or free, whichever predicts left-out points best"),
("upright", "Upright", "Level, its centre at the middle of the box"), ("rolled", "Rolled", "May roll about its line of sight"),
("free", "Free", "May roll, and its centre is solved (a view cropped off-axis)"),
("square", "Square", "Looks straight along a world axis: an elevation drawn from far off")])
lens: bpy.props.FloatProperty(name="Lens", default=0.0, min=0.0, max=4000.0, description="mm on a 36 mm sensor across the box; 0 solves it. Hold it for a view that must agree with another")
turned: bpy.props.StringProperty(name="Turned", maxlen=2000, description="Names, spaces between, of points that turn as one about the vertical through Pivot; the angle is solved")
pivot: bpy.props.StringProperty(name="Pivot", maxlen=80, description="x,y of that vertical; empty is 0,0")
camera_name: bpy.props.StringProperty(name="Camera", maxlen=63, description="A camera object to create or update at the solved camera, with the scene's render size; empty only computes")
width: bpy.props.IntProperty(name="Width", default=1000, min=16, max=16384, description="Pixels across the frame the box becomes")
def work(self, context):
if self.camera_name and getattr(bpy.data.objects.get(self.camera_name), "type", "CAMERA") != "CAMERA":
raise Refused(f"{self.camera_name!r} is an object that is not a camera.")
try:
cam = core.solve(core.points(self.world, 3, "world"), core.points(self.pixels, 2, "pixels"), core.numbers(self.box, 4, "box"), model=self.model,
lens=self.lens or None, turned=tuple(self.turned.split()), pivot=core.numbers(self.pivot, 2, "pivot") if self.pivot.strip() else (0.0, 0.0))
except core.ReferenceFitError as refusal:
raise Refused(str(refusal)) from None
report = {**cam, "residuals": {k: [round(v, 2) for v in r] for k, r in cam["residuals"].items()}, "camera": None} # hundredths of a pixel: 280 points still fit a receipt
if self.camera_name:
report.update(camera=self.camera_name, blender=stand(context.scene, self.camera_name, cam, self.width))
return report
def record(context, name, box):
"""The camera record of the scene camera `name` (core.camera_of), the frame being `box` on the image ('' for
the render's own frame from 0, 0)."""
obj = bpy.data.objects.get(name)
if obj is None or obj.type != "CAMERA":
raise Refused(f"{name!r} is not a camera object.")
data, render = obj.data, context.scene.render
if data.type != "PERSP":
raise Refused(f"camera {name!r} is {data.type}; a camera record is a perspective camera's.")
fit = "HORIZONTAL" if data.sensor_fit == "AUTO" and render.resolution_x >= render.resolution_y else data.sensor_fit
place, turn, _ = obj.matrix_world.decompose() # a scaled camera object draws the same picture
return core.camera_of({"matrix_world": [list(row) for row in Matrix.LocRotScale(place, turn, None)], "lens": data.lens, "shift_x": data.shift_x, "shift_y": data.shift_y,
"sensor_width": data.sensor_width, "sensor_fit": fit, "resolution": [render.resolution_x, render.resolution_y]},
core.numbers(box, 4, "box") if box.strip() else None)
HIDE = 1e-3 # of a diagonal: a sight line stops this share of the edge's own piece of mesh short of the edge, so that the edge's own faces do not hide it; a surface nearer the edge than that hides it only from further than this share of its own object
def _diagonal(obj, placed, dg):
"""The diagonal of an object's evaluated bounding box as `placed` (a world matrix) stands it."""
return float(np.linalg.norm(np.ptp(np.array([placed @ Vector(corner) for corner in obj.evaluated_get(dg).bound_box]), axis=0)))
def built_edges(context, cam, objects, angle):
"""The edges a camera record sees on the build as it stands, modifiers evaluated: creases (two faces meeting at
more than `angle` degrees, one of them toward the camera), contours (one face toward the camera, the other
away) and open borders, each kept where two of three points along it are hidden behind nothing: a ray from the
camera toward the point meets no surface nearer it than the hiding margin: HIDE of the diagonal of the edge's
own piece (the connected part of its mesh it lies on: a box joined into one mesh with a ground is still a
box) or of the object met, the smaller of the two, so the margin is the same share of the parts involved at
any scale and whatever else the scene or the mesh holds (a ground plane, a hull). Past the own piece's margin
the ray is cast once more, and the first surface it meets there decides; the object met is measured whole. `objects` are the meshes read; anything the
scene renders hides. Returns {kind: [[u0, v0, u1, v1], ...]} in the record's pixels."""
scene, dg = context.scene, context.evaluated_depsgraph_get()
eye, out, cos_a = np.array(cam["C"]), {"crease": [], "contour": [], "border": []}, math.cos(math.radians(angle))
def hidden(p, short):
d = float(np.linalg.norm(p - eye))
toward = (p - eye) / d
if scene.ray_cast(dg, Vector(eye), Vector(toward), distance=d - short)[0]:
return True
hit, where, _, _, other, placed = scene.ray_cast(dg, Vector(eye + toward * (d - short)), Vector(toward), distance=short)
return hit and d - float(np.linalg.norm(np.array(where) - eye)) > HIDE * _diagonal(other, placed, dg)
for obj in objects:
ev = obj.evaluated_get(dg)
me = ev.to_mesh()
nv, ne, nl, nf = len(me.vertices), len(me.edges), len(me.loops), len(me.polygons)
if not nf:
ev.to_mesh_clear()
continue
co, ends, loop_edge, totals, normal, centre = np.empty(nv * 3), np.empty(ne * 2, np.int32), np.empty(nl, np.int32), np.empty(nf, np.int32), np.empty(nf * 3), np.empty(nf * 3)
me.vertices.foreach_get("co", co)
me.edges.foreach_get("vertices", ends)
me.loops.foreach_get("edge_index", loop_edge)
me.polygons.foreach_get("loop_total", totals)
me.polygons.foreach_get("normal", normal)
me.polygons.foreach_get("center", centre)
ev.to_mesh_clear()
world = np.array(obj.matrix_world)
co, centre = co.reshape(-1, 3) @ world[:3, :3].T + world[:3, 3], centre.reshape(-1, 3) @ world[:3, :3].T + world[:3, 3]
normal = normal.reshape(-1, 3) @ np.linalg.inv(world[:3, :3])
normal /= np.maximum(np.linalg.norm(normal, axis=1), 1e-12)[:, None]
order = np.argsort(loop_edge, kind="stable")
faces, count = np.repeat(np.arange(nf), totals)[order], np.bincount(loop_edge, minlength=ne)
first = np.searchsorted(loop_edge[order], np.arange(ne))
two = count == 2
f0, f1 = faces[np.minimum(first, nl - 1)], faces[np.minimum(first + 1, nl - 1)]
toward = ((eye - centre) * normal).sum(1) > 0
crease = two & ((normal[f0] * normal[f1]).sum(1) < cos_a) & (toward[f0] | toward[f1])
contour = two & (toward[f0] != toward[f1])
ends = ends.reshape(-1, 2)
piece, shorts = np.arange(nv), {} # each vertex's connected piece, named by its least vertex
while True:
low = np.minimum(piece[ends[:, 0]], piece[ends[:, 1]])
spread = piece.copy()
np.minimum.at(spread, ends[:, 0], low)
np.minimum.at(spread, ends[:, 1], low)
spread = spread[spread]
if (spread == piece).all():
break
piece = spread
for k in np.nonzero(crease | contour | (count == 1))[0]:
a, b = co[ends[k, 0]], co[ends[k, 1]]
if piece[ends[k, 0]] not in shorts:
shorts[piece[ends[k, 0]]] = HIDE * float(np.linalg.norm(np.ptp(co[piece == piece[ends[k, 0]]], axis=0)))
short = shorts[piece[ends[k, 0]]]
if sum(not hidden(a + t * (b - a), short) for t in (0.2, 0.5, 0.8)) >= 2:
(u0, v0), (u1, v1) = core.project(cam, [a, b])
out["contour" if contour[k] else "crease" if crease[k] else "border"].append([float(u0), float(v0), float(u1), float(v1)])
return out
class BROKKR_REFERENCE_OT_flow_score(PolishOperator):
"""Score traced lines against the edges a camera sees on the build: how much of each line has a built crease,
contour or border running along it"""
bl_idname = "brokkr_reference.flow_score"
bl_label = "Flow Score"
camera_name: bpy.props.StringProperty(name="Camera", maxlen=63, description="The camera object the view is seen through (solve_camera stands one)")
box: bpy.props.StringProperty(name="Box", maxlen=120, description="u0,v0,u1,v1: the camera's frame on the image, in the pixels the lines were traced in; empty is the render's own frame")
height: bpy.props.FloatProperty(name="Height", default=0.0, min=0.0, max=1000000.0, description="The figure's height in those pixels: an edge within 1% of it is near; 0 is the box's height")
lines: bpy.props.StringProperty(name="Lines", maxlen=12000, description="tag: u,v u,v ...; tag: u,v u,v ... the traced lines")
objects: bpy.props.StringProperty(name="Objects", maxlen=4000, description="Mesh objects whose edges are read, name; name; ... empty is every mesh the render shows")
angle: bpy.props.FloatProperty(name="Angle", default=18.0, min=1.0, max=179.0, description="Degrees between two faces' normals past which their edge is a crease")
def work(self, context):
try:
cam = record(context, self.camera_name, self.box)
lines = core.polylines(self.lines, "lines")
except core.ReferenceFitError as refusal:
raise Refused(str(refusal)) from None
names = [name.strip() for name in self.objects.split(";") if name.strip()]
meshes = [bpy.data.objects.get(name) for name in names] if names else [o for o in context.scene.objects if o.type == "MESH" and not o.hide_render]
for name, obj in zip(names, meshes):
if obj is None or obj.type != "MESH" or obj.name not in context.scene.objects:
raise Refused(f"{name!r} is not a mesh object of this scene.")
edges = built_edges(context, cam, meshes, self.angle)
height = self.height or cam["box"][3] - cam["box"][1]
segments = [seg for kind in edges.values() for seg in kind]
return {"lines": {tag: core.along(line, segments, height) for tag, line in lines.items()}, "edges": {kind: len(found) for kind, found in edges.items()},
"objects": [o.name for o in meshes], "height": height}
class BROKKR_REFERENCE_OT_fit_shell(PolishOperator):
"""Fit a kitbash shell's sheet to traces of its hard runs through solved cameras, and return the fitted sheet
only where the built runs explain every trace; nothing is written"""
bl_idname = "brokkr_reference.fit_shell"
bl_label = "Fit Shell To Traces"
object_name: bpy.props.StringProperty(name="Object", maxlen=63, description="A shell made by brokkr_kitbash.shell, unscaled; its place in the world is the sheet's frame")
traces: bpy.props.StringProperty(name="Traces", maxlen=12000, description="A JSON array of {camera, box, run: {ring|column, from, to} on a loft or {verts: [v, ...]} on a free cage, side, line: [[u, v], ...]}")
share: bpy.props.FloatProperty(name="Share", default=0.1, min=0.0009, max=10.0, description="A move of this share of the sheet's diagonal from the sheet as it stands costs what one pixel of miss does")
tol: bpy.props.FloatProperty(name="Tolerance", default=core.TOL, min=0.09, max=100.0, description="Pixels: nine tenths of every trace must lie this near its built run, or the fit is refused")
# the action table states share from 0.001 and tol from 0.1: a float property rounds those up, so its bounds stand just under
def work(self, context):
try:
import brokkr_kitbash
except ImportError as error:
raise Refused(f"fit_shell needs the brokkr_kitbash add-on beside this one ({error}).") from None
obj = bpy.data.objects.get(self.object_name)
if obj is None or obj.type != "MESH" or brokkr_kitbash.SHELL not in obj:
raise Refused(f"{self.object_name!r} is not a shell brokkr_kitbash.shell made (a mesh carrying {brokkr_kitbash.SHELL}).")
if max(abs(v - 1.0) for v in obj.matrix_world.to_scale()) > 1e-6:
raise Refused(f"{obj.name!r} is scaled {tuple(round(v, 6) for v in obj.matrix_world.to_scale())}: a sheet is in metres of the shell's own frame. Apply or clear the scale.")
try:
document = json.loads(obj[brokkr_kitbash.SHELL])["sheet"]
cage = brokkr_kitbash.core.sheet(document)
except (ValueError, KeyError, TypeError, brokkr_kitbash.core.KitError) as error:
raise Refused(f"{obj.name!r} carries a request its own parser does not take ({error}).") from None
try:
traces = json.loads(self.traces)
except ValueError as error:
raise Refused(f"traces is not JSON ({error}).") from None
if not isinstance(traces, list) or not all(isinstance(trace, dict) for trace in traces):
raise Refused("traces must be a JSON array of objects {camera, box, run, side, line}.")
cams = []
for k, trace in enumerate(traces):
if set(trace) - {"camera", "box", "run", "side", "line"}:
raise Refused(f"traces[{k}] has {sorted(set(trace) - {'camera', 'box', 'run', 'side', 'line'})}: a trace is {{camera, box, run, side, line}}.")
box = trace.get("box")
if box is not None and not (isinstance(box, list) and len(box) == 4 and all(isinstance(v, (int, float)) and not isinstance(v, bool) for v in box)):
raise Refused(f"traces[{k}].box must be [u0, v0, u1, v1], or absent for the render's own frame.")
if not isinstance(trace.get("camera"), str):
raise Refused(f"traces[{k}].camera must name a camera object.")
try:
cams.append(record(context, trace["camera"], "" if box is None else ",".join(repr(float(v)) for v in box)))
except (Refused, core.ReferenceFitError) as refusal:
raise Refused(f"traces[{k}]: {refusal}") from None
started = time.perf_counter()
try:
out = core.fit_sheet(document, cage, [list(row) for row in obj.matrix_world], traces, cams, share=self.share, tol=self.tol)
except core.ReferenceFitError as refusal:
raise Refused(f"{refusal}. Nothing changed.") from None
return {"object": obj.name, **out, "seconds": round(time.perf_counter() - started, 3)}
class BROKKR_REFERENCE_OT_block_plate(PolishOperator):
"""Block a plate's first free cage from traces of its outline through solved cameras, each trace naming the two
corners it runs between, and say what decided each corner's depth; nothing is written"""
bl_idname = "brokkr_reference.block_plate"
bl_label = "Block Plate From Traces"
frame_object: bpy.props.StringProperty(name="Frame", maxlen=63, description="An empty or object, unscaled, whose place in the world is the plate's frame")
plate: bpy.props.StringProperty(name="Plate", maxlen=2000, description="JSON {corners: [names in the outline's order], mirror, seam: [corners on x = 0]}")
traces: bpy.props.StringProperty(name="Traces", maxlen=12000, description="A JSON array of {camera, box, frame, from, to, side, line: [[u, v], ...]}")
plane: bpy.props.StringProperty(name="Plane", maxlen=200, description="'' for the plane through the corners the views decide, or 'x,y,z; nx,ny,nz' in the frame")
share: bpy.props.FloatProperty(name="Share", default=0.1, min=0.0009, max=10.0, description="A crown point this share of the plate's extent off the plane costs what one pixel of miss does")
tol: bpy.props.FloatProperty(name="Tolerance", default=core.TOL, min=0.09, max=100.0, description="Pixels: nine tenths of every trace must lie this near its built side, or the side gains a point")
def work(self, context):
try:
import brokkr_kitbash
except ImportError as error:
raise Refused(f"block_plate needs the brokkr_kitbash add-on beside this one ({error}).") from None
obj = bpy.data.objects.get(self.frame_object)
if obj is None or obj.name not in context.scene.objects:
raise Refused(f"frame_object {self.frame_object!r} is not an object of this scene.")
if max(abs(v - 1.0) for v in obj.matrix_world.to_scale()) > 1e-6:
raise Refused(f"frame_object {obj.name!r} is scaled {tuple(round(v, 6) for v in obj.matrix_world.to_scale())}: a plate is in metres of its frame. Apply or clear the scale.")
try:
plate, traces = json.loads(self.plate), json.loads(self.traces)
except ValueError as error:
raise Refused(f"plate and traces must be JSON ({error}).") from None
if not isinstance(traces, list) or not all(isinstance(trace, dict) for trace in traces):
raise Refused("traces must be a JSON array of objects {camera, box, frame, from, to, side, line}.")
plane = None
if self.plane.strip():
halves = self.plane.split(";")
try:
if len(halves) != 2:
raise core.ReferenceFitError(f"plane {self.plane.strip()!r} is not 'x,y,z; nx,ny,nz'")
plane = {"point": core.numbers(halves[0], 3, "plane's point"), "normal": core.numbers(halves[1], 3, "plane's normal")}
except core.ReferenceFitError as refusal:
raise Refused(f"{refusal}.") from None
own, views = [list(row) for row in obj.matrix_world], []
for k, trace in enumerate(traces):
box = trace.get("box")
if box is not None and not (isinstance(box, list) and len(box) == 4 and all(isinstance(v, (int, float)) and not isinstance(v, bool) for v in box)):
raise Refused(f"traces[{k}].box must be [u0, v0, u1, v1], or absent for the render's own frame.")
if not isinstance(trace.get("camera"), str):
raise Refused(f"traces[{k}].camera must name a camera object.")
try:
views.append((record(context, trace["camera"], "" if box is None else ",".join(repr(float(v)) for v in box)), trace.get("frame") or own))
except (Refused, core.ReferenceFitError) as refusal:
raise Refused(f"traces[{k}]: {refusal}") from None
started = time.perf_counter()
try:
out = core.block_plate(views, plate, traces, brokkr_kitbash.core.sheet, plane=plane, share=self.share, tol=self.tol)
except core.ReferenceFitError as refusal:
raise Refused(f"{refusal}. Nothing changed.") from None
return {"frame_object": obj.name, **out, "seconds": round(time.perf_counter() - started, 3)}
classes = (BROKKR_REFERENCE_OT_solve_camera, BROKKR_REFERENCE_OT_flow_score, BROKKR_REFERENCE_OT_fit_shell, BROKKR_REFERENCE_OT_block_plate)
def register():
if MISSING is not None or not hasattr(bpy.types.WindowManager, RESULT):
raise RuntimeError(f"brokkr_reference needs brokkr_mesh_polish enabled first ({MISSING or 'its result property is not registered'}).")
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)

View file

@ -0,0 +1,236 @@
{
"schema": "brokkr.blender.host_actions.v0",
"actions": [
{
"name": "brokkr_reference.solve_camera",
"doc": "Solve the camera a reference view was drawn through from six or more points known in the world and marked on the image; with camera_name, stand a camera there and set the render size to the view's box. The result is the camera record (docs/reference.md).",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "world",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 4000,
"doc": "name=x,y,z; name=x,y,z ... points in the world: x right, y forward, z up, metres"
},
{
"name": "pixels",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 4000,
"doc": "name=u,v; name=u,v ... where the image draws each, v down; six or more names shared with world"
},
{
"name": "box",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 120,
"doc": "u0,v0,u1,v1: the view's box on the image, in the pixels the points were marked in"
},
{
"name": "model",
"type": "string",
"enum": [
"auto",
"upright",
"rolled",
"free",
"square"
],
"default": "auto",
"doc": "auto takes upright, rolled or free by leave-one-out error; square looks straight along a world axis (an elevation)"
},
{
"name": "lens",
"type": "number",
"minimum": 0,
"maximum": 4000,
"default": 0,
"doc": "mm on a 36 mm sensor across the box; 0 solves it, 4 to 4000 holds it (a view that must agree with another)"
},
{
"name": "turned",
"type": "string",
"maxLength": 2000,
"doc": "names, spaces between, of points that turn as one about the vertical through pivot; the angle is solved as twist"
},
{
"name": "pivot",
"type": "string",
"maxLength": 80,
"doc": "x,y of that vertical; absent is 0,0"
},
{
"name": "camera_name",
"type": "string",
"maxLength": 63,
"doc": "a camera object to create or update at the solved camera; absent only computes"
},
{
"name": "width",
"type": "integer",
"minimum": 16,
"maximum": 16384,
"default": 1000,
"doc": "pixels across the frame the box becomes when camera_name is given"
}
]
},
{
"name": "brokkr_reference.flow_score",
"doc": "Score traced lines against the edges a camera sees on the evaluated build (creases, contours and open borders, unhidden): per line, the share with a built edge running along it (on), the mean distance to one in % of height (off) and the longest unbroken share (run); and the count of edges by kind (docs/reference.md).",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "camera_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "the camera object the view is seen through (solve_camera stands one)"
},
{
"name": "box",
"type": "string",
"maxLength": 120,
"doc": "u0,v0,u1,v1: the camera's frame on the image, in the pixels the lines were traced in; absent is the render's own frame from 0,0"
},
{
"name": "height",
"type": "number",
"minimum": 0,
"maximum": 1000000,
"default": 0,
"doc": "the figure's height in those pixels: an edge within 1% of it is near; 0 is the box's height"
},
{
"name": "lines",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 12000,
"doc": "tag: u,v u,v ...; tag: u,v u,v ... the traced lines"
},
{
"name": "objects",
"type": "string",
"maxLength": 4000,
"doc": "mesh objects whose edges are read, name; name; ... absent is every mesh the render shows"
},
{
"name": "angle",
"type": "number",
"minimum": 1,
"maximum": 179,
"default": 18,
"doc": "degrees between two faces' normals past which their edge is a crease"
}
]
},
{
"name": "brokkr_reference.fit_shell",
"doc": "Fit a kitbash shell's sheet (a loft or a free cage) to traces of its hard crease and rim runs, each seen through a scene camera: the traced runs' cage points move until the runs as built draw on the traces. Returns the fitted sheet for brokkr_kitbash.shell only where nine tenths of every trace lies within tol px of its built run; otherwise it is refused naming the trace, its reading and the span. A very unsteady hand and a 1 to 2% overdraw read alike: each trace's reading (unexplained_px) and worst point (worst_px) are in the report to judge by. Writes nothing. Per moved point: its depth sensitivity (metres one pixel of trace error moves it along its sight line, across its run; a sensitivity, not an error bound) and the prior's share of that: under 0.2 the traces decide the point, over it the blocking holds it (docs/reference.md).",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "object_name",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "a shell made by brokkr_kitbash.shell, unscaled; its place in the world is the sheet's frame"
},
{
"name": "traces",
"type": "string",
"required": true,
"minLength": 2,
"maxLength": 12000,
"doc": "a JSON array of {camera, box, run, side, line}: camera a camera object's name; box [u0,v0,u1,v1], its frame on the image, absent for the render's own; run {ring, from, to} or {column, from, to} on a loft, {verts: [v, ...]} on a free cage, in authored indices, as the sheet's creases name runs; side 1, or -1 for the mirrored half; line [[u,v],...] drawn from the run's first point to its last"
},
{
"name": "share",
"type": "number",
"minimum": 0.001,
"maximum": 10,
"default": 0.1,
"doc": "the prior: a move of this share of the sheet's diagonal from the sheet as it stands costs what one pixel of miss does"
},
{
"name": "tol",
"type": "number",
"minimum": 0.1,
"maximum": 100,
"default": 5.2,
"doc": "pixels: nine tenths of every trace must lie this near its built run, or the fit is refused"
}
]
},
{
"name": "brokkr_reference.block_plate",
"doc": "Block a plate's first free cage from traces of its outline, each seen through a scene camera and naming the two consecutive corners it runs between: the only correspondence is a trace's ends to its corners. The crown (the corners and each side's points between) is solved until the sides as built draw on the traces; a side whose trace is not explained gains a point, up to 6. Depth comes from the views where two see a corner and a pixel moves their meeting point less than share x the plate's extent, from x = 0 for a mirrored plate's seam corners whose view crosses it, and otherwise from a plane: the one given, or the one through the corners the views and the seam decide. Every corner, and every point between corners (sides[].inner), says what decided it by its prior_share: plane from 0.2 up, else mirror on the seam, else views; a side says corners, views, mirror or plane. A corner one view sees, a seam corner seen along x = 0 included, is refused when the plane stands over 66 degrees off that view. Returns the sheet for brokkr_kitbash.shell, checked by its parser, and fit_traces for brokkr_reference.fit_shell (left_out lists the traces fit_shell cannot state: another frame, or a partner's side -1). Writes nothing (docs/reference.md).",
"changesScene": true,
"editModeSafe": false,
"result": "brokkr_mesh_polish_result",
"fields": [
{
"name": "frame_object",
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 63,
"doc": "an empty or object, unscaled, whose place in the world is the plate's frame"
},
{
"name": "plate",
"type": "string",
"required": true,
"minLength": 2,
"maxLength": 2000,
"doc": "JSON {corners: [names, in the outline's order], mirror: true or false, seam: [the corners on x = 0 of a mirrored plate, two or more next to each other]}; side i runs from corner i to corner i + 1 and is one hard crease"
},
{
"name": "traces",
"type": "string",
"required": true,
"minLength": 2,
"maxLength": 12000,
"doc": "a JSON array of {camera, box, frame, from, to, side, line}: camera a camera object's name; box [u0,v0,u1,v1], its frame on the image, absent for the render's own; frame a 4 x 4 (rows), the part's pose in that view, absent for frame_object's; from and to two consecutive corners; side 1, or -1 for the mirrored half or the partner across the frame's x = 0; line [[u,v],...] drawn from `from` to `to`"
},
{
"name": "plane",
"type": "string",
"required": false,
"maxLength": 200,
"default": "",
"doc": "'' for the plane through the corners the views and the seam decide, or 'x,y,z; nx,ny,nz' in the frame: a point of the plane and its normal"
},
{
"name": "share",
"type": "number",
"minimum": 0.001,
"maximum": 10,
"default": 0.1,
"doc": "the prior: a crown point this share of the corners' extent off the plane costs what one pixel of miss does"
},
{
"name": "tol",
"type": "number",
"minimum": 0.1,
"maximum": 100,
"default": 5.2,
"doc": "pixels: nine tenths of every trace must lie this near its built side, or the side gains a point"
}
]
}
]
}

File diff suppressed because it is too large Load diff

View file

@ -182,10 +182,15 @@ Behaviour the table does not say, per action:
- `createObject`: a `MESH` is a cube of `size`. `lightType`, `emptyDisplayType` and `meshType` apply
only to their own `objectType`.
- `setObjectParent`: an empty or absent `parentObjectName` clears the parent.
- `setObjectParent`: an empty or absent `parentObjectName` clears the parent. Before it writes, each enabled
add-on that defines `brokkr_parent_refusal(object, parent)` is asked, and a reason it answers refuses the
intent with nothing changed (`brokkr_kitbash` answers its one-driver rule over the loops the object is part
of or stands above, `docs/kitbash.md`; an object no loop hangs from is never refused by it).
- `importGltf`: `filepath`, `.gltf` or `.glb`, relative to the add-on preference
`Import Directory` (absolute paths, `..` and symlinks that resolve outside it are
refused). Empty `Import Directory` disables the action. Needs Blender's glTF add-on.
Custom properties named `kit_*` that the file's extras carry are dropped from the imported
objects and their data, and the receipt names the objects: they are brokkr_kitbash's own state.
- `exportGltf`: `filepath`, `.glb` (binary) or `.gltf` (separate `.bin`), relative to the
add-on preference `Render Output Directory` (the renderStill rules: no `..`, no links, and an
existing name is refused; there is no overwrite).

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,473 @@
# Reference views: the camera a picture was drawn through, traced lines scored against the build, and a shell fitted to them
`surfaces/blender/brokkr_reference` is a Blender add-on that fits a scene to a reference image. A concept sheet,
a render or a photograph draws its subject through a camera nobody wrote down; given points whose place in the
world is known and the pixel where the image draws each, `solve_camera` finds that camera, so that a render through
it lays over the image pixel for pixel and a line traced on the image can be scored against the build's edges.
It is a host add-on in Brokkr's sense (`install.md`, "Host add-on actions"), a sibling of `brokkr_mesh_polish`: it
imports that package's operator base and `Refused`, and nothing from `brokkr_bridge`. Enable `brokkr_mesh_polish`
first; `brokkr_reference` refuses to register without it. `brokkr_actions.json` beside its `__init__.py` lists the
three operators agents may run (`solve_camera`, `flow_score`, `fit_shell`); the arithmetic is `core.py` (numpy only, tested without Blender), which a script may
import directly. The action writes its JSON report to `brokkr_mesh_polish_result`, returned in the receipt's
`hostResult`.
The package takes points and traced lines and gives cameras, scores and a fitted sheet. The images, the marks on them, traces and masks belong to whoever
made them; nothing here opens an image.
## Conventions
- World: x right, y forward, z up, metres.
- Pixels: the image's, in whatever unit the points were marked in, u right and v down. `box` is the view's
rectangle on the image, `u0,v0,u1,v1`; for an image that is one view it is `0,0,width,height`.
- Camera record: `C` is where the camera stands, `R` turns world to camera (rows), the camera looks down its own
-z with y up (Blender's), `f` is the focal length in pixels, `c` the principal point in pixels. `lens` is `f`
in millimetres on a 36 mm sensor across the box's width.
- Misses are weighed by a pseudo-Huber loss of 10 px: a build poses some points elsewhere than the image draws
them, and one such point pulls the camera as its distance, not its square.
The record is the truth. A Blender camera stood at it (`core.blender`) is derived, and `core.camera_of` reads one
back into a record.
## solve_camera
`brokkr_reference.solve_camera`. Host action fields are scalar, so points go in as text:
| field | |
| --- | --- |
| `world` | `name=x,y,z; name=x,y,z ...` |
| `pixels` | `name=u,v; name=u,v ...`; six or more names shared with `world`, the rest ignored |
| `box` | `u0,v0,u1,v1` |
| `model` | `auto` (default), `upright`, `rolled`, `free`, `square` |
| `lens` | mm; 0 (default) solves it, 4 to 4000 holds it |
| `turned` | names, spaces between, of points that turn as one about the vertical through `pivot` |
| `pivot` | `x,y`; absent is `0,0` |
| `camera_name` | a camera object to create or update at the solved camera; absent only computes |
| `width` | pixels across the frame the box becomes (default 1000) |
The models differ in what the camera may do beyond standing somewhere, turning and zooming. `upright` holds it
level with its centre at the middle of the box. `rolled` lets it roll about its line of sight. `free` also solves
the centre: a view cropped off-axis. `auto` solves all three and takes the one that predicts left-out points best
(each point predicted by the camera solved without it), since a freer model always fits the marked points closer.
`square` is for an elevation drawn square-on from far off: the points lie nearly in one plane across the line of
sight, where a small turn of the camera and a narrower subject draw the same picture, so the camera is held looking
straight along a world axis, whichever of the four fits best.
`turned` is for one articulated group (a torso on its waist ring): its turn about the vertical through `pivot` is
solved with the camera and reported as `twist`, in degrees from where the points were given.
With `camera_name` the action creates that camera, or updates it if it exists (an object of that name that is not
a camera is refused): its matrix, lens, shifts, a 36 mm sensor fitted horizontally, `clip_end` raised to four
times the camera's distance if it was nearer, and the scene's render resolution set to `width` by the box's
proportion. It does not make it the scene's active camera and does not touch `resolution_percentage`. A pixel of a
render through it at 100% is then the image's pixel less the box's corner, times `width` over the box's width
(`core.in_frame`; the frame's height is a whole number of pixels, so it can stand half a pixel off the box's).
The report is the camera record: `C`, `R`, `f`, `c`, `box`, `lens`, `lens_band`, `lens_at_bound`, `lens_determined`, `planarity`, `plane`, `rms`, `median`
and `worst` (`[name, pixels]`), `left_out` (the leave-one-out rms), `model`, `tried` (each model's `rms`,
`left_out` and `lens`), `azimuth`, `elevation` and `distance` (where the camera stands round the points' middle),
`roll`, `twist`, and `residuals` (`{name: [du, dv]}`, to a hundredth of a pixel in a receipt); plus `camera` (the
object's name or null) and, when a camera was stood, `blender` (what `core.blender` gave it).
Refusals name their cause: fewer than six shared names, a point that is not finite numbers, a name given twice, a
box of no width or height, a lens outside 4 to 4000 mm. Marks that cannot decide a camera are refused before any
solve: fewer than six different world points or six different pixels among the shared names (the message names two
that share one), pixels all on one line, world points all on one line, and world points all in one plane with the
model `free`. These are exact cases, to a billionth of the marks' extent (`core.EXACT`); points nearly in a line or
a plane are solved, and `lens_determined` and the band say what they leave open. A report never holds a number
that is not finite.
`planarity` is how flat the marked world points are: their least extent over their greatest, 0 for a plane, 0.3
for points spread through a box. World points all in one plane (a deck, a wall, a flat sheet of marks) are solved,
and `plane` is then the degrees between the line of sight and square-on to that plane (it is null otherwise). A
plane never decides the centre, so `auto` tries `upright` and `rolled` only.
Flat marks may not decide the lens, and `lens_determined` says whether these did. Seen obliquely a plane does, by
its foreshortening. Seen square-on it does not: every lens draws it the same from its own distance, and a small
tilt of the plane seen through a long lens draws what a short lens draws square-on, so the marks' error picks the
headline lens. Measured on a plane of thirteen marks through a 50 mm lens, each mark a pixel off, six seeds a tilt:
| degrees off square-on | headline lens, mm | band, mm | `lens_determined` |
| --- | --- | --- | --- |
| 0 | 4 to 4000 | 4 to 4000 | false, all six |
| 3 | 4 to 90 | 4 to 4000 (one 45 to 134) | false, all six |
| 6 | 42 to 62 | from 13 to 84, one 4 to 4000 | false, all six |
| 9 | 46 to 57 | from 35 to 69 | true in five |
| 15 | 48 to 53 | from 44 to 59 | true, all six |
| 30 | 49 to 51 | from 45 to 57 | true, all six |
The band held 50 mm in all 36. With marks 3 px off, one band of nine at 5 degrees did not (68 to 152, not
determined). When `lens_determined` is false, do not read `lens` as the lens: hold `lens` from another view, or mark
a point off the plane.
## How far to trust the lens
Six or more points that are not all in one plane decide a camera. What they decide well is the picture: where each
point is drawn. What a long or square-on view decides badly is how far off the camera stands, because distance
and focal length trade against each other (a dolly zoom) and the picture barely changes. So:
- The focal length is held inside 4 to 4000 mm. Without a bound the solve ran the focal length to overflow on long
views; past 4000 mm a view is orthographic to any marking. `lens_at_bound` is `"long"` or `"short"` when the
answer sits at an end: read that as "at least this long", not as a lens.
- `lens_band` is `[low, high]`, walked out from the best lens in steps of a tenth in log f (about 10%) to the first
lens each way that, held and refitted, misses 1.1 times the best rms. Every lens outside the band misses; each
end is the first step that did, so the lenses that fit end somewhere in the step before it, and a band is never
narrower than a step each way. The rms the walk is judged against is never taken under 1 pixel (`core.FINE`):
marks placed truer than a hand places them fit every lens of a flat view to a millionth of a pixel, and one of
those would be called best. It is an **equal-error band, not a confidence interval**: it says which lenses the
marks cannot tell apart, and on probes a few such bands excluded the true lens. A band that ends at 4000 or at 4
was stopped by the bound.
- For flat marks (`planarity` under 0.12, `core.PLANAR`) a band that reaches one end of the range is reported as
the whole range, 4 to 4000. What closes the other end of such a band is a tilt of the plane traded against the
lens, and the marks' error sets that either way: a square-on plane's band read 309 to 4000 mm on one seed with
the true lens at 50. This gives up the one-sided reading ("at least 300 mm") for flat marks; marks with depth
keep it.
- `lens_determined` is true when the band lies inside 4 to 4000 mm and spans no more than 1.57 times
(`core.DECIDED`), false otherwise, and null when `lens` was held.
- There is no prior. Where the data cannot decide, the answer is a wide band rather than a plausible-looking 50 mm.
- Hold `lens` only when views must agree: two views of one subject solved alone may each sit anywhere in their
bands, and a fit rendered from elsewhere than the reference view depends on the lens the band does not fix.
What this buys and costs, measured on a generated hull rendered at known cameras with 10 to 16 marked points
(Blender 5.3 on Starfire): a 50 mm oblique view with 1 px of marking noise came back at 49.9 mm; a 135 mm view on a
build 2% of its length out came back anywhere from 94 mm to the bound, with the camera's place off by eleven hull
lengths, and a crease lifted through that camera onto the hull's mirror plane was still within 1.4% of the hull's
length of the truth, moving at most 0.6% between the band's ends. A wide band is a warning about the camera's
place, not about a lift made in the view's own frame.
`rms` is the plain root mean square of the misses, in pixels at the marking unit, though the solve minimises the
pseudo-Huber loss; `median` beside it shows when a few points carry the error. A solve with `auto` on 13 points
takes several seconds (three models, each from 16 starts, plus a left-out solve per point per model).
## flow_score: traced lines against built edges
`flow_score` says how much of each traced line the build already carries as an edge. It reads the evaluated meshes
(modifiers applied) and keeps the edges the camera sees: creases (two faces whose normals differ by more than
`angle` degrees, at least one of them facing the camera), contours (one face toward the camera, one away) and open
borders, each where two of three points along it are hidden behind nothing the scene shows. A face that looks away
by its winding does not count as seen, so a cage with flipped normals shows no creases.
| field | |
| --- | --- |
| `camera_name` | the camera object the view is seen through (`solve_camera` stands one) |
| `box` | `u0,v0,u1,v1`: the camera's frame on the image, in the pixels the lines were traced in; absent is the render's own frame from 0,0 |
| `height` | the figure's height in the box's pixels; an edge within 1% of it is near. 0 (default) is the box's height |
| `lines` | `tag: u,v u,v ...; tag: u,v u,v ...` |
| `objects` | `name; name; ...`, the meshes whose edges are read; absent is every mesh the render shows. Everything the scene shows hides |
| `angle` | degrees (default 18) |
The report: `lines` (`{tag: {on, off, run}}`), `edges` (the count of seen edges by kind), `objects` and `height`.
`on` is the share of the line with a seen edge within 1% of the height and within 20 degrees of the line's own
direction; `off` the mean distance to such an edge in % of the height, capped at 5; `run` the longest unbroken
share that is on. The edges themselves are not returned and not kept: they are computed on each call.
The hiding test's sight line stops short of each point by a thousandth (`HIDE`) of the diagonal of the edge's own
piece, the connected part of its mesh that it lies on, so that the edge's own faces do not hide it: a box joined
into one mesh with a ground 200 times its size keeps the box's margin. A surface nearer the edge than that hides
it when it stands further off than a thousandth of the diagonal of the object it belongs to, measured whole: the
margin is the smaller of the two, whatever else the scene holds. A greeble modelled into its hull's own connected
surface has the hull's margin, and a surface nearer it than a thousandth of the hull does not hide it. A strip 0.3% of a box's diagonal in front of an edge hides it at scales 0.01, 1 and
100, and with a ground 20 or 40 times the box among the meshes read; chips a fortieth of a box hide its edge from
0.05% of its diagonal. Past the own object's margin the first surface met decides. Edges read true from cameras to
about 20000 diagonals off, where the ray's own rounding reaches the margin. The action writes nothing to the scene (its row says `changesScene`
because the operator base pushes an undo step).
## fit_shell: a shell's sheet fitted to traces of its hard runs
A kitbash shell (`kitbash.md`, "Making a shell") is blocked in by eye; `fit_shell` moves the cage points of its
traced runs until the runs, as Blender builds them and the cameras draw them, lie on the traces. A run is a hard
crease or rim run of a loft or of a free cage, named as the sheet's creases name runs. The unknowns are the authored points on the
traced runs; a mirrored sheet is one set of points seen twice, so a trace of each half through one camera is two
views of the run (Francois et al. 2003), and that is where depth comes from in a single picture. Each built point
of a run is pulled onto its trace along the trace's normal, and the run's two ends onto the trace's ends; no
point of a trace is matched to a point of the run or of another trace (after Debevec's Facade and Drummond and
Cipolla's edge tracker). A prior holds every point to the sheet as it stands: a move of `share` of the sheet's
diagonal costs what one pixel of miss does.
```json
{"action": "brokkr_reference.fit_shell", "object_name": "Pauldron",
"traces": "[{\"camera\": \"Concept\", \"box\": [0, 0, 1024, 1024], \"run\": {\"column\": 3, \"from\": 0, \"to\": 5}, \"side\": 1, \"line\": [[412.5, 96.0], [431.0, 180.2], [440.8, 266.0]]}, {\"camera\": \"Concept\", \"box\": [0, 0, 1024, 1024], \"run\": {\"column\": 3, \"from\": 0, \"to\": 5}, \"side\": -1, \"line\": [[612.0, 90.5], [590.2, 176.0], [583.1, 262.4]]}]"}
```
| field | |
| --- | --- |
| `object_name` | a shell made by `brokkr_kitbash.shell`, unscaled; its place in the world is the sheet's frame |
| `traces` | a JSON array, up to 12000 characters, of `{camera, box, run, side, line}` |
| `share` | the prior (default 0.1) |
| `tol` | pixels (default 5.2): nine tenths of every trace must lie this near its built run |
In a trace, `camera` names a camera object (`solve_camera` stands one) and `box` is its frame on the image, absent
for the render's own; `run` is `{"ring": i, "from": a, "to": b}` or `{"column": j, "from": a, "to": b}` on a loft and
`{"verts": [v, ...]}`, the run's vertices in order, on a free cage, all in authored indices; `side` is 1, or -1
for the mirrored half of a mirrored sheet (the reflections `brokkr_kitbash`'s parser makes: `Sheet.mirror_of`);
`line` is `[[u, v], ...]` in the box's pixels, drawn from the run's first point to its last.
**It returns a fit only where the built runs explain every trace.** After the fit, each trace is walked a pixel
at a time and each point's distance from its run, as built and drawn, is taken. The trace's reading,
`unexplained_px`, is the 90th percentile of those distances; over `tol` the action is refused, naming the trace,
its reading, how much of it lies past `tol` and where, and nothing is returned as a fit. `worst_px` is the
furthest any point of the trace stands. The fit's own residual is no such test: on strokes doubled back over
part of themselves 3% of the view off, every fit converged and without this check all of them came back, up to
0.10 m wrong on a 2 m crease.
The reading is not the worst point because a hand trace's tip is where two traces cannot agree: the Orchid's
hand-traced pair reads 0.80 px, with one tip 9.2 px off its run, and that pair's least 1% overdraw has a worst
point of 9.1 px. The percentile and the default were read from 296 fits and set by the margin rule
(`tests/test_reference.py`, `FitTests`): what should pass reads 3.76 px at most (hand traces wandering 1 and 2
px), what should not reads 7.27 and up (the Orchid's traces overdrawn 2% of their extent; synthetic strokes 3%
off read 7.70), and 5.2 sits 1.39 from each.
**A very unsteady hand and a slight overdraw are not told apart.** Hand traces wandering 4 px read up to 5.84
(31 of 36 pass the default); strokes overdrawn 1% read from 2.57 (11 of 45 pass) and 2% from 5.10 (2 of 45
pass). The reading orders 99.6% of hand trace against 2 to 3% overdraw pairs rightly, but no threshold stands 1.2
from both the 4 px hand traces and the 2% overdraws. So the reading is in the report of every accepted fit and
in every refusal: near 5, look at the trace. An accepted trace reading 3 to 5 px may be a 1 or 2% overdraw; a
refused one reading 5 to 6 may be a clean stroke from an unsteady hand, and asking again with `tol` over its
reading is the caller's judgement. A doubled stretch shorter than a tenth of the trace does not move the
reading: `worst_px` shows it.
**It writes nothing.** The report carries `sheet`, the shell's own request with the traced points moved, ready
for `brokkr_kitbash.shell`, which is the cage's one writer; `flow_score` on the rebuilt shell is the score. The
rest of the report: `traces` (`[{unexplained_px, worst_px}]`), `points` (`[{ring, point, moved_m, m_per_px,
prior_share}]` on a loft, `[{vertex, ...}]` on a free cage, one per moved point) and `seconds`.
`m_per_px` is a point's depth sensitivity: how many metres one pixel of error in the traces moves that point
along its line of sight, taken on the part of the line of sight that stands across the run there (the worst of
the traces that draw it), from the inverse of the fit's normal matrix, prior included (Triggs et al. 2000, sections 9 and 10). A point's slide along its own
run is left out: the traces do not decide it and it does not move the built run. `prior_share` is `m_per_px` over
`share` x the diagonal: near 1 the traces say nothing about the point's depth and it stands where the blocking
put it. Read it per point against 0.2:
- **Under 0.2 the traces decide the point.** A mirrored pair traced in one view: over 18 fits every point reads
0.080 or under and the built run is right to 0.7 mm. The Orchid's concept c09 pair reads 0.018 at most.
- **Over 0.2 the blocking holds it.** One half traced in one view: over the same 18 fits every inner point reads
0.50 to 1.0 (the sine of the angle its run stands off the line of sight) and the built run is 18 to 355 mm
wrong. Either Orchid trace alone reads 0.27 and up on every point. 0.2 is the geometric mean of 0.080 and
0.50, 2.5 from each.
- A run's end seen along the run reads low even on a single trace (down to 0.005): there the line of sight is
the run's own direction, and the depth across the run is decided.
- A run on the mirror plane (a spine, a keel) has no partner and needs none: its points stay on the plane, which
decides their depth. A spine traced once read 0.019 at most and came back within 0.15 mm.
`m_per_px` is a sensitivity, and `tol` x `m_per_px` is no bound on the fit's error. Clean strokes came back
within 0.16 of `tol` x the worst `m_per_px` they report. Hand traces whose wander holds over 30 px did not: of 24
fitted (wander 2 and 4 px), 13 ended further off than that, up to 2.45 times (20 to 87 mm on a 2 m crease),
while every point read a `prior_share` under 0.05. A low reading says the traces decide the point; how well they decide it
is as good as the traces are.
What it refuses before fitting, naming the trace: a run with an edge under weight 1 (a semi-sharp edge rounds
off by an amount the fit does not model), a run whose end does not hold (a dart; a ring run from point 0 of a
mirrored sheet, which runs on across the middle), a run with a point held partway (a corner point or a crossing
crease: trace it as two), a closed loop, an unknown camera, a line of fewer than two points, a run named in the
other form's words (`verts` on a loft, a ring or column on a free cage), a scaled shell, and a result that would
pass the 16000 characters a receipt carries.
Measured (Blender 5.3 and Python 3.13 on Starfire): a mirrored column of 10 points traced in one view at a time,
from blockings 0.10 m and 0.30 m off a 2 m crease, came back within 0.7 mm in 0.1 to 0.6 s. The Orchid's c09
petal edges, traced by hand through a camera solved from hand marks (13 px rms), are accepted at the default,
reading 0.80 and 0.68 px, in 0.2 s; from blockings 5%, 10% and 20% of the ship's length off the built run lands
in one place, 2.0% of the length from a stand-in mesh in the mean and 3.4% at worst. A mirrored free cage's
crease of six vertices, blocked 0.056 m off, came back within 0.43 mm through the action in 0.02 s.
What it gives up: it fits hard runs only. Silhouettes of the smooth surface and semi-sharp creases are not
fitted; a run's depth with no mirror partner, no second view and no mirror plane under it is the blocking's.
The acceptance reads nine tenths of a trace: it passes a short doubled stretch and a tip that stands off, and
reports both as `worst_px`. `m_per_px` is a sensitivity to one pixel, not an error bound.
## block_plate: a plate's first cage from its traces
`fit_shell` refines a cage somebody blocked. `brokkr_reference.block_plate` makes the first one. A plate is a
closed outline of named corners in order; side i runs from corner i to corner i + 1 and is one hard crease of the
plate's crown. A trace is one side drawn in one view, `{camera, box, frame, from, to, side, line}`: `from` and `to`
are two consecutive corners and the line is drawn from the one to the other. That is the only correspondence
there is: a trace's two ends are its two corners. Every other point of the crown is placed by `fit_shell`'s
residual, the pixel distance from the side as built to the trace. Nothing matches a point of one trace to a
point of another.
`frame_object` is the plate's frame. A trace's `frame` is the part's pose in that view where it differs (a limb
swung, a hull pitched); `side` -1 is a view of the plate's reflection across the frame's x = 0, which is the
other half of a mirrored plate or the same plate on the partner limb. `plate` is `{corners, mirror, seam}`. On a
mirrored plate `seam` names the corners on x = 0, two or more next to each other: they are held there, the sides
between them lie on it, and one view decides them.
Where a corner's depth comes from, in this order:
- **the views**, where two or more see it and one pixel moves the point their sight lines meet at less than
`share` x the plate's extent, the prior's own scale. Past that the views alone hold the corner looser than the
plane would and are not used as its start. That factor of 1 is the prior's own unit, not a derived value; the
tests pin it between a plate that blocks and one that is refused. The line is metres a pixel, so it moves
with lens and range: a 1.2 m plate 17.6 m off at 663 px has three corners started at 0.72 of the scale with
its views 19 degrees apart, 0.83 at 16.5, between 1.22 and 1.23 at 11 and 2.73 at 5. With no plane given it blocks down to
16.5 degrees (73 mm from the truth) and is refused at 11, where it would have stood 104 mm off: the line
switches blocking and refusal, it is no cliff in accuracy. At 5 degrees its corners landed 0.25 to 1.5 m off;
through a lens three times as long it starts at 0.65 at 7 degrees and blocks.
- **the mirror plane**, for a seam corner whose sight line crosses x = 0 at 24 degrees or more.
- **a plane**, for the rest: `plane` (`x,y,z; nx,ny,nz`, a point and the normal, in the frame), or with none given
the plane through the corners the views and the seam decide, three or more. A corner one view sees is lifted
onto it, and refused when the plane stands more than 66 degrees off square-on to that view: the lift stretches
past 2.5 times there. A seam corner whose one view runs along x = 0 is such a corner: it is lifted onto the
plane, held on x = 0, and refused by the same 66 degrees.
That is where a corner starts. What the report says decided it is read after the solve, from the point's own
prior share, whatever kind of point it is.
The crown is then solved by the same solver as `fit_shell`, with a different prior: each crown point's distance
to the plane costs a pixel per `share` x the corners' extent, and each side's second differences a pixel per 0.2
x its chord. A distance to a plane does not resist a move in the plane, so the views decide wherever they see,
and a view that sees nothing along its own sight line leaves that to the plane. A side starts as its two
corners. After each solve a side with a trace not explained (the same nine tenths within `tol`) gains one point
and the plate is solved again, to six points a side; past that it is refused as `fit_shell` refuses a trace.
The cage is the crown ring, a skirt 0.05 of the crown's extent out and 0.06 back of it, and one centre vertex
0.017 proud (the extent is the distance between the crown's two furthest points, so a plate of any size has the
same proportions): every crown side
creased 1, the named corners pinned, the centre the declared pole unless the crown has four points. On a
mirrored plate the seam's sides have no skirt and the seam's two ends are poles too. The skirt and centre are
rebuilt from the solved crown and never solved. The sheet goes through `brokkr_kitbash`'s parser before it is
returned, and `brokkr_kitbash.shell` builds it; `block_plate` writes nothing.
The report: `sheet`; `fit_traces`, the traces as `fit_shell` takes them (each side a run of authored vertices),
and `left_out`, the traces `fit_shell` cannot state (one with its own `frame`, or a partner's side -1 on a plate
that is not mirrored); per corner `decided_by`, `parallax_deg`, `m_per_px` and `prior_share`; per side its
points, each trace's readings, `inner` (the same `decided_by`, `m_per_px` and `prior_share` for each point between
its corners) and its own `decided_by`; `plane` with `from` `given` or `corners`; `rounds`, the solves it took.
`decided_by` is read from `prior_share` for every crown point: `plane` from 0.2 up, the prior (the plane, and
for a side's inner points its fairness) holding the depth; under 0.2 `mirror` for a point on the seam and
`views` for any other. A seam corner seen from 10 degrees off the mirror plane reads `plane` (0.57), not
`mirror`. A side says `corners` when it has no point of its own, `plane` when any inner point does, else what
its inner points say: a side can read as explained to 0.1 px and stand 53 mm off with its one inner point at
0.41, and then it says `plane`.
Refused, naming the field: a corner no trace ends at, a side traced in no view, a trace whose corners are not
consecutive, an unknown camera, a scaled frame, a seam that is not one stretch of the outline, no plane where
fewer than three corners are decided, the 66 degrees, a mirrored plate's corner that starts or ends across x = 0
from the others (name it in `seam`, or trace it where the views agree), a side not explained at six points, a
sheet the cage's parser does not take, and a result that could pass the 16000 characters a receipt carries.
Measured against a known truth (`tests/test_reference.py` BlockTests, Python 3.13 on Starfire;
`tests/fixtures/spectre_truth.json`), on one plate through one pair of views. SPECTRE's pass-3 roof, a hard
mirrored cage of 11 vertices, was built by `brokkr_kitbash.shell` and rendered in Blender 5.3 through SPECTRE's
two solved cameras at the sheet's pixel size. Its edges were traced off the renders: the ridge in the side
view, the lip, outer edge and rear edge in the hero's mirrored half and the side view, 62 degrees apart. The
side view's pixel is 27.6 mm across at the plate.
How the traces were taken. No hand drew them. A search follows a seed polyline, takes the strongest brightness
step within a window across each edge, lays a straight stroke through the steps found on each segment, and ends
each stroke where it crosses its neighbours. The seed is the truth's projection moved off the answer, in eight
families: the whole seed by 0.5, 1 or 1.5 px in a drawn direction (a 2.5 px window), or each of its vertices by
a normal draw of 1 or 2 px (3.5 px), 2 px (5 px), 3 px (6 px) or 4 px (8 px). Every corner is named. A take's
worst point stands far from the truth's projection, 3 to 12 px at the families' medians: two strokes that run
nearly along each other cross far from the corner. Forty fresh draws a family (the fixture holds twelve of
each of six, 72 takes, which the test blocks; the 2 px, 5 px and the 4 px, 8 px families are in neither):
| seed | window | blocked of 40 | worst traced point, px: median, most | worst corner, mm: median, most | worst corner over worst point x 27.6 mm, at most |
| --- | --- | --- | --- | --- | --- |
| moved 0.5 px as one | 2.5 px | 40 | 3.4, 30.2 | 47, 913 | 1.11 |
| moved 1 px as one | 2.5 px | 39 | 3.5, 30.4 | 67, 916 | 1.15 |
| moved 1.5 px as one | 2.5 px | 39 | 3.6, 24.9 | 66, 370 | 1.19 |
| each vertex 1 px | 3.5 px | 35 | 8.5, 28.2 | 171, 559 | 1.13 |
| each vertex 2 px | 3.5 px | 35 | 9.1, 28.8 | 153, 745 | 1.14 |
| each vertex 2 px | 5 px | 30 | 9.4, 41.5 | 170, 512 | 1.25 |
| each vertex 3 px | 6 px | 17 | 10.2, 73.6 | 231, 2038 | 1.15 |
| each vertex 4 px | 8 px | 8 | 12.0, 29.0 | 322, 417 | 1.33 |
The fixture's 72 takes read 1.18 at most (62 block; nine are refused at a side not explained at six points,
one at the cage's parser). These ratios are not the bound. A take's worst point is one far crossing, and it
inflates what the corner is measured against: the worst a trace does for its worst point is to have no
outlier, every point the same d px off the truth's projection. With no search, the truth's projection moved:
| every traced point d px off | worst corner over d x 27.6 mm, at most |
| --- | --- |
| each view moved as one, 12 directions by 12, at 1, 2, 3 px (all 144 block) | 1.505, 1.504, 1.502 (1.10 at the median) |
| each stroke its own direction, searched | 1.58 |
| each point its own direction, searched, at 1 and 3 px | 1.67, 1.66 |
The bound: worst corner <= 2.08 x d x pixel, d the furthest any traced point stands from the truth's
projection and pixel the coarser view's. 2.08 is the geometric mean of the 1.505 and of 2.865, what the
blocking reads on the same 144 without its end terms; it stands 1.25 over the worst a search found, which is
not the worst there is, and 1.57 over the worst family of takes. The test holds the 144, the searched worst
at 1 and 3 px and the 72 takes to it. It is a reading on one plate through one pair of views, 62 degrees
apart, not a law, and it says a plate is as good as its worst traced point: one stroke end 30 px off puts a
corner 0.9 m off, and nothing in the report says so, because that trace is explained. No bound is given in
the traces' rms: against it the fixture's takes run 0.57 to 5.3. The same search seeded on the truth's
projection itself, with a 2.5 px window, reads 39 mm; that is the window ending every stroke within 2.5 px of
the answer, and it is not an accuracy.
The error is not a multiple of `m_per_px` either: a seam corner 98 mm off reports 0.0008 m a pixel, because
`m_per_px` is depth along the sight line and most of this error lies across it. With only four corners named,
the roof's ridge and outer edge are one side each and are built as smooth runs through their hard knees:
explained within `tol`, 196 mm from the true edges (5.2 px is 144 mm there). Name a hard corner as a corner.
Fairness, 0.2 x a side's chord, is set by known truth at traced noise. Over ten cells at 1 and 2 px (the rendered
roof with four corners named, its strokes those of the search seeded on the truth with the noise added, with
and without closing strokes moved 3 px, and a bowed pentagon at 60 and 30 degrees and in one view), 168 draws:
the mean of the cells' 90th percentiles and the worst draw, in mm, over the draws that blocked, and the draws
refused, which no percentile counts:
| FAIR | 0.1 | 0.15 | 0.2 | 0.25 | 0.3 | 0.4 | 0.5 | 1 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| mean 90th percentile | 194 | 184 | 178 | 178 | 179 | 186 | 193 | 196 |
| worst draw | 301 | 275 | 273 | 272 | 312 | 382 | 494 | 577 |
| refused of 168 | 19 | 20 | 23 | 24 | 24 | 25 | 26 | 27 |
A higher FAIR, which is weaker fairness, refuses more draws, so each column's percentiles are
over a different set. On other seeds (Soul's probe, verdict cut-trace-block.s2, FAIR 0.1, 0.2, 0.3, 0.5) the
mean 90th percentile read 216, 188, 216, 250, the worst draw 542, 855, 679, 807 and the refused 18, 21, 26,
27; on a third (verdict cut-trace-block.s3, all eight) 196, 196, 195, 202, 199, 220, 234, 255, the worst draw
652, 876, 690, 843, 871, 500, 673, 741 and the refused 10, 15, 20, 20, 22, 22, 23, 23. FAIR is flat from 0.1
to 0.3 and worse above: 0.2 and 0.25 tie in the table, and 0.1 to 0.2 stand within 1 mm on the third set. 0.2
is kept as a point on that plateau, not a resolved lowest. From
exact traces weaker fairness is nearer the truth (a pentagon bowed 35% of its sides: 42 mm at 0.2, 16 at 0.5,
12 with none).
Agreement with other fits, which is not accuracy. SPECTRE's second-pass roof from its hand traces: the ridge
7.3 mm at most and the brow a median of 8.4 mm from the cage `fit_shell` had fitted to the same pixels; with
1 px of noise on those traces the brow's median read 11 to 75 mm over six draws (Soul's probe, verdict cut-trace-block.s1). Paladin's 16 plates, each a polygon traced in
one view with the plane its agent gave: every corner decided by the plane, the crown within 1 mm of the one
the harness had lifted onto the same plane. Its two thigh shields traced as partners are refused, a side 19 px
unexplained: the sheet draws two different polygons, not one plate and its reflection. RAPTOR's hull plate
bearing the 27 (`tests/fixtures/raptor_plates.json`), marked by eye in the hero and the SIDE view: seven hull
marks admit no hero camera under 25 px rms, so the sheet's two views do not draw one hull; through that camera
the plate blocks with its sight lines 34 to 40 degrees apart and the prior holding 0.17 to 0.20 of each corner.
What it gives up. One outline loop a plate: a plate that wraps a corner is two plates, and creases inside the
outline are not blocked. A bend smaller than `tol` is built straight, and a hard knee inside a side is rounded.
Fairness holds a grown side flatter than its trace while the trace still reads as explained (the side's
`decided_by` says when the prior holds it). The plane through the decided corners is a guess at a twisted
plate, and where one view sees a corner the plane is all the depth it has. Every crown point carries a skirt
vertex, so a point a side grows costs two.
## What it cannot do
It solves one pinhole camera for one view: no lens distortion, no two views solved together, one turned group and
no other pose. It does not find the points; marking them is the caller's. Points on posed joints fit worse than
points on rigid features of one body, because the build's pose is not the drawing's. It does not say whether the
subject is the right size: a build twice too large is the same picture from twice as far.
`block_plate` blocks one outline loop a plate and no crease inside it.
## From a script
```python
from brokkr_reference import core
cam = core.solve(world, pixels, box, model="auto") # dicts by name; the record
u_v = core.project(cam, points) # where it draws world points
origin, direction = core.ray(cam, (u, v)) # a pixel's line of sight
point = core.lift(cam, (u, v), plane_point, plane_normal) # a traced pixel on a plane
run = core.crease_run(column) # the hard crease Blender builds from a cage column
fit = core.fit_sheet(sheet, cage, frame, traces, cams) # the fitted sheet and its report; cage is brokkr_kitbash.core.sheet(sheet)
out = core.block_plate(views, plate, traces, parse) # a plate's first sheet and what decided each corner; parse is brokkr_kitbash.core.sheet
score = core.along(line, segments, height) # on, off, run against [u0, v0, u1, v1] segments
params = core.blender(cam, 1000) # matrix_world, lens, shifts, resolution
cam2 = core.camera_of(params, box) # and back
```
The tests are `tests/test_reference.py` (no Blender), `tests/live/reference.py` (a known scene rendered, solved
through the action and rendered again; `reference.result.json` is its last run) and `tests/live/reference_flow.py`
(`crease_run` against Blender's own subdivision, a box and a folded sheet scored by `flow_score`;
`reference_flow.result.json` is its last run) and `tests/live/reference_fit.py` (a mirrored loft and a mirrored
free cage, each blocked off its design, fitted through the action and rebuilt by `brokkr_kitbash.shell`;
`reference_fit.result.json` is its last run) and `tests/live/reference_block.py` (a bowed plate and a mirrored plate
blocked through the action from traces alone, built by `brokkr_kitbash.shell` and handed to `fit_shell`;
`reference_block.result.json` is its last run).

View file

@ -0,0 +1,543 @@
{
"about": "Lofts of planar trapezoid facets: the seeded lofts of Soul's probe of 2026-12-02 (aetheria-release:verdict:cut-kit-faceted-shell.s3), seed, levels and offset as drawn there, on which a wall of even offset folded well under any figure read from the cage (at 0.006342, 0.010394 and 0.00617). thickness is one at which the evaluated wall, Kit Solidify's plain offset, folds; holds, where the action's range reaches it, one at which it does not. Read 2026-12-03: seed 5185 first folds at 0.0425 and seed 5196 at 0.0232, thickness and holds standing 1.2 over and under; seed 5101 folds at the range's floor.",
"lofts": [
{
"seed": 5185,
"levels": 1,
"offset": -1.0,
"thickness": 0.051,
"holds": 0.0354,
"sheet": {
"rings": [
[
[
-0.824534,
0.0,
-0.055726
],
[
-0.20124,
0.0,
-0.555671
],
[
0.277571,
0.0,
-0.326276
],
[
0.355141,
0.0,
-0.095203
],
[
0.451529,
0.0,
-0.526972
],
[
0.730665,
0.0,
-0.126214
]
],
[
[
-0.644054,
0.57461,
-0.007851
],
[
-0.166195,
0.57461,
-0.391143
],
[
0.200893,
0.57461,
-0.215272
],
[
0.260364,
0.57461,
-0.038117
],
[
0.334261,
0.57461,
-0.36914
],
[
0.548265,
0.57461,
-0.061892
]
],
[
[
-0.670812,
0.958364,
0.100578
],
[
-0.338388,
0.958364,
-0.16606
],
[
-0.083022,
0.958364,
-0.043715
],
[
-0.041652,
0.958364,
0.079523
],
[
0.009755,
0.958364,
-0.150754
],
[
0.158628,
0.958364,
0.062984
]
],
[
[
-0.121748,
1.402066,
-0.069972
],
[
0.06524,
1.402066,
-0.219956
],
[
0.208883,
1.402066,
-0.151137
],
[
0.232154,
1.402066,
-0.081816
],
[
0.261071,
1.402066,
-0.211346
],
[
0.344812,
1.402066,
-0.091119
]
]
],
"creases": [
{
"ring": 1,
"from": 4,
"to": 5,
"weight": 0.3
},
{
"column": 3,
"from": 0,
"to": 3,
"weight": 1.0
},
{
"ring": 2,
"from": 0,
"to": 3,
"weight": 1.0
}
],
"rim": 0.5
}
},
{
"seed": 5101,
"levels": 3,
"offset": 0.0,
"thickness": 0.010394,
"holds": null,
"sheet": {
"rings": [
[
[
-0.70481,
0.0,
0.07744
],
[
-0.108308,
0.0,
0.00574
],
[
0.492256,
0.0,
-0.339801
],
[
0.608357,
0.0,
-0.456893
],
[
0.685935,
0.0,
-0.379315
],
[
0.817607,
0.0,
0.061337
]
],
[
[
-0.355146,
0.797251,
0.328588
],
[
0.181707,
0.797251,
0.264058
],
[
0.722214,
0.797251,
-0.046929
],
[
0.826705,
0.797251,
-0.152312
],
[
0.896525,
0.797251,
-0.082492
],
[
1.01503,
0.797251,
0.314095
]
],
[
[
-0.785461,
1.527843,
-0.183277
],
[
-0.308259,
1.527843,
-0.240637
],
[
0.172192,
1.527843,
-0.51707
],
[
0.265072,
1.527843,
-0.610743
],
[
0.327135,
1.527843,
-0.548681
],
[
0.432473,
1.527843,
-0.19616
]
],
[
[
-0.488084,
2.123542,
-0.236617
],
[
-0.070532,
2.123542,
-0.286807
],
[
0.349863,
2.123542,
-0.528686
],
[
0.431133,
2.123542,
-0.61065
],
[
0.485438,
2.123542,
-0.556346
],
[
0.577608,
2.123542,
-0.247889
]
],
[
[
-0.714517,
2.852512,
0.062817
],
[
-0.356616,
2.852512,
0.019796
],
[
0.003723,
2.852512,
-0.187528
],
[
0.073383,
2.852512,
-0.257783
],
[
0.11993,
2.852512,
-0.211237
],
[
0.198933,
2.852512,
0.053154
]
]
],
"creases": [
{
"ring": 2,
"from": 3,
"to": 5,
"weight": 1.0
},
{
"column": 1,
"from": 3,
"to": 4,
"weight": 0.6
},
{
"column": 3,
"from": 3,
"to": 4,
"weight": 1.0
}
],
"rim": 0.0
}
},
{
"seed": 5196,
"levels": 1,
"offset": 1.0,
"thickness": 0.0279,
"holds": 0.0194,
"sheet": {
"rings": [
[
[
-0.383345,
0.0,
-0.359947
],
[
-0.036452,
0.0,
-0.050835
],
[
0.567786,
0.0,
-0.587238
],
[
0.622834,
0.0,
-0.467053
],
[
0.672276,
0.0,
-0.379683
],
[
0.730008,
0.0,
-0.43819
]
],
[
[
-0.557286,
0.459757,
-0.324159
],
[
-0.2711,
0.459757,
-0.069142
],
[
0.227397,
0.459757,
-0.511675
],
[
0.272811,
0.459757,
-0.412522
],
[
0.313601,
0.459757,
-0.340441
],
[
0.36123,
0.459757,
-0.38871
]
],
[
[
-0.062837,
0.80579,
-0.458467
],
[
0.162644,
0.80579,
-0.257545
],
[
0.555399,
0.80579,
-0.606206
],
[
0.591179,
0.80579,
-0.528086
],
[
0.623317,
0.80579,
-0.471295
],
[
0.660843,
0.80579,
-0.509325
]
],
[
[
-0.125811,
1.151684,
-0.10837
],
[
0.038964,
1.151684,
0.038458
],
[
0.325977,
1.151684,
-0.216334
],
[
0.352124,
1.151684,
-0.159246
],
[
0.375609,
1.151684,
-0.117745
],
[
0.403032,
1.151684,
-0.145536
]
],
[
[
0.161946,
1.542628,
0.17642
],
[
0.266014,
1.542628,
0.269154
],
[
0.447285,
1.542628,
0.108233
],
[
0.463799,
1.542628,
0.144288
],
[
0.478632,
1.542628,
0.170499
],
[
0.495952,
1.542628,
0.152947
]
]
],
"creases": [
{
"ring": 3,
"from": 3,
"to": 4,
"weight": 1.0
},
{
"column": 3,
"from": 3,
"to": 4,
"weight": 1.0
}
],
"rim": 0.5
}
}
]
}

View file

@ -0,0 +1,224 @@
{
"what": "Orchid concept c09 (one view): the camera record brokkr_reference.solve_camera solved from hand marks, the frame of the ship's mirror plane, the inboard edge of the two upper petals traced by eye (left is the mirrored half), and a blocking column of 8 stations standing up to a tenth of the ship's length off. No mesh and no hull: the sheet the test builds round the column is a strip that exists to carry it.",
"camera": {
"C": [
-6.168901501633792,
-121.90792252280691,
2.8948965905734094
],
"R": [
[
0.9987259467882663,
-0.05046269128654356,
0.0
],
[
0.0009919726785528231,
0.019632501305770517,
0.9998067717727681
],
[
-0.05045294047016491,
-0.9985329647440779,
0.01965754606547003
]
],
"f": 113777.77777777778,
"c": [
512.0,
512.0
],
"box": [
0.0,
0.0,
1024.0,
1024.0
],
"lens": 4000.0
},
"frame": [
[
0.7946956336528872,
0.5885955750367245,
-0.14837148951272178,
0.03987530991435051
],
[
-0.6006879570259439,
0.7273858746251298,
-0.3317887395313959,
0.013782020658254623
],
[
-0.08736605826654754,
0.35279602951708855,
0.9316126520286978,
0.5812516808509827
],
[
0.0,
0.0,
0.0,
1.0
]
],
"left": [
[
556.3,
34.2
],
[
533.3,
50.0
],
[
518.8,
64.6
],
[
500.0,
89.6
],
[
483.3,
118.8
],
[
466.7,
147.9
],
[
450.0,
178.3
],
[
433.3,
208.3
],
[
408.3,
258.3
],
[
389.6,
295.8
],
[
375.0,
329.2
],
[
356.3,
360.4
],
[
337.5,
389.6
],
[
320.8,
418.8
],
[
306.3,
445.8
]
],
"right": [
[
888.8,
86.7
],
[
853.3,
97.9
],
[
815.8,
112.5
],
[
778.3,
129.2
],
[
740.8,
152.1
],
[
703.3,
179.2
],
[
665.8,
210.4
],
[
636.7,
233.3
],
[
607.5,
262.5
],
[
582.5,
295.8
],
[
559.6,
337.5
],
[
532.5,
395.8
],
[
503.3,
466.7
]
],
"left_side": -1,
"blocking": [
[
0.2278,
0.3586,
0.279
],
[
0.1764,
0.183,
0.3436
],
[
0.1489,
0.0666,
0.297
],
[
0.2226,
0.1029,
0.2136
],
[
0.251,
0.1112,
0.0995
],
[
0.2813,
0.1228,
0.0095
],
[
0.2259,
-0.0472,
0.0286
],
[
0.4158,
0.1062,
-0.1008
]
]
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,50 @@
{"source": {"branch": "nibu/fable-bastion-2", "sha": "eeda8bf2defd411bebc2fd438d8934ba46e88614", "blender": "5.3.0"},
"table": {"schema": "brokkr.plates.v0", "plates": [
{"name": "Core.upper", "mat": "gunmetal", "bevel": 0.0, "mirror": true, "points": [[0.0, 5.3, 5.3], [2.2, 5.0, 5.3], [4.3, 3.6, 5.3], [4.5, 0.9, 5.2], [4.5, -1.4, 5.4], [4.3, -2.8, 5.6], [3.6, -4.4, 5.8], [2.2, -5.0, 5.9], [0.0, -5.0, 5.9], [0.0, 3.4, 6.8], [2.2, 3.4, 6.8], [4.0, 3.0, 6.6], [4.2, 0.9, 6.8], [4.2, -1.4, 6.8], [3.9, -2.8, 6.8], [3.2, -4.2, 6.8], [0.0, -4.6, 6.9], [2.6, 2.6, 7.3], [2.6, -2.6, 7.3], [0.0, 3.4, 7.0]]},
{"name": "Core.belly", "mat": "gunmetal", "bevel": 0.03, "mirror": true, "points": [[2.3, 4.7, 5.3], [2.3, -4.9, 5.9], [1.7, 4.0, 3.6], [1.8, 2.2, 3.3], [1.8, -2.6, 3.35], [1.5, -4.6, 4.0], [1.2, 4.9, 3.7]]},
{"name": "Core.cheek_tray", "mat": "gunmetal", "bevel": 0.0, "sides": "both", "faces": [{"at": [2.2479736988984707, 5.264865987629634, 5.0], "normal": [0.5429510753626048, 0.839764329894162, 0.0]}, {"at": [1.6941636020286137, 4.40830637113759, 5.0], "normal": [-0.5429510753626048, -0.839764329894162, 0.0]}, {"at": [0.0, 0.0, 4.9], "normal": [0.0, 0.0, -1.0]}, {"at": [0.0, 0.0, 5.3], "normal": [0.0, 0.0, 1.0]}, {"at": [2.5, 0.0, 0.0], "normal": [-1.0, 0.0, 0.0]}, {"at": [4.750163376895761, 0.8804114363827034, 4.6936620832203895], "normal": [1.0, 0.07, 0.38]}]},
{"name": "Hull.Brow", "mat": "olive", "bevel": 0.04, "mirror": true, "points": [[0.0, 6.3, 5.58], [1.05, 6.25, 5.72], [2.0, 5.72, 5.76], [2.28, 4.95, 5.8], [0.0, 6.14, 6.12], [1.0, 6.1, 6.14], [1.92, 5.6, 6.16], [2.2, 4.95, 6.2], [0.0, 3.25, 7.0], [2.05, 3.25, 7.0], [0.0, 3.25, 6.2], [2.28, 3.25, 6.2]], "clad": {"mat": "olive_light", "facets": [{"n": [0, 0, 1], "cos": 0.6}, {"radial": [0, 0, 1], "min_r": 1.0, "cos": 0.25}], "floor": -0.35, "min_area": 0.9, "lifts": [0.045, 0.075], "inset": 0.11, "gap": 0.05, "split": 2.2, "seed": 2}},
{"name": "Hull.Chin", "mat": "olive", "bevel": 0.04, "mirror": true, "points": [[0.0, 5.78, 5.2], [1.0, 5.78, 5.2], [2.1, 5.15, 5.2], [2.3, 4.3, 5.2], [0.0, 5.45, 3.95], [0.85, 5.45, 3.95], [1.75, 4.95, 3.98], [1.95, 4.3, 4.0], [2.3, 3.5, 5.2], [1.95, 3.5, 3.95]], "clad": {"mat": "olive_light", "facets": [{"n": [0, 0, 1], "cos": 0.6}, {"radial": [0, 0, 1], "min_r": 1.0, "cos": 0.25}], "floor": -0.35, "min_area": 0.9, "lifts": [0.045, 0.075], "inset": 0.11, "gap": 0.05, "split": 2.2, "seed": 7}},
{"name": "Hull.Sill", "mat": "olive_light", "bevel": 0.02, "mirror": true, "points": [[0.0, 5.9, 5.2], [1.05, 5.9, 5.2], [2.2, 5.22, 5.2], [0.0, 5.84, 5.3], [1.02, 5.84, 5.3], [2.14, 5.18, 5.3], [0.0, 5.3, 5.2], [2.0, 4.9, 5.2], [0.0, 5.3, 5.3], [2.0, 4.9, 5.3]]},
{"name": "Hull.Jaw", "mat": "olive_light", "bevel": 0.03, "mirror": true, "points": [[1.2, 5.3, 3.97], [1.2, 3.7, 3.97], [1.0, 5.12, 3.3], [1.0, 3.85, 3.3]]},
{"name": "Hull.Cheek", "mat": "olive", "bevel": 0.04, "sides": "both", "faces": [{"through": [[2.4, 5.5, 5.25], [4.72, 4.0, 5.25], [2.38, 5.2, 6.2]], "out": [0.5, 1.0, 0.2]}, {"at": [4.93672112563192, 0.8934704787942345, 4.76455402774013], "normal": [1.0, 0.07, 0.38]}, {"at": [4.2, 0.9, 6.95], "normal": [0.3, 0.08, 1.0]}, {"at": [2.38, 5.2, 6.2], "normal": [0.12, 0.4, 1.0]}, {"at": [0.0, 0.0, 5.25], "normal": [0.0, 0.0, -1.0]}, {"at": [0.0, 0.9, 0.0], "normal": [0.0, -1.0, 0.0]}, {"at": [2.38, 0.0, 0.0], "normal": [-1.0, 0.0, 0.0]}, {"at": [2.057666384578959, 1.9719302852215022, 0.0], "normal": [-0.7219882051154242, -0.6919053632356148, -0.0]}], "clad": {"mat": "olive_light", "facets": [{"n": [0, 0, 1], "cos": 0.6}, {"radial": [0, 0, 1], "min_r": 1.0, "cos": 0.25}], "floor": -0.35, "min_area": 0.9, "lifts": [0.045, 0.075], "inset": 0.11, "gap": 0.05, "split": 2.2, "seed": [4, 3]}},
{"name": "Hull.Skirt", "mat": "olive", "bevel": 0.035, "sides": "both", "points": [[4.622999999999999, 4.0, 5.3], [4.8016, 3.62, 4.9], [5.1695, 1.35, 4.35], [5.03, 0.9, 4.8], [4.384, 0.9, 6.5], [4.295, 3.8, 6.2], [4.324507602022145, 3.97910553214155, 5.186572888768415], [4.503107602022145, 3.59910553214155, 4.786572888768416], [4.8710076020221456, 1.3291055321415504, 4.236572888768415], [4.731507602022146, 0.8791055321415502, 4.686572888768415], [4.085507602022146, 0.8791055321415502, 6.3865728887684154], [3.9965076020221453, 3.77910553214155, 6.086572888768416]]},
{"name": "Hull.CheekLip", "mat": "olive_light", "bevel": 0.02, "sides": "both", "faces": [{"at": [2.4, 5.5, 5.0], "normal": [0.5429510753626048, 0.839764329894162, 0.0]}, {"at": [2.313127827941983, 5.365637707216934, 5.0], "normal": [-0.5429510753626048, -0.839764329894162, 0.0]}, {"at": [0.0, 0.0, 4.84], "normal": [0.0, 0.0, -1.0]}, {"at": [0.0, 0.0, 4.99], "normal": [0.0, 0.0, 1.0]}, {"at": [2.45, 0.0, 0.0], "normal": [-1.0, 0.0, 0.0]}, {"at": [4.93672112563192, 0.8934704787942345, 4.76455402774013], "normal": [1.0, 0.07, 0.38]}]},
{"name": "Hull.Quarter", "mat": "olive", "bevel": 0.04, "sides": "both", "faces": [{"at": [5.0, -1.4, 5.5], "normal": [1.0, -0.1, 0.4]}, {"at": [4.45, -3.7, 5.7], "normal": [0.904, -0.427, 0.4]}, {"at": [3.2, -4.9, 5.85], "normal": [0.351, -0.936, 0.35]}, {"at": [4.2, -2.6, 6.95], "normal": [0.28, -0.1, 1.0]}, {"at": [0.0, -1.35, 5.5], "normal": [0.0, -0.12, -1.0]}, {"at": [0.0, -1.4, 0.0], "normal": [0.0, 1.0, 0.0]}, {"at": [1.75, 0.0, 0.0], "normal": [-1.0, 0.0, 0.0]}, {"at": [2.139533523229853, -1.8827895004422703, 0.0], "normal": [-0.7507135169227553, 0.6606278948920247, -0.0]}], "clad": {"mat": "olive_light", "facets": [{"n": [0, 0, 1], "cos": 0.6}, {"radial": [0, 0, 1], "min_r": 1.0, "cos": 0.25}], "floor": -0.35, "min_area": 0.9, "lifts": [0.045, 0.075], "inset": 0.11, "gap": 0.05, "split": 2.2, "seed": [15, 14]}},
{"name": "Hull.FlankRoof", "mat": "olive_light", "bevel": 0.03, "sides": "both", "faces": [{"at": [4.3, 0.0, 7.05], "normal": [0.3, 0.0, 1.0]}, {"at": [4.7, 0.0, 0.0], "normal": [1.0, 0.0, 0.25]}, {"at": [0.0, 0.0, 6.88], "normal": [0.0, 0.0, -1.0]}, {"at": [0.0, 0.85, 0.0], "normal": [0.0, 1.0, 0.0]}, {"at": [0.0, -1.3, 0.0], "normal": [0.0, -1.0, 0.0]}, {"at": [2.8, 0.0, 0.0], "normal": [-1.0, 0.0, 0.0]}], "clad": {"mat": "olive", "facets": [{"n": [0, 0, 1], "cos": 0.6}, {"radial": [0, 0, 1], "min_r": 1.0, "cos": 0.25}], "floor": -0.35, "min_area": 0.9, "lifts": [0.045, 0.075], "inset": 0.11, "gap": 0.05, "split": 2.2, "seed": [10, 9]}},
{"name": "Hull.FlankSill", "mat": "olive", "bevel": 0.03, "sides": "both", "faces": [{"at": [4.98, 0.0, 0.0], "normal": [1.0, 0.0, 0.12]}, {"at": [3.9, 0.0, 0.0], "normal": [-1.0, 0.0, 0.0]}, {"at": [0.0, 0.0, 5.12], "normal": [0.0, 0.0, -1.0]}, {"at": [0.0, 0.0, 5.45], "normal": [0.0, 0.0, 1.0]}, {"at": [0.0, 0.85, 0.0], "normal": [0.0, 1.0, 0.0]}, {"at": [0.0, -1.3, 0.0], "normal": [0.0, -1.0, 0.0]}]},
{"name": "Hull.Tail", "mat": "olive_light", "bevel": 0.03, "mirror": true, "points": [[1.72, -2.75, 7.5], [1.72, -5.0, 7.3], [1.72, -2.75, 7.15], [1.72, -5.0, 7.0]], "clad": {"mat": "olive", "facets": [{"n": [0, 0, 1], "cos": 0.6}, {"radial": [0, 0, 1], "min_r": 1.0, "cos": 0.25}], "floor": -0.35, "min_area": 0.9, "lifts": [0.045, 0.075], "inset": 0.11, "gap": 0.05, "split": 2.2, "seed": 19}},
{"name": "Hull.BellySide", "mat": "olive_light", "bevel": 0.03, "sides": "both", "points": [[2.1, 2.2, 3.9], [2.1, -2.4, 3.95], [2.45, 2.0, 4.1], [2.45, -2.2, 4.15], [2.45, 2.0, 4.85], [2.45, -2.2, 4.9], [2.25, 2.2, 5.1], [2.25, -2.4, 5.15], [1.8, 2.2, 3.9], [1.8, -2.4, 5.15]], "clad": {"mat": "olive", "facets": [{"n": [0, 0, 1], "cos": 0.6}, {"radial": [0, 0, 1], "min_r": 1.0, "cos": 0.25}], "floor": -0.35, "min_area": 0.9, "lifts": [0.045, 0.075], "inset": 0.11, "gap": 0.05, "split": 2.2, "seed": [1, 0]}}
]},
"cases": [
{"side": 1, "truth": {
"Core.upper": {"solid":[[0.0,5.3000002,5.3000002],[2.2,5.0,5.3000002],[4.3000002,3.5999999,5.3000002],[4.5,0.9,5.1999998],[4.5,-1.4,5.4000001],[4.3000002,-2.8,5.5999999],[3.5999999,-4.4000001,5.8000002],[2.2,-5.0,5.9000001],[2.2,3.4000001,6.8000002],[4.0,3.0,6.5999999],[4.1999998,0.9,6.8000002],[4.1999998,-1.4,6.8000002],[3.9000001,-2.8,6.8000002],[3.2,-4.1999998,6.8000002],[0.0,-4.5999999,6.9000001],[2.5999999,2.5999999,7.3000002],[2.5999999,-2.5999999,7.3000002],[0.0,3.4000001,7.0],[-2.2,5.0,5.3000002],[-4.3000002,3.5999999,5.3000002],[-4.5,0.9,5.1999998],[-4.5,-1.4,5.4000001],[-4.3000002,-2.8,5.5999999],[-3.5999999,-4.4000001,5.8000002],[-2.2,-5.0,5.9000001],[-2.2,3.4000001,6.8000002],[-4.0,3.0,6.5999999],[-4.1999998,0.9,6.8000002],[-4.1999998,-1.4,6.8000002],[-3.9000001,-2.8,6.8000002],[-3.2,-4.1999998,6.8000002],[-2.5999999,2.5999999,7.3000002],[-2.5999999,-2.5999999,7.3000002]],"facets":54,"panels":[],"bolts":0},
"Core.belly": {"solid":[[2.3,4.6999998,5.3000002],[2.3,-4.9000001,5.9000001],[1.7,4.0,3.5999999],[1.8,2.2,3.3],[1.8,-2.5999999,3.3499999],[1.5,-4.5999999,4.0],[1.2,4.9000001,3.7],[-2.3,4.6999998,5.3000002],[-2.3,-4.9000001,5.9000001],[-1.7,4.0,3.5999999],[-1.8,2.2,3.3],[-1.8,-2.5999999,3.3499999],[-1.5,-4.5999999,4.0],[-1.2,4.9000001,3.7]],"facets":18,"panels":[],"bolts":0},
"Core.cheek_tray.R": {"solid":[[2.5,5.1019173,4.9000001],[4.4651914,3.8313196,4.9000001],[2.5,5.1019173,5.3000002],[4.3059859,3.9342542,5.3000002],[2.5,3.8872914,4.9000001],[4.5542455,2.5591156,4.9000001],[2.5,3.8872914,5.3000002],[4.39504,2.6620502,5.3000002]],"facets":6,"panels":[],"bolts":0},
"Core.cheek_tray.L": {"solid":[[-2.5,5.1019173,4.9000001],[-4.4651914,3.8313196,4.9000001],[-2.5,5.1019173,5.3000002],[-4.3059859,3.9342542,5.3000002],[-2.5,3.8872914,4.9000001],[-4.5542455,2.5591156,4.9000001],[-2.5,3.8872914,5.3000002],[-4.39504,2.6620502,5.3000002]],"facets":6,"panels":[],"bolts":0},
"Hull.Brow": {"solid":[[0.0,6.3000002,5.5799999],[1.05,6.25,5.7199998],[2.0,5.7199998,5.7600002],[2.28,4.9499998,5.8000002],[0.0,6.1399999,6.1199999],[1.0,6.0999999,6.1399999],[1.92,5.5999999,6.1599998],[2.2,4.9499998,6.1999998],[2.05,3.25,7.0],[2.28,3.25,6.1999998],[-1.05,6.25,5.7199998],[-2.0,5.7199998,5.7600002],[-2.28,4.9499998,5.8000002],[-1.0,6.0999999,6.1399999],[-1.92,5.5999999,6.1599998],[-2.2,4.9499998,6.1999998],[-2.05,3.25,7.0],[-2.28,3.25,6.1999998]],"facets":29,"panels":[[0.3885275,5.9889116,6.1526303],[-0.9221566,5.9889116,6.1526303],[-1.8945599,3.3495317,6.9490747],[0.3885272,3.3495317,6.9490747],[0.3885275,6.0105786,6.2244325],[-0.9221566,6.0105786,6.2244325],[-1.8945599,3.3711982,7.0208769],[0.3885272,3.3711982,7.0208769],[0.3685275,5.9972091,6.2493577],[-0.9080032,5.9972091,6.2493577],[-1.866298,3.3961234,7.0342464],[0.3685272,3.3961234,7.0342464],[1.8945597,3.3495317,6.9490747],[0.9221566,5.9889116,6.1526303],[0.6585274,5.9889116,6.1526303],[0.6585273,3.3495317,6.9490747],[1.8945597,3.3625317,6.992156],[0.9221566,6.0019116,6.1957116],[0.6585274,6.0019116,6.1957116],[0.6585273,3.3625317,6.992156],[1.866298,3.3874567,7.0055256],[0.9080032,5.9885426,6.2206364],[0.6785274,5.9885426,6.2206364],[0.6785272,3.3874567,7.0055256],[1.9754326,3.5847373,6.8687177],[1.811658,5.5343542,6.1817808],[1.1911595,5.8715816,6.168292],[1.9828436,3.60004,6.9103818],[1.8190689,5.5496569,6.2234454],[1.1985704,5.8868842,6.2099562],[1.9730231,3.6689181,6.9084315],[1.8035812,5.5455861,6.2492967],[1.2357996,5.8541627,6.2369537],[-1.811658,5.5343542,6.1817808],[-1.9754326,3.5847373,6.8687177],[-1.1911596,5.8715811,6.168292],[-1.8190689,5.5496569,6.2234454],[-1.9828436,3.60004,6.9103818],[-1.1985705,5.8868837,6.2099562],[-1.8035812,5.5455861,6.2492967],[-1.9730231,3.6689181,6.9084315],[-1.2357996,5.8541627,6.2369537]],"bolts":14},
"Hull.Chin": {"solid":[[1.0,5.7800002,5.1999998],[2.0999999,5.1500001,5.1999998],[2.3,4.3000002,5.1999998],[0.85,5.4499998,3.95],[1.75,4.9499998,3.98],[1.95,4.3000002,4.0],[2.3,3.5,5.1999998],[1.95,3.5,3.95],[-1.0,5.7800002,5.1999998],[-2.0999999,5.1500001,5.1999998],[-2.3,4.3000002,5.1999998],[-0.85,5.4499998,3.95],[-1.75,4.9499998,3.98],[-1.95,4.3000002,4.0],[-2.3,3.5,5.1999998],[-1.95,3.5,3.95]],"facets":18,"panels":[[-0.3619034,5.6700001,5.1800003],[-0.9707303,5.6700001,5.1800003],[-2.0038681,5.0782938,5.1800003],[-2.1900001,4.2872334,5.1800003],[-2.1900001,3.6100001,5.1800003],[-0.3619035,3.6100001,5.1800003],[-0.3619034,5.6700001,5.2250004],[-0.9707303,5.6700001,5.2250004],[-2.0038681,5.0782938,5.2250004],[-2.1900001,4.2872334,5.2250004],[-2.1900001,3.6100001,5.2250004],[-0.3619035,3.6100001,5.2250004],[-0.3819034,5.6500001,5.2450004],[-0.9654085,5.6500001,5.2450004],[-1.9863894,5.0652566,5.2450004],[-2.1700001,4.2849121,5.2450004],[-2.1700001,3.6300001,5.2450004],[-0.3819035,3.6300001,5.2450004],[2.1900001,4.2872334,5.1800003],[2.0038681,5.0782938,5.1800003],[0.9707303,5.6700001,5.1800003],[-0.0919034,5.6700001,5.1800003],[-0.0919033,3.6100001,5.1800003],[2.1900001,3.6100001,5.1800003],[2.1900001,4.2872334,5.2550001],[2.0038681,5.0782938,5.2550001],[0.9707303,5.6700001,5.2550001],[-0.0919034,5.6700001,5.2550001],[-0.0919033,3.6100001,5.2550001],[2.1900001,3.6100001,5.2550001],[2.1700001,4.2849121,5.2750001],[1.9863894,5.0652566,5.2750001],[0.9654086,5.6500001,5.2750001],[-0.0719035,5.6500001,5.2750001],[-0.0719033,3.6300001,5.2750001],[2.1700001,3.6300001,5.2750001],[-0.8764993,5.7325845,5.0987487],[-0.0504766,5.7325845,5.0987487],[-0.0504766,5.4587402,4.061461],[-0.7520249,5.4587402,4.061461],[-0.8764993,5.7760935,5.0872622],[-0.0504766,5.7760935,5.0872622],[-0.0504766,5.5022492,4.0499744],[-0.7520249,5.5022492,4.0499744],[-0.8540447,5.7903261,5.06282],[-0.0704766,5.7903261,5.06282],[-0.0704766,5.5266919,4.0642071],[-0.7342112,5.5266919,4.0642071],[0.2195233,5.7325845,5.0987492],[0.8764993,5.7325845,5.0987492],[0.7520248,5.4587402,4.0614614],[0.2195233,5.4587402,4.0614614],[0.2195233,5.8051,5.0796051],[0.8764993,5.8051,5.0796051],[0.7520248,5.5312557,4.0423174],[0.2195233,5.5312557,4.0423174],[0.2395233,5.8193321,5.0551624],[0.8540447,5.8193321,5.0551624],[0.7342112,5.5556984,4.05655],[0.2395233,5.5556984,4.05655],[1.6727291,5.0044794,4.0888481],[0.9496512,5.4084468,4.064147],[1.0728847,5.6800089,5.100059],[1.9638414,5.1720209,5.0994902],[1.708429,5.0671163,4.068181],[0.9853511,5.4710841,4.0434804],[1.1085846,5.7426457,5.079392],[1.9995413,5.2346578,5.0788231],[1.705741,5.0969553,4.0813947],[1.0146099,5.4830751,4.057785],[1.1331977,5.7443995,5.0546436],[1.9859257,5.2582078,5.0540991],[-1.6727293,5.0044794,4.0888476],[-1.9638416,5.1720209,5.0994897],[-1.0728848,5.6800089,5.1000586],[-0.9496514,5.4084473,4.064147],[-1.6941493,5.0420618,4.0764475],[-1.9852614,5.2096033,5.0870895],[-1.0943048,5.7175913,5.0876584],[-0.9710713,5.4460292,4.0517464],[-1.6914613,5.0719008,4.0896611],[-1.9716458,5.2331533,5.0623655],[-1.1189178,5.7193451,5.0629101],[-1.0003301,5.4580207,4.0660515]],"bolts":28},
"Hull.Sill": {"solid":[[1.05,5.9000001,5.1999998],[2.2,5.2199998,5.1999998],[1.02,5.8400002,5.3000002],[2.1400001,5.1799998,5.3000002],[2.0,4.9000001,5.1999998],[2.0,4.9000001,5.3000002],[-1.05,5.9000001,5.1999998],[-2.2,5.2199998,5.1999998],[-1.02,5.8400002,5.3000002],[-2.1400001,5.1799998,5.3000002],[-2.0,4.9000001,5.1999998],[-2.0,4.9000001,5.3000002]],"facets":12,"panels":[],"bolts":0},
"Hull.Jaw": {"solid":[[1.2,5.3000002,3.97],[1.2,3.7,3.97],[1.0,5.1199999,3.3],[1.0,3.8499999,3.3],[-1.2,5.3000002,3.97],[-1.2,3.7,3.97],[-1.0,5.1199999,3.3],[-1.0,3.8499999,3.3]],"facets":6,"panels":[],"bolts":0},
"Hull.Cheek.R": {"solid":[[4.0699725,4.0184684,6.4698162],[4.5260153,4.125421,5.25],[2.3800001,5.1999998,6.1999998],[2.3800001,5.5129309,5.25],[3.9938784,3.1328073,6.8332119],[4.0936742,0.9,6.9818964],[4.7517948,0.9,5.25],[2.3800001,2.2249999,7.3899999],[3.0849326,0.9,7.2845197],[2.3800001,1.6355822,7.4371529],[3.084933,0.9,5.25],[2.3800001,1.6355822,5.25]],"facets":8,"panels":[[4.0605597,2.097348,6.7920513],[4.1092281,1.0084592,6.8645611],[4.6863694,1.0084592,5.3457685],[4.6074672,2.1356313,5.3457685],[4.1025352,2.1002862,6.808002],[4.1512036,1.0113975,6.8805118],[4.7283449,1.0113975,5.3617191],[4.6494427,2.1385696,5.3617191],[4.1291742,2.0821021,6.7976732],[4.1760793,1.0326607,6.8675566],[4.7384973,1.0326607,5.3875098],[4.6624231,2.1194293,5.3875098],[4.0154209,3.1072907,6.7247982],[4.048501,2.3671649,6.7740841],[4.588614,2.4049726,5.345768],[4.4765992,4.0051847,5.345768],[4.0846686,3.9132679,6.3940973],[4.0853801,3.1121879,6.7513828],[4.1184602,2.372062,6.8006682],[4.6585732,2.4098697,5.3723526],[4.5465584,4.0100818,5.3723526],[4.1546278,3.918165,6.420682],[4.1113443,3.1090918,6.7400494],[4.1433125,2.3938506,6.7876778],[4.6687603,2.4306319,5.3981428],[4.5596213,3.9897637,5.3981428],[4.1793475,3.9005809,6.4152932],[2.4871092,4.9912777,6.2489614],[2.4871092,3.9125221,6.6804638],[3.9440475,3.8522353,6.5297465],[3.9538085,3.9658458,6.4831309],[2.4920921,5.0078874,6.2904863],[2.4920921,3.9291317,6.7219882],[3.9490304,3.868845,6.5712709],[3.9587915,3.9824557,6.5246553],[2.5141838,4.978662,6.3211989],[2.5141838,3.9542611,6.7309594],[3.9328942,3.895556,6.5841966],[3.9402881,3.9816122,6.5488873],[2.4871085,3.661833,6.7807398],[2.4871085,2.4007239,7.285183],[3.8869905,3.1881585,6.8022237],[3.9225841,3.6024342,6.6322427],[2.4954133,3.6895161,6.849947],[2.4954133,2.428407,7.3543901],[3.8952954,3.2158415,6.8714314],[3.9308889,3.6301172,6.7014499],[2.5175052,3.6775062,6.8737741],[2.5175049,2.4690814,7.3571434],[3.8784785,3.2346296,6.8876081],[3.9115732,3.6198206,6.7295604],[3.9776521,1.0081506,6.9871097],[3.9508991,1.6067107,6.9472508],[2.4796586,1.5705372,7.3915172],[2.4796588,1.6776093,7.3829517],[3.121223,1.0081505,7.2440386],[3.990545,1.0115887,7.030086],[3.9637921,1.6101487,6.9902272],[2.4925516,1.5739753,7.4344935],[2.4925516,1.6810473,7.4259276],[3.1341157,1.0115886,7.287015],[3.976222,1.0330583,7.053607],[3.9512725,1.5912702,7.0164351],[2.4791203,1.5550743,7.4609771],[2.4791203,1.7304838,7.4469442],[3.147486,1.0330582,7.302228],[3.9388695,1.8758466,6.9293289],[3.89083,2.9506743,6.8577552],[2.4796584,2.1568897,7.3446093],[2.4796584,1.839969,7.3699627],[3.9603574,1.8815767,7.0009561],[3.912318,2.9564044,6.9293823],[2.5011463,2.1626198,7.4162364],[2.5011463,1.8456992,7.4415898],[3.9460559,1.9025701,7.024509],[3.9003541,2.9250953,6.956418],[2.5260382,2.1520419,7.4305568],[2.5260382,1.8676562,7.4533076],[4.0081611,4.0742669,6.3467288],[4.3805432,4.1615996,5.3506866],[3.2888443,4.8674393,5.3506866],[3.1595957,4.6675353,6.2112494],[4.0474086,4.1349697,6.366724],[4.4197907,4.222302,5.3706822],[3.3280916,4.9281421,5.3706822],[3.1988432,4.7282381,6.2312446],[4.0485392,4.1642456,6.350646],[4.4057102,4.2480106,5.3952904],[3.352458,4.9289927,5.3952904],[3.2286329,4.7374768,6.2197423],[3.0621083,5.0140362,5.3506856],[2.4632707,5.4012156,5.3506856],[2.4632707,5.154366,6.1000748],[2.9381692,4.8223443,6.1758957],[3.0856566,5.050458,5.3626833],[2.486819,5.4376373,5.3626833],[2.486819,5.1907878,6.1120725],[2.9617176,4.8587661,6.1878929],[3.0764322,5.0730267,5.3872914],[2.514328,5.4364557,5.3872914],[2.514328,5.2016211,6.1002059],[2.9587035,4.8909397,6.1711535]],"bolts":34},
"Hull.Cheek.L": {"solid":[[-4.0699725,4.0184684,6.4698162],[-4.5260153,4.125421,5.25],[-2.3800001,5.1999998,6.1999998],[-2.3800001,5.5129309,5.25],[-3.9938784,3.1328073,6.8332119],[-4.0936742,0.9,6.9818964],[-4.7517948,0.9,5.25],[-2.3800001,2.2249999,7.3899999],[-3.0849326,0.9,7.2845197],[-2.3800001,1.6355822,7.4371529],[-3.084933,0.9,5.25],[-2.3800001,1.6355822,5.25]],"facets":8,"panels":[[-4.0154204,3.1072907,6.7247982],[-4.0846686,3.9132679,6.3940978],[-4.4765992,4.0051847,5.3457685],[-4.5553617,2.8800015,5.3457685],[-4.0272317,2.8430324,6.7423954],[-4.0853796,3.1121879,6.7513828],[-4.1546278,3.918165,6.4206824],[-4.5465584,4.0100818,5.3723531],[-4.6253209,2.8848987,5.3723531],[-4.0971909,2.8479295,6.76898],[-4.1113443,3.1090918,6.7400494],[-4.1793475,3.9005809,6.4152937],[-4.5596213,3.9897637,5.3981438],[-4.6355081,2.9056606,5.3981438],[-4.1220431,2.8697181,6.7559896],[-4.5742154,2.6106603,5.3457689],[-4.6863694,1.0084593,5.3457689],[-4.1092281,1.0084593,6.8645616],[-4.0392909,2.5732152,6.7603631],[-4.6161909,2.6135986,5.3617196],[-4.7283449,1.0113976,5.3617196],[-4.1512036,1.0113976,6.8805122],[-4.0812664,2.5761535,6.7763138],[-4.6291714,2.5944583,5.3875103],[-4.7384973,1.0326608,5.3875103],[-4.1760798,1.0326608,6.8675566],[-4.1079054,2.5579693,6.7659855],[-3.9058976,3.4082141,6.7119331],[-3.886991,3.1881585,6.8022237],[-2.4871092,2.4007244,7.285183],[-2.4871092,3.4669223,6.8587041],[-3.9142027,3.4358971,6.7811403],[-3.8952961,3.2158415,6.8714314],[-2.495414,2.4284074,7.3543906],[-2.495414,3.4946053,6.9279113],[-3.894887,3.4256005,6.8092508],[-3.8784792,3.2346299,6.8876081],[-2.5175056,2.4690816,7.3571439],[-2.5175056,3.4825954,6.9517384],[-2.4871089,4.9912777,6.2489614],[-3.9538083,3.9658461,6.4831309],[-3.9273598,3.6580153,6.609437],[-2.4871089,3.7176116,6.7584281],[-2.4920919,5.0078878,6.2904859],[-3.9587913,3.9824557,6.5246553],[-3.9323428,3.6746249,6.6509614],[-2.4920919,3.7342215,6.7999525],[-2.5141835,4.9786625,6.3211989],[-3.9402878,3.9816124,6.5488873],[-3.9162068,3.7013359,6.6638875],[-2.5141835,3.7593505,6.8089242],[-2.4796581,2.0325902,7.3545527],[-2.4796581,2.1568892,7.3446088],[-3.89083,2.9506741,6.8577557],[-3.93027,2.0682566,6.9165163],[-2.4925508,2.0360284,7.3975286],[-2.4925508,2.1603274,7.3875852],[-3.9037228,2.9541123,6.900732],[-3.9431629,2.0716946,6.9594927],[-2.5174427,2.0579853,7.4092464],[-2.5174427,2.1497495,7.4019055],[-3.8917589,2.9228029,6.9277678],[-3.9288611,2.0926881,6.9830456],[-3.1212225,1.0081503,7.2440386],[-2.4796584,1.6776092,7.3829513],[-2.4796584,1.7631588,7.3761072],[-3.9422991,1.7991207,6.9344378],[-3.9776518,1.0081505,6.9871097],[-3.1427104,1.0138805,7.3156652],[-2.5011466,1.6833394,7.4545784],[-2.5011466,1.768889,7.4477344],[-3.9637873,1.8048508,7.0060649],[-3.9991398,1.0138806,7.0587363],[-3.1560807,1.0353501,7.3308787],[-2.5260382,1.6927865,7.4672966],[-2.5260382,1.7509302,7.4626455],[-3.9512677,1.7859722,7.0322728],[-3.9848168,1.0353502,7.0822577],[-2.4632707,5.4012156,5.3506866],[-3.020721,5.0407953,5.3506866],[-2.8977513,4.8506017,6.1694436],[-2.4632707,5.1543655,6.1000757],[-2.5025179,5.4619184,5.3706822],[-3.0599682,5.1014977,5.3706822],[-2.9369986,4.9113045,6.1894393],[-2.5025182,5.2150683,6.1200714],[-2.5300269,5.4607368,5.3952904],[-3.0507438,5.1240664,5.3952904],[-2.9339843,4.9434781,6.1726995],[-2.5300269,5.2259021,6.1082048],[-3.2474575,4.8941984,5.3506866],[-4.3805437,4.1615996,5.3506866],[-4.0081615,4.0742669,6.3467283],[-3.1191783,4.6957932,6.2047954],[-3.2710059,4.9306197,5.3626838],[-4.4040923,4.1980209,5.3626838],[-4.0317101,4.1106887,6.358726],[-3.1427269,4.7322149,6.2167931],[-3.295372,4.9314704,5.3872919],[-4.3900118,4.2237296,5.3872919],[-4.0328407,4.1399646,6.342648],[-3.1725166,4.7414536,6.2052908]],"bolts":34},
"Hull.Skirt.R": {"solid":[[4.6230001,4.0,5.3000002],[4.8016,3.6199999,4.9000001],[5.1694999,1.35,4.3499999],[5.0300002,0.9,4.8000002],[4.3839998,0.9,6.5],[4.2950001,3.8,6.1999998],[4.3245077,3.9791055,5.186573],[4.5031075,3.5991056,4.7865729],[4.8710074,1.3291055,4.2365727],[4.7315078,0.8791055,4.686573],[4.0855074,0.8791055,6.3865728],[3.9965076,3.7791054,6.0865731]],"facets":8,"panels":[],"bolts":0},
"Hull.Skirt.L": {"solid":[[-4.6230001,4.0,5.3000002],[-4.8016,3.6199999,4.9000001],[-5.1694999,1.35,4.3499999],[-5.0300002,0.9,4.8000002],[-4.3839998,0.9,6.5],[-4.2950001,3.8,6.1999998],[-4.3245077,3.9791055,5.186573],[-4.5031075,3.5991056,4.7865729],[-4.8710074,1.3291055,4.2365727],[-4.7315078,0.8791055,4.686573],[-4.0855074,0.8791055,6.3865728],[-3.9965076,3.7791054,6.0865731]],"facets":8,"panels":[],"bolts":0},
"Hull.CheekLip.R": {"solid":[[2.45,5.4676719,4.8400002],[4.6892009,4.0199132,4.8400002],[2.45,5.4676719,4.9899998],[4.629499,4.0585136,4.9899998],[2.45,5.2771425,4.8400002],[4.7031698,3.8203516,4.8400002],[2.45,5.2771425,4.9899998],[4.6434679,3.858952,4.9899998]],"facets":6,"panels":[],"bolts":0},
"Hull.CheekLip.L": {"solid":[[-2.45,5.4676719,4.8400002],[-4.6892009,4.0199132,4.8400002],[-2.45,5.4676719,4.9899998],[-4.629499,4.0585136,4.9899998],[-2.45,5.2771425,4.8400002],[-4.7031698,3.8203516,4.8400002],[-2.45,5.2771425,4.9899998],[-4.6434679,3.858952,4.9899998]],"facets":6,"panels":[],"bolts":0},
"Hull.Quarter.R": {"solid":[[4.2910318,-2.9193861,6.8925695],[4.3936944,-1.4,7.0157642],[4.9976001,-1.4,5.506],[3.5958304,-4.3421259,6.9449539],[3.9363332,-4.6085348,5.8910241],[1.75,-4.8604336,7.409956],[1.75,-5.3931999,5.9851837],[2.5643883,-1.4,7.5279703],[1.75,-2.3254409,7.6634545],[2.5643883,-1.4,5.5060005],[1.75,-2.3254409,5.6170526]],"facets":9,"panels":[[2.6039631,-1.5075765,7.4852662],[1.8505968,-2.3636744,7.6105995],[1.8505968,-3.7839808,7.4685688],[3.7708514,-3.7307458,6.9362202],[4.181469,-2.8904121,6.9052806],[4.2749047,-1.5075765,7.0174022],[2.6160405,-1.5118898,7.5284004],[1.8626742,-2.3679876,7.6537333],[1.8626742,-3.7882941,7.5117025],[3.7829289,-3.7350593,6.9793544],[4.1935463,-2.8947253,6.9484148],[4.2869821,-1.5118899,7.0605364],[2.6295795,-1.5337148,7.543292],[1.8873084,-2.3772049,7.6667795],[1.8873082,-3.7697763,7.5275221],[3.7765129,-3.7174025,7.0037818],[4.1799693,-2.8917232,6.9733815],[4.2717276,-1.5337149,7.0834904],[1.8505965,-4.0526409,7.4417028],[1.8505965,-4.7160707,7.37536],[3.5181954,-4.2478104,6.9552579],[3.6377716,-4.0030956,6.9462481],[1.8707256,-4.0598297,7.5135922],[1.8707258,-4.7232594,7.4472499],[3.5383244,-4.2549992,7.0271478],[3.6579008,-4.0102844,7.0181379],[1.8953596,-4.0811133,7.5254316],[1.8953596,-4.6992774,7.4636159],[3.5305526,-4.2401166,7.0516772],[3.6317692,-4.0329757,7.0440507],[2.7647738,-4.5948009,7.0421376],[1.8471562,-4.8524671,7.273304],[1.8471562,-5.2996264,6.0774708],[2.8457143,-4.9412479,6.0344653],[2.7796867,-4.6345687,7.0570083],[1.862069,-4.8922348,7.2881742],[1.8620691,-5.3393941,6.0923409],[2.8606274,-4.9810157,6.049336],[2.7687323,-4.6642437,7.0491562],[1.8875668,-4.9116745,7.2711391],[1.8875669,-5.3432689,6.1169314],[2.8469315,-4.9989567,6.075614],[3.5113626,-4.385159,6.8540578],[3.0230417,-4.5222793,6.9770751],[3.0996346,-4.8501167,6.0235305],[3.7892847,-4.6026044,5.9938288],[3.5362175,-4.4514389,6.8788414],[3.0478966,-4.5885587,7.0018592],[3.1244895,-4.9163966,6.0483146],[3.8141394,-4.6688843,6.0186129],[3.5286927,-4.4801512,6.8701258],[3.0752041,-4.6074901,6.9843683],[3.1484115,-4.9208369,6.0729723],[3.7952363,-4.688694,6.0451155],[4.8567634,-1.7086165,5.6465893],[4.2893143,-2.930759,6.7566442],[4.0067,-4.2766261,5.9586406],[4.9274721,-1.7305669,5.6585679],[4.3600225,-2.9527094,6.7686234],[4.0774083,-4.2985768,5.9706192],[4.92415,-1.7936081,5.6878805],[4.3820004,-2.9616666,6.7477016],[4.1124616,-4.2452664,5.986618],[4.4087081,-1.5076799,6.8972273],[4.3302989,-2.6681259,6.8031359],[4.869947,-1.5076799,5.7441301],[4.4503107,-1.5118402,6.9138684],[4.371901,-2.672286,6.819777],[4.9115496,-1.5118402,5.7607713],[4.4748921,-1.5336035,6.9010568],[4.4008923,-2.6287878,6.8122573],[4.9101915,-1.5336035,5.8128085],[4.1558022,-3.2465746,6.7950749],[3.6602814,-4.2610569,6.831995],[3.9027374,-4.4507542,6.0815411],[4.2187653,-3.276315,6.8229346],[3.7232447,-4.2907972,6.8598547],[3.9657006,-4.4804945,6.1094007],[4.2140222,-3.3451762,6.8139858],[3.7548034,-4.285428,6.848104],[3.9794402,-4.4611835,6.1528049]],"bolts":27},
"Hull.Quarter.L": {"solid":[[-4.2910318,-2.9193861,6.8925695],[-4.3936944,-1.4,7.0157642],[-4.9976001,-1.4,5.506],[-3.5958304,-4.3421259,6.9449539],[-3.9363332,-4.6085348,5.8910241],[-1.75,-4.8604336,7.409956],[-1.75,-5.3931999,5.9851837],[-2.5643883,-1.4,7.5279703],[-1.75,-2.3254409,7.6634545],[-2.5643883,-1.4,5.5060005],[-1.75,-2.3254409,5.6170526]],"facets":9,"panels":[[-1.8505965,-4.7160707,7.3753595],[-1.8505963,-4.0014849,7.4468179],[-3.6631114,-3.9512372,6.9443383],[-3.5181952,-4.2478104,6.9552579],[-1.8707256,-4.7232594,7.4472494],[-1.8707255,-4.0086741,7.5187078],[-3.6832407,-3.9584262,7.0162282],[-3.5383244,-4.2549992,7.0271473],[-1.8953596,-4.6992774,7.4636154],[-1.8953595,-4.0299578,7.5305471],[-3.6571088,-3.9811172,7.042141],[-3.5305526,-4.2401166,7.0516772],[-1.8505961,-3.7328248,7.4736838],[-1.8505962,-2.3636742,7.6105995],[-2.6039624,-1.5075763,7.4852662],[-4.2749043,-1.5075763,7.0174017],[-4.1814685,-2.8904119,6.9052796],[-3.7961907,-3.6788878,6.93431],[-1.8626735,-3.7371383,7.5168176],[-1.8626738,-2.3679876,7.6537333],[-2.61604,-1.5118898,7.5283999],[-4.2869816,-1.5118897,7.0605354],[-4.1935458,-2.8947253,6.9484134],[-3.8082683,-3.6832011,6.9774437],[-1.8873075,-3.7186203,7.5326371],[-1.8873078,-2.3772047,7.666779],[-2.6295791,-1.5337147,7.543292],[-4.2717271,-1.5337147,7.0834894],[-4.1799688,-2.8917229,6.9733806],[-3.8018522,-3.6655443,7.0018711],[-2.781431,-4.5901232,7.037941],[-3.5113628,-4.385159,6.8540564],[-3.7892847,-4.6026049,5.9938278],[-2.8620911,-4.9353704,6.0337601],[-2.8062859,-4.6564031,7.0627251],[-3.5362177,-4.4514389,6.8788404],[-3.8141396,-4.6688848,6.0186119],[-2.886946,-5.0016503,6.0585442],[-2.8335936,-4.6753345,7.0452337],[-3.528693,-4.4801512,6.8701243],[-3.7952366,-4.6886945,6.0451145],[-2.9108679,-5.0060902,6.0832024],[-1.847156,-5.2996264,6.0774708],[-1.847156,-4.8524671,7.273304],[-2.5231628,-4.6626449,7.103004],[-2.6081707,-5.0265012,6.0446959],[-1.8620689,-5.3393941,6.0923409],[-1.862069,-4.8922348,7.2881746],[-2.5380757,-4.7024126,7.1178746],[-2.6230836,-5.0662689,6.059566],[-1.8875667,-5.3432684,6.1169314],[-1.8875668,-4.9116745,7.2711396],[-2.5271213,-4.7320881,7.1100225],[-2.6093879,-5.0842099,6.0858445],[-4.006701,-4.2766266,5.9586406],[-4.2893152,-2.9307594,6.7566447],[-4.8567643,-1.7086169,5.6465893],[-4.0491261,-4.2897968,5.9658279],[-4.3317404,-2.9439294,6.7638316],[-4.8991895,-1.721787,5.6537766],[-4.0841789,-4.2364864,5.9818268],[-4.3537178,-2.9528866,6.7429104],[-4.8958673,-1.7848281,5.6830893],[-4.3302989,-2.6681259,6.8031359],[-4.4087081,-1.5076799,6.8972273],[-4.869947,-1.5076799,5.7441301],[-4.371901,-2.672286,6.819777],[-4.4503107,-1.5118402,6.9138684],[-4.9115496,-1.5118402,5.7607713],[-4.4008923,-2.6287878,6.8122573],[-4.4748921,-1.5336035,6.9010568],[-4.9101915,-1.5336035,5.8128085],[-3.6602814,-4.2610569,6.8319945],[-4.1558022,-3.2465746,6.7950749],[-3.9027376,-4.4507546,6.0815406],[-3.7232447,-4.2907972,6.8598542],[-4.2187657,-3.276315,6.8229346],[-3.9657006,-4.4804945,6.1094003],[-3.7548034,-4.2854285,6.8481035],[-4.2140226,-3.3451762,6.8139858],[-3.9794402,-4.461184,6.1528044]],"bolts":27},
"Hull.FlankRoof.R": {"solid":[[2.8270271,0.85,7.4918909],[2.8270271,-1.3,7.4918909],[2.8,0.85,7.499999],[2.8,-1.3,7.499999],[2.9800003,0.85,6.8800001],[2.9800003,-1.3,6.8800001],[2.8,0.85,6.8800001],[2.8,-1.3,6.8800001]],"facets":6,"panels":[[2.9339185,0.7400001,6.9818645],[2.8343034,0.7400001,7.3803244],[2.8343034,-1.1899998,7.3803244],[2.9339185,-1.1899998,6.9818645],[3.0066793,0.7400001,7.0000548],[2.907064,0.7400001,7.3985143],[2.907064,-1.1899998,7.3985143],[3.0066793,-1.1899998,7.0000548],[3.0212314,0.7200001,7.0243082],[2.9313176,0.7200001,7.3839622],[2.9313176,-1.1699998,7.3839622],[3.0212314,-1.1699998,7.0243082]],"bolts":4},
"Hull.FlankRoof.L": {"solid":[[-2.8270271,0.85,7.4918909],[-2.8270271,-1.3,7.4918909],[-2.8,0.85,7.499999],[-2.8,-1.3,7.499999],[-2.9800003,0.85,6.8800001],[-2.9800003,-1.3,6.8800001],[-2.8,0.85,6.8800001],[-2.8,-1.3,6.8800001]],"facets":6,"panels":[[-2.8343034,-1.1899998,7.3803244],[-2.8343034,0.7400001,7.3803244],[-2.9339185,0.7400001,6.9818645],[-2.9339185,-1.1899998,6.9818645],[-2.8779597,-1.1899998,7.3912382],[-2.8779597,0.7400001,7.3912382],[-2.9775751,0.7400001,6.9927788],[-2.9775751,-1.1899998,6.9927788],[-2.9022133,-1.1699998,7.3766861],[-2.9022133,0.7200001,7.3766861],[-2.9921272,0.7200001,7.0170321],[-2.9921272,-1.1699998,7.0170321]],"bolts":4},
"Hull.FlankSill.R": {"solid":[[4.3656001,0.85,5.1199999],[4.3656001,-1.3,5.1199999],[4.3260002,0.85,5.4499998],[4.3260002,-1.3,5.4499998],[3.9000001,0.85,5.1199999],[3.9000001,-1.3,5.1199999],[3.9000001,0.85,5.4499998],[3.9000001,-1.3,5.4499998]],"facets":6,"panels":[],"bolts":0},
"Hull.FlankSill.L": {"solid":[[-4.3656001,0.85,5.1199999],[-4.3656001,-1.3,5.1199999],[-4.3260002,0.85,5.4499998],[-4.3260002,-1.3,5.4499998],[-3.9000001,0.85,5.1199999],[-3.9000001,-1.3,5.1199999],[-3.9000001,0.85,5.4499998],[-3.9000001,-1.3,5.4499998]],"facets":6,"panels":[],"bolts":0},
"Hull.Tail": {"solid":[[1.72,-2.75,7.5],[1.72,-5.0,7.3000002],[1.72,-2.75,7.1500001],[1.72,-5.0,7.0],[-1.72,-2.75,7.5],[-1.72,-5.0,7.3000002],[-1.72,-2.75,7.1500001],[-1.72,-5.0,7.0]],"facets":6,"panels":[[1.61,-4.8886614,7.2898178],[1.61,-2.8577971,7.4703388],[-0.0356075,-2.8577971,7.4703388],[-0.0356076,-4.8886614,7.2898178],[1.61,-4.8953018,7.3645234],[1.61,-2.8644376,7.5450439],[-0.0356075,-2.8644376,7.5450439],[-0.0356076,-4.8953018,7.3645234],[1.59,-4.877151,7.3862157],[1.59,-2.8861299,7.5631948],[-0.0156075,-2.8861299,7.5631948],[-0.0156076,-4.877151,7.3862157],[-0.3056076,-2.8577971,7.4703374],[-1.61,-2.8577971,7.4703374],[-1.61,-4.8886609,7.2898192],[-0.3056076,-4.8886609,7.2898192],[-0.3056076,-2.8617814,7.5151606],[-1.61,-2.8617814,7.5151606],[-1.61,-4.8926454,7.3346429],[-0.3056076,-4.8926454,7.3346429],[-0.3256076,-2.8834736,7.5333114],[-1.59,-2.8834736,7.5333114],[-1.59,-4.8744946,7.3563347],[-0.3256076,-4.8744946,7.3563347]],"bolts":8},
"Hull.BellySide.R": {"solid":[[2.0999999,2.2,3.9000001],[2.0999999,-2.4000001,3.95],[2.45,2.0,4.0999999],[2.45,-2.2,4.1500001],[2.45,2.0,4.8499999],[2.45,-2.2,4.9000001],[2.25,2.2,5.0999999],[2.25,-2.4000001,5.1500001],[1.8,2.2,3.9000001],[1.8,-2.4000001,5.1500001]],"facets":15,"panels":[[2.4300001,-2.0900002,4.7886829],[2.4300001,-2.0900002,4.2586985],[2.4300001,-0.6636688,4.2417183],[2.4300001,-0.6573603,4.7716274],[2.5050001,-2.0900002,4.7886829],[2.5050001,-2.0900002,4.2586985],[2.5050001,-0.6636688,4.2417183],[2.5050001,-0.6573603,4.7716274],[2.5250001,-2.0700002,4.7684431],[2.5250001,-2.0700002,4.2784615],[2.5250001,-0.6834292,4.2619548],[2.5250001,-0.677597,4.7518668],[2.4300001,-0.3936881,4.2385039],[2.4300001,1.89,4.2113171],[2.4300001,1.89,4.7413015],[2.4300001,-0.3873795,4.7684135],[2.4750001,-0.3936881,4.2385039],[2.4750001,1.89,4.2113171],[2.4750001,1.89,4.7413015],[2.4750001,-0.3873795,4.7684135],[2.4950001,-0.3734515,4.2582645],[2.4950001,1.87,4.2315569],[2.4950001,1.87,4.7215385],[2.4950001,-0.367619,4.7481766],[2.2321301,1.8335732,5.0840106],[1.9212853,-2.2902241,5.1287899],[2.1400001,-2.2902241,5.1287899],[2.2321301,1.8343884,5.1590061],[1.9212853,-2.2894089,5.2037854],[2.1400001,-2.2894089,5.2037854],[2.2288792,1.7680224,5.179728],[1.9428494,-2.2691927,5.223567],[2.1204419,-2.2691927,5.223567]],"bolts":11},
"Hull.BellySide.L": {"solid":[[-2.0999999,2.2,3.9000001],[-2.0999999,-2.4000001,3.95],[-2.45,2.0,4.0999999],[-2.45,-2.2,4.1500001],[-2.45,2.0,4.8499999],[-2.45,-2.2,4.9000001],[-2.25,2.2,5.0999999],[-2.25,-2.4000001,5.1500001],[-1.8,2.2,3.9000001],[-1.8,-2.4000001,5.1500001]],"facets":15,"panels":[[-2.4300001,-2.0900002,4.2586985],[-2.4300001,-2.0900002,4.7886829],[-2.4300001,0.1687398,4.7617931],[-2.4300001,0.1624316,4.2318835],[-2.5050001,-2.0900002,4.2586985],[-2.5050001,-2.0900002,4.7886829],[-2.5050001,0.1687398,4.7617931],[-2.5050001,0.1624316,4.2318835],[-2.5250001,-2.0700002,4.2784615],[-2.5250001,-2.0700002,4.7684431],[-2.5250001,0.1485032,4.7420325],[-2.5250001,0.1426711,4.2521205],[-2.4300001,0.4387209,4.7585793],[-2.4300001,1.89,4.7413015],[-2.4300001,1.89,4.2113171],[-2.4300001,0.4324124,4.2286692],[-2.4750001,0.4387209,4.7585793],[-2.4750001,1.89,4.7413015],[-2.4750001,1.89,4.2113171],[-2.4750001,0.4324124,4.2286692],[-2.4950001,0.4584814,4.7383423],[-2.4950001,1.87,4.7215385],[-2.4950001,1.87,4.2315569],[-2.4950001,0.4526491,4.2484298],[-2.2321301,1.8335732,5.0840106],[-2.1400001,-2.2902241,5.1287899],[-1.9212852,-2.2902241,5.1287899],[-2.2321301,1.8340623,5.1290078],[-2.1400001,-2.2897351,5.1737871],[-1.9212852,-2.2897351,5.1737871],[-2.2288792,1.7676963,5.1497297],[-2.1204419,-2.2695189,5.1935692],[-1.9428494,-2.2695189,5.1935692]],"bolts":11}
}}
],
"repaired": {"how": {"script": "Blender 5.3 in the background at source.sha, with surfaces/blender/experiments/mechs on sys.path: import mechlib, massing, bastion_body, bastion_form. For a plate of bastion_form.PLATES built as key at side sx (1 for .R, -1 for .L): obj = massing.hard(key, pts, None, plate[\"mat\"], mirror=plate.get(\"mirror\", False), bevel=plate[\"bevel\"], sx=sx); g, bolts = mechlib.Geo(), mechlib.Geo(); clad(obj, g, keep=bastion_body.outward, seed=seed, bolts=bolts), seed the table's clad.seed for that side. solid is obj.data.vertices, facets len(obj.data.polygons), panels g.bm.verts, bolts len(bolts.bm.verts) // 12, coordinates rounded to 7 places.", "corner": "Hull.Quarter.R and .L: pts = massing.corners([bastion_body._face(f) for f in plate[\"faces\"]], tol=1e-5) where the branch calls it at its default, tol=1e-6 (the slack of its inside test, all(n.dot(p) <= d + tol ...)): the corner float32 lost is kept. clad is massing.clad.", "tie": "Hull.BellySide.R: pts = bastion_body._points(plate), and clad is massing.clad with two lines added after its line `k = max(range(len(pts)), key=lambda i: (pts[(i + 1) % len(pts)] - pts[i]).length)`: `tied = [i for i in range(len(pts)) if abs((pts[(i + 1) % len(pts)] - pts[i]).length - (pts[(k + 1) % len(pts)] - pts[k]).length) < 1e-5]` and `k = next((i for i in tied if i != k), k) if len(tied) == 2 else k`: the cut starts from the other of the split facet's two equally long edges."}, "truth": {
"Hull.Quarter.R": {"solid":[[4.2910318,-2.9193861,6.8925695],[4.7526722,-3.0549133,5.7045879],[4.3936944,-1.4,7.0157642],[4.9976001,-1.4,5.506],[3.5958304,-4.3421259,6.9449539],[3.9363332,-4.6085348,5.8910241],[1.75,-4.8604336,7.409956],[1.75,-5.3931999,5.9851837],[2.5643883,-1.4,7.5279703],[1.75,-2.3254409,7.6634545],[2.5643883,-1.4,5.5060005],[1.75,-2.3254409,5.6170526]],"facets":8,"panels":[[2.6039631,-1.5075765,7.4852662],[1.8505968,-2.3636744,7.6105995],[1.8505968,-3.7839808,7.4685688],[3.7708514,-3.7307458,6.9362202],[4.181469,-2.8904121,6.9052806],[4.2749047,-1.5075765,7.0174022],[2.6160405,-1.5118898,7.5284004],[1.8626742,-2.3679876,7.6537333],[1.8626742,-3.7882941,7.5117025],[3.7829289,-3.7350593,6.9793544],[4.1935463,-2.8947253,6.9484148],[4.2869821,-1.5118899,7.0605364],[2.6295795,-1.5337148,7.543292],[1.8873084,-2.3772049,7.6667795],[1.8873082,-3.7697763,7.5275221],[3.7765129,-3.7174025,7.0037818],[4.1799693,-2.8917232,6.9733815],[4.2717276,-1.5337149,7.0834904],[1.8505965,-4.0526409,7.4417028],[1.8505965,-4.7160707,7.37536],[3.5181954,-4.2478104,6.9552579],[3.6377716,-4.0030956,6.9462481],[1.8707256,-4.0598297,7.5135922],[1.8707258,-4.7232594,7.4472499],[3.5383244,-4.2549992,7.0271478],[3.6579008,-4.0102844,7.0181379],[1.8953596,-4.0811133,7.5254316],[1.8953596,-4.6992774,7.4636159],[3.5305526,-4.2401166,7.0516772],[3.6317692,-4.0329757,7.0440507],[2.7647738,-4.5948009,7.0421376],[1.8471562,-4.8524671,7.273304],[1.8471562,-5.2996264,6.0774708],[2.8457143,-4.9412479,6.0344653],[2.7796867,-4.6345687,7.0570083],[1.862069,-4.8922348,7.2881742],[1.8620691,-5.3393941,6.0923409],[2.8606274,-4.9810157,6.049336],[2.7687323,-4.6642437,7.0491562],[1.8875668,-4.9116745,7.2711391],[1.8875669,-5.3432689,6.1169314],[2.8469315,-4.9989567,6.075614],[3.5113626,-4.385159,6.8540578],[3.0230417,-4.5222793,6.9770751],[3.0996346,-4.8501167,6.0235305],[3.7892847,-4.6026044,5.9938288],[3.5362175,-4.4514389,6.8788414],[3.0478966,-4.5885587,7.0018592],[3.1244895,-4.9163966,6.0483146],[3.8141394,-4.6688843,6.0186129],[3.5286927,-4.4801512,6.8701258],[3.0752041,-4.6074901,6.9843683],[3.1484115,-4.9208369,6.0729723],[3.7952363,-4.688694,6.0451155],[4.3817148,-1.9071758,6.8648353],[4.3201332,-2.8185694,6.7909379],[4.710516,-2.9331768,5.7863297],[4.8316121,-2.1149623,5.6881447],[4.4233174,-1.9113361,6.8814764],[4.3617358,-2.8227296,6.8075786],[4.7521186,-2.9373369,5.8029709],[4.8732147,-2.1191227,5.7047858],[4.4476438,-1.9368703,6.8683591],[4.3888788,-2.8065846,6.7978411],[4.7663054,-2.9173882,5.8265738],[4.8817496,-2.1373634,5.7329712],[4.9214897,-1.5076798,5.6152711],[4.4087076,-1.5076798,6.8972268],[4.400281,-1.6323925,6.887115],[4.8708658,-1.8497338,5.6563177],[4.9908276,-1.5146136,5.6430063],[4.478045,-1.5146136,6.924962],[4.4696183,-1.6393265,6.9148502],[4.9402032,-1.8566676,5.6840525],[4.9988408,-1.536377,5.6716146],[4.5026264,-1.5363771,6.9121504],[4.4966955,-1.6241521,6.9050336],[4.9545536,-1.8356153,5.7075229],[4.2655559,-3.0223532,6.786387],[3.6602807,-4.2610564,6.8319945],[3.9375505,-4.4779921,5.9737864],[4.6440229,-3.1334624,5.8124413],[4.3285189,-3.0520933,6.8142467],[3.723244,-4.2907968,6.8598547],[4.0005136,-4.5077324,6.001646],[4.706986,-3.1632028,5.840301],[4.34373,-3.0801873,6.8037205],[3.7548051,-4.28543,6.8480964],[4.0205779,-4.4933701,6.0254736],[4.7070746,-3.186857,5.868691]],"bolts":30},
"Hull.Quarter.L": {"solid":[[-4.2910318,-2.9193861,6.8925695],[-4.7526722,-3.0549133,5.7045879],[-4.3936944,-1.4,7.0157642],[-4.9976001,-1.4,5.506],[-3.5958304,-4.3421259,6.9449539],[-3.9363332,-4.6085348,5.8910241],[-1.75,-4.8604336,7.409956],[-1.75,-5.3931999,5.9851837],[-2.5643883,-1.4,7.5279703],[-1.75,-2.3254409,7.6634545],[-2.5643883,-1.4,5.5060005],[-1.75,-2.3254409,5.6170526]],"facets":8,"panels":[[-1.8505965,-4.7160707,7.3753595],[-1.8505963,-4.0014849,7.4468179],[-3.6631114,-3.9512372,6.9443383],[-3.5181952,-4.2478104,6.9552579],[-1.8707256,-4.7232594,7.4472494],[-1.8707255,-4.0086741,7.5187078],[-3.6832407,-3.9584262,7.0162282],[-3.5383244,-4.2549992,7.0271473],[-1.8953596,-4.6992774,7.4636154],[-1.8953595,-4.0299578,7.5305471],[-3.6571088,-3.9811172,7.042141],[-3.5305526,-4.2401166,7.0516772],[-1.8505961,-3.7328248,7.4736838],[-1.8505962,-2.3636742,7.6105995],[-2.6039624,-1.5075763,7.4852662],[-4.2749043,-1.5075763,7.0174017],[-4.1814685,-2.8904119,6.9052796],[-3.7961907,-3.6788878,6.93431],[-1.8626735,-3.7371383,7.5168176],[-1.8626738,-2.3679876,7.6537333],[-2.61604,-1.5118898,7.5283999],[-4.2869816,-1.5118897,7.0605354],[-4.1935458,-2.8947253,6.9484134],[-3.8082683,-3.6832011,6.9774437],[-1.8873075,-3.7186203,7.5326371],[-1.8873078,-2.3772047,7.666779],[-2.6295791,-1.5337147,7.543292],[-4.2717271,-1.5337147,7.0834894],[-4.1799688,-2.8917229,6.9733806],[-3.8018522,-3.6655443,7.0018711],[-3.5113626,-4.385159,6.8540568],[-3.7892847,-4.6026049,5.9938283],[-2.8620911,-4.9353704,6.0337601],[-2.7814307,-4.5901232,7.0379415],[-3.5362175,-4.4514389,6.8788409],[-3.8141396,-4.6688843,6.0186124],[-2.8869457,-5.0016503,6.0585442],[-2.8062856,-4.6564031,7.0627251],[-3.5286927,-4.4801512,6.8701248],[-3.7952363,-4.6886945,6.0451145],[-2.9108679,-5.0060902,6.0832024],[-2.8335931,-4.6753345,7.0452342],[-2.6081707,-5.0265012,6.0446959],[-1.8471559,-5.2996264,6.0774708],[-1.8471559,-4.8524671,7.273304],[-2.5231626,-4.6626449,7.103004],[-2.6230836,-5.0662689,6.059566],[-1.8620688,-5.3393941,6.0923409],[-1.8620689,-4.8922348,7.2881746],[-2.5380757,-4.7024126,7.1178746],[-2.6093876,-5.0842099,6.0858445],[-1.8875666,-5.3432684,6.1169314],[-1.8875667,-4.9116745,7.2711396],[-2.5271213,-4.7320881,7.1100225],[-4.3919301,-1.7559885,6.8770943],[-4.4087081,-1.5076798,6.8972273],[-4.9214902,-1.5076798,5.615272],[-4.85321,-1.969032,5.6706338],[-4.4335327,-1.7601488,6.8937349],[-4.4503107,-1.5118401,6.9138684],[-4.9630928,-1.5118401,5.6319127],[-4.8948126,-1.9731923,5.6872749],[-4.4606104,-1.7449744,6.8839188],[-4.4748921,-1.5336035,6.9010572],[-4.9711065,-1.5336035,5.660521],[-4.909163,-1.95214,5.7107453],[-4.3201332,-2.8185692,6.7909379],[-4.373363,-2.0307715,6.8548145],[-4.8139558,-2.2342606,5.7024608],[-4.7105155,-2.9331768,5.7863297],[-4.3894706,-2.8255031,6.8186731],[-4.4427004,-2.0377054,6.8825493],[-4.8832932,-2.2411945,5.7301955],[-4.7798533,-2.9401107,5.814065],[-4.4166136,-2.8093579,6.8089352],[-4.4670272,-2.0632396,6.869432],[-4.8918281,-2.2594352,5.7583814],[-4.7940402,-2.920162,5.8376679],[-3.9375505,-4.4779921,5.9737859],[-3.6602805,-4.2610569,6.8319945],[-4.2655559,-3.0223532,6.7863865],[-4.6440229,-3.1334624,5.8124409],[-4.0005136,-4.5077324,6.0016456],[-3.7232437,-4.2907968,6.8598542],[-4.3285189,-3.0520935,6.8142462],[-4.706986,-3.1632028,5.8403006],[-4.0205779,-4.4933701,6.0254736],[-3.7548048,-4.28543,6.8480964],[-4.34373,-3.0801876,6.8037205],[-4.7070746,-3.1868572,5.8686905]],"bolts":30},
"Hull.BellySide.R": {"solid":[[2.0999999,2.2,3.9000001],[2.0999999,-2.4000001,3.95],[2.45,2.0,4.0999999],[2.45,-2.2,4.1500001],[2.45,2.0,4.8499999],[2.45,-2.2,4.9000001],[2.25,2.2,5.0999999],[2.25,-2.4000001,5.1500001],[1.8,2.2,3.9000001],[1.8,-2.4000001,5.1500001]],"facets":15,"panels":[[2.4300001,0.4573603,4.2283726],[2.4300001,1.89,4.2113171],[2.4300001,1.89,4.7413015],[2.4300001,0.4636687,4.7582817],[2.5050001,0.4573603,4.2283726],[2.5050001,1.89,4.2113171],[2.5050001,1.89,4.7413015],[2.5050001,0.4636687,4.7582817],[2.5250001,0.4775969,4.2481332],[2.5250001,1.87,4.2315569],[2.5250001,1.87,4.7215385],[2.5250001,0.4834292,4.7380452],[2.4300001,-2.0900002,4.7886829],[2.4300001,-2.0900002,4.2586985],[2.4300001,0.1873795,4.2315865],[2.4300001,0.193688,4.7614961],[2.4750001,-2.0900002,4.7886829],[2.4750001,-2.0900002,4.2586985],[2.4750001,0.1873795,4.2315865],[2.4750001,0.193688,4.7614961],[2.4950001,-2.0700002,4.7684431],[2.4950001,-2.0700002,4.2784615],[2.4950001,0.167619,4.2518234],[2.4950001,0.1734514,4.7417355],[2.2321301,1.8335732,5.0840106],[1.9212853,-2.2902241,5.1287899],[2.1400001,-2.2902241,5.1287899],[2.2321301,1.8343884,5.1590061],[1.9212853,-2.2894089,5.2037854],[2.1400001,-2.2894089,5.2037854],[2.2288792,1.7680224,5.179728],[1.9428494,-2.2691927,5.223567],[2.1204419,-2.2691927,5.223567]],"bolts":11}
}}}

View file

@ -0,0 +1,98 @@
{"source": {"branch": "nibu/fable-paladin-3", "sha": "c35e57ee5aa9c52e589623fcc8abb19b909f09d4", "blender": "5.3.0"},
"table": {"schema": "brokkr.plates.v0", "plates": [
{"name": "Thigh.core", "mat": "gunmetal", "bevel": 0.02, "sections": [[0.4, 0.9, -0.3, 0.5, 0.12], [0.05, 1.2, -0.34, 0.64, 0.18], [-1.45, 1.2, -0.34, 0.64, 0.18], [-1.8, 0.95, -0.3, 0.5, 0.14]]},
{"name": "Thigh.Shield", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.02, 0.9, -0.5], "normal": [0.06, 1.0, 0.05], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": [[-0.42, 0.98], [0.42, 0.98], [0.66, 0.5], [0.66, -0.52], [0.42, -1.0], [-0.42, -1.0], [-0.66, -0.52], [-0.66, 0.5]], "thick": 0.26, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.05, 0.05], "inset": 0.075, "gap": 0.045, "split": 99.0, "seed": 948708}, "fits": [{"kind": "mark", "id": "tri", "at": [0.0, -0.05], "height": 0.5}]},
{"name": "Thigh.Block", "mat": "olive_light", "bevel": 0.022, "slab": {"at": [0.02, 1.0, 0.12], "normal": [0.06, 1.0, 0.05], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.56, "h": 0.44, "clip": 0.08}, "thick": 0.16, "taper": 0.04, "back": 1.0}},
{"name": "Thigh.Lame", "mat": "olive_light", "bevel": 0.022, "slab": {"at": [0.02, 0.985, -1.17], "normal": [0.06, 1.0, 0.02], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": [[-0.52, 0.2], [0.52, 0.2], [0.58, 0.0], [0.4, -0.26], [-0.4, -0.26], [-0.58, 0.0]], "thick": 0.14, "taper": 0.04, "back": 1.0}},
{"name": "Thigh.Outer", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.86, 0.0, -0.45], "normal": [1.0, 0.08, 0.04], "up": [0.0, 0.0, 1.0], "right": [0.0, 1.0, 0.0], "outline": [[-0.5, 1.0], [0.36, 1.05], [0.68, 0.5], [0.68, -0.6], [0.3, -1.02], [-0.5, -0.86], [-0.74, -0.2], [-0.74, 0.5]], "thick": 0.24, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.04, 0.07], "inset": 0.075, "gap": 0.045, "split": 0.8, "seed": 976538}},
{"name": "Thigh.OuterStep", "mat": "olive_light", "bevel": 0.022, "slab": {"at": [0.95, -0.02, -0.25], "normal": [1.0, 0.08, 0.04], "up": [0.0, 0.0, 1.0], "right": [0.0, 1.0, 0.0], "outline": {"w": 0.8, "h": 0.9, "clip": 0.2}, "thick": 0.13, "taper": 0.04, "back": 1.0}},
{"name": "Thigh.Inner", "mat": "khaki", "bevel": 0.022, "slab": {"at": [-0.82, 0.05, -0.75], "normal": [-1.0, 0.1, 0.0], "up": [0.0, 0.0, 1.0], "right": [0.0, 1.0, 0.0], "outline": [[-0.55, 0.55], [0.5, 0.55], [0.62, 0.15], [0.5, -0.7], [-0.45, -0.7], [-0.62, -0.15]], "thick": 0.2, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.04, 0.07], "inset": 0.075, "gap": 0.045, "split": 0.8, "seed": 947561}},
{"name": "Thigh.Rear", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.0, -0.98, -0.25], "normal": [0.0, -1.0, 0.05], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": [[-0.46, 0.72], [0.46, 0.72], [0.64, 0.3], [0.64, -0.4], [0.42, -0.72], [-0.42, -0.72], [-0.64, -0.4], [-0.64, 0.3]], "thick": 0.22, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.05, 0.05], "inset": 0.075, "gap": 0.045, "split": 99.0, "seed": 398253}},
{"name": "Thigh.RearStep", "mat": "olive_light", "bevel": 0.022, "slab": {"at": [0.0, -1.06, -0.3], "normal": [0.0, -1.0, 0.05], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.7, "h": 0.5, "clip": 0.1}, "thick": 0.12, "taper": 0.04, "back": 1.0}},
{"name": "Thigh.CornerOut", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.7, 0.7, -0.45], "normal": [0.72, 0.7, 0.04], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.3, "h": 1.5, "clip": 0.08}, "thick": 0.2, "taper": 0.04, "back": 1.0}},
{"name": "Thigh.CornerIn", "mat": "khaki", "bevel": 0.022, "slab": {"at": [-0.67, 0.7, -0.6], "normal": [-0.72, 0.7, 0.03], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.26, "h": 1.1, "clip": 0.07}, "thick": 0.18, "taper": 0.04, "back": 1.0}},
{"name": "Thigh.Cap", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.0, 0.12, 0.66], "normal": [0.0, 0.3, 1.0], "up": [0.0, 1.0, 0.0], "right": [1.0, 0.0, 0.0], "outline": [[-0.5, -0.5], [0.5, -0.5], [0.6, 0.1], [0.36, 0.44], [-0.36, 0.44], [-0.6, 0.1]], "thick": 0.18, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.05, 0.05], "inset": 0.075, "gap": 0.045, "split": 99.0, "seed": 387260}},
{"name": "Shin.core", "mat": "gunmetal", "bevel": 0.02, "sections": [[-0.3, 0.9, -0.3, 0.5, 0.12], [-0.65, 1.14, -0.34, 0.6, 0.18], [-1.9, 1.06, -0.34, 0.56, 0.18], [-2.5, 0.8, -0.3, 0.4, 0.12]]},
{"name": "Shin.Knee", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.0, 1.0, 0.02], "normal": [0.0, 1.0, 0.22], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": [[-0.4, 0.56], [0.4, 0.56], [0.62, 0.22], [0.62, -0.3], [0.42, -0.56], [-0.42, -0.56], [-0.62, -0.3], [-0.62, 0.22]], "thick": 0.28, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.05, 0.05], "inset": 0.075, "gap": 0.045, "split": 99.0, "seed": 995246}},
{"name": "Shin.KneeSide", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.7, 0.72, 0.0], "normal": [0.75, 0.66, 0.1], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.34, "h": 0.9, "clip": 0.1}, "thick": 0.2, "taper": 0.04, "back": 1.0}},
{"name": "Shin.KneeSideIn", "mat": "khaki", "bevel": 0.022, "slab": {"at": [-0.7, 0.72, 0.0], "normal": [-0.75, 0.66, 0.1], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.34, "h": 0.9, "clip": 0.1}, "thick": 0.2, "taper": 0.04, "back": 1.0}},
{"name": "Shin.Greave", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.0, 0.88, -1.3], "normal": [0.0, 1.0, -0.07], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": [[-0.5, 0.72], [0.5, 0.72], [0.66, 0.4], [0.6, -0.5], [0.36, -0.95], [-0.36, -0.95], [-0.6, -0.5], [-0.66, 0.4]], "thick": 0.28, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.04, 0.07], "inset": 0.075, "gap": 0.045, "split": 0.8, "seed": 564123}},
{"name": "Shin.GreaveStep", "mat": "olive_light", "bevel": 0.022, "slab": {"at": [0.0, 0.97, -1.2], "normal": [0.0, 1.0, -0.07], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.62, "h": 0.84, "clip": 0.12}, "thick": 0.15, "taper": 0.04, "back": 1.0}},
{"name": "Shin.Outer", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.82, -0.2, -1.05], "normal": [1.0, 0.04, 0.0], "up": [0.0, 0.0, 1.0], "right": [0.0, 1.0, 0.0], "outline": [[-0.75, 0.62], [0.34, 0.74], [0.74, 0.36], [0.7, -0.55], [0.28, -0.96], [-0.6, -0.82], [-0.95, -0.1]], "thick": 0.26, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.04, 0.07], "inset": 0.075, "gap": 0.045, "split": 0.8, "seed": 733553}},
{"name": "Shin.OuterStep", "mat": "olive_light", "bevel": 0.022, "slab": {"at": [0.92, -0.2, -1.0], "normal": [1.0, 0.04, 0.0], "up": [0.0, 0.0, 1.0], "right": [0.0, 1.0, 0.0], "outline": [[-0.42, 0.42], [0.2, 0.46], [0.46, 0.2], [0.44, -0.3], [0.16, -0.5], [-0.36, -0.44], [-0.56, -0.05]], "thick": 0.13, "taper": 0.04, "back": 1.0}, "fits": [{"kind": "mark", "id": "tri", "at": [-0.03, -0.02], "height": 0.4}]},
{"name": "Shin.Inner", "mat": "khaki", "bevel": 0.022, "slab": {"at": [-0.78, -0.12, -1.1], "normal": [-1.0, 0.04, 0.0], "up": [0.0, 0.0, 1.0], "right": [0.0, 1.0, 0.0], "outline": [[-0.7, 0.55], [0.3, 0.66], [0.66, 0.3], [0.62, -0.5], [0.25, -0.86], [-0.55, -0.74], [-0.85, -0.1]], "thick": 0.22, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.05, 0.05], "inset": 0.075, "gap": 0.045, "split": 99.0, "seed": 299054}},
{"name": "Shin.Calf", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.0, -1.12, -0.95], "normal": [0.0, -1.0, 0.1], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": [[-0.5, 0.62], [0.5, 0.62], [0.68, 0.1], [0.5, -0.62], [-0.5, -0.62], [-0.68, 0.1]], "thick": 0.22, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.05, 0.05], "inset": 0.075, "gap": 0.045, "split": 99.0, "seed": 800359}},
{"name": "Shin.CalfStep", "mat": "olive_light", "bevel": 0.022, "slab": {"at": [0.0, -1.2, -1.05], "normal": [0.0, -1.0, 0.1], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.72, "h": 0.46, "clip": 0.1}, "thick": 0.12, "taper": 0.04, "back": 1.0}},
{"name": "Shin.Ankle", "mat": "olive_light", "bevel": 0.022, "slab": {"at": [0.0, 0.66, -2.42], "normal": [0.0, 1.0, -0.2], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.8, "h": 0.52, "clip": 0.12}, "thick": 0.2, "taper": 0.04, "back": 1.0}, "clad": {"mat": "khaki", "min_area": 0.2, "lifts": [0.04, 0.07], "inset": 0.075, "gap": 0.045, "split": 0.8, "seed": 22775}},
{"name": "Shin.AnkleSide", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.6, 0.1, -2.35], "normal": [1.0, 0.1, -0.1], "up": [0.0, 0.0, 1.0], "right": [0.0, 1.0, 0.0], "outline": {"w": 0.7, "h": 0.5, "clip": 0.12}, "thick": 0.16, "taper": 0.04, "back": 1.0}},
{"name": "Pelvis.core", "mat": "gunmetal", "bevel": 0.02, "points": [[0.62, 0.62, 0.5], [0.62, -0.6, 0.5], [0.72, 0.7, -0.3], [0.72, -0.62, -0.3], [0.45, 0.7, 0.62], [0.45, -0.66, 0.62], [0.4, 0.55, -0.8], [0.4, -0.45, -0.8]], "mirror": true},
{"name": "Pelvis.Crown", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.0, 1.0, 0.42], "normal": [0.0, 1.0, 0.16], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": [[-0.32, 0.3], [0.32, 0.3], [0.48, 0.04], [0.3, -0.3], [-0.3, -0.3], [-0.48, 0.04]], "thick": 0.3, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.05, 0.05], "inset": 0.075, "gap": 0.045, "split": 99.0, "seed": 345924}},
{"name": "Pelvis.Cod", "mat": "khaki", "bevel": 0.022, "slab": {"at": [0.0, 1.06, -0.62], "normal": [0.0, 1.0, -0.1], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": [[-0.36, 0.7], [0.36, 0.7], [0.44, 0.3], [0.3, -0.78], [-0.3, -0.78], [-0.44, 0.3]], "thick": 0.34, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.04, 0.07], "inset": 0.075, "gap": 0.045, "split": 0.8, "seed": 876596}},
{"name": "Pelvis.CodStep", "mat": "olive_light", "bevel": 0.022, "slab": {"at": [0.0, 1.17, -0.3], "normal": [0.0, 1.0, -0.1], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.5, "h": 0.42, "clip": 0.1}, "thick": 0.14, "taper": 0.04, "back": 1.0}},
{"name": "Pelvis.CodLame", "mat": "olive_light", "bevel": 0.022, "slab": {"at": [0.0, 1.15, -1.02], "normal": [0.0, 1.0, -0.1], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.42, "h": 0.4, "clip": 0.08}, "thick": 0.13, "taper": 0.04, "back": 1.0}},
{"name": "Pelvis.Wing", "mat": "khaki", "bevel": 0.022, "sides": "both", "slab": {"at": [0.92, 0.84, 0.5], "normal": [0.3, 1.0, 0.2], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": [[-0.46, -0.02], [0.44, 0.36], [0.54, 0.1], [0.44, -0.26], [-0.46, -0.36]], "thick": 0.22, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.04, 0.07], "inset": 0.075, "gap": 0.045, "split": 0.8, "seed": [876672, 589838]}},
{"name": "Pelvis.HipGuard", "mat": "olive_light", "bevel": 0.022, "sides": "both", "slab": {"at": [0.62, 0.92, -0.05], "normal": [0.2, 1.0, -0.05], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.34, "h": 0.5, "clip": 0.08}, "thick": 0.16, "taper": 0.04, "back": 1.0}},
{"name": "Pelvis.Seat", "mat": "khaki", "bevel": 0.022, "sides": "both", "slab": {"at": [0.56, -0.86, 0.02], "normal": [0.22, -1.0, 0.1], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": [[-0.5, 0.66], [0.5, 0.72], [0.6, -0.2], [0.2, -0.86], [-0.5, -0.6]], "thick": 0.24, "taper": 0.04, "back": 1.0}, "clad": {"mat": "olive_light", "min_area": 0.2, "lifts": [0.05, 0.05], "inset": 0.075, "gap": 0.045, "split": 99.0, "seed": [1004746, 453014]}},
{"name": "Pelvis.SeatStep", "mat": "olive_light", "bevel": 0.022, "sides": "both", "slab": {"at": [0.6, -0.95, 0.1], "normal": [0.22, -1.0, 0.1], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.56, "h": 0.6, "clip": 0.12}, "thick": 0.12, "taper": 0.04, "back": 1.0}},
{"name": "Pelvis.Tail", "mat": "olive_light", "bevel": 0.022, "slab": {"at": [0.0, -0.92, -0.2], "normal": [0.0, -1.0, -0.05], "up": [0.0, 0.0, 1.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.36, "h": 1.3, "clip": 0.1}, "thick": 0.22, "taper": 0.04, "back": 1.0}, "clad": {"mat": "khaki", "min_area": 0.2, "lifts": [0.04, 0.07], "inset": 0.075, "gap": 0.045, "split": 0.8, "seed": 995407}},
{"name": "Pelvis.Roof", "mat": "khaki", "bevel": 0.022, "sides": "both", "slab": {"at": [0.62, 0.0, 0.7], "normal": [0.25, 0.0, 1.0], "up": [0.0, 1.0, 0.0], "right": [1.0, 0.0, 0.0], "outline": {"w": 0.6, "h": 1.1, "clip": 0.14}, "thick": 0.14, "taper": 0.04, "back": 1.0}}
]},
"cases": [
{"side": 1, "truth": {
"Thigh.core": {"solid":[[-0.33,-0.3,0.4],[0.33,-0.3,0.4],[0.45,-0.18,0.4],[0.45,0.38,0.4],[0.33,0.5,0.4],[-0.33,0.5,0.4],[-0.45,0.38,0.4],[-0.45,-0.18,0.4],[-0.42,-0.34,0.05],[0.42,-0.34,0.05],[0.6,-0.16,0.05],[0.6,0.46,0.05],[0.42,0.64,0.05],[-0.42,0.64,0.05],[-0.6,0.46,0.05],[-0.6,-0.16,0.05],[-0.42,-0.34,-1.45],[0.42,-0.34,-1.45],[0.6,-0.16,-1.45],[0.6,0.46,-1.45],[0.42,0.64,-1.45],[-0.42,0.64,-1.45],[-0.6,0.46,-1.45],[-0.6,-0.16,-1.45],[-0.335,-0.3,-1.8],[0.335,-0.3,-1.8],[0.475,-0.16,-1.8],[0.475,0.36,-1.8],[0.335,0.5,-1.8],[-0.335,0.5,-1.8],[-0.475,0.36,-1.8],[-0.475,-0.16,-1.8]],"facets":26,"panels":[],"bolts":0},
"Thigh.Shield": {"solid":[[-0.6003516,0.9127237,-0.0100526],[-0.5973628,0.9625379,-1.0099225],[-0.371703,0.9714425,-1.4588065],[0.4174352,0.9240942,-1.4588065],[0.6404113,0.8882715,-1.0099225],[0.6374224,0.8384573,-0.0100526],[0.4117627,0.8295527,0.4388314],[-0.3773755,0.8769009,0.4388314],[-0.6427007,0.874771,-0.0026155],[-0.6396555,0.9255249,-1.0213474],[-0.3986532,0.9350349,-1.5007508],[0.4398389,0.8847254,-1.5007508],[0.677975,0.8464671,-1.0213474],[0.6749298,0.7957132,-0.0026155],[0.4339275,0.7862031,0.4767878],[-0.4045646,0.8365127,0.4767878],[-0.6558607,0.6554389,-0.0135821],[-0.6528155,0.7061929,-1.0323141],[-0.4118131,0.7157029,-1.5117174],[0.426679,0.6653934,-1.5117174],[0.6648151,0.627135,-1.0323141],[0.6617699,0.5763811,-0.0135821],[0.4207676,0.566871,0.4658212],[-0.4177245,0.6171806,0.4658212]],"facets":18,"panels":[[0.5642967,0.8719431,-0.9932363],[0.3697456,0.9031991,-1.3848965],[-0.3268539,0.9449951,-1.3848965],[-0.5237467,0.9372256,-0.9932363],[-0.5266297,0.8891734,-0.0287326],[-0.3320786,0.8579174,0.3629277],[0.3645209,0.8161214,0.3629277],[0.5614136,0.8238909,-0.0287325],[0.5672876,0.9217913,-0.9907439],[0.3727365,0.9530473,-1.3824042],[-0.323863,0.9948433,-1.3824042],[-0.5207558,0.9870738,-0.9907439],[-0.5236388,0.9390216,-0.0262402],[-0.3290877,0.9077656,0.3654201],[0.3675118,0.8659696,0.3654201],[0.5644045,0.8737391,-0.0262401],[0.5485058,0.9426935,-0.9850315],[0.3615346,0.9727318,-1.3614321],[-0.3103879,1.0130471,-1.3614321],[-0.4996094,1.0055803,-0.9850315],[-0.5024643,0.957998,-0.0299587],[-0.3154931,0.9279597,0.346442],[0.3564294,0.8876444,0.346442],[0.5456509,0.8951111,-0.0299587]],"bolts":8},
"Thigh.Block": {"solid":[[-0.2199377,1.0082324,0.243278],[-0.2192007,1.0205159,-0.003278],[-0.1625648,1.0199426,-0.0597762],[0.2036396,0.9979704,-0.0597762],[0.2599377,0.9917676,-0.003278],[0.2592007,0.9794841,0.243278],[0.2025648,0.9800573,0.2997762],[-0.1636396,1.0020295,0.2997762],[-0.262308,0.9699251,0.257832],[-0.2614721,0.9838576,-0.0218199],[-0.1813769,0.9830468,-0.1017204],[0.2179051,0.9590899,-0.1017204],[0.2975226,0.9503179,-0.0218199],[0.2966867,0.9363854,0.257832],[0.2165914,0.9371961,0.3377326],[-0.1826905,0.9611531,0.3377326],[-0.2694862,0.8502895,0.2518502],[-0.2686502,0.8642219,-0.0278017],[-0.188555,0.8634112,-0.1077022],[0.2107269,0.8394543,-0.1077022],[0.2903445,0.8306822,-0.0278017],[0.2895085,0.8167497,0.2518502],[0.2094133,0.8175604,0.3317508],[-0.1898686,0.8415174,0.3317508]],"facets":18,"panels":[],"bolts":0},
"Thigh.Lame": {"solid":[[-0.5152019,1.0169734,-1.1630588],[-0.3580984,1.0120851,-1.3899561],[0.3986245,0.9666817,-1.3899561],[0.5551853,0.9527501,-1.1630588],[0.5091674,0.9524506,-1.0100318],[-0.46955,1.0111736,-1.0100318],[-0.561354,0.9798173,-1.1707984],[-0.3813663,0.9742171,-1.4307466],[0.4171976,0.9263031,-1.4307466],[0.5965636,0.9103422,-1.1707984],[0.5364322,0.909951,-0.9708382],[-0.5017008,0.972239,-0.9708382],[-0.5673421,0.8800166,-1.1727943],[-0.3873544,0.8744164,-1.4327425],[0.4112095,0.8265026,-1.4327425],[0.5905755,0.8105416,-1.1727943],[0.5304441,0.8101503,-0.9728342],[-0.5076889,0.8724384,-0.9728342]],"facets":14,"panels":[],"bolts":0},
"Thigh.Outer": {"solid":[[0.8963261,-0.6993303,0.0405074],[0.9234846,-0.6971576,-0.6427998],[0.9302595,-0.4659773,-1.2745335],[0.8760005,0.2877677,-1.4255476],[0.8321795,0.6398191,-1.0341262],[0.7895345,0.6364074,0.0388219],[0.7930059,0.3335055,0.55784],[0.859628,-0.475686,0.5106725],[0.8593135,-0.7424191,0.0480094],[0.8871133,-0.7401951,-0.6514348],[0.8941858,-0.4988625,-1.3109107],[0.8367438,0.299098,-1.4707837],[0.7897608,0.6765533,-1.0511172],[0.7460753,0.6730585,0.0480094],[0.749751,0.3523302,0.5975726],[0.8203176,-0.504772,0.5476124],[0.6601087,-0.7583555,0.0400412],[0.6879086,-0.7561315,-0.659403],[0.694981,-0.5147989,-1.3188789],[0.6375391,0.2831616,-1.4787519],[0.590556,0.6606169,-1.0590854],[0.5468705,0.6571221,0.0400412],[0.5505463,0.3363939,0.5896044],[0.6211129,-0.5207084,0.5396442]],"facets":18,"panels":[[0.9001193,-0.6237868,-0.7074043],[0.8970585,-0.6240321,-0.6303937],[0.9032756,-0.4118871,-1.2101107],[0.8549845,0.2589536,-1.3445147],[0.8170925,0.5633724,-1.0060527],[0.8052226,0.5624229,-0.7074043],[0.969841,-0.6182091,-0.7046154],[0.9667802,-0.6184544,-0.6276049],[0.9729972,-0.4063094,-1.2073218],[0.9247062,0.2645313,-1.3417259],[0.8868142,0.5689502,-1.0032638],[0.8749442,0.5680006,-0.7046154],[0.9921507,-0.6364881,-0.7238027],[0.9850156,-0.6285996,-0.5612047],[0.9910342,-0.3898667,-1.1891332],[0.9443345,0.2588662,-1.3191079],[0.9080236,0.5505831,-0.9947683],[0.8972539,0.5497215,-0.7238027],[0.8711027,-0.6261086,0.0226564],[0.8923752,-0.6244068,-0.5125591],[0.7974783,0.5618034,-0.5125591],[0.7763985,0.560117,0.0178105],[0.7794868,0.2906393,0.4795566],[0.8387128,-0.4287195,0.4376253],[0.9109437,-0.6229213,0.02425],[0.9322161,-0.6212195,-0.5109655],[0.8373193,0.5649906,-0.5109655],[0.8162394,0.5633042,0.0194041],[0.8193278,0.2938266,0.4811502],[0.8785537,-0.4255322,0.439219],[0.92945,-0.601377,0.020499],[0.9497474,-0.5997531,-0.4901845],[0.8580404,0.5465844,-0.4901845],[0.8379691,0.5449787,0.0148104],[0.8409553,0.2844143,0.4612839],[0.898209,-0.4109892,0.420749]],"bolts":12},
"Thigh.OuterStep": {"solid":[[0.9694378,-0.3795951,-0.0167539],[0.9879788,-0.3781119,-0.4832461],[0.9809105,-0.2015447,-0.6596745],[0.951655,0.1641499,-0.6596745],[0.9305622,0.3395951,-0.4832461],[0.9120212,0.3381118,-0.0167539],[0.9190895,0.1615447,0.1596745],[0.948345,-0.2041499,0.1596745],[0.9321286,-0.4227076,-0.0017921],[0.9519857,-0.4211191,-0.5013952],[0.9439794,-0.2211206,-0.7012363],[0.9120813,0.1776055,-0.7012363],[0.8881895,0.3763331,-0.5013952],[0.8683324,0.3747445,-0.0017921],[0.8763387,0.1747461,0.1980491],[0.9082368,-0.22398,0.1980491],[0.8424864,-0.429879,-0.0053778],[0.8623435,-0.4282905,-0.5049809],[0.8543373,-0.228292,-0.704822],[0.8224391,0.1704341,-0.704822],[0.7985473,0.3691617,-0.5049809],[0.7786903,0.3675731,-0.0053778],[0.7866965,0.1675747,0.1944634],[0.8185946,-0.2311514,0.1944634]],"facets":18,"panels":[],"bolts":0},
"Thigh.Inner": {"solid":[[-0.8776518,-0.5265174,-0.8959235],[-0.861841,-0.3684096,-1.41],[-0.7737058,0.5129414,-1.41],[-0.7623708,0.6262924,-0.603093],[-0.7732095,0.5179051,-0.24],[-0.871125,-0.4612505,-0.24],[-0.8418908,-0.5709032,-0.9],[-0.8249752,-0.4017468,-1.45],[-0.7304466,0.5435384,-1.45],[-0.7185062,0.6629429,-0.6],[-0.7304466,0.5435384,-0.2],[-0.8349255,-0.5012506,-0.2],[-0.6826848,-0.5868238,-0.9],[-0.6657692,-0.4176674,-1.45],[-0.5712407,0.5276178,-1.45],[-0.5593002,0.6470223,-0.6],[-0.5712407,0.5276178,-0.2],[-0.6757196,-0.5171711,-0.2]],"facets":14,"panels":[[-0.850175,-0.4527469,-0.88828],[-0.8444706,-0.3957034,-0.315],[-0.8004089,0.0449137,-0.3149999],[-0.8004089,0.0449137,-1.3349999],[-0.8364358,-0.3153551,-1.3349999],[-0.9198276,-0.4457816,-0.88828],[-0.9141232,-0.3887382,-0.315],[-0.8700615,0.051879,-0.3149999],[-0.8700615,0.051879,-1.3349999],[-0.9060884,-0.3083898,-1.3349999],[-0.9377081,-0.4235888,-0.8862417],[-0.932223,-0.3687381,-0.335],[-0.8919523,0.0339683,-0.3349999],[-0.8919523,0.0339683,-1.3149999],[-0.9245213,-0.2917212,-1.3149999],[-0.7810057,0.238946,-0.315],[-0.7588613,0.4603896,-0.315],[-0.7500883,0.5481198,-0.6088924],[-0.7602883,0.4461192,-1.335],[-0.7810056,0.238946,-1.335],[-0.8208072,0.2429261,-0.315],[-0.7986628,0.4643697,-0.315],[-0.7898898,0.5521,-0.6088925],[-0.8000898,0.4500993,-1.335],[-0.8208071,0.2429261,-1.335],[-0.8387178,0.2648169,-0.335],[-0.8200442,0.451553,-0.335],[-0.8118221,0.5337747,-0.610439],[-0.8217194,0.4348008,-1.3150001],[-0.8387178,0.2648169,-1.3150001]],"bolts":10},
"Thigh.Rear": {"solid":[[-0.6,-0.9654287,0.0414257],[-0.6,-0.9993547,-0.6370928],[-0.3989588,-1.0139576,-0.9291516],[0.3989588,-1.0139576,-0.9291516],[0.6,-0.9993547,-0.6370928],[0.6,-0.9654287,0.0414257],[0.4336241,-0.9460424,0.4291516],[-0.4336241,-0.9460424,0.4291516],[-0.64,-0.9250687,0.0476282],[-0.64,-0.960025,-0.6514985],[-0.42,-0.976005,-0.9710993],[0.42,-0.976005,-0.9710993],[0.64,-0.960025,-0.6514985],[0.64,-0.9250687,0.0476282],[0.46,-0.9040949,0.4671042],[-0.46,-0.9040949,0.4671042],[-0.64,-0.7452933,0.0386394],[-0.64,-0.7802496,-0.6604872],[-0.42,-0.7962296,-0.980088],[0.42,-0.7962296,-0.980088],[0.64,-0.7802496,-0.6604872],[0.64,-0.7452933,0.0386394],[0.46,-0.7243195,0.4581155],[-0.46,-0.7243195,0.4581155]],"facets":18,"panels":[[0.525,-0.9462224,0.0250518],[0.3841694,-0.9298127,0.3532465],[-0.3841694,-0.9298127,0.3532465],[-0.525,-0.9462224,0.0250518],[-0.525,-0.9782164,-0.6148264],[-0.3595065,-0.9902372,-0.8552439],[0.3595065,-0.9902372,-0.8552439],[0.525,-0.9782164,-0.6148264],[0.525,-0.99616,0.0275487],[0.3841694,-0.9797503,0.3557433],[-0.3841694,-0.9797503,0.3557433],[-0.525,-0.99616,0.0275487],[-0.525,-1.028154,-0.6123295],[-0.3595065,-1.0401748,-0.8527471],[0.3595065,-1.0401748,-0.8527471],[0.525,-1.028154,-0.6123295],[0.505,-1.0163401,0.0244474],[0.3709815,-1.0007241,0.3367671],[-0.3709815,-1.0007241,0.3367671],[-0.505,-1.0163401,0.0244474],[-0.505,-1.0478188,-0.6051267],[-0.3489859,-1.0591512,-0.8317733],[0.3489859,-1.0591512,-0.8317733],[0.505,-1.0478188,-0.6051267]],"bolts":8},
"Thigh.RearStep": {"solid":[[-0.31,-1.0533367,-0.166735],[-0.31,-1.0666631,-0.433265],[-0.2334315,-1.0704868,-0.509738],[0.2334315,-1.0704868,-0.509738],[0.31,-1.0666631,-0.433265],[0.31,-1.0533367,-0.166735],[0.2334315,-1.0495131,-0.090262],[-0.2334315,-1.0495131,-0.090262],[-0.35,-1.0125592,-0.1521847],[-0.35,-1.0275404,-0.4518104],[-0.25,-1.0325342,-0.5516856],[0.25,-1.0325342,-0.5516856],[0.35,-1.0275404,-0.4518104],[0.35,-1.0125592,-0.1521847],[0.25,-1.0075654,-0.0523094],[-0.25,-1.0075654,-0.0523094],[-0.35,-0.932659,-0.1561797],[-0.35,-0.9476403,-0.4558054],[-0.25,-0.9526341,-0.5556806],[0.25,-0.9526341,-0.5556806],[0.35,-0.9476403,-0.4558054],[0.35,-0.932659,-0.1561797],[0.25,-0.9276652,-0.0563044],[-0.25,-0.9276652,-0.0563044]],"facets":18,"panels":[],"bolts":0},
"Thigh.CornerOut": {"solid":[[0.6046741,0.7607402,0.2029137],[0.6419686,0.7969987,-1.1029136],[0.6830156,0.7580089,-1.1594374],[0.7575075,0.6813887,-1.1594374],[0.7953259,0.6392598,-1.1029136],[0.7580314,0.6030012,0.2029137],[0.7169843,0.6419911,0.2594374],[0.6424925,0.7186113,0.2594374],[0.5476611,0.7610992,0.217877],[0.5859013,0.7982771,-1.1210611],[0.6439505,0.7431371,-1.2009977],[0.7415414,0.6427579,-1.2009977],[0.7950248,0.5831786,-1.1210611],[0.7567846,0.5460007,0.217877],[0.6987353,0.6011407,0.2978136],[0.6011444,0.70152,0.2978136],[0.4330328,0.6496551,0.2115088],[0.471273,0.686833,-1.1274294],[0.5293223,0.631693,-1.207366],[0.6269132,0.5313138,-1.207366],[0.6803964,0.4717345,-1.1274294],[0.6421562,0.4345566,0.2115088],[0.584107,0.4896966,0.2914454],[0.4865161,0.5900759,0.2914454]],"facets":18,"panels":[],"bolts":0},
"Thigh.CornerIn": {"solid":[[-0.7228147,0.6258237,-0.1367753],[-0.7426594,0.6451172,-1.0632248],[-0.7111945,0.6794759,-1.1097726],[-0.6506443,0.7417562,-1.1097726],[-0.6171853,0.7741762,-1.0632248],[-0.5973406,0.7548828,-0.1367753],[-0.6288055,0.7205241,-0.0902275],[-0.6893557,0.6582438,-0.0902275],[-0.7216761,0.5689284,-0.1214086],[-0.7422302,0.5889115,-1.0809804],[-0.6949335,0.6405582,-1.1509492],[-0.6112841,0.7265977,-1.1509492],[-0.5609899,0.7753302,-1.0809804],[-0.5404358,0.755347,-0.1214086],[-0.5877325,0.7037003,-0.0514398],[-0.6713819,0.6176609,-0.0514398],[-0.6213416,0.4713809,-0.1255892],[-0.6418957,0.4913641,-1.085161],[-0.594599,0.5430108,-1.1551298],[-0.5109496,0.6290503,-1.1551298],[-0.4606554,0.6777828,-1.085161],[-0.4401013,0.6577996,-0.1255892],[-0.487398,0.6061529,-0.0556204],[-0.5710474,0.5201135,-0.0556204]],"facets":18,"panels":[],"bolts":0},
"Thigh.Cap": {"solid":[[-0.4661148,-0.3206001,0.7921801],[0.4661148,-0.3206001,0.7921801],[0.5578418,0.2065509,0.6340348],[0.3392738,0.5031305,0.5450609],[-0.3392738,0.5031305,0.5450609],[-0.5578418,0.2065509,0.6340348],[-0.4999999,-0.370407,0.765361],[0.4999999,-0.370407,0.765361],[0.6,0.2042887,0.5929522],[0.36,0.5299496,0.4952539],[-0.36,0.5299496,0.4952539],[-0.6,0.2042887,0.5929522],[-0.4999999,-0.4106357,0.6312653],[0.4999999,-0.4106357,0.6312653],[0.6,0.16406,0.4588565],[0.36,0.4897209,0.3611582],[-0.36,0.4897209,0.3611582],[-0.6,0.16406,0.4588565]],"facets":14,"panels":[[0.3004121,0.4255465,0.5474553],[-0.3004121,0.4255465,0.5474553],[-0.4787954,0.1834945,0.620071],[-0.4025803,-0.25451,0.7514725],[0.4025803,-0.25451,0.7514725],[0.4787954,0.1834945,0.620071],[0.3004121,0.4399139,0.5953466],[-0.3004121,0.4399139,0.5953466],[-0.4787954,0.1978619,0.6679623],[-0.4025803,-0.2401427,0.7993639],[0.4025803,-0.2401427,0.7993639],[0.4787954,0.1978619,0.6679623],[0.2900489,0.4265044,0.6202502],[-0.2900489,0.4265044,0.6202502],[-0.4577163,0.198993,0.6885036],[-0.3856378,-0.2152392,0.8127734],[0.3856378,-0.2152392,0.8127734],[0.4577163,0.198993,0.6885036]],"bolts":6},
"Shin.core": {"solid":[[-0.33,-0.3,-0.3],[0.33,-0.3,-0.3],[0.45,-0.18,-0.3],[0.45,0.38,-0.3],[0.33,0.5,-0.3],[-0.33,0.5,-0.3],[-0.45,0.38,-0.3],[-0.45,-0.18,-0.3],[-0.39,-0.34,-0.65],[0.39,-0.34,-0.65],[0.57,-0.16,-0.65],[0.57,0.42,-0.65],[0.39,0.6,-0.65],[-0.39,0.6,-0.65],[-0.57,0.42,-0.65],[-0.57,-0.16,-0.65],[-0.35,-0.34,-1.9],[0.35,-0.34,-1.9],[0.53,-0.16,-1.9],[0.53,0.38,-1.9],[0.35,0.56,-1.9],[-0.35,0.56,-1.9],[-0.53,0.38,-1.9],[-0.53,-0.16,-1.9],[-0.28,-0.3,-2.5],[0.28,-0.3,-2.5],[0.4,-0.18,-2.5],[0.4,0.28,-2.5],[0.28,0.4,-2.5],[-0.28,0.4,-2.5],[-0.4,0.28,-2.5],[-0.4,-0.18,-2.5]],"facets":26,"panels":[],"bolts":0},
"Shin.Knee": {"solid":[[-0.58,0.9552685,0.2233251],[-0.58,1.0615354,-0.2597062],[-0.4003039,1.1117281,-0.4878551],[0.4003039,1.1117281,-0.4878551],[0.58,1.0615354,-0.2597062],[0.58,0.9552685,0.2233251],[0.3782389,0.8882719,0.5278551],[-0.3782389,0.8882719,0.5278551],[-0.62,0.9136646,0.2262673],[-0.62,1.0253928,-0.2815878],[-0.42,1.0812569,-0.5355154],[0.42,1.0812569,-0.5355154],[0.62,1.0253928,-0.2815878],[0.62,0.9136646,0.2262673],[0.4,0.8406116,0.5583265],[-0.4,0.8406116,0.5583265],[-0.62,0.67927,0.1747005],[-0.62,0.790998,-0.3331546],[-0.42,0.8468621,-0.5870823],[0.42,0.8468621,-0.5870823],[0.62,0.790998,-0.3331546],[0.62,0.67927,0.1747005],[0.4,0.606217,0.5067596],[-0.4,0.606217,0.5067596]],"facets":18,"panels":[[0.3633738,1.0760806,-0.418904],[-0.3633738,1.0760806,-0.418904],[-0.505,1.0365214,-0.2390901],[-0.505,0.9404944,0.1973966],[-0.3374369,0.8848536,0.4503096],[0.3374369,0.8848536,0.4503096],[0.505,0.9404944,0.1973966],[0.505,1.0365214,-0.2390901],[0.3633738,1.1249127,-0.408161],[-0.3633738,1.1249127,-0.408161],[-0.505,1.0853537,-0.228347],[-0.505,0.9893267,0.2081397],[-0.3374369,0.9336858,0.4610527],[0.3374369,0.9336858,0.4610527],[0.505,0.9893267,0.2081397],[0.505,1.0853537,-0.228347],[0.3535258,1.1401484,-0.3843308],[-0.3535258,1.1401484,-0.3843308],[-0.485,1.103425,-0.2174062],[-0.485,1.0101286,0.2066686],[-0.3265564,0.957516,0.445817],[0.3265564,0.957516,0.445817],[0.485,1.0101286,0.2066686],[0.485,1.103425,-0.2174062]],"bolts":8},
"Shin.KneeSide": {"solid":[[0.589188,0.7956541,0.3317735],[0.6390487,0.8395315,-0.3317735],[0.695357,0.7870885,-0.4079614],[0.7659536,0.706865,-0.4079614],[0.810812,0.644346,-0.3317735],[0.7609513,0.6004685,0.3317735],[0.704643,0.6529116,0.4079614],[0.6340464,0.733135,0.4079614],[0.5316448,0.7982987,0.3442758],[0.5839832,0.8443565,-0.3522436],[0.6575229,0.7758648,-0.4517464],[0.7500108,0.6707649,-0.4517464],[0.8085967,0.5891139,-0.3522436],[0.7562584,0.5430561,0.3442758],[0.6827186,0.6115477,0.4437786],[0.5902307,0.7166476,0.4437786],[0.4121279,0.6931238,0.3283402],[0.4644662,0.7391816,-0.3681792],[0.5380059,0.6706899,-0.467682],[0.6304939,0.56559,-0.467682],[0.6890798,0.483939,-0.3681792],[0.6367414,0.4378812,0.3283402],[0.5632017,0.5063728,0.427843],[0.4707137,0.6114727,0.427843]],"facets":18,"panels":[],"bolts":0},
"Shin.KneeSideIn": {"solid":[[-0.7609513,0.6004685,0.3317735],[-0.810812,0.644346,-0.3317735],[-0.7659536,0.706865,-0.4079614],[-0.695357,0.7870885,-0.4079614],[-0.6390487,0.8395315,-0.3317735],[-0.589188,0.7956541,0.3317735],[-0.6340464,0.733135,0.4079614],[-0.704643,0.6529116,0.4079614],[-0.7562584,0.5430561,0.3442758],[-0.8085967,0.5891139,-0.3522436],[-0.7500108,0.6707649,-0.4517464],[-0.6575229,0.7758648,-0.4517464],[-0.5839832,0.8443565,-0.3522436],[-0.5316448,0.7982987,0.3442758],[-0.5902307,0.7166476,0.4437786],[-0.6827186,0.6115477,0.4437786],[-0.6367414,0.4378812,0.3283402],[-0.6890798,0.483939,-0.3681792],[-0.6304939,0.56559,-0.467682],[-0.5380059,0.6706899,-0.467682],[-0.4644662,0.7391816,-0.3681792],[-0.4121279,0.6931238,0.3283402],[-0.4707137,0.6114727,0.427843],[-0.5632017,0.5063728,0.427843]],"facets":18,"panels":[],"bolts":0},
"Shin.Greave": {"solid":[[-0.6193662,0.9073608,-0.9091315],[-0.5606605,0.8458702,-1.7875686],[-0.336,0.8164555,-2.2077785],[0.336,0.8164555,-2.2077785],[0.5606605,0.8458702,-1.7875686],[0.6193662,0.9073608,-0.9091315],[0.4752786,0.9274838,-0.6216599],[-0.4752786,0.9274838,-0.6216599],[-0.66,0.8680293,-0.8981832],[-0.6,0.8051831,-1.7959863],[-0.36,0.77376,-2.2448878],[0.36,0.77376,-2.2448878],[0.6,0.8051831,-1.7959863],[0.66,0.8680293,-0.8981832],[0.5,0.8903747,-0.5789643],[-0.5,0.8903747,-0.5789643],[-0.66,0.6286151,-0.8814242],[-0.6,0.565769,-1.7792274],[-0.36,0.5343457,-2.2281287],[0.36,0.5343457,-2.2281287],[0.6,0.565769,-1.7792274],[0.66,0.6286151,-0.8814242],[0.5,0.6509604,-0.5622053],[-0.5,0.6509604,-0.5622053]],"facets":18,"panels":[[-0.1732338,0.8017416,-2.1315651],[-0.291,0.8017416,-2.1315651],[-0.4868988,0.8273906,-1.7651516],[-0.5431778,0.8863394,-0.9230259],[-0.4289261,0.9022955,-0.6950803],[-0.1732337,0.9022955,-0.6950803],[-0.1732338,0.8416439,-2.1343582],[-0.291,0.8416439,-2.1343582],[-0.4868988,0.8672929,-1.7679448],[-0.5431778,0.9262417,-0.9258191],[-0.4289261,0.9421979,-0.6978735],[-0.1732337,0.9421979,-0.6978735],[-0.1932338,0.8629917,-2.1158037],[-0.279,0.8629917,-2.1158037],[-0.467229,0.8876365,-1.7637359],[-0.5228609,0.9459075,-0.9312932],[-0.4165654,0.9607525,-0.7192212],[-0.1932337,0.9607525,-0.7192212],[0.4868988,0.8273906,-1.7651516],[0.291,0.8017416,-2.1315651],[0.0217662,0.8017416,-2.1315651],[0.0217663,0.9022955,-0.6950803],[0.4289261,0.9022955,-0.6950803],[0.5431778,0.8863394,-0.9230259],[0.4868988,0.8972197,-1.7700397],[0.291,0.8715707,-2.1364532],[0.0217662,0.8715707,-2.1364532],[0.0217663,0.9721246,-0.6999683],[0.4289261,0.9721247,-0.6999683],[0.5431778,0.9561685,-0.927914],[0.467229,0.9175633,-1.7658308],[0.279,0.8929185,-2.1178985],[0.0417663,0.8929185,-2.1178985],[0.0417663,0.9906793,-0.721316],[0.4165654,0.9906793,-0.721316],[0.5228609,0.9758343,-0.9333881]],"bolts":12},
"Shin.GreaveStep": {"solid":[[-0.27,0.9897918,-0.9172604],[-0.27,0.9502082,-1.4827397],[-0.1734315,0.9434649,-1.5790725],[0.1734315,0.9434649,-1.5790725],[0.27,0.9502082,-1.4827397],[0.27,0.9897918,-0.9172604],[0.1734315,0.9965351,-0.8209276],[-0.1734315,0.9965351,-0.8209276],[-0.31,0.9510465,-0.8979391],[-0.31,0.9091489,-1.4964746],[-0.19,0.9007695,-1.6161816],[0.19,0.9007695,-1.6161816],[0.31,0.9091489,-1.4964746],[0.31,0.9510465,-0.8979391],[0.19,0.9594259,-0.7782321],[-0.19,0.9594259,-0.7782321],[-0.31,0.8413149,-0.890258],[-0.31,0.7994174,-1.4887935],[-0.19,0.7910379,-1.6085005],[0.19,0.7910379,-1.6085005],[0.31,0.7994174,-1.4887935],[0.31,0.8413149,-0.890258],[0.19,0.8496944,-0.7705509],[-0.19,0.8496944,-0.7705509]],"facets":18,"panels":[],"bolts":0},
"Shin.Outer": {"solid":[[0.8562673,-1.1066836,-1.1461235],[0.8429071,-0.7726778,-1.8337708],[0.809351,0.0662256,-1.9673394],[0.7935917,0.4602057,-1.5824323],[0.7920528,0.4986797,-0.7064488],[0.8069738,0.1256552,-0.3517922],[0.8487253,-0.9181325,-0.4667965],[0.8180016,-1.1508397,-1.15],[0.8040128,-0.8011193,-1.8699999],[0.7688409,0.0781775,-2.01],[0.7520543,0.497842,-1.5999999],[0.7504556,0.53781,-0.6899999],[0.7664428,0.1381296,-0.3099999],[0.810008,-0.9509994,-0.4299999],[0.5981774,-1.1596327,-1.15],[0.5841886,-0.8099123,-1.8699999],[0.5490167,0.0693846,-2.01],[0.5322301,0.489049,-1.5999999],[0.5306314,0.529017,-0.6899999],[0.5466186,0.1293367,-0.3099999],[0.5901837,-0.9597924,-0.4299999]],"facets":16,"panels":[[0.7751235,0.4215133,-0.7372904],[0.7880453,0.0984686,-0.4301527],[0.8063356,-0.3587885,-0.4805332],[0.8003194,-0.2083839,-1.8478006],[0.7903833,0.0400187,-1.8873508],[0.7765504,0.3858406,-1.5494928],[0.8150916,0.423112,-0.7372904],[0.8280134,0.1000673,-0.4301527],[0.8463036,-0.3571897,-0.4805332],[0.8402874,-0.2067852,-1.8478006],[0.8303514,0.0416175,-1.8873509],[0.8165184,0.3874393,-1.549493],[0.8358902,0.4035468,-0.7455149],[0.8482788,0.0938301,-0.4510488],[0.8654056,-0.3343395,-0.4982244],[0.8595436,-0.1877901,-1.8304462],[0.8506064,0.0356415,-1.8660206],[0.8372872,0.3686212,-1.5407091],[0.8140826,-0.5524625,-0.5018721],[0.8263962,-0.8603038,-0.53579],[0.8330916,-1.027688,-1.1388552],[0.82091,-0.7231468,-1.765841],[0.8083001,-0.4078998,-1.8160341],[0.8840266,-0.5496647,-0.5018721],[0.8963403,-0.857506,-0.53579],[0.9030357,-1.0248903,-1.1388552],[0.890854,-0.7203491,-1.7658411],[0.8782442,-0.405102,-1.8160342],[0.9047178,-0.5665425,-0.5239406],[0.9156989,-0.8410726,-0.5541883],[0.9221686,-1.0028123,-1.136917],[0.9103012,-0.7061283,-1.7477266],[0.8991374,-0.4270333,-1.7921635]],"bolts":11},
"Shin.OuterStep": {"solid":[[0.9406667,-0.7166683,-1.0460328],[0.933356,-0.5339003,-1.4027153],[0.9140334,-0.0508353,-1.4584981],[0.9039803,0.2004944,-1.2788334],[0.9032401,0.218997,-0.8159006],[0.9126254,-0.0156337,-0.5810822],[0.9355723,-0.5893077,-0.6181231],[0.9024141,-0.7611513,-1.05],[0.8944205,-0.5613111,-1.4400001],[0.8736371,-0.0417266,-1.5],[0.8624461,0.2380497,-1.3],[0.8616467,0.2580338,-0.8],[0.8720384,-0.0017585,-0.54],[0.8968186,-0.6212631,-0.58],[0.812486,-0.7647484,-1.05],[0.8044924,-0.5649082,-1.4400001],[0.783709,-0.0453237,-1.5],[0.772518,0.2344526,-1.3],[0.7717186,0.2544366,-0.8],[0.7821103,-0.0053556,-0.54],[0.8068905,-0.6248603,-0.58]],"facets":16,"panels":[],"bolts":0},
"Shin.Inner": {"solid":[[-0.8122908,-0.9272723,-1.1955323],[-0.8008983,-0.6424584,-1.8036211],[-0.7705547,0.1161316,-1.9175006],[-0.7567852,0.4603711,-1.582297],[-0.7552532,0.4986687,-0.815732],[-0.7685975,0.1650628,-0.4818593],[-0.806675,-0.7868745,-0.5866562],[-0.7740048,-0.9709196,-1.2],[-0.7620144,-0.6711593,-1.84],[-0.73004,0.1282015,-1.96],[-0.7152518,0.4979059,-1.6],[-0.713653,0.537874,-0.8],[-0.7280415,0.1781616,-0.44],[-0.7680096,-0.8210394,-0.55],[-0.5941486,-0.9781139,-1.2],[-0.5821582,-0.6783535,-1.84],[-0.5501838,0.1210073,-1.96],[-0.5353956,0.4907117,-1.6],[-0.5337968,0.5306797,-0.8],[-0.5481853,0.1709673,-0.44],[-0.5881534,-0.8282337,-0.55]],"facets":16,"panels":[[-0.7397362,0.3861963,-1.549104],[-0.7515959,0.0897034,-1.8378143],[-0.7788817,-0.5924411,-1.7354107],[-0.7891533,-0.8492304,-1.1871556],[-0.7842486,-0.7266124,-0.6553865],[-0.7497159,0.1367056,-0.5603455],[-0.7383296,0.421362,-0.8452296],[-0.7896963,0.3881947,-1.5491039],[-0.801556,0.0917018,-1.8378142],[-0.8288417,-0.5904427,-1.7354107],[-0.8391134,-0.847232,-1.1871556],[-0.8342086,-0.724614,-0.6553865],[-0.7996759,0.138704,-0.5603455],[-0.7882897,0.4233604,-0.8452296],[-0.810463,0.3694274,-1.5402523],[-0.8218134,0.0856668,-1.8165646],[-0.8482838,-0.5760922,-1.7172213],[-0.8582564,-0.8254083,-1.1849217],[-0.8535413,-0.7075315,-0.6737146],[-0.8199539,0.1321546,-0.5812752],[-0.8090897,0.4037578,-0.8530955]],"bolts":7},
"Shin.Calf": {"solid":[[-0.6383086,-1.1102328,-0.8523283],[-0.468769,-1.1777122,-1.5271215],[0.468769,-1.1777122,-1.5271215],[0.6383086,-1.1102328,-0.8523283],[0.4715175,-1.0622878,-0.3728784],[-0.4715175,-1.0622878,-0.3728784],[-0.68,-1.0702481,-0.8544765],[-0.5,-1.1418909,-1.5709033],[0.5,-1.1418909,-1.5709033],[0.68,-1.0702481,-0.8544765],[0.5,-1.0185062,-0.3370571],[-0.5,-1.0185062,-0.3370571],[-0.68,-0.8911414,-0.8723871],[-0.5,-0.9627842,-1.5888139],[0.5,-0.9627842,-1.5888139],[0.68,-0.8911414,-0.8723871],[0.5,-0.8393995,-0.3549677],[-0.5,-0.8393995,-0.3549677]],"facets":14,"panels":[[-0.4102107,-1.1503487,-1.4544837],[0.4102107,-1.1503487,-1.4544837],[0.5601374,-1.0906755,-0.8577533],[0.4181128,-1.0498497,-0.4494962],[-0.4181128,-1.0498497,-0.4494962],[-0.5601374,-1.0906755,-0.8577534],[-0.4102107,-1.2001004,-1.4495087],[0.4102107,-1.2001004,-1.4495087],[0.5601374,-1.1404274,-0.8527782],[0.4181128,-1.0996016,-0.444521],[-0.4181128,-1.0996016,-0.444521],[-0.5601374,-1.1404274,-0.8527782],[-0.3945952,-1.2180111,-1.4276178],[0.3945952,-1.2180111,-1.4276178],[0.5392917,-1.1604197,-0.8517041],[0.4038715,-1.1214925,-0.4624317],[-0.4038715,-1.1214925,-0.4624317],[-0.5392917,-1.1604197,-0.8517041]],"bolts":6},
"Shin.CalfStep": {"solid":[[-0.32,-1.1887132,-0.9371314],[-0.32,-1.2112869,-1.1628685],[-0.2434314,-1.2189058,-1.2390571],[0.2434314,-1.2189058,-1.2390571],[0.32,-1.2112869,-1.1628685],[0.32,-1.1887132,-0.9371314],[0.2434314,-1.1810943,-0.8609428],[-0.2434314,-1.1810943,-0.8609428],[-0.36,-1.1472631,-0.9246253],[-0.36,-1.1731341,-1.1833349],[-0.26,-1.1830844,-1.2828387],[0.26,-1.1830844,-1.2828387],[0.36,-1.1731341,-1.1833349],[0.36,-1.1472631,-0.9246253],[0.26,-1.1373128,-0.8251215],[-0.26,-1.1373128,-0.8251215],[-0.36,-1.0676601,-0.9325855],[-0.36,-1.0935311,-1.1912953],[-0.26,-1.1034814,-1.290799],[0.26,-1.1034814,-1.290799],[0.36,-1.0935311,-1.1912953],[0.36,-1.0676601,-0.9325855],[0.26,-1.0577098,-0.8330818],[-0.26,-1.0577098,-0.8330818]],"facets":18,"panels":[],"bolts":0},
"Shin.Ankle": {"solid":[[-0.36,0.6842069,-2.2989655],[-0.36,0.6357931,-2.5410347],[-0.2634315,0.6168545,-2.6357279],[0.2634315,0.6168545,-2.6357279],[0.36,0.6357931,-2.5410347],[0.36,0.6842069,-2.2989655],[0.2634315,0.7031456,-2.2042723],[-0.2634315,0.7031456,-2.2042723],[-0.4000001,0.6482331,-2.274874],[-0.4000001,0.5933205,-2.5494368],[-0.28,0.5697865,-2.6671064],[0.28,0.5697865,-2.6671064],[0.4000001,0.5933205,-2.5494368],[0.4000001,0.6482331,-2.274874],[0.28,0.671767,-2.1572044],[-0.28,0.671767,-2.1572044],[-0.4000001,0.4913402,-2.2434955],[-0.4000001,0.4364276,-2.5180583],[-0.28,0.4128937,-2.6357279],[0.28,0.4128937,-2.6357279],[0.4000001,0.4364276,-2.5180583],[0.4000001,0.4913402,-2.2434955],[0.28,0.5148741,-2.1258259],[-0.28,0.5148741,-2.1258259]],"facets":18,"panels":[[-0.285,0.6222742,-2.5066495],[-0.285,0.6585029,-2.3255057],[-0.2323655,0.6688253,-2.2738934],[0.2323655,0.6688253,-2.2738934],[0.2850001,0.6585029,-2.3255057],[0.285,0.6222742,-2.5066495],[0.2323654,0.6119516,-2.5582621],[-0.2323654,0.6119516,-2.5582621],[-0.285,0.6909148,-2.5203776],[-0.285,0.7271435,-2.3392339],[-0.2323655,0.737466,-2.2876215],[0.2323655,0.737466,-2.2876215],[0.2850001,0.7271435,-2.3392339],[0.285,0.6909148,-2.5203776],[0.2323654,0.6805923,-2.5719903],[-0.2323654,0.6805923,-2.5719903],[-0.265,0.7121511,-2.5161765],[-0.265,0.7451305,-2.3512797],[-0.2240812,0.7531553,-2.3111556],[0.2240812,0.7531553,-2.3111556],[0.265,0.7451305,-2.3512797],[0.265,0.7121511,-2.5161765],[0.2240812,0.7041262,-2.5563009],[-0.2240812,0.7041262,-2.5563009]],"bolts":8},
"Shin.AnkleSide": {"solid":[[0.6420218,-0.207344,-2.2371259],[0.6196706,-0.2095791,-2.4628739],[0.6005474,-0.1144412,-2.5589681],[0.5580729,0.3103032,-2.5589681],[0.5579782,0.407344,-2.4628739],[0.5803295,0.4095791,-2.2371259],[0.5994527,0.3144412,-2.1410317],[0.6419272,-0.1103032,-2.1410317],[0.6080284,-0.2509428,-2.2166781],[0.5824124,-0.2535044,-2.4754004],[0.5586491,-0.1352822,-2.5948107],[0.5128774,0.3224349,-2.5948107],[0.5127598,0.4430216,-2.4754004],[0.5383759,0.4455832,-2.2166781],[0.5621391,0.327361,-2.0972679],[0.6079108,-0.130356,-2.0972679],[0.4892107,-0.2628246,-2.2047963],[0.4635947,-0.2653862,-2.4635186],[0.4398314,-0.147164,-2.5829289],[0.3940597,0.3105531,-2.5829289],[0.3939421,0.4311398,-2.4635186],[0.4195582,0.4337015,-2.2047963],[0.4433214,0.3154793,-2.085386],[0.4890931,-0.1422378,-2.085386]],"facets":18,"panels":[],"bolts":0},
"Pelvis.core": {"solid":[[0.62,0.62,0.5],[0.62,-0.6,0.5],[0.72,0.7,-0.3],[0.72,-0.62,-0.3],[0.45,0.7,0.62],[0.45,-0.66,0.62],[0.4,0.55,-0.8],[0.4,-0.45,-0.8],[-0.62,0.62,0.5],[-0.62,-0.6,0.5],[-0.72,0.7,-0.3],[-0.72,-0.62,-0.3],[-0.45,0.7,0.62],[-0.45,-0.66,0.62],[-0.4,0.55,-0.8],[-0.4,-0.45,-0.8]],"facets":16,"panels":[],"bolts":0},
"Pelvis.Crown": {"solid":[[-0.4339507,0.993916,0.4580249],[-0.2759168,1.0410775,0.1632654],[0.2759168,1.0410775,0.1632654],[0.4339507,0.993916,0.4580249],[0.2976482,0.9589224,0.6767346],[-0.2976482,0.9589224,0.6767346],[-0.48,0.9541827,0.453178],[-0.3,1.0078995,0.1174481],[0.3,1.0078995,0.1174481],[0.48,0.9541827,0.453178],[0.32,0.9131052,0.7099125],[-0.32,0.9131052,0.7099125],[-0.48,0.6974481,0.4121005],[-0.3,0.7511649,0.0763706],[0.3,0.7511649,0.0763706],[0.48,0.6974481,0.4121005],[0.32,0.6563706,0.668835],[-0.32,0.6563706,0.668835]],"facets":14,"panels":[[0.2307606,1.0094794,0.2341636],[-0.2307606,1.0094794,0.2341636],[-0.3476081,0.9746091,0.4521036],[-0.2557386,0.951023,0.5995167],[0.2557386,0.951023,0.5995167],[0.3476081,0.9746091,0.4521036],[0.2307606,1.0588515,0.2420631],[-0.2307606,1.0588515,0.2420631],[-0.3476081,1.0239811,0.4600031],[-0.2557386,1.0003949,0.6074162],[0.2557386,1.0003949,0.6074162],[0.3476081,1.0239811,0.4600031],[0.218719,1.0754405,0.2649717],[-0.218719,1.0754405,0.2649717],[-0.3245834,1.0438477,0.4624265],[-0.2445627,1.0233036,0.5908272],[0.2445627,1.0233036,0.5908272],[0.3245834,1.0438477,0.4624265]],"bolts":6},
"Pelvis.Cod": {"solid":[[-0.3994854,1.089713,-0.3228698],[-0.2648505,0.9863672,-1.3563275],[0.2648505,0.9863672,-1.3563275],[0.3994854,1.089713,-0.3228698],[0.3272079,1.1256723,0.0367246],[-0.3272079,1.1256723,0.0367246],[-0.44,1.0500495,-0.3175087],[-0.3,0.9425856,-1.3921489],[0.3,0.9425856,-1.3921489],[0.44,1.0500495,-0.3175087],[0.36,1.089851,0.0805062],[-0.36,1.089851,0.0805062],[-0.44,0.7515384,-0.2876576],[-0.3,0.6440744,-1.3622978],[0.3,0.6440744,-1.3622978],[0.44,0.7515384,-0.2876576],[0.36,0.7913399,0.1103573],[-0.36,0.7913399,0.1103573]],"facets":14,"panels":[[0.3235205,1.0695533,-0.323469],[0.2698343,1.0283437,-0.7355647],[-0.2790578,1.0354236,-0.6647651],[-0.3235206,1.0695533,-0.323469],[-0.2657226,1.0983088,-0.0359131],[0.2657225,1.0983088,-0.0359132],[0.3235206,1.1093547,-0.3274492],[0.2698343,1.0681452,-0.7395448],[-0.2790578,1.0752251,-0.6687453],[-0.3235206,1.1093547,-0.3274492],[-0.2657226,1.1381103,-0.0398933],[0.2657225,1.1381103,-0.0398933],[0.3032633,1.1291864,-0.3301297],[0.2525714,1.0902753,-0.719241],[-0.2612047,1.0969024,-0.6529709],[-0.3032633,1.1291864,-0.3301297],[-0.2493265,1.156021,-0.0617841],[0.2493265,1.156021,-0.0617842],[0.2447663,1.0091016,-0.927987],[0.1989452,0.9739293,-1.2797097],[-0.1989452,0.9739293,-1.2797097],[-0.2531329,1.0155238,-0.8637649],[0.2447663,1.0787542,-0.9349523],[0.1989452,1.043582,-1.2866749],[-0.1989452,1.043582,-1.2866749],[-0.2531329,1.0851763,-0.8707301],[0.2223611,1.0969372,-0.9541196],[0.1813705,1.0654727,-1.2687643],[-0.1813705,1.0654727,-1.2687643],[-0.2299619,1.1027715,-0.8957762]],"bolts":10},
"Pelvis.CodStep": {"solid":[[-0.21,1.1792967,-0.2070322],[-0.21,1.1607032,-0.3929678],[-0.1334315,1.1530843,-0.4691563],[0.1334315,1.1530843,-0.4691563],[0.21,1.1607032,-0.3929678],[0.21,1.1792967,-0.2070322],[0.1334315,1.1869156,-0.1308437],[-0.1334315,1.1869156,-0.1308437],[-0.25,1.1411439,-0.1865658],[-0.25,1.119253,-0.4054739],[-0.15,1.1093026,-0.5049777],[0.15,1.1093026,-0.5049777],[0.25,1.119253,-0.4054739],[0.25,1.1411439,-0.1865658],[0.15,1.1510943,-0.087062],[-0.15,1.1510943,-0.087062],[-0.25,1.0416402,-0.1766154],[-0.25,1.0197493,-0.3955236],[-0.15,1.0097989,-0.4950273],[0.15,1.0097989,-0.4950273],[0.25,1.0197493,-0.3955236],[0.25,1.0416402,-0.1766154],[0.15,1.0515906,-0.0771117],[-0.15,1.0515906,-0.0771117]],"facets":18,"panels":[],"bolts":0},
"Pelvis.CodLame": {"solid":[[-0.17,1.1602918,-0.9170818],[-0.17,1.1397082,-1.1229181],[-0.1134315,1.1340793,-1.1792059],[0.1134315,1.1340793,-1.1792059],[0.17,1.1397082,-1.1229181],[0.17,1.1602918,-0.9170818],[0.1134315,1.1659206,-0.860794],[-0.1134315,1.1659206,-0.860794],[-0.21,1.122139,-0.8966154],[-0.21,1.098258,-1.1354243],[-0.13,1.0902977,-1.2150273],[0.13,1.0902977,-1.2150273],[0.21,1.098258,-1.1354243],[0.21,1.122139,-0.8966154],[0.13,1.1300993,-0.8170124],[-0.13,1.1300993,-0.8170124],[-0.21,1.0325856,-0.8876601],[-0.21,1.0087047,-1.1264689],[-0.13,1.0007443,-1.206072],[0.13,1.0007443,-1.206072],[0.21,1.0087047,-1.1264689],[0.21,1.0325856,-0.8876601],[0.13,1.0405459,-0.8080571],[-0.13,1.0405459,-0.8080571]],"facets":18,"panels":[],"bolts":0},
"Pelvis.Wing.R": {"solid":[[0.5347595,1.0175078,0.1903216],[1.323531,0.7627897,0.2807549],[1.3916267,0.679267,0.5962243],[1.3032885,0.6646943,0.8015956],[0.5202285,0.9690713,0.4543006],[0.4875739,0.9994265,0.1389033],[1.3442112,0.7227925,0.2371175],[1.4205314,0.6291823,0.5906884],[1.3106923,0.6110626,0.8460452],[0.4691925,0.9381554,0.4728314],[0.436775,0.8300968,0.1050373],[1.2934123,0.5534627,0.2032515],[1.3697325,0.4598526,0.5568224],[1.2598934,0.4417329,0.8121792],[0.4183936,0.7688256,0.4389654]],"facets":12,"panels":[[1.3106201,0.6838076,0.5887305],[1.2579452,0.7484159,0.3447013],[0.5964219,0.9620417,0.2688571],[0.5891105,0.9376703,0.4016816],[1.2625957,0.6758852,0.7003791],[1.3303752,0.7496581,0.6019005],[1.2777003,0.8142664,0.3578714],[0.616177,1.0278922,0.2820272],[0.6088656,1.0035207,0.4148517],[1.2823509,0.7417357,0.7135491],[1.3159229,0.7747005,0.6046685],[1.2673602,0.834265,0.3796901],[0.6397699,1.0369328,0.3077363],[0.6343836,1.0189787,0.4055862],[1.2786489,0.7685515,0.6913244]],"bolts":5},
"Pelvis.Wing.L": {"solid":[[-0.5347595,1.0175078,0.1903216],[-1.323531,0.7627897,0.2807549],[-1.3916267,0.679267,0.5962243],[-1.3032885,0.6646943,0.8015956],[-0.5202285,0.9690713,0.4543006],[-0.4875739,0.9994265,0.1389033],[-1.3442112,0.7227925,0.2371175],[-1.4205314,0.6291823,0.5906884],[-1.3106923,0.6110626,0.8460452],[-0.4691925,0.9381554,0.4728314],[-0.436775,0.8300968,0.1050373],[-1.2934123,0.5534627,0.2032515],[-1.3697325,0.4598526,0.5568224],[-1.2598934,0.4417329,0.8121792],[-0.4183936,0.7688256,0.4389654]],"facets":12,"panels":[[-1.2625957,0.6758852,0.700379],[-0.5891104,0.9376704,0.4016816],[-0.5964218,0.9620418,0.2688571],[-1.2579452,0.7484159,0.3447012],[-1.3106201,0.6838076,0.5887305],[-1.2823508,0.7417357,0.7135491],[-0.6088656,1.0035208,0.4148517],[-0.616177,1.0278922,0.2820272],[-1.2777003,0.8142664,0.3578713],[-1.3303752,0.7496581,0.6019005],[-1.2786489,0.7685515,0.6913244],[-0.6343836,1.0189787,0.4055862],[-0.6397698,1.0369328,0.3077363],[-1.2673602,0.834265,0.37969],[-1.315923,0.7747005,0.6046684]],"bolts":5},
"Pelvis.HipGuard.R": {"solid":[[0.4939981,0.9528628,0.1032474],[0.491051,0.9381275,-0.2032474],[0.5459777,0.9243171,-0.2597481],[0.6899887,0.8955149,-0.2597481],[0.746002,0.8871372,-0.2032474],[0.7489491,0.9018726,0.1032474],[0.6940223,0.915683,0.1597481],[0.5500113,0.9444851,0.1597481],[0.4470987,0.9223269,0.1217549],[0.4438334,0.9060003,-0.2178373],[0.5215116,0.8864695,-0.2977413],[0.6980162,0.8511686,-0.2977413],[0.7772309,0.8393208,-0.2178373],[0.7804962,0.8556474,0.1217549],[0.702818,0.8751782,0.2016589],[0.5263134,0.9104791,0.2016589],[0.423593,0.8047984,0.1276313],[0.4203277,0.7884718,-0.2119608],[0.4980058,0.768941,-0.2918648],[0.6745104,0.7336401,-0.2918648],[0.7537252,0.7217923,-0.2119608],[0.7569904,0.7381189,0.1276313],[0.6793123,0.7576497,0.2075353],[0.5028077,0.7929506,0.2075353]],"facets":18,"panels":[],"bolts":0},
"Pelvis.HipGuard.L": {"solid":[[-0.4939981,0.9528628,0.1032474],[-0.491051,0.9381275,-0.2032474],[-0.5459777,0.9243171,-0.2597481],[-0.6899887,0.8955149,-0.2597481],[-0.746002,0.8871372,-0.2032474],[-0.7489491,0.9018726,0.1032474],[-0.6940223,0.915683,0.1597481],[-0.5500113,0.9444851,0.1597481],[-0.4470987,0.9223269,0.1217549],[-0.4438334,0.9060003,-0.2178373],[-0.5215116,0.8864695,-0.2977413],[-0.6980162,0.8511686,-0.2977413],[-0.7772309,0.8393208,-0.2178373],[-0.7804962,0.8556474,0.1217549],[-0.702818,0.8751782,0.2016589],[-0.5263134,0.9104791,0.2016589],[-0.423593,0.8047984,0.1276313],[-0.4203277,0.7884718,-0.2119608],[-0.4980058,0.768941,-0.2918648],[-0.6745104,0.7336401,-0.2918648],[-0.7537252,0.7217923,-0.2119608],[-0.7569904,0.7381189,0.1276313],[-0.6793123,0.7576497,0.2075353],[-0.5028077,0.7929506,0.2075353]],"facets":18,"panels":[],"bolts":0},
"Pelvis.Seat.R": {"solid":[[0.1226936,-1.0131552,-0.5494777],[0.7555954,-0.897684,-0.7871495],[1.1097059,-0.7580597,-0.1699502],[0.9993517,-0.6958846,0.6945797],[0.0977462,-0.8997577,0.6393812],[0.075655,-0.9855092,-0.5810469],[0.7647362,-0.8597882,-0.8398157],[1.14161,-0.7111885,-0.182941],[1.0247313,-0.6453375,0.7327026],[0.0493399,-0.8658952,0.6729866],[0.0328861,-0.7911053,-0.6004874],[0.7219673,-0.6653842,-0.8592561],[1.0988411,-0.5167845,-0.2023814],[0.9819624,-0.4509336,0.7132621],[0.006571,-0.6714912,0.6535462]],"facets":12,"panels":[[1.0295707,-0.7536014,-0.1548266],[0.9314498,-0.6983188,0.6138653],[0.1681929,-0.8709082,0.5671368],[0.190576,-0.9726495,-0.4995194],[0.7181413,-0.8763967,-0.6976346],[1.0402629,-0.8022023,-0.1499665],[0.9421421,-0.7469198,0.6187254],[0.1788851,-0.9195092,0.5719969],[0.2012682,-1.0212505,-0.4946593],[0.7288335,-0.9249977,-0.6927745],[1.0243109,-0.825638,-0.1434711],[0.9294523,-0.7721934,0.5996639],[0.2030882,-0.9364405,0.5551941],[0.2247875,-1.0350735,-0.4788747],[0.7242631,-0.9439455,-0.6664414]],"bolts":5},
"Pelvis.Seat.L": {"solid":[[-0.1226936,-1.0131552,-0.5494777],[-0.7555954,-0.897684,-0.7871495],[-1.1097059,-0.7580597,-0.1699502],[-0.9993517,-0.6958846,0.6945797],[-0.0977462,-0.8997577,0.6393812],[-0.075655,-0.9855092,-0.5810469],[-0.7647362,-0.8597882,-0.8398157],[-1.14161,-0.7111885,-0.182941],[-1.0247313,-0.6453375,0.7327026],[-0.0493399,-0.8658952,0.6729866],[-0.0328861,-0.7911053,-0.6004874],[-0.7219673,-0.6653842,-0.8592561],[-1.0988411,-0.5167845,-0.2023814],[-0.9819624,-0.4509336,0.7132621],[-0.006571,-0.6714912,0.6535462]],"facets":12,"panels":[[-1.0295707,-0.7536014,-0.1548266],[-0.7181413,-0.8763967,-0.6976346],[-0.190576,-0.9726496,-0.4995195],[-0.1681929,-0.8709082,0.5671368],[-0.9314499,-0.6983188,0.6138653],[-1.0402629,-0.8022023,-0.1499665],[-0.7288336,-0.9249976,-0.6927745],[-0.2012682,-1.0212506,-0.4946594],[-0.1788851,-0.9195092,0.5719969],[-0.9421421,-0.7469198,0.6187254],[-1.0243108,-0.825638,-0.1434711],[-0.7242632,-0.9439455,-0.6664413],[-0.2247876,-1.0350735,-0.4788747],[-0.2030883,-0.9364405,0.5551941],[-0.9294524,-0.7721934,0.5996639]],"bolts":5},
"Pelvis.SeatStep.R": {"solid":[[0.3621921,-0.9860519,0.2626576],[0.3690186,-1.0170816,-0.0626576],[0.4653486,-1.0055002,-0.1587689],[0.7455117,-0.9438643,-0.1587689],[0.837808,-0.913948,-0.0626576],[0.8309814,-0.8829183,0.2626576],[0.7346514,-0.8944998,0.3587689],[0.4544884,-0.9561356,0.3587689],[0.3142265,-0.9541928,0.2752596],[0.3217451,-0.9883682,-0.0830357],[0.4414486,-0.9739767,-0.2024675],[0.7539749,-0.9052209,-0.2024675],[0.8686661,-0.8680456,-0.0830357],[0.8611474,-0.8338702,0.2752596],[0.7414439,-0.8482618,0.3946913],[0.4289176,-0.9170176,0.3946913],[0.2971189,-0.8764312,0.2674834],[0.3046375,-0.9106066,-0.0908119],[0.4243411,-0.8962151,-0.2102437],[0.7368673,-0.8274593,-0.2102437],[0.8515585,-0.790284,-0.0908119],[0.8440399,-0.7561086,0.2674834],[0.7243363,-0.7705002,0.3869152],[0.4118101,-0.839256,0.3869152]],"facets":18,"panels":[],"bolts":0},
"Pelvis.SeatStep.L": {"solid":[[-0.3621921,-0.9860519,0.2626576],[-0.3690186,-1.0170816,-0.0626576],[-0.4653486,-1.0055002,-0.1587689],[-0.7455117,-0.9438643,-0.1587689],[-0.837808,-0.913948,-0.0626576],[-0.8309814,-0.8829183,0.2626576],[-0.7346514,-0.8944998,0.3587689],[-0.4544884,-0.9561356,0.3587689],[-0.3142265,-0.9541928,0.2752596],[-0.3217451,-0.9883682,-0.0830357],[-0.4414486,-0.9739767,-0.2024675],[-0.7539749,-0.9052209,-0.2024675],[-0.8686661,-0.8680456,-0.0830357],[-0.8611474,-0.8338702,0.2752596],[-0.7414439,-0.8482618,0.3946913],[-0.4289176,-0.9170176,0.3946913],[-0.2971189,-0.8764312,0.2674834],[-0.3046375,-0.9106066,-0.0908119],[-0.4243411,-0.8962151,-0.2102437],[-0.7368673,-0.8274593,-0.2102437],[-0.8515585,-0.790284,-0.0908119],[-0.8440399,-0.7561086,0.2674834],[-0.7243363,-0.7705002,0.3869152],[-0.4118101,-0.839256,0.3869152]],"facets":18,"panels":[],"bolts":0},
"Pelvis.Tail": {"solid":[[-0.14,-0.9466383,0.3327659],[-0.14,-0.8933617,-0.7327659],[-0.0634315,-0.889538,-0.8092389],[0.0634315,-0.889538,-0.8092389],[0.14,-0.8933617,-0.7327659],[0.14,-0.9466383,0.3327659],[0.0634315,-0.950462,0.4092389],[-0.0634315,-0.950462,0.4092389],[-0.18,-0.9075156,0.3513113],[-0.18,-0.8525842,-0.7473162],[-0.08,-0.8475905,-0.8471915],[0.08,-0.8475905,-0.8471915],[0.18,-0.8525842,-0.7473162],[0.18,-0.9075156,0.3513113],[0.08,-0.9125094,0.4511865],[-0.08,-0.9125094,0.4511865],[-0.18,-0.7277402,0.3603001],[-0.18,-0.6728088,-0.7383275],[-0.08,-0.6678151,-0.8382027],[0.08,-0.6678151,-0.8382027],[0.18,-0.6728088,-0.7383275],[0.18,-0.7277402,0.3603001],[0.08,-0.732734,0.4601753],[-0.08,-0.732734,0.4601753]],"facets":18,"panels":[[-0.0323655,-0.9267415,0.3353312],[-0.065,-0.9251118,0.3027374],[-0.065,-0.874938,-0.7007399],[-0.0323655,-0.8733082,-0.7333337],[0.0323655,-0.8733082,-0.7333337],[0.065,-0.874938,-0.7007399],[0.065,-0.9251118,0.3027374],[0.0323655,-0.9267415,0.3353312],[-0.0323655,-0.9666916,0.3333337],[-0.065,-0.9650619,0.3007399],[-0.065,-0.914888,-0.7027373],[-0.0323655,-0.9132584,-0.7353312],[0.0323655,-0.9132584,-0.7353312],[0.065,-0.914888,-0.7027373],[0.065,-0.9650619,0.3007399],[0.0323655,-0.9666916,0.3333337],[-0.0240812,-0.9856679,0.31236],[-0.045,-0.9846233,0.2914672],[-0.045,-0.9352768,-0.6954622],[-0.0240812,-0.9342322,-0.716355],[0.0240812,-0.9342322,-0.716355],[0.045,-0.9352768,-0.6954622],[0.045,-0.9846233,0.2914672],[0.0240812,-0.9856679,0.31236]],"bolts":8},
"Pelvis.Roof.R": {"solid":[[0.3677629,0.3934315,0.7630593],[0.3677629,-0.3934315,0.7630593],[0.4808511,-0.51,0.7347872],[0.759149,-0.51,0.6652128],[0.8722371,-0.3934315,0.6369407],[0.8722371,0.3934315,0.6369407],[0.759149,0.51,0.6652128],[0.4808511,0.51,0.7347872],[0.3192558,0.41,0.733955],[0.3192558,-0.41,0.733955],[0.4550758,-0.55,0.7],[0.7655213,-0.55,0.6223885],[0.9013414,-0.41,0.5884336],[0.9013414,0.41,0.5884336],[0.7655213,0.55,0.6223885],[0.4550758,0.55,0.7],[0.2950023,0.41,0.6369407],[0.2950023,-0.41,0.6369407],[0.4308222,-0.55,0.6029857],[0.7412678,-0.55,0.5253743],[0.8770878,-0.41,0.4914193],[0.8770878,0.41,0.4914193],[0.7412678,0.55,0.5253743],[0.4308222,0.55,0.6029857]],"facets":18,"panels":[],"bolts":0},
"Pelvis.Roof.L": {"solid":[[-0.3677629,0.3934315,0.7630593],[-0.3677629,-0.3934315,0.7630593],[-0.4808511,-0.51,0.7347872],[-0.759149,-0.51,0.6652128],[-0.8722371,-0.3934315,0.6369407],[-0.8722371,0.3934315,0.6369407],[-0.759149,0.51,0.6652128],[-0.4808511,0.51,0.7347872],[-0.3192558,0.41,0.733955],[-0.3192558,-0.41,0.733955],[-0.4550758,-0.55,0.7],[-0.7655213,-0.55,0.6223885],[-0.9013414,-0.41,0.5884336],[-0.9013414,0.41,0.5884336],[-0.7655213,0.55,0.6223885],[-0.4550758,0.55,0.7],[-0.2950023,0.41,0.6369407],[-0.2950023,-0.41,0.6369407],[-0.4308222,-0.55,0.6029857],[-0.7412678,-0.55,0.5253743],[-0.8770878,-0.41,0.4914193],[-0.8770878,0.41,0.4914193],[-0.7412678,0.55,0.5253743],[-0.4308222,0.55,0.6029857]],"facets":18,"panels":[],"bolts":0}
}},
{"side": -1, "truth": {
"Thigh.core": {"solid":[[0.33,-0.3,0.4],[-0.33,-0.3,0.4],[-0.45,-0.18,0.4],[-0.45,0.38,0.4],[-0.33,0.5,0.4],[0.33,0.5,0.4],[0.45,0.38,0.4],[0.45,-0.18,0.4],[0.42,-0.34,0.05],[-0.42,-0.34,0.05],[-0.6,-0.16,0.05],[-0.6,0.46,0.05],[-0.42,0.64,0.05],[0.42,0.64,0.05],[0.6,0.46,0.05],[0.6,-0.16,0.05],[0.42,-0.34,-1.45],[-0.42,-0.34,-1.45],[-0.6,-0.16,-1.45],[-0.6,0.46,-1.45],[-0.42,0.64,-1.45],[0.42,0.64,-1.45],[0.6,0.46,-1.45],[0.6,-0.16,-1.45],[0.335,-0.3,-1.8],[-0.335,-0.3,-1.8],[-0.475,-0.16,-1.8],[-0.475,0.36,-1.8],[-0.335,0.5,-1.8],[0.335,0.5,-1.8],[0.475,0.36,-1.8],[0.475,-0.16,-1.8]],"facets":26,"panels":[],"bolts":0},
"Thigh.Shield": {"solid":[[0.6003516,0.9127237,-0.0100526],[0.5973628,0.9625379,-1.0099225],[0.371703,0.9714425,-1.4588065],[-0.4174352,0.9240942,-1.4588065],[-0.6404113,0.8882715,-1.0099225],[-0.6374224,0.8384573,-0.0100526],[-0.4117627,0.8295527,0.4388314],[0.3773755,0.8769009,0.4388314],[0.6427007,0.874771,-0.0026155],[0.6396555,0.9255249,-1.0213474],[0.3986532,0.9350349,-1.5007508],[-0.4398389,0.8847254,-1.5007508],[-0.677975,0.8464671,-1.0213474],[-0.6749298,0.7957132,-0.0026155],[-0.4339275,0.7862031,0.4767878],[0.4045646,0.8365127,0.4767878],[0.6558607,0.6554389,-0.0135821],[0.6528155,0.7061929,-1.0323141],[0.4118131,0.7157029,-1.5117174],[-0.426679,0.6653934,-1.5117174],[-0.6648151,0.627135,-1.0323141],[-0.6617699,0.5763811,-0.0135821],[-0.4207676,0.566871,0.4658212],[0.4177245,0.6171806,0.4658212]],"facets":18,"panels":[[-0.3645209,0.8161214,0.3629277],[0.3320785,0.8579174,0.3629277],[0.5266297,0.8891734,-0.0287326],[0.5237466,0.9372256,-0.9932363],[0.3268539,0.9449951,-1.3848965],[-0.3697456,0.9031991,-1.3848965],[-0.5642967,0.8719431,-0.9932363],[-0.5614136,0.8238909,-0.0287326],[-0.3675118,0.8659696,0.3654201],[0.3290876,0.9077656,0.3654201],[0.5236388,0.9390216,-0.0262402],[0.5207557,0.9870738,-0.9907439],[0.323863,0.9948433,-1.3824042],[-0.3727365,0.9530473,-1.3824042],[-0.5672876,0.9217913,-0.9907439],[-0.5644045,0.8737391,-0.0262402],[-0.3564294,0.8876444,0.346442],[0.3154931,0.9279597,0.346442],[0.5024643,0.957998,-0.0299587],[0.4996094,1.0055803,-0.9850315],[0.3103879,1.0130471,-1.3614321],[-0.3615346,0.9727317,-1.3614321],[-0.5485058,0.9426934,-0.9850315],[-0.5456509,0.8951111,-0.0299587]],"bolts":8},
"Thigh.Block": {"solid":[[0.2199377,1.0082324,0.243278],[0.2192007,1.0205159,-0.003278],[0.1625648,1.0199426,-0.0597762],[-0.2036396,0.9979704,-0.0597762],[-0.2599377,0.9917676,-0.003278],[-0.2592007,0.9794841,0.243278],[-0.2025648,0.9800573,0.2997762],[0.1636396,1.0020295,0.2997762],[0.262308,0.9699251,0.257832],[0.2614721,0.9838576,-0.0218199],[0.1813769,0.9830468,-0.1017204],[-0.2179051,0.9590899,-0.1017204],[-0.2975226,0.9503179,-0.0218199],[-0.2966867,0.9363854,0.257832],[-0.2165914,0.9371961,0.3377326],[0.1826905,0.9611531,0.3377326],[0.2694862,0.8502895,0.2518502],[0.2686502,0.8642219,-0.0278017],[0.188555,0.8634112,-0.1077022],[-0.2107269,0.8394543,-0.1077022],[-0.2903445,0.8306822,-0.0278017],[-0.2895085,0.8167497,0.2518502],[-0.2094133,0.8175604,0.3317508],[0.1898686,0.8415174,0.3317508]],"facets":18,"panels":[],"bolts":0},
"Thigh.Lame": {"solid":[[0.5152019,1.0169734,-1.1630588],[0.3580984,1.0120851,-1.3899561],[-0.3986245,0.9666817,-1.3899561],[-0.5551853,0.9527501,-1.1630588],[-0.5091674,0.9524506,-1.0100318],[0.46955,1.0111736,-1.0100318],[0.561354,0.9798173,-1.1707984],[0.3813663,0.9742171,-1.4307466],[-0.4171976,0.9263031,-1.4307466],[-0.5965636,0.9103422,-1.1707984],[-0.5364322,0.909951,-0.9708382],[0.5017008,0.972239,-0.9708382],[0.5673421,0.8800166,-1.1727943],[0.3873544,0.8744164,-1.4327425],[-0.4112095,0.8265026,-1.4327425],[-0.5905755,0.8105416,-1.1727943],[-0.5304441,0.8101503,-0.9728342],[0.5076889,0.8724384,-0.9728342]],"facets":14,"panels":[],"bolts":0},
"Thigh.Outer": {"solid":[[-0.8963261,-0.6993303,0.0405074],[-0.9234846,-0.6971576,-0.6427998],[-0.9302595,-0.4659773,-1.2745335],[-0.8760005,0.2877677,-1.4255476],[-0.8321795,0.6398191,-1.0341262],[-0.7895345,0.6364074,0.0388219],[-0.7930059,0.3335055,0.55784],[-0.859628,-0.475686,0.5106725],[-0.8593135,-0.7424191,0.0480094],[-0.8871133,-0.7401951,-0.6514348],[-0.8941858,-0.4988625,-1.3109107],[-0.8367438,0.299098,-1.4707837],[-0.7897608,0.6765533,-1.0511172],[-0.7460753,0.6730585,0.0480094],[-0.749751,0.3523302,0.5975726],[-0.8203176,-0.504772,0.5476124],[-0.6601087,-0.7583555,0.0400412],[-0.6879086,-0.7561315,-0.659403],[-0.694981,-0.5147989,-1.3188789],[-0.6375391,0.2831616,-1.4787519],[-0.590556,0.6606169,-1.0590854],[-0.5468705,0.6571221,0.0400412],[-0.5505463,0.3363939,0.5896044],[-0.6211129,-0.5207084,0.5396442]],"facets":18,"panels":[[-0.7794868,0.2906393,0.4795566],[-0.7763985,0.560117,0.0178105],[-0.7886124,0.5610941,-0.2894937],[-0.8835093,-0.6251161,-0.2894937],[-0.8711026,-0.6261086,0.0226564],[-0.8387128,-0.4287195,0.4376253],[-0.8492085,0.2962171,0.4823454],[-0.8461201,0.5656947,0.0205993],[-0.8583341,0.5666718,-0.2867048],[-0.9532309,-0.6195383,-0.2867049],[-0.9408243,-0.6205308,0.0254452],[-0.9084345,-0.4231417,0.4404142],[-0.870836,0.2868047,0.4624791],[-0.8678498,0.5473692,0.0160056],[-0.8790552,0.5482656,-0.2659239],[-0.9707623,-0.5980719,-0.2659239],[-0.9593307,-0.5989864,0.0216942],[-0.9280897,-0.4085987,0.4219443],[-0.7963567,0.5617135,-0.4843388],[-0.8170925,0.5633725,-1.0060527],[-0.8549845,0.2589536,-1.3445148],[-0.9032756,-0.4118871,-1.2101108],[-0.8970585,-0.624032,-0.6303939],[-0.8912535,-0.6244965,-0.4843389],[-0.8361976,0.5649008,-0.4827452],[-0.8569335,0.5665597,-1.004459],[-0.8948255,0.2621409,-1.3429213],[-0.9431165,-0.4086998,-1.2085171],[-0.9368995,-0.6208448,-0.6288003],[-0.9310944,-0.6213092,-0.4827453],[-0.8585073,0.5466217,-0.5019325],[-0.8781428,0.5481926,-0.9959635],[-0.9144538,0.2564758,-1.3203032],[-0.9611534,-0.3922571,-1.1903285],[-0.9550851,-0.5993261,-0.6244828],[-0.9502143,-0.5997157,-0.5019326]],"bolts":12},
"Thigh.OuterStep": {"solid":[[-0.9694378,-0.3795951,-0.0167539],[-0.9879788,-0.3781119,-0.4832461],[-0.9809105,-0.2015447,-0.6596745],[-0.951655,0.1641499,-0.6596745],[-0.9305622,0.3395951,-0.4832461],[-0.9120212,0.3381118,-0.0167539],[-0.9190895,0.1615447,0.1596745],[-0.948345,-0.2041499,0.1596745],[-0.9321286,-0.4227076,-0.0017921],[-0.9519857,-0.4211191,-0.5013952],[-0.9439794,-0.2211206,-0.7012363],[-0.9120813,0.1776055,-0.7012363],[-0.8881895,0.3763331,-0.5013952],[-0.8683324,0.3747445,-0.0017921],[-0.8763387,0.1747461,0.1980491],[-0.9082368,-0.22398,0.1980491],[-0.8424864,-0.429879,-0.0053778],[-0.8623435,-0.4282905,-0.5049809],[-0.8543373,-0.228292,-0.704822],[-0.8224391,0.1704341,-0.704822],[-0.7985473,0.3691617,-0.5049809],[-0.7786903,0.3675731,-0.0053778],[-0.7866965,0.1675747,0.1944634],[-0.8185946,-0.2311514,0.1944634]],"facets":18,"panels":[],"bolts":0},
"Thigh.Inner": {"solid":[[0.8776518,-0.5265174,-0.8959235],[0.861841,-0.3684096,-1.41],[0.7737058,0.5129414,-1.41],[0.7623708,0.6262924,-0.603093],[0.7732095,0.5179051,-0.24],[0.871125,-0.4612505,-0.24],[0.8418908,-0.5709032,-0.9],[0.8249752,-0.4017468,-1.45],[0.7304466,0.5435384,-1.45],[0.7185062,0.6629429,-0.6],[0.7304466,0.5435384,-0.2],[0.8349255,-0.5012506,-0.2],[0.6826848,-0.5868238,-0.9],[0.6657692,-0.4176674,-1.45],[0.5712407,0.5276178,-1.45],[0.5593002,0.6470223,-0.6],[0.5712407,0.5276178,-0.2],[0.6757196,-0.5171711,-0.2]],"facets":14,"panels":[[0.7588614,0.4603896,-0.315],[0.8041243,0.0077606,-0.315],[0.8041242,0.0077606,-1.335],[0.7602884,0.4461192,-1.335],[0.7500883,0.5481198,-0.6088924],[0.828514,0.4673549,-0.315],[0.8737769,0.0147259,-0.315],[0.8737769,0.0147259,-1.335],[0.829941,0.4530844,-1.335],[0.819741,0.5550851,-0.6088925],[0.8498954,0.4545382,-0.335],[0.8916876,0.0366167,-0.335],[0.8916875,0.0366167,-1.3150001],[0.8515706,0.437786,-1.3150001],[0.8416732,0.5367599,-0.610439],[0.8235274,-0.1862716,-0.3149999],[0.8444706,-0.3957034,-0.3149999],[0.8501749,-0.4527469,-0.88828],[0.8364357,-0.3153551,-1.3349999],[0.8235274,-0.1862716,-1.3349999],[0.8633289,-0.1822915,-0.3149999],[0.884272,-0.3917232,-0.3149999],[0.8899764,-0.4487667,-0.88828],[0.8762372,-0.3113749,-1.3349999],[0.8633289,-0.1822915,-1.3349999],[0.8852197,-0.2002021,-0.3349999],[0.9023718,-0.3717233,-0.3349999],[0.9078569,-0.4265738,-0.8862417],[0.8946701,-0.2947063,-1.3149999],[0.8852197,-0.2002021,-1.3149999]],"bolts":10},
"Thigh.Rear": {"solid":[[0.6,-0.9654287,0.0414257],[0.6,-0.9993547,-0.6370928],[0.3989588,-1.0139576,-0.9291516],[-0.3989588,-1.0139576,-0.9291516],[-0.6,-0.9993547,-0.6370928],[-0.6,-0.9654287,0.0414257],[-0.4336241,-0.9460424,0.4291516],[0.4336241,-0.9460424,0.4291516],[0.64,-0.9250687,0.0476282],[0.64,-0.960025,-0.6514985],[0.42,-0.976005,-0.9710993],[-0.42,-0.976005,-0.9710993],[-0.64,-0.960025,-0.6514985],[-0.64,-0.9250687,0.0476282],[-0.46,-0.9040949,0.4671042],[0.46,-0.9040949,0.4671042],[0.64,-0.7452933,0.0386394],[0.64,-0.7802496,-0.6604872],[0.42,-0.7962296,-0.980088],[-0.42,-0.7962296,-0.980088],[-0.64,-0.7802496,-0.6604872],[-0.64,-0.7452933,0.0386394],[-0.46,-0.7243195,0.4581155],[0.46,-0.7243195,0.4581155]],"facets":18,"panels":[[0.525,-0.9462224,0.0250518],[0.3841694,-0.9298127,0.3532465],[-0.3841694,-0.9298127,0.3532465],[-0.525,-0.9462224,0.0250518],[-0.525,-0.9782164,-0.6148264],[-0.3595065,-0.9902372,-0.8552439],[0.3595065,-0.9902372,-0.8552439],[0.525,-0.9782164,-0.6148264],[0.525,-0.99616,0.0275487],[0.3841694,-0.9797503,0.3557433],[-0.3841694,-0.9797503,0.3557433],[-0.525,-0.99616,0.0275487],[-0.525,-1.028154,-0.6123295],[-0.3595065,-1.0401748,-0.8527471],[0.3595065,-1.0401748,-0.8527471],[0.525,-1.028154,-0.6123295],[0.505,-1.0163401,0.0244474],[0.3709815,-1.0007241,0.3367671],[-0.3709815,-1.0007241,0.3367671],[-0.505,-1.0163401,0.0244474],[-0.505,-1.0478188,-0.6051267],[-0.3489859,-1.0591512,-0.8317733],[0.3489859,-1.0591512,-0.8317733],[0.505,-1.0478188,-0.6051267]],"bolts":8},
"Thigh.RearStep": {"solid":[[0.31,-1.0533367,-0.166735],[0.31,-1.0666631,-0.433265],[0.2334315,-1.0704868,-0.509738],[-0.2334315,-1.0704868,-0.509738],[-0.31,-1.0666631,-0.433265],[-0.31,-1.0533367,-0.166735],[-0.2334315,-1.0495131,-0.090262],[0.2334315,-1.0495131,-0.090262],[0.35,-1.0125592,-0.1521847],[0.35,-1.0275404,-0.4518104],[0.25,-1.0325342,-0.5516856],[-0.25,-1.0325342,-0.5516856],[-0.35,-1.0275404,-0.4518104],[-0.35,-1.0125592,-0.1521847],[-0.25,-1.0075654,-0.0523094],[0.25,-1.0075654,-0.0523094],[0.35,-0.932659,-0.1561797],[0.35,-0.9476403,-0.4558054],[0.25,-0.9526341,-0.5556806],[-0.25,-0.9526341,-0.5556806],[-0.35,-0.9476403,-0.4558054],[-0.35,-0.932659,-0.1561797],[-0.25,-0.9276652,-0.0563044],[0.25,-0.9276652,-0.0563044]],"facets":18,"panels":[],"bolts":0},
"Thigh.CornerOut": {"solid":[[-0.6046741,0.7607402,0.2029137],[-0.6419686,0.7969987,-1.1029136],[-0.6830156,0.7580089,-1.1594374],[-0.7575075,0.6813887,-1.1594374],[-0.7953259,0.6392598,-1.1029136],[-0.7580314,0.6030012,0.2029137],[-0.7169843,0.6419911,0.2594374],[-0.6424925,0.7186113,0.2594374],[-0.5476611,0.7610992,0.217877],[-0.5859013,0.7982771,-1.1210611],[-0.6439505,0.7431371,-1.2009977],[-0.7415414,0.6427579,-1.2009977],[-0.7950248,0.5831786,-1.1210611],[-0.7567846,0.5460007,0.217877],[-0.6987353,0.6011407,0.2978136],[-0.6011444,0.70152,0.2978136],[-0.4330328,0.6496551,0.2115088],[-0.471273,0.686833,-1.1274294],[-0.5293223,0.631693,-1.207366],[-0.6269132,0.5313138,-1.207366],[-0.6803964,0.4717345,-1.1274294],[-0.6421562,0.4345566,0.2115088],[-0.584107,0.4896966,0.2914454],[-0.4865161,0.5900759,0.2914454]],"facets":18,"panels":[],"bolts":0},
"Thigh.CornerIn": {"solid":[[0.7228147,0.6258237,-0.1367753],[0.7426594,0.6451172,-1.0632248],[0.7111945,0.6794759,-1.1097726],[0.6506443,0.7417562,-1.1097726],[0.6171853,0.7741762,-1.0632248],[0.5973406,0.7548828,-0.1367753],[0.6288055,0.7205241,-0.0902275],[0.6893557,0.6582438,-0.0902275],[0.7216761,0.5689284,-0.1214086],[0.7422302,0.5889115,-1.0809804],[0.6949335,0.6405582,-1.1509492],[0.6112841,0.7265977,-1.1509492],[0.5609899,0.7753302,-1.0809804],[0.5404358,0.755347,-0.1214086],[0.5877325,0.7037003,-0.0514398],[0.6713819,0.6176609,-0.0514398],[0.6213416,0.4713809,-0.1255892],[0.6418957,0.4913641,-1.085161],[0.594599,0.5430108,-1.1551298],[0.5109496,0.6290503,-1.1551298],[0.4606554,0.6777828,-1.085161],[0.4401013,0.6577996,-0.1255892],[0.487398,0.6061529,-0.0556204],[0.5710474,0.5201135,-0.0556204]],"facets":18,"panels":[],"bolts":0},
"Thigh.Cap": {"solid":[[0.4661148,-0.3206001,0.7921801],[-0.4661148,-0.3206001,0.7921801],[-0.5578418,0.2065509,0.6340348],[-0.3392738,0.5031305,0.5450609],[0.3392738,0.5031305,0.5450609],[0.5578418,0.2065509,0.6340348],[0.4999999,-0.370407,0.765361],[-0.4999999,-0.370407,0.765361],[-0.6,0.2042887,0.5929522],[-0.36,0.5299496,0.4952539],[0.36,0.5299496,0.4952539],[0.6,0.2042887,0.5929522],[0.4999999,-0.4106357,0.6312653],[-0.4999999,-0.4106357,0.6312653],[-0.6,0.16406,0.4588565],[-0.36,0.4897209,0.3611582],[0.36,0.4897209,0.3611582],[0.6,0.16406,0.4588565]],"facets":14,"panels":[[0.3004121,0.4255465,0.5474553],[-0.3004121,0.4255465,0.5474553],[-0.4787954,0.1834945,0.620071],[-0.4025803,-0.25451,0.7514725],[0.4025803,-0.25451,0.7514725],[0.4787954,0.1834945,0.620071],[0.3004121,0.4399139,0.5953466],[-0.3004121,0.4399139,0.5953466],[-0.4787954,0.1978619,0.6679623],[-0.4025803,-0.2401427,0.7993639],[0.4025803,-0.2401427,0.7993639],[0.4787954,0.1978619,0.6679623],[0.2900489,0.4265044,0.6202502],[-0.2900489,0.4265044,0.6202502],[-0.4577163,0.198993,0.6885036],[-0.3856378,-0.2152392,0.8127734],[0.3856378,-0.2152392,0.8127734],[0.4577163,0.198993,0.6885036]],"bolts":6}
}}
]}

View file

@ -0,0 +1,82 @@
{"source": {"branch": "nibu/fable-raptor-4", "sha": "0c271035b89cbf36b26977cc5a19c94e07199ae5", "blender": "5.3.0"},
"table": {"schema": "brokkr.plates.v0", "plates": [
{"name": "Torso.Jaw1", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.27, 5.5, 4.344352800343537], [0.25, 5.5, 4.14792737789203], [0.6025, 4.75, 4.437397172236504], [0.6125, 4.75, 4.857397172236504]], "inside": [0.0, 5.125, 4.5561471722365035], "lift": 0.1, "thick": 0.14, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "olive_light", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 9.0, "seed": [1, 0]}},
{"name": "Torso.Jaw2", "mat": "olive_light", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.6131733333333336, 4.72, 4.885944978524653], [0.6160000000000002, 4.72, 4.4478971722365035], [0.88375, 3.95, 4.672185089974293], [0.85025, 3.95, 5.162396244735779]], "inside": [0.0, 4.335, 4.819518423307627], "lift": 0.13, "thick": 0.16, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "khaki", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 0.9, "seed": [18, 17]}},
{"name": "Torso.Jaw3", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.8582000000000001, 3.92, 5.171231323471511], [0.8920000000000001, 3.92, 4.680185089974293], [1.041875, 3.05, 4.885938303341902], [1.029375, 3.25, 5.265938303341902]], "inside": [0.0, 3.535, 5.03285175664096], "lift": 0.1, "thick": 0.14, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "olive_light", "min_area": 0.12, "lifts": [0.035, 0.035], "inset": 0.07, "gap": 0.04, "split": 99.0, "seed": [35, 34]}},
{"name": "Torso.JawLip1", "mat": "gunmetal", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.27666666666666656, 5.4, 4.19167737789203], [0.1577777777777777, 5.4, 4.03167737789203], [0.45000000000000007, 4.5, 4.364897172236503], [0.7150000000000001, 4.5, 4.5248971722365035]], "inside": [0.0, 4.95, 4.617397172236504], "lift": 0.04, "thick": 0.08, "taper": 0.035, "back": 0.94, "gap": 0.025}},
{"name": "Torso.JawLip2", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.7330000000000001, 4.46, 4.536185089974293], [0.4620000000000001, 4.46, 4.3761850899742925], [0.63, 3.4, 4.655938303341902], [1.0025, 3.4, 4.815938303341902]], "inside": [0.0, 3.9299999999999997, 4.927518423307626], "lift": 0.05, "thick": 0.08, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "olive_light", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 9.0, "seed": [69, 68]}},
{"name": "Torso.CollarU", "mat": "olive_light", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.0636, 3.5, 6.0693942065828415], [0.53, 3.5, 6.007794206582841], [0.566, 3.14, 6.083710663170325], [0.06863999999999999, 3.08, 6.155219361779141]], "inside": [0.0, 3.305, 5.084938303341902], "lift": 0.17, "thick": 0.16, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "khaki", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 9.0, "seed": [86, 85]}},
{"name": "Torso.CollarF", "mat": "olive_light", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.53, 3.5, 6.007794206582841], [1.00125, 3.5, 5.212185089974293], [1.02375, 3.3, 5.255938303341902], [0.566, 3.14, 6.083710663170325]], "inside": [0.0, 3.36, 5.073938303341902], "lift": 0.16, "thick": 0.16, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "khaki", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 9.0, "seed": [103, 102]}},
{"name": "Torso.Cheek", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.5910599999999999, 3.08, 6.0618721194416505], [1.01152, 3.24, 5.29989720287198], [1.0611000000000002, 2.5, 5.445415433520716], [0.9396, 2.32, 5.664961644345172], [0.6307200000000001, 2.32, 6.133612994552364]], "inside": [0.0, 2.692, 5.207538303341902], "lift": 0.11, "thick": 0.13, "taper": 0.035, "back": 0.94, "gap": 0.025}, "fits": [{"kind": "mark", "id": "27", "at": [0.006142872851341963, 0.0045098247937858105], "height": 0.5}]},
{"name": "Torso.CheekDeck", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.06911999999999999, 3.04, 6.1615584474346505], [0.56448, 3.04, 6.1013584474346505], [0.6076, 2.0, 6.175354661707495], [0.0744, 2.0, 6.235554661707495]], "inside": [0.0, 2.52, 5.241938303341902], "lift": 0.07, "thick": 0.1, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "olive_light", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 0.9, "seed": [137, 136]}},
{"name": "Torso.Gill", "mat": "gunmetal", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.63168, 2.28, 6.135409293752973], [1.06132, 2.28, 5.488082927942363], [1.06038, 1.98, 5.5440385341450344], [0.6378699999999999, 1.98, 6.148364408169792]], "inside": [0.0, 2.13, 5.319938303341901], "lift": 0.05, "thick": 0.09, "taper": 0.035, "back": 0.94, "gap": 0.025}},
{"name": "Torso.Shoulder", "mat": "olive_light", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.63681, 1.94, 6.149855403487022], [1.0762500000000002, 1.94, 5.524430162810625], [0.9305714285714286, 0.62, 5.77571206803326], [0.5378933333333333, 0.42, 6.1004641922008265]], "inside": [0.0, 1.23, 5.472763496143958], "lift": 0.2, "thick": 0.16, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "khaki", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 0.7, "seed": [171, 170]}},
{"name": "Torso.ShoulderDeck", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.07428, 1.96, 6.236924230634243], [0.6066199999999999, 1.96, 6.176724230634243], [0.51744, 0.44, 6.119364493385301], [0.06336, 0.44, 6.179564493385301]], "inside": [0.0, 1.2, 5.477763496143958], "lift": 0.09, "thick": 0.1, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "olive_light", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 0.6, "seed": [188, 187]}},
{"name": "Torso.Belt1", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[1.0571000000000002, 3.0, 5.299138303341902], [1.04525, 3.02, 4.891938303341902], [1.07, 2.36, 5.023938303341902], [1.0796000000000001, 2.36, 5.427138303341902]], "inside": [0.0, 2.685, 5.208938303341902], "lift": 0.07, "thick": 0.11, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "olive_light", "min_area": 0.12, "lifts": [0.035, 0.035], "inset": 0.07, "gap": 0.04, "split": 99.0, "seed": [205, 204]}},
{"name": "Torso.Belt2", "mat": "olive_light", "bevel": 0.012, "sides": "both", "slab": {"corners": [[1.0796000000000001, 2.33, 5.433138303341901], [1.07, 2.33, 5.029938303341901], [1.03875, 1.5, 5.1777634961439585], [1.0483500000000001, 1.5, 5.5809634961439585]], "inside": [0.0, 1.915, 5.358596829477292], "lift": 0.11, "thick": 0.12, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "khaki", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 9.0, "seed": [222, 221]}},
{"name": "Torso.Belt3", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[1.046475, 1.47, 5.585963496143958], [1.036875, 1.47, 5.182763496143958], [0.9480000000000001, 0.78, 5.326616966580977], [0.9301714285714286, 0.62, 5.759668263975169]], "inside": [0.0, 1.085, 5.496930162810625], "lift": 0.08, "thick": 0.11, "taper": 0.035, "back": 0.94, "gap": 0.025}},
{"name": "Torso.Lip1", "mat": "gunmetal", "bevel": 0.012, "sides": "both", "slab": {"corners": [[1.0070000000000001, 3.36, 4.823938303341902], [0.632, 3.36, 4.663938303341902], [0.66, 2.4, 4.855938303341902], [1.07, 2.4, 5.015938303341902]], "inside": [0.0, 2.88, 5.169938303341902], "lift": 0.03, "thick": 0.08, "taper": 0.035, "back": 0.94, "gap": 0.025}},
{"name": "Torso.Lip2", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[1.07, 2.36, 5.023938303341902], [0.66, 2.36, 4.863938303341902], [0.625, 1.3, 5.0510968294772915], [1.02625, 1.3, 5.211096829477292]], "inside": [0.0, 1.83, 5.372763496143959], "lift": 0.05, "thick": 0.08, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "olive_light", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 9.0, "seed": [273, 272]}},
{"name": "Torso.Lip3", "mat": "gunmetal", "bevel": 0.012, "sides": "both", "slab": {"corners": [[1.02375, 1.26, 5.2177634961439585], [0.623, 1.26, 5.057763496143958], [0.56, 0.5, 5.250616966580976], [0.9, 0.5, 5.410616966580976]], "inside": [0.0, 0.88, 5.546616966580976], "lift": 0.03, "thick": 0.08, "taper": 0.035, "back": 0.94, "gap": 0.025}},
{"name": "Torso.Hood1D", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.0624, 0.4, 6.169880489976104], [0.52, 0.4, 6.108280489976104], [0.364, -0.66, 6.250353133913001], [0.04368, -0.66, 6.3119531339130015]], "inside": [0.0, -0.13, 5.896217574199579], "lift": 0.14, "thick": 0.11, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "olive_light", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 9.0, "seed": [307, 306]}},
{"name": "Torso.Hood1F", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.5601485714285714, 0.56, 6.135829871438327], [0.9411428571428572, 0.74, 5.338616966580977], [0.6, -0.1, 5.633944846926852], [0.488, -0.66, 5.797178285195826], [0.36976, -0.66, 6.24185255718071]], "inside": [0.0, -0.024000000000000004, 5.852853937835943], "lift": 0.13, "thick": 0.12, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "olive_light", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 0.5, "seed": [324, 323]}},
{"name": "Torso.Hood2D", "mat": "olive_light", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.044399999999999995, -0.6, 6.311459761576258], [0.37, -0.6, 6.249859761576258], [0.32, -1.5, 6.226910880175944], [0.0384, -1.5, 6.288510880175944]], "inside": [0.0, -1.05, 6.070119461666414], "lift": 0.1, "thick": 0.1, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "khaki", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 9.0, "seed": [341, 340]}},
{"name": "Torso.Hood2F", "mat": "olive_light", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.37392, -0.62, 6.242114324404738], [0.496, -0.62, 5.794825344019356], [0.41, -1.5, 5.8465900499017085], [0.3244, -1.5, 6.21998395024202]], "inside": [0.0, -1.06, 6.070707696960532], "lift": 0.09, "thick": 0.11, "taper": 0.035, "back": 0.94, "gap": 0.025}},
{"name": "Torso.Hood3D", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.03864, -1.46, 6.292862675791256], [0.322, -1.46, 6.231262675791256], [0.26, -2.3, 6.16377625008143], [0.0312, -2.3, 6.22537625008143]], "inside": [0.0, -1.88, 6.152707433134606], "lift": 0.06, "thick": 0.09, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "olive_light", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 9.0, "seed": [375, 374]}},
{"name": "Torso.Hood3F", "mat": "khaki", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.32646000000000003, -1.46, 6.22419092354263], [0.4135, -1.46, 5.844237108725237], [0.32, -2.3, 5.992069135262265], [0.2632, -2.3, 6.161355376401335]], "inside": [0.0, -1.88, 6.152707433134606], "lift": 0.05, "thick": 0.1, "taper": 0.035, "back": 0.94, "gap": 0.025}, "clad": {"mat": "olive_light", "min_area": 0.12, "lifts": [0.035, 0.06], "inset": 0.07, "gap": 0.04, "split": 9.0, "seed": [392, 391]}},
{"name": "Torso.HoodLip", "mat": "gunmetal", "bevel": 0.012, "sides": "both", "slab": {"corners": [[0.85, 0.4, 5.4406169665809765], [0.5366666666666667, 0.4, 5.280616966580976], [0.24749999999999997, -2.2, 5.810792539517585], [0.33124999999999993, -2.2, 5.970792539517585]], "inside": [0.0, -0.9000000000000001, 6.061295932254649], "lift": 0.03, "thick": 0.07, "taper": 0.035, "back": 0.94, "gap": 0.025}}
]},
"cases": [
{"side": 1, "truth": {
"Torso.Jaw1.R": {"solid":[[0.6781577,4.8458824,4.7452664],[0.668655,4.8445058,4.4767356],[0.3750727,5.4858899,4.2300553],[0.3787763,5.4840679,4.3069553],[0.6626044,4.800034,4.8098192],[0.6499786,4.7982044,4.4530377],[0.3264895,5.5049257,4.1812291],[0.3335624,5.5014462,4.3280835],[0.5565017,4.7785773,4.7914252],[0.5446335,4.7768579,4.4560513],[0.2405537,5.4411759,4.200551],[0.2472022,5.4379053,4.338594]],"facets":10,"panels":[],"bolts":0},
"Torso.Jaw1.L": {"solid":[[-0.3787763,5.4840679,4.3069553],[-0.3750727,5.4858899,4.2300553],[-0.668655,4.8445058,4.4767356],[-0.6781577,4.8458824,4.7452664],[-0.3335624,5.5014462,4.3280835],[-0.3264895,5.5049257,4.1812291],[-0.6499786,4.7982044,4.4530377],[-0.6626044,4.800034,4.8098187],[-0.2472022,5.4379053,4.338594],[-0.2405537,5.4411759,4.200551],[-0.5446335,4.7768579,4.4560513],[-0.5565017,4.7785773,4.7914252]],"facets":10,"panels":[],"bolts":0},
"Torso.Jaw2.R": {"solid":[[0.9634969,4.0501137,5.0842671],[0.9793593,4.0470967,4.7224078],[0.7621094,4.706634,4.5318127],[0.7502888,4.7032971,4.8479657],[0.9395706,4.0060921,5.1315699],[0.9587276,4.0024481,4.6945519],[0.7194206,4.7289476,4.4846058],[0.7049535,4.7248635,4.8715405],[0.8148237,3.9873223,5.106564],[0.8328313,3.9838972,4.6957669],[0.6078827,4.6668067,4.4984179],[0.5942836,4.6629677,4.8621368]],"facets":10,"panels":[[0.7623737,4.6329627,4.6227379],[0.755846,4.6311202,4.7973275],[0.9262363,4.1091132,4.9861736],[0.9355094,4.1073494,4.7746315],[0.7954733,4.644258,4.624095],[0.7889456,4.642415,4.7986841],[0.9593359,4.1204081,4.9875302],[0.968609,4.1186442,4.7759881],[0.8198669,4.6315074,4.6510701],[0.8148514,4.6300917,4.785213],[0.9730081,4.1455636,4.9605002],[0.9803985,4.1441579,4.7919059]],"bolts":4},
"Torso.Jaw2.L": {"solid":[[-0.7502887,4.7032971,4.8479657],[-0.7621094,4.706634,4.5318127],[-0.9793593,4.0470967,4.7224078],[-0.9634969,4.0501137,5.0842671],[-0.7049535,4.7248635,4.8715405],[-0.7194206,4.7289476,4.4846058],[-0.9587276,4.0024481,4.6945519],[-0.9395706,4.0060921,5.1315699],[-0.5942836,4.6629682,4.8621368],[-0.6078827,4.6668067,4.4984179],[-0.8328313,3.9838972,4.6957669],[-0.8148237,3.9873223,5.106564]],"facets":10,"panels":[[-0.9262362,4.1091132,4.9861732],[-0.7558458,4.6311202,4.797327],[-0.7623736,4.6329632,4.6227379],[-0.9355093,4.1073499,4.774631],[-0.9829783,4.1284761,4.9884992],[-0.812588,4.6504831,4.7996531],[-0.8191157,4.6523261,4.6250639],[-0.9922515,4.1267123,4.776957],[-0.9966506,4.1536317,4.9614692],[-0.8384938,4.6381598,4.7861819],[-0.8435093,4.6395755,4.6520391],[-1.004041,4.152226,4.7928748]],"bolts":4},
"Torso.Jaw3.R": {"solid":[[1.1034771,3.2995813,5.2017331],[1.1353582,3.1601076,4.9280725],[0.9894645,3.8798358,4.7565813],[0.984347,3.8839259,5.1203036],[1.0727185,3.273221,5.2393327],[1.1118007,3.1022437,4.9038582],[0.9487557,3.9065831,4.7122068],[0.9425905,3.9115105,5.1503859],[0.9666496,3.2685959,5.2238503],[1.0033869,3.107877,4.908504],[0.8501246,3.8639562,4.7283521],[0.8443294,3.868588,5.1402402]],"facets":10,"panels":[[0.9797079,3.8106408,5.0591025],[1.0768427,3.3341856,5.1254978],[1.0943214,3.2577195,4.9754639],[0.9827303,3.8082252,4.8442941],[1.0139892,3.8176858,5.0595059],[1.1111239,3.3412309,5.1259007],[1.1286026,3.2647648,4.9758673],[1.0170115,3.8152704,4.844697],[1.03785,3.8019233,5.042316],[1.1287004,3.3562937,5.1044154],[1.1420641,3.2978299,4.9897037],[1.0402737,3.7999861,4.8700538]],"bolts":4},
"Torso.Jaw3.L": {"solid":[[-0.984347,3.8839259,5.1203036],[-0.9894645,3.8798358,4.7565813],[-1.1353582,3.1601076,4.9280725],[-1.1034771,3.2995813,5.2017331],[-0.9425905,3.9115105,5.1503859],[-0.9487557,3.9065831,4.7122068],[-1.1118007,3.1022437,4.9038582],[-1.0727185,3.273221,5.2393327],[-0.8443294,3.868588,5.1402402],[-0.8501246,3.8639562,4.7283521],[-1.0033869,3.107877,4.908504],[-0.9666496,3.2685959,5.2238503]],"facets":10,"panels":[[-1.0943214,3.2577195,4.9754634],[-1.0768428,3.3341856,5.1254973],[-0.979708,3.8106406,5.0591021],[-0.9827303,3.8082252,4.8442936],[-1.1286026,3.2647645,4.9758668],[-1.111124,3.3412306,5.1259003],[-1.0139892,3.8176858,5.0595055],[-1.0170116,3.8152702,4.8446965],[-1.1420641,3.2978299,4.9897032],[-1.1287004,3.3562937,5.1044149],[-1.03785,3.801923,5.0423155],[-1.0402738,3.7999861,4.8700533]],"bolts":4},
"Torso.JawLip1.R": {"solid":[[0.6458802,4.5582738,4.4395108],[0.5161161,4.5574179,4.3403563],[0.2400006,5.3381481,4.0823326],[0.2889529,5.3373065,4.1198077],[0.6731222,4.5253091,4.5064259],[0.4764318,4.5240121,4.3561325],[0.1752755,5.375546,4.0747085],[0.2844312,5.3736696,4.1582718],[0.6295741,4.5529151,4.528182],[0.4446852,4.5516958,4.3869061],[0.1615982,5.352138,4.1223679],[0.2642045,5.3503742,4.2009172]],"facets":10,"panels":[],"bolts":0},
"Torso.JawLip1.L": {"solid":[[-0.2889529,5.3373065,4.1198077],[-0.2400006,5.3381481,4.0823326],[-0.5161161,4.5574179,4.3403563],[-0.6458802,4.5582738,4.4395108],[-0.2844312,5.3736696,4.1582718],[-0.1752755,5.375546,4.0747085],[-0.4764318,4.5240121,4.3561325],[-0.6731222,4.5253091,4.5064259],[-0.2642045,5.3503742,4.2009172],[-0.1615982,5.352138,4.1223679],[-0.4446852,4.5516958,4.3869061],[-0.6295741,4.5529151,4.528182]],"facets":10,"panels":[],"bolts":0},
"Torso.JawLip2.R": {"solid":[[0.9485517,3.4529181,4.7355824],[0.7014969,3.4510305,4.6154981],[0.5440177,4.3942752,4.3846078],[0.7175547,4.3920512,4.4695377],[0.9750648,3.4237115,4.7926283],[0.6596735,3.4213021,4.639328],[0.4905131,4.4345131,4.3913107],[0.7271858,4.4314795,4.5071402],[0.9398439,3.4604948,4.8200493],[0.6433761,3.4582298,4.6759472],[0.4843653,4.4106483,4.442811],[0.7068377,4.4077964,4.5516906]],"facets":10,"panels":[[0.6592853,4.3262753,4.4743786],[0.8565182,3.5244124,4.7015362],[0.7461367,3.5235691,4.6478839],[0.6120198,4.3268809,4.4512467],[0.6852901,4.3175545,4.4210148],[0.882523,3.5156915,4.6481724],[0.7721415,3.5148482,4.5945201],[0.6380246,4.3181601,4.3978829],[0.6797866,4.2950239,4.399528],[0.8673726,3.5323808,4.6155748],[0.7960405,3.5318358,4.5809031],[0.6685987,4.295167,4.3940525]],"bolts":4},
"Torso.JawLip2.L": {"solid":[[-0.7175547,4.3920512,4.4695377],[-0.5440177,4.3942752,4.3846078],[-0.7014969,3.4510307,4.6154981],[-0.9485517,3.4529181,4.7355824],[-0.7271858,4.4314795,4.5071402],[-0.4905131,4.4345131,4.3913107],[-0.6596735,3.4213021,4.639328],[-0.9750648,3.4237115,4.7926283],[-0.7068377,4.4077964,4.5516906],[-0.4843653,4.4106483,4.442811],[-0.6433761,3.4582298,4.6759472],[-0.9398439,3.4604948,4.8200493]],"facets":10,"panels":[[-0.6592851,4.3262753,4.4743786],[-0.6120197,4.3268809,4.4512467],[-0.7461365,3.5235691,4.6478839],[-0.8565181,3.5244124,4.7015362],[-0.6852899,4.3175545,4.4210148],[-0.6380244,4.3181601,4.3978829],[-0.7721414,3.5148482,4.5945201],[-0.8825229,3.5156915,4.6481724],[-0.6797863,4.2950234,4.399528],[-0.6685985,4.295167,4.3940525],[-0.7960405,3.5318358,4.5809031],[-0.8673725,3.5323808,4.6155748]],"bolts":4},
"Torso.CollarU.R": {"solid":[[0.1480696,3.1818228,6.300221],[0.5215798,3.2264247,6.2441702],[0.4968882,3.4767935,6.1938457],[0.1442731,3.4762638,6.2378926],[0.1096004,3.1358895,6.278759],[0.5551332,3.1890917,6.2119007],[0.5240929,3.5038362,6.1486363],[0.1048643,3.5032063,6.2010045],[0.1073099,3.1218333,6.1532855],[0.5261107,3.1718433,6.0904384],[0.4969327,3.4677031,6.0309701],[0.1028579,3.4671111,6.0801959]],"facets":10,"panels":[],"bolts":0},
"Torso.CollarU.L": {"solid":[[-0.1442731,3.4762638,6.2378926],[-0.4968882,3.4767935,6.1938457],[-0.5215798,3.2264247,6.2441702],[-0.1480696,3.1818228,6.300221],[-0.1048643,3.5032063,6.2010045],[-0.5240929,3.5038362,6.1486363],[-0.5551332,3.1890917,6.2119007],[-0.1096004,3.1358895,6.278759],[-0.1028579,3.4671111,6.0801959],[-0.4969327,3.4677031,6.0309701],[-0.5261107,3.1718433,6.0904384],[-0.1073099,3.1218333,6.1532855]],"facets":10,"panels":[],"bolts":0},
"Torso.CollarF.R": {"solid":[[0.72499,3.2426014,6.0970759],[1.1215882,3.3813784,5.3768516],[1.1122297,3.4722867,5.3575101],[0.701372,3.4719968,6.048275],[0.6817346,3.1941087,6.1187196],[1.1131568,3.3450711,5.3352547],[1.0972214,3.4998662,5.302321],[0.650287,3.4995508,6.0537405],[0.5885689,3.1813512,6.0310478],[0.9941058,3.3232558,5.294591],[0.9791265,3.4687634,5.2636328],[0.5590081,3.4684668,5.9699674]],"facets":10,"panels":[],"bolts":0},
"Torso.CollarF.L": {"solid":[[-0.701372,3.4719968,6.048275],[-1.1122297,3.4722867,5.3575101],[-1.1215882,3.3813784,5.3768516],[-0.72499,3.2426014,6.0970759],[-0.650287,3.4995508,6.0537405],[-1.0972214,3.4998662,5.302321],[-1.1131568,3.3450711,5.3352547],[-0.6817346,3.1941087,6.1187196],[-0.5590081,3.4684668,5.9699674],[-0.9791265,3.4687634,5.2636328],[-0.9941058,3.3232558,5.294591],[-0.5885689,3.1813512,6.0310478]],"facets":10,"panels":[],"bolts":0},
"Torso.Cheek.R": {"solid":[[0.7616042,2.3949468,6.1404848],[1.0143056,2.3933237,5.734005],[1.1105072,2.5457008,5.542192],[1.085451,3.1817539,5.4284258],[0.7093408,3.0426319,6.0677066],[0.7164118,2.3559163,6.155828],[0.9945078,2.3541298,5.7084999],[1.1004012,2.5218582,5.4973631],[1.0728861,3.2203295,5.3724322],[0.6590133,3.0672393,6.0758991],[0.6478956,2.3647487,6.0824809],[0.9093057,2.3630698,5.6619925],[1.0088454,2.5207343,5.4635239],[0.9829814,3.1772974,5.3460889],[0.593941,3.0333924,6.0073476]],"facets":12,"panels":[],"bolts":0},
"Torso.Cheek.L": {"solid":[[-0.7093408,3.0426319,6.0677066],[-1.085451,3.1817539,5.4284258],[-1.1105072,2.5457008,5.542192],[-1.0143056,2.3933237,5.734005],[-0.7616042,2.3949468,6.1404848],[-0.6590133,3.0672393,6.0758991],[-1.0728861,3.2203295,5.3724322],[-1.1004012,2.5218582,5.4973631],[-0.9945078,2.3541298,5.7084999],[-0.7164119,2.3559163,6.155828],[-0.5939409,3.0333924,6.0073476],[-0.9829814,3.1772974,5.3460889],[-1.0088454,2.5207343,5.4635239],[-0.9093057,2.3630698,5.6619925],[-0.6478956,2.364749,6.0824809]],"facets":12,"panels":[],"bolts":0},
"Torso.CheekDeck.R": {"solid":[[0.1419043,2.0650213,6.2945924],[0.5534907,2.0649021,6.2464862],[0.515558,2.9853468,6.1829267],[0.1370073,2.98522,6.2271891],[0.1032736,2.027564,6.266542],[0.5856587,2.0274243,6.2101612],[0.5448481,3.0177033,6.1417794],[0.0980052,3.0175533,6.1940269],[0.109527,2.0525076,6.19835],[0.562969,2.0523763,6.1453519],[0.5246071,2.9832382,6.0810733],[0.1045747,2.9830976,6.1301856]],"facets":10,"panels":[[0.4465562,2.9140482,6.1760697],[0.2045898,2.9139671,6.2043619],[0.208744,2.1333499,6.2615409],[0.4787329,2.1332717,6.2299848],[0.4506091,2.9166093,6.2107396],[0.2086427,2.9165282,6.2390318],[0.212797,2.135911,6.2962108],[0.4827859,2.1358328,6.2646546],[0.433872,2.8981199,6.2342525],[0.2309297,2.898052,6.2579818],[0.2348717,2.157315,6.3122396],[0.4644041,2.1572485,6.2854118]],"bolts":4},
"Torso.CheekDeck.L": {"solid":[[-0.1370073,2.98522,6.2271891],[-0.515558,2.9853468,6.1829267],[-0.5534908,2.0649021,6.2464862],[-0.1419043,2.0650213,6.2945924],[-0.0980052,3.0175533,6.1940269],[-0.5448481,3.0177033,6.1417794],[-0.5856587,2.0274243,6.2101612],[-0.1032736,2.027564,6.266542],[-0.1045747,2.9830976,6.1301856],[-0.5246071,2.9832382,6.0810733],[-0.5629691,2.0523763,6.1453519],[-0.109527,2.0525076,6.19835]],"facets":10,"panels":[[-0.4465562,2.9140482,6.1760697],[-0.4787329,2.1332717,6.2299848],[-0.2087439,2.1333499,6.2615409],[-0.2045898,2.9139671,6.2043619],[-0.4535041,2.9184387,6.2355042],[-0.4856809,2.1376622,6.2894192],[-0.2156919,2.1377404,6.3209753],[-0.2115377,2.9183576,6.2637963],[-0.4367669,2.8999493,6.259017],[-0.4672992,2.1590779,6.3101764],[-0.2377666,2.1591444,6.3370037],[-0.2338247,2.8998814,6.2827458]],"bolts":4},
"Torso.Gill.R": {"solid":[[0.7139895,2.0437119,6.1258149],[1.0652895,2.0431433,5.6095428],[1.0703707,2.2240007,5.5789557],[0.7057446,2.223469,6.1149549],[0.6670325,2.0063245,6.1372304],[1.0553687,2.0056958,5.5665302],[1.0624131,2.256434,5.5241241],[0.6555879,2.2558405,6.1221561],[0.6332603,2.0098648,6.0883889],[0.9982963,2.009274,5.5519304],[1.0049181,2.2449677,5.5120687],[0.6225024,2.24441,6.0742188]],"facets":10,"panels":[],"bolts":0},
"Torso.Gill.L": {"solid":[[-0.7057446,2.223469,6.1149549],[-1.0703707,2.2240007,5.5789557],[-1.0652895,2.0431433,5.6095428],[-0.7139896,2.0437119,6.1258149],[-0.6555879,2.2558405,6.1221561],[-1.0624131,2.256434,5.5241241],[-1.0553687,2.0056958,5.5665302],[-0.6670325,2.0063245,6.1372304],[-0.6225024,2.24441,6.0742188],[-1.0049181,2.2449677,5.5120687],[-0.9982963,2.009274,5.5519304],[-0.6332603,2.0098648,6.0883889]],"facets":10,"panels":[],"bolts":0},
"Torso.Shoulder.R": {"solid":[[0.766121,0.503258,6.2084999],[1.0149217,0.6597862,5.9122195],[1.2070429,1.8741268,5.7282615],[0.8078286,1.8753638,6.2140069],[0.7152762,0.4519182,6.2131157],[1.0066018,0.6351999,5.8661952],[1.208279,1.9099404,5.6730876],[0.7596377,1.9113306,6.2189732],[0.631173,0.5016816,6.120554],[0.905019,0.6739665,5.7944489],[1.0945956,1.8722225,5.6129274],[0.6728727,1.8735293,6.12606]],"facets":10,"panels":[[0.9620576,0.7113007,5.9471393],[1.1350672,1.8048418,5.7814813],[0.8347065,1.8057724,6.1469455],[0.7983067,0.6082799,6.1421394],[1.0083938,0.7097393,5.9852252],[1.1814033,1.8032804,5.8195667],[0.8810427,1.804211,6.1850314],[0.8446428,0.6067187,6.1802254],[1.013148,0.7237886,6.0115247],[1.180697,1.7828155,5.8510952],[0.9085804,1.7836586,6.1821938],[0.873697,0.6360558,6.177588]],"bolts":4},
"Torso.Shoulder.L": {"solid":[[-0.8078286,1.8753638,6.2140069],[-1.2070429,1.8741268,5.7282615],[-1.0149217,0.6597862,5.9122195],[-0.766121,0.503258,6.2084999],[-0.7596377,1.9113306,6.2189732],[-1.208279,1.9099404,5.6730876],[-1.0066018,0.6351999,5.8661952],[-0.7152762,0.4519182,6.2131157],[-0.6728727,1.8735293,6.12606],[-1.0945956,1.8722225,5.6129274],[-0.905019,0.6739665,5.7944489],[-0.631173,0.5016816,6.120554]],"facets":10,"panels":[[-0.9620576,0.7113007,5.9471393],[-0.7983067,0.6082799,6.1421394],[-0.8347066,1.8057724,6.1469455],[-1.1350672,1.8048418,5.7814813],[-1.0083938,0.7097393,5.9852252],[-0.8446428,0.6067187,6.1802254],[-0.8810427,1.804211,6.1850314],[-1.1814033,1.8032804,5.8195667],[-1.013148,0.7237886,6.0115247],[-0.873697,0.6360558,6.177588],[-0.9085804,1.7836586,6.1821938],[-1.180697,1.7828155,5.8510952]],"bolts":4},
"Torso.ShoulderDeck.R": {"solid":[[0.1338997,0.4963008,6.2615356],[0.4724211,0.4961444,6.2204647],[0.554043,1.8963948,6.2689981],[0.1444805,1.8962564,6.3186746],[0.094679,0.4627956,6.2296085],[0.5009658,0.4626078,6.180316],[0.5866662,1.9328259,6.2312741],[0.1057881,1.9326636,6.2896004],[0.100499,0.5095817,6.1653223],[0.4824086,0.5094053,6.1189871],[0.562967,1.8914104,6.1668882],[0.1109416,1.8912575,6.221715]],"facets":10,"panels":[[0.4045028,0.5669425,6.2114944],[0.4779677,1.8272576,6.2551775],[0.2110364,1.8271676,6.2875538],[0.2015125,0.5670362,6.2361221],[0.4117219,0.564459,6.2710066],[0.4851868,1.8247741,6.3146901],[0.2182556,1.824684,6.3470664],[0.2087317,0.5645527,6.2956343],[0.3954107,0.5836226,6.2939491],[0.466545,1.8039564,6.3362465],[0.2403655,1.80388,6.3636799],[0.2311435,0.5836985,6.3138785]],"bolts":4},
"Torso.ShoulderDeck.L": {"solid":[[-0.1444805,1.8962564,6.3186746],[-0.5540429,1.8963948,6.2689981],[-0.4724211,0.4961443,6.2204647],[-0.1338998,0.4963008,6.2615356],[-0.1057881,1.9326636,6.2896004],[-0.5866662,1.9328259,6.2312741],[-0.5009658,0.4626078,6.180316],[-0.094679,0.4627956,6.2296085],[-0.1109416,1.8912575,6.221715],[-0.562967,1.8914104,6.1668882],[-0.4824086,0.5094053,6.1189871],[-0.100499,0.5095817,6.1653223]],"facets":10,"panels":[[-0.4045027,0.5669426,6.211494],[-0.2015124,0.5670363,6.2361217],[-0.2110364,1.8271676,6.2875533],[-0.4779676,1.8272578,6.255177],[-0.4087139,0.5654938,6.2462096],[-0.2057236,0.5655876,6.2708373],[-0.2152475,1.8257189,6.322269],[-0.4821788,1.825809,6.2898927],[-0.3924026,0.5846575,6.2691517],[-0.2281355,0.5847334,6.2890816],[-0.2373575,1.8049148,6.3388824],[-0.4635369,1.8049912,6.3114491]],"bolts":4},
"Torso.Belt1.R": {"solid":[[1.146176,2.4221623,5.3521624],[1.1389598,2.4221458,5.071332],[1.1194549,2.9585156,4.964046],[1.1271794,2.9445682,5.2476935],[1.1133937,2.38609,5.3957429],[1.1043435,2.3860693,5.0435414],[1.0822154,2.9945703,4.9218278],[1.0919032,2.9770784,5.2775593],[1.0375291,2.4017417,5.3835039],[1.029022,2.4017222,5.0524349],[1.0082216,2.9737132,4.938024],[1.0173281,2.9572709,5.2724113]],"facets":10,"panels":[[1.104007,2.8835981,5.0507927],[1.1078055,2.8767397,5.1902728],[1.1218143,2.4914992,5.267312],[1.1182659,2.4914911,5.1292229],[1.1389785,2.88469,5.0498943],[1.1427768,2.8778317,5.189374],[1.1567856,2.4925911,5.2664132],[1.1532373,2.492583,5.1283245],[1.1602581,2.8640873,5.074019],[1.1629348,2.8592544,5.172308],[1.1755184,2.5132041,5.2415099],[1.1730181,2.5131984,5.1442046]],"bolts":4},
"Torso.Belt1.L": {"solid":[[-1.1271794,2.9445682,5.2476935],[-1.1194549,2.9585156,4.964046],[-1.1389598,2.4221458,5.071332],[-1.146176,2.4221623,5.3521624],[-1.0919032,2.9770784,5.2775593],[-1.0822154,2.9945703,4.9218278],[-1.1043435,2.3860693,5.0435414],[-1.1133937,2.38609,5.3957429],[-1.0173281,2.9572709,5.2724113],[-1.0082216,2.9737132,4.938024],[-1.029022,2.4017222,5.0524349],[-1.0375291,2.4017417,5.3835039]],"facets":10,"panels":[[-1.1040069,2.8835983,5.0507936],[-1.1182657,2.4914913,5.1292238],[-1.1218141,2.4914994,5.2673125],[-1.1078054,2.8767397,5.1902738],[-1.1389784,2.8846903,5.0498953],[-1.1532372,2.4925833,5.128325],[-1.1567855,2.4925914,5.2664137],[-1.1427768,2.8778317,5.1893749],[-1.1602579,2.8640876,5.0740199],[-1.173018,2.5131986,5.1442051],[-1.1755183,2.5132043,5.2415104],[-1.1629347,2.8592544,5.1723089]],"bolts":4},
"Torso.Belt2.R": {"solid":[[1.1590292,1.5553447,5.5067554],[1.15233,1.5553447,5.2253861],[1.1790659,2.2654498,5.0989141],[1.1857651,2.2654498,5.3802838],[1.1235993,1.5218399,5.5493498],[1.1152079,1.5218399,5.1969128],[1.144577,2.3018837,5.0579844],[1.1529684,2.3018837,5.4104218],[1.0393271,1.5487978,5.5366302],[1.0314392,1.5487978,5.2053394],[1.0590461,2.2820389,5.0747471],[1.0669341,2.2820389,5.4060378]],"facets":10,"panels":[[1.161463,2.1963477,5.3221474],[1.1399935,1.62612,5.4237065],[1.1366785,1.6261201,5.2844734],[1.1581479,2.1963477,5.1829138],[1.2213935,2.1938372,5.3207207],[1.199924,1.6236094,5.4222798],[1.196609,1.6236095,5.2830462],[1.2180784,2.1938372,5.1814871],[1.2401345,2.1730177,5.3034987],[1.2201698,1.642755,5.3979402],[1.2178216,1.6427552,5.2993169],[1.2377863,2.1730177,5.2048755]],"bolts":4},
"Torso.Belt2.L": {"solid":[[-1.1857651,2.2654498,5.3802838],[-1.1790659,2.2654498,5.0989141],[-1.15233,1.5553447,5.2253861],[-1.1590292,1.5553447,5.5067554],[-1.1529684,2.3018837,5.4104218],[-1.144577,2.3018837,5.0579844],[-1.1152079,1.5218399,5.1969128],[-1.1235993,1.5218399,5.5493498],[-1.0669341,2.2820389,5.4060383],[-1.0590461,2.2820389,5.0747471],[-1.0314392,1.5487978,5.2053394],[-1.0393271,1.5487978,5.5366302]],"facets":10,"panels":[[-1.1366785,1.62612,5.2844734],[-1.1399935,1.62612,5.4237065],[-1.161463,2.1963477,5.3221474],[-1.1581479,2.1963477,5.1829138],[-1.1716379,1.6246555,5.2836409],[-1.174953,1.6246555,5.422874],[-1.1964225,2.1948833,5.3213153],[-1.1931074,2.1948833,5.1820812],[-1.1928506,1.6438012,5.2999115],[-1.1951988,1.6438012,5.3985343],[-1.2151635,2.1740639,5.3040934],[-1.2128153,2.1740639,5.2054701]],"bolts":4},
"Torso.Belt3.R": {"solid":[[1.0221877,0.7020862,5.6781473],[1.0325204,0.81351,5.3773651],[1.1108152,1.3995476,5.2550621],[1.1154573,1.3998268,5.5356541],[0.9808402,0.6525131,5.7254996],[0.9938226,0.7925092,5.3475885],[1.0801847,1.4389318,5.2126832],[1.0860105,1.4392823,5.5648246],[0.9098068,0.6883913,5.7109475],[0.9220102,0.8199875,5.355711],[1.0031906,1.4276248,5.2289],[1.0086669,1.4279542,5.5599132]],"facets":10,"panels":[],"bolts":0},
"Torso.Belt3.L": {"solid":[[-1.1154573,1.3998268,5.5356541],[-1.1108152,1.3995476,5.2550621],[-1.0325204,0.81351,5.3773651],[-1.0221877,0.7020862,5.6781473],[-1.0860105,1.4392823,5.5648246],[-1.0801847,1.4389318,5.2126832],[-0.9938226,0.7925092,5.3475885],[-0.9808403,0.6525132,5.7254992],[-1.0086669,1.4279542,5.5599132],[-1.0031906,1.4276248,5.2289],[-0.9220102,0.8199875,5.355711],[-0.9098068,0.6883913,5.7109475]],"facets":10,"panels":[],"bolts":0},
"Torso.Lip1.R": {"solid":[[1.0201858,2.4545801,4.9563909],[0.7262938,2.4538357,4.8369279],[0.6996334,3.2962456,4.6738377],[0.9670646,3.2954555,4.7828097],[1.0420594,2.4259324,5.0087824],[0.6817942,2.4250197,4.8623395],[0.6529431,3.3366497,4.6858482],[0.9845879,3.33567,4.8209863],[1.0132276,2.4606547,5.0400338],[0.6745782,2.4597969,4.9023776],[0.6474582,3.3167291,4.7364755],[0.9592044,3.3158081,4.8635054]],"facets":10,"panels":[],"bolts":0},
"Torso.Lip1.L": {"solid":[[-0.9670646,3.2954555,4.7828097],[-0.6996334,3.2962456,4.6738377],[-0.7262938,2.4538357,4.8369279],[-1.0201858,2.4545801,4.9563909],[-0.9845879,3.33567,4.8209863],[-0.652943,3.3366497,4.6858482],[-0.6817942,2.4250197,4.8623395],[-1.0420594,2.4259324,5.0087824],[-0.9592044,3.3158081,4.8635054],[-0.6474582,3.3167291,4.7364755],[-0.6745782,2.4597969,4.9023776],[-1.0132276,2.4606547,5.0400338]],"facets":10,"panels":[],"bolts":0},
"Torso.Lip2.R": {"solid":[[0.9911727,1.3502163,5.1321969],[0.7006019,1.3504183,5.0175533],[0.7322098,2.2920723,4.8499608],[1.0295374,2.2922714,4.9671926],[1.0096952,1.3218635,5.1831384],[0.6542254,1.3221107,5.0428891],[0.6881451,2.3326383,4.8630385],[1.0508684,2.3328812,5.0060549],[0.9839019,1.360075,5.2147918],[0.6497603,1.3603073,5.0829573],[0.6816448,2.3102033,4.9138975],[1.0226047,2.3104317,5.0483332]],"facets":10,"panels":[[0.9216167,1.4226836,5.1127429],[0.7608439,1.4227954,5.0493107],[0.7878281,2.226702,4.9062343],[0.9543645,2.2268133,4.9718971],[0.9342599,1.416554,5.080687],[0.7734872,1.4166658,5.0172548],[0.8004714,2.2205722,4.8741784],[0.9670078,2.2206838,4.9398413],[0.9236757,1.4327556,5.0515776],[0.799988,1.4328415,5.0027776],[0.8256512,2.1973917,4.8667054],[0.9548187,2.1974781,4.917634]],"bolts":4},
"Torso.Lip2.L": {"solid":[[-1.0295374,2.2922711,4.9671926],[-0.7322098,2.2920723,4.8499608],[-0.7006019,1.3504183,5.0175533],[-0.9911727,1.3502163,5.1321969],[-1.0508684,2.3328812,5.0060549],[-0.6881451,2.3326383,4.8630385],[-0.6542254,1.3221107,5.0428891],[-1.0096952,1.3218635,5.1831384],[-1.0226047,2.3104315,5.0483332],[-0.6816448,2.3102033,4.9138975],[-0.6497603,1.3603073,5.0829573],[-0.9839019,1.360075,5.2147918]],"facets":10,"panels":[[-0.9216166,1.4226835,5.1127429],[-0.9543644,2.2268131,4.9718971],[-0.7878281,2.2267017,4.9062343],[-0.7608438,1.4227953,5.0493107],[-0.9432907,1.4121755,5.0577903],[-0.9760386,2.2163053,4.916944],[-0.8095022,2.2161939,4.8512812],[-0.7825179,1.4122874,4.9943581],[-0.9327064,1.4283772,5.0286808],[-0.9638494,2.1930995,4.8947372],[-0.834682,2.1930132,4.8438082],[-0.8090188,1.4284631,4.9798803]],"bolts":4},
"Torso.Lip3.R": {"solid":[[0.8676552,0.5484633,5.3409948],[0.629285,0.5507765,5.2378912],[0.6864839,1.1930634,5.0655351],[0.9688227,1.1951368,5.1861811],[0.8812362,0.5239664,5.3939147],[0.5808482,0.5268815,5.2639861],[0.6439989,1.2360016,5.0736952],[0.9930302,1.2385647,5.2228398],[0.8577532,0.5576117,5.4243941],[0.5753885,0.5603519,5.3022614],[0.6347501,1.2269248,5.1233878],[0.9628395,1.2293341,5.2635837]],"facets":10,"panels":[],"bolts":0},
"Torso.Lip3.L": {"solid":[[-0.9688227,1.1951368,5.1861811],[-0.6864839,1.1930634,5.0655351],[-0.629285,0.5507765,5.2378912],[-0.8676552,0.5484633,5.3409948],[-0.9930302,1.2385647,5.2228398],[-0.6439989,1.2360016,5.0736952],[-0.5808482,0.5268815,5.2639861],[-0.8812362,0.5239664,5.3939147],[-0.9628395,1.2293341,5.2635837],[-0.6347501,1.2269248,5.1233878],[-0.5753885,0.5603519,5.3022614],[-0.8577532,0.5576117,5.4243941]],"facets":10,"panels":[],"bolts":0},
"Torso.Hood1D.R": {"solid":[[0.12437,-0.5841965,6.4268317],[0.3345847,-0.5832529,6.3944097],[0.4716979,0.3567483,6.2592425],[0.1423651,0.3574846,6.3097682],[0.0838059,-0.6232779,6.4021449],[0.3593167,-0.6220412,6.3596516],[0.5065353,0.3872391,6.2145228],[0.1031336,0.388141,6.276412],[0.0832575,-0.6018638,6.3232055],[0.3422377,-0.6007013,6.2832618],[0.4806232,0.3480221,6.1468406],[0.1014256,0.3488699,6.2050166]],"facets":10,"panels":[[0.3884488,0.2850463,6.2603598],[0.2072538,0.2854514,6.2881584],[0.1919241,-0.5167541,6.3878837],[0.2715463,-0.5163967,6.3756032],[0.3974983,0.2921931,6.3192415],[0.2163033,0.2925983,6.3470402],[0.2009735,-0.5096073,6.4467649],[0.2805958,-0.5092499,6.4344845],[0.3775912,0.2747698,6.3447957],[0.2387213,0.2750803,6.3661008],[0.224153,-0.4872751,6.4608717],[0.2664632,-0.4870851,6.4543462]],"bolts":4},
"Torso.Hood1D.L": {"solid":[[-0.1423651,0.3574846,6.3097682],[-0.4716979,0.3567483,6.2592425],[-0.3345847,-0.5832529,6.3944097],[-0.12437,-0.5841965,6.4268317],[-0.1031336,0.388141,6.276412],[-0.5065353,0.3872391,6.2145228],[-0.3593167,-0.6220412,6.3596516],[-0.0838059,-0.6232779,6.4021449],[-0.1014256,0.3488699,6.2050166],[-0.4806232,0.3480221,6.1468406],[-0.3422377,-0.6007013,6.2832618],[-0.0832575,-0.6018638,6.3232055]],"facets":10,"panels":[[-0.1919241,-0.516754,6.3878837],[-0.2072538,0.2854515,6.2881584],[-0.3884487,0.2850464,6.2603598],[-0.2715462,-0.5163966,6.3756032],[-0.1972029,-0.512585,6.4222312],[-0.2125326,0.2896205,6.322506],[-0.3937276,0.2892154,6.2947073],[-0.2768251,-0.5122277,6.4099507],[-0.2203824,-0.4902529,6.4363379],[-0.2349506,0.2721025,6.341567],[-0.3738205,0.2717921,6.3202615],[-0.2626925,-0.490063,6.4298124]],"bolts":4},
"Torso.Hood1F.R": {"solid":[[0.4889922,-0.6167604,6.2126741],[0.6078163,-0.6218183,5.8866138],[0.9811482,0.6417188,5.4644799],[0.7089781,0.487129,6.133101],[0.4376203,-0.6451254,6.2363691],[0.5786441,-0.6511283,5.8493915],[0.9770675,0.6957217,5.3981285],[0.6700795,0.5213558,6.1522841],[0.3732574,-0.5951188,6.1853604],[0.5058198,-0.6007615,5.8216019],[0.8803378,0.6652775,5.3974147],[0.5917692,0.5013735,6.1063209]],"facets":11,"panels":[[0.6432545,0.1313842,6.0858674],[0.5083398,-0.5456179,6.1346684],[0.5838301,-0.5488312,5.9275188],[0.7427546,-0.0109527,5.7478194],[0.6988522,0.1217758,6.1062775],[0.5639374,-0.5552263,6.1550784],[0.6394277,-0.5584396,5.9479289],[0.7983524,-0.0205611,5.76823],[0.7187667,0.0906101,6.0961523],[0.5932928,-0.5390178,6.1415386],[0.6564021,-0.5417041,5.9683633],[0.8062518,-0.0345391,5.7989254],[0.7033786,0.4330879,6.0641189],[0.6795222,0.3133766,6.0727487],[0.7913266,0.1534384,5.6928978],[0.9083525,0.5495109,5.5605745],[0.7358106,0.427483,6.076025],[0.7119542,0.3077717,6.0846543],[0.8237587,0.1478335,5.7048035],[0.9407845,0.543906,5.5724802],[0.7580383,0.4079248,6.065063],[0.7399283,0.3170487,6.0716138],[0.8424519,0.1703869,5.7232943],[0.9438132,0.513443,5.6086831]],"bolts":8},
"Torso.Hood1F.L": {"solid":[[-0.7089781,0.487129,6.133101],[-0.9811482,0.6417188,5.4644799],[-0.6078163,-0.6218184,5.8866138],[-0.4889922,-0.6167604,6.2126741],[-0.6700795,0.5213558,6.1522841],[-0.9770675,0.6957217,5.3981285],[-0.5786441,-0.6511284,5.8493915],[-0.4376203,-0.6451254,6.2363691],[-0.5917692,0.5013735,6.1063209],[-0.8803378,0.6652775,5.3974147],[-0.5058198,-0.6007615,5.8216019],[-0.3732574,-0.5951188,6.1853604]],"facets":11,"panels":[[-0.7033787,0.4330879,6.0641189],[-0.9083524,0.5495109,5.5605745],[-0.7575487,0.0391177,5.7310915],[-0.654301,0.1868157,6.0818715],[-0.7589764,0.4234796,6.0845289],[-0.9639502,0.5399025,5.5809851],[-0.8131465,0.0295093,5.751502],[-0.7098987,0.1772073,6.1022816],[-0.7812041,0.4039214,6.0735674],[-0.9669788,0.5094395,5.617188],[-0.8318397,0.0520627,5.7699924],[-0.7378727,0.1864843,6.089241],[-0.7089766,-0.1252735,5.7860131],[-0.5838298,-0.5488313,5.9275193],[-0.5083395,-0.5456179,6.1346688],[-0.6180329,0.0048233,6.0949907],[-0.7414086,-0.1308784,5.7979188],[-0.6162618,-0.5544362,5.939425],[-0.5407715,-0.5512229,6.146575],[-0.6504649,-0.0007816,6.1068964],[-0.7493081,-0.1448564,5.8286147],[-0.6332361,-0.5377007,5.9598594],[-0.5701269,-0.5350143,6.1330347],[-0.6703794,-0.0319473,6.0967712]],"bolts":8},
"Torso.Hood2D.R": {"solid":[[0.1169894,-1.4431006,6.374145],[0.2846297,-1.4431865,6.3402987],[0.3272185,-0.6630456,6.3564939],[0.1229361,-0.6631249,6.3977323],[0.0754922,-1.4769762,6.3457222],[0.3101459,-1.4770966,6.2983465],[0.3565559,-0.6269588,6.3159947],[0.0819721,-0.6270654,6.3714247],[0.0704687,-1.4494553,6.2812676],[0.2910432,-1.4495684,6.2367344],[0.3346686,-0.6504388,6.2533236],[0.0765598,-0.650539,6.3054276]],"facets":10,"panels":[],"bolts":0},
"Torso.Hood2D.L": {"solid":[[-0.1229361,-0.6631249,6.3977323],[-0.3272185,-0.6630456,6.3564939],[-0.2846297,-1.4431865,6.3402987],[-0.1169894,-1.4431006,6.374145],[-0.0819721,-0.6270654,6.3714247],[-0.3565559,-0.6269588,6.3159947],[-0.3101459,-1.4770966,6.2983465],[-0.0754922,-1.4769762,6.3457222],[-0.0765598,-0.650539,6.3054276],[-0.3346686,-0.6504388,6.2533236],[-0.2910432,-1.4495684,6.2367344],[-0.0704687,-1.4494553,6.2812676]],"facets":10,"panels":[],"bolts":0},
"Torso.Hood2F.R": {"solid":[[0.4256355,-1.4462472,6.1845303],[0.4919126,-1.4467067,5.924593],[0.5590963,-0.6859823,5.8780618],[0.4755452,-0.6863772,6.2054691],[0.3808642,-1.4786416,6.2088552],[0.4636741,-1.4792155,5.8840771],[0.5370334,-0.6485647,5.8332686],[0.4353537,-0.6490453,6.2317157],[0.3127733,-1.4484841,6.1801996],[0.3906146,-1.4490235,5.874908],[0.4595724,-0.6682117,5.827148],[0.3639935,-0.6686635,6.2016883]],"facets":10,"panels":[],"bolts":0},
"Torso.Hood2F.L": {"solid":[[-0.4755452,-0.6863772,6.2054691],[-0.5590963,-0.6859823,5.8780618],[-0.4919126,-1.4467067,5.924593],[-0.4256355,-1.4462472,6.1845303],[-0.4353537,-0.6490453,6.2317157],[-0.5370334,-0.6485647,5.8332686],[-0.4636741,-1.4792155,5.8840771],[-0.3808642,-1.4786416,6.2088552],[-0.3639935,-0.6686635,6.2016883],[-0.4595724,-0.6682117,5.827148],[-0.3906146,-1.4490235,5.874908],[-0.3127733,-1.4484841,6.1801996]],"facets":10,"panels":[],"bolts":0},
"Torso.Hood3D.R": {"solid":[[0.1032437,-2.2453222,6.2714987],[0.2205016,-2.2456303,6.2435641],[0.2724218,-1.5248752,6.2962074],[0.1108723,-1.5251584,6.33463],[0.0607521,-2.277041,6.2426353],[0.244008,-2.2775223,6.1989779],[0.3009622,-1.4868872,6.2567248],[0.0691178,-1.4872937,6.3118663],[0.0545442,-2.2485428,6.1899295],[0.2268047,-2.2489953,6.1488914],[0.2803416,-1.5057983,6.2031736],[0.0624079,-1.5061804,6.2550068]],"facets":10,"panels":[],"bolts":0},
"Torso.Hood3D.L": {"solid":[[-0.1108722,-1.5251584,6.33463],[-0.2724218,-1.5248752,6.2962074],[-0.2205016,-2.2456303,6.2435641],[-0.1032437,-2.2453222,6.2714987],[-0.0691178,-1.4872937,6.3118663],[-0.3009622,-1.4868872,6.2567248],[-0.244008,-2.2775223,6.1989779],[-0.0607521,-2.277041,6.2426353],[-0.0624079,-1.5061804,6.2550068],[-0.2803416,-1.5057983,6.2031736],[-0.2268047,-2.2489953,6.1488914],[-0.0545442,-2.2485428,6.1899295]],"facets":10,"panels":[],"bolts":0},
"Torso.Hood3F.R": {"solid":[[0.3368095,-2.2442985,6.1210251],[0.3540591,-2.2438414,6.0513573],[0.4430484,-1.5238899,5.9266953],[0.3822896,-1.5235535,6.1727257],[0.2923129,-2.2766652,6.144166],[0.3244511,-2.2758133,6.0143657],[0.4220367,-1.4863158,5.8776622],[0.3422129,-1.4858738,6.2008915],[0.2325801,-2.2478509,6.1235294],[0.2627901,-2.24705,6.0015173],[0.3545205,-1.5049223,5.8730159],[0.2794862,-1.5045068,6.1768513]],"facets":10,"panels":[],"bolts":0},
"Torso.Hood3F.L": {"solid":[[-0.3822896,-1.5235535,6.1727257],[-0.4430485,-1.5238899,5.9266953],[-0.3540591,-2.2438414,6.0513573],[-0.3368095,-2.2442985,6.1210251],[-0.3422129,-1.4858738,6.2008915],[-0.4220367,-1.4863158,5.8776622],[-0.3244511,-2.2758133,6.0143661],[-0.2923129,-2.2766652,6.144166],[-0.2794861,-1.5045068,6.1768513],[-0.3545205,-1.5049223,5.8730159],[-0.2627901,-2.24705,6.0015173],[-0.2325801,-2.2478509,6.1235294]],"facets":10,"panels":[],"bolts":0},
"Torso.HoodLip.R": {"solid":[[0.3319675,-2.1517057,5.8672805],[0.2972293,-2.1460621,5.8425512],[0.6060616,0.3312727,5.2865472],[0.7946815,0.3373919,5.4095373],[0.3353004,-2.1816168,5.9219961],[0.2456244,-2.1670485,5.8581576],[0.5622626,0.3729025,5.2881007],[0.8116803,0.380994,5.4507341],[0.3257884,-2.0959625,5.932734],[0.241493,-2.0822682,5.872726],[0.5391329,0.3052856,5.3368726],[0.7735855,0.3128915,5.4897475]],"facets":10,"panels":[],"bolts":0},
"Torso.HoodLip.L": {"solid":[[-0.7946815,0.3373919,5.4095373],[-0.6060616,0.3312727,5.2865472],[-0.2972293,-2.1460621,5.8425512],[-0.3319675,-2.1517057,5.8672805],[-0.8116803,0.380994,5.4507341],[-0.5622626,0.3729025,5.2881007],[-0.2456244,-2.1670485,5.8581576],[-0.3353004,-2.1816168,5.9219961],[-0.7735855,0.3128915,5.4897475],[-0.5391329,0.3052856,5.3368726],[-0.241493,-2.0822682,5.872726],[-0.3257884,-2.0959625,5.932734]],"facets":10,"panels":[],"bolts":0}
}}
]}

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{"note":"RAPTOR (sheet 38): the hull plate that bears the 27, its four corners marked by eye in the hero (the right flank) and in the SIDE view (the left flank, so side -1), with the nose's front face and the two laser emitters. Coordinates are the hull's (raptor_form.SHEET at 3ced828: x right, y forward of the sheet's hip column, z up). side is raptor_form.SHEET.camera(), square-on at the sheet's 28.6 px a metre. world gives each mark's (y, z) off the SIDE view and its x from the hull's mass (the nose 0, the emitters +-0.56, a plate corner the flank's half-width at its station and height): hero is brokkr_reference.core.solve(world, pixels, box, model rolled, lens 50). The seven marks admit no camera under 21.8 px rms (left-out 44 px, lens not determined; 25.1 px at 50 mm): the sheet's two views do not draw one rigid hull, and four of the seven marks are the plate's own corners. What block_plate gives through these cameras is two views agreeing on a plate, not a measured accuracy: there is no truth for this plate.","cameras":{"hero":{"C":[11.303769012415719,10.50084330876064,1.6426541643628032],"R":[[-0.5899084170655855,0.7870428136060581,0.1804762284242304],[0.1745987487019839,-0.09389198835577137,0.9801528306719831],[0.7883675135537211,0.6097113284773865,-0.08202901620441301]],"f":944.4444444444445,"c":[400.0,320.0]},"side":{"C":[-400.0,0.0,0.0],"R":[[0.0,-1.0,0.0],[0.0,0.0,1.0],[-1.0,0.0,0.0]],"f":11441.176470588236,"c":[348.5,849.5]}},"box":[60,0,740,640],"world":{"nose":[0.0,5.681233933161954,4.038046272493573],"emitter_r":[0.56,4.96452442159383,3.7583547557840613],"emitter_l":[-0.56,4.96452442159383,3.7583547557840613],"p_ft":[0.6753672831185238,4.14293059125964,5.4365038560411305],"p_fb":[1.0477429305912596,4.317737789203084,4.632390745501285],"p_rb":[1.2748071979434448,3.0940874035989716,4.80719794344473],"p_rt":[1.282382176520994,3.0241645244215936,5.576349614395887]},"pixels":{"nose":[683,250],"emitter_r":[557,273],"emitter_l":[617,283],"p_ft":[500,120],"p_fb":[539,183],"p_rb":[461,184],"p_rt":[459,108]},"plate":{"corners":["p_ft","p_fb","p_rb","p_rt"]},"traces":[{"view":"hero","from":"p_ft","to":"p_fb","side":1,"line":[[500,120],[539,183]]},{"view":"side","from":"p_ft","to":"p_fb","side":-1,"line":[[230,694],[225,717]]},{"view":"hero","from":"p_fb","to":"p_rb","side":1,"line":[[539,183],[461,184]]},{"view":"side","from":"p_fb","to":"p_rb","side":-1,"line":[[225,717],[260,712]]},{"view":"hero","from":"p_rb","to":"p_rt","side":1,"line":[[461,184],[459,108]]},{"view":"side","from":"p_rb","to":"p_rt","side":-1,"line":[[260,712],[262,690]]},{"view":"hero","from":"p_rt","to":"p_ft","side":1,"line":[[459,108],[500,120]]},{"view":"side","from":"p_rt","to":"p_ft","side":-1,"line":[[262,690],[230,694]]}]}

View file

@ -0,0 +1 @@
{"note":"SPECTRE's roof and cheek as plates. Cameras: spectre_skel.cameras() at nibu/fable-spectre-2 74fc241, solved by this repo's brokkr_reference.core; frames: the hull pitched about the waist by spectre_skel.PITCH (hero 3 degrees, side 0). Traces marked hand are spectre_skel.TRACES (roof brow and ridge, cheek chine); a trace marked fitted-edge is the straight edge between two vertices of spectre_fits.json's fitted cage drawn through the camera, standing in for a side nobody traced, so the outline closes. reference is spectre_fits.json's fitted cage along the traced runs: a fit from a hand blocking, not ground truth.","cameras":{"hero":{"C":[-9.721115556958573,18.859090658741355,5.242272804029844],"R":[[-0.862189601405842,-0.5065857195259607,0.0],[0.034125232508362004,-0.05807984607580026,0.9977285201827507],[-0.5054350202883507,0.8602311551276064,0.06736319480204615]],"f":1785.0,"c":[378.0,353.0]},"side":{"C":[60.84416742645475,1.422308134553987,3.13474760877321],"R":[[3.061616997868383e-16,1.0,0.0],[0.011634411213376642,-3.5620111131064444e-18,0.9999323179474289],[0.9999323179474289,-3.0614097813457806e-16,-0.011634411213376642]],"f":2200.0,"c":[892.0,532.0]}},"frames":{"hero":[[1.0,0.0,0.0,0.0],[0.0,0.9986295347545738,0.052335956242943835,-0.2773805680876023],[0.0,-0.052335956242943835,0.9986295347545738,0.007263465800758873],[0.0,0.0,0.0,1.0]],"side":[[1.0,0.0,0.0,0.0],[0.0,1.0,0.0,0.0],[0.0,-0.0,1.0,0.0],[0.0,0.0,0.0,1.0]]},"plates":{"roof":{"plate":{"corners":["ridge_rear","nose","brow_rear"],"mirror":true,"seam":["ridge_rear","nose"]},"traces":[{"view":"side","from":"ridge_rear","to":"nose","side":1,"line":[[883,400],[898,408],[930,426],[958,441]],"source":"hand"},{"view":"hero","from":"brow_rear","to":"nose","side":-1,"line":[[487,47],[443,92],[427,126],[400,128],[360,135],[325,142]],"source":"hand"},{"view":"side","from":"brow_rear","to":"nose","side":1,"line":[[883,404],[900.7,413.6],[919,423.6],[938.6,436.4],[958.6,443]],"source":"hand"},{"view":"hero","from":"brow_rear","to":"ridge_rear","side":-1,"line":[[487.1,47.1],[424.7,35.3]],"source":"fitted-edge"},{"view":"side","from":"brow_rear","to":"ridge_rear","side":1,"line":[[883.0,404.1],[883.0,399.9]],"source":"fitted-edge"}],"reference":{"ridge":[[0.0,1.173941,7.498167],[0.0,2.063931,7.015758],[0.0,2.624251,6.687296],[0.0,3.079302,6.461668],[0.0,3.280227,6.334663]],"brow":[[0.776479,1.177565,7.327593],[0.653669,2.30313,6.743599],[0.929821,2.609515,6.428508],[0.197231,2.908778,6.436474],[0.0,3.280227,6.334663]]}},"cheek":{"plate":{"corners":["chine_rear","jaw","chin"],"mirror":true,"seam":["jaw","chin"]},"traces":[{"view":"hero","from":"chine_rear","to":"jaw","side":-1,"line":[[472,169],[438,180],[390,170],[312,182]],"source":"hand"},{"view":"side","from":"chine_rear","to":"jaw","side":1,"line":[[919,447],[945,456.5],[961,459]],"source":"hand"},{"view":"side","from":"jaw","to":"chin","side":1,"line":[[965.6,456.7],[957.7,463.1]],"source":"fitted-edge"},{"view":"hero","from":"chin","to":"chine_rear","side":-1,"line":[[331.3,199.5],[472.1,167.8]],"source":"fitted-edge"},{"view":"side","from":"chin","to":"chine_rear","side":1,"line":[[957.7,463.1],[921.1,451.0]],"source":"fitted-edge"}],"reference":{"chine":[[1.097992,2.211844,6.0315],[0.924701,2.658187,5.897007],[0.340462,2.978516,6.057156],[0.0,3.458134,5.926945]]}}}}

File diff suppressed because one or more lines are too long

View file

@ -1,17 +1,21 @@
"""Live proof, in a background Blender, that the brokkr_kitbash rows are admitted by Brokkr as host actions and that
the mechanical kit goes through run_intent: describe, place_part for all eleven parts, setObjectTransform,
assignMaterial, set_params, report, the refusals, and exportGltf. Not part of the unittest run: it needs Blender.
the mechanical kit goes through run_intent: describe, place_part for all thirteen parts, setObjectTransform,
assignMaterial, set_params, report, the refusals, the frame kit's nine parts (placed, a truss re-parameterised, a beam
seated on a mechanical bracket), and exportGltf. Not part of the unittest run: it needs Blender.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/kitbash.py -- <out>
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). Writes <out>.result.json and exits 1 when a check failed.
without them). Writes <out>.result.json and exits 1 when a check failed. The checks run inside one try: an uncaught error is a failed check that names
the check before it, the checks are printed and the result file written whatever happened, and the exit is 1 with or
without --python-exit-code.
"""
import importlib.util
import json
import math
import os
import sys
import traceback
import tempfile
import types
from pathlib import Path
@ -49,9 +53,17 @@ target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1],
"hostRows": [row["name"] for row in target.host_actions()[0]]}
COUNT = [0]
# the rows the add-on's action table names, in its order: what the host must load, whatever rows the table grows
TABLE = [row["name"] for row in json.loads((SURFACE / "brokkr_kitbash" / "brokkr_actions.json").read_text(encoding="utf-8"))["actions"]]
# the operators the add-on registered: each is an action the table must have a row for, so a row lost from the table is seen
OPERATORS = sorted(f"brokkr_kitbash.{name}" for name in dir(bpy.ops.brokkr_kitbash))
def check(name, ok, detail=None):
try:
json.dumps(detail, default=str)
except TypeError: # a detail keyed by tuples: the result file takes it as text, so a failed check is written and not a crash
detail = repr(detail)
R["checks"].append({"name": name, "ok": bool(ok), "detail": None if ok else detail}) # what was seen, when it was not what was promised
@ -73,188 +85,231 @@ def extent(obj, axis=2):
return float(co[:, axis].max() - co[:, axis].min())
check("the kitbash rows load as host actions with no errors", not R["hostErrors"]
and [r for r in R["hostRows"] if r.startswith("brokkr_kitbash.")] == [f"brokkr_kitbash.{name}" for name in (
"place_part", "set_params", "describe", "report", "attach", "detach", "close", "boolean", "cut", "cut_many", "apply")], [R["hostErrors"], R["hostRows"]])
try:
check("the kitbash rows load as host actions with no errors", not R["hostErrors"]
and [r for r in R["hostRows"] if r.startswith("brokkr_kitbash.")] == TABLE != [] and sorted(TABLE) == OPERATORS, [R["hostErrors"], R["hostRows"], OPERATORS])
# --- describe ---------------------------------------------------------------------------------------------------------
kit = core.load_kit("mechanical")
receipt, described = send("brokkr_kitbash.describe")
names = [p["name"] for p in described["parts"]] if described else []
check("describe lists eleven parts, whole, inside a receipt", receipt["status"] == "accepted" and names == list(kit["parts"]) and len(names) == 11
and "[truncated]" not in receipt["hostResult"], [names, len(receipt.get("hostResult") or "")])
receipt, one = send("brokkr_kitbash.describe", part="actuator")
check("describe of one part gives its params and its sockets at default params", one and [p["name"] for p in one["parts"]] == ["actuator"]
and [p["name"] for p in one["parts"][0]["params"]] == ["body_r", "body_len", "rod_r", "extension", "segments"]
and one["parts"][0]["sockets"] == core.socket_rows(core.build(kit["parts"]["actuator"]).sockets), one)
check("describe changes nothing", len(bpy.data.objects) == 0 and len(bpy.data.meshes) == 0, [len(bpy.data.objects), len(bpy.data.meshes)])
# --- describe ---------------------------------------------------------------------------------------------------------
kit = core.load_kit("mechanical")
receipt, described = send("brokkr_kitbash.describe")
names = [p["name"] for p in described["parts"]] if described else []
check("describe lists thirteen parts, whole, inside a receipt", receipt["status"] == "accepted" and names == list(kit["parts"]) and len(names) == 13
and "[truncated]" not in receipt["hostResult"], [names, len(receipt.get("hostResult") or "")])
receipt, one = send("brokkr_kitbash.describe", part="actuator")
check("describe of one part gives its params and its sockets at default params", one and [p["name"] for p in one["parts"]] == ["actuator"]
and [p["name"] for p in one["parts"][0]["params"]] == ["body_r", "body_len", "rod_r", "extension", "segments"]
and one["parts"][0]["sockets"] == core.socket_rows(core.build(kit["parts"]["actuator"]).sockets), one)
check("describe changes nothing", len(bpy.data.objects) == 0 and len(bpy.data.meshes) == 0, [len(bpy.data.objects), len(bpy.data.meshes)])
# --- place every part at default -----------------------------------------------------------------------------------------
placed = {}
for index, name in enumerate(names):
receipt, report = send("brokkr_kitbash.place_part", part=name, object_name=f"P_{name}")
obj = bpy.data.objects.get(f"P_{name}")
reference = core.build(kit["parts"][name])
faces = len(obj.data.polygons) if obj else -1
clean = obj is not None and not obj.data.validate(verbose=False)
flat = np.zeros(max(faces, 0), dtype=bool)
if obj:
obj.data.attributes["sharp_face"].data.foreach_get("value", flat)
crease = obj.data.attributes.get("sharp_edge") if obj else None
creased = np.zeros(len(obj.data.edges) if crease else 0, dtype=bool)
if crease:
crease.data.foreach_get("value", creased)
marked = sorted(tuple(sorted(edge.vertices)) for edge, on in zip(obj.data.edges, creased) if on) if crease else None
check(f"place_part {name}: sharp_edge is true on exactly core's sharp edges ({len(reference.sharp)})",
marked == sorted(tuple(sorted(pair)) for pair in reference.sharp.tolist()), [marked and len(marked), len(reference.sharp)])
bevel = obj.modifiers.get("Kit Bevel") if obj else None
evaluated = len(obj.evaluated_get(bpy.context.evaluated_depsgraph_get()).data.polygons) if obj else -1
placed[name] = report
check(f"place_part {name}: core's faces, a valid mesh, core's flat faces, at the origin", receipt["status"] == "accepted" and report
and faces == len(reference.counts) == report["faces"] and clean and report["shells"] == reference.shell_count
and flat.tolist() == (~reference.smooth).tolist() and list(obj.location) == [0.0, 0.0, 0.0]
and np.allclose(np.array([v.co[:] for v in obj.data.vertices]), reference.V, atol=1e-6),
[receipt["message"], faces, len(reference.counts), clean])
check(f"place_part {name}: a Bevel of the part's width, 2 segments, angle 30, that evaluates", bevel is not None
and abs(bevel.width - reference.bevel) < 1e-7 and bevel.segments == 2 and bevel.limit_method == "ANGLE"
and abs(bevel.angle_limit - math.radians(30)) < 1e-6 and evaluated > faces, [bevel and bevel.width, reference.bevel, evaluated, faces])
check(f"place_part {name}: kit, part and every resolved param stored on the object, sockets reported in the part frame", obj is not None
and obj["kit_kit"] == "mechanical" and obj["kit_part"] == name and json.loads(obj["kit_params"]) == reference.params == report["params"]
and report["sockets"] == core.socket_rows(reference.sockets), report)
check("eleven parts are eleven mesh objects", len(bpy.data.objects) == 11 and all(o.type == "MESH" for o in bpy.data.objects), len(bpy.data.objects))
# --- place every part at default -----------------------------------------------------------------------------------------
placed = {}
for index, name in enumerate(names):
receipt, report = send("brokkr_kitbash.place_part", part=name, object_name=f"P_{name}")
obj = bpy.data.objects.get(f"P_{name}")
reference = core.build(kit["parts"][name])
faces = len(obj.data.polygons) if obj else -1
clean = obj is not None and not obj.data.validate(verbose=False)
flat = np.zeros(max(faces, 0), dtype=bool)
if obj:
obj.data.attributes["sharp_face"].data.foreach_get("value", flat)
crease = obj.data.attributes.get("sharp_edge") if obj else None
creased = np.zeros(len(obj.data.edges) if crease else 0, dtype=bool)
if crease:
crease.data.foreach_get("value", creased)
marked = sorted(tuple(sorted(edge.vertices)) for edge, on in zip(obj.data.edges, creased) if on) if crease else None
check(f"place_part {name}: sharp_edge is true on exactly core's sharp edges ({len(reference.sharp)})",
marked == sorted(tuple(sorted(pair)) for pair in reference.sharp.tolist()), [marked and len(marked), len(reference.sharp)])
bevel = obj.modifiers.get("Kit Bevel") if obj else None
evaluated = len(obj.evaluated_get(bpy.context.evaluated_depsgraph_get()).data.polygons) if obj else -1
placed[name] = report
check(f"place_part {name}: core's faces, a valid mesh, core's flat faces, at the origin", receipt["status"] == "accepted" and report
and faces == len(reference.counts) == report["faces"] and clean and report["shells"] == reference.shell_count
and flat.tolist() == (~reference.smooth).tolist() and list(obj.location) == [0.0, 0.0, 0.0]
and np.allclose(np.array([v.co[:] for v in obj.data.vertices]), reference.V, atol=1e-6),
[receipt["message"], faces, len(reference.counts), clean])
check(f"place_part {name}: a Bevel of the part's width, 2 segments, angle 30, that evaluates", bevel is not None
and abs(bevel.width - reference.bevel) < 1e-7 and bevel.segments == 2 and bevel.limit_method == "ANGLE"
and abs(bevel.angle_limit - math.radians(30)) < 1e-6 and evaluated > faces, [bevel and bevel.width, reference.bevel, evaluated, faces])
check(f"place_part {name}: kit, part and every resolved param stored on the object, sockets reported in the part frame", obj is not None
and obj["kit_kit"] == "mechanical" and obj["kit_part"] == name and json.loads(obj["kit_params"]) == reference.params == report["params"]
and report["sockets"] == core.socket_rows(reference.sockets), report)
check("thirteen parts are thirteen mesh objects", len(bpy.data.objects) == 13 and all(o.type == "MESH" for o in bpy.data.objects), len(bpy.data.objects))
# --- set_params keeps what is not derived --------------------------------------------------------------------------------
reducer = bpy.data.objects["P_reducer"]
send("brokkr_kitbash.set_params", object_name="P_reducer", params="segments=12")
creased = np.zeros(len(reducer.data.edges), dtype=bool)
reducer.data.attributes["sharp_edge"].data.foreach_get("value", creased)
rings = [np.array([reducer.data.vertices[v].co[:] for edge, on in zip(reducer.data.edges, creased) if on for v in edge.vertices])]
check("the reducer's creases are its two cone rings, 24 edges each at 24 segments, and set_params writes them again: 12 each at 12",
len(core.build(kit["parts"]["reducer"]).sharp) == 48 and int(creased.sum()) == 24
and sorted(set(np.round(np.linalg.norm(rings[0][:, :2], axis=1), 5).tolist())) == [0.05, 0.12], int(creased.sum()))
tank = bpy.data.objects["P_tank"]
send("setObjectTransform", targetObjectName="P_tank", location=[1.0, 2.0, 3.0], rotationEuler=[0.3, -0.2, 0.5], scale=[1.0, 1.0, 1.0])
send("assignMaterial", targetObjectName="P_tank", materialName="Tank Paint", color=[0.35, 0.35, 0.35])
send("setObjectParent", targetObjectName="P_tank", parentObjectName="P_plate")
before = {"z": extent(tank), "mesh": tank.data.name, "basis": [list(r) for r in tank.matrix_basis], "parent": tank.parent and tank.parent.name,
"materials": [s.material and s.material.name for s in tank.material_slots], "modifiers": [m.name for m in tank.modifiers],
"faces": len(tank.data.polygons)}
receipt, grown = send("brokkr_kitbash.set_params", object_name="P_tank", params="length=1.8")
after = {"z": extent(tank), "mesh": tank.data.name, "basis": [list(r) for r in tank.matrix_basis], "parent": tank.parent and tank.parent.name,
"materials": [s.material and s.material.name for s in tank.material_slots], "modifiers": [m.name for m in tank.modifiers],
"faces": len(tank.data.polygons)}
check("set_params doubling the tank's length doubles its z extent", receipt["status"] == "accepted" and abs(before["z"] - 0.9) < 1e-6
and abs(after["z"] - 1.8) < 1e-6, [before["z"], after["z"]])
check("set_params keeps the mesh datablock, transform, parent, Bevel and the assigned material", before["parent"] == "P_plate"
and before["materials"] == ["Tank Paint"] and before["modifiers"] == ["Kit Bevel"]
and {k: v for k, v in after.items() if k != "z"} == {k: v for k, v in before.items() if k != "z"} and not tank.data.validate(verbose=False), [before, after])
check("set_params stores the merged params and reports them", grown and json.loads(tank["kit_params"]) == grown["params"]
== {"radius": 0.22, "length": 1.8, "segments": 24}, grown)
receipt, wide = send("brokkr_kitbash.set_params", object_name="P_tank", params="radius=0.3; segments=12")
check("set_params overlays the stored params, and the Bevel width follows the part's bevel", wide and wide["params"] == {"radius": 0.3, "length": 1.8, "segments": 12}
and abs(tank.modifiers["Kit Bevel"].width - 0.008 * 0.3) < 1e-7 and len(tank.data.polygons) == len(core.build(kit["parts"]["tank"], wide["params"]).counts),
[wide and wide["params"], tank.modifiers["Kit Bevel"].width])
# --- set_params keeps what is not derived --------------------------------------------------------------------------------
reducer = bpy.data.objects["P_reducer"]
send("brokkr_kitbash.set_params", object_name="P_reducer", params="segments=12")
creased = np.zeros(len(reducer.data.edges), dtype=bool)
reducer.data.attributes["sharp_edge"].data.foreach_get("value", creased)
rings = [np.array([reducer.data.vertices[v].co[:] for edge, on in zip(reducer.data.edges, creased) if on for v in edge.vertices])]
check("the reducer's creases are its two cone rings, 24 edges each at 24 segments, and set_params writes them again: 12 each at 12",
len(core.build(kit["parts"]["reducer"]).sharp) == 48 and int(creased.sum()) == 24
and sorted(set(np.round(np.linalg.norm(rings[0][:, :2], axis=1), 5).tolist())) == [0.05, 0.12], int(creased.sum()))
tank = bpy.data.objects["P_tank"]
send("setObjectTransform", targetObjectName="P_tank", location=[1.0, 2.0, 3.0], rotationEuler=[0.3, -0.2, 0.5], scale=[1.0, 1.0, 1.0])
send("assignMaterial", targetObjectName="P_tank", materialName="Tank Paint", color=[0.35, 0.35, 0.35])
send("setObjectParent", targetObjectName="P_tank", parentObjectName="P_plate")
before = {"z": extent(tank), "mesh": tank.data.name, "basis": [list(r) for r in tank.matrix_basis], "parent": tank.parent and tank.parent.name,
"materials": [s.material and s.material.name for s in tank.material_slots], "modifiers": [m.name for m in tank.modifiers],
"faces": len(tank.data.polygons)}
receipt, grown = send("brokkr_kitbash.set_params", object_name="P_tank", params="length=1.8")
after = {"z": extent(tank), "mesh": tank.data.name, "basis": [list(r) for r in tank.matrix_basis], "parent": tank.parent and tank.parent.name,
"materials": [s.material and s.material.name for s in tank.material_slots], "modifiers": [m.name for m in tank.modifiers],
"faces": len(tank.data.polygons)}
check("set_params doubling the tank's length doubles its z extent", receipt["status"] == "accepted" and abs(before["z"] - 0.9) < 1e-6
and abs(after["z"] - 1.8) < 1e-6, [before["z"], after["z"]])
check("set_params keeps the mesh datablock, transform, parent, Bevel and the assigned material", before["parent"] == "P_plate"
and before["materials"] == ["Tank Paint"] and before["modifiers"] == ["Kit Bevel"]
and {k: v for k, v in after.items() if k != "z"} == {k: v for k, v in before.items() if k != "z"} and not tank.data.validate(verbose=False), [before, after])
check("set_params stores the merged params and reports them", grown and json.loads(tank["kit_params"]) == grown["params"]
== {"radius": 0.22, "length": 1.8, "segments": 24}, grown)
receipt, wide = send("brokkr_kitbash.set_params", object_name="P_tank", params="radius=0.3; segments=12")
check("set_params overlays the stored params, and the Bevel width follows the part's bevel", wide and wide["params"] == {"radius": 0.3, "length": 1.8, "segments": 12}
and abs(tank.modifiers["Kit Bevel"].width - 0.008 * 0.3) < 1e-7 and len(tank.data.polygons) == len(core.build(kit["parts"]["tank"], wide["params"]).counts),
[wide and wide["params"], tank.modifiers["Kit Bevel"].width])
# --- report: sockets in the world -------------------------------------------------------------------------------------------
send("setObjectTransform", targetObjectName="P_pipe_fitting", location=[-2.0, 0.5, 1.0], rotationEuler=[1.1, 0.4, -0.7])
receipt, reported = send("brokkr_kitbash.report") # straight after the move, before anything here updates the view layer: the frames are already the moved ones
bpy.context.view_layer.update()
worst, listed = 0.0, []
for entry in (reported or {}).get("parts", []):
obj = bpy.data.objects[entry["object"]]
listed.append(entry["object"])
local = core.build(core.part(kit, entry["part"]), entry["params"]).sockets
world = np.array(obj.matrix_world)
for socket, mine in zip(entry["sockets"], local):
worst = max(worst, float(np.abs(np.array(socket["matrix"]) - world @ mine["matrix"]).max()))
check("report lists every kit part with socket frames equal to matrix_world times the local frame", receipt["status"] == "accepted"
and listed == sorted(f"P_{n}" for n in names) and worst < 1e-6, [listed, worst])
receipt, single = send("brokkr_kitbash.report", object_name="P_tank")
tank_world = np.array(tank.matrix_world)
check("report of the parented, rotated tank carries its parent's and its own transform", single and len(single["parts"]) == 1
and single["parts"][0]["params"] == wide["params"] and single["parts"][0]["faces"] == len(tank.data.polygons)
and np.abs(np.array(single["parts"][0]["sockets"][2]["matrix"]) - tank_world @ core.build(kit["parts"]["tank"], wide["params"]).sockets[2]["matrix"]).max() < 1e-6
and np.abs(tank_world[:3, 3] - [1.0, 2.0, 3.0]).max() < 1e-6, single)
# --- report: sockets in the world -------------------------------------------------------------------------------------------
send("setObjectTransform", targetObjectName="P_pipe_fitting", location=[-2.0, 0.5, 1.0], rotationEuler=[1.1, 0.4, -0.7])
receipt, reported = send("brokkr_kitbash.report") # straight after the move, before anything here updates the view layer: the frames are already the moved ones
bpy.context.view_layer.update()
worst, listed = 0.0, []
for entry in (reported or {}).get("parts", []):
obj = bpy.data.objects[entry["object"]]
listed.append(entry["object"])
local = core.build(core.part(kit, entry["part"]), entry["params"]).sockets
world = np.array(obj.matrix_world)
for socket, mine in zip(entry["sockets"], local):
worst = max(worst, float(np.abs(np.array(socket["matrix"]) - world @ mine["matrix"]).max()))
check("report lists every kit part with socket frames equal to matrix_world times the local frame", receipt["status"] == "accepted"
and listed == sorted(f"P_{n}" for n in names) and worst < 1e-6, [listed, worst])
receipt, single = send("brokkr_kitbash.report", object_name="P_tank")
tank_world = np.array(tank.matrix_world)
check("report of the parented, rotated tank carries its parent's and its own transform", single and len(single["parts"]) == 1
and single["parts"][0]["params"] == wide["params"] and single["parts"][0]["faces"] == len(tank.data.polygons)
and np.abs(np.array(single["parts"][0]["sockets"][2]["matrix"]) - tank_world @ core.build(kit["parts"]["tank"], wide["params"]).sockets[2]["matrix"]).max() < 1e-6
and np.abs(tank_world[:3, 3] - [1.0, 2.0, 3.0]).max() < 1e-6, single)
# --- per-face materials ride on the part's shapes ----------------------------------------------------------------------------
strut = bpy.data.objects["P_strut"]
send("assignMaterial", targetObjectName="P_strut", materialName="Strut Paint", color=[0.35, 0.35, 0.35])
strut.data.materials.append(bpy.data.materials.new("Pin Steel"))
PINS = 2 # the strut's third shape: the repeat of two pins
was = core.build(kit["parts"]["strut"])
strut.data.polygons.foreach_set("material_index", np.where(was.shape == PINS, 1, 0).astype(np.int32))
receipt, _ = send("brokkr_kitbash.set_params", object_name="P_strut", params="segments=12; length=1.2")
now = core.build(kit["parts"]["strut"], {"segments": 12, "length": 1.2})
index = np.zeros(len(strut.data.polygons), dtype=np.int32)
strut.data.polygons.foreach_get("material_index", index)
check("set_params with other segments keeps each shape's material: the pins stay Pin Steel, the rest Strut Paint", receipt["status"] == "accepted"
and len(now.counts) != len(was.counts) and index.tolist() == np.where(now.shape == PINS, 1, 0).tolist() and int(index.sum()) == 2 * (12 + 2)
and [s.material.name for s in strut.material_slots] == ["Strut Paint", "Pin Steel"], [receipt["message"], int(index.sum()), len(index)])
# --- per-face materials ride on the part's shapes ----------------------------------------------------------------------------
strut = bpy.data.objects["P_strut"]
send("assignMaterial", targetObjectName="P_strut", materialName="Strut Paint", color=[0.35, 0.35, 0.35])
strut.data.materials.append(bpy.data.materials.new("Pin Steel"))
PINS = 2 # the strut's third shape: the repeat of two pins
was = core.build(kit["parts"]["strut"])
strut.data.polygons.foreach_set("material_index", np.where(was.shape == PINS, 1, 0).astype(np.int32))
receipt, _ = send("brokkr_kitbash.set_params", object_name="P_strut", params="segments=12; length=1.2")
now = core.build(kit["parts"]["strut"], {"segments": 12, "length": 1.2})
index = np.zeros(len(strut.data.polygons), dtype=np.int32)
strut.data.polygons.foreach_get("material_index", index)
check("set_params with other segments keeps each shape's material: the pins stay Pin Steel, the rest Strut Paint", receipt["status"] == "accepted"
and len(now.counts) != len(was.counts) and index.tolist() == np.where(now.shape == PINS, 1, 0).tolist() and int(index.sum()) == 2 * (12 + 2)
and [s.material.name for s in strut.material_slots] == ["Strut Paint", "Pin Steel"], [receipt["message"], int(index.sum()), len(index)])
# --- refusals leave the scene as it was --------------------------------------------------------------------------------------
bpy.ops.mesh.primitive_cube_add()
bpy.context.active_object.name = "Plain"
twin = bpy.data.objects["P_vent"].copy() # a linked duplicate: one mesh, two objects, each with its own kit_params
twin.name = "P_vent_twin"
bpy.context.scene.collection.objects.link(twin)
send("setObjectTransform", targetObjectName="P_radiator_stack", scale=[2.0, 2.0, 2.0])
send("setObjectTransform", targetObjectName="P_actuator", scale=[-1.0, 1.0, 1.0])
# --- refusals leave the scene as it was --------------------------------------------------------------------------------------
bpy.ops.mesh.primitive_cube_add()
bpy.context.active_object.name = "Plain"
twin = bpy.data.objects["P_vent"].copy() # a linked duplicate: one mesh, two objects, each with its own kit_params
twin.name = "P_vent_twin"
bpy.context.scene.collection.objects.link(twin)
send("setObjectTransform", targetObjectName="P_radiator_stack", scale=[2.0, 2.0, 2.0])
send("setObjectTransform", targetObjectName="P_actuator", scale=[-1.0, 1.0, 1.0])
def scene_state():
return (sorted(o.name for o in bpy.data.objects), sorted(m.name for m in bpy.data.meshes),
{o.name: (len(o.data.polygons), o.get("kit_params")) for o in bpy.data.objects})
def scene_state():
return (sorted(o.name for o in bpy.data.objects), sorted(m.name for m in bpy.data.meshes),
{o.name: (len(o.data.polygons), o.get("kit_params")) for o in bpy.data.objects})
state = scene_state()
refusals = [
("an unknown kit", "brokkr_kitbash.place_part", {"kit": "hydraulic", "part": "tank", "object_name": "X"}, "no kit named 'hydraulic'"),
("a kit name that spells a path", "brokkr_kitbash.place_part", {"kit": "../x", "part": "tank", "object_name": "X"}, "kit"),
("a kit name with a dot", "brokkr_kitbash.place_part", {"kit": "mechanical.v0", "part": "tank", "object_name": "X"}, "must be 1 to 32 of"),
("an unknown part", "brokkr_kitbash.place_part", {"part": "wing", "object_name": "X"}, "has no part 'wing'"),
("an out-of-range param", "brokkr_kitbash.place_part", {"part": "tank", "object_name": "X", "params": "radius=5"}, "param 'radius' = 5.0 is outside [0.12, 0.35]"),
("a fraction for an integer param", "brokkr_kitbash.place_part", {"part": "tank", "object_name": "X", "params": "segments=12.5"}, "is an integer"),
("an existing name", "brokkr_kitbash.place_part", {"part": "tank", "object_name": "P_plate"}, "An object named 'P_plate' exists"),
("set_params on a plain mesh", "brokkr_kitbash.set_params", {"object_name": "Plain", "params": "length=1"}, "is not a kit part"),
("set_params with an unknown param", "brokkr_kitbash.set_params", {"object_name": "P_tank", "params": "girth=1"}, "has no param 'girth'"),
("set_params out of range", "brokkr_kitbash.set_params", {"object_name": "P_tank", "params": "length=0.1"}, "is outside [0.6, 2.0]"),
("set_params with a repeated key", "brokkr_kitbash.set_params", {"object_name": "P_tank", "params": "length=1; length=1.2"}, "'length' is given twice"),
("report of a plain mesh", "brokkr_kitbash.report", {"object_name": "Plain"}, "is not a kit part"),
("set_params on a mesh a linked duplicate shares", "brokkr_kitbash.set_params", {"object_name": "P_vent", "params": "slats=9"}, "shares its mesh 'P_vent' with 1 other user"),
("set_params on the linked duplicate", "brokkr_kitbash.set_params", {"object_name": "P_vent_twin", "params": "slats=9"}, "shares its mesh 'P_vent' with 1 other user"),
("report of a scaled part", "brokkr_kitbash.report", {"object_name": "P_radiator_stack"}, "'P_radiator_stack' is scaled, mirrored or sheared in the world (scale 2, 2, 2)"),
("set_params on a scaled part", "brokkr_kitbash.set_params", {"object_name": "P_radiator_stack", "params": "fins=5"}, "is scaled, mirrored or sheared"),
("report of a mirrored part", "brokkr_kitbash.report", {"object_name": "P_actuator"}, "'P_actuator' is scaled, mirrored or sheared"),
("report of every part while one is scaled", "brokkr_kitbash.report", {}, "is scaled, mirrored or sheared"),
("describe of an unknown part", "brokkr_kitbash.describe", {"part": "wing"}, "has no part 'wing'"),
]
for label, action, fields, expected in refusals:
receipt, _ = send(action, **fields)
check(f"refused, scene unchanged: {label}", receipt["status"] != "accepted" and expected in str(receipt["message"]) and scene_state() == state,
[receipt["status"], receipt["message"]])
state = scene_state()
refusals = [
("an unknown kit", "brokkr_kitbash.place_part", {"kit": "hydraulic", "part": "tank", "object_name": "X"}, "no kit named 'hydraulic'"),
("a kit name that spells a path", "brokkr_kitbash.place_part", {"kit": "../x", "part": "tank", "object_name": "X"}, "kit"),
("a kit name with a dot", "brokkr_kitbash.place_part", {"kit": "mechanical.v0", "part": "tank", "object_name": "X"}, "must be 1 to 32 of"),
("an unknown part", "brokkr_kitbash.place_part", {"part": "wing", "object_name": "X"}, "has no part 'wing'"),
("an out-of-range param", "brokkr_kitbash.place_part", {"part": "tank", "object_name": "X", "params": "radius=5"}, "param 'radius' = 5.0 is outside [0.12, 0.35]"),
("a fraction for an integer param", "brokkr_kitbash.place_part", {"part": "tank", "object_name": "X", "params": "segments=12.5"}, "is an integer"),
("an existing name", "brokkr_kitbash.place_part", {"part": "tank", "object_name": "P_plate"}, "An object named 'P_plate' exists"),
("set_params on a plain mesh", "brokkr_kitbash.set_params", {"object_name": "Plain", "params": "length=1"}, "is not a kit part"),
("set_params with an unknown param", "brokkr_kitbash.set_params", {"object_name": "P_tank", "params": "girth=1"}, "has no param 'girth'"),
("set_params out of range", "brokkr_kitbash.set_params", {"object_name": "P_tank", "params": "length=0.1"}, "is outside [0.6, 2.0]"),
("set_params with a repeated key", "brokkr_kitbash.set_params", {"object_name": "P_tank", "params": "length=1; length=1.2"}, "'length' is given twice"),
("report of a plain mesh", "brokkr_kitbash.report", {"object_name": "Plain"}, "is not a kit part"),
("set_params on a mesh a linked duplicate shares", "brokkr_kitbash.set_params", {"object_name": "P_vent", "params": "slats=9"}, "shares its mesh 'P_vent' with 1 other user"),
("set_params on the linked duplicate", "brokkr_kitbash.set_params", {"object_name": "P_vent_twin", "params": "slats=9"}, "shares its mesh 'P_vent' with 1 other user"),
("report of a scaled part", "brokkr_kitbash.report", {"object_name": "P_radiator_stack"}, "'P_radiator_stack' is scaled, mirrored or sheared in the world (scale 2, 2, 2)"),
("set_params on a scaled part", "brokkr_kitbash.set_params", {"object_name": "P_radiator_stack", "params": "fins=5"}, "is scaled, mirrored or sheared"),
("report of a mirrored part", "brokkr_kitbash.report", {"object_name": "P_actuator"}, "'P_actuator' is scaled, mirrored or sheared"),
("report of every part while one is scaled", "brokkr_kitbash.report", {}, "is scaled, mirrored or sheared"),
("describe of an unknown part", "brokkr_kitbash.describe", {"part": "wing"}, "has no part 'wing'"),
]
for label, action, fields, expected in refusals:
receipt, _ = send(action, **fields)
check(f"refused, scene unchanged: {label}", receipt["status"] != "accepted" and expected in str(receipt["message"]) and scene_state() == state,
[receipt["status"], receipt["message"]])
bpy.data.objects.remove(twin)
send("setObjectTransform", targetObjectName="P_radiator_stack", scale=[1.0, 1.0, 1.0])
send("setObjectTransform", targetObjectName="P_actuator", scale=[1.0, 1.0, 1.0])
receipt, alone = send("brokkr_kitbash.set_params", object_name="P_vent", params="slats=9")
check("with the duplicate gone the vent's mesh is its own again and set_params rebuilds it", receipt["status"] == "accepted" and alone
and alone["params"]["slats"] == 9 and len(bpy.data.objects["P_vent"].data.polygons) == len(core.build(kit["parts"]["vent"], {"slats": 9}).counts), receipt["message"])
receipt, whole = send("brokkr_kitbash.report")
check("with scale back at 1 every part reports again", receipt["status"] == "accepted" and whole and len(whole["parts"]) == 11, receipt["message"])
bpy.data.objects.remove(twin)
send("setObjectTransform", targetObjectName="P_radiator_stack", scale=[1.0, 1.0, 1.0])
send("setObjectTransform", targetObjectName="P_actuator", scale=[1.0, 1.0, 1.0])
receipt, alone = send("brokkr_kitbash.set_params", object_name="P_vent", params="slats=9")
check("with the duplicate gone the vent's mesh is its own again and set_params rebuilds it", receipt["status"] == "accepted" and alone
and alone["params"]["slats"] == 9 and len(bpy.data.objects["P_vent"].data.polygons) == len(core.build(kit["parts"]["vent"], {"slats": 9}).counts), receipt["message"])
receipt, whole = send("brokkr_kitbash.report")
check("with scale back at 1 every part reports again", receipt["status"] == "accepted" and whole and len(whole["parts"]) == 13, receipt["message"])
# --- export ---------------------------------------------------------------------------------------------------------------
receipt, _ = send("exportGltf", filepath="kit.glb", extras=False, yUp=True, applyModifiers=True, selection=[f"P_{n}" for n in names])
glb = WORK / "kit.glb"
meshes = -1
if glb.is_file():
blob = glb.read_bytes()
meshes = len(json.loads(blob[20:20 + int.from_bytes(blob[12:16], "little")]).get("meshes", []))
check("exportGltf of all eleven parts succeeds", receipt["status"] == "accepted" and meshes == 11, [receipt["message"], meshes])
# --- the frame kit: every shell an extrude, a section swept along a path --------------------------------------------------
frame = core.load_kit("frame")
receipt, described = send("brokkr_kitbash.describe", kit="frame")
check("describe of the frame kit lists its nine parts, whole", receipt["status"] == "accepted" and described
and [p["name"] for p in described["parts"]] == list(frame["parts"]) and len(described["parts"]) == 9 and "[truncated]" not in receipt["hostResult"],
[receipt["message"], len(receipt.get("hostResult") or "")])
R["frame"] = {}
for name, part in frame["parts"].items():
receipt, report = send("brokkr_kitbash.place_part", kit="frame", part=name, object_name=f"F_{name}")
obj = bpy.data.objects.get(f"F_{name}")
reference = core.build(part)
faces = len(obj.data.polygons) if obj else -1
flat = np.zeros(max(faces, 0), dtype=bool)
if obj:
obj.data.attributes["sharp_face"].data.foreach_get("value", flat)
check(f"place_part frame {name}: core's faces, shells and vertices, a valid mesh, every face flat, no Bevel, sockets in the part frame",
receipt["status"] == "accepted" and report and obj is not None and faces == len(reference.counts) == report["faces"]
and report["shells"] == reference.shell_count and not obj.data.validate(verbose=False) and bool(flat.all())
and np.allclose(np.array([v.co[:] for v in obj.data.vertices]), reference.V, atol=1e-6) and obj.modifiers.get("Kit Bevel") is None
and (obj["kit_kit"], obj["kit_part"]) == ("frame", name) and report["sockets"] == core.socket_rows(reference.sockets),
[receipt["message"], faces, len(reference.counts)])
R["frame"][name] = {"faces": faces, "shells": reference.shell_count, "sockets": [s["name"] for s in reference.sockets]}
truss = bpy.data.objects["F_truss"]
truss_mesh = truss.data.name
receipt, report = send("brokkr_kitbash.set_params", object_name="F_truss", params="pairs=6")
reference = core.build(frame["parts"]["truss"], {"pairs": 6})
check("set_params pairs=6 rebuilds the truss in place: 27 shells of core's faces on the same object and mesh", receipt["status"] == "accepted" and report
and report["shells"] == reference.shell_count == 27 and len(truss.data.polygons) == len(reference.counts) == report["faces"]
and bpy.data.objects.get("F_truss") == truss and truss.data.name == truss_mesh and report["params"]["pairs"] == 6
and np.allclose(np.array([v.co[:] for v in truss.data.vertices]), reference.V, atol=1e-6), [receipt["message"], report])
receipt, report = send("brokkr_kitbash.attach", object_name="F_box_beam", socket="end_a", parent_name="P_bracket", parent_socket="mount")
beam, bracket = bpy.data.objects["F_box_beam"], bpy.data.objects["P_bracket"]
seat = np.array(bracket.matrix_world) @ np.array(core.build(kit["parts"]["bracket"], json.loads(bracket["kit_params"])).sockets[0]["matrix"])
end = np.array(beam.matrix_world) @ np.array(core.build(frame["parts"]["box_beam"]).sockets[0]["matrix"])
# the connection holds within HELD, 1e-5 m, the rule attach and close share (tests/live/kitbash_assembly.py)
check("a frame box_beam's end_a seats on a mechanical bracket's mount across the two kits, and holds", receipt["status"] == "accepted" and report
and beam.parent == bracket and report["connection"]["holds"] is True and report["connection"]["residual"] <= 1e-5
and float(np.abs(seat[:3, 3] - end[:3, 3]).max()) < 1e-5 and float(np.abs(seat[:3, 2] + end[:3, 2]).max()) < 1e-5,
[receipt["message"], report and report.get("connection")])
# --- export ---------------------------------------------------------------------------------------------------------------
receipt, _ = send("exportGltf", filepath="kit.glb", extras=False, yUp=True, applyModifiers=True, selection=[f"P_{n}" for n in names])
glb = WORK / "kit.glb"
meshes = -1
if glb.is_file():
blob = glb.read_bytes()
meshes = len(json.loads(blob[20:20 + int.from_bytes(blob[12:16], "little")]).get("meshes", []))
check("exportGltf of all thirteen parts succeeds", receipt["status"] == "accepted" and meshes == 13, [receipt["message"], meshes])
R["placed"] = {name: {"faces": report["faces"], "shells": report["shells"], "bevel": report["bevel"], "sockets": [s["name"] for s in report["sockets"]]}
for name, report in placed.items() if report}
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, printed and written, not a missing result file
check(f"no uncaught error after: {R['checks'][-1]['name'] if R['checks'] else 'the start'}", False, traceback.format_exc().splitlines()[-6:])
R["placed"] = {name: {"faces": report["faces"], "shells": report["shells"], "bevel": report["bevel"], "sockets": [s["name"] for s in report["sockets"]]}
for name, report in placed.items() if report}
R["ok"] = all(c["ok"] for c in R["checks"])
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
sys.exit(0 if R["ok"] else 1)

View file

@ -7,7 +7,7 @@
"detail": null
},
{
"name": "describe lists eleven parts, whole, inside a receipt",
"name": "describe lists thirteen parts, whole, inside a receipt",
"ok": true,
"detail": null
},
@ -121,6 +121,46 @@
"ok": true,
"detail": null
},
{
"name": "place_part ram_barrel: sharp_edge is true on exactly core's sharp edges (0)",
"ok": true,
"detail": null
},
{
"name": "place_part ram_barrel: core's faces, a valid mesh, core's flat faces, at the origin",
"ok": true,
"detail": null
},
{
"name": "place_part ram_barrel: a Bevel of the part's width, 2 segments, angle 30, that evaluates",
"ok": true,
"detail": null
},
{
"name": "place_part ram_barrel: kit, part and every resolved param stored on the object, sockets reported in the part frame",
"ok": true,
"detail": null
},
{
"name": "place_part ram_rod: sharp_edge is true on exactly core's sharp edges (0)",
"ok": true,
"detail": null
},
{
"name": "place_part ram_rod: core's faces, a valid mesh, core's flat faces, at the origin",
"ok": true,
"detail": null
},
{
"name": "place_part ram_rod: a Bevel of the part's width, 2 segments, angle 30, that evaluates",
"ok": true,
"detail": null
},
{
"name": "place_part ram_rod: kit, part and every resolved param stored on the object, sockets reported in the part frame",
"ok": true,
"detail": null
},
{
"name": "place_part pipe_fitting: sharp_edge is true on exactly core's sharp edges (0)",
"ok": true,
@ -242,7 +282,7 @@
"detail": null
},
{
"name": "eleven parts are eleven mesh objects",
"name": "thirteen parts are thirteen mesh objects",
"ok": true,
"detail": null
},
@ -392,7 +432,67 @@
"detail": null
},
{
"name": "exportGltf of all eleven parts succeeds",
"name": "describe of the frame kit lists its nine parts, whole",
"ok": true,
"detail": null
},
{
"name": "place_part frame beam_i: core's faces, shells and vertices, a valid mesh, every face flat, no Bevel, sockets in the part frame",
"ok": true,
"detail": null
},
{
"name": "place_part frame channel: core's faces, shells and vertices, a valid mesh, every face flat, no Bevel, sockets in the part frame",
"ok": true,
"detail": null
},
{
"name": "place_part frame tee: core's faces, shells and vertices, a valid mesh, every face flat, no Bevel, sockets in the part frame",
"ok": true,
"detail": null
},
{
"name": "place_part frame angle: core's faces, shells and vertices, a valid mesh, every face flat, no Bevel, sockets in the part frame",
"ok": true,
"detail": null
},
{
"name": "place_part frame box_beam: core's faces, shells and vertices, a valid mesh, every face flat, no Bevel, sockets in the part frame",
"ok": true,
"detail": null
},
{
"name": "place_part frame truss: core's faces, shells and vertices, a valid mesh, every face flat, no Bevel, sockets in the part frame",
"ok": true,
"detail": null
},
{
"name": "place_part frame portal: core's faces, shells and vertices, a valid mesh, every face flat, no Bevel, sockets in the part frame",
"ok": true,
"detail": null
},
{
"name": "place_part frame gusset: core's faces, shells and vertices, a valid mesh, every face flat, no Bevel, sockets in the part frame",
"ok": true,
"detail": null
},
{
"name": "place_part frame wedge: core's faces, shells and vertices, a valid mesh, every face flat, no Bevel, sockets in the part frame",
"ok": true,
"detail": null
},
{
"name": "set_params pairs=6 rebuilds the truss in place: 27 shells of core's faces on the same object and mesh",
"ok": true,
"detail": null
},
{
"name": "a frame box_beam's end_a seats on a mechanical bracket's mount across the two kits, and holds",
"ok": true,
"detail": null
},
{
"name": "exportGltf of all thirteen parts succeeds",
"ok": true,
"detail": null
}
@ -412,12 +512,97 @@
"brokkr_kitbash.report",
"brokkr_kitbash.attach",
"brokkr_kitbash.detach",
"brokkr_kitbash.roll",
"brokkr_kitbash.aim",
"brokkr_kitbash.reach",
"brokkr_kitbash.joint",
"brokkr_kitbash.slide",
"brokkr_kitbash.joints",
"brokkr_kitbash.follow",
"brokkr_kitbash.close",
"brokkr_kitbash.boolean",
"brokkr_kitbash.cut",
"brokkr_kitbash.cut_many",
"brokkr_kitbash.apply"
"brokkr_kitbash.freeze",
"brokkr_kitbash.thaw",
"brokkr_kitbash.ribs",
"brokkr_kitbash.shell",
"brokkr_kitbash.hose"
],
"frame": {
"beam_i": {
"faces": 14,
"shells": 1,
"sockets": [
"end_a",
"end_b"
]
},
"channel": {
"faces": 10,
"shells": 1,
"sockets": [
"end_a",
"end_b"
]
},
"tee": {
"faces": 10,
"shells": 1,
"sockets": [
"end_a",
"end_b"
]
},
"angle": {
"faces": 8,
"shells": 1,
"sockets": [
"end_a",
"end_b"
]
},
"box_beam": {
"faces": 6,
"shells": 1,
"sockets": [
"end_a",
"end_b"
]
},
"truss": {
"faces": 114,
"shells": 19,
"sockets": [
"end_a",
"end_b"
]
},
"portal": {
"faces": 38,
"shells": 1,
"sockets": [
"foot_a",
"foot_b"
]
},
"gusset": {
"faces": 7,
"shells": 1,
"sockets": [
"leg_a",
"leg_b"
]
},
"wedge": {
"faces": 6,
"shells": 1,
"sockets": [
"base",
"back"
]
}
},
"placed": {
"nozzle": {
"faces": 994,
@ -469,6 +654,30 @@
"base",
"base_back",
"rod_end",
"rod_end_back",
"port_cap",
"port_rod"
]
},
"ram_barrel": {
"faces": 180,
"shells": 12,
"bevel": 0.0024,
"sockets": [
"base",
"base_back",
"bore",
"port_cap",
"port_rod"
]
},
"ram_rod": {
"faces": 58,
"shells": 3,
"bevel": 0.0024,
"sockets": [
"piston",
"rod_end",
"rod_end_back"
]
},

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,7 @@
"detail": null
},
{
"name": "a part nobody attached reports connection null and baked false",
"name": "a part nobody attached reports connection null",
"ok": true,
"detail": null
},
@ -497,42 +497,217 @@
"detail": null
},
{
"name": "refused, scene unchanged: apply on a mesh that is not a kit part",
"name": "refused, scene unchanged: freeze on a mesh with no modifiers",
"ok": true,
"detail": null
},
{
"name": "apply makes the evaluated mesh the tank's mesh: the same faces and volume, no modifiers, one mesh datablock of the old name",
"name": "refused, scene unchanged: thaw on a live part",
"ok": true,
"detail": null
},
{
"name": "apply keeps the material slots exactly, and faces of both materials",
"name": "refused, scene unchanged: freeze on a part with a modifier already off names it",
"ok": true,
"detail": null
},
{
"name": "apply marks the part baked and keeps what it is",
"name": "freeze makes the evaluated mesh the tank's mesh: the same faces, volume and non-manifold edges, and the tank still evaluates to them",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: set_params on a baked part",
"name": "freeze holds the live mesh in kit_frozen and keeps the stack, off, with its collection and cutter",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: apply on a baked part with no modifiers left",
"name": "freeze keeps the material slots exactly, and faces of both materials",
"ok": true,
"detail": null
},
{
"name": "a baked part still reports its sockets where its params put them, and what is attached to it still holds",
"name": "a frozen part keeps what it is",
"ok": true,
"detail": null
},
{
"name": "a new part attaches to a baked one",
"name": "refused, scene unchanged: set_params on a frozen part",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: boolean on a frozen part",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: cut on a frozen part",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: cut_many on a frozen part",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: freeze on a frozen part",
"ok": true,
"detail": null
},
{
"name": "a frozen part still reports its sockets where its params put them, and what is attached to it still holds",
"ok": true,
"detail": null
},
{
"name": "a new part attaches to a frozen one",
"ok": true,
"detail": null
},
{
"name": "a frozen child rolls where it hangs on a frozen parent, and what hangs on it follows",
"ok": true,
"detail": null
},
{
"name": "the held live mesh survives a purge of orphans",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: setObjectCustomProperty on kit_frozen",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: setObjectCustomProperty on customProperties.kit_frozen",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: setObjectCustomProperty on kit_roll",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: setObjectCustomProperty on kit_anything",
"ok": true,
"detail": null
},
{
"name": "a frozen part with a modifier shown again reports dirty with the modifier, and not frozen",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: exportGltf applying modifiers over a dirty frozen part: the scene",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: exportGltf applying modifiers over a dirty frozen part: the part by name",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: set_params on a dirty frozen part, named dirty as its report names it",
"ok": true,
"detail": null
},
{
"name": "a frozen part with a modifier shown in renders only reports dirty",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: exportGltf applying modifiers over a frozen part dirty in renders only",
"ok": true,
"detail": null
},
{
"name": "with the modifier hidden again the part reports frozen; the refused exports wrote nothing",
"ok": true,
"detail": null
},
{
"name": "thaw puts the live mesh back, turns every modifier on and removes the frozen mesh",
"ok": true,
"detail": null
},
{
"name": "the thawed tank evaluates to what it did before freeze, and reports frozen false",
"ok": true,
"detail": null
},
{
"name": "a live mesh whose kit_frozen was overwritten by hand survives a purge of orphans",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: thaw on a frozen part whose kit_frozen was overwritten names the kept mesh",
"ok": true,
"detail": null
},
{
"name": "and with the kept mesh put back in kit_frozen it thaws",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: thaw on a frozen part whose held mesh was removed",
"ok": true,
"detail": null
},
{
"name": "thaw after an export that applied modifiers leaves no frozen mesh behind",
"ok": true,
"detail": null
},
{
"name": "freeze gives the live mesh a fake user and kit_kept, a pointer to the frozen mesh; a save writes both",
"ok": true,
"detail": null
},
{
"name": "deleteObject on a frozen object releases its live mesh: a purge takes it and the frozen mesh",
"ok": true,
"detail": null
},
{
"name": "importGltf drops the kit_* properties a file's extras carry, and says so: the imported object is not frozen and not a part",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: thaw on the imported object",
"ok": true,
"detail": null
},
{
"name": "a frozen object deleted in Blender, by no action: a save writes neither mesh, and a purge takes both",
"ok": true,
"detail": null
},
{
"name": "a kept mesh whose kit_kept was cleared by hand still gives its fake user back at thaw",
"ok": true,
"detail": null
},
{
"name": "a live mesh whose kit_frozen was deleted by hand stays kept through a purge and a save",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: thaw on a frozen part whose kit_frozen was deleted names the kept mesh",
"ok": true,
"detail": null
},
{
"name": "and with kit_frozen pointed back it thaws and the mesh is released",
"ok": true,
"detail": null
},
@ -542,22 +717,17 @@
"detail": null
},
{
"name": "refused, scene unchanged: apply on a mesh a linked duplicate shares",
"name": "freeze on a part with no material slot leaves the frozen mesh with none (Blender's Boolean shows it with one empty slot); a linked duplicate keeps the live mesh",
"ok": true,
"detail": null
},
{
"name": "apply on a part with no material slot leaves it with none (Blender's Boolean shows it with one empty slot)",
"name": "a thawed part is cut and frozen again; a cutter that has a material brings it after the part's own slots, on the faces it made",
"ok": true,
"detail": null
},
{
"name": "a baked part is cut and baked again; a cutter that has a material brings it after the part's own slots, on the faces it made",
"ok": true,
"detail": null
},
{
"name": "a vent that fits attaches to the baked plate's front",
"name": "a vent that fits attaches to the frozen plate's front",
"ok": true,
"detail": null
},
@ -577,12 +747,12 @@
"detail": null
},
{
"name": "apply keeps a part's own empty last slot when the cutter has no material",
"name": "freeze keeps a part's own empty last slot when the cutter has no material",
"ok": true,
"detail": null
},
{
"name": "apply leaves no face outside the material slots when a cutter's first slot is empty",
"name": "freeze leaves no face outside the material slots when a cutter's first slot is empty",
"ok": true,
"detail": null
},
@ -590,6 +760,16 @@
"name": "and each face keeps its own slot: the cutter's brass faces are brass, the faces from its empty slot and the plate's own are the plate's paint",
"ok": true,
"detail": null
},
{
"name": "removing an orphan mesh re-evaluates the three live cut tanks, and none of them frozen",
"ok": true,
"detail": null
},
{
"name": "and the update with them frozen costs under the bound of what it costs with them live",
"ok": true,
"detail": null
}
],
"hostErrors": [],
@ -637,5 +817,29 @@
"volume": 0.006031088,
"nonManifoldEdges": 0
},
"frozenCost": {
"live": [
[
"Cold0",
"Cold1",
"Cold2"
],
[
"Cold0",
"Cold1",
"Cold2"
],
[
"Cold0",
"Cold1",
"Cold2"
]
],
"frozen": [
[],
[],
[]
]
},
"ok": true
}

View file

@ -0,0 +1,398 @@
"""Live proof, in a background Blender, of brokkr_kitbash.shell's free cage through run_intent: a cage of triangles
and quads with declared poles becomes a shell whose subdivided face count is the reported one at each level, takes a
wall, counts folds and is cut; a narrow plate's wall throws no needle and a hexagon's thin wall does not fold; a
mirrored cage closes over its seam; a loft shell is rebuilt in place as a free cage
under its cutters; the pole gate refuses without writing; tools/cage_export.py reads a cage back, an open one
included, as its maker's Subdivision draws it; and tools/cage_score.py ranks a near copy, a moved vertex, an
over-creased and a creaseless cage in that order. Not part of the unittest run: it needs Blender.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/kitbash_cage.py -- <out>
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). <out> is an absolute path; writes <out>.result.json and exits 1 when a check failed.
Bounds follow lodur:ruling:deterministic-bound-margin: each sits at the geometric mean of the shipped reading and
its mutant's, both written beside it, and is compared as it stands; an order between two readings asks 1.2
between them; the result file carries the readings. The checks run inside
one try: an uncaught error is a failed check that names its section, and the result file is always written.
"""
import importlib.util
import json
import math
import os
import sys
import tempfile
import traceback
import types
from pathlib import Path
import bmesh
import bpy
import numpy as np
SURFACE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(SURFACE / "tools"))
import private_dirs # noqa: E402
_refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if _refused:
raise SystemExit(_refused)
OUT = sys.argv[sys.argv.index("--") + 1]
if not Path(OUT).is_absolute():
raise SystemExit(f"{OUT!r} is not an absolute path")
package = types.ModuleType("brokkr_bridge")
package.__path__ = [str(SURFACE / "brokkr_bridge")]
sys.modules["brokkr_bridge"] = package
from brokkr_bridge import blender_target as bt # noqa: E402
import addon_utils # noqa: E402
import cage_export # noqa: E402
import cage_score # noqa: E402
core = cage_export.load_core()
sys.path.append(str(SURFACE))
bpy.ops.wm.read_factory_settings(use_empty=True)
for module in ("brokkr_mesh_polish", "brokkr_kitbash"):
addon_utils.enable(module, default_set=True)
target = bt.BrokkrBlenderTarget(bpy)
WORK = Path(tempfile.mkdtemp(prefix="brokkr-kitbash-cage-"))
target.configure_action_dirs("", str(WORK))
target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1], "readings": {}}
COUNT, SECTION = [0], ["setup"]
# Degrees: the largest dihedral angle across an edge of the tent's subdivided surface off its boundary; it is on the
# creased ridge. Shipped 71; least claimed mutant 16 (K1, the free form's creases not written to crease_edge: the
# ridge subdivides smooth), read here by clearing the attribute; the geometric mean, separation 2.1 each side.
CRISP = 34.0
# Per cent of the reference's extent: cage_score's Hausdorff distance. Shipped (the tent against itself) 0, read as
# 5e-5 (the reading is rounded to 1e-4); the mutant is one stated move, the apex lifted 5% of the extent, 3.3; the
# geometric mean, separation 260 each side. A smaller move is not claimed.
SAME = 1.3e-2
# Per cent of extent: the worst distance, both ways, between an open plate as Blender's Subdivision at Boundary Smooth
# All draws it and as shell builds cage_export's document of it. Shipped 1.7e-5; mutant B1 (the shell's Kit Subsurf at
# Keep Corners, read here by setting it) 7.7; the geometric mean, separation 670 each side. A closed cage does not tell
# the two apart, and a hand-modelled hull's own round trip is 0.28 (its seam snap): the open plate stands inside that.
OPEN = 1.1e-2
# Wall thicknesses: how far the furthest vertex of a narrow plate, as evaluated, stands beyond its cage's bounds.
# Shipped 0.95; mutant W1 (Kit Solidify at even offset, read here by setting it: a pinned corner's vertex moves the
# thickness over the cosine of its crease's half-angle) 3.28; the geometric mean, separation 1.86 each side.
NEEDLE = 1.77
# Inner faces of a hexagon plate's wall that fold, read as the count + 1. Shipped 0, read 1; W1 20, read 21; the
# geometric mean, separation 4.6 each side.
FOLDS = 4.6
# A tent: four triangles round an apex of valence 4 with two ridges creased, and a quad hung under one edge: 7
# vertices, vertices 1 and 2 boundary poles of valence 4.
TENT = {"verts": [[0.0, 0.0, 0.5], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [-1.0, 0.0, 0.0], [0.0, -1.0, 0.0], [1.0, 0.0, -1.0], [0.0, 1.0, -1.0]],
"faces": [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 1], [2, 1, 5, 6]], "creases": [[0, 1, 1.0], [0, 3, 1.0]], "poles": [1, 2], "rim": 0.0}
# Half a lozenge hull, mirrored: seam vertices 0 to 3 (one 4 mm off the plane), a nose and tail triangle each side.
HULL = {"verts": [[0.0, -1.0, 0.0], [0.004, 0.0, 0.3], [0.0, 1.0, 0.0], [0.0, 0.0, -0.3], [0.6, 0.0, 0.0]],
"faces": [[0, 4, 1], [1, 4, 2], [2, 4, 3], [3, 4, 0]], "creases": [[0, 4, 1.0], [4, 2, 1.0]], "mirror": True}
LOFT = {"rings": [[[0.3 * j - 0.45, 0.02 * j * j, 0.3 * i] for j in range(4)] for i in range(3)], "flip": True}
# Two crowns, each the outline of a plate's raised face in the plane y = 0: a strip 0.13 m wide and 1.2 m long, and a hexagon 1.2 m across.
STRIP = [[-0.06, 0.0, 0.6], [-0.07, 0.0, -0.6], [0.07, 0.0, -0.6], [0.06, 0.0, 0.6]]
HEXAGON = [[-0.5, 0.0, 0.6], [-0.62, 0.0, 0.1], [-0.4, 0.0, -0.7], [0.4, 0.0, -0.7], [0.62, 0.0, 0.1], [0.5, 0.0, 0.6]]
CUTS = [{"name": "TentLine", "part": "slab", "params": "gap=0.02; length=0.4; depth=0.03", "origin": [0.3, -0.35, 3.0], "direction": [0, 0, -1]}]
def check(name, ok, detail=None):
R["checks"].append({"name": name, "ok": bool(ok), "detail": None if ok else json.loads(json.dumps(detail, default=str))})
def section(name):
SECTION[0] = name
def send(action, **fields):
COUNT[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"live-{COUNT[0]}", "requestedBy": "nibu/hands", "action": action, **fields})
result = None
if receipt.get("hostResult"):
try:
result = json.loads(receipt["hostResult"])
except ValueError:
result = None
print("SEND", action, receipt["status"], str(receipt["message"])[:300], flush=True)
return receipt, result
def evaluated(obj, only=None):
"""An object as Blender evaluates it, as a bmesh; with `only`, with just the modifiers of those names shown."""
hidden = [m for m in obj.modifiers if only is not None and m.name not in only and m.show_viewport]
for m in hidden:
m.show_viewport = False
try:
bpy.context.view_layer.update()
owner = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
bm = bmesh.new()
bm.from_mesh(owner.to_mesh())
owner.to_mesh_clear()
finally:
for m in hidden:
m.show_viewport = True
bpy.context.view_layer.update()
bm.normal_update()
return bm
def sharpest(obj):
bm = evaluated(obj, only=("Kit Subsurf",))
worst = max(math.degrees(e.link_faces[0].normal.angle(e.link_faces[1].normal, 0.0)) for e in bm.edges if len(e.link_faces) == 2)
bm.free()
return worst
def crown_plate(crown, flare=0.06, drop=0.07, dome=0.03):
"""The cage of a plate as the mech experiments block one, facing -y: the crown ring with its sides creased, a skirt
ring flared out of it and dropped back, one centre vertex domed, every ring corner pinned: 2N + 1 vertices."""
P = np.array(crown, dtype=float)
N = len(P)
normal = np.cross(P, np.roll(P, -1, axis=0)).sum(axis=0)
if normal[1] > 0:
P, normal = P[::-1].copy(), -normal
normal, centre = normal / np.linalg.norm(normal), P.mean(axis=0)
out = (P - centre) - np.outer((P - centre) @ normal, normal)
skirt = P + flare * out / np.linalg.norm(out, axis=1)[:, None] - drop * normal
return {"verts": np.vstack([P, skirt, centre + dome * normal]).round(5).tolist(),
"faces": [[i, (i + 1) % N, 2 * N] for i in range(N)] + [[N + i, N + (i + 1) % N, (i + 1) % N, i] for i in range(N)],
"creases": [[i, (i + 1) % N, 1.0] for i in range(N)], "corners": [[i, 1.0] for i in range(2 * N)], "poles": [] if N == 4 else [2 * N], "rim": 0.0}
def beyond(obj, sheet):
"""Metres: how far the furthest vertex of an object, as evaluated, stands outside its cage's bounds along an axis."""
bm = evaluated(obj)
at = np.array([v.co[:] for v in bm.verts])
bm.free()
cage = np.array(sheet["verts"])
return float(max((cage.min(axis=0) - at).max(), (at - cage.max(axis=0)).max(), 0.0))
def state():
return {o.name: (sorted(k for k in o.keys() if k.startswith("kit_")), len(o.data.vertices) if o.type == "MESH" else None, [m.name for m in o.modifiers]) for o in bpy.data.objects}, sorted(m.name for m in bpy.data.meshes)
try:
# --- live-free-cage-shell: counts at each level ----------------------------------------------------------------
section("free-cage-triangle-counts")
for levels in (1, 2, 3):
receipt, report = send("brokkr_kitbash.shell", object_name="Tent", sheet=json.dumps(TENT), thickness=0.04, levels=levels, count_folds=True)
tent = bpy.data.objects.get("Tent")
expected = 1 * 4 ** levels + 4 * 3 * 4 ** (levels - 1)
bm = evaluated(tent, only=("Kit Subsurf",))
faces, sides = len(bm.faces), {len(f.verts) for f in bm.faces}
bm.free()
wall = evaluated(tent, only=("Kit Subsurf", "Kit Solidify"))
closed, walled = all(e.is_manifold for e in wall.edges), len(wall.faces)
wall.free()
check(f"a cage of 4 triangles and a quad at {levels} levels: subdividedFaces is 4^L + 4 * 3 * 4^(L-1) and the evaluated surface has that many faces, all quads",
receipt["status"] == "accepted" and report["subdividedFaces"] == expected == faces and sides == {4}, [receipt["message"], expected, faces, sides])
check(f"at {levels} levels the wall is closed, twice the surface and a rim, and count_folds counts none folded",
closed and walled == 2 * expected + 6 * 2 ** levels and report["folded"] == 0, [closed, walled, report and report["folded"]]) # the tent's boundary is 6 cage edges
built = core.sheet(TENT)
check("the report carries the cage's facts: 7 vertices, 5 faces of which 4 triangles, 2 creases, two poles of valence 4, open; rings and points null",
report and {k: report[k] for k in ("rings", "points", "cageVerts", "cageFaces", "triangles", "creases", "corners", "poles", "closed")}
== {"rings": None, "points": None, "cageVerts": 7, "cageFaces": 5, "triangles": 4, "creases": 2, "corners": 0, "poles": {"4": 2}, "closed": False}, report)
check("the cage mesh is core.sheet's, face for face, and kit_shell is the request",
[tuple(p.vertices) for p in tent.data.polygons] == [tuple(f) for f in TENT["faces"]] and np.abs(np.array([v.co[:] for v in tent.data.vertices]) - built.V).max() < 1e-6
and json.loads(tent["kit_shell"])["sheet"] == TENT, tent["kit_shell"])
# --- plain-wall: the Solidify's plain offset ---------------------------------------------------------------------------
section("plain-wall")
strip, hexagon = crown_plate(STRIP), crown_plate(HEXAGON)
receipt, report = send("brokkr_kitbash.shell", object_name="Strip", sheet=json.dumps(strip), thickness=0.04, levels=2, bevel=0.01)
plate = bpy.data.objects.get("Strip")
needle = beyond(plate, strip) / 0.04
plate.modifiers["Kit Solidify"].use_even_offset = True # W1
R["readings"].update({"needleThicknesses": needle, "needleThicknessesW1": beyond(plate, strip) / 0.04})
check(f"plain-wall-no-needle: a plate 0.13 m wide with a wall of 0.04 stands under {NEEDLE} thicknesses beyond its cage's bounds, and over that at even offset",
receipt["status"] == "accepted" and report["cageVerts"] == 9 and needle < NEEDLE < R["readings"]["needleThicknessesW1"], [receipt["message"], R["readings"]])
receipt, report = send("brokkr_kitbash.shell", object_name="Hexagon", sheet=json.dumps(hexagon), thickness=0.015, levels=2, count_folds=True)
plate = bpy.data.objects.get("Hexagon")
plate.modifiers["Kit Solidify"].use_even_offset = True # W1
even = sys.modules["brokkr_kitbash"].BROKKR_KITBASH_OT_shell.folded_faces(bpy.context, plate, report["subdividedFaces"])
R["readings"].update({"foldedPlusOne": report["folded"] + 1, "foldedPlusOneW1": even + 1})
check(f"plain-wall-folds: a hexagon plate 1.2 m across with a wall of 0.015 folds no inner face of its 168 (the count + 1 under {FOLDS}), and over that at even offset",
receipt["status"] == "accepted" and (report["cageVerts"], report["subdividedFaces"], report["poles"]) == (13, 168, {"6": 1}) and report["folded"] + 1 < FOLDS < even + 1, [receipt["message"], report, even])
for name in ("Strip", "Hexagon"):
mesh = bpy.data.objects[name].data
bpy.data.objects.remove(bpy.data.objects[name])
bpy.data.meshes.remove(mesh)
# --- the creases reach the surface -----------------------------------------------------------------------------------
section("free-cage-crisp")
crisp = sharpest(tent)
attribute = tent.data.attributes["crease_edge"]
kept = [d.value for d in attribute.data]
attribute.data.foreach_set("value", [0.0] * len(kept)) # K1: what the surface is when the creases are not written
tent.data.update()
soft = sharpest(tent)
attribute.data.foreach_set("value", kept)
tent.data.update()
R["readings"].update({"crispDegrees": crisp, "crispDegreesK1": soft})
check(f"the creased ridge stays an edge under subdivision: over {CRISP} degrees, and under it with crease_edge cleared", crisp > CRISP and soft < CRISP, [crisp, soft])
# --- cut -------------------------------------------------------------------------------------------------------------
section("live-free-cage-shell")
receipt, cut = send("brokkr_kitbash.cut_many", object_name="Tent", cuts=json.dumps(CUTS))
plate = evaluated(tent)
check("cut_many cuts a free-cage shell: the Boolean stands after the wall, the plate has more faces than the wall it was cut from (a Boolean that cut nothing leaves as many) and no non-manifold edge",
receipt["status"] == "accepted" and [m.name for m in tent.modifiers] == ["Kit Subsurf", "Kit Solidify", "Kit Difference"] and len(plate.faces) > walled
and sum(1 for e in plate.edges if not e.is_manifold) == 0, [receipt["message"], len(plate.faces), walled, sum(1 for e in plate.edges if not e.is_manifold)])
plate.free()
# --- mirror ----------------------------------------------------------------------------------------------------------
section("free-cage-mirror")
receipt, report = send("brokkr_kitbash.shell", object_name="Hull", sheet=json.dumps(HULL), thickness=0.01)
hull = bpy.data.objects.get("Hull")
bm = evaluated(hull, only=("Kit Subsurf",))
check("a mirrored cage closes over its seam: 6 vertices from 5, 8 triangles, the vertex 4 mm off the plane snapped onto it, no boundary edge on the cage or its surface, and its poles reported",
receipt["status"] == "accepted" and (report["cageVerts"], report["cageFaces"], report["triangles"], report["closed"], report["creases"], report["subdividedFaces"]) == (6, 8, 8, True, 4, 8 * 3 * 16)
and abs(hull.data.vertices[1].co.x) < 1e-9 and all(e.is_manifold for e in bm.edges) and len(bm.faces) == 384 and report["poles"] == {}, report)
bm.free()
# --- rebuild a loft as a free cage -------------------------------------------------------------------------------------
section("free-cage-rebuild")
receipt, _ = send("brokkr_kitbash.shell", object_name="Plate", sheet=json.dumps(LOFT), thickness=0.03)
plate_obj = bpy.data.objects["Plate"]
plate_obj.data.materials.append(bpy.data.materials.new("Khaki"))
receipt, _ = send("brokkr_kitbash.cut_many", object_name="Plate", cuts=json.dumps([{"name": "PlateLine", "part": "slab", "params": "gap=0.02; length=0.3; depth=0.02", "origin": [0.0, 3.0, 0.3], "direction": [0, -1, 0]}]))
before = (plate_obj.as_pointer(), plate_obj.data.as_pointer(), sorted(c.name for c in plate_obj.children), sorted(o.name for o in plate_obj.modifiers["Kit Difference"].collection.objects), [s.material.name for s in plate_obj.material_slots])
loft = core.sheet(LOFT)
quads = loft.faces.reshape(-1, 4).tolist()
FREE = {"verts": [[round(c, 6) for c in v] for v in loft.V.tolist()], "faces": quads[:5] + [quads[5][:3], [quads[5][0], quads[5][2], quads[5][3]]], "poles": [7, 10], "creases": [[5, 6, 1.0]]} # the last quad split along its diagonal: two boundary vertices of valence 4
receipt, report = send("brokkr_kitbash.shell", object_name="Plate", sheet=json.dumps(FREE), thickness=0.03)
again = bpy.data.objects.get("Plate")
after = (again.as_pointer(), again.data.as_pointer(), sorted(c.name for c in again.children), sorted(o.name for o in again.modifiers["Kit Difference"].collection.objects), [s.material.name for s in again.material_slots])
bm = evaluated(again)
check("a loft shell rebuilt in place as a free cage keeps its object, mesh datablock, cutter, Boolean and material slot; the report says rebuilt, 2 triangles and the cage's poles; the plate is still cut and closed",
receipt["status"] == "accepted" and before == after and before[2:] == (["PlateLine"], ["PlateLine"], ["Khaki"]) and report["rebuilt"] is True and (report["triangles"], report["rings"], report["cageFaces"]) == (2, None, 7)
and report["poles"] == {"4": 2} and report["children"] == ["PlateLine"] and sum(1 for e in bm.edges if not e.is_manifold) == 0 and len(bm.faces) > 2 * report["subdividedFaces"], [receipt["message"], report, before, after])
bm.free()
# --- the gate refuses before it writes -------------------------------------------------------------------------------
section("free-cage-refusals")
for label, name, sheet, expected in (
("an undeclared pole, on a shell", "Plate", {**FREE, "poles": [7]}, "sheet.poles lacks vertex 10 (valence 4, on the boundary)"),
("a declared vertex that is no pole, on a new name", "New", {**TENT, "poles": [1, 2, 0]}, "sheet.poles[2] names vertex 0 (valence 4), which is no pole"),
("rings with verts", "New", {**TENT, "rings": LOFT["rings"]}, "sheet states both rings and verts"),
("a face of five sides", "New", {**TENT, "faces": TENT["faces"][:4] + [[2, 1, 5, 6, 3]]}, "sheet.faces[4] must be 3 or 4 vertex indices, not 5"),
("two faces wound against each other", "Plate", {**FREE, "faces": FREE["faces"][:6] + [FREE["faces"][6][::-1]]}, "the two are wound against each other")):
held = state()
receipt, _ = send("brokkr_kitbash.shell", object_name=name, sheet=json.dumps(sheet))
check(f"refused, scene unchanged: {label}", receipt["status"] != "accepted" and expected in str(receipt["message"]) and state() == held, [receipt["status"], receipt["message"]])
check("no refusal made an object", "New" not in bpy.data.objects, None)
# --- export-score-roundtrip -----------------------------------------------------------------------------------------
section("export-score-roundtrip")
saved = str(WORK / "scratch.blend")
probe = bpy.data.objects.new("Probe Cage", bpy.data.meshes.new("Probe Cage")) # a cage as a person leaves one: a mesh, a Mirror, creases on edges; made here, no one's file
bpy.context.scene.collection.objects.link(probe)
probe.data.from_pydata(HULL["verts"], [], HULL["faces"])
probe.data.update(calc_edges=True)
weights = probe.data.attributes.new("crease_edge", "FLOAT", "EDGE")
for e in probe.data.edges:
weights.data[e.index].value = 1.0 if tuple(sorted(e.vertices)) in ((0, 4), (2, 4)) else 0.0
probe.modifiers.new("Mirror", "MIRROR")
probe.modifiers.new("Subdivision", "SUBSURF")
document = cage_export.export(probe, core)
exported = document["sheet"]
check("cage_export reads a mirrored, creased mesh as the free cage it is: the vertices as authored and the seam snapped when built, the creases by vertex pair, mirror set, rim 0, the poles computed, and core.sheet takes it",
exported["verts"][1] == [0.004, 0.0, 0.3] and core.sheet(exported).V[1].tolist() == [0.0, 0.0, 0.3] and exported["faces"] == HULL["faces"] and exported["creases"] == [[0, 4, 1.0], [2, 4, 1.0]] and exported["mirror"] is True
and exported["rim"] == 0.0 and exported["poles"] == [] and document["modifiers"] == [["MIRROR", "Mirror"], ["SUBSURF", "Subdivision"]]
and np.array_equal(core.sheet(exported).faces, core.sheet(HULL).faces), document)
bpy.data.objects.remove(probe)
# an open plate as a person leaves one: a bulge, one creased ridge, an uncreased outline, Subdivision at Boundary Smooth All
grid = [[i - 1.5, j - 1.5, 0.4 * math.cos(i - 1.5) * math.cos(j - 1.5)] for i in range(4) for j in range(4)]
open_plate = bpy.data.objects.new("Open Plate", bpy.data.meshes.new("Open Plate"))
bpy.context.scene.collection.objects.link(open_plate)
open_plate.data.from_pydata(grid, [], [[4 * i + j, 4 * i + 4 + j, 4 * i + 5 + j, 4 * i + 1 + j] for i in range(3) for j in range(3)])
open_plate.data.update(calc_edges=True)
weights = open_plate.data.attributes.new("crease_edge", "FLOAT", "EDGE")
for e in open_plate.data.edges:
weights.data[e.index].value = 1.0 if all(v // 4 == 1 for v in e.vertices) else 0.0
by_hand = open_plate.modifiers.new("Subdivision", "SUBSURF")
by_hand.levels, by_hand.boundary_smooth = 3, "ALL"
bm = evaluated(open_plate)
VH = np.array([v.co[:] for v in bm.verts])
TH = np.array([[f.verts[0].index, f.verts[k].index, f.verts[k + 1].index] for f in bm.faces for k in (1, 2)])
bm.free()
document = cage_export.export(open_plate, core)
receipt, report = send("brokkr_kitbash.shell", object_name="Open Shell", sheet=json.dumps(document["sheet"]), levels=3, thickness=0.001)
shell_obj = bpy.data.objects["Open Shell"]
worst = {}
for mode in ("ALL", "PRESERVE_CORNERS"): # the second is B1
kept, shell_obj.modifiers["Kit Subsurf"].boundary_smooth = shell_obj.modifiers["Kit Subsurf"].boundary_smooth, mode
VS, TS, _, _ = cage_score.surface(shell_obj)
worst[mode] = float(max(cage_score.nearest(VS, VH, TH).max(), cage_score.nearest(VH, VS, TS).max()) / np.ptp(VH, axis=0).max() * 100.0)
shell_obj.modifiers["Kit Subsurf"].boundary_smooth = kept
R["readings"].update({"openRoundTripPct": worst["ALL"], "openRoundTripPctB1": worst["PRESERVE_CORNERS"]})
check(f"an open cage round-trips: shell builds cage_export's document of a plate with an uncreased outline as its Subdivision (Boundary Smooth All) draws it, under {OPEN}% of extent, and over it at Keep Corners",
receipt["status"] == "accepted" and kept == "ALL" and report["closed"] is False and document["sheet"]["corners"] == [] and worst["ALL"] < OPEN < worst["PRESERVE_CORNERS"], [receipt["message"], worst])
by_hand.boundary_smooth = "PRESERVE_CORNERS"
try:
cage_export.export(open_plate, core)
said = None
except core.KitError as error:
said = str(error)
check("cage_export refuses a Subdivision at Keep Corners, saying how to state the corners", said is not None and "Boundary Smooth Keep Corners" in said and "vertex crease of 1" in said, said)
bpy.data.objects.remove(shell_obj)
bpy.data.objects.remove(open_plate)
# --- score-ranks ---------------------------------------------------------------------------------------------------
section("score-ranks")
tent_document = {**TENT, "rim": 1.0}
held = state()
same = cage_score.score(tent_document, tent_document, send)
check("cage_score of a cage against itself: equal counts, distance 0, every silhouette IoU 1, no sharp feature missed or spurious, the cost its complexity alone, and its two shells removed again",
same["agent"] == same["reference"] and same["agent"]["cageVerts"] == 7 and same["distance"]["hausdorffPct"] < SAME and set(same["silhouetteIoU"].values()) == {1.0}
and (same["crease"]["missPct"], same["crease"]["spurPct"]) == (0.0, 0.0) and same["crease"]["agentSharp"] == same["crease"]["referenceSharp"] > 0
and same["cost"]["complexity"] == round(7 * cage_score.C_REP + 8 * cage_score.C_SHARP, 4) and abs(same["cost"]["total"] - same["cost"]["complexity"]) < SAME and state() == held, same)
lifted = cage_score.score({**tent_document, "verts": [[0.0, 0.0, 0.5 + 0.05 * 2.0]] + TENT["verts"][1:]}, tent_document, send) # the apex lifted 5% of the 2 m extent
R["readings"].update({"scoreSameHausdorffPct": same["distance"]["hausdorffPct"], "scoreLiftedHausdorffPct": lifted["distance"]["hausdorffPct"]})
check("cage_score of the tent with its apex lifted 5% of the extent: Hausdorff distance above the bound, a silhouette under 1, the counts and the extent still the reference's",
lifted["distance"]["hausdorffPct"] > SAME and min(lifted["silhouetteIoU"].values()) < 1.0 and lifted["agent"] == lifted["reference"] and abs(lifted["extent"] - same["extent"]) < 1e-9, lifted)
# A box of 26 vertices and 24 quads, its lid's outline creased: the reference. Four agents against it.
points = [(x, y, z) for x in (-1, 0, 1) for y in (-1, 0, 1) for z in (-1, 0, 1) if (x, y, z) != (0, 0, 0)]
at = {point: k for k, point in enumerate(points)}
quads = []
for axis in range(3):
for side in (-1, 1):
for a in (-1, 0):
for b in (-1, 0):
quad = []
for da, db in ((0, 0), (1, 0), (1, 1), (0, 1)):
point = [0, 0, 0]
point[axis], point[(axis + 1) % 3], point[(axis + 2) % 3] = side, a + da, b + db
quad.append(at[tuple(point)])
quads.append(quad if side > 0 else quad[::-1])
cage_edges = sorted({tuple(sorted((q[k], q[k - 1]))) for q in quads for k in range(4)})
BOX = {"verts": [[0.6 * x, 1.0 * y, 0.4 * z] for x, y, z in points], "faces": quads,
"creases": [[a, b, 1.0] for a, b in cage_edges if points[a][2] == points[b][2] == 1 and (0, 0, 1) not in (points[a], points[b])]}
BOX["poles"] = core.poles(BOX)
shaken = (np.array(BOX["verts"]) + np.random.default_rng(7).normal(size=(26, 3)) * 0.005 * 2.0 / math.sqrt(3)).round(6).tolist()
agents = {"Self": BOX, "Near": {**BOX, "verts": shaken}, # every vertex off by 0.5% of the 2 m extent
"Moved": {**BOX, "verts": [[v[0], v[1] + 0.05 * 2.0, v[2]] if k == at[(1, 1, 1)] else v for k, v in enumerate(BOX["verts"])]}, # one vertex, 5% of the extent
"Over": {**BOX, "creases": [[a, b, 1.0] for a, b in cage_edges]}, # every edge creased: the box as a polyhedron
"Bare": {**BOX, "creases": []}} # no crease: a smooth blob
read = {label: cage_score.score(agent, BOX, send) for label, agent in agents.items()}
cost = {label: reading["cost"]["total"] for label, reading in read.items()}
R["readings"].update({f"cost{label}": value for label, value in cost.items()})
R["readings"].update({"costMovedHausdorffPct": read["Moved"]["distance"]["hausdorffPct"], "costBareMissPct": read["Bare"]["crease"]["missPct"], "costOverSpurPct": read["Over"]["crease"]["spurPct"]})
check("the cost ranks: the reference itself is cheapest, and a near copy (every vertex 0.5% off) beats a creaseless cage, each by 1.2 or more",
len(BOX["creases"]) == 8 and cost["Self"] * 1.2 < cost["Near"] and cost["Near"] * 1.2 < cost["Bare"] and read["Bare"]["crease"]["missPct"] > read["Near"]["crease"]["missPct"], [cost, read["Bare"]["crease"]])
check("one vertex moved 5% of the extent registers: its Hausdorff distance is over the bound and its cost 1.2 over the reference's own, though the median and the silhouettes barely see it",
read["Moved"]["distance"]["hausdorffPct"] > SAME and cost["Self"] * 1.2 < cost["Moved"], read["Moved"])
check("an over-creased cage costs more than the reference, by its spurious sharp features and its sharp edges' price",
cost["Self"] * 1.2 < cost["Over"] and read["Over"]["crease"]["spurPct"] > 0.0 and read["Over"]["cost"]["complexity"] > read["Self"]["cost"]["complexity"], read["Over"])
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, not a missing result file
check(f"no uncaught error in section: {SECTION[0]}", False, traceback.format_exc().splitlines()[-6:])
finally:
R["ok"] = all(c["ok"] for c in R["checks"])
R["readings"] = {name: float(f"{value:.2g}") for name, value in sorted(R["readings"].items())}
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
print("READINGS", R["readings"], flush=True)
sys.exit(0 if R["ok"] else 1)

View file

@ -0,0 +1,167 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "a cage of 4 triangles and a quad at 1 levels: subdividedFaces is 4^L + 4 * 3 * 4^(L-1) and the evaluated surface has that many faces, all quads",
"ok": true,
"detail": null
},
{
"name": "at 1 levels the wall is closed, twice the surface and a rim, and count_folds counts none folded",
"ok": true,
"detail": null
},
{
"name": "a cage of 4 triangles and a quad at 2 levels: subdividedFaces is 4^L + 4 * 3 * 4^(L-1) and the evaluated surface has that many faces, all quads",
"ok": true,
"detail": null
},
{
"name": "at 2 levels the wall is closed, twice the surface and a rim, and count_folds counts none folded",
"ok": true,
"detail": null
},
{
"name": "a cage of 4 triangles and a quad at 3 levels: subdividedFaces is 4^L + 4 * 3 * 4^(L-1) and the evaluated surface has that many faces, all quads",
"ok": true,
"detail": null
},
{
"name": "at 3 levels the wall is closed, twice the surface and a rim, and count_folds counts none folded",
"ok": true,
"detail": null
},
{
"name": "the report carries the cage's facts: 7 vertices, 5 faces of which 4 triangles, 2 creases, two poles of valence 4, open; rings and points null",
"ok": true,
"detail": null
},
{
"name": "the cage mesh is core.sheet's, face for face, and kit_shell is the request",
"ok": true,
"detail": null
},
{
"name": "plain-wall-no-needle: a plate 0.13 m wide with a wall of 0.04 stands under 1.77 thicknesses beyond its cage's bounds, and over that at even offset",
"ok": true,
"detail": null
},
{
"name": "plain-wall-folds: a hexagon plate 1.2 m across with a wall of 0.015 folds no inner face of its 168 (the count + 1 under 4.6), and over that at even offset",
"ok": true,
"detail": null
},
{
"name": "the creased ridge stays an edge under subdivision: over 34.0 degrees, and under it with crease_edge cleared",
"ok": true,
"detail": null
},
{
"name": "cut_many cuts a free-cage shell: the Boolean stands after the wall, the plate has more faces than the wall it was cut from (a Boolean that cut nothing leaves as many) and no non-manifold edge",
"ok": true,
"detail": null
},
{
"name": "a mirrored cage closes over its seam: 6 vertices from 5, 8 triangles, the vertex 4 mm off the plane snapped onto it, no boundary edge on the cage or its surface, and its poles reported",
"ok": true,
"detail": null
},
{
"name": "a loft shell rebuilt in place as a free cage keeps its object, mesh datablock, cutter, Boolean and material slot; the report says rebuilt, 2 triangles and the cage's poles; the plate is still cut and closed",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: an undeclared pole, on a shell",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a declared vertex that is no pole, on a new name",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: rings with verts",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a face of five sides",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: two faces wound against each other",
"ok": true,
"detail": null
},
{
"name": "no refusal made an object",
"ok": true,
"detail": null
},
{
"name": "cage_export reads a mirrored, creased mesh as the free cage it is: the vertices as authored and the seam snapped when built, the creases by vertex pair, mirror set, rim 0, the poles computed, and core.sheet takes it",
"ok": true,
"detail": null
},
{
"name": "an open cage round-trips: shell builds cage_export's document of a plate with an uncreased outline as its Subdivision (Boundary Smooth All) draws it, under 0.011% of extent, and over it at Keep Corners",
"ok": true,
"detail": null
},
{
"name": "cage_export refuses a Subdivision at Keep Corners, saying how to state the corners",
"ok": true,
"detail": null
},
{
"name": "cage_score of a cage against itself: equal counts, distance 0, every silhouette IoU 1, no sharp feature missed or spurious, the cost its complexity alone, and its two shells removed again",
"ok": true,
"detail": null
},
{
"name": "cage_score of the tent with its apex lifted 5% of the extent: Hausdorff distance above the bound, a silhouette under 1, the counts and the extent still the reference's",
"ok": true,
"detail": null
},
{
"name": "the cost ranks: the reference itself is cheapest, and a near copy (every vertex 0.5% off) beats a creaseless cage, each by 1.2 or more",
"ok": true,
"detail": null
},
{
"name": "one vertex moved 5% of the extent registers: its Hausdorff distance is over the bound and its cost 1.2 over the reference's own, though the median and the silhouettes barely see it",
"ok": true,
"detail": null
},
{
"name": "an over-creased cage costs more than the reference, by its spurious sharp features and its sharp edges' price",
"ok": true,
"detail": null
}
],
"hostErrors": [],
"readings": {
"costBare": 58.0,
"costBareMissPct": 100.0,
"costMoved": 3.4,
"costMovedHausdorffPct": 2.7,
"costNear": 1.2,
"costOver": 27.0,
"costOverSpurPct": 22.0,
"costSelf": 0.28,
"crispDegrees": 71.0,
"crispDegreesK1": 16.0,
"foldedPlusOne": 1.0,
"foldedPlusOneW1": 21.0,
"needleThicknesses": 0.95,
"needleThicknessesW1": 3.3,
"openRoundTripPct": 1.7e-05,
"openRoundTripPctB1": 7.7,
"scoreLiftedHausdorffPct": 3.3,
"scoreSameHausdorffPct": 0.0
},
"ok": true
}

View file

@ -0,0 +1,457 @@
"""Live proof, in a background Blender, of brokkr_kitbash.shell through run_intent: a loft of rings becomes a cage whose
crease runs stay crisp under subdivision while the rest stays smooth, a wall of plain offset with a filled rim, a
mirror, a rebuild in place under cutters and ribs, cut_many and ribs on the shell, and the refusals. Not part of the
unittest run: it needs Blender.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/kitbash_faceted.py -- <out>
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). <out> is an absolute path; writes <out>.result.json and exits 1 when a check failed.
Bounds follow lodur:ruling:deterministic-bound-margin: each sits at the geometric mean of the shipped worst reading
and the least claimed mutant's, both written beside it; the result file carries the readings. Costs are wall times
of this run, reported and never bounded. The checks run inside one try: an uncaught error is a failed check that
names its section, and the result file is always written.
"""
import importlib.util
import json
import math
import os
import statistics
import sys
import tempfile
import time
import traceback
import types
from pathlib import Path
import bmesh
import bpy
import numpy as np
from mathutils import Matrix, Vector
from mathutils.bvhtree import BVHTree
from mathutils.geometry import normal as triangle_normal
SURFACE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(SURFACE / "tools"))
import private_dirs # noqa: E402
_refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if _refused:
raise SystemExit(_refused)
OUT = sys.argv[sys.argv.index("--") + 1]
if not Path(OUT).is_absolute():
raise SystemExit(f"{OUT!r} is not an absolute path")
package = types.ModuleType("brokkr_bridge")
package.__path__ = [str(SURFACE / "brokkr_bridge")]
sys.modules["brokkr_bridge"] = package
from brokkr_bridge import blender_target as bt # noqa: E402
import addon_utils # noqa: E402
spec = importlib.util.spec_from_file_location("brokkr_kitbash_core_reference", SURFACE / "brokkr_kitbash" / "core.py")
core = importlib.util.module_from_spec(spec) # core as the unit tests load it
spec.loader.exec_module(core)
sys.path.append(str(SURFACE))
bpy.ops.wm.read_factory_settings(use_empty=True)
for module in ("brokkr_mesh_polish", "brokkr_kitbash"):
addon_utils.enable(module, default_set=True)
target = bt.BrokkrBlenderTarget(bpy)
WORK = Path(tempfile.mkdtemp(prefix="brokkr-kitbash-faceted-"))
target.configure_action_dirs("", str(WORK))
target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1], "readings": {}, "costs": {}}
COUNT, SECTION = [0], ["setup"]
WALL = 0.06
# Degrees: the largest dihedral angle anywhere inside the subdivided pauldron (not on its rim), which is on its creased
# column. Shipped 52; least claimed mutant 6.5 (S1, crease_edge not written: the cage subdivides smooth); the geometric
# mean, separation 2.8 each side.
CRISP = 18.0
# Degrees: the largest dihedral angle across a subdivided edge that carries no crease. Shipped 5.8; least claimed
# mutant 25 (W1, the weights written at the creases' own indices, not at the edges found by vertex pair: a crease
# lands on an edge that should have none); the geometric mean, separation 2.07 each side. C1 (a Subdivision that only
# splits, SIMPLE: every cage edge stays an edge) reads 51 here. S1 reads 6.5, 1.13 of shipped: CRISP claims it. W1 is
# also caught by the exact check below, crease_edge edge for edge.
SOFT = 12.0
# Metres from a corner of a sheet whose rim is 0 to the nearest vertex of its subdivided surface: with corners preserved
# the surface keeps the cage's corner. Shipped 0 (read as 1e-7, what a float32 mesh is good to); least claimed mutant
# 0.15 (S5, boundary_smooth ALL: the corner rounds off); the geometric mean, separation 900 each side.
CORNER = 1.6e-4
# The wall's volume over the designed surface's area times the thickness, less 1, as a magnitude. Shipped 0.028 (a wall
# grown inward loses volume inside the crown's curve, and a plain offset is thinner behind the creased shoulder); least
# claimed mutant 0.071 (S6, the Solidify above the Subdivision: the wall's own edges are rounded off); the geometric
# mean, separation 1.58 each side.
SOLID = 0.0447
# Metres between the thickness and the distance from a vertex of the wall's inner face to the designed surface. Shipped
# 0.0061 (a plain offset behind the creased shoulder: the wall is 0.0539 there, the thickness x cos(phi)); least claimed
# mutant 0.024 (S6: the inner face is subdivided again and pulls in); the geometric mean, separation 1.99 each side.
WALL_OFF = 0.0122
# Metres: the thickness at which the wedge of shell-fold folds, (W / 2^levels) / sin(phi) of its narrower facet, as
# measured on flat facets (docs/kitbash.md, Thickness at a crease). The wall is built at FOLD / FOLD_STEP (no inner
# face folded) and at FOLD x FOLD_STEP (some folded); FOLD_STEP is the 1.2 separation the margin rule asks on each
# side of the onset. The counts themselves are exact: count_folds is held to this script's own count, face for face.
FOLD, FOLD_STEP = 0.106, 1.2
def check(name, ok, detail=None):
try:
json.dumps(detail, default=str)
except TypeError: # a detail keyed by vertex pairs: the result file takes it as text, so a failed check is written and not a crash
detail = repr(detail)
R["checks"].append({"name": name, "ok": bool(ok), "detail": None if ok else detail})
def reading(name, value, least=False):
"""The worst of a metric: the largest, or with `least` the smallest."""
R["readings"][name] = (min if least else max)(R["readings"].get(name, float(value)), float(value))
return float(value)
def section(name):
SECTION[0] = name
def send(action, **fields):
COUNT[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"live-{COUNT[0]}", "requestedBy": "nibu/hands", "action": action, **fields})
result = None
if receipt.get("hostResult"):
try:
result = json.loads(receipt["hostResult"])
except ValueError:
result = None
print("SEND", action, receipt["status"], str(receipt["message"])[:300], flush=True)
return receipt, result
def scene_state():
return {o.name: (o.parent and o.parent.name, np.round(np.array(o.matrix_basis), 6).tolist(), {k: repr(o[k]) for k in sorted(o.keys()) if k.startswith("kit_")},
[(m.name, m.type, m.show_viewport) for m in o.modifiers], o.data.name if o.type == "MESH" else None, len(o.data.polygons) if o.type == "MESH" else None,
np.round(points(o), 6).tolist() if o.type == "MESH" else None)
for o in bpy.data.objects}, sorted(m.name for m in bpy.data.meshes), sorted(c.name for c in bpy.data.collections)
def refused(label, fields, expected):
state = scene_state()
receipt, _ = send("brokkr_kitbash.shell", **fields)
check(f"refused, scene unchanged: {label}", receipt["status"] != "accepted" and expected in str(receipt["message"]) and scene_state() == state,
[receipt["status"], receipt["message"]])
def points(obj):
V = np.zeros(3 * len(obj.data.vertices))
obj.data.vertices.foreach_get("co", V)
return V.reshape(-1, 3)
def evaluated(obj, off=()):
"""This script's own copy of an object evaluated with the modifiers of the named types off, as a bmesh in its frame."""
hidden = [m for m in obj.modifiers if m.type in off and m.show_viewport]
for m in hidden:
m.show_viewport = False
try:
bpy.context.view_layer.update()
owner = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
bm = bmesh.new()
bm.from_mesh(owner.to_mesh())
owner.to_mesh_clear()
finally:
for m in hidden:
m.show_viewport = True
bpy.context.view_layer.update()
bm.normal_update()
return bm
def dihedrals(bm):
"""(degrees, crease weight, convex) of every edge between two faces."""
layer = bm.edges.layers.float.get("crease_edge")
rows = []
for e in bm.edges:
if len(e.link_faces) == 2:
a, b = e.link_faces
rows.append((math.degrees(a.normal.angle(b.normal, 0.0)), e[layer] if layer else 0.0, (b.calc_center_median() - a.calc_center_median()).dot(a.normal) < 0))
return rows
def crease_weights(obj) -> dict:
"""{(low vertex, high vertex): weight} of the cage's crease_edge attribute, weights over 0 only."""
attribute = obj.data.attributes.get("crease_edge")
if attribute is None:
return {}
return {tuple(sorted(e.vertices)): round(attribute.data[e.index].value, 6) for e in obj.data.edges if attribute.data[e.index].value > 0}
def stack(obj):
return [m.name for m in obj.modifiers]
def ring(y, s, dip=0.0):
"""One ring of the pauldron: over the crown from inboard (+x) to outboard and down the outer face, at y."""
return [[x * s, y, z * s] for x, z in ((0.55, 1.2), (-0.2, 1.5), (-0.9, 1.35 - dip), (-1.35, 1.0), (-1.55, 0.3), (-1.65, -0.35))]
# A pauldron-like sheet, the one the cut's probes measured: 6 rings of 6 points running aft to fore, a concave dip in ring
# 2, the shoulder line (column 3) creased. Its rings run toward +y and its points toward -x, so by the winding rule the
# crown would face down: flip turns it up.
RINGS = [ring(-1.35, 0.85), ring(-0.8, 0.97), ring(-0.2, 1.0, dip=0.25), ring(0.4, 1.0), ring(0.9, 0.95), ring(1.2, 0.8)]
PAULDRON = {"rings": RINGS, "flip": True, "creases": [{"column": 3, "from": 0, "to": 5, "weight": 1.0}]}
CUTS = [{"name": f"Line{k}", "part": "slab", "params": "gap=0.02; length=0.8; depth=0.025", "origin": [x, y, 3.0], "direction": [0, 0, -1], **({"roll": 90} if k % 2 else {})}
for k, (x, y) in enumerate(((-0.3, -0.5), (-0.3, 0.1), (-0.6, 0.6), (0.1, 0.7)))] + [
{"name": f"Inset{k}", "part": "box", "params": "width=0.25; height=0.2; depth=0.03", "origin": [-3.0, y, 0.5], "direction": [1, 0, 0]} for k, y in enumerate((-0.5, 0.5))]
PLANES = json.dumps([{"origin": [0.0, y, 0.0], "normal": [0.0, 1.0, 0.0]} for y in (-0.6, 0.0, 0.6)])
try:
# --- shell-crisp ------------------------------------------------------------------------------------------------------------
section("shell-crisp")
request = {"object_name": "Pauldron", "sheet": json.dumps(PAULDRON), "thickness": WALL, "bevel": 0.004}
receipt, report = send("brokkr_kitbash.shell", **request)
pauldron = bpy.data.objects.get("Pauldron")
stored = json.loads(pauldron["kit_shell"]) if pauldron is not None and "kit_shell" in pauldron else {}
built = core.sheet(PAULDRON)
check("shell makes one mesh object in the scene: the cage as core.sheet builds it, vertex for vertex, and kit_shell the request",
receipt["status"] == "accepted" and pauldron is not None and pauldron.users_collection == (bpy.context.scene.collection,) and pauldron.parent is None
and np.abs(points(pauldron) - built.V).max() < 1e-6 and [tuple(p.vertices) for p in pauldron.data.polygons] == [tuple(q) for q in built.faces.reshape(-1, 4).tolist()]
and sorted(stored) == ["bevel", "levels", "offset", "sheet", "thickness"] and stored["sheet"] == PAULDRON
and (stored["levels"], stored["offset"]) == (3, -1.0) and abs(stored["thickness"] - WALL) < 1e-7, [receipt["message"], stored])
check("shell reports cage facts: rings, points, quads, creased edges, the subdivided count, an upward facing, no children",
report and sorted(report) == ["cageFaces", "cageVerts", "children", "closed", "corners", "creases", "facing", "folded", "levels", "object", "offset", "points", "poles", "rebuilt", "rings", "subdividedFaces", "thickness", "triangles"]
and (report["cageVerts"], report["triangles"], report["poles"], report["closed"]) == (36, 0, {}, False)
and (report["object"], report["rebuilt"], report["rings"], report["points"], report["cageFaces"], report["creases"], report["corners"], report["subdividedFaces"], report["levels"],
report["thickness"], report["offset"], report["children"]) == ("Pauldron", False, 6, 6, 25, 25, 0, 1600, 3, 0.06, -1.0, [])
and report["facing"][2] > 0.5 and abs(np.linalg.norm(report["facing"]) - 1.0) < 1e-5, report)
smooth, wall = pauldron.modifiers.get("Kit Subsurf"), pauldron.modifiers.get("Kit Solidify")
check("the stack is Kit Subsurf, Kit Solidify, Kit Bevel: creases used, corners preserved, a wall of plain offset inward with its rim filled",
stack(pauldron) == ["Kit Subsurf", "Kit Solidify", "Kit Bevel"] and (smooth.levels, smooth.render_levels, smooth.use_creases, smooth.boundary_smooth) == (3, 3, True, "PRESERVE_CORNERS")
and (wall.use_even_offset, wall.use_rim, wall.offset) == (False, True, -1.0) and abs(wall.thickness - WALL) < 1e-7 and abs(pauldron.modifiers["Kit Bevel"].width - 0.004) < 1e-7,
stack(pauldron))
# W1 dies here: the mesh's edges are not in the order core.sheet lists its creases, so the weights must be looked up by pair
expected = {tuple(pair): round(weight, 6) for pair, weight in zip(built.creases.tolist(), built.weights.tolist())}
check("crease_edge on the cage is the sheet's creases, edge for edge, and crease_vert is all zero", crease_weights(pauldron) == expected and len(expected) == 25
and pauldron.data.attributes.get("crease_vert") is not None and max(d.value for d in pauldron.data.attributes["crease_vert"].data) == 0.0, crease_weights(pauldron))
designed = evaluated(pauldron, ("SOLIDIFY", "BEVEL", "BOOLEAN"))
rows = dihedrals(designed)
reading("crisp", max(angle for angle, _, _ in rows), least=True)
reading("soft", max([angle for angle, weight, _ in rows if weight == 0.0] or [180.0]))
concave = sum(1 for angle, _, convex in rows if not convex and angle > 1.0)
check("shell-crisp: the creased column stays a facet edge under three levels of subdivision, every other edge inside the plate stays smooth, and the dip is concave",
R["readings"]["crisp"] > CRISP and R["readings"]["soft"] < SOFT and len(designed.faces) == report["subdividedFaces"] and concave > 20,
[R["readings"], len(designed.faces), concave])
# a semi-sharp ring, a vertex crease and a soft rim, written edge for edge
MIXED = {"rings": RINGS, "flip": True, "rim": 0.0, "creases": [{"ring": 2, "from": 1, "to": 4, "weight": 0.6}, {"column": 3, "from": 0, "to": 5, "weight": 1.0},
{"point": [4, 1], "weight": 0.8}]}
receipt, report = send("brokkr_kitbash.shell", object_name="Mixed", sheet=json.dumps(MIXED), thickness=WALL, levels=2)
mixed, built = bpy.data.objects.get("Mixed"), core.sheet(MIXED)
expected = {tuple(pair): round(weight, 6) for pair, weight in zip(built.creases.tolist(), built.weights.tolist())}
corner = [round(d.value, 6) for d in mixed.data.attributes["crease_vert"].data] if mixed is not None else []
check("a semi-sharp ring run, a column run and a point land on their own edges and vertex; with rim 0 the boundary carries no crease",
receipt["status"] == "accepted" and crease_weights(mixed) == expected and sorted(set(expected.values())) == [0.6, 1.0] and len(expected) == 8
and corner == [0.8 if k == 4 * 6 + 1 else 0.0 for k in range(36)] and (report["creases"], report["corners"], report["subdividedFaces"]) == (8, 1, 400) and "Kit Bevel" not in stack(mixed),
[receipt["message"], crease_weights(mixed)])
surface = evaluated(mixed, ("SOLIDIFY",))
for corner_at in (RINGS[0][0], RINGS[0][-1], RINGS[-1][0], RINGS[-1][-1]):
reading("corner", max(1e-7, min((v.co - Vector(corner_at)).length for v in surface.verts)))
surface.free()
check("shell-crisp: a sheet whose rim is soft keeps its four corners", R["readings"]["corner"] < CORNER, R["readings"])
# --- shell-fold: count_folds, against this script's own count on the evaluated wall -------------------------------------------
section("shell-fold")
# a ridge of two flat facets 0.3 and 1.0 wide, each tilted 45 degrees, full crease, levels 2: the narrower facet binds, (0.3 / 4) / sin 45 = 0.106
wedge = {"rings": [[[-1.0 * math.sqrt(0.5), y, -1.0 * math.sqrt(0.5)], [0.0, y, 0.0], [0.3 * math.sqrt(0.5), y, -0.3 * math.sqrt(0.5)]] for y in (0.0, 0.5, 1.0)],
"creases": [{"column": 1, "from": 0, "to": 2, "weight": 1.0}]}
def own_folds(obj):
"""This script's count on its own evaluation: inner faces of the wall (Subsurf and Solidify alone) with a corner
whose triangle, the corner and its two neighbours, faces with their outer twin's normal (mathutils' normals)."""
wall_mesh = evaluated(obj, off=("BOOLEAN", "BEVEL"))
wall_mesh.faces.ensure_lookup_table()
count = len(obj.data.polygons) * 4 ** obj.modifiers["Kit Subsurf"].levels # Solidify lists the outer faces, then their inner twins in the same order, then the rim
found = 0
for k in range(count):
at = [v.co for v in wall_mesh.faces[count + k].verts]
found += any(triangle_normal(at[i - 1], at[i], at[(i + 1) % len(at)]).dot(wall_mesh.faces[k].normal) > 0 for i in range(len(at)))
wall_mesh.free()
return found
def folded(name, sheet, thickness, offset=-1.0, levels=2, **asked):
"""[the report's folded (-1: no report), this script's own count]."""
_, told = send("brokkr_kitbash.shell", object_name=name, sheet=json.dumps(sheet), thickness=thickness, offset=offset, levels=levels, **asked)
return [told.get("folded", -1) if told else -1, own_folds(bpy.data.objects[name]) if name in bpy.data.objects else -1]
under, over = folded("FoldUnder", wedge, FOLD / FOLD_STEP, count_folds=True), folded("FoldOver", wedge, FOLD * FOLD_STEP, count_folds=True)
reading("foldUnder", under[1])
reading("foldOver", over[1], least=True)
check("shell-fold: count_folds counts no folded face on a creased ridge under the thickness its narrower facet holds, and the faces this script counts over it",
under == [0, 0] and over[0] == over[1] > 0, [under, over])
unasked, outward = folded("FoldUnasked", wedge, FOLD * FOLD_STEP), folded("FoldOut", wedge, 0.3, offset=1.0, count_folds=True)
check("shell-fold: folded is null unless count_folds asks, whatever the wall does, and a ridge under a wall grown outward folds nowhere",
unasked[0] is None and unasked[1] == over[1] and outward == [0, 0], [unasked, outward])
lofts = json.loads((SURFACE / "tests" / "fixtures" / "fold_lofts.json").read_text(encoding="utf-8"))["lofts"]
seeded = {f"{loft['seed']} offset {loft['offset']:g}": folded(f"Loft{loft['seed']}", loft["sheet"], loft["thickness"], offset=loft["offset"], levels=loft["levels"], count_folds=True) for loft in lofts}
held = {f"{loft['seed']} offset {loft['offset']:g}": folded(f"Held{loft['seed']}", loft["sheet"], loft["holds"], offset=loft["offset"], levels=loft["levels"], count_folds=True) for loft in lofts if loft["holds"]}
R["folds"] = {"seeded": seeded, "held": held}
check("shell-fold: on seeded lofts, at offsets -1, 0 and 1, count_folds counts the faces this script counts at a thickness the wall folds at, and none at one it holds",
len(seeded) == 3 and all(told == own > 0 for told, own in seeded.values()) and held and all(pair == [0, 0] for pair in held.values()), [seeded, held])
for name in ["FoldUnder", "FoldOver", "FoldUnasked", "FoldOut"] + [f"{kind}{loft['seed']}" for loft in lofts for kind in ("Loft", "Held")]:
if name in bpy.data.objects:
bpy.data.objects.remove(bpy.data.objects[name])
# --- shell-solid ------------------------------------------------------------------------------------------------------------
section("shell-solid")
pauldron.modifiers["Kit Bevel"].show_viewport = False # the wall alone: a bevel rounds its edges
whole = evaluated(pauldron)
pauldron.modifiers["Kit Bevel"].show_viewport = True
area = sum(f.calc_area() for f in designed.faces)
outer = BVHTree.FromBMesh(designed)
inner = [v.co for v in whole.verts if all(outer.find_nearest(f.calc_center_median())[3] > WALL / 2 for f in v.link_faces)]
reading("solid", abs(whole.calc_volume(signed=True) / (area * WALL) - 1.0))
for co in inner:
reading("wallOff", abs(outer.find_nearest(co)[3] - WALL))
check("shell-solid: the plate is a closed wall behind the designed surface, its thickness off it but for the creased shoulder's cosine, its rim filled",
sum(1 for e in whole.edges if not e.is_manifold) == 0 and whole.calc_volume(signed=True) > 0 and len(whole.faces) == 2 * 1600 + 4 * 40 and len(inner) > 0.9 * len(designed.verts)
and R["readings"]["solid"] < SOLID and R["readings"]["wallOff"] < WALL_OFF, [R["readings"], len(whole.faces), len(inner), len(designed.verts)])
whole.free()
# a mirrored breast sheet: symmetric as evaluated
half = [[[0.0, -0.5 - 0.05 * i, 0.3 * i], [0.3, -0.45 - 0.05 * i, 0.3 * i], [0.6, -0.2, 0.3 * i + 0.05], [0.7, 0.2, 0.3 * i]] for i in range(4)]
BREAST = {"rings": half, "mirror": True, "creases": [{"column": 1, "from": 0, "to": 3, "weight": 1.0}, {"ring": 2, "from": 0, "to": 1, "weight": 0.7}]}
receipt, report = send("brokkr_kitbash.shell", object_name="Breast", sheet=json.dumps(BREAST), thickness=0.05, levels=2)
breast = bpy.data.objects.get("Breast")
plate = evaluated(breast) if breast is not None else None
V = np.array([v.co[:] for v in plate.verts]) if plate is not None else np.zeros((1, 3))
mirrored = {tuple(np.round(v * (-1.0, 1.0, 1.0), 5) + 0.0) for v in V} == {tuple(np.round(v, 5) + 0.0) for v in V}
check("a mirrored sheet is a plate symmetric in x, facing forward (-y), its creases on both halves", receipt["status"] == "accepted" and mirrored and report["points"] == 7
and report["facing"][1] < -0.5 and abs(report["facing"][0]) < 1e-6 and report["creases"] == 2 * 6 + 2 * 3 + 2 * 3 + 2
and sum(1 for e in plate.edges if not e.is_manifold) == 0, [receipt["message"], report])
if plate is not None:
plate.free()
# --- shell-composes ---------------------------------------------------------------------------------------------------------
section("shell-composes")
receipt, cut = send("brokkr_kitbash.cut_many", object_name="Pauldron", cuts=json.dumps(CUTS))
check("shell-composes: cut_many takes four panel lines and two insets on a shell, and its Boolean goes after the wall and above the bevel",
receipt["status"] == "accepted" and stack(pauldron) == ["Kit Subsurf", "Kit Solidify", "Kit Difference", "Kit Bevel"]
and sorted(c.name for c in pauldron.children) == sorted(c["name"] for c in CUTS), [receipt["message"], stack(pauldron)])
receipt, ribbed = send("brokkr_kitbash.ribs", object_name="Pauldron", ribs_name="PauldronRibs", planes=PLANES, standoff=0.01, depth=0.03, thickness=0.014)
ribs = bpy.data.objects.get("PauldronRibs")
behind = ribs is not None
for v in (points(ribs) if ribs is not None else ()):
on, normal, _, _ = outer.find_nearest(Vector(v))
behind = behind and (Vector(v) - on).dot(normal) < 0
check("shell-composes: ribs takes a shell, reads its thickness from Kit Solidify, and stands behind the plate: on the side the cage's normals face away from",
receipt["status"] == "accepted" and behind and ribs.parent == pauldron and ribbed["thickness"] == 0.06 and ribbed["ribs"] >= 3 and ribbed["nonManifoldEdges"] == 0,
[receipt["message"], ribbed])
receipt, deep = send("brokkr_kitbash.ribs", object_name="Pauldron", ribs_name="PauldronDeep", planes=PLANES, standoff=0.03, depth=0.08, thickness=0.014)
R["readings"]["ribsAcrossTheCrease"] = 1.0 if receipt["status"] == "accepted" else 0.0 # a reading, not a check: deep ribs behind a creased plate are ribs' to clip or refuse
R["creaseRibs"] = str(receipt["message"])[:300]
if bpy.data.objects.get("PauldronDeep") is not None:
bpy.data.objects.remove(bpy.data.objects["PauldronDeep"])
bpy.context.view_layer.update()
# --- shell-rebuild ----------------------------------------------------------------------------------------------------------
section("shell-rebuild")
before = {"pointer": pauldron.as_pointer(), "mesh": pauldron.data.as_pointer(), "children": {c.name: (c.as_pointer(), np.array(c.matrix_basis).tolist(), c.parent.name) for c in pauldron.children},
"cutters": sorted(o.name for o in pauldron.modifiers["Kit Difference"].collection.objects), "collection": pauldron.modifiers["Kit Difference"].collection.as_pointer(),
"ribs": points(ribs).copy(), "slots": len(pauldron.material_slots)}
MOVED = {**PAULDRON, "rings": [[[x, y, z + 0.1 * (1.0 - abs(y))] for x, y, z in r] for r in RINGS]} # the crown lifted, most in the middle
receipt, report = send("brokkr_kitbash.shell", object_name="Pauldron", sheet=json.dumps(MOVED), thickness=0.05, levels=2, bevel=0.004)
again = bpy.data.objects.get("Pauldron")
wall = again.modifiers.get("Kit Solidify")
check("shell-rebuild: the same object and mesh datablock, its cutters and ribs still its children at unchanged matrices, the Boolean's collection untouched, the stack in order",
receipt["status"] == "accepted" and again is not None and (again.as_pointer(), again.data.as_pointer()) == (before["pointer"], before["mesh"])
and {c.name: (c.as_pointer(), np.array(c.matrix_basis).tolist(), c.parent.name) for c in again.children} == before["children"] and len(before["children"]) == 7
and (sorted(o.name for o in again.modifiers["Kit Difference"].collection.objects), again.modifiers["Kit Difference"].collection.as_pointer()) == (before["cutters"], before["collection"])
and len(before["cutters"]) == 6 and stack(again) == ["Kit Subsurf", "Kit Solidify", "Kit Difference", "Kit Bevel"] and np.array_equal(points(ribs), before["ribs"]),
[receipt["message"], stack(again), sorted(c.name for c in again.children)])
check("shell-rebuild: the cage is the new sheet's, the modifiers' settings and kit_shell follow, and the report says rebuilt and names the children",
report and report["rebuilt"] is True and report["children"] == sorted(before["children"]) and (report["levels"], report["thickness"], report["subdividedFaces"]) == (2, 0.05, 400)
and np.abs(points(again) - core.sheet(MOVED).V).max() < 1e-6 and abs(points(again)[:, 2].max() - (1.5 + 0.1 * 0.8)) < 1e-6 and (again.modifiers["Kit Subsurf"].levels, again.modifiers["Kit Subsurf"].render_levels) == (2, 2)
and abs(wall.thickness - 0.05) < 1e-7 and json.loads(again["kit_shell"])["sheet"] == MOVED and json.loads(again["kit_shell"])["levels"] == 2
and crease_weights(again) == {tuple(pair): round(weight, 6) for pair, weight in zip(core.sheet(MOVED).creases.tolist(), core.sheet(MOVED).weights.tolist())}, report)
plate = evaluated(again)
check("shell-rebuild: the rebuilt plate is still cut, and closed", sum(1 for e in plate.edges if not e.is_manifold) == 0 and len(plate.faces) > 2 * 400 + 4 * 20 + 20, len(plate.faces))
plate.free()
receipt, report = send("brokkr_kitbash.shell", object_name="Pauldron", sheet=json.dumps(MOVED), thickness=0.05, levels=2, bevel=0.004, count_folds=True)
check("shell-rebuild: count_folds under cutters counts the wall as this script does and leaves the stack shown, in order",
receipt["status"] == "accepted" and report and report["folded"] == own_folds(again) and [(m.name, m.show_viewport) for m in again.modifiers]
== [("Kit Subsurf", True), ("Kit Solidify", True), ("Kit Difference", True), ("Kit Bevel", True)], [receipt["message"], report and report.get("folded"), [(m.name, m.show_viewport) for m in again.modifiers]])
# --- costs: wall times of this run, never bounded -----------------------------------------------------------------------------
section("costs")
times = {"shell": [], "shellCountingFolds": [], "evaluation": [], "rebuildUnderCuts": [], "rebuildCall": [], "rebuildCallCountingFolds": []}
for k in range(3):
name = f"Timed{k}"
start = time.perf_counter()
bpy.ops.brokkr_kitbash.shell(object_name=name, sheet=json.dumps(PAULDRON), thickness=WALL)
times["shell"].append(time.perf_counter() - start)
start = time.perf_counter()
bpy.ops.brokkr_kitbash.shell(object_name=name + "Counted", sheet=json.dumps(PAULDRON), thickness=WALL, count_folds=True)
times["shellCountingFolds"].append(time.perf_counter() - start)
bpy.data.objects[name].update_tag() # Blender's own update after the action evaluated it already: once more, alone
start = time.perf_counter()
faces = len(bpy.data.objects[name].evaluated_get(bpy.context.evaluated_depsgraph_get()).data.polygons) # one whole evaluation: Subdivision and Solidify
times["evaluation"].append(time.perf_counter() - start)
start = time.perf_counter()
bpy.ops.brokkr_kitbash.shell(object_name="Pauldron", sheet=json.dumps(MOVED if k % 2 else PAULDRON), thickness=WALL, bevel=0.004)
cut_faces = len(pauldron.evaluated_get(bpy.context.evaluated_depsgraph_get()).data.polygons) # with its one Boolean of six cutters
times["rebuildUnderCuts"].append(time.perf_counter() - start)
for counting in (False, True): # the call alone: what count_folds adds to a rebuild under six cutters
start = time.perf_counter()
bpy.ops.brokkr_kitbash.shell(object_name="Pauldron", sheet=json.dumps(MOVED if k % 2 else PAULDRON), thickness=WALL, bevel=0.004, count_folds=counting)
times["rebuildCallCountingFolds" if counting else "rebuildCall"].append(time.perf_counter() - start)
R["costs"] = {name: float(f"{statistics.median(values):.2g}") for name, values in times.items()}
check("costs: the timed shells evaluated whole", faces == 3360 and cut_faces > 3360, [faces, cut_faces])
# --- shell-refusals ---------------------------------------------------------------------------------------------------------
section("shell-refusals")
SHEET = json.dumps(PAULDRON)
plain = bpy.data.objects.new("Plain", bpy.data.meshes.new("Plain"))
plain.data.from_pydata([(0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0)], [], [(0, 1, 2, 3)])
bpy.context.scene.collection.objects.link(plain)
empty = bpy.data.objects.new("Empty", None)
bpy.context.scene.collection.objects.link(empty)
bpy.context.view_layer.update()
refused("a mesh of that name that is no shell", {"object_name": "Plain", "sheet": SHEET}, "An object named 'Plain' exists and is no shell")
refused("an object of that name that is no mesh", {"object_name": "Empty", "sheet": SHEET}, "An object named 'Empty' exists and is no shell")
refused("a ribs object", {"object_name": "PauldronRibs", "sheet": SHEET}, "An object named 'PauldronRibs' exists and is no shell")
mixed.scale = (1.0, 1.0, 1.01)
bpy.context.view_layer.update()
refused("a scaled shell", {"object_name": "Mixed", "sheet": SHEET}, "'Mixed' is scaled, mirrored or sheared in the world")
mixed.scale = (1.0, 1.0, 1.0)
twin = bpy.data.objects.new("Twin", mixed.data)
bpy.context.scene.collection.objects.link(twin)
bpy.context.view_layer.update()
refused("a shell that shares its mesh", {"object_name": "Mixed", "sheet": SHEET}, "'Mixed' shares its mesh 'Mixed' with 1 other user(s)")
bpy.data.objects.remove(twin)
bpy.context.view_layer.update()
uneven = {"rings": [RINGS[0], RINGS[1][:5]]}
refused("a sheet of unequal rings, on a new name", {"object_name": "New", "sheet": json.dumps(uneven)}, "sheet.rings[1] has 5 points and sheet.rings[0] has 6")
refused("a sheet of unequal rings, on a shell", {"object_name": "Mixed", "sheet": json.dumps(uneven)}, "sheet.rings[1] has 5 points and sheet.rings[0] has 6")
refused("a run past the ring", {"object_name": "Mixed", "sheet": json.dumps({**PAULDRON, "creases": [{"ring": 0, "from": 0, "to": 6, "weight": 1}]})},
"sheet.creases[0].to must be a whole number from 0 to 5, not 6")
refused("two weights on one edge", {"object_name": "Mixed", "sheet": json.dumps({**PAULDRON, "creases": [{"ring": 1, "from": 0, "to": 2, "weight": 1}, {"ring": 1, "from": 1, "to": 3, "weight": 0.5}]})},
"sheet.creases[1] gives an edge weight 0.5 that sheet.creases[0] gives 1")
mixed.modifiers["Kit Solidify"].show_viewport = False
refused("count_folds on a shell whose Kit Solidify is hidden", {"object_name": "Mixed", "sheet": SHEET, "count_folds": True}, "'Mixed' has its Kit Solidify hidden in viewports")
mixed.modifiers["Kit Solidify"].show_viewport = True
refused("a sheet that is not JSON", {"object_name": "Mixed", "sheet": "{rings"}, "sheet is not JSON")
refused("a sheet with an unknown key", {"object_name": "New", "sheet": json.dumps({**PAULDRON, "inside": [0, 0, 0]})}, "sheet has no key 'inside'")
dense = {"rings": [[[j / 10, 0, i / 10] for j in range(34)] for i in range(34)]}
refused("too many faces", {"object_name": "New", "sheet": json.dumps(dense), "levels": 4}, "1089 cage quads at 4 levels subdivide to 278784 faces, over 262144")
receipt, report = send("brokkr_kitbash.shell", object_name="Dense", sheet=json.dumps(dense), levels=3, thickness=0.01)
check("the same sheet at three levels is taken", receipt["status"] == "accepted" and report["subdividedFaces"] == 69696, receipt["message"])
check("no refusal made an object", "New" not in bpy.data.objects, None)
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, not a missing result file
check(f"no uncaught error in section: {SECTION[0]}", False, traceback.format_exc().splitlines()[-6:])
finally:
R["ok"] = all(c["ok"] for c in R["checks"])
R["readings"] = {name: float(f"{value:.2g}") for name, value in sorted(R["readings"].items())}
costs = R.pop("costs", None) # wall time is this machine's: printed, and kept out of the result file
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
print("READINGS", R["readings"], flush=True)
print("SECONDS", costs, flush=True)
sys.exit(0 if R["ok"] else 1)

View file

@ -0,0 +1,214 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "shell makes one mesh object in the scene: the cage as core.sheet builds it, vertex for vertex, and kit_shell the request",
"ok": true,
"detail": null
},
{
"name": "shell reports cage facts: rings, points, quads, creased edges, the subdivided count, an upward facing, no children",
"ok": true,
"detail": null
},
{
"name": "the stack is Kit Subsurf, Kit Solidify, Kit Bevel: creases used, corners preserved, a wall of plain offset inward with its rim filled",
"ok": true,
"detail": null
},
{
"name": "crease_edge on the cage is the sheet's creases, edge for edge, and crease_vert is all zero",
"ok": true,
"detail": null
},
{
"name": "shell-crisp: the creased column stays a facet edge under three levels of subdivision, every other edge inside the plate stays smooth, and the dip is concave",
"ok": true,
"detail": null
},
{
"name": "a semi-sharp ring run, a column run and a point land on their own edges and vertex; with rim 0 the boundary carries no crease",
"ok": true,
"detail": null
},
{
"name": "shell-crisp: a sheet whose rim is soft keeps its four corners",
"ok": true,
"detail": null
},
{
"name": "shell-fold: count_folds counts no folded face on a creased ridge under the thickness its narrower facet holds, and the faces this script counts over it",
"ok": true,
"detail": null
},
{
"name": "shell-fold: folded is null unless count_folds asks, whatever the wall does, and a ridge under a wall grown outward folds nowhere",
"ok": true,
"detail": null
},
{
"name": "shell-fold: on seeded lofts, at offsets -1, 0 and 1, count_folds counts the faces this script counts at a thickness the wall folds at, and none at one it holds",
"ok": true,
"detail": null
},
{
"name": "shell-solid: the plate is a closed wall behind the designed surface, its thickness off it but for the creased shoulder's cosine, its rim filled",
"ok": true,
"detail": null
},
{
"name": "a mirrored sheet is a plate symmetric in x, facing forward (-y), its creases on both halves",
"ok": true,
"detail": null
},
{
"name": "shell-composes: cut_many takes four panel lines and two insets on a shell, and its Boolean goes after the wall and above the bevel",
"ok": true,
"detail": null
},
{
"name": "shell-composes: ribs takes a shell, reads its thickness from Kit Solidify, and stands behind the plate: on the side the cage's normals face away from",
"ok": true,
"detail": null
},
{
"name": "shell-rebuild: the same object and mesh datablock, its cutters and ribs still its children at unchanged matrices, the Boolean's collection untouched, the stack in order",
"ok": true,
"detail": null
},
{
"name": "shell-rebuild: the cage is the new sheet's, the modifiers' settings and kit_shell follow, and the report says rebuilt and names the children",
"ok": true,
"detail": null
},
{
"name": "shell-rebuild: the rebuilt plate is still cut, and closed",
"ok": true,
"detail": null
},
{
"name": "shell-rebuild: count_folds under cutters counts the wall as this script does and leaves the stack shown, in order",
"ok": true,
"detail": null
},
{
"name": "costs: the timed shells evaluated whole",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a mesh of that name that is no shell",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: an object of that name that is no mesh",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a ribs object",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a scaled shell",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a shell that shares its mesh",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a sheet of unequal rings, on a new name",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a sheet of unequal rings, on a shell",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a run past the ring",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: two weights on one edge",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: count_folds on a shell whose Kit Solidify is hidden",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a sheet that is not JSON",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a sheet with an unknown key",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: too many faces",
"ok": true,
"detail": null
},
{
"name": "the same sheet at three levels is taken",
"ok": true,
"detail": null
},
{
"name": "no refusal made an object",
"ok": true,
"detail": null
}
],
"hostErrors": [],
"readings": {
"corner": 1.8e-07,
"crisp": 52.0,
"foldOver": 8.0,
"foldUnder": 0.0,
"ribsAcrossTheCrease": 1.0,
"soft": 5.8,
"solid": 0.028,
"wallOff": 0.0061
},
"folds": {
"seeded": {
"5185 offset -1": [
1,
1
],
"5101 offset 0": [
9,
9
],
"5196 offset 1": [
1,
1
]
},
"held": {
"5185 offset -1": [
0,
0
],
"5196 offset 1": [
0,
0
]
}
},
"creaseRibs": "Operator brokkr_kitbash.ribs finished.",
"ok": true
}

View file

@ -0,0 +1,669 @@
"""Live proof, in a background Blender, of brokkr_kitbash followers through run_intent: brokkr_kitbash.follow states a
ratio or a loop, posing a driver derives every follower in the same action (core.close_loop for a loop), a follower
refuses to be posed, brokkr.joints version 2 marks driven rows and pages, and each refusal changes nothing. Not part of
the unittest run: it needs Blender.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/kitbash_follows.py -- <out>
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). <out> is an absolute path; writes <out>.result.json and exits 1 when a check failed. The checks run
inside one try: an uncaught error is a failed check that names the check before it.
The scene, every strut 0.09 wide so its pins take a ram's: a four-bar (Crank on the root Ground, Rocker on the root
Base, Coupler closing on the crank); a ram (A_Barrel on the root Pad, A_Rod in its bore, closing on the rocker), named
to sort before the four-bar it waits on; ratio followers of the crank (Cap, Pinion, and X_Rod's slide in X_Barrel); a
torque link (T_Rod sliding in the root T_Barrel, T_Upper and T_Lower closing on T_Lug, a strut on the rod's
rod_end_back held at 90 degrees by limits of that one value. A real torque link exists to stop the rod rolling in its
barrel, so a lug with no travel is the mechanism and not a way around the kit; and a strut's two pins face one way, so
two arms from the barrel's pin cannot face the rod's own); a second crank (Crank2 on the root Ground2)
whose ram closes on the rocker, and a loop hung from its own driver (K3, B3, Rk3, Cp3 on the root G3), for the
one-driver refusals at the statement, and after it an attach, a clear, widened limits, a pose over limits written by hand and a
detach that would each give a stated loop a second driver, and the reads that tell of one made by hand (follows.holds, the joints report's manyDrivers); Idle and Tip for the refusals and for the writes a two-driver loop does not refuse; a tree of 264 struts with 62-character names for a joints
report over several receipts. Bounds follow lodur:ruling:deterministic-bound-margin, both readings beside each; the
result file carries the readings.
"""
import importlib.util
import json
import math
import os
import sys
import tempfile
import time
import traceback
import types
from pathlib import Path
import bpy
import numpy as np
from mathutils import Matrix
SURFACE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(SURFACE / "tools"))
import private_dirs # noqa: E402
_refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if _refused:
raise SystemExit(_refused)
OUT = sys.argv[sys.argv.index("--") + 1]
if not Path(OUT).is_absolute():
raise SystemExit(f"{OUT!r} is not an absolute path")
package = types.ModuleType("brokkr_bridge")
package.__path__ = [str(SURFACE / "brokkr_bridge")]
sys.modules["brokkr_bridge"] = package
from brokkr_bridge import blender_target as bt # noqa: E402
import addon_utils # noqa: E402
spec = importlib.util.spec_from_file_location("brokkr_kitbash_core_reference", SURFACE / "brokkr_kitbash" / "core.py")
core = importlib.util.module_from_spec(spec) # core as the unit tests load it: the frames every reading here is taken against
spec.loader.exec_module(core)
sys.path.append(str(SURFACE))
bpy.ops.wm.read_factory_settings(use_empty=True)
for module in ("brokkr_mesh_polish", "brokkr_kitbash"):
addon_utils.enable(module, default_set=True)
target = bt.BrokkrBlenderTarget(bpy)
WORK = Path(tempfile.mkdtemp(prefix="brokkr-kitbash-follows-"))
target.configure_action_dirs("", str(WORK))
target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1], "readings": {}}
COUNT = [0]
kit = core.load_kit("mechanical")
# Each mutant's reading below is its least over the cases here that it changes; the shipped reading is the worst.
# Metres (or a difference of unit vectors) between a loop's closing socket and the socket it closes on, read from the two
# world matrices after a driver was posed; a rod's slide against this file's own solve reads against it too. Shipped
# worst 6.4e-07 (float32 matrices); least claimed mutant 0.041 (F11, the ram solved before the four-bar whose rocker it
# closes on, at the smallest turn here); separation 250 each side.
CLOSED = 1.6e-4
# Degrees between a loop follower's roll and the one this file solves by its own steps of core.close_loop from the rest
# pose. Shipped worst 3.3e-05 (an action's roll is a float32 field); least claimed mutant 2.7 (F11 again: the barrel
# aimed at where the rocker was); separation 290 each side.
SOLVED = 9.4e-3
# A ratio follower's roll in degrees or slide in metres against k x the driver's value + offset, read from the stored
# values. Shipped 0: the same doubles. A rule, a double's rounding at these sizes (6e-14 at 360) with room; mutant R1
# (the ratio taken from the driver's value before the pose) reads 0.09 on the crosshead's slide and 45 on the kneecap.
RATIO = 1e-9
ROT = [0.3, -0.2, 0.5] # the roots' rotation: no axis of the scene lines up with the world's
D0, REST = 30.0, (-40.0, 70.0) # the four-bar at rest: the crank's roll, and the rocker's and coupler's
RAM_REST = (200.0, 0.1) # the ram at rest: the barrel's roll and the rod's slide
def check(name, ok, detail=None):
try:
json.dumps(detail, default=str)
except TypeError:
detail = repr(detail)
R["checks"].append({"name": name, "ok": bool(ok), "detail": None if ok else detail})
def reading(name, value):
R["readings"][name] = max(R["readings"].get(name, 0.0), float(value))
return float(value)
def send(action, **fields):
COUNT[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"live-{COUNT[0]}", "requestedBy": "test/driver", "action": action, **fields})
result = None
if receipt.get("hostResult"):
try:
result = json.loads(receipt["hostResult"])
except ValueError:
result = None
if not action.endswith(("place_part", "attach")) or receipt["status"] != "accepted":
print("SEND", action, receipt["status"], str(receipt["message"])[:300], flush=True)
return receipt, result
def place(name, part, params="", world=None):
send("brokkr_kitbash.place_part", part=part, object_name=name, params=params)
if world is not None:
world = Matrix(np.asarray(world).tolist())
send("setObjectTransform", targetObjectName=name, location=list(world.translation), rotationEuler=list(world.to_euler("XYZ")))
return bpy.data.objects[name]
def attach(name, socket_name, parent, parent_socket, roll=0.0):
receipt, _ = send("brokkr_kitbash.attach", object_name=name, socket=socket_name, parent_name=parent, parent_socket=parent_socket, roll=roll)
return receipt["status"] == "accepted"
def socket(obj, name):
built = core.build(core.part(kit, obj["kit_part"]), json.loads(obj["kit_params"]))
return next(s for s in built.sockets if s["name"] == name)
def world(obj):
return np.array(obj.matrix_world, dtype=np.float64)
def frame(obj, name):
"""A socket's world frame, from the object's matrix_world and core's build of its stored params."""
return world(obj) @ socket(obj, name)["matrix"]
def apart(obj, name, other, other_name):
"""How far two sockets stand from meeting as a pin, read from the scene: origins apart, or normals not opposed."""
a, b = frame(obj, name), frame(other, other_name)
return max(float(np.abs(a[:3, 3] - b[:3, 3]).max()), float(np.abs(a[:3, 2] + b[:3, 2]).max()))
def connection(name):
receipt, report = send("brokkr_kitbash.report", object_name=name)
return report["parts"][0]["connection"] if report else {"error": receipt["message"]}
def scene_state():
return {o.name: (o.parent and o.parent.name, np.round(np.array(o.matrix_basis), 6).tolist(), np.round(np.array(o.matrix_parent_inverse), 6).tolist(), len(o.data.vertices),
{k: repr(o[k]) for k in sorted(o.keys()) if k.startswith("kit_")}) for o in bpy.data.objects}
def refused(label, action, fields, *expected):
state = scene_state()
receipt, _ = send(action, **fields)
check(f"refused, scene unchanged: {label}", receipt["status"] != "accepted" and all(text in str(receipt["message"]) for text in expected) and scene_state() == state,
[receipt["status"], receipt["message"], expected])
def stepped(solve, seed, start, end, step):
"""This file's own derivation: the loop's two values after the input goes from start to end in steps of at most `step`."""
count = max(1, math.ceil(abs(end - start) / step))
for index in range(1, count + 1):
seed, _ = solve(start + (end - start) * index / count, seed)
return seed
def turned(a, b):
return abs((a - b + 180.0) % 360.0 - 180.0)
try:
rows = [row["name"] for row in target.host_actions()[0] if row["name"].startswith("brokkr_kitbash.")]
check("follow loads as a host action after joints, with no errors", not R["hostErrors"] and "brokkr_kitbash.joints" in rows
and rows[rows.index("brokkr_kitbash.joints") + 1] == "brokkr_kitbash.follow", [R["hostErrors"], rows])
# --- the four-bar -----------------------------------------------------------------------------------------------------
turn = np.eye(4)
turn[:3, :3] = core._rotation([math.degrees(v) for v in ROT])
turn[:3, 3] = [1.0, 2.0, 3.0]
W = "width=0.09; "
ground = place("Ground", "strut", W + "length=0.8", turn)
crank, rocker, coupler = place("Crank", "strut", W + "length=0.5"), place("Rocker", "strut", W + "length=0.9"), place("Coupler", "strut", W + "length=0.7")
attach("Crank", "end_a", "Ground", "end_a", D0)
def crank_pin(roll, name="end_b"):
return world(ground) @ core.mate(socket(ground, "end_a"), socket(crank, "end_a"), roll) @ socket(crank, name)["matrix"]
def rocker_world(base_world, roll):
return base_world @ core.mate(socket(ground, "end_a"), socket(rocker, "end_a"), roll)
end = rocker_world(turn, REST[0]) @ core.mate(socket(rocker, "end_b"), socket(coupler, "end_a"), REST[1]) @ socket(coupler, "end_b")["matrix"]
shift = np.eye(4)
shift[:3, 3] = crank_pin(D0)[:3, 3] - end[:3, 3]
base = place("Base", "strut", W + "length=0.8", shift @ turn) # where the loop closes at rest
attach("Rocker", "end_a", "Base", "end_a", REST[0])
attach("Coupler", "end_a", "Rocker", "end_b", REST[1])
receipt, report = send("brokkr_kitbash.close", object_name="Coupler", socket="end_b", other_name="Crank", other_socket="end_b")
check("the four-bar stands closed at rest: crank on Ground, rocker on Base, the coupler's end closing on the crank's", receipt["status"] == "accepted"
and report["closure"]["holds"] is True, [receipt["message"], report and report["closure"]])
four_bar = [(socket(base, "end_a"), socket(rocker, "end_a"), "revolute"), (socket(rocker, "end_b"), socket(coupler, "end_a"), "revolute")]
def solve_four_bar(roll, seed):
return core.close_loop(world(base), four_bar, socket(coupler, "end_b"), crank_pin(roll), seed)
# --- parts for the refusals ---------------------------------------------------------------------------------------------
far = np.eye(4)
far[:3, 3] = [0.0, -8.0, 0.0]
place("Idle", "strut", W), place("Tip", "strut", W), place("Loose", "strut", W)
attach("Idle", "end_a", "Ground", "end_b", 15.0)
attach("Tip", "end_a", "Idle", "end_b", 0.0)
tank = place("Tank", "tank", "radius=0.3; length=1.2")
place("Brk", "bracket")
attach("Brk", "mount", "Tank", "lug_b")
loop = '{"driver": "Crank", "kind": "loop"}'
refused("a loop whose two ends both stand still when the driver moves (F7)", "brokkr_kitbash.follow", {"object_name": "Coupler", "record": '{"driver": "Idle", "kind": "loop"}'},
"'Base' (the base) and 'Crank' (closed on), neither moves with 'Idle'")
place("G3", "strut", W + "length=0.8", far @ far @ far @ turn)
k3, b3, rk3, cp3 = place("K3", "strut", W + "length=0.5"), place("B3", "strut", W + "length=0.8"), place("Rk3", "strut", W + "length=0.9"), place("Cp3", "strut", W + "length=0.7")
attach("K3", "end_a", "G3", "end_a", 10.0)
attach("B3", "end_a", "K3", "end_a_back", 0.0)
hung = None
for guess in ((g0, g1) for g0 in range(-180, 180, 45) for g1 in range(-180, 180, 45)): # a pose at which a rocker and coupler on B3 close on K3
try:
hung, _ = core.close_loop(world(b3), [(socket(b3, "end_b"), socket(rk3, "end_a"), "revolute"), (socket(rk3, "end_b_back"), socket(cp3, "end_a"), "revolute")],
socket(cp3, "end_b"), frame(k3, "end_b"), (float(guess[0]), float(guess[1])))
break
except core.KitError:
continue
attach("Rk3", "end_a", "B3", "end_b", core._wrapped(hung[0]) if hung else 0.0)
attach("Cp3", "end_a", "Rk3", "end_b_back", core._wrapped(hung[1]) if hung else 0.0)
receipt, report = send("brokkr_kitbash.close", object_name="Cp3", socket="end_b", other_name="K3", other_socket="end_b")
check("a loop whose base hangs from the part it closes on stands closed", hung is not None and receipt["status"] == "accepted" and report["closure"]["holds"] is True, [hung, receipt["message"]])
refused("a loop whose two ends both move with the driver (F7, the other half)", "brokkr_kitbash.follow", {"object_name": "Cp3", "record": '{"driver": "K3", "kind": "loop"}'},
"'B3' (the base) and 'K3' (closed on), both move with 'K3'")
refused("a loop follower that states no closure", "brokkr_kitbash.follow", {"object_name": "Rocker", "record": loop}, "'Rocker' states no closure that holds")
refused("a follower on a rigid connection", "brokkr_kitbash.follow", {"object_name": "Brk", "record": '{"driver": "Crank", "kind": "ratio", "k": 1, "offset": 0}'},
"socket type 'mount' states no dof")
refused("a follower that is not attached", "brokkr_kitbash.follow", {"object_name": "Loose", "record": loop}, "'Loose' (the follower) is not attached")
refused("a part that follows itself", "brokkr_kitbash.follow", {"object_name": "Idle", "record": '{"driver": "Idle", "kind": "ratio", "k": 1, "offset": 0}'}, "'Idle' is the follower itself")
refused("a driver below its follower", "brokkr_kitbash.follow", {"object_name": "Idle", "record": '{"driver": "Tip", "kind": "ratio", "k": 1, "offset": 0}'}, "'Tip' is below 'Idle'")
for bad in ('{"driver": "Crank", "kind": "ratio", "k": 0, "offset": 0}', '{"driver": "Crank", "kind": "ratio", "k": 1}', '{"driver": "Crank", "kind": "gear"}',
'{"driver": "Crank", "kind": "loop", "k": 1}', "[1, 2]", '{"a"'):
refused(f"a record that is not one of the three shapes: {bad}", "brokkr_kitbash.follow", {"object_name": "Idle", "record": bad}, "record must be")
refused("clearing a part that follows nothing", "brokkr_kitbash.follow", {"object_name": "Idle", "record": "null"}, "'Idle' follows nothing")
# --- a loop follows -----------------------------------------------------------------------------------------------------
receipt, report = send("brokkr_kitbash.follow", object_name="Coupler", record=loop)
rocker_row, coupler_row = connection("Rocker"), report["connection"] if report else None
check("follow states the loop on the closing part and its parent, both following the crank, and the report lists them as written",
receipt["status"] == "accepted" and [f["part"] for f in report["followers"]] == ["Rocker", "Coupler"]
and coupler_row["follows"] == {"driver": "Crank", "kind": "loop", "k": None, "offset": None, "holds": True, "reason": None} == rocker_row["follows"]
and json.loads(rocker["kit_follows"]) == {"kind": "loop"} == json.loads(coupler["kit_follows"]) and rocker["kit_follows_driver"] == crank == coupler["kit_follows_driver"],
[receipt["message"], report and report.get("followers"), rocker_row, coupler_row])
seed = REST
for roll, label in ((75.0, "a 45 degree turn"), (150.0, "to 120 past rest"), (D0, "and back to rest"), (0.0, "30 the other way")):
was = crank["kit_roll"]
receipt, report = send("brokkr_kitbash.roll", object_name="Crank", roll=roll)
seed = stepped(solve_four_bar, seed, was, roll, 5.0)
ok = receipt["status"] == "accepted" and reading("closed", apart(coupler, "end_b", crank, "end_b")) < CLOSED
ok = ok and max(reading("solved", turned(rocker["kit_roll"], seed[0])), reading("solved", turned(coupler["kit_roll"], seed[1]))) < SOLVED
check(f"rolling the crank {label} moves rocker and coupler with it: the closure holds in the scene and the rolls are this file's own stepped solve",
ok and [f["part"] for f in report["followers"]] == ["Rocker", "Coupler"] and report["closures"][0] == {"part": "Coupler", "to": "Crank", "holds": True}
and connection("Rocker")["holds"] and connection("Coupler")["holds"], [receipt["message"], R["readings"], report and report.get("followers"), seed])
refused("the crank driven past the loop's dead centre, naming the driver's value and the closing part", "brokkr_kitbash.roll", {"object_name": "Crank", "roll": -5.0},
"'Crank' at -5: the loop 'Coupler' closes on 'Crank' ('Rocker' and 'Coupler' follow): the loop is at a dead centre", "nothing changed")
send("brokkr_kitbash.roll", object_name="Crank", roll=-2.0) # beside the toggle: 32 back from rest
seed = stepped(solve_four_bar, seed, 0.0, -2.0, 5.0)
jump = None
for roll in range(10, 151): # the nearest jump from here that one solve from the stated rolls does not survive: refused in the dead centre, or on the other branch
direct = stepped(solve_four_bar, seed, -2.0, float(roll), 5.0)
try:
once, _ = solve_four_bar(float(roll), seed)
except core.KitError:
once = None
if once is None or turned(once[0], direct[0]) > 1.0:
jump = float(roll)
break
R["readings"]["jump"] = jump or 0.0
receipt, report = send("brokkr_kitbash.roll", object_name="Crank", roll=jump or 47.0)
seed = stepped(solve_four_bar, seed, -2.0, jump or 47.0, 5.0)
check("a jump from beside the toggle that one solve from the stated rolls does not survive ends on the stepped answer, the branch the linkage is on (F2)",
jump is not None and receipt["status"] == "accepted" and reading("solved", turned(rocker["kit_roll"], seed[0])) < SOLVED and reading("solved", turned(coupler["kit_roll"], seed[1])) < SOLVED
and reading("closed", apart(coupler, "end_b", crank, "end_b")) < CLOSED, [jump, receipt["message"], rocker["kit_roll"], coupler["kit_roll"], seed])
send("brokkr_kitbash.roll", object_name="Crank", roll=D0)
seed = stepped(solve_four_bar, seed, jump or 47.0, D0, 5.0)
# --- followers are derived only ---------------------------------------------------------------------------------------
for name in ("Rocker", "Coupler"):
refused(f"roll on the follower {name}, naming its driver (F4)", "brokkr_kitbash.roll", {"object_name": name, "roll": 10.0}, f"{name!r} follows 'Crank' (loop): its value is derived")
refused("aim on a follower", "brokkr_kitbash.aim", {"object_name": "Rocker", "axis": "+z", "direction_x": 1.0, "direction_y": 0.0, "direction_z": 0.0}, "'Rocker' follows 'Crank'")
refused("reach on a follower", "brokkr_kitbash.reach", {"object_name": "Rocker", "socket": "end_b", "direction_x": 0.0, "direction_y": 0.0, "direction_z": 1.0, "height": 3.0}, "'Rocker' follows 'Crank'")
was = rocker["kit_roll"]
receipt, report = send("brokkr_kitbash.joint", object_name="Rocker", record='{"limits": [-100, 20], "mechanism": "rocker"}')
check("joint on a follower states limits and a mechanism and keeps its derived value and its statement", receipt["status"] == "accepted" and rocker["kit_roll"] == was
and report["connection"]["limits"] == [-100.0, 20.0] and report["connection"]["mechanism"] == "rocker" and report["connection"]["follows"]["holds"] is True,
[receipt["message"], report and report["connection"]])
refused("joint limits on a follower that do not hold its derived value", "brokkr_kitbash.joint", {"object_name": "Rocker", "record": '{"limits": [0, 20]}'}, "is outside the joint's limits")
refused("a driver that is itself a follower", "brokkr_kitbash.follow", {"object_name": "Idle", "record": '{"driver": "Rocker", "kind": "ratio", "k": 1, "offset": 0}'},
"'Rocker' is itself a follower")
refused("a follower that drives another", "brokkr_kitbash.follow", {"object_name": "Crank", "record": '{"driver": "Idle", "kind": "ratio", "k": 1, "offset": 0}'},
"'Crank' drives 'Coupler': a driver is never a follower")
refused("a follower that already follows", "brokkr_kitbash.follow", {"object_name": "Coupler", "record": loop}, "'Rocker' already follows")
refused("a closure stated by a loop's parent follower", "brokkr_kitbash.close", {"object_name": "Rocker", "socket": "end_a_back", "other_name": "Loose", "other_socket": "end_a"},
"'Rocker' follows as the parent of a loop")
# --- ratios -----------------------------------------------------------------------------------------------------------------
place("Cap", "strut", W), place("Pinion", "strut", W), place("X_Barrel", "ram_barrel"), place("X_Rod", "ram_rod")
attach("Cap", "end_a", "Crank", "end_a_back", 0.0)
attach("Pinion", "end_a", "Ground", "end_b_back", 0.0)
attach("X_Barrel", "base", "Ground", "end_a_back", 90.0)
attach("X_Rod", "piston", "X_Barrel", "bore", 0.0)
cap, pinion, x_rod = (bpy.data.objects[name] for name in ("Cap", "Pinion", "X_Rod"))
half = '{"driver": "Crank", "kind": "ratio", "k": 0.5, "offset": 0}'
refused("a ratio whose driver states no limits (F3)", "brokkr_kitbash.follow", {"object_name": "Cap", "record": half}, "'Cap' follows it by ratio, and a ratio's driver states limits")
send("brokkr_kitbash.joint", object_name="Crank", record='{"limits": [-2, 160], "mechanism": "crank"}')
receipts = [send("brokkr_kitbash.follow", object_name="Cap", record=half), send("brokkr_kitbash.follow", object_name="Pinion", record='{"driver": "Crank", "kind": "ratio", "k": -3, "offset": 10}'),
send("brokkr_kitbash.follow", object_name="X_Rod", record='{"driver": "Crank", "kind": "ratio", "k": 0.001, "offset": 0.02}')]
def ratios():
at = crank["kit_roll"]
return max(reading("ratio", turned(cap["kit_roll"], 0.5 * at)), reading("ratio", turned(pinion["kit_roll"], -3.0 * at + 10.0)), reading("ratio", abs(x_rod["kit_slide"] - (0.001 * at + 0.02))))
check("a kneecap at k 0.5, a pinion at k -3 and a crosshead's slide at 0.001 m a degree follow the crank at once: each is k x its roll + offset",
all(receipt["status"] == "accepted" for receipt, _ in receipts) and ratios() < RATIO and abs(cap["kit_roll"] - 15.0) < RATIO and abs(x_rod["kit_slide"] - 0.05) < RATIO
and [f["part"] for f in receipts[2][1]["followers"]] == ["Cap", "Pinion", "X_Rod", "Rocker", "Coupler"]
and receipts[2][1]["connection"]["follows"] == {"driver": "Crank", "kind": "ratio", "k": 0.001, "offset": 0.02, "holds": True, "reason": None}
and connection("X_Rod")["holds"] and connection("Cap")["holds"], [[r["message"] for r, _ in receipts], R["readings"], receipts[2][1] and receipts[2][1].get("followers")])
receipt, report = send("brokkr_kitbash.roll", object_name="Crank", roll=120.0)
seed = stepped(solve_four_bar, seed, D0, 120.0, 5.0)
check("rolling the crank moves ratio followers and the loop in one action: ratios first in the report, the pinion's roll brought inside a turn",
receipt["status"] == "accepted" and ratios() < RATIO and abs(pinion["kit_roll"] - 10.0) < RATIO and abs(x_rod["kit_slide"] - 0.14) < RATIO
and reading("closed", apart(coupler, "end_b", crank, "end_b")) < CLOSED and reading("solved", turned(rocker["kit_roll"], seed[0])) < SOLVED
and reading("slid", float(np.linalg.norm(frame(x_rod, "piston")[:3, 3] - frame(x_rod.parent, "bore")[:3, 3] - 0.14 * frame(x_rod.parent, "bore")[:3, 2]))) < CLOSED
and [f["part"] for f in report["followers"]] == ["Cap", "Pinion", "X_Rod", "Rocker", "Coupler"], [receipt["message"], R["readings"], pinion["kit_roll"], x_rod["kit_slide"]])
refused("slide on a follower", "brokkr_kitbash.slide", {"object_name": "X_Rod", "slide": 0.1}, "'X_Rod' follows 'Crank' (ratio): its value is derived")
send("brokkr_kitbash.joint", object_name="Cap", record='{"limits": [0, 70]}')
refused("a pose of the driver that takes a follower outside its own limits: the driver is not written either (F5)", "brokkr_kitbash.roll", {"object_name": "Crank", "roll": 150.0},
"'Cap' on 'Crank': its roll 75 is outside the joint's limits 0 to 70")
refused("clearing the limits of a driver a ratio follows", "brokkr_kitbash.joint", {"object_name": "Crank", "record": '{"limits": null}'}, "'Cap' follows it by ratio, and a ratio's driver states limits")
receipt, report = send("brokkr_kitbash.follow", object_name="Pinion", record="null")
cleared = receipt["status"] == "accepted" and report["cleared"] == ["Pinion"] and report["connection"]["follows"] is None and "kit_follows" not in pinion and "kit_follows_driver" not in pinion
receipt, report = send("brokkr_kitbash.roll", object_name="Pinion", roll=33.0)
check("follow with null clears the statement, and the part is posed by hand again", cleared and receipt["status"] == "accepted" and abs(pinion["kit_roll"] - 33.0) < RATIO, [receipt["message"]])
# --- two loops: a ram closing on the rocker, solved after the four-bar ---------------------------------------------------
send("brokkr_kitbash.roll", object_name="Crank", roll=D0)
seed = stepped(solve_four_bar, seed, 120.0, D0, 5.0)
a_barrel, a_rod = place("A_Barrel", "ram_barrel"), place("A_Rod", "ram_rod")
def rod_end(pad_world, values, pin=None):
return (pad_world @ core.mate(pin or socket(ground, "end_a"), socket(a_barrel, "base"), values[0]) @ core.mate(socket(a_barrel, "bore"), socket(a_rod, "piston"), 0.0, values[1])
@ socket(a_rod, "rod_end")["matrix"])
# one driver: a ram on a second crank closes on the rocker, which follows the first (the probe of finding second-driver-loop-opens)
place("S_Barrel", "ram_barrel"), place("S_Rod", "ram_rod")
crank2 = place("Crank2", "strut", W + "length=0.4")
shift = np.eye(4)
shift[:3, 3] = frame(rocker, "end_b_back")[:3, 3] - rod_end(turn, RAM_REST, socket(crank2, "end_b"))[:3, 3]
place("Ground2", "strut", W + "length=0.8", shift @ turn @ np.linalg.inv(core.mate(socket(ground, "end_a"), socket(crank2, "end_a"), 20.0)))
attach("Crank2", "end_a", "Ground2", "end_a", 20.0)
attach("S_Barrel", "base", "Crank2", "end_b", RAM_REST[0])
attach("S_Rod", "piston", "S_Barrel", "bore", 0.0)
send("brokkr_kitbash.slide", object_name="S_Rod", slide=RAM_REST[1])
receipt, report = send("brokkr_kitbash.close", object_name="S_Rod", socket="rod_end", other_name="Rocker", other_socket="end_b_back")
check("a ram on a second crank stands closed on the rocker", receipt["status"] == "accepted" and report["closure"]["holds"] is True, [receipt["message"], report and report["closure"]])
refused("a loop whose ends depend on two drivers: its base is its own driver and the part it closes on follows another", "brokkr_kitbash.follow",
{"object_name": "S_Rod", "record": '{"driver": "Crank2", "kind": "loop"}'},
"'Crank2' (the base) and 'Rocker' (closed on), depend on more than one driver: 'Crank2' and 'Crank' ('Rocker' follows it)", "A follower takes its value from one driver")
refused("and with the crank as the driver: the ram's base hangs from the second crank, which is posed by hand", "brokkr_kitbash.follow", {"object_name": "S_Rod", "record": loop},
"depend on more than one driver: 'Crank' and 'Crank2' (it follows nothing and its joint has travel, so it is posed by hand)")
receipt, _ = send("brokkr_kitbash.detach", object_name="S_Rod")
check("the refused ram is detached, and the rocker's pin is free again", receipt["status"] == "accepted" and "kit_close" not in bpy.data.objects["S_Rod"], receipt["message"])
shift = np.eye(4)
shift[:3, 3] = frame(rocker, "end_b_back")[:3, 3] - rod_end(turn, RAM_REST)[:3, 3]
pad = place("Pad", "strut", W + "length=0.8", shift @ turn)
attach("A_Barrel", "base", "Pad", "end_a", RAM_REST[0])
attach("A_Rod", "piston", "A_Barrel", "bore", 0.0)
send("brokkr_kitbash.slide", object_name="A_Rod", slide=RAM_REST[1])
send("brokkr_kitbash.close", object_name="A_Rod", socket="rod_end", other_name="Rocker", other_socket="end_b_back")
receipt, report = send("brokkr_kitbash.follow", object_name="A_Rod", record=loop)
check("a ram on its own ground pin closes on the rocker and follows the crank: the end it closes on follows the driver",
receipt["status"] == "accepted" and [f["part"] for f in report["followers"]] == ["Cap", "X_Rod", "Rocker", "Coupler", "A_Barrel", "A_Rod"]
and report["connection"]["follows"]["holds"] is True, [receipt["message"], report and report.get("followers")])
ram_loop = [(socket(pad, "end_a"), socket(a_barrel, "base"), "revolute"), (socket(a_barrel, "bore"), socket(a_rod, "piston"), "prismatic")]
ram_seed = RAM_REST
for roll in (60.0, 110.0, 45.0):
was = crank["kit_roll"]
receipt, report = send("brokkr_kitbash.roll", object_name="Crank", roll=roll)
count = max(1, math.ceil(abs(roll - was) / 5.0))
for index in range(1, count + 1): # this file's own derivation: at each step the four-bar, then the ram against the rocker where that step put it
seed, _ = solve_four_bar(was + (roll - was) * index / count, seed)
pin = rocker_world(world(base), seed[0]) @ socket(rocker, "end_b_back")["matrix"]
ram_seed, _ = core.close_loop(world(pad), ram_loop, socket(a_rod, "rod_end"), pin, ram_seed)
R["readings"][f"ram closed at {roll:g}"], R["readings"][f"ram solved at {roll:g}"] = apart(a_rod, "rod_end", rocker, "end_b_back"), turned(a_barrel["kit_roll"], ram_seed[0])
check(f"rolling the crank to {roll:g} solves the four-bar and then the ram that closes on its rocker (F11): both closures hold and the barrel's roll and rod's slide are this file's own",
receipt["status"] == "accepted" and reading("closed", apart(a_rod, "rod_end", rocker, "end_b_back")) < CLOSED and reading("closed", apart(coupler, "end_b", crank, "end_b")) < CLOSED
and reading("solved", turned(a_barrel["kit_roll"], ram_seed[0])) < SOLVED and reading("closed", abs(a_rod["kit_slide"] - ram_seed[1])) < CLOSED
and [f["part"] for f in report["followers"]][-4:] == ["Rocker", "Coupler", "A_Barrel", "A_Rod"]
and [row for row in report["closures"] if not row["holds"]] == [], [receipt["message"], R["readings"], a_barrel["kit_roll"], a_rod["kit_slide"], ram_seed])
# --- one driver, after the loop is stated: each action that could give a loop a second one refuses it -------------------------
place("P_Mount", "strut", W + "length=0.8", far @ far @ far @ far @ far @ turn)
refused("attach after the loop is stated: the ram's pad hung on a free pin is a second driver between the loop's ends", "brokkr_kitbash.attach",
{"object_name": "Pad", "socket": "end_b", "parent_name": "P_Mount", "parent_socket": "end_a", "roll": 0.0},
"the two ends of the loop 'A_Rod' closes, 'Pad' (the base) and 'Rocker' (closed on), depend on more than one driver: 'Crank' and 'Pad' (it follows nothing and its joint has travel",
"clear the loop (brokkr_kitbash.follow on 'A_Rod' with record null)")
refused("clear after the loop is stated: the four-bar's rocker, no longer a follower, is a second driver of the ram that closes on it", "brokkr_kitbash.follow",
{"object_name": "Coupler", "record": "null"},
"the two ends of the loop 'A_Rod' closes, 'Pad' (the base) and 'Rocker' (closed on), depend on more than one driver: 'Crank' and 'Rocker' (it follows nothing and its joint has travel")
# --- a torque link: a slide drives two arms ---------------------------------------------------------------------------------
t_barrel, t_rod = place("T_Barrel", "ram_barrel", "", far @ turn), place("T_Rod", "ram_rod")
t_upper, t_lower, t_lug = place("T_Upper", "strut", W + "length=0.5"), place("T_Lower", "strut", W + "length=0.5"), place("T_Lug", "strut", W + "length=0.3")
attach("T_Rod", "piston", "T_Barrel", "bore", 0.0)
send("brokkr_kitbash.joint", object_name="T_Rod", record='{"limits": [0, 0.3], "mechanism": "oleo", "compliance": {"hertz": 3, "damping_ratio": 0.6}}')
send("brokkr_kitbash.slide", object_name="T_Rod", slide=0.05)
attach("T_Lug", "end_a", "T_Rod", "rod_end_back", 90.0)
link = [(socket(t_barrel, "base_back"), socket(t_upper, "end_a"), "revolute"), (socket(t_upper, "end_b"), socket(t_lower, "end_a"), "revolute")]
def lug_pin(slide):
return (world(t_barrel) @ core.mate(socket(t_barrel, "bore"), socket(t_rod, "piston"), 0.0, slide) @ core.mate(socket(t_rod, "rod_end_back"), socket(t_lug, "end_a"), 90.0)
@ socket(t_lug, "end_b")["matrix"])
def solve_link(slide, values):
return core.close_loop(world(t_barrel), link, socket(t_lower, "end_b"), lug_pin(slide), values)
arms = None
for guess in ((40.0, 100.0), (-40.0, -100.0), (140.0, 100.0), (-140.0, -100.0), (90.0, 90.0), (-90.0, -90.0), (10.0, 150.0), (-10.0, -150.0)):
try:
arms, _ = solve_link(0.05, guess)
break
except core.KitError:
continue
check("the torque link's rest pose is found: two arms from the barrel's pin to the lug on the rod", arms is not None, "no guess closed the loop")
arms = tuple(core._wrapped(v) for v in arms)
attach("T_Upper", "end_a", "T_Barrel", "base_back", arms[0])
attach("T_Lower", "end_a", "T_Upper", "end_b", arms[1])
send("brokkr_kitbash.close", object_name="T_Lower", socket="end_b", other_name="T_Lug", other_socket="end_b")
refused("a loop that closes on a part hung from the driver by a free pin: the lug's roll is a second input (the probe of finding torque-link-lug-is-a-free-dof)", "brokkr_kitbash.follow",
{"object_name": "T_Lower", "record": '{"driver": "T_Rod", "kind": "loop"}'},
"'T_Barrel' (the base) and 'T_Lug' (closed on), depend on more than one driver: 'T_Rod' and 'T_Lug' (it follows nothing and its joint has travel, so it is posed by hand)")
receipt, report = send("brokkr_kitbash.joint", object_name="T_Lug", record='{"limits": [90, 90], "mechanism": "lug"}')
check("limits of one value hold the lug on the rod: a pin with no travel", receipt["status"] == "accepted" and report["connection"]["limits"] == [90.0, 90.0], receipt["message"])
receipt, report = send("brokkr_kitbash.follow", object_name="T_Lower", record='{"driver": "T_Rod", "kind": "loop"}')
check("the arms follow the rod's slide as a loop: its base is the barrel, above the driver, and it closes on a part that hangs from the driver",
receipt["status"] == "accepted" and [f["part"] for f in report["followers"]] == ["T_Upper", "T_Lower"], [receipt["message"], report and report.get("followers")])
for slide in (0.15, 0.0, 0.11):
was = t_rod["kit_slide"]
receipt, report = send("brokkr_kitbash.slide", object_name="T_Rod", slide=slide)
arms = stepped(solve_link, arms, was, slide, 0.02)
check(f"sliding the rod to {slide:g} folds the arms: the closure holds in the scene and the rolls are this file's own stepped solve",
receipt["status"] == "accepted" and reading("closed", apart(t_lower, "end_b", t_lug, "end_b")) < CLOSED
and max(reading("solved", turned(t_upper["kit_roll"], arms[0])), reading("solved", turned(t_lower["kit_roll"], arms[1]))) < SOLVED
and report["closures"][0]["holds"] is True, [receipt["message"], R["readings"], t_upper["kit_roll"], t_lower["kit_roll"], arms])
refused("a slide outside the driver's limits", "brokkr_kitbash.slide", {"object_name": "T_Rod", "slide": 0.4}, "its slide 0.4 is outside the joint's limits 0 to 0.3")
refused("a roll of the held lug: no pose opens the torque link", "brokkr_kitbash.roll", {"object_name": "T_Lug", "roll": 100.0}, "'T_Lug' on 'T_Rod': its roll 100 is outside the joint's limits 90 to 90")
for label, limits in (("widened", "[80, 100]"), ("cleared", "null")):
refused(f"limits {label} after the loop is stated: the lug, given travel, is a second driver of the torque link", "brokkr_kitbash.joint",
{"object_name": "T_Lug", "record": '{"limits": %s}' % limits},
"the two ends of the loop 'T_Lower' closes, 'T_Barrel' (the base) and 'T_Lug' (closed on), depend on more than one driver: 'T_Rod' and 'T_Lug' (it follows nothing and its joint has travel")
t_lug["kit_min"], t_lug["kit_max"] = 80.0, 100.0 # by hand, past every action: the next write of any pose reads the rule
refused("a pose of the driver after the lug's limits were widened by hand: the writer reads the rule before it writes", "brokkr_kitbash.slide", {"object_name": "T_Rod", "slide": 0.1},
"depend on more than one driver: 'T_Rod' and 'T_Lug' (it follows nothing and its joint has travel")
refused("and a pose of the lug itself", "brokkr_kitbash.roll", {"object_name": "T_Lug", "roll": 95.0}, "depend on more than one driver: 'T_Rod' and 'T_Lug'")
# a second driver no write made is told by every read of the loop, while its closure still stands closed (finding two-driver-loop-reported-nowhere):
# each follower's follows row reads holds false and names both drivers, and the joints report of a tree the loop is in lists the loop by its closing part
told = "the loop 'T_Lower' closes has more than one driver: 'T_Rod' and 'T_Lug' (it follows nothing and its joint has travel, so it is posed by hand)"
rows = {name: send("brokkr_kitbash.report", object_name=name)[1]["parts"][0] for name in ("T_Upper", "T_Lower")}
check("a loop given a second driver by hand reads follows.holds false on both followers, naming both drivers, while its closure holds",
all(row["connection"]["follows"]["holds"] is False and row["connection"]["follows"]["reason"].startswith(told) for row in rows.values())
and rows["T_Lower"]["closure"]["holds"] is True, [{name: row["connection"] for name, row in rows.items()}, rows["T_Lower"]["closure"]])
receipt, joints = send("brokkr_kitbash.joints", object_name="T_Barrel")
receipt2, joints2 = send("brokkr_kitbash.joints", object_name="T_Lug")
receipt3, joints3 = send("brokkr_kitbash.joints", object_name="Ground")
check("the joints report lists a loop with a second driver in manyDrivers, by its closing part and with both drivers: in a report of the whole mechanism, "
"in one of the second driver's own sub-tree, and not in one of a tree the loop is no part of",
all(r["status"] == "accepted" for r in (receipt, receipt2, receipt3)) and joints["manyDrivers"] == [{"loop": "T_Lower", "drivers": ["T_Rod", "T_Lug"]}] == joints2["manyDrivers"]
and joints3["manyDrivers"] == [], [receipt["message"], joints and joints.get("manyDrivers"), joints2 and joints2.get("manyDrivers"), joints3 and joints3.get("manyDrivers")])
# the rule judges the write, not the scene: with the torque link holding a second driver, a write is refused when it touches that loop (a part of it,
# or one it hangs from) or would give another loop a second driver, and every other write is made (finding parent-hook-gates-on-scene-not-change)
shape = lambda *names: {name: np.array([v.co[:] for v in bpy.data.objects[name].data.vertices]).tobytes() for name in names} # noqa: E731
was = shape("T_Lug", "T_Lower")
refused("set_params of the part a two-driver loop closes on (finding set-params-writes-before-the-guard): the rule is read before the mesh is rebuilt",
"brokkr_kitbash.set_params", {"object_name": "T_Lug", "params": "length=0.31"},
"the two ends of the loop 'T_Lower' closes, 'T_Barrel' (the base) and 'T_Lug' (closed on), depend on more than one driver: 'T_Rod' and 'T_Lug' (it follows nothing and its joint has travel", "nothing changed")
check("and nothing moved: the part's vertices read as before the refusal", shape("T_Lug", "T_Lower") == was)
refused("setObjectParent of the root a two-driver loop hangs from: the write touches the loop", "setObjectParent", {"targetObjectName": "T_Barrel", "parentObjectName": "Loose"},
"the two ends of the loop 'T_Lower' closes, 'T_Barrel' (the base) and 'T_Lug' (closed on), depend on more than one driver: 'T_Rod' and 'T_Lug'", "nothing changed")
refused("setObjectParent that gives another loop a second driver, in a scene that already holds one: the four-bar's base under Idle", "setObjectParent",
{"targetObjectName": "Base", "parentObjectName": "Idle"},
"the two ends of the loop 'A_Rod' closes, 'Pad' (the base) and 'Rocker' (closed on), depend on more than one driver: 'Crank' and 'Idle' (it follows nothing and its joint has travel", "nothing changed")
idle, tip_was = bpy.data.objects["Idle"], connection("Tip")
length, was = json.loads(idle["kit_params"])["length"], shape("Idle")
receipt, _ = send("brokkr_kitbash.set_params", object_name="Idle", params="length=0.6")
grown = receipt["status"] == "accepted" and shape("Idle") != was and connection("Tip")["holds"] is True
receipt2, _ = send("brokkr_kitbash.set_params", object_name="Idle", params=f"length={length!r}")
check("set_params of a part no loop hangs from is written in a scene that holds a second driver, and set back",
grown and receipt2["status"] == "accepted" and shape("Idle") == was and connection("Tip") == tip_was and tip_was["holds"] is True, [receipt["message"], receipt2["message"], tip_was, connection("Tip")])
rolled = idle["kit_roll"]
receipt, _ = send("brokkr_kitbash.roll", object_name="Idle", roll=rolled + 5.0)
receipt2, _ = send("brokkr_kitbash.roll", object_name="Idle", roll=rolled)
check("a pose of a joint no loop hangs from is written in a scene that holds a second driver", receipt["status"] == "accepted" and receipt2["status"] == "accepted", [receipt["message"], receipt2["message"]])
plain, cam = bpy.data.objects.new("PlainEmpty", None), bpy.data.objects.new("Cam", bpy.data.cameras.new("Cam")) # Soul's probe P2a, P2b: neither is a kit part
for made in (plain, cam):
bpy.context.scene.collection.objects.link(made)
asked = []
for name, parent in (("Cam", "PlainEmpty"), ("PlainEmpty", "Ground"), ("PlainEmpty", "T_Lug"), ("Cam", "")):
receipt, _ = send("setObjectParent", targetObjectName=name, parentObjectName=parent)
asked.append((receipt["status"], bpy.data.objects[name].parent and bpy.data.objects[name].parent.name, str(receipt["message"])[:200]))
check("setObjectParent of a camera under an empty, of the empty under a kit part and under a part of the two-driver loop itself, and clearing the camera's, "
"are written in a scene that holds a second driver: nothing of a loop hangs from them",
[row[:2] for row in asked] == [("accepted", "PlainEmpty"), ("accepted", "Ground"), ("accepted", "T_Lug"), ("accepted", None)], asked)
receipt, _ = send("setObjectParent", targetObjectName="T_Barrel", parentObjectName="Cam")
check("and the loop's root under that camera is refused: the camera is no kit part, the root is what the loop hangs from",
receipt["status"] != "accepted" and "depend on more than one driver: 'T_Rod' and 'T_Lug'" in str(receipt["message"]) and t_barrel.parent is None, [receipt["status"], receipt["message"]])
for made in (cam, plain):
bpy.data.objects.remove(made)
# a loop whose driver neither end hangs from, stated by hand on Loose and closing on Tip, whose two free pins are second drivers: a write of the
# driver that poses nothing (its followers are not written) still touches the loop
place("H_Upper", "strut", W), place("H_Lower", "strut", W)
attach("H_Upper", "end_a", "Loose", "end_a", 30.0), attach("H_Lower", "end_a", "H_Upper", "end_b", 40.0)
h_upper, h_lower = bpy.data.objects["H_Upper"], bpy.data.objects["H_Lower"]
h_lower["kit_close_socket"], h_lower["kit_close_to"], h_lower["kit_close_to_socket"] = "end_b", bpy.data.objects["Tip"], "end_b"
for made in (h_upper, h_lower):
made["kit_follows"], made["kit_follows_driver"] = '{"kind": "loop"}', crank
refused("set_params of the driver of a two-driver loop that neither end hangs from: the write touches the loop", "brokkr_kitbash.set_params",
{"object_name": "Crank", "params": f"length={json.loads(crank['kit_params'])['length']!r}"},
"the two ends of the loop 'H_Lower' closes, 'Loose' (the base) and 'Tip' (closed on), depend on more than one driver: 'Crank' and 'Idle' (it follows nothing and its joint has travel", "nothing changed")
for made in (h_lower, h_upper):
bpy.data.objects.remove(made)
t_lug["kit_min"], t_lug["kit_max"] = 90.0, 90.0
receipt, report = send("brokkr_kitbash.slide", object_name="T_Rod", slide=0.11)
check("with the lug held again the driver is posed", receipt["status"] == "accepted" and report["closures"][0]["holds"] is True, receipt["message"])
receipt, report = send("brokkr_kitbash.report", object_name="T_Lower")
receipt2, joints = send("brokkr_kitbash.joints", object_name="T_Barrel")
check("and with one driver again the follower's follows row holds and the joints report lists no loop",
receipt["status"] == "accepted" and receipt2["status"] == "accepted" and report["parts"][0]["connection"]["follows"] == {"driver": "T_Rod", "kind": "loop", "k": None, "offset": None, "holds": True, "reason": None}
and joints["manyDrivers"] == [], [receipt["message"], report and report["parts"][0]["connection"], joints and joints.get("manyDrivers")])
receipt, joints = send("brokkr_kitbash.joints", object_name="T_Barrel")
check("the torque link has one degree of freedom: the rod's slide is its one row with travel that nothing drives, the lug is its one held row, the arms are driven, and no row is unlimited",
receipt["status"] == "accepted" and [(row["id"], row["kind"], row["driven"] and row["driven"]["by"], row["min"], row["max"], row["held"]) for row in joints["joints"]] == [
("T_Rod", "prismatic", None, -0.11, 0.19, False), ("T_Lug", "revolute", None, 0.0, 0.0, True), ("T_Upper", "revolute", "T_Rod", None, None, False), ("T_Lower", "revolute", "T_Rod", None, None, False)]
and joints["unlimited"] == [] and reading("closed", apart(t_lower, "end_b", t_lug, "end_b")) < CLOSED, [receipt["message"], joints])
place("T_Mount", "strut", W, far @ far @ far @ far @ turn)
hinged = attach("T_Barrel", "base", "T_Mount", "end_a", 25.0)
receipt, report = send("brokkr_kitbash.follow", object_name="T_Lower", record="null")
cleared = receipt["status"] == "accepted" and report["cleared"] == ["T_Upper", "T_Lower"]
receipt, report = send("brokkr_kitbash.follow", object_name="T_Lower", record='{"driver": "T_Rod", "kind": "loop"}')
check("a joint both ends of a loop hang from is not one the loop depends on: the barrel hung on a free hinge, the arms follow the rod again",
hinged and cleared and receipt["status"] == "accepted" and [f["part"] for f in report["followers"]] == ["T_Upper", "T_Lower"]
and reading("closed", apart(t_lower, "end_b", t_lug, "end_b")) < CLOSED, [hinged, cleared, receipt["message"]])
refused("detach after the loop is stated: the lug cut from the rod no longer hangs from the barrel, so the barrel's free hinge is a second driver", "brokkr_kitbash.detach",
{"object_name": "T_Lug"},
"the two ends of the loop 'T_Lower' closes, 'T_Barrel' (the base) and 'T_Lug' (closed on), depend on more than one driver: 'T_Rod' and 'T_Barrel' (it follows nothing and its joint has travel")
refused("setObjectParent clearing the lug's parent (finding bridge-reparent-bypasses-the-guard): Brokkr's own row asks the same rule before it writes a parent", "setObjectParent",
{"targetObjectName": "T_Lug", "parentObjectName": ""},
"the two ends of the loop 'T_Lower' closes, 'T_Barrel' (the base) and 'T_Lug' (closed on), depend on more than one driver: 'T_Rod' and 'T_Barrel' (it follows nothing and its joint has travel", "nothing changed")
refused("setObjectParent of a root onto a part on a free pin: with the four-bar's base under Idle, the rocker the ram closes on depends on Idle's roll", "setObjectParent",
{"targetObjectName": "Base", "parentObjectName": "Idle"},
"the two ends of the loop 'A_Rod' closes, 'Pad' (the base) and 'Rocker' (closed on), depend on more than one driver: 'Crank' and 'Idle' (it follows nothing and its joint has travel", "nothing changed")
receipt, _ = send("setObjectParent", targetObjectName="Loose", parentObjectName="Idle")
under = bpy.data.objects["Loose"].parent
receipt2, _ = send("setObjectParent", targetObjectName="Loose", parentObjectName="")
check("setObjectParent of a part no loop depends on is written as before, and cleared again", receipt["status"] == "accepted" and under == bpy.data.objects["Idle"]
and receipt2["status"] == "accepted" and bpy.data.objects["Loose"].parent is None, [receipt["message"], receipt2["message"]])
# --- joints, version 2 ----------------------------------------------------------------------------------------------------------
receipt, joints = send("brokkr_kitbash.joints", object_name="Ground")
table = {row["id"]: row for row in (joints or {}).get("joints", [])}
check("joints is version 2: a driven row names what drives it (F6), and unlimited lists the rows that are not driven and state no limits",
receipt["status"] == "accepted" and joints["version"] == 2 and [row["id"] for row in joints["joints"]] == ["Crank", "Cap", "Idle", "Tip", "Pinion", "X_Barrel", "X_Rod"]
and table["Crank"]["driven"] is None and table["Cap"]["driven"] == {"by": "Crank", "kind": "ratio", "k": 0.5, "offset": 0.0}
and table["X_Rod"]["driven"] == {"by": "Crank", "kind": "ratio", "k": 0.001, "offset": 0.02} and table["X_Rod"]["kind"] == "prismatic"
and joints["unlimited"] == ["Idle", "Tip", "Pinion", "X_Barrel"] and joints["next"] is None and "jointsOmitted" not in joints, [receipt["message"], joints])
receipt, joints = send("brokkr_kitbash.joints", object_name="Base")
check("a loop's two followers are driven rows, kind loop", receipt["status"] == "accepted" and [(row["id"], row["driven"]) for row in joints["joints"]] == [
("Rocker", {"by": "Crank", "kind": "loop", "k": None, "offset": None}), ("Coupler", {"by": "Crank", "kind": "loop", "k": None, "offset": None})] and joints["unlimited"] == [], joints)
receipt, joints = send("brokkr_kitbash.joints", object_name="T_Rod")
check("a root that states a DOF connection has its own row first, parent null", receipt["status"] == "accepted"
and [(row["id"], row["parent"], row["kind"]) for row in joints["joints"]] == [("T_Rod", None, "prismatic"), ("T_Lug", "T_Rod", "revolute")]
and joints["joints"][0]["compliance"] == {"damping_ratio": 0.6, "hertz": 3.0} and joints["rigid"] == 0, joints)
receipt, joints = send("brokkr_kitbash.joints", object_name="Ground", after="Idle")
check("after carries the rows after an id (F12)", receipt["status"] == "accepted" and [row["id"] for row in joints["joints"]] == ["Tip", "Pinion", "X_Barrel", "X_Rod"]
and joints["joints"][0]["parent"] == "Idle" and joints["unlimited"] == ["Tip", "Pinion", "X_Barrel"], joints)
refused("after an id that is no row's", "brokkr_kitbash.joints", {"object_name": "Ground", "after": "Base"}, "after 'Base' is not the id of a joint under 'Ground'")
long = [f"Actuator_joint_name_that_is_long_but_legal_in_blender_{index:04d}_x" for index in range(265)] # 62 characters, of the 63 Blender takes
place(long[0], "strut", W + "length=0.3", far @ far @ turn)
place(long[1], "strut", W + "length=0.3")
attach(long[1], "end_a", long[0], "end_a", 7.0)
for chain, on in enumerate(("end_a", "end_a_back", "end_b", "end_b_back")): # four chains of 66 on the root's four pins: 264 joints, none limited
for index in range(max(2, chain * 66 + 1), chain * 66 + 67): # copies of the one attached by the actions, each stating its own connection: the report reads what is stated
copy = bpy.data.objects[long[1]].copy()
copy.name, copy.parent = long[index], bpy.data.objects[long[0] if index == chain * 66 + 1 else long[index - 1]]
copy["kit_parent_socket"] = on if index == chain * 66 + 1 else "end_b"
bpy.context.scene.collection.objects.link(copy)
pages, after = [], ""
for _ in range(2): # the first two reports; each costs a pass over the 264 parts
receipt, page = send("brokkr_kitbash.joints", object_name=long[0], after=after)
pages.append((receipt["status"], len(receipt.get("hostResult") or ""), page or {}))
after = (page or {}).get("next") or ""
carried = [[row["id"] for row in page.get("joints", [])] for _, _, page in pages]
R["readings"]["rows in the first receipt"], R["readings"]["longest receipt"] = len(carried[0]), max(size for _, size, _ in pages)
check("a tree of 264 unlimited joints with long names, whose ids alone are over a receipt, is many reports and none over a receipt: each carries rows, the ids of its own "
"rows as unlimited, a count of what it omits and the last id it carries as next, and after it the next carries on",
all(status == "accepted" and size <= 16000 and page.get("joints") and page["unlimited"] == ids and page["next"] == ids[-1] for (status, size, page), ids in zip(pages, carried))
and sum(len(json.dumps(name)) + 1 for name in long[1:]) > 16000 and [name for ids in carried for name in ids] == long[1:len(carried[0]) + len(carried[1]) + 1]
and [page["jointsOmitted"] for _, _, page in pages] == [264 - len(carried[0]), 264 - len(carried[0]) - len(carried[1])],
[[(status, size, len(ids), page.get("jointsOmitted"), page.get("next")) for (status, size, page), ids in zip(pages, carried)]])
# --- the joint-records Lows -------------------------------------------------------------------------------------------------
send("brokkr_kitbash.joint", object_name="Idle", record='{"limits": [0, 30]}')
idle = bpy.data.objects["Idle"]
idle["kit_roll"] = 50.0 # by hand: no action writes a roll outside its limits
refused("set_params of a part whose roll was written by hand outside its limits (F9): the mesh is not rebuilt", "brokkr_kitbash.set_params", {"object_name": "Idle", "params": "length=0.6"},
"'Idle' on 'Ground': its roll 50 is outside the joint's limits 0 to 30")
refused("and of its parent", "brokkr_kitbash.set_params", {"object_name": "Ground", "params": "length=0.9"}, "'Idle' on 'Ground': its roll 50 is outside the joint's limits 0 to 30")
idle["kit_roll"], idle["kit_slide"] = 15.0, 0.1
refused("set_params of a part with a slide written by hand on a revolute connection", "brokkr_kitbash.set_params", {"object_name": "Idle", "params": "length=0.6"},
"socket type 'pivot' is revolute: only a prismatic connection slides")
del idle["kit_slide"]
idle["kit_compliance"] = '{"damping_ratio": 0.7, "hertz": 4.0}' # by hand: a compliance is a prismatic joint's
receipt, joints = send("brokkr_kitbash.joints", object_name="Idle")
row = connection("Idle")
check("a compliance written by hand on a revolute joint reads null in the report and the joints report (F10), and the limits beside it still read",
receipt["status"] == "accepted" and row["compliance"] is None and row["limits"] == [0.0, 30.0] and joints["joints"][0]["id"] == "Idle" and joints["joints"][0]["compliance"] is None, [row, joints])
receipt, report = send("brokkr_kitbash.set_params", object_name="Idle", params="length=0.6")
check("set_params seats through the one writer: the part is rebuilt, its child seated on the moved socket, and the hand-written compliance is gone",
receipt["status"] == "accepted" and "kit_compliance" not in idle and connection("Tip")["holds"] and reading("closed", apart(bpy.data.objects["Tip"], "end_a", idle, "end_b")) < CLOSED,
[receipt["message"], sorted(idle.keys())])
# --- detach ---------------------------------------------------------------------------------------------------------------------
receipt, report = send("brokkr_kitbash.detach", object_name="T_Lower")
upper_row = connection("T_Upper")
check("detaching a loop's closing follower clears its partner's statement too", receipt["status"] == "accepted" and upper_row["follows"] is None
and not [k for o in (t_upper, t_lower) for k in o.keys() if k.startswith("kit_follows")], [receipt["message"], upper_row, sorted(t_upper.keys())])
receipt, report = send("brokkr_kitbash.roll", object_name="T_Upper", roll=12.0)
check("and the partner is posed by hand again", receipt["status"] == "accepted", receipt["message"])
receipt, report = send("brokkr_kitbash.detach", object_name="Crank")
cap_row, coupler_row = connection("Cap"), connection("Coupler")
check("detaching a driver leaves its followers' statements, which report that the driver states no DOF connection",
receipt["status"] == "accepted" and cap_row["follows"] == {"driver": "Crank", "kind": "ratio", "k": 0.5, "offset": 0.0, "holds": False, "reason": "the driver states no DOF connection"}
and coupler_row["follows"]["holds"] is False and coupler_row["follows"]["reason"] == "the driver states no DOF connection", [receipt["message"], cap_row, coupler_row])
bpy.data.objects.remove(crank)
coupler_row = connection("Coupler")
check("and once the driver is deleted, that it is gone", coupler_row["follows"]["driver"] is None and coupler_row["follows"]["reason"] == "the driver is gone: deleted, or in no collection", coupler_row)
constrained = [o.name for o in bpy.data.objects if o.constraints or (o.animation_data and o.animation_data.drivers)]
check("no Blender driver or constraint was made", constrained == [], constrained)
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, printed and written, not a missing result file
check(f"no uncaught error after: {R['checks'][-1]['name'] if R['checks'] else 'the start'}", False, traceback.format_exc().splitlines()[-8:])
R["ok"] = all(c["ok"] for c in R["checks"])
R["readings"] = {name: float(f"{value:.2g}") for name, value in sorted(R["readings"].items())}
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
print("READINGS", R["readings"], flush=True)
sys.exit(0 if R["ok"] else 1)

View file

@ -0,0 +1,517 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "follow loads as a host action after joints, with no errors",
"ok": true,
"detail": null
},
{
"name": "the four-bar stands closed at rest: crank on Ground, rocker on Base, the coupler's end closing on the crank's",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a loop whose two ends both stand still when the driver moves (F7)",
"ok": true,
"detail": null
},
{
"name": "a loop whose base hangs from the part it closes on stands closed",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a loop whose two ends both move with the driver (F7, the other half)",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a loop follower that states no closure",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a follower on a rigid connection",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a follower that is not attached",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a part that follows itself",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a driver below its follower",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a record that is not one of the three shapes: {\"driver\": \"Crank\", \"kind\": \"ratio\", \"k\": 0, \"offset\": 0}",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a record that is not one of the three shapes: {\"driver\": \"Crank\", \"kind\": \"ratio\", \"k\": 1}",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a record that is not one of the three shapes: {\"driver\": \"Crank\", \"kind\": \"gear\"}",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a record that is not one of the three shapes: {\"driver\": \"Crank\", \"kind\": \"loop\", \"k\": 1}",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a record that is not one of the three shapes: [1, 2]",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a record that is not one of the three shapes: {\"a\"",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: clearing a part that follows nothing",
"ok": true,
"detail": null
},
{
"name": "follow states the loop on the closing part and its parent, both following the crank, and the report lists them as written",
"ok": true,
"detail": null
},
{
"name": "rolling the crank a 45 degree turn moves rocker and coupler with it: the closure holds in the scene and the rolls are this file's own stepped solve",
"ok": true,
"detail": null
},
{
"name": "rolling the crank to 120 past rest moves rocker and coupler with it: the closure holds in the scene and the rolls are this file's own stepped solve",
"ok": true,
"detail": null
},
{
"name": "rolling the crank and back to rest moves rocker and coupler with it: the closure holds in the scene and the rolls are this file's own stepped solve",
"ok": true,
"detail": null
},
{
"name": "rolling the crank 30 the other way moves rocker and coupler with it: the closure holds in the scene and the rolls are this file's own stepped solve",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: the crank driven past the loop's dead centre, naming the driver's value and the closing part",
"ok": true,
"detail": null
},
{
"name": "a jump from beside the toggle that one solve from the stated rolls does not survive ends on the stepped answer, the branch the linkage is on (F2)",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: roll on the follower Rocker, naming its driver (F4)",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: roll on the follower Coupler, naming its driver (F4)",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: aim on a follower",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: reach on a follower",
"ok": true,
"detail": null
},
{
"name": "joint on a follower states limits and a mechanism and keeps its derived value and its statement",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: joint limits on a follower that do not hold its derived value",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a driver that is itself a follower",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a follower that drives another",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a follower that already follows",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a closure stated by a loop's parent follower",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a ratio whose driver states no limits (F3)",
"ok": true,
"detail": null
},
{
"name": "a kneecap at k 0.5, a pinion at k -3 and a crosshead's slide at 0.001 m a degree follow the crank at once: each is k x its roll + offset",
"ok": true,
"detail": null
},
{
"name": "rolling the crank moves ratio followers and the loop in one action: ratios first in the report, the pinion's roll brought inside a turn",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: slide on a follower",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a pose of the driver that takes a follower outside its own limits: the driver is not written either (F5)",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: clearing the limits of a driver a ratio follows",
"ok": true,
"detail": null
},
{
"name": "follow with null clears the statement, and the part is posed by hand again",
"ok": true,
"detail": null
},
{
"name": "a ram on a second crank stands closed on the rocker",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a loop whose ends depend on two drivers: its base is its own driver and the part it closes on follows another",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: and with the crank as the driver: the ram's base hangs from the second crank, which is posed by hand",
"ok": true,
"detail": null
},
{
"name": "the refused ram is detached, and the rocker's pin is free again",
"ok": true,
"detail": null
},
{
"name": "a ram on its own ground pin closes on the rocker and follows the crank: the end it closes on follows the driver",
"ok": true,
"detail": null
},
{
"name": "rolling the crank to 60 solves the four-bar and then the ram that closes on its rocker (F11): both closures hold and the barrel's roll and rod's slide are this file's own",
"ok": true,
"detail": null
},
{
"name": "rolling the crank to 110 solves the four-bar and then the ram that closes on its rocker (F11): both closures hold and the barrel's roll and rod's slide are this file's own",
"ok": true,
"detail": null
},
{
"name": "rolling the crank to 45 solves the four-bar and then the ram that closes on its rocker (F11): both closures hold and the barrel's roll and rod's slide are this file's own",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: attach after the loop is stated: the ram's pad hung on a free pin is a second driver between the loop's ends",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: clear after the loop is stated: the four-bar's rocker, no longer a follower, is a second driver of the ram that closes on it",
"ok": true,
"detail": null
},
{
"name": "the torque link's rest pose is found: two arms from the barrel's pin to the lug on the rod",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a loop that closes on a part hung from the driver by a free pin: the lug's roll is a second input (the probe of finding torque-link-lug-is-a-free-dof)",
"ok": true,
"detail": null
},
{
"name": "limits of one value hold the lug on the rod: a pin with no travel",
"ok": true,
"detail": null
},
{
"name": "the arms follow the rod's slide as a loop: its base is the barrel, above the driver, and it closes on a part that hangs from the driver",
"ok": true,
"detail": null
},
{
"name": "sliding the rod to 0.15 folds the arms: the closure holds in the scene and the rolls are this file's own stepped solve",
"ok": true,
"detail": null
},
{
"name": "sliding the rod to 0 folds the arms: the closure holds in the scene and the rolls are this file's own stepped solve",
"ok": true,
"detail": null
},
{
"name": "sliding the rod to 0.11 folds the arms: the closure holds in the scene and the rolls are this file's own stepped solve",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a slide outside the driver's limits",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a roll of the held lug: no pose opens the torque link",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: limits widened after the loop is stated: the lug, given travel, is a second driver of the torque link",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: limits cleared after the loop is stated: the lug, given travel, is a second driver of the torque link",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a pose of the driver after the lug's limits were widened by hand: the writer reads the rule before it writes",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: and a pose of the lug itself",
"ok": true,
"detail": null
},
{
"name": "a loop given a second driver by hand reads follows.holds false on both followers, naming both drivers, while its closure holds",
"ok": true,
"detail": null
},
{
"name": "the joints report lists a loop with a second driver in manyDrivers, by its closing part and with both drivers: in a report of the whole mechanism, in one of the second driver's own sub-tree, and not in one of a tree the loop is no part of",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: set_params of the part a two-driver loop closes on (finding set-params-writes-before-the-guard): the rule is read before the mesh is rebuilt",
"ok": true,
"detail": null
},
{
"name": "and nothing moved: the part's vertices read as before the refusal",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: setObjectParent of the root a two-driver loop hangs from: the write touches the loop",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: setObjectParent that gives another loop a second driver, in a scene that already holds one: the four-bar's base under Idle",
"ok": true,
"detail": null
},
{
"name": "set_params of a part no loop hangs from is written in a scene that holds a second driver, and set back",
"ok": true,
"detail": null
},
{
"name": "a pose of a joint no loop hangs from is written in a scene that holds a second driver",
"ok": true,
"detail": null
},
{
"name": "setObjectParent of a camera under an empty, of the empty under a kit part and under a part of the two-driver loop itself, and clearing the camera's, are written in a scene that holds a second driver: nothing of a loop hangs from them",
"ok": true,
"detail": null
},
{
"name": "and the loop's root under that camera is refused: the camera is no kit part, the root is what the loop hangs from",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: set_params of the driver of a two-driver loop that neither end hangs from: the write touches the loop",
"ok": true,
"detail": null
},
{
"name": "with the lug held again the driver is posed",
"ok": true,
"detail": null
},
{
"name": "and with one driver again the follower's follows row holds and the joints report lists no loop",
"ok": true,
"detail": null
},
{
"name": "the torque link has one degree of freedom: the rod's slide is its one row with travel that nothing drives, the lug is its one held row, the arms are driven, and no row is unlimited",
"ok": true,
"detail": null
},
{
"name": "a joint both ends of a loop hang from is not one the loop depends on: the barrel hung on a free hinge, the arms follow the rod again",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: detach after the loop is stated: the lug cut from the rod no longer hangs from the barrel, so the barrel's free hinge is a second driver",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: setObjectParent clearing the lug's parent (finding bridge-reparent-bypasses-the-guard): Brokkr's own row asks the same rule before it writes a parent",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: setObjectParent of a root onto a part on a free pin: with the four-bar's base under Idle, the rocker the ram closes on depends on Idle's roll",
"ok": true,
"detail": null
},
{
"name": "setObjectParent of a part no loop depends on is written as before, and cleared again",
"ok": true,
"detail": null
},
{
"name": "joints is version 2: a driven row names what drives it (F6), and unlimited lists the rows that are not driven and state no limits",
"ok": true,
"detail": null
},
{
"name": "a loop's two followers are driven rows, kind loop",
"ok": true,
"detail": null
},
{
"name": "a root that states a DOF connection has its own row first, parent null",
"ok": true,
"detail": null
},
{
"name": "after carries the rows after an id (F12)",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: after an id that is no row's",
"ok": true,
"detail": null
},
{
"name": "a tree of 264 unlimited joints with long names, whose ids alone are over a receipt, is many reports and none over a receipt: each carries rows, the ids of its own rows as unlimited, a count of what it omits and the last id it carries as next, and after it the next carries on",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: set_params of a part whose roll was written by hand outside its limits (F9): the mesh is not rebuilt",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: and of its parent",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: set_params of a part with a slide written by hand on a revolute connection",
"ok": true,
"detail": null
},
{
"name": "a compliance written by hand on a revolute joint reads null in the report and the joints report (F10), and the limits beside it still read",
"ok": true,
"detail": null
},
{
"name": "set_params seats through the one writer: the part is rebuilt, its child seated on the moved socket, and the hand-written compliance is gone",
"ok": true,
"detail": null
},
{
"name": "detaching a loop's closing follower clears its partner's statement too",
"ok": true,
"detail": null
},
{
"name": "and the partner is posed by hand again",
"ok": true,
"detail": null
},
{
"name": "detaching a driver leaves its followers' statements, which report that the driver states no DOF connection",
"ok": true,
"detail": null
},
{
"name": "and once the driver is deleted, that it is gone",
"ok": true,
"detail": null
},
{
"name": "no Blender driver or constraint was made",
"ok": true,
"detail": null
}
],
"hostErrors": [],
"readings": {
"closed": 6.4e-07,
"jump": 49.0,
"longest receipt": 16000.0,
"ram closed at 110": 2.9e-07,
"ram closed at 45": 5.3e-07,
"ram closed at 60": 2.8e-07,
"ram solved at 110": 5.7e-14,
"ram solved at 45": 0.0,
"ram solved at 60": 0.0,
"ratio": 0.0,
"rows in the first receipt": 32.0,
"slid": 1e-07,
"solved": 3.3e-05
},
"ok": true
}

View file

@ -0,0 +1,510 @@
"""Live proof, in a background Blender, of brokkr_kitbash.hose through run_intent: a bundle of three hoses from an actuator
on one strut to an actuator on the next, around an armour plate and through a point on the knee pin's axis; the pin's
roll range measured without posing anything, and a range that swings the hose into the plate refused by roll; a second
hose that keeps clear of the first; a rebuild in place; a hose from a tank's flange over two clamps to an actuator's
port; and the refusals. Not part of the unittest run: it needs Blender.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/kitbash_hose.py -- <out> [<blend>]
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). <out> is an absolute path; writes <out>.result.json and exits 1 when a check failed. With <blend>, an
absolute path, the scene is saved there at the end.
Bounds follow lodur:ruling:deterministic-bound-margin; each is written beside its constant with the shipped reading
and the least claimed mutant's (cut kit-hose's H list). The checks run inside one try: an uncaught error is a failed
check that names its section, and the result file is always written.
"""
import importlib.util
import json
import math
import os
import sys
import tempfile
import traceback
import types
from pathlib import Path
import bpy
import numpy as np
from mathutils import Vector
from mathutils.bvhtree import BVHTree
SURFACE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(SURFACE / "tools"))
import private_dirs # noqa: E402
_refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if _refused:
raise SystemExit(_refused)
OUT = sys.argv[sys.argv.index("--") + 1]
if not Path(OUT).is_absolute():
raise SystemExit(f"{OUT!r} is not an absolute path")
package = types.ModuleType("brokkr_bridge")
package.__path__ = [str(SURFACE / "brokkr_bridge")]
sys.modules["brokkr_bridge"] = package
from brokkr_bridge import blender_target as bt # noqa: E402
import addon_utils # noqa: E402
spec = importlib.util.spec_from_file_location("brokkr_kitbash_core_reference", SURFACE / "brokkr_kitbash" / "core.py")
core = importlib.util.module_from_spec(spec) # core as the unit tests load it
spec.loader.exec_module(core)
sys.path.append(str(SURFACE))
bpy.ops.wm.read_factory_settings(use_empty=True)
for module in ("brokkr_mesh_polish", "brokkr_kitbash"):
addon_utils.enable(module, default_set=True)
target = bt.BrokkrBlenderTarget(bpy)
WORK = Path(tempfile.mkdtemp(prefix="brokkr-kitbash-hose-"))
target.configure_action_dirs("", str(WORK))
target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1], "readings": {}, "reports": {}, "seconds": {}}
COUNT, SECTION = [0], ["setup"]
kit = core.load_kit("mechanical")
RADIUS, CLEARANCE, COUNT_HOSES = 0.006, 0.005, 3
SPREAD = 2.6 * RADIUS
ENVELOPE = SPREAD + RADIUS # half the bundle's width
LEAD = 8.0 * RADIUS
FLOOR = 4.0 * 2.0 * RADIUS + SPREAD # of the centre line: the innermost hose keeps 4 outside diameters
BUNDLE = {"count": COUNT_HOSES, "radius": RADIUS, "clearance": CLEARANCE}
# Metres between a hose's surface and the nearest other mesh, read on the hose's own vertices further than the lead
# from both its ports (the least is the worst), over every hose this suite makes. Shipped worst 0.031. Least claimed
# mutant 0.0089: H4b (route.verify measures and refuses nothing) accepts the hose past the plate beside a port's
# straight, section "verify", and the ring of it nearest the plate reads that; shipped refuses it and makes no hose.
# The geometric mean, separation 1.8 and 1.9.
CLEAR = 0.017
# Metres a clamped hose's ring vertices stand off the radius about its own line over a clamp (the line through the
# clamp point along the socket's y, offset across the bundle), over the 24 nearest; 1 when a hose has no 24 vertices
# there. Shipped worst 4.6e-08 (float32 meshes); least claimed mutant 1 (C2, the straight laid along the socket's x:
# the route is refused, or no ring stands on the line); the geometric mean, separation 4700 each side.
CLAMPED = 2.1e-4
# Metres along a clamped hose's line from a clamp point to the nearest ring of a bend. Shipped 0.028; least claimed
# mutant 0.013 (C1, no straight kept at a clamp); the geometric mean, separation 1.47 each side.
KEPT = 0.019
def check(name, ok, detail=None):
R["checks"].append({"name": name, "ok": bool(ok), "detail": None if ok else detail})
def reading(name, value, least=False):
"""The worst of a metric: the largest, or with `least` the smallest."""
R["readings"][name] = (min if least else max)(R["readings"].get(name, float(value)), float(value))
return float(value)
def section(name):
SECTION[0] = name
def send(action, **fields):
COUNT[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"live-{COUNT[0]}", "requestedBy": "test/driver", "action": action, **fields})
result = None
if receipt.get("hostResult"):
try:
result = json.loads(receipt["hostResult"])
except ValueError:
result = None
print("SEND", action, receipt["status"], str(receipt["message"])[:400], flush=True)
return receipt, result
def scene_state():
return {o.name: (o.parent and o.parent.name, np.round(np.array(o.matrix_basis), 6).tolist(), {k: repr(o[k]) for k in sorted(o.keys()) if k.startswith("kit_")},
[(m.name, m.type, m.show_viewport) for m in o.modifiers], o.data.name if o.type == "MESH" else None, len(o.data.polygons) if o.type == "MESH" else None,
np.round(np.array([v.co for v in o.data.vertices[:8]]), 6).tolist() if o.type == "MESH" else None)
for o in bpy.data.objects}, sorted(m.name for m in bpy.data.meshes), sorted(c.name for c in bpy.data.collections)
def refused(label, fields, expected):
state = scene_state()
receipt, _ = send("brokkr_kitbash.hose", **fields)
check(f"refused, scene unchanged: {label}", receipt["status"] != "accepted" and expected in str(receipt["message"]) and scene_state() == state,
[receipt["status"], receipt["message"]])
def place(name, part, params="", location=None, rotation=None, parent=None):
send("brokkr_kitbash.place_part", part=part, object_name=name, params=params)
if location is not None:
send("setObjectTransform", targetObjectName=name, location=location, rotationEuler=rotation or [0.0, 0.0, 0.0])
made = bpy.data.objects[name]
if parent is not None: # carried rigidly: a plain parent, which states no connection
bpy.context.view_layer.update()
made.parent = parent
made.matrix_parent_inverse = parent.matrix_world.inverted()
return made
def box(name, low, high, parent=None):
(x0, y0, z0), (x1, y1, z1) = low, high
made = bpy.data.objects.new(name, bpy.data.meshes.new(name))
made.data.from_pydata([(x0, y0, z0), (x1, y0, z0), (x1, y1, z0), (x0, y1, z0), (x0, y0, z1), (x1, y0, z1), (x1, y1, z1), (x0, y1, z1)], [],
[(0, 3, 2, 1), (4, 5, 6, 7), (0, 1, 5, 4), (1, 2, 6, 5), (2, 3, 7, 6), (3, 0, 4, 7)])
bpy.context.scene.collection.objects.link(made)
if parent is not None:
bpy.context.view_layer.update()
made.parent = parent
made.matrix_parent_inverse = parent.matrix_world.inverted()
return made
def frame(obj, name):
"""A socket's world frame, from the object's matrix_world and core's build of its stored params."""
built = core.build(core.part(kit, obj["kit_part"]), json.loads(obj["kit_params"]))
return np.array(obj.matrix_world, dtype=np.float64) @ next(s for s in built.sockets if s["name"] == name)["matrix"]
def world_points(obj):
points = np.zeros(3 * len(obj.data.vertices))
obj.data.vertices.foreach_get("co", points)
world = np.array(obj.matrix_world)
return points.reshape(-1, 3) @ world[:3, :3].T + world[:3, 3]
def others(hose):
"""A tree of every other mesh object's evaluated mesh in the world: this test's own reading of the obstacles."""
depsgraph, points, faces = bpy.context.evaluated_depsgraph_get(), [], []
for obj in bpy.context.scene.objects:
if obj.type != "MESH" or obj == hose:
continue
evaluated = obj.evaluated_get(depsgraph)
mesh, start = evaluated.to_mesh(), sum(len(p) for p in points)
points.append(np.array([evaluated.matrix_world @ v.co for v in mesh.vertices]).reshape(-1, 3))
faces += [[start + i for i in polygon.vertices] for polygon in mesh.polygons]
evaluated.to_mesh_clear()
return BVHTree.FromPolygons(np.vstack(points).tolist(), faces)
def surface_clearance(hose, ports):
"""The least distance from the hose's vertices to any other mesh, over the vertices further than the lead and the
bundle's half width from both ports."""
bpy.context.view_layer.update()
tree, points = others(hose), world_points(hose)
far = np.all([np.linalg.norm(points - port, axis=1) > LEAD + ENVELOPE + CLEARANCE for port in ports], axis=0)
return min(tree.find_nearest(Vector(p))[3] for p in points[far])
def shells(obj):
"""(closed shells, edges that do not join two faces) of a mesh object."""
edges = {}
for polygon in obj.data.polygons:
for a, b in polygon.edge_keys:
edges[(a, b)] = edges.get((a, b), 0) + 1
root = list(range(len(obj.data.vertices)))
def find(i):
while root[i] != i:
root[i] = root[root[i]]
i = root[i]
return i
for a, b in edges:
root[find(a)] = find(b)
return len({find(i) for i in range(len(root))}), sum(1 for n in edges.values() if n != 2)
def timed(fields):
"""Median wall seconds of three rebuilds of a hose, each after one report action."""
import time
taken = []
for _ in range(3):
send("brokkr_kitbash.report", object_name="Thigh")
started = time.perf_counter()
send("brokkr_kitbash.hose", **fields)
taken.append(time.perf_counter() - started)
return sorted(taken)[1]
try:
section("knee")
STRUT = "length=0.8;width=0.08;thickness=0.05"
RAM = "body_r=0.12;body_len=0.2;extension=0"
thigh = place("Thigh", "strut", STRUT)
place("Shin", "strut", STRUT)
send("brokkr_kitbash.attach", object_name="Shin", socket="end_a", parent_name="Thigh", parent_socket="end_b_back", roll=0.0)
shin = bpy.data.objects["Shin"]
upper = place("ActT", "actuator", RAM, [-0.674, -0.2, -0.2], parent=thigh)
lower = place("ActS", "actuator", RAM, [-0.674, -0.2, 0.89], parent=shin)
plate = box("Armour", (-0.21, -0.45, 0.15), (-0.19, 0.05, 0.7), parent=thigh)
bpy.context.view_layer.update()
ports = [frame(upper, "port_cap")[:3, 3], frame(lower, "port_cap")[:3, 3]]
check("the actuator's ports sit on its boss faces, facing out", np.allclose(ports[0], [-0.5, -0.2, 0.01], atol=1e-6) and np.allclose(frame(upper, "port_cap")[:3, 2], [1, 0, 0], atol=1e-6)
and others(None).find_nearest(Vector(ports[0]))[3] < 1e-6 and np.allclose(frame(upper, "port_rod")[:3, 3], [-0.5, -0.2, 0.27], atol=1e-6), ports[0].tolist())
JOINT = {"socket": "Shin:end_a_back", "standoff": 0.08}
def limits(lo, hi):
"""State the knee's limits: the roll range a hose across it is proven over is the pin's own."""
receipt, _ = send("brokkr_kitbash.joint", object_name="Shin", record=json.dumps({"limits": None if lo is None else [lo, hi]}))
return receipt
refused("hose-range-from-pin: a pin with no limits, naming the action that states them", {"object_name": "Feed", "start": "ActT:port_cap", "end": "ActS:port_cap", **BUNDLE, "joint": json.dumps(JOINT)},
"'Shin' on 'Thigh': the pin the hose crosses states no limits: brokkr_kitbash.joint gives it the roll range the hose is proven over")
check("the knee takes its limits", limits(-20, 20)["status"] == "accepted" and (shin["kit_min"], shin["kit_max"]) == (-20.0, 20.0), dict(shin.items()))
FEED = {"object_name": "Feed", "start": "ActT:port_cap", "end": "ActS:port_cap", **BUNDLE, "joint": json.dumps(JOINT)}
state = scene_state()
receipt, report = send("brokkr_kitbash.hose", **FEED)
R["reports"]["feed"] = report
check("hose-behind-armour: three hoses route from the thigh's ram to the shin's, round the plate and through the pin point",
receipt["status"] == "accepted" and report["hoses"] == 3 and not report["rebuilt"] and report["nonManifoldEdges"] == 0 and report["rolls"] >= 9
and report["clearance"] >= CLEARANCE and report["worstClearance"] >= CLEARANCE and report["radii"]["least"] >= FLOOR * (1 - 1e-6) and len(report["voxels"]) == 2,
[receipt["status"], receipt["message"], report])
feed = bpy.data.objects["Feed"]
check("the hose is one object, the start's child under an identity parent inverse, and carries its request",
feed.parent == upper and np.allclose(np.array(feed.matrix_parent_inverse), np.eye(4)) and np.allclose(np.array(feed.matrix_basis), np.eye(4))
and json.loads(feed["kit_hose"])["joint"] == JOINT and len(feed.data.materials) == 0 and len(feed.vertex_groups) == 0, feed.get("kit_hose"))
check("every hose and collar is a closed shell", shells(feed) == (3 + 3 * 4, 0), shells(feed))
points = world_points(feed)
check("each hose starts on the port's face, side by side across it",
min(np.linalg.norm(points - ports[0], axis=1)) < RADIUS * 1.5 and abs(float(((points - ports[0]) @ [1.0, 0, 0]).min())) < 1e-5, None)
line_blocked = others(feed).ray_cast(Vector(ports[0] + [0.12, 0, 0]), Vector((np.array([0, -0.2075, 0.764]) - ports[0] - [0.12, 0, 0])))[0] is not None
check("the straight way from the port to the pin point is through the plate", line_blocked, None)
check("hose-behind-armour: the hose's surface keeps the clearance from every other mesh outside its leads",
reading("clear", surface_clearance(feed, ports), least=True) >= CLEAR, R["readings"])
check("the hose passes the pin's axis: its vertices come within the bundle of the point 0.08 beyond the shin's pin face",
float(np.linalg.norm(points - [0.0, -0.2075, 0.764], axis=1).min()) < 0.08, float(np.linalg.norm(points - [0.0, -0.2075, 0.764], axis=1).min()))
check("the report states sag for both legs, no more than the sag asked for", len(report["sag"]) == 2 and all(0.0 <= s <= 2 * RADIUS + 1e-9 for s in report["sag"]) and any(s > 0 for s in report["sag"]), report["sag"])
_, taut = send("brokkr_kitbash.hose", **{**FEED, "sag": 0.0})
check("sag 0 routes taut and no longer than the sagged hose", taut["sag"] == [0.0, 0.0] and taut["rebuilt"] and taut["length"] < report["length"], [taut["length"], report["length"]])
reading("slack", report["length"] - taut["length"])
section("range")
_, again = send("brokkr_kitbash.hose", **FEED)
check("a rebuild at the same pose reports what the first call did", {**again, "rebuilt": False} == report and len(bpy.data.meshes) == len(state[1]) + 1, again)
check("hose-through-range: the range passes and reports the length's change", report["lengthChange"] is not None and report["lengthChange"] >= 0 and report["worstRoll"] is not None, report)
limits(-20, 90)
refused("a range that swings the shin's hose into the thigh's parts, naming the sagged attempt and the taut one", FEED,
"sagged: roll 48.59: the hose's child's side reads 0.0269 m from the parts about the pin at [-0.2144, -0.2042, 0.7271], counting the 0.0005933 m it can move against the other side's "
"through the 0.156 degrees either side of it: too near the 0.0266 m the bundle needs to prove it of what stands between two readings; taut: roll 50.78: the hose's child's side reads 0.0264 m")
receipt, _ = send("brokkr_kitbash.hose", **FEED)
check("the refusal names both attempts, each by its roll and its side", "sagged: roll " in str(receipt["message"]) and "; taut: roll " in str(receipt["message"])
and str(receipt["message"]).count("the hose's child's side reads") == 2, receipt["message"])
limits(-20, 20)
section("thin plate")
# A plate 1 mm thick, 4 cm square, on the thigh, where a point of the shin's side of a single hose stands at roll
# -17.5: between two of the rolls 5 degrees apart. At -20 and at -15 the hose keeps its need from it.
SINGLE = {**FEED, "object_name": "Single", "start": "ActT:port_rod", "end": "ActS:port_rod", "count": 1, "joint": json.dumps({**JOINT, "standoff": 0.24})}
_, single = send("brokkr_kitbash.hose", **SINGLE)
line = world_points(bpy.data.objects["Single"])
pivot = frame(shin, "end_a_back")
origin, axis = pivot[:3, 3], pivot[:3, 2]
beyond = line[(line[:, 2] > origin[2] + 0.1) & (np.linalg.norm(line - frame(lower, "port_rod")[:3, 3], axis=1) > 0.15)]
far_point = beyond[np.argmax(np.linalg.norm(np.cross(beyond - origin, axis), axis=1))]
turn = math.radians(-17.5)
rel = far_point - origin
at = origin + rel * math.cos(turn) + np.cross(axis, rel) * math.sin(turn) + axis * float(rel @ axis) * (1.0 - math.cos(turn))
way = np.cross(axis, at - origin)
way /= np.linalg.norm(way)
out = np.cross(way, axis)
corners = [at + axis * a * 0.02 + out * b * 0.02 + way * c * 0.0005 for c in (-1, 1) for a in (-1, 1) for b in (-1, 1)]
thin = bpy.data.objects.new("Thin", bpy.data.meshes.new("Thin"))
thin.data.from_pydata([tuple(v) for v in corners], [], [(0, 1, 3, 2), (4, 6, 7, 5), (0, 4, 5, 1), (1, 5, 7, 3), (3, 7, 6, 2), (2, 6, 4, 0)])
bpy.context.scene.collection.objects.link(thin)
bpy.context.view_layer.update()
thin.parent = thigh
thin.matrix_parent_inverse = thigh.matrix_world.inverted()
bpy.context.view_layer.update()
check("the plate stands in the single hose's swing, over 0.03 from where it stands now", single is not None and float(np.linalg.norm(line - at, axis=1).min()) > 0.03, float(np.linalg.norm(line - at, axis=1).min()))
refused("range-sampled-not-swept: a 1 mm plate the hose crosses between two rolls 5 degrees apart", SINGLE, "roll -1")
receipt, _ = send("brokkr_kitbash.hose", **SINGLE)
named = [float(part.split(":")[0]) for part in str(receipt["message"]).split("roll ")[1:]]
check("the refusal names a roll between -20 and -15 for each attempt", len(named) >= 1 and all(-20.0 < roll < -15.0 for roll in named), receipt["message"])
limits(-10, 20)
receipt, narrow = send("brokkr_kitbash.hose", **SINGLE)
check("short of the plate the same hose passes its range", receipt["status"] == "accepted" and narrow["rolls"] >= 7, receipt["message"])
limits(-20, 20)
for name in ("Thin", "Single"):
gone = bpy.data.objects[name]
mesh = gone.data
bpy.data.objects.remove(gone)
bpy.data.meshes.remove(mesh)
bpy.context.view_layer.update()
section("coarse step")
# coarse-step-cuts-thin-plate: no measurement of a hose depends on the search's step. At the coarsest step the
# single taut hose of the finding and the bundle both keep the clearance from the 2 cm armour plate.
for label, extra in (("one taut hose", {"count": 1, "sag": 0.0}), ("the bundle", {})):
receipt, coarse = send("brokkr_kitbash.hose", **{**FEED, "step": 0.2, **extra})
check(f"at step 0.2 {label} routes and keeps the clearance from every other mesh", receipt["status"] == "accepted" and coarse["rebuilt"] and coarse["clearance"] >= CLEARANCE
and reading("clear", surface_clearance(feed, ports), least=True) >= CLEAR, [receipt["message"], R["readings"]])
section("range")
send("brokkr_kitbash.roll", object_name="Shin", roll=10.0)
bpy.context.view_layer.update()
receipt, rolled = send("brokkr_kitbash.hose", **FEED)
check("after a roll the hose rebuilds in place on its name", receipt["status"] == "accepted" and rolled["rebuilt"] and bpy.data.objects["Feed"] == feed and rolled["rolls"] >= 9, receipt["message"])
check("the rebuilt hose keeps the clearance at the new pose", reading("clear", surface_clearance(feed, [frame(upper, "port_cap")[:3, 3], frame(lower, "port_cap")[:3, 3]]), least=True) >= CLEAR, R["readings"])
mesh = feed.data
bpy.data.objects.remove(feed)
bpy.data.meshes.remove(mesh)
bpy.context.view_layer.update()
receipt, fresh = send("brokkr_kitbash.hose", **FEED)
feed = bpy.data.objects["Feed"]
check("hose-through-range: roll then rebuild gives the same report as a fresh hose", receipt["status"] == "accepted" and {**rolled, "rebuilt": False} == fresh, [rolled, fresh])
R["seconds"]["hose on the knee, median of 3"] = round(timed(FEED), 3)
section("second hose")
RETURN = {"object_name": "Return", "start": "ActT:port_rod", "end": "ActS:port_rod", **BUNDLE, "joint": json.dumps({**JOINT, "standoff": 0.24})} # the pin point further out than the first hose's, at the default step
receipt, back = send("brokkr_kitbash.hose", **RETURN)
R["reports"]["return"] = back
check("second-bundle: a second hose routes through the same knee at the default step, its range measured against the parts and not against where the first hose stood",
receipt["status"] == "accepted" and back["nonManifoldEdges"] == 0 and back["rolls"] >= 9 and abs(json.loads(bpy.data.objects["Return"]["kit_hose"])["step"] - 0.02) < 1e-6, [receipt["status"], receipt["message"]])
for step in (0.0125, 0.03, 0.04): # feasibility does not turn on the step: a leg is searched with room for its bends
receipt, _ = send("brokkr_kitbash.hose", **{**FEED, "step": step})
check(f"the first hose's route also stands at step {step}, beside the second", receipt["status"] == "accepted", receipt["message"])
# bend-room-not-monotone-in-step: a search's polyline is a seed. These are steps whose seeds were refused before
# seeds were refined and searched on other grid origins (0.1275 of the first bundle, the rest of the second).
seeds = []
for base, step in [(FEED, 0.1275)] + [(RETURN, step) for step in (0.0225, 0.04, 0.115, 0.1425, 0.155, 0.2)]:
receipt, swept = send("brokkr_kitbash.hose", **{**base, "step": step})
ok = receipt["status"] == "accepted"
check(f"{base['object_name']} routes at step {step}: no bend under the floor, the clearance kept", ok and swept["radii"]["least"] >= FLOOR * (1 - 1e-6) and swept["clearance"] >= CLEARANCE
and swept["worstClearance"] >= CLEARANCE and reading("clear", surface_clearance(bpy.data.objects[base["object_name"]], [frame(ram, "port_cap" if base is FEED else "port_rod")[:3, 3] for ram in (upper, lower)]), least=True) >= CLEAR,
[receipt["message"], swept, R["readings"]])
seeds.append(swept["seed"] if ok else None)
R["reports"]["seeds"] = seeds
check("some of those routes come from a refined seed and some from another grid origin, and the report says which",
any(seed and seed["refined"] for seed in seeds) and any(seed and seed["offset"] != [0.0, 0.0, 0.0] for seed in seeds), seeds)
send("brokkr_kitbash.hose", **FEED)
send("brokkr_kitbash.hose", **RETURN)
refused("a bend the search finds no route for on the knee, by what its first seed lacked", {**FEED, "bend": 16.0}, "under the floor 0.2076: ")
rod_ports = [frame(upper, "port_rod")[:3, 3], frame(lower, "port_rod")[:3, 3]]
check("hose-behind-armour: the second hose keeps the clearance from the first", reading("clear", surface_clearance(bpy.data.objects["Return"], rod_ports), least=True) >= CLEAR, R["readings"])
refused("a pin point another hose already passes", {**RETURN, "object_name": "Third"}, "from an obstacle")
section("too stiff")
# too stiff is said where it is proven: a wall 0.08 above a port leaves the centre line 0.021 beyond its lead to
# turn aside in, and a curve of the floor radius 0.048 cannot; one of 0.012 can, and routes.
for name, x in (("Nozzle", 10.0), ("Drain", 10.6)):
empty = bpy.data.objects.new(name, None)
empty.location = (x, 0.0, 0.0)
bpy.context.scene.collection.objects.link(empty)
box("Lid", (9.0, -1.0, 0.08), (11.6, 1.0, 0.1))
bpy.context.view_layer.update()
LOOP = {"object_name": "Loop", "start": "Nozzle", "end": "Drain", "count": 1, "radius": RADIUS, "clearance": CLEARANCE}
refused("a bundle proven too stiff to leave its port under a wall", LOOP, "the bundle is too stiff to leave its start: from the end of its lead at [10, 0, 0.048] no curve that bends at the floor radius 0.048 m or wider")
receipt, loop = send("brokkr_kitbash.hose", **{**LOOP, "bend": 1.0})
check("the same hose at bend 1 routes under the wall", receipt["status"] == "accepted" and loop["radii"]["least"] >= 0.012 * (1 - 1e-6) and loop["clearance"] >= CLEARANCE, [receipt["message"], loop])
section("clamps")
tank = place("Tank", "tank", "radius=0.22;length=0.9", [3.0, 0.0, 0.0])
seats = [place(name, "plate", "width=0.1;height=0.1", [x, 0.0, 1.25], [0.0, 0.0, math.pi / 2]) for name, x in (("SeatA", 3.45), ("SeatB", 4.05))]
ram = place("Ram", "actuator", RAM, [5.074, 0.0, 1.07], [0.0, 0.0, math.pi])
bpy.context.view_layer.update()
LINE = {"object_name": "Line", "start": "Tank:port_b", "end": "Ram:port_cap", **BUNDLE, "clamps": json.dumps([{"socket": "SeatA:front"}, {"socket": "SeatB:front"}])}
receipt, line = send("brokkr_kitbash.hose", **LINE)
R["reports"]["line"] = line
check("hose-clamps-ports: a hose runs from the tank's flange over two clamps to the ram's port", receipt["status"] == "accepted" and line["nonManifoldEdges"] == 0 and len(line["voxels"]) == 3
and line["rolls"] is None and line["lengthChange"] is None, [receipt["status"], receipt["message"]])
hose = bpy.data.objects["Line"]
check("three hoses with four collars each, two straps and two pads", shells(hose) == (3 + 12 + 4, 0), shells(hose))
points = world_points(hose)
stand, held = ENVELOPE + CLEARANCE + RADIUS, 4.0 * RADIUS + FLOOR
for seat in seats:
at = frame(seat, "front")
centre, y, x = at[:3, 3] + at[:3, 2] * stand, at[:3, 1], at[:3, 0]
for k in range(COUNT_HOSES):
origin = centre + x * (k - 1) * SPREAD
rel = points - origin
along = rel @ y
off = np.abs(np.linalg.norm(rel - np.outer(along, y), axis=1) - RADIUS)
near = np.sort(off[np.abs(along) <= held + 1e-6])[:24] # the two rings where the kept straight ends, twelve vertices each
reading("clamped", near.max() if len(near) == 24 else 1.0)
reading("kept", np.abs(along[off < 1e-5]).min() if (off < 1e-5).any() else 0.0, least=True)
check("hose-clamps-ports: each hose passes each clamp point straight along the socket's y", R["readings"]["clamped"] <= CLAMPED, R["readings"])
check("the bundle runs straight for two outside diameters each side of a clamp point: no ring of a bend stands nearer", R["readings"]["kept"] >= KEPT, R["readings"])
check("the clamped hose reports the clearance it keeps (its pads stand on their seats)", line["clearance"] >= CLEARANCE and surface_clearance(hose, [frame(tank, "port_b")[:3, 3], frame(ram, "port_cap")[:3, 3]]) < 1e-6,
line["clearance"])
refused("a bundle wider than the port", {**LINE, "object_name": "Wide", "count": 5}, "a bundle of 5 hoses is 0.0744 m wide, over socket 'Ram:port_cap' (hose, size 0.048)")
tip = bpy.data.objects.new("Tip", None)
bpy.context.scene.collection.objects.link(tip)
tip.location, tip.rotation_euler = (3.5, 0.0, -1.3), (0.0, -math.pi / 6, 0.0) # under the tank's lower port, its z up toward it
bpy.context.view_layer.update()
receipt, loose = send("brokkr_kitbash.hose", object_name="Loose", start="Tank:port_a", end="Tip", radius=0.02)
check("a hose runs from a flange to an empty", receipt["status"] == "accepted" and loose["hoses"] == 1 and shells(bpy.data.objects["Loose"]) == (5, 0), [receipt["status"], receipt["message"]])
section("verify")
# h4-claimable-live: a straight hose from a ram's port to an empty in line with it has no corner and no pin, and
# its leg starts beyond the plate that stands 0.008 under its first straight: route.verify is the only thing that
# measures that straight, and refuses it. With verify refusing nothing (H4b) the hose is made and reads under CLEAR.
solo = place("Solo", "actuator", RAM, [10.0, 0.0, 0.0])
bpy.context.view_layer.update()
mouth = frame(solo, "port_cap")[:3, 3]
stub = bpy.data.objects.new("Stub", None)
bpy.context.scene.collection.objects.link(stub)
stub.location, stub.rotation_euler = (float(mouth[0]) + 0.5, float(mouth[1]), float(mouth[2])), (0.0, -math.pi / 2, 0.0) # its z back along the line toward the port
box("Beside", (mouth[0] + 0.06, mouth[1] - 0.05, mouth[2] - 0.06), (mouth[0] + 0.08, mouth[1] + 0.05, mouth[2] - 0.008))
bpy.context.view_layer.update()
PAST = {"object_name": "Past", "start": "Solo:port_cap", "end": "Stub", "radius": RADIUS, "clearance": CLEARANCE, "sag": 0.0}
state = scene_state()
receipt, _ = send("brokkr_kitbash.hose", **PAST)
past = bpy.data.objects.get("Past")
if past is not None:
reading("clear", surface_clearance(past, [mouth, np.array(stub.location)]), least=True)
check("h4: the straight past the plate is refused by route.verify, naming the point; nothing changed",
receipt["status"] != "accepted" and "the hose stands 0.008 m from an obstacle at [" in str(receipt["message"]) and "under the 0.011 m the bundle needs" in str(receipt["message"])
and scene_state() == state, [receipt["status"], receipt["message"]])
check("h4: no hose this suite made stands nearer another mesh than CLEAR", R["readings"]["clear"] >= CLEAR, R["readings"])
bpy.data.objects["Beside"].location = (0.0, 0.0, -0.01) # 0.018 under the straight: the same call routes
bpy.context.view_layer.update()
receipt, past = send("brokkr_kitbash.hose", **PAST)
check("with the plate 0.018 under it the same straight is made", receipt["status"] == "accepted" and (past["radii"]["least"] is None or past["radii"]["least"] > 1e3) and abs(past["clearance"] - 0.012) < 1e-4, [receipt["message"], past])
section("refusals")
refused("a name taken by a mesh that is no hose", {**FEED, "object_name": "Thigh"}, "An object named 'Thigh' exists and is no hose")
refused("a socket the part does not have", {**FEED, "start": "ActT:nope"}, "start: 'ActT' (a actuator) has no socket 'nope'; its sockets: base, base_back, rod_end, rod_end_back, port_cap, port_rod")
refused("an object that does not exist", {**FEED, "end": "Nobody:port_cap"}, "end: no object named 'Nobody'")
refused("a pivot as an end", {**FEED, "start": "Thigh:end_a"}, "start: socket 'end_a' of 'Thigh' is a pivot socket; this takes a hose or flange socket")
refused("a mesh that is no empty as an end", {**FEED, "end": "Armour"}, "end 'Armour' names no socket")
refused("a clamp on a pivot", {**FEED, "clamps": json.dumps([{"socket": "Thigh:end_a"}])}, "clamps[0]: socket 'end_a' of 'Thigh' is a pivot socket; this takes a mount socket")
refused("clamps that are not rows of socket", {**FEED, "clamps": json.dumps([{"at": [0, 0, 0]}])}, "clamps[0] must be an object of socket")
refused("nine clamps", {**FEED, "clamps": json.dumps([{"socket": "SeatA:front"}] * 9)}, "clamps must be a JSON array of 0 to 8 objects")
refused("a pin crossed with no joint", {k: v for k, v in FEED.items() if k != "joint"}, "The hose crosses the pin of 'Shin' on 'Thigh' (socket 'end_b_back'): give joint")
refused("a joint where no pin is crossed", {**LINE, "object_name": "New", "joint": json.dumps(JOINT)}, "joint is given and the hose crosses no pin")
feed.modifiers.new("Smooth", "SUBSURF") # by hand: a hose has no modifiers of its own, and freeze takes any mesh that has one
receipt, chilled = send("brokkr_kitbash.freeze", object_name="Feed")
check("a hose given a modifier freezes", receipt["status"] == "accepted" and chilled and chilled["frozen"] is True and feed.data.name == "Feed frozen", receipt["message"])
refused("a rebuild of a frozen hose", FEED, "'Feed' is frozen, and rebuilding it needs its live mesh and modifiers: thaw it first")
send("brokkr_kitbash.thaw", object_name="Feed")
feed.modifiers.remove(feed.modifiers["Smooth"])
receipt, thawed = send("brokkr_kitbash.hose", **FEED)
check("the thawed hose rebuilds", receipt["status"] == "accepted" and "Feed frozen" not in bpy.data.meshes and thawed["nonManifoldEdges"] == 0, receipt["message"])
place("Jack", "actuator", "body_r=0.0534;body_len=0.2;extension=0")
send("brokkr_kitbash.attach", object_name="Jack", socket="base", parent_name="Shin", parent_socket="end_b", roll=90.0)
bpy.context.view_layer.update()
refused("two pins crossed", {**FEED, "object_name": "New", "end": "Jack:port_cap", "count": 1, "radius": 0.004}, "The hose crosses 2 pins ('Jack' on 'Shin', 'Shin' on 'Thigh'): a hose crosses one")
refused("a joint socket off the crossed pin's axis", {**FEED, "joint": json.dumps({**JOINT, "socket": "Shin:end_b_back"})}, "joint.socket 'Shin:end_b_back' is not on the axis of the pin the hose crosses ('Shin' on 'Thigh', socket 'end_b_back')")
state = scene_state()
receipt = limits(30, 60)
check("limits that exclude the roll the knee stands at are the joint action's to refuse", receipt["status"] != "accepted" and "'Shin' on 'Thigh': its roll 10 is outside the joint's limits 30 to 60" in str(receipt["message"])
and scene_state() == state, receipt["message"])
receipt = limits(-200, 200)
check("and limits over a full turn", receipt["status"] != "accepted" and "a revolute joint's span at most 360 degrees" in str(receipt["message"]) and scene_state() == state, receipt["message"])
shin["kit_min"], shin["kit_max"] = 30.0, 60.0 # by hand: the hose reads the pin's limits and finds the roll outside them
refused("the current roll outside limits written by hand", FEED, "'Shin' stands at roll 10, outside its joint's limits 30 to 60")
shin["kit_min"], shin["kit_max"] = -20.0, 20.0
refused("a joint that states a range of its own", {**FEED, "joint": json.dumps({**JOINT, "range": [-20, 20]})}, "joint must be an object of socket (an 'Object:socket' text) and standoff (0 to 10)")
place("Barrel", "ram_barrel", "body_r=0.0534")
place("Rod", "ram_rod", "body_r=0.0534")
send("brokkr_kitbash.attach", object_name="Barrel", socket="base", parent_name="Shin", parent_socket="end_b_back", roll=90.0)
send("brokkr_kitbash.attach", object_name="Rod", socket="piston", parent_name="Barrel", parent_socket="bore")
rod_tip = bpy.data.objects.new("RodTip", None)
bpy.context.scene.collection.objects.link(rod_tip)
rod_tip.parent = bpy.data.objects["Rod"]
bpy.context.view_layer.update()
refused("hose-range-from-pin: a hose across a slide", {**FEED, "object_name": "New", "start": "Barrel:port_cap", "end": "RodTip", "count": 1, "radius": 0.004, "joint": ""},
"The hose crosses the slide of 'Rod' on 'Barrel' (socket 'bore'): a hose across a prismatic connection is not routed")
refused("a grid past the voxel limit", {**FEED, "step": 0.005}, "voxels at step 0.005, over 524288: a step of ")
lower.scale = (1.0, 1.0, 1.01)
bpy.context.view_layer.update()
refused("a scaled part", FEED, "'ActS' is scaled, mirrored or sheared in the world")
lower.scale = (1.0, 1.0, 1.0)
tip.hide_viewport = True
bpy.context.view_layer.update()
refused("a hidden end", {"object_name": "Loose", "start": "Tank:port_a", "end": "Tip", "radius": 0.02}, "Blender does not evaluate 'Tip' in this view layer")
tip.hide_viewport = False
bpy.context.view_layer.update()
if len(sys.argv) > sys.argv.index("--") + 2:
bpy.ops.wm.save_as_mainfile(filepath=sys.argv[sys.argv.index("--") + 2])
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, not a missing result file
check(f"no uncaught error in section: {SECTION[0]}", False, traceback.format_exc().splitlines()[-6:])
finally:
R["ok"] = all(c["ok"] for c in R["checks"])
R["readings"] = {name: float(f"{value:.2g}") for name, value in sorted(R["readings"].items())}
seconds = R.pop("seconds") # wall time is this machine's: printed, and kept out of the result file
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
print("READINGS", R["readings"], flush=True)
print("SECONDS", seconds, flush=True)
sys.exit(0 if R["ok"] else 1)

View file

@ -0,0 +1,593 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "the actuator's ports sit on its boss faces, facing out",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: hose-range-from-pin: a pin with no limits, naming the action that states them",
"ok": true,
"detail": null
},
{
"name": "the knee takes its limits",
"ok": true,
"detail": null
},
{
"name": "hose-behind-armour: three hoses route from the thigh's ram to the shin's, round the plate and through the pin point",
"ok": true,
"detail": null
},
{
"name": "the hose is one object, the start's child under an identity parent inverse, and carries its request",
"ok": true,
"detail": null
},
{
"name": "every hose and collar is a closed shell",
"ok": true,
"detail": null
},
{
"name": "each hose starts on the port's face, side by side across it",
"ok": true,
"detail": null
},
{
"name": "the straight way from the port to the pin point is through the plate",
"ok": true,
"detail": null
},
{
"name": "hose-behind-armour: the hose's surface keeps the clearance from every other mesh outside its leads",
"ok": true,
"detail": null
},
{
"name": "the hose passes the pin's axis: its vertices come within the bundle of the point 0.08 beyond the shin's pin face",
"ok": true,
"detail": null
},
{
"name": "the report states sag for both legs, no more than the sag asked for",
"ok": true,
"detail": null
},
{
"name": "sag 0 routes taut and no longer than the sagged hose",
"ok": true,
"detail": null
},
{
"name": "a rebuild at the same pose reports what the first call did",
"ok": true,
"detail": null
},
{
"name": "hose-through-range: the range passes and reports the length's change",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a range that swings the shin's hose into the thigh's parts, naming the sagged attempt and the taut one",
"ok": true,
"detail": null
},
{
"name": "the refusal names both attempts, each by its roll and its side",
"ok": true,
"detail": null
},
{
"name": "the plate stands in the single hose's swing, over 0.03 from where it stands now",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: range-sampled-not-swept: a 1 mm plate the hose crosses between two rolls 5 degrees apart",
"ok": true,
"detail": null
},
{
"name": "the refusal names a roll between -20 and -15 for each attempt",
"ok": true,
"detail": null
},
{
"name": "short of the plate the same hose passes its range",
"ok": true,
"detail": null
},
{
"name": "at step 0.2 one taut hose routes and keeps the clearance from every other mesh",
"ok": true,
"detail": null
},
{
"name": "at step 0.2 the bundle routes and keeps the clearance from every other mesh",
"ok": true,
"detail": null
},
{
"name": "after a roll the hose rebuilds in place on its name",
"ok": true,
"detail": null
},
{
"name": "the rebuilt hose keeps the clearance at the new pose",
"ok": true,
"detail": null
},
{
"name": "hose-through-range: roll then rebuild gives the same report as a fresh hose",
"ok": true,
"detail": null
},
{
"name": "second-bundle: a second hose routes through the same knee at the default step, its range measured against the parts and not against where the first hose stood",
"ok": true,
"detail": null
},
{
"name": "the first hose's route also stands at step 0.0125, beside the second",
"ok": true,
"detail": null
},
{
"name": "the first hose's route also stands at step 0.03, beside the second",
"ok": true,
"detail": null
},
{
"name": "the first hose's route also stands at step 0.04, beside the second",
"ok": true,
"detail": null
},
{
"name": "Feed routes at step 0.1275: no bend under the floor, the clearance kept",
"ok": true,
"detail": null
},
{
"name": "Return routes at step 0.0225: no bend under the floor, the clearance kept",
"ok": true,
"detail": null
},
{
"name": "Return routes at step 0.04: no bend under the floor, the clearance kept",
"ok": true,
"detail": null
},
{
"name": "Return routes at step 0.115: no bend under the floor, the clearance kept",
"ok": true,
"detail": null
},
{
"name": "Return routes at step 0.1425: no bend under the floor, the clearance kept",
"ok": true,
"detail": null
},
{
"name": "Return routes at step 0.155: no bend under the floor, the clearance kept",
"ok": true,
"detail": null
},
{
"name": "Return routes at step 0.2: no bend under the floor, the clearance kept",
"ok": true,
"detail": null
},
{
"name": "some of those routes come from a refined seed and some from another grid origin, and the report says which",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a bend the search finds no route for on the knee, by what its first seed lacked",
"ok": true,
"detail": null
},
{
"name": "hose-behind-armour: the second hose keeps the clearance from the first",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a pin point another hose already passes",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a bundle proven too stiff to leave its port under a wall",
"ok": true,
"detail": null
},
{
"name": "the same hose at bend 1 routes under the wall",
"ok": true,
"detail": null
},
{
"name": "hose-clamps-ports: a hose runs from the tank's flange over two clamps to the ram's port",
"ok": true,
"detail": null
},
{
"name": "three hoses with four collars each, two straps and two pads",
"ok": true,
"detail": null
},
{
"name": "hose-clamps-ports: each hose passes each clamp point straight along the socket's y",
"ok": true,
"detail": null
},
{
"name": "the bundle runs straight for two outside diameters each side of a clamp point: no ring of a bend stands nearer",
"ok": true,
"detail": null
},
{
"name": "the clamped hose reports the clearance it keeps (its pads stand on their seats)",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a bundle wider than the port",
"ok": true,
"detail": null
},
{
"name": "a hose runs from a flange to an empty",
"ok": true,
"detail": null
},
{
"name": "h4: the straight past the plate is refused by route.verify, naming the point; nothing changed",
"ok": true,
"detail": null
},
{
"name": "h4: no hose this suite made stands nearer another mesh than CLEAR",
"ok": true,
"detail": null
},
{
"name": "with the plate 0.018 under it the same straight is made",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a name taken by a mesh that is no hose",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a socket the part does not have",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: an object that does not exist",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a pivot as an end",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a mesh that is no empty as an end",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a clamp on a pivot",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: clamps that are not rows of socket",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: nine clamps",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a pin crossed with no joint",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a joint where no pin is crossed",
"ok": true,
"detail": null
},
{
"name": "a hose given a modifier freezes",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a rebuild of a frozen hose",
"ok": true,
"detail": null
},
{
"name": "the thawed hose rebuilds",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: two pins crossed",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a joint socket off the crossed pin's axis",
"ok": true,
"detail": null
},
{
"name": "limits that exclude the roll the knee stands at are the joint action's to refuse",
"ok": true,
"detail": null
},
{
"name": "and limits over a full turn",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: the current roll outside limits written by hand",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a joint that states a range of its own",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: hose-range-from-pin: a hose across a slide",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a grid past the voxel limit",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a scaled part",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a hidden end",
"ok": true,
"detail": null
}
],
"hostErrors": [],
"readings": {
"clamped": 4.6e-08,
"clear": 0.031,
"kept": 0.028,
"slack": 0.017
},
"reports": {
"feed": {
"object": "Feed",
"rebuilt": false,
"hoses": 3,
"length": 1.642855,
"lengthChange": 0.034539,
"floor": 0.0636,
"clearance": 0.024995,
"capped": 0.1522,
"voxels": [
79488,
53406
],
"seed": {
"step": 0.02,
"offset": [
0.0,
0.0,
0.0
],
"refined": false
},
"sag": [
0.001879,
0.009076
],
"rolls": 9,
"worstRoll": -20.0,
"worstClearance": 0.025166,
"faces": 3378,
"volume": 0.000577468,
"nonManifoldEdges": 0,
"radii": {
"least": 0.134032,
"corners": [
0.297307,
0.134032,
28.760693,
0.232497,
3.487729,
0.140588
]
}
},
"return": {
"object": "Return",
"rebuilt": false,
"hoses": 3,
"length": 1.679265,
"lengthChange": 0.032203,
"floor": 0.0636,
"clearance": 0.026679,
"capped": 0.1522,
"voxels": [
82110,
92820
],
"seed": {
"step": 0.02,
"offset": [
0.0,
0.0,
0.0
],
"refined": false
},
"sag": [
0.008745,
0.00844
],
"rolls": 9,
"worstRoll": -20.0,
"worstClearance": 0.027159,
"faces": 5466,
"volume": 0.000589265,
"nonManifoldEdges": 0,
"radii": {
"least": 0.082543,
"corners": [
0.082543,
4.587721,
0.136709,
0.183407,
0.094636,
9.943722,
0.104249
]
}
},
"seeds": [
{
"step": 0.1275,
"offset": [
0.0,
0.0,
0.0
],
"refined": false
},
{
"step": 0.0225,
"offset": [
0.0,
0.0,
0.0
],
"refined": false
},
{
"step": 0.04,
"offset": [
0.0,
0.0,
0.0
],
"refined": true
},
{
"step": 0.115,
"offset": [
0.0,
0.0,
0.0
],
"refined": true
},
{
"step": 0.1425,
"offset": [
0.31,
0.67,
0.13
],
"refined": false
},
{
"step": 0.155,
"offset": [
0.0,
0.0,
0.0
],
"refined": true
},
{
"step": 0.1,
"offset": [
0.0,
0.0,
0.0
],
"refined": false
}
],
"line": {
"object": "Line",
"rebuilt": false,
"hoses": 3,
"length": 2.100069,
"lengthChange": null,
"floor": 0.0636,
"clearance": 0.010959,
"capped": 0.1522,
"voxels": [
49815,
34992,
43011
],
"seed": {
"step": 0.02,
"offset": [
0.0,
0.0,
0.0
],
"refined": false
},
"sag": [
0.00942,
0.012,
0.011996
],
"rolls": null,
"worstRoll": null,
"worstClearance": null,
"faces": 2510,
"volume": 0.000777105,
"nonManifoldEdges": 0,
"radii": {
"least": 0.100091,
"corners": [
0.109706,
4.289628,
0.100091,
1.739264,
2.896538,
1.739264,
1.672436,
7.389576,
10.858347
]
}
}
},
"ok": true
}

View file

@ -0,0 +1,486 @@
"""Live proof, in a background Blender, of brokkr_kitbash.plates through run_intent: a plate table written onto a
mechanical-kit link under a pin, each plate's mesh, fit children and anchor empties against plate.build's own answer
under the frame, the Kit Bevels, joints unchanged by the plates, a roll of the pin carrying every plate, a hose between
two port empties either side of the pin across its range, a rebuild in place, each refusal leaving the scene as it
was, and a slab with a fit row of every kind written into a child per material. Not part of the unittest run: it needs Blender.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/kitbash_plates.py -- <out>
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). <out> is an absolute path; writes <out>.result.json and exits 1 when a check failed.
Bounds follow lodur:ruling:deterministic-bound-margin: each sits at the geometric mean of the shipped worst reading
and the least claimed mutant's, both written beside it; the result file carries the readings.
The checks run inside one try: an uncaught error is a failed check that names the section it happened in, and the
result file is written and the checks printed whatever happened.
"""
import copy
import importlib
import json
import math
import os
import sys
import tempfile
import traceback
import types
from pathlib import Path
import bpy
import numpy as np
from mathutils import Euler, Matrix
SURFACE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(SURFACE / "tools"))
import private_dirs # noqa: E402
_refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if _refused:
raise SystemExit(_refused)
OUT = sys.argv[sys.argv.index("--") + 1]
if not Path(OUT).is_absolute():
raise SystemExit(f"{OUT!r} is not an absolute path")
package = types.ModuleType("brokkr_bridge")
package.__path__ = [str(SURFACE / "brokkr_bridge")]
sys.modules["brokkr_bridge"] = package
from brokkr_bridge import blender_target as bt # noqa: E402
import addon_utils # noqa: E402
reference = types.ModuleType("brokkr_kitbash_plates") # plate.py as the unit tests load it: what every reading here is taken against
reference.__path__ = [str(SURFACE / "brokkr_kitbash")]
sys.modules["brokkr_kitbash_plates"] = reference
plate = importlib.import_module("brokkr_kitbash_plates.plate")
sys.path.append(str(SURFACE))
bpy.ops.wm.read_factory_settings(use_empty=True)
for module in ("brokkr_mesh_polish", "brokkr_kitbash"):
addon_utils.enable(module, default_set=True)
target = bt.BrokkrBlenderTarget(bpy)
WORK = Path(tempfile.mkdtemp(prefix="brokkr-kitbash-plates-"))
target.configure_action_dirs("", str(WORK))
target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1], "readings": {}, "reports": {}}
COUNT, SECTION = [0], ["setup"]
# The mutants of brokkr_kitbash.plates this suite was run against, each failing a check: X1 the frame applied twice (the
# basis host_world @ frame); X2 a rebuild that deletes the plate and makes it again; X3 an anchor left at its plate's
# origin; X4 a plate written with no parent; X5 the host's inverse as the parent inverse; X6 a kept anchor not moved; X7
# the plate's Kit Bevel at shell's 30 degrees; X8 the panels' at 12; X9 a fit child parented to the host; X10 an
# anchor's basis under the frame again; X11 stale children kept; X12 no sharp_face written; X13 no material refusal;
# X14 no refusal of a taken child or anchor name; X15 a row's fittings not written (plan leaves entry["fits"] out); X16 no
# refusal of a fit's missing material.
#
# Metres between a written vertex in the world (the object's matrix_world on its mesh's own coordinates) and the same
# vertex of plate.build's answer under the frame this script holds, over every plate and fit child of the suite; inf
# when a face differs or is smooth. Shipped worst 8.5e-08 (float32 meshes and matrices); least claimed mutant 1.7 (X1);
# the geometric mean, separation 4400 each side.
WRITTEN = 3.8e-4
# Largest entry of an anchor empty's matrix_world minus the frame @ plate.build's anchor matrix. Shipped worst 2.2e-07;
# least claimed mutant 0.041 (X6, on the rebuild that moves a port 0.05 along its face; X3 reads 1.5, X10 1.4);
# separation 430 each side.
ANCHORED = 9.5e-5
# Largest entry of matrix_world after a roll of the pin minus (the shin's own motion @ matrix_world before), over
# every plate, fit child and anchor on the shin. Shipped worst 1.0e-07; least claimed mutant 0.23 (X4: the plate stays
# where it stood); separation 1500 each side.
CARRIED = 1.5e-4
# Largest entry of a kept anchor's basis after a rebuild minus plate.build's matrix for the rebuilt row. Shipped worst
# 2.1e-07; least claimed mutant 0.049 (X6); separation 480 each side.
MOVED = 1.0e-4
# Metres along a port's z between the port, as plate.build places it on the panel's top, and the nearest hose vertex
# within 1.5 hose radii of it; 1 when no vertex stands that near, or no hose was made. Shipped worst 3.9e-08; least
# claimed mutant 1 (X10: the hose is routed from where the empty stands, off the plate; under X1, X3 and X4 hose
# refuses); separation 5000 each side.
PORTED = 2.0e-4
RADIUS, CLEARANCE = 0.006, 0.005
def check(name, ok, detail=None):
R["checks"].append({"name": name, "ok": bool(ok), "detail": None if ok else detail}) # what was seen, when it was not what was promised
def reading(name, value):
R["readings"][name] = max(R["readings"].get(name, 0.0), float(value))
return float(value)
def section(name):
SECTION[0] = name
print("SECTION", name, flush=True)
def send(action, **fields):
COUNT[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"live-{COUNT[0]}", "requestedBy": "test/driver", "action": action, **fields})
result = None
if receipt.get("hostResult"):
try:
result = json.loads(receipt["hostResult"])
except ValueError:
result = None
print("SEND", action, receipt["status"], str(receipt["message"])[:400], flush=True)
return receipt, result
def scene_state():
return {o.name: (o.parent and o.parent.name, o.type, o.session_uid, np.round(np.array(o.matrix_basis), 6).tolist(), np.round(np.array(o.matrix_parent_inverse), 6).tolist(),
{k: repr(o[k]) for k in sorted(o.keys())}, [(m.name, m.type, m.show_viewport) for m in o.modifiers],
o.data.name if o.type == "MESH" else None, len(o.data.polygons) if o.type == "MESH" else None,
[s.material and s.material.name for s in o.material_slots],
np.round(points(o)[:8], 6).tolist() if o.type == "MESH" else None)
for o in bpy.data.objects}, sorted(m.name for m in bpy.data.meshes), sorted(c.name for c in bpy.data.collections)
def refused(label, fields, expected):
state = scene_state()
receipt, _ = send("brokkr_kitbash.plates", **fields)
check(f"refused, scene unchanged: {label}", receipt["status"] != "accepted" and expected in str(receipt["message"]) and scene_state() == state,
[receipt["status"], receipt["message"]])
def place(name, part, params=""):
send("brokkr_kitbash.place_part", part=part, object_name=name, params=params)
return bpy.data.objects[name]
def points(obj):
out = np.zeros(3 * len(obj.data.vertices))
obj.data.vertices.foreach_get("co", out)
return out.reshape(-1, 3)
def world(obj):
return np.array(obj.matrix_world, dtype=np.float64)
def under(matrix, V):
return np.asarray(V) @ matrix[:3, :3].T + matrix[:3, 3]
def joined(parts):
"""Meshes (V, faces) as one: the vertices in order, and each face's vertex indices."""
offsets = np.cumsum([0] + [len(V) for V, _ in parts[:-1]])
return np.vstack([V for V, _ in parts]), [[int(k + offset) for k in face] for (_, faces), offset in zip(parts, offsets) for face in faces]
def written(obj, frame, parts):
"""How far the object's mesh stands, in the world, from the meshes (V, faces) under frame; inf when the vertex
count, a face or a smooth face differs."""
V, faces = joined(parts)
if len(obj.data.vertices) != len(V) or [list(p.vertices) for p in obj.data.polygons] != faces or any(p.use_smooth for p in obj.data.polygons):
return math.inf
return float(np.abs(under(world(obj), points(obj)) - under(frame, V)).max())
def off(V, port):
"""Metres along a port's z between the port and the nearest of the vertices within 1.5 hose radii of it; 1 when
none stands that near."""
near = V[np.linalg.norm(V - port[:3, 3], axis=1) < 1.5 * RADIUS]
return abs(float(((near - port[:3, 3]) @ port[:3, 2]).min())) if len(near) else 1.0
def bevel(obj):
modifier = obj.modifiers.get("Kit Bevel")
return None if modifier is None else (round(modifier.width, 6), round(math.degrees(modifier.angle_limit), 4), modifier.segments, modifier.limit_method)
def fits_of(entry, row):
"""{material: [meshes]} of what a built entry's fit children hold: panels, bolts, then the row's fittings."""
held = {}
if row["clad"]:
for material, mesh in ((row["clad"]["mat"], entry["panels"]), (row["clad"]["bolt_mat"], entry["bolts"])):
if len(mesh[1]):
held.setdefault(material, []).append(mesh)
for material, mesh in entry["fits"].items():
held.setdefault(material, []).append(mesh)
return held
def proven(label, document, side, prefix, host, frame, report):
"""Every object one accepted call wrote, against plate.build of the same document: the plates' meshes, parents,
bases, bevels and properties, each fit child, each anchor empty, and the report's rows."""
table = plate.check(document)
built = plate.build(table, side)
host_world = world(host) if host else np.eye(4)
ok, detail, rows = True, [], []
for entry in built:
row, name = table["plates"][entry["row"]], prefix + entry["name"]
obj = bpy.data.objects.get(name)
if obj is None or obj.type != "MESH":
ok, detail = False, detail + [f"{name}: not made"]
continue
apart = reading("written", written(obj, frame, [entry["solid"]]))
basis = np.abs(np.array(obj.matrix_basis) - np.linalg.inv(host_world) @ frame).max()
facts = {"apart": apart < WRITTEN, "parent": obj.parent == host, "inverse": np.array_equal(np.array(obj.matrix_parent_inverse), np.eye(4)), "basis": basis < WRITTEN,
"bevel": bevel(obj) == ((round(row["bevel"], 6), 12.0, 2, "ANGLE") if row["bevel"] > 0 else None), "kind": obj.get("plate_kind") == "hard",
"record": json.loads(obj.get("kit_plate", "null")) == {**row, "side": entry["side"], "prefix": prefix},
"material": obj.material_slots[0].material.name == row["mat"], "noPart": "kit_part" not in obj}
held = fits_of(entry, row)
children = sorted(child.name for child in obj.children if child.type == "MESH")
facts["children"] = children == sorted(f"{name}.fit.{material}" for material in held)
for material, parts in held.items():
child = bpy.data.objects.get(f"{name}.fit.{material}")
if child is None or child.parent != obj:
facts[f"fit {material}"] = False
continue
panels = bool(row["clad"]) and material == row["clad"]["mat"]
facts[f"fit {material}"] = (reading("written", written(child, frame, parts)) < WRITTEN and np.array_equal(np.array(child.matrix_basis), np.eye(4))
and np.array_equal(np.array(child.matrix_parent_inverse), np.eye(4)) and [s.material.name for s in child.material_slots] == [material]
and bevel(child) == ((round(row["clad"]["bevel"], 6), 20.0, 1, "ANGLE") if panels and row["clad"]["bevel"] > 0 else None))
empties = sorted(child.name for child in obj.children if child.type == "EMPTY" and "kit_anchor" in child)
names = []
for anchor in entry["anchors"]:
mark = anchor["kind"] == "mark"
names.append(f"{name}.{'mark' if mark else 'port'}.{anchor['name']}")
empty = bpy.data.objects.get(names[-1])
if empty is None or empty.parent != obj or empty.type != "EMPTY":
facts[names[-1]] = False
continue
record = {"kind": "mark", "id": anchor["name"], "height": anchor["height"]} if mark else {"kind": "hose_port", "name": anchor["name"]}
facts[names[-1]] = (reading("anchored", np.abs(world(empty) - frame @ np.array(anchor["matrix"])).max()) < ANCHORED and json.loads(empty.get("kit_anchor", "null")) == record
and np.array_equal(np.array(empty.matrix_parent_inverse), np.eye(4)))
facts["anchors"] = empties == sorted(names)
rows.append({"name": name, **entry["report"], "anchors": names})
if not all(facts.values()):
ok, detail = False, detail + [f"{name}: {[k for k, v in facts.items() if not v]}"]
reported = report and [{k: v for k, v in row.items() if k != "rebuilt"} for row in report["plates"]]
check(f"written-is-built: {label}", ok and reported == rows and report["host"] == (host.name if host else None) and report["side"] == side, detail or [reported, rows])
return table, built
try:
section("knee")
for name in ("khaki", "olive_light", "gunmetal", "steel"):
bpy.data.materials.new(name)
STRUT = "length=0.8;width=0.08;thickness=0.05"
thigh = place("Thigh", "strut", STRUT)
send("setObjectTransform", targetObjectName="Thigh", location=[0.3, -0.2, 0.1], rotationEuler=[0.2, -0.3, 0.5]) # no frame here is the identity
shin = place("Shin", "strut", STRUT)
send("brokkr_kitbash.attach", object_name="Shin", socket="end_a", parent_name="Thigh", parent_socket="end_b_back", roll=0.0)
send("brokkr_kitbash.joint", object_name="Shin", record=json.dumps({"limits": [-20, 20]}))
bpy.context.view_layer.update()
_, joints_before = send("brokkr_kitbash.joints", object_name="Thigh")
count = len(bpy.data.objects)
def slab(name, at, port, more=None):
"""A plate facing the link's -y, 0.3 by 0.5, with one panel, a hose port on it and a numeral under it."""
return {"name": name, "mat": "khaki", "bevel": 0.006,
"slab": {"at": at, "normal": [0, -1, 0], "up": [0, 0, 1], "outline": {"w": 0.3, "h": 0.5, "clip": 0.04}, "thick": 0.04},
"clad": {"mat": "olive_light", "min_area": 0.01, "lifts": [0.01, 0.015], "inset": 0.03, "gap": 0.02, "split": 99.0, "seed": 7, "bolt_r": 0.008, **(more or {})},
"fits": [{"kind": "hose_port", "name": port[0], "at": port[1]}, {"kind": "mark", "id": "num", "at": [0.0, -0.15], "height": 0.08}]}
def doc(*rows):
return {"schema": "brokkr.plates.v0", "plates": [copy.deepcopy(r) for r in rows]}
THIGH = doc(slab("Guard", [0.0, -0.12, 0.35], ("feed", [0.0, 0.1])))
SHIN = doc(slab("Guard", [0.0, -0.115, 0.45], ("return", [0.0, -0.1]), {"bevel": 0.009}))
section("on the links")
receipt, report = send("brokkr_kitbash.plates", host="Thigh", prefix="Thigh.", table=json.dumps(THIGH))
check("plates on the thigh are accepted and none is a rebuild", receipt["status"] == "accepted" and [row["rebuilt"] for row in report["plates"]] == [False], [receipt["status"], receipt["message"]])
R["reports"]["thigh"] = report
bpy.context.view_layer.update()
_, thigh_built = proven("a plate on the thigh, the frame the host's", THIGH, 1, "Thigh.", thigh, world(thigh), report)
receipt, report = send("brokkr_kitbash.plates", host="Shin", prefix="Shin.", table=json.dumps(SHIN))
bpy.context.view_layer.update()
shin_table, shin_built = proven("a plate on the shin, under the pin", SHIN, 1, "Shin.", shin, world(shin), report)
guard = bpy.data.objects["Thigh.Guard"]
check("a plate with a panel and its bolts has two fit children and two anchors, and the panel's child alone a bevel",
sorted(c.name for c in guard.children) == ["Thigh.Guard.fit.gunmetal", "Thigh.Guard.fit.olive_light", "Thigh.Guard.mark.num", "Thigh.Guard.port.feed"]
and len(bpy.data.objects["Thigh.Guard.fit.gunmetal"].data.polygons) == len(thigh_built[0]["bolts"][1]) > 0 and bevel(bpy.data.objects["Shin.Guard.fit.olive_light"]) == (0.009, 20.0, 1, "ANGLE")
and len(bpy.data.objects) == count + 10, [sorted(c.name for c in guard.children), len(bpy.data.objects["Thigh.Guard.fit.gunmetal"].data.polygons), len(bpy.data.objects) - count])
_, joints_after = send("brokkr_kitbash.joints", object_name="Thigh")
check("roll-carries: joints lists the same rows with the plates as without", joints_before is not None and joints_after == joints_before, joints_after)
_, parts = send("brokkr_kitbash.report")
check("a plate is no kit part: report lists the two struts", parts is not None and [row["object"] for row in parts["parts"]] == ["Shin", "Thigh"], parts and [row.get("object") for row in parts["parts"]])
section("a frame of its own")
F = np.array(Matrix.Translation((1.5, 0.4, -0.3)) @ Euler((0.7, 0.2, -1.1)).to_matrix().to_4x4(), dtype=np.float64)
TWO = doc({"name": "Wing", "mat": "khaki", "bevel": 0.004, "sides": "both",
"slab": {"at": [0.4, 0.1, 0.0], "normal": [1, 0.2, 0.1], "outline": [[-0.2, 0.3], [0.2, 0.3], [0.3, 0.0], [0.2, -0.3], [-0.2, -0.3]], "thick": 0.05},
"clad": {"mat": "steel", "bolt_mat": "steel", "min_area": 0.01, "lifts": [0.01, 0.02], "inset": 0.03, "gap": 0.02, "split": 0.1, "seed": [3, 4], "bolt_r": 0.006},
"fits": [{"kind": "hose_port", "name": "p", "at": [0.0, 0.0], "lift": 0.01}]},
{"name": "Lump", "mat": "gunmetal", "points": [[0, 0, 0], [0.2, 0, 0], [0, 0.2, 0], [0, 0, 0.2], [0.15, 0.15, 0.15]]})
for side, prefix in ((1, "F."), (-1, "G.")):
receipt, report = send("brokkr_kitbash.plates", host="Thigh", prefix=prefix, frame=json.dumps(F.tolist()), side=side, table=json.dumps(TWO))
bpy.context.view_layer.update()
check(f"plates under a stated frame are accepted at side {side}", receipt["status"] == "accepted", [receipt["status"], receipt["message"]])
proven(f"a two-sided row and a bare one under a stated frame, side {side}: panels and bolts of one material are one child", TWO, side, prefix, thigh, F, report)
check("a bare plate has no child and no bevel; a two-sided row is two plates",
not bpy.data.objects["F.Lump"].children and bevel(bpy.data.objects["F.Lump"]) is None and all(name in bpy.data.objects for name in ("F.Wing.R", "F.Wing.L", "G.Wing.R", "G.Wing.L")), None)
receipt, report = send("brokkr_kitbash.plates", prefix="Free.", table=json.dumps(TWO))
bpy.context.view_layer.update()
proven("no host and no frame: the table's frame is the world", TWO, 1, "Free.", None, np.eye(4), report)
section("roll")
carried = [o for o in bpy.data.objects if o.name.startswith("Shin.")]
stays = [o for o in bpy.data.objects if o.name.startswith(("Thigh.", "F.", "Free."))]
before = {o.name: world(o) for o in carried + stays + [shin]}
receipt, _ = send("brokkr_kitbash.roll", object_name="Shin", roll=15.0)
bpy.context.view_layer.update()
motion = world(shin) @ np.linalg.inv(before["Shin"])
check("the roll moved the shin", receipt["status"] == "accepted" and np.abs(motion - np.eye(4)).max() > 0.05, receipt["message"])
check("roll-carries: every plate, fit child and anchor on the shin stands at the roll @ where it stood", len(carried) == 5
and reading("carried", max(np.abs(world(o) - motion @ before[o.name]).max() for o in carried)) < CARRIED, R["readings"])
check("what stands on the thigh or on nothing stayed", all(np.array_equal(world(o), before[o.name]) for o in stays), None)
send("brokkr_kitbash.roll", object_name="Shin", roll=0.0)
bpy.context.view_layer.update()
section("hose")
ports = [bpy.data.objects["Thigh.Guard.port.feed"], bpy.data.objects["Shin.Guard.port.return"]]
HOSE = {"object_name": "Feed", "start": ports[0].name, "end": ports[1].name, "radius": RADIUS, "clearance": CLEARANCE, "joint": json.dumps({"socket": "Shin:end_a_back", "standoff": 0.25})}
receipt, report = send("brokkr_kitbash.hose", **HOSE)
R["reports"]["hose"] = report
check("hose-between-ports: a hose routes between the two plates' port empties through the pin point, clear across the pin's range",
receipt["status"] == "accepted" and report["hoses"] == 1 and report["nonManifoldEdges"] == 0 and report["rolls"] >= 9 and report["clearance"] >= CLEARANCE
and report["worstClearance"] >= CLEARANCE, [receipt["status"], receipt["message"], report])
if receipt["status"] == "accepted":
feed = bpy.data.objects["Feed"]
bpy.context.view_layer.update()
V = under(world(feed), points(feed))
expected = [world(shin if index else thigh) @ np.array(next(a for a in plate.build(plate.check(SHIN if index else THIGH))[0]["anchors"] if a["kind"] == "hose_port")["matrix"]) for index in (0, 1)]
check("hose-between-ports: each end stands on its port, as plate.build places it on the panel's top, and leaves along its z",
all(reading("ported", off(V, port)) < PORTED for port in expected) and feed.parent == ports[0], R["readings"])
else:
reading("ported", 1.0)
section("rebuild")
wing = bpy.data.objects["F.Wing.R"]
uid, mesh_uid = wing.session_uid, wing.data.session_uid
foreign = bpy.data.objects.new("Foreign", None)
bpy.context.scene.collection.objects.link(foreign)
foreign.parent = wing
later = wing.modifiers.new("Hers", "TRIANGULATE")
wing.data.materials.append(bpy.data.materials["gunmetal"])
AGAIN = copy.deepcopy(TWO)
AGAIN["plates"][0]["slab"]["thick"] = 0.08
AGAIN["plates"][0]["fits"] = [{"kind": "hose_port", "name": "p", "at": [0.05, 0.0], "lift": 0.01}, {"kind": "mark", "id": "n", "at": [0.0, 0.1], "height": 0.05}]
port_uid = bpy.data.objects["F.Wing.R.port.p"].session_uid
count = len(bpy.data.objects)
receipt, report = send("brokkr_kitbash.plates", host="Thigh", prefix="F.", frame=json.dumps(F.tolist()), table=json.dumps(AGAIN))
bpy.context.view_layer.update()
check("rebuild-in-place: a second call on the same names reports every plate rebuilt", receipt["status"] == "accepted" and [row["rebuilt"] for row in report["plates"]] == [True, True, True],
[receipt["status"], receipt["message"]])
_, again_built = proven("the rebuilt plates are the changed table's", AGAIN, 1, "F.", thigh, F, report)
check("rebuild-in-place: the plate is the object it was, on the mesh it had, with her child, her modifier after the Kit Bevel and her second material slot",
bpy.data.objects["F.Wing.R"].session_uid == uid and wing.data.session_uid == mesh_uid and foreign.parent == wing and [m.name for m in wing.modifiers] == ["Kit Bevel", "Hers"]
and [s.material.name for s in wing.material_slots] == ["khaki", "gunmetal"] and len(bpy.data.objects) == count + 2, [m.name for m in wing.modifiers])
port = bpy.data.objects["F.Wing.R.port.p"]
check("rebuild-in-place: a kept anchor is the empty it was, moved to the row's new place", port.session_uid == port_uid
and reading("moved", np.abs(np.array(port.matrix_basis) - np.array(next(a for a in again_built[0]["anchors"] if a["name"] == "p")["matrix"])).max()) < MOVED, R["readings"])
BARE = copy.deepcopy(AGAIN)
del BARE["plates"][0]["clad"]
BARE["plates"][0]["fits"] = [{"kind": "mark", "id": "n", "at": [0.0, 0.1], "height": 0.05}]
receipt, report = send("brokkr_kitbash.plates", host="Thigh", prefix="F.", frame=json.dumps(F.tolist()), table=json.dumps(BARE))
bpy.context.view_layer.update()
proven("a rebuild without clad removes the fit child, and the anchor the row no longer names", BARE, 1, "F.", thigh, F, report)
check("rebuild-in-place: the dropped child and anchor are gone, her child stays, and no mesh is left behind",
"F.Wing.R.fit.steel" not in bpy.data.objects and "F.Wing.R.port.p" not in bpy.data.objects and foreign.parent == wing and "F.Wing.R.fit.steel" not in bpy.data.meshes
and len(bpy.data.objects) == count + 2 - 4, sorted(o.name for o in bpy.data.objects))
receipt, report = send("brokkr_kitbash.plates", host="Shin", prefix="F.", table=json.dumps(AGAIN))
bpy.context.view_layer.update()
proven("a rebuild onto another host and frame makes the child and anchor again", AGAIN, 1, "F.", shin, world(shin), report)
check("rebuild-in-place: still the same object", bpy.data.objects["F.Wing.R"].session_uid == uid and wing.parent == shin, None)
section("refusals")
ONE = doc({"name": "Lump", "mat": "gunmetal", "points": [[0, 0, 0], [0.2, 0, 0], [0, 0.2, 0], [0, 0, 0.2]]})
CLAD = slab("Guard", [0.0, -0.12, 0.35], ("feed", [0.0, 0.1]))
call = lambda document, **more: {"host": "Thigh", "prefix": "N.", "table": json.dumps(document), **more} # noqa: E731
refused("a table the format refuses, by its path", call(doc({**ONE["plates"][0], "colour": "red"})), "table: plates[0].colour: unknown key")
refused("a row that bounds no solid", call(doc({"name": "Flat", "mat": "gunmetal", "points": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0]]})), "table: plates[0]")
refused("a table that is not JSON", call(ONE, table="{"), "table is not JSON")
refused("a row material the file lacks", call(doc({**ONE["plates"][0], "mat": "brass"})), "table.plates[0].mat: no material named 'brass'")
refused("a clad material the file lacks", call(doc({**CLAD, "clad": {**CLAD["clad"], "mat": "brass"}})), "table.plates[0].clad.mat: no material named 'brass'")
refused("a bolt material the file lacks", call(doc({**CLAD, "clad": {**CLAD["clad"], "bolt_mat": "brass"}})), "table.plates[0].clad.bolt_mat: no material named 'brass'")
refused("a second row's missing material, after a first row that would be written", call(doc(ONE["plates"][0], {**ONE["plates"][0], "name": "Other", "mat": "brass"})), "table.plates[1].mat")
refused("a host that is not there", call(ONE, host="Hip"), "host: no object named 'Hip'")
scaled = bpy.data.objects.new("Scaled", None)
bpy.context.scene.collection.objects.link(scaled)
scaled.scale = (1.0, 2.0, 1.0)
bpy.context.view_layer.update()
refused("a host that is scaled", call(ONE, host="Scaled"), "'Scaled' is scaled, mirrored or sheared")
eye = np.eye(4)
refused("a frame that is not JSON", call(ONE, frame="[[1, 0"), "frame is not JSON")
refused("a frame of three rows", call(ONE, frame=json.dumps(eye[:3].tolist())), "frame must be a JSON array of 4 rows of 4 finite numbers")
refused("a frame with a number that is not finite", call(ONE, frame=json.dumps(eye.tolist()).replace("1.0", "NaN", 1)), "frame must be a JSON array of 4 rows of 4 finite numbers")
refused("a frame that scales", call(ONE, frame=json.dumps((eye * [2, 1, 1, 1]).tolist())), "frame is not rigid")
refused("a frame that mirrors", call(ONE, frame=json.dumps((eye * [-1, 1, 1, 1]).tolist())), "frame is not rigid")
refused("a frame whose last row is no frame's", call(ONE, frame=json.dumps((eye + np.outer([0, 0, 0, 1], [0.5, 0, 0, 0])).tolist())), "frame is not rigid")
refused("side 0", call(ONE, side=0), "side must be 1 or -1")
refused("a prefix with a character the names do not take", call(ONE, prefix="a-b"), "prefix 'a-b' must be 0 to 32 characters")
refused("a plate's name taken by an object plates did not make", call(ONE, prefix="", table=json.dumps(doc({**ONE["plates"][0], "name": "Shin"}))), "an object named 'Shin' exists and is no plate")
stray = bpy.data.objects.new("N.Guard.fit.olive_light", bpy.data.meshes.new("stray"))
bpy.context.scene.collection.objects.link(stray)
refused("a fit child's name taken, the plate new", call(doc(CLAD)), "an object named 'N.Guard.fit.olive_light' exists and is not this plate's")
stray.name = "Thigh.Guard.port.spare"
spare = copy.deepcopy(THIGH)
spare["plates"][0]["fits"].append({"kind": "hose_port", "name": "spare", "at": [0.05, 0.0]})
refused("an anchor's name taken by an object that is no child of the plate, on a rebuild", call(spare, prefix="Thigh."), "an object named 'Thigh.Guard.port.spare' exists and is not this plate's")
refused("a row whose name is another row's fit child", call(doc(CLAD, {**ONE["plates"][0], "name": "Guard.fit.gunmetal"})), "the name 'N.Guard.fit.gunmetal' is made twice")
refused("a made name over 63 bytes", call(doc({**CLAD, "name": "G" * 40}), prefix="P" * 20), "bytes, over the 63 an object's name holds")
refused("a host that is the plate", call(THIGH, host="Thigh.Guard", prefix="Thigh."), "a plate is no host of itself")
refused("a host under the plate", call(THIGH, host="Thigh.Guard.port.feed", prefix="Thigh."), "a plate is no host of itself")
many = doc(*[{"name": f"a{index:03d}", "mat": "gunmetal", "points": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]]} for index in range(256)])
refused("a report a receipt does not carry", call(many, table=json.dumps(many, separators=(",", ":"))), "over the 16000 a receipt carries")
twin = bpy.data.objects.new("Twin", guard.data)
bpy.context.scene.collection.objects.link(twin)
refused("a plate that shares its mesh", call(THIGH, prefix="Thigh."), "'Thigh.Guard' shares its mesh")
bpy.data.objects.remove(twin)
receipt, _ = send("brokkr_kitbash.freeze", object_name="Thigh.Guard")
refused("a frozen plate", call(THIGH, prefix="Thigh."), "'Thigh.Guard' is frozen")
send("brokkr_kitbash.thaw", object_name="Thigh.Guard")
receipt, report = send("brokkr_kitbash.plates", host="Thigh", prefix="Thigh.", table=json.dumps(THIGH))
bpy.context.view_layer.update()
check("thawed, the plate is rebuilt", receipt["status"] == "accepted" and report["plates"][0]["rebuilt"], [receipt["status"], receipt["message"]])
proven("the thawed plate", THIGH, 1, "Thigh.", thigh, world(thigh), report)
section("fittings")
for name in ("pit", "machine"):
bpy.data.materials.new(name)
KIT = slab("Kit", [0.0, -0.3, 0.3], ("feed", [0.0, 0.1]))
KIT["sides"] = "both"
KIT["fits"] += [{"kind": "bolts", "inset": 0.012, "spacing": 0.08, "params": "r=0.006", "mat": "gunmetal"},
{"kind": "part", "part": "slot", "at": [0.0, 0.18], "params": "w=0.08; h=0.02", "mat": "khaki"},
{"kind": "part", "part": "pit", "at": [0.0, 0.18], "params": "w=0.08; h=0.02", "mat": "pit"},
{"kind": "part", "part": "vents", "at": [-0.06, 0.03], "params": "w=0.06; h=0.012; count=3", "mat": "khaki"},
{"kind": "part", "part": "pit", "at": [-0.06, 0.03], "params": "w=0.06; h=0.012; depth=0.01; count=3; pitch=0.0324", "mat": "pit"},
{"kind": "part", "part": "access_port", "at": [0.07, -0.1], "params": "r=0.03", "mat": "machine"},
{"kind": "part", "part": "port_bolts", "at": [0.07, -0.1], "params": "r=0.03", "mat": "gunmetal"},
{"kind": "part", "part": "handle", "at": [-0.07, -0.1], "roll": 90.0, "params": "length=0.1; lift=0.04; r=0.004", "mat": "gunmetal"},
{"kind": "part", "part": "eye", "at": [0.08, 0.12], "lift": 0.002, "params": "size=0.03", "mat": "gunmetal"},
{"kind": "part", "part": "louvres", "at": [0.0, -0.18], "params": "w=0.1; h=0.1; n=3; depth=0.02; frame=0.02", "mat": "steel"},
{"kind": "step", "outline": [[-0.1, -0.06], [0.1, -0.06], [0.1, 0.06], [-0.1, 0.06]], "at": [0.0, 0.0], "lift": 0.012, "mat": "olive_light", "bolt_mat": "steel"}]
FITS = doc(KIT)
before = scene_state()
refused("a fit whose material is not in the file", call(doc({**KIT, "fits": KIT["fits"] + [{"kind": "part", "part": "bolt", "at": [0, 0], "mat": "brass"}]}), prefix="Fit."), "table.plates[0].fits[13].mat: no material named 'brass'")
refused("a step whose bolts' material is not in the file", call(doc({**KIT, "fits": [{**KIT["fits"][-1], "bolt_mat": "brass"}]}), prefix="Fit."), "table.plates[0].fits[0].bolt_mat: no material named 'brass'")
refused("a part the fittings kit does not have", call(doc({**KIT, "fits": [{"kind": "part", "part": "rivet", "at": [0, 0], "mat": "steel"}]}), prefix="Fit."), "table: plates[0].fits[0].part: 'rivet' is no part of the fittings kit")
check("refused, the fittings call left the scene as it was", scene_state() == before)
receipt, report = send("brokkr_kitbash.plates", host="Thigh", prefix="Fit.", table=json.dumps(FITS))
bpy.context.view_layer.update()
check("a slab with a fit row of every kind is accepted", receipt["status"] == "accepted", [receipt["status"], receipt["message"]])
R["reports"]["fittings"] = report
_, fit_built = proven("a row of every fit kind, on both sides", FITS, 1, "Fit.", thigh, world(thigh), report)
mats = ["gunmetal", "khaki", "machine", "olive_light", "pit", "steel"]
for side in "RL":
kit_plate = bpy.data.objects.get(f"Fit.Kit.{side}")
check(f"fits-written: Kit.{side} has a fit child per material, the fittings beside the panels and their bolts",
kit_plate is not None and sorted(c.name for c in kit_plate.children if c.type == "MESH") == [f"Fit.Kit.{side}.fit.{m}" for m in mats]
and bevel(bpy.data.objects[f"Fit.Kit.{side}.fit.olive_light"]) == (0.012, 20.0, 1, "ANGLE") and bevel(bpy.data.objects[f"Fit.Kit.{side}.fit.pit"]) is None,
kit_plate and sorted(c.name for c in kit_plate.children))
check("the report counts what stands: the rim's bolts, nine parts and a step", report is not None and [row["fits"] for row in report["plates"]] == [fit_built[0]["report"]["fits"]] * 2
and fit_built[0]["report"]["fits"] > 11, report and [row.get("fits") for row in report["plates"]])
BARE = doc({**KIT, "fits": KIT["fits"][:3]})
receipt, report = send("brokkr_kitbash.plates", host="Thigh", prefix="Fit.", table=json.dumps(BARE))
bpy.context.view_layer.update()
proven("rebuilt with the rim's bolts alone", BARE, 1, "Fit.", thigh, world(thigh), report)
check("a rebuild removes the fit children it no longer makes", sorted(c.name for c in bpy.data.objects["Fit.Kit.R"].children if c.type == "MESH") == ["Fit.Kit.R.fit.gunmetal", "Fit.Kit.R.fit.olive_light"]
and "Fit.Kit.R.fit.pit" not in bpy.data.objects, sorted(c.name for c in bpy.data.objects["Fit.Kit.R"].children))
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, not a missing result file
check(f"no uncaught error in section: {SECTION[0]}", False, traceback.format_exc().splitlines()[-6:])
finally:
R["ok"] = all(c["ok"] for c in R["checks"])
R["readings"] = {name: float(f"{value:.2g}") for name, value in sorted(R["readings"].items())}
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
print("READINGS", R["readings"], flush=True)
sys.exit(0 if R["ok"] else 1)

View file

@ -0,0 +1,435 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "plates on the thigh are accepted and none is a rebuild",
"ok": true,
"detail": null
},
{
"name": "written-is-built: a plate on the thigh, the frame the host's",
"ok": true,
"detail": null
},
{
"name": "written-is-built: a plate on the shin, under the pin",
"ok": true,
"detail": null
},
{
"name": "a plate with a panel and its bolts has two fit children and two anchors, and the panel's child alone a bevel",
"ok": true,
"detail": null
},
{
"name": "roll-carries: joints lists the same rows with the plates as without",
"ok": true,
"detail": null
},
{
"name": "a plate is no kit part: report lists the two struts",
"ok": true,
"detail": null
},
{
"name": "plates under a stated frame are accepted at side 1",
"ok": true,
"detail": null
},
{
"name": "written-is-built: a two-sided row and a bare one under a stated frame, side 1: panels and bolts of one material are one child",
"ok": true,
"detail": null
},
{
"name": "plates under a stated frame are accepted at side -1",
"ok": true,
"detail": null
},
{
"name": "written-is-built: a two-sided row and a bare one under a stated frame, side -1: panels and bolts of one material are one child",
"ok": true,
"detail": null
},
{
"name": "a bare plate has no child and no bevel; a two-sided row is two plates",
"ok": true,
"detail": null
},
{
"name": "written-is-built: no host and no frame: the table's frame is the world",
"ok": true,
"detail": null
},
{
"name": "the roll moved the shin",
"ok": true,
"detail": null
},
{
"name": "roll-carries: every plate, fit child and anchor on the shin stands at the roll @ where it stood",
"ok": true,
"detail": null
},
{
"name": "what stands on the thigh or on nothing stayed",
"ok": true,
"detail": null
},
{
"name": "hose-between-ports: a hose routes between the two plates' port empties through the pin point, clear across the pin's range",
"ok": true,
"detail": null
},
{
"name": "hose-between-ports: each end stands on its port, as plate.build places it on the panel's top, and leaves along its z",
"ok": true,
"detail": null
},
{
"name": "rebuild-in-place: a second call on the same names reports every plate rebuilt",
"ok": true,
"detail": null
},
{
"name": "written-is-built: the rebuilt plates are the changed table's",
"ok": true,
"detail": null
},
{
"name": "rebuild-in-place: the plate is the object it was, on the mesh it had, with her child, her modifier after the Kit Bevel and her second material slot",
"ok": true,
"detail": null
},
{
"name": "rebuild-in-place: a kept anchor is the empty it was, moved to the row's new place",
"ok": true,
"detail": null
},
{
"name": "written-is-built: a rebuild without clad removes the fit child, and the anchor the row no longer names",
"ok": true,
"detail": null
},
{
"name": "rebuild-in-place: the dropped child and anchor are gone, her child stays, and no mesh is left behind",
"ok": true,
"detail": null
},
{
"name": "written-is-built: a rebuild onto another host and frame makes the child and anchor again",
"ok": true,
"detail": null
},
{
"name": "rebuild-in-place: still the same object",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a table the format refuses, by its path",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a row that bounds no solid",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a table that is not JSON",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a row material the file lacks",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a clad material the file lacks",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a bolt material the file lacks",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a second row's missing material, after a first row that would be written",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a host that is not there",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a host that is scaled",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a frame that is not JSON",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a frame of three rows",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a frame with a number that is not finite",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a frame that scales",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a frame that mirrors",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a frame whose last row is no frame's",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: side 0",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a prefix with a character the names do not take",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a plate's name taken by an object plates did not make",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a fit child's name taken, the plate new",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: an anchor's name taken by an object that is no child of the plate, on a rebuild",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a row whose name is another row's fit child",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a made name over 63 bytes",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a host that is the plate",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a host under the plate",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a report a receipt does not carry",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a plate that shares its mesh",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a frozen plate",
"ok": true,
"detail": null
},
{
"name": "thawed, the plate is rebuilt",
"ok": true,
"detail": null
},
{
"name": "written-is-built: the thawed plate",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a fit whose material is not in the file",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a step whose bolts' material is not in the file",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a part the fittings kit does not have",
"ok": true,
"detail": null
},
{
"name": "refused, the fittings call left the scene as it was",
"ok": true,
"detail": null
},
{
"name": "a slab with a fit row of every kind is accepted",
"ok": true,
"detail": null
},
{
"name": "written-is-built: a row of every fit kind, on both sides",
"ok": true,
"detail": null
},
{
"name": "fits-written: Kit.R has a fit child per material, the fittings beside the panels and their bolts",
"ok": true,
"detail": null
},
{
"name": "fits-written: Kit.L has a fit child per material, the fittings beside the panels and their bolts",
"ok": true,
"detail": null
},
{
"name": "the report counts what stands: the rim's bolts, nine parts and a step",
"ok": true,
"detail": null
},
{
"name": "written-is-built: rebuilt with the rim's bolts alone",
"ok": true,
"detail": null
},
{
"name": "a rebuild removes the fit children it no longer makes",
"ok": true,
"detail": null
}
],
"hostErrors": [],
"readings": {
"anchored": 2.2e-07,
"carried": 1e-07,
"moved": 2.1e-07,
"ported": 3.9e-08,
"written": 8.4e-08
},
"reports": {
"thigh": {
"plates": [
{
"name": "Thigh.Guard",
"rebuilt": false,
"corners": 16,
"facets": 10,
"panels": 1,
"bolts": 4,
"fits": 0,
"anchors": [
"Thigh.Guard.port.feed",
"Thigh.Guard.mark.num"
]
}
],
"host": "Thigh",
"side": 1
},
"hose": {
"object": "Feed",
"rebuilt": false,
"hoses": 1,
"length": 0.834382,
"lengthChange": 0.002158,
"floor": 0.048,
"clearance": 0.042341,
"capped": 0.121,
"voxels": [
42560,
36456
],
"seed": {
"step": 0.02,
"offset": [
0.0,
0.0,
0.0
],
"refined": false
},
"sag": [
0.007788,
0.003557
],
"rolls": 9,
"worstRoll": -20.0,
"worstClearance": 0.043363,
"faces": 1078,
"volume": 0.000105174,
"nonManifoldEdges": 0,
"radii": {
"least": 0.056641,
"corners": [
0.071927,
1.931459,
0.258593,
3.432944,
0.056641
]
}
},
"fittings": {
"plates": [
{
"name": "Fit.Kit.R",
"rebuilt": false,
"corners": 16,
"facets": 10,
"panels": 1,
"bolts": 4,
"fits": 26,
"anchors": [
"Fit.Kit.R.port.feed",
"Fit.Kit.R.mark.num"
]
},
{
"name": "Fit.Kit.L",
"rebuilt": false,
"corners": 16,
"facets": 10,
"panels": 1,
"bolts": 4,
"fits": 26,
"anchors": [
"Fit.Kit.L.port.feed",
"Fit.Kit.L.mark.num"
]
}
],
"host": "Thigh",
"side": 1
}
},
"ok": true
}

View file

@ -0,0 +1,491 @@
"""Live proof, in a background Blender, of brokkr_kitbash posing through run_intent: roll turns an attached part
where it hangs, aim and reach solve the roll (core.aim_roll, core.reach_roll), each reports the closures it opened,
and each refusal changes nothing. Not part of the unittest run: it needs Blender.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/kitbash_pose.py -- <out>
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). <out> is an absolute path; writes <out>.result.json and exits 1 when a check failed. The checks run inside one try: an uncaught error is a failed check that names
the check before it, the checks are printed and the result file written whatever happened, and the exit is 1 with or
without --python-exit-code.
The scene: a tank, a bracket on its lug, a strut pinned in the bracket, an actuator pinned on the strut's far end,
and a loose strut whose closure names the actuator's rod pin. Bounds follow lodur:ruling:deterministic-bound-margin:
each sits at the geometric mean of the shipped worst reading and the least claimed mutant's, both written beside
it; the result file carries the readings.
"""
import importlib.util
import json
import math
import os
import sys
import traceback
import tempfile
import types
from pathlib import Path
import bpy
import numpy as np
from mathutils import Matrix
SURFACE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(SURFACE / "tools"))
import private_dirs # noqa: E402
_refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if _refused:
raise SystemExit(_refused)
OUT = sys.argv[sys.argv.index("--") + 1]
if not Path(OUT).is_absolute():
raise SystemExit(f"{OUT!r} is not an absolute path")
package = types.ModuleType("brokkr_bridge")
package.__path__ = [str(SURFACE / "brokkr_bridge")]
sys.modules["brokkr_bridge"] = package
from brokkr_bridge import blender_target as bt # noqa: E402
import addon_utils # noqa: E402
spec = importlib.util.spec_from_file_location("brokkr_kitbash_core_reference", SURFACE / "brokkr_kitbash" / "core.py")
core = importlib.util.module_from_spec(spec) # core as the unit tests load it: the frames every reading here is taken against
spec.loader.exec_module(core)
sys.path.append(str(SURFACE))
bpy.ops.wm.read_factory_settings(use_empty=True)
for module in ("brokkr_mesh_polish", "brokkr_kitbash"):
addon_utils.enable(module, default_set=True)
target = bt.BrokkrBlenderTarget(bpy)
WORK = Path(tempfile.mkdtemp(prefix="brokkr-kitbash-pose-"))
target.configure_action_dirs("", str(WORK))
target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1], "readings": {}}
COUNT = [0]
kit = core.load_kit("mechanical")
# Each mutant's reading below is its least over the cases here that it changes; the shipped reading is the worst.
# Metres (or a difference of unit vectors) between where a posed part's socket is and where its mate puts it, read
# from the two world matrices. Shipped worst 1.1e-06 (float32 matrices); least claimed mutant 0.25 (R9,
# write_connection seats with the two sockets swapped); separation 2.3e5.
SEATED = 5.2e-4
# Degrees between the roll read from the two world frames and the roll stated. Shipped worst 8.4e-06; least claimed
# mutant 15 (R3, roll writes kit_roll without seating, at the smallest turn here); separation 1.8e6.
ROLL = 1.1e-2
# Metres the actuator's pin moves when the strut it hangs from is rolled. Shipped least 0.55 (the 45 degree turn);
# least claimed mutant reads at most 5e-08 (R3: nothing moves); separation 1.1e7.
TURNED = 1.7e-4
# The dot aim reports against the dot read from the scene, and how far a roll on the 1-degree grid passes the dot
# read. Shipped worst 3.3e-07; least claimed mutant 0.0014 (R6, a left-handed roll_terms, at the aim nearest its
# mirror); R1 (atan2(A, B)) reads 0.81 and R8 (the dot without its hypot) 0.86; separation 4.2e3.
AIMED = 2.1e-5
# Metres between the socket reach moved and the plane asked for, read from the scene. Shipped worst 2.1e-07; least
# claimed mutant 0.42 (R6); separation 2.0e6.
REACHED = 3.0e-4
# Degrees the other root stands farther from the roll the part had than the root reach took. A rule, the sign: shipped
# least 74; R2 (the farther root) reads -74.
NEARER = 0.0
# Metres past the top of its circle a reach may ask (core.REACH_EDGE, a rule: HELD). A height typed back from a
# refusal's range overshoots by at most 3.2e-07 here and is taken; PAST is refused. The two sit sqrt(10) either side.
EDGE, PAST = 1e-5, 3.2e-5
# The largest difference between a joints row's axis or origin and the parent socket's z or origin read from the scene
# in the root's frame. Shipped worst 4.9e-07 (rows carry 6 decimals); least claimed mutant 3.1 (J11, the rows in the
# world's frame); separation 6.3e6.
JOINT_FRAME = 1.2e-3
# The joint-record readings below use the bounds above: "slid", metres between the rod's piston and the point its slide
# states along the bore's z, against SEATED (shipped 1.4e-07; least claimed mutant J1, the slide applied after FLIP, reads 0.6);
# "limit roll", degrees between a roll solved inside limits and the one expected, against ROLL (shipped
# 2e-05; its mutants J2, J3 and J4 die in test_kitbash's JointRecordTests, where their readings are).
def check(name, ok, detail=None):
try:
json.dumps(detail, default=str)
except TypeError: # a detail keyed by tuples: the result file takes it as text, so a failed check is written and not a crash
detail = repr(detail)
R["checks"].append({"name": name, "ok": bool(ok), "detail": None if ok else detail}) # what was seen, when it was not what was promised
def reading(name, value):
R["readings"][name] = max(R["readings"].get(name, 0.0), float(value))
return float(value)
def least(name, value):
R["readings"][name] = min(R["readings"].get(name, math.inf), float(value))
return float(value)
def send(action, **fields):
COUNT[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"live-{COUNT[0]}", "requestedBy": "test/driver", "action": action, **fields})
result = None
if receipt.get("hostResult"):
try:
result = json.loads(receipt["hostResult"])
except ValueError:
result = None
print("SEND", action, receipt["status"], str(receipt["message"])[:300], flush=True)
return receipt, result
def place(name, part, params="", location=None, rotation=None):
send("brokkr_kitbash.place_part", part=part, object_name=name, params=params)
if location is not None:
send("setObjectTransform", targetObjectName=name, location=location, rotationEuler=rotation or [0.0, 0.0, 0.0])
return bpy.data.objects[name]
def socket(obj, name):
built = core.build(core.part(kit, obj["kit_part"]), json.loads(obj["kit_params"]))
return next(s for s in built.sockets if s["name"] == name)
def frame(obj, name):
"""A socket's world frame, from the object's matrix_world and core's build of its stored params."""
return np.array(obj.matrix_world, dtype=np.float64) @ socket(obj, name)["matrix"]
def seated(child, name, parent, parent_socket, roll=None):
"""How far a child's socket is from seated on its parent's: origins apart, or normals not opposed. With a roll,
also records the degrees between it and the roll read from the two frames."""
a, b = frame(parent, parent_socket), frame(child, name)
if roll is not None:
read = math.degrees(math.atan2(np.cross(a[:3, 1], b[:3, 1]) @ a[:3, 2], a[:3, 1] @ b[:3, 1]))
reading("roll", abs((read - roll + 180.0) % 360.0 - 180.0))
return max(float(np.abs(a[:3, 3] - b[:3, 3]).max()), float(np.abs(a[:3, 2] + b[:3, 2]).max()))
def connection(name):
receipt, report = send("brokkr_kitbash.report", object_name=name)
return report["parts"][0]["connection"] if report else {"error": receipt["message"]}
def holds(found, parent, name, parent_socket, roll):
"""A connection row that states this connection and holds."""
found = found or {}
return found == {**found, "parent": parent, "socket": name, "parentSocket": parent_socket, "roll": roll, "holds": True} and found.get("residual", 1.0) <= 1e-5
def stated(obj):
return obj.parent and obj.parent.name, {k: obj[k] for k in sorted(obj.keys()) if k.startswith("kit_") and k != "kit_roll"}, np.array(obj.matrix_parent_inverse).tolist()
def scene_state():
return {o.name: (o.parent and o.parent.name, np.round(np.array(o.matrix_basis), 6).tolist(), np.round(np.array(o.matrix_parent_inverse), 6).tolist(),
{k: repr(o[k]) for k in sorted(o.keys()) if k.startswith("kit_")}) for o in bpy.data.objects}
def refused(label, action, fields, expected):
state = scene_state()
receipt, _ = send(action, **fields)
check(f"refused, scene unchanged: {label}", receipt["status"] != "accepted" and expected in str(receipt["message"]) and scene_state() == state,
[receipt["status"], receipt["message"]])
try:
rows = [row["name"] for row in target.host_actions()[0] if row["name"].startswith("brokkr_kitbash.")]
check("roll, aim and reach load as host actions after detach, with no errors", not R["hostErrors"] and "brokkr_kitbash.detach" in rows
and rows[rows.index("brokkr_kitbash.detach") + 1:][:3] == ["brokkr_kitbash.roll", "brokkr_kitbash.aim", "brokkr_kitbash.reach"], [R["hostErrors"], rows])
# --- the scene ----------------------------------------------------------------------------------------------------------
tank = place("Tank", "tank", "radius=0.3; length=1.2", location=[1.0, 2.0, 3.0], rotation=[0.3, -0.2, 0.5]) # lug size 0.09
mount = place("Mount", "bracket") # pin 0.054, plate 0.09
strut, ram = place("Strut", "strut", "width=0.09"), place("Ram", "actuator")
spare, orphan = place("Spare", "strut", "width=0.09", location=[0.0, 6.0, 0.0]), place("Orphan", "bracket")
send("createObject", objectType="MESH", name="Plain", location=[0.0, 12.0, 0.0], size=0.3)
send("brokkr_kitbash.attach", object_name="Mount", socket="mount", parent_name="Tank", parent_socket="lug_b")
send("brokkr_kitbash.attach", object_name="Orphan", socket="mount", parent_name="Tank", parent_socket="lug_a")
send("brokkr_kitbash.attach", object_name="Strut", socket="end_a", parent_name="Mount", parent_socket="pivot", roll=20.0)
receipt, report = send("brokkr_kitbash.attach", object_name="Ram", socket="base", parent_name="Strut", parent_socket="end_b", roll=-35.0)
check("the chain stands: tank, bracket, strut, actuator", receipt["status"] == "accepted" and holds(connection("Strut"), "Mount", "end_a", "pivot", 20.0)
and holds(report["connection"], "Strut", "base", "end_b", -35.0), [receipt["message"], connection("Strut")])
def meeting(name, other, other_socket, roll):
"""Place a loose strut so its end_a meets a socket of another part, and close it there."""
loose = place(name, "strut", "width=0.09")
meet = Matrix((np.array(other.matrix_world) @ core.mate(socket(other, other_socket), socket(loose, "end_a"), roll)).tolist())
send("setObjectTransform", targetObjectName=name, location=list(meet.translation), rotationEuler=list(meet.to_euler("XYZ")))
return send("brokkr_kitbash.close", object_name=name, socket="end_a", other_name=other.name, other_socket=other_socket)
anchor = place("Aa_Anchor", "strut", "width=0.09", location=[0.0, -20.0, 0.0])
receipt, report = meeting("Brace", ram, "rod_end", 50.0)
check("a brace closes on the actuator's rod pin", receipt["status"] == "accepted" and report and report["closure"]["holds"] is True, [receipt["message"], report and report["closure"]])
receipt, report = meeting("Aa_Loose", anchor, "end_b", 40.0)
check("and a second closure, named to sort first, holds far from it", receipt["status"] == "accepted" and report and report["closure"]["holds"] is True, [receipt["message"], report and report["closure"]])
brace = bpy.data.objects["Brace"]
closing = {k: brace[k] for k in brace.keys() if k.startswith("kit_close")}
# --- roll: in place -----------------------------------------------------------------------------------------------------
for turn in (65.0, -160.0, 35.0): # from the 20 it was attached at
was, pin, before = stated(strut), frame(ram, "base")[:3, 3].copy(), (stated(ram), ram["kit_roll"], np.array(ram.matrix_basis).tolist())
sent = COUNT[0]
receipt, report = send("brokkr_kitbash.roll", object_name="Strut", roll=turn)
gap, off = reading("seated", seated(strut, "end_a", mount, "pivot", turn)), R["readings"]["roll"]
check(f"roll {turn:g} turns the strut where it hangs: one intent, its parent, sockets and parent inverse as they were, its roll stated and seated",
receipt["status"] == "accepted" and COUNT[0] == sent + 1 and stated(strut) == was and strut["kit_roll"] == turn and gap < SEATED and off < ROLL
and report and report["object"] == "Strut" and holds(report["connection"], "Mount", "end_a", "pivot", turn) and holds(connection("Strut"), "Mount", "end_a", "pivot", turn),
[receipt["message"], report and report["connection"], gap, off])
moved, gap = least("turned", float(np.linalg.norm(frame(ram, "base")[:3, 3] - pin))), reading("seated", seated(ram, "base", strut, "end_b", -35.0))
check(f"and the actuator follows through its own connection, which nothing rewrote (roll {turn:g})",
(stated(ram), ram["kit_roll"], np.array(ram.matrix_basis).tolist()) == before and moved > TURNED and gap < SEATED and R["readings"]["roll"] < ROLL
and holds(connection("Ram"), "Strut", "base", "end_b", -35.0), [moved, gap, connection("Ram"), R["readings"]])
# --- roll: the closures it opens ----------------------------------------------------------------------------------------
check("the rolls above opened the brace's closure and reported it before the one that holds, whatever its name", (report or {}).get("closures") == [
{"part": "Brace", "to": "Ram", "holds": False}, {"part": "Aa_Loose", "to": "Aa_Anchor", "holds": True}] and report["closure"] is None, report and report.get("closures"))
receipt, report = send("brokkr_kitbash.roll", object_name="Strut", roll=20.0)
check("rolled back to where the brace met it, the closure holds again: read from where the parts stand", receipt["status"] == "accepted" and (report or {}).get("closures") == [
{"part": "Aa_Loose", "to": "Aa_Anchor", "holds": True}, {"part": "Brace", "to": "Ram", "holds": True}], report and report.get("closures"))
send("setObjectTransform", targetObjectName="Aa_Loose", location=[0.0, -25.0, 0.0], rotationEuler=[0.0, 0.0, 0.0])
receipt, report = send("brokkr_kitbash.roll", object_name="Ram", roll=-35.0)
check("a roll lists the closures its own part is an end of first, before a broken one elsewhere", receipt["status"] == "accepted" and (report or {}).get("closures") == [
{"part": "Brace", "to": "Ram", "holds": True}, {"part": "Aa_Loose", "to": "Aa_Anchor", "holds": False}], report and report.get("closures"))
receipt, report = send("brokkr_kitbash.roll", object_name="Ram", roll=-36.0)
check("and a roll of the part a closure names opens it; no roll seats or rewrites a closure", receipt["status"] == "accepted" and (report or {}).get("closures") == [
{"part": "Brace", "to": "Ram", "holds": False}, {"part": "Aa_Loose", "to": "Aa_Anchor", "holds": False}]
and {k: brace[k] for k in brace.keys() if k.startswith("kit_close")} == closing and brace.parent is None, [report and report.get("closures"), dict(brace.items())])
# --- aim ----------------------------------------------------------------------------------------------------------------
for axis, direction in (("+z", (1.0, 0.0, 0.0)), ("-x", (0.0, -3.0, 4.0)), ("+z", (0.2, 0.1, -2.0))):
world, unit = np.array(mount.matrix_world, dtype=np.float64), np.array(direction) / np.linalg.norm(direction)
receipt, report = send("brokkr_kitbash.aim", object_name="Strut", axis=axis, direction_x=direction[0], direction_y=direction[1], direction_z=direction[2])
aimed = (report or {}).get("aimed") or {"roll": 1e9, "dot": 1e9}
read = float(np.array(strut.matrix_world, dtype=np.float64)[:3, :3] @ np.array(core.AXES[axis]) @ unit)
grid = max(float((world @ core.mate(socket(mount, "pivot"), socket(strut, "end_a"), float(r)))[:3, :3] @ np.array(core.AXES[axis]) @ unit) for r in range(-180, 180))
apart, short = reading("aimed", abs(aimed["dot"] - read)), reading("aimed short", max(grid - read, 0.0))
check(f"aim points the strut's {axis} at {direction} as far as its pin lets it: the dot it reports is the dot the scene reads, and no roll on a 1-degree grid passes it",
receipt["status"] == "accepted" and apart < AIMED and short < AIMED and 0.2 < aimed["dot"] < 0.999, [receipt["message"], aimed, read, grid])
gap, off = reading("seated", seated(strut, "end_a", mount, "pivot", aimed["roll"])), R["readings"]["roll"]
check(f"and it is stated and seated as roll's: the connection holds at the aimed roll, the actuator with it, closures reported ({axis})",
aimed["roll"] == round(strut["kit_roll"], 6) and -180.0 < aimed["roll"] <= 180.0 and holds(report and report["connection"], "Mount", "end_a", "pivot", aimed["roll"])
and gap < SEATED and off < ROLL and holds(connection("Ram"), "Strut", "base", "end_b", -36.0) and len((report or {}).get("closures", [])) == 2,
[dict(strut.items()), report and report["connection"], report and report.get("closures"), gap, off])
# --- reach --------------------------------------------------------------------------------------------------------------
for direction, part, offset in (((0.0, 0.0, 1.0), 0.5, 40.0), ((0.0, 0.0, 1.0), 0.5, -40.0), ((1.0, 2.0, -0.5), -0.8, 100.0)):
world, unit = np.array(mount.matrix_world, dtype=np.float64), np.array(direction) / np.linalg.norm(direction)
A, B, C = core.roll_terms(world, socket(mount, "pivot"), socket(strut, "end_a"), socket(strut, "end_b")["matrix"][:3, 3], 1.0, unit)
current = float(round(math.degrees(math.atan2(B, A)) + offset)) # the two rolls that reach stand either side of the middle: start nearer one
send("brokkr_kitbash.roll", object_name="Strut", roll=current)
height = round(C + part * math.hypot(A, B), 3)
fields = {"direction_x": direction[0], "direction_y": direction[1], "direction_z": direction[2]} if direction != (0.0, 0.0, 1.0) else {} # world z is the default
receipt, report = send("brokkr_kitbash.reach", object_name="Strut", socket="end_b", height=height, **fields)
reached = (report or {}).get("reached") or {"roll": 1e9, "residual": 1e9}
apart = lambda roll: abs((roll - current + 180.0) % 360.0 - 180.0) # noqa: E731
off_plane = reading("reached", abs(float(frame(strut, "end_b")[:3, 3] @ unit) - height))
farther = least("reach other root", apart(2.0 * math.degrees(math.atan2(B, A)) - reached["roll"]) - apart(reached["roll"])) # the other root mirrors it about the middle
check(f"reach brings the strut's end_b to {height} m along {direction} from roll {current:g}, by the nearer of the two rolls that do",
receipt["status"] == "accepted" and off_plane < REACHED and reached["residual"] < REACHED and farther > NEARER,
[receipt["message"], reached, off_plane, farther])
gap, off = reading("seated", seated(strut, "end_a", mount, "pivot", reached["roll"])), R["readings"]["roll"]
check(f"and it is stated and seated as roll's ({direction}, from {current:g})", reached["roll"] == round(strut["kit_roll"], 6) and -180.0 < reached["roll"] <= 180.0
and holds(report and report["connection"], "Mount", "end_a", "pivot", reached["roll"]) and gap < SEATED and off < ROLL
and holds(connection("Ram"), "Strut", "base", "end_b", -36.0) and len((report or {}).get("closures", [])) == 2,
[dict(strut.items()), report and report["connection"], gap, off])
# --- refusals -----------------------------------------------------------------------------------------------------------
send("setObjectParent", targetObjectName="Orphan", parentObjectName="")
low, high = C - math.hypot(A, B), C + math.hypot(A, B)
refused("roll of a part nobody attached", "brokkr_kitbash.roll", {"object_name": "Spare", "roll": 10.0}, "'Spare' is not attached (it has no kit_socket property)")
refused("aim of a part nobody attached", "brokkr_kitbash.aim", {"object_name": "Spare", "axis": "+z", "direction_x": 1.0, "direction_y": 0.0, "direction_z": 0.0}, "'Spare' is not attached")
refused("reach of a part nobody attached", "brokkr_kitbash.reach", {"object_name": "Spare", "socket": "end_b", "height": 0.0}, "'Spare' is not attached")
refused("roll of a part whose parent was cleared", "brokkr_kitbash.roll", {"object_name": "Orphan", "roll": 10.0}, "'Orphan' states a connection and has no parent: detach it")
refused("roll of a mesh that is not a kit part", "brokkr_kitbash.roll", {"object_name": "Plain", "roll": 10.0}, "'Plain' is not a kit part")
refused("aim of the axis along the pin", "brokkr_kitbash.aim", {"object_name": "Strut", "axis": "+y", "direction_x": 1.0, "direction_y": 0.0, "direction_z": 0.0},
"'Strut' on 'Mount': socket 'end_a' on parent socket 'pivot': the axis (0.0, 1.0, 0.0) of the part or the direction (1.0, 0.0, 0.0) lies along the pin")
refused("aim at no direction", "brokkr_kitbash.aim", {"object_name": "Strut", "axis": "+z", "direction_x": 0.0, "direction_y": 0.0, "direction_z": 0.0}, "The direction is zero")
refused("reach past the circle the socket turns on, naming what it reaches", "brokkr_kitbash.reach",
{"object_name": "Strut", "socket": "end_b", "height": 900.0, "direction_x": direction[0], "direction_y": direction[1], "direction_z": direction[2]},
f"no roll brings the point to 900.000000 m along ({unit[0]:.6f}".rstrip("0"))
receipt, _ = send("brokkr_kitbash.reach", object_name="Strut", socket="end_b", height=900.0, direction_x=direction[0], direction_y=direction[1], direction_z=direction[2])
check("and the range it names is the one core solves", f"it reaches {low:.6f} m to {high:.6f} m" in str(receipt["message"]) and high - low > 1.0, [receipt["message"], low, high])
skew = {"direction_x": direction[0], "direction_y": direction[1], "direction_z": direction[2]}
refused("reach a little past the top it names", "brokkr_kitbash.reach", {"object_name": "Strut", "socket": "end_b", "height": float(f"{high:.6f}") + PAST, **skew}, "no roll brings the point to")
receipt, report = send("brokkr_kitbash.reach", object_name="Strut", socket="end_b", height=float(f"{high:.6f}"), **skew)
reached = (report or {}).get("reached") or {"roll": 1e9, "residual": 1e9}
over, stands = reading("edge typed past", max(float(np.float32(f"{high:.6f}")) - high, 0.0)), reading("edge reached", abs(float(frame(strut, "end_b")[:3, 3] @ unit) - high))
check("reach to the top of the circle, typed back from the range the refusal named, is taken: the socket stands at the top", receipt["status"] == "accepted"
and reached["residual"] <= EDGE and over <= EDGE and stands < REACHED and holds(report["connection"], "Mount", "end_a", "pivot", reached["roll"]),
[receipt["message"], reached, over, stands, high])
refused("reach with the socket the part hangs by: it lies on the pin", "brokkr_kitbash.reach", {"object_name": "Strut", "socket": "end_a", "height": 0.0},
"'Strut' on 'Mount': socket 'end_a' on parent socket 'pivot': no roll moves the point along (0.0, 0.0, 1.0): it lies on the pin")
pin = np.array(mount.matrix_world, dtype=np.float64) @ socket(mount, "pivot")["matrix"]
for label, along in (("as the scene holds it", pin[:3, 2]), ("to 6 decimals", np.round(pin[:3, 2], 6)), ("to 4 decimals", np.round(pin[:3, 2], 4)), ("reversed, to 4 decimals", -np.round(pin[:3, 2], 4))):
refused(f"aim at the pin's own direction {label}", "brokkr_kitbash.aim",
{"object_name": "Strut", "axis": "+z", "direction_x": float(along[0]), "direction_y": float(along[1]), "direction_z": float(along[2])}, "lies along the pin, so no roll turns one toward the other")
refused("reach with a socket the part does not have", "brokkr_kitbash.reach", {"object_name": "Strut", "socket": "end_c", "height": 0.0},
"'Strut' has no socket 'end_c'; its sockets: end_a, end_a_back, end_b, end_b_back")
refused("reach along no direction", "brokkr_kitbash.reach", {"object_name": "Strut", "socket": "end_b", "height": 0.0, "direction_z": 0.0}, "The direction is zero")
refused("a roll past a turn, by the action table", "brokkr_kitbash.roll", {"object_name": "Strut", "roll": 361.0}, "roll")
refused("an axis that is not one of the six, by the action table", "brokkr_kitbash.aim", {"object_name": "Strut", "axis": "x", "direction_x": 1.0, "direction_y": 0.0, "direction_z": 0.0}, "axis")
# --- joint records ------------------------------------------------------------------------------------------------------
# Below the strut: a barrel on its other pin with a rod in its bore, and a bracket hung by its own pin that carries a
# second bracket rigidly, which carries a strut on its pin. Tank > Mount (rigid) > Strut > {Barrel > Rod, Hinge > Foot (rigid) > Toe, Ram}.
rows = [row["name"] for row in target.host_actions()[0] if row["name"].startswith("brokkr_kitbash.")]
check("joint, slide and joints load as host actions after reach", rows[rows.index("brokkr_kitbash.reach") + 1:][:3] == ["brokkr_kitbash.joint", "brokkr_kitbash.slide", "brokkr_kitbash.joints"], rows)
barrel, rod = place("Barrel", "ram_barrel"), place("Rod", "ram_rod")
hinge, foot, toe = place("Hinge", "bracket"), place("Foot", "bracket"), place("Toe", "strut", "width=0.09")
send("brokkr_kitbash.attach", object_name="Barrel", socket="base", parent_name="Strut", parent_socket="end_b_back", roll=25.0)
receipt, report = send("brokkr_kitbash.attach", object_name="Rod", socket="piston", parent_name="Barrel", parent_socket="bore")
send("brokkr_kitbash.attach", object_name="Hinge", socket="pivot", parent_name="Strut", parent_socket="end_a_back", roll=-15.0)
send("brokkr_kitbash.attach", object_name="Foot", socket="mount", parent_name="Hinge", parent_socket="mount", roll=90.0)
send("brokkr_kitbash.attach", object_name="Toe", socket="end_a", parent_name="Foot", parent_socket="pivot", roll=40.0)
found = report and report["connection"]
check("a rod attaches in its barrel's bore: a prismatic connection at slide 0 with no joint record, and no record key written",
receipt["status"] == "accepted" and holds(found, "Barrel", "piston", "bore", 0.0) and found == {**found, "dof": "prismatic", "slide": 0.0, "limits": None, "mechanism": None, "compliance": None, "within": True}
and sorted(k for k in rod.keys() if k.startswith("kit_")) == ["kit_kit", "kit_params", "kit_parent_socket", "kit_part", "kit_roll", "kit_slide", "kit_socket"]
and connection("Strut")["dof"] == "revolute" and connection("Mount")["dof"] is None and "kit_slide" not in strut.keys() and "kit_slide" not in mount.keys(),
[receipt["message"], found, sorted(rod.keys()), connection("Strut"), connection("Mount")])
def slid(amount):
"""How far the rod's piston stands from the point `amount` along the bore's z, and how far its normal is from opposed."""
a, b = frame(barrel, "bore"), frame(rod, "piston")
return max(float(np.linalg.norm(b[:3, 3] - a[:3, 3] - amount * a[:3, 2])), float(np.abs(a[:3, 2] + b[:3, 2]).max()))
# the record: stated by joint, kept key by key
spring = {"hertz": 4.0, "damping_ratio": 0.7}
receipt, report = send("brokkr_kitbash.joint", object_name="Rod", record=json.dumps({"limits": [0.0, 0.3], "mechanism": "shock", "compliance": spring}))
found = report and report["connection"]
check("joint states a slide's limits, mechanism and compliance, and moves nothing", receipt["status"] == "accepted" and found == {**found, "dof": "prismatic", "slide": 0.0, "limits": [0.0, 0.3],
"mechanism": "shock", "compliance": spring, "within": True, "holds": True} and (rod["kit_min"], rod["kit_max"], rod["kit_mechanism"], json.loads(rod["kit_compliance"])) == (0.0, 0.3, "shock", spring)
and reading("slid", slid(0.0)) < SEATED, [receipt["message"], found, dict(rod.items())])
receipt, report = send("brokkr_kitbash.joint", object_name="Rod", record=json.dumps({"mechanism": None}))
found = report and report["connection"]
check("a key left out keeps what is stated and null clears it", receipt["status"] == "accepted" and found == {**found, "limits": [0.0, 0.3], "mechanism": None, "compliance": spring}
and "kit_mechanism" not in rod.keys(), [receipt["message"], found])
send("brokkr_kitbash.joint", object_name="Rod", record=json.dumps({"mechanism": "shock"}))
# slide
for amount in (0.12, 0.3, 0.0, 0.12):
was, pin = stated(rod), frame(rod, "rod_end")[:3, 3].copy()
receipt, report = send("brokkr_kitbash.slide", object_name="Rod", slide=amount)
off, moved = reading("slid", slid(amount)), float(np.linalg.norm(frame(rod, "rod_end")[:3, 3] - pin))
found = report and report["connection"]
check(f"slide {amount:g} moves the rod along the bore's z where it hangs: its parent, sockets, roll and record as they were, the slide stated and seated",
receipt["status"] == "accepted" and off < SEATED and abs(rod["kit_slide"] - amount) < 1e-6 and found["holds"] is True and found["slide"] == round(rod["kit_slide"], 6)
and {k: v for k, v in stated(rod)[1].items() if k != "kit_slide"} == {k: v for k, v in was[1].items() if k != "kit_slide"} and stated(rod)[0] == "Barrel"
and abs(moved - abs(amount - was[1]["kit_slide"])) < SEATED, [receipt["message"], found, off, moved, dict(rod.items())])
receipt, report = send("brokkr_kitbash.roll", object_name="Rod", roll=90.0)
check("a roll on a prismatic connection is a build angle: it turns the rod in the bore and the slide stays", receipt["status"] == "accepted" and rod["kit_roll"] == 90.0
and abs(rod["kit_slide"] - 0.12) < 1e-6 and reading("slid", slid(0.12)) < SEATED and holds(report["connection"], "Barrel", "piston", "bore", 90.0), [receipt["message"], report and report["connection"]])
receipt, report = send("brokkr_kitbash.set_params", object_name="Barrel", params="body_len=0.5")
check("set_params of the barrel moves its bore and reseats the rod at its slide", receipt["status"] == "accepted" and reading("slid", slid(0.12)) < SEATED
and connection("Rod") == {**connection("Rod"), "holds": True, "slide": 0.12}, [receipt["message"], connection("Rod")])
refused("a slide past the joint's limits, naming value and limits", "brokkr_kitbash.slide", {"object_name": "Rod", "slide": 0.31}, "'Rod' on 'Barrel': its slide 0.31 is outside the joint's limits 0 to 0.3")
refused("a slide under them", "brokkr_kitbash.slide", {"object_name": "Rod", "slide": -0.01}, "its slide -0.01 is outside the joint's limits 0 to 0.3")
refused("a slide of a pin, naming its type", "brokkr_kitbash.slide", {"object_name": "Strut", "slide": 0.1}, "'Strut' on 'Mount': socket type 'pivot' is revolute: slide poses a prismatic connection")
refused("a slide of a rigid connection, naming its type", "brokkr_kitbash.slide", {"object_name": "Mount", "slide": 0.1}, "'Mount' on 'Tank': socket type 'mount' is rigid: slide poses a prismatic connection")
refused("a joint record on a rigid connection, naming its type", "brokkr_kitbash.joint", {"object_name": "Mount", "record": '{"limits": [0, 10]}'},
"'Mount' on 'Tank': socket type 'mount' states no dof: the connection is rigid")
refused("limits that exclude the slide the joint has", "brokkr_kitbash.joint", {"object_name": "Rod", "record": '{"limits": [0.2, 0.3]}'}, "its slide 0.12 is outside the joint's limits 0.2 to 0.3")
refused("prismatic limits past 10 m", "brokkr_kitbash.joint", {"object_name": "Rod", "record": '{"limits": [0, 11]}'}, "a prismatic joint's stand within 10 m of 0")
refused("limits cleared under a compliance", "brokkr_kitbash.joint", {"object_name": "Rod", "record": '{"limits": null}'}, "compliance needs limits")
refused("a compliance out of range", "brokkr_kitbash.joint", {"object_name": "Rod", "record": '{"compliance": {"hertz": 0, "damping_ratio": 0.7}}'}, "hertz is over 0 and at most 30")
refused("a compliance on a pin", "brokkr_kitbash.joint", {"object_name": "Strut", "record": '{"limits": [-180, 180], "compliance": {"hertz": 4, "damping_ratio": 0.7}}'},
"compliance is a prismatic joint's (a slide that settles under load): socket type 'pivot' is revolute")
refused("revolute limits spanning over a turn", "brokkr_kitbash.joint", {"object_name": "Strut", "record": '{"limits": [-200, 200]}'}, "a revolute joint's span at most 360 degrees")
refused("a revolute limit past 360", "brokkr_kitbash.joint", {"object_name": "Strut", "record": '{"limits": [300, 400]}'}, "each end within 360 of 0")
refused("a record that is not the shape", "brokkr_kitbash.joint", {"object_name": "Strut", "record": '{"limits": [10, -10]}'}, "record must be a JSON object of any of limits")
refused("a record with a key it does not have", "brokkr_kitbash.joint", {"object_name": "Strut", "record": '{"axis": [0, 0, 1]}'}, "record must be a JSON object of any of limits")
refused("a mechanism that is no label", "brokkr_kitbash.joint", {"object_name": "Strut", "record": '{"mechanism": "Knee Ram"}'}, "record must be a JSON object of any of limits")
refused("a record that is not JSON", "brokkr_kitbash.joint", {"object_name": "Strut", "record": "{limits}"}, "record must be JSON")
refused("a joint record on a part nobody attached", "brokkr_kitbash.joint", {"object_name": "Spare", "record": "{}"}, "'Spare' is not attached")
# limits on a pin: roll, aim and reach stay inside them
world, z = np.array(mount.matrix_world, dtype=np.float64), np.array([0.0, 0.0, 1.0])
pointing = lambda roll: (world @ core.mate(socket(mount, "pivot"), socket(strut, "end_a"), roll))[:3, :3] @ z # noqa: E731 where the strut's z points at a roll
send("brokkr_kitbash.roll", object_name="Strut", roll=180.0)
refused("limits that exclude the roll the joint has", "brokkr_kitbash.joint", {"object_name": "Strut", "record": '{"limits": [190, 210]}'}, "'Strut' on 'Mount': its roll 180 is outside the joint's limits 190 to 210")
receipt, report = send("brokkr_kitbash.joint", object_name="Strut", record='{"limits": [150, 210], "mechanism": "knee"}')
check("joint states a pin's limits about the roll it has", receipt["status"] == "accepted" and report["connection"] == {**report["connection"], "roll": 180.0, "limits": [150.0, 210.0], "mechanism": "knee", "within": True}
and (strut["kit_min"], strut["kit_max"]) == (150.0, 210.0) and "kit_slide" not in strut.keys(), [receipt["message"], report and report["connection"]])
refused("a roll with no turn of itself inside the limits, naming value and limits", "brokkr_kitbash.roll", {"object_name": "Strut", "roll": 100.0}, "'Strut' on 'Mount': its roll 100 is outside the joint's limits 150 to 210")
receipt, report = send("brokkr_kitbash.roll", object_name="Strut", roll=-170.0)
check("a roll a turn away from the limits is written as its representative inside them: -170 as 190", receipt["status"] == "accepted" and strut["kit_roll"] == 190.0
and holds(report["connection"], "Mount", "end_a", "pivot", 190.0) and reading("seated", seated(strut, "end_a", mount, "pivot", 190.0)) < SEATED, [receipt["message"], report and report["connection"]])
send("brokkr_kitbash.roll", object_name="Strut", roll=160.0)
d = pointing(-170.0)
receipt, report = send("brokkr_kitbash.aim", object_name="Strut", axis="+z", direction_x=float(d[0]), direction_y=float(d[1]), direction_z=float(d[2]))
aimed = (report or {}).get("aimed") or {"roll": 1e9, "dot": 1e9}
check("aim solving -170 inside limits 150..210 writes 190", receipt["status"] == "accepted" and reading("limit roll", abs(aimed["roll"] - 190.0)) < ROLL and abs(strut["kit_roll"] - 190.0) < ROLL
and reading("aimed", abs(aimed["dot"] - 1.0)) < AIMED and holds(report["connection"], "Mount", "end_a", "pivot", aimed["roll"]), [receipt["message"], aimed, strut["kit_roll"]])
for free, end in ((100.0, 150.0), (-110.0, 210.0), (127.0, 150.0)):
d = pointing(free)
receipt, report = send("brokkr_kitbash.aim", object_name="Strut", axis="+z", direction_x=float(d[0]), direction_y=float(d[1]), direction_z=float(d[2]))
aimed = (report or {}).get("aimed") or {"roll": 1e9, "dot": 1e9}
read = float(np.array(strut.matrix_world, dtype=np.float64)[:3, :3] @ z @ d)
grid = max(float(pointing(float(r)) @ d) for r in np.arange(150.0, 210.25, 0.25))
check(f"aim at where roll {free:g} points, outside the limits, takes the end that points nearer ({end:g}): no roll inside the limits passes it",
receipt["status"] == "accepted" and aimed["roll"] == end and strut["kit_roll"] == end and reading("aimed", abs(aimed["dot"] - read)) < AIMED
and reading("aimed short", max(grid - read, 0.0)) < AIMED and reading("aimed", abs(read - math.cos(math.radians(free - end)))) < AIMED, [receipt["message"], aimed, read, grid])
A, B, C = core.roll_terms(world, socket(mount, "pivot"), socket(strut, "end_a"), socket(strut, "end_b")["matrix"][:3, 3], 1.0, z)
middle, swing = math.degrees(math.atan2(B, A)), math.hypot(A, B)
near, far, height = middle - 40.0, middle + 40.0, C + math.cos(math.radians(40.0)) * swing # the two rolls that reach this height
send("brokkr_kitbash.joint", object_name="Strut", record='{"limits": null}')
send("brokkr_kitbash.roll", object_name="Strut", roll=round(near + 5.0, 3))
send("brokkr_kitbash.joint", object_name="Strut", record=json.dumps({"limits": [round(near + 2.0, 3), round(far + 10.0, 3)]}))
receipt, report = send("brokkr_kitbash.reach", object_name="Strut", socket="end_b", height=height)
reached = (report or {}).get("reached") or {"roll": 1e9, "residual": 1e9}
check("reach inside limits that hold only the farther of its two rolls takes that one", receipt["status"] == "accepted" and reading("limit roll", abs(reached["roll"] - far)) < ROLL
and reading("reached", abs(float(frame(strut, "end_b")[:3, 3] @ z) - height)) < REACHED and report["connection"]["within"] is True, [receipt["message"], reached, near, far])
send("brokkr_kitbash.roll", object_name="Strut", roll=round(near + 5.0, 3))
send("brokkr_kitbash.joint", object_name="Strut", record=json.dumps({"limits": [round(near + 2.0, 3), round(far - 2.0, 3)]}))
refused("reach with neither roll inside the limits, naming both and the limits", "brokkr_kitbash.reach", {"object_name": "Strut", "socket": "end_b", "height": height},
f"are outside the joint's limits {round(near + 2.0, 3):.6g} to {round(far - 2.0, 3):.6g}")
rod["kit_slide"] = 0.5 # by hand, past the limits: every report says so and the next pose is refused
found = connection("Rod")
check("a slide written by hand outside the limits reads within false and does not hold", found == {**found, "slide": 0.5, "within": False, "holds": False}, found)
refused("and a roll of it is refused by the limits", "brokkr_kitbash.roll", {"object_name": "Rod", "roll": 0.0}, "its slide 0.5 is outside the joint's limits 0 to 0.3")
rod["kit_slide"] = 0.12
check("put back, it holds", connection("Rod") == {**connection("Rod"), "slide": 0.12, "within": True, "holds": True}, connection("Rod"))
# --- the joints report --------------------------------------------------------------------------------------------------
send("brokkr_kitbash.joint", object_name="Hinge", record='{"limits": [-90, 20], "mechanism": "ankle"}')
receipt, joints = send("brokkr_kitbash.joints", object_name="Tank")
R["joints"] = joints
table = {row["id"]: row for row in (joints or {}).get("joints", [])}
check("joints reports the tree under the tank: schema, the root's frame, a row per DOF connection depth first with children by name, parents first, rigid ones counted",
receipt["status"] == "accepted" and {k: v for k, v in joints.items() if k != "joints"} == {"schema": "brokkr.joints", "version": 2, "root": "Tank", "frame": "the root object's: Blender axes (+Z up), metres", "rigid": 2,
"unlimited": ["Barrel", "Toe", "Ram"], "manyDrivers": [], "next": None}
and [row["id"] for row in joints["joints"]] == ["Strut", "Barrel", "Rod", "Hinge", "Toe", "Ram"], [receipt["message"], joints])
check("a joint's parent is the nearest DOF connection above it, not the object it hangs from: the toe's is the hinge, through the rigid foot; the rod's is the barrel",
{name: row["parent"] for name, row in table.items()} == {"Strut": None, "Barrel": "Strut", "Rod": "Barrel", "Hinge": "Strut", "Toe": "Hinge", "Ram": "Strut"} and toe.parent == foot,
{name: row["parent"] for name, row in table.items()})
check("each row names its part, its parent socket and its kind", {name: (row["part"], row["socket"], row["kind"]) for name, row in table.items()} == {
"Strut": ("strut", "Mount:pivot", "revolute"), "Barrel": ("ram_barrel", "Strut:end_b_back", "revolute"), "Rod": ("ram_rod", "Barrel:bore", "prismatic"),
"Hinge": ("bracket", "Strut:end_a_back", "revolute"), "Toe": ("strut", "Foot:pivot", "revolute"), "Ram": ("actuator", "Strut:end_b", "revolute")}, table)
inverse = np.linalg.inv(np.array(tank.matrix_world, dtype=np.float64))
for name, row in table.items():
owner, _, parent_socket = row["socket"].partition(":")
at = inverse @ frame(bpy.data.objects[owner], parent_socket)
reading("joint frame", max(float(np.abs(at[:3, 2] - row["axis"]).max()), float(np.abs(at[:3, 3] - row["origin"]).max())))
check("axis and origin are the parent socket's z and origin in the root's frame, read from the scene", len(table) == 6 and R["readings"]["joint frame"] < JOINT_FRAME, R["readings"])
value = strut["kit_roll"]
check("value is the roll or slide now, limits are as stated, and min and max are the limits less the value: the travel either way",
table["Rod"] == {**table["Rod"], "value": 0.12, "limits": [0.0, 0.3], "min": -0.12, "max": 0.18, "mechanism": "shock", "compliance": spring}
and table["Hinge"] == {**table["Hinge"], "value": -15.0, "limits": [-90.0, 20.0], "min": -75.0, "max": 35.0, "mechanism": "ankle", "compliance": None}
and table["Strut"] == {**table["Strut"], "value": round(value, 6), "min": round(round(near + 2.0, 3) - value, 6), "max": round(round(far - 2.0, 3) - value, 6), "mechanism": "knee"}
and table["Ram"] == {**table["Ram"], "value": -36.0, "limits": None, "min": None, "max": None, "mechanism": None, "compliance": None}, table)
receipt, below = send("brokkr_kitbash.joints", object_name="Hinge")
check("under another root the rows are in its frame and begin with the root's own joint, parent null", receipt["status"] == "accepted"
and [(row["id"], row["parent"]) for row in below["joints"]] == [("Hinge", None), ("Toe", "Hinge")] and below["rigid"] == 1 and below["unlimited"] == ["Toe"]
and float(np.abs((np.linalg.inv(np.array(hinge.matrix_world, dtype=np.float64)) @ frame(foot, "pivot"))[:3, 3] - below["joints"][1]["origin"]).max()) < JOINT_FRAME, below)
refused("joints of a mesh that is not a kit part", "brokkr_kitbash.joints", {"object_name": "Plain"}, "'Plain' is not a kit part")
# --- detach clears the record -------------------------------------------------------------------------------------------
receipt, report = send("brokkr_kitbash.detach", object_name="Rod")
check("detach leaves none of the eight connection keys", receipt["status"] == "accepted" and report["connection"] is None and rod.parent is None
and sorted(k for k in rod.keys() if k.startswith("kit_")) == ["kit_kit", "kit_params", "kit_part"], [receipt["message"], sorted(rod.keys())])
receipt, report = send("brokkr_kitbash.attach", object_name="Rod", socket="piston", parent_name="Barrel", parent_socket="bore")
check("and attached again it states no record", receipt["status"] == "accepted" and report["connection"] == {**report["connection"], "slide": 0.0, "limits": None, "mechanism": None, "compliance": None},
[receipt["message"], report and report["connection"]])
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, printed and written, not a missing result file
check(f"no uncaught error after: {R['checks'][-1]['name'] if R['checks'] else 'the start'}", False, traceback.format_exc().splitlines()[-6:])
R["ok"] = all(c["ok"] for c in R["checks"])
R["readings"] = {name: float(f"{value:.2g}") for name, value in sorted(R["readings"].items())}
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
print("READINGS", R["readings"], flush=True)
sys.exit(0 if R["ok"] else 1)

View file

@ -0,0 +1,674 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "roll, aim and reach load as host actions after detach, with no errors",
"ok": true,
"detail": null
},
{
"name": "the chain stands: tank, bracket, strut, actuator",
"ok": true,
"detail": null
},
{
"name": "a brace closes on the actuator's rod pin",
"ok": true,
"detail": null
},
{
"name": "and a second closure, named to sort first, holds far from it",
"ok": true,
"detail": null
},
{
"name": "roll 65 turns the strut where it hangs: one intent, its parent, sockets and parent inverse as they were, its roll stated and seated",
"ok": true,
"detail": null
},
{
"name": "and the actuator follows through its own connection, which nothing rewrote (roll 65)",
"ok": true,
"detail": null
},
{
"name": "roll -160 turns the strut where it hangs: one intent, its parent, sockets and parent inverse as they were, its roll stated and seated",
"ok": true,
"detail": null
},
{
"name": "and the actuator follows through its own connection, which nothing rewrote (roll -160)",
"ok": true,
"detail": null
},
{
"name": "roll 35 turns the strut where it hangs: one intent, its parent, sockets and parent inverse as they were, its roll stated and seated",
"ok": true,
"detail": null
},
{
"name": "and the actuator follows through its own connection, which nothing rewrote (roll 35)",
"ok": true,
"detail": null
},
{
"name": "the rolls above opened the brace's closure and reported it before the one that holds, whatever its name",
"ok": true,
"detail": null
},
{
"name": "rolled back to where the brace met it, the closure holds again: read from where the parts stand",
"ok": true,
"detail": null
},
{
"name": "a roll lists the closures its own part is an end of first, before a broken one elsewhere",
"ok": true,
"detail": null
},
{
"name": "and a roll of the part a closure names opens it; no roll seats or rewrites a closure",
"ok": true,
"detail": null
},
{
"name": "aim points the strut's +z at (1.0, 0.0, 0.0) as far as its pin lets it: the dot it reports is the dot the scene reads, and no roll on a 1-degree grid passes it",
"ok": true,
"detail": null
},
{
"name": "and it is stated and seated as roll's: the connection holds at the aimed roll, the actuator with it, closures reported (+z)",
"ok": true,
"detail": null
},
{
"name": "aim points the strut's -x at (0.0, -3.0, 4.0) as far as its pin lets it: the dot it reports is the dot the scene reads, and no roll on a 1-degree grid passes it",
"ok": true,
"detail": null
},
{
"name": "and it is stated and seated as roll's: the connection holds at the aimed roll, the actuator with it, closures reported (-x)",
"ok": true,
"detail": null
},
{
"name": "aim points the strut's +z at (0.2, 0.1, -2.0) as far as its pin lets it: the dot it reports is the dot the scene reads, and no roll on a 1-degree grid passes it",
"ok": true,
"detail": null
},
{
"name": "and it is stated and seated as roll's: the connection holds at the aimed roll, the actuator with it, closures reported (+z)",
"ok": true,
"detail": null
},
{
"name": "reach brings the strut's end_b to 4.23 m along (0.0, 0.0, 1.0) from roll -38, by the nearer of the two rolls that do",
"ok": true,
"detail": null
},
{
"name": "and it is stated and seated as roll's ((0.0, 0.0, 1.0), from -38)",
"ok": true,
"detail": null
},
{
"name": "reach brings the strut's end_b to 4.23 m along (0.0, 0.0, 1.0) from roll -118, by the nearer of the two rolls that do",
"ok": true,
"detail": null
},
{
"name": "and it is stated and seated as roll's ((0.0, 0.0, 1.0), from -118)",
"ok": true,
"detail": null
},
{
"name": "reach brings the strut's end_b to 0.885 m along (1.0, 2.0, -0.5) from roll 135, by the nearer of the two rolls that do",
"ok": true,
"detail": null
},
{
"name": "and it is stated and seated as roll's ((1.0, 2.0, -0.5), from 135)",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: roll of a part nobody attached",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: aim of a part nobody attached",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: reach of a part nobody attached",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: roll of a part whose parent was cleared",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: roll of a mesh that is not a kit part",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: aim of the axis along the pin",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: aim at no direction",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: reach past the circle the socket turns on, naming what it reaches",
"ok": true,
"detail": null
},
{
"name": "and the range it names is the one core solves",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: reach a little past the top it names",
"ok": true,
"detail": null
},
{
"name": "reach to the top of the circle, typed back from the range the refusal named, is taken: the socket stands at the top",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: reach with the socket the part hangs by: it lies on the pin",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: aim at the pin's own direction as the scene holds it",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: aim at the pin's own direction to 6 decimals",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: aim at the pin's own direction to 4 decimals",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: aim at the pin's own direction reversed, to 4 decimals",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: reach with a socket the part does not have",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: reach along no direction",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a roll past a turn, by the action table",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: an axis that is not one of the six, by the action table",
"ok": true,
"detail": null
},
{
"name": "joint, slide and joints load as host actions after reach",
"ok": true,
"detail": null
},
{
"name": "a rod attaches in its barrel's bore: a prismatic connection at slide 0 with no joint record, and no record key written",
"ok": true,
"detail": null
},
{
"name": "joint states a slide's limits, mechanism and compliance, and moves nothing",
"ok": true,
"detail": null
},
{
"name": "a key left out keeps what is stated and null clears it",
"ok": true,
"detail": null
},
{
"name": "slide 0.12 moves the rod along the bore's z where it hangs: its parent, sockets, roll and record as they were, the slide stated and seated",
"ok": true,
"detail": null
},
{
"name": "slide 0.3 moves the rod along the bore's z where it hangs: its parent, sockets, roll and record as they were, the slide stated and seated",
"ok": true,
"detail": null
},
{
"name": "slide 0 moves the rod along the bore's z where it hangs: its parent, sockets, roll and record as they were, the slide stated and seated",
"ok": true,
"detail": null
},
{
"name": "slide 0.12 moves the rod along the bore's z where it hangs: its parent, sockets, roll and record as they were, the slide stated and seated",
"ok": true,
"detail": null
},
{
"name": "a roll on a prismatic connection is a build angle: it turns the rod in the bore and the slide stays",
"ok": true,
"detail": null
},
{
"name": "set_params of the barrel moves its bore and reseats the rod at its slide",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a slide past the joint's limits, naming value and limits",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a slide under them",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a slide of a pin, naming its type",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a slide of a rigid connection, naming its type",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a joint record on a rigid connection, naming its type",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: limits that exclude the slide the joint has",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: prismatic limits past 10 m",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: limits cleared under a compliance",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a compliance out of range",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a compliance on a pin",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: revolute limits spanning over a turn",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a revolute limit past 360",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a record that is not the shape",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a record with a key it does not have",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a mechanism that is no label",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a record that is not JSON",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a joint record on a part nobody attached",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: limits that exclude the roll the joint has",
"ok": true,
"detail": null
},
{
"name": "joint states a pin's limits about the roll it has",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a roll with no turn of itself inside the limits, naming value and limits",
"ok": true,
"detail": null
},
{
"name": "a roll a turn away from the limits is written as its representative inside them: -170 as 190",
"ok": true,
"detail": null
},
{
"name": "aim solving -170 inside limits 150..210 writes 190",
"ok": true,
"detail": null
},
{
"name": "aim at where roll 100 points, outside the limits, takes the end that points nearer (150): no roll inside the limits passes it",
"ok": true,
"detail": null
},
{
"name": "aim at where roll -110 points, outside the limits, takes the end that points nearer (210): no roll inside the limits passes it",
"ok": true,
"detail": null
},
{
"name": "aim at where roll 127 points, outside the limits, takes the end that points nearer (150): no roll inside the limits passes it",
"ok": true,
"detail": null
},
{
"name": "reach inside limits that hold only the farther of its two rolls takes that one",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: reach with neither roll inside the limits, naming both and the limits",
"ok": true,
"detail": null
},
{
"name": "a slide written by hand outside the limits reads within false and does not hold",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: and a roll of it is refused by the limits",
"ok": true,
"detail": null
},
{
"name": "put back, it holds",
"ok": true,
"detail": null
},
{
"name": "joints reports the tree under the tank: schema, the root's frame, a row per DOF connection depth first with children by name, parents first, rigid ones counted",
"ok": true,
"detail": null
},
{
"name": "a joint's parent is the nearest DOF connection above it, not the object it hangs from: the toe's is the hinge, through the rigid foot; the rod's is the barrel",
"ok": true,
"detail": null
},
{
"name": "each row names its part, its parent socket and its kind",
"ok": true,
"detail": null
},
{
"name": "axis and origin are the parent socket's z and origin in the root's frame, read from the scene",
"ok": true,
"detail": null
},
{
"name": "value is the roll or slide now, limits are as stated, and min and max are the limits less the value: the travel either way",
"ok": true,
"detail": null
},
{
"name": "under another root the rows are in its frame and begin with the root's own joint, parent null",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: joints of a mesh that is not a kit part",
"ok": true,
"detail": null
},
{
"name": "detach leaves none of the eight connection keys",
"ok": true,
"detail": null
},
{
"name": "and attached again it states no record",
"ok": true,
"detail": null
}
],
"hostErrors": [],
"readings": {
"aimed": 3.3e-07,
"aimed short": 0.0,
"edge reached": 2.6e-08,
"edge typed past": 3.2e-07,
"joint frame": 4e-07,
"limit roll": 2e-05,
"reach other root": 74.0,
"reached": 2.4e-07,
"roll": 8.4e-06,
"seated": 1.1e-06,
"slid": 1.4e-07,
"turned": 0.55
},
"joints": {
"schema": "brokkr.joints",
"version": 2,
"root": "Tank",
"frame": "the root object's: Blender axes (+Z up), metres",
"rigid": 2,
"unlimited": [
"Barrel",
"Toe",
"Ram"
],
"manyDrivers": [],
"next": null,
"joints": [
{
"id": "Strut",
"parent": null,
"part": "strut",
"socket": "Mount:pivot",
"kind": "revolute",
"axis": [
-0.0,
1.0,
0.0
],
"origin": [
0.436,
0.0,
0.85368
],
"value": -113.019997,
"limits": [
-116.02,
-40.02
],
"min": -3.000003,
"max": 72.999997,
"held": false,
"mechanism": "knee",
"compliance": null,
"driven": null
},
{
"id": "Barrel",
"parent": "Strut",
"part": "ram_barrel",
"socket": "Strut:end_b_back",
"kind": "revolute",
"axis": [
-0.0,
1.0,
0.0
],
"origin": [
0.154833,
0.085,
1.515425
],
"value": 25.0,
"limits": null,
"min": null,
"max": null,
"held": false,
"mechanism": null,
"compliance": null,
"driven": null
},
{
"id": "Rod",
"parent": "Barrel",
"part": "ram_rod",
"socket": "Barrel:bore",
"kind": "prismatic",
"axis": [
0.034551,
-0.0,
0.999403
],
"origin": [
0.157321,
0.124,
1.587382
],
"value": 0.12,
"limits": [
0.0,
0.3
],
"min": -0.12,
"max": 0.18,
"held": false,
"mechanism": "shock",
"compliance": {
"damping_ratio": 0.7,
"hertz": 4.0
},
"driven": null
},
{
"id": "Hinge",
"parent": "Strut",
"part": "bracket",
"socket": "Strut:end_a_back",
"kind": "revolute",
"axis": [
-0.0,
1.0,
0.0
],
"origin": [
0.436,
0.085,
0.85368
],
"value": -15.0,
"limits": [
-90.0,
20.0
],
"min": -75.0,
"max": 35.0,
"held": false,
"mechanism": "ankle",
"compliance": null,
"driven": null
},
{
"id": "Toe",
"parent": "Hinge",
"part": "strut",
"socket": "Foot:pivot",
"kind": "revolute",
"axis": [
0.787796,
0.0,
0.615936
],
"origin": [
0.559187,
0.085,
0.696121
],
"value": 40.0,
"limits": null,
"min": null,
"max": null,
"held": false,
"mechanism": null,
"compliance": null,
"driven": null
},
{
"id": "Ram",
"parent": "Strut",
"part": "actuator",
"socket": "Strut:end_b",
"kind": "revolute",
"axis": [
0.0,
-1.0,
-0.0
],
"origin": [
0.154833,
-0.0,
1.515425
],
"value": -36.0,
"limits": null,
"min": null,
"max": null,
"held": false,
"mechanism": null,
"compliance": null,
"driven": null
}
]
},
"ok": true
}

View file

@ -0,0 +1,611 @@
"""Live proof, in a background Blender, of brokkr_kitbash.ribs through run_intent: ribs that stand a standoff behind a
cage's plate along the plate's own normal, however it leans, and in their planes, that follow a crease tighter than they
reach, that stop at a port, run behind a panel break and under a recess, that take their side from the cage's normals, longerons through the ribs of a cage a plane cuts twice, lightening holes through crossing
ribs, and the refusals. Not part of the unittest run: it needs Blender.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/kitbash_ribs.py -- <out>
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). <out> is an absolute path; writes <out>.result.json and exits 1 when a check failed.
Bounds follow lodur:ruling:deterministic-bound-margin: each sits at the geometric mean of the shipped worst reading
and the least claimed mutant's, both written beside it; the result file carries the readings. The checks run inside
one try: an uncaught error is a failed check that names its section, and the result file is always written.
"""
import importlib.util
import json
import math
import os
import sys
import tempfile
import traceback
import types
from pathlib import Path
import bmesh
import bpy
import numpy as np
from mathutils import Matrix, Vector
from mathutils.bvhtree import BVHTree
SURFACE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(SURFACE / "tools"))
import private_dirs # noqa: E402
_refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if _refused:
raise SystemExit(_refused)
OUT = sys.argv[sys.argv.index("--") + 1]
if not Path(OUT).is_absolute():
raise SystemExit(f"{OUT!r} is not an absolute path")
package = types.ModuleType("brokkr_bridge")
package.__path__ = [str(SURFACE / "brokkr_bridge")]
sys.modules["brokkr_bridge"] = package
from brokkr_bridge import blender_target as bt # noqa: E402
import addon_utils # noqa: E402
spec = importlib.util.spec_from_file_location("brokkr_kitbash_core_reference", SURFACE / "brokkr_kitbash" / "core.py")
core = importlib.util.module_from_spec(spec) # core as the unit tests load it
spec.loader.exec_module(core)
sys.path.append(str(SURFACE))
bpy.ops.wm.read_factory_settings(use_empty=True)
for module in ("brokkr_mesh_polish", "brokkr_kitbash"):
addon_utils.enable(module, default_set=True)
target = bt.BrokkrBlenderTarget(bpy)
WORK = Path(tempfile.mkdtemp(prefix="brokkr-kitbash-ribs-"))
target.configure_action_dirs("", str(WORK))
target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1], "readings": {}}
COUNT, SECTION = [0], ["setup"]
STANDOFF, DEPTH, THICKNESS = 0.04, 0.06, 0.014
SIZES = {"standoff": STANDOFF, "depth": DEPTH, "thickness": THICKNESS}
# Metres between the standoff and how near a rib's outer edge comes to the plate's inner face, at each point of the edge,
# on the pod: a doubly curved wall that leans up to 30 degrees out of a rib's plane. Shipped worst 7.5e-05 (the edge is
# moved in by one distance for the whole rib, what its nearest vertex was short); least claimed mutant 0.00081 (O2, the
# rib's half thickness, which a leaning plate comes nearer, left out of the edge: the measure then moves the whole rib);
# the geometric mean, separation 3.3 each side. U1 reads 0.00017 and M2 0.00013 and die at STOOD and RING; S1 0.025.
FIT = 2.5e-4
# The same on cages of flat facets, where it is exact: cones whose wall leans 0, 30, 45 and 60 degrees out of the plane, a
# cylinder whose Solidify is negative, a hipped box, a crease and a dish. Shipped worst 6.4e-08 (float32 meshes); least
# claimed mutant 0.0003 (O2 at 60 degrees); the geometric mean, separation 68 each side. U1 (every Solidify read as not
# even) reads 0.00051, V1 0.003, S1 (the plate's outer face taken for its inner) 0.032.
STOOD = 4.4e-6
# A cone's rib or a hipped box's, over the ring between the section's two offsets times the thickness, less 1. Shipped worst 2.1e-06;
# least claimed mutant 1.8e-05 (L1, a corner of two distances never mitred); the geometric mean, separation 2.9 each side.
# M2 (the edge's corners left as chords) reads 0.00047, O2 0.0017.
RING = 6.1e-6
# A rib inside a crease, over the true clipped offset's area times the thickness, less 1. Shipped 2.3e-07 (the edge's
# corner is where the offset faces meet); least claimed mutant 0.00051 (M2, a chord across it); the geometric mean,
# separation 47 each side. U2 reads 0.0014, U1 0.031, A2 (an end of the section that finds no offset surface) 0.051, X1
# (nothing left out where the offset surface folded) 0.07. tests/test_kitbash.py CREASED is core.band's own, on the same polyline.
CREASED = 1.1e-5
# Metres between the standoff and how near the rib comes to the plate where a plane tilted 64 degrees cuts a prism of 24
# flat sides. Shipped 2.1e-05 (one move for the whole rib, 0.0006 along the plane); least claimed mutant 5.5e-05 (V1, an
# offset clipped at its own distance); the geometric mean, separation 1.6 each side. U1 reads 0.00014, O2 0.00032, E1
# (the edge never measured against the plate and moved in) 0.00059, G1 0.037. Before cut-kit-ribs.h3 it read 0.007.
TILTED = 3.4e-5
# The same on spheres of radius 1 and 0.6 cut 60 degrees off their middle, standoffs 0.04 and 0.01. Shipped worst 9.7e-08;
# least claimed mutant 5.9e-07 (U2, every Solidify read as even: an icosphere's faces meet at unequal angles); the
# geometric mean, separation 2.5 each side. C1 reads 1.5e-05, U1 5.6e-05, O2 0.00016, E1 0.0014, G1 0.024. Before
# cut-kit-ribs.h3 they read 0.020, and at radius 0.6 and standoff 0.01 the rib stood 0.006 through the inner face.
ROUND = 2.4e-7
# The same on a box whose Solidify is not even (Blender's default). Shipped 8.3e-09; least claimed mutant 0.018 (U2, the
# plate read as its Solidify's thickness behind every face, as before cut-kit-ribs.h3); the geometric mean, separation
# 1500 each side. S1 reads 0.038.
UNEVEN = 1.2e-5
# Metres a rib vertex stands off its plane beyond half the rib's thickness. Shipped worst 1.4e-07 (float32 meshes);
# least claimed mutant 0.007 (KP, a rib twice as thick across its plane); separation 220 each side.
PLANAR = 3.1e-5
# Metres from the port's opening to the nearest vertex of a rib, post or hole, along the section: the least is the
# worst. Shipped 0.031 (the last sample under the plate, the clearance of 0.02 and up to a step); least claimed mutant
# 0.0011 (K6, the clearance ignored); separation 5.3 each side. K4 and K10 put vertices inside the opening: -0.12.
CLEARED = 0.0058
# Metres a longeron's station stands from its half-plane, its plane's height or the rib's mid-depth line. Shipped worst
# 5.2e-07; least claimed mutant 0.0021 (K1, a sweep with no mitre: the rib's mid-depth line stands in from where the
# facets' offsets meet); separation 64 each side. K9 (the station at the chain's first point) reads 1.2.
STATIONED = 3.3e-5
# A wedge's or a gusset's longerons' volume less a T's, over the difference of the two sections' areas along both runs,
# less 1. Shipped 1.1e-06; least claimed mutant 0.235, computed, not run (a wedge built as a gusset; the section ignored
# and a T built reads 1); separation 460 each side.
SECTIONED = 5.1e-4
# What lightening holes removed from five crossing ribs, over the holes' faceted area times the thickness, less 1.
# Shipped 2.7e-08; least claimed mutant 22 (K11, each plane's Manifold Boolean taken over all five ribs' webs, which
# cross, with the action's own check of the cut off); separation 28000 each side.
HOLED = 7.7e-4
# Metres under the plate's outer face that the nearest vertex of a frame stands: the least is the worst, and under 0 a post is
# through the plate. Shipped worst 0.0047 (the rim of a post's end on a cone leaning 60 degrees whose wall is 0.02); least
# claimed mutant 0.0015 (P2, every post started a tenth of the plate under its outer face); the geometric mean,
# separation 1.8 each side. P3 (a leaning post not started deeper) reads 0.00013; S1 and G1 put vertices outside: -0.01.
SUNK = 0.0027
def check(name, ok, detail=None):
R["checks"].append({"name": name, "ok": bool(ok), "detail": None if ok else detail})
def reading(name, value, least=False):
"""The worst of a metric: the largest, or with `least` the smallest."""
R["readings"][name] = (min if least else max)(R["readings"].get(name, float(value)), float(value))
return float(value)
def section(name):
SECTION[0] = name
def send(action, **fields):
COUNT[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"live-{COUNT[0]}", "requestedBy": "test/driver", "action": action, **fields})
result = None
if receipt.get("hostResult"):
try:
result = json.loads(receipt["hostResult"])
except ValueError:
result = None
print("SEND", action, receipt["status"], str(receipt["message"])[:300], flush=True)
return receipt, result
def scene_state():
return {o.name: (o.parent and o.parent.name, np.round(np.array(o.matrix_basis), 6).tolist(), {k: repr(o[k]) for k in sorted(o.keys()) if k.startswith("kit_")},
[(m.name, m.type, m.show_viewport) for m in o.modifiers], o.data.name if o.type == "MESH" else None, len(o.data.polygons) if o.type == "MESH" else None)
for o in bpy.data.objects}, sorted(m.name for m in bpy.data.meshes), sorted(c.name for c in bpy.data.collections)
def refused(label, fields, expected):
state = scene_state()
receipt, _ = send("brokkr_kitbash.ribs", **fields)
check(f"refused, scene unchanged: {label}", receipt["status"] != "accepted" and expected in str(receipt["message"]) and scene_state() == state,
[receipt["status"], receipt["message"]])
def mesh_object(name, vertices, faces, world=None, wall=None, levels=0):
"""A mesh object from points and faces, normals as the faces are wound, optionally subdivided and given a wall inward."""
made = bpy.data.objects.new(name, bpy.data.meshes.new(name))
made.data.from_pydata(vertices, [], faces)
bpy.context.scene.collection.objects.link(made)
if levels:
made.modifiers.new("Subsurf", "SUBSURF").levels = levels
if wall:
solid = made.modifiers.new("Solidify", "SOLIDIFY")
solid.thickness, solid.offset, solid.use_even_offset = wall, -1.0, True
if world is not None:
made.matrix_world = world
bpy.context.view_layer.update()
return made
def tree(obj, off=()):
"""This script's own BVH of an object evaluated with the modifiers of the named types off, in its own frame."""
hidden = [m for m in obj.modifiers if m.type in off and m.show_viewport]
for m in hidden:
m.show_viewport = False
try:
return BVHTree.FromObject(obj, bpy.context.evaluated_depsgraph_get())
finally:
for m in hidden:
m.show_viewport = True
def points(obj):
V = np.zeros(3 * len(obj.data.vertices))
obj.data.vertices.foreach_get("co", V)
return V.reshape(-1, 3)
def measure(mesh):
bm = bmesh.new()
bm.from_mesh(mesh)
row = {"faces": len(bm.faces), "volume": bm.calc_volume(signed=True), "nonManifoldEdges": sum(1 for e in bm.edges if not e.is_manifold),
"shells": len({min(v.index for v in island) for island in islands(bm)})}
bm.free()
return row
def islands(bm):
seen, found = set(), []
for start in bm.verts:
if start in seen:
continue
island, stack = [], [start]
seen.add(start)
while stack:
v = stack.pop()
island.append(v)
for e in v.link_edges:
other = e.other_vert(v)
if other not in seen:
seen.add(other)
stack.append(other)
found.append(island)
return found
def nearest_by_column(surface, V):
"""The least distance from a BVH to the vertices that share an x and y (to 1e-5), for each such column."""
found = {}
for v in V:
key = (round(float(v[0]), 5), round(float(v[1]), 5))
found[key] = min(found.get(key, 1.0), surface.find_nearest(Vector(v))[3])
return found
def child_of(ribs, cage):
return ribs is not None and ribs.parent == cage and np.array_equal(np.array(ribs.matrix_parent_inverse), np.eye(4)) and np.array_equal(np.array(ribs.matrix_basis), np.eye(4)) \
and np.abs(np.array(ribs.matrix_world) - np.array(cage.matrix_world)).max() < 1e-6 and len(ribs.modifiers) == 0 and len(ribs.data.materials) == 0
def flat(z_planes):
return json.dumps([{"origin": [0.0, 0.0, z], "normal": [0.0, 0.0, 1.0]} for z in z_planes])
try:
# --- a pod: a closed loft of 6 rings of 8, subdivided, with a wall, a port, a panel break and a recess --------------------
section("a pod")
def ring(w, d, z, n=8, p=3.0):
return [(0.5 * w * math.copysign(abs(math.cos(a)) ** (2 / p), math.cos(a)), 0.5 * d * math.copysign(abs(math.sin(a)) ** (2 / p), math.sin(a)), z)
for a in (2 * math.pi * (k + 0.5) / n for k in range(n))]
rings = [ring(w, d, z) for z, w, d in ((0, .6, .5), (.3, 1.0, .8), (.7, 1.2, .95), (1.1, 1.1, .9), (1.4, .8, .6), (1.6, .4, .3))]
pod = mesh_object("Pod", [p for r in rings for p in r], [(i * 8 + j, i * 8 + (j + 1) % 8, (i + 1) * 8 + (j + 1) % 8, (i + 1) * 8 + j) for i in range(5) for j in range(8)],
Matrix.Translation((4.0, -1.0, 2.0)) @ Matrix.Rotation(0.6, 4, "Z") @ Matrix.Rotation(-0.3, 4, "X"), wall=0.06, levels=3)
CUTS = [{"name": "Port", "part": "box", "params": "width=0.25; height=0.2; depth=0.2", "origin": [2, 0, 0.7], "direction": [-1, 0, 0]},
{"name": "Seam", "part": "slab", "params": "gap=0.02; length=0.6; depth=0.2", "origin": [-2, 0, 0.7], "direction": [1, 0, 0]},
{"name": "Recess", "part": "box", "params": "width=0.2; height=0.15; depth=0.03", "origin": [0, 2, 0.7], "direction": [0, -1, 0]}]
receipt, _ = send("brokkr_kitbash.cut_many", object_name="Pod", cuts=json.dumps(CUTS))
check("the pod is cut by a port, a panel break and a recess", receipt["status"] == "accepted", receipt["message"])
HEIGHTS = (0.3, 0.5, 0.7, 0.9, 1.15)
designed = tree(pod, ("SOLIDIFY", "BEVEL", "BOOLEAN")) # the surface as designed
cuts = [m for m in pod.modifiers if m.type == "BOOLEAN"]
for m in cuts:
m.show_viewport = False
wall = pod.evaluated_get(bpy.context.evaluated_depsgraph_get()).to_mesh() # the wall before it is cut; its inner face is the faces that stand off the designed surface
inner = BVHTree.FromPolygons([v.co.copy() for v in wall.vertices], [tuple(p.vertices) for p in wall.polygons if designed.find_nearest(p.center)[3] > 0.045])
for m in cuts:
m.show_viewport = True
bpy.context.view_layer.update()
# --- ribs-fit-the-plate ----------------------------------------------------------------------------------------------------
section("ribs-fit-the-plate")
request = {"object_name": "Pod", "ribs_name": "Fit", "planes": flat(HEIGHTS), **SIZES}
receipt, report = send("brokkr_kitbash.ribs", **request)
fit = bpy.data.objects.get("Fit")
stored = json.loads(fit["kit_ribs"]) if fit is not None and "kit_ribs" in fit else {}
check("ribs makes one mesh object under the cage: a child under identity matrices, no modifier, no material, and kit_ribs the request", receipt["status"] == "accepted"
and child_of(fit, pod) and stored.get("planes") == json.loads(request["planes"]) and stored.get("object_name") == "Pod"
and all(abs(stored[k] - v) < 1e-7 for k, v in SIZES.items()) and sorted(stored) == sorted(
["object_name", "planes", "standoff", "depth", "thickness", "step", "holes", "posts", "post_r", "bridge", "clearance", "longerons", "longeron", "longeron_w", "longeron_h", "longeron_t"]),
[receipt["message"], stored])
shape = measure(fit.data)
check("ribs reports the frame: one rib a plane, the plate's thickness read from the Solidify, the port's plane open along it, closed shells",
report and sorted(report) == ["faces", "holes", "longerons", "nonManifoldEdges", "object", "posts", "ribs", "sections", "thickness", "volume"]
and (report["object"], report["ribs"], report["thickness"], report["posts"], report["holes"], report["longerons"], report["nonManifoldEdges"]) == ("Fit", 5, 0.06, 0, 0, [], 0)
and [(s["plane"], s["chains"], s["pieces"]) for s in report["sections"]] == [(k, 1, 1) for k in range(5)]
and [s["open"] > 0.25 for s in report["sections"]] == [False, False, True, False, False] and all(s["open"] == 0.0 for k, s in enumerate(report["sections"]) if k != 2)
and (shape["faces"], shape["nonManifoldEdges"], shape["shells"]) == (report["faces"], 0, 5) and abs(shape["volume"] - report["volume"]) < 1e-8
and 0.5 < report["volume"] / (sum(s["length"] for s in report["sections"]) * DEPTH * THICKNESS) < 1.0, report) # a rib inside a curve is shorter than the section it follows
behind, V = True, points(fit)
for v in V:
plane = min(HEIGHTS, key=lambda z: abs(v[2] - z))
reading("planar", abs(abs(v[2] - plane) - THICKNESS / 2))
on, normal, _, _ = designed.find_nearest(Vector((v[0], v[1], plane)))
behind = behind and (Vector((v[0], v[1], plane)) - on).dot(normal) < 0
for least in nearest_by_column(inner, V).values(): # a column: the vertices of one point of an edge, half a thickness either side of the plane
if least < STANDOFF + 0.4 * DEPTH: # the outer edge's; the inner edge's stand a depth further in
reading("fit", abs(least - STANDOFF))
check("ribs-fit-the-plate: at every point of a rib's outer edge the nearer vertex stands the standoff behind the plate's inner face, along the plate's normal; every vertex in its plane, on the side the normals face away from",
behind and R["readings"]["fit"] < FIT and R["readings"]["planar"] < PLANAR, R["readings"])
# --- standoff-oblique-sections: cones, a negative Solidify, and a crease ----------------------------------------------------------
section("ribs-on-leaning-plates")
SIDES = 24
def frustum(name, lean, at):
"""A cone's wall from z = 0.3 to 0.7 that leans `lean` degrees from its axis, radius 0.6 at z = 0.5, normals outward, a wall of 0.06 inward."""
rows = [[((0.6 + (z - 0.5) * math.tan(math.radians(lean))) * math.cos(a), (0.6 + (z - 0.5) * math.tan(math.radians(lean))) * math.sin(a), z)
for a in (2 * math.pi * (k + 0.5) / SIDES for k in range(SIDES))] for z in (0.3, 0.7)]
return mesh_object(name, rows[0] + rows[1], [(k, (k + 1) % SIDES, SIDES + (k + 1) % SIDES, SIDES + k) for k in range(SIDES)], Matrix.Translation(at), wall=0.06)
def stood(cage, ribs, standoff=STANDOFF, name="stood"):
"""How near the ribs come to the cage's plate as it is evaluated, less the standoff."""
plate = tree(cage)
return reading(name, abs(min(plate.find_nearest(Vector(v))[3] for v in points(ribs)) - standoff))
def under(cage, ribs):
"""How far under the cage's outer face (its designed surface: every wall here grows inward) the frame's nearest vertex stands: under 0, a vertex is outside the plate."""
outer, worst = tree(cage, ("SOLIDIFY", "BEVEL", "BOOLEAN")), 1.0
for v in points(ribs):
on, normal, _, _ = outer.find_nearest(Vector(v))
worst = min(worst, -(Vector(v) - on).dot(normal))
return reading("sunk", worst, least=True)
leaned = []
for k, lean in enumerate((0, 30, 45, 60)):
cone = frustum(f"Cone{lean}", lean, (3.0 * k, 9.0, 0.0))
receipt, report = send("brokkr_kitbash.ribs", object_name=cone.name, ribs_name=f"ConeRibs{lean}", planes=flat([0.5]), **SIZES)
ribs = bpy.data.objects.get(f"ConeRibs{lean}")
slope = math.tan(math.radians(lean)) * math.cos(math.pi / SIDES) # of a facet: the cone's own lean is its corners'
back = (0.06 + STANDOFF) * math.hypot(1.0, slope) + THICKNESS / 2 * slope # along the plane, to the rib's outer edge
outer = 0.6 * math.cos(math.pi / SIDES) - back # the inradius of the rib's outer edge, a regular polygon
ring = SIDES * math.tan(math.pi / SIDES) * (outer ** 2 - (outer - DEPTH) ** 2) * THICKNESS
readings = (stood(cone, ribs), reading("ring", abs(measure(ribs.data)["volume"] / ring - 1.0))) if ribs is not None else (1.0, 1.0)
leaned.append(receipt["status"] == "accepted" and child_of(ribs, cone) and (report["ribs"], report["thickness"], report["nonManifoldEdges"]) == (1, 0.06, 0)
and readings[0] < STOOD and readings[1] < RING)
check("standoff-oblique-sections: on cones whose wall leans 0, 30, 45 and 60 degrees out of the rib's plane the rib comes the standoff from the plate's inner face and no nearer, and is the ring between the section's offsets",
leaned == [True] * 4, [leaned, R["readings"]])
# A hipped box: walls that lean 45 and 20 degrees meet at its four corners. No Solidify: Blender's even thickness is not even where a
# vertex's faces meet at unequal angles (a wall of 0.06 here is 0.057 and 0.066 thick), and this check is of the rib, against a plate that is exact.
hip = mesh_object("Hip", [(sx * (0.6 + (z - 0.5) * math.tan(math.radians(45))), sy * (0.5 + (z - 0.5) * math.tan(math.radians(20))), z) for z in (0.3, 0.7) for sx, sy in ((1, -1), (1, 1), (-1, 1), (-1, -1))],
[(k, (k + 1) % 4, 4 + (k + 1) % 4, 4 + k) for k in range(4)], Matrix.Translation((15.0, 9.0, 0.0)))
receipt, report = send("brokkr_kitbash.ribs", object_name="Hip", ribs_name="HipRibs", planes=flat([0.5]), **SIZES)
ribs = bpy.data.objects.get("HipRibs")
wide, deep = (0.6 - STANDOFF * math.hypot(1.0, math.tan(math.radians(lean))) - THICKNESS / 2 * math.tan(math.radians(lean)) for lean in (45, 20)) # the rib's outer edge, from the middle
ring = 4.0 * (wide * (deep - 0.1) - (wide - DEPTH) * (deep - 0.1 - DEPTH)) * THICKNESS
check("where walls that lean 45 and 20 degrees meet, the rib stands the standoff off each wall right into the corner: its edges are each wall's own, met in a mitre (mutant V1 runs one wall's edge into the other's standoff)",
receipt["status"] == "accepted" and (report["ribs"], report["thickness"], report["nonManifoldEdges"]) == (1, 0.0, 0) and stood(hip, ribs) < STOOD
and reading("ring", abs(measure(ribs.data)["volume"] / ring - 1.0)) < RING, [receipt["message"], report, R["readings"]])
turned = frustum("Turned", 0, (12.0, 9.0, 0.0))
turned.modifiers["Solidify"].thickness = -0.06 # the plate grows outward of the designed surface
bpy.context.view_layer.update()
grown = max(math.hypot(v.co.x, v.co.y) for v in turned.evaluated_get(bpy.context.evaluated_depsgraph_get()).data.vertices)
receipt, report = send("brokkr_kitbash.ribs", object_name="Turned", ribs_name="TurnedRibs", planes=flat([0.5]), **SIZES)
check("negative-solidify-thickness: a wall of -0.06 grows outward, and the rib stands the standoff inside the designed surface, the plate's inner face",
receipt["status"] == "accepted" and grown > 0.65 and report["thickness"] == 0.06 and stood(turned, bpy.data.objects["TurnedRibs"]) < STOOD, [receipt["message"], report, grown, R["readings"]])
turn, facet, run = math.radians(49.4), 0.062, 0.3 # tests/test_kitbash.py test_a_band_follows_a_crease_tighter_than_it_reaches: the same section, in x and z
profile = [(-facet / 2 - run * math.cos(turn), -run * math.sin(turn)), (-facet / 2, 0.0), (facet / 2, 0.0), (facet / 2 + run * math.cos(turn), -run * math.sin(turn))]
creased = mesh_object("Creased", [(x, y, z) for y in (-0.3, 0.3) for x, z in profile], [(k, k + 1, k + 5, k + 4) for k in range(3)], Matrix.Translation((0.0, 12.0, 0.0)), wall=0.06)
CREASE = {"object_name": "Creased", "planes": json.dumps([{"origin": [0.0, 0.0, 0.0], "normal": [0.0, 1.0, 0.0]}]), "standoff": 0.03, "depth": 0.08, "thickness": THICKNESS}
receipt, report = send("brokkr_kitbash.ribs", ribs_name="CreaseRibs", **CREASE)
ribs = bpy.data.objects.get("CreaseRibs")
near, far, apex = 0.06 + 0.03, 0.06 + 0.03 + 0.08, facet / 2 / math.cos(turn)
area = 2.0 * ((run + apex) * (far - near) - math.tan(turn) * (far ** 2 - near ** 2) / 2.0)
V = points(ribs) if ribs is not None else np.zeros((1, 3))
off = core.away(V * (1.0, 0.0, 1.0), [(x, 0.0, z) for x, z in profile], False)
check("ribs-fold-at-crease: behind a crease of 49.4 degrees either side of a facet of 0.062 a rib of standoff 0.03 and depth 0.08 is made, clipped: one closed shell the area of the true offset, no vertex nearer the section than the rib starts or further than it reaches",
receipt["status"] == "accepted" and child_of(ribs, creased) and (report["ribs"], report["nonManifoldEdges"], report["sections"][0]["pieces"]) == (1, 0, 1)
and reading("creased", abs(measure(ribs.data)["volume"] / THICKNESS / area - 1.0)) < CREASED and stood(creased, ribs, 0.03) < STOOD
and float(off.min()) > near - 1e-6 and float(off.max()) < far + 1e-6, [receipt["message"], report, off.min(), off.max(), R["readings"]])
receipt, report = send("brokkr_kitbash.ribs", ribs_name="CreaseFrame", **CREASE, holes=0.1, posts=0.05)
_, shallow = send("brokkr_kitbash.ribs", ribs_name="CreaseShallow", **{**CREASE, "depth": 0.02}, posts=0.05)
check("a post behind the crease's facet that would end outside a shallow rib, short of where the rib's edges meet, is left out: ten of the thirteen stations (mutant P1 posts eleven)",
shallow is not None and (shallow["posts"], shallow["nonManifoldEdges"]) == (10, 0), shallow)
check("the creased rib takes holes along its clipped centre line, cut clean, and posts", receipt["status"] == "accepted" and (report["holes"], report["posts"], report["nonManifoldEdges"]) == (3, 11, 0),
[receipt["message"], report]) # the centre line is 0.3 + 0.048 - 0.13 tan 49.4 = 0.196 a run: 0.39 holds three holes 0.1 apart; the section, 0.662, thirteen post stations, one each side of the facet clipped
angle = mesh_object("Angle", [(x, y, z) for y in (-0.3, 0.3) for x, z in ((-0.4, 0.0), (0.0, 0.0), (0.0, -0.4))], [(0, 1, 4, 3), (1, 2, 5, 4)], Matrix.Translation((3.0, 12.0, 0.0)), wall=0.05)
receipt, report = send("brokkr_kitbash.ribs", object_name="Angle", ribs_name="AngleRibs", planes=CREASE["planes"], **SIZES, posts=0.05)
check("inside a right angle no post stands nearer the corner than the rib's outer edge is set back, 0.09: twelve of the sixteen stations (mutant P1 posts all sixteen, four through the other wall)",
receipt["status"] == "accepted" and (report["ribs"], report["posts"], report["nonManifoldEdges"]) == (1, 12, 0) and abs(report["sections"][0]["length"] - 0.8) < 1e-6, [receipt["message"], report])
# --- standoff-curved-and-tilted: the standoff where the plate's lean changes across the rib's reach --------------------------------
section("standoff-curved-and-tilted")
prism = mesh_object("Prism", [(0.6 * math.cos(a), 0.6 * math.sin(a), z) for z in (-1.0, 2.0) for a in (2 * math.pi * (k + 0.5) / SIDES for k in range(SIDES))],
[(k, (k + 1) % SIDES, SIDES + (k + 1) % SIDES, SIDES + k) for k in range(SIDES)], Matrix.Translation((18.0, 9.0, 0.0)), wall=0.06)
receipt, report = send("brokkr_kitbash.ribs", object_name="Prism", ribs_name="PrismRibs", planes=json.dumps([{"origin": [0.0, 0.0, 0.5], "normal": [0.0, 0.9, 0.436]}]), **SIZES)
ribs = bpy.data.objects.get("PrismRibs")
check("a plane tilted 64 degrees through a prism of 24 flat sides: every facet leans differently out of the plane, and the rib stands the standoff off each (the finding: 0.007 short)",
receipt["status"] == "accepted" and (report["ribs"], report["nonManifoldEdges"]) == (1, 0) and stood(prism, ribs, STANDOFF, "tilted") < TILTED, [receipt["message"], report, R["readings"]])
def ball(name, radius, at):
made = bmesh.new()
bmesh.ops.create_icosphere(made, subdivisions=5, radius=radius)
vertices, faces = [tuple(v.co) for v in made.verts], [tuple(v.index for v in f.verts) for f in made.faces]
made.free()
return mesh_object(name, vertices, faces, Matrix.Translation(at), wall=0.06)
rounds = []
for k, (radius, standoff, depth) in enumerate(((1.0, 0.04, 0.06), (1.0, 0.01, 0.06), (0.6, 0.01, 0.03))):
sphere = ball(f"Ball{k}", radius, (3.0 * k, 18.0, 0.0))
ROUND_RIB = {"object_name": sphere.name, "planes": flat([radius * math.sin(math.radians(60))]), "standoff": standoff, "depth": depth, "thickness": THICKNESS}
receipt, report = send("brokkr_kitbash.ribs", ribs_name=f"BallRibs{k}", **ROUND_RIB)
_, posted = send("brokkr_kitbash.ribs", ribs_name=f"BallPosts{k}", **ROUND_RIB, posts=0.2)
ribs, frame = bpy.data.objects.get(f"BallRibs{k}"), bpy.data.objects.get(f"BallPosts{k}")
rounds.append(receipt["status"] == "accepted" and (report["ribs"], report["nonManifoldEdges"]) == (1, 0) and stood(sphere, ribs, standoff, "round") < ROUND
and posted is not None and posted["posts"] > 3 and under(sphere, frame) > SUNK)
check("spheres of radius 1 and 0.6 cut 60 degrees off the middle, standoffs 0.04 and 0.01: a wall curved both ways, leaning 60 degrees, and the rib and its posts stand the standoff off it "
"(the finding: 0.020 short, and at radius 0.6 and standoff 0.01 through the inner face)", rounds == [True] * 3, [rounds, R["readings"]])
ball("Ball3", 0.6, (9.0, 18.0, 0.0))
refused("at radius 0.6 a standoff of 0.04 has no rib in that plane: 0.1 inside the wall the sphere is 0.5, and the plane passes 0.52 from its middle",
{"object_name": "Ball3", "ribs_name": "BallRibs3", "planes": flat([0.6 * math.sin(math.radians(60))]), "standoff": 0.04, "depth": 0.03, "thickness": THICKNESS}, "planes[0]: the section leaves a rib no room")
tight = ball("Tight", 0.15, (15.0, 18.0, 0.0))
refused("a standoff greater than the plate's inner radius: the offset surface has passed through itself everywhere", {"object_name": "Tight", "ribs_name": "TightRibs", "planes": flat([0.0]), "standoff": 0.12,
"depth": 0.02, "thickness": THICKNESS}, "planes[0]: the section leaves a rib no room")
plain = mesh_object("Plain", [(sx * 0.5, sy * 0.5, z) for z in (0.3, 0.7) for sx, sy in ((1, -1), (1, 1), (-1, 1), (-1, -1))], [(k, (k + 1) % 4, 4 + (k + 1) % 4, 4 + k) for k in range(4)],
Matrix.Translation((21.0, 9.0, 0.0)), wall=0.06)
plain.modifiers["Solidify"].use_even_offset = False # Blender's default: each vertex 0.06 along its own normal, so the plate is 0.0424 thick beside a right angle
bpy.context.view_layer.update()
receipt, report = send("brokkr_kitbash.ribs", object_name="Plain", ribs_name="PlainRibs", planes=flat([0.5]), **SIZES)
check("solidify-default-unbounded: a box whose Solidify is not even is 0.0424 thick, not its 0.06, and the rib stands the standoff off the inner face it has (read as 0.06: 0.0176 over)",
receipt["status"] == "accepted" and report["thickness"] == 0.06 and stood(plain, bpy.data.objects["PlainRibs"], STANDOFF, "uneven") < UNEVEN, [receipt["message"], report, R["readings"]])
late = frustum("Late", 30, (27.0, 9.0, 0.0))
late.modifiers.new("Subsurf", "SUBSURF").levels = 2 # after the Solidify: the plate is the wall subdivided, and its faces are not the surface's vertices twice
bpy.context.view_layer.update()
receipt, report = send("brokkr_kitbash.ribs", object_name="Late", ribs_name="LateRibs", planes=flat([0.5]), **SIZES)
check("a cage subdivided after its Solidify is taken as that thick behind every face: a rib, clear of the plate",
receipt["status"] == "accepted" and (report["ribs"], report["thickness"], report["nonManifoldEdges"]) == (1, 0.06, 0)
and min(tree(late).find_nearest(Vector(v))[3] for v in points(bpy.data.objects["LateRibs"])) > 0.5 * STANDOFF, [receipt["message"], report])
# --- plate-window-unpinned: how deep the ray that asks "is the plate here" looks ---------------------------------------------------
section("the-plate-window")
sunk = mesh_object("Sunk", [(-0.5, -0.2, 0.0), (0.5, -0.2, 0.0), (0.5, 0.2, 0.0), (-0.5, 0.2, 0.0)], [(0, 1, 2, 3)], Matrix.Translation((0.0, 15.0, 0.0)), wall=0.05)
send("brokkr_kitbash.cut_many", object_name="Sunk", cuts=json.dumps([{"name": "Deep", "part": "box", "params": "width=0.15; height=0.15; depth=0.04", "origin": [0.0, 0.0, 2.0],
"direction": [0.0, 0.0, -1.0], "up": [0.0, 1.0, 0.0]}]))
receipt, report = send("brokkr_kitbash.ribs", object_name="Sunk", ribs_name="SunkRibs", planes=json.dumps([{"origin": [0.0, 0.0, 0.0], "normal": [0.0, 1.0, 0.0]}]), **SIZES)
check("a recess 0.8 of the plate deep is plate: the rib runs on under it (the ray looks 1.25 of the plate deep; mutant N5 looks 0.5)",
receipt["status"] == "accepted" and [(s["pieces"], s["open"]) for s in report["sections"]] == [(1, 0.0)] and abs(report["sections"][0]["length"] - 1.0) < 1e-6, [receipt["message"], report])
tube = [(0.09 * math.cos(a), 0.09 * math.sin(a), z) for z in (0.0, 0.6) for a in (2 * math.pi * (k + 0.5) / 16 for k in range(16))]
narrow = mesh_object("Narrow", tube, [(k, (k + 1) % 16, 16 + (k + 1) % 16, 16 + k) for k in range(16)], Matrix.Translation((3.0, 15.0, 0.0)), wall=0.04)
send("brokkr_kitbash.cut_many", object_name="Narrow", cuts=json.dumps([{"name": "Slot", "part": "box", "params": "width=0.06; height=0.2; depth=0.07", "origin": [2.0, 0.0, 0.3], "direction": [-1.0, 0.0, 0.0]}]))
receipt, report = send("brokkr_kitbash.ribs", object_name="Narrow", ribs_name="NarrowRibs", planes=flat([0.3]), standoff=0.005, depth=0.015, thickness=THICKNESS)
check("a port in a narrow cage is open though the far wall stands 3.5 plates behind it: the rib stops either side (mutant N13 looks 5 plates deep and finds the far wall)",
receipt["status"] == "accepted" and [(s["chains"], s["pieces"]) for s in report["sections"]] == [(1, 1)] and 0.06 < report["sections"][0]["open"] < 0.06 + 4 * 0.02 + 2 * 0.01,
[receipt["message"], report])
# --- ribs-stop-at-ports: a flat deck with a port, a panel break and a recess along one section ----------------------------------
section("ribs-stop-at-ports")
deck = mesh_object("Deck", [(-0.8, -0.5, 0.0), (0.8, -0.5, 0.0), (0.8, 0.5, 0.0), (-0.8, 0.5, 0.0)], [(0, 1, 2, 3)], Matrix.Translation((0.0, 5.0, 0.0)) @ Matrix.Rotation(0.4, 4, "Y"), wall=0.05)
DOWN = {"direction": [0.0, 0.0, -1.0], "up": [0.0, 1.0, 0.0]}
DECK_CUTS = [{**DOWN, "name": "DeckPort", "part": "box", "params": "width=0.25; height=0.2; depth=0.2", "origin": [-0.3, 0.0, 2.0]},
{**DOWN, "name": "DeckSeam", "part": "slab", "params": "gap=0.02; length=0.6; depth=0.2", "origin": [0.3, 0.0, 2.0]},
{**DOWN, "name": "DeckRecess", "part": "box", "params": "width=0.15; height=0.15; depth=0.02", "origin": [0.6, 0.0, 2.0]}]
send("brokkr_kitbash.cut_many", object_name="Deck", cuts=json.dumps(DECK_CUTS))
ALONG = json.dumps([{"origin": [0.0, 0.0, 0.0], "normal": [0.0, 1.0, 0.0]}, {"origin": [0.0, 0.25, 0.0], "normal": [0.0, 1.0, 0.0]}]) # through all three cuts; through the break alone
receipt, report = send("brokkr_kitbash.ribs", object_name="Deck", ribs_name="DeckRibs", planes=ALONG, **SIZES, posts=0.2, holes=0.1)
ribs = bpy.data.objects.get("DeckRibs")
V = points(ribs) if ribs is not None else np.zeros((1, 3))
first = V[np.abs(V[:, 1]) < 0.1] # the section through the port: everything the frame put there, ribs, posts and holes
for x in first[:, 0]:
reading("cleared", abs(x + 0.3) - 0.125, least=True)
lengths = [s["length"] for s in report["sections"]] if report else []
check("ribs-stop-at-ports: no rib, post or hole stands within the clearance of the port; behind the panel break the rib is one piece; under the recess it runs on",
receipt["status"] == "accepted" and child_of(ribs, deck) and [(s["chains"], s["pieces"]) for s in report["sections"]] == [(1, 2), (1, 1)]
and CLEARED < R["readings"]["cleared"] < 0.02 + 2 * 0.01 and 0.25 + 2 * 0.02 < 1.6 - lengths[0] < 0.25 + 4 * 0.02 and abs(lengths[1] - 1.6) < 1e-6
and report["sections"][1]["open"] == 0.0 and abs(report["sections"][0]["open"] - (1.6 - lengths[0])) < 1e-5 and first[:, 0].max() > 0.79 and first[:, 0].min() < -0.79
and (report["posts"], report["holes"], report["nonManifoldEdges"]) == (1 + 4 + 8, 3 + 9 + 16, 0) # runs of 0.34, 0.94 and 1.6: a post every 0.2 and a hole every 0.1, half a pitch from each end
and abs(float(V[:, 2].max()) + 0.025) < 1e-6 and abs(float(V[:, 2].min()) + 0.05 + STANDOFF + DEPTH) < 1e-6, [receipt["message"], report, R["readings"]]) # a post starts mid-plate; the ribs end 0.15 down
seam_free = send("brokkr_kitbash.ribs", object_name="Deck", ribs_name="DeckSplit", planes=ALONG, **SIZES, bridge=0.0)[1]
check("with no bridge the panel break splits both ribs", seam_free and [s["pieces"] for s in seam_free["sections"]] == [3, 2], seam_free)
# --- ribs-from-normals: a dish whose normals face its hollow side ------------------------------------------------------------
section("ribs-from-normals")
ARC = [math.radians(a) for a in range(-40, 41, 10)]
dish_points = [(math.sin(a), y, 1.0 - math.cos(a)) for y in (-0.3, 0.3) for a in ARC] # a trough of radius 1 about the line x = 0, z = 1; its hollow side is up
dish = mesh_object("Dish", dish_points, [(k, k + 1, k + 10, k + 9) for k in range(8)])
up_facing = all(p.normal.z > 0 for p in dish.data.polygons)
receipt, report = send("brokkr_kitbash.ribs", object_name="Dish", ribs_name="DishRibs", planes=json.dumps([{"origin": [0.0, 0.0, 0.0], "normal": [0.0, 1.0, 0.0]}]), **SIZES)
ribs = bpy.data.objects.get("DishRibs")
from_axis = np.hypot(points(ribs)[:, 0], points(ribs)[:, 2] - 1.0) if ribs is not None else np.zeros(1)
check("ribs-from-normals: a dish whose normals face its hollow side gets its rib on the other, the round side, though its section's middle lies in the hollow; a cage with no Solidify has a plate of no thickness",
receipt["status"] == "accepted" and up_facing and report["thickness"] == 0.0 and report["ribs"] == 1 and report["sections"][0]["open"] == 0.0
and stood(dish, ribs) < STOOD and float(from_axis.min()) > 1.0 and float(from_axis.max()) > 1.0 + STANDOFF + DEPTH - 1e-6, [receipt["message"], report, from_axis.min(), from_axis.max(), R["readings"]])
for polygon in list(dish.data.polygons)[:4]:
polygon.flip()
dish.data.update()
bpy.context.view_layer.update()
refused("a cage with a flipped region, naming the plane", {"object_name": "Dish", "ribs_name": "Flipped", "planes": json.dumps([{"origin": [0.0, 0.0, 0.0], "normal": [0.0, 1.0, 0.0]}]), **SIZES},
"planes[0]: the normals of 'Dish' change sides along the section")
# --- longerons-through-ribs: two legs in one cage, so every plane cuts two chains --------------------------------------------
section("longerons-through-ribs")
leg_points = [(side * 0.6 + 0.3 * math.cos(2 * math.pi * k / 16), 0.3 * math.sin(2 * math.pi * k / 16), z) for side in (-1, 1) for z in (0.0, 1.0) for k in range(16)]
legs = mesh_object("Legs", leg_points, [(s * 32 + k, s * 32 + (k + 1) % 16, s * 32 + 16 + (k + 1) % 16, s * 32 + 16 + k) for s in (0, 1) for k in range(16)], wall=0.04)
TOWARD = [math.cos(math.pi / 16), math.sin(math.pi / 16), 0.0] # through the middle of a facet
BEAMS = [{"origin": [0.6, 0.0, 0.0], "axis": [0.0, 0.0, 1.0], "toward": TOWARD}, {"origin": [-0.6, 0.0, 0.0], "axis": [0.0, 0.0, 1.0], "toward": [-TOWARD[0], TOWARD[1], 0.0]}]
LEVELS = (0.2, 0.5, 0.8)
receipt, report = send("brokkr_kitbash.ribs", object_name="Legs", ribs_name="LegRibs", planes=flat(LEVELS), **SIZES, longerons=json.dumps(BEAMS), longeron="T", longeron_w=0.05, longeron_h=0.05, longeron_t=0.008)
ribs = bpy.data.objects.get("LegRibs")
middle = 0.3 * math.cos(math.pi / 16) - (0.04 + STANDOFF + DEPTH / 2) # the rib's mid-depth line where the half-plane crosses it, from the leg's axis
for row in (report or {}).get("longerons", []):
beam = BEAMS[row["index"]]
for station, level in zip(row["stations"], LEVELS):
from_line = np.array(station) - beam["origin"]
across = np.cross([0.0, 0.0, 1.0], beam["toward"])
reading("stationed", max(abs(from_line @ across), abs(station[2] - level), abs(math.hypot(from_line[0], from_line[1]) - middle), 0.0 if from_line @ np.array(beam["toward"]) > 0 else 1.0))
shape = measure(ribs.data) if ribs is not None else {}
check("longerons-through-ribs: a cage every plane cuts into two chains gets a longeron through each leg's ribs: every station on its half-plane, at its plane's height, on the rib's mid-depth line",
receipt["status"] == "accepted" and [s["chains"] for s in report["sections"]] == [2, 2, 2] and report["ribs"] == 6 and [(r["index"], len(r["stations"])) for r in report["longerons"]] == [(0, 3), (1, 3)]
and R["readings"].get("stationed", 1.0) < STATIONED and (shape["shells"], shape["nonManifoldEdges"]) == (8, 0)
and abs(float(points(ribs)[:, 2].max()) - (0.8 + 0.3 * 0.12)) < 1e-6 and abs(float(points(ribs)[:, 2].min()) - (0.2 - 0.3 * 0.12)) < 1e-6, [receipt["message"], report, R["readings"]])
# the longeron enum's other sections: a wedge and a gusset through the same ribs. A straight longeron's shells are its
# section's area times its length, so against the T's ribs each differs by the two sections' areas over two legs.
t_volume, run = (shape or {}).get("volume", 0.0), LEVELS[-1] - LEVELS[0] + 2 * 0.3 * 0.12
area = lambda kind: (lambda x, y: float(0.5 * np.sum(x * np.roll(y, -1) - np.roll(x, -1) * y)))(*core.profile(kind, 0.05, 0.05, 0.008).T) # noqa: E731
for kind in ("wedge", "gusset"):
receipt, report = send("brokkr_kitbash.ribs", object_name="Legs", ribs_name=f"LegRibs_{kind}", planes=flat(LEVELS), **SIZES, longerons=json.dumps(BEAMS),
longeron=kind, longeron_w=0.05, longeron_h=0.05, longeron_t=0.008)
made = bpy.data.objects.get(f"LegRibs_{kind}")
shape = measure(made.data) if made is not None else {}
check(f"a {kind} longeron through each leg's ribs: the stations a T's has, closed shells, and the {kind}'s area along the run",
receipt["status"] == "accepted" and [(r["index"], len(r["stations"])) for r in report["longerons"]] == [(0, 3), (1, 3)]
and (shape["shells"], shape["nonManifoldEdges"]) == (8, 0)
and reading("sectioned", abs((shape["volume"] - t_volume) / (2 * run * (area(kind) - area("T"))) - 1.0)) < SECTIONED, [receipt["message"], report, R["readings"]])
LEG = {"object_name": "Legs", "ribs_name": "Bad", "planes": flat(LEVELS), **SIZES}
refused("a longeron whose half-plane meets no rib", {**LEG, "longerons": json.dumps([{"origin": [0.0, 0.0, 0.0], "axis": [0.0, 0.0, 1.0], "toward": [0.0, 1.0, 0.0]}])},
"longerons[0] does not meet the ribs of planes[0]")
refused("a longeron whose half-plane meets two ribs", {**LEG, "longerons": json.dumps([{"origin": [0.0, 0.0, 0.0], "axis": [0.0, 0.0, 1.0], "toward": [1.0, 0.0, 0.0]}])},
"longerons[0] meets the ribs of planes[0] 2 times")
refused("a longeron with one plane", {**LEG, "planes": flat([0.5]), "longerons": json.dumps(BEAMS[:1])}, "A longeron runs through the ribs of two or more planes")
refused("a longeron whose wall leaves no section", {**LEG, "longerons": json.dumps(BEAMS[:1]), "longeron": "I", "longeron_t": 0.03}, "profile 'I' of width")
refused("a longeron through the pod's port", {"object_name": "Pod", "ribs_name": "Bad", "planes": flat(HEIGHTS), **SIZES,
"longerons": json.dumps([{"origin": [0.0, 0.0, 0.0], "axis": [0.0, 0.0, 1.0], "toward": [1.0, 0.0, 0.0]}])},
"longerons[0] crosses planes[2] where the plate is open and there is no rib")
receipt, report = send("brokkr_kitbash.ribs", object_name="Pod", ribs_name="Frame", planes=flat(HEIGHTS), **SIZES, posts=0.27, holes=0.11,
longerons=json.dumps([{"origin": [0.0, 0.0, 0.0], "axis": [0.0, 0.0, 1.0], "toward": [math.cos(a), math.sin(a), 0.0]} for a in (0.8, 2.4, 3.9, 5.5)]))
check("the pod takes ribs, holes, posts and four longerons clear of its port in one call", receipt["status"] == "accepted" and child_of(bpy.data.objects.get("Frame"), pod)
and (report["ribs"], len(report["longerons"]), report["nonManifoldEdges"]) == (5, 4, 0) and report["posts"] > 40 and report["holes"] > 80
and all(len(r["stations"]) == 5 for r in report["longerons"]), [receipt["message"], report])
# --- posts-under-the-plate ----------------------------------------------------------------------------------------------------------
section("posts-under-the-plate")
receipt, report = send("brokkr_kitbash.ribs", object_name="Cone60", ribs_name="ConePosts", planes=flat([0.5]), **SIZES, posts=0.2)
thin = frustum("Thin", 60, (24.0, 9.0, 0.0))
thin.modifiers["Solidify"].thickness = 0.02 # thinner than a post's end leans out of its middle, twice over
bpy.context.view_layer.update()
_, leaning = send("brokkr_kitbash.ribs", object_name="Thin", ribs_name="ThinPosts", planes=flat([0.5]), **SIZES, posts=0.2)
depths = [under(cage, bpy.data.objects[name]) for cage, name in ((deck, "DeckRibs"), (creased, "CreaseFrame"), (angle, "AngleRibs"), (pod, "Frame"), (bpy.data.objects["Cone60"], "ConePosts"), (thin, "ThinPosts"))]
check("posts-under-the-plate: a post starts inside the plate, half its thickness under the outer face where it stands square and deeper where it leans, and no vertex of a frame stands outside the outer face: "
"a flat deck, a crease, a right angle, the pod, a cone leaning 60 degrees, the same cone with a wall of 0.02 (and the spheres above)", receipt["status"] == "accepted" and report["posts"] > 10 and leaning is not None and leaning["posts"] > 10 and min(depths) > SUNK
and abs(depths[0] - 0.025) < 1e-6, [receipt["message"], depths, R["readings"]])
# --- holes-manifold: an egg-crate of five ribs that cross ---------------------------------------------------------------------
section("holes-manifold")
crate = mesh_object("Crate", [(-0.5, -0.5, 0.0), (0.5, -0.5, 0.0), (0.5, 0.5, 0.0), (-0.5, 0.5, 0.0)], [(0, 1, 2, 3)], Matrix.Translation((0.0, -5.0, 0.0)), wall=0.05)
GRID = json.dumps([{"origin": [x, 0.0, 0.0], "normal": [1.0, 0.0, 0.0]} for x in (-0.3, 0.0, 0.3)] + [{"origin": [0.0, y, 0.0], "normal": [0.0, 1.0, 0.0]} for y in (-0.3, 0.3)])
_, solid = send("brokkr_kitbash.ribs", object_name="Crate", ribs_name="CrateSolid", planes=GRID, **SIZES)
receipt, report = send("brokkr_kitbash.ribs", object_name="Crate", ribs_name="CrateHoled", planes=GRID, **SIZES, holes=0.09)
holed = bpy.data.objects.get("CrateHoled")
one = 0.5 * 16 * (0.3 * DEPTH) ** 2 * math.sin(2 * math.pi / 16) * THICKNESS
removed = (measure(bpy.data.objects["CrateSolid"].data)["volume"] - measure(holed.data)["volume"]) if holed is not None and solid else 0.0
shape = measure(holed.data) if holed is not None else {}
reading("holed", abs(removed / (55 * one) - 1.0))
check("holes-manifold: five ribs that cross each get their eleven holes, cut a plane at a time: closed shells, and the volume gone is the holes' own",
receipt["status"] == "accepted" and (report["ribs"], report["holes"], report["nonManifoldEdges"]) == (5, 55, 0) and (shape["shells"], shape["nonManifoldEdges"]) == (5, 0)
and R["readings"]["holed"] < HOLED and abs(solid["volume"] - 5 * DEPTH * THICKNESS) < 1e-7
and sorted(o.name for o in bpy.data.objects if o.name.startswith("Crate")) == ["Crate", "CrateHoled", "CrateSolid"], [receipt["message"], report, removed, 55 * one])
refused("holes that overlap", {"object_name": "Crate", "ribs_name": "Bad", "planes": GRID, **SIZES, "holes": 0.02}, "planes[0]: the lightening holes did not cut cleanly")
# --- ribs-refusals --------------------------------------------------------------------------------------------------------------
section("ribs-refusals")
POD = {"object_name": "Pod", "ribs_name": "New", "planes": flat(HEIGHTS), **SIZES}
refused("a name an object has", {**POD, "ribs_name": "Fit"}, "ribs_name 'Fit' must be 1 to 63 characters and no object's name")
refused("a plane that misses the cage", {**POD, "planes": flat([0.5, 9.0])}, "planes[1] misses 'Pod'")
refused("65 planes", {**POD, "planes": flat([0.3 + 0.01 * k for k in range(65)])}, "planes must be a JSON array of 1 to 64 objects")
refused("no plane", {**POD, "planes": "[]"}, "planes must be a JSON array of 1 to 64 objects")
refused("planes that are not JSON", {**POD, "planes": "[{"}, "planes is not JSON")
refused("a plane with no normal", {**POD, "planes": json.dumps([{"origin": [0.0, 0.0, 0.5]}])}, "planes[0] must be an object of origin and normal, each three numbers")
refused("a plane whose normal has no length", {**POD, "planes": json.dumps([{"origin": [0.0, 0.0, 0.5], "normal": [0.0, 0.0, 0.0]}])}, "planes[0].normal has no direction")
refused("17 longerons", {**POD, "longerons": json.dumps([BEAMS[0]] * 17)}, "longerons must be a JSON array of 0 to 16 objects")
refused("ribs deeper than the pod is wide", {**POD, "planes": flat([0.5, 1.5]), "standoff": 0.15, "depth": 0.3}, "the section leaves a rib no room: it turns or closes in tighter than the rib reaches: lower standoff or depth")
precise = json.dumps([{"origin": [0.012345678901234567, -0.012345678901234567, 0.3 + 0.012345678901234567 * k], "normal": [1.2345678901234567e-05, -1.2345678901234567e-05, 0.99999999987654321]} for k in range(64)])
receipt, report = send("brokkr_kitbash.ribs", **{**POD, "ribs_name": "Sixtyfour", "planes": precise})
check("planes-string-cap-below-64: 64 planes written at full precision, over 9000 characters, are taken", len(precise) > 9000 and receipt["status"] == "accepted" and len(report["sections"]) == 64,
[len(precise), receipt["message"]])
refused("a cage that is not a mesh", {**POD, "object_name": "Nothing"}, "No mesh object named 'Nothing'")
refused("a section too long for its step", {**POD, "planes": flat([0.3 + 0.01 * k for k in range(64)]), "step": 0.002}, "The sections are over 20000 points at step 0.002")
pod.scale = (1.0, 1.0, 1.01)
bpy.context.view_layer.update()
refused("a scaled cage", POD, "'Pod' is scaled, mirrored or sheared in the world")
pod.scale = (1.0, 1.0, 1.0)
crate.hide_viewport = True # nothing depends on the crate's cage but its ribs, and children do not hold a parent out of the depsgraph... they do: so they go first
for name in ("CrateSolid", "CrateHoled"):
bpy.data.objects[name].parent = None
bpy.context.view_layer.update()
refused("a cage Blender does not evaluate", {"object_name": "Crate", "ribs_name": "New", "planes": GRID, **SIZES}, "Blender does not evaluate 'Crate' in this view layer")
crate.hide_viewport = False
extra = crate.modifiers.new("Second", "SOLIDIFY")
bpy.context.view_layer.update()
refused("a cage with two Solidifies", {"object_name": "Crate", "ribs_name": "New", "planes": GRID, **SIZES}, "'Crate' has 2 Solidify modifiers (Solidify, Second)")
crate.modifiers.remove(extra)
check("every refusal left the cages' modifiers shown", all(m.show_viewport for o in (pod, deck, legs, crate, dish, hip, creased, angle, sunk, narrow) for m in o.modifiers), None)
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, not a missing result file
check(f"no uncaught error in section: {SECTION[0]}", False, traceback.format_exc().splitlines()[-6:])
finally:
R["ok"] = all(c["ok"] for c in R["checks"])
R["readings"] = {name: float(f"{value:.2g}") for name, value in sorted(R["readings"].items())}
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
print("READINGS", R["readings"], flush=True)
sys.exit(0 if R["ok"] else 1)

View file

@ -0,0 +1,277 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "the pod is cut by a port, a panel break and a recess",
"ok": true,
"detail": null
},
{
"name": "ribs makes one mesh object under the cage: a child under identity matrices, no modifier, no material, and kit_ribs the request",
"ok": true,
"detail": null
},
{
"name": "ribs reports the frame: one rib a plane, the plate's thickness read from the Solidify, the port's plane open along it, closed shells",
"ok": true,
"detail": null
},
{
"name": "ribs-fit-the-plate: at every point of a rib's outer edge the nearer vertex stands the standoff behind the plate's inner face, along the plate's normal; every vertex in its plane, on the side the normals face away from",
"ok": true,
"detail": null
},
{
"name": "standoff-oblique-sections: on cones whose wall leans 0, 30, 45 and 60 degrees out of the rib's plane the rib comes the standoff from the plate's inner face and no nearer, and is the ring between the section's offsets",
"ok": true,
"detail": null
},
{
"name": "where walls that lean 45 and 20 degrees meet, the rib stands the standoff off each wall right into the corner: its edges are each wall's own, met in a mitre (mutant V1 runs one wall's edge into the other's standoff)",
"ok": true,
"detail": null
},
{
"name": "negative-solidify-thickness: a wall of -0.06 grows outward, and the rib stands the standoff inside the designed surface, the plate's inner face",
"ok": true,
"detail": null
},
{
"name": "ribs-fold-at-crease: behind a crease of 49.4 degrees either side of a facet of 0.062 a rib of standoff 0.03 and depth 0.08 is made, clipped: one closed shell the area of the true offset, no vertex nearer the section than the rib starts or further than it reaches",
"ok": true,
"detail": null
},
{
"name": "a post behind the crease's facet that would end outside a shallow rib, short of where the rib's edges meet, is left out: ten of the thirteen stations (mutant P1 posts eleven)",
"ok": true,
"detail": null
},
{
"name": "the creased rib takes holes along its clipped centre line, cut clean, and posts",
"ok": true,
"detail": null
},
{
"name": "inside a right angle no post stands nearer the corner than the rib's outer edge is set back, 0.09: twelve of the sixteen stations (mutant P1 posts all sixteen, four through the other wall)",
"ok": true,
"detail": null
},
{
"name": "a plane tilted 64 degrees through a prism of 24 flat sides: every facet leans differently out of the plane, and the rib stands the standoff off each (the finding: 0.007 short)",
"ok": true,
"detail": null
},
{
"name": "spheres of radius 1 and 0.6 cut 60 degrees off the middle, standoffs 0.04 and 0.01: a wall curved both ways, leaning 60 degrees, and the rib and its posts stand the standoff off it (the finding: 0.020 short, and at radius 0.6 and standoff 0.01 through the inner face)",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: at radius 0.6 a standoff of 0.04 has no rib in that plane: 0.1 inside the wall the sphere is 0.5, and the plane passes 0.52 from its middle",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a standoff greater than the plate's inner radius: the offset surface has passed through itself everywhere",
"ok": true,
"detail": null
},
{
"name": "solidify-default-unbounded: a box whose Solidify is not even is 0.0424 thick, not its 0.06, and the rib stands the standoff off the inner face it has (read as 0.06: 0.0176 over)",
"ok": true,
"detail": null
},
{
"name": "a cage subdivided after its Solidify is taken as that thick behind every face: a rib, clear of the plate",
"ok": true,
"detail": null
},
{
"name": "a recess 0.8 of the plate deep is plate: the rib runs on under it (the ray looks 1.25 of the plate deep; mutant N5 looks 0.5)",
"ok": true,
"detail": null
},
{
"name": "a port in a narrow cage is open though the far wall stands 3.5 plates behind it: the rib stops either side (mutant N13 looks 5 plates deep and finds the far wall)",
"ok": true,
"detail": null
},
{
"name": "ribs-stop-at-ports: no rib, post or hole stands within the clearance of the port; behind the panel break the rib is one piece; under the recess it runs on",
"ok": true,
"detail": null
},
{
"name": "with no bridge the panel break splits both ribs",
"ok": true,
"detail": null
},
{
"name": "ribs-from-normals: a dish whose normals face its hollow side gets its rib on the other, the round side, though its section's middle lies in the hollow; a cage with no Solidify has a plate of no thickness",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a cage with a flipped region, naming the plane",
"ok": true,
"detail": null
},
{
"name": "longerons-through-ribs: a cage every plane cuts into two chains gets a longeron through each leg's ribs: every station on its half-plane, at its plane's height, on the rib's mid-depth line",
"ok": true,
"detail": null
},
{
"name": "a wedge longeron through each leg's ribs: the stations a T's has, closed shells, and the wedge's area along the run",
"ok": true,
"detail": null
},
{
"name": "a gusset longeron through each leg's ribs: the stations a T's has, closed shells, and the gusset's area along the run",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a longeron whose half-plane meets no rib",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a longeron whose half-plane meets two ribs",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a longeron with one plane",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a longeron whose wall leaves no section",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a longeron through the pod's port",
"ok": true,
"detail": null
},
{
"name": "the pod takes ribs, holes, posts and four longerons clear of its port in one call",
"ok": true,
"detail": null
},
{
"name": "posts-under-the-plate: a post starts inside the plate, half its thickness under the outer face where it stands square and deeper where it leans, and no vertex of a frame stands outside the outer face: a flat deck, a crease, a right angle, the pod, a cone leaning 60 degrees, the same cone with a wall of 0.02 (and the spheres above)",
"ok": true,
"detail": null
},
{
"name": "holes-manifold: five ribs that cross each get their eleven holes, cut a plane at a time: closed shells, and the volume gone is the holes' own",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: holes that overlap",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a name an object has",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a plane that misses the cage",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: 65 planes",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: no plane",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: planes that are not JSON",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a plane with no normal",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a plane whose normal has no length",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: 17 longerons",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: ribs deeper than the pod is wide",
"ok": true,
"detail": null
},
{
"name": "planes-string-cap-below-64: 64 planes written at full precision, over 9000 characters, are taken",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a cage that is not a mesh",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a section too long for its step",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a scaled cage",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a cage Blender does not evaluate",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a cage with two Solidifies",
"ok": true,
"detail": null
},
{
"name": "every refusal left the cages' modifiers shown",
"ok": true,
"detail": null
}
],
"hostErrors": [],
"readings": {
"cleared": 0.031,
"creased": 2.3e-07,
"fit": 7.5e-05,
"holed": 5.5e-08,
"planar": 1.4e-07,
"ring": 2.1e-06,
"round": 9.7e-08,
"sectioned": 1.1e-06,
"stationed": 5.2e-07,
"stood": 6.4e-08,
"sunk": 0.0047,
"tilted": 2.1e-05,
"uneven": 8.3e-09
},
"ok": true
}

View file

@ -1,8 +1,8 @@
"""Live proof, in a background Blender, of brokkr_kitbash shell cuts through run_intent: cut on a mesh that is not a kit
part (a subdivided, solidified cage), the one Boolean modifier per operation and its collection, a cast at the surface
without its cuts, machinery on a cutter's floor socket and what moves when the cutter moves or is resized, boolean on
any mesh, the refusals, cut_many, a cutter's axis, a slot's three floors, an object in no collection, and the order of a set_params report's closures. Not part of the
unittest run: it needs Blender.
any mesh, the refusals, cut_many, a cutter's axis, a slot's three floors, an object in no collection or one Blender does not evaluate, a receipt's rows trimmed
to fit, and the order of a set_params report's closures. Not part of the unittest run: it needs Blender.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/kitbash_shell.py -- <out>
@ -11,6 +11,9 @@ without them). <out> is an absolute path; writes <out>.result.json and exits 1 w
Bounds follow lodur:ruling:deterministic-bound-margin: each sits at the geometric mean of the shipped worst reading
and the least claimed mutant's, both written beside it; the result file carries the readings.
The checks run inside one try: an uncaught error is a failed check that names the section it happened in, and the
result file is written and the checks printed whatever happened.
"""
import importlib.util
import json
@ -18,6 +21,7 @@ import math
import os
import sys
import tempfile
import traceback
import types
from pathlib import Path
@ -160,123 +164,15 @@ def stack(obj):
return [m.name for m in obj.modifiers]
# --- a cage: not a kit part. A closed loft of 6 rings of 8, subdivided and given a wall ----------------------------------
bm = bmesh.new()
rings = [[bm.verts.new((r * math.cos(math.pi / 8 + k * math.pi / 4), r * math.sin(math.pi / 8 + k * math.pi / 4), z)) for k in range(8)]
for z, r in ((-1.0, 0.5), (-0.6, 0.7), (-0.2, 0.8), (0.2, 0.8), (0.6, 0.7), (1.0, 0.5))]
for low, high in zip(rings, rings[1:]):
for k in range(8):
bm.faces.new((low[k], low[(k + 1) % 8], high[(k + 1) % 8], high[k]))
bmesh.ops.recalc_face_normals(bm, faces=bm.faces[:])
mesh = bpy.data.meshes.new("Cage")
bm.to_mesh(mesh)
bm.free()
cage = bpy.data.objects.new("Cage", mesh)
bpy.context.scene.collection.objects.link(cage)
cage.modifiers.new("Subsurf", "SUBSURF").levels = 2
wall = cage.modifiers.new("Solidify", "SOLIDIFY")
wall.thickness, wall.offset, wall.use_even_offset = 0.05, -1.0, True
cage.matrix_world = Matrix.Translation((4.0, -1.0, 2.0)) @ Matrix.Rotation(0.6, 4, "Z") @ Matrix.Rotation(-0.3, 4, "X")
bpy.context.view_layer.update()
world = np.array(cage.matrix_world, dtype=np.float64)
uncut, _ = evaluated(cage)
check("the cage is a closed wall before it is cut", uncut["nonManifoldEdges"] == 0 and 0.15 < uncut["volume"] < 0.4 and "kit_part" not in cage, uncut)
R["cage"] = {"uncut": uncut}
SECTION = ["setup"]
# --- cut-at-ray: a through bay, a blind round recess, a row of gills and a panel break --------------------------------------
CUTS = [("Bay", "box", (3.0, 0.0, 0.1), (-1.0, 0.0, 0.0), "width=0.3; height=0.3; depth=0.2", {}),
("Recess", "cyl", (-3.0, 0.1, 0.2), (2.0, 0.0, 0.0), "r=0.1; depth=0.02", {}),
("Gills", "slot", (0.1, 3.0, -0.2), (0.0, -1.0, 0.0), "width=0.3; height=0.04; count=4; pitch=0.08; depth=0.02", {}),
("Break", "slab", (0.0, -3.0, 0.3), (0.0, 1.0, 0.0), "length=0.6; depth=0.1", {"roll": 90.0})]
frames, volume, falls, reports = {}, uncut["volume"], [], {}
for name, part, origin, direction, params, more in CUTS:
hit, normal = cast(cage, origin, direction) # before this cutter exists; the cuts made so far are far from this ray
frames[name] = core.surface_frame(hit, normal, (0.0, 0.0, 1.0), more.get("roll", 0.0))
state = sorted(o.name for o in bpy.data.objects)
receipt, report = cut(name, part, origin, direction, params, **more)
reports[name] = report
cutter = bpy.data.objects.get(name)
ok = receipt["status"] == "accepted" and cutter is not None and sorted(o.name for o in bpy.data.objects) == sorted(state + [name])
ok = ok and cutter.parent == cage and np.array_equal(np.array(cutter.matrix_parent_inverse), np.eye(4))
ok = ok and reading("framed", np.abs(np.array(cutter.matrix_basis) - frames[name]).max()) < FRAMED
ok = ok and (cutter["kit_kit"], cutter["kit_part"]) == ("cutters", part) and bpy.context.scene.collection in cutter.users_collection
ok = ok and not cutter.hide_render and not cutter.hide_viewport and len(cutter.modifiers) == 0
check(f"cut places the {part} cutter {name} on the cage where the ray meets it: parented under an identity inverse, its basis the surface frame",
ok, [receipt["message"], cutter and np.array(cutter.matrix_basis).tolist(), frames[name].tolist()])
wanted = world @ frames[name]
check(f"cut reports {name} as a cutters part with its sockets in the world, and what cuts the cage, without evaluating it", report
and report["object"] == "Cage" and report["cutter"]["object"] == name and report["cutter"]["kit"] == "cutters" and "evaluated" not in report
and report["booleans"] == [{"cutter": n, "operation": "DIFFERENCE"} for n in [c[0] for c in CUTS][:len(frames)]]
and [s["name"] for s in report["cutter"]["sockets"]] == {"slab": [], "slot": ["floor", "floor_l", "floor_r"]}.get(part, ["floor"])
and (part == "slab" or np.abs(np.array(report["cutter"]["sockets"][0]["matrix"]) - wanted @ core.build(kits["cutters"]["parts"][part], report["cutter"]["params"]).sockets[0]["matrix"]).max() < 1e-4),
report)
shown, _ = evaluated(cage)
falls.append(shown["volume"] < volume - 1e-4 and shown["nonManifoldEdges"] == 0)
volume = shown["volume"]
R["cage"][name] = shown
modifier = cage.modifiers.get("Kit Difference")
check("four cuts give the cage one Boolean modifier after its own, over one collection of the four cutters in the order they came",
stack(cage) == ["Subsurf", "Solidify", "Kit Difference"] and modifier is not None
and (modifier.type, modifier.solver, modifier.use_self, modifier.operation, modifier.operand_type, modifier.material_mode) == ("BOOLEAN", "EXACT", True, "DIFFERENCE", "COLLECTION", "TRANSFER")
and [o.name for o in modifier.collection.objects] == [c[0] for c in CUTS] and modifier.collection.name == "Cage difference"
and not any(modifier.collection in s.collection.children_recursive for s in bpy.data.scenes), [stack(cage), modifier and modifier.operand_type])
check("the evaluated cage stays a closed wall and loses volume with each cut", all(falls) and len(falls) == 4, R["cage"])
receipt, report = send("brokkr_kitbash.report", object_name="")
check("report lists the cutters as kit parts and not the cage", report and [p["object"] for p in report["parts"]] == sorted(c[0] for c in CUTS)
and all(p["connection"] is None and p["baked"] is False for p in report["parts"]), report and [p["object"] for p in report["parts"]])
# --- cut-casts-the-uncut-surface --------------------------------------------------------------------------------------------
through = cast(cage, CUTS[0][2], CUTS[0][3])[0] # as the cage is evaluated now, with its cuts: through the bay to the far wall
receipt, report = cut("Bay2", "cyl", CUTS[0][2], CUTS[0][3], "r=0.05; depth=0.2")
again = bpy.data.objects.get("Bay2")
check("a second cut on the through bay's ray lands where the first did, on the surface as it was before any cut, though the ray now passes through the bay",
receipt["status"] == "accepted" and again is not None and np.linalg.norm(through - frames["Bay"][:3, 3]) > 1.0
and reading("recast", np.abs(np.array(again.matrix_basis)[:3, 3] - frames["Bay"][:3, 3]).max()) < RECAST
and stack(cage) == ["Subsurf", "Solidify", "Kit Difference"] and all(m.show_viewport for m in cage.modifiers),
[receipt["message"], through.tolist(), frames["Bay"][:3, 3].tolist(), again and list(again.matrix_basis.translation)])
def section(name):
SECTION[0] = name
# --- floor-carries-machinery ------------------------------------------------------------------------------------------------
recess = bpy.data.objects["Recess"]
vent = place("Vent", "vent", "width=0.2; height=0.15") # back size 0.135; the floor's is 0.2
receipt, report = send("brokkr_kitbash.attach", object_name="Vent", socket="back", parent_name="Recess", parent_socket="floor", roll=30.0)
floor = world @ frames["Recess"] @ np.array(Matrix.Translation((0.0, 0.0, -0.02))) # the hit point, depth along the normal
back = frame(vent, "back")
check("a mechanical vent attaches to the round recess's floor: its back on the hit point taken depth down the normal, facing in, and the connection holds",
receipt["status"] == "accepted" and held(report) and vent.parent == recess and report["connection"]["parent"] == "Recess" and report["kit"] == "mechanical"
and reading("floored", max(np.abs(back[:3, 3] - floor[:3, 3]).max(), np.abs(back[:3, 2] + floor[:3, 2]).max())) < FLOORED,
[receipt["message"], back.tolist(), floor.tolist()])
big = place("Big", "vent", "width=0.8; height=0.6")
refused("a vent larger than the recess's floor", "brokkr_kitbash.attach", {"object_name": "Big", "socket": "back", "parent_name": "Recess", "parent_socket": "floor"},
"'Big' on 'Recess': socket 'back' (mount, size 0.54) and parent socket 'floor' (mount, size 0.2) are mount sockets, where the child fits the parent: it is larger")
nozzle = place("Nozzle", "nozzle")
refused("a flange on a floor", "brokkr_kitbash.attach", {"object_name": "Nozzle", "socket": "mount", "parent_name": "Recess", "parent_socket": "floor"}, "are of different types")
refused("a second part on the floor", "brokkr_kitbash.attach", {"object_name": "Nozzle", "socket": "mount", "parent_name": "Recess", "parent_socket": "floor"}, "'Nozzle' on 'Recess'")
refused("a part on a slab, which has no floor", "brokkr_kitbash.attach", {"object_name": "Big", "socket": "back", "parent_name": "Break", "parent_socket": "floor"},
"kit 'cutters' part 'slab' has no socket 'floor'; its sockets: none")
refused("detach of a cutter, which is placed and not attached", "brokkr_kitbash.detach", {"object_name": "Recess"}, "'Recess' is not attached")
before = evaluated(cage)[0]
moved_to = np.array(recess.matrix_basis)[:3, 3] + np.array(recess.matrix_basis)[:3, :3] @ [0.0, 0.25, 0.0] # along the cutter's own y: up the wall
was = frame(vent, "back")
send("setObjectTransform", targetObjectName="Recess", location=moved_to.tolist())
shift = frame(vent, "back")[:3, 3] - was[:3, 3]
after = evaluated(cage)[0]
check("setObjectTransform on the cutter moves the cut and the vent on its floor together: the vent still holds, and the cage is cut elsewhere",
reading("floored", np.abs(shift - world[:3, :3] @ (moved_to - frames["Recess"][:3, 3])).max()) < FLOORED and abs(np.linalg.norm(shift) - 0.25) < 1e-4
and (connection := send("brokkr_kitbash.report", object_name="Vent")[1]["parts"][0]["connection"])["holds"] is True
and after["nonManifoldEdges"] == 0 and after != before, [shift.tolist(), before, after])
was = frame(vent, "back")
receipt, report = send("brokkr_kitbash.set_params", object_name="Recess", params="depth=0.04")
sunk = frame(vent, "back")[:3, 3] - was[:3, 3]
deeper = evaluated(cage)[0]
check("set_params depth=0.04 on the cutter deepens the cut and seats the vent on the new floor, 0.02 further down the normal",
receipt["status"] == "accepted" and report["params"]["depth"] == 0.04 and reading("floored", np.abs(sunk + was[:3, 2] * -0.02).max()) < FLOORED
and send("brokkr_kitbash.report", object_name="Vent")[1]["parts"][0]["connection"]["holds"] is True
and deeper["volume"] < after["volume"] - 1e-5 and deeper["nonManifoldEdges"] == 0 and stack(cage) == ["Subsurf", "Solidify", "Kit Difference"],
[receipt["message"], sunk.tolist(), after, deeper])
R["cage"]["deeper"] = deeper
# --- cut_many: several cutters for one evaluation, all or none; an axis; a slot's three floors -----------------------------------
def uncut_cast(origin, direction):
"""cast at the cage with its Kit Booleans off: the surface as designed."""
shown = [m for m in cage.modifiers if m.name.startswith("Kit ")]
for m in shown:
m.show_viewport = False
@ -287,151 +183,392 @@ def uncut_cast(origin, direction):
m.show_viewport = True
MANY = [{"name": "Visor", "part": "slot", "params": "width=0.6; height=0.14; depth=0.02; lift=0.2", "origin": [0.6, 3.0, 0.5], "direction": [0.0, -1.0, 0.0]},
{"name": "Seam", "part": "slab", "params": "length=0.4; depth=0.1", "origin": [-0.5, -3.0, -0.7], "direction": [0.0, 1.0, 0.0], "up": [1.0, 0.0, 0.0], "axis": [0.0, -1.0, 0.0]},
{"name": "Port", "part": "cyl", "params": "r=0.05", "origin": [-0.6, 3.0, -0.5], "direction": [0.0, -2.0, 0.0], "up": [1.0, 0.0, 0.0], "roll": 45.0}]
wanted = {}
for spec in MANY:
hit, normal = uncut_cast(spec["origin"], spec["direction"])
wanted[spec["name"]] = core.surface_frame(hit, spec.get("axis", normal), spec.get("up", (0.0, 0.0, 1.0)), spec.get("roll", 0.0))
if "axis" in spec:
lean = float(np.degrees(np.arccos(np.clip(normal @ np.array(spec["axis"]), -1.0, 1.0))))
refused("cut_many whose second ray misses places none", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([MANY[0], {**MANY[1], "origin": [0.0, -3.0, 5.0]}])},
"The ray from (0.0, -3.0, 5.0) along (0.0, 1.0, 0.0) misses 'Cage'")
refused("cut_many with a name twice", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([MANY[0], {**MANY[1], "name": "Visor"}])}, "An object named 'Visor' exists in this call")
refused("cut_many with a name an object has", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([MANY[0], {**MANY[1], "name": "Bay"}])}, "An object named 'Bay' exists;")
refused("cut_many whose last cutter has a bad param", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps(MANY[:2] + [{**MANY[2], "params": "r=9"}])}, "param 'r' = 9.0 is outside")
refused("cut_many of text that is not JSON", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": "[{"}, "cuts is not JSON")
refused("cut_many of no cutters", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": "[]"}, "cuts must be a JSON array of 1 to 64 cutters")
refused("cut_many of a cutter with no direction", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([{k: v for k, v in MANY[0].items() if k != "direction"}])},
"cuts[0] must be an object with name, part, origin and direction")
refused("cut_many of a cutter with a key cut does not have", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([{**MANY[0], "operation": "UNION"}])}, "cuts[0] must be an object")
refused("cut_many of an origin of two numbers", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([{**MANY[0], "origin": [0.0, 1.0]}])}, "cuts[0].origin must be three numbers")
refused("cut_many of a roll of 400", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([{**MANY[0], "roll": 400}])}, "cuts[0].roll must be a number from -360 to 360")
refused("an axis that points into the surface", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([{**MANY[1], "axis": [0.0, 1.0, 0.0]}])}, "'Seam': the axis (0.0, 1.0, 0.0) points into the surface")
addon = sys.modules["brokkr_kitbash"]
limit = addon.REPORT_LIMIT
addon.REPORT_LIMIT = 300
refused("cut_many whose report would not fit a receipt places none", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps(MANY)}, "over the 300 a receipt carries: cut fewer at once")
addon.REPORT_LIMIT = limit
receipt, report = send("brokkr_kitbash.cut_many", object_name="Cage", cuts=json.dumps(MANY))
placed = [bpy.data.objects.get(spec["name"]) for spec in MANY]
check("cut_many places three cutters in one action, each as cut would: parented under an identity inverse, its basis the surface frame at its own ray on the uncut cage, in the difference collection in order",
receipt["status"] == "accepted" and all(placed) and report == {"object": "Cage", "cutters": ["Visor", "Seam", "Port"], "booleans": report["booleans"]}
and [row["cutter"] for row in report["booleans"]] == ["Bay", "Recess", "Gills", "Break", "Bay2", "Visor", "Seam", "Port"]
and all(c.parent == cage and np.array_equal(np.array(c.matrix_parent_inverse), np.eye(4))
and reading("framed", np.abs(np.array(c.matrix_basis) - wanted[c.name]).max()) < FRAMED for c in placed)
and stack(cage) == ["Subsurf", "Solidify", "Kit Difference"] and all(m.show_viewport for m in cage.modifiers) and evaluated(cage)[0]["nonManifoldEdges"] == 0,
[receipt["message"], report])
seam = bpy.data.objects["Seam"]
check("a slab with an axis stands on the axis, not on the wall's normal, which leans from it there", lean > 5.0
and reading("framed", np.abs(np.array(seam.matrix_basis)[:3, 2] - [0.0, -1.0, 0.0]).max()) < FRAMED, [lean, np.array(seam.matrix_basis).tolist()])
receipt, report = send("brokkr_kitbash.cut", object_name="Cage", cutter_name="Seam2", part="slab", params="length=0.3; depth=0.1", origin_x=0.5, origin_y=-3.0, origin_z=-0.7,
direction_x=0.0, direction_y=1.0, direction_z=0.0, up_x=1.0, up_y=0.0, up_z=0.0, axis_x=0.0, axis_y=-1.0, axis_z=0.0)
check("cut takes the same axis", receipt["status"] == "accepted" and reading("framed", np.abs(np.array(bpy.data.objects["Seam2"].matrix_basis)[:3, 2] - [0.0, -1.0, 0.0]).max()) < FRAMED, receipt["message"])
visor = bpy.data.objects["Visor"]
eyes = {}
for socket, x in (("floor", 0.0), ("floor_l", -0.2), ("floor_r", 0.2)):
eye = place(f"Eye_{socket}", "vent", "width=0.2; height=0.15") # back size 0.135; each floor's is 0.14
receipt, report = send("brokkr_kitbash.attach", object_name=eye.name, socket="back", parent_name="Visor", parent_socket=socket)
there = world @ wanted["Visor"] @ np.array(Matrix.Translation((x, 0.0, -0.02)))
eyes[socket] = receipt["status"] == "accepted" and held(report) and eye.parent == visor \
and reading("floored", max(np.abs(frame(eye, "back")[:3, 3] - there[:3, 3]).max(), np.abs(frame(eye, "back")[:3, 2] + there[:3, 2]).max())) < FLOORED
check("a slot's three floors each take a part: at the centre and a third of the width to each side, all on the slot's one floor plane", all(eyes.values()) and len(eyes) == 3, eyes)
refused("a second part on a side floor", "brokkr_kitbash.attach", {"object_name": "Nozzle", "socket": "mount", "parent_name": "Visor", "parent_socket": "floor_l"}, "'Nozzle' on 'Visor'")
refused("a fourth eye on a floor that is taken", "brokkr_kitbash.attach", {"object_name": "Big", "socket": "back", "parent_name": "Visor", "parent_socket": "floor_l"}, "'Big' on 'Visor'")
def quad(name, location):
"""A single square face, 1 m, normal +z: a surface with one side."""
made = bpy.data.objects.new(name, bpy.data.meshes.new(name))
made.data.from_pydata([(-0.5, -0.5, 0.0), (0.5, -0.5, 0.0), (0.5, 0.5, 0.0), (-0.5, 0.5, 0.0)], [], [(0, 1, 2, 3)])
bpy.context.scene.collection.objects.link(made)
made.location = location
bpy.context.view_layer.update()
return made
# --- boolean on any mesh, and the order of the three operations -----------------------------------------------------------------
lump_at = world @ [0.0, 0.0, 1.0, 1.0]
send("createObject", objectType="MESH", name="Lump", location=lump_at[:3].tolist(), size=0.2)
receipt, report = send("brokkr_kitbash.boolean", object_name="Cage", cutter="Lump", operation="UNION")
check("boolean on the cage, which is not a kit part, adds a second modifier after the difference and reports the object, what cuts it and the evaluated mesh",
receipt["status"] == "accepted" and stack(cage) == ["Subsurf", "Solidify", "Kit Difference", "Kit Union"]
and sorted(report) == ["booleans", "evaluated", "object"] and report["object"] == "Cage" and report["evaluated"] == evaluated(cage)[0]
and report["booleans"] == [{"cutter": n, "operation": "DIFFERENCE"} for n in ("Bay", "Recess", "Gills", "Break", "Bay2", "Visor", "Seam", "Port", "Seam2")] + [{"cutter": "Lump", "operation": "UNION"}]
and report["evaluated"]["volume"] > deeper["volume"], [receipt["message"], report])
refused("cut-refusals: a cutter already in the target's union collection", "brokkr_kitbash.boolean", {"object_name": "Cage", "cutter": "Lump"},
"'Lump' already cuts 'Cage' (its Kit Union modifier's collection)")
refused("a cut's own cutter given to boolean again", "brokkr_kitbash.boolean", {"object_name": "Cage", "cutter": "Bay", "operation": "INTERSECT"},
"'Bay' already cuts 'Cage' (its Kit Difference modifier's collection)")
plate = place("Plate", "plate", location=[0.0, -6.0, 0.0])
for name, size, operation in (("Boss", 0.06, "UNION"), ("Keep", 2.0, "INTERSECT"), ("Hole", 0.05, "DIFFERENCE")):
send("createObject", objectType="MESH", name=name, location=[0.0, -6.0, 0.0], size=size)
receipt, report = send("brokkr_kitbash.boolean", object_name="Plate", cutter=name, operation=operation)
check("a part cut by union, then intersect, then difference carries the three modifiers as difference, union, intersect, above its Bevel, and lists its cutters so",
receipt["status"] == "accepted" and stack(plate) == ["Kit Difference", "Kit Union", "Kit Intersect", "Kit Bevel"]
and report["booleans"] == [{"cutter": "Hole", "operation": "DIFFERENCE"}, {"cutter": "Boss", "operation": "UNION"}, {"cutter": "Keep", "operation": "INTERSECT"}]
and report["evaluated"]["nonManifoldEdges"] == 0 and report["kit"] == "mechanical", [stack(plate), report and report["booleans"]])
collections = len(bpy.data.collections)
receipt, baked = send("brokkr_kitbash.apply", object_name="Plate")
check("apply removes the three collections its modifiers held and leaves every cutter in the scene", receipt["status"] == "accepted"
and baked["cutters"] == ["Hole", "Boss", "Keep"] and len(bpy.data.collections) == collections - 3 and len(plate.modifiers) == 0
and all(name in bpy.context.scene.objects for name in ("Hole", "Boss", "Keep")), [receipt["message"], [c.name for c in bpy.data.collections]])
refused("apply on the cage, which is not a kit part", "brokkr_kitbash.apply", {"object_name": "Cage"}, "'Cage' is not a kit part")
# --- cut-refusals -----------------------------------------------------------------------------------------------------------
RAY = {"object_name": "Cage", "cutter_name": "New", "part": "box", "origin_x": 3.0, "origin_y": 0.0, "origin_z": 0.1, "direction_x": -1.0, "direction_y": 0.0, "direction_z": 0.0}
refused("a ray that misses", "brokkr_kitbash.cut", {**RAY, "origin_z": 5.0}, "The ray from (3.0, 0.0, 5.0) along (-1.0, 0.0, 0.0) misses 'Cage'")
refused("a ray of no direction", "brokkr_kitbash.cut", {**RAY, "direction_x": 0.0}, "'New': the ray's direction is zero")
refused("a cutter name an object has", "brokkr_kitbash.cut", {**RAY, "cutter_name": "Bay"}, "An object named 'Bay' exists")
refused("a param the cutter part does not have", "brokkr_kitbash.cut", {**RAY, "params": "radius=0.1"}, "kit 'cutters' part 'box' has no param 'radius'")
refused("a slot wider across than along", "brokkr_kitbash.cut", {**RAY, "part": "slot", "params": "width=0.05; height=0.1"}, "every size must be above 0")
refused("a target that is not a mesh", "brokkr_kitbash.cut", {**RAY, "object_name": "Nothing"}, "No mesh object named 'Nothing'")
block = bpy.data.objects.new("Block", bpy.data.meshes.new("Block"))
bm = bmesh.new()
bmesh.ops.create_cube(bm, size=1.0)
bm.to_mesh(block.data)
bm.free()
bpy.context.scene.collection.objects.link(block)
block.location = (0.0, -9.0, 0.0)
bpy.context.view_layer.update()
DOWN = {**RAY, "object_name": "Block", "origin_x": 0.1, "origin_y": 0.1, "origin_z": 3.0, "direction_x": 0.0, "direction_z": -1.0}
refused("an up along the hit normal", "brokkr_kitbash.cut", DOWN, "up [0.0, 0.0, 1.0] runs along the surface normal [0.0, 0.0, 1.0]")
block.scale = (1.0, 1.0, 1.01)
bpy.context.view_layer.update()
refused("a scaled target", "brokkr_kitbash.cut", {**DOWN, "up_y": 1.0, "up_z": 0.0}, "'Block' is scaled, mirrored or sheared in the world (scale 1, 1, 1.01)")
refused("boolean on a scaled target", "brokkr_kitbash.boolean", {"object_name": "Block", "cutter": "Lump"}, "'Block' is scaled, mirrored or sheared")
block.scale = (1.0, 1.0, 1.0)
bpy.context.view_layer.update()
receipt, report = send("brokkr_kitbash.cut", **{**DOWN, "cutter_name": "Pocket", "up_y": 1.0, "up_z": 0.0, "roll": 90.0})
pocket = bpy.data.objects.get("Pocket")
check("a cut on a plain cube with up +y and roll 90: the cutter's y points along -x, its floor 0.02 under the top face", receipt["status"] == "accepted" and pocket is not None
and np.abs(np.array(pocket.matrix_basis) - [[0, -1, 0, 0.1], [1, 0, 0, 0.1], [0, 0, 1, 0.5], [0, 0, 0, 1]]).max() < 1e-6
and np.abs(np.array(report["cutter"]["sockets"][0]["matrix"])[:3, 3] - [0.1, -8.9, 0.48]).max() < 1e-6 and stack(block) == ["Kit Difference"],
[receipt["message"], pocket and np.array(pocket.matrix_basis).tolist()])
try:
# --- a cage: not a kit part. A closed loft of 6 rings of 8, subdivided and given a wall ----------------------------------
section('a cage: not a kit part. A closed loft of 6 rings of 8, subdivided and given a wall')
bm = bmesh.new()
rings = [[bm.verts.new((r * math.cos(math.pi / 8 + k * math.pi / 4), r * math.sin(math.pi / 8 + k * math.pi / 4), z)) for k in range(8)]
for z, r in ((-1.0, 0.5), (-0.6, 0.7), (-0.2, 0.8), (0.2, 0.8), (0.6, 0.7), (1.0, 0.5))]
for low, high in zip(rings, rings[1:]):
for k in range(8):
bm.faces.new((low[k], low[(k + 1) % 8], high[(k + 1) % 8], high[k]))
bmesh.ops.recalc_face_normals(bm, faces=bm.faces[:])
mesh = bpy.data.meshes.new("Cage")
bm.to_mesh(mesh)
bm.free()
cage = bpy.data.objects.new("Cage", mesh)
bpy.context.scene.collection.objects.link(cage)
cage.modifiers.new("Subsurf", "SUBSURF").levels = 2
wall = cage.modifiers.new("Solidify", "SOLIDIFY")
wall.thickness, wall.offset, wall.use_even_offset = 0.05, -1.0, True
cage.matrix_world = Matrix.Translation((4.0, -1.0, 2.0)) @ Matrix.Rotation(0.6, 4, "Z") @ Matrix.Rotation(-0.3, 4, "X")
bpy.context.view_layer.update()
world = np.array(cage.matrix_world, dtype=np.float64)
uncut, _ = evaluated(cage)
check("the cage is a closed wall before it is cut", uncut["nonManifoldEdges"] == 0 and 0.15 < uncut["volume"] < 0.4 and "kit_part" not in cage, uncut)
R["cage"] = {"uncut": uncut}
# --- cut-orphan and closures-ends-first -----------------------------------------------------------------------------------------
strut = core.build(kits["mechanical"]["parts"]["strut"], {"width": 0.09})
end = {name: next(s for s in strut.sockets if s["name"] == name) for name in ("end_a", "end_b")}
for pair, y in (("Zz", -20.0), ("Aa", -24.0)): # two closures that share no part; the open one is named to sort first
anchor, loose = place(f"{pair}_Anchor", "strut", "width=0.09", location=[0.0, y, 0.0]), place(f"{pair}_Loose", "strut", "width=0.09")
meet = Matrix((np.array(anchor.matrix_world) @ core.mate(end["end_b"], end["end_a"], 40.0)).tolist())
send("setObjectTransform", targetObjectName=f"{pair}_Loose", location=list(meet.translation), rotationEuler=list(meet.to_euler("XYZ")))
send("brokkr_kitbash.close", object_name=f"{pair}_Loose", socket="end_a", other_name=f"{pair}_Anchor", other_socket="end_b")
send("brokkr_kitbash.set_params", object_name="Aa_Anchor", params="length=0.9") # opens Aa's closure
receipt, report = send("brokkr_kitbash.set_params", object_name="Zz_Anchor", params="width=0.09")
check("closures-ends-first: set_params on a part whose own closure holds lists it before another part's closure that is open, though that one sorts first by holds and by name",
receipt["status"] == "accepted" and report["closures"] == [{"part": "Zz_Loose", "to": "Zz_Anchor", "holds": True}, {"part": "Aa_Loose", "to": "Aa_Anchor", "holds": False}],
report and report.get("closures"))
ghost = bpy.data.objects["Aa_Anchor"]
with bpy.context.temp_override(selected_objects=[ghost], active_object=ghost):
bpy.ops.object.delete() # the ordinary Delete: Aa_Loose's closure still points at it, so it stays in the file, in no collection
tie = place("Tie", "strut", "width=0.09")
check("a part deleted with the Delete operator that a closure points to is still in the file", bpy.data.objects.get("Aa_Anchor") is not None and not ghost.users_collection, list(bpy.data.objects.keys()))
GONE = "'Aa_Anchor' is in no collection (a deleted object something still points to)"
refused("cut-orphan: attach onto a deleted part's name", "brokkr_kitbash.attach", {"object_name": "Tie", "socket": "end_a", "parent_name": "Aa_Anchor", "parent_socket": "end_a"}, GONE)
refused("attach of a deleted part", "brokkr_kitbash.attach", {"object_name": "Aa_Anchor", "socket": "end_a", "parent_name": "Tie", "parent_socket": "end_a"}, GONE)
refused("set_params on a deleted part", "brokkr_kitbash.set_params", {"object_name": "Aa_Anchor", "params": "length=1.0"}, GONE)
refused("report of a deleted part", "brokkr_kitbash.report", {"object_name": "Aa_Anchor"}, GONE)
refused("cut on a deleted part", "brokkr_kitbash.cut", {**RAY, "object_name": "Aa_Anchor"}, GONE)
refused("boolean on a deleted part", "brokkr_kitbash.boolean", {"object_name": "Aa_Anchor", "cutter": "Lump"}, GONE)
refused("boolean with a deleted part as the cutter", "brokkr_kitbash.boolean", {"object_name": "Tie", "cutter": "Aa_Anchor"}, GONE)
refused("close onto a deleted part", "brokkr_kitbash.close", {"object_name": "Tie", "socket": "end_a", "other_name": "Aa_Anchor", "other_socket": "end_a"}, GONE)
# --- cut-at-ray: a through bay, a blind round recess, a row of gills and a panel break --------------------------------------
section('cut-at-ray: a through bay, a blind round recess, a row of gills and a panel break')
CUTS = [("Bay", "box", (3.0, 0.0, 0.1), (-1.0, 0.0, 0.0), "width=0.3; height=0.3; depth=0.2", {}),
("Recess", "cyl", (-3.0, 0.1, 0.2), (2.0, 0.0, 0.0), "r=0.1; depth=0.02", {}),
("Gills", "slot", (0.1, 3.0, -0.2), (0.0, -1.0, 0.0), "width=0.3; height=0.04; count=4; pitch=0.08; depth=0.02", {}),
("Break", "slab", (0.0, -3.0, 0.3), (0.0, 1.0, 0.0), "length=0.6; depth=0.1", {"roll": 90.0})]
frames, volume, falls, reports = {}, uncut["volume"], [], {}
for name, part, origin, direction, params, more in CUTS:
hit, normal = cast(cage, origin, direction) # before this cutter exists; the cuts made so far are far from this ray
frames[name] = core.surface_frame(hit, normal, (0.0, 0.0, 1.0), more.get("roll", 0.0))
state = sorted(o.name for o in bpy.data.objects)
receipt, report = cut(name, part, origin, direction, params, **more)
reports[name] = report
cutter = bpy.data.objects.get(name)
ok = receipt["status"] == "accepted" and cutter is not None and sorted(o.name for o in bpy.data.objects) == sorted(state + [name])
ok = ok and cutter.parent == cage and np.array_equal(np.array(cutter.matrix_parent_inverse), np.eye(4))
ok = ok and reading("framed", np.abs(np.array(cutter.matrix_basis) - frames[name]).max()) < FRAMED
ok = ok and (cutter["kit_kit"], cutter["kit_part"]) == ("cutters", part) and bpy.context.scene.collection in cutter.users_collection
ok = ok and not cutter.hide_render and not cutter.hide_viewport and len(cutter.modifiers) == 0
check(f"cut places the {part} cutter {name} on the cage where the ray meets it: parented under an identity inverse, its basis the surface frame",
ok, [receipt["message"], cutter and np.array(cutter.matrix_basis).tolist(), frames[name].tolist()])
wanted = world @ frames[name]
check(f"cut reports {name} as a cutters part with its sockets in the world, and what cuts the cage, without evaluating it", report
and report["object"] == "Cage" and report["cutter"]["object"] == name and report["cutter"]["kit"] == "cutters" and "evaluated" not in report
and report["booleans"] == [{"cutter": n, "operation": "DIFFERENCE"} for n in [c[0] for c in CUTS][:len(frames)]]
and [s["name"] for s in report["cutter"]["sockets"]] == {"slab": [], "slot": ["floor", "floor_l", "floor_r"]}.get(part, ["floor"])
and (part == "slab" or np.abs(np.array(report["cutter"]["sockets"][0]["matrix"]) - wanted @ core.build(kits["cutters"]["parts"][part], report["cutter"]["params"]).sockets[0]["matrix"]).max() < 1e-4),
report)
shown, _ = evaluated(cage)
falls.append(shown["volume"] < volume - 1e-4 and shown["nonManifoldEdges"] == 0)
volume = shown["volume"]
R["cage"][name] = shown
modifier = cage.modifiers.get("Kit Difference")
check("four cuts give the cage one Boolean modifier after its own, over one collection of the four cutters in the order they came",
stack(cage) == ["Subsurf", "Solidify", "Kit Difference"] and modifier is not None
and (modifier.type, modifier.solver, modifier.use_self, modifier.operation, modifier.operand_type, modifier.material_mode) == ("BOOLEAN", "EXACT", True, "DIFFERENCE", "COLLECTION", "TRANSFER")
and [o.name for o in modifier.collection.objects] == [c[0] for c in CUTS] and modifier.collection.name == "Cage difference"
and not any(modifier.collection in s.collection.children_recursive for s in bpy.data.scenes), [stack(cage), modifier and modifier.operand_type])
check("the evaluated cage stays a closed wall and loses volume with each cut", all(falls) and len(falls) == 4, R["cage"])
receipt, report = send("brokkr_kitbash.report", object_name="")
check("report lists the cutters as kit parts and not the cage", report and [p["object"] for p in report["parts"]] == sorted(c[0] for c in CUTS)
and all(p["connection"] is None for p in report["parts"]), report and [p["object"] for p in report["parts"]])
R["ok"] = all(c["ok"] for c in R["checks"])
R["readings"] = {name: float(f"{value:.2g}") for name, value in sorted(R["readings"].items())}
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
print("READINGS", R["readings"], flush=True)
# --- cut-casts-the-uncut-surface --------------------------------------------------------------------------------------------
section('cut-casts-the-uncut-surface')
through = cast(cage, CUTS[0][2], CUTS[0][3])[0] # as the cage is evaluated now, with its cuts: through the bay to the far wall
receipt, report = cut("Bay2", "cyl", CUTS[0][2], CUTS[0][3], "r=0.05; depth=0.2")
again = bpy.data.objects.get("Bay2")
check("a second cut on the through bay's ray lands where the first did, on the surface as it was before any cut, though the ray now passes through the bay",
receipt["status"] == "accepted" and again is not None and np.linalg.norm(through - frames["Bay"][:3, 3]) > 1.0
and reading("recast", np.abs(np.array(again.matrix_basis)[:3, 3] - frames["Bay"][:3, 3]).max()) < RECAST
and stack(cage) == ["Subsurf", "Solidify", "Kit Difference"] and all(m.show_viewport for m in cage.modifiers),
[receipt["message"], through.tolist(), frames["Bay"][:3, 3].tolist(), again and list(again.matrix_basis.translation)])
# --- floor-carries-machinery ------------------------------------------------------------------------------------------------
section('floor-carries-machinery')
recess = bpy.data.objects["Recess"]
vent = place("Vent", "vent", "width=0.2; height=0.15") # back size 0.135; the floor's is 0.2
receipt, report = send("brokkr_kitbash.attach", object_name="Vent", socket="back", parent_name="Recess", parent_socket="floor", roll=30.0)
floor = world @ frames["Recess"] @ np.array(Matrix.Translation((0.0, 0.0, -0.02))) # the hit point, depth along the normal
back = frame(vent, "back")
check("a mechanical vent attaches to the round recess's floor: its back on the hit point taken depth down the normal, facing in, and the connection holds",
receipt["status"] == "accepted" and held(report) and vent.parent == recess and report["connection"]["parent"] == "Recess" and report["kit"] == "mechanical"
and reading("floored", max(np.abs(back[:3, 3] - floor[:3, 3]).max(), np.abs(back[:3, 2] + floor[:3, 2]).max())) < FLOORED,
[receipt["message"], back.tolist(), floor.tolist()])
big = place("Big", "vent", "width=0.8; height=0.6")
refused("a vent larger than the recess's floor", "brokkr_kitbash.attach", {"object_name": "Big", "socket": "back", "parent_name": "Recess", "parent_socket": "floor"},
"'Big' on 'Recess': socket 'back' (mount, size 0.54) and parent socket 'floor' (mount, size 0.2) are mount sockets, where the child fits the parent: it is larger")
nozzle = place("Nozzle", "nozzle")
refused("a flange on a floor", "brokkr_kitbash.attach", {"object_name": "Nozzle", "socket": "mount", "parent_name": "Recess", "parent_socket": "floor"}, "are of different types")
refused("a second part on the floor", "brokkr_kitbash.attach", {"object_name": "Nozzle", "socket": "mount", "parent_name": "Recess", "parent_socket": "floor"}, "'Nozzle' on 'Recess'")
refused("a part on a slab, which has no floor", "brokkr_kitbash.attach", {"object_name": "Big", "socket": "back", "parent_name": "Break", "parent_socket": "floor"},
"kit 'cutters' part 'slab' has no socket 'floor'; its sockets: none")
refused("detach of a cutter, which is placed and not attached", "brokkr_kitbash.detach", {"object_name": "Recess"}, "'Recess' is not attached")
before = evaluated(cage)[0]
moved_to = np.array(recess.matrix_basis)[:3, 3] + np.array(recess.matrix_basis)[:3, :3] @ [0.0, 0.25, 0.0] # along the cutter's own y: up the wall
was = frame(vent, "back")
send("setObjectTransform", targetObjectName="Recess", location=moved_to.tolist())
shift = frame(vent, "back")[:3, 3] - was[:3, 3]
after = evaluated(cage)[0]
check("setObjectTransform on the cutter moves the cut and the vent on its floor together: the vent still holds, and the cage is cut elsewhere",
reading("floored", np.abs(shift - world[:3, :3] @ (moved_to - frames["Recess"][:3, 3])).max()) < FLOORED and abs(np.linalg.norm(shift) - 0.25) < 1e-4
and (connection := send("brokkr_kitbash.report", object_name="Vent")[1]["parts"][0]["connection"])["holds"] is True
and after["nonManifoldEdges"] == 0 and after != before, [shift.tolist(), before, after])
was = frame(vent, "back")
receipt, report = send("brokkr_kitbash.set_params", object_name="Recess", params="depth=0.04")
sunk = frame(vent, "back")[:3, 3] - was[:3, 3]
deeper = evaluated(cage)[0]
check("set_params depth=0.04 on the cutter deepens the cut and seats the vent on the new floor, 0.02 further down the normal",
receipt["status"] == "accepted" and report["params"]["depth"] == 0.04 and reading("floored", np.abs(sunk + was[:3, 2] * -0.02).max()) < FLOORED
and send("brokkr_kitbash.report", object_name="Vent")[1]["parts"][0]["connection"]["holds"] is True
and deeper["volume"] < after["volume"] - 1e-5 and deeper["nonManifoldEdges"] == 0 and stack(cage) == ["Subsurf", "Solidify", "Kit Difference"],
[receipt["message"], sunk.tolist(), after, deeper])
R["cage"]["deeper"] = deeper
# --- cut_many: several cutters for one evaluation, all or none; an axis; a slot's three floors -----------------------------------
section("cut_many: several cutters for one evaluation, all or none; an axis; a slot's three floors")
MANY = [{"name": "Visor", "part": "slot", "params": "width=0.6; height=0.14; depth=0.02; lift=0.2", "origin": [0.6, 3.0, 0.5], "direction": [0.0, -1.0, 0.0]},
{"name": "Seam", "part": "slab", "params": "length=0.4; depth=0.1", "origin": [-0.5, -3.0, -0.7], "direction": [0.0, 1.0, 0.0], "up": [1.0, 0.0, 0.0], "axis": [0.0, -1.0, 0.0]},
{"name": "Port", "part": "cyl", "params": "r=0.05", "origin": [-0.6, 3.0, -0.5], "direction": [0.0, -2.0, 0.0], "up": [1.0, 0.0, 0.0], "roll": 45.0}]
wanted = {}
for spec in MANY:
hit, normal = uncut_cast(spec["origin"], spec["direction"])
wanted[spec["name"]] = core.surface_frame(hit, spec.get("axis", normal), spec.get("up", (0.0, 0.0, 1.0)), spec.get("roll", 0.0))
if "axis" in spec:
lean = float(np.degrees(np.arccos(np.clip(normal @ np.array(spec["axis"]), -1.0, 1.0))))
refused("cut_many whose second ray misses places none", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([MANY[0], {**MANY[1], "origin": [0.0, -3.0, 5.0]}])},
"The ray from (0.0, -3.0, 5.0) along (0.0, 1.0, 0.0) misses 'Cage'")
refused("cut_many with a name twice", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([MANY[0], {**MANY[1], "name": "Visor"}])}, "An object named 'Visor' exists in this call")
refused("cut_many with a name an object has", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([MANY[0], {**MANY[1], "name": "Bay"}])}, "An object named 'Bay' exists;")
refused("cut_many whose last cutter has a bad param", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps(MANY[:2] + [{**MANY[2], "params": "r=9"}])}, "param 'r' = 9.0 is outside")
refused("cut_many of text that is not JSON", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": "[{"}, "cuts is not JSON")
refused("cut_many of no cutters", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": "[]"}, "cuts must be a JSON array of 1 to 64 cutters")
refused("cut_many of a cutter with no direction", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([{k: v for k, v in MANY[0].items() if k != "direction"}])},
"cuts[0] must be an object with name, part, origin and direction")
refused("cut_many of a cutter with a key cut does not have", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([{**MANY[0], "operation": "UNION"}])}, "cuts[0] must be an object")
refused("cut_many of an origin of two numbers", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([{**MANY[0], "origin": [0.0, 1.0]}])}, "cuts[0].origin must be three numbers")
refused("cut_many of a roll of 400", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([{**MANY[0], "roll": 400}])}, "cuts[0].roll must be a number from -360 to 360")
refused("an axis that points into the surface", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([{**MANY[1], "axis": [0.0, 1.0, 0.0]}])}, "'Seam': the axis (0.0, 1.0, 0.0) points into the surface")
quad("Many", (0.0, -27.0, 0.0)) # a target of its own, cheap to evaluate should the 65 ever be placed
refused("M7: cut_many of 65 cutters, one over the limit", "brokkr_kitbash.cut_many",
{"object_name": "Many", "cuts": json.dumps([{"name": f"Over{k}", "part": "cyl", "params": "r=0.005", "origin": [0.4 - k * 0.012, 0.0, 3.0], "direction": [0.0, 0.0, -1.0], "up": [0.0, 1.0, 0.0]}
for k in range(65)])}, "cuts must be a JSON array of 1 to 64 cutters")
receipt, report = send("brokkr_kitbash.cut_many", object_name="Cage", cuts=json.dumps(MANY))
placed = [bpy.data.objects.get(spec["name"]) for spec in MANY]
check("cut_many places three cutters in one action, each as cut would: parented under an identity inverse, its basis the surface frame at its own ray on the uncut cage, in the difference collection in order",
receipt["status"] == "accepted" and all(placed) and report == {"object": "Cage", "cutters": ["Visor", "Seam", "Port"], "booleans": report["booleans"]}
and [row["cutter"] for row in report["booleans"]] == ["Bay", "Recess", "Gills", "Break", "Bay2", "Visor", "Seam", "Port"]
and all(c.parent == cage and np.array_equal(np.array(c.matrix_parent_inverse), np.eye(4))
and reading("framed", np.abs(np.array(c.matrix_basis) - wanted[c.name]).max()) < FRAMED for c in placed)
and stack(cage) == ["Subsurf", "Solidify", "Kit Difference"] and all(m.show_viewport for m in cage.modifiers) and evaluated(cage)[0]["nonManifoldEdges"] == 0,
[receipt["message"], report])
seam = bpy.data.objects["Seam"]
check("a slab with an axis stands on the axis, not on the wall's normal, which leans from it there", lean > 5.0
and reading("framed", np.abs(np.array(seam.matrix_basis)[:3, 2] - [0.0, -1.0, 0.0]).max()) < FRAMED, [lean, np.array(seam.matrix_basis).tolist()])
receipt, report = send("brokkr_kitbash.cut", object_name="Cage", cutter_name="Seam2", part="slab", params="length=0.3; depth=0.1", origin_x=0.5, origin_y=-3.0, origin_z=-0.7,
direction_x=0.0, direction_y=1.0, direction_z=0.0, up_x=1.0, up_y=0.0, up_z=0.0, axis_x=0.0, axis_y=-1.0, axis_z=0.0)
check("cut takes the same axis", receipt["status"] == "accepted" and reading("framed", np.abs(np.array(bpy.data.objects["Seam2"].matrix_basis)[:3, 2] - [0.0, -1.0, 0.0]).max()) < FRAMED, receipt["message"])
visor = bpy.data.objects["Visor"]
eyes = {}
for socket, x in (("floor", 0.0), ("floor_l", -0.23), ("floor_r", 0.23)): # the round ends' centres: -+(0.6 - 0.14) / 2
eye = place(f"Eye_{socket}", "vent", "width=0.2; height=0.15") # back size 0.135; each floor's is 0.14
receipt, report = send("brokkr_kitbash.attach", object_name=eye.name, socket="back", parent_name="Visor", parent_socket=socket)
there = world @ wanted["Visor"] @ np.array(Matrix.Translation((x, 0.0, -0.02)))
eyes[socket] = receipt["status"] == "accepted" and held(report) and eye.parent == visor \
and reading("floored", max(np.abs(frame(eye, "back")[:3, 3] - there[:3, 3]).max(), np.abs(frame(eye, "back")[:3, 2] + there[:3, 2]).max())) < FLOORED
check("slot-floors: a slot's three floors each take a part: at the centre and at the round ends, all on the slot's one floor plane", all(eyes.values()) and len(eyes) == 3, eyes)
refused("a second part on a side floor", "brokkr_kitbash.attach", {"object_name": "Nozzle", "socket": "mount", "parent_name": "Visor", "parent_socket": "floor_l"}, "'Nozzle' on 'Visor'")
refused("a fourth eye on a floor that is taken", "brokkr_kitbash.attach", {"object_name": "Big", "socket": "back", "parent_name": "Visor", "parent_socket": "floor_l"}, "'Big' on 'Visor'")
# --- boolean on any mesh, and the order of the three operations -----------------------------------------------------------------
section('boolean on any mesh, and the order of the three operations')
lump_at = world @ [0.0, 0.0, 1.0, 1.0]
send("createObject", objectType="MESH", name="Lump", location=lump_at[:3].tolist(), size=0.2)
receipt, report = send("brokkr_kitbash.boolean", object_name="Cage", cutter="Lump", operation="UNION")
check("boolean on the cage, which is not a kit part, adds a second modifier after the difference and reports the object, what cuts it and the evaluated mesh",
receipt["status"] == "accepted" and stack(cage) == ["Subsurf", "Solidify", "Kit Difference", "Kit Union"]
and sorted(report) == ["booleans", "evaluated", "object"] and report["object"] == "Cage" and report["evaluated"] == evaluated(cage)[0]
and report["booleans"] == [{"cutter": n, "operation": "DIFFERENCE"} for n in ("Bay", "Recess", "Gills", "Break", "Bay2", "Visor", "Seam", "Port", "Seam2")] + [{"cutter": "Lump", "operation": "UNION"}]
and report["evaluated"]["volume"] > deeper["volume"], [receipt["message"], report])
refused("cut-refusals: a cutter already in the target's union collection", "brokkr_kitbash.boolean", {"object_name": "Cage", "cutter": "Lump"},
"'Lump' already cuts 'Cage' (its Kit Union modifier's collection)")
refused("a cut's own cutter given to boolean again", "brokkr_kitbash.boolean", {"object_name": "Cage", "cutter": "Bay", "operation": "INTERSECT"},
"'Bay' already cuts 'Cage' (its Kit Difference modifier's collection)")
blocked = cast(cage, (-0.3, 0.0, 0.95), (1.0, 0.0, 0.0))[0] # as evaluated now: the ray meets Lump, which the union added inside the cage's mouth
hit, normal = uncut_cast((-0.3, 0.0, 0.95), (1.0, 0.0, 0.0))
receipt, report = cut("Past", "cyl", (-0.3, 0.0, 0.95), (1.0, 0.0, 0.0), "r=0.02; depth=0.01")
past = bpy.data.objects.get("Past")
check("M3: a cut whose ray meets what a union added lands on the surface as designed: the cast has the Kit Union off too",
receipt["status"] == "accepted" and past is not None and np.linalg.norm(blocked - hit) > 0.3
and reading("framed", np.abs(np.array(past.matrix_basis) - core.surface_frame(hit, normal, (0.0, 0.0, 1.0))).max()) < FRAMED
and all(m.show_viewport for m in cage.modifiers), [receipt["message"], blocked.tolist(), hit.tolist(), past and list(past.matrix_basis.translation)])
plate = place("Plate", "plate", location=[0.0, -6.0, 0.0])
for name, size, operation in (("Boss", 0.06, "UNION"), ("Keep", 2.0, "INTERSECT"), ("Hole", 0.05, "DIFFERENCE")):
send("createObject", objectType="MESH", name=name, location=[0.0, -6.0, 0.0], size=size)
receipt, report = send("brokkr_kitbash.boolean", object_name="Plate", cutter=name, operation=operation)
check("a part cut by union, then intersect, then difference carries the three modifiers as difference, union, intersect, above its Bevel, and lists its cutters so",
receipt["status"] == "accepted" and stack(plate) == ["Kit Difference", "Kit Union", "Kit Intersect", "Kit Bevel"]
and report["booleans"] == [{"cutter": "Hole", "operation": "DIFFERENCE"}, {"cutter": "Boss", "operation": "UNION"}, {"cutter": "Keep", "operation": "INTERSECT"}]
and report["evaluated"]["nonManifoldEdges"] == 0 and report["kit"] == "mechanical", [stack(plate), report and report["booleans"]])
THAW = "thaw it first"
shown, cage_shown, collections = evaluated(plate)[0], evaluated(cage)[0], len(bpy.data.collections)
receipt, frozen = send("brokkr_kitbash.freeze", object_name="Plate")
check("freeze keeps the three modifiers, off, the three collections they read and every cutter in the scene", receipt["status"] == "accepted"
and frozen["booleans"] == report["booleans"] and len(bpy.data.collections) == collections and frozen["modifiers"] == stack(plate) == ["Kit Difference", "Kit Union", "Kit Intersect", "Kit Bevel"]
and not any(m.show_viewport or m.show_render for m in plate.modifiers) and frozen["evaluated"] == shown == evaluated(plate)[0]
and all(name in bpy.context.scene.objects for name in ("Hole", "Boss", "Keep")), [receipt["message"], frozen, shown])
cage_stack, cage_mesh = stack(cage), cage.data.name
receipt, frozen = send("brokkr_kitbash.freeze", object_name="Cage")
check("freeze takes the cage, which is not a kit part: its evaluated wall, its stack off, its cutters still its children", receipt["status"] == "accepted" and frozen["object"] == "Cage"
and "kit" not in frozen and frozen["frozen"] is True and frozen["evaluated"] == cage_shown == evaluated(cage)[0]
and frozen["modifiers"] == stack(cage) == cage_stack and not any(m.show_viewport or m.show_render for m in cage.modifiers) and cage.data.name == "Cage frozen"
and bpy.data.objects["Bay"].parent == cage and len(bpy.data.collections) == collections, [receipt["message"], frozen and frozen["modifiers"], cage_shown])
refused("ribs from a frozen cage", "brokkr_kitbash.ribs", {"object_name": "Cage", "ribs_name": "ColdRibs", "planes": json.dumps([{"origin": [0.0, 0.0, 0.5], "normal": [0.0, 0.0, 1.0]}])}, THAW)
refused("cut on a frozen cage", "brokkr_kitbash.cut", {"object_name": "Cage", "cutter_name": "Late", "part": "box", "origin_x": 3.0, "origin_y": 0.0, "origin_z": 0.1,
"direction_x": -1.0, "direction_y": 0.0, "direction_z": 0.0}, THAW)
refused("cut_many on a frozen cage", "brokkr_kitbash.cut_many", {"object_name": "Cage", "cuts": json.dumps([{"name": "Late", "part": "box", "origin": [3.0, 0.0, 0.1], "direction": [-1.0, 0.0, 0.0]}])}, THAW)
refused("boolean on a frozen cage", "brokkr_kitbash.boolean", {"object_name": "Cage", "cutter": "Hole"}, THAW)
for name in ("Plate", "Cage"):
receipt, thawed = send("brokkr_kitbash.thaw", object_name=name)
check("thaw gives both back: the live meshes, every modifier on, the frozen meshes gone, and the same evaluated shapes", receipt["status"] == "accepted"
and thawed == {"object": "Cage", "frozen": False, "modifiers": cage_stack, "faces": len(cage.data.polygons)} and cage.data.name == cage_mesh
and all(m.show_viewport and m.show_render for o in (plate, cage) for m in o.modifiers) and not any(n in bpy.data.meshes for n in ("Cage frozen", "Plate frozen"))
and "kit_frozen" not in cage and "kit_frozen" not in plate and evaluated(plate)[0] == shown and evaluated(cage)[0] == cage_shown,
[receipt["message"], thawed, sorted(m.name for m in bpy.data.meshes)])
twin = place("Twin", "plate", location=[0.0, -15.0, 0.0])
send("createObject", objectType="MESH", name="TwinHole", location=[0.0, -15.0, 0.0], size=0.05)
send("brokkr_kitbash.boolean", object_name="Twin", cutter="TwinHole")
copied = twin.copy() # a copied part: its own mesh, and a Kit Difference modifier that reads the same collection
copied.data = twin.data.copy()
bpy.context.scene.collection.objects.link(copied)
receipt, frozen = send("brokkr_kitbash.freeze", object_name="Twin")
kept = bpy.data.collections.get("Twin difference")
check("M6: a frozen part and its copy still read the one collection, and the copy stays live", receipt["status"] == "accepted" and kept is not None
and twin.modifiers["Kit Difference"].collection == kept == copied.modifiers["Kit Difference"].collection and [o.name for o in kept.objects] == ["TwinHole"]
and "kit_frozen" in twin and all(m.show_viewport for m in copied.modifiers), [receipt["message"], [c.name for c in bpy.data.collections]])
send("brokkr_kitbash.thaw", object_name="Twin")
RINGS = [[[x, y, 0.1 - x * x] for x in (-0.3, -0.1, 0.1, 0.3)] for y in (0.0, 0.2, 0.4)]
lid = {"object_name": "Lid", "sheet": json.dumps({"rings": RINGS}), "thickness": 0.02, "levels": 2}
send("brokkr_kitbash.shell", **lid)
send("setObjectTransform", targetObjectName="Lid", location=[0.0, -30.0, 0.0])
wall = evaluated(bpy.data.objects["Lid"])[0]
receipt, frozen = send("brokkr_kitbash.freeze", object_name="Lid")
check("freeze takes a shell: the wall its Kit Subsurf and Kit Solidify make", receipt["status"] == "accepted" and frozen["modifiers"] == ["Kit Subsurf", "Kit Solidify"]
and frozen["evaluated"] == wall and wall["faces"] > 2 * 6 * 16, [receipt["message"], frozen, wall])
refused("a rebuild of a frozen shell", "brokkr_kitbash.shell", lid, THAW)
refused("a rebuild of a frozen shell that counts folds", "brokkr_kitbash.shell", {**lid, "count_folds": True}, THAW)
send("brokkr_kitbash.thaw", object_name="Lid")
receipt, rebuilt = send("brokkr_kitbash.shell", **lid)
check("and thawed, the shell rebuilds", receipt["status"] == "accepted" and rebuilt["rebuilt"] is True and evaluated(bpy.data.objects["Lid"])[0] == wall, [receipt["message"], rebuilt])
# --- cut-refusals -----------------------------------------------------------------------------------------------------------
section('cut-refusals')
RAY = {"object_name": "Cage", "cutter_name": "New", "part": "box", "origin_x": 3.0, "origin_y": 0.0, "origin_z": 0.1, "direction_x": -1.0, "direction_y": 0.0, "direction_z": 0.0}
refused("a ray that misses", "brokkr_kitbash.cut", {**RAY, "origin_z": 5.0}, "The ray from (3.0, 0.0, 5.0) along (-1.0, 0.0, 0.0) misses 'Cage'")
refused("a ray of no direction", "brokkr_kitbash.cut", {**RAY, "direction_x": 0.0}, "'New': the ray's direction is zero")
refused("a cutter name an object has", "brokkr_kitbash.cut", {**RAY, "cutter_name": "Bay"}, "An object named 'Bay' exists")
refused("a param the cutter part does not have", "brokkr_kitbash.cut", {**RAY, "params": "radius=0.1"}, "kit 'cutters' part 'box' has no param 'radius'")
refused("a slot wider across than along", "brokkr_kitbash.cut", {**RAY, "part": "slot", "params": "width=0.05; height=0.1"}, "every size must be above 0")
refused("a target that is not a mesh", "brokkr_kitbash.cut", {**RAY, "object_name": "Nothing"}, "No mesh object named 'Nothing'")
block = bpy.data.objects.new("Block", bpy.data.meshes.new("Block"))
bm = bmesh.new()
bmesh.ops.create_cube(bm, size=1.0)
bm.to_mesh(block.data)
bm.free()
bpy.context.scene.collection.objects.link(block)
block.location = (0.0, -9.0, 0.0)
bpy.context.view_layer.update()
DOWN = {**RAY, "object_name": "Block", "origin_x": 0.1, "origin_y": 0.1, "origin_z": 3.0, "direction_x": 0.0, "direction_z": -1.0}
refused("an up along the hit normal", "brokkr_kitbash.cut", DOWN, "up [0.0, 0.0, 1.0] runs along the surface normal [0.0, 0.0, 1.0]")
block.scale = (1.0, 1.0, 1.01)
bpy.context.view_layer.update()
refused("a scaled target", "brokkr_kitbash.cut", {**DOWN, "up_y": 1.0, "up_z": 0.0}, "'Block' is scaled, mirrored or sheared in the world (scale 1, 1, 1.01)")
refused("boolean on a scaled target", "brokkr_kitbash.boolean", {"object_name": "Block", "cutter": "Lump"}, "'Block' is scaled, mirrored or sheared")
block.scale = (1.0, 1.0, 1.0)
bpy.context.view_layer.update()
receipt, report = send("brokkr_kitbash.cut", **{**DOWN, "cutter_name": "Pocket", "up_y": 1.0, "up_z": 0.0, "roll": 90.0})
pocket = bpy.data.objects.get("Pocket")
check("a cut on a plain cube with up +y and roll 90: the cutter's y points along -x, its floor 0.02 under the top face", receipt["status"] == "accepted" and pocket is not None
and np.abs(np.array(pocket.matrix_basis) - [[0, -1, 0, 0.1], [1, 0, 0, 0.1], [0, 0, 1, 0.5], [0, 0, 0, 1]]).max() < 1e-6
and np.abs(np.array(report["cutter"]["sockets"][0]["matrix"])[:3, 3] - [0.1, -8.9, 0.48]).max() < 1e-6 and stack(block) == ["Kit Difference"],
[receipt["message"], pocket and np.array(pocket.matrix_basis).tolist()])
# --- lows-pinned: the surface's side, an axis along it, and an object Blender does not evaluate --------------------------------
section("lows-pinned: the surface's side, an axis along it, and an object Blender does not evaluate")
sheet = quad("Sheet", (0.0, -12.0, 0.0))
UNDER = {"object_name": "Sheet", "cutter_name": "Under", "part": "cyl", "origin_x": 0.1, "origin_y": 0.1, "origin_z": -3.0, "direction_x": 0.0, "direction_y": 0.0, "direction_z": 1.0,
"up_x": 0.0, "up_y": 1.0, "up_z": 0.0}
refused("M1: an axis exactly along the surface, neither out of it nor into it", "brokkr_kitbash.cut", {**UNDER, "cutter_name": "Along", "origin_z": 3.0, "direction_z": -1.0, "axis_x": 1.0},
"'Along': the axis (1.0, 0.0, 0.0) points into the surface")
receipt, report = send("brokkr_kitbash.cut", **UNDER)
under = bpy.data.objects.get("Under")
check("M16: a ray that meets a one-sided face from behind gives a cutter whose z faces the ray, against the face's own normal", receipt["status"] == "accepted" and under is not None
and reading("framed", np.abs(np.array(under.matrix_basis)[:3, 2] - [0.0, 0.0, -1.0]).max()) < FRAMED, [receipt["message"], under and np.array(under.matrix_basis).tolist()])
loose = place("Loose", "plate", location=[0.0, -18.0, 0.0])
apart = bpy.data.collections.new("Apart") # a collection no scene holds: Loose is in a collection, and in no view layer
apart.objects.link(loose)
bpy.context.scene.collection.objects.unlink(loose)
veil = quad("Veil", (0.0, -21.0, 0.0)) # nothing depends on it: a disabled object another evaluated object needs (a parent, a cutter) is still evaluated
veil.hide_viewport = plate.hide_viewport = True
bpy.context.view_layer.update()
for name, why in (("Veil", "disabled in viewports"), ("Loose", "in a collection outside the view layer")):
NOT = f"Blender does not evaluate {name!r} in this view layer"
refused(f"unevaluable-target: cut on a target {why}", "brokkr_kitbash.cut", {**DOWN, "object_name": name, "cutter_name": "Unseen", "up_y": 1.0, "up_z": 0.0}, NOT)
refused(f"cut_many on a target {why}", "brokkr_kitbash.cut_many",
{"object_name": name, "cuts": json.dumps([{"name": "Unseen", "part": "box", "origin": [0.1, 0.1, 3.0], "direction": [0.0, 0.0, -1.0], "up": [0.0, 1.0, 0.0]}])}, NOT)
refused(f"boolean on a target {why}", "brokkr_kitbash.boolean", {"object_name": name, "cutter": "Sheet"}, NOT)
refused("freeze on a part disabled in viewports", "brokkr_kitbash.freeze", {"object_name": "Plate"}, "Blender does not evaluate 'Plate' in this view layer")
refused("freeze on a part in a collection outside the view layer", "brokkr_kitbash.freeze", {"object_name": "Loose"}, "Blender does not evaluate 'Loose' in this view layer")
veil.hide_viewport = plate.hide_viewport = False
bpy.context.view_layer.update()
# --- receipt-fitted: rows that would not fit a receipt are left off and counted; the scene keeps the cutters ---------------------
section('receipt-fitted: rows that would not fit a receipt are left off and counted; the scene keeps the cutters')
addon = sys.modules["brokkr_kitbash"]
limit, fits = addon.REPORT_LIMIT, {}
SPOT = {"part": "cyl", "params": "r=0.03", "direction": [0.0, 0.0, -1.0], "up": [0.0, 1.0, 0.0]}
try:
addon.REPORT_LIMIT = 200
fits["cut"] = send("brokkr_kitbash.cut", **{**DOWN, "cutter_name": "Fit1", "part": "cyl", "params": "r=0.03", "origin_x": -0.3, "up_y": 1.0, "up_z": 0.0})
fits["cut_many"] = send("brokkr_kitbash.cut_many", object_name="Block", cuts=json.dumps([{**SPOT, "name": "Fit2", "origin": [-0.3, -0.3, 3.0]}, {**SPOT, "name": "Fit3", "origin": [0.3, -0.3, 3.0]}]))
fits["boolean"] = send("brokkr_kitbash.boolean", object_name="Block", cutter="Lump", operation="UNION")
finally:
addon.REPORT_LIMIT = limit
ROWS = [{"cutter": name, "operation": "DIFFERENCE"} for name in ("Pocket", "Fit1", "Fit2", "Fit3")] + [{"cutter": "Lump", "operation": "UNION"}]
for action, total, keeps in (("cut", 2, 0), ("cut_many", 4, 2), ("boolean", 5, 1)): # rows the scene had after each action, and how many of them 200 characters carry
receipt, report = fits[action]
check(f"receipt-fitted: {action} past what a receipt carries is accepted, its booleans cut short and the rest counted in booleansOmitted", receipt["status"] == "accepted"
and report is not None and report["booleans"] == ROWS[:keeps] and report.get("booleansOmitted") == total - keeps and (keeps == 0 or len(receipt["hostResult"]) <= 200),
[receipt["message"], receipt.get("hostResult")])
check("the scene keeps every cutter a short receipt left off", [o.name for o in block.modifiers["Kit Difference"].collection.objects] == ["Pocket", "Fit1", "Fit2", "Fit3"]
and [o.name for o in block.modifiers["Kit Union"].collection.objects] == ["Lump"], stack(block))
receipt, report = send("brokkr_kitbash.boolean", object_name="Block", cutter="Sheet", operation="INTERSECT")
check("a report that fits carries every row and no count", receipt["status"] == "accepted" and report["booleans"] == ROWS + [{"cutter": "Sheet", "operation": "INTERSECT"}]
and "booleansOmitted" not in report, report)
# --- cut-orphan and closures-ends-first -----------------------------------------------------------------------------------------
section('cut-orphan and closures-ends-first')
strut = core.build(kits["mechanical"]["parts"]["strut"], {"width": 0.09})
end = {name: next(s for s in strut.sockets if s["name"] == name) for name in ("end_a", "end_b")}
for pair, y in (("Zz", -20.0), ("Aa", -24.0)): # two closures that share no part; the open one is named to sort first
anchor, loose = place(f"{pair}_Anchor", "strut", "width=0.09", location=[0.0, y, 0.0]), place(f"{pair}_Loose", "strut", "width=0.09")
meet = Matrix((np.array(anchor.matrix_world) @ core.mate(end["end_b"], end["end_a"], 40.0)).tolist())
send("setObjectTransform", targetObjectName=f"{pair}_Loose", location=list(meet.translation), rotationEuler=list(meet.to_euler("XYZ")))
send("brokkr_kitbash.close", object_name=f"{pair}_Loose", socket="end_a", other_name=f"{pair}_Anchor", other_socket="end_b")
send("brokkr_kitbash.set_params", object_name="Aa_Anchor", params="length=0.9") # opens Aa's closure
receipt, report = send("brokkr_kitbash.set_params", object_name="Zz_Anchor", params="width=0.09")
check("closures-ends-first: set_params on a part whose own closure holds lists it before another part's closure that is open, though that one sorts first by holds and by name",
receipt["status"] == "accepted" and report["closures"] == [{"part": "Zz_Loose", "to": "Zz_Anchor", "holds": True}, {"part": "Aa_Loose", "to": "Aa_Anchor", "holds": False}],
report and report.get("closures"))
ghost = bpy.data.objects["Aa_Anchor"]
with bpy.context.temp_override(selected_objects=[ghost], active_object=ghost):
bpy.ops.object.delete() # the ordinary Delete: Aa_Loose's closure still points at it, so it stays in the file, in no collection
tie = place("Tie", "strut", "width=0.09")
check("a part deleted with the Delete operator that a closure points to is still in the file", bpy.data.objects.get("Aa_Anchor") is not None and not ghost.users_collection, list(bpy.data.objects.keys()))
GONE = "'Aa_Anchor' is in no collection (a deleted object something still points to)"
refused("cut-orphan: attach onto a deleted part's name", "brokkr_kitbash.attach", {"object_name": "Tie", "socket": "end_a", "parent_name": "Aa_Anchor", "parent_socket": "end_a"}, GONE)
refused("attach of a deleted part", "brokkr_kitbash.attach", {"object_name": "Aa_Anchor", "socket": "end_a", "parent_name": "Tie", "parent_socket": "end_a"}, GONE)
refused("set_params on a deleted part", "brokkr_kitbash.set_params", {"object_name": "Aa_Anchor", "params": "length=1.0"}, GONE)
refused("report of a deleted part", "brokkr_kitbash.report", {"object_name": "Aa_Anchor"}, GONE)
refused("cut on a deleted part", "brokkr_kitbash.cut", {**RAY, "object_name": "Aa_Anchor"}, GONE)
refused("boolean on a deleted part", "brokkr_kitbash.boolean", {"object_name": "Aa_Anchor", "cutter": "Lump"}, GONE)
refused("boolean with a deleted part as the cutter", "brokkr_kitbash.boolean", {"object_name": "Tie", "cutter": "Aa_Anchor"}, GONE)
refused("close onto a deleted part", "brokkr_kitbash.close", {"object_name": "Tie", "socket": "end_a", "other_name": "Aa_Anchor", "other_socket": "end_a"}, GONE)
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, not a missing result file
check(f"no uncaught error in section: {SECTION[0]}", False, traceback.format_exc().splitlines()[-6:])
finally:
R["ok"] = all(c["ok"] for c in R["checks"])
R["readings"] = {name: float(f"{value:.2g}") for name, value in sorted(R["readings"].items())}
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
print("READINGS", R["readings"], flush=True)
sys.exit(0 if R["ok"] else 1)

View file

@ -162,7 +162,7 @@
"detail": null
},
{
"name": "refused, scene unchanged: cut_many whose report would not fit a receipt places none",
"name": "refused, scene unchanged: M7: cut_many of 65 cutters, one over the limit",
"ok": true,
"detail": null
},
@ -182,7 +182,7 @@
"detail": null
},
{
"name": "a slot's three floors each take a part: at the centre and a third of the width to each side, all on the slot's one floor plane",
"name": "slot-floors: a slot's three floors each take a part: at the centre and at the round ends, all on the slot's one floor plane",
"ok": true,
"detail": null
},
@ -211,18 +211,73 @@
"ok": true,
"detail": null
},
{
"name": "M3: a cut whose ray meets what a union added lands on the surface as designed: the cast has the Kit Union off too",
"ok": true,
"detail": null
},
{
"name": "a part cut by union, then intersect, then difference carries the three modifiers as difference, union, intersect, above its Bevel, and lists its cutters so",
"ok": true,
"detail": null
},
{
"name": "apply removes the three collections its modifiers held and leaves every cutter in the scene",
"name": "freeze keeps the three modifiers, off, the three collections they read and every cutter in the scene",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: apply on the cage, which is not a kit part",
"name": "freeze takes the cage, which is not a kit part: its evaluated wall, its stack off, its cutters still its children",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: ribs from a frozen cage",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: cut on a frozen cage",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: cut_many on a frozen cage",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: boolean on a frozen cage",
"ok": true,
"detail": null
},
{
"name": "thaw gives both back: the live meshes, every modifier on, the frozen meshes gone, and the same evaluated shapes",
"ok": true,
"detail": null
},
{
"name": "M6: a frozen part and its copy still read the one collection, and the copy stays live",
"ok": true,
"detail": null
},
{
"name": "freeze takes a shell: the wall its Kit Subsurf and Kit Solidify make",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a rebuild of a frozen shell",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a rebuild of a frozen shell that counts folds",
"ok": true,
"detail": null
},
{
"name": "and thawed, the shell rebuilds",
"ok": true,
"detail": null
},
@ -276,6 +331,81 @@
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: M1: an axis exactly along the surface, neither out of it nor into it",
"ok": true,
"detail": null
},
{
"name": "M16: a ray that meets a one-sided face from behind gives a cutter whose z faces the ray, against the face's own normal",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: unevaluable-target: cut on a target disabled in viewports",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: cut_many on a target disabled in viewports",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: boolean on a target disabled in viewports",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: unevaluable-target: cut on a target in a collection outside the view layer",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: cut_many on a target in a collection outside the view layer",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: boolean on a target in a collection outside the view layer",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: freeze on a part disabled in viewports",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: freeze on a part in a collection outside the view layer",
"ok": true,
"detail": null
},
{
"name": "receipt-fitted: cut past what a receipt carries is accepted, its booleans cut short and the rest counted in booleansOmitted",
"ok": true,
"detail": null
},
{
"name": "receipt-fitted: cut_many past what a receipt carries is accepted, its booleans cut short and the rest counted in booleansOmitted",
"ok": true,
"detail": null
},
{
"name": "receipt-fitted: boolean past what a receipt carries is accepted, its booleans cut short and the rest counted in booleansOmitted",
"ok": true,
"detail": null
},
{
"name": "the scene keeps every cutter a short receipt left off",
"ok": true,
"detail": null
},
{
"name": "a report that fits carries every row and no count",
"ok": true,
"detail": null
},
{
"name": "closures-ends-first: set_params on a part whose own closure holds lists it before another part's closure that is open, though that one sorts first by holds and by name",
"ok": true,
@ -329,7 +459,7 @@
],
"hostErrors": [],
"readings": {
"floored": 2.6e-07,
"floored": 3.3e-07,
"framed": 5.1e-07,
"recast": 0.0
},

View file

@ -6,12 +6,15 @@ and does what its doc says to real bpy meshes and images. Not part of the unitte
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). Every action is sent through BrokkrBlenderTarget.run_intent, as tools/run_intents.py sends it.
With BROKKR_POLISH_HULLS=<a directory of generated .glb hulls> it also repairs each and checks that no face was
turned. Writes <out>.result.json and exits 1 when a check failed.
turned. Writes <out>.result.json and exits 1 when a check failed. The checks run inside one try: an uncaught error is a failed check that names
the check before it, the checks are printed and the result file written whatever happened, and the exit is 1 with or
without --python-exit-code.
"""
import json
import math
import os
import sys
import traceback
import types
from pathlib import Path
@ -47,6 +50,10 @@ RATIO_BOUND, DEFICIT_BOUND, SHADE_BOUND = 1.906, 0.136, 0.684 # each derived wh
def check(name, ok, detail=None):
try:
json.dumps(detail, default=str)
except TypeError: # a detail keyed by tuples: the result file takes it as text, so a failed check is written and not a crash
detail = repr(detail)
R["checks"].append({"name": name, "ok": bool(ok), "detail": detail})
@ -94,334 +101,337 @@ def pixels_of(obj):
return flat.reshape(image.size[1], image.size[0], 4)[..., :3], image
check("host file admitted", not R["hostErrors"] and len(R["hostRows"]) == 7, R["hostErrors"] or R["hostRows"])
try:
check("host file admitted", not R["hostErrors"] and len(R["hostRows"]) == 7, R["hostErrors"] or R["hostRows"])
# --- audit and repair: a generator's sphere, torn at every edge, half its faces wound inside out under outward
# --- custom normals, is welded back into one closed shell with no face turned and its shading normals intact ------
size = 256
rows = np.clip(((np.arange(size) + 0.5) / size - 0.1) / 0.8, 0.0, 1.0) # latitude: 0 at the south pole, 1 at the north
baked = np.repeat((0.8 * (0.2 + 0.8 * rows))[:, None, None], size, axis=1) * np.ones((1, 1, 3))
# --- audit and repair: a generator's sphere, torn at every edge, half its faces wound inside out under outward
# --- custom normals, is welded back into one closed shell with no face turned and its shading normals intact ------
size = 256
rows = np.clip(((np.arange(size) + 0.5) / size - 0.1) / 0.8, 0.0, 1.0) # latitude: 0 at the south pole, 1 at the north
baked = np.repeat((0.8 * (0.2 + 0.8 * rows))[:, None, None], size, axis=1) * np.ones((1, 1, 3))
def ball(bm):
bmesh.ops.create_uvsphere(bm, u_segments=48, v_segments=24, radius=1.0, calc_uvs=True)
layer = bm.loops.layers.uv.active
for face in bm.faces: # the island sits inside the texture with a margin, as a generator's atlas does
for loop in face.loops:
loop[layer].uv = loop[layer].uv * 0.8 + Vector((0.1, 0.1))
sphere = new_object("Ball", ball, new_image("ball_bake", baked.astype(np.float32)))
sphere.data.polygons.foreach_set("use_smooth", [True] * len(sphere.data.polygons))
torn = bmesh.new()
torn.from_mesh(sphere.data)
bmesh.ops.split_edges(torn, edges=torn.edges[:])
inside_out = [f for f in torn.faces if f.calc_center_median().x > 0]
reversed_faces, reversed_triangles = len(inside_out), sum(len(f.verts) - 2 for f in inside_out)
bmesh.ops.reverse_faces(torn, faces=inside_out)
torn.to_mesh(sphere.data)
torn.free()
sphere.data.normals_split_custom_set([tuple(sphere.data.vertices[loop.vertex_index].co.normalized()) for loop in sphere.data.loops])
def polygon_normals(mesh):
flat = np.empty(len(mesh.polygons) * 3, dtype=np.float32)
mesh.polygons.foreach_get("normal", flat)
return flat.reshape(-1, 3)
def shading_error(mesh):
"""The worst angle, in degrees, between a corner's shading normal and the sphere's own outward direction."""
flat = np.empty(len(mesh.loops) * 3, dtype=np.float32)
mesh.corner_normals.foreach_get("vector", flat)
outward = np.array([mesh.vertices[loop.vertex_index].co.normalized() for loop in mesh.loops])
return float(np.degrees(np.arccos(np.clip((flat.reshape(-1, 3) * outward).sum(axis=1), -1, 1))).max())
receipt, before = send("brokkr_mesh_polish.audit", object_name="Ball")
check("audit: accepted, no undo step", receipt["status"] == "accepted" and not receipt.get("undoLabel"), receipt["message"])
check("audit: welded topology sees one closed shell in the torn sphere",
before["Ball"]["shells"] == 1 and before["Ball"]["boundaryEdges"] == 0 and before["Ball"]["nonManifoldEdges"] == 0, before["Ball"])
check("audit: texture and UV facts", before["Ball"]["baseColorSize"] == [size, size] and before["Ball"]["uvOverlap"] < 0.02
and before["Ball"]["texelDensityMedian"] > 0 and 0.55 < before["Ball"]["uvCoverage"] < 0.64, before["Ball"]) # an 0.8 x 0.8 island less the pole gaps
check("audit: counts the triangles wound against their shading normals, and none of them as a mirrored texture",
reversed_triangles > 1000 and before["Ball"]["windingAgainstNormals"] == reversed_triangles
and before["Ball"]["uvMirroredTriangles"] == 0, [reversed_triangles, before["Ball"].get("windingAgainstNormals"), before["Ball"].get("uvMirroredTriangles")])
torn_vertices, normals_before = len(sphere.data.vertices), polygon_normals(sphere.data)
receipt, repaired = send("brokkr_mesh_polish.repair", object_name="Ball")
check("repair: accepted as one undo step", receipt["status"] == "accepted" and "repair" in receipt.get("undoLabel", ""), receipt)
check("repair: welds the torn vertices", repaired["changes"]["welded"] == torn_vertices - len(sphere.data.vertices)
and len(sphere.data.vertices) == 48 * 23 + 2, repaired)
check("repair: every edge has two faces again", len(sphere.data.edges) == 48 * 23 + 48 * 24, len(sphere.data.edges))
normals_after = polygon_normals(sphere.data)
turned = int(((normals_before * normals_after).sum(axis=1) < 0).sum()) if len(normals_before) == len(normals_after) else -1
R["winding"] = {"reversedTriangles": reversed_triangles, "turnedByDefaultRepair": turned, "shadingErrorDegrees": shading_error(sphere.data)}
check("repair: by default turns no face (a single-sided material would cull a turned one)",
turned == 0 and repaired["changes"]["windingFlipped"] == 0
and repaired["after"]["windingAgainstNormals"] == repaired["before"]["windingAgainstNormals"] == reversed_triangles, [turned, repaired])
check("repair: the shading normals survive the weld", "custom_normal" in sphere.data.attributes and R["winding"]["shadingErrorDegrees"] < 0.5
and not repaired["changes"]["customNormalsDropped"], R["winding"])
# --- delight: a bake that darkens with latitude is levelled, reading the shading normals, not the windings --------
receipt, lit = send("brokkr_mesh_polish.delight", object_name="Ball", clusters=1, fit_size=128, occlusion_rays=8, max_gain=8)
after_pixels, after_image = pixels_of(sphere)
column = after_pixels[:, size // 2, 0]
north, south = int(size * (0.1 + 0.8 * 0.9)), int(size * (0.1 + 0.8 * 0.1)) # rows at latitude 0.9 and 0.1
ratio_before = float(baked[north, 0, 0] / baked[south, 0, 0])
ratio_after = float(column[north] / column[south])
# On the island's left border the gain field meets texels no triangle covers. With the field filled outward the
# border reads as the middle of the row does; left unfilled, the neutral gain of the uncovered texels bleeds in.
border = int(math.ceil(size * 0.1))
deficit = float(np.median(1.0 - after_pixels[south - 8:south + 8, border, 0] / after_pixels[south - 8:south + 8, size // 2, 0]))
R["delight"] = {"report": lit, "ratioBefore": ratio_before, "ratioAfter": ratio_after, "borderDeficit": deficit}
check("delight: accepted, new packed image on the material, in the old image's colour space", receipt["status"] == "accepted"
and after_image.name == "ball_bake.delit" and after_image.packed_file is not None
and after_image.colorspace_settings.name == "Non-Color", [receipt["message"], after_image.colorspace_settings.name])
check("delight: finds the baked light", lit["explainedByLight"]["before"] > 0.5 and lit["before"]["upDownLuminanceRatio"] > 2.0, lit)
# bound: shipped ratioAfter 1.114; a no-op leaves 3.261 and so do normals taken from the windings (the inside-out half
# cancels the light the fit could find): sqrt(1.114 * 3.261) = 1.906
check("delight: levels top against bottom", ratio_before > RATIO_BOUND * 1.2 and ratio_after < RATIO_BOUND / 1.2, [ratio_before, ratio_after])
# bound: shipped deficit 0.000, an unfilled gain field leaves 0.164; the shipped reading being zero, the bound sits 1.2 under the mutant: 0.136
check("delight: the gain reaches the island's border unweakened", abs(deficit) < DEFICIT_BOUND, deficit)
receipt, rewound = send("brokkr_mesh_polish.repair", object_name="Ball", recalc_normals=True, sharp_angle=30)
check("repair: recalc_normals rewinds the inside-out half and says how many faces it turned",
receipt["status"] == "accepted" and rewound["changes"]["windingFlipped"] == reversed_faces
and rewound["changes"]["customNormalsDropped"] and "custom_normal" not in sphere.data.attributes
and rewound["after"]["windingAgainstNormals"] == 0, rewound)
# --- repair: only holes up to the size asked are filled, and only shells below the share asked are dropped -----
def holey(bm):
bmesh.ops.create_grid(bm, x_segments=6, y_segments=6, size=3.0, calc_uvs=True) # 36 quads, each 1 x 1
at = lambda face: (round(face.calc_center_median().x, 1), round(face.calc_center_median().y, 1))
small = [f for f in bm.faces if at(f) == (1.5, 1.5)] # one quad inside: a 4-edge hole
large = [f for f in bm.faces if at(f)[0] in (-1.5, -0.5) and at(f)[1] in (-1.5, -0.5)] # a 2 x 2 block: an 8-edge hole
bmesh.ops.delete(bm, geom=small + large, context="FACES")
bm.faces.new([bm.verts.new(co) for co in ((9.0, 9.0, 0.0), (9.2, 9.0, 0.0), (9.0, 9.2, 0.0))]) # a far chip: 0.02 of area against 31
sheet = new_object("Sheet", holey)
flipped_sheet = bmesh.new() # the generator's sheet faces down: a fill must follow it, whichever way Blender would guess
flipped_sheet.from_mesh(sheet.data)
bmesh.ops.reverse_faces(flipped_sheet, faces=flipped_sheet.faces[:])
flipped_sheet.to_mesh(sheet.data)
flipped_sheet.free()
TILT = (0.6, 0.0, -0.8) # the generator's shading normals lean: the old faces must keep them, a fill must not borrow them
sheet.data.normals_split_custom_set([TILT] * len(sheet.data.loops))
receipt, mended = send("brokkr_mesh_polish.repair", object_name="Sheet", fill_holes_sides=4, min_shell_area=0.01)
R["mend"] = mended
check("repair: fills the 4-edge hole, leaves the 8-edge hole and the rim, drops the chip",
receipt["status"] == "accepted" and mended["changes"]["holesFilled"] == 1 and mended["changes"]["shellsRemoved"] == 1
and mended["after"]["shells"] == 1 and mended["after"]["boundaryEdges"] == 24 + 8, mended)
facing = polygon_normals(sheet.data)[:, 2]
check("repair: a filled hole is wound as the faces around it", len(facing) == 31 * 1 + 2 and bool((facing < -0.9).all()), [len(facing), float(facing.max())])
shading = np.empty(len(sheet.data.loops) * 3, dtype=np.float32)
sheet.data.corner_normals.foreach_get("vector", shading)
shading = shading.reshape(-1, 3)
fill_loops = [i for polygon in sheet.data.polygons if abs(polygon.center.x - 1.5) < 0.4 and abs(polygon.center.y - 1.5) < 0.4 for i in polygon.loop_indices]
old_loops = [i for i in range(len(shading)) if i not in set(fill_loops)]
check("repair: old faces keep their shading normals through the weld and the fill; the fill is shaded by its own direction",
len(fill_loops) == 6 and np.allclose(shading[old_loops], TILT, atol=1e-3) and np.allclose(shading[fill_loops], (0.0, 0.0, -1.0), atol=1e-3),
[len(fill_loops), shading[fill_loops].tolist()[:2], shading[old_loops[0]].tolist()])
bpy.data.objects.remove(sheet)
# --- delight: darkness that follows occlusion is levelled ---------------------------------------------------------
def pair(bm):
layer = bm.loops.layers.uv.active
for side in (-1.0, 1.0): # two unit spheres 0.1 apart: their facing sides occlude each other
made = bmesh.ops.create_uvsphere(bm, u_segments=32, v_segments=16, radius=1.0, calc_uvs=True, matrix=Matrix.Translation((side * 1.05, 0, 0)))
for face in {f for v in made["verts"] for f in v.link_faces}:
def ball(bm):
bmesh.ops.create_uvsphere(bm, u_segments=48, v_segments=24, radius=1.0, calc_uvs=True)
layer = bm.loops.layers.uv.active
for face in bm.faces: # the island sits inside the texture with a margin, as a generator's atlas does
for loop in face.loops:
loop[layer].uv = Vector((loop[layer].uv.x * 0.5 + (0.0 if side < 0 else 0.5), loop[layer].uv.y))
loop[layer].uv = loop[layer].uv * 0.8 + Vector((0.1, 0.1))
import brokkr_mesh_polish as polish # noqa: E402 the fixture's bake uses the add-on's own occlusion, so the light is exactly what it can explain
twins = new_object("Twins", pair, new_image("twins_bake", np.ones((size, size, 3), dtype=np.float32)))
twins.data.polygons.foreach_set("use_smooth", [True] * len(twins.data.polygons))
twin = polish.arrays(twins)
twin_sky = polish.ambient_occlusion(twin["V"], twin["T"], twin["N"], 64, 0.35 * float(np.linalg.norm(twin["V"].max(axis=0) - twin["V"].min(axis=0))))
owner, bary, _ = polish.core.rasterize(twin["UV"], size)
sky_map = polish.core.interpolate(owner, bary, twin_sky[twin["T"]][..., None])[..., 0]
occluded, open_sky = (owner >= 0) & (sky_map < 0.6), (owner >= 0) & (sky_map > 0.95)
twin_bake = np.where((owner >= 0)[..., None], 0.8 * np.clip(sky_map, 0.05, 1.0)[..., None], 0.5) * np.ones((1, 1, 3))
flat = np.ones((size, size, 4), dtype=np.float32)
flat[..., :3] = twin_bake
bpy.data.images["twins_bake"].pixels.foreach_set(flat.reshape(-1))
receipt, unshadowed = send("brokkr_mesh_polish.delight", object_name="Twins", clusters=1, fit_size=256, occlusion_rays=64, max_gain=8)
twin_after, _ = pixels_of(twins)
shade_before = float(np.median(twin_bake[..., 0][occluded]) / np.median(twin_bake[..., 0][open_sky]))
shade_after = float(np.median(twin_after[..., 0][occluded]) / np.median(twin_after[..., 0][open_sky]))
R["occlusion"] = {"report": unshadowed, "occludedTexels": int(occluded.sum()), "shadeBefore": shade_before, "shadeAfter": shade_after}
# bound: shipped shadeAfter 1.000; with occlusion ignored (a sky of 1 everywhere) it stays 0.468: sqrt(1.000 * 0.468) = 0.684
check("delight: lifts occluded surface to the level of open surface", receipt["status"] == "accepted" and occluded.sum() > 500
and shade_before < SHADE_BOUND / 1.2 and shade_after > SHADE_BOUND * 1.2, R["occlusion"])
bpy.data.objects.remove(twins)
# --- orient: a turned slab is laid along Y, thin on Z, centred, scaled; nothing outside it moves -----------------
slab = new_object("Slab", lambda bm: bmesh.ops.create_cube(bm, size=1.0, matrix=Matrix.Diagonal((3.0, 1.0, 0.5, 1.0))))
slab.matrix_world = Matrix.Translation((4, 5, 6)) @ Matrix.Rotation(math.radians(37), 4, (0.3, 0.5, 0.8))
sphere.location = (20, 0, 0)
bpy.context.view_layer.update()
receipt, oriented = send("brokkr_mesh_polish.orient", object_name="Slab", length=12.0)
corners = np.array([slab.matrix_world @ v.co for v in slab.data.vertices])
extent = corners.max(axis=0) - corners.min(axis=0)
check("orient: long on Y, thin on Z, scaled to the length, centred",
receipt["status"] == "accepted" and np.allclose(extent, [4.0, 12.0, 2.0], atol=1e-3)
and np.allclose((corners.max(axis=0) + corners.min(axis=0)) / 2, 0, atol=1e-4), [list(map(float, extent)), oriented])
check("orient: reports the mirror error of a symmetric body as small", max(oriented["mirrorError"].values()) < 0.05, oriented["mirrorError"])
check("orient: an object outside the named root is not touched", oriented["objects"] == ["Slab"]
and np.allclose(sphere.matrix_world.translation, [20, 0, 0]) and abs(max(v.co.length for v in sphere.data.vertices) - 1.0) < 1e-5, oriented["objects"])
receipt, _ = send("brokkr_mesh_polish.orient", object_name="Nobody")
check("orient: an unknown root is refused", receipt["status"] == "failed", receipt["message"])
bpy.data.objects.remove(slab)
# --- cut_parts: a knob fused to a block is cut off at the crease, capped, and rooted at its cut -----------------
def knobbed(bm):
bmesh.ops.create_cube(bm, size=2.0)
top = next(f for f in bm.faces if f.normal.z > 0.9)
bmesh.ops.inset_region(bm, faces=[top], thickness=0.6)
extruded = bmesh.ops.extrude_face_region(bm, geom=[top])
bmesh.ops.translate(bm, verts=[g for g in extruded["geom"] if isinstance(g, bmesh.types.BMVert)], vec=(0, 0, 1.0))
bmesh.ops.delete(bm, geom=[top], context="FACES")
bmesh.ops.triangulate(bm, faces=bm.faces[:])
bmesh.ops.recalc_face_normals(bm, faces=bm.faces[:])
sphere = new_object("Ball", ball, new_image("ball_bake", baked.astype(np.float32)))
sphere.data.polygons.foreach_set("use_smooth", [True] * len(sphere.data.polygons))
torn = bmesh.new()
torn.from_mesh(sphere.data)
bmesh.ops.split_edges(torn, edges=torn.edges[:])
inside_out = [f for f in torn.faces if f.calc_center_median().x > 0]
reversed_faces, reversed_triangles = len(inside_out), sum(len(f.verts) - 2 for f in inside_out)
bmesh.ops.reverse_faces(torn, faces=inside_out)
torn.to_mesh(sphere.data)
torn.free()
sphere.data.normals_split_custom_set([tuple(sphere.data.vertices[loop.vertex_index].co.normalized()) for loop in sphere.data.loops])
block = new_object("Block", knobbed)
receipt, single = send("brokkr_mesh_polish.audit", object_name="Block")
check("cut fixture is one closed skin", single["Block"]["shells"] == 1 and single["Block"]["boundaryEdges"] == 0, single["Block"])
receipt, cut = send("brokkr_mesh_polish.cut_parts", object_name="Block", seeds="body=0,0,-1; knob=0,0,2", joint_scale=0.5)
R["cut"] = cut
check("cut_parts: accepted, one undo step, the fused object is replaced", receipt["status"] == "accepted" and bool(receipt.get("undoLabel"))
and "Block" not in bpy.data.objects and {"Block.body", "Block.knob"} <= set(bpy.data.objects.keys()), receipt["message"])
if receipt["status"] == "accepted":
knob, body = bpy.data.objects["Block.knob"], bpy.data.objects["Block.body"]
part = {entry["name"]: entry for entry in cut["parts"]}
check("cut_parts: the knob is cut at the crease and rooted at the centre of the cut",
np.allclose(part["Block.knob"]["root"], [0, 0, 1], atol=1e-5) and np.allclose(knob.matrix_world.translation, [0, 0, 1], atol=1e-5)
and abs(abs(part["Block.knob"]["cutNormal"][2]) - 1) < 1e-5, part["Block.knob"])
check("cut_parts: the knob hangs from the body and has not moved", knob.parent == body
and abs(max((knob.matrix_world @ v.co).z for v in knob.data.vertices) - 2.0) < 1e-5, None)
_, closed = send("brokkr_mesh_polish.audit")
check("cut_parts: both sides of the cut are capped (closed shells)",
all(closed[name]["boundaryEdges"] == 0 and closed[name]["shells"] == 1 for name in ("Block.body", "Block.knob")),
{name: [closed[name]["boundaryEdges"], closed[name]["shells"]] for name in ("Block.body", "Block.knob")})
capped = {o.name: sum(1 for polygon in o.data.polygons if getattr(o.data.materials[polygon.material_index], "name", "") == "Polish Cap") for o in (body, knob)}
check("cut_parts: exactly the cap faces carry the cap material", capped["Block.knob"] == part["Block.knob"]["capTriangles"] > 0
and capped["Block.body"] == part["Block.body"]["capTriangles"] > 0, capped)
cap_normals = {o.name: [polygon.normal.z for polygon in o.data.polygons
if getattr(o.data.materials[polygon.material_index], "name", "") == "Polish Cap"] for o in (body, knob)}
check("cut_parts: each cap faces out of its own part, and no old face was turned",
all(z < -0.9 for z in cap_normals["Block.knob"]) and all(z > 0.9 for z in cap_normals["Block.body"])
and closed["Block.body"]["windingAgainstNormals"] == 0 and closed["Block.knob"]["windingAgainstNormals"] == 0, cap_normals)
check("cut_parts: a joint sits at the root", "Polish Cap" in [getattr(m, "name", "") for m in knob.data.materials]
and np.allclose(bpy.data.objects[part["Block.knob"]["joint"]].matrix_world.translation, [0, 0, 1], atol=1e-5), part["Block.knob"].get("joint"))
# orient after the cut: the body and what hangs from it turn as one; the knob keeps its parent and its pivot
receipt, turned_parts = send("brokkr_mesh_polish.orient", object_name="Block.body", length=6.0)
pivot = knob.matrix_world.translation
reach = max(abs((knob.matrix_world @ v.co).y) for v in knob.data.vertices)
R["orientParts"] = {"report": turned_parts, "knobPivot": list(pivot), "knobReach": reach, "parent": knob.parent.name if knob.parent else None}
# the 2 x 2 x 3 body-and-knob is laid along Y and doubled: the cut centre (0, 0, 1), half a unit above the middle, lands 1 along Y
check("orient: after a cut the parts keep their parent and their pivot at the cut", receipt["status"] == "accepted" and knob.parent == body
and abs(abs(pivot.y) - 1.0) < 1e-4 and abs(pivot.x) < 1e-4 and abs(pivot.z) < 1e-4 and abs(reach - 3.0) < 1e-4
and np.allclose(np.array(knob.matrix_world.to_3x3()), np.eye(3), atol=1e-6), R["orientParts"])
receipt, _ = send("brokkr_mesh_polish.cut_parts", object_name="Block.body", seeds="only=0,0,-1")
check("cut_parts: one part is refused with nothing changed", receipt["status"] == "failed" and "Block.body" in bpy.data.objects, receipt["message"])
def polygon_normals(mesh):
flat = np.empty(len(mesh.polygons) * 3, dtype=np.float32)
mesh.polygons.foreach_get("normal", flat)
return flat.reshape(-1, 3)
# --- cut_parts through: a seed on one face of a thin plate also holds the face behind it -----------------------
def plate_body(bm):
bmesh.ops.create_cube(bm, size=2.0, matrix=Matrix.Diagonal((1.0, 1.0, 0.05, 1.0))) # 2 x 2 x 0.1
bmesh.ops.subdivide_edges(bm, edges=bm.edges[:], cuts=7, use_grid_fill=True)
bmesh.ops.triangulate(bm, faces=bm.faces[:])
def shading_error(mesh):
"""The worst angle, in degrees, between a corner's shading normal and the sphere's own outward direction."""
flat = np.empty(len(mesh.loops) * 3, dtype=np.float32)
mesh.corner_normals.foreach_get("vector", flat)
outward = np.array([mesh.vertices[loop.vertex_index].co.normalized() for loop in mesh.loops])
return float(np.degrees(np.arccos(np.clip((flat.reshape(-1, 3) * outward).sum(axis=1), -1, 1))).max())
def underside(name):
"""Triangles of the part that face down and are surface, not cap."""
part_object = bpy.data.objects[name]
return sum(1 for polygon in part_object.data.polygons
if polygon.normal.z < -0.9 and getattr(part_object.data.materials[polygon.material_index], "name", "") != "Polish Cap")
receipt, before = send("brokkr_mesh_polish.audit", object_name="Ball")
check("audit: accepted, no undo step", receipt["status"] == "accepted" and not receipt.get("undoLabel"), receipt["message"])
check("audit: welded topology sees one closed shell in the torn sphere",
before["Ball"]["shells"] == 1 and before["Ball"]["boundaryEdges"] == 0 and before["Ball"]["nonManifoldEdges"] == 0, before["Ball"])
check("audit: texture and UV facts", before["Ball"]["baseColorSize"] == [size, size] and before["Ball"]["uvOverlap"] < 0.02
and before["Ball"]["texelDensityMedian"] > 0 and 0.55 < before["Ball"]["uvCoverage"] < 0.64, before["Ball"]) # an 0.8 x 0.8 island less the pole gaps
check("audit: counts the triangles wound against their shading normals, and none of them as a mirrored texture",
reversed_triangles > 1000 and before["Ball"]["windingAgainstNormals"] == reversed_triangles
and before["Ball"]["uvMirroredTriangles"] == 0, [reversed_triangles, before["Ball"].get("windingAgainstNormals"), before["Ball"].get("uvMirroredTriangles")])
torn_vertices, normals_before = len(sphere.data.vertices), polygon_normals(sphere.data)
receipt, repaired = send("brokkr_mesh_polish.repair", object_name="Ball")
check("repair: accepted as one undo step", receipt["status"] == "accepted" and "repair" in receipt.get("undoLabel", ""), receipt)
check("repair: welds the torn vertices", repaired["changes"]["welded"] == torn_vertices - len(sphere.data.vertices)
and len(sphere.data.vertices) == 48 * 23 + 2, repaired)
check("repair: every edge has two faces again", len(sphere.data.edges) == 48 * 23 + 48 * 24, len(sphere.data.edges))
normals_after = polygon_normals(sphere.data)
turned = int(((normals_before * normals_after).sum(axis=1) < 0).sum()) if len(normals_before) == len(normals_after) else -1
R["winding"] = {"reversedTriangles": reversed_triangles, "turnedByDefaultRepair": turned, "shadingErrorDegrees": shading_error(sphere.data)}
check("repair: by default turns no face (a single-sided material would cull a turned one)",
turned == 0 and repaired["changes"]["windingFlipped"] == 0
and repaired["after"]["windingAgainstNormals"] == repaired["before"]["windingAgainstNormals"] == reversed_triangles, [turned, repaired])
check("repair: the shading normals survive the weld", "custom_normal" in sphere.data.attributes and R["winding"]["shadingErrorDegrees"] < 0.5
and not repaired["changes"]["customNormalsDropped"], R["winding"])
# --- delight: a bake that darkens with latitude is levelled, reading the shading normals, not the windings --------
receipt, lit = send("brokkr_mesh_polish.delight", object_name="Ball", clusters=1, fit_size=128, occlusion_rays=8, max_gain=8)
after_pixels, after_image = pixels_of(sphere)
column = after_pixels[:, size // 2, 0]
north, south = int(size * (0.1 + 0.8 * 0.9)), int(size * (0.1 + 0.8 * 0.1)) # rows at latitude 0.9 and 0.1
ratio_before = float(baked[north, 0, 0] / baked[south, 0, 0])
ratio_after = float(column[north] / column[south])
# On the island's left border the gain field meets texels no triangle covers. With the field filled outward the
# border reads as the middle of the row does; left unfilled, the neutral gain of the uncovered texels bleeds in.
border = int(math.ceil(size * 0.1))
deficit = float(np.median(1.0 - after_pixels[south - 8:south + 8, border, 0] / after_pixels[south - 8:south + 8, size // 2, 0]))
R["delight"] = {"report": lit, "ratioBefore": ratio_before, "ratioAfter": ratio_after, "borderDeficit": deficit}
check("delight: accepted, new packed image on the material, in the old image's colour space", receipt["status"] == "accepted"
and after_image.name == "ball_bake.delit" and after_image.packed_file is not None
and after_image.colorspace_settings.name == "Non-Color", [receipt["message"], after_image.colorspace_settings.name])
check("delight: finds the baked light", lit["explainedByLight"]["before"] > 0.5 and lit["before"]["upDownLuminanceRatio"] > 2.0, lit)
# bound: shipped ratioAfter 1.114; a no-op leaves 3.261 and so do normals taken from the windings (the inside-out half
# cancels the light the fit could find): sqrt(1.114 * 3.261) = 1.906
check("delight: levels top against bottom", ratio_before > RATIO_BOUND * 1.2 and ratio_after < RATIO_BOUND / 1.2, [ratio_before, ratio_after])
# bound: shipped deficit 0.000, an unfilled gain field leaves 0.164; the shipped reading being zero, the bound sits 1.2 under the mutant: 0.136
check("delight: the gain reaches the island's border unweakened", abs(deficit) < DEFICIT_BOUND, deficit)
receipt, rewound = send("brokkr_mesh_polish.repair", object_name="Ball", recalc_normals=True, sharp_angle=30)
check("repair: recalc_normals rewinds the inside-out half and says how many faces it turned",
receipt["status"] == "accepted" and rewound["changes"]["windingFlipped"] == reversed_faces
and rewound["changes"]["customNormalsDropped"] and "custom_normal" not in sphere.data.attributes
and rewound["after"]["windingAgainstNormals"] == 0, rewound)
# --- repair: only holes up to the size asked are filled, and only shells below the share asked are dropped -----
def holey(bm):
bmesh.ops.create_grid(bm, x_segments=6, y_segments=6, size=3.0, calc_uvs=True) # 36 quads, each 1 x 1
at = lambda face: (round(face.calc_center_median().x, 1), round(face.calc_center_median().y, 1))
small = [f for f in bm.faces if at(f) == (1.5, 1.5)] # one quad inside: a 4-edge hole
large = [f for f in bm.faces if at(f)[0] in (-1.5, -0.5) and at(f)[1] in (-1.5, -0.5)] # a 2 x 2 block: an 8-edge hole
bmesh.ops.delete(bm, geom=small + large, context="FACES")
bm.faces.new([bm.verts.new(co) for co in ((9.0, 9.0, 0.0), (9.2, 9.0, 0.0), (9.0, 9.2, 0.0))]) # a far chip: 0.02 of area against 31
R["through"] = {}
for label, through in (("without", 0.0), ("with", 0.1)):
new_object("Plate", plate_body)
# by distance alone (no crease cost) the underside's middle is nearer the body's seed, at an underside corner,
# than the lid's seed on top, which must go round the rim; a ray inward from the lid's seed finds it at once
receipt, _ = send("brokkr_mesh_polish.cut_parts", object_name="Plate", seeds="body=-0.9,-0.9,-0.05; lid=0,0,0.05", crease_cost=0, through=through)
R["through"][label] = underside("Plate.lid") if receipt["status"] == "accepted" else None
for leftover in [o for o in bpy.data.objects if o.name.startswith("Plate")]:
bpy.data.objects.remove(leftover)
check("cut_parts: through seeds the far face of a thin part", R["through"]["without"] == 0 and (R["through"]["with"] or 0) >= 8, R["through"])
sheet = new_object("Sheet", holey)
flipped_sheet = bmesh.new() # the generator's sheet faces down: a fill must follow it, whichever way Blender would guess
flipped_sheet.from_mesh(sheet.data)
bmesh.ops.reverse_faces(flipped_sheet, faces=flipped_sheet.faces[:])
flipped_sheet.to_mesh(sheet.data)
flipped_sheet.free()
TILT = (0.6, 0.0, -0.8) # the generator's shading normals lean: the old faces must keep them, a fill must not borrow them
sheet.data.normals_split_custom_set([TILT] * len(sheet.data.loops))
receipt, mended = send("brokkr_mesh_polish.repair", object_name="Sheet", fill_holes_sides=4, min_shell_area=0.01)
R["mend"] = mended
check("repair: fills the 4-edge hole, leaves the 8-edge hole and the rim, drops the chip",
receipt["status"] == "accepted" and mended["changes"]["holesFilled"] == 1 and mended["changes"]["shellsRemoved"] == 1
and mended["after"]["shells"] == 1 and mended["after"]["boundaryEdges"] == 24 + 8, mended)
facing = polygon_normals(sheet.data)[:, 2]
check("repair: a filled hole is wound as the faces around it", len(facing) == 31 * 1 + 2 and bool((facing < -0.9).all()), [len(facing), float(facing.max())])
shading = np.empty(len(sheet.data.loops) * 3, dtype=np.float32)
sheet.data.corner_normals.foreach_get("vector", shading)
shading = shading.reshape(-1, 3)
fill_loops = [i for polygon in sheet.data.polygons if abs(polygon.center.x - 1.5) < 0.4 and abs(polygon.center.y - 1.5) < 0.4 for i in polygon.loop_indices]
old_loops = [i for i in range(len(shading)) if i not in set(fill_loops)]
check("repair: old faces keep their shading normals through the weld and the fill; the fill is shaded by its own direction",
len(fill_loops) == 6 and np.allclose(shading[old_loops], TILT, atol=1e-3) and np.allclose(shading[fill_loops], (0.0, 0.0, -1.0), atol=1e-3),
[len(fill_loops), shading[fill_loops].tolist()[:2], shading[old_loops[0]].tolist()])
bpy.data.objects.remove(sheet)
# --- pick and scrub_markings: lettering on one panel is found from a camera and painted out ----------------------
panel = np.full((128, 128, 3), [0.1, 0.35, 0.4], dtype=np.float32)
panel += np.random.default_rng(0).normal(0, 0.01, panel.shape).astype(np.float32)
for column_start in range(8, 120, 8): # yellow strokes over the whole texture
panel[:, column_start:column_start + 2] = [0.85, 0.75, 0.2]
# --- delight: darkness that follows occlusion is levelled ---------------------------------------------------------
def pair(bm):
layer = bm.loops.layers.uv.active
for side in (-1.0, 1.0): # two unit spheres 0.1 apart: their facing sides occlude each other
made = bmesh.ops.create_uvsphere(bm, u_segments=32, v_segments=16, radius=1.0, calc_uvs=True, matrix=Matrix.Translation((side * 1.05, 0, 0)))
for face in {f for v in made["verts"] for f in v.link_faces}:
for loop in face.loops:
loop[layer].uv = Vector((loop[layer].uv.x * 0.5 + (0.0 if side < 0 else 0.5), loop[layer].uv.y))
def plate(bm):
bmesh.ops.create_grid(bm, x_segments=2, y_segments=1, size=1.0, matrix=Matrix.Diagonal((2.0, 1.0, 1.0, 1.0)), calc_uvs=True)
import brokkr_mesh_polish as polish # noqa: E402 the fixture's bake uses the add-on's own occlusion, so the light is exactly what it can explain
twins = new_object("Twins", pair, new_image("twins_bake", np.ones((size, size, 3), dtype=np.float32)))
twins.data.polygons.foreach_set("use_smooth", [True] * len(twins.data.polygons))
twin = polish.arrays(twins)
twin_sky = polish.ambient_occlusion(twin["V"], twin["T"], twin["N"], 64, 0.35 * float(np.linalg.norm(twin["V"].max(axis=0) - twin["V"].min(axis=0))))
owner, bary, _ = polish.core.rasterize(twin["UV"], size)
sky_map = polish.core.interpolate(owner, bary, twin_sky[twin["T"]][..., None])[..., 0]
occluded, open_sky = (owner >= 0) & (sky_map < 0.6), (owner >= 0) & (sky_map > 0.95)
twin_bake = np.where((owner >= 0)[..., None], 0.8 * np.clip(sky_map, 0.05, 1.0)[..., None], 0.5) * np.ones((1, 1, 3))
flat = np.ones((size, size, 4), dtype=np.float32)
flat[..., :3] = twin_bake
bpy.data.images["twins_bake"].pixels.foreach_set(flat.reshape(-1))
receipt, unshadowed = send("brokkr_mesh_polish.delight", object_name="Twins", clusters=1, fit_size=256, occlusion_rays=64, max_gain=8)
twin_after, _ = pixels_of(twins)
shade_before = float(np.median(twin_bake[..., 0][occluded]) / np.median(twin_bake[..., 0][open_sky]))
shade_after = float(np.median(twin_after[..., 0][occluded]) / np.median(twin_after[..., 0][open_sky]))
R["occlusion"] = {"report": unshadowed, "occludedTexels": int(occluded.sum()), "shadeBefore": shade_before, "shadeAfter": shade_after}
# bound: shipped shadeAfter 1.000; with occlusion ignored (a sky of 1 everywhere) it stays 0.468: sqrt(1.000 * 0.468) = 0.684
check("delight: lifts occluded surface to the level of open surface", receipt["status"] == "accepted" and occluded.sum() > 500
and shade_before < SHADE_BOUND / 1.2 and shade_after > SHADE_BOUND * 1.2, R["occlusion"])
bpy.data.objects.remove(twins)
# --- orient: a turned slab is laid along Y, thin on Z, centred, scaled; nothing outside it moves -----------------
slab = new_object("Slab", lambda bm: bmesh.ops.create_cube(bm, size=1.0, matrix=Matrix.Diagonal((3.0, 1.0, 0.5, 1.0))))
slab.matrix_world = Matrix.Translation((4, 5, 6)) @ Matrix.Rotation(math.radians(37), 4, (0.3, 0.5, 0.8))
sphere.location = (20, 0, 0)
bpy.context.view_layer.update()
receipt, oriented = send("brokkr_mesh_polish.orient", object_name="Slab", length=12.0)
corners = np.array([slab.matrix_world @ v.co for v in slab.data.vertices])
extent = corners.max(axis=0) - corners.min(axis=0)
check("orient: long on Y, thin on Z, scaled to the length, centred",
receipt["status"] == "accepted" and np.allclose(extent, [4.0, 12.0, 2.0], atol=1e-3)
and np.allclose((corners.max(axis=0) + corners.min(axis=0)) / 2, 0, atol=1e-4), [list(map(float, extent)), oriented])
check("orient: reports the mirror error of a symmetric body as small", max(oriented["mirrorError"].values()) < 0.05, oriented["mirrorError"])
check("orient: an object outside the named root is not touched", oriented["objects"] == ["Slab"]
and np.allclose(sphere.matrix_world.translation, [20, 0, 0]) and abs(max(v.co.length for v in sphere.data.vertices) - 1.0) < 1e-5, oriented["objects"])
receipt, _ = send("brokkr_mesh_polish.orient", object_name="Nobody")
check("orient: an unknown root is refused", receipt["status"] == "failed", receipt["message"])
bpy.data.objects.remove(slab)
# --- cut_parts: a knob fused to a block is cut off at the crease, capped, and rooted at its cut -----------------
def knobbed(bm):
bmesh.ops.create_cube(bm, size=2.0)
top = next(f for f in bm.faces if f.normal.z > 0.9)
bmesh.ops.inset_region(bm, faces=[top], thickness=0.6)
extruded = bmesh.ops.extrude_face_region(bm, geom=[top])
bmesh.ops.translate(bm, verts=[g for g in extruded["geom"] if isinstance(g, bmesh.types.BMVert)], vec=(0, 0, 1.0))
bmesh.ops.delete(bm, geom=[top], context="FACES")
bmesh.ops.triangulate(bm, faces=bm.faces[:])
bmesh.ops.recalc_face_normals(bm, faces=bm.faces[:])
sign = new_object("Sign", plate, new_image("sign_paint", panel)) # 4 x 2, flat on z = 0, u along x
sign.location = (40, 0, 5) # clear of the block
bpy.context.view_layer.update()
camera = bpy.data.objects.new("Eye", bpy.data.cameras.new("Eye"))
bpy.context.scene.collection.objects.link(camera)
camera.data.type = "ORTHO"
camera.data.ortho_scale = 4.0
camera.location = (40, 0, 9)
receipt, picked = send("brokkr_mesh_polish.pick", camera_name="Eye", u=0.25, v=0.5, resolution_x=400, resolution_y=200)
check("pick: names the surface point under (u, v) of a picture of that shape", receipt["status"] == "accepted" and picked["hit"]
and picked["object"] == "Sign" and np.allclose(picked["point"], [39.0, 0.0, 5.0], atol=1e-4), picked)
receipt, missed = send("brokkr_mesh_polish.pick", camera_name="Eye", u=0.5, v=0.99, resolution_x=200, resolution_y=400)
check("pick: off the surface is a miss, not an error", receipt["status"] == "accepted" and missed == {"hit": False}, missed)
block = new_object("Block", knobbed)
receipt, single = send("brokkr_mesh_polish.audit", object_name="Block")
check("cut fixture is one closed skin", single["Block"]["shells"] == 1 and single["Block"]["boundaryEdges"] == 0, single["Block"])
receipt, cut = send("brokkr_mesh_polish.cut_parts", object_name="Block", seeds="body=0,0,-1; knob=0,0,2", joint_scale=0.5)
R["cut"] = cut
check("cut_parts: accepted, one undo step, the fused object is replaced", receipt["status"] == "accepted" and bool(receipt.get("undoLabel"))
and "Block" not in bpy.data.objects and {"Block.body", "Block.knob"} <= set(bpy.data.objects.keys()), receipt["message"])
if receipt["status"] == "accepted":
knob, body = bpy.data.objects["Block.knob"], bpy.data.objects["Block.body"]
part = {entry["name"]: entry for entry in cut["parts"]}
check("cut_parts: the knob is cut at the crease and rooted at the centre of the cut",
np.allclose(part["Block.knob"]["root"], [0, 0, 1], atol=1e-5) and np.allclose(knob.matrix_world.translation, [0, 0, 1], atol=1e-5)
and abs(abs(part["Block.knob"]["cutNormal"][2]) - 1) < 1e-5, part["Block.knob"])
check("cut_parts: the knob hangs from the body and has not moved", knob.parent == body
and abs(max((knob.matrix_world @ v.co).z for v in knob.data.vertices) - 2.0) < 1e-5, None)
_, closed = send("brokkr_mesh_polish.audit")
check("cut_parts: both sides of the cut are capped (closed shells)",
all(closed[name]["boundaryEdges"] == 0 and closed[name]["shells"] == 1 for name in ("Block.body", "Block.knob")),
{name: [closed[name]["boundaryEdges"], closed[name]["shells"]] for name in ("Block.body", "Block.knob")})
capped = {o.name: sum(1 for polygon in o.data.polygons if getattr(o.data.materials[polygon.material_index], "name", "") == "Polish Cap") for o in (body, knob)}
check("cut_parts: exactly the cap faces carry the cap material", capped["Block.knob"] == part["Block.knob"]["capTriangles"] > 0
and capped["Block.body"] == part["Block.body"]["capTriangles"] > 0, capped)
cap_normals = {o.name: [polygon.normal.z for polygon in o.data.polygons
if getattr(o.data.materials[polygon.material_index], "name", "") == "Polish Cap"] for o in (body, knob)}
check("cut_parts: each cap faces out of its own part, and no old face was turned",
all(z < -0.9 for z in cap_normals["Block.knob"]) and all(z > 0.9 for z in cap_normals["Block.body"])
and closed["Block.body"]["windingAgainstNormals"] == 0 and closed["Block.knob"]["windingAgainstNormals"] == 0, cap_normals)
check("cut_parts: a joint sits at the root", "Polish Cap" in [getattr(m, "name", "") for m in knob.data.materials]
and np.allclose(bpy.data.objects[part["Block.knob"]["joint"]].matrix_world.translation, [0, 0, 1], atol=1e-5), part["Block.knob"].get("joint"))
# orient after the cut: the body and what hangs from it turn as one; the knob keeps its parent and its pivot
receipt, turned_parts = send("brokkr_mesh_polish.orient", object_name="Block.body", length=6.0)
pivot = knob.matrix_world.translation
reach = max(abs((knob.matrix_world @ v.co).y) for v in knob.data.vertices)
R["orientParts"] = {"report": turned_parts, "knobPivot": list(pivot), "knobReach": reach, "parent": knob.parent.name if knob.parent else None}
# the 2 x 2 x 3 body-and-knob is laid along Y and doubled: the cut centre (0, 0, 1), half a unit above the middle, lands 1 along Y
check("orient: after a cut the parts keep their parent and their pivot at the cut", receipt["status"] == "accepted" and knob.parent == body
and abs(abs(pivot.y) - 1.0) < 1e-4 and abs(pivot.x) < 1e-4 and abs(pivot.z) < 1e-4 and abs(reach - 3.0) < 1e-4
and np.allclose(np.array(knob.matrix_world.to_3x3()), np.eye(3), atol=1e-6), R["orientParts"])
receipt, _ = send("brokkr_mesh_polish.cut_parts", object_name="Block.body", seeds="only=0,0,-1")
check("cut_parts: one part is refused with nothing changed", receipt["status"] == "failed" and "Block.body" in bpy.data.objects, receipt["message"])
def ink(pixels):
return np.linalg.norm(pixels - [0.1, 0.35, 0.4], axis=-1) > 0.25
# --- cut_parts through: a seed on one face of a thin plate also holds the face behind it -----------------------
def plate_body(bm):
bmesh.ops.create_cube(bm, size=2.0, matrix=Matrix.Diagonal((1.0, 1.0, 0.05, 1.0))) # 2 x 2 x 0.1
bmesh.ops.subdivide_edges(bm, edges=bm.edges[:], cuts=7, use_grid_fill=True)
bmesh.ops.triangulate(bm, faces=bm.faces[:])
receipt, scrubbed = send("brokkr_mesh_polish.scrub_markings", object_name="Sign", x=picked["point"][0], y=0.0, z=5.0, radius=0.5, tolerance=0.25)
after, image = pixels_of(sign)
inside = np.zeros((128, 128), dtype=bool)
inside[48:80, 20:44] = True # well within the sphere: u 0.25 +- 0.09, v 0.5 +- 0.12
far = np.zeros((128, 128), dtype=bool)
far[:, 72:] = True # the other half of the sign
R["scrub"] = {"report": scrubbed, "inkInsideBefore": int(ink(panel)[inside].sum()), "inkInsideAfter": int(ink(after)[inside].sum())}
check("scrub_markings: accepted, the lettering inside the sphere is gone", receipt["status"] == "accepted"
and ink(panel)[inside].sum() > 100 and ink(after)[inside].sum() == 0, R["scrub"])
check("scrub_markings: nothing outside the sphere is touched (to the 8 bits the image stores)", np.allclose(after[far], panel[far], atol=0.6 / 255) and image.name == "sign_paint.scrubbed", image.name)
receipt, _ = send("brokkr_mesh_polish.scrub_markings", object_name="Sign", x=50.0, y=0.0, z=0.0, radius=0.5)
check("scrub_markings: a sphere off the surface is refused", receipt["status"] == "failed", receipt["message"])
receipt, _ = send("brokkr_mesh_polish.delight", object_name="Sign", max_gain=9)
check("a bound miss is denied by Brokkr's table before the operator runs", receipt["status"] == "denied", receipt["message"])
def underside(name):
"""Triangles of the part that face down and are surface, not cap."""
part_object = bpy.data.objects[name]
return sum(1 for polygon in part_object.data.polygons
if polygon.normal.z < -0.9 and getattr(part_object.data.materials[polygon.material_index], "name", "") != "Polish Cap")
# --- real generated hulls, when a directory of .glb files is given: repair must turn none of their faces ---------
HULLS = os.environ.get("BROKKR_POLISH_HULLS", "")
R["hulls"] = {}
for path in sorted(Path(HULLS).glob("*.glb")) if HULLS else []:
known = set(bpy.data.objects.keys())
bpy.ops.import_scene.gltf(filepath=str(path))
for hull in [o for o in bpy.data.objects if o.name not in known and o.type == "MESH"]:
was = polygon_normals(hull.data)
_, raw = send("brokkr_mesh_polish.audit", object_name=hull.name)
against = raw[hull.name]["windingAgainstNormals"]
receipt, mended = send("brokkr_mesh_polish.repair", object_name=hull.name)
now = polygon_normals(hull.data)
turned = int(((was * now).sum(axis=1) < 0).sum()) if len(was) == len(now) else None
R["hulls"][path.name] = {"polygons": len(was), "polygonsAfter": len(now), "turned": turned, "againstBefore": against,
"againstAfter": mended["after"]["windingAgainstNormals"], "changes": mended["changes"]}
check(f"hull {path.name}: repair turns no face and keeps the shading normals' sides", receipt["status"] == "accepted"
and mended["changes"]["windingFlipped"] == 0 and turned in (0, None) # None: faces were removed, so indices no longer pair
and 0 <= against - mended["after"]["windingAgainstNormals"] <= len(was) - len(now), R["hulls"][path.name])
bpy.data.objects.remove(hull)
R["through"] = {}
for label, through in (("without", 0.0), ("with", 0.1)):
new_object("Plate", plate_body)
# by distance alone (no crease cost) the underside's middle is nearer the body's seed, at an underside corner,
# than the lid's seed on top, which must go round the rim; a ray inward from the lid's seed finds it at once
receipt, _ = send("brokkr_mesh_polish.cut_parts", object_name="Plate", seeds="body=-0.9,-0.9,-0.05; lid=0,0,0.05", crease_cost=0, through=through)
R["through"][label] = underside("Plate.lid") if receipt["status"] == "accepted" else None
for leftover in [o for o in bpy.data.objects if o.name.startswith("Plate")]:
bpy.data.objects.remove(leftover)
check("cut_parts: through seeds the far face of a thin part", R["through"]["without"] == 0 and (R["through"]["with"] or 0) >= 8, R["through"])
# --- pick and scrub_markings: lettering on one panel is found from a camera and painted out ----------------------
panel = np.full((128, 128, 3), [0.1, 0.35, 0.4], dtype=np.float32)
panel += np.random.default_rng(0).normal(0, 0.01, panel.shape).astype(np.float32)
for column_start in range(8, 120, 8): # yellow strokes over the whole texture
panel[:, column_start:column_start + 2] = [0.85, 0.75, 0.2]
def plate(bm):
bmesh.ops.create_grid(bm, x_segments=2, y_segments=1, size=1.0, matrix=Matrix.Diagonal((2.0, 1.0, 1.0, 1.0)), calc_uvs=True)
sign = new_object("Sign", plate, new_image("sign_paint", panel)) # 4 x 2, flat on z = 0, u along x
sign.location = (40, 0, 5) # clear of the block
bpy.context.view_layer.update()
camera = bpy.data.objects.new("Eye", bpy.data.cameras.new("Eye"))
bpy.context.scene.collection.objects.link(camera)
camera.data.type = "ORTHO"
camera.data.ortho_scale = 4.0
camera.location = (40, 0, 9)
receipt, picked = send("brokkr_mesh_polish.pick", camera_name="Eye", u=0.25, v=0.5, resolution_x=400, resolution_y=200)
check("pick: names the surface point under (u, v) of a picture of that shape", receipt["status"] == "accepted" and picked["hit"]
and picked["object"] == "Sign" and np.allclose(picked["point"], [39.0, 0.0, 5.0], atol=1e-4), picked)
receipt, missed = send("brokkr_mesh_polish.pick", camera_name="Eye", u=0.5, v=0.99, resolution_x=200, resolution_y=400)
check("pick: off the surface is a miss, not an error", receipt["status"] == "accepted" and missed == {"hit": False}, missed)
def ink(pixels):
return np.linalg.norm(pixels - [0.1, 0.35, 0.4], axis=-1) > 0.25
receipt, scrubbed = send("brokkr_mesh_polish.scrub_markings", object_name="Sign", x=picked["point"][0], y=0.0, z=5.0, radius=0.5, tolerance=0.25)
after, image = pixels_of(sign)
inside = np.zeros((128, 128), dtype=bool)
inside[48:80, 20:44] = True # well within the sphere: u 0.25 +- 0.09, v 0.5 +- 0.12
far = np.zeros((128, 128), dtype=bool)
far[:, 72:] = True # the other half of the sign
R["scrub"] = {"report": scrubbed, "inkInsideBefore": int(ink(panel)[inside].sum()), "inkInsideAfter": int(ink(after)[inside].sum())}
check("scrub_markings: accepted, the lettering inside the sphere is gone", receipt["status"] == "accepted"
and ink(panel)[inside].sum() > 100 and ink(after)[inside].sum() == 0, R["scrub"])
check("scrub_markings: nothing outside the sphere is touched (to the 8 bits the image stores)", np.allclose(after[far], panel[far], atol=0.6 / 255) and image.name == "sign_paint.scrubbed", image.name)
receipt, _ = send("brokkr_mesh_polish.scrub_markings", object_name="Sign", x=50.0, y=0.0, z=0.0, radius=0.5)
check("scrub_markings: a sphere off the surface is refused", receipt["status"] == "failed", receipt["message"])
receipt, _ = send("brokkr_mesh_polish.delight", object_name="Sign", max_gain=9)
check("a bound miss is denied by Brokkr's table before the operator runs", receipt["status"] == "denied", receipt["message"])
# --- real generated hulls, when a directory of .glb files is given: repair must turn none of their faces ---------
HULLS = os.environ.get("BROKKR_POLISH_HULLS", "")
R["hulls"] = {}
for path in sorted(Path(HULLS).glob("*.glb")) if HULLS else []:
known = set(bpy.data.objects.keys())
bpy.ops.import_scene.gltf(filepath=str(path))
for hull in [o for o in bpy.data.objects if o.name not in known and o.type == "MESH"]:
was = polygon_normals(hull.data)
_, raw = send("brokkr_mesh_polish.audit", object_name=hull.name)
against = raw[hull.name]["windingAgainstNormals"]
receipt, mended = send("brokkr_mesh_polish.repair", object_name=hull.name)
now = polygon_normals(hull.data)
turned = int(((was * now).sum(axis=1) < 0).sum()) if len(was) == len(now) else None
R["hulls"][path.name] = {"polygons": len(was), "polygonsAfter": len(now), "turned": turned, "againstBefore": against,
"againstAfter": mended["after"]["windingAgainstNormals"], "changes": mended["changes"]}
check(f"hull {path.name}: repair turns no face and keeps the shading normals' sides", receipt["status"] == "accepted"
and mended["changes"]["windingFlipped"] == 0 and turned in (0, None) # None: faces were removed, so indices no longer pair
and 0 <= against - mended["after"]["windingAgainstNormals"] <= len(was) - len(now), R["hulls"][path.name])
bpy.data.objects.remove(hull)
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, printed and written, not a missing result file
check(f"no uncaught error after: {R['checks'][-1]['name'] if R['checks'] else 'the start'}", False, traceback.format_exc().splitlines()[-6:])
R["ok"] = all(c["ok"] for c in R["checks"])
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
sys.exit(0 if R["ok"] else 1)

View file

@ -125,7 +125,7 @@
"undoLabel": "Brokkr test/driver: brokkr_mesh_polish.repair live-2",
"lookPath": "",
"hostResult": "{\"object\":\"Ball\",\"changes\":{\"welded\":3406,\"facesCollapsedByWeld\":0,\"degenerateFacesRemoved\":0,\"looseEdgesRemoved\":0,\"looseVertsRemoved\":0,\"shellsRemoved\":0,\"holesFilled\":0,\"windingFlipped\":0,\"customNormalsDropped\":false},\"before\":{\"triangles\":2208,\"vertices\":4512,\"boundaryEdges\":0,\"nonManifoldEdges\":0,\"shells\":1,\"windingAgainstNormals\":1104},\"after\":{\"triangles\":2208,\"vertices\":1106,\"boundaryEdges\":0,\"nonManifoldEdges\":0,\"shells\":1,\"windingAgainstNormals\":1104}}",
"observedAt": "2026-12-01T01:10:29.202522+00:00"
"observedAt": "2026-12-02T12:26:00.225314+00:00"
}
},
{
@ -231,21 +231,21 @@
"Ball"
],
"explainedByLight": {
"before": 0.9718638595466577,
"after": 0.0005166823179215685
"before": 0.9718639234640993,
"after": 0.0005166608648451421
},
"before": {
"upDownLuminanceRatio": 2.562451830544031,
"occlusionCorrelation": 0.0
},
"after": {
"upDownLuminanceRatio": 1.0166067038538378,
"upDownLuminanceRatio": 1.016606182115671,
"occlusionCorrelation": 0.0
},
"gain": {
"min": 0.9857558709602762,
"median": 1.457103285957073,
"max": 3.0649151172981792,
"min": 0.9857558916878914,
"median": 1.4570992824185989,
"max": 3.0649098409031676,
"clamped": 0.0
}
}
@ -374,21 +374,21 @@
"Twins"
],
"explainedByLight": {
"before": 0.9999597575085393,
"after": 0.028075104342772272
"before": 0.9999597575085377,
"after": 0.02807510434956728
},
"before": {
"upDownLuminanceRatio": 1.0000084632254227,
"occlusionCorrelation": 0.983967648279407
},
"after": {
"upDownLuminanceRatio": 0.9999964767503613,
"occlusionCorrelation": 0.40471079036691976
"upDownLuminanceRatio": 0.9999964767498971,
"occlusionCorrelation": 0.4047107903548106
},
"gain": {
"min": 0.9999809983875252,
"median": 1.0000990920451596,
"max": 5.493916964800697,
"min": 0.9999809983877584,
"median": 1.0000990920471027,
"max": 5.493916964801517,
"clamped": 0.0
}
},
@ -572,9 +572,9 @@
5.656854
],
"mirrorError": {
"X": 1.8120748396336225e-08,
"X": 1.8120748396474917e-08,
"Y": 0.1508370330678463,
"Z": 1.8363068583553207e-08
"Z": 1.836306858237196e-08
}
},
"knobPivot": [
@ -653,72 +653,6 @@
"name": "a bound miss is denied by Brokkr's table before the operator runs",
"ok": true,
"detail": "max_gain must be between 1 and 8."
},
{
"name": "hull fourth.glb: repair turns no face and keeps the shading normals' sides",
"ok": true,
"detail": {
"polygons": 28426,
"polygonsAfter": 28420,
"turned": null,
"againstBefore": 388,
"againstAfter": 387,
"changes": {
"welded": 6437,
"facesCollapsedByWeld": 2,
"degenerateFacesRemoved": 4,
"looseEdgesRemoved": 0,
"looseVertsRemoved": 0,
"shellsRemoved": 0,
"holesFilled": 0,
"windingFlipped": 0,
"customNormalsDropped": false
}
}
},
{
"name": "hull sub.glb: repair turns no face and keeps the shading normals' sides",
"ok": true,
"detail": {
"polygons": 10406,
"polygonsAfter": 10406,
"turned": 0,
"againstBefore": 64,
"againstAfter": 64,
"changes": {
"welded": 2454,
"facesCollapsedByWeld": 0,
"degenerateFacesRemoved": 0,
"looseEdgesRemoved": 0,
"looseVertsRemoved": 0,
"shellsRemoved": 0,
"holesFilled": 0,
"windingFlipped": 0,
"customNormalsDropped": false
}
}
},
{
"name": "hull third.glb: repair turns no face and keeps the shading normals' sides",
"ok": true,
"detail": {
"polygons": 23341,
"polygonsAfter": 23340,
"turned": null,
"againstBefore": 189,
"againstAfter": 189,
"changes": {
"welded": 3810,
"facesCollapsedByWeld": 0,
"degenerateFacesRemoved": 1,
"looseEdgesRemoved": 0,
"looseVertsRemoved": 0,
"shellsRemoved": 0,
"holesFilled": 0,
"windingFlipped": 0,
"customNormalsDropped": false
}
}
}
],
"hostErrors": [],
@ -744,21 +678,21 @@
"Ball"
],
"explainedByLight": {
"before": 0.9718638595466577,
"after": 0.0005166823179215685
"before": 0.9718639234640993,
"after": 0.0005166608648451421
},
"before": {
"upDownLuminanceRatio": 2.562451830544031,
"occlusionCorrelation": 0.0
},
"after": {
"upDownLuminanceRatio": 1.0166067038538378,
"upDownLuminanceRatio": 1.016606182115671,
"occlusionCorrelation": 0.0
},
"gain": {
"min": 0.9857558709602762,
"median": 1.457103285957073,
"max": 3.0649151172981792,
"min": 0.9857558916878914,
"median": 1.4570992824185989,
"max": 3.0649098409031676,
"clamped": 0.0
}
},
@ -804,21 +738,21 @@
"Twins"
],
"explainedByLight": {
"before": 0.9999597575085393,
"after": 0.028075104342772272
"before": 0.9999597575085377,
"after": 0.02807510434956728
},
"before": {
"upDownLuminanceRatio": 1.0000084632254227,
"occlusionCorrelation": 0.983967648279407
},
"after": {
"upDownLuminanceRatio": 0.9999964767503613,
"occlusionCorrelation": 0.40471079036691976
"upDownLuminanceRatio": 0.9999964767498971,
"occlusionCorrelation": 0.4047107903548106
},
"gain": {
"min": 0.9999809983875252,
"median": 1.0000990920451596,
"max": 5.493916964800697,
"min": 0.9999809983877584,
"median": 1.0000990920471027,
"max": 5.493916964801517,
"clamped": 0.0
}
},
@ -880,9 +814,9 @@
5.656854
],
"mirrorError": {
"X": 1.8120748396336225e-08,
"X": 1.8120748396474917e-08,
"Y": 0.1508370330678463,
"Z": 1.8363068583553207e-08
"Z": 1.836306858237196e-08
}
},
"knobPivot": [
@ -908,61 +842,6 @@
"inkInsideBefore": 192,
"inkInsideAfter": 0
},
"hulls": {
"fourth.glb": {
"polygons": 28426,
"polygonsAfter": 28420,
"turned": null,
"againstBefore": 388,
"againstAfter": 387,
"changes": {
"welded": 6437,
"facesCollapsedByWeld": 2,
"degenerateFacesRemoved": 4,
"looseEdgesRemoved": 0,
"looseVertsRemoved": 0,
"shellsRemoved": 0,
"holesFilled": 0,
"windingFlipped": 0,
"customNormalsDropped": false
}
},
"sub.glb": {
"polygons": 10406,
"polygonsAfter": 10406,
"turned": 0,
"againstBefore": 64,
"againstAfter": 64,
"changes": {
"welded": 2454,
"facesCollapsedByWeld": 0,
"degenerateFacesRemoved": 0,
"looseEdgesRemoved": 0,
"looseVertsRemoved": 0,
"shellsRemoved": 0,
"holesFilled": 0,
"windingFlipped": 0,
"customNormalsDropped": false
}
},
"third.glb": {
"polygons": 23341,
"polygonsAfter": 23340,
"turned": null,
"againstBefore": 189,
"againstAfter": 189,
"changes": {
"welded": 3810,
"facesCollapsedByWeld": 0,
"degenerateFacesRemoved": 1,
"looseEdgesRemoved": 0,
"looseVertsRemoved": 0,
"shellsRemoved": 0,
"holesFilled": 0,
"windingFlipped": 0,
"customNormalsDropped": false
}
}
},
"hulls": {},
"ok": true
}

View file

@ -0,0 +1,522 @@
"""Live proof, in a background Blender, of brokkr_kitbash/ram.py's clearance gate on meshes: the R-3 knee (thigh,
shin, the bracket and horn, a bell crank's or a four-bar's plates, pins and clevises), every piece a closed mesh this
file generates, each a named part of a body, and the gate answered by the package's signed BVH oracle (ram.Signed)
over them. Not part of the unittest run: it needs Blender (mathutils' BVHTree).
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/ram_knee.py -- <out>
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). <out> is an absolute path; writes <out>.result.json and <out>.r3_<angle>.png (the bell crank at 0,
-62.5 and -125) and exits 1 when a check failed.
The oracle is ram.Signed: a point is inside a part where the winding number of the part's faces about it is 0.5 or
more. tests/fixtures/ram_plates.json holds the rocker plates as Imagination's jointlib builds them, four closed bars
joined into one mesh, a side's two overlapping, and 29 points inside them: none reads outside. Nor does a point where
two welded boxes overlap. A part that is open, wound inside out or crossing itself is refused when the oracle is made, a
hollow mass and a part mirrored by its matrix are read, and the depth is to the part's surface: a face buried in another of the
part's solids is not read, and outside the distance is to the nearest face of all.
A clearance verdict is a sign, the gate's own. FLAT follows lodur:ruling:deterministic-bound-margin. The checks run
inside one try: an uncaught error is a failed check that names its section, and the result file is always written.
"""
import importlib.util
import json
import math
import os
import sys
import time
import traceback
from dataclasses import replace
from pathlib import Path
import bmesh
import bpy
import numpy as np
from mathutils import Matrix, Vector
SURFACE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(SURFACE / "tools"))
import private_dirs # noqa: E402
_refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if _refused:
raise SystemExit(_refused)
OUT = sys.argv[sys.argv.index("--") + 1]
if not Path(OUT).is_absolute():
raise SystemExit(f"{OUT!r} is not an absolute path")
spec = importlib.util.spec_from_file_location("brokkr_kitbash_ram", SURFACE / "brokkr_kitbash" / "ram.py")
R = importlib.util.module_from_spec(spec) # ram.py as the unit tests load it
sys.modules[spec.name] = R
spec.loader.exec_module(R)
Signed = R.Signed
RES = {"blender": bpy.app.version_string, "checks": [], "readings": {}}
SECTION = ["setup"]
# Metres between the oracle's reading and 0.0225, on a grid a plate's thickness off a rocker plate's face. Shipped
# worst 1.3e-08 (float32 faces); least claimed mutant 0.045 (a sample signed inside reads -0.0225); the geometric mean.
FLAT = 2.4e-5
BORE, PIN, AXLE = 0.042, 0.026, 0.028
SLAB_C, SLAB_R = (0.31, 0.345), (0.35, 0.385) # the twin link plates along the axis: the coupler's inside the rocker's
X_C, X_R = 0.5 * sum(SLAB_C), 0.5 * sum(SLAB_R)
HALF = 0.5 * (SLAB_R[1] - SLAB_R[0]) # half a plate's thickness
W_ROCKER, W_COUPLER, W_ARM, W_HORN, W_BRACKET, COLLAR = 0.045, 0.04, 0.04, 0.05, 0.055, 0.05
CHEEK = (0.03, 0.05) # a clevis's cheeks, either side of the ram's eye
SLACK = 0.001 # a zone's depth over the burial it lets: a float32 face reads a burial to 1e-8
# P2's seats, (y, z): the deep four-bar behind the knee and the bell crank in front of it
DEEP = {"a": (-0.45, 1.15), "rocker": (-0.2320142211320173, 0.4604939911625098), "p": (-0.43650046730511183, -0.017951928782268284),
"c": (0.06881023105761902, -0.3143743967236484), "d": (-0.43650046730511183, -0.017951928782268284)}
CRANK = {"a": (0.45, 1.15), "rocker": (0.3171126791600819, 0.3216537818398838), "p": (0.7282866960904424, 0.43261578669776135),
"c": (0.34929485118682846, 0.14862538079826304), "d": (0.48651463351122515, 0.49166254003196397)}
ROOTS = {"bell_crank": {"horn": (0.10, -0.40), "bracket": (0.10, 0.55)}, "four_bar": {"horn": (0.0, -0.42), "bracket": (-0.10, 0.55)}}
THIGH_FRONT, EMBED = 0.14, 0.01 # the thigh core's faces stand at y +-0.14; a foot runs this far into it
def check(name, ok, detail=None):
RES["checks"].append({"name": name, "ok": bool(ok), "detail": None if ok else detail})
def prism(outline, x0, x1):
"""A closed shell: the convex (y, z) outline, counter-clockwise seen from +x, run from x0 to x1."""
x0, x1 = min(x0, x1), max(x0, x1)
n = len(outline)
verts = [(x, y, z) for x in (x0, x1) for y, z in outline]
faces = [tuple(range(n - 1, -1, -1)), tuple(range(n, 2 * n))] + [(k, (k + 1) % n, n + (k + 1) % n, n + k) for k in range(n)]
return np.array(verts, dtype=float), faces
def box(centre, size):
(cx, cy, cz), (sx, sy, sz) = centre, size
return prism([(cy - sy / 2, cz - sz / 2), (cy + sy / 2, cz - sz / 2), (cy + sy / 2, cz + sz / 2), (cy - sy / 2, cz + sz / 2)], cx - sx / 2, cx + sx / 2)
def disc(at, r, x0, x1, n=32):
return prism([(at[0] + r * math.cos(2 * math.pi * k / n), at[1] + r * math.sin(2 * math.pi * k / n)) for k in range(n)], x0, x1)
def bar(p, q, w, x0, x1, n=10):
"""A link plate: the stadium of half width w about the segment p -> q."""
p, q = np.array(p, float), np.array(q, float)
base = math.atan2(*((q - p) / np.linalg.norm(q - p))[::-1])
pts = [(c[0] + w * math.cos(a0 + math.pi * k / n), c[1] + w * math.sin(a0 + math.pi * k / n)) for c, a0 in ((q, base - math.pi / 2), (p, base + math.pi / 2)) for k in range(n + 1)]
return prism(pts, x0, x1)
def knee(kind, pn, links=True):
"""part -> [shell], part -> body: the knee at rest (angle 0, every frame the parent's)."""
shells, front = {}, kind == "bell_crank"
def add(part, *made):
shells.setdefault(part, []).extend(made)
r, gap, cheek = 0.25, 0.22, 0.07
half = gap / 2 + cheek
add("parent.body", box((0, 0, 0.725), (0.26, 2 * THIGH_FRONT, 0.85)), box((0, 0.185, 0.725), (0.34, 0.06, 0.77)), box((0, 0, 0.2), (gap - 0.03, 0.24, 0.4)),
disc((0, 0), 0.9 * r, -(gap - 0.03) / 2, (gap - 0.03) / 2))
outline = [(r * math.cos(math.radians(a)), r * math.sin(math.radians(a))) for a in range(0, 181, 15)] + [(-0.12, -0.95), (0.12, -0.95)]
add("child.body", box((0, 0, -0.72), (gap, 0.22, 0.46)), box((0, 0.15, -0.62), (2 * half + 0.06, 0.06, 0.58)))
Rk, P, C, A, D = (pn[k] for k in ("rocker", "p", "c", "a", "d"))
for s in (-1, 1):
add("child.body", prism(outline, s * gap / 2, s * half), disc((0, 0), 0.19, s * half, s * (half + 0.025)), box((s * (half + 0.03), 0.0, -0.62), (0.045, 0.2, 0.5)))
add("child.horn", bar(ROOTS[kind]["horn"], C, W_HORN, s * (half + 0.05), s * SLAB_C[0]))
add("parent.bracket", bar(ROOTS[kind]["bracket"], Rk, W_BRACKET, s * 0.13, s * SLAB_R[0]))
# the base clevis: cheeks about the pin and a foot that runs into the thigh's core, toward it
toward = -1.0 if front else 1.0
foot = (A[0] + toward * 0.2, A[1])
add("parent.seat", bar(A, foot, 1.7 * BORE, s * CHEEK[0], s * CHEEK[1]))
if links:
add("rocker.plate", bar(Rk, P, W_ROCKER, s * SLAB_R[0], s * SLAB_R[1]))
add("coupler.plate", bar(P, C, W_COUPLER, s * SLAB_C[0], s * SLAB_C[1]))
add("rocker.seat", disc(D, COLLAR, s * CHEEK[0], s * CHEEK[1])) # the eye's collars on its pin
if front:
add("rocker.plate", bar(Rk, D, W_ARM, s * SLAB_R[0], s * SLAB_R[1]))
face = toward * (THIGH_FRONT - EMBED)
add("parent.seat", box((0, 0.5 * (face + foot[0]), A[1]), (2 * CHEEK[1], abs(foot[0] - face), 3.4 * BORE)))
if links:
add("rocker.pin.R", disc(Rk, AXLE, -SLAB_R[1] - 0.015, SLAB_R[1] + 0.015))
add("rocker.pin.p", disc(P, PIN, -SLAB_R[1] - 0.015, SLAB_R[1] + 0.015))
add("coupler.pin.c", disc(C, PIN, -SLAB_C[1] - 0.015, SLAB_C[1] + 0.015))
if front:
add("rocker.pin.d", disc(D, PIN, -SLAB_R[1] - 0.015, SLAB_R[1] + 0.015))
return shells, {part: {"parent": "parent", "child": "child", "rocker": "rocker", "coupler": "coupler"}[part.split(".")[0]] for part in shells}
def near(ram, member):
return {"barrel": ram.barrel_r, "rod": ram.rod}.get(member, ram.link_r) + ram.gap + ram.spacing() / 2
def parting(ram, w, degrees):
"""How far from a pin a link parts from a plate of half width w that stands beside it on the pin, a plate's
thickness off along the axis, the two crossing at `degrees` at the least: where the link's axis is what a link
keeps from the plate's edge, and never less than the plate's round end."""
lateral = math.sqrt(near(ram, "rocker") ** 2 - HALF ** 2)
return max((w + lateral) / math.sin(math.radians(min(degrees, 90.0))), w + near(ram, "rocker"))
def crossing(m, kind):
"""The least angle, over the range, at which the rocker, the rocker arm and the coupler cross what stands beside
them: the bracket's bar at the pivot, the horn's at c (seen from the shin), each other at p."""
p, n = R.pose(m, np.linspace(m.lo, m.hi, 126)), m.axis
def least(a, b):
a, b = R._flat(a, n), R._flat(np.broadcast_to(b, a.shape), n)
return float(np.degrees(np.arccos(np.clip((a * b).sum(axis=1) / (np.linalg.norm(a, axis=1) * np.linalg.norm(b, axis=1)), -1.0, 1.0))).min())
root = {key: np.array((0.0, *value)) for key, value in ROOTS[kind].items()}
seen = R._into(m, p, "child", p.P[:, None, :])[:, 0, :]
return {"rocker": least(p.P - m.rocker, root["bracket"] - m.rocker), "rocker arm": least(p.eye - m.rocker, root["bracket"] - m.rocker),
"coupler": least(seen - m.c, root["horn"] - m.c), "p": float(p.mu_p.min())}
def zones(m, ram, parts):
"""Each member's zones. About a pin: the pin's, collar's or cheek's radius plus what the member keeps, as deep as
the pin where it runs through the member's eye and 0 beside a collar, a cheek, the bracket or the horn; a link's
own plate about both its pins, each a little over half its length (a zone is no wider than its member), half
the plate's thickness deep; a plate beside a link as far as the two part. A depth that is not 0 is stated SLACK
over the burial."""
kind, link, at = m.kind, near(ram, "rocker"), crossing(m, m.kind)
PIN, AXLE, HALF = (value + SLACK for value in (globals()["PIN"], globals()["AXLE"], globals()["HALF"]))
reach = {"pin": globals()["PIN"] + link, "axle": globals()["AXLE"] + link}
eye = "rocker.pin.d" if kind == "bell_crank" else "rocker.pin.p"
def own(part, a, b, span):
return [(part, a, 0.51 * span, HALF), (part, b, 0.51 * span, HALF)]
def parts_at(member, w, degrees): # never wider than the member: two that cross at a few degrees part beyond its length
return min(parting(ram, w, degrees), R._span(m, member))
touch = {member: [("parent.seat", "a", 1.7 * BORE + near(ram, member), 0.0), ("rocker.seat", "d", COLLAR + near(ram, member), 0.0),
(eye, "d", globals()["PIN"] + near(ram, member), PIN if member == "rod" else 0.0)] for member in ("barrel", "rod")}
pivot = [("parent.bracket", "rocker", None, 0.0), ("rocker.pin.R", "rocker", reach["axle"], AXLE)]
touch["rocker"] = pivot + [("rocker.pin.p", "p", reach["pin"], PIN), *own("rocker.plate", "rocker", "p", m.lr), ("coupler.plate", "p", parts_at("rocker", W_COUPLER, at["p"]), 0.0)]
touch["coupler"] = [("child.horn", "c", parts_at("coupler", W_HORN, at["coupler"]), 0.0), ("coupler.pin.c", "c", reach["pin"], PIN), ("rocker.pin.p", "p", reach["pin"], PIN),
*own("coupler.plate", "p", "c", m.lc), ("rocker.plate", "p", parts_at("coupler", W_ROCKER, at["p"]), 0.0)]
if kind == "bell_crank":
touch["rocker arm"] = pivot + [("rocker.pin.d", "d", reach["pin"], PIN), *own("rocker.plate", "rocker", "d", R._span(m, "rocker arm"))]
for member in ("rocker", "rocker arm"):
if member in touch:
touch[member][0] = ("parent.bracket", "rocker", parts_at(member, W_BRACKET, at[member]), 0.0)
return {member: [zone for zone in given if zone[0] in parts] for member, given in touch.items()}
def pins3(pn, side=1.0, **moved):
at = {"a": 0.0, "p": 0.0, "d": 0.0, "rocker": side * X_R, "c": side * X_C, **moved}
return {k: (at[k], float(pn[k][0]), float(pn[k][1])) for k in pn}
def needs(m, ram, parts, distance, steps=49):
"""(member, part) -> (pin, radius, depth): for every pair refused with nothing let, the least zone that lets it."""
p = R.pose(m, np.linspace(m.lo, m.hi, steps))
at = {"a": p.base, R.EYE[m.kind]: p.eye, "rocker": m.rocker, "p": p.P, "c": p.C}
step, out = ram.spacing(), {}
for member, label, start, end, radius, pins in R._members(m, ram, R.barrel_length(m, ram), p):
count = max(int(math.ceil(float(np.linalg.norm(end - start, axis=1).max()) / step)) + 1, 2)
pts = start[:, None, :] + (end - start)[:, None, :] * np.linspace(0.0, 1.0, count)[None, :, None]
for part, body in parts.items():
got = distance(part, R._into(m, p, body, pts).reshape(-1, 3)).reshape(len(p.degrees), count)
bad = got < radius + ram.gap + step / 2
if bad.any():
best = None
for pin in pins:
across = np.linalg.norm(R._flat(pts - np.broadcast_to(at[pin], start.shape)[:, None, :], m.axis), axis=2)
reach = float(across[bad].max())
if best is None or reach < best[1]:
best = (pin, reach, max(-float(got[across <= reach].min()), 0.0))
out[(label, part)] = best
return out
def refused(f):
return sorted((pair, round(reading[0], 4), reading[1]) for pair, reading in f.pairs.items() if reading[0] < 0.0)
def label(member):
return member + "[0]" if member in ("barrel", "rod") else member
def hinge4(pivot, degrees):
return Matrix.Translation(Vector(pivot)) @ Matrix.Rotation(math.radians(degrees), 4, "X") @ Matrix.Translation(-Vector(pivot))
def render(m, ram, f, shells, parts):
"""The bell crank at 0, -62.5 and -125, each piece coloured by its part, the ram as the gate holds it."""
scene = bpy.context.scene
colour = {"horn": (0.95, 0.45, 0.1, 1), "bracket": (0.15, 0.45, 0.9, 1), "plate": (0.75, 0.75, 0.78, 1), "seat": (0.55, 0.3, 0.6, 1), "pin": (0.9, 0.9, 0.3, 1)}
objects = []
for part, made in shells.items():
for k, (verts, faces) in enumerate(made):
me = bpy.data.meshes.new(f"{part}.{k}")
me.from_pydata(verts.tolist(), [], faces)
o = bpy.data.objects.new(me.name, me)
scene.collection.objects.link(o)
o.color = colour.get(part.split(".")[1], (0.33, 0.38, 0.24, 1) if parts[part] == "child" else (0.3, 0.32, 0.36, 1))
objects.append((o, parts[part]))
def tube(name, r, col):
me, bm = bpy.data.meshes.new(name), bmesh.new()
bmesh.ops.create_cone(bm, cap_ends=True, segments=24, radius1=r, radius2=r, depth=1.0)
bmesh.ops.translate(bm, verts=bm.verts[:], vec=(0, 0, 0.5))
bm.to_mesh(me)
bm.free()
o = bpy.data.objects.new(name, me)
scene.collection.objects.link(o)
o.color = col
return o
barrel, rod = tube("ram.barrel", ram.barrel_r, (0.85, 0.15, 0.12, 1)), tube("ram.rod", ram.rod, (0.95, 0.95, 0.95, 1))
scene.render.engine = "BLENDER_WORKBENCH"
scene.display.shading.light, scene.display.shading.color_type = "STUDIO", "OBJECT"
scene.display.shading.show_shadows = scene.display.shading.show_cavity = True
scene.render.resolution_x, scene.render.resolution_y, scene.render.film_transparent = 1400, 1500, False
scene.world = bpy.data.worlds.new("w")
scene.world.color = (0.82, 0.83, 0.85)
cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam"))
scene.collection.objects.link(cam)
cam.data.type, cam.data.ortho_scale = "ORTHO", 2.75
target = Vector((0.0, 0.1, 0.12))
cam.location = target + Vector((0.72, 0.62, 0.22)).normalized() * 8.0
cam.rotation_euler = (target - cam.location).to_track_quat("-Z", "Y").to_euler()
scene.camera = cam
made = []
for angle in (0.0, -62.5, -125.0):
p = R.pose(m, angle)
T = {"parent": Matrix.Identity(4), "child": hinge4((0, 0, 0), angle), "rocker": hinge4(m.rocker, math.degrees(p.phi[0])),
"coupler": Matrix.Translation(Vector(p.P[0] - m.p)) @ hinge4(m.p, math.degrees(p.psi[0]))}
for o, body in objects:
o.matrix_world = T[body]
u, base = Vector(p.u[0]), Vector(p.base[0])
frame = u.to_track_quat("Z", "Y").to_matrix().to_4x4()
barrel.matrix_world = Matrix.Translation(base + u * ram.back) @ frame @ Matrix.Diagonal((1, 1, f.barrel, 1))
rod.matrix_world = Matrix.Translation(base + u * (ram.back + f.barrel)) @ frame @ Matrix.Diagonal((1, 1, float(p.L[0]) - ram.back - f.barrel, 1))
scene.render.filepath = f"{OUT}.r3_{abs(angle):g}".replace(".5", "p5") + ".png"
bpy.ops.render.render(write_still=True)
made.append(scene.render.filepath)
return made
try:
bpy.ops.wm.read_factory_settings(use_empty=True)
ram = R.Ram(BORE)
HINGE = ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0), -125.0, 0.0)
SECTION[0] = "oracle"
shells, parts = knee("bell_crank", CRANK)
rows = []
for name, part, point, depth in (("the thigh core's centre", "parent.body", (0.0, 0.0, 0.7), -0.13), ("0.02 inside the thigh's wall", "parent.body", (0.11, 0.0, 0.7), -0.02),
("the shin's leg centre", "child.body", (0.0, 0.0, -0.7), -0.11), ("0.125 off the thigh's plate", "parent.body", (0.0, 0.34, 0.7), 0.125)):
capped, free = (float(Signed(shells, cap)(part, np.array([point]))[0]) for cap in (ram.reach(), None))
rows.append((name, capped, free, abs(free - depth) < FLAT and capped == (free if depth < 0 else min(free, ram.reach()))))
check("inside-is-negative: a point inside a part reads its depth, negative, capped or not; a cap changes only what is outside", all(row[3] for row in rows), rows)
# a grid a plate's thickness off the rocker plates' inner face, over the knee: every point is 0.0225 or more from the
# plates and none is inside; where the plate is under the point the reading is the 0.0225
ys, zs = np.meshgrid(np.linspace(0.1, 0.9, 96), np.linspace(0.1, 0.7, 72))
plane = np.stack([np.full(ys.size, X_C), ys.ravel(), zs.ravel()], axis=1)
off_plates = Signed(shells)("rocker.plate", plane)
def off(a, b): # each grid point's distance from the segment a -> b, across the axis
a, b = np.array(a), np.array(b)
t = np.clip(((plane[:, 1:] - a) @ (b - a)) / ((b - a) @ (b - a)), 0.0, 1.0)
return np.linalg.norm(plane[:, 1:] - a - t[:, None] * (b - a), axis=1)
under = (off(CRANK["rocker"], CRANK["p"]) < W_ROCKER - 0.005) | (off(CRANK["rocker"], CRANK["d"]) < W_ARM - 0.005)
RES["readings"]["FLAT"] = float(np.abs(off_plates[under] - (SLAB_R[0] - X_C)).max())
check("off-the-plates: on a plane 0.0225 off the rocker plates no sample reads inside or nearer, and under a plate each reads the 0.0225",
(off_plates >= SLAB_R[0] - X_C - FLAT).all() and under.sum() > 500 and RES["readings"]["FLAT"] < FLAT, [float(off_plates.min()), int(under.sum()), RES["readings"]["FLAT"]])
# against a shell whose inside is known in closed form: a box, random points
rng = np.random.default_rng(7)
cloud = rng.uniform((-0.2, -0.2, 0.2), (0.2, 0.2, 1.25), (4000, 3))
core = Signed({"core": [box((0, 0, 0.725), (0.26, 0.28, 0.85))]})("core", cloud)
exact = np.maximum.reduce([np.abs(cloud[:, 0]) - 0.13, np.abs(cloud[:, 1]) - 0.14, np.abs(cloud[:, 2] - 0.725) - 0.425])
check("box: 4000 random points about a box are signed as the box signs them", ((core < 0) == (exact < 0)).all(), int(((core < 0) != (exact < 0)).sum()))
# what the gate's proof between samples leans on: no point inside a part reads outside. The jointlib rocker plates
# are four closed bars in one mesh, a side's two overlapping about the pivot (crossing parity read the overlap
# outside); the fixture's 29 points are 0.001 or more inside a bar, 13 of them inside two. A count of points
fixture = json.loads((SURFACE / "tests" / "fixtures" / "ram_plates.json").read_text(encoding="utf-8"))
plates = Signed({"plates": [(np.array(fixture["verts"]), fixture["faces"])]})("plates", np.array(fixture["inside"]))
# two boxes cut through one another and welded at the corner they share
def wound(lo, hi):
verts = np.array([[x, y, z] for x in (lo[0], hi[0]) for y in (lo[1], hi[1]) for z in (lo[2], hi[2])], float)
return verts, [(0, 1, 3, 2), (4, 6, 7, 5), (0, 4, 5, 1), (2, 3, 7, 6), (0, 2, 6, 4), (1, 5, 7, 3)]
(v1, f1), (v2, f2) = wound((0, 0, 0), (1, 1, 1)), wound((0, 0, 0), (2, 0.5, 0.5))
welded = (np.concatenate([v1, v2[1:]]), f1 + [tuple(i + 7 if i else 0 for i in face) for face in f2])
cloud = rng.uniform(-0.2, 2.2, (6000, 3))
truth = ((cloud >= 0) & (cloud <= 1)).all(axis=1) | ((cloud >= 0) & (cloud <= (2, 0.5, 0.5))).all(axis=1)
both = ((cloud >= 0) & (cloud <= (1, 0.5, 0.5))).all(axis=1)
got = Signed({"welded": [welded]})("welded", cloud) < 0
RES["readings"]["jointlib plates: inside points read outside, of %d" % len(plates)] = int((plates >= 0).sum())
RES["readings"]["welded boxes: points missigned, of %d (%d in the overlap)" % (len(cloud), int(both.sum()))] = int((got != truth).sum())
check("inside-reads-inside: no point inside the jointlib rocker plates' bars or in two welded boxes' overlap reads outside, and none outside the boxes reads inside",
len(plates) == 29 and int((plates >= 0).sum()) == 0 and int(both.sum()) > 50 and int((got != truth).sum()) == 0,
[int((plates >= 0).sum()), int(both.sum()), int((got != truth).sum())])
# a part with no inside to sign is refused when the oracle is made, by its reason: a cube with its top off, or
# two adjacent faces off, is open; a cube turned over or mirrored with its winding kept, or a turned-over bar beside
# a whole cube, is a solid of negative volume and wound inside out; the bar welded to the cube along an edge (one
# solid, a positive volume in all) crosses itself, and is told where. What has an inside is read: a mirrored cube handed as its own mesh and its matrix, and a hollow mass, its cavity an inward shell
def one(*meshes):
at, faces = {}, []
for v, f in meshes:
index = [at.setdefault(tuple(float(x) for x in q), len(at)) for q in v]
faces += [tuple(index[i] for i in face) for face in f]
return np.array(list(at)), faces
turned = [face[::-1] for face in f1]
rail = wound((1, 0, -0.2), (1.2, 1, 0))
said = {}
for name, made in (("top off", [(v1, [face for face in f1 if face != (1, 5, 7, 3)])]), ("two faces off", [(v1, [face for face in f1 if face not in ((1, 5, 7, 3), (2, 3, 7, 6))])]),
("turned over", [(v1, turned)]), ("mirrored", [(v1 * (-1, 1, 1), f1)]), ("a turned-over bar beside a cube", [(v1, f1), (v2 + (0, 2, 0), [face[::-1] for face in f2])]),
("a turned-over bar welded to a cube", [one((v1, f1), (rail[0], [face[::-1] for face in rail[1]]))])):
try:
Signed({"cube": made})
said[name] = None
except R.RamError as error:
said[name] = str(error)
RES["refusals"] = said
want = {"top off": "is open: solid 0 of 1 has 4 edges", "two faces off": "is open: solid 0 of 1 has 6 edges", "turned over": "is wound inside out: solid 0 of 1 has a volume of -0.192 of the part's extent cubed, and 6 of its faces, from face 0, stand before a region that winds -1",
"mirrored": "is wound inside out: solid 0 of 1 has a volume of -0.192 of the part's extent cubed, and 6 of its faces, from face 0, stand before a region that winds -1",
"a turned-over bar beside a cube": "is wound inside out: solid 1 of 2 has a volume of -0.0133 of the part's extent cubed, and 6 of its faces, from face 6, stand before a region that winds -1",
"a turned-over bar welded to a cube": "crosses itself: 6 faces, from face 6 of solid 0 of 1, stand before a region that winds -1"}
check("no-inside-is-refused: an open part is refused by its solid and edge count, an inside-out one by its solid's negative volume, and a turned-over bar welded to a whole cube as crossing itself about (1.1, 0.5, -0.1), never as inside out",
len(one((v1, f1), rail)[0]) == 14 and all(said[name] is not None and "part 'cube' " + text in said[name] for name, text in want.items())
and "about (1.1, 0.5, -0.1) and within 0.5 of it" in said["a turned-over bar welded to a cube"] and "inside out" not in said["a turned-over bar welded to a cube"], said)
hollow = [wound((-1, -1, -1), (1, 1, 1)), (lambda v, f: (v, [face[::-1] for face in f]))(*wound((0.4, 0.4, 0.4), (0.6, 0.6, 0.6)))]
at = np.array([(0.5, 0.5, 0.5), (0.0, 0.0, 0.0), (0.5, 0.5, 0.95), (1.2, 0.0, 0.0)])
left = np.array([(-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, 0.9)])
cavity, mirrored = Signed({"p": hollow})("p", at), Signed({"p": [(v1, f1, np.diag((-1.0, 1.0, 1.0, 1.0)))]})("p", left)
RES["readings"]["hollow mass: in the cavity, in the wall by it, under the outer face, outside"] = cavity.tolist()
RES["readings"]["mirrored cube by its matrix: inside, across the mirror, under its top"] = mirrored.tolist()
check("an-inside-is-read: a cavity reads outside and the wall about it by its depth to the cavity; a cube mirrored by its matrix reads as the cube it is",
float(np.abs(cavity - (0.1, -0.4 * math.sqrt(3.0), -0.05, 0.2)).max()) < FLAT and float(np.abs(mirrored - (-0.5, 0.5, -0.1)).max()) < FLAT, [cavity.tolist(), mirrored.tolist()])
# the exposed faces, where a reading turns on them. Outside, the distance is to the nearest face of all: a slab
# with a boss through its middle has its two great faces left out (their centroids are in the boss), and points
# off them read 0.05 and 0.02, not the 0.206 and 0.4 to the nearest exposed face. Two plates stacked 1e-5 of the
# extent apart are two surfaces: under the lower one's top the depth is 0.02, where a nudge of 1e-4 reads that
# face buried in the upper plate and the depth 0.08 to the bottom. A cube turned 0.3, 0.5 and 0.7 radians about
# x, y and z has no face along an axis: its six sides are held at 1e-6 and to 1e-8 (the corners' offsets are
# single precision), and at 1e-9 four read buried
slab = [wound((-1, -1, -0.1), (1, 1, 0.1)), wound((-0.2, -0.2, -0.5), (0.2, 0.2, 0.5))]
off = Signed({"p": slab})("p", np.array([(0.8, 0.0, 0.15), (0.6, 0.6, 0.12), (0.0, 0.0, 0.7), (0.5, 0.0, -0.3)]))
gap = 1e-5 * math.sqrt(2.0 + 0.2 ** 2)
stacked = Signed({"p": [wound((0, 0, 0), (1, 1, 0.1)), wound((0, 0, 0.1 + gap), (1, 1, 0.2 + gap))]})("p", np.array([(0.5, 0.5, 0.08), (0.5, 0.5, 0.12 + gap), (0.5, 0.5, 0.1 + 0.5 * gap)]))
(ca, sa), (cb, sb), (cc, sc) = ((math.cos(t), math.sin(t)) for t in (0.3, 0.5, 0.7))
spin = np.array([[1, 0, 0], [0, ca, -sa], [0, sa, ca]]) @ np.array([[cb, 0, sb], [0, 1, 0], [-sb, 0, cb]]) @ np.array([[cc, -sc, 0], [sc, cc, 0], [0, 0, 1]])
under = 0.9 * np.array([(1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, -1, 0), (0, 0, 1), (0, 0, -1)], float)
spun = Signed({"p": [(cube_v @ spin.T, cube_f) for cube_v, cube_f in [wound((-1, -1, -1), (1, 1, 1))]]})("p", under @ spin.T)
RES["readings"]["slab with a boss through it: off its faces (0.05, 0.02), off the boss's end (0.2), under it (0.2)"] = off.tolist()
RES["readings"]["plates stacked 1e-5 of the extent apart: under the lower's top (0.02), over the upper's bottom (0.02), between them"] = stacked.tolist()
RES["readings"]["a turned cube: 0.1 under each face"] = spun.tolist()
check("exposed-faces-are-read-where-they-are: outside is to the nearest face of all, plates 1e-5 of the extent apart are two surfaces, and a turned cube's six faces are all its surface",
float(np.abs(off - (0.05, 0.02, 0.2, 0.2)).max()) < FLAT and float(np.abs(stacked - (-0.02, -0.02, 0.5 * gap)).max()) < FLAT and float(np.abs(spun + 0.1).max()) < FLAT, [off.tolist(), stacked.tolist(), spun.tolist()])
# the depth is to the part's surface, not to a face buried in another of its solids: a cube of half side 1 with a
# box of side 0.2 buried about (0.5, 0.5, 0.5) reads its own depth by the box and at its centre (the nearest face
# of all is the buried box's: 0.05 and 0.693). A boss through a wall is read, not checked: its side faces cross the
# wall and are kept whole by their centroids, so in the wall by the boss the depth reads to their buried stretch
cube, small = wound((-1, -1, -1), (1, 1, 1)), wound((0.4, 0.4, 0.4), (0.6, 0.6, 0.6))
boss = wound((0.9, -0.5, -0.5), (1.5, 0.5, 0.5))
at = np.array([(0.5, 0.5, 0.55), (0.0, 0.0, 0.0), (0.5, 0.5, 0.95), (0.5, 0.5, 0.5), (1.2, 0.0, 0.0)])
alone, buried, bossed = Signed({"p": [cube]})("p", at), Signed({"p": [cube, small]})("p", at), Signed({"p": [cube, boss]})("p", np.array([(0.95, 0.0, 0.0), (0.7, 0.0, 0.0), (1.2, 0.0, 0.0), (1.6, 0.0, 0.0)]))
RES["readings"]["buried box: depth by it, at the cube's centre, under the cube's face, at the box's centre; outside"] = buried.tolist()
RES["readings"]["boss through a wall (faces that cross a solid are kept or left whole): in both (the surface is 0.502 off), in the wall (0.583), in the boss (0.2), off it (0.1)"] = bossed.tolist()
check("depth-is-to-the-surface: a face buried in another solid of the part is not read: by a buried box the cube reads as the cube alone",
float(np.abs(buried - (-0.45, -1.0, -0.05, -0.5, 0.2)).max()) < FLAT and float(np.abs(buried - alone).max()) < FLAT,
[buried.tolist(), alone.tolist()])
SECTION[0] = "seat"
seat = np.concatenate([v for v, _ in shells["parent.seat"]])
deepest = float(Signed(shells)("parent.body", seat).min())
RES["readings"]["the base clevis's foot inside the thigh"] = deepest
check("the base clevis is seated: its foot runs 0.01 into the thigh's core, through the front plate", abs(deepest + EMBED) < FLAT, deepest)
SECTION[0] = "bell crank"
winner = None
for side in (1.0, -1.0):
m = R.Mechanism("bell_crank", *HINGE, **pins3(CRANK, side), parts=parts)
touch = zones(m, ram, parts)
m = replace(m, touch=touch)
zoned = {(label(member), zone[0]) for member, given in touch.items() for zone in given}
t0 = time.perf_counter()
f = R._fit(m, ram, steps=49, distance=Signed(shells, ram.reach()))
seconds = time.perf_counter() - t0
check(f"bell-crank-clears-on-meshes (side {side:+.0f}): over 0..-125 at 49 steps every member is clear of every part, 5 x {len(parts)} pairs, beside its pins by the record's zones",
f.ok and len(f.pairs) == 5 * len(parts) and set(f.allowed) == zoned, [f.report(), refused(f)])
fine = R._fit(m, ram, steps=251, distance=Signed(shells))
check(f"bell-crank-clears-on-meshes (side {side:+.0f}): and at 251 steps with the oracle uncapped", fine.ok, [fine.report(), refused(fine)])
bare = R._fit(replace(m, touch={}), ram, steps=49, distance=Signed(shells, ram.reach()))
need = needs(m, ram, parts, Signed(shells))
stated = {}
for member, given in touch.items():
for zone in given:
stated.setdefault((label(member), zone[0]), []).append(zone)
def takes(given, pin, radius, depth): # one zone about the pin, or zones about both of the member's pins that meet
return all(zone[3] >= depth for zone in given) and (any(zone[1] == pin and zone[2] >= radius for zone in given)
or (len({zone[1] for zone in given}) == 2 and sum(zone[2] for zone in given) >= radius))
slack = {pair: takes(stated[pair], *least) for pair, least in need.items() if pair in stated}
check(f"zones (side {side:+.0f}): with nothing let the gate refuses, and only pairs the record zones; each stated zone takes in the least that lets its pair",
{pair for pair, _, _ in refused(bare)} == set(need) and set(need) <= zoned and all(slack.values()), [refused(bare), sorted(set(need) - zoned), [k for k, v in slack.items() if not v]])
if side > 0:
winner = (m, f)
def free(fit): # the least margin of the pairs no zone lets: a zoned pair's is its depth's slack at the pin
return min(reading[0] for pair, reading in fit.pairs.items() if pair not in zoned)
RES["readings"].update({"bell crank: least margin of a pair with no zone, 251 steps uncapped": free(fine),
"bell crank: least margin of a zoned pair, 251 steps uncapped": min(reading[0] for pair, reading in fine.pairs.items() if pair in zoned),
"bell crank: pairs": len(f.pairs), "bell crank: zoned pairs": len(f.allowed), "bell crank: pairs refused with nothing let": len(refused(bare)),
"bell crank: seconds, 49 steps capped": seconds})
RES["zones"] = {f"{pair[0]} | {pair[1]}": {"stated": [list(zone[1:]) for zone in stated[pair]], "least": [pin, round(radius, 4), round(depth, 4)]} for pair, (pin, radius, depth) in sorted(need.items()) if pair in stated}
RES["least pairs"] = sorted((round(v[0], 4), v[1], k[0], k[1]) for k, v in fine.pairs.items() if k not in zoned)[:8]
SECTION[0] = "zones end"
m, f = winner
for member, part in (("rocker", "parent.bracket"), ("coupler", "child.horn"), ("rod", "rocker.pin.d")):
short = {**m.touch, member: tuple((p_, pin, 0.5 * radius, depth) if p_ == part else (p_, pin, radius, depth) for p_, pin, radius, depth in m.touch[member])}
got = R._fit(replace(m, touch=short), ram, steps=49, distance=Signed(shells, ram.reach()))
check(f"a zone ends at its radius: {member}'s about {part} cut to half, that pair alone is refused", [pair for pair, _, _ in refused(got)] == [(label(member), part)], refused(got))
SECTION[0] = "moved x"
# Soul's let_hide probes: a link's place along the axis moved from beside the bracket or horn into it
for name, moved, expect in (("the rocker at x 0.25, inside the bracket's 0.13..0.35", {"rocker": 0.25}, {("rocker", "parent.bracket"), ("rocker arm", "parent.bracket")}),
("the coupler at x 0.25, inside the horn's 0.23..0.31", {"c": 0.25}, {("coupler", "child.horn")}),
("both", {"rocker": 0.25, "c": 0.25}, {("rocker", "parent.bracket"), ("rocker arm", "parent.bracket"), ("coupler", "child.horn")})):
mm = R.Mechanism("bell_crank", *HINGE, **pins3(CRANK, 1.0, **moved), parts=parts, touch=m.touch)
got = R._fit(mm, ram, steps=49, distance=Signed(shells, ram.reach()))
inside = {pair: reading for pair, reading, _ in refused(got)}
RES["readings"]["moved x: " + name] = min(inside.values()) if inside else 0.0
check(f"a pin stood inside what it stands beside is refused: {name}", not got.ok and expect <= set(inside) and all(inside[pair] < -0.015 for pair in expect), refused(got))
SECTION[0] = "four bar"
shells4, parts4 = knee("four_bar", DEEP)
m4 = R.Mechanism("four_bar", *HINGE, **pins3(DEEP), parts=parts4)
m4 = replace(m4, touch=zones(m4, ram, parts4))
f4 = R._fit(m4, ram, steps=49, distance=Signed(shells4, ram.reach()))
hit = {pair: reading for pair, reading, _ in refused(f4)}
RES["readings"]["four bar: barrel inside the shin's clearance"] = hit.get(("barrel[0]", "child.body"), 0.0)
check("third-body: the deep four-bar's ram is refused on the shin, which folds into it", not f4.ok and {("barrel[0]", "child.body"), ("rod[0]", "child.body")} <= set(hit) and f4.clear_at[2] == "child.body", refused(f4))
SECTION[0] = "search"
seats = {"rocker": [(X_R, *CRANK["rocker"]), (X_R, CRANK["rocker"][0] - 0.07, CRANK["rocker"][1] + 0.03)], "c": [(X_C, *CRANK["c"]), (X_C, CRANK["c"][0] - 0.05, CRANK["c"][1] + 0.03)],
"a": [(0.0, *CRANK["a"]), (0.0, 0.4, 1.0)], "link": (0.35, 0.5, 3), "d": (0.2, 0.26, 2)}
built = []
def world(mech):
made, bodies = knee("bell_crank", {k: (float(getattr(mech, k)[1]), float(getattr(mech, k)[2])) for k in CRANK})
built.append(mech)
return bodies, zones(mech, ram, bodies), Signed(made, ram.reach())
t0 = time.perf_counter()
s = R.search("bell_crank", {"pivot": HINGE[0], "axis": HINGE[1], "lo": -125, "hi": 0}, ram, seats, world=world, steps=49)
RES["readings"].update({"search: seconds": time.perf_counter() - t0, "search: candidates": s.tried, "search: pass the gates before clearance": s.fits,
"search: worlds built": len(built), "search: refused on their own parts": s.tally.get("clash", 0)})
RES["search"] = {"report": s.report(), "seat": {k: np.round(v, 4).tolist() for k, v in (s.seat or {}).items()}, "tally": s.tally}
again = R._fit(s.best.m, ram, steps=251, distance=world(s.best.m)[2]) if s.found else None
check("search-holds-candidate-links: a seat grid about the probe's bell crank, each candidate met with the meshes its own pins place, runs to a fit that holds at 251 steps",
s.found and s.best.ok and len(built) - 1 == s.tally.get("clash", 0) + 1 and again.ok and len(s.best.pairs) == 5 * len(parts), [s.report(), refused(again) if again else None])
SECTION[0] = "render"
RES["renders"] = render(winner[0], ram, winner[1], shells, parts)
check("the bell crank is drawn at 0, -62.5 and -125", all(Path(path).is_file() for path in RES["renders"]), RES["renders"])
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, not a missing result file
check(f"no uncaught error in section: {SECTION[0]}", False, traceback.format_exc().splitlines()[-8:])
finally:
RES["ok"] = all(c["ok"] for c in RES["checks"])
RES["readings"] = {name: (float(f"{value:.3g}") if isinstance(value, float) else value) for name, value in sorted(RES["readings"].items())}
Path(OUT + ".result.json").write_text(json.dumps(RES, indent=1, default=str), encoding="utf-8")
for c in RES["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
print("READINGS", RES["readings"], flush=True)
sys.exit(0 if RES["ok"] else 1)

View file

@ -0,0 +1,574 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "inside-is-negative: a point inside a part reads its depth, negative, capped or not; a cap changes only what is outside",
"ok": true,
"detail": null
},
{
"name": "off-the-plates: on a plane 0.0225 off the rocker plates no sample reads inside or nearer, and under a plate each reads the 0.0225",
"ok": true,
"detail": null
},
{
"name": "box: 4000 random points about a box are signed as the box signs them",
"ok": true,
"detail": null
},
{
"name": "inside-reads-inside: no point inside the jointlib rocker plates' bars or in two welded boxes' overlap reads outside, and none outside the boxes reads inside",
"ok": true,
"detail": null
},
{
"name": "no-inside-is-refused: an open part is refused by its solid and edge count, an inside-out one by its solid's negative volume, and a turned-over bar welded to a whole cube as crossing itself about (1.1, 0.5, -0.1), never as inside out",
"ok": true,
"detail": null
},
{
"name": "an-inside-is-read: a cavity reads outside and the wall about it by its depth to the cavity; a cube mirrored by its matrix reads as the cube it is",
"ok": true,
"detail": null
},
{
"name": "exposed-faces-are-read-where-they-are: outside is to the nearest face of all, plates 1e-5 of the extent apart are two surfaces, and a turned cube's six faces are all its surface",
"ok": true,
"detail": null
},
{
"name": "depth-is-to-the-surface: a face buried in another solid of the part is not read: by a buried box the cube reads as the cube alone",
"ok": true,
"detail": null
},
{
"name": "the base clevis is seated: its foot runs 0.01 into the thigh's core, through the front plate",
"ok": true,
"detail": null
},
{
"name": "bell-crank-clears-on-meshes (side +1): over 0..-125 at 49 steps every member is clear of every part, 5 x 12 pairs, beside its pins by the record's zones",
"ok": true,
"detail": null
},
{
"name": "bell-crank-clears-on-meshes (side +1): and at 251 steps with the oracle uncapped",
"ok": true,
"detail": null
},
{
"name": "zones (side +1): with nothing let the gate refuses, and only pairs the record zones; each stated zone takes in the least that lets its pair",
"ok": true,
"detail": null
},
{
"name": "bell-crank-clears-on-meshes (side -1): over 0..-125 at 49 steps every member is clear of every part, 5 x 12 pairs, beside its pins by the record's zones",
"ok": true,
"detail": null
},
{
"name": "bell-crank-clears-on-meshes (side -1): and at 251 steps with the oracle uncapped",
"ok": true,
"detail": null
},
{
"name": "zones (side -1): with nothing let the gate refuses, and only pairs the record zones; each stated zone takes in the least that lets its pair",
"ok": true,
"detail": null
},
{
"name": "a zone ends at its radius: rocker's about parent.bracket cut to half, that pair alone is refused",
"ok": true,
"detail": null
},
{
"name": "a zone ends at its radius: coupler's about child.horn cut to half, that pair alone is refused",
"ok": true,
"detail": null
},
{
"name": "a zone ends at its radius: rod's about rocker.pin.d cut to half, that pair alone is refused",
"ok": true,
"detail": null
},
{
"name": "a pin stood inside what it stands beside is refused: the rocker at x 0.25, inside the bracket's 0.13..0.35",
"ok": true,
"detail": null
},
{
"name": "a pin stood inside what it stands beside is refused: the coupler at x 0.25, inside the horn's 0.23..0.31",
"ok": true,
"detail": null
},
{
"name": "a pin stood inside what it stands beside is refused: both",
"ok": true,
"detail": null
},
{
"name": "third-body: the deep four-bar's ram is refused on the shin, which folds into it",
"ok": true,
"detail": null
},
{
"name": "search-holds-candidate-links: a seat grid about the probe's bell crank, each candidate met with the meshes its own pins place, runs to a fit that holds at 251 steps",
"ok": true,
"detail": null
},
{
"name": "the bell crank is drawn at 0, -62.5 and -125",
"ok": true,
"detail": null
}
],
"readings": {
"FLAT": 8.34e-09,
"a turned cube: 0.1 under each face": [
-0.09999994188547134,
-0.09999997913837433,
-0.09999998658895493,
-0.09999998658895493,
-0.10000001639127731,
-0.10000001639127731
],
"bell crank: least margin of a pair with no zone, 251 steps uncapped": 0.0336,
"bell crank: least margin of a zoned pair, 251 steps uncapped": 0.000118,
"bell crank: pairs": 60,
"bell crank: pairs refused with nothing let": 19,
"bell crank: seconds, 49 steps capped": 1.87,
"bell crank: zoned pairs": 20,
"boss through a wall (faces that cross a solid are kept or left whole): in both (the surface is 0.502 off), in the wall (0.583), in the boss (0.2), off it (0.1)": [
-0.5,
-0.5385164618492126,
-0.2999999523162842,
0.10000002384185791
],
"buried box: depth by it, at the cube's centre, under the cube's face, at the box's centre; outside": [
-0.44999998807907104,
-1.0,
-0.050000011920928955,
-0.5,
0.20000004768371582
],
"four bar: barrel inside the shin's clearance": -0.122,
"hollow mass: in the cavity, in the wall by it, under the outer face, outside": [
0.09999999403953552,
-0.6928203105926514,
-0.050000011920928955,
0.20000004768371582
],
"jointlib plates: inside points read outside, of 29": 0,
"mirrored cube by its matrix: inside, across the mirror, under its top": [
-0.5,
0.5,
-0.10000002384185791
],
"moved x: both": -0.0543,
"moved x: the coupler at x 0.25, inside the horn's 0.23..0.31": -0.02,
"moved x: the rocker at x 0.25, inside the bracket's 0.13..0.35": -0.0543,
"plates stacked 1e-5 of the extent apart: under the lower's top (0.02), over the upper's bottom (0.02), between them": [
-0.020000003278255463,
-0.019999995827674866,
7.137656211853027e-06
],
"search: candidates": 13824,
"search: pass the gates before clearance": 78,
"search: refused on their own parts": 21,
"search: seconds": 45.2,
"search: worlds built": 22,
"slab with a boss through it: off its faces (0.05, 0.02), off the boss's end (0.2), under it (0.2)": [
0.05000000447034836,
0.019999995827674866,
0.19999998807907104,
0.20000001788139343
],
"the base clevis's foot inside the thigh": -0.01,
"welded boxes: points missigned, of 6000 (91 in the overlap)": 0
},
"refusals": {
"top off": "mesh ram: signed: part 'cube' is open: solid 0 of 1 has 4 edges no face runs the other way",
"two faces off": "mesh ram: signed: part 'cube' is open: solid 0 of 1 has 6 edges no face runs the other way",
"turned over": "mesh ram: signed: part 'cube' is wound inside out: solid 0 of 1 has a volume of -0.192 of the part's extent cubed, and 6 of its faces, from face 0, stand before a region that winds -1.01",
"mirrored": "mesh ram: signed: part 'cube' is wound inside out: solid 0 of 1 has a volume of -0.192 of the part's extent cubed, and 6 of its faces, from face 0, stand before a region that winds -1.01",
"a turned-over bar beside a cube": "mesh ram: signed: part 'cube' is wound inside out: solid 1 of 2 has a volume of -0.0133 of the part's extent cubed, and 6 of its faces, from face 6, stand before a region that winds -1",
"a turned-over bar welded to a cube": "mesh ram: signed: part 'cube' crosses itself: 6 faces, from face 6 of solid 0 of 1, stand before a region that winds -1 and holds 0.0271 of the part's extent cubed, about (1.1, 0.5, -0.1) and within 0.5 of it, and no solid there has a negative volume: its surfaces cut through one another (cutters never joined, a fold), or a turned piece is welded into a whole one"
},
"zones": {
"barrel[0] | parent.seat": {
"stated": [
[
"a",
0.15645000000000003,
0.0
]
],
"least": [
"a",
0.1222,
0.0
]
},
"barrel[0] | rocker.pin.d": {
"stated": [
[
"d",
0.11105000000000001,
0.0
]
],
"least": [
"d",
0.1108,
0.0
]
},
"barrel[0] | rocker.seat": {
"stated": [
[
"d",
0.13505,
0.0
]
],
"least": [
"d",
0.1263,
0.0
]
},
"coupler | child.horn": {
"stated": [
[
"c",
0.11195,
0.0
]
],
"least": [
"c",
0.0947,
0.0
]
},
"coupler | coupler.pin.c": {
"stated": [
[
"c",
0.08795,
0.027
]
],
"least": [
"c",
0.0474,
0.0259
]
},
"coupler | coupler.plate": {
"stated": [
[
"p",
0.24152975906703586,
0.018500000000000016
],
[
"c",
0.24152975906703586,
0.018500000000000016
]
],
"least": [
"p",
0.4736,
0.0175
]
},
"coupler | rocker.pin.p": {
"stated": [
[
"p",
0.08795,
0.027
]
],
"least": [
"p",
0.0474,
0.0259
]
},
"coupler | rocker.plate": {
"stated": [
[
"p",
0.2818973893266964,
0.0
]
],
"least": [
"p",
0.2368,
0.0
]
},
"rocker | coupler.plate": {
"stated": [
[
"p",
0.26840002998268986,
0.0
]
],
"least": [
"p",
0.2366,
0.0
]
},
"rocker | parent.bracket": {
"stated": [
[
"rocker",
0.11695,
0.0
]
],
"least": [
"rocker",
0.0946,
0.0
]
},
"rocker | rocker.pin.R": {
"stated": [
[
"rocker",
0.08995,
0.029
]
],
"least": [
"rocker",
0.0473,
0.0279
]
},
"rocker | rocker.pin.p": {
"stated": [
[
"p",
0.08795,
0.027
]
],
"least": [
"p",
0.0473,
0.0259
]
},
"rocker | rocker.plate": {
"stated": [
[
"rocker",
0.2172005150345214,
0.018500000000000016
],
[
"p",
0.2172005150345214,
0.018500000000000016
]
],
"least": [
"rocker",
0.4259,
0.0175
]
},
"rocker arm | parent.bracket": {
"stated": [
[
"rocker",
0.11695,
0.0
]
],
"least": [
"rocker",
0.096,
0.0
]
},
"rocker arm | rocker.pin.R": {
"stated": [
[
"rocker",
0.08995,
0.029
]
],
"least": [
"rocker",
0.048,
0.0279
]
},
"rocker arm | rocker.pin.d": {
"stated": [
[
"d",
0.08795,
0.027
]
],
"least": [
"d",
0.048,
0.0259
]
},
"rocker arm | rocker.plate": {
"stated": [
[
"rocker",
0.12240000000000001,
0.018500000000000016
],
[
"d",
0.12240000000000001,
0.018500000000000016
]
],
"least": [
"rocker",
0.24,
0.0175
]
},
"rod[0] | rocker.pin.d": {
"stated": [
[
"d",
0.07955,
0.027
]
],
"least": [
"d",
0.0794,
0.0259
]
},
"rod[0] | rocker.seat": {
"stated": [
[
"d",
0.10355,
0.0
]
],
"least": [
"d",
0.0938,
0.0
]
}
},
"least pairs": [
[
0.0336,
-125.0,
"rocker",
"rocker.pin.d"
],
[
0.0393,
-125.0,
"rod[0]",
"rocker.pin.R"
],
[
0.0417,
0.0,
"coupler",
"parent.bracket"
],
[
0.0579,
0.0,
"rocker arm",
"coupler.plate"
],
[
0.0687,
0.0,
"coupler",
"rocker.pin.R"
],
[
0.0766,
0.0,
"rocker",
"child.horn"
],
[
0.0766,
0.0,
"rocker arm",
"child.horn"
],
[
0.0808,
-125.0,
"coupler",
"child.body"
]
],
"search": {
"report": "78 of 13824 candidates pass the gates before clearance (failed: arm 1406, assembly 4800, clash 21, load 1355, stroke 1160, toggle 7352); best: OK: L 0.664..0.968, barrel 0.513, stroke 0.458 for travel 0.304 (spare +0.137), arm >= 0.090, rocker swing 99.9, pin load <= 0.73, transmission >= 17.3 deg, clear +0.000",
"seat": {
"a": [
0.0,
0.45,
1.15
],
"rocker": [
0.3675,
0.3171,
0.3217
],
"p": [
0.3675,
0.7683,
0.5372
],
"c": [
0.3275,
0.3493,
0.1486
],
"d": [
0.0,
0.4303,
0.4866
]
},
"tally": {
"assembly": 4800,
"toggle": 7352,
"arm": 1406,
"stroke": 1160,
"load": 1355,
"clash": 21
}
},
"renders": [
"F:/aeth-wt/hands-ramlows6-scratch/out/live/knee.r3_0.png",
"F:/aeth-wt/hands-ramlows6-scratch/out/live/knee.r3_62p5.png",
"F:/aeth-wt/hands-ramlows6-scratch/out/live/knee.r3_125.png"
],
"ok": true
}

View file

@ -0,0 +1,183 @@
"""Live proof, in a background Blender, that the brokkr_reference row is admitted by Brokkr as a host action and
that solve_camera, through run_intent, finds the camera a known scene was rendered through: three boxes rendered
at a 50 mm camera cropped off-axis, their corners marked where Blender's own projection draws them (to a tenth of
a pixel), the camera solved and stood as a second camera object, and the scene rendered again through it. The two
silhouettes must agree. Not part of the unittest run: it needs Blender.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/reference.py -- <out>
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). <out> is an absolute path: it writes <out>.result.json, <out>.truth.png and <out>.solved.png, and
exits 1 when a check failed. The checks run inside one try: an uncaught error is a failed check that names the
check before it, and the result file is written whatever happened.
"""
import json
import os
import sys
import tempfile
import time
import traceback
import types
from pathlib import Path
import bmesh
import bpy
import numpy as np
from bpy_extras.object_utils import world_to_camera_view
from mathutils import Euler, Matrix, Vector
SURFACE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(SURFACE / "tools"))
import private_dirs # noqa: E402
_refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if _refused:
raise SystemExit(_refused)
OUT = sys.argv[sys.argv.index("--") + 1]
if not os.path.isabs(OUT):
raise SystemExit(f"<out> must be an absolute path, not {OUT!r}: a relative one lands in Blender's start directory")
package = types.ModuleType("brokkr_bridge")
package.__path__ = [str(SURFACE / "brokkr_bridge")]
sys.modules["brokkr_bridge"] = package
from brokkr_bridge import blender_target as bt # noqa: E402
import addon_utils # noqa: E402
sys.path.append(str(SURFACE))
bpy.ops.wm.read_factory_settings(use_empty=True)
for module in ("brokkr_mesh_polish", "brokkr_reference"):
addon_utils.enable(module, default_set=True)
from brokkr_reference import core # noqa: E402
target = bt.BrokkrBlenderTarget(bpy)
target.configure_action_dirs("", tempfile.mkdtemp(prefix="brokkr-reference-live-"))
target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1],
"hostRows": [row["name"] for row in target.host_actions()[0]]}
COUNT = [0]
T0 = time.time()
WIDTH, HEIGHT = 800, 600
def check(name, ok, detail=None):
R["checks"].append({"name": name, "ok": bool(ok), "detail": detail})
def send(action, **fields):
COUNT[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"live-{COUNT[0]}", "requestedBy": "test/driver", "action": action, **fields})
result = json.loads(receipt["hostResult"]) if receipt.get("hostResult") else None
print("SEND", f"{time.time() - T0:.1f}s", action, receipt["status"], str(receipt["message"])[:300], flush=True)
return receipt, result
def silhouette(camera, path):
"""Render through `camera` with a transparent film and return where the scene covers the frame."""
scene = bpy.context.scene
scene.camera = camera
scene.render.filepath = path
bpy.ops.render.render(write_still=True)
image = bpy.data.images.load(path)
alpha = np.array(image.pixels[:], dtype=np.float32).reshape(image.size[1], image.size[0], 4)[:, :, 3]
bpy.data.images.remove(image)
return alpha > 0.5
def drawn(camera, point):
"""The frame pixel (u, v down) Blender's own projection gives a world point."""
x, y, _ = world_to_camera_view(bpy.context.scene, camera, Vector(point))
return x * WIDTH, (1.0 - y) * HEIGHT
def params_of(camera):
data, render = camera.data, bpy.context.scene.render
return {"matrix_world": [list(row) for row in camera.matrix_world], "lens": data.lens, "shift_x": data.shift_x, "shift_y": data.shift_y,
"sensor_width": data.sensor_width, "sensor_fit": data.sensor_fit, "resolution": [render.resolution_x, render.resolution_y]}
try:
check("host file admitted", not R["hostErrors"] and "brokkr_reference.solve_camera" in R["hostRows"], R["hostRows"])
scene = bpy.context.scene
scene.render.engine = "BLENDER_WORKBENCH"
scene.render.film_transparent = True
scene.render.image_settings.file_format = "PNG"
scene.render.image_settings.color_mode = "RGBA"
scene.render.resolution_x, scene.render.resolution_y, scene.render.resolution_percentage = WIDTH, HEIGHT, 100
# --- the known scene: a hull, a tower off its middle and a wing, none mirrored, so no camera but one draws it --------
bm = bmesh.new()
for size, place in (((1.6, 4.0, 0.8), (0.0, 0.0, 0.4)), ((0.6, 0.8, 1.2), (0.3, -1.0, 1.4)), ((1.8, 1.0, 0.2), (1.7, 0.6, 0.5))):
bmesh.ops.create_cube(bm, size=1.0, matrix=Matrix.Translation(place) @ Matrix.Diagonal((*size, 1.0)))
mesh = bpy.data.meshes.new("Known")
bm.to_mesh(mesh)
bm.free()
scene.collection.objects.link(bpy.data.objects.new("Known", mesh))
truth = bpy.data.objects.new("Truth", bpy.data.cameras.new("Truth"))
scene.collection.objects.link(truth)
truth.data.lens, truth.data.sensor_width, truth.data.sensor_fit, truth.data.shift_x, truth.data.shift_y = 50.0, 36.0, "HORIZONTAL", 0.08, -0.05
truth.matrix_world = Matrix.Translation((-6.5, -8.0, 4.6)) @ Euler((1.2, 0.03, -0.72), "XYZ").to_matrix().to_4x4()
bpy.context.view_layer.update()
first = silhouette(truth, OUT + ".truth.png")
check("fixture: the scene covers part of the frame and touches no edge", 0.05 < first.mean() < 0.6 and not (first[0].any() or first[-1].any() or first[:, 0].any() or first[:, -1].any()), float(first.mean()))
corners = {f"v{v.index}": tuple(v.co) for v in mesh.vertices}
marks = {k: drawn(truth, p) for k, p in corners.items()}
world = "; ".join(f"{k}={p[0]:.4f},{p[1]:.4f},{p[2]:.4f}" for k, p in corners.items())
pixels = "; ".join(f"{k}={u:.1f},{v:.1f}" for k, (u, v) in marks.items())
box = f"0,0,{WIDTH},{HEIGHT}"
# --- camera_of reads the scene's own camera: the record draws what Blender draws ------------------------------------
record = core.camera_of(params_of(truth))
off = float(np.abs(core.project(record, list(corners.values())) - np.array(list(marks.values()))).max())
check("camera_of(the truth camera) draws each corner where Blender does, within 0.01 px", off < 0.01, off)
# --- compute only ----------------------------------------------------------------------------------------------------
before = sorted(o.name for o in bpy.data.objects)
receipt, only = send("brokkr_reference.solve_camera", world=world, pixels=pixels, box=box)
check("compute only: accepted, the record in the receipt, no object made", receipt["status"] == "accepted" and only and only["camera"] is None
and sorted(o.name for o in bpy.data.objects) == before and len(only["residuals"]) == 24, [receipt["message"], only and only["model"]])
check("auto takes the free model on a view cropped off-axis", only and only["model"] == "free", only and only["tried"])
# --- stood as a camera, and the scene rendered again through it ---------------------------------------------------
scene.render.resolution_x, scene.render.resolution_y = 320, 200 # the action sets the frame, not the caller
receipt, solved = send("brokkr_reference.solve_camera", world=world, pixels=pixels, box=box, model="free", camera_name="Solved", width=WIDTH)
stood = bpy.data.objects.get("Solved")
check("solve_camera with camera_name: accepted, a camera object, the render size set to the box", receipt["status"] == "accepted" and stood is not None
and stood.type == "CAMERA" and (scene.render.resolution_x, scene.render.resolution_y) == (WIDTH, HEIGHT), receipt["message"])
R["record"] = {k: solved[k] for k in ("lens", "lens_band", "lens_at_bound", "rms", "median", "left_out", "model", "c", "azimuth", "elevation", "distance", "roll")}
place = float((stood.matrix_world.translation - truth.matrix_world.translation).length)
check("the record: lens within 1 mm of 50, place within 0.1 m, rms under 0.2 px, lens not at a bound",
abs(solved["lens"] - 50.0) < 1.0 and place < 0.1 and solved["rms"] < 0.2 and solved["lens_at_bound"] is None, [solved["lens"], place, solved["rms"]])
check("the centre is solved: the truth's shifts within 0.005 of a frame width", abs(stood.data.shift_x - 0.08) < 0.005 and abs(stood.data.shift_y + 0.05) < 0.005,
[stood.data.shift_x, stood.data.shift_y])
worst = max(float(np.hypot(*np.subtract(drawn(stood, p), marks[k]))) for k, p in corners.items())
check("Blender's projection through the stood camera draws each corner within 0.5 px of its mark", worst < 0.5, worst)
second = silhouette(stood, OUT + ".solved.png")
miss = 1.0 - float((first & second).sum() / (first | second).sum())
R["iouMiss"] = miss
# 1 - IoU of the two silhouettes. Shipped 0.000168; with shift_y's sign flipped in core.blender (M5) 0.6489: the bound is their geometric mean.
check("the re-render's silhouette matches the first: 1 - IoU under 0.0105", miss < 0.0105, miss)
# --- again under the same name updates the one camera; a held lens is held ------------------------------------------
receipt, held = send("brokkr_reference.solve_camera", world=world, pixels=pixels, box=box, model="free", lens=85, camera_name="Solved", width=400)
check("a second run updates the same camera: one object, the lens held at 85, the frame 400 by 300", receipt["status"] == "accepted"
and [o.name for o in bpy.data.objects if o.type == "CAMERA"] == ["Solved", "Truth"] and abs(stood.data.lens - 85.0) < 1e-4
and held["lens_band"] == [85.0, 85.0] and (scene.render.resolution_x, scene.render.resolution_y) == (400, 300), [receipt["message"], held and held["lens"]])
# --- refusals are failed receipts that name the cause ----------------------------------------------------------------
five = "; ".join(pixels.split("; ")[:5])
receipt, _ = send("brokkr_reference.solve_camera", world=world, pixels=five, box=box)
check("five points: failed, naming the count", receipt["status"] == "failed" and "5 points" in receipt["message"], receipt["message"])
receipt, _ = send("brokkr_reference.solve_camera", world=world, pixels=pixels, box=box, camera_name="Known")
check("camera_name of a mesh object: failed, nothing changed", receipt["status"] == "failed" and "not a camera" in receipt["message"]
and bpy.data.objects["Known"].type == "MESH", receipt["message"])
receipt, _ = send("brokkr_reference.solve_camera", world=world, pixels=pixels, box="0,0,0,600")
check("a box of no width: failed, naming it", receipt["status"] == "failed" and "no width" in receipt["message"], receipt["message"])
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, printed and written, not a missing result file
check(f"no uncaught error after: {R['checks'][-1]['name'] if R['checks'] else 'the start'}", False, traceback.format_exc().splitlines()[-6:])
R["ok"] = all(c["ok"] for c in R["checks"])
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
sys.exit(0 if R["ok"] else 1)

View file

@ -0,0 +1,148 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "host file admitted",
"ok": true,
"detail": [
"brokkr_mesh_polish.audit",
"brokkr_mesh_polish.repair",
"brokkr_mesh_polish.orient",
"brokkr_mesh_polish.delight",
"brokkr_mesh_polish.scrub_markings",
"brokkr_mesh_polish.cut_parts",
"brokkr_mesh_polish.pick",
"brokkr_reference.solve_camera",
"brokkr_reference.flow_score"
]
},
{
"name": "fixture: the scene covers part of the frame and touches no edge",
"ok": true,
"detail": 0.1361375
},
{
"name": "camera_of(the truth camera) draws each corner where Blender does, within 0.01 px",
"ok": true,
"detail": 6.941722509168358e-05
},
{
"name": "compute only: accepted, the record in the receipt, no object made",
"ok": true,
"detail": [
"Operator brokkr_reference.solve_camera finished.",
"free"
]
},
{
"name": "auto takes the free model on a view cropped off-axis",
"ok": true,
"detail": {
"upright": {
"rms": 1.380259942769221,
"left_out": 1.5572430492976839,
"lens": 48.08928208959338
},
"rolled": {
"rms": 0.6797349192884168,
"left_out": 0.8350092431422779,
"lens": 48.499059377417225
},
"free": {
"rms": 0.03555833513434369,
"left_out": 0.04252972975472319,
"lens": 50.02266319807241
}
}
},
{
"name": "solve_camera with camera_name: accepted, a camera object, the render size set to the box",
"ok": true,
"detail": "Operator brokkr_reference.solve_camera finished."
},
{
"name": "the record: lens within 1 mm of 50, place within 0.1 m, rms under 0.2 px, lens not at a bound",
"ok": true,
"detail": [
50.02266319807241,
0.004567543465755453,
0.03555833513434369
]
},
{
"name": "the centre is solved: the truth's shifts within 0.005 of a frame width",
"ok": true,
"detail": [
0.079900361597538,
-0.051553647965192795
]
},
{
"name": "Blender's projection through the stood camera draws each corner within 0.5 px of its mark",
"ok": true,
"detail": 0.03400179965902824
},
{
"name": "the re-render's silhouette matches the first: 1 - IoU under 0.0105",
"ok": true,
"detail": 0.00016831152933971527
},
{
"name": "a second run updates the same camera: one object, the lens held at 85, the frame 400 by 300",
"ok": true,
"detail": [
"Operator brokkr_reference.solve_camera finished.",
85.0
]
},
{
"name": "five points: failed, naming the count",
"ok": true,
"detail": "Error: 5 points are named in both world and pixels; six are needed"
},
{
"name": "camera_name of a mesh object: failed, nothing changed",
"ok": true,
"detail": "Error: 'Known' is an object that is not a camera."
},
{
"name": "a box of no width: failed, naming it",
"ok": true,
"detail": "Error: box [0.0, 0.0, 0.0, 600.0] has no width: it is u0, v0, u1, v1 with u1 past u0 and v1 past v0"
}
],
"hostErrors": [],
"hostRows": [
"brokkr_mesh_polish.audit",
"brokkr_mesh_polish.repair",
"brokkr_mesh_polish.orient",
"brokkr_mesh_polish.delight",
"brokkr_mesh_polish.scrub_markings",
"brokkr_mesh_polish.cut_parts",
"brokkr_mesh_polish.pick",
"brokkr_reference.solve_camera",
"brokkr_reference.flow_score"
],
"record": {
"lens": 50.02266319807241,
"lens_band": [
45.26237741142627,
61.09781880064287
],
"lens_at_bound": null,
"rms": 0.03555833513434369,
"median": 0.036713200453055594,
"left_out": 0.04252972975472319,
"model": "free",
"c": [
336.07971210679585,
258.7570824524072
],
"azimuth": 137.66552423487752,
"elevation": 19.81349852084873,
"distance": 11.315569478894277,
"roll": -1.8445361216036547
},
"iouMiss": 0.00016831152933971527,
"ok": true
}

View file

@ -0,0 +1,245 @@
"""Live proof, in a background Blender, of brokkr_reference.block_plate through run_intent.
A plate stands in a frame turned and moved in the world: an empty, "Frame". Its truth is a five-sided crown with
bowed sides, built by brokkr_kitbash.shell from core.plate_sheet, and two cameras 60 degrees apart look at it. Each
side is traced in both views where Blender's own projection draws the side as core.crease_run builds it. Then:
block_plate from the frame, the corner names and the ten traces, no blocking: a sheet with every trace
explained, each corner decided by the views, nothing written to the scene
built brokkr_kitbash.shell takes the sheet without refusal, and at one level Blender builds each crown
side where core.crease_run says
fit_shell with the returned fit_traces on the built plate: accepted, every trace explained, and no point
moved over MOVED (fairness holds a bowed side in and fit_shell's own prior lets it out:
tests/test_reference.py test_the_blocking_goes_to_the_parser_and_to_fit_shell reads 74 mm of
it where a pixel is 27 mm; here a pixel is 5 mm). MOVED, GAP and GAP_MIRRORED each stand between
this scene's reading and a mutant's
mirrored a mirrored plate with two seam corners, traced the same way: the seam stays on x = 0,
brokkr_kitbash.shell builds both halves, and Blender builds the seam's side and a free side where
core.crease_run says
refusals a scaled frame, an unknown camera and a side nobody traced, each a failed receipt naming its cause
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/reference_block.py -- <out>
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). <out> is an absolute path: it writes <out>.result.json and exits 1 when a check failed. Not part
of the unittest run: it needs Blender.
"""
import json
import math
import os
import sys
import tempfile
import time
import traceback
import types
from pathlib import Path
import bpy
import numpy as np
from bpy_extras.object_utils import world_to_camera_view
from mathutils import Euler, Matrix, Vector
SURFACE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(SURFACE / "tools"))
import private_dirs # noqa: E402
_refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if _refused:
raise SystemExit(_refused)
OUT = sys.argv[sys.argv.index("--") + 1]
if not os.path.isabs(OUT):
raise SystemExit(f"<out> must be an absolute path, not {OUT!r}: a relative one lands in Blender's start directory")
package = types.ModuleType("brokkr_bridge")
package.__path__ = [str(SURFACE / "brokkr_bridge")]
sys.modules["brokkr_bridge"] = package
from brokkr_bridge import blender_target as bt # noqa: E402
import addon_utils # noqa: E402
sys.path.append(str(SURFACE))
bpy.ops.wm.read_factory_settings(use_empty=True)
for module in ("brokkr_mesh_polish", "brokkr_kitbash", "brokkr_reference"):
addon_utils.enable(module, default_set=True)
from brokkr_reference import core # noqa: E402
target = bt.BrokkrBlenderTarget(bpy)
target.configure_action_dirs("", tempfile.mkdtemp(prefix="brokkr-reference-block-live-"))
target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1],
"hostRows": [row["name"] for row in target.host_actions()[0]]}
COUNT = [0]
T0 = time.time()
WIDTH, HEIGHT = 1000, 800
MOVED, GAP, GAP_MIRRORED = 0.0165, 0.0088, 0.0273 # metres, each the geometric mean of this scene's reading and its least mutant's (lodur:ruling:deterministic-bound-margin), the mutants run through this script on a copy of the surface: fit_shell moves a point of the blocked plate 0.0048 (FAIR 0.05: 0.0565), the blocked crown stands 0.0027 from its truth (FAIR 0.05: 0.0288), the mirrored crown 0.0140 (FAIR 0.05: 0.0534; no end terms: 0.0646). Separations 3.4, 3.3 and 1.95 each side. A pixel is 5 mm here and the traces are exact, where weaker fairness reads nearer (FAIR 0.5: 0.0011, 0.0018, 0.0054): tests/test_reference.py test_fairness_is_set_by_the_rendered_roof says why 0.2 stands
def check(name, ok, detail=None):
R["checks"].append({"name": name, "ok": bool(ok), "detail": detail})
def send(action, **fields):
COUNT[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"live-{COUNT[0]}", "requestedBy": "test/driver", "action": action, **fields})
result = json.loads(receipt["hostResult"]) if receipt.get("hostResult") else None
print("SEND", f"{time.time() - T0:.1f}s", action, receipt["status"], str(receipt["message"])[:400], flush=True)
return receipt, result
def built(chain):
return core.crease_run(core.crease_run(np.asarray(chain, float)))
def pentagon():
"""Five sides as five-point cage chains: a plate 1.2 m across facing -y, its corners up to 0.15 m off the plane
y = 0, each side bowed 8% of its length toward -y and 35% outward in the plate."""
angles = [2 * math.pi * i / 5 + 0.3 for i in range(5)]
P = np.array([[0.6 * math.cos(t), 0.15 * math.cos(2 * t), 0.6 * math.sin(t)] for t in angles])
s, sides = np.linspace(0, 1, 5)[:, None], []
for a, b in zip(P, np.roll(P, -1, axis=0)):
sides.append(a + s * (b - a) + np.sin(math.pi * s) * np.linalg.norm(b - a) * (0.08 * np.array([0, -1.0, 0]) + 0.35 * (a + b) / np.linalg.norm(a + b)))
return sides
def half():
"""A mirrored plate's authored half as chains: the seam's side on x = 0, bowed in the plane, and three free sides."""
P = np.array([[0.0, 0.0, 0.5], [0.0, 0.0, -0.5], [0.5, 0.1, -0.4], [0.3, 0.1, 0.4]])
s, sides = np.linspace(0, 1, 5)[:, None], []
for i, (a, b) in enumerate(zip(P, np.roll(P, -1, axis=0))):
bow = np.array([0.0, -0.3, 0.0]) if i == 0 else np.array([0.25, -0.1, 0.0]) if i == 1 else np.zeros(3)
sides.append(a + s * (b - a) + np.sin(math.pi * s) * np.linalg.norm(b - a) * bow)
return sides
def pixels(camera, frame, points, side=1):
out = []
for p in np.asarray(points, float) * [side, 1, 1]:
x, y, _ = world_to_camera_view(bpy.context.scene, camera, frame.matrix_world @ Vector(p))
out.append([round(x * WIDTH, 3), round((1.0 - y) * HEIGHT, 3)])
return out
def chains_of(out):
n, first, chains = sum(side["points"] - 1 for side in out["sides"]), 0, []
for side in out["sides"]:
chains.append([(first + m) % n for m in range(side["points"])])
first += side["points"] - 1
return chains
def at_one_level(name, sheet, chains, mirror=False):
"""The furthest a crown side as core.crease_run builds it at one level stands from a vertex Blender built."""
send("brokkr_kitbash.shell", object_name=name, sheet=json.dumps(sheet), thickness=0.03, levels=1)
shell = bpy.data.objects[name]
wall = shell.modifiers["Kit Solidify"]
wall.show_viewport = False
mesh = np.array([v.co for v in shell.evaluated_get(bpy.context.evaluated_depsgraph_get()).to_mesh().vertices])
wall.show_viewport = True
verts = np.array(sheet["verts"])
return max(float(np.linalg.norm(mesh - p * [side, 1, 1], axis=1).min()) for chain in chains for side in ((1, -1) if mirror else (1,)) for p in core.crease_run(verts[chain]))
def snapshot():
return sorted((o.name, o.type, tuple(round(c, 6) for row in o.matrix_world for c in row), o.get("kit_shell")) for o in bpy.data.objects)
try:
check("host files admitted with the block_plate row", not R["hostErrors"] and "brokkr_reference.block_plate" in R["hostRows"], R["hostErrors"] or R["hostRows"][-4:])
scene = bpy.context.scene
scene.render.resolution_x, scene.render.resolution_y, scene.render.resolution_percentage = WIDTH, HEIGHT, 100
frame = bpy.data.objects.new("Frame", None)
scene.collection.objects.link(frame)
frame.matrix_world = Matrix.Translation((0.3, -0.2, 1.0)) @ Euler((0.0, 0.0, math.radians(15.0))).to_matrix().to_4x4()
cameras = []
for name, azimuth in (("A", 15.0), ("B", 75.0)):
camera = bpy.data.objects.new(name, bpy.data.cameras.new(name))
scene.collection.objects.link(camera)
camera.data.lens, camera.data.sensor_fit = 50.0, "HORIZONTAL"
a = math.radians(azimuth)
camera.location = Vector((0.3, -0.2, 1.0)) + 7.0 * Vector((math.sin(a), -math.cos(a), 0.15))
camera.rotation_euler = (Vector((0.3, -0.2, 1.0)) - camera.location).to_track_quat("-Z", "Y").to_euler()
cameras.append(camera)
bpy.context.view_layer.update()
# --- the truth, built by brokkr_kitbash.shell, and its sides traced in both views -------------------------------
names = [f"c{i}" for i in range(5)]
sides = pentagon()
crown = np.concatenate([side[:-1] for side in sides])
truth = core.plate_sheet(crown, [0, 4, 8, 12, 16], facing=[0.0, -1.0, 0.0])
made, _ = send("brokkr_kitbash.shell", object_name="Truth", sheet=json.dumps(truth), thickness=0.03, levels=2)
bpy.data.objects["Truth"].matrix_world = frame.matrix_world
bpy.context.view_layer.update()
traces = [{"camera": camera.name, "from": names[i], "to": names[(i + 1) % 5], "side": 1, "line": pixels(camera, frame, core.resampled(built(side), 24))} for i, side in enumerate(sides) for camera in cameras]
inside = all(0 <= u <= WIDTH and 0 <= v <= HEIGHT for trace in traces for u, v in trace["line"])
check("brokkr_kitbash.shell builds the truth from core.plate_sheet, and both cameras frame every side", made["status"] == "accepted" and inside, made["message"])
# --- block_plate ------------------------------------------------------------------------------------------------------
before = snapshot()
receipt, out = send("brokkr_reference.block_plate", frame_object="Frame", plate=json.dumps({"corners": names}), traces=json.dumps(traces, separators=(",", ":")))
ok = receipt["status"] == "accepted" and out is not None
check(f"block_plate returns a sheet with every trace explained within {core.TOL:g} px and each corner decided by the views",
ok and max(row["unexplained_px"] for side in out["sides"] for row in side["traces"]) <= core.TOL and {corner["decided_by"] for corner in out["corners"]} == {"views"}
and len(receipt["hostResult"]) < 16000,
out and {"sides": [side["points"] for side in out["sides"]], "corners": [[corner["parallax_deg"], corner["m_per_px"], corner["prior_share"]] for corner in out["corners"]],
"rounds": out["rounds"], "seconds": out["seconds"], "chars": len(receipt["hostResult"])} or receipt["message"])
check("block_plate wrote nothing: every object is as it was", snapshot() == before)
if ok:
chains = chains_of(out)
verts = np.array(out["sheet"]["verts"])
gap = max(float(core._off(built(verts[chain]), core.resampled(built(side), 400)).max()) for chain, side in zip(chains, sides))
check(f"the blocked crown as built stands within {GAP:g} m of the truth's", gap < GAP, gap)
worst = at_one_level("Blocked", out["sheet"], chains)
check("brokkr_kitbash.shell takes the blocked sheet, and at one level Blender builds every crown side where core.crease_run says, within 1e-4 m",
"Blocked" in bpy.data.objects and worst < 1e-4, worst)
applied, _ = send("brokkr_kitbash.shell", object_name="Blocked", sheet=json.dumps(out["sheet"]), thickness=0.03, levels=2)
bpy.data.objects["Blocked"].matrix_world = frame.matrix_world
bpy.context.view_layer.update()
receipt, fit = send("brokkr_reference.fit_shell", object_name="Blocked", traces=json.dumps(out["fit_traces"], separators=(",", ":")))
moved = fit and max(point["moved_m"] for point in fit["points"])
check(f"fit_shell takes the returned fit_traces on the built plate: accepted, every trace explained, no point moved over {MOVED:g} m",
applied["status"] == "accepted" and receipt["status"] == "accepted" and len(out["fit_traces"]) == 10 and out["left_out"] == [] and moved < MOVED
and max(row["unexplained_px"] for row in fit["traces"]) <= core.TOL, {"moved_m": moved} if fit else receipt["message"])
# --- a mirrored plate ---------------------------------------------------------------------------------------------------
names = ["top", "bottom", "low", "high"]
sides = half()
traces = [{"camera": camera.name, "from": names[i], "to": names[(i + 1) % 4], "side": side_, "line": pixels(camera, frame, core.resampled(built(side), 24), side_)}
for i, side in enumerate(sides) for camera, side_ in ((cameras[0], 1), (cameras[1], 1), (cameras[0], -1))]
traces = [trace for trace in traces if not (trace["from"] == "top" and trace["side"] == -1)] # the seam's side is its own reflection
receipt, out = send("brokkr_reference.block_plate", frame_object="Frame", plate=json.dumps({"corners": names, "mirror": True, "seam": ["top", "bottom"]}),
traces=json.dumps(traces, separators=(",", ":")))
ok = receipt["status"] == "accepted" and out is not None
if ok:
chains = chains_of(out)
verts = np.array(out["sheet"]["verts"])
gap = max(float(core._off(built(verts[chain]), core.resampled(built(side), 400)).max()) for chain, side in zip(chains, sides))
check(f"a mirrored plate: the seam's corners are decided by the mirror plane, its side stays on x = 0, and the crown as built stands within {GAP_MIRRORED:g} m of the truth's",
[corner["decided_by"] for corner in out["corners"]][:2] == ["mirror", "mirror"] and float(np.abs(verts[chains[0], 0]).max()) == 0.0 and gap < GAP_MIRRORED,
{"gap": gap, "sides": [side["points"] for side in out["sides"]], "corners": [corner["decided_by"] for corner in out["corners"]], "poles": out["sheet"]["poles"]})
worst = at_one_level("Mirrored", out["sheet"], chains, mirror=True)
check("brokkr_kitbash.shell builds both halves of the mirrored sheet, and at one level Blender builds the seam's side and the free sides, on both halves, where core.crease_run says, within 1e-4 m",
"Mirrored" in bpy.data.objects and worst < 1e-4, worst)
else:
check("block_plate blocks a mirrored plate", False, receipt["message"])
# --- refusals ---------------------------------------------------------------------------------------------------------
before = snapshot()
plate, text = json.dumps({"corners": names, "mirror": True, "seam": ["top", "bottom"]}), json.dumps(traces, separators=(",", ":"))
receipt, _ = send("brokkr_reference.block_plate", frame_object="Frame", plate=plate, traces=json.dumps([dict(traces[0], camera="Nobody")] + traces[1:], separators=(",", ":")))
check("an unknown camera is refused naming the trace", receipt["status"] == "failed" and "traces[0]" in receipt["message"] and "Nobody" in receipt["message"], receipt["message"])
receipt, _ = send("brokkr_reference.block_plate", frame_object="Frame", plate=plate, traces=json.dumps([trace for trace in traces if trace["from"] != "low"], separators=(",", ":")))
check("a side nobody traced is refused by its corners' names", receipt["status"] == "failed" and "the side from 'low' to 'high' is traced in no view" in receipt["message"], receipt["message"])
receipt, _ = send("brokkr_reference.block_plate", frame_object="Frame", plate=plate, traces=text, plane="0,0,0; 0,0")
check("a plane that is not a point and a normal is refused", receipt["status"] == "failed" and "plane" in receipt["message"], receipt["message"])
check("no refusal changed the scene", snapshot() == before)
frame.scale = (2.0, 2.0, 2.0)
bpy.context.view_layer.update()
receipt, _ = send("brokkr_reference.block_plate", frame_object="Frame", plate=plate, traces=text)
check("a scaled frame is refused", receipt["status"] == "failed" and "scaled" in receipt["message"], receipt["message"])
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, printed and written, not a missing result file
check(f"no uncaught error after: {R['checks'][-1]['name'] if R['checks'] else 'the start'}", False, traceback.format_exc().splitlines()[-6:])
R["ok"] = all(c["ok"] for c in R["checks"])
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
sys.exit(0 if R["ok"] else 1)

View file

@ -0,0 +1,175 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "host files admitted with the block_plate row",
"ok": true,
"detail": [
"brokkr_reference.solve_camera",
"brokkr_reference.flow_score",
"brokkr_reference.fit_shell",
"brokkr_reference.block_plate"
]
},
{
"name": "brokkr_kitbash.shell builds the truth from core.plate_sheet, and both cameras frame every side",
"ok": true,
"detail": "Operator brokkr_kitbash.shell finished."
},
{
"name": "block_plate returns a sheet with every trace explained within 5.2 px and each corner decided by the views",
"ok": true,
"detail": {
"sides": [
3,
3,
3,
3,
3
],
"corners": [
[
60.6,
0.0031,
0.019
],
[
61.0,
0.0042,
0.026
],
[
56.4,
0.0035,
0.022
],
[
57.3,
0.0036,
0.022
],
[
60.1,
0.0037,
0.023
]
],
"rounds": 2,
"seconds": 0.137,
"chars": 7703
}
},
{
"name": "block_plate wrote nothing: every object is as it was",
"ok": true,
"detail": null
},
{
"name": "the blocked crown as built stands within 0.0088 m of the truth's",
"ok": true,
"detail": 0.002711610846938251
},
{
"name": "brokkr_kitbash.shell takes the blocked sheet, and at one level Blender builds every crown side where core.crease_run says, within 1e-4 m",
"ok": true,
"detail": 1.1421151381392388e-07
},
{
"name": "fit_shell takes the returned fit_traces on the built plate: accepted, every trace explained, no point moved over 0.0165 m",
"ok": true,
"detail": {
"moved_m": 0.0048
}
},
{
"name": "a mirrored plate: the seam's corners are decided by the mirror plane, its side stays on x = 0, and the crown as built stands within 0.0273 m of the truth's",
"ok": true,
"detail": {
"gap": 0.013972102623404082,
"sides": [
3,
3,
2,
2
],
"corners": [
"mirror",
"mirror",
"views",
"views"
],
"poles": [
0,
2,
11
]
}
},
{
"name": "brokkr_kitbash.shell builds both halves of the mirrored sheet, and at one level Blender builds the seam's side and the free sides, on both halves, where core.crease_run says, within 1e-4 m",
"ok": true,
"detail": 8.42242114374928e-08
},
{
"name": "an unknown camera is refused naming the trace",
"ok": true,
"detail": "Error: traces[0]: 'Nobody' is not a camera object."
},
{
"name": "a side nobody traced is refused by its corners' names",
"ok": true,
"detail": "Error: the side from 'low' to 'high' is traced in no view: every side of the outline is traced, or the plate is given fewer corners. Nothing changed."
},
{
"name": "a plane that is not a point and a normal is refused",
"ok": true,
"detail": "Error: plane's normal '0,0' is not 3 finite numbers with commas between."
},
{
"name": "no refusal changed the scene",
"ok": true,
"detail": null
},
{
"name": "a scaled frame is refused",
"ok": true,
"detail": "Error: frame_object 'Frame' is scaled (2.0, 2.0, 2.0): a plate is in metres of its frame. Apply or clear the scale."
}
],
"hostErrors": [],
"hostRows": [
"brokkr_mesh_polish.audit",
"brokkr_mesh_polish.repair",
"brokkr_mesh_polish.orient",
"brokkr_mesh_polish.delight",
"brokkr_mesh_polish.scrub_markings",
"brokkr_mesh_polish.cut_parts",
"brokkr_mesh_polish.pick",
"brokkr_kitbash.place_part",
"brokkr_kitbash.set_params",
"brokkr_kitbash.describe",
"brokkr_kitbash.report",
"brokkr_kitbash.attach",
"brokkr_kitbash.detach",
"brokkr_kitbash.roll",
"brokkr_kitbash.aim",
"brokkr_kitbash.reach",
"brokkr_kitbash.joint",
"brokkr_kitbash.slide",
"brokkr_kitbash.joints",
"brokkr_kitbash.close",
"brokkr_kitbash.boolean",
"brokkr_kitbash.cut",
"brokkr_kitbash.cut_many",
"brokkr_kitbash.freeze",
"brokkr_kitbash.thaw",
"brokkr_kitbash.ribs",
"brokkr_kitbash.shell",
"brokkr_kitbash.hose",
"brokkr_reference.solve_camera",
"brokkr_reference.flow_score",
"brokkr_reference.fit_shell",
"brokkr_reference.block_plate"
],
"ok": true
}

View file

@ -0,0 +1,272 @@
"""Live proof, in a background Blender, of brokkr_reference.fit_shell through run_intent.
A mirrored loft shell made by brokkr_kitbash.shell stands turned and moved in the world: a hard crease column and
the rim's outer column on each half. A camera looks at it from the side, and the four runs are traced where
Blender's own projection draws them on the shell as designed. Then:
blocked the shell is rebuilt from a sheet whose two traced columns stand up to 0.12 m off: flow_score reads
the four traced lines against the build, and little of them is on a built edge
fit_shell from that shell and the traces: every trace explained, the request and the mesh untouched
applied brokkr_kitbash.shell rebuilds the shell from the returned sheet; flow_score reads every traced line
on a built edge (the bound sits between the mean of this reading and of the blocked build's, as CHECK prints)
crease_run the fitted shell at one level: the rim run and the crease stand where core.crease_run says
refusals a trace doubled back over itself, an unknown camera, a scaled shell and a mesh that is no shell,
each a failed receipt naming its cause, the shell unchanged
free cage a mirrored free cage with one hard crease, blocked off its design and traced on both halves: fit_shell
takes the run as {verts}, brokkr_kitbash.shell rebuilds it, and Blender builds the crease on both
halves where core.crease_run says
The Jacobian by differences (mutant F6: core.lm on the same residual) costs time only: the mirrored column of
tests/test_reference.py, views one at a time, medians of 3 interleaved runs on Starfire, read
SECONDS_ANALYTIC against SECONDS_DIFFERENCES below.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/reference_fit.py -- <out>
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). <out> is an absolute path: it writes <out>.result.json and exits 1 when a check failed. Not part
of the unittest run: it needs Blender.
"""
import json
import math
import os
import sys
import tempfile
import time
import traceback
import types
from pathlib import Path
import bpy
import numpy as np
from bpy_extras.object_utils import world_to_camera_view
from mathutils import Euler, Matrix, Vector
SECONDS_ANALYTIC, SECONDS_DIFFERENCES = (0.07, 0.21), (2.3, 3.9) # least and most of the three views, 2026-12-03; the fitted cages agree within 0.11 mm
SURFACE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(SURFACE / "tools"))
import private_dirs # noqa: E402
_refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if _refused:
raise SystemExit(_refused)
OUT = sys.argv[sys.argv.index("--") + 1]
if not os.path.isabs(OUT):
raise SystemExit(f"<out> must be an absolute path, not {OUT!r}: a relative one lands in Blender's start directory")
package = types.ModuleType("brokkr_bridge")
package.__path__ = [str(SURFACE / "brokkr_bridge")]
sys.modules["brokkr_bridge"] = package
from brokkr_bridge import blender_target as bt # noqa: E402
import addon_utils # noqa: E402
sys.path.append(str(SURFACE))
bpy.ops.wm.read_factory_settings(use_empty=True)
for module in ("brokkr_mesh_polish", "brokkr_kitbash", "brokkr_reference"):
addon_utils.enable(module, default_set=True)
from brokkr_reference import core # noqa: E402
target = bt.BrokkrBlenderTarget(bpy)
target.configure_action_dirs("", tempfile.mkdtemp(prefix="brokkr-reference-fit-live-"))
target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1],
"hostRows": [row["name"] for row in target.host_actions()[0]]}
COUNT = [0]
T0 = time.time()
WIDTH, HEIGHT = 800, 600
RINGS, CREASE, RIM = 6, 1, 3 # the sheet's rings, and its two traced columns
def check(name, ok, detail=None):
R["checks"].append({"name": name, "ok": bool(ok), "detail": detail})
def send(action, **fields):
COUNT[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"live-{COUNT[0]}", "requestedBy": "test/driver", "action": action, **fields})
result = json.loads(receipt["hostResult"]) if receipt.get("hostResult") else None
print("SEND", f"{time.time() - T0:.1f}s", action, receipt["status"], str(receipt["message"])[:400], flush=True)
return receipt, result
def designed():
"""The sheet as designed: six rings from y -1 to 1, each from the middle out and down, a fold at column 1."""
rings = []
for i in range(RINGS):
t = i / (RINGS - 1)
y, lift = -1.0 + 2.0 * t, 0.12 * math.sin(math.pi * t)
rings.append([[0.0, y, 0.55 + lift], [0.42 + 0.08 * math.sin(2.5 * t), y, 0.5 + lift], [0.8 + 0.05 * t, y, 0.12 + lift], [1.05 + 0.12 * math.sin(3.0 * t), y, -0.3 + 0.1 * t]])
return {"mirror": True, "rim": 1.0, "creases": [{"column": CREASE, "from": 0, "to": RINGS - 1, "weight": 1.0}], "rings": rings}
def blocking(sheet):
"""The designed sheet with its two traced columns pushed off by smooth bumps, up to 0.12 m."""
out, r, t = json.loads(json.dumps(sheet)), np.random.default_rng(5), np.linspace(0, 1, RINGS)
for column in (CREASE, RIM):
bump = sum(r.normal(0, 1, 3)[None] * np.sin(np.pi * (j + 1) * t + 0.4)[:, None] for j in range(2))
bump *= 0.12 / np.abs(bump).max()
for i in range(RINGS):
out["rings"][i][column] = [round(float(v + d), 6) for v, d in zip(sheet["rings"][i][column], bump[i])]
return out
def free_cage(points=6):
"""A mirrored free cage three columns wide (x 0 on the mirror plane, 0.5, 1) whose middle column is a hard crease,
and that column's vertices in order."""
verts = [[x, -1 + 2 * i / (points - 1), 0.5 - x * x + 0.1 * math.sin(3 * i / (points - 1)) * (c == 1)] for c, x in enumerate((0.0, 0.5, 1.0)) for i in range(points)]
faces = [[c * points + i, c * points + i + 1, c * points + i + 1 + points, c * points + i + points] for c in range(2) for i in range(points - 1)]
chain = list(range(points, 2 * points))
return {"verts": verts, "faces": faces, "creases": [[a, b, 1.0] for a, b in zip(chain, chain[1:])], "mirror": True, "rim": 1.0}, chain
def run_of(sheet, column, side):
"""A column's built run in the shell's frame, as core.crease_run builds it twice over."""
return core.crease_run(core.crease_run(np.array(sheet["rings"])[:, column] * [side, 1, 1]))
def pixels(camera, shell, points):
out = []
for p in points:
x, y, _ = world_to_camera_view(bpy.context.scene, camera, shell.matrix_world @ Vector(p))
out.append([round(x * WIDTH, 3), round((1.0 - y) * HEIGHT, 3)])
return out
def flow(lines, shell):
_, result = send("brokkr_reference.flow_score", camera_name="View", objects=shell.name,
lines="; ".join(f"{tag}: " + " ".join(f"{u},{v}" for u, v in line) for tag, line in lines.items()))
return {tag: row["on"] for tag, row in result["lines"].items()} if result else None
def state(shell):
return shell["kit_shell"], [tuple(round(c, 7) for c in v.co) for v in shell.data.vertices]
try:
check("host files admitted with the fit_shell row", not R["hostErrors"] and "brokkr_reference.fit_shell" in R["hostRows"], R["hostErrors"] or R["hostRows"])
scene = bpy.context.scene
scene.render.resolution_x, scene.render.resolution_y, scene.render.resolution_percentage = WIDTH, HEIGHT, 100
truth = designed()
send("brokkr_kitbash.shell", object_name="Plate", sheet=json.dumps(truth), thickness=0.03, levels=2)
shell = bpy.data.objects["Plate"]
shell.matrix_world = Matrix.Translation((0.3, -0.2, 0.1)) @ Euler((0.0, 0.0, math.radians(15.0))).to_matrix().to_4x4()
camera = bpy.data.objects.new("View", bpy.data.cameras.new("View"))
scene.collection.objects.link(camera)
camera.data.lens, camera.data.sensor_fit = 50.0, "HORIZONTAL"
camera.location = (3.2, -3.0, 5.2)
camera.rotation_euler = (Vector((0.3, -0.1, 0.25)) - camera.location).to_track_quat("-Z", "Y").to_euler()
bpy.context.view_layer.update()
runs = {"crease": (CREASE, 1), "crease_m": (CREASE, -1), "rim": (RIM, 1), "rim_m": (RIM, -1)}
lines = {tag: pixels(camera, shell, core.resampled(run_of(truth, column, side), 40)) for tag, (column, side) in runs.items()}
inside = all(0 <= u <= WIDTH and 0 <= v <= HEIGHT for line in lines.values() for u, v in line)
designed_on = flow(lines, shell)
check("the designed shell: the camera frames all four runs, and flow_score reads each traced line on a built edge", inside and designed_on and min(designed_on.values()) >= 0.9, designed_on)
# --- blocked: the shell rebuilt from a sheet whose traced columns stand off ---------------------------------------
blocked = blocking(truth)
send("brokkr_kitbash.shell", object_name="Plate", sheet=json.dumps(blocked), thickness=0.03, levels=2)
bpy.context.view_layer.update()
blocked_on = flow(lines, shell)
before = state(shell)
# --- fit_shell -----------------------------------------------------------------------------------------------------
traces = [{"camera": "View", "run": {"column": column, "from": 0, "to": RINGS - 1}, "side": side, "line": lines[tag]} for tag, (column, side) in runs.items()]
receipt, fit = send("brokkr_reference.fit_shell", object_name="Plate", traces=json.dumps(traces, separators=(",", ":")))
ok = receipt["status"] == "accepted" and fit is not None
check(f"fit_shell returns a sheet with every trace explained within {core.TOL:g} px, and a row for each of the 12 moved points",
ok and max(row["unexplained_px"] for row in fit["traces"]) <= core.TOL and len(fit["points"]) == 2 * RINGS and len(receipt["hostResult"]) < 16000,
fit and {"traces": fit["traces"], "seconds": fit["seconds"], "chars": len(receipt["hostResult"])})
check("fit_shell wrote nothing: the shell's request and its cage are as they were", state(shell) == before)
if ok:
gap, off = (max(float(core._off(core.resampled(run_of(sheet, column, 1), 200), run_of(truth, column, 1)).max()) for column in (CREASE, RIM)) for sheet in (fit["sheet"], blocked))
check("the fitted runs stand within 5 mm of the designed ones, from a blocking over 0.05 m off them", gap < 0.005 and off > 0.05, [gap, off])
shares = {(row["ring"], row["point"]): row["prior_share"] for row in fit["points"]}
check("every moved point reports metres per pixel and a prior share from 0 to 1", all(0.0 <= row["prior_share"] <= 1.0 and row["m_per_px"] >= 0.0 for row in fit["points"]), shares and max(shares.values()))
# --- applied: brokkr_kitbash.shell is the writer ---------------------------------------------------------------
applied, _ = send("brokkr_kitbash.shell", object_name="Plate", sheet=json.dumps(fit["sheet"]), thickness=0.03, levels=2)
bpy.context.view_layer.update()
fitted_on = flow(lines, shell)
low, high = sum(blocked_on.values()) / 4, sum(fitted_on.values()) / 4
bound = math.sqrt(low * high)
check(f"applied with brokkr_kitbash.shell, flow_score reads the four traced lines on a built edge over {bound:.3f} in the mean: the geometric mean of the fitted build's "
f"reading ({high:.3f}) and the blocked build's ({low:.3f}), separation {high / bound:.2f} each side; no fitted line reads under 0.9",
applied["status"] == "accepted" and high / bound >= 1.2 and min(fitted_on.values()) >= 0.9, {"blocked": blocked_on, "fitted": fitted_on})
# --- crease_run is what Blender builds of both runs ----------------------------------------------------------------
send("brokkr_kitbash.shell", object_name="Plate", sheet=json.dumps(fit["sheet"]), thickness=0.03, levels=1)
wall = shell.modifiers["Kit Solidify"]
wall.show_viewport = False
mesh = shell.evaluated_get(bpy.context.evaluated_depsgraph_get()).to_mesh()
built = np.array([v.co for v in mesh.vertices])
wall.show_viewport = True
worst = {tag: max(float(np.linalg.norm(built - p, axis=1).min()) for p in core.crease_run(np.array(fit["sheet"]["rings"])[:, column] * [side, 1, 1])) for tag, (column, side) in runs.items()}
check("at one level Blender builds the rim run and the crease, on both halves, where core.crease_run says, within 1e-4 m", max(worst.values()) < 1e-4, worst)
send("brokkr_kitbash.shell", object_name="Plate", sheet=json.dumps(blocked), thickness=0.03, levels=2)
# --- refusals ----------------------------------------------------------------------------------------------------------
before = state(shell)
line = np.array(lines["crease_m"])
doubled = np.vstack([line[:25], line[24:9:-1] + [0.0, 14.0], line[10:25] + [0.0, 28.0], line[25:]]).round(3).tolist()
receipt, _ = send("brokkr_reference.fit_shell", object_name="Plate", traces=json.dumps([traces[0], dict(traces[1], line=doubled)], separators=(",", ":")))
check("a trace doubled back over itself is refused, naming the trace and the span no built run draws", receipt["status"] == "failed" and "traces[1] is not explained" in receipt["message"] and "px along it" in receipt["message"], receipt["message"])
receipt, _ = send("brokkr_reference.fit_shell", object_name="Plate", traces=json.dumps([dict(traces[0], camera="Nobody")]))
check("an unknown camera is refused naming the trace", receipt["status"] == "failed" and "traces[0]" in receipt["message"] and "Nobody" in receipt["message"], receipt["message"])
receipt, _ = send("brokkr_reference.fit_shell", object_name="View", traces=json.dumps(traces[:1]))
check("an object that is no shell is refused", receipt["status"] == "failed" and "is not a shell" in receipt["message"], receipt["message"])
shell.scale = (2.0, 2.0, 2.0)
bpy.context.view_layer.update()
receipt, _ = send("brokkr_reference.fit_shell", object_name="Plate", traces=json.dumps(traces[:1]))
shell.scale = (1.0, 1.0, 1.0)
bpy.context.view_layer.update()
check("a scaled shell is refused", receipt["status"] == "failed" and "is scaled" in receipt["message"], receipt["message"])
check("no refusal changed the shell", state(shell) == before)
# --- a free cage, by its vertex chains ---------------------------------------------------------------------------------
design, chain = free_cage()
def crease(sheet, side, levels=core.LEVELS):
run = np.array(sheet["verts"])[chain] * [side, 1, 1]
for _ in range(levels):
run = core.crease_run(run)
return run
send("brokkr_kitbash.shell", object_name="Free", sheet=json.dumps(design), thickness=0.03, levels=2)
free = bpy.data.objects["Free"]
free.matrix_world = shell.matrix_world.copy()
bpy.context.view_layer.update()
free_lines = {side: pixels(camera, free, core.resampled(crease(design, side), 120)) for side in (1, -1)}
rough, bump = json.loads(json.dumps(design)), np.random.default_rng(1).normal(0, 0.06, (len(chain), 3))
for v, d in zip(chain, bump):
rough["verts"][v] = [round(float(x + y), 6) for x, y in zip(design["verts"][v], d)]
send("brokkr_kitbash.shell", object_name="Free", sheet=json.dumps(rough), thickness=0.03, levels=2)
bpy.context.view_layer.update()
before = state(free)
receipt, fit = send("brokkr_reference.fit_shell", object_name="Free",
traces=json.dumps([{"camera": "View", "run": {"verts": chain}, "side": side, "line": free_lines[side]} for side in (1, -1)], separators=(",", ":")))
ok = receipt["status"] == "accepted" and fit is not None
if ok:
gap, off = (float(core._off(core.resampled(crease(sheet, 1), 200), crease(design, 1)).max()) for sheet in (fit["sheet"], rough))
check("a mirrored free cage's crease, traced on both halves and named {verts}, is fitted within 1 mm of the designed run from a blocking over 0.05 m off: "
"a row for each of its six vertices and no other, every trace explained, nothing written",
gap < 0.001 and off > 0.05 and [row["vertex"] for row in fit["points"]] == chain and max(row["unexplained_px"] for row in fit["traces"]) <= core.TOL
and all(0 <= u <= WIDTH and 0 <= v <= HEIGHT for line in free_lines.values() for u, v in line) and state(free) == before,
{"gap": gap, "off": off, "traces": fit["traces"], "prior_share": max(row["prior_share"] for row in fit["points"]), "seconds": fit["seconds"]})
applied, _ = send("brokkr_kitbash.shell", object_name="Free", sheet=json.dumps(fit["sheet"]), thickness=0.03, levels=1)
wall = free.modifiers["Kit Solidify"]
wall.show_viewport = False
built = np.array([v.co for v in free.evaluated_get(bpy.context.evaluated_depsgraph_get()).to_mesh().vertices])
wall.show_viewport = True
worst = {side: max(float(np.linalg.norm(built - p, axis=1).min()) for p in crease(fit["sheet"], side, 1)) for side in (1, -1)}
check("brokkr_kitbash.shell takes the fitted free cage, and at one level Blender builds its crease on both halves where core.crease_run says, within 1e-4 m",
applied["status"] == "accepted" and max(worst.values()) < 1e-4, worst)
else:
check("fit_shell fits a mirrored free cage by its vertex chains", False, receipt["message"])
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, printed and written, not a missing result file
check(f"no uncaught error after: {R['checks'][-1]['name'] if R['checks'] else 'the start'}", False, traceback.format_exc().splitlines()[-6:])
R["ok"] = all(c["ok"] for c in R["checks"])
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
sys.exit(0 if R["ok"] else 1)

View file

@ -0,0 +1,212 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "host files admitted with the fit_shell row",
"ok": true,
"detail": [
"brokkr_mesh_polish.audit",
"brokkr_mesh_polish.repair",
"brokkr_mesh_polish.orient",
"brokkr_mesh_polish.delight",
"brokkr_mesh_polish.scrub_markings",
"brokkr_mesh_polish.cut_parts",
"brokkr_mesh_polish.pick",
"brokkr_kitbash.place_part",
"brokkr_kitbash.set_params",
"brokkr_kitbash.describe",
"brokkr_kitbash.report",
"brokkr_kitbash.attach",
"brokkr_kitbash.detach",
"brokkr_kitbash.roll",
"brokkr_kitbash.aim",
"brokkr_kitbash.reach",
"brokkr_kitbash.joint",
"brokkr_kitbash.slide",
"brokkr_kitbash.joints",
"brokkr_kitbash.close",
"brokkr_kitbash.boolean",
"brokkr_kitbash.cut",
"brokkr_kitbash.cut_many",
"brokkr_kitbash.freeze",
"brokkr_kitbash.thaw",
"brokkr_kitbash.ribs",
"brokkr_kitbash.shell",
"brokkr_kitbash.hose",
"brokkr_reference.solve_camera",
"brokkr_reference.flow_score",
"brokkr_reference.fit_shell"
]
},
{
"name": "the designed shell: the camera frames all four runs, and flow_score reads each traced line on a built edge",
"ok": true,
"detail": {
"crease": 1.0,
"crease_m": 1.0,
"rim": 1.0,
"rim_m": 0.963
}
},
{
"name": "fit_shell returns a sheet with every trace explained within 5.2 px, and a row for each of the 12 moved points",
"ok": true,
"detail": {
"traces": [
{
"unexplained_px": 0.01,
"worst_px": 0.021
},
{
"unexplained_px": 0.054,
"worst_px": 0.082
},
{
"unexplained_px": 0.052,
"worst_px": 0.071
},
{
"unexplained_px": 0.036,
"worst_px": 0.055
}
],
"seconds": 0.176,
"chars": 2066
}
},
{
"name": "fit_shell wrote nothing: the shell's request and its cage are as they were",
"ok": true,
"detail": null
},
{
"name": "the fitted runs stand within 5 mm of the designed ones, from a blocking over 0.05 m off them",
"ok": true,
"detail": [
0.0006199003550468113,
0.132354157889395
]
},
{
"name": "every moved point reports metres per pixel and a prior share from 0 to 1",
"ok": true,
"detail": 0.069
},
{
"name": "applied with brokkr_kitbash.shell, flow_score reads the four traced lines on a built edge over 0.747 in the mean: the geometric mean of the fitted build's reading (0.991) and the blocked build's (0.563), separation 1.33 each side; no fitted line reads under 0.9",
"ok": true,
"detail": {
"blocked": {
"crease": 0.713,
"crease_m": 0.613,
"rim": 0.138,
"rim_m": 0.787
},
"fitted": {
"crease": 1.0,
"crease_m": 1.0,
"rim": 1.0,
"rim_m": 0.963
}
}
},
{
"name": "at one level Blender builds the rim run and the crease, on both halves, where core.crease_run says, within 1e-4 m",
"ok": true,
"detail": {
"crease": 1.341720156294607e-07,
"crease_m": 1.341720156294607e-07,
"rim": 1.6729111618262465e-07,
"rim_m": 1.6729111618262465e-07
}
},
{
"name": "a trace doubled back over itself is refused, naming the trace and the span no built run draws",
"ok": true,
"detail": "Error: traces[1] is not explained: 235 px of the trace, between 126 and 461 px along it, lie more than 5.2 px from the run as built (11.6 px at the 90th of a hundred; up to 15.7 px). Nothing is returned as a fit. The trace draws something this run does not build (an overdrawn or doubled stroke, another edge, a bend the cage has too few points for): redraw it, or give the run more points. A very unsteady hand reads the same as a slight overdraw: if the trace is one clean stroke, ask again with tol over this reading. Nothing changed."
},
{
"name": "an unknown camera is refused naming the trace",
"ok": true,
"detail": "Error: traces[0]: 'Nobody' is not a camera object."
},
{
"name": "an object that is no shell is refused",
"ok": true,
"detail": "Error: 'View' is not a shell brokkr_kitbash.shell made (a mesh carrying kit_shell)."
},
{
"name": "a scaled shell is refused",
"ok": true,
"detail": "Error: 'Plate' is scaled (2.0, 2.0, 2.0): a sheet is in metres of the shell's own frame. Apply or clear the scale."
},
{
"name": "no refusal changed the shell",
"ok": true,
"detail": null
},
{
"name": "a mirrored free cage's crease, traced on both halves and named {verts}, is fitted within 1 mm of the designed run from a blocking over 0.05 m off: a row for each of its six vertices and no other, every trace explained, nothing written",
"ok": true,
"detail": {
"gap": 0.00042547668113367745,
"off": 0.055743395392436126,
"traces": [
{
"unexplained_px": 0.013,
"worst_px": 0.022
},
{
"unexplained_px": 0.02,
"worst_px": 0.032
}
],
"prior_share": 0.06,
"seconds": 0.027
}
},
{
"name": "brokkr_kitbash.shell takes the fitted free cage, and at one level Blender builds its crease on both halves where core.crease_run says, within 1e-4 m",
"ok": true,
"detail": {
"1": 1.305964704160048e-07,
"-1": 1.305964704160048e-07
}
}
],
"hostErrors": [],
"hostRows": [
"brokkr_mesh_polish.audit",
"brokkr_mesh_polish.repair",
"brokkr_mesh_polish.orient",
"brokkr_mesh_polish.delight",
"brokkr_mesh_polish.scrub_markings",
"brokkr_mesh_polish.cut_parts",
"brokkr_mesh_polish.pick",
"brokkr_kitbash.place_part",
"brokkr_kitbash.set_params",
"brokkr_kitbash.describe",
"brokkr_kitbash.report",
"brokkr_kitbash.attach",
"brokkr_kitbash.detach",
"brokkr_kitbash.roll",
"brokkr_kitbash.aim",
"brokkr_kitbash.reach",
"brokkr_kitbash.joint",
"brokkr_kitbash.slide",
"brokkr_kitbash.joints",
"brokkr_kitbash.close",
"brokkr_kitbash.boolean",
"brokkr_kitbash.cut",
"brokkr_kitbash.cut_many",
"brokkr_kitbash.freeze",
"brokkr_kitbash.thaw",
"brokkr_kitbash.ribs",
"brokkr_kitbash.shell",
"brokkr_kitbash.hose",
"brokkr_reference.solve_camera",
"brokkr_reference.flow_score",
"brokkr_reference.fit_shell"
],
"ok": true
}

View file

@ -0,0 +1,276 @@
"""Live proof, in a background Blender, of brokkr_reference.flow_score through run_intent, and of core.crease_run
against Blender's own subdivision.
crease_run a strip of quads with its middle column creased hard, subdivided once by Blender: the built crease
is where core.crease_run says (the numbers printed as BUILT are test_reference.py's fixture)
flow_score a box and, beside it, a folded sheet seen from behind: the box's front edge scores 1, its back edge 0
(it faces away, so it is never read), and the sheet's fold 0, since neither of its faces is toward
the camera (mutant N5, which counts such creases, reads 1 and four creases). Then the box alone at
scales 0.01, 1 and 100, its front edge seen, and hidden by a strip standing in front of it by
0.316% of the box's diagonal (mutants O1, nothing hides; O2, a margin of 0.03 units; O3, HIDE ten
times over: each reads the hidden edge as seen. O4, no margin at all, loses seen edges to their
own faces here and at the first box). The margin is the objects' own: a box over a ground 20 and
40 times its size, a small box over a ground behind a long strip (O7, a share of the largest mesh
read), two chips before a large box (O9, no second cast); a box, a ground and a strip joined
into one mesh, where the margin is the box's own connected piece's (O10, the whole mesh's).
Cameras 30 and 144 diagonals off still read every edge (O5, HIDE at 1e-6, loses four contours
at 144)
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/reference_flow.py -- <out>
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). <out> is an absolute path: it writes <out>.result.json and exits 1 when a check failed. Not part
of the unittest run: it needs Blender.
"""
import json
import math
import os
import sys
import tempfile
import time
import traceback
import types
from pathlib import Path
import bmesh
import bpy
import numpy as np
from bpy_extras.object_utils import world_to_camera_view
from mathutils import Euler, Matrix, Vector
SURFACE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(SURFACE / "tools"))
import private_dirs # noqa: E402
_refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if _refused:
raise SystemExit(_refused)
OUT = sys.argv[sys.argv.index("--") + 1]
if not os.path.isabs(OUT):
raise SystemExit(f"<out> must be an absolute path, not {OUT!r}: a relative one lands in Blender's start directory")
package = types.ModuleType("brokkr_bridge")
package.__path__ = [str(SURFACE / "brokkr_bridge")]
sys.modules["brokkr_bridge"] = package
from brokkr_bridge import blender_target as bt # noqa: E402
import addon_utils # noqa: E402
sys.path.append(str(SURFACE))
bpy.ops.wm.read_factory_settings(use_empty=True)
for module in ("brokkr_mesh_polish", "brokkr_reference"):
addon_utils.enable(module, default_set=True)
from brokkr_reference import core # noqa: E402
target = bt.BrokkrBlenderTarget(bpy)
target.configure_action_dirs("", tempfile.mkdtemp(prefix="brokkr-reference-flow-live-"))
target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1],
"hostRows": [row["name"] for row in target.host_actions()[0]]}
COUNT = [0]
T0 = time.time()
WIDTH, HEIGHT = 800, 600
COLUMN = [[0.5, 0.0, 0.0], [0.6, 0.2, 1.0], [0.4, 0.1, 2.0], [0.7, -0.2, 3.0], [0.5, 0.0, 4.0]]
def check(name, ok, detail=None):
R["checks"].append({"name": name, "ok": bool(ok), "detail": detail})
def send(action, **fields):
COUNT[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"live-{COUNT[0]}", "requestedBy": "test/driver", "action": action, **fields})
result = json.loads(receipt["hostResult"]) if receipt.get("hostResult") else None
print("SEND", f"{time.time() - T0:.1f}s", action, receipt["status"], str(receipt["message"])[:300], flush=True)
return receipt, result
def mesh_object(name, verts, faces):
mesh = bpy.data.meshes.new(name)
mesh.from_pydata(verts, [], faces)
obj = bpy.data.objects.new(name, mesh)
bpy.context.scene.collection.objects.link(obj)
return obj
def traced(camera, points, scale=1.0, corner=(0.0, 0.0)):
"""'u,v u,v ...' where Blender's own projection draws world points, in an image whose pixels are the frame's
times `scale` from `corner`."""
out = []
for p in points:
x, y, _ = world_to_camera_view(bpy.context.scene, camera, Vector(p))
out.append(f"{corner[0] + scale * x * WIDTH:.3f},{corner[1] + scale * (1.0 - y) * HEIGHT:.3f}")
return " ".join(out)
try:
check("host file admitted", not R["hostErrors"] and "brokkr_reference.flow_score" in R["hostRows"], R["hostRows"])
scene = bpy.context.scene
scene.render.resolution_x, scene.render.resolution_y, scene.render.resolution_percentage = WIDTH, HEIGHT, 100
# --- crease_run is Blender's level-1 subdivision of a hard crease -------------------------------------------------
col = np.array(COLUMN)
verts = [tuple(p + d) for p in col for d in ((-0.5, 0.3, 0.0), (0.0, 0.0, 0.0), (0.5, -0.3, 0.1))]
strip = mesh_object("Strip", verts, [(3 * i + j, 3 * i + j + 1, 3 * i + j + 4, 3 * i + j + 3) for i in range(4) for j in range(2)])
sharp = strip.data.attributes.new("crease_edge", "FLOAT", "EDGE")
for edge in strip.data.edges:
sharp.data[edge.index].value = 1.0 if all(v % 3 == 1 for v in edge.vertices) else 0.0
modifier = strip.modifiers.new("Subdivision", "SUBSURF")
modifier.levels, modifier.subdivision_type, modifier.use_creases = 1, "CATMULL_CLARK", True
bpy.context.view_layer.update()
evaluated = strip.evaluated_get(bpy.context.evaluated_depsgraph_get())
built_all = np.array([v.co for v in evaluated.data.vertices])
run = core.crease_run(COLUMN)
nearest = [built_all[np.linalg.norm(built_all - p, axis=1).argmin()] for p in run]
R["BUILT"] = [[round(float(v), 6) for v in p] for p in nearest]
print("BUILT", json.dumps(R["BUILT"]), flush=True)
worst = float(np.abs(np.array(nearest) - run).max())
# Shipped 4.8e-7 m (Blender's single floats); without the limit step (N3) 0.0208: the bound is their geometric mean.
check("crease_run stands where Blender builds the creased column, within 1e-4 m", len(built_all) == 45 and worst < 1e-4, worst)
strip.hide_render = True
strip.hide_viewport = True
# --- the camera every flow_score check below is seen through -------------------------------------------------------
truth = bpy.data.objects.new("Truth", bpy.data.cameras.new("Truth"))
scene.collection.objects.link(truth)
truth.data.lens, truth.data.sensor_width, truth.data.sensor_fit = 50.0, 36.0, "HORIZONTAL"
truth.matrix_world = Matrix.Translation((-6.5, -8.0, 4.6)) @ Euler((1.2, 0.03, -0.72), "XYZ").to_matrix().to_4x4()
bpy.context.view_layer.update()
box = "100,50,1700,1250" # the same view as an image twice the frame's size, its corner at 100, 50
# --- flow_score: the edges the camera sees on a box and on a folded sheet seen from behind ------------------------
bm = bmesh.new()
bmesh.ops.create_cube(bm, size=2.0, matrix=Matrix.Translation((0.0, 0.0, 1.0)))
mesh = bpy.data.meshes.new("Box")
bm.to_mesh(mesh)
bm.free()
scene.collection.objects.link(bpy.data.objects.new("Box", mesh))
# a valley fold running toward the camera in plan, its faces rising 45 degrees to either side: seen from above, both look down and away
fold, wing = [(2.176, -1.734, 0.5), (2.824, -1.266, 0.5)], np.array([0.1755, -0.2433, 0.3])
sheet = mesh_object("Sheet", [fold[0], fold[1], tuple(fold[1] - wing * [1, 1, -1]), tuple(fold[0] - wing * [1, 1, -1]), tuple(fold[1] + wing), tuple(fold[0] + wing)], [(0, 1, 2, 3), (1, 0, 5, 4)])
for polygon in sheet.data.polygons:
if polygon.normal.z > 0:
polygon.flip()
sheet.data.update()
bpy.context.view_layer.update()
eye = np.array(truth.matrix_world.translation)
check("fixture: both of the sheet's faces look away from the camera, and their fold is 90 degrees or so",
all((eye - np.array(p.center)) @ np.array(p.normal) < 0 for p in sheet.data.polygons) and abs(sheet.data.polygons[0].normal @ sheet.data.polygons[1].normal) < 0.5,
[list(p.normal) for p in sheet.data.polygons])
front, back = [(-1.0, -1.0, 0.0), (-1.0, -1.0, 2.0)], [(1.0, 1.0, 0.0), (1.0, 1.0, 2.0)]
lines = f"front: {traced(truth, front)}; back: {traced(truth, back)}; fold: {traced(truth, fold)}; top: {traced(truth, [(-1.0, -1.0, 2.0), (1.0, -1.0, 2.0), (1.0, 1.0, 2.0)])}"
receipt, flow = send("brokkr_reference.flow_score", camera_name="Truth", lines=lines)
R["flow"] = flow
check("flow_score: accepted; the box shows 3 creases and 6 contours, the sheet 6 borders and no crease", receipt["status"] == "accepted"
and flow["edges"] == {"crease": 3, "contour": 6, "border": 6} and flow["objects"] == ["Box", "Sheet"] and flow["height"] == HEIGHT, [receipt["message"], flow and flow["edges"]])
check("the box's front edge and the top's two edges score on 1, run 1", flow and flow["lines"]["front"]["on"] == 1.0 and flow["lines"]["front"]["run"] == 1.0
and flow["lines"]["top"]["on"] > 0.95, flow and flow["lines"])
check("the box's back edge, both its faces turned away, is not read: on 0", flow and flow["lines"]["back"] == {"on": 0.0, "off": 5.0, "run": 0.0}, flow and flow["lines"]["back"])
check("the sheet's fold, both faces turned away, scores on 0 (N5 reads 1)", flow and flow["lines"]["fold"]["on"] == 0.0, flow and flow["lines"]["fold"])
receipt, only = send("brokkr_reference.flow_score", camera_name="Truth", lines=lines, objects="Box", box=box, height=600)
check("objects names the meshes read: the box alone has no border; lines in the frame's pixels miss a box twice its size",
receipt["status"] == "accepted" and only["edges"] == {"crease": 3, "contour": 6, "border": 0} and only["objects"] == ["Box"] and only["lines"]["front"]["on"] == 0.0, [receipt["message"], only])
for fields, said in (({"objects": "Nobody"}, "not a mesh object"), ({"objects": "Truth"}, "not a mesh object"), ({"lines": "1,2 3,4"}, "no tag"), ({"camera_name": "Box"}, "not a camera")):
receipt, _ = send("brokkr_reference.flow_score", **{"camera_name": "Truth", "lines": lines, **fields})
check(f"flow_score refuses {next(iter(fields))}: failed, saying '{said}'", receipt["status"] == "failed" and said in receipt["message"], receipt["message"])
# --- flow_score: an edge the camera would see, hidden by a nearer surface; the margin is the objects' own ----------
def stage(half, ground=0.0, far=0.0):
"""A box of half-width `half` standing on z = 0, alone or over a square ground `ground` across, and a camera:
the first box's, scaled with the box, or one `far` box diagonals off with the lens grown to match. Returns
the camera, the box's front edge, and its line as the camera draws it."""
for obj in [o for o in bpy.data.objects if o.type == "MESH"]:
bpy.data.objects.remove(obj)
name = f"Staged {half:g} {ground:g} {far:g}"
staged = bpy.data.objects.new(name, bpy.data.cameras.new(name))
scene.collection.objects.link(staged)
staged.data.lens, staged.data.sensor_width, staged.data.sensor_fit, staged.data.clip_start, staged.data.clip_end = 50.0 * max(1.0, far / 5.0), 36.0, "HORIZONTAL", 0.01 * half, 1e9
if far:
centre = Vector((0.0, 0.0, half))
place = centre + Vector((-0.55, -0.7, 0.4)).normalized() * far * 2.0 * half * math.sqrt(3.0)
staged.matrix_world = Matrix.Translation(place) @ (centre - place).to_track_quat("-Z", "Y").to_matrix().to_4x4()
else:
staged.matrix_world = Matrix.Translation(truth.matrix_world.translation * half) @ truth.matrix_world.to_3x3().to_4x4()
bm = bmesh.new()
bmesh.ops.create_cube(bm, size=2.0 * half, matrix=Matrix.Translation((0.0, 0.0, half)))
mesh = bpy.data.meshes.new("Box")
bm.to_mesh(mesh)
bm.free()
scene.collection.objects.link(bpy.data.objects.new("Box", mesh))
if ground:
g = ground / 2.0
mesh_object("Ground", [(-g, -g, -4.0 * half), (g, -g, -4.0 * half), (g, g, -4.0 * half), (-g, g, -4.0 * half)], [(0, 1, 2, 3)])
bpy.context.view_layer.update()
edge = np.array([(-1.0, -1.0, 0.0), (-1.0, -1.0, 2.0)]) * half
return staged, edge, f"front: {traced(staged, edge)}"
def screen(staged, name, point, gap, wide, tall):
"""An upright quad `wide` by `tall` that every sight line to `point` meets `gap` before it."""
toward = np.array(staged.matrix_world.translation) - point
toward /= np.linalg.norm(toward)
level = np.array([toward[0], toward[1], 0.0]) / np.hypot(toward[0], toward[1])
side = np.cross([0.0, 0.0, 1.0], level)
at = point + level * gap * float(toward @ level)
mesh_object(name, [tuple(at + side * a * wide / 2.0 + np.array([0.0, 0.0, b * tall / 2.0])) for a, b in ((-1, -1), (1, -1), (1, 1), (-1, 1))], [(0, 1, 2, 3)])
bpy.context.view_layer.update()
def front(staged, line, objects):
receipt, flow = send("brokkr_reference.flow_score", camera_name=staged.name, lines=line, **objects)
return (flow["lines"]["front"]["on"], flow["edges"]["crease"], flow["edges"]["contour"]) if receipt["status"] == "accepted" else receipt["message"]
DIAGONAL = 2.0 * math.sqrt(3.0) # of a box, in its half-widths
for s in (0.01, 1.0, 100.0):
staged, edge, line = stage(s)
bare = front(staged, line, {"objects": "Box"})
gap = 3.16e-3 * DIAGONAL * s # of the box's diagonal: the geometric mean of the shipped HIDE, 1e-3, and one ten times it (mutant O3), 3.16 from each
screen(staged, "Wall", edge.mean(0), gap, 0.4 * s, 3.0 * s)
walled = front(staged, line, {"objects": "Box"})
check(f"at scale {s:g} the box's front edge is a crease the camera sees (on 1); a strip 0.316% of the box's diagonal in front of it hides it (on 0, one crease fewer): O1 (nothing hides), "
"O2 (the ray stops 0.03 units short) and O3 (ten times HIDE) read on 1", bare == (1.0, 3, 6) and walled == (0.0, 2, 6), [bare, walled, gap])
# a larger mesh in the scene and among the meshes read: the margin stays the box's
for half, ground in ((0.5, 20.0), (0.05, 4.0)):
staged, edge, line = stage(half, ground)
bare = front(staged, line, {})
screen(staged, "Wall", edge.mean(0), 0.01 * DIAGONAL * half, 0.4 * half, 3.0 * half)
walled = front(staged, line, {})
check(f"a box {2 * half:g} across over a ground {ground:g} across, every mesh read: its front edge is seen, and a strip 1% of the box's diagonal in front hides it "
f"(a margin of the ground's is {1e-3 * ground * math.sqrt(2.0) / (0.01 * DIAGONAL * half):.1f} times the gap)", bare == (1.0, 3, 6) and walled == (0.0, 2, 6), [bare, walled])
# the box, the ground and the strip joined into one mesh: the margin is the box's own piece's (O10, the whole mesh's diagonal, reads on 1: the ground's margin is 16 times the gap)
staged, edge, line = stage(0.05, 20.0)
screen(staged, "Wall", edge.mean(0), 0.01 * DIAGONAL * 0.05, 0.02, 0.15)
bm = bmesh.new()
for obj in [o for o in bpy.data.objects if o.type == "MESH"]:
bm.from_mesh(obj.data)
bpy.data.objects.remove(obj)
mesh = bpy.data.meshes.new("Joined")
bm.to_mesh(mesh)
bm.free()
scene.collection.objects.link(bpy.data.objects.new("Joined", mesh))
bpy.context.view_layer.update()
walled = front(staged, line, {})
check("a box 0.1 across, a ground 20 across and a strip 1% of the box's diagonal in front of the box's edge, all one mesh: hidden, the margin is the edge's own connected piece's (O10 reads on 1)", walled[0] == 0.0, walled)
# a small box's edge behind a strip far longer than the box, over a ground: the margin is the box's, not the strip's or the ground's (O7, a share of the largest mesh read, reads on 1)
staged, edge, line = stage(0.05, 4.0)
gap = math.sqrt(1e-3 * DIAGONAL * 0.05 * 1e-3 * math.hypot(0.02, 4.0)) # the geometric mean of the box's margin and the strip's, 4.8 from each
screen(staged, "Wall", edge.mean(0), gap, 0.02, 4.0)
walled = front(staged, line, {})
check("a box 0.1 across over a ground 4 across, with a strip 4 long standing between the two margins in front of its edge: hidden, the margin is the smaller object's (O7 reads on 1)", walled == (0.0, 2, 6), [walled, gap])
# two chips far smaller than the box, in front of two of the edge's three read points: the margin is the chips' (O9, no second cast, reads on 1)
staged, edge, line = stage(1.0)
gap = math.sqrt(1e-3 * DIAGONAL * 1e-3 * 0.05 * math.sqrt(2.0)) # the geometric mean of the box's margin and a chip's, 7 from each
for t in (0.2, 0.5):
screen(staged, f"Chip {t}", edge[0] + t * (edge[1] - edge[0]), gap, 0.05, 0.05)
chipped = front(staged, line, {"objects": "Box"})
check("a box 2 across with two chips 0.05 across standing between the two margins in front of its edge: hidden, the margin is the chips' (O9 reads on 1)", chipped == (0.0, 2, 6), [chipped, gap])
# far cameras: the margin's floor is the ray's rounding (O5, HIDE 1e-6, loses four contours to their own faces at 144 diagonals; at 30 it reads true here)
for far in (30.0, 144.0):
staged, edge, line = stage(1.0, far=far)
bare = front(staged, line, {"objects": "Box"})
check(f"a camera {far:g} box diagonals off still reads the box's 3 creases and 6 contours and its front edge on 1" + (" (O5 reads 2 contours)" if far == 144.0 else ""), bare == (1.0, 3, 6), bare)
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, printed and written, not a missing result file
check(f"no uncaught error after: {R['checks'][-1]['name'] if R['checks'] else 'the start'}", False, traceback.format_exc().splitlines()[-6:])
R["ok"] = all(c["ok"] for c in R["checks"])
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
sys.exit(0 if R["ok"] else 1)

View file

@ -0,0 +1,385 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "host file admitted",
"ok": true,
"detail": [
"brokkr_mesh_polish.audit",
"brokkr_mesh_polish.repair",
"brokkr_mesh_polish.orient",
"brokkr_mesh_polish.delight",
"brokkr_mesh_polish.scrub_markings",
"brokkr_mesh_polish.cut_parts",
"brokkr_mesh_polish.pick",
"brokkr_reference.solve_camera",
"brokkr_reference.flow_score"
]
},
{
"name": "crease_run stands where Blender builds the creased column, within 1e-4 m",
"ok": true,
"detail": 4.76837158203125e-07
},
{
"name": "fixture: both of the sheet's faces look away from the camera, and their fold is 90 degrees or so",
"ok": true,
"detail": [
[
-0.4140099287033081,
0.5732445120811462,
-0.7070971727371216
],
[
0.4140099287033081,
-0.5732445120811462,
-0.7070971727371216
]
]
},
{
"name": "flow_score: accepted; the box shows 3 creases and 6 contours, the sheet 6 borders and no crease",
"ok": true,
"detail": [
"Operator brokkr_reference.flow_score finished.",
{
"crease": 3,
"contour": 6,
"border": 6
}
]
},
{
"name": "the box's front edge and the top's two edges score on 1, run 1",
"ok": true,
"detail": {
"front": {
"on": 1.0,
"off": 0.0,
"run": 1.0
},
"back": {
"on": 0.0,
"off": 5.0,
"run": 0.0
},
"fold": {
"on": 0.0,
"off": 5.0,
"run": 0.0
},
"top": {
"on": 0.988,
"off": 0.06,
"run": 0.537
}
}
},
{
"name": "the box's back edge, both its faces turned away, is not read: on 0",
"ok": true,
"detail": {
"on": 0.0,
"off": 5.0,
"run": 0.0
}
},
{
"name": "the sheet's fold, both faces turned away, scores on 0 (N5 reads 1)",
"ok": true,
"detail": {
"on": 0.0,
"off": 5.0,
"run": 0.0
}
},
{
"name": "objects names the meshes read: the box alone has no border; lines in the frame's pixels miss a box twice its size",
"ok": true,
"detail": [
"Operator brokkr_reference.flow_score finished.",
{
"lines": {
"front": {
"on": 0.0,
"off": 5.0,
"run": 0.0
},
"back": {
"on": 0.0,
"off": 5.0,
"run": 0.0
},
"fold": {
"on": 0.0,
"off": 5.0,
"run": 0.0
},
"top": {
"on": 0.0,
"off": 5.0,
"run": 0.0
}
},
"edges": {
"crease": 3,
"contour": 6,
"border": 0
},
"objects": [
"Box"
],
"height": 600.0
}
]
},
{
"name": "flow_score refuses objects: failed, saying 'not a mesh object'",
"ok": true,
"detail": "Error: 'Nobody' is not a mesh object of this scene."
},
{
"name": "flow_score refuses objects: failed, saying 'not a mesh object'",
"ok": true,
"detail": "Error: 'Truth' is not a mesh object of this scene."
},
{
"name": "flow_score refuses lines: failed, saying 'no tag'",
"ok": true,
"detail": "Error: lines entry '1,2 3,4' has no tag; it is 'tag: u,v u,v ...'"
},
{
"name": "flow_score refuses camera_name: failed, saying 'not a camera'",
"ok": true,
"detail": "Error: 'Box' is not a camera object."
},
{
"name": "at scale 0.01 the box's front edge is a crease the camera sees (on 1); a strip 0.316% of the box's diagonal in front of it hides it (on 0, one crease fewer): O1 (nothing hides), O2 (the ray stops 0.03 units short) and O3 (ten times HIDE) read on 1",
"ok": true,
"detail": [
[
1.0,
3,
6
],
[
0.0,
2,
6
],
0.00010946561103835304
]
},
{
"name": "at scale 1 the box's front edge is a crease the camera sees (on 1); a strip 0.316% of the box's diagonal in front of it hides it (on 0, one crease fewer): O1 (nothing hides), O2 (the ray stops 0.03 units short) and O3 (ten times HIDE) read on 1",
"ok": true,
"detail": [
[
1.0,
3,
6
],
[
0.0,
2,
6
],
0.010946561103835304
]
},
{
"name": "at scale 100 the box's front edge is a crease the camera sees (on 1); a strip 0.316% of the box's diagonal in front of it hides it (on 0, one crease fewer): O1 (nothing hides), O2 (the ray stops 0.03 units short) and O3 (ten times HIDE) read on 1",
"ok": true,
"detail": [
[
1.0,
3,
6
],
[
0.0,
2,
6
],
1.0946561103835304
]
},
{
"name": "a box 1 across over a ground 20 across, every mesh read: its front edge is seen, and a strip 1% of the box's diagonal in front hides it (a margin of the ground's is 1.6 times the gap)",
"ok": true,
"detail": [
[
1.0,
3,
6
],
[
0.0,
2,
6
]
]
},
{
"name": "a box 0.1 across over a ground 4 across, every mesh read: its front edge is seen, and a strip 1% of the box's diagonal in front hides it (a margin of the ground's is 3.3 times the gap)",
"ok": true,
"detail": [
[
1.0,
3,
6
],
[
0.0,
2,
6
]
]
},
{
"name": "a box 0.1 across, a ground 20 across and a strip 1% of the box's diagonal in front of the box's edge, all one mesh: hidden, the margin is the edge's own connected piece's (O10 reads on 1)",
"ok": true,
"detail": [
0.0,
2,
6
]
},
{
"name": "a box 0.1 across over a ground 4 across, with a strip 4 long standing between the two margins in front of its edge: hidden, the margin is the smaller object's (O7 reads on 1)",
"ok": true,
"detail": [
[
0.0,
2,
6
],
0.000832363492248106
]
},
{
"name": "a box 2 across with two chips 0.05 across standing between the two margins in front of its edge: hidden, the margin is the chips' (O9 reads on 1)",
"ok": true,
"detail": [
[
0.0,
2,
6
],
0.0004949232003839765
]
},
{
"name": "a camera 30 box diagonals off still reads the box's 3 creases and 6 contours and its front edge on 1",
"ok": true,
"detail": [
1.0,
3,
6
]
},
{
"name": "a camera 144 box diagonals off still reads the box's 3 creases and 6 contours and its front edge on 1 (O5 reads 2 contours)",
"ok": true,
"detail": [
1.0,
3,
6
]
}
],
"hostErrors": [],
"hostRows": [
"brokkr_mesh_polish.audit",
"brokkr_mesh_polish.repair",
"brokkr_mesh_polish.orient",
"brokkr_mesh_polish.delight",
"brokkr_mesh_polish.scrub_markings",
"brokkr_mesh_polish.cut_parts",
"brokkr_mesh_polish.pick",
"brokkr_reference.solve_camera",
"brokkr_reference.flow_score"
],
"BUILT": [
[
0.5,
0.0,
0.0
],
[
0.54375,
0.09375,
0.5
],
[
0.55,
0.15,
1.0
],
[
0.504167,
0.139583,
1.5
],
[
0.483333,
0.066667,
2.0
],
[
0.55,
-0.04375,
2.5
],
[
0.616667,
-0.116667,
3.0
],
[
0.589583,
-0.089583,
3.5
],
[
0.5,
0.0,
4.0
]
],
"flow": {
"lines": {
"front": {
"on": 1.0,
"off": 0.0,
"run": 1.0
},
"back": {
"on": 0.0,
"off": 5.0,
"run": 0.0
},
"fold": {
"on": 0.0,
"off": 5.0,
"run": 0.0
},
"top": {
"on": 0.988,
"off": 0.06,
"run": 0.537
}
},
"edges": {
"crease": 3,
"contour": 6,
"border": 6
},
"objects": [
"Box",
"Sheet"
],
"height": 600.0
},
"ok": true
}

View file

@ -7,7 +7,9 @@ as a GLB the exporter hook has given VRMC_springBone. Not part of the unittest r
Run it with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories (it refuses
without them). Writes <out>.result.json and <out>.glb (the synthetic whale's rig, for the runtime's own parse,
Aetheria SpringRigVerify.VerifyGlb) and exits 1 when a check failed. The acceptance is the runtime's parse, not
Aetheria SpringRigVerify.VerifyGlb) and exits 1 when a check failed. The checks run inside one try: an uncaught error is a failed check that names
the check before it, the checks are printed and the result file written whatever happened, and the exit is 1 with or
without --python-exit-code. The acceptance is the runtime's parse, not
anything here: the structure checks below are what this builder promised, not the runtime's rules.
"""
import json
@ -15,6 +17,7 @@ import math
import os
import struct
import sys
import traceback
import tempfile
import time
import types
@ -56,6 +59,10 @@ T0 = time.time()
def check(name, ok, detail=None):
try:
json.dumps(detail, default=str)
except TypeError: # a detail keyed by tuples: the result file takes it as text, so a failed check is written and not a crash
detail = repr(detail)
R["checks"].append({"name": name, "ok": bool(ok), "detail": detail})
@ -153,186 +160,189 @@ def world_of(nodes, parent, i):
return out
whale = make_whale()
check("host file admitted", not R["hostErrors"] and {"brokkr_rig.body", "brokkr_rig.tendrils", "brokkr_rig.colliders"} <= set(R["hostRows"]),
R["hostErrors"] or R["hostRows"])
whale.rotation_euler = (0.0, 0.0, math.radians(90)) # lying along x with a non-identity transform and an offset
whale.location = (0.4, -0.2, 0.1)
bpy.context.view_layer.update()
receipt, audit = send("brokkr_mesh_polish.audit", object_name="Whale")
R["audit"] = audit
check("fixture: one fused shell and a detached bead", audit and audit["Whale"]["shells"] == 2, audit)
receipt, _ = send("brokkr_mesh_polish.repair", object_name="Whale")
check("repair accepted", receipt["status"] == "accepted", receipt["message"])
receipt, oriented = send("brokkr_mesh_polish.orient", object_name="Whale", length=1.0)
check("orient accepted", receipt["status"] == "accepted", receipt["message"])
receipt, body = send("brokkr_rig.body", object_name="Whale", spine_bones=6, head="+y", seeds="jaw=0,0.45,0.05", smooth_rounds=2)
check("body accepted", receipt["status"] == "accepted", receipt["message"])
R["body"] = body
if body:
arm = bpy.data.objects[body["armature"]]
check("body: a spine of six, a jaw bone parented to a spine bone", body["spine"] == [f"spine_{i:02d}" for i in range(6)]
and [p["name"] for p in body["parts"]] == ["jaw"] and body["parts"][0]["triangles"] > 0
and arm.data.bones["jaw"].parent.name in body["spine"], body["parts"])
head, tail = np.array(body["head"]), np.array(body["tail"])
check("body: the root bone is at the +y end and the object's transform is baked", head[1] > tail[1]
and np.allclose(np.array(whale.matrix_world), np.eye(4), atol=1e-9) and arm.data.bones["spine_00"].parent is None, [head, tail])
receipt, tendrils = send("brokkr_rig.tendrils", object_name="Whale", tau=0.05, band=0.04, dilate=0.01)
check("tendrils accepted", receipt["status"] == "accepted", receipt["message"])
R["tendrils"] = tendrils
if tendrils:
check("tendrils: five chains (the vein folded), the fork made one chain with a rigid branch, the bead attached",
tendrils["chains"] == 5 and tendrils["veinsFolded"] >= 1 and tendrils["branchesRigid"] >= 1 and tendrils["shellsAttached"] >= 1, tendrils)
receipt, colliders = send("brokkr_rig.colliders", object_name="Whale")
check("colliders accepted", receipt["status"] == "accepted", receipt["message"])
R["colliders"] = colliders
try:
whale = make_whale()
check("host file admitted", not R["hostErrors"] and {"brokkr_rig.body", "brokkr_rig.tendrils", "brokkr_rig.colliders"} <= set(R["hostRows"]),
R["hostErrors"] or R["hostRows"])
whale.rotation_euler = (0.0, 0.0, math.radians(90)) # lying along x with a non-identity transform and an offset
whale.location = (0.4, -0.2, 0.1)
bpy.context.view_layer.update()
receipt, audit = send("brokkr_mesh_polish.audit", object_name="Whale")
R["audit"] = audit
check("fixture: one fused shell and a detached bead", audit and audit["Whale"]["shells"] == 2, audit)
receipt, _ = send("brokkr_mesh_polish.repair", object_name="Whale")
check("repair accepted", receipt["status"] == "accepted", receipt["message"])
receipt, oriented = send("brokkr_mesh_polish.orient", object_name="Whale", length=1.0)
check("orient accepted", receipt["status"] == "accepted", receipt["message"])
receipt, body = send("brokkr_rig.body", object_name="Whale", spine_bones=6, head="+y", seeds="jaw=0,0.45,0.05", smooth_rounds=2)
check("body accepted", receipt["status"] == "accepted", receipt["message"])
R["body"] = body
if body:
arm = bpy.data.objects[body["armature"]]
check("body: a spine of six, a jaw bone parented to a spine bone", body["spine"] == [f"spine_{i:02d}" for i in range(6)]
and [p["name"] for p in body["parts"]] == ["jaw"] and body["parts"][0]["triangles"] > 0
and arm.data.bones["jaw"].parent.name in body["spine"], body["parts"])
head, tail = np.array(body["head"]), np.array(body["tail"])
check("body: the root bone is at the +y end and the object's transform is baked", head[1] > tail[1]
and np.allclose(np.array(whale.matrix_world), np.eye(4), atol=1e-9) and arm.data.bones["spine_00"].parent is None, [head, tail])
receipt, tendrils = send("brokkr_rig.tendrils", object_name="Whale", tau=0.05, band=0.04, dilate=0.01)
check("tendrils accepted", receipt["status"] == "accepted", receipt["message"])
R["tendrils"] = tendrils
if tendrils:
check("tendrils: five chains (the vein folded), the fork made one chain with a rigid branch, the bead attached",
tendrils["chains"] == 5 and tendrils["veinsFolded"] >= 1 and tendrils["branchesRigid"] >= 1 and tendrils["shellsAttached"] >= 1, tendrils)
receipt, colliders = send("brokkr_rig.colliders", object_name="Whale")
check("colliders accepted", receipt["status"] == "accepted", receipt["message"])
R["colliders"] = colliders
def skin_state():
"""Every vertex's (group name, weight) pairs and every chain bone's properties, exactly as stored."""
groups = [g.name for g in whale.vertex_groups]
weights = [sorted((groups[e.group], e.weight) for e in v.groups) for v in whale.data.vertices]
props = {b.name: [b[k] for k in ("rig_chain", "rig_index", "rig_stiffness", "rig_drag", "rig_gravity", "rig_hit_radius")]
for b in arm.data.bones if "rig_chain" in b}
return weights, props
def skin_state():
"""Every vertex's (group name, weight) pairs and every chain bone's properties, exactly as stored."""
groups = [g.name for g in whale.vertex_groups]
weights = [sorted((groups[e.group], e.weight) for e in v.groups) for v in whale.data.vertices]
props = {b.name: [b[k] for k in ("rig_chain", "rig_index", "rig_stiffness", "rig_drag", "rig_gravity", "rig_hit_radius")]
for b in arm.data.bones if "rig_chain" in b}
return weights, props
first = skin_state()
send("brokkr_rig.tendrils", object_name="Whale", tau=0.05, band=0.06, dilate=0.02)
other = skin_state()
receipt, again = send("brokkr_rig.tendrils", object_name="Whale", tau=0.05, band=0.04, dilate=0.01)
check("tendrils with other knobs changes the skin", other != first, None)
check("tendrils, other knobs, then the first knobs again restores the weights and bone properties exactly", skin_state() == first, None)
check("the tendrils report says what it sees", tendrils and {"warnings", "largestChainShare", "chainVertexShare", "fusedContacts"} <= set(tendrils)
and len(tendrils["warnings"]) == 1 and "one chain holds" in tendrils["warnings"][0], tendrils) # five chains hold 13% each at most: hull-like by the gauge
receipt, colliders = send("brokkr_rig.colliders", object_name="Whale")
check("the colliders report lists each shrink and the largest share taken", colliders and colliders["shrunk"] > 0
and len(colliders["shrinks"]) == colliders["shrunk"] and all(x["after"] < x["before"] for x in colliders["shrinks"])
and abs(colliders["shrunkMax"] - max(1 - x["after"] / x["before"] for x in colliders["shrinks"])) < 1e-3, colliders)
R["colliders"] = colliders
first = skin_state()
send("brokkr_rig.tendrils", object_name="Whale", tau=0.05, band=0.06, dilate=0.02)
other = skin_state()
receipt, again = send("brokkr_rig.tendrils", object_name="Whale", tau=0.05, band=0.04, dilate=0.01)
check("tendrils with other knobs changes the skin", other != first, None)
check("tendrils, other knobs, then the first knobs again restores the weights and bone properties exactly", skin_state() == first, None)
check("the tendrils report says what it sees", tendrils and {"warnings", "largestChainShare", "chainVertexShare", "fusedContacts"} <= set(tendrils)
and len(tendrils["warnings"]) == 1 and "one chain holds" in tendrils["warnings"][0], tendrils) # five chains hold 13% each at most: hull-like by the gauge
receipt, colliders = send("brokkr_rig.colliders", object_name="Whale")
check("the colliders report lists each shrink and the largest share taken", colliders and colliders["shrunk"] > 0
and len(colliders["shrinks"]) == colliders["shrunk"] and all(x["after"] < x["before"] for x in colliders["shrinks"])
and abs(colliders["shrunkMax"] - max(1 - x["after"] / x["before"] for x in colliders["shrinks"])) < 1e-3, colliders)
R["colliders"] = colliders
# --- export: the five attributes, weights, extension, structure ----------------------------------------------------
receipt, _ = send("exportGltf", filepath="whale.glb", extras=False, yUp=True, applyModifiers=True)
check("exportGltf accepted", receipt["status"] == "accepted", receipt["message"])
gltf, blob, bin_at = glb_json(WORK / "whale.glb")
ext = gltf.get("extensions", {}).get("VRMC_springBone")
check("VRMC_springBone is in extensions and extensionsUsed", ext is not None and "VRMC_springBone" in gltf.get("extensionsUsed", []), list(gltf.get("extensions", {})))
if ext and tendrils and colliders:
check("the springs, joints and colliders are the built ones", len(ext["springs"]) == tendrils["chains"]
and sum(len(s["joints"]) for s in ext["springs"]) == tendrils["springBones"]
and len(ext["colliders"]) == colliders["capsules"] + colliders["spheres"]
and all(s["colliderGroups"] == [0] for s in ext["springs"]) and [g["name"] for g in ext["colliderGroups"]] == ["body"],
[len(ext["springs"]), len(ext["colliders"])])
check("the extension is not required", "VRMC_springBone" not in gltf.get("extensionsRequired", []), gltf.get("extensionsRequired"))
if ext:
check("stiffness tapers from the root's 3 to the tip's 1.5 and hit radii are half a tube's diameter or less",
all(abs(s["joints"][0]["stiffness"] - 3.0) < 1e-6 and abs(s["joints"][-1]["stiffness"] - 1.5) < 1e-6
and all(0 <= j["hitRadius"] <= 0.016 for j in s["joints"]) for s in ext["springs"]),
[[j["stiffness"] for j in ext["springs"][0]["joints"]], [j["hitRadius"] for j in ext["springs"][0]["joints"]]])
prims = [p for m in gltf["meshes"] for p in m["primitives"]]
check("mesh primitives carry exactly the five attributes", all(set(p["attributes"]) == {"POSITION", "NORMAL", "TEXCOORD_0", "JOINTS_0", "WEIGHTS_0"} for p in prims),
[sorted(p["attributes"]) for p in prims])
worst_sum, worst_count = 0.0, 0
for p in prims:
if "WEIGHTS_0" not in p["attributes"]:
check("every primitive is skinned", False, sorted(p["attributes"]))
continue
acc = gltf["accessors"][p["attributes"]["WEIGHTS_0"]]
view = gltf["bufferViews"][acc["bufferView"]]
W = np.frombuffer(blob, np.float32, acc["count"] * 4, bin_at + view.get("byteOffset", 0) + acc.get("byteOffset", 0)).reshape(-1, 4)
worst_sum = max(worst_sum, float(np.abs(W.sum(axis=1) - 1).max()))
worst_count = max(worst_count, int((W > 0).sum(axis=1).max()))
check("weights sum to 1 with at most four influences", worst_sum < 1e-5 and worst_count <= 4, [worst_sum, worst_count])
nodes = gltf["nodes"]
parent = {c: i for i, n in enumerate(nodes) for c in n.get("children", [])}
check("no node carries a matrix and every scale is 1", all("matrix" not in n and all(abs(s - 1) < 1e-4 for s in n.get("scale", (1, 1, 1))) for n in nodes), None)
joints = gltf["skins"][0]["joints"]
check("one skin over every bone", len(gltf["skins"]) == 1 and len(joints) == len(arm.data.bones), [len(joints), len(arm.data.bones)])
if ext:
in_spring = {j["node"] for s in ext["springs"] for j in s["joints"]}
linear = all(parent.get(s["joints"][0]["node"]) in set(joints) - in_spring and all(parent[s["joints"][k]["node"]] == s["joints"][k - 1]["node"] for k in range(1, len(s["joints"])))
for s in ext["springs"])
check("each spring is a linear chain, its first joint hung from a body bone, no bone in two springs", linear
and len(in_spring) == sum(len(s["joints"]) for s in ext["springs"]), None)
check("every segment has length", all(np.linalg.norm(nodes[j["node"]].get("translation", (0, 0, 0))) > 1e-6 for s in ext["springs"] for j in s["joints"][1:]), None)
check("colliders sit on body bones", all(c["node"] in set(joints) - in_spring for c in ext["colliders"]), None)
swing = np.array([[1.0, 0, 0], [0, 0, 1.0], [0, -1.0, 0]])
where = [world_of(nodes, parent, j["node"])[:3, 3] for s in ext["springs"] for j in s["joints"]]
expect = [swing @ np.array(arm.matrix_world @ arm.data.bones[nodes[j["node"]]["name"]].head_local) for s in ext["springs"] for j in s["joints"]]
check("every joint's node stands where its bone's head is in the scene", np.allclose(where, expect, atol=1e-4), float(np.abs(np.array(where) - np.array(expect)).max()))
R["glb"] = {"nodes": len(nodes), "joints": len(joints), "springs": len(ext["springs"]) if ext else 0, "colliders": len(ext["colliders"]) if ext else 0}
Path(OUT + ".glb").write_bytes((WORK / "whale.glb").read_bytes())
# --- export: the five attributes, weights, extension, structure ----------------------------------------------------
receipt, _ = send("exportGltf", filepath="whale.glb", extras=False, yUp=True, applyModifiers=True)
check("exportGltf accepted", receipt["status"] == "accepted", receipt["message"])
gltf, blob, bin_at = glb_json(WORK / "whale.glb")
ext = gltf.get("extensions", {}).get("VRMC_springBone")
check("VRMC_springBone is in extensions and extensionsUsed", ext is not None and "VRMC_springBone" in gltf.get("extensionsUsed", []), list(gltf.get("extensions", {})))
if ext and tendrils and colliders:
check("the springs, joints and colliders are the built ones", len(ext["springs"]) == tendrils["chains"]
and sum(len(s["joints"]) for s in ext["springs"]) == tendrils["springBones"]
and len(ext["colliders"]) == colliders["capsules"] + colliders["spheres"]
and all(s["colliderGroups"] == [0] for s in ext["springs"]) and [g["name"] for g in ext["colliderGroups"]] == ["body"],
[len(ext["springs"]), len(ext["colliders"])])
check("the extension is not required", "VRMC_springBone" not in gltf.get("extensionsRequired", []), gltf.get("extensionsRequired"))
if ext:
check("stiffness tapers from the root's 3 to the tip's 1.5 and hit radii are half a tube's diameter or less",
all(abs(s["joints"][0]["stiffness"] - 3.0) < 1e-6 and abs(s["joints"][-1]["stiffness"] - 1.5) < 1e-6
and all(0 <= j["hitRadius"] <= 0.016 for j in s["joints"]) for s in ext["springs"]),
[[j["stiffness"] for j in ext["springs"][0]["joints"]], [j["hitRadius"] for j in ext["springs"][0]["joints"]]])
prims = [p for m in gltf["meshes"] for p in m["primitives"]]
check("mesh primitives carry exactly the five attributes", all(set(p["attributes"]) == {"POSITION", "NORMAL", "TEXCOORD_0", "JOINTS_0", "WEIGHTS_0"} for p in prims),
[sorted(p["attributes"]) for p in prims])
worst_sum, worst_count = 0.0, 0
for p in prims:
if "WEIGHTS_0" not in p["attributes"]:
check("every primitive is skinned", False, sorted(p["attributes"]))
continue
acc = gltf["accessors"][p["attributes"]["WEIGHTS_0"]]
view = gltf["bufferViews"][acc["bufferView"]]
W = np.frombuffer(blob, np.float32, acc["count"] * 4, bin_at + view.get("byteOffset", 0) + acc.get("byteOffset", 0)).reshape(-1, 4)
worst_sum = max(worst_sum, float(np.abs(W.sum(axis=1) - 1).max()))
worst_count = max(worst_count, int((W > 0).sum(axis=1).max()))
check("weights sum to 1 with at most four influences", worst_sum < 1e-5 and worst_count <= 4, [worst_sum, worst_count])
nodes = gltf["nodes"]
parent = {c: i for i, n in enumerate(nodes) for c in n.get("children", [])}
check("no node carries a matrix and every scale is 1", all("matrix" not in n and all(abs(s - 1) < 1e-4 for s in n.get("scale", (1, 1, 1))) for n in nodes), None)
joints = gltf["skins"][0]["joints"]
check("one skin over every bone", len(gltf["skins"]) == 1 and len(joints) == len(arm.data.bones), [len(joints), len(arm.data.bones)])
if ext:
in_spring = {j["node"] for s in ext["springs"] for j in s["joints"]}
linear = all(parent.get(s["joints"][0]["node"]) in set(joints) - in_spring and all(parent[s["joints"][k]["node"]] == s["joints"][k - 1]["node"] for k in range(1, len(s["joints"])))
for s in ext["springs"])
check("each spring is a linear chain, its first joint hung from a body bone, no bone in two springs", linear
and len(in_spring) == sum(len(s["joints"]) for s in ext["springs"]), None)
check("every segment has length", all(np.linalg.norm(nodes[j["node"]].get("translation", (0, 0, 0))) > 1e-6 for s in ext["springs"] for j in s["joints"][1:]), None)
check("colliders sit on body bones", all(c["node"] in set(joints) - in_spring for c in ext["colliders"]), None)
swing = np.array([[1.0, 0, 0], [0, 0, 1.0], [0, -1.0, 0]])
where = [world_of(nodes, parent, j["node"])[:3, 3] for s in ext["springs"] for j in s["joints"]]
expect = [swing @ np.array(arm.matrix_world @ arm.data.bones[nodes[j["node"]]["name"]].head_local) for s in ext["springs"] for j in s["joints"]]
check("every joint's node stands where its bone's head is in the scene", np.allclose(where, expect, atol=1e-4), float(np.abs(np.array(where) - np.array(expect)).max()))
R["glb"] = {"nodes": len(nodes), "joints": len(joints), "springs": len(ext["springs"]) if ext else 0, "colliders": len(ext["colliders"]) if ext else 0}
Path(OUT + ".glb").write_bytes((WORK / "whale.glb").read_bytes())
# --- determinism, yUp, and a scene with no rig ------------------------------------------------------------------------
send("exportGltf", filepath="again.glb", extras=False, yUp=True, applyModifiers=True)
a, b = glb_json(WORK / "whale.glb")[0], glb_json(WORK / "again.glb")[0]
check("two exports have identical JSON chunks", json.dumps(a, sort_keys=True) == json.dumps(b, sort_keys=True), None)
send("exportGltf", filepath="flat.glb", extras=False, yUp=False, applyModifiers=True)
flat, _, _ = glb_json(WORK / "flat.glb")
fext = flat.get("extensions", {}).get("VRMC_springBone")
if ext and fext:
nodes_f = flat["nodes"]
parent_f = {c: i for i, n in enumerate(nodes_f) for c in n.get("children", [])}
names = {n["name"]: i for i, n in enumerate(nodes)}
# --- determinism, yUp, and a scene with no rig ------------------------------------------------------------------------
send("exportGltf", filepath="again.glb", extras=False, yUp=True, applyModifiers=True)
a, b = glb_json(WORK / "whale.glb")[0], glb_json(WORK / "again.glb")[0]
check("two exports have identical JSON chunks", json.dumps(a, sort_keys=True) == json.dumps(b, sort_keys=True), None)
send("exportGltf", filepath="flat.glb", extras=False, yUp=False, applyModifiers=True)
flat, _, _ = glb_json(WORK / "flat.glb")
fext = flat.get("extensions", {}).get("VRMC_springBone")
if ext and fext:
nodes_f = flat["nodes"]
parent_f = {c: i for i, n in enumerate(nodes_f) for c in n.get("children", [])}
names = {n["name"]: i for i, n in enumerate(nodes)}
def collider_world(gl, nd, par, c, key):
return (world_of(nd, par, c["node"]) @ np.append(c["shape"][list(c["shape"])[0]][key], 1.0))[:3]
def collider_world(gl, nd, par, c, key):
return (world_of(nd, par, c["node"]) @ np.append(c["shape"][list(c["shape"])[0]][key], 1.0))[:3]
pairs = [(collider_world(gltf, nodes, parent, c, "offset"), collider_world(flat, nodes_f, parent_f, f, "offset"))
for c, f in zip(ext["colliders"], fext["colliders"])]
check("yUp false: a collider's node-local offset composes to the same scene point (up to the axis swing)",
bool(pairs) and all(np.allclose(up, swing @ flat_point, atol=1e-4) for up, flat_point in pairs), pairs[:1])
bpy.ops.mesh.primitive_cube_add()
cube = bpy.context.active_object
cube.name = "Cube"
send("exportGltf", filepath="cube.glb", extras=False, yUp=True, applyModifiers=True, selection=["Cube"])
cube_json, _, _ = glb_json(WORK / "cube.glb")
check("a scene with no rig springs exports no VRMC_springBone", "VRMC_springBone" not in cube_json.get("extensions", {})
and "VRMC_springBone" not in cube_json.get("extensionsUsed", []), list(cube_json.get("extensions", {})))
pairs = [(collider_world(gltf, nodes, parent, c, "offset"), collider_world(flat, nodes_f, parent_f, f, "offset"))
for c, f in zip(ext["colliders"], fext["colliders"])]
check("yUp false: a collider's node-local offset composes to the same scene point (up to the axis swing)",
bool(pairs) and all(np.allclose(up, swing @ flat_point, atol=1e-4) for up, flat_point in pairs), pairs[:1])
bpy.ops.mesh.primitive_cube_add()
cube = bpy.context.active_object
cube.name = "Cube"
send("exportGltf", filepath="cube.glb", extras=False, yUp=True, applyModifiers=True, selection=["Cube"])
cube_json, _, _ = glb_json(WORK / "cube.glb")
check("a scene with no rig springs exports no VRMC_springBone", "VRMC_springBone" not in cube_json.get("extensions", {})
and "VRMC_springBone" not in cube_json.get("extensionsUsed", []), list(cube_json.get("extensions", {})))
# --- body again on its own armature: the chains go, nothing is left weighing nothing; colliders alone export no springs
chain_bones = sum(1 for b in arm.data.bones if "rig_chain" in b)
receipt, rebody = send("brokkr_rig.body", object_name="Whale", armature_name=arm.name, seeds="jaw=0,0.45,0.05")
check("body again clears the chain bones it would orphan",
rebody and rebody["chainBonesCleared"] == chain_bones > 0 and not any("rig_chain" in b for b in arm.data.bones), rebody)
check("body again leaves no collider from the old body", not any("rig_colliders" in b for b in arm.data.bones), None)
send("exportGltf", filepath="cleared.glb", extras=False, yUp=True, applyModifiers=True)
cleared_json, _, _ = glb_json(WORK / "cleared.glb")
check("an armature with no chains exports no springs", "VRMC_springBone" not in cleared_json.get("extensions", {}), None)
receipt, lone = send("brokkr_rig.colliders", object_name="Whale")
send("exportGltf", filepath="colliders_only.glb", extras=False, yUp=True, applyModifiers=True)
only_json, _, _ = glb_json(WORK / "colliders_only.glb")
check("colliders without chains export no VRMC_springBone", lone and lone["capsules"] > 0 and "VRMC_springBone" not in only_json.get("extensions", {})
and "VRMC_springBone" not in only_json.get("extensionsUsed", []), lone)
receipt, rerun = send("brokkr_rig.tendrils", object_name="Whale", tau=0.05, band=0.04, dilate=0.01)
check("tendrils after the second body rebuilds the same chains", rerun and tendrils and rerun["chains"] == tendrils["chains"]
and rerun["springBones"] == tendrils["springBones"], [rerun, tendrils])
# --- body again on its own armature: the chains go, nothing is left weighing nothing; colliders alone export no springs
chain_bones = sum(1 for b in arm.data.bones if "rig_chain" in b)
receipt, rebody = send("brokkr_rig.body", object_name="Whale", armature_name=arm.name, seeds="jaw=0,0.45,0.05")
check("body again clears the chain bones it would orphan",
rebody and rebody["chainBonesCleared"] == chain_bones > 0 and not any("rig_chain" in b for b in arm.data.bones), rebody)
check("body again leaves no collider from the old body", not any("rig_colliders" in b for b in arm.data.bones), None)
send("exportGltf", filepath="cleared.glb", extras=False, yUp=True, applyModifiers=True)
cleared_json, _, _ = glb_json(WORK / "cleared.glb")
check("an armature with no chains exports no springs", "VRMC_springBone" not in cleared_json.get("extensions", {}), None)
receipt, lone = send("brokkr_rig.colliders", object_name="Whale")
send("exportGltf", filepath="colliders_only.glb", extras=False, yUp=True, applyModifiers=True)
only_json, _, _ = glb_json(WORK / "colliders_only.glb")
check("colliders without chains export no VRMC_springBone", lone and lone["capsules"] > 0 and "VRMC_springBone" not in only_json.get("extensions", {})
and "VRMC_springBone" not in only_json.get("extensionsUsed", []), lone)
receipt, rerun = send("brokkr_rig.tendrils", object_name="Whale", tau=0.05, band=0.04, dilate=0.01)
check("tendrils after the second body rebuilds the same chains", rerun and tendrils and rerun["chains"] == tendrils["chains"]
and rerun["springBones"] == tendrils["springBones"], [rerun, tendrils])
# --- a mesh with no thin part: no chains is an outcome, not a crash, and the skin stays the body's --------------------------
ball = bmesh.new()
bmesh.ops.create_uvsphere(ball, u_segments=24, v_segments=12, radius=0.3, calc_uvs=True)
ball_mesh = bpy.data.meshes.new("Ball")
ball.to_mesh(ball_mesh)
ball.free()
ball_obj = bpy.data.objects.new("Ball", ball_mesh)
bpy.context.scene.collection.objects.link(ball_obj)
send("brokkr_rig.body", object_name="Ball", spine_bones=4)
# --- a mesh with no thin part: no chains is an outcome, not a crash, and the skin stays the body's --------------------------
ball = bmesh.new()
bmesh.ops.create_uvsphere(ball, u_segments=24, v_segments=12, radius=0.3, calc_uvs=True)
ball_mesh = bpy.data.meshes.new("Ball")
ball.to_mesh(ball_mesh)
ball.free()
ball_obj = bpy.data.objects.new("Ball", ball_mesh)
bpy.context.scene.collection.objects.link(ball_obj)
send("brokkr_rig.body", object_name="Ball", spine_bones=4)
def ball_weights():
names = [g.name for g in ball_obj.vertex_groups]
return [sorted((names[e.group], e.weight) for e in v.groups) for v in ball_obj.data.vertices]
def ball_weights():
names = [g.name for g in ball_obj.vertex_groups]
return [sorted((names[e.group], e.weight) for e in v.groups) for v in ball_obj.data.vertices]
before = ball_weights()
receipt, bald = send("brokkr_rig.tendrils", object_name="Ball", tau=0.05, band=0.04, dilate=0.01)
check("tendrils on a mesh with no thin part is accepted and reports no chains", receipt["status"] == "accepted" and bald and bald["chains"] == 0
and bald["springBones"] == 0 and bald["rings"] == 0 and bald["fusedContacts"] == 0, [receipt["message"], bald])
check("and leaves the skin as body made it, with no chain bones", ball_weights() == before
and not any("rig_chain" in b for b in bpy.data.objects["Ball.rig"].data.bones), None)
before = ball_weights()
receipt, bald = send("brokkr_rig.tendrils", object_name="Ball", tau=0.05, band=0.04, dilate=0.01)
check("tendrils on a mesh with no thin part is accepted and reports no chains", receipt["status"] == "accepted" and bald and bald["chains"] == 0
and bald["springBones"] == 0 and bald["rings"] == 0 and bald["fusedContacts"] == 0, [receipt["message"], bald])
check("and leaves the skin as body made it, with no chain bones", ball_weights() == before
and not any("rig_chain" in b for b in bpy.data.objects["Ball.rig"].data.bones), None)
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, printed and written, not a missing result file
check(f"no uncaught error after: {R['checks'][-1]['name'] if R['checks'] else 'the start'}", False, traceback.format_exc().splitlines()[-6:])
R["ok"] = all(c["ok"] for c in R["checks"])
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
for c in R["checks"]:
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
sys.exit(0 if R["ok"] else 1)

View file

@ -197,8 +197,8 @@
},
{
"bone": "spine_04",
"before": 0.106817,
"after": 0.074496
"before": 0.107081,
"after": 0.07411
}
],
"shrunkMax": 0.6571,
@ -210,7 +210,7 @@
{
"name": "exportGltf accepted",
"ok": true,
"detail": "Exported glTF to C:\\Users\\Meta\\AppData\\Local\\Temp\\brokkr-rig-live-l9ustbpi\\whale.glb (301188 bytes)."
"detail": "Exported glTF to C:\\Users\\Meta\\AppData\\Local\\Temp\\brokkr-rig-live-qccur36g\\whale.glb (301168 bytes)."
},
{
"name": "VRMC_springBone is in extensions and extensionsUsed",
@ -630,8 +630,8 @@
},
{
"bone": "spine_04",
"before": 0.106817,
"after": 0.074496
"before": 0.107081,
"after": 0.07411
}
],
"shrunkMax": 0.6571,

File diff suppressed because it is too large Load diff

View file

@ -609,6 +609,16 @@ class NodeActionTests(unittest.TestCase):
self.assertIn("setModifierInput", receipt["message"])
self.assertFalse(hasattr(host, "custom"))
def test_custom_property_in_the_kit_namespace_is_refused(self):
self.group()
host = self.bpy.data.objects["Host"]
for name in ("kit_frozen", "customProperties.kit_frozen", "kit_roll", "kit_"):
receipt = self.refused(action="setObjectCustomProperty", targetObjectName="Host", propertyName=name, value=3)
self.assertIn("brokkr_kitbash's own state (kit_*)", receipt["message"])
self.assertFalse(hasattr(host, "custom"))
self.accepted(action="setObjectCustomProperty", targetObjectName="Host", propertyName="kitchen", value=3)
self.assertEqual(host.custom, ("kitchen", 3))
def test_custom_property_sharing_only_a_display_name_is_an_ordinary_property(self):
self.group()
host = self.bpy.data.objects["Host"]

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,471 @@
"""Route tests. No Blender: brokkr_kitbash/route.py against analytic distance fields.
Run: python3 -m unittest discover -s surfaces/blender/tests -v (needs numpy; skipped without it)
The hose action is exercised in a real Blender by tests/live/kitbash_hose.py.
Bounds follow lodur:ruling:deterministic-bound-margin: a deterministic reading is exact here, so each assertion is the
rule itself, and each names the mutant it kills (cut kit-hose's H list).
"""
from __future__ import annotations
import importlib.util
import math
import unittest
from pathlib import Path
SURFACE = Path(__file__).resolve().parents[1]
try:
import numpy as np
except ImportError: # pragma: no cover
np = None
if np is not None:
spec = importlib.util.spec_from_file_location("brokkr_kitbash_route", SURFACE / "brokkr_kitbash" / "route.py")
route = importlib.util.module_from_spec(spec)
spec.loader.exec_module(route)
NEED = 0.04
def wall(hole: float):
"""A wall 0.04 thick across x = 1 with a round hole of radius `hole` about the line y = z = 0.2."""
def distance(points):
points = np.asarray(points, dtype=np.float64)
out = np.maximum(np.abs(points[:, 0] - 1.0) - 0.02, 0.0)
inside = hole - np.hypot(points[:, 1] - 0.2, points[:, 2] - 0.2)
return np.where(inside > 0.0, np.hypot(out, inside), out)
return distance
def ball(centre, radius: float):
return lambda points: np.linalg.norm(np.asarray(points, dtype=np.float64) - np.asarray(centre), axis=1) - radius
def nothing(points):
return np.full(len(points), 10.0)
def room_of(distance, need: float):
return lambda a, b: route.room(a, b, distance, need)
def dense(a, b, spacing: float):
"""This test's own reading of a segment: points no further apart than spacing."""
a, b = np.asarray(a, dtype=np.float64), np.asarray(b, dtype=np.float64)
return a[None] + (b - a)[None] * np.linspace(0.0, 1.0, max(2, math.ceil(float(np.linalg.norm(b - a)) / spacing) + 1))[:, None]
def slab(x: float, half: float):
"""A plate across x, `half` thick each side of it."""
return lambda points: np.maximum(np.abs(np.asarray(points, dtype=np.float64)[:, 0] - x) - half, 0.0)
def length(points) -> float:
return float(np.linalg.norm(np.diff(np.asarray(points), axis=0), axis=1).sum())
@unittest.skipIf(np is None, "numpy is not installed")
class SearchTests(unittest.TestCase):
def test_a_leg_passes_the_hole_and_every_sight_line_keeps_need(self):
"""wavefront-and-pull. Mutant H12 (occupancy at need less a voxel): a kept point stands under need."""
distance = wall(0.12)
a, b = np.array([0.0, 0.0, 0.0]), np.array([2.0, 0.0, 0.0])
pulled, voxels = route.leg(a, b, distance, distance, NEED, 0.02, 0.3, 2 ** 19, "leg 1")
self.assertEqual(voxels, 131 * 31 * 31)
self.assertTrue(np.allclose(pulled[0], a) and np.allclose(pulled[-1], b))
read = np.vstack([dense(p, q, 0.0025) for p, q in zip(pulled[:-1], pulled[1:])])
self.assertGreaterEqual(float(distance(read).min()), NEED - 1e-9)
through = read[np.abs(read[:, 0] - 1.0) < 0.02]
self.assertTrue(len(through) and (np.hypot(through[:, 1] - 0.2, through[:, 2] - 0.2) < 0.12 - NEED + 1e-9).all())
self.assertLess(length(pulled), 2.0 * math.hypot(1.0, 0.2 * math.sqrt(2.0)) + 0.05) # taut: near the two straights through the hole's middle
def test_two_neighbouring_free_voxels_keep_need_between_them(self):
"""The half diagonal a free voxel stands beyond need is what a step between two of them can lose: beside an
edge (a thin rod) every step between neighbouring free voxels keeps need, and without it some do not."""
rod = lambda points: np.hypot(np.asarray(points)[:, 0], np.asarray(points)[:, 1]) # noqa: E731
for reach, holds in ((route.REACH, True), (0.0, False)):
cells = route.grid([-0.1, -0.1, 0.0], [0.1, 0.1, 0.0], 0.02, rod, 0.043 + reach * 0.02)
free = [np.array(m) for m in zip(*np.nonzero(cells.free))]
least = min(float(rod(dense(cells.lo + 0.02 * p, cells.lo + 0.02 * q, 0.001)).min())
for p in free for q in free if 0 < np.abs(p - q).max() <= 1)
self.assertEqual(least >= 0.043, holds, least)
def test_a_measure_proves_what_stands_between_its_readings(self):
"""clearance-kept. Mutants M3 and M3b (verify and pull read at a spacing): a plate 1 mm thick stands between
two readings 0.1 apart, each of which keeps need, and the line through it is refused by measure, by pull and by
verify. The bound is a piece's reading less half its length: with the half length left out the first reading
of the whole segment would prove it."""
plate, a, b = slab(1.0, 0.0005), np.array([0.05, 0.0, 0.0]), np.array([1.85, 0.0, 0.0])
self.assertGreaterEqual(float(plate(dense(a, b, 0.1)).min()), 0.04) # readings 0.1 apart straddle it: the nearest stands 0.0495 off
swept = route.measure(a, b, plate, 0.01)
self.assertTrue(swept.short and swept.least < 0.01 and abs(float(swept.where[0]) - 1.0) < 0.0105, swept)
self.assertFalse(route.clear(a, b, plate, 0.01))
self.assertTrue(route.clear(a, [0.98, 0.0, 0.0], plate, 0.01))
over = np.array([a, [1.0, 0.0, 5.0], b]) # the plate ends nowhere: a pulled line keeps the point that leads round nothing, and is not shortened through it
self.assertEqual(len(route.pull(over, lambda points: np.where(np.asarray(points)[:, 2] > 4.0, 10.0, plate(points)), 0.01)), 3)
with self.assertRaisesRegex(route.RouteError, r"^the hose stands 0\.00\d+ m from an obstacle at \[(1|0\.99\d*|1\.00\d*), 0, 0\], under the 0\.01 m the bundle needs"):
route.verify(np.array([a, b]), plate, 0.01, 0.0)
ground = lambda points: np.asarray(points, dtype=np.float64)[:, 2] # noqa: E731
along_ = lambda z: (np.array([0.0, 0.0, z]), np.array([1.0, 0.0, z])) # noqa: E731
self.assertFalse(route.measure(*along_(0.01 + route.FINE), ground, 0.01).short) # a line that keeps need by FINE is proven
grazing = route.measure(*along_(0.01 + route.FINE / 4.0), ground, 0.01) # one that keeps it by less than half of FINE is not, and is refused as that
self.assertTrue(grazing.short and grazing.least >= 0.01)
self.assertIn("too near the 0.01 m the bundle needs to prove it", route.falls(grazing.least, 0.01))
slope = lambda points: 0.3 + np.abs(np.asarray(points, dtype=np.float64)[:, 0] - 0.7137) # noqa: E731
self.assertLess(route.measure([0.0, 0, 0], [1.0, 0, 0], slope, 0.01).least - 0.3, 0.3) # proven at need by a few readings
self.assertLess(route.measure([0.0, 0, 0], [1.0, 0, 0], slope, 0.01, within=route.FINE).least - 0.3, route.FINE) # the least itself, within the bound asked
self.assertTrue(np.allclose(route.span(np.array([[0.0, 0, 0], [1.0, 0, 0], [1.0, 1.0, 0]]), 0.5, 1.5), [[0.5, 0, 0], [1.0, 0, 0], [1.0, 0.5, 0]]))
self.assertEqual(len(route.span(np.array([[0.0, 0, 0], [1.0, 0, 0]]), 0.6, 0.4)), 0)
def test_a_leg_searched_with_room_keeps_it_where_it_wraps(self):
"""A line pulled at need grazes what it wraps, and the corner there has no room for an arc: with pad the
pulled line keeps need and pad of every point further than twice pad from its ends, and a corner's room is
the pad instead of what the pull happened to leave."""
distance, pad = ball([1.0, 0.0, 0.0], 0.3), 0.03
a, b = np.array([0.0, 0.0, 0.0]), np.array([2.0, 0.0, 0.0])
tight = route.leg(a, b, distance, distance, NEED, 0.02, 0.3, 2 ** 19, "leg 1")[0]
roomy = route.leg(a, b, distance, distance, NEED, 0.02, 0.3, 2 ** 19, "leg 1", pad)[0]
least = lambda line: float(distance(np.vstack([dense(p, q, 0.002) for p, q in zip(line[:-1], line[1:])])).min()) # noqa: E731
self.assertLess(least(tight), NEED + 0.2 * pad)
self.assertGreaterEqual(least(tight), NEED)
self.assertGreaterEqual(least(roomy), NEED + pad)
self.assertGreater(length(roomy), length(tight))
near = np.array([0.66, 0.0, 0.0]) # an end that stands need from the ball has no voxel with that room beside it: the caller searches such a leg without
with self.assertRaisesRegex(route.RouteError, r"^leg 1: no free voxel stands in sight of its start \[0\.66, 0, 0\]: an obstacle is nearer it than 0\.08732 m on every side"):
route.leg(near, [0.0, 0.0, 0.0], distance, distance, NEED, 0.02, 0.3, 2 ** 19, "leg 1", pad)
self.assertEqual(len(route.leg(near, [0.0, 0.0, 0.0], distance, distance, NEED, 0.02, 0.3, 2 ** 19, "leg 1")[0]), 2)
def test_a_closed_way_a_buried_end_and_a_box_too_fine_are_refused_by_name(self):
distance = wall(0.03) # a hole narrower than the bundle
ends = (np.array([0.0, 0.0, 0.0]), np.array([2.0, 0.0, 0.0]))
with self.assertRaisesRegex(route.RouteError, r"^leg 2: no free way joins its ends"):
route.leg(*ends, distance, distance, NEED, 0.02, 0.3, 2 ** 19, "leg 2")
with self.assertRaisesRegex(route.RouteError, r"^leg 3: its end \[1, 0, 0\] stands 0 m from an obstacle, under the 0\.04 m"):
route.leg(ends[0], np.array([1.0, 0.0, 0.0]), distance, distance, NEED, 0.02, 0.3, 2 ** 19, "leg 3")
with self.assertRaisesRegex(route.RouteError, r"^leg 4: its search box of \[2\.6, 0\.6, 0\.6\] m is \d+ voxels at step 0\.005, over 524288: a step of 0\.0\d+ fits"):
route.leg(*ends, distance, distance, NEED, 0.005, 0.3, 2 ** 19, "leg 4")
try:
route.leg(*ends, distance, distance, NEED, 0.005, 0.3, 2 ** 19, "leg 4")
except route.RouteError as error:
fits = float(str(error).split("a step of ")[1].split(" ")[0])
self.assertLessEqual(int(np.prod(np.ceil(np.array([2.6, 0.6, 0.6]) / fits - 1e-9) + 1)), 2 ** 19)
with self.assertRaisesRegex(route.RouteError, "its start voxel is not free"):
route.wavefront(np.zeros((2, 2, 2), dtype=bool), (0, 0, 0), (1, 1, 1))
def test_a_wavefront_way_is_a_shortest_one(self):
free = np.ones((9, 9, 1), dtype=bool)
free[4, 1:, 0] = False # a wall with a gap at j = 0
way = route.wavefront(free, (0, 8, 0), (8, 8, 0))
self.assertEqual((way[0], way[-1], len(way)), ((0, 8, 0), (8, 8, 0), 17))
self.assertIn((4, 0, 0), way)
self.assertTrue(all(max(abs(p[i] - q[i]) for i in range(3)) == 1 for p, q in zip(way[:-1], way[1:])))
@unittest.skipIf(np is None, "numpy is not installed")
class FilletTests(unittest.TestCase):
ZIGZAG = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 0.3, 0.0], [2.0, 0.3, 0.4], [2.0, 1.5, 0.4]])
def test_every_arc_is_tangent_and_two_corners_share_a_segment(self):
"""fillet-rule. Mutant H2 (arcs not tangent): the first chord of an arc leaves its segment at more than half a
step of the arc. Two corners on the 0.3 segment shrink until their tangents share it."""
made = route.fillet(self.ZIGZAG, None, 0.01, 0.2)
lengths, unit, turn = route._turns(self.ZIGZAG)
self.assertTrue((made.t[:-1] + made.t[1:] <= lengths[1:-1] + 1e-12).all())
self.assertAlmostEqual(float(made.t[0] + made.t[1]), 0.3, places=12)
self.assertAlmostEqual(float(made.t[0] / made.t[1]), min(0.8, 0.3) / min(0.3, float(lengths[2])), places=12) # in proportion to what each had alone
for c in range(3):
arc = made.curve[made.owner == c]
steps = max(2, math.ceil(turn[c] * route.ARC))
self.assertEqual(len(arc), steps + (c != 1)) # arcs 0 and 1 meet on the shared segment: the point where they meet is listed once, as arc 0's
for chord, tangent in ((arc[1] - arc[0], unit[c]), (arc[-1] - arc[-2], unit[c + 1]))[c == 1:]:
self.assertAlmostEqual(math.acos(min(1.0, float(chord @ tangent) / float(np.linalg.norm(chord)))), turn[c] / steps / 2.0, places=9)
self.assertAlmostEqual(float(np.linalg.norm(arc[-1] - self.ZIGZAG[c + 1])), float(made.t[c]), places=12)
self.assertAlmostEqual(float(made.radii[c]), float(made.t[c] / math.tan(turn[c] / 2.0)), places=12)
def test_the_leads_stay_straight(self):
"""Mutant H1 (lead ignored): the first corner's tangent takes the whole first segment and the bend starts at
the ferrule."""
made = route.fillet(np.array([[0.0, 0.0, 0.0], [0.3, 0.0, 0.0], [0.3, 2.0, 0.0], [0.3, 2.0, 0.5]]), None, 0.01, 0.2)
self.assertAlmostEqual(float(made.t[0]), 0.1, places=12)
self.assertAlmostEqual(float(made.t[1]), 0.3, places=12)
self.assertAlmostEqual(float(np.linalg.norm(made.curve[1] - made.curve[0])), 0.2, places=12)
self.assertAlmostEqual(float(np.linalg.norm(made.curve[-1] - made.curve[-2])), 0.2, places=12)
def test_a_kept_straight_stays_in_the_middle_of_a_centred_segment(self):
points = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 0.5, 0.0], [3.0, 0.5, 1.0]])
made = route.fillet(points, None, 0.01, 0.0, keep=[0.0, 0.1, 0.0], centred=[False, True, False])
self.assertAlmostEqual(float(made.t[0]), 0.2, places=12)
self.assertAlmostEqual(float(made.t[1]), 0.2, places=12)
def test_a_corner_that_wraps_an_obstacle_gets_the_radius_its_room_allows(self):
"""Mutant H3 (the room cap off: radius by segments only): the arc cuts through the ball."""
distance = ball([-0.25, 0.25, 0.0], 0.17)
points = np.array([[-1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0]])
room = room_of(distance, 0.05)
made = route.fillet(points, room, 0.05, 0.0)
radius, t = float(made.radii[0]), float(made.t[0])
depth = 1.0 - math.cos(math.pi / 4.0)
measured = min(room(points[1] - np.array([1.0, 0.0, 0.0]) * t, points[1]), room(points[1], points[1] + np.array([0.0, 1.0, 0.0]) * t))
self.assertLessEqual(radius * depth, measured + 1e-12)
self.assertGreater(radius, 0.03 / depth) # more than the room at the segments' nearest points allows: the room is measured along the tangent segments only
self.assertLess(radius, 0.25)
arc = made.curve[made.owner == 0]
self.assertGreaterEqual(float(distance(np.vstack([dense(p, q, 0.001) for p, q in zip(arc[:-1], arc[1:])])).min()), 0.05)
grown = route.arcs(points, np.array([t * 1.05]))[0] # the largest: 5 percent more breaks the rule
t2 = t * 1.05
self.assertGreater(t2 / math.tan(math.pi / 4.0) * depth, min(room(points[1] - np.array([1.0, 0.0, 0.0]) * t2, points[1]), room(points[1], points[1] + np.array([0.0, 1.0, 0.0]) * t2)))
self.assertEqual(len(grown), len(made.curve))
free = route.fillet(points, None, 0.05, 0.0)
self.assertAlmostEqual(float(free.radii[0]), 1.0, places=12)
self.assertLess(float(distance(free.curve).min()), 0.0)
self.assertGreaterEqual(route.verify(made.curve, distance, 0.05, 0.0), 0.05)
with self.assertRaisesRegex(route.RouteError, r"^the hose stands -0\.\d+ m from an obstacle at \[-0\.\d+, 0\.\d+, 0\], under the 0\.05 m"):
route.verify(free.curve, distance, 0.05, 0.0)
def test_a_corner_under_the_floor_is_refused_by_name(self):
with self.assertRaisesRegex(route.RouteError, r"^corner 1 at \[1, 0, 0\] turns 90\.0 degrees and gets a bend of radius 0\.15 m, under the floor 0\.5: "
r"the corner's segments leave 0\.3 m of straight for the 0\.5 m its tangent takes at the floor"):
route.fillet(self.ZIGZAG, None, 0.5, 0.2)
with self.assertRaisesRegex(route.RouteError, r"^corner 1 at \[0, 0, 0\] turns 90\.0 degrees and gets a bend of radius 0(\.00\d+)? m, under the floor 0\.05: the route passes too near an obstacle to bend here: "
r"its segments stand 0(\.00\d+)? m clear beyond what the bundle needs and the arc at the floor takes 0\.01464 "):
route.fillet(np.array([[-1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0]]), room_of(ball([-0.05, 0.05, 0.0], 0.02), 0.05), 0.05, 0.0) # a ball in the corner
def test_a_corner_keeps_its_floor_s_tangent_before_its_neighbour_gets_more(self):
"""bend-room-searched. Two corners on a 0.5 segment ask 0.5 and 0.25 of it and need 0.22 each at the floor:
each keeps its need and the 0.06 left is shared by what each asked beyond it. Mutant T1 (shared in proportion
to what each asked, floor = 0 in tangents): the second corner gets 0.167 and the polyline is refused."""
points = np.array([[0.0, 0.0, 0.0], [3.0, 0.0, 0.0], [3.0, 0.5, 0.0], [3.25, 0.5, 0.0]])
made = route.fillet(points, None, 0.22, 0.0)
self.assertAlmostEqual(float(made.t.sum()), 0.5, places=12)
self.assertAlmostEqual(float((made.t[0] - 0.22) / (made.t[1] - 0.22)), 0.28 / 0.03, places=9)
self.assertAlmostEqual(float(route.tangents(points, None, 0.0)[1]), 0.5 / 3.0, places=12) # the share a corner got before its need counted
self.assertEqual(float(route.strain(points, 0.22, 0.0).sum()), 0.0)
self.assertAlmostEqual(float(route.strain(points, 0.3, 0.0)[1]), 0.1, places=12)
self.assertAlmostEqual(float(route.strain(points, 0.3, 0.0, keep=[0.0, 0.1, 0.0], centred=[False, True, False])[1]), 0.2, places=12)
held = route.fillet(points, None, 0.1, 0.0, least=[0.4, 0.0]) # a corner that will turn further holds the tangent that takes
self.assertAlmostEqual(float(held.t[0]), 0.4, places=12)
self.assertAlmostEqual(float(held.t[1]), 0.1, places=12)
def test_a_seed_without_the_straight_for_its_bends_is_refined_where_the_oracle_allows(self):
"""bend-room-searched. A seed's vertex stands 0.18 from a held corner and their two tangents at the floor take
0.25; a ball closes the straight way past it. relax moves the vertex until every segment has its straight,
each moved segment proven clear. Mutant X1 (relax returns its seed): strain stays and fillet refuses."""
distance, need, floor = ball([1.0, 0.7, 0.0], 0.05), 0.05, 0.3
seed, tags = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.15, 0.1, 0.0], [1.15, 1.5, 0.0]]), ["P", "E", None, "P"]
self.assertFalse(route.clear(seed[1], seed[3], distance, need))
self.assertGreater(float(route.strain(seed, floor, 0.0).sum()), 0.05)
with self.assertRaisesRegex(route.RouteError, "under the floor 0.3: it shares a segment with the corner beside it"):
route.fillet(seed, room_of(distance, need), floor, 0.0)
tried = []
def sure(a, b):
tried.append((a, b))
return route.clear(a, b, distance, need)
points, kept = route.relax(seed, tags, lambda p, g: route.strain(p, floor, 0.0), sure, floor)
self.assertTrue(tried)
self.assertEqual(float(route.strain(points, floor, 0.0).sum()), 0.0)
self.assertEqual([tag for tag in kept if tag is not None], ["P", "E", "P"])
for index in (0, 1, -1):
self.assertTrue((points[index] == seed[index]).all())
self.assertGreaterEqual(float(distance(np.vstack([dense(p, q, 0.001) for p, q in zip(points[:-1], points[1:])])).min()), need)
made = route.fillet(points, room_of(distance, need), floor, 0.0)
self.assertGreaterEqual(float(made.radii.min()), floor * (1 - 1e-9))
open_points, open_tags = route.relax(seed, tags, lambda p, g: route.strain(p, floor, 0.0), lambda a, b: True, floor)
self.assertEqual(open_tags, ["P", "E", "P"]) # with nothing in the way the vertex is dropped
same, _ = route.relax(seed, tags, lambda p, g: route.strain(p, floor, 0.0), lambda a, b: False, floor)
self.assertTrue((same == seed).all()) # nothing the oracle does not prove is kept
def test_too_stiff_is_proven_of_a_pocket_and_of_nothing_else(self):
"""bend-room-searched. A wall 0.08 ahead of a point a hose leaves along x: no curve of radius 0.2 turns
aside in the 0.06 its centre line has, and one of radius 0.04 does. Mutant S1 (the balls a curve cannot
enter left out of leaves): the stiff bundle is said to leave."""
wall = lambda at: (lambda p: at - np.asarray(p)[:, 0]) # noqa: E731
origin, ahead = np.zeros(3), np.array([1.0, 0.0, 0.0])
self.assertFalse(route.leaves(origin, ahead, 0.2, wall(0.08), 0.02))
self.assertTrue(route.leaves(origin, ahead, 0.04, wall(0.08), 0.02))
self.assertTrue(route.leaves(origin, ahead, 0.2, wall(0.5), 0.02))
slit = lambda p: np.where(np.abs(np.asarray(p)[:, 1]) < 0.03, 1.0, wall(0.08)(p)) # noqa: E731 the wall, open along a slit 0.06 wide straight ahead
self.assertTrue(route.leaves(origin, ahead, 0.2, slit, 0.02))
def test_the_sharpest_turn_of_a_range_is_exact(self):
"""range-measured-unposed. The turn at a pin over a range of rolls, against the turn at 4001 rolls of it."""
rng = np.random.default_rng(7)
for low, high in ((-20.0, 20.0), (-170.0, 5.0), (30.0, 31.0), (-360.0, 360.0), (4.0, 4.0)):
before, after, axis = (v / np.linalg.norm(v) for v in rng.normal(size=(3, 3)))
turns = [math.acos(max(-1.0, min(1.0, float(before @ route.turned(after[None], np.zeros(3), axis, float(roll))[0])))) for roll in np.linspace(low, high, 4001)]
found = route.sharpest_turn(before, after, axis, low, high)
self.assertGreaterEqual(found, max(turns) - 1e-12)
self.assertLess(found - max(turns), 1e-5)
def test_the_floor_is_the_innermost_hose_s(self):
"""Mutant H8 (the floor taken at the centre line): the innermost of three hoses bends tighter than bend
outside diameters."""
sizes = route.bundle(3, 0.014, 0.0, 0.01, 4.0)
self.assertAlmostEqual(sizes["spread"], 0.0364, places=12)
self.assertAlmostEqual(sizes["floor"] - sizes["spread"], 4.0 * 0.028, places=12)
self.assertAlmostEqual(sizes["need"], 0.0364 + 0.014 + 0.01, places=12)
self.assertAlmostEqual(sizes["width"], 2 * 0.0364 + 0.028, places=12)
self.assertAlmostEqual(sizes["lead"], 5 * 0.014 + 1.5 * 0.028, places=12)
self.assertEqual(route.bundle(1, 0.01, 0.0, 0.0, 4.0)["floor"], 0.08)
def test_a_span_sags_by_no_more_than_half_its_room(self):
"""ruling hose-slack-and-skinned. Mutant S1 (the sag not bounded by the room): the span hangs into the floor
under it."""
ground = lambda points: np.asarray(points, dtype=np.float64)[:, 2] # noqa: E731
span = np.array([[0.0, 0.0, 0.1], [1.0, 0.0, 0.1]])
hung, drop = route.sag(span, 0.1, room_of(ground, 0.05))
self.assertAlmostEqual(drop, 0.025 - 0.75 * route.FINE, places=12) # half the room: what the span stands beyond need, less what a measure cannot tell apart
self.assertTrue(np.allclose(hung[1], [0.5, 0.0, 0.1 - drop]))
made = route.fillet(np.vstack([[[0.0, 0.0, 0.5]], hung, [[1.0, 0.0, 0.5]]]), room_of(ground, 0.05), 0.01, 0.1)
self.assertGreaterEqual(route.verify(made.curve, ground, 0.05, 0.1), 0.05)
self.assertGreater(float(made.radii[1]), 1.0) # a gentle arc, not a kink
high, drop = route.sag(span + [0.0, 0.0, 1.0], 0.1, room_of(ground, 0.05))
self.assertEqual((drop, len(high)), (0.1, 3))
self.assertEqual(route.sag(np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]), 0.1, None)[1], 0.0) # a vertical span does not sag
self.assertEqual(route.sag(span, 0.0, None)[1], 0.0)
leaning, drop = route.sag(np.array([[0.0, 0.0, 1.0], [1.0, 0.0, 2.0]]), 0.1, None) # across the span, by how far it runs from vertical
self.assertAlmostEqual(drop, 0.1 * math.sqrt(0.5), places=12)
self.assertAlmostEqual(float((leaning[1] - [0.5, 0.0, 1.5]) @ [1.0, 0.0, 1.0]), 0.0, places=12)
self.assertEqual(route.sag(np.array([[0.0, 0.0, 1.0], [0.5, 0.0, 1.0]]), 0.1, None)[1], 0.0) # too short for the drop
@unittest.skipIf(np is None, "numpy is not installed")
class FrameTests(unittest.TestCase):
@staticmethod
def reference(curve, tangent, up):
"""The double reflection method as Wang et al. 2008 state it, a point at a time."""
ups = [up]
for i in range(len(curve) - 1):
v1 = [curve[i + 1][k] - curve[i][k] for k in range(3)]
c1 = sum(v * v for v in v1)
dot = lambda a, b: sum(x * y for x, y in zip(a, b)) # noqa: E731
r_left = [ups[-1][k] - 2.0 / c1 * dot(v1, ups[-1]) * v1[k] for k in range(3)]
t_left = [tangent[i][k] - 2.0 / c1 * dot(v1, tangent[i]) * v1[k] for k in range(3)]
v2 = [tangent[i + 1][k] - t_left[k] for k in range(3)]
c2 = dot(v2, v2)
ups.append([r_left[k] - 2.0 / c2 * dot(v2, r_left) * v2[k] for k in range(3)])
return np.array(ups)
@staticmethod
def tangents(curve):
steps = np.diff(curve, axis=0)
steps /= np.linalg.norm(steps, axis=1)[:, None]
tangent = np.vstack([steps[:1], steps[:-1] + steps[1:], steps[-1:]])
return tangent / np.linalg.norm(tangent, axis=1)[:, None]
def test_ups_are_rotation_minimising(self):
"""frames-rmf. Mutant H7 (Frenet frames for ups): on a planar S the up leaves the plane's normal."""
s = np.linspace(0.0, 2.0 * math.pi, 200)
planar = np.stack([s, np.sin(s), np.zeros_like(s)], axis=1)
ups = route.frames(planar, [0.0, 0.0, 1.0])
self.assertLess(float(np.abs(ups - [0.0, 0.0, 1.0]).max()), 1e-12)
helix = np.stack([np.cos(s * 2.0), np.sin(s * 2.0), 0.3 * s], axis=1)
ups, tangent = route.frames(helix, [0.0, 0.0, 1.0]), self.tangents(helix)
self.assertLess(float(np.abs(np.einsum("ij,ij->i", ups, tangent)).max()), 1e-12)
self.assertLess(float(np.abs(np.linalg.norm(ups, axis=1) - 1.0).max()), 1e-12)
first = np.array([0.0, 0.0, 1.0]) - tangent[0] * tangent[0][2]
self.assertLess(float(np.abs(ups - self.reference(helix.tolist(), tangent.tolist(), (first / np.linalg.norm(first)).tolist())).max()), 1e-9)
with self.assertRaisesRegex(route.RouteError, "runs along the curve's first tangent"):
route.frames(planar, planar[1] - planar[0])
def test_a_short_straight_between_two_arcs_is_dropped(self):
curve = np.array([[0.0, 0, 0], [1.0, 0, 0], [1.0 + 1e-6, 0, 0], [2.0, 1, 0], [2.0, 1 + 1e-6, 0]])
self.assertEqual(route.thinned(curve, 1e-3).tolist(), curve[[0, 1, 4]].tolist()) # the ends stay, the last in place of a point beside it
self.assertEqual(route.thinned(curve, 1e-9).tolist(), curve.tolist())
self.assertEqual(route.thinned(curve[:2], 10.0).tolist(), curve[:2].tolist())
@unittest.skipIf(np is None, "numpy is not installed")
class JointTests(unittest.TestCase):
P = np.array([[0.5, 0.0, 1.0], [0.2, 0.0, 0.0], [0.5, 0.0, -1.0]]) # through a point on the x axis
AXIS = (np.zeros(3), np.array([1.0, 0.0, 0.0]))
SIZES = {"need": 0.05, "floor": 0.05, "lead": 0.1}
FINEST = 0.3
def test_a_polyline_through_the_axis_keeps_its_length_at_every_roll(self):
"""joint-passage."""
rolls = route.rolls_of(-120.0, 10.0, 5.0)
self.assertEqual((len(rolls), rolls[0], rolls[-2], rolls[-1]), (27, -120.0, 5.0, 10.0))
self.assertEqual(route.rolls_of(0.0, 12.0, 5.0), [0.0, 5.0, 10.0, 12.0])
for roll in rolls:
posed = np.vstack([self.P[:2], route.turned(self.P[2:], *self.AXIS, roll)])
self.assertAlmostEqual(length(posed), length(self.P), places=12)
self.assertTrue(np.allclose(route.turned(np.array([[0.3, 1.0, 0.0]]), *self.AXIS, 90.0), [[0.3, 0.0, 1.0]])) # right-handed about +x
t = route.fillet(self.P, None, 0.05, 0.1).t
found = route.passes(self.P, t, 1, *self.AXIS, rolls, self.FINEST, 0.0, nothing, nothing, **self.SIZES)
self.assertEqual(found["rolls"], 27)
self.assertTrue(10.0 - 1.2 * math.radians(2.5) < found["least"] < 10.0, found) # a reading counts for less by what its point moves in half a step of the rolls
hung = np.vstack([route.sag(self.P[:2], 0.05, None)[0], route.sag(self.P[1:], 0.05, None)[0][1:]]) # sag-with-joint: each side hangs, and the pin point is still the one turned about
self.assertEqual(len(hung), 5)
sagged = route.passes(hung, route.fillet(hung, None, 0.05, 0.1).t, 2, *self.AXIS, rolls, self.FINEST, 0.0, nothing, nothing, **self.SIZES)
self.assertEqual(sagged["rolls"], 27)
self.assertLess(sagged["lengthChange"], found["lengthChange"]) # the hanging spans turn with their sides: only the bend at the pin changes, and its segments are shorter
with self.assertRaisesRegex(route.RouteError, r"^point 1 \[\S+, 0, \S+\] of the hose stands 0\.\d+ m off the pin's axis"):
route.passes(hung, route.fillet(hung, None, 0.05, 0.1).t, 1, *self.AXIS, rolls, self.FINEST, 0.0, nothing, nothing, **self.SIZES)
self.assertGreater(found["lengthChange"], 0.01) # the bend at the pin is what changes: each roll's is the largest arc its segments give
self.assertLess(found["lengthChange"], length(self.P) * (1.0 - math.pi / 4.0) * 2.0) # no more than every corner's shortcut
def test_a_hairpin_roll_is_refused_by_name(self):
t = route.fillet(self.P, None, 0.05, 0.1).t
with self.assertRaisesRegex(route.RouteError, r"^roll 1[67]\d(\.\d+)?: the bend at the pin turns up to 1\d\d\.\d degrees and its segments leave room for a radius of \S+ m, under the floor 0\.05 "
r"through the 0\.\d+ degrees either side of it$"):
route.passes(self.P, t, 1, *self.AXIS, [0.0, 90.0, 180.0], self.FINEST, 0.0, nothing, nothing, **self.SIZES)
def test_each_side_is_measured_against_the_other_where_the_roll_puts_it(self):
"""Mutants H5 (the child's obstacles not turned with the roll) and H6 (the range checked at its ends only): a
part of the child that the roll carries into the parent's side of the hose, between the ends of the range."""
middle = (self.P[0] + self.P[1]) / 2.0
child = ball(route.turned(middle[None], *self.AXIS, -45.0)[0], 0.05) # where it stands at roll 0
t = route.fillet(self.P, None, 0.05, 0.1).t
self.assertEqual(route.passes(self.P, t, 1, *self.AXIS, [0.0], self.FINEST, 0.0, nothing, child, **self.SIZES)["rolls"], 1)
for rolls in ([-90.0, 90.0], route.rolls_of(-90.0, 90.0, 5.0)): # the rolls given are where measuring starts, not all that is measured: the two ends find it as the 5 degree steps do
with self.assertRaisesRegex(route.RouteError, r"^roll 3[34](\.\d+)?: the hose's parent's side reads 0\.0\d+ m from the parts about the pin at \[\S+, \S+, \S+\], counting the 0\.00\d+ m it can move "
r"against the other side's through the 0\.\d+ degrees either side of it: "):
route.passes(self.P, t, 1, *self.AXIS, rolls, self.FINEST, 0.0, nothing, child, **self.SIZES)
seen = []
route.passes(self.P, t, 1, *self.AXIS, [30.0], self.FINEST, 10.0, nothing, lambda points: seen.append(np.array(points)) or nothing(points), **self.SIZES)
line = (self.P[1] - self.P[0]) / np.linalg.norm(self.P[1] - self.P[0])
on = [points for points in seen if np.abs(np.cross(route.turned(points, *self.AXIS, 20.0) - self.P[0], line)).max() < 1e-12]
self.assertTrue(on) # the parent's side was read turned back by roll - current: turned forward again it lies on its own segment
self.assertTrue(any(np.linalg.norm(np.cross(points - self.P[0], line), axis=1).min() > 0.01 for points in on)) # and as read it lay off it
parent = ball(route.turned(((self.P[1] + self.P[2]) / 2.0)[None], *self.AXIS, 45.0)[0], 0.05) # a part of the parent the child's side swings into
with self.assertRaisesRegex(route.RouteError, r"^roll 3[34](\.\d+)?: the hose's child's side reads"):
route.passes(self.P, t, 1, *self.AXIS, route.rolls_of(-90.0, 90.0, 5.0), self.FINEST, 0.0, parent, nothing, **self.SIZES)
def test_the_bend_at_the_pin_is_no_larger_than_its_room(self):
"""A ball inside the bend at the pin that both of the corner's segments clear: the arc there takes the radius
whose dip the segments' room allows, not the largest its segments give. Mutant R3 (the bend's tangent segments
measured for need alone) rounds the corner under need of the ball."""
inside = ball([0.28, 0.0, 0.0], 0.01)
t = route.fillet(self.P, None, 0.05, 0.1).t
self.assertGreater(float(inside(np.vstack([dense(self.P[0], self.P[1], 0.001), dense(self.P[1], self.P[2], 0.001)])).min()), 0.06)
free = route.passes(self.P, t, 1, *self.AXIS, [0.0], self.FINEST, 0.0, nothing, nothing, **self.SIZES)["radius"]
found = route.passes(self.P, t, 1, *self.AXIS, [0.0], self.FINEST, 0.0, inside, nothing, **self.SIZES)["radius"]
self.assertGreater(free, 2.0)
self.assertTrue(0.05 <= found < 0.5, found)
turn = float(route._turns(self.P)[2][0])
arc = route.arcs(self.P, np.array([found * math.tan(turn / 2.0)]))[0]
self.assertGreaterEqual(float(inside(np.vstack([dense(p, q, 0.001) for p, q in zip(arc[:-1], arc[1:])])).min()), 0.05)
self.assertLess(float(inside(route.arcs(self.P, np.array([free * math.tan(turn / 2.0)]))[0]).min()), 0.05) # the largest arc its segments give stands under need of the ball
def test_a_plate_between_two_rolls_is_found(self):
"""range-sampled-not-swept. A part of the child 2 mm across that crosses the parent's side of the hose at roll
17.5, half way between two rolls 5 degrees apart: at 15 and at 20 the hose reads 0.02 from it and keeps its
need of 0.01, and the range is refused at a roll between them. Mutant R1 (a reading not lessened by what its
point moves within its bin) accepts the range."""
middle = (self.P[0] + self.P[1]) / 2.0
child = ball(route.turned(middle[None], *self.AXIS, -17.5)[0], 0.001)
t, sizes = route.fillet(self.P, None, 0.05, 0.1).t, {**self.SIZES, "need": 0.01}
for roll in (15.0, 20.0):
self.assertGreater(float(child(route.turned(dense(self.P[0], self.P[1], 0.0005), *self.AXIS, -roll)).min()), 0.02)
self.assertEqual(route.passes(self.P, t, 1, *self.AXIS, [15.0], self.FINEST, 0.0, nothing, child, **sizes)["rolls"], 1) # one roll answers for itself alone
with self.assertRaisesRegex(route.RouteError, r"^roll 1[5-9]\.\d+: the hose's parent's side reads"):
route.passes(self.P, t, 1, *self.AXIS, route.rolls_of(-20.0, 20.0, 5.0), self.FINEST, 0.0, nothing, child, **sizes)
clear_of = route.passes(self.P, t, 1, *self.AXIS, route.rolls_of(-20.0, 10.0, 5.0), self.FINEST, 0.0, nothing, child, **sizes)
self.assertGreaterEqual(clear_of["rolls"], 7) # short of the plate the same range passes, with more rolls measured where the 5 degree bins fell short
if __name__ == "__main__":
unittest.main()

View file

@ -67,6 +67,15 @@ def fake_render():
return FakeRender()
class Extras(dict):
"""An ID with custom properties: a mapping, and the attributes it is given."""
def __init__(self, properties=(), **attributes):
super().__init__(properties)
self.__dict__.update(attributes)
__hash__ = object.__hash__
class Objects(dict):
"""bpy.data.objects: a mapping with keys() and get(); like bpy_prop_collection, iterating it yields the objects."""
@ -89,7 +98,7 @@ class FakeUndo:
class FakeBpy:
def __init__(self):
self.imported = []
self.imported, self.import_extras, self.import_mesh_extras = [], {}, {}
self.rendered = []
self.scene = NS(name="Scene", camera=None, world=None, render=fake_render())
self.camera_data = NS(lens=50.0, type="PERSP", ortho_scale=6.0, clip_start=0.1, clip_end=100.0,
@ -114,6 +123,7 @@ class FakeBpy:
for o in self.data.objects.values():
o.selected = o is self.mesh
o.select_get = (lambda o=o: o.selected)
o.modifiers, o.get = [], (lambda key, default=None: default) # no modifier, no custom property
o.select_set = (lambda state, o=o: setattr(o, "selected", state))
add = lambda kind: (lambda mode, undo, **kw: self.add_object(kind, kw, (mode, undo)))
self.ops = NS(import_scene=NS(gltf=self.import_gltf), render=NS(render=self.render_still),
@ -140,7 +150,7 @@ class FakeBpy:
def import_gltf(self, mode, undo, filepath):
assert (mode, undo) == ("EXEC_DEFAULT", False)
self.imported.append(filepath)
self.data.objects["Imported"] = NS(name="Imported", type="MESH", data=None)
self.data.objects["Imported"] = Extras(self.import_extras, name="Imported", type="MESH", data=Extras(self.import_mesh_extras))
def export_gltf(self, mode, undo, **kwargs):
assert (mode, undo) == ("EXEC_DEFAULT", False)
@ -192,6 +202,18 @@ class ActionTests(unittest.TestCase):
self.assertEqual(receipt["status"], "accepted")
self.assertEqual(self.bpy.imported, [str(self.root / "in" / "model.glb")])
self.assertEqual(receipt["objectName"], "Imported")
self.assertEqual(receipt["message"], "Imported 1 object(s) from model.glb.")
def test_import_drops_the_kit_properties_a_file_carries(self):
"""kit_* is brokkr_kitbash's own state: what setObjectCustomProperty refuses, importGltf does not bring in from extras."""
self.bpy.import_extras = {"kit_frozen": None, "kit_part": "tank", "kit_params": "{}", "note": "kept", "kitchen": 1}
self.bpy.import_mesh_extras = {"kit_kept": True, "source": "scan"}
receipt = self.run_action(action="importGltf", filepath="model.glb")
imported = self.bpy.data.objects["Imported"]
self.assertEqual((receipt["status"], dict(imported), dict(imported.data)), ("accepted", {"note": "kept", "kitchen": 1}, {"source": "scan"}))
self.assertIn("Dropped the file's kit_* properties from Imported", receipt["message"])
self.assertEqual(bt.kit_owned("kit_frozen") and bt.kit_owned("kit_anything"), True)
self.assertEqual(bt.kit_owned("kitchen") or bt.kit_owned("akit_x"), False)
def test_import_outside_the_import_dir_is_refused_before_bpy(self):
for path in ("../secret.glb", str(self.root / "secret.glb"), "/etc/passwd.glb", "sub/../../secret.glb"):
@ -291,6 +313,24 @@ class ActionTests(unittest.TestCase):
self.assertEqual(call["selected_at_call"], ["Cam", "Lamp"])
self.assertEqual([o.name for o in self.bpy.data.objects.values() if o.selected], ["Cube"])
def test_export_applying_modifiers_refuses_a_frozen_object_with_a_modifier_shown(self):
mesh = self.bpy.data.objects["Cube"]
mesh.get = lambda key, default=None: "live mesh" if key == "kit_frozen" else default
mesh.modifiers = [NS(show_viewport=False, show_render=False), NS(show_viewport=True, show_render=False)]
for fields in ({}, {"selection": ["Cube"]}):
receipt = self.run_action(action="exportGltf", filepath="dirty.glb", **fields)
self.assertEqual(receipt["status"], "failed", receipt)
self.assertIn("Cube: frozen (brokkr_kitbash.freeze) with a modifier shown again", receipt["message"])
self.assertEqual((self.bpy.exported, list((self.root / "out").iterdir())), ([], []))
for fields in ({"applyModifiers": False}, {"selection": ["Cam"]}): # nothing applied, or the object not exported
receipt = self.run_action(action="exportGltf", filepath=f"ok{len(self.bpy.exported)}.glb", **fields)
self.assertEqual(receipt["status"], "accepted", receipt)
mesh.modifiers[1].show_viewport = False
mesh.modifiers[0].show_render = True # shown in renders only: dirty by the rule brokkr_kitbash's report uses
self.assertIn("with a modifier shown again", self.run_action(action="exportGltf", filepath="render.glb")["message"])
mesh.modifiers[0].show_render = False
self.assertEqual(self.run_action(action="exportGltf", filepath="frozen.glb")["status"], "accepted")
def test_export_without_a_selection_never_touches_selection(self):
def explode(*a, **k):
raise AssertionError("selection touched")

View file

@ -0,0 +1,88 @@
"""Write one object of a .blend as a free cage document, the form brokkr_kitbash.shell's sheet takes.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tools/cage_export.py -- <copy.blend> <object> <out.json>
For reading a cage a person modelled by hand: its vertex budget, faces, creases and poles, and as the reference
of tools/cage_score.py. <copy.blend> is a COPY of the file, made by whoever runs this: the script opens it, reads
one mesh, writes <out.json> (an absolute path) and nothing else, and never saves a .blend. It refuses to start
unless BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS are private (tools/private_dirs.py).
The document: {"object", "modifiers" (type and name, as stacked), "matrixWorld", "sheet"}. sheet is the cage in
the object's own frame, before any modifier: verts as authored (core.sheet snaps the seam when it builds), faces,
creases from the crease_edge attribute, corners from crease_vert, mirror true when the object carries a Mirror
across x (any other Mirror is refused), rim 0 (a boundary edge carries the crease it was given and no more), and
poles as the faces make them (core.poles). The sheet is what core.sheet accepts: a cage it would refuse (a face of
five sides, a fin on the mirror plane) is refused here with its reason.
A free cage's boundary is smoothed as Blender's Boundary Smooth: All smooths it (core.Sheet.boundary), the setting
of the hand-modelled cages this was made to read. A Subdivision set to Keep Corners draws another surface from the
same cage, so an object carrying one is refused, saying how to state its corners.
"""
import importlib.util
import json
import os
import sys
from pathlib import Path
import bpy
SURFACE = Path(__file__).resolve().parents[1]
def load_core():
spec = importlib.util.spec_from_file_location("brokkr_kitbash_core_tool", SURFACE / "brokkr_kitbash" / "core.py")
core = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = core
spec.loader.exec_module(core)
return core
def export(obj, core) -> dict:
"""The document of a mesh object's cage. Raises core.KitError when the cage is none core.sheet takes."""
if obj.type != "MESH":
raise core.KitError(f"{obj.name!r} is a {obj.type}, not a mesh")
mirrors = [m for m in obj.modifiers if m.type == "MIRROR"]
if len(mirrors) > 1 or mirrors and (tuple(mirrors[0].use_axis) != (True, False, False) or mirrors[0].mirror_object is not None):
raise core.KitError(f"{obj.name!r} is mirrored otherwise than once across its own x: a free cage mirrors across x = 0 only")
kept = [m.name for m in obj.modifiers if m.type == "SUBSURF" and m.boundary_smooth != "ALL"]
if kept:
raise core.KitError(f"{obj.name!r} has its Subdivision {kept[0]!r} at Boundary Smooth Keep Corners, and a free cage smooths its boundary through every vertex: "
"set it to All and give each corner a vertex crease of 1, which draws the same surface")
mesh = obj.data
verts = [[round(float(c), 6) for c in v.co] for v in mesh.vertices]
creases, corners = mesh.attributes.get("crease_edge"), mesh.attributes.get("crease_vert")
sheet = {"verts": verts, "faces": [list(p.vertices) for p in mesh.polygons],
"creases": sorted([*sorted(e.vertices), round(float(creases.data[e.index].value), 4)] for e in mesh.edges if creases.data[e.index].value > 0) if creases else [],
"corners": [[v.index, round(float(corners.data[v.index].value), 4)] for v in mesh.vertices if corners.data[v.index].value > 0] if corners else [],
"mirror": bool(mirrors), "rim": 0.0}
sheet["poles"] = core.poles(sheet)
core.sheet(sheet)
return {"object": obj.name, "modifiers": [[m.type, m.name] for m in obj.modifiers], "matrixWorld": core.rows(obj.matrix_world), "sheet": sheet}
def main() -> int:
sys.path.insert(0, str(Path(__file__).resolve().parent))
import private_dirs
refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if refused:
raise SystemExit(f"cage_export: {refused}")
arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
if len(arguments) != 3 or not Path(arguments[2]).is_absolute():
raise SystemExit("usage: blender --background --factory-startup --python cage_export.py -- <copy.blend> <object> <absolute out.json>")
blend, name, out = arguments
core = load_core()
bpy.ops.wm.open_mainfile(filepath=str(Path(blend).resolve()), load_ui=False, use_scripts=False)
obj = bpy.data.objects.get(name)
if obj is None:
raise SystemExit(f"cage_export: {blend} has no object {name!r}; its meshes: {', '.join(sorted(o.name for o in bpy.data.objects if o.type == 'MESH'))}")
try:
document = export(obj, core)
except core.KitError as error:
raise SystemExit(f"cage_export: {name!r} is no free cage: {error}") from None
Path(out).write_text(json.dumps(document, indent=1), encoding="utf-8")
print("cage_export:", json.dumps({key: core.cage_report(core.sheet(document["sheet"]))[key] for key in ("cageVerts", "cageFaces", "triangles", "creases", "poles", "closed")}), flush=True)
return 0
if __name__ == "__main__":
sys.exit(main())

View file

@ -0,0 +1,210 @@
"""Read how close one free cage comes to another, and what it spends to get there: an agent's cage against a
reference, both in one frame.
blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tools/cage_score.py -- <agent.json> <reference.json> <out.json>
Each input is a sheet (either form of brokkr_kitbash.shell's) or a cage_export.py document holding one. Both are
built by brokkr_kitbash.shell through the add-on's own agent turn, at three levels, and read with their Kit
Subsurf alone: the tool measures what the tool builds. <out.json> is an absolute path and the one file written;
no .blend is saved. It refuses to start unless BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and
BLENDER_USER_SCRIPTS are private (tools/private_dirs.py).
The result is a reading with no pass bar. Every percentage is of the reference surface's largest extent.
agent, reference each cage's counts as shell reports them: cageVerts, cageFaces, triangles, creases, corners, poles, closed
extent the reference surface's largest extent, metres
distance between the two level-3 surfaces, whose vertices lie on the limit surface. Each one's vertices
to the nearest point of the other: agentToReference and referenceToAgent {meanPct, maxPct},
the mean weighted by each vertex's share of its surface's area. meanPct is the mean of the two
means, hausdorffPct the larger of the two maxima (one moved vertex shows here), medianPct and
p95Pct the pooled centiles.
silhouetteIoU orthographic silhouettes seen along x, y and z, 512 px across the two surfaces' common box:
intersection over union
crease where each surface is sharp, read off the surface and not off the cage's crease weights: the
level-3 edges between two faces that turn SHARP degrees or more, sampled every 1% of extent.
missPct is the mean distance from the reference's sharp samples to the agent's (a feature the
agent lacks), spurPct the reverse (a feature the reference lacks). A side with sharp samples
against one with none reads 100; two with none read 0. agentSharp and referenceSharp count the
sharp edges.
cost the headline, lower is better, after the energy of Hoppe et al., "Piecewise Smooth Surface
Reconstruction" (SIGGRAPH 1994), E = E_dist + c_rep * vertices + c_sharp * sharp edges: fit is
distance.meanPct + distance.hausdorffPct + the mean of crease.missPct and crease.spurPct;
complexity is C_REP per cage vertex and C_SHARP per creased cage edge of the agent, a sharp
edge a fifth of a vertex as in that paper; total is their sum. C_REP is the fit, in per cent
of extent, that one more cage vertex must buy.
"""
import importlib.util
import json
import math
import os
import sys
import types
from pathlib import Path
import bmesh
import bpy
import numpy as np
from mathutils import Vector
from mathutils.bvhtree import BVHTree
from mathutils.kdtree import KDTree
SURFACE = Path(__file__).resolve().parents[1]
LEVELS, PIXELS, SPACING = 3, 512, 0.01
SHARP = 30.0 # degrees between two level-3 faces at which their edge is a sharp feature
C_REP, C_SHARP = 0.01, 0.002 # per cent of extent: the price of a cage vertex, and of a creased cage edge
COUNTS = ("cageVerts", "cageFaces", "triangles", "creases", "corners", "poles", "closed")
def surface(obj):
"""(V, triangles, area, sharp) of a shell read with its Kit Subsurf alone: area (len(V),) is each vertex's share
of the surface, sharp the (S, 2, 3) end points of the edges between two faces that turn SHARP degrees or more."""
hidden = [m for m in obj.modifiers if m.name != "Kit Subsurf" and m.show_viewport]
for m in hidden:
m.show_viewport = False
try:
bpy.context.view_layer.update()
owner = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
bm = bmesh.new()
bm.from_mesh(owner.to_mesh())
owner.to_mesh_clear()
finally:
for m in hidden:
m.show_viewport = True
bpy.context.view_layer.update()
bm.normal_update()
V = np.array([v.co[:] for v in bm.verts], dtype=np.float64)
triangles = np.array([[f.verts[0].index, f.verts[k].index, f.verts[k + 1].index] for f in bm.faces for k in range(1, len(f.verts) - 1)], dtype=np.int64)
area = np.zeros(len(V))
for f in bm.faces:
for v in f.verts:
area[v.index] += f.calc_area() / len(f.verts)
sharp = np.array([[e.verts[0].co[:], e.verts[1].co[:]] for e in bm.edges if len(e.link_faces) == 2 and math.degrees(e.calc_face_angle()) >= SHARP], dtype=np.float64).reshape(-1, 2, 3)
bm.free()
return V, triangles, area, sharp
def nearest(points, V, triangles):
tree = BVHTree.FromPolygons([Vector(v) for v in V], [tuple(int(i) for i in t) for t in triangles])
return np.array([tree.find_nearest(Vector(p))[3] for p in points])
def silhouette(V, triangles, axis, low, scale):
"""A PIXELS-square mask of the triangles seen along `axis`, in the frame (low, scale) both surfaces share."""
keep = [k for k in range(3) if k != axis]
P = (V[:, keep] - low[keep]) * scale
mask = np.zeros((PIXELS, PIXELS), dtype=bool)
for a, b, c in P[triangles]:
x0, y0 = np.floor(np.minimum(np.minimum(a, b), c)).astype(int).clip(0, PIXELS - 1)
x1, y1 = np.ceil(np.maximum(np.maximum(a, b), c)).astype(int).clip(0, PIXELS - 1)
area = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])
if abs(area) < 1e-12:
continue
X, Y = np.meshgrid(np.arange(x0, x1 + 1) + 0.5, np.arange(y0, y1 + 1) + 0.5)
u = ((b[0] - X) * (c[1] - Y) - (b[1] - Y) * (c[0] - X)) / area
v = ((c[0] - X) * (a[1] - Y) - (c[1] - Y) * (a[0] - X)) / area
mask[y0:y1 + 1, x0:x1 + 1] |= (u >= 0) & (v >= 0) & (u + v <= 1)
return mask
def sampled(segments, step):
"""Points along each segment, its ends included, no further apart than step."""
points = [a + (b - a) * np.linspace(0.0, 1.0, max(2, int(np.ceil(np.linalg.norm(b - a) / step)) + 1))[:, None] for a, b in segments]
return np.concatenate(points) if points else np.zeros((0, 3))
def apart(P, Q, extent):
"""The mean distance from P's points to the nearest of Q's, per cent of extent: 0 for no P, 100 for a P against no Q."""
if not len(P) or not len(Q):
return 100.0 if len(P) else 0.0
tree = KDTree(len(Q))
for k, q in enumerate(Q):
tree.insert(q, k)
tree.balance()
return float(np.mean([tree.find(p)[2] for p in P])) / extent * 100.0
def score(agent: dict, reference: dict, send) -> dict:
"""The reading of two sheets. send(action, **fields) -> (receipt, report) runs an intent; the two shells it
builds (Cage Score Agent, Cage Score Reference) are removed again."""
built, reports = {}, {}
try:
for role, sheet in (("agent", agent), ("reference", reference)):
name = f"Cage Score {role.title()}"
receipt, report = send("brokkr_kitbash.shell", object_name=name, sheet=json.dumps(sheet), levels=LEVELS, thickness=0.001)
if receipt["status"] != "accepted":
raise SystemExit(f"cage_score: the {role} cage was refused: {receipt['message']}")
reports[role] = {key: report[key] for key in COUNTS}
built[role] = surface(bpy.data.objects[name])
finally:
for role in ("agent", "reference"):
obj = bpy.data.objects.get(f"Cage Score {role.title()}")
if obj is not None:
mesh = obj.data
bpy.data.objects.remove(obj)
bpy.data.meshes.remove(mesh)
(VA, TA, WA, SA), (VB, TB, WB, SB) = built["agent"], built["reference"]
extent = float(np.ptp(VB, axis=0).max())
to_reference, to_agent = nearest(VA, VB, TB) / extent * 100.0, nearest(VB, VA, TA) / extent * 100.0
pooled = np.concatenate([to_reference, to_agent])
means = float(np.average(to_reference, weights=WA)), float(np.average(to_agent, weights=WB))
mean, hausdorff = 0.5 * (means[0] + means[1]), float(pooled.max())
both = np.concatenate([VA, VB])
low = both.min(axis=0)
scale = (PIXELS - 1) / float(np.ptp(both, axis=0).max())
overlap = {}
for axis, label in enumerate("xyz"):
a, b = silhouette(VA, TA, axis, low, scale), silhouette(VB, TB, axis, low, scale)
overlap[label] = round(float((a & b).sum() / max(1, (a | b).sum())), 4)
PA, PB = sampled(SA, SPACING * extent), sampled(SB, SPACING * extent)
miss, spur = apart(PB, PA, extent), apart(PA, PB, extent)
fit = mean + hausdorff + 0.5 * (miss + spur)
complexity = C_REP * reports["agent"]["cageVerts"] + C_SHARP * reports["agent"]["creases"]
return {"levels": LEVELS, "agent": reports["agent"], "reference": reports["reference"], "extent": round(extent, 6),
"distance": {"meanPct": round(mean, 4), "hausdorffPct": round(hausdorff, 4), "medianPct": round(float(np.median(pooled)), 4), "p95Pct": round(float(np.percentile(pooled, 95)), 4),
"agentToReference": {"meanPct": round(means[0], 4), "maxPct": round(float(to_reference.max()), 4)},
"referenceToAgent": {"meanPct": round(means[1], 4), "maxPct": round(float(to_agent.max()), 4)}},
"silhouetteIoU": overlap,
"crease": {"sharpDegrees": SHARP, "missPct": round(miss, 4), "spurPct": round(spur, 4), "agentSharp": len(SA), "referenceSharp": len(SB)},
"cost": {"fit": round(fit, 4), "complexity": round(complexity, 4), "total": round(fit + complexity, 4), "cRep": C_REP, "cSharp": C_SHARP}}
def main() -> int:
sys.path.insert(0, str(Path(__file__).resolve().parent))
import private_dirs
refused = private_dirs.refusal(os.environ, os.path.expanduser("~"), lambda kind: bpy.utils.user_resource(kind))
if refused:
raise SystemExit(f"cage_score: {refused}")
arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
if len(arguments) != 3 or not Path(arguments[2]).is_absolute():
raise SystemExit("usage: blender --background --factory-startup --python cage_score.py -- <agent.json> <reference.json> <absolute out.json>")
sheets = []
for path in arguments[:2]:
document = json.loads(Path(path).read_text(encoding="utf-8"))
sheets.append(document["sheet"] if "sheet" in document else document)
package = types.ModuleType("brokkr_bridge")
package.__path__ = [str(SURFACE / "brokkr_bridge")]
sys.modules["brokkr_bridge"] = package
blender_target = importlib.import_module("brokkr_bridge.blender_target")
import addon_utils
sys.path.append(str(SURFACE))
bpy.ops.wm.read_factory_settings(use_empty=True)
for module in ("brokkr_mesh_polish", "brokkr_kitbash"):
addon_utils.enable(module, default_set=True)
target = blender_target.BrokkrBlenderTarget(bpy)
target.configure_action_dirs("", str(Path(arguments[2]).parent))
target.reload_host_actions()
count = [0]
def send(action, **fields):
count[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"cage-score-{count[0]}", "requestedBy": "tools/cage_score", "action": action, **fields})
return receipt, json.loads(receipt["hostResult"]) if receipt.get("hostResult") else None
result = score(sheets[0], sheets[1], send)
Path(arguments[2]).write_text(json.dumps(result, indent=1), encoding="utf-8")
print("cage_score:", json.dumps(result), flush=True)
return 0
if __name__ == "__main__":
sys.exit(main())