NumPy integration: Added getArray() and setArray() python API methods #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!