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 Magnum with new scene tools, bindings and plugin additions #2114

Merged
merged 5 commits into from
May 24, 2023
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
Binary file modified data/test_assets/scenes/batch-four-squares-no-scene.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion src/cmake/FindMagnum.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS})

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

# ShaderTools library
elseif(_component STREQUAL ShaderTools)
Expand Down
2 changes: 1 addition & 1 deletion src/deps/magnum
Submodule magnum updated 130 files
2 changes: 1 addition & 1 deletion src/deps/magnum-plugins
Submodule magnum-plugins updated 88 files
+13 −3 doc/changelog-plugins.dox
+15 −1 package/ci/unix-desktop.sh
+9 −9 src/MagnumPlugins/AssimpImporter/AssimpImporter.cpp
+8 −6 src/MagnumPlugins/AssimpImporter/AssimpImporter.h
+8 −8 src/MagnumPlugins/AssimpImporter/Test/AssimpImporterTest.cpp
+3 −0 src/MagnumPlugins/AstcImporter/AstcImporter.h
+3 −0 src/MagnumPlugins/BasisImageConverter/BasisImageConverter.h
+2 −1 src/MagnumPlugins/BasisImporter/BasisImporter.h
+2 −1 src/MagnumPlugins/DdsImporter/DdsImporter.h
+14 −14 src/MagnumPlugins/GltfImporter/GltfImporter.cpp
+6 −2 src/MagnumPlugins/GltfImporter/GltfImporter.h
+34 −20 src/MagnumPlugins/GltfImporter/Test/GltfImporterTest.cpp
+2 −1 src/MagnumPlugins/GltfImporter/Test/light-invalid.gltf
+8 −0 src/MagnumPlugins/GltfImporter/Test/light.gltf
+9 −9 src/MagnumPlugins/GltfSceneConverter/GltfSceneConverter.cpp
+8 −2 src/MagnumPlugins/GltfSceneConverter/GltfSceneConverter.h
+3 −0 src/MagnumPlugins/JpegImageConverter/JpegImageConverter.h
+3 −0 src/MagnumPlugins/KtxImageConverter/KtxImageConverter.h
+2 −1 src/MagnumPlugins/KtxImporter/KtxImporter.h
+7 −2 src/MagnumPlugins/MeshOptimizerSceneConverter/MeshOptimizerSceneConverter.conf
+26 −47 src/MagnumPlugins/MeshOptimizerSceneConverter/MeshOptimizerSceneConverter.cpp
+8 −1 src/MagnumPlugins/MeshOptimizerSceneConverter/MeshOptimizerSceneConverter.h
+85 −1 src/MagnumPlugins/MeshOptimizerSceneConverter/Test/MeshOptimizerSceneConverterTest.cpp
+3 −0 src/MagnumPlugins/MiniExrImageConverter/MiniExrImageConverter.h
+3 −0 src/MagnumPlugins/OpenExrImageConverter/OpenExrImageConverter.h
+3 −0 src/MagnumPlugins/OpenExrImporter/OpenExrImporter.h
+4 −4 src/MagnumPlugins/OpenGexImporter/OpenGexImporter.cpp
+4 −0 src/MagnumPlugins/OpenGexImporter/OpenGexImporter.h
+3 −3 src/MagnumPlugins/OpenGexImporter/Test/OpenGexImporterTest.cpp
+4 −0 src/MagnumPlugins/PngImageConverter/PngImageConverter.h
+4 −1 src/MagnumPlugins/PngImageConverter/Test/CMakeLists.txt
+20 −12 src/MagnumPlugins/PngImageConverter/Test/PngImageConverterTest.cpp
+1 −0 src/MagnumPlugins/PngImageConverter/Test/configure.h.cmake
+6 −0 src/MagnumPlugins/PngImporter/PngImporter.conf
+21 −0 src/MagnumPlugins/PngImporter/PngImporter.cpp
+18 −1 src/MagnumPlugins/PngImporter/PngImporter.h
+5 −1 src/MagnumPlugins/PngImporter/Test/CMakeLists.txt
+167 −9 src/MagnumPlugins/PngImporter/Test/PngImporterTest.cpp
+ src/MagnumPlugins/PngImporter/Test/gray16.png
+ src/MagnumPlugins/PngImporter/Test/rgb16.png
+4 −0 src/MagnumPlugins/SpngImporter/SpngImporter.cpp
+10 −10 src/MagnumPlugins/SpngImporter/Test/SpngImporterTest.cpp
+3 −3 src/MagnumPlugins/StanfordImporter/StanfordImporter.cpp
+1 −1 src/MagnumPlugins/StanfordImporter/StanfordImporter.h
+14 −12 src/MagnumPlugins/StanfordSceneConverter/StanfordSceneConverter.cpp
+3 −0 src/MagnumPlugins/StanfordSceneConverter/StanfordSceneConverter.h
+10 −0 src/MagnumPlugins/StanfordSceneConverter/Test/.gitattributes
+7 −7 src/MagnumPlugins/StanfordSceneConverter/Test/StanfordSceneConverterTest.cpp
+ src/MagnumPlugins/StanfordSceneConverter/Test/indexed-triangle-strip-le.ply
+3 −0 src/MagnumPlugins/StbImageConverter/StbImageConverter.h
+6 −1 src/MagnumPlugins/StbImageConverter/Test/CMakeLists.txt
+31 −19 src/MagnumPlugins/StbImageConverter/Test/StbImageConverterTest.cpp
+1 −0 src/MagnumPlugins/StbImageConverter/Test/configure.h.cmake
+5 −0 src/MagnumPlugins/StbImageImporter/StbImageImporter.conf
+19 −2 src/MagnumPlugins/StbImageImporter/StbImageImporter.cpp
+5 −2 src/MagnumPlugins/StbImageImporter/StbImageImporter.h
+8 −2 src/MagnumPlugins/StbImageImporter/Test/CMakeLists.txt
+273 −23 src/MagnumPlugins/StbImageImporter/Test/StbImageImporterTest.cpp
+ src/MagnumPlugins/StbImageImporter/Test/rgb.hdr
+ src/MagnumPlugins/StbImageImporter/Test/rrr.hdr
+1 −1 src/MagnumPlugins/TinyGltfImporter/Test/CMakeLists.txt
+5 −5 src/MagnumPlugins/TinyGltfImporter/Test/TinyGltfImporterTest.cpp
+51 −0 src/MagnumPlugins/TinyGltfImporter/Test/light.gltf
+9 −9 src/MagnumPlugins/TinyGltfImporter/TinyGltfImporter.cpp
+1 −1 src/MagnumPlugins/TinyGltfImporter/TinyGltfImporter.h
+1 −1 src/MagnumPlugins/UfbxImporter/CMakeLists.txt
+15 −1 src/MagnumPlugins/UfbxImporter/Test/CMakeLists.txt
+974 −45 src/MagnumPlugins/UfbxImporter/Test/UfbxImporterTest.cpp
+488 −0 src/MagnumPlugins/UfbxImporter/Test/animation-interpolation.fbx
+592 −0 src/MagnumPlugins/UfbxImporter/Test/animation-layer-nonlinear-weight.fbx
+617 −0 src/MagnumPlugins/UfbxImporter/Test/animation-layer.fbx
+1,307 −0 src/MagnumPlugins/UfbxImporter/Test/animation-multi-clip.fbx
+763 −0 src/MagnumPlugins/UfbxImporter/Test/animation-pre-rotation.fbx
+509 −0 src/MagnumPlugins/UfbxImporter/Test/animation-rotation-pivot.fbx
+ src/MagnumPlugins/UfbxImporter/Test/animation-space-y-up-cm.fbx
+ src/MagnumPlugins/UfbxImporter/Test/animation-space-y-up-m.fbx
+ src/MagnumPlugins/UfbxImporter/Test/animation-space-z-up-cm.fbx
+ src/MagnumPlugins/UfbxImporter/Test/animation-space-z-up-m.fbx
+ src/MagnumPlugins/UfbxImporter/Test/animation-stacks.fbx
+864 −0 src/MagnumPlugins/UfbxImporter/Test/animation-visibility.fbx
+ src/MagnumPlugins/UfbxImporter/Test/skinning-blender.fbx
+1,234 −0 src/MagnumPlugins/UfbxImporter/Test/skinning.fbx
+22 −0 src/MagnumPlugins/UfbxImporter/UfbxImporter.conf
+580 −23 src/MagnumPlugins/UfbxImporter/UfbxImporter.cpp
+62 −15 src/MagnumPlugins/UfbxImporter/UfbxImporter.h
+1 −1 src/MagnumPlugins/UfbxImporter/UfbxMaterials.h
+10 −5 src/external/ufbx/ufbx.c
+62 −1 src/external/ufbx/ufbx.h
8 changes: 4 additions & 4 deletions src/esp/assets/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
#include <Magnum/Math/Tags.h>
#include <Magnum/MeshTools/Compile.h>
#include <Magnum/MeshTools/Concatenate.h>
#include <Magnum/MeshTools/Copy.h>
#include <Magnum/MeshTools/FilterAttributes.h>
#include <Magnum/MeshTools/Interleave.h>
#include <Magnum/MeshTools/Reference.h>
#include <Magnum/MeshTools/RemoveDuplicates.h>
#include <Magnum/MeshTools/Transform.h>
#include <Magnum/PixelFormat.h>
#include <Magnum/SceneGraph/Object.h>
#include <Magnum/SceneTools/FlattenTransformationHierarchy.h>
#include <Magnum/SceneTools/Hierarchy.h>
#include <Magnum/Trade/AbstractImporter.h>
#include <Magnum/Trade/FlatMaterialData.h>
#include <Magnum/Trade/ImageData.h>
Expand Down Expand Up @@ -1456,7 +1456,7 @@ ResourceManager::flattenImportedMeshAndBuildSemantic(Importer& fileImporter,
// All the transformations, flattened and indexed by mesh id, with
// reframeTransform applied to each
Cr::Containers::Array<Mn::Matrix4> transformations =
Mn::SceneTools::flattenTransformationHierarchy3D(
Mn::SceneTools::absoluteFieldTransformations3D(
*scene, Mn::Trade::SceneField::Mesh, reframeTransform);

Cr::Containers::Array<Mn::Trade::MeshData> flattenedMeshes;
Expand Down Expand Up @@ -3650,7 +3650,7 @@ void ResourceManager::createConvexHullDecomposition(
ch.m_triangles, ch.m_nTriangles * 3};

// create an owned MeshData
Cr::Containers::Optional<Mn::Trade::MeshData> CHMesh = Mn::MeshTools::owned(
Cr::Containers::Optional<Mn::Trade::MeshData> CHMesh = Mn::MeshTools::copy(
Mn::Trade::MeshData{Mn::MeshPrimitive::Triangles,
{},
indices,
Expand Down
1 change: 0 additions & 1 deletion src/esp/geo/VoxelGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <Magnum/Math/Vector.h>
#include <Magnum/MeshTools/Compile.h>
#include <Magnum/MeshTools/Interleave.h>
#include <Magnum/MeshTools/Reference.h>
#include <Magnum/Primitives/Cone.h>
#include <Magnum/Primitives/Cube.h>
#include <Magnum/Primitives/Cylinder.h>
Expand Down
4 changes: 2 additions & 2 deletions src/esp/gfx/PbrImageBasedLighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include <Magnum/Magnum.h>
#include <Magnum/Math/Angle.h>
#include <Magnum/MeshTools/Compile.h>
#include <Magnum/MeshTools/Copy.h>
#include <Magnum/MeshTools/FlipNormals.h>
#include <Magnum/MeshTools/Reference.h>
#include <Magnum/Primitives/Cube.h>
#include <Magnum/Trade/AbstractImporter.h>
#include <Magnum/Trade/ImageData.h>
Expand Down Expand Up @@ -304,7 +304,7 @@ void PbrImageBasedLighting::computePrecomputedMap(PrecomputedMapType type) {

// prepare a cube
Mn::Trade::MeshData cubeData =
Mn::MeshTools::owned(Mn::Primitives::cubeSolid());
Mn::MeshTools::copy(Mn::Primitives::cubeSolid());
// camera is now inside the cube, must flip the face winding, otherwise all
// the faces are culled
Mn::MeshTools::flipFaceWindingInPlace(cubeData.mutableIndices());
Expand Down
23 changes: 13 additions & 10 deletions src/esp/gfx_batch/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <Magnum/MeshTools/Duplicate.h>
#include <Magnum/MeshTools/RemoveDuplicates.h>
#include <Magnum/PixelFormat.h>
#include <Magnum/SceneTools/FlattenMeshHierarchy.h>
#include <Magnum/SceneTools/Hierarchy.h>
#include <Magnum/Shaders/Generic.h>
#include <Magnum/Shaders/Phong.h>
#include <Magnum/Shaders/PhongGL.h>
Expand Down Expand Up @@ -786,24 +786,27 @@ bool Renderer::addFile(const Cr::Containers::StringView filename,
/* Files treated as a whole have their hierarchy flattened and added under
a single name, which is the filename */
} else {
Cr::Containers::Array<
Cr::Containers::Triple<Mn::UnsignedInt, Mn::Int, Mn::Matrix4>>
flattened = Mn::SceneTools::flattenMeshHierarchy3D(*scene);
for (std::size_t i = 0; i != flattened.size(); ++i) {
meshViews[i].transformation = flattened[i].third();
/* The returned transformations are in the same order as the Mesh field,
which is the same order as the meshViews array */
Cr::Containers::Array<Mn::Matrix4> transformations =
Mn::SceneTools::absoluteFieldTransformations3D(
*scene, Mn::Trade::SceneField::Mesh);
for (std::size_t i = 0; i != transformations.size(); ++i) {
meshViews[i].transformation = transformations[i];
}
/* If no name is specified, the full filename is used */
const Cr::Containers::StringView usedName = name ? name : filename;
if (!state_->meshViewRangeForName
.insert({usedName,
{meshViewOffset,
meshViewOffset + Mn::UnsignedInt(flattened.size())}})
.insert(
{usedName,
{meshViewOffset,
meshViewOffset + Mn::UnsignedInt(transformations.size())}})
.second) {
Mn::Error{} << "Renderer::addFile(): node name" << usedName
<< "already exists";
return {};
}
CORRADE_INTERNAL_ASSERT(meshViewOffset + flattened.size() ==
CORRADE_INTERNAL_ASSERT(meshViewOffset + transformations.size() ==
state_->meshViews.size());
}
}
Expand Down
19 changes: 12 additions & 7 deletions src/tests/GfxBatchRendererTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <Magnum/Primitives/Circle.h>
#include <Magnum/Primitives/Plane.h>
#include <Magnum/Primitives/UVSphere.h>
#include <Magnum/SceneTools/FlattenMeshHierarchy.h>
#include <Magnum/SceneTools/Hierarchy.h>
#include <Magnum/Trade/AbstractImageConverter.h>
#include <Magnum/Trade/AbstractSceneConverter.h>
#include <Magnum/Trade/MaterialData.h>
Expand Down Expand Up @@ -1405,13 +1405,18 @@ void GfxBatchRendererTest::generateTestDataFourSquares() {
const Mn::Trade::MeshData squares[]{
Mn::MeshTools::generateIndices(Mn::Primitives::planeSolid(
Mn::Primitives::PlaneFlag::TextureCoordinates))};
Cr::Containers::Array<Cr::Containers::Pair<
Mn::UnsignedInt, Cr::Containers::Pair<Mn::UnsignedInt, Mn::Int>>>
meshesMaterials = sceneData.meshesMaterialsAsArray();
Cr::Containers::Array<Mn::Matrix4> transformations =
Mn::SceneTools::absoluteFieldTransformations3D(
sceneData, Mn::Trade::SceneField::Mesh);
Cr::Containers::Array<Mn::Trade::MeshData> flattenedMeshes;
for (const Cr::Containers::Triple<Mn::UnsignedInt, Mn::Int, Mn::Matrix4>&
meshTransformation :
Mn::SceneTools::flattenMeshHierarchy3D(sceneData)) {
arrayAppend(flattenedMeshes, Mn::MeshTools::transform3D(
squares[meshTransformation.first()],
meshTransformation.third()));
for (std::size_t i = 0; i != meshesMaterials.size(); ++i) {
arrayAppend(flattenedMeshes,
Mn::MeshTools::transform3D(
squares[meshesMaterials[i].second().first()],
transformations[i]));
}
const Mn::Trade::MeshData squaresJoined =
Mn::MeshTools::concatenate(flattenedMeshes);
Expand Down