diff --git a/library/PolyVoxCore/include/PolyVoxCore/Mesh.inl b/library/PolyVoxCore/include/PolyVoxCore/Mesh.inl index cd93f878..e34f51ff 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Mesh.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Mesh.inl @@ -85,6 +85,9 @@ namespace PolyVox template IndexType Mesh::addVertex(const VertexType& vertex) { + // We should not add more vertices than our chosen index type will let us index. + POLYVOX_THROW_IF(m_vecVertices.size() >= std::numeric_limits::max(), std::out_of_range, "Mesh has more vertices that the chosen index type allows."); + m_vecVertices.push_back(vertex); return m_vecVertices.size() - 1; }