| 228 | } |
| 229 | |
| 230 | unsigned int AutoPolygon::getSquareValue(unsigned int x, unsigned int y, const Rect& rect, float threshold) |
| 231 | { |
| 232 | /* |
| 233 | checking the 2x2 pixel grid, assigning these values to each pixel, if not transparent |
| 234 | +---+---+ |
| 235 | | 1 | 2 | |
| 236 | +---+---+ |
| 237 | | 4 | 8 | <- current pixel (curx,cury) |
| 238 | +---+---+ |
| 239 | */ |
| 240 | unsigned int sv = 0; |
| 241 | // NOTE: due to the way we pick points from texture, rect needs to be smaller, otherwise it goes outside 1 pixel |
| 242 | auto fixedRect = Rect(rect.origin, rect.size - Vec2(2, 2)); |
| 243 | |
| 244 | Vec2 tl = Vec2(x - 1.0f, y - 1.0f); |
| 245 | sv += (fixedRect.containsPoint(tl) && getAlphaByPos(tl) > threshold) ? 1 : 0; |
| 246 | Vec2 tr = Vec2(x - 0.0f, y - 1.0f); |
| 247 | sv += (fixedRect.containsPoint(tr) && getAlphaByPos(tr) > threshold) ? 2 : 0; |
| 248 | Vec2 bl = Vec2(x - 1.0f, y - 0.0f); |
| 249 | sv += (fixedRect.containsPoint(bl) && getAlphaByPos(bl) > threshold) ? 4 : 0; |
| 250 | Vec2 br = Vec2(x - 0.0f, y - 0.0f); |
| 251 | sv += (fixedRect.containsPoint(br) && getAlphaByPos(br) > threshold) ? 8 : 0; |
| 252 | AXASSERT(sv != 0 && sv != 15, "square value should not be 0, or 15"); |
| 253 | return sv; |
| 254 | } |
| 255 | |
| 256 | std::vector<ax::Vec2> AutoPolygon::marchSquare(const Rect& rect, const Vec2& start, float threshold) |
| 257 | { |
nothing calls this directly
no test coverage detected