Started getting rid of IntegrealVector3.

Also added ForwardDeclarations.h
This commit is contained in:
David Williams 2008-02-10 21:58:35 +00:00
parent 76df5e00b5
commit e180f67bae
14 changed files with 157 additions and 94 deletions

View File

@ -17,6 +17,7 @@ SET(SRC_FILES
SET(INC_FILES SET(INC_FILES
include/Block.h include/Block.h
include/Constants.h include/Constants.h
include/ForwardDeclarations.h
include/IndexedSurfacePatch.h include/IndexedSurfacePatch.h
include/IntegralVector3.h include/IntegralVector3.h
include/MarchingCubesTables.h include/MarchingCubesTables.h
@ -33,7 +34,7 @@ SET(INC_FILES
include/VolumeIterator.h include/VolumeIterator.h
) )
ADD_DEFINITIONS(-DVOXEL_SCENE_MANAGER_EXPORT) #Export symbols in the .dll ADD_DEFINITIONS(-DPOLYVOX_EXPORT) #Export symbols in the .dll
#Appends "_d" to the generated library when in debug mode #Appends "_d" to the generated library when in debug mode
SET(CMAKE_DEBUG_POSTFIX "_d") SET(CMAKE_DEBUG_POSTFIX "_d")

View File

@ -1,3 +1,4 @@
#pragma region License
/****************************************************************************** /******************************************************************************
This file is part of a voxel plugin for OGRE This file is part of a voxel plugin for OGRE
Copyright (C) 2006 David Williams Copyright (C) 2006 David Williams
@ -16,19 +17,26 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
******************************************************************************/ ******************************************************************************/
#pragma endregion
#ifndef __Block_H__ #ifndef __Block_H__
#define __Block_H__ #define __Block_H__
#pragma region Standard Headers
#pragma endregion
#pragma region Boost Headers
#include "boost/cstdint.hpp" #include "boost/cstdint.hpp"
#pragma endregion
#pragma region PolyVox Headers
#include "Constants.h" #include "Constants.h"
#include "TypeDef.h" #include "TypeDef.h"
#pragma endregion
namespace PolyVox namespace PolyVox
{ {
class POLYVOX_API Block
class VOXEL_SCENE_MANAGER_API Block
{ {
//Make VolumeIterator a friend //Make VolumeIterator a friend
friend class VolumeIterator; friend class VolumeIterator;

View File

@ -0,0 +1,20 @@
#ifndef __ForwardDeclarations_H__
#define __ForwardDeclarations_H__
namespace PolyVox
{
class Block;
class IndexedSurfacePatch;
class IntegrealVector3;
class PolyVoxSceneManager;
class RegionGeometry;
class SurfaceEdge;
class SurfaceTriange;
class SurfaceTypes;
class SurfaceVertex;
class Vector;
class Volume;
class VolumeIterator;
}
#endif

View File

@ -9,7 +9,6 @@
#include <vector> #include <vector>
#include "Constants.h" #include "Constants.h"
#include "IntegralVector3.h"
#include "SurfaceTypes.h" #include "SurfaceTypes.h"
#include "SurfaceVertex.h" #include "SurfaceVertex.h"
#include "TypeDef.h" #include "TypeDef.h"
@ -18,7 +17,7 @@
namespace PolyVox namespace PolyVox
{ {
class VOXEL_SCENE_MANAGER_API IndexedSurfacePatch class POLYVOX_API IndexedSurfacePatch
{ {
public: public:
IndexedSurfacePatch(bool allowDuplicateVertices); IndexedSurfacePatch(bool allowDuplicateVertices);

View File

@ -46,7 +46,7 @@ namespace PolyVox
}; };
/// Voxel scene manager /// Voxel scene manager
class VOXEL_SCENE_MANAGER_API PolyVoxSceneManager class POLYVOX_API PolyVoxSceneManager
{ {
public: public:
//Constructors, etc //Constructors, etc

View File

@ -34,7 +34,7 @@ namespace PolyVox
bool m_bContainsSingleMaterialPatch; bool m_bContainsSingleMaterialPatch;
bool m_bContainsMultiMaterialPatch; bool m_bContainsMultiMaterialPatch;
UIntVector3 m_v3dRegionPosition; Vector3DInt32 m_v3dRegionPosition;
IndexedSurfacePatch* m_patchSingleMaterial; IndexedSurfacePatch* m_patchSingleMaterial;
IndexedSurfacePatch* m_patchMultiMaterial; IndexedSurfacePatch* m_patchMultiMaterial;

View File

@ -27,12 +27,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
namespace PolyVox namespace PolyVox
{ {
class VOXEL_SCENE_MANAGER_API SurfaceVertex class POLYVOX_API SurfaceVertex
{ {
public: public:
SurfaceVertex(); SurfaceVertex();
SurfaceVertex(UIntVector3 positionToSet, float materialToSet, float alphaToSet); SurfaceVertex(Vector3DUint32 positionToSet, float materialToSet, float alphaToSet);
SurfaceVertex(UIntVector3 positionToSet, Vector3DFloat normalToSet); SurfaceVertex(Vector3DUint32 positionToSet, Vector3DFloat normalToSet);
friend bool operator==(const SurfaceVertex& lhs, const SurfaceVertex& rhs); friend bool operator==(const SurfaceVertex& lhs, const SurfaceVertex& rhs);
friend bool operator < (const SurfaceVertex& lhs, const SurfaceVertex& rhs); friend bool operator < (const SurfaceVertex& lhs, const SurfaceVertex& rhs);
@ -41,7 +41,7 @@ namespace PolyVox
const SurfaceEdgeIterator& getEdge(void) const; const SurfaceEdgeIterator& getEdge(void) const;
float getMaterial(void) const; float getMaterial(void) const;
const Vector3DFloat& getNormal(void) const; const Vector3DFloat& getNormal(void) const;
const UIntVector3& getPosition(void) const; const Vector3DUint32& getPosition(void) const;
void setAlpha(float alphaToSet); void setAlpha(float alphaToSet);
void setEdge(const SurfaceEdgeIterator& edgeToSet); void setEdge(const SurfaceEdgeIterator& edgeToSet);
@ -51,7 +51,7 @@ namespace PolyVox
std::string tostring(void) const; std::string tostring(void) const;
private: private:
UIntVector3 position; Vector3DUint32 position;
Vector3DFloat normal; Vector3DFloat normal;
float material; float material;
float alpha; float alpha;

35
include/TypeDef.h Normal file
View File

@ -0,0 +1,35 @@
/******************************************************************************
This file is part of a voxel plugin for OGRE
Copyright (C) 2006 David Williams
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
******************************************************************************/
//Dave, maybe make use of OgrePlatform.h instead?
// I think use _OgreExport instead of POLYVOX_API and define OGRE_NONCLIENT_BUILD instead of POLYVOX_EXPORT?
#ifndef __TYPEDEF_H__
#define __TYPEDEF_H__
#ifdef WIN32
#ifdef POLYVOX_EXPORT
#define POLYVOX_API __declspec(dllexport)
#else
#define POLYVOX_API __declspec(dllimport)
#endif
#else
#define POLYVOX_API __attribute__ ((visibility("default")))
#endif
#endif

View File

@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
namespace PolyVox namespace PolyVox
{ {
class VOXEL_SCENE_MANAGER_API Volume class POLYVOX_API Volume
{ {
//Make VolumeIterator a friend //Make VolumeIterator a friend
friend class VolumeIterator; friend class VolumeIterator;

View File

@ -27,7 +27,7 @@ namespace PolyVox
{ {
class Volume; class Volume;
class VOXEL_SCENE_MANAGER_API VolumeIterator class POLYVOX_API VolumeIterator
{ {
public: public:
VolumeIterator(Volume& volume); VolumeIterator(Volume& volume);

View File

@ -24,12 +24,12 @@ namespace PolyVox
noOfVerticesSubmitted += 3; noOfVerticesSubmitted += 3;
if(!m_AllowDuplicateVertices) 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() +0.5)][long int(v0.getPosition().y() +0.5)][long int(v0.getPosition().z() +0.5)];
if(index == -1) if(index == -1)
{ {
m_vecVertices.push_back(v0); m_vecVertices.push_back(v0);
m_vecTriangleIndices.push_back(m_vecVertices.size()-1); 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() +0.5)][long int(v0.getPosition().y() +0.5)][long int(v0.getPosition().z() +0.5)] = m_vecVertices.size()-1;
noOfVerticesAccepted++; noOfVerticesAccepted++;
} }
@ -38,12 +38,12 @@ namespace PolyVox
m_vecTriangleIndices.push_back(index); 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() +0.5)][long int(v1.getPosition().y() +0.5)][long int(v1.getPosition().z() +0.5)];
if(index == -1) if(index == -1)
{ {
m_vecVertices.push_back(v1); m_vecVertices.push_back(v1);
m_vecTriangleIndices.push_back(m_vecVertices.size()-1); 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() +0.5)][long int(v1.getPosition().y() +0.5)][long int(v1.getPosition().z() +0.5)] = m_vecVertices.size()-1;
noOfVerticesAccepted++; noOfVerticesAccepted++;
} }
@ -52,12 +52,12 @@ namespace PolyVox
m_vecTriangleIndices.push_back(index); 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() +0.5)][long int(v2.getPosition().y() +0.5)][long int(v2.getPosition().z() +0.5)];
if(index == -1) if(index == -1)
{ {
m_vecVertices.push_back(v2); m_vecVertices.push_back(v2);
m_vecTriangleIndices.push_back(m_vecVertices.size()-1); 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() +0.5)][long int(v2.getPosition().y() +0.5)][long int(v2.getPosition().z() +0.5)] = m_vecVertices.size()-1;
noOfVerticesAccepted++; noOfVerticesAccepted++;
} }

View File

@ -65,7 +65,7 @@ namespace PolyVox
RegionGeometry regionGeometry; RegionGeometry regionGeometry;
regionGeometry.m_patchSingleMaterial = new IndexedSurfacePatch(false); regionGeometry.m_patchSingleMaterial = new IndexedSurfacePatch(false);
regionGeometry.m_patchMultiMaterial = new IndexedSurfacePatch(true); regionGeometry.m_patchMultiMaterial = new IndexedSurfacePatch(true);
regionGeometry.m_v3dRegionPosition.setData(regionX, regionY, regionZ); regionGeometry.m_v3dRegionPosition = Vector3DInt32(regionX, regionY, regionZ);
generateMeshDataForRegion(regionX,regionY,regionZ, regionGeometry.m_patchSingleMaterial, regionGeometry.m_patchMultiMaterial); generateMeshDataForRegion(regionX,regionY,regionZ, regionGeometry.m_patchSingleMaterial, regionGeometry.m_patchMultiMaterial);
@ -241,9 +241,9 @@ namespace PolyVox
const uint16_t lastZ = (std::min)(firstZ + OGRE_REGION_SIDE_LENGTH-1,static_cast<uint32_t>(OGRE_VOLUME_SIDE_LENGTH-2)); const uint16_t lastZ = (std::min)(firstZ + OGRE_REGION_SIDE_LENGTH-1,static_cast<uint32_t>(OGRE_VOLUME_SIDE_LENGTH-2));
//Offset from lower block corner //Offset from lower block corner
const UIntVector3 offset(firstX*2,firstY*2,firstZ*2); const Vector3DUint32 offset(firstX*2,firstY*2,firstZ*2);
UIntVector3 vertlist[12]; Vector3DUint32 vertlist[12];
uint8_t vertMaterials[12]; uint8_t vertMaterials[12];
VolumeIterator volIter(*volumeData); VolumeIterator volIter(*volumeData);
volIter.setValidRegion(firstX,firstY,firstZ,lastX,lastY,lastZ); volIter.setValidRegion(firstX,firstY,firstZ,lastX,lastY,lastZ);
@ -291,95 +291,95 @@ namespace PolyVox
/* Find the vertices where the surface intersects the cube */ /* Find the vertices where the surface intersects the cube */
if (edgeTable[iCubeIndex] & 1) if (edgeTable[iCubeIndex] & 1)
{ {
vertlist[0].x = 2*x + 1; vertlist[0].setX(2*x + 1);
vertlist[0].y = 2*y; vertlist[0].setY(2*y);
vertlist[0].z = 2*z; vertlist[0].setZ(2*z);
vertMaterials[0] = v000 | v100; //Because one of these is 0, the or operation takes the max. vertMaterials[0] = v000 | v100; //Because one of these is 0, the or operation takes the max.
} }
if (edgeTable[iCubeIndex] & 2) if (edgeTable[iCubeIndex] & 2)
{ {
vertlist[1].x = 2*x + 2; vertlist[1].setX(2*x + 2);
vertlist[1].y = 2*y + 1; vertlist[1].setY(2*y + 1);
vertlist[1].z = 2*z; vertlist[1].setZ(2*z);
vertMaterials[1] = v100 | v110; vertMaterials[1] = v100 | v110;
} }
if (edgeTable[iCubeIndex] & 4) if (edgeTable[iCubeIndex] & 4)
{ {
vertlist[2].x = 2*x + 1; vertlist[2].setX(2*x + 1);
vertlist[2].y = 2*y + 2; vertlist[2].setY(2*y + 2);
vertlist[2].z = 2*z; vertlist[2].setZ(2*z);
vertMaterials[2] = v010 | v110; vertMaterials[2] = v010 | v110;
} }
if (edgeTable[iCubeIndex] & 8) if (edgeTable[iCubeIndex] & 8)
{ {
vertlist[3].x = 2*x; vertlist[3].setX(2*x);
vertlist[3].y = 2*y + 1; vertlist[3].setY(2*y + 1);
vertlist[3].z = 2*z; vertlist[3].setZ(2*z);
vertMaterials[3] = v000 | v010; vertMaterials[3] = v000 | v010;
} }
if (edgeTable[iCubeIndex] & 16) if (edgeTable[iCubeIndex] & 16)
{ {
vertlist[4].x = 2*x + 1; vertlist[4].setX(2*x + 1);
vertlist[4].y = 2*y; vertlist[4].setY(2*y);
vertlist[4].z = 2*z + 2; vertlist[4].setZ(2*z + 2);
vertMaterials[4] = v001 | v101; vertMaterials[4] = v001 | v101;
} }
if (edgeTable[iCubeIndex] & 32) if (edgeTable[iCubeIndex] & 32)
{ {
vertlist[5].x = 2*x + 2; vertlist[5].setX(2*x + 2);
vertlist[5].y = 2*y + 1; vertlist[5].setY(2*y + 1);
vertlist[5].z = 2*z + 2; vertlist[5].setZ(2*z + 2);
vertMaterials[5] = v101 | v111; vertMaterials[5] = v101 | v111;
} }
if (edgeTable[iCubeIndex] & 64) if (edgeTable[iCubeIndex] & 64)
{ {
vertlist[6].x = 2*x + 1; vertlist[6].setX(2*x + 1);
vertlist[6].y = 2*y + 2; vertlist[6].setY(2*y + 2);
vertlist[6].z = 2*z + 2; vertlist[6].setZ(2*z + 2);
vertMaterials[6] = v011 | v111; vertMaterials[6] = v011 | v111;
} }
if (edgeTable[iCubeIndex] & 128) if (edgeTable[iCubeIndex] & 128)
{ {
vertlist[7].x = 2*x; vertlist[7].setX(2*x);
vertlist[7].y = 2*y + 1; vertlist[7].setY(2*y + 1);
vertlist[7].z = 2*z + 2; vertlist[7].setZ(2*z + 2);
vertMaterials[7] = v001 | v011; vertMaterials[7] = v001 | v011;
} }
if (edgeTable[iCubeIndex] & 256) if (edgeTable[iCubeIndex] & 256)
{ {
vertlist[8].x = 2*x; vertlist[8].setX(2*x);
vertlist[8].y = 2*y; vertlist[8].setY(2*y);
vertlist[8].z = 2*z + 1; vertlist[8].setZ(2*z + 1);
vertMaterials[8] = v000 | v001; vertMaterials[8] = v000 | v001;
} }
if (edgeTable[iCubeIndex] & 512) if (edgeTable[iCubeIndex] & 512)
{ {
vertlist[9].x = 2*x + 2; vertlist[9].setX(2*x + 2);
vertlist[9].y = 2*y; vertlist[9].setY(2*y);
vertlist[9].z = 2*z + 1; vertlist[9].setZ(2*z + 1);
vertMaterials[9] = v100 | v101; vertMaterials[9] = v100 | v101;
} }
if (edgeTable[iCubeIndex] & 1024) if (edgeTable[iCubeIndex] & 1024)
{ {
vertlist[10].x = 2*x + 2; vertlist[10].setX(2*x + 2);
vertlist[10].y = 2*y + 2; vertlist[10].setY(2*y + 2);
vertlist[10].z = 2*z + 1; vertlist[10].setZ(2*z + 1);
vertMaterials[10] = v110 | v111; vertMaterials[10] = v110 | v111;
} }
if (edgeTable[iCubeIndex] & 2048) if (edgeTable[iCubeIndex] & 2048)
{ {
vertlist[11].x = 2*x; vertlist[11].setX(2*x);
vertlist[11].y = 2*y + 2; vertlist[11].setY(2*y + 2);
vertlist[11].z = 2*z + 1; vertlist[11].setZ(2*z + 1);
vertMaterials[11] = v010 | v011; vertMaterials[11] = v010 | v011;
} }
for (int i=0;triTable[iCubeIndex][i]!=-1;i+=3) for (int i=0;triTable[iCubeIndex][i]!=-1;i+=3)
{ {
//The three vertices forming a triangle //The three vertices forming a triangle
const UIntVector3 vertex0 = vertlist[triTable[iCubeIndex][i ]] - offset; const Vector3DUint32 vertex0 = vertlist[triTable[iCubeIndex][i ]] - offset;
const UIntVector3 vertex1 = vertlist[triTable[iCubeIndex][i+1]] - offset; const Vector3DUint32 vertex1 = vertlist[triTable[iCubeIndex][i+1]] - offset;
const UIntVector3 vertex2 = vertlist[triTable[iCubeIndex][i+2]] - offset; const Vector3DUint32 vertex2 = vertlist[triTable[iCubeIndex][i+2]] - offset;
const uint8_t material0 = vertMaterials[triTable[iCubeIndex][i ]]; const uint8_t material0 = vertMaterials[triTable[iCubeIndex][i ]];
const uint8_t material1 = vertMaterials[triTable[iCubeIndex][i+1]]; const uint8_t material1 = vertMaterials[triTable[iCubeIndex][i+1]];
@ -507,7 +507,7 @@ namespace PolyVox
std::vector<SurfaceVertex>::iterator iterSurfaceVertex = singleMaterialPatch->m_vecVertices.begin(); std::vector<SurfaceVertex>::iterator iterSurfaceVertex = singleMaterialPatch->m_vecVertices.begin();
while(iterSurfaceVertex != singleMaterialPatch->m_vecVertices.end()) while(iterSurfaceVertex != singleMaterialPatch->m_vecVertices.end())
{ {
Vector3DFloat tempNormal = computeNormal((iterSurfaceVertex->getPosition() + offset).toVector3DFloat()/2.0f, CENTRAL_DIFFERENCE); Vector3DFloat tempNormal = computeNormal(static_cast<Vector3DFloat>(iterSurfaceVertex->getPosition() + offset)/2.0f, CENTRAL_DIFFERENCE);
const_cast<SurfaceVertex&>(*iterSurfaceVertex).setNormal(tempNormal); const_cast<SurfaceVertex&>(*iterSurfaceVertex).setNormal(tempNormal);
++iterSurfaceVertex; ++iterSurfaceVertex;
} }
@ -515,7 +515,7 @@ namespace PolyVox
iterSurfaceVertex = multiMaterialPatch->m_vecVertices.begin(); iterSurfaceVertex = multiMaterialPatch->m_vecVertices.begin();
while(iterSurfaceVertex != multiMaterialPatch->m_vecVertices.end()) while(iterSurfaceVertex != multiMaterialPatch->m_vecVertices.end())
{ {
Vector3DFloat tempNormal = computeNormal((iterSurfaceVertex->getPosition() + offset).toVector3DFloat()/2.0f, CENTRAL_DIFFERENCE); Vector3DFloat tempNormal = computeNormal(static_cast<Vector3DFloat>(iterSurfaceVertex->getPosition() + offset)/2.0f, CENTRAL_DIFFERENCE);
const_cast<SurfaceVertex&>(*iterSurfaceVertex).setNormal(tempNormal); const_cast<SurfaceVertex&>(*iterSurfaceVertex).setNormal(tempNormal);
++iterSurfaceVertex; ++iterSurfaceVertex;
} }

View File

@ -11,20 +11,20 @@ namespace PolyVox
{ {
} }
SurfaceVertex::SurfaceVertex(UIntVector3 positionToSet, float materialToSet, float alphaToSet) SurfaceVertex::SurfaceVertex(Vector3DUint32 positionToSet, float materialToSet, float alphaToSet)
:material(materialToSet) :material(materialToSet)
,alpha(alphaToSet) ,alpha(alphaToSet)
,position(positionToSet) ,position(positionToSet)
,m_uHash((position.x*(OGRE_REGION_SIDE_LENGTH*2+1)*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.y*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.z)) ,m_uHash((position.x()*(OGRE_REGION_SIDE_LENGTH*2+1)*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.y()*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.z()))
{ {
} }
SurfaceVertex::SurfaceVertex(UIntVector3 positionToSet, Vector3DFloat normalToSet) SurfaceVertex::SurfaceVertex(Vector3DUint32 positionToSet, Vector3DFloat normalToSet)
:position(positionToSet) :position(positionToSet)
,normal(normalToSet) ,normal(normalToSet)
{ {
m_uHash = (position.x*(OGRE_REGION_SIDE_LENGTH*2+1)*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.y*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.z); m_uHash = (position.x()*(OGRE_REGION_SIDE_LENGTH*2+1)*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.y()*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.z());
} }
float SurfaceVertex::getAlpha(void) const float SurfaceVertex::getAlpha(void) const
@ -47,7 +47,7 @@ namespace PolyVox
return normal; return normal;
} }
const UIntVector3& SurfaceVertex::getPosition(void) const const Vector3DUint32& SurfaceVertex::getPosition(void) const
{ {
return position; return position;
} }
@ -76,7 +76,7 @@ namespace PolyVox
std::string SurfaceVertex::tostring(void) const std::string SurfaceVertex::tostring(void) const
{ {
std::stringstream ss; std::stringstream ss;
ss << "SurfaceVertex: Position = (" << position.x << "," << position.y << "," << position.z << "), Normal = " << normal; ss << "SurfaceVertex: Position = (" << position.x() << "," << position.y() << "," << position.z() << "), Normal = " << normal;
return ss.str(); return ss.str();
} }

View File

@ -264,57 +264,57 @@ namespace PolyVox
return; //FIXME - Error message? Exception? return; //FIXME - Error message? Exception?
} }
std::queue<UIntVector3> seeds; std::queue<Vector3DUint32> seeds;
seeds.push(UIntVector3(xStart,yStart,zStart)); seeds.push(Vector3DUint32(xStart,yStart,zStart));
while(!seeds.empty()) while(!seeds.empty())
{ {
UIntVector3 currentSeed = seeds.front(); Vector3DUint32 currentSeed = seeds.front();
seeds.pop(); seeds.pop();
//std::cout << "x = " << currentSeed.x << " y = " << currentSeed.y << " z = " << currentSeed.z << std::endl; //std::cout << "x = " << currentSeed.x << " y = " << currentSeed.y << " z = " << currentSeed.z << std::endl;
//FIXME - introduce 'safe' function which tests this? //FIXME - introduce 'safe' function which tests this?
if((currentSeed.x > OGRE_VOLUME_SIDE_LENGTH-2) || (currentSeed.y > OGRE_VOLUME_SIDE_LENGTH-2) || (currentSeed.z > OGRE_VOLUME_SIDE_LENGTH-2) if((currentSeed.x() > OGRE_VOLUME_SIDE_LENGTH-2) || (currentSeed.y() > OGRE_VOLUME_SIDE_LENGTH-2) || (currentSeed.z() > OGRE_VOLUME_SIDE_LENGTH-2)
|| (currentSeed.x < 1) || (currentSeed.y < 1) || (currentSeed.z < 1)) || (currentSeed.x() < 1) || (currentSeed.y() < 1) || (currentSeed.z() < 1))
{ {
continue; continue;
} }
if(volIter.getVoxelAt(currentSeed.x, currentSeed.y, currentSeed.z+1) == uSeedValue) if(volIter.getVoxelAt(currentSeed.x(), currentSeed.y(), currentSeed.z()+1) == uSeedValue)
{ {
volIter.setVoxelAt(currentSeed.x, currentSeed.y, currentSeed.z+1, value); volIter.setVoxelAt(currentSeed.x(), currentSeed.y(), currentSeed.z()+1, value);
seeds.push(UIntVector3(currentSeed.x, currentSeed.y, currentSeed.z+1)); seeds.push(Vector3DUint32(currentSeed.x(), currentSeed.y(), currentSeed.z()+1));
} }
if(volIter.getVoxelAt(currentSeed.x, currentSeed.y, currentSeed.z-1) == uSeedValue) if(volIter.getVoxelAt(currentSeed.x(), currentSeed.y(), currentSeed.z()-1) == uSeedValue)
{ {
volIter.setVoxelAt(currentSeed.x, currentSeed.y, currentSeed.z-1, value); volIter.setVoxelAt(currentSeed.x(), currentSeed.y(), currentSeed.z()-1, value);
seeds.push(UIntVector3(currentSeed.x, currentSeed.y, currentSeed.z-1)); seeds.push(Vector3DUint32(currentSeed.x(), currentSeed.y(), currentSeed.z()-1));
} }
if(volIter.getVoxelAt(currentSeed.x, currentSeed.y+1, currentSeed.z) == uSeedValue) if(volIter.getVoxelAt(currentSeed.x(), currentSeed.y()+1, currentSeed.z()) == uSeedValue)
{ {
volIter.setVoxelAt(currentSeed.x, currentSeed.y+1, currentSeed.z, value); volIter.setVoxelAt(currentSeed.x(), currentSeed.y()+1, currentSeed.z(), value);
seeds.push(UIntVector3(currentSeed.x, currentSeed.y+1, currentSeed.z)); seeds.push(Vector3DUint32(currentSeed.x(), currentSeed.y()+1, currentSeed.z()));
} }
if(volIter.getVoxelAt(currentSeed.x, currentSeed.y-1, currentSeed.z) == uSeedValue) if(volIter.getVoxelAt(currentSeed.x(), currentSeed.y()-1, currentSeed.z()) == uSeedValue)
{ {
volIter.setVoxelAt(currentSeed.x, currentSeed.y-1, currentSeed.z, value); volIter.setVoxelAt(currentSeed.x(), currentSeed.y()-1, currentSeed.z(), value);
seeds.push(UIntVector3(currentSeed.x, currentSeed.y-1, currentSeed.z)); seeds.push(Vector3DUint32(currentSeed.x(), currentSeed.y()-1, currentSeed.z()));
} }
if(volIter.getVoxelAt(currentSeed.x+1, currentSeed.y, currentSeed.z) == uSeedValue) if(volIter.getVoxelAt(currentSeed.x()+1, currentSeed.y(), currentSeed.z()) == uSeedValue)
{ {
volIter.setVoxelAt(currentSeed.x+1, currentSeed.y, currentSeed.z, value); volIter.setVoxelAt(currentSeed.x()+1, currentSeed.y(), currentSeed.z(), value);
seeds.push(UIntVector3(currentSeed.x+1, currentSeed.y, currentSeed.z)); seeds.push(Vector3DUint32(currentSeed.x()+1, currentSeed.y(), currentSeed.z()));
} }
if(volIter.getVoxelAt(currentSeed.x-1, currentSeed.y, currentSeed.z) == uSeedValue) if(volIter.getVoxelAt(currentSeed.x()-1, currentSeed.y(), currentSeed.z()) == uSeedValue)
{ {
volIter.setVoxelAt(currentSeed.x-1, currentSeed.y, currentSeed.z, value); volIter.setVoxelAt(currentSeed.x()-1, currentSeed.y(), currentSeed.z(), value);
seeds.push(UIntVector3(currentSeed.x-1, currentSeed.y, currentSeed.z)); seeds.push(Vector3DUint32(currentSeed.x()-1, currentSeed.y(), currentSeed.z()));
} }
} }
} }