mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 11:19:54 +02:00
add periodic pruning of the octree on load and save
This commit is contained in:
parent
4ea0d32c8c
commit
13e358549d
5 changed files with 41 additions and 7 deletions
|
@ -1069,6 +1069,24 @@ void EntityTree::dumpTree() {
|
||||||
recurseTreeWithOperator(&theOperator);
|
recurseTreeWithOperator(&theOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PruneOperator : public RecurseOctreeOperator {
|
||||||
|
public:
|
||||||
|
virtual bool preRecursion(OctreeElement* element) { return true; }
|
||||||
|
virtual bool postRecursion(OctreeElement* element);
|
||||||
|
};
|
||||||
|
|
||||||
|
bool PruneOperator::postRecursion(OctreeElement* element) {
|
||||||
|
EntityTreeElement* entityTreeElement = static_cast<EntityTreeElement*>(element);
|
||||||
|
entityTreeElement->pruneChildren();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EntityTree::pruneTree() {
|
||||||
|
// First, look for the existing entity in the tree..
|
||||||
|
PruneOperator theOperator;
|
||||||
|
recurseTreeWithOperator(&theOperator);
|
||||||
|
}
|
||||||
|
|
||||||
void EntityTree::sendEntities(EntityEditPacketSender* packetSender, EntityTree* localTree, float x, float y, float z) {
|
void EntityTree::sendEntities(EntityEditPacketSender* packetSender, EntityTree* localTree, float x, float y, float z) {
|
||||||
SendEntitiesOperationArgs args;
|
SendEntitiesOperationArgs args;
|
||||||
args.packetSender = packetSender;
|
args.packetSender = packetSender;
|
||||||
|
|
|
@ -131,6 +131,7 @@ public:
|
||||||
void resetContainingElement(const EntityItemID& entityItemID, EntityTreeElement* element);
|
void resetContainingElement(const EntityItemID& entityItemID, EntityTreeElement* element);
|
||||||
void debugDumpMap();
|
void debugDumpMap();
|
||||||
virtual void dumpTree();
|
virtual void dumpTree();
|
||||||
|
virtual void pruneTree();
|
||||||
|
|
||||||
void sendEntities(EntityEditPacketSender* packetSender, EntityTree* localTree, float x, float y, float z);
|
void sendEntities(EntityEditPacketSender* packetSender, EntityTree* localTree, float x, float y, float z);
|
||||||
|
|
||||||
|
|
|
@ -812,11 +812,20 @@ bool EntityTreeElement::pruneChildren() {
|
||||||
|
|
||||||
void EntityTreeElement::debugDump() {
|
void EntityTreeElement::debugDump() {
|
||||||
qDebug() << "EntityTreeElement...";
|
qDebug() << "EntityTreeElement...";
|
||||||
qDebug() << "entity count:" << _entityItems->size();
|
AACube temp = getAACube();
|
||||||
qDebug() << "cube:" << getAACube();
|
temp.scale((float)TREE_SCALE);
|
||||||
for (uint16_t i = 0; i < _entityItems->size(); i++) {
|
qDebug() << " cube:" << temp;
|
||||||
EntityItem* entity = (*_entityItems)[i];
|
qDebug() << " has child elements:" << getChildCount();
|
||||||
entity->debugDump();
|
if (_entityItems->size()) {
|
||||||
|
qDebug() << " has entities:" << _entityItems->size();
|
||||||
|
qDebug() << "--------------------------------------------------";
|
||||||
|
for (uint16_t i = 0; i < _entityItems->size(); i++) {
|
||||||
|
EntityItem* entity = (*_entityItems)[i];
|
||||||
|
entity->debugDump();
|
||||||
|
}
|
||||||
|
qDebug() << "--------------------------------------------------";
|
||||||
|
} else {
|
||||||
|
qDebug() << " NO entities!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -352,6 +352,7 @@ public:
|
||||||
void setIsClient(bool isClient) { _isServer = !isClient; }
|
void setIsClient(bool isClient) { _isServer = !isClient; }
|
||||||
|
|
||||||
virtual void dumpTree() { };
|
virtual void dumpTree() { };
|
||||||
|
virtual void pruneTree() { };
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void importSize(float x, float y, float z);
|
void importSize(float x, float y, float z);
|
||||||
|
|
|
@ -36,6 +36,7 @@ bool OctreePersistThread::process() {
|
||||||
{
|
{
|
||||||
PerformanceWarning warn(true, "Loading Octree File", true);
|
PerformanceWarning warn(true, "Loading Octree File", true);
|
||||||
persistantFileRead = _tree->readFromSVOFile(_filename.toLocal8Bit().constData());
|
persistantFileRead = _tree->readFromSVOFile(_filename.toLocal8Bit().constData());
|
||||||
|
_tree->pruneTree();
|
||||||
}
|
}
|
||||||
_tree->unlock();
|
_tree->unlock();
|
||||||
|
|
||||||
|
@ -80,10 +81,14 @@ bool OctreePersistThread::process() {
|
||||||
// check the dirty bit and persist here...
|
// check the dirty bit and persist here...
|
||||||
_lastCheck = usecTimestampNow();
|
_lastCheck = usecTimestampNow();
|
||||||
if (_tree->isDirty()) {
|
if (_tree->isDirty()) {
|
||||||
qDebug() << "saving Octrees to file " << _filename << "...";
|
qDebug() << "pruning Octree before saving...";
|
||||||
|
_tree->pruneTree();
|
||||||
|
qDebug() << "DONE pruning Octree before saving...";
|
||||||
|
|
||||||
|
qDebug() << "saving Octree to file " << _filename << "...";
|
||||||
_tree->writeToSVOFile(_filename.toLocal8Bit().constData());
|
_tree->writeToSVOFile(_filename.toLocal8Bit().constData());
|
||||||
_tree->clearDirtyBit(); // tree is clean after saving
|
_tree->clearDirtyBit(); // tree is clean after saving
|
||||||
qDebug("DONE saving Octrees to file...");
|
qDebug("DONE saving Octree to file...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue