Skip to content

Commit 7ae967b

Browse files
committed
Refactor BezierSplinePipe: Simplify interpolation for positions and radii, and reduce curve and bevel resolution for performance optimization.
1 parent 9ee3c02 commit 7ae967b

1 file changed

Lines changed: 9 additions & 19 deletions

File tree

src/bsr/geometry/primitives/pipe.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,12 @@ def _downsample_data(
224224
# TODO: should we just raise error, or interpolate the positions and radii?
225225
return positions, radii
226226

227-
positions = np.interp(
228-
np.linspace(0, 1, num_elements),
229-
np.linspace(0, 1, positions.shape[1]),
230-
positions,
231-
axis=1,
232-
)
233-
radii = np.interp(
234-
np.linspace(0, 1, num_elements),
235-
np.linspace(0, 1, radii.shape[0]),
236-
radii,
237-
axis=0,
238-
)
227+
t = np.linspace(0, 1, num_elements)
228+
t_old = np.linspace(0, 1, positions.shape[1])
229+
positions[0, :] = np.interp(t, t_old, positions[0, :])
230+
positions[1, :] = np.interp(t, t_old, positions[1, :])
231+
positions[2, :] = np.interp(t, t_old, positions[2, :])
232+
radii = np.interp(t, t_old, radii)
239233

240234
return positions, radii
241235

@@ -269,10 +263,8 @@ def _create_bezier_spline(
269263

270264
# Create a new object with the curve data
271265
curve_object = bpy.data.objects.new("spline_curve_object", curve_data)
272-
curve_object.data.resolution_u = 12 # Increased for smoother curves
273-
curve_object.data.render_resolution_u = (
274-
12 # Consistent resolution for rendering
275-
)
266+
curve_object.data.resolution_u = 1
267+
curve_object.data.render_resolution_u = 1
276268
bpy.context.collection.objects.link(curve_object)
277269

278270
# Create a bevel object for the pipe profile
@@ -286,9 +278,7 @@ def _create_bezier_spline(
286278
bevel_circle = bpy.context.object
287279
bevel_circle.name = "bevel_circle"
288280
# Set resolution for smoother bevel profile
289-
bevel_circle.data.resolution_u = (
290-
8 # Higher resolution for smoother circles
291-
)
281+
bevel_circle.data.resolution_u = 1
292282
# Hide the bevel circle object in the viewport and render
293283
bevel_circle.hide_viewport = True
294284
bevel_circle.hide_render = True

0 commit comments

Comments
 (0)