Fixed #2742 - incorrect triggering if cannon line triggereed Caused
by not updating m_front_xyz when moving the kart (so an incorrect position was used to detect checkline triggering).
This commit is contained in:
parent
4506f4baed
commit
b5f285a182
@ -427,6 +427,14 @@ void Kart::reset()
|
|||||||
|
|
||||||
} // reset
|
} // reset
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
void Kart::setXYZ(const Vec3& a)
|
||||||
|
{
|
||||||
|
AbstractKart::setXYZ(a);
|
||||||
|
Vec3 front(0, 0, getKartLength()*0.5f);
|
||||||
|
m_xyz_front = getTrans()(front);
|
||||||
|
} // setXYZ
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
void Kart::increaseMaxSpeed(unsigned int category, float add_speed,
|
void Kart::increaseMaxSpeed(unsigned int category, float add_speed,
|
||||||
float engine_force, float duration,
|
float engine_force, float duration,
|
||||||
|
@ -286,6 +286,7 @@ public:
|
|||||||
|
|
||||||
virtual bool playCustomSFX (unsigned int type);
|
virtual bool playCustomSFX (unsigned int type);
|
||||||
virtual void setController(Controller *controller);
|
virtual void setController(Controller *controller);
|
||||||
|
virtual void setXYZ(const Vec3& a);
|
||||||
|
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
// Powerup related functions.
|
// Powerup related functions.
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
virtual void stopFlying();
|
virtual void stopFlying();
|
||||||
|
|
||||||
/** Sets the XYZ coordinates of the moveable. */
|
/** Sets the XYZ coordinates of the moveable. */
|
||||||
void setXYZ(const Vec3& a)
|
virtual void setXYZ(const Vec3& a)
|
||||||
{
|
{
|
||||||
m_transform.setOrigin(a);
|
m_transform.setOrigin(a);
|
||||||
if(m_motion_state)
|
if(m_motion_state)
|
||||||
|
@ -781,6 +781,7 @@ void World::moveKartTo(AbstractKart* kart, const btTransform &transform)
|
|||||||
// Project kart to surface of track
|
// Project kart to surface of track
|
||||||
// This will set the physics transform
|
// This will set the physics transform
|
||||||
Track::getCurrentTrack()->findGround(kart);
|
Track::getCurrentTrack()->findGround(kart);
|
||||||
|
CheckManager::get()->resetAfterKartMove(kart);
|
||||||
|
|
||||||
} // moveKartTo
|
} // moveKartTo
|
||||||
|
|
||||||
|
@ -137,6 +137,13 @@ void CheckLine::reset(const Track &track)
|
|||||||
}
|
}
|
||||||
} // reset
|
} // reset
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void CheckLine::resetAfterKartMove(unsigned int kart_index)
|
||||||
|
{
|
||||||
|
AbstractKart *kart = World::getWorld()->getKart(kart_index);
|
||||||
|
m_previous_position[kart_index] = kart->getXYZ();
|
||||||
|
} // resetAfterKartMove
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void CheckLine::changeDebugColor(bool is_active)
|
void CheckLine::changeDebugColor(bool is_active)
|
||||||
{
|
{
|
||||||
@ -167,7 +174,7 @@ void CheckLine::changeDebugColor(bool is_active)
|
|||||||
* additional data.
|
* additional data.
|
||||||
*/
|
*/
|
||||||
bool CheckLine::isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
|
bool CheckLine::isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
|
||||||
unsigned int kart_index)
|
unsigned int kart_index)
|
||||||
{
|
{
|
||||||
World* w = World::getWorld();
|
World* w = World::getWorld();
|
||||||
core::vector2df p=new_pos.toIrrVector2d();
|
core::vector2df p=new_pos.toIrrVector2d();
|
||||||
|
@ -77,6 +77,7 @@ public:
|
|||||||
virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
|
virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
|
||||||
unsigned int indx);
|
unsigned int indx);
|
||||||
virtual void reset(const Track &track);
|
virtual void reset(const Track &track);
|
||||||
|
virtual void resetAfterKartMove(unsigned int kart_index);
|
||||||
virtual void changeDebugColor(bool is_active);
|
virtual void changeDebugColor(bool is_active);
|
||||||
/** Returns the actual line data for this checkpoint. */
|
/** Returns the actual line data for this checkpoint. */
|
||||||
const core::line2df &getLine2D() const {return m_line;}
|
const core::line2df &getLine2D() const {return m_line;}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "io/xml_node.hpp"
|
#include "io/xml_node.hpp"
|
||||||
|
#include "karts/abstract_kart.hpp"
|
||||||
#include "tracks/ambient_light_sphere.hpp"
|
#include "tracks/ambient_light_sphere.hpp"
|
||||||
#include "tracks/check_cannon.hpp"
|
#include "tracks/check_cannon.hpp"
|
||||||
#include "tracks/check_goal.hpp"
|
#include "tracks/check_goal.hpp"
|
||||||
@ -117,6 +118,19 @@ void CheckManager::reset(const Track &track)
|
|||||||
(*i)->reset(track);
|
(*i)->reset(track);
|
||||||
} // reset
|
} // reset
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Called after a kart is moved (e.g. after a rescue) to reset any cached
|
||||||
|
* check information. Without this an incorrect crossing of a checkline
|
||||||
|
* could be triggered since a CheckLine stores the previous position).
|
||||||
|
* \param kart_index Index of the kart that was moved.
|
||||||
|
*/
|
||||||
|
void CheckManager::resetAfterKartMove(AbstractKart *kart)
|
||||||
|
{
|
||||||
|
std::vector<CheckStructure*>::iterator i;
|
||||||
|
for (i = m_all_checks.begin(); i != m_all_checks.end(); i++)
|
||||||
|
(*i)->resetAfterKartMove(kart->getWorldKartId());
|
||||||
|
} // resetAfterKartMove
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Updates all animations. Called one per time step.
|
/** Updates all animations. Called one per time step.
|
||||||
* \param dt Time since last call.
|
* \param dt Time since last call.
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
class AbstractKart;
|
||||||
class CheckStructure;
|
class CheckStructure;
|
||||||
class Track;
|
class Track;
|
||||||
class XMLNode;
|
class XMLNode;
|
||||||
@ -48,6 +49,7 @@ public:
|
|||||||
void load(const XMLNode &node);
|
void load(const XMLNode &node);
|
||||||
void update(float dt);
|
void update(float dt);
|
||||||
void reset(const Track &track);
|
void reset(const Track &track);
|
||||||
|
void resetAfterKartMove(AbstractKart *kart);
|
||||||
unsigned int getLapLineIndex() const;
|
unsigned int getLapLineIndex() const;
|
||||||
int getChecklineTriggering(const Vec3 &from, const Vec3 &to) const;
|
int getChecklineTriggering(const Vec3 &from, const Vec3 &to) const;
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
@ -105,6 +105,7 @@ public:
|
|||||||
CheckStructure(const XMLNode &node, unsigned int index);
|
CheckStructure(const XMLNode &node, unsigned int index);
|
||||||
virtual ~CheckStructure() {};
|
virtual ~CheckStructure() {};
|
||||||
virtual void update(float dt);
|
virtual void update(float dt);
|
||||||
|
virtual void resetAfterKartMove(unsigned int kart_index) {};
|
||||||
virtual void changeDebugColor(bool is_active) {}
|
virtual void changeDebugColor(bool is_active) {}
|
||||||
/** True if going from old_pos to new_pos crosses this checkline. This function
|
/** True if going from old_pos to new_pos crosses this checkline. This function
|
||||||
* is called from update (of the checkline structure).
|
* is called from update (of the checkline structure).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user