Garry's Mod Wiki

Entity:GetRotatedAABB

  Vector, Vector Entity:GetRotatedAABB( Vector min, Vector max )

Description

Returns axis-aligned bounding box (AABB) of a orientated bounding box (OBB) based on entity's rotation.

Arguments

1 Vector min
Minimum extent of an OBB in local coordinates.
2 Vector max
Maximum extent of an OBB in local coordinates.

Returns

1 Vector
Minimum extent of the AABB relative to entity's position.
2 Vector
Maximum extent of the AABB relative to entity's position.

Example

The entity's AABB center (regardless of model origin) is stored in 'pos'.

local a, b = ent:GetRotatedAABB( v:OBBMins(), v:OBBMaxs() ) local pos = ( ent:GetPos() + ( a + b ) / 2 )
Output: pos has the coordinates of the AABB center.

Example

If developer is set to 1, displays entity's OBB and it's AABB based on entity's rotation.

The OBB can be any bounding box, not simply OBB of the model/entity.

local e = Entity( 123 ) local minsB, maxsB = e:OBBMins(), e:OBBMaxs() local minsA, maxsA = e:GetRotatedAABB( minsB, maxsB ) -- Draw the AABB debugoverlay.Box( e:GetPos(), minsA, maxsA, 10, Color( 255, 255, 255, 32 ) ) -- Draw the OBB debugoverlay.BoxAngles( e:GetPos(), minsB, maxsB, e:GetAngles(), 10, Color( 255, 0, 255, 32 ) )
Output: Pink = OBB, white = AABB
image.png