| 157 | } |
| 158 | |
| 159 | float PolygonInfo::getArea() const |
| 160 | { |
| 161 | float area = 0; |
| 162 | V3F_C4B_T2F* verts = triangles.verts; |
| 163 | unsigned short* indices = triangles.indices; |
| 164 | for (unsigned int i = 0; i < triangles.indexCount; i += 3) |
| 165 | { |
| 166 | auto A = verts[indices[i]].vertices; |
| 167 | auto B = verts[indices[i + 1]].vertices; |
| 168 | auto C = verts[indices[i + 2]].vertices; |
| 169 | area += (A.x * (B.y - C.y) + B.x * (C.y - A.y) + C.x * (A.y - B.y)) / 2; |
| 170 | } |
| 171 | return area; |
| 172 | } |
| 173 | |
| 174 | AutoPolygon::AutoPolygon(std::string_view filename) |
| 175 | : _image(nullptr), _data(nullptr), _filename(""), _width(0), _height(0), _scaleFactor(0) |
no outgoing calls