Spaces:
Sleeping
Sleeping
Stephen
commited on
Commit
·
4b51b31
1
Parent(s):
c2162c6
try use mesh2sdf instead
Browse files- requirements.txt +1 -1
- sdf_export.py +4 -11
requirements.txt
CHANGED
@@ -2,4 +2,4 @@ gradio>=4.0.0
|
|
2 |
trimesh>=4.0.0
|
3 |
numpy>=1.24.0
|
4 |
rtree>=1.0.1
|
5 |
-
|
|
|
2 |
trimesh>=4.0.0
|
3 |
numpy>=1.24.0
|
4 |
rtree>=1.0.1
|
5 |
+
mesh2sdf>=1.1.0
|
sdf_export.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import trimesh
|
2 |
import numpy as np
|
3 |
-
import
|
4 |
|
5 |
|
6 |
def mesh_to_sdf_glsl(path, resolution=64):
|
@@ -23,16 +23,9 @@ def mesh_to_sdf_glsl(path, resolution=64):
|
|
23 |
# Flatten the grid and reshape to (n,3)
|
24 |
query_points = np.column_stack((X.ravel(), Y.ravel(), Z.ravel()))
|
25 |
|
26 |
-
# Calculate signed distances using
|
27 |
-
distances =
|
28 |
-
mesh,
|
29 |
-
query_points,
|
30 |
-
surface_point_method="voxel", # Use voxel method instead of scan
|
31 |
-
sign_method="normal",
|
32 |
-
scan_count=100,
|
33 |
-
scan_resolution=400,
|
34 |
-
sample_point_count=10000000,
|
35 |
-
normal_sample_count=11,
|
36 |
)
|
37 |
|
38 |
# Normalize distances to [-1, 1]
|
|
|
1 |
import trimesh
|
2 |
import numpy as np
|
3 |
+
import mesh2sdf
|
4 |
|
5 |
|
6 |
def mesh_to_sdf_glsl(path, resolution=64):
|
|
|
23 |
# Flatten the grid and reshape to (n,3)
|
24 |
query_points = np.column_stack((X.ravel(), Y.ravel(), Z.ravel()))
|
25 |
|
26 |
+
# Calculate signed distances using mesh2sdf
|
27 |
+
distances = mesh2sdf.compute(
|
28 |
+
mesh.vertices, mesh.faces, query_points, return_gradients=False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
)
|
30 |
|
31 |
# Normalize distances to [-1, 1]
|