From 96a004e029c0eba5ee96b6a5c6efc88d003234b0 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sun, 23 Mar 2025 17:41:25 -0400 Subject: [PATCH] Cleanup. --- src/app/qtkscene.cpp | 12 +++--------- src/designer-plugins/toolbox.cpp | 4 ++-- src/designer-plugins/toolbox.h | 7 +++---- src/qtk/object.h | 2 ++ 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/app/qtkscene.cpp b/src/app/qtkscene.cpp index 4fe51e9..4322432 100644 --- a/src/app/qtkscene.cpp +++ b/src/app/qtkscene.cpp @@ -482,15 +482,9 @@ void QtkScene::update() myCube->getTransform().rotate(-0.75f, 0.0f, 1.0f, 0.0f); } - // Helper lambda to set the light position used by GLSL shaders on the model. - // TODO: This could be a helper function on the Model class. - auto setLightPosition = [](const std::string & lightName, Model * model) { - - }; - QMatrix4x4 posMatrix; if (auto alien = getModel("alienTest"); alien) { - setLightPosition("alienTestLight", alien); + alien->setLightPosition("alienTestLight"); alien->setUniform("uCameraPosition", cameraPosition); posMatrix = alien->getTransform().toMatrix(); @@ -502,7 +496,7 @@ void QtkScene::update() } if (auto spartan = getModel("spartanTest"); spartan) { - setLightPosition("spartanTestLight", spartan); + spartan->setLightPosition("spartanTestLight"); spartan->setUniform("uCameraPosition", cameraPosition); posMatrix = spartan->getTransform().toMatrix(); @@ -514,7 +508,7 @@ void QtkScene::update() } if (auto phong = getModel("testPhong"); phong) { - setLightPosition("testLight", phong); + phong->setLightPosition("testLight"); phong->getTransform().rotate(0.75f, 1.0f, 0.5f, 0.0f); phong->bindShaders(); diff --git a/src/designer-plugins/toolbox.cpp b/src/designer-plugins/toolbox.cpp index eb3b768..4d57129 100644 --- a/src/designer-plugins/toolbox.cpp +++ b/src/designer-plugins/toolbox.cpp @@ -123,8 +123,8 @@ void ToolBox::refreshProperties(const Object * object) void ToolBox::refreshShaders(const Object * object) { - vertex_.path.setItem(object->getVertexShader().c_str()); + vertex_.path.setValue(object->getVertexShader().c_str()); vertex_.editor->setText(object->getVertexShaderSourceCode().c_str()); - fragment_.path.setItem(object->getFragmentShader().c_str()); + fragment_.path.setValue(object->getFragmentShader().c_str()); fragment_.editor->setText(object->getFragmentShaderSourceCode().c_str()); } diff --git a/src/designer-plugins/toolbox.h b/src/designer-plugins/toolbox.h index 2ab4fbd..e0dfe4f 100644 --- a/src/designer-plugins/toolbox.h +++ b/src/designer-plugins/toolbox.h @@ -63,10 +63,9 @@ namespace Qtk label(new QLabel(tr(l), parent)), value(new QLabel(tr(v), parent)) { - value->setText(v); } - void setItem(const QString & v) { setItem(label->text(), v); } + void setValue(const QString & v) { value->setText(v); } void setItem(const QString & l, const QString & v) { @@ -121,7 +120,7 @@ namespace Qtk explicit SpinBox3D(QWidget * parent, const char * l = "SpinBox3D:"); /// The main layout for the SpinBox3D widget. - QHBoxLayout * layout {this}; + QHBoxLayout * layout; /// Label for the SpinBox3D. QLabel * label; @@ -161,7 +160,7 @@ namespace Qtk class ShaderView final : QWidget { public: - explicit ShaderView(QWidget * parent = nullptr, + explicit ShaderView(QWidget * parent, const char * l = "ShaderView:") : layout(new QVBoxLayout(this)), path(parent, l), editor(new QTextEdit(parent)) diff --git a/src/qtk/object.h b/src/qtk/object.h index 14cf28e..046ce0e 100644 --- a/src/qtk/object.h +++ b/src/qtk/object.h @@ -251,6 +251,8 @@ namespace Qtk /** * Helper to disconnect a QObject connection, only if it's valid. * If the connection is valid and we fail to disconnect log a message. + * + * @param con QObject connection handle to disconnect. */ static void disconnect(const QMetaObject::Connection & con) {