Skip to content

Commit

Permalink
Added missing Python bindings for Volume API
Browse files Browse the repository at this point in the history
  • Loading branch information
leroyvn authored and Speierers committed Sep 24, 2020
1 parent 2562f74 commit 3214250
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 35 deletions.
1 change: 0 additions & 1 deletion src/librender/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ foreach (MTS_VARIANT ${MTS_VARIANTS})
shape_v.cpp
srgb_v.cpp
texture_v.cpp
# volume_v.cpp
)

target_compile_definitions(${TARGET_NAME}-obj PRIVATE
Expand Down
3 changes: 2 additions & 1 deletion src/librender/python/main_v.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static py::object caster(Object *o) {

PY_TRY_CAST(PhaseFunction);
PY_TRY_CAST(Medium);
PY_TRY_CAST(Volume);

return py::object();
}
Expand Down Expand Up @@ -118,7 +119,7 @@ PYBIND11_MODULE(MODULE_NAME, m) {
MTS_PY_IMPORT(ShapeKDTree);
MTS_PY_IMPORT(srgb);
MTS_PY_IMPORT(Texture);
// MTS_PY_IMPORT(Volume);
MTS_PY_IMPORT(Volume);

/// Register the variant-specific caster with the 'core_ext' module
auto casters = (std::vector<void *> *) (py::capsule)(
Expand Down
33 changes: 0 additions & 33 deletions src/librender/python/texture3d_v.cpp

This file was deleted.

26 changes: 26 additions & 0 deletions src/librender/python/texture_v.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,29 @@ MTS_PY_EXPORT(Texture) {
vectorize(&Texture::pdf_position),
"p"_a, "active"_a = true, D(Texture, pdf_position));
}

MTS_PY_EXPORT(Volume) {
MTS_PY_IMPORT_TYPES(Volume)
MTS_PY_CLASS(Volume, Object)
.def("eval",
vectorize(&Volume::eval),
"it"_a, "active"_a = true, D(Volume, eval))
.def("eval_1",
vectorize(&Volume::eval_1),
"it"_a, "active"_a = true, D(Volume, eval_1))
.def("eval_3",
vectorize(&Volume::eval_3),
"it"_a, "active"_a = true, D(Volume, eval_3))
.def("eval_gradient",
vectorize(&Volume::eval_gradient),
"it"_a, "active"_a = true, D(Volume, eval_gradient))
.def("max",
&Volume::max,
D(Volume, max))
.def("bbox",
&Volume::bbox,
D(Volume, bbox))
.def("resolution",
&Volume::resolution,
D(Volume, resolution));
}

0 comments on commit 3214250

Please sign in to comment.