Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapping with Pybind11 #21

Open
munkybutt opened this issue May 5, 2021 · 0 comments
Open

Wrapping with Pybind11 #21

munkybutt opened this issue May 5, 2021 · 0 comments

Comments

@munkybutt
Copy link

munkybutt commented May 5, 2021

Hey - I saw this project on tech artists and thought it was super nifty.
I am a big fan of the agnostic backend, really nice to see thoughts of DCCs other than Maya - so I figured I would try and integrate this into Blender.

As blender doesn't expose a c++ sdk, I have to expose it via python. I thought this was annoying at first but then realised that it could make integration to any other DCC that uses python easier, potentially avoiding the need for c++ integration all together.

I am using Pybind11 to do the bindings and my current thought is to use numpy arrays as the object types for the point, vector, quat and array template classes, this should be beneficial in a couple of ways:

  • Pybind11 exposes numpy arrays to c++, allowing them to be used like native arrays so no need for any extra conversion steps on c++ side.
  • Standardised types coming from any python environment, no need to write and expose custom classes per DCC.
  • Easier to write any DCC specific adaptor code in python.
  • Numpy arrays are really fast and lightweight c objects especially vs python native types.

I have had one issue so far, with the template size function in TwistSpline.h which attempts to override a size function in the Pybind11 API. This raises a compile error so I have had to change the name to getSize to avoid the conflict.

This has let me get as far as wrapping TwistSpline and it's constructor and creating a python instance in blender ( which is pretty exciting ), but I am having issues when attempting to expose any of the methods which might require some tweaks - if you agree that using numpy is a sensible idea.

I could potentially extend TwistSpline and wrap said extended class if you would prefer not to accept any of the changes, but my c++ knowledge is relatively novice and extra abstraction is best avoided in most scenarios.

Let me know your thoughts!

Cheers,

Shea.

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

No branches or pull requests

1 participant