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 | 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 | 168 | 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); | |
| 171 | 171 | if (vbo.first == 0) { |
| 172 | 172 | GLfloat* vertexData = new GLfloat[vertices * 3]; |
| 173 | 173 | 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; | |
| 176 | 177 | |
| 177 | − for (int j = 0; j < slices; j++) { | |
| 178 | + for (int j = 0; j <= slices; j++) { | |
| 178 | 179 | float theta = PIf * j / slices; |
| 179 | 180 | |
| 180 | 181 | *(vertex++) = sinf(theta) * radius; |
| 182 | + *(vertex++) = y; | |
| 181 | 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 | 193 | GLushort* indexData = new GLushort[indices]; |
| 193 | 194 | GLushort* index = indexData; |
| 194 | 195 | 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; | |
| 197 | 198 | for (int j = 0; j < slices; j++) { |
| 198 | 199 | int next = (j + 1) % slices; |
| 199 | 200 | |