1) Fixed 'wild rotation' on sand (which was only a graphical effect, it

didn't really happen in reality)
2) Applied Minibjorn's patch to allow more violent explosions.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2922 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2009-01-14 23:36:30 +00:00
parent 49400b3090
commit b41bd96125
6 changed files with 42 additions and 12 deletions

View File

@ -20,6 +20,9 @@
(skid-fadeout-time 60) ;; Time till skidm marks fade out
(slowdown-factor 10) ;; Engine reduction depending on terrain,
;; see kart for details.
(near-ground 2) ;; Distance above ground when the upright
;; constraint will be disabled to allow
;; more violent explosions.
(delay-finish-time 10) ;; delay till race results are displayed.
(music-credit-time 10) ;; time for which the music credits
;; are displayed.

View File

@ -437,6 +437,19 @@ bool Kart::isOnGround() const
m_vehicle->getWheelInfo(3).m_raycastInfo.m_isInContact;
} // isOnGround
//-----------------------------------------------------------------------------
/** The kart is near the ground, but not necesarily on it (small jumps). This
* is used to determine when to switch off the upright constraint, so that
* explosions can be more violent, while still
*/
bool Kart::isNearGround() const
{
if(getHoT()==Track::NOHIT)
return false;
else
return ((getXYZ().getZ() - getHoT()) < stk_config->m_near_ground);
} // isNearGround
//-----------------------------------------------------------------------------
void Kart::handleExplosion(const Vec3& pos, bool direct_hit)
{
if(direct_hit)
@ -473,6 +486,8 @@ void Kart::handleExplosion(const Vec3& pos, bool direct_hit)
//-----------------------------------------------------------------------------
void Kart::update(float dt)
{
if(m_body->getAngularVelocity().getZ()>1.9f)
dt=1.0f*dt;
// if its view is blocked by plunger, decrease remaining time
if(m_view_blocked_by_plunger > 0) m_view_blocked_by_plunger -= dt;
@ -494,8 +509,8 @@ void Kart::update(float dt)
m_controls.m_fire = false;
}
// Only use the upright constraint if the kart is in the air!
if(isOnGround())
// When really on air, free fly, when near ground, try to glide / adjust for landing
if(!isNearGround())
m_uprightConstraint->setLimit(M_PI);
else
m_uprightConstraint->setLimit(m_kart_properties->getUprightTolerance());
@ -607,7 +622,7 @@ void Kart::update(float dt)
{
m_power_reduction = material->getSlowDown();
// Normal driving on terrain. Adjust for maximum terrain speed
float max_speed_here = material->getMaxSpeedFraction()*m_max_speed;
float max_speed_here = material->getMaxSpeedFraction()*getMaxSpeed();
// If the speed is too fast, reduce the maximum speed gradually.
// The actual capping happens in updatePhysics
if(max_speed_here<m_speed)
@ -633,7 +648,7 @@ void Kart::handleZipper()
btVector3 v = m_body->getLinearVelocity();
float current_speed = v.length();
float speed = std::min(current_speed+stk_config->m_zipper_speed_gain,
getMaxSpeed());
getMaxSpeedOnTerrain());
// If the speed is too low, very minor components of the velocity vector
// can become too big. E.g. each kart has a z component (to offset gravity
// I assume, around 0.16) --> if the karts are (nearly) at standstill,
@ -773,7 +788,7 @@ void Kart::updatePhysics (float dt)
{
resetBrakes();
// going backward, apply reverse gear ratio (unless he goes too fast backwards)
if ( fabs(m_speed) < getMaxSpeed()*m_max_speed_reverse_ratio )
if ( fabs(m_speed) < getMaxSpeedOnTerrain()*m_max_speed_reverse_ratio )
{
// the backwards acceleration is artificially increased to allow
// players to get "unstuck" quicker if they hit e.g. a wall
@ -858,7 +873,7 @@ void Kart::updatePhysics (float dt)
m_speed *= -1.f;
//cap at maximum velocity
const float max_speed = m_kart_properties->getMaxSpeed();
const float max_speed = getMaxSpeedOnTerrain();
if ( m_speed > max_speed )
{
const float velocity_ratio = max_speed/m_speed;

View File

@ -185,7 +185,12 @@ public:
getControls () const {return m_controls; }
/** Sets the kart controls. Used e.g. by replaying history. */
void setControls(const KartControl &c) { m_controls = c; }
float getMaxSpeed () const {return m_max_speed-
/** Returns the maximum speed of the kart independent of the
* terrain it is on. */
float getMaxSpeed () const {return m_max_speed; }
/** Returns the maximum speed of the kart but includes the effect of
* the terrain it is on. */
float getMaxSpeedOnTerrain() const {return m_max_speed-
m_max_speed_reduction; }
/** Returns the length of the kart. */
float getKartLength () const
@ -207,6 +212,7 @@ public:
float handleNitro (float dt);
float getActualWheelForce();
bool isOnGround () const;
bool isNearGround () const;
bool isEliminated () const {return m_eliminated;}
void eliminate ();
bool isRescue () const {return m_rescue;}

View File

@ -561,7 +561,7 @@ void DefaultRobot::handleAcceleration( const float DELTA )
if(hasViewBlockedByPlunger())
{
if(!(getSpeed() > getMaxSpeed() / 2))
if(!(getSpeed() > getMaxSpeedOnTerrain() / 2))
m_controls.m_accel = 0.05f;
else
m_controls.m_accel = 0.0f;
@ -631,7 +631,7 @@ void DefaultRobot::handleNitroAndZipper()
{
m_controls.m_nitro = false;
// If we are already very fast, save nitro.
if(getSpeed() > 0.95f*getMaxSpeed())
if(getSpeed() > 0.95f*getMaxSpeedOnTerrain())
return;
// Don't use nitro when the AI has a plunger in the face!
if(hasViewBlockedByPlunger()) return;
@ -987,7 +987,7 @@ void DefaultRobot::reset()
m_start_kart_crash_direction = 0;
m_sector = Track::UNKNOWN_SECTOR;
m_inner_curve = 0;
m_curve_target_speed = getMaxSpeed();
m_curve_target_speed = getMaxSpeedOnTerrain();
m_curve_angle = 0.0;
m_future_location[0] = 0.0;
m_future_location[1] = 0.0;
@ -1182,5 +1182,5 @@ void DefaultRobot::findCurve()
m_curve_angle = normalizeAngle(m_track->m_angle[i] - m_track->m_angle[m_track_sector]);
m_inner_curve = m_curve_angle > 0.0 ? -1 : 1;
m_curve_target_speed = getMaxSpeed();
m_curve_target_speed = getMaxSpeedOnTerrain();
} // findCurve

View File

@ -116,6 +116,7 @@ void STKConfig::load(const std::string &filename)
CHECK_NEG(m_max_skidmarks, "max-skidmarks" );
CHECK_NEG(m_skid_fadeout_time, "skid-fadeout-time" );
CHECK_NEG(m_slowdown_factor, "slowdown-factor" );
CHECK_NEG(m_near_ground, "near-ground" );
CHECK_NEG(m_delay_finish_time, "delay-finish-time" );
CHECK_NEG(m_music_credit_time, "music-credit-time" );
m_kart_properties.checkAllSet(filename);
@ -138,7 +139,7 @@ void STKConfig::init_defaults()
m_shortcut_length = m_music_credit_time =
m_delay_finish_time = m_skid_fadeout_time =
m_slowdown_factor = m_offroad_tolerance =
m_final_camera_time =
m_final_camera_time = m_near_ground =
UNDEFINED;
m_max_karts = -100;
m_grid_order = -100;
@ -202,6 +203,7 @@ void STKConfig::getAllData(const lisp::Lisp* lisp)
lisp->get("max-skidmarks", m_max_skidmarks );
lisp->get("skid-fadeout-time", m_skid_fadeout_time );
lisp->get("slowdown-factor", m_slowdown_factor );
lisp->get("near-ground", m_near_ground );
lisp->get("delay-finish-time", m_delay_finish_time );
lisp->get("music-credit-time", m_music_credit_time );
lisp->getVector("menu-background", m_menu_background );

View File

@ -75,6 +75,10 @@ public:
int m_max_skidmarks; /**<Maximum number of skid marks/kart. */
float m_skid_fadeout_time; /**<Time till skidmarks fade away. */
float m_slowdown_factor; /**<Used in terrain specific slowdown. */
float m_near_ground; /**<Determines when a kart is not near
* ground anymore and the upright
* constraint is disabled to allow for
* more violent explosions. */
bool m_enable_networking;
std::vector<float>