aboutsummaryrefslogtreecommitdiff
path: root/libs/preview_nif/src/NifWidget.h
diff options
context:
space:
mode:
authorSulfurNitride <SulfurNitride@users.noreply.github.com>2026-04-12 17:54:45 -0500
committerSulfurNitride <SulfurNitride@users.noreply.github.com>2026-04-12 17:54:45 -0500
commita0355c9b897281d0bfea48bec9d490724ecabd96 (patch)
tree42c56ea4f4829a6115f688956858ada3e59fd9ef /libs/preview_nif/src/NifWidget.h
parentfa43a71f9d05b3673d42296a80decb2228d68f83 (diff)
Add NIF previewer plugin with Linux-specific fixes
Vendored from github.com/Parapets/mo2-preview_nif and adapted for Linux: - BSA texture resolution via MO2 virtual tree with case-insensitive fallback walk (Linux FS is case-sensitive; NIFs reference textures with arbitrary case against files on disk) - Process-wide cached BSA candidate list, keyed by profile path, priority-sorted, filtering disabled mods - Path backslash normalization before loose-file lookup - Polygon offset on SLSF1_Decal-flagged shapes to break z-ties with coincident base meshes (road decals, moss overlays) - Opaque framebuffer via glColorMask alpha lock so alpha-blended shapes can't bleed the dialog background through the preview area - QMouseEvent::globalPosition().toPoint() for Qt6 compatibility Preview dialog behavior (organizercore.cpp): - Switch previewFile and previewFileWithAlternatives from stack-allocated exec() to heap + ApplicationModal + show() + WA_DeleteOnClose. - Parent passed as nullptr so preview lifetime is decoupled from the stack-allocated ModInfoDialog that spawns it. Nested exec() inside the enclosing dialog's exec() was softlocking on close. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'libs/preview_nif/src/NifWidget.h')
-rw-r--r--libs/preview_nif/src/NifWidget.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/libs/preview_nif/src/NifWidget.h b/libs/preview_nif/src/NifWidget.h
new file mode 100644
index 0000000..34f2de0
--- /dev/null
+++ b/libs/preview_nif/src/NifWidget.h
@@ -0,0 +1,71 @@
+#pragma once
+
+#include "Camera.h"
+#include "OpenGLShape.h"
+#include "ShaderManager.h"
+#include "TextureManager.h"
+
+#include <QOpenGLBuffer>
+#include <QOpenGLDebugLogger>
+#include <QOpenGLShaderProgram>
+#include <QOpenGLVertexArrayObject>
+#include <QOpenGLWidget>
+#include <QSharedPointer>
+
+#include <imoinfo.h>
+#include <NifFile.hpp>
+
+#include <memory>
+
+class NifWidget : public QOpenGLWidget
+{
+ Q_OBJECT
+
+public:
+ NifWidget(
+ std::shared_ptr<nifly::NifFile> nifFile,
+ MOBase::IOrganizer* organizer,
+ bool debugContext = false,
+ QWidget* parent = nullptr,
+ Qt::WindowFlags f = {0});
+
+ ~NifWidget();
+ NifWidget(const NifWidget&) = delete;
+ NifWidget(NifWidget&&) = delete;
+ NifWidget& operator=(const NifWidget&) = delete;
+ NifWidget& operator=(NifWidget&&) = delete;
+
+protected:
+ void mousePressEvent(QMouseEvent* event) override;
+ void mouseMoveEvent(QMouseEvent* event) override;
+ void wheelEvent(QWheelEvent* event) override;
+
+ void initializeGL() override;
+ void paintGL() override;
+ void resizeGL(int w, int h) override;
+
+private:
+ void cleanup();
+ void updateCamera();
+
+ inline static QWeakPointer<Camera> SharedCamera;
+
+ std::shared_ptr<nifly::NifFile> m_NifFile;
+ MOBase::IOrganizer* m_MOInfo = nullptr;
+
+ std::unique_ptr<TextureManager> m_TextureManager;
+ std::unique_ptr<ShaderManager> m_ShaderManager;
+
+ QOpenGLDebugLogger* m_Logger = nullptr;
+
+ std::vector<OpenGLShape> m_GLShapes;
+
+ QSharedPointer<Camera> m_Camera;
+
+ QMatrix4x4 m_ViewMatrix;
+ QMatrix4x4 m_ProjectionMatrix;
+
+ int m_ViewportWidth;
+ int m_ViewportHeight;
+ QPoint m_MousePos;
+};