Try to reduce likelihood of karts 'driving' over a fence (by

collisions that pushes them with away with an upwards component
in the impulse vector).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12528 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2013-02-26 06:05:50 +00:00
parent c18ccef5b3
commit bf21f7e857

View File

@@ -1600,7 +1600,13 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
==KartProperties::IMPULSE_NORMAL &&
m_vehicle->getCentralImpulseTime()<=0 )
{
Vec3 impulse = normal;
// Restrict impule to plane defined by gravity (i.e. X/Z plane).
// This avoids the problem that karts can be pushed up, e.g. above
// a fence.
btVector3 gravity = m_body->getGravity();
gravity.normalize();
// Cast necessary since otherwise to operator- (vec3/btvector) exists
Vec3 impulse = (btVector3)normal - gravity* btDot(normal, gravity);
if(impulse.getX() || impulse.getZ())
impulse.normalize();
else