mirror of
https://github.com/overte-org/overte.git
synced 2025-07-24 19:25:21 +02:00
added method for general subtree change bookkeeping
This commit is contained in:
parent
66ebb7d01c
commit
ae3db89f63
4 changed files with 28 additions and 4 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "VoxelNode.h"
|
#include "VoxelNode.h"
|
||||||
|
#include "VoxelTree.h"
|
||||||
#include "VoxelConstants.h"
|
#include "VoxelConstants.h"
|
||||||
#include "OctalCode.h"
|
#include "OctalCode.h"
|
||||||
#include "AABox.h"
|
#include "AABox.h"
|
||||||
|
@ -61,6 +62,22 @@ VoxelNode::~VoxelNode() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method is called by VoxelTree when the subtree below this node
|
||||||
|
// is known to have changed. It's intended to be used as a place to do
|
||||||
|
// bookkeeping that a node may need to do when the subtree below it has
|
||||||
|
// changed. However, you should hopefully make your bookkeeping relatively
|
||||||
|
// localized, because this method will get called for every node in an
|
||||||
|
// recursive unwinding case like delete or add voxel
|
||||||
|
void VoxelNode::handleSubtreeChanged(VoxelTree* myTree) {
|
||||||
|
markWithChangedTime();
|
||||||
|
|
||||||
|
// here's a good place to do color re-averaging...
|
||||||
|
if (myTree->getShouldReaverage()) {
|
||||||
|
setColorFromAverageOfChildren();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void VoxelNode::setShouldRender(bool shouldRender) {
|
void VoxelNode::setShouldRender(bool shouldRender) {
|
||||||
// if shouldRender is changing, then consider ourselves dirty
|
// if shouldRender is changing, then consider ourselves dirty
|
||||||
if (shouldRender != _shouldRender) {
|
if (shouldRender != _shouldRender) {
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#include "ViewFrustum.h"
|
#include "ViewFrustum.h"
|
||||||
#include "VoxelConstants.h"
|
#include "VoxelConstants.h"
|
||||||
|
|
||||||
|
class VoxelTree; // forward delclaration
|
||||||
|
|
||||||
typedef unsigned char colorPart;
|
typedef unsigned char colorPart;
|
||||||
typedef unsigned char nodeColor[4];
|
typedef unsigned char nodeColor[4];
|
||||||
typedef unsigned char rgbColor[3];
|
typedef unsigned char rgbColor[3];
|
||||||
|
@ -79,6 +81,7 @@ public:
|
||||||
void clearDirtyBit() { _isDirty = false; };
|
void clearDirtyBit() { _isDirty = false; };
|
||||||
bool hasChangedSince(double time) const { return (_lastChanged > time); };
|
bool hasChangedSince(double time) const { return (_lastChanged > time); };
|
||||||
void markWithChangedTime() { _lastChanged = usecTimestampNow(); };
|
void markWithChangedTime() { _lastChanged = usecTimestampNow(); };
|
||||||
|
void handleSubtreeChanged(VoxelTree* myTree);
|
||||||
|
|
||||||
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); };
|
||||||
|
|
|
@ -388,9 +388,10 @@ void VoxelTree::deleteVoxelCodeFromTreeRecursion(VoxelNode* node, void* extraDat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the lower level did some work, then we need to track our lastChanged status.
|
// If the lower level did some work, then we need to let this node know, so it can
|
||||||
|
// do any bookkeeping it wants to, like color re-averaging, time stamp marking, etc
|
||||||
if (args->pathChanged) {
|
if (args->pathChanged) {
|
||||||
node->markWithChangedTime();
|
node->handleSubtreeChanged(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,9 +483,10 @@ void VoxelTree::readCodeColorBufferToTreeRecursion(VoxelNode* node, void* extraD
|
||||||
|
|
||||||
// Unwinding...
|
// Unwinding...
|
||||||
|
|
||||||
// If the lower level did some work, then we need to track our lastChanged status.
|
// If the lower level did some work, then we need to let this node know, so it can
|
||||||
|
// do any bookkeeping it wants to, like color re-averaging, time stamp marking, etc
|
||||||
if (args->pathChanged) {
|
if (args->pathChanged) {
|
||||||
node->markWithChangedTime();
|
node->handleSubtreeChanged(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,8 @@ public:
|
||||||
void copySubTreeIntoNewTree(VoxelNode* startNode, VoxelTree* destinationTree, bool rebaseToRoot);
|
void copySubTreeIntoNewTree(VoxelNode* startNode, VoxelTree* destinationTree, bool rebaseToRoot);
|
||||||
void copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelNode* destinationNode);
|
void copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelNode* destinationNode);
|
||||||
|
|
||||||
|
bool getShouldReaverage() const { return _shouldReaverage; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void deleteVoxelCodeFromTreeRecursion(VoxelNode* node, void* extraData);
|
void deleteVoxelCodeFromTreeRecursion(VoxelNode* node, void* extraData);
|
||||||
void readCodeColorBufferToTreeRecursion(VoxelNode* node, void* extraData);
|
void readCodeColorBufferToTreeRecursion(VoxelNode* node, void* extraData);
|
||||||
|
|
Loading…
Reference in a new issue