diff --git a/private/Framework/ProcessorImpl.cpp b/private/Framework/ProcessorImpl.cpp index f6a4de68..4fbca843 100644 --- a/private/Framework/ProcessorImpl.cpp +++ b/private/Framework/ProcessorImpl.cpp @@ -313,6 +313,16 @@ void ProcessorImpl::DumpSceneDatabase() printf("\t[Associated Texture %u] Type = %s\n", textureID.Data(), cd::GetMaterialPropertyGroupName(textureType)); printf("\t\tPath = %s\n", texture.GetPath()); } + + if (auto optUVScale = material.GetVec2fProperty(textureType, cd::MaterialProperty::UVScale); optUVScale.has_value()) + { + details::Dump("\t\tMetallicUVScale", optUVScale.value()); + } + if (auto optUVOffset = material.GetVec2fProperty(textureType, cd::MaterialProperty::UVOffset); optUVOffset.has_value()) + { + details::Dump("\t\tMetallicUVOffset", optUVOffset.value()); + } + } if (auto itDrawMeshes = materialDrawMeshIDs.find(material.GetID().Data()); @@ -336,8 +346,6 @@ void ProcessorImpl::DumpSceneDatabase() printf("\tName = %s\n", texture.GetName()); printf("\tPath = %s\n", texture.GetPath()); printf("\tUVMapMode = (%s, %s)\n", GetTextureMapModeName(texture.GetUMapMode()), GetTextureMapModeName(texture.GetVMapMode())); - details::Dump("\tUVOffset", texture.GetUVOffset()); - details::Dump("\tUVScale", texture.GetUVScale()); } } diff --git a/private/Math/MeshGenerator.cpp b/private/Math/MeshGenerator.cpp index bca85f50..d51839b0 100644 --- a/private/Math/MeshGenerator.cpp +++ b/private/Math/MeshGenerator.cpp @@ -89,12 +89,12 @@ std::optional MeshGenerator::Generate(const Box& box, const VertexFormat& cd::Mesh mesh(static_cast(positions.size()), static_cast(polygons.size())); - for (uint32_t i = 0; i < positions.size(); ++i) + for (uint32_t i = 0U; i < positions.size(); ++i) { mesh.SetVertexPosition(i, positions[i]); } - for (uint32_t i = 0; i < polygons.size(); ++i) + for (uint32_t i = 0U; i < polygons.size(); ++i) { mesh.SetPolygon(i, polygons[i]); } @@ -303,4 +303,4 @@ std::optional MeshGenerator::Generate(const Sphere& sphere, uint32_t numSt return mesh; } -} \ No newline at end of file +} diff --git a/private/Producers/GenericProducer/GenericProducerImpl.cpp b/private/Producers/GenericProducer/GenericProducerImpl.cpp index 1d1a2913..aa82bd71 100644 --- a/private/Producers/GenericProducer/GenericProducerImpl.cpp +++ b/private/Producers/GenericProducer/GenericProducerImpl.cpp @@ -259,7 +259,10 @@ cd::MaterialID GenericProducerImpl::AddMaterial(cd::SceneDatabase* pSceneDatabas aiUVTransform uvTransform; unsigned int maxBytes = sizeof(aiUVTransform); aiGetMaterialFloatArray(pSourceMaterial, AI_MATKEY_UVTRANSFORM(textureType, textureIndex), (float*)&uvTransform, &maxBytes); - + + material.SetVec2fProperty(materialTextureType, cd::MaterialProperty::UVScale, cd::Vec2f(uvTransform.mScaling.x, uvTransform.mScaling.y)); + material.SetVec2fProperty(materialTextureType, cd::MaterialProperty::UVOffset, cd::Vec2f(uvTransform.mTranslation.x, uvTransform.mTranslation.y)); + // Reused textures don't need to add to SceneDatabase again. if (!isTextureReused) { @@ -268,8 +271,6 @@ cd::MaterialID GenericProducerImpl::AddMaterial(cd::SceneDatabase* pSceneDatabas cd::Texture materialTexture(textureID, textureName.string().c_str(), materialTextureType); materialTexture.SetPath(textureAbsolutePath.string().c_str()); ConvertAssimpTextureMapMode(textureMapMode[0]), ConvertAssimpTextureMapMode(textureMapMode[1]); - materialTexture.SetUVOffset(cd::Vec2f(uvTransform.mTranslation.x, uvTransform.mTranslation.y)); - materialTexture.SetUVScale(cd::Vec2f(uvTransform.mScaling.x, uvTransform.mScaling.y)); pSceneDatabase->AddTexture(cd::MoveTemp(materialTexture)); } else diff --git a/private/Scene/Material.cpp b/private/Scene/Material.cpp index 9624658a..d26b1aa2 100644 --- a/private/Scene/Material.cpp +++ b/private/Scene/Material.cpp @@ -201,6 +201,11 @@ std::optional Material::GetStringProperty(MaterialPropertyGroup pro return m_pMaterialImpl->GetProperty(propertyGroup, property); } +std::optional Material::GetVec2fProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const +{ + return m_pMaterialImpl->GetProperty(propertyGroup, property); +} + bool Material::ExistProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const { return m_pMaterialImpl->ExistProperty(propertyGroup, property); diff --git a/private/Scene/Texture.cpp b/private/Scene/Texture.cpp index e7943dfc..2c463378 100644 --- a/private/Scene/Texture.cpp +++ b/private/Scene/Texture.cpp @@ -84,26 +84,6 @@ void Texture::SetVMapMode(cd::TextureMapMode mapMode) m_pTextureImpl->SetVMapMode(mapMode); } -const cd::Vec2f& Texture::GetUVOffset() const -{ - return m_pTextureImpl->GetUVOffset(); -} - -void Texture::SetUVOffset(cd::Vec2f uvOffset) -{ - m_pTextureImpl->SetUVOffset(cd::MoveTemp(uvOffset)); -} - -const cd::Vec2f& Texture::GetUVScale() const -{ - return m_pTextureImpl->GetUVScale(); -} - -void Texture::SetUVScale(cd::Vec2f uvScale) -{ - m_pTextureImpl->SetUVScale(cd::MoveTemp(uvScale)); -} - cd::TextureFormat Texture::GetFormat() const { return m_pTextureImpl->GetFormat(); diff --git a/public/PropertyMap/PropertyMap.hpp b/public/PropertyMap/PropertyMap.hpp index d7015672..599da6d1 100644 --- a/public/PropertyMap/PropertyMap.hpp +++ b/public/PropertyMap/PropertyMap.hpp @@ -47,7 +47,7 @@ class PropertyMap final { return m_stringProperty.at(key); } - else if constexpr (4 <= sizeof(T)) + else if constexpr (4 >= sizeof(T)) { return reinterpret_cast(m_byte4Property.at(key)); } diff --git a/public/Scene/Material.h b/public/Scene/Material.h index b0a83c2b..c6d33050 100644 --- a/public/Scene/Material.h +++ b/public/Scene/Material.h @@ -71,6 +71,7 @@ class CORE_API Material final std::optional GetFloatProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const; std::optional GetDoubleProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const; std::optional GetStringProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const; + std::optional GetVec2fProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const; bool ExistProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const; diff --git a/public/Scene/MaterialTextureType.h b/public/Scene/MaterialTextureType.h index f98d78dd..73a022bc 100644 --- a/public/Scene/MaterialTextureType.h +++ b/public/Scene/MaterialTextureType.h @@ -74,6 +74,8 @@ enum class MaterialProperty Factor, Texture, UseTexture, + UVOffset, + UVScale, // Just for BaseColor Color, @@ -96,6 +98,8 @@ constexpr const char *MaterialPropertyName[] = "Factor", "Texture", "UseTexture", + "UVOffset", + "UVScale", "Color", "BlendMode", "OpacityMaskClipValue", diff --git a/public/Scene/Texture.h b/public/Scene/Texture.h index 70896766..7950e64e 100644 --- a/public/Scene/Texture.h +++ b/public/Scene/Texture.h @@ -45,12 +45,6 @@ class CORE_API Texture final cd::TextureMapMode GetVMapMode() const; void SetVMapMode(cd::TextureMapMode mapMode); - const cd::Vec2f& GetUVOffset() const; - void SetUVOffset(cd::Vec2f uvOffset); - - const cd::Vec2f& GetUVScale() const; - void SetUVScale(cd::Vec2f uvScale); - // File texture data const char* GetPath() const; void SetPath(const char* pFilePath);