@@ -91,8 +91,10 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){
9191 this . _currTexture = regionTextureAtlas . texture . getRealTexture ( ) ;
9292 var batchBroken = cc . renderer . _updateBatchedInfo ( this . _currTexture , this . _getBlendFunc ( slot . data . blendMode , premultiAlpha ) , this . _glProgramState ) ;
9393
94+ // keep the same logic with RendererWebGL.js, avoid vertex data overflow
95+ var uploadAll = vertexDataOffset / 6 + vertCount > ( cc . BATCH_VERTEX_COUNT - 200 ) * 0.5 ;
9496 // Broken for vertex data overflow
95- if ( ! batchBroken && vertexDataOffset + vertCount * 6 > f32buffer . length ) {
97+ if ( ! batchBroken && uploadAll ) {
9698 // render the cached data
9799 cc . renderer . _batchRendering ( ) ;
98100 batchBroken = true ;
@@ -233,7 +235,25 @@ proto._uploadRegionAttachmentData = function(attachment, slot, premultipliedAlph
233235 nodeG = nodeColor . g ,
234236 nodeB = nodeColor . b ,
235237 nodeA = this . _displayedOpacity ;
236- var vertices = attachment . updateWorldVertices ( slot , premultipliedAlpha ) ;
238+
239+ var vertices = spine . Utils . setArraySize ( new Array ( ) , 8 , 0 ) ;
240+ attachment . computeWorldVertices ( slot . bone , vertices , 0 , 2 ) ;
241+
242+ var uvs = attachment . uvs ;
243+
244+ // get the colors data
245+ var skeleton = slot . bone . skeleton ;
246+ var skeletonColor = skeleton . color ;
247+ var slotColor = slot . color ;
248+ var regionColor = attachment . color ;
249+ var alpha = skeletonColor . a * slotColor . a * regionColor . a ;
250+ var multiplier = premultipliedAlpha ? alpha : 1 ;
251+ var colors = attachment . tempColor ;
252+ colors . set ( skeletonColor . r * slotColor . r * regionColor . r * multiplier ,
253+ skeletonColor . g * slotColor . g * regionColor . g * multiplier ,
254+ skeletonColor . b * slotColor . b * regionColor . b * multiplier ,
255+ alpha ) ;
256+
237257 var wt = this . _worldTransform ,
238258 wa = wt . a , wb = wt . b , wc = wt . c , wd = wt . d ,
239259 wx = wt . tx , wy = wt . ty ,
@@ -244,32 +264,32 @@ proto._uploadRegionAttachmentData = function(attachment, slot, premultipliedAlph
244264 // using two angles : (0, 1, 2) & (0, 2, 3)
245265 for ( var i = 0 ; i < 6 ; i ++ ) {
246266 var srcIdx = i < 4 ? i % 3 : i - 2 ;
247- var vx = vertices [ srcIdx * 8 ] ,
248- vy = vertices [ srcIdx * 8 + 1 ] ;
267+ var vx = vertices [ srcIdx * 2 ] ,
268+ vy = vertices [ srcIdx * 2 + 1 ] ;
249269 var x = vx * wa + vy * wc + wx ,
250270 y = vx * wb + vy * wd + wy ;
251- var r = vertices [ srcIdx * 8 + 2 ] * nodeR ,
252- g = vertices [ srcIdx * 8 + 3 ] * nodeG ,
253- b = vertices [ srcIdx * 8 + 4 ] * nodeB ,
254- a = vertices [ srcIdx * 8 + 5 ] * nodeA ;
271+ var r = colors . r * nodeR ,
272+ g = colors . g * nodeG ,
273+ b = colors . b * nodeB ,
274+ a = colors . a * nodeA ;
255275 var color = ( ( a << 24 ) | ( b << 16 ) | ( g << 8 ) | r ) ;
256276 f32buffer [ offset ] = x ;
257277 f32buffer [ offset + 1 ] = y ;
258278 f32buffer [ offset + 2 ] = z ;
259279 ui32buffer [ offset + 3 ] = color ;
260- f32buffer [ offset + 4 ] = vertices [ srcIdx * 8 + 6 ] ;
261- f32buffer [ offset + 5 ] = vertices [ srcIdx * 8 + 7 ] ;
280+ f32buffer [ offset + 4 ] = uvs [ srcIdx * 2 ] ;
281+ f32buffer [ offset + 5 ] = uvs [ srcIdx * 2 + 1 ] ;
262282 offset += 6 ;
263283 }
264284
265285 if ( this . _node . _debugSlots ) {
266286 // return the quad points info if debug slot enabled
267287 var VERTEX = spine . RegionAttachment ;
268288 return [
269- cc . p ( vertices [ VERTEX . X1 ] , vertices [ VERTEX . Y1 ] ) ,
270- cc . p ( vertices [ VERTEX . X2 ] , vertices [ VERTEX . Y2 ] ) ,
271- cc . p ( vertices [ VERTEX . X3 ] , vertices [ VERTEX . Y3 ] ) ,
272- cc . p ( vertices [ VERTEX . X4 ] , vertices [ VERTEX . Y4 ] )
289+ cc . p ( vertices [ VERTEX . OX1 ] , vertices [ VERTEX . OY1 ] ) ,
290+ cc . p ( vertices [ VERTEX . OX2 ] , vertices [ VERTEX . OY2 ] ) ,
291+ cc . p ( vertices [ VERTEX . OX3 ] , vertices [ VERTEX . OY3 ] ) ,
292+ cc . p ( vertices [ VERTEX . OX4 ] , vertices [ VERTEX . OY4 ] )
273293 ] ;
274294 }
275295} ;
@@ -280,30 +300,46 @@ proto._uploadMeshAttachmentData = function(attachment, slot, premultipliedAlpha,
280300 wx = wt . tx , wy = wt . ty ,
281301 z = this . _node . vertexZ ;
282302 // get the vertex data
283- var vertices = attachment . updateWorldVertices ( slot , premultipliedAlpha ) ;
303+ var verticesLength = attachment . worldVerticesLength ;
304+ var vertices = spine . Utils . setArraySize ( new Array ( ) , verticesLength , 0 ) ;
305+ attachment . computeWorldVertices ( slot , 0 , verticesLength , vertices , 0 , 2 ) ;
306+
307+ var uvs = attachment . uvs ;
308+
309+ // get the colors data
310+ var skeleton = slot . bone . skeleton ;
311+ var skeletonColor = skeleton . color , slotColor = slot . color , meshColor = attachment . color ;
312+ var alpha = skeletonColor . a * slotColor . a * meshColor . a ;
313+ var multiplier = premultipliedAlpha ? alpha : 1 ;
314+ var colors = attachment . tempColor ;
315+ colors . set ( skeletonColor . r * slotColor . r * meshColor . r * multiplier ,
316+ skeletonColor . g * slotColor . g * meshColor . g * multiplier ,
317+ skeletonColor . b * slotColor . b * meshColor . b * multiplier ,
318+ alpha ) ;
319+
284320 var offset = vertexDataOffset ;
285321 var nodeColor = this . _displayedColor ;
286322 var nodeR = nodeColor . r ,
287323 nodeG = nodeColor . g ,
288324 nodeB = nodeColor . b ,
289325 nodeA = this . _displayedOpacity ;
290- for ( var i = 0 , n = vertices . length ; i < n ; i += 8 ) {
326+ for ( var i = 0 , n = vertices . length ; i < n ; i += 2 ) {
291327 var vx = vertices [ i ] ,
292328 vy = vertices [ i + 1 ] ;
293329 var x = vx * wa + vy * wb + wx ,
294330 y = vx * wc + vy * wd + wy ;
295- var r = vertices [ i + 2 ] * nodeR ,
296- g = vertices [ i + 3 ] * nodeG ,
297- b = vertices [ i + 4 ] * nodeB ,
298- a = vertices [ i + 5 ] * nodeA ;
331+ var r = colors . r * nodeR ,
332+ g = colors . g * nodeG ,
333+ b = colors . b * nodeB ,
334+ a = colors . a * nodeA ;
299335 var color = ( ( a << 24 ) | ( b << 16 ) | ( g << 8 ) | r ) ;
300336
301337 f32buffer [ offset ] = x ;
302338 f32buffer [ offset + 1 ] = y ;
303339 f32buffer [ offset + 2 ] = z ;
304340 ui32buffer [ offset + 3 ] = color ;
305- f32buffer [ offset + 4 ] = vertices [ i + 6 ] ;
306- f32buffer [ offset + 5 ] = vertices [ i + 7 ] ;
341+ f32buffer [ offset + 4 ] = uvs [ i ] ;
342+ f32buffer [ offset + 5 ] = uvs [ i + 1 ] ;
307343 offset += 6 ;
308344 }
309345} ;
0 commit comments