Moved all debug draw utilities to DebugUtils folder. Added recast data to .obj dump functions.

This commit is contained in:
Mikko Mononen 2009-12-09 15:45:10 +00:00
parent 121807b601
commit a73da5e966
14 changed files with 783 additions and 5900 deletions

View File

@ -1,28 +0,0 @@
//
// Copyright (c) 2009 Mikko Mononen memon@inside.org
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//
#ifndef DETOURDEBUGDRAW_H
#define DETOURDEBUGDRAW_H
#include "DetourNavMesh.h"
void dtDebugDrawNavMesh(const dtNavMesh* mesh, bool drawClosedList = false);
void dtDebugDrawNavMeshBVTree(const dtNavMesh* mesh);
void dtDebugDrawNavMeshPoly(const dtNavMesh* mesh, dtPolyRef ref, const float* col);
#endif // DETOURDEBUGDRAW_H

View File

@ -1,436 +0,0 @@
//
// Copyright (c) 2009 Mikko Mononen memon@inside.org
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//
#include "DetourDebugDraw.h"
#include "DetourNavMesh.h"
#include "SDL.h"
#include "SDL_opengl.h"
static void drawBoxWire(float minx, float miny, float minz, float maxx, float maxy, float maxz, const float* col)
{
glColor4fv(col);
// Top
glVertex3f(minx, miny, minz);
glVertex3f(maxx, miny, minz);
glVertex3f(maxx, miny, minz);
glVertex3f(maxx, miny, maxz);
glVertex3f(maxx, miny, maxz);
glVertex3f(minx, miny, maxz);
glVertex3f(minx, miny, maxz);
glVertex3f(minx, miny, minz);
// bottom
glVertex3f(minx, maxy, minz);
glVertex3f(maxx, maxy, minz);
glVertex3f(maxx, maxy, minz);
glVertex3f(maxx, maxy, maxz);
glVertex3f(maxx, maxy, maxz);
glVertex3f(minx, maxy, maxz);
glVertex3f(minx, maxy, maxz);
glVertex3f(minx, maxy, minz);
// Sides
glVertex3f(minx, miny, minz);
glVertex3f(minx, maxy, minz);
glVertex3f(maxx, miny, minz);
glVertex3f(maxx, maxy, minz);
glVertex3f(maxx, miny, maxz);
glVertex3f(maxx, maxy, maxz);
glVertex3f(minx, miny, maxz);
glVertex3f(minx, maxy, maxz);
}
static float distancePtLine2d(const float* pt, const float* p, const float* q)
{
float pqx = q[0] - p[0];
float pqz = q[2] - p[2];
float dx = pt[0] - p[0];
float dz = pt[2] - p[2];
float d = pqx*pqx + pqz*pqz;
float t = pqx*dx + pqz*dz;
if (d != 0) t /= d;
dx = p[0] + t*pqx - pt[0];
dz = p[2] + t*pqz - pt[2];
return dx*dx + dz*dz;
}
static void drawPolyBoundaries(const dtMeshHeader* header, bool inner)
{
static const float thr = 0.01f*0.01f;
glBegin(GL_LINES);
for (int i = 0; i < header->npolys; ++i)
{
const dtPoly* p = &header->polys[i];
const dtPolyDetail* pd = &header->dmeshes[i];
for (int j = 0, nj = (int)p->nv; j < nj; ++j)
{
if (inner)
{
if (p->n[j] == 0) continue;
if (p->n[j] & 0x8000)
{
bool con = false;
for (int k = 0; k < p->nlinks; ++k)
{
if (header->links[p->links+k].e == j)
{
con = true;
break;
}
}
if (con)
glColor4ub(255,255,255,128);
else
glColor4ub(0,0,0,128);
}
else
glColor4ub(0,48,64,32);
}
else
{
if (p->n[j] != 0) continue;
}
const float* v0 = &header->verts[p->v[j]*3];
const float* v1 = &header->verts[p->v[(j+1)%nj]*3];
// Draw detail mesh edges which align with the actual poly edge.
// This is really slow.
for (int k = 0; k < pd->ntris; ++k)
{
const unsigned char* t = &header->dtris[(pd->tbase+k)*4];
const float* tv[3];
for (int m = 0; m < 3; ++m)
{
if (t[m] < p->nv)
tv[m] = &header->verts[p->v[t[m]]*3];
else
tv[m] = &header->dverts[(pd->vbase+(t[m]-p->nv))*3];
}
for (int m = 0, n = 2; m < 3; n=m++)
{
if (((t[3] >> (n*2)) & 0x3) == 0) continue; // Skip inner detail edges.
if (distancePtLine2d(tv[n],v0,v1) < thr &&
distancePtLine2d(tv[m],v0,v1) < thr)
{
glVertex3fv(tv[n]);
glVertex3fv(tv[m]);
}
}
}
}
}
glEnd();
}
static void drawMeshTile(const dtNavMesh* mesh, const dtMeshTile* tile, bool drawClosedList)
{
const dtMeshHeader* header = tile->header;
dtPolyRef base = mesh->getTileId(tile);
glBegin(GL_TRIANGLES);
for (int i = 0; i < header->npolys; ++i)
{
const dtPoly* p = &header->polys[i];
const dtPolyDetail* pd = &header->dmeshes[i];
if (drawClosedList && mesh->isInClosedList(base | (dtPolyRef)i))
glColor4ub(255,196,0,64);
else
glColor4ub(0,196,255,64);
for (int j = 0; j < pd->ntris; ++j)
{
const unsigned char* t = &header->dtris[(pd->tbase+j)*4];
for (int k = 0; k < 3; ++k)
{
if (t[k] < p->nv)
glVertex3fv(&header->verts[p->v[t[k]]*3]);
else
glVertex3fv(&header->dverts[(pd->vbase+t[k]-p->nv)*3]);
}
}
}
glEnd();
// Draw inter poly boundaries
glColor4ub(0,48,64,32);
glLineWidth(1.5f);
drawPolyBoundaries(header, true);
// Draw outer poly boundaries
glLineWidth(2.5f);
glColor4ub(0,48,64,220);
drawPolyBoundaries(header, false);
glLineWidth(1.0f);
glPointSize(3.0f);
glColor4ub(0,0,0,196);
glBegin(GL_POINTS);
for (int i = 0; i < header->nverts; ++i)
{
const float* v = &header->verts[i*3];
glVertex3f(v[0], v[1], v[2]);
}
glEnd();
glPointSize(1.0f);
// Draw portals
/* glBegin(GL_LINES);
for (int i = 0; i < header->nportals[0]; ++i)
{
const dtTilePortal* p = &header->portals[0][i];
if (p->ncon)
glColor4ub(255,255,255,192);
else
glColor4ub(255,0,0,64);
glVertex3f(header->bmax[0]-0.1f, p->bmin[1], p->bmin[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmax[1], p->bmin[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmax[1], p->bmin[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmax[1], p->bmax[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmax[1], p->bmax[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmin[1], p->bmax[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmin[1], p->bmax[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmin[1], p->bmin[0]);
}
for (int i = 0; i < header->nportals[1]; ++i)
{
const dtTilePortal* p = &header->portals[1][i];
if (p->ncon)
glColor4ub(255,255,255,192);
else
glColor4ub(255,0,0,64);
glVertex3f(p->bmin[0], p->bmin[1], header->bmax[2]-0.1f);
glVertex3f(p->bmin[0], p->bmax[1], header->bmax[2]-0.1f);
glVertex3f(p->bmin[0], p->bmax[1], header->bmax[2]-0.1f);
glVertex3f(p->bmax[0], p->bmax[1], header->bmax[2]-0.1f);
glVertex3f(p->bmax[0], p->bmax[1], header->bmax[2]-0.1f);
glVertex3f(p->bmax[0], p->bmin[1], header->bmax[2]-0.1f);
glVertex3f(p->bmax[0], p->bmin[1], header->bmax[2]-0.1f);
glVertex3f(p->bmin[0], p->bmin[1], header->bmax[2]-0.1f);
}
for (int i = 0; i < header->nportals[2]; ++i)
{
const dtTilePortal* p = &header->portals[2][i];
if (p->ncon)
glColor4ub(255,255,255,192);
else
glColor4ub(255,0,0,64);
glVertex3f(header->bmin[0]+0.1f, p->bmin[1], p->bmin[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmax[1], p->bmin[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmax[1], p->bmin[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmax[1], p->bmax[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmax[1], p->bmax[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmin[1], p->bmax[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmin[1], p->bmax[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmin[1], p->bmin[0]);
}
for (int i = 0; i < header->nportals[3]; ++i)
{
const dtTilePortal* p = &header->portals[3][i];
if (p->ncon)
glColor4ub(255,255,255,192);
else
glColor4ub(255,0,0,64);
glVertex3f(p->bmin[0], p->bmin[1], header->bmin[2]+0.1f);
glVertex3f(p->bmin[0], p->bmax[1], header->bmin[2]+0.1f);
glVertex3f(p->bmin[0], p->bmax[1], header->bmin[2]+0.1f);
glVertex3f(p->bmax[0], p->bmax[1], header->bmin[2]+0.1f);
glVertex3f(p->bmax[0], p->bmax[1], header->bmin[2]+0.1f);
glVertex3f(p->bmax[0], p->bmin[1], header->bmin[2]+0.1f);
glVertex3f(p->bmax[0], p->bmin[1], header->bmin[2]+0.1f);
glVertex3f(p->bmin[0], p->bmin[1], header->bmin[2]+0.1f);
}
glEnd();*/
}
void dtDebugDrawNavMesh(const dtNavMesh* mesh, bool drawClosedList)
{
if (!mesh) return;
for (int i = 0; i < mesh->getMaxTiles(); ++i)
{
const dtMeshTile* tile = mesh->getTile(i);
if (!tile->header) continue;
drawMeshTile(mesh, tile, drawClosedList);
}
}
static void drawMeshTileBVTree(const dtNavMesh* mesh, const dtMeshTile* tile)
{
const dtMeshHeader* header = tile->header;
// Draw BV nodes.
const float col[] = { 1,1,1,0.5f };
const float cs = 1.0f / header->bvquant;
glBegin(GL_LINES);
for (int i = 0; i < header->nbvtree; ++i)
{
const dtBVNode* n = &header->bvtree[i];
if (n->i < 0) // Leaf indices are positive.
continue;
drawBoxWire(header->bmin[0] + n->bmin[0]*cs,
header->bmin[1] + n->bmin[1]*cs,
header->bmin[2] + n->bmin[2]*cs,
header->bmin[0] + n->bmax[0]*cs,
header->bmin[1] + n->bmax[1]*cs,
header->bmin[2] + n->bmax[2]*cs, col);
}
glEnd();
// Draw portals
/* glBegin(GL_LINES);
for (int i = 0; i < header->nportals[0]; ++i)
{
const dtTilePortal* p = &header->portals[0][i];
if (p->ncon)
glColor4ub(255,255,255,192);
else
glColor4ub(255,0,0,64);
glVertex3f(header->bmax[0]-0.1f, p->bmin[1], p->bmin[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmax[1], p->bmin[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmax[1], p->bmin[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmax[1], p->bmax[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmax[1], p->bmax[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmin[1], p->bmax[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmin[1], p->bmax[0]);
glVertex3f(header->bmax[0]-0.1f, p->bmin[1], p->bmin[0]);
}
for (int i = 0; i < header->nportals[1]; ++i)
{
const dtTilePortal* p = &header->portals[1][i];
if (p->ncon)
glColor4ub(255,255,255,192);
else
glColor4ub(255,0,0,64);
glVertex3f(p->bmin[0], p->bmin[1], header->bmax[2]-0.1f);
glVertex3f(p->bmin[0], p->bmax[1], header->bmax[2]-0.1f);
glVertex3f(p->bmin[0], p->bmax[1], header->bmax[2]-0.1f);
glVertex3f(p->bmax[0], p->bmax[1], header->bmax[2]-0.1f);
glVertex3f(p->bmax[0], p->bmax[1], header->bmax[2]-0.1f);
glVertex3f(p->bmax[0], p->bmin[1], header->bmax[2]-0.1f);
glVertex3f(p->bmax[0], p->bmin[1], header->bmax[2]-0.1f);
glVertex3f(p->bmin[0], p->bmin[1], header->bmax[2]-0.1f);
}
for (int i = 0; i < header->nportals[2]; ++i)
{
const dtTilePortal* p = &header->portals[2][i];
if (p->ncon)
glColor4ub(255,255,255,192);
else
glColor4ub(255,0,0,64);
glVertex3f(header->bmin[0]+0.1f, p->bmin[1], p->bmin[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmax[1], p->bmin[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmax[1], p->bmin[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmax[1], p->bmax[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmax[1], p->bmax[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmin[1], p->bmax[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmin[1], p->bmax[0]);
glVertex3f(header->bmin[0]+0.1f, p->bmin[1], p->bmin[0]);
}
for (int i = 0; i < header->nportals[3]; ++i)
{
const dtTilePortal* p = &header->portals[3][i];
if (p->ncon)
glColor4ub(255,255,255,192);
else
glColor4ub(255,0,0,64);
glVertex3f(p->bmin[0], p->bmin[1], header->bmin[2]+0.1f);
glVertex3f(p->bmin[0], p->bmax[1], header->bmin[2]+0.1f);
glVertex3f(p->bmin[0], p->bmax[1], header->bmin[2]+0.1f);
glVertex3f(p->bmax[0], p->bmax[1], header->bmin[2]+0.1f);
glVertex3f(p->bmax[0], p->bmax[1], header->bmin[2]+0.1f);
glVertex3f(p->bmax[0], p->bmin[1], header->bmin[2]+0.1f);
glVertex3f(p->bmax[0], p->bmin[1], header->bmin[2]+0.1f);
glVertex3f(p->bmin[0], p->bmin[1], header->bmin[2]+0.1f);
}
glEnd();*/
}
void dtDebugDrawNavMeshBVTree(const dtNavMesh* mesh)
{
if (!mesh) return;
for (int i = 0; i < mesh->getMaxTiles(); ++i)
{
const dtMeshTile* tile = mesh->getTile(i);
if (!tile->header) continue;
drawMeshTileBVTree(mesh, tile);
}
}
void dtDebugDrawNavMeshPoly(const dtNavMesh* mesh, dtPolyRef ref, const float* col)
{
int ip = 0;
const dtMeshTile* tile = mesh->getTileByRef(ref, &ip);
if (!tile)
return;
const dtMeshHeader* header = tile->header;
const dtPoly* p = &header->polys[ip];
const dtPolyDetail* pd = &header->dmeshes[ip];
glColor4f(col[0],col[1],col[2],0.25f);
glBegin(GL_TRIANGLES);
for (int i = 0; i < pd->ntris; ++i)
{
const unsigned char* t = &header->dtris[(pd->tbase+i)*4];
for (int j = 0; j < 3; ++j)
{
if (t[j] < p->nv)
glVertex3fv(&header->verts[p->v[t[j]]*3]);
else
glVertex3fv(&header->dverts[(pd->vbase+t[j]-p->nv)*3]);
}
}
glEnd();
}

View File

@ -1,117 +0,0 @@
//
// Copyright (c) 2009 Mikko Mononen memon@inside.org
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//
#ifndef RECAST_DEBUGDRAW_H
#define RECAST_DEBUGDRAW_H
enum rcDebugDrawPrimitives
{
RC_DRAW_POINTS,
RC_DRAW_LINES,
RC_DRAW_TRIS,
RC_DRAW_QUADS,
};
// Abstrace debug draw interface.
struct rcDebugDraw
{
// Begin drawing primitives.
// Params:
// prim - (in) primitive type to draw, one of rcDebugDrawPrimitives.
// nverts - (in) number of vertices to be submitted.
// size - (in) size of a primitive, applies to point size and line width only.
virtual void begin(rcDebugDrawPrimitives prim, int nverts, float size = 1.0f) = 0;
// Submit a vertex
// Params:
// pos - (in) position of the verts.
// color - (in) color of the verts.
virtual void vertex(const float* pos, unsigned int color) = 0;
// Submit a vertex
// Params:
// x,y,z - (in) position of the verts.
// color - (in) color of the verts.
virtual void vertex(const float x, const float y, const float z, unsigned int color) = 0;
// End drawing primitives.
virtual void end() = 0;
};
inline unsigned int RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
return (r) | (g << 8) | (b << 16) | (a << 24);
}
inline unsigned int RGBAf(float fr, float fg, float fb, float fa)
{
unsigned char r = (unsigned char)(fr*255.0f);
unsigned char g = (unsigned char)(fg*255.0f);
unsigned char b = (unsigned char)(fb*255.0f);
unsigned char a = (unsigned char)(fa*255.0f);
return RGBA(r,g,b,a);
}
inline int bit(int a, int b)
{
return (a & (1 << b)) >> b;
}
inline unsigned int intToCol(int i, int a)
{
int r = bit(i, 0) + bit(i, 3) * 2 + 1;
int g = bit(i, 1) + bit(i, 4) * 2 + 1;
int b = bit(i, 2) + bit(i, 5) * 2 + 1;
return RGBA(r*63,g*63,b*63,a);
}
inline void intToCol(int i, float* col)
{
int r = bit(i, 0) + bit(i, 3) * 2 + 1;
int g = bit(i, 1) + bit(i, 4) * 2 + 1;
int b = bit(i, 2) + bit(i, 5) * 2 + 1;
col[0] = 1 - r*63.0f/255.0f;
col[1] = 1 - g*63.0f/255.0f;
col[2] = 1 - b*63.0f/255.0f;
}
void rcDebugDrawHeightfieldSolid(rcDebugDraw* dd, const struct rcHeightfield& hf);
void rcDebugDrawHeightfieldWalkable(rcDebugDraw* dd, const struct rcHeightfield& hf);
void rcDebugDrawMesh(rcDebugDraw* dd, const float* verts, int nverts, const int* tris, const float* normals, int ntris, const unsigned char* flags);
void rcDebugDrawMeshSlope(rcDebugDraw* dd, const float* verts, int nverts, const int* tris, const float* normals, int ntris, const float walkableSlopeAngle);
void rcDebugDrawCompactHeightfieldSolid(rcDebugDraw* dd, const struct rcCompactHeightfield& chf);
void rcDebugDrawCompactHeightfieldRegions(rcDebugDraw* dd, const struct rcCompactHeightfield& chf);
void rcDebugDrawCompactHeightfieldDistance(rcDebugDraw* dd, const struct rcCompactHeightfield& chf);
void rcDebugDrawRegionConnections(rcDebugDraw* dd, const struct rcContourSet& cset, const float alpha = 1.0f);
void rcDebugDrawRawContours(rcDebugDraw* dd, const struct rcContourSet& cset, const float alpha = 1.0f);
void rcDebugDrawContours(rcDebugDraw* dd, const struct rcContourSet& cset, const float alpha = 1.0f);
void rcDebugDrawPolyMesh(rcDebugDraw* dd, const struct rcPolyMesh& mesh);
void rcDebugDrawPolyMeshDetail(rcDebugDraw* dd, const struct rcPolyMeshDetail& dmesh);
void rcDebugDrawCylinderWire(rcDebugDraw* dd, float minx, float miny, float minz,
float maxx, float maxy, float maxz, const float* col);
void rcDebugDrawBoxWire(rcDebugDraw* dd, float minx, float miny, float minz,
float maxx, float maxy, float maxz, const float* col);
void rcDebugDrawBox(rcDebugDraw* dd, float minx, float miny, float minz, float maxx, float maxy, float maxz,
const float* col1, const float* col2);
void rcDrawArc(rcDebugDraw* dd, const float* p0, const float* p1, const float* col, float lineWidth);
#endif // RECAST_DEBUGDRAW_H

View File

@ -1,931 +0,0 @@
//
// Copyright (c) 2009 Mikko Mononen memon@inside.org
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//
#define _USE_MATH_DEFINES
#include <math.h>
#include "RecastDebugDraw.h"
#include "MeshLoaderObj.h"
#include "Recast.h"
inline unsigned int dark(unsigned int col)
{
return ((col >> 1) & 0x007f7f7f) | (col & 0xff000000);
}
void rcDebugDrawMesh(rcDebugDraw* dd, const float* verts, int nverts,
const int* tris, const float* normals, int ntris,
const unsigned char* flags)
{
dd->begin(RC_DRAW_TRIS, ntris);
for (int i = 0; i < ntris*3; i += 3)
{
unsigned int color;
unsigned char a = (unsigned char)(150*(2+normals[i+0]+normals[i+1])/4);
if (flags && !flags[i/3])
color = RGBA(a,a/4,a/16,255);
else
color = RGBA(a,a,a,255);
dd->vertex(&verts[tris[i+0]*3], color);
dd->vertex(&verts[tris[i+1]*3], color);
dd->vertex(&verts[tris[i+2]*3], color);
}
dd->end();
}
void rcDebugDrawMeshSlope(rcDebugDraw* dd, const float* verts, int nverts,
const int* tris, const float* normals, int ntris,
const float walkableSlopeAngle)
{
const float walkableThr = cosf(walkableSlopeAngle/180.0f*(float)M_PI);
dd->begin(RC_DRAW_TRIS, ntris);
for (int i = 0; i < ntris*3; i += 3)
{
const float* norm = &normals[i];
unsigned int color;
unsigned char a = (unsigned char)(255*(2+normals[i+0]+normals[i+1])/4);
if (norm[1] < walkableThr)
color = RGBA(a,a/4,a/16,255);
else
color = RGBA(a,a,a,255);
dd->vertex(&verts[tris[i+0]*3], color);
dd->vertex(&verts[tris[i+1]*3], color);
dd->vertex(&verts[tris[i+2]*3], color);
}
dd->end();
}
static void drawBoxWire(rcDebugDraw* dd,
float minx, float miny, float minz,
float maxx, float maxy, float maxz,
const float* col)
{
// Submits 24 vertices.
unsigned int color = RGBAf(col[0],col[1],col[2],col[3]);
// Top
dd->vertex(minx, miny, minz, color);
dd->vertex(maxx, miny, minz, color);
dd->vertex(maxx, miny, minz, color);
dd->vertex(maxx, miny, maxz, color);
dd->vertex(maxx, miny, maxz, color);
dd->vertex(minx, miny, maxz, color);
dd->vertex(minx, miny, maxz, color);
dd->vertex(minx, miny, minz, color);
// bottom
dd->vertex(minx, maxy, minz, color);
dd->vertex(maxx, maxy, minz, color);
dd->vertex(maxx, maxy, minz, color);
dd->vertex(maxx, maxy, maxz, color);
dd->vertex(maxx, maxy, maxz, color);
dd->vertex(minx, maxy, maxz, color);
dd->vertex(minx, maxy, maxz, color);
dd->vertex(minx, maxy, minz, color);
// Sides
dd->vertex(minx, miny, minz, color);
dd->vertex(minx, maxy, minz, color);
dd->vertex(maxx, miny, minz, color);
dd->vertex(maxx, maxy, minz, color);
dd->vertex(maxx, miny, maxz, color);
dd->vertex(maxx, maxy, maxz, color);
dd->vertex(minx, miny, maxz, color);
dd->vertex(minx, maxy, maxz, color);
}
static void drawBox(rcDebugDraw* dd,
float minx, float miny, float minz,
float maxx, float maxy, float maxz,
const float* col1, const float* col2)
{
// Submits 24 vertices.
const float verts[8*3] =
{
minx, miny, minz,
maxx, miny, minz,
maxx, miny, maxz,
minx, miny, maxz,
minx, maxy, minz,
maxx, maxy, minz,
maxx, maxy, maxz,
minx, maxy, maxz,
};
static const float dim[6] =
{
0.95f, 0.55f, 0.65f, 0.85f, 0.65f, 0.85f,
};
static const unsigned char inds[6*5] =
{
0, 7, 6, 5, 4,
1, 0, 1, 2, 3,
2, 1, 5, 6, 2,
3, 3, 7, 4, 0,
4, 2, 6, 7, 3,
5, 0, 4, 5, 1,
};
const unsigned char* in = inds;
for (int i = 0; i < 6; ++i)
{
float d = dim[*in]; in++;
unsigned int color;
if (i == 0)
color = RGBAf(d*col2[0],d*col2[1],d*col2[2], col2[3]);
else
color = RGBAf(d*col1[0],d*col1[1],d*col1[2], col1[3]);
dd->vertex(&verts[*in*3], color); in++;
dd->vertex(&verts[*in*3], color); in++;
dd->vertex(&verts[*in*3], color); in++;
dd->vertex(&verts[*in*3], color); in++;
}
}
void rcDebugDrawCylinderWire(rcDebugDraw* dd, float minx, float miny, float minz,
float maxx, float maxy, float maxz,
const float* col)
{
static const int NUM_SEG = 16;
float dir[NUM_SEG*2];
for (int i = 0; i < NUM_SEG; ++i)
{
const float a = (float)i/(float)NUM_SEG*(float)M_PI*2;
dir[i*2] = cosf(a);
dir[i*2+1] = sinf(a);
}
const float cx = (maxx + minx)/2;
const float cz = (maxz + minz)/2;
const float rx = (maxx - minx)/2;
const float rz = (maxz - minz)/2;
unsigned int color = RGBAf(col[0],col[1],col[2],col[3]);
const int nv = NUM_SEG*4 + 4*2;
dd->begin(RC_DRAW_LINES, nv);
for (int i = 0, j=NUM_SEG-1; i < NUM_SEG; j=i++)
{
dd->vertex(cx+dir[j*2+0]*rx, miny, cz+dir[j*2+1]*rz, color);
dd->vertex(cx+dir[i*2+0]*rx, miny, cz+dir[i*2+1]*rz, color);
dd->vertex(cx+dir[j*2+0]*rx, maxy, cz+dir[j*2+1]*rz, color);
dd->vertex(cx+dir[i*2+0]*rx, maxy, cz+dir[i*2+1]*rz, color);
}
for (int i = 0; i < NUM_SEG; i += NUM_SEG/4)
{
dd->vertex(cx+dir[i*2+0]*rx, miny, cz+dir[i*2+1]*rz, color);
dd->vertex(cx+dir[i*2+0]*rx, maxy, cz+dir[i*2+1]*rz, color);
}
dd->end();
}
void rcDebugDrawBoxWire(rcDebugDraw* dd, float minx, float miny, float minz, float maxx, float maxy, float maxz, const float* col)
{
dd->begin(RC_DRAW_LINES, 24, 1.0f);
drawBoxWire(dd, minx, miny, minz, maxx, maxy, maxz, col);
dd->end();
}
void rcDebugDrawBox(rcDebugDraw* dd, float minx, float miny, float minz, float maxx, float maxy, float maxz,
const float* col1, const float* col2)
{
dd->begin(RC_DRAW_QUADS,24);
drawBox(dd, minx, miny, minz, maxx, maxy, maxz, col1, col2);
dd->end();
}
static int getSpanCount(const rcHeightfield& hf)
{
const int w = hf.width;
const int h = hf.height;
int spanCount = 0;
for (int y = 0; y < h; ++y)
for (int x = 0; x < w; ++x)
for (rcSpan* s = hf.spans[x + y*w]; s; s = s->next)
spanCount++;
return spanCount;
}
void rcDebugDrawHeightfieldSolid(rcDebugDraw* dd, const rcHeightfield& hf)
{
static const float col0[4] = { 1,1,1,1 };
const float* orig = hf.bmin;
const float cs = hf.cs;
const float ch = hf.ch;
const int w = hf.width;
const int h = hf.height;
const int spanCount = getSpanCount(hf);
const int nv = spanCount*24;
dd->begin(RC_DRAW_QUADS, nv);
for (int y = 0; y < h; ++y)
{
for (int x = 0; x < w; ++x)
{
float fx = orig[0] + x*cs;
float fz = orig[2] + y*cs;
const rcSpan* s = hf.spans[x + y*w];
while (s)
{
drawBox(dd, fx, orig[1]+s->smin*ch, fz, fx+cs, orig[1] + s->smax*ch, fz+cs, col0, col0);
s = s->next;
}
}
}
dd->end();
}
void rcDebugDrawHeightfieldWalkable(rcDebugDraw* dd, const rcHeightfield& hf)
{
static const float colb[4] = {0.85f,0.85f,0.85f,1 }; // Base
static const float col0[4] = {0.5f, 0.75f, 0.85f,1}; // Culled
static const float col1[4] = {0.3f, 0.55f, 0.65f, 1}; // Walkable
static const float col2[4] = {0.15f, 0.4f, 0.5f,1}; // Ledge
const float* orig = hf.bmin;
const float cs = hf.cs;
const float ch = hf.ch;
const int w = hf.width;
const int h = hf.height;
const int spanCount = getSpanCount(hf);
const int nv = spanCount*24;
dd->begin(RC_DRAW_QUADS, nv);
for (int y = 0; y < h; ++y)
{
for (int x = 0; x < w; ++x)
{
float fx = orig[0] + x*cs;
float fz = orig[2] + y*cs;
const rcSpan* s = hf.spans[x + y*w];
while (s)
{
const float* c = col0;
if (s->flags & RC_LEDGE)
c = col2;
else if (s->flags & RC_WALKABLE)
c = col1;
drawBox(dd, fx, orig[1]+s->smin*ch, fz, fx+cs, orig[1] + s->smax*ch, fz+cs, colb, c);
s = s->next;
}
}
}
dd->end();
}
void rcDebugDrawCompactHeightfieldSolid(rcDebugDraw* dd, const rcCompactHeightfield& chf)
{
const float cs = chf.cs;
const float ch = chf.ch;
unsigned int color = RGBA(0,192,255,64);
dd->begin(RC_DRAW_QUADS, chf.spanCount*4);
for (int y = 0; y < chf.height; ++y)
{
for (int x = 0; x < chf.width; ++x)
{
const float fx = chf.bmin[0] + x*cs;
const float fz = chf.bmin[2] + y*cs;
const rcCompactCell& c = chf.cells[x+y*chf.width];
for (unsigned i = c.index, ni = c.index+c.count; i < ni; ++i)
{
const rcCompactSpan& s = chf.spans[i];
const float fy = chf.bmin[1] + (s.y+1)*ch;
dd->vertex(fx, fy, fz, color);
dd->vertex(fx, fy, fz+cs, color);
dd->vertex(fx+cs, fy, fz+cs, color);
dd->vertex(fx+cs, fy, fz, color);
}
}
}
dd->end();
}
void rcDebugDrawCompactHeightfieldRegions(rcDebugDraw* dd, const rcCompactHeightfield& chf)
{
const float cs = chf.cs;
const float ch = chf.ch;
dd->begin(RC_DRAW_QUADS, chf.spanCount*4);
for (int y = 0; y < chf.height; ++y)
{
for (int x = 0; x < chf.width; ++x)
{
const float fx = chf.bmin[0] + x*cs;
const float fz = chf.bmin[2] + y*cs;
const rcCompactCell& c = chf.cells[x+y*chf.width];
for (unsigned i = c.index, ni = c.index+c.count; i < ni; ++i)
{
const rcCompactSpan& s = chf.spans[i];
const float fy = chf.bmin[1] + (s.y)*ch;
unsigned int color;
if (chf.reg[i])
color = intToCol(chf.reg[i], 192);
else
color = RGBA(0,0,0,64);
dd->vertex(fx, fy, fz, color);
dd->vertex(fx, fy, fz+cs, color);
dd->vertex(fx+cs, fy, fz+cs, color);
dd->vertex(fx+cs, fy, fz, color);
}
}
}
dd->end();
}
void rcDebugDrawCompactHeightfieldDistance(rcDebugDraw* dd, const rcCompactHeightfield& chf)
{
const float cs = chf.cs;
const float ch = chf.ch;
float maxd = chf.maxDistance;
if (maxd < 1.0f) maxd = 1;
const float dscale = 255.0f / maxd;
dd->begin(RC_DRAW_QUADS, chf.spanCount*4);
for (int y = 0; y < chf.height; ++y)
{
for (int x = 0; x < chf.width; ++x)
{
const float fx = chf.bmin[0] + x*cs;
const float fz = chf.bmin[2] + y*cs;
const rcCompactCell& c = chf.cells[x+y*chf.width];
for (unsigned i = c.index, ni = c.index+c.count; i < ni; ++i)
{
const rcCompactSpan& s = chf.spans[i];
const float fy = chf.bmin[1] + (s.y+1)*ch;
const unsigned char cd = (unsigned char)(chf.dist[i] * dscale);
const unsigned int color = RGBA(cd,cd,cd,255);
dd->vertex(fx, fy, fz, color);
dd->vertex(fx, fy, fz+cs, color);
dd->vertex(fx+cs, fy, fz+cs, color);
dd->vertex(fx+cs, fy, fz, color);
}
}
}
dd->end();
}
static void getContourCenter(const rcContour* cont, const float* orig, float cs, float ch, float* center)
{
center[0] = 0;
center[1] = 0;
center[2] = 0;
if (!cont->nverts)
return;
for (int i = 0; i < cont->nverts; ++i)
{
const int* v = &cont->verts[i*4];
center[0] += (float)v[0];
center[1] += (float)v[1];
center[2] += (float)v[2];
}
const float s = 1.0f / cont->nverts;
center[0] *= s * cs;
center[1] *= s * ch;
center[2] *= s * cs;
center[0] += orig[0];
center[1] += orig[1] + 4*ch;
center[2] += orig[2];
}
static const rcContour* findContourFromSet(const rcContourSet& cset, unsigned short reg)
{
for (int i = 0; i < cset.nconts; ++i)
{
if (cset.conts[i].reg == reg)
return &cset.conts[i];
}
return 0;
}
static const int NUM_ARC_PTS = 8;
static void drawArc(rcDebugDraw* dd, const float* p0, const float* p1, unsigned int color)
{
// Submits NPTS*2 vertices.
float pts[NUM_ARC_PTS*3];
float dir[3];
vsub(dir, p1, p0);
const float len = sqrtf(vdistSqr(p0, p1));
for (int i = 0; i < NUM_ARC_PTS; ++i)
{
float u = (float)i / (float)(NUM_ARC_PTS-1);
float* p = &pts[i*3];
p[0] = p0[0] + dir[0] * u;
p[1] = p0[1] + dir[1] * u + (len/4) * (1-rcSqr(u*2-1));
p[2] = p0[2] + dir[2] * u;
}
for (int i = 0; i < NUM_ARC_PTS-1; ++i)
{
dd->vertex(&pts[i*3], color);
dd->vertex(&pts[(i+1)*3], color);
}
}
void rcDrawArc(rcDebugDraw* dd, const float* p0, const float* p1, const float* col, float lineWidth)
{
const unsigned int color = RGBAf(col[0],col[1],col[2],col[3]);
dd->begin(RC_DRAW_LINES, NUM_ARC_PTS*2, lineWidth);
drawArc(dd, p0, p1, color);
dd->end();
}
void rcDebugDrawRegionConnections(rcDebugDraw* dd, const rcContourSet& cset, const float alpha)
{
const float* orig = cset.bmin;
const float cs = cset.cs;
const float ch = cset.ch;
// Draw centers
float pos[3], pos2[3];
unsigned int color = RGBA(0,0,0,196);
int nv = 0;
for (int i = 0; i < cset.nconts; ++i)
{
const rcContour* cont = &cset.conts[i];
for (int j = 0; j < cont->nverts; ++j)
{
const int* v = &cont->verts[j*4];
if (v[3] == 0 || (unsigned short)v[3] < cont->reg) continue;
if (findContourFromSet(cset, (unsigned short)v[3]))
nv += NUM_ARC_PTS;
}
}
dd->begin(RC_DRAW_LINES, nv, 2.0f);
for (int i = 0; i < cset.nconts; ++i)
{
const rcContour* cont = &cset.conts[i];
getContourCenter(cont, orig, cs, ch, pos);
for (int j = 0; j < cont->nverts; ++j)
{
const int* v = &cont->verts[j*4];
if (v[3] == 0 || (unsigned short)v[3] < cont->reg) continue;
const rcContour* cont2 = findContourFromSet(cset, (unsigned short)v[3]);
if (cont2)
{
getContourCenter(cont2, orig, cs, ch, pos2);
drawArc(dd, pos, pos2, color);
}
}
}
dd->end();
unsigned char a = (unsigned char)(alpha * 255.0f);
dd->begin(RC_DRAW_POINTS, nv, 7.0f);
for (int i = 0; i < cset.nconts; ++i)
{
const rcContour* cont = &cset.conts[i];
unsigned int color = dark(intToCol(cont->reg,a));
getContourCenter(cont, orig, cs, ch, pos);
dd->vertex(pos, color);
}
dd->end();
}
void rcDebugDrawRawContours(rcDebugDraw* dd, const rcContourSet& cset, const float alpha)
{
const float* orig = cset.bmin;
const float cs = cset.cs;
const float ch = cset.ch;
const unsigned char a = (unsigned char)(alpha*255.0f);
int nv = 0;
for (int i = 0; i < cset.nconts; ++i)
{
const rcContour& c = cset.conts[i];
nv += c.nrverts;
}
dd->begin(RC_DRAW_LINES, nv*2, 2.0f);
for (int i = 0; i < cset.nconts; ++i)
{
const rcContour& c = cset.conts[i];
unsigned int color = intToCol(c.reg, a);
for (int j = 0; j < c.nrverts; ++j)
{
const int* v = &c.rverts[j*4];
float fx = orig[0] + v[0]*cs;
float fy = orig[1] + (v[1]+1+(i&1))*ch;
float fz = orig[2] + v[2]*cs;
dd->vertex(fx,fy,fz,color);
if (j > 0)
dd->vertex(fx,fy,fz,color);
}
// Loop last segment.
const int* v = &c.rverts[0];
float fx = orig[0] + v[0]*cs;
float fy = orig[1] + (v[1]+1+(i&1))*ch;
float fz = orig[2] + v[2]*cs;
dd->vertex(fx,fy,fz,color);
}
dd->end();
dd->begin(RC_DRAW_POINTS, nv, 2.0f);
for (int i = 0; i < cset.nconts; ++i)
{
const rcContour& c = cset.conts[i];
unsigned int color = dark(intToCol(c.reg, a));
for (int j = 0; j < c.nrverts; ++j)
{
const int* v = &c.rverts[j*4];
float off = 0;
unsigned int colv = color;
if (v[3] & RC_BORDER_VERTEX)
{
colv = RGBA(255,255,255,a);
off = ch*2;
}
float fx = orig[0] + v[0]*cs;
float fy = orig[1] + (v[1]+1+(i&1))*ch + off;
float fz = orig[2] + v[2]*cs;
dd->vertex(fx,fy,fz, colv);
}
}
dd->end();
}
void rcDebugDrawContours(rcDebugDraw* dd, const rcContourSet& cset, const float alpha)
{
const float* orig = cset.bmin;
const float cs = cset.cs;
const float ch = cset.ch;
const unsigned char a = (unsigned char)(alpha*255.0f);
int nv = 0;
for (int i = 0; i < cset.nconts; ++i)
{
const rcContour& c = cset.conts[i];
nv += c.nverts;
}
dd->begin(RC_DRAW_LINES, nv*2, 2.5f);
for (int i = 0; i < cset.nconts; ++i)
{
const rcContour& c = cset.conts[i];
if (!c.nverts)
continue;
unsigned int color = intToCol(c.reg, a);
for (int j = 0; j < c.nverts; ++j)
{
const int* v = &c.verts[j*4];
float fx = orig[0] + v[0]*cs;
float fy = orig[1] + (v[1]+1+(i&1))*ch;
float fz = orig[2] + v[2]*cs;
dd->vertex(fx,fy,fz, color);
if (j > 0)
dd->vertex(fx,fy,fz, color);
}
// Loop last segment
const int* v = &c.verts[0];
float fx = orig[0] + v[0]*cs;
float fy = orig[1] + (v[1]+1+(i&1))*ch;
float fz = orig[2] + v[2]*cs;
dd->vertex(fx,fy,fz, color);
}
dd->end();
dd->begin(RC_DRAW_POINTS, nv, 3.0f);
for (int i = 0; i < cset.nconts; ++i)
{
const rcContour& c = cset.conts[i];
unsigned int color = dark(intToCol(c.reg, a));
for (int j = 0; j < c.nverts; ++j)
{
const int* v = &c.verts[j*4];
float off = 0;
unsigned int colv = color;
if (v[3] & RC_BORDER_VERTEX)
{
colv = RGBA(255,255,255,a);
off = ch*2;
}
float fx = orig[0] + v[0]*cs;
float fy = orig[1] + (v[1]+1+(i&1))*ch + off;
float fz = orig[2] + v[2]*cs;
dd->vertex(fx,fy,fz, colv);
}
}
dd->end();
}
void rcDebugDrawPolyMesh(rcDebugDraw* dd, const struct rcPolyMesh& mesh)
{
const int nvp = mesh.nvp;
const float cs = mesh.cs;
const float ch = mesh.ch;
const float* orig = mesh.bmin;
int nvt = 0; // triangle verts
int nvb = 0; // boundary edge verts
int nvn = 0; // neighbour edge verts
for (int i = 0; i < mesh.npolys; ++i)
{
const unsigned short* p = &mesh.polys[i*nvp*2];
// Tris
for (int j = 2; j < nvp; ++j)
{
if (p[j] == 0xffff) break;
nvt += 3;
}
// boundary edges
for (int j = 0; j < nvp; ++j)
{
if (p[j] == 0xffff) break;
if (p[nvp+j] == 0xffff) continue;
nvb += 2;
}
// neighbour edges
for (int j = 0; j < nvp; ++j)
{
if (p[j] == 0xffff) break;
if (p[nvp+j] != 0xffff) continue;
nvb += 2;
}
}
dd->begin(RC_DRAW_TRIS, nvt);
for (int i = 0; i < mesh.npolys; ++i)
{
const unsigned short* p = &mesh.polys[i*nvp*2];
unsigned int color = intToCol(i, 192);
unsigned short vi[3];
for (int j = 2; j < nvp; ++j)
{
if (p[j] == 0xffff) break;
vi[0] = p[0];
vi[1] = p[j-1];
vi[2] = p[j];
for (int k = 0; k < 3; ++k)
{
const unsigned short* v = &mesh.verts[vi[k]*3];
const float x = orig[0] + v[0]*cs;
const float y = orig[1] + (v[1]+1)*ch;
const float z = orig[2] + v[2]*cs;
dd->vertex(x,y,z, color);
}
}
}
dd->end();
// Draw neighbours edges
const unsigned int coln = RGBA(0,48,64,32);
dd->begin(RC_DRAW_LINES, nvn, 1.5f);
for (int i = 0; i < mesh.npolys; ++i)
{
const unsigned short* p = &mesh.polys[i*nvp*2];
for (int j = 0; j < nvp; ++j)
{
if (p[j] == 0xffff) break;
if (p[nvp+j] == 0xffff) continue;
int vi[2];
vi[0] = p[j];
if (j+1 >= nvp || p[j+1] == 0xffff)
vi[1] = p[0];
else
vi[1] = p[j+1];
for (int k = 0; k < 2; ++k)
{
const unsigned short* v = &mesh.verts[vi[k]*3];
const float x = orig[0] + v[0]*cs;
const float y = orig[1] + (v[1]+1)*ch + 0.1f;
const float z = orig[2] + v[2]*cs;
dd->vertex(x, y, z, coln);
}
}
}
dd->end();
// Draw boundary edges
const unsigned int colb = RGBA(0,48,64,220);
dd->begin(RC_DRAW_LINES, nvb, 2.5f);
for (int i = 0; i < mesh.npolys; ++i)
{
const unsigned short* p = &mesh.polys[i*nvp*2];
for (int j = 0; j < nvp; ++j)
{
if (p[j] == 0xffff) break;
if (p[nvp+j] != 0xffff) continue;
int vi[2];
vi[0] = p[j];
if (j+1 >= nvp || p[j+1] == 0xffff)
vi[1] = p[0];
else
vi[1] = p[j+1];
for (int k = 0; k < 2; ++k)
{
const unsigned short* v = &mesh.verts[vi[k]*3];
const float x = orig[0] + v[0]*cs;
const float y = orig[1] + (v[1]+1)*ch + 0.1f;
const float z = orig[2] + v[2]*cs;
dd->vertex(x, y, z, colb);
}
}
}
dd->end();
dd->begin(RC_DRAW_POINTS, mesh.nverts, 3.0f);
const unsigned int colv = RGBA(0,0,0,220);
for (int i = 0; i < mesh.nverts; ++i)
{
const unsigned short* v = &mesh.verts[i*3];
const float x = orig[0] + v[0]*cs;
const float y = orig[1] + (v[1]+1)*ch + 0.1f;
const float z = orig[2] + v[2]*cs;
dd->vertex(x,y,z, colv);
}
dd->end();
}
void rcDebugDrawPolyMeshDetail(rcDebugDraw* dd, const struct rcPolyMeshDetail& dmesh)
{
int nvt = 0;
int nvi = 0;
int nve = 0;
int nvv = 0;
for (int i = 0; i < dmesh.nmeshes; ++i)
{
const unsigned short* m = &dmesh.meshes[i*4];
const unsigned short nverts = m[1];
const unsigned short btris = m[2];
const unsigned short ntris = m[3];
const unsigned char* tris = &dmesh.tris[btris*4];
nvt += (int)ntris*3;
nvv += (int)nverts;
for (int j = 0; j < ntris; ++j)
{
const unsigned char* t = &tris[j*4];
for (int k = 0, kp = 2; k < 3; kp=k++)
{
unsigned char ef = (t[3] >> (kp*2)) & 0x3;
if (ef == 0)
{
if (t[kp] < t[k])
nvi += 2;
}
else
{
nve += 2;
}
}
}
}
dd->begin(RC_DRAW_TRIS, nvt);
for (int i = 0; i < dmesh.nmeshes; ++i)
{
const unsigned short* m = &dmesh.meshes[i*4];
const unsigned short bverts = m[0];
const unsigned short btris = m[2];
const unsigned short ntris = m[3];
const float* verts = &dmesh.verts[bverts*3];
const unsigned char* tris = &dmesh.tris[btris*4];
unsigned int color = intToCol(i, 192);
for (int j = 0; j < ntris; ++j)
{
dd->vertex(&verts[tris[j*4+0]*3], color);
dd->vertex(&verts[tris[j*4+1]*3], color);
dd->vertex(&verts[tris[j*4+2]*3], color);
}
}
dd->end();
// Internal edges.
dd->begin(RC_DRAW_LINES, nvi, 1.0f);
const unsigned int coli = RGBA(0,0,0,64);
for (int i = 0; i < dmesh.nmeshes; ++i)
{
const unsigned short* m = &dmesh.meshes[i*4];
const unsigned short bverts = m[0];
const unsigned short btris = m[2];
const unsigned short ntris = m[3];
const float* verts = &dmesh.verts[bverts*3];
const unsigned char* tris = &dmesh.tris[btris*4];
for (int j = 0; j < ntris; ++j)
{
const unsigned char* t = &tris[j*4];
for (int k = 0, kp = 2; k < 3; kp=k++)
{
unsigned char ef = (t[3] >> (kp*2)) & 0x3;
if (ef == 0)
{
// Internal edge
if (t[kp] < t[k])
{
dd->vertex(&verts[t[kp]*3], coli);
dd->vertex(&verts[t[k]*3], coli);
}
}
}
}
}
dd->end();
// External edges.
dd->begin(RC_DRAW_LINES, nve, 2.0f);
const unsigned int cole = RGBA(0,0,0,64);
for (int i = 0; i < dmesh.nmeshes; ++i)
{
const unsigned short* m = &dmesh.meshes[i*4];
const unsigned short bverts = m[0];
const unsigned short btris = m[2];
const unsigned short ntris = m[3];
const float* verts = &dmesh.verts[bverts*3];
const unsigned char* tris = &dmesh.tris[btris*4];
for (int j = 0; j < ntris; ++j)
{
const unsigned char* t = &tris[j*4];
for (int k = 0, kp = 2; k < 3; kp=k++)
{
unsigned char ef = (t[3] >> (kp*2)) & 0x3;
if (ef != 0)
{
// Ext edge
dd->vertex(&verts[t[kp]*3], cole);
dd->vertex(&verts[t[k]*3], cole);
}
}
}
}
dd->end();
dd->begin(RC_DRAW_POINTS, nvv, 3.0f);
const unsigned int colv = RGBA(0,0,0,64);
for (int i = 0; i < dmesh.nmeshes; ++i)
{
const unsigned short* m = &dmesh.meshes[i*4];
const unsigned short bverts = m[0];
const unsigned short nverts = m[1];
const float* verts = &dmesh.verts[bverts*3];
for (int j = 0; j < nverts; ++j)
dd->vertex(&verts[j*3], colv);
}
dd->end();
}

File diff suppressed because it is too large Load Diff

View File

@ -293,25 +293,26 @@
<array>
<string>29B97314FDCFA39411CA2CEA</string>
<string>080E96DDFE201D6D7F000001</string>
<string>6BDD9E030F91110C00904EEF</string>
<string>6BB93C7610CFE1BD00F74F2B</string>
<string>6B137C7D0F7FCBE800459200</string>
<string>6B555DF5100B25FC00247EA3</string>
<string>29B97315FDCFA39411CA2CEA</string>
<string>29B97317FDCFA39411CA2CEA</string>
<string>1C37FBAC04509CD000000102</string>
<string>1C37FABC05509CD000000102</string>
<string>1C77FABC04509CD000000102</string>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
<integer>4</integer>
<integer>3</integer>
<integer>31</integer>
<integer>26</integer>
<integer>1</integer>
<integer>0</integer>
</array>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
<string>{{0, 0}, {282, 660}}</string>
<string>{{0, 11}, {282, 660}}</string>
</dict>
<key>PBXTopSmartGroupGIDs</key>
<array/>
@ -346,7 +347,7 @@
<key>PBXProjectModuleGUID</key>
<string>6B8632A30F78115100E2684A</string>
<key>PBXProjectModuleLabel</key>
<string>DetourNavMesh.h</string>
<string>Sample_SoloMeshSimple.cpp</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
@ -354,11 +355,11 @@
<key>PBXProjectModuleGUID</key>
<string>6B8632A40F78115100E2684A</string>
<key>PBXProjectModuleLabel</key>
<string>DetourNavMesh.h</string>
<string>Sample_SoloMeshSimple.cpp</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>6BB4967910C8F55700BC0805</string>
<string>6BB93D1D10CFFD7600F74F2B</string>
<key>history</key>
<array>
<string>6B57D358108C66B200DDD053</string>
@ -366,44 +367,41 @@
<string>6B8DE70D10B01BBF00DF20FB</string>
<string>6B8DE76D10B0243500DF20FB</string>
<string>6B8DE7F110B0517A00DF20FB</string>
<string>6B8DE7F310B0517A00DF20FB</string>
<string>6B8DE84910B0584400DF20FB</string>
<string>6B8DE85210B6873400DF20FB</string>
<string>6B8DE89910B6B3F800DF20FB</string>
<string>6B8DE89A10B6B3F800DF20FB</string>
<string>6B8DE98B10B6C53B00DF20FB</string>
<string>6B8DE98E10B6C53B00DF20FB</string>
<string>6B8DEA3810B6CBC200DF20FB</string>
<string>6B8DEA6510B6CF6400DF20FB</string>
<string>6B8DEA8A10B6E1C900DF20FB</string>
<string>6B8DEAA110BC7BCD00DF20FB</string>
<string>6BF2589310BE6F220061DCC9</string>
<string>6BA1E63A10C1DB5B008007F6</string>
<string>6BA1E7F210C7B3FF008007F6</string>
<string>6BA1E81F10C7BB85008007F6</string>
<string>6BA1E82010C7BB85008007F6</string>
<string>6BA1E82610C7BB85008007F6</string>
<string>6BA1E89310C7C227008007F6</string>
<string>6BA1E8B010C7C5D1008007F6</string>
<string>6BA1E8DB10C7CB62008007F6</string>
<string>6BA1E8E410C7D2FA008007F6</string>
<string>6BA1E8F110C7D4D9008007F6</string>
<string>6BA1E8F210C7D4D9008007F6</string>
<string>6BB4964510C8ECF300BC0805</string>
<string>6BB4965E10C8F2AE00BC0805</string>
<string>6BB4965F10C8F2AE00BC0805</string>
<string>6BB4966010C8F2AE00BC0805</string>
<string>6BB4966110C8F2AE00BC0805</string>
<string>6BB4966210C8F2AE00BC0805</string>
<string>6BB4966310C8F2AE00BC0805</string>
<string>6BB4966410C8F2AE00BC0805</string>
<string>6BB4966510C8F2AE00BC0805</string>
<string>6BB4966610C8F2AE00BC0805</string>
<string>6BB4966710C8F2AE00BC0805</string>
<string>6BB4966810C8F2AE00BC0805</string>
<string>6BB4966910C8F2AE00BC0805</string>
<string>6BB4966A10C8F2AE00BC0805</string>
<string>6BB4966B10C8F2AE00BC0805</string>
<string>6BB4967C10C8F8F500BC0805</string>
<string>6BB93C8210CFE3B100F74F2B</string>
<string>6BB93CCF10CFEA7A00F74F2B</string>
<string>6BB93CD010CFEA7A00F74F2B</string>
<string>6BB93CD210CFEA7A00F74F2B</string>
<string>6BB93CD710CFEA7A00F74F2B</string>
<string>6BB93CD810CFEA7A00F74F2B</string>
<string>6BB93CE710CFEB5D00F74F2B</string>
<string>6BB93CEB10CFEB5D00F74F2B</string>
<string>6BB93D0510CFFC1300F74F2B</string>
<string>6BB93D0710CFFC1300F74F2B</string>
<string>6BB93D0810CFFC1300F74F2B</string>
<string>6BB93D0910CFFC1300F74F2B</string>
<string>6BB93D0A10CFFC1300F74F2B</string>
<string>6BB93D1510CFFC6D00F74F2B</string>
<string>6BB93D1B10CFFD7600F74F2B</string>
<string>6BB93D1C10CFFD7600F74F2B</string>
</array>
</dict>
<key>SplitCount</key>
@ -417,18 +415,18 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {976, 552}}</string>
<string>{{0, 0}, {976, 524}}</string>
<key>RubberWindowFrame</key>
<string>0 59 1280 719 0 0 1280 778 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
<string>552pt</string>
<string>524pt</string>
</dict>
<dict>
<key>Proportion</key>
<string>121pt</string>
<string>149pt</string>
<key>Tabs</key>
<array>
<dict>
@ -442,7 +440,7 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{10, 27}, {976, 81}}</string>
<string>{{10, 27}, {976, 220}}</string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
@ -458,7 +456,7 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {614, 336}}</string>
<string>{{10, 27}, {976, 220}}</string>
</dict>
<key>Module</key>
<string>PBXProjectFindModule</string>
@ -496,7 +494,7 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{10, 27}, {976, 94}}</string>
<string>{{10, 27}, {976, 122}}</string>
<key>RubberWindowFrame</key>
<string>0 59 1280 719 0 0 1280 778 </string>
</dict>
@ -526,11 +524,11 @@
</array>
<key>TableOfContents</key>
<array>
<string>6BB4966D10C8F2AE00BC0805</string>
<string>6BB93CDB10CFEA7A00F74F2B</string>
<string>1CA23ED40692098700951B8B</string>
<string>6BB4966E10C8F2AE00BC0805</string>
<string>6BB93CDC10CFEA7A00F74F2B</string>
<string>6B8632A30F78115100E2684A</string>
<string>6BB4966F10C8F2AE00BC0805</string>
<string>6BB93CDD10CFEA7A00F74F2B</string>
<string>1CA23EDF0692099D00951B8B</string>
<string>1CA23EE00692099D00951B8B</string>
<string>1CA23EE10692099D00951B8B</string>
@ -679,14 +677,14 @@
</array>
<key>TableOfContents</key>
<array>
<string>6BB4967010C8F2AE00BC0805</string>
<string>6BB93CDE10CFEA7A00F74F2B</string>
<string>1CCC7628064C1048000F2A68</string>
<string>1CCC7629064C1048000F2A68</string>
<string>6BB4967110C8F2AE00BC0805</string>
<string>6BB4967210C8F2AE00BC0805</string>
<string>6BB4967310C8F2AE00BC0805</string>
<string>6BB4967410C8F2AE00BC0805</string>
<string>6BB4967510C8F2AE00BC0805</string>
<string>6BB93CDF10CFEA7A00F74F2B</string>
<string>6BB93CE010CFEA7A00F74F2B</string>
<string>6BB93CE110CFEA7A00F74F2B</string>
<string>6BB93CE210CFEA7A00F74F2B</string>
<string>6BB93CE310CFEA7A00F74F2B</string>
</array>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
<string>2</string>
@ -703,7 +701,7 @@
<key>StatusbarIsVisible</key>
<true/>
<key>TimeStamp</key>
<real>281605463.64179099</real>
<real>282066294.76513201</real>
<key>ToolbarDisplayMode</key>
<integer>1</integer>
<key>ToolbarIsVisible</key>
@ -718,8 +716,8 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
<string>6BB4967610C8F2AE00BC0805</string>
<string>6BB4967710C8F2AE00BC0805</string>
<string>6BB93CE510CFEA7A00F74F2B</string>
<string>6BB93CE610CFEA7A00F74F2B</string>
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
</array>
<key>WindowString</key>

View File

@ -16,7 +16,6 @@
6B137C730F7FCBBB00459200 /* SDLMain.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B137C6E0F7FCBBB00459200 /* SDLMain.m */; };
6B137C8B0F7FCC1100459200 /* Recast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B137C820F7FCC1100459200 /* Recast.cpp */; };
6B137C8C0F7FCC1100459200 /* RecastContour.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B137C830F7FCC1100459200 /* RecastContour.cpp */; };
6B137C8D0F7FCC1100459200 /* RecastDebugDraw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B137C840F7FCC1100459200 /* RecastDebugDraw.cpp */; };
6B137C8E0F7FCC1100459200 /* RecastFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B137C850F7FCC1100459200 /* RecastFilter.cpp */; };
6B137C8F0F7FCC1100459200 /* RecastLog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B137C860F7FCC1100459200 /* RecastLog.cpp */; };
6B137C900F7FCC1100459200 /* RecastMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B137C870F7FCC1100459200 /* RecastMesh.cpp */; };
@ -36,7 +35,10 @@
6BA1E88B10C7BFC9008007F6 /* Sample_SoloMeshSimple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BA1E88810C7BFC9008007F6 /* Sample_SoloMeshSimple.cpp */; };
6BA1E88C10C7BFC9008007F6 /* Sample_SoloMeshTiled.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BA1E88910C7BFC9008007F6 /* Sample_SoloMeshTiled.cpp */; };
6BB788170FC0472B003C24DB /* ChunkyTriMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB788160FC0472B003C24DB /* ChunkyTriMesh.cpp */; };
6BDD9E0A0F91113800904EEF /* DetourDebugDraw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BDD9E070F91113800904EEF /* DetourDebugDraw.cpp */; };
6BB93C7D10CFE1D500F74F2B /* DebugDraw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB93C7A10CFE1D500F74F2B /* DebugDraw.cpp */; };
6BB93C7E10CFE1D500F74F2B /* DetourDebugDraw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB93C7B10CFE1D500F74F2B /* DetourDebugDraw.cpp */; };
6BB93C7F10CFE1D500F74F2B /* RecastDebugDraw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB93C7C10CFE1D500F74F2B /* RecastDebugDraw.cpp */; };
6BB93CF610CFEC4500F74F2B /* RecastDump.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB93CF510CFEC4500F74F2B /* RecastDump.cpp */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
/* End PBXBuildFile section */
@ -61,12 +63,10 @@
6B137C7B0F7FCBE400459200 /* MeshLoaderObj.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MeshLoaderObj.h; path = ../../Include/MeshLoaderObj.h; sourceTree = SOURCE_ROOT; };
6B137C7C0F7FCBE400459200 /* SDLMain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDLMain.h; path = ../../Include/SDLMain.h; sourceTree = SOURCE_ROOT; };
6B137C7E0F7FCBFE00459200 /* Recast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Recast.h; path = ../../../Recast/Include/Recast.h; sourceTree = SOURCE_ROOT; };
6B137C7F0F7FCBFE00459200 /* RecastDebugDraw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecastDebugDraw.h; path = ../../../Recast/Include/RecastDebugDraw.h; sourceTree = SOURCE_ROOT; };
6B137C800F7FCBFE00459200 /* RecastLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecastLog.h; path = ../../../Recast/Include/RecastLog.h; sourceTree = SOURCE_ROOT; };
6B137C810F7FCBFE00459200 /* RecastTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecastTimer.h; path = ../../../Recast/Include/RecastTimer.h; sourceTree = SOURCE_ROOT; };
6B137C820F7FCC1100459200 /* Recast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Recast.cpp; path = ../../../Recast/Source/Recast.cpp; sourceTree = SOURCE_ROOT; };
6B137C830F7FCC1100459200 /* RecastContour.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastContour.cpp; path = ../../../Recast/Source/RecastContour.cpp; sourceTree = SOURCE_ROOT; };
6B137C840F7FCC1100459200 /* RecastDebugDraw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastDebugDraw.cpp; path = ../../../Recast/Source/RecastDebugDraw.cpp; sourceTree = SOURCE_ROOT; };
6B137C850F7FCC1100459200 /* RecastFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastFilter.cpp; path = ../../../Recast/Source/RecastFilter.cpp; sourceTree = SOURCE_ROOT; };
6B137C860F7FCC1100459200 /* RecastLog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastLog.cpp; path = ../../../Recast/Source/RecastLog.cpp; sourceTree = SOURCE_ROOT; };
6B137C870F7FCC1100459200 /* RecastMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastMesh.cpp; path = ../../../Recast/Source/RecastMesh.cpp; sourceTree = SOURCE_ROOT; };
@ -96,8 +96,14 @@
6BA1E88F10C7BFD3008007F6 /* Sample_SoloMeshTiled.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sample_SoloMeshTiled.h; path = ../../Include/Sample_SoloMeshTiled.h; sourceTree = SOURCE_ROOT; };
6BB788160FC0472B003C24DB /* ChunkyTriMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChunkyTriMesh.cpp; path = ../../Source/ChunkyTriMesh.cpp; sourceTree = SOURCE_ROOT; };
6BB788180FC04753003C24DB /* ChunkyTriMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChunkyTriMesh.h; path = ../../Include/ChunkyTriMesh.h; sourceTree = SOURCE_ROOT; };
6BDD9E040F91112200904EEF /* DetourDebugDraw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DetourDebugDraw.h; path = ../../../Detour/Include/DetourDebugDraw.h; sourceTree = SOURCE_ROOT; };
6BDD9E070F91113800904EEF /* DetourDebugDraw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DetourDebugDraw.cpp; path = ../../../Detour/Source/DetourDebugDraw.cpp; sourceTree = SOURCE_ROOT; };
6BB93C7710CFE1D500F74F2B /* DebugDraw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DebugDraw.h; path = ../../../DebugUtils/Include/DebugDraw.h; sourceTree = SOURCE_ROOT; };
6BB93C7810CFE1D500F74F2B /* DetourDebugDraw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DetourDebugDraw.h; path = ../../../DebugUtils/Include/DetourDebugDraw.h; sourceTree = SOURCE_ROOT; };
6BB93C7910CFE1D500F74F2B /* RecastDebugDraw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecastDebugDraw.h; path = ../../../DebugUtils/Include/RecastDebugDraw.h; sourceTree = SOURCE_ROOT; };
6BB93C7A10CFE1D500F74F2B /* DebugDraw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DebugDraw.cpp; path = ../../../DebugUtils/Source/DebugDraw.cpp; sourceTree = SOURCE_ROOT; };
6BB93C7B10CFE1D500F74F2B /* DetourDebugDraw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DetourDebugDraw.cpp; path = ../../../DebugUtils/Source/DetourDebugDraw.cpp; sourceTree = SOURCE_ROOT; };
6BB93C7C10CFE1D500F74F2B /* RecastDebugDraw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastDebugDraw.cpp; path = ../../../DebugUtils/Source/RecastDebugDraw.cpp; sourceTree = SOURCE_ROOT; };
6BB93CF410CFEC4500F74F2B /* RecastDump.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecastDump.h; path = ../../../DebugUtils/Include/RecastDump.h; sourceTree = SOURCE_ROOT; };
6BB93CF510CFEC4500F74F2B /* RecastDump.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastDump.cpp; path = ../../../DebugUtils/Source/RecastDump.cpp; sourceTree = SOURCE_ROOT; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* Recast.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Recast.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@ -120,6 +126,7 @@
isa = PBXGroup;
children = (
6B555DF6100B273500247EA3 /* stb_truetype.h */,
6BB93C7610CFE1BD00F74F2B /* DebugUtils */,
6BDD9E030F91110C00904EEF /* Detour */,
6B137C7D0F7FCBE800459200 /* Recast */,
6B555DF5100B25FC00247EA3 /* Samples */,
@ -211,7 +218,6 @@
children = (
6B137C820F7FCC1100459200 /* Recast.cpp */,
6B137C830F7FCC1100459200 /* RecastContour.cpp */,
6B137C840F7FCC1100459200 /* RecastDebugDraw.cpp */,
6B137C850F7FCC1100459200 /* RecastFilter.cpp */,
6B137C860F7FCC1100459200 /* RecastLog.cpp */,
6B137C870F7FCC1100459200 /* RecastMesh.cpp */,
@ -219,7 +225,6 @@
6B137C890F7FCC1100459200 /* RecastRegion.cpp */,
6B137C8A0F7FCC1100459200 /* RecastTimer.cpp */,
6B137C7E0F7FCBFE00459200 /* Recast.h */,
6B137C7F0F7FCBFE00459200 /* RecastDebugDraw.h */,
6B137C800F7FCBFE00459200 /* RecastLog.h */,
6B137C810F7FCBFE00459200 /* RecastTimer.h */,
6B624169103434880002E346 /* RecastMeshDetail.cpp */,
@ -244,6 +249,21 @@
name = Samples;
sourceTree = "<group>";
};
6BB93C7610CFE1BD00F74F2B /* DebugUtils */ = {
isa = PBXGroup;
children = (
6BB93CF410CFEC4500F74F2B /* RecastDump.h */,
6BB93CF510CFEC4500F74F2B /* RecastDump.cpp */,
6BB93C7710CFE1D500F74F2B /* DebugDraw.h */,
6BB93C7A10CFE1D500F74F2B /* DebugDraw.cpp */,
6BB93C7910CFE1D500F74F2B /* RecastDebugDraw.h */,
6BB93C7C10CFE1D500F74F2B /* RecastDebugDraw.cpp */,
6BB93C7810CFE1D500F74F2B /* DetourDebugDraw.h */,
6BB93C7B10CFE1D500F74F2B /* DetourDebugDraw.cpp */,
);
name = DebugUtils;
sourceTree = "<group>";
};
6BDD9E030F91110C00904EEF /* Detour */ = {
isa = PBXGroup;
children = (
@ -251,8 +271,6 @@
6B8DE88710B69E3E00DF20FB /* DetourNavMesh.cpp */,
6B8DE88C10B69E4C00DF20FB /* DetourNavMeshBuilder.h */,
6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */,
6BDD9E040F91112200904EEF /* DetourDebugDraw.h */,
6BDD9E070F91113800904EEF /* DetourDebugDraw.cpp */,
6B1185F61006896B0018F96F /* DetourNode.h */,
6B1185F41006895B0018F96F /* DetourNode.cpp */,
6B1185FC10068B040018F96F /* DetourCommon.h */,
@ -322,14 +340,12 @@
6B137C730F7FCBBB00459200 /* SDLMain.m in Sources */,
6B137C8B0F7FCC1100459200 /* Recast.cpp in Sources */,
6B137C8C0F7FCC1100459200 /* RecastContour.cpp in Sources */,
6B137C8D0F7FCC1100459200 /* RecastDebugDraw.cpp in Sources */,
6B137C8E0F7FCC1100459200 /* RecastFilter.cpp in Sources */,
6B137C8F0F7FCC1100459200 /* RecastLog.cpp in Sources */,
6B137C900F7FCC1100459200 /* RecastMesh.cpp in Sources */,
6B137C910F7FCC1100459200 /* RecastRasterization.cpp in Sources */,
6B137C920F7FCC1100459200 /* RecastRegion.cpp in Sources */,
6B137C930F7FCC1100459200 /* RecastTimer.cpp in Sources */,
6BDD9E0A0F91113800904EEF /* DetourDebugDraw.cpp in Sources */,
6BB788170FC0472B003C24DB /* ChunkyTriMesh.cpp in Sources */,
6B25B6190FFA62BE004F1BC4 /* Sample.cpp in Sources */,
6B25B61D0FFA62BE004F1BC4 /* main.cpp in Sources */,
@ -343,6 +359,10 @@
6BA1E88A10C7BFC9008007F6 /* Sample_SoloMesh.cpp in Sources */,
6BA1E88B10C7BFC9008007F6 /* Sample_SoloMeshSimple.cpp in Sources */,
6BA1E88C10C7BFC9008007F6 /* Sample_SoloMeshTiled.cpp in Sources */,
6BB93C7D10CFE1D500F74F2B /* DebugDraw.cpp in Sources */,
6BB93C7E10CFE1D500F74F2B /* DetourDebugDraw.cpp in Sources */,
6BB93C7F10CFE1D500F74F2B /* RecastDebugDraw.cpp in Sources */,
6BB93CF610CFEC4500F74F2B /* RecastDump.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -1,11 +1,11 @@
#ifndef RECASTSAMPLE_H
#define RECASTSAMPLE_H
#include "RecastDebugDraw.h"
#include "DebugDraw.h"
struct DebugDrawGL : public rcDebugDraw
struct DebugDrawGL : public duDebugDraw
{
virtual void begin(rcDebugDrawPrimitives prim, int nverts, float size = 1.0f);
virtual void begin(duDebugDrawPrimitives prim, float size = 1.0f);
virtual void vertex(const float* pos, unsigned int color);
virtual void vertex(const float x, const float y, const float z, unsigned int color);
virtual void end();

View File

@ -13,22 +13,22 @@
#endif
void DebugDrawGL::begin(rcDebugDrawPrimitives prim, int nverts, float size)
void DebugDrawGL::begin(duDebugDrawPrimitives prim, float size)
{
switch (prim)
{
case RC_DRAW_POINTS:
case DU_DRAW_POINTS:
glPointSize(size);
glBegin(GL_POINTS);
break;
case RC_DRAW_LINES:
case DU_DRAW_LINES:
glLineWidth(size);
glBegin(GL_LINES);
break;
case RC_DRAW_TRIS:
case DU_DRAW_TRIS:
glBegin(GL_TRIANGLES);
break;
case RC_DRAW_QUADS:
case DU_DRAW_QUADS:
glBegin(GL_QUADS);
break;
};
@ -84,10 +84,10 @@ void Sample::handleRender()
DebugDrawGL dd;
// Draw mesh
rcDebugDrawMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
duDebugDrawTriMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
// Draw bounds
float col[4] = {1,1,1,0.5f};
rcDebugDrawBoxWire(&dd, m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
duDebugDrawBoxWire(&dd, m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
}
void Sample::handleRenderOverlay(double* proj, double* model, int* view)

View File

@ -291,22 +291,22 @@ void Sample_SoloMesh::toolRender(int flags)
glDepthMask(GL_FALSE);
if (flags & NAVMESH_POLYS)
dtDebugDrawNavMesh(m_navMesh, m_toolMode == TOOLMODE_PATHFIND);
duDebugDrawNavMesh(&dd, m_navMesh, m_toolMode == TOOLMODE_PATHFIND);
if (flags & NAVMESH_BVTREE)
dtDebugDrawNavMeshBVTree(m_navMesh);
duDebugDrawNavMeshBVTree(&dd, m_navMesh);
if (flags & NAVMESH_TOOLS)
{
if (m_toolMode == TOOLMODE_PATHFIND)
{
dtDebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol);
dtDebugDrawNavMeshPoly(m_navMesh, m_endRef, endCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_endRef, endCol);
if (m_npolys)
{
for (int i = 1; i < m_npolys-1; ++i)
dtDebugDrawNavMeshPoly(m_navMesh, m_polys[i], pathCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
}
if (m_nstraightPath)
{
@ -338,12 +338,12 @@ void Sample_SoloMesh::toolRender(int flags)
}
else if (m_toolMode == TOOLMODE_RAYCAST)
{
dtDebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
if (m_nstraightPath)
{
for (int i = 1; i < m_npolys; ++i)
dtDebugDrawNavMeshPoly(m_navMesh, m_polys[i], pathCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
glColor4ub(64,16,0,220);
glLineWidth(3.0f);
@ -362,9 +362,9 @@ void Sample_SoloMesh::toolRender(int flags)
}
else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL)
{
dtDebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
const float col[4] = {1,1,1,0.5f};
rcDebugDrawCylinderWire(&dd, m_spos[0]-m_distanceToWall, m_spos[1]+0.02f, m_spos[2]-m_distanceToWall,
duDebugDrawCylinderWire(&dd, m_spos[0]-m_distanceToWall, m_spos[1]+0.02f, m_spos[2]-m_distanceToWall,
m_spos[0]+m_distanceToWall, m_spos[1]+m_agentHeight, m_spos[2]+m_distanceToWall, col);
glLineWidth(3.0f);
glColor4fv(col);
@ -379,13 +379,13 @@ void Sample_SoloMesh::toolRender(int flags)
const float cola[4] = {0,0,0,0.5f};
for (int i = 0; i < m_npolys; ++i)
{
dtDebugDrawNavMeshPoly(m_navMesh, m_polys[i], pathCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
if (m_parent[i])
{
float p0[3], p1[3];
getPolyCenter(m_navMesh, m_polys[i], p0);
getPolyCenter(m_navMesh, m_parent[i], p1);
rcDrawArc(&dd, p0, p1, cola, 2.0f);
duDebugDrawArc(&dd, p0, p1, cola, 2.0f);
}
}
@ -393,7 +393,7 @@ void Sample_SoloMesh::toolRender(int flags)
const float dz = m_epos[2] - m_spos[2];
float dist = sqrtf(dx*dx + dz*dz);
const float col[4] = {1,1,1,0.5f};
rcDebugDrawCylinderWire(&dd, m_spos[0]-dist, m_spos[1]+0.02f, m_spos[2]-dist,
duDebugDrawCylinderWire(&dd, m_spos[0]-dist, m_spos[1]+0.02f, m_spos[2]-dist,
m_spos[0]+dist, m_spos[1]+m_agentHeight, m_spos[2]+dist, col);
}
}
@ -426,7 +426,7 @@ void Sample_SoloMesh::drawAgent(const float* pos, float r, float h, float c, con
// Agent dimensions.
glLineWidth(2.0f);
rcDebugDrawCylinderWire(&dd, pos[0]-r, pos[1]+0.02f, pos[2]-r, pos[0]+r, pos[1]+h, pos[2]+r, col);
duDebugDrawCylinderWire(&dd, pos[0]-r, pos[1]+0.02f, pos[2]-r, pos[0]+r, pos[1]+h, pos[2]+r, col);
glLineWidth(1.0f);
glColor4ub(0,0,0,196);

View File

@ -10,6 +10,7 @@
#include "Recast.h"
#include "RecastTimer.h"
#include "RecastDebugDraw.h"
#include "RecastDump.h"
#include "DetourNavMesh.h"
#include "DetourNavMeshBuilder.h"
#include "DetourDebugDraw.h"
@ -153,12 +154,12 @@ void Sample_SoloMeshSimple::handleRender()
if (m_drawMode == DRAWMODE_MESH)
{
// Draw mesh
rcDebugDrawMeshSlope(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
duDebugDrawTriMeshSlope(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
}
else if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
{
// Draw mesh
rcDebugDrawMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
duDebugDrawTriMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
}
glDisable(GL_FOG);
@ -166,7 +167,7 @@ void Sample_SoloMeshSimple::handleRender()
// Draw bounds
col[0] = 1; col[1] = 1; col[2] = 1; col[3] = 0.5f;
rcDebugDrawBoxWire(&dd, m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
duDebugDrawBoxWire(&dd, m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
if (m_navMesh &&
(m_drawMode == DRAWMODE_NAVMESH ||
@ -185,61 +186,61 @@ void Sample_SoloMeshSimple::handleRender()
glDepthMask(GL_TRUE);
if (m_chf && m_drawMode == DRAWMODE_COMPACT)
rcDebugDrawCompactHeightfieldSolid(&dd, *m_chf);
duDebugDrawCompactHeightfieldSolid(&dd, *m_chf);
if (m_chf && m_drawMode == DRAWMODE_COMPACT_DISTANCE)
rcDebugDrawCompactHeightfieldDistance(&dd, *m_chf);
duDebugDrawCompactHeightfieldDistance(&dd, *m_chf);
if (m_chf && m_drawMode == DRAWMODE_COMPACT_REGIONS)
rcDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
if (m_solid && m_drawMode == DRAWMODE_VOXELS)
{
glEnable(GL_FOG);
rcDebugDrawHeightfieldSolid(&dd, *m_solid);
duDebugDrawHeightfieldSolid(&dd, *m_solid);
glDisable(GL_FOG);
}
if (m_solid && m_drawMode == DRAWMODE_VOXELS_WALKABLE)
{
glEnable(GL_FOG);
rcDebugDrawHeightfieldWalkable(&dd, *m_solid);
duDebugDrawHeightfieldWalkable(&dd, *m_solid);
glDisable(GL_FOG);
}
if (m_cset && m_drawMode == DRAWMODE_RAW_CONTOURS)
{
glDepthMask(GL_FALSE);
rcDebugDrawRawContours(&dd, *m_cset);
duDebugDrawRawContours(&dd, *m_cset);
glDepthMask(GL_TRUE);
}
if (m_cset && m_drawMode == DRAWMODE_BOTH_CONTOURS)
{
glDepthMask(GL_FALSE);
rcDebugDrawRawContours(&dd, *m_cset, 0.5f);
rcDebugDrawContours(&dd, *m_cset);
duDebugDrawRawContours(&dd, *m_cset, 0.5f);
duDebugDrawContours(&dd, *m_cset);
glDepthMask(GL_TRUE);
}
if (m_cset && m_drawMode == DRAWMODE_CONTOURS)
{
glDepthMask(GL_FALSE);
rcDebugDrawContours(&dd, *m_cset);
duDebugDrawContours(&dd, *m_cset);
glDepthMask(GL_TRUE);
}
if (m_chf && m_cset && m_drawMode == DRAWMODE_REGION_CONNECTIONS)
{
rcDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
glDepthMask(GL_FALSE);
rcDebugDrawRegionConnections(&dd, *m_cset);
duDebugDrawRegionConnections(&dd, *m_cset);
glDepthMask(GL_TRUE);
}
if (m_pmesh && m_drawMode == DRAWMODE_POLYMESH)
{
glDepthMask(GL_FALSE);
rcDebugDrawPolyMesh(&dd, *m_pmesh);
duDebugDrawPolyMesh(&dd, *m_pmesh);
glDepthMask(GL_TRUE);
}
if (m_dmesh && m_drawMode == DRAWMODE_POLYMESH_DETAIL)
{
glDepthMask(GL_FALSE);
rcDebugDrawPolyMeshDetail(&dd, *m_dmesh);
duDebugDrawPolyMeshDetail(&dd, *m_dmesh);
glDepthMask(GL_TRUE);
}
@ -480,7 +481,7 @@ bool Sample_SoloMeshSimple::handleBuild()
}
// At this point the navigation mesh data is ready, you can access it from m_pmesh.
// See rcDebugDrawPolyMesh or dtCreateNavMeshData as examples how to access the data.
// See duDebugDrawPolyMesh or dtCreateNavMeshData as examples how to access the data.
//
// (Optional) Step 8. Create Detour data from Recast poly mesh.

View File

@ -186,12 +186,12 @@ void Sample_SoloMeshTiled::handleRender()
if (m_drawMode == DRAWMODE_MESH)
{
// Draw mesh
rcDebugDrawMeshSlope(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
duDebugDrawTriMeshSlope(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
}
else if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
{
// Draw mesh
rcDebugDrawMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
duDebugDrawTriMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
}
glDisable(GL_FOG);
@ -199,7 +199,7 @@ void Sample_SoloMeshTiled::handleRender()
// Draw bounds
col[0] = 1; col[1] = 1; col[2] = 1; col[3] = 0.5f;
rcDebugDrawBoxWire(&dd, m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
duDebugDrawBoxWire(&dd, m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
// Tiling grid.
const int ts = (int)m_tileSize;
@ -262,7 +262,7 @@ void Sample_SoloMeshTiled::handleRender()
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
{
if (m_tileSet->tiles[i].chf)
rcDebugDrawCompactHeightfieldSolid(&dd, *m_tileSet->tiles[i].chf);
duDebugDrawCompactHeightfieldSolid(&dd, *m_tileSet->tiles[i].chf);
}
}
@ -271,7 +271,7 @@ void Sample_SoloMeshTiled::handleRender()
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
{
if (m_tileSet->tiles[i].chf)
rcDebugDrawCompactHeightfieldDistance(&dd, *m_tileSet->tiles[i].chf);
duDebugDrawCompactHeightfieldDistance(&dd, *m_tileSet->tiles[i].chf);
}
}
if (m_drawMode == DRAWMODE_COMPACT_REGIONS)
@ -279,7 +279,7 @@ void Sample_SoloMeshTiled::handleRender()
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
{
if (m_tileSet->tiles[i].chf)
rcDebugDrawCompactHeightfieldRegions(&dd, *m_tileSet->tiles[i].chf);
duDebugDrawCompactHeightfieldRegions(&dd, *m_tileSet->tiles[i].chf);
}
}
@ -289,7 +289,7 @@ void Sample_SoloMeshTiled::handleRender()
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
{
if (m_tileSet->tiles[i].solid)
rcDebugDrawHeightfieldSolid(&dd, *m_tileSet->tiles[i].solid);
duDebugDrawHeightfieldSolid(&dd, *m_tileSet->tiles[i].solid);
}
glDisable(GL_FOG);
}
@ -299,7 +299,7 @@ void Sample_SoloMeshTiled::handleRender()
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
{
if (m_tileSet->tiles[i].solid)
rcDebugDrawHeightfieldWalkable(&dd, *m_tileSet->tiles[i].solid);
duDebugDrawHeightfieldWalkable(&dd, *m_tileSet->tiles[i].solid);
}
glDisable(GL_FOG);
}
@ -309,7 +309,7 @@ void Sample_SoloMeshTiled::handleRender()
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
{
if (m_tileSet->tiles[i].cset)
rcDebugDrawRawContours(&dd, *m_tileSet->tiles[i].cset);
duDebugDrawRawContours(&dd, *m_tileSet->tiles[i].cset);
}
glDepthMask(GL_TRUE);
}
@ -320,8 +320,8 @@ void Sample_SoloMeshTiled::handleRender()
{
if (m_tileSet->tiles[i].cset)
{
rcDebugDrawRawContours(&dd, *m_tileSet->tiles[i].cset, 0.5f);
rcDebugDrawContours(&dd, *m_tileSet->tiles[i].cset);
duDebugDrawRawContours(&dd, *m_tileSet->tiles[i].cset, 0.5f);
duDebugDrawContours(&dd, *m_tileSet->tiles[i].cset);
}
}
glDepthMask(GL_TRUE);
@ -332,7 +332,7 @@ void Sample_SoloMeshTiled::handleRender()
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
{
if (m_tileSet->tiles[i].cset)
rcDebugDrawContours(&dd, *m_tileSet->tiles[i].cset);
duDebugDrawContours(&dd, *m_tileSet->tiles[i].cset);
}
glDepthMask(GL_TRUE);
}
@ -341,14 +341,14 @@ void Sample_SoloMeshTiled::handleRender()
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
{
if (m_tileSet->tiles[i].chf)
rcDebugDrawCompactHeightfieldRegions(&dd, *m_tileSet->tiles[i].chf);
duDebugDrawCompactHeightfieldRegions(&dd, *m_tileSet->tiles[i].chf);
}
glDepthMask(GL_FALSE);
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
{
if (m_tileSet->tiles[i].cset)
rcDebugDrawRegionConnections(&dd, *m_tileSet->tiles[i].cset);
duDebugDrawRegionConnections(&dd, *m_tileSet->tiles[i].cset);
}
glDepthMask(GL_TRUE);
}
@ -357,14 +357,14 @@ void Sample_SoloMeshTiled::handleRender()
glDepthMask(GL_FALSE);
if (m_pmesh)
{
rcDebugDrawPolyMesh(&dd, *m_pmesh);
duDebugDrawPolyMesh(&dd, *m_pmesh);
}
else
{
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
{
if (m_tileSet->tiles[i].pmesh)
rcDebugDrawPolyMesh(&dd, *m_tileSet->tiles[i].pmesh);
duDebugDrawPolyMesh(&dd, *m_tileSet->tiles[i].pmesh);
}
}
@ -375,14 +375,14 @@ void Sample_SoloMeshTiled::handleRender()
glDepthMask(GL_FALSE);
if (m_dmesh)
{
rcDebugDrawPolyMeshDetail(&dd, *m_dmesh);
duDebugDrawPolyMeshDetail(&dd, *m_dmesh);
}
else
{
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
{
if (m_tileSet->tiles[i].dmesh)
rcDebugDrawPolyMeshDetail(&dd, *m_tileSet->tiles[i].dmesh);
duDebugDrawPolyMeshDetail(&dd, *m_tileSet->tiles[i].dmesh);
}
}
glDepthMask(GL_TRUE);

View File

@ -334,15 +334,15 @@ void Sample_TileMesh::handleRender()
// Draw mesh
if (m_navMesh)
rcDebugDrawMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
duDebugDrawTriMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
else
rcDebugDrawMeshSlope(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
duDebugDrawTriMeshSlope(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
glDepthMask(GL_FALSE);
// Draw bounds
float col[4] = {1,1,1,0.5f};
rcDebugDrawBoxWire(&dd, m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
duDebugDrawBoxWire(&dd, m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
// Tiling grid.
const int ts = (int)m_tileSize;
@ -382,10 +382,10 @@ void Sample_TileMesh::handleRender()
glEnd();
// Draw active tile
rcDebugDrawBoxWire(&dd, m_tileBmin[0],m_tileBmin[1],m_tileBmin[2], m_tileBmax[0],m_tileBmax[1],m_tileBmax[2], m_tileCol);
duDebugDrawBoxWire(&dd, m_tileBmin[0],m_tileBmin[1],m_tileBmin[2], m_tileBmax[0],m_tileBmax[1],m_tileBmax[2], m_tileCol);
if (m_navMesh)
dtDebugDrawNavMesh(m_navMesh);
duDebugDrawNavMesh(&dd, m_navMesh);
if (m_sposSet)
{
@ -424,13 +424,13 @@ void Sample_TileMesh::handleRender()
if (m_toolMode == TOOLMODE_PATHFIND)
{
dtDebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol);
dtDebugDrawNavMeshPoly(m_navMesh, m_endRef, endCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_endRef, endCol);
if (m_npolys)
{
for (int i = 1; i < m_npolys-1; ++i)
dtDebugDrawNavMeshPoly(m_navMesh, m_polys[i], pathCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
}
if (m_nstraightPath)
{
@ -451,12 +451,12 @@ void Sample_TileMesh::handleRender()
}
else if (m_toolMode == TOOLMODE_RAYCAST)
{
dtDebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
if (m_nstraightPath)
{
for (int i = 1; i < m_npolys; ++i)
dtDebugDrawNavMeshPoly(m_navMesh, m_polys[i], pathCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
glColor4ub(64,16,0,220);
glLineWidth(3.0f);
@ -475,9 +475,9 @@ void Sample_TileMesh::handleRender()
}
else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL)
{
dtDebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
const float col[4] = {1,1,1,0.5f};
rcDebugDrawCylinderWire(&dd, m_spos[0]-m_distanceToWall, m_spos[1]+0.02f, m_spos[2]-m_distanceToWall,
duDebugDrawCylinderWire(&dd, m_spos[0]-m_distanceToWall, m_spos[1]+0.02f, m_spos[2]-m_distanceToWall,
m_spos[0]+m_distanceToWall, m_spos[1]+m_agentHeight, m_spos[2]+m_distanceToWall, col);
glLineWidth(3.0f);
glColor4fv(col);
@ -492,14 +492,14 @@ void Sample_TileMesh::handleRender()
const float cola[4] = {0,0,0,0.5f};
for (int i = 0; i < m_npolys; ++i)
{
dtDebugDrawNavMeshPoly(m_navMesh, m_polys[i], pathCol);
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
if (m_parent[i])
{
float p0[3], p1[3];
getPolyCenter(m_navMesh, m_polys[i], p0);
getPolyCenter(m_navMesh, m_parent[i], p1);
glColor4ub(0,0,0,128);
rcDrawArc(&dd, p0, p1, cola, 2.0f);
duDebugDrawArc(&dd, p0, p1, cola, 2.0f);
}
}
@ -507,7 +507,7 @@ void Sample_TileMesh::handleRender()
const float dz = m_epos[2] - m_spos[2];
float dist = sqrtf(dx*dx + dz*dz);
const float col[4] = {1,1,1,0.5f};
rcDebugDrawCylinderWire(&dd, m_spos[0]-dist, m_spos[1]+0.02f, m_spos[2]-dist,
duDebugDrawCylinderWire(&dd, m_spos[0]-dist, m_spos[1]+0.02f, m_spos[2]-dist,
m_spos[0]+dist, m_spos[1]+m_agentHeight, m_spos[2]+dist, col);
}