diff --git a/src/program/OutfitStudio.cpp b/src/program/OutfitStudio.cpp index 60dc3ccb..a841883c 100644 --- a/src/program/OutfitStudio.cpp +++ b/src/program/OutfitStudio.cpp @@ -5811,6 +5811,8 @@ void wxGLPanel::SetMeshTextures(const string& shapeName, const vector& t if (hasMatFile) m->UpdateFromMaterialFile(matFile); + + gls.UpdateShaders(m); } } diff --git a/src/program/PreviewWindow.h b/src/program/PreviewWindow.h index 14d611b5..b509890a 100644 --- a/src/program/PreviewWindow.h +++ b/src/program/PreviewWindow.h @@ -82,6 +82,8 @@ class PreviewWindow : public wxFrame { if (hasMatFile) m->UpdateFromMaterialFile(matFile); + + gls.UpdateShaders(m); } } diff --git a/src/render/GLSurface.cpp b/src/render/GLSurface.cpp index 000b64e0..b21992dd 100644 --- a/src/render/GLSurface.cpp +++ b/src/render/GLSurface.cpp @@ -841,6 +841,15 @@ void GLSurface::RenderMesh(mesh* m) { shader.End(); } +void GLSurface::UpdateShaders(mesh* m) { + if (m->material) { + m->material->GetShader().ShowTexture(bTextured); + m->material->GetShader().ShowLighting(bLighting); + m->material->GetShader().ShowWeight(bWeightColors); + m->material->GetShader().ShowSegments(bSegmentColors); + } +} + void GLSurface::ReloadMeshFromNif(NifFile* nif, string shapeName) { DeleteMesh(shapeName); AddMeshFromNif(nif, shapeName); diff --git a/src/render/GLSurface.h b/src/render/GLSurface.h index c20a523a..4b78125a 100644 --- a/src/render/GLSurface.h +++ b/src/render/GLSurface.h @@ -268,6 +268,8 @@ class GLSurface { void RenderOneFrame(); void RenderMesh(mesh* m); + void UpdateShaders(mesh* m); + void ToggleTextures() { if (bTextured) bTextured = false; @@ -275,8 +277,7 @@ class GLSurface { bTextured = true; for (auto &m : meshes) - if (m->material) - m->material->GetShader().ShowTexture(bTextured); + UpdateShaders(m); } void ToggleWireframe() { @@ -293,42 +294,27 @@ class GLSurface { bLighting = true; for (auto &m : meshes) - if (m->material) - m->material->GetShader().ShowLighting(bLighting); + UpdateShaders(m); } void SetMaskVisible(bool bVisible = true) { bMaskVisible = bVisible; for (auto &m : meshes) - if (m->material) - m->material->GetShader().ShowMask(bVisible); + UpdateShaders(m); } void SetWeightColors(bool bVisible = true) { bWeightColors = bVisible; for (auto &m : meshes) - if (m->material) - m->material->GetShader().ShowWeight(bWeightColors); + UpdateShaders(m); } void SetSegmentColors(bool bVisible = true) { bSegmentColors = bVisible; for (auto &m : meshes) - if (m->material) - m->material->GetShader().ShowSegments(bSegmentColors); - } - - void ToggleWeightColors() { - if (bWeightColors) - bWeightColors = false; - else - bWeightColors = true; - - for (auto &m : activeMeshes) - if (m->material) - m->material->GetShader().ShowWeight(bWeightColors); + UpdateShaders(m); } };