def process_data(self, params): out_verts = [] out_edges = [] out_faces = [] for subdivisions, radius in zip(*params): if subdivisions == 0: # In this case we just return the icosahedron verts, edges, faces = icosahedron(radius) out_verts.append(verts) out_edges.append(edges) out_faces.append(faces) continue if subdivisions > self.subdivisions_max: subdivisions = self.subdivisions_max bm = bmesh.new() bmesh.ops.create_icosphere( bm, **{ size_param: radius, "subdivisions": subdivisions }) verts, edges, faces, _ = numpy_data_from_bmesh(bm, self.out_np) bm.free() out_verts.append(verts) out_edges.append(edges) out_faces.append(faces) return out_verts, out_edges, out_faces
def process(self): inputs, outputs = self.inputs, self.outputs if self.dont_process(): return result_vertices, result_edges, result_faces, result_face_data = [], [], [], [] r_inner_vertices, r_inner_edges, r_inner_faces = [], [], [] r_split_vertices, r_split_edges, r_split_faces = [], [], [] use_mask = inputs['EdgeMask'].is_linked show_new = self.show_new and any(s.is_linked for s in outputs[4:7]) show_old = self.show_old and any(s.is_linked for s in outputs[7:]) use_face_data = inputs['FaceData'].is_linked and outputs['FaceData'].is_linked output_numpy = any(self.out_np) meshes = self.get_data() for vertices, edges, faces, face_data, masks, cuts, smooth, fractal, along_normal, seed in zip(*meshes): if cuts < 1: result_vertices.append(vertices) result_edges.append(edges) result_faces.append(faces) result_face_data.append(face_data) r_inner_vertices.append(vertices) r_inner_edges.append(edges) r_inner_faces.append(faces) r_split_vertices.append(vertices) r_split_edges.append(edges) r_split_faces.append(faces) continue if use_face_data and len(face_data) > 0: if isinstance(face_data, ndarray): face_data_matched = numpy_full_list(face_data, len(faces)).tolist() else: face_data_matched = repeat_last_for_length(face_data, len(faces)) else: face_data_matched =[] bm = bmesh_from_pydata( vertices, edges, faces, markup_face_data=use_face_data, markup_edge_data=use_mask, normal_update=True) selected_edges = get_selected_edges(use_mask, masks, bm.edges) geom = subdivide_edges( bm, edges=selected_edges, smooth=smooth, smooth_falloff=self.falloff_type, fractal=fractal, along_normal=along_normal, cuts=cuts, seed=seed, quad_corner_type=self.corner_type, use_grid_fill=self.grid_fill, use_single_edge=self.single_edge, use_only_quads=self.only_quads, use_smooth_even=self.smooth_even) if output_numpy: new_verts, new_edges, new_faces, new_face_data = numpy_data_from_bmesh(bm, self.out_np, face_data_matched) else: if use_face_data and len(face_data) > 0: new_verts, new_edges, new_faces, new_face_data = pydata_from_bmesh(bm, face_data_matched) else: new_verts, new_edges, new_faces = pydata_from_bmesh(bm) new_face_data = [] result_vertices.append(new_verts) result_edges.append(new_edges) result_faces.append(new_faces) result_face_data.append(new_face_data) if show_new: inner_verts, inner_edges, inner_faces = get_partial_result_pydata(geom['geom_inner']) r_inner_vertices.append(inner_verts) r_inner_edges.append(inner_edges) r_inner_faces.append(inner_faces) if show_old: split_verts, split_edges, split_faces = get_partial_result_pydata(geom['geom_split']) r_split_vertices.append(split_verts) r_split_edges.append(split_edges) r_split_faces.append(split_faces) bm.free() outputs['Vertices'].sv_set(result_vertices) outputs['Edges'].sv_set(result_edges) outputs['Faces'].sv_set(result_faces) outputs['FaceData'].sv_set(result_face_data) outputs['NewVertices'].sv_set(r_inner_vertices) outputs['NewEdges'].sv_set(r_inner_edges) outputs['NewFaces'].sv_set(r_inner_faces) outputs['OldVertices'].sv_set(r_split_vertices) outputs['OldEdges'].sv_set(r_split_edges) outputs['OldFaces'].sv_set(r_split_faces)