mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Formatting
This commit is contained in:
parent
e623140c99
commit
120577bfe6
@ -72,7 +72,7 @@ Bone::Bone(BoneData &data, Skeleton &skeleton, Bone *parent) : Updatable(),
|
|||||||
_worldY(0),
|
_worldY(0),
|
||||||
_sorted(false),
|
_sorted(false),
|
||||||
_active(false),
|
_active(false),
|
||||||
_inherit(Inherit_Normal){
|
_inherit(Inherit_Normal) {
|
||||||
setToSetupPose();
|
setToSetupPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,7 @@ RTTI_IMPL(InheritTimeline, Timeline)
|
|||||||
|
|
||||||
InheritTimeline::InheritTimeline(size_t frameCount, int boneIndex) : Timeline(frameCount, ENTRIES),
|
InheritTimeline::InheritTimeline(size_t frameCount, int boneIndex) : Timeline(frameCount, ENTRIES),
|
||||||
_boneIndex(boneIndex) {
|
_boneIndex(boneIndex) {
|
||||||
PropertyId ids[] = {((PropertyId) Property_Inherit << 32) | boneIndex };
|
PropertyId ids[] = {((PropertyId) Property_Inherit << 32) | boneIndex};
|
||||||
setPropertyIds(ids, 1);
|
setPropertyIds(ids, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +72,5 @@ void InheritTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vect
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int idx = Animation::search(_frames, time, ENTRIES) + INHERIT;
|
int idx = Animation::search(_frames, time, ENTRIES) + INHERIT;
|
||||||
bone->_inherit = (Inherit)_frames[idx];
|
bone->_inherit = (Inherit) _frames[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -338,12 +338,14 @@ void PhysicsConstraint::update(Physics physics) {
|
|||||||
if (x || y) {
|
if (x || y) {
|
||||||
if (x) {
|
if (x) {
|
||||||
float u = (_ux - bx) * i;
|
float u = (_ux - bx) * i;
|
||||||
_xOffset += u > q ? q : u < -q ? -q : u;
|
_xOffset += u > q ? q : u < -q ? -q
|
||||||
|
: u;
|
||||||
_ux = bx;
|
_ux = bx;
|
||||||
}
|
}
|
||||||
if (y) {
|
if (y) {
|
||||||
float u = (_uy - by) * i;
|
float u = (_uy - by) * i;
|
||||||
_yOffset += u > q ? q : u < -q ? -q : u;
|
_yOffset += u > q ? q : u < -q ? -q
|
||||||
|
: u;
|
||||||
_uy = by;
|
_uy = by;
|
||||||
}
|
}
|
||||||
if (a >= t) {
|
if (a >= t) {
|
||||||
@ -372,11 +374,11 @@ void PhysicsConstraint::update(Physics physics) {
|
|||||||
float dx = _cx - bone->_worldX, dy = _cy - bone->_worldY;
|
float dx = _cx - bone->_worldX, dy = _cy - bone->_worldY;
|
||||||
if (dx > q)
|
if (dx > q)
|
||||||
dx = q;
|
dx = q;
|
||||||
else if (dx < -q) //
|
else if (dx < -q)//
|
||||||
dx = -q;
|
dx = -q;
|
||||||
if (dy > q)
|
if (dy > q)
|
||||||
dy = q;
|
dy = q;
|
||||||
else if (dy < -q) //
|
else if (dy < -q)//
|
||||||
dy = -q;
|
dy = -q;
|
||||||
if (rotateOrShearX) {
|
if (rotateOrShearX) {
|
||||||
mr = (_data._rotate + _data._shearX) * mix;
|
mr = (_data._rotate + _data._shearX) * mix;
|
||||||
@ -414,7 +416,7 @@ void PhysicsConstraint::update(Physics physics) {
|
|||||||
float r = _rotateOffset * mr + ca;
|
float r = _rotateOffset * mr + ca;
|
||||||
c = MathUtil::cos(r);
|
c = MathUtil::cos(r);
|
||||||
s = MathUtil::sin(r);
|
s = MathUtil::sin(r);
|
||||||
} else if (a < t) //
|
} else if (a < t)//
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -215,19 +215,19 @@ void Skeleton::printUpdateCache() {
|
|||||||
for (size_t i = 0; i < _updateCache.size(); i++) {
|
for (size_t i = 0; i < _updateCache.size(); i++) {
|
||||||
Updatable *updatable = _updateCache[i];
|
Updatable *updatable = _updateCache[i];
|
||||||
if (updatable->getRTTI().isExactly(Bone::rtti)) {
|
if (updatable->getRTTI().isExactly(Bone::rtti)) {
|
||||||
printf("bone %s\n", ((Bone *)updatable)->getData().getName().buffer());
|
printf("bone %s\n", ((Bone *) updatable)->getData().getName().buffer());
|
||||||
} else if (updatable->getRTTI().isExactly(TransformConstraint::rtti)) {
|
} else if (updatable->getRTTI().isExactly(TransformConstraint::rtti)) {
|
||||||
printf("transform constraint %s\n",
|
printf("transform constraint %s\n",
|
||||||
((TransformConstraint *)updatable)->getData().getName().buffer());
|
((TransformConstraint *) updatable)->getData().getName().buffer());
|
||||||
} else if (updatable->getRTTI().isExactly(IkConstraint::rtti)) {
|
} else if (updatable->getRTTI().isExactly(IkConstraint::rtti)) {
|
||||||
printf("ik constraint %s\n",
|
printf("ik constraint %s\n",
|
||||||
((IkConstraint *)updatable)->getData().getName().buffer());
|
((IkConstraint *) updatable)->getData().getName().buffer());
|
||||||
} else if (updatable->getRTTI().isExactly(PathConstraint::rtti)) {
|
} else if (updatable->getRTTI().isExactly(PathConstraint::rtti)) {
|
||||||
printf("path constraint %s\n",
|
printf("path constraint %s\n",
|
||||||
((PathConstraint *)updatable)->getData().getName().buffer());
|
((PathConstraint *) updatable)->getData().getName().buffer());
|
||||||
} else if (updatable->getRTTI().isExactly(PhysicsConstraint::rtti)) {
|
} else if (updatable->getRTTI().isExactly(PhysicsConstraint::rtti)) {
|
||||||
printf("physics constraint %s\n",
|
printf("physics constraint %s\n",
|
||||||
((PhysicsConstraint *)updatable)->getData().getName().buffer());
|
((PhysicsConstraint *) updatable)->getData().getName().buffer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -386,7 +386,7 @@ void Skeleton::setAttachment(const String &slotName,
|
|||||||
if (slot->_data.getName() == slotName) {
|
if (slot->_data.getName() == slotName) {
|
||||||
Attachment *attachment = NULL;
|
Attachment *attachment = NULL;
|
||||||
if (attachmentName.length() > 0) {
|
if (attachmentName.length() > 0) {
|
||||||
attachment = getAttachment((int)i, attachmentName);
|
attachment = getAttachment((int) i, attachmentName);
|
||||||
|
|
||||||
assert(attachment != NULL);
|
assert(attachment != NULL);
|
||||||
}
|
}
|
||||||
@ -734,13 +734,13 @@ void Skeleton::setTime(float time) { _time = time; }
|
|||||||
void Skeleton::update(float delta) { _time += delta; }
|
void Skeleton::update(float delta) { _time += delta; }
|
||||||
|
|
||||||
void Skeleton::physicsTranslate(float x, float y) {
|
void Skeleton::physicsTranslate(float x, float y) {
|
||||||
for (int i = 0; i < (int)_physicsConstraints.size(); i++) {
|
for (int i = 0; i < (int) _physicsConstraints.size(); i++) {
|
||||||
_physicsConstraints[i]->translate(x, y);
|
_physicsConstraints[i]->translate(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::physicsRotate(float x, float y, float degrees) {
|
void Skeleton::physicsRotate(float x, float y, float degrees) {
|
||||||
for (int i = 0; i < (int)_physicsConstraints.size(); i++) {
|
for (int i = 0; i < (int) _physicsConstraints.size(); i++) {
|
||||||
_physicsConstraints[i]->rotate(x, y, degrees);
|
_physicsConstraints[i]->rotate(x, y, degrees);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -246,7 +246,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
|||||||
data->_local = (flags & 2) != 0;
|
data->_local = (flags & 2) != 0;
|
||||||
data->_relative = (flags & 4) != 0;
|
data->_relative = (flags & 4) != 0;
|
||||||
if ((flags & 8) != 0) data->_offsetRotation = readFloat(input);
|
if ((flags & 8) != 0) data->_offsetRotation = readFloat(input);
|
||||||
if ((flags & 16) != 0) data->_offsetX =readFloat(input) * _scale;
|
if ((flags & 16) != 0) data->_offsetX = readFloat(input) * _scale;
|
||||||
if ((flags & 32) != 0) data->_offsetY = readFloat(input) * _scale;
|
if ((flags & 32) != 0) data->_offsetY = readFloat(input) * _scale;
|
||||||
if ((flags & 64) != 0) data->_offsetScaleX = readFloat(input);
|
if ((flags & 64) != 0) data->_offsetScaleX = readFloat(input);
|
||||||
if ((flags & 128) != 0) data->_offsetScaleY = readFloat(input);
|
if ((flags & 128) != 0) data->_offsetScaleY = readFloat(input);
|
||||||
@ -276,9 +276,9 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
|||||||
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
||||||
data->_target = skeletonData->_slots[readVarint(input, true)];
|
data->_target = skeletonData->_slots[readVarint(input, true)];
|
||||||
int flags = readByte(input);
|
int flags = readByte(input);
|
||||||
data->_positionMode = (PositionMode)(flags & 1);
|
data->_positionMode = (PositionMode) (flags & 1);
|
||||||
data->_spacingMode = (SpacingMode)((flags >> 1) & 3);
|
data->_spacingMode = (SpacingMode) ((flags >> 1) & 3);
|
||||||
data->_rotateMode = (RotateMode)((flags >> 3) & 3);
|
data->_rotateMode = (RotateMode) ((flags >> 3) & 3);
|
||||||
if ((flags & 128) != 0) data->_offsetRotation = readFloat(input);
|
if ((flags & 128) != 0) data->_offsetRotation = readFloat(input);
|
||||||
data->_position = readFloat(input);
|
data->_position = readFloat(input);
|
||||||
if (data->_positionMode == PositionMode_Fixed) data->_position *= _scale;
|
if (data->_positionMode == PositionMode_Fixed) data->_position *= _scale;
|
||||||
@ -795,7 +795,7 @@ void SkeletonBinary::readFloatArray(DataInput *input, int n, float scale, Vector
|
|||||||
void SkeletonBinary::readShortArray(DataInput *input, Vector<unsigned short> &array, int n) {
|
void SkeletonBinary::readShortArray(DataInput *input, Vector<unsigned short> &array, int n) {
|
||||||
array.setSize(n, 0);
|
array.setSize(n, 0);
|
||||||
for (int i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
array[i] = (short)readVarint(input, true);
|
array[i] = (short) readVarint(input, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -809,7 +809,7 @@ void SkeletonBinary::setBezier(DataInput *input, CurveTimeline *timeline, int be
|
|||||||
timeline->setBezier(bezier, frame, value, time1, value1, cx1, cy1 * scale, cx2, cy2 * scale, time2, value2);
|
timeline->setBezier(bezier, frame, value, time1, value1, cx1, cy1 * scale, cx2, cy2 * scale, time2, value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonBinary::readTimeline(DataInput *input, Vector<Timeline*> &timelines, CurveTimeline1 *timeline, float scale) {
|
void SkeletonBinary::readTimeline(DataInput *input, Vector<Timeline *> &timelines, CurveTimeline1 *timeline, float scale) {
|
||||||
float time = readFloat(input);
|
float time = readFloat(input);
|
||||||
float value = readFloat(input) * scale;
|
float value = readFloat(input) * scale;
|
||||||
for (int frame = 0, bezier = 0, frameLast = (int) timeline->getFrameCount() - 1;; frame++) {
|
for (int frame = 0, bezier = 0, frameLast = (int) timeline->getFrameCount() - 1;; frame++) {
|
||||||
@ -830,7 +830,7 @@ void SkeletonBinary::readTimeline(DataInput *input, Vector<Timeline*> &timelines
|
|||||||
timelines.add(timeline);
|
timelines.add(timeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonBinary::readTimeline2(DataInput *input, Vector<Timeline*> &timelines, CurveTimeline2 *timeline, float scale) {
|
void SkeletonBinary::readTimeline2(DataInput *input, Vector<Timeline *> &timelines, CurveTimeline2 *timeline, float scale) {
|
||||||
float time = readFloat(input);
|
float time = readFloat(input);
|
||||||
float value1 = readFloat(input) * scale;
|
float value1 = readFloat(input) * scale;
|
||||||
float value2 = readFloat(input) * scale;
|
float value2 = readFloat(input) * scale;
|
||||||
@ -1090,7 +1090,7 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
|||||||
InheritTimeline *timeline = new (__FILE__, __LINE__) InheritTimeline(frameCount, boneIndex);
|
InheritTimeline *timeline = new (__FILE__, __LINE__) InheritTimeline(frameCount, boneIndex);
|
||||||
for (int frame = 0; frame < frameCount; frame++) {
|
for (int frame = 0; frame < frameCount; frame++) {
|
||||||
float time = readFloat(input);
|
float time = readFloat(input);
|
||||||
Inherit inherit = (Inherit)readByte(input);
|
Inherit inherit = (Inherit) readByte(input);
|
||||||
timeline->setFrame(frame, time, inherit);
|
timeline->setFrame(frame, time, inherit);
|
||||||
}
|
}
|
||||||
timelines.add(timeline);
|
timelines.add(timeline);
|
||||||
@ -1104,7 +1104,7 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
|||||||
1);
|
1);
|
||||||
break;
|
break;
|
||||||
case BONE_TRANSLATE:
|
case BONE_TRANSLATE:
|
||||||
readTimeline2(input, timelines,new (__FILE__, __LINE__) TranslateTimeline(frameCount, bezierCount, boneIndex), scale);
|
readTimeline2(input, timelines, new (__FILE__, __LINE__) TranslateTimeline(frameCount, bezierCount, boneIndex), scale);
|
||||||
break;
|
break;
|
||||||
case BONE_TRANSLATEX:
|
case BONE_TRANSLATEX:
|
||||||
readTimeline(input, timelines, new (__FILE__, __LINE__) TranslateXTimeline(frameCount, bezierCount, boneIndex), scale);
|
readTimeline(input, timelines, new (__FILE__, __LINE__) TranslateXTimeline(frameCount, bezierCount, boneIndex), scale);
|
||||||
|
|||||||
@ -1182,7 +1182,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
|||||||
if (!nextMap) break;
|
if (!nextMap) break;
|
||||||
}
|
}
|
||||||
timelines.add(timeline);
|
timelines.add(timeline);
|
||||||
}else {
|
} else {
|
||||||
ContainerUtil::cleanUpVectorOfPointers(timelines);
|
ContainerUtil::cleanUpVectorOfPointers(timelines);
|
||||||
setError(NULL, "Invalid timeline type for a bone: ", timelineMap->_name);
|
setError(NULL, "Invalid timeline type for a bone: ", timelineMap->_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@ -2,4 +2,3 @@
|
|||||||
|
|
||||||
#include "SpineUEGameMode.h"
|
#include "SpineUEGameMode.h"
|
||||||
#include "SpineUE.h"
|
#include "SpineUE.h"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user