From e93ece0f52eb06b2df3c57bd63adeacab0150692 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sun, 21 Apr 2013 19:45:54 -0700 Subject: [PATCH] Added support for NO_FALSE_COLOR define. - changed VoxelNode to have implementation option for NO_FALSE_COLOR Need some help from Stephen and/or Leo on how to make cmake support building the voxels library in NO_FALSE_COLOR mode for the server but keep false color support in the client --- libraries/voxels/src/VoxelNode.cpp | 8 +++++++- libraries/voxels/src/VoxelNode.h | 13 ++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libraries/voxels/src/VoxelNode.cpp b/libraries/voxels/src/VoxelNode.cpp index 7cae90f744..4aef3a0fe8 100644 --- a/libraries/voxels/src/VoxelNode.cpp +++ b/libraries/voxels/src/VoxelNode.cpp @@ -19,7 +19,9 @@ VoxelNode::VoxelNode() { octalCode = NULL; +#ifdef HAS_FALSE_COLOR _falseColored = false; // assume true color +#endif // default pointers to child nodes to NULL for (int i = 0; i < 8; i++) { @@ -83,6 +85,9 @@ void VoxelNode::setColorFromAverageOfChildren() { setColor(newColor); } +// Note: !NO_FALSE_COLOR implementations of setFalseColor(), setFalseColored(), and setColor() here. +// the actual NO_FALSE_COLOR version are inline in the VoxelNode.h +#ifndef NO_FALSE_COLOR // !NO_FALSE_COLOR means, does have false color void VoxelNode::setFalseColor(colorPart red, colorPart green, colorPart blue) { _falseColored=true; _currentColor[0] = red; @@ -91,7 +96,7 @@ void VoxelNode::setFalseColor(colorPart red, colorPart green, colorPart blue) { _currentColor[3] = 1; // XXXBHG - False colors are always considered set } -void VoxelNode::setFalseColored(bool isFalseColored) { +void VoxelNode::setFalseColored(bool isFalseColored) { // if we were false colored, and are no longer false colored, then swap back if (_falseColored && !isFalseColored) { memcpy(&_currentColor,&_trueColor,sizeof(nodeColor)); @@ -107,6 +112,7 @@ void VoxelNode::setColor(const nodeColor& color) { memcpy(&_currentColor,&color,sizeof(nodeColor)); } } +#endif // will detect if children are leaves AND the same color // and in that case will delete the children and make this node diff --git a/libraries/voxels/src/VoxelNode.h b/libraries/voxels/src/VoxelNode.h index 42b4331440..cf644a1fd1 100644 --- a/libraries/voxels/src/VoxelNode.h +++ b/libraries/voxels/src/VoxelNode.h @@ -17,8 +17,10 @@ typedef unsigned char nodeColor[4]; class VoxelNode { private: nodeColor _trueColor; +#ifndef NO_FALSE_COLOR // !NO_FALSE_COLOR means, does have false color nodeColor _currentColor; bool _falseColored; +#endif public: VoxelNode(); ~VoxelNode(); @@ -32,13 +34,22 @@ public: VoxelNode *children[8]; bool isColored() const { return (_trueColor[3]==1); }; + +#ifndef NO_FALSE_COLOR // !NO_FALSE_COLOR means, does have false color 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; }; +#else + void setFalseColor(colorPart red, colorPart green, colorPart blue) { /* no op */ }; + void setFalseColored(bool isFalseColored) { /* no op */ }; + bool getFalseColored() { return false; }; + void setColor(const nodeColor& color) { memcpy(_trueColor,color,sizeof(nodeColor)); }; + const nodeColor& getTrueColor() const { return _trueColor; }; + const nodeColor& getColor() const { return _trueColor; }; +#endif void getAABox(AABox& box) const; };