如何删除box2d maxVelocity?
我不知道 box2D 中是否有这样的参数,但是当我复制场景模拟中的所有数字时会产生不同的结果,我只是模拟一个摆(使用旋转关节将静态盒关节连接到动态盒)并且当我将场景中的所有值乘以 32(与我的游戏具有相同的比例)时,它的下落速度比正常情况慢(并且我也增加了重力)。看起来当钟摆下落时它会达到某个最大速度并且不会超过该速度。因此,当它返回时,它会达到开始坠落高度的一半。顺便说一句,我认为这不是由摩擦引起的,因为我已将所有倾倒和摩擦值设置为零,而且在缩放场景之前这个问题并未出现。
I don't know if there is such a parameter in box2D or not but when I duplicate all the numbers in my scene simulations produce different results, I was just simulating a pendulum (an static box joint to a dynamic box using revolute joint) and when I multiplied all the values in my scene by 32 (to have a same scale with my game), it fall slower than normal condition, (and i've increased gravity too). it seems like when pendulum is falling it reaches some max speed and doesn't go beyond that. so when it's comming back up it reaches half way to the height it started falling from. by the way I think it's not cause by friction because i've set all dumping and friction values to zero and beside this problem didn't apear before scaling my scene.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更改 b2Settings.h 中 b2_maxTranslation 的值
Change the value of b2_maxTranslation in b2Settings.h
Box2d 正在使用迭代求解器进行模拟,对于不同大小的对象,结果可能会有所不同 - 没关系。手册中写道,模拟动态物体的最佳尺寸为 0.1 - 10,静态物体的最佳尺寸为 50。此外,增加所有尺寸不会在现实世界中产生相同的运动。例如,想象一个半径为 1 米的球体从 100 米高处落下。例如,将其半径和高度乘以 10 显然会给出不同的下落时间,因为它仅取决于高度。
我也尝试过 nvidia physx 一次。我刚刚创建了一个非常简单的场景 - 一个立方体落在平面上并弹跳。立方体边长一米。首先,我用立方体 10 的密度进行模拟,一切都很完美。然后我决定模拟一个铁立方体并将密度更改为 7200。正如您所知,弹跳预期完全相同,因为恢复参数没有改变。但模拟真的很丑陋——立方体落入平面并弹起丑陋。因此,将这些值保持在推荐范围内非常重要。
Box2d is simulating using iterative solver and the result might be different for different size of objects - it's ok. In manual is written that the best size of simulated dynamic objects is 0.1 - 10 and up 50 for static bodies. Also increasing all sizes will not produce the same movement in a real world. For example imagine a 1 meter radius falling sphere from 100 meter height. Multiplying it's radius and height by 10 for example will obviously give different fall time, because it's only depend on height.
Also I've tried nvidia physx once. I've just created a very simple scene - a cube falling at the plane and bouncing. The cube was one meter at a side. First I was simulating with density of cube 10 and everything was perfect. Then i decided to simulate an iron cube and changed the density to 7200. As you understand the bounce was expected totally the same because the restitution parameter was not change. But the simulation was really ugly - the cube falling into the plane and bouncing ugly. So it's really important to keep the values in a recommended range.