[cpp] 4.3 porting WIP

This commit is contained in:
Mario Zechner 2025-06-24 16:30:37 +02:00
parent 12c75feeb3
commit 68027c2402
4 changed files with 24 additions and 11 deletions

View File

@ -145,6 +145,9 @@ namespace spine {
/// The animation's name, which is unique across all animations in the skeleton.
const String &getName();
/// The bone indices affected by this animation.
const Vector<int> &getBones();
/// @param target After the first and before the last entry.
static int search(Vector<float> &values, float target);

View File

@ -54,7 +54,7 @@ namespace spine {
virtual void
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
MixDirection direction);
MixDirection direction, bool appliedPose);
int getBoneIndex() { return _boneIndex; }

View File

@ -32,6 +32,8 @@
#include <spine/Skeleton.h>
#include <spine/Timeline.h>
#include <spine/BoneTimeline.h>
#include <spine/RotateTimeline.h>
#include <spine/TranslateTimeline.h>
#include <spine/ContainerUtil.h>
@ -76,6 +78,10 @@ const String &Animation::getName() {
return _name;
}
const Vector<int> &Animation::getBones() {
return _bones;
}
Vector<Timeline *> &Animation::getTimelines() {
return _timelines;
}
@ -113,18 +119,21 @@ void Animation::setTimelines(Vector<Timeline *> &timelines) {
HashMap<int, bool> boneSet;
for (size_t i = 0; i < n; i++) {
Timeline *timeline = timelines[i];
Vector<PropertyId> propertyIds = timeline->getPropertyIds();
Vector<PropertyId> &propertyIds = timeline->getPropertyIds();
for (size_t ii = 0; ii < propertyIds.size(); ii++) {
_timelineIds.put(propertyIds[ii], true);
}
BoneTimeline *boneTimeline = timeline->getRTTI().instanceOf(BoneTimeline1::rtti) ? static_cast<BoneTimeline1 *>(timeline) : NULL;
if (boneTimeline) {
int boneIndex = boneTimeline->getBoneIndex();
if (!boneSet.containsKey(boneIndex)) {
boneSet.put(boneIndex, true);
_bones.add(boneIndex);
}
int boneIndex = -1;
if (timeline->getRTTI().instanceOf(BoneTimeline1::rtti)) {
boneIndex = static_cast<BoneTimeline1 *>(timeline)->getBoneIndex();
} else if (timeline->getRTTI().instanceOf(BoneTimeline2::rtti)) {
boneIndex = static_cast<BoneTimeline2 *>(timeline)->getBoneIndex();
}
if (boneIndex >= 0 && !boneSet.containsKey(boneIndex)) {
boneSet.put(boneIndex, true);
_bones.add(boneIndex);
}
}
}

View File

@ -58,17 +58,18 @@ void InheritTimeline::setFrame(int frame, float time, Inherit inherit) {
void InheritTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
MixBlend blend, MixDirection direction) {
MixBlend blend, MixDirection direction, bool appliedPose) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
SP_UNUSED(alpha);
SP_UNUSED(appliedPose);
Bone *bone = skeleton.getBones()[_boneIndex];
if (!bone->isActive()) return;
if (direction == MixDirection_Out) {
if (blend == MixBlend_Setup) bone->setInherit(bone->_data.getInherit());
if (blend == MixBlend_Setup) bone->_inherit = bone->_data.getInherit();
return;
}