Skip to content

Commit

Permalink
"Bezier in" node: output curve tilt & radius parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
portnov committed Nov 14, 2024
1 parent b5eeabf commit 5a9fd6f
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions nodes/exchange/bezier_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def sv_init(self, context):
self.outputs.new('SvCurveSocket', 'Curves')
self.outputs.new('SvVerticesSocket', 'ControlPoints')
self.outputs.new('SvMatrixSocket', 'Matrices')
self.outputs.new('SvStringsSocket', 'Tilt')
self.outputs.new('SvStringsSocket', 'Radius')

def get_objects_from_scene(self, ops):
"""
Expand Down Expand Up @@ -137,7 +139,6 @@ def get_curve(self, spline, matrix):
if spline.use_cyclic_u:
pairs = list(pairs) + [(spline.bezier_points[-1], spline.bezier_points[0])]
points = []
is_first = True
for p1, p2 in pairs:
c0 = p1.co
c1 = p1.handle_right
Expand All @@ -150,10 +151,18 @@ def get_curve(self, spline, matrix):
points.append([c0, c1, c2, c3])
segment = SvCubicBezierCurve(c0, c1, c2, c3)
segments.append(segment)

tilt_values = []
radius_values = []
if self.concat_segments:
return points, concatenate_curves(segments)
tilt_values = [p.tilt for p in spline.bezier_points]
radius_values = [p.radius for p in spline.bezier_points]
return points, tilt_values, radius_values, concatenate_curves(segments)
else:
return points, segments
for p1, p2 in pairs:
tilt_values.append([p1.tilt, p2.tilt])
radius_values.append([p1.radius, p2.radius])
return points, tilt_values, radius_values, segments

def process(self):

Expand All @@ -163,6 +172,8 @@ def process(self):
curves_out = []
matrices_out = []
controls_out = []
tilt_out = []
radius_out = []
for item in self.object_names:
object_name = item.name
obj = bpy.data.objects.get(object_name)
Expand All @@ -177,14 +188,20 @@ def process(self):
if spline.type != 'BEZIER':
self.warning("%s: not supported spline type: %s", spline, spline.type)
continue
controls, curve = self.get_curve(spline, matrix)
controls, tilt_values, radius_values, curve = self.get_curve(spline, matrix)
curves_out.append(curve)
controls_out.append(controls)
matrices_out.append(matrix)
tilt_out.append(tilt_values)
radius_out.append(radius_values)

self.outputs['Curves'].sv_set(curves_out)
self.outputs['ControlPoints'].sv_set(controls_out)
self.outputs['Matrices'].sv_set(matrices_out)
if 'Tilt' in self.outputs:
self.outputs['Tilt'].sv_set(tilt_out)
if 'Radius' in self.outputs:
self.outputs['Radius'].sv_set(radius_out)


def register():
Expand Down

0 comments on commit 5a9fd6f

Please sign in to comment.