Removed lots of old decimation code.

This commit is contained in:
David Williams
2007-09-21 15:01:28 +00:00
parent 2f5f179886
commit 63c5886d1d
4 changed files with 3 additions and 675 deletions

View File

@ -1013,7 +1013,7 @@ namespace Ogre
//for(uint ct = 0; ct < 3; ct++)
do
{
removedVertex = iterPatch->second.decimate3();
removedVertex = iterPatch->second.decimateOneVertex();
}
while(removedVertex);
}
@ -1023,161 +1023,6 @@ namespace Ogre
return result;
}
#ifdef BLAH
void PolyVoxSceneManager::mergeVertices6(std::vector< std::vector<SurfaceVertex> >& vertexData, std::vector< std::vector<SurfaceTriangle> >& indexData) const
{
for(uint material = 1; material < 256; ++material)
{
if(vertexData[material].empty())
continue;
//Ogre::LogManager::getSingleton().logMessage("Material = " + Ogre::StringConverter::toString(material) + " No of vertices = " + Ogre::StringConverter::toString(vertexData[material].size()));
std::vector< std::set<uint> > connectedVertices;
connectedVertices.resize(vertexData[material].size());
for(uint vertexCt = 0; vertexCt < vertexData[material].size(); vertexCt++)
{
for(uint triangleCt = 0; triangleCt < indexData[material].size(); ++triangleCt)
{
if((indexData[material][triangleCt].v0 == vertexCt) || (indexData[material][triangleCt].v1 == vertexCt) || (indexData[material][triangleCt].v2 == vertexCt))
{
connectedVertices[vertexCt].insert(indexData[material][triangleCt].v0);
connectedVertices[vertexCt].insert(indexData[material][triangleCt].v1);
connectedVertices[vertexCt].insert(indexData[material][triangleCt].v2);
}
}
connectedVertices[vertexCt].erase(vertexCt);
}
std::vector< uint > initialConnections;
initialConnections.resize(vertexData[material].size());
for(uint vertexCt = 0; vertexCt < vertexData[material].size(); vertexCt++)
{
initialConnections[vertexCt] = connectedVertices[vertexCt].size();
}
/*std::vector<uint> noOfEdges; //0 means not on ege, 1 means edge, 2 or more means corner
noOfEdges.resize(vertexData[material].size());
for(uint vertexCt = 0; vertexCt < vertexData[material].size(); ++vertexCt)
{
noOfEdges[vertexCt] = 0;
}
for(uint vertexCt = 0; vertexCt < vertexData[material].size(); ++vertexCt)
{
if(vertexData[material][vertexCt].position.x < 0.25)
noOfEdges[vertexCt] |= 1;
if(vertexData[material][vertexCt].position.y < 0.25)
noOfEdges[vertexCt] |= 2;
if(vertexData[material][vertexCt].position.z < 0.25)
noOfEdges[vertexCt] |= 4;
if(vertexData[material][vertexCt].position.x > OGRE_REGION_SIDE_LENGTH-0.25)
noOfEdges[vertexCt] |= 8;
if(vertexData[material][vertexCt].position.y > OGRE_REGION_SIDE_LENGTH-0.25)
noOfEdges[vertexCt] |= 16;
if(vertexData[material][vertexCt].position.z > OGRE_REGION_SIDE_LENGTH-0.25)
noOfEdges[vertexCt] |= 32;
}*/
for(uint u = 0; u < 50; u++)
{
//FIXME - this is innefficient! iterating over ever vertex, even though one material might just use a few of them.
for(uint vertexCt = 0; vertexCt < vertexData[material].size(); vertexCt++)
{
//if((initialConnections[vertexCt] == 6) || (initialConnections[vertexCt] == initialConnections[*connectedIter]))
{
if(verticesArePlanar3(vertexCt, connectedVertices[vertexCt], vertexData[material]))
{
std::set<uint>::iterator connectedIter = connectedVertices[vertexCt].begin();
/*for(uint triCt = 0; triCt < indexData[material].size(); triCt++)
{
if(indexData[material][triCt].v0 == vertexCt)
{
indexData[material][triCt].v0 = *connectedIter;
}
if(indexData[material][triCt].v1 == vertexCt)
{
indexData[material][triCt].v1 = *connectedIter;
}
if(indexData[material][triCt].v2 == vertexCt)
{
indexData[material][triCt].v2 = *connectedIter;
}
}*/
for(uint innerVertexCt = 0; innerVertexCt < vertexData[material].size(); innerVertexCt++)
{
if(vertexData[material][innerVertexCt].position.distance(vertexData[material][vertexCt].position) < 0.1)
{
if((initialConnections[innerVertexCt] == 6) || (initialConnections[innerVertexCt] == initialConnections[*connectedIter]))
vertexData[material][innerVertexCt].position = vertexData[material][*connectedIter].position;
}
}
}
}
}
}
//Delete degenerate triangles
std::vector<SurfaceVertex> resultingVertexData;
std::vector<SurfaceTriangle> resultingIndexData;
for(uint triCt = 0; triCt < indexData[material].size(); triCt++)
{
if((indexData[material][triCt].v0 != indexData[material][triCt].v1) || (indexData[material][triCt].v1 != indexData[material][triCt].v2))
{
uint pos = resultingVertexData.size();
resultingVertexData.push_back(vertexData[material][indexData[material][triCt].v0]);
resultingVertexData.push_back(vertexData[material][indexData[material][triCt].v1]);
resultingVertexData.push_back(vertexData[material][indexData[material][triCt].v2]);
SurfaceTriangle triangle(pos, pos+1, pos+2);
resultingIndexData.push_back(triangle);
}
}
vertexData[material] = resultingVertexData;
indexData[material] = resultingIndexData;
}
}
#endif
bool PolyVoxSceneManager::verticesArePlanar3(uint uCurrentVertex, std::set<uint> setConnectedVertices, std::vector<SurfaceVertex>& vertexData) const
{
//FIXME - specially handle the case where they are all the same.
//This is happening a lot after many vertices have been moved round?
bool allXMatch = true;
bool allYMatch = true;
bool allZMatch = true;
bool allNormalsMatch = true;
//FIXME - reorder come of these tests based on likelyness to fail?
std::set<uint>::iterator iterConnectedVertices;
for(iterConnectedVertices = setConnectedVertices.begin(); iterConnectedVertices != setConnectedVertices.end(); ++iterConnectedVertices)
{
if(vertexData[uCurrentVertex].position.x != vertexData[*iterConnectedVertices].position.x)
{
allXMatch = false;
}
if(vertexData[uCurrentVertex].position.y != vertexData[*iterConnectedVertices].position.y)
{
allYMatch = false;
}
if(vertexData[uCurrentVertex].position.z != vertexData[*iterConnectedVertices].position.z)
{
allZMatch = false;
}
//FIXME - are these already normalised? We should make sure they are...
if(vertexData[uCurrentVertex].normal.normalisedCopy().dotProduct(vertexData[*iterConnectedVertices].normal.normalisedCopy()) < 0.99)
{
return false;
}
}
return allXMatch || allYMatch || allZMatch;
}
void PolyVoxSceneManager::markVoxelChanged(uint x, uint y, uint z)
{
//If we are not on a boundary, just mark one region.