|
@@ -132,7 +132,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
|
|
skeletonData->_y = readFloat(input);
|
|
|
skeletonData->_width = readFloat(input);
|
|
|
skeletonData->_height = readFloat(input);
|
|
|
- skeletonData->_referenceScale = readFloat(input) * this->_scale;
|
|
|
+ skeletonData->_referenceScale = readFloat(input) * this->_scale;
|
|
|
|
|
|
nonessential = readBoolean(input);
|
|
|
|
|
@@ -165,8 +165,8 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
|
|
data->_skinRequired = readBoolean(input);
|
|
|
if (nonessential) {
|
|
|
readColor(input, data->getColor());
|
|
|
- data->_icon.own(readString(input));
|
|
|
- data->_visible = readBoolean(input);
|
|
|
+ data->_icon.own(readString(input));
|
|
|
+ data->_visible = readBoolean(input);
|
|
|
}
|
|
|
skeletonData->_bones[i] = data;
|
|
|
}
|
|
@@ -176,14 +176,14 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
|
|
skeletonData->_slots.setSize(slotsCount, 0);
|
|
|
for (int i = 0; i < slotsCount; ++i) {
|
|
|
String slotName = String(readString(input), true);
|
|
|
- String pathName = "";
|
|
|
- if (nonessential) {
|
|
|
- int slash = slotName.lastIndexOf('/');
|
|
|
- if (slash != -1) {
|
|
|
- pathName = slotName.substring(0, slash);
|
|
|
- slotName = slotName.substring(slash + 1);
|
|
|
- }
|
|
|
- }
|
|
|
+ String pathName = "";
|
|
|
+ if (nonessential) {
|
|
|
+ int slash = slotName.lastIndexOf('/');
|
|
|
+ if (slash != -1) {
|
|
|
+ pathName = slotName.substring(0, slash);
|
|
|
+ slotName = slotName.substring(slash + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
BoneData *boneData = skeletonData->_bones[readVarint(input, true)];
|
|
|
SlotData *slotData = new (__FILE__, __LINE__) SlotData(i, slotName, *boneData);
|
|
|
|
|
@@ -198,10 +198,10 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
|
|
}
|
|
|
slotData->_attachmentName = readStringRef(input, skeletonData);
|
|
|
slotData->_blendMode = static_cast<BlendMode>(readVarint(input, true));
|
|
|
- if (nonessential) {
|
|
|
- slotData->_visible = readBoolean(input);
|
|
|
- slotData->_path = pathName;
|
|
|
- }
|
|
|
+ if (nonessential) {
|
|
|
+ slotData->_visible = readBoolean(input);
|
|
|
+ slotData->_path = pathName;
|
|
|
+ }
|
|
|
skeletonData->_slots[i] = slotData;
|
|
|
}
|
|
|
|
|
@@ -217,14 +217,14 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
|
|
for (int ii = 0; ii < bonesCount; ++ii)
|
|
|
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
|
|
data->_target = skeletonData->_bones[readVarint(input, true)];
|
|
|
- int flags = readByte(input);
|
|
|
- data->_skinRequired = (flags & 1) != 0;
|
|
|
- data->_bendDirection = (flags & 2) != 0 ? 1 : -1;
|
|
|
- data->_compress = (flags & 4) != 0;
|
|
|
- data->_stretch = (flags & 8) != 0;
|
|
|
- data->_uniform = (flags & 16) != 0;
|
|
|
- if ((flags & 32) != 0) data->_mix = (flags & 64) != 0 ? readFloat(input) : 1;
|
|
|
- if ((flags & 128) != 0) data->_softness = readFloat(input) * _scale;
|
|
|
+ int flags = readByte(input);
|
|
|
+ data->_skinRequired = (flags & 1) != 0;
|
|
|
+ data->_bendDirection = (flags & 2) != 0 ? 1 : -1;
|
|
|
+ data->_compress = (flags & 4) != 0;
|
|
|
+ data->_stretch = (flags & 8) != 0;
|
|
|
+ data->_uniform = (flags & 16) != 0;
|
|
|
+ if ((flags & 32) != 0) data->_mix = (flags & 64) != 0 ? readFloat(input) : 1;
|
|
|
+ if ((flags & 128) != 0) data->_softness = readFloat(input) * _scale;
|
|
|
|
|
|
skeletonData->_ikConstraints[i] = data;
|
|
|
}
|
|
@@ -241,25 +241,25 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
|
|
for (int ii = 0; ii < bonesCount; ++ii)
|
|
|
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
|
|
data->_target = skeletonData->_bones[readVarint(input, true)];
|
|
|
- int flags = readByte(input);
|
|
|
- data->_skinRequired = (flags & 1) != 0;
|
|
|
- data->_local = (flags & 2) != 0;
|
|
|
- data->_relative = (flags & 4) != 0;
|
|
|
- if ((flags & 8) != 0) data->_offsetRotation = readFloat(input);
|
|
|
- if ((flags & 16) != 0) data->_offsetX =readFloat(input) * _scale;
|
|
|
- if ((flags & 32) != 0) data->_offsetY = readFloat(input) * _scale;
|
|
|
- if ((flags & 64) != 0) data->_offsetScaleX = readFloat(input);
|
|
|
- if ((flags & 128) != 0) data->_offsetScaleY = readFloat(input);
|
|
|
- flags = readByte(input);
|
|
|
- if ((flags & 1) != 0) data->_offsetShearY = readFloat(input);
|
|
|
- if ((flags & 2) != 0) data->_mixRotate = readFloat(input);
|
|
|
- if ((flags & 4) != 0) data->_mixX = readFloat(input);
|
|
|
- if ((flags & 8) != 0) data->_mixY = readFloat(input);
|
|
|
- if ((flags & 16) != 0) data->_mixScaleX = readFloat(input);
|
|
|
- if ((flags & 32) != 0) data->_mixScaleY = readFloat(input);
|
|
|
- if ((flags & 64) != 0) data->_mixShearY = readFloat(input);
|
|
|
-
|
|
|
- skeletonData->_transformConstraints[i] = data;
|
|
|
+ int flags = readByte(input);
|
|
|
+ data->_skinRequired = (flags & 1) != 0;
|
|
|
+ data->_local = (flags & 2) != 0;
|
|
|
+ data->_relative = (flags & 4) != 0;
|
|
|
+ if ((flags & 8) != 0) data->_offsetRotation = readFloat(input);
|
|
|
+ if ((flags & 16) != 0) data->_offsetX = readFloat(input) * _scale;
|
|
|
+ if ((flags & 32) != 0) data->_offsetY = readFloat(input) * _scale;
|
|
|
+ if ((flags & 64) != 0) data->_offsetScaleX = readFloat(input);
|
|
|
+ if ((flags & 128) != 0) data->_offsetScaleY = readFloat(input);
|
|
|
+ flags = readByte(input);
|
|
|
+ if ((flags & 1) != 0) data->_offsetShearY = readFloat(input);
|
|
|
+ if ((flags & 2) != 0) data->_mixRotate = readFloat(input);
|
|
|
+ if ((flags & 4) != 0) data->_mixX = readFloat(input);
|
|
|
+ if ((flags & 8) != 0) data->_mixY = readFloat(input);
|
|
|
+ if ((flags & 16) != 0) data->_mixScaleX = readFloat(input);
|
|
|
+ if ((flags & 32) != 0) data->_mixScaleY = readFloat(input);
|
|
|
+ if ((flags & 64) != 0) data->_mixShearY = readFloat(input);
|
|
|
+
|
|
|
+ skeletonData->_transformConstraints[i] = data;
|
|
|
}
|
|
|
|
|
|
/* Path constraints */
|
|
@@ -275,11 +275,11 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
|
|
for (int ii = 0; ii < bonesCount; ++ii)
|
|
|
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
|
|
data->_target = skeletonData->_slots[readVarint(input, true)];
|
|
|
- int flags = readByte(input);
|
|
|
- data->_positionMode = (PositionMode)(flags & 1);
|
|
|
- data->_spacingMode = (SpacingMode)((flags >> 1) & 3);
|
|
|
- data->_rotateMode = (RotateMode)((flags >> 3) & 3);
|
|
|
- if ((flags & 128) != 0) data->_offsetRotation = readFloat(input);
|
|
|
+ int flags = readByte(input);
|
|
|
+ data->_positionMode = (PositionMode) (flags & 1);
|
|
|
+ data->_spacingMode = (SpacingMode) ((flags >> 1) & 3);
|
|
|
+ data->_rotateMode = (RotateMode) ((flags >> 3) & 3);
|
|
|
+ if ((flags & 128) != 0) data->_offsetRotation = readFloat(input);
|
|
|
data->_position = readFloat(input);
|
|
|
if (data->_positionMode == PositionMode_Fixed) data->_position *= _scale;
|
|
|
data->_spacing = readFloat(input);
|
|
@@ -291,40 +291,40 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
|
|
skeletonData->_pathConstraints[i] = data;
|
|
|
}
|
|
|
|
|
|
- // Physics constraints.
|
|
|
- int physicsConstraintsCount = readVarint(input, true);
|
|
|
- skeletonData->_physicsConstraints.setSize(physicsConstraintsCount, 0);
|
|
|
- for (int i = 0; i < physicsConstraintsCount; i++) {
|
|
|
- const char *name = readString(input);
|
|
|
- PhysicsConstraintData *data = new (__FILE__, __LINE__) PhysicsConstraintData(String(name, true));
|
|
|
- data->_order = readVarint(input, true);
|
|
|
- data->_bone = skeletonData->_bones[readVarint(input, true)];
|
|
|
- int flags = readByte(input);
|
|
|
- data->_skinRequired = (flags & 1) != 0;
|
|
|
- if ((flags & 2) != 0) data->_x = readFloat(input);
|
|
|
- if ((flags & 4) != 0) data->_y = readFloat(input);
|
|
|
- if ((flags & 8) != 0) data->_rotate = readFloat(input);
|
|
|
- if ((flags & 16) != 0) data->_scaleX = readFloat(input);
|
|
|
- if ((flags & 32) != 0) data->_shearX = readFloat(input);
|
|
|
- data->_limit = ((flags & 64) != 0 ? readFloat(input) : 5000) * _scale;
|
|
|
- data->_step = 1.f / readByte(input);
|
|
|
- data->_inertia = readFloat(input);
|
|
|
- data->_strength = readFloat(input);
|
|
|
- data->_damping = readFloat(input);
|
|
|
- data->_massInverse = (flags & 128) != 0 ? readFloat(input) : 1;
|
|
|
- data->_wind = readFloat(input);
|
|
|
- data->_gravity = readFloat(input);
|
|
|
- flags = readByte(input);
|
|
|
- if ((flags & 1) != 0) data->_inertiaGlobal = true;
|
|
|
- if ((flags & 2) != 0) data->_strengthGlobal = true;
|
|
|
- if ((flags & 4) != 0) data->_dampingGlobal = true;
|
|
|
- if ((flags & 8) != 0) data->_massGlobal = true;
|
|
|
- if ((flags & 16) != 0) data->_windGlobal = true;
|
|
|
- if ((flags & 32) != 0) data->_gravityGlobal = true;
|
|
|
- if ((flags & 64) != 0) data->_mixGlobal = true;
|
|
|
- data->_mix = (flags & 128) != 0 ? readFloat(input) : 1;
|
|
|
- skeletonData->_physicsConstraints[i] = data;
|
|
|
- }
|
|
|
+ // Physics constraints.
|
|
|
+ int physicsConstraintsCount = readVarint(input, true);
|
|
|
+ skeletonData->_physicsConstraints.setSize(physicsConstraintsCount, 0);
|
|
|
+ for (int i = 0; i < physicsConstraintsCount; i++) {
|
|
|
+ const char *name = readString(input);
|
|
|
+ PhysicsConstraintData *data = new (__FILE__, __LINE__) PhysicsConstraintData(String(name, true));
|
|
|
+ data->_order = readVarint(input, true);
|
|
|
+ data->_bone = skeletonData->_bones[readVarint(input, true)];
|
|
|
+ int flags = readByte(input);
|
|
|
+ data->_skinRequired = (flags & 1) != 0;
|
|
|
+ if ((flags & 2) != 0) data->_x = readFloat(input);
|
|
|
+ if ((flags & 4) != 0) data->_y = readFloat(input);
|
|
|
+ if ((flags & 8) != 0) data->_rotate = readFloat(input);
|
|
|
+ if ((flags & 16) != 0) data->_scaleX = readFloat(input);
|
|
|
+ if ((flags & 32) != 0) data->_shearX = readFloat(input);
|
|
|
+ data->_limit = ((flags & 64) != 0 ? readFloat(input) : 5000) * _scale;
|
|
|
+ data->_step = 1.f / readByte(input);
|
|
|
+ data->_inertia = readFloat(input);
|
|
|
+ data->_strength = readFloat(input);
|
|
|
+ data->_damping = readFloat(input);
|
|
|
+ data->_massInverse = (flags & 128) != 0 ? readFloat(input) : 1;
|
|
|
+ data->_wind = readFloat(input);
|
|
|
+ data->_gravity = readFloat(input);
|
|
|
+ flags = readByte(input);
|
|
|
+ if ((flags & 1) != 0) data->_inertiaGlobal = true;
|
|
|
+ if ((flags & 2) != 0) data->_strengthGlobal = true;
|
|
|
+ if ((flags & 4) != 0) data->_dampingGlobal = true;
|
|
|
+ if ((flags & 8) != 0) data->_massGlobal = true;
|
|
|
+ if ((flags & 16) != 0) data->_windGlobal = true;
|
|
|
+ if ((flags & 32) != 0) data->_gravityGlobal = true;
|
|
|
+ if ((flags & 64) != 0) data->_mixGlobal = true;
|
|
|
+ data->_mix = (flags & 128) != 0 ? readFloat(input) : 1;
|
|
|
+ skeletonData->_physicsConstraints[i] = data;
|
|
|
+ }
|
|
|
|
|
|
/* Default skin. */
|
|
|
Skin *defaultSkin = readSkin(input, true, skeletonData, nonessential);
|
|
@@ -507,7 +507,7 @@ Skin *SkeletonBinary::readSkin(DataInput *input, bool defaultSkin, SkeletonData
|
|
|
} else {
|
|
|
skin = new (__FILE__, __LINE__) Skin(String(readString(input), true));
|
|
|
|
|
|
- if (nonessential) readColor(input, skin->getColor());
|
|
|
+ if (nonessential) readColor(input, skin->getColor());
|
|
|
|
|
|
for (int i = 0, n = readVarint(input, true); i < n; i++) {
|
|
|
int boneIndex = readVarint(input, true);
|
|
@@ -533,11 +533,11 @@ Skin *SkeletonBinary::readSkin(DataInput *input, bool defaultSkin, SkeletonData
|
|
|
skin->getConstraints().add(skeletonData->_pathConstraints[pathIndex]);
|
|
|
}
|
|
|
|
|
|
- for (int i = 0, n = readVarint(input, true); i < n; i++) {
|
|
|
- int physicsIndex = readVarint(input, true);
|
|
|
- if (physicsIndex >= (int) skeletonData->_physicsConstraints.size()) return NULL;
|
|
|
- skin->getConstraints().add(skeletonData->_physicsConstraints[physicsIndex]);
|
|
|
- }
|
|
|
+ for (int i = 0, n = readVarint(input, true); i < n; i++) {
|
|
|
+ int physicsIndex = readVarint(input, true);
|
|
|
+ if (physicsIndex >= (int) skeletonData->_physicsConstraints.size()) return NULL;
|
|
|
+ skin->getConstraints().add(skeletonData->_physicsConstraints[physicsIndex]);
|
|
|
+ }
|
|
|
slotCount = readVarint(input, true);
|
|
|
}
|
|
|
|
|
@@ -568,16 +568,16 @@ Sequence *SkeletonBinary::readSequence(DataInput *input) {
|
|
|
Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slotIndex, const String &attachmentName,
|
|
|
SkeletonData *skeletonData, bool nonessential) {
|
|
|
|
|
|
- int flags = readByte(input);
|
|
|
- String name = (flags & 8) != 0 ? readStringRef(input, skeletonData) : attachmentName;
|
|
|
+ int flags = readByte(input);
|
|
|
+ String name = (flags & 8) != 0 ? readStringRef(input, skeletonData) : attachmentName;
|
|
|
AttachmentType type = static_cast<AttachmentType>(flags & 0x7);
|
|
|
switch (type) {
|
|
|
case AttachmentType_Region: {
|
|
|
- String path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : name;
|
|
|
- Color color(1, 1, 1, 1);
|
|
|
- if ((flags & 32) != 0) readColor(input, color);
|
|
|
- Sequence *sequence = (flags & 64) != 0 ? readSequence(input) : nullptr;
|
|
|
- float rotation = (flags & 128) != 0 ? readFloat(input) : 0;
|
|
|
+ String path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : name;
|
|
|
+ Color color(1, 1, 1, 1);
|
|
|
+ if ((flags & 32) != 0) readColor(input, color);
|
|
|
+ Sequence *sequence = (flags & 64) != 0 ? readSequence(input) : nullptr;
|
|
|
+ float rotation = (flags & 128) != 0 ? readFloat(input) : 0;
|
|
|
float x = readFloat(input) * _scale;
|
|
|
float y = readFloat(input) * _scale;
|
|
|
float scaleX = readFloat(input);
|
|
@@ -627,14 +627,14 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
|
|
float height = 0;
|
|
|
Vector<unsigned short> edges;
|
|
|
|
|
|
- String path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : name;
|
|
|
- Color color(1, 1, 1, 1);
|
|
|
- if ((flags & 32) != 0) readColor(input, color);
|
|
|
- Sequence *sequence = (flags & 64) != 0 ? readSequence(input) : nullptr;
|
|
|
+ String path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : name;
|
|
|
+ Color color(1, 1, 1, 1);
|
|
|
+ if ((flags & 32) != 0) readColor(input, color);
|
|
|
+ Sequence *sequence = (flags & 64) != 0 ? readSequence(input) : nullptr;
|
|
|
hullLength = readVarint(input, true);
|
|
|
- int verticesLength = readVertices(input, vertices, bones, (flags & 128) != 0);
|
|
|
- readFloatArray(input, verticesLength, 1, uvs);
|
|
|
- readShortArray(input, triangles, (verticesLength - hullLength - 2) * 3);
|
|
|
+ int verticesLength = readVertices(input, vertices, bones, (flags & 128) != 0);
|
|
|
+ readFloatArray(input, verticesLength, 1, uvs);
|
|
|
+ readShortArray(input, triangles, (verticesLength - hullLength - 2) * 3);
|
|
|
|
|
|
if (nonessential) {
|
|
|
readShortArray(input, edges, readVarint(input, true));
|
|
@@ -666,14 +666,14 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
|
|
return mesh;
|
|
|
}
|
|
|
case AttachmentType_Linkedmesh: {
|
|
|
- String path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : name;
|
|
|
- Color color(1, 1, 1, 1);
|
|
|
- if ((flags & 32) != 0) readColor(input, color);
|
|
|
- Sequence *sequence = (flags & 64) != 0 ? readSequence(input) : nullptr;
|
|
|
- bool inheritTimelines = (flags & 128) != 0;
|
|
|
- int skinIndex = readVarint(input, true);
|
|
|
+ String path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : name;
|
|
|
+ Color color(1, 1, 1, 1);
|
|
|
+ if ((flags & 32) != 0) readColor(input, color);
|
|
|
+ Sequence *sequence = (flags & 64) != 0 ? readSequence(input) : nullptr;
|
|
|
+ bool inheritTimelines = (flags & 128) != 0;
|
|
|
+ int skinIndex = readVarint(input, true);
|
|
|
String parent(readStringRef(input, skeletonData));
|
|
|
- float width = 0, height = 0;
|
|
|
+ float width = 0, height = 0;
|
|
|
if (nonessential) {
|
|
|
width = readFloat(input) * _scale;
|
|
|
height = readFloat(input) * _scale;
|
|
@@ -756,14 +756,14 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
|
|
|
|
|
int SkeletonBinary::readVertices(DataInput *input, Vector<float> &vertices, Vector<int> &bones, bool weighted) {
|
|
|
float scale = _scale;
|
|
|
- int vertexCount = readVarint(input, true);
|
|
|
+ int vertexCount = readVarint(input, true);
|
|
|
int verticesLength = vertexCount << 1;
|
|
|
- if (!weighted) {
|
|
|
- readFloatArray(input, verticesLength, scale, vertices);
|
|
|
- return verticesLength;
|
|
|
- }
|
|
|
- vertices.ensureCapacity(verticesLength * 3 * 3);
|
|
|
- bones.ensureCapacity(verticesLength * 3);
|
|
|
+ if (!weighted) {
|
|
|
+ readFloatArray(input, verticesLength, scale, vertices);
|
|
|
+ return verticesLength;
|
|
|
+ }
|
|
|
+ vertices.ensureCapacity(verticesLength * 3 * 3);
|
|
|
+ bones.ensureCapacity(verticesLength * 3);
|
|
|
for (int i = 0; i < vertexCount; ++i) {
|
|
|
int boneCount = readVarint(input, true);
|
|
|
bones.add(boneCount);
|
|
@@ -774,7 +774,7 @@ int SkeletonBinary::readVertices(DataInput *input, Vector<float> &vertices, Vect
|
|
|
vertices.add(readFloat(input));
|
|
|
}
|
|
|
}
|
|
|
- return verticesLength;
|
|
|
+ return verticesLength;
|
|
|
}
|
|
|
|
|
|
void SkeletonBinary::readFloatArray(DataInput *input, int n, float scale, Vector<float> &array) {
|
|
@@ -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) {
|
|
|
array.setSize(n, 0);
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
-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 value = readFloat(input) * scale;
|
|
|
for (int frame = 0, bezier = 0, frameLast = (int) timeline->getFrameCount() - 1;; frame++) {
|
|
@@ -827,10 +827,10 @@ void SkeletonBinary::readTimeline(DataInput *input, Vector<Timeline*> &timelines
|
|
|
time = time2;
|
|
|
value = value2;
|
|
|
}
|
|
|
- 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 value1 = readFloat(input) * scale;
|
|
|
float value2 = readFloat(input) * scale;
|
|
@@ -1086,61 +1086,61 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
|
|
for (int ii = 0, nn = readVarint(input, true); ii < nn; ++ii) {
|
|
|
unsigned char timelineType = readByte(input);
|
|
|
int frameCount = readVarint(input, true);
|
|
|
- if (timelineType == BONE_INHERIT) {
|
|
|
- InheritTimeline *timeline = new (__FILE__, __LINE__) InheritTimeline(frameCount, boneIndex);
|
|
|
- for (int frame = 0; frame < frameCount; frame++) {
|
|
|
- float time = readFloat(input);
|
|
|
- Inherit inherit = (Inherit)readByte(input);
|
|
|
- timeline->setFrame(frame, time, inherit);
|
|
|
- }
|
|
|
- timelines.add(timeline);
|
|
|
- continue;
|
|
|
- }
|
|
|
- int bezierCount = readVarint(input, true);
|
|
|
+ if (timelineType == BONE_INHERIT) {
|
|
|
+ InheritTimeline *timeline = new (__FILE__, __LINE__) InheritTimeline(frameCount, boneIndex);
|
|
|
+ for (int frame = 0; frame < frameCount; frame++) {
|
|
|
+ float time = readFloat(input);
|
|
|
+ Inherit inherit = (Inherit) readByte(input);
|
|
|
+ timeline->setFrame(frame, time, inherit);
|
|
|
+ }
|
|
|
+ timelines.add(timeline);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int bezierCount = readVarint(input, true);
|
|
|
switch (timelineType) {
|
|
|
case BONE_ROTATE:
|
|
|
readTimeline(input, timelines,
|
|
|
- new (__FILE__, __LINE__) RotateTimeline(frameCount, bezierCount, boneIndex),
|
|
|
- 1);
|
|
|
+ new (__FILE__, __LINE__) RotateTimeline(frameCount, bezierCount, boneIndex),
|
|
|
+ 1);
|
|
|
break;
|
|
|
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;
|
|
|
case BONE_TRANSLATEX:
|
|
|
readTimeline(input, timelines, new (__FILE__, __LINE__) TranslateXTimeline(frameCount, bezierCount, boneIndex), scale);
|
|
|
break;
|
|
|
case BONE_TRANSLATEY:
|
|
|
- readTimeline(input, timelines, new (__FILE__, __LINE__) TranslateYTimeline(frameCount, bezierCount, boneIndex), scale);
|
|
|
+ readTimeline(input, timelines, new (__FILE__, __LINE__) TranslateYTimeline(frameCount, bezierCount, boneIndex), scale);
|
|
|
break;
|
|
|
case BONE_SCALE:
|
|
|
readTimeline2(input, timelines,
|
|
|
- new (__FILE__, __LINE__) ScaleTimeline(frameCount, bezierCount, boneIndex),
|
|
|
- 1);
|
|
|
+ new (__FILE__, __LINE__) ScaleTimeline(frameCount, bezierCount, boneIndex),
|
|
|
+ 1);
|
|
|
break;
|
|
|
case BONE_SCALEX:
|
|
|
readTimeline(input, timelines,
|
|
|
- new (__FILE__, __LINE__) ScaleXTimeline(frameCount, bezierCount, boneIndex),
|
|
|
- 1);
|
|
|
+ new (__FILE__, __LINE__) ScaleXTimeline(frameCount, bezierCount, boneIndex),
|
|
|
+ 1);
|
|
|
break;
|
|
|
case BONE_SCALEY:
|
|
|
readTimeline(input, timelines,
|
|
|
- new (__FILE__, __LINE__) ScaleYTimeline(frameCount, bezierCount, boneIndex),
|
|
|
- 1);
|
|
|
+ new (__FILE__, __LINE__) ScaleYTimeline(frameCount, bezierCount, boneIndex),
|
|
|
+ 1);
|
|
|
break;
|
|
|
case BONE_SHEAR:
|
|
|
readTimeline2(input, timelines,
|
|
|
- new (__FILE__, __LINE__) ShearTimeline(frameCount, bezierCount, boneIndex),
|
|
|
- 1);
|
|
|
+ new (__FILE__, __LINE__) ShearTimeline(frameCount, bezierCount, boneIndex),
|
|
|
+ 1);
|
|
|
break;
|
|
|
case BONE_SHEARX:
|
|
|
readTimeline(input, timelines,
|
|
|
- new (__FILE__, __LINE__) ShearXTimeline(frameCount, bezierCount, boneIndex),
|
|
|
- 1);
|
|
|
+ new (__FILE__, __LINE__) ShearXTimeline(frameCount, bezierCount, boneIndex),
|
|
|
+ 1);
|
|
|
break;
|
|
|
case BONE_SHEARY:
|
|
|
readTimeline(input, timelines,
|
|
|
- new (__FILE__, __LINE__) ShearYTimeline(frameCount, bezierCount, boneIndex),
|
|
|
- 1);
|
|
|
+ new (__FILE__, __LINE__) ShearYTimeline(frameCount, bezierCount, boneIndex),
|
|
|
+ 1);
|
|
|
break;
|
|
|
default: {
|
|
|
ContainerUtil::cleanUpVectorOfPointers(timelines);
|
|
@@ -1158,19 +1158,19 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
|
|
int frameLast = frameCount - 1;
|
|
|
int bezierCount = readVarint(input, true);
|
|
|
IkConstraintTimeline *timeline = new (__FILE__, __LINE__) IkConstraintTimeline(frameCount, bezierCount, index);
|
|
|
- int flags = readByte(input);
|
|
|
- float time = readFloat(input), mix = (flags & 1) != 0 ? ((flags & 2) != 0 ? readFloat(input) : 1) : 0;
|
|
|
- float softness = (flags & 4) != 0 ? readFloat(input) * scale : 0;
|
|
|
- for (int frame = 0, bezier = 0;; frame++) {
|
|
|
+ int flags = readByte(input);
|
|
|
+ float time = readFloat(input), mix = (flags & 1) != 0 ? ((flags & 2) != 0 ? readFloat(input) : 1) : 0;
|
|
|
+ float softness = (flags & 4) != 0 ? readFloat(input) * scale : 0;
|
|
|
+ for (int frame = 0, bezier = 0;; frame++) {
|
|
|
timeline->setFrame(frame, time, mix, softness, (flags & 8) != 0 ? 1 : -1, (flags & 16) != 0, (flags & 32) != 0);
|
|
|
if (frame == frameLast) break;
|
|
|
- flags = readByte(input);
|
|
|
- float time2 = readFloat(input), mix2 = (flags & 1) != 0 ? ((flags & 2) != 0 ? readFloat(input) : 1) : 0;
|
|
|
- float softness2 = (flags & 4) != 0 ? readFloat(input) * scale : 0;
|
|
|
- if ((flags & 64) != 0)
|
|
|
- timeline->setStepped(frame);
|
|
|
- else if ((flags & 128) != 0) {
|
|
|
- setBezier(input, timeline, bezier++, frame, 0, time, time2, mix, mix2, 1);
|
|
|
+ flags = readByte(input);
|
|
|
+ float time2 = readFloat(input), mix2 = (flags & 1) != 0 ? ((flags & 2) != 0 ? readFloat(input) : 1) : 0;
|
|
|
+ float softness2 = (flags & 4) != 0 ? readFloat(input) * scale : 0;
|
|
|
+ if ((flags & 64) != 0)
|
|
|
+ timeline->setStepped(frame);
|
|
|
+ else if ((flags & 128) != 0) {
|
|
|
+ setBezier(input, timeline, bezier++, frame, 0, time, time2, mix, mix2, 1);
|
|
|
setBezier(input, timeline, bezier++, frame, 1, time, time2, softness, softness2, scale);
|
|
|
}
|
|
|
time = time2;
|
|
@@ -1235,21 +1235,21 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
|
|
int type = readByte(input);
|
|
|
int frameCount = readVarint(input, true);
|
|
|
int bezierCount = readVarint(input, true);
|
|
|
- switch (type) {
|
|
|
+ switch (type) {
|
|
|
case PATH_POSITION: {
|
|
|
readTimeline(input, timelines, new PathConstraintPositionTimeline(frameCount, bezierCount, index),
|
|
|
- data->_positionMode == PositionMode_Fixed ? scale : 1);
|
|
|
+ data->_positionMode == PositionMode_Fixed ? scale : 1);
|
|
|
break;
|
|
|
}
|
|
|
case PATH_SPACING: {
|
|
|
readTimeline(input, timelines,
|
|
|
- new PathConstraintSpacingTimeline(frameCount,
|
|
|
- bezierCount,
|
|
|
- index),
|
|
|
- data->_spacingMode == SpacingMode_Length ||
|
|
|
- data->_spacingMode == SpacingMode_Fixed
|
|
|
- ? scale
|
|
|
- : 1);
|
|
|
+ new PathConstraintSpacingTimeline(frameCount,
|
|
|
+ bezierCount,
|
|
|
+ index),
|
|
|
+ data->_spacingMode == SpacingMode_Length ||
|
|
|
+ data->_spacingMode == SpacingMode_Fixed
|
|
|
+ ? scale
|
|
|
+ : 1);
|
|
|
break;
|
|
|
}
|
|
|
case PATH_MIX:
|
|
@@ -1284,44 +1284,44 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Physics timelines.
|
|
|
- for (int i = 0, n = readVarint(input, true); i < n; i++) {
|
|
|
- int index = readVarint(input, true) - 1;
|
|
|
- for (int ii = 0, nn = readVarint(input, true); ii < nn; ii++) {
|
|
|
- int type = readByte(input);
|
|
|
- int frameCount = readVarint(input, true);
|
|
|
- if (type == PHYSICS_RESET) {
|
|
|
- PhysicsConstraintResetTimeline *timeline = new (__FILE__, __LINE__) PhysicsConstraintResetTimeline(frameCount, index);
|
|
|
- for (int frame = 0; frame < frameCount; frame++)
|
|
|
- timeline->setFrame(frame, readFloat(input));
|
|
|
- timelines.add(timeline);
|
|
|
- continue;
|
|
|
- }
|
|
|
- int bezierCount = readVarint(input, true);
|
|
|
- switch (type) {
|
|
|
- case PHYSICS_INERTIA:
|
|
|
- readTimeline(input, timelines, new PhysicsConstraintInertiaTimeline(frameCount, bezierCount, index), 1);
|
|
|
- break;
|
|
|
- case PHYSICS_STRENGTH:
|
|
|
- readTimeline(input, timelines, new PhysicsConstraintStrengthTimeline(frameCount, bezierCount, index), 1);
|
|
|
- break;
|
|
|
- case PHYSICS_DAMPING:
|
|
|
- readTimeline(input, timelines, new PhysicsConstraintDampingTimeline(frameCount, bezierCount, index), 1);
|
|
|
- break;
|
|
|
- case PHYSICS_MASS:
|
|
|
- readTimeline(input, timelines, new PhysicsConstraintMassTimeline(frameCount, bezierCount, index), 1);
|
|
|
- break;
|
|
|
- case PHYSICS_WIND:
|
|
|
- readTimeline(input, timelines, new PhysicsConstraintWindTimeline(frameCount, bezierCount, index), 1);
|
|
|
- break;
|
|
|
- case PHYSICS_GRAVITY:
|
|
|
- readTimeline(input, timelines, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, index), 1);
|
|
|
- break;
|
|
|
- case PHYSICS_MIX:
|
|
|
- readTimeline(input, timelines, new PhysicsConstraintMixTimeline(frameCount, bezierCount, index), 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // Physics timelines.
|
|
|
+ for (int i = 0, n = readVarint(input, true); i < n; i++) {
|
|
|
+ int index = readVarint(input, true) - 1;
|
|
|
+ for (int ii = 0, nn = readVarint(input, true); ii < nn; ii++) {
|
|
|
+ int type = readByte(input);
|
|
|
+ int frameCount = readVarint(input, true);
|
|
|
+ if (type == PHYSICS_RESET) {
|
|
|
+ PhysicsConstraintResetTimeline *timeline = new (__FILE__, __LINE__) PhysicsConstraintResetTimeline(frameCount, index);
|
|
|
+ for (int frame = 0; frame < frameCount; frame++)
|
|
|
+ timeline->setFrame(frame, readFloat(input));
|
|
|
+ timelines.add(timeline);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int bezierCount = readVarint(input, true);
|
|
|
+ switch (type) {
|
|
|
+ case PHYSICS_INERTIA:
|
|
|
+ readTimeline(input, timelines, new PhysicsConstraintInertiaTimeline(frameCount, bezierCount, index), 1);
|
|
|
+ break;
|
|
|
+ case PHYSICS_STRENGTH:
|
|
|
+ readTimeline(input, timelines, new PhysicsConstraintStrengthTimeline(frameCount, bezierCount, index), 1);
|
|
|
+ break;
|
|
|
+ case PHYSICS_DAMPING:
|
|
|
+ readTimeline(input, timelines, new PhysicsConstraintDampingTimeline(frameCount, bezierCount, index), 1);
|
|
|
+ break;
|
|
|
+ case PHYSICS_MASS:
|
|
|
+ readTimeline(input, timelines, new PhysicsConstraintMassTimeline(frameCount, bezierCount, index), 1);
|
|
|
+ break;
|
|
|
+ case PHYSICS_WIND:
|
|
|
+ readTimeline(input, timelines, new PhysicsConstraintWindTimeline(frameCount, bezierCount, index), 1);
|
|
|
+ break;
|
|
|
+ case PHYSICS_GRAVITY:
|
|
|
+ readTimeline(input, timelines, new PhysicsConstraintGravityTimeline(frameCount, bezierCount, index), 1);
|
|
|
+ break;
|
|
|
+ case PHYSICS_MIX:
|
|
|
+ readTimeline(input, timelines, new PhysicsConstraintMixTimeline(frameCount, bezierCount, index), 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// Attachment timelines.
|
|
|
for (int i = 0, n = readVarint(input, true); i < n; ++i) {
|
|
@@ -1467,12 +1467,12 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
|
|
event->_intValue = readVarint(input, false);
|
|
|
event->_floatValue = readFloat(input);
|
|
|
const char *event_stringValue = readString(input);
|
|
|
- if (event_stringValue == nullptr) {
|
|
|
- event->_stringValue = eventData->_stringValue;
|
|
|
- } else {
|
|
|
- event->_stringValue = String(event_stringValue);
|
|
|
- SpineExtension::free(event_stringValue, __FILE__, __LINE__);
|
|
|
- }
|
|
|
+ if (event_stringValue == nullptr) {
|
|
|
+ event->_stringValue = eventData->_stringValue;
|
|
|
+ } else {
|
|
|
+ event->_stringValue = String(event_stringValue);
|
|
|
+ SpineExtension::free(event_stringValue, __FILE__, __LINE__);
|
|
|
+ }
|
|
|
|
|
|
if (!eventData->_audioPath.isEmpty()) {
|
|
|
event->_volume = readFloat(input);
|