From 4797e147b5e4270f8a1d27db613d35fc27d8abe3 Mon Sep 17 00:00:00 2001 From: Tobias Frisch <tfrisch@uni-koblenz.de> Date: Fri, 9 Jul 2021 11:59:10 +0200 Subject: [PATCH] [#56] Fixed material usage increase/decrease Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de> --- modules/scene/include/vkcv/scene/MeshPart.hpp | 4 ++-- modules/scene/src/vkcv/scene/MeshPart.cpp | 24 +++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/modules/scene/include/vkcv/scene/MeshPart.hpp b/modules/scene/include/vkcv/scene/MeshPart.hpp index 027c6f20..0d3467c6 100644 --- a/modules/scene/include/vkcv/scene/MeshPart.hpp +++ b/modules/scene/include/vkcv/scene/MeshPart.hpp @@ -34,8 +34,8 @@ namespace vkcv::scene { public: ~MeshPart(); - MeshPart(const MeshPart& other) = default; - MeshPart(MeshPart&& other) = default; + MeshPart(const MeshPart& other); + MeshPart(MeshPart&& other); MeshPart& operator=(const MeshPart& other); MeshPart& operator=(MeshPart&& other) noexcept; diff --git a/modules/scene/src/vkcv/scene/MeshPart.cpp b/modules/scene/src/vkcv/scene/MeshPart.cpp index 4bed429a..46e79897 100644 --- a/modules/scene/src/vkcv/scene/MeshPart.cpp +++ b/modules/scene/src/vkcv/scene/MeshPart.cpp @@ -83,6 +83,28 @@ namespace vkcv::scene { m_scene.decreaseMaterialUsage(m_materialIndex); } + MeshPart::MeshPart(const MeshPart &other) : + m_scene(other.m_scene), + m_vertices(other.m_vertices), + m_vertexBindings(other.m_vertexBindings), + m_indices(other.m_indices), + m_indexCount(other.m_indexCount), + m_bounds(other.m_bounds), + m_materialIndex(other.m_materialIndex) { + m_scene.increaseMaterialUsage(m_materialIndex); + } + + MeshPart::MeshPart(MeshPart &&other) : + m_scene(other.m_scene), + m_vertices(other.m_vertices), + m_vertexBindings(other.m_vertexBindings), + m_indices(other.m_indices), + m_indexCount(other.m_indexCount), + m_bounds(other.m_bounds), + m_materialIndex(other.m_materialIndex) { + m_scene.increaseMaterialUsage(m_materialIndex); + } + MeshPart &MeshPart::operator=(const MeshPart &other) { if (&other == this) { return *this; @@ -106,8 +128,6 @@ namespace vkcv::scene { m_bounds = other.m_bounds; m_materialIndex = other.m_materialIndex; - other.m_materialIndex = std::numeric_limits<size_t>::max(); - return *this; } -- GitLab