Skip to content

Commit 4bfb3fa

Browse files
TMHSDigitalclaude
andcommitted
fix: street-lantern quality pass, a knee brace that bites post and arm
The brace ends sat just outside the post and under the arm, so one bevelled corner grazed each host and it read as a loose stick; the BVH gap budget passed on the graze. Both ends now tenon in, and a brace-bite budget asserts each end inside its host (exit 20, --shallow-brace). Aged brass, sorted bevel input, 60 m stage, temp glb removed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: TMHSDigital <154358121+TMHSDigital@users.noreply.github.com>
1 parent caf3638 commit 4bfb3fa

8 files changed

Lines changed: 245 additions & 55 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Budget-conformance props. Not examples. Conventions: [`showcase/README.md`](show
114114
<a href="showcase/wooden-barrel/"><img src="showcase/wooden-barrel/preview.webp" width="24%" alt="Wooden barrel: a 20-stave wine-cask with a head of four boards, chord-lofted iron hoops, and a bung on a dark studio floor" /></a>
115115
<a href="showcase/campfire/"><img src="showcase/campfire/preview.webp" width="24%" alt="Campfire: a two-course ring of rounded fieldstones around a tripod of logs and glowing ash on a dark studio floor, warm wedge on the back wall" /></a>
116116
<a href="showcase/market-stall/"><img src="showcase/market-stall/preview.webp" width="24%" alt="Market stall: a grained timber frame with post feet, diagonal side braces, slatted counter, rafters, and a striped canvas awning on a dark studio floor, warm wedge on the back wall" /></a>
117-
<a href="showcase/street-lantern/"><img src="showcase/street-lantern/preview.webp" width="24%" alt="Street lantern: an iron post with brass collars, a braced arm, and a muntined amber cage on a dark studio floor" /></a>
117+
<a href="showcase/street-lantern/"><img src="showcase/street-lantern/preview.webp" width="24%" alt="Street lantern: an iron post with aged brass collars, a knee brace tenoned into post and arm, and a muntined amber cage on a dark studio floor" /></a>
118118
<a href="showcase/treasure-chest/"><img src="showcase/treasure-chest/preview.webp" width="24%" alt="Treasure chest: a slatted wooden chest with iron bands, corner brackets, and an open lid on a dark studio floor" /></a>
119119
<a href="showcase/terrain-scatter/"><img src="showcase/terrain-scatter/preview.webp" width="24%" alt="Terrain scatter: a Geometry Nodes dirt hill tile with bevelled masonry rocks on a dark studio floor" /></a>
120120
<a href="showcase/fence-kit/"><img src="showcase/fence-kit/preview.webp" width="24%" alt="Fence kit: a timber post-and-rail section with pyramidal caps, iron shoes and straps on a dark studio floor" /></a>
@@ -149,7 +149,7 @@ Budget-conformance props. Not examples. Conventions: [`showcase/README.md`](show
149149

150150
[`market-stall`](showcase/market-stall/) — procedural timber stall with striped awning and counter through the same pipeline. Falsifiers `--skip-decimate` exits 9, `--short-brace` exits 17.
151151

152-
[`street-lantern`](showcase/street-lantern/) — procedural hanging lantern with iron post, brass fittings, and amber cage through the same pipeline. Falsifier `--skip-decimate` exits 9.
152+
[`street-lantern`](showcase/street-lantern/) — procedural hanging lantern with iron post, brass fittings, and amber cage through the same pipeline. Falsifiers `--skip-decimate` exits 9, `--shallow-brace` exits 20.
153153

154154
[`treasure-chest`](showcase/treasure-chest/) — procedural slatted chest with iron bands, corner brackets, and an open lid through the same pipeline. Falsifier `--skip-decimate` exits 9.
155155

476 Bytes
Loading
308 Bytes
Loading

‎docs/gallery/street-lantern/index.html‎

Lines changed: 117 additions & 29 deletions
Large diffs are not rendered by default.

‎showcase/gallery.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
"name": "street-lantern",
7777
"dir": "showcase/street-lantern",
7878
"teaches": "A procedural hanging street lantern through UVs, bake, LOD, collider, and Unity glTF, asserting recomputed budgets rather than an API contract.",
79-
"alt": "A black iron street lamp post with an arm holding a hanging lantern with glowing panes.",
80-
"witnessesFix": "Recomputed: 3338 tris, three materials with 1530 metal, 24 glass and 209 brass faces, UVs in 0..1 with zero AABB overlap, outer AABB 0.300×0.786×1.287 m, zmin 0, hygiene 0, brace BVH gap 0, hanger-roof gap −1 mm, post 0.100×1.120 m plumb 0, LOD ratios in band (5.2 COLLAPSE 2 tris leaner on LOD2), convex collider 78 tris, non-empty glTF. --skip-decimate exits 9; --stray-vert 15; --lift-z 16; --float-brace 17; --sink-arm 18; --rake-post 19.",
79+
"alt": "A black iron street lamp post with aged brass collars and a knee brace under the arm, holding a hanging lantern with glowing panes.",
80+
"witnessesFix": "Recomputed: 3338 tris, three materials with 1530 metal, 24 glass and 209 brass faces, UVs in 0..1 with zero AABB overlap, outer AABB 0.300×0.786×1.287 m, zmin 0, hygiene 0, brace BVH gap 0, brace ends 13 mm into the post and the arm, hanger-roof gap −1 mm, post 0.100×1.120 m plumb 0, LOD ratios in band (5.2 COLLAPSE 2 tris leaner on LOD2), convex collider 78 tris, non-empty glTF. --skip-decimate exits 9; --stray-vert 15; --lift-z 16; --float-brace 17; --sink-arm 18; --rake-post 19; --shallow-brace 20.",
8181
"hero": "docs/gallery/assets/street-lantern-hero.webp",
8282
"preview": "showcase/street-lantern/preview.webp",
8383
"tags": [

‎showcase/street-lantern/README.md‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@ bake, LOD chain, convex collider, Unity glTF export.
88

99
The arm axis, drop length, and roof stack are one closed-form chain: the
1010
roof peak stays below the arm, the hanger is the arm's far station, and
11-
the brace is an oriented box between a post-radius station and an arm
12-
station. The square pyramid is lofted on the cage axes, not a 4-gon cone.
11+
the brace is an oriented box tenoned into the post wall and into the
12+
arm's lower half. The square pyramid is lofted on the cage axes, not a 4-gon cone.
1313
Cage posts and rails share a named overlap (`CAGE_JOINT`); glass sits
1414
behind the muntins by `PANE_REBATE`. Collars and the arm root evaluate
1515
`post_radius_at(z)`.
1616

17+
The first build parked the brace's post end 0.35 × `BRACE_T` outside
18+
the post and its arm end under the arm, so a single bevelled corner
19+
grazed each host and the brace read as a loose stick in both side
20+
elevations. The brace-to-arm gap budget passed anyway, because a
21+
grazing corner is a zero gap, and nothing measured the post end at
22+
all. The brace ends now start half a brace inside the post wall and on
23+
the arm's centre-line side, and the brace-bite budget below asserts
24+
that each end is actually inside its host. Brass is aged and rougher
25+
(it was bright polished gold at roughness 0.28).
26+
1727
It asserts **budget conformance** of the generated result. It does not
1828
witness an API contract. "It rendered without error" is not a check.
1929

@@ -43,7 +53,7 @@ materials, UVs, evaluated LOD, collider, or export file.
4353
| UVs | in `0..1`, AABB overlap ≤ 1e-5 | in range, overlap 0 |
4454
| Outer AABB | (0.300, 0.786, 1.287) m ± 0.01 | (0.3000, 0.7860, 1.2874), zmin 0 |
4555
| Collider tris | ≤ 120 | 78 |
46-
| Export | written, size > 0 | 250980 / 250980 / 250964 bytes |
56+
| Export | written, size > 0, removed after measuring | 251016 / 251016 / 251000 bytes |
4757

4858
Base triangles dropped from **3520 to 3338** in the quality pass: the
4959
open 4-gon cone roof became a closed square pyramid, cage crossings
@@ -76,13 +86,14 @@ Recomputed from the generated mesh, not asserted about the script.
7686
| Axis | Declared | Measured (all three) |
7787
| --- | --- | --- |
7888
| Brace-to-arm BVH gap | ≤ 0.006 m | 0.00000 |
89+
| Brace bite: deepest brace vertex inside the post / inside the arm (signed distance to the host shell) | ≥ 0.004 m each | 0.01305 / 0.01282 |
7990
| Arm underside vs roof peak | ≥ 0.008 m clearance | 0.05300 |
8091
| Hanger-to-roof BVH gap | ≤ 0.004 m | −0.00100 |
8192

8293
### Falsifiers
8394

84-
Each violates one named budget. All six were run on 4.5.11, 5.1.2 and
85-
5.2.1 and returned the same code on each.
95+
Each violates one named budget. Every falsifier was run on 4.5.11,
96+
5.1.2 and 5.2.1 and returned the same code on each.
8697

8798
| Flag | Budget violated | Exit |
8899
| --- | --- | --- |
@@ -92,11 +103,15 @@ Each violates one named budget. All six were run on 4.5.11, 5.1.2 and
92103
| `--float-brace` | brace-to-arm BVH gap | 17 |
93104
| `--sink-arm` | arm-over-roof clearance | 18 |
94105
| `--rake-post` | post plumb | 19 |
106+
| `--shallow-brace` | brace bite (the first build's ends: −0.00593 m into the post, 0.00000 m into the arm) | 20 |
95107

96108
`--sink-arm` lowers only the arm. Hang-station `hang_z` stays at post
97109
top so the cage does not follow, which is what lets the clearance budget
98110
fire.
99111

112+
The brace-bite check runs last, after plumb, so a raked post is reported
113+
as plumb (19) rather than as a brace that no longer reaches it.
114+
100115
## Run
101116

102117
```bash
@@ -107,6 +122,7 @@ blender --background --python street_lantern.py -- --lift-z
107122
blender --background --python street_lantern.py -- --float-brace
108123
blender --background --python street_lantern.py -- --sink-arm
109124
blender --background --python street_lantern.py -- --rake-post
125+
blender --background --python street_lantern.py -- --shallow-brace
110126
blender --background --python street_lantern.py -- --output lantern.png
111127
```
112128

@@ -116,7 +132,7 @@ Smoke passes no flags.
116132

117133
File-local. `9` is a valid check code. `10` is reserved for
118134
`gallery_framing.check_framing` on the `--output` path. `15`–`19` are the
119-
hygiene and joint-fit family.
135+
hygiene and joint-fit family; `20` is file-local.
120136

121137
| Code | Meaning |
122138
| --- | --- |
@@ -140,3 +156,4 @@ hygiene and joint-fit family.
140156
| 17 | Joint fit: brace-to-arm gap (`--float-brace`) |
141157
| 18 | Seat: arm-roof clearance or hanger-roof gap (`--sink-arm`) |
142158
| 19 | Post plumb or post size off the stated real-world size (`--rake-post`) |
159+
| 20 | Brace bite: a brace end not inside the post or the arm (`--shallow-brace`) |
318 Bytes
Loading

‎showcase/street-lantern/street_lantern.py‎

Lines changed: 101 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
77
The arm axis, drop length, and roof stack are one closed-form chain: the
88
roof peak stays below the arm, the hanger is the arm's far station, and
9-
the brace is an oriented box between a post-radius station and an arm
10-
station. The square pyramid is lofted on the cage axes, not a 4-gon cone.
9+
the brace is an oriented box tenoned into the post wall and into the
10+
arm's lower half. The square pyramid is lofted on the cage axes, not a 4-gon cone.
1111
1212
Budgets are declared below and recomputed from the generated result.
1313
They are not API-contract witnesses. Each falsifier violates one named
1414
budget: ``--skip-decimate`` the LOD-ratio band, ``--stray-vert`` mesh
1515
hygiene, ``--lift-z`` grounded zmin, ``--float-brace`` brace-to-arm
16-
joint, ``--sink-arm`` arm-over-roof clearance, ``--rake-post`` post plumb.
16+
joint, ``--sink-arm`` arm-over-roof clearance, ``--rake-post`` post plumb,
17+
``--shallow-brace`` brace bite into post and arm (exit 20).
1718
1819
No RNG. Construction is closed-form. DECIMATE COLLAPSE triangle counts
1920
are not byte-identical across Blender versions — the LOD gate is a
@@ -118,6 +119,13 @@
118119
HANGER_ROOF_GAP_MAX = 0.004
119120
PLUMB_MAX = 0.008
120121
SINK_ARM = 0.14
122+
# Each brace end must bite into its host: the deepest brace vertex inside the
123+
# post shell, and inside the arm shell, measured as signed distance to that
124+
# shell's surface. The first build parked the post end 0.35 x BRACE_T outside
125+
# the post and the arm end under the arm, so one bevelled corner grazed each
126+
# host and the brace read as a loose stick (it measured -0.0059 m into the
127+
# post and 0.0000 m into the arm).
128+
BRACE_BITE_MIN = 0.004
121129
RAKE = math.radians(8.0)
122130

123131
METAL_IDX = 0
@@ -286,6 +294,7 @@ def build_lantern_mesh(
286294
float_brace=False,
287295
sink_arm=False,
288296
rake_post=False,
297+
shallow_brace=False,
289298
):
290299
bm = bmesh.new()
291300
try:
@@ -383,8 +392,15 @@ def build_lantern_mesh(
383392

384393
brace_z = arm_z - BRACE_POST_DROP
385394
post_r = post_radius_at(brace_z)
386-
p_post = Vector((0.0, post_r + BRACE_T * 0.35, brace_z))
387-
p_arm = Vector((0.0, ARM_LEN * BRACE_ARM_FRAC, arm_z - ARM_R - BRACE_T * 0.20))
395+
if shallow_brace:
396+
# The first build: ends parked on the host surfaces, not in them.
397+
p_post = Vector((0.0, post_r + BRACE_T * 0.35, brace_z))
398+
p_arm = Vector((0.0, ARM_LEN * BRACE_ARM_FRAC, arm_z - ARM_R - BRACE_T * 0.20))
399+
else:
400+
# Tenoned: the post end starts half a brace inside the post wall,
401+
# the arm end sits on the arm's lower half, so both ends bite.
402+
p_post = Vector((0.0, post_r - BRACE_T * 0.5, brace_z))
403+
p_arm = Vector((0.0, ARM_LEN * BRACE_ARM_FRAC, arm_z - ARM_R * 0.35))
388404
if float_brace:
389405
p_arm = p_post + Vector((0.0, 0.11, -0.06))
390406
bevel_verts.extend(add_oriented_box(bm, p_post, p_arm, (BRACE_T, BRACE_T), METAL_IDX))
@@ -523,7 +539,12 @@ def build_lantern_mesh(
523539
)
524540

525541
if bevel_offset > 0.0:
526-
edges = list({e for v in bevel_verts for e in v.link_edges})
542+
# A set of BMEdges iterates in memory order, which varies run to
543+
# run and reorders the bevelled faces; sort by index.
544+
bm.edges.index_update()
545+
edges = sorted(
546+
{e for v in bevel_verts for e in v.link_edges}, key=lambda e: e.index
547+
)
527548
bmesh.ops.bevel(
528549
bm,
529550
geom=edges,
@@ -606,6 +627,24 @@ def principled(name, color, metallic, roughness, emission=None, roughness_var=0.
606627
return mat
607628

608629

630+
def lantern_materials():
631+
"""(metal, glass, brass): shared by the check, the render and inspection.
632+
633+
The first build's brass was bright polished gold (0.72, 0.46, 0.14,
634+
roughness 0.28) and outshone the lamp; it is aged, rougher brass now.
635+
"""
636+
metal = principled("LanternMetal", (0.045, 0.048, 0.055, 1.0), 0.88, 0.40, roughness_var=0.12)
637+
glass = principled(
638+
"LanternGlass",
639+
(0.62, 0.32, 0.08, 1.0),
640+
0.0,
641+
0.22,
642+
emission=((0.85, 0.42, 0.10, 1.0), 0.45),
643+
)
644+
brass = principled("LanternBrass", (0.44, 0.29, 0.10, 1.0), 0.9, 0.44, roughness_var=0.14)
645+
return metal, glass, brass
646+
647+
609648
def assign_slots(obj, metal, glass, brass):
610649
# Do not materials.clear() — that resets polygon material_index to 0
611650
# on this Blender, which would drop glass/brass faces onto metal.
@@ -793,6 +832,32 @@ def shell_bvh_gap(me, ga, gb):
793832
bm_b.free()
794833

795834

835+
def shell_bite(me, ga, gb):
836+
"""Deepest vertex of shell ``ga`` inside closed shell ``gb`` (m); negative if none is."""
837+
bm_b = bmesh.new()
838+
try:
839+
bm_b.from_mesh(me)
840+
keep_b = set(gb)
841+
drop_b = [f for f in bm_b.faces if not all(v.index in keep_b for v in f.verts)]
842+
if drop_b:
843+
bmesh.ops.delete(bm_b, geom=drop_b, context="FACES")
844+
if not bm_b.faces:
845+
return -1e9
846+
bmesh.ops.recalc_face_normals(bm_b, faces=list(bm_b.faces))
847+
tree = BVHTree.FromBMesh(bm_b)
848+
best = -1e9
849+
for i in ga:
850+
co = me.vertices[i].co
851+
loc, nrm, _idx, dist = tree.find_nearest(co)
852+
if loc is None:
853+
continue
854+
depth = dist if (co - loc).dot(nrm) < 0.0 else -dist
855+
best = max(best, depth)
856+
return best
857+
finally:
858+
bm_b.free()
859+
860+
796861
def joint_audit(me):
797862
"""Brace reaches the arm; roof stays under the arm."""
798863
groups = shells(me)
@@ -827,6 +892,10 @@ def joint_audit(me):
827892
brace_gap = 99.0
828893
if arms and braces:
829894
brace_gap = min(shell_bvh_gap(me, b[0], a[0]) for b in braces for a in arms)
895+
post_bite = arm_bite = -1.0
896+
if braces and posts and arms:
897+
post_bite = min(shell_bite(me, b[0], posts[0][0]) for b in braces)
898+
arm_bite = min(shell_bite(me, b[0], arms[0][0]) for b in braces)
830899
roof_zmax = max((a[5] for _g, a in roofs), default=0.0)
831900
arm_zmin = min((a[2] for _g, a in arms), default=99.0)
832901
hanger_zmin = min((a[2] for _g, a in hangers), default=99.0)
@@ -838,6 +907,8 @@ def joint_audit(me):
838907
"posts": len(posts),
839908
"hangers": len(hangers),
840909
"brace_gap": brace_gap,
910+
"post_bite": post_bite,
911+
"arm_bite": arm_bite,
841912
"arm_roof_clear": arm_zmin - roof_zmax,
842913
"hanger_roof_gap": hanger_zmin - roof_zmax,
843914
}
@@ -992,6 +1063,7 @@ def check(
9921063
float_brace=False,
9931064
sink_arm=False,
9941065
rake_post=False,
1066+
shallow_brace=False,
9951067
):
9961068
bpy.ops.wm.read_factory_settings(use_empty=True)
9971069
low = build_lantern_mesh(
@@ -1001,6 +1073,7 @@ def check(
10011073
float_brace=float_brace,
10021074
sink_arm=sink_arm,
10031075
rake_post=rake_post,
1076+
shallow_brace=shallow_brace,
10041077
)
10051078
high = build_lantern_mesh(
10061079
"LanternHigh",
@@ -1009,16 +1082,9 @@ def check(
10091082
float_brace=float_brace,
10101083
sink_arm=sink_arm,
10111084
rake_post=rake_post,
1085+
shallow_brace=shallow_brace,
10121086
)
1013-
metal = principled("LanternMetal", (0.045, 0.048, 0.055, 1.0), 0.88, 0.34, roughness_var=0.08)
1014-
glass = principled(
1015-
"LanternGlass",
1016-
(0.62, 0.32, 0.08, 1.0),
1017-
0.0,
1018-
0.22,
1019-
emission=((0.85, 0.42, 0.10, 1.0), 0.45),
1020-
)
1021-
brass = principled("LanternBrass", (0.72, 0.46, 0.14, 1.0), 1.0, 0.28, roughness_var=0.07)
1087+
metal, glass, brass = lantern_materials()
10221088
assign_slots(low, metal, glass, brass)
10231089
assign_slots(high, metal, glass, brass)
10241090

@@ -1079,6 +1145,14 @@ def check(
10791145
os.remove(export_path)
10801146
export_unity(export_path, [low, collider])
10811147
export_size = os.path.getsize(export_path) if os.path.isfile(export_path) else 0
1148+
# Blender sets TMPDIR from its own preference, which resolves to the
1149+
# working directory on a stock portable build, so every run left a .glb
1150+
# behind. The budget only needs the byte count.
1151+
if os.path.isfile(export_path):
1152+
try:
1153+
os.remove(export_path)
1154+
except OSError:
1155+
pass
10821156

10831157
print(f"blender={tuple(bpy.app.version)} skip_decimate={skip_decimate}")
10841158
print(
@@ -1104,6 +1178,7 @@ def check(
11041178
)
11051179
print(
11061180
f"measured brace_gap={jnt['brace_gap']:.5f} "
1181+
f"post_bite={jnt['post_bite']:.5f} arm_bite={jnt['arm_bite']:.5f} "
11071182
f"arm_roof_clear={jnt['arm_roof_clear']:.5f} "
11081183
f"hanger_roof_gap={jnt['hanger_roof_gap']:.5f} "
11091184
f"plumb={plumb:.5f} post_size=({pxy:.4f},{pz:.4f}) "
@@ -1220,6 +1295,14 @@ def check(
12201295
f"plumb {plumb:.5f} post_size=({pxy:.4f},{pz:.4f})",
12211296
19,
12221297
), None, None, None, None, None
1298+
# Last, so a raked post (plumb, 19) is reported as plumb, not as a brace
1299+
# that no longer reaches it.
1300+
if min(jnt["post_bite"], jnt["arm_bite"]) < BRACE_BITE_MIN:
1301+
return fail(
1302+
f"brace bite post={jnt['post_bite']:.5f} arm={jnt['arm_bite']:.5f} "
1303+
f"< {BRACE_BITE_MIN}",
1304+
20,
1305+
), None, None, None, None, None
12231306
return 0, low, high, metal, tex, collider
12241307

12251308

@@ -1246,7 +1329,7 @@ def render_still(low, metal, tex, path, engine):
12461329
floor_me = bpy.data.meshes.new("Floor")
12471330
bm = bmesh.new()
12481331
try:
1249-
bmesh.ops.create_grid(bm, x_segments=1, y_segments=1, size=14.0)
1332+
bmesh.ops.create_grid(bm, x_segments=1, y_segments=1, size=60.0)
12501333
bm.to_mesh(floor_me)
12511334
finally:
12521335
bm.free()
@@ -1337,6 +1420,7 @@ def main():
13371420
p.add_argument("--stray-vert", action="store_true")
13381421
p.add_argument("--lift-z", action="store_true")
13391422
p.add_argument("--float-brace", action="store_true")
1423+
p.add_argument("--shallow-brace", action="store_true")
13401424
p.add_argument("--sink-arm", action="store_true")
13411425
p.add_argument("--rake-post", action="store_true")
13421426
args = p.parse_args(argv)
@@ -1348,6 +1432,7 @@ def main():
13481432
float_brace=args.float_brace,
13491433
sink_arm=args.sink_arm,
13501434
rake_post=args.rake_post,
1435+
shallow_brace=args.shallow_brace,
13511436
)
13521437
if code:
13531438
return code

0 commit comments

Comments
 (0)