Moved typedef'd integers into PlyVox namespace instead of std.
This commit is contained in:
		| @@ -9,7 +9,7 @@ using namespace std; | ||||
|  | ||||
| namespace PolyVox | ||||
| { | ||||
| 	POLYVOX_API void computeNormalsForVertices(BlockVolume<std::uint8_t>* volumeData, RegionGeometry& regGeom, NormalGenerationMethod normalGenerationMethod) | ||||
| 	POLYVOX_API void computeNormalsForVertices(BlockVolume<uint8>* volumeData, RegionGeometry& regGeom, NormalGenerationMethod normalGenerationMethod) | ||||
| 	{ | ||||
| 		std::vector<SurfaceVertex>& vecVertices = regGeom.m_patchSingleMaterial->m_vecVertices; | ||||
| 		std::vector<SurfaceVertex>::iterator iterSurfaceVertex = vecVertices.begin(); | ||||
| @@ -18,7 +18,7 @@ namespace PolyVox | ||||
| 			const Vector3DFloat& v3dPos = iterSurfaceVertex->getPosition() + static_cast<Vector3DFloat>(regGeom.m_v3dRegionPosition); | ||||
| 			const Vector3DInt32 v3dFloor = static_cast<Vector3DInt32>(v3dPos); | ||||
|  | ||||
| 			BlockVolumeIterator<std::uint8_t> volIter(*volumeData); | ||||
| 			BlockVolumeIterator<uint8> volIter(*volumeData); | ||||
|  | ||||
| 			//Check all corners are within the volume, allowing a boundary for gradient estimation | ||||
| 			bool lowerCornerInside = volumeData->containsPoint(v3dFloor,1); | ||||
| @@ -78,15 +78,15 @@ namespace PolyVox | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	Vector3DFloat computeNormal(BlockVolume<uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) | ||||
| 	Vector3DFloat computeNormal(BlockVolume<uint8>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) | ||||
| 	{ | ||||
| 		const float posX = position.getX(); | ||||
| 		const float posY = position.getY(); | ||||
| 		const float posZ = position.getZ(); | ||||
|  | ||||
| 		const uint16_t floorX = static_cast<uint16_t>(posX); | ||||
| 		const uint16_t floorY = static_cast<uint16_t>(posY); | ||||
| 		const uint16_t floorZ = static_cast<uint16_t>(posZ); | ||||
| 		const uint16 floorX = static_cast<uint16>(posX); | ||||
| 		const uint16 floorY = static_cast<uint16>(posY); | ||||
| 		const uint16 floorZ = static_cast<uint16>(posZ); | ||||
|  | ||||
| 		//Check all corners are within the volume, allowing a boundary for gradient estimation | ||||
| 		bool lowerCornerInside = volumeData->containsPoint(Vector3DInt32(floorX, floorY, floorZ),1); | ||||
| @@ -98,24 +98,24 @@ namespace PolyVox | ||||
|  | ||||
| 		Vector3DFloat result; | ||||
|  | ||||
| 		BlockVolumeIterator<std::uint8_t> volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create? | ||||
| 		BlockVolumeIterator<uint8> volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create? | ||||
|  | ||||
|  | ||||
| 		if(normalGenerationMethod == SOBEL) | ||||
| 		{ | ||||
| 			volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ)); | ||||
| 			volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ)); | ||||
| 			const Vector3DFloat gradFloor = computeSobelGradient(volIter); | ||||
| 			if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{			 | ||||
| 				volIter.setPosition(static_cast<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ)); | ||||
| 				volIter.setPosition(static_cast<uint16>(posX+1.0),static_cast<uint16>(posY),static_cast<uint16>(posZ)); | ||||
| 			} | ||||
| 			if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{			 | ||||
| 				volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY+1.0),static_cast<uint16_t>(posZ)); | ||||
| 				volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY+1.0),static_cast<uint16>(posZ)); | ||||
| 			} | ||||
| 			if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{			 | ||||
| 				volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));					 | ||||
| 				volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ+1.0));					 | ||||
| 			} | ||||
| 			const Vector3DFloat gradCeil = computeSobelGradient(volIter); | ||||
| 			result = ((gradFloor + gradCeil) * -1.0f); | ||||
| @@ -127,19 +127,19 @@ namespace PolyVox | ||||
| 		} | ||||
| 		if(normalGenerationMethod == CENTRAL_DIFFERENCE) | ||||
| 		{ | ||||
| 			volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ)); | ||||
| 			volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ)); | ||||
| 			const Vector3DFloat gradFloor = computeCentralDifferenceGradient(volIter); | ||||
| 			if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{			 | ||||
| 				volIter.setPosition(static_cast<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ)); | ||||
| 				volIter.setPosition(static_cast<uint16>(posX+1.0),static_cast<uint16>(posY),static_cast<uint16>(posZ)); | ||||
| 			} | ||||
| 			if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{			 | ||||
| 				volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY+1.0),static_cast<uint16_t>(posZ)); | ||||
| 				volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY+1.0),static_cast<uint16>(posZ)); | ||||
| 			} | ||||
| 			if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{			 | ||||
| 				volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));					 | ||||
| 				volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ+1.0));					 | ||||
| 			} | ||||
| 			const Vector3DFloat gradCeil = computeCentralDifferenceGradient(volIter); | ||||
| 			result = ((gradFloor + gradCeil) * -1.0f); | ||||
| @@ -151,21 +151,21 @@ namespace PolyVox | ||||
| 		} | ||||
| 		if(normalGenerationMethod == SIMPLE) | ||||
| 		{ | ||||
| 			volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ)); | ||||
| 			const uint8_t uFloor = volIter.getVoxel() > 0 ? 1 : 0; | ||||
| 			volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ)); | ||||
| 			const uint8 uFloor = volIter.getVoxel() > 0 ? 1 : 0; | ||||
| 			if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{					 | ||||
| 				uint8_t uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0; | ||||
| 				uint8 uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0; | ||||
| 				result = Vector3DFloat(static_cast<float>(uFloor - uCeil),0.0,0.0); | ||||
| 			} | ||||
| 			else if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{ | ||||
| 				uint8_t uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0; | ||||
| 				uint8 uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0; | ||||
| 				result = Vector3DFloat(0.0,static_cast<float>(uFloor - uCeil),0.0); | ||||
| 			} | ||||
| 			else if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{ | ||||
| 				uint8_t uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0; | ||||
| 				uint8 uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0; | ||||
| 				result = Vector3DFloat(0.0, 0.0,static_cast<float>(uFloor - uCeil));					 | ||||
| 			} | ||||
| 		} | ||||
|   | ||||
| @@ -43,7 +43,7 @@ namespace PolyVox | ||||
| 		m_vecTriangleIndices.push_back(m_vecVertices.size()-1); | ||||
| 	} | ||||
|  | ||||
| 	void IndexedSurfacePatch::fillVertexAndIndexData(std::vector<SurfaceVertex>& vecVertices, std::vector<uint32_t>& vecIndices) | ||||
| 	void IndexedSurfacePatch::fillVertexAndIndexData(std::vector<SurfaceVertex>& vecVertices, std::vector<uint32>& vecIndices) | ||||
| 	{ | ||||
| 		vecVertices.resize(m_vecVertices.size()); | ||||
| 		std::copy(m_vecVertices.begin(), m_vecVertices.end(), vecVertices.begin()); | ||||
| @@ -68,7 +68,7 @@ namespace PolyVox | ||||
| 		return m_vecVertices; | ||||
| 	} | ||||
|  | ||||
| 	const std::vector<std::uint32_t>& IndexedSurfacePatch::getIndices(void) const | ||||
| 	const std::vector<uint32>& IndexedSurfacePatch::getIndices(void) const | ||||
| 	{ | ||||
| 		return m_vecTriangleIndices; | ||||
| 	} | ||||
|   | ||||
| @@ -44,7 +44,7 @@ namespace PolyVox | ||||
| 			&& (pos.getZ() >= m_v3dLowerCorner.getZ() + boundary); | ||||
| 	} | ||||
|  | ||||
| 	bool Region::containsPoint(const Vector3DInt32& pos, std::uint8_t boundary) const | ||||
| 	bool Region::containsPoint(const Vector3DInt32& pos, uint8 boundary) const | ||||
| 	{ | ||||
| 		return (pos.getX() <= m_v3dUpperCorner.getX() - boundary) | ||||
| 			&& (pos.getY() <= m_v3dUpperCorner.getY() - boundary)  | ||||
|   | ||||
| @@ -13,12 +13,12 @@ using namespace std; | ||||
|  | ||||
| namespace PolyVox | ||||
| { | ||||
| 	void smoothRegionGeometry(BlockVolume<std::uint8_t>* volumeData, RegionGeometry& regGeom) | ||||
| 	void smoothRegionGeometry(BlockVolume<uint8>* volumeData, RegionGeometry& regGeom) | ||||
| 	{ | ||||
| 		const std::uint8_t uSmoothingFactor = 2; | ||||
| 		const uint8 uSmoothingFactor = 2; | ||||
| 		const float fThreshold = 0.5f; | ||||
|  | ||||
| 		BlockVolumeIterator<std::uint8_t> volIter(*volumeData); | ||||
| 		BlockVolumeIterator<uint8> volIter(*volumeData); | ||||
|  | ||||
| 		std::vector<SurfaceVertex>& vecVertices = regGeom.m_patchSingleMaterial->m_vecVertices; | ||||
| 		std::vector<SurfaceVertex>::iterator iterSurfaceVertex = vecVertices.begin(); | ||||
| @@ -77,9 +77,9 @@ namespace PolyVox | ||||
| 		} //while(iterSurfaceVertex != vecVertices.end()) | ||||
| 	} | ||||
|  | ||||
| 	void adjustDecimatedGeometry(BlockVolume<std::uint8_t>* volumeData, RegionGeometry& regGeom, uint8_t val) | ||||
| 	void adjustDecimatedGeometry(BlockVolume<uint8>* volumeData, RegionGeometry& regGeom, uint8 val) | ||||
| 	{ | ||||
| 		BlockVolumeIterator<std::uint8_t> volIter(*volumeData); | ||||
| 		BlockVolumeIterator<uint8> volIter(*volumeData); | ||||
|  | ||||
| 		std::vector<SurfaceVertex>& vecVertices = regGeom.m_patchSingleMaterial->m_vecVertices; | ||||
| 		std::vector<SurfaceVertex>::iterator iterSurfaceVertex = vecVertices.begin(); | ||||
| @@ -88,7 +88,7 @@ namespace PolyVox | ||||
| 			Vector3DFloat v3dPos = iterSurfaceVertex->getPosition() + static_cast<Vector3DFloat>(regGeom.m_v3dRegionPosition); | ||||
| 			Vector3DInt32 v3dFloor = static_cast<Vector3DInt32>(v3dPos); | ||||
|  | ||||
| 			BlockVolumeIterator<std::uint8_t> volIter(*volumeData); | ||||
| 			BlockVolumeIterator<uint8> volIter(*volumeData); | ||||
|  | ||||
| 			//Check all corners are within the volume, allowing a boundary for gradient estimation | ||||
| 			bool lowerCornerInside = volumeData->containsPoint(v3dFloor,1); | ||||
| @@ -97,7 +97,7 @@ namespace PolyVox | ||||
| 			if(lowerCornerInside && upperCornerInside) //If this test fails the vertex will be left as it was | ||||
| 			{				 | ||||
| 				//volIter.setPosition(static_cast<Vector3DInt16>(v3dFloor)); | ||||
| 				//const uint8_t uFloor = volIter.getVoxel(); | ||||
| 				//const uint8 uFloor = volIter.getVoxel(); | ||||
| 				if(((v3dPos.getX() - v3dFloor.getX()) < 0.001) && ((v3dPos.getY() - v3dFloor.getY()) < 0.001) && ((v3dPos.getZ() - v3dFloor.getZ()) < 0.001)) | ||||
| 				//int x = v3dPos.getX(); | ||||
| 				//if(x % 2 != 0) | ||||
| @@ -105,7 +105,7 @@ namespace PolyVox | ||||
| 				{	 | ||||
| 					//exit(0); | ||||
| 					//volIter.setPosition(static_cast<Vector3DInt16>(v3dFloor+Vector3DInt32(1,0,0))); | ||||
| 					//const uint8_t uCeil = volIter.getVoxel(); | ||||
| 					//const uint8 uCeil = volIter.getVoxel(); | ||||
| 					//if(uFloor == uCeil) //In this case they must both be zero | ||||
| 					{						 | ||||
| 						//if(iterSurfaceVertex->getNormal().getX() > 0) | ||||
| @@ -115,9 +115,9 @@ namespace PolyVox | ||||
| 							v3dFloor = static_cast<Vector3DInt32>(v3dPos); | ||||
|  | ||||
| 							volIter.setPosition(static_cast<Vector3DInt16>(v3dFloor)); | ||||
| 							const uint8_t uFloor = volIter.getVoxel(); | ||||
| 							const uint8 uFloor = volIter.getVoxel(); | ||||
|  | ||||
| 							uint8_t uCeil; | ||||
| 							uint8 uCeil; | ||||
| 							if((iterSurfaceVertex->getNormal().getX() > 0.5f) || (iterSurfaceVertex->getNormal().getX() < -0.5f)) | ||||
| 							{ | ||||
| 								volIter.setPosition(static_cast<Vector3DInt16>(v3dFloor+Vector3DInt32(1,0,0))); | ||||
|   | ||||
| @@ -30,9 +30,9 @@ namespace PolyVox | ||||
| 			regionGeometry.m_patchSingleMaterial = new IndexedSurfacePatch(); | ||||
| 			regionGeometry.m_v3dRegionPosition = iterChangedRegions->getLowerCorner(); | ||||
|  | ||||
| 			generateDecimatedMeshDataForRegion(volume.getVolumeData(), 1, *iterChangedRegions, regionGeometry.m_patchSingleMaterial); | ||||
| 			//generateDecimatedMeshDataForRegion(volume.getVolumeData(), 1, *iterChangedRegions, regionGeometry.m_patchSingleMaterial); | ||||
|  | ||||
| 			//generateReferenceMeshDataForRegion(volume.getVolumeData(), *iterChangedRegions, regionGeometry.m_patchSingleMaterial); | ||||
| 			generateReferenceMeshDataForRegion(volume.getVolumeData(), *iterChangedRegions, regionGeometry.m_patchSingleMaterial); | ||||
| 		 | ||||
| 			//for(int ct = 0; ct < 2; ct++) | ||||
| 			Vector3DInt32 temp = regionGeometry.m_v3dRegionPosition; | ||||
| @@ -61,27 +61,27 @@ namespace PolyVox | ||||
| 		return listChangedRegionGeometry; | ||||
| 	} | ||||
|  | ||||
| 	std::uint32_t getIndex(std::uint32_t x, std::uint32_t y) | ||||
| 	uint32 getIndex(uint32 x, uint32 y) | ||||
| 	{ | ||||
| 		return x + (y * (POLYVOX_REGION_SIDE_LENGTH+1)); | ||||
| 	} | ||||
|  | ||||
| 	void generateRoughMeshDataForRegion(BlockVolume<uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) | ||||
| 	void generateRoughMeshDataForRegion(BlockVolume<uint8>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) | ||||
| 	{	 | ||||
| 		singleMaterialPatch->m_vecVertices.clear(); | ||||
| 		singleMaterialPatch->m_vecTriangleIndices.clear(); | ||||
|  | ||||
| 		//For edge indices | ||||
| 		std::int32_t* vertexIndicesX0 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		std::int32_t* vertexIndicesY0 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		std::int32_t* vertexIndicesZ0 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		std::int32_t* vertexIndicesX1 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		std::int32_t* vertexIndicesY1 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		std::int32_t* vertexIndicesZ1 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		int32* vertexIndicesX0 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		int32* vertexIndicesY0 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		int32* vertexIndicesZ0 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		int32* vertexIndicesX1 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		int32* vertexIndicesY1 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		int32* vertexIndicesZ1 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
|  | ||||
| 		//Cell bitmasks | ||||
| 		std::uint8_t* bitmask0 = new std::uint8_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		std::uint8_t* bitmask1 = new std::uint8_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		uint8* bitmask0 = new uint8[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		uint8* bitmask1 = new uint8[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
|  | ||||
| 		//When generating the mesh for a region we actually look one voxel outside it in the | ||||
| 		// back, bottom, right direction. Protect against access violations by cropping region here | ||||
| @@ -97,22 +97,22 @@ namespace PolyVox | ||||
| 		regSlice0.setUpperCorner(Vector3DInt32(regSlice0.getUpperCorner().getX(),regSlice0.getUpperCorner().getY(),regSlice0.getLowerCorner().getZ())); | ||||
| 		 | ||||
| 		//Iterator to access the volume data | ||||
| 		BlockVolumeIterator<std::uint8_t> volIter(*volumeData);		 | ||||
| 		BlockVolumeIterator<uint8> volIter(*volumeData);		 | ||||
|  | ||||
| 		//Compute bitmask for initial slice | ||||
| 		std::uint32_t uNoOfNonEmptyCellsForSlice0 = computeInitialRoughBitmaskForSlice(volIter, regSlice0, offset, bitmask0);		 | ||||
| 		uint32 uNoOfNonEmptyCellsForSlice0 = computeInitialRoughBitmaskForSlice(volIter, regSlice0, offset, bitmask0);		 | ||||
| 		if(uNoOfNonEmptyCellsForSlice0 != 0) | ||||
| 		{ | ||||
| 			//If there were some non-empty cells then generate initial slice vertices for them | ||||
| 			generateRoughVerticesForSlice(volIter,regSlice0, offset, bitmask0, singleMaterialPatch, vertexIndicesX0, vertexIndicesY0, vertexIndicesZ0); | ||||
| 		} | ||||
|  | ||||
| 		for(std::uint32_t uSlice = 0; ((uSlice <= POLYVOX_REGION_SIDE_LENGTH-1) && (uSlice + offset.getZ() < region.getUpperCorner().getZ())); ++uSlice) | ||||
| 		for(uint32 uSlice = 0; ((uSlice <= POLYVOX_REGION_SIDE_LENGTH-1) && (uSlice + offset.getZ() < region.getUpperCorner().getZ())); ++uSlice) | ||||
| 		{ | ||||
| 			Region regSlice1(regSlice0); | ||||
| 			regSlice1.shift(Vector3DInt32(0,0,1)); | ||||
|  | ||||
| 			std::uint32_t uNoOfNonEmptyCellsForSlice1 = computeRoughBitmaskForSliceFromPrevious(volIter, regSlice1, offset, bitmask1, bitmask0); | ||||
| 			uint32 uNoOfNonEmptyCellsForSlice1 = computeRoughBitmaskForSliceFromPrevious(volIter, regSlice1, offset, bitmask1, bitmask0); | ||||
|  | ||||
| 			if(uNoOfNonEmptyCellsForSlice1 != 0) | ||||
| 			{ | ||||
| @@ -143,9 +143,9 @@ namespace PolyVox | ||||
| 		delete[] vertexIndicesZ1; | ||||
| 	} | ||||
|  | ||||
| 	std::uint32_t computeInitialRoughBitmaskForSlice(BlockVolumeIterator<uint8_t>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask) | ||||
| 	uint32 computeInitialRoughBitmaskForSlice(BlockVolumeIterator<uint8>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask) | ||||
| 	{ | ||||
| 		std::uint32_t uNoOfNonEmptyCells = 0; | ||||
| 		uint32 uNoOfNonEmptyCells = 0; | ||||
|  | ||||
| 		//Iterate over each cell in the region | ||||
| 		volIter.setPosition(regSlice.getLowerCorner().getX(),regSlice.getLowerCorner().getY(), regSlice.getLowerCorner().getZ()); | ||||
| @@ -153,23 +153,23 @@ namespace PolyVox | ||||
| 		do | ||||
| 		{		 | ||||
| 			//Current position | ||||
| 			const uint16_t x = volIter.getPosX() - offset.getX(); | ||||
| 			const uint16_t y = volIter.getPosY() - offset.getY(); | ||||
| 			const uint16 x = volIter.getPosX() - offset.getX(); | ||||
| 			const uint16 y = volIter.getPosY() - offset.getY(); | ||||
|  | ||||
| 			//Determine the index into the edge table which tells us which vertices are inside of the surface | ||||
| 			uint8_t iCubeIndex = 0; | ||||
| 			uint8 iCubeIndex = 0; | ||||
|  | ||||
| 			if((x==0) && (y==0)) | ||||
| 			{ | ||||
| 				const uint8_t v000 = volIter.getVoxel(); | ||||
| 				const uint8_t v100 = volIter.peekVoxel1px0py0pz(); | ||||
| 				const uint8_t v010 = volIter.peekVoxel0px1py0pz(); | ||||
| 				const uint8_t v110 = volIter.peekVoxel1px1py0pz(); | ||||
| 				const uint8 v000 = volIter.getVoxel(); | ||||
| 				const uint8 v100 = volIter.peekVoxel1px0py0pz(); | ||||
| 				const uint8 v010 = volIter.peekVoxel0px1py0pz(); | ||||
| 				const uint8 v110 = volIter.peekVoxel1px1py0pz(); | ||||
|  | ||||
| 				const uint8_t v001 = volIter.peekVoxel0px0py1pz(); | ||||
| 				const uint8_t v101 = volIter.peekVoxel1px0py1pz(); | ||||
| 				const uint8_t v011 = volIter.peekVoxel0px1py1pz(); | ||||
| 				const uint8_t v111 = volIter.peekVoxel1px1py1pz();			 | ||||
| 				const uint8 v001 = volIter.peekVoxel0px0py1pz(); | ||||
| 				const uint8 v101 = volIter.peekVoxel1px0py1pz(); | ||||
| 				const uint8 v011 = volIter.peekVoxel0px1py1pz(); | ||||
| 				const uint8 v111 = volIter.peekVoxel1px1py1pz();			 | ||||
|  | ||||
| 				if (v000 == 0) iCubeIndex |= 1; | ||||
| 				if (v100 == 0) iCubeIndex |= 2; | ||||
| @@ -182,25 +182,25 @@ namespace PolyVox | ||||
| 			} | ||||
| 			else if((x>0) && y==0) | ||||
| 			{ | ||||
| 				const uint8_t v100 = volIter.peekVoxel1px0py0pz(); | ||||
| 				const uint8_t v110 = volIter.peekVoxel1px1py0pz(); | ||||
| 				const uint8 v100 = volIter.peekVoxel1px0py0pz(); | ||||
| 				const uint8 v110 = volIter.peekVoxel1px1py0pz(); | ||||
|  | ||||
| 				const uint8_t v101 = volIter.peekVoxel1px0py1pz(); | ||||
| 				const uint8_t v111 = volIter.peekVoxel1px1py1pz();			 | ||||
| 				const uint8 v101 = volIter.peekVoxel1px0py1pz(); | ||||
| 				const uint8 v111 = volIter.peekVoxel1px1py1pz();			 | ||||
|  | ||||
| 				//x | ||||
| 				uint8_t iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; | ||||
| 				uint8_t srcBit6 = iPreviousCubeIndexX & 64; | ||||
| 				uint8_t destBit7 = srcBit6 << 1; | ||||
| 				uint8 iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; | ||||
| 				uint8 srcBit6 = iPreviousCubeIndexX & 64; | ||||
| 				uint8 destBit7 = srcBit6 << 1; | ||||
| 				 | ||||
| 				uint8_t srcBit5 = iPreviousCubeIndexX & 32; | ||||
| 				uint8_t destBit4 = srcBit5 >> 1; | ||||
| 				uint8 srcBit5 = iPreviousCubeIndexX & 32; | ||||
| 				uint8 destBit4 = srcBit5 >> 1; | ||||
|  | ||||
| 				uint8_t srcBit2 = iPreviousCubeIndexX & 4; | ||||
| 				uint8_t destBit3 = srcBit2 << 1; | ||||
| 				uint8 srcBit2 = iPreviousCubeIndexX & 4; | ||||
| 				uint8 destBit3 = srcBit2 << 1; | ||||
| 				 | ||||
| 				uint8_t srcBit1 = iPreviousCubeIndexX & 2; | ||||
| 				uint8_t destBit0 = srcBit1 >> 1; | ||||
| 				uint8 srcBit1 = iPreviousCubeIndexX & 2; | ||||
| 				uint8 destBit0 = srcBit1 >> 1; | ||||
|  | ||||
| 				iCubeIndex |= destBit0; | ||||
| 				if (v100 == 0) iCubeIndex |= 2; | ||||
| @@ -213,25 +213,25 @@ namespace PolyVox | ||||
| 			} | ||||
| 			else if((x==0) && (y>0)) | ||||
| 			{ | ||||
| 				const uint8_t v010 = volIter.peekVoxel0px1py0pz(); | ||||
| 				const uint8_t v110 = volIter.peekVoxel1px1py0pz(); | ||||
| 				const uint8 v010 = volIter.peekVoxel0px1py0pz(); | ||||
| 				const uint8 v110 = volIter.peekVoxel1px1py0pz(); | ||||
|  | ||||
| 				const uint8_t v011 = volIter.peekVoxel0px1py1pz(); | ||||
| 				const uint8_t v111 = volIter.peekVoxel1px1py1pz(); | ||||
| 				const uint8 v011 = volIter.peekVoxel0px1py1pz(); | ||||
| 				const uint8 v111 = volIter.peekVoxel1px1py1pz(); | ||||
|  | ||||
| 				//y | ||||
| 				uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; | ||||
| 				uint8_t srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 				uint8_t destBit4 = srcBit7 >> 3; | ||||
| 				uint8 iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; | ||||
| 				uint8 srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 				uint8 destBit4 = srcBit7 >> 3; | ||||
| 				 | ||||
| 				uint8_t srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 				uint8_t destBit5 = srcBit6 >> 1; | ||||
| 				uint8 srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 				uint8 destBit5 = srcBit6 >> 1; | ||||
|  | ||||
| 				uint8_t srcBit3 = iPreviousCubeIndexY & 8; | ||||
| 				uint8_t destBit0 = srcBit3 >> 3; | ||||
| 				uint8 srcBit3 = iPreviousCubeIndexY & 8; | ||||
| 				uint8 destBit0 = srcBit3 >> 3; | ||||
| 				 | ||||
| 				uint8_t srcBit2 = iPreviousCubeIndexY & 4; | ||||
| 				uint8_t destBit1 = srcBit2 >> 1; | ||||
| 				uint8 srcBit2 = iPreviousCubeIndexY & 4; | ||||
| 				uint8 destBit1 = srcBit2 >> 1; | ||||
|  | ||||
| 				iCubeIndex |= destBit0; | ||||
| 				iCubeIndex |= destBit1; | ||||
| @@ -244,31 +244,31 @@ namespace PolyVox | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				const uint8_t v110 = volIter.peekVoxel1px1py0pz(); | ||||
| 				const uint8 v110 = volIter.peekVoxel1px1py0pz(); | ||||
|  | ||||
| 				const uint8_t v111 = volIter.peekVoxel1px1py1pz(); | ||||
| 				const uint8 v111 = volIter.peekVoxel1px1py1pz(); | ||||
|  | ||||
| 				//y | ||||
| 				uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; | ||||
| 				uint8_t srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 				uint8_t destBit4 = srcBit7 >> 3; | ||||
| 				uint8 iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; | ||||
| 				uint8 srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 				uint8 destBit4 = srcBit7 >> 3; | ||||
| 				 | ||||
| 				uint8_t srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 				uint8_t destBit5 = srcBit6 >> 1; | ||||
| 				uint8 srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 				uint8 destBit5 = srcBit6 >> 1; | ||||
|  | ||||
| 				uint8_t srcBit3 = iPreviousCubeIndexY & 8; | ||||
| 				uint8_t destBit0 = srcBit3 >> 3; | ||||
| 				uint8 srcBit3 = iPreviousCubeIndexY & 8; | ||||
| 				uint8 destBit0 = srcBit3 >> 3; | ||||
| 				 | ||||
| 				uint8_t srcBit2 = iPreviousCubeIndexY & 4; | ||||
| 				uint8_t destBit1 = srcBit2 >> 1; | ||||
| 				uint8 srcBit2 = iPreviousCubeIndexY & 4; | ||||
| 				uint8 destBit1 = srcBit2 >> 1; | ||||
|  | ||||
| 				//x | ||||
| 				uint8_t iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; | ||||
| 				uint8 iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; | ||||
| 				srcBit6 = iPreviousCubeIndexX & 64; | ||||
| 				uint8_t destBit7 = srcBit6 << 1; | ||||
| 				uint8 destBit7 = srcBit6 << 1; | ||||
|  | ||||
| 				srcBit2 = iPreviousCubeIndexX & 4; | ||||
| 				uint8_t destBit3 = srcBit2 << 1; | ||||
| 				uint8 destBit3 = srcBit2 << 1; | ||||
|  | ||||
| 				iCubeIndex |= destBit0; | ||||
| 				iCubeIndex |= destBit1; | ||||
| @@ -293,9 +293,9 @@ namespace PolyVox | ||||
| 		return uNoOfNonEmptyCells; | ||||
| 	} | ||||
|  | ||||
| 	std::uint32_t computeRoughBitmaskForSliceFromPrevious(BlockVolumeIterator<uint8_t>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, uint8_t* previousBitmask) | ||||
| 	uint32 computeRoughBitmaskForSliceFromPrevious(BlockVolumeIterator<uint8>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, uint8* previousBitmask) | ||||
| 	{ | ||||
| 		std::uint32_t uNoOfNonEmptyCells = 0; | ||||
| 		uint32 uNoOfNonEmptyCells = 0; | ||||
|  | ||||
| 		//Iterate over each cell in the region | ||||
| 		volIter.setPosition(regSlice.getLowerCorner().getX(),regSlice.getLowerCorner().getY(), regSlice.getLowerCorner().getZ()); | ||||
| @@ -303,21 +303,21 @@ namespace PolyVox | ||||
| 		do | ||||
| 		{		 | ||||
| 			//Current position | ||||
| 			const uint16_t x = volIter.getPosX() - offset.getX(); | ||||
| 			const uint16_t y = volIter.getPosY() - offset.getY(); | ||||
| 			const uint16 x = volIter.getPosX() - offset.getX(); | ||||
| 			const uint16 y = volIter.getPosY() - offset.getY(); | ||||
|  | ||||
| 			//Determine the index into the edge table which tells us which vertices are inside of the surface | ||||
| 			uint8_t iCubeIndex = 0; | ||||
| 			uint8 iCubeIndex = 0; | ||||
|  | ||||
| 			if((x==0) && (y==0)) | ||||
| 			{ | ||||
| 				const uint8_t v001 = volIter.peekVoxel0px0py1pz(); | ||||
| 				const uint8_t v101 = volIter.peekVoxel1px0py1pz(); | ||||
| 				const uint8_t v011 = volIter.peekVoxel0px1py1pz(); | ||||
| 				const uint8_t v111 = volIter.peekVoxel1px1py1pz();			 | ||||
| 				const uint8 v001 = volIter.peekVoxel0px0py1pz(); | ||||
| 				const uint8 v101 = volIter.peekVoxel1px0py1pz(); | ||||
| 				const uint8 v011 = volIter.peekVoxel0px1py1pz(); | ||||
| 				const uint8 v111 = volIter.peekVoxel1px1py1pz();			 | ||||
|  | ||||
| 				//z | ||||
| 				uint8_t iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; | ||||
| 				uint8 iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; | ||||
| 				iCubeIndex = iPreviousCubeIndexZ >> 4; | ||||
|  | ||||
| 				if (v001 == 0) iCubeIndex |= 16; | ||||
| @@ -327,20 +327,20 @@ namespace PolyVox | ||||
| 			} | ||||
| 			else if((x>0) && y==0) | ||||
| 			{ | ||||
| 				const uint8_t v101 = volIter.peekVoxel1px0py1pz(); | ||||
| 				const uint8_t v111 = volIter.peekVoxel1px1py1pz();			 | ||||
| 				const uint8 v101 = volIter.peekVoxel1px0py1pz(); | ||||
| 				const uint8 v111 = volIter.peekVoxel1px1py1pz();			 | ||||
|  | ||||
| 				//z | ||||
| 				uint8_t iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; | ||||
| 				uint8 iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; | ||||
| 				iCubeIndex = iPreviousCubeIndexZ >> 4; | ||||
|  | ||||
| 				//x | ||||
| 				uint8_t iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; | ||||
| 				uint8_t srcBit6 = iPreviousCubeIndexX & 64; | ||||
| 				uint8_t destBit7 = srcBit6 << 1; | ||||
| 				uint8 iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; | ||||
| 				uint8 srcBit6 = iPreviousCubeIndexX & 64; | ||||
| 				uint8 destBit7 = srcBit6 << 1; | ||||
| 				 | ||||
| 				uint8_t srcBit5 = iPreviousCubeIndexX & 32; | ||||
| 				uint8_t destBit4 = srcBit5 >> 1; | ||||
| 				uint8 srcBit5 = iPreviousCubeIndexX & 32; | ||||
| 				uint8 destBit4 = srcBit5 >> 1; | ||||
|  | ||||
| 				iCubeIndex |= destBit4; | ||||
| 				if (v101 == 0) iCubeIndex |= 32; | ||||
| @@ -349,20 +349,20 @@ namespace PolyVox | ||||
| 			} | ||||
| 			else if((x==0) && (y>0)) | ||||
| 			{ | ||||
| 				const uint8_t v011 = volIter.peekVoxel0px1py1pz(); | ||||
| 				const uint8_t v111 = volIter.peekVoxel1px1py1pz(); | ||||
| 				const uint8 v011 = volIter.peekVoxel0px1py1pz(); | ||||
| 				const uint8 v111 = volIter.peekVoxel1px1py1pz(); | ||||
|  | ||||
| 				//z | ||||
| 				uint8_t iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; | ||||
| 				uint8 iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; | ||||
| 				iCubeIndex = iPreviousCubeIndexZ >> 4; | ||||
|  | ||||
| 				//y | ||||
| 				uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; | ||||
| 				uint8_t srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 				uint8_t destBit4 = srcBit7 >> 3; | ||||
| 				uint8 iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; | ||||
| 				uint8 srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 				uint8 destBit4 = srcBit7 >> 3; | ||||
| 				 | ||||
| 				uint8_t srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 				uint8_t destBit5 = srcBit6 >> 1; | ||||
| 				uint8 srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 				uint8 destBit5 = srcBit6 >> 1; | ||||
|  | ||||
| 				iCubeIndex |= destBit4; | ||||
| 				iCubeIndex |= destBit5; | ||||
| @@ -371,24 +371,24 @@ namespace PolyVox | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				const uint8_t v111 = volIter.peekVoxel1px1py1pz();			 | ||||
| 				const uint8 v111 = volIter.peekVoxel1px1py1pz();			 | ||||
|  | ||||
| 				//z | ||||
| 				uint8_t iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; | ||||
| 				uint8 iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; | ||||
| 				iCubeIndex = iPreviousCubeIndexZ >> 4; | ||||
|  | ||||
| 				//y | ||||
| 				uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; | ||||
| 				uint8_t srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 				uint8_t destBit4 = srcBit7 >> 3; | ||||
| 				uint8 iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; | ||||
| 				uint8 srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 				uint8 destBit4 = srcBit7 >> 3; | ||||
| 				 | ||||
| 				uint8_t srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 				uint8_t destBit5 = srcBit6 >> 1; | ||||
| 				uint8 srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 				uint8 destBit5 = srcBit6 >> 1; | ||||
|  | ||||
| 				//x | ||||
| 				uint8_t iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; | ||||
| 				uint8 iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; | ||||
| 				srcBit6 = iPreviousCubeIndexX & 64; | ||||
| 				uint8_t destBit7 = srcBit6 << 1; | ||||
| 				uint8 destBit7 = srcBit6 << 1; | ||||
|  | ||||
| 				iCubeIndex |= destBit4; | ||||
| 				iCubeIndex |= destBit5; | ||||
| @@ -409,7 +409,7 @@ namespace PolyVox | ||||
| 		return uNoOfNonEmptyCells; | ||||
| 	} | ||||
|  | ||||
| 	void generateRoughVerticesForSlice(BlockVolumeIterator<uint8_t>& volIter, Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,std::int32_t vertexIndicesX[],std::int32_t vertexIndicesY[],std::int32_t vertexIndicesZ[]) | ||||
| 	void generateRoughVerticesForSlice(BlockVolumeIterator<uint8>& volIter, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]) | ||||
| 	{ | ||||
| 		//Iterate over each cell in the region | ||||
| 		volIter.setPosition(regSlice.getLowerCorner().getX(),regSlice.getLowerCorner().getY(), regSlice.getLowerCorner().getZ()); | ||||
| @@ -418,14 +418,14 @@ namespace PolyVox | ||||
| 		do | ||||
| 		{		 | ||||
| 			//Current position | ||||
| 			const uint16_t x = volIter.getPosX() - offset.getX(); | ||||
| 			const uint16_t y = volIter.getPosY() - offset.getY(); | ||||
| 			const uint16_t z = volIter.getPosZ() - offset.getZ(); | ||||
| 			const uint16 x = volIter.getPosX() - offset.getX(); | ||||
| 			const uint16 y = volIter.getPosY() - offset.getY(); | ||||
| 			const uint16 z = volIter.getPosZ() - offset.getZ(); | ||||
|  | ||||
| 			const uint8_t v000 = volIter.getVoxel(); | ||||
| 			const uint8 v000 = volIter.getVoxel(); | ||||
|  | ||||
| 			//Determine the index into the edge table which tells us which vertices are inside of the surface | ||||
| 			uint8_t iCubeIndex = bitmask[getIndex(x,y)]; | ||||
| 			uint8 iCubeIndex = bitmask[getIndex(x,y)]; | ||||
|  | ||||
| 			/* Cube is entirely in/out of the surface */ | ||||
| 			if (edgeTable[iCubeIndex] == 0) | ||||
| @@ -438,10 +438,10 @@ namespace PolyVox | ||||
| 			{ | ||||
| 				if((x + offset.getX()) != regSlice.getUpperCorner().getX()) | ||||
| 				{ | ||||
| 					const uint8_t v100 = volIter.peekVoxel1px0py0pz(); | ||||
| 					const uint8 v100 = volIter.peekVoxel1px0py0pz(); | ||||
| 					const Vector3DFloat v3dPosition(x + 0.5f, y, z); | ||||
| 					const Vector3DFloat v3dNormal(v000 > v100 ? 1.0f : -1.0f, 0.0f, 0.0f);					 | ||||
| 					const uint8_t uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max. | ||||
| 					const uint8 uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max. | ||||
| 					const SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); | ||||
| 					singleMaterialPatch->m_vecVertices.push_back(surfaceVertex); | ||||
| 					vertexIndicesX[getIndex(x,y)] = singleMaterialPatch->m_vecVertices.size()-1; | ||||
| @@ -451,10 +451,10 @@ namespace PolyVox | ||||
| 			{ | ||||
| 				if((y + offset.getY()) != regSlice.getUpperCorner().getY()) | ||||
| 				{ | ||||
| 					const uint8_t v010 = volIter.peekVoxel0px1py0pz(); | ||||
| 					const uint8 v010 = volIter.peekVoxel0px1py0pz(); | ||||
| 					const Vector3DFloat v3dPosition(x, y + 0.5f, z); | ||||
| 					const Vector3DFloat v3dNormal(0.0f, v000 > v010 ? 1.0f : -1.0f, 0.0f); | ||||
| 					const uint8_t uMaterial = v000 | v010; | ||||
| 					const uint8 uMaterial = v000 | v010; | ||||
| 					SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); | ||||
| 					singleMaterialPatch->m_vecVertices.push_back(surfaceVertex); | ||||
| 					vertexIndicesY[getIndex(x,y)] = singleMaterialPatch->m_vecVertices.size()-1; | ||||
| @@ -464,10 +464,10 @@ namespace PolyVox | ||||
| 			{ | ||||
| 				//if((z + offset.getZ()) != upperCorner.getZ()) | ||||
| 				{ | ||||
| 					const uint8_t v001 = volIter.peekVoxel0px0py1pz(); | ||||
| 					const uint8 v001 = volIter.peekVoxel0px0py1pz(); | ||||
| 					const Vector3DFloat v3dPosition(x, y, z + 0.5f); | ||||
| 					const Vector3DFloat v3dNormal(0.0f, 0.0f, v000 > v001 ? 1.0f : -1.0f); | ||||
| 					const uint8_t uMaterial = v000 | v001; | ||||
| 					const uint8 uMaterial = v000 | v001; | ||||
| 					SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); | ||||
| 					singleMaterialPatch->m_vecVertices.push_back(surfaceVertex); | ||||
| 					vertexIndicesZ[getIndex(x,y)] = singleMaterialPatch->m_vecVertices.size()-1; | ||||
| @@ -476,9 +476,9 @@ namespace PolyVox | ||||
| 		}while(volIter.moveForwardInRegionXYZ());//For each cell | ||||
| 	} | ||||
|  | ||||
| 	void generateRoughIndicesForSlice(BlockVolumeIterator<uint8_t>& volIter, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8_t* bitmask0, uint8_t* bitmask1, std::int32_t vertexIndicesX0[],std::int32_t vertexIndicesY0[],std::int32_t vertexIndicesZ0[], std::int32_t vertexIndicesX1[],std::int32_t vertexIndicesY1[],std::int32_t vertexIndicesZ1[]) | ||||
| 	void generateRoughIndicesForSlice(BlockVolumeIterator<uint8>& volIter, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8* bitmask0, uint8* bitmask1, int32 vertexIndicesX0[],int32 vertexIndicesY0[],int32 vertexIndicesZ0[], int32 vertexIndicesX1[],int32 vertexIndicesY1[],int32 vertexIndicesZ1[]) | ||||
| 	{ | ||||
| 		std::uint32_t indlist[12]; | ||||
| 		uint32 indlist[12]; | ||||
|  | ||||
| 		Region regCroppedSlice(regSlice);		 | ||||
| 		regCroppedSlice.setUpperCorner(regCroppedSlice.getUpperCorner() - Vector3DInt32(1,1,0)); | ||||
| @@ -488,12 +488,12 @@ namespace PolyVox | ||||
| 		do | ||||
| 		{		 | ||||
| 			//Current position | ||||
| 			const uint16_t x = volIter.getPosX() - offset.getX(); | ||||
| 			const uint16_t y = volIter.getPosY() - offset.getY(); | ||||
| 			const uint16_t z = volIter.getPosZ() - offset.getZ(); | ||||
| 			const uint16 x = volIter.getPosX() - offset.getX(); | ||||
| 			const uint16 y = volIter.getPosY() - offset.getY(); | ||||
| 			const uint16 z = volIter.getPosZ() - offset.getZ(); | ||||
|  | ||||
| 			//Determine the index into the edge table which tells us which vertices are inside of the surface | ||||
| 			uint8_t iCubeIndex = bitmask0[getIndex(x,y)]; | ||||
| 			uint8 iCubeIndex = bitmask0[getIndex(x,y)]; | ||||
|  | ||||
| 			/* Cube is entirely in/out of the surface */ | ||||
| 			if (edgeTable[iCubeIndex] == 0) | ||||
| @@ -565,9 +565,9 @@ namespace PolyVox | ||||
|  | ||||
| 			for (int i=0;triTable[iCubeIndex][i]!=-1;i+=3) | ||||
| 			{ | ||||
| 				std::uint32_t ind0 = indlist[triTable[iCubeIndex][i  ]]; | ||||
| 				std::uint32_t ind1 = indlist[triTable[iCubeIndex][i+1]]; | ||||
| 				std::uint32_t ind2 = indlist[triTable[iCubeIndex][i+2]]; | ||||
| 				uint32 ind0 = indlist[triTable[iCubeIndex][i  ]]; | ||||
| 				uint32 ind1 = indlist[triTable[iCubeIndex][i+1]]; | ||||
| 				uint32 ind2 = indlist[triTable[iCubeIndex][i+2]]; | ||||
|  | ||||
| 				singleMaterialPatch->m_vecTriangleIndices.push_back(ind0); | ||||
| 				singleMaterialPatch->m_vecTriangleIndices.push_back(ind1); | ||||
| @@ -576,11 +576,11 @@ namespace PolyVox | ||||
| 		}while(volIter.moveForwardInRegionXYZ());//For each cell | ||||
| 	} | ||||
|  | ||||
| 	void generateReferenceMeshDataForRegion(BlockVolume<uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) | ||||
| 	void generateReferenceMeshDataForRegion(BlockVolume<uint8>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) | ||||
| 	{	 | ||||
| 		static std::int32_t vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; | ||||
| 		static std::int32_t vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; | ||||
| 		static std::int32_t vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; | ||||
| 		static int32 vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; | ||||
| 		static int32 vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; | ||||
| 		static int32 vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; | ||||
|  | ||||
| 		memset(vertexIndicesX,0xFF,sizeof(vertexIndicesX)); //0xFF is -1 as two's complement - this may not be portable... | ||||
| 		memset(vertexIndicesY,0xFF,sizeof(vertexIndicesY)); | ||||
| @@ -598,8 +598,8 @@ namespace PolyVox | ||||
|  | ||||
| 		Vector3DFloat vertlist[12]; | ||||
| 		Vector3DFloat normlist[12]; | ||||
| 		uint8_t vertMaterials[12]; | ||||
| 		BlockVolumeIterator<std::uint8_t> volIter(*volumeData); | ||||
| 		uint8 vertMaterials[12]; | ||||
| 		BlockVolumeIterator<uint8> volIter(*volumeData); | ||||
| 		volIter.setValidRegion(region); | ||||
|  | ||||
| 		////////////////////////////////////////////////////////////////////////// | ||||
| @@ -611,22 +611,22 @@ namespace PolyVox | ||||
| 		while(volIter.moveForwardInRegionXYZ()) | ||||
| 		{		 | ||||
| 			//Current position | ||||
| 			const uint16_t x = volIter.getPosX(); | ||||
| 			const uint16_t y = volIter.getPosY(); | ||||
| 			const uint16_t z = volIter.getPosZ(); | ||||
| 			const uint16 x = volIter.getPosX(); | ||||
| 			const uint16 y = volIter.getPosY(); | ||||
| 			const uint16 z = volIter.getPosZ(); | ||||
|  | ||||
| 			//Voxels values | ||||
| 			const uint8_t v000 = volIter.getVoxel(); | ||||
| 			const uint8_t v100 = volIter.peekVoxel1px0py0pz(); | ||||
| 			const uint8_t v010 = volIter.peekVoxel0px1py0pz(); | ||||
| 			const uint8_t v110 = volIter.peekVoxel1px1py0pz(); | ||||
| 			const uint8_t v001 = volIter.peekVoxel0px0py1pz(); | ||||
| 			const uint8_t v101 = volIter.peekVoxel1px0py1pz(); | ||||
| 			const uint8_t v011 = volIter.peekVoxel0px1py1pz(); | ||||
| 			const uint8_t v111 = volIter.peekVoxel1px1py1pz(); | ||||
| 			const uint8 v000 = volIter.getVoxel(); | ||||
| 			const uint8 v100 = volIter.peekVoxel1px0py0pz(); | ||||
| 			const uint8 v010 = volIter.peekVoxel0px1py0pz(); | ||||
| 			const uint8 v110 = volIter.peekVoxel1px1py0pz(); | ||||
| 			const uint8 v001 = volIter.peekVoxel0px0py1pz(); | ||||
| 			const uint8 v101 = volIter.peekVoxel1px0py1pz(); | ||||
| 			const uint8 v011 = volIter.peekVoxel0px1py1pz(); | ||||
| 			const uint8 v111 = volIter.peekVoxel1px1py1pz(); | ||||
|  | ||||
| 			//Determine the index into the edge table which tells us which vertices are inside of the surface | ||||
| 			uint8_t iCubeIndex = 0; | ||||
| 			uint8 iCubeIndex = 0; | ||||
|  | ||||
| 			if (v000 == 0) iCubeIndex |= 1; | ||||
| 			if (v100 == 0) iCubeIndex |= 2; | ||||
| @@ -781,9 +781,9 @@ namespace PolyVox | ||||
| 				//const Vector3DFloat vertex1AsFloat = (static_cast<Vector3DFloat>(vertex1) / 2.0f) - offset; | ||||
| 				//const Vector3DFloat vertex2AsFloat = (static_cast<Vector3DFloat>(vertex2) / 2.0f) - offset; | ||||
|  | ||||
| 				const uint8_t material0 = vertMaterials[triTable[iCubeIndex][i  ]]; | ||||
| 				const uint8_t material1 = vertMaterials[triTable[iCubeIndex][i+1]]; | ||||
| 				const uint8_t material2 = vertMaterials[triTable[iCubeIndex][i+2]]; | ||||
| 				const uint8 material0 = vertMaterials[triTable[iCubeIndex][i  ]]; | ||||
| 				const uint8 material1 = vertMaterials[triTable[iCubeIndex][i+1]]; | ||||
| 				const uint8 material2 = vertMaterials[triTable[iCubeIndex][i+2]]; | ||||
|  | ||||
| 				//If all the materials are the same, we just need one triangle for that material with all the alphas set high. | ||||
| 				SurfaceVertex v0(vertex0, normal0, material0 + 0.1f); | ||||
| @@ -792,7 +792,7 @@ namespace PolyVox | ||||
|  | ||||
| 				//singleMaterialPatch->addTriangle(surfaceVertex0Alpha1, surfaceVertex1Alpha1, surfaceVertex2Alpha1); | ||||
|  | ||||
| 				int32_t index = getIndexFor(v0.getPosition(), vertexIndicesX, vertexIndicesY, vertexIndicesZ); | ||||
| 				int32 index = getIndexFor(v0.getPosition(), vertexIndicesX, vertexIndicesY, vertexIndicesZ); | ||||
| 				if(index == -1) | ||||
| 				{ | ||||
| 					singleMaterialPatch->m_vecVertices.push_back(v0); | ||||
| @@ -831,7 +831,7 @@ namespace PolyVox | ||||
| 		}//For each cell | ||||
| 	} | ||||
|  | ||||
| 	std::int32_t getIndexFor(const Vector3DFloat& pos, std::int32_t vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], std::int32_t vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], std::int32_t vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]) | ||||
| 	int32 getIndexFor(const Vector3DFloat& pos, int32 vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], int32 vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], int32 vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]) | ||||
| 	{ | ||||
| 		assert(pos.getX() >= 0.0f); | ||||
| 		assert(pos.getY() >= 0.0f); | ||||
| @@ -850,20 +850,20 @@ namespace PolyVox | ||||
| 		//Of all the fractional parts, two should be zero and one should have a value. | ||||
| 		if(xFracPart > 0.000001f) | ||||
| 		{ | ||||
| 			return vertexIndicesX[static_cast<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)]; | ||||
| 			return vertexIndicesX[static_cast<uint16>(xIntPart)][static_cast<uint16>(yIntPart)][static_cast<uint16>(zIntPart)]; | ||||
| 		} | ||||
| 		if(yFracPart > 0.000001f) | ||||
| 		{ | ||||
| 			return vertexIndicesY[static_cast<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)]; | ||||
| 			return vertexIndicesY[static_cast<uint16>(xIntPart)][static_cast<uint16>(yIntPart)][static_cast<uint16>(zIntPart)]; | ||||
| 		} | ||||
| 		if(zFracPart > 0.000001f) | ||||
| 		{ | ||||
| 			return vertexIndicesZ[static_cast<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)]; | ||||
| 			return vertexIndicesZ[static_cast<uint16>(xIntPart)][static_cast<uint16>(yIntPart)][static_cast<uint16>(zIntPart)]; | ||||
| 		} | ||||
| 		while(true); | ||||
| 	} | ||||
|  | ||||
| 	void setIndexFor(const Vector3DFloat& pos, std::int32_t newIndex, std::int32_t vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], std::int32_t vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], std::int32_t vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]) | ||||
| 	void setIndexFor(const Vector3DFloat& pos, int32 newIndex, int32 vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], int32 vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], int32 vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]) | ||||
| 	{ | ||||
| 		assert(pos.getX() >= 0.0f); | ||||
| 		assert(pos.getY() >= 0.0f); | ||||
| @@ -884,15 +884,15 @@ namespace PolyVox | ||||
| 		//Of all the fractional parts, two should be zero and one should have a value. | ||||
| 		if(xFracPart > 0.000001f) | ||||
| 		{ | ||||
| 			vertexIndicesX[static_cast<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)] = newIndex; | ||||
| 			vertexIndicesX[static_cast<uint16>(xIntPart)][static_cast<uint16>(yIntPart)][static_cast<uint16>(zIntPart)] = newIndex; | ||||
| 		} | ||||
| 		if(yFracPart > 0.000001f) | ||||
| 		{ | ||||
| 			vertexIndicesY[static_cast<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)] = newIndex; | ||||
| 			vertexIndicesY[static_cast<uint16>(xIntPart)][static_cast<uint16>(yIntPart)][static_cast<uint16>(zIntPart)] = newIndex; | ||||
| 		} | ||||
| 		if(zFracPart > 0.000001f) | ||||
| 		{ | ||||
| 			vertexIndicesZ[static_cast<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)] = newIndex; | ||||
| 			vertexIndicesZ[static_cast<uint16>(xIntPart)][static_cast<uint16>(yIntPart)][static_cast<uint16>(zIntPart)] = newIndex; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -15,29 +15,29 @@ using namespace std; | ||||
|  | ||||
| namespace PolyVox | ||||
| { | ||||
| 	std::uint32_t getDecimatedIndex(std::uint32_t x, std::uint32_t y) | ||||
| 	uint32 getDecimatedIndex(uint32 x, uint32 y) | ||||
| 	{ | ||||
| 		return x + (y * (POLYVOX_REGION_SIDE_LENGTH+1)); | ||||
| 	} | ||||
|  | ||||
| 	void generateDecimatedMeshDataForRegion(BlockVolume<uint8_t>* volumeData, uint8_t uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch) | ||||
| 	void generateDecimatedMeshDataForRegion(BlockVolume<uint8>* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch) | ||||
| 	{	 | ||||
| 		singleMaterialPatch->m_vecVertices.clear(); | ||||
| 		singleMaterialPatch->m_vecTriangleIndices.clear(); | ||||
|  | ||||
| 		//For edge indices | ||||
| 		std::int32_t* vertexIndicesX0 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		std::int32_t* vertexIndicesY0 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		std::int32_t* vertexIndicesZ0 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		std::int32_t* vertexIndicesX1 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		std::int32_t* vertexIndicesY1 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		std::int32_t* vertexIndicesZ1 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		int32* vertexIndicesX0 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		int32* vertexIndicesY0 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		int32* vertexIndicesZ0 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		int32* vertexIndicesX1 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		int32* vertexIndicesY1 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		int32* vertexIndicesZ1 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
|  | ||||
| 		//Cell bitmasks | ||||
| 		std::uint8_t* bitmask0 = new std::uint8_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		std::uint8_t* bitmask1 = new std::uint8_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		uint8* bitmask0 = new uint8[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
| 		uint8* bitmask1 = new uint8[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; | ||||
|  | ||||
| 		const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; | ||||
| 		const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; | ||||
|  | ||||
| 		//When generating the mesh for a region we actually look outside it in the | ||||
| 		// back, bottom, right direction. Protect against access violations by cropping region here | ||||
| @@ -55,22 +55,22 @@ namespace PolyVox | ||||
| 		regSlice0.setUpperCorner(v3dUpperCorner); | ||||
| 		 | ||||
| 		//Iterator to access the volume data | ||||
| 		BlockVolumeIterator<std::uint8_t> volIter(*volumeData);		 | ||||
| 		BlockVolumeIterator<uint8> volIter(*volumeData);		 | ||||
|  | ||||
| 		//Compute bitmask for initial slice | ||||
| 		std::uint32_t uNoOfNonEmptyCellsForSlice0 = computeInitialDecimatedBitmaskForSlice(volIter, uLevel, regSlice0, offset, bitmask0);		 | ||||
| 		uint32 uNoOfNonEmptyCellsForSlice0 = computeInitialDecimatedBitmaskForSlice(volIter, uLevel, regSlice0, offset, bitmask0);		 | ||||
| 		if(uNoOfNonEmptyCellsForSlice0 != 0) | ||||
| 		{ | ||||
| 			//If there were some non-empty cells then generate initial slice vertices for them | ||||
| 			generateDecimatedVerticesForSlice(volIter, uLevel, regSlice0, offset, bitmask0, singleMaterialPatch, vertexIndicesX0, vertexIndicesY0, vertexIndicesZ0); | ||||
| 		} | ||||
|  | ||||
| 		for(std::uint32_t uSlice = 1; ((uSlice <= POLYVOX_REGION_SIDE_LENGTH) && (uSlice + offset.getZ() <= regVolume.getUpperCorner().getZ())); uSlice += uStepSize) | ||||
| 		for(uint32 uSlice = 1; ((uSlice <= POLYVOX_REGION_SIDE_LENGTH) && (uSlice + offset.getZ() <= regVolume.getUpperCorner().getZ())); uSlice += uStepSize) | ||||
| 		{ | ||||
| 			Region regSlice1(regSlice0); | ||||
| 			regSlice1.shift(Vector3DInt32(0,0,uStepSize)); | ||||
|  | ||||
| 			std::uint32_t uNoOfNonEmptyCellsForSlice1 = computeDecimatedBitmaskForSliceFromPrevious(volIter, uLevel, regSlice1, offset, bitmask1, bitmask0); | ||||
| 			uint32 uNoOfNonEmptyCellsForSlice1 = computeDecimatedBitmaskForSliceFromPrevious(volIter, uLevel, regSlice1, offset, bitmask1, bitmask0); | ||||
|  | ||||
| 			if(uNoOfNonEmptyCellsForSlice1 != 0) | ||||
| 			{ | ||||
| @@ -110,41 +110,41 @@ namespace PolyVox | ||||
| 		}*/ | ||||
| 	} | ||||
|  | ||||
| 	std::uint32_t computeInitialDecimatedBitmaskForSlice(BlockVolumeIterator<uint8_t>& volIter, uint8_t uLevel,  const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask) | ||||
| 	uint32 computeInitialDecimatedBitmaskForSlice(BlockVolumeIterator<uint8>& volIter, uint8 uLevel,  const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask) | ||||
| 	{ | ||||
| 		const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; | ||||
| 		std::uint32_t uNoOfNonEmptyCells = 0; | ||||
| 		const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; | ||||
| 		uint32 uNoOfNonEmptyCells = 0; | ||||
|  | ||||
| 		//Iterate over each cell in the region | ||||
| 		for(uint16_t y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) | ||||
| 		for(uint16 y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) | ||||
| 		{ | ||||
| 			for(uint16_t x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) | ||||
| 			for(uint16 x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) | ||||
| 			{		 | ||||
| 				//Current position | ||||
| 				volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()); | ||||
|  | ||||
| 				//Determine the index into the edge table which tells us which vertices are inside of the surface | ||||
| 				uint8_t iCubeIndex = 0; | ||||
| 				uint8 iCubeIndex = 0; | ||||
|  | ||||
| 				if((x==regSlice.getLowerCorner().getX()) && (y==regSlice.getLowerCorner().getY())) | ||||
| 				{ | ||||
| 					volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()); | ||||
| 					const uint8_t v000 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v000 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()); | ||||
| 					const uint8_t v100 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v100 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()); | ||||
| 					const uint8_t v010 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v010 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()); | ||||
| 					const uint8_t v110 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v110 = volIter.getSubSampledVoxel(uLevel); | ||||
|  | ||||
| 					volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v001 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v001 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v101 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v101 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v011 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v011 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);		 | ||||
| 					const uint8 v111 = volIter.getSubSampledVoxel(uLevel);		 | ||||
|  | ||||
| 					if (v000 == 0) iCubeIndex |= 1; | ||||
| 					if (v100 == 0) iCubeIndex |= 2; | ||||
| @@ -158,28 +158,28 @@ namespace PolyVox | ||||
| 				else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY()) | ||||
| 				{ | ||||
| 					volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()); | ||||
| 					const uint8_t v100 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v100 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()); | ||||
| 					const uint8_t v110 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v110 = volIter.getSubSampledVoxel(uLevel); | ||||
|  | ||||
| 					volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v101 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v101 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v111 = volIter.getSubSampledVoxel(uLevel); | ||||
|  | ||||
| 					//x | ||||
| 					uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; | ||||
| 					uint8_t srcBit6 = iPreviousCubeIndexX & 64; | ||||
| 					uint8_t destBit7 = srcBit6 << 1; | ||||
| 					uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; | ||||
| 					uint8 srcBit6 = iPreviousCubeIndexX & 64; | ||||
| 					uint8 destBit7 = srcBit6 << 1; | ||||
| 					 | ||||
| 					uint8_t srcBit5 = iPreviousCubeIndexX & 32; | ||||
| 					uint8_t destBit4 = srcBit5 >> 1; | ||||
| 					uint8 srcBit5 = iPreviousCubeIndexX & 32; | ||||
| 					uint8 destBit4 = srcBit5 >> 1; | ||||
|  | ||||
| 					uint8_t srcBit2 = iPreviousCubeIndexX & 4; | ||||
| 					uint8_t destBit3 = srcBit2 << 1; | ||||
| 					uint8 srcBit2 = iPreviousCubeIndexX & 4; | ||||
| 					uint8 destBit3 = srcBit2 << 1; | ||||
| 					 | ||||
| 					uint8_t srcBit1 = iPreviousCubeIndexX & 2; | ||||
| 					uint8_t destBit0 = srcBit1 >> 1; | ||||
| 					uint8 srcBit1 = iPreviousCubeIndexX & 2; | ||||
| 					uint8 destBit0 = srcBit1 >> 1; | ||||
|  | ||||
| 					iCubeIndex |= destBit0; | ||||
| 					if (v100 == 0) iCubeIndex |= 2; | ||||
| @@ -193,28 +193,28 @@ namespace PolyVox | ||||
| 				else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY())) | ||||
| 				{ | ||||
| 					volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()); | ||||
| 					const uint8_t v010 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v010 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()); | ||||
| 					const uint8_t v110 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v110 = volIter.getSubSampledVoxel(uLevel); | ||||
|  | ||||
| 					volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v011 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v011 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v111 = volIter.getSubSampledVoxel(uLevel); | ||||
|  | ||||
| 					//y | ||||
| 					uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; | ||||
| 					uint8_t srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 					uint8_t destBit4 = srcBit7 >> 3; | ||||
| 					uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; | ||||
| 					uint8 srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 					uint8 destBit4 = srcBit7 >> 3; | ||||
| 					 | ||||
| 					uint8_t srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 					uint8_t destBit5 = srcBit6 >> 1; | ||||
| 					uint8 srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 					uint8 destBit5 = srcBit6 >> 1; | ||||
|  | ||||
| 					uint8_t srcBit3 = iPreviousCubeIndexY & 8; | ||||
| 					uint8_t destBit0 = srcBit3 >> 3; | ||||
| 					uint8 srcBit3 = iPreviousCubeIndexY & 8; | ||||
| 					uint8 destBit0 = srcBit3 >> 3; | ||||
| 					 | ||||
| 					uint8_t srcBit2 = iPreviousCubeIndexY & 4; | ||||
| 					uint8_t destBit1 = srcBit2 >> 1; | ||||
| 					uint8 srcBit2 = iPreviousCubeIndexY & 4; | ||||
| 					uint8 destBit1 = srcBit2 >> 1; | ||||
|  | ||||
| 					iCubeIndex |= destBit0; | ||||
| 					iCubeIndex |= destBit1; | ||||
| @@ -228,32 +228,32 @@ namespace PolyVox | ||||
| 				else | ||||
| 				{ | ||||
| 					volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()); | ||||
| 					const uint8_t v110 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v110 = volIter.getSubSampledVoxel(uLevel); | ||||
|  | ||||
| 					volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v111 = volIter.getSubSampledVoxel(uLevel); | ||||
|  | ||||
| 					//y | ||||
| 					uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; | ||||
| 					uint8_t srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 					uint8_t destBit4 = srcBit7 >> 3; | ||||
| 					uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; | ||||
| 					uint8 srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 					uint8 destBit4 = srcBit7 >> 3; | ||||
| 					 | ||||
| 					uint8_t srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 					uint8_t destBit5 = srcBit6 >> 1; | ||||
| 					uint8 srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 					uint8 destBit5 = srcBit6 >> 1; | ||||
|  | ||||
| 					uint8_t srcBit3 = iPreviousCubeIndexY & 8; | ||||
| 					uint8_t destBit0 = srcBit3 >> 3; | ||||
| 					uint8 srcBit3 = iPreviousCubeIndexY & 8; | ||||
| 					uint8 destBit0 = srcBit3 >> 3; | ||||
| 					 | ||||
| 					uint8_t srcBit2 = iPreviousCubeIndexY & 4; | ||||
| 					uint8_t destBit1 = srcBit2 >> 1; | ||||
| 					uint8 srcBit2 = iPreviousCubeIndexY & 4; | ||||
| 					uint8 destBit1 = srcBit2 >> 1; | ||||
|  | ||||
| 					//x | ||||
| 					uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; | ||||
| 					uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; | ||||
| 					srcBit6 = iPreviousCubeIndexX & 64; | ||||
| 					uint8_t destBit7 = srcBit6 << 1; | ||||
| 					uint8 destBit7 = srcBit6 << 1; | ||||
|  | ||||
| 					srcBit2 = iPreviousCubeIndexX & 4; | ||||
| 					uint8_t destBit3 = srcBit2 << 1; | ||||
| 					uint8 destBit3 = srcBit2 << 1; | ||||
|  | ||||
| 					iCubeIndex |= destBit0; | ||||
| 					iCubeIndex |= destBit1; | ||||
| @@ -279,35 +279,35 @@ namespace PolyVox | ||||
| 		return uNoOfNonEmptyCells; | ||||
| 	} | ||||
|  | ||||
| 	std::uint32_t computeDecimatedBitmaskForSliceFromPrevious(BlockVolumeIterator<uint8_t>& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, uint8_t* previousBitmask) | ||||
| 	uint32 computeDecimatedBitmaskForSliceFromPrevious(BlockVolumeIterator<uint8>& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, uint8* previousBitmask) | ||||
| 	{ | ||||
| 		const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; | ||||
| 		std::uint32_t uNoOfNonEmptyCells = 0; | ||||
| 		const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; | ||||
| 		uint32 uNoOfNonEmptyCells = 0; | ||||
|  | ||||
| 		//Iterate over each cell in the region | ||||
| 		for(uint16_t y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) | ||||
| 		for(uint16 y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) | ||||
| 		{ | ||||
| 			for(uint16_t x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) | ||||
| 			for(uint16 x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) | ||||
| 			{	 | ||||
| 				//Current position | ||||
| 				volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()); | ||||
|  | ||||
| 				//Determine the index into the edge table which tells us which vertices are inside of the surface | ||||
| 				uint8_t iCubeIndex = 0; | ||||
| 				uint8 iCubeIndex = 0; | ||||
|  | ||||
| 				if((x==regSlice.getLowerCorner().getX()) && (y==regSlice.getLowerCorner().getY())) | ||||
| 				{ | ||||
| 					volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v001 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v001 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v101 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v101 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v011 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v011 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);	 | ||||
| 					const uint8 v111 = volIter.getSubSampledVoxel(uLevel);	 | ||||
|  | ||||
| 					//z | ||||
| 					uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; | ||||
| 					uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; | ||||
| 					iCubeIndex = iPreviousCubeIndexZ >> 4; | ||||
|  | ||||
| 					if (v001 == 0) iCubeIndex |= 16; | ||||
| @@ -318,21 +318,21 @@ namespace PolyVox | ||||
| 				else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY()) | ||||
| 				{ | ||||
| 					volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v101 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v101 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);	 | ||||
| 					const uint8 v111 = volIter.getSubSampledVoxel(uLevel);	 | ||||
|  | ||||
| 					//z | ||||
| 					uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; | ||||
| 					uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; | ||||
| 					iCubeIndex = iPreviousCubeIndexZ >> 4; | ||||
|  | ||||
| 					//x | ||||
| 					uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; | ||||
| 					uint8_t srcBit6 = iPreviousCubeIndexX & 64; | ||||
| 					uint8_t destBit7 = srcBit6 << 1; | ||||
| 					uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; | ||||
| 					uint8 srcBit6 = iPreviousCubeIndexX & 64; | ||||
| 					uint8 destBit7 = srcBit6 << 1; | ||||
| 					 | ||||
| 					uint8_t srcBit5 = iPreviousCubeIndexX & 32; | ||||
| 					uint8_t destBit4 = srcBit5 >> 1; | ||||
| 					uint8 srcBit5 = iPreviousCubeIndexX & 32; | ||||
| 					uint8 destBit4 = srcBit5 >> 1; | ||||
|  | ||||
| 					iCubeIndex |= destBit4; | ||||
| 					if (v101 == 0) iCubeIndex |= 32; | ||||
| @@ -342,21 +342,21 @@ namespace PolyVox | ||||
| 				else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY())) | ||||
| 				{ | ||||
| 					volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v011 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					const uint8 v011 = volIter.getSubSampledVoxel(uLevel); | ||||
| 					volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);	 | ||||
| 					const uint8 v111 = volIter.getSubSampledVoxel(uLevel);	 | ||||
|  | ||||
| 					//z | ||||
| 					uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; | ||||
| 					uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; | ||||
| 					iCubeIndex = iPreviousCubeIndexZ >> 4; | ||||
|  | ||||
| 					//y | ||||
| 					uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; | ||||
| 					uint8_t srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 					uint8_t destBit4 = srcBit7 >> 3; | ||||
| 					uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; | ||||
| 					uint8 srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 					uint8 destBit4 = srcBit7 >> 3; | ||||
| 					 | ||||
| 					uint8_t srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 					uint8_t destBit5 = srcBit6 >> 1; | ||||
| 					uint8 srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 					uint8 destBit5 = srcBit6 >> 1; | ||||
|  | ||||
| 					iCubeIndex |= destBit4; | ||||
| 					iCubeIndex |= destBit5; | ||||
| @@ -366,24 +366,24 @@ namespace PolyVox | ||||
| 				else | ||||
| 				{ | ||||
| 					volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); | ||||
| 					const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);	 | ||||
| 					const uint8 v111 = volIter.getSubSampledVoxel(uLevel);	 | ||||
|  | ||||
| 					//z | ||||
| 					uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; | ||||
| 					uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; | ||||
| 					iCubeIndex = iPreviousCubeIndexZ >> 4; | ||||
|  | ||||
| 					//y | ||||
| 					uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; | ||||
| 					uint8_t srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 					uint8_t destBit4 = srcBit7 >> 3; | ||||
| 					uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; | ||||
| 					uint8 srcBit7 = iPreviousCubeIndexY & 128; | ||||
| 					uint8 destBit4 = srcBit7 >> 3; | ||||
| 					 | ||||
| 					uint8_t srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 					uint8_t destBit5 = srcBit6 >> 1; | ||||
| 					uint8 srcBit6 = iPreviousCubeIndexY & 64; | ||||
| 					uint8 destBit5 = srcBit6 >> 1; | ||||
|  | ||||
| 					//x | ||||
| 					uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; | ||||
| 					uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; | ||||
| 					srcBit6 = iPreviousCubeIndexX & 64; | ||||
| 					uint8_t destBit7 = srcBit6 << 1; | ||||
| 					uint8 destBit7 = srcBit6 << 1; | ||||
|  | ||||
| 					iCubeIndex |= destBit4; | ||||
| 					iCubeIndex |= destBit5; | ||||
| @@ -405,23 +405,23 @@ namespace PolyVox | ||||
| 		return uNoOfNonEmptyCells; | ||||
| 	} | ||||
|  | ||||
| 	void generateDecimatedVerticesForSlice(BlockVolumeIterator<uint8_t>& volIter, uint8_t uLevel, Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,std::int32_t vertexIndicesX[],std::int32_t vertexIndicesY[],std::int32_t vertexIndicesZ[]) | ||||
| 	void generateDecimatedVerticesForSlice(BlockVolumeIterator<uint8>& volIter, uint8 uLevel, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]) | ||||
| 	{ | ||||
| 		const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; | ||||
| 		const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; | ||||
|  | ||||
| 		//Iterate over each cell in the region | ||||
| 		for(uint16_t y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) | ||||
| 		for(uint16 y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) | ||||
| 		{ | ||||
| 			for(uint16_t x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) | ||||
| 			for(uint16 x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) | ||||
| 			{		 | ||||
| 				//Current position | ||||
| 				const uint16_t z = regSlice.getLowerCorner().getZ(); | ||||
| 				const uint16 z = regSlice.getLowerCorner().getZ(); | ||||
|  | ||||
| 				volIter.setPosition(x,y,z); | ||||
| 				const uint8_t v000 = volIter.getSubSampledVoxel(uLevel); | ||||
| 				const uint8 v000 = volIter.getSubSampledVoxel(uLevel); | ||||
|  | ||||
| 				//Determine the index into the edge table which tells us which vertices are inside of the surface | ||||
| 				uint8_t iCubeIndex = bitmask[getDecimatedIndex(x - offset.getX(),y - offset.getY())]; | ||||
| 				uint8 iCubeIndex = bitmask[getDecimatedIndex(x - offset.getX(),y - offset.getY())]; | ||||
|  | ||||
| 				/* Cube is entirely in/out of the surface */ | ||||
| 				if (edgeTable[iCubeIndex] == 0) | ||||
| @@ -435,10 +435,10 @@ namespace PolyVox | ||||
| 					if(x != regSlice.getUpperCorner().getX()) | ||||
| 					{ | ||||
| 						volIter.setPosition(x + uStepSize,y,z); | ||||
| 						const uint8_t v100 = volIter.getSubSampledVoxel(uLevel); | ||||
| 						const uint8 v100 = volIter.getSubSampledVoxel(uLevel); | ||||
| 						const Vector3DFloat v3dPosition(x - offset.getX() + 0.5f * uStepSize, y - offset.getY(), z - offset.getZ()); | ||||
| 						const Vector3DFloat v3dNormal(v000 > v100 ? 1.0f : -1.0f,0.0,0.0); | ||||
| 						const uint8_t uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max. | ||||
| 						const uint8 uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max. | ||||
| 						SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); | ||||
| 						singleMaterialPatch->m_vecVertices.push_back(surfaceVertex); | ||||
| 						vertexIndicesX[getDecimatedIndex(x - offset.getX(),y - offset.getY())] = singleMaterialPatch->m_vecVertices.size()-1; | ||||
| @@ -449,10 +449,10 @@ namespace PolyVox | ||||
| 					if(y != regSlice.getUpperCorner().getY()) | ||||
| 					{ | ||||
| 						volIter.setPosition(x,y + uStepSize,z); | ||||
| 						const uint8_t v010 = volIter.getSubSampledVoxel(uLevel); | ||||
| 						const uint8 v010 = volIter.getSubSampledVoxel(uLevel); | ||||
| 						const Vector3DFloat v3dPosition(x - offset.getX(), y - offset.getY() + 0.5f * uStepSize, z - offset.getZ()); | ||||
| 						const Vector3DFloat v3dNormal(0.0,v000 > v010 ? 1.0f : -1.0f,0.0); | ||||
| 						const uint8_t uMaterial = v000 | v010; //Because one of these is 0, the or operation takes the max. | ||||
| 						const uint8 uMaterial = v000 | v010; //Because one of these is 0, the or operation takes the max. | ||||
| 						SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); | ||||
| 						singleMaterialPatch->m_vecVertices.push_back(surfaceVertex); | ||||
| 						vertexIndicesY[getDecimatedIndex(x - offset.getX(),y - offset.getY())] = singleMaterialPatch->m_vecVertices.size()-1; | ||||
| @@ -463,10 +463,10 @@ namespace PolyVox | ||||
| 					//if(z != regSlice.getUpperCorner.getZ()) | ||||
| 					{ | ||||
| 						volIter.setPosition(x,y,z + uStepSize); | ||||
| 						const uint8_t v001 = volIter.getSubSampledVoxel(uLevel); | ||||
| 						const uint8 v001 = volIter.getSubSampledVoxel(uLevel); | ||||
| 						const Vector3DFloat v3dPosition(x - offset.getX(), y - offset.getY(), z - offset.getZ() + 0.5f * uStepSize); | ||||
| 						const Vector3DFloat v3dNormal(0.0,0.0,v000 > v001 ? 1.0f : -1.0f); | ||||
| 						const uint8_t uMaterial = v000 | v001; //Because one of these is 0, the or operation takes the max. | ||||
| 						const uint8 uMaterial = v000 | v001; //Because one of these is 0, the or operation takes the max. | ||||
| 						const SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); | ||||
| 						singleMaterialPatch->m_vecVertices.push_back(surfaceVertex); | ||||
| 						vertexIndicesZ[getDecimatedIndex(x - offset.getX(),y - offset.getY())] = singleMaterialPatch->m_vecVertices.size()-1; | ||||
| @@ -476,20 +476,20 @@ namespace PolyVox | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	void generateDecimatedIndicesForSlice(BlockVolumeIterator<uint8_t>& volIter, uint8_t uLevel, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8_t* bitmask0, uint8_t* bitmask1, std::int32_t vertexIndicesX0[],std::int32_t vertexIndicesY0[],std::int32_t vertexIndicesZ0[], std::int32_t vertexIndicesX1[],std::int32_t vertexIndicesY1[],std::int32_t vertexIndicesZ1[]) | ||||
| 	void generateDecimatedIndicesForSlice(BlockVolumeIterator<uint8>& volIter, uint8 uLevel, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8* bitmask0, uint8* bitmask1, int32 vertexIndicesX0[],int32 vertexIndicesY0[],int32 vertexIndicesZ0[], int32 vertexIndicesX1[],int32 vertexIndicesY1[],int32 vertexIndicesZ1[]) | ||||
| 	{ | ||||
| 		const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; | ||||
| 		std::uint32_t indlist[12]; | ||||
| 		const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; | ||||
| 		uint32 indlist[12]; | ||||
|  | ||||
| 		for(uint16_t y = regSlice.getLowerCorner().getY() - offset.getY(); y < regSlice.getUpperCorner().getY() - offset.getY(); y += uStepSize) | ||||
| 		for(uint16 y = regSlice.getLowerCorner().getY() - offset.getY(); y < regSlice.getUpperCorner().getY() - offset.getY(); y += uStepSize) | ||||
| 		{ | ||||
| 			for(uint16_t x = regSlice.getLowerCorner().getX() - offset.getX(); x < regSlice.getUpperCorner().getX() - offset.getX(); x += uStepSize) | ||||
| 			for(uint16 x = regSlice.getLowerCorner().getX() - offset.getX(); x < regSlice.getUpperCorner().getX() - offset.getX(); x += uStepSize) | ||||
| 			{		 | ||||
| 				//Current position | ||||
| 				const uint16_t z = regSlice.getLowerCorner().getZ() - offset.getZ(); | ||||
| 				const uint16 z = regSlice.getLowerCorner().getZ() - offset.getZ(); | ||||
|  | ||||
| 				//Determine the index into the edge table which tells us which vertices are inside of the surface | ||||
| 				uint8_t iCubeIndex = bitmask0[getDecimatedIndex(x,y)]; | ||||
| 				uint8 iCubeIndex = bitmask0[getDecimatedIndex(x,y)]; | ||||
|  | ||||
| 				/* Cube is entirely in/out of the surface */ | ||||
| 				if (edgeTable[iCubeIndex] == 0) | ||||
| @@ -561,9 +561,9 @@ namespace PolyVox | ||||
|  | ||||
| 				for (int i=0;triTable[iCubeIndex][i]!=-1;i+=3) | ||||
| 				{ | ||||
| 					std::uint32_t ind0 = indlist[triTable[iCubeIndex][i  ]]; | ||||
| 					std::uint32_t ind1 = indlist[triTable[iCubeIndex][i+1]]; | ||||
| 					std::uint32_t ind2 = indlist[triTable[iCubeIndex][i+2]]; | ||||
| 					uint32 ind0 = indlist[triTable[iCubeIndex][i  ]]; | ||||
| 					uint32 ind1 = indlist[triTable[iCubeIndex][i+1]]; | ||||
| 					uint32 ind2 = indlist[triTable[iCubeIndex][i+2]]; | ||||
|  | ||||
| 					singleMaterialPatch->m_vecTriangleIndices.push_back(ind0); | ||||
| 					singleMaterialPatch->m_vecTriangleIndices.push_back(ind1); | ||||
| @@ -573,7 +573,7 @@ namespace PolyVox | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	void generateDecimatedMeshDataForRegionSlow(BlockVolume<uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) | ||||
| 	void generateDecimatedMeshDataForRegionSlow(BlockVolume<uint8>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) | ||||
| 	{	 | ||||
| 		//When generating the mesh for a region we actually look one voxel outside it in the | ||||
| 		// back, bottom, right direction. Protect against access violations by cropping region here | ||||
| @@ -587,8 +587,8 @@ namespace PolyVox | ||||
|  | ||||
| 		Vector3DFloat vertlist[12]; | ||||
| 		Vector3DFloat normlist[12]; | ||||
| 		uint8_t vertMaterials[12]; | ||||
| 		BlockVolumeIterator<std::uint8_t> volIter(*volumeData); | ||||
| 		uint8 vertMaterials[12]; | ||||
| 		BlockVolumeIterator<uint8> volIter(*volumeData); | ||||
| 		volIter.setValidRegion(region); | ||||
|  | ||||
| 		////////////////////////////////////////////////////////////////////////// | ||||
| @@ -597,33 +597,33 @@ namespace PolyVox | ||||
|  | ||||
| 		//Iterate over each cell in the region | ||||
| 		//volIter.setPosition(region.getLowerCorner().getX(),region.getLowerCorner().getY(), region.getLowerCorner().getZ()); | ||||
| 		for(uint16_t z = region.getLowerCorner().getZ(); z <= region.getUpperCorner().getZ(); z += 2) | ||||
| 		for(uint16 z = region.getLowerCorner().getZ(); z <= region.getUpperCorner().getZ(); z += 2) | ||||
| 		{ | ||||
| 		for(uint16_t y = region.getLowerCorner().getY(); y <= region.getUpperCorner().getY(); y += 2) | ||||
| 		for(uint16 y = region.getLowerCorner().getY(); y <= region.getUpperCorner().getY(); y += 2) | ||||
| 		{ | ||||
| 		for(uint16_t x = region.getLowerCorner().getX(); x <= region.getUpperCorner().getX(); x += 2) | ||||
| 		for(uint16 x = region.getLowerCorner().getX(); x <= region.getUpperCorner().getX(); x += 2) | ||||
| 		{ | ||||
| 		//while(volIter.moveForwardInRegionXYZ()) | ||||
| 		//{		 | ||||
| 			volIter.setPosition(x,y,z); | ||||
| 			const uint8_t v000 = volIter.getSubSampledVoxel(1); | ||||
| 			const uint8 v000 = volIter.getSubSampledVoxel(1); | ||||
| 			volIter.setPosition(x+2,y,z); | ||||
| 			const uint8_t v100 = volIter.getSubSampledVoxel(1); | ||||
| 			const uint8 v100 = volIter.getSubSampledVoxel(1); | ||||
| 			volIter.setPosition(x,y+2,z); | ||||
| 			const uint8_t v010 = volIter.getSubSampledVoxel(1); | ||||
| 			const uint8 v010 = volIter.getSubSampledVoxel(1); | ||||
| 			volIter.setPosition(x+2,y+2,z); | ||||
| 			const uint8_t v110 = volIter.getSubSampledVoxel(1); | ||||
| 			const uint8 v110 = volIter.getSubSampledVoxel(1); | ||||
| 			volIter.setPosition(x,y,z+2); | ||||
| 			const uint8_t v001 = volIter.getSubSampledVoxel(1); | ||||
| 			const uint8 v001 = volIter.getSubSampledVoxel(1); | ||||
| 			volIter.setPosition(x+2,y,z+2); | ||||
| 			const uint8_t v101 = volIter.getSubSampledVoxel(1); | ||||
| 			const uint8 v101 = volIter.getSubSampledVoxel(1); | ||||
| 			volIter.setPosition(x,y+2,z+2); | ||||
| 			const uint8_t v011 = volIter.getSubSampledVoxel(1); | ||||
| 			const uint8 v011 = volIter.getSubSampledVoxel(1); | ||||
| 			volIter.setPosition(x+2,y+2,z+2); | ||||
| 			const uint8_t v111 = volIter.getSubSampledVoxel(1); | ||||
| 			const uint8 v111 = volIter.getSubSampledVoxel(1); | ||||
|  | ||||
| 			//Determine the index into the edge table which tells us which vertices are inside of the surface | ||||
| 			uint8_t iCubeIndex = 0; | ||||
| 			uint8 iCubeIndex = 0; | ||||
|  | ||||
| 			if (v000 == 0) iCubeIndex |= 1; | ||||
| 			if (v100 == 0) iCubeIndex |= 2; | ||||
| @@ -762,9 +762,9 @@ namespace PolyVox | ||||
| 				//const Vector3DFloat vertex1AsFloat = (static_cast<Vector3DFloat>(vertex1) / 2.0f) - offset; | ||||
| 				//const Vector3DFloat vertex2AsFloat = (static_cast<Vector3DFloat>(vertex2) / 2.0f) - offset; | ||||
|  | ||||
| 				const uint8_t material0 = vertMaterials[triTable[iCubeIndex][i  ]]; | ||||
| 				const uint8_t material1 = vertMaterials[triTable[iCubeIndex][i+1]]; | ||||
| 				const uint8_t material2 = vertMaterials[triTable[iCubeIndex][i+2]]; | ||||
| 				const uint8 material0 = vertMaterials[triTable[iCubeIndex][i  ]]; | ||||
| 				const uint8 material1 = vertMaterials[triTable[iCubeIndex][i+1]]; | ||||
| 				const uint8 material2 = vertMaterials[triTable[iCubeIndex][i+2]]; | ||||
|  | ||||
|  | ||||
| 				//If all the materials are the same, we just need one triangle for that material with all the alphas set high. | ||||
| @@ -784,7 +784,7 @@ namespace PolyVox | ||||
| 		//FIXME - can it happen that we have no vertices or triangles? Should exit early? | ||||
|  | ||||
|  | ||||
| 		//for(std::map<uint8_t, IndexedSurfacePatch*>::iterator iterPatch = surfacePatchMapResult.begin(); iterPatch != surfacePatchMapResult.end(); ++iterPatch) | ||||
| 		//for(std::map<uint8, IndexedSurfacePatch*>::iterator iterPatch = surfacePatchMapResult.begin(); iterPatch != surfacePatchMapResult.end(); ++iterPatch) | ||||
| 		{ | ||||
|  | ||||
| 			/*std::vector<SurfaceVertex>::iterator iterSurfaceVertex = singleMaterialPatch->getVertices().begin(); | ||||
| @@ -797,15 +797,15 @@ namespace PolyVox | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	Vector3DFloat computeDecimatedNormal(BlockVolume<uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) | ||||
| 	Vector3DFloat computeDecimatedNormal(BlockVolume<uint8>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) | ||||
| 	{ | ||||
| 		const float posX = position.getX(); | ||||
| 		const float posY = position.getY(); | ||||
| 		const float posZ = position.getZ(); | ||||
|  | ||||
| 		const uint16_t floorX = static_cast<uint16_t>(posX); | ||||
| 		const uint16_t floorY = static_cast<uint16_t>(posY); | ||||
| 		const uint16_t floorZ = static_cast<uint16_t>(posZ); | ||||
| 		const uint16 floorX = static_cast<uint16>(posX); | ||||
| 		const uint16 floorY = static_cast<uint16>(posY); | ||||
| 		const uint16 floorZ = static_cast<uint16>(posZ); | ||||
|  | ||||
| 		//Check all corners are within the volume, allowing a boundary for gradient estimation | ||||
| 		bool lowerCornerInside = volumeData->containsPoint(Vector3DInt32(floorX, floorY, floorZ),1); | ||||
| @@ -817,24 +817,24 @@ namespace PolyVox | ||||
|  | ||||
| 		Vector3DFloat result; | ||||
|  | ||||
| 		BlockVolumeIterator<std::uint8_t> volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create? | ||||
| 		BlockVolumeIterator<uint8> volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create? | ||||
|  | ||||
|  | ||||
| 		if(normalGenerationMethod == SOBEL) | ||||
| 		{ | ||||
| 			volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ)); | ||||
| 			volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ)); | ||||
| 			const Vector3DFloat gradFloor = computeSobelGradient(volIter); | ||||
| 			if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{			 | ||||
| 				volIter.setPosition(static_cast<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ)); | ||||
| 				volIter.setPosition(static_cast<uint16>(posX+1.0),static_cast<uint16>(posY),static_cast<uint16>(posZ)); | ||||
| 			} | ||||
| 			if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{			 | ||||
| 				volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY+1.0),static_cast<uint16_t>(posZ)); | ||||
| 				volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY+1.0),static_cast<uint16>(posZ)); | ||||
| 			} | ||||
| 			if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{			 | ||||
| 				volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));					 | ||||
| 				volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ+1.0));					 | ||||
| 			} | ||||
| 			const Vector3DFloat gradCeil = computeSobelGradient(volIter); | ||||
| 			result = ((gradFloor + gradCeil) * -1.0f); | ||||
| @@ -846,19 +846,19 @@ namespace PolyVox | ||||
| 		} | ||||
| 		if(normalGenerationMethod == CENTRAL_DIFFERENCE) | ||||
| 		{ | ||||
| 			volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ)); | ||||
| 			volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ)); | ||||
| 			const Vector3DFloat gradFloor = computeCentralDifferenceGradient(volIter); | ||||
| 			if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{			 | ||||
| 				volIter.setPosition(static_cast<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ)); | ||||
| 				volIter.setPosition(static_cast<uint16>(posX+1.0),static_cast<uint16>(posY),static_cast<uint16>(posZ)); | ||||
| 			} | ||||
| 			if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{			 | ||||
| 				volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY+1.0),static_cast<uint16_t>(posZ)); | ||||
| 				volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY+1.0),static_cast<uint16>(posZ)); | ||||
| 			} | ||||
| 			if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{			 | ||||
| 				volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));					 | ||||
| 				volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ+1.0));					 | ||||
| 			} | ||||
| 			const Vector3DFloat gradCeil = computeCentralDifferenceGradient(volIter); | ||||
| 			result = ((gradFloor + gradCeil) * -1.0f); | ||||
| @@ -870,21 +870,21 @@ namespace PolyVox | ||||
| 		} | ||||
| 		if(normalGenerationMethod == SIMPLE) | ||||
| 		{ | ||||
| 			volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ)); | ||||
| 			const uint8_t uFloor = volIter.getVoxel() > 0 ? 1 : 0; | ||||
| 			volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ)); | ||||
| 			const uint8 uFloor = volIter.getVoxel() > 0 ? 1 : 0; | ||||
| 			if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{					 | ||||
| 				uint8_t uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0; | ||||
| 				uint8 uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0; | ||||
| 				result = Vector3DFloat(static_cast<float>(uFloor - uCeil),0.0,0.0); | ||||
| 			} | ||||
| 			else if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{ | ||||
| 				uint8_t uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0; | ||||
| 				uint8 uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0; | ||||
| 				result = Vector3DFloat(0.0,static_cast<float>(uFloor - uCeil),0.0); | ||||
| 			} | ||||
| 			else if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5 | ||||
| 			{ | ||||
| 				uint8_t uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0; | ||||
| 				uint8 uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0; | ||||
| 				result = Vector3DFloat(0.0, 0.0,static_cast<float>(uFloor - uCeil));					 | ||||
| 			} | ||||
| 		} | ||||
|   | ||||
| @@ -27,21 +27,21 @@ namespace PolyVox | ||||
| { | ||||
| 	//Note: this function only works for inputs which are a power of two and not zero | ||||
| 	//If this is not the case then the output is undefined. | ||||
| 	std::uint8_t logBase2(std::uint32_t uInput) | ||||
| 	uint8 logBase2(uint32 uInput) | ||||
| 	{ | ||||
| 		assert(uInput != 0); | ||||
| 		assert(isPowerOf2(uInput)); | ||||
|  | ||||
| 		std::uint32_t uResult = 0; | ||||
| 		uint32 uResult = 0; | ||||
| 		while( (uInput >> uResult) != 0) | ||||
| 		{ | ||||
| 			++uResult; | ||||
| 		} | ||||
| 		return static_cast<std::uint8_t>(uResult-1); | ||||
| 		return static_cast<uint8>(uResult-1); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	bool isPowerOf2(std::uint32_t uInput) | ||||
| 	bool isPowerOf2(uint32 uInput) | ||||
| 	{ | ||||
| 		if(uInput == 0) | ||||
| 			return false; | ||||
|   | ||||
| @@ -50,7 +50,7 @@ namespace PolyVox | ||||
| 	{ | ||||
| 	} | ||||
|  | ||||
| 	void VolumeChangeTracker::setVolumeData(BlockVolume<std::uint8_t>* volumeDataToSet) | ||||
| 	void VolumeChangeTracker::setVolumeData(BlockVolume<uint8>* volumeDataToSet) | ||||
| 	{ | ||||
| 		volumeData = volumeDataToSet; | ||||
| 		volRegionUpToDate = new LinearVolume<bool>(PolyVox::logBase2(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS)); | ||||
| @@ -64,23 +64,23 @@ namespace PolyVox | ||||
| 		listToFill.clear(); | ||||
|  | ||||
| 		//Regenerate meshes. | ||||
| 		for(uint16_t regionZ = 0; regionZ < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionZ) | ||||
| 		//for(uint16_t regionZ = 0; regionZ < 1; ++regionZ) | ||||
| 		for(uint16 regionZ = 0; regionZ < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionZ) | ||||
| 		//for(uint16 regionZ = 0; regionZ < 1; ++regionZ) | ||||
| 		{		 | ||||
| 			for(uint16_t regionY = 0; regionY < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionY) | ||||
| 			//for(uint16_t regionY = 0; regionY < 2; ++regionY) | ||||
| 			for(uint16 regionY = 0; regionY < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionY) | ||||
| 			//for(uint16 regionY = 0; regionY < 2; ++regionY) | ||||
| 			{ | ||||
| 				for(uint16_t regionX = 0; regionX < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionX) | ||||
| 				//for(uint16_t regionX = 0; regionX < 2; ++regionX) | ||||
| 				for(uint16 regionX = 0; regionX < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionX) | ||||
| 				//for(uint16 regionX = 0; regionX < 2; ++regionX) | ||||
| 				{ | ||||
| 					if(volRegionUpToDate->getVoxelAt(regionX, regionY, regionZ) == false) | ||||
| 					{ | ||||
| 						const uint16_t firstX = regionX * POLYVOX_REGION_SIDE_LENGTH; | ||||
| 						const uint16_t firstY = regionY * POLYVOX_REGION_SIDE_LENGTH; | ||||
| 						const uint16_t firstZ = regionZ * POLYVOX_REGION_SIDE_LENGTH; | ||||
| 						const uint16_t lastX = firstX + POLYVOX_REGION_SIDE_LENGTH; | ||||
| 						const uint16_t lastY = firstY + POLYVOX_REGION_SIDE_LENGTH; | ||||
| 						const uint16_t lastZ = firstZ + POLYVOX_REGION_SIDE_LENGTH; | ||||
| 						const uint16 firstX = regionX * POLYVOX_REGION_SIDE_LENGTH; | ||||
| 						const uint16 firstY = regionY * POLYVOX_REGION_SIDE_LENGTH; | ||||
| 						const uint16 firstZ = regionZ * POLYVOX_REGION_SIDE_LENGTH; | ||||
| 						const uint16 lastX = firstX + POLYVOX_REGION_SIDE_LENGTH; | ||||
| 						const uint16 lastY = firstY + POLYVOX_REGION_SIDE_LENGTH; | ||||
| 						const uint16 lastZ = firstZ + POLYVOX_REGION_SIDE_LENGTH; | ||||
|  | ||||
| 						listToFill.push_back(Region(Vector3DInt32(firstX, firstY, firstZ), Vector3DInt32(lastX, lastY, lastZ))); | ||||
| 					} | ||||
| @@ -91,11 +91,11 @@ namespace PolyVox | ||||
|  | ||||
| 	void VolumeChangeTracker::setAllRegionsUpToDate(bool newUpToDateValue) | ||||
| 	{ | ||||
| 		for(uint16_t blockZ = 0; blockZ < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockZ) | ||||
| 		for(uint16 blockZ = 0; blockZ < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockZ) | ||||
| 		{ | ||||
| 			for(uint16_t blockY = 0; blockY < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockY) | ||||
| 			for(uint16 blockY = 0; blockY < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockY) | ||||
| 			{ | ||||
| 				for(uint16_t blockX = 0; blockX < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockX) | ||||
| 				for(uint16 blockX = 0; blockX < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockX) | ||||
| 				{ | ||||
| 					volRegionUpToDate->setVoxelAt(blockX, blockY, blockZ, newUpToDateValue); | ||||
| 				} | ||||
| @@ -103,7 +103,7 @@ namespace PolyVox | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	uint16_t VolumeChangeTracker::getSideLength(void) | ||||
| 	uint16 VolumeChangeTracker::getSideLength(void) | ||||
| 	{ | ||||
| 		return volumeData->getSideLength(); | ||||
| 	} | ||||
| @@ -113,31 +113,31 @@ namespace PolyVox | ||||
| 		return volumeData->getEnclosingRegion(); | ||||
| 	} | ||||
|  | ||||
| 	uint8_t VolumeChangeTracker::getVoxelAt(const Vector3DUint16& pos) | ||||
| 	uint8 VolumeChangeTracker::getVoxelAt(const Vector3DUint16& pos) | ||||
| 	{ | ||||
| 		return getVoxelAt(pos.getX(), pos.getY(), pos.getZ()); | ||||
| 	} | ||||
|  | ||||
| 	uint8_t VolumeChangeTracker::getVoxelAt(uint16_t uX, uint16_t uY, uint16_t uZ) | ||||
| 	uint8 VolumeChangeTracker::getVoxelAt(uint16 uX, uint16 uY, uint16 uZ) | ||||
| 	{ | ||||
| 		assert(uX < volumeData->getSideLength()); | ||||
| 		assert(uY < volumeData->getSideLength()); | ||||
| 		assert(uZ < volumeData->getSideLength()); | ||||
|  | ||||
| 		BlockVolumeIterator<std::uint8_t> volIter(*volumeData); | ||||
| 		BlockVolumeIterator<uint8> volIter(*volumeData); | ||||
| 		volIter.setPosition(uX,uY,uZ); | ||||
| 		return volIter.getVoxel(); | ||||
| 	} | ||||
|  | ||||
| 	BlockVolume<std::uint8_t>* VolumeChangeTracker::getVolumeData(void) const | ||||
| 	BlockVolume<uint8>* VolumeChangeTracker::getVolumeData(void) const | ||||
| 	{ | ||||
| 		return volumeData; | ||||
| 	} | ||||
|  | ||||
| 	void VolumeChangeTracker::setVoxelAt(std::uint16_t x, std::uint16_t y, std::uint16_t z, std::uint8_t value) | ||||
| 	void VolumeChangeTracker::setVoxelAt(uint16 x, uint16 y, uint16 z, uint8 value) | ||||
| 	{ | ||||
| 		//FIXME - rather than creating a iterator each time we should have one stored | ||||
| 		BlockVolumeIterator<std::uint8_t> iterVol(*volumeData); | ||||
| 		BlockVolumeIterator<uint8> iterVol(*volumeData); | ||||
| 		iterVol.setPosition(x,y,z); | ||||
| 		iterVol.setVoxel(value); | ||||
| 		 | ||||
| @@ -153,23 +153,23 @@ namespace PolyVox | ||||
| 		} | ||||
| 		else //Mark surrounding regions as well | ||||
| 		{ | ||||
| 			const uint16_t regionX = x >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 			const uint16_t regionY = y >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 			const uint16_t regionZ = z >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 			const uint16 regionX = x >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 			const uint16 regionY = y >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 			const uint16 regionZ = z >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
|  | ||||
| 			const uint16_t minRegionX = (std::max)(uint16_t(0),uint16_t(regionX-1)); | ||||
| 			const uint16_t minRegionY = (std::max)(uint16_t(0),uint16_t(regionY-1)); | ||||
| 			const uint16_t minRegionZ = (std::max)(uint16_t(0),uint16_t(regionZ-1)); | ||||
| 			const uint16 minRegionX = (std::max)(uint16(0),uint16(regionX-1)); | ||||
| 			const uint16 minRegionY = (std::max)(uint16(0),uint16(regionY-1)); | ||||
| 			const uint16 minRegionZ = (std::max)(uint16(0),uint16(regionZ-1)); | ||||
|  | ||||
| 			const uint16_t maxRegionX = (std::min)(uint16_t(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16_t(regionX+1)); | ||||
| 			const uint16_t maxRegionY = (std::min)(uint16_t(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16_t(regionY+1)); | ||||
| 			const uint16_t maxRegionZ = (std::min)(uint16_t(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16_t(regionZ+1)); | ||||
| 			const uint16 maxRegionX = (std::min)(uint16(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16(regionX+1)); | ||||
| 			const uint16 maxRegionY = (std::min)(uint16(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16(regionY+1)); | ||||
| 			const uint16 maxRegionZ = (std::min)(uint16(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16(regionZ+1)); | ||||
|  | ||||
| 			for(uint16_t zCt = minRegionZ; zCt <= maxRegionZ; zCt++) | ||||
| 			for(uint16 zCt = minRegionZ; zCt <= maxRegionZ; zCt++) | ||||
| 			{ | ||||
| 				for(uint16_t yCt = minRegionY; yCt <= maxRegionY; yCt++) | ||||
| 				for(uint16 yCt = minRegionY; yCt <= maxRegionY; yCt++) | ||||
| 				{ | ||||
| 					for(uint16_t xCt = minRegionX; xCt <= maxRegionX; xCt++) | ||||
| 					for(uint16 xCt = minRegionX; xCt <= maxRegionX; xCt++) | ||||
| 					{ | ||||
| 						volRegionUpToDate->setVoxelAt(xCt,yCt,zCt,false); | ||||
| 					} | ||||
| @@ -178,12 +178,12 @@ namespace PolyVox | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	void VolumeChangeTracker::setLockedVoxelAt(std::uint16_t x, std::uint16_t y, std::uint16_t z, std::uint8_t value) | ||||
| 	void VolumeChangeTracker::setLockedVoxelAt(uint16 x, uint16 y, uint16 z, uint8 value) | ||||
| 	{ | ||||
| 		assert(m_bIsLocked); | ||||
|  | ||||
| 		//FIXME - rather than creating a iterator each time we should have one stored | ||||
| 		BlockVolumeIterator<std::uint8_t> iterVol(*volumeData); | ||||
| 		BlockVolumeIterator<uint8> iterVol(*volumeData); | ||||
| 		iterVol.setPosition(x,y,z); | ||||
| 		iterVol.setVoxel(value); | ||||
| 	} | ||||
| @@ -206,19 +206,19 @@ namespace PolyVox | ||||
| 			throw std::logic_error("No region is locked. You must lock a region before you can unlock it."); | ||||
| 		} | ||||
|  | ||||
| 		const uint16_t firstRegionX = m_regLastLocked.getLowerCorner().getX() >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 		const uint16_t firstRegionY = m_regLastLocked.getLowerCorner().getY() >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 		const uint16_t firstRegionZ = m_regLastLocked.getLowerCorner().getZ() >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 		const uint16 firstRegionX = m_regLastLocked.getLowerCorner().getX() >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 		const uint16 firstRegionY = m_regLastLocked.getLowerCorner().getY() >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 		const uint16 firstRegionZ = m_regLastLocked.getLowerCorner().getZ() >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
|  | ||||
| 		const uint16_t lastRegionX = m_regLastLocked.getUpperCorner().getX() >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 		const uint16_t lastRegionY = m_regLastLocked.getUpperCorner().getY() >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 		const uint16_t lastRegionZ = m_regLastLocked.getUpperCorner().getZ() >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 		const uint16 lastRegionX = m_regLastLocked.getUpperCorner().getX() >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 		const uint16 lastRegionY = m_regLastLocked.getUpperCorner().getY() >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
| 		const uint16 lastRegionZ = m_regLastLocked.getUpperCorner().getZ() >> POLYVOX_REGION_SIDE_LENGTH_POWER; | ||||
|  | ||||
| 		for(uint16_t zCt = firstRegionZ; zCt <= lastRegionZ; zCt++) | ||||
| 		for(uint16 zCt = firstRegionZ; zCt <= lastRegionZ; zCt++) | ||||
| 		{ | ||||
| 			for(uint16_t yCt = firstRegionY; yCt <= lastRegionY; yCt++) | ||||
| 			for(uint16 yCt = firstRegionY; yCt <= lastRegionY; yCt++) | ||||
| 			{ | ||||
| 				for(uint16_t xCt = firstRegionX; xCt <= lastRegionX; xCt++) | ||||
| 				for(uint16 xCt = firstRegionX; xCt <= lastRegionX; xCt++) | ||||
| 				{ | ||||
| 					volRegionUpToDate->setVoxelAt(xCt,yCt,zCt,false); | ||||
| 				} | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
|  | ||||
| namespace PolyVox | ||||
| { | ||||
| 	float computeSmoothedVoxel(BlockVolumeIterator<std::uint8_t>& volIter) | ||||
| 	float computeSmoothedVoxel(BlockVolumeIterator<uint8>& volIter) | ||||
| 	{ | ||||
| 		assert(volIter.getPosX() >= 1); | ||||
| 		assert(volIter.getPosY() >= 1); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user