From 5fe90b456f68f00d3d9106f8f620c587dfeda931 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Tue, 10 Jun 2025 15:21:41 +0200 Subject: [PATCH] [cpp] 4.3 porting WIP --- spine-cpp/spine-cpp/include/spine/BoneData.h | 71 ++---------- spine-cpp/spine-cpp/include/spine/PosedData.h | 1 + .../spine-cpp/include/spine/ToProperty.h | 62 +++++++++++ spine-cpp/spine-cpp/include/spine/spine.h | 1 + spine-cpp/spine-cpp/src/spine/BoneData.cpp | 104 ++---------------- spine-cpp/spine-cpp/src/spine/ToProperty.cpp | 38 +++++++ 6 files changed, 123 insertions(+), 154 deletions(-) create mode 100644 spine-cpp/spine-cpp/include/spine/ToProperty.h create mode 100644 spine-cpp/spine-cpp/src/spine/ToProperty.cpp diff --git a/spine-cpp/spine-cpp/include/spine/BoneData.h b/spine-cpp/spine-cpp/include/spine/BoneData.h index eb53487dd..bedcbacd6 100644 --- a/spine-cpp/spine-cpp/include/spine/BoneData.h +++ b/spine-cpp/spine-cpp/include/spine/BoneData.h @@ -30,13 +30,15 @@ #ifndef Spine_BoneData_h #define Spine_BoneData_h -#include -#include +#include +#include #include #include +#include namespace spine { - class SP_API BoneData : public SpineObject { + class SP_API BoneData : public PosedData { + RTTI_DECL friend class SkeletonBinary; friend class SkeletonJson; @@ -69,9 +71,6 @@ namespace spine { /// The index of the bone in Skeleton.Bones int getIndex(); - /// The name of the bone, which is unique within the skeleton. - const String &getName(); - /// May be NULL. BoneData *getParent(); @@ -79,71 +78,23 @@ namespace spine { void setLength(float inValue); - /// Local X translation. - float getX(); - - void setX(float inValue); - - /// Local Y translation. - float getY(); - - void setY(float inValue); - - /// Local rotation. - float getRotation(); - - void setRotation(float inValue); - - /// Local scaleX. - float getScaleX(); - - void setScaleX(float inValue); - - /// Local scaleY. - float getScaleY(); - - void setScaleY(float inValue); - - /// Local shearX. - float getShearX(); - - void setShearX(float inValue); - - /// Local shearY. - float getShearY(); - - void setShearY(float inValue); - - /// The transform mode for how parent world transforms affect this bone. - Inherit getInherit(); - - void setInherit(Inherit inValue); - - bool isSkinRequired(); - - void setSkinRequired(bool inValue); - Color &getColor(); - const String &getIcon(); + const String &getIcon(); - void setIcon(const String &icon); + void setIcon(const String &icon); - bool isVisible(); + bool isVisible(); - void setVisible(bool inValue); + void setVisible(bool inValue); private: const int _index; - const String _name; BoneData *_parent; float _length; - float _x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY; - Inherit _inherit; - bool _skinRequired; Color _color; - String _icon; - bool _visible; + String _icon; + bool _visible; }; } diff --git a/spine-cpp/spine-cpp/include/spine/PosedData.h b/spine-cpp/spine-cpp/include/spine/PosedData.h index 8cbd4dbd0..edb7423ab 100644 --- a/spine-cpp/spine-cpp/include/spine/PosedData.h +++ b/spine-cpp/spine-cpp/include/spine/PosedData.h @@ -70,6 +70,7 @@ namespace spine { template PosedData

::~PosedData() { + delete _setup; } template diff --git a/spine-cpp/spine-cpp/include/spine/ToProperty.h b/spine-cpp/spine-cpp/include/spine/ToProperty.h new file mode 100644 index 000000000..72d7345b8 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/ToProperty.h @@ -0,0 +1,62 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, 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_TOPROPERTY_H_ +#define SPINE_TOPROPERTY_H_ + +#include + +namespace spine { + class TransformConstraintPose; + class BonePose; + + /// Constrained property for a TransformConstraint. + class SP_API ToProperty { + public: + ToProperty(); + virtual ~ToProperty(); + + /// The value of this property that corresponds to FromProperty::offset. + float offset; + + /// The maximum value of this property when TransformConstraintData::clamp clamped. + float max; + + /// The scale of the FromProperty value in relation to this property. + float scale; + + /// 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; + }; +} + +#endif /* SPINE_TOPROPERTY_H_ */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/spine.h b/spine-cpp/spine-cpp/include/spine/spine.h index afde87069..6456a67e0 100644 --- a/spine-cpp/spine-cpp/include/spine/spine.h +++ b/spine-cpp/spine-cpp/include/spine/spine.h @@ -123,6 +123,7 @@ #include #include #include +#include #include #include #include diff --git a/spine-cpp/spine-cpp/src/spine/BoneData.cpp b/spine-cpp/spine-cpp/src/spine/BoneData.cpp index 31ab264ef..e9b5fa479 100644 --- a/spine-cpp/spine-cpp/src/spine/BoneData.cpp +++ b/spine-cpp/spine-cpp/src/spine/BoneData.cpp @@ -33,34 +33,22 @@ using namespace spine; -BoneData::BoneData(int index, const String &name, BoneData *parent) : _index(index), - _name(name), - _parent(parent), - _length(0), - _x(0), - _y(0), - _rotation(0), - _scaleX(1), - _scaleY(1), - _shearX(0), - _shearY(0), - _inherit(Inherit_Normal), - _skinRequired(false), - _color(), - _icon(), - _visible(true) { +RTTI_IMPL_NOPARENT(BoneData) + +BoneData::BoneData(int index, const String &name, BoneData *parent) : PosedData(name, new (__FILE__, __LINE__) BoneLocal()), + _index(index), + _parent(parent), + _length(0), + _color(0.61f, 0.61f, 0.61f, 1.0f), + _icon(), + _visible(true) { assert(index >= 0); - assert(_name.length() > 0); } int BoneData::getIndex() { return _index; } -const String &BoneData::getName() { - return _name; -} - BoneData *BoneData::getParent() { return _parent; } @@ -73,78 +61,6 @@ void BoneData::setLength(float inValue) { _length = inValue; } -float BoneData::getX() { - return _x; -} - -void BoneData::setX(float inValue) { - _x = inValue; -} - -float BoneData::getY() { - return _y; -} - -void BoneData::setY(float inValue) { - _y = inValue; -} - -float BoneData::getRotation() { - return _rotation; -} - -void BoneData::setRotation(float inValue) { - _rotation = inValue; -} - -float BoneData::getScaleX() { - return _scaleX; -} - -void BoneData::setScaleX(float inValue) { - _scaleX = inValue; -} - -float BoneData::getScaleY() { - return _scaleY; -} - -void BoneData::setScaleY(float inValue) { - _scaleY = inValue; -} - -float BoneData::getShearX() { - return _shearX; -} - -void BoneData::setShearX(float inValue) { - _shearX = inValue; -} - -float BoneData::getShearY() { - return _shearY; -} - -void BoneData::setShearY(float inValue) { - _shearY = inValue; -} - -Inherit BoneData::getInherit() { - return _inherit; -} - -void BoneData::setInherit(Inherit inValue) { - _inherit = inValue; -} - -bool BoneData::isSkinRequired() { - return _skinRequired; -} - -void BoneData::setSkinRequired(bool inValue) { - _skinRequired = inValue; -} - Color &BoneData::getColor() { return _color; } @@ -163,4 +79,4 @@ bool BoneData::isVisible() { void BoneData::setVisible(bool inValue) { this->_visible = inValue; -} +} \ No newline at end of file diff --git a/spine-cpp/spine-cpp/src/spine/ToProperty.cpp b/spine-cpp/spine-cpp/src/spine/ToProperty.cpp new file mode 100644 index 000000000..1481aabde --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/ToProperty.cpp @@ -0,0 +1,38 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, 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 + +using namespace spine; + +ToProperty::ToProperty() : offset(0), max(0), scale(1) { +} + +ToProperty::~ToProperty() { +} \ No newline at end of file