Skip to content

Commit

Permalink
Add JBox.FullyContains
Browse files Browse the repository at this point in the history
  • Loading branch information
notgiven688 committed Dec 18, 2024
1 parent 85be7dd commit f9f5453
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Jitter2/Collision/DynamicTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,7 @@ private void ScanForMovedProxies(Parallel.Batch batch)

ref var node = ref Nodes[proxy.NodePtr];

if (node.ForceUpdate || node.ExpandedBox.Contains(proxy.WorldBoundingBox) !=
JBBox.ContainmentType.Contains)
if (node.ForceUpdate || !node.ExpandedBox.FullyContains(proxy.WorldBoundingBox))
{
node.ForceUpdate = false;
list.Add(proxy);
Expand Down Expand Up @@ -811,7 +810,7 @@ private void InsertLeaf(int node, int where)

while (where != root)
{
if (Nodes[where].ExpandedBox.Contains(nodeBox) == JBBox.ContainmentType.Contains)
if (Nodes[where].ExpandedBox.FullyContains(nodeBox))
{
break;
}
Expand Down
7 changes: 7 additions & 0 deletions src/Jitter2/LinearMath/JBBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ public readonly bool Disjoint(in JBBox box)
Max.Z >= box.Min.Z && Min.Z <= box.Max.Z);
}

public readonly bool FullyContains(in JBBox box)
{
return Min.X <= box.Min.X && Max.X >= box.Max.X &&
Min.Y <= box.Min.Y && Max.Y >= box.Max.Y &&
Min.Z <= box.Min.Z && Max.Z >= box.Max.Z;
}

public static JBBox CreateMerged(in JBBox original, in JBBox additional)
{
CreateMerged(original, additional, out JBBox result);
Expand Down

0 comments on commit f9f5453

Please sign in to comment.