Revert "fix warnings (#1034)"

This reverts commit 5948e5a62f0d9fb5a526c200dc70a81d286b1e38.
This commit is contained in:
badlogic 2017-12-06 15:35:02 +01:00
parent 1132594797
commit f40efe6066
8 changed files with 52 additions and 50 deletions

View File

@ -745,7 +745,7 @@ void _spAttachmentTimeline_apply (const spTimeline* timeline, spSkeleton* skelet
spSlot* slot = skeleton->slots[self->slotIndex]; spSlot* slot = skeleton->slots[self->slotIndex];
if (direction == SP_MIX_DIRECTION_OUT && pose == SP_MIX_POSE_SETUP) { if (direction == SP_MIX_DIRECTION_OUT && pose == SP_MIX_POSE_SETUP) {
attachmentName = slot->data->attachmentName; const char* attachmentName = slot->data->attachmentName;
spSlot_setAttachment(slot, attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0); spSlot_setAttachment(slot, attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0);
return; return;
} }

View File

@ -307,8 +307,9 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
break; break;
} }
default: { default: {
for (iii = 0; iii < kv_size(timelines); ++iii) int i;
spTimeline_dispose(kv_A(timelines, iii)); for (i = 0; i < kv_size(timelines); ++i)
spTimeline_dispose(kv_A(timelines, i));
kv_destroy(timelines); kv_destroy(timelines);
_spSkeletonBinary_setError(self, "Invalid timeline type for a slot: ", skeletonData->slots[slotIndex]->name); _spSkeletonBinary_setError(self, "Invalid timeline type for a slot: ", skeletonData->slots[slotIndex]->name);
return 0; return 0;
@ -369,8 +370,9 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
break; break;
} }
default: { default: {
for (iii = 0; iii < kv_size(timelines); ++iii) int i;
spTimeline_dispose(kv_A(timelines, iii)); for (i = 0; i < kv_size(timelines); ++i)
spTimeline_dispose(kv_A(timelines, i));
kv_destroy(timelines); kv_destroy(timelines);
_spSkeletonBinary_setError(self, "Invalid timeline type for a bone: ", skeletonData->bones[boneIndex]->name); _spSkeletonBinary_setError(self, "Invalid timeline type for a bone: ", skeletonData->bones[boneIndex]->name);
return 0; return 0;
@ -480,9 +482,9 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
spVertexAttachment* attachment = SUB_CAST(spVertexAttachment, spVertexAttachment* attachment = SUB_CAST(spVertexAttachment,
spSkin_getAttachment(skin, slotIndex, attachmentName)); spSkin_getAttachment(skin, slotIndex, attachmentName));
if (!attachment) { if (!attachment) {
int iiii; int i;
for (iiii = 0; iiii < kv_size(timelines); ++iiii) for (i = 0; i < kv_size(timelines); ++i)
spTimeline_dispose(kv_A(timelines, iiii)); spTimeline_dispose(kv_A(timelines, i));
kv_destroy(timelines); kv_destroy(timelines);
_spSkeletonBinary_setError(self, "Attachment not found: ", attachmentName); _spSkeletonBinary_setError(self, "Attachment not found: ", attachmentName);
FREE(attachmentName); FREE(attachmentName);
@ -599,7 +601,7 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
animation = spAnimation_create(name, 0); animation = spAnimation_create(name, 0);
FREE(animation->timelines); FREE(animation->timelines);
animation->duration = duration; animation->duration = duration;
animation->timelinesCount = (int)kv_size(timelines); animation->timelinesCount = kv_size(timelines);
animation->timelines = kv_array(timelines); animation->timelines = kv_array(timelines);
return animation; return animation;
} }
@ -663,11 +665,11 @@ static void _readVertices(spSkeletonBinary* self, _dataInput* input, spVertexAtt
} }
kv_trim(float, weights); kv_trim(float, weights);
attachment->verticesCount = (int)kv_size(weights); attachment->verticesCount = kv_size(weights);
attachment->vertices = kv_array(weights); attachment->vertices = kv_array(weights);
kv_trim(int, bones); kv_trim(int, bones);
attachment->bonesCount = (int)kv_size(bones); attachment->bonesCount = kv_size(bones);
attachment->bones = kv_array(bones); attachment->bones = kv_array(bones);
} }

View File

@ -94,8 +94,7 @@ static float toColor (const char* value, int index) {
int color; int color;
if (index >= strlen(value) / 2) if (index >= strlen(value) / 2)
return -1; return -1;
value += index * 2; value += index * 2;
digits[0] = *value; digits[0] = *value;
@ -404,33 +403,33 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) {
Json* vertices = Json_getItem(valueMap, "vertices"); Json* vertices = Json_getItem(valueMap, "vertices");
float* deform2; float* deform;
if (!vertices) { if (!vertices) {
if (weighted) { if (weighted) {
deform2 = tempDeform; deform = tempDeform;
memset(deform, 0, sizeof(float) * deformLength); memset(deform, 0, sizeof(float) * deformLength);
} else } else
deform2 = attachment->vertices; deform = attachment->vertices;
} else { } else {
int v, start = Json_getInt(valueMap, "offset", 0); int v, start = Json_getInt(valueMap, "offset", 0);
Json* vertex; Json* vertex;
deform2 = tempDeform; deform = tempDeform;
memset(deform, 0, sizeof(float) * start); memset(deform, 0, sizeof(float) * start);
if (self->scale == 1) { if (self->scale == 1) {
for (vertex = vertices->child, v = start; vertex; vertex = vertex->next, ++v) for (vertex = vertices->child, v = start; vertex; vertex = vertex->next, ++v)
deform2[v] = vertex->valueFloat; deform[v] = vertex->valueFloat;
} else { } else {
for (vertex = vertices->child, v = start; vertex; vertex = vertex->next, ++v) for (vertex = vertices->child, v = start; vertex; vertex = vertex->next, ++v)
deform2[v] = vertex->valueFloat * self->scale; deform[v] = vertex->valueFloat * self->scale;
} }
memset(deform + v, 0, sizeof(float) * (deformLength - v)); memset(deform + v, 0, sizeof(float) * (deformLength - v));
if (!weighted) { if (!weighted) {
float* verticesAttachment = attachment->vertices; float* vertices = attachment->vertices;
for (v = 0; v < deformLength; ++v) for (v = 0; v < deformLength; ++v)
deform2[v] += verticesAttachment[v]; deform[v] += vertices[v];
} }
} }
spDeformTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), deform2); spDeformTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), deform);
readCurve(valueMap, SUPER(timeline), frameIndex); readCurve(valueMap, SUPER(timeline), frameIndex);
} }
FREE(tempDeform); FREE(tempDeform);
@ -446,16 +445,16 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
spDrawOrderTimeline* timeline = spDrawOrderTimeline_create(drawOrder->size, skeletonData->slotsCount); spDrawOrderTimeline* timeline = spDrawOrderTimeline_create(drawOrder->size, skeletonData->slotsCount);
for (valueMap = drawOrder->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { for (valueMap = drawOrder->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) {
int ii; int ii;
int* drawOrder2 = 0; int* drawOrder = 0;
Json* offsets = Json_getItem(valueMap, "offsets"); Json* offsets = Json_getItem(valueMap, "offsets");
if (offsets) { if (offsets) {
Json* offsetMap; Json* offsetMap;
int* unchanged = MALLOC(int, skeletonData->slotsCount - offsets->size); int* unchanged = MALLOC(int, skeletonData->slotsCount - offsets->size);
int originalIndex = 0, unchangedIndex = 0; int originalIndex = 0, unchangedIndex = 0;
drawOrder2 = MALLOC(int, skeletonData->slotsCount); drawOrder = MALLOC(int, skeletonData->slotsCount);
for (ii = skeletonData->slotsCount - 1; ii >= 0; --ii) for (ii = skeletonData->slotsCount - 1; ii >= 0; --ii)
drawOrder2[ii] = -1; drawOrder[ii] = -1;
for (offsetMap = offsets->child; offsetMap; offsetMap = offsetMap->next) { for (offsetMap = offsets->child; offsetMap; offsetMap = offsetMap->next) {
int slotIndex = spSkeletonData_findSlotIndex(skeletonData, Json_getString(offsetMap, "slot", 0)); int slotIndex = spSkeletonData_findSlotIndex(skeletonData, Json_getString(offsetMap, "slot", 0));
@ -468,7 +467,7 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
while (originalIndex != slotIndex) while (originalIndex != slotIndex)
unchanged[unchangedIndex++] = originalIndex++; unchanged[unchangedIndex++] = originalIndex++;
/* Set changed items. */ /* Set changed items. */
drawOrder2[originalIndex + Json_getInt(offsetMap, "offset", 0)] = originalIndex; drawOrder[originalIndex + Json_getInt(offsetMap, "offset", 0)] = originalIndex;
originalIndex++; originalIndex++;
} }
/* Collect remaining unchanged items. */ /* Collect remaining unchanged items. */
@ -476,11 +475,11 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
unchanged[unchangedIndex++] = originalIndex++; unchanged[unchangedIndex++] = originalIndex++;
/* Fill in unchanged items. */ /* Fill in unchanged items. */
for (ii = skeletonData->slotsCount - 1; ii >= 0; ii--) for (ii = skeletonData->slotsCount - 1; ii >= 0; ii--)
if (drawOrder2[ii] == -1) drawOrder2[ii] = unchanged[--unchangedIndex]; if (drawOrder[ii] == -1) drawOrder[ii] = unchanged[--unchangedIndex];
FREE(unchanged); FREE(unchanged);
} }
spDrawOrderTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), drawOrder2); spDrawOrderTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), drawOrder);
FREE(drawOrder2); FREE(drawOrder);
} }
animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline); animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
animation->duration = MAX(animation->duration, timeline->frames[drawOrder->size - 1]); animation->duration = MAX(animation->duration, timeline->frames[drawOrder->size - 1]);
@ -874,7 +873,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
spAttachment* attachment; spAttachment* attachment;
const char* skinAttachmentName = attachmentMap->name; const char* skinAttachmentName = attachmentMap->name;
const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName); const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName);
const char* attachmentPath = Json_getString(attachmentMap, "path", attachmentName); const char* path = Json_getString(attachmentMap, "path", attachmentName);
const char* color; const char* color;
Json* entry; Json* entry;
@ -898,7 +897,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
return 0; return 0;
} }
attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, attachmentName, attachmentPath); attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, attachmentName, path);
if (!attachment) { if (!attachment) {
if (self->attachmentLoader->error1) { if (self->attachmentLoader->error1) {
spSkeletonData_dispose(skeletonData); spSkeletonData_dispose(skeletonData);
@ -911,7 +910,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
switch (attachment->type) { switch (attachment->type) {
case SP_ATTACHMENT_REGION: { case SP_ATTACHMENT_REGION: {
spRegionAttachment* region = SUB_CAST(spRegionAttachment, attachment); spRegionAttachment* region = SUB_CAST(spRegionAttachment, attachment);
if (path) MALLOC_STR(region->path, attachmentPath); if (path) MALLOC_STR(region->path, path);
region->x = Json_getFloat(attachmentMap, "x", 0) * self->scale; region->x = Json_getFloat(attachmentMap, "x", 0) * self->scale;
region->y = Json_getFloat(attachmentMap, "y", 0) * self->scale; region->y = Json_getFloat(attachmentMap, "y", 0) * self->scale;
region->scaleX = Json_getFloat(attachmentMap, "scaleX", 1); region->scaleX = Json_getFloat(attachmentMap, "scaleX", 1);
@ -938,7 +937,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
case SP_ATTACHMENT_LINKED_MESH: { case SP_ATTACHMENT_LINKED_MESH: {
spMeshAttachment* mesh = SUB_CAST(spMeshAttachment, attachment); spMeshAttachment* mesh = SUB_CAST(spMeshAttachment, attachment);
MALLOC_STR(mesh->path, attachmentPath); MALLOC_STR(mesh->path, path);
color = Json_getString(attachmentMap, "color", 0); color = Json_getString(attachmentMap, "color", 0);
if (color) { if (color) {
@ -998,19 +997,19 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
break; break;
} }
case SP_ATTACHMENT_PATH: { case SP_ATTACHMENT_PATH: {
spPathAttachment* pathAttatchment = SUB_CAST(spPathAttachment, attachment); spPathAttachment* path = SUB_CAST(spPathAttachment, attachment);
int vertexCount = 0; int vertexCount = 0;
pathAttatchment->closed = Json_getInt(attachmentMap, "closed", 0); path->closed = Json_getInt(attachmentMap, "closed", 0);
pathAttatchment->constantSpeed = Json_getInt(attachmentMap, "constantSpeed", 1); path->constantSpeed = Json_getInt(attachmentMap, "constantSpeed", 1);
vertexCount = Json_getInt(attachmentMap, "vertexCount", 0); vertexCount = Json_getInt(attachmentMap, "vertexCount", 0);
_readVertices(self, attachmentMap, SUPER(pathAttatchment), vertexCount << 1); _readVertices(self, attachmentMap, SUPER(path), vertexCount << 1);
pathAttatchment->lengthsLength = vertexCount / 3; path->lengthsLength = vertexCount / 3;
pathAttatchment->lengths = MALLOC(float, pathAttatchment->lengthsLength); path->lengths = MALLOC(float, path->lengthsLength);
curves = Json_getItem(attachmentMap, "lengths"); curves = Json_getItem(attachmentMap, "lengths");
for (curves = curves->child, ii = 0; curves; curves = curves->next, ++ii) { for (curves = curves->child, ii = 0; curves; curves = curves->next, ++ii) {
pathAttatchment->lengths[ii] = curves->valueFloat * self->scale; path->lengths[ii] = curves->valueFloat * self->scale;
} }
break; break;
} }

View File

@ -152,9 +152,8 @@ spShortArray* spTriangulator_triangulate(spTriangulator* self, spFloatArray* ver
spShortArray_ensureCapacity(triangles, MAX(0, vertexCount - 2) << 2); spShortArray_ensureCapacity(triangles, MAX(0, vertexCount - 2) << 2);
while (vertexCount > 3) { while (vertexCount > 3) {
int previous = vertexCount - 1, next = 1; int previous = vertexCount - 1, i = 0, next = 1;
int previousIndex, nextIndex; int previousIndex, nextIndex;
i = 0;
while (1) { while (1) {
if (!isConcave[i]) { if (!isConcave[i]) {
int p1 = indices[previous] << 1, p2 = indices[i] << 1, p3 = indices[next] << 1; int p1 = indices[previous] << 1, p2 = indices[i] << 1, p3 = indices[next] << 1;

View File

@ -114,6 +114,8 @@ void SkeletonAnimation::initialize () {
_state = spAnimationState_create(spAnimationStateData_create(_skeleton->data)); _state = spAnimationState_create(spAnimationStateData_create(_skeleton->data));
_state->rendererObject = this; _state->rendererObject = this;
_state->listener = animationCallback; _state->listener = animationCallback;
_spAnimationState* stateInternal = (_spAnimationState*)_state;
} }
SkeletonAnimation::SkeletonAnimation () SkeletonAnimation::SkeletonAnimation ()

View File

@ -146,8 +146,8 @@ void SkeletonBatch::reset() {
cocos2d::TrianglesCommand* SkeletonBatch::nextFreeCommand() { cocos2d::TrianglesCommand* SkeletonBatch::nextFreeCommand() {
if (_commandsPool.size() <= _nextFreeCommand) { if (_commandsPool.size() <= _nextFreeCommand) {
size_t newSize = _commandsPool.size() * 2 + 1; unsigned int newSize = _commandsPool.size() * 2 + 1;
for (size_t i = _commandsPool.size(); i < newSize; i++) { for (int i = _commandsPool.size(); i < newSize; i++) {
_commandsPool.push_back(new TrianglesCommand()); _commandsPool.push_back(new TrianglesCommand());
} }
} }

View File

@ -282,8 +282,8 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount; trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachmentVertices->_triangles->vertCount); trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachmentVertices->_triangles->vertCount);
trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount; trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
for (int ii = 0; ii < trianglesTwoColor.vertCount; ii++) { for (int i = 0; i < trianglesTwoColor.vertCount; i++) {
trianglesTwoColor.verts[ii].texCoords = attachmentVertices->_triangles->verts[ii].texCoords; trianglesTwoColor.verts[i].texCoords = attachmentVertices->_triangles->verts[i].texCoords;
} }
spRegionAttachment_computeWorldVertices(attachment, slot->bone, (float*)trianglesTwoColor.verts, 0, 7); spRegionAttachment_computeWorldVertices(attachment, slot->bone, (float*)trianglesTwoColor.verts, 0, 7);
} }
@ -311,8 +311,8 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount; trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachmentVertices->_triangles->vertCount); trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachmentVertices->_triangles->vertCount);
trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount; trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
for (int ii = 0; ii < trianglesTwoColor.vertCount; ii++) { for (int i = 0; i < trianglesTwoColor.vertCount; i++) {
trianglesTwoColor.verts[ii].texCoords = attachmentVertices->_triangles->verts[ii].texCoords; trianglesTwoColor.verts[i].texCoords = attachmentVertices->_triangles->verts[i].texCoords;
} }
spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, trianglesTwoColor.vertCount * sizeof(V3F_C4B_C4B_T2F) / 4, (float*)trianglesTwoColor.verts, 0, 7); spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, trianglesTwoColor.vertCount * sizeof(V3F_C4B_C4B_T2F) / 4, (float*)trianglesTwoColor.verts, 0, 7);
} }

View File

@ -336,8 +336,8 @@ void SkeletonTwoColorBatch::reset() {
TwoColorTrianglesCommand* SkeletonTwoColorBatch::nextFreeCommand() { TwoColorTrianglesCommand* SkeletonTwoColorBatch::nextFreeCommand() {
if (_commandsPool.size() <= _nextFreeCommand) { if (_commandsPool.size() <= _nextFreeCommand) {
size_t newSize = _commandsPool.size() * 2 + 1; unsigned int newSize = _commandsPool.size() * 2 + 1;
for (size_t i = _commandsPool.size(); i < newSize; i++) { for (int i = _commandsPool.size(); i < newSize; i++) {
_commandsPool.push_back(new TwoColorTrianglesCommand()); _commandsPool.push_back(new TwoColorTrianglesCommand());
} }
} }