History

fix conditional inclusion of voxel in vertices and color arrays

Stephen Birarda committed 13 years ago

Commit f9793231 parent f8485ab1 file · +9 −11Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 1 file). Show all

Unified · Split

interface/src/VoxelSystem.cpp+9−11
@@ -78,22 +78,20 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode) { · 77 unmodified lines
7878
7979 // if we didn't get any voxels added then we're a leaf
8080 // add our vertex and color information to the interleaved array
81− if (voxelsAdded == 0) {
81+ if (voxelsAdded == 0 && currentNode->color[3] == 1) {
8282 float * startVertex = firstVertexForCode(currentNode->octalCode);
8383 float voxelScale = 1 / powf(2, *currentNode->octalCode);
8484
85− if (currentNode->color[3] == 1) {
86− // populate the array with points for the 8 vertices
87− // and RGB color for each added vertex
88− for (int j = 0; j < VERTEX_POINTS_PER_VOXEL; j++ ) {
89− *verticesEndPointer = startVertex[j % 3] + (identityVertices[j] * voxelScale);
90− *(colorsArray + (verticesEndPointer - verticesArray)) = currentNode->color[j % 3];
91−
92− verticesEndPointer++;
93− }
85+ // populate the array with points for the 8 vertices
86+ // and RGB color for each added vertex
87+ for (int j = 0; j < VERTEX_POINTS_PER_VOXEL; j++ ) {
88+ *verticesEndPointer = startVertex[j % 3] + (identityVertices[j] * voxelScale);
89+ *(colorsArray + (verticesEndPointer - verticesArray)) = currentNode->color[j % 3];
9490
95− voxelsAdded++;
91+ verticesEndPointer++;
9692 }
93+
94+ voxelsAdded++;
9795
9896 delete [] startVertex;
9997 }