Skip to content

Commit

Permalink
fix meshBuffer realloac vData (cocos#3258)
Browse files Browse the repository at this point in the history
  • Loading branch information
PPpro authored and pandamicro committed Sep 17, 2018
1 parent 8b8db69 commit dd03aba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cocos2d/core/renderer/webgl/mesh-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,18 @@ let MeshBuffer = cc.Class({
},

_reallocVData (copyOldData) {
let oldVData = this._vData;
let oldVData;
if (this._vData) {
oldVData = new Uint8Array(oldVData.buffer);
}

this._vData = new Float32Array(this._initVDataCount);
this._uintVData = new Uint32Array(this._vData.buffer);
let newData = new Uint8Array(this._uintVData.buffer);

if (oldVData && copyOldData) {
let vData = this._vData;
for (let i = 0, l = oldVData.length; i < l; i++) {
vData[i] = oldVData[i];
newData[i] = oldVData[i];
}
}

Expand Down

0 comments on commit dd03aba

Please sign in to comment.