Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest Magnum with full skinning support and much more #1968

Merged
merged 3 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/cmake/FindCorrade.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
# CORRADE_BUILD_MULTITHREADED - Defined if compiled in a way that makes it
# possible to safely use certain Corrade features simultaneously in multiple
# threads
# CORRADE_BUILD_CPU_RUNTIME_DISPATCH - Defined if built with code paths
# optimized for multiple architectres with the best matching variant selected
# at runtime based on detected CPU features
# CORRADE_TARGET_UNIX - Defined if compiled for some Unix flavor
# (Linux, BSD, macOS)
# CORRADE_TARGET_APPLE - Defined if compiled for Apple platforms
Expand All @@ -100,6 +103,8 @@
# CORRADE_TARGET_MSVC - Defined if compiling with MSVC or Clang with
# a MSVC frontend
# CORRADE_TARGET_MINGW - Defined if compiling under MinGW
# CORRADE_CPU_USE_IFUNC - Defined if GNU IFUNC is allowed to be used
# for runtime dispatch in the Cpu library
# CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT - Defined if PluginManager
# doesn't support dynamic plugin loading due to platform limitations
# CORRADE_TESTSUITE_TARGET_XCTEST - Defined if TestSuite is targeting Xcode
Expand Down Expand Up @@ -210,7 +215,7 @@
# <metadata file>
# <sources>...)
#
# Unline the above version this puts everything into ``<debug install dir>`` on
# Unlike the above version this puts everything into ``<debug install dir>`` on
# both DLL and non-DLL platforms. If ``<debug install dir>`` is set to
# :variable:`CMAKE_CURRENT_BINARY_DIR` (e.g. for testing purposes), the files
# are copied directly, without the need to perform install step. Note that the
Expand Down Expand Up @@ -319,6 +324,7 @@ set(_corradeFlags
BUILD_STATIC
BUILD_STATIC_UNIQUE_GLOBALS
BUILD_MULTITHREADED
BUILD_CPU_RUNTIME_DISPATCH
TARGET_UNIX
TARGET_APPLE
TARGET_IOS
Expand All @@ -327,10 +333,12 @@ set(_corradeFlags
TARGET_WINDOWS_RT
TARGET_EMSCRIPTEN
TARGET_ANDROID
# TARGET_X86 etc and TARGET_LIBCXX are not exposed to CMake as the meaning
# is unclear on platforms with multi-arch binaries or when mixing different
# STL implementations. TARGET_GCC etc are figured out via UseCorrade.cmake,
# as the compiler can be different when compiling the lib & when using it.
# TARGET_X86 etc, TARGET_32BIT, TARGET_BIG_ENDIAN and TARGET_LIBCXX etc.
# are not exposed to CMake as the meaning is unclear on platforms with
# multi-arch binaries or when mixing different STL implementations.
# TARGET_GCC etc are figured out via UseCorrade.cmake, as the compiler can
# be different when compiling the lib & when using it.
CPU_USE_IFUNC
PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT
TESTSUITE_TARGET_XCTEST
UTILITY_USE_ANSI_COLORS)
Expand Down
15 changes: 13 additions & 2 deletions src/cmake/FindMagnum.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
# Audio - Audio library
# DebugTools - DebugTools library
# GL - GL library
# MaterialTools - MaterialTools library
# MeshTools - MeshTools library
# Primitives - Primitives library
# SceneGraph - SceneGraph library
Expand Down Expand Up @@ -367,8 +368,8 @@ endif()
# Component distinction (listing them explicitly to avoid mistakes with finding
# components from other repositories)
set(_MAGNUM_LIBRARY_COMPONENTS
Audio DebugTools GL MeshTools Primitives SceneGraph SceneTools Shaders
ShaderTools Text TextureTools Trade
Audio DebugTools GL MaterialTools MeshTools Primitives SceneGraph
SceneTools Shaders ShaderTools Text TextureTools Trade
WindowlessEglApplication EglContext OpenGLTester)
set(_MAGNUM_PLUGIN_COMPONENTS
AnyAudioImporter AnyImageConverter AnyImageImporter AnySceneConverter
Expand Down Expand Up @@ -432,6 +433,8 @@ if(MAGNUM_TARGET_GL)
set(_MAGNUM_DebugTools_GL_DEPENDENCY_IS_OPTIONAL ON)
endif()

set(_MAGNUM_MaterialTools_DEPENDENCIES Trade)

set(_MAGNUM_MeshTools_DEPENDENCIES Trade)
if(MAGNUM_TARGET_GL)
list(APPEND _MAGNUM_MeshTools_DEPENDENCIES GL)
Expand Down Expand Up @@ -883,6 +886,10 @@ foreach(_component ${Magnum_FIND_COMPONENTS})
INTERFACE_LINK_LIBRARIES OpenGLES3::OpenGLES3)
endif()

# MaterialTools library
elseif(_component STREQUAL MaterialTools)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES PhongToPbrMetallicRoughness.h)

# MeshTools library
elseif(_component STREQUAL MeshTools)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES CompressIndices.h)
Expand All @@ -901,6 +908,10 @@ foreach(_component ${Magnum_FIND_COMPONENTS})

# No special setup for SceneGraph library

# SceneTools library
elseif(_component STREQUAL SceneTools)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES FlattenMeshHierarchy.h)

# ShaderTools library
elseif(_component STREQUAL ShaderTools)
set_property(TARGET Magnum::${_component} APPEND PROPERTY
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/FindMagnumPlugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ foreach(_component ${MagnumPlugins_FIND_COMPONENTS})

# Dynamic plugins don't have any prefix (e.g. `lib` on Linux),
# search with empty prefix and then reset that back so we don't
# accidentaly break something else
# accidentally break something else
set(_tmp_prefixes "${CMAKE_FIND_LIBRARY_PREFIXES}")
set(CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES};")

Expand Down
4 changes: 4 additions & 0 deletions src/cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ if(NOT USE_SYSTEM_MAGNUM)
set(MAGNUM_TARGET_EGL ON CACHE BOOL "" FORCE)
endif()

# These are enabled by default but we don't need them for anything yet
set(MAGNUM_WITH_SHADERTOOLS OFF CACHE BOOL "" FORCE)
set(MAGNUM_WITH_MATERIALTOOLS OFF CACHE BOOL "" FORCE)

# These are enabled by default but we don't need them if not building GUI
# viewers -- disabling for slightly faster builds. If you need any of these
# always, simply delete a line.
Expand Down
2 changes: 1 addition & 1 deletion src/deps/corrade
Submodule corrade updated 134 files
2 changes: 1 addition & 1 deletion src/deps/magnum
Submodule magnum updated 270 files
2 changes: 1 addition & 1 deletion src/deps/magnum-plugins
Submodule magnum-plugins updated 122 files
3 changes: 2 additions & 1 deletion src/esp/gfx/DebugLineRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ class DebugLineRender {
Magnum::GL::Buffer buffer;
Magnum::GL::Mesh mesh{Magnum::GL::MeshPrimitive::Lines};
Magnum::Shaders::FlatGL3D shader{
Magnum::Shaders::FlatGL3D::Flag::VertexColor};
Magnum::Shaders::FlatGL3D::Configuration{}.setFlags(
Magnum::Shaders::FlatGL3D::Flag::VertexColor)};
};

std::vector<Magnum::Matrix4> _inputTransformStack;
Expand Down
5 changes: 4 additions & 1 deletion src/esp/gfx/GenericDrawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ void GenericDrawable::updateShader() {
// if no shader with desired number of lights and flags exists, create one
if (!shader_) {
shaderManager_.set<Mn::GL::AbstractShaderProgram>(
shader_.key(), new Mn::Shaders::PhongGL{flags_, lightCount},
shader_.key(),
new Mn::Shaders::PhongGL{Mn::Shaders::PhongGL::Configuration{}
.setFlags(flags_)
.setLightCount(lightCount)},
Mn::ResourceDataState::Final, Mn::ResourcePolicy::ReferenceCounted);
}

Expand Down
6 changes: 5 additions & 1 deletion src/esp/gfx_batch/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,11 @@ bool Renderer::addFile(const Cr::Containers::StringView filename,
// that fetched from actual GL limits instead once I get to actually
// splitting draws by this limit
state_->shaders[Mn::UnsignedInt(extraFlags)] = Mn::Shaders::PhongGL{
shaderFlags, 0, Mn::UnsignedInt(state_->materials.size()), 1024};
Mn::Shaders::PhongGL::Configuration{}
.setFlags(shaderFlags)
.setLightCount(0)
.setMaterialCount(Mn::UnsignedInt(state_->materials.size()))
.setDrawCount(1024)};
}

/* Bind buffers that don't change per-view. All shaders share the same
Expand Down
3 changes: 2 additions & 1 deletion src/utils/viewer/ObjectPickingHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class ObjectPickingHelper {
Magnum::GL::Renderbuffer selectionDrawableId_;

Magnum::Shaders::MeshVisualizerGL3D shader_{
Magnum::Shaders::MeshVisualizerGL3D::Flag::Wireframe};
Magnum::Shaders::MeshVisualizerGL3D::Configuration{}.setFlags(
Magnum::Shaders::MeshVisualizerGL3D::Flag::Wireframe)};
esp::gfx::MeshVisualizerDrawable* meshVisualizerDrawable_ = nullptr;
esp::gfx::DrawableGroup pickedObjectDrawbles_;
ObjectPickingHelper& mapForDraw();
Expand Down