| | | 1 | | //======================================================================= |
| | | 2 | | // ContactManifold.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.Collections; |
| | | 9 | | using System.Collections.Generic; |
| | | 10 | | using System.Runtime.CompilerServices; |
| | | 11 | | using FixedMathSharp; |
| | | 12 | | using Gravitas.Materials; |
| | | 13 | | |
| | | 14 | | namespace Gravitas.CollisionHandling; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Pair-owned deterministic contact manifold with up to four samples per |
| | | 18 | | /// geometric surface group and no fixed pair-wide group or contact limit. |
| | | 19 | | /// </summary> |
| | | 20 | | /// <remarks> |
| | | 21 | | /// Inspection flattens canonical structural group order, then ascending contact |
| | | 22 | | /// identity within each group. Index zero is not necessarily the deepest contact; |
| | | 23 | | /// use <see cref="PrimaryContact"/> for that purpose. Overflow capacity is retained |
| | | 24 | | /// across updates and resets; reaching a new high-water mark can allocate. |
| | | 25 | | /// </remarks> |
| | | 26 | | public sealed partial class ContactManifold : IEnumerable<ManifoldContact> |
| | | 27 | | { |
| | | 28 | | /// <summary>Maximum number of point samples retained per geometric surface group.</summary> |
| | | 29 | | public const int MaxContactsPerGroup = 4; |
| | | 30 | | |
| | | 31 | | private ContactGroup _firstGroup; |
| | | 32 | | private SwiftCollections.SwiftList<ContactGroup>? _additionalGroups; |
| | | 33 | | private int _count; |
| | 73686 | 34 | | private long _lastUpdatedFrame = -1; |
| | | 35 | | |
| | | 36 | | /// <summary>Number of independent surface regions currently retained; this has no fixed pair-wide cap.</summary> |
| | | 37 | | public int GroupCount { get; private set; } |
| | | 38 | | |
| | | 39 | | /// <summary>Gets the first flattened point index of a group in canonical structural order.</summary> |
| | | 40 | | public int GetGroupStartIndex(int groupIndex) |
| | | 41 | | { |
| | 54 | 42 | | ChronicleGuard.ThrowIfListIndexInvalid(groupIndex, GroupCount); |
| | 52 | 43 | | int start = 0; |
| | 554 | 44 | | for (int i = 0; i < groupIndex; i++) |
| | 225 | 45 | | start += GetGroup(i).Count; |
| | 52 | 46 | | return start; |
| | | 47 | | } |
| | | 48 | | |
| | | 49 | | /// <summary>Gets the number of retained samples in a group, from one through <see cref="MaxContactsPerGroup"/>.</su |
| | | 50 | | public int GetGroupContactCount(int groupIndex) |
| | | 51 | | { |
| | 85 | 52 | | ChronicleGuard.ThrowIfListIndexInvalid(groupIndex, GroupCount); |
| | 83 | 53 | | return GetGroup(groupIndex).Count; |
| | | 54 | | } |
| | | 55 | | |
| | | 56 | | internal ref ContactGroup GetGroup(int index) |
| | | 57 | | { |
| | 6847602 | 58 | | if (index == 0) return ref _firstGroup; |
| | 703184 | 59 | | return ref _additionalGroups!.InnerArray[index - 1]; |
| | | 60 | | } |
| | | 61 | | |
| | | 62 | | internal int FindGroup(in ContactGroupKey key) |
| | | 63 | | { |
| | 158776 | 64 | | int low = 0, high = GroupCount - 1; |
| | 96022 | 65 | | while (low <= high) |
| | | 66 | | { |
| | 94709 | 67 | | int middle = low + ((high - low) >> 1); |
| | 94709 | 68 | | int order = GetGroup(middle).Key.CompareTo(key); |
| | 172784 | 69 | | if (order == 0) return middle; |
| | 29941 | 70 | | if (order < 0) low = middle + 1; |
| | 3327 | 71 | | else high = middle - 1; |
| | | 72 | | } |
| | 1313 | 73 | | return -1; |
| | | 74 | | } |
| | | 75 | | |
| | | 76 | | internal void ReserveGroups(int capacity) |
| | | 77 | | { |
| | 137054 | 78 | | ChronicleGuard.ThrowIfNegative(capacity, nameof(capacity)); |
| | 252653 | 79 | | if (capacity <= 1) return; |
| | 21451 | 80 | | _additionalGroups ??= new SwiftCollections.SwiftList<ContactGroup>(capacity - 1); |
| | 21451 | 81 | | _additionalGroups.EnsureCapacity(capacity - 1); |
| | 21451 | 82 | | } |
| | | 83 | | |
| | | 84 | | /// <summary> |
| | | 85 | | /// Total number of active samples across all groups, without a fixed pair-wide cap. |
| | | 86 | | /// </summary> |
| | | 87 | | public int Count |
| | | 88 | | { |
| | | 89 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 208820 | 90 | | get => _count; |
| | | 91 | | } |
| | | 92 | | |
| | | 93 | | /// <summary> |
| | | 94 | | /// Gets whether this manifold currently contains narrow-phase contact data. |
| | | 95 | | /// </summary> |
| | | 96 | | public bool HasContact |
| | | 97 | | { |
| | | 98 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 453518 | 99 | | get => _count > 0; |
| | | 100 | | } |
| | | 101 | | |
| | | 102 | | /// <summary> |
| | | 103 | | /// Simulation frame in which the active contacts were last rebuilt. |
| | | 104 | | /// </summary> |
| | | 105 | | public long LastUpdatedFrame |
| | | 106 | | { |
| | | 107 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 1688 | 108 | | get => _lastUpdatedFrame; |
| | | 109 | | } |
| | | 110 | | |
| | | 111 | | /// <summary> |
| | | 112 | | /// Deepest contact in the manifold. Ties use the lowest contact identity. |
| | | 113 | | /// </summary> |
| | | 114 | | public ManifoldContact PrimaryContact |
| | | 115 | | { |
| | | 116 | | get |
| | | 117 | | { |
| | 26826 | 118 | | ChronicleGuard.ThrowIfListIndexInvalid(0, _count); |
| | | 119 | | |
| | 26826 | 120 | | ManifoldContact best = _firstGroup[0]; |
| | 162164 | 121 | | foreach (ManifoldContact candidate in this) |
| | | 122 | | { |
| | 54256 | 123 | | if (candidate.Depth > best.Depth |
| | 54256 | 124 | | || candidate.Depth == best.Depth && candidate.ContactId < best.ContactId) |
| | | 125 | | { |
| | 984 | 126 | | best = candidate; |
| | | 127 | | } |
| | | 128 | | } |
| | | 129 | | |
| | 26826 | 130 | | return best; |
| | | 131 | | } |
| | | 132 | | } |
| | | 133 | | |
| | | 134 | | /// <summary>Gets a contact in flattened structural-group/ascending-contact-identity order.</summary> |
| | | 135 | | public ManifoldContact this[int index] |
| | | 136 | | { |
| | | 137 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 138 | | get |
| | | 139 | | { |
| | 1767 | 140 | | ChronicleGuard.ThrowIfListIndexInvalid(index, _count); |
| | 7162 | 141 | | for (int group = 0; ; group++) |
| | | 142 | | { |
| | 7162 | 143 | | ref ContactGroup current = ref GetGroup(group); |
| | 8927 | 144 | | if (index < current.Count) return current[index]; |
| | 5397 | 145 | | index -= current.Count; |
| | | 146 | | } |
| | | 147 | | } |
| | | 148 | | } |
| | | 149 | | |
| | | 150 | | /// <summary> |
| | | 151 | | /// Clears contacts and records the frame for a new narrow-phase pass. |
| | | 152 | | /// </summary> |
| | | 153 | | public void BeginUpdate(long frame) |
| | | 154 | | { |
| | 138212 | 155 | | ClearContacts(); |
| | 138212 | 156 | | _lastUpdatedFrame = frame; |
| | 138212 | 157 | | } |
| | | 158 | | |
| | | 159 | | /// <summary> |
| | | 160 | | /// Clears all contact data. |
| | | 161 | | /// </summary> |
| | | 162 | | public void Reset() |
| | | 163 | | { |
| | 44520 | 164 | | ClearContacts(); |
| | 44520 | 165 | | _lastUpdatedFrame = -1; |
| | 44520 | 166 | | } |
| | | 167 | | |
| | | 168 | | /// <summary> |
| | | 169 | | /// Replaces the manifold with one contact. |
| | | 170 | | /// </summary> |
| | | 171 | | public void SetContact(Vector3d pointA, Vector3d pointB, Fixed64 depth, Vector3d normal) |
| | | 172 | | { |
| | 145 | 173 | | ClearContacts(); |
| | 145 | 174 | | AddContact(pointA, pointB, depth, normal); |
| | 145 | 175 | | } |
| | | 176 | | |
| | | 177 | | /// <summary> |
| | | 178 | | /// Replaces the manifold with one rigid-frame contact. |
| | | 179 | | /// </summary> |
| | | 180 | | public void SetContact( |
| | | 181 | | ContactAnchor anchorA, |
| | | 182 | | ContactAnchor anchorB, |
| | | 183 | | Fixed64 depth, |
| | | 184 | | Vector3d normal, |
| | | 185 | | bool depthIsClamped = false) |
| | | 186 | | { |
| | 12303 | 187 | | ClearContacts(); |
| | 12303 | 188 | | AddContact(anchorA, anchorB, depth, normal, depthIsClamped); |
| | 12303 | 189 | | } |
| | | 190 | | |
| | | 191 | | /// <summary> |
| | | 192 | | /// Adds a contact, keeping up to four samples in the default surface group and exposing them by stable contact iden |
| | | 193 | | /// </summary> |
| | | 194 | | public void AddContact(Vector3d pointA, Vector3d pointB, Fixed64 depth, Vector3d normal) |
| | | 195 | | { |
| | 5774 | 196 | | AddContact( |
| | 5774 | 197 | | ContactAnchor.FromWorldPoint(pointA), |
| | 5774 | 198 | | ContactAnchor.FromWorldPoint(pointB), |
| | 5774 | 199 | | depth, |
| | 5774 | 200 | | normal); |
| | 5774 | 201 | | } |
| | | 202 | | |
| | | 203 | | /// <summary> |
| | | 204 | | /// Adds a rigid-frame contact, keeping up to four samples in the default surface group and |
| | | 205 | | /// exposing them by stable anchor identity. |
| | | 206 | | /// </summary> |
| | | 207 | | public void AddContact( |
| | | 208 | | ContactAnchor anchorA, |
| | | 209 | | ContactAnchor anchorB, |
| | | 210 | | Fixed64 depth, |
| | | 211 | | Vector3d normal, |
| | | 212 | | bool depthIsClamped = false) |
| | | 213 | | { |
| | 41685 | 214 | | AddContactCore( |
| | 41685 | 215 | | anchorA, |
| | 41685 | 216 | | anchorB, |
| | 41685 | 217 | | depth, |
| | 41685 | 218 | | normal, |
| | 41685 | 219 | | hasMaterialOverride: false, |
| | 41685 | 220 | | default, |
| | 41685 | 221 | | default, |
| | 41685 | 222 | | depthIsClamped, |
| | 41685 | 223 | | featureNamespaceA: 0, |
| | 41685 | 224 | | featureNamespaceB: 0); |
| | 41685 | 225 | | } |
| | | 226 | | |
| | | 227 | | internal void AddContact( |
| | | 228 | | Vector3d pointA, |
| | | 229 | | Vector3d pointB, |
| | | 230 | | Fixed64 depth, |
| | | 231 | | Vector3d normal, |
| | | 232 | | PhysicsMaterial materialA, |
| | | 233 | | PhysicsMaterial materialB, |
| | | 234 | | bool depthIsClamped = false) |
| | | 235 | | { |
| | 1 | 236 | | AddContactCore( |
| | 1 | 237 | | ContactAnchor.FromWorldPoint(pointA), |
| | 1 | 238 | | ContactAnchor.FromWorldPoint(pointB), |
| | 1 | 239 | | depth, |
| | 1 | 240 | | normal, |
| | 1 | 241 | | hasMaterialOverride: true, |
| | 1 | 242 | | materialA, |
| | 1 | 243 | | materialB, |
| | 1 | 244 | | depthIsClamped, |
| | 1 | 245 | | featureNamespaceA: 0, |
| | 1 | 246 | | featureNamespaceB: 0); |
| | 1 | 247 | | } |
| | | 248 | | |
| | | 249 | | internal void AddContact( |
| | | 250 | | ContactAnchor anchorA, |
| | | 251 | | ContactAnchor anchorB, |
| | | 252 | | Fixed64 depth, |
| | | 253 | | Vector3d normal, |
| | | 254 | | PhysicsMaterial materialA, |
| | | 255 | | PhysicsMaterial materialB, |
| | | 256 | | bool depthIsClamped = false, |
| | | 257 | | int featureNamespaceA = 0, |
| | | 258 | | int featureNamespaceB = 0, |
| | | 259 | | ContactGroupKey group = default, |
| | | 260 | | int sampleIdentity = 0, |
| | | 261 | | ulong? contactIdentity = null) |
| | | 262 | | { |
| | 173516 | 263 | | AddContactCore( |
| | 173516 | 264 | | anchorA, |
| | 173516 | 265 | | anchorB, |
| | 173516 | 266 | | depth, |
| | 173516 | 267 | | normal, |
| | 173516 | 268 | | hasMaterialOverride: true, |
| | 173516 | 269 | | materialA, |
| | 173516 | 270 | | materialB, |
| | 173516 | 271 | | depthIsClamped, |
| | 173516 | 272 | | featureNamespaceA, |
| | 173516 | 273 | | featureNamespaceB, |
| | 173516 | 274 | | group, sampleIdentity, contactIdentity); |
| | 173516 | 275 | | } |
| | | 276 | | |
| | | 277 | | private void AddContactCore( |
| | | 278 | | ContactAnchor anchorA, |
| | | 279 | | ContactAnchor anchorB, |
| | | 280 | | Fixed64 depth, |
| | | 281 | | Vector3d normal, |
| | | 282 | | bool hasMaterialOverride, |
| | | 283 | | PhysicsMaterial materialA, |
| | | 284 | | PhysicsMaterial materialB, |
| | | 285 | | bool depthIsClamped, |
| | | 286 | | int featureNamespaceA, |
| | | 287 | | int featureNamespaceB, |
| | | 288 | | ContactGroupKey group = default, |
| | | 289 | | int sampleIdentity = 0, |
| | | 290 | | ulong? contactIdentity = null) |
| | | 291 | | { |
| | 215202 | 292 | | ulong contactId = contactIdentity ?? CreateContactId( |
| | 215202 | 293 | | anchorA, |
| | 215202 | 294 | | featureNamespaceA, |
| | 215202 | 295 | | anchorB, |
| | 215202 | 296 | | featureNamespaceB); |
| | | 297 | | // A continuous normal family can share paired anchors at zero depth. |
| | | 298 | | // Keep its reduced directions as distinct rows inside one feature group. |
| | 216148 | 299 | | if (sampleIdentity != 0) Mix(ref contactId, sampleIdentity); |
| | 215202 | 300 | | var contact = new ManifoldContact( |
| | 215202 | 301 | | contactId, |
| | 215202 | 302 | | anchorA, |
| | 215202 | 303 | | anchorB, |
| | 215202 | 304 | | depth, |
| | 215202 | 305 | | normal, |
| | 215202 | 306 | | hasMaterialOverride, |
| | 215202 | 307 | | materialA, |
| | 215202 | 308 | | materialB, |
| | 215202 | 309 | | depthIsClamped, |
| | 215202 | 310 | | featureNamespaceA, |
| | 215202 | 311 | | featureNamespaceB); |
| | | 312 | | |
| | 215202 | 313 | | AddContact(group.Remap(featureNamespaceA, featureNamespaceB, reverse: false), contact); |
| | 215202 | 314 | | } |
| | | 315 | | |
| | | 316 | | internal void AddContact(in ContactGroupKey key, in ManifoldContact contact) |
| | | 317 | | { |
| | 257823 | 318 | | int group = 0; |
| | 322443 | 319 | | while (group < GroupCount && GetGroup(group).Key.CompareTo(key) < 0) |
| | 64620 | 320 | | group++; |
| | 257823 | 321 | | if (group == GroupCount || GetGroup(group).Key.CompareTo(key) != 0) |
| | | 322 | | { |
| | 113741 | 323 | | ReserveGroups(GroupCount + 1); |
| | 113741 | 324 | | if (GroupCount > 0) |
| | | 325 | | { |
| | 20450 | 326 | | _additionalGroups!.Add(default); |
| | 108256 | 327 | | for (int i = GroupCount; i > group; i--) |
| | 33678 | 328 | | GetGroup(i) = GetGroup(i - 1); |
| | | 329 | | } |
| | 113741 | 330 | | GetGroup(group) = new ContactGroup { Key = key }; |
| | 113741 | 331 | | GroupCount++; |
| | | 332 | | } |
| | 257823 | 333 | | _count += GetGroup(group).Add(contact); |
| | 257823 | 334 | | } |
| | | 335 | | |
| | | 336 | | internal void CopyFrom(ContactManifold source, long frame) |
| | | 337 | | { |
| | 17606 | 338 | | if (ReferenceEquals(this, source)) return; |
| | 17596 | 339 | | BeginUpdate(frame); |
| | 17596 | 340 | | ReserveGroups(source.GroupCount); |
| | 69404 | 341 | | for (int i = 0; i < source.GroupCount; i++) |
| | | 342 | | { |
| | 33181 | 343 | | if (i == 0) _firstGroup = source.GetGroup(i); |
| | 1031 | 344 | | else _additionalGroups!.Add(source.GetGroup(i)); |
| | | 345 | | } |
| | 17596 | 346 | | GroupCount = source.GroupCount; |
| | 17596 | 347 | | _count = source._count; |
| | 17596 | 348 | | } |
| | | 349 | | |
| | | 350 | | internal bool HasSameContacts(ContactManifold source) |
| | | 351 | | { |
| | 51 | 352 | | if (GroupCount != source.GroupCount) return false; |
| | 106 | 353 | | for (int group = 0; group < GroupCount; group++) |
| | | 354 | | { |
| | 45 | 355 | | ref ContactGroup previous = ref GetGroup(group); |
| | 45 | 356 | | ref ContactGroup incoming = ref source.GetGroup(group); |
| | 52 | 357 | | if (previous.Key.CompareTo(incoming.Key) != 0 || previous.Count != incoming.Count) return false; |
| | 96 | 358 | | for (int index = 0; index < previous.Count; index++) |
| | 70 | 359 | | if (!SameConstraint(previous[index], incoming[index])) return false; |
| | | 360 | | } |
| | 8 | 361 | | return true; |
| | | 362 | | } |
| | | 363 | | |
| | | 364 | | private static bool SameConstraint(in ManifoldContact previous, in ManifoldContact incoming) => |
| | 40 | 365 | | previous.ContactId == incoming.ContactId && previous.FeatureNamespaceA == incoming.FeatureNamespaceA |
| | 40 | 366 | | && previous.FeatureNamespaceB == incoming.FeatureNamespaceB && previous.Normal == incoming.Normal |
| | 40 | 367 | | && previous.Depth == incoming.Depth && previous.DepthIsClamped == incoming.DepthIsClamped |
| | 40 | 368 | | && previous.HasMaterialOverride == incoming.HasMaterialOverride |
| | 40 | 369 | | && previous.MaterialA == incoming.MaterialA && previous.MaterialB == incoming.MaterialB |
| | 40 | 370 | | && SamePoint(previous.AnchorA, incoming.AnchorA) && SamePoint(previous.AnchorB, incoming.AnchorB); |
| | | 371 | | |
| | | 372 | | private static bool SamePoint(in ContactAnchor previous, in ContactAnchor incoming) |
| | | 373 | | { |
| | 38 | 374 | | ExactLever3D delta = previous.GetLeverFrom(incoming); |
| | 38 | 375 | | return delta.XNumerator.IsZero && delta.YNumerator.IsZero && delta.ZNumerator.IsZero; |
| | | 376 | | } |
| | | 377 | | |
| | | 378 | | internal bool ReferencesSuppliers(SwiftCollections.SwiftHashSet<int> suppliers, bool first, int fallbackSource) |
| | | 379 | | { |
| | 450 | 380 | | for (int group = 0; group < GroupCount; group++) |
| | | 381 | | { |
| | 127 | 382 | | ContactGroupKey key = GetGroup(group).Key; |
| | 127 | 383 | | int source = first ? key.SourceIdA : key.SourceIdB; |
| | 241 | 384 | | if (suppliers.Contains(source == 0 ? fallbackSource : source)) return true; |
| | | 385 | | } |
| | 98 | 386 | | return false; |
| | | 387 | | } |
| | | 388 | | |
| | | 389 | | private void ClearContacts() |
| | | 390 | | { |
| | 195180 | 391 | | _count = GroupCount = 0; |
| | 195180 | 392 | | _firstGroup = default; |
| | 195180 | 393 | | _additionalGroups?.FastClear(); |
| | 35383 | 394 | | } |
| | | 395 | | |
| | | 396 | | /// <summary>Returns an allocation-free enumerator over the active contacts.</summary> |
| | 46476 | 397 | | public Enumerator GetEnumerator() => new(this); |
| | | 398 | | |
| | 328 | 399 | | IEnumerator<ManifoldContact> IEnumerable<ManifoldContact>.GetEnumerator() => GetEnumerator(); |
| | 100 | 400 | | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); |
| | | 401 | | |
| | | 402 | | internal static ulong RemapContactIdentity(ulong contactId, int namespaceA, int namespaceB) |
| | | 403 | | { |
| | | 404 | | // Group provenance carries the ordered owners. Identity remains |
| | | 405 | | // invariant when compound dispatch reverses the paired anchors. |
| | 25730 | 406 | | Mix(ref contactId, System.Math.Min(namespaceA, namespaceB)); |
| | 25730 | 407 | | Mix(ref contactId, System.Math.Max(namespaceA, namespaceB)); |
| | 25730 | 408 | | return contactId; |
| | | 409 | | } |
| | | 410 | | |
| | | 411 | | internal static ulong CreateContactId( |
| | | 412 | | ContactAnchor anchorA, |
| | | 413 | | int featureNamespaceA, |
| | | 414 | | ContactAnchor anchorB, |
| | | 415 | | int featureNamespaceB) |
| | | 416 | | { |
| | 200228 | 417 | | if (CompareLocalFeature( |
| | 200228 | 418 | | featureNamespaceB, |
| | 200228 | 419 | | anchorB, |
| | 200228 | 420 | | featureNamespaceA, |
| | 200228 | 421 | | anchorA) < 0) |
| | | 422 | | { |
| | 93165 | 423 | | (anchorA, anchorB) = (anchorB, anchorA); |
| | 93165 | 424 | | (featureNamespaceA, featureNamespaceB) = |
| | 93165 | 425 | | (featureNamespaceB, featureNamespaceA); |
| | | 426 | | } |
| | | 427 | | |
| | 200228 | 428 | | ulong hash = 14695981039346656037UL; |
| | 200228 | 429 | | Mix(ref hash, featureNamespaceA); |
| | 200228 | 430 | | MixLocalFeature(ref hash, anchorA); |
| | 200228 | 431 | | Mix(ref hash, featureNamespaceB); |
| | 200228 | 432 | | MixLocalFeature(ref hash, anchorB); |
| | 200228 | 433 | | return hash; |
| | | 434 | | } |
| | | 435 | | |
| | | 436 | | private static int CompareLocalFeature( |
| | | 437 | | int leftNamespace, |
| | | 438 | | ContactAnchor left, |
| | | 439 | | int rightNamespace, |
| | | 440 | | ContactAnchor right) |
| | | 441 | | { |
| | 200228 | 442 | | int comparison = leftNamespace.CompareTo(rightNamespace); |
| | 200228 | 443 | | return comparison != 0 |
| | 200228 | 444 | | ? comparison |
| | 200228 | 445 | | : left.CompareLocalFeature(right); |
| | | 446 | | } |
| | | 447 | | |
| | | 448 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 449 | | private static void Mix(ref ulong hash, long value) |
| | | 450 | | { |
| | | 451 | | unchecked |
| | | 452 | | { |
| | 853318 | 453 | | hash ^= (ulong)value; |
| | 853318 | 454 | | hash *= 1099511628211UL; |
| | | 455 | | } |
| | 853318 | 456 | | } |
| | | 457 | | |
| | | 458 | | private static void MixLocalFeature( |
| | | 459 | | ref ulong hash, |
| | | 460 | | ContactAnchor anchor) |
| | | 461 | | { |
| | 400456 | 462 | | Mix( |
| | 400456 | 463 | | ref hash, |
| | 400456 | 464 | | unchecked((long)anchor.GetLocalFeatureHash64())); |
| | 400456 | 465 | | } |
| | | 466 | | |
| | | 467 | | |
| | | 468 | | } |