From a0355c9b897281d0bfea48bec9d490724ecabd96 Mon Sep 17 00:00:00 2001 From: SulfurNitride Date: Sun, 12 Apr 2026 17:54:45 -0500 Subject: 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) --- libs/preview_nif/src/Camera.cpp | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 libs/preview_nif/src/Camera.cpp (limited to 'libs/preview_nif/src/Camera.cpp') diff --git a/libs/preview_nif/src/Camera.cpp b/libs/preview_nif/src/Camera.cpp new file mode 100644 index 0000000..0a9ce73 --- /dev/null +++ b/libs/preview_nif/src/Camera.cpp @@ -0,0 +1,50 @@ +#include "Camera.h" + +#include + +void Camera::setDistance(float distance) +{ + m_Distance = qBound(MinDistance, distance, MaxDistance); + cameraMoved(); +} + +void Camera::setLookAt(QVector3D lookAt) +{ + m_LookAt = lookAt; + cameraMoved(); +} + +void Camera::pan(QVector3D distance) +{ + m_LookAt += distance; + cameraMoved(); +} + +void Camera::rotate(float yaw, float pitch) +{ + m_Yaw = repeat(m_Yaw + yaw, 0.0f, 360.0f); + m_Pitch = repeat(m_Pitch + pitch, 0.0f, 360.0f); + + cameraMoved(); +} + +void Camera::zoomDistance(float distance) +{ + m_Distance += distance; + m_Distance = qBound(MinDistance, m_Distance, MaxDistance); + + cameraMoved(); +} + +void Camera::zoomFactor(float factor) +{ + m_Distance *= factor; + m_Distance = qBound(MinDistance, m_Distance, MaxDistance); + + cameraMoved(); +} + +float Camera::repeat(float value, float min, float max) +{ + return fmod(fmod(value, max - min) + (max - min), max - min) + min; +} -- cgit v1.3.1