parent
f0ac3bf4f7
commit
4be720a677
|
@ -135,10 +135,12 @@ std::unique_ptr<Drawable> Model::processMesh(aiMesh* mesh, const aiScene* scene,
|
||||||
std::vector<Vertex> vertices;
|
std::vector<Vertex> vertices;
|
||||||
for (unsigned int i = 0; i < mesh->mNumVertices; i++)
|
for (unsigned int i = 0; i < mesh->mNumVertices; i++)
|
||||||
{
|
{
|
||||||
if (mesh->mNormals && mesh->mTextureCoords[0])
|
if (mesh->mNormals)
|
||||||
{
|
{
|
||||||
auto pos = mesh->mVertices[i];
|
auto pos = mesh->mVertices[i];
|
||||||
vertices.push_back(Vertex(pos, mesh->mNormals[i], mesh->mTextureCoords[0][i]));
|
aiVector3D textureCoords;
|
||||||
|
if (mesh->mTextureCoords[0]) textureCoords = mesh->mTextureCoords[0][i];
|
||||||
|
vertices.push_back(Vertex(pos, mesh->mNormals[i], textureCoords));
|
||||||
auto worldPos = model * pos;
|
auto worldPos = model * pos;
|
||||||
minPos = glm::min(minPos, glm::vec3(worldPos.x, worldPos.y, worldPos.z));
|
minPos = glm::min(minPos, glm::vec3(worldPos.x, worldPos.y, worldPos.z));
|
||||||
maxPos = glm::max(maxPos, glm::vec3(worldPos.x, worldPos.y, worldPos.z));
|
maxPos = glm::max(maxPos, glm::vec3(worldPos.x, worldPos.y, worldPos.z));
|
||||||
|
@ -149,6 +151,9 @@ std::unique_ptr<Drawable> Model::processMesh(aiMesh* mesh, const aiScene* scene,
|
||||||
for (auto face = mesh->mFaces; face < mesh->mFaces + mesh->mNumFaces; face++)
|
for (auto face = mesh->mFaces; face < mesh->mFaces + mesh->mNumFaces; face++)
|
||||||
indices.insert(indices.end(), face->mIndices, face->mIndices + face->mNumIndices);
|
indices.insert(indices.end(), face->mIndices, face->mIndices + face->mNumIndices);
|
||||||
|
|
||||||
|
if (vertices.empty() || indices.empty())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];
|
aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];
|
||||||
|
|
||||||
if (auto iter = paintingMap.find([&] {
|
if (auto iter = paintingMap.find([&] {
|
||||||
|
|
Loading…
Reference in New Issue