mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[cpp] 4.3 porting WIP
This commit is contained in:
parent
e3fb50da5b
commit
366291deaf
@ -38,6 +38,9 @@
|
|||||||
namespace spine {
|
namespace spine {
|
||||||
/// Stores a bone's local pose.
|
/// Stores a bone's local pose.
|
||||||
class SP_API BoneLocal : public Pose<BoneLocal> {
|
class SP_API BoneLocal : public Pose<BoneLocal> {
|
||||||
|
friend class BoneTimeline1;
|
||||||
|
friend class RotateTimeline;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -31,8 +31,13 @@
|
|||||||
#define Spine_BoneTimeline_h
|
#define Spine_BoneTimeline_h
|
||||||
|
|
||||||
#include <spine/dll.h>
|
#include <spine/dll.h>
|
||||||
|
#include <spine/CurveTimeline.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
class Skeleton;
|
||||||
|
class Event;
|
||||||
|
class BoneLocal;
|
||||||
|
|
||||||
/// An interface for timelines which change the property of a bone.
|
/// An interface for timelines which change the property of a bone.
|
||||||
class SP_API BoneTimeline {
|
class SP_API BoneTimeline {
|
||||||
public:
|
public:
|
||||||
@ -42,6 +47,33 @@ namespace spine {
|
|||||||
/// The index of the bone in Skeleton::getBones() that will be changed when this timeline is applied.
|
/// The index of the bone in Skeleton::getBones() that will be changed when this timeline is applied.
|
||||||
virtual int getBoneIndex() = 0;
|
virtual int getBoneIndex() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Base class for timelines that animate a single bone property.
|
||||||
|
class SP_API BoneTimeline1 : public CurveTimeline1, public BoneTimeline {
|
||||||
|
friend class SkeletonBinary;
|
||||||
|
friend class SkeletonJson;
|
||||||
|
friend class AnimationState;
|
||||||
|
|
||||||
|
RTTI_DECL
|
||||||
|
|
||||||
|
public:
|
||||||
|
BoneTimeline1(size_t frameCount, size_t bezierCount, int boneIndex, Property property);
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
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;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -37,6 +37,7 @@ namespace spine {
|
|||||||
template<class D, class P, class A>
|
template<class D, class P, class A>
|
||||||
class SP_API Posed : public SpineObject {
|
class SP_API Posed : public SpineObject {
|
||||||
friend class AnimationState;
|
friend class AnimationState;
|
||||||
|
friend class BoneTimeline1;
|
||||||
friend class RotateTimeline;
|
friend class RotateTimeline;
|
||||||
friend class IkConstraint;
|
friend class IkConstraint;
|
||||||
friend class TransformConstraint;
|
friend class TransformConstraint;
|
||||||
|
|||||||
@ -42,6 +42,24 @@ namespace spine {
|
|||||||
class SP_API PosedData : public SpineObject {
|
class SP_API PosedData : public SpineObject {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
friend class BoneTimeline1;
|
||||||
|
friend class RotateTimeline;
|
||||||
|
friend class AttachmentTimeline;
|
||||||
|
friend class RGBATimeline;
|
||||||
|
friend class RGBTimeline;
|
||||||
|
friend class AlphaTimeline;
|
||||||
|
friend class RGBA2Timeline;
|
||||||
|
friend class RGB2Timeline;
|
||||||
|
friend class ScaleTimeline;
|
||||||
|
friend class ScaleXTimeline;
|
||||||
|
friend class ScaleYTimeline;
|
||||||
|
friend class ShearTimeline;
|
||||||
|
friend class ShearXTimeline;
|
||||||
|
friend class ShearYTimeline;
|
||||||
|
friend class TranslateTimeline;
|
||||||
|
friend class TranslateXTimeline;
|
||||||
|
friend class TranslateYTimeline;
|
||||||
|
friend class InheritTimeline;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
spine::String _name;
|
spine::String _name;
|
||||||
|
|||||||
@ -30,10 +30,11 @@
|
|||||||
#ifndef Spine_RotateTimeline_h
|
#ifndef Spine_RotateTimeline_h
|
||||||
#define Spine_RotateTimeline_h
|
#define Spine_RotateTimeline_h
|
||||||
|
|
||||||
#include <spine/CurveTimeline.h>
|
#include <spine/BoneTimeline.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API RotateTimeline : public CurveTimeline1 {
|
/// Changes a bone's local rotation.
|
||||||
|
class SP_API RotateTimeline : public BoneTimeline1 {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
@ -45,16 +46,9 @@ namespace spine {
|
|||||||
public:
|
public:
|
||||||
explicit RotateTimeline(size_t frameCount, size_t bezierCount, int boneIndex);
|
explicit RotateTimeline(size_t frameCount, size_t bezierCount, int boneIndex);
|
||||||
|
|
||||||
virtual void
|
protected:
|
||||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
virtual void apply(BoneLocal &pose, BoneLocal &setup, float time, float alpha, MixBlend blend,
|
||||||
MixDirection direction);
|
MixDirection direction) override;
|
||||||
|
|
||||||
int getBoneIndex() { return _boneIndex; }
|
|
||||||
|
|
||||||
void setBoneIndex(int inValue) { _boneIndex = inValue; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int _boneIndex;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -107,6 +107,8 @@ namespace spine {
|
|||||||
|
|
||||||
friend class TransformConstraintTimeline;
|
friend class TransformConstraintTimeline;
|
||||||
|
|
||||||
|
friend class BoneTimeline1;
|
||||||
|
|
||||||
friend class RotateTimeline;
|
friend class RotateTimeline;
|
||||||
|
|
||||||
friend class TranslateTimeline;
|
friend class TranslateTimeline;
|
||||||
|
|||||||
@ -29,6 +29,13 @@
|
|||||||
|
|
||||||
#include <spine/BoneTimeline.h>
|
#include <spine/BoneTimeline.h>
|
||||||
|
|
||||||
|
#include <spine/Event.h>
|
||||||
|
#include <spine/Skeleton.h>
|
||||||
|
#include <spine/Bone.h>
|
||||||
|
#include <spine/BoneData.h>
|
||||||
|
#include <spine/BoneLocal.h>
|
||||||
|
#include <spine/Property.h>
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
BoneTimeline::BoneTimeline() {
|
BoneTimeline::BoneTimeline() {
|
||||||
@ -36,3 +43,22 @@ BoneTimeline::BoneTimeline() {
|
|||||||
|
|
||||||
BoneTimeline::~BoneTimeline() {
|
BoneTimeline::~BoneTimeline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(BoneTimeline1, CurveTimeline1)
|
||||||
|
|
||||||
|
BoneTimeline1::BoneTimeline1(size_t frameCount, size_t bezierCount, int boneIndex, Property property) :
|
||||||
|
CurveTimeline1(frameCount, bezierCount), _boneIndex(boneIndex) {
|
||||||
|
PropertyId ids[] = {((PropertyId) property << 32) | boneIndex};
|
||||||
|
setPropertyIds(ids, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BoneTimeline1::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
|
MixBlend blend, MixDirection direction, bool appliedPose) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
|
||||||
|
Bone *bone = skeleton._bones[_boneIndex];
|
||||||
|
if (bone->isActive()) {
|
||||||
|
apply(appliedPose ? *bone->_applied : bone->_pose, *bone->_data._setup, time, alpha, blend, direction);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -29,31 +29,18 @@
|
|||||||
|
|
||||||
#include <spine/RotateTimeline.h>
|
#include <spine/RotateTimeline.h>
|
||||||
|
|
||||||
#include <spine/Event.h>
|
#include <spine/BoneLocal.h>
|
||||||
#include <spine/Skeleton.h>
|
|
||||||
|
|
||||||
#include <spine/Animation.h>
|
|
||||||
#include <spine/Bone.h>
|
|
||||||
#include <spine/BoneData.h>
|
|
||||||
#include <spine/Property.h>
|
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL(RotateTimeline, CurveTimeline1)
|
RTTI_IMPL(RotateTimeline, BoneTimeline1)
|
||||||
|
|
||||||
RotateTimeline::RotateTimeline(size_t frameCount, size_t bezierCount, int boneIndex) : CurveTimeline1(frameCount,
|
RotateTimeline::RotateTimeline(size_t frameCount, size_t bezierCount, int boneIndex) :
|
||||||
bezierCount),
|
BoneTimeline1(frameCount, bezierCount, boneIndex, Property_Rotate) {
|
||||||
_boneIndex(boneIndex) {
|
|
||||||
PropertyId ids[] = {((PropertyId) Property_Rotate << 32) | boneIndex};
|
|
||||||
setPropertyIds(ids, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotateTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void RotateTimeline::apply(BoneLocal &pose, BoneLocal &setup, float time, float alpha, MixBlend blend,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixDirection direction) {
|
||||||
SP_UNUSED(lastTime);
|
|
||||||
SP_UNUSED(pEvents);
|
|
||||||
SP_UNUSED(direction);
|
SP_UNUSED(direction);
|
||||||
|
pose._rotation = getRelativeValue(time, alpha, blend, pose._rotation, setup._rotation);
|
||||||
Bone *bone = skeleton._bones[_boneIndex];
|
|
||||||
if (bone->isActive()) bone->_rotation = getRelativeValue(time, alpha, blend, bone->_rotation, bone->getData()._rotation);
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user