在花栗鼠物理中从关节中移除物体

发布于 2024-09-28 16:55:15 字数 108 浏览 0 评论 0原文

在 Box2D 中,当连接到关节的主体从空间中移除时,关节会自动删除,您可以在回调等中执行操作。

花栗鼠会这样做吗?如果是这样,我如何检测联合连接何时“断开”?我必须手动跟踪这些东西吗?

In Box2D, when a body that is connected to a joint is removed from the space, the joint is automatically deleted and you can do stuff in callbacks and so on.

Does Chipmunk do this? If so, how can I detect when a joint connection is 'broken'? Do I have to keep track of this stuff manually?

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

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

发布评论

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

评论(1

青巷忧颜 2024-10-05 16:55:15

我不确定你所说的检测关节何时断裂是什么意思。我不相信花栗鼠会在模拟过程中弄断关节。如果由于尸体被毁而导致关节断裂,清理时要小心。来自 Chipmunk 的文档页面:

小心,在附加到物体的任何形状或约束从空间中移除之前,不要释放物体。

使用 cpSpaceRemoveConstraint 它将把它从两个物体上移除。然后使用 cpConstraintFree 释放约束内存。

I'm not sure what you mean by detecting when a joint is broken. I don't believe Chipmunk breaks joints as part of the simulation. If the joint is broken because a body has been destroyed be careful on cleanup. From the documentation page for Chipmunk:

Be careful not to free a body before any shapes or constraints attached to it have been removed from a space.

Use cpSpaceRemoveConstraint and it will remove it from both bodies. Then free the constraint memory using cpConstraintFree.

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