Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquick3dsceneenvironment.cpp
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5#include "qquick3dobject_p.h"
6#include "qquick3dtexture_p.h"
9
11
121 : QQuick3DObject(*(new QQuick3DObjectPrivate(QQuick3DObjectPrivate::Type::SceneEnvironment)), parent)
122{
123 m_debugSettings = new QQuick3DDebugSettings(this);
124 m_debugSettingsSignalConnection = QObject::connect(m_debugSettings, &QQuick3DDebugSettings::changed, this,
125 [this] { update(); });
126 QObject::connect(m_debugSettings, &QObject::destroyed, this,
127 [this](QObject *obj) {
128 if (m_debugSettings == obj) {
129 m_debugSettings = nullptr;
130 update();
131 }
132 });
133}
134
138
217
247
362
375{
376 return m_clearColor;
377}
378
417{
418 return m_aoStrength;
419}
420
448{
449 return m_aoDistance;
450}
451
479{
480 return m_aoSoftness;
481}
482
501{
502 return m_aoDither;
503}
504
514{
515 return m_aoSampleRate;
516}
517
531{
532 return m_aoBias;
533}
534
704{
705 return m_lightProbe;
706}
707
723{
724 return m_probeExposure;
725}
726
752{
753 return m_probeHorizon;
754}
755
768{
769 return m_probeOrientation;
770}
771
792{
793 return m_temporalAAEnabled;
794}
795
808{
809 return m_temporalAAStrength;
810}
811
832{
833 return m_specularAAEnabled;
834}
835
872{
873 return m_depthTestEnabled;
874}
898{
899 return m_depthPrePassEnabled;
900}
901
913QQmlListProperty<QQuick3DEffect> QQuick3DSceneEnvironment::effects()
914{
915 return QQmlListProperty<QQuick3DEffect>(this,
916 nullptr,
917 QQuick3DSceneEnvironment::qmlAppendEffect,
918 QQuick3DSceneEnvironment::qmlEffectsCount,
919 QQuick3DSceneEnvironment::qmlEffectAt,
920 QQuick3DSceneEnvironment::qmlClearEffects);
921}
922
968
983{
984 return m_skyboxBlurAmount;
985}
986
1010{
1011 return m_debugSettings;
1012}
1013
1023{
1024 return m_scissorRect;
1025}
1026
1028{
1029 if (m_antialiasingMode == antialiasingMode)
1030 return;
1031
1032 m_antialiasingMode = antialiasingMode;
1034 update();
1035}
1036
1038{
1039 if (m_antialiasingQuality == antialiasingQuality)
1040 return;
1041
1042 m_antialiasingQuality = antialiasingQuality;
1044 update();
1045}
1046
1048{
1049 if (m_backgroundMode == backgroundMode)
1050 return;
1051
1052 m_backgroundMode = backgroundMode;
1054 update();
1055}
1056
1058{
1059 if (m_clearColor == clearColor)
1060 return;
1061
1062 m_clearColor = clearColor;
1064 update();
1065}
1066
1068{
1069 if (qFuzzyCompare(m_aoStrength, aoStrength))
1070 return;
1071
1072 m_aoStrength = aoStrength;
1073
1074 const bool aoEnabled = !(qFuzzyIsNull(m_aoStrength) || qFuzzyIsNull(m_aoDistance));
1075 setAoEnabled(aoEnabled);
1076
1078 update();
1079}
1080
1082{
1083 if (qFuzzyCompare(m_aoDistance, aoDistance))
1084 return;
1085
1086 m_aoDistance = aoDistance;
1087
1088 const bool aoEnabled = !(qFuzzyIsNull(m_aoStrength) || qFuzzyIsNull(m_aoDistance));
1089 setAoEnabled(aoEnabled);
1090
1092 update();
1093}
1094
1096{
1097 if (qFuzzyCompare(m_aoSoftness, aoSoftness))
1098 return;
1099
1100 m_aoSoftness = aoSoftness;
1102 update();
1103}
1104
1106{
1107 if (m_aoDither == aoDither)
1108 return;
1109
1110 m_aoDither = aoDither;
1112 update();
1113}
1114
1116{
1117 if (m_aoSampleRate == aoSampleRate)
1118 return;
1119
1120 m_aoSampleRate = aoSampleRate;
1122 update();
1123}
1124
1126{
1127 if (qFuzzyCompare(m_aoBias, aoBias))
1128 return;
1129
1130 m_aoBias = aoBias;
1132 update();
1133}
1134
1136{
1137 if (m_lightProbe == lightProbe)
1138 return;
1139
1141
1142 m_lightProbe = lightProbe;
1144 update();
1145}
1146
1148{
1149 if (qFuzzyCompare(m_probeExposure, probeExposure))
1150 return;
1151
1152 m_probeExposure = probeExposure;
1154 update();
1155}
1156
1158{
1159 // clamp value to expected range
1160 probeHorizon = qBound(0.0f, probeHorizon, 1.0f);
1161
1162 if (qFuzzyCompare(m_probeHorizon, probeHorizon))
1163 return;
1164
1165 m_probeHorizon = probeHorizon;
1167 update();
1168}
1169
1171{
1172 if (qFuzzyCompare(m_probeOrientation, orientation))
1173 return;
1174
1175 m_probeOrientation = orientation;
1177 update();
1178}
1179
1181{
1182 if (m_depthTestEnabled == depthTestEnabled)
1183 return;
1184
1185 m_depthTestEnabled = depthTestEnabled;
1187 update();
1188}
1189
1191{
1192 if (m_depthPrePassEnabled == depthPrePassEnabled)
1193 return;
1194
1195 m_depthPrePassEnabled = depthPrePassEnabled;
1197 update();
1198}
1199
1201{
1202 if (m_tonemapMode == tonemapMode)
1203 return;
1204
1205 m_tonemapMode = tonemapMode;
1207 update();
1208}
1209
1211{
1212 return true;
1213}
1214
1216{
1217 // Don't do anything, these properties get set by the scene renderer
1218 return node;
1219}
1220
1221void QQuick3DSceneEnvironment::itemChange(QQuick3DObject::ItemChange change, const QQuick3DObject::ItemChangeData &value)
1222{
1223 if (change == QQuick3DObject::ItemSceneChange)
1224 updateSceneManager(value.sceneManager);
1225}
1226
1227const QVector<QQuick3DEffect *> &QQuick3DSceneEnvironment::effectList() const
1228{
1229 return m_effects;
1230}
1231
1232void QQuick3DSceneEnvironment::updateSceneManager(QQuick3DSceneManager *manager)
1233{
1234 if (manager) {
1237 } else {
1240 }
1241}
1242
1244{
1245 if (m_temporalAAEnabled == temporalAAEnabled)
1246 return;
1247
1248 m_temporalAAEnabled = temporalAAEnabled;
1250 update();
1251}
1252
1254{
1255 if (qFuzzyCompare(m_temporalAAStrength, strength))
1256 return;
1257
1258 m_temporalAAStrength = strength;
1260 update();
1261}
1262
1263void QQuick3DSceneEnvironment::setSpecularAAEnabled(bool enabled)
1264{
1265 if (m_specularAAEnabled == enabled)
1266 return;
1267
1268 m_specularAAEnabled = enabled;
1269 emit specularAAEnabledChanged();
1270 update();
1271}
1272
1273void QQuick3DSceneEnvironment::qmlAppendEffect(QQmlListProperty<QQuick3DEffect> *list, QQuick3DEffect *effect)
1274{
1275 if (effect == nullptr)
1276 return;
1278 self->m_effects.push_back(effect);
1279
1280 if (effect->parentItem() == nullptr)
1281 effect->setParentItem(self);
1282
1283 for (QQuick3DEffect *e : self->m_effects)
1284 e->effectChainDirty();
1285
1286 self->update();
1287}
1288
1289QQuick3DEffect *QQuick3DSceneEnvironment::qmlEffectAt(QQmlListProperty<QQuick3DEffect> *list, qsizetype index)
1290{
1292 return self->m_effects.at(index);
1293}
1294
1295qsizetype QQuick3DSceneEnvironment::qmlEffectsCount(QQmlListProperty<QQuick3DEffect> *list)
1296{
1298 return self->m_effects.size();
1299}
1300
1301void QQuick3DSceneEnvironment::qmlClearEffects(QQmlListProperty<QQuick3DEffect> *list)
1302{
1304 self->m_effects.clear();
1305 self->update();
1306}
1307
1308void QQuick3DSceneEnvironment::setSkyboxBlurAmount(float newSkyboxBlurAmount)
1309{
1310 newSkyboxBlurAmount = qBound(0.0f, newSkyboxBlurAmount, 1.0f);
1311
1312 if (qFuzzyCompare(m_skyboxBlurAmount, newSkyboxBlurAmount))
1313 return;
1314
1315 m_skyboxBlurAmount = newSkyboxBlurAmount;
1316 emit skyboxBlurAmountChanged();
1317 update();
1318}
1319
1340{
1341 return m_lightmapper;
1342}
1343
1344void QQuick3DSceneEnvironment::setLightmapper(QQuick3DLightmapper *lightmapper)
1345{
1346 if (m_lightmapper == lightmapper)
1347 return;
1348
1349 if (m_lightmapper)
1350 m_lightmapper->disconnect(m_lightmapperSignalConnection);
1351
1352 m_lightmapper = lightmapper;
1353
1354 m_lightmapperSignalConnection = QObject::connect(m_lightmapper, &QQuick3DLightmapper::changed, this,
1355 [this] { update(); });
1356
1357 QObject::connect(m_lightmapper, &QObject::destroyed, this,
1358 [this](QObject *obj)
1359 {
1360 if (m_lightmapper == obj) {
1361 m_lightmapper = nullptr;
1362 update();
1363 }
1364 });
1365
1366 emit lightmapperChanged();
1367 update();
1368}
1369
1378{
1379 return m_skyBoxCubeMap;
1380}
1381
1382void QQuick3DSceneEnvironment::setSkyBoxCubeMap(QQuick3DCubeMapTexture *newSkyBoxCubeMap)
1383{
1384 if (m_skyBoxCubeMap == newSkyBoxCubeMap)
1385 return;
1386
1387 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DSceneEnvironment::setSkyBoxCubeMap, newSkyBoxCubeMap, m_skyBoxCubeMap);
1388
1389 m_skyBoxCubeMap = newSkyBoxCubeMap;
1390 emit skyBoxCubeMapChanged();
1391}
1392
1393void QQuick3DSceneEnvironment::setDebugSettings(QQuick3DDebugSettings *newDebugSettings)
1394{
1395 if (m_debugSettings == newDebugSettings)
1396 return;
1397
1398 if (m_debugSettings)
1399 m_debugSettings->disconnect(m_debugSettingsSignalConnection);
1400
1401 m_debugSettings = newDebugSettings;
1402
1403 m_debugSettingsSignalConnection = QObject::connect(m_debugSettings, &QQuick3DDebugSettings::changed, this,
1404 [this] { update(); });
1405 QObject::connect(m_debugSettings, &QObject::destroyed, this,
1406 [this](QObject *obj) {
1407 if (m_debugSettings == obj) {
1408 m_debugSettings = nullptr;
1409 update();
1410 }
1411 });
1412
1413 emit debugSettingsChanged();
1414 update();
1415}
1416
1417void QQuick3DSceneEnvironment::setScissorRect(QRect rect)
1418{
1419 if (m_scissorRect == rect)
1420 return;
1421
1422 m_scissorRect = rect;
1423 emit scissorRectChanged();
1424 update();
1425}
1426
1428{
1429 return m_gridEnabled;
1430}
1431
1433{
1434 if (m_gridEnabled == newGridEnabled)
1435 return;
1436 m_gridEnabled = newGridEnabled;
1437 update();
1438}
1439
1441{
1442 return m_gridScale;
1443}
1444
1446{
1447 if (qFuzzyCompare(m_gridScale, newGridScale))
1448 return;
1449 m_gridScale = newGridScale;
1450 update();
1451}
1452
1454{
1455 return m_gridFlags;
1456}
1457
1459{
1460 if (m_gridFlags == newGridFlags)
1461 return;
1462 m_gridFlags = newGridFlags;
1463 update();
1464}
1465
1487{
1488 return m_aoEnabled;
1489}
1490
1491void QQuick3DSceneEnvironment::setAoEnabled(bool newAoEnabled)
1492{
1493 if (m_aoEnabled == newAoEnabled)
1494 return;
1495
1496 m_aoEnabled = newAoEnabled;
1497
1498 if (m_aoEnabled) {
1499 if (qFuzzyIsNull(m_aoStrength))
1500 setAoStrength(100.0f);
1501 if (qFuzzyIsNull(m_aoDistance))
1502 setAoDistance(defaultAoDistance());
1503 }
1504
1505 emit aoEnabledChanged();
1506 update();
1507}
1508
1525{
1526 return m_fog;
1527}
1528
1529void QQuick3DSceneEnvironment::setFog(QQuick3DFog *fog)
1530{
1531 if (m_fog == fog)
1532 return;
1533
1534 if (m_fog)
1535 m_fog->disconnect(m_fogSignalConnection);
1536
1537 m_fog = fog;
1538
1539 m_fogSignalConnection = QObject::connect(m_fog, &QQuick3DFog::changed, this, [this] { update(); });
1540
1542 [this](QObject *obj)
1543 {
1544 if (m_fog == obj) {
1545 m_fog = nullptr;
1546 update();
1547 }
1548 });
1549
1550 emit fogChanged();
1551 update();
1552}
1553
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3236
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
void changed()
void refSceneManager(QQuick3DSceneManager &)
static void attachWatcher(Context *context, Setter setter, Object3D *newO, Object3D *oldO)
Attach a object-destroyed-watcher to an object that's not owned.
\qmltype Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DObject \inherits QtObject
QQuick3DDebugSettings * debugSettings
\qmlproperty QtQuick3D::DebugSettings QtQuick3D::SceneEnvironment::debugSettings
QRect scissorRect
\qmlproperty rect QtQuick3D::SceneEnvironment::scissorRect
QQuick3DCubeMapTexture * skyBoxCubeMap
\qmlproperty QtQuick3D::CubeMapTexture QtQuick3D::SceneEnvironment::skyBoxCubeMap
void itemChange(ItemChange, const ItemChangeData &) override
void setTonemapMode(QQuick3DSceneEnvironment::QQuick3DEnvironmentTonemapModes tonemapMode)
void setProbeOrientation(const QVector3D &orientation)
float skyboxBlurAmount
\qmlproperty float QtQuick3D::SceneEnvironment::skyboxBlurAmount
void setBackgroundMode(QQuick3DSceneEnvironment::QQuick3DEnvironmentBackgroundTypes backgroundMode)
void setDepthPrePassEnabled(bool depthPrePassEnabled)
QQuick3DSceneEnvironment(QQuick3DObject *parent=nullptr)
\qmltype SceneEnvironment \inherits Object3D \inqmlmodule QtQuick3D
QQuick3DEnvironmentAAModeValues antialiasingMode
void setGridScale(float newGridScale)
void setProbeHorizon(float probeHorizon)
QSSGRenderGraphObject * updateSpatialNode(QSSGRenderGraphObject *node) override
virtual const QVector< QQuick3DEffect * > & effectList() const
bool specularAAEnabled
\qmlproperty bool QtQuick3D::SceneEnvironment::specularAAEnabled
QQuick3DEnvironmentTonemapModes tonemapMode
QQmlListProperty< QQuick3DEffect > effects
\qmlproperty List<QtQuick3D::Effect> QtQuick3D::SceneEnvironment::effects
void setLightProbe(QQuick3DTexture *lightProbe)
void setGridEnabled(bool newGridEnabled)
void setAntialiasingQuality(QQuick3DSceneEnvironment::QQuick3DEnvironmentAAQualityValues antialiasingQuality)
void setAntialiasingMode(QQuick3DSceneEnvironment::QQuick3DEnvironmentAAModeValues antialiasingMode)
void setClearColor(const QColor &clearColor)
void setTemporalAAEnabled(bool temporalAAEnabled)
bool aoEnabled
\qmlproperty bool SceneEnvironment::aoEnabled
QQuick3DFog * fog
\qmlproperty QtQuick3D::Fog QtQuick3D::SceneEnvironment::fog
QQuick3DEnvironmentBackgroundTypes backgroundMode
void setDepthTestEnabled(bool depthTestEnabled)
QQuick3DLightmapper * lightmapper
\qmlproperty Lightmapper QtQuick3D::SceneEnvironment::lightmapper
void setProbeExposure(float probeExposure)
QQuick3DEnvironmentAAQualityValues antialiasingQuality
\inmodule QtCore\reentrant
Definition qrect.h:30
void clear()
Clears the contents of the string and makes it null.
Definition qstring.h:1252
qsizetype size() const noexcept
Returns the number of characters in this string.
Definition qstring.h:186
void push_back(QChar c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.h:957
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
Definition qstring.h:1226
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
rect
[4]
Combined button and popup list for selecting options.
QString self
Definition language.cpp:58
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:333
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:349
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
GLuint index
[2]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLhandleARB obj
[2]
#define emit
ptrdiff_t qsizetype
Definition qtypes.h:165
unsigned int uint
Definition qtypes.h:34
#define enabled
QList< int > list
[14]
QGraphicsOpacityEffect * effect
the effect attached to this item
QNetworkAccessManager manager
Definition moc.h:23