![]() |
|
This class implements the internals of an LOD screenSize heuristic, but without any dependencies on USD scene data or any USD data types. More...
#include <screenSizeHeuristicQuery.h>
Inheritance diagram for UsdLodScreenSizeHeuristicQuery:Public Types | |
| using | Parent = UsdLodHeuristicQuery |
Public Member Functions | |
| UsdLodScreenSizeHeuristicQuery (const UsdLodScreenSizeHeuristicQuery &)=default | |
| UsdLodScreenSizeHeuristicQuery (UsdLodScreenSizeHeuristicQuery &&)=default | |
| UsdLodScreenSizeHeuristicQuery (const TfToken &domainIn, const GfRange3d extentIn=GfRange3d(), const TfToken &projectionMethodIn=UsdLodTokens->projectedSphere, const VtFloatArray &thresholdsIn=VtFloatArray(), const VtFloatArray &blendThresholdsIn=VtFloatArray()) | |
| virtual USDLOD_API | ~UsdLodScreenSizeHeuristicQuery () |
| Destructor. | |
| USDLOD_API double | ComputeScreenSize (const GfFrustum &frustum, const GfMatrix4d &transform) const |
Calculate the screen size given a frustum and a transform. | |
| double | ComputeScreenSize (const GfFrustum &frustum, const GfMatrix4d &transform, double prevSize, double hysteresis) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Calculate the screen size applying hysteresis to the result. | |
| USDLOD_API float | ComputeLOD (double size) const |
| Calculate an LOD index given a screen size. | |
| float | ComputeLOD (const GfFrustum &frustum, const GfMatrix4d &transform) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Calculate an LOD index given a frustum and a transform. | |
| float | ComputeLOD (const GfFrustum &frustum, const GfMatrix4d &transform, double prevSize, double hysteresis, double *sizeOut) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Calculate an LOD index given a frustum and a transform with hysteresis. | |
Public Member Functions inherited from UsdLodHeuristicQuery | |
| UsdLodHeuristicQuery (const TfToken &lodDomainIn) | |
| Construct with an explicit domain. | |
| virtual USDLOD_API | ~UsdLodHeuristicQuery () |
| Destructor. | |
Public Attributes | |
| GfRange3d | extent |
| The bounding box of the geometry, stored in a GfRange3d. | |
| TfToken | projectionMethod = UsdLodTokens->projectedSphere |
| Defines how screen size is calculated. | |
| VtFloatArray | thresholds |
| The screen size thresholds for LOD transitions in descending order as a fraction of the viewport size. | |
| VtFloatArray | blendThresholds |
| This defines screen size thresholds for LOD transitions in descending order. | |
Public Attributes inherited from UsdLodHeuristicQuery | |
| TfToken | lodDomain |
| The LOD domain of this heuristic. | |
This class implements the internals of an LOD screenSize heuristic, but without any dependencies on USD scene data or any USD data types.
It is intended to be usable inside a renderer to make fast, run-time LOD decisions without requiring access back to the original USD layers or prims.
The data types match the UsdLodScreenSizeHeuristic prim type: a center point or an extent, and one or two sets of screen size thresholds. See the documentation for UsdLodScreenSizeHeuristic for full details.
Definition at line 39 of file screenSizeHeuristicQuery.h.
| using Parent = UsdLodHeuristicQuery |
Definition at line 42 of file screenSizeHeuristicQuery.h.
|
inline |
Definition at line 132 of file screenSizeHeuristicQuery.h.
|
virtual |
Destructor.
The destructor is virtual to support RTTI and allow the object to be safely held as a pointer to UsdLodHeuristicQuery.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Calculate an LOD index given a frustum and a transform.
Definition at line 235 of file screenSizeHeuristicQuery.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Calculate an LOD index given a frustum and a transform with hysteresis.
The arguments prevSize and hysteresis should contain the most recently calculated screen size and a hysteresis threshold respectively. If the computed screen size differs from prevSize by less than hysteresis, then prevSize is used, otherwise the computed screen size is used. This helps prevent flickering between LOD levels when the computed size is very close to a threshold value. The size used (either prevSize or the newly computed size) will be returned in sizeOut so it can be used in next call to ComputeLOD.
Definition at line 254 of file screenSizeHeuristicQuery.h.
| USDLOD_API float ComputeLOD | ( | double | size | ) | const |
Calculate an LOD index given a screen size.
Compare the size against the values in thresholds to determine an LOD index. If blendThresholds has values and size is between a thresholds value and its corresponding blendThresholds value, then the returned value will be non-integral. If the renderer can blend between 2 LOD item children then it should use the returned index as follows:
If blendThresholds is not set then only integral valued LOD indices will ever be returned.
| USDLOD_API double ComputeScreenSize | ( | const GfFrustum & | frustum, |
| const GfMatrix4d & | transform ) const |
Calculate the screen size given a frustum and a transform.
The matrix transform should convert from the root's local coordinate system to the viewpoint's coordinate system. Typically, the viewpoint will be specified in world coordinates and transform will convert from the root's coordinate system to world coordinates.
The returned screen size is measured as the projection of the extent (or its bounding sphere) onto the viewplane and converted to a fraction of the visible window. The projected shape is not clipped by the viewing frustum as we do not want the computed size of an extent to change simply because it is moving off the side of the screen.
If the extent crosses the near plane, then the calculated size will be 1.0 (i.e., 100%). If the extent is entirely in front of the near plane or entirely behind the far plane (would be clipped by near or far plane clipping) then the calculated size will be 0.0.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Calculate the screen size applying hysteresis to the result.
The arguments prevSize and hysteresis should contain the most recently calculated screen size and a hysteresis threshold respectively. If the computed screen size differs from prevSize by less than hysteresis, then prevSize is returned, otherwise the computed screen size is returned. This helps prevent flickering between LOD levels when the computed size is very close to a threshold value.
Definition at line 181 of file screenSizeHeuristicQuery.h.
| VtFloatArray blendThresholds |
This defines screen size thresholds for LOD transitions in descending order.
The blend threshold is consulted for transitions that blend or combine multiple LOD items.
For example if:
then:
The blend amount should be computed linearly between the corresponding thresholds and blendThresholds values.
This field is advisory and not strongly interoperable.
Definition at line 125 of file screenSizeHeuristicQuery.h.
| GfRange3d extent |
The bounding box of the geometry, stored in a GfRange3d.
If the value is not empty, it will be used to compute the screenSize, otherwise the value of center will be used. The value is empty by default.
Definition at line 48 of file screenSizeHeuristicQuery.h.
| TfToken projectionMethod = UsdLodTokens->projectedSphere |
Defines how screen size is calculated.
If projectionMethod is projectedSphere, a very quick approximation of the extent area is used.
If projectionMethod is projectedExtent, a more expensive but more accurate computation is used.
Definition at line 87 of file screenSizeHeuristicQuery.h.
| VtFloatArray thresholds |
The screen size thresholds for LOD transitions in descending order as a fraction of the viewport size.
For example, the values {0.25, 0.10, 0.025} would mean:
Definition at line 99 of file screenSizeHeuristicQuery.h.