| 190 | } |
| 191 | |
| 192 | SpriteHandlePoint* Sprite::getHandlePoint( |
| 193 | Transform::UnitVector& cameraPosition, int posX, int posY) |
| 194 | { |
| 195 | const Transform::UnitVector pixelCamera |
| 196 | = cameraPosition.to<Transform::Units::ScenePixels>(); |
| 197 | Transform::UnitVector targetPos |
| 198 | = Transform::UnitVector(posX, posY, Transform::Units::ScenePixels); |
| 199 | targetPos = m_positionTransformer(targetPos, -pixelCamera, m_layer); |
| 200 | unsigned int i = 0; |
| 201 | for (Transform::Referential& ref : Transform::Referential::Referentials) |
| 202 | { |
| 203 | const Transform::UnitVector refPoint |
| 204 | = Rect::getPosition(ref).to<Transform::Units::ScenePixels>(); |
| 205 | int lowerXBound = std::min(refPoint.x - SpriteHandlePoint::radius, |
| 206 | refPoint.x + SpriteHandlePoint::radius); |
| 207 | int upperXBound = std::max(refPoint.x - SpriteHandlePoint::radius, |
| 208 | refPoint.x + SpriteHandlePoint::radius); |
| 209 | if (obe::Utils::Math::isBetween(targetPos.x, lowerXBound, upperXBound) |
| 210 | && ref != Transform::Referential::Center) |
| 211 | { |
| 212 | int lowerYBound = std::min(refPoint.y - SpriteHandlePoint::radius, |
| 213 | refPoint.y + SpriteHandlePoint::radius); |
| 214 | int upperYBound = std::max(refPoint.y - SpriteHandlePoint::radius, |
| 215 | refPoint.y + SpriteHandlePoint::radius); |
| 216 | if (obe::Utils::Math::isBetween(targetPos.y, lowerYBound, upperYBound)) |
| 217 | return &m_handlePoints[i]; |
| 218 | } |
| 219 | i++; |
| 220 | } |
| 221 | |
| 222 | const double radAngle = obe::Utils::Math::convertToRadian(-m_angle); |
| 223 | const double cosAngle = std::cos(radAngle); |
| 224 | const double sinAngle = std::sin(radAngle); |
| 225 | const Transform::UnitVector topPos |
| 226 | = this->getPosition(Transform::Referential::Top) |
| 227 | .to<Transform::Units::ScenePixels>(); |
| 228 | Transform::UnitVector rotHandle = topPos; |
| 229 | Transform::UnitVector result; |
| 230 | const double dy = m_size.y / 4; |
| 231 | result.x = (-dy * sinAngle) * -1; |
| 232 | result.y = (dy * cosAngle) * -1; |
| 233 | rotHandle.add(result); |
| 234 | |
| 235 | const int lowerXBound = std::min(rotHandle.x - SpriteHandlePoint::radius, |
| 236 | rotHandle.x + SpriteHandlePoint::radius); |
| 237 | const int upperXBound = std::max(rotHandle.x - SpriteHandlePoint::radius, |
| 238 | rotHandle.x + SpriteHandlePoint::radius); |
| 239 | if (obe::Utils::Math::isBetween(targetPos.x, lowerXBound, upperXBound)) |
| 240 | { |
| 241 | const int lowerYBound = std::min(rotHandle.y - SpriteHandlePoint::radius, |
| 242 | rotHandle.y + SpriteHandlePoint::radius); |
| 243 | const int upperYBound = std::max(rotHandle.y - SpriteHandlePoint::radius, |
| 244 | rotHandle.y + SpriteHandlePoint::radius); |
| 245 | if (obe::Utils::Math::isBetween(targetPos.y, lowerYBound, upperYBound)) |
| 246 | return &m_handlePoints.back(); |
| 247 | } |
| 248 | return nullptr; |
| 249 | } |
nothing calls this directly
no test coverage detected