| 215 | } |
| 216 | |
| 217 | Vec2 Spine::getKeyPoint(String name) { |
| 218 | AssertIf(_flags.isOn(Node::Cleanup), "can not operate on an invalid Spine"); |
| 219 | auto tokens = name.split("/"_slice); |
| 220 | if (tokens.size() == 1) { |
| 221 | auto slotName = toSpineString(name); |
| 222 | auto slot = _skeletonData->getSkel()->findSlot(slotName); |
| 223 | if (!slot) return Vec2::zero; |
| 224 | if (auto skin = _skeleton->getSkin()) { |
| 225 | auto slotIndex = slot->getIndex(); |
| 226 | spine::Array<spine::Attachment*> attachments; |
| 227 | skin->findAttachmentsForSlot(slotIndex, attachments); |
| 228 | for (size_t i = 0; i < attachments.size(); ++i) { |
| 229 | auto attachment = attachments[i]; |
| 230 | if (attachment->getRTTI().isExactly(spine::PointAttachment::rtti)) { |
| 231 | spine::PointAttachment* point = s_cast<spine::PointAttachment*>(attachment); |
| 232 | Vec2 res = Vec2::zero; |
| 233 | auto& bone = _skeleton->getSlots()[slotIndex]->getBone().getAppliedPose(); |
| 234 | point->computeWorldPosition(bone, res.x, res.y); |
| 235 | return res; |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | } else if (tokens.size() == 2) { |
| 240 | auto slotName = toSpineString(tokens.front()); |
| 241 | auto slot = _skeletonData->getSkel()->findSlot(slotName); |
| 242 | if (!slot) return Vec2::zero; |
| 243 | int slotIndex = slot->getIndex(); |
| 244 | if (slotIndex < 0) return Vec2::zero; |
| 245 | auto attachmentName = toSpineString(tokens.back()); |
| 246 | auto attachment = _skeleton->getAttachment(slotIndex, attachmentName); |
| 247 | if (attachment && attachment->getRTTI().isExactly(spine::PointAttachment::rtti)) { |
| 248 | spine::PointAttachment* point = s_cast<spine::PointAttachment*>(attachment); |
| 249 | Vec2 res = Vec2::zero; |
| 250 | auto& bone = _skeleton->getSlots()[slotIndex]->getBone().getAppliedPose(); |
| 251 | point->computeWorldPosition(bone, res.x, res.y); |
| 252 | return res; |
| 253 | } |
| 254 | } |
| 255 | return Vec2::zero; |
| 256 | } |
| 257 | |
| 258 | float Spine::play(String name, bool loop) { |
| 259 | AssertIf(_flags.isOn(Node::Cleanup), "can not operate on an invalid Spine"); |
nothing calls this directly
no test coverage detected