diff --git a/docs/research/geonodes-translation-corpus.md b/docs/research/geonodes-translation-corpus.md index e22499f..c3333ec 100644 --- a/docs/research/geonodes-translation-corpus.md +++ b/docs/research/geonodes-translation-corpus.md @@ -124,8 +124,9 @@ Completed pie chart entry: Completed field value helper entry: - `docs/research/translations/shriinivas-fieldvalue-digit-at.md` -- Source group: `Digit At` -- Verification: translated scalar helper matches source behavior across four +- Source groups: `Create Decimal`, `Digit At` +- Verification: decimal glyph geometry matches source 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. ## Extraction Workflow diff --git a/docs/research/procedural-doctrine.md b/docs/research/procedural-doctrine.md index 0cecdbd..04d48a4 100644 --- a/docs/research/procedural-doctrine.md +++ b/docs/research/procedural-doctrine.md @@ -128,6 +128,15 @@ Metaphor: if a graph only whispers a number, build a little megaphone around it. The verifier's job is not to be beautiful. It is to make the invisible output hard to lie about. +## Glyphs Are Parts + +Display systems are made from small, boring geometry tokens: bars, dots, +strokes, caps, labels. `Create Decimal` is only a filled circle moved downward, +but naming it as a group gives the larger display graph a clean punctuation +part instead of another anonymous mesh primitive. + +Tiny named parts are not overengineering when they carry stable intent. + ## Stack Abstractions Carefully There are two abstraction layers available: diff --git a/docs/research/translations/shriinivas-fieldvalue-digit-at.md b/docs/research/translations/shriinivas-fieldvalue-digit-at.md index e9ded9e..a879e45 100644 --- a/docs/research/translations/shriinivas-fieldvalue-digit-at.md +++ b/docs/research/translations/shriinivas-fieldvalue-digit-at.md @@ -1,24 +1,41 @@ -# Translation: Shriinivas Field Value Digit At +# Translation: Shriinivas Field Value Helpers ## Source - Repository: https://github.com/Shriinivas/geometrynodes - Source file: `fieldvalue.blend` -- Source group: `Digit At` +- Source groups: + - `Create Decimal` + - `Digit At` - Geometry Script recreation: `examples/geometry_script/shriinivas_fieldvalue.py` ## 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 target is a scalar helper: -`Digit At`. +`Field Value` graph has 176 nodes, so the first honest targets are small +helpers: `Create Decimal` and `Digit At`. -This group does not make visible geometry. It extracts a digit from a number at -a requested decimal position. That makes it useful for learning how value-only -node groups support larger procedural systems. +Together they show both sides of a display system: tiny glyph geometry and +value-only digit extraction. -## Graph Map +## Create Decimal Map + +Source group: `Create Decimal` + +Geometry Script group: `VG Create Decimal` + +Mechanism: + +- Create a filled 32-vertex `Mesh Circle`. +- Use `radius` as the circle radius. +- Offset it downward by `Vertical Segment Size * -1`. +- Return the dot geometry. + +Metaphor: the decimal is a loose bead placed under the seven-segment digit +frame. It is not a digit; it is punctuation geometry with one placement rule. + +## Digit At Map Inputs: @@ -57,12 +74,13 @@ into geometry Blender can evaluate and compare. Results from Blender 5.1.1: -| Number | Position | Source Count | Translated Count | Status | -| ---: | ---: | ---: | ---: | --- | -| 1234.0 | 0 | 4 | 4 | accepted | -| 1234.0 | 1 | 3 | 3 | accepted | -| 98765.0 | 2 | 7 | 7 | accepted | -| 120305.0 | 3 | 0 | 0 | accepted | +| Case | Source | Translated | Delta | Status | +| --- | ---: | ---: | ---: | --- | +| Create Decimal vertices | 32 | 32 | 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 | ## Lessons @@ -73,3 +91,6 @@ Results from Blender 5.1.1: normalize. - Large procedural display systems should be built from tiny tested scalar helpers before composing visible glyph geometry. +- Tiny glyph marks are still worth isolating as named groups. A decimal point is + just a dot, but a named dot with scale and placement controls is a reusable + punctuation part. diff --git a/examples/geometry_script/shriinivas_fieldvalue.py b/examples/geometry_script/shriinivas_fieldvalue.py index 1c26428..5123d01 100644 --- a/examples/geometry_script/shriinivas_fieldvalue.py +++ b/examples/geometry_script/shriinivas_fieldvalue.py @@ -14,6 +14,17 @@ load_repo_geometry_script() from geometry_script import * # noqa: F403 - Geometry Script exposes node functions as DSL globals. +@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) + offset = combine_xyz( + x=0.0, + y=math(operation=Math.Operation.MULTIPLY, value=(-1.0, vertical_segment_size)), + z=0.0, + ) + return {"Dot": dot.set_position(offset=offset)} + + @tree("VG Digit At") def vg_digit_at(number: Float = 0.0, position: Int = 0): shifted_position = math(operation=Math.Operation.ADD, value=(position, 1.0)) @@ -47,11 +58,14 @@ def vg_digit_at(number: Float = 0.0, position: Int = 0): def _finalize_groups(): import bpy - group = bpy.data.node_groups.get("VG Digit At") - if not group: - return [] - group.use_fake_user = True - return [group] + groups = [] + for name in ("VG Create Decimal", "VG Digit At"): + group = bpy.data.node_groups.get(name) + if not group: + continue + group.use_fake_user = True + groups.append(group) + return groups _finalize_groups() diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index bb3fd2f..6b42ecb 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -41,7 +41,7 @@ The completed pie chart translation is The completed field-value helper translation is `docs/research/translations/shriinivas-fieldvalue-digit-at.md`. It covers -`Digit At` from `fieldvalue.blend`. +`Create Decimal` 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 @@ -54,8 +54,8 @@ Run `.\tools\setup_geometry_script_clone.ps1` if `external/geometry-script` is missing in a fresh workspace. The current next action is to continue `fieldvalue.blend` by translating the -next bounded seven-segment display helper, likely `Create Decimal` or -`Create Segment`, before attempting the full `Field Value` graph. +next bounded seven-segment display helper, `Create Segment`, before attempting +the full `Field Value` graph. ## Important Invariants diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 6fe48bb..ea13721 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -8,3 +8,4 @@ {"ts": "2026-05-04T12:42:20+00:00", "type": "tooling", "status": "accepted", "note": "Reverted direct AppData Geometry Script surgery. Cloned upstream Geometry Script into ignored external/geometry-script, committed local branch vibegeometry/blender-5-nested-tree-groups with nested @tree group fix, stored patch under patches/geometry-script, and added setup_geometry_script_clone.ps1 plus loader so VibeGeometry uses the repo-local patched clone."} {"ts": "2026-05-04T12:48:18+00:00", "type": "implementation", "status": "accepted", "note": "Translated and verified Shriinivas/piechart.blend small graph family: NodeGroup -> VG Pie Segment and Pie Chart -> VG Pie Chart. Segment and chart evaluated mesh comparisons both passed in Blender 5.1.1 with sorted max vertex delta 0.0. Doctrine added: reusable groups can pass invisible scalar state such as End angle alongside visible geometry."} {"ts": "2026-05-04T12:50:55+00:00", "type": "implementation", "status": "accepted", "note": "Translated and verified Shriinivas/fieldvalue.blend Digit At scalar helper as VG Digit At. Verification wraps source and translation by driving Mesh Line.Count and matches four number/position cases, including zero output. Doctrine added: value-only node groups need geometry-producing verification harnesses."} +{"ts": "2026-05-04T12:53:00+00:00", "type": "implementation", "status": "accepted", "note": "Extended fieldvalue translation with Create Decimal -> VG Create Decimal. Verified against source by comparing evaluated dot geometry: both source and translation produce 32 vertices with sorted max vertex delta 0.0. Doctrine added: tiny glyph marks such as decimal points should be isolated as named reusable parts when they carry stable display intent."} diff --git a/state/map.yaml b/state/map.yaml index 98ec104..41cd74c 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -83,4 +83,4 @@ data_flow: 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 bounded seven-segment display helper, likely `Create Decimal` or `Create Segment`, before attempting the full `Field Value` graph. + next_action: Continue fieldvalue.blend by translating `Create Segment`, the next bounded seven-segment display helper, before attempting the full `Field Value` graph. diff --git a/tools/verify_fieldvalue_translations.py b/tools/verify_fieldvalue_translations.py index 686d801..80a1bc3 100644 --- a/tools/verify_fieldvalue_translations.py +++ b/tools/verify_fieldvalue_translations.py @@ -4,6 +4,7 @@ from __future__ import annotations import importlib.util import json +import math import sys from pathlib import Path @@ -20,6 +21,8 @@ CASES = [ {"Number": 120305.0, "Position": 3}, ] +DECIMAL_CASE = {"Vertical Segment Size": 2.4, "radius": 0.18} + def _load_translation() -> None: spec = importlib.util.spec_from_file_location("vg_fieldvalue_translation", TRANSLATION) @@ -68,6 +71,23 @@ def _build_count_wrapper(name: str, digit_group: bpy.types.GeometryNodeTree, inp 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 + links = wrapper.links + group_node = nodes.new("GeometryNodeGroup") + group_node.node_tree = source_group + lower_inputs = {key.lower(): value for key, value in inputs.items()} + for socket in group_node.inputs: + if socket.name in inputs: + socket.default_value = inputs[socket.name] + elif socket.name.lower() in lower_inputs: + socket.default_value = lower_inputs[socket.name.lower()] + group_output = nodes.new("NodeGroupOutput") + links.new(_socket_by_name(group_node.outputs, output), _socket_by_name(group_output.inputs, "Geometry")) + return wrapper + + def _evaluated_vertex_count(group: bpy.types.GeometryNodeTree) -> int: mesh = bpy.data.meshes.new(group.name + " Input Mesh") obj = bpy.data.objects.new(group.name + " Object", mesh) @@ -83,11 +103,47 @@ def _evaluated_vertex_count(group: bpy.types.GeometryNodeTree) -> int: evaluated.to_mesh_clear() +def _evaluated_vertices(group: bpy.types.GeometryNodeTree) -> list[tuple[float, float, float]]: + mesh = bpy.data.meshes.new(group.name + " Input Mesh") + obj = bpy.data.objects.new(group.name + " Object", mesh) + bpy.context.collection.objects.link(obj) + modifier = obj.modifiers.new(group.name + " Modifier", "NODES") + modifier.node_group = group + depsgraph = bpy.context.evaluated_depsgraph_get() + evaluated = obj.evaluated_get(depsgraph) + evaluated_mesh = evaluated.to_mesh() + try: + return [tuple(vertex.co) for vertex in evaluated_mesh.vertices] + finally: + evaluated.to_mesh_clear() + + def main() -> int: _load_translation() source = bpy.data.node_groups["Digit At"] translated = bpy.data.node_groups["VG Digit At"] results = [] + source_decimal = _evaluated_vertices( + _build_geometry_wrapper("VG Verify Source Decimal", bpy.data.node_groups["Create Decimal"], DECIMAL_CASE, "Dot") + ) + translated_decimal = _evaluated_vertices( + _build_geometry_wrapper("VG Verify Translated Decimal", bpy.data.node_groups["VG Create Decimal"], DECIMAL_CASE, "Dot") + ) + results.append( + { + "case": "create_decimal", + "source_vertex_count": len(source_decimal), + "translated_vertex_count": len(translated_decimal), + "max_sorted_vertex_delta": max( + (math.dist(a, b) for a, b in zip(sorted(source_decimal), sorted(translated_decimal))), + default=0.0, + ), + } + ) + results[-1]["ok"] = ( + results[-1]["source_vertex_count"] == results[-1]["translated_vertex_count"] + and results[-1]["max_sorted_vertex_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(