Added a minimum speed karts need in order to use slipstreaming. Removed debug output.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4274 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2009-12-09 03:50:44 +00:00
parent f78baf0c82
commit 81eeb36edb
5 changed files with 24 additions and 7 deletions

View File

@@ -123,6 +123,7 @@ skid-visual: Additional graphical rotation of kart.
slipstrea slipstream-length: How far behind a kart slipstream works
slipstream-time: How many seconds of sstream give maximum benefit
slipstream-add-power: Additional power due to sstreaming. 1 = +100%
slipstream-min-speed: Minimum speed necessary for slipstream to take effect.
min-speed-radius and max-speed-radius define the smallest turn radius at
lowest speed (4.64 m at speed 0) and at high speed (13.5 m at speed 12 m/s).
@@ -189,6 +190,7 @@ rubber-band-duration is the duration a rubber band acts.
slipstream-length="5"
slipstream-time="5"
slipstream-add-power="3"
slipstream-min-speed="15"
brake-factor="11.0"
min-speed-radius="0 3"

View File

@@ -455,7 +455,6 @@ scene::IMesh *IrrDriver::createTexturedQuadMesh(const video::SMaterial *material
return mesh;
} // createQuadMesh
// ----------------------------------------------------------------------------
/** Removes a scene node from the scene.
* \param node The scene node to remove.
@@ -473,6 +472,7 @@ void IrrDriver::removeMesh(scene::IMesh *mesh)
{
m_scene_manager->getMeshCache()->removeMesh(mesh);
} // removeMesh
// ----------------------------------------------------------------------------
/** Removes a texture from irrlicht's texture cache.
* \param t The texture to remove.
@@ -491,7 +491,6 @@ scene::IAnimatedMeshSceneNode *IrrDriver::addAnimatedMesh(scene::IAnimatedMesh *
return m_scene_manager->addAnimatedMeshSceneNode(mesh);
} // addAnimatedMesh
// ----------------------------------------------------------------------------
/** Adds a sky dome. Documentation from irrlicht:
* A skydome is a large (half-) sphere with a panoramic texture on the inside

View File

@@ -776,6 +776,9 @@ float Kart::handleNitro(float dt)
*/
float Kart::handleSlipstream(float dt)
{
// If this kart is too slow for slipstreaming taking effect, do nothing
if(getSpeed()<m_kart_properties->getSlipstreamMinSpeed()) return 0;
m_slipstream_original_area->transform(getTrans(), m_slipstream_area);
// Note: there is a slight inconsistency here: Karts are updated one
@@ -784,7 +787,8 @@ float Kart::handleSlipstream(float dt)
// slipstream area of that kart, but for karts not yet updated the
// old position will be used. The differences should not be noticable,
// and simplifies the update process (which would otherwise have to be
// done in two stages).
// done in two stages). Besides, the same problem exists everywhere
// in the kart update process.
unsigned int n = race_manager->getNumKarts();
bool is_sstreaming = false;
for(unsigned int i=0; i<n; i++)
@@ -793,6 +797,13 @@ float Kart::handleSlipstream(float dt)
// Don't test for slipstream with itself.
if(kart==this) continue;
// If the kart we are testing against is too slow, no need to test
// slipstreaming. Note: We compare the speed of the other kart
// against the minimum slipstream kart of this kart - not entirely
// sure if this makes sense, but it makes it easier to give karts
// different slipstream properties.
if(kart->getSpeed()<m_kart_properties->getSlipstreamMinSpeed())
continue;
// Quick test: the kart must be not more than
// slipstream length+kart_length() away from the other kart
Vec3 delta = getXYZ() - kart->getXYZ();
@@ -808,13 +819,11 @@ float Kart::handleSlipstream(float dt)
float add_power = 0;
if(m_slipstream_time >0 && !is_sstreaming)
{
// Kart is using slipstream advantage
add_power = getMaxPower() * m_kart_properties->getSlipstreamAddPower();
m_slipstream_time = std::max(m_slipstream_time - dt, 0.0f);
printf("Add power %f, t=%f for '%s'\n", m_slipstream_time, add_power, getIdent().c_str());
}
else if(is_sstreaming)
{

View File

@@ -71,7 +71,7 @@ KartProperties::KartProperties(const std::string &filename) : m_icon_material(0)
m_skid_decrease = m_skid_increase = m_skid_visual = m_skid_max =
m_camera_max_accel = m_camera_max_brake =
m_slipstream_length = m_slipstream_time = m_slipstream_add_power =
m_camera_distance = UNDEFINED;
m_slipstream_min_speed = m_camera_distance = UNDEFINED;
m_gravity_center_shift = Vec3(UNDEFINED);
m_has_skidmarks = true;
m_version = 0;
@@ -241,6 +241,7 @@ void KartProperties::getAllData(const XMLNode * root)
root->get("slipstream-length", &m_slipstream_length);
root->get("slipstream-time", &m_slipstream_time);
root->get("slipstream-add-power", &m_slipstream_add_power);
root->get("slipstream-min-speed", &m_slipstream_min_speed);
root->get("brake-factor", &m_brake_factor);
std::vector<float> v;
@@ -449,6 +450,7 @@ void KartProperties::getAllData(const lisp::Lisp* lisp)
lisp->get("slipstream-length", m_slipstream_length );
lisp->get("slipstream-time", m_slipstream_time );
lisp->get("slipstream-add-power", m_slipstream_add_power );
lisp->get("slipstream-min-speed", m_slipstream_min_speed );
lisp->getVector("groups", m_groups );
@@ -540,7 +542,8 @@ void KartProperties::checkAllSet(const std::string &filename)
CHECK_NEG(m_skid_visual, "skid-visual" );
CHECK_NEG(m_slipstream_length, "slipstream-length" );
CHECK_NEG(m_slipstream_time, "slipstream-time" );
CHECK_NEG(m_slipstream_add_power, "slipstream-add-power" );
CHECK_NEG(m_slipstream_add_power, "slipstream-add-power" );
CHECK_NEG(m_slipstream_min_speed, "slipstream-min-speed" );
CHECK_NEG(m_camera_max_accel, "camera-max-accel" );
CHECK_NEG(m_camera_max_brake, "camera-max-brake" );

View File

@@ -139,6 +139,8 @@ private:
float m_slipstream_time; /**< Time after which sstream has maxium
* benefit. */
float m_slipstream_add_power; /**< Additional power due to sstreaming. */
float m_slipstream_min_speed; /**< Minimum speed for slipstream to take
* effect. */
float m_skid_max; /**< Maximal increase of steering when
* skidding. */
float m_skid_increase; /**< Skidding is multiplied by this when
@@ -240,6 +242,8 @@ public:
float getSlipstreamTime () const {return m_slipstream_time; }
/** Returns additional power due to slipstreaming. */
float getSlipstreamAddPower () const {return m_slipstream_add_power; }
/** Returns the minimum slipstream speed. */
float getSlipstreamMinSpeed () const {return m_slipstream_min_speed; }
/** Returns the maximum factor by which the steering angle can be increased. */
float getMaxSkid () const {return m_skid_max; }
/** Returns the factor by which m_skidding is multiplied when the kart is