Removed reversal of quads, instead fixed handling of the data structures
that depend on the orientation to properly handle reverse tracks. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/reverse_mode@10821 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
9c51953e7a
commit
92ef262bb0
@ -44,17 +44,22 @@ GraphNode::GraphNode(unsigned int quad_index, unsigned int node_index)
|
||||
// The width is the average width at the beginning and at the end.
|
||||
m_width = ( (quad[1]-quad[0]).length()
|
||||
+ (quad[3]-quad[2]).length() ) * 0.5f;
|
||||
m_lower_center = (quad[0]+quad[1]) * 0.5f;
|
||||
m_upper_center = (quad[2]+quad[3]) * 0.5f;
|
||||
if(QuadGraph::get()->isReverse())
|
||||
{
|
||||
m_lower_center = (quad[2]+quad[3]) * 0.5f;
|
||||
m_upper_center = (quad[0]+quad[1]) * 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lower_center = (quad[0]+quad[1]) * 0.5f;
|
||||
m_upper_center = (quad[2]+quad[3]) * 0.5f;
|
||||
}
|
||||
m_line = core::line2df(m_lower_center.getX(), m_lower_center.getZ(),
|
||||
m_upper_center.getX(), m_upper_center.getZ() );
|
||||
// Only this 2d point is needed later
|
||||
m_lower_center_2d = core::vector2df(m_lower_center.getX(),
|
||||
m_lower_center.getZ() );
|
||||
|
||||
// The vector from the center of the quad to the middle of the right
|
||||
// side of the quad
|
||||
m_center_to_right = (quad[1]+quad[2])*0.5f - quad.getCenter();
|
||||
} // GraphNode
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -166,8 +171,8 @@ void GraphNode::getDistances(const Vec3 &xyz, Vec3 *result)
|
||||
result->setX( (closest-xyz2d).getLength()); // to the right
|
||||
else
|
||||
result->setX(-(closest-xyz2d).getLength()); // to the left
|
||||
result->setZ( m_distance_from_start + (closest-m_lower_center_2d).getLength());
|
||||
printf("get distances %f %f\n", result->getX(), result->getZ());
|
||||
result->setZ( m_distance_from_start +
|
||||
(closest-m_lower_center_2d).getLength());
|
||||
} // getDistances
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -193,10 +193,6 @@ public:
|
||||
return m_path_to_node.size()>0 ? m_path_to_node[n] : 0;
|
||||
} // getSuccesorToReach
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a vector from the center of the node to the middle of the
|
||||
* right side. */
|
||||
const Vec3 &getCenterToRightVector() const { return m_center_to_right; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the checkline requirements of this graph node. */
|
||||
const std::vector<int>& getChecklineRequirements() const
|
||||
{ return m_checkline_requirements; }
|
||||
|
@ -132,13 +132,3 @@ void Quad::transform(const btTransform &t, Quad *result) const
|
||||
result->m_p[3].getY()) );
|
||||
} // transform
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Reverse the quad */
|
||||
void Quad::reverse() {
|
||||
Vec3 tmp = m_p[0];
|
||||
m_p[0] = m_p[2];
|
||||
m_p[2] = tmp;
|
||||
tmp = m_p[1];
|
||||
m_p[1] = m_p[3];
|
||||
m_p[3] = tmp;
|
||||
}
|
||||
|
@ -76,7 +76,5 @@ public:
|
||||
/** True if this quad should be ignored by the AI. */
|
||||
bool letAIIgnore() const { return m_ai_ignore; }
|
||||
|
||||
/** Reverse the quad */
|
||||
void reverse();
|
||||
}; // class Quad
|
||||
#endif
|
||||
|
@ -52,9 +52,6 @@ QuadGraph::QuadGraph(const std::string &quad_file_name,
|
||||
m_lap_length = 0;
|
||||
QuadSet::create();
|
||||
QuadSet::get()->init(quad_file_name);
|
||||
if(m_reverse) {
|
||||
QuadSet::get()->reverse_all_quads();
|
||||
}
|
||||
m_quad_filename = quad_file_name;
|
||||
m_quad_graph = this;
|
||||
load(graph_file_name);
|
||||
|
@ -48,13 +48,7 @@ QuadSet::~QuadSet()
|
||||
m_quad_set = NULL;
|
||||
} // ~QuadSet
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void reverse_quad(Quad* q) {
|
||||
q->reverse();
|
||||
}
|
||||
void QuadSet::reverse_all_quads() {
|
||||
for_each(m_all_quads.begin(),m_all_quads.end(),reverse_quad);
|
||||
}
|
||||
// -----------------------------------------------------------------------------}
|
||||
/** This function interprets a point specification as an attribute in the
|
||||
xml quadset file. It understands two different specifications:
|
||||
p1="n:p" : get point p from square n (n, p integers)
|
||||
|
@ -52,8 +52,6 @@ public:
|
||||
static const int QUAD_NONE=-1;
|
||||
|
||||
void init (const std::string &filename);
|
||||
void reverse_all_quads();
|
||||
int getCurrentQuad(const Vec3& p, int oldQuad) const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Creates one instance of the quad set. */
|
||||
static void create()
|
||||
|
Loading…
x
Reference in New Issue
Block a user