BoxCollider、SphereCollider、CapsuleCollider的性能对比
概述
我决定放一些测试数据上来。
Well I decided to post some results from some testing.
所有测试均完成于INTEL二核的3GH处理器,无渲染部分,仅仅是物理部分。
All tests were done on an intel core2duo 3ghz imac with no rendering, just physics.
静态碰撞体几乎没有什么性能开销,高达6万多个不同的碰撞体对性能的影响在一帧之内(<3ms)几乎可以让人忽略不算。
Static colliders seem to have such a minimal impact on performance, Upto 60,000 and beyond of all different colliders were causing no noticable effect on the frame time (<3ms)
所以我尝试去测试动态碰撞体,这会更加有挑战性。
So I tried testing dynamic colliders instead, much more challenging.
要记住这只是物理部分,你的渲染部分的瓶颈只能达到2500个独立模型物体。
Remember this is just physics, your renderer would bottleneck way before reaching 2500 individual objects.
数据
Collider Count | 500 | 1000 | 1500 | 2500 | Unit |
---|---|---|---|---|---|
Capsule | 2.1 | 5.6 | 16.1 | 459-481 | ms |
Box | 2.6 | 5.8 | 20.5 | 490-520 | |
Sphere | 2 | 2.9 | 4.8 | 190-233 |
结论
看到了吧?通过这些数据,我们能发现,capsule collider性能要稍稍优越于 box collider ,但是sphere collider的性能明显要甩掉所有人九条街。
So there you have it, across the board capsule actually beats box but not by a huge amount, and sphere obviously kicks everyones ass.