Renamed vertex classes to the far more meaningful 'CubicVertex' and 'MarchingCubesVertex'. The old names didn't make much sense, even less so now they are templatized.
This commit is contained in:
		| @@ -113,9 +113,9 @@ namespace PolyVox | ||||
| 		// This is a bit ugly - it seems that the C++03 syntax is different from the C++11 syntax? See this thread: http://stackoverflow.com/questions/6076015/typename-outside-of-template | ||||
| 		// Long term we should probably come back to this and if the #ifdef is still needed then maybe it should check for C++11 mode instead of MSVC?  | ||||
| #if defined(_MSC_VER) | ||||
| 		CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded()); | ||||
| 		CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<CubicVertex<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded()); | ||||
| #else | ||||
| 		CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded()); | ||||
| 		CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<CubicVertex<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded()); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| @@ -135,7 +135,7 @@ namespace PolyVox | ||||
| 		Region m_regSizeInVoxels; | ||||
|  | ||||
| 		//The surface patch we are currently filling. | ||||
| 		SurfaceMesh<PositionMaterialNormal<typename VolumeType::VoxelType> >* m_meshCurrent; | ||||
| 		SurfaceMesh<CubicVertex<typename VolumeType::VoxelType> >* m_meshCurrent; | ||||
|  | ||||
| 		//Used to avoid creating duplicate vertices. | ||||
| 		Array<3, IndexAndMaterial> m_previousSliceVertices; | ||||
|   | ||||
| @@ -36,7 +36,7 @@ namespace PolyVox | ||||
| 	const uint32_t CubicSurfaceExtractor<VolumeType, IsQuadNeeded>::MaxVerticesPerPosition = 8; | ||||
|  | ||||
| 	template<typename VolumeType, typename IsQuadNeeded> | ||||
| 	CubicSurfaceExtractor<VolumeType, IsQuadNeeded>::CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, bool bMergeQuads, IsQuadNeeded isQuadNeeded) | ||||
| 	CubicSurfaceExtractor<VolumeType, IsQuadNeeded>::CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<CubicVertex<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, bool bMergeQuads, IsQuadNeeded isQuadNeeded) | ||||
| 		:m_volData(volData) | ||||
| 		,m_regSizeInVoxels(region) | ||||
| 		,m_meshCurrent(result) | ||||
| @@ -214,7 +214,7 @@ namespace PolyVox | ||||
| 			if(rEntry.iIndex == -1) | ||||
| 			{ | ||||
| 				//No vertices matched and we've now hit an empty space. Fill it by creating a vertex. The 0.5f offset is because vertices set between voxels in order to build cubes around them. | ||||
| 				rEntry.iIndex = m_meshCurrent->addVertex(PositionMaterialNormal<typename VolumeType::VoxelType>(Vector3DFloat(static_cast<float>(uX)-0.5f, static_cast<float>(uY)-0.5f, static_cast<float>(uZ)-0.5f), uMaterialIn)); | ||||
| 				rEntry.iIndex = m_meshCurrent->addVertex(CubicVertex<typename VolumeType::VoxelType>(Vector3DFloat(static_cast<float>(uX)-0.5f, static_cast<float>(uY)-0.5f, static_cast<float>(uZ)-0.5f), uMaterialIn)); | ||||
| 				rEntry.uMaterial = uMaterialIn; | ||||
|  | ||||
| 				return rEntry.iIndex; | ||||
|   | ||||
| @@ -41,9 +41,9 @@ namespace PolyVox | ||||
| 		// This is a bit ugly - it seems that the C++03 syntax is different from the C++11 syntax? See this thread: http://stackoverflow.com/questions/6076015/typename-outside-of-template | ||||
| 		// Long term we should probably come back to this and if the #ifdef is still needed then maybe it should check for C++11 mode instead of MSVC?  | ||||
| #if defined(_MSC_VER) | ||||
| 		MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(), Controller controller = Controller()); | ||||
| 		MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<MarchingCubesVertex<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(), Controller controller = Controller()); | ||||
| #else | ||||
| 		MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), Controller controller = Controller()); | ||||
| 		MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<MarchingCubesVertex<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), Controller controller = Controller()); | ||||
| #endif | ||||
|  | ||||
| 		void execute(); | ||||
| @@ -193,7 +193,7 @@ namespace PolyVox | ||||
| 		uint32_t m_uNoOfOccupiedCells; | ||||
|  | ||||
| 		//The surface patch we are currently filling. | ||||
| 		SurfaceMesh<PositionMaterialNormal<typename VolumeType::VoxelType> >* m_meshCurrent; | ||||
| 		SurfaceMesh<MarchingCubesVertex<typename VolumeType::VoxelType> >* m_meshCurrent; | ||||
|  | ||||
| 		//Information about the region we are currently processing | ||||
| 		Region m_regSizeInVoxels; | ||||
|   | ||||
| @@ -26,7 +26,7 @@ freely, subject to the following restrictions: | ||||
| namespace PolyVox | ||||
| { | ||||
| 	template<typename VolumeType, typename Controller> | ||||
| 	MarchingCubesSurfaceExtractor<VolumeType, Controller>::MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, Controller controller) | ||||
| 	MarchingCubesSurfaceExtractor<VolumeType, Controller>::MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<MarchingCubesVertex<typename VolumeType::VoxelType> >* result, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, Controller controller) | ||||
| 		:m_volData(volData) | ||||
| 		,m_sampVolume(volData) | ||||
| 		,m_meshCurrent(result) | ||||
| @@ -459,7 +459,7 @@ namespace PolyVox | ||||
| 					// Allow the controller to decide how the material should be derived from the voxels. | ||||
| 					const typename VolumeType::VoxelType uMaterial = m_controller.blendMaterials(v000, v100, fInterp); | ||||
|  | ||||
| 					const PositionMaterialNormal<typename VolumeType::VoxelType> surfaceVertex(v3dPosition, v3dNormal, uMaterial); | ||||
| 					const MarchingCubesVertex<typename VolumeType::VoxelType> surfaceVertex(v3dPosition, v3dNormal, uMaterial); | ||||
| 					const uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); | ||||
| 					m_pCurrentVertexIndicesX[iXVolSpace - m_regSizeInVoxels.getLowerX()][iYVolSpace - m_regSizeInVoxels.getLowerY()] = uLastVertexIndex; | ||||
|  | ||||
| @@ -488,7 +488,7 @@ namespace PolyVox | ||||
| 					// Allow the controller to decide how the material should be derived from the voxels. | ||||
| 					const typename VolumeType::VoxelType uMaterial = m_controller.blendMaterials(v000, v010, fInterp); | ||||
|  | ||||
| 					PositionMaterialNormal<typename VolumeType::VoxelType> surfaceVertex(v3dPosition, v3dNormal, uMaterial); | ||||
| 					MarchingCubesVertex<typename VolumeType::VoxelType> surfaceVertex(v3dPosition, v3dNormal, uMaterial); | ||||
| 					uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); | ||||
| 					m_pCurrentVertexIndicesY[iXVolSpace - m_regSizeInVoxels.getLowerX()][iYVolSpace - m_regSizeInVoxels.getLowerY()] = uLastVertexIndex; | ||||
|  | ||||
| @@ -516,7 +516,7 @@ namespace PolyVox | ||||
| 					// Allow the controller to decide how the material should be derived from the voxels. | ||||
| 					const typename VolumeType::VoxelType uMaterial = m_controller.blendMaterials(v000, v001, fInterp); | ||||
|  | ||||
| 					const PositionMaterialNormal<typename VolumeType::VoxelType> surfaceVertex(v3dPosition, v3dNormal, uMaterial); | ||||
| 					const MarchingCubesVertex<typename VolumeType::VoxelType> surfaceVertex(v3dPosition, v3dNormal, uMaterial); | ||||
| 					const uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); | ||||
| 					m_pCurrentVertexIndicesZ[iXVolSpace - m_regSizeInVoxels.getLowerX()][iYVolSpace - m_regSizeInVoxels.getLowerY()] = uLastVertexIndex; | ||||
|  | ||||
|   | ||||
| @@ -78,6 +78,11 @@ namespace PolyVox | ||||
| 	template<typename VoxelType> class DefaultIsQuadNeeded; | ||||
| 	template<typename VolumeType, typename IsQuadNeeded = DefaultIsQuadNeeded<typename VolumeType::VoxelType> > class CubicSurfaceExtractor; | ||||
|  | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| 	// CubicVertex | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| 	template<typename VoxelType> class CubicVertex; | ||||
|  | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| 	// Density | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -103,6 +108,11 @@ namespace PolyVox | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| 	template <typename VoxelType> class LargeVolume; | ||||
|  | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| 	// MarchingCubesVertex | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| 	template<typename VoxelType> class MarchingCubesVertex; | ||||
|  | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| 	// Material | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -129,11 +139,6 @@ namespace PolyVox | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| 	template <typename VoxelType> class Pager; | ||||
|  | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| 	// PositionMaterialNormal | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| 	template<typename MaterialType> class PositionMaterialNormal; | ||||
|  | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
| 	// RawVolume | ||||
| 	//////////////////////////////////////////////////////////////////////////////// | ||||
|   | ||||
| @@ -34,74 +34,31 @@ freely, subject to the following restrictions: | ||||
| namespace PolyVox | ||||
| {	 | ||||
| #ifdef SWIG | ||||
| 	class PositionMaterial | ||||
| 	class CubicVertex | ||||
| #else | ||||
| 	template<typename MaterialType> | ||||
| 	class POLYVOX_API PositionMaterial | ||||
| 	template<typename VoxelType> | ||||
| 	class POLYVOX_API CubicVertex | ||||
| #endif | ||||
| 	{ | ||||
| 	public:	 | ||||
| 		PositionMaterial() | ||||
| 		CubicVertex() | ||||
| 		{ | ||||
| 		} | ||||
|  | ||||
| 		PositionMaterial(Vector3DFloat positionToSet, MaterialType materialToSet) | ||||
| 		CubicVertex(Vector3DFloat positionToSet, VoxelType materialToSet) | ||||
| 			:position(positionToSet) | ||||
| 			,material(materialToSet) | ||||
| 		{ | ||||
| 		} | ||||
|  | ||||
| 		MaterialType getMaterial(void) const | ||||
| 		{ | ||||
| 			return material; | ||||
| 		} | ||||
|  | ||||
| 		const Vector3DFloat& getPosition(void) const | ||||
| 		{ | ||||
| 			return position; | ||||
| 		} | ||||
|  | ||||
| 		void setMaterial(MaterialType materialToSet) | ||||
| 		{ | ||||
| 			material = materialToSet; | ||||
| 		} | ||||
|  | ||||
| 		void setPosition(const Vector3DFloat& positionToSet) | ||||
| 		{ | ||||
| 			position = positionToSet; | ||||
| 		} | ||||
| 	public:		 | ||||
| 		//Nicely fits into four floats. | ||||
| 		Vector3DFloat position; | ||||
| 		MaterialType material; | ||||
| 	};	 | ||||
|  | ||||
| #ifdef SWIG | ||||
| 	class PositionMaterialNormal | ||||
| #else | ||||
| 	template<typename MaterialType> | ||||
| 	class POLYVOX_API PositionMaterialNormal | ||||
| #endif | ||||
| 	{ | ||||
| 	public:	 | ||||
| 		PositionMaterialNormal() | ||||
| 		{ | ||||
| 		} | ||||
|  | ||||
| 		PositionMaterialNormal(Vector3DFloat positionToSet, MaterialType materialToSet) | ||||
| 			:position(positionToSet) | ||||
| 			,material(materialToSet) | ||||
| 		{ | ||||
| 		} | ||||
|  | ||||
| 		PositionMaterialNormal(Vector3DFloat positionToSet, Vector3DFloat normalToSet, MaterialType materialToSet) | ||||
| 		CubicVertex(Vector3DFloat positionToSet, Vector3DFloat normalToSet, VoxelType materialToSet) | ||||
| 			:position(positionToSet) | ||||
| 			,normal(normalToSet) | ||||
| 			,material(materialToSet) | ||||
| 		{ | ||||
| 		} | ||||
|  | ||||
| 		MaterialType getMaterial(void) const | ||||
| 		VoxelType getMaterial(void) const | ||||
| 		{ | ||||
| 			return material; | ||||
| 		} | ||||
| @@ -116,7 +73,7 @@ namespace PolyVox | ||||
| 			return position; | ||||
| 		} | ||||
|  | ||||
| 		void setMaterial(MaterialType materialToSet) | ||||
| 		void setMaterial(VoxelType materialToSet) | ||||
| 		{ | ||||
| 			material = materialToSet; | ||||
| 		} | ||||
| @@ -131,12 +88,71 @@ namespace PolyVox | ||||
| 			position = positionToSet; | ||||
| 		} | ||||
|  | ||||
| 	public:		 | ||||
| 		//Nicely fits into seven floats, meaning we | ||||
| 		//can squeeze in one more for material blending. | ||||
| 	public: | ||||
| 		Vector3DFloat position; | ||||
| 		Vector3DFloat normal; | ||||
| 		MaterialType material; //FIXME: This shouldn't be float on CPU? | ||||
| 		VoxelType material; | ||||
| 	}; | ||||
|  | ||||
| #ifdef SWIG | ||||
| 	class MarchingCubesVertex | ||||
| #else | ||||
| 	template<typename VoxelType> | ||||
| 	class POLYVOX_API MarchingCubesVertex | ||||
| #endif | ||||
| 	{ | ||||
| 	public: | ||||
| 		MarchingCubesVertex() | ||||
| 		{ | ||||
| 		} | ||||
|  | ||||
| 		MarchingCubesVertex(Vector3DFloat positionToSet, VoxelType materialToSet) | ||||
| 			:position(positionToSet) | ||||
| 			, material(materialToSet) | ||||
| 		{ | ||||
| 		} | ||||
|  | ||||
| 		MarchingCubesVertex(Vector3DFloat positionToSet, Vector3DFloat normalToSet, VoxelType materialToSet) | ||||
| 			:position(positionToSet) | ||||
| 			, normal(normalToSet) | ||||
| 			, material(materialToSet) | ||||
| 		{ | ||||
| 		} | ||||
|  | ||||
| 		VoxelType getMaterial(void) const | ||||
| 		{ | ||||
| 			return material; | ||||
| 		} | ||||
|  | ||||
| 		const Vector3DFloat& getNormal(void) const | ||||
| 		{ | ||||
| 			return normal; | ||||
| 		} | ||||
|  | ||||
| 		const Vector3DFloat& getPosition(void) const | ||||
| 		{ | ||||
| 			return position; | ||||
| 		} | ||||
|  | ||||
| 		void setMaterial(VoxelType materialToSet) | ||||
| 		{ | ||||
| 			material = materialToSet; | ||||
| 		} | ||||
|  | ||||
| 		void setNormal(const Vector3DFloat& normalToSet) | ||||
| 		{ | ||||
| 			normal = normalToSet; | ||||
| 		} | ||||
|  | ||||
| 		void setPosition(const Vector3DFloat& positionToSet) | ||||
| 		{ | ||||
| 			position = positionToSet; | ||||
| 		} | ||||
|  | ||||
| 	public: | ||||
| 		Vector3DFloat position; | ||||
| 		Vector3DFloat normal; | ||||
| 		VoxelType material; | ||||
| 	}; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user