Increase the brake force the longer the brake key is pressed (before it

took ~1.6 seconds for a kart to stop, now 0.5; while hardly any change to
short brakes to slow down the kart a bit only). Also made the impulse to
keep karts parallel to the ground configurable.
This commit is contained in:
hiker 2014-08-06 07:52:02 +10:00
parent 1ba6537e37
commit 03160e3b7b
6 changed files with 54 additions and 14 deletions

View File

@ -373,12 +373,15 @@
track-connection-accel: An artificial force that pulls a wheel to
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). -->
anymore).
smooth-flying-impulse: apply a torque impulse to flying kart to keep
them parallel to the ground.-->
<stability roll-influence="0.3"
chassis-linear-damping="0.2"
chassis-angular-damping="0"
downward-impulse-factor="0"
track-connection-accel="2"/>
track-connection-accel="2"
smooth-flying-impulse="10"/>
<!-- collision
impulse-type: STK can apply an additional impulse in case of
@ -568,9 +571,14 @@
<!-- Speed and acceleration related values: power and max-speed (in m/s)
have 3 values, one for low, medium, and hard.
brake-factor: Value used when braking. max-speed-reverse-ratio is
the percentage of max speed for reverse gear. -->
brake-factor: Value used when braking.
brake-time-increase: The brake force is multiplied by
(1+brake_time*brake_time_increase - i.e. the longer the brake was
pressed, the harder the kart will brake.
max-speed-reverse-ratio is the percentage of max speed for reverse gear.
-->
<engine power="450 475 500 510" max-speed="17 21 23 25" brake-factor="11.0"
brake-time-increase="10"
max-speed-reverse-ratio="0.3"/>
<!-- Simulated gears: switch-ratio defines at what ratio of the maximum

View File

@ -343,6 +343,7 @@ void Kart::reset()
m_has_started = false;
m_wheel_rotation = 0;
m_bounce_back_time = 0.0f;
m_brake_time = 0.0f;
m_time_last_crash = 0.0f;
m_speed = 0.0f;
m_current_lean = 0.0f;
@ -2150,6 +2151,7 @@ void Kart::updateEnginePowerAndBrakes(float dt)
if(m_vehicle->getWheelInfo(0).m_brake &&
!World::getWorld()->isStartPhase())
m_vehicle->setAllBrakes(0);
m_brake_time = 0;
}
else
{ // not accelerating
@ -2159,9 +2161,11 @@ void Kart::updateEnginePowerAndBrakes(float dt)
if(m_speed > 0.0f)
{ // Still going forward while braking
applyEngineForce(0.f);
//apply the brakes
m_vehicle->setAllBrakes(m_kart_properties->getBrakeFactor());
m_brake_time += dt;
// Apply the brakes - include the time dependent brake increase
float f = 1 + m_brake_time
* getKartProperties()->getBrakeTimeIncrease();
m_vehicle->setAllBrakes(m_kart_properties->getBrakeFactor()*f);
}
else // m_speed < 0
{
@ -2185,6 +2189,7 @@ void Kart::updateEnginePowerAndBrakes(float dt)
}
else // !m_brake
{
m_brake_time = 0;
// lift the foot from throttle, brakes with 10% engine_power
assert(!isnan(m_controls.m_accel));
assert(!isnan(engine_power));

View File

@ -116,9 +116,13 @@ private:
* determine startup boost. */
bool m_has_started;
/**<Maximum engine rpm's for the current gear*/
/** Maximum engine rpm's for the current gear. */
float m_max_gear_rpm;
/** How long the brake key has been pressed - the longer the harder
* the kart will brake. */
float m_brake_time;
/** A short time after a collision acceleration is disabled to allow
* the karts to bounce back*/
float m_bounce_back_time;

View File

@ -64,7 +64,7 @@ KartProperties::KartProperties(const std::string &filename)
// Set all other values to undefined, so that it can later be tested
// if everything is defined properly.
m_mass = m_brake_factor =
m_mass = m_brake_factor = m_brake_time_increase =
m_time_reset_steer = m_nitro_consumption = m_nitro_engine_force =
m_nitro_small_container = m_nitro_big_container = m_nitro_max =
m_nitro_max_speed_increase = m_nitro_duration = m_nitro_fade_out_time =
@ -92,6 +92,7 @@ KartProperties::KartProperties(const std::string &filename)
m_squash_duration = m_downward_impulse_factor =
m_bubblegum_fade_in_time = m_bubblegum_speed_fraction =
m_bubblegum_time = m_bubblegum_torque = m_jump_animation_time =
m_smooth_flying_impulse =
UNDEFINED;
m_engine_power.resize(RaceManager::DIFFICULTY_COUNT, UNDEFINED);
@ -370,6 +371,7 @@ void KartProperties::getAllData(const XMLNode * root)
&m_downward_impulse_factor);
stability_node->get("track-connection-accel",
&m_track_connection_accel );
stability_node->get("smooth-flying-impulse", &m_smooth_flying_impulse);
}
if(const XMLNode *collision_node = root->getNode("collision"))
@ -527,7 +529,8 @@ void KartProperties::getAllData(const XMLNode * root)
if(const XMLNode *engine_node = root->getNode("engine"))
{
engine_node->get("brake-factor", &m_brake_factor);
engine_node->get("brake-factor", &m_brake_factor);
engine_node->get("brake-time-increase", &m_brake_time_increase);
engine_node->get("max-speed-reverse-ratio", &m_max_speed_reverse_ratio);
engine_node->get("power", &m_engine_power);
if(m_engine_power.size()!=RaceManager::DIFFICULTY_COUNT)
@ -659,8 +662,10 @@ void KartProperties::checkAllSet(const std::string &filename)
CHECK_NEG(m_chassis_angular_damping, "stability chassis-angular-damping");
CHECK_NEG(m_downward_impulse_factor, "stability downward-impulse-factor");
CHECK_NEG(m_track_connection_accel, "stability track-connection-accel" );
CHECK_NEG(m_smooth_flying_impulse, "smooth-flying-impulse" );
CHECK_NEG(m_max_speed_reverse_ratio, "engine max-speed-reverse-ratio");
CHECK_NEG(m_brake_factor, "engine brake-factor" );
CHECK_NEG(m_brake_time_increase, "engine brake-time-increase" );
CHECK_NEG(m_suspension_stiffness, "suspension stiffness" );
CHECK_NEG(m_suspension_rest, "suspension rest" );
CHECK_NEG(m_suspension_travel_cm, "suspension travel-cm" );

View File

@ -130,12 +130,19 @@ private:
/** Braking factor * engine_power braking force. */
float m_brake_factor;
/** Brake_time * m_brake_time_increase will increase the break time
* over time. */
float m_brake_time_increase;
/** Time for player karts to reach full steer angle. */
InterpolationArray m_time_full_steer;
/** Time for steering to go back to zero from full steer. */
float m_time_reset_steer;
/** A torque impulse applied to keep the kart parallel to the ground. */
float m_smooth_flying_impulse;;
/** The turn angle depending on speed. */
InterpolationArray m_turn_angle_at_speed;
@ -501,10 +508,21 @@ public:
/** Get braking information. */
float getBrakeFactor () const {return m_brake_factor; }
// ------------------------------------------------------------------------
/** Returns the additional brake factor which depends on time. */
float getBrakeTimeIncrease() const { return m_brake_time_increase; }
// ------------------------------------------------------------------------
/** Returns the torque scaling factor used to keep the karts parallel to
* the ground when flying. */
float getSmoothFlyingImpulse() const
{
return m_smooth_flying_impulse;
} // getSmoothFlyingImpulse
// ------------------------------------------------------------------------
/** Get maximum reverse speed ratio. */
float getMaxSpeedReverseRatio () const
{return m_max_speed_reverse_ratio; }
float getMaxSpeedReverseRatio() const {return m_max_speed_reverse_ratio; }
// ------------------------------------------------------------------------
/** Returns the engine type (used to change sfx depending on kart size). */

View File

@ -394,8 +394,8 @@ void btKart::updateVehicle( btScalar step )
btVector3 kart_up = getChassisWorldTransform().getBasis().getColumn(1);
btVector3 terrain_up(0,1,0);
btVector3 axis = kart_up.cross(terrain_up);
// Times 10 gives a nicely balanced feeling.
m_chassisBody->applyTorqueImpulse(axis * 10);
// Give a nicely balanced feeling for rebalancing the kart
m_chassisBody->applyTorqueImpulse(axis * m_kart->getKartProperties()->getSmoothFlyingImpulse());
}
// Work around: make sure that either both wheels on one axis