| | | 1 | | //======================================================================= |
| | | 2 | | // CollisionPairMixed.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; |
| | | 9 | | using System.Runtime.CompilerServices; |
| | | 10 | | using FixedMathSharp; |
| | | 11 | | using Gravitas.Colliders; |
| | | 12 | | using SwiftCollections; |
| | | 13 | | |
| | | 14 | | namespace Gravitas.CollisionHandling; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Owns one stable mixed 3D/2D collision pair identity and contact lifecycle. |
| | | 18 | | /// </summary> |
| | | 19 | | /// <content>Owns retained mixed manifold rows, per-step impulses, notifications and replay state.</content> |
| | | 20 | | internal sealed partial class CollisionPairMixed |
| | | 21 | | { |
| | | 22 | | private bool _isColliding; |
| | | 23 | | private bool _isTriggerPair; |
| | | 24 | | private bool _notificationInProgress; |
| | | 25 | | private bool _separationPending; |
| | | 26 | | private bool _collider3DNotified; |
| | | 27 | | private bool _collider2DNotified; |
| | | 28 | | private long _lifetimeVersion; |
| | | 29 | | private uint _lastCollider3DContactDependencyVersion; |
| | | 30 | | private uint _lastCollider2DContactDependencyVersion; |
| | | 31 | | private bool _hasManifoldCache; |
| | | 32 | | private uint _manifold3DBroadPhaseVersion, _manifold2DBroadPhaseVersion; |
| | | 33 | | private uint _manifold3DContactDependencyVersion, _manifold2DContactDependencyVersion; |
| | | 34 | | private Vector2d _manifold2DCenter; |
| | | 35 | | private Fixed64 _manifold2DRotation; |
| | | 36 | | private bool _watchSpatialLayerRow, _watchPlanarLayerColumn; |
| | | 37 | | private ulong _manifoldCollisionLayers; |
| | | 38 | | |
| | 810 | 39 | | public CollisionPairMixed(LSCollider collider3D, LSCollider2D collider2D) |
| | | 40 | | { |
| | 810 | 41 | | Collider3D = collider3D; |
| | 810 | 42 | | Collider2D = collider2D; |
| | 810 | 43 | | Initialize(collider3D, collider2D); |
| | 810 | 44 | | } |
| | | 45 | | |
| | | 46 | | public LSCollider Collider3D { get; private set; } |
| | | 47 | | |
| | | 48 | | public LSCollider2D Collider2D { get; private set; } |
| | | 49 | | |
| | | 50 | | public int Collider3DId { get; private set; } |
| | | 51 | | |
| | | 52 | | public int Collider2DId { get; private set; } |
| | | 53 | | |
| | | 54 | | public ulong Key { get; private set; } |
| | | 55 | | |
| | 80137 | 56 | | public GravitasWorldContext Context => Collider3D.Context; |
| | | 57 | | |
| | | 58 | | public long LastFrame { get; private set; } = -1; |
| | | 59 | | |
| | | 60 | | // Collision-pass freshness is independent of hosts advancing the public frame clock. |
| | | 61 | | internal long LastVisitToken { get; private set; } = -1; |
| | | 62 | | |
| | | 63 | | public MixedContact Contact { get; private set; } |
| | | 64 | | |
| | | 65 | | public ContactManifold Manifold { get; } = new(); |
| | | 66 | | |
| | | 67 | | // Accumulation belongs to one solve pass; mixed pairs do not warm-start across frames. |
| | | 68 | | internal ContactWarmStartCache SolveImpulses; |
| | | 69 | | |
| | | 70 | | internal ExactContactImpulseState?[]? ExactSolveImpulses; |
| | | 71 | | |
| | | 72 | | internal ContactResponseSnapshot ResponseSnapshot { get; set; } |
| | | 73 | | |
| | 64642 | 74 | | internal long LifetimeVersion => _lifetimeVersion; |
| | | 75 | | |
| | 183 | 76 | | internal bool IsNotificationInProgress => _notificationInProgress; |
| | | 77 | | |
| | | 78 | | public void Initialize(LSCollider collider3D, LSCollider2D collider2D) |
| | | 79 | | { |
| | 821 | 80 | | ChronicleGuard.ThrowIfNull(collider3D, nameof(collider3D)); |
| | 821 | 81 | | ChronicleGuard.ThrowIfNull(collider2D, nameof(collider2D)); |
| | | 82 | | |
| | 821 | 83 | | _lifetimeVersion++; |
| | 821 | 84 | | Collider3D = collider3D; |
| | 821 | 85 | | Collider2D = collider2D; |
| | 821 | 86 | | Collider3DId = collider3D.Id; |
| | 821 | 87 | | Collider2DId = collider2D.Id; |
| | 821 | 88 | | Key = MixedColliderKey.CreateKey(Collider3DId, Collider2DId); |
| | 821 | 89 | | LastFrame = -1; |
| | 821 | 90 | | LastVisitToken = -1; |
| | 821 | 91 | | _isColliding = false; |
| | 821 | 92 | | _hasManifoldCache = false; |
| | 821 | 93 | | _watchSpatialLayerRow = _watchPlanarLayerColumn = false; |
| | 821 | 94 | | _manifoldCollisionLayers = 0; |
| | 821 | 95 | | _lastCollider3DContactDependencyVersion = 0; |
| | 821 | 96 | | _lastCollider2DContactDependencyVersion = 0; |
| | 821 | 97 | | _isTriggerPair = collider3D.IsTrigger || collider2D.IsTrigger; |
| | 821 | 98 | | _notificationInProgress = false; |
| | 821 | 99 | | _separationPending = false; |
| | 821 | 100 | | _collider3DNotified = false; |
| | 821 | 101 | | _collider2DNotified = false; |
| | 821 | 102 | | Contact = default; |
| | 821 | 103 | | Manifold.Reset(); |
| | 821 | 104 | | ClearSolveState(); |
| | 821 | 105 | | } |
| | | 106 | | |
| | | 107 | | public void MarkColliding(long frame, MixedContact contact) |
| | | 108 | | { |
| | 12 | 109 | | PublishContact(frame, contact); |
| | 12 | 110 | | NotifyCollision(frame); |
| | 10 | 111 | | } |
| | | 112 | | |
| | | 113 | | public void MarkColliding(long frame, ContactManifold manifold) |
| | | 114 | | { |
| | 16090 | 115 | | PublishManifold(frame, manifold); |
| | 16090 | 116 | | NotifyCollision(frame); |
| | 16090 | 117 | | } |
| | | 118 | | |
| | | 119 | | private void NotifyCollision(long frame) |
| | | 120 | | { |
| | 16102 | 121 | | bool changed = !_isColliding; |
| | 16102 | 122 | | _isColliding = true; |
| | 16102 | 123 | | _isTriggerPair = Collider3D.IsTrigger || Collider2D.IsTrigger; |
| | 16102 | 124 | | LastFrame = frame; |
| | 16102 | 125 | | LastVisitToken = Context.LateSimulateToken; |
| | | 126 | | |
| | 16102 | 127 | | Context.Diagnostics.EmitMixedContact(this, Contact); |
| | | 128 | | |
| | 16102 | 129 | | var registration3D = new ColliderLifetimeToken(Collider3D); |
| | 16102 | 130 | | var registration2D = new ColliderLifetimeToken2D(Collider2D); |
| | 16102 | 131 | | bool shouldRaiseTrigger = ColliderTriggerEventPolicy.ShouldRaise(Collider3D, Collider2D); |
| | 16102 | 132 | | _notificationInProgress = true; |
| | 16102 | 133 | | SwiftList<Exception>? notificationExceptions = null; |
| | | 134 | | try |
| | | 135 | | { |
| | 16102 | 136 | | bool notifyEnter3D = changed || !_collider3DNotified; |
| | 16102 | 137 | | _collider3DNotified = true; |
| | 16102 | 138 | | Collider3D.NotifyMixedContact( |
| | 16102 | 139 | | Collider2D, |
| | 16102 | 140 | | true, |
| | 16102 | 141 | | notifyEnter3D, |
| | 16102 | 142 | | _isTriggerPair, |
| | 16102 | 143 | | allowInactive: false, |
| | 16102 | 144 | | registration3D, |
| | 16102 | 145 | | registration2D, |
| | 16102 | 146 | | shouldRaiseTrigger); |
| | 16101 | 147 | | if (_isColliding && registration3D.IsActive && registration2D.IsActive && !_separationPending) |
| | | 148 | | { |
| | 16090 | 149 | | bool notifyEnter2D = changed || !_collider2DNotified; |
| | 16090 | 150 | | _collider2DNotified = true; |
| | 16090 | 151 | | Collider2D.NotifyMixedContact( |
| | 16090 | 152 | | Collider3D, |
| | 16090 | 153 | | true, |
| | 16090 | 154 | | notifyEnter2D, |
| | 16090 | 155 | | _isTriggerPair, |
| | 16090 | 156 | | allowInactive: false, |
| | 16090 | 157 | | registration2D, |
| | 16090 | 158 | | registration3D, |
| | 16090 | 159 | | shouldRaiseTrigger); |
| | | 160 | | } |
| | 16101 | 161 | | } |
| | 1 | 162 | | catch (Exception exception) |
| | | 163 | | { |
| | 1 | 164 | | CollisionNotificationExceptions.Capture(ref notificationExceptions, exception); |
| | 1 | 165 | | } |
| | | 166 | | |
| | | 167 | | try |
| | | 168 | | { |
| | 16102 | 169 | | EndNotification( |
| | 16102 | 170 | | registration3D, |
| | 16102 | 171 | | registration2D, |
| | 16102 | 172 | | shouldRaiseTrigger); |
| | 16101 | 173 | | } |
| | 1 | 174 | | catch (Exception exception) |
| | | 175 | | { |
| | 1 | 176 | | CollisionNotificationExceptions.Capture(ref notificationExceptions, exception); |
| | 1 | 177 | | } |
| | | 178 | | |
| | 16102 | 179 | | CollisionNotificationExceptions.ThrowIfAny(notificationExceptions); |
| | 16100 | 180 | | } |
| | | 181 | | |
| | | 182 | | public void MarkResting(long frame) |
| | | 183 | | { |
| | 2 | 184 | | _hasManifoldCache = false; |
| | 2 | 185 | | RefreshContactDependencies(); |
| | 2 | 186 | | LastFrame = frame; |
| | 2 | 187 | | LastVisitToken = Context.LateSimulateToken; |
| | 2 | 188 | | ClearSolveState(); |
| | 2 | 189 | | } |
| | | 190 | | |
| | | 191 | | public void MarkResting(long frame, ContactManifold manifold) |
| | | 192 | | { |
| | 154 | 193 | | PublishManifold(frame, manifold); |
| | 153 | 194 | | LastFrame = frame; |
| | 153 | 195 | | LastVisitToken = Context.LateSimulateToken; |
| | 153 | 196 | | } |
| | | 197 | | |
| | | 198 | | private void PublishContact(long frame, MixedContact contact) |
| | | 199 | | { |
| | 12 | 200 | | _hasManifoldCache = false; |
| | 12 | 201 | | RefreshContactDependencies(incomingPlanar: contact.HasContact && contact.Normal3DTo2D.ToVector2d() != Vector2d.Z |
| | 12 | 202 | | Manifold.BeginUpdate(frame); |
| | 12 | 203 | | if (contact.HasContact) |
| | 10 | 204 | | Manifold.AddContact(default, contact.ToManifoldContact()); |
| | 12 | 205 | | Contact = contact; |
| | 12 | 206 | | ClearSolveState(); |
| | 12 | 207 | | } |
| | | 208 | | |
| | | 209 | | private void PublishManifold(long frame, ContactManifold source) |
| | | 210 | | { |
| | 16244 | 211 | | ChronicleGuard.ThrowIfNull(source, nameof(source)); |
| | 16243 | 212 | | bool solid = !Collider3D.IsTrigger && !Collider2D.IsTrigger; |
| | 16243 | 213 | | bool watchRow = solid && Collider2D.StaticSurface != null; |
| | 16243 | 214 | | bool watchColumn = solid && Collider3D is LSMeshCollider { StaticSurface: not null }; |
| | 16243 | 215 | | ulong layers = watchRow || watchColumn |
| | 16243 | 216 | | ? Context.Settings.GetCollisionLayerMask(Collider3D.Layer, Collider2D.Layer, watchRow, watchColumn) : 0; |
| | | 217 | | // An edited but locally unused matrix bit must not wake an unchanged |
| | | 218 | | // sleeper. Compare the rebuilt physical rows before publishing them. |
| | 16243 | 219 | | if (_isColliding && _hasManifoldCache && layers != _manifoldCollisionLayers && !Manifold.HasSameContacts(source) |
| | 2 | 220 | | WakeBodiesForContactChange(source); |
| | 16243 | 221 | | _hasManifoldCache = false; |
| | 16243 | 222 | | RefreshContactDependencies(source); |
| | 16243 | 223 | | Manifold.CopyFrom(source, frame); |
| | 16243 | 224 | | Contact = Manifold.HasContact ? MixedContact.FromManifoldContact(Manifold.PrimaryContact) : default; |
| | 16243 | 225 | | _manifold3DBroadPhaseVersion = Collider3D.BroadPhaseVersion; |
| | 16243 | 226 | | _manifold2DBroadPhaseVersion = Collider2D.BroadPhaseVersion; |
| | 16243 | 227 | | _manifold3DContactDependencyVersion = Collider3D.ContactDependencyVersion; |
| | 16243 | 228 | | _manifold2DContactDependencyVersion = Collider2D.ContactDependencyVersion; |
| | 16243 | 229 | | _manifold2DCenter = Collider2D.Center; |
| | 16243 | 230 | | _manifold2DRotation = Collider2D.Rotation; |
| | 32486 | 231 | | _watchSpatialLayerRow = watchRow; _watchPlanarLayerColumn = watchColumn; |
| | 16243 | 232 | | _manifoldCollisionLayers = layers; |
| | 16243 | 233 | | _hasManifoldCache = true; |
| | 16243 | 234 | | ClearSolveState(); |
| | 16243 | 235 | | } |
| | | 236 | | |
| | | 237 | | // Dynamic 2D pose can change without a partition or contact-dependency revision. |
| | 31782 | 238 | | internal bool HasCurrentManifoldCache => _isColliding && _hasManifoldCache |
| | 31782 | 239 | | && _manifold3DBroadPhaseVersion == Collider3D.BroadPhaseVersion |
| | 31782 | 240 | | && _manifold2DBroadPhaseVersion == Collider2D.BroadPhaseVersion |
| | 31782 | 241 | | && _manifold3DContactDependencyVersion == Collider3D.ContactDependencyVersion |
| | 31782 | 242 | | && _manifold2DContactDependencyVersion == Collider2D.ContactDependencyVersion |
| | 31782 | 243 | | && _manifold2DCenter == Collider2D.Center |
| | 31782 | 244 | | && _manifold2DRotation == Collider2D.Rotation |
| | 31782 | 245 | | && (!_watchSpatialLayerRow && !_watchPlanarLayerColumn || _manifoldCollisionLayers == |
| | 31782 | 246 | | Context.Settings.GetCollisionLayerMask(Collider3D.Layer, Collider2D.Layer, |
| | 31782 | 247 | | _watchSpatialLayerRow, _watchPlanarLayerColumn)); |
| | | 248 | | |
| | | 249 | | internal bool TryCopyCachedManifold(long frame, ContactManifold target) |
| | | 250 | | { |
| | 30474 | 251 | | if (!HasCurrentManifoldCache) return false; |
| | 748 | 252 | | target.CopyFrom(Manifold, frame); |
| | 748 | 253 | | return true; |
| | | 254 | | } |
| | | 255 | | |
| | | 256 | | internal void InvalidateSurfaceContact(bool wake) |
| | | 257 | | { |
| | 462 | 258 | | _hasManifoldCache = false; |
| | 462 | 259 | | ClearSolveState(); |
| | 692 | 260 | | if (wake && _isColliding && !_isTriggerPair) WakeBodiesForContactChange(); |
| | 462 | 261 | | } |
| | | 262 | | |
| | | 263 | | private void ClearSolveState() |
| | | 264 | | { |
| | 17728 | 265 | | SolveImpulses.Clear(); |
| | 17728 | 266 | | if (ExactSolveImpulses != null) |
| | 45 | 267 | | foreach (ExactContactImpulseState? state in ExactSolveImpulses) state?.Clear(); |
| | 17728 | 268 | | ResponseSnapshot = default; |
| | 17728 | 269 | | } |
| | | 270 | | public void MarkSeparated() |
| | | 271 | | { |
| | 188 | 272 | | _hasManifoldCache = false; |
| | 188 | 273 | | if (_isColliding && !_isTriggerPair) |
| | 168 | 274 | | WakeBodiesForContactChange(); |
| | 188 | 275 | | Manifold.Reset(); |
| | 188 | 276 | | ClearSolveState(); |
| | 188 | 277 | | Contact = default; |
| | | 278 | | // The 2D side is admitted only after the 3D side, so it cannot be the sole notified side. |
| | 188 | 279 | | if (!_isColliding && !_collider3DNotified) |
| | 2 | 280 | | return; |
| | | 281 | | |
| | 186 | 282 | | _isColliding = false; |
| | 186 | 283 | | if (_notificationInProgress) |
| | | 284 | | { |
| | 16 | 285 | | _separationPending = true; |
| | 16 | 286 | | return; |
| | | 287 | | } |
| | | 288 | | |
| | 170 | 289 | | var registration3D = new ColliderLifetimeToken(Collider3D); |
| | 170 | 290 | | var registration2D = new ColliderLifetimeToken2D(Collider2D); |
| | 170 | 291 | | _notificationInProgress = true; |
| | | 292 | | try |
| | | 293 | | { |
| | 170 | 294 | | NotifySeparation( |
| | 170 | 295 | | registration3D, |
| | 170 | 296 | | registration2D, |
| | 170 | 297 | | ColliderTriggerEventPolicy.ShouldRaise(Collider3D, Collider2D)); |
| | 169 | 298 | | } |
| | | 299 | | finally |
| | | 300 | | { |
| | 170 | 301 | | _separationPending = false; |
| | 170 | 302 | | _notificationInProgress = false; |
| | 170 | 303 | | } |
| | 169 | 304 | | } |
| | | 305 | | |
| | | 306 | | private void EndNotification( |
| | | 307 | | in ColliderLifetimeToken registration3D, |
| | | 308 | | in ColliderLifetimeToken2D registration2D, |
| | | 309 | | bool shouldRaiseTrigger) |
| | | 310 | | { |
| | | 311 | | try |
| | | 312 | | { |
| | 16102 | 313 | | if (!_separationPending) |
| | 16086 | 314 | | return; |
| | | 315 | | |
| | 16 | 316 | | _separationPending = false; |
| | 16 | 317 | | NotifySeparation(registration3D, registration2D, shouldRaiseTrigger); |
| | 15 | 318 | | } |
| | | 319 | | finally |
| | | 320 | | { |
| | 16102 | 321 | | _separationPending = false; |
| | 16102 | 322 | | _notificationInProgress = false; |
| | 16102 | 323 | | } |
| | 16101 | 324 | | } |
| | | 325 | | |
| | | 326 | | private void NotifySeparation( |
| | | 327 | | in ColliderLifetimeToken registration3D, |
| | | 328 | | in ColliderLifetimeToken2D registration2D, |
| | | 329 | | bool shouldRaiseTrigger) |
| | | 330 | | { |
| | 186 | 331 | | bool notify2D = _collider2DNotified; |
| | 186 | 332 | | _collider3DNotified = false; |
| | 186 | 333 | | _collider2DNotified = false; |
| | 186 | 334 | | SwiftList<Exception>? notificationExceptions = null; |
| | | 335 | | try |
| | | 336 | | { |
| | 186 | 337 | | Collider3D.NotifyMixedContact( |
| | 186 | 338 | | Collider2D, |
| | 186 | 339 | | false, |
| | 186 | 340 | | true, |
| | 186 | 341 | | _isTriggerPair, |
| | 186 | 342 | | allowInactive: true, |
| | 186 | 343 | | registration3D, |
| | 186 | 344 | | registration2D, |
| | 186 | 345 | | shouldRaiseTrigger); |
| | 184 | 346 | | } |
| | 2 | 347 | | catch (Exception exception) |
| | | 348 | | { |
| | 2 | 349 | | CollisionNotificationExceptions.Capture(ref notificationExceptions, exception); |
| | 2 | 350 | | } |
| | | 351 | | |
| | 186 | 352 | | if (notify2D && registration2D.IsCurrentLifetime) |
| | | 353 | | { |
| | | 354 | | try |
| | | 355 | | { |
| | 173 | 356 | | Collider2D.NotifyMixedContact( |
| | 173 | 357 | | Collider3D, |
| | 173 | 358 | | false, |
| | 173 | 359 | | true, |
| | 173 | 360 | | _isTriggerPair, |
| | 173 | 361 | | allowInactive: true, |
| | 173 | 362 | | registration2D, |
| | 173 | 363 | | registration3D, |
| | 173 | 364 | | shouldRaiseTrigger); |
| | 172 | 365 | | } |
| | 1 | 366 | | catch (Exception exception) |
| | | 367 | | { |
| | 1 | 368 | | CollisionNotificationExceptions.Capture(ref notificationExceptions, exception); |
| | 1 | 369 | | } |
| | | 370 | | } |
| | | 371 | | |
| | 186 | 372 | | CollisionNotificationExceptions.ThrowIfAny(notificationExceptions); |
| | 184 | 373 | | } |
| | | 374 | | |
| | | 375 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 376 | | private void RefreshContactDependencies(ContactManifold? incoming = null, bool incomingPlanar = false) |
| | | 377 | | { |
| | 16257 | 378 | | uint version3D = Collider3D.ContactDependencyVersion; |
| | 16257 | 379 | | uint version2D = Collider2D.ContactDependencyVersion; |
| | 16257 | 380 | | bool triggerPair = Collider3D.IsTrigger || Collider2D.IsTrigger; |
| | | 381 | | // Replacing a planar constraint with a vertical one still invalidates |
| | | 382 | | // its former 2D dependency. Purely vertical rows never couple 2D wake. |
| | 16257 | 383 | | if (_isColliding) |
| | | 384 | | { |
| | 15550 | 385 | | if (triggerPair != _isTriggerPair) WakeBodiesForContactChange(incoming, incomingPlanar); |
| | 15542 | 386 | | else if (!triggerPair) |
| | | 387 | | { |
| | 16015 | 388 | | if (version2D != _lastCollider2DContactDependencyVersion) Collider3D.Body?.WakeForContactChange(); |
| | 15468 | 389 | | if (version3D != _lastCollider3DContactDependencyVersion) |
| | 1292 | 390 | | Wake2DBodyForContactChange(incoming, incomingPlanar); |
| | | 391 | | } |
| | | 392 | | } |
| | | 393 | | |
| | 16257 | 394 | | _lastCollider3DContactDependencyVersion = version3D; |
| | 16257 | 395 | | _lastCollider2DContactDependencyVersion = version2D; |
| | 16257 | 396 | | _isTriggerPair = triggerPair; |
| | 16257 | 397 | | } |
| | | 398 | | |
| | | 399 | | private void WakeBodiesForContactChange(ContactManifold? incoming = null, bool incomingPlanar = false) |
| | | 400 | | { |
| | 404 | 401 | | Collider3D.Body?.WakeForContactChange(); |
| | 404 | 402 | | Wake2DBodyForContactChange(incoming, incomingPlanar); |
| | 404 | 403 | | } |
| | | 404 | | |
| | | 405 | | private void Wake2DBodyForContactChange(ContactManifold? incoming, bool incomingPlanar) |
| | | 406 | | { |
| | 1696 | 407 | | SolidBody2D? body = Collider2D.Body; |
| | 1696 | 408 | | if (body?.IsSleeping != true) |
| | 1675 | 409 | | return; |
| | | 410 | | |
| | 21 | 411 | | if (incomingPlanar || CollisionResponseMixed.HasPlanarResponseCoupling(Manifold) |
| | 21 | 412 | | || (incoming != null && CollisionResponseMixed.HasPlanarResponseCoupling(incoming))) |
| | 12 | 413 | | body.WakeForContactChange(); |
| | 21 | 414 | | } |
| | | 415 | | |
| | | 416 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 417 | | internal void WakeSleepingBodiesForCollision() |
| | | 418 | | { |
| | 10397 | 419 | | SolidBody? body3D = Collider3D.Body; |
| | 10397 | 420 | | SolidBody2D? body2D = Collider2D.Body; |
| | 10397 | 421 | | if (body3D == null || body2D == null) |
| | 10265 | 422 | | return; |
| | | 423 | | |
| | 132 | 424 | | bool body3DAwake = body3D.IsAwakeForCollision; |
| | 132 | 425 | | bool body2DAwake = body2D.IsAwakeForCollision; |
| | 132 | 426 | | if (body3D.IsSleeping && body2DAwake) |
| | 1 | 427 | | body3D.Wake(); |
| | 132 | 428 | | if (body2D.IsSleeping && body3DAwake) |
| | 3 | 429 | | body2D.Wake(); |
| | 132 | 430 | | } |
| | | 431 | | } |