Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
2325 lines (2124 loc) · 162 KB
/
Copy pathindex.html
File metadata and controls
2325 lines (2124 loc) · 162 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>chopping-block — Showcase — Blender Developer Tools</title>
<meta name="description" content="A procedural log-round chopping block with a riveted iron hoop and a felling axe buried in the sawn face, through UVs, bake, LOD, collider, and Unity glTF, asserting recomputed budgets rather than an API contract." />
<link rel="canonical" href="https://tmhsdigital.github.io/Blender-Developer-Tools/gallery/chopping-block/" />
<link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml" />
<meta name="theme-color" content="#1a1b1e" />
<meta name="color-scheme" content="dark" />
<meta property="og:type" content="website" />
<meta property="og:title" content="chopping-block — Showcase — Blender Developer Tools" />
<meta property="og:description" content="A procedural log-round chopping block with a riveted iron hoop and a felling axe buried in the sawn face, through UVs, bake, LOD, collider, and Unity glTF, asserting recomputed budgets rather than an API contract." />
<meta property="og:url" content="https://tmhsdigital.github.io/Blender-Developer-Tools/gallery/chopping-block/" />
<meta property="og:image" content="https://tmhsdigital.github.io/Blender-Developer-Tools/gallery/assets/chopping-block-hero.webp" />
<meta property="og:image:width" content="1280" />
<meta property="og:image:height" content="720" />
<meta property="og:image:alt" content="chopping-block: the showcase piece's own headless render" />
<meta property="og:site_name" content="Blender Developer Tools" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="chopping-block — Showcase — Blender Developer Tools" />
<meta name="twitter:description" content="A procedural log-round chopping block with a riveted iron hoop and a felling axe buried in the sawn face, through UVs, bake, LOD, collider, and Unity glTF, asserting recomputed budgets rather than an API contract." />
<meta name="twitter:image" content="https://tmhsdigital.github.io/Blender-Developer-Tools/gallery/assets/chopping-block-hero.webp" />
<meta name="twitter:image:alt" content="chopping-block: the showcase piece's own headless render" />
<style>
/* fonts are deployed by the landing build (docs/fonts/) */
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap;
src: url('../../fonts/barlow-condensed-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap;
src: url('../../fonts/inter-regular.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap;
src: url('../../fonts/inter-medium.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap;
src: url('../../fonts/jetbrains-mono-regular.woff2') format('woff2'); }
/* Blender-viewport system, shared with the landing page. Dark only. */
:root {
color-scheme: dark;
--bg: #1a1b1e; --surface: #222327; --surface-2: #2a2b30; --bg2: #131417;
--border: #3a3b40; --text: #e8e9eb; --text-dim: #9698a0;
--select: #ff8c19; --ok: #6dc96d;
--radius: 4px; --radius-lg: 6px; --maxw: 1080px;
--font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
--font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
--font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
--code-k: #ff7b72; --code-s: #a5d6ff; --code-c: #9698a0; --code-n: #79c0ff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text);
line-height: 1.6; min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--select); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--select); outline-offset: 2px; border-radius: 3px; }
::selection { background: color-mix(in srgb, var(--select) 40%, transparent); }
.skip { position: absolute; left: -999px; top: 0; background: var(--select); color: #1a1b1e;
padding: 0.5rem 1rem; border-radius: var(--radius); z-index: 10; font-weight: 500; }
.skip:focus { left: 0.5rem; top: 0.5rem; }
.hud { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.04em;
color: var(--text-dim); text-transform: uppercase; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center;
justify-content: space-between; gap: 1rem; padding: 0 1.25rem; height: 46px;
background: color-mix(in srgb, var(--surface) 92%, transparent);
backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar .back { color: var(--text-dim); font-size: 0.8125rem; font-weight: 500; }
.topbar .back:hover { color: var(--select); text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 0.85rem; }
.topbar-right .ghlink { color: var(--text-dim); font-size: 0.8125rem; font-weight: 500; }
.topbar-right .ghlink:hover { color: var(--select); text-decoration: none; }
header.hero { max-width: var(--maxw); margin: 0 auto; padding: 2.75rem 1.25rem 1.25rem; }
header.hero h1 { font-family: var(--font-display); font-weight: 600; text-transform: uppercase;
font-size: clamp(2.2rem, 5vw, 3.4rem); letter-spacing: 0.005em; line-height: 0.98; }
header.hero p { color: var(--text-dim); max-width: 62ch; margin-top: 0.7rem; font-size: 1rem; }
/* ---- index: sticky controls (search, density toggle, tag chips) ---- */
.controls { position: sticky; top: 46px; z-index: 4;
background: color-mix(in srgb, var(--bg) 94%, transparent);
backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
border-bottom: 1px solid var(--border); }
.controls-inner { max-width: var(--maxw); margin: 0 auto; padding: 0.55rem 1.25rem 0.6rem;
display: flex; flex-direction: column; gap: 0.5rem; }
.controls-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.searchwrap { position: relative; flex: 1 1 240px; min-width: 150px; }
.searchwrap input { width: 100%; background: var(--surface-2); border: 1px solid var(--border);
color: var(--text); border-radius: var(--radius); padding: 0.34rem 1.9rem 0.34rem 0.7rem;
font-family: var(--font-sans); font-size: 0.85rem; line-height: 1.4; }
.searchwrap input:focus { border-color: var(--select); outline: none; }
.searchwrap input::placeholder { color: var(--text-dim); }
.searchwrap input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.q-clear { position: absolute; right: 0.2rem; top: 50%; transform: translateY(-50%);
background: none; border: none; color: var(--text-dim); font-size: 1.05rem; line-height: 1;
cursor: pointer; padding: 0.25rem 0.45rem; border-radius: 3px; }
.q-clear:hover { color: var(--select); }
.count { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.04em;
text-transform: uppercase; color: var(--text-dim); white-space: nowrap; }
.density { display: flex; border: 1px solid var(--border); border-radius: var(--radius);
overflow: hidden; }
.density-btn { background: var(--surface-2); border: none; color: var(--text-dim); cursor: pointer;
font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.04em;
text-transform: uppercase; padding: 0.36rem 0.7rem; transition: color 0.15s, background 0.15s; }
.density-btn + .density-btn { border-left: 1px solid var(--border); }
.density-btn:hover { color: var(--select); }
.density-btn.active { background: var(--select); color: #1a1b1e; }
.tags-toggle { display: none; background: var(--surface-2); border: 1px solid var(--border);
color: var(--text-dim); border-radius: 3px; padding: 0.3rem 0.7rem; cursor: pointer;
font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; }
.tags-toggle:hover, .tags-toggle.has-active { color: var(--select); border-color: var(--select); }
/* Tag chips wrap by default (no-JS safe). With JS the row becomes a scroll
strip on wide viewports and collapses behind the Tags toggle on narrow
ones, so the sticky bar never eats the mobile viewport. */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
html.js .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.25rem;
scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
html.js .chips::-webkit-scrollbar { height: 5px; }
html.js .chips::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.chip { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
border-radius: 3px; padding: 0.22rem 0.7rem; font-size: 0.72rem; font-weight: 400;
font-family: var(--font-mono); cursor: pointer; white-space: nowrap; flex: 0 0 auto;
transition: color 0.15s, border-color 0.15s; }
.chip:hover { color: var(--select); border-color: var(--select); }
.chip.active { color: #1a1b1e; background: var(--select); border-color: var(--select); }
@media (max-width: 719px) {
html.js .tags-toggle { display: inline-block; }
html.js .chips { display: none; }
html.js .chips.open { display: flex; flex-wrap: wrap; overflow-y: auto; max-height: 40vh; }
}
/* Compact density: hero + name + one-line teaser. The description and
WITNESSES text stay in the DOM (searchable, screen-reader reachable,
present with JS disabled when the class is never applied) but are
visually collapsed. Applied only by JS via the density-compact class. */
html.density-compact .grid { gap: 1rem; }
html.density-compact .card-body { padding: 0.65rem 0.9rem 0.7rem; }
html.density-compact .card-body h2 { font-size: 0.88rem; margin-bottom: 0.15rem; }
html.density-compact .teaches { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.density-compact .witnesses { position: absolute; width: 1px; height: 1px; margin: -1px;
padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
html.density-compact .card-link { display: none; }
.noresults { color: var(--text-dim); text-align: center; padding: 3rem 1rem; font-size: 0.95rem; }
.noresults .chip { margin-left: 0.6rem; }
.to-top { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 6; cursor: pointer;
background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
border-radius: var(--radius); padding: 0.45rem 0.75rem;
font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.04em;
text-transform: uppercase; opacity: 0; visibility: hidden;
transition: opacity 0.2s, visibility 0.2s, color 0.15s, border-color 0.15s; }
.to-top.show { opacity: 1; visibility: visible; }
.to-top:hover { color: var(--select); border-color: var(--select); }
main { max-width: var(--maxw); margin: 0 auto; padding: 1rem 1.25rem 2rem; }
.grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; align-items: stretch; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
overflow: hidden; display: flex; flex-direction: column;
outline: 2px solid transparent; outline-offset: -1px;
transition: outline-color 0.12s ease, border-color 0.12s ease; }
.card:hover { border-color: var(--select); outline-color: var(--select); }
.card.hidden { display: none; }
.card-media { display: block; background: var(--bg2); line-height: 0; }
.card-media img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.card-body { padding: 1.15rem 1.4rem 1.45rem; display: flex; flex-direction: column; flex: 1 1 auto; }
.card-body h2 { font-family: var(--font-mono); font-size: 1rem; font-weight: 400; margin-bottom: 0.5rem; }
.card-body h2 a { color: var(--text); }
.card-body h2 a:hover { color: var(--select); text-decoration: none; }
.teaches { color: var(--text); margin-bottom: 0.7rem; font-size: 0.92rem; }
.witnesses { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 1rem; }
.tag { display: inline-block; font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase;
letter-spacing: 0.06em; color: var(--select); border: 1px solid color-mix(in srgb, var(--select) 55%, transparent);
border-radius: 3px; padding: 0.08rem 0.5rem; margin-right: 0.4rem; vertical-align: 1px; }
.card-link { font-weight: 600; font-size: 0.95rem; margin-top: auto; }
/* ---- detail page ---- */
.detail-hero { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
background: var(--bg2); padding: 0; display: block; width: 100%; cursor: zoom-in; line-height: 0; }
.detail-hero img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.zoom-hint { color: var(--text-dim); font-size: 0.78rem; margin-top: 0.4rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
white-space: nowrap; }
.callout { border: 1px solid color-mix(in srgb, var(--select) 45%, var(--border));
border-left: 3px solid var(--select); border-radius: var(--radius);
background: color-mix(in srgb, var(--select) 7%, var(--surface));
padding: 0.85rem 1.1rem; margin: 1.5rem 0; font-size: 0.95rem; }
.runline { display: flex; align-items: stretch; gap: 0.5rem; margin: 1.5rem 0; }
.runline pre { flex: 1 1 auto; background: var(--surface-2); border: 1px solid var(--border);
border-radius: var(--radius); padding: 0.7rem 0.9rem; overflow-x: auto;
font-family: var(--font-mono); font-size: 0.83rem; line-height: 1.5; }
.copy-btn { flex: 0 0 auto; background: var(--surface-2); border: 1px solid var(--border);
color: var(--text-dim); border-radius: var(--radius); padding: 0 0.85rem; cursor: pointer;
font-family: var(--font-sans); font-size: 0.82rem; font-weight: 500; transition: color 0.15s, border-color 0.15s; }
.copy-btn:hover { color: var(--select); border-color: var(--select); }
.detail-section { margin-top: 2.25rem; }
.detail-section > h2 { font-family: var(--font-display); font-weight: 600; text-transform: uppercase;
font-size: 1.45rem; letter-spacing: 0.005em; padding-bottom: 0.5rem;
border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.md h1, .md h2, .md h3 { letter-spacing: -0.01em; margin: 1.4rem 0 0.6rem; line-height: 1.25; }
.md h1 { font-size: 1.35rem; } .md h2 { font-size: 1.15rem; } .md h3 { font-size: 1rem; }
.md p { margin: 0.7rem 0; }
.md ul, .md ol { margin: 0.7rem 0 0.7rem 1.4rem; }
.md li { margin: 0.3rem 0; }
.md .table-wrap { overflow-x: auto; margin: 0.9rem 0; }
.md table { border-collapse: collapse; font-size: 0.86rem; min-width: 100%; }
.md th, .md td { text-align: left; vertical-align: top; padding: 0.4rem 0.75rem 0.4rem 0;
border-bottom: 1px solid var(--border); }
.md th { color: var(--text-dim); font-weight: 600; white-space: nowrap; }
.md code { background: var(--surface-2); border: 1px solid var(--border); padding: 0.08rem 0.35rem;
border-radius: 4px; font-family: var(--font-mono); font-size: 0.84em; }
.md pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
padding: 0.85rem 1rem; overflow-x: auto; margin: 0.9rem 0; }
.md pre code { background: none; border: none; padding: 0; font-size: 0.83rem; line-height: 1.55; }
.src pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
padding: 1rem 1.1rem; overflow-x: auto; font-family: var(--font-mono);
font-size: 0.82rem; line-height: 1.55; }
.src .k { color: var(--code-k); } .src .s { color: var(--code-s); }
.src .c { color: var(--code-c); font-style: italic; } .src .n { color: var(--code-n); }
.src-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
flex-wrap: wrap; margin-bottom: 0.6rem; color: var(--text-dim); font-size: 0.85rem; }
.src-meta code { font-family: var(--font-mono); font-size: 0.82rem; }
.lightbox { border: 0; margin: 0; padding: 2rem; width: 100%; height: 100%; max-width: none;
max-height: none; background: rgba(0,0,0,0.85); cursor: zoom-out; }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox::backdrop { background: transparent; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius); }
.lightbox-close { position: absolute; top: 0.9rem; right: 0.9rem; background: var(--surface-2);
color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
font: 500 0.8rem var(--font-sans); padding: 0.4rem 0.75rem; cursor: pointer; }
.lightbox-close:hover { border-color: var(--select); color: var(--select); }
footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 2rem; }
footer .statusbar { max-width: var(--maxw); margin: 0 auto; padding: 0.55rem 1.25rem;
display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.04em;
text-transform: uppercase; color: var(--text-dim); }
footer .statusbar code { font-family: inherit; text-transform: none; }
@media (min-width: 720px) { .grid { grid-template-columns: 1fr 1fr; gap: 1.75rem; } }
@media (min-width: 560px) { html.density-compact .grid { grid-template-columns: 1fr 1fr; gap: 1rem; } }
@media (min-width: 900px) { html.density-compact .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1560px) {
html.density-compact .controls-inner,
html.density-compact main { max-width: 1400px; }
html.density-compact .grid { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
html { scroll-behavior: auto; }
.card { transition: none; }
.card:hover { transform: none; }
.to-top { transition: none; }
}
</style>
</head>
<body>
<a class="skip" href="#main">Skip to content</a>
<div class="topbar">
<a class="back" href="../"><span aria-hidden="true">←</span> Examples and Showcase</a>
<div class="topbar-right">
<a class="ghlink" href="https://github.com/TMHSDigital/Blender-Developer-Tools">GitHub</a>
</div>
</div>
<header class="hero">
<h1>chopping-block</h1>
<p>A procedural log-round chopping block with a riveted iron hoop and a felling axe buried in the sawn face, through UVs, bake, LOD, collider, and Unity glTF, asserting recomputed budgets rather than an API contract.</p>
</header>
<main id="main">
<button class="detail-hero" id="heroZoom" type="button" aria-label="Zoom chopping-block render">
<img src="../assets/chopping-block-hero.webp" alt="chopping-block render" width="1280" height="720" />
</button>
<p class="zoom-hint">Rendered headless by the showcase piece itself — click to zoom.</p>
<div class="callout"><span class="tag">witnesses</span> Recomputed: 1800 tris, four materials with 180 bark / 216 grain / 404 metal / 176 haft faces, UVs in 0..1 with zero AABB overlap, outer AABB 0.526 x 0.526 x 1.006 m, LOD ratios in band, convex collider 538 tris, non-empty glTF. Hygiene: zero non-manifold edges, loose geometry, doubles, zero-area faces, n-gons and coplanar disjoint face pairs, grounded at zmin 0, log plumb to 1e-7, oval haft 1.35 wide-to-thick. Joint fit: six shells, 18.0 mm haft clearance in the eye, 78.7 mm bit bury, hoop biting 3.7-4.2 mm into the log on every segment, two lap rivets seated 1.50 and 1.54 mm. --fat-haft exits 17 on eye clearance; --round-band and --float-rivets exit 18 on their seats; --round-haft exits 19 on the haft section.</div>
<div class="runline">
<pre id="runCmd">blender --background --python showcase/chopping-block/chopping_block.py --</pre>
<button class="copy-btn" id="copyRun" type="button">Copy</button>
</div>
<section class="detail-section md">
<p>A showcase piece, not an example. Procedural chopping block (a log round with a riveted iron hoop and a felling axe buried in the sawn face) then the shipped pipeline: unique-cell UVs, Cycles high-to-low normal bake, LOD chain, convex collider, Unity glTF export.</p>
<p>The log is an out-of-round loft whose radius is a closed-form function of angle and height; the hoop, its rivets, the top rim and the drying checks are all generated from that same function, so they stay seated when a dimension changes. The hoop is a lapped strip with two domed rivets through the lap. The axe head is one lofted shell from poll to bit with its chamfers modelled into the section profile, and the haft is swept through the eye rather than pushed into it. The haft is oval, bows away from the bit, and hooks toward it at the knob.</p>
<p>It asserts <strong>budget conformance</strong> of the generated result. It does not witness an API contract. "It rendered without error" is not a check.</p>
<p><strong>Composes</strong> skills <code>mesh-editing-and-bmesh</code>, <code>bake-high-to-low</code>, <code>depsgraph-and-evaluated-data</code>, <code>engine-export-presets</code>, and snippets <code>bake_normal_high_to_low.py</code>, <code>setup_bake_target_image.py</code>, <code>lod_chain.py</code> / <code>decimate_to_budget.py</code>, <code>convex_hull_collider.py</code>, <code>export_preset_unity.py</code> (helpers copied, not imported as a package).</p>
<h2>Budgets</h2>
<p>Declared as named constants; every gate <strong>recomputes</strong> from the mesh, materials, UVs, evaluated LOD, collider, or export file.</p>
<div class="table-wrap"><table><thead><tr><th scope="col">Axis</th><th scope="col">Declared</th><th scope="col">Measured (4.5.11 / 5.1.2 / 5.2.1)</th></tr></thead><tbody><tr><td>Base triangles</td><td>1730–1870</td><td>1800 / 1800 / 1800</td></tr><tr><td>LOD1 ratio</td><td>0.32–0.62 of base</td><td>0.5000 / 0.5000 / 0.5000</td></tr><tr><td>LOD2 ratio</td><td>0.10–0.35 of base</td><td>0.2200 / 0.2200 / 0.2200</td></tr><tr><td>Materials</td><td>exactly 4 distinct; ≥160 bark, ≥90 grain, ≥170 metal, ≥150 haft faces</td><td>4 slots; 180 / 216 / 404 / 176</td></tr><tr><td>UVs</td><td>in <code>0..1</code>, AABB overlap ≤ 1e-5</td><td>in range, overlap 0</td></tr><tr><td>Outer AABB</td><td>(0.526, 0.526, 1.006) m ± 0.012</td><td>(0.5264, 0.5264, 1.0064)</td></tr><tr><td>Collider tris</td><td>≤ 560</td><td>538</td></tr><tr><td>Export</td><td>written, size > 0</td><td>180588 / 180588 / 180572 bytes</td></tr></tbody></table></div>
<p>The triangle band, the outer AABB and the collider ceiling were re-fitted in the quality pass that added the lap, the rivets and the 16-segment oval haft (1472 → 1800 triangles, collider 434 → 538). The triangle band is centred on the new measurement, ± 4 %.</p>
<h3>Hygiene</h3>
<p>Recomputed from the generated mesh, not asserted about the script.</p>
<div class="table-wrap"><table><thead><tr><th scope="col">Axis</th><th scope="col">Declared</th><th scope="col">Measured (all three)</th></tr></thead><tbody><tr><td>Non-manifold edges</td><td>0</td><td>0</td></tr><tr><td>Loose verts / edges</td><td>0 / 0</td><td>0 / 0</td></tr><tr><td>Doubles merged at 1e-5</td><td>0</td><td>0</td></tr><tr><td>Zero-area faces</td><td>0</td><td>0</td></tr><tr><td>N-gons</td><td>0</td><td>0</td></tr><tr><td>Coplanar disjoint face pairs</td><td>0</td><td>0</td></tr><tr><td>Grounded: <code>zmin</code></td><td>within 1e-4 of 0</td><td>0.0000</td></tr><tr><td>Log axis out of plumb</td><td>≤ 1e-5</td><td>0.0000000</td></tr><tr><td>Log size</td><td>0.535 × 0.360 m ± 0.030 / ± 0.010</td><td>0.5464 × 0.3600</td></tr><tr><td>Haft section, wide over thick at the grip</td><td>1.25–1.60</td><td>1.3500</td></tr></tbody></table></div>
<h3>Joint fit</h3>
<p>Six shells that have to meet correctly: log, hoop, head, haft, and the two rivets through the hoop's lap.</p>
<div class="table-wrap"><table><thead><tr><th scope="col">Axis</th><th scope="col">Declared</th><th scope="col">Measured (all three)</th></tr></thead><tbody><tr><td>Shell count</td><td>exactly 6</td><td>6</td></tr><tr><td>Haft clearance inside the eye</td><td>≥ 0.006 m</td><td>0.01800</td></tr><tr><td>Haft engagement through the eye</td><td>≥ 0.020 m</td><td>0.08225</td></tr><tr><td>Haft breakout margin below the head</td><td>≥ 0.006 m</td><td>0.02175</td></tr><tr><td>Bit bury below the sawn top</td><td>≥ 0.030 m</td><td>0.07871</td></tr><tr><td>Bit inset from the rim</td><td>≥ 0.030 m</td><td>0.14647</td></tr><tr><td>Hoop bite into the log, every segment</td><td>0.002–0.007 m</td><td>0.00371–0.00422</td></tr><tr><td>Haft clearance above the log</td><td>≥ 0.015 m, 0 verts inside</td><td>0.07531, 0</td></tr><tr><td>Rivet seat into the hoop, each rivet</td><td>0.0008–0.0025 m</td><td>0.00150, 0.00154</td></tr><tr><td>Rivet dome proud of the hoop, each rivet</td><td>≥ 0.0025 m</td><td>0.00419, 0.00432</td></tr></tbody></table></div>
<p>The hoop bite is binned by angular segment against the log's own radius function. A single global midpoint radius misclassifies outer chamfer vertices as inner ones on an out-of-round log, which is how a hoop that visibly floated on one side still passed.</p>
<p>The rivet seat is measured radially at each rivet vertex's own angle, against the hoop's outer face read off the mesh by a ray cast from the axis. Each rivet is aimed down the hoop's surface normal, not the radial: the log is out of round, so across one 12 mm head its surface falls by up to 1.4 mm, and radially aimed heads seated 1.87 and 2.82 mm against a 1.5 mm design bite, one edge sunk and the other lifted.</p>
<p>DECIMATE COLLAPSE triangle counts happen to agree across all three series here; the gate is still a ratio band, not an exact count. Bake pixels are stochastic; the gate is <code>has_data</code> plus operator <code>FINISHED</code>, not byte-identity. Construction uses no RNG: two runs on each binary print identical measurements, and the three binaries agree on every gated axis. Export byte counts differ by 16 B on 5.2.1 (glTF serializer), not a gated axis.</p>
<h3>Shading and materials</h3>
<p>Only the axe head is flat-shaded: it is a chamfered forging, and its facets are its form. The log and the hoop are smooth-shaded. Flat-shaded, the log's 36 equal facets read as coopered staves and the block as a tub, and the hoop threw one highlight per facet. The log's wobble still reads in the silhouette, and its surface is carried by the materials: vertical bark furrows with a bump, growth rings about an off-centre pith on the sawn face, and dark radial checks drawn at the same angles the geometry notches. Every material boundary is a hard edge, so the sawn rim stays crisp against the bark.</p>
<p>The haft has its own material slot. It used to share the bark's, which made the hickory handle the darkest wood on the piece.</p>
<h3>Falsifiers</h3>
<p>Each violates one named budget. All seven were run on 4.5.11, 5.1.2 and 5.2.1 and returned the same code on each.</p>
<div class="table-wrap"><table><thead><tr><th scope="col">Flag</th><th scope="col">Budget violated</th><th scope="col">Exit</th></tr></thead><tbody><tr><td><code>--skip-decimate</code></td><td>LOD1 ratio band</td><td>9</td></tr><tr><td><code>--stray-vert</code></td><td>loose vertex count is 0</td><td>15</td></tr><tr><td><code>--lift-z</code></td><td>bounding box <code>zmin</code> is 0</td><td>16</td></tr><tr><td><code>--fat-haft</code></td><td>haft clearance inside the eye</td><td>17</td></tr><tr><td><code>--round-band</code></td><td>hoop bite into the log</td><td>18</td></tr><tr><td><code>--float-rivets</code></td><td>rivet seat into the hoop</td><td>18</td></tr><tr><td><code>--round-haft</code></td><td>haft section wide over thick</td><td>19</td></tr></tbody></table></div>
<p><code>--fat-haft</code> thickens the haft across the cheeks only, which is the dimension the eye clearance measures. Scaling the whole oval section grew the knob 16 mm past the bounding box, so it exited 8 instead.</p>
<h2>Run</h2>
<pre><code>blender --background --python chopping_block.py --
blender --background --python chopping_block.py -- --skip-decimate
blender --background --python chopping_block.py -- --stray-vert
blender --background --python chopping_block.py -- --lift-z
blender --background --python chopping_block.py -- --fat-haft
blender --background --python chopping_block.py -- --round-band
blender --background --python chopping_block.py -- --float-rivets
blender --background --python chopping_block.py -- --round-haft
blender --background --python chopping_block.py -- --output chopping-block.png</code></pre>
<p>Smoke passes no flags.</p>
<h2>Exit codes</h2>
<p>File-local. <code>9</code> is a valid check code. <code>10</code> is reserved for <code>gallery_framing.check_framing</code> on the <code>--output</code> path. <code>15</code>–<code>19</code> are the hygiene and joint-fit family.</p>
<div class="table-wrap"><table><thead><tr><th scope="col">Code</th><th scope="col">Meaning</th></tr></thead><tbody><tr><td>0</td><td>Success</td></tr><tr><td>1</td><td>Uncaught exception (FATAL wrapper)</td></tr><tr><td>2</td><td>argparse / usage</td></tr><tr><td>3</td><td>Mesh did not build / no UV layer</td></tr><tr><td>4</td><td>Base triangle count outside range</td></tr><tr><td>5</td><td>Material count ≠ 4 distinct slots, or a face-count floor missed</td></tr><tr><td>6</td><td>UVs outside 0..1</td></tr><tr><td>7</td><td>UV AABB overlap above tolerance</td></tr><tr><td>8</td><td>World AABB off declared outer size</td></tr><tr><td>9</td><td>LOD ratio band (<code>--skip-decimate</code> lands here)</td></tr><tr><td>10</td><td>Framing gate (render path only)</td></tr><tr><td>11</td><td>Collider triangle count above ceiling</td></tr><tr><td>12</td><td>Bake did not finish or image has no data</td></tr><tr><td>13</td><td>Export file missing or empty</td></tr><tr><td>14</td><td><code>--output</code> produced no file</td></tr><tr><td>15</td><td>Mesh hygiene: loose, non-manifold, zero-area, doubles, n-gons, z-fight</td></tr><tr><td>16</td><td>Not grounded: bounding box <code>zmin</code> off 0</td></tr><tr><td>17</td><td>Joint fit: shell count, eye clearance, engagement, breakout, bury, inset</td></tr><tr><td>18</td><td>Contact fit: hoop bite band, haft fouling the log, or a rivet off its seat band</td></tr><tr><td>19</td><td>Log out of plumb, off its stated real-world size, or a round haft section</td></tr></tbody></table></div>
</section>
<section class="detail-section src">
<h2>Source</h2>
<div class="src-meta">
<code>showcase/chopping-block/chopping_block.py</code>
<a href="https://github.com/TMHSDigital/Blender-Developer-Tools/tree/main/showcase/chopping-block/chopping_block.py">View on GitHub →</a>
</div>
<pre><span class="s">"""Game-ready chopping block — a showcase piece, not an example.
Asserts budget conformance of a procedural splitting block (a hooped log
round with a felling axe standing in it) after composing shipped pipeline
pieces: bmesh construction, UVs, four materials, high-to-low normal bake,
LOD chain, convex collider, Unity glTF export.
Budgets are declared below and recomputed from the generated result. They
are not API-contract witnesses. Each falsifier violates exactly one named
budget: ``--skip-decimate`` skips the LOD DECIMATE stage so the LOD-ratio
budget fails, ``--lift-z`` moves the mesh off the floor so the grounded
budget fails, ``--stray-vert`` adds one unconnected vertex so the
mesh-hygiene budget fails, ``--fat-haft`` widens the handle to the full
thickness of the axe eye so the eye joint-fit budget fails,
``--round-band`` generates the iron band on a circle instead of on the
log's own surface so the band-seat budget fails, ``--float-rivets`` lifts
the lap rivets off the hoop so the rivet-seat budget fails, and
``--round-haft`` turns the oval handle round so the haft-section budget
fails.
No RNG. The log's out-of-round profile is a closed-form sum of sines, so
construction is deterministic. DECIMATE COLLAPSE triangle counts are not
byte-identical across Blender versions — the LOD gate is a ratio band,
not an exact count.
blender --background --python chopping_block.py --
blender --background --python chopping_block.py -- --skip-decimate
blender --background --python chopping_block.py -- --lift-z
blender --background --python chopping_block.py -- --stray-vert
blender --background --python chopping_block.py -- --fat-haft
blender --background --python chopping_block.py -- --round-band
blender --background --python chopping_block.py -- --float-rivets
blender --background --python chopping_block.py -- --round-haft
blender --background --python chopping_block.py -- --output block.png
"""</span>
<span class="k">import</span> argparse
<span class="k">import</span> math
<span class="k">import</span> os
<span class="k">import</span> sys
<span class="k">import</span> tempfile
<span class="k">import</span> traceback
<span class="k">import</span> bmesh
<span class="k">import</span> bpy
<span class="k">from</span> mathutils <span class="k">import</span> Matrix, Vector
<span class="k">from</span> mathutils.bvhtree <span class="k">import</span> BVHTree
<span class="c"># Showcase lives at repo-root/showcase/, not under examples/. The framing</span>
<span class="c"># helper is the repo's only shared import and lives next to the examples;</span>
<span class="c"># resolve the repo root so we do not move gallery_framing.py.</span>
_REPO = os.path.abspath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, os.pardir)
)
sys.path.insert(<span class="n">0</span>, os.path.join(_REPO, <span class="s">"examples"</span>))
sys.dont_write_bytecode = <span class="k">True</span>
<span class="k">import</span> gallery_framing <span class="c"># noqa: E402</span>
<span class="c"># A splitting block is a log round: 0.41 m across, 0.46 m tall, near-parallel</span>
<span class="c"># sides. The old piece was a truncated cone 0.44 m across and 0.36 m tall,</span>
<span class="c"># which reads as a pail.</span>
<span class="c"># A log round is wider than it is tall: 0.52 m across, 0.36 m high. At</span>
<span class="c"># 0.41 across and 0.46 high the silhouette was a cylinder as tall as it was</span>
<span class="c"># wide, which is a canister no matter what detail is put on its surface.</span>
BLOCK_R = <span class="n">0.260</span>
BLOCK_H = <span class="n">0.36</span>
BLOCK_SEGS = <span class="n">36</span>
BLOCK_TAPER = <span class="n">0.052</span>
<span class="c"># The bake's high-poly is the same construction at a higher detail level, so</span>
<span class="c"># what the normal map records is real rounding, not a second sculpt.</span>
HIGH_SEG_SCALE = <span class="n">2</span>
HIGH_CHAMFER_SEGS = <span class="n">3</span>
<span class="c"># Out-of-round profile, as (frequency, phase, amplitude). A perfect circle</span>
<span class="c"># reads as a turned bucket. Frequencies are chosen so that no sum or</span>
<span class="c"># difference with the rim-chip frequency lands on 1 or on 1 mod BLOCK_SEGS:</span>
<span class="c"># that is what keeps each ring's centroid exactly on the axis, which is in</span>
<span class="c"># turn what makes the plumb assertion meaningful rather than approximate.</span>
WOBBLE = ((<span class="n">3.0</span>, <span class="n">0.4</span>, <span class="n">0.030</span>), (<span class="n">7.0</span>, <span class="n">2.1</span>, <span class="n">0.019</span>), (<span class="n">11.0</span>, <span class="n">5.0</span>, <span class="n">0.011</span>))
WOBBLE_TWIST = <span class="n">0.10</span>
<span class="c"># Stump hoop, low on the body. Generated from the log's own radius function,</span>
<span class="c"># so it seats uniformly on an out-of-round surface; a circular hoop</span>
<span class="c"># alternately sinks and floats, which is what the old torus did. Up under</span>
<span class="c"># the rim it read as the clamp ring of a lid.</span>
BAND_Z0 = <span class="n">0.075</span>
BAND_Z1 = <span class="n">0.125</span>
BAND_BITE = <span class="n">0.004</span>
BAND_PROUD = <span class="n">0.006</span>
BAND_CHAMFER = <span class="n">0.0022</span>
<span class="c"># Lap joint. A hoop is a strip of iron riveted where its ends overlap; a</span>
<span class="c"># ring of constant section reads as a painted stripe. The outer end steps</span>
<span class="c"># up sharply at LAP_U0, and the lap tapers out past LAP_U1 where the hidden</span>
<span class="c"># end runs underneath. Every kink is its own band section, and none lands</span>
<span class="c"># on a log segment at either detail level (10 and 5 degrees).</span>
LAP_U0 = math.radians(<span class="n">302.5</span>)
LAP_STEP = math.radians(<span class="n">1.0</span>)
LAP_U1 = math.radians(<span class="n">316.5</span>)
LAP_TAPER = math.radians(<span class="n">4.0</span>)
LAP_T = <span class="n">0.0025</span>
<span class="c"># Two domed rivets through the lap, each on its own band section so the</span>
<span class="c"># surface under it is exact rather than a chord.</span>
RIVET_US = (math.radians(<span class="n">307.5</span>), math.radians(<span class="n">312.5</span>))
RIVET_R = <span class="n">0.0062</span>
RIVET_H = <span class="n">0.0042</span>
RIVET_BITE = <span class="n">0.0015</span>
RIVET_SEGS = <span class="n">8</span>
<span class="c"># (height as a fraction of RIVET_H, radius scale). The first ring is below</span>
<span class="c"># the band surface by RIVET_BITE; that is the seat.</span>
RIVET_RINGS = ((<span class="n">0.45</span>, <span class="n">0.86</span>), (<span class="n">0.82</span>, <span class="n">0.52</span>), (<span class="n">0.97</span>, <span class="n">0.22</span>))
FLOAT_RIVET = <span class="n">0.003</span>
<span class="c"># (z, rim scale). The scaled rings are modelled chamfers: the rim of a sawn</span>
<span class="c"># log catches light, and modelling it costs less than bevelling 32 segments.</span>
<span class="c"># The band's own two heights are ring heights, so the hoop's inner face and</span>
<span class="c"># the log's facet interpolate identically between them and the seat cannot</span>
<span class="c"># open up between rings.</span>
BLOCK_RINGS = (
(<span class="n">0.000</span>, <span class="n">0.958</span>),
(<span class="n">0.018</span>, <span class="n">1.000</span>),
(BAND_Z0, <span class="n">1.000</span>),
(BAND_Z1, <span class="n">1.000</span>),
(<span class="n">0.250</span>, <span class="n">1.000</span>),
(BLOCK_H - <span class="n">0.028</span>, <span class="n">1.000</span>),
(BLOCK_H, <span class="n">0.955</span>),
)
<span class="c"># A block that gets split on reads as a canister with a lid unless the top</span>
<span class="c"># is dished and hacked, the rim is chipped, and the end grain has opened up</span>
<span class="c"># along radial checks. The cracks are the single strongest read.</span>
TOP_RIM_SCALE = <span class="n">0.955</span>
TOP_RIM_CHIP = <span class="n">0.035</span>
TOP_CAP_RINGS = (<span class="n">0.72</span>, <span class="n">0.44</span>, <span class="n">0.18</span>)
TOP_DISH = <span class="n">0.0110</span>
TOP_SCAR = <span class="n">0.0110</span>
<span class="c"># (angle, depth). Depth stays under the 28 mm top chamfer so a check can</span>
<span class="c"># notch the rim without pushing it below the chamfer ring and inverting it.</span>
TOP_CRACKS = ((<span class="n">0.55</span>, <span class="n">0.015</span>), (<span class="n">2.60</span>, <span class="n">0.011</span>), (<span class="n">4.35</span>, <span class="n">0.018</span>))
TOP_CRACK_WIDTH = <span class="n">0.15</span>
<span class="c"># Felling axe. The head is a single lofted shell from poll to bit, not a</span>
<span class="c"># stack of boxes. Angles are measured in the XZ plane before the azimuth</span>
<span class="c"># spin; the 18 degrees between the head axis and the haft is the hang angle.</span>
HEAD_LEN = <span class="n">0.225</span>
HEAD_EYE_T = <span class="n">0.26</span>
AXE_BIT_ANGLE = math.radians(<span class="n">228.0</span>)
AXE_HAFT_ANGLE = math.radians(<span class="n">126.0</span>)
AXE_AZIMUTH = math.radians(<span class="n">34.0</span>)
BIT_CENTER = (<span class="n">0.010</span>, <span class="n">0.0</span>, BLOCK_H - <span class="n">0.030</span>)
<span class="c"># (t along poll to bit, half height along the edge, half thickness). The</span>
<span class="c"># first and last pairs are the lengthwise chamfers on the poll and the bit;</span>
<span class="c"># every corner of every section is chamfered by HEAD_CHAMFER. Modelling the</span>
<span class="c"># chamfer is what replaced a bmesh bevel here: bevelling a four-sided loft</span>
<span class="c"># left sixteen boundary edges and two doubles at the bit.</span>
<span class="c"># A felling axe is long and narrow: 225 mm poll to bit with a 148 mm edge.</span>
<span class="c"># At 155 mm with a 172 mm edge it read as a paddle; at 185 mm against a</span>
<span class="c"># 530 mm block it read as a trowel. The head is sized off the block, not</span>
<span class="c"># off an absolute idea of an axe -- half the block diameter is what makes</span>
<span class="c"># the two objects look like they belong in the same scene.</span>
HEAD_SECTIONS = (
(<span class="n">0.000</span>, <span class="n">0.0280</span>, <span class="n">0.0215</span>),
(<span class="n">0.028</span>, <span class="n">0.0340</span>, <span class="n">0.0270</span>),
(<span class="n">0.150</span>, <span class="n">0.0485</span>, <span class="n">0.0385</span>),
(<span class="n">0.330</span>, <span class="n">0.0520</span>, <span class="n">0.0280</span>),
(<span class="n">0.620</span>, <span class="n">0.0615</span>, <span class="n">0.0160</span>),
(<span class="n">0.870</span>, <span class="n">0.0710</span>, <span class="n">0.0062</span>),
(<span class="n">0.980</span>, <span class="n">0.0745</span>, <span class="n">0.0018</span>),
(<span class="n">1.000</span>, <span class="n">0.0728</span>, <span class="n">0.0013</span>),
)
HEAD_CHAMFER = <span class="n">0.0042</span>
HAFT_LEN = <span class="n">0.68</span>
HAFT_DROP = <span class="n">0.024</span>
HAFT_BOW = <span class="n">0.020</span>
HAFT_SEGS = <span class="n">16</span>
<span class="c"># (t along the haft, half thickness across the cheeks). The shoulder-waist-</span>
<span class="c"># swell spread is wide on purpose: a 0.68 m haft that runs 15 mm to 18 mm</span>
<span class="c"># reads as dowel at any distance a viewer will see it from. The swell holds</span>
<span class="c"># its width to within 2 mm of the butt and then rounds off: a knob that</span>
<span class="c"># tapers the whole way to its end cap reads as a pencil stub.</span>
HAFT_SECTIONS = (
(<span class="n">0.00</span>, <span class="n">0.0192</span>),
(<span class="n">0.10</span>, <span class="n">0.0205</span>),
(<span class="n">0.32</span>, <span class="n">0.0150</span>),
(<span class="n">0.58</span>, <span class="n">0.0136</span>),
(<span class="n">0.78</span>, <span class="n">0.0150</span>),
(<span class="n">0.88</span>, <span class="n">0.0188</span>),
(<span class="n">0.94</span>, <span class="n">0.0226</span>),
(<span class="n">0.975</span>, <span class="n">0.0222</span>),
(<span class="n">0.993</span>, <span class="n">0.0192</span>),
(<span class="n">1.00</span>, <span class="n">0.0140</span>),
)
<span class="c"># An axe handle is oval, wider in the swing plane than across the cheeks.</span>
<span class="c"># A round section at any width is a broom handle.</span>
HAFT_OVAL = <span class="n">1.35</span>
HAFT_OVAL_MIN = <span class="n">1.25</span>
HAFT_OVAL_MAX = <span class="n">1.60</span>
<span class="c"># The grip station the oval is measured at, as a fraction along the haft.</span>
HAFT_GRIP_T = <span class="n">0.58</span>
<span class="c"># The knob hooks toward the bit, the other half of the S the bow starts.</span>
HAFT_HOOK = <span class="n">0.016</span>
FAT_HAFT_SCALE = <span class="n">1.85</span>
<span class="c"># Six closed shells: log, iron band, axe head, axe haft, two rivets.</span>
PART_COUNT = <span class="n">4</span> + len(RIVET_US)
BBOX_TOL = <span class="n">0.012</span>
<span class="c"># Fitted after locking geometry. Recomputed from bound_box.</span>
OUTER_SIZE = (<span class="n">0.526</span>, <span class="n">0.526</span>, <span class="n">1.006</span>)
<span class="c"># Stated real-world size of the block itself, checked separately from the</span>
<span class="c"># fitted AABB so a proportion drift is named rather than absorbed by it.</span>
BLOCK_DIAMETER = <span class="n">0.535</span>
BLOCK_HEIGHT = <span class="n">0.360</span>
BLOCK_DIAMETER_TOL = <span class="n">0.030</span>
BLOCK_HEIGHT_TOL = <span class="n">0.010</span>
PLUMB_EPS = <span class="n">1e-5</span>
<span class="c"># Joint contract, all recomputed from vertex positions in the axe's own</span>
<span class="c"># construction frame.</span>
EYE_CLEARANCE_MIN = <span class="n">0.006</span>
HAFT_ENGAGE_MIN = <span class="n">0.020</span>
HAFT_INSIDE_MIN = <span class="n">0.006</span>
BIT_BURY_MIN = <span class="n">0.030</span>
BIT_INSET_MIN = <span class="n">0.030</span>
BAND_BITE_MIN = <span class="n">0.002</span>
BAND_BITE_MAX = <span class="n">0.007</span>
HAFT_BLOCK_CLEAR_MIN = <span class="n">0.015</span>
<span class="c"># Rivet seat, measured radially at each rivet vertex's own angle against the</span>
<span class="c"># band surface read off the mesh. A floor so the head cannot float off the</span>
<span class="c"># lap, a ceiling so it cannot sink into it, and a proud minimum so the dome</span>
<span class="c"># is actually visible.</span>
RIVET_SEAT_MIN = <span class="n">0.0008</span>
RIVET_SEAT_MAX = <span class="n">0.0025</span>
RIVET_PROUD_MIN = <span class="n">0.0025</span>
RIVET_SPAN_MAX = <span class="n">0.03</span>
ZMIN_EPS = <span class="n">1e-4</span>
DOUBLES_EPS = <span class="n">1e-5</span>
AREA_EPS = <span class="n">1e-10</span>
ZFIGHT_EPS = <span class="n">0.0012</span>
ZFIGHT_COS = <span class="n">0.9995</span>
LIFT_Z = <span class="n">0.05</span>
BASE_TRIS_MIN = <span class="n">1730</span>
BASE_TRIS_MAX = <span class="n">1870</span>
LOD1_RATIO_MIN = <span class="n">0.32</span>
LOD1_RATIO_MAX = <span class="n">0.62</span>
LOD2_RATIO_MIN = <span class="n">0.10</span>
LOD2_RATIO_MAX = <span class="n">0.35</span>
LOD1_TARGET = <span class="n">0.50</span>
LOD2_TARGET = <span class="n">0.22</span>
MATERIAL_COUNT = <span class="n">4</span>
UV_EPS = <span class="n">1e-4</span>
UV_OVERLAP_MAX = <span class="n">1e-5</span>
COLLIDER_TRIS_MAX = <span class="n">560</span>
BAKE_RES = <span class="n">256</span>
CAGE_EXTRUSION = <span class="n">0.08</span>
<span class="c"># Floors catch the slot-assignment wipe class and the bevel-inherits-slot-0</span>
<span class="c"># class: the axe head's chamfers are claimed from the bevel op's own return,</span>
<span class="c"># so a regression there drops the metal count well below this floor.</span>
WOOD_FACES_MIN = <span class="n">160</span>
GRAIN_FACES_MIN = <span class="n">90</span>
METAL_FACES_MIN = <span class="n">170</span>
HAFT_FACES_MIN = <span class="n">150</span>
WOOD_IDX = <span class="n">0</span>
GRAIN_IDX = <span class="n">1</span>
METAL_IDX = <span class="n">2</span>
<span class="c"># The haft is hickory, not bark. Sharing the bark slot made the handle the</span>
<span class="c"># darkest wood on the piece and would fissure it with the bark texture.</span>
HAFT_IDX = <span class="n">3</span>
<span class="c"># End-grain shading. The pith sits off the geometric centre, as it does in</span>
<span class="c"># nearly every real log; concentric rings about the exact centre read as a</span>
<span class="c"># target. Checks are drawn at the same angles the geometry notches.</span>
PITH = (<span class="n">0.021</span>, -<span class="n">0.013</span>)
RING_SCALE = <span class="n">38.0</span>
CHECK_W0 = <span class="n">0.0010</span>
CHECK_WIDEN = <span class="n">0.012</span>
<span class="k">def</span> eevee_engine_id():
<span class="k">return</span> <span class="s">"BLENDER_EEVEE"</span> <span class="k">if</span> bpy.app.version >= (<span class="n">5</span>, <span class="n">0</span>, <span class="n">0</span>) <span class="k">else</span> <span class="s">"BLENDER_EEVEE_NEXT"</span>
<span class="k">def</span> fail(msg, code):
print(<span class="s">f"</span><span class="s">ERROR: </span>{msg}<span class="s">"</span>, file=sys.stderr)
<span class="k">return</span> code
<span class="k">def</span> triangle_count(mesh):
mesh.calc_loop_triangles()
<span class="k">return</span> len(mesh.loop_triangles)
<span class="k">def</span> evaluated_triangle_count(obj):
<span class="c"># Duplicated from snippets/lod_chain.py / decimate_to_budget.py (not a package).</span>
depsgraph = bpy.context.evaluated_depsgraph_get()
eval_obj = obj.evaluated_get(depsgraph)
eval_mesh = eval_obj.to_mesh()
<span class="k">try</span>:
eval_mesh.calc_loop_triangles()
<span class="k">return</span> len(eval_mesh.loop_triangles)
<span class="k">finally</span>:
eval_obj.to_mesh_clear()
<span class="k">def</span> log_radius(u, z):
<span class="s">"""Radius of the log's side at angle u and height z.
One function owns the surface. The iron band, the assertions and the
mesh all evaluate it, so the band cannot drift off the wood when a
dimension changes.
"""</span>
zt = z / BLOCK_H
taper = <span class="n">1.0</span> - BLOCK_TAPER * zt
wobble = <span class="n">1.0</span>
<span class="k">for</span> freq, phase, amp <span class="k">in</span> WOBBLE:
wobble += amp * math.sin(freq * u + phase + WOBBLE_TWIST * freq * zt)
<span class="k">return</span> BLOCK_R * taper * wobble
<span class="k">def</span> rim_scale(u):
<span class="s">"""Chipped top rim. Always below 1.0, so the widest point of the block
stays on the body and the rim cannot become the AABB."""</span>
chip = <span class="n">0.5</span> * (<span class="n">1.0</span> + math.sin(<span class="n">5.0</span> * u + <span class="n">1.7</span>))
<span class="k">return</span> TOP_RIM_SCALE - TOP_RIM_CHIP * chip
<span class="k">def</span> top_dz(u, rr):
<span class="s">"""Dish, hack scarring and radial checks on the sawn top.
Dish and scars vanish at the rim; the checks do not, because a drying
check opens widest at the edge and notches it.
"""</span>
scar = <span class="n">0.5</span> * (<span class="n">1.0</span> + math.sin(<span class="n">3.0</span> * u + <span class="n">0.9</span>))
drop = TOP_DISH * (<span class="n">1.0</span> - rr * rr) + TOP_SCAR * scar * (<span class="n">1.0</span> - rr)
<span class="k">for</span> angle, depth <span class="k">in</span> TOP_CRACKS:
d = (u - angle + math.pi) % (<span class="n">2.0</span> * math.pi) - math.pi
drop += (
depth
* math.exp(-((d / TOP_CRACK_WIDTH) ** <span class="n">2</span>))
* (<span class="n">0.25</span> + <span class="n">0.75</span> * rr)
)
<span class="k">return</span> -drop
<span class="k">def</span> fan_cap(bm, ring):
center = Vector((<span class="n">0.0</span>, <span class="n">0.0</span>, <span class="n">0.0</span>))
<span class="k">for</span> v <span class="k">in</span> ring:
center += v.co
center /= len(ring)
hub = bm.verts.new(center)
n = len(ring)
faces = [bm.faces.new((hub, ring[i], ring[(i + <span class="n">1</span>) % n])) <span class="k">for</span> i <span class="k">in</span> range(n)]
<span class="k">return</span> hub, faces
<span class="k">def</span> loft(bm, rings, cap_start=<span class="k">True</span>, cap_end=<span class="k">True</span>):
<span class="s">"""Sweep equal-length vertex rings into a closed shell.
Returns (verts, rows, caps): rows[i] holds the faces between ring i and
ring i+1, so a caller can give the sawn rim a different material slot
from the bark side without re-deriving which faces those are.
"""</span>
vert_rings = [[bm.verts.new(p) <span class="k">for</span> p <span class="k">in</span> ring] <span class="k">for</span> ring <span class="k">in</span> rings]
bm.verts.ensure_lookup_table()
n = len(vert_rings[<span class="n">0</span>])
rows = []
<span class="k">for</span> a, b <span class="k">in</span> zip(vert_rings, vert_rings[<span class="n">1</span>:]):
row = []
<span class="k">for</span> i <span class="k">in</span> range(n):
j = (i + <span class="n">1</span>) % n
row.append(bm.faces.new((a[i], a[j], b[j], b[i])))
rows.append(row)
verts = [v <span class="k">for</span> ring <span class="k">in</span> vert_rings <span class="k">for</span> v <span class="k">in</span> ring]
caps = []
<span class="k">if</span> cap_start:
hub, faces = fan_cap(bm, vert_rings[<span class="n">0</span>])
verts.append(hub)
caps.append(faces)
<span class="k">if</span> cap_end:
hub, faces = fan_cap(bm, vert_rings[-<span class="n">1</span>])
verts.append(hub)
caps.append(faces)
<span class="k">return</span> verts, rows, caps
<span class="k">def</span> loft_cyclic(bm, sections):
<span class="s">"""Sweep a closed cross-section around a closed path (a hoop)."""</span>
vert_rings = [[bm.verts.new(p) <span class="k">for</span> p <span class="k">in</span> s] <span class="k">for</span> s <span class="k">in</span> sections]
bm.verts.ensure_lookup_table()
m = len(vert_rings)
n = len(vert_rings[<span class="n">0</span>])
faces = []
<span class="k">for</span> k <span class="k">in</span> range(m):
a = vert_rings[k]
b = vert_rings[(k + <span class="n">1</span>) % m]
<span class="k">for</span> i <span class="k">in</span> range(n):
j = (i + <span class="n">1</span>) % n
faces.append(bm.faces.new((a[i], a[j], b[j], b[i])))
<span class="k">return</span> [v <span class="k">for</span> ring <span class="k">in</span> vert_rings <span class="k">for</span> v <span class="k">in</span> ring], faces
<span class="k">def</span> chamfered_rect(he, hs, chamfer, segs):
<span class="s">"""Rectangle corner loop with quarter-arc corners, walked CCW.
``segs`` of 1 gives a flat chamfer; higher values round it, which is how
the bake's high-poly differs from the shipped low-poly.
"""</span>
c = max(<span class="n">1e-5</span>, min(chamfer, <span class="n">0.35</span> * he, <span class="n">0.35</span> * hs))
corners = (
(he - c, hs - c, <span class="n">0.0</span>),
(-(he - c), hs - c, <span class="n">0.5</span> * math.pi),
(-(he - c), -(hs - c), math.pi),
(he - c, -(hs - c), <span class="n">1.5</span> * math.pi),
)
pts = []
<span class="k">for</span> cx, cy, a0 <span class="k">in</span> corners:
<span class="k">for</span> k <span class="k">in</span> range(segs + <span class="n">1</span>):
a = a0 + <span class="n">0.5</span> * math.pi * (k / segs)
pts.append((cx + c * math.cos(a), cy + c * math.sin(a)))
<span class="k">return</span> pts
<span class="k">def</span> build_log(bm, segs):
<span class="s">"""Log round: body, chamfered rims, and a dished, hacked top face.
The top cap is a ring stack rather than a single fan so the sawn face
can carry the dish and the hack scars. A flat pale disc up there is what
made the old piece read as a lidded pail.
"""</span>
us = [i * (<span class="n">2.0</span> * math.pi / segs) <span class="k">for</span> i <span class="k">in</span> range(segs)]
rings = []
<span class="k">for</span> z, scale <span class="k">in</span> BLOCK_RINGS[:-<span class="n">1</span>]:
rings.append(
[
Vector(
(
log_radius(u, z) * scale * math.cos(u),
log_radius(u, z) * scale * math.sin(u),
z,
)
)
<span class="k">for</span> u <span class="k">in</span> us
]
)
rim = [log_radius(u, BLOCK_H) * rim_scale(u) <span class="k">for</span> u <span class="k">in</span> us]
rings.append(
[
Vector((r * math.cos(u), r * math.sin(u), BLOCK_H + top_dz(u, <span class="n">1.0</span>)))
<span class="k">for</span> r, u <span class="k">in</span> zip(rim, us)
]
)
body_rows = len(rings) - <span class="n">1</span>
<span class="k">for</span> rr <span class="k">in</span> TOP_CAP_RINGS:
rings.append(
[
Vector(
(
r * rr * math.cos(u),
r * rr * math.sin(u),
BLOCK_H + top_dz(u, rr),
)
)
<span class="k">for</span> r, u <span class="k">in</span> zip(rim, us)
]
)
verts, rows, caps = loft(bm, rings)
<span class="c"># Bark on the sides and down to the ground; pale end grain on both sawn</span>
<span class="c"># faces and the top rim. A pale bottom chamfer ran a light ring round</span>
<span class="c"># the floor line, which is the foot of a tub, not the butt of a log.</span>
bark = [face <span class="k">for</span> row <span class="k">in</span> rows[:body_rows - <span class="n">1</span>] <span class="k">for</span> face <span class="k">in</span> row]
grain = list(rows[body_rows - <span class="n">1</span>])
<span class="k">for</span> row <span class="k">in</span> rows[body_rows:]:
grain.extend(row)
<span class="k">for</span> cap <span class="k">in</span> caps:
grain.extend(cap)
<span class="k">return</span> verts, bark, grain
<span class="k">def</span> lap_thickness(u):
<span class="s">"""Extra outer thickness of the hoop's lap joint at angle u."""</span>
d = (u - LAP_U0) % (<span class="n">2.0</span> * math.pi)
span = LAP_U1 - LAP_U0
<span class="k">if</span> d <= LAP_STEP:
<span class="k">return</span> LAP_T * d / LAP_STEP
<span class="k">if</span> d <= span:
<span class="k">return</span> LAP_T
<span class="k">if</span> d <= span + LAP_TAPER:
<span class="k">return</span> LAP_T * (<span class="n">1.0</span> - (d - span) / LAP_TAPER)
<span class="k">return</span> <span class="n">0.0</span>
<span class="k">def</span> band_mean_radius(segs):
mid_z = <span class="n">0.5</span> * (BAND_Z0 + BAND_Z1)
<span class="k">return</span> sum(
log_radius(i * (<span class="n">2.0</span> * math.pi / segs), mid_z) <span class="k">for</span> i <span class="k">in</span> range(segs)
) / segs
<span class="k">def</span> band_host_radii(u, round_band, mean_r):
<span class="s">"""Log radius the hoop is built on, at its bottom and top edge."""</span>
<span class="k">if</span> round_band:
<span class="k">return</span> mean_r, mean_r
<span class="k">return</span> log_radius(u, BAND_Z0), log_radius(u, BAND_Z1)
<span class="k">def</span> band_outer_radius(u, z, round_band, mean_r):
<span class="s">"""The hoop's outer face at angle u and height z, lap included."""</span>
r0, r1 = band_host_radii(u, round_band, mean_r)
za = BAND_Z0 + BAND_CHAMFER
zb = BAND_Z1 - BAND_CHAMFER
k = (z - za) / (zb - za)
<span class="k">return</span> r0 + (r1 - r0) * k + BAND_PROUD + lap_thickness(u)
<span class="k">def</span> band_angles(segs):
<span class="s">"""Log-segment angles plus every kink of the lap and every rivet."""</span>
us = {i * (<span class="n">2.0</span> * math.pi / segs) <span class="k">for</span> i <span class="k">in</span> range(segs)}
us.update(
(
LAP_U0,
LAP_U0 + LAP_STEP,
LAP_U1,
LAP_U1 + LAP_TAPER,
)
)
us.update(RIVET_US)
<span class="k">return</span> sorted(u % (<span class="n">2.0</span> * math.pi) <span class="k">for</span> u <span class="k">in</span> us)
<span class="k">def</span> build_band(bm, segs, round_band):
<span class="s">"""Iron hoop, generated on the log's own surface.
``round_band`` is the falsifier: the hoop is generated on a circle of
the mean radius instead, which is exactly what made the old torus sink
into the wood on one side and float off it on the other.
"""</span>
mean_r = band_mean_radius(segs)
sections = []
c = BAND_CHAMFER
<span class="k">for</span> u <span class="k">in</span> band_angles(segs):
cu, su = math.cos(u), math.sin(u)
r0, r1 = band_host_radii(u, round_band, mean_r)
lap = lap_thickness(u)
profile = (
(r0 - BAND_BITE, BAND_Z0),
(r0 + BAND_PROUD + lap - c, BAND_Z0),
(r0 + BAND_PROUD + lap, BAND_Z0 + c),
(r1 + BAND_PROUD + lap, BAND_Z1 - c),
(r1 + BAND_PROUD + lap - c, BAND_Z1),
(r1 - BAND_BITE, BAND_Z1),
)
sections.append([Vector((r * cu, r * su, z)) <span class="k">for</span> r, z <span class="k">in</span> profile])
<span class="k">return</span> loft_cyclic(bm, sections)
<span class="k">def</span> build_rivets(bm, segs, round_band, float_out):
<span class="s">"""Domed rivet heads through the lap, seated into the band's own face.
Each head is placed from ``band_outer_radius`` at its own angle, which
is a band section, so the seat is measured against the exact surface.
``float_out`` is the falsifier: it moves every head off the lap.
"""</span>
mean_r = band_mean_radius(segs)
zc = <span class="n">0.5</span> * (BAND_Z0 + BAND_Z1)
<span class="k">def</span> surface_point(u, z):
r = band_outer_radius(u, z, round_band, mean_r)
<span class="k">return</span> Vector((r * math.cos(u), r * math.sin(u), z))
verts, faces = [], []
<span class="k">for</span> u <span class="k">in</span> RIVET_US:
<span class="c"># Aim the head down the band's own surface normal. The log is out</span>
<span class="c"># of round, so its surface is not square to the radial: across one</span>
<span class="c"># head the radius falls 1.4 mm, and a radially aimed head sank on</span>
<span class="c"># one side and lifted on the other.</span>
eps = <span class="n">1e-4</span>
du = surface_point(u + eps, zc) - surface_point(u - eps, zc)
dz = surface_point(u, zc + eps) - surface_point(u, zc - eps)
normal = du.cross(dz).normalized()
<span class="k">if</span> normal.dot(Vector((math.cos(u), math.sin(u), <span class="n">0.0</span>))) < <span class="n">0.0</span>:
normal = -normal
tang = du.normalized()
up = normal.cross(tang).normalized()
center = surface_point(u, zc) + normal * float_out
stations = ((-RIVET_BITE / RIVET_H, <span class="n">1.0</span>),) + RIVET_RINGS
rings = []
<span class="k">for</span> h, scale <span class="k">in</span> stations:
ring = []
<span class="k">for</span> i <span class="k">in</span> range(RIVET_SEGS):
a = i * (<span class="n">2.0</span> * math.pi / RIVET_SEGS)
offset = (tang * math.cos(a) + up * math.sin(a)) * (RIVET_R * scale)
ring.append(center + normal * (h * RIVET_H) + offset)
rings.append(ring)
v, rows, caps = loft(bm, rings)
verts.extend(v)
faces.extend(face <span class="k">for</span> row <span class="k">in</span> rows <span class="k">for</span> face <span class="k">in</span> row)
faces.extend(face <span class="k">for</span> cap <span class="k">in</span> caps <span class="k">for</span> face <span class="k">in</span> cap)
<span class="k">return</span> verts, faces
<span class="k">def</span> axe_frame():
<span class="s">"""Orthonormal head frame plus the haft direction.
``f`` runs poll to bit, ``s`` is the cheek normal and ``eh`` is the edge
direction. The haft is deliberately not perpendicular to ``f``: the 18
degrees between them is the hang angle.
"""</span>
f = Vector((math.cos(AXE_BIT_ANGLE), <span class="n">0.0</span>, math.sin(AXE_BIT_ANGLE)))
s = Vector((<span class="n">0.0</span>, <span class="n">1.0</span>, <span class="n">0.0</span>))
eh = s.cross(f).normalized()
haft = Vector((math.cos(AXE_HAFT_ANGLE), <span class="n">0.0</span>, math.sin(AXE_HAFT_ANGLE)))
bit = Vector(BIT_CENTER)
poll = bit - f * HEAD_LEN
eye = poll + f * (HEAD_EYE_T * HEAD_LEN)
<span class="k">return</span> f, s, eh, haft, poll, eye
<span class="k">def</span> build_head(bm, chamfer_segs):
f, s, eh, _haft, poll, _eye = axe_frame()
rings = []
<span class="k">for</span> t, he, hs <span class="k">in</span> HEAD_SECTIONS:
center = poll + f * (t * HEAD_LEN)
rings.append(
[
center + eh * px + s * py
<span class="k">for</span> px, py <span class="k">in</span> chamfered_rect(he, hs, HEAD_CHAMFER, chamfer_segs)
]
)
verts, rows, caps = loft(bm, rings)
faces = [face <span class="k">for</span> row <span class="k">in</span> rows <span class="k">for</span> face <span class="k">in</span> row]
faces.extend(face <span class="k">for</span> cap <span class="k">in</span> caps <span class="k">for</span> face <span class="k">in</span> cap)
<span class="k">return</span> verts, faces
<span class="k">def</span> haft_curve():
<span class="s">"""Start, control and end points of the haft's centreline Bezier."""</span>
_f, _s, _eh, haft, _poll, eye = axe_frame()
start = eye - haft * HAFT_DROP
end = eye + haft * HAFT_LEN
<span class="c"># A straight stick reads as a broom. The bow is a quadratic Bezier</span>
<span class="c"># leaning away from the bit, the way a hung haft curves.</span>
bit_dir = Vector((math.cos(AXE_BIT_ANGLE), <span class="n">0.0</span>, math.sin(AXE_BIT_ANGLE)))
mid = (start + end) * <span class="n">0.5</span> - bit_dir * HAFT_BOW
<span class="k">return</span> start, mid, end
<span class="k">def</span> haft_point(t):
start, mid, end = haft_curve()
omt = <span class="n">1.0</span> - t
p = start * (omt * omt) + mid * (<span class="n">2.0</span> * omt * t) + end * (t * t)
dp = (mid - start) * (<span class="n">2.0</span> * omt) + (end - mid) * (<span class="n">2.0</span> * t)
<span class="k">return</span> p, dp.normalized()
<span class="k">def</span> haft_rings(scale, segs, oval=HAFT_OVAL):
f, s, _eh, _haft, _poll, _eye = axe_frame()
rings = []
<span class="k">for</span> t, radius <span class="k">in</span> HAFT_SECTIONS:
p, tangent = haft_point(t)
side = s.cross(tangent).normalized()
up = tangent.cross(side).normalized()
<span class="c"># The knob hooks toward the bit: smoothstep in over the last fifth.</span>
k = min(<span class="n">1.0</span>, max(<span class="n">0.0</span>, (t - <span class="n">0.80</span>) / <span class="n">0.20</span>))
hook = HAFT_HOOK * k * k * (<span class="n">3.0</span> - <span class="n">2.0</span> * k)
p = p + side * (hook <span class="k">if</span> side.dot(f) > <span class="n">0.0</span> <span class="k">else</span> -hook)
<span class="c"># ``side`` lies in the swing plane, ``up`` across the cheeks; the</span>
<span class="c"># oval is wide along the first and keeps the eye fit on the second.</span>
<span class="c"># ``scale`` thickens across the cheeks only: that is the dimension</span>
<span class="c"># the eye has to clear, and the one --fat-haft breaks. Scaling the</span>
<span class="c"># swing-plane width too grew the knob past the bounding box, so</span>
<span class="c"># the falsifier failed exit 8 instead of its own budget.</span>
ring = []
<span class="k">for</span> i <span class="k">in</span> range(segs):
a = i * (<span class="n">2.0</span> * math.pi / segs)
ring.append(
p
+ side * (radius * oval * math.cos(a))