Skip to content

Commit

Permalink
Scene: Update bounding box when relevant params changed
Browse files Browse the repository at this point in the history
  • Loading branch information
rtabbara authored and njroussel committed Aug 30, 2023
1 parent 5016304 commit 97d4b6a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/render/scene.cpp
Expand Up @@ -369,6 +369,10 @@ MI_VARIANT void Scene<Float, Spectrum>::parameters_changed(const std::vector<std
accel_parameters_changed_gpu();
else
accel_parameters_changed_cpu();

m_bbox = {};
for (auto &s : m_shapes)
m_bbox.expand(s->bbox());
}

// Check whether any shape parameters have gradient tracking enabled
Expand Down
18 changes: 18 additions & 0 deletions src/render/tests/test_scene.py
Expand Up @@ -246,3 +246,21 @@ def test09_test_emitter_sampling_weight_update(variants_all_backends_once):
assert dr.allclose(scene.pdf_emitter(0), pdf[0])
assert dr.allclose(scene.pdf_emitter(1), pdf[1])
assert dr.allclose(scene.pdf_emitter(2), pdf[2])


def test10_test_scene_bbox_update(variant_scalar_rgb):
scene = mi.load_dict({
'type': 'scene',
"sphere" : {
"type" : "sphere"
}
})

bbox = scene.bbox()
params = mi.traverse(scene)
offset = [-1, -1, -1]
params['sphere.to_world'] = mi.Transform4f.translate(offset)
params.update()

expected = mi.BoundingBox3f(bbox.min + offset, bbox.max + offset)
assert expected == scene.bbox()

0 comments on commit 97d4b6a

Please sign in to comment.