History

code cleanup

ZappoMan committed 13 years ago

Commit 015fd051 parent 62e7c032 files · +13 −29Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+12−28
@@ -364,19 +364,12 @@ void VoxelSystem::render() { · 363 unmodified lines
364364 glPopMatrix();
365365 }
366366
367−void VoxelSystem::simulate(float deltaTime) {
368−
369−}
370−
371367 int VoxelSystem::_nodeCount = 0;
372368
373369 bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) {
374370 _nodeCount++;
375371 if (node->isColored()) {
376− nodeColor newColor = { 0,0,0,1 };
377− newColor[0] = randomColorValue(150);
378− newColor[1] = randomColorValue(150);
379− newColor[1] = randomColorValue(150);
372+ nodeColor newColor = { randomColorValue(150), randomColorValue(150), randomColorValue(150), 1 };
380373 node->setColor(newColor);
381374 }
382375 return true;
@@ -385,24 +378,21 @@ bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) { · 2 unmodified lines
385378 void VoxelSystem::randomizeVoxelColors() {
386379 _nodeCount = 0;
387380 _tree->recurseTreeWithOperation(randomColorOperation);
388− printLog("setting randomized true color for %d nodes\n",_nodeCount);
381+ printLog("setting randomized true color for %d nodes\n", _nodeCount);
389382 setupNewVoxelsForDrawing();
390383 }
391384
392385 bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, void* extraData) {
393386 _nodeCount++;
394387 // always false colorize
395− unsigned char newR = randomColorValue(150);
396− unsigned char newG = randomColorValue(150);
397− unsigned char newB = randomColorValue(150);
398− node->setFalseColor(newR,newG,newB);
388+ node->setFalseColor(randomColorValue(150), randomColorValue(150), randomColorValue(150));
399389 return true; // keep going!
400390 }
401391
402392 void VoxelSystem::falseColorizeRandom() {
403393 _nodeCount = 0;
404394 _tree->recurseTreeWithOperation(falseColorizeRandomOperation);
405− printLog("setting randomized false color for %d nodes\n",_nodeCount);
395+ printLog("setting randomized false color for %d nodes\n", _nodeCount);
406396 setupNewVoxelsForDrawing();
407397 }
408398
@@ -415,7 +405,7 @@ bool VoxelSystem::trueColorizeOperation(VoxelNode* node, void* extraData) { · 6 unmodified lines
415405 void VoxelSystem::trueColorize() {
416406 _nodeCount = 0;
417407 _tree->recurseTreeWithOperation(trueColorizeOperation);
418− printLog("setting true color for %d nodes\n",_nodeCount);
408+ printLog("setting true color for %d nodes\n", _nodeCount);
419409 setupNewVoxelsForDrawing();
420410 }
421411
@@ -426,10 +416,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData) · 4 unmodified lines
426416 if (node->isColored()) {
427417 if (!node->isInView(*viewFrustum)) {
428418 // Out of view voxels are colored RED
429− unsigned char newR = 255;
430− unsigned char newG = 0;
431− unsigned char newB = 0;
432− node->setFalseColor(newR,newG,newB);
419+ node->setFalseColor(255, 0, 0);
433420 }
434421 }
435422 return true; // keep going!
@@ -438,7 +425,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData) · 2 unmodified lines
438425 void VoxelSystem::falseColorizeInView(ViewFrustum* viewFrustum) {
439426 _nodeCount = 0;
440427 _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum);
441− printLog("setting in view false color for %d nodes\n",_nodeCount);
428+ printLog("setting in view false color for %d nodes\n", _nodeCount);
442429 setupNewVoxelsForDrawing();
443430 }
444431
@@ -448,17 +435,14 @@ bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, void* · 3 unmodified lines
448435 if (node->isColored()) {
449436 float distance = node->distanceToCamera(*viewFrustum);
450437 _nodeCount++;
451− float distanceRatio = (_minDistance==_maxDistance) ? 1 : (distance - _minDistance)/(_maxDistance - _minDistance);
438+ float distanceRatio = (_minDistance == _maxDistance) ? 1 : (distance - _minDistance) / (_maxDistance - _minDistance);
452439
453440 // We want to colorize this in 16 bug chunks of color
454441 const unsigned char maxColor = 255;
455442 const unsigned char colorBands = 16;
456443 const unsigned char gradientOver = 128;
457− unsigned char colorBand = (colorBands*distanceRatio);
458− unsigned char newR = (colorBand*(gradientOver/colorBands))+(maxColor-gradientOver);
459− unsigned char newG = 0;
460− unsigned char newB = 0;
461− node->setFalseColor(newR,newG,newB);
444+ unsigned char colorBand = (colorBands * distanceRatio);
445+ node->setFalseColor((colorBand * (gradientOver / colorBands)) + (maxColor - gradientOver), 0, 0);
462446 }
463447 return true; // keep going!
464448 }
@@ -491,10 +475,10 @@ void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) { · 26 unmodified lines
491475 _maxDistance = 0.0;
492476 _minDistance = FLT_MAX;
493477 _tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation,(void*)viewFrustum);
494− printLog("determining distance range for %d nodes\n",_nodeCount);
478+ printLog("determining distance range for %d nodes\n", _nodeCount);
495479 _nodeCount = 0;
496480 _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum);
497− printLog("setting in distance false color for %d nodes\n",_nodeCount);
481+ printLog("setting in distance false color for %d nodes\n", _nodeCount);
498482 setupNewVoxelsForDrawing();
499483 }
500484