History

move the voxel system to 40,0,40, only re-render on new voxels

Stephen Birarda committed 13 years ago

Commit 9cd314d1 parent 1f989291 file · +12 −6Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+12−6
@@ -230,8 +230,6 @@ void VoxelSystem::parseData(void *data, int size) { · 229 unmodified lines
230230 // output the bits received from the voxel server
231231 unsigned char *voxelData = (unsigned char *) data + 1;
232232
233− printf("Received a packet of %d bytes from VS\n", size);
234−
235233 // ask the VoxelTree to read the bitstream into the tree
236234 tree->readBitstreamToTree(voxelData, size - 1);
237235
@@ -240,10 +238,15 @@ void VoxelSystem::parseData(void *data, int size) { · 2 unmodified lines
240238
241239 // call recursive function to populate in memory arrays
242240 // it will return the number of voxels added
243− voxelsRendered = treeToArrays(tree->rootNode);
241+ int newVoxels = treeToArrays(tree->rootNode);
244242
245− // set the boolean if there are any voxels to be rendered so we re-fill the VBOs
246− voxelsToRender = (voxelsRendered > 0);
243+ if (newVoxels > voxelsRendered) {
244+
245+ voxelsRendered = newVoxels;
246+
247+ // set the boolean if there are any voxels to be rendered so we re-fill the VBOs
248+ voxelsToRender = true;
249+ }
247250 }
248251
249252 int VoxelSystem::treeToArrays(VoxelNode *currentNode) {
@@ -318,7 +321,9 @@ void VoxelSystem::init() { · 68 unmodified lines
318321 // VBO for the indicesArray
319322 glGenBuffers(1, &vboIndicesID);
320323 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID);
321− glBufferData(GL_ELEMENT_ARRAY_BUFFER, INDICES_PER_VOXEL * sizeof(GLuint) * MAX_VOXELS_PER_SYSTEM, indicesArray, GL_STATIC_DRAW);
324+ glBufferData(GL_ELEMENT_ARRAY_BUFFER,
325+ INDICES_PER_VOXEL * sizeof(GLuint) * MAX_VOXELS_PER_SYSTEM,
326+ indicesArray, GL_STATIC_DRAW);
322327
323328 // delete the indices array that is no longer needed
324329 delete[] indicesArray;
@@ -352,6 +357,7 @@ void VoxelSystem::render() { · 27 unmodified lines
352357
353358 // draw the number of voxels we have
354359 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID);
360+ glTranslatef(40, 0, 40);
355361 glScalef(10, 10, 10);
356362 glDrawElements(GL_TRIANGLES, 36 * voxelsRendered, GL_UNSIGNED_INT, 0);
357363