MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / getKeyPoint

Method getKeyPoint

Source/Node/Spine.cpp:217–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217Vec2 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
258float Spine::play(String name, bool loop) {
259 AssertIf(_flags.isOn(Node::Cleanup), "can not operate on an invalid Spine");

Callers

nothing calls this directly

Calls 14

isOnMethod · 0.80
getSkelMethod · 0.80
getSkinMethod · 0.80
isExactlyMethod · 0.80
computeWorldPositionMethod · 0.80
splitMethod · 0.65
sizeMethod · 0.45
findSlotMethod · 0.45
getIndexMethod · 0.45
getBoneMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected