Collision Hulls

Discussion in 'Mapping Questions & Discussion' started by FOREVER, Mar 21, 2011.

  1. FOREVER

    FOREVER L1: Registered

    Messages:
    41
    Positive Ratings:
    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?
     
  2. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,769
    Positive Ratings:
    5,535
    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.
     
  3. FOREVER

    FOREVER L1: Registered

    Messages:
    41
    Positive Ratings:
    1
    from http://wiki.teamfortress.com/wiki/Mechanics#Hit_detection

    "Projectile collision detection does not use model-conforming hitboxes, instead using large, singular, position-based-only projectile hitboxes that completely encompass the player model (for example, a standing Heavy has the same projectile hit detection as a crouching Scout)."
     
  4. Terr

    aa Terr Cranky Coder

    Messages:
    1,591
    Positive Ratings:
    405
    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.)

    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.

    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: Mar 21, 2011
  5. LeSwordfish

    aa LeSwordfish semi-trained quasi-professional

    Messages:
    4,113
    Positive Ratings:
    6,084
    Plus, it vastly simplifies things. Having a cuboid collision box is not too big an issue, and frees up time and processing power for other stuff.
     
  6. FOREVER

    FOREVER L1: Registered

    Messages:
    41
    Positive Ratings:
    1
    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?

    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.
     
  7. FOREVER

    FOREVER L1: Registered

    Messages:
    41
    Positive Ratings:
    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?
     
  8. ardysqrrl

    ardysqrrl L4: Comfortable Member

    Messages:
    173
    Positive Ratings:
    159
    you're talking about doing trigonometry once versus doing it every frame, not really viable
    make your own source mod. Why would you want to though?
     
  9. LeSwordfish

    aa LeSwordfish semi-trained quasi-professional

    Messages:
    4,113
    Positive Ratings:
    6,084
    The difference would be absolutely tiny.
     
  10. Terr

    aa Terr Cranky Coder

    Messages:
    1,591
    Positive Ratings:
    405
    • 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.