Refactor geometry node groups for image depth processing
- Introduced new utility functions in common nodes for evaluating fields and capturing attributes. - Simplified volume field calculations in image depth cutout and panorama groups by utilizing new utility functions. - Enhanced readability and maintainability of the image depth cutout and panorama node groups by removing redundant code and improving function usage. - Adjusted default values for thickness and depth scale in image relief plane group for better user experience. - Improved handling of geometry attributes and connections in image depth plane group to streamline processing.
This commit is contained in:
@@ -104,3 +104,23 @@ def store_float_attribute(group, geometry, name, value, domain="POINT"):
|
||||
else:
|
||||
group.links.new(value, node.inputs["Value"])
|
||||
return node.outputs["Geometry"]
|
||||
|
||||
|
||||
def evaluate_field(group, value, data_type, domain):
|
||||
"""Evaluate a field on an explicit domain before downstream adaptation."""
|
||||
node = group.nodes.new("GeometryNodeFieldOnDomain")
|
||||
node.data_type, node.domain = data_type, domain
|
||||
group.links.new(value, node.inputs["Value"])
|
||||
return node.outputs["Value"]
|
||||
|
||||
|
||||
def capture_fields(group, geometry, domain, **fields):
|
||||
"""Keep source fields attached to geometry through later changes."""
|
||||
node = group.nodes.new("GeometryNodeCaptureAttribute")
|
||||
node.domain = domain
|
||||
node.capture_items.clear()
|
||||
group.links.new(geometry, node.inputs["Geometry"])
|
||||
for name, (data_type, value) in fields.items():
|
||||
node.capture_items.new(data_type, name)
|
||||
group.links.new(value, node.inputs[name])
|
||||
return node.outputs["Geometry"], {name: node.outputs[name] for name in fields}
|
||||
|
||||
Reference in New Issue
Block a user