mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:18:24 +02:00
fix delete local voxels in case of last voxel server going away
This commit is contained in:
parent
8addfdc433
commit
48e35ec6cb
2 changed files with 19 additions and 5 deletions
|
@ -63,6 +63,7 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels) :
|
||||||
_abandonedVBOSlots = 0;
|
_abandonedVBOSlots = 0;
|
||||||
_falseColorizeBySource = false;
|
_falseColorizeBySource = false;
|
||||||
_dataSourceID = UNKNOWN_NODE_ID;
|
_dataSourceID = UNKNOWN_NODE_ID;
|
||||||
|
_voxelServerCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::nodeDeleted(VoxelNode* node) {
|
void VoxelSystem::nodeDeleted(VoxelNode* node) {
|
||||||
|
@ -1538,6 +1539,7 @@ void VoxelSystem::nodeAdded(Node* node) {
|
||||||
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
||||||
uint16_t nodeID = node->getNodeID();
|
uint16_t nodeID = node->getNodeID();
|
||||||
printf("VoxelSystem... voxel server %u added...\n", nodeID);
|
printf("VoxelSystem... voxel server %u added...\n", nodeID);
|
||||||
|
_voxelServerCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1545,8 +1547,11 @@ bool VoxelSystem::killSourceVoxelsOperation(VoxelNode* node, void* extraData) {
|
||||||
uint16_t killedNodeID = *(uint16_t*)extraData;
|
uint16_t killedNodeID = *(uint16_t*)extraData;
|
||||||
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
|
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
|
||||||
VoxelNode* childNode = node->getChildAtIndex(i);
|
VoxelNode* childNode = node->getChildAtIndex(i);
|
||||||
if (childNode && childNode->getSourceID()== killedNodeID) {
|
if (childNode) {
|
||||||
node->safeDeepDeleteChildAtIndex(i);
|
uint16_t childNodeID = childNodeID = childNode->getSourceID();
|
||||||
|
if (childNodeID == killedNodeID) {
|
||||||
|
node->safeDeepDeleteChildAtIndex(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1554,12 +1559,19 @@ bool VoxelSystem::killSourceVoxelsOperation(VoxelNode* node, void* extraData) {
|
||||||
|
|
||||||
void VoxelSystem::nodeKilled(Node* node) {
|
void VoxelSystem::nodeKilled(Node* node) {
|
||||||
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
||||||
|
_voxelServerCount--;
|
||||||
uint16_t nodeID = node->getNodeID();
|
uint16_t nodeID = node->getNodeID();
|
||||||
printf("VoxelSystem... voxel server %u removed...\n", nodeID);
|
printf("VoxelSystem... voxel server %u removed...\n", nodeID);
|
||||||
|
|
||||||
// Kill any voxels from the local tree
|
if (_voxelServerCount > 0) {
|
||||||
_tree->recurseTreeWithOperation(killSourceVoxelsOperation, &nodeID);
|
// Kill any voxels from the local tree that match this nodeID
|
||||||
_tree->setDirtyBit();
|
_tree->recurseTreeWithOperation(killSourceVoxelsOperation, &nodeID);
|
||||||
|
_tree->setDirtyBit();
|
||||||
|
} else {
|
||||||
|
// Last server, take the easy way and kill all the local voxels!
|
||||||
|
_tree->eraseAllVoxels();
|
||||||
|
_voxelsInWriteArrays = _voxelsInReadArrays = 0; // better way to do this??
|
||||||
|
}
|
||||||
setupNewVoxelsForDrawing();
|
setupNewVoxelsForDrawing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,6 +206,8 @@ private:
|
||||||
|
|
||||||
bool _falseColorizeBySource;
|
bool _falseColorizeBySource;
|
||||||
int _dataSourceID;
|
int _dataSourceID;
|
||||||
|
|
||||||
|
int _voxelServerCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue