triro 1.3.0
A Python Ray-Mesh Intersector in OptiX
Loading...
Searching...
No Matches
binding.cpp
Go to the documentation of this file.
1
2#include "ray.h"
3#include <torch/extension.h>
4
5namespace hmesh {
6
7extern void initOptix();
8extern void createOptixContext();
9extern void createOptixModule();
10extern torch::Tensor intersectsAny(OptixAccelStructureWrapperCPP as,
11 const torch::Tensor &origins,
12 const torch::Tensor &dirs);
13extern torch::Tensor intersectsFirst(OptixAccelStructureWrapperCPP as,
14 const torch::Tensor &origins,
15 const torch::Tensor &dirs);
16extern std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor,
17 torch::Tensor>
18intersectsClosest(OptixAccelStructureWrapperCPP as, torch::Tensor origins,
19 torch::Tensor directions);
20extern torch::Tensor intersectsCount(OptixAccelStructureWrapperCPP as,
21 torch::Tensor origins,
22 torch::Tensor directions);
23extern std::tuple<torch::Tensor, torch::Tensor, torch::Tensor>
24intersectsLocation(OptixAccelStructureWrapperCPP as, torch::Tensor origins,
25 torch::Tensor directions);
26extern void createPipelines();
27extern void buildSBT();
28
29} // namespace hmesh
30
31PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
32 pybind11::class_<hmesh::OptixAccelStructureWrapperCPP>(
33 m, "OptixAccelStructureWrapperCPP")
34 .def(pybind11::init<>())
35 .def("buildAccelStructure",
37 .def("freeAccelStructure",
39
40 m.def("initOptix", &hmesh::initOptix, "Initialize Optix");
41 m.def("createOptixContext", &hmesh::createOptixContext,
42 "Create Optix context");
43 m.def("createOptixModule", &hmesh::createOptixModule,
44 "Create Optix module");
45 m.def("createOptixPipelines", &hmesh::createPipelines,
46 "Create Optix pipelines for each function type.");
47 m.def("buildSBT", &hmesh::buildSBT, "Build SBT for each function type.");
48 m.def("intersectsAny", &hmesh::intersectsAny,
49 "Find out if each ray hit any triangle on the mesh.");
50 m.def("intersectsFirst", &hmesh::intersectsFirst,
51 "Find the index of the first triangle a ray hits.");
52 m.def("intersectsClosest", &hmesh::intersectsClosest,
53 "Find if ray hits any triangle and return ray index, triangle index, "
54 "hit location and uv.");
55 m.def("intersectsCount", &hmesh::intersectsCount,
56 "Find the intersection count.");
57 m.def("intersectsLocation", &hmesh::intersectsLocation,
58 "Find all intersection locations.");
59}
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)
Definition binding.cpp:31
Definition base.cpp:13
void initOptix()
Definition base.cpp:31
std::tuple< torch::Tensor, torch::Tensor, torch::Tensor > intersectsLocation(OptixAccelStructureWrapperCPP as, torch::Tensor origins, torch::Tensor directions)
Definition ray.cpp:325
torch::Tensor intersectsFirst(OptixAccelStructureWrapperCPP as, const torch::Tensor &origins, const torch::Tensor &dirs)
Definition ray.cpp:191
std::tuple< torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor > intersectsClosest(OptixAccelStructureWrapperCPP as, torch::Tensor origins, torch::Tensor directions)
Find if ray hits any triangle and return ray index, triangle index, hit location and uv.
Definition ray.cpp:233
void createOptixContext()
Definition base.cpp:33
void createPipelines()
Definition base.cpp:77
void createOptixModule()
Definition base.cpp:43
torch::Tensor intersectsCount(OptixAccelStructureWrapperCPP as, torch::Tensor origins, torch::Tensor directions)
Definition ray.cpp:291
torch::Tensor intersectsAny(OptixAccelStructureWrapperCPP as, const torch::Tensor &origins, const torch::Tensor &dirs)
Definition ray.cpp:161
void buildSBT()
Definition base.cpp:134
void buildAccelStructure(torch::Tensor vertices, torch::Tensor faces)
Definition ray.cpp:27