Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 12 files). Show all
Unified · Split
| @@ -54,12 +54,6 @@ const int NUM_TRIANGLES_PER_QUAD = 2; · 53 unmodified lines | |||
| 54 | const int NUM_VERTICES_PER_TRIANGULATED_QUAD = NUM_VERTICES_PER_TRIANGLE * NUM_TRIANGLES_PER_QUAD; | 54 | const int NUM_VERTICES_PER_TRIANGULATED_QUAD = NUM_VERTICES_PER_TRIANGLE * NUM_TRIANGLES_PER_QUAD; |
| 55 | const int NUM_COORDS_PER_VERTEX = 3; | 55 | const int NUM_COORDS_PER_VERTEX = 3; |
| 56 | 56 | ||
| 57 | void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) { | ||
| 58 | gpu::Batch batch; | ||
| 59 | renderSphere(batch, radius, slices, stacks, color, solid, id); | ||
| 60 | gpu::GLBackend::renderBatch(batch); | ||
| 61 | } | ||
| 62 | |||
| 63 | void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) { | 57 | void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) { |
| 64 | bool registered = (id != UNKNOWN_ID); | 58 | bool registered = (id != UNKNOWN_ID); |
| 65 | 59 | ||
| @@ -304,12 +298,6 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in · 238 unmodified lines | |||
| 304 | } | 298 | } |
| 305 | } | 299 | } |
| 306 | 300 | ||
| 307 | void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& color) { | ||
| 308 | gpu::Batch batch; | ||
| 309 | renderGrid(batch, xDivisions, yDivisions, color); | ||
| 310 | gpu::GLBackend::renderBatch(batch); | ||
| 311 | } | ||
| 312 | |||
| 313 | void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions, const glm::vec4& color) { | 301 | void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions, const glm::vec4& color) { |
| 314 | IntPair key(xDivisions, yDivisions); | 302 | IntPair key(xDivisions, yDivisions); |
| 315 | Vec3Pair colorKey(glm::vec3(color.x, color.y, yDivisions), glm::vec3(color.z, color.y, xDivisions)); | 303 | Vec3Pair colorKey(glm::vec3(color.x, color.y, yDivisions), glm::vec3(color.z, color.y, xDivisions)); |
| @@ -384,12 +372,6 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions · 68 unmodified lines | |||
| 384 | batch.draw(gpu::LINES, vertices, 0); | 372 | batch.draw(gpu::LINES, vertices, 0); |
| 385 | } | 373 | } |
| 386 | 374 | ||
| 387 | void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) { | ||
| 388 | gpu::Batch batch; | ||
| 389 | renderGrid(batch, x, y, width, height, rows, cols, color, id); | ||
| 390 | gpu::GLBackend::renderBatch(batch); | ||
| 391 | } | ||
| 392 | |||
| 393 | // TODO: why do we seem to create extra BatchItemDetails when we resize the window?? what's that?? | 375 | // TODO: why do we seem to create extra BatchItemDetails when we resize the window?? what's that?? |
| 394 | void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) { | 376 | void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) { |
| 395 | #ifdef WANT_DEBUG | 377 | #ifdef WANT_DEBUG |
| @@ -691,12 +673,6 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con · 295 unmodified lines | |||
| 691 | #endif | 673 | #endif |
| 692 | } | 674 | } |
| 693 | 675 | ||
| 694 | void GeometryCache::renderVertices(gpu::Primitive primitiveType, int id) { | ||
| 695 | gpu::Batch batch; | ||
| 696 | renderVertices(batch, primitiveType, id); | ||
| 697 | gpu::GLBackend::renderBatch(batch); | ||
| 698 | } | ||
| 699 | |||
| 700 | void GeometryCache::renderVertices(gpu::Batch& batch, gpu::Primitive primitiveType, int id) { | 676 | void GeometryCache::renderVertices(gpu::Batch& batch, gpu::Primitive primitiveType, int id) { |
| 701 | BatchItemDetails& details = _registeredVertices[id]; | 677 | BatchItemDetails& details = _registeredVertices[id]; |
| 702 | if (details.isCreated) { | 678 | if (details.isCreated) { |
| @@ -706,12 +682,6 @@ void GeometryCache::renderVertices(gpu::Batch& batch, gpu::Primitive primitiveTy · 3 unmodified lines | |||
| 706 | } | 682 | } |
| 707 | } | 683 | } |
| 708 | 684 | ||
| 709 | void GeometryCache::renderSolidCube(float size, const glm::vec4& color) { | ||
| 710 | gpu::Batch batch; | ||
| 711 | renderSolidCube(batch, size, color); | ||
| 712 | gpu::GLBackend::renderBatch(batch); | ||
| 713 | } | ||
| 714 | |||
| 715 | void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color) { | 685 | void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color) { |
| 716 | Vec2Pair colorKey(glm::vec2(color.x, color.y), glm::vec2(color.z, color.y)); | 686 | Vec2Pair colorKey(glm::vec2(color.x, color.y), glm::vec2(color.z, color.y)); |
| 717 | const int FLOATS_PER_VERTEX = 3; | 687 | const int FLOATS_PER_VERTEX = 3; |
| @@ -833,12 +803,6 @@ void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::ve · 115 unmodified lines | |||
| 833 | batch.drawIndexed(gpu::TRIANGLES, indices); | 803 | batch.drawIndexed(gpu::TRIANGLES, indices); |
| 834 | } | 804 | } |
| 835 | 805 | ||
| 836 | void GeometryCache::renderWireCube(float size, const glm::vec4& color) { | ||
| 837 | gpu::Batch batch; | ||
| 838 | renderWireCube(batch, size, color); | ||
| 839 | gpu::GLBackend::renderBatch(batch); | ||
| 840 | } | ||
| 841 | |||
| 842 | void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color) { | 806 | void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color) { |
| 843 | Vec2Pair colorKey(glm::vec2(color.x, color.y),glm::vec2(color.z, color.y)); | 807 | Vec2Pair colorKey(glm::vec2(color.x, color.y),glm::vec2(color.z, color.y)); |
| 844 | const int FLOATS_PER_VERTEX = 3; | 808 | const int FLOATS_PER_VERTEX = 3; |
| @@ -922,12 +886,6 @@ void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec · 77 unmodified lines | |||
| 922 | batch.drawIndexed(gpu::LINES, indices); | 886 | batch.drawIndexed(gpu::LINES, indices); |
| 923 | } | 887 | } |
| 924 | 888 | ||
| 925 | void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) { | ||
| 926 | gpu::Batch batch; | ||
| 927 | renderBevelCornersRect(batch, x, y, width, height, bevelDistance, color, id); | ||
| 928 | gpu::GLBackend::renderBatch(batch); | ||
| 929 | } | ||
| 930 | |||
| 931 | void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) { | 889 | void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) { |
| 932 | bool registered = (id != UNKNOWN_ID); | 890 | bool registered = (id != UNKNOWN_ID); |
| 933 | Vec3Pair key(glm::vec3(x, y, 0.0f), glm::vec3(width, height, bevelDistance)); | 891 | Vec3Pair key(glm::vec3(x, y, 0.0f), glm::vec3(width, height, bevelDistance)); |
| @@ -1029,12 +987,6 @@ void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int · 95 unmodified lines | |||
| 1029 | batch.draw(gpu::TRIANGLE_STRIP, details.vertices, 0); | 987 | batch.draw(gpu::TRIANGLE_STRIP, details.vertices, 0); |
| 1030 | } | 988 | } |
| 1031 | 989 | ||
| 1032 | void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) { | ||
| 1033 | gpu::Batch batch; | ||
| 1034 | renderQuad(batch, minCorner, maxCorner, color, id); | ||
| 1035 | gpu::GLBackend::renderBatch(batch); | ||
| 1036 | } | ||
| 1037 | |||
| 1038 | void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) { | 990 | void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) { |
| 1039 | bool registered = (id != UNKNOWN_ID); | 991 | bool registered = (id != UNKNOWN_ID); |
| 1040 | Vec4Pair key(glm::vec4(minCorner.x, minCorner.y, maxCorner.x, maxCorner.y), color); | 992 | Vec4Pair key(glm::vec4(minCorner.x, minCorner.y, maxCorner.x, maxCorner.y), color); |
| @@ -1111,12 +1063,6 @@ void GeometryCache::renderUnitCube(gpu::Batch& batch) { · 70 unmodified lines | |||
| 1111 | renderSolidCube(batch, 1, color); | 1063 | renderSolidCube(batch, 1, color); |
| 1112 | } | 1064 | } |
| 1113 | 1065 | ||
| 1114 | void GeometryCache::renderUnitQuad(const glm::vec4& color, int id) { | ||
| 1115 | gpu::Batch batch; | ||
| 1116 | renderUnitQuad(batch, color, id); | ||
| 1117 | gpu::GLBackend::renderBatch(batch); | ||
| 1118 | } | ||
| 1119 | |||
| 1120 | void GeometryCache::renderUnitQuad(gpu::Batch& batch, const glm::vec4& color, int id) { | 1066 | void GeometryCache::renderUnitQuad(gpu::Batch& batch, const glm::vec4& color, int id) { |
| 1121 | static const glm::vec2 topLeft(-1, 1); | 1067 | static const glm::vec2 topLeft(-1, 1); |
| 1122 | static const glm::vec2 bottomRight(1, -1); | 1068 | static const glm::vec2 bottomRight(1, -1); |
| @@ -1126,14 +1072,6 @@ void GeometryCache::renderUnitQuad(gpu::Batch& batch, const glm::vec4& color, in · 3 unmodified lines | |||
| 1126 | } | 1072 | } |
| 1127 | 1073 | ||
| 1128 | 1074 | ||
| 1129 | void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, | ||
| 1130 | const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, | ||
| 1131 | const glm::vec4& color, int id) { | ||
| 1132 | gpu::Batch batch; | ||
| 1133 | renderQuad(batch, minCorner, maxCorner, texCoordMinCorner, texCoordMaxCorner, color, id); | ||
| 1134 | gpu::GLBackend::renderBatch(batch); | ||
| 1135 | } | ||
| 1136 | |||
| 1137 | void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, | 1075 | void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, |
| 1138 | const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, | 1076 | const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, |
| 1139 | const glm::vec4& color, int id) { | 1077 | const glm::vec4& color, int id) { |
| @@ -1214,12 +1152,6 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co · 74 unmodified lines | |||
| 1214 | batch.draw(gpu::QUADS, 4, 0); | 1152 | batch.draw(gpu::QUADS, 4, 0); |
| 1215 | } | 1153 | } |
| 1216 | 1154 | ||
| 1217 | void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) { | ||
| 1218 | gpu::Batch batch; | ||
| 1219 | renderQuad(batch, minCorner, maxCorner, color, id); | ||
| 1220 | gpu::GLBackend::renderBatch(batch); | ||
| 1221 | } | ||
| 1222 | |||
| 1223 | void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) { | 1155 | void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) { |
| 1224 | bool registered = (id != UNKNOWN_ID); | 1156 | bool registered = (id != UNKNOWN_ID); |
| 1225 | Vec3PairVec4 key(Vec3Pair(minCorner, maxCorner), color); | 1157 | Vec3PairVec4 key(Vec3Pair(minCorner, maxCorner), color); |
| @@ -1291,17 +1223,6 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, co · 65 unmodified lines | |||
| 1291 | batch.draw(gpu::QUADS, 4, 0); | 1223 | batch.draw(gpu::QUADS, 4, 0); |
| 1292 | } | 1224 | } |
| 1293 | 1225 | ||
| 1294 | void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomLeft, | ||
| 1295 | const glm::vec3& bottomRight, const glm::vec3& topRight, | ||
| 1296 | const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft, | ||
| 1297 | const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight, | ||
| 1298 | const glm::vec4& color, int id) { | ||
| 1299 | gpu::Batch batch; | ||
| 1300 | renderQuad(batch, topLeft, bottomLeft, bottomRight, topRight, texCoordTopLeft, texCoordBottomLeft, | ||
| 1301 | texCoordBottomRight, texCoordTopRight, color, id); | ||
| 1302 | gpu::GLBackend::renderBatch(batch); | ||
| 1303 | } | ||
| 1304 | |||
| 1305 | void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, const glm::vec3& bottomLeft, | 1226 | void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, const glm::vec3& bottomLeft, |
| 1306 | const glm::vec3& bottomRight, const glm::vec3& topRight, | 1227 | const glm::vec3& bottomRight, const glm::vec3& topRight, |
| 1307 | const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft, | 1228 | const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft, |
| @@ -1395,12 +1316,6 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons · 87 unmodified lines | |||
| 1395 | batch.draw(gpu::QUADS, 4, 0); | 1316 | batch.draw(gpu::QUADS, 4, 0); |
| 1396 | } | 1317 | } |
| 1397 | 1318 | ||
| 1398 | void GeometryCache::renderDashedLine(const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) { | ||
| 1399 | gpu::Batch batch; | ||
| 1400 | renderDashedLine(batch, start, end, color, id); | ||
| 1401 | gpu::GLBackend::renderBatch(batch); | ||
| 1402 | } | ||
| 1403 | |||
| 1404 | void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) { | 1319 | void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) { |
| 1405 | bool registered = (id != UNKNOWN_ID); | 1320 | bool registered = (id != UNKNOWN_ID); |
| 1406 | Vec3PairVec2Pair key(Vec3Pair(start, end), Vec2Pair(glm::vec2(color.x, color.y), glm::vec2(color.z, color.w))); | 1321 | Vec3PairVec2Pair key(Vec3Pair(start, end), Vec2Pair(glm::vec2(color.x, color.y), glm::vec2(color.z, color.w))); |
| @@ -1555,13 +1470,6 @@ void GeometryCache::BatchItemDetails::clear() { · 148 unmodified lines | |||
| 1555 | stream.reset(); | 1470 | stream.reset(); |
| 1556 | } | 1471 | } |
| 1557 | 1472 | ||
| 1558 | void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2, | ||
| 1559 | const glm::vec4& color1, const glm::vec4& color2, int id) { | ||
| 1560 | gpu::Batch batch; | ||
| 1561 | renderLine(batch, p1, p2, color1, color2, id); | ||
| 1562 | gpu::GLBackend::renderBatch(batch); | ||
| 1563 | } | ||
| 1564 | |||
| 1565 | void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2, | 1473 | void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2, |
| 1566 | const glm::vec4& color1, const glm::vec4& color2, int id) { | 1474 | const glm::vec4& color1, const glm::vec4& color2, int id) { |
| 1567 | 1475 | ||
| @@ -1646,12 +1554,6 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm · 78 unmodified lines | |||
| 1646 | batch.draw(gpu::LINES, 2, 0); | 1554 | batch.draw(gpu::LINES, 2, 0); |
| 1647 | } | 1555 | } |
| 1648 | 1556 | ||
| 1649 | void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color1, const glm::vec4& color2, int id) { | ||
| 1650 | gpu::Batch batch; | ||
| 1651 | renderLine(batch, p1, p2, color1, color2, id); | ||
| 1652 | gpu::GLBackend::renderBatch(batch); | ||
| 1653 | } | ||
| 1654 | |||
| 1655 | void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2, | 1557 | void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2, |
| 1656 | const glm::vec4& color1, const glm::vec4& color2, int id) { | 1558 | const glm::vec4& color1, const glm::vec4& color2, int id) { |
| 1657 | 1559 | ||