diff --git a/SvoViewer/src/Render.cpp b/SvoViewer/src/Render.cpp index cb6ddd25c9..396bfad0b1 100755 --- a/SvoViewer/src/Render.cpp +++ b/SvoViewer/src/Render.cpp @@ -51,9 +51,9 @@ bool SvoViewer::PointRenderAssemblePerVoxel(OctreeElement* node, void* extraData center *= 100.0; args->buffer[args->count] = center; int cCount = args->count * 3; - args->colorBuffer[cCount] = voxel->getTrueColor()[0]; - args->colorBuffer[cCount+1] = voxel->getTrueColor()[1]; - args->colorBuffer[cCount+2] = voxel->getTrueColor()[2]; + args->colorBuffer[cCount] = voxel->getColor()[0]; + args->colorBuffer[cCount+1] = voxel->getColor()[1]; + args->colorBuffer[cCount+2] = voxel->getColor()[2]; args->count++; return true; // keep going! } @@ -189,7 +189,7 @@ bool SvoViewer::VoxelRenderAssemblePerVoxel(OctreeElement* node, void* extraData int totalNodesProcessedSinceLastFlush = args->leafCount - args->lastBufferSegmentStart; // ack, one of these components is flags, not alpha int cCount = totalNodesProcessedSinceLastFlush * 4; // Place it relative to the current segment. - unsigned char col[4] = {voxel->getTrueColor()[0], voxel->getTrueColor()[1], voxel->getTrueColor()[2], 1}; + unsigned char col[4] = {voxel->getColor()[0], voxel->getColor()[1], voxel->getColor()[2], 1}; for(int i = 0; i < GLOBAL_NORMALS_VERTICES_PER_VOXEL; i++) memcpy(&args->colorBuffer[cCount+i*4], col, sizeof(col)); @@ -582,9 +582,9 @@ bool SvoViewer::VoxelOptRenderAssemblePerVoxel(OctreeElement* node, void* extraD args->vtxBuffer[args->vtxCount].position *= 100; args->vtxBuffer[args->vtxCount].position.x -= 25; args->vtxBuffer[args->vtxCount].position.y -= 4; - args->vtxBuffer[args->vtxCount].color[0] = voxel->getTrueColor()[0]; - args->vtxBuffer[args->vtxCount].color[1] = voxel->getTrueColor()[1]; - args->vtxBuffer[args->vtxCount].color[2] = voxel->getTrueColor()[2]; + args->vtxBuffer[args->vtxCount].color[0] = voxel->getColor()[0]; + args->vtxBuffer[args->vtxCount].color[1] = voxel->getColor()[1]; + args->vtxBuffer[args->vtxCount].color[2] = voxel->getColor()[2]; args->vtxBuffer[args->vtxCount].color[3] = 1; args->bounds.AddToSet(args->vtxBuffer[args->vtxCount].position); args->vtxCount++; diff --git a/SvoViewer/src/Render2.cpp b/SvoViewer/src/Render2.cpp index 7765aa288b..976dc1ee36 100755 --- a/SvoViewer/src/Render2.cpp +++ b/SvoViewer/src/Render2.cpp @@ -148,9 +148,9 @@ bool SvoViewer::VoxelOpt2RenderAssemblePerVoxel(OctreeElement* node, void* extra args->vtxBuffer[args->vtxCount].position *= 100; args->vtxBuffer[args->vtxCount].position.x -= 25; args->vtxBuffer[args->vtxCount].position.y -= 4; - args->vtxBuffer[args->vtxCount].color[0] = voxel->getTrueColor()[0]; - args->vtxBuffer[args->vtxCount].color[1] = voxel->getTrueColor()[1]; - args->vtxBuffer[args->vtxCount].color[2] = voxel->getTrueColor()[2]; + args->vtxBuffer[args->vtxCount].color[0] = voxel->getColor()[0]; + args->vtxBuffer[args->vtxCount].color[1] = voxel->getColor()[1]; + args->vtxBuffer[args->vtxCount].color[2] = voxel->getColor()[2]; args->vtxBuffer[args->vtxCount].color[3] = 1; cubeVerts[i] = args->vtxBuffer[args->vtxCount].position; args->vtxCount++; diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 6155ebdcd4..f91e6eb1ff 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -2117,15 +2117,9 @@ bool VoxelSystem::hideAllSubTreeOperation(OctreeElement* element, void* extraDat args->nodesOutside++; if (voxel->isKnownBufferIndex()) { args->nodesRemoved++; - bool falseColorize = false; - if (falseColorize) { - voxel->setFalseColor(255,0,0); // false colorize - } else { - VoxelSystem* thisVoxelSystem = args->thisVoxelSystem; - thisVoxelSystem->_voxelsUpdated += thisVoxelSystem->forceRemoveNodeFromArrays(voxel); - thisVoxelSystem->setupNewVoxelsForDrawingSingleNode(); - } - + VoxelSystem* thisVoxelSystem = args->thisVoxelSystem; + thisVoxelSystem->_voxelsUpdated += thisVoxelSystem->forceRemoveNodeFromArrays(voxel); + thisVoxelSystem->setupNewVoxelsForDrawingSingleNode(); } return true; @@ -2158,20 +2152,9 @@ bool VoxelSystem::showAllSubTreeOperation(OctreeElement* element, void* extraDat voxel->setShouldRender(shouldRender); if (shouldRender && !voxel->isKnownBufferIndex()) { - bool falseColorize = false; - if (falseColorize) { - voxel->setFalseColor(0,0,255); // false colorize - } // These are both needed to force redraw... voxel->setDirtyBit(); voxel->markWithChangedTime(); - // and this? -// no, not needed, because markWithChangedTime notifies hooks, which calls elementUpdated, which calls updateNodeInArrays -// { -// VoxelSystem* thisVoxelSystem = args->thisVoxelSystem; -// thisVoxelSystem->_voxelsUpdated += thisVoxelSystem->updateNodeInArrays(voxel, true, true); -// thisVoxelSystem->setupNewVoxelsForDrawingSingleNode(); -// } args->nodesShown++; } diff --git a/libraries/voxels/src/VoxelTreeElement.cpp b/libraries/voxels/src/VoxelTreeElement.cpp index 3f8af58afd..5609e279d7 100644 --- a/libraries/voxels/src/VoxelTreeElement.cpp +++ b/libraries/voxels/src/VoxelTreeElement.cpp @@ -39,8 +39,7 @@ void VoxelTreeElement::init(unsigned char* octalCode) { setVoxelSystem(NULL); setBufferIndex(GLBUFFER_INDEX_UNKNOWN); _falseColored = false; // assume true color - _currentColor[0] = _currentColor[1] = _currentColor[2] = _currentColor[3] = 0; - _trueColor[0] = _trueColor[1] = _trueColor[2] = _trueColor[3] = 0; + _color[0] = _color[1] = _color[2] = _color[3] = 0; _density = 0.0f; OctreeElement::init(octalCode); _voxelMemoryUsage += sizeof(VoxelTreeElement); @@ -115,39 +114,9 @@ void VoxelTreeElement::setVoxelSystem(VoxelSystem* voxelSystem) { } } - -void VoxelTreeElement::setFalseColor(colorPart red, colorPart green, colorPart blue) { - if (_falseColored != true || _currentColor[0] != red || _currentColor[1] != green || _currentColor[2] != blue) { - _falseColored=true; - _currentColor[0] = red; - _currentColor[1] = green; - _currentColor[2] = blue; - _currentColor[3] = 1; // XXXBHG - False colors are always considered set - _isDirty = true; - markWithChangedTime(); - } -} - -void VoxelTreeElement::setFalseColored(bool isFalseColored) { - if (_falseColored != isFalseColored) { - // if we were false colored, and are no longer false colored, then swap back - if (_falseColored && !isFalseColored) { - memcpy(&_currentColor,&_trueColor,sizeof(nodeColor)); - } - _falseColored = isFalseColored; - _isDirty = true; - _density = 1.0f; // If color set, assume leaf, re-averaging will update density if needed. - markWithChangedTime(); - } -}; - - void VoxelTreeElement::setColor(const nodeColor& color) { - if (_trueColor[0] != color[0] || _trueColor[1] != color[1] || _trueColor[2] != color[2]) { - memcpy(&_trueColor,&color,sizeof(nodeColor)); - if (!_falseColored) { - memcpy(&_currentColor,&color,sizeof(nodeColor)); - } + if (_color[0] != color[0] || _color[1] != color[1] || _color[2] != color[2]) { + memcpy(&_color,&color,sizeof(nodeColor)); _isDirty = true; if (color[3]) { _density = 1.0f; // If color set, assume leaf, re-averaging will update density if needed. @@ -168,7 +137,7 @@ void VoxelTreeElement::calculateAverageFromChildren() { VoxelTreeElement* childAt = getChildAtIndex(i); if (childAt && childAt->isColored()) { for (int j = 0; j < 3; j++) { - colorArray[j] += childAt->getTrueColor()[j]; // color averaging should always be based on true colors + colorArray[j] += childAt->getColor()[j]; // color averaging should always be based on true colors } colorArray[3]++; } @@ -260,9 +229,9 @@ bool VoxelTreeElement::findSpherePenetration(const glm::vec3& center, float radi voxelDetails->y = _box.getCorner().y; voxelDetails->z = _box.getCorner().z; voxelDetails->s = _box.getScale(); - voxelDetails->red = getTrueColor()[RED_INDEX]; - voxelDetails->green = getTrueColor()[GREEN_INDEX]; - voxelDetails->blue = getTrueColor()[BLUE_INDEX]; + voxelDetails->red = getColor()[RED_INDEX]; + voxelDetails->green = getColor()[GREEN_INDEX]; + voxelDetails->blue = getColor()[BLUE_INDEX]; *penetratedObject = (void*)voxelDetails; } diff --git a/libraries/voxels/src/VoxelTreeElement.h b/libraries/voxels/src/VoxelTreeElement.h index 83544bea32..c88fd6d207 100644 --- a/libraries/voxels/src/VoxelTreeElement.h +++ b/libraries/voxels/src/VoxelTreeElement.h @@ -57,14 +57,10 @@ public: virtual bool isRendered() const { return isKnownBufferIndex(); } - bool isColored() const { return _trueColor[3] == 1; } + bool isColored() const { return _color[3] == 1; } - void setFalseColor(colorPart red, colorPart green, colorPart blue); - void setFalseColored(bool isFalseColored); - bool getFalseColored() { return _falseColored; } void setColor(const nodeColor& color); - const nodeColor& getTrueColor() const { return _trueColor; } - const nodeColor& getColor() const { return _currentColor; } + const nodeColor& getColor() const { return _color; } void setDensity(float density) { _density = density; } float getDensity() const { return _density; } @@ -92,8 +88,7 @@ protected: float _density; /// Client and server, If leaf: density = 1, if internal node: 0-1 density of voxels inside, 4 bytes - nodeColor _trueColor; /// Client and server, true color of this voxel, 4 bytes - nodeColor _currentColor; /// Client only, false color of this voxel, 4 bytes + nodeColor _color; /// Client and server, true color of this voxel, 4 bytes private: unsigned char _exteriorOcclusions; ///< Exterior shared partition boundaries that are completely occupied diff --git a/voxel-edit/src/main.cpp b/voxel-edit/src/main.cpp index e2529a4599..b1dde051ae 100644 --- a/voxel-edit/src/main.cpp +++ b/voxel-edit/src/main.cpp @@ -163,9 +163,9 @@ bool copyAndFillOperation(OctreeElement* element, void* extraData) { float y = voxel->getCorner().y; float z = voxel->getCorner().z; float s = voxel->getScale(); - unsigned char red = voxel->getTrueColor()[RED_INDEX]; - unsigned char green = voxel->getTrueColor()[GREEN_INDEX]; - unsigned char blue = voxel->getTrueColor()[BLUE_INDEX]; + unsigned char red = voxel->getColor()[RED_INDEX]; + unsigned char green = voxel->getColor()[GREEN_INDEX]; + unsigned char blue = voxel->getColor()[BLUE_INDEX]; bool destructive = true; args->destinationTree->createVoxel(x, y, z, s, red, green, blue, destructive);