changed new float[] -> Vector3f

This commit is contained in:
ikpil 2023-04-16 17:34:04 +09:00
parent 65e3fb3259
commit 8260ebbe52
4 changed files with 9 additions and 22 deletions

View File

@ -939,16 +939,6 @@ namespace DotRecast.Core
return Tuple.Create(s, t); return Tuple.Create(s, t);
} }
public static float[] vScale(float[] @in, float scale)
{
float[] @out = new float[3];
@out[0] = @in[0] * scale;
@out[1] = @in[1] * scale;
@out[2] = @in[2] * scale;
return @out;
}
public static Vector3f vScale(Vector3f @in, float scale) public static Vector3f vScale(Vector3f @in, float scale)
{ {
var @out = new Vector3f(); var @out = new Vector3f();

View File

@ -7,7 +7,7 @@ namespace DotRecast.Core
public float x; public float x;
public float y; public float y;
public static readonly Vector2f Zero = new Vector2f { x = 0, y = 0 }; public static Vector2f Zero { get; } = new Vector2f { x = 0, y = 0 };
public float Get(int idx) public float Get(int idx)
{ {

View File

@ -48,8 +48,8 @@ namespace DotRecast.Detour.Extras.Unity.Astar
connection.poly = poly; connection.poly = poly;
connection.pos = new float[] connection.pos = new float[]
{ {
l.clamped1.x, l.clamped1.y, l.clamped1.z, l.clamped2.x, l.clamped2.y, l.clamped1.x, l.clamped1.y, l.clamped1.z,
l.clamped2.z l.clamped2.x, l.clamped2.y, l.clamped2.z
}; };
connection.rad = 0.1f; connection.rad = 0.1f;
connection.side = startTile == endTile connection.side = startTile == endTile

View File

@ -2241,7 +2241,8 @@ namespace DotRecast.Detour
float[] verts = new float[m_nav.getMaxVertsPerPoly() * 3 + 3]; float[] verts = new float[m_nav.getMaxVertsPerPoly() * 3 + 3];
Vector3f curPos = new Vector3f(), lastPos = new Vector3f(); Vector3f curPos = Vector3f.Zero;
Vector3f lastPos = Vector3f.Zero;
curPos = startPos; curPos = startPos;
var dir = vSub(endPos, startPos); var dir = vSub(endPos, startPos);
@ -2369,9 +2370,7 @@ namespace DotRecast.Detour
+ (tile.data.verts[right + 2] - tile.data.verts[left + 2]) * (link.bmax * s); + (tile.data.verts[right + 2] - tile.data.verts[left + 2]) * (link.bmax * s);
if (lmin > lmax) if (lmin > lmax)
{ {
float temp = lmin; (lmin, lmax) = (lmax, lmin);
lmin = lmax;
lmax = temp;
} }
// Find Z intersection. // Find Z intersection.
@ -2391,9 +2390,7 @@ namespace DotRecast.Detour
+ (tile.data.verts[right] - tile.data.verts[left]) * (link.bmax * s); + (tile.data.verts[right] - tile.data.verts[left]) * (link.bmax * s);
if (lmin > lmax) if (lmin > lmax)
{ {
float temp = lmin; (lmin, lmax) = (lmax, lmin);
lmin = lmax;
lmax = temp;
} }
// Find X intersection. // Find X intersection.
@ -2692,7 +2689,7 @@ namespace DotRecast.Detour
m_nodePool.clear(); m_nodePool.clear();
m_openList.clear(); m_openList.clear();
float[] centerPos = new float[] { 0, 0, 0 }; Vector3f centerPos = Vector3f.Zero;
for (int i = 0; i < nverts; ++i) for (int i = 0; i < nverts; ++i)
{ {
centerPos[0] += verts[i * 3]; centerPos[0] += verts[i * 3];
@ -2706,7 +2703,7 @@ namespace DotRecast.Detour
centerPos[2] *= scale; centerPos[2] *= scale;
Node startNode = m_nodePool.getNode(startRef); Node startNode = m_nodePool.getNode(startRef);
vCopy(ref startNode.pos, centerPos); startNode.pos = centerPos;
startNode.pidx = 0; startNode.pidx = 0;
startNode.cost = 0; startNode.cost = 0;
startNode.total = 0; startNode.total = 0;