From 147952966a9dbec96575417fcfd97b57e4a3e482 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 13 Jul 2017 12:56:59 +0800 Subject: [PATCH 1/4] Support skeletons batching for spine --- extensions/spine/SGSkeleton.js | 29 ++++--- extensions/spine/SGSkeletonWebGLRenderCmd.js | 86 ++++++++++++-------- 2 files changed, 69 insertions(+), 46 deletions(-) diff --git a/extensions/spine/SGSkeleton.js b/extensions/spine/SGSkeleton.js index 56670b5cba..a16420e482 100644 --- a/extensions/spine/SGSkeleton.js +++ b/extensions/spine/SGSkeleton.js @@ -36,7 +36,6 @@ sp._SGSkeleton = _ccsg.Node.extend({ _premultipliedAlpha: false, _ownsSkeletonData: null, _atlas: null, - _blendFunc: null, ctor: function(skeletonDataFile, atlasFile, scale) { _ccsg.Node.prototype.ctor.call(this); @@ -57,7 +56,6 @@ sp._SGSkeleton = _ccsg.Node.extend({ init: function () { _ccsg.Node.prototype.init.call(this); this._premultipliedAlpha = (cc._renderType === cc.game.RENDER_TYPE_WEBGL && cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA); - this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; this.scheduleUpdate(); }, @@ -289,27 +287,27 @@ sp._SGSkeleton = _ccsg.Node.extend({ }, /** - * Returns the blendFunc of sp._SGSkeleton. + * Returns the blendFunc of sp._SGSkeleton, actually it's the first slot's blend function. * @returns {BlendFunc} */ getBlendFunc: function () { - return this._blendFunc; + var slot = this._skeleton.drawOrder[0]; + if (slot) { + var blend = this._renderCmd._getBlendFunc(slot.data.blendMode, this._premultipliedAlpha); + return blend; + } + else { + return {}; + } }, /** - * Sets the blendFunc of sp._SGSkeleton. + * Sets the blendFunc of sp._SGSkeleton, it won't have any effect for skeleton, skeleton is using slot's data to determine the blend function. * @param {BlendFunc|Number} src * @param {Number} [dst] */ setBlendFunc: function (src, dst) { - var locBlendFunc = this._blendFunc; - if (dst === undefined) { - locBlendFunc.src = src.src; - locBlendFunc.dst = src.dst; - } else { - locBlendFunc.src = src; - locBlendFunc.dst = dst; - } + return; }, /** @@ -327,3 +325,8 @@ sp._SGSkeleton = _ccsg.Node.extend({ Object.defineProperty(sp._SGSkeleton.prototype, 'opacityModifyRGB', { get: sp._SGSkeleton.prototype.isOpacityModifyRGB }); + +// For renderer webgl to identify skeleton's default blend function +Object.defineProperty(sp._SGSkeleton.prototype, '_blendFunc', { + get: sp._SGSkeleton.prototype.getBlendFunc +}); \ No newline at end of file diff --git a/extensions/spine/SGSkeletonWebGLRenderCmd.js b/extensions/spine/SGSkeletonWebGLRenderCmd.js index e63a5680b6..30e113a6a0 100644 --- a/extensions/spine/SGSkeletonWebGLRenderCmd.js +++ b/extensions/spine/SGSkeletonWebGLRenderCmd.js @@ -30,19 +30,15 @@ sp._SGSkeleton.WebGLRenderCmd = function (renderableObject) { this._needDraw = true; this._matrix = new cc.math.Matrix4(); this._matrix.identity(); + this._currBlendFunc = {}; this.vertexType = cc.renderer.VertexType.CUSTOM; - this.setShaderProgram(cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR)); + this.setShaderProgram(cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLOR)); }; var proto = sp._SGSkeleton.WebGLRenderCmd.prototype = Object.create(_ccsg.Node.WebGLRenderCmd.prototype); proto.constructor = sp._SGSkeleton.WebGLRenderCmd; proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){ - - // rendering the cached data first - cc.renderer._batchRendering(); - vertexDataOffset = 0; - var node = this._node; var color = this._displayedColor, locSkeleton = node._skeleton; @@ -52,17 +48,6 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){ var dataInited = false; var cachedVertices = 0; - var wt = this._worldTransform, mat = this._matrix.mat; - mat[0] = wt.a; - mat[4] = wt.c; - mat[12] = wt.tx; - mat[1] = wt.b; - mat[5] = wt.d; - mat[13] = wt.ty; - - this._shaderProgram.use(); - this._shaderProgram._setUniformForMVPMatrixWithMat4(this._matrix); - locSkeleton.r = color.r / 255; locSkeleton.g = color.g / 255; locSkeleton.b = color.b / 255; @@ -105,18 +90,16 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){ if (!dataInited) { textureAtlas = regionTextureAtlas; blendMode = slot.data.blendMode; - cc.renderer._updateBatchedInfo(textureAtlas.texture.getRealTexture(), this._getBlendFunc(blendMode, premultiAlpha), this.getShaderProgram()); dataInited = true; } // if data changed or the vertices will be overflow - if ((cachedVertices + vertCount) * 6 > f32buffer.length || + if (vertexDataOffset + vertCount * 6 > f32buffer.length || textureAtlas.texture.getRealTexture() !== regionTextureAtlas.texture.getRealTexture() || blendMode !== slot.data.blendMode) { // render the cached data cc.renderer._batchRendering(); vertexDataOffset = 0; - cachedVertices = 0; // update the batched info textureAtlas = regionTextureAtlas; @@ -148,16 +131,21 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){ } // update the index data - cachedVertices += vertCount; vertexDataOffset += vertCount * 6; } - // render the left vertices - if (cachedVertices > 0) { - cc.renderer._batchRendering(); - } - if (node._debugBones || node._debugSlots) { + // flush previous vertices + cc.renderer._batchRendering(); + + var wt = this._worldTransform, mat = this._matrix.mat; + mat[0] = wt.a; + mat[4] = wt.c; + mat[12] = wt.tx; + mat[1] = wt.b; + mat[5] = wt.d; + mat[13] = wt.ty; + cc.math.glMatrixMode(cc.math.KM_GL_MODELVIEW); //cc.math.glPushMatrixWitMat4(this._matrix); cc.current_stack.stack.push(cc.current_stack.top); @@ -209,7 +197,7 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){ }; proto._getBlendFunc = function (blendMode, premultiAlpha) { - var ret = {}; + var ret = this._currBlendFunc; switch (blendMode) { case spine.BlendMode.Normal: ret.src = premultiAlpha ? cc.macro.ONE : cc.macro.SRC_ALPHA; @@ -254,19 +242,28 @@ proto._uploadRegionAttachmentData = function(attachment, slot, premultipliedAlph nodeB = nodeColor.b, nodeA = this._displayedOpacity; var vertices = attachment.updateWorldVertices(slot, premultipliedAlpha); + var wt = this._worldTransform, + wa = wt.a, wb = wt.b, wc = wt.c, wd = wt.d, + wx = wt.tx, wy = wt.ty, + z = this._node.vertexZ; + var offset = vertexDataOffset; // generate 6 vertices data (two triangles) from the quad vertices // using two angles : (0, 1, 2) & (0, 2, 3) for (var i = 0; i < 6; i++) { var srcIdx = i < 4 ? i % 3 : i - 2; + var vx = vertices[srcIdx * 8], + vy = vertices[srcIdx * 8 + 1]; + var x = vx * wa + vy * wb + wx, + y = vx * wc + vy * wd + wy; var r = vertices[srcIdx * 8 + 2] * nodeR, g = vertices[srcIdx * 8 + 3] * nodeG, b = vertices[srcIdx * 8 + 4] * nodeB, a = vertices[srcIdx * 8 + 5] * nodeA; var color = ((a<<24) | (b<<16) | (g<<8) | r); - f32buffer[offset] = vertices[srcIdx * 8]; - f32buffer[offset + 1] = vertices[srcIdx * 8 + 1]; - f32buffer[offset + 2] = this._node.vertexZ; + f32buffer[offset] = x; + f32buffer[offset + 1] = y; + f32buffer[offset + 2] = z; ui32buffer[offset + 3] = color; f32buffer[offset + 4] = vertices[srcIdx * 8 + 6]; f32buffer[offset + 5] = vertices[srcIdx * 8 + 7]; @@ -286,6 +283,10 @@ proto._uploadRegionAttachmentData = function(attachment, slot, premultipliedAlph }; proto._uploadMeshAttachmentData = function(attachment, slot, premultipliedAlpha, f32buffer, ui32buffer, vertexDataOffset) { + var wt = this._worldTransform, + wa = wt.a, wb = wt.b, wc = wt.c, wd = wt.d, + wx = wt.tx, wy = wt.ty, + z = this._node.vertexZ; // get the vertex data var vertices = attachment.updateWorldVertices(slot, premultipliedAlpha); var offset = vertexDataOffset; @@ -295,18 +296,37 @@ proto._uploadMeshAttachmentData = function(attachment, slot, premultipliedAlpha, nodeB = nodeColor.b, nodeA = this._displayedOpacity; for (var i = 0, n = vertices.length; i < n; i += 8) { + var vx = vertices[i], + vy = vertices[i + 1]; + var x = vx * wa + vy * wb + wx, + y = vx * wc + vy * wd + wy; var r = vertices[i + 2] * nodeR, g = vertices[i + 3] * nodeG, b = vertices[i + 4] * nodeB, a = vertices[i + 5] * nodeA; var color = ((a<<24) | (b<<16) | (g<<8) | r); - f32buffer[offset] = vertices[i]; - f32buffer[offset + 1] = vertices[i + 1]; - f32buffer[offset + 2] = this._node.vertexZ; + f32buffer[offset] = x; + f32buffer[offset + 1] = y; + f32buffer[offset + 2] = z; ui32buffer[offset + 3] = color; f32buffer[offset + 4] = vertices[i + 6]; f32buffer[offset + 5] = vertices[i + 7]; offset += 6; } }; + +// For renderer webgl to identify skeleton's default texture +Object.defineProperty(proto, '_texture', { + get: function () { + var node = this._node; + var slot = node._skeleton.drawOrder[0]; + if (slot) { + var textureAtlas = node.getTextureAtlas(slot.attachment); + return textureAtlas.texture.getRealTexture(); + } + else { + return null; + } + } +}); \ No newline at end of file From 33b0ef954f03a061d8427ff82e9397790f7afafc Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 13 Jul 2017 14:26:35 +0800 Subject: [PATCH 2/4] Fix skeleton batching issue --- cocos2d/core/renderer/RendererWebGL.js | 19 ++++++++----- extensions/spine/SGSkeletonWebGLRenderCmd.js | 30 +++++++------------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 133506c9de..5ff21fc926 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -311,17 +311,22 @@ cc.rendererWebGL = { }, _updateBatchedInfo: function (texture, blendFunc, shaderProgram) { - if (texture) { + if (texture !== _batchedInfo.texture || + blendFunc.src !== _batchedInfo.blendSrc || + blendFunc.dst !== _batchedInfo.blendDst || + shaderProgram !== _batchedInfo.shader) { + // Draw batched elements + this._batchRendering(); + // Update _batchedInfo _batchedInfo.texture = texture; - } - - if (blendFunc) { _batchedInfo.blendSrc = blendFunc.src; _batchedInfo.blendDst = blendFunc.dst; - } - - if (shaderProgram) { _batchedInfo.shader = shaderProgram; + + return true; + } + else { + return false; } }, diff --git a/extensions/spine/SGSkeletonWebGLRenderCmd.js b/extensions/spine/SGSkeletonWebGLRenderCmd.js index 30e113a6a0..ab99df3ea1 100644 --- a/extensions/spine/SGSkeletonWebGLRenderCmd.js +++ b/extensions/spine/SGSkeletonWebGLRenderCmd.js @@ -42,11 +42,8 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){ var node = this._node; var color = this._displayedColor, locSkeleton = node._skeleton; - var textureAtlas, attachment, slot, i, n; + var attachment, slot, i, n; var premultiAlpha = node._premultipliedAlpha; - var blendMode = -1; - var dataInited = false; - var cachedVertices = 0; locSkeleton.r = color.r / 255; locSkeleton.g = color.g / 255; @@ -86,25 +83,18 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){ continue; } var regionTextureAtlas = node.getTextureAtlas(attachment); - // init data at the first time - if (!dataInited) { - textureAtlas = regionTextureAtlas; - blendMode = slot.data.blendMode; - dataInited = true; - } - // if data changed or the vertices will be overflow - if (vertexDataOffset + vertCount * 6 > f32buffer.length || - textureAtlas.texture.getRealTexture() !== regionTextureAtlas.texture.getRealTexture() || - blendMode !== slot.data.blendMode) { + // Broken for changing batch info + var batchBroken = cc.renderer._updateBatchedInfo(regionTextureAtlas.texture.getRealTexture(), this._getBlendFunc(slot.data.blendMode, premultiAlpha), this._shaderProgram); + + // Broken for vertex data overflow + if (!batchBroken && vertexDataOffset + vertCount * 6 > f32buffer.length) { // render the cached data cc.renderer._batchRendering(); + batchBroken = true; + } + if (batchBroken) { vertexDataOffset = 0; - - // update the batched info - textureAtlas = regionTextureAtlas; - blendMode = slot.data.blendMode; - cc.renderer._updateBatchedInfo(textureAtlas.texture.getRealTexture(), this._getBlendFunc(blendMode, premultiAlpha), this.getShaderProgram()); } // update the vertex buffer @@ -321,7 +311,7 @@ Object.defineProperty(proto, '_texture', { get: function () { var node = this._node; var slot = node._skeleton.drawOrder[0]; - if (slot) { + if (slot && slot.attachment) { var textureAtlas = node.getTextureAtlas(slot.attachment); return textureAtlas.texture.getRealTexture(); } From 0779e5a3c6241606b0a0b998a157e8ccf0a00b86 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 13 Jul 2017 23:39:43 +0800 Subject: [PATCH 3/4] Fix spine empty slot breaking batch issue and cleanup code --- cocos2d/core/renderer/RendererWebGL.js | 2 +- extensions/spine/SGSkeleton.js | 18 +++++++++---- extensions/spine/SGSkeletonAnimation.js | 15 ----------- extensions/spine/SGSkeletonTexture.js | 23 +++++++++++++++++ extensions/spine/SGSkeletonWebGLRenderCmd.js | 21 +++------------ extensions/spine/lib/LICENSE | 27 ++++++++++++++++++++ extensions/spine/lib/spine.js | 2 ++ 7 files changed, 70 insertions(+), 38 deletions(-) create mode 100644 extensions/spine/lib/LICENSE diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 5ff21fc926..32cdc49f78 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -128,7 +128,7 @@ cc.rendererWebGL = { _cacheToBufferCmds: {}, // an array saves the renderer commands need for cache to other canvas _cacheInstanceIds: [], _currentID: 0, - _clearColor: {r: 0, g: 0, b: 0, a: 255}, //background color,default BLACK + _clearColor: {r: 0, g: 0, b: 0, a: 1}, //background color,default BLACK init: function () { var gl = cc._renderContext; diff --git a/extensions/spine/SGSkeleton.js b/extensions/spine/SGSkeleton.js index a16420e482..52b6dcd57a 100644 --- a/extensions/spine/SGSkeleton.js +++ b/extensions/spine/SGSkeleton.js @@ -145,7 +145,7 @@ sp._SGSkeleton = _ccsg.Node.extend({ */ getBoundingBox: function () { var minX = cc.macro.FLT_MAX, minY = cc.macro.FLT_MAX, maxX = cc.macro.FLT_MIN, maxY = cc.macro.FLT_MIN; - var scaleX = this.getScaleX(), scaleY = this.getScaleY(), vertices = [], + var scaleX = this.getScaleX(), scaleY = this.getScaleY(), vertices, slots = this._skeleton.slots, VERTEX = spine.RegionAttachment; for (var i = 0, slotCount = slots.length; i < slotCount; ++i) { @@ -322,11 +322,19 @@ sp._SGSkeleton = _ccsg.Node.extend({ // fireball#2856 -Object.defineProperty(sp._SGSkeleton.prototype, 'opacityModifyRGB', { - get: sp._SGSkeleton.prototype.isOpacityModifyRGB +var proto = sp._SGSkeleton.prototype; +Object.defineProperty(proto, 'opacityModifyRGB', { + get: proto.isOpacityModifyRGB }); // For renderer webgl to identify skeleton's default blend function -Object.defineProperty(sp._SGSkeleton.prototype, '_blendFunc', { - get: sp._SGSkeleton.prototype.getBlendFunc +Object.defineProperty(proto, '_blendFunc', { + get: proto.getBlendFunc +}); + +// For renderer webgl to identify skeleton's default texture +Object.defineProperty(proto, '_texture', { + get: function () { + return this._renderCmd._currTexture; + } }); \ No newline at end of file diff --git a/extensions/spine/SGSkeletonAnimation.js b/extensions/spine/SGSkeletonAnimation.js index d79eb120a9..c1b5fbfcf1 100644 --- a/extensions/spine/SGSkeletonAnimation.js +++ b/extensions/spine/SGSkeletonAnimation.js @@ -28,21 +28,6 @@ var spine = sp.spine; var animEventType = sp.AnimationEventType; -sp._atlasPage_createTexture_webGL = function (self, path) { - var texture = cc.textureCache.addImage(path); - self.rendererObject = new cc.TextureAtlas(texture, 128); - self.width = texture.getPixelWidth(); - self.height = texture.getPixelHeight(); -}; - -sp._atlasPage_createTexture_canvas = function(self, path) { - self._texture = cc.textureCache.addImage(path); -}; - -sp._atlasPage_disposeTexture = function (self) { - self.rendererObject.release(); -}; - sp._atlasLoader = { spAtlasFile:null, setAtlasFile:function(spAtlasFile){ diff --git a/extensions/spine/SGSkeletonTexture.js b/extensions/spine/SGSkeletonTexture.js index d6b9121542..9d544d7d2b 100644 --- a/extensions/spine/SGSkeletonTexture.js +++ b/extensions/spine/SGSkeletonTexture.js @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2017 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ sp.SkeletonTexture = cc.Class({ name: 'sp.SkeletonTexture', diff --git a/extensions/spine/SGSkeletonWebGLRenderCmd.js b/extensions/spine/SGSkeletonWebGLRenderCmd.js index ab99df3ea1..c8aba7eac1 100644 --- a/extensions/spine/SGSkeletonWebGLRenderCmd.js +++ b/extensions/spine/SGSkeletonWebGLRenderCmd.js @@ -30,6 +30,7 @@ sp._SGSkeleton.WebGLRenderCmd = function (renderableObject) { this._needDraw = true; this._matrix = new cc.math.Matrix4(); this._matrix.identity(); + this._currTexture = null; this._currBlendFunc = {}; this.vertexType = cc.renderer.VertexType.CUSTOM; this.setShaderProgram(cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLOR)); @@ -85,7 +86,8 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){ var regionTextureAtlas = node.getTextureAtlas(attachment); // Broken for changing batch info - var batchBroken = cc.renderer._updateBatchedInfo(regionTextureAtlas.texture.getRealTexture(), this._getBlendFunc(slot.data.blendMode, premultiAlpha), this._shaderProgram); + this._currTexture = regionTextureAtlas.texture.getRealTexture(); + var batchBroken = cc.renderer._updateBatchedInfo(this._currTexture, this._getBlendFunc(slot.data.blendMode, premultiAlpha), this._shaderProgram); // Broken for vertex data overflow if (!batchBroken && vertexDataOffset + vertCount * 6 > f32buffer.length) { @@ -304,19 +306,4 @@ proto._uploadMeshAttachmentData = function(attachment, slot, premultipliedAlpha, f32buffer[offset + 5] = vertices[i + 7]; offset += 6; } -}; - -// For renderer webgl to identify skeleton's default texture -Object.defineProperty(proto, '_texture', { - get: function () { - var node = this._node; - var slot = node._skeleton.drawOrder[0]; - if (slot && slot.attachment) { - var textureAtlas = node.getTextureAtlas(slot.attachment); - return textureAtlas.texture.getRealTexture(); - } - else { - return null; - } - } -}); \ No newline at end of file +}; \ No newline at end of file diff --git a/extensions/spine/lib/LICENSE b/extensions/spine/lib/LICENSE new file mode 100644 index 0000000000..daceab94a4 --- /dev/null +++ b/extensions/spine/lib/LICENSE @@ -0,0 +1,27 @@ +Spine Runtimes Software License v2.5 + +Copyright (c) 2013-2016, Esoteric Software +All rights reserved. + +You are granted a perpetual, non-exclusive, non-sublicensable, and +non-transferable license to use, install, execute, and perform the Spine +Runtimes software and derivative works solely for personal or internal +use. Without the written permission of Esoteric Software (see Section 2 of +the Spine Software License Agreement), you may not (a) modify, translate, +adapt, or develop new applications using the Spine Runtimes or otherwise +create derivative works or improvements of the Spine Runtimes or (b) remove, +delete, alter, or obscure any trademarks or any copyright, trademark, patent, +or other intellectual property or proprietary rights notices on or in the +Software, including any copy thereof. Redistributions in binary or source +form must include this license and terms. + +THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF +USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/extensions/spine/lib/spine.js b/extensions/spine/lib/spine.js index 230c75cc2f..2ca6537665 100644 --- a/extensions/spine/lib/spine.js +++ b/extensions/spine/lib/spine.js @@ -1,3 +1,5 @@ +// Spine runtime version 3.5.35 + var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } From 0a2d7d685aaade093c2165c91432d90450997461 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 13 Jul 2017 23:40:32 +0800 Subject: [PATCH 4/4] Fix action manager's memory leak --- cocos2d/actions/CCActionManager.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cocos2d/actions/CCActionManager.js b/cocos2d/actions/CCActionManager.js index d9afe9b4d2..5268292657 100644 --- a/cocos2d/actions/CCActionManager.js +++ b/cocos2d/actions/CCActionManager.js @@ -29,15 +29,13 @@ * @constructor * @private */ -var HashElement = cc._Class.extend({ - ctor:function () { - this.actions = []; - this.target = null; //ccobject - this.actionIndex = 0; - this.currentAction = null; //CCAction - this.paused = false; - } -}); +var HashElement = function () { + this.actions = []; + this.target = null; //ccobject + this.actionIndex = 0; + this.currentAction = null; //CCAction + this.paused = false; +}; /** * !#en @@ -91,6 +89,7 @@ cc.ActionManager = cc._Class.extend(/** @lends cc.ActionManager# */{ element.actionIndex = 0; element.currentAction = null; element.paused = false; + element.target = null; this._elementPool.push(element); },