Work on improving material system.
This commit is contained in:
parent
9d1f9e7959
commit
e51b9cfee9
@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||||||
#define __PolyVox_IndexedSurfacePatch_H__
|
#define __PolyVox_IndexedSurfacePatch_H__
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include "PolyVoxImpl/CPlusPlusZeroXSupport.h"
|
#include "PolyVoxImpl/CPlusPlusZeroXSupport.h"
|
||||||
|
|
||||||
@ -54,6 +55,8 @@ namespace PolyVox
|
|||||||
|
|
||||||
void smooth(float fAmount, bool bIncludeEdgeVertices = false);
|
void smooth(float fAmount, bool bIncludeEdgeVertices = false);
|
||||||
|
|
||||||
|
POLYVOX_SHARED_PTR<IndexedSurfacePatch> extractSubset(std::set<uint8_t> setMaterials);
|
||||||
|
|
||||||
void generateAveragedFaceNormals(bool bNormalise, bool bIncludeEdgeVertices = false);
|
void generateAveragedFaceNormals(bool bNormalise, bool bIncludeEdgeVertices = false);
|
||||||
|
|
||||||
//Vector3DInt32 m_v3dRegionPosition; //FIXME - remove this?
|
//Vector3DInt32 m_v3dRegionPosition; //FIXME - remove this?
|
||||||
@ -66,7 +69,6 @@ namespace PolyVox
|
|||||||
std::vector<uint32_t> m_vecTriangleIndices;
|
std::vector<uint32_t> m_vecTriangleIndices;
|
||||||
std::vector<SurfaceVertex> m_vecVertices;
|
std::vector<SurfaceVertex> m_vecVertices;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __IndexedSurfacePatch_H__ */
|
#endif /* __IndexedSurfacePatch_H__ */
|
||||||
|
@ -218,4 +218,38 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
POLYVOX_SHARED_PTR<IndexedSurfacePatch> IndexedSurfacePatch::extractSubset(std::set<uint8_t> setMaterials)
|
||||||
|
{
|
||||||
|
POLYVOX_SHARED_PTR<IndexedSurfacePatch> result(new IndexedSurfacePatch);
|
||||||
|
|
||||||
|
if(m_vecVertices.size() == 0) //FIXME - I don't think we should need this test, but I have seen crashes otherwise...
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(vector<uint32_t>::iterator iterIndex = m_vecTriangleIndices.begin(); iterIndex != m_vecTriangleIndices.end();)
|
||||||
|
{
|
||||||
|
SurfaceVertex& v0 = m_vecVertices[*iterIndex];
|
||||||
|
iterIndex++;
|
||||||
|
SurfaceVertex& v1 = m_vecVertices[*iterIndex];
|
||||||
|
iterIndex++;
|
||||||
|
SurfaceVertex& v2 = m_vecVertices[*iterIndex];
|
||||||
|
iterIndex++;
|
||||||
|
|
||||||
|
if(
|
||||||
|
(setMaterials.find(v0.getMaterial()) != setMaterials.end()) ||
|
||||||
|
(setMaterials.find(v1.getMaterial()) != setMaterials.end()) ||
|
||||||
|
(setMaterials.find(v2.getMaterial()) != setMaterials.end()))
|
||||||
|
{
|
||||||
|
uint32_t i0 = result->addVertex(v0);
|
||||||
|
uint32_t i1 = result->addVertex(v1);
|
||||||
|
uint32_t i2 = result->addVertex(v2);
|
||||||
|
|
||||||
|
result->addTriangle(i0,i1,i2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user