Question

I'm devloping some library classes for flocking/steering behaviours on large numbers of objects (2000+). I'm finding that at < 500 instances, performance is reasonable. As the numbers increase, framerate bogs down.

I've seen remarkable performance with libraries such as Flint or Box2D with ridiculous #'s of particles / objects, so it should be possible to optimize / refactor my code to be a bit better.

I'm aware of the basic optimizations, such as bitwise operations and optimized for loops. Are there any more fundamental approaches I should be considering? For example, currently each instance is a vector-based MovieClip. Would working with BitmapData be more efficient?

Was it helpful?

Solution

forget about vectors.

cache them as bitmapdata and draw to a bitmap, or draw a bitmapfilled rect to graphics.

dont use vectors. find a way around it. be clever. bitmap lookup tables, caching, more lookup tables. spend RAM on caching things for different orientations, views, frames, etc, rather than spending PROCESSOR on wasteful cpu cycles.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top