From 61126de9f3133cd6a0c94462a1304da32e299f5f Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Tue, 10 Jun 2025 16:49:03 +0200 Subject: [PATCH] [cpp] 4.3 porting WIP --- .../spine-cpp/include/spine/ToProperty.h | 4 ++ spine-cpp/spine-cpp/include/spine/ToRotate.h | 56 +++++++++++++++ spine-cpp/spine-cpp/include/spine/ToScaleX.h | 52 ++++++++++++++ spine-cpp/spine-cpp/include/spine/ToScaleY.h | 56 +++++++++++++++ spine-cpp/spine-cpp/include/spine/ToShearY.h | 56 +++++++++++++++ spine-cpp/spine-cpp/include/spine/ToX.h | 56 +++++++++++++++ spine-cpp/spine-cpp/include/spine/ToY.h | 56 +++++++++++++++ spine-cpp/spine-cpp/include/spine/spine.h | 6 ++ spine-cpp/spine-cpp/src/spine/ToProperty.cpp | 2 + spine-cpp/spine-cpp/src/spine/ToRotate.cpp | 68 ++++++++++++++++++ spine-cpp/spine-cpp/src/spine/ToScaleX.cpp | 66 +++++++++++++++++ spine-cpp/spine-cpp/src/spine/ToScaleY.cpp | 66 +++++++++++++++++ spine-cpp/spine-cpp/src/spine/ToShearY.cpp | 70 +++++++++++++++++++ spine-cpp/spine-cpp/src/spine/ToX.cpp | 56 +++++++++++++++ spine-cpp/spine-cpp/src/spine/ToY.cpp | 56 +++++++++++++++ 15 files changed, 726 insertions(+) create mode 100644 spine-cpp/spine-cpp/include/spine/ToRotate.h create mode 100644 spine-cpp/spine-cpp/include/spine/ToScaleX.h create mode 100644 spine-cpp/spine-cpp/include/spine/ToScaleY.h create mode 100644 spine-cpp/spine-cpp/include/spine/ToShearY.h create mode 100644 spine-cpp/spine-cpp/include/spine/ToX.h create mode 100644 spine-cpp/spine-cpp/include/spine/ToY.h create mode 100644 spine-cpp/spine-cpp/src/spine/ToRotate.cpp create mode 100644 spine-cpp/spine-cpp/src/spine/ToScaleX.cpp create mode 100644 spine-cpp/spine-cpp/src/spine/ToScaleY.cpp create mode 100644 spine-cpp/spine-cpp/src/spine/ToShearY.cpp create mode 100644 spine-cpp/spine-cpp/src/spine/ToX.cpp create mode 100644 spine-cpp/spine-cpp/src/spine/ToY.cpp diff --git a/spine-cpp/spine-cpp/include/spine/ToProperty.h b/spine-cpp/spine-cpp/include/spine/ToProperty.h index 72d7345b8..95973ac56 100644 --- a/spine-cpp/spine-cpp/include/spine/ToProperty.h +++ b/spine-cpp/spine-cpp/include/spine/ToProperty.h @@ -31,6 +31,7 @@ #define SPINE_TOPROPERTY_H_ #include +#include namespace spine { class TransformConstraintPose; @@ -38,10 +39,12 @@ namespace spine { /// Constrained property for a TransformConstraint. class SP_API ToProperty { + RTTI_DECL public: ToProperty(); virtual ~ToProperty(); + protected: /// The value of this property that corresponds to FromProperty::offset. float offset; @@ -51,6 +54,7 @@ namespace spine { /// The scale of the FromProperty value in relation to this property. float scale; + public: /// Reads the mix for this property from the specified pose. virtual float mix(TransformConstraintPose& pose) = 0; diff --git a/spine-cpp/spine-cpp/include/spine/ToRotate.h b/spine-cpp/spine-cpp/include/spine/ToRotate.h new file mode 100644 index 000000000..8be64cf3c --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/ToRotate.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * 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 + * 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_TOROTATE_H_ +#define SPINE_TOROTATE_H_ + +#include +#include +#include + +namespace spine { + class TransformConstraintPose; + class BonePose; + + class SP_API ToRotate : public ToProperty { + RTTI_DECL + + public: + ToRotate(); + virtual ~ToRotate(); + + /// Returns the mix rotation value from the pose. + virtual float mix(TransformConstraintPose& pose) override; + + /// Applies the rotation value to the bone. + virtual void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) override; + }; +} + +#endif /* SPINE_TOROTATE_H_ */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/ToScaleX.h b/spine-cpp/spine-cpp/include/spine/ToScaleX.h new file mode 100644 index 000000000..eff89d270 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/ToScaleX.h @@ -0,0 +1,52 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * 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 + * 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_TOSCALEX_H_ +#define SPINE_TOSCALEX_H_ + +#include +#include + +namespace spine { + class TransformConstraintPose; + class BonePose; + + class SP_API ToScaleX : public ToProperty { + RTTI_DECL + public: + ToScaleX(); + virtual ~ToScaleX(); + + virtual float mix(TransformConstraintPose& pose) override; + + virtual void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) override; + }; +} + +#endif /* SPINE_TOSCALEX_H_ */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/ToScaleY.h b/spine-cpp/spine-cpp/include/spine/ToScaleY.h new file mode 100644 index 000000000..d7b795184 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/ToScaleY.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * 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 + * 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_TOSCALEY_H_ +#define SPINE_TOSCALEY_H_ + +#include +#include +#include + +namespace spine { + class TransformConstraintPose; + class BonePose; + + class SP_API ToScaleY : public ToProperty { + RTTI_DECL + + public: + ToScaleY(); + virtual ~ToScaleY(); + + /// Returns the mix scale Y value from the pose. + virtual float mix(TransformConstraintPose& pose) override; + + /// Applies the scale Y value to the bone. + virtual void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) override; + }; +} + +#endif /* SPINE_TOSCALEY_H_ */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/ToShearY.h b/spine-cpp/spine-cpp/include/spine/ToShearY.h new file mode 100644 index 000000000..e8c3e67a7 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/ToShearY.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * 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 + * 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_TOSHEARY_H_ +#define SPINE_TOSHEARY_H_ + +#include +#include +#include + +namespace spine { + class TransformConstraintPose; + class BonePose; + + class SP_API ToShearY : public ToProperty { + RTTI_DECL + + public: + ToShearY(); + virtual ~ToShearY(); + + /// Returns the mix shear Y value from the pose. + virtual float mix(TransformConstraintPose& pose) override; + + /// Applies the shear Y value to the bone. + virtual void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) override; + }; +} + +#endif /* SPINE_TOSHEARY_H_ */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/ToX.h b/spine-cpp/spine-cpp/include/spine/ToX.h new file mode 100644 index 000000000..63e4135c8 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/ToX.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * 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 + * 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_TOX_H_ +#define SPINE_TOX_H_ + +#include +#include +#include + +namespace spine { + class TransformConstraintPose; + class BonePose; + + class SP_API ToX : public ToProperty { + RTTI_DECL + + public: + ToX(); + virtual ~ToX(); + + /// Returns the mix X value from the pose. + virtual float mix(TransformConstraintPose& pose) override; + + /// Applies the X value to the bone. + virtual void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) override; + }; +} + +#endif /* SPINE_TOX_H_ */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/ToY.h b/spine-cpp/spine-cpp/include/spine/ToY.h new file mode 100644 index 000000000..9792b6ad0 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/ToY.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * 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 + * 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_TOY_H_ +#define SPINE_TOY_H_ + +#include +#include +#include + +namespace spine { + class TransformConstraintPose; + class BonePose; + + class SP_API ToY : public ToProperty { + RTTI_DECL + + public: + ToY(); + virtual ~ToY(); + + /// Returns the mix Y value from the pose. + virtual float mix(TransformConstraintPose& pose) override; + + /// Applies the Y value to the bone. + virtual void apply(TransformConstraintPose& pose, BonePose& bone, float value, bool local, bool additive) override; + }; +} + +#endif /* SPINE_TOY_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 d723575af..7ae6c496c 100644 --- a/spine-cpp/spine-cpp/include/spine/spine.h +++ b/spine-cpp/spine-cpp/include/spine/spine.h @@ -126,6 +126,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/spine-cpp/spine-cpp/src/spine/ToProperty.cpp b/spine-cpp/spine-cpp/src/spine/ToProperty.cpp index 1481aabde..7d5b40406 100644 --- a/spine-cpp/spine-cpp/src/spine/ToProperty.cpp +++ b/spine-cpp/spine-cpp/src/spine/ToProperty.cpp @@ -31,6 +31,8 @@ using namespace spine; +RTTI_IMPL_NOPARENT(ToProperty) + ToProperty::ToProperty() : offset(0), max(0), scale(1) { } diff --git a/spine-cpp/spine-cpp/src/spine/ToRotate.cpp b/spine-cpp/spine-cpp/src/spine/ToRotate.cpp new file mode 100644 index 000000000..122cafd16 --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/ToRotate.cpp @@ -0,0 +1,68 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * 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 + * 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 +#include +#include +#include + +using namespace spine; + +RTTI_IMPL(ToRotate, ToProperty) + +ToRotate::ToRotate() { +} + +ToRotate::~ToRotate() { +} + +float ToRotate::mix(TransformConstraintPose& pose) { + return pose.getMixRotate(); +} + +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.getMixRotate()); + } 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.getMixRotate(); + 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; + } +} \ No newline at end of file diff --git a/spine-cpp/spine-cpp/src/spine/ToScaleX.cpp b/spine-cpp/spine-cpp/src/spine/ToScaleX.cpp new file mode 100644 index 000000000..07f6be13a --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/ToScaleX.cpp @@ -0,0 +1,66 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * 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 + * 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 +#include +#include +#include + +using namespace spine; + +RTTI_IMPL(ToScaleX, ToProperty) + +ToScaleX::ToScaleX() { +} + +ToScaleX::~ToScaleX() { +} + +float ToScaleX::mix(TransformConstraintPose& pose) { + return pose.getMixScaleX(); +} + +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.getMixScaleX()))); + else if (bone.getScaleX() != 0) + bone.setScaleX(1 + (value / bone.getScaleX() - 1) * pose.getMixScaleX()); + } else { + float s; + if (additive) + s = 1 + (value - 1) * pose.getMixScaleX(); + else { + s = MathUtil::sqrt(bone._a * bone._a + bone._c * bone._c); + if (s != 0) s = 1 + (value / s - 1) * pose.getMixScaleX(); + } + bone._a *= s; + bone._c *= s; + } +} \ No newline at end of file diff --git a/spine-cpp/spine-cpp/src/spine/ToScaleY.cpp b/spine-cpp/spine-cpp/src/spine/ToScaleY.cpp new file mode 100644 index 000000000..ecfe4fa4c --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/ToScaleY.cpp @@ -0,0 +1,66 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * 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 + * 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 +#include +#include +#include + +using namespace spine; + +RTTI_IMPL(ToScaleY, ToProperty) + +ToScaleY::ToScaleY() { +} + +ToScaleY::~ToScaleY() { +} + +float ToScaleY::mix(TransformConstraintPose& pose) { + return pose.getMixScaleY(); +} + +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.getMixScaleY()))); + else if (bone.getScaleY() != 0) + bone.setScaleY(1 + (value / bone.getScaleY() - 1) * pose.getMixScaleY()); + } else { + float s; + if (additive) + s = 1 + (value - 1) * pose.getMixScaleY(); + else { + s = MathUtil::sqrt(bone._b * bone._b + bone._d * bone._d); + if (s != 0) s = 1 + (value / s - 1) * pose.getMixScaleY(); + } + bone._b *= s; + bone._d *= s; + } +} \ No newline at end of file diff --git a/spine-cpp/spine-cpp/src/spine/ToShearY.cpp b/spine-cpp/spine-cpp/src/spine/ToShearY.cpp new file mode 100644 index 000000000..0611f81df --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/ToShearY.cpp @@ -0,0 +1,70 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * 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 + * 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 +#include +#include +#include + +using namespace spine; + +RTTI_IMPL(ToShearY, ToProperty) + +ToShearY::ToShearY() { +} + +ToShearY::~ToShearY() { +} + +float ToShearY::mix(TransformConstraintPose& pose) { + return pose.getMixShearY(); +} + +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.getMixShearY()); + } 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.getMixShearY(); + float s = MathUtil::sqrt(b * b + d * d); + bone._b = MathUtil::cos(value) * s; + bone._d = MathUtil::sin(value) * s; + } +} \ No newline at end of file diff --git a/spine-cpp/spine-cpp/src/spine/ToX.cpp b/spine-cpp/spine-cpp/src/spine/ToX.cpp new file mode 100644 index 000000000..9423727a9 --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/ToX.cpp @@ -0,0 +1,56 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * 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 + * 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 +#include +#include + +using namespace spine; + +RTTI_IMPL(ToX, ToProperty) + +ToX::ToX() { +} + +ToX::~ToX() { +} + +float ToX::mix(TransformConstraintPose& pose) { + return pose.getMixX(); +} + +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.getMixX()); + } else { + if (!additive) value -= bone.getWorldX(); + bone.setWorldX(bone.getWorldX() + value * pose.getMixX()); + } +} \ No newline at end of file diff --git a/spine-cpp/spine-cpp/src/spine/ToY.cpp b/spine-cpp/spine-cpp/src/spine/ToY.cpp new file mode 100644 index 000000000..6b767c2da --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/ToY.cpp @@ -0,0 +1,56 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * 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 + * 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 +#include +#include + +using namespace spine; + +RTTI_IMPL(ToY, ToProperty) + +ToY::ToY() { +} + +ToY::~ToY() { +} + +float ToY::mix(TransformConstraintPose& pose) { + return pose.getMixY(); +} + +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.getMixY()); + } else { + if (!additive) value -= bone.getWorldY(); + bone.setWorldY(bone.getWorldY() + value * pose.getMixY()); + } +} \ No newline at end of file