What causes the joints of a physics engine to tear?

ぐ巨炮叔叔 提交于 2019-12-12 01:54:04

问题


I will keep this brief, know that what I am talking about happened on Box2d for AS3 in 2009, and it also happens today with a totally separate library p2 physics in JavaScript.

Please go to the following 2d ragdoll demo page and spin the ragdoll around by the head quite vigorously.

https://schteppe.github.io/p2.js/demos/ragdoll.html

You will see the result that the joints separate and turn elastic.

This problem prevents me making anything fun with physics. Ball and chains, catapults, forklifts, ragdolls, spiderman shooting webs, 2d vehicles.....

Contraints just seem unstable as to be superfluous. I am thinking that a physics engine is good for say angry birds, or falling blocks, but the moment you add Constraints, the project turns into Demo fit for breakage.

Can you explain why this happens? Am I being Naive? Does a physics engine exist to provide the bare bones bodies and constraints? It is upto me as a developer, to apply the math to make constraints work correctly?


回答1:


Physics engine joints (constraints) can be thought of as springs that apply force. A spring is not rock solid - it will bend if you push it too hard.

The "softness" of the joints is often proportional to the performance of the physics engine. If you use tiny time steps and many constraint iterations, you can get very stiff joints, but poor performance. If you force the physics engine to make the joints stiff, but use a larger time step, the simulation will become unstable and probably explode.

Joints will always have some "softness". You can not rely on joints to look rock solid at all times and under all circumstances. As a developer of a physics-based game, you must restrict the player to not break your physics. This can be done in many ways, for example by setting a limit on the maximum force applied by the player, or by removing some player interactions.

In the game "Bad Piggies", Rovio use constraints quite a lot - but they also put limits on the way the user can interact too.

a physics engine is good for say angry birds, or falling blocks, but the moment you add Constraints, the project turns into Demo fit for breakage.

Not quite true. "Falling blocks" that collide will create contacts - which are constraints too (internally in the physics engine). If you push the contacts too hard, or by applying too much gravity, the contacts will look springy too. That's why games like Angry Birds use weak gravity fields.

Making a physics based game where the user experiences freedom without limiting the way the user interacts is difficult - but not impossible.



来源:https://stackoverflow.com/questions/27374145/what-causes-the-joints-of-a-physics-engine-to-tear

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!