GetAbsOrigin(): Difference between revisions
Jump to navigation
Jump to search
TomEdwards (talk | contribs) No edit summary |
TomEdwards (talk | contribs) mNo edit summary |
||
Line 1: | Line 1: | ||
'''<code>GetAbsOrigin()</code>''' returns the absolute (i.e. [[world]]-relative) [[origin]] of an entity as a [[vector]]. | '''<code>GetAbsOrigin()</code>''' returns the absolute (i.e. [[world]]-relative) [[origin]] of an entity as a [[vector]]. Its sister function '''<code>SetAbsOrigin()</code>''' changes it. | ||
The origin is actually stored in local space (i.e [[parent]]-relative), meaning that the Abs functions perform a conversion before returning. If you can, use the more direct <code>[[GetLocalOrigin()]]</code> and <code>[[SetLocalOrigin()]]</code> instead. | The origin is actually stored in local space (i.e [[parent]]-relative), meaning that the Abs functions perform a conversion before returning. If you can, use the more direct <code>[[GetLocalOrigin()]]</code> and <code>[[SetLocalOrigin()]]</code> instead. | ||
Line 5: | Line 5: | ||
== Alternatives == | == 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 slower than <code>GetAbsOrigin()</code>! | 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 slower than plain <code>GetAbsOrigin()</code>! | ||
; [[Vector]] <code>WorldSpaceCenter()</code> | ; [[Vector]] <code>WorldSpaceCenter()</code> |
Revision as of 15:28, 6 June 2009
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 a conversion before returning. If you can, use the more direct GetLocalOrigin()
and SetLocalOrigin()
instead.
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 slower than plain GetAbsOrigin()
!
- 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
. ModifiespVecNearestWorldPt
with the result.
Todo: Do these OBB functions work with vphysics?