bounding boxes pt 2

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 boxes pt 2

Post by boxrick »

http://forums.inside3d.com/viewtopic.php?t=1470

In reference to the above thread.

So once i have these colliding, i now wish to use an orientated bounding box as opposed to just the axis alined....

Everything i find on the internet seems to go into extremely complicated details instead of just actually explaining the basics...

So i have my bounding boxes in world space... each with 8 x y and z positions... i need to calculate when one corner goes through an edge or an edge goes through an edge..

Not quite as simple as just using the max and min values.... do i do this using something like using the 12 edges of the box ( equation of a line ) and checking if they intersect ... or am i going down totally the wrong route here?
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

If it is just a bounding box, why bother to rotate it anyway?
If its not really a box, but rather an shape around a model, why not use a sphere type shape instead?

In quake (1/2/3) bounding boxes do not rotate. Ever.
Rotating bsp objects rotate by rotating the start and end points of traces into their orientation. This means that as the rotating bsp object rotates, the bounding boxes that light intersect it rotate too. But only for collisions with that bsp object.

Anyway, my point is that as an abstract concept to facilitate optimisations, bounding boxes do not need to rotate. The only rotation of a bounding box that really makes sense is one where the bbox was expanded to encompass the entire rotated object, but still not actually at an angle itself.

Unless you really are dealing with only cuboids, use bounding spheres for mosters, but honestly don't bother rotating bounding boxes - except for expanding the bbox to encompass the full rotation.
Urre
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon
Contact:

Post by Urre »

Spike: a very useful reason to add support for rotated bboxes would be physics. I wouldn't mind making Twig use those instead of particles. It'd obviously need to be made as separate builtins, for calling aligned box shape tracing (possibly even a rotating sweep, wohoo), and not replace the current bbox operations.
I was once a Quake modder
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

What's the difference between that and 'simply' tracing against meshes?
Imho the definition of a bounding box is a box specifying the maximum bounds of an object. In this context there is no need for it to rotate, only to expand with rotation (in quake the bbox is specified by the absmin/absmax vales).
If you want to blur stuff a bit, then a collision box is the box with which things will collide. Imho in Quake, this would actually be best represented with a cylinder. Which would not need to rotate, and would not need to push things out of the way in order to rotate. But yes, quake uses a non-rotating box, because a BSP tree is built from the other object's mins/maxs.

Triggers trigger when their bounding box is touched - because the bounding box is larger than the model actually is, allowing items to be grabbed off shelves (triggers have special touch code or they would never be touched). Nothing else uses the bounding box as anything but an optimisation, in quake. I think most games out there follow this behaviour.
By rotating the collision box, you are stating that the object is a box, and if its not, then you're just wasting cpu cycles.
And if it really is a box, why are you not using full mesh-based collisions instead?
If all you wanted was to stop the corners of collision boxes from getting in the way constantly, then use cylinders or spheres.[/i]
Urre
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon
Contact:

Post by Urre »

Well I don't know what boxrick was ultimately after, but I can imagine implementing aligned box collisions is easier than sweeping mesh collisions, and certainly faster. You can also cull the rotated box with a regular non-rotated bounding box, ofcourse.
I was once a Quake modder
Post Reply