15 #ifndef INCLUDED_IMATHFRUSTUMTEST_H
16 #define INCLUDED_IMATHFRUSTUMTEST_H
27 IMATH_INTERNAL_NAMESPACE_HEADER_ENTER
97 setFrustum (frust, cameraMat);
104 setFrustum (frustum, cameraMat);
132 bool isVisible (const
Vec3<
T>& vec) const IMATH_NOEXCEPT;
136 bool completelyContains (const
Sphere3<
T>& sphere) const IMATH_NOEXCEPT;
140 bool completelyContains (const
Box<
Vec3<
T>>& box) const IMATH_NOEXCEPT;
188 frustum.planes (frustumPlanes, cameraMat);
192 for (
int i = 0; i < 2; ++i)
197 frustumPlanes[index + 0].
normal.x,
198 frustumPlanes[index + 1].
normal.x,
199 frustumPlanes[index + 2].
normal.x);
201 frustumPlanes[index + 0].
normal.y,
202 frustumPlanes[index + 1].
normal.y,
203 frustumPlanes[index + 2].
normal.y);
205 frustumPlanes[index + 0].
normal.z,
206 frustumPlanes[index + 1].
normal.z,
207 frustumPlanes[index + 2].
normal.z);
227 currFrustum = frustum;
228 cameraMatrix = cameraMat;
231 template <
typename T>
235 Vec3<T> center = sphere.center;
236 Vec3<T> radiusVec =
Vec3<T> (sphere.radius, sphere.radius, sphere.radius);
239 Vec3<T> d0 = planeNormX[0] * center.
x + planeNormY[0] * center.
y +
240 planeNormZ[0] * center.
z - radiusVec - planeOffsetVec[0];
242 if (d0.
x >= 0 || d0.
y >= 0 || d0.
z >= 0)
return false;
244 Vec3<T> d1 = planeNormX[1] * center.
x + planeNormY[1] * center.
y +
245 planeNormZ[1] * center.
z - radiusVec - planeOffsetVec[1];
247 if (d1.
x >= 0 || d1.
y >= 0 || d1.
z >= 0)
return false;
252 template <
typename T>
257 Vec3<T> center = sphere.center;
258 Vec3<T> radiusVec =
Vec3<T> (sphere.radius, sphere.radius, sphere.radius);
261 Vec3<T> d0 = planeNormX[0] * center.
x + planeNormY[0] * center.
y +
262 planeNormZ[0] * center.
z + radiusVec - planeOffsetVec[0];
264 if (d0.
x >= 0 || d0.
y >= 0 || d0.
z >= 0)
return false;
266 Vec3<T> d1 = planeNormX[1] * center.
x + planeNormY[1] * center.
y +
267 planeNormZ[1] * center.
z + radiusVec - planeOffsetVec[1];
269 if (d1.
x >= 0 || d1.
y >= 0 || d1.
z >= 0)
return false;
274 template <
typename T>
278 if (box.isEmpty ())
return false;
280 Vec3<T> center = (box.min + box.max) / 2;
281 Vec3<T> extent = (box.max - center);
284 Vec3<T> d0 = planeNormX[0] * center.
x + planeNormY[0] * center.
y +
285 planeNormZ[0] * center.
z - planeNormAbsX[0] * extent.
x -
286 planeNormAbsY[0] * extent.
y - planeNormAbsZ[0] * extent.
z -
289 if (d0.
x >= 0 || d0.
y >= 0 || d0.
z >= 0)
return false;
291 Vec3<T> d1 = planeNormX[1] * center.
x + planeNormY[1] * center.
y +
292 planeNormZ[1] * center.
z - planeNormAbsX[1] * extent.
x -
293 planeNormAbsY[1] * extent.
y - planeNormAbsZ[1] * extent.
z -
296 if (d1.
x >= 0 || d1.
y >= 0 || d1.
z >= 0)
return false;
301 template <
typename T>
306 if (box.isEmpty ())
return false;
308 Vec3<T> center = (box.min + box.max) / 2;
309 Vec3<T> extent = (box.max - center);
312 Vec3<T> d0 = planeNormX[0] * center.
x + planeNormY[0] * center.
y +
313 planeNormZ[0] * center.
z + planeNormAbsX[0] * extent.
x +
314 planeNormAbsY[0] * extent.
y + planeNormAbsZ[0] * extent.
z -
317 if (d0.
x >= 0 || d0.
y >= 0 || d0.
z >= 0)
return false;
319 Vec3<T> d1 = planeNormX[1] * center.
x + planeNormY[1] * center.
y +
320 planeNormZ[1] * center.
z + planeNormAbsX[1] * extent.
x +
321 planeNormAbsY[1] * extent.
y + planeNormAbsZ[1] * extent.
z -
324 if (d1.
x >= 0 || d1.
y >= 0 || d1.
z >= 0)
return false;
329 template <
typename T>
334 Vec3<T> d0 = (planeNormX[0] * vec.x) + (planeNormY[0] * vec.y) +
335 (planeNormZ[0] * vec.z) - planeOffsetVec[0];
337 if (d0.
x >= 0 || d0.
y >= 0 || d0.
z >= 0)
return false;
339 Vec3<T> d1 = (planeNormX[1] * vec.x) + (planeNormY[1] * vec.y) +
340 (planeNormZ[1] * vec.z) - planeOffsetVec[1];
342 if (d1.
x >= 0 || d1.
y >= 0 || d1.
z >= 0)
return false;
353 IMATH_INTERNAL_NAMESPACE_HEADER_EXIT
355 #endif // INCLUDED_IMATHFRUSTUMTEST_H
#define IMATH_INTERNAL_NAMESPACE
GLdouble GLdouble GLdouble z
IMATH_INTERNAL_NAMESPACE::Frustum< T > currentFrustum() const IMATH_NOEXCEPT
Return the viewing frustum (primarily for debugging)
FrustumTest< float > FrustumTestf
FrustymTest of type float.
T distance
The distance from the origin to the plane.
FrustumTest() IMATH_NOEXCEPT
Initialize camera matrix to identity.
FrustumTest(const Frustum< T > &frustum, const Matrix44< T > &cameraMat) IMATH_NOEXCEPT
Initialize to a given frustum and camera matrix.
bool isVisible(const Sphere3< T > &sphere) const IMATH_NOEXCEPT
FrustumTest< double > FrustumTestd
FrustymTest of type double.
#define IMATH_EXPORT_TEMPLATE_TYPE
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE constexpr T abs(T a) IMATH_NOEXCEPT
bool completelyContains(const Sphere3< T > &sphere) const IMATH_NOEXCEPT
Vec3< T > normal
The normal to the plane.
IMATH_HOSTDEVICE void makeIdentity() IMATH_NOEXCEPT
Set to the identity matrix.
void setFrustum(const Frustum< T > &frustum, const Matrix44< T > &cameraMat) IMATH_NOEXCEPT