Bounding Box

From Valve Developer Community
< Es
Revision as of 00:34, 25 October 2024 by Ryo (talk | contribs) (Created page with "{{subst:#if: Translation of 'Bounding box' to 'español' via Template:LanguageBar buttons...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

{{subst:#if:|||

Important step for replacing wikilinks after you've created this page

After you click 'Edit' do what the image shows. If you can't see editing toolbar you need to enable it in 'Preferences' -> Editing -> checkbox 'Enable the editing toolbar'

Preload - Language Links Replace.jpg
Véase también:  {{LAuto}}

--- DON'T JUST BLINDLY DELETE THIS PART. DO REPLACE THE LINKS AND CATEGORIES. THE PICTURE SHOWS HOW TO USE IT ! ---

SEARCH FOR: \[\[(?!#|File(?:[ _]talk)?:|Image(?:[ _]talk)?:|Media:|Template(?:[ _]talk)?:|MediaWiki(?:[ _]talk)?:|Talk:|Category[ _]talk:|Project[ _]talk:|Valve[ _]Developer[ _]Community[ _]talk:|Help[ _]talk:|User(?:[ _]talk)?:|c:|commons:|Dictionary:|Google:|GoogleGroups:|IMDB:|M:|Meta:|Metawikipedia:|MW:|SdkBug:|SourceForge:|Steampowered:|W:|Wiki:|WikiBooks:|Wikipedia:|Wikiquote:|Wiktionary:|WP:)(:?(?:Category|Category|Help|Project|Valve[ _]Developer[ _]Community|Special|)(?:[^\|\]]+))(\|?.*?)\]\]

REPLACE WITH: {{subst:LAuto|$1$2}}

}}
Under construction.png
This page is actively undergoing a major edit.
As a courtesy, please do not edit this while this message is displayed.
If this page has not been edited for at least several hours to a few days, please remove this template. This message is intended to help reduce edit conflicts; please remove it between editing sessions to allow others to edit the page.

The person who added this notice will be listed in its edit history should you wish to contact them.

Info content.png
This page needs to be translated.
This page either contains information that is only partially or incorrectly translated, or there isn't a translation yet.
If this page cannot be translated for some reason, or is left untranslated for an extended period of time after this notice is posted, the page should be requested to be deleted.
Also, please make sure the article complies with the alternate languages guide.(en)
English (en)Español (es)中文 (zh)Translate (Translate)


Graph of "mins" and "maxs"

A bounding box (Axis-Aligned Bounding Box and Oriented Bounding Box) is an automatically-created invisible box that defines the rough size of an entity. Its purpose is to perform cheap QPhysics collision tests given the entity is visible (often before moving on to more expensive ones).

As shown in the graph, a bounding box is compromised of two coordinate-based points: "mins" and "maxs." Both "mins" and "maxs" represent offsets to the bounding box's origin, where "mins" is always negative, and "maxs" is always positive. Interestingly, the sum of the offsets "mins" and "maxs" is the size of the bounding box.

Bounding boxes can be seen used with:

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

If a bounding box needs to be overridden manually, these can be done:

  • Modellers use the $bbox QC command
  • Mappers and scripters use the mins and maxs keys, if the solid key is set to 2
  • Programmers call the functions UTIL_SetSize() or CBaseEntity::SetSize()
Note.pngNota:Entity parts that protrude 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.

Pendiente: Is there more to describe, like how well do they work? Merge with earlier section if there isn't anything else.

Industry Terms

Source and its community does not make use of all the industry terms to bounding boxes, however development in or outside Source may use these variants of bounding box terms: AABB and OBB, or Axis-Aligned Bounding Box and Oriented Bounding Box.

An AABB is "a 3D volume relative to a given origin," or a box that isn't rotated. Its name is due to the fact that all its edges are parallel to the axes it is aligned to. An OBB is a box that's rotated, also known as "a 3D volume relative to a given origin and angle."

In most cases including Source, a bounding box is an AABB, as it's very simple to test for intersections—an AABB can't rotate along its model, requiring a recompute of the bounding box instead. In cases where a bounding box rotates along its model, these bounding boxes are referred as an AABB.

Debug-Based

npc_metropolice with ent_bbox.

Bounding boxes are quite involved in debugging; there are not only tools that visualize bounding boxes, but also tools that rely on bounding boxes to work.

Console commands that relate to bounding boxes:

  • ent_bbox - Visualizes an entity's bounding box, either the one you look at, a targetname, or a classname
  • ent_absbox - Visualizes an entity's AABB, either the one you look at, a targetname, or a classname
  • picker - For the entity on your crosshair, visualise the bounding box and other details

Programmer functions that are related:

  • UTIL_EntitiesInBox - Find all entities within a given bounding box.
  • NDebugOverlay::Box - Draw a box with the given mins and maxs. In Squirrel/Lua, the function DebugDrawBox() may be available.

See also

General

Resources