diff --git a/surfaces/blender/docs/kitbash.md b/surfaces/blender/docs/kitbash.md index 8eb7ab9..1f974ed 100644 --- a/surfaces/blender/docs/kitbash.md +++ b/surfaces/blender/docs/kitbash.md @@ -1036,14 +1036,28 @@ about the point, over 4 pi: about a closed mesh the whole number of times the su inside, 2 where two solids overlap. A point is inside the part at 0.5 or more. The joint library's plates are one mesh of four bars, a side's two overlapping about the pivot (`tests/fixtures/ram_plates.json`, with 29 points inside them, 13 inside two bars): each reads inside, as does the overlap of two boxes welded at a corner and a -staircase prism a line crosses six times. Faces are wound counterclockwise seen from outside; a mesh wound inside -out reads outside everywhere. An open mesh is answered, not refused: the number is the closed mesh's less the -missing faces' share of the sphere about the point, so a cube with a face open reads inside up to the hole's plane -(0.5009 at 0.001 under the centre of a unit face) and the sign turns on that plane with no face there. The gate's -proof between samples assumes a distance changes by no more than the way between two points, which holds across a -face and not across a hole: a part with a hole the axis may reach is closed before it is given. The depth is to the -nearest face of any of the part's meshes, one buried inside another included, so inside two overlapping solids a -point may read shallower than its depth below their union. +staircase prism a line crosses six times. + +`Signed` checks what the winding number needs before it answers, and refuses a part by its reason when the oracle is +made (`ram.solids`, a `RamError` at gate `signed`). A part's faces fall into solids, the faces joined across an +edge. Every solid is closed: each edge one face runs is run the other way by another, and a solid with an edge +that is not (a boundary edge, or two faces wound against each other) is refused with the count of such edges. Every +solid is wound counterclockwise seen from outside: one of negative volume is refused with its number, its first +face and its volume, a turned-over bar beside a whole cube included, whose volume in all is positive. Nothing is +repaired or guessed. The shipped plates are four closed solids of 84 faces each, and the 12 parts of both R-3 knees +pass. What it gives up: a part exported open is capped before it is given, a part mirrored by a negative scale has +its faces turned back, and a cavity cut as its own inward shell is refused with the inside-out solids. + +With every solid closed the number is whole, so `ram.inside` reads the same at any bound over 0 and up to 1; 0.5 is +pinned in the unit suite on a test-only open cube, where the number is 0.527 under the hole and 0.473 over it. + +Outside, the distance is to the nearest face of all. Inside, the depth is to the nearest exposed face: one whose +centroid, set 1e-6 of the part's extent off the face along its normal, is not inside the part. A face buried in +another of the part's solids is left out, so a pin sunk 0.056 into a slab with a thin sheet buried along it reads +0.056 and is refused by a zone of depth 0.01. A face that crosses another solid is kept or left whole by where its +centroid is, not split: left out, the depth by it reads greater than it is, which the gate takes as a refusal; +kept, a point by its buried stretch reads shallower than the union's surface is (a boss through a wall: 0.500 for +0.502 and 0.539 for 0.583 in the live readings). | drive | reading | | --- | --- | @@ -1061,7 +1075,11 @@ zones (the own plates, stated with no slack, to the floor); the samples alone to (20,000) is 30 to 40 s. On the meshes the bell crank's 60 pairs at 49 steps took 0.80 to 1.00 s capped (two runs), the winding number as the plain sum over a part's 124 to 408 triangles in numpy (single precision over double offsets, blocks of 32,768 pairs) and the depth a Python loop of BVH queries, and the 13,824-candidate search with its 22 -worlds 34.5 and 38.5 s (two runs). With the angles in double precision the search took 47.7 to 47.9 s (three runs). +worlds 34.5 and 38.5 s (two runs) on a quiet machine. With the angles in double precision the search took 47.7 to +47.9 s (three runs). The live result reports the search's seconds as a reading and no check holds it: beside other +agents' Blenders at full load the same search took 61 to 94 s. With the refusals and +the exposed faces found as each of its 22 worlds is made it took 66.8 s, run after 59.3 s for the oracle before +them under that load (one pair); finding the solids of a 336-face part takes 1.6 ms. ## The actions diff --git a/surfaces/blender/tests/live/ram_knee.py b/surfaces/blender/tests/live/ram_knee.py index 272fe15..d503e2c 100644 --- a/surfaces/blender/tests/live/ram_knee.py +++ b/surfaces/blender/tests/live/ram_knee.py @@ -12,7 +12,8 @@ without them). is an absolute path; writes .result.json and .r3_ 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, or inside a cube with a face left open. +two welded boxes overlap. A part that is open or wound inside out is refused when the oracle is made, and the depth +is to the part's surface: a face buried in another of the part's solids is not read. 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. @@ -326,7 +327,7 @@ try: # 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; and a cube with its top left open + # 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)] @@ -336,14 +337,43 @@ try: 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 - inner = rng.uniform(0.001, 0.999, (4000, 3)) - opened = Signed({"open": [(v1, [face for face in f1 if face != (1, 5, 7, 3)])]})("open", inner) 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()) - RES["readings"]["open cube: inside points read outside, of %d" % len(inner)] = int((opened >= 0).sum()) - check("inside-reads-inside: no point inside the jointlib rocker plates' bars, in two welded boxes' overlap or in a cube with a face open 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 and int((opened >= 0).sum()) == 0, - [int((plates >= 0).sum()), int(both.sum()), int((got != truth).sum()), int((opened >= 0).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, mirrored, or a turned-over bar beside a whole cube (a + # positive volume in all) is wound inside out. Every part of both knees made here passed the same two checks + turned = [face[::-1] for face in f1] + 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])])): + 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 (6 faces from face 0) has volume -1", + "mirrored": "is wound inside out: solid 0 of 1 (6 faces from face 0) has volume -1", "a turned-over bar beside a cube": "is wound inside out: solid 1 of 2 (6 faces from face 6) has volume -0.5"} + check("no-inside-is-refused: an open part is refused by its solid and edge count, an inside-out one by its solid and volume, a turned-over bar beside a whole cube included", + all(said[name] is not None and "part 'cube' " + text in said[name] for name, text in want.items()), said) + + # 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"]]) diff --git a/surfaces/blender/tests/live/ram_knee.result.json b/surfaces/blender/tests/live/ram_knee.result.json index 34bb0b1..6935ca7 100644 --- a/surfaces/blender/tests/live/ram_knee.result.json +++ b/surfaces/blender/tests/live/ram_knee.result.json @@ -17,7 +17,17 @@ "detail": null }, { - "name": "inside-reads-inside: no point inside the jointlib rocker plates' bars, in two welded boxes' overlap or in a cube with a face open reads outside, and none outside the boxes reads inside", + "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 and volume, a turned-over bar beside a whole cube included", + "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 }, @@ -108,22 +118,41 @@ "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": 0.8, + "bell crank: seconds, 49 steps capped": 1.34, "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, "jointlib plates: inside points read outside, of 29": 0, "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, - "open cube: inside points read outside, of 4000": 0, "search: candidates": 13824, "search: pass the gates before clearance": 78, "search: refused on their own parts": 21, - "search: seconds": 34.5, + "search: seconds": 66.8, "search: worlds built": 22, "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 (6 faces from face 0) has volume -1", + "mirrored": "mesh ram: signed: part 'cube' is wound inside out: solid 0 of 1 (6 faces from face 0) has volume -1", + "a turned-over bar beside a cube": "mesh ram: signed: part 'cube' is wound inside out: solid 1 of 2 (6 faces from face 6) has volume -0.5" + }, "zones": { "barrel[0] | parent.seat": { "stated": [ @@ -496,9 +525,9 @@ } }, "renders": [ - "F:/aeth-wt/fable-ramlows/scratch/out/h3f.r3_0.png", - "F:/aeth-wt/fable-ramlows/scratch/out/h3f.r3_62p5.png", - "F:/aeth-wt/fable-ramlows/scratch/out/h3f.r3_125.png" + "F:/aeth-wt/fable-ramlows/scratch/out/live_h4b.r3_0.png", + "F:/aeth-wt/fable-ramlows/scratch/out/live_h4b.r3_62p5.png", + "F:/aeth-wt/fable-ramlows/scratch/out/live_h4b.r3_125.png" ], "ok": true } \ No newline at end of file