_pos[i] = _cmpr[i] = 0;
_spring = 1;
_damp = 0;
- _sfric = 0.8;
- _dfric = 0.7;
+ _sfric = 0.8f;
+ _dfric = 0.7f;
_brake = 0;
_rot = 0;
_extension = 1;
+ _castering = false;
}
void Gear::setPosition(float* position)
_extension = Math::clamp(extension, 0, 1);
}
+void Gear::setCastering(bool c)
+{
+ _castering = c;
+}
+
void Gear::getPosition(float* out)
{
int i;
return _frac;
}
+bool Gear::getCastering()
+{
+ return _castering;
+}
+
void Gear::calcForce(RigidBody* body, float* v, float* rot, float* ground)
{
// Init the return values
_wow = (fmag - damp) * -Math::dot3(cmpr, ground);
Math::mul3(-_wow, ground, _force);
+ // Castering gear feel no force in the ground plane
+ if(_castering)
+ return;
+
// Wheels are funky. Split the velocity along the ground plane
// into rolling and skidding components. Assuming small angles,
// we generate "forward" and "left" unit vectors (the compression
float Gear::calcFriction(float wgt, float v)
{
- // How slow is stopped? 50 cm/second?
- const float STOP = 0.5;
- const float iSTOP = 1/STOP;
+ // How slow is stopped? 10 cm/second?
+ const float STOP = 0.1f;
+ const float iSTOP = 1.0f/STOP;
v = Math::abs(v);
if(v < STOP) return v*iSTOP * wgt * _sfric;
else return wgt * _dfric;