Remove skidding properties and use characteristics instead
This commit is contained in:
parent
2f1d08edbd
commit
79c962dd79
@ -27,12 +27,6 @@ AbstractCharacteristic::AbstractCharacteristic()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
const SkiddingProperties* AbstractCharacteristic::getSkiddingProperties() const
|
||||
{
|
||||
return nullptr;
|
||||
} // getSkiddingProperties
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** The process function should change the given value.
|
||||
* The input and output argument is saved in value.
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class SkiddingProperties;
|
||||
class InterpolationArray;
|
||||
|
||||
/**
|
||||
@ -224,18 +223,11 @@ public:
|
||||
// Count
|
||||
CHARACTERISTIC_COUNT
|
||||
};
|
||||
private:
|
||||
/** The skididing properties for this kart, as a separate object in order
|
||||
* to reduce dependencies (and therefore compile time) when changing
|
||||
* any skidding property. */
|
||||
//TODO SkiddingProperties *m_skidding;
|
||||
|
||||
public:
|
||||
AbstractCharacteristic();
|
||||
virtual ~AbstractCharacteristic() {}
|
||||
|
||||
virtual const SkiddingProperties* getSkiddingProperties() const;
|
||||
|
||||
/**
|
||||
* The process function is the core of this characteristics system.
|
||||
* Any computation of the properties should happen here and modify the
|
||||
|
@ -174,12 +174,6 @@ void CachedCharacteristic::updateSource()
|
||||
} // foreach characteristic
|
||||
} // updateSource
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
const SkiddingProperties* CachedCharacteristic::getSkiddingProperties() const
|
||||
{
|
||||
return m_origin->getSkiddingProperties();
|
||||
} // getSkiddingProperties
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Returns the stored value. */
|
||||
void CachedCharacteristic::process(CharacteristicType type, Value value,
|
||||
|
@ -47,7 +47,6 @@ public:
|
||||
/** Fetches all cached values from the original source. */
|
||||
void updateSource();
|
||||
|
||||
virtual const SkiddingProperties* getSkiddingProperties() const;
|
||||
virtual void process(CharacteristicType type, Value value, bool *is_set) const;
|
||||
};
|
||||
|
||||
|
@ -24,18 +24,6 @@ void CombinedCharacteristic::addCharacteristic(
|
||||
m_childs.push_back(characteristic);
|
||||
} // addCharacteristic
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
const SkiddingProperties* CombinedCharacteristic::getSkiddingProperties() const
|
||||
{
|
||||
for (const AbstractCharacteristic *characteristic : m_childs)
|
||||
{
|
||||
const SkiddingProperties *skid = characteristic->getSkiddingProperties();
|
||||
if (skid)
|
||||
return skid;
|
||||
}
|
||||
return nullptr;
|
||||
} // getSkiddingProperties
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Combines all contained source characteristics. */
|
||||
void CombinedCharacteristic::process(CharacteristicType type, Value value,
|
||||
|
@ -29,7 +29,6 @@ private:
|
||||
public:
|
||||
void addCharacteristic(const AbstractCharacteristic *characteristic);
|
||||
|
||||
virtual const SkiddingProperties* getSkiddingProperties() const;
|
||||
virtual void process(CharacteristicType type, Value value, bool *is_set) const;
|
||||
};
|
||||
|
||||
|
@ -20,9 +20,9 @@
|
||||
#include "karts/controller/ai_base_controller.hpp"
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "karts/abstract_characteristic.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "karts/skidding_properties.hpp"
|
||||
#include "karts/controller/ai_properties.hpp"
|
||||
#include "modes/linear_world.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
@ -501,8 +501,7 @@ bool AIBaseController::doSkid(float steer_fraction)
|
||||
// FIXME: Disable skidding for now if the new skidding
|
||||
// code is activated, since the AI can not handle this
|
||||
// properly.
|
||||
if(m_kart->getKartProperties()->getSkiddingProperties()
|
||||
->getSkidVisualTime()>0)
|
||||
if(m_kart->getCharacteristic()->getSkidVisualTime() > 0)
|
||||
return false;
|
||||
|
||||
// Otherwise return if we need a sharp turn (which is
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "karts/max_speed.hpp"
|
||||
#include "karts/rescue_animation.hpp"
|
||||
#include "karts/skidding.hpp"
|
||||
#include "karts/skidding_properties.hpp"
|
||||
#include "modes/linear_world.hpp"
|
||||
#include "modes/profile_world.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
@ -2260,7 +2259,6 @@ bool SkiddingAI::doSkid(float steer_fraction)
|
||||
// the actual path is adjusted during the turn. So apply an
|
||||
// experimentally found factor in to get better estimates.
|
||||
duration *= 1.5f;
|
||||
const Skidding *skidding = m_kart->getSkidding();
|
||||
|
||||
// If the remaining estimated time for skidding is too short, stop
|
||||
// it. This code will mostly trigger the bonus at the end of a skid.
|
||||
@ -2289,8 +2287,8 @@ bool SkiddingAI::doSkid(float steer_fraction)
|
||||
return false;
|
||||
}
|
||||
// If there is a skidding bonus, try to get it.
|
||||
else if(skidding->getNumberOfBonusTimes()>0 &&
|
||||
skidding->getTimeTillBonus(0) < duration)
|
||||
else if (m_kart->getCharacteristic()->getSkidBonusSpeed().size() > 0 &&
|
||||
m_kart->getCharacteristic()->getSkidTimeTillBonus()[0] < duration)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if(!m_controls->m_skid && m_ai_debug)
|
||||
|
@ -225,8 +225,7 @@ void Kart::init(RaceManager::KartType type)
|
||||
loadData(type, animations);
|
||||
|
||||
m_kart_gfx = new KartGFX(this);
|
||||
m_skidding = new Skidding(this,
|
||||
m_kart_properties->getSkiddingProperties());
|
||||
m_skidding = new Skidding(this);
|
||||
// Create the stars effect
|
||||
m_stars_effect =
|
||||
new Stars(getNode(),
|
||||
@ -1369,7 +1368,7 @@ void Kart::update(float dt)
|
||||
static video::SColor green(255, 61, 87, 23);
|
||||
|
||||
// draw skidmarks if relevant (we force pink skidmarks on when hitting a bubblegum)
|
||||
if(m_kart_properties->getSkiddingProperties()->hasSkidmarks())
|
||||
if(m_characteristic->getSkidEnabled())
|
||||
{
|
||||
m_skidmarks->update(dt,
|
||||
m_bubblegum_time > 0,
|
||||
@ -2244,8 +2243,8 @@ void Kart::updateEnginePowerAndBrakes(float dt)
|
||||
engine_power *= 5.0f;
|
||||
|
||||
// Lose some traction when skidding, to balance the advantage
|
||||
if(m_controls.m_skid &&
|
||||
m_kart_properties->getSkiddingProperties()->getSkidVisualTime()==0)
|
||||
if (m_controls.m_skid &&
|
||||
m_characteristic->getSkidVisualTime() == 0)
|
||||
engine_power *= 0.5f;
|
||||
|
||||
applyEngineForce(engine_power*m_controls.m_accel);
|
||||
@ -2446,7 +2445,7 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model)
|
||||
|
||||
m_slipstream = new SlipStream(this);
|
||||
|
||||
if(m_kart_properties->getSkiddingProperties()->hasSkidmarks())
|
||||
if (m_characteristic->getSkidEnabled())
|
||||
{
|
||||
m_skidmarks = new SkidMarks(*this);
|
||||
m_skidmarks->adjustFog(
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "karts/controller/ai_properties.hpp"
|
||||
#include "karts/kart_model.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "karts/skidding_properties.hpp"
|
||||
#include "karts/xml_characteristic.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
@ -95,14 +94,12 @@ KartProperties::KartProperties(const std::string &filename)
|
||||
// The default constructor for stk_config uses filename=""
|
||||
if (filename != "")
|
||||
{
|
||||
m_skidding_properties = NULL;
|
||||
for(unsigned int i=0; i<RaceManager::DIFFICULTY_COUNT; i++)
|
||||
m_ai_properties[i]= NULL;
|
||||
load(filename, "kart");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_skidding_properties = new SkiddingProperties();
|
||||
for(unsigned int i=0; i<RaceManager::DIFFICULTY_COUNT; i++)
|
||||
m_ai_properties[i]= new AIProperties((RaceManager::Difficulty)i);
|
||||
}
|
||||
@ -113,8 +110,6 @@ KartProperties::KartProperties(const std::string &filename)
|
||||
KartProperties::~KartProperties()
|
||||
{
|
||||
delete m_kart_model;
|
||||
if(m_skidding_properties)
|
||||
delete m_skidding_properties;
|
||||
for(unsigned int i=0; i<RaceManager::DIFFICULTY_COUNT; i++)
|
||||
if(m_ai_properties[i])
|
||||
delete m_ai_properties[i];
|
||||
@ -133,10 +128,6 @@ void KartProperties::copyFrom(const KartProperties *source)
|
||||
|
||||
// After the memcpy any pointers will be shared.
|
||||
// So all pointer variables need to be separately allocated and assigned.
|
||||
m_skidding_properties = new SkiddingProperties();
|
||||
assert(m_skidding_properties);
|
||||
*m_skidding_properties = *source->m_skidding_properties;
|
||||
|
||||
if (source->m_characteristic)
|
||||
{
|
||||
m_characteristic.reset(new XmlCharacteristic());
|
||||
@ -446,11 +437,6 @@ void KartProperties::getAllData(const XMLNode * root)
|
||||
#endif
|
||||
} // if sounds-node exist
|
||||
|
||||
if(const XMLNode *skid_node = root->getNode("skid"))
|
||||
{
|
||||
m_skidding_properties->load(skid_node);
|
||||
}
|
||||
|
||||
|
||||
if(const XMLNode *lean_node= root->getNode("lean"))
|
||||
{
|
||||
@ -490,7 +476,6 @@ void KartProperties::checkAllSet(const std::string &filename)
|
||||
|
||||
m_speed_weighted_object_properties.checkAllSet();
|
||||
|
||||
m_skidding_properties->checkAllSet(filename);
|
||||
for(unsigned int i=0; i<RaceManager::DIFFICULTY_COUNT; i++)
|
||||
m_ai_properties[i]->checkAllSet(filename);
|
||||
} // checkAllSet
|
||||
|
@ -41,7 +41,6 @@ class AbstractCharacteristic;
|
||||
class AIProperties;
|
||||
class CombinedCharacteristic;
|
||||
class Material;
|
||||
class SkiddingProperties;
|
||||
class XMLNode;
|
||||
|
||||
/**
|
||||
@ -60,11 +59,6 @@ private:
|
||||
/** Base directory for this kart. */
|
||||
std::string m_root;
|
||||
|
||||
/** The skididing properties for this kart, as a separate object in order
|
||||
* to reduce dependencies (and therefore compile time) when changing
|
||||
* any skidding property. */
|
||||
SkiddingProperties *m_skidding_properties;
|
||||
|
||||
/** AI Properties for this kart, as a separate object in order to
|
||||
* reduce dependencies (and therefore compile time) when changing
|
||||
* any AI property. There is one separate object for each
|
||||
@ -375,11 +369,6 @@ public:
|
||||
* had to be set. */
|
||||
float getShadowZOffset () const {return m_shadow_z_offset; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a pointer to the skidding properties. */
|
||||
const SkiddingProperties *getSkiddingProperties() const
|
||||
{ return m_skidding_properties; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a pointer to the AI properties. */
|
||||
const AIProperties *getAIPropertiesForDifficulty() const
|
||||
|
@ -23,6 +23,7 @@
|
||||
#endif
|
||||
#include "achievements/achievement_info.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "karts/abstract_characteristic.hpp"
|
||||
#include "karts/ghost_kart.hpp"
|
||||
#include "karts/kart.hpp"
|
||||
#include "karts/kart_gfx.hpp"
|
||||
@ -36,7 +37,7 @@
|
||||
|
||||
/** Constructor of the skidding object.
|
||||
*/
|
||||
Skidding::Skidding(Kart *kart, const SkiddingProperties *sp)
|
||||
Skidding::Skidding(Kart *kart)
|
||||
{
|
||||
#ifdef SKID_DEBUG
|
||||
m_predicted_curve = new ShowCurve(0.05f, 0.05f,
|
||||
@ -47,8 +48,7 @@ Skidding::Skidding(Kart *kart, const SkiddingProperties *sp)
|
||||
m_actual_curve->setVisible(false);
|
||||
#endif
|
||||
m_kart = kart;
|
||||
copyFrom(sp);
|
||||
m_skid_reduce_turn_delta = m_skid_reduce_turn_max - m_skid_reduce_turn_min;
|
||||
m_skid_reduce_turn_delta = m_kart->getCharacteristic()->getSkidReduceTurnMax() - m_kart->getCharacteristic()->getSkidReduceTurnMin();
|
||||
reset();
|
||||
} // Skidding
|
||||
|
||||
@ -101,7 +101,7 @@ void Skidding::updateSteering(float steer, float dt)
|
||||
case SKID_SHOW_GFX_RIGHT:
|
||||
case SKID_NONE:
|
||||
m_real_steering = steer;
|
||||
if(m_skid_time<m_skid_visual_time && m_skid_time>0)
|
||||
if (m_skid_time < m_kart->getCharacteristic()->getSkidVisualTime() && m_skid_time > 0)
|
||||
{
|
||||
float f = m_visual_rotation - m_visual_rotation*dt/m_skid_time;
|
||||
// Floating point errors when m_skid_time is very close to 0
|
||||
@ -125,25 +125,27 @@ void Skidding::updateSteering(float steer, float dt)
|
||||
case SKID_ACCUMULATE_RIGHT:
|
||||
{
|
||||
float f = (1.0f+steer)*0.5f; // map [-1,1] --> [0, 1]
|
||||
m_real_steering = m_skid_reduce_turn_min+
|
||||
m_skid_reduce_turn_delta*f;
|
||||
if(m_skid_time < m_skid_visual_time)
|
||||
m_visual_rotation = m_skid_visual*m_real_steering*m_skid_time
|
||||
/ m_skid_visual_time;
|
||||
m_real_steering = m_kart->getCharacteristic()->getSkidReduceTurnMin()
|
||||
+ m_skid_reduce_turn_delta * f;
|
||||
if(m_skid_time < m_kart->getCharacteristic()->getSkidVisualTime())
|
||||
m_visual_rotation = m_kart->getCharacteristic()->getSkidVisual()
|
||||
* m_real_steering * m_skid_time
|
||||
/ m_kart->getCharacteristic()->getSkidVisualTime();
|
||||
else
|
||||
m_visual_rotation = m_skid_visual * m_real_steering;
|
||||
m_visual_rotation = m_kart->getCharacteristic()->getSkidVisual() * m_real_steering;
|
||||
break;
|
||||
}
|
||||
case SKID_ACCUMULATE_LEFT:
|
||||
{
|
||||
float f = (-1.0f+steer)*0.5f; // map [-1,1] --> [-1, 0]
|
||||
m_real_steering = -m_skid_reduce_turn_min+
|
||||
m_skid_reduce_turn_delta*f;
|
||||
if(m_skid_time < m_skid_visual_time)
|
||||
m_visual_rotation = m_skid_visual*m_real_steering*m_skid_time
|
||||
/ m_skid_visual_time;
|
||||
m_real_steering = -m_kart->getCharacteristic()->getSkidReduceTurnMin()
|
||||
+ m_skid_reduce_turn_delta * f;
|
||||
if(m_skid_time < m_kart->getCharacteristic()->getSkidVisualTime())
|
||||
m_visual_rotation = m_kart->getCharacteristic()->getSkidVisual()
|
||||
* m_real_steering * m_skid_time
|
||||
/ m_kart->getCharacteristic()->getSkidVisualTime();
|
||||
else
|
||||
m_visual_rotation = m_skid_visual * m_real_steering;
|
||||
m_visual_rotation = m_kart->getCharacteristic()->getSkidVisual() * m_real_steering;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -173,13 +175,13 @@ float Skidding::getSteeringWhenSkidding(float steering) const
|
||||
break;
|
||||
case SKID_ACCUMULATE_RIGHT:
|
||||
{
|
||||
float f = (steering - m_skid_reduce_turn_min)
|
||||
float f = (steering - m_kart->getCharacteristic()->getSkidReduceTurnMin())
|
||||
/ m_skid_reduce_turn_delta;
|
||||
return f *2.0f-1.0f;
|
||||
}
|
||||
case SKID_ACCUMULATE_LEFT:
|
||||
{
|
||||
float f = (steering + m_skid_reduce_turn_min)
|
||||
float f = (steering + m_kart->getCharacteristic()->getSkidReduceTurnMin())
|
||||
/ m_skid_reduce_turn_delta;
|
||||
return 2.0f * f +1.0f;
|
||||
}
|
||||
@ -212,7 +214,7 @@ void Skidding::update(float dt, bool is_on_ground,
|
||||
#endif
|
||||
|
||||
// No skidding backwards or while stopped
|
||||
if(m_kart->getSpeed() < m_min_skid_speed &&
|
||||
if(m_kart->getSpeed() < m_kart->getCharacteristic()->getSkidMinSpeed() &&
|
||||
m_skid_state != SKID_NONE && m_skid_state != SKID_BREAK)
|
||||
{
|
||||
m_skid_state = SKID_BREAK;
|
||||
@ -223,15 +225,16 @@ void Skidding::update(float dt, bool is_on_ground,
|
||||
m_skid_bonus_ready = false;
|
||||
if (is_on_ground)
|
||||
{
|
||||
if((fabs(steering) > 0.001f) &&
|
||||
m_kart->getSpeed()>m_min_skid_speed &&
|
||||
(skidding==KartControl::SC_LEFT||skidding==KartControl::SC_RIGHT))
|
||||
if ((fabs(steering) > 0.001f) &&
|
||||
m_kart->getSpeed() > m_kart->getCharacteristic()->getSkidMinSpeed() &&
|
||||
(skidding == KartControl::SC_LEFT || skidding == KartControl::SC_RIGHT))
|
||||
{
|
||||
m_skid_factor += m_skid_increase *dt/m_time_till_max_skid;
|
||||
m_skid_factor += m_kart->getCharacteristic()->getSkidIncrease()
|
||||
* dt / m_kart->getCharacteristic()->getSkidTimeTillMax();
|
||||
}
|
||||
else if(m_skid_factor>1.0f)
|
||||
else if (m_skid_factor > 1.0f)
|
||||
{
|
||||
m_skid_factor *= m_skid_decrease;
|
||||
m_skid_factor *= m_kart->getCharacteristic()->getSkidDecrease();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -239,10 +242,10 @@ void Skidding::update(float dt, bool is_on_ground,
|
||||
m_skid_factor = 1.0f; // Lose any skid factor as soon as we fly
|
||||
}
|
||||
|
||||
if(m_skid_factor>m_skid_max)
|
||||
m_skid_factor = m_skid_max;
|
||||
if (m_skid_factor > m_kart->getCharacteristic()->getSkidMax())
|
||||
m_skid_factor = m_kart->getCharacteristic()->getSkidMax();
|
||||
else
|
||||
if(m_skid_factor<1.0f) m_skid_factor = 1.0f;
|
||||
if (m_skid_factor < 1.0f) m_skid_factor = 1.0f;
|
||||
|
||||
// If skidding was started and a graphical jump should still
|
||||
// be displayed, update the data
|
||||
@ -288,8 +291,9 @@ void Skidding::update(float dt, bool is_on_ground,
|
||||
break;
|
||||
// Don't allow skidding while the kart is (apparently)
|
||||
// still in the air, or when the kart is too slow
|
||||
if(m_remaining_jump_time>0 ||
|
||||
m_kart->getSpeed() <m_min_skid_speed) break;
|
||||
if (m_remaining_jump_time > 0 ||
|
||||
m_kart->getSpeed() < m_kart->getCharacteristic()->getSkidMinSpeed())
|
||||
break;
|
||||
|
||||
m_skid_state = skidding==KartControl::SC_RIGHT
|
||||
? SKID_ACCUMULATE_RIGHT
|
||||
@ -300,14 +304,14 @@ void Skidding::update(float dt, bool is_on_ground,
|
||||
// Then use this speed to determine the impulse necessary to
|
||||
// reach this speed.
|
||||
float v = World::getWorld()->getTrack()->getGravity()
|
||||
* 0.5f*m_physical_jump_time;
|
||||
* 0.5f * m_kart->getCharacteristic()->getSkidPhysicalJumpTime();
|
||||
btVector3 imp(0, v / m_kart->getBody()->getInvMass(),0);
|
||||
m_kart->getVehicle()->getRigidBody()->applyCentralImpulse(imp);
|
||||
|
||||
// Some karts might use a graphical-only jump. Set it up:
|
||||
m_jump_speed = World::getWorld()->getTrack()->getGravity()
|
||||
* 0.5f*m_graphical_jump_time;
|
||||
m_remaining_jump_time = m_graphical_jump_time;
|
||||
* 0.5f * m_kart->getCharacteristic()->getSkidGraphicalJumpTime();
|
||||
m_remaining_jump_time = m_kart->getCharacteristic()->getSkidGraphicalJumpTime();
|
||||
|
||||
#ifdef SKID_DEBUG
|
||||
#define SPEED 20.0f
|
||||
@ -388,11 +392,11 @@ void Skidding::update(float dt, bool is_on_ground,
|
||||
m_skid_state = m_skid_state == SKID_ACCUMULATE_LEFT
|
||||
? SKID_SHOW_GFX_LEFT
|
||||
: SKID_SHOW_GFX_RIGHT;
|
||||
float t = std::min(m_skid_time, m_skid_visual_time);
|
||||
t = std::min(t, m_skid_revert_visual_time);
|
||||
float t = std::min(m_skid_time, m_kart->getCharacteristic()->getSkidVisualTime());
|
||||
t = std::min(t, m_kart->getCharacteristic()->getSkidRevertVisualTime());
|
||||
|
||||
float vso = getVisualSkidRotation();
|
||||
btVector3 rot(0, vso*m_post_skid_rotate_factor, 0);
|
||||
btVector3 rot(0, vso * m_kart->getCharacteristic()->getSkidPostSkidRotateFactor(), 0);
|
||||
m_kart->getVehicle()->setTimedRotation(t, rot);
|
||||
// skid_time is used to count backwards for the GFX
|
||||
m_skid_time = t;
|
||||
@ -455,13 +459,14 @@ unsigned int Skidding::getSkidBonus(float *bonus_time,
|
||||
*bonus_time = 0;
|
||||
*bonus_speed = 0;
|
||||
*bonus_force = 0;
|
||||
for(unsigned int i=0; i<m_skid_bonus_speed.size(); i++)
|
||||
for (unsigned int i = 0; i < m_kart->getCharacteristic()->getSkidBonusSpeed().size(); i++)
|
||||
{
|
||||
if(m_skid_time<=m_skid_time_till_bonus[i]) return i;
|
||||
*bonus_speed = m_skid_bonus_speed[i];
|
||||
*bonus_time = m_skid_bonus_time[i];
|
||||
*bonus_force = m_skid_bonus_force[i];
|
||||
if (m_skid_time <= m_kart->getCharacteristic()->getSkidTimeTillBonus()[i])
|
||||
return i;
|
||||
*bonus_speed = m_kart->getCharacteristic()->getSkidBonusSpeed()[i];
|
||||
*bonus_time = m_kart->getCharacteristic()->getSkidBonusTime()[i];
|
||||
*bonus_force = m_kart->getCharacteristic()->getSkidBonusForce()[i];
|
||||
}
|
||||
return (unsigned int) m_skid_bonus_speed.size();
|
||||
return (unsigned int) m_kart->getCharacteristic()->getSkidBonusSpeed().size();
|
||||
} // getSkidBonusForce
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#ifndef HEADER_SKIDDING_HPP
|
||||
#define HEADER_SKIDDING_HPP
|
||||
|
||||
#include "karts/skidding_properties.hpp"
|
||||
#include "karts/controller/kart_control.hpp"
|
||||
#include "utils/leak_check.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
@ -35,7 +34,7 @@ class ShowCurve;
|
||||
|
||||
#undef SKID_DEBUG
|
||||
|
||||
class Skidding : public SkiddingProperties
|
||||
class Skidding
|
||||
{
|
||||
public:
|
||||
LEAK_CHECK();
|
||||
@ -101,7 +100,7 @@ private:
|
||||
float *bonus_force) const;
|
||||
void updateSteering(float steer, float dt);
|
||||
public:
|
||||
Skidding(Kart *kart, const SkiddingProperties *sp);
|
||||
Skidding(Kart *kart);
|
||||
~Skidding();
|
||||
void reset();
|
||||
void update(float dt, bool is_on_ground, float steer,
|
||||
|
@ -1,134 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2012-2015 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "karts/skidding_properties.hpp"
|
||||
|
||||
#include "io/xml_node.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
float SkiddingProperties::UNDEFINED = -99.9f;
|
||||
|
||||
SkiddingProperties::SkiddingProperties()
|
||||
{
|
||||
m_skid_increase = UNDEFINED;
|
||||
m_skid_decrease = UNDEFINED;
|
||||
m_skid_max = UNDEFINED;
|
||||
m_time_till_max_skid = UNDEFINED;
|
||||
m_skid_visual = UNDEFINED;
|
||||
m_skid_visual_time = UNDEFINED;
|
||||
m_skid_revert_visual_time = UNDEFINED;
|
||||
m_post_skid_rotate_factor = UNDEFINED;
|
||||
m_skid_reduce_turn_min = UNDEFINED;
|
||||
m_skid_reduce_turn_max = UNDEFINED;
|
||||
m_physical_jump_time = UNDEFINED;
|
||||
m_graphical_jump_time = UNDEFINED;
|
||||
m_min_skid_speed = UNDEFINED;
|
||||
m_has_skidmarks = true;
|
||||
|
||||
m_skid_bonus_time.clear();
|
||||
m_skid_bonus_speed.clear();
|
||||
m_skid_time_till_bonus.clear();
|
||||
m_skid_bonus_force.clear();
|
||||
} // SkiddingProperties
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void SkiddingProperties::load(const XMLNode *skid_node)
|
||||
{
|
||||
skid_node->get("increase", &m_skid_increase );
|
||||
skid_node->get("decrease", &m_skid_decrease );
|
||||
skid_node->get("max", &m_skid_max );
|
||||
skid_node->get("time-till-max", &m_time_till_max_skid );
|
||||
skid_node->get("visual", &m_skid_visual );
|
||||
skid_node->get("visual-time", &m_skid_visual_time );
|
||||
skid_node->get("revert-visual-time", &m_skid_revert_visual_time);
|
||||
skid_node->get("post-skid-rotate-factor",&m_post_skid_rotate_factor);
|
||||
skid_node->get("reduce-turn-min", &m_skid_reduce_turn_min );
|
||||
skid_node->get("reduce-turn-max", &m_skid_reduce_turn_max );
|
||||
skid_node->get("enable", &m_has_skidmarks );
|
||||
skid_node->get("bonus-time", &m_skid_bonus_time );
|
||||
skid_node->get("bonus-speed", &m_skid_bonus_speed );
|
||||
skid_node->get("time-till-bonus", &m_skid_time_till_bonus );
|
||||
skid_node->get("bonus-force", &m_skid_bonus_force );
|
||||
skid_node->get("physical-jump-time", &m_physical_jump_time );
|
||||
skid_node->get("graphical-jump-time", &m_graphical_jump_time );
|
||||
skid_node->get("min-speed", &m_min_skid_speed );
|
||||
} // load
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void SkiddingProperties::checkAllSet(const std::string &filename) const
|
||||
{
|
||||
#define CHECK_NEG( a,strA) if(a<=UNDEFINED) { \
|
||||
Log::fatal("Skidding_Properties", "Missing default value for '%s'"\
|
||||
"in '%s'.", \
|
||||
strA,filename.c_str()); \
|
||||
}
|
||||
CHECK_NEG(m_skid_increase, "skid increase" );
|
||||
CHECK_NEG(m_skid_decrease, "skid decrease" );
|
||||
CHECK_NEG(m_skid_max, "skid max" );
|
||||
CHECK_NEG(m_time_till_max_skid, "skid time-till-max" );
|
||||
CHECK_NEG(m_skid_visual, "skid visual" );
|
||||
CHECK_NEG(m_skid_visual_time, "skid visual-time" );
|
||||
CHECK_NEG(m_skid_revert_visual_time, "skid revert-visual-time" );
|
||||
CHECK_NEG(m_post_skid_rotate_factor, "skid post-skid-rotate-factor" );
|
||||
CHECK_NEG(m_skid_reduce_turn_min, "skid reduce-turn-min" );
|
||||
CHECK_NEG(m_skid_reduce_turn_max, "skid reduce-turn-max" );
|
||||
CHECK_NEG(m_physical_jump_time, "skid physical-jump-time" );
|
||||
CHECK_NEG(m_graphical_jump_time, "skid graphical-jump-time" );
|
||||
CHECK_NEG(m_min_skid_speed, "skid min-speed" );
|
||||
|
||||
if(m_skid_time_till_bonus.size()==0)
|
||||
Log::error("Skidding_Properties", "Warning: no skid time declared,"
|
||||
"can be ignored.");
|
||||
if(m_skid_time_till_bonus.size()!=m_skid_bonus_speed.size())
|
||||
{
|
||||
Log::fatal("Skidding_Properties", "Warning: skid time-till-bonus"
|
||||
"and bonus-speed\n must have same number of elements.");
|
||||
}
|
||||
if(m_skid_time_till_bonus.size()!=m_skid_bonus_time.size())
|
||||
{
|
||||
Log::fatal("Skidding_Properties", "Warning: skid time-till-bonus"
|
||||
"and bonus-time must\n have same number of elements.");
|
||||
}
|
||||
if(m_skid_time_till_bonus.size()!=m_skid_bonus_force.size())
|
||||
{
|
||||
Log::fatal("Skidding_Properties", "Warning: skid time-till-bonus"
|
||||
"and bonus-force must\n have same number of elements.");
|
||||
}
|
||||
for(unsigned int i=0; i<m_skid_time_till_bonus.size()-1; i++)
|
||||
{
|
||||
if(m_skid_time_till_bonus[i]>=m_skid_time_till_bonus[i+1])
|
||||
{
|
||||
Log::fatal("Skidding_Properties", "Warning: skid time-till-bonus"
|
||||
"not sorted.");
|
||||
}
|
||||
} // for i
|
||||
|
||||
} // check
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void SkiddingProperties::copyFrom(const SkiddingProperties *destination)
|
||||
{
|
||||
*this = *destination;
|
||||
} // copyFrom
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/* EOF */
|
@ -1,171 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2012-2015 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_SKIDDING_PROPERTIES_HPP
|
||||
#define HEADER_SKIDDING_PROPERTIES_HPP
|
||||
|
||||
#include "utils/leak_check.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
|
||||
class Kart;
|
||||
class XMLNode;
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/** A simple class that stores all skidding related properties. It acts as
|
||||
* interface between kart_properties and Skidding (to avoid either passing
|
||||
* very many individual variables, or making KartProperties a dependency
|
||||
* of Skidding).
|
||||
* \ingroup karts
|
||||
*/
|
||||
|
||||
class SkiddingProperties
|
||||
{
|
||||
public:
|
||||
//LEAK_CHECK();
|
||||
protected:
|
||||
/** Skidding is multiplied by this when skidding
|
||||
* to increase to m_skid_increase. */
|
||||
float m_skid_increase;
|
||||
|
||||
/** Skidding is multiplied by this when not skidding to decrease to 1.0. */
|
||||
float m_skid_decrease;
|
||||
|
||||
/** How long it takes for visual skid to reach maximum. */
|
||||
float m_skid_visual_time;
|
||||
|
||||
/** How long it takes for the physical and graphical bodies to be
|
||||
* in sync again after a skid. */
|
||||
float m_skid_revert_visual_time;
|
||||
|
||||
/** Time till maximum skidding is reached. */
|
||||
float m_time_till_max_skid;
|
||||
|
||||
/** Maximal increase of steering when skidding. */
|
||||
float m_skid_max;
|
||||
|
||||
/** Additional rotation of 3d model when skidding. */
|
||||
float m_skid_visual;
|
||||
|
||||
/** Time for a small physical when skidding starts. */
|
||||
float m_physical_jump_time;
|
||||
|
||||
/** Time for a small graphics-only jump when skidding starts. */
|
||||
float m_graphical_jump_time;
|
||||
|
||||
/** This factor is used to determine how much the chassis of a kart
|
||||
* should rotate to match the graphical view. A factor of 1 is
|
||||
* identical, a smaller factor will rotate the kart less (which might
|
||||
* feel better). */
|
||||
float m_post_skid_rotate_factor;
|
||||
|
||||
/*** Minimum speed a kart must have before it can skid. */
|
||||
float m_min_skid_speed;
|
||||
|
||||
/** Time of skidding before you get a bonus boost. It's possible to
|
||||
* define more than one time, i.e. longer skidding gives more bonus. */
|
||||
std::vector<float> m_skid_time_till_bonus;
|
||||
|
||||
/** How much additional speed a kart gets when skidding. It's possible to
|
||||
* define more than one speed, i.e. longer skidding gives more bonus. */
|
||||
std::vector<float> m_skid_bonus_speed;
|
||||
|
||||
/** How long the bonus will last. It's possible to define more than one
|
||||
* time, i.e. longer skidding gives more bonus. */
|
||||
std::vector<float> m_skid_bonus_time;
|
||||
|
||||
/** Additional force accelerating the kart (in addition to the immediate
|
||||
* speed bonus). Without this force turning to correct the direction
|
||||
* after skidding will use up nearly all of the additional speed (turning
|
||||
* reduces the forward engine impulse) */
|
||||
std::vector<float> m_skid_bonus_force;
|
||||
|
||||
/** A factor is used to reduce the amount of steering while skidding. This
|
||||
* is the minimum factor used (i.e. resulting in the largest turn
|
||||
* radius). */
|
||||
float m_skid_reduce_turn_min;
|
||||
|
||||
/** A factor is used to reduce the amount of steering while skidding. This
|
||||
* is the maximum factor used (i.e. resulting in the smallest turn
|
||||
* radius). */
|
||||
float m_skid_reduce_turn_max;
|
||||
|
||||
|
||||
/** Kart leaves skid marks. */
|
||||
bool m_has_skidmarks;
|
||||
|
||||
/** Used to check that all values are defined in the xml file. */
|
||||
static float UNDEFINED;
|
||||
|
||||
public:
|
||||
|
||||
SkiddingProperties();
|
||||
void load(const XMLNode *skid_node);
|
||||
void copyFrom(const SkiddingProperties *destination);
|
||||
void checkAllSet(const std::string &filename) const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns if the kart leaves skidmarks or not. */
|
||||
bool hasSkidmarks() const { return m_has_skidmarks; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the maximum factor by which the steering angle
|
||||
* can be increased. */
|
||||
float getMaxSkid() const {return m_skid_max; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns additional rotation of 3d model when skidding. */
|
||||
float getSkidVisual () const {return m_skid_visual; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the time for the visual skid to reach maximum. */
|
||||
float getSkidVisualTime () const {return m_skid_visual_time; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a factor to be used to determine how much the chassis of a
|
||||
* kart should rotate to match the graphical view. A factor of 1 is
|
||||
* identical, a smaller factor will rotate the kart less (which might
|
||||
* feel better). */
|
||||
float getPostSkidRotateFactor () const {return m_post_skid_rotate_factor;}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the factor by which to recude the amount of steering while
|
||||
skidding. */
|
||||
float getSkidReduceTurnMin () const { return m_skid_reduce_turn_min; }
|
||||
// ------------------------------------------------------------------------
|
||||
float getSkidReduceTurnMax () const { return m_skid_reduce_turn_max; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how many boni are defined for this kart. */
|
||||
int getNumberOfBonusTimes() const { return (int) m_skid_bonus_time.size(); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how long a kart must skid in order to reach the specified
|
||||
* bonus level.
|
||||
* param n Bonus level (0<=n<m_skid_bonus_time.size())
|
||||
*/
|
||||
float getTimeTillBonus(unsigned int n) const
|
||||
{ return m_skid_time_till_bonus[n]; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
}; // SkiddingProperties
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* EOF */
|
||||
|
Loading…
Reference in New Issue
Block a user