3D AABB Not working on top left collision C#

324 Views Asked by At

I have a number of axis-aligned bounding boxes (AABB) that I need to check for collision. If the bounds are on the right hand side the collision detection is flawless as shown below:

Normal collision

However, if I come in from the "Left side" the collision fails until it hits a much larger object:

Should collide

This should be a collision but it fails every time. Below is the code I am using for detection.

var Collides =
    (box1.Minimum.X <= box2.Maximum.X && box1.Maximum.X >= box2.Minimum.X) &&
    (box1.Minimum.Y <= box2.Maximum.Y && box1.Maximum.Y >= box2.Minimum.Y) &&
    (box1.Minimum.Z <= box2.Maximum.Z && box1.Maximum.Z >= box2.Minimum.Z);
if(Collides)
    Console.WriteLine(Collides+" - "+DateTime.Now);

I'm not sure where I am going wrong with the code. Any help would be awesome!

Also I am using Helix-Toolkit with SharpDX as the engine for the models. I have tried SharpDX.Collision.boxintersectbox and that has the same issue.

0

There are 0 best solutions below