History

Fix renderHalfCylinder so it only has 2 args now.

Hifi Test Account committed 13 years ago

Commit d725bcd1 parent 24e47752 files · +11 −10Browse files

Showing the changes to interface/src/renderer/GeometryCache.cpp (1 of 2 files). Show all

Unified · Split

interface/src/renderer/GeometryCache.cpp+10−9
@@ -164,22 +164,23 @@ void GeometryCache::renderSquare(int xDivisions, int yDivisions) { · 163 unmodified lines
164164 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
165165 }
166166
167−void GeometryCache::renderHalfCylinder(int slices, int stacks, float radius, float height) {
167+void GeometryCache::renderHalfCylinder(int slices, int stacks) {
168168 VerticesIndices& vbo = _halfCylinderVBOs[IntPair(slices, stacks)];
169− int vertices = slices * (stacks - 1) + 1;
170− int indices = slices * 2 * 3 * (stacks - 2) + slices * 3;
169+ int vertices = (slices + 1) * stacks;
170+ int indices = 2 * 3 * slices * (stacks - 1);
171171 if (vbo.first == 0) {
172172 GLfloat* vertexData = new GLfloat[vertices * 3];
173173 GLfloat* vertex = vertexData;
174− for (int i = 0; i < stacks; i++) {
175− float z = i * height / stacks;
174+ for (int i = 0; i <= (stacks - 1); i++) {
175+ float y = (float)i / (stacks - 1);
176+ float radius = 1.0f;
176177
177− for (int j = 0; j < slices; j++) {
178+ for (int j = 0; j <= slices; j++) {
178179 float theta = PIf * j / slices;
179180
180181 *(vertex++) = sinf(theta) * radius;
182+ *(vertex++) = y;
181183 *(vertex++) = cosf(theta) * radius;
182− *(vertex++) = z;
183184 }
184185 }
185186
@@ -192,8 +193,8 @@ void GeometryCache::renderHalfCylinder(int slices, int stacks, float radius, flo · 6 unmodified lines
192193 GLushort* indexData = new GLushort[indices];
193194 GLushort* index = indexData;
194195 for (int i = 0; i < stacks - 1; i++) {
195− GLushort bottom = i * slices;
196− GLushort top = bottom + slices;
196+ GLushort bottom = i * (slices + 1);
197+ GLushort top = bottom + slices + 1;
197198 for (int j = 0; j < slices; j++) {
198199 int next = (j + 1) % slices;
199200