CubicVertex now uses a more memory efficient representation which can be decoded on the CPU or GPU.
This commit is contained in:
		| @@ -215,7 +215,7 @@ namespace PolyVox | ||||
| 			{ | ||||
| 				//No vertices matched and we've now hit an empty space. Fill it by creating a vertex. The 0.5f offset is because vertices set between voxels in order to build cubes around them. | ||||
| 				CubicVertex<typename VolumeType::VoxelType> cubicVertex; | ||||
| 				cubicVertex.position.setElements(static_cast<float>(uX)-0.5f, static_cast<float>(uY)-0.5f, static_cast<float>(uZ)-0.5f); | ||||
| 				cubicVertex.position.setElements(static_cast<uint8_t>(uX), static_cast<uint8_t>(uY), static_cast<uint8_t>(uZ)); | ||||
| 				cubicVertex.material = uMaterialIn; | ||||
| 				rEntry.iIndex = m_meshCurrent->addVertex(cubicVertex); | ||||
| 				rEntry.uMaterial = uMaterialIn; | ||||
|   | ||||
| @@ -105,7 +105,7 @@ namespace PolyVox | ||||
| 	Mesh< Vertex< typename MeshType::VertexType::VoxelType > > decode(const MeshType& mesh) | ||||
| 	{ | ||||
| 		Mesh< Vertex< typename MeshType::VertexType::VoxelType > > result; | ||||
| 		result.m_vecVertices.reserve(mesh.m_vecVertices.size()); | ||||
| 		result.m_vecVertices.resize(mesh.m_vecVertices.size()); | ||||
|  | ||||
| 		for(uint32_t ct = 0; ct < mesh.m_vecVertices.size(); ct++) | ||||
| 		{ | ||||
|   | ||||
| @@ -56,8 +56,8 @@ namespace PolyVox | ||||
| 	{ | ||||
| 		typedef _VoxelType VoxelType; | ||||
|  | ||||
| 		Vector3DFloat position; | ||||
| 		Vector3DFloat normal; | ||||
| 		Vector3DUint8 position; | ||||
| 		uint8_t normal; | ||||
| 		VoxelType material; | ||||
| 	}; | ||||
|  | ||||
| @@ -81,8 +81,9 @@ namespace PolyVox | ||||
| 	Vertex<VoxelType> decode(const CubicVertex<VoxelType>& cubicVertex) | ||||
| 	{ | ||||
| 		Vertex<VoxelType> result; | ||||
| 		result.position = cubicVertex.position; | ||||
| 		result.normal = cubicVertex.normal; | ||||
| 		Vector3DUint8 temp = cubicVertex.position; // For some reason we can't cast Vector3DUint8 to Vector3DFloat - investigate why. | ||||
| 		result.position = Vector3DFloat(temp.getX(), temp.getY(), temp.getZ()) - Vector3DFloat(0.5, 0.5, 0.5); | ||||
| 		//result.normal = cubicVertex.normal; | ||||
| 		result.material = cubicVertex.material; | ||||
| 		return result; | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user