mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
Gather and print out some stats after loading the data.
This commit is contained in:
parent
f9036dbaec
commit
3b7945fc14
3 changed files with 49 additions and 11 deletions
|
@ -226,19 +226,22 @@ void MetavoxelPersister::load() {
|
|||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
QDebug debug = qDebug() << "Reading from" << SAVE_FILE << "...";
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QDataStream inStream(&file);
|
||||
Bitstream in(inStream);
|
||||
MetavoxelData data;
|
||||
try {
|
||||
in >> data;
|
||||
} catch (const BitstreamException& e) {
|
||||
debug << "failed, " << e.getDescription();
|
||||
return;
|
||||
{
|
||||
QDebug debug = qDebug() << "Reading from" << SAVE_FILE << "...";
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QDataStream inStream(&file);
|
||||
Bitstream in(inStream);
|
||||
try {
|
||||
in >> data;
|
||||
} catch (const BitstreamException& e) {
|
||||
debug << "failed, " << e.getDescription();
|
||||
return;
|
||||
}
|
||||
QMetaObject::invokeMethod(_server, "setData", Q_ARG(const MetavoxelData&, data));
|
||||
debug << "done.";
|
||||
}
|
||||
QMetaObject::invokeMethod(_server, "setData", Q_ARG(const MetavoxelData&, data));
|
||||
debug << "done.";
|
||||
data.dumpStats();
|
||||
}
|
||||
|
||||
void MetavoxelPersister::save(const MetavoxelData& data) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
//
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebugStateSaver>
|
||||
#include <QScriptEngine>
|
||||
#include <QtDebug>
|
||||
|
||||
|
@ -627,6 +628,25 @@ bool MetavoxelData::deepEquals(const MetavoxelData& other, const MetavoxelLOD& l
|
|||
return true;
|
||||
}
|
||||
|
||||
void MetavoxelData::dumpStats(QDebug debug) const {
|
||||
QDebugStateSaver saver(debug);
|
||||
debug.nospace() << "[size=" << _size << ", roots=[";
|
||||
int totalInternal = 0, totalLeaves = 0;
|
||||
for (QHash<AttributePointer, MetavoxelNode*>::const_iterator it = _roots.constBegin(); it != _roots.constEnd(); it++) {
|
||||
if (it != _roots.constBegin()) {
|
||||
debug << ", ";
|
||||
}
|
||||
debug << it.key()->getName() << " (" << it.key()->metaObject()->className() << "): ";
|
||||
int internal = 0, leaves = 0;
|
||||
it.value()->countDescendants(internal, leaves);
|
||||
debug << internal << " internal, " << leaves << " leaves, " << (internal + leaves) << " total";
|
||||
totalInternal += internal;
|
||||
totalLeaves += leaves;
|
||||
}
|
||||
debug << "], totalInternal=" << totalInternal << ", totalLeaves=" << totalLeaves <<
|
||||
", grandTotal=" << (totalInternal + totalLeaves) << "]";
|
||||
}
|
||||
|
||||
bool MetavoxelData::operator==(const MetavoxelData& other) const {
|
||||
return _size == other._size && _roots == other._roots;
|
||||
}
|
||||
|
@ -1061,6 +1081,17 @@ void MetavoxelNode::getSpanners(const AttributePointer& attribute, const glm::ve
|
|||
}
|
||||
}
|
||||
|
||||
void MetavoxelNode::countDescendants(int& internalNodes, int& leaves) const {
|
||||
if (isLeaf()) {
|
||||
leaves++;
|
||||
return;
|
||||
}
|
||||
internalNodes++;
|
||||
for (int i = 0; i < CHILD_COUNT; i++) {
|
||||
_children[i]->countDescendants(internalNodes, leaves);
|
||||
}
|
||||
}
|
||||
|
||||
int MetavoxelVisitor::encodeOrder(int first, int second, int third, int fourth,
|
||||
int fifth, int sixth, int seventh, int eighth) {
|
||||
return first | (second << 3) | (third << 6) | (fourth << 9) |
|
||||
|
|
|
@ -125,6 +125,8 @@ public:
|
|||
/// shallow comparison).
|
||||
bool deepEquals(const MetavoxelData& other, const MetavoxelLOD& lod = MetavoxelLOD()) const;
|
||||
|
||||
void dumpStats(QDebug debug = QDebug(QtDebugMsg)) const;
|
||||
|
||||
bool operator==(const MetavoxelData& other) const;
|
||||
bool operator!=(const MetavoxelData& other) const;
|
||||
|
||||
|
@ -221,6 +223,8 @@ public:
|
|||
void getSpanners(const AttributePointer& attribute, const glm::vec3& minimum,
|
||||
float size, const MetavoxelLOD& lod, SharedObjectSet& results) const;
|
||||
|
||||
void countDescendants(int& internalNodes, int& leaves) const;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(MetavoxelNode)
|
||||
|
||||
|
|
Loading…
Reference in a new issue