From 6ff9b825ff7110c524b58425d5864af3dc7b102c Mon Sep 17 00:00:00 2001 From: Dimo Markov Date: Sun, 17 Mar 2024 15:49:28 +0200 Subject: [PATCH] Mesh interface improvements --- include/Langulus/Asset.inl | 3 +- include/Langulus/Mesh.hpp | 12 ++++---- include/Langulus/Mesh.inl | 58 ++++++++++++++++++++++++-------------- 3 files changed, 45 insertions(+), 28 deletions(-) diff --git a/include/Langulus/Asset.inl b/include/Langulus/Asset.inl index 409f4a2..eb7dde7 100644 --- a/include/Langulus/Asset.inl +++ b/include/Langulus/Asset.inl @@ -57,8 +57,7 @@ namespace Langulus::A /// Get a data list from the contents /// @tparam T - the trait to search for /// @return a pointer to the data list, or nullptr if none exists - template - LANGULUS(INLINED) + template LANGULUS(INLINED) const Asset::DataList* Asset::GetDataList() const noexcept { return GetDataList(MetaTraitOf()); } diff --git a/include/Langulus/Mesh.hpp b/include/Langulus/Mesh.hpp index 266d44b..616f683 100644 --- a/include/Langulus/Mesh.hpp +++ b/include/Langulus/Mesh.hpp @@ -61,11 +61,13 @@ namespace Langulus::A template NOD() bool CheckTopology() const; NOD() DMeta GetTopology() const noexcept; + void SetTopology(DMeta) noexcept; NOD() Math::MapMode GetTextureMapper() const noexcept; + void SetTextureMapper(Math::MapMode) noexcept; - NOD() const MeshView& GetView() const noexcept; - NOD() MeshView& GetView() noexcept; + NOD() MeshView const& GetView() const noexcept; + NOD() MeshView& GetView() noexcept; NOD() virtual Ref GetLOD(const Math::LOD&) const = 0; @@ -75,21 +77,21 @@ namespace Langulus::A // NOD() bool MadeOfPoints() const noexcept; NOD() Count GetPointCount() const; - template + template NOD() Any GetPointTrait(Offset) const; // NOD() bool MadeOfLines() const noexcept; NOD() Count GetLineCount() const; NOD() Math::Vec2u GetLineIndices(Offset) const; - template + template NOD() Any GetLineTrait(Offset) const; // NOD() bool MadeOfTriangles() const noexcept; NOD() Count GetTriangleCount() const; NOD() Math::Vec3u GetTriangleIndices(Offset) const; - template + template NOD() Any GetTriangleTrait(Offset) const; }; diff --git a/include/Langulus/Mesh.inl b/include/Langulus/Mesh.inl index 5828116..308c726 100644 --- a/include/Langulus/Mesh.inl +++ b/include/Langulus/Mesh.inl @@ -82,6 +82,14 @@ namespace Langulus::A return mView.mTopology; } + /// Set the topology of the geometry + /// @attention will reset all contents + LANGULUS(INLINED) + void Mesh::SetTopology(DMeta t) noexcept { + mView.mTopology = t; + mDataListMap.Reset(); + } + /// Check if topology matches one of the specified types /// @tparam T1, TN - types to check /// @return true if T matches one of the topology types @@ -90,6 +98,35 @@ namespace Langulus::A return mView.mTopology == MetaDataOf() or ((mView.mTopology == MetaDataOf()) or ...); } + + /// Get texture mapping mode + /// @return the texturing mode + LANGULUS(INLINED) + Math::MapMode Mesh::GetTextureMapper() const noexcept { + return mView.mTextureMapping; + } + + /// Set texture mapping mode + /// @attention will reset texture coordinates + LANGULUS(INLINED) + void Mesh::SetTextureMapper(Math::MapMode m) noexcept { + mView.mTextureMapping = m; + mDataListMap.RemoveKey(MetaTraitOf()); + } + + /// Get the geometry view (const) + /// @return the geometry view + LANGULUS(INLINED) + const MeshView& Mesh::GetView() const noexcept { + return mView; + } + + /// Get the geometry view + /// @return the geometry view + LANGULUS(INLINED) + MeshView& Mesh::GetView() noexcept { + return mView; + } /// Helper that indirects in case there is an index buffer /// @param indices - index buffer @@ -403,25 +440,4 @@ namespace Langulus::A return result; } - /// Get texture mapping mode - /// @return the texturing mode - LANGULUS(INLINED) - Math::MapMode Mesh::GetTextureMapper() const noexcept { - return mView.mTextureMapping; - } - - /// Get the geometry view (const) - /// @return the geometry view - LANGULUS(INLINED) - const MeshView& Mesh::GetView() const noexcept { - return mView; - } - - /// Get the geometry view - /// @return the geometry view - LANGULUS(INLINED) - MeshView& Mesh::GetView() noexcept { - return mView; - } - } // namespace Langulus::A