From: <hik...@us...> - 2009-12-17 23:45:49
|
Revision: 4319 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4319&view=rev Author: hikerstk Date: 2009-12-17 23:45:42 +0000 (Thu, 17 Dec 2009) Log Message: ----------- Removed more tabs. Modified Paths: -------------- main/trunk/src/tracks/ambient_light_sphere.hpp main/trunk/src/tracks/bezier_curve.hpp main/trunk/src/tracks/check_line.hpp main/trunk/src/tracks/check_manager.hpp main/trunk/src/tracks/check_sphere.hpp main/trunk/src/tracks/check_structure.hpp Modified: main/trunk/src/tracks/ambient_light_sphere.hpp =================================================================== --- main/trunk/src/tracks/ambient_light_sphere.hpp 2009-12-17 23:42:50 UTC (rev 4318) +++ main/trunk/src/tracks/ambient_light_sphere.hpp 2009-12-17 23:45:42 UTC (rev 4319) @@ -46,7 +46,7 @@ * inner radius. */ video::SColor m_ambient_color; public: - AmbientLightSphere(CheckManager *check_manager, + AmbientLightSphere(CheckManager *check_manager, const XMLNode &node); virtual ~AmbientLightSphere() {}; virtual void update(float dt); Modified: main/trunk/src/tracks/bezier_curve.hpp =================================================================== --- main/trunk/src/tracks/bezier_curve.hpp 2009-12-17 23:42:50 UTC (rev 4318) +++ main/trunk/src/tracks/bezier_curve.hpp 2009-12-17 23:45:42 UTC (rev 4319) @@ -31,29 +31,29 @@ class BezierCurve { private: - /** A data structure to store one bezier control point and - * the two handles. */ - struct BezierData - { - /** The control point. */ - Vec3 m_control_point; - /** First handle, i.e. the one towards the previous point. */ - Vec3 m_handle1; - /** Second handle, i.e. the one towards the next point. */ - Vec3 m_handle2; - }; // BezierData + /** A data structure to store one bezier control point and + * the two handles. */ + struct BezierData + { + /** The control point. */ + Vec3 m_control_point; + /** First handle, i.e. the one towards the previous point. */ + Vec3 m_handle1; + /** Second handle, i.e. the one towards the next point. */ + Vec3 m_handle2; + }; // BezierData - /** Overall duration. */ - float m_time; + /** Overall duration. */ + float m_time; - /** Vector with all control points and handles. */ - std::vector<BezierData> m_all_data; + /** Vector with all control points and handles. */ + std::vector<BezierData> m_all_data; public: - BezierCurve(const XMLNode &node); - Vec3 getXYZ(float t) const; - Vec3 getHPR(float t) const; + BezierCurve(const XMLNode &node); + Vec3 getXYZ(float t) const; + Vec3 getHPR(float t) const; - /** Returns the number of points in this bezier curve. */ - unsigned int getNumPoints() const {return m_all_data.size(); } + /** Returns the number of points in this bezier curve. */ + unsigned int getNumPoints() const {return m_all_data.size(); } }; // BezierCurve #endif Modified: main/trunk/src/tracks/check_line.hpp =================================================================== --- main/trunk/src/tracks/check_line.hpp 2009-12-17 23:42:50 UTC (rev 4318) +++ main/trunk/src/tracks/check_line.hpp 2009-12-17 23:45:42 UTC (rev 4319) @@ -38,18 +38,18 @@ class CheckLine : public CheckStructure { private: - /** The line that is tested for being crossed. */ + /** The line that is tested for being crossed. */ core::line2df m_line; - /** The minimum height of the checkline. */ - float m_min_height; + /** The minimum height of the checkline. */ + float m_min_height; /** Stores the sign (i.e. side) of the previous line to save some * computations. True if the value is >=0, i.e. the point is on * or to the right of the line. */ std::vector<bool> m_previous_sign; public: - CheckLine(CheckManager *check_manager, const XMLNode &node); + CheckLine(CheckManager *check_manager, const XMLNode &node); virtual ~CheckLine() {}; virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int indx); virtual void reset(const Track &track); Modified: main/trunk/src/tracks/check_manager.hpp =================================================================== --- main/trunk/src/tracks/check_manager.hpp 2009-12-17 23:42:50 UTC (rev 4318) +++ main/trunk/src/tracks/check_manager.hpp 2009-12-17 23:45:42 UTC (rev 4319) @@ -30,11 +30,11 @@ class CheckManager { private: - std::vector<CheckStructure*> m_all_checks; + std::vector<CheckStructure*> m_all_checks; public: - CheckManager(const XMLNode &node, Track *track); - void update(float dt); - void reset(const Track &track); + CheckManager(const XMLNode &node, Track *track); + void update(float dt); + void reset(const Track &track); /** Returns the nth. check structure. */ CheckStructure *getCheckStructure(unsigned int n) { return m_all_checks[n]; } Modified: main/trunk/src/tracks/check_sphere.hpp =================================================================== --- main/trunk/src/tracks/check_sphere.hpp 2009-12-17 23:42:50 UTC (rev 4318) +++ main/trunk/src/tracks/check_sphere.hpp 2009-12-17 23:45:42 UTC (rev 4319) @@ -47,7 +47,7 @@ * This saves some computations. */ std::vector<float> m_distance2; public: - CheckSphere(CheckManager *check_manager, const XMLNode &node); + CheckSphere(CheckManager *check_manager, const XMLNode &node); virtual ~CheckSphere() {}; virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int kart_id); Modified: main/trunk/src/tracks/check_structure.hpp =================================================================== --- main/trunk/src/tracks/check_structure.hpp 2009-12-17 23:42:50 UTC (rev 4318) +++ main/trunk/src/tracks/check_structure.hpp 2009-12-17 23:45:42 UTC (rev 4319) @@ -60,7 +60,7 @@ enum CheckType {CT_NEW_LAP, CT_ACTIVATE, CT_TOGGLE, CT_AMBIENT_SPHERE}; protected: - /** Stores the previous position of all karts. This is needed to detect + /** Stores the previous position of all karts. This is needed to detect * when e.g. a check point is reached the first time, or a checkline is * crossed. */ std::vector<Vec3> m_previous_position; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-01-07 01:14:56
|
Revision: 4405 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4405&view=rev Author: hikerstk Date: 2010-01-07 01:14:46 +0000 (Thu, 07 Jan 2010) Log Message: ----------- Fixed memory leaks due to missing destructor. Modified Paths: -------------- main/trunk/src/tracks/track_object_manager.cpp main/trunk/src/tracks/track_object_manager.hpp Modified: main/trunk/src/tracks/track_object_manager.cpp =================================================================== --- main/trunk/src/tracks/track_object_manager.cpp 2010-01-06 16:48:06 UTC (rev 4404) +++ main/trunk/src/tracks/track_object_manager.cpp 2010-01-07 01:14:46 UTC (rev 4405) @@ -29,6 +29,15 @@ } // TrackObjectManager // ---------------------------------------------------------------------------- +TrackObjectManager::~TrackObjectManager() +{ + for(unsigned int i=0; i<m_all_objects.size(); i++) + { + delete m_all_objects[i]; + } +} // ~TrackObjectManager + +// ---------------------------------------------------------------------------- /** Adds an object to the track object manager. The type to add is specified * in the xml_node. */ Modified: main/trunk/src/tracks/track_object_manager.hpp =================================================================== --- main/trunk/src/tracks/track_object_manager.hpp 2010-01-06 16:48:06 UTC (rev 4404) +++ main/trunk/src/tracks/track_object_manager.hpp 2010-01-07 01:14:46 UTC (rev 4405) @@ -38,6 +38,7 @@ std::vector<TrackObject*> m_all_objects; public: TrackObjectManager(); + ~TrackObjectManager(); void add(const XMLNode &xml_node, const Track &track); void update(float dt); void handleExplosion(const Vec3 &pos, const PhysicalObject *mp) const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-02-01 11:34:26
|
Revision: 4598 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4598&view=rev Author: hikerstk Date: 2010-02-01 11:34:19 +0000 (Mon, 01 Feb 2010) Log Message: ----------- Items will now (as a default) be dropped to the ground. Modified Paths: -------------- main/trunk/src/tracks/track.cpp main/trunk/src/tracks/track.hpp Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2010-02-01 02:15:57 UTC (rev 4597) +++ main/trunk/src/tracks/track.cpp 2010-02-01 11:34:19 UTC (rev 4598) @@ -703,9 +703,15 @@ else if(name=="small-nitro") type = Item::ITEM_SILVER_COIN; else type = Item::ITEM_GOLD_COIN; Vec3 xyz; - int bits = node->getXYZ(&xyz); + // Set some kind of default in case Z is not defined in the file + // (with the new track exporter it always is defined anyway). + // Z is the height from which the item is dropped on the track. + xyz.setZ(1000); + node->getXYZ(&xyz); + bool drop=true; + node->get("drop", &drop); // Height is needed if bit 2 (for z) is not set - itemCommand(xyz, type, /* need_height */ !XMLNode::hasZ(bits) ); + itemCommand(xyz, type, drop); } else if (name=="start") { @@ -878,11 +884,11 @@ /** Handle creation and placement of an item. * \param xyz The position of the item. * \param type The item type. - * \param need_height True if the item Z position should be determined based on + * \param drop True if the item Z position should be determined based on * the track topology. */ void Track::itemCommand(const Vec3 &xyz, Item::ItemType type, - int need_height) + bool drop) { // Some modes (e.g. time trial) don't have any bonus boxes if(type==Item::ITEM_BONUS_BOX && @@ -891,9 +897,8 @@ Vec3 loc(xyz); // if only 2d coordinates are given, let the item fall from very high - if(need_height) + if(drop) { - loc.setZ(1000); loc.setZ(getTerrainHeight(loc)); } Modified: main/trunk/src/tracks/track.hpp =================================================================== --- main/trunk/src/tracks/track.hpp 2010-02-01 02:15:57 UTC (rev 4597) +++ main/trunk/src/tracks/track.hpp 2010-02-01 11:34:19 UTC (rev 4598) @@ -162,7 +162,7 @@ void loadTrackInfo(); void itemCommand(const Vec3 &xyz, Item::ItemType item_type, - int bNeedHeight); + bool drop); void loadQuadGraph(unsigned int mode_id); void convertTrackToBullet(const scene::IMesh *mesh, const scene::ISceneNode*node); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-03-15 09:20:14
|
Revision: 4998 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4998&view=rev Author: hikerstk Date: 2010-03-15 09:20:08 +0000 (Mon, 15 Mar 2010) Log Message: ----------- Removed unused functions. Modified Paths: -------------- main/trunk/src/tracks/quad_set.cpp main/trunk/src/tracks/quad_set.hpp Modified: main/trunk/src/tracks/quad_set.cpp =================================================================== --- main/trunk/src/tracks/quad_set.cpp 2010-03-15 05:09:26 UTC (rev 4997) +++ main/trunk/src/tracks/quad_set.cpp 2010-03-15 09:20:08 UTC (rev 4998) @@ -95,36 +95,3 @@ } // load // ----------------------------------------------------------------------------- -/** Returns wether a point is to the left or to the right of a line. - While all arguments are 3d, only the x and y coordinates are actually used. -*/ -float QuadSet::sideOfLine2D(const Vec3 &l1, const Vec3 &l2, const Vec3 &p) const -{ - return (l2.getX()-l1.getX())*(p.getZ()-l1.getZ()) - - (l2.getZ()-l1.getZ())*(p.getX()-l1.getX()); -} // sideOfLine - -// ----------------------------------------------------------------------------- -bool QuadSet::pointInQuad(const Quad& q, const btVector3& p) const { - if(sideOfLine2D(q[0], q[2], p)<0) { - return sideOfLine2D(q[0], q[1], p) > 0.0 && - sideOfLine2D(q[1], q[2], p) >= 0.0; - } else { - return sideOfLine2D(q[2], q[3], p) > 0.0 && - sideOfLine2D(q[3], q[0], p) >= 0.0; - } -} // pointInQuad - -// ----------------------------------------------------------------------------- -/** Determines the quad on which the position pos is. This is a rather slow - algorithm, used to get the initial quad position of a kart, but not for - constantly updating it. -*/ -int QuadSet::getQuadAtPos(const Vec3 &pos) const { - for(unsigned int i=0; i<m_all_quads.size(); i++) { - if(pointInQuad(*(m_all_quads[i]), pos)) return i; - } - return QUAD_NONE; -} // getQuadAtPos - -// ----------------------------------------------------------------------------- Modified: main/trunk/src/tracks/quad_set.hpp =================================================================== --- main/trunk/src/tracks/quad_set.hpp 2010-03-15 05:09:26 UTC (rev 4997) +++ main/trunk/src/tracks/quad_set.hpp 2010-03-15 09:20:08 UTC (rev 4998) @@ -38,19 +38,13 @@ void load (const std::string &filename); void getPoint(const XMLNode *xml, const std::string &attribute_name, Vec3 *result) const; - float sideOfLine2D(const Vec3 &l1, const Vec3 &l2, const Vec3 &p) const; public: static const int QUAD_NONE=-1; QuadSet (const std::string& filename); - int getQuadAtPos (const Vec3& p) const; const Quad& getQuad(int n) const {return *(m_all_quads[n]); } int getCurrentQuad(const Vec3& p, int oldQuad) const; - bool pointInQuad (const Quad& q, const btVector3& p) const; - /** Returns true if the point p is in the n-th. quad. */ - bool pointInQuad (int n, const btVector3& p) const - {return pointInQuad(*m_all_quads[n],p);} /** Return the minimum and maximum coordinates of this quad set. */ void getBoundingBox(Vec3 *min, Vec3 *max) { *min=m_min; *max=m_max; } /** Returns the number of quads. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-03-15 09:21:27
|
Revision: 4999 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4999&view=rev Author: hikerstk Date: 2010-03-15 09:21:21 +0000 (Mon, 15 Mar 2010) Log Message: ----------- Fixed potential incorrect order of karts when a kart is off track. Modified Paths: -------------- main/trunk/src/tracks/quad.cpp main/trunk/src/tracks/quad.hpp main/trunk/src/tracks/quad_graph.cpp Modified: main/trunk/src/tracks/quad.cpp =================================================================== --- main/trunk/src/tracks/quad.cpp 2010-03-15 09:20:08 UTC (rev 4998) +++ main/trunk/src/tracks/quad.cpp 2010-03-15 09:21:21 UTC (rev 4999) @@ -44,6 +44,9 @@ m_min_height = std::min ( std::min(p0.getY(), p1.getY()), std::min(p0.getY(), p1.getY()) ); m_invisible = invisible; + + m_lower_center = 0.5f*(m_p[0]+m_p[1]); + m_upper_center = 0.5f*(m_p[2]+m_p[3]); } // Quad // ---------------------------------------------------------------------------- @@ -113,10 +116,24 @@ * \param result The quad which stores the result. */ void Quad::transform(const btTransform &t, Quad *result) const - { result->m_p[0] = t(m_p[0]); result->m_p[1] = t(m_p[1]); result->m_p[2] = t(m_p[2]); result->m_p[3] = t(m_p[3]); } // transform + +// ---------------------------------------------------------------------------- +/** Returns true if the orthognal projection of the point xyz on the center + * line of this quad is inside this quad. This is used when determining + * on which quad a kart is if it is off-track. + * \param xyz The coordinates to project. + * \return True if the orthognal projection is inside this quad. + */ +bool Quad::projectionIsInside(const Vec3 &xyz) const +{ + Vec3 v1 = xyz-m_lower_center; + Vec3 v2 = m_upper_center - m_lower_center; + float ratio = v1.dot(v2) / (m_upper_center-m_lower_center).length2(); + return ratio>=0 && ratio <=1.0f; +} // projectionIsInside Modified: main/trunk/src/tracks/quad.hpp =================================================================== --- main/trunk/src/tracks/quad.hpp 2010-03-15 09:20:08 UTC (rev 4998) +++ main/trunk/src/tracks/quad.hpp 2010-03-15 09:21:21 UTC (rev 4999) @@ -37,6 +37,11 @@ * This saves some computations at runtime. */ Vec3 m_center; + /** The middle points of the 'lower' and 'upper' lines. The line + * connecting these two points is used in projectionIsInside(). + */ + Vec3 m_lower_center, m_upper_center; + /** The minimum height of the quad, used in case that several quads * are on top of each other when determining the sector a kart is on. */ float m_min_height; @@ -51,6 +56,7 @@ void getVertices(video::S3DVertex *v, const video::SColor &color) const; bool pointInQuad(const Vec3& p) const; void transform(const btTransform &t, Quad *result) const; + bool projectionIsInside(const Vec3 &xyz) const; // ------------------------------------------------------------------------ /** Returns the i-th. point of a quad. */ const Vec3& operator[](int i) const {return m_p[i]; } Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2010-03-15 09:20:08 UTC (rev 4998) +++ main/trunk/src/tracks/quad_graph.cpp 2010-03-15 09:21:21 UTC (rev 4999) @@ -446,11 +446,26 @@ else next_sector = current_sector+1 == (int)getNumNodes() ? 0 : current_sector+1; + // A first simple test uses the 2d distance to the center of the quad. float dist_2 = xyz.distance2(getQuad(next_sector).getCenter()-xyz); if(dist_2<min_dist_2) { - min_dist_2 = dist_2; - min_sector = next_sector; + // If the current quad's center is closer to the kart than the + // previously determined minimum, test if the kart's projected + // position on the center line of the quad is still in the + // same quad. Consider the following situation: + // +-----------------+-----+ + // | A | B | + // +-----------------+-----+ + // X + // A kart at position X will be closer to the center of quad B + // than to quad A, but it should be considered to be on quad + // A! + if(getQuad(next_sector).projectionIsInside(xyz)) + { + min_dist_2 = dist_2; + min_sector = next_sector; + } } current_sector = next_sector; } // for j This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-03-19 10:39:00
|
Revision: 5032 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5032&view=rev Author: hikerstk Date: 2010-03-19 10:38:52 +0000 (Fri, 19 Mar 2010) Log Message: ----------- Replaced off-road handling code, which hopefully fixes all off-road problems. Modified Paths: -------------- main/trunk/src/tracks/graph_node.cpp main/trunk/src/tracks/graph_node.hpp main/trunk/src/tracks/quad.cpp main/trunk/src/tracks/quad.hpp main/trunk/src/tracks/quad_graph.cpp Modified: main/trunk/src/tracks/graph_node.cpp =================================================================== --- main/trunk/src/tracks/graph_node.cpp 2010-03-19 10:37:51 UTC (rev 5031) +++ main/trunk/src/tracks/graph_node.cpp 2010-03-19 10:38:52 UTC (rev 5032) @@ -115,3 +115,17 @@ result->setX(-(closest-xyz2d).getLength()); // to the left result->setZ( m_distance_from_start + (closest-m_lower_center).getLength()); } // getDistances + +// ---------------------------------------------------------------------------- +/** Returns the square of the distance between the given point and any point + * on the 'centre' line, i.e. the finite line from the middle point of the + * lower end of the quad node to the middle point of the upper end of the + * quad which belongs to this graph node. The value is computed in 2d only! + * \param xyz The point for which the distance to the line is computed. + */ +float GraphNode::getDistance2FromPoint(const Vec3 &xyz) +{ + core::vector2df xyz2d(xyz.getX(), xyz.getZ()); + core::vector2df closest = m_line.getClosestPoint(xyz2d); + return (closest-xyz2d).getLengthSQ(); +} // getDistance2FromPoint \ No newline at end of file Modified: main/trunk/src/tracks/graph_node.hpp =================================================================== --- main/trunk/src/tracks/graph_node.hpp 2010-03-19 10:37:51 UTC (rev 5031) +++ main/trunk/src/tracks/graph_node.hpp 2010-03-19 10:38:52 UTC (rev 5032) @@ -81,6 +81,7 @@ GraphNode(unsigned int index); void addSuccessor (unsigned int to); void getDistances(const Vec3 &xyz, Vec3 *result); + float getDistance2FromPoint(const Vec3 &xyz); /** Returns the i-th successor. */ unsigned int getSuccessor(unsigned int i) const Modified: main/trunk/src/tracks/quad.cpp =================================================================== --- main/trunk/src/tracks/quad.cpp 2010-03-19 10:37:51 UTC (rev 5031) +++ main/trunk/src/tracks/quad.cpp 2010-03-19 10:38:52 UTC (rev 5032) @@ -45,8 +45,6 @@ std::min(p0.getY(), p1.getY()) ); m_invisible = invisible; - m_lower_center = 0.5f*(m_p[0]+m_p[1]); - m_upper_center = 0.5f*(m_p[2]+m_p[3]); } // Quad // ---------------------------------------------------------------------------- @@ -125,18 +123,3 @@ result->m_p[2] = t(m_p[2]); result->m_p[3] = t(m_p[3]); } // transform - -// ---------------------------------------------------------------------------- -/** Returns true if the orthognal projection of the point xyz on the center - * line of this quad is inside this quad. This is used when determining - * on which quad a kart is if it is off-track. - * \param xyz The coordinates to project. - * \return True if the orthognal projection is inside this quad. - */ -bool Quad::projectionIsInside(const Vec3 &xyz) const -{ - Vec3 v1 = xyz-m_lower_center; - Vec3 v2 = m_upper_center - m_lower_center; - float ratio = v1.dot(v2) / (m_upper_center-m_lower_center).length2(); - return ratio>=0 && ratio <=1.0f; -} // projectionIsInside Modified: main/trunk/src/tracks/quad.hpp =================================================================== --- main/trunk/src/tracks/quad.hpp 2010-03-19 10:37:51 UTC (rev 5031) +++ main/trunk/src/tracks/quad.hpp 2010-03-19 10:38:52 UTC (rev 5032) @@ -37,11 +37,6 @@ * This saves some computations at runtime. */ Vec3 m_center; - /** The middle points of the 'lower' and 'upper' lines. The line - * connecting these two points is used in projectionIsInside(). - */ - Vec3 m_lower_center, m_upper_center; - /** The minimum height of the quad, used in case that several quads * are on top of each other when determining the sector a kart is on. */ float m_min_height; @@ -56,7 +51,6 @@ void getVertices(video::S3DVertex *v, const video::SColor &color) const; bool pointInQuad(const Vec3& p) const; void transform(const btTransform &t, Quad *result) const; - bool projectionIsInside(const Vec3 &xyz) const; // ------------------------------------------------------------------------ /** Returns the i-th. point of a quad. */ const Vec3& operator[](int i) const {return m_p[i]; } Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2010-03-19 10:37:51 UTC (rev 5031) +++ main/trunk/src/tracks/quad_graph.cpp 2010-03-19 10:38:52 UTC (rev 5032) @@ -447,25 +447,11 @@ next_sector = current_sector+1 == (int)getNumNodes() ? 0 : current_sector+1; // A first simple test uses the 2d distance to the center of the quad. - float dist_2 = xyz.distance2(getQuad(next_sector).getCenter()-xyz); + float dist_2 = m_all_nodes[next_sector]->getDistance2FromPoint(xyz); if(dist_2<min_dist_2) { - // If the current quad's center is closer to the kart than the - // previously determined minimum, test if the kart's projected - // position on the center line of the quad is still in the - // same quad. Consider the following situation: - // +-----------------+-----+ - // | A | B | - // +-----------------+-----+ - // X - // A kart at position X will be closer to the center of quad B - // than to quad A, but it should be considered to be on quad - // A! - if(getQuad(next_sector).projectionIsInside(xyz)) - { - min_dist_2 = dist_2; - min_sector = next_sector; - } + min_dist_2 = dist_2; + min_sector = next_sector; } current_sector = next_sector; } // for j This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-04-12 14:23:46
|
Revision: 5180 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5180&view=rev Author: hikerstk Date: 2010-04-12 14:23:39 +0000 (Mon, 12 Apr 2010) Log Message: ----------- Removed unnecessary 'offset' added to quad graph. This code could cause the position of the karts to be incorrect just after crossing the lap line. Problem was that the center point of the first quad line (which by definition is on the line) would be considered to be not on the line due to floating point errors (i.e. 0.5*(A+B) would not be on the line between A and B). Modified Paths: -------------- main/trunk/src/tracks/quad_graph.cpp main/trunk/src/tracks/quad_graph.hpp Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2010-04-12 14:15:38 UTC (rev 5179) +++ main/trunk/src/tracks/quad_graph.cpp 2010-04-12 14:23:39 UTC (rev 5180) @@ -40,7 +40,6 @@ m_mesh = NULL; m_mesh_buffer = NULL; m_lap_length = 0; - m_offset_for_startline = 0; m_all_quads = new QuadSet(quad_file_name); m_quad_filename = quad_file_name; GraphNode::m_all_quads = m_all_quads; @@ -79,7 +78,6 @@ } Vec3 xyz; spatialToTrack(&xyz, start_point, sector); - m_offset_for_startline = xyz.getZ(); } // setStartCoordinate // ----------------------------------------------------------------------------- @@ -325,10 +323,6 @@ } getNode(sector).getDistances(xyz, dst); - float z=dst->getZ(); - z=z-m_offset_for_startline; - if(z<0) z+=m_lap_length; - dst->setZ(z); } // spatialToTrack //----------------------------------------------------------------------------- Modified: main/trunk/src/tracks/quad_graph.hpp =================================================================== --- main/trunk/src/tracks/quad_graph.hpp 2010-04-12 14:15:38 UTC (rev 5179) +++ main/trunk/src/tracks/quad_graph.hpp 2010-04-12 14:23:39 UTC (rev 5180) @@ -52,11 +52,6 @@ /** Scaling for mini map, only x and y components are used. */ Vec3 m_scaling; - /** This is the track coordinate for the start line. This offset is - * added to the Y value of spatialToTrack. It guarantees that the - * start line is always at track coordinates 0 (for Y). */ - float m_offset_for_startline; - /** Stores the filename - just used for error messages. */ std::string m_quad_filename; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-04-23 20:53:51
|
Revision: 5251 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5251&view=rev Author: auria Date: 2010-04-23 20:53:45 +0000 (Fri, 23 Apr 2010) Log Message: ----------- More work to enhance Doxygen output Modified Paths: -------------- main/trunk/src/tracks/ambient_light_sphere.hpp main/trunk/src/tracks/bezier_curve.hpp main/trunk/src/tracks/check_line.hpp main/trunk/src/tracks/check_manager.hpp main/trunk/src/tracks/check_sphere.hpp main/trunk/src/tracks/check_structure.hpp main/trunk/src/tracks/graph_node.hpp main/trunk/src/tracks/quad.hpp main/trunk/src/tracks/quad_graph.hpp main/trunk/src/tracks/quad_set.hpp main/trunk/src/tracks/terrain_info.hpp main/trunk/src/tracks/track.hpp main/trunk/src/tracks/track_manager.hpp main/trunk/src/tracks/track_object.hpp main/trunk/src/tracks/track_object_manager.hpp Modified: main/trunk/src/tracks/ambient_light_sphere.hpp =================================================================== --- main/trunk/src/tracks/ambient_light_sphere.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/ambient_light_sphere.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -28,11 +28,15 @@ class XMLNode; class CheckManager; -/** This class implements a check sphere that is used to change the ambient - * light if a kart is inside this sphere. Besides a normal radius this - * sphere also has a 2nd 'inner' radius: player karts inside the inner - * radius will have the full new ambient light, karts outside the default - * light, and karts in between will mix the light dependent on distance. +/** + * \brief This class implements a check sphere that is used to change the ambient + * light if a kart is inside this sphere. + * + * Besides a normal radius this sphere also has a 2nd 'inner' radius: player karts + * inside the inner radius will have the full new ambient light, karts outside the + * default light, and karts in between will mix the light dependent on distance. + * + * \ingroup tracks */ class AmbientLightSphere : public CheckSphere { Modified: main/trunk/src/tracks/bezier_curve.hpp =================================================================== --- main/trunk/src/tracks/bezier_curve.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/bezier_curve.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -26,8 +26,10 @@ class XMLNode; -/** A class to manage bezier curves and interpolation. - */ +/** + * A class to manage bezier curves and interpolation. + * \ingroup tracks + */ class BezierCurve { private: Modified: main/trunk/src/tracks/check_line.hpp =================================================================== --- main/trunk/src/tracks/check_line.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/check_line.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -28,12 +28,16 @@ class XMLNode; class CheckManager; -/** Implements a simple checkline. It's a finite line with 2 endpoints in 2d +/** + * \brief Implements a simple checkline. + * It's a finite line with 2 endpoints in 2d * and a minimum height (i.e. the minimum Y coordinate of the two points). * If a kart crosses the line (in the projection on the 2d plane) and has an * appropriate height, the checkline will be triggered. This allows for very * easy checking of checklines, and should be sufficient for most check * structure. + * + * \ingroup tracks */ class CheckLine : public CheckStructure { Modified: main/trunk/src/tracks/check_manager.hpp =================================================================== --- main/trunk/src/tracks/check_manager.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/check_manager.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -26,7 +26,10 @@ class CheckStructure; class Track; -/** Controls all checks structures of a track. */ +/** + * \brief Controls all checks structures of a track. + * \ingroup tracks + */ class CheckManager { private: Modified: main/trunk/src/tracks/check_sphere.hpp =================================================================== --- main/trunk/src/tracks/check_sphere.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/check_sphere.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -33,6 +33,8 @@ * sphere also has a 2nd 'inner' radius: player karts inside the inner * radius will have the full new ambient light, karts outside the default * light, and karts in between will mix the light dependent on distance. + * + * \ingroup tracks */ class CheckSphere : public CheckStructure { Modified: main/trunk/src/tracks/check_structure.hpp =================================================================== --- main/trunk/src/tracks/check_structure.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/check_structure.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -28,8 +28,10 @@ class Track; class CheckManager; -/** Virtual base class for a check structure. A check structure has a certain - * type: +/** + * \brief Virtual base class for a check structure. + * + * A check structure has a certain ype: * CT_NEW_LAP : triggering this check structure will cause a new lap to be * counted. If this type is triggered, it will set itselt to * inactive (which means it is not possible to count several @@ -42,6 +44,8 @@ * Each check structure can be active or inactive. A new_la counter is * initialised as non-active, so that karts have to trigger a reset check * before a lap can be counted. + * + * \ingroup tracks */ class CheckStructure { Modified: main/trunk/src/tracks/graph_node.hpp =================================================================== --- main/trunk/src/tracks/graph_node.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/graph_node.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -30,9 +30,10 @@ class QuadSet; class QuadGraph; -/** This class stores a node of the graph, i.e. a list of successor - * edges. - */ +/** + * \brief This class stores a node of the graph, i.e. a list of successor edges. + * \ingroup tracks + */ class GraphNode { /** Index of this node in the set of quads. Several graph nodes can use Modified: main/trunk/src/tracks/quad.hpp =================================================================== --- main/trunk/src/tracks/quad.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/quad.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -27,6 +27,10 @@ #include "utils/vec3.hpp" class btTransform; + +/** + * \ingroup tracks + */ class Quad { private: Modified: main/trunk/src/tracks/quad_graph.hpp =================================================================== --- main/trunk/src/tracks/quad_graph.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/quad_graph.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -28,8 +28,12 @@ class CheckLine; -/** This class stores a graph of quads. */ -class QuadGraph { +/** + * \brief This class stores a graph of quads. + * \ingroup tracks + */ +class QuadGraph +{ private: /** The actual graph data structure. */ Modified: main/trunk/src/tracks/quad_set.hpp =================================================================== --- main/trunk/src/tracks/quad_set.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/quad_set.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -28,7 +28,11 @@ class XMLNode; -class QuadSet { +/** + * \ingroup tracks + */ +class QuadSet +{ private: /** The 2d bounding box, used for hashing. */ Vec3 m_min; Modified: main/trunk/src/tracks/terrain_info.hpp =================================================================== --- main/trunk/src/tracks/terrain_info.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/terrain_info.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -25,6 +25,7 @@ /** This class stores information about the triangle that's under an object, i.e.: * the normal, a pointer to the material, and the height above th + * \ingroup tracks */ class TerrainInfo { Modified: main/trunk/src/tracks/track.hpp =================================================================== --- main/trunk/src/tracks/track.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/track.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -18,6 +18,8 @@ #ifndef HEADER_TRACK_HPP #define HEADER_TRACK_HPP +/** \defgroup tracks */ + #ifdef __APPLE__ # include <OpenGL/gl.h> #else @@ -51,6 +53,9 @@ class World; class XMLNode; +/** + * \ingroup tracks + */ class Track { private: Modified: main/trunk/src/tracks/track_manager.hpp =================================================================== --- main/trunk/src/tracks/track_manager.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/track_manager.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -26,8 +26,10 @@ class Track; -/** Simple class to load and manage track data, track names and - such */ +/** + * \brief Simple class to load and manage track data, track names and such + * \ingroup tracks + */ class TrackManager { private: Modified: main/trunk/src/tracks/track_object.hpp =================================================================== --- main/trunk/src/tracks/track_object.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/track_object.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -28,6 +28,9 @@ class XMLNode; +/** + * \ingroup tracks + */ class TrackObject : public scene::IAnimationEndCallBack { //public: Modified: main/trunk/src/tracks/track_object_manager.hpp =================================================================== --- main/trunk/src/tracks/track_object_manager.hpp 2010-04-23 20:48:56 UTC (rev 5250) +++ main/trunk/src/tracks/track_object_manager.hpp 2010-04-23 20:53:45 UTC (rev 5251) @@ -28,12 +28,17 @@ class Vec3; class XMLNode; +/** + * \ingroup tracks + */ class TrackObjectManager { public: - // The different type of track objects: physical objects, graphical - // objects (without a physical representation) - the latter might be - // eye candy (to reduce work for physics), ... + /** + * The different type of track objects: physical objects, graphical + * objects (without a physical representation) - the latter might be + * eye candy (to reduce work for physics), ... + */ enum TrackObjectType {TO_PHYSICAL, TO_GRAPHICAL}; std::vector<TrackObject*> m_all_objects; public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-07-08 23:03:51
|
Revision: 5674 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5674&view=rev Author: hikerstk Date: 2010-07-08 23:03:45 +0000 (Thu, 08 Jul 2010) Log Message: ----------- Fixed more memory leaks. Modified Paths: -------------- main/trunk/src/tracks/quad_graph.cpp main/trunk/src/tracks/quad_set.cpp main/trunk/src/tracks/quad_set.hpp main/trunk/src/tracks/track.cpp Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2010-07-08 05:14:42 UTC (rev 5673) +++ main/trunk/src/tracks/quad_graph.cpp 2010-07-08 23:03:45 UTC (rev 5674) @@ -55,6 +55,8 @@ for(unsigned int i=0; i<m_all_nodes.size(); i++) { delete m_all_nodes[i]; } + if(UserConfigParams::m_track_debug) + cleanupDebugMesh(); } // ~QuadGraph // ----------------------------------------------------------------------------- @@ -276,7 +278,7 @@ c.setBlue(i%2 ? 0 : 255); v[i].Color = c; } - m_node = irr_driver->addMesh(m_mesh); + m_node = irr_driver->addMesh(m_mesh); } // createDebugMesh // ----------------------------------------------------------------------------- @@ -285,7 +287,11 @@ void QuadGraph::cleanupDebugMesh() { irr_driver->removeNode(m_node); - irr_driver->removeMesh(m_mesh); + m_node = NULL; + // No need to call irr_driber->removeMesh, since the mesh + // was manually made and so never added to the mesh cache. + m_mesh->drop(); + m_mesh = NULL; } // cleanupDebugMesh // ----------------------------------------------------------------------------- Modified: main/trunk/src/tracks/quad_set.cpp =================================================================== --- main/trunk/src/tracks/quad_set.cpp 2010-07-08 05:14:42 UTC (rev 5673) +++ main/trunk/src/tracks/quad_set.cpp 2010-07-08 23:03:45 UTC (rev 5674) @@ -33,6 +33,18 @@ } // QuadSet // ----------------------------------------------------------------------------- +/** Destructor, frees all memory. + */ +QuadSet::~QuadSet() +{ + for(unsigned int i=0; i<m_all_quads.size(); i++) + { + delete m_all_quads[i]; + } + m_all_quads.clear(); +} // ~QuadSet + +// ----------------------------------------------------------------------------- /** This function interprets a point specification as an attribute in the xml quadset file. It understands two different specifications: p1="n:p" : get point p from square n (n, p integers) Modified: main/trunk/src/tracks/quad_set.hpp =================================================================== --- main/trunk/src/tracks/quad_set.hpp 2010-07-08 05:14:42 UTC (rev 5673) +++ main/trunk/src/tracks/quad_set.hpp 2010-07-08 23:03:45 UTC (rev 5674) @@ -47,6 +47,7 @@ static const int QUAD_NONE=-1; QuadSet (const std::string& filename); + ~QuadSet (); int getCurrentQuad(const Vec3& p, int oldQuad) const; const Quad& getQuad(int n) const {return *(m_all_quads[n]); } Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2010-07-08 05:14:42 UTC (rev 5673) +++ main/trunk/src/tracks/track.cpp 2010-07-08 23:03:45 UTC (rev 5674) @@ -118,8 +118,11 @@ */ void Track::cleanup() { - if(UserConfigParams::m_track_debug) - m_quad_graph->cleanupDebugMesh(); + if(m_quad_graph) + { + delete m_quad_graph; + m_quad_graph = NULL; + } item_manager->cleanup(); for(unsigned int i=0; i<m_animated_textures.size(); i++) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-08-04 10:33:38
|
Revision: 5722 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5722&view=rev Author: hikerstk Date: 2010-08-04 10:33:32 +0000 (Wed, 04 Aug 2010) Log Message: ----------- Fixed incorrect display of karts in mini-map. Modified Paths: -------------- main/trunk/src/tracks/quad_graph.cpp main/trunk/src/tracks/quad_graph.hpp Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2010-08-02 23:25:35 UTC (rev 5721) +++ main/trunk/src/tracks/quad_graph.cpp 2010-08-04 10:33:32 UTC (rev 5722) @@ -469,7 +469,7 @@ const video::SColor &fill_color) { IrrDriver::RTTProvider rttProvider(dimension, name); - createMesh(false); + createMesh(/*show_invisible part of the track*/false); video::S3DVertex *v = (video::S3DVertex*)m_mesh_buffer->getVertices(); for(unsigned int i=0; i<m_mesh_buffer->getVertexCount(); i++) { @@ -485,15 +485,41 @@ Vec3 bb_min, bb_max; m_all_quads->getBoundingBox(&bb_min, &bb_max); Vec3 center = (bb_max+bb_min)*0.5f; - core::matrix4 projection; - float range; - if((bb_max.getX()-bb_min.getX()) > (bb_max.getZ()-bb_min.getZ())) { - range = bb_max.getX()-bb_min.getX(); - } else { - range = bb_max.getZ()-bb_min.getZ(); + float dx = bb_max.getX()-bb_min.getX(); + float dz = bb_max.getZ()-bb_min.getZ(); + + // Set the scaling correctly. Also the center point (which is used + // as the camera position) needs to be adjusted: the track must + // be aligned to the left/top of the texture which is used (otherwise + // mapPoint2MiniMap doesn't work), so adjust the camera position + // that the track is properly aligned (view from the side): + // c camera + // / \ + // / \ <--- camera angle + // / \ + // { [-] } <--- track flat (viewed from the side) + // If [-] is the shorter side of the track, then the camera will + // actually render the area in { } - which is the length of the + // longer side of the track. + // To align the [-] side to the left, the camera must be moved + // the distance betwwen '{' and '[' to the right. This distance + // is exacly (longer_side - shorter_side) / 2. + // So, adjust the center point by this amount: + if(dz > dx) + { + center.setX(center.getX() + (dz-dx)*0.5f); + m_scaling = dimension.Width / dz; } + else + { + center.setZ(center.getZ() + (dx-dz)*0.5f); + m_scaling = dimension.Width / dx; + } + float range = (dx>dz) ? dx : dz; + + core::matrix4 projection; projection.buildProjectionMatrixOrthoLH(range, range, -1, bb_max.getY()-bb_min.getY()+1); @@ -510,17 +536,9 @@ cleanupDebugMesh(); irr_driver->removeCameraSceneNode(camera); m_min_coord = bb_min; - m_scaling.setX(dimension.Width/(bb_max.getX()-bb_min.getX())); - m_scaling.setZ(dimension.Width/(bb_max.getZ()-bb_min.getZ())); - if(m_scaling.getX() > m_scaling.getZ()) { - m_scaling.setX(m_scaling.getZ()); - } else { - m_scaling.setZ(m_scaling.getX()); - } - return texture; -} // drawMiniMap +} // makeMiniMap //----------------------------------------------------------------------------- /** Returns the 2d coordinates of a point when drawn on the mini map @@ -531,7 +549,7 @@ */ void QuadGraph::mapPoint2MiniMap(const Vec3 &xyz,Vec3 *draw_at) const { - draw_at->setX((xyz.getX()-m_min_coord.getX())*m_scaling.getX()); - draw_at->setY((xyz.getZ()-m_min_coord.getZ())*m_scaling.getZ()); + draw_at->setX((xyz.getX()-m_min_coord.getX())*m_scaling); + draw_at->setY((xyz.getZ()-m_min_coord.getZ())*m_scaling); } // mapPoint Modified: main/trunk/src/tracks/quad_graph.hpp =================================================================== --- main/trunk/src/tracks/quad_graph.hpp 2010-08-02 23:25:35 UTC (rev 5721) +++ main/trunk/src/tracks/quad_graph.hpp 2010-08-04 10:33:32 UTC (rev 5722) @@ -53,8 +53,8 @@ /** The minimum coordinates of the quad graph. */ Vec3 m_min_coord; - /** Scaling for mini map, only x and y components are used. */ - Vec3 m_scaling; + /** Scaling for mini map. */ + float m_scaling; /** Stores the filename - just used for error messages. */ std::string m_quad_filename; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-09-28 23:27:20
|
Revision: 6160 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6160&view=rev Author: hikerstk Date: 2010-09-28 23:27:14 +0000 (Tue, 28 Sep 2010) Log Message: ----------- Added files missing in previous commit - sorry. Modified Paths: -------------- main/trunk/src/tracks/check_manager.cpp main/trunk/src/tracks/quad_graph.hpp Modified: main/trunk/src/tracks/check_manager.cpp =================================================================== --- main/trunk/src/tracks/check_manager.cpp 2010-09-28 23:19:56 UTC (rev 6159) +++ main/trunk/src/tracks/check_manager.cpp 2010-09-28 23:27:14 UTC (rev 6160) @@ -39,7 +39,6 @@ m_all_checks.push_back(cl); if(cl->getType()==CheckStructure::CT_NEW_LAP) { - track->getQuadGraph().setStartCoordinate(*cl); track->setStartCoordinates(cl->getLine2D()); } } // checkline Modified: main/trunk/src/tracks/quad_graph.hpp =================================================================== --- main/trunk/src/tracks/quad_graph.hpp 2010-09-28 23:19:56 UTC (rev 6159) +++ main/trunk/src/tracks/quad_graph.hpp 2010-09-28 23:27:14 UTC (rev 6160) @@ -85,7 +85,6 @@ const video::SColor &fill_color =video::SColor(127, 255, 255, 255) ); void mapPoint2MiniMap(const Vec3 &xyz, Vec3 *out) const; - void setStartCoordinate(const CheckLine &cl); /** Returns the number of nodes in the graph. */ unsigned int getNumNodes() const { return m_all_nodes.size(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-09-28 23:29:31
|
Revision: 6161 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6161&view=rev Author: hikerstk Date: 2010-09-28 23:29:21 +0000 (Tue, 28 Sep 2010) Log Message: ----------- Support for grouping check structures. E.g. it is now possible to have more than one lap line, which will always be in synch (i.e. if one is triggered, all will be set to inactive). Modified Paths: -------------- main/trunk/src/tracks/check_manager.cpp main/trunk/src/tracks/check_structure.cpp main/trunk/src/tracks/check_structure.hpp Modified: main/trunk/src/tracks/check_manager.cpp =================================================================== --- main/trunk/src/tracks/check_manager.cpp 2010-09-28 23:27:14 UTC (rev 6160) +++ main/trunk/src/tracks/check_manager.cpp 2010-09-28 23:29:21 UTC (rev 6161) @@ -29,6 +29,7 @@ CheckManager::CheckManager(const XMLNode &node, Track *track) { + bool lap_line_found = false; for(unsigned int i=0; i<node.getNumNodes(); i++) { const XMLNode *check_node = node.getNode(i); @@ -37,9 +38,13 @@ { CheckLine *cl = new CheckLine(this, *check_node, i); m_all_checks.push_back(cl); - if(cl->getType()==CheckStructure::CT_NEW_LAP) + // Only record the first lap line to be used to compute + // start coordinates with. The track exporter always exports + // the one based on the quads first. + if(cl->getType()==CheckStructure::CT_NEW_LAP && !lap_line_found) { track->setStartCoordinates(cl->getLine2D()); + lap_line_found = true; } } // checkline else if(type=="check-sphere") Modified: main/trunk/src/tracks/check_structure.cpp =================================================================== --- main/trunk/src/tracks/check_structure.cpp 2010-09-28 23:27:14 UTC (rev 6160) +++ main/trunk/src/tracks/check_structure.cpp 2010-09-28 23:29:21 UTC (rev 6161) @@ -42,13 +42,16 @@ { printf("Unknown check structure '%s' - ignored.\n", kind.c_str()); } - m_activate_check_index = -1; - node.get("other-id", &m_activate_check_index); - if( (m_check_type==CT_TOGGLE || m_check_type==CT_ACTIVATE) && - m_activate_check_index==-1) - { - printf("Unknown other-id in checkline.\n"); - } + m_check_structures_to_change_state.clear(); + node.get("other-ids", &m_check_structures_to_change_state); + // Backwards compatibility to tracks exported with older versions of + // the track exporter + if(m_check_structures_to_change_state.size()==0) + node.get("other-id", &m_check_structures_to_change_state); + + m_same_group.clear(); + node.get("same-group", &m_same_group); + m_active_at_reset=true; node.get("active", &m_active_at_reset); } // CheckStructure @@ -103,45 +106,76 @@ { switch(m_check_type) { - case CT_NEW_LAP : World::getWorld()->newLap(kart_index); - m_is_active[kart_index] = false; - if(UserConfigParams::m_check_debug) - { - printf("CHECK: %s new lap %d triggered, now deactivated.\n", - World::getWorld()->getKart(kart_index)->getIdent().c_str(), - m_index); - } - break; - case CT_ACTIVATE: { - CheckStructure *cs= - m_check_manager->getCheckStructure(m_activate_check_index); - cs->m_is_active[kart_index] = true; - if(UserConfigParams::m_check_debug) - { - printf("CHECK: %s %d triggered, activating %d.\n", - World::getWorld()->getKart(kart_index)->getIdent().c_str(), - m_index, m_activate_check_index); - } - break; - } - case CT_TOGGLE: { - CheckStructure *cs= - m_check_manager->getCheckStructure(m_activate_check_index); - cs->m_is_active[kart_index] = !cs->m_is_active[kart_index]; - if(UserConfigParams::m_check_debug) - { - // At least on gcc 4.3.2 we can't simply print - // cs->m_is_active[kart_index] ("cannot pass objects of - // non-POD type ‘struct std::_Bit_reference’ through ‘...’; - // call will abort at runtime"). So we use this somewhat - // unusual but portable construct. - printf("CHECK: %s %d triggered, setting %d to %d.\n", - World::getWorld()->getKart(kart_index)->getIdent().c_str(), - m_index, m_activate_check_index, - cs->m_is_active[kart_index]==true); - } - break; - } + case CT_NEW_LAP : + World::getWorld()->newLap(kart_index); + m_is_active[kart_index] = false; + if(UserConfigParams::m_check_debug) + { + printf("CHECK: %s new lap %d triggered, now deactivated.\n", + World::getWorld()->getKart(kart_index)->getIdent().c_str(), + m_index); + } + // Set all checkstructures of the same group to the same state. + // This is to avoid e.g. only deactivating one of many new lap + // counters, which could enable the user to cheat by crossing + // all different lap counting lines. + for(unsigned int i=0; i<m_same_group.size(); i++) + { + CheckStructure *cs = + m_check_manager->getCheckStructure(m_same_group[i]); + cs->m_is_active[kart_index] = false; + printf("CHECK: also deactivating index %d\n", m_same_group[i]); + } + break; + case CT_ACTIVATE: + { + for(unsigned int i=0; i<m_check_structures_to_change_state.size(); + i++) + { + int check_index = m_check_structures_to_change_state[i]; + CheckStructure *cs= + m_check_manager->getCheckStructure(check_index); + // We don't have to activate all members of the group of + // cs, since this check line's m_check_structure_to_change + // will include the full groups. + cs->m_is_active[kart_index] = true; + if(UserConfigParams::m_check_debug) + { + printf("CHECK: %s %d triggered, activating %d.\n", + World::getWorld()->getKart(kart_index)->getIdent().c_str(), + m_index, check_index); + } + } // for i<m_check_structures_to_change_state.size() + break; + } + case CT_TOGGLE: + { + for(unsigned int i=0; i<m_check_structures_to_change_state.size(); + i++) + { + int check_index = m_check_structures_to_change_state[i]; + CheckStructure *cs= + m_check_manager->getCheckStructure(check_index); + // We don't have to toggle all members of the group of + // cs, since this check line's m_check_structure_to_change + // will include the full groups. This esp. avoids toggling + // cs more than once! + cs->m_is_active[kart_index] = !cs->m_is_active[kart_index]; + if(UserConfigParams::m_check_debug) + { + // At least on gcc 4.3.2 we can't simply print + // cs->m_is_active[kart_index] ("cannot pass objects of + // non-POD type ‘struct std::_Bit_reference’ through ‘...’; + // call will abort at runtime"). So we use this somewhat + // unusual but portable construct. + printf("CHECK: %s %d triggered, setting %d to %d.\n", + World::getWorld()->getKart(kart_index)->getIdent().c_str(), + m_index, check_index, + cs->m_is_active[kart_index]==true); + } + } // for i < m_check_structures_to_change_state + break; + } default: break; } // switch m_check_type } // trigger Modified: main/trunk/src/tracks/check_structure.hpp =================================================================== --- main/trunk/src/tracks/check_structure.hpp 2010-09-28 23:27:14 UTC (rev 6160) +++ main/trunk/src/tracks/check_structure.hpp 2010-09-28 23:29:21 UTC (rev 6161) @@ -1,7 +1,7 @@ // $Id: check_structure.hpp 1681 2008-04-09 13:52:48Z hikerstk $ // // SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2009 Joerg Henrichs +// Copyright (C) 2009-2010 Joerg Henrichs // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -53,7 +53,7 @@ /** Different types of check structures: * ACTIVATE: Activates another check structure (independent of * the state that check structure is in) - * TOGGLE: Switches (or inverts) the state of another check structure. + * TOGGLE: Switches (inverts) the state of another check structure. * NEW_LAP: On crossing a new lap is counted. * AMBIENT_SPHERE: Modifies the ambient color. * A combination of an activate and new_lap line are used to @@ -86,8 +86,17 @@ bool m_active_at_reset; /** If this is a CT_ACTIVATE or CT_SWITCH type, this will contain - * the index of the corresponding check structure that is triggered. */ - int m_activate_check_index; + * the indices of the corresponding check structures that get their + * state changed (activated or switched). */ + std::vector<int> m_check_structures_to_change_state; + + /** A list of check lines that should be activated/switched when this + * lines is activated/switched. I.e. can be used if more than one lap + * counting line is used to make sure they are all in synch, otherwise + * players could cross first one then the other lap counting line + * as huge shortcuts. */ + std::vector<int> m_same_group; + public: CheckStructure(CheckManager *check_manager, const XMLNode &node, unsigned int index); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-10-14 00:56:31
|
Revision: 6285 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6285&view=rev Author: hikerstk Date: 2010-10-14 00:56:25 +0000 (Thu, 14 Oct 2010) Log Message: ----------- Improved start positions: - Karts will now start forwards_distance after the lap counting line, meaning they will start behind the 'checkers' line. - Every 2nd row is now moved 0.5*sidewards_distance to the right, meaning that there is much more space ahead of the kart for quick starts (i.e. the kart can drive between the karts in the row ahead of it). Modified Paths: -------------- main/trunk/src/tracks/graph_node.hpp main/trunk/src/tracks/quad_graph.cpp Modified: main/trunk/src/tracks/graph_node.hpp =================================================================== --- main/trunk/src/tracks/graph_node.hpp 2010-10-13 22:37:41 UTC (rev 6284) +++ main/trunk/src/tracks/graph_node.hpp 2010-10-14 00:56:25 UTC (rev 6285) @@ -127,6 +127,10 @@ // ------------------------------------------------------------------------ /** Returns the center point of the upper edge of this graph node. */ const Vec3& getUpperCenter() const {return m_upper_center;} + // ------------------------------------------------------------------------ + /** Returns the length of the quad of this node. */ + float getNodeLength() const + {return (m_lower_center-m_upper_center).length();} }; // GraphNode #endif Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2010-10-13 22:37:41 UTC (rev 6284) +++ main/trunk/src/tracks/quad_graph.cpp 2010-10-14 00:56:25 UTC (rev 6285) @@ -207,26 +207,27 @@ { // Node 0 is always the node on which the start line is. int current_node = getPredecessor(0); - float distance_from_start = 0.1f; + float distance_from_start = 0.1f+forwards_distance; // Maximum distance to left (or right) of centre line - const float max_x_dist = (karts_per_row-1)*0.5f*sidewards_distance; + const float max_x_dist = 0.5f*(karts_per_row-0.5f)*sidewards_distance; // X position relative to the centre line - float x_pos = -max_x_dist; + float x_pos = -max_x_dist + sidewards_distance*0.5f; + unsigned int row_number = 0; for(unsigned int i=0; i<start_transforms->size(); i++) { // First find on which segment we have to start - while(distance_from_start > getNode(current_node).getDistanceToSuccessor(0)) + while(distance_from_start > getNode(current_node).getNodeLength()) { - distance_from_start -= getNode(current_node).getDistanceToSuccessor(0); + distance_from_start -= getNode(current_node).getNodeLength(); current_node = getPredecessor(current_node); } const GraphNode &gn = getNode(current_node); Vec3 center_line = gn.getLowerCenter() - gn.getUpperCenter(); center_line.normalize(); - Vec3 horizontal_line = gn[3] - gn[2]; + Vec3 horizontal_line = gn[2] - gn[3]; horizontal_line.normalize(); Vec3 start = gn.getUpperCenter() @@ -238,9 +239,16 @@ (*start_transforms)[i].setRotation( btQuaternion(btVector3(0, 1, 0), gn.getAngleToSuccessor(0))); - - if(fabsf(x_pos - max_x_dist)<0.1f) + if(x_pos >= max_x_dist-sidewards_distance*0.5f) + { x_pos = -max_x_dist; + // Every 2nd row will be pushed sideways by half the distance + // between karts, so that a kart can drive between the karts in + // the row ahead of it. + row_number ++; + if(row_number % 2 == 0) + x_pos += sidewards_distance*0.5f; + } else x_pos += sidewards_distance; distance_from_start += forwards_distance; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-11-08 23:58:19
|
Revision: 6465 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6465&view=rev Author: hikerstk Date: 2010-11-08 23:58:12 +0000 (Mon, 08 Nov 2010) Log Message: ----------- Removed unnecessary/old code: support for track specific number of karts, and light settings in track.xml (which can be set using the track exporter in scene.xml). Modified Paths: -------------- main/trunk/src/tracks/track.cpp main/trunk/src/tracks/track.hpp Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2010-11-08 21:46:36 UTC (rev 6464) +++ main/trunk/src/tracks/track.cpp 2010-11-08 23:58:12 UTC (rev 6465) @@ -78,7 +78,6 @@ m_mini_map = NULL; m_sky_dx = 0.05f; m_sky_dy = 0.0f; - m_max_kart_count = 8; loadTrackInfo(); } // Track @@ -206,10 +205,6 @@ root->get("gravity", &m_gravity); root->get("arena", &m_is_arena); root->get("groups", &m_groups); - root->get("ambient", &m_sun_diffuse_color); - root->get("ambient", &m_sun_specular_color); - root->get("ambient", &m_default_ambient_color); - root->get("maxKartCount", &m_max_kart_count); for(unsigned int i=0; i<root->getNumNodes(); i++) { Modified: main/trunk/src/tracks/track.hpp =================================================================== --- main/trunk/src/tracks/track.hpp 2010-11-08 21:46:36 UTC (rev 6464) +++ main/trunk/src/tracks/track.hpp 2010-11-08 23:58:12 UTC (rev 6465) @@ -136,9 +136,6 @@ /** List of all modes for a track. */ std::vector<TrackMode> m_all_modes; - /** Maximum number of karts that this track can sustain without them starting off-track */ - int m_max_kart_count; - /** Name of the track to display. */ irr::core::stringw m_name; bool m_use_fog; @@ -275,11 +272,7 @@ /** Get the number of start positions defined in the scene file. */ unsigned int getNumberOfStartPositions() const - { return m_start_transforms.size(); } - - /** \return the maximum number of karts that this track can sustain without them starting off-track */ - int getMaxKartCount() const { return m_max_kart_count; } - + { return m_start_transforms.size(); } }; // class Track #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-11-14 21:47:35
|
Revision: 6530 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6530&view=rev Author: hikerstk Date: 2010-11-14 21:47:29 +0000 (Sun, 14 Nov 2010) Log Message: ----------- Fixed bug in checck structures (activation lines were set to active as default, which means that if there is more than one activation line, you only needed to cross the last one). This will break proper lap counting in all tracks! Modified Paths: -------------- main/trunk/src/tracks/check_structure.cpp main/trunk/src/tracks/check_structure.hpp Modified: main/trunk/src/tracks/check_structure.cpp =================================================================== --- main/trunk/src/tracks/check_structure.cpp 2010-11-14 21:08:40 UTC (rev 6529) +++ main/trunk/src/tracks/check_structure.cpp 2010-11-14 21:47:29 UTC (rev 6530) @@ -17,10 +17,13 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include "tracks/check_structure.hpp" + +#include <algorithm> + #include "modes/world.hpp" #include "race/race_manager.hpp" #include "tracks/check_manager.hpp" -#include "tracks/check_structure.hpp" CheckStructure::CheckStructure(CheckManager *check_manager, @@ -51,8 +54,16 @@ m_same_group.clear(); node.get("same-group", &m_same_group); + // Make sure that the index of this check structure is included in + // the same_group list. While this should be guaranteed by the + // current track exporter, tracks exported with the old track + // exporter will not have this. + if(std::find(m_same_group.begin(), m_same_group.end(), m_index) + == m_same_group.end()) + m_same_group.push_back(m_index); - m_active_at_reset=true; + // As a default, only lap lines are activated + m_active_at_reset= m_check_type==CT_NEW_LAP; node.get("active", &m_active_at_reset); } // CheckStructure @@ -99,6 +110,61 @@ } // update // ---------------------------------------------------------------------------- +/** Changes the status (active/inactive) of all check structures contained + * in the index list indices. + * \param indices List of index of check structures in check_manager that + * are to be changed. + * \param int kart_index For which the status should be changed. + * \param change_state How to change the state (active, deactivate, toggle). + */ +void CheckStructure::changeStatus(const std::vector<int> indices, + int kart_index, + ChangeState change_state) +{ + for(unsigned int i=0; i<indices.size(); i++) + { + CheckStructure *cs = + m_check_manager->getCheckStructure(indices[i]); + switch(change_state) + { + case CS_DEACTIVATE: + cs->m_is_active[kart_index] = false; + if(UserConfigParams::m_check_debug) + { + printf("CHECK: Deactivating %d for %s.\n", + indices[i], + World::getWorld()->getKart(kart_index)->getIdent().c_str()); + } + break; + case CS_ACTIVATE: + cs->m_is_active[kart_index] = true; + if(UserConfigParams::m_check_debug) + { + printf("CHECK: Activating %d for %s.\n", + indices[i], + World::getWorld()->getKart(kart_index)->getIdent().c_str()); + } + break; + case CS_TOGGLE: + if(UserConfigParams::m_check_debug) + { + // At least on gcc 4.3.2 we can't simply print + // cs->m_is_active[kart_index] ("cannot pass objects of + // non-POD type ‘struct std::_Bit_reference’ through ‘...’; + // call will abort at runtime"). So we use this somewhat + // unusual but portable construct. + printf("CHECK: Toggling %d for %s from %d.\n", + indices[i], + World::getWorld()->getKart(kart_index)->getIdent().c_str(), + cs->m_is_active[kart_index]==true); + } + cs->m_is_active[kart_index] = !cs->m_is_active[kart_index]; + } // switch + + } // for i<indices.size() +} //changeStatus + +// ---------------------------------------------------------------------------- /** Is called when this check structure is triggered. This then can cause * a lap to be counted, animation to be started etc. */ @@ -108,75 +174,25 @@ { case CT_NEW_LAP : World::getWorld()->newLap(kart_index); - m_is_active[kart_index] = false; if(UserConfigParams::m_check_debug) { - printf("CHECK: %s new lap %d triggered, now deactivated.\n", - World::getWorld()->getKart(kart_index)->getIdent().c_str(), - m_index); + printf("CHECK: %s new lap %d triggered\n", + World::getWorld()->getKart(kart_index)->getIdent().c_str(), + m_index); } - // Set all checkstructures of the same group to the same state. - // This is to avoid e.g. only deactivating one of many new lap - // counters, which could enable the user to cheat by crossing - // all different lap counting lines. - for(unsigned int i=0; i<m_same_group.size(); i++) - { - CheckStructure *cs = - m_check_manager->getCheckStructure(m_same_group[i]); - cs->m_is_active[kart_index] = false; - if(UserConfigParams::m_check_debug) - printf("CHECK: also deactivating index %d\n", m_same_group[i]); - } + changeStatus(m_check_structures_to_change_state, + kart_index, CS_ACTIVATE); break; case CT_ACTIVATE: - { - for(unsigned int i=0; i<m_check_structures_to_change_state.size(); - i++) - { - int check_index = m_check_structures_to_change_state[i]; - CheckStructure *cs= - m_check_manager->getCheckStructure(check_index); - // We don't have to activate all members of the group of - // cs, since this check line's m_check_structure_to_change - // will include the full groups. - cs->m_is_active[kart_index] = true; - if(UserConfigParams::m_check_debug) - { - printf("CHECK: %s %d triggered, activating %d.\n", - World::getWorld()->getKart(kart_index)->getIdent().c_str(), - m_index, check_index); - } - } // for i<m_check_structures_to_change_state.size() - break; - } + changeStatus(m_check_structures_to_change_state, + kart_index, CS_ACTIVATE); + break; case CT_TOGGLE: - { - for(unsigned int i=0; i<m_check_structures_to_change_state.size(); - i++) - { - int check_index = m_check_structures_to_change_state[i]; - CheckStructure *cs= - m_check_manager->getCheckStructure(check_index); - // We don't have to toggle all members of the group of - // cs, since this check line's m_check_structure_to_change - // will include the full groups. This esp. avoids toggling - // cs more than once! - cs->m_is_active[kart_index] = !cs->m_is_active[kart_index]; - if(UserConfigParams::m_check_debug) - { - // At least on gcc 4.3.2 we can't simply print - // cs->m_is_active[kart_index] ("cannot pass objects of - // non-POD type ‘struct std::_Bit_reference’ through ‘...’; - // call will abort at runtime"). So we use this somewhat - // unusual but portable construct. - printf("CHECK: %s %d triggered, setting %d to %d.\n", - World::getWorld()->getKart(kart_index)->getIdent().c_str(), - m_index, check_index, - cs->m_is_active[kart_index]==true); - } - } // for i < m_check_structures_to_change_state - break; - } - default: break; + changeStatus(m_check_structures_to_change_state, + kart_index, CS_TOGGLE); + break; + default: + break; } // switch m_check_type + changeStatus(m_same_group, kart_index, CS_DEACTIVATE); } // trigger Modified: main/trunk/src/tracks/check_structure.hpp =================================================================== --- main/trunk/src/tracks/check_structure.hpp 2010-11-14 21:08:40 UTC (rev 6529) +++ main/trunk/src/tracks/check_structure.hpp 2010-11-14 21:47:29 UTC (rev 6530) @@ -31,19 +31,17 @@ /** * \brief Virtual base class for a check structure. * - * A check structure has a certain ype: + * A check structure has a certain ype: * CT_NEW_LAP : triggering this check structure will cause a new lap to be * counted. If this type is triggered, it will set itselt to * inactive (which means it is not possible to count several * laps by driving over the starting line forwardws and * backwards) - * CT_RESET_NEW_LAP: Activates all lap checks. Each track must have at least - * one reset checks somewhere on the track. This is used to - * avoid shortcuts, since karts are forced to cross this reset - * check first before a new lap can be counted. - * Each check structure can be active or inactive. A new_la counter is - * initialised as non-active, so that karts have to trigger a reset check - * before a lap can be counted. + * CT_ACTIVATE: Activates the specified other check structures. + * CT_TOGGLE: Toggles the specified other check structures (active to + * inactive and vice versa. + * Each check structure can be active or inactive. Only lap counters are + * initialised to be active, all other check structures are inactive. * * \ingroup tracks */ @@ -68,8 +66,7 @@ * when e.g. a check point is reached the first time, or a checkline is * crossed. */ std::vector<Vec3> m_previous_position; - /** Stores if this check structure is active (for a given kart). Used e.g. - * in lap counting. */ + /** Stores if this check structure is active (for a given kart). */ std::vector<bool> m_is_active; private: /** Stores a pointer to the check manager. */ @@ -85,9 +82,8 @@ /** True if this check structure should be activated at a reset. */ bool m_active_at_reset; - /** If this is a CT_ACTIVATE or CT_SWITCH type, this will contain - * the indices of the corresponding check structures that get their - * state changed (activated or switched). */ + /** Contains the indices of the corresponding check structures that + * get their state changed (activated or switched). */ std::vector<int> m_check_structures_to_change_state; /** A list of check lines that should be activated/switched when this @@ -97,6 +93,11 @@ * as huge shortcuts. */ std::vector<int> m_same_group; + enum ChangeState {CS_DEACTIVATE, CS_ACTIVATE, CS_TOGGLE}; + + void changeStatus(const std::vector<int> indices, int kart_index, + ChangeState change_state); + public: CheckStructure(CheckManager *check_manager, const XMLNode &node, unsigned int index); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-11-17 11:52:45
|
Revision: 6626 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6626&view=rev Author: hikerstk Date: 2010-11-17 11:52:39 +0000 (Wed, 17 Nov 2010) Log Message: ----------- Improved minimap so that not all (visible) quads would be displayed, but only the quads actually used in the graph. Modified Paths: -------------- main/trunk/src/tracks/graph_node.hpp main/trunk/src/tracks/quad_graph.cpp Modified: main/trunk/src/tracks/graph_node.hpp =================================================================== --- main/trunk/src/tracks/graph_node.hpp 2010-11-17 11:45:40 UTC (rev 6625) +++ main/trunk/src/tracks/graph_node.hpp 2010-11-17 11:52:39 UTC (rev 6626) @@ -99,6 +99,9 @@ int getIndex() const { return m_index; } // ------------------------------------------------------------------------ + /** Returns the quad of this graph node. */ + const Quad& getQuad() const {return m_all_quads->getQuad(m_index);} + // ------------------------------------------------------------------------ /** Returns the i-th. point of a quad. ATM this just returns the vertices * from the quads, but if necessary this method will also consider * rotated quads. So index 0 will always be lower left point, then Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2010-11-17 11:45:40 UTC (rev 6625) +++ main/trunk/src/tracks/quad_graph.cpp 2010-11-17 11:52:39 UTC (rev 6626) @@ -271,9 +271,9 @@ // Count the number of quads to display (some quads might be invisible unsigned int n = 0; - for(unsigned int i=0; i<m_all_quads->getNumberOfQuads(); i++) + for(unsigned int i=0; i<m_all_nodes.size(); i++) { - if(show_invisible || !m_all_quads->getQuad(i).isInvisible()) + if(show_invisible || !m_all_nodes[i]->getQuad().isInvisible()) n++; } @@ -286,16 +286,16 @@ // Now add all quads int i=0; - for(unsigned int count=0; count<m_all_quads->getNumberOfQuads(); count++) + for(unsigned int count=0; count<m_all_nodes.size(); count++) { // Ignore invisible quads - if(!show_invisible && m_all_quads->getQuad(count).isInvisible()) + if(!show_invisible && m_all_nodes[count]->getQuad().isInvisible()) continue; // Swap the colours from red to blue and back c.setRed (i%2 ? 255 : 0); c.setBlue(i%2 ? 0 : 255); // Transfer the 4 points of the current quad to the list of vertices - m_all_quads->getQuad(i).getVertices(new_v+4*i, c); + m_all_nodes[count]->getQuad().getVertices(new_v+4*i, c); // Set up the indices for the triangles // (note, afaik with opengl we could use quads directly, but the code This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-11-22 01:22:55
|
Revision: 6691 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6691&view=rev Author: hikerstk Date: 2010-11-22 01:22:49 +0000 (Mon, 22 Nov 2010) Log Message: ----------- Zipper are now converted into buller objects. This means that a zipper should be flat now and not slightly raised anymore. This fixes bug 3114770. Modified Paths: -------------- main/trunk/src/tracks/track.cpp main/trunk/src/tracks/track.hpp Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2010-11-22 01:10:37 UTC (rev 6690) +++ main/trunk/src/tracks/track.cpp 2010-11-22 01:22:49 UTC (rev 6691) @@ -67,7 +67,6 @@ m_screenshot = ""; m_version = 0; m_track_mesh = new TriangleMesh(); - m_non_collision_mesh = new TriangleMesh(); m_all_nodes.clear(); m_all_meshes.clear(); m_is_arena = false; @@ -89,7 +88,6 @@ if(m_check_manager) delete m_check_manager; if(m_mini_map) irr_driver->removeTexture(m_mini_map); delete m_track_mesh; - delete m_non_collision_mesh; } // ~Track //----------------------------------------------------------------------------- @@ -153,8 +151,6 @@ irr_driver->removeNode(m_sun); - delete m_non_collision_mesh; - m_non_collision_mesh = new TriangleMesh(); delete m_track_mesh; m_track_mesh = new TriangleMesh(); @@ -342,11 +338,6 @@ fprintf(stderr, "ERROR: m_track_mesh == NULL, cannot createPhysicsModel\n"); return; } - if (m_non_collision_mesh == NULL) - { - fprintf(stderr, "ERROR: m_track_mesh == NULL, cannot createPhysicsModel\n"); - return; - } m_track_mesh->removeBody(); for(unsigned int i=main_track_count; i<m_all_nodes.size(); i++) @@ -354,7 +345,6 @@ convertTrackToBullet(m_all_nodes[i]); } m_track_mesh->createBody(); - m_non_collision_mesh->createBody(btCollisionObject::CF_NO_CONTACT_RESPONSE); } // createPhysicsModel @@ -428,10 +418,6 @@ { std::string image = std::string(core::stringc(t->getName()).c_str()); material=material_manager->getMaterial(StringUtils::getBasename(image)); - // Zipper are converted to non-collision mesh, since otherwise - // the road becomes 'bumpy' if the meshes are not 100% correctly - // aligned. - if(material->isZipper()) tmesh = m_non_collision_mesh; // Materials to be ignored are not converted into bullet meshes. if(material->isIgnore()) continue; } Modified: main/trunk/src/tracks/track.hpp =================================================================== --- main/trunk/src/tracks/track.hpp 2010-11-22 01:10:37 UTC (rev 6690) +++ main/trunk/src/tracks/track.hpp 2010-11-22 01:22:49 UTC (rev 6691) @@ -70,7 +70,6 @@ std::vector<scene::IMesh*> m_all_meshes; scene::ILightSceneNode *m_sun; TriangleMesh* m_track_mesh; - TriangleMesh* m_non_collision_mesh; /** Minimum coordinates of this track. */ Vec3 m_aabb_min; /** Maximum coordinates of this track. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2012-02-13 23:40:33
|
Revision: 10842 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=10842&view=rev Author: auria Date: 2012-02-13 23:40:27 +0000 (Mon, 13 Feb 2012) Log Message: ----------- When failing to load a track object, don't leave a malformed TrackObject instance in the track_object_manager Modified Paths: -------------- main/trunk/src/tracks/track_object.cpp main/trunk/src/tracks/track_object_manager.cpp Modified: main/trunk/src/tracks/track_object.cpp =================================================================== --- main/trunk/src/tracks/track_object.cpp 2012-02-13 23:32:15 UTC (rev 10841) +++ main/trunk/src/tracks/track_object.cpp 2012-02-13 23:40:27 UTC (rev 10842) @@ -152,11 +152,8 @@ if(!m_mesh) { - fprintf(stderr, - "Warning: model '%s' in node '%s' not found and is ignored.\n", - model_name.c_str(), xml_node.getName().c_str()); - return; - } // if(!m_mesh) + throw std::runtime_error("Model '" + model_name + "' cannot be found"); + } } m_mesh->grab(); Modified: main/trunk/src/tracks/track_object_manager.cpp =================================================================== --- main/trunk/src/tracks/track_object_manager.cpp 2012-02-13 23:32:15 UTC (rev 10841) +++ main/trunk/src/tracks/track_object_manager.cpp 2012-02-13 23:40:27 UTC (rev 10842) @@ -47,51 +47,59 @@ */ void TrackObjectManager::add(const XMLNode &xml_node) { - std::string groupname; - xml_node.get("lod_group", &groupname); - bool is_lod = !groupname.empty(); - - std::string type; - xml_node.get("type", &type); - if(type=="movable") + try { - if (is_lod) + std::string groupname; + xml_node.get("lod_group", &groupname); + bool is_lod = !groupname.empty(); + + std::string type; + xml_node.get("type", &type); + if(type=="movable") { - m_lod_objects[groupname].push_back(new PhysicalObject(xml_node)); + if (is_lod) + { + m_lod_objects[groupname].push_back(new PhysicalObject(xml_node)); + } + else + { + m_all_objects.push_back(new PhysicalObject(xml_node)); + } } - else + else if(type=="animation") { - m_all_objects.push_back(new PhysicalObject(xml_node)); + if (is_lod) + { + m_lod_objects[groupname].push_back(new ThreeDAnimation(xml_node)); + } + else + { + m_all_objects.push_back(new ThreeDAnimation(xml_node)); + } } - } - else if(type=="animation") - { - if (is_lod) + else if(type=="billboard") { - m_lod_objects[groupname].push_back(new ThreeDAnimation(xml_node)); + m_all_objects.push_back(new BillboardAnimation(xml_node)); } + else if(type=="sfx-emitter") + { + m_all_objects.push_back(new TrackObject(xml_node)); + } + else if(type=="action-trigger") + { + m_all_objects.push_back(new TrackObject(xml_node)); + } else { - m_all_objects.push_back(new ThreeDAnimation(xml_node)); + fprintf(stderr, "Unknown track object: '%s' - ignored.\n", + type.c_str()); } } - else if(type=="billboard") + catch (std::exception& e) { - m_all_objects.push_back(new BillboardAnimation(xml_node)); + fprintf(stderr, "[TrackObjectManager] WARNING: Could not load track object. Reason : %s\n", + e.what()); } - else if(type=="sfx-emitter") - { - m_all_objects.push_back(new TrackObject(xml_node)); - } - else if(type=="action-trigger") - { - m_all_objects.push_back(new TrackObject(xml_node)); - } - else - { - fprintf(stderr, "Unknown track object: '%s' - ignored.\n", - type.c_str()); - } } // add // ---------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2012-10-21 20:48:39
|
Revision: 11730 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11730&view=rev Author: hikerstk Date: 2012-10-21 20:48:33 +0000 (Sun, 21 Oct 2012) Log Message: ----------- Use maximum height of a quad when determining if a kart is on a quad or not. This fixes the problem that the AI can not drive up the ramp in sandtrack. Modified Paths: -------------- main/trunk/src/tracks/quad.cpp main/trunk/src/tracks/quad.hpp Modified: main/trunk/src/tracks/quad.cpp =================================================================== --- main/trunk/src/tracks/quad.cpp 2012-10-21 00:43:15 UTC (rev 11729) +++ main/trunk/src/tracks/quad.cpp 2012-10-21 20:48:33 UTC (rev 11730) @@ -44,6 +44,8 @@ m_center = 0.25f*(p0+p1+p2+p3); m_min_height = std::min ( std::min(p0.getY(), p1.getY()), std::min(p2.getY(), p3.getY()) ); + m_max_height = std::max ( std::max(p0.getY(), p1.getY()), + std::max(p2.getY(), p3.getY()) ); m_invisible = invisible; m_ai_ignore = ai_ignore; @@ -95,7 +97,7 @@ // is taken into account, too. to simplify this test we only compare // with the minimum height of the quad (and not with the actual // height of the quad at the point where the kart is). - if(p.getY() - m_min_height > 5.0f || + if(p.getY() - m_max_height > 5.0f || p.getY() - m_min_height < -1.0f ) return false; Modified: main/trunk/src/tracks/quad.hpp =================================================================== --- main/trunk/src/tracks/quad.hpp 2012-10-21 00:43:15 UTC (rev 11729) +++ main/trunk/src/tracks/quad.hpp 2012-10-21 20:48:33 UTC (rev 11730) @@ -47,6 +47,10 @@ * are on top of each other when determining the sector a kart is on. */ float m_min_height; + /** The maximum height of the quad, used together with m_min_height + * to distinguish between quads which are on top of each other. */ + float m_max_height; + /** Set to true if this quad should not be shown in the minimap. */ bool m_invisible; @@ -67,9 +71,9 @@ const Vec3& getCenter () const {return m_center; } // ------------------------------------------------------------------------ /** Returns the minimum height of a quad. */ - float getMinHeight() const { return m_min_height; } + float getMinHeight() const { return m_min_height; } // ------------------------------------------------------------------------ - /** Returns true of this quad is invisible, i.e. not to be shown in + /** Returns true of this quad is invisible, i.e. not to be shown in * the minimap. */ bool isInvisible() const { return m_invisible; } // ------------------------------------------------------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-11-28 22:07:12
|
Revision: 6746 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6746&view=rev Author: hikerstk Date: 2010-11-28 22:07:05 +0000 (Sun, 28 Nov 2010) Log Message: ----------- Fixed memory leak (check_manager and therefore all check structures were not freed). Modified Paths: -------------- main/trunk/src/tracks/check_manager.cpp main/trunk/src/tracks/check_manager.hpp main/trunk/src/tracks/track.cpp Modified: main/trunk/src/tracks/check_manager.cpp =================================================================== --- main/trunk/src/tracks/check_manager.cpp 2010-11-28 20:54:45 UTC (rev 6745) +++ main/trunk/src/tracks/check_manager.cpp 2010-11-28 22:07:05 UTC (rev 6746) @@ -55,6 +55,16 @@ } // CheckManager // ---------------------------------------------------------------------------- +CheckManager::~CheckManager() +{ + for(unsigned int i=0; i<m_all_checks.size(); i++) + { + delete m_all_checks[i]; + } +} // ~CheckManager + +// ---------------------------------------------------------------------------- + /** Resets all checks. */ void CheckManager::reset(const Track &track) { Modified: main/trunk/src/tracks/check_manager.hpp =================================================================== --- main/trunk/src/tracks/check_manager.hpp 2010-11-28 20:54:45 UTC (rev 6745) +++ main/trunk/src/tracks/check_manager.hpp 2010-11-28 22:07:05 UTC (rev 6746) @@ -36,6 +36,7 @@ std::vector<CheckStructure*> m_all_checks; public: CheckManager(const XMLNode &node, Track *track); + ~CheckManager(); void update(float dt); void reset(const Track &track); /** Returns the nth. check structure. */ Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2010-11-28 20:54:45 UTC (rev 6745) +++ main/trunk/src/tracks/track.cpp 2010-11-28 22:07:05 UTC (rev 6746) @@ -146,6 +146,12 @@ m_animation_manager = NULL; } + if(m_check_manager) + { + delete m_check_manager; + m_check_manager=NULL; + } + delete m_track_object_manager; m_track_object_manager = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-11-28 22:08:08
|
Revision: 6747 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6747&view=rev Author: hikerstk Date: 2010-11-28 22:08:02 +0000 (Sun, 28 Nov 2010) Log Message: ----------- Added visual debugging to check lines. Modified Paths: -------------- main/trunk/src/tracks/check_line.cpp main/trunk/src/tracks/check_line.hpp main/trunk/src/tracks/check_structure.hpp Modified: main/trunk/src/tracks/check_line.cpp =================================================================== --- main/trunk/src/tracks/check_line.cpp 2010-11-28 22:07:05 UTC (rev 6746) +++ main/trunk/src/tracks/check_line.cpp 2010-11-28 22:08:02 UTC (rev 6747) @@ -42,9 +42,55 @@ node.get("p2", &p2); node.get("min-height", &m_min_height); m_line.setLine(p1, p2); + if(UserConfigParams::m_check_debug) + { + video::SMaterial material; + material.setFlag(video::EMF_BACK_FACE_CULLING, false); + material.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; + scene::IMesh *mesh = irr_driver->createQuadMesh(&material, + /*create mesh*/true); + scene::IMeshBuffer *buffer = mesh->getMeshBuffer(0); + assert(buffer->getVertexType()==video::EVT_STANDARD); + irr::video::S3DVertex* vertices + = (video::S3DVertex*)buffer->getVertices(); + vertices[0].Pos = core::vector3df(p1.X, + m_min_height-m_under_min_height, + p1.Y); + vertices[1].Pos = core::vector3df(p2.X, + m_min_height-m_under_min_height, + p2.Y); + vertices[2].Pos = core::vector3df(p2.X, + m_min_height+m_over_min_height, + p2.Y); + vertices[3].Pos = core::vector3df(p1.X, + m_min_height+m_over_min_height, + p1.Y); + for(unsigned int i=0; i<4; i++) + { + vertices[i].Color = m_active_at_reset + ? video::SColor(0, 255, 0, 0) + : video::SColor(0, 128, 128, 128); + } + buffer->recalculateBoundingBox(); + mesh->setBoundingBox(buffer->getBoundingBox()); + m_debug_node = irr_driver->addMesh(mesh); + mesh->drop(); + m_debug_node->grab(); + } + else + { + m_debug_node = NULL; + } } // CheckLine // ---------------------------------------------------------------------------- +CheckLine::~CheckLine() +{ + if(m_debug_node) + m_debug_node->drop(); + +} // CheckLine +// ---------------------------------------------------------------------------- void CheckLine::reset(const Track &track) { CheckStructure::reset(track); @@ -80,8 +126,8 @@ // between -1 and 4 units (negative numbers are unlikely, but help // in case that there is 'somewhat' inside of the track, or the // checklines are a bit off in Z direction. - result = new_pos.getY()-m_min_height<4.0f && - new_pos.getY()-m_min_height>-1.0f; + result = new_pos.getY()-m_min_height<m_over_min_height && + new_pos.getY()-m_min_height>-m_under_min_height; if(UserConfigParams::m_check_debug && !result) { printf("CHECK: Kart %s crosses line, but wrong height (%f vs %f).\n", Modified: main/trunk/src/tracks/check_line.hpp =================================================================== --- main/trunk/src/tracks/check_line.hpp 2010-11-28 22:07:05 UTC (rev 6746) +++ main/trunk/src/tracks/check_line.hpp 2010-11-28 22:08:02 UTC (rev 6747) @@ -52,10 +52,21 @@ * computations. True if the value is >=0, i.e. the point is on * or to the right of the line. */ std::vector<bool> m_previous_sign; + + /** Used to display debug information about checklines. */ + scene::IMeshSceneNode *m_debug_node; + + /** How much a kart is allowed to be under the minimum height of a + * quad and still considered to be able to cross it. */ + static const int m_under_min_height = 1; + + /** How much a kart is allowed to be over the minimum height of a + * quad and still considered to be able to cross it. */ + static const int m_over_min_height = 4; public: CheckLine(CheckManager *check_manager, const XMLNode &node, unsigned int index); - virtual ~CheckLine() {}; + virtual ~CheckLine(); virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int indx); virtual void reset(const Track &track); /** Returns the actual line data for this checkpoint. */ Modified: main/trunk/src/tracks/check_structure.hpp =================================================================== --- main/trunk/src/tracks/check_structure.hpp 2010-11-28 22:07:05 UTC (rev 6746) +++ main/trunk/src/tracks/check_structure.hpp 2010-11-28 22:08:02 UTC (rev 6747) @@ -68,6 +68,10 @@ std::vector<Vec3> m_previous_position; /** Stores if this check structure is active (for a given kart). */ std::vector<bool> m_is_active; + + /** True if this check structure should be activated at a reset. */ + bool m_active_at_reset; + private: /** Stores a pointer to the check manager. */ CheckManager *m_check_manager; @@ -79,9 +83,6 @@ * debugging (use --check-debug option). */ unsigned int m_index; - /** True if this check structure should be activated at a reset. */ - bool m_active_at_reset; - /** Contains the indices of the corresponding check structures that * get their state changed (activated or switched). */ std::vector<int> m_check_structures_to_change_state; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-11-29 05:26:52
|
Revision: 6765 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6765&view=rev Author: hikerstk Date: 2010-11-29 05:26:45 +0000 (Mon, 29 Nov 2010) Log Message: ----------- Adjust color of check lines according to state: active ones are light red, inactive ones white-grey. Modified Paths: -------------- main/trunk/src/tracks/check_line.cpp main/trunk/src/tracks/check_line.hpp main/trunk/src/tracks/check_structure.cpp main/trunk/src/tracks/check_structure.hpp Modified: main/trunk/src/tracks/check_line.cpp =================================================================== --- main/trunk/src/tracks/check_line.cpp 2010-11-29 05:24:31 UTC (rev 6764) +++ main/trunk/src/tracks/check_line.cpp 2010-11-29 05:26:45 UTC (rev 6765) @@ -21,6 +21,8 @@ #include <string> +#include "irrlicht.h" + #include "io/xml_node.hpp" #include "modes/world.hpp" #include "race/race_manager.hpp" @@ -46,6 +48,7 @@ { video::SMaterial material; material.setFlag(video::EMF_BACK_FACE_CULLING, false); + material.setFlag(video::EMF_LIGHTING, false); material.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; scene::IMesh *mesh = irr_driver->createQuadMesh(&material, /*create mesh*/true); @@ -102,6 +105,22 @@ } // reset // ---------------------------------------------------------------------------- +void CheckLine::changeDebugColor(bool is_active) +{ + assert(m_debug_node); + + scene::IMesh *mesh = m_debug_node->getMesh(); + scene::IMeshBuffer *buffer = mesh->getMeshBuffer(0); + irr::video::S3DVertex* vertices + = (video::S3DVertex*)buffer->getVertices(); + for(unsigned int i=0; i<4; i++) + { + vertices[i].Color = is_active ? video::SColor(0, 255, 0, 0) + : video::SColor(0, 128, 128, 128); + } +} // changeDebugColor + +// ---------------------------------------------------------------------------- /** True if going from old_pos to new_pos crosses this checkline. This function * is called from update (of the checkline structure). * \param old_pos Position in previous frame. Modified: main/trunk/src/tracks/check_line.hpp =================================================================== --- main/trunk/src/tracks/check_line.hpp 2010-11-29 05:24:31 UTC (rev 6764) +++ main/trunk/src/tracks/check_line.hpp 2010-11-29 05:26:45 UTC (rev 6765) @@ -69,6 +69,7 @@ virtual ~CheckLine(); virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int indx); virtual void reset(const Track &track); + virtual void changeDebugColor(bool is_active); /** Returns the actual line data for this checkpoint. */ const core::line2df &getLine2D() const {return m_line;} }; // CheckLine Modified: main/trunk/src/tracks/check_structure.cpp =================================================================== --- main/trunk/src/tracks/check_structure.cpp 2010-11-29 05:24:31 UTC (rev 6764) +++ main/trunk/src/tracks/check_structure.cpp 2010-11-29 05:26:45 UTC (rev 6765) @@ -121,6 +121,10 @@ int kart_index, ChangeState change_state) { + bool update_debug_colors = + UserConfigParams::m_check_debug && + kart_index==World::getWorld()->getPlayerKart(0)->getWorldKartId(); + for(unsigned int i=0; i<indices.size(); i++) { CheckStructure *cs = @@ -160,7 +164,10 @@ } cs->m_is_active[kart_index] = !cs->m_is_active[kart_index]; } // switch - + if(update_debug_colors) + { + cs->changeDebugColor(cs->m_is_active[kart_index]); + } } // for i<indices.size() } //changeStatus Modified: main/trunk/src/tracks/check_structure.hpp =================================================================== --- main/trunk/src/tracks/check_structure.hpp 2010-11-29 05:24:31 UTC (rev 6764) +++ main/trunk/src/tracks/check_structure.hpp 2010-11-29 05:26:45 UTC (rev 6765) @@ -104,6 +104,7 @@ unsigned int index); virtual ~CheckStructure() {}; virtual void update(float dt); + virtual void changeDebugColor(bool is_active) {} /** True if going from old_pos to new_pos crosses this checkline. This function * is called from update (of the checkline structure). * \param old_pos Position in previous frame. @@ -117,6 +118,7 @@ /** Returns the type of this check structure. */ CheckType getType() const { return m_check_type; } + }; // CheckStructure #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-01-31 02:27:25
|
Revision: 7568 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=7568&view=rev Author: auria Date: 2011-01-31 02:27:19 +0000 (Mon, 31 Jan 2011) Log Message: ----------- Add support for full particle emitters anywhere in track Modified Paths: -------------- main/trunk/src/tracks/track.cpp main/trunk/src/tracks/track.hpp Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2011-01-30 23:08:25 UTC (rev 7567) +++ main/trunk/src/tracks/track.cpp 2011-01-31 02:27:19 UTC (rev 7568) @@ -132,6 +132,8 @@ irr_driver->removeNode(m_all_nodes[i]); } m_all_nodes.clear(); + + m_all_emitters.clearAndDeleteAll(); if (m_sky_particles_emitter) delete m_sky_particles_emitter; m_sky_particles_emitter = NULL; @@ -831,41 +833,21 @@ } else if (name=="particle-emitter") { - // based on http://irrlicht.sourceforge.net/tut008.html std::string path; - std::vector<float> emitter_origin; - scene::ISceneManager* smgr = irr_driver->getSceneManager(); - node->get("texture", &path); + irr::core::vector3df emitter_origin; + node->get("kind", &path); node->get("origin", &emitter_origin); - video::ITexture* particle_texture_load; - particle_texture_load = irr_driver->getTexture(path); - scene::IParticleSystemSceneNode* ps = smgr->addParticleSystemSceneNode(false); - - scene::IParticleEmitter* em = ps->createBoxEmitter( - core::aabbox3d<f32>(-2,0,-2,2,1,2), // emitter size - core::vector3df(0.0f,0.06f,0.0f), // initial direction - 2,3, // emit rate - video::SColor(0,255,255,255), // darkest color - video::SColor(0,255,255,255), // brightest color - 800,2000,0, // min and max age, angle - core::dimension2df(1.f,1.f), // min size - core::dimension2df(2.f,2.f)); // max size - - ps->setEmitter(em); - em->drop(); - - scene::IParticleAffector* paf = ps->createFadeOutParticleAffector(); - - ps->addAffector(paf); - paf->drop(); - - ps->setPosition(core::vector3df(emitter_origin[0], emitter_origin[2], emitter_origin[1] )); - ps->setScale(core::vector3df(1,1,1)); - ps->setMaterialFlag(video::EMF_LIGHTING, false); - ps->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false); - ps->setMaterialTexture(0, particle_texture_load); - ps->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL); + try + { + ParticleKind* kind = ParticleKindManager::get()->getParticles( path.c_str() ); + ParticleEmitter* emitter = new ParticleEmitter( kind, emitter_origin ); + m_all_emitters.push_back(emitter); + } + catch (std::runtime_error& e) + { + fprintf(stderr, "[Track] WARNING: Could not load particles '%s'; cause :\n %s", path.c_str(), e.what()); + } } else if(name=="sun") { Modified: main/trunk/src/tracks/track.hpp =================================================================== --- main/trunk/src/tracks/track.hpp 2011-01-30 23:08:25 UTC (rev 7567) +++ main/trunk/src/tracks/track.hpp 2011-01-31 02:27:19 UTC (rev 7568) @@ -27,11 +27,14 @@ using namespace irr; #include "LinearMath/btTransform.h" + #include "audio/music_information.hpp" #include "graphics/material.hpp" +#include "graphics/particle_emitter.hpp" #include "items/item.hpp" #include "tracks/quad_graph.hpp" #include "utils/vec3.hpp" +#include "utils/ptr_vector.hpp" class AnimationManager; class BezierCurve; @@ -69,6 +72,7 @@ std::vector<std::string> m_groups; std::vector<scene::ISceneNode*> m_all_nodes; std::vector<scene::IMesh*> m_all_meshes; + ptr_vector<ParticleEmitter> m_all_emitters; scene::ILightSceneNode *m_sun; TriangleMesh* m_track_mesh; /** Minimum coordinates of this track. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2011-02-10 21:33:32
|
Revision: 7672 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=7672&view=rev Author: hikerstk Date: 2011-02-10 21:33:26 +0000 (Thu, 10 Feb 2011) Log Message: ----------- Added lap line (not fully tuned yet). Modified Paths: -------------- main/trunk/src/tracks/quad_graph.cpp main/trunk/src/tracks/quad_graph.hpp main/trunk/src/tracks/terrain_info.cpp Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2011-02-10 13:38:14 UTC (rev 7671) +++ main/trunk/src/tracks/quad_graph.cpp 2011-02-10 21:33:26 UTC (rev 7672) @@ -259,7 +259,7 @@ /** Creates a mesh for this graph. The mesh is not added to a scene node and * is stored in m_mesh. */ -void QuadGraph::createMesh(bool show_invisible) +void QuadGraph::createMesh(bool show_invisible, bool draw_lap_line) { // The debug track will not be lighted or culled. video::SMaterial m; @@ -278,10 +278,10 @@ } // Four vertices for each of the n-1 remaining quads - video::S3DVertex *new_v = new video::S3DVertex[n*4]; + video::S3DVertex *new_v = new video::S3DVertex[4*n]; // Each quad consists of 2 triangles with 3 elements, so // we need 2*3 indices for each quad. - irr::u16 *ind = new irr::u16[n*6]; + irr::u16 *ind = new irr::u16[6*n]; video::SColor c(255, 255, 0, 0); // Now add all quads @@ -310,6 +310,50 @@ } // for i=1; i<m_all_quads m_mesh_buffer->append(new_v, n*4, ind, n*6); + + if(draw_lap_line) + { + video::S3DVertex lap_v[4]; + irr::u16 lap_ind[6]; + video::SColor c(128, 128, 128, 128); + m_all_nodes[0]->getQuad().getVertices(lap_v, c); + + // Now scale the length (distance between vertix 0 and 3 + // and between 1 and 2) to be 'length': + Vec3 bb_min, bb_max; + m_all_quads->getBoundingBox(&bb_min, &bb_max); + const float length=(bb_max.getZ()-bb_min.getZ())/20.0f; + + core::vector3df dl = lap_v[3].Pos-lap_v[0].Pos; + float ll2 = dl.getLengthSQ(); + if(ll2<0.001) + lap_v[3].Pos = lap_v[0].Pos+core::vector3df(0, 0, 1); + else + lap_v[3].Pos = lap_v[0].Pos+dl*length/sqrt(ll2); + + core::vector3df dr = lap_v[2].Pos-lap_v[1].Pos; + float lr2 = dr.getLengthSQ(); + if(lr2<0.001) + lap_v[2].Pos = lap_v[1].Pos+core::vector3df(0, 0, 1); + else + lap_v[2].Pos = lap_v[1].Pos+dr*length/sqrt(lr2); +lap_v[3].Pos.Y += 1.0f; + lap_ind[0] = 0; + lap_ind[1] = 1; + lap_ind[2] = 2; + lap_ind[3] = 0; + lap_ind[4] = 3; + lap_ind[5] = 2; + lap_v[0].TCoords = core::vector2df(0,0); + lap_v[1].TCoords = core::vector2df(3,0); + lap_v[2].TCoords = core::vector2df(3,1); + lap_v[3].TCoords = core::vector2df(0,1); + m_mesh_buffer->append(lap_v, 4, lap_ind, 6); + video::SMaterial &m = m_mesh_buffer->getMaterial(); + video::ITexture *t = irr_driver->getTexture("chess.png"); + m.setTexture(0, t); + } + // Instead of setting the bounding boxes, we could just disable culling, // since the debug track should always be drawn. //m_node->setAutomaticCulling(scene::EAC_OFF); @@ -558,13 +602,17 @@ const video::SColor &fill_color) { IrrDriver::RTTProvider rttProvider(dimension, name); - createMesh(/*show_invisible part of the track*/false); + createMesh(/*show_invisible part of the track*/ false, + /*createLapLine*/ true ); video::S3DVertex *v = (video::S3DVertex*)m_mesh_buffer->getVertices(); - for(unsigned int i=0; i<m_mesh_buffer->getVertexCount(); i++) + // The last 4 vertices are for the lap counting line, which + // is textured, so don't change the colour there. + for(unsigned int i=0; i<m_mesh_buffer->getVertexCount()-4; i++) { v[i].Color = fill_color; } + m_node = irr_driver->addMesh(m_mesh); // add Debug Mesh #ifdef DEBUG m_node->setName("minimap-mesh"); Modified: main/trunk/src/tracks/quad_graph.hpp =================================================================== --- main/trunk/src/tracks/quad_graph.hpp 2011-02-10 13:38:14 UTC (rev 7671) +++ main/trunk/src/tracks/quad_graph.hpp 2011-02-10 21:33:26 UTC (rev 7672) @@ -62,7 +62,7 @@ void setDefaultSuccessors(); void load (const std::string &filename); - void createMesh(bool show_invisible=true); + void createMesh(bool show_invisible=true, bool draw_lap_line=false); int getPredecessor(unsigned int target_node) const; public: static const int UNKNOWN_SECTOR; Modified: main/trunk/src/tracks/terrain_info.cpp =================================================================== --- main/trunk/src/tracks/terrain_info.cpp 2011-02-10 13:38:14 UTC (rev 7671) +++ main/trunk/src/tracks/terrain_info.cpp 2011-02-10 21:33:26 UTC (rev 7672) @@ -69,7 +69,7 @@ { btTransform from; from.setIdentity(); - from.setOrigin(m_hit_point+btVector3(0,5,0)); + from.setOrigin(m_hit_point); btTransform to; to.setIdentity(); to.setOrigin(m_hit_point+btVector3(0, 10000.0f, 0)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2011-02-11 10:43:27
|
Revision: 7678 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=7678&view=rev Author: hikerstk Date: 2011-02-11 10:43:20 +0000 (Fri, 11 Feb 2011) Log Message: ----------- Made lap line consistently red (code to get a checkered lap line is still in but commented out - it looks quite for in the shorter tracks imho). Modified Paths: -------------- main/trunk/src/tracks/quad_graph.cpp main/trunk/src/tracks/quad_graph.hpp Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2011-02-11 04:24:04 UTC (rev 7677) +++ main/trunk/src/tracks/quad_graph.cpp 2011-02-11 10:43:20 UTC (rev 7678) @@ -259,7 +259,9 @@ /** Creates a mesh for this graph. The mesh is not added to a scene node and * is stored in m_mesh. */ -void QuadGraph::createMesh(bool show_invisible, bool draw_lap_line) +void QuadGraph::createMesh(bool show_invisible, + const video::SColor *track_color, + const video::SColor *lap_color) { // The debug track will not be lighted or culled. video::SMaterial m; @@ -284,6 +286,9 @@ irr::u16 *ind = new irr::u16[6*n]; video::SColor c(255, 255, 0, 0); + if(track_color) + c = *track_color; + // Now add all quads int i=0; for(unsigned int count=0; count<m_all_nodes.size(); count++) @@ -292,8 +297,11 @@ if(!show_invisible && m_all_nodes[count]->getQuad().isInvisible()) continue; // Swap the colours from red to blue and back - c.setRed (i%2 ? 255 : 0); - c.setBlue(i%2 ? 0 : 255); + if(!track_color) + { + c.setRed (i%2 ? 255 : 0); + c.setBlue(i%2 ? 0 : 255); + } // Transfer the 4 points of the current quad to the list of vertices m_all_nodes[count]->getQuad().getVertices(new_v+4*i, c); @@ -311,18 +319,20 @@ m_mesh_buffer->append(new_v, n*4, ind, n*6); - if(draw_lap_line) + if(lap_color) { video::S3DVertex lap_v[4]; irr::u16 lap_ind[6]; - video::SColor c(128, 128, 128, 128); - m_all_nodes[0]->getQuad().getVertices(lap_v, c); + video::SColor c(128, 255, 0, 0); + m_all_nodes[0]->getQuad().getVertices(lap_v, *lap_color); // Now scale the length (distance between vertix 0 and 3 // and between 1 and 2) to be 'length': Vec3 bb_min, bb_max; m_all_quads->getBoundingBox(&bb_min, &bb_max); - const float length=(bb_max.getZ()-bb_min.getZ())/20.0f; + // Length of the lap line about 3% of the 'height' + // of the track. + const float length=(bb_max.getZ()-bb_min.getZ())*0.03; core::vector3df dl = lap_v[3].Pos-lap_v[0].Pos; float ll2 = dl.getLengthSQ(); @@ -337,13 +347,19 @@ lap_v[2].Pos = lap_v[1].Pos+core::vector3df(0, 0, 1); else lap_v[2].Pos = lap_v[1].Pos+dr*length/sqrt(lr2); -lap_v[3].Pos.Y += 1.0f; lap_ind[0] = 0; lap_ind[1] = 1; lap_ind[2] = 2; lap_ind[3] = 0; - lap_ind[4] = 3; - lap_ind[5] = 2; + lap_ind[4] = 2; + lap_ind[5] = 3; + // Set it a bit higher to avoid issued with z fighting, + // i.e. part of the lap line might not be visible. + for(unsigned int i=0; i<4; i++) + lap_v[i].Pos.Y += 0.1f; +#ifndef USE_TEXTURED_LINE + m_mesh_buffer->append(lap_v, 4, lap_ind, 6); +#else lap_v[0].TCoords = core::vector2df(0,0); lap_v[1].TCoords = core::vector2df(3,0); lap_v[2].TCoords = core::vector2df(3,1); @@ -352,6 +368,7 @@ video::SMaterial &m = m_mesh_buffer->getMaterial(); video::ITexture *t = irr_driver->getTexture("chess.png"); m.setTexture(0, t); +#endif } // Instead of setting the bounding boxes, we could just disable culling, @@ -602,16 +619,11 @@ const video::SColor &fill_color) { IrrDriver::RTTProvider rttProvider(dimension, name); + video::SColor red(128, 255, 0, 0); createMesh(/*show_invisible part of the track*/ false, - /*createLapLine*/ true ); + /*track_color*/ &fill_color, + /*lap line color*/ &red ); video::S3DVertex *v = (video::S3DVertex*)m_mesh_buffer->getVertices(); - // The last 4 vertices are for the lap counting line, which - // is textured, so don't change the colour there. - for(unsigned int i=0; i<m_mesh_buffer->getVertexCount()-4; i++) - { - v[i].Color = fill_color; - } - m_node = irr_driver->addMesh(m_mesh); // add Debug Mesh #ifdef DEBUG Modified: main/trunk/src/tracks/quad_graph.hpp =================================================================== --- main/trunk/src/tracks/quad_graph.hpp 2011-02-11 04:24:04 UTC (rev 7677) +++ main/trunk/src/tracks/quad_graph.hpp 2011-02-11 10:43:20 UTC (rev 7678) @@ -62,7 +62,9 @@ void setDefaultSuccessors(); void load (const std::string &filename); - void createMesh(bool show_invisible=true, bool draw_lap_line=false); + void createMesh(bool show_invisible=true, + const video::SColor *track_color=NULL, + const video::SColor *lap_color=NULL); int getPredecessor(unsigned int target_node) const; public: static const int UNKNOWN_SECTOR; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |