add markWithChangedTime() method as public method

Conflicts:
	libraries/voxels/src/VoxelNode.cpp
	libraries/voxels/src/VoxelNode.h
This commit is contained in:
ZappoMan 2013-06-05 10:31:24 -07:00
parent 873ae85d4e
commit 4f1131fc97
2 changed files with 14 additions and 1 deletions

View file

@ -46,7 +46,7 @@ void VoxelNode::init(unsigned char * octalCode) {
_isDirty = true; _isDirty = true;
_shouldRender = false; _shouldRender = false;
_isStagedForDeletion = false; _isStagedForDeletion = false;
markWithChangedTime();
calculateAABox(); calculateAABox();
} }
@ -66,6 +66,7 @@ void VoxelNode::setShouldRender(bool shouldRender) {
if (shouldRender != _shouldRender) { if (shouldRender != _shouldRender) {
_shouldRender = shouldRender; _shouldRender = shouldRender;
_isDirty = true; _isDirty = true;
markWithChangedTime();
} }
} }
@ -89,6 +90,7 @@ void VoxelNode::deleteChildAtIndex(int childIndex) {
delete _children[childIndex]; delete _children[childIndex];
_children[childIndex] = NULL; _children[childIndex] = NULL;
_isDirty = true; _isDirty = true;
markWithChangedTime();
_childCount--; _childCount--;
} }
} }
@ -99,6 +101,7 @@ VoxelNode* VoxelNode::removeChildAtIndex(int childIndex) {
if (_children[childIndex]) { if (_children[childIndex]) {
_children[childIndex] = NULL; _children[childIndex] = NULL;
_isDirty = true; _isDirty = true;
markWithChangedTime();
_childCount--; _childCount--;
} }
return returnedChild; return returnedChild;
@ -108,6 +111,7 @@ void VoxelNode::addChildAtIndex(int childIndex) {
if (!_children[childIndex]) { if (!_children[childIndex]) {
_children[childIndex] = new VoxelNode(childOctalCode(_octalCode, childIndex)); _children[childIndex] = new VoxelNode(childOctalCode(_octalCode, childIndex));
_isDirty = true; _isDirty = true;
markWithChangedTime();
_childCount++; _childCount++;
} }
} }
@ -135,6 +139,7 @@ void VoxelNode::safeDeepDeleteChildAtIndex(int childIndex, bool& stagedForDeleti
deleteChildAtIndex(childIndex); deleteChildAtIndex(childIndex);
_isDirty = true; _isDirty = true;
} }
markWithChangedTime();
} }
} }
@ -178,6 +183,7 @@ void VoxelNode::setFalseColor(colorPart red, colorPart green, colorPart blue) {
_currentColor[2] = blue; _currentColor[2] = blue;
_currentColor[3] = 1; // XXXBHG - False colors are always considered set _currentColor[3] = 1; // XXXBHG - False colors are always considered set
_isDirty = true; _isDirty = true;
markWithChangedTime();
} }
} }
@ -189,6 +195,7 @@ void VoxelNode::setFalseColored(bool isFalseColored) {
} }
_falseColored = isFalseColored; _falseColored = isFalseColored;
_isDirty = true; _isDirty = true;
markWithChangedTime();
} }
}; };
@ -202,6 +209,7 @@ void VoxelNode::setColor(const nodeColor& color) {
memcpy(&_currentColor,&color,sizeof(nodeColor)); memcpy(&_currentColor,&color,sizeof(nodeColor));
} }
_isDirty = true; _isDirty = true;
markWithChangedTime();
} }
} }
#endif #endif

View file

@ -9,6 +9,7 @@
#ifndef __hifi__VoxelNode__ #ifndef __hifi__VoxelNode__
#define __hifi__VoxelNode__ #define __hifi__VoxelNode__
#include <SharedUtil.h>
#include "AABox.h" #include "AABox.h"
#include "ViewFrustum.h" #include "ViewFrustum.h"
#include "VoxelConstants.h" #include "VoxelConstants.h"
@ -26,6 +27,7 @@ private:
#endif #endif
glBufferIndex _glBufferIndex; glBufferIndex _glBufferIndex;
bool _isDirty; bool _isDirty;
double _lastChanged;
bool _shouldRender; bool _shouldRender;
bool _isStagedForDeletion; bool _isStagedForDeletion;
AABox _box; AABox _box;
@ -75,6 +77,9 @@ public:
void printDebugDetails(const char* label) const; void printDebugDetails(const char* label) const;
bool isDirty() const { return _isDirty; }; bool isDirty() const { return _isDirty; };
void clearDirtyBit() { _isDirty = false; }; void clearDirtyBit() { _isDirty = false; };
bool hasChangedSince(double time) const { return (_lastChanged > time); };
void markWithChangedTime() { _lastChanged = usecTimestampNow(); };
glBufferIndex getBufferIndex() const { return _glBufferIndex; }; glBufferIndex getBufferIndex() const { return _glBufferIndex; };
bool isKnownBufferIndex() const { return (_glBufferIndex != GLBUFFER_INDEX_UNKNOWN); }; bool isKnownBufferIndex() const { return (_glBufferIndex != GLBUFFER_INDEX_UNKNOWN); };
void setBufferIndex(glBufferIndex index) { _glBufferIndex = index; }; void setBufferIndex(glBufferIndex index) { _glBufferIndex = index; };