mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-22 02:06:03 +08:00
[c] Fix readVarint, closes #2281
This commit is contained in:
parent
350ad06269
commit
fc1cc6f0ee
@ -20,24 +20,25 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(spine-c)
|
|
||||||
add_subdirectory(spine-cpp)
|
|
||||||
add_subdirectory(spine-cpp/spine-cpp-unit-tests)
|
|
||||||
|
|
||||||
if((${SPINE_SFML}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-sfml"))
|
if((${SPINE_SFML}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-sfml"))
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
set(CMAKE_OSX_ARCHITECTURES x86_64)
|
set(CMAKE_OSX_ARCHITECTURES x86_64)
|
||||||
set(ONLY_ACTIVE_ARCH NO)
|
set(ONLY_ACTIVE_ARCH NO)
|
||||||
endif()
|
endif()
|
||||||
|
add_subdirectory(spine-c)
|
||||||
|
add_subdirectory(spine-cpp)
|
||||||
add_subdirectory(spine-sfml/c)
|
add_subdirectory(spine-sfml/c)
|
||||||
add_subdirectory(spine-sfml/cpp)
|
add_subdirectory(spine-sfml/cpp)
|
||||||
endif()
|
elseif((${SPINE_SDL}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-sdl"))
|
||||||
|
|
||||||
if((${SPINE_SDL}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-sdl"))
|
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
set(CMAKE_OSX_ARCHITECTURES x86_64;arm64)
|
set(CMAKE_OSX_ARCHITECTURES x86_64;arm64)
|
||||||
set(ONLY_ACTIVE_ARCH NO)
|
set(ONLY_ACTIVE_ARCH NO)
|
||||||
endif()
|
endif()
|
||||||
|
add_subdirectory(spine-c)
|
||||||
|
add_subdirectory(spine-cpp)
|
||||||
add_subdirectory(spine-sdl)
|
add_subdirectory(spine-sdl)
|
||||||
|
else()
|
||||||
|
add_subdirectory(spine-c)
|
||||||
|
add_subdirectory(spine-cpp)
|
||||||
|
add_subdirectory(spine-cpp/spine-cpp-unit-tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@ -114,7 +114,7 @@ static int readInt(_dataInput *input) {
|
|||||||
|
|
||||||
static int readVarint(_dataInput *input, int /*bool*/ optimizePositive) {
|
static int readVarint(_dataInput *input, int /*bool*/ optimizePositive) {
|
||||||
unsigned char b = readByte(input);
|
unsigned char b = readByte(input);
|
||||||
uint32_t value = b & 0x7F;
|
int32_t value = b & 0x7F;
|
||||||
if (b & 0x80) {
|
if (b & 0x80) {
|
||||||
b = readByte(input);
|
b = readByte(input);
|
||||||
value |= (b & 0x7F) << 7;
|
value |= (b & 0x7F) << 7;
|
||||||
@ -124,13 +124,12 @@ static int readVarint(_dataInput *input, int /*bool*/ optimizePositive) {
|
|||||||
if (b & 0x80) {
|
if (b & 0x80) {
|
||||||
b = readByte(input);
|
b = readByte(input);
|
||||||
value |= (b & 0x7F) << 21;
|
value |= (b & 0x7F) << 21;
|
||||||
if (b & 0x80) value |= (uint32_t) (readByte(input) & 0x7F) << 28;
|
if (b & 0x80) value |= (readByte(input) & 0x7F) << 28;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!optimizePositive)
|
if (!optimizePositive) value = (((unsigned int) value >> 1) ^ -(value & 1));
|
||||||
value = ((unsigned int) value >> 1) ^ (~(value & 1));
|
return value;
|
||||||
return (int) value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float readFloat(_dataInput *input) {
|
float readFloat(_dataInput *input) {
|
||||||
@ -1031,9 +1030,10 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
{
|
{
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name,
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name,
|
||||||
path, sequence);
|
path, sequence);
|
||||||
|
spRegionAttachment *region = NULL;
|
||||||
if (!attachment)
|
if (!attachment)
|
||||||
return NULL;
|
return NULL;
|
||||||
spRegionAttachment *region = SUB_CAST(spRegionAttachment, attachment);
|
region = SUB_CAST(spRegionAttachment, attachment);
|
||||||
region->path = path;
|
region->path = path;
|
||||||
region->rotation = rotation;
|
region->rotation = rotation;
|
||||||
region->x = x;
|
region->x = x;
|
||||||
@ -1053,9 +1053,10 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
int vertexCount = readVarint(input, 1);
|
int vertexCount = readVarint(input, 1);
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
||||||
NULL);
|
NULL);
|
||||||
|
spVertexAttachment *vertexAttachment = NULL;
|
||||||
if (!attachment)
|
if (!attachment)
|
||||||
return NULL;
|
return NULL;
|
||||||
spVertexAttachment *vertexAttachment = SUB_CAST(spVertexAttachment, attachment);
|
vertexAttachment = SUB_CAST(spVertexAttachment, attachment);
|
||||||
_readVertices(self, input, &vertexAttachment->bonesCount, &vertexAttachment->bones,
|
_readVertices(self, input, &vertexAttachment->bonesCount, &vertexAttachment->bones,
|
||||||
&vertexAttachment->verticesCount, &vertexAttachment->vertices,
|
&vertexAttachment->verticesCount, &vertexAttachment->vertices,
|
||||||
&vertexAttachment->worldVerticesLength, vertexCount);
|
&vertexAttachment->worldVerticesLength, vertexCount);
|
||||||
@ -1106,9 +1107,10 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
|
|
||||||
{
|
{
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path, sequence);
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path, sequence);
|
||||||
|
spMeshAttachment *mesh = NULL;
|
||||||
if (!attachment)
|
if (!attachment)
|
||||||
return NULL;
|
return NULL;
|
||||||
spMeshAttachment *mesh = SUB_CAST(spMeshAttachment, attachment);
|
mesh = SUB_CAST(spMeshAttachment, attachment);
|
||||||
mesh->path = path;
|
mesh->path = path;
|
||||||
spColor_setFromColor(&mesh->color, &color);
|
spColor_setFromColor(&mesh->color, &color);
|
||||||
mesh->regionUVs = regionUVs;
|
mesh->regionUVs = regionUVs;
|
||||||
@ -1157,9 +1159,10 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
|
|
||||||
{
|
{
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path, sequence);
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path, sequence);
|
||||||
|
spMeshAttachment *mesh = NULL;
|
||||||
if (!attachment)
|
if (!attachment)
|
||||||
return NULL;
|
return NULL;
|
||||||
spMeshAttachment *mesh = SUB_CAST(spMeshAttachment, attachment);
|
mesh = SUB_CAST(spMeshAttachment, attachment);
|
||||||
mesh->path = path;
|
mesh->path = path;
|
||||||
spColor_setFromColor(&mesh->color, &color);
|
spColor_setFromColor(&mesh->color, &color);
|
||||||
mesh->sequence = sequence;
|
mesh->sequence = sequence;
|
||||||
@ -1172,11 +1175,13 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
case SP_ATTACHMENT_PATH: {
|
case SP_ATTACHMENT_PATH: {
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
||||||
NULL);
|
NULL);
|
||||||
|
spPathAttachment *path = NULL;
|
||||||
|
spVertexAttachment *vertexAttachment = NULL;
|
||||||
|
int vertexCount = 0;
|
||||||
if (!attachment)
|
if (!attachment)
|
||||||
return NULL;
|
return NULL;
|
||||||
spPathAttachment *path = SUB_CAST(spPathAttachment, attachment);
|
path = SUB_CAST(spPathAttachment, attachment);
|
||||||
spVertexAttachment *vertexAttachment = SUPER(path);
|
vertexAttachment = SUPER(path);
|
||||||
int vertexCount = 0;
|
|
||||||
path->closed = readBoolean(input);
|
path->closed = readBoolean(input);
|
||||||
path->constantSpeed = readBoolean(input);
|
path->constantSpeed = readBoolean(input);
|
||||||
vertexCount = readVarint(input, 1);
|
vertexCount = readVarint(input, 1);
|
||||||
@ -1197,9 +1202,10 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
case SP_ATTACHMENT_POINT: {
|
case SP_ATTACHMENT_POINT: {
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
||||||
NULL);
|
NULL);
|
||||||
|
spPointAttachment *point = NULL;
|
||||||
if (!attachment)
|
if (!attachment)
|
||||||
return NULL;
|
return NULL;
|
||||||
spPointAttachment *point = SUB_CAST(spPointAttachment, attachment);
|
point = SUB_CAST(spPointAttachment, attachment);
|
||||||
point->rotation = readFloat(input);
|
point->rotation = readFloat(input);
|
||||||
point->x = readFloat(input) * self->scale;
|
point->x = readFloat(input) * self->scale;
|
||||||
point->y = readFloat(input) * self->scale;
|
point->y = readFloat(input) * self->scale;
|
||||||
@ -1215,10 +1221,12 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
|
|||||||
int vertexCount = readVarint(input, 1);
|
int vertexCount = readVarint(input, 1);
|
||||||
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
spAttachment *attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0,
|
||||||
NULL);
|
NULL);
|
||||||
|
spClippingAttachment *clip = NULL;
|
||||||
|
spVertexAttachment *vertexAttachment = NULL;
|
||||||
if (!attachment)
|
if (!attachment)
|
||||||
return NULL;
|
return NULL;
|
||||||
spClippingAttachment *clip = SUB_CAST(spClippingAttachment, attachment);
|
clip = SUB_CAST(spClippingAttachment, attachment);
|
||||||
spVertexAttachment *vertexAttachment = SUPER(clip);
|
vertexAttachment = SUPER(clip);
|
||||||
_readVertices(self, input, &vertexAttachment->bonesCount, &vertexAttachment->bones,
|
_readVertices(self, input, &vertexAttachment->bonesCount, &vertexAttachment->bones,
|
||||||
&vertexAttachment->verticesCount, &vertexAttachment->vertices,
|
&vertexAttachment->verticesCount, &vertexAttachment->vertices,
|
||||||
&vertexAttachment->worldVerticesLength, vertexCount);
|
&vertexAttachment->worldVerticesLength, vertexCount);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user