Bounding box, silly issues help please!

Discuss programming topics for any language, any source base. If it is programming related but doesn't fit in one of the below categories, it goes here.
Post Reply
boxrick
Posts: 5
Joined: Tue Jan 20, 2009 12:15 pm

Bounding box, silly issues help please!

Post by boxrick »

I have a game world, with all entities being contained by a bounding box. This is working fine, i am in the process of updating my collision code. However im having issues with deciding if objects are colliding am i doing this right? If not where am i going wrong?

I have object A and object B with x y and z max and minimums of them all.

1) (if object A min X >Object B max X OR object B min X >Object A max X)
X axis is colliding

(if object A min Y>Object B max Y OR object B min Y >Object A max Y)
Y axis is colliding

(if object A min Z >Object B max Z OR object B min Z >Object A max Z )
Z axis is colliding

if X / Y and Z axis are colliding then i have a collision
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

don't you mean:
if (a.min_x <= b.max_x && a.max_x >= b.min_x &&
a.min_y <= b.max_y && a.max_y >= b.min_y &&
a.min_x <= b.max_z && a.max_z >= b.min_z)
collide();
Post Reply