Browse Source

[c][cpp] CMake clean-up, update to C++11.

badlogic 4 years ago
parent
commit
e842e67d19

+ 2 - 0
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.

+ 2 - 2
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 "./")

+ 1 - 1
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()
 
 

+ 1 - 1
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) {

+ 0 - 9
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")

+ 0 - 1
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 "./")

+ 7 - 1
spine-cpp/spine-cpp-unit-tests/src/main.cpp

@@ -2,7 +2,9 @@
 #include <spine/spine.h>
 #include <stdio.h>
 
+#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);
 

+ 1 - 0
spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h

@@ -45,6 +45,7 @@ namespace spine {
 		Color &getColor();
 
 		virtual Attachment *copy();
+
 	private:
 		Color _color;
 	};

+ 2 - 2
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<float> &vertices);
 
-		Vector <Vector<float> > &getVertices();
+		Vector <Vector<float>> &getVertices();
 
 		VertexAttachment *getAttachment();
 
@@ -71,7 +71,7 @@ namespace spine {
 	protected:
 		int _slotIndex;
 
-		Vector <Vector<float> > _vertices;
+		Vector <Vector<float>> _vertices;
 
 		VertexAttachment *_attachment;
 	};

+ 2 - 2
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<int> &drawOrder);
 
-		Vector <Vector<int> > &getDrawOrders();
+		Vector <Vector<int>> &getDrawOrders();
 
 	private:
-		Vector <Vector<int> > _drawOrders;
+		Vector <Vector<int>> _drawOrders;
 	};
 }
 

+ 4 - 2
spine-cpp/spine-cpp/include/spine/HasRendererObject.h

@@ -30,13 +30,15 @@
 #ifndef Spine_HasRendererObject_h
 #define Spine_HasRendererObject_h
 
+#include <spine/dll.h>
+
 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);
 

+ 2 - 1
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);

+ 3 - 3
spine-cpp/spine-cpp/include/spine/Skin.h

@@ -88,11 +88,11 @@ namespace spine {
 				}
 
 			protected:
-				Entries(Vector <Vector<Entry> > &buckets) : _buckets(buckets), _slotIndex(0), _bucketIndex(0) {
+				Entries(Vector <Vector<Entry>> &buckets) : _buckets(buckets), _slotIndex(0), _bucketIndex(0) {
 				}
 
 			private:
-				Vector <Vector<Entry > > &_buckets;
+				Vector <Vector<Entry>> &_buckets;
 				size_t _slotIndex;
 				size_t _bucketIndex;
 			};
@@ -112,7 +112,7 @@ namespace spine {
 
 			int findInBucket(Vector <Entry> &, const String &attachmentName);
 
-			Vector <Vector<Entry> > _buckets;
+			Vector <Vector<Entry>> _buckets;
 		};
 
 		explicit Skin(const String &name);

+ 2 - 2
spine-cpp/spine-cpp/include/spine/Triangulator.h

@@ -56,8 +56,8 @@ namespace spine {
 		Vector<bool> _isConcaveArray;
 		Vector<int> _triangles;
 
-		Pool <Vector<float> > _polygonPool;
-		Pool <Vector<int> > _polygonIndicesPool;
+		Pool <Vector<float>> _polygonPool;
+		Pool <Vector<int>> _polygonIndicesPool;
 
 		static bool isConcave(int index, int vertexCount, Vector<float> &vertices, Vector<int> &indices);
 

+ 2 - 1
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;

+ 4 - 2
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;
 	}

+ 2 - 1
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<float> &PathAttachment::getLengths() {

+ 3 - 1
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<VertexAttachment *>(inValue)->getDeformAttachment() != (static_cast<VertexAttachment *>(_attachment)->getDeformAttachment()))) {
+			!(_attachment->getRTTI().instanceOf(VertexAttachment::rtti)) ||
+			(static_cast<VertexAttachment *>(inValue)->getDeformAttachment() !=
+			 (static_cast<VertexAttachment *>(_attachment)->getDeformAttachment()))) {
 			_deform.clear();
 		}
 	}

+ 0 - 2
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
 #

+ 0 - 1
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
 #