Better handling of low obstacles.
This commit is contained in:
parent
bd2e60a008
commit
9bf68216a3
@ -126,15 +126,16 @@ void duDebugDrawHeightfieldWalkable(duDebugDraw* dd, const rcHeightfield& hf)
|
||||
const int h = hf.height;
|
||||
|
||||
unsigned int fcol0[6], fcol1[6], fcol2[6];
|
||||
duCalcBoxColors(fcol0, duRGBA(128,192,217,255), duRGBA(217,217,217,255)); // Culled
|
||||
duCalcBoxColors(fcol0, duRGBA(64,48,32,255), duRGBA(217,217,217,255)); // Culled
|
||||
duCalcBoxColors(fcol1, duRGBA(77,140,165,255), duRGBA(217,217,217,255)); // Walkable
|
||||
duCalcBoxColors(fcol2, duRGBA(38,102,128,255), duRGBA(217,217,217,255)); // Ledge
|
||||
duCalcBoxColors(fcol2, duRGBA(128,38,102,255), duRGBA(217,217,217,255)); // Ledge
|
||||
|
||||
dd->begin(DU_DRAW_QUADS);
|
||||
|
||||
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;
|
||||
|
@ -416,8 +416,10 @@ void rcMarkWalkableTriangles(const float walkableSlopeAngle,
|
||||
// v0,v1,v2 - (in) the vertices of the triangle.
|
||||
// flags - (in) triangle flags (uses WALKABLE)
|
||||
// solid - (in) heighfield where the triangle is rasterized
|
||||
// flagMergeThr - (in) distance in voxel where walkable flag is favored over non-walkable.
|
||||
void rcRasterizeTriangle(const float* v0, const float* v1, const float* v2,
|
||||
unsigned char flags, rcHeightfield& solid);
|
||||
unsigned char flags, rcHeightfield& solid,
|
||||
const int flagMergeThr = 1);
|
||||
|
||||
// Rasterizes the triangles into heightfield spans.
|
||||
// Params:
|
||||
@ -427,9 +429,10 @@ void rcRasterizeTriangle(const float* v0, const float* v1, const float* v2,
|
||||
// flags - (in) array of triangle flags (uses WALKABLE)
|
||||
// nt - (in) triangle count
|
||||
// solid - (in) heighfield where the triangles are rasterized
|
||||
// flagMergeThr - (in) distance in voxel where walkable flag is favored over non-walkable.
|
||||
void rcRasterizeTriangles(const float* verts, int nv,
|
||||
const int* tris, const unsigned char* flags, int nt,
|
||||
rcHeightfield& solid);
|
||||
rcHeightfield& solid, const int flagMergeThr = 1);
|
||||
|
||||
// Rasterizes the triangles into heightfield spans.
|
||||
// Params:
|
||||
@ -439,9 +442,10 @@ void rcRasterizeTriangles(const float* verts, int nv,
|
||||
// flags - (in) array of triangle flags (uses WALKABLE)
|
||||
// nt - (in) triangle count
|
||||
// solid - (in) heighfield where the triangles are rasterized
|
||||
// flagMergeThr - (in) distance in voxel where walkable flag is favored over non-walkable.
|
||||
void rcRasterizeTriangles(const float* verts, int nv,
|
||||
const unsigned short* tris, const unsigned char* flags, int nt,
|
||||
rcHeightfield& solid);
|
||||
rcHeightfield& solid, const int flagMergeThr = 1);
|
||||
|
||||
// Rasterizes the triangles into heightfield spans.
|
||||
// Params:
|
||||
@ -452,6 +456,15 @@ void rcRasterizeTriangles(const float* verts, int nv,
|
||||
void rcRasterizeTriangles(const float* verts, const unsigned char* flags, int nt,
|
||||
rcHeightfield& solid);
|
||||
|
||||
// Marks non-walkable low obstacles as walkable if they are closer than walkableClimb
|
||||
// from a walkable surface. Applying this filter allows to step over low hanging
|
||||
// low obstacles.
|
||||
// Params:
|
||||
// walkableHeight - (in) minimum height where the agent can still walk
|
||||
// solid - (in/out) heightfield describing the solid space
|
||||
// TODO: Missuses ledge flag, must be called before rcFilterLedgeSpans!
|
||||
void rcFilterLowHangingWalkableObstacles(const int walkableClimb, rcHeightfield& solid);
|
||||
|
||||
// Removes WALKABLE flag from all spans that are at ledges. This filtering
|
||||
// removes possible overestimation of the conservative voxelization so that
|
||||
// the resulting mesh will not have regions hanging in air over ledges.
|
||||
|
@ -24,6 +24,42 @@
|
||||
#include "RecastTimer.h"
|
||||
|
||||
|
||||
// TODO: Missuses ledge flag, must be called before rcFilterLedgeSpans!
|
||||
void rcFilterLowHangingWalkableObstacles(const int walkableClimb, rcHeightfield& solid)
|
||||
{
|
||||
const int w = solid.width;
|
||||
const int h = solid.height;
|
||||
|
||||
for (int y = 0; y < h; ++y)
|
||||
{
|
||||
for (int x = 0; x < w; ++x)
|
||||
{
|
||||
rcSpan* ps = 0;
|
||||
for (rcSpan* s = solid.spans[x + y*w]; s; ps = s, s = s->next)
|
||||
{
|
||||
const bool walkable = (s->flags & RC_WALKABLE) != 0;
|
||||
const bool previousWalkable = ps && (ps->flags & RC_WALKABLE) != 0;
|
||||
// If current span is not walkable, but there is walkable
|
||||
// span just below it, mark the span above it walkable too.
|
||||
// Missuse the edge flag so that walkable flag cannot propagate
|
||||
// past multiple non-walkable objects.
|
||||
if (!walkable && previousWalkable)
|
||||
{
|
||||
if (rcAbs((int)s->smax - (int)ps->smax) <= walkableClimb)
|
||||
s->flags |= RC_LEDGE;
|
||||
}
|
||||
}
|
||||
// Transfer "fake ledges" to walkables.
|
||||
for (rcSpan* s = solid.spans[x + y*w]; s; ps = s, s = s->next)
|
||||
{
|
||||
if (s->flags & RC_LEDGE)
|
||||
s->flags |= RC_WALKABLE;
|
||||
s->flags &= ~RC_LEDGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rcFilterLedgeSpans(const int walkableHeight,
|
||||
const int walkableClimb,
|
||||
rcHeightfield& solid)
|
||||
@ -51,6 +87,10 @@ void rcFilterLedgeSpans(const int walkableHeight,
|
||||
// Find neighbours minimum height.
|
||||
int minh = MAX_HEIGHT;
|
||||
|
||||
// Min and max height of accessible neighbours.
|
||||
int asmin = s->smax;
|
||||
int asmax = s->smax;
|
||||
|
||||
for (int dir = 0; dir < 4; ++dir)
|
||||
{
|
||||
int dx = x + rcGetDirOffsetX(dir);
|
||||
@ -77,7 +117,17 @@ void rcFilterLedgeSpans(const int walkableHeight,
|
||||
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)
|
||||
{
|
||||
minh = rcMin(minh, nbot - bot);
|
||||
|
||||
// Find min/max accessible neighbour height.
|
||||
if (rcAbs(nbot - bot) <= walkableClimb)
|
||||
{
|
||||
if (nbot < asmin) asmin = nbot;
|
||||
if (nbot > asmax) asmax = nbot;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,6 +135,13 @@ void rcFilterLedgeSpans(const int walkableHeight,
|
||||
// neighbour span is less than the walkableClimb.
|
||||
if (minh < -walkableClimb)
|
||||
s->flags |= RC_LEDGE;
|
||||
|
||||
// If the difference between all neighbours is too large,
|
||||
// we are at steep slope, mark the span as ledge.
|
||||
if ((asmax - asmin) > walkableClimb)
|
||||
{
|
||||
s->flags |= RC_LEDGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,9 +83,9 @@ static void freeSpan(rcHeightfield& hf, rcSpan* ptr)
|
||||
hf.freelist = ptr;
|
||||
}
|
||||
|
||||
static void addSpan(rcHeightfield& hf, int x, int y,
|
||||
unsigned short smin, unsigned short smax,
|
||||
unsigned short flags)
|
||||
static void addSpan(rcHeightfield& hf, const int x, const int y,
|
||||
const unsigned short smin, const unsigned short smax,
|
||||
const unsigned short flags, const int flagMergeThr)
|
||||
{
|
||||
int idx = x + y*hf.width;
|
||||
|
||||
@ -127,8 +127,7 @@ static void addSpan(rcHeightfield& hf, int x, int y,
|
||||
s->smax = cur->smax;
|
||||
|
||||
// Merge flags.
|
||||
// if (s->smax == cur->smax)
|
||||
if (rcAbs((int)s->smax - (int)cur->smax) <= 1)
|
||||
if (rcAbs((int)s->smax - (int)cur->smax) <= flagMergeThr)
|
||||
s->flags |= cur->flags;
|
||||
|
||||
// Remove current span.
|
||||
@ -188,7 +187,8 @@ static int clipPoly(const float* in, int n, float* out, float pnx, float pnz, fl
|
||||
static void rasterizeTri(const float* v0, const float* v1, const float* v2,
|
||||
unsigned char flags, rcHeightfield& hf,
|
||||
const float* bmin, const float* bmax,
|
||||
const float cs, const float ics, const float ich)
|
||||
const float cs, const float ics, const float ich,
|
||||
const int flagMergeThr)
|
||||
{
|
||||
const int w = hf.width;
|
||||
const int h = hf.height;
|
||||
@ -263,19 +263,20 @@ static void rasterizeTri(const float* v0, const float* v1, const float* v2,
|
||||
unsigned short ismin = (unsigned short)rcClamp((int)floorf(smin * ich), 0, 0x7fff);
|
||||
unsigned short ismax = (unsigned short)rcClamp((int)ceilf(smax * ich), 0, 0x7fff);
|
||||
|
||||
addSpan(hf, x, y, ismin, ismax, flags);
|
||||
addSpan(hf, x, y, ismin, ismax, flags, flagMergeThr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rcRasterizeTriangle(const float* v0, const float* v1, const float* v2,
|
||||
unsigned char flags, rcHeightfield& solid)
|
||||
unsigned char flags, rcHeightfield& solid,
|
||||
const int flagMergeThr)
|
||||
{
|
||||
rcTimeVal startTime = rcGetPerformanceTimer();
|
||||
|
||||
const float ics = 1.0f/solid.cs;
|
||||
const float ich = 1.0f/solid.ch;
|
||||
rasterizeTri(v0, v1, v2, flags, solid, solid.bmin, solid.bmax, solid.cs, ics, ich);
|
||||
rasterizeTri(v0, v1, v2, flags, solid, solid.bmin, solid.bmax, solid.cs, ics, ich, flagMergeThr);
|
||||
|
||||
rcTimeVal endTime = rcGetPerformanceTimer();
|
||||
|
||||
@ -285,7 +286,7 @@ void rcRasterizeTriangle(const float* v0, const float* v1, const float* v2,
|
||||
|
||||
void rcRasterizeTriangles(const float* verts, int nv,
|
||||
const int* tris, const unsigned char* flags, int nt,
|
||||
rcHeightfield& solid)
|
||||
rcHeightfield& solid, const int flagMergeThr)
|
||||
{
|
||||
rcTimeVal startTime = rcGetPerformanceTimer();
|
||||
|
||||
@ -298,7 +299,7 @@ void rcRasterizeTriangles(const float* verts, int nv,
|
||||
const float* v1 = &verts[tris[i*3+1]*3];
|
||||
const float* v2 = &verts[tris[i*3+2]*3];
|
||||
// Rasterize.
|
||||
rasterizeTri(v0, v1, v2, flags[i], solid, solid.bmin, solid.bmax, solid.cs, ics, ich);
|
||||
rasterizeTri(v0, v1, v2, flags[i], solid, solid.bmin, solid.bmax, solid.cs, ics, ich, flagMergeThr);
|
||||
}
|
||||
|
||||
rcTimeVal endTime = rcGetPerformanceTimer();
|
||||
@ -309,7 +310,7 @@ void rcRasterizeTriangles(const float* verts, int nv,
|
||||
|
||||
void rcRasterizeTriangles(const float* verts, int nv,
|
||||
const unsigned short* tris, const unsigned char* flags, int nt,
|
||||
rcHeightfield& solid)
|
||||
rcHeightfield& solid, const int flagMergeThr)
|
||||
{
|
||||
rcTimeVal startTime = rcGetPerformanceTimer();
|
||||
|
||||
@ -322,7 +323,7 @@ void rcRasterizeTriangles(const float* verts, int nv,
|
||||
const float* v1 = &verts[tris[i*3+1]*3];
|
||||
const float* v2 = &verts[tris[i*3+2]*3];
|
||||
// Rasterize.
|
||||
rasterizeTri(v0, v1, v2, flags[i], solid, solid.bmin, solid.bmax, solid.cs, ics, ich);
|
||||
rasterizeTri(v0, v1, v2, flags[i], solid, solid.bmin, solid.bmax, solid.cs, ics, ich, flagMergeThr);
|
||||
}
|
||||
|
||||
rcTimeVal endTime = rcGetPerformanceTimer();
|
||||
@ -332,7 +333,7 @@ void rcRasterizeTriangles(const float* verts, int nv,
|
||||
}
|
||||
|
||||
void rcRasterizeTriangles(const float* verts, const unsigned char* flags, int nt,
|
||||
rcHeightfield& solid)
|
||||
rcHeightfield& solid, const int flagMergeThr)
|
||||
{
|
||||
rcTimeVal startTime = rcGetPerformanceTimer();
|
||||
|
||||
@ -345,7 +346,7 @@ void rcRasterizeTriangles(const float* verts, const unsigned char* flags, int nt
|
||||
const float* v1 = &verts[(i*3+1)*3];
|
||||
const float* v2 = &verts[(i*3+2)*3];
|
||||
// Rasterize.
|
||||
rasterizeTri(v0, v1, v2, flags[i], solid, solid.bmin, solid.bmax, solid.cs, ics, ich);
|
||||
rasterizeTri(v0, v1, v2, flags[i], solid, solid.bmin, solid.bmax, solid.cs, ics, ich, flagMergeThr);
|
||||
}
|
||||
|
||||
rcTimeVal endTime = rcGetPerformanceTimer();
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -281,13 +281,14 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>61</integer>
|
||||
<integer>32</integer>
|
||||
<integer>23</integer>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||
<string>{{0, 539}, {358, 643}}</string>
|
||||
<string>{{0, 247}, {358, 643}}</string>
|
||||
</dict>
|
||||
<key>PBXTopSmartGroupGIDs</key>
|
||||
<array/>
|
||||
@ -322,7 +323,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>TestCase.cpp</string>
|
||||
<string>Sample_SoloMeshTiled.cpp</string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@ -330,11 +331,11 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A40F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>TestCase.cpp</string>
|
||||
<string>Sample_SoloMeshTiled.cpp</string>
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>6BF7C24A1111DAC1002B3F46</string>
|
||||
<string>6BF7C3791112FE75002B3F46</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>6B8DE70D10B01BBF00DF20FB</string>
|
||||
@ -348,23 +349,11 @@
|
||||
<string>6B69739F10FFCA4500984788</string>
|
||||
<string>6BCF325F1104CFE7009445BF</string>
|
||||
<string>6BCF33651105BBA2009445BF</string>
|
||||
<string>6BCF33AF1105BE51009445BF</string>
|
||||
<string>6BCF34031105E98C009445BF</string>
|
||||
<string>6BCF341A1105EC43009445BF</string>
|
||||
<string>6B4260301109E1EE00C48C36</string>
|
||||
<string>6BF7BE1F110F0792002B3F46</string>
|
||||
<string>6BF7BE5C110F170A002B3F46</string>
|
||||
<string>6BF7BE5D110F170A002B3F46</string>
|
||||
<string>6BF7BE60110F170A002B3F46</string>
|
||||
<string>6BF7BE75110F1832002B3F46</string>
|
||||
<string>6BF7BE82110F196C002B3F46</string>
|
||||
<string>6BF7C0E311116E74002B3F46</string>
|
||||
<string>6BF7C0E511116E74002B3F46</string>
|
||||
<string>6BF7C0E611116E74002B3F46</string>
|
||||
<string>6BF7C0E711116E74002B3F46</string>
|
||||
<string>6BF7C0E811116E74002B3F46</string>
|
||||
<string>6BF7C0E911116E74002B3F46</string>
|
||||
<string>6BF7C0EA11116E74002B3F46</string>
|
||||
<string>6BF7C0EC11116E74002B3F46</string>
|
||||
<string>6BF7C0ED11116E74002B3F46</string>
|
||||
<string>6BF7C0EE11116E74002B3F46</string>
|
||||
@ -372,23 +361,37 @@
|
||||
<string>6BF7C0F011116E74002B3F46</string>
|
||||
<string>6BF7C0F311116E74002B3F46</string>
|
||||
<string>6BF7C13411118CEB002B3F46</string>
|
||||
<string>6BF7C13511118CEB002B3F46</string>
|
||||
<string>6BF7C14511119BB4002B3F46</string>
|
||||
<string>6BF7C16211119C69002B3F46</string>
|
||||
<string>6BF7C16C11119D8F002B3F46</string>
|
||||
<string>6BF7C1A21111A9C0002B3F46</string>
|
||||
<string>6BF7C1CF1111BCF2002B3F46</string>
|
||||
<string>6BF7C1D01111BCF2002B3F46</string>
|
||||
<string>6BF7C1E21111BD81002B3F46</string>
|
||||
<string>6BF7C1EB1111C0A6002B3F46</string>
|
||||
<string>6BF7C1EC1111C0A6002B3F46</string>
|
||||
<string>6BF7C1ED1111C0A6002B3F46</string>
|
||||
<string>6BF7C1F91111D204002B3F46</string>
|
||||
<string>6BF7C20F1111D361002B3F46</string>
|
||||
<string>6BF7C2421111DAC1002B3F46</string>
|
||||
<string>6BF7C2431111DAC1002B3F46</string>
|
||||
<string>6BF7C2441111DAC1002B3F46</string>
|
||||
<string>6BF7C2451111DAC1002B3F46</string>
|
||||
<string>6BF7C2591112B456002B3F46</string>
|
||||
<string>6BF7C25A1112B456002B3F46</string>
|
||||
<string>6BF7C25B1112B456002B3F46</string>
|
||||
<string>6BF7C2761112BE4F002B3F46</string>
|
||||
<string>6BF7C2851112C348002B3F46</string>
|
||||
<string>6BF7C2A51112D13E002B3F46</string>
|
||||
<string>6BF7C2BD1112D453002B3F46</string>
|
||||
<string>6BF7C2BE1112D453002B3F46</string>
|
||||
<string>6BF7C2BF1112D453002B3F46</string>
|
||||
<string>6BF7C2DB1112D4DA002B3F46</string>
|
||||
<string>6BF7C2EF1112D646002B3F46</string>
|
||||
<string>6BF7C2F51112D716002B3F46</string>
|
||||
<string>6BF7C2F61112D716002B3F46</string>
|
||||
<string>6BF7C3201112DB82002B3F46</string>
|
||||
<string>6BF7C3211112DB82002B3F46</string>
|
||||
<string>6BF7C3281112DDCE002B3F46</string>
|
||||
<string>6BF7C3431112E74B002B3F46</string>
|
||||
<string>6BF7C35D1112EA84002B3F46</string>
|
||||
<string>6BF7C36A1112EB0C002B3F46</string>
|
||||
<string>6BF7C36E1112EB25002B3F46</string>
|
||||
<string>6BF7C3761112FE75002B3F46</string>
|
||||
<string>6BF7C3771112FE75002B3F46</string>
|
||||
</array>
|
||||
<key>prevStack</key>
|
||||
<array>
|
||||
@ -406,7 +409,6 @@
|
||||
<string>6BB7FE1A10F37CF7006DA0A6</string>
|
||||
<string>6BB7FE2110F37CF7006DA0A6</string>
|
||||
<string>6BB7FE2210F37CF7006DA0A6</string>
|
||||
<string>6BB7FE2310F37CF7006DA0A6</string>
|
||||
<string>6BB7FE5410F3817A006DA0A6</string>
|
||||
<string>6BB7FECF10F4B5E1006DA0A6</string>
|
||||
<string>6BB7FF2410F4D699006DA0A6</string>
|
||||
@ -427,7 +429,6 @@
|
||||
<string>6BF7C0F811116E74002B3F46</string>
|
||||
<string>6BF7C0F911116E74002B3F46</string>
|
||||
<string>6BF7C0FA11116E74002B3F46</string>
|
||||
<string>6BF7C0FB11116E74002B3F46</string>
|
||||
<string>6BF7C0FC11116E74002B3F46</string>
|
||||
<string>6BF7C0FD11116E74002B3F46</string>
|
||||
<string>6BF7C0FE11116E74002B3F46</string>
|
||||
@ -457,7 +458,6 @@
|
||||
<string>6BF7C12E11116FFB002B3F46</string>
|
||||
<string>6BF7C13911118CEB002B3F46</string>
|
||||
<string>6BF7C13A11118CEB002B3F46</string>
|
||||
<string>6BF7C14911119BB4002B3F46</string>
|
||||
<string>6BF7C14A11119BB4002B3F46</string>
|
||||
<string>6BF7C14E11119BB4002B3F46</string>
|
||||
<string>6BF7C14F11119BB4002B3F46</string>
|
||||
@ -483,7 +483,6 @@
|
||||
<string>6BF7C1E51111BD81002B3F46</string>
|
||||
<string>6BF7C1EF1111C0A6002B3F46</string>
|
||||
<string>6BF7C1F01111C0A6002B3F46</string>
|
||||
<string>6BF7C1F11111C0A6002B3F46</string>
|
||||
<string>6BF7C1F21111C0A6002B3F46</string>
|
||||
<string>6BF7C15711119BB4002B3F46</string>
|
||||
<string>6BF7C20B1111D299002B3F46</string>
|
||||
@ -507,6 +506,76 @@
|
||||
<string>6BF7C2471111DAC1002B3F46</string>
|
||||
<string>6BF7C2481111DAC1002B3F46</string>
|
||||
<string>6BF7C2491111DAC1002B3F46</string>
|
||||
<string>6BF7C25D1112B456002B3F46</string>
|
||||
<string>6BF7C25E1112B456002B3F46</string>
|
||||
<string>6BF7C25F1112B456002B3F46</string>
|
||||
<string>6BF7C2601112B456002B3F46</string>
|
||||
<string>6BF7C2701112B56F002B3F46</string>
|
||||
<string>6BF7C2791112BE4F002B3F46</string>
|
||||
<string>6BF7C27A1112BE4F002B3F46</string>
|
||||
<string>6BF7C2801112C0EA002B3F46</string>
|
||||
<string>6BF7C28A1112C349002B3F46</string>
|
||||
<string>6BF7C28B1112C349002B3F46</string>
|
||||
<string>6BF7C28C1112C349002B3F46</string>
|
||||
<string>6BF7C28D1112C349002B3F46</string>
|
||||
<string>6BF7C2971112C4A2002B3F46</string>
|
||||
<string>6BF7C2A81112D13E002B3F46</string>
|
||||
<string>6BF7C2A91112D13E002B3F46</string>
|
||||
<string>6BF7C2AA1112D13E002B3F46</string>
|
||||
<string>6BF7C2AB1112D13E002B3F46</string>
|
||||
<string>6BF7C2AC1112D13E002B3F46</string>
|
||||
<string>6BF7C2B31112D395002B3F46</string>
|
||||
<string>6BF7C2B51112D395002B3F46</string>
|
||||
<string>6BF7C2B61112D395002B3F46</string>
|
||||
<string>6BF7C2B71112D395002B3F46</string>
|
||||
<string>6BF7C2B81112D395002B3F46</string>
|
||||
<string>6BF7C2C61112D453002B3F46</string>
|
||||
<string>6BF7C2C71112D453002B3F46</string>
|
||||
<string>6BF7C2C81112D453002B3F46</string>
|
||||
<string>6BF7C2C91112D453002B3F46</string>
|
||||
<string>6BF7C2CB1112D453002B3F46</string>
|
||||
<string>6BF7C2CD1112D453002B3F46</string>
|
||||
<string>6BF7C2CF1112D453002B3F46</string>
|
||||
<string>6BF7C2D01112D453002B3F46</string>
|
||||
<string>6BF7C2D11112D453002B3F46</string>
|
||||
<string>6BF7C2D71112D479002B3F46</string>
|
||||
<string>6BF7C2E21112D520002B3F46</string>
|
||||
<string>6BF7C2E81112D611002B3F46</string>
|
||||
<string>6BF7C2E91112D611002B3F46</string>
|
||||
<string>6BF7C2F11112D646002B3F46</string>
|
||||
<string>6BF7C2F21112D646002B3F46</string>
|
||||
<string>6BF7C2F91112D716002B3F46</string>
|
||||
<string>6BF7C2FA1112D716002B3F46</string>
|
||||
<string>6BF7C3061112D780002B3F46</string>
|
||||
<string>6BF7C30C1112D8C1002B3F46</string>
|
||||
<string>6BF7C30D1112D8C1002B3F46</string>
|
||||
<string>6BF7C3141112DAFB002B3F46</string>
|
||||
<string>6BF7C3161112DAFB002B3F46</string>
|
||||
<string>6BF7C3171112DAFB002B3F46</string>
|
||||
<string>6BF7C3231112DB82002B3F46</string>
|
||||
<string>6BF7C3241112DB82002B3F46</string>
|
||||
<string>6BF7C3251112DB82002B3F46</string>
|
||||
<string>6BF7C32A1112DDCE002B3F46</string>
|
||||
<string>6BF7C3371112E571002B3F46</string>
|
||||
<string>6BF7C33C1112E5D1002B3F46</string>
|
||||
<string>6BF7C3451112E74B002B3F46</string>
|
||||
<string>6BF7C3461112E74B002B3F46</string>
|
||||
<string>6BF7C3471112E74B002B3F46</string>
|
||||
<string>6BF7C3481112E74B002B3F46</string>
|
||||
<string>6BF7C3551112E875002B3F46</string>
|
||||
<string>6BF7C3601112EA84002B3F46</string>
|
||||
<string>6BF7C3611112EA84002B3F46</string>
|
||||
<string>6BF7C3621112EA84002B3F46</string>
|
||||
<string>6BF7C3631112EA84002B3F46</string>
|
||||
<string>6BF7C3641112EA84002B3F46</string>
|
||||
<string>6BF7C3651112EA84002B3F46</string>
|
||||
<string>6BF7C3661112EA84002B3F46</string>
|
||||
<string>6BF7C3671112EA84002B3F46</string>
|
||||
<string>6BF7C3681112EA84002B3F46</string>
|
||||
<string>6BF7C36C1112EB0C002B3F46</string>
|
||||
<string>6BF7C3701112EB25002B3F46</string>
|
||||
<string>6BF7C3711112EB25002B3F46</string>
|
||||
<string>6BF7C3781112FE75002B3F46</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
@ -520,18 +589,18 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {876, 555}}</string>
|
||||
<string>{{0, 0}, {876, 502}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>11 76 1256 702 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXNavigatorGroup</string>
|
||||
<key>Proportion</key>
|
||||
<string>555pt</string>
|
||||
<string>502pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>101pt</string>
|
||||
<string>154pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -599,7 +668,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {876, 74}}</string>
|
||||
<string>{{10, 27}, {876, 127}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>11 76 1256 702 0 0 1280 778 </string>
|
||||
</dict>
|
||||
|
@ -27,9 +27,6 @@ class NavMeshTesterTool : public SampleTool
|
||||
Sample* m_sample;
|
||||
|
||||
dtNavMesh* m_navMesh;
|
||||
float m_agentRadius;
|
||||
float m_agentHeight;
|
||||
float m_agentClimb;
|
||||
|
||||
dtQueryFilter m_filter;
|
||||
|
||||
|
@ -50,8 +50,6 @@ inline bool inRange(const float* v1, const float* v2, const float r, const float
|
||||
NavMeshTesterTool::NavMeshTesterTool() :
|
||||
m_sample(0),
|
||||
m_navMesh(0),
|
||||
m_agentRadius(0),
|
||||
m_agentHeight(0),
|
||||
m_toolMode(TOOLMODE_PATHFIND_ITER),
|
||||
m_startRef(0),
|
||||
m_endRef(0),
|
||||
@ -84,9 +82,6 @@ NavMeshTesterTool::~NavMeshTesterTool()
|
||||
void NavMeshTesterTool::init(Sample* sample)
|
||||
{
|
||||
m_sample = sample;
|
||||
m_agentRadius = sample->getAgentRadius();
|
||||
m_agentHeight = sample->getAgentHeight();
|
||||
m_agentClimb = sample->getAgentClimb();
|
||||
m_navMesh = sample->getNavMesh();
|
||||
recalc();
|
||||
|
||||
@ -494,9 +489,6 @@ static void getPolyCenter(dtNavMesh* navMesh, dtPolyRef ref, float* center)
|
||||
|
||||
void NavMeshTesterTool::handleRender()
|
||||
{
|
||||
if (!m_navMesh)
|
||||
return;
|
||||
|
||||
DebugDrawGL dd;
|
||||
|
||||
static const unsigned int startCol = duRGBA(128,25,0,192);
|
||||
@ -505,11 +497,18 @@ void NavMeshTesterTool::handleRender()
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
if (m_sposSet)
|
||||
drawAgent(m_spos, m_agentRadius, m_agentHeight, 0/*m_agentMaxClimb*/, startCol);
|
||||
if (m_eposSet)
|
||||
drawAgent(m_epos, m_agentRadius, m_agentHeight, 0/*m_agentMaxClimb*/, endCol);
|
||||
const float agentRadius = m_sample->getAgentRadius();
|
||||
const float agentHeight = m_sample->getAgentHeight();
|
||||
const float agentClimb = m_sample->getAgentClimb();
|
||||
|
||||
if (m_sposSet)
|
||||
drawAgent(m_spos, agentRadius, agentHeight, agentClimb, startCol);
|
||||
if (m_eposSet)
|
||||
drawAgent(m_epos, agentRadius, agentHeight, agentClimb, endCol);
|
||||
|
||||
if (!m_navMesh)
|
||||
return;
|
||||
|
||||
if (m_toolMode == TOOLMODE_PATHFIND_ITER)
|
||||
{
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
|
||||
@ -600,19 +599,19 @@ void NavMeshTesterTool::handleRender()
|
||||
const unsigned int hitCol = duRGBA(0,0,0,128);
|
||||
dd.begin(DU_DRAW_LINES, 2.0f);
|
||||
dd.vertex(m_hitPos[0], m_hitPos[1] + 0.4f, m_hitPos[2], hitCol);
|
||||
dd.vertex(m_hitPos[0] + m_hitNormal[0]*m_agentRadius,
|
||||
m_hitPos[1] + 0.4f + m_hitNormal[1]*m_agentRadius,
|
||||
m_hitPos[2] + m_hitNormal[2]*m_agentRadius, hitCol);
|
||||
dd.vertex(m_hitPos[0] + m_hitNormal[0]*agentRadius,
|
||||
m_hitPos[1] + 0.4f + m_hitNormal[1]*agentRadius,
|
||||
m_hitPos[2] + m_hitNormal[2]*agentRadius, hitCol);
|
||||
dd.end();
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL)
|
||||
{
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
|
||||
duDebugDrawCircle(&dd, m_spos[0], m_spos[1]+m_agentHeight/2, m_spos[2], m_distanceToWall, duRGBA(64,16,0,220), 2.0f);
|
||||
duDebugDrawCircle(&dd, m_spos[0], m_spos[1]+agentHeight/2, m_spos[2], m_distanceToWall, duRGBA(64,16,0,220), 2.0f);
|
||||
dd.begin(DU_DRAW_LINES, 3.0f);
|
||||
dd.vertex(m_hitPos[0], m_hitPos[1] + 0.02f, m_hitPos[2], duRGBA(0,0,0,192));
|
||||
dd.vertex(m_hitPos[0], m_hitPos[1] + m_agentHeight, m_hitPos[2], duRGBA(0,0,0,192));
|
||||
dd.vertex(m_hitPos[0], m_hitPos[1] + agentHeight, m_hitPos[2], duRGBA(0,0,0,192));
|
||||
dd.end();
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_AROUND)
|
||||
@ -637,7 +636,7 @@ void NavMeshTesterTool::handleRender()
|
||||
const float dx = m_epos[0] - m_spos[0];
|
||||
const float dz = m_epos[2] - m_spos[2];
|
||||
const float dist = sqrtf(dx*dx + dz*dz);
|
||||
duDebugDrawCircle(&dd, m_spos[0], m_spos[1]+m_agentHeight/2, m_spos[2], dist, duRGBA(64,16,0,220), 2.0f);
|
||||
duDebugDrawCircle(&dd, m_spos[0], m_spos[1]+agentHeight/2, m_spos[2], dist, duRGBA(64,16,0,220), 2.0f);
|
||||
dd.depthMask(true);
|
||||
}
|
||||
}
|
||||
@ -671,6 +670,8 @@ void NavMeshTesterTool::drawAgent(const float* pos, float r, float h, float c, c
|
||||
// Agent dimensions.
|
||||
duDebugDrawCylinderWire(&dd, pos[0]-r, pos[1]+0.02f, pos[2]-r, pos[0]+r, pos[1]+h, pos[2]+r, col, 2.0f);
|
||||
|
||||
duDebugDrawCircle(&dd, pos[0],pos[1]+c,pos[2],r,duRGBA(0,0,0,64),1.0f);
|
||||
|
||||
unsigned int colb = duRGBA(0,0,0,196);
|
||||
dd.begin(DU_DRAW_LINES);
|
||||
dd.vertex(pos[0], pos[1]-c, pos[2], colb);
|
||||
|
@ -349,7 +349,7 @@ bool Sample_SoloMeshSimple::handleBuild()
|
||||
m_cfg.ch = m_cellHeight;
|
||||
m_cfg.walkableSlopeAngle = m_agentMaxSlope;
|
||||
m_cfg.walkableHeight = (int)ceilf(m_agentHeight / m_cfg.ch);
|
||||
m_cfg.walkableClimb = (int)ceilf(m_agentMaxClimb / m_cfg.ch);
|
||||
m_cfg.walkableClimb = (int)floorf(m_agentMaxClimb / m_cfg.ch);
|
||||
m_cfg.walkableRadius = (int)ceilf(m_agentRadius / m_cfg.cs);
|
||||
m_cfg.maxEdgeLen = (int)(m_edgeMaxLen / m_cellSize);
|
||||
m_cfg.maxSimplificationError = m_edgeMaxError;
|
||||
@ -415,7 +415,7 @@ bool Sample_SoloMeshSimple::handleBuild()
|
||||
// the flags for each of the meshes and rasterize them.
|
||||
memset(m_triflags, 0, ntris*sizeof(unsigned char));
|
||||
rcMarkWalkableTriangles(m_cfg.walkableSlopeAngle, verts, nverts, tris, ntris, m_triflags);
|
||||
rcRasterizeTriangles(verts, nverts, tris, m_triflags, ntris, *m_solid);
|
||||
rcRasterizeTriangles(verts, nverts, tris, m_triflags, ntris, *m_solid, m_cfg.walkableClimb);
|
||||
|
||||
if (!m_keepInterResults)
|
||||
{
|
||||
@ -430,6 +430,7 @@ bool Sample_SoloMeshSimple::handleBuild()
|
||||
// Once all geoemtry is rasterized, we do initial pass of filtering to
|
||||
// remove unwanted overhangs caused by the conservative rasterization
|
||||
// as well as filter spans where the character cannot possibly stand.
|
||||
rcFilterLowHangingWalkableObstacles(m_cfg.walkableClimb, *m_solid);
|
||||
rcFilterLedgeSpans(m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid);
|
||||
rcFilterWalkableLowHeightSpans(m_cfg.walkableHeight, *m_solid);
|
||||
|
||||
|
@ -731,11 +731,11 @@ bool Sample_SoloMeshTiled::handleBuild()
|
||||
rcMarkWalkableTriangles(tileCfg.walkableSlopeAngle,
|
||||
verts, nverts, tris, ntris, triangleFlags);
|
||||
|
||||
rcRasterizeTriangles(verts, nverts, tris, triangleFlags, ntris, *solid);
|
||||
rcRasterizeTriangles(verts, nverts, tris, triangleFlags, ntris, *solid, m_cfg.walkableClimb);
|
||||
}
|
||||
|
||||
rcFilterLowHangingWalkableObstacles(m_cfg.walkableClimb, *solid);
|
||||
rcFilterLedgeSpans(tileCfg.walkableHeight, tileCfg.walkableClimb, *solid);
|
||||
|
||||
rcFilterWalkableLowHeightSpans(tileCfg.walkableHeight, *solid);
|
||||
|
||||
chf = new rcCompactHeightfield;
|
||||
|
@ -638,7 +638,7 @@ unsigned char* Sample_TileMesh::buildTileMesh(const float* bmin, const float* bm
|
||||
rcMarkWalkableTriangles(m_cfg.walkableSlopeAngle,
|
||||
verts, nverts, tris, ntris, m_triflags);
|
||||
|
||||
rcRasterizeTriangles(verts, nverts, tris, m_triflags, ntris, *m_solid);
|
||||
rcRasterizeTriangles(verts, nverts, tris, m_triflags, ntris, *m_solid, m_cfg.walkableClimb);
|
||||
}
|
||||
|
||||
if (!m_keepInterResults)
|
||||
@ -650,6 +650,7 @@ unsigned char* Sample_TileMesh::buildTileMesh(const float* bmin, const float* bm
|
||||
// Once all geoemtry is rasterized, we do initial pass of filtering to
|
||||
// remove unwanted overhangs caused by the conservative rasterization
|
||||
// as well as filter spans where the character cannot possibly stand.
|
||||
rcFilterLowHangingWalkableObstacles(m_cfg.walkableClimb, *m_solid);
|
||||
rcFilterLedgeSpans(m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid);
|
||||
rcFilterWalkableLowHeightSpans(m_cfg.walkableHeight, *m_solid);
|
||||
|
||||
@ -772,15 +773,6 @@ unsigned char* Sample_TileMesh::buildTileMesh(const float* bmin, const float* bm
|
||||
rcGetLog()->log(RC_LOG_ERROR, "Too many vertices per tile %d (max: %d).", m_pmesh->nverts, 0xffff);
|
||||
return false;
|
||||
}
|
||||
/* if (m_pmesh->npolys > DT_MAX_TILES)
|
||||
{
|
||||
// If you hit this error, you have too many polygons per tile.
|
||||
// You can trade off tile count to poly count by adjusting DT_TILE_REF_TILE_BITS and DT_TILE_REF_POLY_BITS.
|
||||
// The current setup is optimized for large number of tiles and small number of polys per tile.
|
||||
if (rcGetLog())
|
||||
rcGetLog()->log(RC_LOG_ERROR, "Too many polygons per tile %d (max: %d).", m_pmesh->npolys, DT_MAX_TILES);
|
||||
return false;
|
||||
}*/
|
||||
|
||||
dtNavMeshCreateParams params;
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
|
Loading…
x
Reference in New Issue
Block a user