mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[cpp] 4.3 porting WIP
This commit is contained in:
parent
972a1bc8fc
commit
5aeceb27c9
@ -59,7 +59,7 @@ namespace spine {
|
||||
|
||||
virtual bool isSourceActive() override;
|
||||
|
||||
IkConstraintData &getData();
|
||||
IkConstraintData &getData() override;
|
||||
|
||||
Vector<BonePose *> &getBones();
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ namespace spine {
|
||||
|
||||
virtual void
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction, bool appliedPose);
|
||||
MixDirection direction, bool appliedPose) override;
|
||||
|
||||
private:
|
||||
static const int ENTRIES = 2;
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#define Spine_Json_h
|
||||
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/Vector.h>
|
||||
|
||||
#ifndef SPINE_JSON_HAVE_PREV
|
||||
/* spine doesn't use the "prev" link in the Json sibling lists. */
|
||||
@ -53,10 +54,12 @@ namespace spine {
|
||||
|
||||
template <typename T>
|
||||
static bool asArray(Json *value, Vector<T> &array) {
|
||||
if (value == NULL) return false;
|
||||
array.setSize(value->_size, 0);
|
||||
Json *vertex = value->_child;
|
||||
for (int i = 0; vertex; vertex = vertex->_next, i++)
|
||||
array[i] = vertex->_valueInt;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
|
||||
@ -51,7 +51,7 @@ namespace spine {
|
||||
|
||||
virtual void
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction, bool appliedPose);
|
||||
MixDirection direction, bool appliedPose) override;
|
||||
|
||||
/// Sets the time and color for the specified frame.
|
||||
/// @param frame Between 0 and frameCount, inclusive.
|
||||
|
||||
@ -51,7 +51,7 @@ namespace spine {
|
||||
|
||||
virtual void
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction, bool appliedPose);
|
||||
MixDirection direction, bool appliedPose) override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ namespace spine {
|
||||
|
||||
virtual void
|
||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||
MixDirection direction, bool appliedPose);
|
||||
MixDirection direction, bool appliedPose) override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -35,6 +35,8 @@
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/SpineString.h>
|
||||
#include <spine/Color.h>
|
||||
#include <spine/BoneTimeline.h>
|
||||
#include <spine/SkeletonData.h>
|
||||
|
||||
namespace spine {
|
||||
class SkeletonData;
|
||||
|
||||
@ -183,7 +183,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||
|
||||
/* Bones. */
|
||||
Vector<BoneData *> &bones = skeletonData->_bones.setSize(input.readInt(true), NULL);
|
||||
for (int i = 0; i < bones.size(); ++i) {
|
||||
for (int i = 0; i < (int)bones.size(); ++i) {
|
||||
const char *name = input.readString();
|
||||
BoneData *parent = i == 0 ? 0 : bones[input.readInt(true)];
|
||||
BoneData *data = new (__FILE__, __LINE__) BoneData(i, String(name, true), parent);
|
||||
@ -208,7 +208,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||
|
||||
/* Slots. */
|
||||
Vector<SlotData *> &slots = skeletonData->_slots.setSize(input.readInt(true), NULL);
|
||||
for (int i = 0; i < slots.size(); ++i) {
|
||||
for (int i = 0; i < (int)slots.size(); ++i) {
|
||||
String slotName = String(input.readString(), true);
|
||||
BoneData *boneData = bones[input.readInt(true)];
|
||||
SlotData *data = new (__FILE__, __LINE__) SlotData(i, slotName, *boneData);
|
||||
|
||||
@ -71,7 +71,7 @@ void Slider::update(Skeleton &skeleton, Physics physics) {
|
||||
if (!_bone->isActive()) return;
|
||||
if (_data._local) _bone->_applied->validateLocalTransform(skeleton);
|
||||
p._time = _data._offset
|
||||
+ (_data._property->value(skeleton, *_bone->_applied, _data._local, _offsets) - _data._property->offset) * _data._scale;
|
||||
+ (_data._property->value(skeleton, *_bone->_applied, _data._local, _offsets) - _data._property->_offset) * _data._scale;
|
||||
if (_data._loop)
|
||||
p._time = animation->getDuration() + MathUtil::fmod(p._time, animation->getDuration());
|
||||
else
|
||||
|
||||
@ -83,18 +83,18 @@ void TransformConstraint::update(Skeleton &skeleton, Physics physics) {
|
||||
}
|
||||
for (size_t f = 0; f < fn; f++) {
|
||||
FromProperty *from = fromItems[f];
|
||||
float value = from->value(skeleton, source, localSource, offsets) - from->offset;
|
||||
Vector<ToProperty *> &toProps = from->to;
|
||||
float value = from->value(skeleton, source, localSource, offsets) - from->_offset;
|
||||
Vector<ToProperty *> &toProps = from->_to;
|
||||
ToProperty **toItems = toProps.buffer();
|
||||
for (size_t t = 0, tn = toProps.size(); t < tn; t++) {
|
||||
ToProperty *to = toItems[t];
|
||||
if (to->mix(p) != 0) {
|
||||
float clamped = to->offset + value * to->scale;
|
||||
float clamped = to->_offset + value * to->_scale;
|
||||
if (clamp) {
|
||||
if (to->offset < to->max)
|
||||
clamped = MathUtil::clamp(clamped, to->offset, to->max);
|
||||
if (to->_offset < to->_max)
|
||||
clamped = MathUtil::clamp(clamped, to->_offset, to->_max);
|
||||
else
|
||||
clamped = MathUtil::clamp(clamped, to->max, to->offset);
|
||||
clamped = MathUtil::clamp(clamped, to->_max, to->_offset);
|
||||
}
|
||||
to->apply(skeleton, p, *bone, clamped, localTarget, additive);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user