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
623623 _textureTextureID(0),
624624 _heightSize(glm::sqrt(height.size())),
625625 _heightIncrement(scale / (_heightSize - HEIGHT_EXTENSION)),
626− _colorSize(glm::sqrt(color.size() / HeightfieldData::COLOR_BYTES)),
626+ _colorSize(glm::sqrt(color.size() / DataBlock::COLOR_BYTES)),
627627 _colorIncrement(scale / (_colorSize - SHARED_EDGE)) {
628628
629629 _heightBounds.minimum.x -= _heightIncrement * HEIGHT_BORDER;
@@ -660,13 +660,13 @@ QByteArray HeightfieldBuffer::getUnextendedHeight() const { · 30 unmodified lines
660660 }
661661
662662 QByteArray HeightfieldBuffer::getUnextendedColor() const {
663− int srcSize = glm::sqrt(_color.size() / HeightfieldData::COLOR_BYTES);
663+ int srcSize = glm::sqrt(_color.size() / DataBlock::COLOR_BYTES);
664664 int destSize = srcSize - 1;
665− QByteArray unextended(destSize * destSize * HeightfieldData::COLOR_BYTES, 0);
665+ QByteArray unextended(destSize * destSize * DataBlock::COLOR_BYTES, 0);
666666 const char* src = _color.constData();
667− int srcStride = srcSize * HeightfieldData::COLOR_BYTES;
667+ int srcStride = srcSize * DataBlock::COLOR_BYTES;
668668 char* dest = unextended.data();
669− int destStride = destSize * HeightfieldData::COLOR_BYTES;
669+ int destStride = destSize * DataBlock::COLOR_BYTES;
670670 for (int z = 0; z < destSize; z++, src += srcStride, dest += destStride) {
671671 memcpy(dest, src, destStride);
672672 }
@@ -705,7 +705,7 @@ void HeightfieldBuffer::render(bool cursor) { · 32 unmodified lines
705705 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, WHITE_COLOR);
706706
707707 } else {
708− int colorSize = glm::sqrt(_color.size() / HeightfieldData::COLOR_BYTES);
708+ int colorSize = glm::sqrt(_color.size() / DataBlock::COLOR_BYTES);
709709 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, colorSize, colorSize, 0, GL_RGB, GL_UNSIGNED_BYTE, _color.constData());
710710 }
711711
@@ -1289,13 +1289,13 @@ int HeightfieldFetchVisitor::visit(MetavoxelInfo& info) { · 577 unmodified lines
12891289 destY = (overlap.minimum.z - colorBounds.minimum.z) / colorIncrement;
12901290 destWidth = glm::ceil((overlap.maximum.x - overlap.minimum.x) / colorIncrement);
12911291 destHeight = glm::ceil((overlap.maximum.z - overlap.minimum.z) / colorIncrement);
1292− dest = _buffer->getColor().data() + (destY * colorSize + destX) * HeightfieldData::COLOR_BYTES;
1293− int destStride = colorSize * HeightfieldData::COLOR_BYTES;
1294− int destBytes = destWidth * HeightfieldData::COLOR_BYTES;
1292+ dest = _buffer->getColor().data() + (destY * colorSize + destX) * DataBlock::COLOR_BYTES;
1293+ int destStride = colorSize * DataBlock::COLOR_BYTES;
1294+ int destBytes = destWidth * DataBlock::COLOR_BYTES;
12951295
12961296 const QByteArray& srcColor = color->getContents();
1297− srcSize = glm::sqrt(srcColor.size() / HeightfieldData::COLOR_BYTES);
1298− int srcStride = srcSize * HeightfieldData::COLOR_BYTES;
1297+ srcSize = glm::sqrt(srcColor.size() / DataBlock::COLOR_BYTES);
1298+ int srcStride = srcSize * DataBlock::COLOR_BYTES;
12991299 srcIncrement = info.size / srcSize;
13001300
13011301 if (srcIncrement == colorIncrement) {
@@ -1303,7 +1303,7 @@ int HeightfieldFetchVisitor::visit(MetavoxelInfo& info) { · 1 unmodified line
13031303 int srcX = (overlap.minimum.x - info.minimum.x) / srcIncrement;
13041304 int srcY = (overlap.minimum.z - info.minimum.z) / srcIncrement;
13051305
1306− const char* src = srcColor.constData() + (srcY * srcSize + srcX) * HeightfieldData::COLOR_BYTES;
1306+ const char* src = srcColor.constData() + (srcY * srcSize + srcX) * DataBlock::COLOR_BYTES;
13071307 for (int y = 0; y < destHeight; y++, src += srcStride, dest += destStride) {
13081308 memcpy(dest, src, destBytes);
13091309 }
@@ -1315,9 +1315,9 @@ int HeightfieldFetchVisitor::visit(MetavoxelInfo& info) { · 5 unmodified lines
13151315 for (int y = 0; y < destHeight; y++, dest += destStride, srcY += srcAdvance) {
13161316 const char* src = srcColor.constData() + (int)srcY * srcStride;
13171317 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,
13191319 lineSrcX += srcAdvance) {
1320− const char* lineSrc = src + (int)lineSrcX * HeightfieldData::COLOR_BYTES;
1320+ const char* lineSrc = src + (int)lineSrcX * DataBlock::COLOR_BYTES;
13211321 lineDest[0] = lineSrc[0];
13221322 lineDest[1] = lineSrc[1];
13231323 lineDest[2] = lineSrc[2];
@@ -1372,9 +1372,9 @@ int HeightfieldRegionVisitor::visit(MetavoxelInfo& info) { · 48 unmodified lines
13721372 int colorContentsSize = 0;
13731373 if (color) {
13741374 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);
13761376 int extendedColorSize = colorSize + HeightfieldBuffer::SHARED_EDGE;
1377− colorContentsSize = extendedColorSize * extendedColorSize * HeightfieldData::COLOR_BYTES;
1377+ colorContentsSize = extendedColorSize * extendedColorSize * DataBlock::COLOR_BYTES;
13781378 }
13791379
13801380 HeightfieldTextureDataPointer texture = info.inputValues.at(2).getInlineValue<HeightfieldTextureDataPointer>();