Merge branch '3.6' into 3.7-beta

This commit is contained in:
badlogic 2017-07-19 10:45:51 +02:00
commit 8827cbdf03
6 changed files with 35 additions and 33 deletions

View File

@ -50,6 +50,7 @@
* `AnimationState#apply` returns boolean indicating if any timeline was applied or not.
* `Animation#apply` and `Timeline#apply`` now take enums `MixPose` and `MixDirection` instead of booleans
* Added `spVertexEffect` and corresponding implementations `spJitterVertexEffect` and `spSwirlVertexEffect`. Create/dispose through the corresponding `spXXXVertexEffect_create()/dispose()` functions. Set on framework/engine specific renderer. See changes for spine-c based frameworks/engines below.
* Functions in `extension.h` are not prefixed with `_sp` instead of just `_` to avoid interference with other libraries.
### Cocos2d-X
* Fixed renderer to work with 3.6 changes

View File

@ -62,9 +62,9 @@
#define SPINE_EXTENSION_H_
/* All allocation uses these. */
#define MALLOC(TYPE,COUNT) ((TYPE*)_malloc(sizeof(TYPE) * (COUNT), __FILE__, __LINE__))
#define CALLOC(TYPE,COUNT) ((TYPE*)_calloc(COUNT, sizeof(TYPE), __FILE__, __LINE__))
#define REALLOC(PTR,TYPE,COUNT) ((TYPE*)_realloc(PTR, sizeof(TYPE) * (COUNT)))
#define MALLOC(TYPE,COUNT) ((TYPE*)_spMalloc(sizeof(TYPE) * (COUNT), __FILE__, __LINE__))
#define CALLOC(TYPE,COUNT) ((TYPE*)_spCalloc(COUNT, sizeof(TYPE), __FILE__, __LINE__))
#define REALLOC(PTR,TYPE,COUNT) ((TYPE*)_spRealloc(PTR, sizeof(TYPE) * (COUNT)))
#define NEW(TYPE) CALLOC(TYPE,1)
/* Gets the direct super class. Type safe. */
@ -83,7 +83,7 @@
#define VTABLE(TYPE,VALUE) ((_##TYPE##Vtable*)((TYPE*)VALUE)->vtable)
/* Frees memory. Can be used on const types. */
#define FREE(VALUE) _free((void*)VALUE)
#define FREE(VALUE) _spFree((void*)VALUE)
/* Allocates a new char[], assigns it to TO, and copies FROM to it. Can be used on const types. */
#define MALLOC_STR(TO,FROM) strcpy(CONST_CAST(char*, TO) = (char*)MALLOC(char, strlen(FROM) + 1), FROM)
@ -164,19 +164,19 @@ char* _spUtil_readFile (const char* path, int* length);
* Internal API available for extension:
*/
void* _malloc (size_t size, const char* file, int line);
void* _calloc (size_t num, size_t size, const char* file, int line);
void* _realloc(void* ptr, size_t size);
void _free (void* ptr);
float _random ();
void* _spMalloc (size_t size, const char* file, int line);
void* _spCalloc (size_t num, size_t size, const char* file, int line);
void* _spRealloc(void* ptr, size_t size);
void _spFree (void* ptr);
float _spRandom ();
void _setMalloc (void* (*_malloc) (size_t size));
void _setDebugMalloc (void* (*_malloc) (size_t size, const char* file, int line));
void _setRealloc(void* (*_realloc) (void* ptr, size_t size));
void _setFree (void (*_free) (void* ptr));
void _setRandom(float (*_random) ());
void _spSetMalloc (void* (*_malloc) (size_t size));
void _spSetDebugMalloc (void* (*_malloc) (size_t size, const char* file, int line));
void _spSetRealloc(void* (*_realloc) (void* ptr, size_t size));
void _spSetFree (void (*_free) (void* ptr));
void _spSetRandom(float (*_random) ());
char* _readFile (const char* path, int* length);
char* _spReadFile (const char* path, int* length);
/*

View File

@ -31,7 +31,7 @@
#include <spine/extension.h>
#include <stdio.h>
float _spRandom () {
float _spInternalRandom () {
return rand() / (float)RAND_MAX;
}
@ -39,51 +39,51 @@ static void* (*mallocFunc) (size_t size) = malloc;
static void* (*reallocFunc) (void* ptr, size_t size) = realloc;
static void* (*debugMallocFunc) (size_t size, const char* file, int line) = NULL;
static void (*freeFunc) (void* ptr) = free;
static float (*randomFunc) () = _spRandom;
static float (*randomFunc) () = _spInternalRandom;
void* _malloc (size_t size, const char* file, int line) {
void* _spMalloc (size_t size, const char* file, int line) {
if(debugMallocFunc)
return debugMallocFunc(size, file, line);
return mallocFunc(size);
}
void* _calloc (size_t num, size_t size, const char* file, int line) {
void* ptr = _malloc(num * size, file, line);
void* _spCalloc (size_t num, size_t size, const char* file, int line) {
void* ptr = _spMalloc(num * size, file, line);
if (ptr) memset(ptr, 0, num * size);
return ptr;
}
void* _realloc(void* ptr, size_t size) {
void* _spRealloc(void* ptr, size_t size) {
return reallocFunc(ptr, size);
}
void _free (void* ptr) {
void _spFree (void* ptr) {
freeFunc(ptr);
}
float _random () {
float _spRandom () {
return randomFunc();
}
void _setDebugMalloc(void* (*malloc) (size_t size, const char* file, int line)) {
void _spSetDebugMalloc(void* (*malloc) (size_t size, const char* file, int line)) {
debugMallocFunc = malloc;
}
void _setMalloc (void* (*malloc) (size_t size)) {
void _spSetMalloc (void* (*malloc) (size_t size)) {
mallocFunc = malloc;
}
void _setRealloc (void* (*realloc) (void* ptr, size_t size)) {
void _spSetRealloc (void* (*realloc) (void* ptr, size_t size)) {
reallocFunc = realloc;
}
void _setFree (void (*free) (void* ptr)) {
void _spSetFree (void (*free) (void* ptr)) {
freeFunc = free;
}
void _setRandom (float (*random) ()) {
void _spSetRandom (float (*random) ()) {
randomFunc = random;
}
char* _readFile (const char* path, int* length) {
char* _spReadFile (const char* path, int* length) {
char *data;
FILE *file = fopen(path, "rb");
if (!file) return 0;
@ -100,7 +100,7 @@ char* _readFile (const char* path, int* length) {
}
float _spMath_random(float min, float max) {
return min + (max - min) * _random();
return min + (max - min) * _spRandom();
}
float _spMath_randomTriangular(float min, float max) {
@ -108,7 +108,7 @@ float _spMath_randomTriangular(float min, float max) {
}
float _spMath_randomTriangularWith(float min, float max, float mode) {
float u = _random();
float u = _spRandom();
float d = max - min;
if (u <= (mode - min) / d) return min + SQRT(u * d * (mode - min));
return max - SQRT((1 - u) * d * (max - mode));

View File

@ -22,6 +22,7 @@ spine-cocos2d-objc does not yet support loading the binary format.
2. Download the Spine Runtimes source using git (`git clone https://github.com/esotericsoftware/spine-runtimes`) or download it [as a zip](https://github.com/EsotericSoftware/spine-runtimes/archive/3.6.zip)
3. Add the sources from `spine-c/spine-c/src/spine` and `spine-cocos2d-objc/src/spine` to your project
4. Add the folders `spine-c/spine-c/include` and `spine-cocos2d-objc/src` to your header search path. Note that includes are specified as `#inclue <spine/file.h>`, so the `spine` directory cannot be omitted when copying the source files.
5. If your project uses ARC, you have to exclude the `.m` files in `spine-cocos2d-objc/src` from ARC. See https://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project for more information.
See the [Spine Runtimes documentation](http://esotericsoftware.com/spine-documentation#runtimesTitle) on how to use the APIs or check out the Spine cocos2d-objc example.

View File

@ -44,5 +44,5 @@ void _spAtlasPage_disposeTexture (spAtlasPage* self) {
}
char* _spUtil_readFile (const char* path, int* length) {
return _readFile([[[CCFileUtils sharedFileUtils] fullPathForFilename:@(path)] UTF8String], length);
return _spReadFile([[[CCFileUtils sharedFileUtils] fullPathForFilename:@(path)] UTF8String], length);
}

View File

@ -56,7 +56,7 @@ void _AtlasPage_disposeTexture (AtlasPage* self){
}
char* _Util_readFile (const char* path, int* length){
return _readFile(path, length);
return _spReadFile(path, length);
}
/**/