Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 3 files). Show all
Unified · Split
| @@ -38,10 +38,12 @@ GeometryCache::GeometryCache() : · 37 unmodified lines | ||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | GeometryCache::~GeometryCache() { |
| 41 | − qDebug() << "GeometryCache::~GeometryCache()... "; | |
| 42 | − qDebug() << " _registeredLine3DVBOs.size():" << _registeredLine3DVBOs.size(); | |
| 43 | − qDebug() << " _line3DVBOs.size():" << _line3DVBOs.size(); | |
| 44 | − qDebug() << " BatchItemDetails... population:" << GeometryCache::BatchItemDetails::population; | |
| 41 | + #ifdef WANT_DEBUG | |
| 42 | + qDebug() << "GeometryCache::~GeometryCache()... "; | |
| 43 | + qDebug() << " _registeredLine3DVBOs.size():" << _registeredLine3DVBOs.size(); | |
| 44 | + qDebug() << " _line3DVBOs.size():" << _line3DVBOs.size(); | |
| 45 | + qDebug() << " BatchItemDetails... population:" << GeometryCache::BatchItemDetails::population; | |
| 46 | + #endif //def WANT_DEBUG | |
| 45 | 47 | } |
| 46 | 48 | |
| 47 | 49 | const int NUM_VERTICES_PER_TRIANGLE = 3; |
| @@ -53,21 +55,16 @@ const int NUM_BYTES_PER_INDEX = sizeof(GLushort); · 5 unmodified lines | ||
| 53 | 55 | |
| 54 | 56 | void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid) { |
| 55 | 57 | |
| 56 | − Vec2Pair keyRadius(glm::vec2(radius, slices), glm::vec2(stacks, 0)); | |
| 57 | − IntPair keySlicesStacks(slices, stacks); | |
| 58 | − | |
| 59 | −//qDebug() << " key:" << key; | |
| 60 | −//qDebug() << "renderSphere() radius:" << radius << "slices:" << slices << "stacks:" << stacks; | |
| 61 | − | |
| 58 | + Vec2Pair radiusKey(glm::vec2(radius, slices), glm::vec2(stacks, 0)); | |
| 59 | + IntPair slicesStacksKey(slices, stacks); | |
| 62 | 60 | Vec3Pair colorKey(glm::vec3(color.x, color.y, slices),glm::vec3(color.z, color.y, stacks)); |
| 63 | 61 | |
| 64 | − | |
| 65 | 62 | int vertices = slices * (stacks - 1) + 2; |
| 66 | 63 | int indices = slices * (stacks - 1) * NUM_VERTICES_PER_TRIANGULATED_QUAD; |
| 67 | 64 | |
| 68 | − if (!_sphereVertices.contains(keyRadius)) { | |
| 65 | + if (!_sphereVertices.contains(radiusKey)) { | |
| 69 | 66 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); |
| 70 | − _sphereVertices[keyRadius] = verticesBuffer; | |
| 67 | + _sphereVertices[radiusKey] = verticesBuffer; | |
| 71 | 68 | |
| 72 | 69 | GLfloat* vertexData = new GLfloat[vertices * NUM_COORDS_PER_VERTEX]; |
| 73 | 70 | GLfloat* vertex = vertexData; |
| @@ -99,17 +96,20 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm · 25 unmodified lines | ||
| 99 | 96 | |
| 100 | 97 | verticesBuffer->append(sizeof(GLfloat) * vertices * NUM_COORDS_PER_VERTEX, (gpu::Buffer::Byte*) vertexData); |
| 101 | 98 | delete[] vertexData; |
| 102 | −qDebug() << "GeometryCache::renderSphere()... --- CREATING VERTICES BUFFER"; | |
| 103 | −qDebug() << " radius:" << radius; | |
| 104 | −qDebug() << " slices:" << slices; | |
| 105 | −qDebug() << " stacks:" << stacks; | |
| 106 | 99 | |
| 107 | −qDebug() << " _sphereVertices.size():" << _sphereVertices.size(); | |
| 100 | + #ifdef WANT_DEBUG | |
| 101 | + qDebug() << "GeometryCache::renderSphere()... --- CREATING VERTICES BUFFER"; | |
| 102 | + qDebug() << " radius:" << radius; | |
| 103 | + qDebug() << " slices:" << slices; | |
| 104 | + qDebug() << " stacks:" << stacks; | |
| 105 | + | |
| 106 | + qDebug() << " _sphereVertices.size():" << _sphereVertices.size(); | |
| 107 | + #endif | |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | − if (!_sphereIndices.contains(keySlicesStacks)) { | |
| 110 | + if (!_sphereIndices.contains(slicesStacksKey)) { | |
| 111 | 111 | gpu::BufferPointer indicesBuffer(new gpu::Buffer()); |
| 112 | − _sphereIndices[keySlicesStacks] = indicesBuffer; | |
| 112 | + _sphereIndices[slicesStacksKey] = indicesBuffer; | |
| 113 | 113 | |
| 114 | 114 | GLushort* indexData = new GLushort[indices]; |
| 115 | 115 | GLushort* index = indexData; |
| @@ -162,14 +162,16 @@ qDebug() << " _sphereVertices.size():" << _sphereVertices.size(); · 46 unmodified lines | ||
| 162 | 162 | } |
| 163 | 163 | indicesBuffer->append(sizeof(GLushort) * indices, (gpu::Buffer::Byte*) indexData); |
| 164 | 164 | delete[] indexData; |
| 165 | −qDebug() << "GeometryCache::renderSphere()... --- CREATING INDEX BUFFER"; | |
| 166 | −qDebug() << " radius:" << radius; | |
| 167 | −qDebug() << " slices:" << slices; | |
| 168 | −qDebug() << " stacks:" << stacks; | |
| 169 | −qDebug() << "indexCount:" << indexCount; | |
| 170 | −qDebug() << " indices:" << indices; | |
| 171 | − | |
| 172 | −qDebug() << " _sphereIndices.size():" << _sphereIndices.size(); | |
| 165 | + | |
| 166 | + #ifdef WANT_DEBUG | |
| 167 | + qDebug() << "GeometryCache::renderSphere()... --- CREATING INDEX BUFFER"; | |
| 168 | + qDebug() << " radius:" << radius; | |
| 169 | + qDebug() << " slices:" << slices; | |
| 170 | + qDebug() << " stacks:" << stacks; | |
| 171 | + qDebug() << "indexCount:" << indexCount; | |
| 172 | + qDebug() << " indices:" << indices; | |
| 173 | + qDebug() << " _sphereIndices.size():" << _sphereIndices.size(); | |
| 174 | + #endif | |
| 173 | 175 | } |
| 174 | 176 | |
| 175 | 177 | if (!_sphereColors.contains(colorKey)) { |
| @@ -191,27 +193,20 @@ qDebug() << " _sphereIndices.size():" << _sphereIndices.size(); · 15 unmodified lines | ||
| 191 | 193 | colorBuffer->append(sizeof(int) * vertices, (gpu::Buffer::Byte*) colorData); |
| 192 | 194 | delete[] colorData; |
| 193 | 195 | |
| 194 | −qDebug() << "GeometryCache::renderSphere()... --- CREATING COLORS BUFFER"; | |
| 195 | −qDebug() << " vertices:" << vertices; | |
| 196 | −qDebug() << " color:" << color; | |
| 197 | −qDebug() << " slices:" << slices; | |
| 198 | −qDebug() << " stacks:" << stacks; | |
| 199 | − | |
| 200 | −qDebug() << " _sphereColors.size():" << _sphereColors.size(); | |
| 196 | + #ifdef WANT_DEBUG | |
| 197 | + qDebug() << "GeometryCache::renderSphere()... --- CREATING COLORS BUFFER"; | |
| 198 | + qDebug() << " vertices:" << vertices; | |
| 199 | + qDebug() << " color:" << color; | |
| 200 | + qDebug() << " slices:" << slices; | |
| 201 | + qDebug() << " stacks:" << stacks; | |
| 202 | + qDebug() << " _sphereColors.size():" << _sphereColors.size(); | |
| 203 | + #endif | |
| 201 | 204 | |
| 202 | 205 | } |
| 203 | − gpu::BufferPointer verticesBuffer = _sphereVertices[keyRadius]; | |
| 204 | − gpu::BufferPointer indicesBuffer = _sphereIndices[keySlicesStacks]; | |
| 206 | + gpu::BufferPointer verticesBuffer = _sphereVertices[radiusKey]; | |
| 207 | + gpu::BufferPointer indicesBuffer = _sphereIndices[slicesStacksKey]; | |
| 205 | 208 | gpu::BufferPointer colorBuffer = _sphereColors[colorKey]; |
| 206 | 209 | |
| 207 | − #ifdef WANT_DEBUG | |
| 208 | − qDebug() << "renderSphere() radius:" << radius << "slices:" << slices << "stacks:" << stacks; | |
| 209 | − qDebug() << " vertices:" << vertices; | |
| 210 | − qDebug() << " indices:" << indices; | |
| 211 | − qDebug() << " colorBuffer->getSize():" << colorBuffer->getSize(); | |
| 212 | − #endif //def WANT_DEBUG | |
| 213 | − | |
| 214 | − | |
| 215 | 210 | const int VERTICES_SLOT = 0; |
| 216 | 211 | const int NORMALS_SLOT = 1; |
| 217 | 212 | const int COLOR_SLOT = 2; |
| @@ -348,8 +343,6 @@ void GeometryCache::renderCone(float base, float height, int slices, int stacks) · 130 unmodified lines | ||
| 348 | 343 | } |
| 349 | 344 | |
| 350 | 345 | void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& color) { |
| 351 | − //qDebug() << "GeometryCache::renderGrid(xDivisions["<<xDivisions<<"], yDivisions["<<yDivisions<<"])"; | |
| 352 | − | |
| 353 | 346 | IntPair key(xDivisions, yDivisions); |
| 354 | 347 | Vec3Pair colorKey(glm::vec3(color.x, color.y, yDivisions),glm::vec3(color.z, color.y, xDivisions)); |
| 355 | 348 | |
| @@ -436,13 +429,15 @@ void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& · 80 unmodified lines | ||
| 436 | 429 | // TODO: properly handle the x,y,w,h changing for an ID |
| 437 | 430 | // TODO: why do we seem to create extra BatchItemDetails when we resize the window?? what's that?? |
| 438 | 431 | void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) { |
| 439 | − qDebug() << "GeometryCache::renderGrid(x["<<x<<"], " | |
| 432 | + #ifdef WANT_DEBUG | |
| 433 | + qDebug() << "GeometryCache::renderGrid(x["<<x<<"], " | |
| 440 | 434 | "y["<<y<<"]," |
| 441 | 435 | "w["<<width<<"]," |
| 442 | 436 | "h["<<height<<"]," |
| 443 | 437 | "rows["<<rows<<"]," |
| 444 | 438 | "cols["<<cols<<"]," |
| 445 | 439 | " id:"<<id<<")..."; |
| 440 | + #endif | |
| 446 | 441 | |
| 447 | 442 | bool registered = (id != UNKNOWN_ID); |
| 448 | 443 | Vec3Pair key(glm::vec3(x, y, width), glm::vec3(height, rows, cols)); |
| @@ -542,7 +537,6 @@ void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, in · 93 unmodified lines | ||
| 542 | 537 | } |
| 543 | 538 | |
| 544 | 539 | void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, const glm::vec4& color) { |
| 545 | − //qDebug() << "GeometryCache::updateVertices(vec2.... id=" << id <<")..."; | |
| 546 | 540 | BatchItemDetails& details = _registeredVertices[id]; |
| 547 | 541 | |
| 548 | 542 | if (details.isCreated) { |
| @@ -605,7 +599,6 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con · 56 unmodified lines | ||
| 605 | 599 | } |
| 606 | 600 | |
| 607 | 601 | void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, const glm::vec4& color) { |
| 608 | − //qDebug() << "GeometryCache::updateVertices(id=" << id <<")..."; | |
| 609 | 602 | BatchItemDetails& details = _registeredVertices[id]; |
| 610 | 603 | |
| 611 | 604 | if (details.isCreated) { |
| @@ -669,8 +662,6 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con · 57 unmodified lines | ||
| 669 | 662 | } |
| 670 | 663 | |
| 671 | 664 | void GeometryCache::renderVertices(gpu::Primitive primitiveType, int id) { |
| 672 | − //qDebug() << "GeometryCache::renderVertices(id=" << id <<")..."; | |
| 673 | − | |
| 674 | 665 | BatchItemDetails& details = _registeredVertices[id]; |
| 675 | 666 | if (details.isCreated) { |
| 676 | 667 | gpu::Batch batch; |
| @@ -900,7 +891,6 @@ void GeometryCache::renderWireCube(float size, const glm::vec4& color) { · 223 unmodified lines | ||
| 900 | 891 | } |
| 901 | 892 | |
| 902 | 893 | void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) { |
| 903 | − //qDebug() << "GeometryCache::renderBevelCornersRect(id=" << id <<")..."; | |
| 904 | 894 | bool registered = (id != UNKNOWN_ID); |
| 905 | 895 | Vec3Pair key(glm::vec3(x, y, 0.0f), glm::vec3(width, height, bevelDistance)); |
| 906 | 896 | BatchItemDetails& details = registered ? _registeredBevelRects[id] : _bevelRects[key]; |
| @@ -1008,7 +998,6 @@ void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, · 101 unmodified lines | ||
| 1008 | 998 | } |
| 1009 | 999 | |
| 1010 | 1000 | void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) { |
| 1011 | − //qDebug() << "GeometryCache::renderQuad(vec2,id=" << id <<")..."; | |
| 1012 | 1001 | bool registered = (id != UNKNOWN_ID); |
| 1013 | 1002 | Vec2Pair key(minCorner, maxCorner); |
| 1014 | 1003 | BatchItemDetails& details = registered ? _registeredQuad2D[id] : _quad2D[key]; |
| @@ -1092,7 +1081,6 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC · 77 unmodified lines | ||
| 1092 | 1081 | const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, |
| 1093 | 1082 | const glm::vec4& color, int id) { |
| 1094 | 1083 | |
| 1095 | − //qDebug() << "GeometryCache::renderQuad(vec2/texture,id=" << id <<")..."; | |
| 1096 | 1084 | bool registered = (id != UNKNOWN_ID); |
| 1097 | 1085 | Vec2PairPair key(Vec2Pair(minCorner, maxCorner), Vec2Pair(texCoordMinCorner, texCoordMaxCorner)); |
| 1098 | 1086 | BatchItemDetails& details = registered ? _registeredQuad2DTextures[id] : _quad2DTextures[key]; |
| @@ -1183,7 +1171,6 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC · 84 unmodified lines | ||
| 1183 | 1171 | } |
| 1184 | 1172 | |
| 1185 | 1173 | void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) { |
| 1186 | − //qDebug() << "GeometryCache::renderQuad(vec3,id=" << id <<")..."; | |
| 1187 | 1174 | bool registered = (id != UNKNOWN_ID); |
| 1188 | 1175 | Vec3Pair key(minCorner, maxCorner); |
| 1189 | 1176 | BatchItemDetails& details = registered ? _registeredQuad3D[id] : _quad3D[key]; |
| @@ -1471,7 +1458,9 @@ GeometryCache::BatchItemDetails::BatchItemDetails() : · 281 unmodified lines | ||
| 1471 | 1458 | isCreated(false) |
| 1472 | 1459 | { |
| 1473 | 1460 | population++; |
| 1474 | − qDebug() << "BatchItemDetails()... population:" << population << "**********************************"; | |
| 1461 | + #ifdef WANT_DEBUG | |
| 1462 | + qDebug() << "BatchItemDetails()... population:" << population << "**********************************"; | |
| 1463 | + #endif | |
| 1475 | 1464 | } |
| 1476 | 1465 | |
| 1477 | 1466 | GeometryCache::BatchItemDetails::BatchItemDetails(const GeometryCache::BatchItemDetails& other) : |
| @@ -1484,13 +1473,17 @@ GeometryCache::BatchItemDetails::BatchItemDetails(const GeometryCache::BatchItem · 6 unmodified lines | ||
| 1484 | 1473 | isCreated(other.isCreated) |
| 1485 | 1474 | { |
| 1486 | 1475 | population++; |
| 1487 | − qDebug() << "BatchItemDetails()... population:" << population << "**********************************"; | |
| 1476 | + #ifdef WANT_DEBUG | |
| 1477 | + qDebug() << "BatchItemDetails()... population:" << population << "**********************************"; | |
| 1478 | + #endif | |
| 1488 | 1479 | } |
| 1489 | 1480 | |
| 1490 | 1481 | GeometryCache::BatchItemDetails::~BatchItemDetails() { |
| 1491 | 1482 | population--; |
| 1492 | 1483 | clear(); |
| 1493 | − qDebug() << "~BatchItemDetails()... population:" << population << "**********************************"; | |
| 1484 | + #ifdef WANT_DEBUG | |
| 1485 | + qDebug() << "~BatchItemDetails()... population:" << population << "**********************************"; | |
| 1486 | + #endif | |
| 1494 | 1487 | } |
| 1495 | 1488 | |
| 1496 | 1489 | void GeometryCache::BatchItemDetails::clear() { |
| @@ -1504,7 +1497,6 @@ void GeometryCache::BatchItemDetails::clear() { · 7 unmodified lines | ||
| 1504 | 1497 | void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2, |
| 1505 | 1498 | const glm::vec4& color1, const glm::vec4& color2, int id) { |
| 1506 | 1499 | |
| 1507 | − //qDebug() << "GeometryCache::renderLine(vec3)..."; | |
| 1508 | 1500 | bool registered = (id != UNKNOWN_ID); |
| 1509 | 1501 | Vec3Pair key(p1, p2); |
| 1510 | 1502 | |
| @@ -1597,7 +1589,6 @@ void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2, · 86 unmodified lines | ||
| 1597 | 1589 | void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2, |
| 1598 | 1590 | const glm::vec4& color1, const glm::vec4& color2, int id) { |
| 1599 | 1591 | |
| 1600 | − //qDebug() << "GeometryCache::renderLine(vec2)..."; | |
| 1601 | 1592 | bool registered = (id != UNKNOWN_ID); |
| 1602 | 1593 | Vec2Pair key(p1, p2); |
| 1603 | 1594 | |