From 3b1dddf26df6155c610df4d687f570e60081452c Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 18:07:43 +0200 Subject: [PATCH 01/11] Ndk/GraphicsComponent: Add GetAttachedRenderables Former-commit-id: 6a5a017caf0af3fd5c40ead7d67d30b640eba243 [formerly 2796343e15655263669366fc7dd5ff8b3ca65d76] Former-commit-id: 7738d1c5a929d3cd1261aaa1c9899bddf0ad1541 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 5 +++++ SDK/include/NDK/Components/GraphicsComponent.inl | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index aed427105..4ea76d0d8 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -23,6 +23,8 @@ namespace Ndk friend class RenderSystem; public: + using RenderableList = std::vector; + GraphicsComponent() = default; inline GraphicsComponent(const GraphicsComponent& graphicsComponent); ~GraphicsComponent() = default; @@ -38,6 +40,9 @@ namespace Ndk inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; + inline void GetAttachedRenderables(Nz::InstancedRenderableRef* renderables) const; + inline std::size_t GetAttachedRenderableCount() const; + inline const Nz::BoundingVolumef& GetBoundingVolume() const; static ComponentIndex componentIndex; diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index 9ca100d0e..b38ce6dd6 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -79,6 +79,20 @@ namespace Ndk UpdateTransformMatrix(); } + inline void GraphicsComponent::GetAttachedRenderables(RenderableList* renderables) const + { + NazaraAssert(renderables, "Invalid renderable list"); + + renderables->reserve(renderables->size() + m_renderables.size()); + for (const Renderable& r : m_renderables) + renderables->push_back(r.renderable); + } + + inline std::size_t GraphicsComponent::GetAttachedRenderableCount() const + { + return m_renderables.size(); + } + inline const Nz::BoundingVolumef& GraphicsComponent::GetBoundingVolume() const { EnsureBoundingVolumeUpdate(); From a4120e0a37cc1629e9eb04c831c7c85f95eb4898 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 18:17:18 +0200 Subject: [PATCH 02/11] Fix typo Former-commit-id: 07bb1e9aa33b06c79b6d30af8598c5678eb4b37c [formerly db529eb77de00026196de3000f67fd13916011ef] Former-commit-id: 25db8b31bbd53791033517a4788471a8a3eafe9b --- SDK/include/NDK/Components/GraphicsComponent.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index 4ea76d0d8..a7ac3ebc2 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -40,7 +40,7 @@ namespace Ndk inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; - inline void GetAttachedRenderables(Nz::InstancedRenderableRef* renderables) const; + inline void GetAttachedRenderables(RenderableList* renderables) const; inline std::size_t GetAttachedRenderableCount() const; inline const Nz::BoundingVolumef& GetBoundingVolume() const; From b3e888563b11f9a578c2db470d241cf4f7e8cfb2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:34:45 +0200 Subject: [PATCH 03/11] Utility/OBJParser: Prepare for saving Former-commit-id: 90a78b4ca33ff8ce36fd5d37191799b196803c09 [formerly b39fe56eafb502516007de75ca77fdc6ab8a3391] Former-commit-id: 5481142d659e43f687a5b8b4e1634405702bfc7b --- include/Nazara/Utility/Formats/OBJParser.hpp | 67 ++++++++++++-------- include/Nazara/Utility/Formats/OBJParser.inl | 64 +++++++++++++++++++ src/Nazara/Utility/Formats/OBJLoader.cpp | 4 +- src/Nazara/Utility/Formats/OBJLoader.hpp | 4 +- src/Nazara/Utility/Formats/OBJParser.cpp | 10 ++- 5 files changed, 117 insertions(+), 32 deletions(-) diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 79aa1824a..b9c5e41c3 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -20,12 +20,41 @@ namespace Nz class NAZARA_UTILITY_API OBJParser { public: - struct FaceVertex - { - int normal; - int position; - int texCoord; - }; + struct Face; + struct FaceVertex; + struct Mesh; + + OBJParser() = default; + ~OBJParser() = default; + + inline void Clear(); + + inline String* GetMaterials(); + inline const String* GetMaterials() const; + inline unsigned int GetMaterialCount() const; + inline Mesh* GetMeshes(); + inline const Mesh* GetMeshes() const; + inline unsigned int GetMeshCount() const; + inline const String& GetMtlLib() const; + inline Vector3f* GetNormals(); + inline const Vector3f* GetNormals() const; + inline unsigned int GetNormalCount() const; + inline Vector4f* GetPositions(); + inline const Vector4f* GetPositions() const; + inline unsigned int GetPositionCount() const; + inline Vector3f* GetTexCoords(); + inline const Vector3f* GetTexCoords() const; + inline unsigned int GetTexCoordCount() const; + + bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); + + bool Save(Stream& stream) const; + + inline String* SetMaterialCount(std::size_t materialCount); + inline Mesh* SetMeshCount(std::size_t meshCount); + inline Vector3f* SetNormalCount(std::size_t normalCount); + inline Vector4f* SetPositionCount(std::size_t positionCount); + inline Vector3f* SetTexCoordCount(std::size_t texCoordCount); struct Face { @@ -33,6 +62,13 @@ namespace Nz std::size_t vertexCount; }; + struct FaceVertex + { + std::size_t normal; + std::size_t position; + std::size_t texCoord; + }; + struct Mesh { std::vector faces; @@ -41,25 +77,6 @@ namespace Nz std::size_t material; }; - OBJParser() = default; - ~OBJParser() = default; - - inline const String* GetMaterials() const; - inline unsigned int GetMaterialCount() const; - inline const Mesh* GetMeshes() const; - inline unsigned int GetMeshCount() const; - inline const String& GetMtlLib() const; - inline const Vector3f* GetNormals() const; - inline unsigned int GetNormalCount() const; - inline const Vector4f* GetPositions() const; - inline unsigned int GetPositionCount() const; - inline const Vector3f* GetTexCoords() const; - inline unsigned int GetTexCoordCount() const; - - bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); - - bool Save(Stream& stream) const; - private: bool Advance(bool required = true); template void Emit(const T& text) const; diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index 7cd0060b4..a4fcffaec 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -8,6 +8,20 @@ namespace Nz { + inline void OBJParser::Clear() + { + m_materials.clear(); + m_meshes.clear(); + m_positions.clear(); + m_normals.clear(); + m_texCoords.clear(); + } + + inline String* OBJParser::GetMaterials() + { + return m_materials.data(); + } + inline const String* OBJParser::GetMaterials() const { return m_materials.data(); @@ -18,6 +32,11 @@ namespace Nz return m_materials.size(); } + inline OBJParser::Mesh* OBJParser::GetMeshes() + { + return m_meshes.data(); + } + inline const OBJParser::Mesh* OBJParser::GetMeshes() const { return m_meshes.data(); @@ -33,6 +52,11 @@ namespace Nz return m_mtlLib; } + inline Vector3f* OBJParser::GetNormals() + { + return m_normals.data(); + } + inline const Vector3f* OBJParser::GetNormals() const { return m_normals.data(); @@ -43,6 +67,11 @@ namespace Nz return m_normals.size(); } + inline Vector4f* OBJParser::GetPositions() + { + return m_positions.data(); + } + inline const Vector4f* OBJParser::GetPositions() const { return m_positions.data(); @@ -53,6 +82,11 @@ namespace Nz return m_positions.size(); } + inline Vector3f* OBJParser::GetTexCoords() + { + return m_texCoords.data(); + } + inline const Vector3f* OBJParser::GetTexCoords() const { return m_texCoords.data(); @@ -63,6 +97,36 @@ namespace Nz return m_texCoords.size(); } + inline String* OBJParser::SetMaterialCount(std::size_t materialCount) + { + m_materials.resize(materialCount); + return m_materials.data(); + } + + inline OBJParser::Mesh* OBJParser::SetMeshCount(std::size_t meshCount) + { + m_meshes.resize(meshCount); + return m_meshes.data(); + } + + inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount) + { + m_normals.resize(normalCount); + return m_normals.data(); + } + + inline Vector4f* OBJParser::SetPositionCount(std::size_t positionCount) + { + m_positions.resize(positionCount); + return m_positions.data(); + } + + inline Vector3f* OBJParser::SetTexCoordCount(std::size_t texCoordCount) + { + m_texCoords.resize(texCoordCount); + return m_texCoords.data(); + } + template void OBJParser::Emit(const T& text) const { diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 720b5ec5d..a8d5d68ec 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -298,12 +298,12 @@ namespace Nz namespace Loaders { - void RegisterOBJ() + void RegisterOBJLoader() { MeshLoader::RegisterLoader(IsSupported, Check, Load); } - void UnregisterOBJ() + void UnregisterOBJLoader() { MeshLoader::UnregisterLoader(IsSupported, Check, Load); } diff --git a/src/Nazara/Utility/Formats/OBJLoader.hpp b/src/Nazara/Utility/Formats/OBJLoader.hpp index 05a3efdff..46dd8d976 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.hpp +++ b/src/Nazara/Utility/Formats/OBJLoader.hpp @@ -13,8 +13,8 @@ namespace Nz { namespace Loaders { - void RegisterOBJ(); - void UnregisterOBJ(); + void RegisterOBJLoader(); + void UnregisterOBJLoader(); } } diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index a05ef6960..5c941e938 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -125,9 +125,9 @@ namespace Nz for (unsigned int i = 0; i < vertexCount; ++i) { int offset; - int& n = currentMesh->vertices[face.firstVertex + i].normal; - int& p = currentMesh->vertices[face.firstVertex + i].position; - int& t = currentMesh->vertices[face.firstVertex + i].texCoord; + std::size_t n = 0; + std::size_t p = 0; + std::size_t t = 0; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { @@ -199,6 +199,10 @@ namespace Nz break; } + currentMesh->vertices[face.firstVertex + i].normal = static_cast(n); + currentMesh->vertices[face.firstVertex + i].position = static_cast(p); + currentMesh->vertices[face.firstVertex + i].texCoord = static_cast(t); + pos += offset; } From a1108ed9551634838546eb58d745025e97ec712b Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:35:36 +0200 Subject: [PATCH 04/11] Utility/IndexMapper: Makes it work without index buffers (sequential mode) Former-commit-id: 594f3f2c31f30122889e8b3f2dd214b09455b640 [formerly 085c770b3effaa2faf9b61fa32280a7957f71258] Former-commit-id: a54711d1cfb80f2792a80174a5808bb44d2095f3 --- include/Nazara/Utility/IndexMapper.hpp | 7 +- src/Nazara/Utility/IndexMapper.cpp | 89 +++++++++++++++----------- 2 files changed, 55 insertions(+), 41 deletions(-) diff --git a/include/Nazara/Utility/IndexMapper.hpp b/include/Nazara/Utility/IndexMapper.hpp index 9dd6a5c46..7f632f196 100644 --- a/include/Nazara/Utility/IndexMapper.hpp +++ b/include/Nazara/Utility/IndexMapper.hpp @@ -23,9 +23,10 @@ namespace Nz class NAZARA_UTILITY_API IndexMapper { public: - IndexMapper(IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadWrite); - IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadOnly); - IndexMapper(const SubMesh* subMesh); + IndexMapper(IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadWrite, std::size_t indexCount = 0); + IndexMapper(SubMesh* subMesh, BufferAccess access = BufferAccess_ReadWrite); + IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadOnly, std::size_t indexCount = 0); + IndexMapper(const SubMesh* subMesh, BufferAccess access = BufferAccess_ReadOnly); ~IndexMapper() = default; UInt32 Get(unsigned int i) const; diff --git a/src/Nazara/Utility/IndexMapper.cpp b/src/Nazara/Utility/IndexMapper.cpp index adf80a764..5a664128c 100644 --- a/src/Nazara/Utility/IndexMapper.cpp +++ b/src/Nazara/Utility/IndexMapper.cpp @@ -12,6 +12,13 @@ namespace Nz { namespace { + UInt32 GetterSequential(const void* buffer, unsigned int i) + { + NazaraUnused(buffer); + + return i; + } + UInt32 Getter16(const void* buffer, unsigned int i) { const UInt16* ptr = static_cast(buffer); @@ -42,61 +49,67 @@ namespace Nz } } - IndexMapper::IndexMapper(IndexBuffer* indexBuffer, BufferAccess access) : - m_indexCount(indexBuffer->GetIndexCount()) + IndexMapper::IndexMapper(IndexBuffer* indexBuffer, BufferAccess access, std::size_t indexCount) : + m_indexCount((indexCount != 0) ? indexCount : indexBuffer->GetIndexCount()) { - #if NAZARA_UTILITY_SAFE - if (!indexBuffer) - { - NazaraError("Index buffer must be valid"); - return; - } - #endif + NazaraAssert(indexCount != 0 || indexBuffer, "Invalid index count with invalid index buffer"); - if (!m_mapper.Map(indexBuffer, access)) - NazaraError("Failed to map buffer"); ///TODO: Unexcepted - - if (indexBuffer->HasLargeIndices()) + if (indexBuffer) { - m_getter = Getter32; - if (access != BufferAccess_ReadOnly) - m_setter = Setter32; + if (!m_mapper.Map(indexBuffer, access)) + NazaraError("Failed to map buffer"); ///TODO: Unexcepted + + if (indexBuffer->HasLargeIndices()) + { + m_getter = Getter32; + if (access != BufferAccess_ReadOnly) + m_setter = Setter32; + else + m_setter = SetterError; + } else - m_setter = SetterError; + { + m_getter = Getter16; + if (access != BufferAccess_ReadOnly) + m_setter = Setter16; + else + m_setter = SetterError; + } } else { - m_getter = Getter16; - if (access != BufferAccess_ReadOnly) - m_setter = Setter16; - else - m_setter = SetterError; + m_getter = GetterSequential; + m_setter = SetterError; } } - IndexMapper::IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access) : + IndexMapper::IndexMapper(SubMesh* subMesh, BufferAccess access) : + IndexMapper(subMesh->GetIndexBuffer(), access, (subMesh->GetIndexBuffer()) ? 0 : subMesh->GetVertexCount()) + { + } + + IndexMapper::IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access, std::size_t indexCount) : m_setter(SetterError), - m_indexCount(indexBuffer->GetIndexCount()) + m_indexCount((indexCount != 0) ? indexCount : indexBuffer->GetIndexCount()) { - #if NAZARA_UTILITY_SAFE - if (!indexBuffer) + NazaraAssert(indexCount != 0 || indexBuffer, "Invalid index count with invalid index buffer"); + + if (indexBuffer) { - NazaraError("Index buffer must be valid"); - return; + if (!m_mapper.Map(indexBuffer, access)) + NazaraError("Failed to map buffer"); ///TODO: Unexcepted + + if (indexBuffer->HasLargeIndices()) + m_getter = Getter32; + else + m_getter = Getter16; } - #endif - - if (!m_mapper.Map(indexBuffer, access)) - NazaraError("Failed to map buffer"); ///TODO: Unexcepted - - if (indexBuffer->HasLargeIndices()) - m_getter = Getter32; else - m_getter = Getter16; + m_getter = GetterSequential; } - IndexMapper::IndexMapper(const SubMesh* subMesh) : - IndexMapper(subMesh->GetIndexBuffer()) + IndexMapper::IndexMapper(const SubMesh* subMesh, BufferAccess access) : + IndexMapper(subMesh->GetIndexBuffer(), access, (subMesh->GetIndexBuffer()) ? 0 : subMesh->GetVertexCount()) { } From 52436a93955405b0fe3a3c1fc9e7bd3a9c6de990 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:35:48 +0200 Subject: [PATCH 05/11] Utility: Fix an oopsie Former-commit-id: 90d740ad9f3dac2dc742a5febc431b269c90ddbb [formerly 46c254826cbbca0231713289771add7a46df3a3c] Former-commit-id: c34ceb2f44c83914d2207454612682590b4fcfb4 --- src/Nazara/Utility/Utility.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 78553ce54..ae5b5066d 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -124,7 +124,7 @@ namespace Nz Loaders::RegisterMD5Anim(); // Loader de fichiers .md5anim (v10) // Mesh (text) - Loaders::RegisterOBJ(); + Loaders::RegisterOBJLoader(); // Mesh Loaders::RegisterMD2(); // Loader de fichiers .md2 (v8) @@ -162,7 +162,7 @@ namespace Nz Loaders::UnregisterMD2(); Loaders::UnregisterMD5Anim(); Loaders::UnregisterMD5Mesh(); - Loaders::UnregisterOBJ(); + Loaders::UnregisterOBJLoader(); Loaders::UnregisterPCX(); Loaders::UnregisterSTBLoader(); Loaders::UnregisterSTBSaver(); From 5711ff555fb67a126423967b7bd9c84c489c1c57 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:36:42 +0200 Subject: [PATCH 06/11] Utility: Allow TriangleIterator and VertexMapper to take constant submesh Former-commit-id: 708fe75333a54b739794e7c9729ee1557ab26164 [formerly c68c2ff4e2deb1a512237ec4e502f00c801f7c7e] Former-commit-id: 5fd3fd8b0a518526ee3c91d418cf321611d2bc67 --- include/Nazara/Utility/TriangleIterator.hpp | 2 +- include/Nazara/Utility/VertexMapper.hpp | 2 ++ src/Nazara/Utility/TriangleIterator.cpp | 13 ++++++-- src/Nazara/Utility/VertexMapper.cpp | 36 +++++++++++++++++++++ 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Utility/TriangleIterator.hpp b/include/Nazara/Utility/TriangleIterator.hpp index 0addb1836..32c9ceb07 100644 --- a/include/Nazara/Utility/TriangleIterator.hpp +++ b/include/Nazara/Utility/TriangleIterator.hpp @@ -19,7 +19,7 @@ namespace Nz { public: TriangleIterator(PrimitiveMode primitiveMode, const IndexBuffer* indexBuffer); - TriangleIterator(SubMesh* subMesh); + TriangleIterator(const SubMesh* subMesh); ~TriangleIterator() = default; bool Advance(); diff --git a/include/Nazara/Utility/VertexMapper.hpp b/include/Nazara/Utility/VertexMapper.hpp index 3dc9accdb..e18250d7c 100644 --- a/include/Nazara/Utility/VertexMapper.hpp +++ b/include/Nazara/Utility/VertexMapper.hpp @@ -22,6 +22,8 @@ namespace Nz public: VertexMapper(SubMesh* subMesh, BufferAccess access = BufferAccess_ReadWrite); VertexMapper(VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadWrite); + VertexMapper(const SubMesh* subMesh, BufferAccess access = BufferAccess_ReadOnly); + VertexMapper(const VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadOnly); ~VertexMapper(); template SparsePtr GetComponentPtr(VertexComponent component); diff --git a/src/Nazara/Utility/TriangleIterator.cpp b/src/Nazara/Utility/TriangleIterator.cpp index 0c6830c87..53086ddb8 100644 --- a/src/Nazara/Utility/TriangleIterator.cpp +++ b/src/Nazara/Utility/TriangleIterator.cpp @@ -17,12 +17,19 @@ namespace Nz m_triangleIndices[1] = m_indexMapper.Get(1); m_triangleIndices[2] = m_indexMapper.Get(2); - m_indexCount = indexBuffer->GetIndexCount(); + m_indexCount = m_indexMapper.GetIndexCount(); } - TriangleIterator::TriangleIterator(SubMesh* subMesh) : - TriangleIterator(subMesh->GetPrimitiveMode(), subMesh->GetIndexBuffer()) + TriangleIterator::TriangleIterator(const SubMesh* subMesh) : + m_primitiveMode(subMesh->GetPrimitiveMode()), + m_indexMapper(subMesh, BufferAccess_ReadOnly) { + m_currentIndex = 3; + m_triangleIndices[0] = m_indexMapper.Get(0); + m_triangleIndices[1] = m_indexMapper.Get(1); + m_triangleIndices[2] = m_indexMapper.Get(2); + + m_indexCount = m_indexMapper.GetIndexCount(); } bool TriangleIterator::Advance() diff --git a/src/Nazara/Utility/VertexMapper.cpp b/src/Nazara/Utility/VertexMapper.cpp index 1edbdc7f8..158dae801 100644 --- a/src/Nazara/Utility/VertexMapper.cpp +++ b/src/Nazara/Utility/VertexMapper.cpp @@ -47,6 +47,42 @@ namespace Nz ErrorFlags flags(ErrorFlag_ThrowException, true); m_mapper.Map(vertexBuffer, access); } + + VertexMapper::VertexMapper(const SubMesh* subMesh, BufferAccess access) + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + + const VertexBuffer* buffer = nullptr; + switch (subMesh->GetAnimationType()) + { + case AnimationType_Skeletal: + { + const SkeletalMesh* skeletalMesh = static_cast(subMesh); + buffer = skeletalMesh->GetVertexBuffer(); + break; + } + + case AnimationType_Static: + { + const StaticMesh* staticMesh = static_cast(subMesh); + buffer = staticMesh->GetVertexBuffer(); + break; + } + } + + if (!buffer) + { + NazaraInternalError("Animation type not handled (0x" + String::Number(subMesh->GetAnimationType(), 16) + ')'); + } + + m_mapper.Map(buffer, access); + } + + VertexMapper::VertexMapper(const VertexBuffer* vertexBuffer, BufferAccess access) + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + m_mapper.Map(vertexBuffer, access); + } VertexMapper::~VertexMapper() = default; From c2270f23ce16a3122780b7c5b337faf36f5a2a7c Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:36:54 +0200 Subject: [PATCH 07/11] Utility/STBSaver: Fix error message Former-commit-id: 40d0d01efcce56f8cd1ba516a5f1336ac4dc2a26 [formerly 46a7331866a7a1033d8238d2f49a6100bc9e8dd6] Former-commit-id: 52de2bb4622a3499f69fb59dc5b9f1602cbac8cb --- src/Nazara/Utility/Formats/STBSaver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Utility/Formats/STBSaver.cpp b/src/Nazara/Utility/Formats/STBSaver.cpp index 4166de86f..1b65312fe 100644 --- a/src/Nazara/Utility/Formats/STBSaver.cpp +++ b/src/Nazara/Utility/Formats/STBSaver.cpp @@ -121,7 +121,7 @@ namespace Nz ImageType type = image.GetType(); if (type != ImageType_1D && type != ImageType_2D) { - NazaraError("Image type 0x" + String::Number(type, 16) + " is not "); + NazaraError("Image type 0x" + String::Number(type, 16) + " is not in a supported format"); return false; } From f17228d568a21063d26c5888fea6074b1ef949d0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:37:22 +0200 Subject: [PATCH 08/11] Utility/Mesh: Add MeshSaver Former-commit-id: 5d80ab9f7da18c157ba5f2b903007b8702f12700 [formerly 2e7f2fe5ea6ba7d744f7af8a89c073fb2519b4db] Former-commit-id: 05124de36a78a3780dd167efea9865c1728cc475 --- include/Nazara/Utility/Mesh.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 865a228a9..11e7c14bd 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,7 @@ namespace Nz using MeshLoader = ResourceLoader; using MeshManager = ResourceManager; using MeshRef = ObjectRef; + using MeshSaver = ResourceSaver; struct MeshImpl; From a1a445d90dcba7df1109d5ddab8545e6a80fd53a Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:38:34 +0200 Subject: [PATCH 09/11] Utility/OBJParser: Fix mistake Former-commit-id: 09440c600405f710e5f1c03cac353f6986830814 [formerly 3ce06ef4b0d7c941835580b080e8a73c853e13cf] Former-commit-id: 21b606ff995a7192e5fa322b6eb11759ce274e39 --- src/Nazara/Utility/Formats/OBJParser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 5c941e938..cec716442 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -125,9 +125,9 @@ namespace Nz for (unsigned int i = 0; i < vertexCount; ++i) { int offset; - std::size_t n = 0; - std::size_t p = 0; - std::size_t t = 0; + int n = 0; + int p = 0; + int t = 0; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { From 6c34b55bdd77b4e5b615688e13cdfe1432b3cade Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:40:51 +0200 Subject: [PATCH 10/11] Utility/Mesh: Fix linking Former-commit-id: 03c42c75e847592a08693b607270673838a47230 [formerly 077959728baeaf36fe3ad80cf0fb2e8b6cc7e7e9] Former-commit-id: caae509fb871f0b05147f034c75403cafadd2959 --- src/Nazara/Utility/Mesh.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index f41f67440..0401a9a10 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -697,4 +697,5 @@ namespace Nz MeshLoader::LoaderList Mesh::s_loaders; MeshManager::ManagerMap Mesh::s_managerMap; MeshManager::ManagerParams Mesh::s_managerParameters; + MeshSaver::SaverList Mesh::s_savers; }