mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
Type hierarchy fixes.
This commit is contained in:
parent
90536c3b49
commit
5347aed45a
@ -40,12 +40,19 @@ namespace spine {
|
||||
|
||||
/// An interface for timelines which change the property of a bone.
|
||||
class SP_API BoneTimeline {
|
||||
RTTI_DECL
|
||||
|
||||
public:
|
||||
BoneTimeline();
|
||||
virtual ~BoneTimeline();
|
||||
|
||||
BoneTimeline(int boneIndex) : _boneIndex(boneIndex) {}
|
||||
virtual ~BoneTimeline() {}
|
||||
|
||||
/// The index of the bone in Skeleton::getBones() that will be changed when this timeline is applied.
|
||||
virtual int getBoneIndex() = 0;
|
||||
virtual int getBoneIndex() { return _boneIndex; }
|
||||
|
||||
virtual void setBoneIndex(int inValue) { _boneIndex = inValue; }
|
||||
|
||||
protected:
|
||||
int _boneIndex;
|
||||
};
|
||||
|
||||
/// Base class for timelines that animate a single bone property.
|
||||
@ -63,16 +70,10 @@ namespace spine {
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction, bool appliedPose) override;
|
||||
|
||||
virtual int getBoneIndex() override { return _boneIndex; }
|
||||
|
||||
void setBoneIndex(int inValue) { _boneIndex = inValue; }
|
||||
|
||||
protected:
|
||||
/// Applies changes to the pose based on the timeline values.
|
||||
virtual void apply(BoneLocal &pose, BoneLocal &setup, float time, float alpha, MixBlend blend,
|
||||
MixDirection direction) = 0;
|
||||
|
||||
int _boneIndex;
|
||||
};
|
||||
|
||||
/// Base class for timelines that animate two bone properties.
|
||||
@ -90,16 +91,11 @@ namespace spine {
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction, bool appliedPose) override;
|
||||
|
||||
virtual int getBoneIndex() override { return _boneIndex; }
|
||||
|
||||
void setBoneIndex(int inValue) { _boneIndex = inValue; }
|
||||
|
||||
protected:
|
||||
/// Applies changes to the pose based on the timeline values.
|
||||
virtual void apply(BoneLocal &pose, BoneLocal &setup, float time, float alpha, MixBlend blend,
|
||||
MixDirection direction) = 0;
|
||||
|
||||
int _boneIndex;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -36,20 +36,12 @@ namespace spine {
|
||||
template<class P>
|
||||
class SP_API Pose : public SpineObject {
|
||||
public:
|
||||
Pose();
|
||||
virtual ~Pose();
|
||||
|
||||
Pose() {};
|
||||
virtual ~Pose() {};
|
||||
|
||||
/// Sets the pose values.
|
||||
virtual void set(P& pose) = 0;
|
||||
};
|
||||
|
||||
template<class P>
|
||||
Pose<P>::Pose() {
|
||||
}
|
||||
|
||||
template<class P>
|
||||
Pose<P>::~Pose() {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -44,7 +44,6 @@ Animation::Animation(const String &name, Vector<Timeline *> &timelines, float du
|
||||
_bones(),
|
||||
_duration(duration),
|
||||
_name(name) {
|
||||
assert(_name.length() > 0);
|
||||
setTimelines(timelines);
|
||||
}
|
||||
|
||||
@ -106,11 +105,11 @@ int Animation::search(Vector<float> &frames, float target, int step) {
|
||||
|
||||
void Animation::setTimelines(Vector<Timeline *> &timelines) {
|
||||
_timelines = timelines;
|
||||
|
||||
|
||||
size_t n = timelines.size();
|
||||
_timelineIds.clear();
|
||||
_bones.clear();
|
||||
|
||||
|
||||
HashMap<int, bool> boneSet;
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
Timeline *timeline = timelines[i];
|
||||
@ -118,14 +117,9 @@ void Animation::setTimelines(Vector<Timeline *> &timelines) {
|
||||
for (size_t ii = 0; ii < propertyIds.size(); ii++) {
|
||||
_timelineIds.put(propertyIds[ii], true);
|
||||
}
|
||||
|
||||
BoneTimeline *boneTimeline = nullptr;
|
||||
if (timeline->getRTTI().instanceOf(BoneTimeline1::rtti)) {
|
||||
boneTimeline = static_cast<BoneTimeline1 *>(timeline);
|
||||
} else if (timeline->getRTTI().instanceOf(BoneTimeline2::rtti)) {
|
||||
boneTimeline = static_cast<BoneTimeline2 *>(timeline);
|
||||
}
|
||||
|
||||
|
||||
BoneTimeline *boneTimeline = timeline->getRTTI().instanceOf(BoneTimeline1::rtti) ?
|
||||
static_cast<BoneTimeline1 *>(timeline) : NULL;
|
||||
if (boneTimeline) {
|
||||
int boneIndex = boneTimeline->getBoneIndex();
|
||||
if (!boneSet.containsKey(boneIndex)) {
|
||||
|
||||
@ -38,16 +38,13 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
BoneTimeline::BoneTimeline() {
|
||||
}
|
||||
|
||||
BoneTimeline::~BoneTimeline() {
|
||||
}
|
||||
RTTI_IMPL(BoneTimeline, BoneTimeline)
|
||||
|
||||
RTTI_IMPL(BoneTimeline1, CurveTimeline1)
|
||||
|
||||
BoneTimeline1::BoneTimeline1(size_t frameCount, size_t bezierCount, int boneIndex, Property property) :
|
||||
CurveTimeline1(frameCount, bezierCount), _boneIndex(boneIndex) {
|
||||
BoneTimeline1::BoneTimeline1(size_t frameCount, size_t bezierCount, int boneIndex, Property property) :
|
||||
BoneTimeline(boneIndex),
|
||||
CurveTimeline1(frameCount, bezierCount) {
|
||||
PropertyId ids[] = {((PropertyId) property << 32) | boneIndex};
|
||||
setPropertyIds(ids, 1);
|
||||
}
|
||||
@ -59,14 +56,15 @@ void BoneTimeline1::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
||||
|
||||
Bone *bone = skeleton._bones[_boneIndex];
|
||||
if (bone->isActive()) {
|
||||
apply(appliedPose ? *bone->_applied : bone->_pose, *bone->_data._setup, time, alpha, blend, direction);
|
||||
apply(appliedPose ? *bone->_applied : bone->_pose, bone->_data._setup, time, alpha, blend, direction);
|
||||
}
|
||||
}
|
||||
|
||||
RTTI_IMPL(BoneTimeline2, CurveTimeline2)
|
||||
|
||||
BoneTimeline2::BoneTimeline2(size_t frameCount, size_t bezierCount, int boneIndex, Property property1, Property property2) :
|
||||
CurveTimeline2(frameCount, bezierCount), _boneIndex(boneIndex) {
|
||||
BoneTimeline2::BoneTimeline2(size_t frameCount, size_t bezierCount, int boneIndex, Property property1, Property property2) :
|
||||
BoneTimeline(boneIndex),
|
||||
CurveTimeline2(frameCount, bezierCount) {
|
||||
PropertyId ids[] = {((PropertyId) property1 << 32) | boneIndex, ((PropertyId) property2 << 32) | boneIndex};
|
||||
setPropertyIds(ids, 2);
|
||||
}
|
||||
@ -78,6 +76,6 @@ void BoneTimeline2::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
||||
|
||||
Bone *bone = skeleton._bones[_boneIndex];
|
||||
if (bone->isActive()) {
|
||||
apply(appliedPose ? *bone->_applied : bone->_pose, *bone->_data._setup, time, alpha, blend, direction);
|
||||
apply(appliedPose ? *bone->_applied : bone->_pose, bone->_data._setup, time, alpha, blend, direction);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user