Skip to content

Commit 9ea433c

Browse files
committed
[qtAliceVision] PhongImageViewer: Use std::pow instead of std::powf
`std::powf` fails to compile with gcc which is not compliant with C++17 when it comes to libstdc++. Additionally, static casts are performed to fix warnings.
1 parent c1fe5f1 commit 9ea433c

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/qtAliceVision/PhongImageViewer.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,10 @@ QSGNode* PhongImageViewer::updatePaintNode(QSGNode* oldNode, QQuickItem::UpdateP
349349
}
350350
else
351351
{
352-
const float windowRatio = _boundingRect.width() / _boundingRect.height();
353-
const float textureRatio = _textureSize.width() / float(_textureSize.height());
352+
const float windowRatio = static_cast<float>(_boundingRect.width()) /
353+
static_cast<float>(_boundingRect.height());
354+
const float textureRatio = static_cast<float>(_textureSize.width()) /
355+
static_cast<float>(_textureSize.height());
354356
QRectF geometryRect = _boundingRect;
355357

356358
if (windowRatio > textureRatio)
@@ -388,6 +390,8 @@ QSGNode* PhongImageViewer::updatePaintNode(QSGNode* oldNode, QQuickItem::UpdateP
388390
case EChannelMode::A:
389391
channelOrder = QVector4D(3.f, 3.f, 3.f, -1.f);
390392
break;
393+
default:
394+
break;
391395
}
392396

393397
node->setSourceParameters(channelOrder, _gamma, _gain);
@@ -400,13 +404,21 @@ QSGNode* PhongImageViewer::updatePaintNode(QSGNode* oldNode, QQuickItem::UpdateP
400404
if (isNewNode || _shadingParametersChanged)
401405
{
402406
// light direction from Yaw and Pitch
403-
const Eigen::AngleAxis<double> yawA(static_cast<double>(aliceVision::degreeToRadian(_lightYaw)), Eigen::Vector3d::UnitY());
404-
const Eigen::AngleAxis<double> pitchA(static_cast<double>(aliceVision::degreeToRadian(_lightPitch)), Eigen::Vector3d::UnitX());
405-
const aliceVision::Vec3 direction = yawA.toRotationMatrix() * pitchA.toRotationMatrix() * aliceVision::Vec3(0.0, 0.0, -1.0);
406-
const QVector3D lightDirection(direction.x(), direction.y(), direction.z());
407+
const Eigen::AngleAxis<double> yawA(static_cast<double>(aliceVision::degreeToRadian(_lightYaw)),
408+
Eigen::Vector3d::UnitY());
409+
const Eigen::AngleAxis<double> pitchA(static_cast<double>(aliceVision::degreeToRadian(_lightPitch)),
410+
Eigen::Vector3d::UnitX());
411+
const aliceVision::Vec3 direction = yawA.toRotationMatrix() * pitchA.toRotationMatrix() *
412+
aliceVision::Vec3(0.0, 0.0, -1.0);
413+
const QVector3D lightDirection(static_cast<float>(direction.x()),
414+
static_cast<float>(direction.y()),
415+
static_cast<float>(direction.z()));
407416

408417
// linear base color from QColor
409-
const QVector4D baseColor(std::powf(_baseColor.redF(), 2.2), std::powf(_baseColor.greenF(), 2.2), std::powf(_baseColor.blueF(), 2.2), _baseColor.alphaF());
418+
const QVector4D baseColor(std::pow(static_cast<float>(_baseColor.redF()), 2.2f),
419+
std::pow(static_cast<float>(_baseColor.greenF()), 2.2f),
420+
std::pow(static_cast<float>(_baseColor.blueF()), 2.2f),
421+
_baseColor.alphaF());
410422

411423
node->setShadingParameters(baseColor, lightDirection, _textureOpacity, _ka, _kd, _ks, _shininess);
412424

0 commit comments

Comments
 (0)