redpawfx/partio — pull request #21 by mattebb (2013-01-04 07:32:11+00:00)
Title: NumPy integration: Added getArray() and setArray() python API methods 

This adds two new methods to the python API to retrieve and set particle attribute data with NumPy arrays. Not only is it much, much faster than iterating over each particle with get(), but it's more memory efficient too, especially if the intended destination for the particles is a NumPy array.

I've been using this for a point cloud/particle system viewer I've made* using pyglet for OpenGL drawing. Using this addion, in my app, memory for the NumPy array is allocated once in the partio API, and passed directly through to an OpenGL vertex buffer object, with no additional copying. Load time is similar (just a little bit slower) to the builtin partview C++ demo app, which is not bad for python!

I've added in NumPy support to the cmake build system, which seems to work fine here on CentOS 6.2, but don't know about any other OSes yet.

cheers!

* http://www.pasteall.org/pic/show.php?id=42968