Changeset View
Changeset View
Standalone View
Standalone View
modules/snap_context/mesh_drawing.py
| Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| def get_bmesh_vert_co_array(bm): | def get_bmesh_vert_co_array(bm): | ||||
| tot_vco = len(bm.verts) | tot_vco = len(bm.verts) | ||||
| if tot_vco: | if tot_vco: | ||||
| return np.array([v.co for v in bm.verts], 'f4') | return np.array([v.co for v in bm.verts], 'f4') | ||||
| return None | return None | ||||
| def get_mesh_tri_verts_array(me): | def get_mesh_tri_verts_array(me): | ||||
| me.calc_tessface() | me.calc_loop_triangles() | ||||
| len_tessfaces = len(me.tessfaces) | tris = [tri.vertices[:] for tri in me.loop_triangles] | ||||
| if len_tessfaces: | if tris: | ||||
| tessfaces = np.empty(len_tessfaces * 4, 'i4') | return np.array(tris, 'i4') | ||||
| me.tessfaces.foreach_get("vertices_raw", tessfaces) | |||||
| tessfaces.shape = (-1, 4) | |||||
| quad_indices = tessfaces[:, 3].nonzero()[0] | |||||
| tris = np.empty(((len_tessfaces + len(quad_indices)), 3), 'i4') | |||||
| tris[:len_tessfaces] = tessfaces[:, :3] | |||||
| tris[len_tessfaces:] = tessfaces[quad_indices][:, (0, 2, 3)] | |||||
| del tessfaces | |||||
| return tris | |||||
| return None | return None | ||||
| def get_bmesh_tri_verts_array(bm): | def get_bmesh_tri_verts_array(bm): | ||||
| ltris = bm.calc_tessface() | ltris = bm.calc_loop_triangles() | ||||
| tris = [[ltri[0].vert.index, ltri[1].vert.index, ltri[2].vert.index] for ltri in ltris if not ltri[0].face.hide] | tris = [[ltri[0].vert.index, ltri[1].vert.index, ltri[2].vert.index] for ltri in ltris if not ltri[0].face.hide] | ||||
| if tris: | if tris: | ||||
| return np.array(tris, 'i4') | return np.array(tris, 'i4') | ||||
| return None | return None | ||||
| def get_mesh_edge_verts_array(me): | def get_mesh_edge_verts_array(me): | ||||
| tot_edges = len(me.edges) | tot_edges = len(me.edges) | ||||
| ▲ Show 20 Lines • Show All 436 Lines • Show Last 20 Lines | |||||