mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[cpp] 4.3 porting WIP
This commit is contained in:
parent
2868c79f7c
commit
d22ada68e5
@ -30,6 +30,7 @@
|
||||
#ifndef Spine_Bone_h
|
||||
#define Spine_Bone_h
|
||||
|
||||
#include <spine/Posed.h>
|
||||
#include <spine/PosedActive.h>
|
||||
#include <spine/BoneData.h>
|
||||
#include <spine/BoneLocal.h>
|
||||
@ -42,7 +43,7 @@ namespace spine {
|
||||
/// A bone has a local transform which is used to compute its world transform. A bone also has an applied transform, which is a
|
||||
/// local transform that can be applied to compute the world transform. The local transform and applied transform may differ if a
|
||||
/// constraint or application code modifies the world transform after it was computed from the local transform.
|
||||
class SP_API Bone : public PosedActiveGeneric<BoneData, BoneLocal, BonePose> {
|
||||
class SP_API Bone : public PosedGeneric<BoneData, BoneLocal, BonePose>, public PosedActive {
|
||||
friend class AnimationState;
|
||||
friend class RotateTimeline;
|
||||
friend class IkConstraint;
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#ifndef Spine_Constraint_h
|
||||
#define Spine_Constraint_h
|
||||
|
||||
#include <spine/Posed.h>
|
||||
#include <spine/PosedActive.h>
|
||||
#include <spine/Update.h>
|
||||
#include <spine/RTTI.h>
|
||||
@ -38,35 +39,50 @@
|
||||
namespace spine {
|
||||
class Skeleton;
|
||||
|
||||
class SP_API Constraint: public Update {
|
||||
class SP_API Constraint : public Update {
|
||||
RTTI_DECL_NOPARENT
|
||||
public:
|
||||
Constraint();
|
||||
virtual ~Constraint();
|
||||
|
||||
ConstraintData &getData();
|
||||
};
|
||||
|
||||
template<class T, class D, class P>
|
||||
class SP_API ConstraintGeneric : public PosedActiveGeneric<D, P, P>, public Constraint {
|
||||
RTTI_DECL
|
||||
|
||||
friend class Skeleton;
|
||||
|
||||
public:
|
||||
ConstraintGeneric(D& data) : PosedActiveGeneric<D, P, P>(data), Constraint() {
|
||||
}
|
||||
Constraint();
|
||||
virtual ~Constraint();
|
||||
|
||||
virtual ~ConstraintGeneric() {
|
||||
}
|
||||
virtual ConstraintData &getData() = 0;
|
||||
|
||||
virtual void sort(Skeleton& skeleton) = 0;
|
||||
virtual void sort(Skeleton &skeleton) = 0;
|
||||
|
||||
virtual bool isSourceActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void pose() = 0;
|
||||
|
||||
// Inherited from Update
|
||||
virtual void update(Skeleton& skeleton, Physics physics) override = 0;
|
||||
virtual void update(Skeleton &skeleton, Physics physics) override = 0;
|
||||
|
||||
protected:
|
||||
bool _active;
|
||||
};
|
||||
}
|
||||
|
||||
template<class T, class D, class P>
|
||||
class SP_API ConstraintGeneric : public PosedGeneric<D, P, P>, public PosedActive, public Constraint {
|
||||
RTTI_DECL
|
||||
|
||||
public:
|
||||
ConstraintGeneric(D &data) : PosedGeneric<D, P, P>(data), PosedActive(), Constraint() {
|
||||
}
|
||||
|
||||
virtual ~ConstraintGeneric() {
|
||||
}
|
||||
|
||||
virtual ConstraintData &getData() override {
|
||||
return PosedGeneric<D, P, P>::getData();
|
||||
}
|
||||
|
||||
virtual void pose() override {
|
||||
PosedGeneric<D, P, P>::pose();
|
||||
}
|
||||
};
|
||||
}// namespace spine
|
||||
|
||||
#endif /* Spine_Constraint_h */
|
||||
@ -30,12 +30,13 @@
|
||||
#ifndef Spine_ConstraintData_h
|
||||
#define Spine_ConstraintData_h
|
||||
|
||||
#include <spine/PosedData.h>
|
||||
#include <spine/SpineString.h>
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/RTTI.h>
|
||||
|
||||
namespace spine {
|
||||
class Skeleton;
|
||||
class Constraint;
|
||||
|
||||
/// Base class for all constraint data types.
|
||||
class SP_API ConstraintData : public SpineObject {
|
||||
@ -44,25 +45,12 @@ namespace spine {
|
||||
ConstraintData(const String &name);
|
||||
virtual ~ConstraintData();
|
||||
const String &getName() const;
|
||||
|
||||
virtual Constraint* create(Skeleton& skeleton) = 0;
|
||||
|
||||
private:
|
||||
String _name;
|
||||
};
|
||||
|
||||
/// Generic base class for all constraint data.
|
||||
template<class T, class P>
|
||||
class SP_API ConstraintDataGeneric : public PosedDataGeneric<P>, public ConstraintData {
|
||||
friend class SkeletonBinary;
|
||||
friend class SkeletonJson;
|
||||
|
||||
public:
|
||||
ConstraintDataGeneric(const String &name) : PosedDataGeneric<P>(name), ConstraintData(name) {
|
||||
}
|
||||
virtual ~ConstraintDataGeneric() {
|
||||
}
|
||||
|
||||
/// Creates a constraint instance.
|
||||
virtual T* create(Skeleton& skeleton) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* Spine_ConstraintData_h */
|
||||
|
||||
@ -34,13 +34,14 @@
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/SpineString.h>
|
||||
#include <spine/ConstraintData.h>
|
||||
#include <spine/PosedData.h>
|
||||
#include <spine/IkConstraintPose.h>
|
||||
|
||||
namespace spine {
|
||||
class BoneData;
|
||||
class IkConstraint;
|
||||
|
||||
class SP_API IkConstraintData : public ConstraintDataGeneric<IkConstraint, IkConstraintPose> {
|
||||
class SP_API IkConstraintData : public ConstraintData, public PosedDataGeneric<IkConstraintPose> {
|
||||
friend class SkeletonBinary;
|
||||
|
||||
friend class SkeletonJson;
|
||||
@ -55,6 +56,8 @@ namespace spine {
|
||||
|
||||
public:
|
||||
explicit IkConstraintData(const String &name);
|
||||
|
||||
virtual Constraint* create(Skeleton& skeleton) override;
|
||||
|
||||
/// The bones that are constrained by this IK Constraint.
|
||||
Vector<BoneData *> &getBones();
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#define Spine_PathConstraintData_h
|
||||
|
||||
#include <spine/ConstraintData.h>
|
||||
#include <spine/PosedData.h>
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/PathConstraintPose.h>
|
||||
#include <spine/dll.h>
|
||||
@ -47,7 +48,7 @@ namespace spine {
|
||||
/// Stores the setup pose for a PathConstraint.
|
||||
///
|
||||
/// See https://esotericsoftware.com/spine-path-constraints Path constraints in the Spine User Guide.
|
||||
class SP_API PathConstraintData : public ConstraintDataGeneric<PathConstraint, PathConstraintPose> {
|
||||
class SP_API PathConstraintData : public ConstraintData, public PosedDataGeneric<PathConstraintPose> {
|
||||
friend class SkeletonBinary;
|
||||
|
||||
friend class SkeletonJson;
|
||||
@ -66,6 +67,8 @@ namespace spine {
|
||||
public:
|
||||
|
||||
explicit PathConstraintData(const String &name);
|
||||
|
||||
virtual Constraint* create(Skeleton& skeleton) override;
|
||||
|
||||
|
||||
/// The bones that will be modified by this path constraint.
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#define Spine_PhysicsConstraintData_h
|
||||
|
||||
#include <spine/ConstraintData.h>
|
||||
#include <spine/PosedData.h>
|
||||
#include <spine/PhysicsConstraintPose.h>
|
||||
|
||||
namespace spine {
|
||||
@ -40,7 +41,7 @@ namespace spine {
|
||||
/// Stores the setup pose for a PhysicsConstraint.
|
||||
///
|
||||
/// See https://esotericsoftware.com/spine-physics-constraints Physics constraints in the Spine User Guide.
|
||||
class SP_API PhysicsConstraintData : public ConstraintDataGeneric<PhysicsConstraint, PhysicsConstraintPose> {
|
||||
class SP_API PhysicsConstraintData : public ConstraintData, public PosedDataGeneric<PhysicsConstraintPose> {
|
||||
friend class SkeletonBinary;
|
||||
friend class SkeletonJson;
|
||||
friend class PhysicsConstraint;
|
||||
@ -49,6 +50,8 @@ namespace spine {
|
||||
RTTI_DECL
|
||||
public:
|
||||
explicit PhysicsConstraintData(const String &name);
|
||||
|
||||
virtual Constraint* create(Skeleton& skeleton) override;
|
||||
|
||||
/// The bone constrained by this physics constraint.
|
||||
BoneData* getBone();
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
* Last updated April 5, 2025. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
* 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
|
||||
@ -27,31 +27,24 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef SPINE_POSEDACTIVE_H_
|
||||
#define SPINE_POSEDACTIVE_H_
|
||||
#ifndef Spine_PosedActive_h
|
||||
#define Spine_PosedActive_h
|
||||
|
||||
#include <spine/dll.h>
|
||||
#include <spine/Posed.h>
|
||||
|
||||
namespace spine {
|
||||
|
||||
template<class D, class P, class A>
|
||||
class SP_API PosedActiveGeneric : public PosedGeneric<D, P, A> {
|
||||
friend class SlotCurveTimeline;
|
||||
|
||||
public:
|
||||
PosedActiveGeneric(D &data): PosedGeneric<D, P, A>(data), _active(false) {
|
||||
this->setupPose();
|
||||
}
|
||||
virtual ~PosedActiveGeneric() {}
|
||||
|
||||
bool isActive() {
|
||||
return _active;
|
||||
}
|
||||
|
||||
/// Simple mixin class that adds active state tracking
|
||||
class SP_API PosedActive {
|
||||
protected:
|
||||
bool _active;
|
||||
};
|
||||
}// namespace spine
|
||||
|
||||
#endif /* SPINE_POSEDACTIVE_H_ */
|
||||
public:
|
||||
PosedActive() : _active(true) {}
|
||||
virtual ~PosedActive() {}
|
||||
|
||||
bool isActive() const { return _active; }
|
||||
void setActive(bool active) { _active = active; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* Spine_PosedActive_h */
|
||||
@ -71,7 +71,7 @@ namespace spine {
|
||||
/// contains this constraint.
|
||||
///
|
||||
/// See Skin::getConstraints().
|
||||
bool getSkinRequired() { return _skinRequired; };
|
||||
bool isSkinRequired() { return _skinRequired; };
|
||||
void setSkinRequired(bool skinRequired) { _skinRequired = skinRequired; };
|
||||
|
||||
protected:
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#define Spine_SliderData_h
|
||||
|
||||
#include <spine/ConstraintData.h>
|
||||
#include <spine/PosedData.h>
|
||||
#include <spine/SliderPose.h>
|
||||
#include <spine/SpineString.h>
|
||||
|
||||
@ -44,7 +45,7 @@ namespace spine {
|
||||
/// Stores the setup pose for a PhysicsConstraint.
|
||||
///
|
||||
/// See https://esotericsoftware.com/spine-physics-constraints Physics constraints in the Spine User Guide.
|
||||
class SP_API SliderData : public ConstraintDataGeneric<Slider, SliderPose> {
|
||||
class SP_API SliderData : public ConstraintData, public PosedDataGeneric<SliderPose> {
|
||||
friend class SkeletonBinary;
|
||||
friend class SkeletonJson;
|
||||
friend class Slider;
|
||||
@ -55,7 +56,7 @@ namespace spine {
|
||||
explicit SliderData(const String &name);
|
||||
|
||||
/// Creates a slider instance.
|
||||
virtual Slider* create(Skeleton& skeleton) override;
|
||||
virtual Constraint* create(Skeleton& skeleton) override;
|
||||
|
||||
Animation* getAnimation();
|
||||
void setAnimation(Animation* animation);
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#define Spine_TransformConstraintData_h
|
||||
|
||||
#include <spine/ConstraintData.h>
|
||||
#include <spine/PosedData.h>
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/TransformConstraintPose.h>
|
||||
|
||||
@ -149,7 +150,7 @@ namespace spine {
|
||||
/// Stores the setup pose for a TransformConstraint.
|
||||
///
|
||||
/// 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 ConstraintData, public PosedDataGeneric<TransformConstraintPose> {
|
||||
public:
|
||||
RTTI_DECL
|
||||
static const int ROTATION = 0, X = 1, Y = 2, SCALEX = 3, SCALEY = 4, SHEARY = 5;
|
||||
@ -162,6 +163,8 @@ namespace spine {
|
||||
public:
|
||||
explicit TransformConstraintData(const String &name);
|
||||
~TransformConstraintData();
|
||||
|
||||
virtual Constraint* create(Skeleton& skeleton) override;
|
||||
|
||||
/// The bones that will be modified by this transform constraint.
|
||||
Vector<BoneData*>& getBones();
|
||||
|
||||
@ -36,7 +36,8 @@ using namespace spine;
|
||||
|
||||
RTTI_IMPL_NOPARENT(Bone)
|
||||
|
||||
Bone::Bone(BoneData &data, Bone *parent) : PosedActiveGeneric(data),
|
||||
Bone::Bone(BoneData &data, Bone *parent) : PosedGeneric<BoneData, BoneLocal, BonePose>(data),
|
||||
PosedActive(),
|
||||
_parent(parent),
|
||||
_children(),
|
||||
_sorted(false) {
|
||||
|
||||
@ -28,14 +28,16 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include <spine/IkConstraintData.h>
|
||||
|
||||
#include <spine/IkConstraint.h>
|
||||
#include <spine/BoneData.h>
|
||||
#include <spine/Skeleton.h>
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(IkConstraintData, ConstraintData)
|
||||
|
||||
IkConstraintData::IkConstraintData(const String &name) : ConstraintDataGeneric<IkConstraint, IkConstraintPose>(name),
|
||||
IkConstraintData::IkConstraintData(const String &name) : ConstraintData(name),
|
||||
PosedDataGeneric<IkConstraintPose>(name),
|
||||
_target(NULL),
|
||||
_uniform(false) {
|
||||
}
|
||||
@ -58,4 +60,8 @@ bool IkConstraintData::getUniform() {
|
||||
|
||||
void IkConstraintData::setUniform(bool uniform) {
|
||||
_uniform = uniform;
|
||||
}
|
||||
|
||||
Constraint* IkConstraintData::create(Skeleton& skeleton) {
|
||||
return new (__FILE__, __LINE__) IkConstraint(*this, skeleton);
|
||||
}
|
||||
@ -28,6 +28,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include <spine/PathConstraintData.h>
|
||||
#include <spine/PathConstraint.h>
|
||||
#include <spine/BoneData.h>
|
||||
#include <spine/SlotData.h>
|
||||
#include <spine/Skeleton.h>
|
||||
@ -36,7 +37,8 @@ using namespace spine;
|
||||
|
||||
RTTI_IMPL(PathConstraintData, ConstraintData)
|
||||
|
||||
PathConstraintData::PathConstraintData(const String &name) : ConstraintDataGeneric<PathConstraint, PathConstraintPose>(name),
|
||||
PathConstraintData::PathConstraintData(const String &name) : ConstraintData(name),
|
||||
PosedDataGeneric<PathConstraintPose>(name),
|
||||
_slot(NULL),
|
||||
_positionMode(PositionMode_Fixed),
|
||||
_spacingMode(SpacingMode_Length),
|
||||
@ -87,4 +89,8 @@ float PathConstraintData::getOffsetRotation() {
|
||||
|
||||
void PathConstraintData::setOffsetRotation(float offsetRotation) {
|
||||
_offsetRotation = offsetRotation;
|
||||
}
|
||||
|
||||
Constraint* PathConstraintData::create(Skeleton& skeleton) {
|
||||
return new (__FILE__, __LINE__) PathConstraint(*this, skeleton);
|
||||
}
|
||||
@ -28,13 +28,16 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include <spine/PhysicsConstraintData.h>
|
||||
#include <spine/PhysicsConstraint.h>
|
||||
#include <spine/BoneData.h>
|
||||
#include <spine/Skeleton.h>
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(PhysicsConstraintData, ConstraintData)
|
||||
|
||||
PhysicsConstraintData::PhysicsConstraintData(const String &name) : ConstraintDataGeneric<PhysicsConstraint, PhysicsConstraintPose>(name),
|
||||
PhysicsConstraintData::PhysicsConstraintData(const String &name) : ConstraintData(name),
|
||||
PosedDataGeneric<PhysicsConstraintPose>(name),
|
||||
_bone(NULL),
|
||||
_x(0), _y(0), _rotate(0), _scaleX(0), _shearX(0), _limit(0), _step(0),
|
||||
_inertiaGlobal(false), _strengthGlobal(false), _dampingGlobal(false), _massGlobal(false),
|
||||
@ -159,4 +162,8 @@ bool PhysicsConstraintData::getMixGlobal() {
|
||||
|
||||
void PhysicsConstraintData::setMixGlobal(bool mixGlobal) {
|
||||
_mixGlobal = mixGlobal;
|
||||
}
|
||||
|
||||
Constraint* PhysicsConstraintData::create(Skeleton& skeleton) {
|
||||
return new (__FILE__, __LINE__) PhysicsConstraint(*this, skeleton);
|
||||
}
|
||||
@ -35,7 +35,8 @@ using namespace spine;
|
||||
|
||||
RTTI_IMPL(SliderData, ConstraintData)
|
||||
|
||||
SliderData::SliderData(const String &name) : ConstraintDataGeneric<Slider, SliderPose>(name),
|
||||
SliderData::SliderData(const String &name) : ConstraintData(name),
|
||||
PosedDataGeneric<SliderPose>(name),
|
||||
_animation(NULL),
|
||||
_additive(false),
|
||||
_loop(false),
|
||||
@ -45,7 +46,7 @@ SliderData::SliderData(const String &name) : ConstraintDataGeneric<Slider, Slide
|
||||
_local(false) {
|
||||
}
|
||||
|
||||
Slider *SliderData::create(Skeleton &skeleton) {
|
||||
Constraint *SliderData::create(Skeleton &skeleton) {
|
||||
return new (__FILE__, __LINE__) Slider(*this, skeleton);
|
||||
}
|
||||
|
||||
|
||||
@ -52,5 +52,5 @@ void SlotCurveTimeline::apply(Skeleton &skeleton, float lastTime, float time, Ve
|
||||
SP_UNUSED(direction);
|
||||
|
||||
Slot *slot = skeleton._slots[_slotIndex];
|
||||
if (slot->_bone._active) apply(*slot, appliedPose ? *slot->_applied : slot->_pose, time, alpha, blend);
|
||||
if (slot->_bone.isActive()) apply(*slot, appliedPose ? *slot->_applied : slot->_pose, time, alpha, blend);
|
||||
}
|
||||
@ -28,17 +28,20 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include <spine/TransformConstraintData.h>
|
||||
#include <spine/TransformConstraint.h>
|
||||
#include <spine/BoneData.h>
|
||||
#include <spine/BonePose.h>
|
||||
#include <spine/TransformConstraintPose.h>
|
||||
#include <spine/MathUtil.h>
|
||||
#include <spine/ContainerUtil.h>
|
||||
#include <spine/Skeleton.h>
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL(TransformConstraintData, ConstraintData)
|
||||
|
||||
TransformConstraintData::TransformConstraintData(const String &name) : ConstraintDataGeneric<TransformConstraint, TransformConstraintPose>(name),
|
||||
TransformConstraintData::TransformConstraintData(const String &name) : ConstraintData(name),
|
||||
PosedDataGeneric<TransformConstraintPose>(name),
|
||||
_source(NULL),
|
||||
_localSource(false),
|
||||
_localTarget(false),
|
||||
@ -353,4 +356,8 @@ TransformConstraintData::~TransformConstraintData() {
|
||||
}
|
||||
}
|
||||
_properties.clear();
|
||||
}
|
||||
|
||||
Constraint* TransformConstraintData::create(Skeleton& skeleton) {
|
||||
return new (__FILE__, __LINE__) TransformConstraint(*this, skeleton);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user