Added sanity check baseline made by claude.
Also changed the location to a panel in VIEW_3D instead of menu.
This commit is contained in:
1 parent
71b1a61b5c
commit
4617c47ad0
33 files changed
+2771
-52
No files matched your search
@@ -0,0 +1,32 @@
|
||||
"""Fast mesh data access with numpy."""
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
def polygon_arrays(mesh):
|
||||
"""Return (loop_start, loop_total, loop_vertex_index) as int arrays."""
|
||||
n_polys = len(mesh.polygons)
|
||||
starts = np.empty(n_polys, dtype=np.int32)
|
||||
totals = np.empty(n_polys, dtype=np.int32)
|
||||
mesh.polygons.foreach_get("loop_start", starts)
|
||||
mesh.polygons.foreach_get("loop_total", totals)
|
||||
loop_verts = np.empty(len(mesh.loops), dtype=np.int32)
|
||||
mesh.loops.foreach_get("vertex_index", loop_verts)
|
||||
return starts, totals, loop_verts
|
||||
|
||||
|
||||
def loop_polygon_index(totals):
|
||||
"""Polygon index of every loop."""
|
||||
return np.repeat(np.arange(len(totals), dtype=np.int32), totals)
|
||||
|
||||
|
||||
def vertex_coords(mesh):
|
||||
co = np.empty(len(mesh.vertices) * 3, dtype=np.float64)
|
||||
mesh.vertices.foreach_get("co", co)
|
||||
return co.reshape(-1, 3)
|
||||
|
||||
|
||||
def polygon_normals(mesh):
|
||||
normals = np.empty(len(mesh.polygons) * 3, dtype=np.float64)
|
||||
mesh.polygon_normals.foreach_get("vector", normals)
|
||||
return normals.reshape(-1, 3)
|
||||
Reference in new issue
Block a user