Rename QuadGraph to DriveGraph, make it use the new Graph interface

This commit is contained in:
Benau
2016-09-17 14:30:28 +08:00
parent 606a5401d3
commit eeac5668d9
36 changed files with 641 additions and 1447 deletions

View File

@@ -29,8 +29,8 @@
#include "modes/linear_world.hpp"
#include "physics/btKart.hpp"
#include "physics/triangle_mesh.hpp"
#include "tracks/graph_node.hpp"
#include "tracks/quad_graph.hpp"
#include "tracks/drive_graph.hpp"
#include "tracks/drive_node.hpp"
#include "tracks/track.hpp"
#include "utils/log.hpp" //TODO: remove after debugging is done
@@ -100,7 +100,7 @@ RubberBall::RubberBall(AbstractKart *kart)
// initialises the current graph node
TrackSector::update(getXYZ());
const Vec3& normal =
QuadGraph::get()->getNode(getCurrentGraphNode())->getNormal();
DriveGraph::get()->getNode(getCurrentGraphNode())->getNormal();
TerrainInfo::update(getXYZ(), -normal);
initializeControlPoints(m_owner->getXYZ());
@@ -136,7 +136,7 @@ void RubberBall::initializeControlPoints(const Vec3 &xyz)
// left or right when firing the ball off track.
getNextControlPoint();
m_control_points[2] =
QuadGraph::get()->getNode(m_last_aimed_graph_node)->getCenter();
DriveGraph::get()->getNode(m_last_aimed_graph_node)->getCenter();
// This updates m_last_aimed_graph_node, and sets m_control_points[3]
getNextControlPoint();
@@ -201,12 +201,12 @@ unsigned int RubberBall::getSuccessorToHitTarget(unsigned int node_index,
unsigned int sect =
lin_world->getSectorForKart(m_target);
succ = QuadGraph::get()->getNode(node_index)->getSuccessorToReach(sect);
succ = DriveGraph::get()->getNode(node_index)->getSuccessorToReach(sect);
if(dist)
*dist += QuadGraph::get()->getNode(node_index)
*dist += DriveGraph::get()->getNode(node_index)
->getDistanceToSuccessor(succ);
return QuadGraph::get()->getNode(node_index)->getSuccessor(succ);
return DriveGraph::get()->getNode(node_index)->getSuccessor(succ);
} // getSuccessorToHitTarget
// ----------------------------------------------------------------------------
@@ -224,21 +224,21 @@ void RubberBall::getNextControlPoint()
// spline between the control points.
float dist=0;
float f = QuadGraph::get()->getDistanceFromStart(m_last_aimed_graph_node);
float f = DriveGraph::get()->getDistanceFromStart(m_last_aimed_graph_node);
int next = getSuccessorToHitTarget(m_last_aimed_graph_node, &dist);
float d = QuadGraph::get()->getDistanceFromStart(next)-f;
float d = DriveGraph::get()->getDistanceFromStart(next)-f;
while(d<m_st_min_interpolation_distance && d>=0)
{
next = getSuccessorToHitTarget(next, &dist);
d = QuadGraph::get()->getDistanceFromStart(next)-f;
d = DriveGraph::get()->getDistanceFromStart(next)-f;
}
m_last_aimed_graph_node = next;
m_length_cp_2_3 = dist;
const GraphNode* gn =
QuadGraph::get()->getNode(m_last_aimed_graph_node);
m_control_points[3] = gn->getCenter();
const DriveNode* dn =
DriveGraph::get()->getNode(m_last_aimed_graph_node);
m_control_points[3] = dn->getCenter();
} // getNextControlPoint
// ----------------------------------------------------------------------------