From 1efbaef44b16a051f6036b617ffe0ea4216f81a1 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 20 Mar 2013 16:21:45 -0700 Subject: [PATCH] only add voxel to be drawn if not transparent --- interface/src/VoxelSystem.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index c7f710e340..4e71270c03 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -82,18 +82,20 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode) { float * startVertex = firstVertexForCode(currentNode->octalCode); float voxelScale = 1 / powf(2, *currentNode->octalCode); - // populate the array with points for the 8 vertices - // and RGB color for each added vertex - for (int j = 0; j < VERTEX_POINTS_PER_VOXEL; j++ ) { - *verticesEndPointer = startVertex[j % 3] + (identityVertices[j] * voxelScale); - *(colorsArray + (verticesEndPointer - verticesArray)) = currentNode->color[j % 3]; + if (currentNode->color[3] == 1) { + // populate the array with points for the 8 vertices + // and RGB color for each added vertex + for (int j = 0; j < VERTEX_POINTS_PER_VOXEL; j++ ) { + *verticesEndPointer = startVertex[j % 3] + (identityVertices[j] * voxelScale); + *(colorsArray + (verticesEndPointer - verticesArray)) = currentNode->color[j % 3]; + + verticesEndPointer++; + } - verticesEndPointer++; + voxelsAdded++; } - + delete [] startVertex; - - voxelsAdded++; } return voxelsAdded;