Fix cylinder debug draw

This commit is contained in:
Amos 2022-03-16 01:33:58 +01:00
parent 7cd73893f4
commit 243c5e4af7
3 changed files with 30 additions and 31 deletions

View File

@ -259,7 +259,7 @@ void ConvexVolumeTool::handleRender()
{
const float* vi = &m_pts[m_hull[j]*3];
const float* vj = &m_pts[m_hull[i]*3];
dd.vertex(vj[0],vj[1], minh, duRGBA(255, 255, 255, 64));
dd.vertex(vj[0], vj[1], minh, duRGBA(255, 255, 255, 64));
dd.vertex(vi[0], vi[1], minh, duRGBA(255, 255, 255, 64));
dd.vertex(vj[0], vj[1], maxh, duRGBA(255, 255, 255, 64));
dd.vertex(vi[0], vi[1], maxh, duRGBA(255, 255, 255, 64));

View File

@ -424,8 +424,8 @@ void CrowdToolState::handleRender()
else if (ag->targetState == DT_CROWDAGENT_TARGET_VELOCITY)
col = duLerpCol(col, duRGBA(64,255,0,128), 128);
duDebugDrawCylinder(&dd, pos[0]-radius, pos[1]+radius*0.1f, pos[2]-radius,
pos[0]+radius, pos[1]+height, pos[2]+radius, col);
duDebugDrawCylinder(&dd, pos[0]-radius, pos[1]-radius, pos[2]+radius*0.1f,
pos[0]+radius, pos[1]+radius, pos[2]+height, col);
}
@ -443,8 +443,8 @@ void CrowdToolState::handleRender()
const dtObstacleAvoidanceDebugData* vod = m_agentDebug.vod;
const float dx = ag->npos[0];
const float dy = ag->npos[1]+ag->params.height;
const float dz = ag->npos[2];
const float dy = ag->npos[1];
const float dz = ag->npos[2]+ag->params.height;
duDebugDrawCircle(&dd, dx,dy,dz, ag->params.maxSpeed, duRGBA(255,255,255,64), 2.0f);
@ -488,7 +488,7 @@ void CrowdToolState::handleRender()
else if (ag->targetState == DT_CROWDAGENT_TARGET_VELOCITY)
col = duLerpCol(col, duRGBA(64,255,0,192), 128);
duDebugDrawCircle(&dd, pos[0], pos[1]+height, pos[2], radius, col, 2.0f);
duDebugDrawCircle(&dd, pos[0], pos[1], pos[2]+height, radius, col, 2.0f);
duDebugDrawArrow(&dd, pos[0],pos[1]+height,pos[2],
pos[0]+dvel[0],pos[1]+height+dvel[1],pos[2]+dvel[2],
@ -557,7 +557,7 @@ void CrowdToolState::handleRenderOverlay(double* proj, double* model, int* view)
if (!ag->active) continue;
const float* pos = ag->npos;
const float h = ag->params.height;
if (gluProject((GLdouble)pos[0], (GLdouble)pos[1]+h, (GLdouble)pos[2],
if (gluProject((GLdouble)pos[0], (GLdouble)pos[1], (GLdouble)pos[2]+h,
model, proj, view, &x, &y, &z))
{
snprintf(label, 32, "%d", i);

View File

@ -82,7 +82,7 @@ void duDebugDrawCylinderWire(struct duDebugDraw* dd, float minx, float miny, flo
if (!dd) return;
dd->begin(DU_DRAW_LINES, lineWidth);
duAppendCylinderWire(dd, minx,miny,minz, maxx,maxy,maxz, col);
duAppendCylinderWire(dd, minx,minz,miny, maxx,maxz,maxy, col);
dd->end();
}
@ -124,7 +124,7 @@ void duDebugDrawCircle(struct duDebugDraw* dd, const float x, const float y, con
if (!dd) return;
dd->begin(DU_DRAW_LINES, lineWidth);
duAppendCircle(dd, x,y,z, r, col);
duAppendCircle(dd, x,z,y, r, col);
dd->end();
}
@ -154,7 +154,7 @@ void duDebugDrawCylinder(struct duDebugDraw* dd, float minx, float miny, float m
if (!dd) return;
dd->begin(DU_DRAW_TRIS);
duAppendCylinder(dd, minx,miny,minz, maxx,maxy,maxz, col);
duAppendCylinder(dd, minx,minz,miny, maxx,maxz,maxy, col);
dd->end();
}
@ -243,15 +243,15 @@ void duAppendCylinderWire(struct duDebugDraw* dd, float minx, float miny, float
for (int i = 0, j = NUM_SEG-1; i < NUM_SEG; j = i++)
{
dd->vertex(cx+dir[j*2+0]*rx, miny, cz+dir[j*2+1]*rz, col);
dd->vertex(cx+dir[i*2+0]*rx, miny, cz+dir[i*2+1]*rz, col);
dd->vertex(cx+dir[j*2+0]*rx, maxy, cz+dir[j*2+1]*rz, col);
dd->vertex(cx+dir[i*2+0]*rx, maxy, cz+dir[i*2+1]*rz, col);
dd->vertex(cx+dir[j*2+0]*rx, cz+dir[j*2+1]*rz, miny, col);
dd->vertex(cx+dir[i*2+0]*rx, cz+dir[i*2+1]*rz, miny, col);
dd->vertex(cx+dir[j*2+0]*rx, cz+dir[j*2+1]*rz, maxy, col);
dd->vertex(cx+dir[i*2+0]*rx, cz+dir[i*2+1]*rz, maxy, col);
}
for (int i = 0; i < NUM_SEG; i += NUM_SEG/4)
{
dd->vertex(cx+dir[i*2+0]*rx, miny, cz+dir[i*2+1]*rz, col);
dd->vertex(cx+dir[i*2+0]*rx, maxy, cz+dir[i*2+1]*rz, col);
dd->vertex(cx+dir[i*2+0]*rx, cz+dir[i*2+1]*rz, miny, col);
dd->vertex(cx+dir[i*2+0]*rx, cz+dir[i*2+1]*rz, maxy, col);
}
}
@ -379,30 +379,29 @@ void duAppendCylinder(struct duDebugDraw* dd, float minx, float miny, float minz
for (int i = 2; i < NUM_SEG; ++i)
{
const int a = 0, b = i-1, c = i;
dd->vertex(cx+dir[a*2+0]*rx, miny, cz+dir[a*2+1]*rz, col2);
dd->vertex(cx+dir[b*2+0]*rx, miny, cz+dir[b*2+1]*rz, col2);
dd->vertex(cx+dir[c*2+0]*rx, miny, cz+dir[c*2+1]*rz, col2);
dd->vertex(cx+dir[a*2+0]*rx, cz+dir[a*2+1]*rz, miny, col2);
dd->vertex(cx+dir[b*2+0]*rx, cz+dir[b*2+1]*rz, miny, col2);
dd->vertex(cx+dir[c*2+0]*rx, cz+dir[c*2+1]*rz, miny, col2);
}
for (int i = 2; i < NUM_SEG; ++i)
{
const int a = 0, b = i, c = i-1;
dd->vertex(cx+dir[a*2+0]*rx, maxy, cz+dir[a*2+1]*rz, col);
dd->vertex(cx+dir[b*2+0]*rx, maxy, cz+dir[b*2+1]*rz, col);
dd->vertex(cx+dir[c*2+0]*rx, maxy, cz+dir[c*2+1]*rz, col);
dd->vertex(cx+dir[a*2+0]*rx, cz+dir[a*2+1]*rz, maxy, col);
dd->vertex(cx+dir[b*2+0]*rx, cz+dir[b*2+1]*rz, maxy, col);
dd->vertex(cx+dir[c*2+0]*rx, cz+dir[c*2+1]*rz, maxy, col);
}
for (int i = 0, j = NUM_SEG-1; i < NUM_SEG; j = i++)
{
dd->vertex(cx+dir[i*2+0]*rx, miny, cz+dir[i*2+1]*rz, col2);
dd->vertex(cx+dir[j*2+0]*rx, miny, cz+dir[j*2+1]*rz, col2);
dd->vertex(cx+dir[j*2+0]*rx, maxy, cz+dir[j*2+1]*rz, col);
dd->vertex(cx+dir[i*2+0]*rx, cz+dir[i*2+1]*rz, miny, col2);
dd->vertex(cx+dir[j*2+0]*rx, cz+dir[j*2+1]*rz, miny, col2);
dd->vertex(cx+dir[j*2+0]*rx, cz+dir[j*2+1]*rz, maxy, col);
dd->vertex(cx+dir[i*2+0]*rx, miny, cz+dir[i*2+1]*rz, col2);
dd->vertex(cx+dir[j*2+0]*rx, maxy, cz+dir[j*2+1]*rz, col);
dd->vertex(cx+dir[i*2+0]*rx, maxy, cz+dir[i*2+1]*rz, col);
dd->vertex(cx+dir[i*2+0]*rx, cz+dir[i*2+1]*rz, miny, col2);
dd->vertex(cx+dir[j*2+0]*rx, cz+dir[j*2+1]*rz, maxy, col);
dd->vertex(cx+dir[i*2+0]*rx, cz+dir[i*2+1]*rz, maxy, col);
}
}
inline void evalArc(const float x0, const float y0, const float z0,
const float dx, const float dy, const float dz,
const float h, const float u, float* res)
@ -546,8 +545,8 @@ void duAppendCircle(struct duDebugDraw* dd, const float x, const float y, const
for (int i = 0, j = NUM_SEG-1; i < NUM_SEG; j = i++)
{
dd->vertex(x+dir[j*2+0]*r, y, z+dir[j*2+1]*r, col);
dd->vertex(x+dir[i*2+0]*r, y, z+dir[i*2+1]*r, col);
dd->vertex(x+dir[j*2+0]*r, z+dir[j*2+1]*r, y, col);
dd->vertex(x+dir[i*2+0]*r, z+dir[i*2+1]*r, y, col);
}
}