Skip to content

Commit

Permalink
Unfucked limsa and slightly unfucked southern thanalan.
Browse files Browse the repository at this point in the history
  • Loading branch information
awgil committed Mar 16, 2024
1 parent 82946c3 commit e612f61
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion vnavmesh/Navmesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Navmesh;
public record class Navmesh(DtNavMesh Mesh, VoxelMap? Volume)
{
public static readonly uint Magic = 0x444D564E; // 'NVMD'
public static readonly uint Version = 11;
public static readonly uint Version = 12;

// throws an exception on failure
public static Navmesh Deserialize(BinaryReader reader, NavmeshSettings settings)
Expand Down
4 changes: 2 additions & 2 deletions vnavmesh/NavmeshBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public Intermediates BuildTile(int x, int z)
var shf = new RcHeightfield(_tileSizeXVoxels, _tileSizeZVoxels, tileBoundsMin.SystemToRecast(), tileBoundsMax.SystemToRecast(), Settings.CellSize, Settings.CellHeight, _borderSizeVoxels);
var vox = Navmesh.Volume != null ? new Voxelizer(_voxelizerNumX, _voxelizerNumY, _voxelizerNumZ) : null;
var rasterizer = new NavmeshRasterizer(shf, _walkableNormalThreshold, _walkableClimbVoxels, _walkableHeightVoxels, Settings.Filtering.HasFlag(NavmeshSettings.Filter.Interiors), vox, Telemetry);
rasterizer.Rasterize(Scene, SceneExtractor.MeshType.Terrain | SceneExtractor.MeshType.AnalyticPlane, false, true); // rasterize terrain
rasterizer.Rasterize(Scene, SceneExtractor.MeshType.FileMesh | SceneExtractor.MeshType.CylinderMesh | SceneExtractor.MeshType.AnalyticShape, true, true); // rasterize everything else
rasterizer.Rasterize(Scene, SceneExtractor.MeshType.FileMesh | SceneExtractor.MeshType.CylinderMesh | SceneExtractor.MeshType.AnalyticShape, true, true); // rasterize normal geometry
rasterizer.Rasterize(Scene, SceneExtractor.MeshType.Terrain | SceneExtractor.MeshType.AnalyticPlane, false, true); // rasterize terrain and bounding planes

// 2. perform a bunch of postprocessing on a heightfield
if (Settings.Filtering.HasFlag(NavmeshSettings.Filter.LowHangingObstacles))
Expand Down
12 changes: 6 additions & 6 deletions vnavmesh/NavmeshRasterizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,12 @@ public bool RasterizeMesh(SceneExtractor.Mesh mesh, SceneExtractor.MeshInstance
return true;
}

private void AddSpan(int x, int z, int y0, int y1, int areaId, bool includeInVolume)
private void AddSpan(int x, int z, int y0, int y1, int areaId, bool includeInVolume, bool mergeBelow = true)
{
ref var cellHead = ref _heightfield.spans[z * _heightfield.width + x];

// find insert position for new span: skip any existing spans that end before new span start
var prevMaxY = y0 - _minSpanGap - 1; // any spans that have smax >= prevMaxY are merged
var prevMaxY = mergeBelow ? y0 - _minSpanGap - 1 : y1; // any spans that have smax >= prevMaxY are merged
var nextMinY = y1 + _minSpanGap + 1; // any spans that have smin <= nextMinY are merged
uint prevSpanIndex = 0;
uint currSpanIndex = cellHead;
Expand All @@ -339,7 +339,7 @@ private void AddSpan(int x, int z, int y0, int y1, int areaId, bool includeInVol
var heightDiff = currSpan.smax - y1;
if (heightDiff > _walkableClimbThreshold || heightDiff >= -_walkableClimbThreshold && currSpan.area > areaId)
areaId = currSpan.area;
y0 = Math.Min(y0, currSpan.smin);
y0 = mergeBelow ? Math.Min(y0, currSpan.smin) : Math.Max(y0, currSpan.smax);
y1 = Math.Max(y1, currSpan.smax);

// free merged span; note that prev would still point to it, we'll fix it later
Expand Down Expand Up @@ -398,9 +398,9 @@ private void FillInterior(int z0, int z1, int x0, int x1, int yBelowNonManifold)
if (solidVoxel[idx] > yBelowNonManifold)
{
// non-manifold mesh, assume everything below is interior
//while (idx + 1 < cnt && solidVoxel[idx + 1] > yBelowNonManifold)
// ++idx; // well i dunno, some terrain (eg south thanalan) is really _that_ fucked
AddSpan(x, z, yBelowNonManifold, solidVoxel[idx], 0, true);
while (idx + 1 < cnt && solidVoxel[idx + 1] > yBelowNonManifold)
++idx; // well i dunno, some terrain (eg south thanalan) is really _that_ fucked
AddSpan(x, z, yBelowNonManifold, solidVoxel[idx], 0, true, false);
++idx;
}

Expand Down

0 comments on commit e612f61

Please sign in to comment.