Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QSSGRenderCamera Struct Reference

#include <qssgrendercamera_p.h>

+ Inheritance diagram for QSSGRenderCamera:
+ Collaboration diagram for QSSGRenderCamera:

Public Types

enum class  DirtyFlag : quint8 { CameraDirty = 0x1 }
 
using FlagT = std::underlying_type_t< DirtyFlag >
 
- Public Types inherited from QSSGRenderNode
enum class  LocalState : quint8 { Active = 1 << 0 , Pickable = 1 << 1 }
 
enum class  GlobalState : quint8 { Active = 1 << 2 , Pickable = 1 << 3 }
 
enum class  DirtyFlag : quint32 {
  TransformDirty = 1 << 4 , OpacityDirty = 1 << 5 , ActiveDirty = 1 << 6 , PickableDirty = 1 << 7 ,
  SubNodeDirty = 1 << 8 , GlobalValuesDirty = TransformDirty | OpacityDirty | ActiveDirty | PickableDirty , DirtyMask = GlobalValuesDirty | SubNodeDirty
}
 
using FlagT = std::underlying_type_t< DirtyFlag >
 
using ChildList = QSSGInvasiveLinkedList< QSSGRenderNode, &QSSGRenderNode::previousSibling, &QSSGRenderNode::nextSibling >
 
- Public Types inherited from QSSGRenderGraphObject
enum  BaseType : quint16 {
  Node = 0x10 , Light = 0x20 , Camera = 0x40 , Renderable = 0x80 ,
  Resource = 0x100 , Material = 0x200 , Texture = 0x400 , Extension = 0x800
}
 
enum class  Type : quint16 {
  Unknown = 0 , Node = BaseType::Node , Layer , Joint ,
  Skeleton , ImportScene , ReflectionProbe , DirectionalLight = BaseType::Light | BaseType::Node ,
  PointLight , SpotLight , OrthographicCamera = BaseType::Camera | BaseType::Node , PerspectiveCamera ,
  CustomFrustumCamera , CustomCamera , Model = BaseType::Renderable | BaseType::Node , Item2D ,
  Particles , SceneEnvironment = BaseType::Resource , Effect , Geometry ,
  TextureData , MorphTarget , ModelInstance , ModelBlendParticle ,
  ResourceLoader , DefaultMaterial = BaseType::Material | BaseType::Resource , PrincipledMaterial , CustomMaterial ,
  SpecularGlossyMaterial , Skin , Image2D = BaseType::Texture | BaseType::Resource , ImageCube ,
  RenderExtension = BaseType::Extension
}
 

Public Member Functions

 QSSGRenderCamera (QSSGRenderGraphObject::Type type)
 
QMatrix3x3 getLookAtMatrix (const QVector3D &inUpDir, const QVector3D &inDirection) const
 
void lookAt (const QVector3D &inCameraPos, const QVector3D &inUpDir, const QVector3D &inTargetPos, const QVector3D &pivot)
 
QSSGCameraGlobalCalculationResult calculateGlobalVariables (const QRectF &inViewport)
 
bool calculateProjection (const QRectF &inViewport)
 
bool computeFrustumOrtho (const QRectF &inViewport)
 
float getOrthographicScaleFactor (const QRectF &inViewport) const
 
bool computeFrustumPerspective (const QRectF &inViewport)
 
bool computeCustomFrustum (const QRectF &inViewport)
 
void calculateViewProjectionMatrix (QMatrix4x4 &outMatrix) const
 
void calculateViewProjectionWithoutTranslation (float near, float far, QMatrix4x4 &outMatrix) const
 
QSSGRenderRay unproject (const QVector2D &inLayerRelativeMouseCoords, const QRectF &inViewport) const
 
QVector3D unprojectToPosition (const QVector3D &inGlobalPos, const QSSGRenderRay &inRay) const
 
float verticalFov (float aspectRatio) const
 
float verticalFov (const QRectF &inViewport) const
 
bool isDirty (DirtyFlag dirtyFlag=DirtyMask) const
 
void markDirty (DirtyFlag dirtyFlag)
 
void clearDirty (DirtyFlag dirtyFlag)
 
float getLevelOfDetailMultiplier () const
 
- Public Member Functions inherited from QSSGRenderNode
 QSSGRenderNode ()
 
 QSSGRenderNode (Type type)
 
 ~QSSGRenderNode () override
 
void markDirty (DirtyFlag dirtyFlag)
 
void clearDirty (DirtyFlag dirtyFlag)
 
constexpr bool isDirty (DirtyFlag dirtyFlag=DirtyFlag::DirtyMask) const
 
void setState (LocalState state, bool on=true)
 
constexpr bool getLocalState (LocalState stateFlag) const
 
constexpr bool getGlobalState (GlobalState stateFlag) const
 
void addChild (QSSGRenderNode &inChild)
 
void removeChild (QSSGRenderNode &inChild)
 
void removeFromGraph ()
 
bool calculateGlobalVariables ()
 
QSSGBounds3 getBounds (QSSGBufferManager &inManager, bool inIncludeChildren=true) const
 
QSSGBounds3 getChildBounds (QSSGBufferManager &inManager) const
 
QVector3D getGlobalPos () const
 
QVector3D getGlobalPivot () const
 
QVector3D getDirection () const
 
QVector3D getScalingCorrectDirection () const
 
void calculateMVPAndNormalMatrix (const QMatrix4x4 &inViewProjection, QMatrix4x4 &outMVP, QMatrix3x3 &outNormalMatrix) const
 
QMatrix3x3 calculateNormalMatrix () const
 
- Public Member Functions inherited from QSSGRenderGraphObject
Q_QUICK3D_PROFILE_ID QSSGRenderGraphObject (QSSGRenderGraphObject::Type inType)
 
virtual ~QSSGRenderGraphObject ()
 

Public Attributes

float clipNear
 
float clipFar
 
float fov
 
bool fovHorizontal
 
float top = 0.0f
 
float bottom = 0.0f
 
float left = 0.0f
 
float right = 0.0f
 
float horizontalMagnification = 1.0f
 
float verticalMagnification = 1.0f
 
float dpr = 1.0f
 
QMatrix4x4 projection
 
QVector2D frustumScale
 
bool enableFrustumClipping
 
FlagT cameraDirtyFlags = 0
 
float levelOfDetailPixelThreshold = 1.0
 
QRectF previousInViewport
 
- Public Attributes inherited from QSSGRenderNode
QVector3D pivot
 
int staticFlags = 0
 
float localOpacity = 1.0f
 
FlagT flags { FlagT(DirtyFlag::GlobalValuesDirty) | FlagT(LocalState::Active) }
 
QMatrix4x4 localTransform
 
QMatrix4x4 globalTransform
 
QMatrix4x4 localInstanceTransform
 
QMatrix4x4 globalInstanceTransform
 
float globalOpacity = 1.0f
 
QSSGRenderNodeparent = nullptr
 
QSSGRenderNodenextSibling = nullptr
 
QSSGRenderNodepreviousSibling = nullptr
 
QSSGRenderNodeinstanceRoot = nullptr
 
quint32 dfsIndex = 0
 
ChildList children
 
QString debugObjectName
 
- Public Attributes inherited from QSSGRenderGraphObject
Type type
 

Static Public Attributes

static constexpr DirtyFlag DirtyMask { std::numeric_limits<FlagT>::max() }
 
- Static Public Attributes inherited from QSSGRenderNode
static constexpr QVector3D initScale { 1.0f, 1.0f, 1.0f }
 

Additional Inherited Members

- Static Public Member Functions inherited from QSSGRenderNode
static QMatrix4x4 calculateTransformMatrix (QVector3D position, QVector3D scale, QVector3D pivot, QQuaternion rotation)
 
static float signedSquared (float val)
 
- Static Public Member Functions inherited from QSSGRenderGraphObject
static Q_REQUIRED_RESULT constexpr bool isNodeType (Type type) Q_DECL_NOTHROW
 
static Q_REQUIRED_RESULT constexpr bool isLight (Type type) Q_DECL_NOTHROW
 
static Q_REQUIRED_RESULT constexpr bool isCamera (Type type) Q_DECL_NOTHROW
 
static Q_REQUIRED_RESULT constexpr bool isMaterial (Type type) Q_DECL_NOTHROW
 
static Q_REQUIRED_RESULT constexpr bool isTexture (Type type) Q_DECL_NOTHROW
 
static Q_REQUIRED_RESULT constexpr bool isRenderable (Type type) Q_DECL_NOTHROW
 
static Q_REQUIRED_RESULT constexpr bool isResource (Type type) Q_DECL_NOTHROW
 
static constexpr bool isExtension (Type type) noexcept
 
static Q_REQUIRED_RESULT constexpr bool hasGraphicsResources (Type type) Q_DECL_NOTHROW
 
static const char * asString (QSSGRenderGraphObject::Type type)
 
static QDebug debugPrintImpl (QDebug stream, QSSGRenderGraphObject::Type type)
 

Detailed Description

Definition at line 34 of file qssgrendercamera_p.h.

Member Typedef Documentation

◆ FlagT

using QSSGRenderCamera::FlagT = std::underlying_type_t<DirtyFlag>

Definition at line 40 of file qssgrendercamera_p.h.

Member Enumeration Documentation

◆ DirtyFlag

enum class QSSGRenderCamera::DirtyFlag : quint8
strong
Enumerator
CameraDirty 

Definition at line 36 of file qssgrendercamera_p.h.

Constructor & Destructor Documentation

◆ QSSGRenderCamera()

QSSGRenderCamera::QSSGRenderCamera ( QSSGRenderGraphObject::Type  type)
explicit

Definition at line 27 of file qssgrendercamera.cpp.

References CameraDirty, QSSGRenderGraphObject::isCamera(), markDirty(), and Q_ASSERT.

+ Here is the call graph for this function:

Member Function Documentation

◆ calculateGlobalVariables()

QSSGCameraGlobalCalculationResult QSSGRenderCamera::calculateGlobalVariables ( const QRectF inViewport)

Definition at line 40 of file qssgrendercamera.cpp.

References QSSGRenderNode::calculateGlobalVariables(), and calculateProjection().

Referenced by QSSGLayerRenderPreparationResult::setupCameraForRender(), setupCameraForShadowMap(), setupCubeReflectionCameras(), setupCubeShadowCameras(), and QQuick3DCamera::updateGlobalVariables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateProjection()

bool QSSGRenderCamera::calculateProjection ( const QRectF inViewport)

Definition at line 46 of file qssgrendercamera.cpp.

References CameraDirty, clearDirty(), computeCustomFrustum(), computeFrustumOrtho(), computeFrustumPerspective(), QMatrix4x4::data(), frustumScale, isDirty(), previousInViewport, projection, QVector2D::setX(), and QVector2D::setY().

Referenced by calculateGlobalVariables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateViewProjectionMatrix()

void QSSGRenderCamera::calculateViewProjectionMatrix ( QMatrix4x4 outMatrix) const

Definition at line 148 of file qssgrendercamera.cpp.

References QMatrix4x4::column(), QSSGRenderNode::globalTransform, QMatrix4x4::inverted(), QVector4D::normalized(), projection, QMatrix4x4::setColumn(), and Qt::Uninitialized.

Referenced by computeFrustumBounds(), RenderHelpers::rhiPrepareGrid(), RenderHelpers::rhiRenderShadowMap(), and QSSGMaterialShaderGenerator::setRhiMaterialProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateViewProjectionWithoutTranslation()

void QSSGRenderCamera::calculateViewProjectionWithoutTranslation ( float  near,
float  far,
QMatrix4x4 outMatrix 
) const

Definition at line 158 of file qssgrendercamera.cpp.

References clipFar, clipNear, QMatrix4x4::column(), QSSGRenderNode::globalTransform, QMatrix4x4::inverted(), QVector4D::normalized(), projection, qFuzzyIsNull(), qWarning, QMatrix4x4::setColumn(), and Qt::Uninitialized.

+ Here is the call graph for this function:

◆ clearDirty()

void QSSGRenderCamera::clearDirty ( DirtyFlag  dirtyFlag)

Definition at line 238 of file qssgrendercamera.cpp.

References cameraDirtyFlags, QSSGRenderNode::clearDirty(), and QSSGRenderNode::SubNodeDirty.

Referenced by calculateProjection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ computeCustomFrustum()

bool QSSGRenderCamera::computeCustomFrustum ( const QRectF inViewport)

Definition at line 93 of file qssgrendercamera.cpp.

References clipFar, clipNear, QMatrix4x4::frustum(), projection, Q_UNUSED, and QMatrix4x4::setToIdentity().

Referenced by calculateProjection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ computeFrustumOrtho()

bool QSSGRenderCamera::computeFrustumOrtho ( const QRectF inViewport)

Compute the projection matrix for a orthographic camera

Returns
true if the computed projection matrix is valid

Definition at line 106 of file qssgrendercamera.cpp.

References clipFar, clipNear, dpr, QRectF::height(), horizontalMagnification, QMatrix4x4::ortho(), projection, verticalMagnification, and QRectF::width().

Referenced by calculateProjection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ computeFrustumPerspective()

bool QSSGRenderCamera::computeFrustumPerspective ( const QRectF inViewport)

Compute the projection matrix for a perspective camera

Returns
true if the computed projection matrix is valid

Definition at line 86 of file qssgrendercamera.cpp.

References clipFar, clipNear, QMatrix4x4::perspective(), projection, qRadiansToDegrees(), and verticalFov().

Referenced by calculateProjection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLevelOfDetailMultiplier()

float QSSGRenderCamera::getLevelOfDetailMultiplier ( ) const

Definition at line 274 of file qssgrendercamera.cpp.

References getViewportHalfExtents(), getZNear(), projection, and QVector2D::x().

Referenced by QSSGLayerRenderData::prepareModelsForRender().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLookAtMatrix()

QMatrix3x3 QSSGRenderCamera::getLookAtMatrix ( const QVector3D inUpDir,
const QVector3D inDirection 
) const

◆ getOrthographicScaleFactor()

float QSSGRenderCamera::getOrthographicScaleFactor ( const QRectF inViewport) const

Definition at line 115 of file qssgrendercamera.cpp.

References horizontalMagnification, Q_UNUSED, qMax(), and verticalMagnification.

+ Here is the call graph for this function:

◆ isDirty()

bool QSSGRenderCamera::isDirty ( DirtyFlag  dirtyFlag = DirtyMask) const
inline

Definition at line 109 of file qssgrendercamera_p.h.

References QSSGRenderNode::DirtyMask, and QSSGRenderNode::isDirty().

Referenced by calculateProjection(), and QSSGLayerRenderData::prepareForRender().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookAt()

void QSSGRenderCamera::lookAt ( const QVector3D inCameraPos,
const QVector3D inUpDir,
const QVector3D inTargetPos,
const QVector3D pivot 
)

Definition at line 141 of file qssgrendercamera.cpp.

References QSSGRenderNode::calculateTransformMatrix(), QSSGRenderNode::getScalingCorrectDirection(), QSSGRenderNode::globalTransform, QSSGRenderNode::initScale, QSSGRenderNode::localTransform, QSSGRenderNode::markDirty(), QVector3D::normalized(), QSSGRenderNode::pivot, rotationQuaternionForLookAt(), and QSSGRenderNode::TransformDirty.

Referenced by setupCameraForShadowMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ markDirty()

void QSSGRenderCamera::markDirty ( DirtyFlag  dirtyFlag)

Definition at line 232 of file qssgrendercamera.cpp.

References cameraDirtyFlags, QSSGRenderNode::markDirty(), and QSSGRenderNode::SubNodeDirty.

Referenced by QSSGRenderCamera().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unproject()

QSSGRenderRay QSSGRenderCamera::unproject ( const QVector2D inLayerRelativeMouseCoords,
const QRectF inViewport 
) const

Definition at line 176 of file qssgrendercamera.cpp.

References QSSGRenderNode::calculateNormalMatrix(), QSSGRenderRay::direction, frustumScale, QSSGRenderNode::globalTransform, QVector3D::normalize(), QSSGRenderRay::origin, relativeToNormalizedCoordinates(), QVector3D::setX(), QVector3D::setY(), QVector3D::setZ(), mat33::transform(), mat44::transform(), QVector2D::x(), and QVector2D::y().

Referenced by QQuick3DSceneRenderer::getRayFromViewportPos().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unprojectToPosition()

QVector3D QSSGRenderCamera::unprojectToPosition ( const QVector3D inGlobalPos,
const QSSGRenderRay inRay 
) const

Definition at line 213 of file qssgrendercamera.cpp.

References QVector3D::dotProduct(), QSSGRenderNode::getDirection(), and QSSGRenderRay::intersect().

+ Here is the call graph for this function:

◆ verticalFov() [1/2]

float QSSGRenderCamera::verticalFov ( const QRectF inViewport) const

Definition at line 227 of file qssgrendercamera.cpp.

References verticalFov().

+ Here is the call graph for this function:

◆ verticalFov() [2/2]

float QSSGRenderCamera::verticalFov ( float  aspectRatio) const

Definition at line 222 of file qssgrendercamera.cpp.

References fov, fovHorizontal, qAtan(), and qTan().

Referenced by computeFrustumPerspective(), and verticalFov().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ bottom

float QSSGRenderCamera::bottom = 0.0f

Definition at line 52 of file qssgrendercamera_p.h.

◆ cameraDirtyFlags

FlagT QSSGRenderCamera::cameraDirtyFlags = 0

Definition at line 66 of file qssgrendercamera_p.h.

Referenced by clearDirty(), and markDirty().

◆ clipFar

◆ clipNear

◆ DirtyMask

constexpr DirtyFlag QSSGRenderCamera::DirtyMask { std::numeric_limits<FlagT>::max() }
staticconstexpr

Definition at line 42 of file qssgrendercamera_p.h.

◆ dpr

float QSSGRenderCamera::dpr = 1.0f

◆ enableFrustumClipping

bool QSSGRenderCamera::enableFrustumClipping

Definition at line 65 of file qssgrendercamera_p.h.

◆ fov

float QSSGRenderCamera::fov

◆ fovHorizontal

bool QSSGRenderCamera::fovHorizontal

Definition at line 49 of file qssgrendercamera_p.h.

Referenced by verticalFov().

◆ frustumScale

QVector2D QSSGRenderCamera::frustumScale

Definition at line 64 of file qssgrendercamera_p.h.

Referenced by calculateProjection(), and unproject().

◆ horizontalMagnification

float QSSGRenderCamera::horizontalMagnification = 1.0f

◆ left

float QSSGRenderCamera::left = 0.0f

Definition at line 53 of file qssgrendercamera_p.h.

◆ levelOfDetailPixelThreshold

float QSSGRenderCamera::levelOfDetailPixelThreshold = 1.0

Definition at line 68 of file qssgrendercamera_p.h.

Referenced by QSSGLayerRenderData::prepareForRender().

◆ previousInViewport

QRectF QSSGRenderCamera::previousInViewport

Definition at line 70 of file qssgrendercamera_p.h.

Referenced by calculateProjection().

◆ projection

◆ right

float QSSGRenderCamera::right = 0.0f

Definition at line 54 of file qssgrendercamera_p.h.

◆ top

float QSSGRenderCamera::top = 0.0f

Definition at line 51 of file qssgrendercamera_p.h.

◆ verticalMagnification

float QSSGRenderCamera::verticalMagnification = 1.0f

The documentation for this struct was generated from the following files: