"""Arrange staggered calculation branches on both sides of the geometry path.""" from node_layout import arrange_nodes # Main geometry advances left to right. Local fields grow to either side of it; # a long calculation may start before the geometry input or span several stages. POSITIONS = { "Position": (0, 260), "Store Named Attribute": (0, 0), "Store Named Attribute.001": (260, 0), "Store Named Attribute.002": (520, 0), "Store Named Attribute.003": (780, 0), "Split Edges": (1060, 0), "Switch": (1360, 0), # Face sampling stays near its stores; selection forms a dense field cluster. "Named Attribute": (-400, -320), "Evaluate on Domain": (-180, -320), "Image Texture": (20, -320), "Named Attribute.003": (260, 260), "Named Attribute.001": (-1090, 1060), "Separate XYZ": (-870, 1060), "Named Attribute.002": (-390, 590), "Corners of Edge": (-1090, 910), "Face of Corner": (-910, 910), "Corners of Edge.001": (-1090, 770), "Face of Corner.001": (-910, 770), "Evaluate at Index": (-170, 750), "Evaluate at Index.002": (-170, 610), "Evaluate at Index.001": (-710, 1060), "Evaluate at Index.003": (-710, 920), "Vector Math": (10, 710), "Math": (-530, 1040), "Math.001": (-350, 1040), "Math.002": (-170, 1040), "Math.003": (-350, 830), "Math.004": (10, 1040), "Math.005": (190, 1040), "Math.006": (190, 790), "Math.007": (370, 980), "Math.008": (190, 620), "Math.009": (550, 910), "Edge Neighbors": (370, 590), "Math.010": (550, 590), "Math.011": (730, 810), "Evaluate on Domain.001": (730, 670), "Evaluate on Domain.002": (910, 670), "Math.012": (1090, 670), "Math.013": (1360, 280), # Cleanup is a separate compact cluster before projection. "Face Area": (1460, 780), "Mesh Island": (1460, 580), "Accumulate Field": (1680, 780), "Math.014": (1900, 580), "Delete Geometry": (2120, 0), # Camera-ray reconstruction runs below; scene projection runs above. "Named Attribute.004": (1290, -440), "Image Texture.001": (1510, -440), "Separate XYZ.001": (1740, -440), "Named Attribute.005": (1510, -710), "Separate XYZ.002": (1740, -710), "Math.017": (1960, -440), "Vector Math.001": (2180, -440), "Named Attribute.006": (1740, -940), "Math.015": (1510, -940), "Math.016": (1960, -940), "Switch.001": (2600, -240), "Store Named Attribute.004": (2920, 0), "Named Attribute.007": (2340, 1080), "Vector Math.002": (2560, 1080), "Separate XYZ.003": (2740, 1080), "Math.018": (3100, 730), "Math.019": (3280, 730), "Math.020": (2740, 910), "Combine XYZ": (2920, 1040), "Position.001": (2920, 790), "Mix": (3100, 950), "Separate XYZ.004": (3280, 950), "Combine XYZ.001": (3460, 850), "Set Position": (3870, 0), # Short preparation fields sit above the axis; the long wall-count branch # sits below, reading geometry back from the source-vertex store. "Position.002": (4560, 340), "Store Named Attribute.005": (4560, 0), "Vector Math.003": (4780, 340), "Set Position.001": (4780, 0), "Index": (5010, 340), "Store Named Attribute.006": (5010, 0), "Edge Vertices": (3470, -610), "Vector Math.004": (3700, -610), "Edge Neighbors.001": (3470, -850), "Math.021": (3700, -850), "Attribute Statistic": (3920, -610), "Math.022": (4150, -610), "Math.023": (4370, -610), "Math.024": (4590, -610), "Math.025": (4820, -610), "Math.026": (5040, -610), "Store Named Attribute.007": (5310, 0), "Repeat Input": (5620, 0), "Extrude Mesh": (5850, 0), "Combine XYZ.003": (5620, -340), "Separate Geometry": (6070, 0), "Join Geometry": (6300, -180), "Repeat Output": (6520, 0), "Flip Faces.001": (6740, 0), "Join Geometry.001": (6970, 0), "Named Attribute.010": (5620, -530), "Math.027": (5850, -530), "Combine XYZ.004": (6070, -530), "Set Position.002": (6300, -320), "Flip Faces": (6740, -320), # Identity decoding above and position restoration below have independent, # horizontally spread readers rather than equally tall vertical stacks. "Named Attribute.008": (6240, 880), "Integer Math": (6470, 880), "Named Attribute.009": (6240, 650), "Integer Math.001": (6470, 650), "Position.004": (6240, 410), "Separate XYZ.006": (6470, 410), "Combine XYZ.002": (6670, 650), "Set Position.003": (7410, 0), "Merge by Distance": (7640, 0), "Position.003": (6910, -950), "Separate XYZ.005": (7160, -950), "Named Attribute.011": (6900, -710), "Math.028": (7140, -580), "Math.029": (7380, -750), "Combine XYZ.005": (7600, -680), "Named Attribute.012": (7600, -370), "Vector Math.005": (7830, -340), "Set Position.004": (8080, 0), "Math.030": (8310, 260), "Switch.002": (8310, 0), "Remove Named Attribute": (9000, 0), "Set Shade Smooth": (9220, 0), "Group Output": (9440, 0), } INPUT_REGIONS = ( (("Store Named Attribute",), (-240, 0)), (("Switch",), (1100, -300)), (("Image Texture",), (-180, -190)), (("Math.002",), (-350, 1140)), (("Math.003",), (-530, 830)), (("Math.005",), (10, 1140)), (("Math.013",), (1100, 320)), (("Math.014",), (1680, 400)), (("Image Texture.001",), (1290, -270)), (("Math.015",), (1290, -940)), (("Vector Math.002",), (2340, 1200)), (("Math.018", "Math.019"), (2920, 680)), (("Mix",), (2920, 900)), (("Math.023",), (4150, -820)), (("Math.028",), (6900, -540)), (("Math.030",), (8080, 300)), ) def _route(group, source_name, output, target_name, input_name, points): """Place geometry references around the local branches they serve.""" source = group.nodes[source_name].outputs[output] target = group.nodes[target_name].inputs[input_name] for link in list(group.links): if link.from_socket == source and link.to_socket == target: group.links.remove(link) for point in points: node = group.nodes.new("NodeReroute") node.location = point node.select = False group.links.new(source, node.inputs[0]) source = node.outputs[0] group.links.new(source, target) def layout_depth_surface(group): """Keep the geometry path readable while staggering long and short branches.""" arrange_nodes(group, POSITIONS, INPUT_REGIONS) _route( group, "Repeat Input", "Sides", "Join Geometry", "Geometry", ((5810, -170), (6280, -170)), ) _route( group, "Store Named Attribute.007", "Geometry", "Join Geometry.001", "Geometry", ((5530, 150), (6950, 150)), ) _route( group, "Store Named Attribute.007", "Geometry", "Set Position.002", "Geometry", ((5530, -270), (6280, -270)), ) _route( group, "Set Position", "Geometry", "Switch.002", "True", ((4110, 240), (8290, 240)), )