[Supertuxkart-commit] SF.net SVN: supertuxkart:[11730] main/trunk/src/tracks From: - 2012-10-21 20:48 ```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. ```

[Supertuxkart-commit] SF.net SVN: supertuxkart:[4319] main/trunk/src/tracks <hikerstk@us...>
 [Supertuxkart-commit] SF.net SVN: supertuxkart:[4405] main/trunk/src/tracks From: - 2010-01-07 01:14 ```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; 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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[4598] main/trunk/src/tracks From: - 2010-02-01 11:34 ```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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[4998] main/trunk/src/tracks From: - 2010-03-15 09:20 ```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

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[4999] main/trunk/src/tracks From: - 2010-03-15 09:21 ```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

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[5032] main/trunk/src/tracks From: - 2010-03-19 10:39 ```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

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[5180] main/trunk/src/tracks From: - 2010-04-12 14:23 ```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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[5251] main/trunk/src/tracks From: - 2010-04-23 20:53 ```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 #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 m_all_objects; public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[5674] main/trunk/src/tracks From: - 2010-07-08 23:03 ```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; iaddMesh(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; icleanupDebugMesh(); + if(m_quad_graph) + { + delete m_quad_graph; + m_quad_graph = NULL; + } item_manager->cleanup(); for(unsigned int i=0; i

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[5722] main/trunk/src/tracks From: - 2010-08-04 10:33 ```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; igetVertexCount(); 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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[6160] main/trunk/src/tracks From: - 2010-09-28 23:27 ```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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[6161] main/trunk/src/tracks From: - 2010-09-28 23:29 ```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; igetType()==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; igetCheckStructure(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; igetCheckStructure(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 igetCheckStructure(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 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 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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[6285] main/trunk/src/tracks From: - 2010-10-14 00:56 ```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; isize(); 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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[6465] main/trunk/src/tracks From: - 2010-11-08 23:58 ```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; igetNumNodes(); 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 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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[6530] main/trunk/src/tracks From: - 2010-11-14 21:47 ```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 + #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 indices, + int kart_index, + ChangeState change_state) +{ + for(unsigned int i=0; igetCheckStructure(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 inewLap(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; igetCheckStructure(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; igetCheckStructure(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 igetCheckStructure(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 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 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 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 m_same_group; + enum ChangeState {CS_DEACTIVATE, CS_ACTIVATE, CS_TOGGLE}; + + void changeStatus(const std::vector 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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[6626] main/trunk/src/tracks From: - 2010-11-17 11:52 ```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; igetNumberOfQuads(); i++) + for(unsigned int i=0; igetQuad(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; countgetNumberOfQuads(); count++) + for(unsigned int count=0; countgetQuad(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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[6691] main/trunk/src/tracks From: - 2010-11-22 01:22 ```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; icreateBody(); - 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 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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[6746] main/trunk/src/tracks From: - 2010-11-28 22:07 ```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; 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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[6747] main/trunk/src/tracks From: - 2010-11-28 22: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_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 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 m_previous_position; /** Stores if this check structure is active (for a given kart). */ std::vector 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 m_check_structures_to_change_state; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[6765] main/trunk/src/tracks From: - 2010-11-29 05:26 ```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 +#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; im_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

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[7568] main/trunk/src/tracks From: - 2011-01-31 02:27 ```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 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(-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 m_groups; std::vector m_all_nodes; std::vector m_all_meshes; + ptr_vector 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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[7672] main/trunk/src/tracks From: - 2011-02-10 21:33 ```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; iappend(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; igetVertexCount(); 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; igetVertexCount()-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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[7678] main/trunk/src/tracks From: - 2011-02-11 10:43 ```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; countgetQuad().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; igetVertexCount()-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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[7704] main/trunk/src/tracks From: - 2011-02-15 09:10 ```Revision: 7704 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=7704&view=rev Author: hikerstk Date: 2011-02-15 09:10:45 +0000 (Tue, 15 Feb 2011) Log Message: ----------- Added warning message is a item projected on the terrain does not hit the terrain. In this case the original position is kept. Additionally the raycast starts from a slightly higher position to allow for some floating point errors in the projection. Fixe bug #63 (floating powerups). 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-02-14 03:55:26 UTC (rev 7703) +++ main/trunk/src/tracks/track.cpp 2011-02-15 09:10:45 UTC (rev 7704) @@ -1112,7 +1112,19 @@ // if only 2d coordinates are given, let the item fall from very high if(drop) { - loc.setY(getTerrainHeight(loc)); + // If raycast is used, increase the start position slightly + // in case that the point is too close to the actual surface + // (e.g. floating point errors can cause a problem here). + loc += Vec3(0,0.1f,0); + bool drop_success = setTerrainHeight(&loc); +#ifdef DEBUG + if(!drop_success) + { + printf("Item at position (%f,%f,%f) can not be dropped\n", + loc.getX(), loc.getY(), loc.getZ()); + printf("onto terrain - position unchanged.\n"); + } +#endif } // Don't tilt the items, since otherwise the rotation will look odd, @@ -1124,17 +1136,25 @@ } // itemCommand // ---------------------------------------------------------------------------- -/** Simplified version to determine only the height of the terrain. - * \param pos Position at which to determine the height (x,y coordinates - * are only used). - * \return The height at the x,y coordinates. +/** Does a raycast from the given position, and if terrain was found + * adjust the Y position of the given vector to the actual terrain + * height. If no terrain is found, false is returned and the + * y position is not modified. + * \param pos Pointer to the position at which to determine the + * height. If terrain is found, its Y position will be + * set to the actual height. + * \return True if terrain was found and the height was adjusted. */ -float Track::getTerrainHeight(const Vec3 &pos) const +bool Track::setTerrainHeight(Vec3 *pos) const { Vec3 hit_point; Vec3 normal; const Material *m; - Vec3 to=pos+Vec3(0,-10000,0); - m_track_mesh->castRay(pos, to, &hit_point, &m, &normal); - return hit_point.getY(); -} // getTerrainHeight + Vec3 to=*pos+Vec3(0,-10000,0); + if(m_track_mesh->castRay(*pos, to, &hit_point, &m, &normal)) + { + pos->setY(hit_point.getY()); + return true; + } + return false; +} // setTerrainHeight Modified: main/trunk/src/tracks/track.hpp =================================================================== --- main/trunk/src/tracks/track.hpp 2011-02-14 03:55:26 UTC (rev 7703) +++ main/trunk/src/tracks/track.hpp 2011-02-15 09:10:45 UTC (rev 7704) @@ -235,7 +235,7 @@ /** Starts the music for this track. */ void startMusic () const; - float getTerrainHeight(const Vec3 &pos) const; + bool setTerrainHeight(Vec3 *pos) const; void createPhysicsModel(unsigned int main_track_count); void update(float dt); void reset(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[7946] main/trunk/src/tracks From: - 2011-03-16 15:33 ```Revision: 7946 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=7946&view=rev Author: auria Date: 2011-03-16 15:33:49 +0000 (Wed, 16 Mar 2011) Log Message: ----------- Fixed warnings (one of which caught a real code problem) Modified Paths: -------------- main/trunk/src/tracks/quad_graph.cpp main/trunk/src/tracks/track_object.cpp Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2011-03-16 15:33:23 UTC (rev 7945) +++ main/trunk/src/tracks/quad_graph.cpp 2011-03-16 15:33:49 UTC (rev 7946) @@ -629,7 +629,7 @@ createMesh(/*show_invisible part of the track*/ false, /*track_color*/ &fill_color, /*lap line color*/ &red ); - video::S3DVertex *v = (video::S3DVertex*)m_mesh_buffer->getVertices(); + //video::S3DVertex *v = (video::S3DVertex*)m_mesh_buffer->getVertices(); m_node = irr_driver->addMesh(m_mesh); // add Debug Mesh #ifdef DEBUG Modified: main/trunk/src/tracks/track_object.cpp =================================================================== --- main/trunk/src/tracks/track_object.cpp 2011-03-16 15:33:23 UTC (rev 7945) +++ main/trunk/src/tracks/track_object.cpp 2011-03-16 15:33:49 UTC (rev 7946) @@ -60,7 +60,7 @@ scene::IAnimatedMesh *mesh=NULL; if(file_manager->fileExists(full_path)) { - scene::IAnimatedMesh *mesh = irr_driver->getAnimatedMesh(full_path); + mesh = irr_driver->getAnimatedMesh(full_path); } if(!mesh) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[8476] main/trunk/src/tracks From: - 2011-04-27 23:08 ```Revision: 8476 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8476&view=rev Author: hikerstk Date: 2011-04-27 23:08:35 +0000 (Wed, 27 Apr 2011) Log Message: ----------- Made the m_old_mesh_buffer a member of the class instead of a global variable. 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-04-27 22:48:36 UTC (rev 8475) +++ main/trunk/src/tracks/track.cpp 2011-04-27 23:08:35 UTC (rev 8476) @@ -115,8 +115,6 @@ * Called at the end of a race. */ -std::vector m_old_mesh_buffers; - void Track::cleanup() { if(m_quad_graph) Modified: main/trunk/src/tracks/track.hpp =================================================================== --- main/trunk/src/tracks/track.hpp 2011-04-27 22:48:36 UTC (rev 8475) +++ main/trunk/src/tracks/track.hpp 2011-04-27 23:08:35 UTC (rev 8476) @@ -83,6 +83,14 @@ /** The list of all meshes that are loaded from disk, which means * that those meshes are being cached by irrlicht, and need to be freed. */ std::vector m_all_cached_meshes; +#ifdef DEBUG + /** Used to store all buffers in irrlicht's memory cache before a track + * is loaded. After cleanup of a track we can test which meshes are + * still in the cache, and print a report of leaked meshes (of course in + * debug mode only). */ + std::vector m_old_mesh_buffers; +#endif + PtrVector m_all_emitters; scene::ILightSceneNode *m_sun; /** Used to collect the triangles for the bullet mesh. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[8479] main/trunk/src/tracks From: - 2011-04-28 12:48 ```Revision: 8479 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8479&view=rev Author: hikerstk Date: 2011-04-28 12:48:28 +0000 (Thu, 28 Apr 2011) Log Message: ----------- Added memory debug output for texture cache usage. 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-04-28 10:56:13 UTC (rev 8478) +++ main/trunk/src/tracks/track.cpp 2011-04-28 12:48:28 UTC (rev 8479) @@ -179,9 +179,10 @@ if(UserConfigParams::logMemory()) { - printf("[memory] Number of meshes in cache after cleaning up '%s': %d.\n", + printf("[memory] After cleaning '%s': mesh cache %d texture cache %d\n", getIdent().c_str(), - irr_driver->getSceneManager()->getMeshCache()->getMeshCount()); + irr_driver->getSceneManager()->getMeshCache()->getMeshCount(), + irr_driver->getVideoDriver()->getTextureCount()); #ifdef DEBUG scene::IMeshCache *cache = irr_driver->getSceneManager()->getMeshCache(); for(unsigned int i=0; igetMeshCount(); i++) @@ -198,6 +199,24 @@ name.getInternalName().c_str()); } // if name not found } // for i < cache size + + video::IVideoDriver *vd = irr_driver->getVideoDriver(); + for(unsigned int i=0; igetTextureCount(); i++) + { + video::ITexture *t = vd->getTextureByIndex(i); + std::vector::iterator p; + p = std::find(m_all_used_textures.begin(), m_all_used_textures.end(), + t); + if(p!=m_all_used_textures.end()) + { + m_all_used_textures.erase(p); + } + else + { + printf("[memory] Leaked texture '%s'.\n", + t->getName().getInternalName().c_str()); + } + } #endif } // if verbose @@ -964,9 +983,10 @@ assert(m_all_cached_meshes.size()==0); if(UserConfigParams::logMemory()) { - printf("[memory] Number of meshes in cache before loading '%s': %d.\n", - getIdent().c_str(), - irr_driver->getSceneManager()->getMeshCache()->getMeshCount()); + printf("[memory] Before loading '%s': mesh cache %d texture cache %d\n", + getIdent().c_str(), + irr_driver->getSceneManager()->getMeshCache()->getMeshCount(), + irr_driver->getVideoDriver()->getTextureCount()); #ifdef DEBUG scene::IMeshCache *cache = irr_driver->getSceneManager()->getMeshCache(); m_old_mesh_buffers.clear(); @@ -975,6 +995,14 @@ const io::SNamedPath &name=cache->getMeshName(i); m_old_mesh_buffers.push_back(name.getInternalName().c_str()); } + + m_all_used_textures.clear(); + video::IVideoDriver *vd = irr_driver->getVideoDriver(); + for(unsigned int i=0; igetTextureCount(); i++) + { + video::ITexture *t=vd->getTextureByIndex(i); + m_all_used_textures.push_back(t); + } #endif } @@ -1288,9 +1316,10 @@ } if(UserConfigParams::logMemory()) - printf("[memory] Number of meshes in cache after loading '%s': %d.\n", + printf("[memory] After loading '%s': mesh cache %d texture cache %d\n", getIdent().c_str(), - irr_driver->getSceneManager()->getMeshCache()->getMeshCount()); + irr_driver->getSceneManager()->getMeshCache()->getMeshCount(), + irr_driver->getVideoDriver()->getTextureCount()); } // loadTrackModel Modified: main/trunk/src/tracks/track.hpp =================================================================== --- main/trunk/src/tracks/track.hpp 2011-04-28 10:56:13 UTC (rev 8478) +++ main/trunk/src/tracks/track.hpp 2011-04-28 12:48:28 UTC (rev 8479) @@ -83,6 +83,9 @@ /** The list of all meshes that are loaded from disk, which means * that those meshes are being cached by irrlicht, and need to be freed. */ std::vector m_all_cached_meshes; + /** A list of textures to help in removing unused textures from irrlicht's + * texture cache after cleanup. */ + std::vector m_all_used_textures; #ifdef DEBUG /** Used to store all buffers in irrlicht's memory cache before a track * is loaded. After cleanup of a track we can test which meshes are This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[8633] main/trunk/src/tracks From: - 2011-05-18 01:00 ```Revision: 8633 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8633&view=rev Author: auria Date: 2011-05-18 01:00:26 +0000 (Wed, 18 May 2011) Log Message: ----------- Fix fog wrt LOD nodes Modified Paths: -------------- main/trunk/src/tracks/track.cpp main/trunk/src/tracks/track_object.hpp main/trunk/src/tracks/track_object_manager.cpp main/trunk/src/tracks/track_object_manager.hpp Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2011-05-18 00:42:24 UTC (rev 8632) +++ main/trunk/src/tracks/track.cpp 2011-05-18 01:00:26 UTC (rev 8633) @@ -1274,10 +1274,12 @@ { const unsigned int count = m_all_nodes.size(); for(unsigned int i=0; isetMaterialFlag(video::EMF_FOG_ENABLE, true); + { + adjustForFog(m_all_nodes[i]); + } } + m_track_object_manager->enableFog(m_use_fog); - // Sky dome and boxes support // -------------------------- if(m_sky_type==SKY_DOME && m_sky_textures.size() > 0) @@ -1365,6 +1367,15 @@ void Track::adjustForFog(scene::ISceneNode *node) { node->setMaterialFlag(video::EMF_FOG_ENABLE, m_use_fog); + + if (node->getType() == scene::ESNT_LOD_NODE) + { + std::vector& subnodes = ((LODNode*)node)->getAllNodes(); + for (unsigned int n=0; nsetMaterialFlag(video::EMF_FOG_ENABLE, true); + } + } } // adjustForFog //----------------------------------------------------------------------------- Modified: main/trunk/src/tracks/track_object.hpp =================================================================== --- main/trunk/src/tracks/track_object.hpp 2011-05-18 00:42:24 UTC (rev 8632) +++ main/trunk/src/tracks/track_object.hpp 2011-05-18 01:00:26 UTC (rev 8633) @@ -86,6 +86,8 @@ * e.g. be overwritten by physical objects etc. */ virtual void handleExplosion(const Vec3& pos, bool directHit) {}; void setEnable(bool mode); + + scene::ISceneNode* getNode() { return m_node; } }; // TrackObject #endif Modified: main/trunk/src/tracks/track_object_manager.cpp =================================================================== --- main/trunk/src/tracks/track_object_manager.cpp 2011-05-18 00:42:24 UTC (rev 8632) +++ main/trunk/src/tracks/track_object_manager.cpp 2011-05-18 01:00:26 UTC (rev 8633) @@ -22,6 +22,7 @@ #include "config/user_config.hpp" #include "animations/billboard_animation.hpp" #include "animations/three_d_animation.hpp" +#include "graphics/lod_node.hpp" #include "io/xml_node.hpp" #include "physics/physical_object.hpp" #include "tracks/track_object.hpp" @@ -120,3 +121,21 @@ } // update // ---------------------------------------------------------------------------- + +void TrackObjectManager::enableFog(bool enable) +{ + const unsigned int count = m_all_objects.size(); + for(unsigned int i=0; igetNode()->setMaterialFlag(video::EMF_FOG_ENABLE, true); + + if (m_all_objects[i]->getNode()->getType() == scene::ESNT_LOD_NODE) + { + std::vector& nodes = ((LODNode*)m_all_objects[i]->getNode())->getAllNodes(); + for (unsigned int n=0; nsetMaterialFlag(video::EMF_FOG_ENABLE, enable); + } + } + } +} Modified: main/trunk/src/tracks/track_object_manager.hpp =================================================================== --- main/trunk/src/tracks/track_object_manager.hpp 2011-05-18 00:42:24 UTC (rev 8632) +++ main/trunk/src/tracks/track_object_manager.hpp 2011-05-18 01:00:26 UTC (rev 8633) @@ -49,6 +49,10 @@ void handleExplosion(const Vec3 &pos, const PhysicalObject *mp) const; void reset(); void init(); + + /** Enable or disable fog on objects */ + void enableFog(bool enable); + }; // class TrackObjectManager #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[8688] main/trunk/src/tracks From: - 2011-05-24 00:04 ```Revision: 8688 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8688&view=rev Author: auria Date: 2011-05-24 00:04:43 +0000 (Tue, 24 May 2011) Log Message: ----------- Simplify code by using PtrVector instead of vector + manual delete 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 2011-05-23 23:56:52 UTC (rev 8687) +++ main/trunk/src/tracks/track_object_manager.cpp 2011-05-24 00:04:43 UTC (rev 8688) @@ -34,10 +34,6 @@ // ---------------------------------------------------------------------------- TrackObjectManager::~TrackObjectManager() { - for(unsigned int i=0; i::iterator i; - for(i=m_all_objects.begin(); i!=m_all_objects.end(); i++) + TrackObject* curr; + for_in (curr, m_all_objects) { - (*i)->init(); + curr->init(); } } // reset // ---------------------------------------------------------------------------- @@ -83,10 +79,10 @@ */ void TrackObjectManager::reset() { - std::vector::iterator i; - for(i=m_all_objects.begin(); i!=m_all_objects.end(); i++) + TrackObject* curr; + for_in (curr, m_all_objects) { - (*i)->reset(); + curr->reset(); } } // reset @@ -98,12 +94,12 @@ * more. Otherwise this is NULL. */ -void TrackObjectManager::handleExplosion(const Vec3 &pos, const PhysicalObject *mp) const +void TrackObjectManager::handleExplosion(const Vec3 &pos, const PhysicalObject *mp) { - for(std::vector::const_iterator i=m_all_objects.begin(); - i!=m_all_objects.end(); i++) + TrackObject* curr; + for_in (curr, m_all_objects) { - (*i)->handleExplosion(pos, mp==(*i)); + curr->handleExplosion(pos, mp == curr); } } // handleExplosion @@ -112,10 +108,10 @@ { if ( UserConfigParams::m_graphical_effects ) { - for(std::vector::const_iterator i=m_all_objects.begin(); - i!=m_all_objects.end(); i++) + TrackObject* curr; + for_in (curr, m_all_objects) { - (*i)->update(dt); + curr->update(dt); } } } // update @@ -124,14 +120,14 @@ void TrackObjectManager::enableFog(bool enable) { - const unsigned int count = m_all_objects.size(); - for(unsigned int i=0; igetNode()->setMaterialFlag(video::EMF_FOG_ENABLE, enable); + curr->getNode()->setMaterialFlag(video::EMF_FOG_ENABLE, enable); - if (m_all_objects[i]->getNode()->getType() == scene::ESNT_LOD_NODE) + if (curr->getNode()->getType() == scene::ESNT_LOD_NODE) { - std::vector& nodes = ((LODNode*)m_all_objects[i]->getNode())->getAllNodes(); + std::vector& nodes = ((LODNode*)curr->getNode())->getAllNodes(); for (unsigned int n=0; nsetMaterialFlag(video::EMF_FOG_ENABLE, enable); Modified: main/trunk/src/tracks/track_object_manager.hpp =================================================================== --- main/trunk/src/tracks/track_object_manager.hpp 2011-05-23 23:56:52 UTC (rev 8687) +++ main/trunk/src/tracks/track_object_manager.hpp 2011-05-24 00:04:43 UTC (rev 8688) @@ -20,11 +20,11 @@ #ifndef HEADER_TRACK_OBJECT_MANAGER_HPP #define HEADER_TRACK_OBJECT_MANAGER_HPP -#include +#include "tracks/track_object.hpp" +#include "utils/ptr_vector.hpp" class PhysicalObject; class Track; -class TrackObject; class Vec3; class XMLNode; @@ -40,13 +40,14 @@ * eye candy (to reduce work for physics), ... */ enum TrackObjectType {TO_PHYSICAL, TO_GRAPHICAL}; - std::vector m_all_objects; + PtrVector m_all_objects; + public: TrackObjectManager(); ~TrackObjectManager(); void add(const XMLNode &xml_node); void update(float dt); - void handleExplosion(const Vec3 &pos, const PhysicalObject *mp) const; + void handleExplosion(const Vec3 &pos, const PhysicalObject *mp); void reset(); void init(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[8818] main/trunk/src/tracks From: - 2011-06-04 23:31 ```Revision: 8818 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8818&view=rev Author: auria Date: 2011-06-04 23:31:31 +0000 (Sat, 04 Jun 2011) Log Message: ----------- Avoid crashing when checklines are incorrect Modified Paths: -------------- main/trunk/src/tracks/check_manager.hpp main/trunk/src/tracks/check_structure.cpp Modified: main/trunk/src/tracks/check_manager.hpp =================================================================== --- main/trunk/src/tracks/check_manager.hpp 2011-06-04 22:58:10 UTC (rev 8817) +++ main/trunk/src/tracks/check_manager.hpp 2011-06-04 23:31:31 UTC (rev 8818) @@ -41,7 +41,10 @@ void reset(const Track &track); /** Returns the nth. check structure. */ CheckStructure *getCheckStructure(unsigned int n) - { return m_all_checks[n]; } + { + if (n >= m_all_checks.size()) return NULL; + return m_all_checks[n]; + } }; // CheckManager #endif Modified: main/trunk/src/tracks/check_structure.cpp =================================================================== --- main/trunk/src/tracks/check_structure.cpp 2011-06-04 22:58:10 UTC (rev 8817) +++ main/trunk/src/tracks/check_structure.cpp 2011-06-04 23:31:31 UTC (rev 8818) @@ -129,6 +129,8 @@ { CheckStructure *cs = m_check_manager->getCheckStructure(indices[i]); + if (cs == NULL) continue; + switch(change_state) { case CS_DEACTIVATE: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[8871] main/trunk/src/tracks From: - 2011-06-10 01:15 ```Revision: 8871 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8871&view=rev Author: auria Date: 2011-06-10 01:15:39 +0000 (Fri, 10 Jun 2011) Log Message: ----------- Remove logging Modified Paths: -------------- main/trunk/src/tracks/track.cpp main/trunk/src/tracks/track_object_manager.cpp Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2011-06-10 01:10:32 UTC (rev 8870) +++ main/trunk/src/tracks/track.cpp 2011-06-10 01:15:39 UTC (rev 8871) @@ -1419,9 +1419,6 @@ } else { - unsigned int t = node->getType(); - const char* type = (const char*)&t; - printf("Unknown mesh type %c%c%c%c\n", type[0], type[1], type[2], type[3]); node->setMaterialFlag(video::EMF_FOG_ENABLE, m_use_fog); } Modified: main/trunk/src/tracks/track_object_manager.cpp =================================================================== --- main/trunk/src/tracks/track_object_manager.cpp 2011-06-10 01:10:32 UTC (rev 8870) +++ main/trunk/src/tracks/track_object_manager.cpp 2011-06-10 01:15:39 UTC (rev 8871) @@ -163,9 +163,6 @@ } else { - unsigned int t = node->getType(); - const char* type = (const char*)&t; - printf("Unknown mesh type %c%c%c%c\n", type[0], type[1], type[2], type[3]); node->setMaterialFlag(video::EMF_FOG_ENABLE, enable); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[8954] main/trunk/src/tracks From: - 2011-06-18 22:36 ```Revision: 8954 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8954&view=rev Author: auria Date: 2011-06-18 22:36:14 +0000 (Sat, 18 Jun 2011) Log Message: ----------- Allow playing without driveline when no AI akrt is used Modified Paths: -------------- main/trunk/src/tracks/quad_graph.cpp main/trunk/src/tracks/track.cpp Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2011-06-18 16:45:59 UTC (rev 8953) +++ main/trunk/src/tracks/quad_graph.cpp 2011-06-18 22:36:14 UTC (rev 8954) @@ -81,8 +81,18 @@ m_all_nodes.push_back(new GraphNode(i)); // Then set the default loop: setDefaultSuccessors(); - m_lap_length = m_all_nodes[m_all_nodes.size()-1]->getDistanceFromStart() - + m_all_nodes[m_all_nodes.size()-1]->getDistanceToSuccessor(0); + + if (m_all_nodes.size() > 0) + { + m_lap_length = m_all_nodes[m_all_nodes.size()-1]->getDistanceFromStart() + + m_all_nodes[m_all_nodes.size()-1]->getDistanceToSuccessor(0); + } + else + { + fprintf(stderr, "[QuadGraph] No node in driveline graph\n"); + m_lap_length = 10.0f; + } + return; } @@ -210,6 +220,7 @@ { // Node 0 is always the node on which the start line is. int current_node = getPredecessor(0); + float distance_from_start = 0.1f+forwards_distance; // Maximum distance to left (or right) of centre line @@ -220,41 +231,49 @@ for(unsigned int i=0; i<(unsigned int)start_transforms->size(); i++) { - // First find on which segment we have to start - while(distance_from_start > getNode(current_node).getNodeLength()) + if (current_node == -1) { - distance_from_start -= getNode(current_node).getNodeLength(); - current_node = getPredecessor(current_node); + (*start_transforms)[i].setOrigin(Vec3(0,0,0)); + (*start_transforms)[i].setRotation(btQuaternion(btVector3(0, 1, 0), 0)); } - const GraphNode &gn = getNode(current_node); - Vec3 center_line = gn.getLowerCenter() - gn.getUpperCenter(); - center_line.normalize(); + else + { + // First find on which segment we have to start + while(distance_from_start > getNode(current_node).getNodeLength()) + { + 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[2] - gn[3]; - horizontal_line.normalize(); - - Vec3 start = gn.getUpperCenter() - + center_line * distance_from_start - + horizontal_line * x_pos; - // Add a certain epsilon to the height in case that the - // drivelines are beneath the track. - (*start_transforms)[i].setOrigin(start+Vec3(0,upwards_distance,0)); - (*start_transforms)[i].setRotation( - btQuaternion(btVector3(0, 1, 0), - gn.getAngleToSuccessor(0))); - 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; + Vec3 horizontal_line = gn[2] - gn[3]; + horizontal_line.normalize(); + + Vec3 start = gn.getUpperCenter() + + center_line * distance_from_start + + horizontal_line * x_pos; + // Add a certain epsilon to the height in case that the + // drivelines are beneath the track. + (*start_transforms)[i].setOrigin(start+Vec3(0,upwards_distance,0)); + (*start_transforms)[i].setRotation( + btQuaternion(btVector3(0, 1, 0), + gn.getAngleToSuccessor(0))); + 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; } - else - x_pos += sidewards_distance; - distance_from_start += forwards_distance; } // for im_max_karts } // setStartPositions Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2011-06-18 16:45:59 UTC (rev 8953) +++ main/trunk/src/tracks/track.cpp 2011-06-18 22:36:14 UTC (rev 8954) @@ -403,14 +403,17 @@ { m_quad_graph = new QuadGraph(m_root+"/"+m_all_modes[mode_id].m_quad_name, m_root+"/"+m_all_modes[mode_id].m_graph_name); - m_mini_map = m_quad_graph->makeMiniMap(World::getWorld()->getRaceGUI()->getMiniMapSize(), - "minimap::"+m_ident); if(m_quad_graph->getNumNodes()==0) { - fprintf(stderr, "No graph nodes defined for track '%s'\n", + fprintf(stderr, "[Track] WARNING: No graph nodes defined for track '%s'\n", m_filename.c_str()); - exit(-1); } + else + { + m_mini_map = m_quad_graph->makeMiniMap(World::getWorld()->getRaceGUI()->getMiniMapSize(), + "minimap::"+m_ident); + + } } // loadQuadGraph // ----------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[9165] main/trunk/src/tracks From: - 2011-07-05 01:35 ```Revision: 9165 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9165&view=rev Author: hikerstk Date: 2011-07-05 01:35:45 +0000 (Tue, 05 Jul 2011) Log Message: ----------- Added support for storing a predecessor for each node in the quad graph (needed for rescueing). Modified Paths: -------------- main/trunk/src/tracks/graph_node.cpp main/trunk/src/tracks/graph_node.hpp main/trunk/src/tracks/quad_graph.cpp main/trunk/src/tracks/track.cpp Modified: main/trunk/src/tracks/graph_node.cpp =================================================================== --- main/trunk/src/tracks/graph_node.cpp 2011-07-05 01:21:08 UTC (rev 9164) +++ main/trunk/src/tracks/graph_node.cpp 2011-07-05 01:35:45 UTC (rev 9165) @@ -39,12 +39,14 @@ /** Constructor. Saves the quad index which belongs to this graph node. * \param index Index of the quad to use for this node (in m_all_quads). */ -GraphNode::GraphNode(unsigned int index) +GraphNode::GraphNode(unsigned int quad_index, unsigned int node_index) { - assert(indexgetNumberOfQuads()); - m_index = index; + assert(quad_indexgetNumberOfQuads()); + m_quad_index = quad_index; + m_node_index = node_index; + m_predecessor = -1; m_distance_from_start = 0; - const Quad &quad = m_all_quads->getQuad(m_index); + const Quad &quad = m_all_quads->getQuad(m_quad_index); // FIXME: the following values should depend on the actual orientation // of the quad. ATM we always assume that indices 0,1 are the lower end, // and 2,3 are the upper end. @@ -64,15 +66,20 @@ /** Adds a successor to a node. This function will also pre-compute certain * values (like distance from this node to the successor, angle (in world) * between this node and the successor. - * \param to The index of the successor. + * \param to The index of the graph node of the successor. */ void GraphNode::addSuccessor(unsigned int to) { - m_vertices.push_back(to); - // m_index is the quad index, so we use m_all_quads - const Quad &this_quad = m_all_quads->getQuad(m_index); + m_successor_node.push_back(to); + // m_quad_index is the quad index, so we use m_all_quads + const Quad &this_quad = m_all_quads->getQuad(m_quad_index); // to is the graph node, so we have to use m_all_nodes to get the right quad + GraphNode &gn = m_all_nodes->getNode(to); const Quad &next_quad = m_all_nodes->getQuad(to); + + // Keep the first predecessor, which is usually the most 'natural' one. + if(gn.m_predecessor==-1) + gn.m_predecessor = m_node_index; core::vector2df d2 = m_lower_center_2d - m_all_nodes->getNode(to).m_lower_center_2d; Modified: main/trunk/src/tracks/graph_node.hpp =================================================================== --- main/trunk/src/tracks/graph_node.hpp 2011-07-05 01:21:08 UTC (rev 9164) +++ main/trunk/src/tracks/graph_node.hpp 2011-07-05 01:35:45 UTC (rev 9165) @@ -41,11 +41,22 @@ /** Index of this node in the set of quads. Several graph nodes can use * the same quad, meaning it is possible to use a quad more than once, * e.g. a figure 8 like track. */ - unsigned int m_index; - /** The list of successors. */ - std::vector m_vertices; + unsigned int m_quad_index; + + /** Index of this graph node. */ + unsigned int m_node_index; + + /** The list of successor graph nodes. */ + std::vector m_successor_node; + + /** The first predecessor. This is used in moving karts after a rescue. + * For this a node on the main driveline will be used (i.e. the first + * reported node which has this node as a successor). */ + int m_predecessor; + /** The distance to each of the successors. */ std::vector m_distance_to_next; + /** The angle of the line from this node to each neighbour. */ std::vector m_angle_to_next; @@ -76,6 +87,7 @@ * saves computation, and it is only needed to determine the distance * from the center of the drivelines anyway. */ core::line2df m_line; + public: /** Keep a shared pointer so that some asserts and tests can be * done without adding additional parameters. */ @@ -84,32 +96,32 @@ * has access to the actual quad to which a node points. */ static QuadGraph *m_all_nodes; - GraphNode(unsigned int index); + GraphNode(unsigned int quad_index, unsigned int node_index); void addSuccessor (unsigned int to); void getDistances(const Vec3 &xyz, Vec3 *result); float getDistance2FromPoint(const Vec3 &xyz); - /** Returns the i-th successor. */ + /** Returns the i-th successor node. */ unsigned int getSuccessor(unsigned int i) const - { return m_vertices[i]; } + { return m_successor_node[i]; } // ------------------------------------------------------------------------ /** Returns the number of successors. */ unsigned int getNumberOfSuccessors() const - { return (unsigned int)m_vertices.size(); } + { return (unsigned int)m_successor_node.size(); } // ------------------------------------------------------------------------ - /** Returns the index in the quad_set of this node. */ - int getIndex() const { return m_index; } + /** Returns the quad_index in the quad_set of this node. */ + int getIndex() const { return m_quad_index; } // ------------------------------------------------------------------------ /** Returns the quad of this graph node. */ - const Quad& getQuad() const {return m_all_quads->getQuad(m_index);} + const Quad& getQuad() const {return m_all_quads->getQuad(m_quad_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 * counterclockwise. */ const Vec3& operator[](int i) const - {return m_all_quads->getQuad(m_index)[i];} + {return m_all_quads->getQuad(m_quad_index)[i];} // ------------------------------------------------------------------------ /** Returns the distance to the j-th. successor. */ float getDistanceToSuccessor(unsigned int j) const @@ -142,8 +154,12 @@ * \param index Index of the successor. */ bool ignoreSuccessorForAI(unsigned int i) const { - return m_all_quads->getQuad(m_vertices[i]).letAIIgnore(); + return m_all_quads->getQuad(m_successor_node[i]).letAIIgnore(); }; + // ------------------------------------------------------------------------ + /** Returns a predecessor for this node. */ + unsigned int getPredecessor() const {return m_predecessor; } + // ------------------------------------------------------------------------ }; // GraphNode #endif Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2011-07-05 01:21:08 UTC (rev 9164) +++ main/trunk/src/tracks/quad_graph.cpp 2011-07-05 01:35:45 UTC (rev 9165) @@ -78,7 +78,7 @@ // i.e. each quad is part of the graph exactly once. // First create an empty graph node for each quad: for(unsigned int i=0; igetNumberOfQuads(); i++) - m_all_nodes.push_back(new GraphNode(i)); + m_all_nodes.push_back(new GraphNode(i, m_all_nodes.size())); // Then set the default loop: setDefaultSuccessors(); @@ -111,7 +111,7 @@ xml_node->get("to-quad", &to); for(unsigned int i=from; i<=to; i++) { - m_all_nodes.push_back(new GraphNode(i)); + m_all_nodes.push_back(new GraphNode(i, m_all_nodes.size())); } } else if(xml_node->getName()=="node") @@ -119,7 +119,7 @@ // A single quad is connected to a single graph node. unsigned int id; xml_node->get("quad", &id); - m_all_nodes.push_back(new GraphNode(id)); + m_all_nodes.push_back(new GraphNode(id, m_all_nodes.size())); } // Then the definition of edges between the graph nodes: Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2011-07-05 01:21:08 UTC (rev 9164) +++ main/trunk/src/tracks/track.cpp 2011-07-05 01:35:45 UTC (rev 9165) @@ -403,6 +403,13 @@ { m_quad_graph = new QuadGraph(m_root+"/"+m_all_modes[mode_id].m_quad_name, m_root+"/"+m_all_modes[mode_id].m_graph_name); +#ifdef DEBUG + for(unsigned int i=0; igetNumNodes(); i++) + { + assert(m_quad_graph->getNode(i).getPredecessor()!=-1); + } +#endif + if(m_quad_graph->getNumNodes()==0) { fprintf(stderr, "[Track] WARNING: No graph nodes defined for track '%s'\n", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[9415] main/trunk/src/tracks From: - 2011-08-03 02:20 ```Revision: 9415 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9415&view=rev Author: hikerstk Date: 2011-08-03 02:20:29 +0000 (Wed, 03 Aug 2011) Log Message: ----------- Replaced QuadGraph::getPredecessor function with (faster) function GraphNode::getPredecessor(). 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-08-03 02:19:01 UTC (rev 9414) +++ main/trunk/src/tracks/quad_graph.cpp 2011-08-03 02:20:29 UTC (rev 9415) @@ -219,7 +219,7 @@ float upwards_distance) const { // Node 0 is always the node on which the start line is. - int current_node = getPredecessor(0); + int current_node = getNode(0).getPredecessor(); float distance_from_start = 0.1f+forwards_distance; @@ -242,7 +242,7 @@ while(distance_from_start > getNode(current_node).getNodeLength()) { distance_from_start -= getNode(current_node).getNodeLength(); - current_node = getPredecessor(current_node); + current_node = getNode(current_node).getPredecessor(); } const GraphNode &gn = getNode(current_node); Vec3 center_line = gn.getLowerCenter() - gn.getUpperCenter(); @@ -464,28 +464,6 @@ } // getSuccessors //----------------------------------------------------------------------------- -/** Returns the first predecessor or a node (i.e. the one usually on the main - * driveline). - * \param node_number The number of the node. - * \return The node number of the first predecessor node, or -1 if no - * predecessor was found (and a warning is printed in this case). - */ -int QuadGraph::getPredecessor(unsigned int target_node) const -{ - for(unsigned int node_id=0; node_idgetNumberOfSuccessors(); i++) - { - if(gn->getSuccessor(i)==target_node) - return node_id; - } // for igetNumberOfSuccessors() - } // node_id

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[10323] main/trunk/src/tracks From: - 2011-12-04 01:29 ```Revision: 10323 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=10323&view=rev Author: auria Date: 2011-12-04 01:29:27 +0000 (Sun, 04 Dec 2011) Log Message: ----------- Complete animating LOD objects Modified Paths: -------------- main/trunk/src/tracks/track.cpp main/trunk/src/tracks/track_object_manager.hpp Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2011-12-04 01:25:09 UTC (rev 10322) +++ main/trunk/src/tracks/track.cpp 2011-12-04 01:29:27 UTC (rev 10323) @@ -1244,8 +1244,11 @@ { std::vector& queue = track_objects[ lod_nodes[n]->getGroupName() ]; assert( queue.size() > 0 ); - queue[ queue.size() - 1 ]->setNode( lod_nodes[n] ); + TrackObject* obj = queue[ queue.size() - 1 ]; + obj->setNode( lod_nodes[n] ); queue.erase( queue.end() - 1 ); + + m_track_object_manager->manualInsertObject( obj ); } track_objects.clear(); Modified: main/trunk/src/tracks/track_object_manager.hpp =================================================================== --- main/trunk/src/tracks/track_object_manager.hpp 2011-12-04 01:25:09 UTC (rev 10322) +++ main/trunk/src/tracks/track_object_manager.hpp 2011-12-04 01:29:27 UTC (rev 10323) @@ -72,6 +72,11 @@ void removeObject(PhysicalObject* who); + void manualInsertObject(TrackObject* obj) + { + m_all_objects.push_back(obj); + } + /** Get the queue of LOD objects that are waiting to be assigned a scene node */ std::map >& getLodObjects() { return m_lod_objects; } }; // class TrackObjectManager This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[10399] main/trunk/src/tracks From: - 2011-12-10 21:49 ```Revision: 10399 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=10399&view=rev Author: auria Date: 2011-12-10 21:49:24 +0000 (Sat, 10 Dec 2011) Log Message: ----------- Cleanup loading animated LOD nodes Modified Paths: -------------- main/trunk/src/tracks/track.cpp main/trunk/src/tracks/track_object_manager.cpp main/trunk/src/tracks/track_object_manager.hpp Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2011-12-10 21:32:07 UTC (rev 10398) +++ main/trunk/src/tracks/track.cpp 2011-12-10 21:49:24 UTC (rev 10399) @@ -1239,21 +1239,7 @@ std::vector devnull; lod_loader.done(m_root, devnull, lod_nodes); - std::map >& track_objects = - m_track_object_manager->getLodObjects(); - - for (unsigned int n=0; n& queue = track_objects[ lod_nodes[n]->getGroupName() ]; - assert( queue.size() > 0 ); - TrackObject* obj = queue[ queue.size() - 1 ]; - obj->setNode( lod_nodes[n] ); - queue.erase( queue.end() - 1 ); - - m_track_object_manager->manualInsertObject( obj ); - } - - track_objects.clear(); + m_track_object_manager->assingLodNodes(lod_nodes); // --------------------------------------------- delete root; Modified: main/trunk/src/tracks/track_object_manager.cpp =================================================================== --- main/trunk/src/tracks/track_object_manager.cpp 2011-12-10 21:32:07 UTC (rev 10398) +++ main/trunk/src/tracks/track_object_manager.cpp 2011-12-10 21:49:24 UTC (rev 10399) @@ -41,6 +41,9 @@ // ---------------------------------------------------------------------------- /** Adds an object to the track object manager. The type to add is specified * in the xml_node. + * \note If you add add any objects with LOD, don't forget to call + * TrackObjectManager::assingLodNodes after everything is loaded + * to finalize their creation. */ void TrackObjectManager::add(const XMLNode &xml_node) { @@ -231,3 +234,26 @@ delete obj; } // removeObject +// ---------------------------------------------------------------------------- +/** + * \brief To be called after all objects are loaded and the LodNodeLoader is done + * parsing everything. + * This method exists because LOD objects need to be created after others. + * + * \param lod_nodes the LOD nodes created by the LodNodeLoader. + */ +void TrackObjectManager::assingLodNodes(const std::vector& lod_nodes) +{ + for (unsigned int n=0; n& queue = m_lod_objects[ lod_nodes[n]->getGroupName() ]; + assert( queue.size() > 0 ); + TrackObject* obj = queue[ queue.size() - 1 ]; + obj->setNode( lod_nodes[n] ); + queue.erase( queue.end() - 1 ); + + manualInsertObject( obj ); + } + + m_lod_objects.clear(); +} Modified: main/trunk/src/tracks/track_object_manager.hpp =================================================================== --- main/trunk/src/tracks/track_object_manager.hpp 2011-12-10 21:32:07 UTC (rev 10398) +++ main/trunk/src/tracks/track_object_manager.hpp 2011-12-10 21:49:24 UTC (rev 10399) @@ -26,6 +26,7 @@ class Track; class Vec3; class XMLNode; +class LODNode; #include #include @@ -76,8 +77,7 @@ m_all_objects.push_back(obj); } - /** Get the queue of LOD objects that are waiting to be assigned a scene node */ - std::map >& getLodObjects() { return m_lod_objects; } + void assingLodNodes(const std::vector& lod); }; // class TrackObjectManager #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[10774] main/trunk/src/tracks From: - 2012-01-31 02:24 ```Revision: 10774 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=10774&view=rev Author: auria Date: 2012-01-31 02:24:10 +0000 (Tue, 31 Jan 2012) Log Message: ----------- Fix leak by introducing code to free meshes that are not associated to any scene node 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 2012-01-31 01:23:50 UTC (rev 10773) +++ main/trunk/src/tracks/track.cpp 2012-01-31 02:24:10 UTC (rev 10774) @@ -195,6 +195,14 @@ } m_all_cached_meshes.clear(); + // Now free meshes that are not associated to any scene node. + for (unsigned int i=0; idropAllTextures(m_detached_cached_meshes[i]); + irr_driver->removeMeshFromCache(m_detached_cached_meshes[i]); + } + m_detached_cached_meshes.clear(); + QuadGraph::destroy(); if(m_check_manager) delete m_check_manager; if(m_mini_map) @@ -821,6 +829,13 @@ scene::IMesh* original_mesh = irr_driver->getMesh(full_path); + if (std::find(m_detached_cached_meshes.begin(), + m_detached_cached_meshes.end(), + original_mesh) == m_detached_cached_meshes.end()) + { + m_detached_cached_meshes.push_back(original_mesh); + } + // create a node out of this mesh just for bullet; delete it after, normal maps are special // and require tangent meshes scene_node = irr_driver->addMesh(original_mesh); @@ -836,6 +851,7 @@ scene::IMesh* mesh = manip->createMeshWithTangents(original_mesh); mesh->grab(); irr_driver->grabAllTextures(mesh); + m_all_cached_meshes.push_back(mesh); scene_node = irr_driver->addMesh(mesh); scene_node->setPosition(xyz); Modified: main/trunk/src/tracks/track.hpp =================================================================== --- main/trunk/src/tracks/track.hpp 2012-01-31 01:23:50 UTC (rev 10773) +++ main/trunk/src/tracks/track.hpp 2012-01-31 02:24:10 UTC (rev 10774) @@ -136,6 +136,12 @@ * that those meshes are being cached by irrlicht, and need to be freed. */ std::vector m_all_cached_meshes; + /** + * m_all_cached_meshes assumes meshes are attached to a scene node. + * This one assumes the mesh is NOT connected to any node. + */ + std::vector m_detached_cached_meshes; + /** A list of all textures loaded by the track, so that they can * be removed from the cache at cleanup time. */ std::vector m_all_cached_textures; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[10840] main/trunk/src/tracks From: - 2012-02-13 23:23 ```Revision: 10840 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=10840&view=rev Author: auria Date: 2012-02-13 23:23:10 +0000 (Mon, 13 Feb 2012) Log Message: ----------- Fix use of unintialized pointer and improve error reporting Modified Paths: -------------- main/trunk/src/tracks/track.cpp main/trunk/src/tracks/track_object.cpp Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2012-02-13 15:35:42 UTC (rev 10839) +++ main/trunk/src/tracks/track.cpp 2012-02-13 23:23:10 UTC (rev 10840) @@ -472,7 +472,8 @@ node = ((LODNode*)node)->getFirstNode(); if (node == NULL) { - fprintf(stderr, "[Track] WARNING: this track contains an empty LOD group\n"); + fprintf(stderr, "[Track] WARNING: this track contains an empty LOD group : '%s'\n", + ((LODNode*)node)->getGroupName().c_str()); return; } } Modified: main/trunk/src/tracks/track_object.cpp =================================================================== --- main/trunk/src/tracks/track_object.cpp 2012-02-13 15:35:42 UTC (rev 10839) +++ main/trunk/src/tracks/track_object.cpp 2012-02-13 23:23:10 UTC (rev 10840) @@ -45,6 +45,7 @@ m_enabled = true; m_is_looped = false; m_sound = NULL; + m_mesh = NULL; xml_node.get("xyz", &m_init_xyz ); xml_node.get("hpr", &m_init_hpr ); @@ -136,6 +137,7 @@ { std::string full_path = World::getWorld()->getTrack()->getTrackFile(model_name); + if(file_manager->fileExists(full_path)) { m_mesh = irr_driver->getAnimatedMesh(full_path); @@ -146,11 +148,12 @@ // in STK's model directory. full_path = file_manager->getModelFile(model_name); m_mesh = irr_driver->getAnimatedMesh(full_path); + if(!m_mesh) { fprintf(stderr, - "Warning: '%s' in '%s' not found and is ignored.\n", - xml_node.getName().c_str(), model_name.c_str()); + "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) } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[10842] main/trunk/src/tracks From: - 2012-02-13 23:40 ```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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[11125] main/trunk/src/tracks From: - 2012-04-18 22:07 ```Revision: 11125 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11125&view=rev Author: hikerstk Date: 2012-04-18 22:07:45 +0000 (Wed, 18 Apr 2012) Log Message: ----------- Added support for checklines to be specified by two 3d points instead of 2d points and the minimum height. Modified Paths: -------------- main/trunk/src/tracks/check_line.cpp main/trunk/src/tracks/check_line.hpp Modified: main/trunk/src/tracks/check_line.cpp =================================================================== --- main/trunk/src/tracks/check_line.cpp 2012-04-18 20:49:34 UTC (rev 11124) +++ main/trunk/src/tracks/check_line.cpp 2012-04-18 22:07:45 UTC (rev 11125) @@ -18,15 +18,16 @@ #include "tracks/check_line.hpp" -#include - -#include "irrlicht.h" - #include "io/xml_node.hpp" #include "karts/abstract_kart.hpp" #include "modes/world.hpp" #include "race/race_manager.hpp" +#include "irrlicht.h" + +#include +#include + /** Constructor for a checkline. * \param node XML node containing the parameters for this checkline. * \param index Index of this check structure in the check manager. @@ -38,9 +39,21 @@ // in world, so we can't call world->getNumKarts() m_previous_sign.resize(race_manager->getNumberOfKarts()); core::vector2df p1, p2; - node.get("p1", &p1); - node.get("p2", &p2); - node.get("min-height", &m_min_height); + if(node.get("p1", &p1) && + node.get("p2", &p2) && + node.get("min-height", &m_min_height)) + { + m_left_point = Vec3(p1.X, m_min_height, p1.Y); + m_right_point = Vec3(p2.X, m_min_height, p2.Y); + } + else + { + node.get("p1", &m_left_point); + p1 = core::vector2df(m_left_point.getX(), m_left_point.getZ()); + node.get("p2", &m_right_point); + p2 = core::vector2df(m_right_point.getX(), m_right_point.getZ()); + m_min_height = std::min(m_left_point.getY(), m_right_point.getY()); + } m_line.setLine(p1, p2); if(UserConfigParams::m_check_debug) { Modified: main/trunk/src/tracks/check_line.hpp =================================================================== --- main/trunk/src/tracks/check_line.hpp 2012-04-18 20:49:34 UTC (rev 11124) +++ main/trunk/src/tracks/check_line.hpp 2012-04-18 22:07:45 UTC (rev 11125) @@ -51,6 +51,11 @@ /** The minimum height of the checkline. */ float m_min_height; + /** The actual (or estimated) left and right end points in 3d. This is + * used by the cannon. If the xml file stores only the min_height, those + * points are set from the 2d points and the min height. */ + Vec3 m_left_point, m_right_point; + /** 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. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[11273] main/trunk/src/tracks From: - 2012-06-03 00:08 ```Revision: 11273 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11273&view=rev Author: auria Date: 2012-06-03 00:08:18 +0000 (Sun, 03 Jun 2012) Log Message: ----------- More work on cutscenes 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 2012-06-02 22:35:09 UTC (rev 11272) +++ main/trunk/src/tracks/track.cpp 2012-06-03 00:08:18 UTC (rev 11273) @@ -91,6 +91,7 @@ m_all_nodes.clear(); m_all_cached_meshes.clear(); m_is_arena = false; + m_is_cutscene = false; m_camera_far = 1000.0f; m_mini_map = NULL; m_sky_particles = NULL; @@ -301,6 +302,7 @@ root->get("screenshot", &m_screenshot); root->get("gravity", &m_gravity); root->get("arena", &m_is_arena); + root->get("cutscene", &m_is_cutscene); root->get("groups", &m_groups); root->get("internal", &m_internal); root->get("reverse", &m_reverse_available); @@ -1223,7 +1225,7 @@ // the race gui was created. The race gui is needed since it stores // the information about the size of the texture to render the mini // map to. - if (!m_is_arena) loadQuadGraph(mode_id, reverse_track); + if (!m_is_arena && !m_is_cutscene) loadQuadGraph(mode_id, reverse_track); // Set the default start positions. Node that later the default // positions can still be overwritten. @@ -1240,7 +1242,7 @@ default_start->get("upwards-distance", &upwards_distance ); default_start->get("karts-per-row", &karts_per_row ); } - if(!m_is_arena) + if(!m_is_arena && !m_is_cutscene) { m_start_transforms.resize(race_manager->getNumberOfKarts()); QuadGraph::get()->setDefaultStartPositions(&m_start_transforms, Modified: main/trunk/src/tracks/track.hpp =================================================================== --- main/trunk/src/tracks/track.hpp 2012-06-02 22:35:09 UTC (rev 11272) +++ main/trunk/src/tracks/track.hpp 2012-06-03 00:08:18 UTC (rev 11273) @@ -201,6 +201,9 @@ Vec3 m_aabb_max; /** True if this track is an arena. */ bool m_is_arena; + + bool m_is_cutscene; + /** The version of this track. A certain STK version will only support * certain track versions. */ int m_version; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[11437] main/trunk/src/tracks From: - 2012-07-25 22:09 ```Revision: 11437 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11437&view=rev Author: hikerstk Date: 2012-07-25 22:09:12 +0000 (Wed, 25 Jul 2012) Log Message: ----------- Fixed minimap, which was also shown transparent after r11435. Revision Links: -------------- http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11435&view=rev 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 2012-07-25 01:27:29 UTC (rev 11436) +++ main/trunk/src/tracks/quad_graph.cpp 2012-07-25 22:09:12 UTC (rev 11437) @@ -389,21 +389,26 @@ // ----------------------------------------------------------------------------- /** Creates a mesh for this graph. The mesh is not added to a scene node and * is stored in m_mesh. + * \param show_invisble If true, also create a mesh for parts of the + * driveline that are invisible. + * \param enable_transparency Enable alpha blending to make the mesh + * semi transparent. + * \param track_color Colour of the actual quads. + * \param lap_color If defined, show the lap counting line in that colour. */ -void QuadGraph::createMesh(bool show_invisible, +void QuadGraph::createMesh(bool show_invisible, + bool enable_transparency, const video::SColor *track_color, const video::SColor *lap_color) { // The debug track will not be lighted or culled. video::SMaterial m; - m.BackfaceCulling = false; - m.Lighting = false; -#define TRANSPARENT_DEBUG_MESH -#ifdef TRANSPARENT_DEBUG_MESH - m.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; -#endif - m_mesh = irr_driver->createQuadMesh(&m); - m_mesh_buffer = m_mesh->getMeshBuffer(0); + m.BackfaceCulling = false; + m.Lighting = false; + if(enable_transparency) + m.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + m_mesh = irr_driver->createQuadMesh(&m); + m_mesh_buffer = m_mesh->getMeshBuffer(0); assert(m_mesh_buffer->getVertexType()==video::EVT_STANDARD); // Count the number of quads to display (some quads might be invisible @@ -524,14 +529,11 @@ { if(m_all_nodes.size()<=0) return; // no debug output if not graph - createMesh(); + createMesh(/*show_invisible*/true, + /*enable_transparency*/true); // Now colour the quads red/blue/red ... -#ifdef TRANSPARENT_DEBUG_MESH video::SColor c( 32, 255, 0, 0); -#else - video::SColor c(255, 255, 0, 0); -#endif video::S3DVertex *v = (video::S3DVertex*)m_mesh_buffer->getVertices(); for(unsigned int i=0; igetVertexCount(); i++) { @@ -935,9 +937,9 @@ IrrDriver::RTTProvider rttProvider(dimension, name, true); video::SColor red(128, 255, 0, 0); createMesh(/*show_invisible part of the track*/ false, + /*enable_transparency*/ false, /*track_color*/ &fill_color, /*lap line color*/ &red ); - //video::S3DVertex *v = (video::S3DVertex*)m_mesh_buffer->getVertices(); 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 2012-07-25 01:27:29 UTC (rev 11436) +++ main/trunk/src/tracks/quad_graph.hpp 2012-07-25 22:09:12 UTC (rev 11437) @@ -87,7 +87,8 @@ void addSuccessor(unsigned int from, unsigned int to); void load (const std::string &filename); void computeDistanceFromStart(unsigned int start_node, float distance); - void createMesh(bool show_invisible=true, + void createMesh(bool show_invisible=true, + bool enable_transparency=false, const video::SColor *track_color=NULL, const video::SColor *lap_color=NULL); unsigned int getStartNode() const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[11487] main/trunk/src/tracks From: - 2012-08-08 06:58 ```Revision: 11487 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11487&view=rev Author: hikerstk Date: 2012-08-08 06:57:55 +0000 (Wed, 08 Aug 2012) Log Message: ----------- Renamed GraphNode::getIndex to getQuadIndex. Modified Paths: -------------- main/trunk/src/tracks/graph_node.hpp main/trunk/src/tracks/quad_graph.cpp main/trunk/src/tracks/quad_graph.hpp main/trunk/src/tracks/quad_set.cpp Modified: main/trunk/src/tracks/graph_node.hpp =================================================================== --- main/trunk/src/tracks/graph_node.hpp 2012-08-07 23:31:35 UTC (rev 11486) +++ main/trunk/src/tracks/graph_node.hpp 2012-08-08 06:57:55 UTC (rev 11487) @@ -151,8 +151,7 @@ int getPredecessor(unsigned int i) const {return m_predecessor_nodes[i]; } // ------------------------------------------------------------------------ /** Returns the quad_index in the quad_set of this node. */ - int getIndex() const { return m_quad_index; } - + int getQuadIndex() const { return m_quad_index; } // ------------------------------------------------------------------------ /** Returns the quad of this graph node. */ const Quad& getQuad() const {return QuadSet::get()->getQuad(m_quad_index);} Modified: main/trunk/src/tracks/quad_graph.cpp =================================================================== --- main/trunk/src/tracks/quad_graph.cpp 2012-08-07 23:31:35 UTC (rev 11486) +++ main/trunk/src/tracks/quad_graph.cpp 2012-08-08 06:57:55 UTC (rev 11487) @@ -605,7 +605,7 @@ if(current_distancegetIndex(), delta); + updateDistancesForAllSuccessors(gn->getQuadIndex(), delta); } return; } @@ -622,7 +622,7 @@ if(gn_next->getDistanceFromStart()==0) continue; - computeDistanceFromStart(gn_next->getIndex(), + computeDistanceFromStart(gn_next->getQuadIndex(), new_distance + gn->getDistanceToSuccessor(i)); } // for i } // computeDistanceFromStart Modified: main/trunk/src/tracks/quad_graph.hpp =================================================================== --- main/trunk/src/tracks/quad_graph.hpp 2012-08-07 23:31:35 UTC (rev 11486) +++ main/trunk/src/tracks/quad_graph.hpp 2012-08-08 06:57:55 UTC (rev 11487) @@ -174,7 +174,7 @@ // ---------------------------------------------------------------------- /** Returns the quad that belongs to a graph node. */ const Quad& getQuadOfNode(unsigned int j) const - { return QuadSet::get()->getQuad(m_all_nodes[j]->getIndex()); } + { return QuadSet::get()->getQuad(m_all_nodes[j]->getQuadIndex()); } // ---------------------------------------------------------------------- /** Returns the quad that belongs to a graph node. */ GraphNode& getNode(unsigned int j) const{ return *m_all_nodes[j]; } Modified: main/trunk/src/tracks/quad_set.cpp =================================================================== --- main/trunk/src/tracks/quad_set.cpp 2012-08-07 23:31:35 UTC (rev 11486) +++ main/trunk/src/tracks/quad_set.cpp 2012-08-08 06:57:55 UTC (rev 11487) @@ -74,7 +74,7 @@ } // getPoint // ----------------------------------------------------------------------------- -/** Loads the set of all quads from the speciified filename. +/** Loads the set of all quads from the specified filename. * \param filename The absolute filename to load the quad file from. */ void QuadSet::init(const std::string &filename) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[11730] main/trunk/src/tracks From: - 2012-10-21 20:48 ```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. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[12391] main/trunk/src/tracks From: - 2013-01-19 21:43 ```Revision: 12391 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=12391&view=rev Author: auria Date: 2013-01-19 21:43:21 +0000 (Sat, 19 Jan 2013) Log Message: ----------- Minor cleanup 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 2013-01-19 14:52:40 UTC (rev 12390) +++ main/trunk/src/tracks/track_object_manager.cpp 2013-01-19 21:43:21 UTC (rev 12391) @@ -280,7 +280,7 @@ obj->setNode( lod_nodes[n] ); queue.erase( queue.end() - 1 ); - manualInsertObject( obj ); + m_all_objects.push_back(obj); } m_lod_objects.clear(); Modified: main/trunk/src/tracks/track_object_manager.hpp =================================================================== --- main/trunk/src/tracks/track_object_manager.hpp 2013-01-19 14:52:40 UTC (rev 12390) +++ main/trunk/src/tracks/track_object_manager.hpp 2013-01-19 21:43:21 UTC (rev 12391) @@ -73,11 +73,6 @@ void removeObject(PhysicalObject* who); - void manualInsertObject(TrackObject* obj) - { - m_all_objects.push_back(obj); - } - void assingLodNodes(const std::vector& lod); PtrVector& getObjects() { return m_all_objects; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[12604] main/trunk/src/tracks From: - 2013-04-04 22:57 ```Revision: 12604 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=12604&view=rev Author: auria Date: 2013-04-04 22:57:07 +0000 (Thu, 04 Apr 2013) Log Message: ----------- Minor cleanup Modified Paths: -------------- main/trunk/src/tracks/track_object.cpp main/trunk/src/tracks/track_object.hpp Modified: main/trunk/src/tracks/track_object.cpp =================================================================== --- main/trunk/src/tracks/track_object.cpp 2013-04-04 22:55:32 UTC (rev 12603) +++ main/trunk/src/tracks/track_object.cpp 2013-04-04 22:57:07 UTC (rev 12604) @@ -19,35 +19,15 @@ #include "tracks/track_object.hpp" #include "animations/three_d_animation.hpp" -#include "audio/sfx_base.hpp" -#include "audio/sfx_buffer.hpp" -#include "audio/sfx_manager.hpp" #include "graphics/irr_driver.hpp" -#include "graphics/lod_node.hpp" -#include "graphics/material_manager.hpp" -#include "graphics/particle_emitter.hpp" -#include "graphics/particle_kind_manager.hpp" #include "io/file_manager.hpp" #include "io/xml_node.hpp" #include "input/device_manager.hpp" #include "items/item_manager.hpp" -#include "modes/overworld.hpp" -#include "modes/world.hpp" #include "physics/physical_object.hpp" -#include "states_screens/dialogs/tutorial_message_dialog.hpp" -#include "states_screens/dialogs/race_paused_dialog.hpp" -#include "states_screens/main_menu_screen.hpp" -#include "tracks/track.hpp" +#include "race/race_manager.hpp" -#include -#include -#include -#include -#include - - - /** A track object: any additional object on the track. This object implements * a graphics-only representation, i.e. there is no physical representation. * Derived classes can implement a physical representation (see Modified: main/trunk/src/tracks/track_object.hpp =================================================================== --- main/trunk/src/tracks/track_object.hpp 2013-04-04 22:55:32 UTC (rev 12603) +++ main/trunk/src/tracks/track_object.hpp 2013-04-04 22:57:07 UTC (rev 12604) @@ -20,15 +20,8 @@ #define HEADER_TRACK_OBJECT_HPP #include -#include -namespace irr -{ - namespace scene { class IAnimatedMesh; class ISceneNode; } -} -using namespace irr; #include "items/item.hpp" -#include "graphics/lod_node.hpp" #include "tracks/track_object_presentation.hpp" #include "utils/cpp2011.h" #include "utils/no_copy.hpp" @@ -36,8 +29,6 @@ #include class XMLNode; -class SFXBase; -class ParticleEmitter; class PhysicalObject; class ThreeDAnimation; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[12605] main/trunk/src/tracks From: - 2013-04-04 23:02 ```Revision: 12605 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=12605&view=rev Author: auria Date: 2013-04-04 23:02:15 +0000 (Thu, 04 Apr 2013) Log Message: ----------- Bring back LOD + particles Modified Paths: -------------- main/trunk/src/tracks/track_object_presentation.cpp main/trunk/src/tracks/track_object_presentation.hpp Modified: main/trunk/src/tracks/track_object_presentation.cpp =================================================================== --- main/trunk/src/tracks/track_object_presentation.cpp 2013-04-04 22:57:07 UTC (rev 12604) +++ main/trunk/src/tracks/track_object_presentation.cpp 2013-04-04 23:02:15 UTC (rev 12605) @@ -37,6 +37,7 @@ #include #include #include +#include // ---------------------------------------------------------------------------- @@ -410,7 +411,7 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles(const XMLNode& xml_node) : - TrackObjectPresentation(xml_node) + TrackObjectPresentationSceneNode(xml_node) { m_emitter = NULL; m_lod_emitter_node = NULL; @@ -434,7 +435,7 @@ } ParticleEmitter* emitter = new ParticleEmitter( kind, emitter_origin ); - /* + if (clip_distance > 0) { scene::ISceneManager* sm = irr_driver->getSceneManager(); @@ -445,12 +446,12 @@ m_node = lod; m_lod_emitter_node = lod; m_emitter = emitter; - }*/ - //else - //{ - //m_node = emitter->getNode(); // FIXME: this leaks + } + else + { + m_node = emitter->getNode(); m_emitter = emitter; - //} + } if (m_trigger_condition.size() > 0) { @@ -493,12 +494,6 @@ } } -void TrackObjectPresentationParticles::move(const core::vector3df& xyz, const core::vector3df& hpr, - const core::vector3df& scale) -{ - if (m_emitter != NULL) m_emitter->setPosition(xyz); -} - // ---------------------------------------------------------------------------- Modified: main/trunk/src/tracks/track_object_presentation.hpp =================================================================== --- main/trunk/src/tracks/track_object_presentation.hpp 2013-04-04 22:57:07 UTC (rev 12604) +++ main/trunk/src/tracks/track_object_presentation.hpp 2013-04-04 23:02:15 UTC (rev 12605) @@ -210,7 +210,7 @@ * \ingroup tracks * A track object representation that consists of a particle emitter */ -class TrackObjectPresentationParticles : public TrackObjectPresentation +class TrackObjectPresentationParticles : public TrackObjectPresentationSceneNode { private: ParticleEmitter* m_emitter; @@ -222,8 +222,7 @@ virtual ~TrackObjectPresentationParticles(); virtual void update(float dt) OVERRIDE; - virtual void move(const core::vector3df& xyz, const core::vector3df& hpr, - const core::vector3df& scale) OVERRIDE; + std::string& getTriggerCondition() { return m_trigger_condition; } void triggerParticles(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[12613] main/trunk/src/tracks From: - 2013-04-05 23:39 ```Revision: 12613 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=12613&view=rev Author: auria Date: 2013-04-05 23:38:58 +0000 (Fri, 05 Apr 2013) Log Message: ----------- Fix leaks Modified Paths: -------------- main/trunk/src/tracks/track_object.cpp main/trunk/src/tracks/track_object.hpp Modified: main/trunk/src/tracks/track_object.cpp =================================================================== --- main/trunk/src/tracks/track_object.cpp 2013-04-05 12:31:14 UTC (rev 12612) +++ main/trunk/src/tracks/track_object.cpp 2013-04-05 23:38:58 UTC (rev 12613) @@ -178,6 +178,7 @@ { delete m_presentation; delete m_animator; + delete m_rigid_body; } // ~TrackObject // ---------------------------------------------------------------------------- Modified: main/trunk/src/tracks/track_object.hpp =================================================================== --- main/trunk/src/tracks/track_object.hpp 2013-04-05 12:31:14 UTC (rev 12612) +++ main/trunk/src/tracks/track_object.hpp 2013-04-05 23:38:58 UTC (rev 12613) @@ -132,6 +132,8 @@ const core::vector3df& getPosition() const; const core::vector3df& getRotation() const; const core::vector3df& getScale() const; + + LEAK_CHECK() }; // TrackObject #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[12629] main/trunk/src/tracks From: - 2013-04-10 01:29 ```Revision: 12629 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=12629&view=rev Author: auria Date: 2013-04-10 01:29:48 +0000 (Wed, 10 Apr 2013) Log Message: ----------- Two unrelated changes : make scene node presentation fault-tolerant, and add fallback support for old XML xyz syntax Modified Paths: -------------- main/trunk/src/tracks/track_object.cpp main/trunk/src/tracks/track_object_presentation.cpp Modified: main/trunk/src/tracks/track_object.cpp =================================================================== --- main/trunk/src/tracks/track_object.cpp 2013-04-10 00:13:49 UTC (rev 12628) +++ main/trunk/src/tracks/track_object.cpp 2013-04-10 01:29:48 UTC (rev 12629) @@ -141,6 +141,7 @@ } else { + m_type = "mesh"; m_presentation = new TrackObjectPresentationMesh(xml_node, m_enabled); } Modified: main/trunk/src/tracks/track_object_presentation.cpp =================================================================== --- main/trunk/src/tracks/track_object_presentation.cpp 2013-04-10 00:13:49 UTC (rev 12628) +++ main/trunk/src/tracks/track_object_presentation.cpp 2013-04-10 01:29:48 UTC (rev 12629) @@ -47,7 +47,13 @@ m_init_hpr = core::vector3df(0,0,0); m_init_scale = core::vector3df(1,1,1); - xml_node.get("xyz", &m_init_xyz ); + + if (!xml_node.get("xyz", &m_init_xyz )) + { + // support for old deprecated syntax + xml_node.getXYZ(&m_init_xyz); + } + xml_node.get("hpr", &m_init_hpr ); xml_node.get("scale", &m_init_scale); } @@ -57,16 +63,19 @@ const core::vector3df& TrackObjectPresentationSceneNode::getPosition() const { + if (m_node == NULL) return m_init_xyz; return m_node->getPosition(); } const core::vector3df& TrackObjectPresentationSceneNode::getRotation() const { + if (m_node == NULL) return m_init_hpr; return m_node->getRotation(); } const core::vector3df& TrackObjectPresentationSceneNode::getScale() const { + if (m_node == NULL) return m_init_scale; return m_node->getScale(); } @@ -74,20 +83,23 @@ void TrackObjectPresentationSceneNode::move(const core::vector3df& xyz, const core::vector3df& hpr, const core::vector3df& scale) { + if (m_node == NULL) return; + m_node->setPosition(xyz); m_node->setRotation(hpr); m_node->setScale(scale); - - //if (dynamic_cast(this) != NULL) } void TrackObjectPresentationSceneNode::setEnable(bool enabled) { - m_node->setVisible(enabled); + if (m_node != NULL) + m_node->setVisible(enabled); } void TrackObjectPresentationSceneNode::reset() { + if (m_node == NULL) return; + m_node->setPosition(m_init_xyz); m_node->setRotation(m_init_hpr); m_node->setScale(m_init_scale); @@ -473,9 +485,10 @@ m_lod_emitter_node = NULL; std::string path; - irr::core::vector3df emitter_origin; xml_node.get("kind", &path); - xml_node.getXYZ(&emitter_origin); + + //irr::core::vector3df emitter_origin; + //xml_node.getXYZ(&emitter_origin); int clip_distance = -1; xml_node.get("clip_distance", &clip_distance); @@ -489,7 +502,7 @@ { throw std::runtime_error(path + " could not be loaded"); } - ParticleEmitter* emitter = new ParticleEmitter( kind, emitter_origin ); + ParticleEmitter* emitter = new ParticleEmitter( kind, m_init_xyz ); if (clip_distance > 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[13086] main/trunk/src/tracks From: - 2013-07-05 00:02 ```Revision: 13086 http://sourceforge.net/p/supertuxkart/code/13086 Author: auria Date: 2013-07-05 00:02:50 +0000 (Fri, 05 Jul 2013) Log Message: ----------- Fix restarting tutorial Modified Paths: -------------- main/trunk/src/tracks/track_object_presentation.cpp main/trunk/src/tracks/track_object_presentation.hpp Modified: main/trunk/src/tracks/track_object_presentation.cpp =================================================================== --- main/trunk/src/tracks/track_object_presentation.cpp 2013-07-04 23:56:24 UTC (rev 13085) +++ main/trunk/src/tracks/track_object_presentation.cpp 2013-07-05 00:02:50 UTC (rev 13086) @@ -574,6 +574,8 @@ xml_node.get("action", &m_action); + m_action_active = true; + if (m_action.size() == 0) { fprintf(stderr, "[TrackObject] WARNING: action-trigger has no action defined\n"); @@ -584,6 +586,8 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who) { + if (!m_action_active) return; + if (m_action == "garage") { new RacePausedDialog(0.8f, 0.6f); @@ -593,7 +597,7 @@ { //if (World::getWorld()->getPhase() == World::RACE_PHASE) { - m_action = "__disabled__"; + m_action_active = false; //World::getWorld()->getRaceGUI()->clearAllMessages(); InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); @@ -608,13 +612,13 @@ } else if (m_action == "tutorial_bananas") { - m_action = "__disabled__"; + m_action_active = false; new TutorialMessageDialog(_("Avoid bananas!"), true); } else if (m_action == "tutorial_giftboxes") { - m_action = "__disabled__"; + m_action_active = false; InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); DeviceConfig* config = device->getConfiguration(); irr::core::stringw fire = config->getBindingAsString(PA_FIRE); @@ -624,14 +628,14 @@ } else if (m_action == "tutorial_nitro_collect") { - m_action = "__disabled__"; + m_action_active = false; new TutorialMessageDialog(_("Collect nitro bottles (we will use them after the curve)"), true); } else if (m_action == "tutorial_nitro_use") { - m_action = "__disabled__"; + m_action_active = false; InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); DeviceConfig* config = device->getConfiguration(); irr::core::stringw nitro = config->getBindingAsString(PA_NITRO); @@ -641,7 +645,7 @@ } else if (m_action == "tutorial_rescue") { - m_action = "__disabled__"; + m_action_active = false; InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); DeviceConfig* config = device->getConfiguration(); irr::core::stringw rescue = config->getBindingAsString(PA_RESCUE); @@ -651,7 +655,7 @@ } else if (m_action == "tutorial_skidding") { - m_action = "__disabled__"; + m_action_active = false; //World::getWorld()->getRaceGUI()->clearAllMessages(); InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); @@ -664,7 +668,7 @@ } else if (m_action == "tutorial_skidding2") { - m_action = "__disabled__"; + m_action_active = false; World::getWorld()->getRaceGUI()->clearAllMessages(); new TutorialMessageDialog(_("Note that if you manage to skid for several seconds, you will receive a bonus speedup as a reward!"), @@ -672,7 +676,7 @@ } else if (m_action == "tutorial_endmessage") { - m_action = "__disabled__"; + m_action_active = false; World::getWorld()->getRaceGUI()->clearAllMessages(); new TutorialMessageDialog(_("You are now ready to race. Good luck!"), @@ -683,9 +687,6 @@ World::getWorld()->scheduleExitRace(); return; } - else if (m_action == "__disabled__") - { - } else { fprintf(stderr, "[TrackObject] WARNING: unknown action <%s>\n", Modified: main/trunk/src/tracks/track_object_presentation.hpp =================================================================== --- main/trunk/src/tracks/track_object_presentation.hpp 2013-07-04 23:56:24 UTC (rev 13085) +++ main/trunk/src/tracks/track_object_presentation.hpp 2013-07-05 00:02:50 UTC (rev 13086) @@ -253,6 +253,8 @@ /** For action trigger objects */ std::string m_action; + bool m_action_active; + public: @@ -260,6 +262,8 @@ virtual ~TrackObjectPresentationActionTrigger() {} virtual void onTriggerItemApproached(Item* who) OVERRIDE; + + virtual void reset() OVERRIDE { m_action_active = true; } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Supertuxkart-commit] SF.net SVN: supertuxkart:[14300] main/trunk/src/tracks From: - 2013-10-24 06:04 ```Revision: 14300 http://sourceforge.net/p/supertuxkart/code/14300 Author: hikerstk Date: 2013-10-24 06:04:22 +0000 (Thu, 24 Oct 2013) Log Message: ----------- Avoid infinite recursion when a track with looped shortcuts is loaded. 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 2013-10-24 00:29:05 UTC (rev 14299) +++ main/trunk/src/tracks/quad_graph.cpp 2013-10-24 06:04:22 UTC (rev 14300) @@ -605,7 +605,7 @@ if(current_distancegetQuadIndex(), delta); + updateDistancesForAllSuccessors(gn->getQuadIndex(), delta, 0); } return; } @@ -634,9 +634,21 @@ * distance from start. * \param indx Index of the node for which to increase the distance. * \param delta Amount by which to increase the distance. + * \param recursive_count Counts how often this function was called + * recursively in order to catch incorrect graphs that contain loops. */ -void QuadGraph::updateDistancesForAllSuccessors(unsigned int indx, float delta) +void QuadGraph::updateDistancesForAllSuccessors(unsigned int indx, float delta, + unsigned int recursive_count) { + if(recursive_count>getNumNodes()) + { + Log::error("QuadGraph", + "Quad graph contains a loop (without start node)."); + Log::fatal("QuadGraph", + "Fix graph, check for directions of all shortcuts etc."); + } + recursive_count++; + GraphNode &g=getNode(indx); g.setDistanceFromStart(g.getDistanceFromStart()+delta); for(unsigned int i=0; i g_next.getDistanceFromStart()) { - updateDistancesForAllSuccessors(g.getSuccessor(i), delta); + updateDistancesForAllSuccessors(g.getSuccessor(i), delta, + recursive_count); } } } // updateDistancesForAllSuccessors Modified: main/trunk/src/tracks/quad_graph.hpp =================================================================== --- main/trunk/src/tracks/quad_graph.hpp 2013-10-24 00:29:05 UTC (rev 14299) +++ main/trunk/src/tracks/quad_graph.hpp 2013-10-24 06:04:22 UTC (rev 14300) @@ -123,7 +123,9 @@ const video::SColor &fill_color =video::SColor(127, 255, 255, 255) ); void mapPoint2MiniMap(const Vec3 &xyz, Vec3 *out) const; - void updateDistancesForAllSuccessors(unsigned int indx, float delta); + void updateDistancesForAllSuccessors(unsigned int indx, + float delta, + unsigned int count); void setupPaths(); void computeChecklineRequirements(); // ---------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```