Even More XZY->XYZ changes

This commit is contained in:
Kawe Mazidjatari 2022-07-28 15:45:02 +02:00
parent cbaf10478a
commit 9eeaebaf6a
8 changed files with 33 additions and 41 deletions

View File

@ -535,7 +535,7 @@ void CrowdToolState::handleRenderOverlay(double* proj, double* model, int* view)
const dtNode* node = pool->getNodeAtIdx(j+1);
if (!node) continue;
if (gluProject((GLdouble)node->pos[0],(GLdouble)node->pos[1]+off,(GLdouble)node->pos[2],
if (gluProject((GLdouble)node->pos[0],(GLdouble)node->pos[1],(GLdouble)node->pos[2]+off,
model, proj, view, &x, &y, &z))
{
const float heuristic = node->total;// - node->cost;
@ -588,7 +588,7 @@ void CrowdToolState::handleRenderOverlay(double* proj, double* model, int* view)
const dtCrowdAgent* nei = crowd->getAgent(ag->neis[j].idx);
if (!nei->active) continue;
if (gluProject((GLdouble)nei->npos[0], (GLdouble)nei->npos[1]+radius, (GLdouble)nei->npos[2],
if (gluProject((GLdouble)nei->npos[0], (GLdouble)nei->npos[1], (GLdouble)nei->npos[2]+radius,
model, proj, view, &x, &y, &z))
{
snprintf(label, 32, "%.3f", ag->neis[j].dist);

View File

@ -381,7 +381,6 @@ static void drawMeshTilePortal(duDebugDraw* dd, const dtMeshTile* tile)
dd->vertex(vb[0], y, vb[2] - padz, col);
dd->vertex(va[0], y, va[2] - padz, col);
}
}
}
}
@ -497,11 +496,11 @@ static void debugDrawTileCachePortals(struct duDebugDraw* dd, const dtTileCacheL
{
const int* seg = &segs[dir*4];
const float ax = bmin[0] + (x+seg[0])*cs;
const float ay = bmin[1] + (lh+1)*ch;
const float az = bmin[2] + (y+seg[2])*cs;
const float bx = bmin[0] + (x+seg[2])*cs;
const float by = bmin[1] + (lh+3)*ch;
const float bz = bmin[2] + (y+seg[2])*cs;
const float ay = bmin[1] + (y+seg[1])*cs;
const float az = bmin[2] + (lh+1)*ch;
const float bx = bmin[0] + (x+seg[1])*cs;
const float by = bmin[1] + (y+seg[1])*cs;
const float bz = bmin[2] + (lh+3)*ch;
dd->vertex(ax, ay, az, pcol);
dd->vertex(bx, by, bz, pcol);
}

View File

@ -184,7 +184,7 @@ int getNeighbours(const float* pos, const float height, const float range,
dtVsub(diff, pos, ag->npos);
if (dtMathFabsf(diff[2]) >= (height+ag->params.height)/2.0f)
continue;
diff[1] = 0;
diff[2] = 0;
const float distSqr = dtVlenSqr(diff);
if (distSqr > dtSqr(range))
continue;

View File

@ -293,13 +293,13 @@ void dtObstacleAvoidanceQuery::prepare(const float* pos, const float* dvel)
const float a = dtTriArea2D(orig, cir->dp,dv);
if (a < 0.01f)
{
cir->np[0] = -cir->dp[2];
cir->np[2] = cir->dp[0];
cir->np[0] = -cir->dp[1];
cir->np[1] = cir->dp[0];
}
else
{
cir->np[0] = cir->dp[2];
cir->np[2] = -cir->dp[0];
cir->np[0] = cir->dp[1];
cir->np[1] = -cir->dp[0];
}
}

View File

@ -486,8 +486,8 @@ dtStatus dtTileCache::queryTiles(const float* bmin, const float* bmax,
const float th = m_params.height * m_params.cs;
const int tx0 = (int)dtMathFloorf((bmin[0]-m_params.orig[0]) / tw);
const int tx1 = (int)dtMathFloorf((bmax[0]-m_params.orig[0]) / tw);
const int ty0 = (int)dtMathFloorf((bmin[2]-m_params.orig[2]) / th);
const int ty1 = (int)dtMathFloorf((bmax[2]-m_params.orig[2]) / th);
const int ty0 = (int)dtMathFloorf((bmin[1]-m_params.orig[1]) / th);
const int ty1 = (int)dtMathFloorf((bmax[1]-m_params.orig[1]) / th);
for (int ty = ty0; ty <= ty1; ++ty)
{

View File

@ -398,7 +398,7 @@ static bool appendVertex(dtTempContour& cont, const int x, const int y, const in
pb[0] = (unsigned char)x;
return true;
}
else if (pa[2] == pb[2] && (int)pb[2] == y)
else if (pa[1] == pb[1] && (int)pb[1] == y)
{
// The verts are aligned aling y-axis, update x.
pb[0] = (unsigned char)x;
@ -523,7 +523,7 @@ static bool walkContour(dtTileCacheLayer& layer, int x, int y, dtTempContour& co
// Remove last vertex if it is duplicate of the first one.
unsigned char* pa = &cont.verts[(cont.nverts-1)*4];
unsigned char* pb = &cont.verts[0];
if (pa[0] == pb[0] && pa[2] == pb[2])
if (pa[0] == pb[0] && pa[1] == pb[1])
cont.nverts--;
return true;

View File

@ -650,7 +650,7 @@ static bool mergeContours(rcContour& ca, rcContour& cb, int ia, int ib)
struct rcContourHole
{
rcContour* contour;
int minx, minz, leftmost;
int minx, miny, leftmost;
};
struct rcContourRegion
@ -667,19 +667,19 @@ struct rcPotentialDiagonal
};
// Finds the lowest leftmost vertex of a contour.
static void findLeftMostVertex(rcContour* contour, int* minx, int* minz, int* leftmost)
static void findLeftMostVertex(rcContour* contour, int* minx, int* miny, int* leftmost)
{
*minx = contour->verts[0];
*minz = contour->verts[2];
*miny = contour->verts[1];
*leftmost = 0;
for (int i = 1; i < contour->nverts; i++)
{
const int x = contour->verts[i*4+0];
const int z = contour->verts[i*4+2];
if (x < *minx || (x == *minx && z < *minz))
const int y = contour->verts[i*4+1];
if (x < *minx || (x == *minx && y < *miny))
{
*minx = x;
*minz = z;
*miny = y;
*leftmost = i;
}
}
@ -691,9 +691,9 @@ static int compareHoles(const void* va, const void* vb)
const rcContourHole* b = (const rcContourHole*)vb;
if (a->minx == b->minx)
{
if (a->minz < b->minz)
if (a->miny < b->miny)
return -1;
if (a->minz > b->minz)
if (a->miny > b->miny)
return 1;
}
else
@ -723,7 +723,7 @@ static void mergeRegionHoles(rcContext* ctx, rcContourRegion& region)
{
// Sort holes from left to right.
for (int i = 0; i < region.nholes; i++)
findLeftMostVertex(region.holes[i].contour, &region.holes[i].minx, &region.holes[i].minz, &region.holes[i].leftmost);
findLeftMostVertex(region.holes[i].contour, &region.holes[i].minx, &region.holes[i].miny, &region.holes[i].leftmost);
qsort(region.holes, region.nholes, sizeof(rcContourHole), compareHoles);
@ -764,9 +764,9 @@ static void mergeRegionHoles(rcContext* ctx, rcContourRegion& region)
if (inCone(j, outline->nverts, outline->verts, corner))
{
int dx = outline->verts[j*4+0] - corner[0];
int dz = outline->verts[j*4+2] - corner[2];
int dy = outline->verts[j*4+1] - corner[1];
diags[ndiags].vert = j;
diags[ndiags].dist = dx*dx + dz*dz;
diags[ndiags].dist = dx*dx + dy*dy;
ndiags++;
}
}

View File

@ -81,7 +81,7 @@ static bool circumCircle(const float* p1, const float* p2, const float* p3,
const float v2Sq = vdot2(v2,v2);
const float v3Sq = vdot2(v3,v3);
c[0] = (v1Sq*(v2[1]-v3[1]) + v2Sq*(v3[1]-v1[1]) + v3Sq*(v1[1]-v2[1])) / (2*cp);
c[1] = (v1Sq*(v3[0] - v2[0]) + v2Sq * (v1[0] - v3[0]) + v3Sq * (v2[0] - v1[0])) / (2 * cp);
c[1] = (v1Sq*(v3[0]-v2[0]) + v2Sq*(v1[0]-v3[0]) + v3Sq*(v2[0]-v1[0])) / (2*cp);
c[2] = 0;
r = vdist2(c, v1);
rcVadd(c, c, p1);
@ -905,7 +905,7 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
{
float pt[3];
pt[0] = x*sampleDist;
pt[1] = y * sampleDist;
pt[1] = y*sampleDist;
pt[2] = (bmax[2] + bmin[2])*0.5f;
// Make sure the samples are not too close to the edges.
if (distToPoly(nin,in,pt) > -sampleDist/2) continue;
@ -937,8 +937,8 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
// The sample location is jittered to get rid of some bad triangulations
// which are cause by symmetrical data from the grid structure.
pt[0] = s[0]*sampleDist + getJitterX(i)*cs*0.1f;
pt[1] = s[1] * sampleDist + getJitterY(i)*cs*0.1f;
pt[2] = s[2] * chf.ch;
pt[1] = s[1]*sampleDist + getJitterY(i)*cs*0.1f;
pt[2] = s[2]*chf.ch;
float d = distToTriMesh(pt, verts, nverts, tris.data(), tris.size()/4);
if (d < 0) continue; // did not hit the mesh.
if (d > bestd)
@ -1407,7 +1407,7 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
for (int j = 0; j < nverts; ++j)
{
verts[j*3+0] += orig[0];
verts[j * 3 + 1] += orig[1];
verts[j*3+1] += orig[1];
verts[j*3+2] += orig[2] + chf.ch; // Is this offset necessary?
}
// Offset poly too, will be used to flag checking.
@ -1470,18 +1470,11 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
for (int j = 0; j < ntris; ++j)
{
const int* t = &tris[j*4];
#if 1
dmesh.tris[dmesh.ntris*4+0] = (unsigned char)t[0];
dmesh.tris[dmesh.ntris*4+1] = (unsigned char)t[2];
dmesh.tris[dmesh.ntris*4+2] = (unsigned char)t[1];
dmesh.tris[dmesh.ntris*4+3] = getTriFlags(&verts[t[0]*3], &verts[t[2]*3], &verts[t[1]*3], poly, npoly);
#else
dmesh.tris[dmesh.ntris * 4 + 0] = (unsigned char)t[0];
dmesh.tris[dmesh.ntris * 4 + 1] = (unsigned char)t[1];
dmesh.tris[dmesh.ntris * 4 + 2] = (unsigned char)t[2];
dmesh.tris[dmesh.ntris * 4 + 3] = getTriFlags(&verts[t[0] * 3], &verts[t[1] * 3], &verts[t[2] * 3], poly, npoly);
#endif
dmesh.ntris++;
}
}