From 35f999666348e8cdbd3f4665b5c741435e062178 Mon Sep 17 00:00:00 2001 From: David Williams Date: Wed, 16 Apr 2008 20:46:24 +0000 Subject: [PATCH] Removed redundant classes SurfaceEdge, SurfaceTriange, and SurfaceTypes. Also fixed a new bug in IndexedSurfacePatch --- CMakeLists.txt | 5 ----- include/PolyVoxForwardDeclarations.h | 6 +++--- include/SurfaceVertex.h | 9 +-------- source/IndexedSurfacePatch.cpp | 13 ++++++------- source/SurfaceVertex.cpp | 24 ------------------------ 5 files changed, 10 insertions(+), 47 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 919a59cf..57218438 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,6 @@ SET(SRC_FILES source/MarchingCubesTables.cpp source/PolyVoxSceneManager.cpp source/RegionGeometry.cpp - source/SurfaceEdge.cpp - source/SurfaceTriangle.cpp source/SurfaceVertex.cpp source/Volume.cpp source/VolumeIterator.cpp @@ -23,9 +21,6 @@ SET(INC_FILES include/PolyVoxForwardDeclarations.h include/PolyVoxSceneManager.h include/RegionGeometry.h - include/SurfaceEdge.h - include/SurfaceTypes.h - include/SurfaceTriangle.h include/SurfaceVertex.h include/TypeDef.h include/Vector.h diff --git a/include/PolyVoxForwardDeclarations.h b/include/PolyVoxForwardDeclarations.h index 2cd2302f..780e6555 100644 --- a/include/PolyVoxForwardDeclarations.h +++ b/include/PolyVoxForwardDeclarations.h @@ -10,9 +10,9 @@ namespace PolyVox class IntegrealVector3; class PolyVoxSceneManager; class RegionGeometry; - class SurfaceEdge; - class SurfaceTriange; - class SurfaceTypes; + //class SurfaceEdge; + //class SurfaceTriange; + //class SurfaceTypes; class SurfaceVertex; template class Vector; typedef Vector<2,float> Vector2DFloat; diff --git a/include/SurfaceVertex.h b/include/SurfaceVertex.h index a704ca73..9b6bd21d 100644 --- a/include/SurfaceVertex.h +++ b/include/SurfaceVertex.h @@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef __PolyVox_SurfaceVertex_H__ #define __PolyVox_SurfaceVertex_H__ -#include "SurfaceTypes.h" #include "TypeDef.h" #include "Vector.h" @@ -37,13 +36,11 @@ namespace PolyVox friend bool operator < (const SurfaceVertex& lhs, const SurfaceVertex& rhs); float getAlpha(void) const; - const SurfaceEdgeIterator& getEdge(void) const; float getMaterial(void) const; const Vector3DFloat& getNormal(void) const; const Vector3DFloat& getPosition(void) const; void setAlpha(float alphaToSet); - void setEdge(const SurfaceEdgeIterator& edgeToSet); void setMaterial(float materialToSet); void setNormal(const Vector3DFloat& normalToSet); @@ -54,11 +51,7 @@ namespace PolyVox Vector3DFloat normal; float material; float alpha; - - - SurfaceEdgeIterator edge; - - unsigned long m_uHash; + }; diff --git a/source/IndexedSurfacePatch.cpp b/source/IndexedSurfacePatch.cpp index d3fde99b..58b22932 100644 --- a/source/IndexedSurfacePatch.cpp +++ b/source/IndexedSurfacePatch.cpp @@ -1,5 +1,4 @@ #include "IndexedSurfacePatch.h" -#include "SurfaceTypes.h" using namespace boost; @@ -26,12 +25,12 @@ namespace PolyVox noOfVerticesSubmitted += 3; if(!m_AllowDuplicateVertices) { - long int index = vertexIndices[long int(v0.getPosition().x() +0.5)][long int(v0.getPosition().y() +0.5)][long int(v0.getPosition().z() +0.5)]; + long int index = vertexIndices[long int(v0.getPosition().x() * 2.0 +0.5)][long int(v0.getPosition().y() * 2.0 +0.5)][long int(v0.getPosition().z() * 2.0 +0.5)]; if(index == -1) { m_vecVertices.push_back(v0); m_vecTriangleIndices.push_back(m_vecVertices.size()-1); - vertexIndices[long int(v0.getPosition().x() +0.5)][long int(v0.getPosition().y() +0.5)][long int(v0.getPosition().z() +0.5)] = m_vecVertices.size()-1; + vertexIndices[long int(v0.getPosition().x() * 2.0 +0.5)][long int(v0.getPosition().y() * 2.0 +0.5)][long int(v0.getPosition().z() * 2.0 +0.5)] = m_vecVertices.size()-1; noOfVerticesAccepted++; } @@ -40,12 +39,12 @@ namespace PolyVox m_vecTriangleIndices.push_back(index); } - index = vertexIndices[long int(v1.getPosition().x() +0.5)][long int(v1.getPosition().y() +0.5)][long int(v1.getPosition().z() +0.5)]; + index = vertexIndices[long int(v1.getPosition().x() * 2.0 +0.5)][long int(v1.getPosition().y() * 2.0 +0.5)][long int(v1.getPosition().z() * 2.0 +0.5)]; if(index == -1) { m_vecVertices.push_back(v1); m_vecTriangleIndices.push_back(m_vecVertices.size()-1); - vertexIndices[long int(v1.getPosition().x() +0.5)][long int(v1.getPosition().y() +0.5)][long int(v1.getPosition().z() +0.5)] = m_vecVertices.size()-1; + vertexIndices[long int(v1.getPosition().x() * 2.0 +0.5)][long int(v1.getPosition().y() * 2.0 +0.5)][long int(v1.getPosition().z() * 2.0 +0.5)] = m_vecVertices.size()-1; noOfVerticesAccepted++; } @@ -54,12 +53,12 @@ namespace PolyVox m_vecTriangleIndices.push_back(index); } - index = vertexIndices[long int(v2.getPosition().x() +0.5)][long int(v2.getPosition().y() +0.5)][long int(v2.getPosition().z() +0.5)]; + index = vertexIndices[long int(v2.getPosition().x() * 2.0 +0.5)][long int(v2.getPosition().y() * 2.0 +0.5)][long int(v2.getPosition().z() * 2.0 +0.5)]; if(index == -1) { m_vecVertices.push_back(v2); m_vecTriangleIndices.push_back(m_vecVertices.size()-1); - vertexIndices[long int(v2.getPosition().x() +0.5)][long int(v2.getPosition().y() +0.5)][long int(v2.getPosition().z() +0.5)] = m_vecVertices.size()-1; + vertexIndices[long int(v2.getPosition().x() * 2.0 +0.5)][long int(v2.getPosition().y() * 2.0 +0.5)][long int(v2.getPosition().z() * 2.0 +0.5)] = m_vecVertices.size()-1; noOfVerticesAccepted++; } diff --git a/source/SurfaceVertex.cpp b/source/SurfaceVertex.cpp index 54a771f0..83eee643 100644 --- a/source/SurfaceVertex.cpp +++ b/source/SurfaceVertex.cpp @@ -2,8 +2,6 @@ #include "Constants.h" #include "SurfaceVertex.h" -#include "SurfaceTriangle.h" -#include "SurfaceEdge.h" namespace PolyVox { @@ -15,7 +13,6 @@ namespace PolyVox :material(materialToSet) ,alpha(alphaToSet) ,position(positionToSet) - ,m_uHash((position.x()*(POLYVOX_REGION_SIDE_LENGTH*2+1)*(POLYVOX_REGION_SIDE_LENGTH*2+1)) + (position.y()*(POLYVOX_REGION_SIDE_LENGTH*2+1)) + (position.z())) { } @@ -24,7 +21,6 @@ namespace PolyVox :position(positionToSet) ,normal(normalToSet) { - m_uHash = (position.x()*(POLYVOX_REGION_SIDE_LENGTH*2+1)*(POLYVOX_REGION_SIDE_LENGTH*2+1)) + (position.y()*(POLYVOX_REGION_SIDE_LENGTH*2+1)) + (position.z()); } float SurfaceVertex::getAlpha(void) const @@ -37,11 +33,6 @@ namespace PolyVox return material; } - const SurfaceEdgeIterator& SurfaceVertex::getEdge(void) const - { - return edge; - } - const Vector3DFloat& SurfaceVertex::getNormal(void) const { return normal; @@ -62,11 +53,6 @@ namespace PolyVox material = materialToSet; } - void SurfaceVertex::setEdge(const SurfaceEdgeIterator& edgeToSet) - { - edge = edgeToSet; - } - void SurfaceVertex::setNormal(const Vector3DFloat& normalToSet) { normal = normalToSet; @@ -78,15 +64,5 @@ namespace PolyVox std::stringstream ss; ss << "SurfaceVertex: Position = (" << position.x() << "," << position.y() << "," << position.z() << "), Normal = " << normal; return ss.str(); - } - - bool operator==(const SurfaceVertex& lhs, const SurfaceVertex& rhs) - { - return (lhs.m_uHash == rhs.m_uHash); - } - - bool operator < (const SurfaceVertex& lhs, const SurfaceVertex& rhs) - { - return (lhs.m_uHash < rhs.m_uHash); } }