Removed rcMarkReachableSpans(), added RC_LEDGE flag, made rcFilterLedgeSpans() to add RC_LEDGE flags instead of removing RC_WALKABLE flag. Voxel debugdraw colors voxels based on flags. Added debug draw interface.
This commit is contained in:
parent
14d1c97f1a
commit
480063229d
@ -231,7 +231,7 @@ public:
|
||||
enum rcSpanFlags
|
||||
{
|
||||
RC_WALKABLE = 0x01,
|
||||
RC_REACHABLE = 0x02,
|
||||
RC_LEDGE = 0x02,
|
||||
};
|
||||
|
||||
// If heightfield region ID has the following bit set, the region is on border area
|
||||
@ -466,16 +466,6 @@ void rcFilterLedgeSpans(const int walkableHeight,
|
||||
void rcFilterWalkableLowHeightSpans(int walkableHeight,
|
||||
rcHeightfield& solid);
|
||||
|
||||
// Marks spans which are reachable from any of the topmost spans.
|
||||
// Params:
|
||||
// walkableHeight - (in) minimum height where the agent can still walk
|
||||
// walkableClimb - (in) maximum height between grid cells the agent can climb
|
||||
// solid - (in/out) heightfield describing the solid space
|
||||
// Returns false if operation ran out of memory.
|
||||
bool rcMarkReachableSpans(const int walkableHeight,
|
||||
const int walkableClimb,
|
||||
rcHeightfield& solid);
|
||||
|
||||
// Builds compact representation of the heightfield.
|
||||
// Params:
|
||||
// walkableHeight - (in) minimum height where the agent can still walk
|
||||
|
@ -19,11 +19,49 @@
|
||||
#ifndef RECAST_DEBUGDRAW_H
|
||||
#define RECAST_DEBUGDRAW_H
|
||||
|
||||
enum rcDebugDrawPrimitives
|
||||
{
|
||||
RC_DRAW_POINTS,
|
||||
RC_DRAW_LINES,
|
||||
RC_DRAW_TRIS,
|
||||
RC_DRAW_QUADS,
|
||||
};
|
||||
|
||||
struct rcDebugDraw
|
||||
{
|
||||
virtual void begin(rcDebugDrawPrimitives prim, int nverts, float size = 1.0f) = 0;
|
||||
virtual void vertex(const float* pos, unsigned int color) = 0;
|
||||
virtual void vertex(const float x, const float y, const float z, unsigned int color) = 0;
|
||||
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;
|
||||
@ -34,26 +72,28 @@ inline void intToCol(int i, float* col)
|
||||
col[2] = 1 - b*63.0f/255.0f;
|
||||
}
|
||||
|
||||
void rcDebugDrawHeightfieldSolid(const struct rcHeightfield& hf);
|
||||
void rcDebugDrawHeightfieldWalkable(const struct rcHeightfield& hf);
|
||||
void rcDebugDrawHeightfieldSolid(rcDebugDraw* dd, const struct rcHeightfield& hf);
|
||||
void rcDebugDrawHeightfieldWalkable(rcDebugDraw* dd, const struct rcHeightfield& hf);
|
||||
|
||||
void rcDebugDrawMesh(const float* verts, int nverts, const int* tris, const float* normals, int ntris, const unsigned char* flags);
|
||||
void rcDebugDrawMeshSlope(const float* verts, int nverts, const int* tris, const float* normals, int ntris, const float walkableSlopeAngle);
|
||||
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(const struct rcCompactHeightfield& chf);
|
||||
void rcDebugDrawCompactHeightfieldRegions(const struct rcCompactHeightfield& chf);
|
||||
void rcDebugDrawCompactHeightfieldDistance(const struct rcCompactHeightfield& chf);
|
||||
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(const struct rcContourSet& cset, const float alpha = 1.0f);
|
||||
void rcDebugDrawRawContours(const struct rcContourSet& cset, const float alpha = 1.0f);
|
||||
void rcDebugDrawContours(const struct rcContourSet& cset, const float alpha = 1.0f);
|
||||
void rcDebugDrawPolyMesh(const struct rcPolyMesh& mesh);
|
||||
void rcDebugDrawPolyMeshDetail(const struct rcPolyMeshDetail& dmesh);
|
||||
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(float minx, float miny, float minz, float maxx, float maxy, float maxz, const float* col);
|
||||
void rcDebugDrawBoxWire(float minx, float miny, float minz, float maxx, float maxy, float maxz, const float* col);
|
||||
void rcDebugDrawBox(float minx, float miny, float minz, float maxx, float maxy, float maxz,
|
||||
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(const float* p0, const float* p1);
|
||||
void rcDrawArc(rcDebugDraw* dd, const float* p0, const float* p1, const float* col, float lineWidth);
|
||||
|
||||
#endif // RECAST_DEBUGDRAW_H
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -84,8 +84,7 @@ void rcFilterLedgeSpans(const int walkableHeight,
|
||||
// The current span is close to a ledge if the drop to any
|
||||
// neighbour span is less than the walkableClimb.
|
||||
if (minh < -walkableClimb)
|
||||
s->flags &= ~RC_WALKABLE;
|
||||
|
||||
s->flags |= RC_LEDGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,121 +128,3 @@ void rcFilterWalkableLowHeightSpans(int walkableHeight,
|
||||
if (rcGetBuildTimes())
|
||||
rcGetBuildTimes()->filterWalkable += rcGetDeltaTimeUsec(startTime, endTime);
|
||||
}
|
||||
|
||||
|
||||
struct rcReachableSeed
|
||||
{
|
||||
inline void set(int ix, int iy, rcSpan* is)
|
||||
{
|
||||
x = (unsigned short)ix;
|
||||
y = (unsigned short)iy;
|
||||
s = is;
|
||||
}
|
||||
unsigned short x, y;
|
||||
rcSpan* s;
|
||||
};
|
||||
|
||||
bool rcMarkReachableSpans(const int walkableHeight,
|
||||
const int walkableClimb,
|
||||
rcHeightfield& solid)
|
||||
{
|
||||
const int w = solid.width;
|
||||
const int h = solid.height;
|
||||
const int MAX_HEIGHT = 0xffff;
|
||||
|
||||
rcTimeVal startTime = rcGetPerformanceTimer();
|
||||
|
||||
// Build navigable space.
|
||||
const int MAX_SEEDS = w*h;
|
||||
rcReachableSeed* stack = new rcReachableSeed[MAX_SEEDS];
|
||||
if (!stack)
|
||||
{
|
||||
if (rcGetLog())
|
||||
rcGetLog()->log(RC_LOG_ERROR, "rcMarkReachableSpans: Out of memory 'stack' (%d).", MAX_SEEDS);
|
||||
return false;
|
||||
}
|
||||
int stackSize = 0;
|
||||
|
||||
for (int y = 0; y < h; ++y)
|
||||
{
|
||||
for (int x = 0; x < w; ++x)
|
||||
{
|
||||
rcSpan* topSpan = solid.spans[x + y*w];
|
||||
if (!topSpan)
|
||||
continue;
|
||||
while (topSpan->next)
|
||||
topSpan = topSpan->next;
|
||||
|
||||
// If the span is not walkable, skip it.
|
||||
if ((topSpan->flags & RC_WALKABLE) == 0)
|
||||
continue;
|
||||
// If the span has been visited already, skip it.
|
||||
if (topSpan->flags & RC_REACHABLE)
|
||||
continue;
|
||||
|
||||
// Start flood fill.
|
||||
topSpan->flags |= RC_REACHABLE;
|
||||
stackSize = 0;
|
||||
stack[stackSize].set(x, y, topSpan);
|
||||
stackSize++;
|
||||
|
||||
while (stackSize)
|
||||
{
|
||||
// Pop a seed from the stack.
|
||||
stackSize--;
|
||||
rcReachableSeed cur = stack[stackSize];
|
||||
|
||||
const int bot = (int)(cur.s->smax);
|
||||
const int top = cur.s->next ? (int)(cur.s->next->smin) : MAX_HEIGHT;
|
||||
|
||||
// Visit neighbours in all 4 directions.
|
||||
for (int dir = 0; dir < 4; ++dir)
|
||||
{
|
||||
int dx = (int)cur.x + rcGetDirOffsetX(dir);
|
||||
int dy = (int)cur.y + rcGetDirOffsetY(dir);
|
||||
// Skip neighbour which are out of bounds.
|
||||
if (dx < 0 || dy < 0 || dx >= w || dy >= h)
|
||||
continue;
|
||||
for (rcSpan* ns = solid.spans[dx + dy*w]; ns; ns = ns->next)
|
||||
{
|
||||
// Skip neighbour if it is not walkable.
|
||||
if ((ns->flags & RC_WALKABLE) == 0)
|
||||
continue;
|
||||
// Skip the neighbour if it has been visited already.
|
||||
if (ns->flags & RC_REACHABLE)
|
||||
continue;
|
||||
|
||||
const int nbot = (int)ns->smax;
|
||||
const int ntop = ns->next ? (int)ns->next->smin : MAX_HEIGHT;
|
||||
// Skip neightbour if the gap between the spans is too small.
|
||||
if (rcMin(top,ntop) - rcMax(bot,nbot) < walkableHeight)
|
||||
continue;
|
||||
// Skip neightbour if the climb height to the neighbour is too high.
|
||||
if (rcAbs(nbot - bot) >= walkableClimb)
|
||||
continue;
|
||||
|
||||
// This neighbour has not been visited yet.
|
||||
// Mark it as reachable and add it to the seed stack.
|
||||
ns->flags |= RC_REACHABLE;
|
||||
if (stackSize < MAX_SEEDS)
|
||||
{
|
||||
stack[stackSize].set(dx, dy, ns);
|
||||
stackSize++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete [] stack;
|
||||
|
||||
rcTimeVal endTime = rcGetPerformanceTimer();
|
||||
|
||||
// if (rcGetLog())
|
||||
// rcGetLog()->log(RC_LOG_PROGRESS, "Mark reachable: %.3f ms", rcGetDeltaTimeUsec(startTime, endTime)/1000.0f);
|
||||
if (rcGetBuildTimes())
|
||||
rcGetBuildTimes()->filterMarkReachable += rcGetDeltaTimeUsec(startTime, endTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -279,14 +279,14 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>28</integer>
|
||||
<integer>21</integer>
|
||||
<integer>18</integer>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||
<string>{{0, 125}, {282, 660}}</string>
|
||||
<string>{{0, 49}, {282, 660}}</string>
|
||||
</dict>
|
||||
<key>PBXTopSmartGroupGIDs</key>
|
||||
<array/>
|
||||
@ -321,7 +321,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>Recast.cpp</string>
|
||||
<string>RecastDebugDraw.cpp</string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@ -329,37 +329,44 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A40F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>Recast.cpp</string>
|
||||
<string>RecastDebugDraw.cpp</string>
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>6B8DE74910B01BE900DF20FB</string>
|
||||
<string>6B8DE84710B055DA00DF20FB</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>6B6FA3B61076452F009B0572</string>
|
||||
<string>6B3BFADD107A80E1006284CD</string>
|
||||
<string>6B3BFB0C107A8979006284CD</string>
|
||||
<string>6B3BFB0D107A8979006284CD</string>
|
||||
<string>6B57D358108C66B200DDD053</string>
|
||||
<string>6B57D38F108C69E400DDD053</string>
|
||||
<string>6B7FB74A1091EBDE001BA51A</string>
|
||||
<string>6B7FB74D1091EBDE001BA51A</string>
|
||||
<string>6B8DE6FE10B01BBF00DF20FB</string>
|
||||
<string>6B8DE6FF10B01BBF00DF20FB</string>
|
||||
<string>6B8DE70010B01BBF00DF20FB</string>
|
||||
<string>6B8DE70110B01BBF00DF20FB</string>
|
||||
<string>6B8DE70310B01BBF00DF20FB</string>
|
||||
<string>6B8DE70410B01BBF00DF20FB</string>
|
||||
<string>6B8DE70510B01BBF00DF20FB</string>
|
||||
<string>6B8DE70610B01BBF00DF20FB</string>
|
||||
<string>6B8DE70710B01BBF00DF20FB</string>
|
||||
<string>6B8DE70810B01BBF00DF20FB</string>
|
||||
<string>6B8DE70910B01BBF00DF20FB</string>
|
||||
<string>6B8DE70A10B01BBF00DF20FB</string>
|
||||
<string>6B8DE70B10B01BBF00DF20FB</string>
|
||||
<string>6B8DE70C10B01BBF00DF20FB</string>
|
||||
<string>6B8DE70D10B01BBF00DF20FB</string>
|
||||
<string>6B8DE73D10B01BBF00DF20FB</string>
|
||||
<string>6B8DE76D10B0243500DF20FB</string>
|
||||
<string>6B8DE76E10B0243500DF20FB</string>
|
||||
<string>6B8DE7F110B0517A00DF20FB</string>
|
||||
<string>6B8DE7F310B0517A00DF20FB</string>
|
||||
<string>6B8DE7F410B0517A00DF20FB</string>
|
||||
<string>6B8DE7F510B0517A00DF20FB</string>
|
||||
<string>6B8DE7F610B0517A00DF20FB</string>
|
||||
<string>6B8DE7F710B0517A00DF20FB</string>
|
||||
<string>6B8DE7F810B0517A00DF20FB</string>
|
||||
<string>6B8DE81E10B0528100DF20FB</string>
|
||||
<string>6B8DE81F10B0528100DF20FB</string>
|
||||
<string>6B8DE82010B0528100DF20FB</string>
|
||||
<string>6B8DE82110B0528100DF20FB</string>
|
||||
</array>
|
||||
<key>prevStack</key>
|
||||
<array>
|
||||
@ -367,7 +374,6 @@
|
||||
<string>6B6FA36B1070C1F7009B0572</string>
|
||||
<string>6B6FA3B81076452F009B0572</string>
|
||||
<string>6B6FA3BA1076452F009B0572</string>
|
||||
<string>6B6FA3BC1076452F009B0572</string>
|
||||
<string>6B3BFADF107A80E1006284CD</string>
|
||||
<string>6B3BFB12107A8979006284CD</string>
|
||||
<string>6B3BFB13107A8979006284CD</string>
|
||||
@ -375,7 +381,6 @@
|
||||
<string>6B57D35B108C66B200DDD053</string>
|
||||
<string>6B57D376108C692900DDD053</string>
|
||||
<string>6B57D393108C69E400DDD053</string>
|
||||
<string>6B7FB7531091EBDE001BA51A</string>
|
||||
<string>6B7FB7541091EBDE001BA51A</string>
|
||||
<string>6B7FB7571091EBDE001BA51A</string>
|
||||
<string>6B8DE71110B01BBF00DF20FB</string>
|
||||
@ -406,17 +411,76 @@
|
||||
<string>6B8DE72E10B01BBF00DF20FB</string>
|
||||
<string>6B8DE72F10B01BBF00DF20FB</string>
|
||||
<string>6B8DE73010B01BBF00DF20FB</string>
|
||||
<string>6B8DE73110B01BBF00DF20FB</string>
|
||||
<string>6B8DE73210B01BBF00DF20FB</string>
|
||||
<string>6B8DE73310B01BBF00DF20FB</string>
|
||||
<string>6B8DE73410B01BBF00DF20FB</string>
|
||||
<string>6B8DE73510B01BBF00DF20FB</string>
|
||||
<string>6B8DE73610B01BBF00DF20FB</string>
|
||||
<string>6B8DE73710B01BBF00DF20FB</string>
|
||||
<string>6B8DE73810B01BBF00DF20FB</string>
|
||||
<string>6B8DE73910B01BBF00DF20FB</string>
|
||||
<string>6B8DE73A10B01BBF00DF20FB</string>
|
||||
<string>6B8DE73B10B01BBF00DF20FB</string>
|
||||
<string>6B8DE75010B01EEA00DF20FB</string>
|
||||
<string>6B8DE75110B01EEA00DF20FB</string>
|
||||
<string>6B8DE75210B01EEA00DF20FB</string>
|
||||
<string>6B8DE75310B01EEA00DF20FB</string>
|
||||
<string>6B8DE75410B01EEA00DF20FB</string>
|
||||
<string>6B8DE75510B01EEA00DF20FB</string>
|
||||
<string>6B8DE75610B01EEA00DF20FB</string>
|
||||
<string>6B8DE75A10B01F1A00DF20FB</string>
|
||||
<string>6B8DE75F10B01F9900DF20FB</string>
|
||||
<string>6B8DE76710B022B200DF20FB</string>
|
||||
<string>6B8DE77010B0243500DF20FB</string>
|
||||
<string>6B8DE77110B0243500DF20FB</string>
|
||||
<string>6B8DE7A010B0404100DF20FB</string>
|
||||
<string>6B8DE7A110B0404100DF20FB</string>
|
||||
<string>6B8DE7A510B0412B00DF20FB</string>
|
||||
<string>6B8DE7A610B0412B00DF20FB</string>
|
||||
<string>6B8DE7A710B0412B00DF20FB</string>
|
||||
<string>6B8DE7A810B0412B00DF20FB</string>
|
||||
<string>6B8DE7AC10B0463F00DF20FB</string>
|
||||
<string>6B8DE7AD10B0463F00DF20FB</string>
|
||||
<string>6B8DE7C910B04B7F00DF20FB</string>
|
||||
<string>6B8DE7CA10B04B7F00DF20FB</string>
|
||||
<string>6B8DE7CB10B04B7F00DF20FB</string>
|
||||
<string>6B8DE7CC10B04B7F00DF20FB</string>
|
||||
<string>6B8DE7CD10B04B7F00DF20FB</string>
|
||||
<string>6B8DE7CE10B04B7F00DF20FB</string>
|
||||
<string>6B8DE7D510B04C5000DF20FB</string>
|
||||
<string>6B8DE7FA10B0517A00DF20FB</string>
|
||||
<string>6B8DE7FB10B0517A00DF20FB</string>
|
||||
<string>6B8DE7FC10B0517A00DF20FB</string>
|
||||
<string>6B8DE7FD10B0517A00DF20FB</string>
|
||||
<string>6B8DE7FE10B0517A00DF20FB</string>
|
||||
<string>6B8DE7FF10B0517A00DF20FB</string>
|
||||
<string>6B8DE80010B0517A00DF20FB</string>
|
||||
<string>6B8DE80110B0517A00DF20FB</string>
|
||||
<string>6B8DE80210B0517A00DF20FB</string>
|
||||
<string>6B8DE80310B0517A00DF20FB</string>
|
||||
<string>6B8DE80410B0517A00DF20FB</string>
|
||||
<string>6B8DE80510B0517A00DF20FB</string>
|
||||
<string>6B8DE80610B0517A00DF20FB</string>
|
||||
<string>6B8DE80710B0517A00DF20FB</string>
|
||||
<string>6B8DE80810B0517A00DF20FB</string>
|
||||
<string>6B8DE80910B0517A00DF20FB</string>
|
||||
<string>6B8DE80A10B0517A00DF20FB</string>
|
||||
<string>6B8DE80B10B0517A00DF20FB</string>
|
||||
<string>6B8DE80C10B0517A00DF20FB</string>
|
||||
<string>6B8DE80D10B0517A00DF20FB</string>
|
||||
<string>6B8DE80E10B0517A00DF20FB</string>
|
||||
<string>6B8DE80F10B0517A00DF20FB</string>
|
||||
<string>6B8DE81010B0517A00DF20FB</string>
|
||||
<string>6B8DE81110B0517A00DF20FB</string>
|
||||
<string>6B8DE81210B0517A00DF20FB</string>
|
||||
<string>6B8DE81310B0517A00DF20FB</string>
|
||||
<string>6B8DE81410B0517A00DF20FB</string>
|
||||
<string>6B8DE81510B0517A00DF20FB</string>
|
||||
<string>6B8DE81610B0517A00DF20FB</string>
|
||||
<string>6B8DE81710B0517A00DF20FB</string>
|
||||
<string>6B8DE81810B0517A00DF20FB</string>
|
||||
<string>6B8DE81910B0517A00DF20FB</string>
|
||||
<string>6B8DE81A10B0517A00DF20FB</string>
|
||||
<string>6B8DE82210B0528100DF20FB</string>
|
||||
<string>6B8DE82310B0528100DF20FB</string>
|
||||
<string>6B8DE82410B0528100DF20FB</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
@ -430,18 +494,18 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {976, 434}}</string>
|
||||
<string>{{0, 0}, {976, 456}}</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>434pt</string>
|
||||
<string>456pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>239pt</string>
|
||||
<string>217pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -471,9 +535,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {976, 212}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>0 59 1280 719 0 0 1280 778 </string>
|
||||
<string>{{10, 27}, {976, 175}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXProjectFindModule</string>
|
||||
@ -511,7 +573,9 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {976, 155}}</string>
|
||||
<string>{{10, 27}, {976, 190}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>0 59 1280 719 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXBuildResultsModule</string>
|
||||
|
@ -1,6 +1,16 @@
|
||||
#ifndef RECASTSAMPLE_H
|
||||
#define RECASTSAMPLE_H
|
||||
|
||||
#include "RecastDebugDraw.h"
|
||||
|
||||
struct DebugDrawGL : public rcDebugDraw
|
||||
{
|
||||
virtual void begin(rcDebugDrawPrimitives prim, int nverts, 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();
|
||||
};
|
||||
|
||||
|
||||
class Sample
|
||||
{
|
||||
|
@ -5,12 +5,55 @@
|
||||
#include "Recast.h"
|
||||
#include "RecastDebugDraw.h"
|
||||
#include "imgui.h"
|
||||
#include "SDL.h"
|
||||
#include "SDL_opengl.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
|
||||
void DebugDrawGL::begin(rcDebugDrawPrimitives prim, int nverts, float size)
|
||||
{
|
||||
switch (prim)
|
||||
{
|
||||
case RC_DRAW_POINTS:
|
||||
glPointSize(size);
|
||||
glBegin(GL_POINTS);
|
||||
break;
|
||||
case RC_DRAW_LINES:
|
||||
glLineWidth(size);
|
||||
glBegin(GL_LINES);
|
||||
break;
|
||||
case RC_DRAW_TRIS:
|
||||
glBegin(GL_TRIANGLES);
|
||||
break;
|
||||
case RC_DRAW_QUADS:
|
||||
glBegin(GL_QUADS);
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
void DebugDrawGL::vertex(const float* pos, unsigned int color)
|
||||
{
|
||||
glColor4ubv((GLubyte*)&color);
|
||||
glVertex3fv(pos);
|
||||
}
|
||||
|
||||
void DebugDrawGL::vertex(const float x, const float y, const float z, unsigned int color)
|
||||
{
|
||||
glColor4ubv((GLubyte*)&color);
|
||||
glVertex3f(x,y,z);
|
||||
}
|
||||
|
||||
void DebugDrawGL::end()
|
||||
{
|
||||
glEnd();
|
||||
glLineWidth(1.0f);
|
||||
glPointSize(1.0f);
|
||||
}
|
||||
|
||||
|
||||
Sample::Sample() :
|
||||
m_verts(0), m_nverts(0), m_tris(0), m_trinorms(0), m_ntris(0)
|
||||
{
|
||||
@ -37,11 +80,14 @@ void Sample::handleRender()
|
||||
{
|
||||
if (!m_verts || !m_tris || !m_trinorms)
|
||||
return;
|
||||
|
||||
DebugDrawGL dd;
|
||||
|
||||
// Draw mesh
|
||||
rcDebugDrawMesh(m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
|
||||
rcDebugDrawMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
|
||||
// Draw bounds
|
||||
float col[4] = {1,1,1,0.5f};
|
||||
rcDebugDrawBoxWire(m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
|
||||
rcDebugDrawBoxWire(&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)
|
||||
|
@ -193,6 +193,8 @@ void Sample_StatMesh::toolRender(int flags)
|
||||
if (!m_navMesh)
|
||||
return;
|
||||
|
||||
DebugDrawGL dd;
|
||||
|
||||
static const float startCol[4] = { 0.5f, 0.1f, 0.0f, 0.75f };
|
||||
static const float endCol[4] = { 0.2f, 0.4f, 0.0f, 0.75f };
|
||||
static const float pathCol[4] = {0,0,0,0.25f};
|
||||
@ -262,7 +264,7 @@ void Sample_StatMesh::toolRender(int flags)
|
||||
{
|
||||
dtDebugDrawStatNavMeshPoly(m_navMesh, m_startRef, startCol);
|
||||
const float col[4] = {1,1,1,0.5f};
|
||||
rcDebugDrawCylinderWire(m_spos[0]-m_distanceToWall, m_spos[1]+0.02f, m_spos[2]-m_distanceToWall,
|
||||
rcDebugDrawCylinderWire(&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);
|
||||
@ -274,7 +276,7 @@ void Sample_StatMesh::toolRender(int flags)
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_AROUND)
|
||||
{
|
||||
glLineWidth(2.0f);
|
||||
const float cola[4] = {0,0,0,0.5f};
|
||||
for (int i = 0; i < m_npolys; ++i)
|
||||
{
|
||||
dtDebugDrawStatNavMeshPoly(m_navMesh, m_polys[i], pathCol);
|
||||
@ -283,17 +285,15 @@ void Sample_StatMesh::toolRender(int flags)
|
||||
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(p0, p1);
|
||||
rcDrawArc(&dd, p0, p1, cola, 2.0f);
|
||||
}
|
||||
}
|
||||
glLineWidth(1.0f);
|
||||
|
||||
const float dx = m_epos[0] - m_spos[0];
|
||||
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(m_spos[0]-dist, m_spos[1]+0.02f, m_spos[2]-dist,
|
||||
rcDebugDrawCylinderWire(&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);
|
||||
}
|
||||
}
|
||||
@ -320,11 +320,13 @@ void Sample_StatMesh::toolRenderOverlay(double* proj, double* model, int* view)
|
||||
|
||||
void Sample_StatMesh::drawAgent(const float* pos, float r, float h, float c, const float* col)
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
// Agent dimensions.
|
||||
glLineWidth(2.0f);
|
||||
rcDebugDrawCylinderWire(pos[0]-r, pos[1]+0.02f, pos[2]-r, pos[0]+r, pos[1]+h, pos[2]+r, col);
|
||||
rcDebugDrawCylinderWire(&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);
|
||||
|
@ -144,6 +144,8 @@ void Sample_StatMeshSimple::handleRender()
|
||||
return;
|
||||
|
||||
float col[4];
|
||||
|
||||
DebugDrawGL dd;
|
||||
|
||||
glEnable(GL_FOG);
|
||||
glDepthMask(GL_TRUE);
|
||||
@ -151,12 +153,12 @@ void Sample_StatMeshSimple::handleRender()
|
||||
if (m_drawMode == DRAWMODE_MESH)
|
||||
{
|
||||
// Draw mesh
|
||||
rcDebugDrawMeshSlope(m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
|
||||
rcDebugDrawMeshSlope(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
|
||||
}
|
||||
else if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
|
||||
{
|
||||
// Draw mesh
|
||||
rcDebugDrawMesh(m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
|
||||
rcDebugDrawMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
|
||||
}
|
||||
|
||||
glDisable(GL_FOG);
|
||||
@ -164,7 +166,7 @@ void Sample_StatMeshSimple::handleRender()
|
||||
|
||||
// Draw bounds
|
||||
col[0] = 1; col[1] = 1; col[2] = 1; col[3] = 0.5f;
|
||||
rcDebugDrawBoxWire(m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
|
||||
rcDebugDrawBoxWire(&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 ||
|
||||
@ -183,61 +185,61 @@ void Sample_StatMeshSimple::handleRender()
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
if (m_chf && m_drawMode == DRAWMODE_COMPACT)
|
||||
rcDebugDrawCompactHeightfieldSolid(*m_chf);
|
||||
rcDebugDrawCompactHeightfieldSolid(&dd, *m_chf);
|
||||
|
||||
if (m_chf && m_drawMode == DRAWMODE_COMPACT_DISTANCE)
|
||||
rcDebugDrawCompactHeightfieldDistance(*m_chf);
|
||||
rcDebugDrawCompactHeightfieldDistance(&dd, *m_chf);
|
||||
if (m_chf && m_drawMode == DRAWMODE_COMPACT_REGIONS)
|
||||
rcDebugDrawCompactHeightfieldRegions(*m_chf);
|
||||
rcDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
|
||||
if (m_solid && m_drawMode == DRAWMODE_VOXELS)
|
||||
{
|
||||
glEnable(GL_FOG);
|
||||
rcDebugDrawHeightfieldSolid(*m_solid);
|
||||
rcDebugDrawHeightfieldSolid(&dd, *m_solid);
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
if (m_solid && m_drawMode == DRAWMODE_VOXELS_WALKABLE)
|
||||
{
|
||||
glEnable(GL_FOG);
|
||||
rcDebugDrawHeightfieldWalkable(*m_solid);
|
||||
rcDebugDrawHeightfieldWalkable(&dd, *m_solid);
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
if (m_cset && m_drawMode == DRAWMODE_RAW_CONTOURS)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
rcDebugDrawRawContours(*m_cset);
|
||||
rcDebugDrawRawContours(&dd, *m_cset);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_cset && m_drawMode == DRAWMODE_BOTH_CONTOURS)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
rcDebugDrawRawContours(*m_cset, 0.5f);
|
||||
rcDebugDrawContours(*m_cset);
|
||||
rcDebugDrawRawContours(&dd, *m_cset, 0.5f);
|
||||
rcDebugDrawContours(&dd, *m_cset);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_cset && m_drawMode == DRAWMODE_CONTOURS)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
rcDebugDrawContours(*m_cset);
|
||||
rcDebugDrawContours(&dd, *m_cset);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_chf && m_cset && m_drawMode == DRAWMODE_REGION_CONNECTIONS)
|
||||
{
|
||||
rcDebugDrawCompactHeightfieldRegions(*m_chf);
|
||||
rcDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
rcDebugDrawRegionConnections(*m_cset);
|
||||
rcDebugDrawRegionConnections(&dd, *m_cset);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_pmesh && m_drawMode == DRAWMODE_POLYMESH)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
rcDebugDrawPolyMesh(*m_pmesh);
|
||||
rcDebugDrawPolyMesh(&dd, *m_pmesh);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_dmesh && m_drawMode == DRAWMODE_POLYMESH_DETAIL)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
rcDebugDrawPolyMeshDetail(*m_dmesh);
|
||||
rcDebugDrawPolyMeshDetail(&dd, *m_dmesh);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
|
@ -178,18 +178,20 @@ void Sample_StatMeshTiled::handleRender()
|
||||
|
||||
float col[4];
|
||||
|
||||
DebugDrawGL dd;
|
||||
|
||||
glEnable(GL_FOG);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
if (m_drawMode == DRAWMODE_MESH)
|
||||
{
|
||||
// Draw mesh
|
||||
rcDebugDrawMeshSlope(m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
|
||||
rcDebugDrawMeshSlope(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
|
||||
}
|
||||
else if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
|
||||
{
|
||||
// Draw mesh
|
||||
rcDebugDrawMesh(m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
|
||||
rcDebugDrawMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
|
||||
}
|
||||
|
||||
glDisable(GL_FOG);
|
||||
@ -197,7 +199,7 @@ void Sample_StatMeshTiled::handleRender()
|
||||
|
||||
// Draw bounds
|
||||
col[0] = 1; col[1] = 1; col[2] = 1; col[3] = 0.5f;
|
||||
rcDebugDrawBoxWire(m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
|
||||
rcDebugDrawBoxWire(&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;
|
||||
@ -260,7 +262,7 @@ void Sample_StatMeshTiled::handleRender()
|
||||
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
|
||||
{
|
||||
if (m_tileSet->tiles[i].chf)
|
||||
rcDebugDrawCompactHeightfieldSolid(*m_tileSet->tiles[i].chf);
|
||||
rcDebugDrawCompactHeightfieldSolid(&dd, *m_tileSet->tiles[i].chf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,7 +271,7 @@ void Sample_StatMeshTiled::handleRender()
|
||||
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
|
||||
{
|
||||
if (m_tileSet->tiles[i].chf)
|
||||
rcDebugDrawCompactHeightfieldDistance(*m_tileSet->tiles[i].chf);
|
||||
rcDebugDrawCompactHeightfieldDistance(&dd, *m_tileSet->tiles[i].chf);
|
||||
}
|
||||
}
|
||||
if (m_drawMode == DRAWMODE_COMPACT_REGIONS)
|
||||
@ -277,7 +279,7 @@ void Sample_StatMeshTiled::handleRender()
|
||||
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
|
||||
{
|
||||
if (m_tileSet->tiles[i].chf)
|
||||
rcDebugDrawCompactHeightfieldRegions(*m_tileSet->tiles[i].chf);
|
||||
rcDebugDrawCompactHeightfieldRegions(&dd, *m_tileSet->tiles[i].chf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,7 +289,7 @@ void Sample_StatMeshTiled::handleRender()
|
||||
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
|
||||
{
|
||||
if (m_tileSet->tiles[i].solid)
|
||||
rcDebugDrawHeightfieldSolid(*m_tileSet->tiles[i].solid);
|
||||
rcDebugDrawHeightfieldSolid(&dd, *m_tileSet->tiles[i].solid);
|
||||
}
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
@ -297,7 +299,7 @@ void Sample_StatMeshTiled::handleRender()
|
||||
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
|
||||
{
|
||||
if (m_tileSet->tiles[i].solid)
|
||||
rcDebugDrawHeightfieldWalkable(*m_tileSet->tiles[i].solid);
|
||||
rcDebugDrawHeightfieldWalkable(&dd, *m_tileSet->tiles[i].solid);
|
||||
}
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
@ -307,7 +309,7 @@ void Sample_StatMeshTiled::handleRender()
|
||||
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
|
||||
{
|
||||
if (m_tileSet->tiles[i].cset)
|
||||
rcDebugDrawRawContours(*m_tileSet->tiles[i].cset);
|
||||
rcDebugDrawRawContours(&dd, *m_tileSet->tiles[i].cset);
|
||||
}
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
@ -318,8 +320,8 @@ void Sample_StatMeshTiled::handleRender()
|
||||
{
|
||||
if (m_tileSet->tiles[i].cset)
|
||||
{
|
||||
rcDebugDrawRawContours(*m_tileSet->tiles[i].cset, 0.5f);
|
||||
rcDebugDrawContours(*m_tileSet->tiles[i].cset);
|
||||
rcDebugDrawRawContours(&dd, *m_tileSet->tiles[i].cset, 0.5f);
|
||||
rcDebugDrawContours(&dd, *m_tileSet->tiles[i].cset);
|
||||
}
|
||||
}
|
||||
glDepthMask(GL_TRUE);
|
||||
@ -330,7 +332,7 @@ void Sample_StatMeshTiled::handleRender()
|
||||
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
|
||||
{
|
||||
if (m_tileSet->tiles[i].cset)
|
||||
rcDebugDrawContours(*m_tileSet->tiles[i].cset);
|
||||
rcDebugDrawContours(&dd, *m_tileSet->tiles[i].cset);
|
||||
}
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
@ -339,14 +341,14 @@ void Sample_StatMeshTiled::handleRender()
|
||||
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
|
||||
{
|
||||
if (m_tileSet->tiles[i].chf)
|
||||
rcDebugDrawCompactHeightfieldRegions(*m_tileSet->tiles[i].chf);
|
||||
rcDebugDrawCompactHeightfieldRegions(&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(*m_tileSet->tiles[i].cset);
|
||||
rcDebugDrawRegionConnections(&dd, *m_tileSet->tiles[i].cset);
|
||||
}
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
@ -355,14 +357,14 @@ void Sample_StatMeshTiled::handleRender()
|
||||
glDepthMask(GL_FALSE);
|
||||
if (m_pmesh)
|
||||
{
|
||||
rcDebugDrawPolyMesh(*m_pmesh);
|
||||
rcDebugDrawPolyMesh(&dd, *m_pmesh);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
|
||||
{
|
||||
if (m_tileSet->tiles[i].pmesh)
|
||||
rcDebugDrawPolyMesh(*m_tileSet->tiles[i].pmesh);
|
||||
rcDebugDrawPolyMesh(&dd, *m_tileSet->tiles[i].pmesh);
|
||||
}
|
||||
}
|
||||
|
||||
@ -373,14 +375,14 @@ void Sample_StatMeshTiled::handleRender()
|
||||
glDepthMask(GL_FALSE);
|
||||
if (m_dmesh)
|
||||
{
|
||||
rcDebugDrawPolyMeshDetail(*m_dmesh);
|
||||
rcDebugDrawPolyMeshDetail(&dd, *m_dmesh);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < m_tileSet->width*m_tileSet->height; ++i)
|
||||
{
|
||||
if (m_tileSet->tiles[i].dmesh)
|
||||
rcDebugDrawPolyMeshDetail(*m_tileSet->tiles[i].dmesh);
|
||||
rcDebugDrawPolyMeshDetail(&dd, *m_tileSet->tiles[i].dmesh);
|
||||
}
|
||||
}
|
||||
glDepthMask(GL_TRUE);
|
||||
|
@ -244,17 +244,19 @@ void Sample_TileMesh::handleRender()
|
||||
if (!m_verts || !m_tris || !m_trinorms)
|
||||
return;
|
||||
|
||||
DebugDrawGL dd;
|
||||
|
||||
// Draw mesh
|
||||
if (m_navMesh)
|
||||
rcDebugDrawMesh(m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
|
||||
rcDebugDrawMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
|
||||
else
|
||||
rcDebugDrawMeshSlope(m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
|
||||
rcDebugDrawMeshSlope(&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(m_bmin[0],m_bmin[1],m_bmin[2], m_bmax[0],m_bmax[1],m_bmax[2], col);
|
||||
rcDebugDrawBoxWire(&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;
|
||||
@ -294,7 +296,7 @@ void Sample_TileMesh::handleRender()
|
||||
glEnd();
|
||||
|
||||
// Draw active tile
|
||||
rcDebugDrawBoxWire(m_tileBmin[0],m_tileBmin[1],m_tileBmin[2], m_tileBmax[0],m_tileBmax[1],m_tileBmax[2], m_tileCol);
|
||||
rcDebugDrawBoxWire(&dd, m_tileBmin[0],m_tileBmin[1],m_tileBmin[2], m_tileBmax[0],m_tileBmax[1],m_tileBmax[2], m_tileCol);
|
||||
|
||||
if (m_navMesh)
|
||||
dtDebugDrawTiledNavMesh(m_navMesh);
|
||||
@ -389,7 +391,7 @@ void Sample_TileMesh::handleRender()
|
||||
{
|
||||
dtDebugDrawTiledNavMeshPoly(m_navMesh, m_startRef, startCol);
|
||||
const float col[4] = {1,1,1,0.5f};
|
||||
rcDebugDrawCylinderWire(m_spos[0]-m_distanceToWall, m_spos[1]+0.02f, m_spos[2]-m_distanceToWall,
|
||||
rcDebugDrawCylinderWire(&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);
|
||||
@ -401,7 +403,7 @@ void Sample_TileMesh::handleRender()
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_AROUND)
|
||||
{
|
||||
glLineWidth(2.0f);
|
||||
const float cola[4] = {0,0,0,0.5f};
|
||||
for (int i = 0; i < m_npolys; ++i)
|
||||
{
|
||||
dtDebugDrawTiledNavMeshPoly(m_navMesh, m_polys[i], pathCol);
|
||||
@ -411,16 +413,15 @@ void Sample_TileMesh::handleRender()
|
||||
getPolyCenter(m_navMesh, m_polys[i], p0);
|
||||
getPolyCenter(m_navMesh, m_parent[i], p1);
|
||||
glColor4ub(0,0,0,128);
|
||||
rcDrawArc(p0, p1);
|
||||
rcDrawArc(&dd, p0, p1, cola, 2.0f);
|
||||
}
|
||||
}
|
||||
glLineWidth(1.0f);
|
||||
|
||||
const float dx = m_epos[0] - m_spos[0];
|
||||
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(m_spos[0]-dist, m_spos[1]+0.02f, m_spos[2]-dist,
|
||||
rcDebugDrawCylinderWire(&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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user