mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[cpp] Add pose architecture foundation for 4.3-beta
- Replace Updatable interface with Update interface - Add Pose<P> template interface for pose management - Add PosedData<P> abstract base class for setup data - Add Posed<D,P,A> base class linking data, pose, and applied states - Add PosedActive<D,P,A> 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.
This commit is contained in:
parent
0c6c0a2a7b
commit
84637da40b
4
.gitignore
vendored
4
.gitignore
vendored
@ -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
|
||||
|
||||
@ -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 <spine/RTTI.h>
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/Physics.h>
|
||||
#ifndef Spine_Pose_h
|
||||
#define Spine_Pose_h
|
||||
|
||||
namespace spine {
|
||||
class SP_API Updatable : public SpineObject {
|
||||
RTTI_DECL
|
||||
|
||||
template<typename P>
|
||||
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 */
|
||||
83
spine-cpp/spine-cpp/include/spine/Posed.h
Normal file
83
spine-cpp/spine-cpp/include/spine/Posed.h
Normal file
@ -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 <spine/SpineObject.h>
|
||||
#include <spine/PosedData.h>
|
||||
#include <spine/Pose.h>
|
||||
|
||||
namespace spine {
|
||||
template<typename D, typename P, typename A>
|
||||
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 */
|
||||
61
spine-cpp/spine-cpp/include/spine/PosedActive.h
Normal file
61
spine-cpp/spine-cpp/include/spine/PosedActive.h
Normal file
@ -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 <spine/Posed.h>
|
||||
|
||||
namespace spine {
|
||||
template<typename D, typename P, typename A>
|
||||
class PosedActive : public Posed<D, P, A> {
|
||||
public:
|
||||
PosedActive(D& data, P& pose, A& constrained) : Posed<D, P, A>(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 */
|
||||
79
spine-cpp/spine-cpp/include/spine/PosedData.h
Normal file
79
spine-cpp/spine-cpp/include/spine/PosedData.h
Normal file
@ -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 <spine/SpineObject.h>
|
||||
#include <spine/SpineString.h>
|
||||
#include <spine/Pose.h>
|
||||
|
||||
namespace spine {
|
||||
/// The base class for all constrained datas.
|
||||
template<typename P>
|
||||
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 */
|
||||
55
spine-cpp/spine-cpp/include/spine/Update.h
Normal file
55
spine-cpp/spine-cpp/include/spine/Update.h
Normal file
@ -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 <spine/RTTI.h>
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/Physics.h>
|
||||
|
||||
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 */
|
||||
@ -107,7 +107,11 @@
|
||||
#include <spine/TransformConstraintTimeline.h>
|
||||
#include <spine/TranslateTimeline.h>
|
||||
#include <spine/Triangulator.h>
|
||||
#include <spine/Updatable.h>
|
||||
#include <spine/Update.h>
|
||||
#include <spine/Pose.h>
|
||||
#include <spine/PosedData.h>
|
||||
#include <spine/Posed.h>
|
||||
#include <spine/PosedActive.h>
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/VertexAttachment.h>
|
||||
#include <spine/Vertices.h>
|
||||
|
||||
@ -27,14 +27,14 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <spine/Updatable.h>
|
||||
#include <spine/Update.h>
|
||||
|
||||
using namespace spine;
|
||||
|
||||
RTTI_IMPL_NOPARENT(Updatable)
|
||||
RTTI_IMPL_NOPARENT(Update)
|
||||
|
||||
Updatable::Updatable() {
|
||||
Update::Update() {
|
||||
}
|
||||
|
||||
Updatable::~Updatable() {
|
||||
}
|
||||
Update::~Update() {
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user