Fixed disappearing rubber ball on steep slopes (like the ramp
in sand track). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9555 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -130,6 +130,7 @@ Flyable::Flyable(Kart *kart, PowerupManager::PowerupType type, float mass)
|
||||
m_mass = mass;
|
||||
m_adjust_up_velocity = true;
|
||||
m_time_since_thrown = 0;
|
||||
m_position_offset = Vec3(0,0,0);
|
||||
m_owner_has_temporary_immunity = true;
|
||||
m_max_lifespan = -1;
|
||||
|
||||
@@ -397,7 +398,10 @@ void Flyable::update(float dt)
|
||||
return;
|
||||
}
|
||||
|
||||
TerrainInfo::update(xyz);
|
||||
// Add the position offset so that the flyable can adjust its position
|
||||
// (usually to do the raycast from a slightly higher position to avoid
|
||||
// problems finding the terrain in steep uphill sections).
|
||||
TerrainInfo::update(xyz+m_position_offset);
|
||||
|
||||
if(m_adjust_up_velocity)
|
||||
{
|
||||
|
||||
@@ -51,11 +51,18 @@ private:
|
||||
* It can happen that more than one collision between a rocket and
|
||||
* a track or kart is reported by the physics. */
|
||||
bool m_exploded;
|
||||
|
||||
/** If this flag is set, the up velocity of the kart will not be
|
||||
* adjusted in case that the objects is too high or too low above the
|
||||
* terrain. Otherwise gravity will not work correctly on this object. */
|
||||
bool m_adjust_up_velocity;
|
||||
|
||||
/** An offset that is added when doing the raycast for terrain. This
|
||||
* is useful in case that the position of the object is just under
|
||||
* the terrain (perhaps due to floating point errors), and would
|
||||
* otherwise result in an invalid terrain. */
|
||||
Vec3 m_position_offset;
|
||||
|
||||
protected:
|
||||
/** Kart which shot this flyable. */
|
||||
Kart* m_owner;
|
||||
@@ -144,27 +151,50 @@ public:
|
||||
Flyable (Kart* kart, PowerupManager::PowerupType type,
|
||||
float mass=1.0f);
|
||||
virtual ~Flyable ();
|
||||
/** Enables/disables adjusting ov velocity depending on height above
|
||||
* terrain. Missiles can 'follow the terrain' with this adjustment,
|
||||
* but gravity will basically be disabled. */
|
||||
void setAdjustUpVelocity(bool f) { m_adjust_up_velocity = f; }
|
||||
static void init (const XMLNode &node, scene::IMesh *model,
|
||||
PowerupManager::PowerupType type);
|
||||
virtual void update (float);
|
||||
void updateFromServer(const FlyableInfo &f, float dt);
|
||||
bool isOwnerImmunity(const Kart *kart_hit) const;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** If true the up velocity of the flyable will be adjust so that the
|
||||
* flyable stays at a height close to the average height.
|
||||
* \param f True if the up velocity should be adjusted. */
|
||||
void setAdjustUpVelocity(bool f) { m_adjust_up_velocity = f; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the offset to be used when determining the terrain under the
|
||||
* flyable. This needs to be used in case that an object might be just
|
||||
* under the actual terrain (e.g. rubber ball on a steep uphill slope). */
|
||||
void setPositionOffset(const Vec3 &o) {m_position_offset = o; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Called when this flyable hits the track. */
|
||||
virtual void hitTrack () {};
|
||||
// ------------------------------------------------------------------------
|
||||
/** Called when this flyable hit a kart or physical object.
|
||||
* \param kart Pointer to the kart hit (NULL if no kart was hit).
|
||||
* \param obj Pointer to the object hit (NULL if no object was hit). */
|
||||
virtual void hit (Kart* kart, PhysicalObject* obj=NULL);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Enables/disables adjusting ov velocity depending on height above
|
||||
* terrain. Missiles can 'follow the terrain' with this adjustment,
|
||||
* but gravity will basically be disabled. */
|
||||
bool hasHit () { return m_has_hit_something; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Indicates that something was hit and that this object must
|
||||
* be removed. */
|
||||
void setHasHit () { m_has_hit_something = true; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Resets this flyable. */
|
||||
void reset () { Moveable::reset(); }
|
||||
bool isOwnerImmunity(const Kart *kart_hit) const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the type of flyable. */
|
||||
PowerupManager::PowerupType
|
||||
getType() const {return m_type;}
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the sfx that should be played in case of an explosion. */
|
||||
virtual const char* getExplosionSound() const { return "explosion"; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Indicates if an explosion needs to be added if this flyable
|
||||
* is removed. */
|
||||
virtual bool needsExplosion() const {return true;}
|
||||
|
||||
@@ -34,6 +34,10 @@ RubberBall::RubberBall(Kart *kart)
|
||||
: Flyable(kart, PowerupManager::POWERUP_RUBBERBALL, 0.0f /* mass */),
|
||||
TrackSector()
|
||||
{
|
||||
// The rubber ball often misses the terrain on steep uphill slopes, e.g.
|
||||
// the ramp in sand track. Add an Y offset so that the terrain raycast
|
||||
// will always be done from a position high enough to avoid this.
|
||||
setPositionOffset(Vec3(0, 1.0f, 0));
|
||||
float forw_offset = 0.5f*kart->getKartLength() + m_extend.getZ()*0.5f+5.0f;
|
||||
|
||||
createPhysics(forw_offset, btVector3(0.0f, 0.0f, m_speed*2),
|
||||
|
||||
Reference in New Issue
Block a user