| | | 1 | | //======================================================================= |
| | | 2 | | // NavigationRayWork.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2024-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using System; |
| | | 9 | | using FixedMathSharp; |
| | | 10 | | using FixedMathSharp.Geometry; |
| | | 11 | | using GridForge.Grids; |
| | | 12 | | using GridForge.Grids.Topology; |
| | | 13 | | using GridForge.Utility; |
| | | 14 | | |
| | | 15 | | namespace Trailblazer.Pathing; |
| | | 16 | | |
| | | 17 | | /// <summary>Evaluates one bounded straight segment through the immutable navigation graph.</summary> |
| | | 18 | | internal sealed class NavigationRayWork |
| | | 19 | | { |
| | | 20 | | private readonly NavigationRayWorkspace _workspace; |
| | | 21 | | private NavigationRayRequest _request; |
| | | 22 | | private TraversalEvaluator _evaluator; |
| | | 23 | | private ulong _worldChangeSequence; |
| | | 24 | | private bool _meterBlocked; |
| | | 25 | | private bool _begun; |
| | | 26 | | |
| | 17226 | 27 | | internal NavigationRayWork(NavigationRayWorkspace workspace) |
| | | 28 | | { |
| | 17226 | 29 | | SwiftThrowHelper.ThrowIfNull(workspace, nameof(workspace)); |
| | 17226 | 30 | | _workspace = workspace; |
| | 17226 | 31 | | Status = NavigationRayStatus.Pending; |
| | 17226 | 32 | | } |
| | | 33 | | |
| | | 34 | | internal NavigationRayStatus Status { get; private set; } |
| | | 35 | | |
| | | 36 | | internal NavigationRayResult Result { get; private set; } |
| | | 37 | | |
| | 14933 | 38 | | private TraversalMedium Medium => _request.Medium; |
| | | 39 | | |
| | | 40 | | internal void Begin(in NavigationRayRequest request) |
| | | 41 | | { |
| | 1955 | 42 | | Reset(); |
| | 1955 | 43 | | _request = request; |
| | 1955 | 44 | | _evaluator = new TraversalEvaluator( |
| | 1955 | 45 | | request.ExpectedGraph, |
| | 1955 | 46 | | request.Profile, |
| | 1955 | 47 | | request.AreaPolicy, |
| | 1955 | 48 | | request.Medium); |
| | 1955 | 49 | | Result = default; |
| | 1955 | 50 | | Status = NavigationRayStatus.Pending; |
| | 1955 | 51 | | _worldChangeSequence = 0; |
| | 1955 | 52 | | _meterBlocked = false; |
| | 1955 | 53 | | _begun = true; |
| | 1955 | 54 | | } |
| | | 55 | | |
| | | 56 | | internal void Reset() |
| | | 57 | | { |
| | 7494 | 58 | | ReleaseExplicitConnectionReferences(); |
| | 7494 | 59 | | _workspace.Reset(); |
| | 7494 | 60 | | _request = default; |
| | 7494 | 61 | | _evaluator = default; |
| | 7494 | 62 | | Result = default; |
| | 7494 | 63 | | Status = NavigationRayStatus.Pending; |
| | 7494 | 64 | | _worldChangeSequence = 0; |
| | 7494 | 65 | | _meterBlocked = false; |
| | 7494 | 66 | | _begun = false; |
| | 7494 | 67 | | } |
| | | 68 | | |
| | | 69 | | internal NavigationRayStatus Advance(NavigationWorkMeter meter) |
| | | 70 | | { |
| | 1327 | 71 | | SwiftThrowHelper.ThrowIfNull(meter, nameof(meter)); |
| | 1327 | 72 | | GuideSampleWorkMeter unused = default; |
| | 1327 | 73 | | return AdvanceCore(meter, ref unused, useGuideMeter: false); |
| | | 74 | | } |
| | | 75 | | |
| | | 76 | | internal NavigationRayStatus Advance(ref GuideSampleWorkMeter meter) => |
| | 624 | 77 | | AdvanceCore(null, ref meter, useGuideMeter: true); |
| | | 78 | | |
| | | 79 | | private NavigationRayStatus AdvanceCore( |
| | | 80 | | NavigationWorkMeter? queryMeter, |
| | | 81 | | ref GuideSampleWorkMeter guideMeter, |
| | | 82 | | bool useGuideMeter) |
| | | 83 | | { |
| | 1951 | 84 | | if (!_begun || Status != NavigationRayStatus.Pending) |
| | 2 | 85 | | return Status; |
| | 1949 | 86 | | if (useGuideMeter |
| | 1949 | 87 | | && Medium is TraversalMedium.Gas or TraversalMedium.Liquid) |
| | | 88 | | { |
| | 1 | 89 | | return Finish(NavigationRayStatus.Blocked); |
| | | 90 | | } |
| | | 91 | | |
| | 1948 | 92 | | NavigationRayStatus traceStatus = Trace( |
| | 1948 | 93 | | queryMeter, |
| | 1948 | 94 | | ref guideMeter, |
| | 1948 | 95 | | useGuideMeter); |
| | 1948 | 96 | | if (traceStatus != NavigationRayStatus.Pending) |
| | 91 | 97 | | return Finish(traceStatus); |
| | 1857 | 98 | | NavigationRayStatus mapStatus = MapIntervals( |
| | 1857 | 99 | | queryMeter, |
| | 1857 | 100 | | ref guideMeter, |
| | 1857 | 101 | | useGuideMeter); |
| | 1857 | 102 | | if (mapStatus != NavigationRayStatus.Pending) |
| | 24 | 103 | | return Finish(mapStatus); |
| | 1833 | 104 | | return EvaluateChain(queryMeter, ref guideMeter, useGuideMeter); |
| | | 105 | | } |
| | | 106 | | |
| | | 107 | | private NavigationRayStatus Trace( |
| | | 108 | | NavigationWorkMeter? queryMeter, |
| | | 109 | | ref GuideSampleWorkMeter guideMeter, |
| | | 110 | | bool useGuideMeter) |
| | | 111 | | { |
| | 1954 | 112 | | int gridLimit = useGuideMeter |
| | 1954 | 113 | | ? _workspace.MapCapacity |
| | 1954 | 114 | | : Math.Min(_workspace.MapCapacity, queryMeter!.RemainingLookupProbes); |
| | 1954 | 115 | | int addressLimit = useGuideMeter |
| | 1954 | 116 | | ? _workspace.CoveredAddressCapacity |
| | 1954 | 117 | | : Math.Min( |
| | 1954 | 118 | | _workspace.CoveredAddressCapacity, |
| | 1954 | 119 | | queryMeter!.RemainingCoveredVoxelIntervals); |
| | 1954 | 120 | | int outputLimit = Math.Min( |
| | 1954 | 121 | | _workspace.TraceIntervalCapacity, |
| | 1954 | 122 | | useGuideMeter |
| | 1954 | 123 | | ? guideMeter.GetTraceIntervalAllowance() |
| | 1954 | 124 | | : queryMeter!.RemainingTraceIntervals); |
| | 1954 | 125 | | long candidateWorkLimit = useGuideMeter |
| | 1954 | 126 | | ? guideMeter.GetCurrentNodeLookupAllowance() |
| | 1954 | 127 | | : queryMeter!.RemainingGridCandidateWork; |
| | 1954 | 128 | | ulong before = _request.World.ChangeSequence; |
| | 1954 | 129 | | GridTraceIntervalReport report = GridTracer.TraceIntervalsInto( |
| | 1954 | 130 | | _request.World, |
| | 1954 | 131 | | _request.Start, |
| | 1954 | 132 | | _request.End, |
| | 1954 | 133 | | _workspace.TraceIntervals, |
| | 1954 | 134 | | _workspace.TraceScratch, |
| | 1954 | 135 | | gridLimit, |
| | 1954 | 136 | | addressLimit, |
| | 1954 | 137 | | outputLimit, |
| | 1954 | 138 | | candidateWorkLimit); |
| | 1954 | 139 | | ulong after = _request.World.ChangeSequence; |
| | | 140 | | |
| | 1954 | 141 | | int traceIntervals = report.Status == GridTraceIntervalStatus.OutputLimitExceeded |
| | 1954 | 142 | | ? outputLimit |
| | 1954 | 143 | | : report.IntervalCount; |
| | 1954 | 144 | | if (useGuideMeter) |
| | | 145 | | { |
| | 623 | 146 | | guideMeter.TryConsumeCurrentNodeLookupProbes( |
| | 623 | 147 | | checked(report.GridCandidateCount + report.AddressCandidateCount)); |
| | 623 | 148 | | guideMeter.TryConsumeTraceIntervals(traceIntervals); |
| | | 149 | | } |
| | | 150 | | else |
| | | 151 | | { |
| | 1331 | 152 | | queryMeter!.TryConsumeLookupProbes(report.GridCandidateCount); |
| | 1331 | 153 | | queryMeter.TryConsumeCoveredVoxelIntervals(report.AddressCandidateCount); |
| | 1331 | 154 | | queryMeter.TryConsumeTraceIntervals(traceIntervals); |
| | | 155 | | } |
| | 1954 | 156 | | _worldChangeSequence = after; |
| | 1954 | 157 | | return ResolveTraceStatus( |
| | 1954 | 158 | | before, |
| | 1954 | 159 | | after, |
| | 1954 | 160 | | report.Status, |
| | 1954 | 161 | | gridLimit, |
| | 1954 | 162 | | _workspace.MapCapacity, |
| | 1954 | 163 | | addressLimit, |
| | 1954 | 164 | | _workspace.CoveredAddressCapacity, |
| | 1954 | 165 | | outputLimit, |
| | 1954 | 166 | | _workspace.TraceIntervalCapacity); |
| | | 167 | | } |
| | | 168 | | |
| | | 169 | | internal static NavigationRayStatus ResolveTraceStatus( |
| | | 170 | | ulong worldSequenceBefore, |
| | | 171 | | ulong worldSequenceAfter, |
| | | 172 | | GridTraceIntervalStatus status, |
| | | 173 | | int gridLimit, |
| | | 174 | | int mapCapacity, |
| | | 175 | | int addressLimit, |
| | | 176 | | int coveredAddressCapacity, |
| | | 177 | | int outputLimit, |
| | | 178 | | int traceIntervalCapacity) |
| | | 179 | | { |
| | 1964 | 180 | | if (worldSequenceBefore != worldSequenceAfter) |
| | 1 | 181 | | return NavigationRayStatus.Stale; |
| | 1963 | 182 | | return status switch |
| | 1963 | 183 | | { |
| | 1864 | 184 | | GridTraceIntervalStatus.Complete => NavigationRayStatus.Pending, |
| | 2 | 185 | | GridTraceIntervalStatus.UnrepresentableGeometry => NavigationRayStatus.CostOverflow, |
| | 1963 | 186 | | GridTraceIntervalStatus.GridCandidateLimitExceeded => |
| | 5 | 187 | | gridLimit < mapCapacity |
| | 5 | 188 | | ? NavigationRayStatus.BudgetExceeded |
| | 5 | 189 | | : NavigationRayStatus.CapacityExceeded, |
| | 1963 | 190 | | GridTraceIntervalStatus.AddressCandidateLimitExceeded => |
| | 63 | 191 | | addressLimit < coveredAddressCapacity |
| | 63 | 192 | | ? NavigationRayStatus.BudgetExceeded |
| | 63 | 193 | | : NavigationRayStatus.CapacityExceeded, |
| | 1963 | 194 | | GridTraceIntervalStatus.CandidateWorkLimitExceeded => |
| | 12 | 195 | | NavigationRayStatus.BudgetExceeded, |
| | 17 | 196 | | _ => outputLimit < traceIntervalCapacity |
| | 17 | 197 | | ? NavigationRayStatus.BudgetExceeded |
| | 17 | 198 | | : NavigationRayStatus.CapacityExceeded |
| | 1963 | 199 | | }; |
| | | 200 | | } |
| | | 201 | | |
| | | 202 | | private NavigationRayStatus MapIntervals( |
| | | 203 | | NavigationWorkMeter? queryMeter, |
| | | 204 | | ref GuideSampleWorkMeter guideMeter, |
| | | 205 | | bool useGuideMeter) |
| | | 206 | | { |
| | 1863 | 207 | | NavigationWorldGraph graph = _request.ExpectedGraph; |
| | 1863 | 208 | | NavigationRayChainRecord[] records = _workspace.ChainRecords; |
| | 18116 | 209 | | for (int ordinal = 0; ordinal < _workspace.TraceIntervals.Count; ordinal++) |
| | | 210 | | { |
| | 7219 | 211 | | ref NavigationRayChainRecord record = ref records[ordinal]; |
| | 7219 | 212 | | record = default; |
| | 7219 | 213 | | record.PredecessorOrdinal = -1; |
| | 7219 | 214 | | record.RootOrdinal = -1; |
| | 7219 | 215 | | GridTraceInterval interval = _workspace.TraceIntervals[ordinal]; |
| | 7219 | 216 | | if (!TryConsumeLookup( |
| | 7219 | 217 | | queryMeter, |
| | 7219 | 218 | | ref guideMeter, |
| | 7219 | 219 | | useGuideMeter, |
| | 7219 | 220 | | 1)) |
| | 12 | 221 | | return NavigationRayStatus.BudgetExceeded; |
| | 7207 | 222 | | if (!graph.TryGetMapId(interval.ConfigurationKey, out string mapId)) |
| | | 223 | | continue; |
| | 7202 | 224 | | bool hasInstance = graph.TryGetMap( |
| | 7202 | 225 | | mapId, |
| | 7202 | 226 | | out NavigationMapInstance instance); |
| | | 227 | | System.Diagnostics.Debug.Assert( |
| | | 228 | | hasInstance, |
| | | 229 | | "the immutable configuration index and map directory are built and replaced together"); |
| | 7202 | 230 | | if (!IsTraceIntervalCurrent( |
| | 7202 | 231 | | instance.GridIdentity.Matches( |
| | 7202 | 232 | | interval.Cell.WorldSpawnToken, |
| | 7202 | 233 | | interval.Cell.GridIndex, |
| | 7202 | 234 | | interval.Cell.GridSpawnToken), |
| | 7202 | 235 | | instance.GridIdentity.ConfigurationKey == interval.ConfigurationKey, |
| | 7202 | 236 | | instance.GridLastChangeSequence == interval.GridLastChangeSequence)) |
| | | 237 | | { |
| | 4 | 238 | | return NavigationRayStatus.Stale; |
| | | 239 | | } |
| | 7198 | 240 | | if (!interval.IsPhysicallyPresent) |
| | | 241 | | continue; |
| | | 242 | | |
| | 6881 | 243 | | var address = new NavigationCellAddress(mapId, interval.Cell.VoxelIndex); |
| | 6881 | 244 | | if (!graph.TryGetNodeRef(address, out NavigationNodeRef node)) |
| | | 245 | | continue; |
| | 5312 | 246 | | if (!_workspace.Dependencies.TryRecordPage( |
| | 5312 | 247 | | mapId, |
| | 5312 | 248 | | node.CellSlot / NavigationSemanticPage.SlotCount)) |
| | | 249 | | { |
| | 5 | 250 | | return NavigationRayStatus.CapacityExceeded; |
| | | 251 | | } |
| | 5307 | 252 | | if (!graph.TryGetSurfaceComponent( |
| | 5307 | 253 | | address, |
| | 5307 | 254 | | Medium, |
| | 5307 | 255 | | out NavigationSurfaceComponentKey component, |
| | 5307 | 256 | | out _)) |
| | | 257 | | { |
| | | 258 | | continue; |
| | | 259 | | } |
| | 5302 | 260 | | if (!_workspace.Dependencies.TryRecordComponent(component)) |
| | 3 | 261 | | return NavigationRayStatus.CapacityExceeded; |
| | 5299 | 262 | | if (!_evaluator.TryGetPassableNodeState(node, out _)) |
| | | 263 | | continue; |
| | | 264 | | |
| | 5293 | 265 | | record.Node = node; |
| | 5293 | 266 | | record.State = NavigationRayChainRecordState.Unreached; |
| | 5293 | 267 | | record.IsSemanticCostNeutral = true; |
| | | 268 | | } |
| | 1839 | 269 | | return NavigationRayStatus.Pending; |
| | | 270 | | } |
| | | 271 | | |
| | | 272 | | private NavigationRayStatus EvaluateChain( |
| | | 273 | | NavigationWorkMeter? queryMeter, |
| | | 274 | | ref GuideSampleWorkMeter guideMeter, |
| | | 275 | | bool useGuideMeter) |
| | | 276 | | { |
| | 1839 | 277 | | NavigationRayChainRecord[] records = _workspace.ChainRecords; |
| | 1839 | 278 | | int count = _workspace.TraceIntervals.Count; |
| | 1839 | 279 | | NavigationSurfaceComponentKey finishComponent = default; |
| | 1839 | 280 | | if (_request.ChainConstraint.Kind |
| | 1839 | 281 | | == NavigationRayChainConstraintKind.FinishAddress |
| | 1839 | 282 | | && !_request.ExpectedGraph.TryGetSurfaceComponent( |
| | 1839 | 283 | | _request.ChainConstraint.TargetAddress, |
| | 1839 | 284 | | Medium, |
| | 1839 | 285 | | out finishComponent, |
| | 1839 | 286 | | out _)) |
| | | 287 | | { |
| | 1 | 288 | | return Finish(NavigationRayStatus.Stale); |
| | | 289 | | } |
| | 1838 | 290 | | bool permitsStartPrefix = _request.EndpointAllowance |
| | 1838 | 291 | | == NavigationRayEndpointAllowance.StartPrefix; |
| | 1838 | 292 | | bool permitsDestinationSuffix = _request.EndpointAllowance |
| | 1838 | 293 | | == NavigationRayEndpointAllowance.DestinationSuffix; |
| | 1838 | 294 | | Fixed64 firstSeedParameter = Fixed64.MaxValue; |
| | 1838 | 295 | | if (permitsStartPrefix) |
| | | 296 | | { |
| | 2992 | 297 | | for (int ordinal = 0; ordinal < count; ordinal++) |
| | | 298 | | { |
| | 1048 | 299 | | if (records[ordinal].State == NavigationRayChainRecordState.Unreached |
| | 1048 | 300 | | && MatchesSeedConstraint(ordinal, finishComponent) |
| | 1048 | 301 | | && _workspace.TraceIntervals[ordinal].TEnter < firstSeedParameter) |
| | | 302 | | { |
| | 443 | 303 | | firstSeedParameter = _workspace.TraceIntervals[ordinal].TEnter; |
| | | 304 | | } |
| | | 305 | | } |
| | 448 | 306 | | NavigationRayChainConstraintKind constraintKind = |
| | 448 | 307 | | _request.ChainConstraint.Kind; |
| | 448 | 308 | | if (constraintKind is NavigationRayChainConstraintKind.SourceAddress |
| | 448 | 309 | | or NavigationRayChainConstraintKind.SelectedEdge) |
| | | 310 | | { |
| | 2736 | 311 | | for (int ordinal = 0; ordinal < count; ordinal++) |
| | | 312 | | { |
| | 968 | 313 | | if (records[ordinal].State == NavigationRayChainRecordState.Unreached |
| | 968 | 314 | | && _workspace.TraceIntervals[ordinal].TEnter < firstSeedParameter) |
| | | 315 | | { |
| | 17 | 316 | | return FinishBlocked(); |
| | | 317 | | } |
| | | 318 | | } |
| | | 319 | | } |
| | | 320 | | } |
| | 17872 | 321 | | for (int ordinal = 0; ordinal < count; ordinal++) |
| | | 322 | | { |
| | 7119 | 323 | | GridTraceInterval interval = _workspace.TraceIntervals[ordinal]; |
| | 7119 | 324 | | ref NavigationRayChainRecord record = ref records[ordinal]; |
| | 7119 | 325 | | NavigationRayStatus seedStatus = NavigationRayStatus.Pending; |
| | 7119 | 326 | | if (record.State != NavigationRayChainRecordState.Unreached |
| | 7119 | 327 | | || (permitsStartPrefix |
| | 7119 | 328 | | ? interval.TEnter != firstSeedParameter |
| | 7119 | 329 | | : interval.TEnter > Fixed64.Zero || interval.TExit < Fixed64.Zero) |
| | 7119 | 330 | | || !CanSeed( |
| | 7119 | 331 | | ordinal, |
| | 7119 | 332 | | finishComponent, |
| | 7119 | 333 | | queryMeter, |
| | 7119 | 334 | | ref guideMeter, |
| | 7119 | 335 | | useGuideMeter, |
| | 7119 | 336 | | out seedStatus)) |
| | | 337 | | { |
| | 5307 | 338 | | if (_meterBlocked) |
| | 3 | 339 | | return Finish(NavigationRayStatus.BudgetExceeded); |
| | 5304 | 340 | | if (seedStatus != NavigationRayStatus.Pending) |
| | 1 | 341 | | return Finish(seedStatus); |
| | | 342 | | continue; |
| | | 343 | | } |
| | 1812 | 344 | | record.RootOrdinal = ordinal; |
| | 1812 | 345 | | record.ArrivalParameter = Fixed64.Zero; |
| | 1812 | 346 | | record.TraversalCost = Fixed64.Zero; |
| | 1812 | 347 | | record.IsSemanticCostNeutral = true; |
| | 1812 | 348 | | record.State = NavigationRayChainRecordState.Ready; |
| | | 349 | | } |
| | | 350 | | |
| | | 351 | | bool progressed; |
| | | 352 | | do |
| | | 353 | | { |
| | 1880 | 354 | | progressed = false; |
| | 14320 | 355 | | for (int ordinal = 0; ordinal < count; ordinal++) |
| | | 356 | | { |
| | 7031 | 357 | | ref NavigationRayChainRecord record = ref records[ordinal]; |
| | 7031 | 358 | | if (record.State != NavigationRayChainRecordState.Ready) |
| | | 359 | | continue; |
| | 4906 | 360 | | NavigationRayStatus finishStatus = NavigationRayStatus.Pending; |
| | 4906 | 361 | | if (!permitsDestinationSuffix |
| | 4906 | 362 | | && CanFinish( |
| | 4906 | 363 | | ordinal, |
| | 4906 | 364 | | queryMeter, |
| | 4906 | 365 | | ref guideMeter, |
| | 4906 | 366 | | useGuideMeter, |
| | 4906 | 367 | | out finishStatus)) |
| | 1708 | 368 | | return FinishSuccess(ordinal); |
| | 3198 | 369 | | if (_meterBlocked) |
| | 4 | 370 | | return Finish(NavigationRayStatus.BudgetExceeded); |
| | 3194 | 371 | | if (finishStatus != NavigationRayStatus.Pending) |
| | 3 | 372 | | return Finish(finishStatus); |
| | | 373 | | |
| | 3191 | 374 | | record.State = NavigationRayChainRecordState.Expanded; |
| | 3191 | 375 | | progressed = true; |
| | 3191 | 376 | | NavigationRayChainConstraintKind constraintKind = |
| | 3191 | 377 | | _request.ChainConstraint.Kind; |
| | 3191 | 378 | | if (constraintKind == NavigationRayChainConstraintKind.SourceAddress |
| | 3191 | 379 | | || (constraintKind == NavigationRayChainConstraintKind.SelectedEdge |
| | 3191 | 380 | | && record.PredecessorOrdinal >= 0)) |
| | | 381 | | { |
| | | 382 | | continue; |
| | | 383 | | } |
| | | 384 | | |
| | 3179 | 385 | | NavigationRayStatus expansion = Expand( |
| | 3179 | 386 | | ordinal, |
| | 3179 | 387 | | queryMeter, |
| | 3179 | 388 | | ref guideMeter, |
| | 3179 | 389 | | useGuideMeter); |
| | 3179 | 390 | | if (expansion != NavigationRayStatus.Pending) |
| | 36 | 391 | | return Finish(expansion); |
| | | 392 | | } |
| | | 393 | | } |
| | 129 | 394 | | while (progressed); |
| | | 395 | | |
| | 66 | 396 | | if (permitsDestinationSuffix) |
| | 15 | 397 | | return FinishDestinationSuffix(queryMeter, ref guideMeter, useGuideMeter); |
| | 51 | 398 | | return FinishBlocked(); |
| | | 399 | | } |
| | | 400 | | |
| | | 401 | | private NavigationRayStatus FinishDestinationSuffix( |
| | | 402 | | NavigationWorkMeter? queryMeter, |
| | | 403 | | ref GuideSampleWorkMeter guideMeter, |
| | | 404 | | bool useGuideMeter) |
| | | 405 | | { |
| | 15 | 406 | | Fixed64 farthestExit = Fixed64.MinValue; |
| | 15 | 407 | | NavigationRayChainRecord[] records = _workspace.ChainRecords; |
| | 15 | 408 | | int count = _workspace.TraceIntervals.Count; |
| | 100 | 409 | | for (int ordinal = 0; ordinal < count; ordinal++) |
| | | 410 | | { |
| | 35 | 411 | | if (ShouldAdvanceFarthestExit( |
| | 35 | 412 | | records[ordinal].State, |
| | 35 | 413 | | _workspace.TraceIntervals[ordinal].TExit, |
| | 35 | 414 | | farthestExit)) |
| | | 415 | | { |
| | 23 | 416 | | farthestExit = _workspace.TraceIntervals[ordinal].TExit; |
| | | 417 | | } |
| | | 418 | | } |
| | 56 | 419 | | for (int ordinal = 0; ordinal < count; ordinal++) |
| | | 420 | | { |
| | 27 | 421 | | if (records[ordinal].State != NavigationRayChainRecordState.Expanded |
| | 27 | 422 | | || _workspace.TraceIntervals[ordinal].TExit != farthestExit) |
| | | 423 | | { |
| | | 424 | | continue; |
| | | 425 | | } |
| | 15 | 426 | | if (CanFinish( |
| | 15 | 427 | | ordinal, |
| | 15 | 428 | | queryMeter, |
| | 15 | 429 | | ref guideMeter, |
| | 15 | 430 | | useGuideMeter, |
| | 15 | 431 | | out NavigationRayStatus finishStatus)) |
| | 12 | 432 | | return FinishSuccess(ordinal); |
| | 3 | 433 | | if (_meterBlocked) |
| | 1 | 434 | | return Finish(NavigationRayStatus.BudgetExceeded); |
| | 2 | 435 | | if (finishStatus != NavigationRayStatus.Pending) |
| | 1 | 436 | | return Finish(finishStatus); |
| | | 437 | | } |
| | 1 | 438 | | return FinishBlocked(); |
| | | 439 | | } |
| | | 440 | | |
| | | 441 | | private NavigationRayStatus Expand( |
| | | 442 | | int sourceOrdinal, |
| | | 443 | | NavigationWorkMeter? queryMeter, |
| | | 444 | | ref GuideSampleWorkMeter guideMeter, |
| | | 445 | | bool useGuideMeter) |
| | | 446 | | { |
| | 3179 | 447 | | if (!useGuideMeter |
| | 3179 | 448 | | && Medium is TraversalMedium.Gas or TraversalMedium.Liquid) |
| | | 449 | | { |
| | 271 | 450 | | return ExpandVolume(sourceOrdinal, queryMeter!); |
| | | 451 | | } |
| | | 452 | | |
| | 2908 | 453 | | NavigationWorldGraph graph = _request.ExpectedGraph; |
| | 2908 | 454 | | NavigationRayChainRecord[] records = _workspace.ChainRecords; |
| | 2908 | 455 | | ref NavigationRayChainRecord sourceRecord = ref records[sourceOrdinal]; |
| | 2908 | 456 | | if (!TryGetIncomingPortal( |
| | 2908 | 457 | | sourceOrdinal, |
| | 2908 | 458 | | queryMeter, |
| | 2908 | 459 | | ref guideMeter, |
| | 2908 | 460 | | useGuideMeter, |
| | 2908 | 461 | | out GridNavigationPortal incomingPortal)) |
| | | 462 | | { |
| | 2 | 463 | | return NavigationRayStatus.BudgetExceeded; |
| | | 464 | | } |
| | 2906 | 465 | | graph.TryGetNodeAddress( |
| | 2906 | 466 | | sourceRecord.Node, |
| | 2906 | 467 | | out NavigationCellAddress sourceAddress); |
| | 2906 | 468 | | graph.TryGetSeamPrism(sourceAddress, out GridCellPrism sourcePrism); |
| | | 469 | | |
| | 2906 | 470 | | NavigationSurfaceEdgeEnumerator edges = graph.EnumerateSurfaceEdges(sourceRecord.Node); |
| | 2906 | 471 | | int edgeSteps = int.MaxValue; |
| | 2845 | 472 | | while (true) |
| | | 473 | | { |
| | 10952 | 474 | | NavigationSurfaceEdgeAdvanceStatus advance = useGuideMeter |
| | 10952 | 475 | | ? edges.AdvanceOne(ref guideMeter, ref edgeSteps) |
| | 10952 | 476 | | : edges.AdvanceOne(queryMeter, ref edgeSteps); |
| | 10952 | 477 | | if (advance == NavigationSurfaceEdgeAdvanceStatus.Blocked) |
| | 12 | 478 | | return NavigationRayStatus.BudgetExceeded; |
| | 10940 | 479 | | if (advance == NavigationSurfaceEdgeAdvanceStatus.Pending) |
| | | 480 | | continue; |
| | 8038 | 481 | | if (advance == NavigationSurfaceEdgeAdvanceStatus.Complete) |
| | 2877 | 482 | | return NavigationRayStatus.Pending; |
| | | 483 | | |
| | 5161 | 484 | | NavigationGraphEdge edge = edges.Current; |
| | 5161 | 485 | | int edgeOrdinal = edges.CurrentOrdinal; |
| | 5161 | 486 | | if (!AllowsEdge(sourceAddress, edge.Target, edgeOrdinal)) |
| | | 487 | | continue; |
| | | 488 | | Fixed64 edgeCost; |
| | | 489 | | int targetOrdinal; |
| | | 490 | | Fixed64 targetParameter; |
| | 5139 | 491 | | NavigationExplicitConnectionRecord incomingExplicit = null!; |
| | 5139 | 492 | | if (edge.Kind == NavigationGraphEdgeKind.Explicit) |
| | | 493 | | { |
| | 35 | 494 | | NavigationRayStatus explicitStatus = EvaluateExplicitEdge( |
| | 35 | 495 | | sourceOrdinal, |
| | 35 | 496 | | sourceRecord.Node, |
| | 35 | 497 | | edge, |
| | 35 | 498 | | incomingPortal, |
| | 35 | 499 | | queryMeter, |
| | 35 | 500 | | ref guideMeter, |
| | 35 | 501 | | useGuideMeter, |
| | 35 | 502 | | out edgeCost, |
| | 35 | 503 | | out targetOrdinal, |
| | 35 | 504 | | out targetParameter); |
| | 35 | 505 | | if (explicitStatus == NavigationRayStatus.BudgetExceeded |
| | 35 | 506 | | || explicitStatus == NavigationRayStatus.CostOverflow |
| | 35 | 507 | | || explicitStatus == NavigationRayStatus.CapacityExceeded |
| | 35 | 508 | | || explicitStatus == NavigationRayStatus.Stale) |
| | | 509 | | { |
| | 5 | 510 | | return explicitStatus; |
| | | 511 | | } |
| | 30 | 512 | | if (explicitStatus != NavigationRayStatus.Success) |
| | | 513 | | { |
| | | 514 | | continue; |
| | | 515 | | } |
| | 19 | 516 | | incomingExplicit = edge.ExplicitConnection; |
| | | 517 | | } |
| | | 518 | | else |
| | | 519 | | { |
| | 5104 | 520 | | TraversalEvaluationStatus evaluation = _evaluator.EvaluateEdge( |
| | 5104 | 521 | | sourceRecord.Node, |
| | 5104 | 522 | | edge, |
| | 5104 | 523 | | out TraversalEdgeEvidence evidence); |
| | 5104 | 524 | | edgeCost = evidence.Cost; |
| | 5104 | 525 | | if (evaluation == TraversalEvaluationStatus.CostOverflow) |
| | 1 | 526 | | return NavigationRayStatus.CostOverflow; |
| | 5103 | 527 | | if (evaluation != TraversalEvaluationStatus.Passable) |
| | | 528 | | continue; |
| | 5102 | 529 | | if (!TryConsumePortal(queryMeter, ref guideMeter, useGuideMeter) |
| | 5102 | 530 | | || !GridCellGeometry.TryGetNavigationPortalTraversalParameters( |
| | 5102 | 531 | | evidence.SourcePrism, |
| | 5102 | 532 | | evidence.TargetPrism, |
| | 5102 | 533 | | evidence.Portal, |
| | 5102 | 534 | | _request.Start, |
| | 5102 | 535 | | _request.End, |
| | 5102 | 536 | | _request.Profile.Shape.Radius, |
| | 5102 | 537 | | _request.Profile.Shape.Height, |
| | 5102 | 538 | | out Fixed64 sourceParameter, |
| | 5102 | 539 | | out targetParameter)) |
| | | 540 | | { |
| | 2268 | 541 | | if (_meterBlocked) |
| | 6 | 542 | | return NavigationRayStatus.BudgetExceeded; |
| | | 543 | | continue; |
| | | 544 | | } |
| | 2834 | 545 | | GridTraceInterval sourceInterval = _workspace.TraceIntervals[sourceOrdinal]; |
| | 2834 | 546 | | targetOrdinal = ResolvePortalTargetOrdinal( |
| | 2834 | 547 | | sourceParameter, |
| | 2834 | 548 | | sourceRecord.ArrivalParameter, |
| | 2834 | 549 | | sourceInterval.TEnter, |
| | 2834 | 550 | | sourceInterval.TExit, |
| | 2834 | 551 | | FindTarget(edge.Target, targetParameter)); |
| | 2834 | 552 | | if (targetOrdinal < 0) |
| | | 553 | | continue; |
| | 2832 | 554 | | Vector3d sourcePoint = Vector3d.Lerp( |
| | 2832 | 555 | | _request.Start, |
| | 2832 | 556 | | _request.End, |
| | 2832 | 557 | | sourceRecord.ArrivalParameter); |
| | 2832 | 558 | | Vector3d portalPoint = Vector3d.Lerp( |
| | 2832 | 559 | | _request.Start, |
| | 2832 | 560 | | _request.End, |
| | 2832 | 561 | | sourceParameter); |
| | | 562 | | System.Diagnostics.Debug.Assert( |
| | | 563 | | sourceRecord.IncomingExplicitConnection == null |
| | | 564 | | || new FixedSegment(sourcePoint, portalPoint).Contains( |
| | | 565 | | sourceRecord.IncomingExplicitConnection.Definition.ExitAnchor), |
| | | 566 | | "a successful explicit exit lies on the traced ray inside the convex source prism and therefore on i |
| | 2832 | 567 | | if (!TryConsumePrism(queryMeter, ref guideMeter, useGuideMeter) |
| | 2832 | 568 | | || !GridCellGeometry.IsNavigationBodySegmentValid( |
| | 2832 | 569 | | sourcePrism, |
| | 2832 | 570 | | sourcePoint, |
| | 2832 | 571 | | portalPoint, |
| | 2832 | 572 | | _request.Profile.Shape.Radius, |
| | 2832 | 573 | | _request.Profile.Shape.Height, |
| | 2832 | 574 | | incomingPortal, |
| | 2832 | 575 | | evidence.Portal, |
| | 2832 | 576 | | GetEndpointAllowance( |
| | 2832 | 577 | | sourceOrdinal, |
| | 2832 | 578 | | sourceRecord, |
| | 2832 | 579 | | isFinalSegment: false))) |
| | | 580 | | { |
| | 5 | 581 | | if (_meterBlocked) |
| | 4 | 582 | | return NavigationRayStatus.BudgetExceeded; |
| | | 583 | | continue; |
| | | 584 | | } |
| | | 585 | | } |
| | 2846 | 586 | | if (!Fixed64.TryAdd( |
| | 2846 | 587 | | sourceRecord.TraversalCost, |
| | 2846 | 588 | | edgeCost, |
| | 2846 | 589 | | out Fixed64 traversalCost)) |
| | | 590 | | { |
| | 1 | 591 | | return NavigationRayStatus.CostOverflow; |
| | | 592 | | } |
| | | 593 | | |
| | 2845 | 594 | | ref NavigationRayChainRecord targetRecord = ref records[targetOrdinal]; |
| | 2845 | 595 | | bool isEarlierContinuation = IsEarlierContinuation( |
| | 2845 | 596 | | targetRecord, |
| | 2845 | 597 | | targetParameter, |
| | 2845 | 598 | | incomingExplicit); |
| | 2845 | 599 | | ApplyContinuation( |
| | 2845 | 600 | | ref targetRecord, |
| | 2845 | 601 | | candidatePassable: true, |
| | 2845 | 602 | | isEarlierContinuation, |
| | 2845 | 603 | | sourceOrdinal, |
| | 2845 | 604 | | sourceRecord.RootOrdinal, |
| | 2845 | 605 | | targetParameter, |
| | 2845 | 606 | | traversalCost, |
| | 2845 | 607 | | incomingExplicit, |
| | 2845 | 608 | | sourceRecord.IsSemanticCostNeutral && IsSemanticCostNeutral(edge)); |
| | | 609 | | } |
| | | 610 | | } |
| | | 611 | | |
| | | 612 | | private NavigationRayStatus ExpandVolume( |
| | | 613 | | int sourceOrdinal, |
| | | 614 | | NavigationWorkMeter meter) |
| | | 615 | | { |
| | 271 | 616 | | NavigationWorldGraph graph = _request.ExpectedGraph; |
| | 271 | 617 | | NavigationRayChainRecord[] records = _workspace.ChainRecords; |
| | 271 | 618 | | ref NavigationRayChainRecord sourceRecord = ref records[sourceOrdinal]; |
| | 271 | 619 | | var source = new NavigationMediumStateRef(sourceRecord.Node, Medium); |
| | 271 | 620 | | var edges = new NavigationTraversalEdgeEnumerator( |
| | 271 | 621 | | _request.World, |
| | 271 | 622 | | graph, |
| | 271 | 623 | | source, |
| | 271 | 624 | | _request.Profile, |
| | 271 | 625 | | _request.AreaPolicy, |
| | 271 | 626 | | _workspace, |
| | 271 | 627 | | allowTransitions: false, |
| | 271 | 628 | | emittedSurfaceOrdinal: -1); |
| | 271 | 629 | | var segmentEvaluator = new NavigationVolumeEdgeEvaluator( |
| | 271 | 630 | | _request.World, |
| | 271 | 631 | | graph, |
| | 271 | 632 | | _request.Profile, |
| | 271 | 633 | | _request.AreaPolicy, |
| | 271 | 634 | | Medium, |
| | 271 | 635 | | _workspace); |
| | 271 | 636 | | int edgeSteps = int.MaxValue; |
| | 271 | 637 | | int connectionSteps = int.MaxValue; |
| | 270 | 638 | | while (true) |
| | | 639 | | { |
| | 1022 | 640 | | NavigationTraversalEdgeAdvanceStatus advance = edges.AdvanceOne( |
| | 1022 | 641 | | meter, |
| | 1022 | 642 | | _workspace.Dependencies, |
| | 1022 | 643 | | ref edgeSteps, |
| | 1022 | 644 | | ref connectionSteps); |
| | | 645 | | System.Diagnostics.Debug.Assert( |
| | | 646 | | advance != NavigationTraversalEdgeAdvanceStatus.Blocked, |
| | | 647 | | "volume-ray enumeration uses an unbounded local edge-step allowance"); |
| | 1022 | 648 | | if (advance != NavigationTraversalEdgeAdvanceStatus.Edge) |
| | 270 | 649 | | return MapTraversalAdvanceStatus(advance); |
| | | 650 | | System.Diagnostics.Debug.Assert( |
| | | 651 | | advance == NavigationTraversalEdgeAdvanceStatus.Edge |
| | | 652 | | && edges.CurrentKind == NavigationTraversalEdgeKind.Volume |
| | | 653 | | && edges.CurrentTarget.Medium == Medium, |
| | | 654 | | "a transition-disabled volume enumerator emits only same-medium volume edges"); |
| | 752 | 655 | | if (!AllowsEdge( |
| | 752 | 656 | | GetAddress(sourceRecord.Node), |
| | 752 | 657 | | edges.CurrentTarget.Node, |
| | 752 | 658 | | edges.CurrentOrdinal)) |
| | | 659 | | { |
| | | 660 | | continue; |
| | | 661 | | } |
| | | 662 | | |
| | 519 | 663 | | int targetOrdinal = FindVolumeTarget( |
| | 519 | 664 | | sourceOrdinal, |
| | 519 | 665 | | edges.CurrentTarget.Node, |
| | 519 | 666 | | edges.CurrentVolumeIsShortcut, |
| | 519 | 667 | | out Fixed64 targetParameter); |
| | 519 | 668 | | if (targetOrdinal < 0) |
| | | 669 | | continue; |
| | 271 | 670 | | Vector3d sourcePoint = Vector3d.Lerp( |
| | 271 | 671 | | _request.Start, |
| | 271 | 672 | | _request.End, |
| | 271 | 673 | | sourceRecord.ArrivalParameter); |
| | 271 | 674 | | Vector3d targetPoint = Vector3d.Lerp( |
| | 271 | 675 | | _request.Start, |
| | 271 | 676 | | _request.End, |
| | 271 | 677 | | targetParameter); |
| | 271 | 678 | | NavigationTraversalEvaluationStatus segmentStatus = |
| | 271 | 679 | | segmentEvaluator.CertifyRaySegment( |
| | 271 | 680 | | source, |
| | 271 | 681 | | edges.CurrentTarget, |
| | 271 | 682 | | sourcePoint, |
| | 271 | 683 | | targetPoint, |
| | 271 | 684 | | meter, |
| | 271 | 685 | | _workspace.Dependencies); |
| | 271 | 686 | | NavigationRayStatus terminalStatus = ResolveVolumeTraversalStatus( |
| | 271 | 687 | | segmentStatus, |
| | 271 | 688 | | sourceRecord.TraversalCost, |
| | 271 | 689 | | edges.CurrentCost, |
| | 271 | 690 | | out Fixed64 traversalCost); |
| | 271 | 691 | | if (terminalStatus != NavigationRayStatus.Pending) |
| | 1 | 692 | | return terminalStatus; |
| | | 693 | | |
| | 270 | 694 | | ref NavigationRayChainRecord targetRecord = ref records[targetOrdinal]; |
| | 270 | 695 | | bool isEarlierContinuation = IsEarlierContinuation( |
| | 270 | 696 | | targetRecord, |
| | 270 | 697 | | targetParameter, |
| | 270 | 698 | | null!); |
| | 270 | 699 | | ApplyContinuation( |
| | 270 | 700 | | ref targetRecord, |
| | 270 | 701 | | segmentStatus == NavigationTraversalEvaluationStatus.Passable, |
| | 270 | 702 | | isEarlierContinuation, |
| | 270 | 703 | | sourceOrdinal, |
| | 270 | 704 | | sourceRecord.RootOrdinal, |
| | 270 | 705 | | targetParameter, |
| | 270 | 706 | | traversalCost, |
| | 270 | 707 | | null!, |
| | 270 | 708 | | sourceRecord.IsSemanticCostNeutral |
| | 270 | 709 | | && IsSemanticCostNeutral(edges.CurrentTarget.Node)); |
| | | 710 | | } |
| | | 711 | | } |
| | | 712 | | |
| | | 713 | | private int FindVolumeTarget( |
| | | 714 | | int sourceOrdinal, |
| | | 715 | | NavigationNodeRef target, |
| | | 716 | | bool isShortcut, |
| | | 717 | | out Fixed64 targetParameter) |
| | | 718 | | { |
| | 519 | 719 | | NavigationWorldGraph graph = _request.ExpectedGraph; |
| | 519 | 720 | | NavigationRayChainRecord sourceRecord = _workspace.ChainRecords[sourceOrdinal]; |
| | 519 | 721 | | if (!isShortcut) |
| | | 722 | | { |
| | 258 | 723 | | graph.TryGetNodeAddress( |
| | 258 | 724 | | sourceRecord.Node, |
| | 258 | 725 | | out NavigationCellAddress sourceAddress); |
| | 258 | 726 | | graph.TryGetNodeAddress(target, out NavigationCellAddress targetAddress); |
| | 258 | 727 | | graph.TryGetSeamPrism(sourceAddress, out GridCellPrism sourcePrism); |
| | 258 | 728 | | graph.TryGetSeamPrism(targetAddress, out GridCellPrism targetPrism); |
| | 258 | 729 | | GridCellGeometry.TryCreateNavigationPortal( |
| | 258 | 730 | | sourcePrism, |
| | 258 | 731 | | targetPrism, |
| | 258 | 732 | | out GridNavigationPortal portal); |
| | 258 | 733 | | if (GridCellGeometry.TryGetNavigationPortalTraversalParameters( |
| | 258 | 734 | | sourcePrism, |
| | 258 | 735 | | targetPrism, |
| | 258 | 736 | | portal, |
| | 258 | 737 | | _request.Start, |
| | 258 | 738 | | _request.End, |
| | 258 | 739 | | _request.Profile.Shape.Radius, |
| | 258 | 740 | | _request.Profile.Shape.Height, |
| | 258 | 741 | | out Fixed64 sourceParameter, |
| | 258 | 742 | | out targetParameter)) |
| | | 743 | | { |
| | 165 | 744 | | GridTraceInterval sourceInterval = |
| | 165 | 745 | | _workspace.TraceIntervals[sourceOrdinal]; |
| | 165 | 746 | | return ResolvePortalTargetOrdinal( |
| | 165 | 747 | | sourceParameter, |
| | 165 | 748 | | sourceRecord.ArrivalParameter, |
| | 165 | 749 | | sourceInterval.TEnter, |
| | 165 | 750 | | sourceInterval.TExit, |
| | 165 | 751 | | FindTarget(target, targetParameter)); |
| | | 752 | | } |
| | | 753 | | } |
| | 2082 | 754 | | for (int ordinal = 0; ordinal < _workspace.TraceIntervals.Count; ordinal++) |
| | | 755 | | { |
| | 793 | 756 | | ref NavigationRayChainRecord targetRecord = |
| | 793 | 757 | | ref _workspace.ChainRecords[ordinal]; |
| | 793 | 758 | | if (targetRecord.State == NavigationRayChainRecordState.Unavailable |
| | 793 | 759 | | || !targetRecord.Node.Equals(target)) |
| | | 760 | | { |
| | | 761 | | continue; |
| | | 762 | | } |
| | 113 | 763 | | GridTraceInterval interval = _workspace.TraceIntervals[ordinal]; |
| | 113 | 764 | | targetParameter = interval.TEnter < sourceRecord.ArrivalParameter |
| | 113 | 765 | | ? sourceRecord.ArrivalParameter |
| | 113 | 766 | | : interval.TEnter; |
| | 113 | 767 | | if (targetParameter <= interval.TExit) |
| | 106 | 768 | | return ordinal; |
| | | 769 | | } |
| | 248 | 770 | | targetParameter = default; |
| | 248 | 771 | | return -1; |
| | | 772 | | } |
| | | 773 | | |
| | | 774 | | private NavigationRayStatus EvaluateExplicitEdge( |
| | | 775 | | int sourceOrdinal, |
| | | 776 | | NavigationNodeRef source, |
| | | 777 | | in NavigationGraphEdge edge, |
| | | 778 | | in GridNavigationPortal incomingPortal, |
| | | 779 | | NavigationWorkMeter? queryMeter, |
| | | 780 | | ref GuideSampleWorkMeter guideMeter, |
| | | 781 | | bool useGuideMeter, |
| | | 782 | | out Fixed64 cost, |
| | | 783 | | out int targetOrdinal, |
| | | 784 | | out Fixed64 targetParameter) |
| | | 785 | | { |
| | 35 | 786 | | cost = Fixed64.Zero; |
| | 35 | 787 | | targetOrdinal = -1; |
| | 35 | 788 | | targetParameter = default; |
| | 35 | 789 | | TraversalExplicitEdgeStatus status = _evaluator.BeginExplicitEdge( |
| | 35 | 790 | | source, |
| | 35 | 791 | | edge, |
| | 35 | 792 | | out TraversalExplicitEdgeWork work); |
| | 35 | 793 | | if (status != TraversalExplicitEdgeStatus.Pending) |
| | 1 | 794 | | return MapExplicitStatus(status); |
| | | 795 | | |
| | 34 | 796 | | NavigationExplicitConnectionRecord record = edge.ExplicitConnection; |
| | 34 | 797 | | NavigationConnection connection = record.Definition; |
| | 34 | 798 | | var path = new FixedSegment(_request.Start, _request.End); |
| | 34 | 799 | | bool geometryPassable = path.Contains(connection.EntryAnchor) |
| | 34 | 800 | | && path.Contains(connection.ExitAnchor); |
| | 34 | 801 | | int currentOrdinal = sourceOrdinal; |
| | 34 | 802 | | Fixed64 currentParameter = |
| | 34 | 803 | | _workspace.ChainRecords[sourceOrdinal].ArrivalParameter; |
| | 34 | 804 | | GridNavigationPortal currentIncoming = incomingPortal; |
| | 34 | 805 | | int portalOrdinal = 0; |
| | 86 | 806 | | while (status == TraversalExplicitEdgeStatus.Pending) |
| | | 807 | | { |
| | 56 | 808 | | if (!TryConsumeConnectionLeg( |
| | 56 | 809 | | queryMeter, |
| | 56 | 810 | | ref guideMeter, |
| | 56 | 811 | | useGuideMeter)) |
| | 1 | 812 | | return NavigationRayStatus.BudgetExceeded; |
| | 55 | 813 | | status = _evaluator.AdvanceExplicitEdge( |
| | 55 | 814 | | ref work, |
| | 55 | 815 | | out TraversalEdgeEvidence evidence); |
| | 55 | 816 | | if (status == TraversalExplicitEdgeStatus.CostOverflow) |
| | 1 | 817 | | return MapExplicitStatus(status); |
| | | 818 | | System.Diagnostics.Debug.Assert( |
| | | 819 | | evidence.DependencyNode.IsValid, |
| | | 820 | | "every advanced explicit corridor leg identifies its immutable dependency node"); |
| | 54 | 821 | | if (!TryRecordDependencyNode(evidence.DependencyNode)) |
| | 1 | 822 | | return NavigationRayStatus.CapacityExceeded; |
| | 53 | 823 | | if (status == TraversalExplicitEdgeStatus.Impassable) |
| | 1 | 824 | | return NavigationRayStatus.Blocked; |
| | | 825 | | |
| | 52 | 826 | | cost = evidence.Cost; |
| | 52 | 827 | | if (!geometryPassable) |
| | | 828 | | continue; |
| | 39 | 829 | | if (!TryConsumePortal(queryMeter, ref guideMeter, useGuideMeter)) |
| | | 830 | | { |
| | 1 | 831 | | geometryPassable = false; |
| | 1 | 832 | | continue; |
| | | 833 | | } |
| | 38 | 834 | | bool hasPortalParameters = |
| | 38 | 835 | | GridCellGeometry.TryGetNavigationPortalTraversalParameters( |
| | 38 | 836 | | evidence.SourcePrism, |
| | 38 | 837 | | evidence.TargetPrism, |
| | 38 | 838 | | evidence.Portal, |
| | 38 | 839 | | _request.Start, |
| | 38 | 840 | | _request.End, |
| | 38 | 841 | | _request.Profile.Shape.Radius, |
| | 38 | 842 | | _request.Profile.Shape.Height, |
| | 38 | 843 | | out Fixed64 sourceParameter, |
| | 38 | 844 | | out Fixed64 nextParameter); |
| | 38 | 845 | | GridTraceInterval currentInterval = |
| | 38 | 846 | | _workspace.TraceIntervals[currentOrdinal]; |
| | 38 | 847 | | if (!IsExplicitPortalProgressValid( |
| | 38 | 848 | | hasPortalParameters, |
| | 38 | 849 | | sourceParameter, |
| | 38 | 850 | | currentParameter, |
| | 38 | 851 | | currentInterval.TEnter, |
| | 38 | 852 | | currentInterval.TExit)) |
| | | 853 | | { |
| | 1 | 854 | | geometryPassable = false; |
| | 1 | 855 | | continue; |
| | | 856 | | } |
| | 37 | 857 | | int nextOrdinal = FindMapped( |
| | 37 | 858 | | _workspace, |
| | 37 | 859 | | evidence.DependencyNode, |
| | 37 | 860 | | nextParameter); |
| | 37 | 861 | | if (nextOrdinal < 0) |
| | | 862 | | { |
| | 1 | 863 | | geometryPassable = false; |
| | 1 | 864 | | continue; |
| | | 865 | | } |
| | 36 | 866 | | Vector3d currentPoint = Vector3d.Lerp( |
| | 36 | 867 | | _request.Start, |
| | 36 | 868 | | _request.End, |
| | 36 | 869 | | currentParameter); |
| | 36 | 870 | | Vector3d outgoingPoint = Vector3d.Lerp( |
| | 36 | 871 | | _request.Start, |
| | 36 | 872 | | _request.End, |
| | 36 | 873 | | sourceParameter); |
| | 36 | 874 | | if (portalOrdinal == 0) |
| | | 875 | | { |
| | 23 | 876 | | var firstLeg = new FixedSegment(currentPoint, outgoingPoint); |
| | 23 | 877 | | NavigationExplicitConnectionRecord prior = |
| | 23 | 878 | | _workspace.ChainRecords[sourceOrdinal].IncomingExplicitConnection; |
| | 23 | 879 | | if (!IsExplicitFirstLegValid( |
| | 23 | 880 | | firstLeg, |
| | 23 | 881 | | connection.EntryAnchor, |
| | 23 | 882 | | prior, |
| | 23 | 883 | | _request.Start, |
| | 23 | 884 | | _request.End)) |
| | | 885 | | { |
| | 1 | 886 | | geometryPassable = false; |
| | 1 | 887 | | continue; |
| | | 888 | | } |
| | | 889 | | } |
| | 35 | 890 | | if (!TryConsumePrism(queryMeter, ref guideMeter, useGuideMeter)) |
| | | 891 | | { |
| | 1 | 892 | | geometryPassable = false; |
| | 1 | 893 | | continue; |
| | | 894 | | } |
| | 34 | 895 | | if (!GridCellGeometry.IsNavigationBodySegmentValid( |
| | 34 | 896 | | evidence.SourcePrism, |
| | 34 | 897 | | currentPoint, |
| | 34 | 898 | | outgoingPoint, |
| | 34 | 899 | | _request.Profile.Shape.Radius, |
| | 34 | 900 | | _request.Profile.Shape.Height, |
| | 34 | 901 | | currentIncoming, |
| | 34 | 902 | | evidence.Portal, |
| | 34 | 903 | | portalOrdinal == 0 |
| | 34 | 904 | | ? GetEndpointAllowance( |
| | 34 | 905 | | sourceOrdinal, |
| | 34 | 906 | | _workspace.ChainRecords[sourceOrdinal], |
| | 34 | 907 | | isFinalSegment: false) |
| | 34 | 908 | | : GridNavigationBodySegmentEndpointAllowance.None)) |
| | | 909 | | { |
| | 1 | 910 | | geometryPassable = false; |
| | 1 | 911 | | continue; |
| | | 912 | | } |
| | | 913 | | |
| | 33 | 914 | | currentOrdinal = nextOrdinal; |
| | 33 | 915 | | currentParameter = nextParameter; |
| | 33 | 916 | | currentIncoming = evidence.Portal; |
| | 33 | 917 | | portalOrdinal++; |
| | | 918 | | } |
| | | 919 | | |
| | 30 | 920 | | if (_meterBlocked) |
| | 2 | 921 | | return NavigationRayStatus.BudgetExceeded; |
| | 28 | 922 | | if (!geometryPassable) |
| | 9 | 923 | | return NavigationRayStatus.Blocked; |
| | | 924 | | System.Diagnostics.Debug.Assert( |
| | | 925 | | _workspace.ChainRecords[currentOrdinal].Node.Equals(edge.Target) |
| | | 926 | | && _workspace.ChainRecords[currentOrdinal].State |
| | | 927 | | != NavigationRayChainRecordState.Unavailable, |
| | | 928 | | "a successful explicit replay ends on the final passable dependency node mapped by FindMapped"); |
| | 19 | 929 | | targetOrdinal = currentOrdinal; |
| | 19 | 930 | | targetParameter = currentParameter; |
| | 19 | 931 | | return NavigationRayStatus.Success; |
| | | 932 | | } |
| | | 933 | | |
| | | 934 | | private static NavigationRayStatus MapExplicitStatus( |
| | | 935 | | TraversalExplicitEdgeStatus status) => |
| | 2 | 936 | | status == TraversalExplicitEdgeStatus.CostOverflow |
| | 2 | 937 | | ? NavigationRayStatus.CostOverflow |
| | 2 | 938 | | : NavigationRayStatus.Blocked; |
| | | 939 | | |
| | | 940 | | internal static bool IsExplicitFirstLegValid( |
| | | 941 | | in FixedSegment firstLeg, |
| | | 942 | | Vector3d entryAnchor, |
| | | 943 | | NavigationExplicitConnectionRecord prior, |
| | | 944 | | Vector3d rayStart, |
| | | 945 | | Vector3d rayEnd) |
| | | 946 | | { |
| | 28 | 947 | | if (!firstLeg.Contains(entryAnchor)) |
| | 1 | 948 | | return false; |
| | 27 | 949 | | if (prior == null) |
| | 18 | 950 | | return true; |
| | 9 | 951 | | Vector3d priorExit = prior.Definition.ExitAnchor; |
| | 9 | 952 | | return firstLeg.Contains(priorExit) |
| | 9 | 953 | | && CompareAlongRay(rayStart, rayEnd, priorExit, entryAnchor) <= 0; |
| | | 954 | | } |
| | | 955 | | |
| | | 956 | | private bool IsEarlierContinuation( |
| | | 957 | | in NavigationRayChainRecord current, |
| | | 958 | | Fixed64 candidateArrivalParameter, |
| | | 959 | | NavigationExplicitConnectionRecord candidateExplicit) |
| | | 960 | | { |
| | 3115 | 961 | | Vector3d candidate = candidateExplicit != null |
| | 3115 | 962 | | ? candidateExplicit.Definition.ExitAnchor |
| | 3115 | 963 | | : Vector3d.Lerp( |
| | 3115 | 964 | | _request.Start, |
| | 3115 | 965 | | _request.End, |
| | 3115 | 966 | | candidateArrivalParameter); |
| | 3115 | 967 | | Vector3d prior = current.IncomingExplicitConnection != null |
| | 3115 | 968 | | ? current.IncomingExplicitConnection.Definition.ExitAnchor |
| | 3115 | 969 | | : Vector3d.Lerp( |
| | 3115 | 970 | | _request.Start, |
| | 3115 | 971 | | _request.End, |
| | 3115 | 972 | | current.ArrivalParameter); |
| | 3115 | 973 | | return CompareAlongRay(candidate, prior) < 0; |
| | | 974 | | } |
| | | 975 | | |
| | | 976 | | private int CompareAlongRay(Vector3d first, Vector3d second) |
| | 3115 | 977 | | => CompareAlongRay(_request.Start, _request.End, first, second); |
| | | 978 | | |
| | | 979 | | private static int CompareAlongRay( |
| | | 980 | | Vector3d rayStart, |
| | | 981 | | Vector3d rayEnd, |
| | | 982 | | Vector3d first, |
| | | 983 | | Vector3d second) |
| | | 984 | | { |
| | 3123 | 985 | | if (rayEnd.X != rayStart.X) |
| | | 986 | | { |
| | 2963 | 987 | | return rayEnd.X > rayStart.X |
| | 2963 | 988 | | ? first.X.CompareTo(second.X) |
| | 2963 | 989 | | : second.X.CompareTo(first.X); |
| | | 990 | | } |
| | 160 | 991 | | return rayEnd.Z > rayStart.Z |
| | 160 | 992 | | ? first.Z.CompareTo(second.Z) |
| | 160 | 993 | | : second.Z.CompareTo(first.Z); |
| | | 994 | | } |
| | | 995 | | |
| | | 996 | | internal static int FindMapped( |
| | | 997 | | NavigationRayWorkspace workspace, |
| | | 998 | | NavigationNodeRef target, |
| | | 999 | | Fixed64 parameter) |
| | | 1000 | | { |
| | 21918 | 1001 | | for (int ordinal = 0; ordinal < workspace.TraceIntervals.Count; ordinal++) |
| | | 1002 | | { |
| | 10956 | 1003 | | GridTraceInterval interval = workspace.TraceIntervals[ordinal]; |
| | 10956 | 1004 | | if (interval.TEnter > parameter) |
| | | 1005 | | break; |
| | 10955 | 1006 | | ref NavigationRayChainRecord record = ref workspace.ChainRecords[ordinal]; |
| | 10955 | 1007 | | if (record.State != NavigationRayChainRecordState.Unavailable |
| | 10955 | 1008 | | && record.Node.Equals(target) |
| | 10955 | 1009 | | && interval.TExit >= parameter) |
| | | 1010 | | { |
| | 3034 | 1011 | | return ordinal; |
| | | 1012 | | } |
| | | 1013 | | } |
| | 4 | 1014 | | return -1; |
| | | 1015 | | } |
| | | 1016 | | |
| | | 1017 | | internal static bool ContainsParameter( |
| | | 1018 | | Fixed64 enter, |
| | | 1019 | | Fixed64 exit, |
| | 3048 | 1020 | | Fixed64 parameter) => enter <= parameter && exit >= parameter; |
| | | 1021 | | |
| | | 1022 | | internal static int ResolvePortalTargetOrdinal( |
| | | 1023 | | Fixed64 sourceParameter, |
| | | 1024 | | Fixed64 arrivalParameter, |
| | | 1025 | | Fixed64 intervalEnter, |
| | | 1026 | | Fixed64 intervalExit, |
| | | 1027 | | int targetOrdinal) => |
| | 3004 | 1028 | | sourceParameter >= arrivalParameter |
| | 3004 | 1029 | | && ContainsParameter(intervalEnter, intervalExit, sourceParameter) |
| | 3004 | 1030 | | ? targetOrdinal |
| | 3004 | 1031 | | : -1; |
| | | 1032 | | |
| | | 1033 | | internal static bool IsExplicitPortalProgressValid( |
| | | 1034 | | bool hasPortalParameters, |
| | | 1035 | | Fixed64 sourceParameter, |
| | | 1036 | | Fixed64 currentParameter, |
| | | 1037 | | Fixed64 intervalEnter, |
| | | 1038 | | Fixed64 intervalExit) => |
| | 43 | 1039 | | hasPortalParameters |
| | 43 | 1040 | | && sourceParameter >= currentParameter |
| | 43 | 1041 | | && ContainsParameter(intervalEnter, intervalExit, sourceParameter); |
| | | 1042 | | |
| | | 1043 | | internal static bool ShouldAcceptContinuation( |
| | | 1044 | | NavigationRayChainRecordState currentState, |
| | | 1045 | | bool candidateIsEarlier) => |
| | 3121 | 1046 | | currentState == NavigationRayChainRecordState.Unreached |
| | 3121 | 1047 | | || candidateIsEarlier; |
| | | 1048 | | |
| | | 1049 | | internal static void ApplyContinuation( |
| | | 1050 | | ref NavigationRayChainRecord target, |
| | | 1051 | | bool candidatePassable, |
| | | 1052 | | bool candidateIsEarlier, |
| | | 1053 | | int predecessorOrdinal, |
| | | 1054 | | int rootOrdinal, |
| | | 1055 | | Fixed64 arrivalParameter, |
| | | 1056 | | Fixed64 traversalCost, |
| | | 1057 | | NavigationExplicitConnectionRecord incomingExplicitConnection, |
| | | 1058 | | bool isSemanticCostNeutral) |
| | | 1059 | | { |
| | 3119 | 1060 | | if (!candidatePassable |
| | 3119 | 1061 | | || !ShouldAcceptContinuation(target.State, candidateIsEarlier)) |
| | | 1062 | | { |
| | 8 | 1063 | | return; |
| | | 1064 | | } |
| | 3111 | 1065 | | target.PredecessorOrdinal = predecessorOrdinal; |
| | 3111 | 1066 | | target.RootOrdinal = rootOrdinal; |
| | 3111 | 1067 | | target.ArrivalParameter = arrivalParameter; |
| | 3111 | 1068 | | target.TraversalCost = traversalCost; |
| | 3111 | 1069 | | target.IncomingExplicitConnection = incomingExplicitConnection; |
| | 3111 | 1070 | | target.IsSemanticCostNeutral = isSemanticCostNeutral; |
| | 3111 | 1071 | | target.State = NavigationRayChainRecordState.Ready; |
| | 3111 | 1072 | | } |
| | | 1073 | | |
| | | 1074 | | private int FindTarget(NavigationNodeRef target, Fixed64 parameter) => |
| | 2999 | 1075 | | FindMapped(_workspace, target, parameter); |
| | | 1076 | | |
| | | 1077 | | private bool CanSeed( |
| | | 1078 | | int ordinal, |
| | | 1079 | | NavigationSurfaceComponentKey finishComponent, |
| | | 1080 | | NavigationWorkMeter? queryMeter, |
| | | 1081 | | ref GuideSampleWorkMeter guideMeter, |
| | | 1082 | | bool useGuideMeter, |
| | | 1083 | | out NavigationRayStatus terminalStatus) |
| | | 1084 | | { |
| | 1848 | 1085 | | terminalStatus = NavigationRayStatus.Pending; |
| | 1848 | 1086 | | NavigationNodeRef node = _workspace.ChainRecords[ordinal].Node; |
| | 1848 | 1087 | | NavigationRayChainConstraint constraint = _request.ChainConstraint; |
| | | 1088 | | NavigationCellAddress address; |
| | 1848 | 1089 | | if (constraint.Kind == NavigationRayChainConstraintKind.FinishAddress |
| | 1848 | 1090 | | && !MatchesSeedConstraint(ordinal, finishComponent)) |
| | | 1091 | | { |
| | 17 | 1092 | | return false; |
| | | 1093 | | } |
| | 1831 | 1094 | | if (constraint.Kind is NavigationRayChainConstraintKind.Unrestricted |
| | 1831 | 1095 | | or NavigationRayChainConstraintKind.FinishAddress) |
| | | 1096 | | { |
| | 1352 | 1097 | | if (_request.EndpointAllowance == NavigationRayEndpointAllowance.StartPrefix) |
| | 31 | 1098 | | return true; |
| | 1321 | 1099 | | _request.ExpectedGraph.TryGetNodeAddress(node, out address); |
| | | 1100 | | } |
| | | 1101 | | else |
| | | 1102 | | { |
| | 479 | 1103 | | _request.ExpectedGraph.TryGetNodeAddress(node, out address); |
| | 479 | 1104 | | if (address != constraint.SourceAddress) |
| | | 1105 | | { |
| | 9 | 1106 | | return false; |
| | | 1107 | | } |
| | 470 | 1108 | | if (_request.EndpointAllowance == NavigationRayEndpointAllowance.StartPrefix) |
| | 400 | 1109 | | return true; |
| | | 1110 | | } |
| | 1391 | 1111 | | if (!useGuideMeter |
| | 1391 | 1112 | | && Medium is TraversalMedium.Gas or TraversalMedium.Liquid) |
| | | 1113 | | { |
| | 184 | 1114 | | var state = new NavigationMediumStateRef(node, Medium); |
| | 184 | 1115 | | return CertifyVolumeSegment( |
| | 184 | 1116 | | state, |
| | 184 | 1117 | | state, |
| | 184 | 1118 | | _request.Start, |
| | 184 | 1119 | | _request.Start, |
| | 184 | 1120 | | queryMeter!, |
| | 184 | 1121 | | out terminalStatus); |
| | | 1122 | | } |
| | 1207 | 1123 | | _request.ExpectedGraph.TryGetSeamPrism(address, out GridCellPrism prism); |
| | 1207 | 1124 | | return TryConsumePrism(queryMeter, ref guideMeter, useGuideMeter) |
| | 1207 | 1125 | | && GridCellGeometry.IsNavigationBodySegmentValid( |
| | 1207 | 1126 | | prism, |
| | 1207 | 1127 | | _request.Start, |
| | 1207 | 1128 | | _request.Start, |
| | 1207 | 1129 | | _request.Profile.Shape.Radius, |
| | 1207 | 1130 | | _request.Profile.Shape.Height, |
| | 1207 | 1131 | | default, |
| | 1207 | 1132 | | default, |
| | 1207 | 1133 | | GridNavigationBodySegmentEndpointAllowance.None); |
| | | 1134 | | } |
| | | 1135 | | |
| | | 1136 | | private bool MatchesSeedConstraint( |
| | | 1137 | | int ordinal, |
| | | 1138 | | NavigationSurfaceComponentKey finishComponent) |
| | | 1139 | | { |
| | 790 | 1140 | | NavigationRayChainConstraint constraint = _request.ChainConstraint; |
| | 790 | 1141 | | if (constraint.Kind == NavigationRayChainConstraintKind.Unrestricted) |
| | 3 | 1142 | | return true; |
| | 787 | 1143 | | if (constraint.Kind == NavigationRayChainConstraintKind.FinishAddress) |
| | | 1144 | | { |
| | 96 | 1145 | | _request.ExpectedGraph.TryGetNodeAddress( |
| | 96 | 1146 | | _workspace.ChainRecords[ordinal].Node, |
| | 96 | 1147 | | out NavigationCellAddress seedAddress); |
| | 96 | 1148 | | _request.ExpectedGraph.TryGetSurfaceComponent( |
| | 96 | 1149 | | seedAddress, |
| | 96 | 1150 | | Medium, |
| | 96 | 1151 | | out NavigationSurfaceComponentKey actual, |
| | 96 | 1152 | | out _); |
| | 96 | 1153 | | return actual.Equals(finishComponent); |
| | | 1154 | | } |
| | 691 | 1155 | | _request.ExpectedGraph.TryGetNodeAddress( |
| | 691 | 1156 | | _workspace.ChainRecords[ordinal].Node, |
| | 691 | 1157 | | out NavigationCellAddress address); |
| | 691 | 1158 | | return address == constraint.SourceAddress; |
| | | 1159 | | } |
| | | 1160 | | |
| | | 1161 | | private bool AllowsEdge( |
| | | 1162 | | NavigationCellAddress source, |
| | | 1163 | | NavigationNodeRef targetNode, |
| | | 1164 | | int edgeOrdinal) |
| | | 1165 | | { |
| | 5913 | 1166 | | NavigationRayChainConstraint constraint = _request.ChainConstraint; |
| | 5913 | 1167 | | if (constraint.Kind is NavigationRayChainConstraintKind.Unrestricted |
| | 5913 | 1168 | | or NavigationRayChainConstraintKind.SeedAddress |
| | 5913 | 1169 | | or NavigationRayChainConstraintKind.FinishAddress) |
| | 5549 | 1170 | | return true; |
| | 364 | 1171 | | return constraint.Kind == NavigationRayChainConstraintKind.SelectedEdge |
| | 364 | 1172 | | && source == constraint.SourceAddress |
| | 364 | 1173 | | && edgeOrdinal == constraint.EdgeOrdinal |
| | 364 | 1174 | | && GetAddress(targetNode) == constraint.TargetAddress; |
| | | 1175 | | } |
| | | 1176 | | |
| | | 1177 | | private bool CanFinish( |
| | | 1178 | | int ordinal, |
| | | 1179 | | NavigationWorkMeter? queryMeter, |
| | | 1180 | | ref GuideSampleWorkMeter guideMeter, |
| | | 1181 | | bool useGuideMeter, |
| | | 1182 | | out NavigationRayStatus terminalStatus) |
| | | 1183 | | { |
| | 4897 | 1184 | | terminalStatus = NavigationRayStatus.Pending; |
| | 4897 | 1185 | | GridTraceInterval interval = _workspace.TraceIntervals[ordinal]; |
| | 4897 | 1186 | | ref NavigationRayChainRecord record = ref _workspace.ChainRecords[ordinal]; |
| | 4897 | 1187 | | bool permitsDestinationSuffix = _request.EndpointAllowance |
| | 4897 | 1188 | | == NavigationRayEndpointAllowance.DestinationSuffix; |
| | 4897 | 1189 | | _request.ExpectedGraph.TryGetNodeAddress( |
| | 4897 | 1190 | | record.Node, |
| | 4897 | 1191 | | out NavigationCellAddress address); |
| | 4897 | 1192 | | if (!IsPermittedFinalTarget( |
| | 4897 | 1193 | | permitsDestinationSuffix, |
| | 4897 | 1194 | | interval.TEnter, |
| | 4897 | 1195 | | interval.TExit, |
| | 4897 | 1196 | | _request.ChainConstraint.Kind, |
| | 4897 | 1197 | | address, |
| | 4897 | 1198 | | _request.ChainConstraint.TargetAddress, |
| | 4897 | 1199 | | record.PredecessorOrdinal)) |
| | | 1200 | | { |
| | 3154 | 1201 | | return false; |
| | | 1202 | | } |
| | 1743 | 1203 | | Vector3d arrival = Vector3d.Lerp( |
| | 1743 | 1204 | | _request.Start, |
| | 1743 | 1205 | | _request.End, |
| | 1743 | 1206 | | record.ArrivalParameter); |
| | | 1207 | | // EvaluateExplicitEdge certifies this exact arrival-to-end suffix before |
| | | 1208 | | // publishing an incoming explicit continuation into a chain record. |
| | 1743 | 1209 | | if (!useGuideMeter |
| | 1743 | 1210 | | && Medium is TraversalMedium.Gas or TraversalMedium.Liquid) |
| | | 1211 | | { |
| | 271 | 1212 | | _request.ExpectedGraph.TryGetSeamPrism( |
| | 271 | 1213 | | address, |
| | 271 | 1214 | | out GridCellPrism targetPrism); |
| | 271 | 1215 | | if (record.PredecessorOrdinal >= 0 |
| | 271 | 1216 | | && TryGetIncomingPortal( |
| | 271 | 1217 | | ordinal, |
| | 271 | 1218 | | queryMeter, |
| | 271 | 1219 | | ref guideMeter, |
| | 271 | 1220 | | useGuideMeter, |
| | 271 | 1221 | | out GridNavigationPortal volumeIncoming) |
| | 271 | 1222 | | && GridCellGeometry.IsNavigationBodySegmentValid( |
| | 271 | 1223 | | targetPrism, |
| | 271 | 1224 | | arrival, |
| | 271 | 1225 | | _request.End, |
| | 271 | 1226 | | _request.Profile.Shape.Radius, |
| | 271 | 1227 | | _request.Profile.Shape.Height, |
| | 271 | 1228 | | volumeIncoming, |
| | 271 | 1229 | | default, |
| | 271 | 1230 | | GetEndpointAllowance(ordinal, record, isFinalSegment: true))) |
| | | 1231 | | { |
| | 155 | 1232 | | return true; |
| | | 1233 | | } |
| | 116 | 1234 | | var state = new NavigationMediumStateRef(record.Node, Medium); |
| | 116 | 1235 | | return CertifyVolumeSegment( |
| | 116 | 1236 | | state, |
| | 116 | 1237 | | state, |
| | 116 | 1238 | | arrival, |
| | 116 | 1239 | | _request.End, |
| | 116 | 1240 | | queryMeter!, |
| | 116 | 1241 | | out terminalStatus); |
| | | 1242 | | } |
| | 1472 | 1243 | | _request.ExpectedGraph.TryGetSeamPrism(address, out GridCellPrism prism); |
| | 1472 | 1244 | | return TryGetIncomingPortal( |
| | 1472 | 1245 | | ordinal, |
| | 1472 | 1246 | | queryMeter, |
| | 1472 | 1247 | | ref guideMeter, |
| | 1472 | 1248 | | useGuideMeter, |
| | 1472 | 1249 | | out GridNavigationPortal incomingPortal) |
| | 1472 | 1250 | | && TryConsumePrism(queryMeter, ref guideMeter, useGuideMeter) |
| | 1472 | 1251 | | && GridCellGeometry.IsNavigationBodySegmentValid( |
| | 1472 | 1252 | | prism, |
| | 1472 | 1253 | | arrival, |
| | 1472 | 1254 | | _request.End, |
| | 1472 | 1255 | | _request.Profile.Shape.Radius, |
| | 1472 | 1256 | | _request.Profile.Shape.Height, |
| | 1472 | 1257 | | incomingPortal, |
| | 1472 | 1258 | | default, |
| | 1472 | 1259 | | GetEndpointAllowance(ordinal, record, isFinalSegment: true)); |
| | | 1260 | | } |
| | | 1261 | | |
| | | 1262 | | private bool CertifyVolumeSegment( |
| | | 1263 | | NavigationMediumStateRef source, |
| | | 1264 | | NavigationMediumStateRef target, |
| | | 1265 | | Vector3d sourceFoot, |
| | | 1266 | | Vector3d targetFoot, |
| | | 1267 | | NavigationWorkMeter meter, |
| | | 1268 | | out NavigationRayStatus terminalStatus) |
| | | 1269 | | { |
| | 300 | 1270 | | var evaluator = new NavigationVolumeEdgeEvaluator( |
| | 300 | 1271 | | _request.World, |
| | 300 | 1272 | | _request.ExpectedGraph, |
| | 300 | 1273 | | _request.Profile, |
| | 300 | 1274 | | _request.AreaPolicy, |
| | 300 | 1275 | | Medium, |
| | 300 | 1276 | | _workspace); |
| | 300 | 1277 | | NavigationTraversalEvaluationStatus status = evaluator.CertifyRaySegment( |
| | 300 | 1278 | | source, |
| | 300 | 1279 | | target, |
| | 300 | 1280 | | sourceFoot, |
| | 300 | 1281 | | targetFoot, |
| | 300 | 1282 | | meter, |
| | 300 | 1283 | | _workspace.Dependencies); |
| | 300 | 1284 | | terminalStatus = MapVolumeStatus(status); |
| | 300 | 1285 | | return status == NavigationTraversalEvaluationStatus.Passable; |
| | | 1286 | | } |
| | | 1287 | | |
| | | 1288 | | internal static NavigationRayStatus MapVolumeStatus( |
| | 584 | 1289 | | NavigationTraversalEvaluationStatus status) => status switch |
| | 584 | 1290 | | { |
| | 584 | 1291 | | NavigationTraversalEvaluationStatus.BudgetExceeded => |
| | 7 | 1292 | | NavigationRayStatus.BudgetExceeded, |
| | 584 | 1293 | | NavigationTraversalEvaluationStatus.CapacityExceeded => |
| | 2 | 1294 | | NavigationRayStatus.CapacityExceeded, |
| | 584 | 1295 | | NavigationTraversalEvaluationStatus.CostOverflow => |
| | 2 | 1296 | | NavigationRayStatus.CostOverflow, |
| | 2 | 1297 | | NavigationTraversalEvaluationStatus.Stale => NavigationRayStatus.Stale, |
| | 571 | 1298 | | _ => NavigationRayStatus.Pending |
| | 584 | 1299 | | }; |
| | | 1300 | | |
| | | 1301 | | internal static bool IsTraceIntervalCurrent( |
| | | 1302 | | bool identityMatches, |
| | | 1303 | | bool configurationMatches, |
| | | 1304 | | bool sequenceMatches) => |
| | 7206 | 1305 | | identityMatches |
| | 7206 | 1306 | | && configurationMatches |
| | 7206 | 1307 | | && sequenceMatches; |
| | | 1308 | | |
| | | 1309 | | internal static bool ShouldAdvanceFarthestExit( |
| | | 1310 | | NavigationRayChainRecordState state, |
| | | 1311 | | Fixed64 candidateExit, |
| | | 1312 | | Fixed64 farthestExit) => |
| | 39 | 1313 | | state == NavigationRayChainRecordState.Expanded |
| | 39 | 1314 | | && candidateExit > farthestExit; |
| | | 1315 | | |
| | | 1316 | | internal static bool IsPermittedFinalTarget( |
| | | 1317 | | bool permitsDestinationSuffix, |
| | | 1318 | | Fixed64 intervalEnter, |
| | | 1319 | | Fixed64 intervalExit, |
| | | 1320 | | NavigationRayChainConstraintKind constraintKind, |
| | | 1321 | | NavigationCellAddress actualAddress, |
| | | 1322 | | NavigationCellAddress targetAddress, |
| | | 1323 | | int predecessorOrdinal) |
| | | 1324 | | { |
| | | 1325 | | System.Diagnostics.Debug.Assert( |
| | | 1326 | | intervalEnter <= Fixed64.One, |
| | | 1327 | | "trace intervals are normalized to the closed segment parameter range"); |
| | 4905 | 1328 | | if (!permitsDestinationSuffix && intervalExit < Fixed64.One) |
| | | 1329 | | { |
| | 3152 | 1330 | | return false; |
| | | 1331 | | } |
| | 1753 | 1332 | | if (constraintKind == NavigationRayChainConstraintKind.FinishAddress |
| | 1753 | 1333 | | && actualAddress != targetAddress) |
| | | 1334 | | { |
| | 2 | 1335 | | return false; |
| | | 1336 | | } |
| | 1751 | 1337 | | if (constraintKind == NavigationRayChainConstraintKind.SelectedEdge |
| | 1751 | 1338 | | && (predecessorOrdinal < 0 || actualAddress != targetAddress)) |
| | | 1339 | | { |
| | 4 | 1340 | | return false; |
| | | 1341 | | } |
| | 1747 | 1342 | | return true; |
| | | 1343 | | } |
| | | 1344 | | |
| | | 1345 | | internal static bool IsPageDependencyCurrent( |
| | | 1346 | | bool found, |
| | | 1347 | | GraphPageDependency expected, |
| | | 1348 | | GraphPageDependency current) => |
| | 1853 | 1349 | | found && expected.Equals(current); |
| | | 1350 | | |
| | | 1351 | | internal static NavigationRayStatus ResolveVolumeTraversalStatus( |
| | | 1352 | | NavigationTraversalEvaluationStatus segmentStatus, |
| | | 1353 | | Fixed64 sourceTraversalCost, |
| | | 1354 | | Fixed64 edgeCost, |
| | | 1355 | | out Fixed64 traversalCost) |
| | | 1356 | | { |
| | 278 | 1357 | | traversalCost = default; |
| | 278 | 1358 | | NavigationRayStatus status = MapVolumeStatus(segmentStatus); |
| | 278 | 1359 | | if (status != NavigationRayStatus.Pending |
| | 278 | 1360 | | || segmentStatus != NavigationTraversalEvaluationStatus.Passable) |
| | | 1361 | | { |
| | 5 | 1362 | | return status; |
| | | 1363 | | } |
| | 273 | 1364 | | return Fixed64.TryAdd(sourceTraversalCost, edgeCost, out traversalCost) |
| | 273 | 1365 | | ? NavigationRayStatus.Pending |
| | 273 | 1366 | | : NavigationRayStatus.CostOverflow; |
| | | 1367 | | } |
| | | 1368 | | |
| | | 1369 | | internal static NavigationRayStatus MapTraversalAdvanceStatus( |
| | 278 | 1370 | | NavigationTraversalEdgeAdvanceStatus status) => status switch |
| | 278 | 1371 | | { |
| | 1 | 1372 | | NavigationTraversalEdgeAdvanceStatus.Blocked => NavigationRayStatus.Blocked, |
| | 278 | 1373 | | NavigationTraversalEdgeAdvanceStatus.BudgetExceeded => |
| | 3 | 1374 | | NavigationRayStatus.BudgetExceeded, |
| | 278 | 1375 | | NavigationTraversalEdgeAdvanceStatus.CapacityExceeded => |
| | 2 | 1376 | | NavigationRayStatus.CapacityExceeded, |
| | 278 | 1377 | | NavigationTraversalEdgeAdvanceStatus.CostOverflow => |
| | 2 | 1378 | | NavigationRayStatus.CostOverflow, |
| | 1 | 1379 | | NavigationTraversalEdgeAdvanceStatus.Stale => NavigationRayStatus.Stale, |
| | 269 | 1380 | | _ => NavigationRayStatus.Pending |
| | 278 | 1381 | | }; |
| | | 1382 | | |
| | | 1383 | | private GridNavigationBodySegmentEndpointAllowance GetEndpointAllowance( |
| | | 1384 | | int ordinal, |
| | | 1385 | | in NavigationRayChainRecord record, |
| | | 1386 | | bool isFinalSegment) |
| | | 1387 | | { |
| | 4566 | 1388 | | if (record.PredecessorOrdinal < 0 |
| | 4566 | 1389 | | && _request.EndpointAllowance == NavigationRayEndpointAllowance.StartPrefix |
| | 4566 | 1390 | | && _workspace.TraceIntervals[ordinal].TEnter > Fixed64.Zero) |
| | | 1391 | | { |
| | 296 | 1392 | | return GridNavigationBodySegmentEndpointAllowance.StartFootprintEdge; |
| | | 1393 | | } |
| | 4270 | 1394 | | return isFinalSegment |
| | 4270 | 1395 | | && _request.EndpointAllowance |
| | 4270 | 1396 | | == NavigationRayEndpointAllowance.DestinationSuffix |
| | 4270 | 1397 | | && _workspace.TraceIntervals[ordinal].TExit < Fixed64.One |
| | 4270 | 1398 | | ? GridNavigationBodySegmentEndpointAllowance.EndFootprintEdge |
| | 4270 | 1399 | | : GridNavigationBodySegmentEndpointAllowance.None; |
| | | 1400 | | } |
| | | 1401 | | |
| | | 1402 | | private bool TryGetIncomingPortal( |
| | | 1403 | | int ordinal, |
| | | 1404 | | NavigationWorkMeter? queryMeter, |
| | | 1405 | | ref GuideSampleWorkMeter guideMeter, |
| | | 1406 | | bool useGuideMeter, |
| | | 1407 | | out GridNavigationPortal portal) |
| | | 1408 | | { |
| | 4630 | 1409 | | ref NavigationRayChainRecord record = ref _workspace.ChainRecords[ordinal]; |
| | 4630 | 1410 | | if (record.PredecessorOrdinal < 0) |
| | | 1411 | | { |
| | 1540 | 1412 | | portal = default; |
| | 1540 | 1413 | | return true; |
| | | 1414 | | } |
| | 3090 | 1415 | | if (record.IncomingExplicitConnection != null) |
| | | 1416 | | { |
| | 18 | 1417 | | if (!TryConsumePortal(queryMeter, ref guideMeter, useGuideMeter)) |
| | | 1418 | | { |
| | 1 | 1419 | | portal = default; |
| | 1 | 1420 | | return false; |
| | | 1421 | | } |
| | 17 | 1422 | | var portals = record.IncomingExplicitConnection.NavigationPortals; |
| | 17 | 1423 | | portal = portals[portals.Count - 1]; |
| | 17 | 1424 | | return true; |
| | | 1425 | | } |
| | 3072 | 1426 | | NavigationRayChainRecord predecessor = |
| | 3072 | 1427 | | _workspace.ChainRecords[record.PredecessorOrdinal]; |
| | 3072 | 1428 | | NavigationWorldGraph graph = _request.ExpectedGraph; |
| | 3072 | 1429 | | if (!TryConsumePortal(queryMeter, ref guideMeter, useGuideMeter)) |
| | | 1430 | | { |
| | 3 | 1431 | | portal = default; |
| | 3 | 1432 | | return false; |
| | | 1433 | | } |
| | 3069 | 1434 | | graph.TryGetNodeAddress(predecessor.Node, out NavigationCellAddress source); |
| | 3069 | 1435 | | graph.TryGetNodeAddress(record.Node, out NavigationCellAddress target); |
| | 3069 | 1436 | | graph.TryGetSeamPrism(source, out GridCellPrism sourcePrism); |
| | 3069 | 1437 | | graph.TryGetSeamPrism(target, out GridCellPrism targetPrism); |
| | 3069 | 1438 | | GridCellGeometry.TryCreateNavigationPortal(sourcePrism, targetPrism, out portal); |
| | 3069 | 1439 | | return true; |
| | | 1440 | | } |
| | | 1441 | | |
| | | 1442 | | private bool IsSemanticCostNeutral(in NavigationGraphEdge edge) |
| | | 1443 | | { |
| | 2842 | 1444 | | return IsSemanticCostNeutral(edge.Target) |
| | 2842 | 1445 | | && (edge.Kind != NavigationGraphEdgeKind.Explicit |
| | 2842 | 1446 | | || edge.ExplicitConnection.Definition.AdditionalCost == Fixed64.Zero); |
| | | 1447 | | } |
| | | 1448 | | |
| | | 1449 | | private NavigationCellAddress GetAddress(NavigationNodeRef node) |
| | | 1450 | | { |
| | 862 | 1451 | | _request.ExpectedGraph.TryGetNodeAddress(node, out NavigationCellAddress address); |
| | 862 | 1452 | | return address; |
| | | 1453 | | } |
| | | 1454 | | |
| | | 1455 | | private bool IsSemanticCostNeutral(NavigationNodeRef target) |
| | | 1456 | | { |
| | 3110 | 1457 | | _request.ExpectedGraph.TryGetNodeState( |
| | 3110 | 1458 | | target, |
| | 3110 | 1459 | | Medium, |
| | 3110 | 1460 | | out NavigationNodeState state); |
| | 3110 | 1461 | | _request.AreaPolicy.TryGetRule(state.Cell.Area, out NavigationAreaRule rule); |
| | 3110 | 1462 | | return state.Cell.EnterCost == Fixed64.Zero |
| | 3110 | 1463 | | && rule.AdditionalEnterCost == Fixed64.Zero; |
| | | 1464 | | } |
| | | 1465 | | |
| | | 1466 | | private bool TryRecordDependencyNode(NavigationNodeRef node) |
| | | 1467 | | { |
| | 54 | 1468 | | NavigationWorldGraph graph = _request.ExpectedGraph; |
| | 54 | 1469 | | graph.TryGetNodeAddress(node, out NavigationCellAddress address); |
| | 54 | 1470 | | if (!_workspace.Dependencies.TryRecordPage( |
| | 54 | 1471 | | address.MapId, |
| | 54 | 1472 | | node.CellSlot / NavigationSemanticPage.SlotCount)) |
| | | 1473 | | { |
| | 1 | 1474 | | return false; |
| | | 1475 | | } |
| | 53 | 1476 | | graph.TryGetSurfaceComponent( |
| | 53 | 1477 | | address, |
| | 53 | 1478 | | Medium, |
| | 53 | 1479 | | out NavigationSurfaceComponentKey component, |
| | 53 | 1480 | | out _); |
| | 53 | 1481 | | return _workspace.Dependencies.TryRecordComponent(component); |
| | | 1482 | | } |
| | | 1483 | | |
| | | 1484 | | private NavigationRayStatus FinishSuccess(int ordinal) |
| | | 1485 | | { |
| | 1720 | 1486 | | NavigationRayChainRecord record = _workspace.ChainRecords[ordinal]; |
| | 1720 | 1487 | | NavigationRayChainRecord root = _workspace.ChainRecords[record.RootOrdinal]; |
| | 1720 | 1488 | | _request.ExpectedGraph.TryGetNodeAddress( |
| | 1720 | 1489 | | root.Node, |
| | 1720 | 1490 | | out NavigationCellAddress start); |
| | 1720 | 1491 | | _request.ExpectedGraph.TryGetNodeAddress( |
| | 1720 | 1492 | | record.Node, |
| | 1720 | 1493 | | out NavigationCellAddress end); |
| | 1720 | 1494 | | if (!AreDependenciesCurrent()) |
| | | 1495 | | { |
| | 7 | 1496 | | return Finish(NavigationRayStatus.Stale); |
| | | 1497 | | } |
| | 1713 | 1498 | | Result = new NavigationRayResult( |
| | 1713 | 1499 | | NavigationRayStatus.Success, |
| | 1713 | 1500 | | start, |
| | 1713 | 1501 | | end, |
| | 1713 | 1502 | | record.TraversalCost, |
| | 1713 | 1503 | | record.IsSemanticCostNeutral); |
| | 1713 | 1504 | | return Finish(NavigationRayStatus.Success, preserveResult: true); |
| | | 1505 | | } |
| | | 1506 | | |
| | | 1507 | | private NavigationRayStatus FinishBlocked() => |
| | 69 | 1508 | | AreDependenciesCurrent() |
| | 69 | 1509 | | ? Finish(NavigationRayStatus.Blocked) |
| | 69 | 1510 | | : Finish(NavigationRayStatus.Stale); |
| | | 1511 | | |
| | | 1512 | | private bool AreDependenciesCurrent() |
| | | 1513 | | { |
| | 1789 | 1514 | | if (_request.World.ChangeSequence != _worldChangeSequence) |
| | 3 | 1515 | | return false; |
| | 1786 | 1516 | | NavigationWorldGraph expected = _request.ExpectedGraph; |
| | 1786 | 1517 | | NavigationWorldGraph current = _request.Store.Current; |
| | 1786 | 1518 | | if (!current.AreaCatalog.TryGet( |
| | 1786 | 1519 | | _request.AreaPolicy.Key, |
| | 1786 | 1520 | | out NavigationAreaPolicy currentPolicy) |
| | 1786 | 1521 | | || !currentPolicy.ContentEquals(_request.AreaPolicy)) |
| | | 1522 | | { |
| | 4 | 1523 | | return false; |
| | | 1524 | | } |
| | 1782 | 1525 | | NavigationDependencyWorkspace dependencies = _workspace.Dependencies; |
| | 7180 | 1526 | | for (int i = 0; i < dependencies.ComponentCount; i++) |
| | | 1527 | | { |
| | 1809 | 1528 | | NavigationSurfaceComponentKey key = dependencies.Components[i]; |
| | 1809 | 1529 | | expected.TryGetComponentDependency(key, out GraphComponentDependency prior); |
| | 1809 | 1530 | | if (!current.TryGetComponentDependency(key, out GraphComponentDependency next) |
| | 1809 | 1531 | | || !prior.Equals(next)) |
| | | 1532 | | { |
| | 1 | 1533 | | return false; |
| | | 1534 | | } |
| | | 1535 | | } |
| | 7260 | 1536 | | for (int i = 0; i < dependencies.PageCount; i++) |
| | | 1537 | | { |
| | 1850 | 1538 | | GraphPageDependencyAddress address = dependencies.Pages[i]; |
| | 1850 | 1539 | | expected.TryGetPageDependency(address, out GraphPageDependency prior); |
| | 1850 | 1540 | | bool found = current.TryGetPageDependency( |
| | 1850 | 1541 | | address, |
| | 1850 | 1542 | | out GraphPageDependency next); |
| | 1850 | 1543 | | if (!IsPageDependencyCurrent(found, prior, next)) |
| | | 1544 | | { |
| | 1 | 1545 | | return false; |
| | | 1546 | | } |
| | | 1547 | | } |
| | 1780 | 1548 | | return _request.World.ChangeSequence == _worldChangeSequence; |
| | | 1549 | | } |
| | | 1550 | | |
| | | 1551 | | private bool TryConsumeLookup( |
| | | 1552 | | NavigationWorkMeter? queryMeter, |
| | | 1553 | | ref GuideSampleWorkMeter guideMeter, |
| | | 1554 | | bool useGuideMeter, |
| | | 1555 | | int count) |
| | | 1556 | | { |
| | 7219 | 1557 | | bool consumed = useGuideMeter |
| | 7219 | 1558 | | ? guideMeter.TryConsumeCurrentNodeLookupProbes(count) |
| | 7219 | 1559 | | : queryMeter!.TryConsumeLookupProbes(count); |
| | 7219 | 1560 | | _meterBlocked |= !consumed; |
| | 7219 | 1561 | | return consumed; |
| | | 1562 | | } |
| | | 1563 | | |
| | | 1564 | | private bool TryConsumeConnectionLeg( |
| | | 1565 | | NavigationWorkMeter? queryMeter, |
| | | 1566 | | ref GuideSampleWorkMeter guideMeter, |
| | | 1567 | | bool useGuideMeter) |
| | | 1568 | | { |
| | 56 | 1569 | | bool consumed = useGuideMeter |
| | 56 | 1570 | | ? guideMeter.TryConsumeCursorLegScans(1) |
| | 56 | 1571 | | : queryMeter!.TryConsumeConnectionLegs(1); |
| | 56 | 1572 | | _meterBlocked |= !consumed; |
| | 56 | 1573 | | return consumed; |
| | | 1574 | | } |
| | | 1575 | | |
| | | 1576 | | private bool TryConsumePortal( |
| | | 1577 | | NavigationWorkMeter? queryMeter, |
| | | 1578 | | ref GuideSampleWorkMeter guideMeter, |
| | | 1579 | | bool useGuideMeter) |
| | | 1580 | | { |
| | 8231 | 1581 | | bool consumed = useGuideMeter |
| | 8231 | 1582 | | ? guideMeter.TryConsumePortalChecks(1) |
| | 8231 | 1583 | | : queryMeter == null |
| | 8231 | 1584 | | || !queryMeter.IsGuideSampleBridge |
| | 8231 | 1585 | | || queryMeter.TryConsumeGuidePortalChecks(1); |
| | 8231 | 1586 | | _meterBlocked |= !consumed; |
| | 8231 | 1587 | | return consumed; |
| | | 1588 | | } |
| | | 1589 | | |
| | | 1590 | | private bool TryConsumePrism( |
| | | 1591 | | NavigationWorkMeter? queryMeter, |
| | | 1592 | | ref GuideSampleWorkMeter guideMeter, |
| | | 1593 | | bool useGuideMeter) |
| | | 1594 | | { |
| | 5544 | 1595 | | bool consumed = useGuideMeter |
| | 5544 | 1596 | | ? guideMeter.TryConsumePrismChecks(1) |
| | 5544 | 1597 | | : queryMeter == null |
| | 5544 | 1598 | | || !queryMeter.IsGuideSampleBridge |
| | 5544 | 1599 | | || queryMeter.TryConsumeGuidePrismChecks(1); |
| | 5544 | 1600 | | _meterBlocked |= !consumed; |
| | 5544 | 1601 | | return consumed; |
| | | 1602 | | } |
| | | 1603 | | |
| | | 1604 | | private NavigationRayStatus Finish( |
| | | 1605 | | NavigationRayStatus status, |
| | | 1606 | | bool preserveResult = false) |
| | | 1607 | | { |
| | 1955 | 1608 | | Status = status; |
| | 1955 | 1609 | | if (!preserveResult) |
| | 242 | 1610 | | Result = new NavigationRayResult(status, default, default, default, false); |
| | 1955 | 1611 | | ReleaseExplicitConnectionReferences(); |
| | 1955 | 1612 | | _request = default; |
| | 1955 | 1613 | | _evaluator = default; |
| | 1955 | 1614 | | _begun = false; |
| | 1955 | 1615 | | return status; |
| | | 1616 | | } |
| | | 1617 | | |
| | | 1618 | | private void ReleaseExplicitConnectionReferences() |
| | | 1619 | | { |
| | 9449 | 1620 | | NavigationRayChainRecord[] records = _workspace.ChainRecords; |
| | 47098 | 1621 | | for (int ordinal = 0; ordinal < _workspace.TraceIntervals.Count; ordinal++) |
| | | 1622 | | { |
| | 14100 | 1623 | | if (records[ordinal].IncomingExplicitConnection != null) |
| | 18 | 1624 | | records[ordinal].IncomingExplicitConnection = null!; |
| | | 1625 | | } |
| | 9449 | 1626 | | } |
| | | 1627 | | } |