Fixes using gameobject like chairs, also fixes indoor checks
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
public static partial class Detour
|
||||
{
|
||||
@@ -180,6 +181,22 @@ public static partial class Detour
|
||||
return dx * dx + dz * dz;
|
||||
}
|
||||
|
||||
public static float dtDistancePtSegSqr2D(float[] pt, int ptStart, Vector3 p, Vector3 q, ref float t)
|
||||
{
|
||||
float pqx = q.GetAt(0) - p.GetAt(0);
|
||||
float pqz = q.GetAt(2) - p.GetAt(2);
|
||||
float dx = pt[ptStart + 0] - p.GetAt(0);
|
||||
float dz = pt[ptStart + 2] - p.GetAt(2);
|
||||
float d = pqx * pqx + pqz * pqz;
|
||||
t = pqx * dx + pqz * dz;
|
||||
if (d > 0) t /= d;
|
||||
if (t < 0) t = 0;
|
||||
else if (t > 1) t = 1;
|
||||
dx = p.GetAt(0) + t * pqx - pt[ptStart + 0];
|
||||
dz = p.GetAt(2) + t * pqz - pt[ptStart + 2];
|
||||
return dx * dx + dz * dz;
|
||||
}
|
||||
|
||||
/// Derives the centroid of a convex polygon.
|
||||
/// @param[out] tc The centroid of the polgyon. [(x, y, z)]
|
||||
/// @param[in] idx The polygon indices. [(vertIndex) * @p nidx]
|
||||
|
||||
Reference in New Issue
Block a user