Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.

Commit

Permalink
Fixed uvs and normals
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestionableM committed May 14, 2022
1 parent d3d12bc commit f9d641e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Code/BlueprintConverter/ModelStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ namespace SMBC
const std::size_t uv_offset = model->uvs.size();
const std::size_t normal_offset = model->normals.size();

const bool has_uvs = ConvertSettings::ExportUvs && mesh->HasTextureCoords(0);
const bool has_normals = ConvertSettings::ExportNormals && mesh->HasNormals();

sub_mesh->DataIdx.reserve(mesh->mNumFaces);
for (unsigned int a = 0; a < mesh->mNumFaces; a++)
{
Expand All @@ -73,8 +70,8 @@ namespace SMBC

d_idx.push_back({
ind_idx + vertex_offset,
(has_uvs ? (ind_idx + uv_offset) : -1),
(has_normals ? (ind_idx + normal_offset) : -1)
(sub_mesh->has_uvs ? (ind_idx + uv_offset) : 0),
(sub_mesh->has_normals ? (ind_idx + normal_offset) : 0)
});
}

Expand All @@ -90,6 +87,9 @@ namespace SMBC
const aiMesh* cMesh = scene->mMeshes[a];
SubMeshData* cSubMesh = new SubMeshData(a);

cSubMesh->has_normals = ConvertSettings::ExportNormals && cMesh->HasNormals();
cSubMesh->has_uvs = ConvertSettings::ExportUvs && cMesh->HasTextureCoords(0);

ModelStorage::LoadIndices(cMesh, model, cSubMesh);
ModelStorage::LoadVertices(cMesh, model);
ModelStorage::LoadMaterialName(scene, cMesh, cSubMesh);
Expand Down
4 changes: 4 additions & 0 deletions Code/BlueprintConverter/ObjectDefinitions/BlockModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ namespace SMBC
}

SubMeshData* new_subMesh = new SubMeshData(0);

new_subMesh->has_normals = ConvertSettings::ExportNormals;
new_subMesh->has_uvs = ConvertSettings::ExportUvs;

new_subMesh->DataIdx =
{
{{0, 0, 0}, {1, 1, 0}, {2, 2, 0}},
Expand Down
9 changes: 3 additions & 6 deletions Code/BlueprintConverter/ObjectDefinitions/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,18 @@ namespace SMBC
if (mOffset.VertexMap.find(pVertex) != mOffset.VertexMap.end())
String::Combine(_f_str, " ", (mOffset.VertexMap.at(pVertex) + 1));

const bool has_uv = (ConvertSettings::ExportUvs && d_idx.m_Uv > -1);
const bool has_normal = (ConvertSettings::ExportNormals && d_idx.m_Norm > -1);

if (!has_uv && !has_normal) continue;
if (!pSubMesh->has_uvs && !pSubMesh->has_normals) continue;

_f_str.append("/");

if (has_uv)
if (pSubMesh->has_uvs)
{
const glm::vec2& pUv = this->uvs[d_idx.m_Uv];
if (mOffset.UvMap.find(pUv) != mOffset.UvMap.end())
String::Combine(_f_str, (mOffset.UvMap.at(pUv) + 1));
}

if (has_normal)
if (pSubMesh->has_normals)
{
const glm::vec3& pNormal = translated_normals[d_idx.m_Norm];
if (mOffset.NormalMap.find(pNormal) != mOffset.NormalMap.end())
Expand Down
3 changes: 3 additions & 0 deletions Code/BlueprintConverter/ObjectDefinitions/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ namespace SMBC

std::vector<std::vector<VertexData>> DataIdx;

bool has_uvs;
bool has_normals;

bool IsEmpty();
SubMeshData(const int& sub_mesh_idx);
~SubMeshData() = default;
Expand Down
2 changes: 1 addition & 1 deletion Code/Lib/BuildVersion.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#pragma once
#define SMBC_BUILD_VERSION 856
#define SMBC_BUILD_VERSION 858

0 comments on commit f9d641e

Please sign in to comment.