## [Supertuxkart-commit] SF.net SVN: supertuxkart:[6499] main/trunk/src/karts/kart.cpp

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[6499] main/trunk/src/karts/kart.cpp From: - 2010-11-11 01:28:16 ```Revision: 6499 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6499&view=rev Author: auria Date: 2010-11-11 01:28:09 +0000 (Thu, 11 Nov 2010) Log Message: ----------- Use Joerg's Nice Formula to determine the amount of 'vertical slipperinness' to apply - quite more elegant than my approximation. hacienda shortcut still impossible to take, but I tweaked it so that we keep friction of mild slopes Modified Paths: -------------- main/trunk/src/karts/kart.cpp Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-11-11 01:03:15 UTC (rev 6498) +++ main/trunk/src/karts/kart.cpp 2010-11-11 01:28:09 UTC (rev 6499) @@ -1358,18 +1358,24 @@ float friction = 1.0f; if (isOnGround()) { - float pitch = fabs(getPitch()); - float roll = fabsf(getRoll()); - if (pitch > 0.25f) + const btMatrix3x3 &m = m_vehicle->getChassisWorldTransform().getBasis(); + // To get the angle between up=(0,1,0), we have to do: + // m*(0,1,0) to get the up vector of the kart, then the + // scalar product between this and (0,1,0) - which is m[1][1]: + float distanceFromUp = m[1][1]; + + if (distanceFromUp < 0.85f) { - float x = std::min((pitch - 0.25f) / 0.25f, 1.0f); - friction = std::min( friction, 1.0f - x*x ); + friction = 0.0f; } - if (roll > 0.25f) + else if (distanceFromUp > 0.9f) { - float x = std::min((roll - 0.25f) / 0.25f, 1.0f); - friction = std::min( friction, 1.0f - x*x ); + friction = 1.0f; } + else + { + friction = (distanceFromUp - 0.85f) / 0.5f; + } } for (unsigned int i=0; i<4; i++) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```