[Bf-python] a lesson from numpy

Stephen Guerin stephen.guerin at redfish.com
Thu Aug 30 23:58:14 CEST 2007


Wow, we'd really be interested in this line of development. We'd like to run
simulatations of at least 100,000 agents in our agent-based models and have
stumbled in Blender around 20k-40k agents when using dupliverts.

You can see some low-end visualizations of of our wildfire traffic evacuation
Blender renders at:
http://www.redfish.com/wildfire/trafficmovies/PalExtBarbirdseye2.mov and
http://www.redfish.com/wildfire/fromJosh/camera_moving2.mov
http://www.redfish.com/wildfire

As another example, here's a stadium evacuation simulation we did in Processing
but we'd love to pull it off in Blender in the future:
http://www.redfish.com/stadium/

The processing appletis at:
http://www.redfish.com/stadium/Stadium/applet/index.html

Also, any way that we could get large simulations going in the game engine would
be welcome.

-Steve

--- -. .   ..-. .. ... ....   - .-- ---   ..-. .. ... ....
Stephen.Guerin at Redfish.com
www.Redfish.com
624 Agua Fria Street, Santa Fe, NM 87501
mobile: (505)577-5828
office: Santa Fe, NM (505)995-0206 / London, UK +44 (0) 20 7993 4769


> -----Original Message-----
> From: Theo de Ridder [mailto:theo.de.ridder at planet.nl] 
> Sent: Thursday, August 30, 2007 2:03 PM
> To: bf-python at blender.org
> Subject: [Bf-python] a lesson from numpy
> 
> 
> Last couple of weeks I experimented with numpy to enable 
> scalable interactive animations of swarms. The current BPY is 
> not very suited for swarms.
> Manipulating large amounts of individual objects on frame 
> events is too slow, and more efficient techniques like 
> DupliVerts or ShapeKeys don't facilitate individual r/w access.
> And the getData() of keyblock is copying data in a very 
> clumsy and read-only way.
> 
> So I extended the Key.KeyBlock interface with getBuffer() 
> returning a r/w Python buffer wrapping without copying the 
> underlying keyverts. Then I could handle in numpy the 
> different aspects like positions, rotations, and scales of 
> all subjects as algebraic manipulation of multi-dimensional 
> index matrices without having any loop in Python !
> 
> I did not incorporate yet lost buffers, but I think that a 
> publish/subscribe of buffers for this is more flexible than 
> using tracking IDs and forced 1-1 relations (pybuffers do 
> have a slot to be made NULL when data is gone).
> Using the standard pybuffer protocol for wrapping any 
> contiguous memory-data is very simple, general, fast and 
> save, and removes the burden to do this specific for each 
> Blender type. Specifying types and strides can simply be 
> postponed to the Python level.
> 
> Conclusion: when scalability is an issue like in swarms one 
> should prefer direct adressable buffers to iterator for loops 
> and list/object conversions at a Python level. And numpy is 
> amazingly suitable to bring efficient manipulation of 
> low-level Blender data at an elegant mathematical level.
> 
> Theo
> 
> 




More information about the Bf-python mailing list