Fixed problem with distance in my previous commit
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14816 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -134,17 +134,13 @@ void OverWorld::update(float dt)
|
||||
continue;
|
||||
|
||||
Vec3 m_garage_pos = obj->getPosition();
|
||||
float m_distance = obj->getDistance();
|
||||
|
||||
AbstractKart* m_kart = getKart(0);
|
||||
Vec3 m_kart_pos = m_kart->getXYZ();
|
||||
//~ float kart_len = m_kart->getKartModel()->getLength();
|
||||
Vec3 m_kart_pos = getKart(0)->getXYZ();
|
||||
|
||||
//~ printf("%f\n", (m_garage_pos-m_kart_pos).length2_2d());
|
||||
//~ printf("%f\n", kart_len);
|
||||
|
||||
//TODO: Compare distance between garage and kart with for example length
|
||||
// of the kart or distance of object defined in scene.xml
|
||||
if ((m_garage_pos-m_kart_pos).length2_2d() > CHALLENGE_DISTANCE_SQUARED*3)
|
||||
// Distance should be written as m_distance*m_distance. Look at
|
||||
// m_distance_2 variable in item.cpp file.
|
||||
if ((m_garage_pos-m_kart_pos).length2_2d() > m_distance*m_distance)
|
||||
{
|
||||
obj->reset();
|
||||
}
|
||||
|
||||
@@ -103,6 +103,7 @@ void TrackObject::init(const XMLNode &xml_node, LODNode* lod_node)
|
||||
xml_node.get("soccer_ball", &m_soccer_ball);
|
||||
|
||||
m_garage = false;
|
||||
m_distance = 0;
|
||||
|
||||
std::string type;
|
||||
xml_node.get("type", &type );
|
||||
@@ -126,6 +127,7 @@ void TrackObject::init(const XMLNode &xml_node, LODNode* lod_node)
|
||||
{
|
||||
std::string m_action;
|
||||
xml_node.get("action", &m_action);
|
||||
xml_node.get("distance", &m_distance);
|
||||
if (m_action == "garage")
|
||||
{
|
||||
m_garage = true;
|
||||
|
||||
@@ -75,6 +75,8 @@ protected:
|
||||
bool m_soccer_ball;
|
||||
|
||||
bool m_garage;
|
||||
|
||||
float m_distance;
|
||||
|
||||
PhysicalObject* m_rigid_body;
|
||||
|
||||
@@ -109,6 +111,7 @@ public:
|
||||
|
||||
bool isSoccerBall() const { return m_soccer_ball; }
|
||||
bool isGarage() const { return m_garage; }
|
||||
float getDistance() const { return m_distance; }
|
||||
|
||||
const PhysicalObject* getPhysics() const { return m_rigid_body; }
|
||||
PhysicalObject* getPhysics() { return m_rigid_body; }
|
||||
|
||||
Reference in New Issue
Block a user