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

This commit is contained in:
badlogic 2021-07-01 11:04:12 +02:00
parent a1959ee1a0
commit e842e67d19
20 changed files with 40 additions and 35 deletions

View File

@ -15,6 +15,7 @@
### Starling ### 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.** **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. * 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 ## C
* **Breaking change:** Removed `SPINE_SHORT_NAMES` define and C++ constructors. * **Breaking change:** Removed `SPINE_SHORT_NAMES` define and C++ constructors.
@ -43,6 +44,7 @@
* Added proportional spacing mode support for path constraints. * Added proportional spacing mode support for path constraints.
* Added support for uniform scaling for two bone IK. * Added support for uniform scaling for two bone IK.
* Fixed applying a constraint reverting changes from other constraints. * Fixed applying a constraint reverting changes from other constraints.
* spine-cpp now requires C++11.
### Cocos2d-x ### Cocos2d-x
* Added `IKExample` scene to illustrate how to drive a bone and IK chain through mouse movement. * Added `IKExample` scene to illustrate how to drive a bone and IK chain through mouse movement.

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.9) cmake_minimum_required(VERSION 3.19)
project(spine) project(spine)
if(MSVC) if(MSVC)
@ -7,7 +7,7 @@ if(MSVC)
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
else() 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_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() endif()
set(CMAKE_INSTALL_PREFIX "./") set(CMAKE_INSTALL_PREFIX "./")

View File

@ -4,7 +4,7 @@ project(spine_unit_test)
set(CMAKE_INSTALL_PREFIX "./") set(CMAKE_INSTALL_PREFIX "./")
set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_VERBOSE_MAKEFILE ON)
if(MSVC) 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() endif()

View File

@ -130,7 +130,7 @@ void spPathConstraint_update(spPathConstraint *self) {
break; break;
case SP_SPACING_MODE_PROPORTIONAL: case SP_SPACING_MODE_PROPORTIONAL:
sum = 0; sum = 0;
for (i = 0; i < boneCount;) { for (i = 0, n = spacesCount - 1; i < n;) {
spBone *bone = bones[i]; spBone *bone = bones[i];
setupLength = bone->data->length; setupLength = bone->data->length;
if (setupLength < EPSILON) { if (setupLength < EPSILON) {

View File

@ -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) include_directories(include)
file(GLOB INCLUDES "spine-cpp/include/**/*.h") file(GLOB INCLUDES "spine-cpp/include/**/*.h")
file(GLOB SOURCES "spine-cpp/src/**/*.cpp") file(GLOB SOURCES "spine-cpp/src/**/*.cpp")

View File

@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 2.8.9)
project(spine_cpp_unit_test) project(spine_cpp_unit_test)
set(CMAKE_INSTALL_PREFIX "./") set(CMAKE_INSTALL_PREFIX "./")

View File

@ -2,7 +2,9 @@
#include <spine/spine.h> #include <spine/spine.h>
#include <stdio.h> #include <stdio.h>
#ifdef MSVC
#pragma warning(disable : 4710) #pragma warning(disable : 4710)
#endif
using namespace spine; using namespace spine;
@ -56,7 +58,9 @@ void dispose(Atlas *atlas, SkeletonData *skeletonData, AnimationStateData *state
struct TestData { struct TestData {
TestData(const String &jsonSkeleton, const String &binarySkeleton, const String &atlas) : _jsonSkeleton( TestData(const String &jsonSkeleton, const String &binarySkeleton, const String &atlas) : _jsonSkeleton(
jsonSkeleton), jsonSkeleton),
_binarySkeleton(binarySkeleton), _atlas(atlas) {} _binarySkeleton(
binarySkeleton),
_atlas(atlas) {}
String _jsonSkeleton; String _jsonSkeleton;
String _binarySkeleton; String _binarySkeleton;
@ -101,6 +105,8 @@ namespace spine {
}// namespace spine }// namespace spine
int main(int argc, char **argv) { int main(int argc, char **argv) {
SP_UNUSED(argc);
SP_UNUSED(argv);
DebugExtension debug(SpineExtension::getInstance()); DebugExtension debug(SpineExtension::getInstance());
SpineExtension::setInstance(&debug); SpineExtension::setInstance(&debug);

View File

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

View File

@ -52,7 +52,7 @@ namespace spine {
/// Sets the time and value of the specified keyframe. /// Sets the time and value of the specified keyframe.
void setFrame(int frameIndex, float time, Vector<float> &vertices); void setFrame(int frameIndex, float time, Vector<float> &vertices);
Vector <Vector<float> > &getVertices(); Vector <Vector<float>> &getVertices();
VertexAttachment *getAttachment(); VertexAttachment *getAttachment();
@ -71,7 +71,7 @@ namespace spine {
protected: protected:
int _slotIndex; int _slotIndex;
Vector <Vector<float> > _vertices; Vector <Vector<float>> _vertices;
VertexAttachment *_attachment; VertexAttachment *_attachment;
}; };

View File

@ -51,10 +51,10 @@ namespace spine {
/// @param drawOrder May be NULL to use bind pose draw order /// @param drawOrder May be NULL to use bind pose draw order
void setFrame(size_t frame, float time, Vector<int> &drawOrder); void setFrame(size_t frame, float time, Vector<int> &drawOrder);
Vector <Vector<int> > &getDrawOrders(); Vector <Vector<int>> &getDrawOrders();
private: private:
Vector <Vector<int> > _drawOrders; Vector <Vector<int>> _drawOrders;
}; };
} }

View File

@ -30,13 +30,15 @@
#ifndef Spine_HasRendererObject_h #ifndef Spine_HasRendererObject_h
#define Spine_HasRendererObject_h #define Spine_HasRendererObject_h
#include <spine/dll.h>
namespace spine { namespace spine {
typedef void (*DisposeRendererObject)(void *rendererObject); typedef void (*DisposeRendererObject)(void *rendererObject);
class SP_API HasRendererObject { class SP_API HasRendererObject {
public: public:
explicit HasRendererObject() : _rendererObject(NULL), _dispose(NULL) {}; explicit HasRendererObject() : _rendererObject(0), _dispose(0) {};
virtual ~HasRendererObject() { virtual ~HasRendererObject() {
if (_dispose && _rendererObject) if (_dispose && _rendererObject)
@ -45,7 +47,7 @@ namespace spine {
void *getRendererObject() { return _rendererObject; } void *getRendererObject() { return _rendererObject; }
void setRendererObject(void *rendererObject, DisposeRendererObject dispose = NULL) { void setRendererObject(void *rendererObject, DisposeRendererObject dispose = 0) {
if (_dispose && _rendererObject && _rendererObject != rendererObject) if (_dispose && _rendererObject && _rendererObject != rendererObject)
_dispose(_rendererObject); _dispose(_rendererObject);

View File

@ -58,7 +58,8 @@ namespace spine {
/// possible. The target is specified in the world coordinate system. /// possible. The target is specified in the world coordinate system.
/// @param child A direct descendant of the parent bone. /// @param child A direct descendant of the parent bone.
static void 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); float alpha);
IkConstraint(IkConstraintData &data, Skeleton &skeleton); IkConstraint(IkConstraintData &data, Skeleton &skeleton);

View File

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

View File

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

View File

@ -182,7 +182,8 @@ void Bone::updateWorldTransform(float x, float y, float rotation, float scaleX,
za *= s; za *= s;
zc *= s; zc *= s;
s = MathUtil::sqrt(za * za + zc * zc); 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; s = -s;
r = MathUtil::Pi / 2 + MathUtil::atan2(zc, za); r = MathUtil::Pi / 2 + MathUtil::atan2(zc, za);
zb = MathUtil::cos(r) * s; zb = MathUtil::cos(r) * s;

View File

@ -94,7 +94,8 @@ void IkConstraint::apply(Bone &bone, float targetX, float targetY, bool compress
bone._ashearY); 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 alpha) {
float a, b, c, d; float a, b, c, d;
float px, py, psx, psy, sx, sy; float px, py, psx, psy, sx, sy;
@ -283,7 +284,8 @@ void IkConstraint::update() {
case 2: { case 2: {
Bone *bone0 = _bones[0]; Bone *bone0 = _bones[0];
Bone *bone1 = _bones[1]; 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); _mix);
} break; } break;
} }

View File

@ -37,7 +37,8 @@ using namespace spine;
RTTI_IMPL(PathAttachment, VertexAttachment) 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() { Vector<float> &PathAttachment::getLengths() {

View File

@ -101,7 +101,9 @@ void Slot::setAttachment(Attachment *inValue) {
if (inValue && _attachment) { if (inValue && _attachment) {
if (!(inValue->getRTTI().instanceOf(VertexAttachment::rtti)) || 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(); _deform.clear();
} }
} }

View File

@ -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 # First download and extract SFML 2.3.2 for the respective OS we are on
# #

View File

@ -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 # First download and extract SFML 2.4.1 for the respective OS we are on
# #