Fix a bug where the kart's wheels would intersect with the road when rescued to an upside location.

This commit is contained in:
nixt 2014-07-03 17:24:04 +05:30
parent 184e45bb6d
commit 437f8191f4
2 changed files with 3 additions and 2 deletions

View File

@ -715,7 +715,7 @@ void World::moveKartTo(AbstractKart* kart, const btTransform &transform)
btQuaternion rot = pos.getRotation();
// Move the kart
Vec3 xyz = pos.getOrigin() + btVector3(0, 0.55f*kart->getKartHeight(),0.0f).
Vec3 xyz = pos.getOrigin() + btVector3(0, 0.5f*kart->getKartHeight(),0.0f).
rotate(rot.getAxis(),rot.getAngle());
pos.setOrigin(xyz);

View File

@ -2431,6 +2431,7 @@ bool Track::findGround(AbstractKart *kart)
btTransform t = kart->getBody()->getCenterOfMassTransform();
btQuaternion q = t.getRotation();
// The computer offset is slightly too large, it should take
// the default suspension rest insteat of suspension rest (i.e. the
// length of the suspension with the weight of the kart resting on
@ -2438,7 +2439,7 @@ bool Track::findGround(AbstractKart *kart)
// - so I'll leave it in for now.
float offset = kart->getKartProperties()->getSuspensionRest() +
kart->getKartProperties()->getWheelRadius();
t.setOrigin(hit_point+Vec3(0, offset, 0) );
t.setOrigin(hit_point+ (btVector3(0, offset, 0).rotate(q.getAxis(),q.getAngle()) ) );
kart->getBody()->setCenterOfMassTransform(t);
kart->setTrans(t);