added removeChildAtIndex() which removes a node, but doesn't delete it

This commit is contained in:
ZappoMan 2013-05-06 11:02:28 -07:00
parent 17b137cc53
commit e0d040a73b
2 changed files with 10 additions and 0 deletions

View file

@ -89,6 +89,15 @@ void VoxelNode::deleteChildAtIndex(int childIndex) {
}
}
// does not delete the node!
VoxelNode* VoxelNode::removeChildAtIndex(int childIndex) {
VoxelNode* returnedChild = _children[childIndex];
if (_children[childIndex]) {
_children[childIndex] = NULL;
}
return returnedChild;
}
void VoxelNode::addChildAtIndex(int childIndex) {
if (!_children[childIndex]) {
_children[childIndex] = new VoxelNode(childOctalCode(_octalCode, childIndex));

View file

@ -43,6 +43,7 @@ public:
unsigned char* getOctalCode() const { return _octalCode; };
VoxelNode* getChildAtIndex(int i) const { return _children[i]; };
void deleteChildAtIndex(int childIndex);
VoxelNode* removeChildAtIndex(int childIndex);
void addChildAtIndex(int childIndex);
void setColorFromAverageOfChildren();
void setRandomColor(int minimumBrightness);