mitsuba-renderer / mitsuba3

Mitsuba 3: A Retargetable Forward and Inverse Renderer
https://www.mitsuba-renderer.org/
Other
2.1k stars 246 forks source link

SceneParameter: fix update parameters #1266

Closed rtabbara closed 3 months ago

rtabbara commented 3 months ago

For custom Python plugins that expose modifiable parameters, updating these values through the use of mi.traverse required the use of assign to enable updating of the underlying cpp data. i.e. we can propagate the modifications to the actual plugin parameters.

For this particular case, we instead rely on nanobind's nb::inst_replace_copy function to perform the same functionality.

The behaviour updating parameters of cpp plugins remains unchanged.

dvicini commented 3 months ago

Amazing - I was about to re-raise this. I tried the fix and it works for me.

It would be great to also add a unit test.

rtabbara commented 3 months ago

Good point! I've updated the test_util.py tests to check whether changes to params actual affect the corresponding plugin variables for both cpp plugins and custom Python plugins.

dvicini commented 3 months ago

Looks great!