|
在使用Drive漫游器的时候发现水平路面没问题,但是有些坡爬不上去,好像碰到障碍物卡到了,坡路面是光滑倾斜的,计算碰撞代码:
if (fabs(_velocity*dt)>1e-8)
{
double distanceToMove = _velocity*dt;
double signedBuffer;
if (distanceToMove>=0.0) signedBuffer=_buffer;
else signedBuffer=-_buffer;
osg::Vec3d ip, np;
if (intersect(_eye,_eye+lv*(signedBuffer+distanceToMove), ip, np))
{
if (distanceToMove>=0.0)
{
distanceToMove = (ip-_eye).length()-_buffer;
}
else
{
distanceToMove = _buffer-(ip-_eye).length();
}
_velocity = 0.0;
}
osg::Vec3d fp = _eye + lv*distanceToMove;
osg::Vec3d lfp = fp - up*(_height*5.0);
if (intersect(lfp, fp, ip, np))
{
if (up*np>0.0) up = np;
else up = -np;
_eye = ip+up*_height;
lv = up^sv;
computePosition(_eye,_eye+lv,up);
return true;
}
osg::Vec3d dp = lfp;
dp -= getUpVector(cf)* (2.0*_modelScale);
if (intersect(dp,lfp, ip, np))
{
if (up*np>0.0) up = np;
else up = -np;
_eye = ip+up*_height;
lv = up^sv;
computePosition(_eye,_eye+lv,up);
return true;
}
lv *= (_velocity*dt);
_eye += lv;
}
是我的height设置不够吗,我设置的是1000.0。
该怎么解决这个问题,谢谢了! |
|