ActionScript 3 优化 - 提高大量对象的性能
我正在开发一些库类,用于对大量对象(2000+)进行聚集/引导行为。我发现在< 500个实例,性能还算可以。随着数字的增加,帧速率会下降。
我已经看到 Flint 或 Box2D 等库的出色性能,其中包含大量粒子/对象,因此应该可以优化/重构我的代码,使其更好一些。
我了解基本的优化,例如按位运算和循环优化。我应该考虑任何更基本的方法吗?例如,当前每个实例都是一个基于矢量的MovieClip。使用 BitmapData 会更高效吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
忘记向量吧。
将它们缓存为位图数据并绘制位图,或将位图填充的矩形绘制为图形。
不要使用向量。找到解决办法。聪明一点。位图查找表、缓存、更多查找表。
花费 RAM 来缓存不同方向、视图、帧等的内容,而不是将 PROCESSOR 花费在浪费的 CPU 周期上。
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.