warp-lang 1.8.0__py3-none-macosx_10_13_universal2.whl → 1.9.0__py3-none-macosx_10_13_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of warp-lang might be problematic. Click here for more details.
- warp/__init__.py +282 -103
- warp/__init__.pyi +482 -110
- warp/bin/libwarp-clang.dylib +0 -0
- warp/bin/libwarp.dylib +0 -0
- warp/build.py +93 -30
- warp/build_dll.py +48 -63
- warp/builtins.py +955 -137
- warp/codegen.py +327 -209
- warp/config.py +1 -1
- warp/context.py +1363 -800
- warp/examples/core/example_marching_cubes.py +1 -0
- warp/examples/core/example_render_opengl.py +100 -3
- warp/examples/fem/example_apic_fluid.py +98 -52
- warp/examples/fem/example_convection_diffusion_dg.py +25 -4
- warp/examples/fem/example_diffusion_mgpu.py +8 -3
- warp/examples/fem/utils.py +68 -22
- warp/examples/interop/example_jax_callable.py +34 -4
- warp/examples/interop/example_jax_kernel.py +27 -1
- warp/fabric.py +1 -1
- warp/fem/cache.py +27 -19
- warp/fem/domain.py +2 -2
- warp/fem/field/nodal_field.py +2 -2
- warp/fem/field/virtual.py +266 -166
- warp/fem/geometry/geometry.py +5 -5
- warp/fem/integrate.py +200 -91
- warp/fem/space/restriction.py +4 -0
- warp/fem/space/shape/tet_shape_function.py +3 -10
- warp/jax_experimental/custom_call.py +1 -1
- warp/jax_experimental/ffi.py +203 -54
- warp/marching_cubes.py +708 -0
- warp/native/array.h +103 -8
- warp/native/builtin.h +90 -9
- warp/native/bvh.cpp +64 -28
- warp/native/bvh.cu +58 -58
- warp/native/bvh.h +2 -2
- warp/native/clang/clang.cpp +7 -7
- warp/native/coloring.cpp +13 -3
- warp/native/crt.cpp +2 -2
- warp/native/crt.h +3 -5
- warp/native/cuda_util.cpp +42 -11
- warp/native/cuda_util.h +10 -4
- warp/native/exports.h +1842 -1908
- warp/native/fabric.h +2 -1
- warp/native/hashgrid.cpp +37 -37
- warp/native/hashgrid.cu +2 -2
- warp/native/initializer_array.h +1 -1
- warp/native/intersect.h +4 -4
- warp/native/mat.h +1913 -119
- warp/native/mathdx.cpp +43 -43
- warp/native/mesh.cpp +24 -24
- warp/native/mesh.cu +26 -26
- warp/native/mesh.h +5 -3
- warp/native/nanovdb/GridHandle.h +179 -12
- warp/native/nanovdb/HostBuffer.h +8 -7
- warp/native/nanovdb/NanoVDB.h +517 -895
- warp/native/nanovdb/NodeManager.h +323 -0
- warp/native/nanovdb/PNanoVDB.h +2 -2
- warp/native/quat.h +337 -16
- warp/native/rand.h +7 -7
- warp/native/range.h +7 -1
- warp/native/reduce.cpp +10 -10
- warp/native/reduce.cu +13 -14
- warp/native/runlength_encode.cpp +2 -2
- warp/native/runlength_encode.cu +5 -5
- warp/native/scan.cpp +3 -3
- warp/native/scan.cu +4 -4
- warp/native/sort.cpp +10 -10
- warp/native/sort.cu +22 -22
- warp/native/sparse.cpp +8 -8
- warp/native/sparse.cu +14 -14
- warp/native/spatial.h +366 -17
- warp/native/svd.h +23 -8
- warp/native/temp_buffer.h +2 -2
- warp/native/tile.h +303 -70
- warp/native/tile_radix_sort.h +5 -1
- warp/native/tile_reduce.h +16 -25
- warp/native/tuple.h +2 -2
- warp/native/vec.h +385 -18
- warp/native/volume.cpp +54 -54
- warp/native/volume.cu +1 -1
- warp/native/volume.h +2 -1
- warp/native/volume_builder.cu +30 -37
- warp/native/warp.cpp +150 -149
- warp/native/warp.cu +337 -193
- warp/native/warp.h +227 -226
- warp/optim/linear.py +736 -271
- warp/render/imgui_manager.py +289 -0
- warp/render/render_opengl.py +137 -57
- warp/render/render_usd.py +0 -1
- warp/sim/collide.py +1 -2
- warp/sim/graph_coloring.py +2 -2
- warp/sim/integrator_vbd.py +10 -2
- warp/sparse.py +559 -176
- warp/tape.py +2 -0
- warp/tests/aux_test_module_aot.py +7 -0
- warp/tests/cuda/test_async.py +3 -3
- warp/tests/cuda/test_conditional_captures.py +101 -0
- warp/tests/geometry/test_marching_cubes.py +233 -12
- warp/tests/sim/test_cloth.py +89 -6
- warp/tests/sim/test_coloring.py +82 -7
- warp/tests/test_array.py +56 -5
- warp/tests/test_assert.py +53 -0
- warp/tests/test_atomic_cas.py +127 -114
- warp/tests/test_codegen.py +3 -2
- warp/tests/test_context.py +8 -15
- warp/tests/test_enum.py +136 -0
- warp/tests/test_examples.py +2 -2
- warp/tests/test_fem.py +45 -2
- warp/tests/test_fixedarray.py +229 -0
- warp/tests/test_func.py +18 -15
- warp/tests/test_future_annotations.py +7 -5
- warp/tests/test_linear_solvers.py +30 -0
- warp/tests/test_map.py +1 -1
- warp/tests/test_mat.py +1540 -378
- warp/tests/test_mat_assign_copy.py +178 -0
- warp/tests/test_mat_constructors.py +574 -0
- warp/tests/test_module_aot.py +287 -0
- warp/tests/test_print.py +69 -0
- warp/tests/test_quat.py +162 -34
- warp/tests/test_quat_assign_copy.py +145 -0
- warp/tests/test_reload.py +2 -1
- warp/tests/test_sparse.py +103 -0
- warp/tests/test_spatial.py +140 -34
- warp/tests/test_spatial_assign_copy.py +160 -0
- warp/tests/test_static.py +48 -0
- warp/tests/test_struct.py +43 -3
- warp/tests/test_tape.py +38 -0
- warp/tests/test_types.py +0 -20
- warp/tests/test_vec.py +216 -441
- warp/tests/test_vec_assign_copy.py +143 -0
- warp/tests/test_vec_constructors.py +325 -0
- warp/tests/tile/test_tile.py +206 -152
- warp/tests/tile/test_tile_cholesky.py +605 -0
- warp/tests/tile/test_tile_load.py +169 -0
- warp/tests/tile/test_tile_mathdx.py +2 -558
- warp/tests/tile/test_tile_matmul.py +179 -0
- warp/tests/tile/test_tile_mlp.py +1 -1
- warp/tests/tile/test_tile_reduce.py +100 -11
- warp/tests/tile/test_tile_shared_memory.py +16 -16
- warp/tests/tile/test_tile_sort.py +59 -55
- warp/tests/unittest_suites.py +16 -0
- warp/tests/walkthrough_debug.py +1 -1
- warp/thirdparty/unittest_parallel.py +108 -9
- warp/types.py +554 -264
- warp/utils.py +68 -86
- {warp_lang-1.8.0.dist-info → warp_lang-1.9.0.dist-info}/METADATA +28 -65
- {warp_lang-1.8.0.dist-info → warp_lang-1.9.0.dist-info}/RECORD +150 -138
- warp/native/marching.cpp +0 -19
- warp/native/marching.cu +0 -514
- warp/native/marching.h +0 -19
- {warp_lang-1.8.0.dist-info → warp_lang-1.9.0.dist-info}/WHEEL +0 -0
- {warp_lang-1.8.0.dist-info → warp_lang-1.9.0.dist-info}/licenses/LICENSE.md +0 -0
- {warp_lang-1.8.0.dist-info → warp_lang-1.9.0.dist-info}/top_level.txt +0 -0
warp/native/mathdx.cpp
CHANGED
|
@@ -24,48 +24,24 @@ extern "C"
|
|
|
24
24
|
{
|
|
25
25
|
|
|
26
26
|
WP_API
|
|
27
|
-
bool
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
bool wp_cuda_compile_fft(
|
|
28
|
+
const char* ltoir_output_path,
|
|
29
|
+
const char* symbol_name,
|
|
30
|
+
int num_include_dirs,
|
|
31
|
+
const char** include_dirs,
|
|
32
|
+
const char* mathdx_include_dir,
|
|
33
|
+
int arch,
|
|
34
|
+
int size,
|
|
35
|
+
int elements_per_thread,
|
|
36
|
+
int direction,
|
|
37
|
+
int precision,
|
|
38
|
+
int* shared_memory_size)
|
|
39
39
|
{
|
|
40
40
|
printf("CUDA is disabled and/or Warp was not compiled with MathDx support.\n");
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
WP_API bool
|
|
45
|
-
const char* ltoir_output_path,
|
|
46
|
-
const char* symbol_name,
|
|
47
|
-
int num_include_dirs,
|
|
48
|
-
const char** include_dirs,
|
|
49
|
-
const char* mathdx_include_dir,
|
|
50
|
-
int arch,
|
|
51
|
-
int M,
|
|
52
|
-
int N,
|
|
53
|
-
int K,
|
|
54
|
-
int precision_A,
|
|
55
|
-
int precision_B,
|
|
56
|
-
int precision_C,
|
|
57
|
-
int type,
|
|
58
|
-
int arrangement_A,
|
|
59
|
-
int arrangement_B,
|
|
60
|
-
int arrangement_C,
|
|
61
|
-
int num_threads)
|
|
62
|
-
{
|
|
63
|
-
printf("CUDA is disabled and/or Warp was not compiled with MathDx support.\n");
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
WP_API bool cuda_compile_solver(
|
|
68
|
-
const char* fatbin_output_path,
|
|
44
|
+
WP_API bool wp_cuda_compile_dot(
|
|
69
45
|
const char* ltoir_output_path,
|
|
70
46
|
const char* symbol_name,
|
|
71
47
|
int num_include_dirs,
|
|
@@ -74,20 +50,44 @@ WP_API bool cuda_compile_solver(
|
|
|
74
50
|
int arch,
|
|
75
51
|
int M,
|
|
76
52
|
int N,
|
|
77
|
-
int
|
|
78
|
-
int
|
|
79
|
-
int
|
|
80
|
-
int
|
|
81
|
-
int
|
|
53
|
+
int K,
|
|
54
|
+
int precision_A,
|
|
55
|
+
int precision_B,
|
|
56
|
+
int precision_C,
|
|
57
|
+
int type,
|
|
82
58
|
int arrangement_A,
|
|
83
59
|
int arrangement_B,
|
|
84
|
-
int
|
|
60
|
+
int arrangement_C,
|
|
85
61
|
int num_threads)
|
|
86
62
|
{
|
|
87
63
|
printf("CUDA is disabled and/or Warp was not compiled with MathDx support.\n");
|
|
88
64
|
return false;
|
|
89
65
|
}
|
|
90
66
|
|
|
67
|
+
WP_API bool wp_cuda_compile_solver(
|
|
68
|
+
const char* fatbin_output_path,
|
|
69
|
+
const char* ltoir_output_path,
|
|
70
|
+
const char* symbol_name,
|
|
71
|
+
int num_include_dirs,
|
|
72
|
+
const char** include_dirs,
|
|
73
|
+
const char* mathdx_include_dir,
|
|
74
|
+
int arch,
|
|
75
|
+
int M,
|
|
76
|
+
int N,
|
|
77
|
+
int NRHS,
|
|
78
|
+
int function,
|
|
79
|
+
int side,
|
|
80
|
+
int diag,
|
|
81
|
+
int precision,
|
|
82
|
+
int arrangement_A,
|
|
83
|
+
int arrangement_B,
|
|
84
|
+
int fill_mode,
|
|
85
|
+
int num_threads)
|
|
86
|
+
{
|
|
87
|
+
printf("CUDA is disabled and/or Warp was not compiled with MathDx support.\n");
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
91
|
} // extern "C"
|
|
92
92
|
|
|
93
93
|
#endif // !WP_ENABLE_CUDA || !WP_ENABLE_MATHDX
|
warp/native/mesh.cpp
CHANGED
|
@@ -96,8 +96,8 @@ void bvh_refit_with_solid_angle_recursive_host(BVH& bvh, int index, Mesh& mesh)
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
(
|
|
100
|
-
(
|
|
99
|
+
reinterpret_cast<vec3&>(lower) = mesh.solid_angle_props[index].box.lower;
|
|
100
|
+
reinterpret_cast<vec3&>(upper) = mesh.solid_angle_props[index].box.upper;
|
|
101
101
|
}
|
|
102
102
|
else
|
|
103
103
|
{
|
|
@@ -114,19 +114,19 @@ void bvh_refit_with_solid_angle_recursive_host(BVH& bvh, int index, Mesh& mesh)
|
|
|
114
114
|
combine_precomputed_solid_angle_props(mesh.solid_angle_props[index], left_child_data, right_child_data);
|
|
115
115
|
|
|
116
116
|
// compute union of children
|
|
117
|
-
const vec3& left_lower = (
|
|
118
|
-
const vec3& left_upper = (
|
|
117
|
+
const vec3& left_lower = reinterpret_cast<const vec3&>(bvh.node_lowers[left_index]);
|
|
118
|
+
const vec3& left_upper = reinterpret_cast<const vec3&>(bvh.node_uppers[left_index]);
|
|
119
119
|
|
|
120
|
-
const vec3& right_lower = (
|
|
121
|
-
const vec3& right_upper = (
|
|
120
|
+
const vec3& right_lower = reinterpret_cast<const vec3&>(bvh.node_lowers[right_index]);
|
|
121
|
+
const vec3& right_upper = reinterpret_cast<const vec3&>(bvh.node_uppers[right_index]);
|
|
122
122
|
|
|
123
123
|
// union of child bounds
|
|
124
124
|
vec3 new_lower = min(left_lower, right_lower);
|
|
125
125
|
vec3 new_upper = max(left_upper, right_upper);
|
|
126
126
|
|
|
127
127
|
// write new BVH nodes
|
|
128
|
-
(
|
|
129
|
-
(
|
|
128
|
+
reinterpret_cast<vec3&>(lower) = new_lower;
|
|
129
|
+
reinterpret_cast<vec3&>(upper) = new_upper;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -135,7 +135,7 @@ void bvh_refit_with_solid_angle_host(BVH& bvh, Mesh& mesh)
|
|
|
135
135
|
bvh_refit_with_solid_angle_recursive_host(bvh, 0, mesh);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
uint64_t
|
|
138
|
+
uint64_t wp_mesh_create_host(array_t<wp::vec3> points, array_t<wp::vec3> velocities, array_t<int> indices, int num_points, int num_tris, int support_winding_number, int constructor_type)
|
|
139
139
|
{
|
|
140
140
|
Mesh* m = new Mesh(points, velocities, indices, num_points, num_tris);
|
|
141
141
|
|
|
@@ -177,7 +177,7 @@ uint64_t mesh_create_host(array_t<wp::vec3> points, array_t<wp::vec3> velocities
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
|
|
180
|
-
void
|
|
180
|
+
void wp_mesh_destroy_host(uint64_t id)
|
|
181
181
|
{
|
|
182
182
|
Mesh* m = (Mesh*)(id);
|
|
183
183
|
|
|
@@ -187,12 +187,12 @@ void mesh_destroy_host(uint64_t id)
|
|
|
187
187
|
if (m->solid_angle_props) {
|
|
188
188
|
delete [] m->solid_angle_props;
|
|
189
189
|
}
|
|
190
|
-
bvh_destroy_host(m->bvh);
|
|
190
|
+
wp::bvh_destroy_host(m->bvh);
|
|
191
191
|
|
|
192
192
|
delete m;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
void
|
|
195
|
+
void wp_mesh_refit_host(uint64_t id)
|
|
196
196
|
{
|
|
197
197
|
Mesh* m = (Mesh*)(id);
|
|
198
198
|
|
|
@@ -223,30 +223,30 @@ void mesh_refit_host(uint64_t id)
|
|
|
223
223
|
}
|
|
224
224
|
else
|
|
225
225
|
{
|
|
226
|
-
bvh_refit_host(m->bvh);
|
|
226
|
+
wp::bvh_refit_host(m->bvh);
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
void
|
|
230
|
+
void wp_mesh_set_points_host(uint64_t id, wp::array_t<wp::vec3> points)
|
|
231
231
|
{
|
|
232
232
|
Mesh* m = (Mesh*)(id);
|
|
233
233
|
if (points.ndim != 1 || points.shape[0] != m->points.shape[0])
|
|
234
234
|
{
|
|
235
|
-
fprintf(stderr, "The new points input for
|
|
235
|
+
fprintf(stderr, "The new points input for wp_mesh_set_points_host does not match the shape of the original points!\n");
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
m->points = points;
|
|
240
240
|
|
|
241
|
-
|
|
241
|
+
wp_mesh_refit_host(id);
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
void
|
|
244
|
+
void wp_mesh_set_velocities_host(uint64_t id, wp::array_t<wp::vec3> velocities)
|
|
245
245
|
{
|
|
246
246
|
Mesh* m = (Mesh*)(id);
|
|
247
247
|
if (velocities.ndim != 1 || velocities.shape[0] != m->velocities.shape[0])
|
|
248
248
|
{
|
|
249
|
-
fprintf(stderr, "The new velocities input for
|
|
249
|
+
fprintf(stderr, "The new velocities input for wp_mesh_set_velocities_host does not match the shape of the original velocities!\n");
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
m->velocities = velocities;
|
|
@@ -256,11 +256,11 @@ void mesh_set_velocities_host(uint64_t id, wp::array_t<wp::vec3> velocities)
|
|
|
256
256
|
#if !WP_ENABLE_CUDA
|
|
257
257
|
|
|
258
258
|
|
|
259
|
-
WP_API uint64_t
|
|
260
|
-
WP_API void
|
|
261
|
-
WP_API void
|
|
262
|
-
WP_API void
|
|
263
|
-
WP_API void
|
|
259
|
+
WP_API uint64_t wp_mesh_create_device(void* context, wp::array_t<wp::vec3> points, wp::array_t<wp::vec3> velocities, wp::array_t<int> tris, int num_points, int num_tris, int support_winding_number, int constructor_type) { return 0; }
|
|
260
|
+
WP_API void wp_mesh_destroy_device(uint64_t id) {}
|
|
261
|
+
WP_API void wp_mesh_refit_device(uint64_t id) {}
|
|
262
|
+
WP_API void wp_mesh_set_points_device(uint64_t id, wp::array_t<wp::vec3> points) {};
|
|
263
|
+
WP_API void wp_mesh_set_velocities_device(uint64_t id, wp::array_t<wp::vec3> points) {};
|
|
264
264
|
|
|
265
265
|
|
|
266
|
-
#endif // !WP_ENABLE_CUDA
|
|
266
|
+
#endif // !WP_ENABLE_CUDA
|
warp/native/mesh.cu
CHANGED
|
@@ -237,7 +237,7 @@ void bvh_refit_with_solid_angle_device(BVH& bvh, Mesh& mesh)
|
|
|
237
237
|
ContextGuard guard(bvh.context);
|
|
238
238
|
|
|
239
239
|
// clear child counters
|
|
240
|
-
|
|
240
|
+
wp_memset_device(WP_CURRENT_CONTEXT, bvh.node_counts, 0, sizeof(int) * bvh.max_nodes);
|
|
241
241
|
wp_launch_device(WP_CURRENT_CONTEXT, bvh_refit_with_solid_angle_kernel, bvh.num_leaf_nodes,
|
|
242
242
|
(bvh.num_leaf_nodes, bvh.node_parents, bvh.node_counts, bvh.node_lowers, bvh.node_uppers, mesh.points, mesh.indices, bvh.primitive_indices, mesh.solid_angle_props));
|
|
243
243
|
}
|
|
@@ -245,26 +245,26 @@ void bvh_refit_with_solid_angle_device(BVH& bvh, Mesh& mesh)
|
|
|
245
245
|
} // namespace wp
|
|
246
246
|
|
|
247
247
|
|
|
248
|
-
uint64_t
|
|
248
|
+
uint64_t wp_mesh_create_device(void* context, wp::array_t<wp::vec3> points, wp::array_t<wp::vec3> velocities, wp::array_t<int> indices, int num_points, int num_tris, int support_winding_number, int constructor_type)
|
|
249
249
|
{
|
|
250
250
|
ContextGuard guard(context);
|
|
251
251
|
|
|
252
252
|
wp::Mesh mesh(points, velocities, indices, num_points, num_tris);
|
|
253
253
|
|
|
254
|
-
mesh.context = context ? context :
|
|
254
|
+
mesh.context = context ? context : wp_cuda_context_get_current();
|
|
255
255
|
|
|
256
256
|
// create lower upper arrays expected by GPU BVH builder
|
|
257
|
-
mesh.lowers = (wp::vec3*)
|
|
258
|
-
mesh.uppers = (wp::vec3*)
|
|
257
|
+
mesh.lowers = (wp::vec3*)wp_alloc_device(WP_CURRENT_CONTEXT, sizeof(wp::vec3)*num_tris);
|
|
258
|
+
mesh.uppers = (wp::vec3*)wp_alloc_device(WP_CURRENT_CONTEXT, sizeof(wp::vec3)*num_tris);
|
|
259
259
|
|
|
260
260
|
if (support_winding_number)
|
|
261
261
|
{
|
|
262
262
|
int num_bvh_nodes = 2 * num_tris;
|
|
263
|
-
mesh.solid_angle_props = (wp::SolidAngleProps*)
|
|
263
|
+
mesh.solid_angle_props = (wp::SolidAngleProps*)wp_alloc_device(WP_CURRENT_CONTEXT, sizeof(wp::SolidAngleProps) * num_bvh_nodes);
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
wp::Mesh* mesh_device = (wp::Mesh*)
|
|
267
|
-
|
|
266
|
+
wp::Mesh* mesh_device = (wp::Mesh*)wp_alloc_device(WP_CURRENT_CONTEXT, sizeof(wp::Mesh));
|
|
267
|
+
wp_memcpy_h2d(WP_CURRENT_CONTEXT, mesh_device, &mesh, sizeof(wp::Mesh));
|
|
268
268
|
|
|
269
269
|
// save descriptor
|
|
270
270
|
uint64_t mesh_id = (uint64_t)mesh_device;
|
|
@@ -283,17 +283,17 @@ uint64_t mesh_create_device(void* context, wp::array_t<wp::vec3> points, wp::arr
|
|
|
283
283
|
wp::bvh_create_device(mesh.context, mesh.lowers, mesh.uppers, num_tris, constructor_type, mesh.bvh);
|
|
284
284
|
|
|
285
285
|
// we need to overwrite mesh.bvh because it is not initialized when we construct it on device
|
|
286
|
-
|
|
286
|
+
wp_memcpy_h2d(WP_CURRENT_CONTEXT, &(mesh_device->bvh), &mesh.bvh, sizeof(wp::BVH));
|
|
287
287
|
|
|
288
288
|
mesh_add_descriptor(mesh_id, mesh);
|
|
289
289
|
|
|
290
290
|
if (support_winding_number)
|
|
291
|
-
|
|
291
|
+
wp_mesh_refit_device(mesh_id);
|
|
292
292
|
|
|
293
293
|
return mesh_id;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
void
|
|
296
|
+
void wp_mesh_destroy_device(uint64_t id)
|
|
297
297
|
{
|
|
298
298
|
wp::Mesh mesh;
|
|
299
299
|
if (wp::mesh_get_descriptor(id, mesh))
|
|
@@ -302,12 +302,12 @@ void mesh_destroy_device(uint64_t id)
|
|
|
302
302
|
|
|
303
303
|
wp::bvh_destroy_device(mesh.bvh);
|
|
304
304
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
305
|
+
wp_free_device(WP_CURRENT_CONTEXT, mesh.lowers);
|
|
306
|
+
wp_free_device(WP_CURRENT_CONTEXT, mesh.uppers);
|
|
307
|
+
wp_free_device(WP_CURRENT_CONTEXT, (wp::Mesh*)id);
|
|
308
308
|
|
|
309
309
|
if (mesh.solid_angle_props) {
|
|
310
|
-
|
|
310
|
+
wp_free_device(WP_CURRENT_CONTEXT, mesh.solid_angle_props);
|
|
311
311
|
}
|
|
312
312
|
wp::mesh_rem_descriptor(id);
|
|
313
313
|
}
|
|
@@ -318,7 +318,7 @@ void mesh_update_stats(uint64_t id)
|
|
|
318
318
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
void
|
|
321
|
+
void wp_mesh_refit_device(uint64_t id)
|
|
322
322
|
{
|
|
323
323
|
// recompute triangle bounds
|
|
324
324
|
wp::Mesh m;
|
|
@@ -346,59 +346,59 @@ void mesh_refit_device(uint64_t id)
|
|
|
346
346
|
}
|
|
347
347
|
else
|
|
348
348
|
{
|
|
349
|
-
bvh_refit_device(m.bvh);
|
|
349
|
+
wp::bvh_refit_device(m.bvh);
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
void
|
|
354
|
+
void wp_mesh_set_points_device(uint64_t id, wp::array_t<wp::vec3> points)
|
|
355
355
|
{
|
|
356
356
|
wp::Mesh m;
|
|
357
357
|
if (mesh_get_descriptor(id, m))
|
|
358
358
|
{
|
|
359
359
|
if (points.ndim != 1 || points.shape[0] != m.points.shape[0])
|
|
360
360
|
{
|
|
361
|
-
fprintf(stderr, "The new points input for
|
|
361
|
+
fprintf(stderr, "The new points input for wp_mesh_set_points_device does not match the shape of the original points!\n");
|
|
362
362
|
return;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
m.points = points;
|
|
366
366
|
|
|
367
367
|
wp::Mesh* mesh_device = (wp::Mesh*)id;
|
|
368
|
-
|
|
368
|
+
wp_memcpy_h2d(WP_CURRENT_CONTEXT, mesh_device, &m, sizeof(wp::Mesh));
|
|
369
369
|
|
|
370
370
|
// update the cpu copy as well
|
|
371
371
|
mesh_set_descriptor(id, m);
|
|
372
372
|
|
|
373
|
-
|
|
373
|
+
wp_mesh_refit_device(id);
|
|
374
374
|
}
|
|
375
375
|
else
|
|
376
376
|
{
|
|
377
|
-
fprintf(stderr, "The mesh id provided to
|
|
377
|
+
fprintf(stderr, "The mesh id provided to wp_mesh_set_points_device is not valid!\n");
|
|
378
378
|
return;
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
void
|
|
382
|
+
void wp_mesh_set_velocities_device(uint64_t id, wp::array_t<wp::vec3> velocities)
|
|
383
383
|
{
|
|
384
384
|
wp::Mesh m;
|
|
385
385
|
if (mesh_get_descriptor(id, m))
|
|
386
386
|
{
|
|
387
387
|
if (velocities.ndim != 1 || velocities.shape[0] != m.velocities.shape[0])
|
|
388
388
|
{
|
|
389
|
-
fprintf(stderr, "The new velocities input for
|
|
389
|
+
fprintf(stderr, "The new velocities input for wp_mesh_set_velocities_device does not match the shape of the original velocities\n");
|
|
390
390
|
return;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
m.velocities = velocities;
|
|
394
394
|
|
|
395
395
|
wp::Mesh* mesh_device = (wp::Mesh*)id;
|
|
396
|
-
|
|
396
|
+
wp_memcpy_h2d(WP_CURRENT_CONTEXT, mesh_device, &m, sizeof(wp::Mesh));
|
|
397
397
|
mesh_set_descriptor(id, m);
|
|
398
398
|
}
|
|
399
399
|
else
|
|
400
400
|
{
|
|
401
|
-
fprintf(stderr, "The mesh id provided to
|
|
401
|
+
fprintf(stderr, "The mesh id provided to wp_mesh_set_velocities_device is not valid!\n");
|
|
402
402
|
return;
|
|
403
403
|
}
|
|
404
404
|
}
|
warp/native/mesh.h
CHANGED
|
@@ -58,6 +58,7 @@ struct Mesh
|
|
|
58
58
|
context = nullptr;
|
|
59
59
|
solid_angle_props = nullptr;
|
|
60
60
|
average_edge_length = 0.0f;
|
|
61
|
+
bvh = BVH{};
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
inline CUDA_CALLABLE Mesh(
|
|
@@ -73,6 +74,7 @@ struct Mesh
|
|
|
73
74
|
uppers = nullptr;
|
|
74
75
|
solid_angle_props = nullptr;
|
|
75
76
|
average_edge_length = 0.0f;
|
|
77
|
+
bvh = BVH{};
|
|
76
78
|
}
|
|
77
79
|
};
|
|
78
80
|
|
|
@@ -1357,7 +1359,7 @@ CUDA_CALLABLE inline void adj_mesh_query_point_sign_normal(uint64_t id, const ve
|
|
|
1357
1359
|
uint64_t adj_id, vec3& adj_point, float& adj_max_dist, float& adj_epsilon, mesh_query_point_t& adj_ret)
|
|
1358
1360
|
{
|
|
1359
1361
|
adj_mesh_query_point_sign_normal(id, point, max_dist, ret.sign, ret.face, ret.u, ret.v, epsilon,
|
|
1360
|
-
adj_id, adj_point, adj_max_dist, adj_ret.sign, adj_ret.face, adj_ret.u, adj_ret.v,
|
|
1362
|
+
adj_id, adj_point, adj_max_dist, adj_ret.sign, adj_ret.face, adj_ret.u, adj_ret.v, adj_epsilon, adj_ret.result);
|
|
1361
1363
|
}
|
|
1362
1364
|
|
|
1363
1365
|
CUDA_CALLABLE inline void adj_mesh_query_point_sign_winding_number(uint64_t id, const vec3& point, float max_dist, float accuracy, float winding_number_threshold, const mesh_query_point_t& ret,
|
|
@@ -1630,7 +1632,7 @@ CUDA_CALLABLE inline mesh_query_aabb_t mesh_query_aabb(
|
|
|
1630
1632
|
BVHPackedNodeHalf node_lower = bvh_load_node(mesh.bvh.node_lowers, nodeIndex);
|
|
1631
1633
|
BVHPackedNodeHalf node_upper = bvh_load_node(mesh.bvh.node_uppers, nodeIndex);
|
|
1632
1634
|
|
|
1633
|
-
if (!input_bounds.overlaps((
|
|
1635
|
+
if (!input_bounds.overlaps(reinterpret_cast<vec3&>(node_lower), reinterpret_cast<vec3&>(node_upper)))
|
|
1634
1636
|
{
|
|
1635
1637
|
// Skip this box, it doesn't overlap with our target box.
|
|
1636
1638
|
continue;
|
|
@@ -1715,7 +1717,7 @@ CUDA_CALLABLE inline bool mesh_query_aabb_next(mesh_query_aabb_t& query, int& in
|
|
|
1715
1717
|
BVHPackedNodeHalf node_lower = bvh_load_node(mesh.bvh.node_lowers, node_index);
|
|
1716
1718
|
BVHPackedNodeHalf node_upper = bvh_load_node(mesh.bvh.node_uppers, node_index);
|
|
1717
1719
|
|
|
1718
|
-
if (!input_bounds.overlaps((
|
|
1720
|
+
if (!input_bounds.overlaps(reinterpret_cast<vec3&>(node_lower), reinterpret_cast<vec3&>(node_upper)))
|
|
1719
1721
|
{
|
|
1720
1722
|
// Skip this box, it doesn't overlap with our target box.
|
|
1721
1723
|
continue;
|