RynthSuite as of 2026-11-23 (internal 327a8263): release 2026.11.23.1
This commit is contained in:
parent
660e6b5b1c
commit
759009b569
196 changed files with 21066 additions and 1021 deletions
71
Tools/RynthNav.GraphTests/PortalFloorTests.cs
Normal file
71
Tools/RynthNav.GraphTests/PortalFloorTests.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using DotRecast.Core;
|
||||
using DotRecast.Core.Numerics;
|
||||
using DotRecast.Detour;
|
||||
using RynthNav.Routing;
|
||||
|
||||
|
||||
|
||||
// 11-18: the goto stood 1 u from Zaikhal's Olthoi Tunnel, 7.7 u above it on the street, and circled it:
|
||||
// the goal was looked up from the walker's own height, so the nearest polygon was the street right above
|
||||
// the portal, not the tunnel floor it stands on. NavPathQuery.PortalFloor finds the floor by the portal's
|
||||
// own height, and Reaches says whether a walk gets there (that tunnel's floor is a piece of its own: no).
|
||||
internal static partial class Program
|
||||
{
|
||||
private static void RunPortalFloors()
|
||||
{
|
||||
Run(nameof(RealPortalFloors), RealPortalFloors);
|
||||
}
|
||||
|
||||
private static DtNavMeshQuery? Around(string dir, uint lb)
|
||||
{
|
||||
if (!File.Exists(Path.Combine(dir, $"nav_{lb:X4}.tile"))) return null;
|
||||
var nav = new DtNavMesh();
|
||||
nav.Init(new DtNavMeshParams { orig = new RcVec3f(0, 0, 0), tileWidth = 192f, tileHeight = 192f, maxTiles = 64, maxPolys = 1 << 16 }, 6);
|
||||
for (int dx = -1; dx <= 1; dx++)
|
||||
for (int dy = -1; dy <= 1; dy++)
|
||||
{
|
||||
uint t = (uint)((((int)(lb >> 8) + dx) << 8) | ((int)(lb & 0xFF) + dy));
|
||||
if (File.Exists(Path.Combine(dir, $"nav_{t:X4}.tile"))) nav.AddTile(ReadTile(dir, t), 0, 0, out _);
|
||||
}
|
||||
return new DtNavMeshQuery(nav);
|
||||
}
|
||||
|
||||
private static void RealPortalFloors()
|
||||
{
|
||||
string dir = Environment.GetEnvironmentVariable("RYNTHNAV_NAVDATA") ?? @"C:\Games\RynthCore\NavData";
|
||||
DtNavMeshQuery? q = Around(dir, 0x7F8F);
|
||||
if (q == null) { Console.WriteLine(" (no real NavData here: skipped)"); return; }
|
||||
var filter = new DtQueryDefaultFilter();
|
||||
|
||||
// Zaikhal's Olthoi Tunnel: cell 7F8F0123 at (83.92, 21.12, 118.34); the street above is ~126.
|
||||
double e = 0x7F * 192 + 83.92, n = 0x8F * 192 + 21.12, z = 118.34;
|
||||
long floor = NavPathQuery.PortalFloor(q, filter, e, z, n, out RcVec3f fPt);
|
||||
Check(floor != 0 && Math.Abs(fPt.Y - z) < 1.0, $"the tunnel floor is found by the portal's height ({(floor != 0 ? fPt.Y.ToString("F1") : "none")})");
|
||||
q.FindNearestPoly(new RcVec3f((float)e, 126.5f, (float)n), new RcVec3f(3, 1.5f, 3), filter, out long street, out RcVec3f sPt, out _);
|
||||
Check(street != 0 && sPt.Y > z + 5, $"the street right above it ({(street != 0 ? sPt.Y.ToString("F1") : "none")})");
|
||||
// The old lookup, from the walker's height on the street: the street, not the floor.
|
||||
q.FindNearestPoly(new RcVec3f((float)e, sPt.Y, (float)n), new RcVec3f(12, 256, 12), filter, out long old, out RcVec3f oPt, out _);
|
||||
Check(old != 0 && old != floor && oPt.Y > z + 5, $"looked up from the street, the goal was the street above ({oPt.Y:F1}): the 11-18 circling");
|
||||
Check(!NavPathQuery.Reaches(q, street, sPt, floor, fPt, filter), "no walk from the street reaches that floor: use it from above, then give up and plan another way");
|
||||
Check(NavPathQuery.Reaches(q, floor, fPt, floor, fPt, filter), "a floor reaches itself");
|
||||
|
||||
// A portal in a building on the ground: Town of Dryreach (3B4D0104), its floor joined to the land round it.
|
||||
DtNavMeshQuery? q2 = Around(dir, 0x3B4D);
|
||||
if (q2 == null) { Console.WriteLine(" (no tile for 3B4D: the building part skipped)"); return; }
|
||||
double e2 = 0x3B * 192 + 38.63, n2 = 0x4D * 192 + 130.22, z2 = 2.0;
|
||||
long f2 = NavPathQuery.PortalFloor(q2, filter, e2, z2, n2, out RcVec3f f2Pt);
|
||||
Check(f2 != 0, "the Dryreach portal's floor is found");
|
||||
var rnd = new RcRand(1119);
|
||||
int reached = 0, tries = 0;
|
||||
for (int i = 0; i < 10 && f2 != 0; i++)
|
||||
{
|
||||
// Ground up to 40 u away that a walk from that floor gets to: from there, back to the floor.
|
||||
if (q2.FindRandomPointAroundCircle(f2, f2Pt, 40f, filter, rnd, out long r, out RcVec3f rPt).Failed() || r == 0) continue;
|
||||
tries++;
|
||||
if (NavPathQuery.Reaches(q2, r, rPt, f2, f2Pt, filter)) reached++;
|
||||
}
|
||||
Check(tries > 0 && reached == tries, $"walks from the ground round it reach that floor ({reached}/{tries})");
|
||||
}
|
||||
}
|
||||
|
|
@ -51,6 +51,7 @@ internal static partial class Program
|
|||
Run(nameof(RaycastOnTheMesh), RaycastOnTheMesh);
|
||||
Run(nameof(RealPathEx), RealPathEx);
|
||||
Run(nameof(RealDoorsteps), RealDoorsteps);
|
||||
Run(nameof(RealYaraqThreadExit), RealYaraqThreadExit);
|
||||
Run(nameof(RealTripWalk), RealTripWalk);
|
||||
Run(nameof(MeshViewFloorAndWalls), MeshViewFloorAndWalls);
|
||||
Run(nameof(MeshViewEmitBudgetAndFrame), MeshViewEmitBudgetAndFrame);
|
||||
|
|
@ -58,6 +59,7 @@ internal static partial class Program
|
|||
Run(nameof(DungeonFileAndLayer), DungeonFileAndLayer);
|
||||
Run(nameof(RealDungeons), RealDungeons);
|
||||
RunRouteMaker(); // RouteMakerTests.cs
|
||||
RunPortalFloors(); // PortalFloorTests.cs
|
||||
}
|
||||
finally { try { Directory.Delete(_root, true); } catch { } }
|
||||
Console.WriteLine();
|
||||
|
|
@ -751,6 +753,60 @@ internal static partial class Program
|
|||
/// The real map (read only, when it's installed): FindPathEx and Raycast round Holtburg on the tiles
|
||||
/// a short query loads, a ring of goals at 40/80/150 u; the answers agree, and how long they take.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// 2026-11-18, a DreamWeave Thread in Yaraq (7D64): the Thread Exit's 4 m circle (24015.6, 19327.2)
|
||||
/// touches the edge of one 73 x 161 m polygon, the town's open middle, and the corridor round the
|
||||
/// circle left all of it out: every hunt walk from the east of town to the monsters on the west went
|
||||
/// round the north edge, 262-380 m for 72-119 m, and the hunt called them "too far round". The plain
|
||||
/// corridor, 40-97 m clear of the Exit, is taken now; a walk that does pass the Exit still goes round it.
|
||||
/// </summary>
|
||||
private static void RealYaraqThreadExit()
|
||||
{
|
||||
string dir = Environment.GetEnvironmentVariable("RYNTHNAV_NAVDATA") ?? @"C:\Games\RynthCore\NavData";
|
||||
if (!File.Exists(Path.Combine(dir, "nav_7D64.tile")) || !File.Exists(Path.Combine(dir, "nav_7C64.tile")))
|
||||
{ Console.WriteLine(" (no real NavData here: skipped)"); return; }
|
||||
var nav = new DtNavMesh();
|
||||
nav.Init(new DtNavMeshParams { orig = new RcVec3f(0, 0, 0), tileWidth = 192f, tileHeight = 192f, maxTiles = 64, maxPolys = 1 << 16 }, 6);
|
||||
for (int x = 0x7B; x <= 0x7E; x++)
|
||||
for (int y = 0x62; y <= 0x66; y++)
|
||||
{
|
||||
uint lb = (uint)((x << 8) | y);
|
||||
if (File.Exists(Path.Combine(dir, $"nav_{lb:X4}.tile"))) nav.AddTile(ReadTile(dir, lb), 0, 0, out _);
|
||||
}
|
||||
var q = new DtNavMeshQuery(nav);
|
||||
var exit = new PortalAvoid();
|
||||
exit.Set(new[] { new PortalAvoid.Spot(24015.63, 19327.15, PortalAvoid.LiveRadius, "Thread Exit") }, Array.Empty<PortalAvoid.Spot>());
|
||||
int flags = RynthNavPathApiV1.PathAvoidPortals | RynthNavPathApiV1.PathWallClearance | RynthNavPathApiV1.PathAllowPartial
|
||||
| RynthNavPathApiV1.PathQuiet | RynthNavPathApiV1.PathStartOutdoors;
|
||||
double Gap(PathExResult r)
|
||||
{
|
||||
double g = double.MaxValue;
|
||||
for (int i = 1; i < r.Corners.Count; i++)
|
||||
g = Math.Min(g, PortalAvoid.SegmentDistance(24015.63, 19327.15, r.Corners[i - 1].X, r.Corners[i - 1].Y, r.Corners[i].X, r.Corners[i].Y));
|
||||
return g;
|
||||
}
|
||||
// From the street east of the square (and building 7D64#2's door) to the monsters of that Thread on the west.
|
||||
var walks = new (double Sx, double Sy, double Gx, double Gy, double Gz, double Straight)[]
|
||||
{
|
||||
(24060, 19235, 23958.76, 19277.39, 1.69, 110), (24060, 19235, 23990.02, 19220.82, 8.34, 72),
|
||||
(24076, 19284, 23958.76, 19277.39, 1.69, 119), (24076, 19284, 23990.02, 19220.82, 8.34, 107),
|
||||
};
|
||||
foreach (var (sx, sy, gx, gy, gz, straight) in walks)
|
||||
{
|
||||
var r = Ex(q, sx, sy, gx, gy, flags, new AvoidFilter(exit), sz: 10, gz: gz, maxCorners: 128);
|
||||
Check(r.Code == RynthNavPathApiV1.ResultOk, $"({sx},{sy}) -> ({gx:F0},{gy:F0}): a way (code {r.Code})");
|
||||
Check(r.Length < straight + 15, $"({sx},{sy}) -> ({gx:F0},{gy:F0}): {r.Length:F0} m, not round the north of town (the plain way is {straight} m)");
|
||||
Check(r.PlainClear && !r.FellBack, $"({sx},{sy}) -> ({gx:F0},{gy:F0}): the plain corridor, taken because it is clear (PlainClear {r.PlainClear})");
|
||||
Check(Gap(r) > PortalAvoid.LiveRadius + NavPathQuery.PlainClearMargin, $"({sx},{sy}) -> ({gx:F0},{gy:F0}): {Gap(r):F0} m from the Thread Exit");
|
||||
Console.WriteLine($" ({sx},{sy}) -> ({gx:F0},{gy:F0}): {r.Length:F0} m, {Gap(r):F0} m from the Exit");
|
||||
}
|
||||
// A walk that does pass the Exit still goes round it: from its west side to its east side, through it.
|
||||
var past = Ex(q, 24000, 19327, 24031, 19327, flags, new AvoidFilter(exit), sz: 10, gz: 10, maxCorners: 128);
|
||||
Check(past.Code == RynthNavPathApiV1.ResultOk && !past.PlainClear, $"a walk across the Exit: not the plain corridor (code {past.Code}, PlainClear {past.PlainClear})");
|
||||
Check(Gap(past) >= PortalAvoid.LiveRadius - 0.5, $"a walk across the Exit keeps out of its circle ({Gap(past):F1} m)");
|
||||
Console.WriteLine($" across the Exit: {past.Length:F0} m, {Gap(past):F1} m from it");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RynthAi's hunt into buildings (2026-10-25) walks to a door's step out (BuildingMap: 1.5 m out of
|
||||
/// the door, at its foot) and asks RynthNav where the ground is there (a path from the step to
|
||||
|
|
|
|||
Loading…
Reference in a new issue