@@ -91,8 +91,10 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){
91
91
this . _currTexture = regionTextureAtlas . texture . getRealTexture ( ) ;
92
92
var batchBroken = cc . renderer . _updateBatchedInfo ( this . _currTexture , this . _getBlendFunc ( slot . data . blendMode , premultiAlpha ) , this . _glProgramState ) ;
93
93
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 ;
94
96
// Broken for vertex data overflow
95
- if ( ! batchBroken && vertexDataOffset + vertCount * 6 > f32buffer . length ) {
97
+ if ( ! batchBroken && uploadAll ) {
96
98
// render the cached data
97
99
cc . renderer . _batchRendering ( ) ;
98
100
batchBroken = true ;
@@ -233,7 +235,25 @@ proto._uploadRegionAttachmentData = function(attachment, slot, premultipliedAlph
233
235
nodeG = nodeColor . g ,
234
236
nodeB = nodeColor . b ,
235
237
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
+
237
257
var wt = this . _worldTransform ,
238
258
wa = wt . a , wb = wt . b , wc = wt . c , wd = wt . d ,
239
259
wx = wt . tx , wy = wt . ty ,
@@ -244,32 +264,32 @@ proto._uploadRegionAttachmentData = function(attachment, slot, premultipliedAlph
244
264
// using two angles : (0, 1, 2) & (0, 2, 3)
245
265
for ( var i = 0 ; i < 6 ; i ++ ) {
246
266
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 ] ;
249
269
var x = vx * wa + vy * wc + wx ,
250
270
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 ;
255
275
var color = ( ( a << 24 ) | ( b << 16 ) | ( g << 8 ) | r ) ;
256
276
f32buffer [ offset ] = x ;
257
277
f32buffer [ offset + 1 ] = y ;
258
278
f32buffer [ offset + 2 ] = z ;
259
279
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 ] ;
262
282
offset += 6 ;
263
283
}
264
284
265
285
if ( this . _node . _debugSlots ) {
266
286
// return the quad points info if debug slot enabled
267
287
var VERTEX = spine . RegionAttachment ;
268
288
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 ] )
273
293
] ;
274
294
}
275
295
} ;
@@ -280,30 +300,46 @@ proto._uploadMeshAttachmentData = function(attachment, slot, premultipliedAlpha,
280
300
wx = wt . tx , wy = wt . ty ,
281
301
z = this . _node . vertexZ ;
282
302
// 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
+
284
320
var offset = vertexDataOffset ;
285
321
var nodeColor = this . _displayedColor ;
286
322
var nodeR = nodeColor . r ,
287
323
nodeG = nodeColor . g ,
288
324
nodeB = nodeColor . b ,
289
325
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 ) {
291
327
var vx = vertices [ i ] ,
292
328
vy = vertices [ i + 1 ] ;
293
329
var x = vx * wa + vy * wb + wx ,
294
330
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 ;
299
335
var color = ( ( a << 24 ) | ( b << 16 ) | ( g << 8 ) | r ) ;
300
336
301
337
f32buffer [ offset ] = x ;
302
338
f32buffer [ offset + 1 ] = y ;
303
339
f32buffer [ offset + 2 ] = z ;
304
340
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 ] ;
307
343
offset += 6 ;
308
344
}
309
345
} ;
0 commit comments