From e52570c89f4c59b2e3f599e21dd8eb2e5e253e89 Mon Sep 17 00:00:00 2001 From: Mike Solar Date: Sun, 12 Jul 2026 15:47:14 +0800 Subject: [PATCH] Add diagnostics and robust direction reading for OCIO LUT node - Introduce ReadDirectionInput() helper that accepts both integer and string ('Forward'/'Inverse') representations of the direction combo. - Log every processor creation with the raw direction value and the OCIO transform direction being used, along with whether it is main or worker. - This helps determine why Forward/Inverse switching reportedly has no effect in the viewer/worker. Tests still pass. --- app/node/color/ociolut/ociolut.cpp | 40 +++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/app/node/color/ociolut/ociolut.cpp b/app/node/color/ociolut/ociolut.cpp index 43b505138..af63dd774 100644 --- a/app/node/color/ociolut/ociolut.cpp +++ b/app/node/color/ociolut/ociolut.cpp @@ -50,6 +50,29 @@ bool IsMainProcess() return qobject_cast(QCoreApplication::instance()) != nullptr; } +int ReadDirectionInput(const Node *node) +{ + QVariant v = node->GetStandardValue(OCIOLutNode::kDirectionInput); + + bool ok = false; + int direction = v.toInt(&ok); + if (ok) { + return direction; + } + + // Some old serializers stored the combo value as a string. + const QString s = v.toString().toLower(); + if (s == QStringLiteral("forward") || s == QStringLiteral("0")) { + return 0; + } + if (s == QStringLiteral("inverse") || s == QStringLiteral("1")) { + return 1; + } + + qWarning() << "OCIOLutNode: unexpected direction value" << v; + return 0; +} + } // namespace OCIOLutNode::OCIOLutNode() @@ -162,7 +185,7 @@ void OCIOLutNode::EnsureProcessor() const if (!processor_dirty_ && last_processor_ && GetStandardValue(kFileInput).toString() == last_path_ && - GetStandardValue(kDirectionInput).toInt() == last_direction_) { + ReadDirectionInput(this) == last_direction_) { return; } @@ -181,7 +204,7 @@ bool OCIOLutNode::CreateProcessorFromInputs() const } const QString path = GetStandardValue(kFileInput).toString(); - const int direction = GetStandardValue(kDirectionInput).toInt(); + const int direction = ReadDirectionInput(this); if (path.isEmpty()) { const_cast(this)->set_processor(nullptr); @@ -222,14 +245,19 @@ bool OCIOLutNode::CreateProcessorFromInputs() const ColorProcessorPtr processor; try { + const bool forward = + static_cast(direction) == + ColorProcessor::kNormal; + qDebug() << "OCIOLutNode: creating processor for" << path + << "direction=" << direction + << "ocio_dir=" << (forward ? "FORWARD" : "INVERSE") + << "process=" << (IsMainProcess() ? "main" : "worker"); + OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create(); transform->setSrc(path.toUtf8().constData()); transform->setInterpolation(OCIO::INTERP_LINEAR); transform->setDirection( - static_cast(direction) == - ColorProcessor::kNormal - ? OCIO::TRANSFORM_DIR_FORWARD - : OCIO::TRANSFORM_DIR_INVERSE); + forward ? OCIO::TRANSFORM_DIR_FORWARD : OCIO::TRANSFORM_DIR_INVERSE); processor = ColorProcessor::Create(manager()->GetConfig()->getProcessor(transform)); } catch (const std::exception &e) {