History

fix for calls to glm sqrt with ints

Stephen Birarda committed 12 years ago

Commit 7bae88e1 parent 1007f521 file · +11 −10Browse files

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

Unified · Split

interface/src/MetavoxelSystem.cpp+11−10
@@ -16,6 +16,7 @@ · 15 unmodified lines
16#include <QOpenGLFramebufferObject>16#include <QOpenGLFramebufferObject>
17#include <QReadLocker>17#include <QReadLocker>
18#include <QWriteLocker>18#include <QWriteLocker>
19#include <QThreadPool>
19#include <QtDebug>20#include <QtDebug>
20 21
21#include <glm/gtx/transform.hpp>22#include <glm/gtx/transform.hpp>
@@ -636,9 +637,9 @@ HeightfieldBuffer::HeightfieldBuffer(const glm::vec3& translation, float scale, · 614 unmodified lines
636 _heightTextureID(0),637 _heightTextureID(0),
637 _colorTextureID(0),638 _colorTextureID(0),
638 _materialTextureID(0),639 _materialTextureID(0),
639 _heightSize(glm::sqrt(height.size())),640 _heightSize(glm::sqrt(float(height.size()))),
640 _heightIncrement(scale / (_heightSize - HEIGHT_EXTENSION)),641 _heightIncrement(scale / (_heightSize - HEIGHT_EXTENSION)),
641 _colorSize(glm::sqrt(color.size() / DataBlock::COLOR_BYTES)),642 _colorSize(glm::sqrt(float(color.size() / DataBlock::COLOR_BYTES))),
642 _colorIncrement(scale / (_colorSize - SHARED_EDGE)) {643 _colorIncrement(scale / (_colorSize - SHARED_EDGE)) {
643 644
644 _heightBounds.minimum.x -= _heightIncrement * HEIGHT_BORDER;645 _heightBounds.minimum.x -= _heightIncrement * HEIGHT_BORDER;
@@ -663,7 +664,7 @@ HeightfieldBuffer::~HeightfieldBuffer() { · 18 unmodified lines
663}664}
664 665
665QByteArray HeightfieldBuffer::getUnextendedHeight() const {666QByteArray HeightfieldBuffer::getUnextendedHeight() const {
666 int srcSize = glm::sqrt(_height.size());667 int srcSize = glm::sqrt(float(_height.size()));
667 int destSize = srcSize - 3;668 int destSize = srcSize - 3;
668 QByteArray unextended(destSize * destSize, 0);669 QByteArray unextended(destSize * destSize, 0);
669 const char* src = _height.constData() + srcSize + 1;670 const char* src = _height.constData() + srcSize + 1;
@@ -675,7 +676,7 @@ QByteArray HeightfieldBuffer::getUnextendedHeight() const { · 5 unmodified lines
675}676}
676 677
677QByteArray HeightfieldBuffer::getUnextendedColor() const {678QByteArray HeightfieldBuffer::getUnextendedColor() const {
678 int srcSize = glm::sqrt(_color.size() / DataBlock::COLOR_BYTES);679 int srcSize = glm::sqrt(float(_color.size() / DataBlock::COLOR_BYTES));
679 int destSize = srcSize - 1;680 int destSize = srcSize - 1;
680 QByteArray unextended(destSize * destSize * DataBlock::COLOR_BYTES, 0);681 QByteArray unextended(destSize * destSize * DataBlock::COLOR_BYTES, 0);
681 const char* src = _color.constData();682 const char* src = _color.constData();
@@ -720,7 +721,7 @@ void HeightfieldBuffer::render(bool cursor) { · 38 unmodified lines
720 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, WHITE_COLOR);721 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, WHITE_COLOR);
721 722
722 } else {723 } else {
723 int colorSize = glm::sqrt(_color.size() / DataBlock::COLOR_BYTES); 724 int colorSize = glm::sqrt(float(_color.size() / DataBlock::COLOR_BYTES));
724 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, colorSize, colorSize, 0, GL_RGB, GL_UNSIGNED_BYTE, _color.constData());725 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, colorSize, colorSize, 0, GL_RGB, GL_UNSIGNED_BYTE, _color.constData());
725 }726 }
726 727
@@ -731,7 +732,7 @@ void HeightfieldBuffer::render(bool cursor) { · 4 unmodified lines
731 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);732 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
732 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);733 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
733 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);734 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
734 int materialSize = glm::sqrt(_material.size()); 735 int materialSize = glm::sqrt(float(_material.size()));
735 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, materialSize, materialSize, 0,736 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, materialSize, materialSize, 0,
736 GL_LUMINANCE, GL_UNSIGNED_BYTE, _material.constData());737 GL_LUMINANCE, GL_UNSIGNED_BYTE, _material.constData());
737 738
@@ -1270,7 +1271,7 @@ int HeightfieldFetchVisitor::visit(MetavoxelInfo& info) { · 532 unmodified lines
1270 char* dest = _buffer->getHeight().data() + destY * heightSize + destX;1271 char* dest = _buffer->getHeight().data() + destY * heightSize + destX;
1271 1272
1272 const QByteArray& srcHeight = height->getContents();1273 const QByteArray& srcHeight = height->getContents();
1273 int srcSize = glm::sqrt(srcHeight.size());1274 int srcSize = glm::sqrt(float(srcHeight.size()));
1274 float srcIncrement = info.size / srcSize;1275 float srcIncrement = info.size / srcSize;
1275 1276
1276 if (info.size == _buffer->getScale() && srcSize == (heightSize - HeightfieldBuffer::HEIGHT_EXTENSION)) {1277 if (info.size == _buffer->getScale() && srcSize == (heightSize - HeightfieldBuffer::HEIGHT_EXTENSION)) {
@@ -1323,7 +1324,7 @@ int HeightfieldFetchVisitor::visit(MetavoxelInfo& info) { · 46 unmodified lines
1323 int destBytes = destWidth * DataBlock::COLOR_BYTES;1324 int destBytes = destWidth * DataBlock::COLOR_BYTES;
1324 1325
1325 const QByteArray& srcColor = color->getContents();1326 const QByteArray& srcColor = color->getContents();
1326 srcSize = glm::sqrt(srcColor.size() / DataBlock::COLOR_BYTES);1327 srcSize = glm::sqrt(float(srcColor.size() / DataBlock::COLOR_BYTES));
1327 int srcStride = srcSize * DataBlock::COLOR_BYTES;1328 int srcStride = srcSize * DataBlock::COLOR_BYTES;
1328 srcIncrement = info.size / srcSize;1329 srcIncrement = info.size / srcSize;
1329 1330
@@ -1393,7 +1394,7 @@ int HeightfieldRegionVisitor::visit(MetavoxelInfo& info) { · 63 unmodified lines
1393 HeightfieldHeightDataPointer height = info.inputValues.at(0).getInlineValue<HeightfieldHeightDataPointer>();1394 HeightfieldHeightDataPointer height = info.inputValues.at(0).getInlineValue<HeightfieldHeightDataPointer>();
1394 if (height) {1395 if (height) {
1395 const QByteArray& heightContents = height->getContents();1396 const QByteArray& heightContents = height->getContents();
1396 int size = glm::sqrt(heightContents.size());1397 int size = glm::sqrt(float(heightContents.size()));
1397 int extendedSize = size + HeightfieldBuffer::HEIGHT_EXTENSION;1398 int extendedSize = size + HeightfieldBuffer::HEIGHT_EXTENSION;
1398 int heightContentsSize = extendedSize * extendedSize;1399 int heightContentsSize = extendedSize * extendedSize;
1399 1400
@@ -1401,7 +1402,7 @@ int HeightfieldRegionVisitor::visit(MetavoxelInfo& info) { · 1 unmodified line
1401 int colorContentsSize = 0;1402 int colorContentsSize = 0;
1402 if (color) {1403 if (color) {
1403 const QByteArray& colorContents = color->getContents();1404 const QByteArray& colorContents = color->getContents();
1404 int colorSize = glm::sqrt(colorContents.size() / DataBlock::COLOR_BYTES);1405 int colorSize = glm::sqrt(float(colorContents.size() / DataBlock::COLOR_BYTES));
1405 int extendedColorSize = colorSize + HeightfieldBuffer::SHARED_EDGE;1406 int extendedColorSize = colorSize + HeightfieldBuffer::SHARED_EDGE;
1406 colorContentsSize = extendedColorSize * extendedColorSize * DataBlock::COLOR_BYTES;1407 colorContentsSize = extendedColorSize * extendedColorSize * DataBlock::COLOR_BYTES;
1407 }1408 }