Recast: also cast ray against convex hulls for clip brushes

A ray should not go through clip brushes. This fixes an issue were traverse links are generated inside or through clip brushes.
This commit is contained in:
Kawe Mazidjatari 2024-09-04 16:08:30 +02:00
parent 6050ce5555
commit 6fa5080fe5

View File

@ -514,11 +514,43 @@ bool InputGeom::raycastMesh(const float* src, const float* dst, float* tmin) con
if (!ncid)
return false;
float localtmin = 1.0f;
bool hit = false;
const int nvol = m_volumeCount;
float tsmin = 0.0f, tsmax = 0.0f;
int segMin = 0, segMax = 0;
const bool calcTmin = tmin != nullptr;
bool hit = false;
for (int i = 0; i < nvol; i++)
{
const ConvexVolume& vol = m_volumes[i];
if (vol.area != RC_NULL_AREA)
continue; // Clip brushes only.
if ((src[2] >= vol.hmin && src[2] <= vol.hmax) ||
(dst[2] >= vol.hmin && dst[2] <= vol.hmax))
{
if (rdIntersectSegmentPoly2D(src, dst, vol.verts, vol.nverts,
tsmin, tsmax, segMin, segMax))
{
hit = true;
break;
}
}
}
if (hit)
{
if (calcTmin)
*tmin = tsmin;
return true;
}
const float* verts = m_mesh->getVerts();
float localtmin = 1.0f;
for (int i = 0; i < ncid; ++i)
{