Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
gggmork

bounding circles [s]boxes[/s]

Recommended Posts

Since monsters in doom are infinitely tall cubes with a main attack of trying to trip you with their corners, couldn't the 'bounding boxes' be 'bounding circles' (infinitely tall columns) instead? Squares would seem easier to implement in code if they were always aligned the same way, but doom squares rotate, so might as well make them circles? You don't even have to rotate a circle if you want to check collisions or whatever?

Share this post


Link to post
gggmork said:

Since monsters in doom are infinitely tall cubes with a main attack of trying to trip you with their corners, couldn't the 'bounding boxes' be 'bounding circles' (infinitely tall columns) instead? Squares would seem easier to implement in code if they were always aligned the same way, but doom squares rotate, so might as well make them circles? You don't even have to rotate a circle if you want to check collisions or whatever?

An infinitely tall cube would also be infinitely wide. :p

And no, they don't rotate. The angle changes, but the bounding box remains always the same. In ZDoom, if you type am_cheat 3 in the console, you'll see each actor's bounding box on the automap, surrounding the little triangle. You'll see how the triangle rotates around freely, but the box itself does not.

Doom does collision checks like this because it's simpler. Just a question of comparing the mobjs' X and Y values, with a simple addition/subtraction of their "radius". Using cylinders would require trigonometry and it would be more complicated and more CPU-intensive. Of course, today's computers would barely notice it. But anyway, it would change gameplay a lot and wouldn't be a clear bugfix or logic improvement, so it's no wonder nobody ever felt the need to change this.

Share this post


Link to post

Wow, I can't believe I never noticed that. Maybe that means that if you do an entire level facing diagonally NE or something, you can land more ssg shots (since a square's diagonal is longer than its sides).

'An infinitely tall cube would also be infinitely wide. :p'
I tried closing my eyes, sticking my tongue out to the side in concentration and clenching my fists, but I couldn't understand why.

edit:
here's a demo of pretty typical bounding box annoyance in hell revealed 13:
http://www.speedyshare.com/files/23791321/hr-13-ggg-boundingboxlol.lmp

Share this post


Link to post

gggmork said:
'An infinitely tall cube would also be infinitely wide. :p'
I tried closing my eyes, sticking my tongue out to the side in concentration and clenching my fists, but I couldn't understand why.


You wrote cube instead of cuboid.

Share this post


Link to post
gggmork said:

'An infinitely tall cube would also be infinitely wide. :p'
I tried closing my eyes, sticking my tongue out to the side in concentration and clenching my fists, but I couldn't understand why.

For a second I couldn't either, but it comes down to what the word "cube" means (e.g. like "square" means same width as height).

I think I'd prefer having physics done with cylinders, it would feel more natural to slide around monsters instead of being completely blocked even at a corner.

Share this post


Link to post

That makes sense. Maybe it doesn't have to be a perfect circle requiring trig (oh man, I fail trig.. a 'rotation matrix' works by magic).
It could be a blocky circle like:

0 0 1 1 1 1 0 0
0 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
0 1 1 1 1 1 1 0
0 0 1 1 1 1 0 0

Or maybe that might snag you even more since there's more corners. Or maybe just keep it a square but somehow make the code say, 'if player hits a corner, allow player to slip by easier instead of getting blocked'. Or maybe simply keep all 'shootable' boxes the same size, but shrink all 'walk into' boxes. But the doom source is way over my head and like usual I don't really know what I'm writing about.

Share this post


Link to post

Wouldn't actually be simpler.

The way Doom does it, it simply compares both mobjs' X and Y positions.

To do cylinders, perfect or not, you'd need to also compute the angle between the grid and a line connecting both mobjs, and once you have that it'd be silly to use a table of approximate values rather than a call to the trig functions to estimate the distance properly.

Share this post


Link to post
gggmork said:

Wow, I can't believe I never noticed that. Maybe that means that if you do an entire level facing diagonally NE or something, you can land more ssg shots (since a square's diagonal is longer than its sides).

It would also mean that you'd need to make all areas in the map about 40 % bigger to account for things hitting walls more easily.

Cylinder-shaped hit boxes would make all hitscan attacks less accurate (most noticeable at long ranges with weapons like SSG and BFG tracers) and it might make melee combat more awkward. With the current hit boxes you simply "clash" on the monster when tysoning/chainsawing and staying by it is easy. That might become more difficult with cylinder-shaped boxes, since you'd be sliding off the monsters.

Share this post


Link to post

Good points. Maybe a cylinder could be for 'bumping into' only, with a separate normal box for hitscan attacks so stuff still hits at the same rate.

Maybe you could just use multiple rectangles simulating a circle instead of a circle. Like these 3 rects together should be the same as that blocky circle above.
0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 0

0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

But yeah, more complicated. And its not like I'm planning to build this; just thinking hypothetically.

Share this post


Link to post

It would be easy enough to use squares for the hitscans/melee, and cylinders for the movement physics.

Share this post


Link to post

Hmm, if that was the case, you'd be able to actually move your center of mass inside the hitscan bounding box (at the corners, namely) of larger monsters, which would result in the fun effect of having any attacks instantly hit the monster even if you try and fire away from it.

Share this post


Link to post

Also the bigger possible problem with melee would be how the cylinder-shaped physical hit box would affect "gliding" along monsters (for example, when meleeing PEs you want to stick right to their face for maximum safety, rather than staying few pixels away). Even if the hit-hit box was square-shaped, you'd still be gliding off the monster, solving nothing at all.

Share this post


Link to post

I've known about the square bounding boxes for ages, but they're more obvious to me than ever now that I've been recording some speedruns. They definitely shouldn't be made circular or pseudo-circular - when speedrunning it's crucial to be able to predictably slide past and against monsters, and changing the shape of bounding boxes would change these close-up interactions between things to such a degree that speedrunning would feel like running an entirely different game. I guess most casual players without an up-close-and-personal play style wouldn't notice the change, but, if every player would either dislike the change or not notice it, why bother?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×