Skip to content

Commit

Permalink
Merge https://github.com/bxy176179/AssetPipeline into CubeIndexForAABB
Browse files Browse the repository at this point in the history
  • Loading branch information
bxy176179 committed Aug 5, 2023
2 parents ff2e29b + 263c11c commit ff67cc0
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 35 deletions.
12 changes: 10 additions & 2 deletions private/Framework/ProcessorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
}
}

Expand Down
6 changes: 3 additions & 3 deletions private/Math/MeshGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ std::optional<Mesh> MeshGenerator::Generate(const Box& box, const VertexFormat&

cd::Mesh mesh(static_cast<uint32_t>(positions.size()), static_cast<uint32_t>(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]);
}
Expand Down Expand Up @@ -303,4 +303,4 @@ std::optional<Mesh> MeshGenerator::Generate(const Sphere& sphere, uint32_t numSt
return mesh;
}

}
}
7 changes: 4 additions & 3 deletions private/Producers/GenericProducer/GenericProducerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions private/Scene/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ std::optional<std::string> Material::GetStringProperty(MaterialPropertyGroup pro
return m_pMaterialImpl->GetProperty<std::string>(propertyGroup, property);
}

std::optional<cd::Vec2f> Material::GetVec2fProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const
{
return m_pMaterialImpl->GetProperty<cd::Vec2f>(propertyGroup, property);
}

bool Material::ExistProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const
{
return m_pMaterialImpl->ExistProperty(propertyGroup, property);
Expand Down
20 changes: 0 additions & 20 deletions private/Scene/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion public/PropertyMap/PropertyMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const T &>(m_byte4Property.at(key));
}
Expand Down
1 change: 1 addition & 0 deletions public/Scene/Material.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class CORE_API Material final
std::optional<float> GetFloatProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const;
std::optional<double> GetDoubleProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const;
std::optional<std::string> GetStringProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const;
std::optional<cd::Vec2f> GetVec2fProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const;

bool ExistProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const;

Expand Down
4 changes: 4 additions & 0 deletions public/Scene/MaterialTextureType.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ enum class MaterialProperty
Factor,
Texture,
UseTexture,
UVOffset,
UVScale,

// Just for BaseColor
Color,
Expand All @@ -96,6 +98,8 @@ constexpr const char *MaterialPropertyName[] =
"Factor",
"Texture",
"UseTexture",
"UVOffset",
"UVScale",
"Color",
"BlendMode",
"OpacityMaskClipValue",
Expand Down
6 changes: 0 additions & 6 deletions public/Scene/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ff67cc0

Please sign in to comment.