更改 Farseer 物理引擎设置以提高性能

发布于 2024-12-18 11:32:27 字数 1001 浏览 3 评论 0原文

我已成功使用 Farseer 使用 XNA 开发了我的一款游戏。该游戏在 Windows 和 WP7 中运行起来就像一个魅力。我目前正在使用 MonotouchMonogame 将我的游戏移植到 IOS 中。我还成功地在通过 Monotouch 和 Monogame 移植的游戏的第一个版本中编译并使用了 Farseer。除了表演之外,一切都很好。游戏在 iPhone 设备上运行速度要慢得多。我做了一些代码调查,看来主要的瓶颈是 Farseer。当它必须管理超过 5-6 个带有单个固定装置的物体(圆圈)时,它会变得非常慢。

阅读文档时,我注意到要调整 Farseer,我可以更改设置静态类中的值:

性能

为了充分利用引擎,您应该尝试遵循以下准则:

启用睡眠 睡眠使你能够在世界上拥有大量的身体。它还可以提高发动机的稳定性,因为一堆物体中的小运动不会在堆栈中扩散。睡眠体的开销很小,因此建议启用它。

禁用 CCD 连续碰撞检测可以防止隧道传输,但会牺牲性能。如果隧道传输没有问题,则应完全禁用 CCD。

最大限度地减少位置和速度迭代的次数 大量的迭代使引擎更加稳定,但牺牲了性能。您应该调整这些值以适合您的游戏。

坏消息是,如果我更改该类的任何值,似乎什么也不会发生。我尝试按如下方式更改值:

EnableDiagnostics = false
VelocityIterations = 6
PositionIterations = 2
ContinuousPhysics = false

我也尝试使用较低的值,例如 VelocityIterations = 1 但似乎没有任何变化......

有人已经更改了 Settings 类值以提高性能?

I have sucessfully used Farseer to develop one of my game using XNA. The game runs like a charm in Windows and WP7. I'm currently working on porting my game in IOS using Monotouch and Monogame. I've sucessfully compiled and used Farseer also over the first version of my game ported over Monotouch and Monogame. All works fine except for performances. The game runs much more slower on the iPhone device. I did some code investigations and it seems that the major bottleneck is Farseer. It become really slow when it has to manage more then 5-6 bodies with a single fixture attached (circle).

Reading the documentation I noticed that to tune Farseer I could change values from the Setting static class:

Performance

In order to get the most out of the engine, you should try and follow the guidelines below:

Enable sleeping
Sleeping enables you to have large number of bodies in the world. It can also increase the stability of the engine since small movements in a stack of bodies don’t spread in the stack. A sleeping body has little overhead, so enabling it is recommended.

Disable CCD
Continuous Collision Detection prevents tunneling but at the cost of performance. If you don’t have problems with tunneling, you should disable CCD all together.

Minimize the number of position and velocity iterations
A high number of iterations makes the engine more stable at the cost of performance. You should tweak the values to fit your game.

The bad news is that if I change any value of that class, nothing seems to happen. I tried to change values as follow:

EnableDiagnostics = false
VelocityIterations = 6
PositionIterations = 2
ContinuousPhysics = false

I tried also with lower values like VelocityIterations = 1 but nothing seems to change....

Anyone have already changed Settings class values to improve performances?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风向决定发型 2024-12-25 11:32:27

好的,

我已经做到了。主要瓶颈与 Farseer 无关。一旦我解决了与我的“糟糕代码”相关的所有性能问题,像上面描述的那样调整 Farseer 就可以很好地获得 5-10% 的性能。

我的游戏是用 XNA 编写的,已成功移植到 iOS 和 Android,具有 monotouch 和 mono4android。

Ok,

I have managed this. The major bottlenek was not related to Farseer. Once I solved all performance issues related to my "bad code", tuning Farseer like described above works very well to gain 5-10% of performances.

My game is written in XNA, ported to iOS an Android with monotouch and mono4android sucessfully.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文