| | | 1 | | //======================================================================= |
| | | 2 | | // GravitasMixedCollisionService.Partitioning.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2026-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using System.Runtime.CompilerServices; |
| | | 9 | | using FixedMathSharp; |
| | | 10 | | using FixedMathSharp.Geometry; |
| | | 11 | | using Gravitas.Colliders; |
| | | 12 | | using Gravitas.Support; |
| | | 13 | | using GridForge.Grids; |
| | | 14 | | using GridForge.Spatial; |
| | | 15 | | using GridForge.Utility; |
| | | 16 | | using SwiftCollections; |
| | | 17 | | |
| | | 18 | | namespace Gravitas; |
| | | 19 | | |
| | | 20 | | /// <content>Maintains mixed collider partition membership and gathers cross-dimensional broad-phase candidates.</conten |
| | | 21 | | internal sealed partial class GravitasMixedCollisionService |
| | | 22 | | { |
| | | 23 | | internal bool Refresh3DColliderPartition(LSCollider collider) |
| | | 24 | | { |
| | 31043 | 25 | | ChronicleGuard.ThrowIfNull(collider, nameof(collider)); |
| | 31043 | 26 | | ChronicleGuard.ThrowIfArgument( |
| | 31043 | 27 | | !ReferenceEquals(collider.Context, _context), |
| | 31043 | 28 | | nameof(collider), |
| | 31043 | 29 | | "3D collider must belong to this mixed collision service context."); |
| | | 30 | | |
| | 31043 | 31 | | if (!collider.IsActive || collider.Shape == ColliderType.None) |
| | | 32 | | { |
| | 3 | 33 | | ClearPartitioned3DCollider(collider, force: true); |
| | 3 | 34 | | collider.MarkMixedUnpartitioned(); |
| | 3 | 35 | | collider.ClearMixedPartitionCoordinates(); |
| | | 36 | | |
| | 3 | 37 | | return false; |
| | | 38 | | } |
| | | 39 | | |
| | 31040 | 40 | | Get3DCoverageBounds(collider, out Vector3d coverageMin, out Vector3d coverageMax); |
| | 31040 | 41 | | PhysicsMobilityType kind = Get3DMobilityKind(collider); |
| | 31040 | 42 | | if (collider.MatchesMixedPartitionGridBounds(coverageMin, coverageMax, (int)kind)) |
| | | 43 | | { |
| | 10436 | 44 | | Refresh3DPartitionAwakeState(collider); |
| | 10436 | 45 | | return false; |
| | | 46 | | } |
| | | 47 | | |
| | 20604 | 48 | | return Partition3DCollider(collider, coverageMin, coverageMax); |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | internal bool Refresh2DColliderPartition(LSCollider2D collider) => |
| | 150 | 52 | | Refresh2DColliderPartition(collider, rebuildShape: true); |
| | | 53 | | |
| | | 54 | | internal bool Refresh2DColliderPartition(LSCollider2D collider, bool rebuildShape) |
| | | 55 | | { |
| | 35657 | 56 | | ChronicleGuard.ThrowIfNull(collider, nameof(collider)); |
| | 35657 | 57 | | ChronicleGuard.ThrowIfArgument( |
| | 35657 | 58 | | !ReferenceEquals(collider.Context, _context), |
| | 35657 | 59 | | nameof(collider), |
| | 35657 | 60 | | "2D collider must belong to this mixed collision service context."); |
| | | 61 | | |
| | 35657 | 62 | | if (rebuildShape) |
| | 913 | 63 | | collider.Rebuild(); |
| | | 64 | | |
| | 35657 | 65 | | if (!collider.IsActive || collider.Shape == ColliderType2D.None) |
| | | 66 | | { |
| | 5 | 67 | | ClearPartitioned2DCollider(collider, force: true); |
| | 5 | 68 | | collider.MarkMixedUnpartitioned(); |
| | 5 | 69 | | collider.ClearMixedPartitionCoordinates(); |
| | | 70 | | |
| | 5 | 71 | | return false; |
| | | 72 | | } |
| | | 73 | | |
| | 35652 | 74 | | Get2DMixedCoverageBounds(collider, out Vector3d coverageMin, out Vector3d coverageMax); |
| | 35652 | 75 | | PhysicsMobilityType kind = Get2DMobilityKind(collider); |
| | 35652 | 76 | | if (collider.MatchesMixedPartitionGridBounds(coverageMin, coverageMax, (int)kind)) |
| | | 77 | | { |
| | 26962 | 78 | | Refresh2DPartitionAwakeState(collider); |
| | 26962 | 79 | | return false; |
| | | 80 | | } |
| | | 81 | | |
| | 8690 | 82 | | return Partition2DCollider(collider, coverageMin, coverageMax); |
| | | 83 | | } |
| | | 84 | | |
| | | 85 | | internal bool ClearPartitioned3DCollider(LSCollider collider, bool force = false) |
| | | 86 | | { |
| | 91 | 87 | | ChronicleGuard.ThrowIfNull(collider, nameof(collider)); |
| | 91 | 88 | | if (!collider.IsMixedPartitioned) |
| | 3 | 89 | | return false; |
| | | 90 | | |
| | 88 | 91 | | Get3DCoverageBounds(collider, out Vector3d coverageMin, out Vector3d coverageMax); |
| | 88 | 92 | | PhysicsMobilityType currentKind = Get3DMobilityKind(collider); |
| | 88 | 93 | | if (!force && collider.MatchesMixedPartitionGridBounds(coverageMin, coverageMax, (int)currentKind)) |
| | 1 | 94 | | return false; |
| | | 95 | | |
| | 87 | 96 | | SwiftList<WorldVoxelIndex> coordinates = collider.MixedPartitionCoordinates!; |
| | 87 | 97 | | PhysicsMobilityType partitionKind = GetStoredMobilityKind(collider.MixedPartitionKind); |
| | 87 | 98 | | Remove3DPartitionMemberships(collider, coordinates, partitionKind, preserveCovered: false); |
| | | 99 | | |
| | 87 | 100 | | collider.MarkMixedUnpartitioned(); |
| | 87 | 101 | | collider.ClearMixedPartitionCoordinates(); |
| | 87 | 102 | | return true; |
| | | 103 | | } |
| | | 104 | | |
| | | 105 | | private void Remove3DPartitionMemberships( |
| | | 106 | | LSCollider collider, |
| | | 107 | | SwiftList<WorldVoxelIndex> coordinates, |
| | | 108 | | PhysicsMobilityType partitionKind, |
| | | 109 | | bool preserveCovered) |
| | | 110 | | { |
| | 20691 | 111 | | GridWorld world = _context.World; |
| | 1529854 | 112 | | for (int i = 0; i < coordinates.Count; i++) |
| | | 113 | | { |
| | 744236 | 114 | | WorldVoxelIndex coordinate = coordinates[i]; |
| | 744236 | 115 | | if (preserveCovered && _nextCoveredCoordinates.Contains(coordinate)) |
| | | 116 | | continue; |
| | | 117 | | |
| | 37586 | 118 | | if (!world.TryGetVoxel(coordinate, out Voxel? voxel) |
| | 37586 | 119 | | || !voxel!.TryGetPartition(out PhysicsMixedPartition? partition)) |
| | | 120 | | { |
| | | 121 | | continue; |
| | | 122 | | } |
| | | 123 | | |
| | 37556 | 124 | | Remove3DObject(partition!, collider.Id, partitionKind); |
| | | 125 | | } |
| | 20691 | 126 | | } |
| | | 127 | | |
| | | 128 | | internal bool ClearPartitioned2DCollider(LSCollider2D collider, bool force = false) |
| | | 129 | | { |
| | 112 | 130 | | ChronicleGuard.ThrowIfNull(collider, nameof(collider)); |
| | 112 | 131 | | if (!collider.IsMixedPartitioned) |
| | 5 | 132 | | return false; |
| | | 133 | | |
| | 107 | 134 | | Get2DMixedCoverageBounds(collider, out Vector3d coverageMin, out Vector3d coverageMax); |
| | 107 | 135 | | PhysicsMobilityType currentKind = Get2DMobilityKind(collider); |
| | 107 | 136 | | if (!force && collider.MatchesMixedPartitionGridBounds(coverageMin, coverageMax, (int)currentKind)) |
| | 3 | 137 | | return false; |
| | | 138 | | |
| | 104 | 139 | | SwiftList<WorldVoxelIndex> coordinates = collider.MixedPartitionCoordinates!; |
| | 104 | 140 | | PhysicsMobilityType partitionKind = GetStoredMobilityKind(collider.MixedPartitionKind); |
| | 104 | 141 | | Remove2DPartitionMemberships(collider, coordinates, partitionKind, preserveCovered: false); |
| | | 142 | | |
| | 104 | 143 | | collider.MarkMixedUnpartitioned(); |
| | 104 | 144 | | collider.ClearMixedPartitionCoordinates(); |
| | 104 | 145 | | return true; |
| | | 146 | | } |
| | | 147 | | |
| | | 148 | | private void Remove2DPartitionMemberships( |
| | | 149 | | LSCollider2D collider, |
| | | 150 | | SwiftList<WorldVoxelIndex> coordinates, |
| | | 151 | | PhysicsMobilityType partitionKind, |
| | | 152 | | bool preserveCovered) |
| | | 153 | | { |
| | 8794 | 154 | | GridWorld world = _context.World; |
| | 199270 | 155 | | for (int i = 0; i < coordinates.Count; i++) |
| | | 156 | | { |
| | 90841 | 157 | | WorldVoxelIndex coordinate = coordinates[i]; |
| | 90841 | 158 | | if (preserveCovered && _nextCoveredCoordinates.Contains(coordinate)) |
| | | 159 | | continue; |
| | | 160 | | |
| | 10650 | 161 | | if (!world.TryGetVoxel(coordinate, out Voxel? voxel) |
| | 10650 | 162 | | || !voxel!.TryGetPartition(out PhysicsMixedPartition? partition)) |
| | | 163 | | { |
| | | 164 | | continue; |
| | | 165 | | } |
| | | 166 | | |
| | 10621 | 167 | | Remove2DObject(partition!, collider.Id, partitionKind); |
| | | 168 | | } |
| | 8794 | 169 | | } |
| | | 170 | | |
| | | 171 | | internal void Refresh3DPartitionAwakeState(LSCollider collider) |
| | | 172 | | { |
| | 12843 | 173 | | ChronicleGuard.ThrowIfNull(collider, nameof(collider)); |
| | 12843 | 174 | | if (!collider.IsMixedPartitioned) |
| | 1999 | 175 | | return; |
| | | 176 | | |
| | 10844 | 177 | | SwiftList<WorldVoxelIndex> coordinates = collider.MixedPartitionCoordinates!; |
| | 10844 | 178 | | SolidBody? body = collider.Body; |
| | 10844 | 179 | | if (collider.IsStatic) |
| | 8756 | 180 | | return; |
| | | 181 | | |
| | 2088 | 182 | | bool awake = body!.IsAwakeForCollision; |
| | 2088 | 183 | | GridWorld world = _context.World; |
| | 186260 | 184 | | for (int i = 0; i < coordinates.Count; i++) |
| | | 185 | | { |
| | 91042 | 186 | | WorldVoxelIndex coordinate = coordinates[i]; |
| | 91042 | 187 | | if (!world.TryGetVoxel(coordinate, out Voxel? voxel) |
| | 91042 | 188 | | || !voxel!.TryGetPartition(out PhysicsMixedPartition? partition)) |
| | | 189 | | { |
| | | 190 | | continue; |
| | | 191 | | } |
| | | 192 | | |
| | 91039 | 193 | | partition!.SetDynamic3DObjectAwake(collider.Id, awake); |
| | | 194 | | } |
| | 2088 | 195 | | } |
| | | 196 | | |
| | | 197 | | internal void Refresh2DPartitionAwakeState(LSCollider2D collider) |
| | | 198 | | { |
| | 28866 | 199 | | ChronicleGuard.ThrowIfNull(collider, nameof(collider)); |
| | 28866 | 200 | | if (!collider.IsMixedPartitioned) |
| | 1607 | 201 | | return; |
| | | 202 | | |
| | 27259 | 203 | | SwiftList<WorldVoxelIndex> coordinates = collider.MixedPartitionCoordinates!; |
| | 27259 | 204 | | SolidBody2D? body = collider.Body; |
| | 27259 | 205 | | if (collider.IsStatic) |
| | 25342 | 206 | | return; |
| | | 207 | | |
| | 1917 | 208 | | bool awake = body!.IsAwakeForCollision; |
| | 1917 | 209 | | GridWorld world = _context.World; |
| | 87172 | 210 | | for (int i = 0; i < coordinates.Count; i++) |
| | | 211 | | { |
| | 41669 | 212 | | WorldVoxelIndex coordinate = coordinates[i]; |
| | 41669 | 213 | | if (!world.TryGetVoxel(coordinate, out Voxel? voxel) |
| | 41669 | 214 | | || !voxel!.TryGetPartition(out PhysicsMixedPartition? partition)) |
| | | 215 | | { |
| | | 216 | | continue; |
| | | 217 | | } |
| | | 218 | | |
| | 41667 | 219 | | partition!.SetDynamic2DObjectAwake(collider.Id, awake); |
| | | 220 | | } |
| | 1917 | 221 | | } |
| | | 222 | | |
| | | 223 | | internal void ProcessPartitionCandidate(int collider3DId, int collider2DId) |
| | | 224 | | { |
| | 301622 | 225 | | if (!_context.Physics.TryGetColliderById(collider3DId, out LSCollider? collider3D) |
| | 301622 | 226 | | || !_context.Physics2D.TryGetColliderById(collider2DId, out LSCollider2D? collider2D) |
| | 301622 | 227 | | || !RequireCollisionPair(collider3D!, collider2D!) |
| | 301622 | 228 | | || !MixedBoundsOverlap(collider3D!, collider2D!)) |
| | | 229 | | { |
| | 25387 | 230 | | return; |
| | | 231 | | } |
| | | 232 | | |
| | 276235 | 233 | | ulong key = MixedColliderKey.CreateKey(collider3DId, collider2DId); |
| | 276235 | 234 | | if (!_processedPairKeys.Add(key)) |
| | 259640 | 235 | | return; |
| | | 236 | | |
| | 16595 | 237 | | _candidatePairs.Add(new MixedColliderKey(collider3DId, collider2DId)); |
| | 16595 | 238 | | } |
| | | 239 | | |
| | | 240 | | internal void Collect2DCandidatesInMixedBounds( |
| | | 241 | | Vector3d min, |
| | | 242 | | Vector3d max, |
| | | 243 | | PhysicsLayerMask layerMask, |
| | | 244 | | SwiftList<LSCollider2D> candidates, |
| | | 245 | | bool staticStyleOnly = false, |
| | | 246 | | bool cachePartitionRefresh = false) |
| | | 247 | | { |
| | 9861 | 248 | | ChronicleGuard.ThrowIfNull(candidates, nameof(candidates)); |
| | 9861 | 249 | | Refresh2DColliderPartitionsForQuery(cachePartitionRefresh); |
| | 9852 | 250 | | candidates.FastClear(); |
| | 9852 | 251 | | FixedBoundBox queryBounds = FixedBoundBox.FromMinMax(min, max); |
| | 9852 | 252 | | CollectCoveredMixedQueryPartitions(min, max, _queryPartitions); |
| | 9852 | 253 | | _queryPartitions.SortInPlace(PartitionOrderComparer); |
| | 9852 | 254 | | _queryColliderRedundancy.Clear(); |
| | | 255 | | |
| | 2085090 | 256 | | for (int i = 0; i < _queryPartitions.Count; i++) |
| | | 257 | | { |
| | 1032693 | 258 | | PhysicsMixedPartition partition = _queryPartitions[i]; |
| | 1032693 | 259 | | if (staticStyleOnly) |
| | 1016077 | 260 | | partition.CopyStaticStyle2DColliderIds(_queryColliderIds); |
| | | 261 | | else |
| | 16616 | 262 | | partition.Copy2DColliderIds(_queryColliderIds); |
| | | 263 | | |
| | 4124118 | 264 | | for (int j = 0; j < _queryColliderIds.Count; j++) |
| | | 265 | | { |
| | 1029366 | 266 | | int colliderId = _queryColliderIds[j]; |
| | 1029366 | 267 | | if (!_queryColliderRedundancy.Add(colliderId) |
| | 1029366 | 268 | | || !_context.Physics2D.TryGetColliderById(colliderId, out LSCollider2D? collider) |
| | 1029366 | 269 | | || !Is2DQueryCandidate(collider!, queryBounds, layerMask)) |
| | | 270 | | { |
| | | 271 | | continue; |
| | | 272 | | } |
| | | 273 | | |
| | 19975 | 274 | | candidates.Add(collider!); |
| | | 275 | | } |
| | | 276 | | } |
| | | 277 | | |
| | 9852 | 278 | | _queryColliderRedundancy.Clear(); |
| | 9852 | 279 | | candidates.SortInPlace(Collider2DIdOrderComparer); |
| | 9852 | 280 | | } |
| | | 281 | | |
| | | 282 | | internal void Collect3DCandidatesInMixedBounds( |
| | | 283 | | Vector3d min, |
| | | 284 | | Vector3d max, |
| | | 285 | | PhysicsLayerMask layerMask, |
| | | 286 | | SwiftList<LSCollider> candidates, |
| | | 287 | | bool staticStyleOnly = false, |
| | | 288 | | bool cachePartitionRefresh = false) |
| | | 289 | | { |
| | 1803 | 290 | | ChronicleGuard.ThrowIfNull(candidates, nameof(candidates)); |
| | 1803 | 291 | | Refresh3DColliderPartitionsForQuery(cachePartitionRefresh); |
| | 1803 | 292 | | candidates.FastClear(); |
| | 1803 | 293 | | FixedBoundBox queryBounds = FixedBoundBox.FromMinMax(min, max); |
| | 1803 | 294 | | CollectCoveredMixedQueryPartitions(min, max, _queryPartitions); |
| | 1803 | 295 | | _queryPartitions.SortInPlace(PartitionOrderComparer); |
| | 1803 | 296 | | _queryColliderRedundancy.Clear(); |
| | | 297 | | |
| | 130416 | 298 | | for (int i = 0; i < _queryPartitions.Count; i++) |
| | | 299 | | { |
| | 63405 | 300 | | PhysicsMixedPartition partition = _queryPartitions[i]; |
| | 63405 | 301 | | if (staticStyleOnly) |
| | 16259 | 302 | | partition.CopyStaticStyle3DColliderIds(_queryColliderIds); |
| | | 303 | | else |
| | 47146 | 304 | | partition.Copy3DColliderIds(_queryColliderIds); |
| | | 305 | | |
| | 241004 | 306 | | for (int j = 0; j < _queryColliderIds.Count; j++) |
| | | 307 | | { |
| | 57097 | 308 | | int colliderId = _queryColliderIds[j]; |
| | 57097 | 309 | | if (!_queryColliderRedundancy.Add(colliderId) |
| | 57097 | 310 | | || !_context.Physics.TryGetColliderById(colliderId, out LSCollider? collider) |
| | 57097 | 311 | | || !Is3DQueryCandidate(collider!, queryBounds, layerMask)) |
| | | 312 | | { |
| | | 313 | | continue; |
| | | 314 | | } |
| | | 315 | | |
| | 1928 | 316 | | candidates.Add(collider!); |
| | | 317 | | } |
| | | 318 | | } |
| | | 319 | | |
| | 1803 | 320 | | _queryColliderRedundancy.Clear(); |
| | 1803 | 321 | | candidates.SortInPlace(Collider3DIdOrderComparer); |
| | 1803 | 322 | | } |
| | | 323 | | |
| | | 324 | | |
| | | 325 | | internal int ActivatePartition(PhysicsMixedPartition partition) |
| | | 326 | | { |
| | 96420 | 327 | | ChronicleGuard.ThrowIfNull(partition, nameof(partition)); |
| | 96420 | 328 | | ChronicleGuard.ThrowIfArgument( |
| | 96420 | 329 | | !ReferenceEquals(partition.Owner, this), |
| | 96420 | 330 | | nameof(partition), |
| | 96420 | 331 | | "Mixed partition must belong to this collision service."); |
| | | 332 | | |
| | 96420 | 333 | | return _activePartitions.Add(partition); |
| | | 334 | | } |
| | | 335 | | |
| | 96418 | 336 | | internal void DeactivatePartition(int activationId) => _activePartitions.TryRemoveAt(activationId); |
| | | 337 | | |
| | | 338 | | internal PhysicsMixedPartition RentPartition() |
| | | 339 | | { |
| | 434916 | 340 | | if (_inactivePartitionPool.Count == 0) |
| | 434875 | 341 | | TryRetireEmptyRetainedPartitionForReuse(); |
| | | 342 | | |
| | 434916 | 343 | | PhysicsMixedPartition partition = _inactivePartitionPool.Count > 0 |
| | 434916 | 344 | | ? _inactivePartitionPool.Pop() |
| | 434916 | 345 | | : new PhysicsMixedPartition(); |
| | 434916 | 346 | | partition.SetOwner(this); |
| | 434916 | 347 | | return partition; |
| | | 348 | | } |
| | | 349 | | |
| | | 350 | | internal void ReleasePartition(PhysicsMixedPartition partition) |
| | | 351 | | { |
| | 434915 | 352 | | ChronicleGuard.ThrowIfNull(partition, nameof(partition)); |
| | 434915 | 353 | | ChronicleGuard.ThrowIfArgument( |
| | 434915 | 354 | | !ReferenceEquals(partition.Owner, this), |
| | 434915 | 355 | | nameof(partition), |
| | 434915 | 356 | | "Mixed partition must be released through its owning collision service."); |
| | | 357 | | |
| | 434915 | 358 | | UntrackRetainedPartition(partition); |
| | 434915 | 359 | | partition.ResetForPool(); |
| | 434915 | 360 | | _inactivePartitionPool.Push(partition); |
| | 434915 | 361 | | } |
| | | 362 | | |
| | | 363 | | internal SwiftHashSet<int> RentPartitionMembership() |
| | | 364 | | { |
| | 566978 | 365 | | return _inactivePartitionMembershipPool.Count > 0 |
| | 566978 | 366 | | ? _inactivePartitionMembershipPool.Pop() |
| | 566978 | 367 | | : new SwiftHashSet<int>(); |
| | | 368 | | } |
| | | 369 | | |
| | | 370 | | internal void ReleasePartitionMembership(ref SwiftHashSet<int>? membership) |
| | | 371 | | { |
| | 3559096 | 372 | | if (membership == null) |
| | 2992128 | 373 | | return; |
| | | 374 | | |
| | 566968 | 375 | | SwiftHashSet<int> released = membership; |
| | 566968 | 376 | | membership = null; |
| | 566968 | 377 | | released.Clear(); |
| | 566968 | 378 | | _inactivePartitionMembershipPool.Push(released); |
| | 566968 | 379 | | } |
| | | 380 | | |
| | | 381 | | private void Refresh3DColliderPartitions() |
| | | 382 | | { |
| | 17576 | 383 | | int count = _context.Physics.ColliderCount; |
| | 75912 | 384 | | for (int i = 0; i < count; i++) |
| | 20380 | 385 | | Refresh3DColliderPartition(_context.Physics.GetColliderByServiceIndex(i)); |
| | 17576 | 386 | | } |
| | | 387 | | |
| | | 388 | | private void Refresh3DColliderPartitionsForQuery(bool cachePartitionRefresh) |
| | | 389 | | { |
| | 1803 | 390 | | if (!cachePartitionRefresh) |
| | | 391 | | { |
| | 1124 | 392 | | Refresh3DColliderPartitions(); |
| | 1124 | 393 | | return; |
| | | 394 | | } |
| | | 395 | | |
| | 679 | 396 | | long frame = _context.FrameCount; |
| | 679 | 397 | | long lateToken = _context.LateSimulateToken; |
| | | 398 | | // CCD batches query stable opposite-dimension targets many times in one late-sim phase. |
| | | 399 | | // Cache only the partition refresh; every sweep still gathers and sorts its own hits. |
| | 679 | 400 | | if (_cached3DQueryRefreshFrame == frame && _cached3DQueryRefreshLateToken == lateToken) |
| | 226 | 401 | | return; |
| | | 402 | | |
| | 453 | 403 | | Refresh3DColliderPartitions(); |
| | 453 | 404 | | _cached3DQueryRefreshFrame = frame; |
| | 453 | 405 | | _cached3DQueryRefreshLateToken = lateToken; |
| | 453 | 406 | | } |
| | | 407 | | |
| | | 408 | | private void Refresh2DColliderPartitions(bool rebuildShapes = true) |
| | | 409 | | { |
| | 21606 | 410 | | int count = _context.Physics2D.ColliderCount; |
| | 109194 | 411 | | for (int i = 0; i < count; i++) |
| | 32991 | 412 | | Refresh2DColliderPartition(_context.Physics2D.GetColliderByServiceIndex(i), rebuildShapes); |
| | 21606 | 413 | | } |
| | | 414 | | |
| | | 415 | | private void Refresh2DColliderPartitionsForQuery(bool cachePartitionRefresh) |
| | | 416 | | { |
| | 9861 | 417 | | if (!_context.Settings.RuntimeMode.RunsMixedContacts()) |
| | | 418 | | { |
| | | 419 | | // Explicit mixed queries can index slabs that pure 2D admission did not use. |
| | 32 | 420 | | for (int i = 0; i < _context.Physics2D.ColliderCount; i++) |
| | | 421 | | { |
| | 11 | 422 | | LSCollider2D collider = _context.Physics2D.GetColliderByServiceIndex(i); |
| | 11 | 423 | | if (collider.IsActive) |
| | | 424 | | { |
| | 10 | 425 | | collider.Rebuild(); |
| | 9 | 426 | | collider.ValidateCommittedMixedGeometry(); |
| | | 427 | | } |
| | | 428 | | } |
| | 5 | 429 | | Refresh2DColliderPartitions(rebuildShapes: false); |
| | 5 | 430 | | return; |
| | | 431 | | } |
| | 9847 | 432 | | if (!cachePartitionRefresh) |
| | | 433 | | { |
| | 581 | 434 | | Refresh2DColliderPartitions(); |
| | 581 | 435 | | return; |
| | | 436 | | } |
| | | 437 | | |
| | 9266 | 438 | | long frame = _context.FrameCount; |
| | 9266 | 439 | | long lateToken = _context.LateSimulateToken; |
| | | 440 | | // CCD batches query stable opposite-dimension targets many times in one late-sim phase. |
| | | 441 | | // Cache only the partition refresh; every sweep still gathers and sorts its own hits. |
| | 9266 | 442 | | if (_cached2DQueryRefreshFrame == frame && _cached2DQueryRefreshLateToken == lateToken) |
| | 4245 | 443 | | return; |
| | | 444 | | |
| | | 445 | | // CCD callers request a cached refresh only after the 2D frame has |
| | | 446 | | // prepared its authoritative target poses. Rebuilding those shapes |
| | | 447 | | // again here duplicates work and can churn shape-owned scratch state. |
| | 5021 | 448 | | Refresh2DColliderPartitions(rebuildShapes: false); |
| | 5021 | 449 | | _cached2DQueryRefreshFrame = frame; |
| | 5021 | 450 | | _cached2DQueryRefreshLateToken = lateToken; |
| | 5021 | 451 | | } |
| | | 452 | | |
| | | 453 | | private bool Partition3DCollider(LSCollider collider, Vector3d coverageMin, Vector3d coverageMax) |
| | | 454 | | { |
| | 20604 | 455 | | PhysicsMobilityType kind = Get3DMobilityKind(collider); |
| | 20604 | 456 | | SwiftList<WorldVoxelIndex> coordinates = collider.GetOrCreateMixedPartitionCoordinates(); |
| | 20604 | 457 | | ScanCovered3DVoxels(collider, coverageMin, coverageMax, coordinates, kind); |
| | 20604 | 458 | | if (coordinates.Count == 0) |
| | | 459 | | { |
| | 75 | 460 | | collider.MarkMixedUnpartitioned(); |
| | 75 | 461 | | return false; |
| | | 462 | | } |
| | | 463 | | |
| | 20529 | 464 | | collider.MarkMixedPartitioned(coverageMin, coverageMax, (int)kind); |
| | 20529 | 465 | | return true; |
| | | 466 | | } |
| | | 467 | | |
| | | 468 | | private bool Partition2DCollider(LSCollider2D collider, Vector3d coverageMin, Vector3d coverageMax) |
| | | 469 | | { |
| | 8690 | 470 | | PhysicsMobilityType kind = Get2DMobilityKind(collider); |
| | 8690 | 471 | | SwiftList<WorldVoxelIndex> coordinates = collider.GetOrCreateMixedPartitionCoordinates(); |
| | 8690 | 472 | | ScanCovered2DMixedVoxels(collider, coverageMin, coverageMax, coordinates, kind); |
| | 8690 | 473 | | if (coordinates.Count == 0) |
| | | 474 | | { |
| | 59 | 475 | | collider.MarkMixedUnpartitioned(); |
| | 59 | 476 | | return false; |
| | | 477 | | } |
| | | 478 | | |
| | 8631 | 479 | | collider.MarkMixedPartitioned(coverageMin, coverageMax, (int)kind); |
| | 8631 | 480 | | return true; |
| | | 481 | | } |
| | | 482 | | |
| | | 483 | | private void ScanCovered3DVoxels( |
| | | 484 | | LSCollider collider, |
| | | 485 | | Vector3d coverageMin, |
| | | 486 | | Vector3d coverageMax, |
| | | 487 | | SwiftList<WorldVoxelIndex> coordinates, |
| | | 488 | | PhysicsMobilityType kind) |
| | | 489 | | { |
| | 20604 | 490 | | GridWorld world = _context.World; |
| | 20604 | 491 | | GridTracer.GetCoveredVoxelsInto( |
| | 20604 | 492 | | world, |
| | 20604 | 493 | | coverageMin, |
| | 20604 | 494 | | coverageMax, |
| | 20604 | 495 | | _coveredVoxels, |
| | 20604 | 496 | | _traceScratch, |
| | 20604 | 497 | | Fixed64.Half); |
| | | 498 | | |
| | 20604 | 499 | | var traversal = new GridTraversalState(world, GridTraversalPaddingMode.MaxCellEdge); |
| | 20604 | 500 | | _nextCoveredCoordinates.Clear(); |
| | 20604 | 501 | | int coveredCount = 0; |
| | 2885832 | 502 | | for (int i = 0; i < _coveredVoxels.Count; i++) |
| | | 503 | | { |
| | 1422312 | 504 | | Voxel voxel = _coveredVoxels[i]; |
| | 1422312 | 505 | | if (collider.IsPositionInBounds(traversal.GetCellEdge(voxel), voxel.WorldPosition)) |
| | | 506 | | { |
| | 924648 | 507 | | _nextCoveredCoordinates.Add(voxel.WorldIndex); |
| | 924648 | 508 | | _coveredVoxels[coveredCount++] = voxel; |
| | | 509 | | } |
| | | 510 | | } |
| | | 511 | | |
| | | 512 | | // Remove departures in the previous coordinate order, then publish the |
| | | 513 | | // new tracer order. Hash storage never determines simulation order. |
| | 20604 | 514 | | PhysicsMobilityType previousKind = GetStoredMobilityKind(collider.MixedPartitionKind); |
| | 20604 | 515 | | Remove3DPartitionMemberships(collider, coordinates, previousKind, previousKind == kind); |
| | 20604 | 516 | | coordinates.FastClear(); |
| | 1890504 | 517 | | for (int i = 0; i < coveredCount; i++) |
| | 924648 | 518 | | Partition3DVoxel(collider, coordinates, _coveredVoxels[i], kind); |
| | 20604 | 519 | | } |
| | | 520 | | |
| | | 521 | | private void ScanCovered2DMixedVoxels( |
| | | 522 | | LSCollider2D collider, |
| | | 523 | | Vector3d coverageMin, |
| | | 524 | | Vector3d coverageMax, |
| | | 525 | | SwiftList<WorldVoxelIndex> coordinates, |
| | | 526 | | PhysicsMobilityType kind) |
| | | 527 | | { |
| | 8690 | 528 | | GridWorld world = _context.World; |
| | 8690 | 529 | | GridTracer.GetCoveredVoxelsInto( |
| | 8690 | 530 | | world, |
| | 8690 | 531 | | coverageMin, |
| | 8690 | 532 | | coverageMax, |
| | 8690 | 533 | | _coveredVoxels, |
| | 8690 | 534 | | _traceScratch, |
| | 8690 | 535 | | Fixed64.Half); |
| | | 536 | | |
| | 8690 | 537 | | var traversal = new GridTraversalState(world, GridTraversalPaddingMode.MaxCellEdge); |
| | 8690 | 538 | | _nextCoveredCoordinates.Clear(); |
| | 1891694 | 539 | | for (int i = 0; i < _coveredVoxels.Count; i++) |
| | | 540 | | { |
| | 937157 | 541 | | Voxel voxel = _coveredVoxels[i]; |
| | 937157 | 542 | | if (collider.IsPositionInMixedBounds(traversal.GetCellEdge(voxel), voxel.WorldPosition)) |
| | 374546 | 543 | | _nextCoveredCoordinates.Add(voxel.WorldIndex); |
| | | 544 | | } |
| | | 545 | | |
| | 8690 | 546 | | PhysicsMobilityType previousKind = GetStoredMobilityKind(collider.MixedPartitionKind); |
| | 8690 | 547 | | Remove2DPartitionMemberships(collider, coordinates, previousKind, previousKind == kind); |
| | 8690 | 548 | | coordinates.FastClear(); |
| | 1891694 | 549 | | for (int i = 0; i < _coveredVoxels.Count; i++) |
| | 937157 | 550 | | TryPartition2DMixedVoxel(collider, coordinates, _coveredVoxels[i], kind); |
| | 8690 | 551 | | } |
| | | 552 | | |
| | | 553 | | private void CollectCoveredMixedQueryPartitions( |
| | | 554 | | Vector3d min, |
| | | 555 | | Vector3d max, |
| | | 556 | | SwiftList<PhysicsMixedPartition> partitions) |
| | | 557 | | { |
| | 11655 | 558 | | partitions.FastClear(); |
| | 11655 | 559 | | ScanCoveredMixedQueryPartitions(min, max, partitions); |
| | 11655 | 560 | | } |
| | | 561 | | |
| | | 562 | | private void ScanCoveredMixedQueryPartitions( |
| | | 563 | | Vector3d queryMin, |
| | | 564 | | Vector3d queryMax, |
| | | 565 | | SwiftList<PhysicsMixedPartition> partitions) |
| | | 566 | | { |
| | 11655 | 567 | | GridTracer.GetCoveredVoxelsInto( |
| | 11655 | 568 | | _context.World, |
| | 11655 | 569 | | queryMin, |
| | 11655 | 570 | | queryMax, |
| | 11655 | 571 | | _coveredVoxels, |
| | 11655 | 572 | | _traceScratch, |
| | 11655 | 573 | | Fixed64.Half); |
| | | 574 | | |
| | 11655 | 575 | | VisitCoveredVoxelsForMixedQuery(queryMin, queryMax, partitions); |
| | 11655 | 576 | | } |
| | | 577 | | |
| | | 578 | | private void VisitCoveredVoxelsForMixedQuery( |
| | | 579 | | Vector3d queryMin, |
| | | 580 | | Vector3d queryMax, |
| | | 581 | | SwiftList<PhysicsMixedPartition> partitions) |
| | | 582 | | { |
| | 11655 | 583 | | GridWorld world = _context.World; |
| | 11655 | 584 | | var traversal = new GridTraversalState(world, GridTraversalPaddingMode.MaxCellEdge); |
| | 18359236 | 585 | | for (int i = 0; i < _coveredVoxels.Count; i++) |
| | | 586 | | { |
| | 9167963 | 587 | | Voxel voxel = _coveredVoxels[i]; |
| | 9167963 | 588 | | Fixed64 cellEdge = traversal.GetCellEdge(voxel); |
| | | 589 | | |
| | 9167963 | 590 | | if (!GridTraversal.IsWorldPositionInPaddedBounds(queryMin, queryMax, cellEdge, voxel.WorldPosition) |
| | 9167963 | 591 | | || !voxel.TryGetPartition(out PhysicsMixedPartition? partition) |
| | 9167963 | 592 | | || partition!.IsEmpty) |
| | | 593 | | { |
| | | 594 | | continue; |
| | | 595 | | } |
| | | 596 | | |
| | 1096098 | 597 | | partitions.Add(partition); |
| | | 598 | | } |
| | 11655 | 599 | | } |
| | | 600 | | |
| | | 601 | | private void Partition3DVoxel( |
| | | 602 | | LSCollider collider, |
| | | 603 | | SwiftList<WorldVoxelIndex> coordinates, |
| | | 604 | | Voxel voxel, |
| | | 605 | | PhysicsMobilityType kind) |
| | | 606 | | { |
| | 924648 | 607 | | PhysicsMixedPartition partition = GetOrCreatePartition(voxel); |
| | 924648 | 608 | | coordinates.Add(voxel.WorldIndex); |
| | 924648 | 609 | | Add3DObject(partition, collider.Id, kind); |
| | | 610 | | // Duplicate additions leave membership unchanged, including its awake |
| | | 611 | | // bit. Mixed refresh remains responsible for synchronizing that bit. |
| | 924648 | 612 | | if (kind == PhysicsMobilityType.Dynamic) |
| | 782469 | 613 | | partition.SetDynamic3DObjectAwake(collider.Id, collider.Body!.IsAwakeForCollision); |
| | 924648 | 614 | | } |
| | | 615 | | |
| | | 616 | | private void TryPartition2DMixedVoxel( |
| | | 617 | | LSCollider2D collider, |
| | | 618 | | SwiftList<WorldVoxelIndex> coordinates, |
| | | 619 | | Voxel voxel, |
| | | 620 | | PhysicsMobilityType kind) |
| | | 621 | | { |
| | 937157 | 622 | | if (!_nextCoveredCoordinates.Contains(voxel.WorldIndex)) |
| | 562611 | 623 | | return; |
| | | 624 | | |
| | 374546 | 625 | | PhysicsMixedPartition partition = GetOrCreatePartition(voxel); |
| | 374546 | 626 | | coordinates.Add(voxel.WorldIndex); |
| | 374546 | 627 | | Add2DObject(partition, collider.Id, kind); |
| | 374546 | 628 | | if (kind == PhysicsMobilityType.Dynamic) |
| | 96272 | 629 | | partition.SetDynamic2DObjectAwake(collider.Id, collider.Body!.IsAwakeForCollision); |
| | 374546 | 630 | | } |
| | | 631 | | |
| | | 632 | | private PhysicsMixedPartition GetOrCreatePartition(Voxel voxel) |
| | | 633 | | { |
| | 1299194 | 634 | | if (voxel.TryGetPartition(out PhysicsMixedPartition? partition)) |
| | 864289 | 635 | | return partition!; |
| | | 636 | | |
| | 434905 | 637 | | partition = RentPartition(); |
| | 434905 | 638 | | ChronicleGuard.ThrowIfTrue( |
| | 434905 | 639 | | !voxel.TryAddPartition(partition), |
| | 434905 | 640 | | nameof(GravitasMixedCollisionService), |
| | 434905 | 641 | | "Unable to attach mixed physics partition to voxel."); |
| | | 642 | | |
| | 434905 | 643 | | TrackRetainedPartition(partition); |
| | 434905 | 644 | | return partition; |
| | | 645 | | } |
| | | 646 | | |
| | | 647 | | private void Get3DCoverageBounds(LSCollider collider, out Vector3d coverageMin, out Vector3d coverageMax) |
| | | 648 | | { |
| | 31128 | 649 | | coverageMin = collider.BoundsMin; |
| | 31128 | 650 | | coverageMax = collider.BoundsMax; |
| | 31128 | 651 | | } |
| | | 652 | | |
| | | 653 | | private void Get2DMixedCoverageBounds(LSCollider2D collider, out Vector3d coverageMin, out Vector3d coverageMax) |
| | | 654 | | { |
| | 35759 | 655 | | FixedBoundBox bounds = collider.MixedBounds3D; |
| | 35759 | 656 | | coverageMin = bounds.Min; |
| | 35759 | 657 | | coverageMax = bounds.Max; |
| | 35759 | 658 | | } |
| | | 659 | | |
| | | 660 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 661 | | private static PhysicsMobilityType Get3DMobilityKind(LSCollider collider) |
| | | 662 | | { |
| | 51732 | 663 | | if (collider.IsStatic) |
| | 10038 | 664 | | return PhysicsMobilityType.Static; |
| | | 665 | | |
| | 41694 | 666 | | SolidBody? body = collider.Body; |
| | 41694 | 667 | | return body!.IsKinematic ? PhysicsMobilityType.Kinematic : PhysicsMobilityType.Dynamic; |
| | | 668 | | } |
| | | 669 | | |
| | | 670 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 671 | | private static PhysicsMobilityType Get2DMobilityKind(LSCollider2D collider) |
| | | 672 | | { |
| | 44449 | 673 | | if (collider.IsStatic) |
| | 28415 | 674 | | return PhysicsMobilityType.Static; |
| | | 675 | | |
| | 16034 | 676 | | SolidBody2D? body = collider.Body; |
| | 16034 | 677 | | return body!.IsKinematic ? PhysicsMobilityType.Kinematic : PhysicsMobilityType.Dynamic; |
| | | 678 | | } |
| | | 679 | | |
| | | 680 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 681 | | private static PhysicsMobilityType GetStoredMobilityKind(int partitionKind) |
| | | 682 | | { |
| | 29485 | 683 | | return partitionKind == (int)PhysicsMobilityType.Kinematic |
| | 29485 | 684 | | ? PhysicsMobilityType.Kinematic |
| | 29485 | 685 | | : partitionKind == (int)PhysicsMobilityType.Static |
| | 29485 | 686 | | ? PhysicsMobilityType.Static |
| | 29485 | 687 | | : PhysicsMobilityType.Dynamic; |
| | | 688 | | } |
| | | 689 | | |
| | | 690 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 691 | | private static void Add3DObject(PhysicsMixedPartition partition, int id, PhysicsMobilityType kind) |
| | | 692 | | { |
| | 924648 | 693 | | if (kind == PhysicsMobilityType.Static) |
| | | 694 | | { |
| | 126338 | 695 | | partition.AddStatic3DObject(id); |
| | 126338 | 696 | | return; |
| | | 697 | | } |
| | | 698 | | |
| | 798310 | 699 | | if (kind == PhysicsMobilityType.Kinematic) |
| | | 700 | | { |
| | 15841 | 701 | | partition.AddKinematic3DObject(id); |
| | 15841 | 702 | | return; |
| | | 703 | | } |
| | | 704 | | |
| | 782469 | 705 | | partition.AddDynamic3DObject(id); |
| | 782469 | 706 | | } |
| | | 707 | | |
| | | 708 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 709 | | private static void Add2DObject(PhysicsMixedPartition partition, int id, PhysicsMobilityType kind) |
| | | 710 | | { |
| | 374546 | 711 | | if (kind == PhysicsMobilityType.Static) |
| | | 712 | | { |
| | 273396 | 713 | | partition.AddStatic2DObject(id); |
| | 273396 | 714 | | return; |
| | | 715 | | } |
| | | 716 | | |
| | 101150 | 717 | | if (kind == PhysicsMobilityType.Kinematic) |
| | | 718 | | { |
| | 4878 | 719 | | partition.AddKinematic2DObject(id); |
| | 4878 | 720 | | return; |
| | | 721 | | } |
| | | 722 | | |
| | 96272 | 723 | | partition.AddDynamic2DObject(id); |
| | 96272 | 724 | | } |
| | | 725 | | |
| | | 726 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 727 | | private static void Remove3DObject(PhysicsMixedPartition partition, int id, PhysicsMobilityType kind) |
| | | 728 | | { |
| | 37556 | 729 | | if (kind == PhysicsMobilityType.Static) |
| | | 730 | | { |
| | 8956 | 731 | | partition.RemoveStatic3DObject(id); |
| | 8956 | 732 | | return; |
| | | 733 | | } |
| | | 734 | | |
| | 28600 | 735 | | if (kind == PhysicsMobilityType.Kinematic) |
| | | 736 | | { |
| | 5992 | 737 | | partition.RemoveKinematic3DObject(id); |
| | 5992 | 738 | | return; |
| | | 739 | | } |
| | | 740 | | |
| | 22608 | 741 | | partition.RemoveDynamic3DObject(id); |
| | 22608 | 742 | | } |
| | | 743 | | |
| | | 744 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 745 | | private static void Remove2DObject(PhysicsMixedPartition partition, int id, PhysicsMobilityType kind) |
| | | 746 | | { |
| | 10621 | 747 | | if (kind == PhysicsMobilityType.Static) |
| | | 748 | | { |
| | 4461 | 749 | | partition.RemoveStatic2DObject(id); |
| | 4461 | 750 | | return; |
| | | 751 | | } |
| | | 752 | | |
| | 6160 | 753 | | if (kind == PhysicsMobilityType.Kinematic) |
| | | 754 | | { |
| | 1629 | 755 | | partition.RemoveKinematic2DObject(id); |
| | 1629 | 756 | | return; |
| | | 757 | | } |
| | | 758 | | |
| | 4531 | 759 | | partition.RemoveDynamic2DObject(id); |
| | 4531 | 760 | | } |
| | | 761 | | |
| | | 762 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 763 | | private static bool MixedBoundsOverlap(LSCollider collider3D, LSCollider2D collider2D) |
| | | 764 | | { |
| | 318098 | 765 | | return collider3D.Bounds.Intersects(collider2D.MixedBounds3D); |
| | | 766 | | } |
| | | 767 | | |
| | | 768 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 769 | | private static bool Is2DQueryCandidate(LSCollider2D collider, FixedBoundBox queryBounds, PhysicsLayerMask layerMask) |
| | | 770 | | { |
| | 21103 | 771 | | if (!layerMask.Includes(collider.Layer)) |
| | 3 | 772 | | return false; |
| | | 773 | | |
| | 21100 | 774 | | return collider.MixedBounds3D.Intersects(queryBounds); |
| | | 775 | | } |
| | | 776 | | |
| | | 777 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 778 | | private static bool Is3DQueryCandidate(LSCollider collider, FixedBoundBox queryBounds, PhysicsLayerMask layerMask) |
| | | 779 | | { |
| | 2089 | 780 | | return collider.IsActive |
| | 2089 | 781 | | && layerMask.Includes(collider.Layer) |
| | 2089 | 782 | | && collider.Bounds.Intersects(queryBounds); |
| | | 783 | | } |
| | | 784 | | |
| | 113 | 785 | | private void DetachRetainedPartitions() => RetainedPartitionLifecycle.DetachAll( |
| | 113 | 786 | | _retainedPartitions, |
| | 113 | 787 | | _emptyRetainedPartitions, |
| | 113 | 788 | | _context.World, |
| | 113 | 789 | | this, |
| | 113 | 790 | | _releaseRetainedPartition, |
| | 113 | 791 | | nameof(PhysicsMixedPartition), |
| | 113 | 792 | | "Unable to detach retained mixed physics partition from its voxel during reset."); |
| | | 793 | | |
| | 434906 | 794 | | private void TrackRetainedPartition(PhysicsMixedPartition partition) => RetainedPartitionLifecycle.Track( |
| | 434906 | 795 | | _retainedPartitions, |
| | 434906 | 796 | | _emptyRetainedPartitions, |
| | 434906 | 797 | | this, |
| | 434906 | 798 | | partition, |
| | 434906 | 799 | | nameof(PhysicsMixedPartition)); |
| | | 800 | | |
| | 434915 | 801 | | private void UntrackRetainedPartition(PhysicsMixedPartition partition) => RetainedPartitionLifecycle.Untrack( |
| | 434915 | 802 | | _retainedPartitions, |
| | 434915 | 803 | | _emptyRetainedPartitions, |
| | 434915 | 804 | | this, |
| | 434915 | 805 | | partition, |
| | 434915 | 806 | | ref _retainedPartitionRetirementCursor); |
| | | 807 | | |
| | 546727 | 808 | | internal void RefreshRetainedPartitionEligibility(PhysicsMixedPartition partition) => RetainedPartitionLifecycle.Ref |
| | 546727 | 809 | | _emptyRetainedPartitions, this, partition); |
| | | 810 | | |
| | 15999 | 811 | | private void RetireExpiredRetainedPartitions() => RetainedPartitionLifecycle.RetireExpired( |
| | 15999 | 812 | | _retainedPartitions, |
| | 15999 | 813 | | _context.World, |
| | 15999 | 814 | | this, |
| | 15999 | 815 | | _context.Settings.RetainedPartitionRetirementSweepBudget, |
| | 15999 | 816 | | _context.FrameCount, |
| | 15999 | 817 | | _context.Settings.RetainedPartitionTimeToKillFrames, |
| | 15999 | 818 | | _releaseRetainedPartition, |
| | 15999 | 819 | | ref _retainedPartitionRetirementCursor); |
| | | 820 | | |
| | 434875 | 821 | | private bool TryRetireEmptyRetainedPartitionForReuse() => RetainedPartitionLifecycle.TryRetireEmptyForReuse( |
| | 434875 | 822 | | _emptyRetainedPartitions, |
| | 434875 | 823 | | _inactivePartitionPool, |
| | 434875 | 824 | | _context.World, |
| | 434875 | 825 | | this, |
| | 434875 | 826 | | _releaseRetainedPartition); |
| | | 827 | | |
| | | 828 | | } |