AABB

Caja bordeada alineada con el eje.

Descripción

AABB consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.

It uses floating-point coordinates. The 2D counterpart to AABB is Rect2.

Negative values for size are not supported and will not work for most methods. Use abs to get an AABB with a positive size.

Note: Unlike Rect2, AABB does not have a variant that uses integer coordinates.

Tutoriales

Propiedades

Vector3

end

Vector3( 0, 0, 0 )

Vector3

position

Vector3( 0, 0, 0 )

Vector3

size

Vector3( 0, 0, 0 )

Métodos

AABB

AABB ( Vector3 position, Vector3 size )

AABB

abs ( )

bool

encloses ( AABB with )

AABB

expand ( Vector3 to_point )

float

get_area ( )

Vector3

get_center ( )

Vector3

get_endpoint ( int idx )

Vector3

get_longest_axis ( )

int

get_longest_axis_index ( )

float

get_longest_axis_size ( )

Vector3

get_shortest_axis ( )

int

get_shortest_axis_index ( )

float

get_shortest_axis_size ( )

Vector3

get_support ( Vector3 dir )

AABB

grow ( float by )

bool

has_no_area ( )

bool

has_no_surface ( )

bool

has_point ( Vector3 point )

AABB

intersection ( AABB with )

bool

intersects ( AABB with )

bool

intersects_plane ( Plane plane )

bool

intersects_segment ( Vector3 from, Vector3 to )

bool

is_equal_approx ( AABB aabb )

AABB

merge ( AABB with )

Descripciones de Propiedades

Default

Vector3( 0, 0, 0 )

Esquina final. Esto se calcula como position + size. Cambiar esta propiedad cambia el tamaño.


Default

Vector3( 0, 0, 0 )

Esquina de inicio. Normalmente tiene valores inferiores a end.


Default

Vector3( 0, 0, 0 )

Size from position to end. Typically, all components are positive.

If the size is negative, you can use abs to fix it.

Descripciones de Métodos

Construye un AABB a partir de una posición y un tamaño.


Devuelve un AABB con posición y tamaño equivalentes, modificado para que la esquina más negativa sea el origen y el tamaño sea positivo.


Devuelve true si este AABB contiene completamente a otro.


Returns a copy of this AABB expanded to include a given point.

Example:

# position (-3, 2, 0), size (1, 1, 1)
var box = AABB(Vector3(-3, 2, 0), Vector3(1, 1, 1))
# position (-3, -1, 0), size (3, 4, 2), so we fit both the original AABB and Vector3(0, -1, 2)
var box2 = box.expand(Vector3(0, -1, 2))

Devuelve el volumen del AABB.


Returns the center of the AABB, which is equal to position + (size / 2).


Obtiene la posición de los 8 puntos finales del AABB en el espacio.


Devuelve el eje más largo normalizado del AABB.


  • int get_longest_axis_index ( )

Devuelve el indice del eje mas grande de AABB (segun la constante Vector3 AXIS_*).


  • float get_longest_axis_size ( )

Devuelve la longitud escalar del eje más largo del AABB.


Devuelve el eje más corto normalizado de la AABB.


  • int get_shortest_axis_index ( )

Devuelve el índice del eje más corto del AABB (según el enumerado Vector3::AXIS* ).


  • float get_shortest_axis_size ( )

Devuelve la longitud escalar del eje más corto del AABB.


Devuelve el punto de apoyo en una dirección determinada. Esto es útil para los algoritmos de detección de colisiones.


Devuelve una copia de la AABB crecida una cantidad dada de unidades hacia todos los lados.


  • bool has_no_area ( )

Devuelve true si el AABB es plano o vacío.


  • bool has_no_surface ( )

Devuelve true si el AABB está vacío.


Devuelve true si el AABB contiene un punto.


Devuelve la intersección entre dos AABB. Un AABB vacío (tamaño 0,0,0) se devuelve al fallar.


Devuelve true si el AABB se solapa con otro.


Devuelve true si el AABB está a ambos lados de un plano.


Devuelve true si el AABB intersecta el segmento de línea entre from y to.


Devuelve true si este AABB y aabb son aproximadamente iguales, llamando al @GDScript.is_equal_approx en cada componente.


Devuelve un AABB más grande que contiene tanto este AABB como el with.