From abe66c3d818b33ea47c40e6221e73d717afda1e6 Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 1 Sep 2007 11:40:54 +0000 Subject: [PATCH] Refactoring work... working on meshes --- include/SurfacePatch.h | 6 +++++- source/PolyVoxSceneManager.cpp | 3 ++- source/SurfacePatch.cpp | 14 +++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/SurfacePatch.h b/include/SurfacePatch.h index e58a7eb0..394d26e9 100644 --- a/include/SurfacePatch.h +++ b/include/SurfacePatch.h @@ -32,7 +32,9 @@ namespace Ogre void getVertexAndIndexData(std::vector& vertexData, std::vector& indexData); - void computeNormalsFromVolume(uint regionX, uint regionY, uint regionZ, VolumeIterator volIter); + void computeNormalsFromVolume(VolumeIterator volIter); + + UIntVector3 m_v3dOffset; private: std::set m_setVertices; @@ -45,6 +47,8 @@ namespace Ogre uint m_uVerticesAdded; long int* vertexIndices; + + //UIntVector3 m_v3dOffset; }; } diff --git a/source/PolyVoxSceneManager.cpp b/source/PolyVoxSceneManager.cpp index 3a372189..658323bb 100644 --- a/source/PolyVoxSceneManager.cpp +++ b/source/PolyVoxSceneManager.cpp @@ -1005,7 +1005,8 @@ namespace Ogre for(std::map::iterator iterPatch = result.begin(); iterPatch != result.end(); ++iterPatch) { - iterPatch->second.computeNormalsFromVolume(regionX,regionY,regionZ,volIter); + iterPatch->second.m_v3dOffset = offset; + iterPatch->second.computeNormalsFromVolume(volIter); iterPatch->second.endDefinition(); } diff --git a/source/SurfacePatch.cpp b/source/SurfacePatch.cpp index a080bae9..71eec583 100644 --- a/source/SurfacePatch.cpp +++ b/source/SurfacePatch.cpp @@ -56,19 +56,19 @@ namespace Ogre triangle.v2->listTrianglesUsingThisVertex.push_back(m_listTriangles.end()); } - void SurfacePatch::computeNormalsFromVolume(uint regionX, uint regionY, uint regionZ, VolumeIterator volIter) + void SurfacePatch::computeNormalsFromVolume(VolumeIterator volIter) { //LogManager::getSingleton().logMessage("In SurfacePatch::computeNormalsFromVolume"); for(std::set::iterator vertexIter = m_setVertices.begin(); vertexIter != m_setVertices.end(); ++vertexIter) { //LogManager::getSingleton().logMessage("In Loop"); - const float posX = vertexIter->position.x/2.0f + static_cast(regionX * OGRE_REGION_SIDE_LENGTH); - const float posY = vertexIter->position.y/2.0f + static_cast(regionY * OGRE_REGION_SIDE_LENGTH); - const float posZ = vertexIter->position.z/2.0f + static_cast(regionZ * OGRE_REGION_SIDE_LENGTH); + const float posX = (vertexIter->position.x + m_v3dOffset.x) / 2.0f; + const float posY = (vertexIter->position.y + m_v3dOffset.y) / 2.0f; + const float posZ = (vertexIter->position.z + m_v3dOffset.z) / 2.0f; - const uint floorX = static_cast(vertexIter->position.x/2.0f) + regionX * OGRE_REGION_SIDE_LENGTH; - const uint floorY = static_cast(vertexIter->position.y/2.0f) + regionY * OGRE_REGION_SIDE_LENGTH; - const uint floorZ = static_cast(vertexIter->position.z/2.0f) + regionZ * OGRE_REGION_SIDE_LENGTH; + const uint floorX = static_cast(posX); + const uint floorY = static_cast(posY); + const uint floorZ = static_cast(posZ); NormalGenerationMethod normalGenerationMethod = CENTRAL_DIFFERENCE;