diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index 9860fc080..9a7a199e7 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -36,6 +36,7 @@ #include #include "Code/QRDUtils.h" #include "Code/Resources.h" +#include "Windows/Dialogs/AxisMappingDialog.h" #include "ui_BufferViewer.h" static const uint32_t MaxVisibleRows = 10000; @@ -70,7 +71,7 @@ enum #error "Unknown platform! Define NativeScanCode" #endif }; -}; +}; // namespace NativeScanCode namespace NativeVirtualKey { @@ -101,7 +102,7 @@ enum #error "Unknown platform! Define NativeVirtualKey" #endif }; -}; +}; // namespace NativeVirtualKey class CameraWrapper { @@ -2167,6 +2168,11 @@ BufferViewer::BufferViewer(ICaptureContext &ctx, bool meshview, QWidget *parent) ui->matrixType->addItems({tr("Perspective"), tr("Orthographic")}); + ui->axisMappingCombo->addItems({tr("Y-up, left handed"), tr("Y-up, right handed"), + tr("Z-up, left handed"), tr("Z-up, right handed"), + tr("Custom...")}); + ui->axisMappingCombo->setCurrentIndex(0); + // wireframe only available on solid shaded options ui->wireframeRender->setEnabled(false); @@ -2688,7 +2694,6 @@ void BufferViewer::OnEventChanged(uint32_t eventId) QPointer me(this); m_Ctx.Replay().AsyncInvoke([this, me, bufdata](IReplayController *r) { - if(!me) return; @@ -2945,7 +2950,18 @@ void BufferViewer::populateBBox(PopulateBufferData *bufdata) QVariant BufferViewer::persistData() { - QVariantMap state = ui->dockarea->saveState(); + QVariantMap state; + state[lit("dockarea")] = ui->dockarea->saveState(); + state[lit("axisMappingIndex")] = ui->axisMappingCombo->currentIndex(); + QVariantList xAxisMapping = {QVariant(m_Config.xAxisMapping.x), QVariant(m_Config.xAxisMapping.y), + QVariant(m_Config.xAxisMapping.z)}; + state[lit("xAxisMapping")] = xAxisMapping; + QVariantList yAxisMapping = {QVariant(m_Config.yAxisMapping.x), QVariant(m_Config.yAxisMapping.y), + QVariant(m_Config.yAxisMapping.z)}; + state[lit("yAxisMapping")] = yAxisMapping; + QVariantList zAxisMapping = {QVariant(m_Config.zAxisMapping.x), QVariant(m_Config.zAxisMapping.y), + QVariant(m_Config.zAxisMapping.z)}; + state[lit("zAxisMapping")] = zAxisMapping; return state; } @@ -2954,7 +2970,20 @@ void BufferViewer::setPersistData(const QVariant &persistData) { QVariantMap state = persistData.toMap(); - ui->dockarea->restoreState(state); + ui->dockarea->restoreState(state[lit("dockarea")].toMap()); + ui->axisMappingCombo->setCurrentIndex(state[lit("axisMappingIndex")].toInt()); + if(!state[lit("xAxisMapping")].toList().isEmpty()) + { + m_Config.xAxisMapping.x = state[lit("xAxisMapping")].toList()[0].toInt(); + m_Config.xAxisMapping.y = state[lit("xAxisMapping")].toList()[1].toInt(); + m_Config.xAxisMapping.z = state[lit("xAxisMapping")].toList()[2].toInt(); + m_Config.yAxisMapping.x = state[lit("yAxisMapping")].toList()[0].toInt(); + m_Config.yAxisMapping.y = state[lit("yAxisMapping")].toList()[1].toInt(); + m_Config.yAxisMapping.z = state[lit("yAxisMapping")].toList()[2].toInt(); + m_Config.zAxisMapping.x = state[lit("zAxisMapping")].toList()[0].toInt(); + m_Config.zAxisMapping.y = state[lit("zAxisMapping")].toList()[1].toInt(); + m_Config.zAxisMapping.z = state[lit("zAxisMapping")].toList()[2].toInt(); + } } void BufferViewer::calcBoundingData(CalcBoundingBoxData &bbox) @@ -4030,6 +4059,57 @@ void BufferViewer::camGuess_changed(double value) INVOKE_MEMFN(RT_UpdateAndDisplay); } +void BufferViewer::on_axisMappingCombo_currentIndexChanged(int index) +{ + if(index != 4) + { + switch(index) + { + case 0: // Y-up, Left Handed + m_Config.xAxisMapping = FloatVector(1.0f, 0.0f, 0.0f, 0.0f); + m_Config.yAxisMapping = FloatVector(0.0f, 1.0f, 0.0f, 0.0f); + m_Config.zAxisMapping = FloatVector(0.0f, 0.0f, 1.0f, 0.0f); + break; + case 1: // Y-up, Right Handed + m_Config.xAxisMapping = FloatVector(1.0f, 0.0f, 0.0f, 0.0f); + m_Config.yAxisMapping = FloatVector(0.0f, 1.0f, 0.0f, 0.0f); + m_Config.zAxisMapping = FloatVector(0.0f, 0.0f, -1.0f, 0.0f); + break; + case 2: // Z-up, Left Handed + m_Config.xAxisMapping = FloatVector(1.0f, 0.0f, 0.0f, 0.0f); + m_Config.yAxisMapping = FloatVector(0.0f, 0.0f, -1.0f, 0.0f); + m_Config.zAxisMapping = FloatVector(0.0f, 1.0f, 0.0f, 0.0f); + break; + case 3: // Z-up, Right Handed + m_Config.xAxisMapping = FloatVector(1.0f, 0.0f, 0.0f, 0.0f); + m_Config.yAxisMapping = FloatVector(0.0f, 0.0f, 1.0f, 0.0f); + m_Config.zAxisMapping = FloatVector(0.0f, 1.0f, 0.0f, 0.0f); + break; + default: break; + } + ui->axisMappingButton->setEnabled(false); + INVOKE_MEMFN(RT_UpdateAndDisplay); + } + else + { + ui->axisMappingButton->setEnabled(true); + } +} + +void BufferViewer::on_axisMappingButton_clicked() +{ + AxisMappingDialog dialog(m_Ctx, m_Config, this); + RDDialog::show(&dialog); + + if(dialog.result() == QDialog::Accepted) + { + m_Config.xAxisMapping = dialog.getXAxisMapping(); + m_Config.yAxisMapping = dialog.getYAxisMapping(); + m_Config.zAxisMapping = dialog.getZAxisMapping(); + INVOKE_MEMFN(RT_UpdateAndDisplay); + } +} + void BufferViewer::processFormat(const QString &format) { QString errors; @@ -4385,7 +4465,6 @@ void BufferViewer::debugVertex() } done = true; - }); QString debugContext = tr("Vertex %1").arg(vertid); diff --git a/qrenderdoc/Windows/BufferViewer.h b/qrenderdoc/Windows/BufferViewer.h index 652459ee4..c193c755f 100644 --- a/qrenderdoc/Windows/BufferViewer.h +++ b/qrenderdoc/Windows/BufferViewer.h @@ -118,6 +118,8 @@ private slots: void on_rowOffset_valueChanged(int value); void on_byteRangeStart_valueChanged(double value); void on_byteRangeLength_valueChanged(double value); + void on_axisMappingCombo_currentIndexChanged(int index); + void on_axisMappingButton_clicked(); // manual slots void render_mouseMove(QMouseEvent *e); diff --git a/qrenderdoc/Windows/BufferViewer.ui b/qrenderdoc/Windows/BufferViewer.ui index d8f18d7be..5387604a5 100644 --- a/qrenderdoc/Windows/BufferViewer.ui +++ b/qrenderdoc/Windows/BufferViewer.ui @@ -495,7 +495,7 @@ Enter 0.0 to use automatic/guessed value derived from data. - + Qt::Horizontal @@ -560,7 +560,7 @@ Enter 0.0 to use automatic/guessed value derived from data. - + @@ -584,7 +584,7 @@ Enter 0.0 to use automatic/guessed value derived from data. - + Qt::Vertical @@ -597,21 +597,41 @@ Enter 0.0 to use automatic/guessed value derived from data. - + - + Bounding Box: - + + + + Axis Mapping: + + + + + + + false + + + Edit Custom Mapping + + + + + + + diff --git a/qrenderdoc/Windows/Dialogs/AxisMappingDialog.cpp b/qrenderdoc/Windows/Dialogs/AxisMappingDialog.cpp new file mode 100644 index 000000000..e8550680c --- /dev/null +++ b/qrenderdoc/Windows/Dialogs/AxisMappingDialog.cpp @@ -0,0 +1,156 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2019-2021 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#include "AxisMappingDialog.h" +#include +#include "ui_AxisMappingDialog.h" + +int AxisMappingDialog::getIndexFromVector(const FloatVector &v) +{ + float x = v.x; + float y = v.y; + float z = v.z; + int index; + float nonZeroMapping; + + if(x != 0.0f) + { + index = 0; + nonZeroMapping = x; + } + else if(y != 0.0f) + { + index = 2; + nonZeroMapping = y; + } + else + { + index = 4; + nonZeroMapping = z; + } + + if(nonZeroMapping == -1.0f) + { + index += 1; + } + return index; +} + +FloatVector AxisMappingDialog::getVectorFromIndex(int index) +{ + FloatVector v = FloatVector(); + if(index == 0) + { + v.x = 1.0f; + } + else if(index == 1) + { + v.x = -1.0f; + } + else if(index == 2) + { + v.y = 1.0f; + } + else if(index == 3) + { + v.y = -1.0f; + } + else if(index == 4) + { + v.z = 1.0f; + } + else + { + v.z = -1.0f; + } + return v; +} + +AxisMappingDialog::AxisMappingDialog(ICaptureContext &Ctx, const MeshDisplay &m_config, + QWidget *parent) + : QDialog(parent), + m_Ctx(Ctx), + xAxisMapping(m_config.xAxisMapping), + yAxisMapping(m_config.yAxisMapping), + zAxisMapping(m_config.zAxisMapping), + ui(new Ui::AxisMappingDialog) +{ + ui->setupUi(this); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + const QStringList items{tr("Right"), tr("Left"), tr("Up"), + tr("Down"), tr("Into Screen"), tr("Out of Screen")}; + + ui->xAxisCombo->addItems(items); + ui->yAxisCombo->addItems(items); + ui->zAxisCombo->addItems(items); + ui->xAxisCombo->setCurrentIndex(getIndexFromVector(xAxisMapping)); + ui->yAxisCombo->setCurrentIndex(getIndexFromVector(yAxisMapping)); + ui->zAxisCombo->setCurrentIndex(getIndexFromVector(zAxisMapping)); + + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AxisMappingDialog::setNewAxisMappings); + connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); +} + +void AxisMappingDialog::setNewAxisMappings() +{ + int xIndex = ui->xAxisCombo->currentIndex(); + int yIndex = ui->yAxisCombo->currentIndex(); + int zIndex = ui->zAxisCombo->currentIndex(); + + if(xIndex / 2 != yIndex / 2 && yIndex / 2 != zIndex / 2 && xIndex / 2 != zIndex / 2) + { + xAxisMapping = getVectorFromIndex(xIndex); + yAxisMapping = getVectorFromIndex(yIndex); + zAxisMapping = getVectorFromIndex(zIndex); + accept(); + } + else + { + QMessageBox messageBox; + messageBox.critical(0, tr("Error"), tr("Your axis mappings are not compatible.")); + messageBox.setFixedSize(700, 150); + } + // insert error message logic here +} + +FloatVector AxisMappingDialog::getXAxisMapping() +{ + return xAxisMapping; +} + +FloatVector AxisMappingDialog::getYAxisMapping() +{ + return yAxisMapping; +} + +FloatVector AxisMappingDialog::getZAxisMapping() +{ + return zAxisMapping; +} + +AxisMappingDialog::~AxisMappingDialog() +{ + delete ui; +} diff --git a/qrenderdoc/Windows/Dialogs/AxisMappingDialog.h b/qrenderdoc/Windows/Dialogs/AxisMappingDialog.h new file mode 100644 index 000000000..7e2812af6 --- /dev/null +++ b/qrenderdoc/Windows/Dialogs/AxisMappingDialog.h @@ -0,0 +1,57 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2019-2021 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#pragma once + +#include +#include "Code/Interface/QRDInterface.h" + +namespace Ui +{ +class AxisMappingDialog; +} + +struct ICaptureContext; + +class AxisMappingDialog : public QDialog +{ + Q_OBJECT +public: + explicit AxisMappingDialog(ICaptureContext &Ctx, const MeshDisplay &m_config, QWidget *parent = 0); + FloatVector getXAxisMapping(); + FloatVector getYAxisMapping(); + FloatVector getZAxisMapping(); + ~AxisMappingDialog(); + +private: + Ui::AxisMappingDialog *ui; + ICaptureContext &m_Ctx; + FloatVector xAxisMapping; + FloatVector yAxisMapping; + FloatVector zAxisMapping; + void setNewAxisMappings(); + + static int getIndexFromVector(const FloatVector &v); + static FloatVector getVectorFromIndex(int index); +}; diff --git a/qrenderdoc/Windows/Dialogs/AxisMappingDialog.ui b/qrenderdoc/Windows/Dialogs/AxisMappingDialog.ui new file mode 100644 index 000000000..77c1f4277 --- /dev/null +++ b/qrenderdoc/Windows/Dialogs/AxisMappingDialog.ui @@ -0,0 +1,87 @@ + + + AxisMappingDialog + + + + 0 + 0 + 300 + 200 + + + + Edit Custom Mapping + + + + QLayout::SetFixedSize + + + 30 + + + 30 + + + 30 + + + 30 + + + + + 10 + + + + + X Axis: + + + + + + + + + + Y Axis: + + + + + + + + + + Z Axis: + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + true + + + + + + + + + diff --git a/qrenderdoc/qrenderdoc.pro b/qrenderdoc/qrenderdoc.pro index cc73cfce7..40d269ec9 100644 --- a/qrenderdoc/qrenderdoc.pro +++ b/qrenderdoc/qrenderdoc.pro @@ -247,7 +247,8 @@ SOURCES += Code/qrenderdoc.cpp \ Windows/PerformanceCounterViewer.cpp \ Windows/ResourceInspector.cpp \ Windows/Dialogs/AnalyticsConfirmDialog.cpp \ - Windows/Dialogs/AnalyticsPromptDialog.cpp + Windows/Dialogs/AnalyticsPromptDialog.cpp \ + Windows/Dialogs/AxisMappingDialog.cpp HEADERS += Code/CaptureContext.h \ Code/qprocessinfo.h \ Code/ReplayManager.h \ @@ -332,7 +333,8 @@ HEADERS += Code/CaptureContext.h \ Windows/PerformanceCounterViewer.h \ Windows/ResourceInspector.h \ Windows/Dialogs/AnalyticsConfirmDialog.h \ - Windows/Dialogs/AnalyticsPromptDialog.h + Windows/Dialogs/AnalyticsPromptDialog.h \ + Windows/Dialogs/AxisMappingDialog.h FORMS += Windows/Dialogs/AboutDialog.ui \ Windows/Dialogs/CrashDialog.ui \ Windows/Dialogs/UpdateDialog.ui \ @@ -376,7 +378,8 @@ FORMS += Windows/Dialogs/AboutDialog.ui \ Windows/PerformanceCounterViewer.ui \ Windows/ResourceInspector.ui \ Windows/Dialogs/AnalyticsConfirmDialog.ui \ - Windows/Dialogs/AnalyticsPromptDialog.ui + Windows/Dialogs/AnalyticsPromptDialog.ui \ + Windows/Dialogs/AxisMappingDialog.ui RESOURCES += Resources/resources.qrc diff --git a/qrenderdoc/qrenderdoc_local.vcxproj b/qrenderdoc/qrenderdoc_local.vcxproj index 8ffd64368..e50669409 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj +++ b/qrenderdoc/qrenderdoc_local.vcxproj @@ -616,6 +616,7 @@ + @@ -754,6 +755,7 @@ + @@ -955,6 +957,7 @@ + @@ -1258,6 +1261,12 @@ MOC %(Filename).h $(IntDir)generated\moc_%(Filename).cpp + + %(Fullpath);$(QtBinDir)\moc.exe;%(AdditionalInputs) + "$(QtBinDir)\moc.exe" -DUNICODE -DWIN32 -DWIN64 -D_WIN32 -D_WIN64 -DRENDERDOC_PLATFORM_WIN32 -DSCINTILLA_QT=1 -DSCI_LEXER=1 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1900 -I"$(ProjectDir)." -I"$(SolutionDir)\renderdoc\api\replay" -I"$(QtIncludeDir)" -I"$(QtIncludeDir)\QtWidgets" -I"$(QtIncludeDir)\QtGui" -I"$(QtIncludeDir)\QtCore" "%(Fullpath)" -o "$(IntDir)generated\moc_%(Filename).cpp" + MOC %(Filename).h + $(IntDir)generated\moc_%(Filename).cpp + %(Fullpath);$(QtBinDir)\moc.exe;%(AdditionalInputs) "$(QtBinDir)\moc.exe" -DUNICODE -DWIN32 -DWIN64 -D_WIN32 -D_WIN64 -DRENDERDOC_PLATFORM_WIN32 -DSCINTILLA_QT=1 -DSCI_LEXER=1 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1900 -I"$(ProjectDir)." -I"$(SolutionDir)\renderdoc\api\replay" -I"$(QtIncludeDir)" -I"$(QtIncludeDir)\QtWidgets" -I"$(QtIncludeDir)\QtGui" -I"$(QtIncludeDir)\QtCore" "%(Fullpath)" -o "$(IntDir)generated\moc_%(Filename).cpp" @@ -1553,6 +1562,12 @@ UIC %(Filename).ui $(IntDir)generated\ui_%(Filename).h + + %(Fullpath);$(QtBinDir)\uic.exe;%(AdditionalInputs) + "$(QtBinDir)\uic.exe" "%(Fullpath)" -o "$(IntDir)generated\ui_%(Filename).h" + UIC %(Filename).ui + $(IntDir)generated\ui_%(Filename).h + %(Fullpath);$(QtBinDir)\uic.exe;%(AdditionalInputs) "$(QtBinDir)\uic.exe" "%(Fullpath)" -o "$(IntDir)generated\ui_%(Filename).h" diff --git a/qrenderdoc/qrenderdoc_local.vcxproj.filters b/qrenderdoc/qrenderdoc_local.vcxproj.filters index 7d285d51d..e1112c090 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj.filters +++ b/qrenderdoc/qrenderdoc_local.vcxproj.filters @@ -141,6 +141,9 @@ Windows\Dialogs + + Windows\Dialogs + Windows\Dialogs @@ -399,6 +402,9 @@ Generated Files + + Generated Files + Generated Files @@ -962,6 +968,9 @@ Generated Files + + Generated Files + Generated Files @@ -1229,6 +1238,9 @@ Windows\Dialogs + + Windows\Dialogs + Windows\Dialogs @@ -1322,6 +1334,9 @@ Windows\Dialogs + + Windows\Dialogs + Windows\Dialogs diff --git a/renderdoc/api/replay/control_types.h b/renderdoc/api/replay/control_types.h index 8338c7ec8..35f21592d 100644 --- a/renderdoc/api/replay/control_types.h +++ b/renderdoc/api/replay/control_types.h @@ -129,6 +129,24 @@ struct MeshDisplay )"); ICamera *cam = NULL; + DOCUMENT(R"(The mapping of the x axis of the mesh's coordinate system. + +:type: FloatVector +)"); + FloatVector xAxisMapping; + + DOCUMENT(R"(The mapping of the y axis of the mesh's coordinate system. + +:type: FloatVector +)"); + FloatVector yAxisMapping; + + DOCUMENT(R"(The mapping of the z axis of the mesh's coordinate system. + +:type: FloatVector +)"); + FloatVector zAxisMapping; + DOCUMENT( "``True`` if the projection matrix to use when unprojecting vertex positions is " "orthographic."); diff --git a/renderdoc/driver/gl/gl_debug.cpp b/renderdoc/driver/gl/gl_debug.cpp index 09e2a2fa1..d22cbae3b 100644 --- a/renderdoc/driver/gl/gl_debug.cpp +++ b/renderdoc/driver/gl/gl_debug.cpp @@ -2238,6 +2238,21 @@ bool GLReplay::GetHistogram(ResourceId texid, const Subresource &sub, CompType t return true; } +static Matrix4f getAxisMapMat(const MeshDisplay &cfg) +{ + Matrix4f axisMapMat = Matrix4f::Identity(); + axisMapMat[0] = cfg.xAxisMapping.x; + axisMapMat[4] = cfg.xAxisMapping.y; + axisMapMat[8] = cfg.xAxisMapping.z; + axisMapMat[1] = cfg.yAxisMapping.x; + axisMapMat[5] = cfg.yAxisMapping.y; + axisMapMat[9] = cfg.yAxisMapping.z; + axisMapMat[2] = cfg.zAxisMapping.x; + axisMapMat[6] = cfg.zAxisMapping.y; + axisMapMat[10] = cfg.zAxisMapping.z; + return axisMapMat; +} + uint32_t GLReplay::PickVertex(uint32_t eventId, int32_t width, int32_t height, const MeshDisplay &cfg, uint32_t x, uint32_t y) { @@ -2254,6 +2269,10 @@ uint32_t GLReplay::PickVertex(uint32_t eventId, int32_t width, int32_t height, Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity(); Matrix4f pickMVP = projMat.Mul(camMat); + if(!cfg.position.unproject) + { + pickMVP = pickMVP.Mul(getAxisMapMat(cfg)); + } bool reverseProjection = false; Matrix4f guessProj; diff --git a/renderdoc/driver/gl/gl_rendermesh.cpp b/renderdoc/driver/gl/gl_rendermesh.cpp index 61d9da59e..5557da563 100644 --- a/renderdoc/driver/gl/gl_rendermesh.cpp +++ b/renderdoc/driver/gl/gl_rendermesh.cpp @@ -33,6 +33,21 @@ #define OPENGL 1 #include "data/glsl/glsl_ubos_cpp.h" +static Matrix4f getAxisMapMat(const MeshDisplay &cfg) +{ + Matrix4f axisMapMat = Matrix4f::Identity(); + axisMapMat[0] = cfg.xAxisMapping.x; + axisMapMat[4] = cfg.xAxisMapping.y; + axisMapMat[8] = cfg.xAxisMapping.z; + axisMapMat[1] = cfg.yAxisMapping.x; + axisMapMat[5] = cfg.yAxisMapping.y; + axisMapMat[9] = cfg.yAxisMapping.z; + axisMapMat[2] = cfg.zAxisMapping.x; + axisMapMat[6] = cfg.zAxisMapping.y; + axisMapMat[10] = cfg.zAxisMapping.z; + return axisMapMat; +} + void GLReplay::RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg) { @@ -51,7 +66,9 @@ void GLReplay::RenderMesh(uint32_t eventId, const rdcarray &secondar Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity(); - Matrix4f ModelViewProj = projMat.Mul(camMat); + Matrix4f axisMapMat = getAxisMapMat(cfg); + + Matrix4f ModelViewProj = projMat.Mul(camMat.Mul(axisMapMat)); Matrix4f guessProjInv; drv.glBindVertexArray(DebugData.meshVAO); @@ -479,6 +496,8 @@ void GLReplay::RenderMesh(uint32_t eventId, const rdcarray &secondar uboParams.color = Vec4f(0.2f, 0.2f, 1.0f, 1.0f); Matrix4f mvpMat = projMat.Mul(camMat); + if(!cfg.position.unproject) + mvpMat = mvpMat.Mul(axisMapMat); uboParams.mvp = mvpMat; @@ -589,7 +608,7 @@ void GLReplay::RenderMesh(uint32_t eventId, const rdcarray &secondar if(cfg.position.unproject) ModelViewProj = projMat.Mul(camMat.Mul(guessProjInv)); else - ModelViewProj = projMat.Mul(camMat); + ModelViewProj = projMat.Mul(camMat.Mul(axisMapMat)); uboParams.homogenousInput = cfg.position.unproject;