warp-lang 0.9.0__py3-none-win_amd64.whl → 0.11.0__py3-none-win_amd64.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 +15 -7
- warp/__init__.pyi +1 -0
- warp/bin/warp-clang.dll +0 -0
- warp/bin/warp.dll +0 -0
- warp/build.py +22 -443
- warp/build_dll.py +384 -0
- warp/builtins.py +998 -488
- warp/codegen.py +1307 -739
- warp/config.py +5 -3
- warp/constants.py +6 -0
- warp/context.py +1291 -548
- warp/dlpack.py +31 -31
- warp/fabric.py +326 -0
- warp/fem/__init__.py +27 -0
- warp/fem/cache.py +389 -0
- warp/fem/dirichlet.py +181 -0
- warp/fem/domain.py +263 -0
- warp/fem/field/__init__.py +101 -0
- warp/fem/field/field.py +149 -0
- warp/fem/field/nodal_field.py +299 -0
- warp/fem/field/restriction.py +21 -0
- warp/fem/field/test.py +181 -0
- warp/fem/field/trial.py +183 -0
- warp/fem/geometry/__init__.py +19 -0
- warp/fem/geometry/closest_point.py +70 -0
- warp/fem/geometry/deformed_geometry.py +271 -0
- warp/fem/geometry/element.py +744 -0
- warp/fem/geometry/geometry.py +186 -0
- warp/fem/geometry/grid_2d.py +373 -0
- warp/fem/geometry/grid_3d.py +435 -0
- warp/fem/geometry/hexmesh.py +953 -0
- warp/fem/geometry/partition.py +376 -0
- warp/fem/geometry/quadmesh_2d.py +532 -0
- warp/fem/geometry/tetmesh.py +840 -0
- warp/fem/geometry/trimesh_2d.py +577 -0
- warp/fem/integrate.py +1616 -0
- warp/fem/operator.py +191 -0
- warp/fem/polynomial.py +213 -0
- warp/fem/quadrature/__init__.py +2 -0
- warp/fem/quadrature/pic_quadrature.py +245 -0
- warp/fem/quadrature/quadrature.py +294 -0
- warp/fem/space/__init__.py +292 -0
- warp/fem/space/basis_space.py +489 -0
- warp/fem/space/collocated_function_space.py +105 -0
- warp/fem/space/dof_mapper.py +236 -0
- warp/fem/space/function_space.py +145 -0
- warp/fem/space/grid_2d_function_space.py +267 -0
- warp/fem/space/grid_3d_function_space.py +306 -0
- warp/fem/space/hexmesh_function_space.py +352 -0
- warp/fem/space/partition.py +350 -0
- warp/fem/space/quadmesh_2d_function_space.py +369 -0
- warp/fem/space/restriction.py +160 -0
- warp/fem/space/shape/__init__.py +15 -0
- warp/fem/space/shape/cube_shape_function.py +738 -0
- warp/fem/space/shape/shape_function.py +103 -0
- warp/fem/space/shape/square_shape_function.py +611 -0
- warp/fem/space/shape/tet_shape_function.py +567 -0
- warp/fem/space/shape/triangle_shape_function.py +429 -0
- warp/fem/space/tetmesh_function_space.py +292 -0
- warp/fem/space/topology.py +295 -0
- warp/fem/space/trimesh_2d_function_space.py +221 -0
- warp/fem/types.py +77 -0
- warp/fem/utils.py +495 -0
- warp/native/array.h +164 -55
- warp/native/builtin.h +150 -174
- warp/native/bvh.cpp +75 -328
- warp/native/bvh.cu +406 -23
- warp/native/bvh.h +37 -45
- warp/native/clang/clang.cpp +136 -24
- warp/native/crt.cpp +1 -76
- warp/native/crt.h +111 -104
- warp/native/cuda_crt.h +1049 -0
- warp/native/cuda_util.cpp +15 -3
- warp/native/cuda_util.h +3 -1
- warp/native/cutlass/tools/library/scripts/conv2d_operation.py +463 -0
- warp/native/cutlass/tools/library/scripts/conv3d_operation.py +321 -0
- warp/native/cutlass/tools/library/scripts/gemm_operation.py +988 -0
- warp/native/cutlass/tools/library/scripts/generator.py +4625 -0
- warp/native/cutlass/tools/library/scripts/library.py +799 -0
- warp/native/cutlass/tools/library/scripts/manifest.py +402 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/docs/source/conf.py +96 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/profile/conv/conv2d_f16_sm80.py +106 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/profile/gemm/gemm_f32_sm80.py +91 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/setup.py +80 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/__init__.py +48 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/arguments.py +118 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/c_types.py +241 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/compiler.py +432 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/conv2d_operation.py +631 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/epilogue.py +1026 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/frontend.py +104 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/gemm_operation.py +1276 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/library.py +744 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/memory_manager.py +74 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/operation.py +110 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/parser.py +619 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/reduction_operation.py +398 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/tensor_ref.py +70 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/__init__.py +4 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/conv2d_testbed.py +646 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/gemm_grouped_testbed.py +235 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/gemm_testbed.py +557 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/profiler.py +70 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/type_hint.py +39 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/utils/__init__.py +1 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/utils/device.py +76 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/utils/reference_model.py +255 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/__init__.py +0 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_f16nhwc_f16nhwc_f16nhwc_tensor_op_f16_sm80.py +201 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +177 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_f32nhwc_f32nhwc_f32nhwc_simt_f32_sm80.py +98 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_tf32nhwc_tf32nhwc_f32nhwc_tensor_op_f32_sm80.py +95 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_few_channels_f16nhwc_f16nhwc_f16nhwc_tensor_op_f32_sm80.py +163 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_fixed_channels_f16nhwc_f16nhwc_f16nhwc_tensor_op_f32_sm80.py +187 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_f16nhwc_f16nhwc_f16nhwc_tensor_op_f16_sm80.py +309 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +54 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_f32nhwc_f32nhwc_f32nhwc_simt_f32_sm80.py +96 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_tf32nhwc_tf32nhwc_f32nhwc_tensor_op_f32_sm80.py +107 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_strided_dgrad_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +253 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_f16nhwc_f16nhwc_f16nhwc_tensor_op_f16_sm80.py +97 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +242 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_f32nhwc_f32nhwc_f32nhwc_simt_f32_sm80.py +96 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_tf32nhwc_tf32nhwc_f32nhwc_tensor_op_f32_sm80.py +107 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/run_all_tests.py +10 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/frontend/test_frontend.py +146 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/__init__.py +0 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_bf16_sm80.py +96 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_f16_sm80.py +447 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_f32_sm80.py +146 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_f64_sm80.py +102 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_grouped_sm80.py +203 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_s8_sm80.py +229 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/run_all_tests.py +9 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/unit/test_sm80.py +453 -0
- warp/native/cutlass/tools/library/scripts/rank_2k_operation.py +398 -0
- warp/native/cutlass/tools/library/scripts/rank_k_operation.py +387 -0
- warp/native/cutlass/tools/library/scripts/rt.py +796 -0
- warp/native/cutlass/tools/library/scripts/symm_operation.py +400 -0
- warp/native/cutlass/tools/library/scripts/trmm_operation.py +407 -0
- warp/native/cutlass_gemm.cu +5 -3
- warp/native/exports.h +1240 -949
- warp/native/fabric.h +228 -0
- warp/native/hashgrid.cpp +4 -4
- warp/native/hashgrid.h +22 -2
- warp/native/initializer_array.h +2 -2
- warp/native/intersect.h +22 -7
- warp/native/intersect_adj.h +8 -8
- warp/native/intersect_tri.h +13 -16
- warp/native/marching.cu +157 -161
- warp/native/mat.h +119 -19
- warp/native/matnn.h +2 -2
- warp/native/mesh.cpp +108 -83
- warp/native/mesh.cu +243 -6
- warp/native/mesh.h +1547 -458
- warp/native/nanovdb/NanoVDB.h +1 -1
- warp/native/noise.h +272 -329
- warp/native/quat.h +51 -8
- warp/native/rand.h +45 -35
- warp/native/range.h +6 -2
- warp/native/reduce.cpp +157 -0
- warp/native/reduce.cu +348 -0
- warp/native/runlength_encode.cpp +62 -0
- warp/native/runlength_encode.cu +46 -0
- warp/native/scan.cu +11 -13
- warp/native/scan.h +1 -0
- warp/native/solid_angle.h +442 -0
- warp/native/sort.cpp +13 -0
- warp/native/sort.cu +9 -1
- warp/native/sparse.cpp +338 -0
- warp/native/sparse.cu +545 -0
- warp/native/spatial.h +2 -2
- warp/native/temp_buffer.h +30 -0
- warp/native/vec.h +126 -24
- warp/native/volume.h +120 -0
- warp/native/warp.cpp +658 -53
- warp/native/warp.cu +660 -68
- warp/native/warp.h +112 -12
- warp/optim/__init__.py +1 -0
- warp/optim/linear.py +922 -0
- warp/optim/sgd.py +92 -0
- warp/render/render_opengl.py +392 -152
- warp/render/render_usd.py +11 -11
- warp/sim/__init__.py +2 -2
- warp/sim/articulation.py +385 -185
- warp/sim/collide.py +21 -8
- warp/sim/import_mjcf.py +297 -106
- warp/sim/import_urdf.py +389 -210
- warp/sim/import_usd.py +198 -97
- warp/sim/inertia.py +17 -18
- warp/sim/integrator_euler.py +14 -8
- warp/sim/integrator_xpbd.py +161 -19
- warp/sim/model.py +795 -291
- warp/sim/optimizer.py +2 -6
- warp/sim/render.py +65 -3
- warp/sim/utils.py +3 -0
- warp/sparse.py +1227 -0
- warp/stubs.py +665 -223
- warp/tape.py +66 -15
- warp/tests/__main__.py +3 -6
- warp/tests/assets/curlnoise_golden.npy +0 -0
- warp/tests/assets/pnoise_golden.npy +0 -0
- warp/tests/assets/torus.usda +105 -105
- warp/tests/{test_class_kernel.py → aux_test_class_kernel.py} +9 -1
- warp/tests/aux_test_conditional_unequal_types_kernels.py +21 -0
- warp/tests/{test_dependent.py → aux_test_dependent.py} +2 -2
- warp/tests/{test_reference.py → aux_test_reference.py} +1 -1
- warp/tests/aux_test_unresolved_func.py +14 -0
- warp/tests/aux_test_unresolved_symbol.py +14 -0
- warp/tests/disabled_kinematics.py +239 -0
- warp/tests/run_coverage_serial.py +31 -0
- warp/tests/test_adam.py +103 -106
- warp/tests/test_arithmetic.py +128 -74
- warp/tests/test_array.py +1497 -211
- warp/tests/test_array_reduce.py +150 -0
- warp/tests/test_atomic.py +64 -28
- warp/tests/test_bool.py +99 -0
- warp/tests/test_builtins_resolution.py +1292 -0
- warp/tests/test_bvh.py +75 -43
- warp/tests/test_closest_point_edge_edge.py +54 -57
- warp/tests/test_codegen.py +233 -128
- warp/tests/test_compile_consts.py +28 -20
- warp/tests/test_conditional.py +108 -24
- warp/tests/test_copy.py +10 -12
- warp/tests/test_ctypes.py +112 -88
- warp/tests/test_dense.py +21 -14
- warp/tests/test_devices.py +98 -0
- warp/tests/test_dlpack.py +136 -108
- warp/tests/test_examples.py +277 -0
- warp/tests/test_fabricarray.py +955 -0
- warp/tests/test_fast_math.py +15 -11
- warp/tests/test_fem.py +1271 -0
- warp/tests/test_fp16.py +53 -19
- warp/tests/test_func.py +187 -74
- warp/tests/test_generics.py +194 -49
- warp/tests/test_grad.py +180 -116
- warp/tests/test_grad_customs.py +176 -0
- warp/tests/test_hash_grid.py +52 -37
- warp/tests/test_import.py +10 -23
- warp/tests/test_indexedarray.py +577 -24
- warp/tests/test_intersect.py +18 -9
- warp/tests/test_large.py +141 -0
- warp/tests/test_launch.py +251 -15
- warp/tests/test_lerp.py +64 -65
- warp/tests/test_linear_solvers.py +154 -0
- warp/tests/test_lvalue.py +493 -0
- warp/tests/test_marching_cubes.py +12 -13
- warp/tests/test_mat.py +508 -2778
- warp/tests/test_mat_lite.py +115 -0
- warp/tests/test_mat_scalar_ops.py +2889 -0
- warp/tests/test_math.py +103 -9
- warp/tests/test_matmul.py +305 -69
- warp/tests/test_matmul_lite.py +410 -0
- warp/tests/test_mesh.py +71 -14
- warp/tests/test_mesh_query_aabb.py +41 -25
- warp/tests/test_mesh_query_point.py +325 -34
- warp/tests/test_mesh_query_ray.py +39 -22
- warp/tests/test_mlp.py +30 -22
- warp/tests/test_model.py +92 -89
- warp/tests/test_modules_lite.py +39 -0
- warp/tests/test_multigpu.py +88 -114
- warp/tests/test_noise.py +12 -11
- warp/tests/test_operators.py +16 -20
- warp/tests/test_options.py +11 -11
- warp/tests/test_pinned.py +17 -18
- warp/tests/test_print.py +32 -11
- warp/tests/test_quat.py +275 -129
- warp/tests/test_rand.py +18 -16
- warp/tests/test_reload.py +38 -34
- warp/tests/test_rounding.py +50 -43
- warp/tests/test_runlength_encode.py +190 -0
- warp/tests/test_smoothstep.py +9 -11
- warp/tests/test_snippet.py +143 -0
- warp/tests/test_sparse.py +460 -0
- warp/tests/test_spatial.py +276 -243
- warp/tests/test_streams.py +110 -85
- warp/tests/test_struct.py +331 -85
- warp/tests/test_tape.py +39 -21
- warp/tests/test_torch.py +118 -89
- warp/tests/test_transient_module.py +12 -13
- warp/tests/test_types.py +614 -0
- warp/tests/test_utils.py +494 -0
- warp/tests/test_vec.py +354 -1987
- warp/tests/test_vec_lite.py +73 -0
- warp/tests/test_vec_scalar_ops.py +2099 -0
- warp/tests/test_volume.py +457 -293
- warp/tests/test_volume_write.py +124 -134
- warp/tests/unittest_serial.py +35 -0
- warp/tests/unittest_suites.py +341 -0
- warp/tests/unittest_utils.py +568 -0
- warp/tests/unused_test_misc.py +71 -0
- warp/tests/{test_debug.py → walkthough_debug.py} +3 -17
- warp/thirdparty/appdirs.py +36 -45
- warp/thirdparty/unittest_parallel.py +549 -0
- warp/torch.py +72 -30
- warp/types.py +1744 -713
- warp/utils.py +360 -350
- warp_lang-0.11.0.dist-info/LICENSE.md +36 -0
- warp_lang-0.11.0.dist-info/METADATA +238 -0
- warp_lang-0.11.0.dist-info/RECORD +332 -0
- {warp_lang-0.9.0.dist-info → warp_lang-0.11.0.dist-info}/WHEEL +1 -1
- warp/bin/warp-clang.exp +0 -0
- warp/bin/warp-clang.lib +0 -0
- warp/bin/warp.exp +0 -0
- warp/bin/warp.lib +0 -0
- warp/tests/test_all.py +0 -215
- warp/tests/test_array_scan.py +0 -60
- warp/tests/test_base.py +0 -208
- warp/tests/test_unresolved_func.py +0 -7
- warp/tests/test_unresolved_symbol.py +0 -7
- warp_lang-0.9.0.dist-info/METADATA +0 -20
- warp_lang-0.9.0.dist-info/RECORD +0 -177
- /warp/tests/{test_compile_consts_dummy.py → aux_test_compile_consts_dummy.py} +0 -0
- /warp/tests/{test_reference_reference.py → aux_test_reference_reference.py} +0 -0
- /warp/tests/{test_square.py → aux_test_square.py} +0 -0
- {warp_lang-0.9.0.dist-info → warp_lang-0.11.0.dist-info}/top_level.txt +0 -0
|
@@ -5,14 +5,13 @@
|
|
|
5
5
|
# distribution of this software and related documentation without an express
|
|
6
6
|
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
|
7
7
|
|
|
8
|
-
# include parent path
|
|
9
|
-
import numpy as np
|
|
10
8
|
import math
|
|
9
|
+
import unittest
|
|
11
10
|
|
|
12
|
-
import
|
|
13
|
-
from warp.tests.test_base import *
|
|
11
|
+
import numpy as np
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
import warp as wp
|
|
14
|
+
from warp.tests.unittest_utils import *
|
|
16
15
|
|
|
17
16
|
wp.init()
|
|
18
17
|
|
|
@@ -44,6 +43,110 @@ def sample_mesh_query(
|
|
|
44
43
|
query_faces[tid] = face_index
|
|
45
44
|
query_dist[tid] = wp.length(cp - p)
|
|
46
45
|
|
|
46
|
+
query = wp.mesh_query_point(mesh, p, max_dist)
|
|
47
|
+
wp.expect_eq(query.sign, sign)
|
|
48
|
+
wp.expect_eq(query.face, face_index)
|
|
49
|
+
wp.expect_eq(query.u, face_u)
|
|
50
|
+
wp.expect_eq(query.v, face_v)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@wp.kernel
|
|
54
|
+
def sample_mesh_query_no_sign(
|
|
55
|
+
mesh: wp.uint64,
|
|
56
|
+
query_points: wp.array(dtype=wp.vec3),
|
|
57
|
+
query_faces: wp.array(dtype=int),
|
|
58
|
+
query_dist: wp.array(dtype=float),
|
|
59
|
+
):
|
|
60
|
+
tid = wp.tid()
|
|
61
|
+
|
|
62
|
+
face_index = int(0)
|
|
63
|
+
face_u = float(0.0)
|
|
64
|
+
face_v = float(0.0)
|
|
65
|
+
|
|
66
|
+
max_dist = 10012.0
|
|
67
|
+
|
|
68
|
+
p = query_points[tid]
|
|
69
|
+
|
|
70
|
+
wp.mesh_query_point_no_sign(mesh, p, max_dist, face_index, face_u, face_v)
|
|
71
|
+
|
|
72
|
+
cp = wp.mesh_eval_position(mesh, face_index, face_u, face_v)
|
|
73
|
+
|
|
74
|
+
query_faces[tid] = face_index
|
|
75
|
+
query_dist[tid] = wp.length(cp - p)
|
|
76
|
+
|
|
77
|
+
query = wp.mesh_query_point_no_sign(mesh, p, max_dist)
|
|
78
|
+
wp.expect_eq(query.face, face_index)
|
|
79
|
+
wp.expect_eq(query.u, face_u)
|
|
80
|
+
wp.expect_eq(query.v, face_v)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@wp.kernel
|
|
84
|
+
def sample_mesh_query_sign_normal(
|
|
85
|
+
mesh: wp.uint64,
|
|
86
|
+
query_points: wp.array(dtype=wp.vec3),
|
|
87
|
+
query_faces: wp.array(dtype=int),
|
|
88
|
+
query_signs: wp.array(dtype=float),
|
|
89
|
+
query_dist: wp.array(dtype=float),
|
|
90
|
+
):
|
|
91
|
+
tid = wp.tid()
|
|
92
|
+
|
|
93
|
+
face_index = int(0)
|
|
94
|
+
face_u = float(0.0)
|
|
95
|
+
face_v = float(0.0)
|
|
96
|
+
sign = float(0.0)
|
|
97
|
+
|
|
98
|
+
max_dist = 10012.0
|
|
99
|
+
|
|
100
|
+
p = query_points[tid]
|
|
101
|
+
|
|
102
|
+
wp.mesh_query_point_sign_normal(mesh, p, max_dist, sign, face_index, face_u, face_v)
|
|
103
|
+
|
|
104
|
+
cp = wp.mesh_eval_position(mesh, face_index, face_u, face_v)
|
|
105
|
+
|
|
106
|
+
query_signs[tid] = sign
|
|
107
|
+
query_faces[tid] = face_index
|
|
108
|
+
query_dist[tid] = wp.length(cp - p)
|
|
109
|
+
|
|
110
|
+
query = wp.mesh_query_point_sign_normal(mesh, p, max_dist)
|
|
111
|
+
wp.expect_eq(query.sign, sign)
|
|
112
|
+
wp.expect_eq(query.face, face_index)
|
|
113
|
+
wp.expect_eq(query.u, face_u)
|
|
114
|
+
wp.expect_eq(query.v, face_v)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@wp.kernel
|
|
118
|
+
def sample_mesh_query_sign_winding_number(
|
|
119
|
+
mesh: wp.uint64,
|
|
120
|
+
query_points: wp.array(dtype=wp.vec3),
|
|
121
|
+
query_faces: wp.array(dtype=int),
|
|
122
|
+
query_signs: wp.array(dtype=float),
|
|
123
|
+
query_dist: wp.array(dtype=float),
|
|
124
|
+
):
|
|
125
|
+
tid = wp.tid()
|
|
126
|
+
|
|
127
|
+
face_index = int(0)
|
|
128
|
+
face_u = float(0.0)
|
|
129
|
+
face_v = float(0.0)
|
|
130
|
+
sign = float(0.0)
|
|
131
|
+
|
|
132
|
+
max_dist = 10012.0
|
|
133
|
+
|
|
134
|
+
p = query_points[tid]
|
|
135
|
+
|
|
136
|
+
wp.mesh_query_point_sign_winding_number(mesh, p, max_dist, sign, face_index, face_u, face_v)
|
|
137
|
+
|
|
138
|
+
cp = wp.mesh_eval_position(mesh, face_index, face_u, face_v)
|
|
139
|
+
|
|
140
|
+
query_signs[tid] = sign
|
|
141
|
+
query_faces[tid] = face_index
|
|
142
|
+
query_dist[tid] = wp.length(cp - p)
|
|
143
|
+
|
|
144
|
+
query = wp.mesh_query_point_sign_winding_number(mesh, p, max_dist)
|
|
145
|
+
wp.expect_eq(query.sign, sign)
|
|
146
|
+
wp.expect_eq(query.face, face_index)
|
|
147
|
+
wp.expect_eq(query.u, face_u)
|
|
148
|
+
wp.expect_eq(query.v, face_v)
|
|
149
|
+
|
|
47
150
|
|
|
48
151
|
@wp.func
|
|
49
152
|
def triangle_closest_point(a: wp.vec3, b: wp.vec3, c: wp.vec3, p: wp.vec3):
|
|
@@ -107,7 +210,7 @@ def solid_angle(v0: wp.vec3, v1: wp.vec3, v2: wp.vec3, p: wp.vec3):
|
|
|
107
210
|
det = wp.dot(a, wp.cross(b, c))
|
|
108
211
|
den = a_len * b_len * c_len + wp.dot(a, b) * c_len + wp.dot(b, c) * a_len + wp.dot(c, a) * b_len
|
|
109
212
|
|
|
110
|
-
return wp.atan2(det, den)
|
|
213
|
+
return 2.0 * wp.atan2(det, den)
|
|
111
214
|
|
|
112
215
|
|
|
113
216
|
@wp.kernel
|
|
@@ -125,7 +228,7 @@ def sample_mesh_brute(
|
|
|
125
228
|
min_face = int(0)
|
|
126
229
|
min_dist = float(1.0e6)
|
|
127
230
|
|
|
128
|
-
|
|
231
|
+
sum_solid_angle = float(0.0)
|
|
129
232
|
|
|
130
233
|
p = query_points[tid]
|
|
131
234
|
|
|
@@ -134,7 +237,7 @@ def sample_mesh_brute(
|
|
|
134
237
|
b = tri_points[tri_indices[i * 3 + 1]]
|
|
135
238
|
c = tri_points[tri_indices[i * 3 + 2]]
|
|
136
239
|
|
|
137
|
-
|
|
240
|
+
sum_solid_angle += solid_angle(a, b, c, p)
|
|
138
241
|
|
|
139
242
|
bary = triangle_closest_point(a, b, c, p)
|
|
140
243
|
u = bary[0]
|
|
@@ -147,16 +250,20 @@ def sample_mesh_brute(
|
|
|
147
250
|
min_dist = cp_dist
|
|
148
251
|
min_face = i
|
|
149
252
|
|
|
253
|
+
# for an inside point, the sum of the solid angle should be 4PI
|
|
254
|
+
# for an outside point, the sum should be 0
|
|
150
255
|
query_faces[tid] = min_face
|
|
151
|
-
query_signs[tid] =
|
|
256
|
+
query_signs[tid] = sum_solid_angle
|
|
152
257
|
query_dist[tid] = min_dist
|
|
153
258
|
|
|
154
259
|
|
|
155
260
|
# constructs a grid of evenly spaced particles
|
|
156
261
|
def particle_grid(dim_x, dim_y, dim_z, lower, radius, jitter):
|
|
262
|
+
rng = np.random.default_rng(123)
|
|
263
|
+
|
|
157
264
|
points = np.meshgrid(np.linspace(0, dim_x, dim_x), np.linspace(0, dim_y, dim_y), np.linspace(0, dim_z, dim_z))
|
|
158
265
|
points_t = np.array((points[0], points[1], points[2])).T * radius * 2.0 + np.array(lower)
|
|
159
|
-
points_t = points_t +
|
|
266
|
+
points_t = points_t + rng.random(points_t.shape) * radius * jitter
|
|
160
267
|
|
|
161
268
|
return points_t.reshape((-1, 3))
|
|
162
269
|
|
|
@@ -180,6 +287,7 @@ def triangulate(face_counts, face_indices):
|
|
|
180
287
|
return tri_indices
|
|
181
288
|
|
|
182
289
|
|
|
290
|
+
@unittest.skipUnless(USD_AVAILABLE, "Requires usd-core")
|
|
183
291
|
def test_mesh_query_point(test, device):
|
|
184
292
|
from pxr import Usd, UsdGeom
|
|
185
293
|
|
|
@@ -195,7 +303,7 @@ def test_mesh_query_point(test, device):
|
|
|
195
303
|
mesh_indices = wp.array(np.array(tri_indices), dtype=int, device=device)
|
|
196
304
|
|
|
197
305
|
# create mesh
|
|
198
|
-
mesh = wp.Mesh(points=mesh_points, velocities=None, indices=mesh_indices)
|
|
306
|
+
mesh = wp.Mesh(points=mesh_points, velocities=None, indices=mesh_indices, support_winding_number=True)
|
|
199
307
|
|
|
200
308
|
p = particle_grid(32, 32, 32, np.array([-1.1, -1.1, -1.1]), 0.05, 0.0)
|
|
201
309
|
|
|
@@ -206,6 +314,17 @@ def test_mesh_query_point(test, device):
|
|
|
206
314
|
faces_query = wp.zeros(query_count, dtype=int, device=device)
|
|
207
315
|
dist_query = wp.zeros(query_count, dtype=float, device=device)
|
|
208
316
|
|
|
317
|
+
faces_query_no_sign = wp.zeros(query_count, dtype=int, device=device)
|
|
318
|
+
dist_query_no_sign = wp.zeros(query_count, dtype=float, device=device)
|
|
319
|
+
|
|
320
|
+
signs_query_normal = wp.zeros(query_count, dtype=float, device=device)
|
|
321
|
+
faces_query_normal = wp.zeros(query_count, dtype=int, device=device)
|
|
322
|
+
dist_query_normal = wp.zeros(query_count, dtype=float, device=device)
|
|
323
|
+
|
|
324
|
+
signs_query_winding_number = wp.zeros(query_count, dtype=float, device=device)
|
|
325
|
+
faces_query_winding_number = wp.zeros(query_count, dtype=int, device=device)
|
|
326
|
+
dist_query_winding_number = wp.zeros(query_count, dtype=float, device=device)
|
|
327
|
+
|
|
209
328
|
signs_brute = wp.zeros(query_count, dtype=float, device=device)
|
|
210
329
|
faces_brute = wp.zeros(query_count, dtype=int, device=device)
|
|
211
330
|
dist_brute = wp.zeros(query_count, dtype=float, device=device)
|
|
@@ -216,6 +335,34 @@ def test_mesh_query_point(test, device):
|
|
|
216
335
|
inputs=[mesh.id, query_points, faces_query, signs_query, dist_query],
|
|
217
336
|
device=device,
|
|
218
337
|
)
|
|
338
|
+
|
|
339
|
+
wp.launch(
|
|
340
|
+
kernel=sample_mesh_query_no_sign,
|
|
341
|
+
dim=query_count,
|
|
342
|
+
inputs=[mesh.id, query_points, faces_query_no_sign, dist_query_no_sign],
|
|
343
|
+
device=device,
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
wp.launch(
|
|
347
|
+
kernel=sample_mesh_query_sign_normal,
|
|
348
|
+
dim=query_count,
|
|
349
|
+
inputs=[mesh.id, query_points, faces_query_normal, signs_query_normal, dist_query_normal],
|
|
350
|
+
device=device,
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
wp.launch(
|
|
354
|
+
kernel=sample_mesh_query_sign_winding_number,
|
|
355
|
+
dim=query_count,
|
|
356
|
+
inputs=[
|
|
357
|
+
mesh.id,
|
|
358
|
+
query_points,
|
|
359
|
+
faces_query_winding_number,
|
|
360
|
+
signs_query_winding_number,
|
|
361
|
+
dist_query_winding_number,
|
|
362
|
+
],
|
|
363
|
+
device=device,
|
|
364
|
+
)
|
|
365
|
+
|
|
219
366
|
wp.launch(
|
|
220
367
|
kernel=sample_mesh_brute,
|
|
221
368
|
dim=query_count,
|
|
@@ -235,23 +382,44 @@ def test_mesh_query_point(test, device):
|
|
|
235
382
|
faces_query = faces_query.numpy()
|
|
236
383
|
dist_query = dist_query.numpy()
|
|
237
384
|
|
|
385
|
+
faces_query_no_sign = faces_query_no_sign.numpy()
|
|
386
|
+
dist_query_no_sign = dist_query_no_sign.numpy()
|
|
387
|
+
|
|
388
|
+
signs_query_normal = signs_query_normal.numpy()
|
|
389
|
+
faces_query_normal = faces_query_normal.numpy()
|
|
390
|
+
dist_query_normal = dist_query_normal.numpy()
|
|
391
|
+
|
|
392
|
+
signs_query_winding_number = signs_query_winding_number.numpy()
|
|
393
|
+
faces_query_winding_number = faces_query_winding_number.numpy()
|
|
394
|
+
dist_query_winding_number = dist_query_winding_number.numpy()
|
|
395
|
+
|
|
238
396
|
signs_brute = signs_brute.numpy()
|
|
239
397
|
faces_brute = faces_brute.numpy()
|
|
240
398
|
dist_brute = dist_brute.numpy()
|
|
241
399
|
|
|
242
400
|
query_points = query_points.numpy()
|
|
243
401
|
|
|
244
|
-
inside_query = []
|
|
245
|
-
|
|
402
|
+
inside_query = [[0.0, 0.0, 0.0]]
|
|
403
|
+
inside_query_normal = [[0.0, 0.0, 0.0]]
|
|
404
|
+
inside_query_winding_number = [[0.0, 0.0, 0.0]]
|
|
405
|
+
inside_brute = [[0.0, 0.0, 0.0]]
|
|
246
406
|
|
|
247
407
|
for i in range(query_count):
|
|
248
408
|
if signs_query[i] < 0.0:
|
|
249
409
|
inside_query.append(query_points[i].tolist())
|
|
250
410
|
|
|
251
|
-
if
|
|
411
|
+
if signs_query_normal[i] < 0.0:
|
|
412
|
+
inside_query_normal.append(query_points[i].tolist())
|
|
413
|
+
|
|
414
|
+
if signs_query_winding_number[i] < 0.0:
|
|
415
|
+
inside_query_winding_number.append(query_points[i].tolist())
|
|
416
|
+
|
|
417
|
+
if signs_brute[i] > math.pi * 2.0:
|
|
252
418
|
inside_brute.append(query_points[i].tolist())
|
|
253
419
|
|
|
254
420
|
inside_query = np.array(inside_query)
|
|
421
|
+
inside_query_normal = np.array(inside_query_normal)
|
|
422
|
+
inside_query_winding_number = np.array(inside_query_winding_number)
|
|
255
423
|
inside_brute = np.array(inside_brute)
|
|
256
424
|
|
|
257
425
|
# import warp.render
|
|
@@ -269,13 +437,43 @@ def test_mesh_query_point(test, device):
|
|
|
269
437
|
# stage.save()
|
|
270
438
|
|
|
271
439
|
test.assertTrue(len(inside_query) == len(inside_brute))
|
|
440
|
+
test.assertTrue(len(inside_query_normal) == len(inside_brute))
|
|
441
|
+
test.assertTrue(len(inside_query_winding_number) == len(inside_brute))
|
|
272
442
|
|
|
443
|
+
tolerance = 1.5e-4
|
|
273
444
|
dist_error = np.max(np.abs(dist_query - dist_brute))
|
|
274
445
|
sign_error = np.max(np.abs(inside_query - inside_brute))
|
|
275
446
|
|
|
276
|
-
tolerance
|
|
277
|
-
test.assertTrue(
|
|
278
|
-
|
|
447
|
+
test.assertTrue(dist_error < tolerance, f"mesh_query_point dist_error is {dist_error} which is >= {tolerance}")
|
|
448
|
+
test.assertTrue(sign_error < tolerance, f"mesh_query_point sign_error is {sign_error} which is >= {tolerance}")
|
|
449
|
+
|
|
450
|
+
dist_error = np.max(np.abs(dist_query_no_sign - dist_brute))
|
|
451
|
+
|
|
452
|
+
test.assertTrue(
|
|
453
|
+
dist_error < tolerance, f"mesh_query_point_no_sign dist_error is {dist_error} which is >= {tolerance}"
|
|
454
|
+
)
|
|
455
|
+
|
|
456
|
+
dist_error = np.max(np.abs(dist_query_normal - dist_brute))
|
|
457
|
+
sign_error = np.max(np.abs(inside_query_normal - inside_brute))
|
|
458
|
+
|
|
459
|
+
test.assertTrue(
|
|
460
|
+
dist_error < tolerance, f"mesh_query_point_sign_normal dist_error is {dist_error} which is >= {tolerance}"
|
|
461
|
+
)
|
|
462
|
+
test.assertTrue(
|
|
463
|
+
sign_error < tolerance, f"mesh_query_point_sign_normal sign_error is {sign_error} which is >= {tolerance}"
|
|
464
|
+
)
|
|
465
|
+
|
|
466
|
+
dist_error = np.max(np.abs(dist_query_winding_number - dist_brute))
|
|
467
|
+
sign_error = np.max(np.abs(inside_query_winding_number - inside_brute))
|
|
468
|
+
|
|
469
|
+
test.assertTrue(
|
|
470
|
+
dist_error < tolerance,
|
|
471
|
+
f"mesh_query_point_sign_winding_number dist_error is {dist_error} which is >= {tolerance}",
|
|
472
|
+
)
|
|
473
|
+
test.assertTrue(
|
|
474
|
+
sign_error < tolerance,
|
|
475
|
+
f"mesh_query_point_sign_winding_number sign_error is {sign_error} which is >= {tolerance}",
|
|
476
|
+
)
|
|
279
477
|
|
|
280
478
|
|
|
281
479
|
@wp.kernel
|
|
@@ -305,6 +503,7 @@ def mesh_query_point_loss(
|
|
|
305
503
|
loss[tid] = dist
|
|
306
504
|
|
|
307
505
|
|
|
506
|
+
@unittest.skipUnless(USD_AVAILABLE, "Requires usd-core")
|
|
308
507
|
def test_adj_mesh_query_point(test, device):
|
|
309
508
|
from pxr import Usd, UsdGeom
|
|
310
509
|
|
|
@@ -325,7 +524,7 @@ def test_adj_mesh_query_point(test, device):
|
|
|
325
524
|
# mesh_indices = wp.array(np.array([0,1,2]), dtype=int, device=device)
|
|
326
525
|
|
|
327
526
|
# create mesh
|
|
328
|
-
mesh = wp.Mesh(points=mesh_points, velocities=None, indices=mesh_indices)
|
|
527
|
+
mesh = wp.Mesh(points=mesh_points, velocities=None, indices=mesh_indices, support_winding_number=True)
|
|
329
528
|
|
|
330
529
|
# p = particle_grid(32, 32, 32, np.array([-5.0, -5.0, -5.0]), 0.1, 0.1)*100.0
|
|
331
530
|
p = wp.vec3(50.0, 50.0, 50.0)
|
|
@@ -384,28 +583,120 @@ def test_adj_mesh_query_point(test, device):
|
|
|
384
583
|
test.assertTrue(error < tolerance, f"error is {error} which is >= {tolerance}")
|
|
385
584
|
|
|
386
585
|
|
|
387
|
-
|
|
388
|
-
|
|
586
|
+
@wp.kernel
|
|
587
|
+
def sample_furthest_points(mesh: wp.uint64, query_points: wp.array(dtype=wp.vec3), query_result: wp.array(dtype=float)):
|
|
588
|
+
tid = wp.tid()
|
|
389
589
|
|
|
390
|
-
|
|
391
|
-
pass
|
|
590
|
+
p = query_points[tid]
|
|
392
591
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
592
|
+
face = int(0)
|
|
593
|
+
bary_u = float(0.0)
|
|
594
|
+
bary_v = float(0.0)
|
|
396
595
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
have_usd = False
|
|
596
|
+
if wp.mesh_query_furthest_point_no_sign(mesh, p, 0.0, face, bary_u, bary_v):
|
|
597
|
+
closest = wp.mesh_eval_position(mesh, face, bary_u, bary_v)
|
|
400
598
|
|
|
401
|
-
|
|
402
|
-
add_function_test(TestMeshQuery, "test_mesh_query_point", test_mesh_query_point, devices=devices)
|
|
403
|
-
add_function_test(TestMeshQuery, "test_adj_mesh_query_point", test_adj_mesh_query_point, devices=devices)
|
|
599
|
+
query_result[tid] = wp.length_sq(p - closest)
|
|
404
600
|
|
|
405
|
-
|
|
601
|
+
query = wp.mesh_query_furthest_point_no_sign(mesh, p, 0.0)
|
|
602
|
+
wp.expect_eq(query.face, face)
|
|
603
|
+
wp.expect_eq(query.u, bary_u)
|
|
604
|
+
wp.expect_eq(query.v, bary_v)
|
|
406
605
|
|
|
407
606
|
|
|
408
|
-
|
|
409
|
-
|
|
607
|
+
@wp.kernel
|
|
608
|
+
def sample_furthest_points_brute(
|
|
609
|
+
mesh_points: wp.array(dtype=wp.vec3), query_points: wp.array(dtype=wp.vec3), query_result: wp.array(dtype=float)
|
|
610
|
+
):
|
|
611
|
+
tid = wp.tid()
|
|
612
|
+
|
|
613
|
+
p = query_points[tid]
|
|
614
|
+
max_dist_sq = float(0.0)
|
|
615
|
+
|
|
616
|
+
for i in range(mesh_points.shape[0]):
|
|
617
|
+
dist_sq = wp.length_sq(p - mesh_points[i])
|
|
618
|
+
|
|
619
|
+
if dist_sq > max_dist_sq:
|
|
620
|
+
max_dist_sq = dist_sq
|
|
621
|
+
|
|
622
|
+
query_result[tid] = max_dist_sq
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
@unittest.skipUnless(USD_AVAILABLE, "Requires usd-core")
|
|
626
|
+
def test_mesh_query_furthest_point(test, device):
|
|
627
|
+
from pxr import Usd, UsdGeom
|
|
628
|
+
|
|
629
|
+
mesh = Usd.Stage.Open(os.path.abspath(os.path.join(os.path.dirname(__file__), "assets/spiky.usd")))
|
|
630
|
+
mesh_geom = UsdGeom.Mesh(mesh.GetPrimAtPath("/Cube/Cube"))
|
|
631
|
+
|
|
632
|
+
mesh_counts = mesh_geom.GetFaceVertexCountsAttr().Get()
|
|
633
|
+
mesh_indices = mesh_geom.GetFaceVertexIndicesAttr().Get()
|
|
634
|
+
|
|
635
|
+
tri_indices = triangulate(mesh_counts, mesh_indices)
|
|
636
|
+
|
|
637
|
+
mesh_points = wp.array(np.array(mesh_geom.GetPointsAttr().Get()), dtype=wp.vec3, device=device)
|
|
638
|
+
mesh_indices = wp.array(np.array(tri_indices), dtype=int, device=device)
|
|
639
|
+
|
|
640
|
+
# create mesh
|
|
641
|
+
mesh = wp.Mesh(points=mesh_points, indices=mesh_indices)
|
|
642
|
+
|
|
643
|
+
p = particle_grid(32, 32, 32, np.array([-1.1, -1.1, -1.1]), 0.05, 0.0)
|
|
410
644
|
|
|
645
|
+
query_count = len(p)
|
|
646
|
+
query_points = wp.array(p, dtype=wp.vec3, device=device)
|
|
647
|
+
|
|
648
|
+
dist_query = wp.zeros(query_count, dtype=float, device=device)
|
|
649
|
+
dist_brute = wp.zeros(query_count, dtype=float, device=device)
|
|
650
|
+
|
|
651
|
+
wp.launch(sample_furthest_points, dim=query_count, inputs=[mesh.id, query_points, dist_query], device=device)
|
|
652
|
+
wp.launch(
|
|
653
|
+
sample_furthest_points_brute, dim=query_count, inputs=[mesh_points, query_points, dist_brute], device=device
|
|
654
|
+
)
|
|
655
|
+
|
|
656
|
+
assert_np_equal(dist_query.numpy(), dist_brute.numpy(), tol=1.0e-3)
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
def test_mesh_query_point_codegen_adjoints_with_select(test, device):
|
|
660
|
+
def kernel_fn(
|
|
661
|
+
mesh: wp.uint64,
|
|
662
|
+
):
|
|
663
|
+
v = wp.vec3(0.0, 0.0, 0.0)
|
|
664
|
+
d = 1e-6
|
|
665
|
+
|
|
666
|
+
if True:
|
|
667
|
+
query_1 = wp.mesh_query_point(mesh, v, d)
|
|
668
|
+
query_2 = wp.mesh_query_point_no_sign(mesh, v, d)
|
|
669
|
+
query_3 = wp.mesh_query_furthest_point_no_sign(mesh, v, d)
|
|
670
|
+
query_4 = wp.mesh_query_point_sign_normal(mesh, v, d)
|
|
671
|
+
query_5 = wp.mesh_query_point_sign_winding_number(mesh, v, d)
|
|
672
|
+
else:
|
|
673
|
+
query_1 = wp.mesh_query_point(mesh, v, d)
|
|
674
|
+
query_2 = wp.mesh_query_point_no_sign(mesh, v, d)
|
|
675
|
+
query_3 = wp.mesh_query_furthest_point_no_sign(mesh, v, d)
|
|
676
|
+
query_4 = wp.mesh_query_point_sign_normal(mesh, v, d)
|
|
677
|
+
query_5 = wp.mesh_query_point_sign_winding_number(mesh, v, d)
|
|
678
|
+
|
|
679
|
+
wp.Kernel(func=kernel_fn)
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
devices = get_test_devices()
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
class TestMeshQueryPoint(unittest.TestCase):
|
|
686
|
+
pass
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
add_function_test(TestMeshQueryPoint, "test_mesh_query_point", test_mesh_query_point, devices=devices)
|
|
690
|
+
add_function_test(TestMeshQueryPoint, "test_mesh_query_furthest_point", test_mesh_query_furthest_point, devices=devices)
|
|
691
|
+
add_function_test(TestMeshQueryPoint, "test_adj_mesh_query_point", test_adj_mesh_query_point, devices=devices)
|
|
692
|
+
add_function_test(
|
|
693
|
+
TestMeshQueryPoint,
|
|
694
|
+
"test_mesh_query_point_codegen_adjoints_with_select",
|
|
695
|
+
test_mesh_query_point_codegen_adjoints_with_select,
|
|
696
|
+
devices=devices,
|
|
697
|
+
)
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
if __name__ == "__main__":
|
|
701
|
+
wp.build.clear_kernel_cache()
|
|
411
702
|
unittest.main(verbosity=2)
|
|
@@ -5,14 +5,12 @@
|
|
|
5
5
|
# distribution of this software and related documentation without an express
|
|
6
6
|
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import unittest
|
|
9
|
+
|
|
9
10
|
import numpy as np
|
|
10
|
-
import math
|
|
11
11
|
|
|
12
12
|
import warp as wp
|
|
13
|
-
from warp.tests.
|
|
14
|
-
|
|
15
|
-
np.random.seed(42)
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
16
14
|
|
|
17
15
|
wp.init()
|
|
18
16
|
|
|
@@ -66,9 +64,18 @@ def mesh_query_ray_loss(
|
|
|
66
64
|
l = q[0]
|
|
67
65
|
loss[tid] = l
|
|
68
66
|
|
|
67
|
+
query = wp.mesh_query_ray(mesh, p, D, max_t)
|
|
68
|
+
wp.expect_eq(query.t, t)
|
|
69
|
+
wp.expect_eq(query.u, bary_u)
|
|
70
|
+
wp.expect_eq(query.v, bary_v)
|
|
71
|
+
wp.expect_eq(query.sign, sign)
|
|
72
|
+
wp.expect_eq(query.normal, normal)
|
|
73
|
+
wp.expect_eq(query.face, face_index)
|
|
74
|
+
|
|
69
75
|
|
|
76
|
+
@unittest.skipUnless(USD_AVAILABLE, "Requires usd-core")
|
|
70
77
|
def test_mesh_query_ray_grad(test, device):
|
|
71
|
-
from pxr import Usd, UsdGeom
|
|
78
|
+
from pxr import Usd, UsdGeom
|
|
72
79
|
|
|
73
80
|
# test tri
|
|
74
81
|
# print("Testing Single Triangle")
|
|
@@ -210,7 +217,7 @@ def raycast_kernel(
|
|
|
210
217
|
sign = float(0.0) # hit face sign
|
|
211
218
|
n = wp.vec3() # hit face normal
|
|
212
219
|
f = int(0) # hit face index
|
|
213
|
-
max_dist = 1e6 # max raycast
|
|
220
|
+
max_dist = 1e6 # max raycast distance
|
|
214
221
|
|
|
215
222
|
# ray cast against the mesh
|
|
216
223
|
tid = wp.tid()
|
|
@@ -259,28 +266,38 @@ def test_mesh_query_ray_edge(test, device):
|
|
|
259
266
|
test.assertEqual(counts.numpy()[0], n)
|
|
260
267
|
|
|
261
268
|
|
|
262
|
-
def
|
|
263
|
-
|
|
269
|
+
def test_mesh_query_codegen_adjoints_with_select(test, device):
|
|
270
|
+
def kernel_fn(
|
|
271
|
+
mesh: wp.uint64,
|
|
272
|
+
):
|
|
273
|
+
v = wp.vec3(0.0, 0.0, 0.0)
|
|
274
|
+
d = 1e-6
|
|
275
|
+
|
|
276
|
+
if True:
|
|
277
|
+
query = wp.mesh_query_ray(mesh, v, v, d)
|
|
278
|
+
else:
|
|
279
|
+
query = wp.mesh_query_ray(mesh, v, v, d)
|
|
280
|
+
|
|
281
|
+
wp.Kernel(func=kernel_fn)
|
|
264
282
|
|
|
265
|
-
class TestMeshQueryRay(parent):
|
|
266
|
-
pass
|
|
267
283
|
|
|
268
|
-
|
|
284
|
+
devices = get_test_devices()
|
|
269
285
|
|
|
270
|
-
# USD import failures should not count as a test failure
|
|
271
|
-
try:
|
|
272
|
-
from pxr import Usd, UsdGeom
|
|
273
286
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
have_usd = False
|
|
287
|
+
class TestMeshQueryRay(unittest.TestCase):
|
|
288
|
+
pass
|
|
277
289
|
|
|
278
|
-
if have_usd:
|
|
279
|
-
add_function_test(TestMeshQueryRay, "test_mesh_query_ray_grad", test_mesh_query_ray_grad, devices=devices)
|
|
280
290
|
|
|
281
|
-
|
|
291
|
+
add_function_test(TestMeshQueryRay, "test_mesh_query_ray_edge", test_mesh_query_ray_edge, devices=devices)
|
|
292
|
+
add_function_test(TestMeshQueryRay, "test_mesh_query_ray_grad", test_mesh_query_ray_grad, devices=devices)
|
|
293
|
+
add_function_test(
|
|
294
|
+
TestMeshQueryRay,
|
|
295
|
+
"test_mesh_query_codegen_adjoints_with_select",
|
|
296
|
+
test_mesh_query_codegen_adjoints_with_select,
|
|
297
|
+
devices=devices,
|
|
298
|
+
)
|
|
282
299
|
|
|
283
300
|
|
|
284
301
|
if __name__ == "__main__":
|
|
285
|
-
|
|
302
|
+
wp.build.clear_kernel_cache()
|
|
286
303
|
unittest.main(verbosity=2)
|