| 836 | } |
| 837 | |
| 838 | void DrawNode::_drawPolygon(const Vec2* verts, |
| 839 | unsigned int count, |
| 840 | const Color4F& fillColor, |
| 841 | const Color4F& borderColor, |
| 842 | bool closedPolygon, |
| 843 | float thickness, |
| 844 | bool isconvex) |
| 845 | { |
| 846 | AXASSERT(count >= 0, "invalid count value"); |
| 847 | |
| 848 | bool outline = (thickness != 0.0f); |
| 849 | |
| 850 | auto _vertices = _transform(verts, count, closedPolygon); |
| 851 | |
| 852 | std::vector<V2F_C4B_T2F_Triangle> triangleList; |
| 853 | |
| 854 | int vertex_count = 0; |
| 855 | |
| 856 | // calculate the memory (important for correct drawing stuff) |
| 857 | if (closedPolygon && !isconvex && fillColor.a > 0.0f && !isConvex(_vertices.data(), count) && count >= 3) |
| 858 | { |
| 859 | std::vector<p2t::Point> p2pointsStorage; |
| 860 | p2pointsStorage.reserve(count); |
| 861 | std::vector<p2t::Point*> p2points; |
| 862 | p2points.reserve(count); |
| 863 | |
| 864 | for (unsigned int i = 0; i < count - 1; |
| 865 | i++) // count-1 is needed because of: _vertices[0] = _vertices[i < count] |
| 866 | { |
| 867 | p2points.emplace_back(&p2pointsStorage.emplace_back((float)_vertices[i].x, (float)_vertices[i].y)); |
| 868 | } |
| 869 | p2t::CDT cdt(p2points); |
| 870 | cdt.Triangulate(); |
| 871 | std::vector<p2t::Triangle*> tris = cdt.GetTriangles(); |
| 872 | |
| 873 | vertex_count += tris.size(); |
| 874 | for (auto&& t : tris) // use it later; only one calculate!!! |
| 875 | { |
| 876 | p2t::Point* vec1 = t->GetPoint(0); |
| 877 | p2t::Point* vec2 = t->GetPoint(1); |
| 878 | p2t::Point* vec3 = t->GetPoint(2); |
| 879 | |
| 880 | V2F_C4B_T2F_Triangle triangle = { |
| 881 | {Vec2(vec1->x, vec1->y), fillColor, Vec2::ZERO}, |
| 882 | {Vec2(vec2->x, vec2->y), fillColor, Vec2::ZERO}, |
| 883 | {Vec2(vec3->x, vec3->y), fillColor, Vec2::ZERO}, |
| 884 | }; |
| 885 | triangleList.emplace_back(triangle); // use it for drawing later |
| 886 | } |
| 887 | } |
| 888 | else if (fillColor.a > 0.0f) |
| 889 | { |
| 890 | vertex_count += count - 2; |
| 891 | } |
| 892 | |
| 893 | if (outline) |
| 894 | { |
| 895 | if (thickness != 1.0f || properties.drawOrder) |
nothing calls this directly
no test coverage detected