Merge branch 'master' into spine-ue4

This commit is contained in:
badlogic 2016-12-01 11:51:39 +01:00
commit 6d84a04de9
21 changed files with 1672 additions and 1457 deletions

View File

@ -126,7 +126,7 @@ public class Atlas {
region.splits = new Vector.<int>(parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3])); region.splits = new Vector.<int>(parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3]));
if (reader.readTuple(tuple) == 4) { // pad is optional, but only present with splits if (reader.readTuple(tuple) == 4) { // pad is optional, but only present with splits
region.pads = Vector.<int>(parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3])); region.pads = new Vector.<int>(parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3]));
reader.readTuple(tuple); reader.readTuple(tuple);
} }

View File

@ -179,4 +179,44 @@ void MemoryTestFixture::reproduceIssue_777()
DisposeAll(skeleton, state, stateData, skeletonData, atlas); DisposeAll(skeleton, state, stateData, skeletonData, atlas);
} }
spSkeleton* skeleton = nullptr;
static void spineAnimStateHandler(spAnimationState* state, int type, spTrackEntry* entry, spEvent* event)
{
if (type == SP_ANIMATION_COMPLETE)
{
spAnimationState_setAnimationByName(state, 0, "walk", false);
spAnimationState_update(state, 0);
spAnimationState_apply(state, skeleton);
}
}
void MemoryTestFixture::reproduceIssue_Loop()
{
spAtlas* atlas = nullptr;
spSkeletonData* skeletonData = nullptr;
spAnimationStateData* stateData = nullptr;
spAnimationState* state = nullptr;
//////////////////////////////////////////////////////////////////////////
// Initialize Animations
LoadSpineboyExample(atlas, skeletonData, stateData, skeleton, state);
///////////////////////////////////////////////////////////////////////////
if (state)
state->listener = (spAnimationStateListener)&spineAnimStateHandler;
spAnimationState_setAnimationByName(state, 0, "walk", false);
// run normal update
for (int i = 0; i < 50; ++i) {
const float timeSlice = 1.0f / 60.0f;
spSkeleton_update(skeleton, timeSlice);
spAnimationState_update(state, timeSlice);
spAnimationState_apply(state, skeleton);
}
DisposeAll(skeleton, state, stateData, skeletonData, atlas);
}

View File

@ -17,6 +17,7 @@ public:
// Comment out here to disable individual test cases // Comment out here to disable individual test cases
TEST_CASE(reproduceIssue_776); TEST_CASE(reproduceIssue_776);
TEST_CASE(reproduceIssue_777); TEST_CASE(reproduceIssue_777);
TEST_CASE(reproduceIssue_Loop);
initialize(); initialize();
} }
@ -29,6 +30,7 @@ public:
public: public:
void reproduceIssue_776(); void reproduceIssue_776();
void reproduceIssue_777(); void reproduceIssue_777();
void reproduceIssue_Loop(); // http://esotericsoftware.com/forum/spine-c-3-5-animation-jerking-7451
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// test fixture setup // test fixture setup

View File

@ -216,6 +216,9 @@ public class SkeletonViewer extends ApplicationAdapter {
if (ui.skinList.getSelected() != null) skeleton.setSkin(ui.skinList.getSelected()); if (ui.skinList.getSelected() != null) skeleton.setSkin(ui.skinList.getSelected());
setAnimation(); setAnimation();
// ui.animationList.clearListeners();
// state.setAnimation(0, "walk", true);
} }
void setAnimation () { void setAnimation () {

View File

@ -160,6 +160,7 @@ The configuration object has the following fields:
* `atlas`: required, path to the `.atlas` file, absolute or relative, e.g. "assets/animation.atlas" * `atlas`: required, path to the `.atlas` file, absolute or relative, e.g. "assets/animation.atlas"
* `animation`: required, the name of the animation to play back * `animation`: required, the name of the animation to play back
* `imagesPath`: optional, the location of images on the server to load atlas pages from. If omitted, atlas `.png` page files are loaded relative to the `.atlas` file. * `imagesPath`: optional, the location of images on the server to load atlas pages from. If omitted, atlas `.png` page files are loaded relative to the `.atlas` file.
* `atlasPages`: optional, the list of atlas page images, e.g. `atlasPages: ["assets/page1.png", "assets/page2.png"]` when using code, or `data-atlas-pages="assets/page1.png,assets/page2.png"` on case of HTML instantiation. Use this if you have a multi-page atlas. If ommited, only one atlas page image is loaded based on the atlas file name, replacing `.atlas` with `.png`.
* `skin`: optional, the name of the skin to use. Defaults to `default` if omitted. * `skin`: optional, the name of the skin to use. Defaults to `default` if omitted.
* `loop`: optional, whether to loop the animation or not. Defaults to `true` if omitted. * `loop`: optional, whether to loop the animation or not. Defaults to `true` if omitted.
* `scale`: optional, the scaling factor to apply when loading the `.json` file. Defaults to `1` if omitted. Irrelevant if `data-fit-to-canavs` is `true`. * `scale`: optional, the scaling factor to apply when loading the `.json` file. Defaults to `1` if omitted. Irrelevant if `data-fit-to-canavs` is `true`.

View File

@ -1543,6 +1543,7 @@ declare module spine {
atlas: string; atlas: string;
animation: string; animation: string;
imagesPath: string; imagesPath: string;
atlasPages: string[];
skin: string; skin: string;
loop: boolean; loop: boolean;
scale: number; scale: number;

View File

@ -7899,7 +7899,14 @@ var spine;
var assets = this.assetManager = new spine.webgl.AssetManager(gl); var assets = this.assetManager = new spine.webgl.AssetManager(gl);
assets.loadText(config.atlas); assets.loadText(config.atlas);
assets.loadText(config.json); assets.loadText(config.json);
assets.loadTexture(config.atlas.replace(".atlas", ".png")); if (config.atlasPages == null) {
assets.loadTexture(config.atlas.replace(".atlas", ".png"));
}
else {
for (var i = 0; i < config.atlasPages.length; i++) {
assets.loadTexture(config.atlasPages[i]);
}
}
requestAnimationFrame(function () { _this.load(); }); requestAnimationFrame(function () { _this.load(); });
} }
SpineWidget.prototype.validateConfig = function (config) { SpineWidget.prototype.validateConfig = function (config) {
@ -8082,6 +8089,8 @@ var spine;
config.animation = widget.getAttribute("data-animation"); config.animation = widget.getAttribute("data-animation");
if (widget.getAttribute("data-images-path")) if (widget.getAttribute("data-images-path"))
config.imagesPath = widget.getAttribute("data-images-path"); config.imagesPath = widget.getAttribute("data-images-path");
if (widget.getAttribute("data-atlas-pages"))
config.atlasPages = widget.getAttribute("data-atlas-pages").split(",");
if (widget.getAttribute("data-skin")) if (widget.getAttribute("data-skin"))
config.skin = widget.getAttribute("data-skin"); config.skin = widget.getAttribute("data-skin");
if (widget.getAttribute("data-loop")) if (widget.getAttribute("data-loop"))

File diff suppressed because one or more lines are too long

View File

@ -1473,6 +1473,7 @@ declare module spine {
atlas: string; atlas: string;
animation: string; animation: string;
imagesPath: string; imagesPath: string;
atlasPages: string[];
skin: string; skin: string;
loop: boolean; loop: boolean;
scale: number; scale: number;

View File

@ -7478,7 +7478,14 @@ var spine;
var assets = this.assetManager = new spine.webgl.AssetManager(gl); var assets = this.assetManager = new spine.webgl.AssetManager(gl);
assets.loadText(config.atlas); assets.loadText(config.atlas);
assets.loadText(config.json); assets.loadText(config.json);
assets.loadTexture(config.atlas.replace(".atlas", ".png")); if (config.atlasPages == null) {
assets.loadTexture(config.atlas.replace(".atlas", ".png"));
}
else {
for (var i = 0; i < config.atlasPages.length; i++) {
assets.loadTexture(config.atlasPages[i]);
}
}
requestAnimationFrame(function () { _this.load(); }); requestAnimationFrame(function () { _this.load(); });
} }
SpineWidget.prototype.validateConfig = function (config) { SpineWidget.prototype.validateConfig = function (config) {
@ -7661,6 +7668,8 @@ var spine;
config.animation = widget.getAttribute("data-animation"); config.animation = widget.getAttribute("data-animation");
if (widget.getAttribute("data-images-path")) if (widget.getAttribute("data-images-path"))
config.imagesPath = widget.getAttribute("data-images-path"); config.imagesPath = widget.getAttribute("data-images-path");
if (widget.getAttribute("data-atlas-pages"))
config.atlasPages = widget.getAttribute("data-atlas-pages").split(",");
if (widget.getAttribute("data-skin")) if (widget.getAttribute("data-skin"))
config.skin = widget.getAttribute("data-skin"); config.skin = widget.getAttribute("data-skin");
if (widget.getAttribute("data-loop")) if (widget.getAttribute("data-loop"))

File diff suppressed because one or more lines are too long

View File

@ -80,7 +80,13 @@ module spine {
let assets = this.assetManager = new spine.webgl.AssetManager(gl); let assets = this.assetManager = new spine.webgl.AssetManager(gl);
assets.loadText(config.atlas); assets.loadText(config.atlas);
assets.loadText(config.json); assets.loadText(config.json);
assets.loadTexture(config.atlas.replace(".atlas", ".png")); if (config.atlasPages == null) {
assets.loadTexture(config.atlas.replace(".atlas", ".png"));
} else {
for (let i = 0; i < config.atlasPages.length; i++) {
assets.loadTexture(config.atlasPages[i]);
}
}
requestAnimationFrame(() => { this.load(); }); requestAnimationFrame(() => { this.load(); });
} }
@ -264,6 +270,7 @@ module spine {
config.json = widget.getAttribute("data-json"); config.json = widget.getAttribute("data-json");
config.animation = widget.getAttribute("data-animation"); config.animation = widget.getAttribute("data-animation");
if (widget.getAttribute("data-images-path")) config.imagesPath = widget.getAttribute("data-images-path"); if (widget.getAttribute("data-images-path")) config.imagesPath = widget.getAttribute("data-images-path");
if (widget.getAttribute("data-atlas-pages")) config.atlasPages = widget.getAttribute("data-atlas-pages").split(",");
if (widget.getAttribute("data-skin")) config.skin = widget.getAttribute("data-skin"); if (widget.getAttribute("data-skin")) config.skin = widget.getAttribute("data-skin");
if (widget.getAttribute("data-loop")) config.loop = widget.getAttribute("data-loop") === "true"; if (widget.getAttribute("data-loop")) config.loop = widget.getAttribute("data-loop") === "true";
if (widget.getAttribute("data-scale")) config.scale = parseFloat(widget.getAttribute("data-scale")); if (widget.getAttribute("data-scale")) config.scale = parseFloat(widget.getAttribute("data-scale"));
@ -303,6 +310,7 @@ module spine {
atlas: string; atlas: string;
animation: string; animation: string;
imagesPath: string; imagesPath: string;
atlasPages: string[];
skin = "default"; skin = "default";
loop = true; loop = true;
scale = 1.0; scale = 1.0;

View File

@ -233,7 +233,7 @@ MonoBehaviour:
skeletonDataAsset: {fileID: 11400000, guid: 44691b56ed7d1f04da0cbc2a52a91b8d, type: 2} skeletonDataAsset: {fileID: 11400000, guid: 44691b56ed7d1f04da0cbc2a52a91b8d, type: 2}
initialSkinName: default initialSkinName: default
separatorSlotNames: separatorSlotNames:
- front_foot - --B
zSpacing: 0 zSpacing: 0
renderMeshes: 1 renderMeshes: 1
immutableTriangles: 0 immutableTriangles: 0
@ -402,7 +402,7 @@ Transform:
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 565117361} m_GameObject: {fileID: 565117361}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.3629907, y: 3.7230203, z: 0} m_LocalPosition: {x: -1.3626752, y: 3.7231483, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: [] m_Children: []
@ -2989,7 +2989,7 @@ MonoBehaviour:
skeletonDataAsset: {fileID: 11400000, guid: 44691b56ed7d1f04da0cbc2a52a91b8d, type: 2} skeletonDataAsset: {fileID: 11400000, guid: 44691b56ed7d1f04da0cbc2a52a91b8d, type: 2}
initialSkinName: default initialSkinName: default
separatorSlotNames: separatorSlotNames:
- front_upper_arm - --A
zSpacing: 0 zSpacing: 0
renderMeshes: 1 renderMeshes: 1
immutableTriangles: 0 immutableTriangles: 0

File diff suppressed because it is too large Load Diff

View File

@ -8,21 +8,123 @@ Material:
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_Name: spineboy_Material m_Name: spineboy_Material
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3} m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
m_ShaderKeywords: m_ShaderKeywords: _EMISSION
m_LightmapFlags: 5 m_LightmapFlags: 1
m_CustomRenderQueue: -1 m_CustomRenderQueue: -1
stringTagMap: {} stringTagMap: {}
m_SavedProperties: m_SavedProperties:
serializedVersion: 2 serializedVersion: 2
m_TexEnvs: m_TexEnvs:
- first:
name: _BumpMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailAlbedoMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailMask
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailNormalMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _EmissionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first: - first:
name: _MainTex name: _MainTex
second: second:
m_Texture: {fileID: 2800000, guid: 49bb65eefe08e424bbf7a38bc98ec638, type: 3} m_Texture: {fileID: 2800000, guid: 49bb65eefe08e424bbf7a38bc98ec638, type: 3}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- first:
name: _MetallicGlossMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _OcclusionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _ParallaxMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats: m_Floats:
- first:
name: _BumpScale
second: 1
- first: - first:
name: _Cutoff name: _Cutoff
second: 0.1 second: 0.1
m_Colors: [] - first:
name: _DetailNormalMapScale
second: 1
- first:
name: _DstBlend
second: 0
- first:
name: _GlossMapScale
second: 1
- first:
name: _Glossiness
second: 0.5
- first:
name: _GlossyReflections
second: 1
- first:
name: _Metallic
second: 0
- first:
name: _Mode
second: 0
- first:
name: _OcclusionStrength
second: 1
- first:
name: _Parallax
second: 0.02
- first:
name: _SmoothnessTextureChannel
second: 0
- first:
name: _SpecularHighlights
second: 1
- first:
name: _SrcBlend
second: 1
- first:
name: _UVSec
second: 0
- first:
name: _ZWrite
second: 1
m_Colors:
- first:
name: _Black
second: {r: 0, g: 0, b: 0, a: 0}
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}

View File

@ -12,7 +12,7 @@ Material:
m_LightmapFlags: 5 m_LightmapFlags: 5
m_CustomRenderQueue: 3000 m_CustomRenderQueue: 3000
stringTagMap: stringTagMap:
RenderType: Transparent RenderType: Sprite
m_SavedProperties: m_SavedProperties:
serializedVersion: 2 serializedVersion: 2
m_TexEnvs: m_TexEnvs:

View File

@ -55,7 +55,7 @@ namespace Spine.Unity.Modules {
MeshRenderer mainMeshRenderer; MeshRenderer mainMeshRenderer;
public bool copyPropertyBlock = false; public bool copyPropertyBlock = false;
[Tooltip("Copies MeshRenderer flags into ")] [Tooltip("Copies MeshRenderer flags into each parts renderer")]
public bool copyMeshRendererFlags = false; public bool copyMeshRendererFlags = false;
public List<Spine.Unity.Modules.SkeletonPartsRenderer> partsRenderers = new List<SkeletonPartsRenderer>(); public List<Spine.Unity.Modules.SkeletonPartsRenderer> partsRenderers = new List<SkeletonPartsRenderer>();
@ -125,7 +125,7 @@ namespace Spine.Unity.Modules {
int rendererCount = partsRenderers.Count; int rendererCount = partsRenderers.Count;
if (rendererCount <= 0) return; if (rendererCount <= 0) return;
int rendererIndex = 0;
if (copyPropertyBlock) if (copyPropertyBlock)
mainMeshRenderer.GetPropertyBlock(copiedBlock); mainMeshRenderer.GetPropertyBlock(copiedBlock);
@ -134,11 +134,13 @@ namespace Spine.Unity.Modules {
var submeshInstructionsItems = submeshInstructions.Items; var submeshInstructionsItems = submeshInstructions.Items;
int lastSubmeshInstruction = submeshInstructions.Count - 1; int lastSubmeshInstruction = submeshInstructions.Count - 1;
var currentRenderer = partsRenderers[rendererIndex];
bool addNormals = skeletonRenderer.calculateNormals; bool addNormals = skeletonRenderer.calculateNormals;
bool addTangents = skeletonRenderer.calculateTangents; bool addTangents = skeletonRenderer.calculateTangents;
bool pmaVertexColors = skeletonRenderer.pmaVertexColors; bool pmaVertexColors = skeletonRenderer.pmaVertexColors;
int rendererIndex = 0;
var currentRenderer = partsRenderers[rendererIndex];
for (int si = 0, start = 0; si <= lastSubmeshInstruction; si++) { for (int si = 0, start = 0; si <= lastSubmeshInstruction; si++) {
if (submeshInstructionsItems[si].forceSeparate || si == lastSubmeshInstruction) { if (submeshInstructionsItems[si].forceSeparate || si == lastSubmeshInstruction) {
// Apply properties // Apply properties

View File

@ -267,6 +267,7 @@ namespace Spine.Unity {
bool isCustomSlotMaterialsPopulated = customSlotMaterials.Count > 0; bool isCustomSlotMaterialsPopulated = customSlotMaterials.Count > 0;
#endif #endif
bool hasSeparators = separatorSlots.Count > 0;
int vertexCount = 0; int vertexCount = 0;
int submeshVertexCount = 0; int submeshVertexCount = 0;
int submeshTriangleCount = 0, submeshFirstVertex = 0, submeshStartSlotIndex = 0; int submeshTriangleCount = 0, submeshFirstVertex = 0, submeshStartSlotIndex = 0;
@ -281,8 +282,9 @@ namespace Spine.Unity {
workingFlipsItems[i] = flip; workingFlipsItems[i] = flip;
#endif #endif
object rendererObject; // An AtlasRegion in plain Spine-Unity. Spine-TK2D hooks into TK2D's system. eventual source of Material object. object rendererObject = null; // An AtlasRegion in plain Spine-Unity. Spine-TK2D hooks into TK2D's system. eventual source of Material object.
int attachmentVertexCount, attachmentTriangleCount; int attachmentVertexCount, attachmentTriangleCount;
bool noRender = false;
var regionAttachment = attachment as RegionAttachment; var regionAttachment = attachment as RegionAttachment;
if (regionAttachment != null) { if (regionAttachment != null) {
@ -290,56 +292,85 @@ namespace Spine.Unity {
attachmentVertexCount = 4; attachmentVertexCount = 4;
attachmentTriangleCount = 6; attachmentTriangleCount = 6;
} else { } else {
if (!renderMeshes) if (!renderMeshes) {
continue; noRender = true;
var meshAttachment = attachment as MeshAttachment; attachmentVertexCount = 0;
if (meshAttachment != null) { attachmentTriangleCount = 0;
rendererObject = meshAttachment.RendererObject; //continue;
attachmentVertexCount = meshAttachment.worldVerticesLength >> 1;
attachmentTriangleCount = meshAttachment.triangles.Length;
} else { } else {
continue; var meshAttachment = attachment as MeshAttachment;
if (meshAttachment != null) {
rendererObject = meshAttachment.RendererObject;
attachmentVertexCount = meshAttachment.worldVerticesLength >> 1;
attachmentTriangleCount = meshAttachment.triangles.Length;
} else {
noRender = true;
attachmentVertexCount = 0;
attachmentTriangleCount = 0;
//continue;
}
} }
} }
#if !SPINE_TK2D
Material material; //= (Material)((AtlasRegion)rendererObject).page.rendererObject; // For no customSlotMaterials
if (isCustomSlotMaterialsPopulated) {
if (!customSlotMaterials.TryGetValue(slot, out material)) {
material = (Material)((AtlasRegion)rendererObject).page.rendererObject;
}
} else {
material = (Material)((AtlasRegion)rendererObject).page.rendererObject;
}
#else
Material material = (rendererObject.GetType() == typeof(Material)) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject;
#endif
// Create a new SubmeshInstruction when material changes. (or when forced to separate by a submeshSeparator) // Create a new SubmeshInstruction when material changes. (or when forced to separate by a submeshSeparator)
bool forceSeparate = (separatorSlots.Count > 0 && separatorSlots.Contains(slot)); // Slot with a separator/new material will become the starting slot of the next new instruction.
if (vertexCount > 0 && (lastMaterial.GetInstanceID() != material.GetInstanceID() || forceSeparate)) { bool forceSeparate = (hasSeparators && separatorSlots.Contains(slot));
workingSubmeshInstructions.Add( if (noRender) {
new Spine.Unity.MeshGeneration.SubmeshInstruction { if (forceSeparate && vertexCount > 0 && this.generateMeshOverride != null) {
skeleton = this.skeleton, workingSubmeshInstructions.Add(
material = lastMaterial, new Spine.Unity.MeshGeneration.SubmeshInstruction {
startSlot = submeshStartSlotIndex, skeleton = this.skeleton,
endSlot = i, material = lastMaterial,
triangleCount = submeshTriangleCount, startSlot = submeshStartSlotIndex,
firstVertexIndex = submeshFirstVertex, endSlot = i,
vertexCount = submeshVertexCount, triangleCount = submeshTriangleCount,
forceSeparate = forceSeparate firstVertexIndex = submeshFirstVertex,
} vertexCount = submeshVertexCount,
); forceSeparate = forceSeparate
submeshTriangleCount = 0; }
submeshVertexCount = 0; );
submeshFirstVertex = vertexCount; submeshTriangleCount = 0;
submeshStartSlotIndex = i; submeshVertexCount = 0;
submeshFirstVertex = vertexCount;
submeshStartSlotIndex = i;
}
} else {
#if !SPINE_TK2D
Material material;
if (isCustomSlotMaterialsPopulated) {
if (!customSlotMaterials.TryGetValue(slot, out material))
material = (Material)((AtlasRegion)rendererObject).page.rendererObject;
} else {
material = (Material)((AtlasRegion)rendererObject).page.rendererObject;
}
#else
Material material = (rendererObject.GetType() == typeof(Material)) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject;
#endif
if (vertexCount > 0 && (forceSeparate || lastMaterial.GetInstanceID() != material.GetInstanceID())) {
workingSubmeshInstructions.Add(
new Spine.Unity.MeshGeneration.SubmeshInstruction {
skeleton = this.skeleton,
material = lastMaterial,
startSlot = submeshStartSlotIndex,
endSlot = i,
triangleCount = submeshTriangleCount,
firstVertexIndex = submeshFirstVertex,
vertexCount = submeshVertexCount,
forceSeparate = forceSeparate
}
);
submeshTriangleCount = 0;
submeshVertexCount = 0;
submeshFirstVertex = vertexCount;
submeshStartSlotIndex = i;
}
// Update state for the next iteration.
lastMaterial = material;
submeshTriangleCount += attachmentTriangleCount;
vertexCount += attachmentVertexCount;
submeshVertexCount += attachmentVertexCount;
} }
// Update state for the next iteration.
lastMaterial = material;
submeshTriangleCount += attachmentTriangleCount;
vertexCount += attachmentVertexCount;
submeshVertexCount += attachmentVertexCount;
} }
if (submeshVertexCount != 0) { if (submeshVertexCount != 0) {