012 -> xyz

This commit is contained in:
ikpil 2023-04-29 13:11:38 +09:00
parent 3ecfa5d9fd
commit 6ead61661d
12 changed files with 94 additions and 94 deletions

View File

@ -46,9 +46,9 @@ namespace DotRecast.Detour.Dynamic.Colliders
float s0 = (i & 1) != 0 ? 1f : -1f; float s0 = (i & 1) != 0 ? 1f : -1f;
float s1 = (i & 2) != 0 ? 1f : -1f; float s1 = (i & 2) != 0 ? 1f : -1f;
float s2 = (i & 4) != 0 ? 1f : -1f; float s2 = (i & 4) != 0 ? 1f : -1f;
float vx = center[0] + s0 * halfEdges[0][0] + s1 * halfEdges[1][0] + s2 * halfEdges[2][0]; float vx = center.x + s0 * halfEdges[0].x + s1 * halfEdges[1].x + s2 * halfEdges[2].x;
float vy = center[1] + s0 * halfEdges[0][1] + s1 * halfEdges[1][1] + s2 * halfEdges[2][1]; float vy = center.y + s0 * halfEdges[0].y + s1 * halfEdges[1].y + s2 * halfEdges[2].y;
float vz = center[2] + s0 * halfEdges[0][2] + s1 * halfEdges[1][2] + s2 * halfEdges[2][2]; float vz = center.z + s0 * halfEdges[0].z + s1 * halfEdges[1].z + s2 * halfEdges[2].z;
bounds[0] = Math.Min(bounds[0], vx); bounds[0] = Math.Min(bounds[0], vx);
bounds[1] = Math.Min(bounds[1], vy); bounds[1] = Math.Min(bounds[1], vy);
bounds[2] = Math.Min(bounds[2], vz); bounds[2] = Math.Min(bounds[2], vz);
@ -71,7 +71,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
Vector3f[] halfEdges = Vector3f[] halfEdges =
{ {
Vector3f.Zero, Vector3f.Zero,
Vector3f.Of(up[0], up[1], up[2]), Vector3f.Of(up.x, up.y, up.z),
Vector3f.Zero Vector3f.Zero
}; };
RecastVectors.normalize(ref halfEdges[1]); RecastVectors.normalize(ref halfEdges[1]);
@ -79,15 +79,15 @@ namespace DotRecast.Detour.Dynamic.Colliders
RecastVectors.normalize(ref halfEdges[0]); RecastVectors.normalize(ref halfEdges[0]);
RecastVectors.cross(ref halfEdges[2], halfEdges[0], up); RecastVectors.cross(ref halfEdges[2], halfEdges[0], up);
RecastVectors.normalize(ref halfEdges[2]); RecastVectors.normalize(ref halfEdges[2]);
halfEdges[0][0] *= extent[0]; halfEdges[0].x *= extent.x;
halfEdges[0][1] *= extent[0]; halfEdges[0].y *= extent.x;
halfEdges[0][2] *= extent[0]; halfEdges[0].z *= extent.x;
halfEdges[1][0] *= extent[1]; halfEdges[1].x *= extent.y;
halfEdges[1][1] *= extent[1]; halfEdges[1].y *= extent.y;
halfEdges[1][2] *= extent[1]; halfEdges[1].z *= extent.y;
halfEdges[2][0] *= extent[2]; halfEdges[2].x *= extent.z;
halfEdges[2][1] *= extent[2]; halfEdges[2].y *= extent.z;
halfEdges[2][2] *= extent[2]; halfEdges[2].z *= extent.z;
return halfEdges; return halfEdges;
} }
} }

View File

@ -46,9 +46,9 @@ namespace DotRecast.Detour.Dynamic.Colliders
{ {
return new float[] return new float[]
{ {
Math.Min(start[0], end[0]) - radius, Math.Min(start[1], end[1]) - radius, Math.Min(start.x, end.x) - radius, Math.Min(start.y, end.y) - radius,
Math.Min(start[2], end[2]) - radius, Math.Max(start[0], end[0]) + radius, Math.Max(start[1], end[1]) + radius, Math.Min(start.z, end.z) - radius, Math.Max(start.x, end.x) + radius, Math.Max(start.y, end.y) + radius,
Math.Max(start[2], end[2]) + radius Math.Max(start.z, end.z) + radius
}; };
} }
} }

View File

@ -46,9 +46,9 @@ namespace DotRecast.Detour.Dynamic.Colliders
{ {
return new float[] return new float[]
{ {
Math.Min(start[0], end[0]) - radius, Math.Min(start[1], end[1]) - radius, Math.Min(start.x, end.x) - radius, Math.Min(start.y, end.y) - radius,
Math.Min(start[2], end[2]) - radius, Math.Max(start[0], end[0]) + radius, Math.Max(start[1], end[1]) + radius, Math.Min(start.z, end.z) - radius, Math.Max(start.x, end.x) + radius, Math.Max(start.y, end.y) + radius,
Math.Max(start[2], end[2]) + radius Math.Max(start.z, end.z) + radius
}; };
} }
} }

View File

@ -44,12 +44,12 @@ namespace DotRecast.Detour.Dynamic.Colliders
{ {
return new float[] return new float[]
{ {
center[0] - radius, center.x - radius,
center[1] - radius, center.y - radius,
center[2] - radius, center.z - radius,
center[0] + radius, center.x + radius,
center[1] + radius, center.y + radius,
center[2] + radius center.z + radius
}; };
} }
} }

View File

@ -59,9 +59,9 @@ namespace DotRecast.Detour.Dynamic
config.detailSampleMaxError = voxelFile.detailSampleMaxError; config.detailSampleMaxError = voxelFile.detailSampleMaxError;
builder = new RecastBuilder(); builder = new RecastBuilder();
navMeshParams = new NavMeshParams(); navMeshParams = new NavMeshParams();
navMeshParams.orig[0] = voxelFile.bounds[0]; navMeshParams.orig.x = voxelFile.bounds[0];
navMeshParams.orig[1] = voxelFile.bounds[1]; navMeshParams.orig.y = voxelFile.bounds[1];
navMeshParams.orig[2] = voxelFile.bounds[2]; navMeshParams.orig.z = voxelFile.bounds[2];
navMeshParams.tileWidth = voxelFile.cellSize * voxelFile.tileSizeX; navMeshParams.tileWidth = voxelFile.cellSize * voxelFile.tileSizeX;
navMeshParams.tileHeight = voxelFile.cellSize * voxelFile.tileSizeZ; navMeshParams.tileHeight = voxelFile.cellSize * voxelFile.tileSizeZ;
navMeshParams.maxTiles = voxelFile.tiles.Count; navMeshParams.maxTiles = voxelFile.tiles.Count;
@ -189,10 +189,10 @@ namespace DotRecast.Detour.Dynamic
return _tiles.Values; return _tiles.Values;
} }
int minx = (int)Math.Floor((bounds[0] - navMeshParams.orig[0]) / navMeshParams.tileWidth); int minx = (int)Math.Floor((bounds[0] - navMeshParams.orig.x) / navMeshParams.tileWidth);
int minz = (int)Math.Floor((bounds[2] - navMeshParams.orig[2]) / navMeshParams.tileHeight); int minz = (int)Math.Floor((bounds[2] - navMeshParams.orig.z) / navMeshParams.tileHeight);
int maxx = (int)Math.Floor((bounds[3] - navMeshParams.orig[0]) / navMeshParams.tileWidth); int maxx = (int)Math.Floor((bounds[3] - navMeshParams.orig.x) / navMeshParams.tileWidth);
int maxz = (int)Math.Floor((bounds[5] - navMeshParams.orig[2]) / navMeshParams.tileHeight); int maxz = (int)Math.Floor((bounds[5] - navMeshParams.orig.z) / navMeshParams.tileHeight);
List<DynamicTile> tiles = new List<DynamicTile>(); List<DynamicTile> tiles = new List<DynamicTile>();
for (int z = minz; z <= maxz; ++z) for (int z = minz; z <= maxz; ++z)
{ {

View File

@ -65,7 +65,7 @@ namespace DotRecast.Detour.Dynamic
{ {
if (!rasterizedColliders.Contains(cid)) if (!rasterizedColliders.Contains(cid))
{ {
heightfield.bmax[1] = Math.Max(heightfield.bmax[1], c.bounds()[4] + heightfield.ch * 2); heightfield.bmax.y = Math.Max(heightfield.bmax.y, c.bounds()[4] + heightfield.ch * 2);
c.rasterize(heightfield, telemetry); c.rasterize(heightfield, telemetry);
} }
} }

View File

@ -103,12 +103,12 @@ namespace DotRecast.Detour.Dynamic.Io
foreach (RecastBuilderResult r in results) foreach (RecastBuilderResult r in results)
{ {
f.tiles.Add(new VoxelTile(r.tileX, r.tileZ, r.getSolidHeightfield())); f.tiles.Add(new VoxelTile(r.tileX, r.tileZ, r.getSolidHeightfield()));
f.bounds[0] = Math.Min(f.bounds[0], r.getSolidHeightfield().bmin[0]); f.bounds[0] = Math.Min(f.bounds[0], r.getSolidHeightfield().bmin.x);
f.bounds[1] = Math.Min(f.bounds[1], r.getSolidHeightfield().bmin[1]); f.bounds[1] = Math.Min(f.bounds[1], r.getSolidHeightfield().bmin.y);
f.bounds[2] = Math.Min(f.bounds[2], r.getSolidHeightfield().bmin[2]); f.bounds[2] = Math.Min(f.bounds[2], r.getSolidHeightfield().bmin.z);
f.bounds[3] = Math.Max(f.bounds[3], r.getSolidHeightfield().bmax[0]); f.bounds[3] = Math.Max(f.bounds[3], r.getSolidHeightfield().bmax.x);
f.bounds[4] = Math.Max(f.bounds[4], r.getSolidHeightfield().bmax[1]); f.bounds[4] = Math.Max(f.bounds[4], r.getSolidHeightfield().bmax.y);
f.bounds[5] = Math.Max(f.bounds[5], r.getSolidHeightfield().bmax[2]); f.bounds[5] = Math.Max(f.bounds[5], r.getSolidHeightfield().bmax.z);
} }
return f; return f;
@ -148,12 +148,12 @@ namespace DotRecast.Detour.Dynamic.Io
{ {
Heightfield heightfield = vt.heightfield(); Heightfield heightfield = vt.heightfield();
f.tiles.Add(new VoxelTile(vt.tileX, vt.tileZ, heightfield)); f.tiles.Add(new VoxelTile(vt.tileX, vt.tileZ, heightfield));
f.bounds[0] = Math.Min(f.bounds[0], vt.boundsMin[0]); f.bounds[0] = Math.Min(f.bounds[0], vt.boundsMin.x);
f.bounds[1] = Math.Min(f.bounds[1], vt.boundsMin[1]); f.bounds[1] = Math.Min(f.bounds[1], vt.boundsMin.y);
f.bounds[2] = Math.Min(f.bounds[2], vt.boundsMin[2]); f.bounds[2] = Math.Min(f.bounds[2], vt.boundsMin.z);
f.bounds[3] = Math.Max(f.bounds[3], vt.boundsMax[0]); f.bounds[3] = Math.Max(f.bounds[3], vt.boundsMax.x);
f.bounds[4] = Math.Max(f.bounds[4], vt.boundsMax[1]); f.bounds[4] = Math.Max(f.bounds[4], vt.boundsMax.y);
f.bounds[5] = Math.Max(f.bounds[5], vt.boundsMax[2]); f.bounds[5] = Math.Max(f.bounds[5], vt.boundsMax.z);
} }
return f; return f;

View File

@ -73,9 +73,9 @@ namespace DotRecast.Detour.Dynamic.Io
file.useTiles = buf.get() != 0; file.useTiles = buf.get() != 0;
file.tileSizeX = buf.getInt(); file.tileSizeX = buf.getInt();
file.tileSizeZ = buf.getInt(); file.tileSizeZ = buf.getInt();
file.rotation[0] = buf.getFloat(); file.rotation.x = buf.getFloat();
file.rotation[1] = buf.getFloat(); file.rotation.y = buf.getFloat();
file.rotation[2] = buf.getFloat(); file.rotation.z = buf.getFloat();
file.bounds[0] = buf.getFloat(); file.bounds[0] = buf.getFloat();
file.bounds[1] = buf.getFloat(); file.bounds[1] = buf.getFloat();
file.bounds[2] = buf.getFloat(); file.bounds[2] = buf.getFloat();
@ -102,22 +102,22 @@ namespace DotRecast.Detour.Dynamic.Io
int depth = buf.getInt(); int depth = buf.getInt();
int borderSize = buf.getInt(); int borderSize = buf.getInt();
Vector3f boundsMin = new Vector3f(); Vector3f boundsMin = new Vector3f();
boundsMin[0] = buf.getFloat(); boundsMin.x = buf.getFloat();
boundsMin[1] = buf.getFloat(); boundsMin.y = buf.getFloat();
boundsMin[2] = buf.getFloat(); boundsMin.z = buf.getFloat();
Vector3f boundsMax = new Vector3f(); Vector3f boundsMax = new Vector3f();
boundsMax[0] = buf.getFloat(); boundsMax.x = buf.getFloat();
boundsMax[1] = buf.getFloat(); boundsMax.y = buf.getFloat();
boundsMax[2] = buf.getFloat(); boundsMax.z = buf.getFloat();
if (isExportedFromAstar) if (isExportedFromAstar)
{ {
// bounds are local // bounds are local
boundsMin[0] += file.bounds[0]; boundsMin.x += file.bounds[0];
boundsMin[1] += file.bounds[1]; boundsMin.y += file.bounds[1];
boundsMin[2] += file.bounds[2]; boundsMin.z += file.bounds[2];
boundsMax[0] += file.bounds[0]; boundsMax.x += file.bounds[0];
boundsMax[1] += file.bounds[1]; boundsMax.y += file.bounds[1];
boundsMax[2] += file.bounds[2]; boundsMax.z += file.bounds[2];
} }
float cellSize = buf.getFloat(); float cellSize = buf.getFloat();

View File

@ -51,9 +51,9 @@ namespace DotRecast.Detour.Dynamic.Io
write(stream, f.useTiles); write(stream, f.useTiles);
write(stream, f.tileSizeX, byteOrder); write(stream, f.tileSizeX, byteOrder);
write(stream, f.tileSizeZ, byteOrder); write(stream, f.tileSizeZ, byteOrder);
write(stream, f.rotation[0], byteOrder); write(stream, f.rotation.x, byteOrder);
write(stream, f.rotation[1], byteOrder); write(stream, f.rotation.y, byteOrder);
write(stream, f.rotation[2], byteOrder); write(stream, f.rotation.z, byteOrder);
write(stream, f.bounds[0], byteOrder); write(stream, f.bounds[0], byteOrder);
write(stream, f.bounds[1], byteOrder); write(stream, f.bounds[1], byteOrder);
write(stream, f.bounds[2], byteOrder); write(stream, f.bounds[2], byteOrder);
@ -74,12 +74,12 @@ namespace DotRecast.Detour.Dynamic.Io
write(stream, tile.width, byteOrder); write(stream, tile.width, byteOrder);
write(stream, tile.depth, byteOrder); write(stream, tile.depth, byteOrder);
write(stream, tile.borderSize, byteOrder); write(stream, tile.borderSize, byteOrder);
write(stream, tile.boundsMin[0], byteOrder); write(stream, tile.boundsMin.x, byteOrder);
write(stream, tile.boundsMin[1], byteOrder); write(stream, tile.boundsMin.y, byteOrder);
write(stream, tile.boundsMin[2], byteOrder); write(stream, tile.boundsMin.z, byteOrder);
write(stream, tile.boundsMax[0], byteOrder); write(stream, tile.boundsMax.x, byteOrder);
write(stream, tile.boundsMax[1], byteOrder); write(stream, tile.boundsMax.y, byteOrder);
write(stream, tile.boundsMax[2], byteOrder); write(stream, tile.boundsMax.z, byteOrder);
write(stream, tile.cellSize, byteOrder); write(stream, tile.cellSize, byteOrder);
write(stream, tile.cellHeight, byteOrder); write(stream, tile.cellHeight, byteOrder);
byte[] bytes = tile.spanData; byte[] bytes = tile.spanData;

View File

@ -54,20 +54,20 @@ namespace DotRecast.Detour.Dynamic
private float? traverseTiles(Vector3f start, Vector3f end) private float? traverseTiles(Vector3f start, Vector3f end)
{ {
float relStartX = start[0] - origin[0]; float relStartX = start.x - origin.x;
float relStartZ = start[2] - origin[2]; float relStartZ = start.z - origin.z;
int sx = (int)Math.Floor(relStartX / tileWidth); int sx = (int)Math.Floor(relStartX / tileWidth);
int sz = (int)Math.Floor(relStartZ / tileDepth); int sz = (int)Math.Floor(relStartZ / tileDepth);
int ex = (int)Math.Floor((end[0] - origin[0]) / tileWidth); int ex = (int)Math.Floor((end.x - origin.x) / tileWidth);
int ez = (int)Math.Floor((end[2] - origin[2]) / tileDepth); int ez = (int)Math.Floor((end.z - origin.z) / tileDepth);
int dx = ex - sx; int dx = ex - sx;
int dz = ez - sz; int dz = ez - sz;
int stepX = dx < 0 ? -1 : 1; int stepX = dx < 0 ? -1 : 1;
int stepZ = dz < 0 ? -1 : 1; int stepZ = dz < 0 ? -1 : 1;
float xRem = (tileWidth + (relStartX % tileWidth)) % tileWidth; float xRem = (tileWidth + (relStartX % tileWidth)) % tileWidth;
float zRem = (tileDepth + (relStartZ % tileDepth)) % tileDepth; float zRem = (tileDepth + (relStartZ % tileDepth)) % tileDepth;
float tx = end[0] - start[0]; float tx = end.x - start.x;
float tz = end[2] - start[2]; float tz = end.z - start.z;
float xOffest = Math.Abs(tx < 0 ? xRem : tileWidth - xRem); float xOffest = Math.Abs(tx < 0 ? xRem : tileWidth - xRem);
float zOffest = Math.Abs(tz < 0 ? zRem : tileDepth - zRem); float zOffest = Math.Abs(tz < 0 ? zRem : tileDepth - zRem);
tx = Math.Abs(tx); tx = Math.Abs(tx);
@ -112,17 +112,17 @@ namespace DotRecast.Detour.Dynamic
Heightfield hf = heightfieldProvider.Invoke(x, z); Heightfield hf = heightfieldProvider.Invoke(x, z);
if (null != hf) if (null != hf)
{ {
float tx = end[0] - start[0]; float tx = end.x - start.x;
float ty = end[1] - start[1]; float ty = end.y - start.y;
float tz = end[2] - start[2]; float tz = end.z - start.z;
float[] entry = { start[0] + tMin * tx, start[1] + tMin * ty, start[2] + tMin * tz }; float[] entry = { start.x + tMin * tx, start.y + tMin * ty, start.z + tMin * tz };
float[] exit = { start[0] + tMax * tx, start[1] + tMax * ty, start[2] + tMax * tz }; float[] exit = { start.x + tMax * tx, start.y + tMax * ty, start.z + tMax * tz };
float relStartX = entry[0] - hf.bmin[0]; float relStartX = entry[0] - hf.bmin.x;
float relStartZ = entry[2] - hf.bmin[2]; float relStartZ = entry[2] - hf.bmin.z;
int sx = (int)Math.Floor(relStartX / hf.cs); int sx = (int)Math.Floor(relStartX / hf.cs);
int sz = (int)Math.Floor(relStartZ / hf.cs); int sz = (int)Math.Floor(relStartZ / hf.cs);
int ex = (int)Math.Floor((exit[0] - hf.bmin[0]) / hf.cs); int ex = (int)Math.Floor((exit[0] - hf.bmin.x) / hf.cs);
int ez = (int)Math.Floor((exit[2] - hf.bmin[2]) / hf.cs); int ez = (int)Math.Floor((exit[2] - hf.bmin.z) / hf.cs);
int dx = ex - sx; int dx = ex - sx;
int dz = ez - sz; int dz = ez - sz;
int stepX = dx < 0 ? -1 : 1; int stepX = dx < 0 ? -1 : 1;
@ -142,8 +142,8 @@ namespace DotRecast.Detour.Dynamic
{ {
if (sx >= 0 && sx < hf.width && sz >= 0 && sz < hf.height) if (sx >= 0 && sx < hf.width && sz >= 0 && sz < hf.height)
{ {
float y1 = start[1] + ty * (tMin + t) - hf.bmin[1]; float y1 = start.y + ty * (tMin + t) - hf.bmin.y;
float y2 = start[1] + ty * (tMin + Math.Min(tMaxX, tMaxZ)) - hf.bmin[1]; float y2 = start.y + ty * (tMin + Math.Min(tMaxX, tMaxZ)) - hf.bmin.y;
float ymin = Math.Min(y1, y2) / hf.ch; float ymin = Math.Min(y1, y2) / hf.ch;
float ymax = Math.Max(y1, y2) / hf.ch; float ymax = Math.Max(y1, y2) / hf.ch;
Span span = hf.spans[sx + sz * hf.width]; Span span = hf.spans[sx + sz * hf.width];