diff --git a/include/mitsuba/render/scene.h b/include/mitsuba/render/scene.h index 42250310..97c46686 100644 --- a/include/mitsuba/render/scene.h +++ b/include/mitsuba/render/scene.h @@ -72,6 +72,14 @@ public: */ void initialize(); + /** + *\brief Invalidate the kd-tree + * + * This function must be called if, after running \ref initialize(), + * additional geometry is added to the scene. + */ + void invalidate(); + /** * \brief Initialize the scene for bidirectional rendering algorithms. * diff --git a/src/libpython/render.cpp b/src/libpython/render.cpp index a5d0d96f..e3ae9c6a 100644 --- a/src/libpython/render.cpp +++ b/src/libpython/render.cpp @@ -330,6 +330,7 @@ void export_render() { .def("getPrimitiveCount", &ShapeKDTree::getPrimitiveCount) .def("addShape", &ShapeKDTree::addShape) .def("build", &ShapeKDTree::build) + .def("isBuilt", &ShapeKDTree::isBuilt) .def("getAABB", &shapekdtree_getAABB, BP_RETURN_VALUE) .def("getShapes", &shapekdtree_getShapes) .def("rayIntersect", &shapekdtree_rayIntersect); @@ -343,6 +344,7 @@ void export_render() { .def(bp::init()) .def(bp::init()) .def("initialize", &Scene::initialize) + .def("invalidate", &Scene::invalidate) .def("preprocess", &Scene::preprocess) .def("render", &Scene::render) .def("postprocess", &Scene::postprocess) diff --git a/src/librender/scene.cpp b/src/librender/scene.cpp index 2f7f0e39..2b269949 100644 --- a/src/librender/scene.cpp +++ b/src/librender/scene.cpp @@ -315,6 +315,10 @@ void Scene::configure() { m_integrator->configureSampler(this, m_sampler); } +void Scene::invalidate() { + m_kdtree = new ShapeKDTree(); +} + void Scene::initialize() { if (!m_kdtree->isBuilt()) { /* Expand all geometry */