change float[] -> Vector3f

This commit is contained in:
ikpil 2023-04-22 12:27:52 +09:00
parent 4662542675
commit f232d5638d
4 changed files with 14 additions and 7 deletions

View File

@ -371,13 +371,13 @@ namespace DotRecast.Detour.TileCache
} }
// Aabb obstacle // Aabb obstacle
public long addBoxObstacle(float[] bmin, float[] bmax) public long addBoxObstacle(Vector3f bmin, Vector3f bmax)
{ {
TileCacheObstacle ob = allocObstacle(); TileCacheObstacle ob = allocObstacle();
ob.type = TileCacheObstacle.TileCacheObstacleType.BOX; ob.type = TileCacheObstacle.TileCacheObstacleType.BOX;
vCopy(ref ob.bmin, bmin); ob.bmin = bmin;
vCopy(ref ob.bmax, bmax); ob.bmax = bmax;
return addObstacleRequest(ob).refs; return addObstacleRequest(ob).refs;
} }

View File

@ -684,7 +684,7 @@ namespace DotRecast.Recast
} }
// rectangle vertex // rectangle vertex
float[] point = new float[] { 0, rectangle[1], 0 }; var point = Vector3f.Of(0, rectangle[1], 0);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
point[0] = ((i & 1) == 0) ? rectangle[0] : rectangle[2]; point[0] = ((i & 1) == 0) ? rectangle[0] : rectangle[2];
@ -740,7 +740,7 @@ namespace DotRecast.Recast
return null; return null;
} }
private static float? rayTriangleIntersection(float[] point, int plane, float[][] planes) private static float? rayTriangleIntersection(Vector3f point, int plane, float[][] planes)
{ {
float t = (planes[plane][3] - dot(planes[plane], point)) / planes[plane][1]; float t = (planes[plane][3] - dot(planes[plane], point)) / planes[plane][1];
float[] s = { point[0], point[1] + t, point[2] }; float[] s = { point[0], point[1] + t, point[2] };

View File

@ -168,6 +168,11 @@ namespace DotRecast.Recast
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]; return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
} }
public static float dot(float[] v1, Vector3f v2)
{
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
}
public static float dot(Vector3f v1, Vector3f v2) public static float dot(Vector3f v1, Vector3f v2)
{ {
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]; return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];

View File

@ -80,8 +80,10 @@ public class TempObstaclesTest : AbstractTileCacheTest
MeshTile tile = tiles[0]; MeshTile tile = tiles[0];
Assert.That(tile.data.header.vertCount, Is.EqualTo(16)); Assert.That(tile.data.header.vertCount, Is.EqualTo(16));
Assert.That(tile.data.header.polyCount, Is.EqualTo(6)); Assert.That(tile.data.header.polyCount, Is.EqualTo(6));
long o = tc.addBoxObstacle(new float[] { -2.315208f, 9.998184f, -20.807983f }, long o = tc.addBoxObstacle(
new float[] { -1.315208f, 11.998184f, -19.807983f }); Vector3f.Of(-2.315208f, 9.998184f, -20.807983f),
Vector3f.Of(-1.315208f, 11.998184f, -19.807983f)
);
bool upToDate = tc.update(); bool upToDate = tc.update();
Assert.That(upToDate, Is.True); Assert.That(upToDate, Is.True);
tiles = tc.getNavMesh().getTilesAt(1, 4); tiles = tc.getNavMesh().getTilesAt(1, 4);