History

Added some new debugging code, removed some old debugging code, some small coding standard tweaks

ZappoMan committed 13 years ago

Commit 70818bd1 parent 3cb41a61 file · +75 −36Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+75−36
@@ -115,8 +115,6 @@ float VoxelSystem::getVoxelsBytesReadPerSecondAverage() { · 114 unmodified lines
115115 return tree->voxelsBytesReadStats.getAverageSampleValuePerSecond();
116116 }
117117
118−bool pickAorB = false;
119−
120118 int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
121119
122120 unsigned char command = *sourceBuffer;
@@ -130,6 +128,71 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 7 unmodified lines
130128 // would make a point of removing this code when all this work is done. But in the mean time, I need it here for
131129 // debugging purposes... When you do the code review... DO NOT tell me to remove it. :) Thank you!
132130 //
131+ unsigned char fakePacketA[18] = { 86,4,39,128,232,128,128,128,139,138,139,139,137,139,138,139,139,0 };
132+ unsigned char fakePacketB[13] = { 86,
133+ 7,39,135,128,
134+ 136,
135+ 255,0,0,
136+ 0,255,0,
137+ 0
138+ };
139+ unsigned char fakePacketC[13] = { 86,
140+ 7,39,135,64,
141+ 136,
142+ 0,0,255,
143+ 0,255,255,
144+ 0
145+ };
146+
147+ unsigned char fakePacketD[25] = { 86,
148+ 6,39,135,64,
149+ 136,
150+ 0,0,255,
151+ 0,255,255,
152+ 0,
153+ 6,39,135,128,
154+ 136,
155+ 255,0,0,
156+ 0,255,0,
157+ 0
158+ };
159+
160+ unsigned char fakePacketE[60] = {
161+ 86 // V
162+
163+ ,6,39,135,64,
164+ 136,
165+ 0,0,255,
166+ 0,255,255,
167+ 0
168+
169+ ,6,39,135,128,
170+ 136,
171+ 255,0,0,
172+ 0,255,0,
173+ 0
174+
175+ // now some extra bits, what happens???
176+ ,2,252, // octcode for root
177+ 7, // child color bits
178+ 255,0,0, // child 1 color
179+ 255,255,0, // child 1 color
180+ 128,128,0, // child 1 color
181+ 0 // child tree bits
182+
183+ ,3,0,0, // octcode for root
184+ 3, // child color bits
185+ 0,0,255, // child 128 color
186+ 0,255,0, // child 8 color
187+ 0 // child tree bits - none
188+
189+ ,3,0,0, // octcode for root
190+ 136, // child color bits
191+ 0,0,255, // child 128 color
192+ 0,255,0, // child 8 color
193+ 0 // child tree bits - none
194+ };
195+
133196 unsigned char fakeBuffer[18] = {
134197 86, // V
135198 2,0, // octcode for root
@@ -185,13 +248,6 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 49 unmodified lines
185248 };
186249
187250 // trim off the "V"
188− printf("loading fake data! pickAorB=%s\n", (pickAorB ? "A" : "B") );
189− if (pickAorB) {
190− tree->readBitstreamToTree((unsigned char*)&fakeBufferA[1], sizeof(fakeBufferA)-1);
191− } else {
192− tree->readBitstreamToTree((unsigned char*)&fakeBufferB[1], sizeof(fakeBufferB)-1);
193− }
194− pickAorB = !pickAorB;
195251
196252 ***** END OF TEMPORARY CODE ***************************************************************************************/
197253
@@ -256,9 +312,8 @@ void VoxelSystem::copyWrittenDataToReadArrays() { · 58 unmodified lines
256312 pthread_mutex_unlock(&bufferWriteLock);
257313 }
258314
259−int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosition) {
315+int VoxelSystem::treeToArrays(VoxelNode* currentNode, const glm::vec3& nodePosition) {
260316 int voxelsAdded = 0;
261−
262317 float halfUnitForVoxel = powf(0.5, *currentNode->octalCode) * (0.5 * TREE_SCALE);
263318 glm::vec3 viewerPosition = viewerAvatar->getPosition();
264319
@@ -266,21 +321,12 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosi · 1 unmodified line
266321 glm::vec3 debugNodePosition;
267322 copyFirstVertexForCode(currentNode->octalCode,(float*)&debugNodePosition);
268323
269− //printf("-----------------\n");
270− //printf("halfUnitForVoxel=%f\n",halfUnitForVoxel);
271− //printf("viewer.x=%f y=%f z=%f \n", viewerPosition.x, viewerPosition.y, viewerPosition.z);
272− //printf("node.x=%f y=%f z=%f \n", nodePosition[0], nodePosition[1], nodePosition[2]);
273− //printf("debugNodePosition.x=%f y=%f z=%f \n", debugNodePosition[0], debugNodePosition[1], debugNodePosition[2]);
274−
275324 float distanceToVoxelCenter = sqrtf(powf(viewerPosition.x - nodePosition[0] - halfUnitForVoxel, 2) +
276325 powf(viewerPosition.y - nodePosition[1] - halfUnitForVoxel, 2) +
277326 powf(viewerPosition.z - nodePosition[2] - halfUnitForVoxel, 2));
278327
279328 int renderLevel = *currentNode->octalCode + 1;
280329 int boundaryPosition = boundaryDistanceForRenderLevel(renderLevel);
281− //printLog("treeToArrays() renderLevel=%d distanceToVoxelCenter=%f boundaryPosition=%d\n",
282− // renderLevel,distanceToVoxelCenter,boundaryPosition);
283−
284330 bool alwaysDraw = false; // XXXBHG - temporary debug code. Flip this to true to disable LOD blurring
285331
286332 if (alwaysDraw || distanceToVoxelCenter < boundaryPosition) {
@@ -291,22 +337,6 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosi · 4 unmodified lines
291337 glm::vec3 childNodePosition;
292338 copyFirstVertexForCode(currentNode->children[i]->octalCode,(float*)&childNodePosition);
293339 childNodePosition *= (float)TREE_SCALE; // scale it up
294−
295− /**** disabled ************************************************************************************************
296− // Note: Stephen, I intentionally left this in so you would talk to me about it. Here's the deal, this code
297− // doesn't seem to work correctly. It returns X and Z flipped and the values are negative. Since we use the
298− // firstVertexForCode() function below to calculate the child vertex and that DOES work, I've decided to use
299− // that function to calculate our position for LOD handling.
300− //
301− // calculate the child's position based on the parent position
302− for (int j = 0; j < 3; j++) {
303− childNodePosition[j] = nodePosition[j];
304−
305− if (oneAtBit(branchIndexWithDescendant(currentNode->octalCode,currentNode->children[i]->octalCode),(7 - j))) {
306− childNodePosition[j] -= (powf(0.5, *currentNode->children[i]->octalCode) * TREE_SCALE);
307− }
308− }
309− **** disabled ************************************************************************************************/
310340 voxelsAdded += treeToArrays(currentNode->children[i], childNodePosition);
311341 }
312342 }
@@ -314,6 +344,15 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosi · 1 unmodified line
314344
315345 // if we didn't get any voxels added then we're a leaf
316346 // add our vertex and color information to the interleaved array
347+ /****** XXXBHG ***** Stephen!!! ********************************************************************************************
348+ * What is this code about??? Why are we checking to see if voxelsAdded==0???? Shouldn't we always be writing arrays?
349+ * Help me understand this? If I remove this check, then two things happen:
350+ * 1) I get much more blinking... which is not desirable.
351+ * 2) I seem to get large blocks of "average color" voxels... namely I see big voxels, where their should be smaller ones
352+ *
353+ * But with this check in here, the blinking stops... which kind of makes sense... and the average blocks go away??? not
354+ * sure why, but updates seem to be slower... namely, we don't seem to see the new voxels even though the client got them.
355+ ***************************************************************************************************************************/
317356 if (voxelsAdded == 0 && currentNode->isColored()) {
318357 float startVertex[3];
319358 copyFirstVertexForCode(currentNode->octalCode,(float*)&startVertex);