Collision Hulls

  • If you're asking a question make sure to set the thread type to be a question!

FOREVER

L1: Registered
Feb 14, 2011
41
1
I read somewhere that TF2's collision hulls are A. boxes and B. of fixed orientation (i.e., independent of player direction).

If this is true, than I wonder why this decision was made. The collision hull determines whether splash damage affects the player. The corners of a box are 2^.5 times longer than the shortest path from center to edge, and the player can't determine the location of the corners of this box, meaning the splash damage effect of projectiles within a certain range (from 1 - 1*2^.5 times the length of the collision hull) is entirely unpredictable. A cylinder with constant radius would avoid this issue entirely.

A collision hull with 90 degree corners also makes it easy for players to get stuck on sharp edges and ridges in the map, a problem that I'd call severe for most tf2 maps. Cases in point: the back stairs of badwater, final cap have a tiny raised edge that traps anyone moving against the wall; the final cap room in well has a raised lip on the floor outside spawn that stops players. There are innumerable other examples. Again, pretty much any regular prism besides a box would sidestep this issue.

So a few questions: Am I totally wrong about the shape of the collision hull? I really hope I am. Is it possible to draw collision hulls with a console command? Is it possible to change the collision hulls? Are there some computational reasons why a cylindrical hull (or even better, a pill-shaped ellipsoid hull) wouldn't work?
 

A Boojum Snark

Toraipoddodezain Mazahabado
aa
Nov 2, 2007
4,775
7,669
Collision hulls are indeed fixed boxes, but I'm pretty sure they are just used for world collision. Hit detection is handled by the various hitboxes attached to the skeleton.
 

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
I read somewhere that TF2's collision hulls are A. boxes and B. of fixed orientation (i.e., independent of player direction).

As far as I know this is quite true. Player-models have AABBs, or Axis-Aligned Bounding Boxes. (The command I used to show them has since been disabled, sorry.)

The corners of a box are 2^.5 times longer than the shortest path from center to edge [...] A cylinder with constant radius would avoid this issue entirely.

It's much easier to do collision testing with an AABB than a cylinder, especially when you consider how two people might try pushing past each other.

In addition, the extra "diagonal distance" probably does not mean much when you consider it in comparison to the size of the blast-radius of an explosion...

I would not be surprised if the extra diagonal distance doesn't really matter for explosions: Valve might use the AABB only to determine whether someone "got hit" (as opposed to being safely behind a wall) and then do the damage scaling by a straight-line distance to the origin. In that case the only benefit of a cylinder to the player would be to make it easier for to take cover.

A collision hull with 90 degree corners also makes it easy for players to get stuck on sharp edges and ridges in the map, a problem that I'd call severe for most tf2 maps.

True, but I'd point out that a box that wasn't axis-aligned would have even more problems, since you'd find yourself (un)able to go certain places depending on whether you look straight ahead or not.

Ultimately I think it's a matter of AABBs being "good enough" and easy to test/debug.
 
Last edited:

FOREVER

L1: Registered
Feb 14, 2011
41
1
It's much easier to do collision testing with an AABB than a cylinder, especially when you consider how two people might try pushing past each other

I'm not sure I understand, probably because I know next to nothing about collision testing. When I imagine two cylinders trying to push past each other I imagine them doing so with velocity proportional to how off-axis they are. Would this be problematic?

In addition, the extra "diagonal distance" probably does not mean much when you consider it in comparison to the size of the blast-radius of an explosion...

I would not be surprised if the extra diagonal distance doesn't really matter for explosions: Valve might use the AABB only to determine whether someone "got hit" (as opposed to being safely behind a wall) and then do the damage scaling by a straight-line distance to the origin. In that case the only benefit of a cylinder to the player would be to make it easier for to take cover.

I wouldn't doubt damage works as you say, but for projectile crits lethal damage and "getting hit" are often enough identical. In my mind the chief benefit of a cylinder in this case would be making explosions far more predictable, as anything in the range I mentioned earlier is entirely unpredictable. But if it's a debugging nightmare then I guess there's not much more to say. Seems like a hexagonal prism might be a nice compromise, especially in regards to how clunky movement is in most tf2 maps.
 

FOREVER

L1: Registered
Feb 14, 2011
41
1
WAIIITTTT a minute:

if tf2 uses euclidean distance to calculate the damage you receive from a projectile, why can't it just use the same distance calculation to determine whether you were hit in the first place?

basically, there's no essential connection between player-player collisions and player-projectile collisions. So is valve just lazy in pretending that there is?

Also, does anyone know how to change collisions hulls?
 

ardysqrrl

L4: Comfortable Member
Oct 26, 2009
173
159
if tf2 uses euclidean distance to calculate the damage you receive from a projectile, why can't it just use the same distance calculation to determine whether you were hit in the first place?
you're talking about doing trigonometry once versus doing it every frame, not really viable
Also, does anyone know how to change collisions hulls?
make your own source mod. Why would you want to though?
 

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
WAIIITTTT a minute:

if tf2 uses euclidean distance to calculate the damage you receive from a projectile, why can't it just use the same distance calculation to determine whether you were hit in the first place?

  • Because you might be "close" to the explosion, yet behind a nice thick wall.
  • Because players aren't in the shape of a sphere, they aren't as wide as they are tall. And if you change it to an ellipse or capsule (or "swept-sphere") the math gets trickier.
  • AABB boxes are easier to optimize for speed.