mirror of
https://github.com/recastnavigation/recastnavigation.git
synced 2026-11-18 13:56:00 +00:00
- Added rcOffsetPoly() helper function to expand polygon areas
This commit is contained in:
@@ -101,6 +101,7 @@ static int pointInPoly(int nvert, const float* verts, const float* p)
|
||||
ConvexVolumeTool::ConvexVolumeTool() :
|
||||
m_sample(0),
|
||||
m_areaType(SAMPLE_POLYAREA_GRASS),
|
||||
m_polyOffset(0.0f),
|
||||
m_boxHeight(6.0f),
|
||||
m_boxDescent(1.0f),
|
||||
m_npts(0),
|
||||
@@ -127,6 +128,7 @@ void ConvexVolumeTool::handleMenu()
|
||||
{
|
||||
imguiSlider("Shape Height", &m_boxHeight, 0.1f, 20.0f, 0.1f);
|
||||
imguiSlider("Shape Descent", &m_boxDescent, 0.1f, 20.0f, 0.1f);
|
||||
imguiSlider("Poly Offset", &m_polyOffset, 0.0f, 10.0f, 0.1f);
|
||||
|
||||
imguiSeparator();
|
||||
|
||||
@@ -195,8 +197,18 @@ void ConvexVolumeTool::handleClick(const float* /*s*/, const float* p, bool shif
|
||||
minh = rcMin(minh, verts[i*3+1]);
|
||||
minh -= m_boxDescent;
|
||||
maxh = minh + m_boxHeight;
|
||||
|
||||
geom->addConvexVolume(verts, m_nhull, minh, maxh, (unsigned char)m_areaType);
|
||||
|
||||
if (m_polyOffset > 0.01f)
|
||||
{
|
||||
float offset[MAX_PTS*2*3];
|
||||
int noffset = rcOffsetPoly(verts, m_nhull, m_polyOffset, offset, MAX_PTS*2);
|
||||
if (noffset > 0)
|
||||
geom->addConvexVolume(offset, noffset, minh, maxh, (unsigned char)m_areaType);
|
||||
}
|
||||
else
|
||||
{
|
||||
geom->addConvexVolume(verts, m_nhull, minh, maxh, (unsigned char)m_areaType);
|
||||
}
|
||||
}
|
||||
|
||||
m_npts = 0;
|
||||
|
||||
Reference in New Issue
Block a user