MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Contains

Method Contains

Source/Engine/Core/Math/OrientedBoundingBox.cpp:137–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137ContainmentType OrientedBoundingBox::Contains(const Vector3& point, Real* distance) const
138{
139 // Transform the point into the obb coordinates
140 Vector3 locPoint;
141 Transformation.WorldToLocal(point, locPoint);
142 locPoint.X = Math::Abs(locPoint.X);
143 locPoint.Y = Math::Abs(locPoint.Y);
144 locPoint.Z = Math::Abs(locPoint.Z);
145
146 if (distance)
147 {
148 // Get minimum distance to edge in local space
149 Vector3 tmp;
150 Vector3::Subtract(Extents, locPoint, tmp);
151 const Real minDstToEdgeLocal = tmp.GetAbsolute().MinValue();
152
153 // Transform distance to world space
154 Vector3 dstVec = Vector3::UnitX * minDstToEdgeLocal;
155 Transformation.LocalToWorldVector(dstVec, dstVec);
156 *distance = dstVec.Length();
157 }
158
159 // Simple axes-aligned BB check
160 if (locPoint.X < Extents.X && locPoint.Y < Extents.Y && locPoint.Z < Extents.Z)
161 return ContainmentType::Contains;
162 if (Vector3::NearEqual(locPoint, Extents))
163 return ContainmentType::Intersects;
164 return ContainmentType::Disjoint;
165}
166
167ContainmentType OrientedBoundingBox::Contains(const BoundingSphere& sphere, bool ignoreScale) const
168{

Callers

nothing calls this directly

Calls 9

SubtractFunction · 0.85
ClampFunction · 0.85
AbsFunction · 0.70
NearEqualFunction · 0.70
WorldToLocalMethod · 0.45
MinValueMethod · 0.45
GetAbsoluteMethod · 0.45
LocalToWorldVectorMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected