mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-05 18:26:52 +08:00
[cpp] 4.3 porting WIP
This commit is contained in:
parent
b605f0ccac
commit
11435f471a
@ -39,10 +39,14 @@ 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 BoneTimeline1;
|
||||||
|
friend class BoneTimeline2;
|
||||||
friend class RotateTimeline;
|
friend class RotateTimeline;
|
||||||
friend class ScaleTimeline;
|
friend class ScaleTimeline;
|
||||||
friend class ScaleXTimeline;
|
friend class ScaleXTimeline;
|
||||||
friend class ScaleYTimeline;
|
friend class ScaleYTimeline;
|
||||||
|
friend class ShearTimeline;
|
||||||
|
friend class ShearXTimeline;
|
||||||
|
friend class ShearYTimeline;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
|
|||||||
@ -30,10 +30,11 @@
|
|||||||
#ifndef Spine_ShearTimeline_h
|
#ifndef Spine_ShearTimeline_h
|
||||||
#define Spine_ShearTimeline_h
|
#define Spine_ShearTimeline_h
|
||||||
|
|
||||||
#include <spine/TranslateTimeline.h>
|
#include <spine/BoneTimeline.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API ShearTimeline : public CurveTimeline2 {
|
/// Changes a bone's local shear X and Y.
|
||||||
|
class SP_API ShearTimeline : public BoneTimeline2 {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
@ -43,21 +44,13 @@ namespace spine {
|
|||||||
public:
|
public:
|
||||||
explicit ShearTimeline(size_t frameCount, size_t bezierCount, int boneIndex);
|
explicit ShearTimeline(size_t frameCount, size_t bezierCount, int boneIndex);
|
||||||
|
|
||||||
virtual ~ShearTimeline();
|
protected:
|
||||||
|
virtual void apply(BoneLocal &pose, BoneLocal &setup, float time, float alpha, MixBlend blend,
|
||||||
virtual void
|
MixDirection direction) override;
|
||||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
|
||||||
MixDirection direction);
|
|
||||||
|
|
||||||
int getBoneIndex() { return _boneIndex; }
|
|
||||||
|
|
||||||
void setBoneIndex(int inValue) { _boneIndex = inValue; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int _boneIndex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SP_API ShearXTimeline : public CurveTimeline1 {
|
/// Changes a bone's local shear X.
|
||||||
|
class SP_API ShearXTimeline : public BoneTimeline1 {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
@ -67,21 +60,13 @@ namespace spine {
|
|||||||
public:
|
public:
|
||||||
explicit ShearXTimeline(size_t frameCount, size_t bezierCount, int boneIndex);
|
explicit ShearXTimeline(size_t frameCount, size_t bezierCount, int boneIndex);
|
||||||
|
|
||||||
virtual ~ShearXTimeline();
|
protected:
|
||||||
|
virtual void apply(BoneLocal &pose, BoneLocal &setup, float time, float alpha, MixBlend blend,
|
||||||
virtual void
|
MixDirection direction) override;
|
||||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
|
||||||
MixDirection direction);
|
|
||||||
|
|
||||||
int getBoneIndex() { return _boneIndex; }
|
|
||||||
|
|
||||||
void setBoneIndex(int inValue) { _boneIndex = inValue; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int _boneIndex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SP_API ShearYTimeline : public CurveTimeline1 {
|
/// Changes a bone's local shear Y.
|
||||||
|
class SP_API ShearYTimeline : public BoneTimeline1 {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
@ -91,18 +76,9 @@ namespace spine {
|
|||||||
public:
|
public:
|
||||||
explicit ShearYTimeline(size_t frameCount, size_t bezierCount, int boneIndex);
|
explicit ShearYTimeline(size_t frameCount, size_t bezierCount, int boneIndex);
|
||||||
|
|
||||||
virtual ~ShearYTimeline();
|
protected:
|
||||||
|
virtual void apply(BoneLocal &pose, BoneLocal &setup, float time, float alpha, MixBlend blend,
|
||||||
virtual void
|
MixDirection direction) override;
|
||||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
|
||||||
MixDirection direction);
|
|
||||||
|
|
||||||
int getBoneIndex() { return _boneIndex; }
|
|
||||||
|
|
||||||
void setBoneIndex(int inValue) { _boneIndex = inValue; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int _boneIndex;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <spine/Event.h>
|
#include <spine/Event.h>
|
||||||
#include <spine/Skeleton.h>
|
#include <spine/Skeleton.h>
|
||||||
|
#include <spine/Animation.h>
|
||||||
|
|
||||||
#include <spine/Bone.h>
|
#include <spine/Bone.h>
|
||||||
#include <spine/BoneData.h>
|
#include <spine/BoneData.h>
|
||||||
@ -39,37 +40,23 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL(ShearTimeline, CurveTimeline2)
|
RTTI_IMPL(ShearTimeline, BoneTimeline2)
|
||||||
|
|
||||||
ShearTimeline::ShearTimeline(size_t frameCount, size_t bezierCount, int boneIndex) : CurveTimeline2(frameCount,
|
ShearTimeline::ShearTimeline(size_t frameCount, size_t bezierCount, int boneIndex) :
|
||||||
bezierCount),
|
BoneTimeline2(frameCount, bezierCount, boneIndex, Property_ShearX, Property_ShearY) {
|
||||||
_boneIndex(boneIndex) {
|
|
||||||
PropertyId ids[] = {((PropertyId) Property_ShearX << 32) | boneIndex,
|
|
||||||
((PropertyId) Property_ShearY << 32) | boneIndex};
|
|
||||||
setPropertyIds(ids, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ShearTimeline::~ShearTimeline() {
|
void ShearTimeline::apply(BoneLocal &pose, BoneLocal &setup, float time, float alpha, MixBlend blend,
|
||||||
}
|
MixDirection direction) {
|
||||||
|
|
||||||
void ShearTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
|
||||||
MixBlend blend, MixDirection direction) {
|
|
||||||
SP_UNUSED(lastTime);
|
|
||||||
SP_UNUSED(pEvents);
|
|
||||||
SP_UNUSED(direction);
|
|
||||||
|
|
||||||
Bone *bone = skeleton._bones[_boneIndex];
|
|
||||||
if (!bone->_active) return;
|
|
||||||
|
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
bone->_shearX = bone->_data._shearX;
|
pose._shearX = setup._shearX;
|
||||||
bone->_shearY = bone->_data._shearY;
|
pose._shearY = setup._shearY;
|
||||||
return;
|
return;
|
||||||
case MixBlend_First:
|
case MixBlend_First:
|
||||||
bone->_shearX += (bone->_data._shearX - bone->_shearX) * alpha;
|
pose._shearX += (setup._shearX - pose._shearX) * alpha;
|
||||||
bone->_shearY += (bone->_data._shearY - bone->_shearY) * alpha;
|
pose._shearY += (setup._shearY - pose._shearY) * alpha;
|
||||||
default: {
|
default: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,7 +67,7 @@ void ShearTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
int i = Animation::search(_frames, time, CurveTimeline2::ENTRIES);
|
int i = Animation::search(_frames, time, CurveTimeline2::ENTRIES);
|
||||||
int curveType = (int) _curves[i / CurveTimeline2::ENTRIES];
|
int curveType = (int) _curves[i / CurveTimeline2::ENTRIES];
|
||||||
switch (curveType) {
|
switch (curveType) {
|
||||||
case CurveTimeline2::LINEAR: {
|
case CurveTimeline::LINEAR: {
|
||||||
float before = _frames[i];
|
float before = _frames[i];
|
||||||
x = _frames[i + CurveTimeline2::VALUE1];
|
x = _frames[i + CurveTimeline2::VALUE1];
|
||||||
y = _frames[i + CurveTimeline2::VALUE2];
|
y = _frames[i + CurveTimeline2::VALUE2];
|
||||||
@ -89,7 +76,7 @@ void ShearTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
y += (_frames[i + CurveTimeline2::ENTRIES + CurveTimeline2::VALUE2] - y) * t;
|
y += (_frames[i + CurveTimeline2::ENTRIES + CurveTimeline2::VALUE2] - y) * t;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CurveTimeline2::STEPPED: {
|
case CurveTimeline::STEPPED: {
|
||||||
x = _frames[i + CurveTimeline2::VALUE1];
|
x = _frames[i + CurveTimeline2::VALUE1];
|
||||||
y = _frames[i + CurveTimeline2::VALUE2];
|
y = _frames[i + CurveTimeline2::VALUE2];
|
||||||
break;
|
break;
|
||||||
@ -103,60 +90,38 @@ void ShearTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
|
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
bone->_shearX = bone->_data._shearX + x * alpha;
|
pose._shearX = setup._shearX + x * alpha;
|
||||||
bone->_shearY = bone->_data._shearY + y * alpha;
|
pose._shearY = setup._shearY + y * alpha;
|
||||||
break;
|
break;
|
||||||
case MixBlend_First:
|
case MixBlend_First:
|
||||||
case MixBlend_Replace:
|
case MixBlend_Replace:
|
||||||
bone->_shearX += (bone->_data._shearX + x - bone->_shearX) * alpha;
|
pose._shearX += (setup._shearX + x - pose._shearX) * alpha;
|
||||||
bone->_shearY += (bone->_data._shearY + y - bone->_shearY) * alpha;
|
pose._shearY += (setup._shearY + y - pose._shearY) * alpha;
|
||||||
break;
|
break;
|
||||||
case MixBlend_Add:
|
case MixBlend_Add:
|
||||||
bone->_shearX += x * alpha;
|
pose._shearX += x * alpha;
|
||||||
bone->_shearY += y * alpha;
|
pose._shearY += y * alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RTTI_IMPL(ShearXTimeline, CurveTimeline1)
|
RTTI_IMPL(ShearXTimeline, BoneTimeline1)
|
||||||
|
|
||||||
ShearXTimeline::ShearXTimeline(size_t frameCount, size_t bezierCount, int boneIndex) : CurveTimeline1(frameCount,
|
ShearXTimeline::ShearXTimeline(size_t frameCount, size_t bezierCount, int boneIndex) :
|
||||||
bezierCount),
|
BoneTimeline1(frameCount, bezierCount, boneIndex, Property_ShearX) {
|
||||||
_boneIndex(boneIndex) {
|
|
||||||
PropertyId ids[] = {((PropertyId) Property_ShearX << 32) | boneIndex};
|
|
||||||
setPropertyIds(ids, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ShearXTimeline::~ShearXTimeline() {
|
void ShearXTimeline::apply(BoneLocal &pose, BoneLocal &setup, float time, float alpha, MixBlend blend,
|
||||||
|
MixDirection direction) {
|
||||||
|
pose._shearX = getRelativeValue(time, alpha, blend, pose._shearX, setup._shearX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShearXTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
RTTI_IMPL(ShearYTimeline, BoneTimeline1)
|
||||||
MixBlend blend, MixDirection direction) {
|
|
||||||
SP_UNUSED(lastTime);
|
|
||||||
SP_UNUSED(pEvents);
|
|
||||||
SP_UNUSED(direction);
|
|
||||||
|
|
||||||
Bone *bone = skeleton._bones[_boneIndex];
|
ShearYTimeline::ShearYTimeline(size_t frameCount, size_t bezierCount, int boneIndex) :
|
||||||
if (bone->_active) bone->_shearX = getRelativeValue(time, alpha, blend, bone->_shearX, bone->_data._shearX);
|
BoneTimeline1(frameCount, bezierCount, boneIndex, Property_ShearY) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RTTI_IMPL(ShearYTimeline, CurveTimeline1)
|
void ShearYTimeline::apply(BoneLocal &pose, BoneLocal &setup, float time, float alpha, MixBlend blend,
|
||||||
|
MixDirection direction) {
|
||||||
ShearYTimeline::ShearYTimeline(size_t frameCount, size_t bezierCount, int boneIndex) : CurveTimeline1(frameCount,
|
pose._shearY = getRelativeValue(time, alpha, blend, pose._shearY, setup._shearY);
|
||||||
bezierCount),
|
|
||||||
_boneIndex(boneIndex) {
|
|
||||||
PropertyId ids[] = {((PropertyId) Property_ShearX << 32) | boneIndex};
|
|
||||||
setPropertyIds(ids, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ShearYTimeline::~ShearYTimeline() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShearYTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
|
||||||
MixBlend blend, MixDirection direction) {
|
|
||||||
SP_UNUSED(lastTime);
|
|
||||||
SP_UNUSED(pEvents);
|
|
||||||
SP_UNUSED(direction);
|
|
||||||
|
|
||||||
Bone *bone = skeleton._bones[_boneIndex];
|
|
||||||
if (bone->_active) bone->_shearY = getRelativeValue(time, alpha, blend, bone->_shearY, bone->_data._shearY);
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user