History

some cleanup

ZappoMan committed 11 years ago

Commit 30f985a1 parent 96317613 files · +59 −64Browse files

Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 3 files). Show all

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+52−61
@@ -38,10 +38,12 @@ GeometryCache::GeometryCache() : · 37 unmodified lines
3838 }
3939
4040 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
4547 }
4648
4749 const int NUM_VERTICES_PER_TRIANGLE = 3;
@@ -53,21 +55,16 @@ const int NUM_BYTES_PER_INDEX = sizeof(GLushort); · 5 unmodified lines
5355
5456 void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid) {
5557
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);
6260 Vec3Pair colorKey(glm::vec3(color.x, color.y, slices),glm::vec3(color.z, color.y, stacks));
6361
64−
6562 int vertices = slices * (stacks - 1) + 2;
6663 int indices = slices * (stacks - 1) * NUM_VERTICES_PER_TRIANGULATED_QUAD;
6764
68− if (!_sphereVertices.contains(keyRadius)) {
65+ if (!_sphereVertices.contains(radiusKey)) {
6966 gpu::BufferPointer verticesBuffer(new gpu::Buffer());
70− _sphereVertices[keyRadius] = verticesBuffer;
67+ _sphereVertices[radiusKey] = verticesBuffer;
7168
7269 GLfloat* vertexData = new GLfloat[vertices * NUM_COORDS_PER_VERTEX];
7370 GLfloat* vertex = vertexData;
@@ -99,17 +96,20 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm · 25 unmodified lines
9996
10097 verticesBuffer->append(sizeof(GLfloat) * vertices * NUM_COORDS_PER_VERTEX, (gpu::Buffer::Byte*) vertexData);
10198 delete[] vertexData;
102−qDebug() << "GeometryCache::renderSphere()... --- CREATING VERTICES BUFFER";
103−qDebug() << " radius:" << radius;
104−qDebug() << " slices:" << slices;
105−qDebug() << " stacks:" << stacks;
10699
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
108108 }
109109
110− if (!_sphereIndices.contains(keySlicesStacks)) {
110+ if (!_sphereIndices.contains(slicesStacksKey)) {
111111 gpu::BufferPointer indicesBuffer(new gpu::Buffer());
112− _sphereIndices[keySlicesStacks] = indicesBuffer;
112+ _sphereIndices[slicesStacksKey] = indicesBuffer;
113113
114114 GLushort* indexData = new GLushort[indices];
115115 GLushort* index = indexData;
@@ -162,14 +162,16 @@ qDebug() << " _sphereVertices.size():" << _sphereVertices.size(); · 46 unmodified lines
162162 }
163163 indicesBuffer->append(sizeof(GLushort) * indices, (gpu::Buffer::Byte*) indexData);
164164 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
173175 }
174176
175177 if (!_sphereColors.contains(colorKey)) {
@@ -191,27 +193,20 @@ qDebug() << " _sphereIndices.size():" << _sphereIndices.size(); · 15 unmodified lines
191193 colorBuffer->append(sizeof(int) * vertices, (gpu::Buffer::Byte*) colorData);
192194 delete[] colorData;
193195
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
201204
202205 }
203− gpu::BufferPointer verticesBuffer = _sphereVertices[keyRadius];
204− gpu::BufferPointer indicesBuffer = _sphereIndices[keySlicesStacks];
206+ gpu::BufferPointer verticesBuffer = _sphereVertices[radiusKey];
207+ gpu::BufferPointer indicesBuffer = _sphereIndices[slicesStacksKey];
205208 gpu::BufferPointer colorBuffer = _sphereColors[colorKey];
206209
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−
215210 const int VERTICES_SLOT = 0;
216211 const int NORMALS_SLOT = 1;
217212 const int COLOR_SLOT = 2;
@@ -348,8 +343,6 @@ void GeometryCache::renderCone(float base, float height, int slices, int stacks) · 130 unmodified lines
348343 }
349344
350345 void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& color) {
351− //qDebug() << "GeometryCache::renderGrid(xDivisions["<<xDivisions<<"], yDivisions["<<yDivisions<<"])";
352−
353346 IntPair key(xDivisions, yDivisions);
354347 Vec3Pair colorKey(glm::vec3(color.x, color.y, yDivisions),glm::vec3(color.z, color.y, xDivisions));
355348
@@ -436,13 +429,15 @@ void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& · 80 unmodified lines
436429 // TODO: properly handle the x,y,w,h changing for an ID
437430 // TODO: why do we seem to create extra BatchItemDetails when we resize the window?? what's that??
438431 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<<"], "
440434 "y["<<y<<"],"
441435 "w["<<width<<"],"
442436 "h["<<height<<"],"
443437 "rows["<<rows<<"],"
444438 "cols["<<cols<<"],"
445439 " id:"<<id<<")...";
440+ #endif
446441
447442 bool registered = (id != UNKNOWN_ID);
448443 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
542537 }
543538
544539 void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, const glm::vec4& color) {
545− //qDebug() << "GeometryCache::updateVertices(vec2.... id=" << id <<")...";
546540 BatchItemDetails& details = _registeredVertices[id];
547541
548542 if (details.isCreated) {
@@ -605,7 +599,6 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con · 56 unmodified lines
605599 }
606600
607601 void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, const glm::vec4& color) {
608− //qDebug() << "GeometryCache::updateVertices(id=" << id <<")...";
609602 BatchItemDetails& details = _registeredVertices[id];
610603
611604 if (details.isCreated) {
@@ -669,8 +662,6 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con · 57 unmodified lines
669662 }
670663
671664 void GeometryCache::renderVertices(gpu::Primitive primitiveType, int id) {
672− //qDebug() << "GeometryCache::renderVertices(id=" << id <<")...";
673−
674665 BatchItemDetails& details = _registeredVertices[id];
675666 if (details.isCreated) {
676667 gpu::Batch batch;
@@ -900,7 +891,6 @@ void GeometryCache::renderWireCube(float size, const glm::vec4& color) { · 223 unmodified lines
900891 }
901892
902893 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 <<")...";
904894 bool registered = (id != UNKNOWN_ID);
905895 Vec3Pair key(glm::vec3(x, y, 0.0f), glm::vec3(width, height, bevelDistance));
906896 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
1008998 }
1009999
10101000 void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) {
1011− //qDebug() << "GeometryCache::renderQuad(vec2,id=" << id <<")...";
10121001 bool registered = (id != UNKNOWN_ID);
10131002 Vec2Pair key(minCorner, maxCorner);
10141003 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
10921081 const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner,
10931082 const glm::vec4& color, int id) {
10941083
1095− //qDebug() << "GeometryCache::renderQuad(vec2/texture,id=" << id <<")...";
10961084 bool registered = (id != UNKNOWN_ID);
10971085 Vec2PairPair key(Vec2Pair(minCorner, maxCorner), Vec2Pair(texCoordMinCorner, texCoordMaxCorner));
10981086 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
11831171 }
11841172
11851173 void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) {
1186− //qDebug() << "GeometryCache::renderQuad(vec3,id=" << id <<")...";
11871174 bool registered = (id != UNKNOWN_ID);
11881175 Vec3Pair key(minCorner, maxCorner);
11891176 BatchItemDetails& details = registered ? _registeredQuad3D[id] : _quad3D[key];
@@ -1471,7 +1458,9 @@ GeometryCache::BatchItemDetails::BatchItemDetails() : · 281 unmodified lines
14711458 isCreated(false)
14721459 {
14731460 population++;
1474− qDebug() << "BatchItemDetails()... population:" << population << "**********************************";
1461+ #ifdef WANT_DEBUG
1462+ qDebug() << "BatchItemDetails()... population:" << population << "**********************************";
1463+ #endif
14751464 }
14761465
14771466 GeometryCache::BatchItemDetails::BatchItemDetails(const GeometryCache::BatchItemDetails& other) :
@@ -1484,13 +1473,17 @@ GeometryCache::BatchItemDetails::BatchItemDetails(const GeometryCache::BatchItem · 6 unmodified lines
14841473 isCreated(other.isCreated)
14851474 {
14861475 population++;
1487− qDebug() << "BatchItemDetails()... population:" << population << "**********************************";
1476+ #ifdef WANT_DEBUG
1477+ qDebug() << "BatchItemDetails()... population:" << population << "**********************************";
1478+ #endif
14881479 }
14891480
14901481 GeometryCache::BatchItemDetails::~BatchItemDetails() {
14911482 population--;
14921483 clear();
1493− qDebug() << "~BatchItemDetails()... population:" << population << "**********************************";
1484+ #ifdef WANT_DEBUG
1485+ qDebug() << "~BatchItemDetails()... population:" << population << "**********************************";
1486+ #endif
14941487 }
14951488
14961489 void GeometryCache::BatchItemDetails::clear() {
@@ -1504,7 +1497,6 @@ void GeometryCache::BatchItemDetails::clear() { · 7 unmodified lines
15041497 void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2,
15051498 const glm::vec4& color1, const glm::vec4& color2, int id) {
15061499
1507− //qDebug() << "GeometryCache::renderLine(vec3)...";
15081500 bool registered = (id != UNKNOWN_ID);
15091501 Vec3Pair key(p1, p2);
15101502
@@ -1597,7 +1589,6 @@ void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2, · 86 unmodified lines
15971589 void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2,
15981590 const glm::vec4& color1, const glm::vec4& color2, int id) {
15991591
1600− //qDebug() << "GeometryCache::renderLine(vec2)...";
16011592 bool registered = (id != UNKNOWN_ID);
16021593 Vec2Pair key(p1, p2);
16031594

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t