From 84637da40bc7c2a1d753b14feb2428faa8ee572f Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 26 May 2025 16:51:07 +0200 Subject: [PATCH] [cpp] Add pose architecture foundation for 4.3-beta - Replace Updatable interface with Update interface - Add Pose

template interface for pose management - Add PosedData

abstract base class for setup data - Add Posed base class linking data, pose, and applied states - Add PosedActive extending Posed with active state management - Update spine.h to include new pose system headers This implements the foundational pose architecture required for the 4.3-beta constraint system overhaul. The new pose-based system provides better separation of concerns and enables more flexible constraint management. --- .gitignore | 4 + .../include/spine/{Updatable.h => Pose.h} | 25 ++---- spine-cpp/spine-cpp/include/spine/Posed.h | 83 +++++++++++++++++++ .../spine-cpp/include/spine/PosedActive.h | 61 ++++++++++++++ spine-cpp/spine-cpp/include/spine/PosedData.h | 79 ++++++++++++++++++ spine-cpp/spine-cpp/include/spine/Update.h | 55 ++++++++++++ spine-cpp/spine-cpp/include/spine/spine.h | 6 +- .../src/spine/{Updatable.cpp => Update.cpp} | 10 +-- 8 files changed, 299 insertions(+), 24 deletions(-) rename spine-cpp/spine-cpp/include/spine/{Updatable.h => Pose.h} (81%) create mode 100644 spine-cpp/spine-cpp/include/spine/Posed.h create mode 100644 spine-cpp/spine-cpp/include/spine/PosedActive.h create mode 100644 spine-cpp/spine-cpp/include/spine/PosedData.h create mode 100644 spine-cpp/spine-cpp/include/spine/Update.h rename spine-cpp/spine-cpp/src/spine/{Updatable.cpp => Update.cpp} (93%) diff --git a/.gitignore b/.gitignore index 1140eb43a..2ed9dbadc 100644 --- a/.gitignore +++ b/.gitignore @@ -222,3 +222,7 @@ spine-godot/vc140.pdb spine-godot/example-v4-extension/bin spine-godot/example-v4-extension/MoltenVK.xcframework spine-flutter/example/android/app/.cxx +CLAUDE.md +.claude +port-plan.md +port-todo.md diff --git a/spine-cpp/spine-cpp/include/spine/Updatable.h b/spine-cpp/spine-cpp/include/spine/Pose.h similarity index 81% rename from spine-cpp/spine-cpp/include/spine/Updatable.h rename to spine-cpp/spine-cpp/include/spine/Pose.h index dc5b4d375..ab23a5335 100644 --- a/spine-cpp/spine-cpp/include/spine/Updatable.h +++ b/spine-cpp/spine-cpp/include/spine/Pose.h @@ -27,28 +27,17 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef Spine_Updatable_h -#define Spine_Updatable_h - -#include -#include -#include +#ifndef Spine_Pose_h +#define Spine_Pose_h namespace spine { - class SP_API Updatable : public SpineObject { - RTTI_DECL - + template + class Pose { public: - Updatable(); + virtual ~Pose() {} - virtual ~Updatable(); - - virtual void update(Physics physics) = 0; - - virtual bool isActive() = 0; - - virtual void setActive(bool inValue) = 0; + virtual void set(const P& pose) = 0; }; } -#endif /* Spine_Updatable_h */ +#endif /* Spine_Pose_h */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/Posed.h b/spine-cpp/spine-cpp/include/spine/Posed.h new file mode 100644 index 000000000..df1d34cfd --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/Posed.h @@ -0,0 +1,83 @@ +/****************************************************************************** + * 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_Posed_h +#define Spine_Posed_h + +#include +#include +#include + +namespace spine { + template + class Posed : public SpineObject { + public: + Posed(D& data, P& pose, A& constrained) : _data(data), _pose(pose), _constrained(constrained), _applied(&pose) { + } + + virtual ~Posed() {} + + void setupPose() { + _pose.set(_data.getSetupPose()); + } + + /// The constraint's setup pose data. + D& getData() { + return _data; + } + + const D& getData() const { + return _data; + } + + P& getPose() { + return _pose; + } + + const P& getPose() const { + return _pose; + } + + A& getAppliedPose() { + return *_applied; + } + + const A& getAppliedPose() const { + return *_applied; + } + + protected: + D& _data; + P& _pose; + A& _constrained; + A* _applied; + }; +} + +#endif /* Spine_Posed_h */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/PosedActive.h b/spine-cpp/spine-cpp/include/spine/PosedActive.h new file mode 100644 index 000000000..0a4568eac --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/PosedActive.h @@ -0,0 +1,61 @@ +/****************************************************************************** + * 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_PosedActive_h +#define Spine_PosedActive_h + +#include + +namespace spine { + template + class PosedActive : public Posed { + public: + PosedActive(D& data, P& pose, A& constrained) : Posed(data, pose, constrained), _active(false) { + this->setupPose(); + } + + virtual ~PosedActive() {} + + /// Returns false when this constraint won't be updated by + /// Skeleton::updateWorldTransform(Physics) because a skin is required and the + /// active skin does not contain this item. + /// @see Skin::getBones() + /// @see Skin::getConstraints() + /// @see PosedData::getSkinRequired() + /// @see Skeleton::updateCache() + bool isActive() const { + return _active; + } + + protected: + bool _active; + }; +} + +#endif /* Spine_PosedActive_h */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/PosedData.h b/spine-cpp/spine-cpp/include/spine/PosedData.h new file mode 100644 index 000000000..ade6e8a79 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/PosedData.h @@ -0,0 +1,79 @@ +/****************************************************************************** + * 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_PosedData_h +#define Spine_PosedData_h + +#include +#include +#include + +namespace spine { + /// The base class for all constrained datas. + template + class PosedData : public SpineObject { + public: + PosedData(const String& name, P& setup) : _name(name), _setup(setup), _skinRequired(false) { + } + + virtual ~PosedData() {} + + /// The constraint's name, which is unique across all constraints in the skeleton of the same type. + const String& getName() const { + return _name; + } + + P& getSetupPose() { + return _setup; + } + + const P& getSetupPose() const { + return _setup; + } + + /// When true, Skeleton::updateWorldTransform(Physics) only updates this constraint if the Skeleton::getSkin() + /// contains this constraint. + /// + /// See Skin::getConstraints(). + bool getSkinRequired() const { + return _skinRequired; + } + + void setSkinRequired(bool skinRequired) { + _skinRequired = skinRequired; + } + + protected: + const String _name; + P& _setup; + bool _skinRequired; + }; +} + +#endif /* Spine_PosedData_h */ \ No newline at end of file diff --git a/spine-cpp/spine-cpp/include/spine/Update.h b/spine-cpp/spine-cpp/include/spine/Update.h new file mode 100644 index 000000000..70204ddf0 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/Update.h @@ -0,0 +1,55 @@ +/****************************************************************************** + * 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_Update_h +#define Spine_Update_h + +#include +#include +#include + +namespace spine { + class Skeleton; + + /// The interface for items updated by Skeleton::updateWorldTransform(Physics). + class SP_API Update : public SpineObject { + RTTI_DECL + + public: + Update(); + + virtual ~Update(); + + /// @param skeleton The skeleton being updated. + /// @param physics Determines how physics and other non-deterministic updates are applied. + virtual void update(Skeleton& skeleton, Physics physics) = 0; + }; +} + +#endif /* Spine_Update_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 ab3e5414e..5f0e60acc 100644 --- a/spine-cpp/spine-cpp/include/spine/spine.h +++ b/spine-cpp/spine-cpp/include/spine/spine.h @@ -107,7 +107,11 @@ #include #include #include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/spine-cpp/spine-cpp/src/spine/Updatable.cpp b/spine-cpp/spine-cpp/src/spine/Update.cpp similarity index 93% rename from spine-cpp/spine-cpp/src/spine/Updatable.cpp rename to spine-cpp/spine-cpp/src/spine/Update.cpp index 8e874a272..81ee025dc 100644 --- a/spine-cpp/spine-cpp/src/spine/Updatable.cpp +++ b/spine-cpp/spine-cpp/src/spine/Update.cpp @@ -27,14 +27,14 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#include +#include using namespace spine; -RTTI_IMPL_NOPARENT(Updatable) +RTTI_IMPL_NOPARENT(Update) -Updatable::Updatable() { +Update::Update() { } -Updatable::~Updatable() { -} +Update::~Update() { +} \ No newline at end of file