Showing the changes to interface/src/renderer/GeometryCache.cpp (1 of 2 files). Show all
Unified · Split
| @@ -164,22 +164,23 @@ void GeometryCache::renderSquare(int xDivisions, int yDivisions) { · 163 unmodified lines | |||
| 164 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | 164 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | void GeometryCache::renderHalfCylinder(int slices, int stacks, float radius, float height) { | 167 | void GeometryCache::renderHalfCylinder(int slices, int stacks) { |
| 168 | VerticesIndices& vbo = _halfCylinderVBOs[IntPair(slices, stacks)]; | 168 | VerticesIndices& vbo = _halfCylinderVBOs[IntPair(slices, stacks)]; |
| 169 | int vertices = slices * (stacks - 1) + 1; | 169 | int vertices = (slices + 1) * stacks; |
| 170 | int indices = slices * 2 * 3 * (stacks - 2) + slices * 3; | 170 | int indices = 2 * 3 * slices * (stacks - 1); |
| 171 | if (vbo.first == 0) { | 171 | if (vbo.first == 0) { |
| 172 | GLfloat* vertexData = new GLfloat[vertices * 3]; | 172 | GLfloat* vertexData = new GLfloat[vertices * 3]; |
| 173 | GLfloat* vertex = vertexData; | 173 | GLfloat* vertex = vertexData; |
| 174 | for (int i = 0; i < stacks; i++) { | 174 | for (int i = 0; i <= (stacks - 1); i++) { |
| 175 | float z = i * height / stacks; | 175 | float y = (float)i / (stacks - 1); |
| 176 | float radius = 1.0f; | ||
| 176 | 177 | ||
| 177 | for (int j = 0; j < slices; j++) { | 178 | for (int j = 0; j <= slices; j++) { |
| 178 | float theta = PIf * j / slices; | 179 | float theta = PIf * j / slices; |
| 179 | 180 | ||
| 180 | *(vertex++) = sinf(theta) * radius; | 181 | *(vertex++) = sinf(theta) * radius; |
| 182 | *(vertex++) = y; | ||
| 181 | *(vertex++) = cosf(theta) * radius; | 183 | *(vertex++) = cosf(theta) * radius; |
| 182 | *(vertex++) = z; | ||
| 183 | } | 184 | } |
| 184 | } | 185 | } |
| 185 | 186 | ||
| @@ -192,8 +193,8 @@ void GeometryCache::renderHalfCylinder(int slices, int stacks, float radius, flo · 6 unmodified lines | |||
| 192 | GLushort* indexData = new GLushort[indices]; | 193 | GLushort* indexData = new GLushort[indices]; |
| 193 | GLushort* index = indexData; | 194 | GLushort* index = indexData; |
| 194 | for (int i = 0; i < stacks - 1; i++) { | 195 | for (int i = 0; i < stacks - 1; i++) { |
| 195 | GLushort bottom = i * slices; | 196 | GLushort bottom = i * (slices + 1); |
| 196 | GLushort top = bottom + slices; | 197 | GLushort top = bottom + slices + 1; |
| 197 | for (int j = 0; j < slices; j++) { | 198 | for (int j = 0; j < slices; j++) { |
| 198 | int next = (j + 1) % slices; | 199 | int next = (j + 1) % slices; |
| 199 | 200 | ||