mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-05 10:16:54 +08:00
[cpp] 4.3 porting WIP
This commit is contained in:
parent
7a99a2f487
commit
4f728c6fd2
@ -46,8 +46,6 @@ namespace spine {
|
|||||||
/// Spine Runtimes Guide.
|
/// Spine Runtimes Guide.
|
||||||
class SP_API AtlasAttachmentLoader : public AttachmentLoader {
|
class SP_API AtlasAttachmentLoader : public AttachmentLoader {
|
||||||
public:
|
public:
|
||||||
RTTI_DECL
|
|
||||||
|
|
||||||
explicit AtlasAttachmentLoader(Atlas *atlas);
|
explicit AtlasAttachmentLoader(Atlas *atlas);
|
||||||
|
|
||||||
virtual RegionAttachment *newRegionAttachment(Skin &skin, const String &name, const String &path, Sequence *sequence);
|
virtual RegionAttachment *newRegionAttachment(Skin &skin, const String &name, const String &path, Sequence *sequence);
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API Attachment : public SpineObject {
|
class SP_API Attachment : public SpineObject {
|
||||||
RTTI_DECL
|
RTTI_DECL_NOPARENT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Attachment(const String &name);
|
explicit Attachment(const String &name);
|
||||||
|
|||||||
@ -55,8 +55,6 @@ namespace spine {
|
|||||||
|
|
||||||
class SP_API AttachmentLoader : public SpineObject {
|
class SP_API AttachmentLoader : public SpineObject {
|
||||||
public:
|
public:
|
||||||
RTTI_DECL
|
|
||||||
|
|
||||||
AttachmentLoader();
|
AttachmentLoader();
|
||||||
|
|
||||||
virtual ~AttachmentLoader();
|
virtual ~AttachmentLoader();
|
||||||
|
|||||||
@ -36,6 +36,7 @@
|
|||||||
#include <spine/MixBlend.h>
|
#include <spine/MixBlend.h>
|
||||||
#include <spine/MixDirection.h>
|
#include <spine/MixDirection.h>
|
||||||
#include <spine/SpineString.h>
|
#include <spine/SpineString.h>
|
||||||
|
#include <spine/SlotTimeline.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
@ -43,9 +44,11 @@ namespace spine {
|
|||||||
|
|
||||||
class Slot;
|
class Slot;
|
||||||
|
|
||||||
|
class SlotPose;
|
||||||
|
|
||||||
class Event;
|
class Event;
|
||||||
|
|
||||||
class SP_API AttachmentTimeline : public Timeline {
|
class SP_API AttachmentTimeline : public Timeline, public SlotTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
@ -59,23 +62,17 @@ namespace spine {
|
|||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||||
MixDirection direction);
|
MixDirection direction, bool appliedPose) override;
|
||||||
|
|
||||||
/// Sets the time and value of the specified keyframe.
|
/// Sets the time and value of the specified keyframe.
|
||||||
void setFrame(int frame, float time, const String &attachmentName);
|
void setFrame(int frame, float time, const String &attachmentName);
|
||||||
|
|
||||||
Vector<String> &getAttachmentNames();
|
Vector<String> &getAttachmentNames();
|
||||||
|
|
||||||
int getSlotIndex() { return _slotIndex; }
|
|
||||||
|
|
||||||
void setSlotIndex(int inValue) { _slotIndex = inValue; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int _slotIndex;
|
|
||||||
|
|
||||||
Vector<String> _attachmentNames;
|
Vector<String> _attachmentNames;
|
||||||
|
|
||||||
void setAttachment(Skeleton &skeleton, Slot &slot, String *attachmentName);
|
void setAttachment(Skeleton &skeleton, SlotPose &pose, String *attachmentName);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,7 @@ namespace spine {
|
|||||||
friend class TranslateYTimeline;
|
friend class TranslateYTimeline;
|
||||||
friend class InheritTimeline;
|
friend class InheritTimeline;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL_NOPARENT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// @param parent May be NULL.
|
/// @param parent May be NULL.
|
||||||
|
|||||||
@ -38,7 +38,6 @@
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API BoneData : public PosedData<BoneLocal> {
|
class SP_API BoneData : public PosedData<BoneLocal> {
|
||||||
RTTI_DECL
|
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|||||||
@ -52,8 +52,6 @@ namespace spine {
|
|||||||
friend class TranslateXTimeline;
|
friend class TranslateXTimeline;
|
||||||
friend class TranslateYTimeline;
|
friend class TranslateYTimeline;
|
||||||
|
|
||||||
RTTI_DECL
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float _x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY;
|
float _x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY;
|
||||||
Inherit _inherit;
|
Inherit _inherit;
|
||||||
|
|||||||
@ -40,7 +40,6 @@ namespace spine {
|
|||||||
|
|
||||||
class SP_API BonePose : public BoneLocal, public Update {
|
class SP_API BonePose : public BoneLocal, public Update {
|
||||||
friend class IkConstraint;
|
friend class IkConstraint;
|
||||||
RTTI_DECL
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Bone* _bone;
|
Bone* _bone;
|
||||||
|
|||||||
@ -44,7 +44,7 @@ namespace spine {
|
|||||||
|
|
||||||
Color &getColor();
|
Color &getColor();
|
||||||
|
|
||||||
virtual Attachment *copy();
|
virtual Attachment *copy() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Color _color;
|
Color _color;
|
||||||
|
|||||||
@ -54,7 +54,7 @@ namespace spine {
|
|||||||
|
|
||||||
Color &getColor();
|
Color &getColor();
|
||||||
|
|
||||||
virtual Attachment *copy();
|
virtual Attachment *copy() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SlotData *_endSlot;
|
SlotData *_endSlot;
|
||||||
|
|||||||
@ -47,8 +47,6 @@ namespace spine {
|
|||||||
|
|
||||||
virtual ~RGBATimeline();
|
virtual ~RGBATimeline();
|
||||||
|
|
||||||
int getFrameEntries();
|
|
||||||
|
|
||||||
/// Sets the time and color for the specified frame.
|
/// Sets the time and color for the specified frame.
|
||||||
/// @param frame Between 0 and frameCount, inclusive.
|
/// @param frame Between 0 and frameCount, inclusive.
|
||||||
/// @param time The frame time in seconds.
|
/// @param time The frame time in seconds.
|
||||||
@ -77,8 +75,6 @@ namespace spine {
|
|||||||
|
|
||||||
virtual ~RGBTimeline();
|
virtual ~RGBTimeline();
|
||||||
|
|
||||||
int getFrameEntries();
|
|
||||||
|
|
||||||
/// Sets the time and color for the specified frame.
|
/// Sets the time and color for the specified frame.
|
||||||
/// @param frame Between 0 and frameCount, inclusive.
|
/// @param frame Between 0 and frameCount, inclusive.
|
||||||
/// @param time The frame time in seconds.
|
/// @param time The frame time in seconds.
|
||||||
@ -108,11 +104,6 @@ namespace spine {
|
|||||||
virtual void
|
virtual void
|
||||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||||
MixDirection direction, bool appliedPose) override;
|
MixDirection direction, bool appliedPose) override;
|
||||||
|
|
||||||
virtual int getSlotIndex() override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int _slotIndex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Changes a slot's SlotPose::getColor() and SlotPose::getDarkColor() for two color tinting.
|
/// Changes a slot's SlotPose::getColor() and SlotPose::getDarkColor() for two color tinting.
|
||||||
@ -128,8 +119,6 @@ namespace spine {
|
|||||||
|
|
||||||
virtual ~RGBA2Timeline();
|
virtual ~RGBA2Timeline();
|
||||||
|
|
||||||
int getFrameEntries();
|
|
||||||
|
|
||||||
/// Sets the time, light color, and dark color for the specified frame.
|
/// Sets the time, light color, and dark color for the specified frame.
|
||||||
/// @param frame Between 0 and frameCount, inclusive.
|
/// @param frame Between 0 and frameCount, inclusive.
|
||||||
/// @param time The frame time in seconds.
|
/// @param time The frame time in seconds.
|
||||||
@ -161,8 +150,6 @@ namespace spine {
|
|||||||
|
|
||||||
virtual ~RGB2Timeline();
|
virtual ~RGB2Timeline();
|
||||||
|
|
||||||
int getFrameEntries();
|
|
||||||
|
|
||||||
/// Sets the time, light color, and dark color for the specified frame.
|
/// Sets the time, light color, and dark color for the specified frame.
|
||||||
/// @param frame Between 0 and frameCount, inclusive.
|
/// @param frame Between 0 and frameCount, inclusive.
|
||||||
/// @param time The frame time in seconds.
|
/// @param time The frame time in seconds.
|
||||||
|
|||||||
@ -37,15 +37,22 @@
|
|||||||
namespace spine {
|
namespace spine {
|
||||||
class Skeleton;
|
class Skeleton;
|
||||||
|
|
||||||
|
class SP_API Constraint: public Update {
|
||||||
|
RTTI_DECL_NOPARENT
|
||||||
|
public:
|
||||||
|
Constraint();
|
||||||
|
virtual ~Constraint();
|
||||||
|
};
|
||||||
|
|
||||||
template<class T, class D, class P>
|
template<class T, class D, class P>
|
||||||
class SP_API Constraint : public PosedActive<D, P, P>, public Update {
|
class SP_API ConstraintGeneric : public PosedActive<D, P, P>, public Constraint {
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Constraint(D& data) : PosedActive<D, P, P>(data) {
|
ConstraintGeneric(D& data) : PosedActive<D, P, P>(data), Constraint() {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Constraint() {
|
virtual ~ConstraintGeneric() {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sort(Skeleton& skeleton) = 0;
|
virtual void sort(Skeleton& skeleton) = 0;
|
||||||
@ -55,7 +62,7 @@ namespace spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inherited from Update
|
// Inherited from Update
|
||||||
virtual void update(Skeleton& skeleton, Physics physics) = 0;
|
virtual void update(Skeleton& skeleton, Physics physics) override = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,8 +39,8 @@ namespace spine {
|
|||||||
|
|
||||||
/// Base class for all constraint data types.
|
/// Base class for all constraint data types.
|
||||||
class SP_API ConstraintData : public SpineObject {
|
class SP_API ConstraintData : public SpineObject {
|
||||||
RTTI_DECL
|
|
||||||
public:
|
public:
|
||||||
|
RTTI_DECL_NOPARENT
|
||||||
ConstraintData(const String &name);
|
ConstraintData(const String &name);
|
||||||
virtual ~ConstraintData();
|
virtual ~ConstraintData();
|
||||||
const String &getName() const;
|
const String &getName() const;
|
||||||
|
|||||||
@ -75,8 +75,6 @@ namespace spine {
|
|||||||
|
|
||||||
virtual ~CurveTimeline1();
|
virtual ~CurveTimeline1();
|
||||||
|
|
||||||
size_t getFrameEntries();
|
|
||||||
|
|
||||||
/// Sets the time and value for the specified frame.
|
/// Sets the time and value for the specified frame.
|
||||||
/// @param frame Between 0 and frameCount, inclusive.
|
/// @param frame Between 0 and frameCount, inclusive.
|
||||||
/// @param time The frame time in seconds.
|
/// @param time The frame time in seconds.
|
||||||
|
|||||||
@ -30,13 +30,12 @@
|
|||||||
#ifndef Spine_DeformTimeline_h
|
#ifndef Spine_DeformTimeline_h
|
||||||
#define Spine_DeformTimeline_h
|
#define Spine_DeformTimeline_h
|
||||||
|
|
||||||
#include <spine/CurveTimeline.h>
|
#include <spine/SlotCurveTimeline.h>
|
||||||
#include <spine/SlotTimeline.h>
|
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class VertexAttachment;
|
class VertexAttachment;
|
||||||
|
|
||||||
class SP_API DeformTimeline : public CurveTimeline, public SlotTimeline {
|
class SP_API DeformTimeline : public SlotCurveTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
@ -48,7 +47,7 @@ namespace spine {
|
|||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||||
MixDirection direction) override;
|
MixDirection direction, bool appliedPose) override;
|
||||||
|
|
||||||
/// Sets the time and vertices for the specified frame.
|
/// Sets the time and vertices for the specified frame.
|
||||||
void setFrame(int frameIndex, float time, Vector<float> &vertices);
|
void setFrame(int frameIndex, float time, Vector<float> &vertices);
|
||||||
@ -67,18 +66,12 @@ namespace spine {
|
|||||||
|
|
||||||
float getCurvePercent(float time, int frame);
|
float getCurvePercent(float time, int frame);
|
||||||
|
|
||||||
int getSlotIndex() override { return _slotIndex; }
|
|
||||||
|
|
||||||
void setSlotIndex(int inValue) { _slotIndex = inValue; }
|
|
||||||
|
|
||||||
size_t getFrameCount() { return _frames.size(); }
|
size_t getFrameCount() { return _frames.size(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void apply(Slot &slot, SlotPose &pose, float time, float alpha, MixBlend blend);
|
void apply(Slot &slot, SlotPose &pose, float time, float alpha, MixBlend blend) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _slotIndex;
|
|
||||||
|
|
||||||
Vector <Vector<float>> _vertices;
|
Vector <Vector<float>> _vertices;
|
||||||
|
|
||||||
VertexAttachment *_attachment;
|
VertexAttachment *_attachment;
|
||||||
|
|||||||
@ -41,7 +41,7 @@ namespace spine {
|
|||||||
class Bone;
|
class Bone;
|
||||||
class BonePose;
|
class BonePose;
|
||||||
|
|
||||||
class SP_API IkConstraint : public Constraint<IkConstraint, IkConstraintData, IkConstraintPose> {
|
class SP_API IkConstraint : public ConstraintGeneric<IkConstraint, IkConstraintData, IkConstraintPose> {
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
|
|
||||||
friend class IkConstraintTimeline;
|
friend class IkConstraintTimeline;
|
||||||
@ -63,11 +63,11 @@ namespace spine {
|
|||||||
|
|
||||||
IkConstraint(IkConstraintData &data, Skeleton &skeleton);
|
IkConstraint(IkConstraintData &data, Skeleton &skeleton);
|
||||||
|
|
||||||
virtual void update(Skeleton& skeleton, Physics physics);
|
virtual void update(Skeleton& skeleton, Physics physics) override;
|
||||||
|
|
||||||
virtual void sort(Skeleton& skeleton);
|
virtual void sort(Skeleton& skeleton) override;
|
||||||
|
|
||||||
virtual bool isSourceActive();
|
virtual bool isSourceActive() override;
|
||||||
|
|
||||||
virtual IkConstraint* copy(Skeleton& skeleton);
|
virtual IkConstraint* copy(Skeleton& skeleton);
|
||||||
|
|
||||||
|
|||||||
@ -51,9 +51,9 @@ namespace spine {
|
|||||||
|
|
||||||
friend class IkConstraintTimeline;
|
friend class IkConstraintTimeline;
|
||||||
|
|
||||||
public:
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
|
public:
|
||||||
explicit IkConstraintData(const String &name);
|
explicit IkConstraintData(const String &name);
|
||||||
|
|
||||||
/// The bones that are constrained by this IK Constraint.
|
/// The bones that are constrained by this IK Constraint.
|
||||||
|
|||||||
@ -38,7 +38,6 @@ namespace spine {
|
|||||||
/// Stores the current pose for an IK constraint.
|
/// Stores the current pose for an IK constraint.
|
||||||
class SP_API IkConstraintPose : public Pose<IkConstraintPose> {
|
class SP_API IkConstraintPose : public Pose<IkConstraintPose> {
|
||||||
friend class IkConstraint;
|
friend class IkConstraint;
|
||||||
RTTI_DECL
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IkConstraintPose();
|
IkConstraintPose();
|
||||||
|
|||||||
@ -56,7 +56,7 @@ namespace spine {
|
|||||||
using VertexAttachment::computeWorldVertices;
|
using VertexAttachment::computeWorldVertices;
|
||||||
|
|
||||||
virtual void computeWorldVertices(Skeleton &skeleton, Slot &slot, size_t start, size_t count, float *worldVertices, size_t offset,
|
virtual void computeWorldVertices(Skeleton &skeleton, Slot &slot, size_t start, size_t count, float *worldVertices, size_t offset,
|
||||||
size_t stride = 2);
|
size_t stride = 2) override;
|
||||||
|
|
||||||
void updateRegion();
|
void updateRegion();
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ namespace spine {
|
|||||||
|
|
||||||
void setHeight(float inValue);
|
void setHeight(float inValue);
|
||||||
|
|
||||||
virtual Attachment *copy();
|
virtual Attachment *copy() override;
|
||||||
|
|
||||||
MeshAttachment *newLinkedMesh();
|
MeshAttachment *newLinkedMesh();
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,7 @@ namespace spine {
|
|||||||
|
|
||||||
Color &getColor();
|
Color &getColor();
|
||||||
|
|
||||||
virtual Attachment *copy();
|
virtual Attachment *copy() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<float> _lengths;
|
Vector<float> _lengths;
|
||||||
|
|||||||
@ -49,7 +49,7 @@ namespace spine {
|
|||||||
/// constrained bones so they follow a PathAttachment.
|
/// constrained bones so they follow a PathAttachment.
|
||||||
///
|
///
|
||||||
/// See https://esotericsoftware.com/spine-path-constraints Path constraints in the Spine User Guide.
|
/// See https://esotericsoftware.com/spine-path-constraints Path constraints in the Spine User Guide.
|
||||||
class SP_API PathConstraint : public Constraint<PathConstraint, PathConstraintData, PathConstraintPose> {
|
class SP_API PathConstraint : public ConstraintGeneric<PathConstraint, PathConstraintData, PathConstraintPose> {
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
friend class PathConstraintMixTimeline;
|
friend class PathConstraintMixTimeline;
|
||||||
friend class PathConstraintPositionTimeline;
|
friend class PathConstraintPositionTimeline;
|
||||||
@ -63,11 +63,11 @@ namespace spine {
|
|||||||
|
|
||||||
PathConstraint(PathConstraintData &data, Skeleton &skeleton);
|
PathConstraint(PathConstraintData &data, Skeleton &skeleton);
|
||||||
|
|
||||||
virtual void update(Skeleton& skeleton, Physics physics);
|
virtual void update(Skeleton& skeleton, Physics physics) override;
|
||||||
|
|
||||||
virtual void sort(Skeleton& skeleton);
|
virtual void sort(Skeleton& skeleton) override;
|
||||||
|
|
||||||
virtual bool isSourceActive();
|
virtual bool isSourceActive() override;
|
||||||
|
|
||||||
PathConstraintData &getData();
|
PathConstraintData &getData();
|
||||||
|
|
||||||
|
|||||||
@ -87,8 +87,9 @@ namespace spine {
|
|||||||
friend class PathConstraintPositionTimeline;
|
friend class PathConstraintPositionTimeline;
|
||||||
|
|
||||||
friend class PathConstraintSpacingTimeline;
|
friend class PathConstraintSpacingTimeline;
|
||||||
public:
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
public:
|
||||||
|
|
||||||
explicit PathConstraintData(const String &name);
|
explicit PathConstraintData(const String &name);
|
||||||
|
|
||||||
|
|||||||
@ -38,8 +38,6 @@ namespace spine {
|
|||||||
class SP_API PathConstraintPose : public Pose<PathConstraintPose> {
|
class SP_API PathConstraintPose : public Pose<PathConstraintPose> {
|
||||||
friend class PathConstraint;
|
friend class PathConstraint;
|
||||||
|
|
||||||
RTTI_DECL
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _position;
|
float _position;
|
||||||
float _spacing;
|
float _spacing;
|
||||||
|
|||||||
@ -44,7 +44,7 @@ namespace spine {
|
|||||||
/// Stores the current pose for a physics constraint. A physics constraint applies physics to bones.
|
/// Stores the current pose for a physics constraint. A physics constraint applies physics to bones.
|
||||||
///
|
///
|
||||||
/// See https://esotericsoftware.com/spine-physics-constraints Physics constraints in the Spine User Guide.
|
/// See https://esotericsoftware.com/spine-physics-constraints Physics constraints in the Spine User Guide.
|
||||||
class SP_API PhysicsConstraint : public Constraint<PhysicsConstraint, PhysicsConstraintData, PhysicsConstraintPose> {
|
class SP_API PhysicsConstraint : public ConstraintGeneric<PhysicsConstraint, PhysicsConstraintData, PhysicsConstraintPose> {
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
friend class PhysicsConstraintTimeline;
|
friend class PhysicsConstraintTimeline;
|
||||||
friend class PhysicsConstraintInertiaTimeline;
|
friend class PhysicsConstraintInertiaTimeline;
|
||||||
@ -62,8 +62,8 @@ namespace spine {
|
|||||||
PhysicsConstraint(PhysicsConstraintData& data, Skeleton& skeleton);
|
PhysicsConstraint(PhysicsConstraintData& data, Skeleton& skeleton);
|
||||||
|
|
||||||
void update(Skeleton& skeleton, Physics physics) override;
|
void update(Skeleton& skeleton, Physics physics) override;
|
||||||
void sort(Skeleton& skeleton);
|
void sort(Skeleton& skeleton) override;
|
||||||
bool isSourceActive();
|
bool isSourceActive() override;
|
||||||
PhysicsConstraint* copy(Skeleton& skeleton);
|
PhysicsConstraint* copy(Skeleton& skeleton);
|
||||||
|
|
||||||
/// Translates the physics constraint so next update() forces are applied as if the bone moved an additional amount in world space.
|
/// Translates the physics constraint so next update() forces are applied as if the bone moved an additional amount in world space.
|
||||||
|
|||||||
@ -46,9 +46,8 @@ namespace spine {
|
|||||||
friend class PhysicsConstraint;
|
friend class PhysicsConstraint;
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
|
|
||||||
public:
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
public:
|
||||||
explicit PhysicsConstraintData(const String &name);
|
explicit PhysicsConstraintData(const String &name);
|
||||||
|
|
||||||
/// The bone constrained by this physics constraint.
|
/// The bone constrained by this physics constraint.
|
||||||
|
|||||||
@ -36,8 +36,6 @@
|
|||||||
namespace spine {
|
namespace spine {
|
||||||
/// Stores a pose for a physics constraint.
|
/// Stores a pose for a physics constraint.
|
||||||
class SP_API PhysicsConstraintPose : public Pose<PhysicsConstraintPose> {
|
class SP_API PhysicsConstraintPose : public Pose<PhysicsConstraintPose> {
|
||||||
RTTI_DECL
|
|
||||||
|
|
||||||
friend class PhysicsConstraint;
|
friend class PhysicsConstraint;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -71,7 +71,7 @@ namespace spine {
|
|||||||
|
|
||||||
float computeWorldRotation(BonePose &bone);
|
float computeWorldRotation(BonePose &bone);
|
||||||
|
|
||||||
virtual Attachment *copy();
|
virtual Attachment *copy() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _x, _y, _rotation;
|
float _x, _y, _rotation;
|
||||||
|
|||||||
@ -56,11 +56,16 @@ namespace spine {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RTTI_DECL \
|
#define RTTI_DECL_NOPARENT \
|
||||||
public: \
|
public: \
|
||||||
static const spine::RTTI rtti; \
|
static const spine::RTTI rtti; \
|
||||||
virtual const spine::RTTI& getRTTI() const;
|
virtual const spine::RTTI& getRTTI() const;
|
||||||
|
|
||||||
|
#define RTTI_DECL \
|
||||||
|
public: \
|
||||||
|
static const spine::RTTI rtti; \
|
||||||
|
virtual const spine::RTTI& getRTTI() const override;
|
||||||
|
|
||||||
#define RTTI_IMPL_NOPARENT(name) \
|
#define RTTI_IMPL_NOPARENT(name) \
|
||||||
const spine::RTTI name::rtti(#name); \
|
const spine::RTTI name::rtti(#name); \
|
||||||
const spine::RTTI& name::getRTTI() const { return rtti; }
|
const spine::RTTI& name::getRTTI() const { return rtti; }
|
||||||
|
|||||||
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class Bone;
|
class Bone;
|
||||||
|
class Slot;
|
||||||
|
|
||||||
/// Attachment that displays a texture region.
|
/// Attachment that displays a texture region.
|
||||||
class SP_API RegionAttachment : public Attachment {
|
class SP_API RegionAttachment : public Attachment {
|
||||||
@ -115,7 +116,7 @@ namespace spine {
|
|||||||
|
|
||||||
Vector<float> &getUVs();
|
Vector<float> &getUVs();
|
||||||
|
|
||||||
virtual Attachment *copy();
|
virtual Attachment *copy() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int BLX;
|
static const int BLX;
|
||||||
|
|||||||
@ -43,7 +43,6 @@ namespace spine {
|
|||||||
class SkeletonJson;
|
class SkeletonJson;
|
||||||
|
|
||||||
class SP_API Sequence : public SpineObject {
|
class SP_API Sequence : public SpineObject {
|
||||||
RTTI_DECL
|
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -31,12 +31,14 @@
|
|||||||
#define Spine_SequenceTimeline_h
|
#define Spine_SequenceTimeline_h
|
||||||
|
|
||||||
#include <spine/Timeline.h>
|
#include <spine/Timeline.h>
|
||||||
|
#include <spine/SlotTimeline.h>
|
||||||
#include <spine/Sequence.h>
|
#include <spine/Sequence.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class Attachment;
|
class Attachment;
|
||||||
|
class HasTextureRegion;
|
||||||
|
|
||||||
class SP_API SequenceTimeline : public Timeline {
|
class SP_API SequenceTimeline : public Timeline, public SlotTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
@ -50,19 +52,14 @@ namespace spine {
|
|||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||||
MixDirection direction);
|
MixDirection direction, bool appliedPose) override;
|
||||||
|
|
||||||
void setFrame(int frame, float time, SequenceMode mode, int index, float delay);
|
void setFrame(int frame, float time, SequenceMode mode, int index, float delay);
|
||||||
|
|
||||||
int getSlotIndex() { return _slotIndex; };
|
Attachment *getAttachment() { return (Attachment*)_attachment; }
|
||||||
|
|
||||||
void setSlotIndex(int inValue) { _slotIndex = inValue; }
|
|
||||||
|
|
||||||
Attachment *getAttachment() { return _attachment; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int _slotIndex;
|
HasTextureRegion *_attachment;
|
||||||
Attachment *_attachment;
|
|
||||||
|
|
||||||
static const int ENTRIES = 3;
|
static const int ENTRIES = 3;
|
||||||
static const int MODE = 1;
|
static const int MODE = 1;
|
||||||
|
|||||||
@ -127,6 +127,8 @@ namespace spine {
|
|||||||
|
|
||||||
friend class PhysicsConstraint;
|
friend class PhysicsConstraint;
|
||||||
|
|
||||||
|
friend class BonePose;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Skeleton(SkeletonData *skeletonData);
|
explicit Skeleton(SkeletonData *skeletonData);
|
||||||
|
|
||||||
@ -290,6 +292,7 @@ namespace spine {
|
|||||||
float _x, _y;
|
float _x, _y;
|
||||||
float _time;
|
float _time;
|
||||||
float _windX, _windY, _gravityX, _gravityY;
|
float _windX, _windY, _gravityX, _gravityY;
|
||||||
|
int _update;
|
||||||
|
|
||||||
void sortIkConstraint(IkConstraint *constraint);
|
void sortIkConstraint(IkConstraint *constraint);
|
||||||
|
|
||||||
|
|||||||
@ -145,7 +145,7 @@ namespace spine {
|
|||||||
getConstraints(); // Ensure constraints array is populated
|
getConstraints(); // Ensure constraints array is populated
|
||||||
for (size_t i = 0, n = _constraints.size(); i < n; i++) {
|
for (size_t i = 0, n = _constraints.size(); i < n; i++) {
|
||||||
ConstraintData *constraint = _constraints[i];
|
ConstraintData *constraint = _constraints[i];
|
||||||
if (constraint->getName().equals(constraintName)) {
|
if (constraint->getName() == constraintName) {
|
||||||
if (constraint->rtti.isExactly(T::rtti)) {
|
if (constraint->rtti.isExactly(T::rtti)) {
|
||||||
return static_cast<T*>(constraint);
|
return static_cast<T*>(constraint);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,12 +37,11 @@
|
|||||||
namespace spine {
|
namespace spine {
|
||||||
class Skeleton;
|
class Skeleton;
|
||||||
class Bone;
|
class Bone;
|
||||||
enum Physics;
|
|
||||||
|
|
||||||
/// Stores the setup pose for a PhysicsConstraint.
|
/// Stores the setup pose for a PhysicsConstraint.
|
||||||
///
|
///
|
||||||
/// See https://esotericsoftware.com/spine-physics-constraints Physics constraints in the Spine User Guide.
|
/// See https://esotericsoftware.com/spine-physics-constraints Physics constraints in the Spine User Guide.
|
||||||
class SP_API Slider : public Constraint<Slider, SliderData, SliderPose> {
|
class SP_API Slider : public ConstraintGeneric<Slider, SliderData, SliderPose> {
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -57,7 +56,9 @@ namespace spine {
|
|||||||
virtual void update(Skeleton& skeleton, Physics physics) override;
|
virtual void update(Skeleton& skeleton, Physics physics) override;
|
||||||
|
|
||||||
/// Called by Skeleton to sort constraints.
|
/// Called by Skeleton to sort constraints.
|
||||||
void sort(Skeleton& skeleton);
|
void sort(Skeleton& skeleton) override;
|
||||||
|
|
||||||
|
bool isSourceActive() override;
|
||||||
|
|
||||||
Bone* getBone();
|
Bone* getBone();
|
||||||
void setBone(Bone* bone);
|
void setBone(Bone* bone);
|
||||||
|
|||||||
@ -49,9 +49,9 @@ namespace spine {
|
|||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
friend class Slider;
|
friend class Slider;
|
||||||
|
|
||||||
public:
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
|
public:
|
||||||
explicit SliderData(const String &name);
|
explicit SliderData(const String &name);
|
||||||
|
|
||||||
/// Creates a slider instance.
|
/// Creates a slider instance.
|
||||||
|
|||||||
@ -36,7 +36,6 @@
|
|||||||
namespace spine {
|
namespace spine {
|
||||||
/// Stores a pose for a slider.
|
/// Stores a pose for a slider.
|
||||||
class SP_API SliderPose : public Pose<SliderPose> {
|
class SP_API SliderPose : public Pose<SliderPose> {
|
||||||
RTTI_DECL
|
|
||||||
private:
|
private:
|
||||||
float _time, _mix;
|
float _time, _mix;
|
||||||
|
|
||||||
|
|||||||
@ -49,16 +49,12 @@ namespace spine {
|
|||||||
|
|
||||||
virtual ~SlotCurveTimeline();
|
virtual ~SlotCurveTimeline();
|
||||||
|
|
||||||
virtual int getSlotIndex() override;
|
|
||||||
|
|
||||||
virtual void apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
virtual void apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction, bool appliedPose) override;
|
MixBlend blend, MixDirection direction, bool appliedPose) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Applies the timeline to the slot pose.
|
/// Applies the timeline to the slot pose.
|
||||||
virtual void apply(Slot& slot, SlotPose& pose, float time, float alpha, MixBlend blend) = 0;
|
virtual void apply(Slot& slot, SlotPose& pose, float time, float alpha, MixBlend blend) = 0;
|
||||||
|
|
||||||
int _slotIndex;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,8 +41,6 @@ namespace spine {
|
|||||||
|
|
||||||
/// Stores the setup pose for a Slot.
|
/// Stores the setup pose for a Slot.
|
||||||
class SP_API SlotData : public PosedData<SlotPose> {
|
class SP_API SlotData : public PosedData<SlotPose> {
|
||||||
RTTI_DECL
|
|
||||||
|
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
friend class PathConstraint;
|
friend class PathConstraint;
|
||||||
|
|||||||
@ -43,14 +43,13 @@ namespace spine {
|
|||||||
class SP_API SlotPose : public Pose<SlotPose> {
|
class SP_API SlotPose : public Pose<SlotPose> {
|
||||||
friend class Slot;
|
friend class Slot;
|
||||||
friend class SlotCurveTimeline;
|
friend class SlotCurveTimeline;
|
||||||
|
friend class DeformTimeline;
|
||||||
friend class RGBATimeline;
|
friend class RGBATimeline;
|
||||||
friend class RGBTimeline;
|
friend class RGBTimeline;
|
||||||
friend class AlphaTimeline;
|
friend class AlphaTimeline;
|
||||||
friend class RGBA2Timeline;
|
friend class RGBA2Timeline;
|
||||||
friend class RGB2Timeline;
|
friend class RGB2Timeline;
|
||||||
|
|
||||||
RTTI_DECL
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Color _color;
|
Color _color;
|
||||||
Color _darkColor;
|
Color _darkColor;
|
||||||
|
|||||||
@ -37,10 +37,16 @@ namespace spine {
|
|||||||
|
|
||||||
/// An interface for timelines which change the property of a slot.
|
/// An interface for timelines which change the property of a slot.
|
||||||
class SP_API SlotTimeline {
|
class SP_API SlotTimeline {
|
||||||
RTTI_DECL
|
RTTI_DECL_NOPARENT
|
||||||
|
|
||||||
|
friend class AlphaTimeline;
|
||||||
|
friend class AttachmentTimeline;
|
||||||
|
friend class SequenceTimeline;
|
||||||
|
friend class SlotCurveTimeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~SlotTimeline() {}
|
SlotTimeline(int slotIndex);
|
||||||
|
virtual ~SlotTimeline();
|
||||||
|
|
||||||
/// The index of the slot in Skeleton::getSlots() that will be changed when this timeline is applied.
|
/// The index of the slot in Skeleton::getSlots() that will be changed when this timeline is applied.
|
||||||
virtual int getSlotIndex();
|
virtual int getSlotIndex();
|
||||||
|
|||||||
@ -43,7 +43,7 @@ namespace spine {
|
|||||||
class Event;
|
class Event;
|
||||||
|
|
||||||
class SP_API Timeline : public SpineObject {
|
class SP_API Timeline : public SpineObject {
|
||||||
RTTI_DECL
|
RTTI_DECL_NOPARENT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Timeline(size_t frameCount, size_t frameEntries);
|
Timeline(size_t frameCount, size_t frameEntries);
|
||||||
|
|||||||
@ -40,7 +40,7 @@ namespace spine {
|
|||||||
class Bone;
|
class Bone;
|
||||||
class BonePose;
|
class BonePose;
|
||||||
|
|
||||||
class SP_API TransformConstraint : public Constraint<TransformConstraint, TransformConstraintData, TransformConstraintPose> {
|
class SP_API TransformConstraint : public ConstraintGeneric<TransformConstraint, TransformConstraintData, TransformConstraintPose> {
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
friend class TransformConstraintTimeline;
|
friend class TransformConstraintTimeline;
|
||||||
|
|
||||||
@ -52,11 +52,11 @@ namespace spine {
|
|||||||
TransformConstraint copy(Skeleton& skeleton);
|
TransformConstraint copy(Skeleton& skeleton);
|
||||||
|
|
||||||
/// Applies the constraint to the constrained bones.
|
/// Applies the constraint to the constrained bones.
|
||||||
void update(Skeleton& skeleton, Physics physics);
|
void update(Skeleton& skeleton, Physics physics) override;
|
||||||
|
|
||||||
void sort(Skeleton& skeleton);
|
void sort(Skeleton& skeleton) override;
|
||||||
|
|
||||||
bool isSourceActive();
|
bool isSourceActive() override;
|
||||||
|
|
||||||
/// The bones that will be modified by this transform constraint.
|
/// The bones that will be modified by this transform constraint.
|
||||||
Vector<BonePose*>& getBones();
|
Vector<BonePose*>& getBones();
|
||||||
|
|||||||
@ -151,6 +151,7 @@ namespace spine {
|
|||||||
/// See https://esotericsoftware.com/spine-transform-constraints Transform constraints in the Spine User Guide.
|
/// See https://esotericsoftware.com/spine-transform-constraints Transform constraints in the Spine User Guide.
|
||||||
class SP_API TransformConstraintData : public ConstraintDataGeneric<TransformConstraint, TransformConstraintPose> {
|
class SP_API TransformConstraintData : public ConstraintDataGeneric<TransformConstraint, TransformConstraintPose> {
|
||||||
public:
|
public:
|
||||||
|
RTTI_DECL
|
||||||
static const int ROTATION = 0, X = 1, Y = 2, SCALEX = 3, SCALEY = 4, SHEARY = 5;
|
static const int ROTATION = 0, X = 1, Y = 2, SCALEX = 3, SCALEY = 4, SHEARY = 5;
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
@ -159,8 +160,6 @@ namespace spine {
|
|||||||
friend class TransformConstraintTimeline;
|
friend class TransformConstraintTimeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RTTI_DECL
|
|
||||||
|
|
||||||
explicit TransformConstraintData(const String &name);
|
explicit TransformConstraintData(const String &name);
|
||||||
~TransformConstraintData();
|
~TransformConstraintData();
|
||||||
|
|
||||||
|
|||||||
@ -36,8 +36,6 @@
|
|||||||
namespace spine {
|
namespace spine {
|
||||||
/// Stores a pose for a transform constraint.
|
/// Stores a pose for a transform constraint.
|
||||||
class SP_API TransformConstraintPose : public Pose<TransformConstraintPose> {
|
class SP_API TransformConstraintPose : public Pose<TransformConstraintPose> {
|
||||||
RTTI_DECL
|
|
||||||
|
|
||||||
friend class FromProperty;
|
friend class FromProperty;
|
||||||
friend class ToProperty;
|
friend class ToProperty;
|
||||||
friend class FromRotate;
|
friend class FromRotate;
|
||||||
|
|||||||
@ -40,7 +40,7 @@ namespace spine {
|
|||||||
|
|
||||||
/// The interface for items updated by Skeleton::updateWorldTransform().
|
/// The interface for items updated by Skeleton::updateWorldTransform().
|
||||||
class SP_API Update : public SpineObject {
|
class SP_API Update : public SpineObject {
|
||||||
RTTI_DECL
|
RTTI_DECL_NOPARENT
|
||||||
public:
|
public:
|
||||||
Update();
|
Update();
|
||||||
virtual ~Update();
|
virtual ~Update();
|
||||||
|
|||||||
@ -38,75 +38,72 @@
|
|||||||
|
|
||||||
#include <spine/Atlas.h>
|
#include <spine/Atlas.h>
|
||||||
|
|
||||||
namespace spine {
|
using namespace spine;
|
||||||
RTTI_IMPL(AtlasAttachmentLoader, AttachmentLoader)
|
|
||||||
|
|
||||||
AtlasAttachmentLoader::AtlasAttachmentLoader(Atlas *atlas) : AttachmentLoader(), _atlas(atlas) {
|
AtlasAttachmentLoader::AtlasAttachmentLoader(Atlas *atlas) : AttachmentLoader(), _atlas(atlas) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool loadSequence(Atlas *atlas, const String &basePath, Sequence *sequence) {
|
||||||
|
Vector<TextureRegion *> ®ions = sequence->getRegions();
|
||||||
|
for (int i = 0, n = (int) regions.size(); i < n; i++) {
|
||||||
|
String path = sequence->getPath(basePath, i);
|
||||||
|
regions[i] = atlas->findRegion(path);
|
||||||
|
if (!regions[i]) return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool loadSequence(Atlas *atlas, const String &basePath, Sequence *sequence) {
|
RegionAttachment *AtlasAttachmentLoader::newRegionAttachment(Skin &skin, const String &name, const String &path, Sequence *sequence) {
|
||||||
Vector<TextureRegion *> ®ions = sequence->getRegions();
|
SP_UNUSED(skin);
|
||||||
for (int i = 0, n = (int) regions.size(); i < n; i++) {
|
RegionAttachment *attachment = new (__FILE__, __LINE__) RegionAttachment(name);
|
||||||
String path = sequence->getPath(basePath, i);
|
if (sequence) {
|
||||||
regions[i] = atlas->findRegion(path);
|
if (!loadSequence(_atlas, path, sequence)) return NULL;
|
||||||
if (!regions[i]) return false;
|
} else {
|
||||||
}
|
AtlasRegion *region = findRegion(path);
|
||||||
return true;
|
if (!region) return NULL;
|
||||||
|
attachment->setRegion(region);
|
||||||
}
|
}
|
||||||
|
return attachment;
|
||||||
|
}
|
||||||
|
|
||||||
RegionAttachment *AtlasAttachmentLoader::newRegionAttachment(Skin &skin, const String &name, const String &path, Sequence *sequence) {
|
MeshAttachment *AtlasAttachmentLoader::newMeshAttachment(Skin &skin, const String &name, const String &path, Sequence *sequence) {
|
||||||
SP_UNUSED(skin);
|
SP_UNUSED(skin);
|
||||||
RegionAttachment *attachment = new (__FILE__, __LINE__) RegionAttachment(name);
|
MeshAttachment *attachment = new (__FILE__, __LINE__) MeshAttachment(name);
|
||||||
if (sequence) {
|
|
||||||
if (!loadSequence(_atlas, path, sequence)) return NULL;
|
if (sequence) {
|
||||||
} else {
|
if (!loadSequence(_atlas, path, sequence)) return NULL;
|
||||||
AtlasRegion *region = findRegion(path);
|
} else {
|
||||||
if (!region) return NULL;
|
AtlasRegion *region = findRegion(path);
|
||||||
attachment->setRegion(region);
|
if (!region) return NULL;
|
||||||
}
|
attachment->setRegion(region);
|
||||||
return attachment;
|
|
||||||
}
|
}
|
||||||
|
return attachment;
|
||||||
|
}
|
||||||
|
|
||||||
MeshAttachment *AtlasAttachmentLoader::newMeshAttachment(Skin &skin, const String &name, const String &path, Sequence *sequence) {
|
BoundingBoxAttachment *AtlasAttachmentLoader::newBoundingBoxAttachment(Skin &skin, const String &name) {
|
||||||
SP_UNUSED(skin);
|
SP_UNUSED(skin);
|
||||||
MeshAttachment *attachment = new (__FILE__, __LINE__) MeshAttachment(name);
|
return new (__FILE__, __LINE__) BoundingBoxAttachment(name);
|
||||||
|
}
|
||||||
|
|
||||||
if (sequence) {
|
PathAttachment *AtlasAttachmentLoader::newPathAttachment(Skin &skin, const String &name) {
|
||||||
if (!loadSequence(_atlas, path, sequence)) return NULL;
|
SP_UNUSED(skin);
|
||||||
} else {
|
return new (__FILE__, __LINE__) PathAttachment(name);
|
||||||
AtlasRegion *region = findRegion(path);
|
}
|
||||||
if (!region) return NULL;
|
|
||||||
attachment->setRegion(region);
|
|
||||||
}
|
|
||||||
return attachment;
|
|
||||||
}
|
|
||||||
|
|
||||||
BoundingBoxAttachment *AtlasAttachmentLoader::newBoundingBoxAttachment(Skin &skin, const String &name) {
|
PointAttachment *AtlasAttachmentLoader::newPointAttachment(Skin &skin, const String &name) {
|
||||||
SP_UNUSED(skin);
|
SP_UNUSED(skin);
|
||||||
return new (__FILE__, __LINE__) BoundingBoxAttachment(name);
|
return new (__FILE__, __LINE__) PointAttachment(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
PathAttachment *AtlasAttachmentLoader::newPathAttachment(Skin &skin, const String &name) {
|
ClippingAttachment *AtlasAttachmentLoader::newClippingAttachment(Skin &skin, const String &name) {
|
||||||
SP_UNUSED(skin);
|
SP_UNUSED(skin);
|
||||||
return new (__FILE__, __LINE__) PathAttachment(name);
|
return new (__FILE__, __LINE__) ClippingAttachment(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
PointAttachment *AtlasAttachmentLoader::newPointAttachment(Skin &skin, const String &name) {
|
void AtlasAttachmentLoader::configureAttachment(Attachment *attachment) {
|
||||||
SP_UNUSED(skin);
|
SP_UNUSED(attachment);
|
||||||
return new (__FILE__, __LINE__) PointAttachment(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ClippingAttachment *AtlasAttachmentLoader::newClippingAttachment(Skin &skin, const String &name) {
|
AtlasRegion *AtlasAttachmentLoader::findRegion(const String &name) {
|
||||||
SP_UNUSED(skin);
|
return _atlas->findRegion(name);
|
||||||
return new (__FILE__, __LINE__) ClippingAttachment(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void AtlasAttachmentLoader::configureAttachment(Attachment *attachment) {
|
|
||||||
SP_UNUSED(attachment);
|
|
||||||
}
|
|
||||||
|
|
||||||
AtlasRegion *AtlasAttachmentLoader::findRegion(const String &name) {
|
|
||||||
return _atlas->findRegion(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
}// namespace spine
|
|
||||||
|
|||||||
@ -39,8 +39,6 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(AttachmentLoader)
|
|
||||||
|
|
||||||
AttachmentLoader::AttachmentLoader() {
|
AttachmentLoader::AttachmentLoader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,13 +37,14 @@
|
|||||||
#include <spine/Property.h>
|
#include <spine/Property.h>
|
||||||
#include <spine/Slot.h>
|
#include <spine/Slot.h>
|
||||||
#include <spine/SlotData.h>
|
#include <spine/SlotData.h>
|
||||||
|
#include <spine/SlotPose.h>
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL(AttachmentTimeline, Timeline)
|
RTTI_IMPL(AttachmentTimeline, Timeline)
|
||||||
|
|
||||||
AttachmentTimeline::AttachmentTimeline(size_t frameCount, int slotIndex) : Timeline(frameCount, 1),
|
AttachmentTimeline::AttachmentTimeline(size_t frameCount, int slotIndex) : Timeline(frameCount, 1),
|
||||||
_slotIndex(slotIndex) {
|
SlotTimeline(slotIndex) {
|
||||||
PropertyId ids[] = {((PropertyId) Property_Attachment << 32) | slotIndex};
|
PropertyId ids[] = {((PropertyId) Property_Attachment << 32) | slotIndex};
|
||||||
setPropertyIds(ids, 1);
|
setPropertyIds(ids, 1);
|
||||||
|
|
||||||
@ -55,39 +56,27 @@ AttachmentTimeline::AttachmentTimeline(size_t frameCount, int slotIndex) : Timel
|
|||||||
|
|
||||||
AttachmentTimeline::~AttachmentTimeline() {}
|
AttachmentTimeline::~AttachmentTimeline() {}
|
||||||
|
|
||||||
void AttachmentTimeline::setAttachment(Skeleton &skeleton, Slot &slot, String *attachmentName) {
|
void AttachmentTimeline::setAttachment(Skeleton &skeleton, SlotPose &pose, String *attachmentName) {
|
||||||
slot.setAttachment(attachmentName == NULL || attachmentName->isEmpty() ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName));
|
pose.setAttachment(attachmentName == NULL || attachmentName->isEmpty() ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachmentTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void AttachmentTimeline::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(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(alpha);
|
SP_UNUSED(alpha);
|
||||||
|
|
||||||
Slot *slot = skeleton._slots[_slotIndex];
|
Slot *slot = skeleton._slots[_slotIndex];
|
||||||
if (!slot->_bone._active) return;
|
if (!slot->_bone._active) return;
|
||||||
|
SlotPose &pose = appliedPose ? *slot->_applied : slot->_pose;
|
||||||
|
|
||||||
if (direction == MixDirection_Out) {
|
if (direction == MixDirection_Out) {
|
||||||
if (blend == MixBlend_Setup) setAttachment(skeleton, *slot, &slot->_data._attachmentName);
|
if (blend == MixBlend_Setup) setAttachment(skeleton, pose, &slot->_data._attachmentName);
|
||||||
return;
|
} else if (time < _frames[0]) {
|
||||||
|
if (blend == MixBlend_Setup || blend == MixBlend_First) setAttachment(skeleton, pose, &slot->_data._attachmentName);
|
||||||
|
} else {
|
||||||
|
setAttachment(skeleton, pose, &_attachmentNames[Animation::search(_frames, time)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time < _frames[0]) {
|
|
||||||
// Time is before first frame.
|
|
||||||
if (blend == MixBlend_Setup || blend == MixBlend_First) {
|
|
||||||
setAttachment(skeleton, *slot, &slot->_data._attachmentName);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (time < _frames[0]) {
|
|
||||||
if (blend == MixBlend_Setup || blend == MixBlend_First)
|
|
||||||
setAttachment(skeleton, *slot, &slot->_data._attachmentName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setAttachment(skeleton, *slot, &_attachmentNames[Animation::search(_frames, time)]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachmentTimeline::setFrame(int frame, float time, const String &attachmentName) {
|
void AttachmentTimeline::setFrame(int frame, float time, const String &attachmentName) {
|
||||||
|
|||||||
@ -33,8 +33,6 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(BoneData)
|
|
||||||
|
|
||||||
BoneData::BoneData(int index, const String &name, BoneData *parent) : PosedData<BoneLocal>(name),
|
BoneData::BoneData(int index, const String &name, BoneData *parent) : PosedData<BoneLocal>(name),
|
||||||
_index(index),
|
_index(index),
|
||||||
_parent(parent),
|
_parent(parent),
|
||||||
|
|||||||
@ -31,8 +31,6 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(BoneLocal)
|
|
||||||
|
|
||||||
BoneLocal::BoneLocal() : _x(0), _y(0), _rotation(0), _scaleX(1), _scaleY(1), _shearX(0), _shearY(0), _inherit(Inherit_Normal) {
|
BoneLocal::BoneLocal() : _x(0), _y(0), _rotation(0), _scaleX(1), _scaleY(1), _shearX(0), _shearY(0), _inherit(Inherit_Normal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,8 +36,6 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL(BonePose, BoneLocal)
|
|
||||||
|
|
||||||
BonePose::BonePose() : BoneLocal(), _bone(nullptr), _a(0), _b(0), _worldX(0), _c(0), _d(0), _worldY(0), _world(0), _local(0) {
|
BonePose::BonePose() : BoneLocal(), _bone(nullptr), _a(0), _b(0), _worldX(0), _c(0), _d(0), _worldY(0), _world(0), _local(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,14 +43,14 @@ BonePose::~BonePose() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BonePose::update(Skeleton& skeleton, Physics physics) {
|
void BonePose::update(Skeleton& skeleton, Physics physics) {
|
||||||
if (_world != skeleton.getUpdate()) updateWorldTransform(skeleton);
|
if (_world != skeleton._update) updateWorldTransform(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BonePose::updateWorldTransform(Skeleton& skeleton) {
|
void BonePose::updateWorldTransform(Skeleton& skeleton) {
|
||||||
if (_local == skeleton.getUpdate())
|
if (_local == skeleton._update)
|
||||||
updateLocalTransform(skeleton);
|
updateLocalTransform(skeleton);
|
||||||
else
|
else
|
||||||
_world = skeleton.getUpdate();
|
_world = skeleton._update;
|
||||||
|
|
||||||
if (_bone->getParent() == nullptr) { // Root bone.
|
if (_bone->getParent() == nullptr) { // Root bone.
|
||||||
float sx = skeleton.getScaleX(), sy = skeleton.getScaleY();
|
float sx = skeleton.getScaleX(), sy = skeleton.getScaleY();
|
||||||
@ -67,7 +65,7 @@ void BonePose::updateWorldTransform(Skeleton& skeleton) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BonePose& parent = _bone->getParent()->getApplied();
|
BonePose& parent = _bone->getParent()->getAppliedPose();
|
||||||
float pa = parent._a, pb = parent._b, pc = parent._c, pd = parent._d;
|
float pa = parent._a, pb = parent._b, pc = parent._c, pd = parent._d;
|
||||||
_worldX = pa * _x + pb * _y + parent._worldX;
|
_worldX = pa * _x + pb * _y + parent._worldX;
|
||||||
_worldY = pc * _x + pd * _y + parent._worldY;
|
_worldY = pc * _x + pd * _y + parent._worldY;
|
||||||
@ -158,7 +156,7 @@ void BonePose::updateWorldTransform(Skeleton& skeleton) {
|
|||||||
|
|
||||||
void BonePose::updateLocalTransform(Skeleton& skeleton) {
|
void BonePose::updateLocalTransform(Skeleton& skeleton) {
|
||||||
_local = 0;
|
_local = 0;
|
||||||
_world = skeleton.getUpdate();
|
_world = skeleton._update;
|
||||||
|
|
||||||
if (_bone->getParent() == nullptr) {
|
if (_bone->getParent() == nullptr) {
|
||||||
_x = _worldX - skeleton.getX();
|
_x = _worldX - skeleton.getX();
|
||||||
@ -172,7 +170,7 @@ void BonePose::updateLocalTransform(Skeleton& skeleton) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BonePose& parent = _bone->getParent()->getApplied();
|
BonePose& parent = _bone->getParent()->getAppliedPose();
|
||||||
float pa = parent._a, pb = parent._b, pc = parent._c, pd = parent._d;
|
float pa = parent._a, pb = parent._b, pc = parent._c, pd = parent._d;
|
||||||
float pid = 1 / (pa * pd - pb * pc);
|
float pid = 1 / (pa * pd - pb * pc);
|
||||||
float ia = pd * pid, ib = pb * pid, ic = pc * pid, id = pa * pid;
|
float ia = pd * pid, ib = pb * pid, ic = pc * pid, id = pa * pid;
|
||||||
@ -243,13 +241,13 @@ void BonePose::updateLocalTransform(Skeleton& skeleton) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BonePose::validateLocalTransform(Skeleton& skeleton) {
|
void BonePose::validateLocalTransform(Skeleton& skeleton) {
|
||||||
if (_local == skeleton.getUpdate()) updateLocalTransform(skeleton);
|
if (_local == skeleton._update) updateLocalTransform(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BonePose::modifyLocal(Skeleton& skeleton) {
|
void BonePose::modifyLocal(Skeleton& skeleton) {
|
||||||
if (_local == skeleton.getUpdate()) updateLocalTransform(skeleton);
|
if (_local == skeleton._update) updateLocalTransform(skeleton);
|
||||||
_world = 0;
|
_world = 0;
|
||||||
resetWorld(skeleton.getUpdate());
|
resetWorld(skeleton._update);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BonePose::modifyWorld(int update) {
|
void BonePose::modifyWorld(int update) {
|
||||||
@ -261,7 +259,7 @@ void BonePose::modifyWorld(int update) {
|
|||||||
void BonePose::resetWorld(int update) {
|
void BonePose::resetWorld(int update) {
|
||||||
Vector<Bone*>& children = _bone->getChildren();
|
Vector<Bone*>& children = _bone->getChildren();
|
||||||
for (size_t i = 0, n = children.size(); i < n; i++) {
|
for (size_t i = 0, n = children.size(); i < n; i++) {
|
||||||
BonePose& child = children[i]->getApplied();
|
BonePose& child = children[i]->getAppliedPose();
|
||||||
if (child._world == update) {
|
if (child._world == update) {
|
||||||
child._world = 0;
|
child._world = 0;
|
||||||
child._local = 0;
|
child._local = 0;
|
||||||
@ -352,7 +350,7 @@ void BonePose::worldToParent(float worldX, float worldY, float& outParentX, floa
|
|||||||
outParentX = worldX;
|
outParentX = worldX;
|
||||||
outParentY = worldY;
|
outParentY = worldY;
|
||||||
} else {
|
} else {
|
||||||
_bone->getParent()->getApplied().worldToLocal(worldX, worldY, outParentX, outParentY);
|
_bone->getParent()->getAppliedPose().worldToLocal(worldX, worldY, outParentX, outParentY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,7 +359,7 @@ void BonePose::parentToWorld(float parentX, float parentY, float& outWorldX, flo
|
|||||||
outWorldX = parentX;
|
outWorldX = parentX;
|
||||||
outWorldY = parentY;
|
outWorldY = parentY;
|
||||||
} else {
|
} else {
|
||||||
_bone->getParent()->getApplied().localToWorld(parentX, parentY, outWorldX, outWorldY);
|
_bone->getParent()->getAppliedPose().localToWorld(parentX, parentY, outWorldX, outWorldY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,10 +52,6 @@ RGBATimeline::RGBATimeline(size_t frameCount, size_t bezierCount, int slotIndex)
|
|||||||
RGBATimeline::~RGBATimeline() {
|
RGBATimeline::~RGBATimeline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int RGBATimeline::getFrameEntries() {
|
|
||||||
return ENTRIES;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RGBATimeline::setFrame(int frame, float time, float r, float g, float b, float a) {
|
void RGBATimeline::setFrame(int frame, float time, float r, float g, float b, float a) {
|
||||||
frame *= ENTRIES;
|
frame *= ENTRIES;
|
||||||
_frames[frame] = time;
|
_frames[frame] = time;
|
||||||
@ -68,7 +64,7 @@ void RGBATimeline::setFrame(int frame, float time, float r, float g, float b, fl
|
|||||||
void RGBATimeline::apply(Slot& slot, SlotPose& pose, float time, float alpha, MixBlend blend) {
|
void RGBATimeline::apply(Slot& slot, SlotPose& pose, float time, float alpha, MixBlend blend) {
|
||||||
Color& color = pose._color;
|
Color& color = pose._color;
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
Color& setup = slot._data._setup->_color;
|
Color& setup = slot._data._setup._color;
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
color.set(setup);
|
color.set(setup);
|
||||||
@ -118,7 +114,7 @@ void RGBATimeline::apply(Slot& slot, SlotPose& pose, float time, float alpha, Mi
|
|||||||
if (alpha == 1)
|
if (alpha == 1)
|
||||||
color.set(r, g, b, a);
|
color.set(r, g, b, a);
|
||||||
else {
|
else {
|
||||||
if (blend == MixBlend_Setup) color.set(slot._data._setup->_color);
|
if (blend == MixBlend_Setup) color.set(slot._data._setup._color);
|
||||||
color.add((r - color.r) * alpha, (g - color.g) * alpha,
|
color.add((r - color.r) * alpha, (g - color.g) * alpha,
|
||||||
(b - color.b) * alpha, (a - color.a) * alpha);
|
(b - color.b) * alpha, (a - color.a) * alpha);
|
||||||
}
|
}
|
||||||
@ -135,10 +131,6 @@ RGBTimeline::RGBTimeline(size_t frameCount, size_t bezierCount, int slotIndex)
|
|||||||
RGBTimeline::~RGBTimeline() {
|
RGBTimeline::~RGBTimeline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int RGBTimeline::getFrameEntries() {
|
|
||||||
return ENTRIES;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RGBTimeline::setFrame(int frame, float time, float r, float g, float b) {
|
void RGBTimeline::setFrame(int frame, float time, float r, float g, float b) {
|
||||||
frame <<= 2;
|
frame <<= 2;
|
||||||
_frames[frame] = time;
|
_frames[frame] = time;
|
||||||
@ -150,7 +142,7 @@ void RGBTimeline::setFrame(int frame, float time, float r, float g, float b) {
|
|||||||
void RGBTimeline::apply(Slot& slot, SlotPose& pose, float time, float alpha, MixBlend blend) {
|
void RGBTimeline::apply(Slot& slot, SlotPose& pose, float time, float alpha, MixBlend blend) {
|
||||||
Color& color = pose._color;
|
Color& color = pose._color;
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
Color& setup = slot._data._setup->_color;
|
Color& setup = slot._data._setup._color;
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
color.r = setup.r;
|
color.r = setup.r;
|
||||||
@ -202,7 +194,7 @@ void RGBTimeline::apply(Slot& slot, SlotPose& pose, float time, float alpha, Mix
|
|||||||
color.b = b;
|
color.b = b;
|
||||||
} else {
|
} else {
|
||||||
if (blend == MixBlend_Setup) {
|
if (blend == MixBlend_Setup) {
|
||||||
Color& setup = slot._data._setup->_color;
|
Color& setup = slot._data._setup._color;
|
||||||
color.r = setup.r;
|
color.r = setup.r;
|
||||||
color.g = setup.g;
|
color.g = setup.g;
|
||||||
color.b = setup.b;
|
color.b = setup.b;
|
||||||
@ -213,10 +205,10 @@ void RGBTimeline::apply(Slot& slot, SlotPose& pose, float time, float alpha, Mix
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RTTI_IMPL(AlphaTimeline, CurveTimeline1)
|
RTTI_IMPL(AlphaTimeline, SlotTimeline)
|
||||||
|
|
||||||
AlphaTimeline::AlphaTimeline(size_t frameCount, size_t bezierCount, int slotIndex)
|
AlphaTimeline::AlphaTimeline(size_t frameCount, size_t bezierCount, int slotIndex)
|
||||||
: CurveTimeline1(frameCount, bezierCount), _slotIndex(slotIndex) {
|
: CurveTimeline1(frameCount, bezierCount), SlotTimeline(slotIndex) {
|
||||||
PropertyId ids[] = {((PropertyId) Property_Alpha << 32) | slotIndex};
|
PropertyId ids[] = {((PropertyId) Property_Alpha << 32) | slotIndex};
|
||||||
setPropertyIds(ids, 1);
|
setPropertyIds(ids, 1);
|
||||||
}
|
}
|
||||||
@ -233,9 +225,9 @@ void AlphaTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
Slot *slot = skeleton._slots[_slotIndex];
|
Slot *slot = skeleton._slots[_slotIndex];
|
||||||
if (!slot->_bone._active) return;
|
if (!slot->_bone._active) return;
|
||||||
|
|
||||||
Color& color = (appliedPose ? slot->_applied : slot->_pose)._color;
|
Color& color = (appliedPose ? *slot->_applied : slot->_pose)._color;
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
Color& setup = slot->_data._setup->_color;
|
Color& setup = slot->_data._setup._color;
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
color.a = setup.a;
|
color.a = setup.a;
|
||||||
@ -252,15 +244,11 @@ void AlphaTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
if (alpha == 1)
|
if (alpha == 1)
|
||||||
color.a = a;
|
color.a = a;
|
||||||
else {
|
else {
|
||||||
if (blend == MixBlend_Setup) color.a = slot->_data._setup->_color.a;
|
if (blend == MixBlend_Setup) color.a = slot->_data._setup._color.a;
|
||||||
color.a += (a - color.a) * alpha;
|
color.a += (a - color.a) * alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int AlphaTimeline::getSlotIndex() {
|
|
||||||
return _slotIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
RTTI_IMPL(RGBA2Timeline, SlotCurveTimeline)
|
RTTI_IMPL(RGBA2Timeline, SlotCurveTimeline)
|
||||||
|
|
||||||
RGBA2Timeline::RGBA2Timeline(size_t frameCount, size_t bezierCount, int slotIndex)
|
RGBA2Timeline::RGBA2Timeline(size_t frameCount, size_t bezierCount, int slotIndex)
|
||||||
@ -274,10 +262,6 @@ RGBA2Timeline::RGBA2Timeline(size_t frameCount, size_t bezierCount, int slotInde
|
|||||||
RGBA2Timeline::~RGBA2Timeline() {
|
RGBA2Timeline::~RGBA2Timeline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int RGBA2Timeline::getFrameEntries() {
|
|
||||||
return ENTRIES;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RGBA2Timeline::setFrame(int frame, float time, float r, float g, float b, float a, float r2, float g2, float b2) {
|
void RGBA2Timeline::setFrame(int frame, float time, float r, float g, float b, float a, float r2, float g2, float b2) {
|
||||||
frame <<= 3;
|
frame <<= 3;
|
||||||
_frames[frame] = time;
|
_frames[frame] = time;
|
||||||
@ -294,7 +278,7 @@ void RGBA2Timeline::apply(Slot& slot, SlotPose& pose, float time, float alpha, M
|
|||||||
Color& light = pose._color;
|
Color& light = pose._color;
|
||||||
Color& dark = pose._darkColor;
|
Color& dark = pose._darkColor;
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
SlotPose& setup = *slot._data._setup;
|
SlotPose& setup = slot._data._setup;
|
||||||
Color& setupLight = setup._color;
|
Color& setupLight = setup._color;
|
||||||
Color& setupDark = setup._darkColor;
|
Color& setupDark = setup._darkColor;
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
@ -368,7 +352,7 @@ void RGBA2Timeline::apply(Slot& slot, SlotPose& pose, float time, float alpha, M
|
|||||||
dark.b = b2;
|
dark.b = b2;
|
||||||
} else {
|
} else {
|
||||||
if (blend == MixBlend_Setup) {
|
if (blend == MixBlend_Setup) {
|
||||||
SlotPose& setup = *slot._data._setup;
|
SlotPose& setup = slot._data._setup;
|
||||||
light.set(setup._color);
|
light.set(setup._color);
|
||||||
Color& setupDark = setup._darkColor;
|
Color& setupDark = setup._darkColor;
|
||||||
dark.r = setupDark.r;
|
dark.r = setupDark.r;
|
||||||
@ -395,10 +379,6 @@ RGB2Timeline::RGB2Timeline(size_t frameCount, size_t bezierCount, int slotIndex)
|
|||||||
RGB2Timeline::~RGB2Timeline() {
|
RGB2Timeline::~RGB2Timeline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int RGB2Timeline::getFrameEntries() {
|
|
||||||
return ENTRIES;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RGB2Timeline::setFrame(int frame, float time, float r, float g, float b, float r2, float g2, float b2) {
|
void RGB2Timeline::setFrame(int frame, float time, float r, float g, float b, float r2, float g2, float b2) {
|
||||||
frame *= ENTRIES;
|
frame *= ENTRIES;
|
||||||
_frames[frame] = time;
|
_frames[frame] = time;
|
||||||
@ -414,7 +394,7 @@ void RGB2Timeline::apply(Slot& slot, SlotPose& pose, float time, float alpha, Mi
|
|||||||
Color& light = pose._color;
|
Color& light = pose._color;
|
||||||
Color& dark = pose._darkColor;
|
Color& dark = pose._darkColor;
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
SlotPose& setup = *slot._data._setup;
|
SlotPose& setup = slot._data._setup;
|
||||||
Color& setupLight = setup._color;
|
Color& setupLight = setup._color;
|
||||||
Color& setupDark = setup._darkColor;
|
Color& setupDark = setup._darkColor;
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
@ -489,7 +469,7 @@ void RGB2Timeline::apply(Slot& slot, SlotPose& pose, float time, float alpha, Mi
|
|||||||
dark.b = b2;
|
dark.b = b2;
|
||||||
} else {
|
} else {
|
||||||
if (blend == MixBlend_Setup) {
|
if (blend == MixBlend_Setup) {
|
||||||
SlotPose& setup = *slot._data._setup;
|
SlotPose& setup = slot._data._setup;
|
||||||
light.r = setup._color.r;
|
light.r = setup._color.r;
|
||||||
light.g = setup._color.g;
|
light.g = setup._color.g;
|
||||||
light.b = setup._color.b;
|
light.b = setup._color.b;
|
||||||
|
|||||||
38
spine-cpp/spine-cpp/src/spine/Constraint.cpp
Normal file
38
spine-cpp/spine-cpp/src/spine/Constraint.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Spine Runtimes License Agreement
|
||||||
|
* Last updated April 5, 2025. Replaces all prior versions.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2025, Esoteric Software LLC
|
||||||
|
*
|
||||||
|
* Integration of the Spine Runtimes into software or otherwise creating
|
||||||
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||||
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||||
|
* http://esotericsoftware.com/spine-editor-license
|
||||||
|
*
|
||||||
|
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||||
|
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||||
|
* "Products"), provided that each user of the Products must obtain their own
|
||||||
|
* Spine Editor license and redistribution of the Products in any form must
|
||||||
|
* include this license and copyright notice.
|
||||||
|
*
|
||||||
|
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||||
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <spine/Constraint.h>
|
||||||
|
|
||||||
|
using namespace spine;
|
||||||
|
|
||||||
|
Constraint::Constraint() {
|
||||||
|
}
|
||||||
|
|
||||||
|
Constraint::~Constraint() {
|
||||||
|
}
|
||||||
@ -104,10 +104,6 @@ CurveTimeline1::CurveTimeline1(size_t frameCount, size_t bezierCount) : CurveTim
|
|||||||
CurveTimeline1::~CurveTimeline1() {
|
CurveTimeline1::~CurveTimeline1() {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CurveTimeline1::getFrameEntries() {
|
|
||||||
return ENTRIES;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveTimeline1::setFrame(size_t frame, float time, float value) {
|
void CurveTimeline1::setFrame(size_t frame, float time, float value) {
|
||||||
frame <<= 1;
|
frame <<= 1;
|
||||||
_frames[frame] = time;
|
_frames[frame] = time;
|
||||||
|
|||||||
@ -44,7 +44,7 @@ using namespace spine;
|
|||||||
RTTI_IMPL(DeformTimeline, CurveTimeline)
|
RTTI_IMPL(DeformTimeline, CurveTimeline)
|
||||||
|
|
||||||
DeformTimeline::DeformTimeline(size_t frameCount, size_t bezierCount, int slotIndex, VertexAttachment *attachment)
|
DeformTimeline::DeformTimeline(size_t frameCount, size_t bezierCount, int slotIndex, VertexAttachment *attachment)
|
||||||
: CurveTimeline(frameCount, 1, bezierCount), _slotIndex(slotIndex), _attachment(attachment) {
|
: SlotCurveTimeline(frameCount, 1, bezierCount, slotIndex), _attachment(attachment) {
|
||||||
PropertyId ids[] = {((PropertyId) Property_Deform << 32) | ((slotIndex << 16 | attachment->_id) & 0xffffffff)};
|
PropertyId ids[] = {((PropertyId) Property_Deform << 32) | ((slotIndex << 16 | attachment->_id) & 0xffffffff)};
|
||||||
setPropertyIds(ids, 1);
|
setPropertyIds(ids, 1);
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ DeformTimeline::DeformTimeline(size_t frameCount, size_t bezierCount, int slotIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void DeformTimeline::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(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(direction);
|
SP_UNUSED(direction);
|
||||||
@ -64,12 +64,13 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
Slot *slotP = skeleton._slots[_slotIndex];
|
Slot *slotP = skeleton._slots[_slotIndex];
|
||||||
Slot &slot = *slotP;
|
Slot &slot = *slotP;
|
||||||
if (!slot._bone.isActive()) return;
|
if (!slot._bone.isActive()) return;
|
||||||
|
SlotPose& pose = appliedPose ? *slot._applied : slot._pose;
|
||||||
|
|
||||||
apply(slot, slot._pose, time, alpha, blend);
|
apply(slot, pose, time, alpha, blend);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeformTimeline::apply(Slot &slot, SlotPose &pose, float time, float alpha, MixBlend blend) {
|
void DeformTimeline::apply(Slot &slot, SlotPose &pose, float time, float alpha, MixBlend blend) {
|
||||||
Attachment *slotAttachment = pose.attachment;
|
Attachment *slotAttachment = pose._attachment;
|
||||||
if (slotAttachment == NULL || !slotAttachment->getRTTI().instanceOf(VertexAttachment::rtti)) {
|
if (slotAttachment == NULL || !slotAttachment->getRTTI().instanceOf(VertexAttachment::rtti)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -79,7 +80,7 @@ void DeformTimeline::apply(Slot &slot, SlotPose &pose, float time, float alpha,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<float> &deformArray = pose.deform;
|
Vector<float> &deformArray = pose._deform;
|
||||||
if (deformArray.size() == 0) {
|
if (deformArray.size() == 0) {
|
||||||
blend = MixBlend_Setup;
|
blend = MixBlend_Setup;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(IkConstraint)
|
RTTI_IMPL(IkConstraint, Constraint)
|
||||||
|
|
||||||
void IkConstraint::apply(Skeleton& skeleton, BonePose& bone, float targetX, float targetY, bool compress, bool stretch, bool uniform, float mix) {
|
void IkConstraint::apply(Skeleton& skeleton, BonePose& bone, float targetX, float targetY, bool compress, bool stretch, bool uniform, float mix) {
|
||||||
bone.modifyLocal(skeleton);
|
bone.modifyLocal(skeleton);
|
||||||
@ -250,7 +250,7 @@ void IkConstraint::apply(Skeleton& skeleton, BonePose& parent, BonePose& child,
|
|||||||
}
|
}
|
||||||
|
|
||||||
IkConstraint::IkConstraint(IkConstraintData &data, Skeleton &skeleton) :
|
IkConstraint::IkConstraint(IkConstraintData &data, Skeleton &skeleton) :
|
||||||
Constraint<IkConstraint, IkConstraintData, IkConstraintPose>(data),
|
ConstraintGeneric<IkConstraint, IkConstraintData, IkConstraintPose>(data),
|
||||||
_target(skeleton.findBone(data.getTarget()->getName())) {
|
_target(skeleton.findBone(data.getTarget()->getName())) {
|
||||||
|
|
||||||
_bones.ensureCapacity(data.getBones().size());
|
_bones.ensureCapacity(data.getBones().size());
|
||||||
|
|||||||
@ -31,8 +31,6 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(IkConstraintPose)
|
|
||||||
|
|
||||||
IkConstraintPose::IkConstraintPose() : _bendDirection(0), _compress(false), _stretch(false), _mix(0), _softness(0) {
|
IkConstraintPose::IkConstraintPose() : _bendDirection(0), _compress(false), _stretch(false), _mix(0), _softness(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(PathConstraint)
|
RTTI_IMPL(PathConstraint, Constraint)
|
||||||
|
|
||||||
const float PathConstraint::epsilon = 0.00001f;
|
const float PathConstraint::epsilon = 0.00001f;
|
||||||
const int PathConstraint::NONE = -1;
|
const int PathConstraint::NONE = -1;
|
||||||
@ -52,7 +52,7 @@ const int PathConstraint::BEFORE = -2;
|
|||||||
const int PathConstraint::AFTER = -3;
|
const int PathConstraint::AFTER = -3;
|
||||||
|
|
||||||
PathConstraint::PathConstraint(PathConstraintData &data, Skeleton &skeleton) :
|
PathConstraint::PathConstraint(PathConstraintData &data, Skeleton &skeleton) :
|
||||||
Constraint<PathConstraint, PathConstraintData, PathConstraintPose>(data),
|
ConstraintGeneric<PathConstraint, PathConstraintData, PathConstraintPose>(data),
|
||||||
_slot(skeleton._slots.buffer()[data._slot->_index]) {
|
_slot(skeleton._slots.buffer()[data._slot->_index]) {
|
||||||
|
|
||||||
_bones.ensureCapacity(data.getBones().size());
|
_bones.ensureCapacity(data.getBones().size());
|
||||||
@ -247,7 +247,6 @@ Slot *PathConstraint::getSlot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PathConstraint::setSlot(Slot *slot) {
|
void PathConstraint::setSlot(Slot *slot) {
|
||||||
if (slot == NULL) throw;
|
|
||||||
_slot = slot;
|
_slot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,8 +31,6 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(PathConstraintPose)
|
|
||||||
|
|
||||||
PathConstraintPose::PathConstraintPose() : Pose<PathConstraintPose>(), _position(0), _spacing(0), _mixRotate(0), _mixX(0), _mixY(0) {
|
PathConstraintPose::PathConstraintPose() : Pose<PathConstraintPose>(), _position(0), _spacing(0), _mixRotate(0), _mixX(0), _mixY(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,10 +39,10 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(PhysicsConstraint)
|
RTTI_IMPL(PhysicsConstraint, Constraint)
|
||||||
|
|
||||||
PhysicsConstraint::PhysicsConstraint(PhysicsConstraintData &data, Skeleton &skeleton) :
|
PhysicsConstraint::PhysicsConstraint(PhysicsConstraintData &data, Skeleton &skeleton) :
|
||||||
Constraint<PhysicsConstraint, PhysicsConstraintData, PhysicsConstraintPose>(data),
|
ConstraintGeneric<PhysicsConstraint, PhysicsConstraintData, PhysicsConstraintPose>(data),
|
||||||
_reset(true), _ux(0), _uy(0), _cx(0), _cy(0), _tx(0), _ty(0),
|
_reset(true), _ux(0), _uy(0), _cx(0), _cy(0), _tx(0), _ty(0),
|
||||||
_xOffset(0), _xLag(0), _xVelocity(0), _yOffset(0), _yLag(0), _yVelocity(0),
|
_xOffset(0), _xLag(0), _xVelocity(0), _yOffset(0), _yLag(0), _yVelocity(0),
|
||||||
_rotateOffset(0), _rotateLag(0), _rotateVelocity(0), _scaleOffset(0), _scaleLag(0), _scaleVelocity(0),
|
_rotateOffset(0), _rotateLag(0), _rotateVelocity(0), _scaleOffset(0), _scaleLag(0), _scaleVelocity(0),
|
||||||
|
|||||||
@ -31,8 +31,6 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(PhysicsConstraintPose)
|
|
||||||
|
|
||||||
PhysicsConstraintPose::PhysicsConstraintPose() : Pose<PhysicsConstraintPose>(), _inertia(0), _strength(0), _damping(0), _massInverse(0), _wind(0), _gravity(0), _mix(0) {
|
PhysicsConstraintPose::PhysicsConstraintPose() : Pose<PhysicsConstraintPose>(), _inertia(0), _strength(0), _damping(0), _massInverse(0), _wind(0), _gravity(0), _mix(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,8 +36,6 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(Sequence)
|
|
||||||
|
|
||||||
int Sequence::_nextID = 0;
|
int Sequence::_nextID = 0;
|
||||||
|
|
||||||
Sequence::Sequence(int count) : _id(nextID()),
|
Sequence::Sequence(int count) : _id(nextID()),
|
||||||
|
|||||||
@ -31,18 +31,19 @@
|
|||||||
#include <spine/Bone.h>
|
#include <spine/Bone.h>
|
||||||
#include <spine/RegionAttachment.h>
|
#include <spine/RegionAttachment.h>
|
||||||
#include <spine/MeshAttachment.h>
|
#include <spine/MeshAttachment.h>
|
||||||
|
#include <spine/VertexAttachment.h>
|
||||||
#include <spine/Event.h>
|
#include <spine/Event.h>
|
||||||
#include <spine/Skeleton.h>
|
#include <spine/Skeleton.h>
|
||||||
#include <spine/Attachment.h>
|
#include <spine/Attachment.h>
|
||||||
#include <spine/PathConstraintData.h>
|
|
||||||
#include <spine/Slot.h>
|
#include <spine/Slot.h>
|
||||||
#include <spine/Animation.h>
|
#include <spine/Animation.h>
|
||||||
|
#include <spine/MathUtil.h>
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL(SequenceTimeline, Timeline)
|
RTTI_IMPL(SequenceTimeline, Timeline)
|
||||||
|
|
||||||
SequenceTimeline::SequenceTimeline(size_t frameCount, int slotIndex, Attachment *attachment) : Timeline(frameCount, ENTRIES), _slotIndex(slotIndex), _attachment(attachment) {
|
SequenceTimeline::SequenceTimeline(size_t frameCount, int slotIndex, Attachment *attachment) : Timeline(frameCount, ENTRIES), SlotTimeline(slotIndex), _attachment((HasTextureRegion*)attachment) {
|
||||||
int sequenceId = 0;
|
int sequenceId = 0;
|
||||||
if (attachment->getRTTI().instanceOf(RegionAttachment::rtti)) sequenceId = ((RegionAttachment *) attachment)->getSequence()->getId();
|
if (attachment->getRTTI().instanceOf(RegionAttachment::rtti)) sequenceId = ((RegionAttachment *) attachment)->getSequence()->getId();
|
||||||
if (attachment->getRTTI().instanceOf(MeshAttachment::rtti)) sequenceId = ((MeshAttachment *) attachment)->getSequence()->getId();
|
if (attachment->getRTTI().instanceOf(MeshAttachment::rtti)) sequenceId = ((MeshAttachment *) attachment)->getSequence()->getId();
|
||||||
@ -62,31 +63,32 @@ void SequenceTimeline::setFrame(int frame, float time, SequenceMode mode, int in
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SequenceTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
void SequenceTimeline::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(alpha);
|
SP_UNUSED(alpha);
|
||||||
SP_UNUSED(lastTime);
|
SP_UNUSED(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(direction);
|
|
||||||
|
|
||||||
Slot *slot = skeleton.getSlots()[_slotIndex];
|
Slot *slot = skeleton.getSlots()[getSlotIndex()];
|
||||||
if (!slot->getBone().isActive()) return;
|
if (!slot->getBone().isActive()) return;
|
||||||
Attachment *slotAttachment = slot->getAttachment();
|
SlotPose& pose = appliedPose ? slot->getAppliedPose() : slot->getPose();
|
||||||
if (slotAttachment != _attachment) {
|
|
||||||
if (slotAttachment == NULL || !slotAttachment->getRTTI().instanceOf(VertexAttachment::rtti) || ((VertexAttachment *) slotAttachment)->getTimelineAttachment() != _attachment) return;
|
Attachment *slotAttachment = pose.getAttachment();
|
||||||
|
if (slotAttachment != (Attachment*)_attachment) {
|
||||||
|
if (slotAttachment == NULL || !slotAttachment->getRTTI().instanceOf(VertexAttachment::rtti) || ((VertexAttachment *) slotAttachment)->getTimelineAttachment() != (Attachment*)_attachment) return;
|
||||||
}
|
}
|
||||||
Sequence *sequence = NULL;
|
Sequence *sequence = NULL;
|
||||||
if (_attachment->getRTTI().instanceOf(RegionAttachment::rtti)) sequence = ((RegionAttachment *) _attachment)->getSequence();
|
if (((Attachment*)_attachment)->getRTTI().instanceOf(RegionAttachment::rtti)) sequence = ((RegionAttachment *) _attachment)->getSequence();
|
||||||
if (_attachment->getRTTI().instanceOf(MeshAttachment::rtti)) sequence = ((MeshAttachment *) _attachment)->getSequence();
|
if (((Attachment*)_attachment)->getRTTI().instanceOf(MeshAttachment::rtti)) sequence = ((MeshAttachment *) _attachment)->getSequence();
|
||||||
if (!sequence) return;
|
if (!sequence) return;
|
||||||
|
|
||||||
if (direction == MixDirection_Out) {
|
if (direction == MixDirection_Out) {
|
||||||
if (blend == MixBlend_Setup) slot->setSequenceIndex(-1);
|
if (blend == MixBlend_Setup) pose.setSequenceIndex(-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<float> &frames = this->_frames;
|
Vector<float> &frames = this->_frames;
|
||||||
if (time < frames[0]) {// Time is before first frame.
|
if (time < frames[0]) {
|
||||||
if (blend == MixBlend_Setup || blend == MixBlend_First) slot->setSequenceIndex(-1);
|
if (blend == MixBlend_Setup || blend == MixBlend_First) pose.setSequenceIndex(-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +124,9 @@ void SequenceTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vec
|
|||||||
int n = (count << 1) - 2;
|
int n = (count << 1) - 2;
|
||||||
index = n == 0 ? 0 : (index + count - 1) % n;
|
index = n == 0 ? 0 : (index + count - 1) % n;
|
||||||
if (index >= count) index = n - index;
|
if (index >= count) index = n - index;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slot->setSequenceIndex(index);
|
pose.setSequenceIndex(index);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,11 +40,11 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL(Slider, Update)
|
RTTI_IMPL(Slider, Constraint)
|
||||||
|
|
||||||
float Slider::_offsets[6];
|
float Slider::_offsets[6];
|
||||||
|
|
||||||
Slider::Slider(SliderData& data, Skeleton& skeleton) : Constraint<Slider, SliderData, SliderPose>(data), _bone(NULL) {
|
Slider::Slider(SliderData& data, Skeleton& skeleton) : ConstraintGeneric<Slider, SliderData, SliderPose>(data), _bone(NULL) {
|
||||||
if (data.getBone() != NULL) {
|
if (data.getBone() != NULL) {
|
||||||
_bone = skeleton.findBone(data.getBone()->getName());
|
_bone = skeleton.findBone(data.getBone()->getName());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,8 +31,6 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(SliderPose)
|
|
||||||
|
|
||||||
SliderPose::SliderPose() : _time(0), _mix(0) {
|
SliderPose::SliderPose() : _time(0), _mix(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,16 +39,12 @@ using namespace spine;
|
|||||||
RTTI_IMPL(SlotCurveTimeline, CurveTimeline)
|
RTTI_IMPL(SlotCurveTimeline, CurveTimeline)
|
||||||
|
|
||||||
SlotCurveTimeline::SlotCurveTimeline(size_t frameCount, size_t frameEntries, size_t bezierCount, int slotIndex)
|
SlotCurveTimeline::SlotCurveTimeline(size_t frameCount, size_t frameEntries, size_t bezierCount, int slotIndex)
|
||||||
: CurveTimeline(frameCount, frameEntries, bezierCount), _slotIndex(slotIndex) {
|
: CurveTimeline(frameCount, frameEntries, bezierCount), SlotTimeline(slotIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SlotCurveTimeline::~SlotCurveTimeline() {
|
SlotCurveTimeline::~SlotCurveTimeline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int SlotCurveTimeline::getSlotIndex() {
|
|
||||||
return _slotIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SlotCurveTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void SlotCurveTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction, bool appliedPose) {
|
MixBlend blend, MixDirection direction, bool appliedPose) {
|
||||||
SP_UNUSED(lastTime);
|
SP_UNUSED(lastTime);
|
||||||
@ -56,5 +52,5 @@ void SlotCurveTimeline::apply(Skeleton &skeleton, float lastTime, float time, Ve
|
|||||||
SP_UNUSED(direction);
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
Slot *slot = skeleton._slots[_slotIndex];
|
Slot *slot = skeleton._slots[_slotIndex];
|
||||||
if (slot->_bone._active) apply(*slot, appliedPose ? slot->_applied : slot->_pose, time, alpha, blend);
|
if (slot->_bone._active) apply(*slot, appliedPose ? *slot->_applied : slot->_pose, time, alpha, blend);
|
||||||
}
|
}
|
||||||
@ -35,8 +35,6 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(SlotData)
|
|
||||||
|
|
||||||
SlotData::SlotData(int index, const String& name, BoneData& boneData) :
|
SlotData::SlotData(int index, const String& name, BoneData& boneData) :
|
||||||
PosedData<SlotPose>(name),
|
PosedData<SlotPose>(name),
|
||||||
_index(index),
|
_index(index),
|
||||||
|
|||||||
@ -33,8 +33,6 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(SlotPose)
|
|
||||||
|
|
||||||
SlotPose::SlotPose() : _color(1, 1, 1, 1), _darkColor(0, 0, 0, 0), _hasDarkColor(false), _attachment(nullptr), _sequenceIndex(-1) {
|
SlotPose::SlotPose() : _color(1, 1, 1, 1), _darkColor(0, 0, 0, 0), _hasDarkColor(false), _attachment(nullptr), _sequenceIndex(-1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,6 +33,12 @@ using namespace spine;
|
|||||||
|
|
||||||
RTTI_IMPL_NOPARENT(SlotTimeline)
|
RTTI_IMPL_NOPARENT(SlotTimeline)
|
||||||
|
|
||||||
|
SlotTimeline::SlotTimeline(int slotIndex) : _slotIndex(slotIndex) {
|
||||||
|
}
|
||||||
|
|
||||||
|
SlotTimeline::~SlotTimeline() {
|
||||||
|
}
|
||||||
|
|
||||||
int SlotTimeline::getSlotIndex() {
|
int SlotTimeline::getSlotIndex() {
|
||||||
return _slotIndex;
|
return _slotIndex;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,11 +39,10 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(TransformConstraint)
|
RTTI_IMPL(TransformConstraint, Constraint)
|
||||||
|
|
||||||
TransformConstraint::TransformConstraint(TransformConstraintData& data, Skeleton& skeleton) :
|
TransformConstraint::TransformConstraint(TransformConstraintData& data, Skeleton& skeleton) :
|
||||||
Constraint<TransformConstraint, TransformConstraintData, TransformConstraintPose>(data) {
|
ConstraintGeneric<TransformConstraint, TransformConstraintData, TransformConstraintPose>(data) {
|
||||||
if (&skeleton == NULL) throw;
|
|
||||||
|
|
||||||
_bones.ensureCapacity(data.getBones().size());
|
_bones.ensureCapacity(data.getBones().size());
|
||||||
for (size_t i = 0; i < data.getBones().size(); i++) {
|
for (size_t i = 0; i < data.getBones().size(); i++) {
|
||||||
@ -140,6 +139,5 @@ Bone* TransformConstraint::getSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TransformConstraint::setSource(Bone* source) {
|
void TransformConstraint::setSource(Bone* source) {
|
||||||
if (source == NULL) throw;
|
|
||||||
_source = source;
|
_source = source;
|
||||||
}
|
}
|
||||||
@ -31,8 +31,6 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(TransformConstraintPose)
|
|
||||||
|
|
||||||
TransformConstraintPose::TransformConstraintPose() :
|
TransformConstraintPose::TransformConstraintPose() :
|
||||||
_mixRotate(0), _mixX(0), _mixY(0), _mixScaleX(0), _mixScaleY(0), _mixShearY(0) {
|
_mixRotate(0), _mixX(0), _mixY(0), _mixScaleX(0), _mixScaleY(0), _mixShearY(0) {
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user