aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-08-18 11:12:44 +0200
committerQt Cherry-pick Bot <[email protected]>2025-08-20 05:45:44 +0000
commit9b182985b2dc69ee78242f64467937f0ad462632 (patch)
treeb4c861d3f7d2c2b7e56ea36d090b0121ed2803c5
parent9b828375fb746f11ac92ed18e02820ffd3f76488 (diff)
BenchFrustumCulling: fix pointless QQuaternion::fromEulerAngles() calls6.9
QQuaternion::fromEulerAngles({}) is fromEulerAngles(0, 0, 0), which is the identity quaternion (w=1, x=0, y=0, z=0). Use a constexpr global constant for this instead of forcing the compiler to re-evaluate this out-of-line function over and over again. Also fixes an ambiguity error caused by the addition of a fromEulerAngle() overload in QtBase. Amends b1a8f963b2b3dd0ee0e970ae958c544af7d4f340. Pick-to: 6.8 Change-Id: I0f3094695a8d4b09aadc58bf3092b1abae45e554 Reviewed-by: Volker Hilsheimer <[email protected]> (cherry picked from commit 6478aeefd7cb52c75fd516d870030bdd30ac032c) Reviewed-by: Qt Cherry-pick Bot <[email protected]> (cherry picked from commit cd261c72cbef30a2d76c46296a978dfb1ff1af9a)
-rw-r--r--tests/benchmarks/culling/frustumculling/tst_benchfrustumculling.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/benchmarks/culling/frustumculling/tst_benchfrustumculling.cpp b/tests/benchmarks/culling/frustumculling/tst_benchfrustumculling.cpp
index 5dc6ab18..df4b03de 100644
--- a/tests/benchmarks/culling/frustumculling/tst_benchfrustumculling.cpp
+++ b/tests/benchmarks/culling/frustumculling/tst_benchfrustumculling.cpp
@@ -110,6 +110,8 @@ void BenchFrustumCulling::test_frustumCulling()
}
+constexpr auto Identity = QQuaternion{1, 0, 0, 0};
+
void BenchFrustumCulling::bench_outputlist()
{
// bounds 10x10x10 all in world coordinates
@@ -133,14 +135,14 @@ void BenchFrustumCulling::bench_outputlist()
// Fill the list with object data that should be culled
for (quint32 i = 0, end = objectCount; i != end; ++i) {
if (i % 2)
- objects.push_back(createRenderableData({0.0f, 0.0f, frustumNearBorder }, QQuaternion::fromEulerAngles({}), bounds));
+ objects.push_back(createRenderableData({0.0f, 0.0f, frustumNearBorder }, Identity, bounds));
else
- objects.push_back(createRenderableData({0.0f, 0.0f, frustumFarBorder }, QQuaternion::fromEulerAngles({}), bounds));
+ objects.push_back(createRenderableData({0.0f, 0.0f, frustumFarBorder }, Identity, bounds));
}
// Insert items at random positions in the list that should not be culled
for (auto v : std::as_const(replaceIndexes))
- objects.replace(v, createRenderableData({0.0f, 0.0f, 0.0f}, QQuaternion::fromEulerAngles({}), bounds));
+ objects.replace(v, createRenderableData({0.0f, 0.0f, 0.0f}, Identity, bounds));
QCOMPARE(objects.size(), objectCount);
@@ -192,14 +194,14 @@ void BenchFrustumCulling::bench_inline()
// Fill the list with object data that should be culled
for (quint32 i = 0, end = objectCount; i != end; ++i) {
if (i % 2)
- objects.push_back(createRenderableData({0.0f, 0.0f, frustumNearBorder }, QQuaternion::fromEulerAngles({}), bounds));
+ objects.push_back(createRenderableData({0.0f, 0.0f, frustumNearBorder }, Identity, bounds));
else
- objects.push_back(createRenderableData({0.0f, 0.0f, frustumFarBorder }, QQuaternion::fromEulerAngles({}), bounds));
+ objects.push_back(createRenderableData({0.0f, 0.0f, frustumFarBorder }, Identity, bounds));
}
// Insert items at random positions in the list that should not be culled
for (auto v : std::as_const(replaceIndexes))
- objects.replace(v, createRenderableData({0.0f, 0.0f, 0.0f}, QQuaternion::fromEulerAngles({}), bounds));
+ objects.replace(v, createRenderableData({0.0f, 0.0f, 0.0f}, Identity, bounds));
QCOMPARE(objects.size(), objectCount);