fixed vertex duplicates algorithm
This commit is contained in:
parent
7825ecd12f
commit
1b14d61bdc
@ -125,13 +125,13 @@ void MeshBuilder::mergeVertices()
|
||||
std::set<int, VertexComparator> vertexSet;
|
||||
VertexComparator::setMesh(this);
|
||||
|
||||
int size = positions.size();
|
||||
int swappedOffset = positions.size() - 1;
|
||||
|
||||
for(Group &g : indiceGroups)
|
||||
for(int i=0; i<g.indices.size(); ++i)
|
||||
{
|
||||
if(g.indices[i] >= positions.size())
|
||||
g.indices[i] = swapped[size - g.indices[i]];
|
||||
g.indices[i] = swapped[swappedOffset - g.indices[i]];
|
||||
std::pair<std::set<int,VertexComparator>::iterator,bool> ret = vertexSet.insert(g.indices[i]);
|
||||
if(!ret.second) // duplicate found
|
||||
{
|
||||
@ -154,13 +154,18 @@ void MeshBuilder::mergeVertices()
|
||||
}
|
||||
if(hasTangents())
|
||||
{
|
||||
tangents[g.indices[i]].tangent += tangents[toDelete].tangent;
|
||||
tangents[g.indices[i]].binormal += tangents[toDelete].binormal;
|
||||
tangents[toDelete] = tangents.back();
|
||||
tangents.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stdout, "found %d vertex duplicates\n", swapped.size());
|
||||
for(Tangents &t : tangents)
|
||||
{
|
||||
t.tangent = glm::normalize(t.tangent);
|
||||
t.binormal = glm::normalize(t.binormal);
|
||||
}
|
||||
}
|
||||
|
||||
void MeshBuilder::computeNormals()
|
||||
|
Loading…
x
Reference in New Issue
Block a user