History

Working on voxel representations.

Andrzej Kapolka committed 12 years ago

Commit 7aa2a1d1 parent 6fbde0f5 files · +149 −78Browse files

Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 5 files). Show all

Unified · Split

interface/src/MetavoxelSystem.cpp+16−16
@@ -623,7 +623,7 @@ HeightfieldBuffer::HeightfieldBuffer(const glm::vec3& translation, float scale, · 622 unmodified lines
623 _textureTextureID(0),623 _textureTextureID(0),
624 _heightSize(glm::sqrt(height.size())),624 _heightSize(glm::sqrt(height.size())),
625 _heightIncrement(scale / (_heightSize - HEIGHT_EXTENSION)),625 _heightIncrement(scale / (_heightSize - HEIGHT_EXTENSION)),
626 _colorSize(glm::sqrt(color.size() / HeightfieldData::COLOR_BYTES)),626 _colorSize(glm::sqrt(color.size() / DataBlock::COLOR_BYTES)),
627 _colorIncrement(scale / (_colorSize - SHARED_EDGE)) {627 _colorIncrement(scale / (_colorSize - SHARED_EDGE)) {
628 628
629 _heightBounds.minimum.x -= _heightIncrement * HEIGHT_BORDER;629 _heightBounds.minimum.x -= _heightIncrement * HEIGHT_BORDER;
@@ -660,13 +660,13 @@ QByteArray HeightfieldBuffer::getUnextendedHeight() const { · 30 unmodified lines
660}660}
661 661
662QByteArray HeightfieldBuffer::getUnextendedColor() const {662QByteArray HeightfieldBuffer::getUnextendedColor() const {
663 int srcSize = glm::sqrt(_color.size() / HeightfieldData::COLOR_BYTES);663 int srcSize = glm::sqrt(_color.size() / DataBlock::COLOR_BYTES);
664 int destSize = srcSize - 1;664 int destSize = srcSize - 1;
665 QByteArray unextended(destSize * destSize * HeightfieldData::COLOR_BYTES, 0);665 QByteArray unextended(destSize * destSize * DataBlock::COLOR_BYTES, 0);
666 const char* src = _color.constData();666 const char* src = _color.constData();
667 int srcStride = srcSize * HeightfieldData::COLOR_BYTES;667 int srcStride = srcSize * DataBlock::COLOR_BYTES;
668 char* dest = unextended.data();668 char* dest = unextended.data();
669 int destStride = destSize * HeightfieldData::COLOR_BYTES;669 int destStride = destSize * DataBlock::COLOR_BYTES;
670 for (int z = 0; z < destSize; z++, src += srcStride, dest += destStride) {670 for (int z = 0; z < destSize; z++, src += srcStride, dest += destStride) {
671 memcpy(dest, src, destStride);671 memcpy(dest, src, destStride);
672 }672 }
@@ -705,7 +705,7 @@ void HeightfieldBuffer::render(bool cursor) { · 32 unmodified lines
705 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, WHITE_COLOR);705 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, WHITE_COLOR);
706 706
707 } else {707 } else {
708 int colorSize = glm::sqrt(_color.size() / HeightfieldData::COLOR_BYTES); 708 int colorSize = glm::sqrt(_color.size() / DataBlock::COLOR_BYTES);
709 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, colorSize, colorSize, 0, GL_RGB, GL_UNSIGNED_BYTE, _color.constData());709 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, colorSize, colorSize, 0, GL_RGB, GL_UNSIGNED_BYTE, _color.constData());
710 }710 }
711 711
@@ -1289,13 +1289,13 @@ int HeightfieldFetchVisitor::visit(MetavoxelInfo& info) { · 577 unmodified lines
1289 destY = (overlap.minimum.z - colorBounds.minimum.z) / colorIncrement;1289 destY = (overlap.minimum.z - colorBounds.minimum.z) / colorIncrement;
1290 destWidth = glm::ceil((overlap.maximum.x - overlap.minimum.x) / colorIncrement);1290 destWidth = glm::ceil((overlap.maximum.x - overlap.minimum.x) / colorIncrement);
1291 destHeight = glm::ceil((overlap.maximum.z - overlap.minimum.z) / colorIncrement);1291 destHeight = glm::ceil((overlap.maximum.z - overlap.minimum.z) / colorIncrement);
1292 dest = _buffer->getColor().data() + (destY * colorSize + destX) * HeightfieldData::COLOR_BYTES;1292 dest = _buffer->getColor().data() + (destY * colorSize + destX) * DataBlock::COLOR_BYTES;
1293 int destStride = colorSize * HeightfieldData::COLOR_BYTES;1293 int destStride = colorSize * DataBlock::COLOR_BYTES;
1294 int destBytes = destWidth * HeightfieldData::COLOR_BYTES;1294 int destBytes = destWidth * DataBlock::COLOR_BYTES;
1295 1295
1296 const QByteArray& srcColor = color->getContents();1296 const QByteArray& srcColor = color->getContents();
1297 srcSize = glm::sqrt(srcColor.size() / HeightfieldData::COLOR_BYTES);1297 srcSize = glm::sqrt(srcColor.size() / DataBlock::COLOR_BYTES);
1298 int srcStride = srcSize * HeightfieldData::COLOR_BYTES;1298 int srcStride = srcSize * DataBlock::COLOR_BYTES;
1299 srcIncrement = info.size / srcSize;1299 srcIncrement = info.size / srcSize;
1300 1300
1301 if (srcIncrement == colorIncrement) {1301 if (srcIncrement == colorIncrement) {
@@ -1303,7 +1303,7 @@ int HeightfieldFetchVisitor::visit(MetavoxelInfo& info) { · 1 unmodified line
1303 int srcX = (overlap.minimum.x - info.minimum.x) / srcIncrement;1303 int srcX = (overlap.minimum.x - info.minimum.x) / srcIncrement;
1304 int srcY = (overlap.minimum.z - info.minimum.z) / srcIncrement;1304 int srcY = (overlap.minimum.z - info.minimum.z) / srcIncrement;
1305 1305
1306 const char* src = srcColor.constData() + (srcY * srcSize + srcX) * HeightfieldData::COLOR_BYTES; 1306 const char* src = srcColor.constData() + (srcY * srcSize + srcX) * DataBlock::COLOR_BYTES;
1307 for (int y = 0; y < destHeight; y++, src += srcStride, dest += destStride) {1307 for (int y = 0; y < destHeight; y++, src += srcStride, dest += destStride) {
1308 memcpy(dest, src, destBytes);1308 memcpy(dest, src, destBytes);
1309 }1309 }
@@ -1315,9 +1315,9 @@ int HeightfieldFetchVisitor::visit(MetavoxelInfo& info) { · 5 unmodified lines
1315 for (int y = 0; y < destHeight; y++, dest += destStride, srcY += srcAdvance) {1315 for (int y = 0; y < destHeight; y++, dest += destStride, srcY += srcAdvance) {
1316 const char* src = srcColor.constData() + (int)srcY * srcStride;1316 const char* src = srcColor.constData() + (int)srcY * srcStride;
1317 float lineSrcX = srcX;1317 float lineSrcX = srcX;
1318 for (char* lineDest = dest, *end = dest + destBytes; lineDest != end; lineDest += HeightfieldData::COLOR_BYTES,1318 for (char* lineDest = dest, *end = dest + destBytes; lineDest != end; lineDest += DataBlock::COLOR_BYTES,
1319 lineSrcX += srcAdvance) {1319 lineSrcX += srcAdvance) {
1320 const char* lineSrc = src + (int)lineSrcX * HeightfieldData::COLOR_BYTES;1320 const char* lineSrc = src + (int)lineSrcX * DataBlock::COLOR_BYTES;
1321 lineDest[0] = lineSrc[0];1321 lineDest[0] = lineSrc[0];
1322 lineDest[1] = lineSrc[1];1322 lineDest[1] = lineSrc[1];
1323 lineDest[2] = lineSrc[2];1323 lineDest[2] = lineSrc[2];
@@ -1372,9 +1372,9 @@ int HeightfieldRegionVisitor::visit(MetavoxelInfo& info) { · 48 unmodified lines
1372 int colorContentsSize = 0;1372 int colorContentsSize = 0;
1373 if (color) {1373 if (color) {
1374 const QByteArray& colorContents = color->getContents();1374 const QByteArray& colorContents = color->getContents();
1375 int colorSize = glm::sqrt(colorContents.size() / HeightfieldData::COLOR_BYTES);1375 int colorSize = glm::sqrt(colorContents.size() / DataBlock::COLOR_BYTES);
1376 int extendedColorSize = colorSize + HeightfieldBuffer::SHARED_EDGE;1376 int extendedColorSize = colorSize + HeightfieldBuffer::SHARED_EDGE;
1377 colorContentsSize = extendedColorSize * extendedColorSize * HeightfieldData::COLOR_BYTES;1377 colorContentsSize = extendedColorSize * extendedColorSize * DataBlock::COLOR_BYTES;
1378 }1378 }
1379 1379
1380 HeightfieldTextureDataPointer texture = info.inputValues.at(2).getInlineValue<HeightfieldTextureDataPointer>();1380 HeightfieldTextureDataPointer texture = info.inputValues.at(2).getInlineValue<HeightfieldTextureDataPointer>();