Moved pointer to last material from kart to terrain_info.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6602 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-11-16 09:23:18 +00:00
parent d877c8b829
commit 9bed1f01c5
4 changed files with 17 additions and 12 deletions

View File

@ -441,7 +441,7 @@ void Kart::reset()
m_skidding = 1.0f;
m_time_last_crash = 0.0f;
m_slipstream_mode = SS_NONE;
m_last_material = NULL;
if(m_terrain_sound)
{
sfx_manager->deleteSFX(m_terrain_sound);
@ -808,7 +808,7 @@ void Kart::update(float dt)
// In case that three sfx needed to be played (i.e. a previous is
// playing, a current is playing, and a new terrain with sfx is
// entered), the oldest (previous) sfx is stopped and deleted.
if(m_last_material!=material)
if(getLastMaterial()!=material)
{
// First stop any previously playing terrain sound
// and remove it, sp that m_previous_terrain_sound
@ -845,7 +845,6 @@ void Kart::update(float dt)
m_terrain_sound->position(getXYZ());
material->setSFXSpeed(m_terrain_sound, m_speed);
}
m_last_material = material;
if (material->isReset() && isOnGround()) forceRescue();
else if(material->isZipper() && isOnGround()) handleZipper(material);

View File

@ -194,10 +194,6 @@ private:
SFXBase *m_goo_sound;
float m_time_last_crash;
/** Stores the last material, used to detect if a kart enteres a new
* terrain and might stop/start terrain specific sfx. */
const Material *m_last_material;
float handleSlipstream(float dt);
void updatePhysics(float dt);

View File

@ -28,8 +28,9 @@
TerrainInfo::TerrainInfo(int frequency)
{
m_HoT_frequency=frequency;
m_HoT_counter=frequency;
m_HoT_frequency = frequency;
m_HoT_counter = frequency;
m_last_material = NULL;
}
//-----------------------------------------------------------------------------
@ -46,6 +47,7 @@ void TerrainInfo::update(const Vec3& pos)
m_HoT_counter++;
if(m_HoT_counter>=m_HoT_frequency)
{
m_last_material = m_material;
World::getWorld()->getTrack()->getTerrainInfo(pos, &m_HoT,
&m_normal, &m_material);
m_normal.normalize();

View File

@ -34,6 +34,7 @@ private:
int m_HoT_counter; // compute HAT only every N timesteps
Vec3 m_normal; // normal of the triangle under the object
const Material *m_material; // material of the triangle under the object
const Material *m_last_material; // the previous material a kart was on
float m_HoT; // height of terrain
public:
@ -43,9 +44,16 @@ public:
virtual void update(const Vec3 &pos);
float getHoT() const {return m_HoT; }
const Material *getMaterial() const {return m_material;}
const Vec3 &getNormal() const {return m_normal; }
/** Returns the height above the terrain. */
float getHoT() const {return m_HoT; }
/** Returns the current material the kart is on. */
const Material *getMaterial() const {return m_material; }
/** Returns the previous material the kart was one (which might be
* the same as getMaterial() ). */
const Material *getLastMaterial() const {return m_last_material;}
/** Returns the normal of the terrain the kart is on. */
const Vec3 &getNormal() const {return m_normal; }
/** Returns the pitch of the terrain depending on the heading. */
float getTerrainPitch(float heading) const;
}; // TerrainInfo