Make the physics settings configurable, but default to use the old

settings for now.
This commit is contained in:
hiker 2014-08-16 10:20:24 +10:00
parent 6d5651f357
commit 8c525ab2d4
4 changed files with 26 additions and 8 deletions

View File

@ -415,11 +415,14 @@
physical-wheel-position: Defines where the 'physical' (raycast)
wheel will be located. It's a weight factor with 0 = being
at the widest side of the bevel, 1 = at the front and
narrowest part of the kart. -->
narrowest part of the kart. If the value is less than 0, the old
physics settings are used which places the raycast wheels
outside of the chassis and results in more stable physical
behaviour of the karts. -->
<collision impulse-type="normal"
impulse="3000" impulse-time="0.1" terrain-impulse="8000"
restitution="1.0" bevel-factor="0.5 0.0 0.7"
physical-wheel-position="0.5" />
physical-wheel-position="-1" />
<!-- If a kart starts within the specified time after 'go',
it receives the corresponding bonus from 'boost'. Those

View File

@ -606,7 +606,10 @@ void Kart::createPhysics()
if (y == -1)
{
int index = (x + 1) / 2 + 1 - z; // get index of wheel
if(true)
float f = getKartProperties()->getPhysicalWheelPosition();
// f < 0 indicates to use the old physics position, i.e.
// to place the wheels outside of the chassis
if(f<0)
{
const Vec3 cs = getKartProperties()->getGravityCenterShift();
wheel_pos[index].setX(x*0.5f*getKartWidth()+cs.getX());
@ -621,7 +624,6 @@ void Kart::createPhysics()
}
else
{
float f = getKartProperties()->getPhysicalWheelPosition();
wheel_pos[index] = p*(orig_factor*(1.0f - f) + bevel_factor*f);
wheel_pos[index].setY(0);
}

View File

@ -272,8 +272,15 @@ void KartProperties::load(const std::string &filename, const std::string &node)
m_gravity_center_shift.setZ(0);
}
//FIXME: magix 0.25 factor to keep it compatible with previous tourning
m_wheel_base = fabsf( m_kart_model->getLength() - (true ? 0 : -0.25f));
if(m_physical_wheel_position < 0)
m_wheel_base = fabsf(m_kart_model->getLength() );
else
{
// The new (atm unused) physical position results in steering to be
// not sharp enough - therefore decrease the wheel base somewhat to
// approximate the behaviour of the old steering.
m_wheel_base = fabsf(m_kart_model->getLength() - 0.25f);
}
// Now convert the turn radius into turn angle:
for(unsigned int i=0; i<m_turn_angle_at_speed.size(); i++)

View File

@ -152,7 +152,11 @@ private:
/** The position of the physical wheel is a weighted average of the
* two ends of the beveled shape. This determines the weight: 0 =
* a the widest end, 1 = at the narrowest front end. */
* a the widest end, 1 = at the narrowest front end. If the value is
* < 0, the old physics settings are used which places the raycast
* wheels outside of the chassis - but result in a more stable
* physics behaviour (which is therefore atm still the default).
*/
float m_physical_wheel_position;
/** Time a kart is moved upwards after when it is rescued. */
@ -916,7 +920,9 @@ public:
// ------------------------------------------------------------------------
/** Returns position of the physical wheel is a weighted average of the
* two ends of the beveled shape. This determines the weight: 0 =
* a the widest end, 1 = at the narrowest, front end. */
* a the widest end, 1 = at the narrowest, front end. If the value is <0,
* the old physics position is picked, which placed the raycast wheels
* outside of the chassis, but gives more stable physics. */
const float getPhysicalWheelPosition() const
{
return m_physical_wheel_position;