From 8d2061bdb5296bb2dd47c096bf0f286d9ceeae95 Mon Sep 17 00:00:00 2001 From: Daviw Williams Date: Mon, 4 Feb 2013 16:38:50 +0100 Subject: [PATCH] Fixed crash with MaxVerticesPerPosition being set too low. --- .../include/PolyVoxCore/CubicSurfaceExtractor.inl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl index 5cf72fc6..72294e2c 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl @@ -26,13 +26,12 @@ namespace PolyVox // We try to avoid duplicate vertices by checking whether a vertex has already been added at a given position. // However, it is possible that vertices have the same position but different materials. In this case, the // vertices are not true duplicates and both must be added to the mesh. As far as I can tell, it is possible to have - // at most six vertices with the same position but different materials. This worst-case scenario happens when we - // have a 2x2x2 group of voxels (all with different materials) and then we delete two voxels from opposing corners. - // The vertex position at the center of this group is then going to be used by six quads all with different materials. - // One futher note - we can actually have eight quads sharing a vertex position (imagine two 1x1x10 rows of voxels - // sharing a common edge) but in this case all eight quads will not have different materials. + // at most eight vertices with the same position but different materials. For example, this worst-case scenario + // happens when we have a 2x2x2 group of voxels, all with different materials and some/all partially transparent. + // The vertex position at the center of this group is then going to be used by all eight voxels all with different + // materials. template - const uint32_t CubicSurfaceExtractor::MaxVerticesPerPosition = 6; + const uint32_t CubicSurfaceExtractor::MaxVerticesPerPosition = 8; template CubicSurfaceExtractor::CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, bool bMergeQuads, IsQuadNeeded isQuadNeeded)