I’m looking for the fastest way to copy pixels generated on C++ side to Python. What I’m doing now is:
- generate pixels in c++
- copy them to boost::python::list
- assign it in python to layer.rect
Even when I create empty list, pass it to c++ via reference, fill it, then assign it to layer.rect, assigning alone takes around 30-40ms on my pc. My first thought was to pass layer.rect by reference and fill it on c++ side, but python throws error as bpy_array_list doesnt match boost::python::list (thought it indeed is list since I’m assigning list of pixels anyway…).
Ideal solution would be getting pointer to array of pixels (array of rgba), pass to c++ and fill it, but afaik python lists are different than c++ arrays, and layer.rect isn’t list anyway. This would be ideal because copying pixels would be just one call to glReadPixels or Vulkan equivalent, done.
So, how to do it better? Is there any working C/C++ api for blender plugins? Or it could be done with Python?
Already found this: https://wiki.blender.org/index.php/Dev:2.8/Source/Viewport/EngineAPI but it’s not well documented, maybe I should check Cycles or Eevee sources.
Thanks in advance.