diff --git a/spine-cpp/spine-cpp/include/spine/ConstraintData.h b/spine-cpp/spine-cpp/include/spine/ConstraintData.h index c3c6dcf4d..e69837cba 100644 --- a/spine-cpp/spine-cpp/include/spine/ConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/ConstraintData.h @@ -45,7 +45,7 @@ namespace spine { friend class SkeletonJson; public: - ConstraintData(const String &name, P* setup); + ConstraintData(const String &name); virtual ~ConstraintData(); /// Creates a constraint instance. @@ -53,7 +53,7 @@ namespace spine { }; template - ConstraintData::ConstraintData(const String &name, P* setup) : PosedData

(name, setup) { + ConstraintData::ConstraintData(const String &name) : PosedData

(name) { } template diff --git a/spine-cpp/spine-cpp/include/spine/PathConstraintData.h b/spine-cpp/spine-cpp/include/spine/PathConstraintData.h index b018ad3a6..d6a1771bf 100644 --- a/spine-cpp/spine-cpp/include/spine/PathConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/PathConstraintData.h @@ -30,20 +30,49 @@ #ifndef Spine_PathConstraintData_h #define Spine_PathConstraintData_h -#include -#include -#include -#include -#include -#include #include +#include namespace spine { class BoneData; - class SlotData; + class PathConstraint; + class PathConstraintPose; + class Skeleton; - class SP_API PathConstraintData : public ConstraintData { + /// Controls how the first bone is positioned along the path. + /// + /// See https://esotericsoftware.com/spine-path-constraints#Position-mode Position mode in the Spine User Guide. + enum PositionMode { + PositionMode_Fixed, + PositionMode_Percent + }; + + /// Controls how bones after the first bone are positioned along the path. + /// + /// See https://esotericsoftware.com/spine-path-constraints#Spacing-mode Spacing mode in the Spine User Guide. + enum SpacingMode { + SpacingMode_Length, + SpacingMode_Fixed, + SpacingMode_Percent, + SpacingMode_Proportional + }; + + /// Controls how bones are rotated, translated, and scaled to match the path. + /// + /// See https://esotericsoftware.com/spine-path-constraints#Rotate-Mix Rotate mode in the Spine User Guide. + enum RotateMode { + RotateMode_Tangent, + RotateMode_Chain, + /// When chain scale, constrained bones should all have the same parent. That way when the path constraint scales a bone, it + /// doesn't affect other constrained bones. + RotateMode_ChainScale + }; + + /// 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 ConstraintData { friend class SkeletonBinary; friend class SkeletonJson; @@ -62,57 +91,42 @@ namespace spine { explicit PathConstraintData(const String &name); + + /// The bones that will be modified by this path constraint. Vector &getBones(); - SlotData *getTarget(); + /// The slot whose path attachment will be used to constrained the bones. + SlotData *getSlot(); - void setTarget(SlotData *inValue); + void setSlot(SlotData *slot); + /// The mode for positioning the first bone on the path. PositionMode getPositionMode(); - void setPositionMode(PositionMode inValue); + void setPositionMode(PositionMode positionMode); + /// The mode for positioning the bones after the first bone on the path. SpacingMode getSpacingMode(); - void setSpacingMode(SpacingMode inValue); + void setSpacingMode(SpacingMode spacingMode); + /// The mode for adjusting the rotation of the bones. RotateMode getRotateMode(); - void setRotateMode(RotateMode inValue); + void setRotateMode(RotateMode rotateMode); + /// An offset added to the constrained bone rotation. float getOffsetRotation(); - void setOffsetRotation(float inValue); - - float getPosition(); - - void setPosition(float inValue); - - float getSpacing(); - - void setSpacing(float inValue); - - float getMixRotate(); - - void setMixRotate(float inValue); - - float getMixX(); - - void setMixX(float inValue); - - float getMixY(); - - void setMixY(float inValue); + void setOffsetRotation(float offsetRotation); private: Vector _bones; - SlotData *_target; + SlotData *_slot; PositionMode _positionMode; SpacingMode _spacingMode; RotateMode _rotateMode; float _offsetRotation; - float _position, _spacing; - float _mixRotate, _mixX, _mixY; }; } diff --git a/spine-cpp/spine-cpp/include/spine/PosedData.h b/spine-cpp/spine-cpp/include/spine/PosedData.h index fb4b33fa6..2a2c405a8 100644 --- a/spine-cpp/spine-cpp/include/spine/PosedData.h +++ b/spine-cpp/spine-cpp/include/spine/PosedData.h @@ -64,17 +64,17 @@ namespace spine { private: spine::String _name; - P* _setup; + P _setup; bool _skinRequired; public: - PosedData(const spine::String& name, P* setup); + PosedData(const spine::String& name); virtual ~PosedData(); /// The constraint's name, which is unique across all constraints in the skeleton of the same type. const spine::String& getName(); - P* getSetupPose(); + P& getSetupPose(); /// When true, Skeleton::updateWorldTransform(Physics) only updates this constraint if the Skeleton::getSkin() /// contains this constraint. @@ -87,12 +87,11 @@ namespace spine { }; template - PosedData

::PosedData(const spine::String& name, P* setup) : _name(name), _setup(setup), _skinRequired(false) { + PosedData

::PosedData(const spine::String& name) : _name(name), _setup(), _skinRequired(false) { } template PosedData

::~PosedData() { - delete _setup; } template @@ -101,7 +100,7 @@ namespace spine { } template - P* PosedData

::getSetupPose() { + P& PosedData

::getSetupPose() { return _setup; } diff --git a/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp index 6d13223bc..8d08f9891 100644 --- a/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp +++ b/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp @@ -28,109 +28,65 @@ *****************************************************************************/ #include - +#include +#include #include #include - -#include +#include using namespace spine; -RTTI_IMPL(PathConstraintData, ConstraintData) +RTTI_IMPL_NOPARENT(PathConstraintData) -PathConstraintData::PathConstraintData(const String &name) : ConstraintData(name), - _target(NULL), +PathConstraintData::PathConstraintData(const String &name) : ConstraintData(name), + _slot(NULL), _positionMode(PositionMode_Fixed), _spacingMode(SpacingMode_Length), _rotateMode(RotateMode_Tangent), - _offsetRotation(0), - _position(0), - _spacing(0), - _mixRotate(0), - _mixX(0), - _mixY(0) { + _offsetRotation(0) { } + Vector &PathConstraintData::getBones() { return _bones; } -SlotData *PathConstraintData::getTarget() { - return _target; +SlotData *PathConstraintData::getSlot() { + return _slot; } -void PathConstraintData::setTarget(SlotData *inValue) { - _target = inValue; +void PathConstraintData::setSlot(SlotData *slot) { + _slot = slot; } PositionMode PathConstraintData::getPositionMode() { return _positionMode; } -void PathConstraintData::setPositionMode(PositionMode inValue) { - _positionMode = inValue; +void PathConstraintData::setPositionMode(PositionMode positionMode) { + _positionMode = positionMode; } SpacingMode PathConstraintData::getSpacingMode() { return _spacingMode; } -void PathConstraintData::setSpacingMode(SpacingMode inValue) { - _spacingMode = inValue; +void PathConstraintData::setSpacingMode(SpacingMode spacingMode) { + _spacingMode = spacingMode; } RotateMode PathConstraintData::getRotateMode() { return _rotateMode; } -void PathConstraintData::setRotateMode(RotateMode inValue) { - _rotateMode = inValue; +void PathConstraintData::setRotateMode(RotateMode rotateMode) { + _rotateMode = rotateMode; } float PathConstraintData::getOffsetRotation() { return _offsetRotation; } -void PathConstraintData::setOffsetRotation(float inValue) { - _offsetRotation = inValue; -} - -float PathConstraintData::getPosition() { - return _position; -} - -void PathConstraintData::setPosition(float inValue) { - _position = inValue; -} - -float PathConstraintData::getSpacing() { - return _spacing; -} - -void PathConstraintData::setSpacing(float inValue) { - _spacing = inValue; -} - -float PathConstraintData::getMixRotate() { - return _mixRotate; -} - -void PathConstraintData::setMixRotate(float inValue) { - _mixRotate = inValue; -} - -float PathConstraintData::getMixX() { - return _mixX; -} - -void PathConstraintData::setMixX(float inValue) { - _mixX = inValue; -} - -float PathConstraintData::getMixY() { - return _mixY; -} - -void PathConstraintData::setMixY(float inValue) { - _mixY = inValue; -} +void PathConstraintData::setOffsetRotation(float offsetRotation) { + _offsetRotation = offsetRotation; +} \ No newline at end of file