Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 2 files). Show all
Unified · Split
| @@ -223,8 +223,8 @@ void MetavoxelSystem::render() { · 222 unmodified lines | |||
| 223 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); | 223 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); |
| 224 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); | 224 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); |
| 225 | 225 | ||
| 226 | batch.vertexBuffer->bind(); | 226 | glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBufferID); |
| 227 | batch.indexBuffer->bind(); | 227 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch.indexBufferID); |
| 228 | 228 | ||
| 229 | HeightfieldPoint* point = 0; | 229 | HeightfieldPoint* point = 0; |
| 230 | glVertexPointer(3, GL_FLOAT, sizeof(HeightfieldPoint), &point->vertex); | 230 | glVertexPointer(3, GL_FLOAT, sizeof(HeightfieldPoint), &point->vertex); |
| @@ -245,8 +245,8 @@ void MetavoxelSystem::render() { · 14 unmodified lines | |||
| 245 | glActiveTexture(GL_TEXTURE0); | 245 | glActiveTexture(GL_TEXTURE0); |
| 246 | glBindTexture(GL_TEXTURE_2D, 0); | 246 | glBindTexture(GL_TEXTURE_2D, 0); |
| 247 | 247 | ||
| 248 | batch.vertexBuffer->release(); | 248 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 249 | batch.indexBuffer->release(); | 249 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 250 | 250 | ||
| 251 | glPopMatrix(); | 251 | glPopMatrix(); |
| 252 | } | 252 | } |
| @@ -273,8 +273,8 @@ void MetavoxelSystem::render() { · 20 unmodified lines | |||
| 273 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); | 273 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); |
| 274 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); | 274 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); |
| 275 | 275 | ||
| 276 | batch.vertexBuffer->bind(); | 276 | glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBufferID); |
| 277 | batch.indexBuffer->bind(); | 277 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch.indexBufferID); |
| 278 | 278 | ||
| 279 | HeightfieldPoint* point = 0; | 279 | HeightfieldPoint* point = 0; |
| 280 | glVertexPointer(3, GL_FLOAT, sizeof(HeightfieldPoint), &point->vertex); | 280 | glVertexPointer(3, GL_FLOAT, sizeof(HeightfieldPoint), &point->vertex); |
| @@ -324,8 +324,8 @@ void MetavoxelSystem::render() { · 43 unmodified lines | |||
| 324 | glActiveTexture(GL_TEXTURE0); | 324 | glActiveTexture(GL_TEXTURE0); |
| 325 | glBindTexture(GL_TEXTURE_2D, 0); | 325 | glBindTexture(GL_TEXTURE_2D, 0); |
| 326 | 326 | ||
| 327 | batch.vertexBuffer->release(); | 327 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 328 | batch.indexBuffer->release(); | 328 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 329 | 329 | ||
| 330 | glPopMatrix(); | 330 | glPopMatrix(); |
| 331 | } | 331 | } |
| @@ -368,8 +368,8 @@ void MetavoxelSystem::render() { · 36 unmodified lines | |||
| 368 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); | 368 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); |
| 369 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); | 369 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); |
| 370 | 370 | ||
| 371 | batch.vertexBuffer->bind(); | 371 | glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBufferID); |
| 372 | batch.indexBuffer->bind(); | 372 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch.indexBufferID); |
| 373 | 373 | ||
| 374 | VoxelPoint* point = 0; | 374 | VoxelPoint* point = 0; |
| 375 | glVertexPointer(3, GL_FLOAT, sizeof(VoxelPoint), &point->vertex); | 375 | glVertexPointer(3, GL_FLOAT, sizeof(VoxelPoint), &point->vertex); |
| @@ -378,8 +378,8 @@ void MetavoxelSystem::render() { · 2 unmodified lines | |||
| 378 | 378 | ||
| 379 | glDrawRangeElements(GL_QUADS, 0, batch.vertexCount - 1, batch.indexCount, GL_UNSIGNED_INT, 0); | 379 | glDrawRangeElements(GL_QUADS, 0, batch.vertexCount - 1, batch.indexCount, GL_UNSIGNED_INT, 0); |
| 380 | 380 | ||
| 381 | batch.vertexBuffer->release(); | 381 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 382 | batch.indexBuffer->release(); | 382 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 383 | 383 | ||
| 384 | glPopMatrix(); | 384 | glPopMatrix(); |
| 385 | } | 385 | } |
| @@ -409,8 +409,8 @@ void MetavoxelSystem::render() { · 23 unmodified lines | |||
| 409 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); | 409 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); |
| 410 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); | 410 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); |
| 411 | 411 | ||
| 412 | batch.vertexBuffer->bind(); | 412 | glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBufferID); |
| 413 | batch.indexBuffer->bind(); | 413 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch.indexBufferID); |
| 414 | 414 | ||
| 415 | VoxelPoint* point = 0; | 415 | VoxelPoint* point = 0; |
| 416 | glVertexPointer(3, GL_FLOAT, sizeof(VoxelPoint), &point->vertex); | 416 | glVertexPointer(3, GL_FLOAT, sizeof(VoxelPoint), &point->vertex); |
| @@ -453,8 +453,8 @@ void MetavoxelSystem::render() { · 36 unmodified lines | |||
| 453 | 453 | ||
| 454 | glActiveTexture(GL_TEXTURE0); | 454 | glActiveTexture(GL_TEXTURE0); |
| 455 | 455 | ||
| 456 | batch.vertexBuffer->release(); | 456 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 457 | batch.indexBuffer->release(); | 457 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 458 | 458 | ||
| 459 | glPopMatrix(); | 459 | glPopMatrix(); |
| 460 | } | 460 | } |
| @@ -492,13 +492,13 @@ void MetavoxelSystem::render() { · 31 unmodified lines | |||
| 492 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); | 492 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); |
| 493 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); | 493 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); |
| 494 | 494 | ||
| 495 | batch.vertexBuffer->bind(); | 495 | glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBufferID); |
| 496 | 496 | ||
| 497 | glVertexPointer(3, GL_FLOAT, 0, 0); | 497 | glVertexPointer(3, GL_FLOAT, 0, 0); |
| 498 | 498 | ||
| 499 | glDrawArrays(GL_LINES, 0, batch.vertexCount); | 499 | glDrawArrays(GL_LINES, 0, batch.vertexCount); |
| 500 | 500 | ||
| 501 | batch.vertexBuffer->release(); | 501 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 502 | 502 | ||
| 503 | glPopMatrix(); | 503 | glPopMatrix(); |
| 504 | } | 504 | } |
| @@ -547,6 +547,12 @@ void MetavoxelSystem::deleteTextures(int heightTextureID, int colorTextureID, in · 42 unmodified lines | |||
| 547 | glDeleteTextures(1, (const GLuint*)&materialTextureID); | 547 | glDeleteTextures(1, (const GLuint*)&materialTextureID); |
| 548 | } | 548 | } |
| 549 | 549 | ||
| 550 | void MetavoxelSystem::deleteBuffers(int vertexBufferID, int indexBufferID, int hermiteBufferID) const { | ||
| 551 | glDeleteBuffers(1, (const GLuint*)&vertexBufferID); | ||
| 552 | glDeleteBuffers(1, (const GLuint*)&indexBufferID); | ||
| 553 | glDeleteBuffers(1, (const GLuint*)&hermiteBufferID); | ||
| 554 | } | ||
| 555 | |||
| 550 | class SpannerRenderVisitor : public SpannerVisitor { | 556 | class SpannerRenderVisitor : public SpannerVisitor { |
| 551 | public: | 557 | public: |
| 552 | 558 | ||
| @@ -649,8 +655,8 @@ void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float r · 96 unmodified lines | |||
| 649 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); | 655 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); |
| 650 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); | 656 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); |
| 651 | 657 | ||
| 652 | batch.vertexBuffer->bind(); | 658 | glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBufferID); |
| 653 | batch.indexBuffer->bind(); | 659 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch.indexBufferID); |
| 654 | 660 | ||
| 655 | HeightfieldPoint* point = 0; | 661 | HeightfieldPoint* point = 0; |
| 656 | glVertexPointer(3, GL_FLOAT, sizeof(HeightfieldPoint), &point->vertex); | 662 | glVertexPointer(3, GL_FLOAT, sizeof(HeightfieldPoint), &point->vertex); |
| @@ -662,8 +668,8 @@ void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float r · 5 unmodified lines | |||
| 662 | 668 | ||
| 663 | glBindTexture(GL_TEXTURE_2D, 0); | 669 | glBindTexture(GL_TEXTURE_2D, 0); |
| 664 | 670 | ||
| 665 | batch.vertexBuffer->release(); | 671 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 666 | batch.indexBuffer->release(); | 672 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 667 | 673 | ||
| 668 | glPopMatrix(); | 674 | glPopMatrix(); |
| 669 | } | 675 | } |
| @@ -687,16 +693,16 @@ void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float r · 17 unmodified lines | |||
| 687 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); | 693 | glRotatef(glm::degrees(glm::angle(batch.rotation)), axis.x, axis.y, axis.z); |
| 688 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); | 694 | glScalef(batch.scale.x, batch.scale.y, batch.scale.z); |
| 689 | 695 | ||
| 690 | batch.vertexBuffer->bind(); | 696 | glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBufferID); |
| 691 | batch.indexBuffer->bind(); | 697 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch.indexBufferID); |
| 692 | 698 | ||
| 693 | VoxelPoint* point = 0; | 699 | VoxelPoint* point = 0; |
| 694 | glVertexPointer(3, GL_FLOAT, sizeof(VoxelPoint), &point->vertex); | 700 | glVertexPointer(3, GL_FLOAT, sizeof(VoxelPoint), &point->vertex); |
| 695 | 701 | ||
| 696 | glDrawRangeElements(GL_QUADS, 0, batch.vertexCount - 1, batch.indexCount, GL_UNSIGNED_INT, 0); | 702 | glDrawRangeElements(GL_QUADS, 0, batch.vertexCount - 1, batch.indexCount, GL_UNSIGNED_INT, 0); |
| 697 | 703 | ||
| 698 | batch.vertexBuffer->release(); | 704 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 699 | batch.indexBuffer->release(); | 705 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 700 | 706 | ||
| 701 | glPopMatrix(); | 707 | glPopMatrix(); |
| 702 | } | 708 | } |
| @@ -1033,10 +1039,17 @@ VoxelBuffer::VoxelBuffer(const QVector<VoxelPoint>& vertices, const QVector<int> · 330 unmodified lines | |||
| 1033 | _vertexCount(vertices.size()), | 1039 | _vertexCount(vertices.size()), |
| 1034 | _indexCount(indices.size()), | 1040 | _indexCount(indices.size()), |
| 1035 | _hermiteCount(hermite.size()), | 1041 | _hermiteCount(hermite.size()), |
| 1036 | _indexBuffer(QOpenGLBuffer::IndexBuffer), | 1042 | _vertexBufferID(0), |
| 1043 | _indexBufferID(0), | ||
| 1044 | _hermiteBufferID(0), | ||
| 1037 | _materials(materials) { | 1045 | _materials(materials) { |
| 1038 | } | 1046 | } |
| 1039 | 1047 | ||
| 1048 | VoxelBuffer::~VoxelBuffer() { | ||
| 1049 | QMetaObject::invokeMethod(Application::getInstance()->getMetavoxels(), "deleteBuffers", Q_ARG(int, _vertexBufferID), | ||
| 1050 | Q_ARG(int, _indexBufferID), Q_ARG(int, _hermiteBufferID)); | ||
| 1051 | } | ||
| 1052 | |||
| 1040 | bool VoxelBuffer::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, | 1053 | bool VoxelBuffer::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, |
| 1041 | float boundsDistance, float& distance) const { | 1054 | float boundsDistance, float& distance) const { |
| 1042 | float highest = _size - 1.0f; | 1055 | float highest = _size - 1.0f; |
| @@ -1106,16 +1119,16 @@ bool VoxelBuffer::findRayIntersection(const glm::vec3& origin, const glm::vec3& · 63 unmodified lines | |||
| 1106 | } | 1119 | } |
| 1107 | 1120 | ||
| 1108 | void VoxelBuffer::render(const glm::vec3& translation, const glm::quat& rotation, const glm::vec3& scale, bool cursor) { | 1121 | void VoxelBuffer::render(const glm::vec3& translation, const glm::quat& rotation, const glm::vec3& scale, bool cursor) { |
| 1109 | if (!_vertexBuffer.isCreated()) { | 1122 | if (_vertexBufferID == 0) { |
| 1110 | _vertexBuffer.create(); | 1123 | glGenBuffers(1, &_vertexBufferID); |
| 1111 | _vertexBuffer.bind(); | 1124 | glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferID); |
| 1112 | _vertexBuffer.allocate(_vertices.constData(), _vertices.size() * sizeof(VoxelPoint)); | 1125 | glBufferData(GL_ARRAY_BUFFER, _vertices.size() * sizeof(VoxelPoint), _vertices.constData(), GL_STATIC_DRAW); |
| 1113 | _vertexBuffer.release(); | 1126 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 1114 | 1127 | ||
| 1115 | _indexBuffer.create(); | 1128 | glGenBuffers(1, &_indexBufferID); |
| 1116 | _indexBuffer.bind(); | 1129 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBufferID); |
| 1117 | _indexBuffer.allocate(_indices.constData(), _indices.size() * sizeof(int)); | 1130 | glBufferData(GL_ELEMENT_ARRAY_BUFFER, _indices.size() * sizeof(int), _indices.constData(), GL_STATIC_DRAW); |
| 1118 | _indexBuffer.release(); | 1131 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 1119 | 1132 | ||
| 1120 | if (!_materials.isEmpty()) { | 1133 | if (!_materials.isEmpty()) { |
| 1121 | _networkTextures.resize(_materials.size()); | 1134 | _networkTextures.resize(_materials.size()); |
| @@ -1134,8 +1147,8 @@ void VoxelBuffer::render(const glm::vec3& translation, const glm::quat& rotation · 12 unmodified lines | |||
| 1134 | baseBatch.translation = translation; | 1147 | baseBatch.translation = translation; |
| 1135 | baseBatch.rotation = rotation; | 1148 | baseBatch.rotation = rotation; |
| 1136 | baseBatch.scale = scale; | 1149 | baseBatch.scale = scale; |
| 1137 | baseBatch.vertexBuffer = &_vertexBuffer; | 1150 | baseBatch.vertexBufferID = _vertexBufferID; |
| 1138 | baseBatch.indexBuffer = &_indexBuffer; | 1151 | baseBatch.indexBufferID = _indexBufferID; |
| 1139 | baseBatch.vertexCount = _vertexCount; | 1152 | baseBatch.vertexCount = _vertexCount; |
| 1140 | baseBatch.indexCount = _indexCount; | 1153 | baseBatch.indexCount = _indexCount; |
| 1141 | Application::getInstance()->getMetavoxels()->addVoxelBaseBatch(baseBatch); | 1154 | Application::getInstance()->getMetavoxels()->addVoxelBaseBatch(baseBatch); |
| @@ -1145,8 +1158,8 @@ void VoxelBuffer::render(const glm::vec3& translation, const glm::quat& rotation · 3 unmodified lines | |||
| 1145 | splatBatch.translation = translation; | 1158 | splatBatch.translation = translation; |
| 1146 | splatBatch.rotation = rotation; | 1159 | splatBatch.rotation = rotation; |
| 1147 | splatBatch.scale = scale; | 1160 | splatBatch.scale = scale; |
| 1148 | splatBatch.vertexBuffer = &_vertexBuffer; | 1161 | splatBatch.vertexBufferID = _vertexBufferID; |
| 1149 | splatBatch.indexBuffer = &_indexBuffer; | 1162 | splatBatch.indexBufferID = _indexBufferID; |
| 1150 | splatBatch.vertexCount = _vertexCount; | 1163 | splatBatch.vertexCount = _vertexCount; |
| 1151 | splatBatch.indexCount = _indexCount; | 1164 | splatBatch.indexCount = _indexCount; |
| 1152 | splatBatch.splatTextureOffset = glm::vec3( | 1165 | splatBatch.splatTextureOffset = glm::vec3( |
| @@ -1178,18 +1191,18 @@ void VoxelBuffer::render(const glm::vec3& translation, const glm::quat& rotation · 25 unmodified lines | |||
| 1178 | } | 1191 | } |
| 1179 | 1192 | ||
| 1180 | if (_hermiteCount > 0) { | 1193 | if (_hermiteCount > 0) { |
| 1181 | if (!_hermiteBuffer.isCreated()) { | 1194 | if (_hermiteBufferID == 0) { |
| 1182 | _hermiteBuffer.create(); | 1195 | glGenBuffers(1, &_hermiteBufferID); |
| 1183 | _hermiteBuffer.bind(); | 1196 | glBindBuffer(GL_ARRAY_BUFFER, _hermiteBufferID); |
| 1184 | _hermiteBuffer.allocate(_hermite.constData(), _hermite.size() * sizeof(glm::vec3)); | 1197 | glBufferData(GL_ARRAY_BUFFER, _hermite.size() * sizeof(glm::vec3), _hermite.constData(), GL_STATIC_DRAW); |
| 1185 | _hermiteBuffer.release(); | 1198 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 1186 | _hermite.clear(); | 1199 | _hermite.clear(); |
| 1187 | } | 1200 | } |
| 1188 | HermiteBatch hermiteBatch; | 1201 | HermiteBatch hermiteBatch; |
| 1189 | hermiteBatch.translation = translation; | 1202 | hermiteBatch.translation = translation; |
| 1190 | hermiteBatch.rotation = rotation; | 1203 | hermiteBatch.rotation = rotation; |
| 1191 | hermiteBatch.scale = scale; | 1204 | hermiteBatch.scale = scale; |
| 1192 | hermiteBatch.vertexBuffer = &_hermiteBuffer; | 1205 | hermiteBatch.vertexBufferID = _hermiteBufferID; |
| 1193 | hermiteBatch.vertexCount = _hermiteCount; | 1206 | hermiteBatch.vertexCount = _hermiteCount; |
| 1194 | Application::getInstance()->getMetavoxels()->addHermiteBatch(hermiteBatch); | 1207 | Application::getInstance()->getMetavoxels()->addHermiteBatch(hermiteBatch); |
| 1195 | } | 1208 | } |
| @@ -1741,29 +1754,19 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g · 545 unmodified lines | |||
| 1741 | const int NO_CORNERS = 0; | 1754 | const int NO_CORNERS = 0; |
| 1742 | const int ALL_CORNERS = UPPER_LEFT_CORNER | UPPER_RIGHT_CORNER | LOWER_LEFT_CORNER | LOWER_RIGHT_CORNER; | 1755 | const int ALL_CORNERS = UPPER_LEFT_CORNER | UPPER_RIGHT_CORNER | LOWER_LEFT_CORNER | LOWER_RIGHT_CORNER; |
| 1743 | int corners = NO_CORNERS; | 1756 | int corners = NO_CORNERS; |
| 1744 | int stitchMinimumY = INT_MAX, stitchMaximumY = -1; | ||
| 1745 | if (heightfieldHeight != 0.0f) { | 1757 | if (heightfieldHeight != 0.0f) { |
| 1746 | corners |= UPPER_LEFT_CORNER; | 1758 | corners |= UPPER_LEFT_CORNER; |
| 1747 | stitchMinimumY = qMin(stitchMinimumY, (int)heightfieldHeight); | ||
| 1748 | stitchMaximumY = qMax(stitchMaximumY, (int)heightfieldHeight); | ||
| 1749 | } | 1759 | } |
| 1750 | if (nextHeightfieldHeightX != 0.0f && x != stackWidth) { | 1760 | if (nextHeightfieldHeightX != 0.0f && x != stackWidth) { |
| 1751 | corners |= UPPER_RIGHT_CORNER; | 1761 | corners |= UPPER_RIGHT_CORNER; |
| 1752 | stitchMinimumY = qMin(stitchMinimumY, (int)nextHeightfieldHeightX); | ||
| 1753 | stitchMaximumY = qMax(stitchMaximumY, (int)nextHeightfieldHeightX); | ||
| 1754 | } | 1762 | } |
| 1755 | if (nextHeightfieldHeightZ != 0.0f && z != stackHeight) { | 1763 | if (nextHeightfieldHeightZ != 0.0f && z != stackHeight) { |
| 1756 | corners |= LOWER_LEFT_CORNER; | 1764 | corners |= LOWER_LEFT_CORNER; |
| 1757 | stitchMinimumY = qMin(stitchMinimumY, (int)nextHeightfieldHeightZ); | ||
| 1758 | stitchMaximumY = qMax(stitchMaximumY, (int)nextHeightfieldHeightZ); | ||
| 1759 | } | 1765 | } |
| 1760 | if (nextHeightfieldHeightXZ != 0.0f && x != stackWidth && z != stackHeight) { | 1766 | if (nextHeightfieldHeightXZ != 0.0f && x != stackWidth && z != stackHeight) { |
| 1761 | corners |= LOWER_RIGHT_CORNER; | 1767 | corners |= LOWER_RIGHT_CORNER; |
| 1762 | stitchMinimumY = qMin(stitchMinimumY, (int)nextHeightfieldHeightXZ); | ||
| 1763 | stitchMaximumY = qMax(stitchMaximumY, (int)nextHeightfieldHeightXZ); | ||
| 1764 | } | 1768 | } |
| 1765 | bool stitchable = x != 0 && z != 0 && !(corners == NO_CORNERS || corners == ALL_CORNERS); | 1769 | bool stitchable = x != 0 && z != 0 && !(corners == NO_CORNERS || corners == ALL_CORNERS); |
| 1766 | bool stitched = false; | ||
| 1767 | VoxelPoint cornerPoints[4]; | 1770 | VoxelPoint cornerPoints[4]; |
| 1768 | int clampedX = qMax(x - 1, 0), clampedZ = qMax(z - 1, 0); | 1771 | int clampedX = qMax(x - 1, 0), clampedZ = qMax(z - 1, 0); |
| 1769 | if (stitchable) { | 1772 | if (stitchable) { |
| @@ -2105,7 +2108,7 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g · 335 unmodified lines | |||
| 2105 | vertices.append(point); | 2108 | vertices.append(point); |
| 2106 | } | 2109 | } |
| 2107 | 2110 | ||
| 2108 | if (stitchable && !stitched && y >= stitchMinimumY && y <= stitchMaximumY) { | 2111 | if (stitchable) { |
| 2109 | int nextIndex = vertices.size(); | 2112 | int nextIndex = vertices.size(); |
| 2110 | const NormalIndex& previousIndexX = lastIndicesX.getClosest(y); | 2113 | const NormalIndex& previousIndexX = lastIndicesX.getClosest(y); |
| 2111 | const NormalIndex& previousIndexZ = lastIndicesZ[x].getClosest(y); | 2114 | const NormalIndex& previousIndexZ = lastIndicesZ[x].getClosest(y); |
| @@ -2270,7 +2273,6 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g · 158 unmodified lines | |||
| 2270 | break; | 2273 | break; |
| 2271 | } | 2274 | } |
| 2272 | } | 2275 | } |
| 2273 | stitched = true; | ||
| 2274 | } | 2276 | } |
| 2275 | } | 2277 | } |
| 2276 | 2278 | ||
| @@ -2395,8 +2397,8 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g · 118 unmodified lines | |||
| 2395 | } | 2397 | } |
| 2396 | 2398 | ||
| 2397 | HeightfieldBaseLayerBatch baseBatch; | 2399 | HeightfieldBaseLayerBatch baseBatch; |
| 2398 | baseBatch.vertexBuffer = &bufferPair.first; | 2400 | baseBatch.vertexBufferID = bufferPair.first.bufferId(); |
| 2399 | baseBatch.indexBuffer = &bufferPair.second; | 2401 | baseBatch.indexBufferID = bufferPair.second.bufferId(); |
| 2400 | baseBatch.translation = translation; | 2402 | baseBatch.translation = translation; |
| 2401 | baseBatch.rotation = rotation; | 2403 | baseBatch.rotation = rotation; |
| 2402 | baseBatch.scale = scale; | 2404 | baseBatch.scale = scale; |
| @@ -2410,8 +2412,8 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g · 7 unmodified lines | |||
| 2410 | 2412 | ||
| 2411 | if (!(cursor || _networkTextures.isEmpty())) { | 2413 | if (!(cursor || _networkTextures.isEmpty())) { |
| 2412 | HeightfieldSplatBatch splatBatch; | 2414 | HeightfieldSplatBatch splatBatch; |
| 2413 | splatBatch.vertexBuffer = &bufferPair.first; | 2415 | splatBatch.vertexBufferID = bufferPair.first.bufferId(); |
| 2414 | splatBatch.indexBuffer = &bufferPair.second; | 2416 | splatBatch.indexBufferID = bufferPair.second.bufferId(); |
| 2415 | splatBatch.translation = translation; | 2417 | splatBatch.translation = translation; |
| 2416 | splatBatch.rotation = rotation; | 2418 | splatBatch.rotation = rotation; |
| 2417 | splatBatch.scale = scale; | 2419 | splatBatch.scale = scale; |