[cpp] Fix more warnings on latest Clang.

This commit is contained in:
Mario Zechner 2022-11-03 16:52:22 +01:00
parent 2e179b4e03
commit 4a89b2b84d
5 changed files with 14 additions and 10 deletions

View File

@ -61,7 +61,7 @@ namespace spine {
void updateRegion(); void updateRegion();
/// Transforms the attachment's four vertices to world coordinates. /// Transforms the attachment's four vertices to world coordinates.
/// @param bone The parent bone. /// @param slot The parent slot.
/// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + 8. /// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + 8.
/// @param offset The worldVertices index to begin writing values. /// @param offset The worldVertices index to begin writing values.
/// @param stride The number of worldVertices entries between the value pairs written. /// @param stride The number of worldVertices entries between the value pairs written.

View File

@ -523,7 +523,7 @@ void Bone::updateAppliedTransform() {
break; break;
} }
case TransformMode_NoScale: case TransformMode_NoScale:
case TransformMode_NoScaleOrReflection: case TransformMode_NoScaleOrReflection: {
float cos = MathUtil::cosDeg(_rotation), sin = MathUtil::sinDeg(_rotation); float cos = MathUtil::cosDeg(_rotation), sin = MathUtil::sinDeg(_rotation);
pa = (pa * cos + pb * sin) / _skeleton.getScaleX(); pa = (pa * cos + pb * sin) / _skeleton.getScaleX();
pc = (pc * cos + pd * sin) / _skeleton.getScaleY(); pc = (pc * cos + pd * sin) / _skeleton.getScaleY();
@ -541,6 +541,10 @@ void Bone::updateAppliedTransform() {
ib = pb * pid; ib = pb * pid;
ic = pc * pid; ic = pc * pid;
id = pa * pid; id = pa * pid;
break;
}
default:
break;
} }
ra = ia * _a - ib * _c; ra = ia * _a - ib * _c;
rb = ia * _b - ib * _d; rb = ia * _b - ib * _d;

View File

@ -154,11 +154,11 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY
} }
x = targetX - pp->_worldX; x = targetX - pp->_worldX;
y = targetY - pp->_worldY; y = targetY - pp->_worldY;
tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py; tx = (x * d - y * b) * id - px; ty = (y * a - x * c) * id - py;
dd = tx * tx + ty * ty; dd = tx * tx + ty * ty;
if (softness != 0) { if (softness != 0) {
softness *= psx * (csx + 1) * 0.5f; softness *= psx * (csx + 1) * 0.5f;
td = MathUtil::sqrt(dd), sd = td - l1 - l2 * psx + softness; td = MathUtil::sqrt(dd); sd = td - l1 - l2 * psx + softness;
if (sd > 0) { if (sd > 0) {
p = MathUtil::min(1.0f, sd / (softness * 2)) - 1; p = MathUtil::min(1.0f, sd / (softness * 2)) - 1;
p = (sd - softness * (1 - p * p)) / td; p = (sd - softness * (1 - p * p)) / td;
@ -188,7 +188,7 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY
b = l2 * MathUtil::sin(a2); b = l2 * MathUtil::sin(a2);
a1 = MathUtil::atan2(ty * a - tx * b, tx * a + ty * b); a1 = MathUtil::atan2(ty * a - tx * b, tx * a + ty * b);
} else { } else {
a = psx * l2, b = psy * l2; a = psx * l2; b = psy * l2;
float aa = a * a, bb = b * b, ll = l1 * l1, ta = MathUtil::atan2(ty, tx); float aa = a * a, bb = b * b, ll = l1 * l1, ta = MathUtil::atan2(ty, tx);
float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa; float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa;
d = c1 * c1 - 4 * c2 * c0; d = c1 * c1 - 4 * c2 * c0;

View File

@ -109,9 +109,9 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
int lowHash = readInt(input); int lowHash = readInt(input);
int hightHash = readInt(input); int hightHash = readInt(input);
String hashString; String hashString;
sprintf(buffer, "%x", hightHash); snprintf(buffer, 16, "%x", hightHash);
hashString.append(buffer); hashString.append(buffer);
sprintf(buffer, "%x", lowHash); snprintf(buffer, 16, "%x", lowHash);
hashString.append(buffer); hashString.append(buffer);
skeletonData->_hash = hashString; skeletonData->_hash = hashString;
@ -120,7 +120,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
if (!skeletonData->_version.startsWith(SPINE_VERSION_STRING)) { if (!skeletonData->_version.startsWith(SPINE_VERSION_STRING)) {
char errorMsg[255]; char errorMsg[255];
sprintf(errorMsg, "Skeleton version %s does not match runtime version %s", skeletonData->_version.buffer(), SPINE_VERSION_STRING); snprintf(errorMsg, 255, "Skeleton version %s does not match runtime version %s", skeletonData->_version.buffer(), SPINE_VERSION_STRING);
setError(errorMsg, ""); setError(errorMsg, "");
return NULL; return NULL;
} }

View File

@ -152,7 +152,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
skeletonData->_version = Json::getString(skeleton, "spine", 0); skeletonData->_version = Json::getString(skeleton, "spine", 0);
if (!skeletonData->_version.startsWith(SPINE_VERSION_STRING)) { if (!skeletonData->_version.startsWith(SPINE_VERSION_STRING)) {
char errorMsg[255]; char errorMsg[255];
sprintf(errorMsg, "Skeleton version %s does not match runtime version %s", skeletonData->_version.buffer(), SPINE_VERSION_STRING); snprintf(errorMsg, 255, "Skeleton version %s does not match runtime version %s", skeletonData->_version.buffer(), SPINE_VERSION_STRING);
setError(NULL, errorMsg, ""); setError(NULL, errorMsg, "");
return NULL; return NULL;
} }