Fix warning
This commit is contained in:
@@ -41,8 +41,16 @@ Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
|
||||
initItem(type, xyz);
|
||||
//* Rotate item depending on the normal */
|
||||
if (normal.angle(Vec3(0, 1, 0))!= 0)
|
||||
{
|
||||
m_original_hpr.setHPR(btQuaternion(-normal.cross(Vec3(0, 1, 0)),
|
||||
normal.angle(Vec3(0, 1, 0))));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sets heading to 0, and sets pitch and roll depending on the normal. */
|
||||
m_original_hpr = Vec3(0, normal);
|
||||
}
|
||||
|
||||
m_original_mesh = mesh;
|
||||
m_original_lowmesh = lowres_mesh;
|
||||
m_listener = NULL;
|
||||
|
||||
@@ -2055,7 +2055,7 @@ void SkiddingAI::findNonCrashingPointFixed(Vec3 *aim_position, int *last_node)
|
||||
* \param aim_position On exit contains the point the AI should aim at.
|
||||
* \param last_node On exit contais the graph node the AI is aiming at.
|
||||
*/
|
||||
void SkiddingAI::findNonCrashingPoint(Vec3 *aim_position, int *last_node)
|
||||
void SkiddingAI::findNonCrashingPoint(Vec3 *aim_position, int *last_node)
|
||||
{
|
||||
#ifdef AI_DEBUG_KART_HEADING
|
||||
const Vec3 eps(0,0.5f,0);
|
||||
@@ -2068,7 +2068,7 @@ void SkiddingAI::findNonCrashingPointFixed(Vec3 *aim_position, int *last_node)
|
||||
float angle = QuadGraph::get()->getAngleToNext(m_track_node,
|
||||
m_successor_index[m_track_node]);
|
||||
int target_sector;
|
||||
|
||||
|
||||
Vec3 direction;
|
||||
Vec3 step_track_coord;
|
||||
|
||||
@@ -2096,7 +2096,6 @@ void SkiddingAI::findNonCrashingPointFixed(Vec3 *aim_position, int *last_node)
|
||||
// target_sector is the sector at the longest distance that we can
|
||||
// drive to without crashing with the track.
|
||||
target_sector = m_next_node_index[*last_node];
|
||||
|
||||
|
||||
angle1 = QuadGraph::get()->getAngleToNext(target_sector,
|
||||
m_successor_index[target_sector]);
|
||||
@@ -2110,15 +2109,12 @@ void SkiddingAI::findNonCrashingPointFixed(Vec3 *aim_position, int *last_node)
|
||||
.getCenter();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Quad target_quad_unrolled = QuadGraph::get()->getNode(m_track_node).
|
||||
getUnrolledQuad(future_successor_idx,j + 1);
|
||||
|
||||
direction = target_quad_unrolled.getCenter() - m_kart->getXYZ();
|
||||
|
||||
|
||||
float len = direction.length();
|
||||
unsigned int steps = (unsigned int)( len / m_kart_length );
|
||||
if( steps < 3 ) steps = 3;
|
||||
@@ -2129,7 +2125,8 @@ void SkiddingAI::findNonCrashingPointFixed(Vec3 *aim_position, int *last_node)
|
||||
if( steps>1000) steps = 1000;
|
||||
|
||||
// Protection against having vel_normal with nan values
|
||||
if(len>0.0f) {
|
||||
if(len>0.0f)
|
||||
{
|
||||
direction*= 1.0f/len;
|
||||
}
|
||||
|
||||
@@ -2138,7 +2135,7 @@ void SkiddingAI::findNonCrashingPointFixed(Vec3 *aim_position, int *last_node)
|
||||
for(unsigned int i = 2; i < steps; ++i )
|
||||
{
|
||||
step_coord = m_kart->getXYZ()+direction*m_kart_length * float(i);
|
||||
|
||||
|
||||
QuadGraph::get()->spatialToTrackUnrolled(&step_track_coord, step_coord,
|
||||
m_track_node, j, future_successor_idx);
|
||||
|
||||
@@ -2152,15 +2149,14 @@ void SkiddingAI::findNonCrashingPointFixed(Vec3 *aim_position, int *last_node)
|
||||
.getCenter();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
angle = angle1;
|
||||
angle = angle1;
|
||||
*last_node = target_sector;
|
||||
}
|
||||
}
|
||||
// If we are inside entire unrolled set then set the aim_point to be center of the last unrolled quad
|
||||
*aim_position = QuadGraph::get()->getNode(m_track_node).
|
||||
getUnrolledQuad(future_successor_idx,QuadGraph::get()->getNumberOfUnrolledQuads()).getCenter();
|
||||
|
||||
|
||||
} // findNonCrashingPoint
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -283,10 +283,9 @@ void GraphNode::buildUnrolledQuads(unsigned int unroll_quad_count)
|
||||
{
|
||||
m_unrolled_quads.clear();
|
||||
|
||||
|
||||
unsigned int numberOfForks = 1;
|
||||
GraphNode* currentNode = this;
|
||||
for (int i = 0; i < unroll_quad_count+1; i++)
|
||||
for (unsigned i = 0; i < unroll_quad_count+1; i++)
|
||||
{
|
||||
unsigned int successorCount = currentNode->getNumberOfSuccessors();
|
||||
if (successorCount >= 2)
|
||||
@@ -303,7 +302,7 @@ void GraphNode::buildUnrolledQuads(unsigned int unroll_quad_count)
|
||||
|
||||
m_unrolled_quads.resize(numberOfForks);
|
||||
|
||||
for (int i = 0; i < numberOfForks; i++)
|
||||
for (unsigned i = 0; i < numberOfForks; i++)
|
||||
{
|
||||
Quad thisQuad = getQuad();
|
||||
m_unrolled_quads[i].push_back(thisQuad);
|
||||
|
||||
@@ -631,16 +631,20 @@ void QuadGraph::spatialToTrack(Vec3 *dst, const Vec3& xyz,
|
||||
getNode(sector).getDistances(xyz, dst);
|
||||
} // spatialToTrack
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void QuadGraph::spatialToTrackUnrolled(Vec3 *dst, const Vec3& xyz,
|
||||
const int parent_sector, const int unroll_qd_idx, const int fork_number) const
|
||||
const int parent_sector,
|
||||
const int unroll_qd_idx,
|
||||
const int fork_number) const
|
||||
{
|
||||
if (parent_sector == UNKNOWN_SECTOR)
|
||||
{
|
||||
Log::warn("Quad Graph", "UNKNOWN_SECTOR in spatialToTrack().");
|
||||
Log::warn("Quad Graph", "UNKNOWN_SECTOR in spatialToTrackUnrolled().");
|
||||
return;
|
||||
}
|
||||
getNode(parent_sector).getDistancesUnrolled(xyz, fork_number, unroll_qd_idx, dst);
|
||||
}
|
||||
getNode(parent_sector).getDistancesUnrolled(xyz, fork_number,
|
||||
unroll_qd_idx, dst);
|
||||
} // spatialToTrackUnrolled
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** findRoadSector returns in which sector on the road the position
|
||||
|
||||
@@ -195,7 +195,7 @@ public:
|
||||
{ return getNode(node).getUnrolledQuad(fork_number,quad_number); }
|
||||
// ----------------------------------------------------------------------
|
||||
/** Returns the number of forward quads that are unrolled for each quad **/
|
||||
int getNumberOfUnrolledQuads() const { return m_unroll_quad_count; }
|
||||
unsigned int getNumberOfUnrolledQuads() const { return m_unroll_quad_count; }
|
||||
|
||||
}; // QuadGraph
|
||||
|
||||
|
||||
Reference in New Issue
Block a user