Expand official geometry node corpus

This commit is contained in:
Meta Vens 2026-05-04 17:56:40 +01:00
commit 3c4ad988c3
17 changed files with 1883 additions and 6 deletions

View file

@ -35,6 +35,17 @@ modifier sockets, and basic graph inspection.
Use these after the primitive layer can be recreated without guessing.
- Blender public Geometry Nodes demo: instance attributes grass tuft
- Source:
https://download.blender.org/demo/geometry-nodes/instance_attribtues.blend
- Completed entry:
`docs/research/translations/blender-instance-attributes.md`
- Why it matters: compact scatter graph that captures instance root position
before realization and uses it to curl each realized blade.
- Translation value: distribute points, instance on points, scale instances,
capture attributes on instance domain, realize instances, tangent-axis
deformation, and profile-scaled curve-to-mesh output.
- Blender Guru beginner Geometry Nodes candy tutorial
- Source: https://www.blenderguru.com/tutorials/2025/9/10/blender-tutorial-geometry-nodes-for-beginners
- Candidate artifact: downloadable final `.blend`
@ -73,6 +84,36 @@ Use these to learn how artists package node networks into inspectable tools.
Use these only after the smaller idioms are reliable.
- Blender public Geometry Nodes demo: Index Of Nearest
- Source: https://download.blender.org/demo/geometry-nodes/index_of_nearest.blend
- Completed entry:
`docs/research/translations/blender-index-of-nearest.md`
- Why it matters: compact helper groups around a simulation-zone point
system.
- Translation value: nearest-neighbor lookup, evaluate-at-index sampling,
point-radius collision, velocity-field harnessing, and boundary/collider
constraint helpers.
- Blender public Geometry Nodes demo: shortest-path labyrinth
- Source:
https://download.blender.org/demo/geometry-nodes/labyrinth-shortest_path-simon_thommes.blend
- Completed entry:
`docs/research/translations/blender-labyrinth-shortest-path.md`
- Why it matters: compact pathfinding system built around shortest edge
paths and path-to-curve conversion.
- Translation value: topology-first graph structure, edge path selection,
path capture before deletion, filleted curve output, and solution reveal
control.
- Blender public Geometry Nodes demo: raycast minigame
- Source: https://download.blender.org/demo/geometry-nodes/raycast-minigame.blend
- Completed entry:
`docs/research/translations/blender-raycast-minigame.md`
- Why it matters: small ray-step helper groups inside a larger game-like
procedural setup.
- Translation value: initial direction vectors, sampled ray lines, raycast
hit updates, reflected direction, and curve-output harnessing.
- Blender Studio Geometry Nodes from Scratch files
- Source: https://studio.blender.org/training/geometry-nodes-from-scratch/chapter/files/
- Candidate files: rock scattering, tree generator, grass tuft generator,
@ -164,6 +205,60 @@ Completed CurveToMeshUV utility entry:
harness, caps-mask harness, demo geometry, and title geometry all match
source evaluated geometry.
Completed Blender instance attributes entry:
- `docs/research/translations/blender-instance-attributes.md`
- Source group: `Grass Tuft Generator`
- Verification: default and wider/curlier/seeded control cases match source
evaluated geometry with sorted max vertex delta `0.0`; edge counts, polygon
counts, and smooth-face flags also match.
- Translation value: scatter nurseries, reused radial falloff, instance-domain
capture before realization, and per-blade curl driven by remembered root
position.
Completed Blender index-of-nearest helper entry:
- `docs/research/translations/blender-index-of-nearest.md`
- Source groups: `boundary_step`, `update_velocity`, `collision_step`,
`collider_step`
- Verification: helper harnesses match source evaluated geometry with sorted
max vertex delta `0.0`.
- Translation value: constraint projection, velocity capping, nearest-neighbor
collision, and point-output verification harnesses.
Completed Blender shortest-path labyrinth entry:
- `docs/research/translations/blender-labyrinth-shortest-path.md`
- Source group: `Solvable Labyrinth Generator`
- Verification: small unsolved and solved cases match source evaluated
geometry with sorted max vertex delta `0.0`; edge and polygon counts also
match.
- Translation value: shortest edge paths, path capture, topology carving,
path-to-curve conversion, and solution reveal.
Completed Blender raycast minigame foothold:
- `docs/research/translations/blender-raycast-minigame.md`
- Source groups: `Initial Direction`, `Line to be Casted`, `Cast Rays`
- Verification: direction, line, and raycast-step harnesses match source
evaluated geometry with sorted max vertex delta `0.0`.
- Translation value: direction vectors, curve breadcrumbs, raycast hit updates,
reflected vectors, and object-target controls.
Inspected but deferred official demo files:
- `hexgrid_blender_geometry_nodes_demo.blend`: mostly legacy undefined nodes
in Blender 5.1, plus a duplicate `Auto Smooth` helper already covered.
- `wavy_procedural_wall.blend`: several legacy/undefined attribute-toolkit
groups; useful later as migration quarry, not current doctrine.
- `pebble_scattering.blend`: legacy undefined nodes dominate the single group.
- `gizmo_array.blend`: focused on Blender 4.3+ geometry-node gizmo nodes.
Needs a dedicated gizmo-authoring pass.
- `jiggly_pudding.blend`: simulation-zone graph. Needs dedicated simulation
zone support and verification discipline.
- `repeat_zone_flower_by_MiRA.blend`: repeat-zone flower system. Needs a
repeat-zone pass before translation.
## Extraction Workflow
1. Download one source `.blend` into an ignored experiment folder.

View file

@ -460,6 +460,188 @@ of instances and domains, untagged values are gone in the baggage system.
Verification cue: test the full composed graph after realization or deletion,
not just the captured helper. The point of capture is later survival.
## Scatter In Layers
Reach for scatter layering when the target is grass, fur, candies, rivets,
pebbles, bubbles, leaves, scales, debris, or any repeated body distributed over
a surface.
Mental move: separate the nursery from the bodies. First make the surface that
decides where points may live. Then make the point field that controls density,
spacing, randomness, scale, and seed. Then instance a separately named body and
only realize it when later deformation needs real vertices.
```python
base_disc = mesh_circle(fill_type=MeshCircle.FillType.TRIANGLE_FAN, vertices=12, radius=radius)
scattered_surface = subdivide_mesh(mesh=base_disc, level=3)
radial_distance = vector_math(operation=VectorMath.Operation.LENGTH, vector=position())
radial_falloff = map_range(
clamp=True,
interpolation_type="SMOOTHSTEP",
data_type="FLOAT",
value=radial_distance,
from_min=0.0,
from_max=radius,
to_min=1.0,
to_max=0.38999998569488525,
)
points = distribute_points_on_faces(
distribute_method="POISSON",
mesh=scattered_surface,
distance_min=math(
operation=Math.Operation.DIVIDE,
value=(math(operation=Math.Operation.MULTIPLY, value=(thickness, 2.0)), density),
),
density_max=math(operation=Math.Operation.MULTIPLY, value=(density, 5000.0)),
density_factor=radial_falloff,
seed=seed,
)
instances = instance_on_points(points=points.points, instance=tapered_blade)
scaled = scale_instances(instances=instances, scale=radial_falloff)
roots = _capture_attribute_item("VECTOR", "INSTANCE", scaled, position(), "Value")
realized = realize_instances(geometry=roots.geometry, realize_all=True, depth=0)
```
Metaphor in use: the scatter surface is a nursery tray. Points are planting
holes. Instances are seedlings. Realization is when the seedlings stop being
copies and become individual geometry you can bend, cut, or shade.
Verification cue: test more than one seed/control set. Scatter graphs can match
counts at one setting while density, scale, or captured-root behavior is wrong.
## Constraint Helpers Are Bumpers
Reach for constraint helpers when a procedural system has a small physical rule
that should be true after each update: stay inside a boundary, avoid another
point, cap velocity, project out of a collider, or keep motion planar.
Mental move: express the rule as condition, projection, and `Set Position`.
The condition says when the rule applies. The projection computes the nearest
allowed state. `Set Position` makes the point obey.
```python
from_center = vector_math(operation=VectorMath.Operation.SUBTRACT, vector=(position(), vector))
distance = vector_math(operation=VectorMath.Operation.LENGTH, vector=from_center)
outside = compare(
operation=Compare.Operation.GREATER_THAN,
data_type=Compare.DataType.FLOAT,
mode=Compare.Mode.ELEMENT,
a=distance,
b=b,
)
clamped_xy = vector_math(
operation=VectorMath.Operation.MULTIPLY,
vector=(
vector_math(
operation=VectorMath.Operation.SCALE,
vector=vector_math(operation=VectorMath.Operation.NORMALIZE, vector=from_center),
scale=b,
),
(1.0, 1.0, 0.0),
),
)
geometry = set_position(geometry=geometry, selection=outside, position=clamped_xy)
```
For point collisions, make the neighbor visible as a sampled field:
```python
neighbor = index_of_nearest(position=position())
neighbor_position = evaluate_at_index(
domain="POINT",
data_type="FLOAT_VECTOR",
value=position(),
index=neighbor.index,
)
from_neighbor = vector_math(operation=VectorMath.Operation.SUBTRACT, vector=(position(), neighbor_position))
push = vector_math(operation=VectorMath.Operation.SCALE, vector=from_neighbor, scale=push_strength)
geometry = set_position(geometry=geometry, offset=push)
```
Metaphor in use: these are bumpers on the table. They do not make the whole
simulation smart; they keep one kind of stupidity from persisting into the next
tick.
Verification cue: point clouds may evaluate to empty mesh summaries. When the
promise is point position, convert points to vertices in the harness before
comparing geometry.
## Paths Are Topology First
Reach for path nodes when the visual idea depends on connectivity: mazes,
routes, veins, circuit traces, cracks, growth paths, street maps, or solution
reveals.
Mental move: solve the graph before drawing the tube. First mark the root or
target vertices, compute path selection on mesh topology, capture the path
state that later deletion or conversion will destroy, then convert the accepted
path into visible curves.
```python
start_vertex = compare(
operation=Compare.Operation.EQUAL,
data_type=Compare.DataType.INT,
mode=Compare.Mode.ELEMENT,
a=index(),
b=0,
)
paths = shortest_edge_paths(end_vertex=start_vertex, edge_cost=edge_cost)
path_selection = edge_paths_to_selection(next_vertex_index=paths.next_vertex_index)
captured_path = _capture_attribute_item("BOOLEAN", "EDGE", base_geometry, path_selection, "Path")
subdivided = subdivide_mesh(mesh=captured_path.geometry, level=1)
walkable = delete_geometry(
mode=DeleteGeometry.Mode.ALL,
domain=DeleteGeometry.Domain.POINT,
geometry=subdivided,
selection=captured_path.path,
)
solution = edge_paths_to_curves(mesh=walkable, start_vertices=far_x_vertices, next_vertex_index=paths.next_vertex_index)
```
Metaphor in use: topology is the street map. Curves are the painted route.
Paint after the route exists, or you are decorating roads that may be closed in
the next operation.
Verification cue: compare solved and unsolved control states. A path graph can
preserve topology while putting visible tubes at the wrong scale if anonymous
value nodes are misread.
## Rays Are Breadcrumbs
Reach for raycast helpers when a path should bounce, aim, probe, measure
distance, or react to a target object.
Mental move: keep the ray step explicit. Store the breadcrumb line, sample the
previous point, cast from there, write the next point, then pass the reflected
direction and next index forward.
```python
previous_position = sample_index(
data_type=SampleIndex.DataType.FLOAT_VECTOR,
domain=SampleIndex.Domain.POINT,
clamp=True,
geometry=line,
value=position(),
index=math(operation=Math.Operation.SUBTRACT, value=(hit_index, integer(integer=1))),
)
hit = raycast(
data_type="FLOAT_VECTOR",
target_geometry=target_info.geometry,
interpolation="Nearest",
source_position=previous_position,
ray_direction=ray_direction,
ray_length=20.0,
)
updated_line = set_position(geometry=line, selection=active_point, position=hit.hit_position)
reflected = vector_math(operation=VectorMath.Operation.REFLECT, vector=(ray_direction, hit.hit_normal))
```
Metaphor in use: every hit drops a crumb and turns the flashlight. The next
step reads the crumb, not the whole trail.
Verification cue: curve breadcrumbs need a curve-to-points or curve-to-mesh
harness before evaluated mesh comparison can see them.
## Branch Helpers Are Switchboards
Reach for branch helpers when the same output contract can be fed by multiple

View file

@ -0,0 +1,88 @@
# Translation: Blender Index Of Nearest Helpers
## Source
- Source file: https://download.blender.org/demo/geometry-nodes/index_of_nearest.blend
- Source groups translated in this pass:
- `boundary_step`
- `update_velocity`
- `collision_step`
- `collider_step`
- Geometry Script recreation:
`examples/geometry_script/blender_index_of_nearest.py`
## Why This Graph
The main `Geometry Nodes` group is a simulation-zone point system. The compact
helper groups are the useful entry point: each one enforces a small physical
rule on point positions or velocity fields.
## Helper Maps
`VG Boundary Step`:
- Compute point position relative to a center vector.
- If distance exceeds boundary radius `B`, normalize the direction and place
the point on the boundary circle.
- Multiply by `(1, 1, 0)` to keep the constraint planar.
`VG Update Velocity`:
- Estimate movement from current `Position - Last Position`.
- Dampen and flatten the movement vector.
- If it exceeds the velocity cap, normalize to the cap.
- Otherwise blend previous velocity toward the new planar movement.
`VG Collision Step`:
- Find the nearest point with `Index Of Nearest`.
- Evaluate that neighbor's position with `Evaluate at Index`.
- If the current point is closer than its radius, push it away a small planar
amount.
`VG Collider Step`:
- Read an object's location and scale.
- If a point is inside the object's scaled radius, project it to the collider
boundary in XY.
- The accepted Geometry Script group exposes the collider as an object input
instead of hard-coding the source object's name.
Metaphor: these groups are bumpers. They do not decide the whole simulation;
they make one small rule true each tick: stay inside the table, do not move too
fast, stop sitting on another point, stop sitting inside the obstacle.
## Verification
Run:
```powershell
& 'C:\Program Files (x86)\Steam\steamapps\common\Blender\blender.exe' --background '.\experiments\source-blends\blender-index-of-nearest.blend' --python '.\tools\verify_index_of_nearest_translations.py'
```
Results from Blender 5.1.1:
| Case | Source vertices | Translated vertices | Delta | Status |
| --- | ---: | ---: | ---: | --- |
| boundary_step | 6 | 6 | 0.0 | accepted |
| update_velocity harness | 4 | 4 | 0.0 | accepted |
| collision_step point harness | 5 | 5 | 0.0 | accepted |
| collider_step | 6 | 6 | 0.0 | accepted |
The velocity output is verified by driving `Set Position.Position` with the
output vector. The collision output is verified by converting the resulting
points to vertices after the helper group.
## Lessons
- Small simulation helpers are better first translation targets than full
simulation zones.
- Constraint groups read well when scripted as condition, projection, and
`Set Position`.
- Invisible vector fields need harnesses. `update_velocity` became observable
only after using the vector output as point position.
- Point-cloud outputs can evaluate as empty mesh summaries. Convert points to
vertices in the verifier when point positions are the behavior under test.
- Geometry Script's `mix(...)` helper mapped to the wrong Blender node family
here. The accepted translation expresses the source vector mix as explicit
scale-and-add nodes.

View file

@ -0,0 +1,74 @@
# Translation: Blender Instance Attributes Grass Tuft
## Source
- Source file: https://download.blender.org/demo/geometry-nodes/instance_attribtues.blend
- Source group: `Grass Tuft Generator`
- Geometry Script recreation:
`examples/geometry_script/blender_instance_attributes.py`
## Why This Graph
This is the first verified scatter/instance/deform sample in the corpus. It is
small enough to translate directly, but it uses the important grown-up trick:
capture instance state before realization, then use that remembered value to
deform the realized geometry.
## Graph Map
Source group: `Grass Tuft Generator`
Geometry Script group: `VG Grass Tuft Generator`
Mechanism:
- Build a triangular-fan disc, subdivide it, and use it as the scatter nursery.
- Compute radial distance from `Position`, remap it through `Map Range`, and
reuse that falloff for both point density and instance scale.
- Build one blade as a five-point vertical mesh line, convert it to a curve,
and taper it with `Set Curve Radius` from `1 - Spline Parameter.Factor`.
- Distribute points on the disc with Poisson spacing controlled by thickness
and density.
- Instance the tapered blade on the points, scale each instance by radial
falloff, then capture the instance `Position` on the `INSTANCE` domain.
- Realize the instances. The captured root position survives as the center,
radius sample, and tangent-axis basis for curl.
- Rotate each realized blade position around a tangent axis. Curl grows along
blade length and is modulated by distance from the tuft center.
- Convert curled curves to mesh with a triangular profile. If a `radius`
attribute exists, use it as the profile scale.
Metaphor: the disc is a nursery tray, the points are planting holes, each
instance carries a root tag, and realization turns the tray into individual
blades. Curl reads the root tag to bend every blade around its own base instead
of around the world origin.
## Verification
Run:
```powershell
& 'C:\Program Files (x86)\Steam\steamapps\common\Blender\blender.exe' --background '.\experiments\source-blends\blender-instance-attributes.blend' --python '.\tools\verify_instance_attributes_translations.py'
```
Results from Blender 5.1.1:
| Case | Source vertices | Translated vertices | Delta | Status |
| --- | ---: | ---: | ---: | --- |
| default | 45 | 45 | 0.0 | accepted |
| wider curlier seeded | 165 | 165 | 0.0 | accepted |
Both cases also match edge counts, polygon counts, and smooth-face flags.
## Lessons
- Scatter graphs often have three separable layers: seed surface, point field,
and instance body. Keep them named in script.
- A field can be reused across domains intentionally. Here, radial falloff
controls both scatter density and final instance scale.
- Captured instance attributes must be explicit under Blender 5.1. Geometry
Script's generic `capture_attribute(...)` call did not create the required
capture item here; the verified script uses the explicit
`_capture_attribute_item(...)` helper.
- `nodes_to_script` recovered the wiring and defaults well enough to debug the
translation, but its output remains a transcript, not accepted style.

View file

@ -0,0 +1,67 @@
# Translation: Blender Shortest-Path Labyrinth
## Source
- Source file:
https://download.blender.org/demo/geometry-nodes/labyrinth-shortest_path-simon_thommes.blend
- Source group: `Solvable Labyrinth Generator`
- Geometry Script recreation:
`examples/geometry_script/blender_labyrinth_shortest_path.py`
## Why This Graph
This graph is the first accepted pathfinding translation. It uses grid topology,
randomized edge costs, shortest-edge paths, path selection, path-to-curve
conversion, stored UV attributes, curve radius, and endpoint markers.
## Graph Map
- Build a square grid and store its UV map on the corner domain.
- Mark vertex `0` as the path root.
- Use edge-neighbor count and random booleans to create edge costs.
- Run `Shortest Edge Paths`, convert the result to an edge selection, and
capture that boolean on the edge domain.
- Subdivide the mesh and delete selected points to carve the walkable graph.
- Run shortest paths again on the carved graph, find the farthest X point on
the path, and convert the edge path into curves.
- Instance endpoint marker spheres on the path endpoints and capture their
instance indices as `Start/End`.
- Trim the solution curve by the exposed `Solve` value and capture a `Path`
boolean on the curve domain.
- Convert maze walls and solution curves into filleted radius curves, then
convert them to mesh with a circular profile.
- Join endpoint markers, path/wall geometry, and the base grid.
Metaphor: the grid is a street map, random edge costs close some roads, shortest
path draws the route home, and the captured booleans are colored tape left on
the roads so later carving and tube-building know what survived.
## Verification
Run:
```powershell
& 'C:\Program Files (x86)\Steam\steamapps\common\Blender\blender.exe' --background '.\experiments\source-blends\blender-labyrinth-shortest-path.blend' --python '.\tools\verify_labyrinth_translations.py'
```
Results from Blender 5.1.1:
| Case | Source vertices | Translated vertices | Delta | Status |
| --- | ---: | ---: | ---: | --- |
| small unsolved | 22730 | 22730 | 0.0 | accepted |
| small solved | 25484 | 25484 | 0.0 | accepted |
Edge and polygon counts also match for both cases.
## Lessons
- Shortest-path graphs can be translated as topology passes first, visual
passes second.
- Capture path booleans before subdivision/deletion. Once the graph is carved,
the original edge selection is no longer obvious.
- Anonymous `Value` nodes are easy for converter output to misassign. The
source links showed `0.1 / Size` driving radius and `3.0` driving marker
scale; trusting the generated variable names produced the right topology at
the wrong size.
- Path outputs are fields. Geometry comparison catches the visible contract;
scalar/boolean path outputs need a harness only when they become the target.

View file

@ -0,0 +1,75 @@
# Translation: Blender Raycast Minigame Foothold
## Source
- Source file:
https://download.blender.org/demo/geometry-nodes/raycast-minigame.blend
- Source groups translated in this pass:
- `Initial Direction`
- `Line to be Casted`
- `Cast Rays`
- Geometry Script recreation:
`examples/geometry_script/blender_raycast_minigame.py`
## Why This Graph
The full minigame graph is larger, but these helpers isolate the ray pipeline:
make a direction, make a sampled line, cast one ray step, write the hit point
back into the line, and return the reflected direction plus traveled distance.
## Helper Maps
`VG Initial Direction`:
- Start with `(1, 0, 0)` as forward.
- Rotate it by the exposed Euler vector.
- Output the resulting direction vector.
`VG Line To Be Casted`:
- Create a zero-length curve line.
- Move it to `Start Pos`.
- Resample it to `Line Size` points.
`VG Cast Rays`:
- Select the active hit point by `Hit Index`.
- Sample the previous line point.
- Raycast from that previous point into the target geometry along the current
ray direction.
- Move the active point to the hit position scaled by `0.999`.
- Reflect the ray direction by the hit normal.
- Add hit distance to traveled distance and increment the hit index.
Metaphor: the line is a breadcrumb trail. Each raycast step reads the previous
crumb, throws a beam into the boundary object, places the next crumb just short
of impact, then turns the beam for the next bounce.
## Verification
Run:
```powershell
& 'C:\Program Files (x86)\Steam\steamapps\common\Blender\blender.exe' --background '.\experiments\source-blends\blender-raycast-minigame.blend' --python '.\tools\verify_raycast_translations.py'
```
Results from Blender 5.1.1:
| Case | Source vertices | Translated vertices | Delta | Status |
| --- | ---: | ---: | ---: | --- |
| initial direction harness | 1 | 1 | 0.0 | accepted |
| line to be casted | 5 | 5 | 0.0 | accepted |
| cast rays | 4 | 4 | 0.0 | accepted |
Vector outputs are verified by geometry harnesses: direction drives a single
vertex position, and curve outputs are converted through curve points to
vertices before comparison.
## Lessons
- A ray pipeline is a baton chain: direction, previous point, hit, reflected
direction, next index.
- Object-dependent groups are better authored with explicit object inputs than
hard-coded source object names.
- Curve outputs may need curve-to-points harnesses before evaluated mesh
comparison can see their control points.

View file

@ -0,0 +1,150 @@
"""Geometry Script footholds from Blender's index_of_nearest demo."""
try:
from tools.geometry_script_loader import load_repo_geometry_script
except ModuleNotFoundError:
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from tools.geometry_script_loader import load_repo_geometry_script
load_repo_geometry_script()
from geometry_script import * # noqa: F403 - Geometry Script exposes node functions as DSL globals.
@tree("VG Boundary Step")
def vg_boundary_step(
geometry: Geometry,
vector: Vector = (0.0, 0.0, 0.0),
b: Float = 0.05000000074505806,
):
from_center = vector_math(operation=VectorMath.Operation.SUBTRACT, vector=(position(), vector))
distance = vector_math(operation=VectorMath.Operation.LENGTH, vector=from_center)
outside = compare(
operation=Compare.Operation.GREATER_THAN,
data_type=Compare.DataType.FLOAT,
mode=Compare.Mode.ELEMENT,
a=distance,
b=b,
)
clamped_xy = vector_math(
operation=VectorMath.Operation.MULTIPLY,
vector=(vector_math(operation=VectorMath.Operation.SCALE, vector=vector_math(operation=VectorMath.Operation.NORMALIZE, vector=from_center), scale=b), (1.0, 1.0, 0.0)),
)
return {"Geometry": set_position(geometry=geometry, selection=outside, position=clamped_xy, offset=(0.0, 0.0, 0.0))}
@tree("VG Update Velocity")
def vg_update_velocity(
current_velocity: Vector = (0.0, 0.0, 0.0),
last_position: Vector = (0.0, 0.0, 0.0),
):
movement = vector_math(operation=VectorMath.Operation.SUBTRACT, vector=(position(), last_position))
damped_movement = vector_math(operation=VectorMath.Operation.SCALE, vector=movement, scale=0.9599999785423279)
planar_movement = vector_math(operation=VectorMath.Operation.MULTIPLY, vector=(damped_movement, (1.0, 1.0, 0.0)))
fast_enough = compare(
operation=Compare.Operation.GREATER_THAN,
data_type=Compare.DataType.FLOAT,
mode=Compare.Mode.ELEMENT,
a=vector_math(operation=VectorMath.Operation.LENGTH, vector=planar_movement),
b=0.009999999776482582,
)
blended = vector_math(
operation=VectorMath.Operation.ADD,
vector=(
vector_math(operation=VectorMath.Operation.SCALE, vector=current_velocity, scale=0.75),
vector_math(operation=VectorMath.Operation.SCALE, vector=planar_movement, scale=0.25),
),
)
capped = vector_math(
operation=VectorMath.Operation.SCALE,
vector=vector_math(operation=VectorMath.Operation.NORMALIZE, vector=damped_movement),
scale=0.009999999776482582,
)
return {"velocity": switch(input_type=Switch.InputType.VECTOR, switch=fast_enough, false=blended, true=capped)}
@tree("VG Collision Step")
def vg_collision_step(geometry: Geometry):
current_position = position()
neighbor = index_of_nearest(position=position())
neighbor_position = evaluate_at_index(
domain="POINT",
data_type="FLOAT_VECTOR",
value=position(),
index=neighbor.index,
)
from_neighbor = vector_math(operation=VectorMath.Operation.SUBTRACT, vector=(current_position, neighbor_position))
too_close = compare(
operation=Compare.Operation.LESS_THAN,
data_type=Compare.DataType.FLOAT,
mode=Compare.Mode.ELEMENT,
a=vector_math(operation=VectorMath.Operation.LENGTH, vector=from_neighbor),
b=radius(),
)
push_strength = math(operation=Math.Operation.MULTIPLY, value=(too_close, 0.02500000037252903))
push = vector_math(
operation=VectorMath.Operation.MULTIPLY,
vector=(vector_math(operation=VectorMath.Operation.SCALE, vector=from_neighbor, scale=push_strength), (1.0, 1.0, 0.0)),
)
return {"Geometry": set_position(geometry=geometry, offset=push)}
@tree("VG Collider Step")
def vg_collider_step(geometry: Geometry, collider: Object = None):
collider_info = object_info(transform_space="ORIGINAL", object=collider, as_instance=False)
from_collider = vector_math(operation=VectorMath.Operation.SUBTRACT, vector=(position(), collider_info.location))
collider_radius = vector_math(operation=VectorMath.Operation.ABSOLUTE, vector=collider_info.scale)
inside = compare(
operation=Compare.Operation.LESS_THAN,
data_type=Compare.DataType.FLOAT,
mode=Compare.Mode.ELEMENT,
a=vector_math(operation=VectorMath.Operation.LENGTH, vector=from_collider),
b=collider_radius,
)
clamped = vector_math(
operation=VectorMath.Operation.ADD,
vector=(
vector_math(
operation=VectorMath.Operation.SCALE,
vector=vector_math(operation=VectorMath.Operation.NORMALIZE, vector=from_collider),
scale=collider_radius,
),
collider_info.location,
),
)
planar_clamped = vector_math(operation=VectorMath.Operation.MULTIPLY, vector=(clamped, (1.0, 1.0, 0.0)))
return {"Geometry": set_position(geometry=geometry, selection=inside, position=planar_clamped, offset=(0.0, 0.0, 0.0))}
def _finalize_groups():
import bpy
groups = []
for name in (
"VG Boundary Step",
"VG Update Velocity",
"VG Collision Step",
"VG Collider Step",
):
group = bpy.data.node_groups.get(name)
if group:
group.use_fake_user = True
groups.append(group)
return groups
_finalize_groups()
if __name__ == "__main__":
for group in _finalize_groups():
print(
"VG_INDEX_OF_NEAREST_GROUP",
group.name,
len(group.nodes),
len(group.links),
sorted(set(node.bl_idname for node in group.nodes)),
)

View file

@ -0,0 +1,164 @@
"""Geometry Script recreation of Blender's instance_attribtues.blend demo graph."""
try:
from tools.geometry_script_loader import load_repo_geometry_script
except ModuleNotFoundError:
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from tools.geometry_script_loader import load_repo_geometry_script
load_repo_geometry_script()
from geometry_script import * # noqa: F403 - Geometry Script exposes node functions as DSL globals.
from geometry_script.api.node_mapper import OutputsList, set_or_create_link
from geometry_script.api.state import State
from geometry_script.api.types import Type
def _capture_attribute_item(data_type: str, domain: str, geometry, value, name: str):
node = State.current_node_tree.nodes.new("GeometryNodeCaptureAttribute")
node.capture_items.new(data_type, name)
node.active_index = 0
node.domain = domain
set_or_create_link(geometry, node.inputs[0])
set_or_create_link(value, node.inputs[1])
return OutputsList({"geometry": Type(node.outputs[0]), name.lower().replace(" ", "_"): Type(node.outputs[1])})
@tree("VG Grass Tuft Generator")
def vg_grass_tuft_generator(
geometry: Geometry,
height: Float = 0.20000000298023224,
radius: Float = 0.05000000074505806,
density: Float = 1.0,
thickness: Float = 0.009999999776482582,
curl: Float = 0.5,
seed: Int = 0,
):
del geometry
base_disc = mesh_circle(fill_type=MeshCircle.FillType.TRIANGLE_FAN, vertices=12, radius=radius)
scattered_surface = subdivide_mesh(mesh=base_disc, level=3)
radial_distance = vector_math(operation=VectorMath.Operation.LENGTH, vector=position())
radial_falloff = map_range(
clamp=True,
interpolation_type="SMOOTHSTEP",
data_type="FLOAT",
value=radial_distance,
from_min=0.0,
from_max=radius,
to_min=1.0,
to_max=0.38999998569488525,
)
points = distribute_points_on_faces(
distribute_method="POISSON",
use_legacy_normal=True,
mesh=scattered_surface,
distance_min=math(
operation=Math.Operation.DIVIDE,
value=(math(operation=Math.Operation.MULTIPLY, value=(thickness, 2.0)), density),
),
density_max=math(operation=Math.Operation.MULTIPLY, value=(density, 5000.0)),
density_factor=radial_falloff,
seed=seed,
)
blade_spine = mesh_line(
mode=MeshLine.Mode.END_POINTS,
count_mode=MeshLine.CountMode.TOTAL,
count=5,
start_location=(0.0, 0.0, 0.0),
offset=combine_xyz(x=0.0, y=0.0, z=height),
)
blade_curve = mesh_to_curve(mode="EDGES", mesh=blade_spine)
taper = math(operation=Math.Operation.SUBTRACT, value=(1.0, spline_parameter().factor))
tapered_blade = set_curve_radius(curve=blade_curve, radius=taper)
instances = instance_on_points(
points=points.points,
instance=tapered_blade,
pick_instance=False,
rotation=(0.0, 0.0, 0.0),
scale=(1.0, 1.0, 1.0),
)
scaled_instances = scale_instances(
instances=instances,
scale=radial_falloff,
center=(0.0, 0.0, 0.0),
local_space=True,
)
roots = _capture_attribute_item("VECTOR", "INSTANCE", scaled_instances, position(), "Value")
realized_blades = realize_instances(
realize_to_point_domain=True,
geometry=roots.geometry,
realize_all=True,
depth=0,
)
root_position = roots.value
tangent_axis = vector_rotate(
rotation_type="Z_AXIS",
invert=False,
vector=vector_math(operation=VectorMath.Operation.NORMALIZE, vector=root_position),
center=(0.0, 0.0, 0.0),
angle=1.5707963705062866,
)
root_distance = vector_math(operation=VectorMath.Operation.LENGTH, vector=root_position)
curl_falloff = map_range(
clamp=True,
interpolation_type="SMOOTHSTEP",
data_type="FLOAT",
value=root_distance,
from_min=0.0,
from_max=radius,
to_min=0.20000000298023224,
to_max=2.0,
)
curl_angle = math(
operation=Math.Operation.MULTIPLY,
value=(math(operation=Math.Operation.MULTIPLY, value=(spline_parameter().factor, curl)), curl_falloff),
)
curled_position = vector_rotate(
rotation_type="AXIS_ANGLE",
invert=False,
vector=position(),
center=root_position,
axis=tangent_axis,
angle=curl_angle,
)
curled_blades = set_position(geometry=realized_blades, position=curled_position, offset=(0.0, 0.0, 0.0))
profile = curve_circle(mode=CurveCircle.Mode.RADIUS, resolution=3, radius=thickness)
radius_attribute = named_attribute(data_type=NamedAttribute.DataType.FLOAT, name="radius")
radius_scale = switch(input_type=Switch.InputType.FLOAT, switch=radius_attribute.exists, false=1.0, true=radius_attribute.attribute)
mesh = curve_to_mesh(curve=curled_blades, profile_curve=profile, scale=radius_scale, fill_caps=False)
smooth_mesh = set_shade_smooth(domain=SetShadeSmooth.Domain.FACE, mesh=mesh, shade_smooth=False)
return {"Geometry": set_material(geometry=smooth_mesh, material=None)}
def _finalize_groups():
import bpy
groups = []
for name in ("VG Grass Tuft Generator",):
group = bpy.data.node_groups.get(name)
if group:
group.use_fake_user = True
groups.append(group)
return groups
_finalize_groups()
if __name__ == "__main__":
for group in _finalize_groups():
print(
"VG_INSTANCE_ATTRIBUTES_GROUP",
group.name,
len(group.nodes),
len(group.links),
sorted(set(node.bl_idname for node in group.nodes)),
)

View file

@ -0,0 +1,191 @@
"""Geometry Script recreation of Blender's shortest-path labyrinth demo."""
try:
from tools.geometry_script_loader import load_repo_geometry_script
except ModuleNotFoundError:
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from tools.geometry_script_loader import load_repo_geometry_script
load_repo_geometry_script()
from geometry_script import * # noqa: F403 - Geometry Script exposes node functions as DSL globals.
from geometry_script.api.node_mapper import OutputsList, set_or_create_link
from geometry_script.api.state import State
from geometry_script.api.types import Type
def _capture_attribute_item(data_type: str, domain: str, geometry, value, name: str):
node = State.current_node_tree.nodes.new("GeometryNodeCaptureAttribute")
node.capture_items.new(data_type, name)
node.active_index = 0
node.domain = domain
set_or_create_link(geometry, node.inputs[0])
set_or_create_link(value, node.inputs[1])
return OutputsList({"geometry": Type(node.outputs[0]), name.lower().replace(" ", "_").replace("/", "_"): Type(node.outputs[1])})
@tree("VG Solvable Labyrinth Generator")
def vg_solvable_labyrinth_generator(
geometry: Geometry,
size: Int = 20,
seed: Int = 247,
solve: Float = 1.0,
):
del geometry
base = grid(size_x=1.0, size_y=1.0, vertices_x=size, vertices_y=size)
base_with_uv = store_named_attribute(
data_type=StoreNamedAttribute.DataType.FLOAT_VECTOR,
domain=StoreNamedAttribute.Domain.CORNER,
geometry=base.mesh,
name="uv_map",
value=base.uv_map,
)
start_vertex = compare(
operation=Compare.Operation.EQUAL,
data_type=Compare.DataType.INT,
mode=Compare.Mode.ELEMENT,
a=index(),
b=0,
)
sparse_edges = compare(
operation=Compare.Operation.LESS_THAN,
data_type=Compare.DataType.INT,
mode=Compare.Mode.ELEMENT,
a=edge_neighbors(),
b=2,
)
random_cost = random_value(data_type=RandomValue.DataType.BOOLEAN, probability=0.5, seed=seed)
edge_cost = switch(input_type=Switch.InputType.FLOAT, switch=sparse_edges, false=random_cost, true=0.0)
random_paths = shortest_edge_paths(end_vertex=start_vertex, edge_cost=edge_cost)
random_path_selection = edge_paths_to_selection(next_vertex_index=random_paths.next_vertex_index)
captured_maze_edges = _capture_attribute_item("BOOLEAN", "EDGE", base_with_uv, random_path_selection, "Path")
subdivided = subdivide_mesh(mesh=captured_maze_edges.geometry, level=1)
carved_walkable = delete_geometry(
mode=DeleteGeometry.Mode.ALL,
domain=DeleteGeometry.Domain.POINT,
geometry=subdivided,
selection=captured_maze_edges.path,
)
parts = separate_xyz(vector=position())
direct_paths = shortest_edge_paths(end_vertex=start_vertex)
direct_selection = edge_paths_to_selection(next_vertex_index=direct_paths.next_vertex_index)
x_stats_on_path = attribute_statistic(
data_type=AttributeStatistic.DataType.FLOAT,
domain=AttributeStatistic.Domain.POINT,
geometry=carved_walkable,
selection=direct_selection,
attribute=parts.x,
)
far_x_vertices = compare(
operation=Compare.Operation.EQUAL,
data_type=Compare.DataType.FLOAT,
mode=Compare.Mode.ELEMENT,
a=parts.x,
b=x_stats_on_path.max,
epsilon=0.0010000000474974513,
)
solution_curves = edge_paths_to_curves(
mesh=carved_walkable,
start_vertices=far_x_vertices,
next_vertex_index=direct_paths.next_vertex_index,
)
marker_radius = math(operation=Math.Operation.DIVIDE, value=(0.10000000149011612, size))
marker_mesh = ico_sphere(radius=marker_radius, subdivisions=3)
marker_with_uv = store_named_attribute(
data_type=StoreNamedAttribute.DataType.FLOAT_VECTOR,
domain=StoreNamedAttribute.Domain.CORNER,
geometry=marker_mesh.mesh,
name="UVMap",
value=marker_mesh.uv_map,
)
endpoint_markers = instance_on_points(
points=solution_curves,
selection=endpoint_selection(start_size=1, end_size=1),
instance=marker_with_uv,
pick_instance=False,
rotation=(0.0, 0.0, 0.0),
scale=3.0,
)
marker_indices = _capture_attribute_item("INT", "INSTANCE", endpoint_markers, index(), "Start End")
realized_markers = realize_instances(
realize_to_point_domain=True,
geometry=marker_indices.geometry,
realize_all=True,
depth=0,
)
marker_geometry = set_material(geometry=realized_markers, material=None)
trimmed_solution = trim_curve(mode=TrimCurve.Mode.FACTOR, curve=solution_curves, start=0.0, end=solve)
captured_solution = _capture_attribute_item("BOOLEAN", "CURVE", trimmed_solution, True, "Path")
maze_walls_source = delete_geometry(
mode=DeleteGeometry.Mode.ALL,
domain=DeleteGeometry.Domain.POINT,
geometry=subdivided,
selection=boolean_math(operation=BooleanMath.Operation.NOT, boolean=captured_maze_edges.path),
)
wall_curves = mesh_to_curve(mode="EDGES", mesh=maze_walls_source)
all_curves = join_geometry(geometry=[captured_solution.geometry, wall_curves])
filleted = fillet_curve(curve=all_curves, radius=0.004999999888241291, limit_radius=True, mode="Poly", count=6)
curve_radius = switch(input_type=Switch.InputType.FLOAT, switch=captured_solution.path, false=2.0, true=1.0)
radius_curves = set_curve_radius(curve=filleted, radius=curve_radius)
smoothed_marker = set_shade_smooth(domain=SetShadeSmooth.Domain.FACE, mesh=marker_with_uv, shade_smooth=True)
curve_endpoint_markers = instance_on_points(
points=radius_curves,
selection=endpoint_selection(start_size=1, end_size=1),
instance=smoothed_marker,
pick_instance=False,
rotation=(0.0, 0.0, 0.0),
scale=radius(),
)
realized_curve_markers = realize_instances(
realize_to_point_domain=True,
geometry=curve_endpoint_markers,
realize_all=True,
depth=0,
)
profile = curve_circle(mode=CurveCircle.Mode.RADIUS, resolution=16, radius=marker_radius)
radius_attribute = named_attribute(data_type=NamedAttribute.DataType.FLOAT, name="radius")
profile_scale = switch(input_type=Switch.InputType.FLOAT, switch=radius_attribute.exists, false=1.0, true=radius_attribute.attribute)
path_mesh = curve_to_mesh(curve=radius_curves, profile_curve=profile, scale=profile_scale, fill_caps=False)
curve_geometry = set_material(geometry=join_geometry(geometry=[realized_curve_markers, path_mesh]), material=None)
base_geometry = set_material(geometry=base_with_uv, material=None)
return {
"Geometry": join_geometry(geometry=[marker_geometry, curve_geometry, base_geometry]),
"Path": captured_solution.path,
"Start/End": marker_indices.start_end,
}
def _finalize_groups():
import bpy
groups = []
for name in ("VG Solvable Labyrinth Generator",):
group = bpy.data.node_groups.get(name)
if group:
group.use_fake_user = True
groups.append(group)
return groups
_finalize_groups()
if __name__ == "__main__":
for group in _finalize_groups():
print(
"VG_LABYRINTH_GROUP",
group.name,
len(group.nodes),
len(group.links),
sorted(set(node.bl_idname for node in group.nodes)),
)

View file

@ -0,0 +1,115 @@
"""Geometry Script footholds from Blender's raycast minigame demo."""
try:
from tools.geometry_script_loader import load_repo_geometry_script
except ModuleNotFoundError:
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from tools.geometry_script_loader import load_repo_geometry_script
load_repo_geometry_script()
from geometry_script import * # noqa: F403 - Geometry Script exposes node functions as DSL globals.
@tree("VG Initial Direction")
def vg_initial_direction(rotation: Vector = (0.0, 0.0, 0.0)):
forward = combine_xyz(x=1.0, y=0.0, z=0.0)
return {
"Vector": vector_rotate(
rotation_type="EULER_XYZ",
invert=False,
vector=forward,
center=(0.0, 0.0, 0.0),
rotation=rotation,
)
}
@tree("VG Line To Be Casted")
def vg_line_to_be_casted(
start_pos: Vector = (0.0, 0.0, 0.0),
line_size: Int = 3,
):
seed_line = curve_line(mode=CurveLine.Mode.POINTS, start=(0.0, 0.0, 0.0), end=(0.0, 0.0, 0.0))
placed = set_position(geometry=seed_line, position=start_pos, offset=(0.0, 0.0, 0.0))
return {
"Line": resample_curve(
keep_last_segment=False,
curve=placed,
mode="Count",
count=line_size,
length=0.10000000149011612,
)
}
@tree("VG Cast Rays")
def vg_cast_rays(
line: Geometry,
ray_direction: Vector = (0.0, 0.0, 0.0),
traveled_distance: Float = 0.0,
hit_index: Int = 1,
target: Object = None,
):
active_point = compare(
operation=Compare.Operation.EQUAL,
data_type=Compare.DataType.INT,
mode=Compare.Mode.ELEMENT,
a=index(),
b=hit_index,
)
target_info = object_info(transform_space="RELATIVE", object=target, as_instance=False)
previous_index = math(operation=Math.Operation.SUBTRACT, value=(hit_index, integer(integer=1)))
previous_position = sample_index(
data_type=SampleIndex.DataType.FLOAT_VECTOR,
domain=SampleIndex.Domain.POINT,
clamp=True,
geometry=line,
value=position(),
index=previous_index,
)
hit = raycast(
data_type="FLOAT_VECTOR",
target_geometry=target_info.geometry,
interpolation="Nearest",
source_position=previous_position,
ray_direction=ray_direction,
ray_length=20.0,
)
hit_position = vector_math(operation=VectorMath.Operation.SCALE, vector=hit.hit_position, scale=0.9990000128746033)
updated_line = set_position(geometry=line, selection=active_point, position=hit_position, offset=(0.0, 0.0, 0.0))
return {
"Line": updated_line,
"Reflected Direction": vector_math(operation=VectorMath.Operation.REFLECT, vector=(ray_direction, hit.hit_normal)),
"Traveled Distance": math(operation=Math.Operation.ADD, value=(hit.hit_distance, traveled_distance)),
"Next Hit Index": math(operation=Math.Operation.ADD, value=(hit_index, integer(integer=1))),
}
def _finalize_groups():
import bpy
groups = []
for name in ("VG Initial Direction", "VG Line To Be Casted", "VG Cast Rays"):
group = bpy.data.node_groups.get(name)
if group:
group.use_fake_user = True
groups.append(group)
return groups
_finalize_groups()
if __name__ == "__main__":
for group in _finalize_groups():
print(
"VG_RAYCAST_GROUP",
group.name,
len(group.nodes),
len(group.links),
sorted(set(node.bl_idname for node in group.nodes)),
)

View file

@ -57,6 +57,23 @@ The completed CurveToMeshUV utility sample is
`docs/research/translations/quellenform-curve-to-mesh-uv.md`. It covers
`Auto Smooth`, `Curve to Mesh UV`, `_258246`, and `_Title`.
The completed official Blender demo tranche now includes:
- `docs/research/translations/blender-instance-attributes.md`, covering
`Grass Tuft Generator`.
- `docs/research/translations/blender-index-of-nearest.md`, covering
`boundary_step`, `update_velocity`, `collision_step`, and `collider_step`.
- `docs/research/translations/blender-labyrinth-shortest-path.md`, covering
`Solvable Labyrinth Generator`.
- `docs/research/translations/blender-raycast-minigame.md`, covering
`Initial Direction`, `Line to be Casted`, and `Cast Rays`.
Official demo files inspected but deferred are listed in
`docs/research/geonodes-translation-corpus.md`: hexgrid, wavy wall, pebble
scattering, gizmo array, jiggly pudding, and repeat-zone flower. They are not
empty; they need legacy-node migration, gizmo-node, simulation-zone, or
repeat-zone support before they are good doctrine targets.
`docs/research/procedural-doctrine.md` now stores the current spatial reasoning
playbook for mapping geometric ideas to Geometry Script. Doctrine entries should
explain when a tool becomes salient for a visual form, the mental move that
@ -82,10 +99,12 @@ The GameCult fork is intentionally pruned to `main` plus VibeGeometry-owned
tooling branches. Upstream branch clutter should not be copied forward unless a
future patch actually needs it.
The current next action is to add a new source sample focused on scattering,
instancing, and attribute distribution. Keep
`docs/research/procedural-doctrine.md` compact; put sample-specific graph maps
and verification details in `docs/research/translations/`.
The current next action is to move from translation-corpus chewing into the
next architecture organ: define the scene brief and node graph manifest
contracts using the verified idioms and deferred-zone blockers as pressure
cases. Keep `docs/research/procedural-doctrine.md` compact; put
sample-specific graph maps and verification details in
`docs/research/translations/`.
## Important Invariants

View file

@ -25,3 +25,4 @@
{"ts": "2026-05-04T14:54:04+00:00", "type": "implementation", "status": "ok", "note": "Completed and verified full VG Field Value translation, including Blender 5 capture-item helper and Geometry Script menu-socket default tolerance patch. Added and verified paramnpolareq translations for equation helpers, Archimedes spiral, epicycloid, and mirrored root spiral."}
{"ts": "2026-05-04T14:59:36+00:00", "type": "implementation", "status": "ok", "note": "Started CurveToMeshUV utility sample by translating and verifying Auto Smooth; main Curve to Mesh UV remains a staged utility-quarry target rather than a one-pass translation."}
{"ts": "2026-05-04T15:57:11+00:00", "type": "implementation", "status": "ok", "note": "Finished remaining local sample graph families: extended pie clones/compositor, param/polar selector and wrapper, and full CurveToMeshUV utility/demo/title with mesh, UV-field, and caps-mask harness verification."}
{"ts": "2026-05-04T16:56:12+00:00", "type": "implementation", "status": "accepted", "note": "Expanded the verified Geometry Nodes translation corpus with official Blender demo samples: instance attributes grass tuft, index-of-nearest helpers, shortest-path labyrinth, and raycast minigame helpers. All new verifiers pass in Blender 5.1.1 with sorted max vertex delta 0.0 across their harness cases. Deferred official samples are classified as legacy-node, gizmo-node, simulation-zone, or repeat-zone targets rather than padded into doctrine."}

View file

@ -91,8 +91,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 all currently inspected local sample graph families: Shriinivas cartesian, pie chart including extended clones, field-value full display, parametric/polar selectors and wrappers, plus CurveToMeshUV utility/demo/title graphs. The repo-local Geometry Script fork includes a Blender 5.1 nodes_to_script converter port plus nested-group and menu-socket fixes needed by these translations.
next_action: Add a new source sample focused on scattering/instancing and attribute distribution; keep doctrine compact and put graph-specific autopsies under `docs/research/translations/`.
summary: VibeGeometry has an initial persistence scaffold plus verified Geometry Script translations for local math/utility samples and a first official Blender demo tranche: instance attributes grass tuft, index-of-nearest helpers, shortest-path labyrinth, and raycast minigame helpers. Deferred official samples are now classified when they require legacy-node migration, gizmo-node authoring, repeat-zone support, or simulation-zone support. The repo-local Geometry Script fork includes a Blender 5.1 nodes_to_script converter port plus nested-group and menu-socket fixes needed by these translations.
next_action: Move from translation-corpus chewing into the next architecture organ: define the scene brief and node graph manifest contracts using the verified idioms and deferred-zone blockers as pressure cases.
remotes:
vibegeometry: https://github.com/GameCult/VibeGeometry
geometry_script_fork: https://github.com/GameCult/geometry-script

View file

@ -0,0 +1,199 @@
"""Compare compact index_of_nearest demo helpers against Geometry Script translations."""
from __future__ import annotations
import importlib.util
import json
import math
import sys
from pathlib import Path
import bpy
ROOT = Path(__file__).resolve().parents[1]
TRANSLATION = ROOT / "examples" / "geometry_script" / "blender_index_of_nearest.py"
def _load_translation() -> None:
spec = importlib.util.spec_from_file_location("vg_index_of_nearest_translation", TRANSLATION)
if spec is None or spec.loader is None:
raise RuntimeError(f"Could not load translation script: {TRANSLATION}")
module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = module
spec.loader.exec_module(module)
def _socket_by_name(sockets, name: str):
for socket in sockets:
if socket.name == name:
return socket
raise KeyError(name)
def _socket_key(name: str) -> str:
return name.lower().replace(" ", "").replace("_", "")
def _set_inputs(group_node: bpy.types.GeometryNode, inputs: dict[str, object]) -> None:
normalized = {_socket_key(key): value for key, value in inputs.items()}
for socket in group_node.inputs:
key = _socket_key(socket.name)
if key in normalized:
socket.default_value = normalized[key]
def _new_geometry_group(name: str) -> bpy.types.GeometryNodeTree:
if name in bpy.data.node_groups:
bpy.data.node_groups.remove(bpy.data.node_groups[name])
group = bpy.data.node_groups.new(name, "GeometryNodeTree")
group.is_modifier = True
group.interface.new_socket(name="Geometry", in_out="INPUT", socket_type="NodeSocketGeometry")
group.interface.new_socket(name="Geometry", in_out="OUTPUT", socket_type="NodeSocketGeometry")
return group
def _add_line(nodes, *, count: int = 6, offset=(0.024000000208616257, 0.017999999225139618, 0.0)):
line = nodes.new("GeometryNodeMeshLine")
line.mode = "OFFSET"
line.count_mode = "TOTAL"
_socket_by_name(line.inputs, "Count").default_value = count
_socket_by_name(line.inputs, "Offset").default_value = offset
return line
def _build_geometry_wrapper(name: str, source_group: bpy.types.GeometryNodeTree, inputs: dict[str, object] | None = None):
wrapper = _new_geometry_group(name)
nodes = wrapper.nodes
links = wrapper.links
line = _add_line(nodes)
group_node = nodes.new("GeometryNodeGroup")
group_node.node_tree = source_group
links.new(_socket_by_name(line.outputs, "Mesh"), _socket_by_name(group_node.inputs, "Geometry"))
_set_inputs(group_node, inputs or {})
group_output = nodes.new("NodeGroupOutput")
links.new(_socket_by_name(group_node.outputs, "Geometry"), _socket_by_name(group_output.inputs, "Geometry"))
return wrapper
def _build_velocity_wrapper(name: str, source_group: bpy.types.GeometryNodeTree):
wrapper = _new_geometry_group(name)
nodes = wrapper.nodes
links = wrapper.links
line = _add_line(nodes, count=4, offset=(0.020000000298023224, 0.0, 0.0))
group_node = nodes.new("GeometryNodeGroup")
group_node.node_tree = source_group
_set_inputs(
group_node,
{
"Current Velocity": (0.0020000000949949026, 0.004000000189989805, 0.0),
"Last Position": (0.009999999776482582, 0.0, 0.0),
},
)
set_position = nodes.new("GeometryNodeSetPosition")
links.new(_socket_by_name(line.outputs, "Mesh"), _socket_by_name(set_position.inputs, "Geometry"))
links.new(_socket_by_name(group_node.outputs, "velocity"), _socket_by_name(set_position.inputs, "Position"))
group_output = nodes.new("NodeGroupOutput")
links.new(_socket_by_name(set_position.outputs, "Geometry"), _socket_by_name(group_output.inputs, "Geometry"))
return wrapper
def _build_collision_wrapper(name: str, source_group: bpy.types.GeometryNodeTree):
wrapper = _new_geometry_group(name)
nodes = wrapper.nodes
links = wrapper.links
line = _add_line(nodes, count=5, offset=(0.003000000026077032, 0.0, 0.0))
points = nodes.new("GeometryNodeMeshToPoints")
points.mode = "VERTICES"
links.new(_socket_by_name(line.outputs, "Mesh"), _socket_by_name(points.inputs, "Mesh"))
radius = nodes.new("GeometryNodeSetPointRadius")
_socket_by_name(radius.inputs, "Radius").default_value = 0.02500000037252903
links.new(_socket_by_name(points.outputs, "Points"), _socket_by_name(radius.inputs, "Points"))
group_node = nodes.new("GeometryNodeGroup")
group_node.node_tree = source_group
links.new(_socket_by_name(radius.outputs, "Points"), _socket_by_name(group_node.inputs, "Geometry"))
vertices = nodes.new("GeometryNodePointsToVertices")
links.new(_socket_by_name(group_node.outputs, "Geometry"), _socket_by_name(vertices.inputs, "Points"))
group_output = nodes.new("NodeGroupOutput")
links.new(_socket_by_name(vertices.outputs, "Mesh"), _socket_by_name(group_output.inputs, "Geometry"))
return wrapper
def _build_collider_wrapper(name: str, source_group: bpy.types.GeometryNodeTree, inputs: dict[str, object] | None = None):
return _build_geometry_wrapper(name, source_group, inputs)
def _evaluated_vertices(group: bpy.types.GeometryNodeTree):
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 _compare(case: str, source_group, translated_group, builder, source_inputs=None, translated_inputs=None):
source = _evaluated_vertices(builder(f"VG Verify Source {case}", source_group, source_inputs or {}) if builder != _build_velocity_wrapper and builder != _build_collision_wrapper else builder(f"VG Verify Source {case}", source_group))
translated = _evaluated_vertices(
builder(f"VG Verify Translated {case}", translated_group, translated_inputs or {})
if builder != _build_velocity_wrapper and builder != _build_collision_wrapper
else builder(f"VG Verify Translated {case}", translated_group)
)
max_delta = (
max((math.dist(a, b) for a, b in zip(sorted(source), sorted(translated))), default=0.0)
if len(source) == len(translated)
else math.inf
)
return {
"case": case,
"source_vertex_count": len(source),
"translated_vertex_count": len(translated),
"max_sorted_vertex_delta": max_delta,
"ok": len(source) == len(translated) and max_delta <= 1e-6,
}
def main() -> int:
_load_translation()
collider = bpy.data.objects.get("Icosphere")
results = [
_compare(
"boundary_step",
bpy.data.node_groups["boundary_step"],
bpy.data.node_groups["VG Boundary Step"],
_build_geometry_wrapper,
{"Vector": (0.0, 0.0, 0.0), "B": 0.05000000074505806},
{"Vector": (0.0, 0.0, 0.0), "B": 0.05000000074505806},
),
_compare("update_velocity", bpy.data.node_groups["update_velocity"], bpy.data.node_groups["VG Update Velocity"], _build_velocity_wrapper),
_compare("collision_step", bpy.data.node_groups["collision_step"], bpy.data.node_groups["VG Collision Step"], _build_collision_wrapper),
_compare(
"collider_step",
bpy.data.node_groups["collider_step"],
bpy.data.node_groups["VG Collider Step"],
_build_collider_wrapper,
{},
{"Collider": collider},
),
]
payload = {"ok": all(result["ok"] for result in results), "results": results}
print("VG_INDEX_OF_NEAREST_TRANSLATION_BEHAVIOR " + json.dumps(payload, sort_keys=True))
return 0 if payload["ok"] else 1
if __name__ == "__main__":
raise SystemExit(main())

View file

@ -0,0 +1,151 @@
"""Compare Blender's instance attributes demo against the Geometry Script translation."""
from __future__ import annotations
import importlib.util
import json
import math
import sys
from pathlib import Path
import bpy
ROOT = Path(__file__).resolve().parents[1]
TRANSLATION = ROOT / "examples" / "geometry_script" / "blender_instance_attributes.py"
CASES = {
"default": {
"Height": 0.20000000298023224,
"Radius": 0.05000000074505806,
"Density": 1.0,
"Thickness": 0.009999999776482582,
"Curl": 0.5,
"Seed": 0,
},
"wider_curlier_seeded": {
"Height": 0.24000000953674316,
"Radius": 0.07000000029802322,
"Density": 0.75,
"Thickness": 0.00800000037997961,
"Curl": 0.8500000238418579,
"Seed": 11,
},
}
def _load_translation() -> None:
spec = importlib.util.spec_from_file_location("vg_instance_attributes_translation", TRANSLATION)
if spec is None or spec.loader is None:
raise RuntimeError(f"Could not load translation script: {TRANSLATION}")
module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = module
spec.loader.exec_module(module)
def _socket_by_name(sockets, name: str):
for socket in sockets:
if socket.name == name:
return socket
raise KeyError(name)
def _new_geometry_group(name: str) -> bpy.types.GeometryNodeTree:
if name in bpy.data.node_groups:
bpy.data.node_groups.remove(bpy.data.node_groups[name])
group = bpy.data.node_groups.new(name, "GeometryNodeTree")
group.is_modifier = True
group.interface.new_socket(name="Geometry", in_out="INPUT", socket_type="NodeSocketGeometry")
group.interface.new_socket(name="Geometry", in_out="OUTPUT", socket_type="NodeSocketGeometry")
return group
def _build_wrapper(name: str, source_group: bpy.types.GeometryNodeTree, inputs: dict[str, object]):
wrapper = _new_geometry_group(name)
nodes = wrapper.nodes
links = wrapper.links
group_node = nodes.new("GeometryNodeGroup")
group_node.node_tree = source_group
for socket in group_node.inputs:
if socket.name in inputs:
socket.default_value = inputs[socket.name]
group_output = nodes.new("NodeGroupOutput")
links.new(_socket_by_name(group_node.outputs, "Geometry"), _socket_by_name(group_output.inputs, "Geometry"))
return wrapper
def _evaluated_mesh_summary(group: bpy.types.GeometryNodeTree):
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:
vertices = [tuple(vertex.co) for vertex in evaluated_mesh.vertices]
edges = [tuple(edge.vertices) for edge in evaluated_mesh.edges]
polygons = [tuple(polygon.vertices) for polygon in evaluated_mesh.polygons]
return {
"vertices": vertices,
"edges": edges,
"polygons": polygons,
"polygon_smooth": [polygon.use_smooth for polygon in evaluated_mesh.polygons],
}
finally:
evaluated.to_mesh_clear()
def _max_sorted_vertex_delta(source_vertices, translated_vertices) -> float:
if len(source_vertices) != len(translated_vertices):
return math.inf
return max(
(math.dist(a, b) for a, b in zip(sorted(source_vertices), sorted(translated_vertices))),
default=0.0,
)
def main() -> int:
_load_translation()
results = []
for case_name, inputs in CASES.items():
source = _evaluated_mesh_summary(
_build_wrapper(f"VG Verify Source Grass Tuft {case_name}", bpy.data.node_groups["Grass Tuft Generator"], inputs)
)
translated = _evaluated_mesh_summary(
_build_wrapper(
f"VG Verify Translated Grass Tuft {case_name}",
bpy.data.node_groups["VG Grass Tuft Generator"],
inputs,
)
)
max_delta = _max_sorted_vertex_delta(source["vertices"], translated["vertices"])
result = {
"case": f"grass_tuft_generator_{case_name}",
"source_vertex_count": len(source["vertices"]),
"translated_vertex_count": len(translated["vertices"]),
"source_edge_count": len(source["edges"]),
"translated_edge_count": len(translated["edges"]),
"source_polygon_count": len(source["polygons"]),
"translated_polygon_count": len(translated["polygons"]),
"source_smooth_faces": sum(source["polygon_smooth"]),
"translated_smooth_faces": sum(translated["polygon_smooth"]),
"max_sorted_vertex_delta": max_delta,
}
result["ok"] = (
result["source_vertex_count"] == result["translated_vertex_count"]
and result["source_edge_count"] == result["translated_edge_count"]
and result["source_polygon_count"] == result["translated_polygon_count"]
and source["polygon_smooth"] == translated["polygon_smooth"]
and max_delta <= 1e-6
)
results.append(result)
payload = {"ok": all(result["ok"] for result in results), "results": results}
print("VG_INSTANCE_ATTRIBUTES_TRANSLATION_BEHAVIOR " + json.dumps(payload, sort_keys=True))
return 0 if payload["ok"] else 1
if __name__ == "__main__":
raise SystemExit(main())

View file

@ -0,0 +1,126 @@
"""Compare Blender's shortest-path labyrinth graph against the Geometry Script translation."""
from __future__ import annotations
import importlib.util
import json
import math
import sys
from pathlib import Path
import bpy
ROOT = Path(__file__).resolve().parents[1]
TRANSLATION = ROOT / "examples" / "geometry_script" / "blender_labyrinth_shortest_path.py"
CASES = {
"small_unsolved": {"Size": 8, "Seed": 13, "Solve": 0.0},
"small_solved": {"Size": 8, "Seed": 13, "Solve": 1.0},
}
def _load_translation() -> None:
spec = importlib.util.spec_from_file_location("vg_labyrinth_translation", TRANSLATION)
if spec is None or spec.loader is None:
raise RuntimeError(f"Could not load translation script: {TRANSLATION}")
module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = module
spec.loader.exec_module(module)
def _socket_by_name(sockets, name: str):
for socket in sockets:
if socket.name == name:
return socket
raise KeyError(name)
def _new_geometry_group(name: str) -> bpy.types.GeometryNodeTree:
if name in bpy.data.node_groups:
bpy.data.node_groups.remove(bpy.data.node_groups[name])
group = bpy.data.node_groups.new(name, "GeometryNodeTree")
group.is_modifier = True
group.interface.new_socket(name="Geometry", in_out="INPUT", socket_type="NodeSocketGeometry")
group.interface.new_socket(name="Geometry", in_out="OUTPUT", socket_type="NodeSocketGeometry")
return group
def _build_wrapper(name: str, source_group: bpy.types.GeometryNodeTree, inputs: dict[str, object]):
wrapper = _new_geometry_group(name)
nodes = wrapper.nodes
links = wrapper.links
group_node = nodes.new("GeometryNodeGroup")
group_node.node_tree = source_group
for socket in group_node.inputs:
if socket.name in inputs:
socket.default_value = inputs[socket.name]
group_output = nodes.new("NodeGroupOutput")
links.new(_socket_by_name(group_node.outputs, "Geometry"), _socket_by_name(group_output.inputs, "Geometry"))
return wrapper
def _evaluated_mesh_summary(group: bpy.types.GeometryNodeTree):
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 {
"vertices": [tuple(vertex.co) for vertex in evaluated_mesh.vertices],
"edges": [tuple(edge.vertices) for edge in evaluated_mesh.edges],
"polygons": [tuple(polygon.vertices) for polygon in evaluated_mesh.polygons],
}
finally:
evaluated.to_mesh_clear()
def main() -> int:
_load_translation()
results = []
for case_name, inputs in CASES.items():
source = _evaluated_mesh_summary(
_build_wrapper(f"VG Verify Source Labyrinth {case_name}", bpy.data.node_groups["Solvable Labyrinth Generator"], inputs)
)
translated = _evaluated_mesh_summary(
_build_wrapper(
f"VG Verify Translated Labyrinth {case_name}",
bpy.data.node_groups["VG Solvable Labyrinth Generator"],
inputs,
)
)
max_delta = (
max(
(math.dist(a, b) for a, b in zip(sorted(source["vertices"]), sorted(translated["vertices"]))),
default=0.0,
)
if len(source["vertices"]) == len(translated["vertices"])
else math.inf
)
result = {
"case": f"labyrinth_{case_name}",
"source_vertex_count": len(source["vertices"]),
"translated_vertex_count": len(translated["vertices"]),
"source_edge_count": len(source["edges"]),
"translated_edge_count": len(translated["edges"]),
"source_polygon_count": len(source["polygons"]),
"translated_polygon_count": len(translated["polygons"]),
"max_sorted_vertex_delta": max_delta,
}
result["ok"] = (
result["source_vertex_count"] == result["translated_vertex_count"]
and result["source_edge_count"] == result["translated_edge_count"]
and result["source_polygon_count"] == result["translated_polygon_count"]
and max_delta <= 1e-6
)
results.append(result)
payload = {"ok": all(result["ok"] for result in results), "results": results}
print("VG_LABYRINTH_TRANSLATION_BEHAVIOR " + json.dumps(payload, sort_keys=True))
return 0 if payload["ok"] else 1
if __name__ == "__main__":
raise SystemExit(main())

View file

@ -0,0 +1,180 @@
"""Compare compact raycast minigame groups against Geometry Script translations."""
from __future__ import annotations
import importlib.util
import json
import math
import sys
from pathlib import Path
import bpy
ROOT = Path(__file__).resolve().parents[1]
TRANSLATION = ROOT / "examples" / "geometry_script" / "blender_raycast_minigame.py"
def _load_translation() -> None:
spec = importlib.util.spec_from_file_location("vg_raycast_translation", TRANSLATION)
if spec is None or spec.loader is None:
raise RuntimeError(f"Could not load translation script: {TRANSLATION}")
module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = module
spec.loader.exec_module(module)
def _socket_by_name(sockets, name: str):
for socket in sockets:
if socket.name == name:
return socket
raise KeyError(name)
def _socket_key(name: str) -> str:
return name.lower().replace(" ", "").replace("_", "")
def _set_inputs(group_node: bpy.types.GeometryNode, inputs: dict[str, object]) -> None:
normalized = {_socket_key(key): value for key, value in inputs.items()}
for socket in group_node.inputs:
key = _socket_key(socket.name)
if key in normalized:
socket.default_value = normalized[key]
def _new_geometry_group(name: str) -> bpy.types.GeometryNodeTree:
if name in bpy.data.node_groups:
bpy.data.node_groups.remove(bpy.data.node_groups[name])
group = bpy.data.node_groups.new(name, "GeometryNodeTree")
group.is_modifier = True
group.interface.new_socket(name="Geometry", in_out="INPUT", socket_type="NodeSocketGeometry")
group.interface.new_socket(name="Geometry", in_out="OUTPUT", socket_type="NodeSocketGeometry")
return group
def _points_to_vertices(nodes, links, curve_socket):
points = nodes.new("GeometryNodeCurveToPoints")
points.mode = "EVALUATED"
links.new(curve_socket, _socket_by_name(points.inputs, "Curve"))
vertices = nodes.new("GeometryNodePointsToVertices")
links.new(_socket_by_name(points.outputs, "Points"), _socket_by_name(vertices.inputs, "Points"))
return _socket_by_name(vertices.outputs, "Mesh")
def _build_initial_direction_wrapper(name: str, source_group: bpy.types.GeometryNodeTree):
wrapper = _new_geometry_group(name)
nodes = wrapper.nodes
links = wrapper.links
line = nodes.new("GeometryNodeMeshLine")
line.mode = "OFFSET"
line.count_mode = "TOTAL"
_socket_by_name(line.inputs, "Count").default_value = 1
group_node = nodes.new("GeometryNodeGroup")
group_node.node_tree = source_group
_set_inputs(group_node, {"Rotation": (0.0, 0.0, 0.7853981852531433)})
set_position = nodes.new("GeometryNodeSetPosition")
links.new(_socket_by_name(line.outputs, "Mesh"), _socket_by_name(set_position.inputs, "Geometry"))
links.new(_socket_by_name(group_node.outputs, "Vector"), _socket_by_name(set_position.inputs, "Position"))
group_output = nodes.new("NodeGroupOutput")
links.new(_socket_by_name(set_position.outputs, "Geometry"), _socket_by_name(group_output.inputs, "Geometry"))
return wrapper
def _build_line_wrapper(name: str, source_group: bpy.types.GeometryNodeTree):
wrapper = _new_geometry_group(name)
nodes = wrapper.nodes
links = wrapper.links
group_node = nodes.new("GeometryNodeGroup")
group_node.node_tree = source_group
_set_inputs(group_node, {"Start Pos": (0.25, -0.125, 0.0), "Line Size": 5})
mesh_socket = _points_to_vertices(nodes, links, _socket_by_name(group_node.outputs, "Line"))
group_output = nodes.new("NodeGroupOutput")
links.new(mesh_socket, _socket_by_name(group_output.inputs, "Geometry"))
return wrapper
def _build_cast_rays_wrapper(name: str, source_group: bpy.types.GeometryNodeTree, target=None):
wrapper = _new_geometry_group(name)
nodes = wrapper.nodes
links = wrapper.links
line_group = nodes.new("GeometryNodeGroup")
line_group.node_tree = bpy.data.node_groups["Line to be Casted"]
_set_inputs(line_group, {"Start Pos": (0.0, 0.0, 0.0), "Line Size": 4})
group_node = nodes.new("GeometryNodeGroup")
group_node.node_tree = source_group
_set_inputs(
group_node,
{
"Ray Direction": (1.0, 0.25, 0.0),
"Traveled Distance": 0.0,
"Hit Index": 1,
"Target": target,
},
)
links.new(_socket_by_name(line_group.outputs, "Line"), _socket_by_name(group_node.inputs, "Line"))
mesh_socket = _points_to_vertices(nodes, links, _socket_by_name(group_node.outputs, "Line"))
group_output = nodes.new("NodeGroupOutput")
links.new(mesh_socket, _socket_by_name(group_output.inputs, "Geometry"))
return wrapper
def _evaluated_vertices(group: bpy.types.GeometryNodeTree):
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 _compare(case: str, source_group, translated_group, source_builder, translated_builder=None):
translated_builder = translated_builder or source_builder
source = _evaluated_vertices(source_builder(f"VG Verify Source {case}", source_group))
translated = _evaluated_vertices(translated_builder(f"VG Verify Translated {case}", translated_group))
max_delta = (
max((math.dist(a, b) for a, b in zip(sorted(source), sorted(translated))), default=0.0)
if len(source) == len(translated)
else math.inf
)
return {
"case": case,
"source_vertex_count": len(source),
"translated_vertex_count": len(translated),
"max_sorted_vertex_delta": max_delta,
"ok": len(source) == len(translated) and max_delta <= 1e-6,
}
def main() -> int:
_load_translation()
target = bpy.data.objects.get("Field and Boundaries")
results = [
_compare("initial_direction", bpy.data.node_groups["Initial Direction"], bpy.data.node_groups["VG Initial Direction"], _build_initial_direction_wrapper),
_compare("line_to_be_casted", bpy.data.node_groups["Line to be Casted"], bpy.data.node_groups["VG Line To Be Casted"], _build_line_wrapper),
_compare(
"cast_rays",
bpy.data.node_groups["Cast Rays"],
bpy.data.node_groups["VG Cast Rays"],
lambda name, group: _build_cast_rays_wrapper(name, group),
lambda name, group: _build_cast_rays_wrapper(name, group, target),
),
]
payload = {"ok": all(result["ok"] for result in results), "results": results}
print("VG_RAYCAST_TRANSLATION_BEHAVIOR " + json.dumps(payload, sort_keys=True))
return 0 if payload["ok"] else 1
if __name__ == "__main__":
raise SystemExit(main())