forked from bit/DotRecastNetSim
012 -> xyz
This commit is contained in:
parent
b714e5b0f7
commit
3ecfa5d9fd
|
@ -869,7 +869,7 @@ namespace DotRecast.Detour.Crowd
|
|||
{
|
||||
Vector3f p = ag.npos;
|
||||
float r = ag.option.radius;
|
||||
m_grid.addItem(ag, p[0] - r, p[2] - r, p[0] + r, p[2] + r);
|
||||
m_grid.addItem(ag, p.x - r, p.z - r, p.x + r, p.z + r);
|
||||
}
|
||||
|
||||
_telemetry.stop("buildProximityGrid");
|
||||
|
@ -905,7 +905,7 @@ namespace DotRecast.Detour.Crowd
|
|||
private List<CrowdNeighbour> getNeighbours(Vector3f pos, float height, float range, CrowdAgent skip, ProximityGrid grid)
|
||||
{
|
||||
List<CrowdNeighbour> result = new List<CrowdNeighbour>();
|
||||
HashSet<CrowdAgent> proxAgents = grid.queryItems(pos[0] - range, pos[2] - range, pos[0] + range, pos[2] + range);
|
||||
HashSet<CrowdAgent> proxAgents = grid.queryItems(pos.x - range, pos.z - range, pos.x + range, pos.z + range);
|
||||
|
||||
foreach (CrowdAgent ag in proxAgents)
|
||||
{
|
||||
|
@ -916,12 +916,12 @@ namespace DotRecast.Detour.Crowd
|
|||
|
||||
// Check for overlap.
|
||||
Vector3f diff = vSub(pos, ag.npos);
|
||||
if (Math.Abs(diff[1]) >= (height + ag.option.height) / 2.0f)
|
||||
if (Math.Abs(diff.y) >= (height + ag.option.height) / 2.0f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
diff[1] = 0;
|
||||
diff.y = 0;
|
||||
float distSqr = vLenSqr(diff);
|
||||
if (distSqr > sqr(range))
|
||||
{
|
||||
|
@ -1090,7 +1090,7 @@ namespace DotRecast.Detour.Crowd
|
|||
CrowdAgent nei = ag.neis[j].agent;
|
||||
|
||||
Vector3f diff = vSub(ag.npos, nei.npos);
|
||||
diff[1] = 0;
|
||||
diff.y = 0;
|
||||
|
||||
float distSqr = vLenSqr(diff);
|
||||
if (distSqr < 0.00001f)
|
||||
|
@ -1244,7 +1244,7 @@ namespace DotRecast.Detour.Crowd
|
|||
CrowdAgent nei = ag.neis[j].agent;
|
||||
long idx1 = nei.idx;
|
||||
Vector3f diff = vSub(ag.npos, nei.npos);
|
||||
diff[1] = 0;
|
||||
diff.y = 0;
|
||||
|
||||
float dist = vLenSqr(diff);
|
||||
if (dist > sqr(ag.option.radius + nei.option.radius))
|
||||
|
@ -1259,11 +1259,11 @@ namespace DotRecast.Detour.Crowd
|
|||
// Agents on top of each other, try to choose diverging separation directions.
|
||||
if (idx0 > idx1)
|
||||
{
|
||||
vSet(ref diff, -ag.dvel[2], 0, ag.dvel[0]);
|
||||
vSet(ref diff, -ag.dvel.z, 0, ag.dvel.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
vSet(ref diff, ag.dvel[2], 0, -ag.dvel[0]);
|
||||
vSet(ref diff, ag.dvel.z, 0, -ag.dvel.x);
|
||||
}
|
||||
|
||||
pen = 0.01f;
|
||||
|
@ -1392,4 +1392,4 @@ namespace DotRecast.Detour.Crowd
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,17 +195,17 @@ namespace DotRecast.Detour.Crowd
|
|||
|
||||
var dir0 = vSub(p0, npos);
|
||||
var dir1 = vSub(p1, npos);
|
||||
dir0[1] = 0;
|
||||
dir1[1] = 0;
|
||||
dir0.y = 0;
|
||||
dir1.y = 0;
|
||||
|
||||
float len0 = vLen(dir0);
|
||||
float len1 = vLen(dir1);
|
||||
if (len1 > 0.001f)
|
||||
dir1 = vScale(dir1, 1.0f / len1);
|
||||
|
||||
dir[0] = dir0[0] - dir1[0] * len0 * 0.5f;
|
||||
dir[1] = 0;
|
||||
dir[2] = dir0[2] - dir1[2] * len0 * 0.5f;
|
||||
dir.x = dir0.x - dir1.x * len0 * 0.5f;
|
||||
dir.y = 0;
|
||||
dir.z = dir0.z - dir1.z * len0 * 0.5f;
|
||||
|
||||
vNormalize(ref dir);
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ namespace DotRecast.Detour.Crowd
|
|||
if (0 < corners.Count)
|
||||
{
|
||||
dir = vSub(corners[0].getPos(), npos);
|
||||
dir[1] = 0;
|
||||
dir.y = 0;
|
||||
vNormalize(ref dir);
|
||||
}
|
||||
|
||||
|
@ -241,4 +241,4 @@ namespace DotRecast.Detour.Crowd
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,12 +46,12 @@ namespace DotRecast.Detour.Crowd
|
|||
|
||||
public LocalBoundary()
|
||||
{
|
||||
m_center[0] = m_center[1] = m_center[2] = float.MaxValue;
|
||||
m_center.x = m_center.y = m_center.z = float.MaxValue;
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
m_center[0] = m_center[1] = m_center[2] = float.MaxValue;
|
||||
m_center.x = m_center.y = m_center.z = float.MaxValue;
|
||||
m_polys.Clear();
|
||||
m_segs.Clear();
|
||||
}
|
||||
|
@ -172,4 +172,4 @@ namespace DotRecast.Detour.Crowd
|
|||
return m_segs.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,13 +166,13 @@ namespace DotRecast.Detour.Crowd
|
|||
float a = triArea2D(orig, cir.dp, dv);
|
||||
if (a < 0.01f)
|
||||
{
|
||||
cir.np[0] = -cir.dp[2];
|
||||
cir.np[2] = cir.dp[0];
|
||||
cir.np.x = -cir.dp.z;
|
||||
cir.np.z = cir.dp.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
cir.np[0] = cir.dp[2];
|
||||
cir.np[2] = -cir.dp[0];
|
||||
cir.np.x = cir.dp.z;
|
||||
cir.np.z = -cir.dp.x;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,8 +300,8 @@ namespace DotRecast.Detour.Crowd
|
|||
// Special case when the agent is very close to the segment.
|
||||
Vector3f sdir = vSub(seg.q, seg.p);
|
||||
Vector3f snorm = new Vector3f();
|
||||
snorm[0] = -sdir[2];
|
||||
snorm[2] = sdir[0];
|
||||
snorm.x = -sdir.z;
|
||||
snorm.z = sdir.x;
|
||||
// If the velocity is pointing towards the segment, no collision.
|
||||
if (vDot2D(snorm, vcand) < 0.0f)
|
||||
continue;
|
||||
|
@ -357,8 +357,8 @@ namespace DotRecast.Detour.Crowd
|
|||
if (debug != null)
|
||||
debug.reset();
|
||||
|
||||
float cvx = dvel[0] * m_params.velBias;
|
||||
float cvz = dvel[2] * m_params.velBias;
|
||||
float cvx = dvel.x * m_params.velBias;
|
||||
float cvz = dvel.z * m_params.velBias;
|
||||
float cs = vmax * 2 * (1 - m_params.velBias) / (m_params.gridSize - 1);
|
||||
float half = (m_params.gridSize - 1) * cs * 0.5f;
|
||||
|
||||
|
@ -372,7 +372,7 @@ namespace DotRecast.Detour.Crowd
|
|||
Vector3f vcand = new Vector3f();
|
||||
vSet(ref vcand, cvx + x * cs - half, 0f, cvz + y * cs - half);
|
||||
|
||||
if (sqr(vcand[0]) + sqr(vcand[2]) > sqr(vmax + cs / 2))
|
||||
if (sqr(vcand.x) + sqr(vcand.z) > sqr(vmax + cs / 2))
|
||||
continue;
|
||||
|
||||
float penalty = processSample(vcand, cs, pos, rad, vel, dvel, minPenalty, debug);
|
||||
|
@ -405,9 +405,9 @@ namespace DotRecast.Detour.Crowd
|
|||
Vector3f dest = new Vector3f();
|
||||
float c = (float)Math.Cos(ang);
|
||||
float s = (float)Math.Sin(ang);
|
||||
dest[0] = v[0] * c - v[2] * s;
|
||||
dest[2] = v[0] * s + v[2] * c;
|
||||
dest[1] = v[1];
|
||||
dest.x = v[0] * c - v[2] * s;
|
||||
dest.z = v[0] * s + v[2] * c;
|
||||
dest.y = v[1];
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
@ -446,9 +446,9 @@ namespace DotRecast.Detour.Crowd
|
|||
vCopy(ddir, dvel);
|
||||
dtNormalize2D(ddir);
|
||||
Vector3f rotated = dtRotate2D(ddir, da * 0.5f); // rotated by da/2
|
||||
ddir[3] = rotated[0];
|
||||
ddir[4] = rotated[1];
|
||||
ddir[5] = rotated[2];
|
||||
ddir[3] = rotated.x;
|
||||
ddir[4] = rotated.y;
|
||||
ddir[5] = rotated.z;
|
||||
|
||||
// Always add sample at zero
|
||||
pat[npat * 2 + 0] = 0;
|
||||
|
@ -489,7 +489,7 @@ namespace DotRecast.Detour.Crowd
|
|||
// Start sampling.
|
||||
float cr = vmax * (1.0f - m_params.velBias);
|
||||
Vector3f res = new Vector3f();
|
||||
vSet(ref res, dvel[0] * m_params.velBias, 0, dvel[2] * m_params.velBias);
|
||||
vSet(ref res, dvel.x * m_params.velBias, 0, dvel.z * m_params.velBias);
|
||||
int ns = 0;
|
||||
for (int k = 0; k < depth; ++k)
|
||||
{
|
||||
|
@ -500,8 +500,8 @@ namespace DotRecast.Detour.Crowd
|
|||
for (int i = 0; i < npat; ++i)
|
||||
{
|
||||
Vector3f vcand = new Vector3f();
|
||||
vSet(ref vcand, res[0] + pat[i * 2 + 0] * cr, 0f, res[2] + pat[i * 2 + 1] * cr);
|
||||
if (sqr(vcand[0]) + sqr(vcand[2]) > sqr(vmax + 0.001f))
|
||||
vSet(ref vcand, res.x + pat[i * 2 + 0] * cr, 0f, res.z + pat[i * 2 + 1] * cr);
|
||||
if (sqr(vcand.x) + sqr(vcand.z) > sqr(vmax + 0.001f))
|
||||
continue;
|
||||
|
||||
float penalty = processSample(vcand, cr / 10, pos, rad, vel, dvel, minPenalty, debug);
|
||||
|
@ -523,4 +523,4 @@ namespace DotRecast.Detour.Crowd
|
|||
return Tuple.Create(ns, nvel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -435,7 +435,7 @@ namespace DotRecast.Detour.Crowd
|
|||
Result<float> hr = navquery.getPolyHeight(m_path[0], masResult.result.getResultPos());
|
||||
if (hr.Succeeded())
|
||||
{
|
||||
m_pos[1] = hr.result;
|
||||
m_pos.y = hr.result;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -471,8 +471,8 @@ namespace DotRecast.Detour.Crowd
|
|||
// TODO: should we do that?
|
||||
// Adjust the position to stay on top of the navmesh.
|
||||
/*
|
||||
* float h = m_target[1]; navquery->getPolyHeight(m_path[m_npath-1],
|
||||
* result, &h); result[1] = h;
|
||||
* float h = m_target.y; navquery->getPolyHeight(m_path[m_npath-1],
|
||||
* result, &h); result.y = h;
|
||||
*/
|
||||
m_target = masResult.result.getResultPos();
|
||||
return true;
|
||||
|
@ -632,4 +632,4 @@ namespace DotRecast.Detour.Crowd
|
|||
return m_path.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,9 +84,9 @@ namespace DotRecast.Detour.Crowd.Tracking
|
|||
{
|
||||
if (m_nsamples >= m_maxSamples)
|
||||
return;
|
||||
m_vel[m_nsamples * 3] = vel[0];
|
||||
m_vel[m_nsamples * 3 + 1] = vel[1];
|
||||
m_vel[m_nsamples * 3 + 2] = vel[2];
|
||||
m_vel[m_nsamples * 3] = vel.x;
|
||||
m_vel[m_nsamples * 3 + 1] = vel.y;
|
||||
m_vel[m_nsamples * 3 + 2] = vel.z;
|
||||
m_ssize[m_nsamples] = ssize;
|
||||
m_pen[m_nsamples] = pen;
|
||||
m_vpen[m_nsamples] = vpen;
|
||||
|
@ -104,9 +104,9 @@ namespace DotRecast.Detour.Crowd.Tracking
|
|||
public Vector3f getSampleVelocity(int i)
|
||||
{
|
||||
Vector3f vel = new Vector3f();
|
||||
vel[0] = m_vel[i * 3];
|
||||
vel[1] = m_vel[i * 3 + 1];
|
||||
vel[2] = m_vel[i * 3 + 2];
|
||||
vel.x = m_vel[i * 3];
|
||||
vel.y = m_vel[i * 3 + 1];
|
||||
vel.z = m_vel[i * 3 + 2];
|
||||
return vel;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue