1) Fixed the incorrect early explosion of the plunger.
2) Fixed the fact that a plunger would not explode 'normally' when hitting the track. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2562 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
0723e095fd
commit
f9fc764893
@ -102,7 +102,7 @@ public:
|
||||
|
||||
virtual void hitTrack () {};
|
||||
void explode (Kart* kart, MovingPhysics* moving_physics=NULL);
|
||||
bool hasHit () { return m_has_hit_something; }
|
||||
bool hasHit () { return m_has_hit_something; }
|
||||
void reset () { Moveable::reset(); }
|
||||
}; // Flyable
|
||||
|
||||
|
@ -33,7 +33,8 @@ public:
|
||||
~Plunger();
|
||||
static void init (const lisp::Lisp* lisp, ssgEntity* missile);
|
||||
virtual void update (float dt);
|
||||
virtual void hitTrack () { explode(NULL); }
|
||||
|
||||
}; // Missile
|
||||
}; // Plunger
|
||||
|
||||
#endif
|
||||
|
@ -86,27 +86,29 @@ void RubberBand::removeFromScene()
|
||||
*/
|
||||
void RubberBand::update(float dt)
|
||||
{
|
||||
const Vec3 &p=m_plunger->getXYZ();
|
||||
const Vec3 &k=m_kart.getXYZ();
|
||||
// Don't do anything for plungers who already hit something.
|
||||
if(m_plunger->hasHit()) return;
|
||||
|
||||
Vec3 diff=p-k;
|
||||
const Vec3 &p = m_plunger->getXYZ();
|
||||
const Vec3 &k = m_kart.getXYZ();
|
||||
|
||||
// See if anything hits the rubber band, but only if there is a certain
|
||||
// distance between plunger and kart. Otherwise the raycast will either
|
||||
// hit the kart or the plunger.
|
||||
if(diff.length2()>2.0f)
|
||||
btCollisionWorld::ClosestRayResultCallback ray_callback(k, p);
|
||||
// Disable raycast collision detection for this plunger and this kart!
|
||||
short int old_plunger_group = m_plunger->getBody()->getBroadphaseHandle()->m_collisionFilterGroup;
|
||||
short int old_kart_group = m_kart.getBody()->getBroadphaseHandle()->m_collisionFilterGroup;
|
||||
m_plunger->getBody()->getBroadphaseHandle()->m_collisionFilterGroup = 0;
|
||||
m_kart.getBody()->getBroadphaseHandle()->m_collisionFilterGroup = 0;
|
||||
|
||||
// Do the raycast
|
||||
RaceManager::getWorld()->getPhysics()->getPhysicsWorld()->rayTest(k, p,
|
||||
ray_callback);
|
||||
// Reset collision groups
|
||||
m_plunger->getBody()->getBroadphaseHandle()->m_collisionFilterGroup = old_plunger_group;
|
||||
m_kart.getBody()->getBroadphaseHandle()->m_collisionFilterGroup = old_kart_group;
|
||||
if(ray_callback.HasHit())
|
||||
{
|
||||
diff.normalize();
|
||||
const Vec3 from=k+diff; // this could be made dependent on kart length
|
||||
const Vec3 to = p-diff;
|
||||
btCollisionWorld::ClosestRayResultCallback ray_callback(from, to);
|
||||
RaceManager::getWorld()->getPhysics()->getPhysicsWorld()->rayTest(from,
|
||||
to, ray_callback);
|
||||
if(ray_callback.HasHit())
|
||||
{
|
||||
m_plunger->explode(NULL);
|
||||
return;
|
||||
}
|
||||
m_plunger->explode(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise set the new coordinates for the plunger and the kart:
|
||||
|
Loading…
x
Reference in New Issue
Block a user