36 enum class DirtyFlag : quint8
40 using FlagT = std::underlying_type_t<DirtyFlag>;
42 static constexpr DirtyFlag DirtyMask { std::numeric_limits<FlagT>::max() };
56 float horizontalMagnification = 1.0f;
57 float verticalMagnification = 1.0f;
61 QMatrix4x4 projection;
64 QVector2D frustumScale;
65 bool enableFrustumClipping;
66 FlagT cameraDirtyFlags = 0;
68 float levelOfDetailPixelThreshold = 1.0;
70 QRectF previousInViewport;
72 explicit QSSGRenderCamera(QSSGRenderGraphObject::Type type);
74 QMatrix3x3 getLookAtMatrix(
const QVector3D &inUpDir,
const QVector3D &inDirection)
const;
80 void lookAt(
const QVector3D &inCameraPos,
const QVector3D &inUpDir,
const QVector3D &inTargetPos,
const QVector3D &pivot);
82 QSSGCameraGlobalCalculationResult calculateGlobalVariables(
const QRectF &inViewport);
83 bool calculateProjection(
const QRectF &inViewport);
84 bool computeFrustumOrtho(
const QRectF &inViewport);
89 float getOrthographicScaleFactor(
const QRectF &inViewport)
const;
90 bool computeFrustumPerspective(
const QRectF &inViewport);
91 bool computeCustomFrustum(
const QRectF &inViewport);
93 static void calculateViewProjectionMatrix(
const QMatrix4x4 &globalTransform,
94 const QMatrix4x4 &projection,
95 QMatrix4x4 &outMatrix);
97 void calculateViewProjectionMatrix(QMatrix4x4 &outMatrix)
const;
98 void calculateViewProjectionMatrix(QMatrix4x4 &outMatrix,
float clipNear,
float clipFar)
const;
100 void calculateViewProjectionWithoutTranslation(
float near,
float far, QMatrix4x4 &outMatrix)
const;
104 QSSGRenderRay unproject(
const QVector2D &inLayerRelativeMouseCoords,
const QRectF &inViewport)
const;
109 QVector3D unprojectToPosition(
const QVector3D &inGlobalPos,
const QSSGRenderRay &inRay)
const;
111 float verticalFov(
float aspectRatio)
const;
112 float verticalFov(
const QRectF &inViewport)
const;
114 [[nodiscard]]
inline bool isDirty(DirtyFlag dirtyFlag = DirtyMask)
const
116 return ((cameraDirtyFlags & FlagT(dirtyFlag)) != 0)
117 || ((dirtyFlag == DirtyMask) && QSSGRenderNode::isDirty());
119 void markDirty(DirtyFlag dirtyFlag);
120 void clearDirty(DirtyFlag dirtyFlag);
122 float getLevelOfDetailMultiplier()
const;