[cpp] 4.3 porting WIP

This commit is contained in:
Mario Zechner 2025-06-11 20:09:55 +02:00
parent 5cd55f83c9
commit df13ca0815
4 changed files with 79 additions and 110 deletions

View File

@ -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<class T, class P>
ConstraintData<T, P>::ConstraintData(const String &name, P* setup) : PosedData<P>(name, setup) {
ConstraintData<T, P>::ConstraintData(const String &name) : PosedData<P>(name) {
}
template<class T, class P>

View File

@ -30,20 +30,49 @@
#ifndef Spine_PathConstraintData_h
#define Spine_PathConstraintData_h
#include <spine/PositionMode.h>
#include <spine/SpacingMode.h>
#include <spine/RotateMode.h>
#include <spine/Vector.h>
#include <spine/SpineObject.h>
#include <spine/SpineString.h>
#include <spine/ConstraintData.h>
#include <spine/Vector.h>
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<PathConstraint, PathConstraintPose> {
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<BoneData *> &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<BoneData *> _bones;
SlotData *_target;
SlotData *_slot;
PositionMode _positionMode;
SpacingMode _spacingMode;
RotateMode _rotateMode;
float _offsetRotation;
float _position, _spacing;
float _mixRotate, _mixX, _mixY;
};
}

View File

@ -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<class P>
PosedData<P>::PosedData(const spine::String& name, P* setup) : _name(name), _setup(setup), _skinRequired(false) {
PosedData<P>::PosedData(const spine::String& name) : _name(name), _setup(), _skinRequired(false) {
}
template<class P>
PosedData<P>::~PosedData() {
delete _setup;
}
template<class P>
@ -101,7 +100,7 @@ namespace spine {
}
template<class P>
P* PosedData<P>::getSetupPose() {
P& PosedData<P>::getSetupPose() {
return _setup;
}

View File

@ -28,109 +28,65 @@
*****************************************************************************/
#include <spine/PathConstraintData.h>
#include <spine/PathConstraint.h>
#include <spine/PathConstraintPose.h>
#include <spine/BoneData.h>
#include <spine/SlotData.h>
#include <assert.h>
#include <spine/Skeleton.h>
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<PathConstraint, PathConstraintPose>(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<BoneData *> &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;
}