Bounding box

From Valve Developer Community
(Redirected from Object-aligned bounding box)
Jump to: navigation, search
The bounding box of npc_metropolice.

A Bounding Box is an invisible box that defines the rough size of an entity. It's chiefly used to determine when the entity is visible and to perform cheap QPhysics collision tests (often before moving on to more expensive ones: for example, bullets are only tested against hitboxes if they are first found to intersect with the given entity's bounding box).

Note:Parts of an entity that protrude from its bounding box will not pass QPhysics collision tests. This includes hitboxes.

Rotation

Bounding boxes are always aligned to the world's axes. They never rotate. This is presumably because of their use for collision detection of players: it would be impossible to turn around in a tight corridor if the four corners of your bounding box rotated with you. Axis-aligned boxes are also far cheaper to compute.

While this isn't a huge issue for objects that are roughly square from above, it makes oblong dimensions difficult to manage without switching to VPhysics. When VPhysics isn't an option there isn't much that can be done: a Day of Defeat: Source player who has gone prone has an oblong shape that can rotate through a full 360°, which Valve could only accommodate for by creating a 'squished' bounding box that leaves the head and feet sticking out at all times (an image of this would be nice).

Object-aligned

Object-aligned bounding boxes rotate with their entity. They appear to be linked to VPhysics to some extent. To do: How well do they work?

Defining

Source will automatically create bounding boxes. But if you need to tweak the results:

  • Modellers use the $bbox QC command
  • Programmers call UTIL_SetSize() or CBaseEntity::SetSize()

Uses

  • QPhysics collision detection (mainly NPCs and players)
  • Prerequisite for hitbox collision detection
  • Line of sight tests
  • Visleaves occupied by an entity

See Also