mirror of
https://github.com/overte-org/overte.git
synced 2025-08-16 14:31:48 +02:00
added voxel-data compression code to see what the sizes are like
This commit is contained in:
parent
a251ae7f50
commit
59f68f5625
2 changed files with 26 additions and 0 deletions
|
@ -9,6 +9,9 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QByteArray>
|
||||
|
||||
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
|
||||
|
@ -89,6 +92,7 @@ void RenderablePolyVoxEntityItem::setSphereInVolume(glm::vec3 center, float radi
|
|||
}
|
||||
}
|
||||
}
|
||||
compressVolumeData();
|
||||
}
|
||||
|
||||
void RenderablePolyVoxEntityItem::createSphereInVolume(glm::vec3 centerVoxelCoords, float radiusVoxelCoords) {
|
||||
|
@ -292,3 +296,23 @@ bool RenderablePolyVoxEntityItem::findDetailedRayIntersection(const glm::vec3& o
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void RenderablePolyVoxEntityItem::compressVolumeData() {
|
||||
int rawSize = _volData->getDepth() * _volData->getHeight() * _volData->getWidth();
|
||||
QByteArray uncompressedData = QByteArray(rawSize, '\0');
|
||||
|
||||
for (int z = 0; z < _volData->getDepth(); z++) {
|
||||
for (int y = 0; y < _volData->getHeight(); y++) {
|
||||
for (int x = 0; x < _volData->getWidth(); x++) {
|
||||
uint8_t uVoxelValue = _volData->getVoxelAt(x, y, z);
|
||||
int uncompressedIndex = z * _volData->getHeight() * _volData->getWidth() + y * _volData->getWidth() + x;
|
||||
uncompressedData[uncompressedIndex] = uVoxelValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray compressedData = qCompress(uncompressedData, 9);
|
||||
qDebug() << "-----------------------------------------------------------------------------";
|
||||
qDebug() << "raw-size =" << rawSize << " compressed-size =" << compressedData.size();
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ public:
|
|||
void eraseSphereInVolume(glm::vec3 center, float radius);
|
||||
|
||||
private:
|
||||
void compressVolumeData();
|
||||
|
||||
PolyVox::SimpleVolume<uint8_t>* _volData = nullptr;
|
||||
model::Geometry _modelGeometry;
|
||||
bool _needsModelReload = true;
|
||||
|
|
Loading…
Reference in a new issue