Пример #1
0
 def to_mesh(self, verts, faces, falloff):
     bvh = bvhtree.BVHTree.FromPolygons(verts, faces)
     sfield = SvBvhAttractorScalarField(bvh=bvh,
                                        falloff=falloff,
                                        signed=self.signed)
     vfield = SvBvhAttractorVectorField(bvh=bvh, falloff=falloff)
     return vfield, sfield
Пример #2
0
    def process(self):
        if not any(socket.is_linked for socket in self.outputs):
            return

        vertices_s = self.inputs['Vertices'].sv_get()
        faces_s = self.inputs['Faces'].sv_get()

        fields_out = []
        for vertices, faces in zip_long_repeat(vertices_s, faces_s):
            if self.interpolate and scipy is None:
                self.info("Normal interpolation mode was enabled earlier, but scipy is not available currently. Will not apply interpolation.")
            if self.interpolate and scipy is not None:
                bvh = bvhtree.BVHTree.FromPolygons(vertices, faces)

                bm = bmesh_from_pydata(vertices, [], faces, normal_update=True)
                normals = np.array([f.normal for f in bm.faces])
                centers = np.array([f.calc_center_median() for f in bm.faces])
                bm.free()

                xs_from = centers[:,0]
                ys_from = centers[:,1]
                zs_from = centers[:,2]

                rbf = Rbf(xs_from, ys_from, zs_from, normals,
                        function = self.function,
                        mode = 'N-D')

                field = SvBvhRbfNormalVectorField(bvh, rbf)
            else:
                field = SvBvhAttractorVectorField(verts=vertices, faces=faces, use_normal=True, signed_normal=self.signed)
            fields_out.append(field)
        self.outputs['Field'].sv_set(fields_out)