Не подтверждена Коммит 2683c0d9 создал по автору Victor Doval's avatar Victor Doval Зафиксировано автором GitHub
Просмотр файлов

blend along surface 2D prop (#4105)

владелец 66e39d61
......@@ -39,6 +39,8 @@ This node has the following parameters:
* **Auto scale**. If checked, scale the source space along the vertical axis,
trying to match the scale coefficient for two other axes. Otherwise, the
space will not be scaled along the vertical axis. Unchecked by default.
* **As 2D**. If checked, it will discard the vertical axis. Enable to bend flat objects.
Improves performance.
* **Flip surface**. This parameter is only available in the node's N panel. If
checked, then the surface will be considered as flipped (turned upside down),
so the vector field will also turn the space upside down. Unchecked by
......@@ -57,4 +59,3 @@ Example of usage
Generate a rectangular grid of cubes, and bend it along formula-specified surface:
.. image:: https://user-images.githubusercontent.com/284644/79602628-42df3c80-8104-11ea-80c3-09be659d54f8.png
......@@ -45,6 +45,10 @@ class SvBendAlongSurfaceFieldNode(bpy.types.Node, SverchCustomTreeNode):
name="Auto scale", description="Scale object along orientation axis automatically",
default=False, update=updateNode)
only_2D: BoolProperty(
name="As 2D", description="It will discard the vertical axis. Enable to bend flat objects (improves performance)",
default=False, update=updateNode)
flip: BoolProperty(
name="Flip surface",
description="Flip the surface orientation",
......@@ -82,11 +86,14 @@ class SvBendAlongSurfaceFieldNode(bpy.types.Node, SverchCustomTreeNode):
layout.label(text="Object vertical axis:")
layout.prop(self, "orient_axis_", expand=True)
layout.prop(self, "autoscale", toggle=True)
layout.prop(self, 'only_2D')
def draw_buttons_ext(self, context, layout):
self.draw_buttons(context, layout)
layout.prop(self, 'flip')
def process(self):
if not any(socket.is_linked for socket in self.outputs):
return
......@@ -109,7 +116,7 @@ class SvBendAlongSurfaceFieldNode(bpy.types.Node, SverchCustomTreeNode):
v_max = v_max[0]
field = SvBendAlongSurfaceField(surface, self.orient_axis,
self.autoscale, self.flip)
self.autoscale, self.flip, self.only_2D)
field.u_bounds = (u_min, u_max)
field.v_bounds = (v_min, v_max)
fields_out.append(field)
......@@ -121,4 +128,3 @@ def register():
def unregister():
bpy.utils.unregister_class(SvBendAlongSurfaceFieldNode)
......@@ -969,13 +969,14 @@ class SvBendAlongCurveField(SvVectorField):
return R[0], R[1], R[2]
class SvBendAlongSurfaceField(SvVectorField):
def __init__(self, surface, axis, autoscale=False, flip=False):
def __init__(self, surface, axis, autoscale=False, flip=False, only_2D=False):
self.surface = surface
self.orient_axis = axis
self.autoscale = autoscale
self.flip = flip
self.u_bounds = (0, 1)
self.v_bounds = (0, 1)
self.only_2D = only_2D
self.__description__ = "Bend along {}".format(surface)
def get_other_axes(self):
......@@ -1028,6 +1029,9 @@ class SvBendAlongSurfaceField(SvVectorField):
if self.flip:
scale_z = - scale_z
if self.only_2D:
return self.surface.evaluate_array(us, vs)
surf_vertices = self.surface.evaluate_array(us, vs)
spline_normals = self.surface.normal_array(us, vs)
zs = vertices[:,self.orient_axis].flatten()
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать