Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into 4.0
  • Loading branch information
badlogic committed Apr 21, 2022
2 parents 0db28c0 + 14af269 commit 01524d4
Show file tree
Hide file tree
Showing 76 changed files with 2,586 additions and 513 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -163,6 +163,9 @@
* Improved `Advanced - Fix Prefab Override MeshFilter` property for `SkeletonRenderer` (and subclasses`SkeletonAnimation` and `SkeletonMecanim`), now providing an additional option to use a global value which can be set in `Edit - Preferences - Spine`.
* Timeline naming improvements: `Spine AnimationState Clip` Inspector parameter `Custom Duration` changed and inverted to `Default Mix Duration` for more clarity. Shortened all Timeline add track menu entries from: `Spine.Unity.Playables - <track type>` to `Spine - <track type>`, `Spine Animation State Track` to `SkeletonAnimation Track`, `Spine AnimationState Graphic Track` to `SkeletonGraphic Track`, and `Spine Skeleton Flip Track` to `Skeleton Flip Track`.
* Timeline track appearance and Inspector: Tracks now show icons and track colors to make them easier to distinguish. When a Track is selected, the Inspector now shows an editable track name which was previously only editable at the Timeline asset.
* Added example component `SkeletonRenderTexture` to render a `SkeletonRenderer` to a `RenderTexture`, mainly for proper transparency. Added an example scene named `RenderTexture FadeOut Transparency` that demonstrates usage for a fadeout transparency effect.
* Added another fadeout example component named `SkeletonRenderTextureFadeout` which takes over transparency fadeout when enabled. You can use this component as-is, attach it in disabled state and enable it to start a fadeout effect.
* Timeline clips now offer an additional `Alpha` parameter for setting a custom constant mix alpha value other than 1.0, just as `TrackEntry.Alpha`. Defaults to 1.0.

* **Changes of default values**

Expand Down Expand Up @@ -237,6 +240,7 @@
* `SkeletonMesh` now takes an optional `SkeletonMeshMaterialParametersCustomizer` function that allows you to modify the `ShaderMaterialParameters` before the material is finalized. Use it to modify things like THREEJS' `Material.depthTest` etc. See #1590.
* **Breaking change:** the global object `spine.canvas` no longer exists. All classes and functions are now exposed on the global `spine` object directly. Simply replace any reference to `spine.threejs.` in your source code with `spine.`.
* **Breaking change:** the default fragment shader of `SkeletonMeshMaterial` now explicitely discards fragments with alpha < 0.5. See https://github.com/EsotericSoftware/spine-runtimes/issues/1985
* **Breaking change:** reversal of the previous breaking change: the default fragment shader of `SkeletonMeshMaterial` does no longer discard fragments with alpha < 0.5. Pass a `SkeletonMeshMaterialParametersCustomizer` to the `SkeletonMesh` constructor, and modify `parameters.alphaTest` to be > 0.

### Player
* Added `SpinePlayerConfig.rawDataURIs`. Allows to embed data URIs for skeletons, atlases and atlas page images directly in the HTML/JS without needing to load it from a separate file. See the example for a demonstration.
Expand Down Expand Up @@ -631,6 +635,8 @@
* Added `MeshAttachment#newLinkedMesh()`, creates a linked mesh linkted to either the original mesh, or the parent of the original mesh.
* Added IK softness.
* Added `AssetManager.setRawDataURI(path, data)`. Allows to embed data URIs for skeletons, atlases and atlas page images directly in the HTML/JS without needing to load it from a separate file.
* Added `AssetManager.loadAll()` to allow Promise/async/await based waiting for completion of asset load. See the `spine-canvas` examples.
* Added `Skeleton.getBoundRect()` helper method to calculate the bouding rectangle of the current pose, returning the result as `{ x, y, width, height }`. Note that this method will create temporary objects which can add to garbage collection pressure.

### WebGL backend
* `Input` can now take a partially defined implementation of `InputListener`.
Expand Down
20 changes: 13 additions & 7 deletions CMakeLists.txt
@@ -1,20 +1,26 @@
cmake_minimum_required(VERSION 3.17)
project(spine)

set(CMAKE_INSTALL_PREFIX "./")
set(CMAKE_VERBOSE_MAKEFILE ON)
set(SPINE_SFML FALSE CACHE BOOL FALSE)
set(SPINE_COCOS2D_OBJC FALSE CACHE BOOL FALSE)
set(SPINE_COCOS2D_X FALSE CACHE BOOL FALSE)
set(SPINE_SANITIZE FALSE CACHE BOOL FALSE)

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 -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++11 -fno-exceptions -fno-rtti")
endif()

set(CMAKE_INSTALL_PREFIX "./")
set(CMAKE_VERBOSE_MAKEFILE ON)
set(SPINE_SFML FALSE CACHE BOOL FALSE)
set(SPINE_COCOS2D_OBJC FALSE CACHE BOOL FALSE)
set(SPINE_COCOS2D_X FALSE CACHE BOOL FALSE)
if (${SPINE_SANITIZE})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined")
endif()
endif()

if((${SPINE_SFML}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-sfml"))
add_subdirectory(spine-c)
Expand All @@ -34,4 +40,4 @@ if((${SPINE_COCOS2D_X}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-cocos2dx"
endif()

# add_subdirectory(spine-c/spine-c-unit-tests)
add_subdirectory(spine-cpp/spine-cpp-unit-tests)
add_subdirectory(spine-cpp/spine-cpp-unit-tests)
2 changes: 1 addition & 1 deletion spine-c/spine-c/src/spine/SkeletonBinary.c
Expand Up @@ -1189,7 +1189,7 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const
highHash = readInt(input);
sprintf(buffer, "%x%x", highHash, lowHash);
buffer[31] = 0;
skeletonData->hash = strdup(buffer);
MALLOC_STR(skeletonData->hash, buffer);

skeletonData->version = readString(input);
if (!strlen(skeletonData->version)) {
Expand Down
16 changes: 10 additions & 6 deletions spine-c/spine-c/src/spine/SkeletonJson.c
Expand Up @@ -34,10 +34,6 @@
#include <spine/extension.h>
#include <stdio.h>

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#define strdup _strdup
#endif

typedef struct {
const char *parent;
const char *skin;
Expand Down Expand Up @@ -938,9 +934,17 @@ spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char
skeletonData->height = Json_getFloat(skeleton, "height", 0);
skeletonData->fps = Json_getFloat(skeleton, "fps", 30);
skeletonData->imagesPath = Json_getString(skeleton, "images", 0);
if (skeletonData->imagesPath) skeletonData->imagesPath = strdup(skeletonData->imagesPath);
if (skeletonData->imagesPath) {
char *tmp = NULL;
MALLOC_STR(tmp, skeletonData->imagesPath);
skeletonData->imagesPath = tmp;
}
skeletonData->audioPath = Json_getString(skeleton, "audio", 0);
if (skeletonData->audioPath) skeletonData->audioPath = strdup(skeletonData->audioPath);
if (skeletonData->audioPath) {
char *tmp = NULL;
MALLOC_STR(tmp, skeletonData->audioPath);
skeletonData->audioPath = tmp;
}
}

/* Bones. */
Expand Down
10 changes: 5 additions & 5 deletions spine-cpp/spine-cpp/include/spine/Extension.h
Expand Up @@ -104,15 +104,15 @@ namespace spine {
virtual ~DefaultSpineExtension();

protected:
virtual void *_alloc(size_t size, const char *file, int line);
virtual void *_alloc(size_t size, const char *file, int line) override;

virtual void *_calloc(size_t size, const char *file, int line);
virtual void *_calloc(size_t size, const char *file, int line) override;

virtual void *_realloc(void *ptr, size_t size, const char *file, int line);
virtual void *_realloc(void *ptr, size_t size, const char *file, int line) override;

virtual void _free(void *mem, const char *file, int line);
virtual void _free(void *mem, const char *file, int line) override;

virtual char *_readFile(const String &path, int *length);
virtual char *_readFile(const String &path, int *length) override;
};

// This function is to be implemented by engine specific runtimes to provide
Expand Down
6 changes: 2 additions & 4 deletions spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp
Expand Up @@ -73,10 +73,6 @@
#include <spine/TranslateTimeline.h>
#include <spine/Vertices.h>

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#define strdup _strdup
#endif

using namespace spine;

static float toColor(const char *value, size_t index) {
Expand Down Expand Up @@ -418,6 +414,8 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
data->_spacingMode = SpacingMode_Fixed;
else if (strcmp(item, "percent") == 0)
data->_spacingMode = SpacingMode_Percent;
else
data->_spacingMode = SpacingMode_Proportional;

item = Json::getString(constraintMap, "rotateMode", "tangent");
if (strcmp(item, "tangent") == 0) data->_rotateMode = RotateMode_Tangent;
Expand Down
6 changes: 3 additions & 3 deletions spine-csharp/src/SkeletonBinary.cs
Expand Up @@ -1200,7 +1200,7 @@ internal class SkeletonInput {
input.Position = initialPosition;
return GetVersionStringOld3X();
} catch (Exception e) {
throw new ArgumentException("Stream does not contain a valid binary Skeleton Data.\n" + e, "input");
throw new ArgumentException("Stream does not contain valid binary Skeleton Data.\n" + e, "input");
}
}

Expand All @@ -1212,13 +1212,13 @@ internal class SkeletonInput {

// Version.
byteCount = ReadInt(true);
if (byteCount > 1) {
if (byteCount > 1 && byteCount <= 13) {
byteCount--;
var buffer = new byte[byteCount];
ReadFully(buffer, 0, byteCount);
return System.Text.Encoding.UTF8.GetString(buffer, 0, byteCount);
}
return null;
throw new ArgumentException("Stream does not contain valid binary Skeleton Data.");
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions spine-csharp/src/package.json
Expand Up @@ -11,9 +11,6 @@
},
"dependencies": {
},
"files": [
"src"
],
"repository": {
"type": "git",
"url": "git@github.com:EsotericSoftware/spine-runtimes.git"
Expand Down
16 changes: 15 additions & 1 deletion spine-ts/.vscode/launch.json
Expand Up @@ -17,6 +17,20 @@
"name": "drag-and-drop",
"url": "http://localhost:8080/spine-webgl/example/drag-and-drop.html",
"webRoot": "${workspaceFolder}"
},
{
"type": "pwa-chrome",
"request": "launch",
"name": "barebones-dragon",
"url": "http://localhost:8080/spine-webgl/example/barebones-dragon.html",
"webRoot": "${workspaceFolder}"
},
{
"type": "pwa-chrome",
"request": "launch",
"name": "threejs-example",
"url": "http://localhost:8080/spine-threejs/example/index.html",
"webRoot": "${workspaceFolder}"
}
]
}
}
6 changes: 3 additions & 3 deletions spine-ts/README.md
Expand Up @@ -56,8 +56,8 @@ You can include a module in your project via a `<script>` tag from the [unpkg](h
<script src="https://unpkg.com/@esotericsoftware/spine-player@4.0.*/dist/iife/spine-player.js">
<link rel="stylesheet" href="https://unpkg.com/@esotericsoftware/spine-player@4.0.*/dist/spine-player.css">
// spine-ts WebGL
<script src="https://unpkg.com/@esotericsoftware/spine-threejs@4.0.*/dist/iife/spine-webgl.js">
// spine-ts ThreeJS
<script src="https://unpkg.com/@esotericsoftware/spine-threejs@4.0.*/dist/iife/spine-threejs.js">
```

We also provide `js.map` source maps. They will be automatically fetched from unpkg when debugging code of a spine-module in Chrome, Firefox, or Safari, mapping the JavaScript code back to its original TypeScript sources.
Expand Down Expand Up @@ -113,4 +113,4 @@ The final command `npm run dev` will start a local web server at http://127.0.0.

You can then open Visual Studio Code to inspect, edit, and debug the source code. We also supply launch configurations to start examples and demos in debug mode, so you can debug them right inside Visual Studio code.

To build the artifacts as they are published to NPM, run `npm run build`.
To build the artifacts as they are published to NPM, run `npm run build`.
1 change: 1 addition & 0 deletions spine-ts/index.html
Expand Up @@ -14,6 +14,7 @@ <h1>spine-ts Examples</h1>
<li>Canvas</li>
<ul>
<li><a href="/spine-canvas/example">Example</a></li>
<li><a href="/spine-canvas/example/mouse-click.html">Mouse click</a></li>
</ul>
<li>Player</li>
<ul>
Expand Down

0 comments on commit 01524d4

Please sign in to comment.