private void updateVertices() { verticesMustBeUpdated = false; Array<Vector2> vertices = new Array<Vector2>(); float step = MathUtils.PI2 / (float) vertexCount; for (float i = 0; i < vertexCount; i++) { Vector2 v = new Vector2(radius, 0); v.rotateRad(step * i); vertices.add(v); } for (OutlinePolygon outlinePolygon : basic.outlinePolygons) { outlinePolygon.setVertices(vertices); } if (basic.texturePolygon != null) { basic.texturePolygon.setVertices(vertices); } if (basic.physicsThing != null) { ((Circle) basic.physicsThing).setRadius(radius); } }
/** * Draw the edges defined by {@link #setVertices(Array)}. If {@link * OutlineMerger#mergeOutlines(Array)} has been used on this {@link OutlinePolygon} then the draw * method may just be redirected to this outlinePolygon's parents. * * @param batch Accumulates data and sends it in large portions to the gpu, instead of sending * small portions more often. * @return this for chaining. */ public OutlinePolygon draw(PrettyPolygonBatch batch) { if (myParents.size > 0) { // if i have a parent i will not be drawn for (OutlinePolygon outlinePolygon : myParents) { outlinePolygon.draw(batch); } return this; } drawInvocations++; if (myChildren.size == 0 || drawInvocations >= myChildren.size) { if (!visible) return this; debugRenderer.queueIfEnabled(batch); timeOfLastDrawCall = System.currentTimeMillis(); // if i don't have any children i will just attempt to draw right away // also if all my children has had their draw method called i will attempt to draw drawInvocations = 0; if (halfWidth <= 0) return this; if (color.a <= 0) return this; if (weight <= 0) return this; if (scale <= 0) return this; if (!drawInside && !drawOutside) return this; Rectangle frustum = this.frustum.set(batch.frustum); tmpColor.set(color).a *= opacity; updateStripAndCulling(); for (BoundingBox box : boundingBoxes) { Rectangle cullingArea = getCullingArea(tmpRectangle, box.rectangle, angleRad, position, scale); if (frustum.overlaps(cullingArea)) { // if we reached here we can draw the vertices within this particular BoundingBox if (drawInside) { batch.drawOutline( vertexDataArray, closedPolygon, true, box.begin, box.begin + box.count + 1, box.dataCount, tmpColor, scale, angleRad, position.x, position.y, weight); } if (drawOutside) { batch.drawOutline( vertexDataArray, closedPolygon, false, box.begin, box.begin + box.count + 1, box.dataCount, tmpColor, scale, angleRad, position.x, position.y, weight); } } } } return this; }