Simplify code by using the kart's normal.
This commit is contained in:
@@ -390,6 +390,10 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void crashed(const Material *m, const Vec3 &normal) = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the normal of the terrain the kart is over atm. This is
|
||||
* defined even if the kart is flying. */
|
||||
virtual const Vec3& getNormal() const = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the height of the terrain. we're currently above */
|
||||
virtual float getHoT() const = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@@ -374,7 +374,7 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if the kart is close to the ground, used to dis/enable
|
||||
* the upright constraint to allow for more realistic explosions. */
|
||||
bool isNearGround () const;
|
||||
bool isNearGround() const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if the kart is eliminated. */
|
||||
virtual bool isEliminated() const { return m_eliminated; }
|
||||
@@ -419,6 +419,10 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void setOnScreenText(const wchar_t *text);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the normal of the terrain the kart is over atm. This is
|
||||
* defined even if the kart is flying. */
|
||||
virtual const Vec3& getNormal() const {return m_terrain_info->getNormal();}
|
||||
// ------------------------------------------------------------------------
|
||||
/** For debugging only: check if a kart is flying. */
|
||||
bool isFlying() const { return m_flying; }
|
||||
}; // Kart
|
||||
|
||||
@@ -112,10 +112,8 @@ RescueAnimation::~RescueAnimation()
|
||||
*/
|
||||
void RescueAnimation::update(float dt)
|
||||
{
|
||||
|
||||
//m_xyz.setY(m_xyz.getY() + dt*m_velocity);
|
||||
btQuaternion q1 = m_kart->getTrans().getRotation();
|
||||
m_xyz = m_xyz + dt*m_velocity*(Vec3(0, 1, 0).rotate(q1.getAxis(), q1.getAngle()));
|
||||
m_xyz += dt*m_velocity * m_kart->getNormal();
|
||||
m_kart->setXYZ(m_xyz);
|
||||
m_curr_rotation += dt*m_add_rotation;
|
||||
btQuaternion q(m_curr_rotation.getHeading(), m_curr_rotation.getPitch(),
|
||||
|
||||
@@ -715,9 +715,7 @@ void World::moveKartTo(AbstractKart* kart, const btTransform &transform)
|
||||
btQuaternion rot = pos.getRotation();
|
||||
|
||||
// Move the kart
|
||||
Vec3 xyz = pos.getOrigin() + btVector3(0, 0.5f*kart->getKartHeight(),0.0f).
|
||||
rotate(rot.getAxis(),rot.getAngle());
|
||||
|
||||
Vec3 xyz = pos.getOrigin() + 0.5f*kart->getKartHeight() * kart->getNormal();
|
||||
pos.setOrigin(xyz);
|
||||
kart->setXYZ(xyz);
|
||||
kart->setRotation(pos.getRotation());
|
||||
|
||||
Reference in New Issue
Block a user