OpenGLExample does decimation now, so so we can check it still compiles.

This commit is contained in:
David Williams 2011-01-06 22:36:25 +00:00
parent db13224bba
commit 83b2f84529
2 changed files with 11 additions and 6 deletions

View File

@ -27,6 +27,7 @@ freely, subject to the following restrictions:
#include "GradientEstimators.h"
#include "MaterialDensityPair.h"
#include "MeshDecimator.h"
#include "SurfaceExtractor.h"
#include "Mesh.h"
@ -93,6 +94,10 @@ void OpenGLWidget::setVolume(PolyVox::Volume<MaterialDensityPair44>* volData)
SurfaceExtractor<MaterialDensityPair44> surfaceExtractor(volData, PolyVox::Region(regLowerCorner, regUpperCorner), mesh.get());
surfaceExtractor.execute();
polyvox_shared_ptr< SurfaceMesh<PositionMaterialNormal> > decimatedMesh(new SurfaceMesh<PositionMaterialNormal>);
MeshDecimator<PositionMaterialNormal> decimator(mesh.get(), decimatedMesh.get(), 0.95f);
decimator.execute();
//computeNormalsForVertices(m_volData, *(mesh.get()), SOBEL_SMOOTHED);
//*meshCurrent = getSmoothedSurface(*meshCurrent);
//mesh->smooth(0.3f);
@ -139,12 +144,12 @@ void OpenGLWidget::setVolume(PolyVox::Volume<MaterialDensityPair44>* volData)
Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ);
if(m_bUseOpenGLVertexBufferObjects)
{
OpenGLSurfaceMesh openGLSurfaceMesh = BuildOpenGLSurfaceMesh(*(mesh.get()));
OpenGLSurfaceMesh openGLSurfaceMesh = BuildOpenGLSurfaceMesh(*(decimatedMesh.get()));
m_mapOpenGLSurfaceMeshes.insert(make_pair(v3dRegPos, openGLSurfaceMesh));
}
//else
//{
m_mapSurfaceMeshes.insert(make_pair(v3dRegPos, mesh));
m_mapSurfaceMeshes.insert(make_pair(v3dRegPos, decimatedMesh));
//}
//delete meshCurrent;
}

View File

@ -366,7 +366,9 @@ namespace PolyVox
{
//We don't actually use the normal here, because we want to allow face
//vertices to collapse onto edge vertices. Simply checking whether anything
//has flipped has proved to be the most robust approach, though rather slow...
//has flipped has proved to be the most robust approach, though rather slow.
//It's not sufficient to just check the normals, there can be holes in the middle
//of the mesh for example.
//User specified threshold is not used for cubic surface, any
//movement is too much (but allow for floating point error).
@ -455,10 +457,8 @@ namespace PolyVox
OldNormal.normalise();
NewNormal.normalise();
// Note for after holiday - We are still getting faces flipping despite the following test. I tried changing
// the 0.0 to 0.9 (which should still let coplanar faces merge) but oddly nothing then merged. Investigate this.
float dotProduct = OldNormal.dot(NewNormal);
//cout << dotProduct << endl;
//NOTE: I don't think we should be using the threshold here, we're just checking for a complete face flip
if(dotProduct < fThreshold)
{
//cout << " Face flipped!!" << endl;