Added support for animated physical objects to trigger a reset
of a kart on collision. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9924 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
d957436771
commit
a354f5521d
@ -39,6 +39,8 @@
|
||||
ThreeDAnimation::ThreeDAnimation(const XMLNode &node)
|
||||
: AnimationBase(node)
|
||||
{
|
||||
m_crash_reset = false;
|
||||
node.get("reset", &m_crash_reset);
|
||||
m_triangle_mesh = NULL;
|
||||
|
||||
/** Save the initial position and rotation in the base animation object. */
|
||||
|
@ -53,6 +53,10 @@ private:
|
||||
|
||||
/** Non-null only if the shape is exact */
|
||||
TriangleMesh *m_triangle_mesh;
|
||||
|
||||
/** True if a collision with this object should trigger
|
||||
* rescuing a kart. */
|
||||
bool m_crash_reset;
|
||||
|
||||
/** We have to store the rotation value as computed in blender, since
|
||||
* irrlicht uses a different order, so for rotation animations we
|
||||
@ -65,6 +69,10 @@ public:
|
||||
ThreeDAnimation(const XMLNode &node);
|
||||
virtual ~ThreeDAnimation();
|
||||
virtual void update(float dt);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if a collision with this object should
|
||||
* trigger a rescue. */
|
||||
bool isCrashReset() const { return m_crash_reset; }
|
||||
|
||||
}; // ThreeDAnimation
|
||||
#endif
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "physics/physics.hpp"
|
||||
|
||||
#include "animations/three_d_animation.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "network/race_state.hpp"
|
||||
#include "graphics/stars.hpp"
|
||||
@ -143,7 +144,18 @@ void Physics::update(float dt)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(p->a->is(UserPointer::UP_ANIMATION))
|
||||
{
|
||||
// Kart hits animation
|
||||
ThreeDAnimation *anim=p->a->getPointerAnimation();
|
||||
if(anim->isCrashReset())
|
||||
{
|
||||
Kart *kart = p->b->getPointerKart();
|
||||
kart->forceRescue();
|
||||
}
|
||||
continue;
|
||||
|
||||
}
|
||||
// now the first object must be a projectile
|
||||
// =========================================
|
||||
if(p->b->is(UserPointer::UP_TRACK))
|
||||
@ -363,6 +375,8 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies,
|
||||
else if(upB->is(UserPointer::UP_PHYSICAL_OBJECT))
|
||||
// 2.3 kart hits physical object
|
||||
m_all_collisions.push_back(upB, upA);
|
||||
else if(upB->is(UserPointer::UP_ANIMATION))
|
||||
m_all_collisions.push_back(upB, upA);
|
||||
}
|
||||
// 3) object is a projectile
|
||||
// =========================
|
||||
@ -389,6 +403,11 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies,
|
||||
else if(upB->is(UserPointer::UP_KART))
|
||||
m_all_collisions.push_back(upA, upB);
|
||||
}
|
||||
else if (upA->is(UserPointer::UP_ANIMATION))
|
||||
{
|
||||
if(upB->is(UserPointer::UP_KART))
|
||||
m_all_collisions.push_back(upA, upB);
|
||||
}
|
||||
else assert("Unknown user pointer"); // 4) Should never happen
|
||||
} // for i<numManifolds
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user