mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[cpp] 4.3 porting WIP
This commit is contained in:
parent
89513d0128
commit
5f74729a2e
@ -31,16 +31,24 @@
|
||||
#define Spine_ConstraintTimeline_h
|
||||
|
||||
#include <spine/dll.h>
|
||||
#include <spine/RTTI.h>
|
||||
|
||||
namespace spine {
|
||||
/// An interface for timelines which change the property of a constraint.
|
||||
class SP_API ConstraintTimeline {
|
||||
RTTI_DECL_NOPARENT
|
||||
|
||||
public:
|
||||
ConstraintTimeline();
|
||||
virtual ~ConstraintTimeline();
|
||||
|
||||
ConstraintTimeline(int constraintIndex);
|
||||
virtual ~ConstraintTimeline() {}
|
||||
|
||||
/// The index of the constraint in Skeleton::getConstraints() that will be changed when this timeline is applied.
|
||||
virtual int getConstraintIndex() = 0;
|
||||
virtual int getConstraintIndex() { return _constraintIndex; }
|
||||
|
||||
virtual void setConstraintIndex(int inValue) { _constraintIndex = inValue; }
|
||||
|
||||
protected:
|
||||
int _constraintIndex;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -32,20 +32,16 @@
|
||||
|
||||
#include <spine/CurveTimeline.h>
|
||||
#include <spine/Property.h>
|
||||
#include <spine/ConstraintTimeline.h>
|
||||
|
||||
namespace spine {
|
||||
/// Base class for single-value constraint timelines.
|
||||
class SP_API ConstraintTimeline1 : public CurveTimeline1 {
|
||||
class SP_API ConstraintTimeline1 : public CurveTimeline1, public ConstraintTimeline {
|
||||
RTTI_DECL
|
||||
|
||||
private:
|
||||
int _constraintIndex;
|
||||
|
||||
public:
|
||||
ConstraintTimeline1(size_t frameCount, size_t bezierCount, int constraintIndex, Property property);
|
||||
|
||||
/// The index of the constraint in Skeleton::getConstraints() that will be changed when this timeline is applied.
|
||||
int getConstraintIndex();
|
||||
virtual ~ConstraintTimeline1() {}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -31,10 +31,11 @@
|
||||
#define Spine_IkConstraintTimeline_h
|
||||
|
||||
#include <spine/CurveTimeline.h>
|
||||
#include <spine/ConstraintTimeline.h>
|
||||
|
||||
namespace spine {
|
||||
|
||||
class SP_API IkConstraintTimeline : public CurveTimeline {
|
||||
class SP_API IkConstraintTimeline : public CurveTimeline, public ConstraintTimeline {
|
||||
friend class SkeletonBinary;
|
||||
|
||||
friend class SkeletonJson;
|
||||
@ -51,13 +52,7 @@ namespace spine {
|
||||
/// Sets the time, mix and bend direction of the specified keyframe.
|
||||
void setFrame(int frame, float time, float mix, float softness, int bendDirection, bool compress, bool stretch);
|
||||
|
||||
int getIkConstraintIndex() { return _constraintIndex; }
|
||||
|
||||
void setIkConstraintIndex(int inValue) { _constraintIndex = inValue; }
|
||||
|
||||
private:
|
||||
int _constraintIndex;
|
||||
|
||||
static const int ENTRIES = 6;
|
||||
static const int MIX = 1;
|
||||
static const int SOFTNESS = 2;
|
||||
|
||||
@ -31,14 +31,14 @@
|
||||
#define Spine_InheritTimeline_h
|
||||
|
||||
#include <spine/Timeline.h>
|
||||
|
||||
#include <spine/BoneTimeline.h>
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/Property.h>
|
||||
#include <spine/Inherit.h>
|
||||
|
||||
namespace spine {
|
||||
|
||||
class SP_API InheritTimeline : public Timeline {
|
||||
class SP_API InheritTimeline : public Timeline, public BoneTimeline {
|
||||
friend class SkeletonBinary;
|
||||
|
||||
friend class SkeletonJson;
|
||||
@ -56,13 +56,7 @@ namespace spine {
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction, bool appliedPose);
|
||||
|
||||
int getBoneIndex() { return _boneIndex; }
|
||||
|
||||
void setBoneIndex(int inValue) { _boneIndex = inValue; }
|
||||
|
||||
private:
|
||||
int _boneIndex;
|
||||
|
||||
static const int ENTRIES = 2;
|
||||
static const int INHERIT = 1;
|
||||
};
|
||||
|
||||
@ -31,10 +31,11 @@
|
||||
#define Spine_PathConstraintMixTimeline_h
|
||||
|
||||
#include <spine/CurveTimeline.h>
|
||||
#include <spine/ConstraintTimeline.h>
|
||||
|
||||
namespace spine {
|
||||
|
||||
class SP_API PathConstraintMixTimeline : public CurveTimeline {
|
||||
class SP_API PathConstraintMixTimeline : public CurveTimeline, public ConstraintTimeline {
|
||||
friend class SkeletonBinary;
|
||||
|
||||
friend class SkeletonJson;
|
||||
@ -46,18 +47,12 @@ namespace spine {
|
||||
|
||||
virtual void
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction);
|
||||
MixDirection direction, bool appliedPose);
|
||||
|
||||
/// Sets the time and mixes of the specified keyframe.
|
||||
void setFrame(int frameIndex, float time, float mixRotate, float mixX, float mixY);
|
||||
|
||||
int getPathConstraintIndex() { return _constraintIndex; }
|
||||
|
||||
void setPathConstraintIndex(int inValue) { _constraintIndex = inValue; }
|
||||
|
||||
private:
|
||||
int _constraintIndex;
|
||||
|
||||
static const int ENTRIES = 4;
|
||||
static const int ROTATE = 1;
|
||||
static const int X = 2;
|
||||
|
||||
@ -30,11 +30,11 @@
|
||||
#ifndef Spine_PathConstraintPositionTimeline_h
|
||||
#define Spine_PathConstraintPositionTimeline_h
|
||||
|
||||
#include <spine/CurveTimeline.h>
|
||||
#include <spine/ConstraintTimeline1.h>
|
||||
|
||||
namespace spine {
|
||||
|
||||
class SP_API PathConstraintPositionTimeline : public CurveTimeline1 {
|
||||
class SP_API PathConstraintPositionTimeline : public ConstraintTimeline1 {
|
||||
friend class SkeletonBinary;
|
||||
|
||||
friend class SkeletonJson;
|
||||
@ -50,14 +50,7 @@ namespace spine {
|
||||
|
||||
virtual void
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction);
|
||||
|
||||
int getPathConstraintIndex() { return _constraintIndex; }
|
||||
|
||||
void setPathConstraintIndex(int inValue) { _constraintIndex = inValue; }
|
||||
|
||||
protected:
|
||||
int _constraintIndex;
|
||||
MixDirection direction, bool appliedPose);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#include <spine/PathConstraintPositionTimeline.h>
|
||||
|
||||
namespace spine {
|
||||
class SP_API PathConstraintSpacingTimeline : public CurveTimeline1 {
|
||||
class SP_API PathConstraintSpacingTimeline : public ConstraintTimeline1 {
|
||||
friend class SkeletonBinary;
|
||||
|
||||
friend class SkeletonJson;
|
||||
@ -45,14 +45,7 @@ namespace spine {
|
||||
|
||||
virtual void
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction);
|
||||
|
||||
int getPathConstraintIndex() { return _pathConstraintIndex; }
|
||||
|
||||
void setPathConstraintIndex(int inValue) { _pathConstraintIndex = inValue; }
|
||||
|
||||
protected:
|
||||
int _pathConstraintIndex;
|
||||
MixDirection direction, bool appliedPose);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -34,10 +34,11 @@
|
||||
#include <spine/PhysicsConstraint.h>
|
||||
#include <spine/PhysicsConstraintData.h>
|
||||
#include <spine/PhysicsConstraintPose.h>
|
||||
#include <spine/ConstraintTimeline.h>
|
||||
|
||||
namespace spine {
|
||||
|
||||
class SP_API PhysicsConstraintTimeline : public CurveTimeline1 {
|
||||
class SP_API PhysicsConstraintTimeline : public CurveTimeline1, public ConstraintTimeline {
|
||||
friend class SkeletonBinary;
|
||||
|
||||
friend class SkeletonJson;
|
||||
@ -51,10 +52,6 @@ namespace spine {
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction, bool appliedPose) override;
|
||||
|
||||
int getPhysicsConstraintIndex() { return _constraintIndex; }
|
||||
|
||||
void setPhysicsConstraintIndex(int inValue) { _constraintIndex = inValue; }
|
||||
|
||||
protected:
|
||||
virtual float get(PhysicsConstraintPose &pose) = 0;
|
||||
virtual void set(PhysicsConstraintPose &pose, float value) = 0;
|
||||
@ -232,7 +229,7 @@ namespace spine {
|
||||
}
|
||||
};
|
||||
|
||||
class SP_API PhysicsConstraintResetTimeline : public Timeline {
|
||||
class SP_API PhysicsConstraintResetTimeline : public Timeline, public ConstraintTimeline {
|
||||
friend class SkeletonBinary;
|
||||
|
||||
friend class SkeletonJson;
|
||||
@ -240,7 +237,7 @@ namespace spine {
|
||||
RTTI_DECL
|
||||
|
||||
public:
|
||||
explicit PhysicsConstraintResetTimeline(size_t frameCount, int physicsConstraintIndex): Timeline(frameCount, 1), _constraintIndex(physicsConstraintIndex) {
|
||||
explicit PhysicsConstraintResetTimeline(size_t frameCount, int physicsConstraintIndex): Timeline(frameCount, 1), ConstraintTimeline(physicsConstraintIndex) {
|
||||
PropertyId ids[] = {((PropertyId)Property_PhysicsConstraintReset) << 32};
|
||||
setPropertyIds(ids, 1);
|
||||
}
|
||||
@ -249,9 +246,6 @@ namespace spine {
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction, bool appliedPose) override;
|
||||
|
||||
/// The index of the physics constraint that will be reset when this timeline is applied, or -1 if all physics constraints in the skeleton will be reset.
|
||||
int getConstraintIndex() { return _constraintIndex; }
|
||||
|
||||
int getFrameCount() { return (int)_frames.size(); }
|
||||
|
||||
/// Sets the time for the specified frame.
|
||||
|
||||
@ -110,6 +110,13 @@ namespace spine {
|
||||
friend class TranslateXTimeline;
|
||||
friend class TranslateYTimeline;
|
||||
friend class InheritTimeline;
|
||||
friend class PhysicsConstraintTimeline;
|
||||
friend class PhysicsConstraintInertiaTimeline;
|
||||
friend class PhysicsConstraintStrengthTimeline;
|
||||
friend class PhysicsConstraintDampingTimeline;
|
||||
friend class PhysicsConstraintMassTimeline;
|
||||
friend class PhysicsConstraintWindTimeline;
|
||||
friend class PhysicsConstraintGravityTimeline;
|
||||
|
||||
protected:
|
||||
P _setup;
|
||||
|
||||
@ -39,6 +39,12 @@ namespace spine {
|
||||
|
||||
RTTI(const char *className, const RTTI &baseRTTI);
|
||||
|
||||
// New constructor for multiple interfaces (up to 3)
|
||||
RTTI(const char *className, const RTTI &baseRTTI,
|
||||
const RTTI* interface1,
|
||||
const RTTI* interface2 = 0,
|
||||
const RTTI* interface3 = 0);
|
||||
|
||||
const char *getClassName() const;
|
||||
|
||||
bool isExactly(const RTTI &rtti) const;
|
||||
@ -53,6 +59,8 @@ namespace spine {
|
||||
|
||||
const char *_className;
|
||||
const RTTI *_pBaseRTTI;
|
||||
const RTTI *_interfaces[3]; // Support up to 3 interfaces
|
||||
int _interfaceCount;
|
||||
};
|
||||
}
|
||||
|
||||
@ -74,4 +82,8 @@ const spine::RTTI& name::getRTTI() const { return rtti; }
|
||||
const spine::RTTI name::rtti(#name, parent::rtti); \
|
||||
const spine::RTTI& name::getRTTI() const { return rtti; }
|
||||
|
||||
#define RTTI_IMPL_MULTI(name, parent, ...) \
|
||||
const spine::RTTI name::rtti(#name, parent::rtti, &__VA_ARGS__::rtti); \
|
||||
const spine::RTTI& name::getRTTI() const { return rtti; }
|
||||
|
||||
#endif /* Spine_RTTI_h */
|
||||
|
||||
@ -37,30 +37,31 @@
|
||||
namespace spine {
|
||||
class Skeleton;
|
||||
class Bone;
|
||||
class Animation;
|
||||
|
||||
/// Stores the setup pose for a PhysicsConstraint.
|
||||
///
|
||||
/// See https://esotericsoftware.com/spine-physics-constraints Physics constraints in the Spine User Guide.
|
||||
class SP_API Slider : public ConstraintGeneric<Slider, SliderData, SliderPose> {
|
||||
friend class Skeleton;
|
||||
friend class SliderTimeline;
|
||||
friend class SliderMixTimeline;
|
||||
|
||||
public:
|
||||
RTTI_DECL
|
||||
|
||||
public:
|
||||
Slider(SliderData& data, Skeleton& skeleton);
|
||||
|
||||
/// Creates a copy of this slider for the specified skeleton.
|
||||
Slider* copy(Skeleton& skeleton);
|
||||
|
||||
/// Updates the slider constraint.
|
||||
virtual void update(Skeleton& skeleton, Physics physics) override;
|
||||
|
||||
/// Called by Skeleton to sort constraints.
|
||||
void sort(Skeleton& skeleton) override;
|
||||
virtual void sort(Skeleton& skeleton) override;
|
||||
|
||||
bool isSourceActive() override;
|
||||
virtual bool isSourceActive() override;
|
||||
|
||||
Bone* getBone();
|
||||
|
||||
void setBone(Bone* bone);
|
||||
|
||||
private:
|
||||
|
||||
@ -31,10 +31,11 @@
|
||||
#define Spine_TransformConstraintTimeline_h
|
||||
|
||||
#include <spine/CurveTimeline.h>
|
||||
#include <spine/ConstraintTimeline.h>
|
||||
|
||||
namespace spine {
|
||||
|
||||
class SP_API TransformConstraintTimeline : public CurveTimeline {
|
||||
class SP_API TransformConstraintTimeline : public CurveTimeline, public ConstraintTimeline {
|
||||
friend class SkeletonBinary;
|
||||
|
||||
friend class SkeletonJson;
|
||||
@ -46,18 +47,12 @@ namespace spine {
|
||||
|
||||
virtual void
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction);
|
||||
MixDirection direction, bool appliedPose);
|
||||
|
||||
void setFrame(size_t frameIndex, float time, float mixRotate, float mixX, float mixY, float mixScaleX,
|
||||
float mixScaleY, float mixShearY);
|
||||
|
||||
int getTransformConstraintIndex() { return _constraintIndex; }
|
||||
|
||||
void setTransformConstraintIndex(int inValue) { _constraintIndex = inValue; }
|
||||
|
||||
private:
|
||||
int _constraintIndex;
|
||||
|
||||
static const int ENTRIES = 7;
|
||||
static const int ROTATE = 1;
|
||||
static const int X = 2;
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(AttachmentTimeline, Timeline)
|
||||
RTTI_IMPL_MULTI(AttachmentTimeline, Timeline, SlotTimeline)
|
||||
|
||||
AttachmentTimeline::AttachmentTimeline(size_t frameCount, int slotIndex) : Timeline(frameCount, 1),
|
||||
SlotTimeline(slotIndex) {
|
||||
|
||||
@ -40,7 +40,7 @@ using namespace spine;
|
||||
|
||||
RTTI_IMPL_NOPARENT(BoneTimeline)
|
||||
|
||||
RTTI_IMPL(BoneTimeline1, CurveTimeline1)
|
||||
RTTI_IMPL_MULTI(BoneTimeline1, CurveTimeline1, BoneTimeline)
|
||||
|
||||
BoneTimeline1::BoneTimeline1(size_t frameCount, size_t bezierCount, int boneIndex, Property property) : CurveTimeline1(frameCount, bezierCount), BoneTimeline(boneIndex) {
|
||||
PropertyId ids[] = {((PropertyId) property << 32) | boneIndex};
|
||||
@ -58,7 +58,7 @@ void BoneTimeline1::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
||||
}
|
||||
}
|
||||
|
||||
RTTI_IMPL(BoneTimeline2, CurveTimeline2)
|
||||
RTTI_IMPL_MULTI(BoneTimeline2, CurveTimeline2, BoneTimeline)
|
||||
|
||||
BoneTimeline2::BoneTimeline2(size_t frameCount, size_t bezierCount, int boneIndex, Property property1, Property property2) : CurveTimeline2(frameCount, bezierCount), BoneTimeline(boneIndex) {
|
||||
PropertyId ids[] = {((PropertyId) property1 << 32) | boneIndex, ((PropertyId) property2 << 32) | boneIndex};
|
||||
|
||||
@ -205,7 +205,7 @@ void RGBTimeline::apply(Slot &slot, SlotPose &pose, float time, float alpha, Mix
|
||||
}
|
||||
}
|
||||
|
||||
RTTI_IMPL(AlphaTimeline, SlotTimeline)
|
||||
RTTI_IMPL(AlphaTimeline, SlotCurveTimeline)
|
||||
|
||||
AlphaTimeline::AlphaTimeline(size_t frameCount, size_t bezierCount, int slotIndex)
|
||||
: CurveTimeline1(frameCount, bezierCount), SlotTimeline(slotIndex) {
|
||||
|
||||
@ -31,8 +31,4 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
ConstraintTimeline::ConstraintTimeline() {
|
||||
}
|
||||
|
||||
ConstraintTimeline::~ConstraintTimeline() {
|
||||
}
|
||||
RTTI_IMPL_NOPARENT(ConstraintTimeline)
|
||||
@ -31,14 +31,10 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(ConstraintTimeline1, CurveTimeline1)
|
||||
RTTI_IMPL_MULTI(ConstraintTimeline1, CurveTimeline1, ConstraintTimeline)
|
||||
|
||||
ConstraintTimeline1::ConstraintTimeline1(size_t frameCount, size_t bezierCount, int constraintIndex, Property property)
|
||||
: CurveTimeline1(frameCount, bezierCount), _constraintIndex(constraintIndex) {
|
||||
: CurveTimeline1(frameCount, bezierCount), ConstraintTimeline(constraintIndex) {
|
||||
PropertyId ids[] = {((PropertyId) property << 32) | constraintIndex};
|
||||
setPropertyIds(ids, 1);
|
||||
}
|
||||
|
||||
int ConstraintTimeline1::getConstraintIndex() {
|
||||
return _constraintIndex;
|
||||
}
|
||||
@ -41,10 +41,10 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(IkConstraintTimeline, CurveTimeline)
|
||||
RTTI_IMPL_MULTI(IkConstraintTimeline, CurveTimeline, ConstraintTimeline)
|
||||
|
||||
IkConstraintTimeline::IkConstraintTimeline(size_t frameCount, size_t bezierCount, int ikConstraintIndex)
|
||||
: CurveTimeline(frameCount, IkConstraintTimeline::ENTRIES, bezierCount), _constraintIndex(ikConstraintIndex) {
|
||||
: CurveTimeline(frameCount, IkConstraintTimeline::ENTRIES, bezierCount), ConstraintTimeline(ikConstraintIndex) {
|
||||
PropertyId ids[] = {((PropertyId) Property_IkConstraint << 32) | ikConstraintIndex};
|
||||
setPropertyIds(ids, 1);
|
||||
}
|
||||
@ -69,9 +69,9 @@ void IkConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time,
|
||||
constraint.getAppliedPose().setStretch(constraint._data.getSetupPose().getStretch());
|
||||
return;
|
||||
case MixBlend_First:
|
||||
constraint.getAppliedPose().setMix(constraint.getAppliedPose().getMix() +
|
||||
constraint.getAppliedPose().setMix(constraint.getAppliedPose().getMix() +
|
||||
(constraint._data.getSetupPose().getMix() - constraint.getAppliedPose().getMix()) * alpha);
|
||||
constraint.getAppliedPose().setSoftness(constraint.getAppliedPose().getSoftness() +
|
||||
constraint.getAppliedPose().setSoftness(constraint.getAppliedPose().getSoftness() +
|
||||
(constraint._data.getSetupPose().getSoftness() - constraint.getAppliedPose().getSoftness()) * alpha);
|
||||
constraint.getAppliedPose().setBendDirection(constraint._data.getSetupPose().getBendDirection());
|
||||
constraint.getAppliedPose().setCompress(constraint._data.getSetupPose().getCompress());
|
||||
@ -109,9 +109,9 @@ void IkConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time,
|
||||
}
|
||||
|
||||
if (blend == MixBlend_Setup) {
|
||||
constraint.getAppliedPose().setMix(constraint._data.getSetupPose().getMix() +
|
||||
constraint.getAppliedPose().setMix(constraint._data.getSetupPose().getMix() +
|
||||
(mix - constraint._data.getSetupPose().getMix()) * alpha);
|
||||
constraint.getAppliedPose().setSoftness(constraint._data.getSetupPose().getSoftness() +
|
||||
constraint.getAppliedPose().setSoftness(constraint._data.getSetupPose().getSoftness() +
|
||||
(softness - constraint._data.getSetupPose().getSoftness()) * alpha);
|
||||
|
||||
if (direction == MixDirection_Out) {
|
||||
@ -124,9 +124,9 @@ void IkConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time,
|
||||
constraint.getAppliedPose().setStretch(_frames[i + IkConstraintTimeline::STRETCH] != 0);
|
||||
}
|
||||
} else {
|
||||
constraint.getAppliedPose().setMix(constraint.getAppliedPose().getMix() +
|
||||
constraint.getAppliedPose().setMix(constraint.getAppliedPose().getMix() +
|
||||
(mix - constraint.getAppliedPose().getMix()) * alpha);
|
||||
constraint.getAppliedPose().setSoftness(constraint.getAppliedPose().getSoftness() +
|
||||
constraint.getAppliedPose().setSoftness(constraint.getAppliedPose().getSoftness() +
|
||||
(softness - constraint.getAppliedPose().getSoftness()) * alpha);
|
||||
if (direction == MixDirection_In) {
|
||||
constraint.getAppliedPose().setBendDirection(_frames[i + IkConstraintTimeline::BEND_DIRECTION]);
|
||||
|
||||
@ -39,10 +39,10 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(InheritTimeline, Timeline)
|
||||
RTTI_IMPL_MULTI(InheritTimeline, Timeline, BoneTimeline)
|
||||
|
||||
InheritTimeline::InheritTimeline(size_t frameCount, int boneIndex) : Timeline(frameCount, ENTRIES),
|
||||
_boneIndex(boneIndex) {
|
||||
BoneTimeline(boneIndex) {
|
||||
PropertyId ids[] = {((PropertyId) Property_Inherit << 32) | boneIndex};
|
||||
setPropertyIds(ids, 1);
|
||||
}
|
||||
|
||||
@ -255,12 +255,10 @@ void PathConstraint::setSlot(Slot *slot) {
|
||||
|
||||
Vector<float> &
|
||||
PathConstraint::computeWorldPositions(Skeleton &skeleton, PathAttachment &path, int spacesCount, bool tangents) {
|
||||
Slot &slot = *_slot;
|
||||
float position = _applied->_position;
|
||||
float *spaces = _spaces.buffer();
|
||||
_positions.setSize(spacesCount * 3 + 2, 0);
|
||||
Vector<float> &out = _positions;
|
||||
float *outBuffer = out.buffer();
|
||||
Vector<float> &world = _world;
|
||||
bool closed = path.isClosed();
|
||||
int verticesLength = (int) path.getWorldVerticesLength();
|
||||
@ -542,7 +540,7 @@ void PathConstraint::sortPathSlot(Skeleton &skeleton, Skin &skin, int slotIndex,
|
||||
Skin::AttachmentMap::Entries entries = skin.getAttachments();
|
||||
while (entries.hasNext()) {
|
||||
Skin::AttachmentMap::Entry &entry = entries.next();
|
||||
if (entry._slotIndex == slotIndex) sortPath(skeleton, entry._attachment, slotBone);
|
||||
if (entry._slotIndex == (size_t)slotIndex) sortPath(skeleton, entry._attachment, slotBone);
|
||||
}
|
||||
}
|
||||
|
||||
@ -557,7 +555,7 @@ void PathConstraint::sortPath(Skeleton &skeleton, Attachment *attachment, Bone &
|
||||
for (size_t i = 0, n = pathBones.size(); i < n;) {
|
||||
int nn = pathBones[i++];
|
||||
nn += i;
|
||||
while (i < nn)
|
||||
while (i < (size_t)nn)
|
||||
skeleton.sortBone(bones[pathBones[i++]]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,17 +41,17 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(PathConstraintMixTimeline, CurveTimeline)
|
||||
RTTI_IMPL_MULTI(PathConstraintMixTimeline, CurveTimeline, ConstraintTimeline)
|
||||
|
||||
PathConstraintMixTimeline::PathConstraintMixTimeline(size_t frameCount, size_t bezierCount, int pathConstraintIndex)
|
||||
: CurveTimeline(frameCount, PathConstraintMixTimeline::ENTRIES, bezierCount),
|
||||
_constraintIndex(pathConstraintIndex) {
|
||||
ConstraintTimeline(pathConstraintIndex) {
|
||||
PropertyId ids[] = {((PropertyId) Property_PathConstraintMix << 32) | pathConstraintIndex};
|
||||
setPropertyIds(ids, 1);
|
||||
}
|
||||
|
||||
void PathConstraintMixTimeline::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);
|
||||
|
||||
@ -41,13 +41,13 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(PathConstraintPositionTimeline, CurveTimeline1)
|
||||
RTTI_IMPL(PathConstraintPositionTimeline, ConstraintTimeline1)
|
||||
|
||||
PathConstraintPositionTimeline::PathConstraintPositionTimeline(size_t frameCount, size_t bezierCount,
|
||||
int pathConstraintIndex) : CurveTimeline1(frameCount,
|
||||
bezierCount),
|
||||
_constraintIndex(
|
||||
pathConstraintIndex) {
|
||||
int pathConstraintIndex) : ConstraintTimeline1(frameCount,
|
||||
bezierCount,
|
||||
pathConstraintIndex,
|
||||
Property_PathConstraintPosition) {
|
||||
PropertyId ids[] = {((PropertyId) Property_PathConstraintPosition << 32) | pathConstraintIndex};
|
||||
setPropertyIds(ids, 1);
|
||||
}
|
||||
@ -56,7 +56,7 @@ PathConstraintPositionTimeline::~PathConstraintPositionTimeline() {
|
||||
}
|
||||
|
||||
void PathConstraintPositionTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
||||
float alpha, MixBlend blend, MixDirection direction) {
|
||||
float alpha, MixBlend blend, MixDirection direction, bool appliedPose) {
|
||||
SP_UNUSED(lastTime);
|
||||
SP_UNUSED(pEvents);
|
||||
SP_UNUSED(direction);
|
||||
|
||||
@ -41,19 +41,19 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(PathConstraintSpacingTimeline, PathConstraintPositionTimeline)
|
||||
RTTI_IMPL(PathConstraintSpacingTimeline, ConstraintTimeline1)
|
||||
|
||||
PathConstraintSpacingTimeline::PathConstraintSpacingTimeline(size_t frameCount, size_t bezierCount,
|
||||
int pathConstraintIndex) : CurveTimeline1(frameCount,
|
||||
bezierCount),
|
||||
_pathConstraintIndex(
|
||||
pathConstraintIndex) {
|
||||
int pathConstraintIndex) : ConstraintTimeline1(frameCount,
|
||||
bezierCount,
|
||||
pathConstraintIndex,
|
||||
Property_PathConstraintSpacing) {
|
||||
PropertyId ids[] = {((PropertyId) Property_PathConstraintSpacing << 32) | pathConstraintIndex};
|
||||
setPropertyIds(ids, 1);
|
||||
}
|
||||
|
||||
void PathConstraintSpacingTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
||||
float alpha, MixBlend blend, MixDirection direction) {
|
||||
float alpha, MixBlend blend, MixDirection direction, bool appliedPose) {
|
||||
SP_UNUSED(lastTime);
|
||||
SP_UNUSED(pEvents);
|
||||
SP_UNUSED(direction);
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(PhysicsConstraintTimeline, CurveTimeline)
|
||||
RTTI_IMPL_MULTI(PhysicsConstraintTimeline, CurveTimeline, ConstraintTimeline)
|
||||
RTTI_IMPL(PhysicsConstraintInertiaTimeline, PhysicsConstraintTimeline)
|
||||
RTTI_IMPL(PhysicsConstraintStrengthTimeline, PhysicsConstraintTimeline)
|
||||
RTTI_IMPL(PhysicsConstraintDampingTimeline, PhysicsConstraintTimeline)
|
||||
@ -49,11 +49,11 @@ RTTI_IMPL(PhysicsConstraintMassTimeline, PhysicsConstraintTimeline)
|
||||
RTTI_IMPL(PhysicsConstraintWindTimeline, PhysicsConstraintTimeline)
|
||||
RTTI_IMPL(PhysicsConstraintGravityTimeline, PhysicsConstraintTimeline)
|
||||
RTTI_IMPL(PhysicsConstraintMixTimeline, PhysicsConstraintTimeline)
|
||||
RTTI_IMPL(PhysicsConstraintResetTimeline, Timeline)
|
||||
RTTI_IMPL_MULTI(PhysicsConstraintResetTimeline, Timeline, ConstraintTimeline)
|
||||
|
||||
PhysicsConstraintTimeline::PhysicsConstraintTimeline(size_t frameCount, size_t bezierCount,
|
||||
int constraintIndex, Property property) : CurveTimeline1(frameCount, bezierCount),
|
||||
_constraintIndex(constraintIndex) {
|
||||
ConstraintTimeline(constraintIndex) {
|
||||
PropertyId ids[] = {((PropertyId) property << 32) | constraintIndex};
|
||||
setPropertyIds(ids, 1);
|
||||
}
|
||||
@ -66,7 +66,7 @@ void PhysicsConstraintTimeline::apply(Skeleton &skeleton, float, float time, Vec
|
||||
Vector<PhysicsConstraint *> &physicsConstraints = skeleton.getPhysicsConstraints();
|
||||
for (size_t i = 0; i < physicsConstraints.size(); i++) {
|
||||
PhysicsConstraint *constraint = physicsConstraints[i];
|
||||
if (constraint->_active && global(constraint->_data)) {
|
||||
if (constraint->isActive() && global(constraint->_data)) {
|
||||
PhysicsConstraintPose &pose = appliedPose ? *constraint->_applied : constraint->_pose;
|
||||
PhysicsConstraintPose &setupPose = constraint->_data._setup;
|
||||
set(pose, getAbsoluteValue(time, alpha, blend, get(pose), get(setupPose), value));
|
||||
@ -74,8 +74,8 @@ void PhysicsConstraintTimeline::apply(Skeleton &skeleton, float, float time, Vec
|
||||
}
|
||||
} else {
|
||||
PhysicsConstraint *constraint = skeleton.getPhysicsConstraints()[_constraintIndex];
|
||||
if (constraint->_active) {
|
||||
PhysicsConstraintPose &pose = appliedPose ? constraint->_applied : constraint->_pose;
|
||||
if (constraint->isActive()) {
|
||||
PhysicsConstraintPose &pose = appliedPose ? *constraint->_applied : constraint->_pose;
|
||||
PhysicsConstraintPose &setupPose = constraint->_data._setup;
|
||||
set(pose, getAbsoluteValue(time, alpha, blend, get(pose), get(setupPose)));
|
||||
}
|
||||
@ -86,7 +86,7 @@ void PhysicsConstraintResetTimeline::apply(Skeleton &skeleton, float lastTime, f
|
||||
PhysicsConstraint *constraint = nullptr;
|
||||
if (_constraintIndex != -1) {
|
||||
constraint = skeleton.getPhysicsConstraints()[_constraintIndex];
|
||||
if (!constraint->_active) return;
|
||||
if (!constraint->isActive()) return;
|
||||
}
|
||||
|
||||
if (lastTime > time) {// Apply after lastTime for looped animations.
|
||||
@ -103,7 +103,7 @@ void PhysicsConstraintResetTimeline::apply(Skeleton &skeleton, float lastTime, f
|
||||
Vector<PhysicsConstraint *> &physicsConstraints = skeleton.getPhysicsConstraints();
|
||||
for (size_t i = 0; i < physicsConstraints.size(); i++) {
|
||||
constraint = physicsConstraints[i];
|
||||
if (constraint->_active) constraint->reset(skeleton);
|
||||
if (constraint->isActive()) constraint->reset(skeleton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,10 +32,27 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI::RTTI(const char *className) : _className(className), _pBaseRTTI(NULL) {
|
||||
RTTI::RTTI(const char *className) : _className(className), _pBaseRTTI(NULL), _interfaceCount(0) {
|
||||
_interfaces[0] = NULL;
|
||||
_interfaces[1] = NULL;
|
||||
_interfaces[2] = NULL;
|
||||
}
|
||||
|
||||
RTTI::RTTI(const char *className, const RTTI &baseRTTI) : _className(className), _pBaseRTTI(&baseRTTI) {
|
||||
RTTI::RTTI(const char *className, const RTTI &baseRTTI) : _className(className), _pBaseRTTI(&baseRTTI), _interfaceCount(0) {
|
||||
_interfaces[0] = NULL;
|
||||
_interfaces[1] = NULL;
|
||||
_interfaces[2] = NULL;
|
||||
}
|
||||
|
||||
RTTI::RTTI(const char *className, const RTTI &baseRTTI, const RTTI* interface1, const RTTI* interface2, const RTTI* interface3)
|
||||
: _className(className), _pBaseRTTI(&baseRTTI), _interfaceCount(0) {
|
||||
_interfaces[0] = interface1;
|
||||
_interfaces[1] = interface2;
|
||||
_interfaces[2] = interface3;
|
||||
|
||||
if (interface1) _interfaceCount++;
|
||||
if (interface2) _interfaceCount++;
|
||||
if (interface3) _interfaceCount++;
|
||||
}
|
||||
|
||||
const char *RTTI::getClassName() const {
|
||||
@ -47,10 +64,20 @@ bool RTTI::isExactly(const RTTI &rtti) const {
|
||||
}
|
||||
|
||||
bool RTTI::instanceOf(const RTTI &rtti) const {
|
||||
// Check the main inheritance chain
|
||||
const RTTI *pCompare = this;
|
||||
while (pCompare) {
|
||||
if (!strcmp(pCompare->_className, rtti._className)) return true;
|
||||
|
||||
// Check interfaces at this level of the hierarchy
|
||||
for (int i = 0; i < pCompare->_interfaceCount; i++) {
|
||||
if (pCompare->_interfaces[i] && !strcmp(pCompare->_interfaces[i]->_className, rtti._className)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
pCompare = pCompare->_pBaseRTTI;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(SequenceTimeline, Timeline)
|
||||
RTTI_IMPL_MULTI(SequenceTimeline, Timeline, SlotTimeline)
|
||||
|
||||
SequenceTimeline::SequenceTimeline(size_t frameCount, int slotIndex, Attachment *attachment) : Timeline(frameCount, ENTRIES), SlotTimeline(slotIndex), _attachment((HasTextureRegion *) attachment) {
|
||||
int sequenceId = 0;
|
||||
|
||||
@ -31,10 +31,16 @@
|
||||
#include <spine/Skeleton.h>
|
||||
#include <spine/Bone.h>
|
||||
#include <spine/BoneData.h>
|
||||
#include <spine/BonePose.h>
|
||||
#include <spine/Animation.h>
|
||||
#include <spine/Timeline.h>
|
||||
#include <spine/SlotTimeline.h>
|
||||
#include <spine/ConstraintTimeline.h>
|
||||
#include <spine/PhysicsConstraintTimeline.h>
|
||||
#include <spine/SliderData.h>
|
||||
#include <spine/SliderPose.h>
|
||||
#include <spine/Slot.h>
|
||||
#include <spine/PhysicsConstraint.h>
|
||||
#include <spine/TransformConstraintData.h>
|
||||
#include <spine/MathUtil.h>
|
||||
|
||||
@ -45,8 +51,8 @@ RTTI_IMPL(Slider, Constraint)
|
||||
float Slider::_offsets[6];
|
||||
|
||||
Slider::Slider(SliderData &data, Skeleton &skeleton) : ConstraintGeneric<Slider, SliderData, SliderPose>(data), _bone(NULL) {
|
||||
if (data.getBone() != NULL) {
|
||||
_bone = skeleton.findBone(data.getBone()->getName());
|
||||
if (data._bone != NULL) {
|
||||
_bone = skeleton._bones[data._bone->getIndex()];
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,11 +63,70 @@ Slider *Slider::copy(Skeleton &skeleton) {
|
||||
}
|
||||
|
||||
void Slider::update(Skeleton &skeleton, Physics physics) {
|
||||
// TODO: Implement when Animation is ported
|
||||
SliderPose &p = *_applied;
|
||||
if (p._mix == 0) return;
|
||||
|
||||
Animation *animation = _data._animation;
|
||||
if (_bone != NULL) {
|
||||
if (!_bone->isActive()) return;
|
||||
if (_data._local) _bone->_applied->validateLocalTransform(skeleton);
|
||||
p._time = _data._offset
|
||||
+ (_data._property->value(skeleton, *_bone->_applied, _data._local, _offsets) - _data._property->offset) * _data._scale;
|
||||
if (_data._loop)
|
||||
p._time = animation->getDuration() + MathUtil::fmod(p._time, animation->getDuration());
|
||||
else
|
||||
p._time = MathUtil::max(0.0f, p._time);
|
||||
}
|
||||
|
||||
Vector<Bone *> &bones = skeleton._bones;
|
||||
const Vector<int> &indices = animation->getBones();
|
||||
for (size_t i = 0, n = indices.size(); i < n; i++)
|
||||
bones[indices[i]]->_applied->modifyLocal(skeleton);
|
||||
|
||||
animation->apply(skeleton, p._time, p._time, _data._loop, NULL, p._mix, _data._additive ? MixBlend_Add : MixBlend_Replace,
|
||||
MixDirection_In, true);
|
||||
}
|
||||
|
||||
void Slider::sort(Skeleton &skeleton) {
|
||||
// TODO: Implement when Animation is ported
|
||||
if (_bone != NULL && !_data._local) skeleton.sortBone(_bone);
|
||||
skeleton._updateCache.add(this);
|
||||
|
||||
Vector<Bone *> &bones = skeleton._bones;
|
||||
const Vector<int> &indices = _data._animation->getBones();
|
||||
for (size_t i = 0, n = indices.size(); i < n; i++) {
|
||||
Bone *bone = bones[indices[i]];
|
||||
bone->_sorted = false;
|
||||
skeleton.sortReset(bone->getChildren());
|
||||
skeleton.constrained(*bone);
|
||||
}
|
||||
|
||||
Vector<Timeline *> &timelines = _data._animation->getTimelines();
|
||||
Vector<Slot *> &slots = skeleton._slots;
|
||||
Vector<Constraint *> &constraints = skeleton._constraints;
|
||||
Vector<PhysicsConstraint *> &physics = skeleton._physics;
|
||||
size_t physicsCount = physics.size();
|
||||
for (size_t i = 0, n = timelines.size(); i < n; i++) {
|
||||
Timeline *t = timelines[i];
|
||||
|
||||
if (t->getRTTI().instanceOf(SlotTimeline::rtti)) {
|
||||
SlotTimeline *timeline = (SlotTimeline *)t;
|
||||
skeleton.constrained(*slots[timeline->getSlotIndex()]);
|
||||
} else if (t->getRTTI().instanceOf(PhysicsConstraintTimeline::rtti)) {
|
||||
PhysicsConstraintTimeline *timeline = (PhysicsConstraintTimeline *)t;
|
||||
if (timeline->getConstraintIndex() == -1) {
|
||||
for (size_t ii = 0; ii < physicsCount; ii++)
|
||||
skeleton.constrained(*physics[ii]);
|
||||
} else
|
||||
skeleton.constrained((Posed &)*constraints[timeline->getConstraintIndex()]);
|
||||
} else if (t->getRTTI().instanceOf(ConstraintTimeline::rtti)) {
|
||||
ConstraintTimeline *timeline = (ConstraintTimeline *)t;
|
||||
skeleton.constrained((Posed &)*constraints[timeline->getConstraintIndex()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Slider::isSourceActive() {
|
||||
return _bone == NULL || _bone->isActive();
|
||||
}
|
||||
|
||||
Bone *Slider::getBone() {
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(SlotCurveTimeline, CurveTimeline)
|
||||
RTTI_IMPL_MULTI(SlotCurveTimeline, CurveTimeline, SlotTimeline)
|
||||
|
||||
SlotCurveTimeline::SlotCurveTimeline(size_t frameCount, size_t frameEntries, size_t bezierCount, int slotIndex)
|
||||
: CurveTimeline(frameCount, frameEntries, bezierCount), SlotTimeline(slotIndex) {
|
||||
|
||||
@ -41,20 +41,19 @@
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(TransformConstraintTimeline, CurveTimeline)
|
||||
RTTI_IMPL_MULTI(TransformConstraintTimeline, CurveTimeline, ConstraintTimeline)
|
||||
|
||||
TransformConstraintTimeline::TransformConstraintTimeline(size_t frameCount, size_t bezierCount,
|
||||
int transformConstraintIndex) : CurveTimeline(frameCount,
|
||||
TransformConstraintTimeline::ENTRIES,
|
||||
bezierCount),
|
||||
_constraintIndex(
|
||||
transformConstraintIndex) {
|
||||
ConstraintTimeline(transformConstraintIndex) {
|
||||
PropertyId ids[] = {((PropertyId) Property_TransformConstraint << 32) | transformConstraintIndex};
|
||||
setPropertyIds(ids, 1);
|
||||
}
|
||||
|
||||
void TransformConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
||||
float alpha, MixBlend blend, MixDirection direction) {
|
||||
float alpha, MixBlend blend, MixDirection direction, bool appliedPose) {
|
||||
SP_UNUSED(lastTime);
|
||||
SP_UNUSED(pEvents);
|
||||
SP_UNUSED(direction);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user