Skip to content

Commit

Permalink
Prevent inactive-inactive collision reports (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
notgiven688 authored Sep 12, 2024
1 parent 1c2aca9 commit 923e48c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Jitter2/Collision/PairHashSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public PairHashSet()
private void Resize(int size)
{
if (Slots.Length == size) return;
Trace.WriteLine($"RESIZING PAIRHASHSET, {Slots.Length} -> {size}");
Trace.WriteLine($"PairHashSet: Resizing {Slots.Length} -> {size}");

var tmp = Slots;
Count = 0;
Expand Down
7 changes: 7 additions & 0 deletions src/Jitter2/SoftBodies/BroadPhaseCollisionFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public bool Filter(IDynamicTreeProxy proxyA, IDynamicTreeProxy proxyB)
(i1, i2) = (i2, i1);
}

if (!i1.SoftBody.IsActive && !i2.SoftBody.IsActive) return false;

bool colliding = NarrowPhase.MPREPA(i1, i2,
JQuaternion.Identity, JVector.Zero,
out JVector pA, out JVector pB, out JVector normal, out float penetration);
Expand All @@ -66,6 +68,9 @@ public bool Filter(IDynamicTreeProxy proxyA, IDynamicTreeProxy proxyB)
if (i1 != null)
{
var rb = (proxyB as RigidBodyShape)!.RigidBody!;

if (!i1.SoftBody.IsActive && !rb.Data.IsActive) return false;

bool colliding = NarrowPhase.MPREPA(i1, (proxyB as RigidBodyShape)!, rb.Orientation, rb.Position,
out JVector pA, out JVector pB, out JVector normal, out float penetration);

Expand All @@ -83,6 +88,8 @@ public bool Filter(IDynamicTreeProxy proxyA, IDynamicTreeProxy proxyB)
{
var ra = (proxyA as RigidBodyShape)!.RigidBody!;

if (!i2.SoftBody.IsActive && !ra.Data.IsActive) return false;

bool colliding = NarrowPhase.MPREPA(i2, (proxyA as RigidBodyShape)!, ra.Orientation, ra.Position,
out JVector pA, out JVector pB, out JVector normal, out float penetration);

Expand Down

0 comments on commit 923e48c

Please sign in to comment.