diff --git a/.github/workflows/laigter-linux.yaml b/.github/workflows/laigter-linux.yaml index f3104a5..7288dbe 100644 --- a/.github/workflows/laigter-linux.yaml +++ b/.github/workflows/laigter-linux.yaml @@ -9,23 +9,28 @@ jobs: steps: - name: checkout sources - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: add build dependencies + - name: Install Dependencies + shell: bash run: | - apt update - apt install -y software-properties-common clang make wget libomp-dev - add-apt-repository ppa:beineri/opt-qt-5.15.2-focal - apt-get update - apt install -y qt515base qt515x11extras qt515tools libgl1-mesa-dev qt515imageformats - - - name: build Laigter + apt-get update && apt-get install -y sudo p7zip-full wget file + sudo ln -fs /usr/share/zoneinfo/UTC /etc/localtime + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends software-properties-common + + - name: Install Qt + uses: jurplel/install-qt-action@v4 + with: + version: '6.8.0' + arch: 'linux_gcc_64' + extra: '--external 7z' + modules: 'qtimageformats' + + - name: Build Laigter shell: bash run: | echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - source /opt/qt*/bin/qt*-env.sh || true - export CXX=clang++ - /opt/qt515/bin/qmake -spec linux-clang CONFIG+=release PREFIX=/usr + qmake CONFIG+=release PREFIX=/usr make -j$(nproc) make INSTALL_ROOT=appdir install find appdir/ @@ -37,7 +42,7 @@ jobs: ./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/*.desktop -extra-plugins=imageformats -appimage -verbose=2 - name: upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: test-artifact path: Laigter-x86_64.AppImage diff --git a/.github/workflows/laigter-mac.yaml b/.github/workflows/laigter-mac.yaml index 81f8271..43832af 100644 --- a/.github/workflows/laigter-mac.yaml +++ b/.github/workflows/laigter-mac.yaml @@ -6,18 +6,19 @@ jobs: runs-on: macOS-latest steps: - name: checkout sources - uses: actions/checkout@v2 - - name: setup Homebrew - shell: bash - run: | - rm /usr/local/bin/2to3* - export HOMEBREW_NO_AUTO_UPDATE=1 && export HOMEBREW_NO_INSTALL_CLEANUP=1 && brew update - HOMEBREW_VERBOSE_USING_DOTS=1 brew reinstall --verbose qt@5 - brew link qt@5 --force + uses: actions/checkout@v4 + + - name: Install Qt + uses: jurplel/install-qt-action@v4 + with: + version: '6.8.0' + extra: '--external 7z' + arch: 'clang_64' + modules: 'qtimageformats' + - name: build Laigter shell: bash run: | - export PATH="/usr/local/opt/qt@5/bin:$PATH" qmake CONFIG+=release PREFIX=/usr make -j$(nproc) make INSTALL_ROOT=appdir install @@ -29,7 +30,7 @@ jobs: zip -r laigter-mac.zip laigter.app - name: upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: mac-artifacts path: laigter-mac.zip diff --git a/.github/workflows/laigter-windows.yaml b/.github/workflows/laigter-windows.yaml index 00de75d..0d31d7d 100644 --- a/.github/workflows/laigter-windows.yaml +++ b/.github/workflows/laigter-windows.yaml @@ -8,15 +8,18 @@ jobs: steps: - name: checkout sources - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install Qt - uses: jurplel/install-qt-action@v2 + uses: jurplel/install-qt-action@v4 with: - version: '5.15.2' - modules: 'imageformats' - arch: win64_mingw81 + aqtversion: '==3.1.*' + version: '6.2.0' + arch: 'win64_mingw81' extra: '--external 7z' + target: 'desktop' + host: 'windows' + modules: 'qtimageformats' - name: Build Laigter shell: cmd @@ -30,7 +33,7 @@ jobs: tar.exe -a -c -f laigter-windows.zip laigter-windows - name: upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: mac-artifacts path: laigter-windows.zip diff --git a/gui/language_selector.cpp b/gui/language_selector.cpp index 0742021..f07e8e6 100644 --- a/gui/language_selector.cpp +++ b/gui/language_selector.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include LanguageSelector::LanguageSelector(QWidget *parent) : QDialog(parent), ui(new Ui::LanguageSelector) @@ -14,7 +14,7 @@ LanguageSelector::LanguageSelector(QWidget *parent) if (f.open(QIODevice::ReadOnly)) { QTextStream in(&f); - in.setCodec( QTextCodec::codecForName( "UTF-8" ) ); + in.setEncoding( QStringConverter::Utf8 ); while (!in.atEnd()) { QStringList line = in.readLine().split("\t"); diff --git a/gui/presets_manager.cpp b/gui/presets_manager.cpp index 137e7b4..bbc094a 100644 --- a/gui/presets_manager.cpp +++ b/gui/presets_manager.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include static QString presetCodes[30] = {"EnhanceHeight ", @@ -161,7 +161,7 @@ void PresetsManager::on_pushButtonSavePreset_clicked() if (preset.open(QIODevice::WriteOnly)) { QTextStream in(&preset); - in.setCodec(QTextCodec::codecForName("UTF-8")); + in.setEncoding(QStringConverter::Utf8); in << "[Laigter Preset]"; bool saveLights = false; QTreeWidgetItemIterator it(ui->treeWidget); @@ -519,7 +519,7 @@ void PresetsManager::SaveAllPresets(ImageProcessor *p, QString path) { QTextStream in(&preset); in << "[Laigter Preset]"; - in.setCodec(QTextCodec::codecForName("UTF-8")); + in.setEncoding(QStringConverter::Utf8); for (int i = 0; i < 30; i++) { in << "\n" diff --git a/gui/presets_manager.ui b/gui/presets_manager.ui index d060ad9..63d3b63 100644 --- a/gui/presets_manager.ui +++ b/gui/presets_manager.ui @@ -77,7 +77,8 @@ - + + .. @@ -102,7 +103,8 @@ - + + .. @@ -121,7 +123,8 @@ - + + .. @@ -208,7 +211,7 @@ Checked - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -221,7 +224,7 @@ - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -233,6 +236,9 @@ 0 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -244,6 +250,9 @@ 1 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -257,7 +266,7 @@ - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -269,6 +278,9 @@ 2 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -280,6 +292,9 @@ 3 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -291,6 +306,9 @@ 4 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -302,6 +320,9 @@ 5 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -315,7 +336,7 @@ - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -327,6 +348,9 @@ 7 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -338,6 +362,9 @@ 8 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -352,7 +379,7 @@ 6 - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -363,7 +390,7 @@ Checked - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -375,6 +402,9 @@ 9 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -387,7 +417,7 @@ - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -399,6 +429,9 @@ 10 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -410,6 +443,9 @@ 11 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -421,6 +457,9 @@ 13 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -432,6 +471,9 @@ 14 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -444,6 +486,9 @@ 12 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -453,7 +498,7 @@ Checked - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -465,6 +510,9 @@ 15 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -476,6 +524,9 @@ 16 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -488,6 +539,9 @@ 17 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -498,7 +552,7 @@ Checked - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -511,7 +565,7 @@ 18 - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -525,7 +579,7 @@ 19 - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -539,7 +593,7 @@ 20 - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -553,7 +607,7 @@ 21 - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -567,7 +621,7 @@ 22 - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -579,7 +633,7 @@ Checked - ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable|ItemIsEnabled|ItemIsTristate + NoItemFlags @@ -591,6 +645,9 @@ 23 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -602,6 +659,9 @@ 24 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -613,6 +673,9 @@ 25 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -624,6 +687,9 @@ 26 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -635,6 +701,9 @@ 27 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -646,6 +715,9 @@ 28 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + @@ -657,6 +729,9 @@ 29 + + ItemIsSelectable|ItemIsDragEnabled|ItemIsDropEnabled|ItemIsUserCheckable + diff --git a/gui/widgets/slider.cpp b/gui/widgets/slider.cpp index 06aa02f..097fa41 100644 --- a/gui/widgets/slider.cpp +++ b/gui/widgets/slider.cpp @@ -1,4 +1,6 @@ #include "slider.h" +#include "qevent.h" +#include "qscreen.h" #include @@ -6,6 +8,7 @@ #include #include #include +#include Slider::Slider(QWidget *parent) : QSlider(parent) { @@ -17,9 +20,6 @@ Slider::Slider(QWidget *parent) : QSlider(parent) connect(&spin_box, SIGNAL(valueChanged(int)), this, SLOT(setValue(int))); connect(this, SIGNAL(rangeChanged(int,int)), this, SLOT(setSpinBoxRange(int,int))); - // QFile style(":/styles/spinboxslider.qss"); - // style.open(QIODevice::ReadOnly); - // setStyleSheet(style.readAll()); } Slider::Slider(Qt::Orientation orientation, QWidget *parent) @@ -31,8 +31,7 @@ void Slider::setValueFromSpinBox(int v) { setValue(v * maximum() / 100.0); } void Slider::setValueToSpinBox(int v) { - Q_UNUSED(v) - spin_box.setValue(value() * 100.0 / maximum()); + spin_box.setValue(v * 100.0 / maximum()); } void Slider::setSpinBoxRange(int min, int max) @@ -47,11 +46,8 @@ void Slider::resizeEvent(QResizeEvent *ev) setMinimumSize(QSize(50, 20)); QString num = QString::number(value()); QFontMetrics fm(spin_box.font()); - spin_box.resize(fm.size(Qt::TextSingleLine, num + " ").width(), 20); - // spin_box.move(0.5*width()*value()/maximum()-0.5*value()/maximum()*spin_box.width(), - // height()/2-spin_box.height()/2); - // spin_box.move(0.5*value()/maximum()*spin_box.width(), - // height()/2-spin_box.height()/2); + int width = fm.size(Qt::TextSingleLine, num + " ").width() + handler_min / 2; + spin_box.resize(width, 20); } void Slider::sliderChange(QAbstractSlider::SliderChange change) @@ -61,19 +57,15 @@ void Slider::sliderChange(QAbstractSlider::SliderChange change) { QString num = QString::number(value()); QFontMetrics fm(spin_box.font()); - spin_box.resize(fm.size(Qt::TextSingleLine, num + " ").width(), 20); - // spin_box.move(0.5*width()*value()/maximum()-0.5*value()/maximum()*spin_box.width(), - // height()/2-spin_box.height()/2); + int width = fm.size(Qt::TextSingleLine, num + " ").width() + handler_min / 2; + spin_box.resize(width, 20); } } void Slider::paintEvent(QPaintEvent *ev) { QSlider::paintEvent(ev); - QRect rect(1.0 * (width() - 12.0) * (value() - minimum()) / - (maximum() - minimum()) + - 37.0 * (maximum() - value()) / (maximum() - minimum()), - 8, 4, 4); + QRect rect(1.0 * (width() - handler_right_offset) * (value() - minimum()) / (maximum() - minimum()) + handler_min * (maximum() - value()) / (maximum() - minimum()), 8, 4, 4); QPainter painter(this); if (isEnabled()) @@ -87,3 +79,25 @@ void Slider::mouseDoubleClickEvent( QMouseEvent * e ){ spin_box.setFocus(); spin_box.selectAll(); } + + +void Slider::mousePressEvent(QMouseEvent *event) +{ + + QPointF new_position = event->position(); + new_position.setX(0.5*handler_min * (event->position().x() - width()) / (handler_min - width()) + + (width() - handler_right_offset)*(event->position().x() - handler_min) / (width()- handler_min)); + event = new QMouseEvent(event->type(), new_position, new_position + pos(), event->button(), event->buttons(), event->modifiers()); QSlider::mousePressEvent(event); + delete event; + +} + +void Slider::mouseMoveEvent(QMouseEvent *event) +{ + QPointF new_position = event->position(); + new_position.setX(0.5*handler_min * (event->position().x() - width()) / (handler_min - width()) + + (width() - handler_right_offset)*(event->position().x() - handler_min) / (width()- handler_min)); + event = new QMouseEvent(event->type(), new_position, this->mapToGlobal(new_position), event->button(), event->buttons(), event->modifiers()); + QSlider::mouseMoveEvent(event); + delete event; +} diff --git a/gui/widgets/slider.h b/gui/widgets/slider.h index 3695422..34db628 100644 --- a/gui/widgets/slider.h +++ b/gui/widgets/slider.h @@ -13,6 +13,8 @@ class Slider : public QSlider QSpinBox spin_box; public: + int handler_min = 37; + int handler_right_offset = 12; explicit Slider(QWidget *parent = nullptr); explicit Slider(Qt::Orientation orientation, QWidget *parent = nullptr); @@ -26,6 +28,8 @@ private slots: void setSpinBoxRange(int min, int max); void setValueFromSpinBox(int v); void setValueToSpinBox(int v); + void mousePressEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; signals: void resized(); diff --git a/gui/widgets/slider2.cpp b/gui/widgets/slider2.cpp index 018b4e1..a3ab23f 100644 --- a/gui/widgets/slider2.cpp +++ b/gui/widgets/slider2.cpp @@ -15,8 +15,8 @@ Slider2::Slider2(QWidget *parent) : QSlider(parent) spin_box.setAlignment(Qt::AlignCenter); connect(this, SIGNAL(valueChanged(int)), &spin_box, SLOT(setValue(int))); connect(&spin_box, SIGNAL(valueChanged(int)), this, SLOT(setValue(int))); - connect(this, SIGNAL(rangeChanged(int, int)), this, - SLOT(setSpinBoxRange(int, int))); + connect(this, SIGNAL(rangeChanged(int,int)), this, + SLOT(setSpinBoxRange(int,int))); QFile style(":/styles/spin_box_slider2.qss"); style.open(QIODevice::ReadOnly); setStyleSheet(style.readAll()); @@ -31,7 +31,7 @@ void Slider2::setValueFromSpinBox(int v) { setValue(v * maximum() / 100.0); } void Slider2::setValueToSpinBox(int v) { - spin_box.setValue(value() * 100.0 / maximum()); + spin_box.setValue(v * 100.0 / maximum()); } void Slider2::setSpinBoxRange(int min, int max) @@ -46,8 +46,8 @@ void Slider2::resizeEvent(QResizeEvent *ev) setMinimumSize(QSize(50, 20)); QString num = QString::number(spin_box.value()); QFontMetrics fm(spin_box.font()); - spin_box.resize(width(), 15); - spin_box.move(0.5 * width() - 0.5 * spin_box.width(), 0); + spin_box.resize(fm.size(Qt::TextSingleLine, num).width(), 15); + spin_box.move(0.5 * fm.size(Qt::TextSingleLine, num).width() - 0.5 * spin_box.width(), 0); } void Slider2::sliderChange(QAbstractSlider::SliderChange change) @@ -57,7 +57,8 @@ void Slider2::sliderChange(QAbstractSlider::SliderChange change) { QString num = QString::number(spin_box.value()); QFontMetrics fm(spin_box.font()); - spin_box.resize(width(), 15); + + spin_box.resize(fm.size(Qt::TextSingleLine, num).width(), 15); spin_box.move(0.5 * width() - 0.5 * spin_box.width(), 0); } } diff --git a/laigter.pro b/laigter.pro index 1f8e19f..d3a8254 100644 --- a/laigter.pro +++ b/laigter.pro @@ -21,7 +21,7 @@ # #------------------------------------------------- -QT += core gui widgets network +QT += core gui widgets network opengl openglwidgets TARGET = laigter TEMPLATE = app diff --git a/main_window.cpp b/main_window.cpp index 2a7c426..20b7caf 100644 --- a/main_window.cpp +++ b/main_window.cpp @@ -469,7 +469,7 @@ ImageProcessor *MainWindow::find_processor(QString name) return nullptr; } -QStringList MainWindow::FindSimilarFiles(QString file_name, QStringList checkedFiles, QString *prefix) +QStringList MainWindow::FindSimilarFiles(QString file_name, QStringList checkedFiles, QString &prefix) { /* Check for auto loading of frames */ @@ -481,10 +481,10 @@ QStringList MainWindow::FindSimilarFiles(QString file_name, QStringList checkedF QRegularExpression rx("((\\d+)(?!.*\\d))"); QRegularExpressionMatch match = rx.match(info.fileName()); QStringList parts = file_name.split("/").last().split(match.captured(0)); - *prefix = parts.first(); + prefix = parts.first(); postfix = parts.last(); QDir dir = info.absoluteDir(); - if (*prefix != "") + if (prefix != "") { foreach (QString file, dir.entryList()) { @@ -518,7 +518,7 @@ void MainWindow::open_files(QStringList fileNames) if (reader.imageCount() <= 1) { - similarList = FindSimilarFiles(fileName, checkedFiles, &prefix); + similarList = FindSimilarFiles(fileName, checkedFiles, prefix); if (similarList.count() == 0) { diff --git a/main_window.h b/main_window.h index 3957a6a..c1cc659 100644 --- a/main_window.h +++ b/main_window.h @@ -89,7 +89,7 @@ class MainWindow : public QMainWindow void SaveProject(QString path); void LoadProject(QString path); bool ExportMap(TextureTypes type, ImageProcessor *p, QString postfix, QString destination = "", bool useAlpha = false); - QStringList FindSimilarFiles(QString file_name, QStringList checkedFiles, QString *prefix); + QStringList FindSimilarFiles(QString file_name, QStringList checkedFiles, QString &prefix); public slots: ImageProcessor *find_processor(QString name); diff --git a/src/image_processor.cpp b/src/image_processor.cpp index 5fc229d..737faca 100644 --- a/src/image_processor.cpp +++ b/src/image_processor.cpp @@ -26,9 +26,20 @@ using namespace cimg_library; +void SetAlphaChannel(const QImage &src, QImage &dst) +{ + for (int y = 0; y < dst.height(); ++y) { + const QRgb *srcLine = reinterpret_cast(src.constScanLine(y)); + uchar *destLine = dst.scanLine(y); + for (int x = 0; x < src.width(); ++x) { + destLine[x] = qAlpha(srcLine[x]); + } + } +} + ImageProcessor::ImageProcessor(QObject *parent) : QObject(parent) { - position = offset = QVector2D(0, 0); + position = offset = QVector3D(0, 0, 0); zoom = 1.0; selected = false; normal_bisel_depth = 100; @@ -200,25 +211,26 @@ void ImageProcessor::recalculate() { normal_mutex.unlock(); - QtConcurrent::run(this, &ImageProcessor::generate_normal_map, enhance_requested, bump_requested, - distance_requested, rect_requested); + bool updateEnhance = enhance_requested, updateBump = bump_requested, updateDistance = distance_requested; + QRect rect = rect_requested; + QtConcurrent::run([=](){this->generate_normal_map(updateEnhance, updateBump, updateDistance, rect);}); enhance_requested = bump_requested = distance_requested = false; rect_requested = QRect(0, 0, 0, 0); normal_counter = 0; } if (specular_counter > 0) { - QtConcurrent::run(this, &ImageProcessor::calculate_specular); + QtConcurrent::run([this](){this->calculate_specular();}); specular_counter = 0; } if (parallax_counter > 0) { - QtConcurrent::run(this, &ImageProcessor::calculate_parallax); + QtConcurrent::run([this](){this->calculate_parallax();}); parallax_counter = 0; } if (occlussion_counter > 0) { - QtConcurrent::run(this, &ImageProcessor::calculate_occlusion); + QtConcurrent::run([this](){this->calculate_occlusion();}); occlussion_counter = 0; } } @@ -1049,7 +1061,7 @@ QImage *ImageProcessor::get_normal() sprite.get_image(TextureTypes::Normal, &last_normal); if (useNormalAlpha) { - last_normal.setAlphaChannel(texture.alphaChannel()); + SetAlphaChannel(texture, last_normal); } return &last_normal; } @@ -1059,7 +1071,7 @@ QImage *ImageProcessor::get_parallax() sprite.get_image(TextureTypes::Parallax, &last_parallax); if (useParallaxAlpha) { - last_parallax.setAlphaChannel(texture.alphaChannel()); + SetAlphaChannel(texture, last_parallax); } return &last_parallax; } @@ -1069,7 +1081,7 @@ QImage *ImageProcessor::get_specular() sprite.get_image(TextureTypes::Specular, &last_specular); if (useSpecularAlpha) { - last_specular.setAlphaChannel(texture.alphaChannel()); + SetAlphaChannel(texture, last_specular); } return &last_specular; } @@ -1079,7 +1091,7 @@ QImage *ImageProcessor::get_occlusion() sprite.get_image(TextureTypes::Occlussion, &last_occlussion); if (useOcclusionAlpha) { - last_occlussion.setAlphaChannel(texture.alphaChannel()); + SetAlphaChannel(texture, last_occlussion); } return &last_occlussion; } @@ -1399,11 +1411,6 @@ QImage ImageProcessor::get_heightmap() return heightmap.copy(); } -QImage ImageProcessor::get_distance_map() -{ - /* Implement this ? */ -} - void ImageProcessor::set_light_list(QList &list) { lightList.clear(); diff --git a/src/image_processor.h b/src/image_processor.h index f19b185..c86647e 100644 --- a/src/image_processor.h +++ b/src/image_processor.h @@ -262,7 +262,6 @@ class ImageProcessor : public QObject QImage *get_parallax(); QImage *get_specular(); QImage *get_texture(); - QImage get_distance_map(); QImage get_heightmap(); QString get_heightmap_path(); QString get_name(); diff --git a/src/open_gl_widget.cpp b/src/open_gl_widget.cpp index 817eed1..8944281 100644 --- a/src/open_gl_widget.cpp +++ b/src/open_gl_widget.cpp @@ -185,7 +185,7 @@ void OpenGlWidget::update_scene() glViewport(0, 0, m_width, m_height); QVector3D color; - double r, g, b; + float r, g, b; GLfloat bkColor[4]; glGetFloatv(GL_COLOR_CLEAR_VALUE, bkColor); @@ -738,7 +738,7 @@ void OpenGlWidget::mousePressEvent(QMouseEvent *event) float lightWidth = (float)laigter.width() * 0.25; float lightHeight = (float)laigter.height() * 0.25; - if (event->buttons() & (Qt::LeftButton | Qt::MidButton)) + if (event->buttons() & (Qt::LeftButton | Qt::MiddleButton)) { if (addLight) { @@ -961,7 +961,7 @@ void OpenGlWidget::mouseMoveEvent(QMouseEvent *event) } need_to_update = true; } - else if (event->buttons() & Qt::MidButton) + else if (event->buttons() & Qt::MiddleButton) { origin += QVector3D(global_mouse_last_position - global_mouse_press_position); updateView(); @@ -1298,7 +1298,7 @@ QImage OpenGlWidget::calculate_preview(bool fullPreview) glClear(GL_COLOR_BUFFER_BIT); QVector3D color; - double r, g, b; + float r, g, b; GLfloat bkColor[4]; glGetFloatv(GL_COLOR_CLEAR_VALUE, bkColor); @@ -1484,7 +1484,7 @@ QImage OpenGlWidget::get_preview(bool fullPreview, bool autosave, void OpenGlWidget::apply_light_params(QMatrix4x4 projection, QMatrix4x4 view) { - double r, g, b; + float r, g, b; QVector3D color; QList currentLightList;