forked from mirror/DotRecast
for unity3d
This commit is contained in:
parent
d58f3937de
commit
bbb9c7816f
|
@ -277,15 +277,10 @@ public class TestNavmeshTool : IRcTool
|
|||
{
|
||||
if (m_sposSet && m_startRef != 0 && m_eposSet)
|
||||
{
|
||||
float dx = m_epos.x - m_spos.x;
|
||||
float dz = m_epos.z - m_spos.z;
|
||||
float dist = (float)Math.Sqrt(dx * dx + dz * dz);
|
||||
|
||||
List<long> refs = new();
|
||||
List<long> parentRefs = new();
|
||||
List<float> costs = new();
|
||||
|
||||
var status = m_navQuery.FindPolysAroundCircle(m_startRef, m_spos, dist, m_filter, ref refs, ref parentRefs, ref costs);
|
||||
var status = _impl.FindPolysAroundCircle(m_startRef, m_spos, m_epos, m_filter, ref refs, ref parentRefs);
|
||||
if (status.Succeeded())
|
||||
{
|
||||
m_polys = refs;
|
||||
|
@ -798,7 +793,6 @@ public class TestNavmeshTool : IRcTool
|
|||
}
|
||||
|
||||
|
||||
|
||||
public void HandleUpdate(float dt)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -252,28 +252,40 @@ namespace DotRecast.Recast.DemoTool.Tools
|
|||
return status;
|
||||
}
|
||||
|
||||
public DtStatus FindPolysAroundShape(long startRef, RcVec3f m_spos, RcVec3f m_epos, IDtQueryFilter filter, ref List<long> resultRef, ref List<long> resultParent, out RcVec3f[] queryPoly)
|
||||
public DtStatus FindPolysAroundCircle(long startRef, RcVec3f spos, RcVec3f epos, IDtQueryFilter filter, ref List<long> resultRef, ref List<long> resultParent)
|
||||
{
|
||||
float nx = (m_epos.z - m_spos.z) * 0.25f;
|
||||
float nz = -(m_epos.x - m_spos.x) * 0.25f;
|
||||
float dx = epos.x - spos.x;
|
||||
float dz = epos.z - spos.z;
|
||||
float dist = (float)Math.Sqrt(dx * dx + dz * dz);
|
||||
|
||||
List<float> costs = new List<float>();
|
||||
var navQuery = _sample.GetNavMeshQuery();
|
||||
|
||||
return navQuery.FindPolysAroundCircle(startRef, spos, dist, filter, ref resultRef, ref resultParent, ref costs);
|
||||
}
|
||||
|
||||
public DtStatus FindPolysAroundShape(long startRef, RcVec3f spos, RcVec3f epos, IDtQueryFilter filter, ref List<long> resultRef, ref List<long> resultParent, out RcVec3f[] queryPoly)
|
||||
{
|
||||
float nx = (epos.z - spos.z) * 0.25f;
|
||||
float nz = -(epos.x - spos.x) * 0.25f;
|
||||
float agentHeight = GetSample() != null ? GetSample().GetSettings().agentHeight : 0;
|
||||
|
||||
queryPoly = new RcVec3f[4];
|
||||
queryPoly[0].x = m_spos.x + nx * 1.2f;
|
||||
queryPoly[0].y = m_spos.y + agentHeight / 2;
|
||||
queryPoly[0].z = m_spos.z + nz * 1.2f;
|
||||
queryPoly[0].x = spos.x + nx * 1.2f;
|
||||
queryPoly[0].y = spos.y + agentHeight / 2;
|
||||
queryPoly[0].z = spos.z + nz * 1.2f;
|
||||
|
||||
queryPoly[1].x = m_spos.x - nx * 1.3f;
|
||||
queryPoly[1].y = m_spos.y + agentHeight / 2;
|
||||
queryPoly[1].z = m_spos.z - nz * 1.3f;
|
||||
queryPoly[1].x = spos.x - nx * 1.3f;
|
||||
queryPoly[1].y = spos.y + agentHeight / 2;
|
||||
queryPoly[1].z = spos.z - nz * 1.3f;
|
||||
|
||||
queryPoly[2].x = m_epos.x - nx * 0.8f;
|
||||
queryPoly[2].y = m_epos.y + agentHeight / 2;
|
||||
queryPoly[2].z = m_epos.z - nz * 0.8f;
|
||||
queryPoly[2].x = epos.x - nx * 0.8f;
|
||||
queryPoly[2].y = epos.y + agentHeight / 2;
|
||||
queryPoly[2].z = epos.z - nz * 0.8f;
|
||||
|
||||
queryPoly[3].x = m_epos.x + nx;
|
||||
queryPoly[3].y = m_epos.y + agentHeight / 2;
|
||||
queryPoly[3].z = m_epos.z + nz;
|
||||
queryPoly[3].x = epos.x + nx;
|
||||
queryPoly[3].y = epos.y + agentHeight / 2;
|
||||
queryPoly[3].z = epos.z + nz;
|
||||
|
||||
var costs = new List<float>();
|
||||
var navQuery = _sample.GetNavMeshQuery();
|
||||
|
|
Loading…
Reference in New Issue