mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[cpp] 4.3 porting WIP
This commit is contained in:
parent
df13ca0815
commit
c6dd51015d
@ -84,7 +84,7 @@ namespace spine {
|
|||||||
|
|
||||||
void setIcon(const String &icon);
|
void setIcon(const String &icon);
|
||||||
|
|
||||||
bool isVisible();
|
bool getVisible();
|
||||||
|
|
||||||
void setVisible(bool inValue);
|
void setVisible(bool inValue);
|
||||||
|
|
||||||
|
|||||||
@ -34,11 +34,13 @@
|
|||||||
#include <spine/SpineObject.h>
|
#include <spine/SpineObject.h>
|
||||||
#include <spine/SpineString.h>
|
#include <spine/SpineString.h>
|
||||||
#include <spine/ConstraintData.h>
|
#include <spine/ConstraintData.h>
|
||||||
|
#include <spine/IkConstraintPose.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class BoneData;
|
class BoneData;
|
||||||
|
class IkConstraint;
|
||||||
|
|
||||||
class SP_API IkConstraintData : public ConstraintData {
|
class SP_API IkConstraintData : public ConstraintData<IkConstraint, IkConstraintPose> {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
@ -62,40 +64,15 @@ namespace spine {
|
|||||||
|
|
||||||
void setTarget(BoneData *inValue);
|
void setTarget(BoneData *inValue);
|
||||||
|
|
||||||
/// Controls the bend direction of the IK bones, either 1 or -1.
|
/// When true and IkConstraintPose compress or stretch is used, the bone is scaled on both the X and Y axes.
|
||||||
int getBendDirection();
|
|
||||||
|
|
||||||
void setBendDirection(int inValue);
|
|
||||||
|
|
||||||
bool getCompress();
|
|
||||||
|
|
||||||
void setCompress(bool inValue);
|
|
||||||
|
|
||||||
bool getStretch();
|
|
||||||
|
|
||||||
void setStretch(bool inValue);
|
|
||||||
|
|
||||||
bool getUniform();
|
bool getUniform();
|
||||||
|
|
||||||
void setUniform(bool inValue);
|
void setUniform(bool uniform);
|
||||||
|
|
||||||
float getMix();
|
|
||||||
|
|
||||||
void setMix(float inValue);
|
|
||||||
|
|
||||||
float getSoftness();
|
|
||||||
|
|
||||||
void setSoftness(float inValue);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<BoneData *> _bones;
|
Vector<BoneData *> _bones;
|
||||||
BoneData *_target;
|
BoneData *_target;
|
||||||
int _bendDirection;
|
|
||||||
bool _compress;
|
|
||||||
bool _stretch;
|
|
||||||
bool _uniform;
|
bool _uniform;
|
||||||
float _mix;
|
|
||||||
float _softness;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,12 +32,13 @@
|
|||||||
|
|
||||||
#include <spine/ConstraintData.h>
|
#include <spine/ConstraintData.h>
|
||||||
#include <spine/Vector.h>
|
#include <spine/Vector.h>
|
||||||
|
#include <spine/PathConstraintPose.h>
|
||||||
|
#include <spine/dll.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class BoneData;
|
class BoneData;
|
||||||
class SlotData;
|
class SlotData;
|
||||||
class PathConstraint;
|
class PathConstraint;
|
||||||
class PathConstraintPose;
|
|
||||||
class Skeleton;
|
class Skeleton;
|
||||||
|
|
||||||
/// Controls how the first bone is positioned along the path.
|
/// Controls how the first bone is positioned along the path.
|
||||||
|
|||||||
@ -30,122 +30,78 @@
|
|||||||
#ifndef Spine_PhysicsConstraintData_h
|
#ifndef Spine_PhysicsConstraintData_h
|
||||||
#define Spine_PhysicsConstraintData_h
|
#define Spine_PhysicsConstraintData_h
|
||||||
|
|
||||||
#include <spine/Vector.h>
|
|
||||||
#include <spine/SpineObject.h>
|
|
||||||
#include <spine/SpineString.h>
|
|
||||||
#include <spine/ConstraintData.h>
|
#include <spine/ConstraintData.h>
|
||||||
|
#include <spine/PhysicsConstraintPose.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class BoneData;
|
class BoneData;
|
||||||
|
class PhysicsConstraint;
|
||||||
|
|
||||||
class SP_API PhysicsConstraintData : public ConstraintData {
|
/// 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 ConstraintData<PhysicsConstraint, PhysicsConstraintPose> {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
friend class PhysicsConstraint;
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
|
|
||||||
friend class PhysicsConstraint;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
explicit PhysicsConstraintData(const String &name);
|
explicit PhysicsConstraintData(const String &name);
|
||||||
|
|
||||||
void setBone(BoneData* bone);
|
/// The bone constrained by this physics constraint.
|
||||||
|
BoneData* getBone();
|
||||||
|
void setBone(BoneData* bone);
|
||||||
|
|
||||||
BoneData* getBone() const;
|
float getStep();
|
||||||
|
void setStep(float step);
|
||||||
|
|
||||||
void setX(float x);
|
float getX();
|
||||||
|
void setX(float x);
|
||||||
|
|
||||||
float getX() const;
|
float getY();
|
||||||
|
void setY(float y);
|
||||||
|
|
||||||
void setY(float y);
|
float getRotate();
|
||||||
|
void setRotate(float rotate);
|
||||||
|
|
||||||
float getY() const;
|
float getScaleX();
|
||||||
|
void setScaleX(float scaleX);
|
||||||
|
|
||||||
void setRotate(float rotate);
|
float getShearX();
|
||||||
|
void setShearX(float shearX);
|
||||||
|
|
||||||
float getRotate() const;
|
float getLimit();
|
||||||
|
void setLimit(float limit);
|
||||||
|
|
||||||
void setScaleX(float scaleX);
|
bool getInertiaGlobal();
|
||||||
|
void setInertiaGlobal(bool inertiaGlobal);
|
||||||
|
|
||||||
float getScaleX() const;
|
bool getStrengthGlobal();
|
||||||
|
void setStrengthGlobal(bool strengthGlobal);
|
||||||
|
|
||||||
void setShearX(float shearX);
|
bool getDampingGlobal();
|
||||||
|
void setDampingGlobal(bool dampingGlobal);
|
||||||
|
|
||||||
float getShearX() const;
|
bool getMassGlobal();
|
||||||
|
void setMassGlobal(bool massGlobal);
|
||||||
|
|
||||||
void setLimit(float limit);
|
bool getWindGlobal();
|
||||||
|
void setWindGlobal(bool windGlobal);
|
||||||
|
|
||||||
float getLimit() const;
|
bool getGravityGlobal();
|
||||||
|
void setGravityGlobal(bool gravityGlobal);
|
||||||
|
|
||||||
void setStep(float step);
|
bool getMixGlobal();
|
||||||
|
void setMixGlobal(bool mixGlobal);
|
||||||
float getStep() const;
|
|
||||||
|
|
||||||
void setInertia(float inertia);
|
|
||||||
|
|
||||||
float getInertia() const;
|
|
||||||
|
|
||||||
void setStrength(float strength);
|
|
||||||
|
|
||||||
float getStrength() const;
|
|
||||||
|
|
||||||
void setDamping(float damping);
|
|
||||||
|
|
||||||
float getDamping() const;
|
|
||||||
|
|
||||||
void setMassInverse(float massInverse);
|
|
||||||
|
|
||||||
float getMassInverse() const;
|
|
||||||
|
|
||||||
void setWind(float wind);
|
|
||||||
|
|
||||||
float getWind() const;
|
|
||||||
|
|
||||||
void setGravity(float gravity);
|
|
||||||
|
|
||||||
float getGravity() const;
|
|
||||||
|
|
||||||
void setMix(float mix);
|
|
||||||
|
|
||||||
float getMix() const;
|
|
||||||
|
|
||||||
void setInertiaGlobal(bool inertiaGlobal);
|
|
||||||
|
|
||||||
bool isInertiaGlobal() const;
|
|
||||||
|
|
||||||
void setStrengthGlobal(bool strengthGlobal);
|
|
||||||
|
|
||||||
bool isStrengthGlobal() const;
|
|
||||||
|
|
||||||
void setDampingGlobal(bool dampingGlobal);
|
|
||||||
|
|
||||||
bool isDampingGlobal() const;
|
|
||||||
|
|
||||||
void setMassGlobal(bool massGlobal);
|
|
||||||
|
|
||||||
bool isMassGlobal() const;
|
|
||||||
|
|
||||||
void setWindGlobal(bool windGlobal);
|
|
||||||
|
|
||||||
bool isWindGlobal() const;
|
|
||||||
|
|
||||||
void setGravityGlobal(bool gravityGlobal);
|
|
||||||
|
|
||||||
bool isGravityGlobal() const;
|
|
||||||
|
|
||||||
void setMixGlobal(bool mixGlobal);
|
|
||||||
|
|
||||||
bool isMixGlobal() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BoneData *_bone;
|
BoneData* _bone;
|
||||||
float _x, _y, _rotate, _scaleX, _shearX, _limit;
|
float _x, _y, _rotate, _scaleX, _shearX, _limit, _step;
|
||||||
float _step, _inertia, _strength, _damping, _massInverse, _wind, _gravity, _mix;
|
bool _inertiaGlobal, _strengthGlobal, _dampingGlobal, _massGlobal, _windGlobal, _gravityGlobal, _mixGlobal;
|
||||||
bool _inertiaGlobal, _strengthGlobal, _dampingGlobal, _massGlobal, _windGlobal, _gravityGlobal, _mixGlobal;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_PhysicsConstraintData_h */
|
#endif /* Spine_PhysicsConstraintData_h */
|
||||||
@ -34,10 +34,10 @@
|
|||||||
#include <spine/PosedData.h>
|
#include <spine/PosedData.h>
|
||||||
#include <spine/SpineString.h>
|
#include <spine/SpineString.h>
|
||||||
#include <spine/RTTI.h>
|
#include <spine/RTTI.h>
|
||||||
|
#include <spine/SlotPose.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class BoneData;
|
class BoneData;
|
||||||
class SlotPose;
|
|
||||||
|
|
||||||
/// 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> {
|
||||||
@ -83,7 +83,7 @@ namespace spine {
|
|||||||
void setBlendMode(BlendMode blendMode);
|
void setBlendMode(BlendMode blendMode);
|
||||||
|
|
||||||
/// False if the slot was hidden in Spine and nonessential data was exported. Does not affect runtime rendering.
|
/// False if the slot was hidden in Spine and nonessential data was exported. Does not affect runtime rendering.
|
||||||
bool isVisible();
|
bool getVisible();
|
||||||
void setVisible(bool visible);
|
void setVisible(bool visible);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -30,99 +30,209 @@
|
|||||||
#ifndef Spine_TransformConstraintData_h
|
#ifndef Spine_TransformConstraintData_h
|
||||||
#define Spine_TransformConstraintData_h
|
#define Spine_TransformConstraintData_h
|
||||||
|
|
||||||
#include <spine/Vector.h>
|
|
||||||
#include <spine/SpineObject.h>
|
|
||||||
#include <spine/SpineString.h>
|
|
||||||
#include <spine/ConstraintData.h>
|
#include <spine/ConstraintData.h>
|
||||||
|
#include <spine/Vector.h>
|
||||||
|
#include <spine/TransformConstraintPose.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class BoneData;
|
class BoneData;
|
||||||
|
class TransformConstraint;
|
||||||
|
class BonePose;
|
||||||
|
class TransformConstraintPose;
|
||||||
|
|
||||||
class SP_API TransformConstraintData : public ConstraintData {
|
/// Source property for a TransformConstraint.
|
||||||
|
class SP_API FromProperty : public SpineObject {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
|
||||||
|
/// The value of this property that corresponds to ToProperty offset.
|
||||||
|
float offset;
|
||||||
|
|
||||||
|
/// Constrained properties.
|
||||||
|
Vector<class ToProperty*> to;
|
||||||
|
|
||||||
|
FromProperty();
|
||||||
|
virtual ~FromProperty();
|
||||||
|
|
||||||
|
/// Reads this property from the specified bone.
|
||||||
|
virtual float value(BonePose& source, bool local, float* offsets) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Constrained property for a TransformConstraint.
|
||||||
|
class SP_API ToProperty : public SpineObject {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
|
||||||
|
/// The value of this property that corresponds to FromProperty offset.
|
||||||
|
float offset;
|
||||||
|
|
||||||
|
/// The maximum value of this property when clamped.
|
||||||
|
float max;
|
||||||
|
|
||||||
|
/// The scale of the FromProperty value in relation to this property.
|
||||||
|
float scale;
|
||||||
|
|
||||||
|
ToProperty();
|
||||||
|
virtual ~ToProperty();
|
||||||
|
|
||||||
|
/// Reads the mix for this property from the specified pose.
|
||||||
|
virtual float mix(TransformConstraintPose& pose) = 0;
|
||||||
|
|
||||||
|
/// Applies the value to this property.
|
||||||
|
virtual void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SP_API FromRotate : public FromProperty {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
float value(BonePose& source, bool local, float* offsets) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SP_API ToRotate : public ToProperty {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
float mix(TransformConstraintPose& pose) override;
|
||||||
|
void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SP_API FromX : public FromProperty {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
float value(BonePose& source, bool local, float* offsets) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SP_API ToX : public ToProperty {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
float mix(TransformConstraintPose& pose) override;
|
||||||
|
void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SP_API FromY : public FromProperty {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
float value(BonePose& source, bool local, float* offsets) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SP_API ToY : public ToProperty {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
float mix(TransformConstraintPose& pose) override;
|
||||||
|
void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SP_API FromScaleX : public FromProperty {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
float value(BonePose& source, bool local, float* offsets) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SP_API ToScaleX : public ToProperty {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
float mix(TransformConstraintPose& pose) override;
|
||||||
|
void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SP_API FromScaleY : public FromProperty {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
float value(BonePose& source, bool local, float* offsets) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SP_API ToScaleY : public ToProperty {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
float mix(TransformConstraintPose& pose) override;
|
||||||
|
void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SP_API FromShearY : public FromProperty {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
float value(BonePose& source, bool local, float* offsets) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SP_API ToShearY : public ToProperty {
|
||||||
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
float mix(TransformConstraintPose& pose) override;
|
||||||
|
void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// 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 ConstraintData<TransformConstraint, TransformConstraintPose> {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
friend class TransformConstraint;
|
friend class TransformConstraint;
|
||||||
|
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
|
|
||||||
friend class TransformConstraintTimeline;
|
friend class TransformConstraintTimeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
explicit TransformConstraintData(const String &name);
|
explicit TransformConstraintData(const String &name);
|
||||||
|
~TransformConstraintData();
|
||||||
|
|
||||||
Vector<BoneData *> &getBones();
|
/// The bones that will be modified by this transform constraint.
|
||||||
|
Vector<BoneData*>& getBones();
|
||||||
|
|
||||||
BoneData *getTarget();
|
/// The bone whose world transform will be copied to the constrained bones.
|
||||||
|
BoneData* getSource();
|
||||||
void setTarget(BoneData *target);
|
void setSource(BoneData* source);
|
||||||
|
|
||||||
float getMixRotate();
|
|
||||||
|
|
||||||
void setMixRotate(float mixRotate);
|
|
||||||
|
|
||||||
float getMixX();
|
|
||||||
|
|
||||||
void setMixX(float mixX);
|
|
||||||
|
|
||||||
float getMixY();
|
|
||||||
|
|
||||||
void setMixY(float mixY);
|
|
||||||
|
|
||||||
float getMixScaleX();
|
|
||||||
|
|
||||||
void setMixScaleX(float mixScaleX);
|
|
||||||
|
|
||||||
float getMixScaleY();
|
|
||||||
|
|
||||||
void setMixScaleY(float mixScaleY);
|
|
||||||
|
|
||||||
float getMixShearY();
|
|
||||||
|
|
||||||
void setMixShearY(float mixShearY);
|
|
||||||
|
|
||||||
|
/// An offset added to the constrained bone rotation.
|
||||||
float getOffsetRotation();
|
float getOffsetRotation();
|
||||||
|
void setOffsetRotation(float offsetRotation);
|
||||||
|
|
||||||
void setOffsetRotation(float offsetRotation);
|
/// An offset added to the constrained bone X translation.
|
||||||
|
|
||||||
float getOffsetX();
|
float getOffsetX();
|
||||||
|
void setOffsetX(float offsetX);
|
||||||
|
|
||||||
void setOffsetX(float offsetX);
|
/// An offset added to the constrained bone Y translation.
|
||||||
|
|
||||||
float getOffsetY();
|
float getOffsetY();
|
||||||
|
void setOffsetY(float offsetY);
|
||||||
|
|
||||||
void setOffsetY(float offsetY);
|
/// An offset added to the constrained bone scaleX.
|
||||||
|
|
||||||
float getOffsetScaleX();
|
float getOffsetScaleX();
|
||||||
|
void setOffsetScaleX(float offsetScaleX);
|
||||||
|
|
||||||
void setOffsetScaleX(float offsetScaleX);
|
/// An offset added to the constrained bone scaleY.
|
||||||
|
|
||||||
float getOffsetScaleY();
|
float getOffsetScaleY();
|
||||||
|
void setOffsetScaleY(float offsetScaleY);
|
||||||
|
|
||||||
void setOffsetScaleY(float offsetScaleY);
|
/// An offset added to the constrained bone shearY.
|
||||||
|
|
||||||
float getOffsetShearY();
|
float getOffsetShearY();
|
||||||
|
void setOffsetShearY(float offsetShearY);
|
||||||
|
|
||||||
void setOffsetShearY(float offsetShearY);
|
/// Reads the source bone's local transform instead of its world transform.
|
||||||
|
bool getLocalSource();
|
||||||
|
void setLocalSource(bool localSource);
|
||||||
|
|
||||||
bool isRelative();
|
/// Sets the constrained bones' local transforms instead of their world transforms.
|
||||||
|
bool getLocalTarget();
|
||||||
|
void setLocalTarget(bool localTarget);
|
||||||
|
|
||||||
void setRelative(bool isRelative);
|
/// Adds the source bone transform to the constrained bones instead of setting it absolutely.
|
||||||
|
bool getAdditive();
|
||||||
|
void setAdditive(bool additive);
|
||||||
|
|
||||||
bool isLocal();
|
/// Prevents constrained bones from exceeding the ranged defined by offset and max.
|
||||||
|
bool getClamp();
|
||||||
|
void setClamp(bool clamp);
|
||||||
|
|
||||||
void setLocal(bool isLocal);
|
/// The mapping of transform properties to other transform properties.
|
||||||
|
Vector<class FromProperty*>& getProperties();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<BoneData *> _bones;
|
Vector<BoneData*> _bones;
|
||||||
BoneData *_target;
|
BoneData* _source;
|
||||||
float _mixRotate, _mixX, _mixY, _mixScaleX, _mixScaleY, _mixShearY;
|
float _offsets[6]; // [rotation, x, y, scaleX, scaleY, shearY]
|
||||||
float _offsetRotation, _offsetX, _offsetY, _offsetScaleX, _offsetScaleY, _offsetShearY;
|
bool _localSource, _localTarget, _additive, _clamp;
|
||||||
bool _relative, _local;
|
Vector<class FromProperty*> _properties;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_TransformConstraintData_h */
|
#endif /* Spine_TransformConstraintData_h */
|
||||||
@ -37,6 +37,22 @@ 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
|
RTTI_DECL
|
||||||
|
|
||||||
|
friend class FromProperty;
|
||||||
|
friend class ToProperty;
|
||||||
|
friend class FromRotate;
|
||||||
|
friend class ToRotate;
|
||||||
|
friend class FromX;
|
||||||
|
friend class ToX;
|
||||||
|
friend class FromY;
|
||||||
|
friend class ToY;
|
||||||
|
friend class FromScaleX;
|
||||||
|
friend class ToScaleX;
|
||||||
|
friend class FromScaleY;
|
||||||
|
friend class ToScaleY;
|
||||||
|
friend class FromShearY;
|
||||||
|
friend class ToShearY;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _mixRotate, _mixX, _mixY, _mixScaleX, _mixScaleY, _mixShearY;
|
float _mixRotate, _mixX, _mixY, _mixScaleX, _mixScaleY, _mixShearY;
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ using namespace spine;
|
|||||||
|
|
||||||
RTTI_IMPL_NOPARENT(BoneData)
|
RTTI_IMPL_NOPARENT(BoneData)
|
||||||
|
|
||||||
BoneData::BoneData(int index, const String &name, BoneData *parent) : PosedData<BoneLocal>(name, new (__FILE__, __LINE__) BoneLocal()),
|
BoneData::BoneData(int index, const String &name, BoneData *parent) : PosedData<BoneLocal>(name),
|
||||||
_index(index),
|
_index(index),
|
||||||
_parent(parent),
|
_parent(parent),
|
||||||
_length(0),
|
_length(0),
|
||||||
@ -73,7 +73,7 @@ void BoneData::setIcon(const String &icon) {
|
|||||||
this->_icon = icon;
|
this->_icon = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoneData::isVisible() {
|
bool BoneData::getVisible() {
|
||||||
return _visible;
|
return _visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,16 +33,11 @@
|
|||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL(IkConstraintData, ConstraintData)
|
RTTI_IMPL_NOPARENT(IkConstraintData)
|
||||||
|
|
||||||
IkConstraintData::IkConstraintData(const String &name) : ConstraintData(name),
|
IkConstraintData::IkConstraintData(const String &name) : ConstraintData<IkConstraint, IkConstraintPose>(name),
|
||||||
_target(NULL),
|
_target(NULL),
|
||||||
_bendDirection(0),
|
_uniform(false) {
|
||||||
_compress(false),
|
|
||||||
_stretch(false),
|
|
||||||
_uniform(false),
|
|
||||||
_mix(0),
|
|
||||||
_softness(0) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<BoneData *> &IkConstraintData::getBones() {
|
Vector<BoneData *> &IkConstraintData::getBones() {
|
||||||
@ -57,51 +52,10 @@ void IkConstraintData::setTarget(BoneData *inValue) {
|
|||||||
_target = inValue;
|
_target = inValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IkConstraintData::getBendDirection() {
|
|
||||||
return _bendDirection;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IkConstraintData::setBendDirection(int inValue) {
|
|
||||||
_bendDirection = inValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
float IkConstraintData::getMix() {
|
|
||||||
return _mix;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IkConstraintData::setMix(float inValue) {
|
|
||||||
_mix = inValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IkConstraintData::getStretch() {
|
|
||||||
return _stretch;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IkConstraintData::setStretch(bool inValue) {
|
|
||||||
_stretch = inValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IkConstraintData::getCompress() {
|
|
||||||
return _compress;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IkConstraintData::setCompress(bool inValue) {
|
|
||||||
_compress = inValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool IkConstraintData::getUniform() {
|
bool IkConstraintData::getUniform() {
|
||||||
return _uniform;
|
return _uniform;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IkConstraintData::setUniform(bool inValue) {
|
void IkConstraintData::setUniform(bool uniform) {
|
||||||
_uniform = inValue;
|
_uniform = uniform;
|
||||||
}
|
}
|
||||||
|
|
||||||
float IkConstraintData::getSoftness() {
|
|
||||||
return _softness;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IkConstraintData::setSoftness(float inValue) {
|
|
||||||
_softness = inValue;
|
|
||||||
}
|
|
||||||
@ -28,8 +28,6 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <spine/PathConstraintData.h>
|
#include <spine/PathConstraintData.h>
|
||||||
#include <spine/PathConstraint.h>
|
|
||||||
#include <spine/PathConstraintPose.h>
|
|
||||||
#include <spine/BoneData.h>
|
#include <spine/BoneData.h>
|
||||||
#include <spine/SlotData.h>
|
#include <spine/SlotData.h>
|
||||||
#include <spine/Skeleton.h>
|
#include <spine/Skeleton.h>
|
||||||
|
|||||||
@ -28,196 +28,135 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <spine/PhysicsConstraintData.h>
|
#include <spine/PhysicsConstraintData.h>
|
||||||
|
|
||||||
#include <spine/BoneData.h>
|
#include <spine/BoneData.h>
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL(PhysicsConstraintData, ConstraintData)
|
RTTI_IMPL_NOPARENT(PhysicsConstraintData)
|
||||||
|
|
||||||
PhysicsConstraintData::PhysicsConstraintData(const String &name) : ConstraintData(name),
|
PhysicsConstraintData::PhysicsConstraintData(const String &name) : ConstraintData<PhysicsConstraint, PhysicsConstraintPose>(name),
|
||||||
_bone(nullptr),
|
_bone(NULL),
|
||||||
_x(0), _y(0), _rotate(0), _scaleX(0), _shearX(0), _limit(0),
|
_x(0), _y(0), _rotate(0), _scaleX(0), _shearX(0), _limit(0), _step(0),
|
||||||
_step(0), _inertia(0), _strength(0), _damping(0), _massInverse(0), _wind(0), _gravity(0), _mix(0),
|
|
||||||
_inertiaGlobal(false), _strengthGlobal(false), _dampingGlobal(false), _massGlobal(false),
|
_inertiaGlobal(false), _strengthGlobal(false), _dampingGlobal(false), _massGlobal(false),
|
||||||
_windGlobal(false), _gravityGlobal(false), _mixGlobal(false) {
|
_windGlobal(false), _gravityGlobal(false), _mixGlobal(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BoneData* PhysicsConstraintData::getBone() {
|
||||||
void PhysicsConstraintData::setBone(BoneData *bone) {
|
|
||||||
_bone = bone;
|
|
||||||
}
|
|
||||||
|
|
||||||
BoneData *PhysicsConstraintData::getBone() const {
|
|
||||||
return _bone;
|
return _bone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setX(float x) {
|
void PhysicsConstraintData::setBone(BoneData* bone) {
|
||||||
_x = x;
|
_bone = bone;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraintData::getX() const {
|
float PhysicsConstraintData::getStep() {
|
||||||
return _x;
|
return _step;
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicsConstraintData::setY(float y) {
|
|
||||||
_y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
float PhysicsConstraintData::getY() const {
|
|
||||||
return _y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicsConstraintData::setRotate(float rotate) {
|
|
||||||
_rotate = rotate;
|
|
||||||
}
|
|
||||||
|
|
||||||
float PhysicsConstraintData::getRotate() const {
|
|
||||||
return _rotate;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicsConstraintData::setScaleX(float scaleX) {
|
|
||||||
_scaleX = scaleX;
|
|
||||||
}
|
|
||||||
|
|
||||||
float PhysicsConstraintData::getScaleX() const {
|
|
||||||
return _scaleX;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicsConstraintData::setShearX(float shearX) {
|
|
||||||
_shearX = shearX;
|
|
||||||
}
|
|
||||||
|
|
||||||
float PhysicsConstraintData::getShearX() const {
|
|
||||||
return _shearX;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicsConstraintData::setLimit(float limit) {
|
|
||||||
_limit = limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
float PhysicsConstraintData::getLimit() const {
|
|
||||||
return _limit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setStep(float step) {
|
void PhysicsConstraintData::setStep(float step) {
|
||||||
_step = step;
|
_step = step;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraintData::getStep() const {
|
float PhysicsConstraintData::getX() {
|
||||||
return _step;
|
return _x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setInertia(float inertia) {
|
void PhysicsConstraintData::setX(float x) {
|
||||||
_inertia = inertia;
|
_x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraintData::getInertia() const {
|
float PhysicsConstraintData::getY() {
|
||||||
return _inertia;
|
return _y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setStrength(float strength) {
|
void PhysicsConstraintData::setY(float y) {
|
||||||
_strength = strength;
|
_y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraintData::getStrength() const {
|
float PhysicsConstraintData::getRotate() {
|
||||||
return _strength;
|
return _rotate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setDamping(float damping) {
|
void PhysicsConstraintData::setRotate(float rotate) {
|
||||||
_damping = damping;
|
_rotate = rotate;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraintData::getDamping() const {
|
float PhysicsConstraintData::getScaleX() {
|
||||||
return _damping;
|
return _scaleX;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setMassInverse(float massInverse) {
|
void PhysicsConstraintData::setScaleX(float scaleX) {
|
||||||
_massInverse = massInverse;
|
_scaleX = scaleX;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraintData::getMassInverse() const {
|
float PhysicsConstraintData::getShearX() {
|
||||||
return _massInverse;
|
return _shearX;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setWind(float wind) {
|
void PhysicsConstraintData::setShearX(float shearX) {
|
||||||
_wind = wind;
|
_shearX = shearX;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraintData::getWind() const {
|
float PhysicsConstraintData::getLimit() {
|
||||||
return _wind;
|
return _limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setGravity(float gravity) {
|
void PhysicsConstraintData::setLimit(float limit) {
|
||||||
_gravity = gravity;
|
_limit = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysicsConstraintData::getGravity() const {
|
bool PhysicsConstraintData::getInertiaGlobal() {
|
||||||
return _gravity;
|
return _inertiaGlobal;
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicsConstraintData::setMix(float mix) {
|
|
||||||
_mix = mix;
|
|
||||||
}
|
|
||||||
|
|
||||||
float PhysicsConstraintData::getMix() const {
|
|
||||||
return _mix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setInertiaGlobal(bool inertiaGlobal) {
|
void PhysicsConstraintData::setInertiaGlobal(bool inertiaGlobal) {
|
||||||
_inertiaGlobal = inertiaGlobal;
|
_inertiaGlobal = inertiaGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PhysicsConstraintData::isInertiaGlobal() const {
|
bool PhysicsConstraintData::getStrengthGlobal() {
|
||||||
return _inertiaGlobal;
|
return _strengthGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setStrengthGlobal(bool strengthGlobal) {
|
void PhysicsConstraintData::setStrengthGlobal(bool strengthGlobal) {
|
||||||
_strengthGlobal = strengthGlobal;
|
_strengthGlobal = strengthGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PhysicsConstraintData::isStrengthGlobal() const {
|
bool PhysicsConstraintData::getDampingGlobal() {
|
||||||
return _strengthGlobal;
|
return _dampingGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setDampingGlobal(bool dampingGlobal) {
|
void PhysicsConstraintData::setDampingGlobal(bool dampingGlobal) {
|
||||||
_dampingGlobal = dampingGlobal;
|
_dampingGlobal = dampingGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PhysicsConstraintData::isDampingGlobal() const {
|
bool PhysicsConstraintData::getMassGlobal() {
|
||||||
return _dampingGlobal;
|
return _massGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setMassGlobal(bool massGlobal) {
|
void PhysicsConstraintData::setMassGlobal(bool massGlobal) {
|
||||||
_massGlobal = massGlobal;
|
_massGlobal = massGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PhysicsConstraintData::isMassGlobal() const {
|
bool PhysicsConstraintData::getWindGlobal() {
|
||||||
return _massGlobal;
|
return _windGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setWindGlobal(bool windGlobal) {
|
void PhysicsConstraintData::setWindGlobal(bool windGlobal) {
|
||||||
_windGlobal = windGlobal;
|
_windGlobal = windGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PhysicsConstraintData::isWindGlobal() const {
|
bool PhysicsConstraintData::getGravityGlobal() {
|
||||||
return _windGlobal;
|
return _gravityGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setGravityGlobal(bool gravityGlobal) {
|
void PhysicsConstraintData::setGravityGlobal(bool gravityGlobal) {
|
||||||
_gravityGlobal = gravityGlobal;
|
_gravityGlobal = gravityGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PhysicsConstraintData::isGravityGlobal() const {
|
bool PhysicsConstraintData::getMixGlobal() {
|
||||||
return _gravityGlobal;
|
return _mixGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsConstraintData::setMixGlobal(bool mixGlobal) {
|
void PhysicsConstraintData::setMixGlobal(bool mixGlobal) {
|
||||||
_mixGlobal = mixGlobal;
|
_mixGlobal = mixGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PhysicsConstraintData::isMixGlobal() const {
|
|
||||||
return _mixGlobal;
|
|
||||||
}
|
|
||||||
@ -38,7 +38,7 @@ using namespace spine;
|
|||||||
RTTI_IMPL_NOPARENT(SlotData)
|
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, new (__FILE__, __LINE__) SlotPose()),
|
PosedData<SlotPose>(name),
|
||||||
_index(index),
|
_index(index),
|
||||||
_boneData(boneData),
|
_boneData(boneData),
|
||||||
_attachmentName(),
|
_attachmentName(),
|
||||||
@ -71,7 +71,7 @@ void SlotData::setBlendMode(BlendMode blendMode) {
|
|||||||
_blendMode = blendMode;
|
_blendMode = blendMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SlotData::isVisible() {
|
bool SlotData::getVisible() {
|
||||||
return _visible;
|
return _visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,153 +28,330 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <spine/TransformConstraintData.h>
|
#include <spine/TransformConstraintData.h>
|
||||||
|
|
||||||
#include <spine/BoneData.h>
|
#include <spine/BoneData.h>
|
||||||
|
#include <spine/BonePose.h>
|
||||||
#include <assert.h>
|
#include <spine/TransformConstraintPose.h>
|
||||||
|
#include <spine/MathUtil.h>
|
||||||
|
#include <spine/ContainerUtil.h>
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL(TransformConstraintData, ConstraintData)
|
RTTI_IMPL_NOPARENT(TransformConstraintData)
|
||||||
|
|
||||||
TransformConstraintData::TransformConstraintData(const String &name) : ConstraintData(name),
|
TransformConstraintData::TransformConstraintData(const String &name) : ConstraintData<TransformConstraint, TransformConstraintPose>(name),
|
||||||
_target(NULL),
|
_source(NULL),
|
||||||
_mixRotate(0),
|
_localSource(false),
|
||||||
_mixX(0),
|
_localTarget(false),
|
||||||
_mixY(0),
|
_additive(false),
|
||||||
_mixScaleX(0),
|
_clamp(false) {
|
||||||
_mixScaleY(0),
|
for (int i = 0; i < 6; i++) {
|
||||||
_mixShearY(0),
|
_offsets[i] = 0;
|
||||||
_offsetRotation(0),
|
}
|
||||||
_offsetX(0),
|
|
||||||
_offsetY(0),
|
|
||||||
_offsetScaleX(0),
|
|
||||||
_offsetScaleY(0),
|
|
||||||
_offsetShearY(0),
|
|
||||||
_relative(false),
|
|
||||||
_local(false) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<BoneData *> &TransformConstraintData::getBones() {
|
Vector<BoneData*>& TransformConstraintData::getBones() {
|
||||||
return _bones;
|
return _bones;
|
||||||
}
|
}
|
||||||
|
|
||||||
BoneData *TransformConstraintData::getTarget() {
|
BoneData* TransformConstraintData::getSource() {
|
||||||
return _target;
|
return _source;
|
||||||
}
|
}
|
||||||
|
|
||||||
float TransformConstraintData::getMixRotate() {
|
void TransformConstraintData::setSource(BoneData* source) {
|
||||||
return _mixRotate;
|
_source = source;
|
||||||
}
|
|
||||||
|
|
||||||
float TransformConstraintData::getMixX() {
|
|
||||||
return _mixX;
|
|
||||||
}
|
|
||||||
|
|
||||||
float TransformConstraintData::getMixY() {
|
|
||||||
return _mixY;
|
|
||||||
}
|
|
||||||
|
|
||||||
float TransformConstraintData::getMixScaleX() {
|
|
||||||
return _mixScaleX;
|
|
||||||
}
|
|
||||||
|
|
||||||
float TransformConstraintData::getMixScaleY() {
|
|
||||||
return _mixScaleY;
|
|
||||||
}
|
|
||||||
|
|
||||||
float TransformConstraintData::getMixShearY() {
|
|
||||||
return _mixShearY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float TransformConstraintData::getOffsetRotation() {
|
float TransformConstraintData::getOffsetRotation() {
|
||||||
return _offsetRotation;
|
return _offsets[0];
|
||||||
}
|
|
||||||
|
|
||||||
float TransformConstraintData::getOffsetX() {
|
|
||||||
return _offsetX;
|
|
||||||
}
|
|
||||||
|
|
||||||
float TransformConstraintData::getOffsetY() {
|
|
||||||
return _offsetY;
|
|
||||||
}
|
|
||||||
|
|
||||||
float TransformConstraintData::getOffsetScaleX() {
|
|
||||||
return _offsetScaleX;
|
|
||||||
}
|
|
||||||
|
|
||||||
float TransformConstraintData::getOffsetScaleY() {
|
|
||||||
return _offsetScaleY;
|
|
||||||
}
|
|
||||||
|
|
||||||
float TransformConstraintData::getOffsetShearY() {
|
|
||||||
return _offsetShearY;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TransformConstraintData::isRelative() {
|
|
||||||
return _relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TransformConstraintData::isLocal() {
|
|
||||||
return _local;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransformConstraintData::setTarget(BoneData *target) {
|
|
||||||
_target = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransformConstraintData::setMixRotate(float mixRotate) {
|
|
||||||
_mixRotate = mixRotate;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransformConstraintData::setMixX(float mixX) {
|
|
||||||
_mixX = mixX;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransformConstraintData::setMixY(float mixY) {
|
|
||||||
_mixY = mixY;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransformConstraintData::setMixScaleX(float mixScaleX) {
|
|
||||||
_mixScaleX = mixScaleX;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransformConstraintData::setMixScaleY(float mixScaleY) {
|
|
||||||
_mixScaleY = mixScaleY;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransformConstraintData::setMixShearY(float mixShearY) {
|
|
||||||
_mixShearY = mixShearY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformConstraintData::setOffsetRotation(float offsetRotation) {
|
void TransformConstraintData::setOffsetRotation(float offsetRotation) {
|
||||||
_offsetRotation = offsetRotation;
|
_offsets[0] = offsetRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getOffsetX() {
|
||||||
|
return _offsets[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformConstraintData::setOffsetX(float offsetX) {
|
void TransformConstraintData::setOffsetX(float offsetX) {
|
||||||
_offsetX = offsetX;
|
_offsets[1] = offsetX;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getOffsetY() {
|
||||||
|
return _offsets[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformConstraintData::setOffsetY(float offsetY) {
|
void TransformConstraintData::setOffsetY(float offsetY) {
|
||||||
_offsetY = offsetY;
|
_offsets[2] = offsetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getOffsetScaleX() {
|
||||||
|
return _offsets[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformConstraintData::setOffsetScaleX(float offsetScaleX) {
|
void TransformConstraintData::setOffsetScaleX(float offsetScaleX) {
|
||||||
_offsetScaleX = offsetScaleX;
|
_offsets[3] = offsetScaleX;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getOffsetScaleY() {
|
||||||
|
return _offsets[4];
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformConstraintData::setOffsetScaleY(float offsetScaleY) {
|
void TransformConstraintData::setOffsetScaleY(float offsetScaleY) {
|
||||||
_offsetScaleY = offsetScaleY;
|
_offsets[4] = offsetScaleY;
|
||||||
|
}
|
||||||
|
|
||||||
|
float TransformConstraintData::getOffsetShearY() {
|
||||||
|
return _offsets[5];
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformConstraintData::setOffsetShearY(float offsetShearY) {
|
void TransformConstraintData::setOffsetShearY(float offsetShearY) {
|
||||||
_offsetShearY = offsetShearY;
|
_offsets[5] = offsetShearY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformConstraintData::setRelative(bool isRelative) {
|
bool TransformConstraintData::getLocalSource() {
|
||||||
_relative = isRelative;
|
return _localSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformConstraintData::setLocal(bool isLocal) {
|
void TransformConstraintData::setLocalSource(bool localSource) {
|
||||||
_local = isLocal;
|
_localSource = localSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TransformConstraintData::getLocalTarget() {
|
||||||
|
return _localTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setLocalTarget(bool localTarget) {
|
||||||
|
_localTarget = localTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TransformConstraintData::getAdditive() {
|
||||||
|
return _additive;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setAdditive(bool additive) {
|
||||||
|
_additive = additive;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TransformConstraintData::getClamp() {
|
||||||
|
return _clamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setClamp(bool clamp) {
|
||||||
|
_clamp = clamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<FromProperty*>& TransformConstraintData::getProperties() {
|
||||||
|
return _properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// Property Classes
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
RTTI_IMPL_NOPARENT(FromProperty)
|
||||||
|
|
||||||
|
FromProperty::FromProperty() : SpineObject(), offset(0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
FromProperty::~FromProperty() {
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL_NOPARENT(ToProperty)
|
||||||
|
|
||||||
|
ToProperty::ToProperty() : offset(0), max(0), scale(1) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ToProperty::~ToProperty() {
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(FromRotate, FromProperty)
|
||||||
|
|
||||||
|
float FromRotate::value(BonePose& source, bool local, float* offsets) {
|
||||||
|
if (local) return source.getRotation() + offsets[0];
|
||||||
|
float value = MathUtil::atan2(source._c, source._a) * MathUtil::Rad_Deg
|
||||||
|
+ (source._a * source._d - source._b * source._c > 0 ? offsets[0] : -offsets[0]);
|
||||||
|
if (value < 0) value += 360;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(ToRotate, ToProperty)
|
||||||
|
|
||||||
|
float ToRotate::mix(TransformConstraintPose& pose) {
|
||||||
|
return pose._mixRotate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToRotate::apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) {
|
||||||
|
if (local) {
|
||||||
|
if (!additive) value -= bone.getRotation();
|
||||||
|
bone.setRotation(bone.getRotation() + value * pose._mixRotate);
|
||||||
|
} else {
|
||||||
|
float a = bone._a, b = bone._b, c = bone._c, d = bone._d;
|
||||||
|
value *= MathUtil::Deg_Rad;
|
||||||
|
if (!additive) value -= MathUtil::atan2(c, a);
|
||||||
|
if (value > MathUtil::Pi)
|
||||||
|
value -= MathUtil::Pi * 2;
|
||||||
|
else if (value < -MathUtil::Pi)
|
||||||
|
value += MathUtil::Pi * 2;
|
||||||
|
value *= pose._mixRotate;
|
||||||
|
float cosVal = MathUtil::cos(value), sinVal = MathUtil::sin(value);
|
||||||
|
bone._a = cosVal * a - sinVal * c;
|
||||||
|
bone._b = cosVal * b - sinVal * d;
|
||||||
|
bone._c = sinVal * a + cosVal * c;
|
||||||
|
bone._d = sinVal * b + cosVal * d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(FromX, FromProperty)
|
||||||
|
|
||||||
|
float FromX::value(BonePose& source, bool local, float* offsets) {
|
||||||
|
return local ? source.getX() + offsets[1] : offsets[1] * source._a + offsets[2] * source._b + source.getWorldX();
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(ToX, ToProperty)
|
||||||
|
|
||||||
|
float ToX::mix(TransformConstraintPose& pose) {
|
||||||
|
return pose._mixX;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToX::apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) {
|
||||||
|
if (local) {
|
||||||
|
if (!additive) value -= bone.getX();
|
||||||
|
bone.setX(bone.getX() + value * pose._mixX);
|
||||||
|
} else {
|
||||||
|
if (!additive) value -= bone.getWorldX();
|
||||||
|
bone.setWorldX(bone.getWorldX() + value * pose._mixX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(FromY, FromProperty)
|
||||||
|
|
||||||
|
float FromY::value(BonePose& source, bool local, float* offsets) {
|
||||||
|
return local ? source.getY() + offsets[2] : offsets[1] * source._c + offsets[2] * source._d + source.getWorldY();
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(ToY, ToProperty)
|
||||||
|
|
||||||
|
float ToY::mix(TransformConstraintPose& pose) {
|
||||||
|
return pose._mixY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToY::apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) {
|
||||||
|
if (local) {
|
||||||
|
if (!additive) value -= bone.getY();
|
||||||
|
bone.setY(bone.getY() + value * pose._mixY);
|
||||||
|
} else {
|
||||||
|
if (!additive) value -= bone.getWorldY();
|
||||||
|
bone.setWorldY(bone.getWorldY() + value * pose._mixY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(FromScaleX, FromProperty)
|
||||||
|
|
||||||
|
float FromScaleX::value(BonePose& source, bool local, float* offsets) {
|
||||||
|
return (local ? source.getScaleX() : MathUtil::sqrt(source._a * source._a + source._c * source._c)) + offsets[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(ToScaleX, ToProperty)
|
||||||
|
|
||||||
|
float ToScaleX::mix(TransformConstraintPose& pose) {
|
||||||
|
return pose._mixScaleX;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToScaleX::apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) {
|
||||||
|
if (local) {
|
||||||
|
if (additive)
|
||||||
|
bone.setScaleX(bone.getScaleX() * (1 + ((value - 1) * pose._mixScaleX)));
|
||||||
|
else if (bone.getScaleX() != 0)
|
||||||
|
bone.setScaleX(bone.getScaleX() * (1 + (value / bone.getScaleX() - 1) * pose._mixScaleX));
|
||||||
|
} else {
|
||||||
|
float s;
|
||||||
|
if (additive)
|
||||||
|
s = 1 + (value - 1) * pose._mixScaleX;
|
||||||
|
else {
|
||||||
|
s = MathUtil::sqrt(bone._a * bone._a + bone._c * bone._c);
|
||||||
|
if (s != 0) s = 1 + (value / s - 1) * pose._mixScaleX;
|
||||||
|
}
|
||||||
|
bone._a *= s;
|
||||||
|
bone._c *= s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(FromScaleY, FromProperty)
|
||||||
|
|
||||||
|
float FromScaleY::value(BonePose& source, bool local, float* offsets) {
|
||||||
|
return (local ? source.getScaleY() : MathUtil::sqrt(source._b * source._b + source._d * source._d)) + offsets[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(ToScaleY, ToProperty)
|
||||||
|
|
||||||
|
float ToScaleY::mix(TransformConstraintPose& pose) {
|
||||||
|
return pose._mixScaleY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToScaleY::apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) {
|
||||||
|
if (local) {
|
||||||
|
if (additive)
|
||||||
|
bone.setScaleY(bone.getScaleY() * (1 + ((value - 1) * pose._mixScaleY)));
|
||||||
|
else if (bone.getScaleY() != 0)
|
||||||
|
bone.setScaleY(bone.getScaleY() * (1 + (value / bone.getScaleY() - 1) * pose._mixScaleY));
|
||||||
|
} else {
|
||||||
|
float s;
|
||||||
|
if (additive)
|
||||||
|
s = 1 + (value - 1) * pose._mixScaleY;
|
||||||
|
else {
|
||||||
|
s = MathUtil::sqrt(bone._b * bone._b + bone._d * bone._d);
|
||||||
|
if (s != 0) s = 1 + (value / s - 1) * pose._mixScaleY;
|
||||||
|
}
|
||||||
|
bone._b *= s;
|
||||||
|
bone._d *= s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(FromShearY, FromProperty)
|
||||||
|
|
||||||
|
float FromShearY::value(BonePose& source, bool local, float* offsets) {
|
||||||
|
return (local ? source.getShearY() : (MathUtil::atan2(source._d, source._b) - MathUtil::atan2(source._c, source._a)) * MathUtil::Rad_Deg - 90) + offsets[5];
|
||||||
|
}
|
||||||
|
|
||||||
|
RTTI_IMPL(ToShearY, ToProperty)
|
||||||
|
|
||||||
|
float ToShearY::mix(TransformConstraintPose& pose) {
|
||||||
|
return pose._mixShearY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToShearY::apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) {
|
||||||
|
if (local) {
|
||||||
|
if (!additive) value -= bone.getShearY();
|
||||||
|
bone.setShearY(bone.getShearY() + value * pose._mixShearY);
|
||||||
|
} else {
|
||||||
|
float b = bone._b, d = bone._d, by = MathUtil::atan2(d, b);
|
||||||
|
value = (value + 90) * MathUtil::Deg_Rad;
|
||||||
|
if (additive)
|
||||||
|
value -= MathUtil::Pi / 2;
|
||||||
|
else {
|
||||||
|
value -= by - MathUtil::atan2(bone._c, bone._a);
|
||||||
|
if (value > MathUtil::Pi)
|
||||||
|
value -= MathUtil::Pi * 2;
|
||||||
|
else if (value < -MathUtil::Pi)
|
||||||
|
value += MathUtil::Pi * 2;
|
||||||
|
}
|
||||||
|
value = by + value * pose._mixShearY;
|
||||||
|
float s = MathUtil::sqrt(b * b + d * d);
|
||||||
|
bone._b = MathUtil::cos(value) * s;
|
||||||
|
bone._d = MathUtil::sin(value) * s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TransformConstraintData::~TransformConstraintData() {
|
||||||
|
// Clean up all FromProperty objects, which will in turn clean up their ToProperty objects
|
||||||
|
for (size_t i = 0; i < _properties.size(); i++) {
|
||||||
|
FromProperty* fromProp = _properties[i];
|
||||||
|
if (fromProp) {
|
||||||
|
// Clean up the ToProperty objects in the FromProperty
|
||||||
|
ContainerUtil::cleanUpVectorOfPointers(fromProp->to);
|
||||||
|
delete fromProp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_properties.clear();
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user