Skip to content

VDBObject bindings : Adapt for OpenVDB 12#1531

Open
murraystevenson wants to merge 3 commits intoImageEngine:mainfrom
murraystevenson:nanobindConverter
Open

VDBObject bindings : Adapt for OpenVDB 12#1531
murraystevenson wants to merge 3 commits intoImageEngine:mainfrom
murraystevenson:nanobindConverter

Conversation

@murraystevenson
Copy link
Copy Markdown
Collaborator

OpenVDB 12 switched from PyBind11 to Nanobind for its bindings, so VDBObject needs another update to support the change. Rather than maintain three sets of bindings, I've gone ahead and removed the Boost bindings required for OpenVDB <= 10.0 in the last commit, but this could be dropped if there's a compelling argument for keeping it...

This should unlock the final part of the VFX Platform 2025 update.

This ends up quite similar to the existing PyBindConverter class, but the trick is the need to initialise the nanobind internals before use.

Nanobind keeps a type registry that is initialised by the `NB_MODULE` macro which expands to include a call to `nanobind::detail::nb_module_exec()` which performs the initialisation. As the point of our converter is to call `nanobind::cast()` from within a `BOOST_PYTHON_MODULE` rather than a `NB_MODULE`, we first have to manually call `nanobind::detail::nb_module_exec()` ourselves to ensure the nanobind internals are initialised before we attempt to cast. Otherwise nanobind::cast() will attempt to look up into an invalid or null type registry and crash.

It's a little unfortunate to be calling into `nanobind::detail`, but there appears to be no other way of doing this...
OpenVDB 12 switched from PyBind11 to Nanobind for its bindings, so we now provide three different ways of binding...
@murraystevenson murraystevenson self-assigned this May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant