Added Material16 and Material32 types.
Small fixes for where 8-bit material was assumed.
This commit is contained in:
parent
22959716c1
commit
8b353fb5bc
@ -40,8 +40,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
//and if their density is below the threshold.
|
//and if their density is below the threshold.
|
||||||
Material8 voxel = volData->getVoxelAt(v3dPos);
|
VoxelType voxel = volData->getVoxelAt(v3dPos);
|
||||||
if(voxel.getDensity() >= Material8::getThreshold())
|
if(voxel.getDensity() >= VoxelType::getThreshold())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ namespace PolyVox
|
|||||||
void execute();
|
void execute();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32_t addVertex(float fX, float fY, float fZ, uint8_t uMaterial, Array<3, IndexAndMaterial>& existingVertices);
|
int32_t addVertex(float fX, float fY, float fZ, uint32_t uMaterial, Array<3, IndexAndMaterial>& existingVertices);
|
||||||
bool performQuadMerging(std::list<Quad>& quads);
|
bool performQuadMerging(std::list<Quad>& quads);
|
||||||
bool mergeQuads(Quad& q1, Quad& q2);
|
bool mergeQuads(Quad& q1, Quad& q2);
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ namespace PolyVox
|
|||||||
|
|
||||||
if((currentVoxelIsSolid != negXVoxelIsSolid) && (finalY == false) && (finalZ == false))
|
if((currentVoxelIsSolid != negXVoxelIsSolid) && (finalY == false) && (finalZ == false))
|
||||||
{
|
{
|
||||||
int material = (std::max)(currentVoxel.getMaterial(), negXVoxel.getMaterial());
|
uint32_t material = (std::max)(currentVoxel.getMaterial(), negXVoxel.getMaterial());
|
||||||
|
|
||||||
// Check to ensure that when a voxel solid/non-solid change is right on a region border, the vertices are generated on the solid side of the region border
|
// Check to ensure that when a voxel solid/non-solid change is right on a region border, the vertices are generated on the solid side of the region border
|
||||||
if(((currentVoxelIsSolid > negXVoxelIsSolid) && finalX == false) || ((currentVoxelIsSolid < negXVoxelIsSolid) && regX != 0))
|
if(((currentVoxelIsSolid > negXVoxelIsSolid) && finalX == false) || ((currentVoxelIsSolid < negXVoxelIsSolid) && regX != 0))
|
||||||
@ -241,7 +241,7 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template< template<typename> class VolumeType, typename VoxelType>
|
||||||
int32_t CubicSurfaceExtractor<VolumeType, VoxelType>::addVertex(float fX, float fY, float fZ, uint8_t uMaterialIn, Array<3, IndexAndMaterial>& existingVertices)
|
int32_t CubicSurfaceExtractor<VolumeType, VoxelType>::addVertex(float fX, float fY, float fZ, uint32_t uMaterialIn, Array<3, IndexAndMaterial>& existingVertices)
|
||||||
{
|
{
|
||||||
uint32_t uX = static_cast<uint32_t>(fX + 0.75f);
|
uint32_t uX = static_cast<uint32_t>(fX + 0.75f);
|
||||||
uint32_t uY = static_cast<uint32_t>(fY + 0.75f);
|
uint32_t uY = static_cast<uint32_t>(fY + 0.75f);
|
||||||
|
@ -58,7 +58,7 @@ namespace PolyVox
|
|||||||
int plusXVoxel = m_volData->getVoxelAt(x+1,y,z).getDensity() >= VoxelType::getThreshold();
|
int plusXVoxel = m_volData->getVoxelAt(x+1,y,z).getDensity() >= VoxelType::getThreshold();
|
||||||
if(currentVoxel > plusXVoxel)
|
if(currentVoxel > plusXVoxel)
|
||||||
{
|
{
|
||||||
int material = m_volData->getVoxelAt(x,y,z).getMaterial();
|
uint32_t material = m_volData->getVoxelAt(x,y,z).getMaterial();
|
||||||
|
|
||||||
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ - 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), material));
|
uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ - 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), material));
|
||||||
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), material));
|
uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), material));
|
||||||
|
@ -88,6 +88,8 @@ namespace PolyVox
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef Material<uint8_t> Material8;
|
typedef Material<uint8_t> Material8;
|
||||||
|
typedef Material<uint16_t> Material16;
|
||||||
|
typedef Material<uint32_t> Material32;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //__PolyVox_Material_H__
|
#endif //__PolyVox_Material_H__
|
||||||
|
@ -77,6 +77,8 @@ namespace PolyVox
|
|||||||
typedef Density<uint8_t> Density8;
|
typedef Density<uint8_t> Density8;
|
||||||
template <typename Type> class Material;
|
template <typename Type> class Material;
|
||||||
typedef Material<uint8_t> Material8;
|
typedef Material<uint8_t> Material8;
|
||||||
|
typedef Material<uint16_t> Material16;
|
||||||
|
typedef Material<uint32_t> Material32;
|
||||||
template <typename Type, uint8_t NoOfMaterialBits, uint8_t NoOfDensityBits> class MaterialDensityPair;
|
template <typename Type, uint8_t NoOfMaterialBits, uint8_t NoOfDensityBits> class MaterialDensityPair;
|
||||||
typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44;
|
typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44;
|
||||||
|
|
||||||
|
@ -448,7 +448,7 @@ namespace PolyVox
|
|||||||
Vector3DFloat v3dNormal = (n100*fInterp) + (n000*(1-fInterp));
|
Vector3DFloat v3dNormal = (n100*fInterp) + (n000*(1-fInterp));
|
||||||
v3dNormal.normalise();
|
v3dNormal.normalise();
|
||||||
|
|
||||||
const uint8_t uMaterial = v000.getMaterial() | v100.getMaterial(); //Because one of these is 0, the or operation takes the max.
|
const uint32_t uMaterial = v000.getMaterial() | v100.getMaterial(); //Because one of these is 0, the or operation takes the max.
|
||||||
|
|
||||||
PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, uMaterial);
|
PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, uMaterial);
|
||||||
uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex);
|
uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex);
|
||||||
@ -471,7 +471,7 @@ namespace PolyVox
|
|||||||
Vector3DFloat v3dNormal = (n010*fInterp) + (n000*(1-fInterp));
|
Vector3DFloat v3dNormal = (n010*fInterp) + (n000*(1-fInterp));
|
||||||
v3dNormal.normalise();
|
v3dNormal.normalise();
|
||||||
|
|
||||||
const uint8_t uMaterial = v000.getMaterial() | v010.getMaterial(); //Because one of these is 0, the or operation takes the max.
|
const uint32_t uMaterial = v000.getMaterial() | v010.getMaterial(); //Because one of these is 0, the or operation takes the max.
|
||||||
|
|
||||||
PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, uMaterial);
|
PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, uMaterial);
|
||||||
uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex);
|
uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex);
|
||||||
@ -494,7 +494,7 @@ namespace PolyVox
|
|||||||
Vector3DFloat v3dNormal = (n001*fInterp) + (n000*(1-fInterp));
|
Vector3DFloat v3dNormal = (n001*fInterp) + (n000*(1-fInterp));
|
||||||
v3dNormal.normalise();
|
v3dNormal.normalise();
|
||||||
|
|
||||||
const uint8_t uMaterial = v000.getMaterial() | v001.getMaterial(); //Because one of these is 0, the or operation takes the max.
|
const uint32_t uMaterial = v000.getMaterial() | v001.getMaterial(); //Because one of these is 0, the or operation takes the max.
|
||||||
|
|
||||||
PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, uMaterial);
|
PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, uMaterial);
|
||||||
uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex);
|
uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user