From e842e67d1959efe098731b70c915a403fb751e19 Mon Sep 17 00:00:00 2001 From: badlogic Date: Thu, 1 Jul 2021 11:04:12 +0200 Subject: [PATCH] [c][cpp] CMake clean-up, update to C++11. --- CHANGELOG.md | 2 ++ CMakeLists.txt | 4 ++-- spine-c/spine-c-unit-tests/CMakeLists.txt | 2 +- spine-c/spine-c/src/spine/PathConstraint.c | 2 +- spine-cpp/CMakeLists.txt | 9 --------- spine-cpp/spine-cpp-unit-tests/CMakeLists.txt | 1 - spine-cpp/spine-cpp-unit-tests/src/main.cpp | 8 +++++++- .../spine-cpp/include/spine/BoundingBoxAttachment.h | 1 + spine-cpp/spine-cpp/include/spine/DeformTimeline.h | 4 ++-- spine-cpp/spine-cpp/include/spine/DrawOrderTimeline.h | 4 ++-- spine-cpp/spine-cpp/include/spine/HasRendererObject.h | 6 ++++-- spine-cpp/spine-cpp/include/spine/IkConstraint.h | 3 ++- spine-cpp/spine-cpp/include/spine/Skin.h | 6 +++--- spine-cpp/spine-cpp/include/spine/Triangulator.h | 4 ++-- spine-cpp/spine-cpp/src/spine/Bone.cpp | 3 ++- spine-cpp/spine-cpp/src/spine/IkConstraint.cpp | 6 ++++-- spine-cpp/spine-cpp/src/spine/PathAttachment.cpp | 3 ++- spine-cpp/spine-cpp/src/spine/Slot.cpp | 4 +++- spine-sfml/c/CMakeLists.txt | 2 -- spine-sfml/cpp/CMakeLists.txt | 1 - 20 files changed, 40 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eb99dc31..06d16c206 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ ### Starling **NOTE: Spine 4.0 will be the last release supporting spine-starling. Starting from Spine 4.1, spine-starling will no longer be supported or maintained.** * Switched projects from FDT to Visual Studio Code. See updated `README.md` files for instructions. +* Updated to Starling 2.6 and Air SDK 33. ## C * **Breaking change:** Removed `SPINE_SHORT_NAMES` define and C++ constructors. @@ -43,6 +44,7 @@ * Added proportional spacing mode support for path constraints. * Added support for uniform scaling for two bone IK. * Fixed applying a constraint reverting changes from other constraints. +* spine-cpp now requires C++11. ### Cocos2d-x * Added `IKExample` scene to illustrate how to drive a bone and IK chain through mouse movement. diff --git a/CMakeLists.txt b/CMakeLists.txt index 165eb29fe..fc42f3700 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.9) +cmake_minimum_required(VERSION 3.19) project(spine) if(MSVC) @@ -7,7 +7,7 @@ if(MSVC) set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}") else() set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wunused-value -Wno-c++11-long-long -Wno-variadic-macros -Werror -Wextra -pedantic -Wnonportable-include-path -Wshadow -std=c89") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wunused-value -Wno-c++11-long-long -Wno-variadic-macros -Werror -Wextra -Wnon-virtual-dtor -pedantic -Wnonportable-include-path -Wshadow -std=c++03 -fno-exceptions -fno-rtti") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wunused-value -Wno-c++11-long-long -Wno-variadic-macros -Werror -Wextra -Wnon-virtual-dtor -pedantic -Wnonportable-include-path -Wshadow -std=c++11 -fno-exceptions -fno-rtti") endif() set(CMAKE_INSTALL_PREFIX "./") diff --git a/spine-c/spine-c-unit-tests/CMakeLists.txt b/spine-c/spine-c-unit-tests/CMakeLists.txt index 1b3349e99..8e01b39f1 100755 --- a/spine-c/spine-c-unit-tests/CMakeLists.txt +++ b/spine-c/spine-c-unit-tests/CMakeLists.txt @@ -4,7 +4,7 @@ project(spine_unit_test) set(CMAKE_INSTALL_PREFIX "./") set(CMAKE_VERBOSE_MAKEFILE ON) if(MSVC) -set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wnon-virtual-dtor -pedantic -std=c++03 -fno-rtti -DKANJI_MEMTRACE -DUSE_CPP11_MUTEX") +set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wnon-virtual-dtor -pedantic -std=c++11 -fno-rtti -DKANJI_MEMTRACE -DUSE_CPP11_MUTEX") endif() diff --git a/spine-c/spine-c/src/spine/PathConstraint.c b/spine-c/spine-c/src/spine/PathConstraint.c index 388b59a78..833d35993 100644 --- a/spine-c/spine-c/src/spine/PathConstraint.c +++ b/spine-c/spine-c/src/spine/PathConstraint.c @@ -130,7 +130,7 @@ void spPathConstraint_update(spPathConstraint *self) { break; case SP_SPACING_MODE_PROPORTIONAL: sum = 0; - for (i = 0; i < boneCount;) { + for (i = 0, n = spacesCount - 1; i < n;) { spBone *bone = bones[i]; setupLength = bone->data->length; if (setupLength < EPSILON) { diff --git a/spine-cpp/CMakeLists.txt b/spine-cpp/CMakeLists.txt index 706040cab..92f355180 100644 --- a/spine-cpp/CMakeLists.txt +++ b/spine-cpp/CMakeLists.txt @@ -1,12 +1,3 @@ -if(MSVC) - message("MSCV detected") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}") -else() - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c89") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -pedantic -std=c++03 -fno-exceptions -fno-rtti") -endif() - include_directories(include) file(GLOB INCLUDES "spine-cpp/include/**/*.h") file(GLOB SOURCES "spine-cpp/src/**/*.cpp") diff --git a/spine-cpp/spine-cpp-unit-tests/CMakeLists.txt b/spine-cpp/spine-cpp-unit-tests/CMakeLists.txt index f45d857bf..e853f5692 100755 --- a/spine-cpp/spine-cpp-unit-tests/CMakeLists.txt +++ b/spine-cpp/spine-cpp-unit-tests/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.8.9) project(spine_cpp_unit_test) set(CMAKE_INSTALL_PREFIX "./") diff --git a/spine-cpp/spine-cpp-unit-tests/src/main.cpp b/spine-cpp/spine-cpp-unit-tests/src/main.cpp index 6594f5edd..6cb8e0535 100644 --- a/spine-cpp/spine-cpp-unit-tests/src/main.cpp +++ b/spine-cpp/spine-cpp-unit-tests/src/main.cpp @@ -2,7 +2,9 @@ #include #include +#ifdef MSVC #pragma warning(disable : 4710) +#endif using namespace spine; @@ -56,7 +58,9 @@ void dispose(Atlas *atlas, SkeletonData *skeletonData, AnimationStateData *state struct TestData { TestData(const String &jsonSkeleton, const String &binarySkeleton, const String &atlas) : _jsonSkeleton( jsonSkeleton), - _binarySkeleton(binarySkeleton), _atlas(atlas) {} + _binarySkeleton( + binarySkeleton), + _atlas(atlas) {} String _jsonSkeleton; String _binarySkeleton; @@ -101,6 +105,8 @@ namespace spine { }// namespace spine int main(int argc, char **argv) { + SP_UNUSED(argc); + SP_UNUSED(argv); DebugExtension debug(SpineExtension::getInstance()); SpineExtension::setInstance(&debug); diff --git a/spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h b/spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h index 367fe4bbf..fa2913f3e 100644 --- a/spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h @@ -45,6 +45,7 @@ namespace spine { Color &getColor(); virtual Attachment *copy(); + private: Color _color; }; diff --git a/spine-cpp/spine-cpp/include/spine/DeformTimeline.h b/spine-cpp/spine-cpp/include/spine/DeformTimeline.h index 62acb110c..e43be9178 100644 --- a/spine-cpp/spine-cpp/include/spine/DeformTimeline.h +++ b/spine-cpp/spine-cpp/include/spine/DeformTimeline.h @@ -52,7 +52,7 @@ namespace spine { /// Sets the time and value of the specified keyframe. void setFrame(int frameIndex, float time, Vector &vertices); - Vector > &getVertices(); + Vector > &getVertices(); VertexAttachment *getAttachment(); @@ -71,7 +71,7 @@ namespace spine { protected: int _slotIndex; - Vector > _vertices; + Vector > _vertices; VertexAttachment *_attachment; }; diff --git a/spine-cpp/spine-cpp/include/spine/DrawOrderTimeline.h b/spine-cpp/spine-cpp/include/spine/DrawOrderTimeline.h index 89f4bbaff..b78b90cfa 100644 --- a/spine-cpp/spine-cpp/include/spine/DrawOrderTimeline.h +++ b/spine-cpp/spine-cpp/include/spine/DrawOrderTimeline.h @@ -51,10 +51,10 @@ namespace spine { /// @param drawOrder May be NULL to use bind pose draw order void setFrame(size_t frame, float time, Vector &drawOrder); - Vector > &getDrawOrders(); + Vector > &getDrawOrders(); private: - Vector > _drawOrders; + Vector > _drawOrders; }; } diff --git a/spine-cpp/spine-cpp/include/spine/HasRendererObject.h b/spine-cpp/spine-cpp/include/spine/HasRendererObject.h index d7b1233f7..d07648ec5 100644 --- a/spine-cpp/spine-cpp/include/spine/HasRendererObject.h +++ b/spine-cpp/spine-cpp/include/spine/HasRendererObject.h @@ -30,13 +30,15 @@ #ifndef Spine_HasRendererObject_h #define Spine_HasRendererObject_h +#include + namespace spine { typedef void (*DisposeRendererObject)(void *rendererObject); class SP_API HasRendererObject { public: - explicit HasRendererObject() : _rendererObject(NULL), _dispose(NULL) {}; + explicit HasRendererObject() : _rendererObject(0), _dispose(0) {}; virtual ~HasRendererObject() { if (_dispose && _rendererObject) @@ -45,7 +47,7 @@ namespace spine { void *getRendererObject() { return _rendererObject; } - void setRendererObject(void *rendererObject, DisposeRendererObject dispose = NULL) { + void setRendererObject(void *rendererObject, DisposeRendererObject dispose = 0) { if (_dispose && _rendererObject && _rendererObject != rendererObject) _dispose(_rendererObject); diff --git a/spine-cpp/spine-cpp/include/spine/IkConstraint.h b/spine-cpp/spine-cpp/include/spine/IkConstraint.h index 3e44b6377..93edacb56 100644 --- a/spine-cpp/spine-cpp/include/spine/IkConstraint.h +++ b/spine-cpp/spine-cpp/include/spine/IkConstraint.h @@ -58,7 +58,8 @@ namespace spine { /// possible. The target is specified in the world coordinate system. /// @param child A direct descendant of the parent bone. static void - apply(Bone &parent, Bone &child, float targetX, float targetY, int bendDir, bool stretch, bool uniform, float softness, + apply(Bone &parent, Bone &child, float targetX, float targetY, int bendDir, bool stretch, bool uniform, + float softness, float alpha); IkConstraint(IkConstraintData &data, Skeleton &skeleton); diff --git a/spine-cpp/spine-cpp/include/spine/Skin.h b/spine-cpp/spine-cpp/include/spine/Skin.h index ef8452a41..09e3b7b26 100644 --- a/spine-cpp/spine-cpp/include/spine/Skin.h +++ b/spine-cpp/spine-cpp/include/spine/Skin.h @@ -88,11 +88,11 @@ namespace spine { } protected: - Entries(Vector > &buckets) : _buckets(buckets), _slotIndex(0), _bucketIndex(0) { + Entries(Vector > &buckets) : _buckets(buckets), _slotIndex(0), _bucketIndex(0) { } private: - Vector > &_buckets; + Vector > &_buckets; size_t _slotIndex; size_t _bucketIndex; }; @@ -112,7 +112,7 @@ namespace spine { int findInBucket(Vector &, const String &attachmentName); - Vector > _buckets; + Vector > _buckets; }; explicit Skin(const String &name); diff --git a/spine-cpp/spine-cpp/include/spine/Triangulator.h b/spine-cpp/spine-cpp/include/spine/Triangulator.h index 2715f7bcf..af77fa56f 100644 --- a/spine-cpp/spine-cpp/include/spine/Triangulator.h +++ b/spine-cpp/spine-cpp/include/spine/Triangulator.h @@ -56,8 +56,8 @@ namespace spine { Vector _isConcaveArray; Vector _triangles; - Pool > _polygonPool; - Pool > _polygonIndicesPool; + Pool > _polygonPool; + Pool > _polygonIndicesPool; static bool isConcave(int index, int vertexCount, Vector &vertices, Vector &indices); diff --git a/spine-cpp/spine-cpp/src/spine/Bone.cpp b/spine-cpp/spine-cpp/src/spine/Bone.cpp index cfaf6847a..26c1240bc 100644 --- a/spine-cpp/spine-cpp/src/spine/Bone.cpp +++ b/spine-cpp/spine-cpp/src/spine/Bone.cpp @@ -182,7 +182,8 @@ void Bone::updateWorldTransform(float x, float y, float rotation, float scaleX, za *= s; zc *= s; s = MathUtil::sqrt(za * za + zc * zc); - if (_data.getTransformMode() == TransformMode_NoScale && (pa * pd - pb * pc < 0) != (_skeleton.getScaleX() < 0 != _skeleton.getScaleY() < 0)) + if (_data.getTransformMode() == TransformMode_NoScale && + (pa * pd - pb * pc < 0) != (_skeleton.getScaleX() < 0 != _skeleton.getScaleY() < 0)) s = -s; r = MathUtil::Pi / 2 + MathUtil::atan2(zc, za); zb = MathUtil::cos(r) * s; diff --git a/spine-cpp/spine-cpp/src/spine/IkConstraint.cpp b/spine-cpp/spine-cpp/src/spine/IkConstraint.cpp index 624fe1c9f..cee23c565 100644 --- a/spine-cpp/spine-cpp/src/spine/IkConstraint.cpp +++ b/spine-cpp/spine-cpp/src/spine/IkConstraint.cpp @@ -94,7 +94,8 @@ void IkConstraint::apply(Bone &bone, float targetX, float targetY, bool compress bone._ashearY); } -void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY, int bendDir, bool stretch, bool uniform, float softness, +void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY, int bendDir, bool stretch, bool uniform, + float softness, float alpha) { float a, b, c, d; float px, py, psx, psy, sx, sy; @@ -283,7 +284,8 @@ void IkConstraint::update() { case 2: { Bone *bone0 = _bones[0]; Bone *bone1 = _bones[1]; - apply(*bone0, *bone1, _target->getWorldX(), _target->getWorldY(), _bendDirection, _stretch, _data._uniform, _softness, + apply(*bone0, *bone1, _target->getWorldX(), _target->getWorldY(), _bendDirection, _stretch, _data._uniform, + _softness, _mix); } break; } diff --git a/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp b/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp index 50dd46969..016932f21 100644 --- a/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp @@ -37,7 +37,8 @@ using namespace spine; RTTI_IMPL(PathAttachment, VertexAttachment) -PathAttachment::PathAttachment(const String &name) : VertexAttachment(name), _closed(false), _constantSpeed(false), _color() { +PathAttachment::PathAttachment(const String &name) : VertexAttachment(name), _closed(false), _constantSpeed(false), + _color() { } Vector &PathAttachment::getLengths() { diff --git a/spine-cpp/spine-cpp/src/spine/Slot.cpp b/spine-cpp/spine-cpp/src/spine/Slot.cpp index 4d791b8f1..f8f26ce8a 100644 --- a/spine-cpp/spine-cpp/src/spine/Slot.cpp +++ b/spine-cpp/spine-cpp/src/spine/Slot.cpp @@ -101,7 +101,9 @@ void Slot::setAttachment(Attachment *inValue) { if (inValue && _attachment) { if (!(inValue->getRTTI().instanceOf(VertexAttachment::rtti)) || - !(_attachment->getRTTI().instanceOf(VertexAttachment::rtti)) || (static_cast(inValue)->getDeformAttachment() != (static_cast(_attachment)->getDeformAttachment()))) { + !(_attachment->getRTTI().instanceOf(VertexAttachment::rtti)) || + (static_cast(inValue)->getDeformAttachment() != + (static_cast(_attachment)->getDeformAttachment()))) { _deform.clear(); } } diff --git a/spine-sfml/c/CMakeLists.txt b/spine-sfml/c/CMakeLists.txt index ba0397f6a..3bf749a09 100644 --- a/spine-sfml/c/CMakeLists.txt +++ b/spine-sfml/c/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 2.8.9) - # # First download and extract SFML 2.3.2 for the respective OS we are on # diff --git a/spine-sfml/cpp/CMakeLists.txt b/spine-sfml/cpp/CMakeLists.txt index 864bcc7f5..1cca39771 100644 --- a/spine-sfml/cpp/CMakeLists.txt +++ b/spine-sfml/cpp/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.8.9) # # First download and extract SFML 2.4.1 for the respective OS we are on #