使用box2d时速度是否有上限? [英] Is there an upper limit on velocity when using box2d?

查看:150
本文介绍了使用box2d时速度是否有上限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用box2d进行物理模拟.每当按下键时,都会在身体上施加脉冲,从而使用箭头键移动圆圈.不幸的是,圆环的移动速度极慢,似乎并没有像真实的身体那样加速. 我的世界尺寸为400x800像素.圆体的半径为20f.

I'm using box2d for physics simulation. I'm moving a circle using arrow keys by applying impulse on the body when ever a key is pressed. Unfortunately, the circle moves excruciatingly slow and doesn't seem to accelerate like a true physical body is supposed to. My world's dimensions are 400x800 pixels. The radius of the circle body is 20f.

根据,可以通过减小圆半径来解决问题创建它并在绘画过程中获得身体位置后按比例放大.它似乎根本没有任何区别.有什么步骤或设置我在这里不见了吗?

According to this, the problem can be solved by scaling the circle radius down when creating it and scaling up after getting the body position during painting. It doesn't seem to make any difference at all. Is there some step or setting I'm missing here ?

pastebin上的代码

推荐答案

我花了很长时间才了解这一点,但实际上Box2D中确实对速度进行了 IS 硬限制.请参见此处:

It took me pretty long to understand that now, but there actually really IS a hard limit on velocity in Box2D. See here:

源代码中的文件b2Settings.h中给出了每个时间步长的最大移动限制为2.0个单位.

There is a maximum movement limit of 2.0 units per time step, given in the file b2Settings.h in the source code.

如果每帧以60FPS速度迈出一步,那么您的身体可以以120m/s的最大速度运动.也许有一天可以节省一些时间.

If you have one step per frame at 60FPS, then your bodies can move at a maximum speed of 120m/s. Maybe this will save somebody a bit of time one day.

这篇关于使用box2d时速度是否有上限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆