///////////////////////////////////////////////////////
| 215 | |
| 216 | //////////////////////////////////////////////////////////// |
| 217 | void Shape::update() |
| 218 | { |
| 219 | // Get the total number of points of the shape |
| 220 | const std::size_t count = getPointCount(); |
| 221 | if (count < 3) |
| 222 | { |
| 223 | m_vertices.clear(); |
| 224 | m_outlineVertices.clear(); |
| 225 | return; |
| 226 | } |
| 227 | |
| 228 | m_vertices.resize(count + 2); // + 2 for center and repeated first point |
| 229 | |
| 230 | // Position |
| 231 | for (std::size_t i = 0; i < count; ++i) |
| 232 | m_vertices[i + 1].position = getPoint(i); |
| 233 | m_vertices[count + 1].position = m_vertices[1].position; |
| 234 | |
| 235 | // Update the bounding rectangle |
| 236 | m_vertices[0] = m_vertices[1]; // so that the result of getBounds() is correct |
| 237 | m_insideBounds = m_vertices.getBounds(); |
| 238 | |
| 239 | // Compute the center and make it the first vertex |
| 240 | m_vertices[0].position = m_insideBounds.getCenter(); |
| 241 | |
| 242 | // Color |
| 243 | updateFillColors(); |
| 244 | |
| 245 | // Texture coordinates |
| 246 | updateTexCoords(); |
| 247 | |
| 248 | // Outline |
| 249 | updateOutline(); |
| 250 | } |
| 251 | |
| 252 | |
| 253 | //////////////////////////////////////////////////////////// |
no test coverage detected