VPlane

From Valve Developer Community
Jump to navigation Jump to search
English (en)Deutsch (de)Translate (Translate)

VPlane is a C++ class that represents an infinite 2D surface.

Each VPlane contains a normalised Vector that defines its facing (m_Normal) and a vec_t that defines its distance from the current origin (m_Dist).

VPlane with two different offset values
Tip.pngTip:m_Dist can be negative too.

Member functions

vec_t DistTo(Vector point)
The distance between the given point and its nearest point on the plane. Positive if in front, negative if behind.
SideType GetPointSide(Vector point, vec_t epsilon = 0.01f)
Performs DistTo() then processes the result. The optional epsilon value specifies an unsigned threshold within which the return value will be considered SIDE_ON.
SideType is a redefined int which has #defined values of SIDE_FRONT, SIDE_BACK and SIDE_ON.
SideType GetPointSideExact(Vector point)
As above, but without an epsilon and assuming 0 to be behind the plane.
VPlane Flip()
Returns a new VPlane with both m_Dist and m_Normal inverted. Does not change the VPlane's own values (but this = Flip() would).
Vector GetPointOnPlane()
Returns the point on the plane nearest to the current origin.
Vector SnapPointToPlane(const Vector &point)
Returns a new Vector representing the nearest point on the plane to the given Vector.