GetAbsOrigin()

From Valve Developer Community
Revision as of 15:32, 6 June 2009 by TomEdwards (talk | contribs)
Jump to navigation Jump to search

GetAbsOrigin() returns the absolute (i.e. world-relative) origin of an entity as a vector. Its sister function SetAbsOrigin() changes it.

The origin is actually stored in local space (i.e parent-relative), meaning that the Abs functions perform extra calculations to get their return value. Use the more direct GetLocalOrigin() and SetLocalOrigin() if possible; they work directly with the stored value (m_vecOrigin).

Alternatives

A different approach for finding an origin can be useful, particularly when dealing with a brush entity which might not have one stored. Bear in mind that these alternatives are all significantly more expensive than the 'vanilla' functions listed above.

Vector WorldSpaceCenter()
Returns the centre of an entity's object-aligned bounding box.
void CollisionProp()->CalcNearestPoint(&vecWorldPt,*pVecNearestWorldPt)
Finds the nearest point on the entity's OBB to vecWorldPt. Modifies pVecNearestWorldPt with the result.
Todo: Do these OBB functions work with vphysics?