The ugly and humble beginnings of path following and multi-agent navigation code.
This commit is contained in:
parent
474a3ddc67
commit
7d8fe75de1
@ -83,11 +83,35 @@ inline unsigned int duMultCol(const unsigned int col, const unsigned int d)
|
||||
return duRGBA((r*d) >> 8, (g*d) >> 8, (b*d) >> 8, a);
|
||||
}
|
||||
|
||||
inline unsigned int duDarkenColor(unsigned int col)
|
||||
inline unsigned int duDarkenCol(unsigned int col)
|
||||
{
|
||||
return ((col >> 1) & 0x007f7f7f) | (col & 0xff000000);
|
||||
}
|
||||
|
||||
inline unsigned int duLerpCol(unsigned int ca, unsigned int cb, unsigned int u)
|
||||
{
|
||||
const unsigned int ra = ca & 0xff;
|
||||
const unsigned int ga = (ca >> 8) & 0xff;
|
||||
const unsigned int ba = (ca >> 16) & 0xff;
|
||||
const unsigned int aa = (ca >> 24) & 0xff;
|
||||
const unsigned int rb = cb & 0xff;
|
||||
const unsigned int gb = (cb >> 8) & 0xff;
|
||||
const unsigned int bb = (cb >> 16) & 0xff;
|
||||
const unsigned int ab = (cb >> 24) & 0xff;
|
||||
|
||||
unsigned int r = (ra*(255-u) + rb*u)/255;
|
||||
unsigned int g = (ga*(255-u) + gb*u)/255;
|
||||
unsigned int b = (ba*(255-u) + bb*u)/255;
|
||||
unsigned int a = (aa*(255-u) + ab*u)/255;
|
||||
return duRGBA(r,g,b,a);
|
||||
}
|
||||
|
||||
inline unsigned int duTransCol(unsigned int c, unsigned int a)
|
||||
{
|
||||
return (a<<24) | (c & 0x00ffffff);
|
||||
}
|
||||
|
||||
|
||||
void duCalcBoxColors(unsigned int* colors, unsigned int colTop, unsigned int colSide);
|
||||
|
||||
void duDebugDrawCylinderWire(struct duDebugDraw* dd, float minx, float miny, float minz,
|
||||
@ -100,6 +124,10 @@ void duDebugDrawArc(struct duDebugDraw* dd, const float x0, const float y0, cons
|
||||
const float x1, const float y1, const float z1, const float h,
|
||||
const float as0, const float as1, unsigned int col, const float lineWidth);
|
||||
|
||||
void duDebugDrawArrow(struct duDebugDraw* dd, const float x0, const float y0, const float z0,
|
||||
const float x1, const float y1, const float z1,
|
||||
const float as0, const float as1, unsigned int col, const float lineWidth);
|
||||
|
||||
void duDebugDrawCircle(struct duDebugDraw* dd, const float x, const float y, const float z,
|
||||
const float r, unsigned int col, const float lineWidth);
|
||||
|
||||
@ -128,6 +156,10 @@ void duAppendArc(struct duDebugDraw* dd, const float x0, const float y0, const f
|
||||
const float x1, const float y1, const float z1, const float h,
|
||||
const float as0, const float as1, unsigned int col);
|
||||
|
||||
void duAppendArrow(struct duDebugDraw* dd, const float x0, const float y0, const float z0,
|
||||
const float x1, const float y1, const float z1,
|
||||
const float as0, const float as1, unsigned int col);
|
||||
|
||||
void duAppendCircle(struct duDebugDraw* dd, const float x, const float y, const float z,
|
||||
const float r, unsigned int col);
|
||||
|
||||
|
@ -94,6 +94,17 @@ void duDebugDrawArc(struct duDebugDraw* dd, const float x0, const float y0, cons
|
||||
dd->end();
|
||||
}
|
||||
|
||||
void duDebugDrawArrow(struct duDebugDraw* dd, const float x0, const float y0, const float z0,
|
||||
const float x1, const float y1, const float z1,
|
||||
const float as0, const float as1, unsigned int col, const float lineWidth)
|
||||
{
|
||||
if (!dd) return;
|
||||
|
||||
dd->begin(DU_DRAW_LINES, lineWidth);
|
||||
duAppendArrow(dd, x0,y0,z0, x1,y1,z1, as0, as1, col);
|
||||
dd->end();
|
||||
}
|
||||
|
||||
void duDebugDrawCircle(struct duDebugDraw* dd, const float x, const float y, const float z,
|
||||
const float r, unsigned int col, const float lineWidth)
|
||||
{
|
||||
@ -375,6 +386,23 @@ void duAppendArc(struct duDebugDraw* dd, const float x0, const float y0, const f
|
||||
}
|
||||
}
|
||||
|
||||
void duAppendArrow(struct duDebugDraw* dd, const float x0, const float y0, const float z0,
|
||||
const float x1, const float y1, const float z1,
|
||||
const float as0, const float as1, unsigned int col)
|
||||
{
|
||||
if (!dd) return;
|
||||
|
||||
dd->vertex(x0,y0,z0, col);
|
||||
dd->vertex(x1,y1,z1, col);
|
||||
|
||||
// End arrows
|
||||
const float p[3] = {x0,y0,z0}, q[3] = {x1,y1,z1};
|
||||
if (as0 > 0.001f)
|
||||
appendArrowHead(dd, p, q, as0, col);
|
||||
if (as1 > 0.001f)
|
||||
appendArrowHead(dd, q, p, as1, col);
|
||||
}
|
||||
|
||||
void duAppendCircle(struct duDebugDraw* dd, const float x, const float y, const float z,
|
||||
const float r, unsigned int col)
|
||||
{
|
||||
|
@ -174,7 +174,7 @@ static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtMeshTil
|
||||
if ((flags & DU_DRAWNAVMESH_CLOSEDLIST) && mesh.isInClosedList(base | (dtPolyRef)i))
|
||||
col = duRGBA(255,196,0,220);
|
||||
else
|
||||
col = duDarkenColor(duIntToCol(p->area, 220));
|
||||
col = duDarkenCol(duIntToCol(p->area, 220));
|
||||
|
||||
const dtOffMeshConnection* con = &tile->offMeshCons[i - tile->header->offMeshBase];
|
||||
const float* va = &tile->verts[p->verts[0]*3];
|
||||
|
@ -342,7 +342,7 @@ void duDebugDrawRegionConnections(duDebugDraw* dd, const rcContourSet& cset, con
|
||||
for (int i = 0; i < cset.nconts; ++i)
|
||||
{
|
||||
const rcContour* cont = &cset.conts[i];
|
||||
unsigned int color = duDarkenColor(duIntToCol(cont->reg,a));
|
||||
unsigned int color = duDarkenCol(duIntToCol(cont->reg,a));
|
||||
getContourCenter(cont, orig, cs, ch, pos);
|
||||
dd->vertex(pos, color);
|
||||
}
|
||||
@ -390,7 +390,7 @@ void duDebugDrawRawContours(duDebugDraw* dd, const rcContourSet& cset, const flo
|
||||
for (int i = 0; i < cset.nconts; ++i)
|
||||
{
|
||||
const rcContour& c = cset.conts[i];
|
||||
unsigned int color = duDarkenColor(duIntToCol(c.reg, a));
|
||||
unsigned int color = duDarkenCol(duIntToCol(c.reg, a));
|
||||
|
||||
for (int j = 0; j < c.nrverts; ++j)
|
||||
{
|
||||
@ -455,7 +455,7 @@ void duDebugDrawContours(duDebugDraw* dd, const rcContourSet& cset, const float
|
||||
for (int i = 0; i < cset.nconts; ++i)
|
||||
{
|
||||
const rcContour& c = cset.conts[i];
|
||||
unsigned int color = duDarkenColor(duIntToCol(c.reg, a));
|
||||
unsigned int color = duDarkenCol(duIntToCol(c.reg, a));
|
||||
for (int j = 0; j < c.nverts; ++j)
|
||||
{
|
||||
const int* v = &c.verts[j*4];
|
||||
|
@ -89,6 +89,11 @@ inline void dtVmax(float* mx, const float* v)
|
||||
mx[2] = dtMax(mx[2], v[2]);
|
||||
}
|
||||
|
||||
inline void dtVset(float* dest, const float x, const float y, const float z)
|
||||
{
|
||||
dest[0] = x; dest[1] = y; dest[2] = z;
|
||||
}
|
||||
|
||||
inline void dtVcopy(float* dest, const float* a)
|
||||
{
|
||||
dest[0] = a[0];
|
||||
@ -96,22 +101,46 @@ inline void dtVcopy(float* dest, const float* a)
|
||||
dest[2] = a[2];
|
||||
}
|
||||
|
||||
inline float dtVlen(const float* v)
|
||||
{
|
||||
return dtSqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
|
||||
}
|
||||
|
||||
inline float dtVlenSqr(const float* v)
|
||||
{
|
||||
return v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
|
||||
}
|
||||
|
||||
inline float dtVdist(const float* v1, const float* v2)
|
||||
{
|
||||
float dx = v2[0] - v1[0];
|
||||
float dy = v2[1] - v1[1];
|
||||
float dz = v2[2] - v1[2];
|
||||
const float dx = v2[0] - v1[0];
|
||||
const float dy = v2[1] - v1[1];
|
||||
const float dz = v2[2] - v1[2];
|
||||
return dtSqrt(dx*dx + dy*dy + dz*dz);
|
||||
}
|
||||
|
||||
inline float dtVdistSqr(const float* v1, const float* v2)
|
||||
{
|
||||
float dx = v2[0] - v1[0];
|
||||
float dy = v2[1] - v1[1];
|
||||
float dz = v2[2] - v1[2];
|
||||
const float dx = v2[0] - v1[0];
|
||||
const float dy = v2[1] - v1[1];
|
||||
const float dz = v2[2] - v1[2];
|
||||
return dx*dx + dy*dy + dz*dz;
|
||||
}
|
||||
|
||||
inline float dtVdist2D(const float* v1, const float* v2)
|
||||
{
|
||||
const float dx = v2[0] - v1[0];
|
||||
const float dz = v2[2] - v1[2];
|
||||
return dtSqrt(dx*dx + dz*dz);
|
||||
}
|
||||
|
||||
inline float dtVdist2DSqr(const float* v1, const float* v2)
|
||||
{
|
||||
const float dx = v2[0] - v1[0];
|
||||
const float dz = v2[2] - v1[2];
|
||||
return dx*dx + dz*dz;
|
||||
}
|
||||
|
||||
inline void dtVnormalize(float* v)
|
||||
{
|
||||
float d = 1.0f / dtSqrt(dtSqr(v[0]) + dtSqr(v[1]) + dtSqr(v[2]));
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -283,14 +283,13 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>15</integer>
|
||||
<integer>11</integer>
|
||||
<integer>65</integer>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||
<string>{{0, 49}, {264, 632}}</string>
|
||||
<string>{{0, 658}, {264, 632}}</string>
|
||||
</dict>
|
||||
<key>PBXTopSmartGroupGIDs</key>
|
||||
<array/>
|
||||
@ -325,7 +324,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>DetourNavMesh.cpp</string>
|
||||
<string>CrowdTool.cpp</string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@ -333,19 +332,16 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A40F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>DetourNavMesh.cpp</string>
|
||||
<string>CrowdTool.cpp</string>
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>6BAF3C56121163FD008CFCDF</string>
|
||||
<string>6BAF40B8121425BA008CFCDF</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>6BBB4AA1115B4F3400CF791D</string>
|
||||
<string>6BBB4AA5115B4F3400CF791D</string>
|
||||
<string>6BBB4AA6115B4F3400CF791D</string>
|
||||
<string>6BBB4AAB115B4F3400CF791D</string>
|
||||
<string>6BBB4AB0115B4F3400CF791D</string>
|
||||
<string>6BBB4AB2115B4F3400CF791D</string>
|
||||
<string>6BBB4ABF115B4F3400CF791D</string>
|
||||
<string>6BBB4C34115B7A3D00CF791D</string>
|
||||
<string>6BF5F27011747CFA000502A6</string>
|
||||
@ -354,9 +350,7 @@
|
||||
<string>6BF5F2E511748884000502A6</string>
|
||||
<string>6BF5F2E611748884000502A6</string>
|
||||
<string>6BF5F2E711748884000502A6</string>
|
||||
<string>6BF5F31C117490A1000502A6</string>
|
||||
<string>6BF5F32E11759C3C000502A6</string>
|
||||
<string>6BF5F474117644A2000502A6</string>
|
||||
<string>6BF5F5041176F5F8000502A6</string>
|
||||
<string>6B4214D911803923006C347B</string>
|
||||
<string>6B2CDC911197F0720090FA4D</string>
|
||||
@ -371,50 +365,56 @@
|
||||
<string>6B98482611E9D23600FA177B</string>
|
||||
<string>6BF9B12C11EB8CF20043574C</string>
|
||||
<string>6BF9B12F11EB8CF20043574C</string>
|
||||
<string>6BF9B13511EB8CF20043574C</string>
|
||||
<string>6BF9B13611EB8CF20043574C</string>
|
||||
<string>6BF9B13711EB8CF20043574C</string>
|
||||
<string>6BF9B18811EC2D470043574C</string>
|
||||
<string>6BF9B20B11EC450E0043574C</string>
|
||||
<string>6BF9B21211EC49A30043574C</string>
|
||||
<string>6BF9B21B11EC49F90043574C</string>
|
||||
<string>6BAF37D411FEAC16008CFCDF</string>
|
||||
<string>6BAF37F911FEB4BB008CFCDF</string>
|
||||
<string>6BAF382112019EDA008CFCDF</string>
|
||||
<string>6BAF38471202CC9B008CFCDF</string>
|
||||
<string>6BAF385A120A8A8E008CFCDF</string>
|
||||
<string>6BAF385C120A8A8E008CFCDF</string>
|
||||
<string>6BAF3873120AD32F008CFCDF</string>
|
||||
<string>6BAF3875120AD32F008CFCDF</string>
|
||||
<string>6BAF390F120FEB27008CFCDF</string>
|
||||
<string>6BAF39D112100A22008CFCDF</string>
|
||||
<string>6BAF39D212100A22008CFCDF</string>
|
||||
<string>6BAF39E712100DE4008CFCDF</string>
|
||||
<string>6BAF3A5F12102BB9008CFCDF</string>
|
||||
<string>6BAF3A7812103373008CFCDF</string>
|
||||
<string>6BAF3AAB1210369A008CFCDF</string>
|
||||
<string>6BAF3AB4121038F9008CFCDF</string>
|
||||
<string>6BAF3AB5121038F9008CFCDF</string>
|
||||
<string>6BAF3ADA12112A65008CFCDF</string>
|
||||
<string>6BAF3B0112112E63008CFCDF</string>
|
||||
<string>6BAF3B0312112E63008CFCDF</string>
|
||||
<string>6BAF3B3F121137C7008CFCDF</string>
|
||||
<string>6BAF3BA51211425E008CFCDF</string>
|
||||
<string>6BAF3BA912114288008CFCDF</string>
|
||||
<string>6BAF3BAF12114389008CFCDF</string>
|
||||
<string>6BAF3BB012114389008CFCDF</string>
|
||||
<string>6BAF3BB8121146D8008CFCDF</string>
|
||||
<string>6BAF3BB9121146D8008CFCDF</string>
|
||||
<string>6BAF3BC91211472E008CFCDF</string>
|
||||
<string>6BAF3BFE121151C3008CFCDF</string>
|
||||
<string>6BAF3C4312116225008CFCDF</string>
|
||||
<string>6BAF3C78121167CA008CFCDF</string>
|
||||
<string>6BAF3C7D121167CA008CFCDF</string>
|
||||
<string>6BAF3CB012116AD9008CFCDF</string>
|
||||
<string>6BAF3CB112116AD9008CFCDF</string>
|
||||
<string>6BAF3CB212116AD9008CFCDF</string>
|
||||
<string>6BAF3CB412116AD9008CFCDF</string>
|
||||
<string>6BAF3CB712116AD9008CFCDF</string>
|
||||
<string>6BAF3CB812116AD9008CFCDF</string>
|
||||
<string>6BAF3D3012117A05008CFCDF</string>
|
||||
<string>6BAF3D3E12117B40008CFCDF</string>
|
||||
<string>6BAF3DA51211882E008CFCDF</string>
|
||||
<string>6BAF3DFC1211AEB2008CFCDF</string>
|
||||
<string>6BAF3E421211B19C008CFCDF</string>
|
||||
<string>6BAF3E781212869F008CFCDF</string>
|
||||
<string>6BAF3EE01212B890008CFCDF</string>
|
||||
<string>6BAF3F5B1213E45B008CFCDF</string>
|
||||
<string>6BAF3FBD1213FABE008CFCDF</string>
|
||||
<string>6BAF3FFC121401AB008CFCDF</string>
|
||||
<string>6BAF404F12140B4E008CFCDF</string>
|
||||
<string>6BAF405012140B4E008CFCDF</string>
|
||||
<string>6BAF405112140B4E008CFCDF</string>
|
||||
<string>6BAF405212140B4E008CFCDF</string>
|
||||
<string>6BAF405312140B4E008CFCDF</string>
|
||||
<string>6BAF409312142142008CFCDF</string>
|
||||
<string>6BAF409512142142008CFCDF</string>
|
||||
<string>6BAF40AB1214239C008CFCDF</string>
|
||||
<string>6BAF40AC1214239C008CFCDF</string>
|
||||
</array>
|
||||
<key>prevStack</key>
|
||||
<array>
|
||||
<string>6BBB4AD3115B4F3400CF791D</string>
|
||||
<string>6BBB4AE0115B4F3400CF791D</string>
|
||||
<string>6BBB4AE1115B4F3400CF791D</string>
|
||||
<string>6BBB4AE2115B4F3400CF791D</string>
|
||||
<string>6BBB4AE6115B4F3400CF791D</string>
|
||||
<string>6BBB4AE7115B4F3400CF791D</string>
|
||||
<string>6BBB4AE8115B4F3400CF791D</string>
|
||||
@ -427,7 +427,6 @@
|
||||
<string>6BBB4AEF115B4F3400CF791D</string>
|
||||
<string>6BBB4AF0115B4F3400CF791D</string>
|
||||
<string>6BBB4AF1115B4F3400CF791D</string>
|
||||
<string>6BBB4AF7115B4F3400CF791D</string>
|
||||
<string>6BBB4AF8115B4F3400CF791D</string>
|
||||
<string>6BBB4AF9115B4F3400CF791D</string>
|
||||
<string>6BBB4AFA115B4F3400CF791D</string>
|
||||
@ -444,8 +443,6 @@
|
||||
<string>6BF5F2EE11748884000502A6</string>
|
||||
<string>6BF5F33911759C3C000502A6</string>
|
||||
<string>6B4215D1118066FE006C347B</string>
|
||||
<string>6B4215DF1180672F006C347B</string>
|
||||
<string>6B5562681193EF2F00843384</string>
|
||||
<string>6B10005C11AD08FA0098A59A</string>
|
||||
<string>6B10011E11AD19F90098A59A</string>
|
||||
<string>6B10011F11AD19F90098A59A</string>
|
||||
@ -481,7 +478,6 @@
|
||||
<string>6BAF3878120AD32F008CFCDF</string>
|
||||
<string>6BAF3879120AD32F008CFCDF</string>
|
||||
<string>6BAF387A120AD32F008CFCDF</string>
|
||||
<string>6BAF387B120AD32F008CFCDF</string>
|
||||
<string>6BAF38B9120ADE23008CFCDF</string>
|
||||
<string>6BAF38BF120ADE8A008CFCDF</string>
|
||||
<string>6BAF38C4120ADF7B008CFCDF</string>
|
||||
@ -496,8 +492,6 @@
|
||||
<string>6BAF3919120FEB27008CFCDF</string>
|
||||
<string>6BAF391B120FEB27008CFCDF</string>
|
||||
<string>6BAF391C120FEB27008CFCDF</string>
|
||||
<string>6BBB4AD2115B4F3400CF791D</string>
|
||||
<string>6BAF3974120FF609008CFCDF</string>
|
||||
<string>6BAF3983120FF75F008CFCDF</string>
|
||||
<string>6BAF398E120FF809008CFCDF</string>
|
||||
<string>6BAF3990120FF809008CFCDF</string>
|
||||
@ -513,48 +507,25 @@
|
||||
<string>6BAF3A4F121028E6008CFCDF</string>
|
||||
<string>6BAF3A50121028E6008CFCDF</string>
|
||||
<string>6BAF3A51121028E6008CFCDF</string>
|
||||
<string>6BAF3A6212102BB9008CFCDF</string>
|
||||
<string>6BAF3A6312102BB9008CFCDF</string>
|
||||
<string>6BAF3A6512102BB9008CFCDF</string>
|
||||
<string>6BAF3A6612102BB9008CFCDF</string>
|
||||
<string>6BAF3A7C12103373008CFCDF</string>
|
||||
<string>6BAF3A7D12103373008CFCDF</string>
|
||||
<string>6BAF3A7E12103373008CFCDF</string>
|
||||
<string>6BAF3A7F12103373008CFCDF</string>
|
||||
<string>6BAF3A8012103373008CFCDF</string>
|
||||
<string>6BAF3A8212103373008CFCDF</string>
|
||||
<string>6BAF3A8412103373008CFCDF</string>
|
||||
<string>6BAF3A8512103373008CFCDF</string>
|
||||
<string>6BAF3A8612103373008CFCDF</string>
|
||||
<string>6BAF3A8712103373008CFCDF</string>
|
||||
<string>6BAF3A8812103373008CFCDF</string>
|
||||
<string>6BAF3A8912103373008CFCDF</string>
|
||||
<string>6BAF3A8A12103373008CFCDF</string>
|
||||
<string>6BAF3A8B12103373008CFCDF</string>
|
||||
<string>6BAF3A8C12103373008CFCDF</string>
|
||||
<string>6BAF3A8D12103373008CFCDF</string>
|
||||
<string>6BAF3A8E12103373008CFCDF</string>
|
||||
<string>6BAF3A8F12103373008CFCDF</string>
|
||||
<string>6BAF3A9012103373008CFCDF</string>
|
||||
<string>6BAF3A9112103373008CFCDF</string>
|
||||
<string>6BAF3A9212103373008CFCDF</string>
|
||||
<string>6BAF3A9312103373008CFCDF</string>
|
||||
<string>6BAF3A9512103373008CFCDF</string>
|
||||
<string>6BAF3A9612103373008CFCDF</string>
|
||||
<string>6BAF3AB7121038F9008CFCDF</string>
|
||||
<string>6BAF3AB8121038F9008CFCDF</string>
|
||||
<string>6BAF3AB9121038F9008CFCDF</string>
|
||||
<string>6BAF3ABA121038F9008CFCDF</string>
|
||||
<string>6BAF3ABB121038F9008CFCDF</string>
|
||||
<string>6BAF3ABC121038F9008CFCDF</string>
|
||||
<string>6BAF3ABD121038F9008CFCDF</string>
|
||||
<string>6BAF3ACB12112937008CFCDF</string>
|
||||
<string>6BAF3ADD12112A65008CFCDF</string>
|
||||
<string>6BAF3ADE12112A65008CFCDF</string>
|
||||
<string>6BAF3ADF12112A65008CFCDF</string>
|
||||
<string>6BAF3AE012112A65008CFCDF</string>
|
||||
<string>6BAF3AE912112BBF008CFCDF</string>
|
||||
<string>6BAF3AF512112C6C008CFCDF</string>
|
||||
<string>6BAF3B0512112E63008CFCDF</string>
|
||||
<string>6BAF3B0612112E63008CFCDF</string>
|
||||
<string>6BAF3B1512112F65008CFCDF</string>
|
||||
@ -571,17 +542,72 @@
|
||||
<string>6BAF3B6F12113E1F008CFCDF</string>
|
||||
<string>6BAF3BA71211425E008CFCDF</string>
|
||||
<string>6BAF3BAB12114288008CFCDF</string>
|
||||
<string>6BAF3BB212114389008CFCDF</string>
|
||||
<string>6BAF3BB312114389008CFCDF</string>
|
||||
<string>6BAF3BBB121146D8008CFCDF</string>
|
||||
<string>6BAF3BBC121146D8008CFCDF</string>
|
||||
<string>6BAF3BC212114716008CFCDF</string>
|
||||
<string>6BAF3BC312114716008CFCDF</string>
|
||||
<string>6BAF3BCB1211472E008CFCDF</string>
|
||||
<string>6BAF3BDC12114B45008CFCDF</string>
|
||||
<string>6BAF3BDD12114B45008CFCDF</string>
|
||||
<string>6BAF3C00121151C3008CFCDF</string>
|
||||
<string>6BAF3C01121151C3008CFCDF</string>
|
||||
<string>6BAF3C6512116712008CFCDF</string>
|
||||
<string>6BAF3C6A12116712008CFCDF</string>
|
||||
<string>6BAF3C6B12116712008CFCDF</string>
|
||||
<string>6BAF3C6C12116712008CFCDF</string>
|
||||
<string>6BAF3C6D12116712008CFCDF</string>
|
||||
<string>6BAF3C81121167CA008CFCDF</string>
|
||||
<string>6BAF3C82121167CA008CFCDF</string>
|
||||
<string>6BAF3C84121167CA008CFCDF</string>
|
||||
<string>6BAF3C87121167CA008CFCDF</string>
|
||||
<string>6BAF3C88121167CA008CFCDF</string>
|
||||
<string>6BAF3C89121167CA008CFCDF</string>
|
||||
<string>6BAF3C8B121167CA008CFCDF</string>
|
||||
<string>6BAF3C8C121167CA008CFCDF</string>
|
||||
<string>6BAF3C8D121167CA008CFCDF</string>
|
||||
<string>6BAF3C8E121167CA008CFCDF</string>
|
||||
<string>6BAF3CBB12116AD9008CFCDF</string>
|
||||
<string>6BAF3CBD12116AD9008CFCDF</string>
|
||||
<string>6BAF3CBF12116AD9008CFCDF</string>
|
||||
<string>6BAF3CC312116AD9008CFCDF</string>
|
||||
<string>6BAF3CC412116AD9008CFCDF</string>
|
||||
<string>6BAF3CC512116AD9008CFCDF</string>
|
||||
<string>6BAF3CC712116AD9008CFCDF</string>
|
||||
<string>6BAF3CCA12116AD9008CFCDF</string>
|
||||
<string>6BAF3CCB12116AD9008CFCDF</string>
|
||||
<string>6BAF3CCC12116AD9008CFCDF</string>
|
||||
<string>6BAF3CCD12116AD9008CFCDF</string>
|
||||
<string>6BAF3CCE12116AD9008CFCDF</string>
|
||||
<string>6B4215DF1180672F006C347B</string>
|
||||
<string>6BAF3D3312117A05008CFCDF</string>
|
||||
<string>6BAF3D4212117B40008CFCDF</string>
|
||||
<string>6BAF3DAA1211882E008CFCDF</string>
|
||||
<string>6BAF3E2A1211AF3A008CFCDF</string>
|
||||
<string>6BAF3E441211B19C008CFCDF</string>
|
||||
<string>6BAF3E631211B713008CFCDF</string>
|
||||
<string>6BAF3EE41212B890008CFCDF</string>
|
||||
<string>6BAF3F5F1213E45B008CFCDF</string>
|
||||
<string>6BBB4AE2115B4F3400CF791D</string>
|
||||
<string>6BBB4AF7115B4F3400CF791D</string>
|
||||
<string>6BAF405612140B4E008CFCDF</string>
|
||||
<string>6BAF405712140B4E008CFCDF</string>
|
||||
<string>6BAF405812140B4E008CFCDF</string>
|
||||
<string>6BAF405912140B4E008CFCDF</string>
|
||||
<string>6BAF407212141245008CFCDF</string>
|
||||
<string>6BAF407412141245008CFCDF</string>
|
||||
<string>6BAF407612141245008CFCDF</string>
|
||||
<string>6BAF408412141303008CFCDF</string>
|
||||
<string>6BAF409712142142008CFCDF</string>
|
||||
<string>6BAF409812142142008CFCDF</string>
|
||||
<string>6BAF409912142142008CFCDF</string>
|
||||
<string>6BAF409A12142142008CFCDF</string>
|
||||
<string>6BAF409B12142142008CFCDF</string>
|
||||
<string>6BAF409C12142142008CFCDF</string>
|
||||
<string>6BAF409D12142142008CFCDF</string>
|
||||
<string>6BAF40A612142254008CFCDF</string>
|
||||
<string>6BAF40A712142254008CFCDF</string>
|
||||
<string>6BAF40AD1214239C008CFCDF</string>
|
||||
<string>6BAF40AE1214239C008CFCDF</string>
|
||||
<string>6BAF40AF1214239C008CFCDF</string>
|
||||
<string>6BAF40B01214239C008CFCDF</string>
|
||||
<string>6BAF40B11214239C008CFCDF</string>
|
||||
<string>6BAF40B21214239C008CFCDF</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
@ -595,18 +621,18 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {887, 558}}</string>
|
||||
<string>{{0, 0}, {887, 498}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>34 87 1173 691 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXNavigatorGroup</string>
|
||||
<key>Proportion</key>
|
||||
<string>558pt</string>
|
||||
<string>498pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>88pt</string>
|
||||
<string>148pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -636,7 +662,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {887, 61}}</string>
|
||||
<string>{{10, 27}, {887, 87}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXProjectFindModule</string>
|
||||
@ -674,7 +700,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {887, 61}}</string>
|
||||
<string>{{10, 27}, {887, 121}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>34 87 1173 691 0 0 1280 778 </string>
|
||||
</dict>
|
||||
@ -759,12 +785,12 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {1173, 323}}</string>
|
||||
<string>{{0, 0}, {1173, 277}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXDebugCLIModule</string>
|
||||
<key>Proportion</key>
|
||||
<string>323pt</string>
|
||||
<string>277pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ContentConfiguration</key>
|
||||
@ -783,8 +809,8 @@
|
||||
<string>yes</string>
|
||||
<key>sizes</key>
|
||||
<array>
|
||||
<string>{{0, 0}, {536, 112}}</string>
|
||||
<string>{{536, 0}, {637, 112}}</string>
|
||||
<string>{{0, 0}, {529, 90}}</string>
|
||||
<string>{{529, 0}, {644, 90}}</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>VerticalSplitView</key>
|
||||
@ -799,8 +825,8 @@
|
||||
<string>yes</string>
|
||||
<key>sizes</key>
|
||||
<array>
|
||||
<string>{{0, 0}, {1173, 112}}</string>
|
||||
<string>{{0, 112}, {1173, 210}}</string>
|
||||
<string>{{0, 0}, {1173, 90}}</string>
|
||||
<string>{{0, 90}, {1173, 278}}</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
@ -820,7 +846,7 @@
|
||||
<key>DebugSTDIOWindowFrame</key>
|
||||
<string>{{200, 200}, {500, 300}}</string>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 328}, {1173, 322}}</string>
|
||||
<string>{{0, 282}, {1173, 368}}</string>
|
||||
<key>PBXDebugSessionStackFrameViewKey</key>
|
||||
<dict>
|
||||
<key>DebugVariablesTableConfiguration</key>
|
||||
@ -830,16 +856,16 @@
|
||||
<string>Value</string>
|
||||
<real>85</real>
|
||||
<string>Summary</string>
|
||||
<real>344</real>
|
||||
<real>351</real>
|
||||
</array>
|
||||
<key>Frame</key>
|
||||
<string>{{536, 0}, {637, 112}}</string>
|
||||
<string>{{529, 0}, {644, 90}}</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXDebugSessionModule</string>
|
||||
<key>Proportion</key>
|
||||
<string>322pt</string>
|
||||
<string>368pt</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Name</key>
|
||||
|
@ -37,6 +37,7 @@
|
||||
6B9846EF11E718F800FA177B /* DetourAlloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B9846EE11E718F800FA177B /* DetourAlloc.cpp */; };
|
||||
6B9847B811E7519A00FA177B /* RecastAlloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B9847B711E7519A00FA177B /* RecastAlloc.cpp */; };
|
||||
6BA1E88B10C7BFC9008007F6 /* Sample_SoloMeshSimple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BA1E88810C7BFC9008007F6 /* Sample_SoloMeshSimple.cpp */; };
|
||||
6BAF3C591211663A008CFCDF /* CrowdTool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BAF3C581211663A008CFCDF /* CrowdTool.cpp */; };
|
||||
6BB788170FC0472B003C24DB /* ChunkyTriMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB788160FC0472B003C24DB /* ChunkyTriMesh.cpp */; };
|
||||
6BB7FC0B10EBB6AA006DA0A6 /* NavMeshTesterTool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB7FC0A10EBB6AA006DA0A6 /* NavMeshTesterTool.cpp */; };
|
||||
6BB7FDA510F36F0E006DA0A6 /* InputGeom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB7FDA410F36F0E006DA0A6 /* InputGeom.cpp */; };
|
||||
@ -110,6 +111,8 @@
|
||||
6B9847B711E7519A00FA177B /* RecastAlloc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastAlloc.cpp; path = ../../../Recast/Source/RecastAlloc.cpp; sourceTree = SOURCE_ROOT; };
|
||||
6BA1E88810C7BFC9008007F6 /* Sample_SoloMeshSimple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Sample_SoloMeshSimple.cpp; path = ../../Source/Sample_SoloMeshSimple.cpp; sourceTree = SOURCE_ROOT; };
|
||||
6BA1E88E10C7BFD3008007F6 /* Sample_SoloMeshSimple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sample_SoloMeshSimple.h; path = ../../Include/Sample_SoloMeshSimple.h; sourceTree = SOURCE_ROOT; };
|
||||
6BAF3C571211663A008CFCDF /* CrowdTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CrowdTool.h; path = ../../Include/CrowdTool.h; sourceTree = SOURCE_ROOT; };
|
||||
6BAF3C581211663A008CFCDF /* CrowdTool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CrowdTool.cpp; path = ../../Source/CrowdTool.cpp; 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; };
|
||||
6BB7FC0910EBB6AA006DA0A6 /* NavMeshTesterTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NavMeshTesterTool.h; path = ../../Include/NavMeshTesterTool.h; sourceTree = SOURCE_ROOT; };
|
||||
@ -295,6 +298,8 @@
|
||||
6BB7FE8E10F4A175006DA0A6 /* Tools */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6BAF3C571211663A008CFCDF /* CrowdTool.h */,
|
||||
6BAF3C581211663A008CFCDF /* CrowdTool.cpp */,
|
||||
6B324C64111C5D9A00EBD2FD /* ConvexVolumeTool.h */,
|
||||
6B324C65111C5D9A00EBD2FD /* ConvexVolumeTool.cpp */,
|
||||
6BCF32341104CD05009445BF /* OffMeshConnectionTool.h */,
|
||||
@ -431,6 +436,7 @@
|
||||
6B98463311E6144400FA177B /* Sample_SoloMeshTiled.cpp in Sources */,
|
||||
6B9846EF11E718F800FA177B /* DetourAlloc.cpp in Sources */,
|
||||
6B9847B811E7519A00FA177B /* RecastAlloc.cpp in Sources */,
|
||||
6BAF3C591211663A008CFCDF /* CrowdTool.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -44,8 +44,9 @@ public:
|
||||
virtual void init(Sample* sample);
|
||||
virtual void reset();
|
||||
virtual void handleMenu();
|
||||
virtual void handleClick(const float* p, bool shift);
|
||||
virtual void handleClick(const float* s, const float* p, bool shift);
|
||||
virtual void handleStep();
|
||||
virtual void handleUpdate(const float dt);
|
||||
virtual void handleRender();
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view);
|
||||
};
|
||||
|
190
RecastDemo/Include/CrowdTool.h
Normal file
190
RecastDemo/Include/CrowdTool.h
Normal file
@ -0,0 +1,190 @@
|
||||
//
|
||||
// Copyright (c) 2009-2010 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 CROWDTOOL_H
|
||||
#define CROWDTOOL_H
|
||||
|
||||
#include "Sample.h"
|
||||
#include "DetourNavMesh.h"
|
||||
|
||||
// Tool to create crowds.
|
||||
|
||||
|
||||
enum BodyType
|
||||
{
|
||||
BODY_CIRCLE = 0,
|
||||
BODY_CAPSULE = 1,
|
||||
};
|
||||
|
||||
struct Body
|
||||
{
|
||||
float p[3], q[3]; // Position of the obstacle
|
||||
float vel[3]; // Velocity of the obstacle
|
||||
float dvel[3]; // Velocity of the obstacle
|
||||
float rad; // Radius of the obstacle
|
||||
int type; // Type of the obstacle (see ObstacleType)
|
||||
};
|
||||
|
||||
|
||||
static const int RVO_SAMPLE_RAD = 15;
|
||||
static const int MAX_RVO_SAMPLES = (RVO_SAMPLE_RAD*2+1)*(RVO_SAMPLE_RAD*2+1) + 100;
|
||||
|
||||
struct RVO
|
||||
{
|
||||
inline RVO() : ns(0) {}
|
||||
float spos[MAX_RVO_SAMPLES*3];
|
||||
float scs[MAX_RVO_SAMPLES];
|
||||
float spen[MAX_RVO_SAMPLES];
|
||||
float svpen[MAX_RVO_SAMPLES];
|
||||
float svcpen[MAX_RVO_SAMPLES];
|
||||
float sspen[MAX_RVO_SAMPLES];
|
||||
float stpen[MAX_RVO_SAMPLES];
|
||||
|
||||
int ns;
|
||||
};
|
||||
|
||||
enum AgentTargetState
|
||||
{
|
||||
AGENT_TARGET_NONE = 0,
|
||||
AGENT_TARGET_SET = 1,
|
||||
AGENT_TARGET_ACQUIRED = 2,
|
||||
AGENT_TARGET_PATH = 3,
|
||||
AGENT_TARGET_FAILED = 4,
|
||||
};
|
||||
|
||||
static const int AGENT_MAX_PATH = 256;
|
||||
static const int AGENT_MAX_CORNERS = 4;
|
||||
static const int AGENT_MAX_TRAIL = 64;
|
||||
static const int AGENT_MAX_COLSEGS = 32;
|
||||
|
||||
enum AgentApproach
|
||||
{
|
||||
AGENT_APPROACH_CORNER = 0,
|
||||
AGENT_APPROACH_OFFMESH_CON = 0,
|
||||
AGENT_APPROACH_END = 0,
|
||||
};
|
||||
|
||||
struct Agent
|
||||
{
|
||||
float pos[3];
|
||||
float radius, height;
|
||||
|
||||
float dvel[3];
|
||||
float nvel[3];
|
||||
float vel[3];
|
||||
float npos[3];
|
||||
float disp[3];
|
||||
|
||||
float maxspeed;
|
||||
float t;
|
||||
float var;
|
||||
|
||||
RVO rvo;
|
||||
|
||||
float colradius;
|
||||
float colcenter[3];
|
||||
float colsegs[AGENT_MAX_COLSEGS*6];
|
||||
int ncolsegs;
|
||||
|
||||
float trail[AGENT_MAX_TRAIL*3];
|
||||
int htrail;
|
||||
|
||||
unsigned char targetState;
|
||||
float target[3];
|
||||
dtPolyRef targetRef;
|
||||
|
||||
dtPolyRef path[AGENT_MAX_PATH];
|
||||
int npath;
|
||||
float corners[AGENT_MAX_CORNERS*3];
|
||||
int ncorners;
|
||||
|
||||
unsigned char active;
|
||||
};
|
||||
|
||||
enum UpdateFlags
|
||||
{
|
||||
CROWDMAN_ANTICIPATE_TURNS = 1,
|
||||
CROWDMAN_USE_VO = 2,
|
||||
CROWDMAN_DRUNK = 4,
|
||||
};
|
||||
|
||||
class CrowdManager
|
||||
{
|
||||
static const int MAX_AGENTS = 32;
|
||||
Agent m_agents[MAX_AGENTS];
|
||||
int m_shortcutIter;
|
||||
public:
|
||||
CrowdManager();
|
||||
~CrowdManager();
|
||||
|
||||
void reset();
|
||||
const Agent* getAgent(const int idx);
|
||||
const int getAgentCount() const;
|
||||
int addAgent(const float* pos, const float radius, const float height);
|
||||
void removeAgent(const int idx);
|
||||
void setMoveTarget(const int idx, const float* pos);
|
||||
|
||||
void update(const float dt, unsigned int flags, dtNavMesh* nmesh);
|
||||
};
|
||||
|
||||
class CrowdTool : public SampleTool
|
||||
{
|
||||
Sample* m_sample;
|
||||
float m_targetPos[3];
|
||||
bool m_targetPosSet;
|
||||
|
||||
bool m_expandDebugDraw;
|
||||
bool m_showLabels;
|
||||
bool m_showCorners;
|
||||
bool m_showTargets;
|
||||
bool m_showCollisionSegments;
|
||||
bool m_showPath;
|
||||
bool m_showVO;
|
||||
|
||||
bool m_expandOptions;
|
||||
bool m_anticipateTurns;
|
||||
bool m_useVO;
|
||||
bool m_drunkMove;
|
||||
|
||||
bool m_run;
|
||||
|
||||
CrowdManager m_crowd;
|
||||
|
||||
enum ToolMode
|
||||
{
|
||||
TOOLMODE_CREATE,
|
||||
TOOLMODE_MOVE,
|
||||
};
|
||||
ToolMode m_mode;
|
||||
|
||||
public:
|
||||
CrowdTool();
|
||||
~CrowdTool();
|
||||
|
||||
virtual int type() { return TOOL_CROWD; }
|
||||
virtual void init(Sample* sample);
|
||||
virtual void reset();
|
||||
virtual void handleMenu();
|
||||
virtual void handleClick(const float* s, const float* p, bool shift);
|
||||
virtual void handleStep();
|
||||
virtual void handleUpdate(const float dt);
|
||||
virtual void handleRender();
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view);
|
||||
};
|
||||
|
||||
#endif // CROWDTOOL_H
|
@ -87,8 +87,9 @@ public:
|
||||
virtual void init(Sample* sample);
|
||||
virtual void reset();
|
||||
virtual void handleMenu();
|
||||
virtual void handleClick(const float* p, bool shift);
|
||||
virtual void handleClick(const float* s, const float* p, bool shift);
|
||||
virtual void handleStep();
|
||||
virtual void handleUpdate(const float dt);
|
||||
virtual void handleRender();
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view);
|
||||
|
||||
|
@ -39,8 +39,9 @@ public:
|
||||
virtual void init(Sample* sample);
|
||||
virtual void reset();
|
||||
virtual void handleMenu();
|
||||
virtual void handleClick(const float* p, bool shift);
|
||||
virtual void handleClick(const float* s, const float* p, bool shift);
|
||||
virtual void handleStep();
|
||||
virtual void handleUpdate(const float dt);
|
||||
virtual void handleRender();
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view);
|
||||
};
|
||||
|
@ -81,6 +81,7 @@ enum SampleToolType
|
||||
TOOL_NAVMESH_TESTER,
|
||||
TOOL_OFFMESH_CONNECTION,
|
||||
TOOL_CONVEX_VOLUME,
|
||||
TOOL_CROWD,
|
||||
};
|
||||
|
||||
struct SampleTool
|
||||
@ -90,10 +91,11 @@ struct SampleTool
|
||||
virtual void init(class Sample* sample) = 0;
|
||||
virtual void reset() = 0;
|
||||
virtual void handleMenu() = 0;
|
||||
virtual void handleClick(const float* p, bool shift) = 0;
|
||||
virtual void handleClick(const float* s, const float* p, bool shift) = 0;
|
||||
virtual void handleRender() = 0;
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view) = 0;
|
||||
virtual void handleStep() = 0;
|
||||
virtual void handleUpdate(const float dt) = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -129,12 +131,13 @@ public:
|
||||
virtual void handleSettings();
|
||||
virtual void handleTools();
|
||||
virtual void handleDebugMode();
|
||||
virtual void handleClick(const float* p, bool shift);
|
||||
virtual void handleClick(const float* s, const float* p, bool shift);
|
||||
virtual void handleStep();
|
||||
virtual void handleRender();
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view);
|
||||
virtual void handleMeshChanged(class InputGeom* geom);
|
||||
virtual bool handleBuild();
|
||||
virtual void handleUpdate(const float dt);
|
||||
|
||||
virtual class InputGeom* getInputGeom() { return m_geom; }
|
||||
virtual class dtNavMesh* getNavMesh() { return m_navMesh; }
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
virtual void handleSettings();
|
||||
virtual void handleTools();
|
||||
virtual void handleDebugMode();
|
||||
virtual void handleClick(const float* p, bool shift);
|
||||
virtual void handleClick(const float* s, const float* p, bool shift);
|
||||
virtual void handleStep();
|
||||
virtual void handleRender();
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view);
|
||||
|
@ -161,7 +161,7 @@ void ConvexVolumeTool::handleMenu()
|
||||
imguiSeparator();
|
||||
}
|
||||
|
||||
void ConvexVolumeTool::handleClick(const float* p, bool shift)
|
||||
void ConvexVolumeTool::handleClick(const float* s, const float* p, bool shift)
|
||||
{
|
||||
if (!m_sample) return;
|
||||
InputGeom* geom = m_sample->getInputGeom();
|
||||
@ -234,6 +234,10 @@ void ConvexVolumeTool::handleStep()
|
||||
{
|
||||
}
|
||||
|
||||
void ConvexVolumeTool::handleUpdate(const float dt)
|
||||
{
|
||||
}
|
||||
|
||||
void ConvexVolumeTool::handleRender()
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
|
1347
RecastDemo/Source/CrowdTool.cpp
Normal file
1347
RecastDemo/Source/CrowdTool.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -415,13 +415,13 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/)
|
||||
dd->vertex(vb[0],vol->hmax,vb[2], col);
|
||||
dd->vertex(va[0],vol->hmax,va[2], col);
|
||||
|
||||
dd->vertex(va[0],vol->hmin,va[2], duDarkenColor(col));
|
||||
dd->vertex(va[0],vol->hmin,va[2], duDarkenCol(col));
|
||||
dd->vertex(va[0],vol->hmax,va[2], col);
|
||||
dd->vertex(vb[0],vol->hmax,vb[2], col);
|
||||
|
||||
dd->vertex(va[0],vol->hmin,va[2], duDarkenColor(col));
|
||||
dd->vertex(va[0],vol->hmin,va[2], duDarkenCol(col));
|
||||
dd->vertex(vb[0],vol->hmax,vb[2], col);
|
||||
dd->vertex(vb[0],vol->hmin,vb[2], duDarkenColor(col));
|
||||
dd->vertex(vb[0],vol->hmin,vb[2], duDarkenCol(col));
|
||||
}
|
||||
}
|
||||
|
||||
@ -436,11 +436,11 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/)
|
||||
{
|
||||
const float* va = &vol->verts[k*3];
|
||||
const float* vb = &vol->verts[j*3];
|
||||
dd->vertex(va[0],vol->hmin,va[2], duDarkenColor(col));
|
||||
dd->vertex(vb[0],vol->hmin,vb[2], duDarkenColor(col));
|
||||
dd->vertex(va[0],vol->hmin,va[2], duDarkenCol(col));
|
||||
dd->vertex(vb[0],vol->hmin,vb[2], duDarkenCol(col));
|
||||
dd->vertex(va[0],vol->hmax,va[2], col);
|
||||
dd->vertex(vb[0],vol->hmax,vb[2], col);
|
||||
dd->vertex(va[0],vol->hmin,va[2], duDarkenColor(col));
|
||||
dd->vertex(va[0],vol->hmin,va[2], duDarkenCol(col));
|
||||
dd->vertex(va[0],vol->hmax,va[2], col);
|
||||
}
|
||||
}
|
||||
@ -450,7 +450,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/)
|
||||
for (int i = 0; i < m_volumeCount; ++i)
|
||||
{
|
||||
const ConvexVolume* vol = &m_volumes[i];
|
||||
unsigned int col = duDarkenColor(duIntToCol(vol->area, 255));
|
||||
unsigned int col = duDarkenCol(duIntToCol(vol->area, 255));
|
||||
for (int j = 0; j < vol->nverts; ++j)
|
||||
{
|
||||
dd->vertex(vol->verts[j*3+0],vol->verts[j*3+1]+0.1f,vol->verts[j*3+2], col);
|
||||
|
@ -315,7 +315,7 @@ void NavMeshTesterTool::handleMenu()
|
||||
}
|
||||
}
|
||||
|
||||
void NavMeshTesterTool::handleClick(const float* p, bool shift)
|
||||
void NavMeshTesterTool::handleClick(const float* s, const float* p, bool shift)
|
||||
{
|
||||
if (shift)
|
||||
{
|
||||
@ -477,6 +477,10 @@ void NavMeshTesterTool::handleStep()
|
||||
|
||||
}
|
||||
|
||||
void NavMeshTesterTool::handleUpdate(const float dt)
|
||||
{
|
||||
}
|
||||
|
||||
void NavMeshTesterTool::reset()
|
||||
{
|
||||
m_startRef = 0;
|
||||
@ -893,8 +897,8 @@ void NavMeshTesterTool::handleRender()
|
||||
|
||||
for (int i = 0; i < m_steerPointCount-1; ++i)
|
||||
{
|
||||
dd.vertex(m_steerPoints[i*3+0],m_steerPoints[i*3+1]+0.2f,m_steerPoints[i*3+2], duDarkenColor(steerCol));
|
||||
dd.vertex(m_steerPoints[(i+1)*3+0],m_steerPoints[(i+1)*3+1]+0.2f,m_steerPoints[(i+1)*3+2], duDarkenColor(steerCol));
|
||||
dd.vertex(m_steerPoints[i*3+0],m_steerPoints[i*3+1]+0.2f,m_steerPoints[i*3+2], duDarkenCol(steerCol));
|
||||
dd.vertex(m_steerPoints[(i+1)*3+0],m_steerPoints[(i+1)*3+1]+0.2f,m_steerPoints[(i+1)*3+2], duDarkenCol(steerCol));
|
||||
}
|
||||
|
||||
dd.end();
|
||||
|
@ -83,7 +83,7 @@ void OffMeshConnectionTool::handleMenu()
|
||||
}
|
||||
}
|
||||
|
||||
void OffMeshConnectionTool::handleClick(const float* p, bool shift)
|
||||
void OffMeshConnectionTool::handleClick(const float* s, const float* p, bool shift)
|
||||
{
|
||||
if (!m_sample) return;
|
||||
InputGeom* geom = m_sample->getInputGeom();
|
||||
@ -136,6 +136,10 @@ void OffMeshConnectionTool::handleStep()
|
||||
{
|
||||
}
|
||||
|
||||
void OffMeshConnectionTool::handleUpdate(const float dt)
|
||||
{
|
||||
}
|
||||
|
||||
void OffMeshConnectionTool::handleRender()
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
|
@ -266,10 +266,10 @@ void Sample::handleCommonSettings()
|
||||
imguiSeparator();
|
||||
}
|
||||
|
||||
void Sample::handleClick(const float* p, bool shift)
|
||||
void Sample::handleClick(const float* s, const float* p, bool shift)
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleClick(p, shift);
|
||||
m_tool->handleClick(s, p, shift);
|
||||
}
|
||||
|
||||
void Sample::handleStep()
|
||||
@ -282,3 +282,10 @@ bool Sample::handleBuild()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Sample::handleUpdate(const float dt)
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleUpdate(dt);
|
||||
}
|
||||
|
||||
|
@ -352,10 +352,10 @@ const float* Sample_Debug::getBoundsMax()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Sample_Debug::handleClick(const float* p, bool shift)
|
||||
void Sample_Debug::handleClick(const float* s, const float* p, bool shift)
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleClick(p, shift);
|
||||
m_tool->handleClick(s, p, shift);
|
||||
}
|
||||
|
||||
void Sample_Debug::handleStep()
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "NavMeshTesterTool.h"
|
||||
#include "OffMeshConnectionTool.h"
|
||||
#include "ConvexVolumeTool.h"
|
||||
#include "CrowdTool.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define snprintf _snprintf
|
||||
@ -111,6 +112,10 @@ void Sample_SoloMeshSimple::handleTools()
|
||||
{
|
||||
setTool(new ConvexVolumeTool);
|
||||
}
|
||||
if (imguiCheck("Create Crowds", type == TOOL_CROWD))
|
||||
{
|
||||
setTool(new CrowdTool);
|
||||
}
|
||||
|
||||
imguiSeparator();
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "NavMeshTesterTool.h"
|
||||
#include "OffMeshConnectionTool.h"
|
||||
#include "ConvexVolumeTool.h"
|
||||
#include "CrowdTool.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define snprintf _snprintf
|
||||
@ -78,7 +79,7 @@ public:
|
||||
imguiValue("Click LMB to highlight a tile.");
|
||||
}
|
||||
|
||||
virtual void handleClick(const float* p, bool /*shift*/)
|
||||
virtual void handleClick(const float* /*s*/, const float* p, bool /*shift*/)
|
||||
{
|
||||
m_hitPosSet = true;
|
||||
rcVcopy(m_hitPos,p);
|
||||
@ -88,6 +89,8 @@ public:
|
||||
|
||||
virtual void handleStep() {}
|
||||
|
||||
virtual void handleUpdate(const float dt) {}
|
||||
|
||||
virtual void handleRender()
|
||||
{
|
||||
if (m_hitPosSet)
|
||||
@ -215,6 +218,10 @@ void Sample_SoloMeshTiled::handleTools()
|
||||
{
|
||||
setTool(new ConvexVolumeTool);
|
||||
}
|
||||
if (imguiCheck("Create Crowds", type == TOOL_CROWD))
|
||||
{
|
||||
setTool(new CrowdTool);
|
||||
}
|
||||
if (imguiCheck("Highlight Tile", type == TOOL_TILE_HIGHLIGHT))
|
||||
{
|
||||
setTool(new TileHighlightTool);
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "NavMeshTesterTool.h"
|
||||
#include "OffMeshConnectionTool.h"
|
||||
#include "ConvexVolumeTool.h"
|
||||
#include "CrowdTool.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define snprintf _snprintf
|
||||
@ -112,7 +113,7 @@ public:
|
||||
imguiValue("Shift+LMB to remove a tile.");
|
||||
}
|
||||
|
||||
virtual void handleClick(const float* p, bool shift)
|
||||
virtual void handleClick(const float* s, const float* p, bool shift)
|
||||
{
|
||||
m_hitPosSet = true;
|
||||
rcVcopy(m_hitPos,p);
|
||||
@ -126,6 +127,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void handleStep() {}
|
||||
|
||||
virtual void handleUpdate(const float dt) {}
|
||||
|
||||
virtual void handleRender()
|
||||
{
|
||||
@ -406,6 +409,10 @@ void Sample_TileMesh::handleTools()
|
||||
{
|
||||
setTool(new ConvexVolumeTool);
|
||||
}
|
||||
if (imguiCheck("Create Crowds", type == TOOL_CROWD))
|
||||
{
|
||||
setTool(new CrowdTool);
|
||||
}
|
||||
|
||||
imguiSeparator();
|
||||
|
||||
|
@ -113,6 +113,7 @@ int main(int /*argc*/, char** /*argv*/)
|
||||
}
|
||||
|
||||
float t = 0.0f;
|
||||
float timeAcc = 0.0f;
|
||||
Uint32 lastTime = SDL_GetTicks();
|
||||
int mx = 0, my = 0;
|
||||
float rx = 45;
|
||||
@ -363,6 +364,7 @@ int main(int /*argc*/, char** /*argv*/)
|
||||
|
||||
t += dt;
|
||||
|
||||
|
||||
// Hit test mesh.
|
||||
if (processHitTest && geom && sample)
|
||||
{
|
||||
@ -383,7 +385,7 @@ int main(int /*argc*/, char** /*argv*/)
|
||||
pos[0] = rays[0] + (raye[0] - rays[0])*t;
|
||||
pos[1] = rays[1] + (raye[1] - rays[1])*t;
|
||||
pos[2] = rays[2] + (raye[2] - rays[2])*t;
|
||||
sample->handleClick(pos, processHitTestShift);
|
||||
sample->handleClick(rays, pos, processHitTestShift);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -396,7 +398,22 @@ int main(int /*argc*/, char** /*argv*/)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update sample simulation.
|
||||
const float SIM_RATE = 20;
|
||||
const float DELTA_TIME = 1.0f/SIM_RATE;
|
||||
timeAcc = rcClamp(timeAcc+dt, -1.0f, 1.0f);
|
||||
int simIter = 0;
|
||||
while (timeAcc > DELTA_TIME)
|
||||
{
|
||||
timeAcc -= DELTA_TIME;
|
||||
if (simIter < 5)
|
||||
{
|
||||
if (sample)
|
||||
sample->handleUpdate(DELTA_TIME);
|
||||
}
|
||||
simIter++;
|
||||
}
|
||||
|
||||
// Update and render
|
||||
glViewport(0, 0, width, height);
|
||||
glClearColor(0.3f, 0.3f, 0.32f, 1.0f);
|
||||
|
Loading…
x
Reference in New Issue
Block a user