code cleanup in new suspension damping

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2804 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2008-12-28 20:17:34 +00:00
parent b1698e2cc5
commit 586a4a3a84
2 changed files with 13 additions and 7 deletions

View File

@ -38,8 +38,10 @@ KartModel::KartModel()
m_wheel_physics_position[i] = Vec3(UNDEFINED);
m_wheel_graphics_radius[i] = 0.0f; // for kart without separate wheels
m_wheel_model[i] = NULL;
m_min_suspension[i] = -99.9f;
m_max_suspension[i] = 99.9f;
// default value for kart suspensions. move to config file later if we find each kart needs custom values
m_min_suspension[i] = -1.3;
m_max_suspension[i] = 1.3;
m_dampen_suspension_amplitude[i] = 2.5f;
}
m_wheel_filename[0] = "wheel-front-right.ac";
m_wheel_filename[1] = "wheel-front-left.ac";
@ -227,11 +229,11 @@ void KartModel::adjustWheels(float rotation, float steer,
// the graphical wheel models don't look too wrong.
for(unsigned int i=0; i<4; i++)
{
m_min_suspension[i] = -1.3; // FIXME - why are these still not inited at this point?
m_max_suspension[i] = 1.3;
const float suspension_length = (m_max_suspension[i]-m_min_suspension[i])/2;
clamped_suspension[i] = std::min(std::max(suspension[i]/2.5f, // somewhat arbitrary constant to reduce visible wheel movement
// limit amplitude between set limits, first dividing it by a
// somewhat arbitrary constant to reduce visible wheel movement
clamped_suspension[i] = std::min(std::max(suspension[i]/m_dampen_suspension_amplitude[i],
m_min_suspension[i]),
m_max_suspension[i]);
float ratio = clamped_suspension[i] / suspension_length;

View File

@ -70,6 +70,10 @@ private:
* any longer, the wheel would look too far away from the chassis. */
float m_max_suspension[4];
/** value used to divide the visual movement of wheels (because the actual movement
of wheels in bullet is too large and looks strange). 1=no change, 2=half the amplitude */
float m_dampen_suspension_amplitude[4];
/** The transform for the wheels, used to rotate the wheels and display
* the suspension in the race. */
ssgTransform *m_wheel_transform[4];
@ -80,8 +84,8 @@ private:
float m_z_offset; /**< Models are usually not at z=0 (due
* to the wheels), so this value moves
* the karts down appropriately. */
void loadWheelInfo(const lisp::Lisp* const lisp,
const std::string &wheel_name, int index);
void loadWheelInfo(const lisp::Lisp* const lisp,
const std::string &wheel_name, int index);
public:
KartModel();