Translate field value segment composition helpers
This commit is contained in:
parent
60db427fc6
commit
b860bd8bb8
8 changed files with 408 additions and 14 deletions
|
|
@ -124,12 +124,15 @@ Completed pie chart entry:
|
|||
Completed field value helper entry:
|
||||
|
||||
- `docs/research/translations/shriinivas-fieldvalue-digit-at.md`
|
||||
- Source groups: `Create Decimal`, `Create Segment`, `Digit At`
|
||||
- Source groups: `Create Decimal`, `Create Segment`, `Seven Segments`,
|
||||
`Delete Segments`, `Digit At`
|
||||
- Verification: decimal glyph geometry matches source with sorted max vertex
|
||||
delta `0.0`; segment geometry matches horizontal and vertical source cases
|
||||
with sorted max vertex delta `0.0`; digit scalar helper matches source
|
||||
behavior across four number/position cases by driving `Mesh Line.Count` with
|
||||
the result.
|
||||
with sorted max vertex delta `0.0`; seven-segment chassis geometry matches
|
||||
source with 74 vertices and sorted max vertex delta `0.0`; digit scalar
|
||||
helper matches source behavior across four number/position cases by driving
|
||||
`Mesh Line.Count` with the result; delete-mask scalar helper matches source
|
||||
across 195 digit/segment-position cases with zero mismatches.
|
||||
|
||||
## Extraction Workflow
|
||||
|
||||
|
|
|
|||
|
|
@ -137,6 +137,39 @@ part instead of another anonymous mesh primitive.
|
|||
|
||||
Tiny named parts are not overengineering when they carry stable intent.
|
||||
|
||||
## Chassis Groups Compose Parts
|
||||
|
||||
Once a part has a stable contract, the next group up should read like assembly,
|
||||
not reinvention. `Seven Segments` does not know how to pinch bar tips; it calls
|
||||
`Create Segment` seven times with different orientation, length, thickness, and
|
||||
offset controls, then joins the results with a decimal dot.
|
||||
|
||||
The useful pattern is:
|
||||
|
||||
```text
|
||||
tested part -> repeated placements -> joined chassis -> later visibility logic
|
||||
```
|
||||
|
||||
Metaphor: the lower group machines the bolt. The chassis group decides where
|
||||
the bolts go. Keep those jobs separate so later graph layers can remove,
|
||||
materialize, or transform parts without reopening the primitive geometry logic.
|
||||
|
||||
## Boolean Thickets Are Often Tables
|
||||
|
||||
Large boolean node regions can look more algorithmic than they are. `Delete
|
||||
Segments` is mostly a truth table: compare the digit, compare the segment
|
||||
position, combine masks, and decide whether that part should disappear.
|
||||
|
||||
When a graph is a table, translate it as a table with named clauses:
|
||||
|
||||
```text
|
||||
input values -> grouped masks -> digit-specific clauses -> final OR
|
||||
```
|
||||
|
||||
The source node count is not sacred. The behavior is. A compact translation is
|
||||
acceptable when full-grid verification proves every input pair still lands on
|
||||
the same boolean result.
|
||||
|
||||
## Field Masks Are Chisels
|
||||
|
||||
You can sculpt simple meshes by combining a regular seed mesh with field masks.
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
- Source groups:
|
||||
- `Create Decimal`
|
||||
- `Create Segment`
|
||||
- `Seven Segments`
|
||||
- `Delete Segments`
|
||||
- `Digit At`
|
||||
- Geometry Script recreation:
|
||||
`examples/geometry_script/shriinivas_fieldvalue.py`
|
||||
|
|
@ -14,11 +16,12 @@
|
|||
## Why This Graph
|
||||
|
||||
`fieldvalue.blend` contains a large seven-segment field display system. The full
|
||||
`Field Value` graph has 176 nodes, so the first honest targets are small
|
||||
helpers: `Create Decimal` and `Digit At`.
|
||||
`Field Value` graph has 176 nodes, so the first honest targets are helpers that
|
||||
build the digit chassis before the full display logic is attempted.
|
||||
|
||||
Together they show the first display-system layers: tiny glyph geometry,
|
||||
field-sculpted segment geometry, and value-only digit extraction.
|
||||
field-sculpted segment geometry, segment composition, segment visibility masks,
|
||||
and value-only digit extraction.
|
||||
|
||||
## Create Decimal Map
|
||||
|
||||
|
|
@ -88,6 +91,57 @@ Metaphor: the segment starts as a plain rectangular tile. The position field is
|
|||
a stencil laid over its vertices. The end-corner vertices get pinched into tips,
|
||||
while the middle vertices stay put. It is a chisel, not a sculpting spree.
|
||||
|
||||
## Seven Segments Map
|
||||
|
||||
Source group: `Seven Segments`
|
||||
|
||||
Geometry Script group: `VG Seven Segments`
|
||||
|
||||
Mechanism:
|
||||
|
||||
- Divide horizontal and vertical segment sizes by two to get left/right and
|
||||
upper/lower placement extents.
|
||||
- Subtract `X Separation` from horizontal length and `Y Seperation` from
|
||||
vertical length so the bars leave small gaps.
|
||||
- Create four vertical bars with `X Major = False`:
|
||||
lower left, upper left, lower right, and upper right.
|
||||
- Create three horizontal bars with `X Major = True`:
|
||||
bottom, middle, and top.
|
||||
- Create the decimal dot with radius `Horizontal Segment Thickness / 2`.
|
||||
- Join dot plus seven bars into one `bars` output.
|
||||
|
||||
Metaphor: `Create Segment` is a single machined stroke; `Seven Segments` is the
|
||||
digit chassis. It bolts seven strokes and one punctuation bead onto a shared
|
||||
frame so later graph layers can decide which pieces stay visible.
|
||||
|
||||
## Delete Segments Map
|
||||
|
||||
Source group: `Delete Segments`
|
||||
|
||||
Geometry Script group: `VG Delete Segments`
|
||||
|
||||
Inputs:
|
||||
|
||||
- `Digit`
|
||||
- `Segment Position`
|
||||
|
||||
Output:
|
||||
|
||||
- `result`
|
||||
|
||||
Mechanism:
|
||||
|
||||
- Shift `Digit` down by one.
|
||||
- Group `Segment Position` into repeated pair masks:
|
||||
`0/1`, `2/3`, `4/5`, `6/7`, `8/9`, `10/11`, `12/13`, plus singleton `14`.
|
||||
- Compare the shifted digit against the source's digit cases.
|
||||
- For each digit case, return true when that segment-position mask should be
|
||||
deleted.
|
||||
- OR all digit-specific delete clauses into the final `result`.
|
||||
|
||||
Metaphor: `Delete Segments` is not a sculptor. It is a stencil card. Given a
|
||||
digit and a slot on the chassis, it punches out the slots that should go dark.
|
||||
|
||||
## Verification
|
||||
|
||||
Run:
|
||||
|
|
@ -107,10 +161,12 @@ Results from Blender 5.1.1:
|
|||
| Create Decimal vertices | 32 | 32 | 0.0 | accepted |
|
||||
| Create Segment horizontal vertices | 6 | 6 | 0.0 | accepted |
|
||||
| Create Segment vertical vertices | 6 | 6 | 0.0 | accepted |
|
||||
| Seven Segments vertices | 74 | 74 | 0.0 | accepted |
|
||||
| Digit At `1234.0`, position `0` | 4 | 4 | 0 | accepted |
|
||||
| Digit At `1234.0`, position `1` | 3 | 3 | 0 | accepted |
|
||||
| Digit At `98765.0`, position `2` | 7 | 7 | 0 | accepted |
|
||||
| Digit At `120305.0`, position `3` | 0 | 0 | 0 | accepted |
|
||||
| Delete Segments grid | 195 cases | 195 cases | 0 mismatches | accepted |
|
||||
|
||||
## Lessons
|
||||
|
||||
|
|
@ -127,3 +183,10 @@ Results from Blender 5.1.1:
|
|||
- Field masks can act as chisels. In `Create Segment`, comparisons over
|
||||
position decide which vertices are allowed to move, creating pointed tips
|
||||
without hand-authoring mesh coordinates.
|
||||
- Composition groups should preserve part boundaries in the script even when
|
||||
the output is one joined geometry stream. The source `Seven Segments` graph is
|
||||
easier to reason about as four vertical bars, three horizontal bars, and one
|
||||
dot than as a pile of joined anonymous geometry.
|
||||
- Dense boolean graphs often hide lookup tables. Translate them into named
|
||||
clauses and verify over the full input grid instead of preserving every source
|
||||
`OR` node as ceremony.
|
||||
|
|
|
|||
|
|
@ -14,6 +14,26 @@ load_repo_geometry_script()
|
|||
from geometry_script import * # noqa: F403 - Geometry Script exposes node functions as DSL globals.
|
||||
|
||||
|
||||
def _int_equal(value, target: int):
|
||||
return compare(
|
||||
operation=Compare.Operation.EQUAL,
|
||||
data_type=Compare.DataType.INT,
|
||||
mode=Compare.Mode.ELEMENT,
|
||||
a=value,
|
||||
b=target,
|
||||
)
|
||||
|
||||
|
||||
def _float_equal(value, target: float):
|
||||
return compare(
|
||||
operation=Compare.Operation.EQUAL,
|
||||
data_type=Compare.DataType.FLOAT,
|
||||
mode=Compare.Mode.ELEMENT,
|
||||
a=value,
|
||||
b=target,
|
||||
)
|
||||
|
||||
|
||||
@tree("VG Create Decimal")
|
||||
def vg_create_decimal(vertical_segment_size: Float = 2.0, radius: Float = 0.0):
|
||||
dot = mesh_circle(fill_type=MeshCircle.FillType.NGON, vertices=32, radius=radius)
|
||||
|
|
@ -127,11 +147,170 @@ def vg_create_segment(
|
|||
return {"Segment": segment.set_position(offset=total_offset)}
|
||||
|
||||
|
||||
@tree("VG Seven Segments")
|
||||
def vg_seven_segments(
|
||||
horizontal_segment_size: Float = 2.0,
|
||||
horizontal_segment_thickness: Float = 0.5,
|
||||
vertical_segment_size: Float = 2.0,
|
||||
vertical_segment_thickness: Float = 0.5,
|
||||
x_separation: Float = 0.1,
|
||||
y_seperation: Float = 0.1,
|
||||
tip_sharpness: Float = 1.0,
|
||||
):
|
||||
half_horizontal = math(operation=Math.Operation.DIVIDE, value=(horizontal_segment_size, 2.0))
|
||||
half_vertical = math(operation=Math.Operation.DIVIDE, value=(vertical_segment_size, 2.0))
|
||||
negative_half_horizontal = math(operation=Math.Operation.MULTIPLY, value=(-1.0, half_horizontal))
|
||||
negative_half_vertical = math(operation=Math.Operation.MULTIPLY, value=(-1.0, half_vertical))
|
||||
|
||||
vertical_bar_length = math(operation=Math.Operation.SUBTRACT, value=(vertical_segment_size, y_seperation))
|
||||
horizontal_bar_length = math(operation=Math.Operation.SUBTRACT, value=(horizontal_segment_size, x_separation))
|
||||
|
||||
lower_left = vg_create_segment(
|
||||
x_major=False,
|
||||
segment_length_along_x=vertical_segment_thickness,
|
||||
segment_length_along_y=vertical_bar_length,
|
||||
secondary_axis_segment_thickness=horizontal_segment_thickness,
|
||||
sharpness=tip_sharpness,
|
||||
offset=combine_xyz(x=negative_half_horizontal, y=negative_half_vertical, z=0.0),
|
||||
)
|
||||
upper_left = vg_create_segment(
|
||||
x_major=False,
|
||||
segment_length_along_x=vertical_segment_thickness,
|
||||
segment_length_along_y=vertical_bar_length,
|
||||
secondary_axis_segment_thickness=horizontal_segment_thickness,
|
||||
sharpness=tip_sharpness,
|
||||
offset=combine_xyz(x=negative_half_horizontal, y=half_vertical, z=0.0),
|
||||
)
|
||||
lower_right = vg_create_segment(
|
||||
x_major=False,
|
||||
segment_length_along_x=vertical_segment_thickness,
|
||||
segment_length_along_y=vertical_bar_length,
|
||||
secondary_axis_segment_thickness=horizontal_segment_thickness,
|
||||
sharpness=tip_sharpness,
|
||||
offset=combine_xyz(x=half_horizontal, y=negative_half_vertical, z=0.0),
|
||||
)
|
||||
upper_right = vg_create_segment(
|
||||
x_major=False,
|
||||
segment_length_along_x=vertical_segment_thickness,
|
||||
segment_length_along_y=vertical_bar_length,
|
||||
secondary_axis_segment_thickness=horizontal_segment_thickness,
|
||||
sharpness=tip_sharpness,
|
||||
offset=combine_xyz(x=half_horizontal, y=half_vertical, z=0.0),
|
||||
)
|
||||
|
||||
bottom = vg_create_segment(
|
||||
x_major=True,
|
||||
segment_length_along_x=horizontal_bar_length,
|
||||
segment_length_along_y=horizontal_segment_thickness,
|
||||
secondary_axis_segment_thickness=vertical_segment_thickness,
|
||||
sharpness=tip_sharpness,
|
||||
offset=combine_xyz(x=0.0, y=math(operation=Math.Operation.MULTIPLY, value=(-1.0, vertical_segment_size)), z=0.0),
|
||||
)
|
||||
middle = vg_create_segment(
|
||||
x_major=True,
|
||||
segment_length_along_x=horizontal_bar_length,
|
||||
segment_length_along_y=horizontal_segment_thickness,
|
||||
secondary_axis_segment_thickness=vertical_segment_thickness,
|
||||
sharpness=tip_sharpness,
|
||||
offset=(0.0, 0.0, 0.0),
|
||||
)
|
||||
top = vg_create_segment(
|
||||
x_major=True,
|
||||
segment_length_along_x=horizontal_bar_length,
|
||||
segment_length_along_y=horizontal_segment_thickness,
|
||||
secondary_axis_segment_thickness=vertical_segment_thickness,
|
||||
sharpness=tip_sharpness,
|
||||
offset=combine_xyz(x=0.0, y=vertical_segment_size, z=0.0),
|
||||
)
|
||||
dot = vg_create_decimal(
|
||||
vertical_segment_size=vertical_segment_size,
|
||||
radius=math(operation=Math.Operation.DIVIDE, value=(horizontal_segment_thickness, 2.0)),
|
||||
)
|
||||
|
||||
return {
|
||||
"bars": join_geometry(
|
||||
geometry=[
|
||||
dot,
|
||||
top,
|
||||
middle,
|
||||
bottom,
|
||||
upper_right,
|
||||
lower_right,
|
||||
upper_left,
|
||||
lower_left,
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@tree("VG Delete Segments")
|
||||
def vg_delete_segments(digit: Int = 0, segment_position: Int = 0):
|
||||
digit_minus_one = math(operation=Math.Operation.SUBTRACT, value=(digit, 1.0))
|
||||
|
||||
p01 = _int_equal(segment_position, 0) | _int_equal(segment_position, 1)
|
||||
p23 = _int_equal(segment_position, 2) | _int_equal(segment_position, 3)
|
||||
p45 = _int_equal(segment_position, 4) | _int_equal(segment_position, 5)
|
||||
p67 = _int_equal(segment_position, 6) | _int_equal(segment_position, 7)
|
||||
p89 = _int_equal(segment_position, 8) | _int_equal(segment_position, 9)
|
||||
p1011 = _int_equal(segment_position, 10) | _int_equal(segment_position, 11)
|
||||
p1213 = _int_equal(segment_position, 12) | _int_equal(segment_position, 13)
|
||||
p14 = _int_equal(segment_position, 14)
|
||||
|
||||
d_minus_one = _float_equal(digit_minus_one, -1.0)
|
||||
d0 = _float_equal(digit_minus_one, 0.0)
|
||||
d1 = _float_equal(digit_minus_one, 1.0)
|
||||
d2 = _float_equal(digit_minus_one, 2.0)
|
||||
d3 = _float_equal(digit_minus_one, 3.0)
|
||||
d4 = _float_equal(digit_minus_one, 4.0)
|
||||
d5 = _float_equal(digit_minus_one, 5.0)
|
||||
d6 = _float_equal(digit_minus_one, 6.0)
|
||||
d7 = _float_equal(digit_minus_one, 7.0)
|
||||
d9 = _float_equal(digit_minus_one, 9.0)
|
||||
d10 = _float_equal(digit_minus_one, 10.0)
|
||||
d11 = _float_equal(digit_minus_one, 11.0)
|
||||
|
||||
delete_for_minus_one = d_minus_one
|
||||
delete_for_zero = d0 & p1011
|
||||
delete_for_one = d1 & ~(p45 | p67)
|
||||
delete_for_two = d2 & (p23 | p45 | p14)
|
||||
delete_for_three = d3 & (p01 | p23 | p14)
|
||||
delete_for_four = d4 & (p89 | p1213 | p01 | p14)
|
||||
delete_for_five = d5 & (p01 | p67 | p14)
|
||||
delete_for_six = d6 & (p67 | p14)
|
||||
delete_for_seven = d7 & ~(p1213 | p45 | p67)
|
||||
delete_for_nine = d9 & (p01 | p14)
|
||||
delete_for_ten = d10 & ~p1011
|
||||
delete_for_eleven = d11 & ~p14
|
||||
delete_for_decimal = p14 & ~d11
|
||||
|
||||
return (
|
||||
delete_for_eleven
|
||||
| delete_for_ten
|
||||
| delete_for_minus_one
|
||||
| delete_for_zero
|
||||
| delete_for_one
|
||||
| delete_for_two
|
||||
| delete_for_three
|
||||
| delete_for_four
|
||||
| delete_for_five
|
||||
| delete_for_six
|
||||
| delete_for_seven
|
||||
| delete_for_decimal
|
||||
| delete_for_nine
|
||||
)
|
||||
|
||||
|
||||
def _finalize_groups():
|
||||
import bpy
|
||||
|
||||
groups = []
|
||||
for name in ("VG Create Decimal", "VG Digit At", "VG Create Segment"):
|
||||
for name in (
|
||||
"VG Create Decimal",
|
||||
"VG Digit At",
|
||||
"VG Create Segment",
|
||||
"VG Seven Segments",
|
||||
"VG Delete Segments",
|
||||
):
|
||||
group = bpy.data.node_groups.get(name)
|
||||
if not group:
|
||||
continue
|
||||
|
|
@ -142,6 +321,15 @@ def _finalize_groups():
|
|||
item.name = "X Major"
|
||||
if item.item_type == "SOCKET" and item.in_out == "INPUT" and item.name in {"Radius", "Offset"}:
|
||||
item.name = item.name.lower()
|
||||
if item.item_type == "SOCKET" and item.in_out == "OUTPUT" and item.name == "Bars":
|
||||
item.name = "bars"
|
||||
if (
|
||||
name == "VG Delete Segments"
|
||||
and item.item_type == "SOCKET"
|
||||
and item.in_out == "OUTPUT"
|
||||
and item.name == "Result"
|
||||
):
|
||||
item.name = "result"
|
||||
groups.append(group)
|
||||
return groups
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,8 @@ The completed pie chart translation is
|
|||
|
||||
The completed field-value helper translation is
|
||||
`docs/research/translations/shriinivas-fieldvalue-digit-at.md`. It covers
|
||||
`Create Decimal`, `Create Segment`, and `Digit At` from `fieldvalue.blend`.
|
||||
`Create Decimal`, `Create Segment`, `Seven Segments`, `Delete Segments`, and
|
||||
`Digit At` from `fieldvalue.blend`.
|
||||
|
||||
`docs/research/procedural-doctrine.md` now stores the current intuitive model
|
||||
for mapping geometric ideas to Geometry Script: curves as rails, fields as
|
||||
|
|
@ -58,9 +59,8 @@ The GameCult fork is intentionally pruned to `main` plus the active
|
|||
`vibegeometry/blender-5-nested-tree-groups` branch. Upstream branch clutter
|
||||
should not be copied forward unless a future patch actually needs it.
|
||||
|
||||
The current next action is to continue `fieldvalue.blend` by translating the
|
||||
next composition helper, likely `Seven Segments` or `Delete Segments`, before
|
||||
attempting the full `Field Value` graph.
|
||||
The current next action is to continue `fieldvalue.blend` by inspecting
|
||||
`Next Digit`, `Geometry Nodes Group.002`, and then the full `Field Value` graph.
|
||||
|
||||
## Important Invariants
|
||||
|
||||
|
|
|
|||
|
|
@ -13,3 +13,5 @@
|
|||
{"ts": "2026-05-04T13:11:35+00:00", "type": "tooling", "status": "accepted", "note": "Created and pushed GameCult/VibeGeometry remote. Forked Geometry Script to GameCult/geometry-script, pushed branch vibegeometry/blender-5-nested-tree-groups, and opened upstream PR https://github.com/carson-katri/geometry-script/pull/69 for the nested @tree group reference fix."}
|
||||
{"ts": "2026-05-04T13:22:50+00:00", "type": "tooling", "status": "accepted", "note": "Pruned inherited upstream-only branches gh-pages and nodes_to_script from GameCult/geometry-script. The fork branch surface is intentionally main plus vibegeometry/blender-5-nested-tree-groups while upstream may retain its own historical branch soup."}
|
||||
{"ts": "2026-05-04T13:24:38+00:00", "type": "research", "status": "accepted", "note": "Upstream Geometry Script nodes_to_script branch is a real node-tree-to-script prototype from 2023-03-01. It adds operators/convert_tree.py, which walks a node tree and emits a @tree script text datablock, but it predates Blender 4 interface migration and later main-branch fixes, so VibeGeometry should treat it as a translation assistant candidate to port/test rather than a current drop-in dependency."}
|
||||
{"ts": "2026-05-04T13:30:24+00:00", "type": "implementation", "status": "accepted", "note": "Extended fieldvalue translation with Seven Segments -> VG Seven Segments. Verified against source with 74 vertices and sorted max vertex delta 0.0 in Blender 5.1.1. Doctrine added: chassis groups compose tested parts into a joined assembly while preserving part intent in script."}
|
||||
{"ts": "2026-05-04T13:34:19+00:00", "type": "implementation", "status": "accepted", "note": "Extended fieldvalue translation with Delete Segments -> VG Delete Segments. Verified source and translation across 195 digit/segment-position cases with zero mismatches by driving the boolean output into a Mesh Line count harness. Doctrine added: dense boolean node regions often encode lookup tables and should be translated into named clauses plus full-grid verification."}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ current_artifacts:
|
|||
- tools/vibegeometry_prepare_compaction.py
|
||||
- tools/inspect_blend_node_groups.py
|
||||
- tools/verify_cartesian_translations.py
|
||||
- tools/verify_piechart_translations.py
|
||||
- tools/verify_fieldvalue_translations.py
|
||||
- tools/geometry_script_loader.py
|
||||
pending_contracts:
|
||||
- schemas/scene-brief.schema.json
|
||||
|
|
@ -82,8 +84,8 @@ data_flow:
|
|||
- If state grows faster than understanding, cut it back.
|
||||
|
||||
current_status:
|
||||
summary: VibeGeometry has an initial persistence scaffold plus verified Geometry Script translations for inspected Shriinivas cartesian, pie chart, and field-value helper graph families.
|
||||
next_action: Continue fieldvalue.blend by translating the next composition helper, likely `Seven Segments` or `Delete Segments`, before attempting the full `Field Value` graph.
|
||||
summary: VibeGeometry has an initial persistence scaffold plus verified Geometry Script translations for inspected Shriinivas cartesian, pie chart, and field-value helper/chassis/mask graph families.
|
||||
next_action: Continue fieldvalue.blend by inspecting `Next Digit`, `Geometry Nodes Group.002`, and then the full `Field Value` graph.
|
||||
remotes:
|
||||
vibegeometry: https://github.com/GameCult/VibeGeometry
|
||||
geometry_script_fork: https://github.com/GameCult/geometry-script
|
||||
|
|
|
|||
|
|
@ -40,6 +40,17 @@ SEGMENT_CASES = [
|
|||
"offset": (-0.3, 0.25, 0.0),
|
||||
},
|
||||
]
|
||||
SEVEN_SEGMENTS_CASE = {
|
||||
"Horizontal Segment Size": 2.2,
|
||||
"Horizontal Segment Thickness": 0.42,
|
||||
"Vertical Segment Size": 1.7,
|
||||
"Vertical Segment Thickness": 0.36,
|
||||
"X Separation": 0.13,
|
||||
"Y Seperation": 0.17,
|
||||
"Tip Sharpness": 0.8,
|
||||
}
|
||||
DELETE_DIGITS = range(0, 13)
|
||||
DELETE_SEGMENT_POSITIONS = range(0, 15)
|
||||
|
||||
|
||||
def _load_translation() -> None:
|
||||
|
|
@ -89,6 +100,33 @@ def _build_count_wrapper(name: str, digit_group: bpy.types.GeometryNodeTree, inp
|
|||
return wrapper
|
||||
|
||||
|
||||
def _build_bool_count_wrapper(name: str, bool_group: bpy.types.GeometryNodeTree, inputs: dict[str, object]):
|
||||
wrapper = _new_geometry_group(name)
|
||||
nodes = wrapper.nodes
|
||||
links = wrapper.links
|
||||
bool_node = nodes.new("GeometryNodeGroup")
|
||||
bool_node.node_tree = bool_group
|
||||
for socket in bool_node.inputs:
|
||||
if socket.name in inputs:
|
||||
socket.default_value = inputs[socket.name]
|
||||
|
||||
switch_node = nodes.new("GeometryNodeSwitch")
|
||||
switch_node.input_type = "INT"
|
||||
_socket_by_name(switch_node.inputs, "False").default_value = 0
|
||||
_socket_by_name(switch_node.inputs, "True").default_value = 1
|
||||
links.new(_socket_by_name(bool_node.outputs, "result"), _socket_by_name(switch_node.inputs, "Switch"))
|
||||
|
||||
line = nodes.new("GeometryNodeMeshLine")
|
||||
line.mode = "OFFSET"
|
||||
line.count_mode = "TOTAL"
|
||||
_socket_by_name(line.inputs, "Offset").default_value = (1.0, 0.0, 0.0)
|
||||
links.new(_socket_by_name(switch_node.outputs, "Output"), _socket_by_name(line.inputs, "Count"))
|
||||
|
||||
group_output = nodes.new("NodeGroupOutput")
|
||||
links.new(_socket_by_name(line.outputs, "Mesh"), _socket_by_name(group_output.inputs, "Geometry"))
|
||||
return wrapper
|
||||
|
||||
|
||||
def _build_geometry_wrapper(name: str, source_group: bpy.types.GeometryNodeTree, inputs: dict[str, object], output: str):
|
||||
wrapper = _new_geometry_group(name)
|
||||
nodes = wrapper.nodes
|
||||
|
|
@ -192,6 +230,35 @@ def main() -> int:
|
|||
"ok": len(source_segment) == len(translated_segment) and max_delta <= 1e-6,
|
||||
}
|
||||
)
|
||||
source_seven_segments = _evaluated_vertices(
|
||||
_build_geometry_wrapper(
|
||||
"VG Verify Source Seven Segments",
|
||||
bpy.data.node_groups["Seven Segments"],
|
||||
SEVEN_SEGMENTS_CASE,
|
||||
"bars",
|
||||
)
|
||||
)
|
||||
translated_seven_segments = _evaluated_vertices(
|
||||
_build_geometry_wrapper(
|
||||
"VG Verify Translated Seven Segments",
|
||||
bpy.data.node_groups["VG Seven Segments"],
|
||||
SEVEN_SEGMENTS_CASE,
|
||||
"bars",
|
||||
)
|
||||
)
|
||||
seven_segments_delta = max(
|
||||
(math.dist(a, b) for a, b in zip(sorted(source_seven_segments), sorted(translated_seven_segments))),
|
||||
default=0.0,
|
||||
)
|
||||
results.append(
|
||||
{
|
||||
"case": {"seven_segments": SEVEN_SEGMENTS_CASE},
|
||||
"source_vertex_count": len(source_seven_segments),
|
||||
"translated_vertex_count": len(translated_seven_segments),
|
||||
"max_sorted_vertex_delta": seven_segments_delta,
|
||||
"ok": len(source_seven_segments) == len(translated_seven_segments) and seven_segments_delta <= 1e-6,
|
||||
}
|
||||
)
|
||||
for index, inputs in enumerate(CASES):
|
||||
source_count = _evaluated_vertex_count(_build_count_wrapper(f"VG Verify Source Digit {index}", source, inputs))
|
||||
translated_count = _evaluated_vertex_count(
|
||||
|
|
@ -205,6 +272,42 @@ def main() -> int:
|
|||
"ok": source_count == translated_count,
|
||||
}
|
||||
)
|
||||
delete_mismatches = []
|
||||
source_delete = bpy.data.node_groups["Delete Segments"]
|
||||
translated_delete = bpy.data.node_groups["VG Delete Segments"]
|
||||
checked = 0
|
||||
for digit in DELETE_DIGITS:
|
||||
for segment_position in DELETE_SEGMENT_POSITIONS:
|
||||
inputs = {"Digit": digit, "Segment Position": segment_position}
|
||||
source_count = _evaluated_vertex_count(
|
||||
_build_bool_count_wrapper(f"VG Verify Source Delete {digit}-{segment_position}", source_delete, inputs)
|
||||
)
|
||||
translated_count = _evaluated_vertex_count(
|
||||
_build_bool_count_wrapper(
|
||||
f"VG Verify Translated Delete {digit}-{segment_position}",
|
||||
translated_delete,
|
||||
inputs,
|
||||
)
|
||||
)
|
||||
checked += 1
|
||||
if source_count != translated_count:
|
||||
delete_mismatches.append(
|
||||
{
|
||||
"digit": digit,
|
||||
"segment_position": segment_position,
|
||||
"source_count": source_count,
|
||||
"translated_count": translated_count,
|
||||
}
|
||||
)
|
||||
results.append(
|
||||
{
|
||||
"case": "delete_segments_grid",
|
||||
"checked": checked,
|
||||
"mismatches": delete_mismatches[:10],
|
||||
"mismatch_count": len(delete_mismatches),
|
||||
"ok": not delete_mismatches,
|
||||
}
|
||||
)
|
||||
ok = all(result["ok"] for result in results)
|
||||
print("VG_FIELDVALUE_TRANSLATION_BEHAVIOR " + json.dumps({"ok": ok, "results": results}, sort_keys=True))
|
||||
return 0 if ok else 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue