24 #ifndef PXR_BASE_GF_FRUSTUM_H
25 #define PXR_BASE_GF_FRUSTUM_H
109 : _position(o._position)
110 , _rotation(o._rotation)
112 , _nearFar(o._nearFar)
113 , _viewDistance(o._viewDistance)
114 , _projectionType(o._projectionType)
116 if (
auto *planes = o._planes.load()) {
117 _planes =
new std::array<GfPlane, 6>(*planes);
123 : _position(o._position)
124 , _rotation(o._rotation)
126 , _nearFar(o._nearFar)
127 , _viewDistance(o._viewDistance)
128 , _projectionType(o._projectionType)
131 o._planes.exchange(
nullptr, std::memory_order_relaxed)) {
141 double viewDistance = 5.0);
149 double viewDistance = 5.0);
156 _position = o._position;
157 _rotation = o._rotation;
159 _nearFar = o._nearFar;
160 _viewDistance = o._viewDistance;
161 _projectionType = o._projectionType;
162 delete _planes.load(std::memory_order_relaxed);
163 if (
auto *planes = o._planes.load(std::memory_order_relaxed)) {
164 _planes.store(
new std::array<GfPlane, 6>(*planes),
165 std::memory_order_relaxed);
168 _planes.store(
nullptr, std::memory_order_relaxed);
178 _position = o._position;
179 _rotation = o._rotation;
181 _nearFar = o._nearFar;
182 _viewDistance = o._viewDistance;
183 _projectionType = o._projectionType;
184 delete _planes.load(std::memory_order_relaxed);
185 _planes.store(o._planes.load(std::memory_order_relaxed),
186 std::memory_order_relaxed);
187 o._planes.store(
nullptr, std::memory_order_relaxed);
204 if (_position != f._position)
return false;
205 if (_rotation != f._rotation)
return false;
206 if (_window != f._window)
return false;
207 if (_nearFar != f._nearFar)
return false;
208 if (_viewDistance != f._viewDistance)
return false;
209 if (_projectionType != f._projectionType)
return false;
216 return !(*
this ==
f);
230 _DirtyFrustumPlanes();
243 _DirtyFrustumPlanes();
263 _DirtyFrustumPlanes();
279 _DirtyFrustumPlanes();
289 _viewDistance = viewDistance;
294 return _viewDistance;
299 _projectionType = projectionType;
300 _DirtyFrustumPlanes();
305 return _projectionType;
337 double nearDistance,
double farDistance);
369 double nearDistance,
double farDistance);
376 double *nearDistance,
377 double *farDistance)
const;
385 double *nearDistance,
386 double *farDistance)
const;
408 double nearPlane,
double farPlane);
415 double *nearPlane,
double *farPlane)
632 GF_API void _DirtyFrustumPlanes();
635 GF_API void _CalculateFrustumPlanes()
const;
642 const GfVec3d &camSpaceDir)
const;
663 bool _SegmentIntersects(
GfVec3d const &p0, uint32_t p0Mask,
664 GfVec3d const &p1, uint32_t p1Mask)
const;
680 double _viewDistance;
687 mutable std::atomic<std::array<GfPlane, 6> *> _planes;
701 #endif // PXR_BASE_GF_FRUSTUM_H
bool operator==(const GfFrustum &f) const
void SetRotation(const GfRotation &rotation)
GfFrustum(GfFrustum const &o)
Copy constructor.
void SetViewDistance(double viewDistance)
Sets the view distance.
friend size_t hash_value(const GfFrustum &f)
GfFrustum & operator=(GfFrustum const &o) noexcept
Copy assignment.
static double GetReferencePlaneDepth()
Returns the depth of the reference plane.
GF_API std::vector< GfVec3d > ComputeCorners() const
GF_API std::ostream & operator<<(std::ostream &out, const GfFrustum &f)
GF_API bool Intersects(const GfBBox3d &bbox) const
GF_API GfVec3d ComputeViewDirection() const
GF_API bool GetOrthographic(double *left, double *right, double *bottom, double *top, double *nearPlane, double *farPlane) const
GF_API double ComputeAspectRatio() const
GF_API GfFrustum & Transform(const GfMatrix4d &matrix)
GF_API GfRay ComputePickRay(const GfVec2d &windowPos) const
GF_API void FitToSphere(const GfVec3d ¢er, double radius, double slack=0.0)
const GfVec3d & GetPosition() const
Returns the position of the frustum in world space.
GF_API void SetPositionAndRotationFromMatrix(const GfMatrix4d &camToWorldXf)
GF_API GfVec3d ComputeLookAtPoint() const
GfFrustum(GfFrustum &&o) noexcept
Move constructor.
const GfRange1d & GetNearFar() const
Returns the near/far interval.
GF_API GfMatrix4d ComputeViewMatrix() const
GF_API GfMatrix4d ComputeViewInverse() const
GF_API void SetOrthographic(double left, double right, double bottom, double top, double nearPlane, double farPlane)
GF_API GfMatrix4d ComputeProjectionMatrix() const
void SetWindow(const GfRange2d &window)
GfFrustum::ProjectionType GetProjectionType() const
Returns the projection type.
static GF_API bool IntersectsViewVolume(const GfBBox3d &bbox, const GfMatrix4d &vpMat)
SIM_API const UT_StringHolder rotation
double GetViewDistance() const
Returns the view distance.
GF_API bool GetPerspective(double *fieldOfViewHeight, double *aspectRatio, double *nearDistance, double *farDistance) const
bool operator!=(const GfFrustum &f) const
GF_API std::vector< GfVec3d > ComputeCornersAtDistance(double d) const
const GfRange2d & GetWindow() const
Returns the window rectangle in the reference plane.
const GfRotation & GetRotation() const
void SetProjectionType(GfFrustum::ProjectionType projectionType)
Sets the projection type.
GF_API GfRay ComputeRay(const GfVec2d &windowPos) const
static size_t Combine(Args &&...args)
Produce a hash code by combining the hash codes of several objects.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
GA_API const UT_StringHolder up
GF_API GfFrustum ComputeNarrowedFrustum(const GfVec2d &windowPos, const GfVec2d &size) const
SIM_API const UT_StringHolder position
#define PXR_NAMESPACE_CLOSE_SCOPE
GF_API ~GfFrustum()
Destructor.
GLdouble GLdouble GLdouble top
GF_API void SetPerspective(double fieldOfViewHeight, double aspectRatio, double nearDistance, double farDistance)
GF_API double GetFOV(bool isFovVertical=false)
void SetNearFar(const GfRange1d &nearFar)
Sets the near/far interval.
GF_API GfVec3d ComputeUpVector() const
GfFrustum & operator=(GfFrustum &&o) noexcept
Move assignment.
void SetPosition(const GfVec3d &position)
Sets the position of the frustum in world space.
GF_API void ComputeViewFrame(GfVec3d *side, GfVec3d *up, GfVec3d *view) const