Box2D 中大型静态边缘地形的性能问题
我想在我正在制作的游戏中支持非常大的世界。这通常不是问题,因为我可以剔除世界的大部分,因为它不是一次性可见的。然而,Box2D 似乎不喜欢我的想法!
我的地形目前由大约 1000 个边缘形状组成。然而,仅此一项似乎就可以正常工作: 即使我只添加了一些(~25)动态对象(小圆圈),性能也会急剧下降!
- 为什么会出现这种情况,动态 树应该取消所有未受影响的 静态地形很早就形成了 没有表现惩罚, 不应该吗?
- (如何)我可以解决这个问题吗?
I'd like to support very large worlds in the game that I'm making. This is not a problem usually, because I can cull most of the world as it is not visible all at once. However, Box2D doesn't seem to like my idea!
My terrain currently consists of about 1000 edge shapes. This alone seems to work fine, however:
Even after I add only a few (~25) dynamic objects (small circles), the performance is decreasing dramatically!
- Why does this happen, the dynamic
tree should cancel out all unaffected
static terrain shapes very early and
without performance penalties,
shouldn't it? - (How) can I work around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是因为边缘形状不会与其他边缘形状发生碰撞。
从手册:
因此,即使您有许多边缘形状,由于它们不会相互碰撞,您也不会看到性能下降。添加一些对象后,box2d 就会开始检查碰撞。
The answer is because edge shapes do not collide with other edge shapes.
From the manual:
So even though you have many edge shapes, as they do not collide with each other, you aren't seeing a performance drop. Once you add some objects, then box2d starts checking for collisions.