mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-06 18:56:54 +08:00
[cpp] 4.3 porting WIP
This commit is contained in:
parent
5f74729a2e
commit
cba2d4d0d7
@ -64,9 +64,12 @@ namespace spine {
|
|||||||
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;
|
||||||
|
|
||||||
/// Sets the time and value of the specified keyframe.
|
/// Sets the time and attachment name for the specified frame.
|
||||||
|
/// @param frame Between 0 and frameCount, inclusive.
|
||||||
|
/// @param time The frame time in seconds.
|
||||||
void setFrame(int frame, float time, const String &attachmentName);
|
void setFrame(int frame, float time, const String &attachmentName);
|
||||||
|
|
||||||
|
/// The attachment name for each frame. May contain null values to clear the attachment.
|
||||||
Vector<String> &getAttachmentNames();
|
Vector<String> &getAttachmentNames();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -42,6 +42,7 @@ namespace spine {
|
|||||||
friend class BoneTimeline1;
|
friend class BoneTimeline1;
|
||||||
friend class BoneTimeline2;
|
friend class BoneTimeline2;
|
||||||
friend class RotateTimeline;
|
friend class RotateTimeline;
|
||||||
|
friend class InheritTimeline;
|
||||||
friend class ScaleTimeline;
|
friend class ScaleTimeline;
|
||||||
friend class ScaleXTimeline;
|
friend class ScaleXTimeline;
|
||||||
friend class ScaleYTimeline;
|
friend class ScaleYTimeline;
|
||||||
|
|||||||
@ -38,6 +38,7 @@ 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;
|
||||||
|
friend class IkConstraintTimeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IkConstraintPose();
|
IkConstraintPose();
|
||||||
|
|||||||
@ -45,11 +45,16 @@ namespace spine {
|
|||||||
public:
|
public:
|
||||||
explicit IkConstraintTimeline(size_t frameCount, size_t bezierCount, int ikConstraintIndex);
|
explicit IkConstraintTimeline(size_t frameCount, size_t bezierCount, int ikConstraintIndex);
|
||||||
|
|
||||||
|
virtual ~IkConstraintTimeline();
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
/// Sets the time, mix and bend direction of the specified keyframe.
|
/// Sets the time, mix, softness, bend direction, compress, and stretch for the specified frame.
|
||||||
|
/// @param frame Between 0 and frameCount, inclusive.
|
||||||
|
/// @param time The frame time in seconds.
|
||||||
|
/// @param bendDirection 1 or -1.
|
||||||
void setFrame(int frame, float time, float mix, float softness, int bendDirection, bool compress, bool stretch);
|
void setFrame(int frame, float time, float mix, float softness, int bendDirection, bool compress, bool stretch);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -50,6 +50,9 @@ namespace spine {
|
|||||||
|
|
||||||
virtual ~InheritTimeline();
|
virtual ~InheritTimeline();
|
||||||
|
|
||||||
|
/// Sets the inherit transform mode for the specified frame.
|
||||||
|
/// @param frame Between 0 and frameCount, inclusive.
|
||||||
|
/// @param time The frame time in seconds.
|
||||||
void setFrame(int frame, float time, Inherit inherit);
|
void setFrame(int frame, float time, Inherit inherit);
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
|
|||||||
@ -53,6 +53,7 @@ namespace spine {
|
|||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
friend class PathConstraintMixTimeline;
|
friend class PathConstraintMixTimeline;
|
||||||
friend class PathConstraintPositionTimeline;
|
friend class PathConstraintPositionTimeline;
|
||||||
|
friend class PathConstraintPositionTimeline;
|
||||||
friend class PathConstraintSpacingTimeline;
|
friend class PathConstraintSpacingTimeline;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|||||||
@ -45,12 +45,16 @@ namespace spine {
|
|||||||
public:
|
public:
|
||||||
explicit PathConstraintMixTimeline(size_t frameCount, size_t bezierCount, int pathConstraintIndex);
|
explicit PathConstraintMixTimeline(size_t frameCount, size_t bezierCount, int pathConstraintIndex);
|
||||||
|
|
||||||
|
virtual ~PathConstraintMixTimeline();
|
||||||
|
|
||||||
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);
|
MixDirection direction, bool appliedPose);
|
||||||
|
|
||||||
/// Sets the time and mixes of the specified keyframe.
|
/// Sets the time and color for the specified frame.
|
||||||
void setFrame(int frameIndex, float time, float mixRotate, float mixX, float mixY);
|
/// @param frame Between 0 and frameCount, inclusive.
|
||||||
|
/// @param time The frame time in seconds.
|
||||||
|
void setFrame(int frame, float time, float mixRotate, float mixX, float mixY);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int ENTRIES = 4;
|
static const int ENTRIES = 4;
|
||||||
|
|||||||
@ -37,6 +37,9 @@ namespace spine {
|
|||||||
/// Stores a pose for a path constraint.
|
/// Stores a pose for a path constraint.
|
||||||
class SP_API PathConstraintPose : public Pose<PathConstraintPose> {
|
class SP_API PathConstraintPose : public Pose<PathConstraintPose> {
|
||||||
friend class PathConstraint;
|
friend class PathConstraint;
|
||||||
|
friend class PathConstraintPositionTimeline;
|
||||||
|
friend class PathConstraintSpacingTimeline;
|
||||||
|
friend class PathConstraintMixTimeline;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _position;
|
float _position;
|
||||||
|
|||||||
@ -30,9 +30,10 @@
|
|||||||
#ifndef Spine_PathConstraintSpacingTimeline_h
|
#ifndef Spine_PathConstraintSpacingTimeline_h
|
||||||
#define Spine_PathConstraintSpacingTimeline_h
|
#define Spine_PathConstraintSpacingTimeline_h
|
||||||
|
|
||||||
#include <spine/PathConstraintPositionTimeline.h>
|
#include <spine/ConstraintTimeline1.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
/// Changes a path constraint's PathConstraintPose::getSpacing().
|
||||||
class SP_API PathConstraintSpacingTimeline : public ConstraintTimeline1 {
|
class SP_API PathConstraintSpacingTimeline : public ConstraintTimeline1 {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
@ -43,6 +44,8 @@ namespace spine {
|
|||||||
public:
|
public:
|
||||||
explicit PathConstraintSpacingTimeline(size_t frameCount, size_t bezierCount, int pathConstraintIndex);
|
explicit PathConstraintSpacingTimeline(size_t frameCount, size_t bezierCount, int pathConstraintIndex);
|
||||||
|
|
||||||
|
virtual ~PathConstraintSpacingTimeline();
|
||||||
|
|
||||||
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);
|
MixDirection direction, bool appliedPose);
|
||||||
|
|||||||
@ -61,7 +61,9 @@ namespace spine {
|
|||||||
Property_PhysicsConstraintGravity = 1 << 25,
|
Property_PhysicsConstraintGravity = 1 << 25,
|
||||||
Property_PhysicsConstraintMix = 1 << 26,
|
Property_PhysicsConstraintMix = 1 << 26,
|
||||||
Property_PhysicsConstraintReset = 1 << 27,
|
Property_PhysicsConstraintReset = 1 << 27,
|
||||||
Property_Sequence = 1 << 28
|
Property_Sequence = 1 << 28,
|
||||||
|
Property_SliderTime = 1 << 29,
|
||||||
|
Property_SliderMix = 1 << 30
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -94,6 +94,8 @@ namespace spine {
|
|||||||
|
|
||||||
friend class IkConstraintTimeline;
|
friend class IkConstraintTimeline;
|
||||||
|
|
||||||
|
friend class InheritTimeline;
|
||||||
|
|
||||||
friend class PathConstraint;
|
friend class PathConstraint;
|
||||||
|
|
||||||
friend class PathConstraintMixTimeline;
|
friend class PathConstraintMixTimeline;
|
||||||
@ -102,6 +104,10 @@ namespace spine {
|
|||||||
|
|
||||||
friend class PathConstraintSpacingTimeline;
|
friend class PathConstraintSpacingTimeline;
|
||||||
|
|
||||||
|
friend class SliderTimeline;
|
||||||
|
|
||||||
|
friend class SliderMixTimeline;
|
||||||
|
|
||||||
friend class ScaleTimeline;
|
friend class ScaleTimeline;
|
||||||
|
|
||||||
friend class ScaleXTimeline;
|
friend class ScaleXTimeline;
|
||||||
|
|||||||
@ -49,6 +49,8 @@ namespace spine {
|
|||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
friend class Slider;
|
friend class Slider;
|
||||||
|
friend class SliderMixTimeline;
|
||||||
|
friend class SliderTimeline;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
|
|||||||
54
spine-cpp/spine-cpp/include/spine/SliderMixTimeline.h
Normal file
54
spine-cpp/spine-cpp/include/spine/SliderMixTimeline.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef Spine_SliderMixTimeline_h
|
||||||
|
#define Spine_SliderMixTimeline_h
|
||||||
|
|
||||||
|
#include <spine/ConstraintTimeline1.h>
|
||||||
|
|
||||||
|
namespace spine {
|
||||||
|
/// Changes a slider's SliderPose::getMix().
|
||||||
|
class SP_API SliderMixTimeline : public ConstraintTimeline1 {
|
||||||
|
friend class SkeletonBinary;
|
||||||
|
friend class SkeletonJson;
|
||||||
|
|
||||||
|
RTTI_DECL
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SliderMixTimeline(size_t frameCount, size_t bezierCount, int sliderIndex);
|
||||||
|
|
||||||
|
virtual ~SliderMixTimeline();
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||||
|
MixDirection direction, bool appliedPose);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* Spine_SliderMixTimeline_h */
|
||||||
@ -39,6 +39,8 @@ 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> {
|
||||||
friend class Slider;
|
friend class Slider;
|
||||||
|
friend class SliderMixTimeline;
|
||||||
|
friend class SliderTimeline;
|
||||||
private:
|
private:
|
||||||
float _time, _mix;
|
float _time, _mix;
|
||||||
|
|
||||||
|
|||||||
53
spine-cpp/spine-cpp/include/spine/SliderTimeline.h
Normal file
53
spine-cpp/spine-cpp/include/spine/SliderTimeline.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef Spine_SliderTimeline_h
|
||||||
|
#define Spine_SliderTimeline_h
|
||||||
|
|
||||||
|
#include <spine/ConstraintTimeline1.h>
|
||||||
|
|
||||||
|
namespace spine {
|
||||||
|
class SP_API SliderTimeline : public ConstraintTimeline1 {
|
||||||
|
friend class SkeletonBinary;
|
||||||
|
friend class SkeletonJson;
|
||||||
|
|
||||||
|
RTTI_DECL
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SliderTimeline(size_t frameCount, size_t bezierCount, int sliderIndex);
|
||||||
|
|
||||||
|
virtual ~SliderTimeline();
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||||
|
MixDirection direction, bool appliedPose);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* Spine_SliderTimeline_h */
|
||||||
@ -51,6 +51,7 @@ namespace spine {
|
|||||||
friend class FromShearY;
|
friend class FromShearY;
|
||||||
friend class ToShearY;
|
friend class ToShearY;
|
||||||
friend class TransformConstraint;
|
friend class TransformConstraint;
|
||||||
|
friend class TransformConstraintTimeline;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _mixRotate, _mixX, _mixY, _mixScaleX, _mixScaleY, _mixShearY;
|
float _mixRotate, _mixX, _mixY, _mixScaleX, _mixScaleY, _mixShearY;
|
||||||
|
|||||||
@ -45,11 +45,16 @@ namespace spine {
|
|||||||
public:
|
public:
|
||||||
explicit TransformConstraintTimeline(size_t frameCount, size_t bezierCount, int transformConstraintIndex);
|
explicit TransformConstraintTimeline(size_t frameCount, size_t bezierCount, int transformConstraintIndex);
|
||||||
|
|
||||||
|
virtual ~TransformConstraintTimeline();
|
||||||
|
|
||||||
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);
|
MixDirection direction, bool appliedPose);
|
||||||
|
|
||||||
void setFrame(size_t frameIndex, float time, float mixRotate, float mixX, float mixY, float mixScaleX,
|
/// Sets the time, rotate mix, translate mix, scale mix, and shear mix for the specified frame.
|
||||||
|
/// @param frame Between 0 and frameCount, inclusive.
|
||||||
|
/// @param time The frame time in seconds.
|
||||||
|
void setFrame(int frame, float time, float mixRotate, float mixX, float mixY, float mixScaleX,
|
||||||
float mixScaleY, float mixShearY);
|
float mixScaleY, float mixShearY);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -67,7 +67,7 @@ void AttachmentTimeline::apply(Skeleton &skeleton, float lastTime, float time, V
|
|||||||
SP_UNUSED(alpha);
|
SP_UNUSED(alpha);
|
||||||
|
|
||||||
Slot *slot = skeleton._slots[_slotIndex];
|
Slot *slot = skeleton._slots[_slotIndex];
|
||||||
if (!slot->_bone._active) return;
|
if (!slot->_bone.isActive()) return;
|
||||||
SlotPose &pose = appliedPose ? *slot->_applied : slot->_pose;
|
SlotPose &pose = appliedPose ? *slot->_applied : slot->_pose;
|
||||||
|
|
||||||
if (direction == MixDirection_Out) {
|
if (direction == MixDirection_Out) {
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
#include <spine/Animation.h>
|
#include <spine/Animation.h>
|
||||||
#include <spine/IkConstraint.h>
|
#include <spine/IkConstraint.h>
|
||||||
#include <spine/IkConstraintData.h>
|
#include <spine/IkConstraintData.h>
|
||||||
|
#include <spine/IkConstraintPose.h>
|
||||||
#include <spine/Property.h>
|
#include <spine/Property.h>
|
||||||
#include <spine/Slot.h>
|
#include <spine/Slot.h>
|
||||||
#include <spine/SlotData.h>
|
#include <spine/SlotData.h>
|
||||||
@ -49,33 +50,34 @@ IkConstraintTimeline::IkConstraintTimeline(size_t frameCount, size_t bezierCount
|
|||||||
setPropertyIds(ids, 1);
|
setPropertyIds(ids, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IkConstraintTimeline::~IkConstraintTimeline() {
|
||||||
|
}
|
||||||
|
|
||||||
void IkConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void IkConstraintTimeline::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);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(appliedPose);
|
|
||||||
|
|
||||||
IkConstraint *constraintP = (IkConstraint *) skeleton._constraints[_constraintIndex];
|
IkConstraint *constraint = (IkConstraint *) skeleton._constraints[_constraintIndex];
|
||||||
IkConstraint &constraint = *constraintP;
|
if (!constraint->isActive()) return;
|
||||||
if (!constraint.isActive()) return;
|
IkConstraintPose &pose = appliedPose ? *constraint->_applied : constraint->_pose;
|
||||||
|
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
|
IkConstraintPose &setup = constraint->_data._setup;
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
constraint.getAppliedPose().setMix(constraint._data.getSetupPose().getMix());
|
pose._mix = setup._mix;
|
||||||
constraint.getAppliedPose().setSoftness(constraint._data.getSetupPose().getSoftness());
|
pose._softness = setup._softness;
|
||||||
constraint.getAppliedPose().setBendDirection(constraint._data.getSetupPose().getBendDirection());
|
pose._bendDirection = setup._bendDirection;
|
||||||
constraint.getAppliedPose().setCompress(constraint._data.getSetupPose().getCompress());
|
pose._compress = setup._compress;
|
||||||
constraint.getAppliedPose().setStretch(constraint._data.getSetupPose().getStretch());
|
pose._stretch = setup._stretch;
|
||||||
return;
|
return;
|
||||||
case MixBlend_First:
|
case MixBlend_First:
|
||||||
constraint.getAppliedPose().setMix(constraint.getAppliedPose().getMix() +
|
pose._mix += (setup._mix - pose._mix) * alpha;
|
||||||
(constraint._data.getSetupPose().getMix() - constraint.getAppliedPose().getMix()) * alpha);
|
pose._softness += (setup._softness - pose._softness) * alpha;
|
||||||
constraint.getAppliedPose().setSoftness(constraint.getAppliedPose().getSoftness() +
|
pose._bendDirection = setup._bendDirection;
|
||||||
(constraint._data.getSetupPose().getSoftness() - constraint.getAppliedPose().getSoftness()) * alpha);
|
pose._compress = setup._compress;
|
||||||
constraint.getAppliedPose().setBendDirection(constraint._data.getSetupPose().getBendDirection());
|
pose._stretch = setup._stretch;
|
||||||
constraint.getAppliedPose().setCompress(constraint._data.getSetupPose().getCompress());
|
|
||||||
constraint.getAppliedPose().setStretch(constraint._data.getSetupPose().getStretch());
|
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -83,57 +85,59 @@ void IkConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time,
|
|||||||
}
|
}
|
||||||
|
|
||||||
float mix = 0, softness = 0;
|
float mix = 0, softness = 0;
|
||||||
int i = Animation::search(_frames, time, IkConstraintTimeline::ENTRIES);
|
int i = Animation::search(_frames, time, ENTRIES);
|
||||||
int curveType = (int) _curves[i / IkConstraintTimeline::ENTRIES];
|
int curveType = (int) _curves[i / ENTRIES];
|
||||||
switch (curveType) {
|
switch (curveType) {
|
||||||
case IkConstraintTimeline::LINEAR: {
|
case LINEAR: {
|
||||||
float before = _frames[i];
|
float before = _frames[i];
|
||||||
mix = _frames[i + IkConstraintTimeline::MIX];
|
mix = _frames[i + MIX];
|
||||||
softness = _frames[i + IkConstraintTimeline::SOFTNESS];
|
softness = _frames[i + SOFTNESS];
|
||||||
float t = (time - before) / (_frames[i + IkConstraintTimeline::ENTRIES] - before);
|
float t = (time - before) / (_frames[i + ENTRIES] - before);
|
||||||
mix += (_frames[i + IkConstraintTimeline::ENTRIES + IkConstraintTimeline::MIX] - mix) * t;
|
mix += (_frames[i + ENTRIES + MIX] - mix) * t;
|
||||||
softness += (_frames[i + IkConstraintTimeline::ENTRIES + IkConstraintTimeline::SOFTNESS] - softness) * t;
|
softness += (_frames[i + ENTRIES + SOFTNESS] - softness) * t;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IkConstraintTimeline::STEPPED: {
|
case STEPPED: {
|
||||||
mix = _frames[i + IkConstraintTimeline::MIX];
|
mix = _frames[i + MIX];
|
||||||
softness = _frames[i + IkConstraintTimeline::SOFTNESS];
|
softness = _frames[i + SOFTNESS];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
mix = getBezierValue(time, i, IkConstraintTimeline::MIX, curveType - IkConstraintTimeline::BEZIER);
|
mix = getBezierValue(time, i, MIX, curveType - BEZIER);
|
||||||
softness = getBezierValue(time, i, IkConstraintTimeline::SOFTNESS,
|
softness = getBezierValue(time, i, SOFTNESS,
|
||||||
curveType + IkConstraintTimeline::BEZIER_SIZE -
|
curveType + BEZIER_SIZE -
|
||||||
IkConstraintTimeline::BEZIER);
|
BEZIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blend == MixBlend_Setup) {
|
switch (blend) {
|
||||||
constraint.getAppliedPose().setMix(constraint._data.getSetupPose().getMix() +
|
case MixBlend_Setup: {
|
||||||
(mix - constraint._data.getSetupPose().getMix()) * alpha);
|
IkConstraintPose &setup = constraint->_data._setup;
|
||||||
constraint.getAppliedPose().setSoftness(constraint._data.getSetupPose().getSoftness() +
|
pose._mix = setup._mix + (mix - setup._mix) * alpha;
|
||||||
(softness - constraint._data.getSetupPose().getSoftness()) * alpha);
|
pose._softness = setup._softness + (softness - setup._softness) * alpha;
|
||||||
|
if (direction == MixDirection_Out) {
|
||||||
if (direction == MixDirection_Out) {
|
pose._bendDirection = setup._bendDirection;
|
||||||
constraint.getAppliedPose().setBendDirection(constraint._data.getSetupPose().getBendDirection());
|
pose._compress = setup._compress;
|
||||||
constraint.getAppliedPose().setCompress(constraint._data.getSetupPose().getCompress());
|
pose._stretch = setup._stretch;
|
||||||
constraint.getAppliedPose().setStretch(constraint._data.getSetupPose().getStretch());
|
return;
|
||||||
} else {
|
}
|
||||||
constraint.getAppliedPose().setBendDirection(_frames[i + IkConstraintTimeline::BEND_DIRECTION]);
|
break;
|
||||||
constraint.getAppliedPose().setCompress(_frames[i + IkConstraintTimeline::COMPRESS] != 0);
|
|
||||||
constraint.getAppliedPose().setStretch(_frames[i + IkConstraintTimeline::STRETCH] != 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
constraint.getAppliedPose().setMix(constraint.getAppliedPose().getMix() +
|
|
||||||
(mix - constraint.getAppliedPose().getMix()) * alpha);
|
|
||||||
constraint.getAppliedPose().setSoftness(constraint.getAppliedPose().getSoftness() +
|
|
||||||
(softness - constraint.getAppliedPose().getSoftness()) * alpha);
|
|
||||||
if (direction == MixDirection_In) {
|
|
||||||
constraint.getAppliedPose().setBendDirection(_frames[i + IkConstraintTimeline::BEND_DIRECTION]);
|
|
||||||
constraint.getAppliedPose().setCompress(_frames[i + IkConstraintTimeline::COMPRESS] != 0);
|
|
||||||
constraint.getAppliedPose().setStretch(_frames[i + IkConstraintTimeline::STRETCH] != 0);
|
|
||||||
}
|
}
|
||||||
|
case MixBlend_First:
|
||||||
|
case MixBlend_Replace:
|
||||||
|
pose._mix += (mix - pose._mix) * alpha;
|
||||||
|
pose._softness += (softness - pose._softness) * alpha;
|
||||||
|
if (direction == MixDirection_Out) return;
|
||||||
|
break;
|
||||||
|
case MixBlend_Add:
|
||||||
|
pose._mix += mix * alpha;
|
||||||
|
pose._softness += softness * alpha;
|
||||||
|
if (direction == MixDirection_Out) return;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
pose._bendDirection = (int)_frames[i + BEND_DIRECTION];
|
||||||
|
pose._compress = _frames[i + COMPRESS] != 0;
|
||||||
|
pose._stretch = _frames[i + STRETCH] != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IkConstraintTimeline::setFrame(int frame, float time, float mix, float softness, int bendDirection, bool compress,
|
void IkConstraintTimeline::setFrame(int frame, float time, float mix, float softness, int bendDirection, bool compress,
|
||||||
|
|||||||
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include <spine/Bone.h>
|
#include <spine/Bone.h>
|
||||||
#include <spine/BoneData.h>
|
#include <spine/BoneData.h>
|
||||||
|
#include <spine/BoneLocal.h>
|
||||||
#include <spine/Slot.h>
|
#include <spine/Slot.h>
|
||||||
#include <spine/SlotData.h>
|
#include <spine/SlotData.h>
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ InheritTimeline::~InheritTimeline() {
|
|||||||
void InheritTimeline::setFrame(int frame, float time, Inherit inherit) {
|
void InheritTimeline::setFrame(int frame, float time, Inherit inherit) {
|
||||||
frame *= ENTRIES;
|
frame *= ENTRIES;
|
||||||
_frames[frame] = time;
|
_frames[frame] = time;
|
||||||
_frames[frame + INHERIT] = inherit;
|
_frames[frame + INHERIT] = (float)inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,22 +62,21 @@ void InheritTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vect
|
|||||||
MixBlend blend, MixDirection direction, bool appliedPose) {
|
MixBlend blend, MixDirection direction, bool appliedPose) {
|
||||||
SP_UNUSED(lastTime);
|
SP_UNUSED(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(direction);
|
|
||||||
SP_UNUSED(alpha);
|
SP_UNUSED(alpha);
|
||||||
SP_UNUSED(appliedPose);
|
|
||||||
|
|
||||||
Bone *bone = skeleton.getBones()[_boneIndex];
|
Bone *bone = skeleton._bones[_boneIndex];
|
||||||
if (!bone->isActive()) return;
|
if (!bone->isActive()) return;
|
||||||
|
BoneLocal &pose = appliedPose ? *bone->_applied : bone->_pose;
|
||||||
|
|
||||||
if (direction == MixDirection_Out) {
|
if (direction == MixDirection_Out) {
|
||||||
if (blend == MixBlend_Setup) bone->_inherit = bone->_data.getInherit();
|
if (blend == MixBlend_Setup) pose._inherit = bone->_data._setup._inherit;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
if (blend == MixBlend_Setup || blend == MixBlend_First) bone->_inherit = bone->_data.getInherit();
|
if (blend == MixBlend_Setup || blend == MixBlend_First) pose._inherit = bone->_data._setup._inherit;
|
||||||
return;
|
} else {
|
||||||
|
int idx = Animation::search(_frames, time, ENTRIES) + INHERIT;
|
||||||
|
pose._inherit = static_cast<Inherit>((int)_frames[idx]);
|
||||||
}
|
}
|
||||||
int idx = Animation::search(_frames, time, ENTRIES) + INHERIT;
|
|
||||||
bone->_inherit = static_cast<Inherit>(_frames[idx]);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
#include <spine/Animation.h>
|
#include <spine/Animation.h>
|
||||||
#include <spine/PathConstraint.h>
|
#include <spine/PathConstraint.h>
|
||||||
#include <spine/PathConstraintData.h>
|
#include <spine/PathConstraintData.h>
|
||||||
|
#include <spine/PathConstraintPose.h>
|
||||||
#include <spine/Property.h>
|
#include <spine/Property.h>
|
||||||
#include <spine/Slot.h>
|
#include <spine/Slot.h>
|
||||||
#include <spine/SlotData.h>
|
#include <spine/SlotData.h>
|
||||||
@ -50,31 +51,35 @@ PathConstraintMixTimeline::PathConstraintMixTimeline(size_t frameCount, size_t b
|
|||||||
setPropertyIds(ids, 1);
|
setPropertyIds(ids, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PathConstraintMixTimeline::~PathConstraintMixTimeline() {
|
||||||
|
}
|
||||||
|
|
||||||
void PathConstraintMixTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void PathConstraintMixTimeline::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);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(direction);
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
PathConstraint *constraintP = skeleton._cons[_constraintIndex];
|
PathConstraint *constraint = (PathConstraint *) skeleton._constraints[_constraintIndex];
|
||||||
PathConstraint &constraint = *constraintP;
|
if (!constraint->isActive()) return;
|
||||||
if (!constraint.isActive()) return;
|
PathConstraintPose &pose = appliedPose ? *constraint->_applied : constraint->_pose;
|
||||||
|
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
|
PathConstraintPose &setup = constraint->_data._setup;
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
constraint._mixRotate = constraint._data._mixRotate;
|
pose._mixRotate = setup._mixRotate;
|
||||||
constraint._mixX = constraint._data._mixX;
|
pose._mixX = setup._mixX;
|
||||||
constraint._mixY = constraint._data._mixY;
|
pose._mixY = setup._mixY;
|
||||||
return;
|
return;
|
||||||
case MixBlend_First:
|
case MixBlend_First:
|
||||||
constraint._mixRotate += (constraint._data._mixRotate - constraint._mixRotate) * alpha;
|
pose._mixRotate += (setup._mixRotate - pose._mixRotate) * alpha;
|
||||||
constraint._mixX += (constraint._data._mixX - constraint._mixX) * alpha;
|
pose._mixX += (setup._mixX - pose._mixX) * alpha;
|
||||||
constraint._mixY += (constraint._data._mixY - constraint._mixY) * alpha;
|
pose._mixY += (setup._mixY - pose._mixY) * alpha;
|
||||||
default: {
|
return;
|
||||||
}
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float rotate, x, y;
|
float rotate, x, y;
|
||||||
@ -105,15 +110,25 @@ void PathConstraintMixTimeline::apply(Skeleton &skeleton, float lastTime, float
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blend == MixBlend_Setup) {
|
switch (blend) {
|
||||||
PathConstraintData data = constraint._data;
|
case MixBlend_Setup: {
|
||||||
constraint._mixRotate = data._mixRotate + (rotate - data._mixRotate) * alpha;
|
PathConstraintPose &setup = constraint->_data._setup;
|
||||||
constraint._mixX = data._mixX + (x - data._mixX) * alpha;
|
pose._mixRotate = setup._mixRotate + (rotate - setup._mixRotate) * alpha;
|
||||||
constraint._mixY = data._mixY + (y - data._mixY) * alpha;
|
pose._mixX = setup._mixX + (x - setup._mixX) * alpha;
|
||||||
} else {
|
pose._mixY = setup._mixY + (y - setup._mixY) * alpha;
|
||||||
constraint._mixRotate += (rotate - constraint._mixRotate) * alpha;
|
break;
|
||||||
constraint._mixX += (x - constraint._mixX) * alpha;
|
}
|
||||||
constraint._mixY += (y - constraint._mixY) * alpha;
|
case MixBlend_First:
|
||||||
|
case MixBlend_Replace:
|
||||||
|
pose._mixRotate += (rotate - pose._mixRotate) * alpha;
|
||||||
|
pose._mixX += (x - pose._mixX) * alpha;
|
||||||
|
pose._mixY += (y - pose._mixY) * alpha;
|
||||||
|
break;
|
||||||
|
case MixBlend_Add:
|
||||||
|
pose._mixRotate += rotate * alpha;
|
||||||
|
pose._mixX += x * alpha;
|
||||||
|
pose._mixY += y * alpha;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,9 +45,9 @@ RTTI_IMPL(PathConstraintPositionTimeline, ConstraintTimeline1)
|
|||||||
|
|
||||||
PathConstraintPositionTimeline::PathConstraintPositionTimeline(size_t frameCount, size_t bezierCount,
|
PathConstraintPositionTimeline::PathConstraintPositionTimeline(size_t frameCount, size_t bezierCount,
|
||||||
int pathConstraintIndex) : ConstraintTimeline1(frameCount,
|
int pathConstraintIndex) : ConstraintTimeline1(frameCount,
|
||||||
bezierCount,
|
bezierCount,
|
||||||
pathConstraintIndex,
|
pathConstraintIndex,
|
||||||
Property_PathConstraintPosition) {
|
Property_PathConstraintPosition) {
|
||||||
PropertyId ids[] = {((PropertyId) Property_PathConstraintPosition << 32) | pathConstraintIndex};
|
PropertyId ids[] = {((PropertyId) Property_PathConstraintPosition << 32) | pathConstraintIndex};
|
||||||
setPropertyIds(ids, 1);
|
setPropertyIds(ids, 1);
|
||||||
}
|
}
|
||||||
@ -61,6 +61,10 @@ void PathConstraintPositionTimeline::apply(Skeleton &skeleton, float lastTime, f
|
|||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(direction);
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
PathConstraint *constraint = skeleton._pathConstraints[_constraintIndex];
|
PathConstraint *constraint = (PathConstraint *) skeleton._constraints[_constraintIndex];
|
||||||
if (constraint->_active) constraint->_position = getAbsoluteValue(time, alpha, blend, constraint->_position, constraint->_data._position);
|
if (constraint->isActive()) {
|
||||||
|
PathConstraintPose &pose = appliedPose ? *constraint->_applied : constraint->_pose;
|
||||||
|
PathConstraintData &data = constraint->_data;
|
||||||
|
pose._position = getAbsoluteValue(time, alpha, blend, pose._position, data._setup._position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,13 +52,19 @@ PathConstraintSpacingTimeline::PathConstraintSpacingTimeline(size_t frameCount,
|
|||||||
setPropertyIds(ids, 1);
|
setPropertyIds(ids, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PathConstraintSpacingTimeline::~PathConstraintSpacingTimeline() {
|
||||||
|
}
|
||||||
|
|
||||||
void PathConstraintSpacingTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
void PathConstraintSpacingTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
||||||
float alpha, MixBlend blend, MixDirection direction, bool appliedPose) {
|
float alpha, MixBlend blend, MixDirection direction, bool appliedPose) {
|
||||||
SP_UNUSED(lastTime);
|
SP_UNUSED(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(direction);
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
PathConstraint *constraint = skeleton._pathConstraints[_pathConstraintIndex];
|
PathConstraint *constraint = (PathConstraint *)skeleton._constraints[_constraintIndex];
|
||||||
if (constraint->_active)
|
if (constraint->isActive()) {
|
||||||
constraint->_spacing = getAbsoluteValue(time, alpha, blend, constraint->_spacing, constraint->_data._spacing);
|
PathConstraintPose &pose = appliedPose ? *constraint->_applied : constraint->_pose;
|
||||||
|
PathConstraintData &data = constraint->_data;
|
||||||
|
pose._spacing = getAbsoluteValue(time, alpha, blend, pose._spacing, data._setup._spacing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
69
spine-cpp/spine-cpp/src/spine/SliderMixTimeline.cpp
Normal file
69
spine-cpp/spine-cpp/src/spine/SliderMixTimeline.cpp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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/SliderMixTimeline.h>
|
||||||
|
|
||||||
|
#include <spine/Event.h>
|
||||||
|
#include <spine/Skeleton.h>
|
||||||
|
|
||||||
|
#include <spine/Animation.h>
|
||||||
|
#include <spine/Slider.h>
|
||||||
|
#include <spine/SliderData.h>
|
||||||
|
#include <spine/SliderPose.h>
|
||||||
|
#include <spine/Property.h>
|
||||||
|
|
||||||
|
using namespace spine;
|
||||||
|
|
||||||
|
RTTI_IMPL(SliderMixTimeline, ConstraintTimeline1)
|
||||||
|
|
||||||
|
SliderMixTimeline::SliderMixTimeline(size_t frameCount, size_t bezierCount,
|
||||||
|
int sliderIndex) : ConstraintTimeline1(frameCount,
|
||||||
|
bezierCount,
|
||||||
|
sliderIndex,
|
||||||
|
Property_SliderMix) {
|
||||||
|
PropertyId ids[] = {((PropertyId) Property_SliderMix << 32) | sliderIndex};
|
||||||
|
setPropertyIds(ids, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SliderMixTimeline::~SliderMixTimeline() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SliderMixTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
||||||
|
float alpha, MixBlend blend, MixDirection direction, bool appliedPose) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
|
Slider *constraint = (Slider *) skeleton._constraints[_constraintIndex];
|
||||||
|
if (constraint->isActive()) {
|
||||||
|
SliderPose &pose = appliedPose ? *constraint->_applied : constraint->_pose;
|
||||||
|
SliderData &data = constraint->_data;
|
||||||
|
pose._mix = getAbsoluteValue(time, alpha, blend, pose._mix, data._setup._mix);
|
||||||
|
}
|
||||||
|
}
|
||||||
69
spine-cpp/spine-cpp/src/spine/SliderTimeline.cpp
Normal file
69
spine-cpp/spine-cpp/src/spine/SliderTimeline.cpp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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/SliderTimeline.h>
|
||||||
|
|
||||||
|
#include <spine/Event.h>
|
||||||
|
#include <spine/Skeleton.h>
|
||||||
|
|
||||||
|
#include <spine/Animation.h>
|
||||||
|
#include <spine/Slider.h>
|
||||||
|
#include <spine/SliderData.h>
|
||||||
|
#include <spine/SliderPose.h>
|
||||||
|
#include <spine/Property.h>
|
||||||
|
|
||||||
|
using namespace spine;
|
||||||
|
|
||||||
|
RTTI_IMPL(SliderTimeline, ConstraintTimeline1)
|
||||||
|
|
||||||
|
SliderTimeline::SliderTimeline(size_t frameCount, size_t bezierCount,
|
||||||
|
int sliderIndex) : ConstraintTimeline1(frameCount,
|
||||||
|
bezierCount,
|
||||||
|
sliderIndex,
|
||||||
|
Property_SliderTime) {
|
||||||
|
PropertyId ids[] = {((PropertyId) Property_SliderTime << 32) | sliderIndex};
|
||||||
|
setPropertyIds(ids, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SliderTimeline::~SliderTimeline() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SliderTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
||||||
|
float alpha, MixBlend blend, MixDirection direction, bool appliedPose) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
|
Slider *constraint = (Slider *) skeleton._constraints[_constraintIndex];
|
||||||
|
if (constraint->isActive()) {
|
||||||
|
SliderPose &pose = appliedPose ? *constraint->_applied : constraint->_pose;
|
||||||
|
SliderData &data = constraint->_data;
|
||||||
|
pose._time = getAbsoluteValue(time, alpha, blend, pose._time, data._setup._time);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -38,6 +38,7 @@
|
|||||||
#include <spine/SlotData.h>
|
#include <spine/SlotData.h>
|
||||||
#include <spine/TransformConstraint.h>
|
#include <spine/TransformConstraint.h>
|
||||||
#include <spine/TransformConstraintData.h>
|
#include <spine/TransformConstraintData.h>
|
||||||
|
#include <spine/TransformConstraintPose.h>
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
@ -52,34 +53,37 @@ TransformConstraintTimeline::TransformConstraintTimeline(size_t frameCount, size
|
|||||||
setPropertyIds(ids, 1);
|
setPropertyIds(ids, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TransformConstraintTimeline::~TransformConstraintTimeline() {
|
||||||
|
}
|
||||||
|
|
||||||
void TransformConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
void TransformConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
||||||
float alpha, MixBlend blend, MixDirection direction, bool appliedPose) {
|
float alpha, MixBlend blend, MixDirection direction, bool appliedPose) {
|
||||||
SP_UNUSED(lastTime);
|
SP_UNUSED(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(direction);
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
TransformConstraint *constraintP = skeleton._transformConstraints[_constraintIndex];
|
TransformConstraint *constraint = (TransformConstraint *) skeleton._constraints[_constraintIndex];
|
||||||
TransformConstraint &constraint = *constraintP;
|
if (!constraint->isActive()) return;
|
||||||
if (!constraint.isActive()) return;
|
TransformConstraintPose &pose = appliedPose ? *constraint->_applied : constraint->_pose;
|
||||||
|
|
||||||
TransformConstraintData &data = constraint._data;
|
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
|
TransformConstraintPose &setup = constraint->_data._setup;
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
constraint._mixRotate = data._mixRotate;
|
pose._mixRotate = setup._mixRotate;
|
||||||
constraint._mixX = data._mixX;
|
pose._mixX = setup._mixX;
|
||||||
constraint._mixY = data._mixY;
|
pose._mixY = setup._mixY;
|
||||||
constraint._mixScaleX = data._mixScaleX;
|
pose._mixScaleX = setup._mixScaleX;
|
||||||
constraint._mixScaleY = data._mixScaleY;
|
pose._mixScaleY = setup._mixScaleY;
|
||||||
constraint._mixShearY = data._mixShearY;
|
pose._mixShearY = setup._mixShearY;
|
||||||
return;
|
return;
|
||||||
case MixBlend_First:
|
case MixBlend_First:
|
||||||
constraint._mixRotate += (data._mixRotate - constraint._mixRotate) * alpha;
|
pose._mixRotate += (setup._mixRotate - pose._mixRotate) * alpha;
|
||||||
constraint._mixX += (data._mixX - constraint._mixX) * alpha;
|
pose._mixX += (setup._mixX - pose._mixX) * alpha;
|
||||||
constraint._mixY += (data._mixY - constraint._mixY) * alpha;
|
pose._mixY += (setup._mixY - pose._mixY) * alpha;
|
||||||
constraint._mixScaleX += (data._mixScaleX - constraint._mixScaleX) * alpha;
|
pose._mixScaleX += (setup._mixScaleX - pose._mixScaleX) * alpha;
|
||||||
constraint._mixScaleY += (data._mixScaleY - constraint._mixScaleY) * alpha;
|
pose._mixScaleY += (setup._mixScaleY - pose._mixScaleY) * alpha;
|
||||||
constraint._mixShearY += (data._mixShearY - constraint._mixShearY) * alpha;
|
pose._mixShearY += (setup._mixShearY - pose._mixShearY) * alpha;
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -87,10 +91,10 @@ void TransformConstraintTimeline::apply(Skeleton &skeleton, float lastTime, floa
|
|||||||
}
|
}
|
||||||
|
|
||||||
float rotate, x, y, scaleX, scaleY, shearY;
|
float rotate, x, y, scaleX, scaleY, shearY;
|
||||||
int i = Animation::search(_frames, time, TransformConstraintTimeline::ENTRIES);
|
int i = Animation::search(_frames, time, ENTRIES);
|
||||||
int curveType = (int) _curves[i / TransformConstraintTimeline::ENTRIES];
|
int curveType = (int) _curves[i / ENTRIES];
|
||||||
switch (curveType) {
|
switch (curveType) {
|
||||||
case TransformConstraintTimeline::LINEAR: {
|
case LINEAR: {
|
||||||
float before = _frames[i];
|
float before = _frames[i];
|
||||||
rotate = _frames[i + ROTATE];
|
rotate = _frames[i + ROTATE];
|
||||||
x = _frames[i + X];
|
x = _frames[i + X];
|
||||||
@ -107,7 +111,7 @@ void TransformConstraintTimeline::apply(Skeleton &skeleton, float lastTime, floa
|
|||||||
shearY += (_frames[i + ENTRIES + SHEARY] - shearY) * t;
|
shearY += (_frames[i + ENTRIES + SHEARY] - shearY) * t;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TransformConstraintTimeline::STEPPED: {
|
case STEPPED: {
|
||||||
rotate = _frames[i + ROTATE];
|
rotate = _frames[i + ROTATE];
|
||||||
x = _frames[i + X];
|
x = _frames[i + X];
|
||||||
y = _frames[i + Y];
|
y = _frames[i + Y];
|
||||||
@ -126,24 +130,38 @@ void TransformConstraintTimeline::apply(Skeleton &skeleton, float lastTime, floa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blend == MixBlend_Setup) {
|
switch (blend) {
|
||||||
constraint._mixRotate = data._mixRotate + (rotate - data._mixRotate) * alpha;
|
case MixBlend_Setup: {
|
||||||
constraint._mixX = data._mixX + (x - data._mixX) * alpha;
|
TransformConstraintPose &setup = constraint->_data._setup;
|
||||||
constraint._mixY = data._mixY + (y - data._mixY) * alpha;
|
pose._mixRotate = setup._mixRotate + (rotate - setup._mixRotate) * alpha;
|
||||||
constraint._mixScaleX = data._mixScaleX + (scaleX - data._mixScaleX) * alpha;
|
pose._mixX = setup._mixX + (x - setup._mixX) * alpha;
|
||||||
constraint._mixScaleY = data._mixScaleY + (scaleY - data._mixScaleY) * alpha;
|
pose._mixY = setup._mixY + (y - setup._mixY) * alpha;
|
||||||
constraint._mixShearY = data._mixShearY + (shearY - data._mixShearY) * alpha;
|
pose._mixScaleX = setup._mixScaleX + (scaleX - setup._mixScaleX) * alpha;
|
||||||
} else {
|
pose._mixScaleY = setup._mixScaleY + (scaleY - setup._mixScaleY) * alpha;
|
||||||
constraint._mixRotate += (rotate - constraint._mixRotate) * alpha;
|
pose._mixShearY = setup._mixShearY + (shearY - setup._mixShearY) * alpha;
|
||||||
constraint._mixX += (x - constraint._mixX) * alpha;
|
break;
|
||||||
constraint._mixY += (y - constraint._mixY) * alpha;
|
}
|
||||||
constraint._mixScaleX += (scaleX - constraint._mixScaleX) * alpha;
|
case MixBlend_First:
|
||||||
constraint._mixScaleY += (scaleY - constraint._mixScaleY) * alpha;
|
case MixBlend_Replace:
|
||||||
constraint._mixShearY += (shearY - constraint._mixShearY) * alpha;
|
pose._mixRotate += (rotate - pose._mixRotate) * alpha;
|
||||||
|
pose._mixX += (x - pose._mixX) * alpha;
|
||||||
|
pose._mixY += (y - pose._mixY) * alpha;
|
||||||
|
pose._mixScaleX += (scaleX - pose._mixScaleX) * alpha;
|
||||||
|
pose._mixScaleY += (scaleY - pose._mixScaleY) * alpha;
|
||||||
|
pose._mixShearY += (shearY - pose._mixShearY) * alpha;
|
||||||
|
break;
|
||||||
|
case MixBlend_Add:
|
||||||
|
pose._mixRotate += rotate * alpha;
|
||||||
|
pose._mixX += x * alpha;
|
||||||
|
pose._mixY += y * alpha;
|
||||||
|
pose._mixScaleX += scaleX * alpha;
|
||||||
|
pose._mixScaleY += scaleY * alpha;
|
||||||
|
pose._mixShearY += shearY * alpha;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformConstraintTimeline::setFrame(size_t frame, float time, float mixRotate, float mixX, float mixY,
|
void TransformConstraintTimeline::setFrame(int frame, float time, float mixRotate, float mixX, float mixY,
|
||||||
float mixScaleX, float mixScaleY, float mixShearY) {
|
float mixScaleX, float mixScaleY, float mixShearY) {
|
||||||
frame *= ENTRIES;
|
frame *= ENTRIES;
|
||||||
_frames[frame] = time;
|
_frames[frame] = time;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user