blurstudio / TwistSpline

A smoothly reparameterizing Bezier spline that also interpolates orientations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrapping with Pybind11

munkybutt opened this issue · comments

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.