From 0f5cc0b766a41363de64c4d1b1a2aec061b8ef4c Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Tue, 10 Jun 2025 14:16:46 +0200 Subject: [PATCH] [cpp] 4.3 porting WIP --- .../spine-cpp/include/spine/FromProperty.h | 5 +- .../spine-cpp/include/spine/FromRotate.h | 49 +++++++++++++++++++ .../spine-cpp/include/spine/FromScaleX.h | 49 +++++++++++++++++++ .../spine-cpp/include/spine/FromScaleY.h | 49 +++++++++++++++++++ .../spine-cpp/include/spine/FromShearY.h | 49 +++++++++++++++++++ spine-cpp/spine-cpp/include/spine/FromX.h | 49 +++++++++++++++++++ spine-cpp/spine-cpp/include/spine/FromY.h | 49 +++++++++++++++++++ .../spine-cpp/include/spine/PointAttachment.h | 8 +-- spine-cpp/spine-cpp/include/spine/spine.h | 6 +++ .../spine-cpp/src/spine/FromProperty.cpp | 4 +- spine-cpp/spine-cpp/src/spine/FromRotate.cpp | 47 ++++++++++++++++++ spine-cpp/spine-cpp/src/spine/FromScaleX.cpp | 43 ++++++++++++++++ spine-cpp/spine-cpp/src/spine/FromScaleY.cpp | 43 ++++++++++++++++ spine-cpp/spine-cpp/src/spine/FromShearY.cpp | 43 ++++++++++++++++ spine-cpp/spine-cpp/src/spine/FromX.cpp | 42 ++++++++++++++++ spine-cpp/spine-cpp/src/spine/FromY.cpp | 42 ++++++++++++++++ .../spine-cpp/src/spine/PointAttachment.cpp | 26 +++++----- 17 files changed, 585 insertions(+), 18 deletions(-) create mode 100644 spine-cpp/spine-cpp/include/spine/FromRotate.h create mode 100644 spine-cpp/spine-cpp/include/spine/FromScaleX.h create mode 100644 spine-cpp/spine-cpp/include/spine/FromScaleY.h create mode 100644 spine-cpp/spine-cpp/include/spine/FromShearY.h create mode 100644 spine-cpp/spine-cpp/include/spine/FromX.h create mode 100644 spine-cpp/spine-cpp/include/spine/FromY.h create mode 100644 spine-cpp/spine-cpp/src/spine/FromRotate.cpp create mode 100644 spine-cpp/spine-cpp/src/spine/FromScaleX.cpp create mode 100644 spine-cpp/spine-cpp/src/spine/FromScaleY.cpp create mode 100644 spine-cpp/spine-cpp/src/spine/FromShearY.cpp create mode 100644 spine-cpp/spine-cpp/src/spine/FromX.cpp create mode 100644 spine-cpp/spine-cpp/src/spine/FromY.cpp diff --git a/spine-cpp/spine-cpp/include/spine/FromProperty.h b/spine-cpp/spine-cpp/include/spine/FromProperty.h index 9de7a72d6..acb64a8cf 100644 --- a/spine-cpp/spine-cpp/include/spine/FromProperty.h +++ b/spine-cpp/spine-cpp/include/spine/FromProperty.h @@ -32,13 +32,16 @@ #include #include +#include +#include namespace spine { class ToProperty; class BonePose; /// Source property for a TransformConstraint. - class SP_API FromProperty { + class SP_API FromProperty : public SpineObject { + RTTI_DECL public: FromProperty(); virtual ~FromProperty(); diff --git a/spine-cpp/spine-cpp/include/spine/FromRotate.h b/spine-cpp/spine-cpp/include/spine/FromRotate.h new file mode 100644 index 000000000..779f5d1e3 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/FromRotate.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * 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_FROMROTATE_H_ +#define SPINE_FROMROTATE_H_ + +#include +#include +#include + +namespace spine { + class BonePose; + + class SP_API FromRotate : public FromProperty { + RTTI_DECL + public: + FromRotate(); + + virtual float value(BonePose& source, bool local, Vector& offsets) override; + }; +} + +#endif /* SPINE_FROMROTATE_H_ */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/FromScaleX.h b/spine-cpp/spine-cpp/include/spine/FromScaleX.h new file mode 100644 index 000000000..98444d888 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/FromScaleX.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * 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_FROMSCALEX_H_ +#define SPINE_FROMSCALEX_H_ + +#include +#include +#include + +namespace spine { + class BonePose; + + class SP_API FromScaleX : public FromProperty { + RTTI_DECL + public: + FromScaleX(); + + virtual float value(BonePose& source, bool local, Vector& offsets) override; + }; +} + +#endif /* SPINE_FROMSCALEX_H_ */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/FromScaleY.h b/spine-cpp/spine-cpp/include/spine/FromScaleY.h new file mode 100644 index 000000000..d37f0802e --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/FromScaleY.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * 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_FROMSCALEY_H_ +#define SPINE_FROMSCALEY_H_ + +#include +#include +#include + +namespace spine { + class BonePose; + + class SP_API FromScaleY : public FromProperty { + RTTI_DECL + public: + FromScaleY(); + + virtual float value(BonePose& source, bool local, Vector& offsets) override; + }; +} + +#endif /* SPINE_FROMSCALEY_H_ */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/FromShearY.h b/spine-cpp/spine-cpp/include/spine/FromShearY.h new file mode 100644 index 000000000..071c6351c --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/FromShearY.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * 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_FROMSHEARY_H_ +#define SPINE_FROMSHEARY_H_ + +#include +#include +#include + +namespace spine { + class BonePose; + + class SP_API FromShearY : public FromProperty { + RTTI_DECL + public: + FromShearY(); + + virtual float value(BonePose& source, bool local, Vector& offsets) override; + }; +} + +#endif /* SPINE_FROMSHEARY_H_ */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/FromX.h b/spine-cpp/spine-cpp/include/spine/FromX.h new file mode 100644 index 000000000..941761d27 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/FromX.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * 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_FROMX_H_ +#define SPINE_FROMX_H_ + +#include +#include +#include + +namespace spine { + class BonePose; + + class SP_API FromX : public FromProperty { + RTTI_DECL + public: + FromX(); + + virtual float value(BonePose& source, bool local, Vector& offsets) override; + }; +} + +#endif /* SPINE_FROMX_H_ */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/FromY.h b/spine-cpp/spine-cpp/include/spine/FromY.h new file mode 100644 index 000000000..6454ba95b --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/FromY.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * 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_FROMY_H_ +#define SPINE_FROMY_H_ + +#include +#include +#include + +namespace spine { + class BonePose; + + class SP_API FromY : public FromProperty { + RTTI_DECL + public: + FromY(); + + virtual float value(BonePose& source, bool local, Vector& offsets) override; + }; +} + +#endif /* SPINE_FROMY_H_ */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/PointAttachment.h b/spine-cpp/spine-cpp/include/spine/PointAttachment.h index 031a9f70b..9dab04e6b 100644 --- a/spine-cpp/spine-cpp/include/spine/PointAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/PointAttachment.h @@ -52,10 +52,6 @@ namespace spine { public: explicit PointAttachment(const String &name); - void computeWorldPosition(Bone &bone, float &ox, float &oy); - - float computeWorldRotation(Bone &bone); - float getX(); void setX(float inValue); @@ -70,6 +66,10 @@ namespace spine { Color &getColor(); + void computeWorldPosition(Bone &bone, float &ox, float &oy); + + float computeWorldRotation(Bone &bone); + virtual Attachment *copy(); private: diff --git a/spine-cpp/spine-cpp/include/spine/spine.h b/spine-cpp/spine-cpp/include/spine/spine.h index 32304c78e..afde87069 100644 --- a/spine-cpp/spine-cpp/include/spine/spine.h +++ b/spine-cpp/spine-cpp/include/spine/spine.h @@ -60,6 +60,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/spine-cpp/spine-cpp/src/spine/FromProperty.cpp b/spine-cpp/spine-cpp/src/spine/FromProperty.cpp index 0e371e4dc..b0aa19164 100644 --- a/spine-cpp/spine-cpp/src/spine/FromProperty.cpp +++ b/spine-cpp/spine-cpp/src/spine/FromProperty.cpp @@ -31,7 +31,9 @@ using namespace spine; -FromProperty::FromProperty() : offset(0) { +RTTI_IMPL_NOPARENT(FromProperty) + +FromProperty::FromProperty() : SpineObject(), offset(0) { } FromProperty::~FromProperty() { diff --git a/spine-cpp/spine-cpp/src/spine/FromRotate.cpp b/spine-cpp/spine-cpp/src/spine/FromRotate.cpp new file mode 100644 index 000000000..dede04d5c --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/FromRotate.cpp @@ -0,0 +1,47 @@ +/****************************************************************************** + * 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 +#include +#include + +using namespace spine; + +RTTI_IMPL(FromRotate, FromProperty) + +FromRotate::FromRotate() : FromProperty() { +} + +float FromRotate::value(BonePose& source, bool local, Vector& 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; +} \ No newline at end of file diff --git a/spine-cpp/spine-cpp/src/spine/FromScaleX.cpp b/spine-cpp/spine-cpp/src/spine/FromScaleX.cpp new file mode 100644 index 000000000..fff88f931 --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/FromScaleX.cpp @@ -0,0 +1,43 @@ +/****************************************************************************** + * 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 +#include +#include + +using namespace spine; + +RTTI_IMPL(FromScaleX, FromProperty) + +FromScaleX::FromScaleX() : FromProperty() { +} + +float FromScaleX::value(BonePose& source, bool local, Vector& offsets) { + return (local ? source.getScaleX() : MathUtil::sqrt(source._a * source._a + source._c * source._c)) + offsets[3]; +} \ No newline at end of file diff --git a/spine-cpp/spine-cpp/src/spine/FromScaleY.cpp b/spine-cpp/spine-cpp/src/spine/FromScaleY.cpp new file mode 100644 index 000000000..1794e5788 --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/FromScaleY.cpp @@ -0,0 +1,43 @@ +/****************************************************************************** + * 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 +#include +#include + +using namespace spine; + +RTTI_IMPL(FromScaleY, FromProperty) + +FromScaleY::FromScaleY() : FromProperty() { +} + +float FromScaleY::value(BonePose& source, bool local, Vector& offsets) { + return (local ? source.getScaleY() : MathUtil::sqrt(source._b * source._b + source._d * source._d)) + offsets[4]; +} \ No newline at end of file diff --git a/spine-cpp/spine-cpp/src/spine/FromShearY.cpp b/spine-cpp/spine-cpp/src/spine/FromShearY.cpp new file mode 100644 index 000000000..cd19b2dc2 --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/FromShearY.cpp @@ -0,0 +1,43 @@ +/****************************************************************************** + * 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 +#include +#include + +using namespace spine; + +RTTI_IMPL(FromShearY, FromProperty) + +FromShearY::FromShearY() : FromProperty() { +} + +float FromShearY::value(BonePose& source, bool local, Vector& offsets) { + return (local ? source.getShearY() : (MathUtil::atan2(source._d, source._b) - MathUtil::atan2(source._c, source._a)) * MathUtil::Rad_Deg - 90) + offsets[5]; +} \ No newline at end of file diff --git a/spine-cpp/spine-cpp/src/spine/FromX.cpp b/spine-cpp/spine-cpp/src/spine/FromX.cpp new file mode 100644 index 000000000..46f44caa6 --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/FromX.cpp @@ -0,0 +1,42 @@ +/****************************************************************************** + * 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 +#include + +using namespace spine; + +RTTI_IMPL(FromX, FromProperty) + +FromX::FromX() : FromProperty() { +} + +float FromX::value(BonePose& source, bool local, Vector& offsets) { + return local ? source.getX() + offsets[1] : offsets[1] * source._a + offsets[2] * source._b + source._worldX; +} \ No newline at end of file diff --git a/spine-cpp/spine-cpp/src/spine/FromY.cpp b/spine-cpp/spine-cpp/src/spine/FromY.cpp new file mode 100644 index 000000000..895add8b0 --- /dev/null +++ b/spine-cpp/spine-cpp/src/spine/FromY.cpp @@ -0,0 +1,42 @@ +/****************************************************************************** + * 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 +#include + +using namespace spine; + +RTTI_IMPL(FromY, FromProperty) + +FromY::FromY() : FromProperty() { +} + +float FromY::value(BonePose& source, bool local, Vector& offsets) { + return local ? source.getY() + offsets[2] : offsets[1] * source._c + offsets[2] * source._d + source._worldY; +} \ No newline at end of file diff --git a/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp b/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp index 611f3aff9..8c9605fc2 100644 --- a/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp @@ -37,18 +37,7 @@ using namespace spine; RTTI_IMPL(PointAttachment, Attachment) -PointAttachment::PointAttachment(const String &name) : Attachment(name), _x(0), _y(0), _rotation(0), _color() { -} - -void PointAttachment::computeWorldPosition(Bone &bone, float &ox, float &oy) { - bone.localToWorld(_x, _y, ox, oy); -} - -float PointAttachment::computeWorldRotation(Bone &bone) { - float r = _rotation * MathUtil::Deg_Rad, cosine = MathUtil::cos(r), sine = MathUtil::sin(r); - float x = cosine * bone._a + sine * bone._b; - float y = cosine * bone._c + sine * bone._d; - return MathUtil::atan2Deg(y, x); +PointAttachment::PointAttachment(const String &name) : Attachment(name), _x(0), _y(0), _rotation(0), _color(0.9451f, 0.9451f, 0, 1) { } float PointAttachment::getX() { @@ -79,10 +68,23 @@ Color &PointAttachment::getColor() { return _color; } +void PointAttachment::computeWorldPosition(Bone &bone, float &ox, float &oy) { + ox = _x * bone._a + _y * bone._b + bone._worldX; + oy = _x * bone._c + _y * bone._d + bone._worldY; +} + +float PointAttachment::computeWorldRotation(Bone &bone) { + float r = _rotation * MathUtil::Deg_Rad, cosine = MathUtil::cos(r), sine = MathUtil::sin(r); + float x = cosine * bone._a + sine * bone._b; + float y = cosine * bone._c + sine * bone._d; + return MathUtil::atan2Deg(y, x); +} + Attachment *PointAttachment::copy() { PointAttachment *copy = new (__FILE__, __LINE__) PointAttachment(getName()); copy->_x = _x; copy->_y = _y; copy->_rotation = _rotation; + copy->_color.set(_color); return copy; }