refactor: update depth cutout and surface handling for improved geometry manipulation and clarity

This commit is contained in:
2026-09-18 01:43:52 +08:00
parent 076a8c90f1
commit 0e0287d340
13 changed files with 272 additions and 191 deletions

View File

@@ -7,6 +7,8 @@ from .smoothing import edge_boundary_field, pinned_smooth
def _gated(group, value, blocked, *, default):
"""Return the value unless the blocked control is true."""
if blocked is False:
return value
node = group.nodes.new("GeometryNodeSwitch")
node.input_type = "FLOAT"
node.inputs["True"].default_value = default

View File

@@ -1,10 +1,7 @@
"""Clean cutout boundary triangles and taper the split thickness profile."""
from .depth_surface import _math
from .nodes import (
boolean_node, compare_node, evaluate_field, group_input,
read_float_attribute, sample_field, store_float_attribute,
)
from .nodes import boolean_node, compare_node, evaluate_field, read_float_attribute, store_float_attribute
from .smoothing import edge_boundary_field
from .boundary_smoothing import boundary_influence
@@ -23,37 +20,10 @@ def remove_boundary_triangles(group, geometry):
return delete.outputs["Geometry"]
def original_boundary_field(group, original, rim=None):
"""Sample the unsplit outline in UV space after projection and separation."""
nodes, links = group.nodes, group.links
uv = nodes.new("GeometryNodeInputNamedAttribute")
uv.data_type = "FLOAT_VECTOR"
uv.inputs["Name"].default_value = "UVMap"
original_uv = nodes.new("GeometryNodeSetPosition")
links.new(original, original_uv.inputs["Geometry"])
links.new(uv.outputs["Attribute"], original_uv.inputs["Position"])
nearest = nodes.new("GeometryNodeSampleNearest")
nearest.domain = "POINT"
links.new(original_uv.outputs["Geometry"], nearest.inputs["Geometry"])
links.new(uv.outputs["Attribute"], nearest.inputs["Sample Position"])
if rim is None:
rim = evaluate_field(group, edge_boundary_field(nodes, links), "FLOAT", "POINT")
return sample_field(group, original, rim, "FLOAT", index=nearest.outputs["Index"])
def taper_split_profile(group, geometry, original_boundary):
"""Taper balloon thickness through the shared two-ring influence builder."""
def taper_split_profile(group, geometry, cut_boundary):
"""Taper the balloon profile to zero across the Depth Split cuts."""
nodes = group.nodes
links = group.links
influence = boundary_influence(group, original_boundary)
controls = group_input(nodes, {"Depth Split"})
has_split = compare_node(group, "GREATER_THAN", controls.outputs["Depth Split"], 0)
band = nodes.new("GeometryNodeSwitch")
band.input_type = "FLOAT"
band.inputs["False"].default_value = 0.0
links.new(has_split, band.inputs["Switch"])
links.new(influence, band.inputs["True"])
band = band.outputs[0]
retained = _math(group, "SQRT", _math(group, "MAXIMUM", _math(group, "SUBTRACT", 1, band), 0))
retained = _math(group, "SUBTRACT", 1, boundary_influence(group, boundary=cut_boundary))
profile = _math(group, "MULTIPLY", read_float_attribute(group, "o_balloon"), retained)
return store_float_attribute(group, geometry, "o_balloon", profile)

View File

@@ -7,7 +7,7 @@ from .nodes import (
from .smoothing import edge_boundary_field
CUT_ATTRIBUTE = "_o_anyimage_depth_cut"
CUT_ATTRIBUTE = "_o_depth_cut"
def _math(group, operation, a, b=None):