From 6da15633e68396dcd1185cbbaabc31207f28eb5e Mon Sep 17 00:00:00 2001 From: David Williams Date: Wed, 29 Apr 2009 22:07:50 +0000 Subject: [PATCH] Small changes for the purpose of profiling. --- examples/OpenGL/OpenGLWidget.cpp | 16 +++++++--------- examples/OpenGL/OpenGLWidget.h | 2 -- examples/OpenGL/main.cpp | 20 ++++++++++++++------ library/PolyVoxCore/include/SurfaceVertex.h | 2 -- library/PolyVoxCore/source/SurfaceVertex.cpp | 7 ------- 5 files changed, 21 insertions(+), 26 deletions(-) diff --git a/examples/OpenGL/OpenGLWidget.cpp b/examples/OpenGL/OpenGLWidget.cpp index d532fcd9..8963c217 100644 --- a/examples/OpenGL/OpenGLWidget.cpp +++ b/examples/OpenGL/OpenGLWidget.cpp @@ -16,7 +16,7 @@ OpenGLWidget::OpenGLWidget(QWidget *parent) { m_xRotation = 0; m_yRotation = 0; - m_uRegionSideLength = 16.0f; + m_uRegionSideLength = 32.0f; timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(update())); @@ -41,6 +41,7 @@ void OpenGLWidget::setVolume(PolyVox::Volume* volData) //This three-level for loop iterates over each region. for(PolyVox::uint16_t uRegionZ = 0; uRegionZ < m_uVolumeDepthInRegions; ++uRegionZ) { + std::cout << "uRegionZ = " << uRegionZ << " of " << m_uVolumeDepthInRegions << std::endl; for(PolyVox::uint16_t uRegionY = 0; uRegionY < m_uVolumeHeightInRegions; ++uRegionY) { for(PolyVox::uint16_t uRegionX = 0; uRegionX < m_uVolumeWidthInRegions; ++uRegionX) @@ -63,13 +64,10 @@ void OpenGLWidget::setVolume(PolyVox::Volume* volData) Vector3DInt32 regUpperCorner(regionEndX, regionEndY, regionEndZ); //Extract the surface for this region - extractReferenceSurface(m_volData, PolyVox::Region(regLowerCorner, regUpperCorner), ispCurrent); - computeNormalsForVertices(m_volData, *ispCurrent, SOBEL_SMOOTHED); - - //for(int ct = 0; ct < 100; ct++) - //{ - *ispCurrent = getSmoothedSurface(*ispCurrent); - //} + extractSurface(m_volData, 0, PolyVox::Region(regLowerCorner, regUpperCorner), ispCurrent); + + //computeNormalsForVertices(m_volData, *ispCurrent, SOBEL_SMOOTHED); + //*ispCurrent = getSmoothedSurface(*ispCurrent); Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ); @@ -94,7 +92,7 @@ void OpenGLWidget::setVolume(PolyVox::Volume* volData) void OpenGLWidget::initializeGL() { - m_bUseOpenGLVertexBufferObjects = true; + m_bUseOpenGLVertexBufferObjects = false; if(m_bUseOpenGLVertexBufferObjects) { #ifdef WIN32 diff --git a/examples/OpenGL/OpenGLWidget.h b/examples/OpenGL/OpenGLWidget.h index de5765b7..6cf8d12f 100644 --- a/examples/OpenGL/OpenGLWidget.h +++ b/examples/OpenGL/OpenGLWidget.h @@ -16,8 +16,6 @@ #include "Shapes.h" const PolyVox::uint16_t g_uVolumeSideLength = 128; -//const PolyVox::uint16_t g_uRegionSideLength = 16; -//const PolyVox::uint16_t g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength; class OpenGLWidget : public QGLWidget { diff --git a/examples/OpenGL/main.cpp b/examples/OpenGL/main.cpp index b2516766..b5b19ee2 100644 --- a/examples/OpenGL/main.cpp +++ b/examples/OpenGL/main.cpp @@ -53,20 +53,28 @@ int main(int argc, char *argv[]) PolyVox::uint16_t minPos = 0; PolyVox::uint16_t midPos = g_uVolumeSideLength / 2; PolyVox::uint16_t maxPos = g_uVolumeSideLength - 1; - createCubeInVolume(volData, Vector3DUint16(minPos, minPos, minPos), Vector3DUint16(maxPos, maxPos, maxPos), 0); + //createCubeInVolume(volData, Vector3DUint16(minPos, minPos, minPos), Vector3DUint16(maxPos, maxPos, maxPos), 0); - createSphereInVolume(volData, 50.0f, 5); - createSphereInVolume(volData, 40.0f, 4); - createSphereInVolume(volData, 30.0f, 3); - createSphereInVolume(volData, 20.0f, 2); - createSphereInVolume(volData, 10.0f, 1); + cout << "Creating sphere 1" << std::endl; + createSphereInVolume(volData, 60.0f, 5); + cout << "Creating sphere 2" << std::endl; + createSphereInVolume(volData, 50.0f, 4); + cout << "Creating sphere 3" << std::endl; + createSphereInVolume(volData, 40.0f, 3); + cout << "Creating sphere 4" << std::endl; + createSphereInVolume(volData, 30.0f, 2); + cout << "Creating sphere 5" << std::endl; + createSphereInVolume(volData, 20.0f, 1); + cout << "Creating cubes" << std::endl; createCubeInVolume(volData, Vector3DUint16(minPos, minPos, minPos), Vector3DUint16(midPos-1, midPos-1, midPos-1), 0); createCubeInVolume(volData, Vector3DUint16(midPos+1, midPos+1, minPos), Vector3DUint16(maxPos, maxPos, midPos-1), 0); createCubeInVolume(volData, Vector3DUint16(midPos+1, minPos, midPos+1), Vector3DUint16(maxPos, midPos-1, maxPos), 0); createCubeInVolume(volData, Vector3DUint16(minPos, midPos+1, midPos+1), Vector3DUint16(midPos-1, maxPos, maxPos), 0); + cout << "Tidying memory..."; volData.tidyUpMemory(0); + cout << "done." << endl; QApplication app(argc, argv); diff --git a/library/PolyVoxCore/include/SurfaceVertex.h b/library/PolyVoxCore/include/SurfaceVertex.h index 74a23c34..5bfb0b2d 100644 --- a/library/PolyVoxCore/include/SurfaceVertex.h +++ b/library/PolyVoxCore/include/SurfaceVertex.h @@ -42,8 +42,6 @@ namespace PolyVox void setNormal(const Vector3DFloat& normalToSet); void setPosition(const Vector3DFloat& positionToSet); - std::string tostring(void) const; - public: Vector3DFloat position; Vector3DFloat normal; diff --git a/library/PolyVoxCore/source/SurfaceVertex.cpp b/library/PolyVoxCore/source/SurfaceVertex.cpp index a9f4b3fb..b0471315 100644 --- a/library/PolyVoxCore/source/SurfaceVertex.cpp +++ b/library/PolyVoxCore/source/SurfaceVertex.cpp @@ -72,11 +72,4 @@ namespace PolyVox { position = positionToSet; } - - std::string SurfaceVertex::tostring(void) const - { - std::stringstream ss; - ss << "SurfaceVertex: Position = (" << position.getX() << "," << position.getY() << "," << position.getZ() << "), Normal = " << normal; - return ss.str(); - } }