Added support to modify the angular factor of a kart. The angular
factor can be used to reduce the effect of an impulse for roll and pitch - keeping karts more parallel to the ground.
This commit is contained in:
parent
f55c39b3b1
commit
b8655e53cc
@ -45,6 +45,9 @@
|
||||
the ground if its off ground. Reduces the affect if a kart loses
|
||||
contact with the ground (i.e. it then can't steer or accelerate
|
||||
anymore).
|
||||
angular-factor: Factor to change angular impulses. X and Z rotations
|
||||
are damped to avoid that karts in a collision are too easily pushed
|
||||
into a roll or pitch, which makes them topple over
|
||||
smooth-flying-impulse: apply a torque impulse to flying kart to keep
|
||||
them parallel to the ground. -->
|
||||
<stability roll-influence="0.3"
|
||||
@ -52,6 +55,7 @@
|
||||
chassis-angular-damping="0"
|
||||
downward-impulse-factor="5"
|
||||
track-connection-accel="2"
|
||||
angular-factor="1.0 1.0 1.0"
|
||||
smooth-flying-impulse="250" />
|
||||
|
||||
<!-- Turning
|
||||
|
@ -74,6 +74,8 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(
|
||||
return TYPE_FLOAT;
|
||||
case STABILITY_TRACK_CONNECTION_ACCEL:
|
||||
return TYPE_FLOAT;
|
||||
case STABILITY_ANGULAR_FACTOR:
|
||||
return TYPE_FLOAT_VECTOR;
|
||||
case STABILITY_SMOOTH_FLYING_IMPULSE:
|
||||
return TYPE_FLOAT;
|
||||
case TURN_RADIUS:
|
||||
@ -304,6 +306,8 @@ std::string AbstractCharacteristic::getName(CharacteristicType type)
|
||||
return "STABILITY_DOWNWARD_IMPULSE_FACTOR";
|
||||
case STABILITY_TRACK_CONNECTION_ACCEL:
|
||||
return "STABILITY_TRACK_CONNECTION_ACCEL";
|
||||
case STABILITY_ANGULAR_FACTOR:
|
||||
return "STABILITY_ANGULAR_FACTOR";
|
||||
case STABILITY_SMOOTH_FLYING_IMPULSE:
|
||||
return "STABILITY_SMOOTH_FLYING_IMPULSE";
|
||||
case TURN_RADIUS:
|
||||
@ -626,6 +630,18 @@ float AbstractCharacteristic::getStabilityTrackConnectionAccel() const
|
||||
return result;
|
||||
} // getStabilityTrackConnectionAccel
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
std::vector<float> AbstractCharacteristic::getStabilityAngularFactor() const
|
||||
{
|
||||
std::vector<float> result;
|
||||
bool is_set = false;
|
||||
process(STABILITY_ANGULAR_FACTOR, &result, &is_set);
|
||||
if (!is_set)
|
||||
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s",
|
||||
getName(STABILITY_ANGULAR_FACTOR).c_str());
|
||||
return result;
|
||||
} // getStabilityAngularFactor
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float AbstractCharacteristic::getStabilitySmoothFlyingImpulse() const
|
||||
{
|
||||
@ -1006,7 +1022,7 @@ float AbstractCharacteristic::getFrictionKartFriction() const
|
||||
process(FRICTION_KART_FRICTION, &result, &is_set);
|
||||
if (!is_set)
|
||||
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s",
|
||||
getName(FRICTION_KART_FRICTION).c_str());
|
||||
getName(FRICTION_KART_FRICTION).c_str());
|
||||
return result;
|
||||
} // getFrictionKartFriction
|
||||
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
STABILITY_CHASSIS_ANGULAR_DAMPING,
|
||||
STABILITY_DOWNWARD_IMPULSE_FACTOR,
|
||||
STABILITY_TRACK_CONNECTION_ACCEL,
|
||||
STABILITY_ANGULAR_FACTOR,
|
||||
STABILITY_SMOOTH_FLYING_IMPULSE,
|
||||
|
||||
// Turn
|
||||
@ -269,6 +270,7 @@ public:
|
||||
float getStabilityChassisAngularDamping() const;
|
||||
float getStabilityDownwardImpulseFactor() const;
|
||||
float getStabilityTrackConnectionAccel() const;
|
||||
std::vector<float> getStabilityAngularFactor() const;
|
||||
float getStabilitySmoothFlyingImpulse() const;
|
||||
|
||||
InterpolationArray getTurnRadius() const;
|
||||
|
@ -668,6 +668,10 @@ void Kart::createPhysics()
|
||||
trans.setIdentity();
|
||||
createBody(mass, trans, &m_kart_chassis,
|
||||
m_kart_properties->getRestitution());
|
||||
std::vector<float> ang_fact = m_kart_properties->getStabilityAngularFactor();
|
||||
// The angular factor (with X and Z values <1) helps to keep the kart
|
||||
// upright, especially in case of a collision.
|
||||
m_body->setAngularFactor(Vec3(ang_fact[0], ang_fact[1], ang_fact[2]));
|
||||
m_body->setFriction(m_kart_properties->getFrictionKartFriction());
|
||||
m_user_pointer.set(this);
|
||||
m_body->setDamping(m_kart_properties->getStabilityChassisLinearDamping(),
|
||||
|
@ -597,6 +597,12 @@ float KartProperties::getStabilityTrackConnectionAccel() const
|
||||
return m_cached_characteristic->getStabilityTrackConnectionAccel();
|
||||
} // getStabilityTrackConnectionAccel
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
std::vector<float> KartProperties::getStabilityAngularFactor() const
|
||||
{
|
||||
return m_cached_characteristic->getStabilityAngularFactor();
|
||||
} // getStabilityAngularFactor
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getStabilitySmoothFlyingImpulse() const
|
||||
{
|
||||
|
@ -431,6 +431,7 @@ public:
|
||||
float getStabilityChassisAngularDamping() const;
|
||||
float getStabilityDownwardImpulseFactor() const;
|
||||
float getStabilityTrackConnectionAccel() const;
|
||||
std::vector<float> getStabilityAngularFactor() const;
|
||||
float getStabilitySmoothFlyingImpulse() const;
|
||||
|
||||
InterpolationArray getTurnRadius() const;
|
||||
|
@ -343,6 +343,8 @@ void XmlCharacteristic::load(const XMLNode *node)
|
||||
&m_values[STABILITY_DOWNWARD_IMPULSE_FACTOR]);
|
||||
sub_node->get("track-connection-accel",
|
||||
&m_values[STABILITY_TRACK_CONNECTION_ACCEL]);
|
||||
sub_node->get("angular-factor",
|
||||
&m_values[STABILITY_ANGULAR_FACTOR]);
|
||||
sub_node->get("smooth-flying-impulse",
|
||||
&m_values[STABILITY_SMOOTH_FLYING_IMPULSE]);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import sys
|
||||
# Each line contains a topic and the attributes of that topic.
|
||||
# This model is used for the xml file and to access the kart properties in the code.
|
||||
characteristics = """Suspension: stiffness, rest, travel, expSpringResponse(bool), maxForce
|
||||
Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, smoothFlyingImpulse
|
||||
Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, angularFactor(std::vector<float>/floatVector), smoothFlyingImpulse
|
||||
Turn: radius(InterpolationArray), timeResetSteer, timeFullSteer(InterpolationArray)
|
||||
Engine: power, maxSpeed, brakeFactor, brakeTimeIncrease, maxSpeedReverseRatio
|
||||
Gear: switchRatio(std::vector<float>/floatVector), powerIncrease(std::vector<float>/floatVector)
|
||||
|
Loading…
Reference in New Issue
Block a user