mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Merge branch 'master' into spine-ue4
This commit is contained in:
commit
983855a2a5
3
CHANGELOG
Normal file
3
CHANGELOG
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[3.6.x]
|
||||||
|
- [c] Modified kvec.h used by SkeletonBinary.c to use Spine's MALLOC/FREE macros. That way there's only one place
|
||||||
|
to inject custom allocators (extension.h) https://github.com/EsotericSoftware/spine-runtimes/commit/c2cfbc6cb8709daa082726222d558188d75a004f
|
||||||
@ -43,50 +43,63 @@ int main() {
|
|||||||
|
|
||||||
* The initial version.
|
* The initial version.
|
||||||
|
|
||||||
|
2017-19-18 (0.1.1):
|
||||||
|
|
||||||
|
Spine Special Edition
|
||||||
|
* Made helper macros for alloc, free and memcpy, which can be overridden.
|
||||||
|
* Made these helpers point to the Spine C Runtime alloc and free functions by default
|
||||||
|
* Reimplemented kv_resize to use alloc and free instead of realloc
|
||||||
|
* Changed kv_push to use kv_resize instead of realloc
|
||||||
|
* Removed kv_pushp and kv_a macros because the weren't used
|
||||||
|
* Removed stdlib include
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef AC_KVEC_H
|
#ifndef AC_KVEC_H
|
||||||
#define AC_KVEC_H
|
#define AC_KVEC_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
#ifndef _kv_free
|
||||||
|
#define _kv_free(type, p) (FREE(p))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _kv_alloc
|
||||||
|
#define _kv_alloc(type, s) ((type*)(MALLOC(type, (s))))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _kv_copy
|
||||||
|
#define _kv_copy(type, d, s, n) memcpy((d), (s), sizeof(type) * (n))
|
||||||
|
#endif
|
||||||
|
|
||||||
#define kv_roundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
|
#define kv_roundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
|
||||||
|
|
||||||
#define kvec_t(type) struct { size_t n, m; type *a; }
|
#define kvec_t(type) struct { size_t n, m; type *a; }
|
||||||
#define kv_init(v) ((v).n = (v).m = 0, (v).a = 0)
|
#define kv_init(v) ((v).n = (v).m = 0, (v).a = 0)
|
||||||
#define kv_destroy(v) free((v).a)
|
#define kv_destroy(v) _kv_free(type, (v).a)
|
||||||
#define kv_A(v, i) ((v).a[(i)])
|
#define kv_A(v, i) ((v).a[(i)])
|
||||||
#define kv_array(v) ((v).a)
|
#define kv_array(v) ((v).a)
|
||||||
#define kv_pop(v) ((v).a[--(v).n])
|
#define kv_pop(v) ((v).a[--(v).n])
|
||||||
#define kv_size(v) ((v).n)
|
#define kv_size(v) ((v).n)
|
||||||
#define kv_max(v) ((v).m)
|
#define kv_max(v) ((v).m)
|
||||||
|
|
||||||
#define kv_resize(type, v, s) ((v).m = (s), (v).a = (type*)realloc((v).a, sizeof(type) * (v).m))
|
#define kv_resize(type, v, s) do { \
|
||||||
#define kv_trim(type, v) (kv_resize(type, (v), kv_size(v)))
|
type* b = _kv_alloc(type, (s)); \
|
||||||
|
if (((s) > 0) && ((v).m > 0)) \
|
||||||
#define kv_copy(type, v1, v0) do { \
|
_kv_copy(type, b, (v).a, ((s) < (v).m)? (s) : (v).m); \
|
||||||
if ((v1).m < (v0).n) kv_resize(type, v1, (v0).n); \
|
_kv_free(type, (v).a); \
|
||||||
(v1).n = (v0).n; \
|
(v).a = b; (v).m = (s); \
|
||||||
memcpy((v1).a, (v0).a, sizeof(type) * (v0).n); \
|
|
||||||
} while (0) \
|
|
||||||
|
|
||||||
#define kv_push(type, v, x) do { \
|
|
||||||
if ((v).n == (v).m) { \
|
|
||||||
(v).m = (v).m? (v).m<<1 : 2; \
|
|
||||||
(v).a = (type*)realloc((v).a, sizeof(type) * (v).m); \
|
|
||||||
} \
|
|
||||||
(v).a[(v).n++] = (x); \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define kv_pushp(type, v) (((v).n == (v).m)? \
|
#define kv_trim(type, v) kv_resize(type, (v), kv_size(v))
|
||||||
((v).m = ((v).m? (v).m<<1 : 2), \
|
|
||||||
(v).a = (type*)realloc((v).a, sizeof(type) * (v).m), 0) \
|
|
||||||
: 0), ((v).a + ((v).n++))
|
|
||||||
|
|
||||||
#define kv_a(type, v, i) (((v).m <= (size_t)(i)? \
|
#define kv_copy(type, v1, v0) do { \
|
||||||
((v).m = (v).n = (i) + 1, kv_roundup32((v).m), \
|
if ((v1).m < (v0).n) kv_resize(type, v1, (v0).n); \
|
||||||
(v).a = (type*)realloc((v).a, sizeof(type) * (v).m), 0) \
|
(v1).n = (v0).n; \
|
||||||
: (v).n <= (size_t)(i)? (v).n = (i) + 1 \
|
_kv_copy(type, (v1).a, (v0).a, (v0).n); \
|
||||||
: 0), (v).a[(i)])
|
} while (0) \
|
||||||
|
|
||||||
|
#define kv_push(type, v, x) do { \
|
||||||
|
if ((v).n == (v).m) \
|
||||||
|
kv_resize(type, (v), ((v).m? (v).m<<1 : 2)); \
|
||||||
|
(v).a[(v).n++] = (x); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -42,7 +42,14 @@ namespace Spine.Unity.MeshGeneration {
|
|||||||
readonly ExposedList<SubmeshTriangleBuffer> submeshBuffers = new ExposedList<SubmeshTriangleBuffer>();
|
readonly ExposedList<SubmeshTriangleBuffer> submeshBuffers = new ExposedList<SubmeshTriangleBuffer>();
|
||||||
Material[] sharedMaterials = new Material[0];
|
Material[] sharedMaterials = new Material[0];
|
||||||
|
|
||||||
public MeshAndMaterials GenerateMesh (ExposedList<SubmeshInstruction> instructions, int startSubmesh, int endSubmesh) {
|
/// <summary>
|
||||||
|
/// Generates a mesh based on a subset of instructions.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A UnityEngine.Mesh.</returns>
|
||||||
|
/// <param name="instructions">A list of SubmeshInstructions.</param>
|
||||||
|
/// <param name="startSubmesh">The index of the starting submesh.</param>
|
||||||
|
/// <param name="endSubmesh">The exclusive upper bound of the last submesh to be included.</param>
|
||||||
|
public MeshAndMaterials GenerateMesh (ExposedList<SubmeshInstruction> instructions, int startSubmesh, int endSubmesh, float scale = 1f) {
|
||||||
// STEP 0: Prepare instructions.
|
// STEP 0: Prepare instructions.
|
||||||
var paramItems = instructions.Items;
|
var paramItems = instructions.Items;
|
||||||
currentInstructions.Clear(false);
|
currentInstructions.Clear(false);
|
||||||
@ -122,6 +129,15 @@ namespace Spine.Unity.MeshGeneration {
|
|||||||
this.sharedMaterials = currentInstructions.GetUpdatedMaterialArray(this.sharedMaterials);
|
this.sharedMaterials = currentInstructions.GetUpdatedMaterialArray(this.sharedMaterials);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scale != 1f) {
|
||||||
|
for (int i = 0; i < vertexCount; i++) {
|
||||||
|
meshVertices[i].x *= scale;
|
||||||
|
meshVertices[i].y *= scale;
|
||||||
|
//meshVertices[i].z *= scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// STEP 3: Assign the buffers into the Mesh.
|
// STEP 3: Assign the buffers into the Mesh.
|
||||||
smartMesh.Set(this.meshVertices, this.meshUVs, this.meshColors32, workingAttachments, currentInstructions);
|
smartMesh.Set(this.meshVertices, this.meshUVs, this.meshColors32, workingAttachments, currentInstructions);
|
||||||
mesh.bounds = ArraysMeshGenerator.ToBounds(meshBoundsMin, meshBoundsMax);
|
mesh.bounds = ArraysMeshGenerator.ToBounds(meshBoundsMin, meshBoundsMax);
|
||||||
|
|||||||
@ -41,6 +41,7 @@ namespace Spine.Unity.MeshGeneration {
|
|||||||
public List<Slot> Separators { get { return this.separators; } }
|
public List<Slot> Separators { get { return this.separators; } }
|
||||||
|
|
||||||
#region Settings
|
#region Settings
|
||||||
|
// ArraysMeshGenerator.PremultiplyAlpha
|
||||||
public float ZSpacing { get; set; }
|
public float ZSpacing { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -44,6 +44,7 @@ namespace Spine.Unity.MeshGeneration {
|
|||||||
List<Slot> Separators { get; }
|
List<Slot> Separators { get; }
|
||||||
|
|
||||||
float ZSpacing { get; set; }
|
float ZSpacing { get; set; }
|
||||||
|
bool PremultiplyVertexColors { get; set; }
|
||||||
bool AddNormals { get; set; }
|
bool AddNormals { get; set; }
|
||||||
bool AddTangents { get; set; }
|
bool AddTangents { get; set; }
|
||||||
}
|
}
|
||||||
@ -55,7 +56,7 @@ namespace Spine.Unity.MeshGeneration {
|
|||||||
// Step 3: Call GenerateMesh. You'll get a Mesh and Materials.
|
// Step 3: Call GenerateMesh. You'll get a Mesh and Materials.
|
||||||
// Step 4: Put the Mesh in MeshFilter. Put the Materials in MeshRenderer.sharedMaterials.
|
// Step 4: Put the Mesh in MeshFilter. Put the Materials in MeshRenderer.sharedMaterials.
|
||||||
public interface ISubmeshSetMeshGenerator {
|
public interface ISubmeshSetMeshGenerator {
|
||||||
MeshAndMaterials GenerateMesh (ExposedList<SubmeshInstruction> instructions, int startSubmesh, int endSubmesh);
|
MeshAndMaterials GenerateMesh (ExposedList<SubmeshInstruction> instructions, int startSubmesh, int endSubmesh, float scale = 1f);
|
||||||
|
|
||||||
float ZSpacing { get; set; }
|
float ZSpacing { get; set; }
|
||||||
bool PremultiplyVertexColors { get; set; }
|
bool PremultiplyVertexColors { get; set; }
|
||||||
|
|||||||
@ -163,11 +163,11 @@ namespace Spine.Unity {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Update () {
|
public void Update () {
|
||||||
Update(Time.deltaTime);
|
Update(Time.deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Update (float deltaTime) {
|
public void Update (float deltaTime) {
|
||||||
if (!valid)
|
if (!valid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@ -83,7 +83,7 @@ namespace Spine.Unity {
|
|||||||
animationTable.Add(a.Name.GetHashCode(), a);
|
animationTable.Add(a.Name.GetHashCode(), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update () {
|
public void Update () {
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
|
|
||||||
if (layerMixModes.Length < animator.layerCount)
|
if (layerMixModes.Length < animator.layerCount)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user