Fixed various crashes when enabling AI debug (e.g. missing textures,
heap corruption because the hpp file did not know about AI_DEBUG and so did not declare some variables).
This commit is contained in:
parent
e97b0a9955
commit
cf464f1ed8
@ -18,6 +18,7 @@
|
||||
|
||||
#include "graphics/show_curve.hpp"
|
||||
|
||||
#include "graphics/glwrap.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
@ -64,6 +65,9 @@ void ShowCurve::addEmptyMesh()
|
||||
m_mesh = irr_driver->createQuadMesh(&m,
|
||||
/*create_one_quad*/ false);
|
||||
m_buffer = m_mesh->getMeshBuffer(0);
|
||||
m_buffer->getMaterial().setTexture(0, getUnicolorTexture(video::SColor(128, 255, 105, 180)));
|
||||
m_buffer->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
|
||||
|
||||
assert(m_buffer->getVertexType()==video::EVT_STANDARD);
|
||||
} // addEmptyMesh
|
||||
|
||||
|
@ -252,13 +252,16 @@ void fillLocalBuffer(GLMesh &mesh, scene::IMeshBuffer* mb)
|
||||
glGenBuffers(1, &(mesh.index_buffer));
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, mesh.vertex_buffer);
|
||||
|
||||
const void* vertices = mb->getVertices();
|
||||
const u32 vertexCount = mb->getVertexCount();
|
||||
// This can happen for certain debug structures, e.g. ShowCurve
|
||||
if (vertexCount == 0)
|
||||
return;
|
||||
|
||||
const c8* vbuf = static_cast<const c8*>(vertices);
|
||||
glBufferData(GL_ARRAY_BUFFER, vertexCount * mesh.Stride, vbuf,
|
||||
GL_STREAM_DRAW);
|
||||
assert(vertexCount);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh.index_buffer);
|
||||
const void* indices = mb->getIndices();
|
||||
|
@ -19,24 +19,10 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
//The AI debugging works best with just 1 AI kart, so set the number of karts
|
||||
//to 2 in main.cpp with quickstart and run supertuxkart with the arg -N.
|
||||
#ifdef DEBUG
|
||||
// Enable AI graphical debugging
|
||||
# undef AI_DEBUG
|
||||
// Shows left and right lines when using new findNonCrashing function
|
||||
# undef AI_DEBUG_NEW_FIND_NON_CRASHING
|
||||
// Show the predicted turn circles
|
||||
# undef AI_DEBUG_CIRCLES
|
||||
// Show the heading of the kart
|
||||
# undef AI_DEBUG_KART_HEADING
|
||||
// Shows line from kart to its aim point
|
||||
# undef AI_DEBUG_KART_AIM
|
||||
#endif
|
||||
|
||||
#include "karts/controller/skidding_ai.hpp"
|
||||
|
||||
#ifdef AI_DEBUG
|
||||
# include "graphics/glwrap.hpp"
|
||||
# include "graphics/irr_driver.hpp"
|
||||
#endif
|
||||
#include "graphics/show_curve.hpp"
|
||||
@ -110,6 +96,8 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
|
||||
i==2 ? 128 : 0);
|
||||
m_debug_sphere[i] = irr_driver->addSphere(1.0f, col_debug);
|
||||
m_debug_sphere[i]->setVisible(false);
|
||||
m_debug_sphere[i]->setMaterialTexture(0, getUnicolorTexture(video::SColor(128, 255, 105, 180)));
|
||||
m_debug_sphere[i]->setMaterialTexture(1, getUnicolorTexture(video::SColor(128, 255, 105, 180)));
|
||||
}
|
||||
m_debug_sphere[m_point_selection_algorithm]->setVisible(true);
|
||||
m_item_sphere = irr_driver->addSphere(1.0f);
|
||||
@ -166,7 +154,7 @@ SkiddingAI::~SkiddingAI()
|
||||
{
|
||||
delete m_curve[i];
|
||||
}
|
||||
delete m_curve;
|
||||
delete [] m_curve;
|
||||
#endif
|
||||
} // ~SkiddingAI
|
||||
|
||||
@ -1843,7 +1831,7 @@ void SkiddingAI::findNonCrashingPointNew(Vec3 *result, int *last_node)
|
||||
m_curve[CURVE_RIGHT]->addPoint(q[RIGHT_END_POINT]+eps1);
|
||||
m_curve[CURVE_RIGHT]->addPoint(m_kart->getXYZ()+eps1);
|
||||
#endif
|
||||
#ifdef AI_DEBUG_KART_HEADING
|
||||
#if defined(AI_DEBUG_KART_HEADING) || defined(AI_DEBUG_NEW_FIND_NON_CRASHING)
|
||||
const Vec3 eps(0,0.5f,0);
|
||||
m_curve[CURVE_KART]->clear();
|
||||
m_curve[CURVE_KART]->addPoint(m_kart->getXYZ()+eps);
|
||||
|
@ -22,6 +22,27 @@
|
||||
#ifndef HEADER_SKIDDING_AI_HPP
|
||||
#define HEADER_SKIDDING_AI_HPP
|
||||
|
||||
// Some debugging features for the AI. For example you can visualise the
|
||||
// point the AI is aiming at, or visualise the curve the AI is predicting.
|
||||
// It works best with just 1 AI kart, so set the number of karts
|
||||
// to 2 in main.cpp with quickstart and run supertuxkart with the arg -N.
|
||||
// Or use --profile-laps=99 and run just one AI. Using the debug camera
|
||||
// (top view) is useful, too
|
||||
|
||||
#ifdef DEBUG
|
||||
// Enable AI graphical debugging
|
||||
# define AI_DEBUG
|
||||
// Shows left and right lines when using new findNonCrashing function
|
||||
# undef AI_DEBUG_NEW_FIND_NON_CRASHING
|
||||
// Show the predicted turn circles
|
||||
# undef AI_DEBUG_CIRCLES
|
||||
// Show the heading of the kart
|
||||
# undef AI_DEBUG_KART_HEADING
|
||||
// Shows line from kart to its aim point
|
||||
# undef AI_DEBUG_KART_AIM
|
||||
#endif
|
||||
|
||||
|
||||
#include "karts/controller/ai_base_controller.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "tracks/graph_node.hpp"
|
||||
|
Loading…
Reference in New Issue
Block a user