Fix updateWorldVerts based on worldMatUpdated and other issues (#2593)

* Fix updateWorldVerts based on worldMatUpdated

* Fix issues
This commit is contained in:
pandamicro
2018-04-24 22:23:18 +08:00
committed by GitHub
parent c80c8328b4
commit 7b98f49cd6
7 changed files with 21 additions and 13 deletions
+8 -5
View File
@@ -916,9 +916,9 @@ var Node = cc.Class({
this._matrix = mathPools.mat4.get();
this._worldMatrix = mathPools.mat4.get();
this._localMatDirty = 0;
this._worldMatDirty = false;
this.setLocalDirty(ALL_DIRTY_FLAG);
this._localMatDirty = ALL_DIRTY_FLAG;
this._worldMatDirty = true;
this._worldMatUpdated = false;
this._cullingMask = 1 << this.groupIndex;
},
@@ -1990,11 +1990,12 @@ var Node = cc.Class({
math.mat4.copy(this._worldMatrix, this._matrix);
}
this._worldMatDirty = false;
this._worldMatUpdated = true;
},
_updateWorldMatrix () {
if (this.parent) {
this.parent._updateWorldMatrix();
if (this._parent) {
this._parent._updateWorldMatrix();
}
if (this._worldMatDirty) {
this._calculWorldMatrix();
@@ -2010,12 +2011,14 @@ var Node = cc.Class({
this._localMatDirty = this._localMatDirty | flag;
if (!this._worldMatDirty) {
this._worldMatDirty = true;
this._worldMatUpdated = false;
}
},
setWorldDirty () {
if (!this._worldMatDirty) {
this._worldMatDirty = true;
this._worldMatUpdated = false;
}
},
+1 -1
View File
@@ -1080,7 +1080,7 @@ cc.ContainerStrategy = cc.Class({
locCanvas.height = h * devicePixelRatio;
// set sharedCanvas size
if (cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT_GAME) {
if (cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT_GAME && wx.getOpenDataContext) {
var openDataContext = wx.getOpenDataContext();
var sharedCanvas = openDataContext.canvas;
if (sharedCanvas) {
@@ -95,7 +95,7 @@ let maskFrontAssembler = js.addon({
datas = mask._renderDatas;
datas.length = 0;
renderData.dataLength = 4;
spriteAssembler.update(mask);
spriteAssembler.updateRenderData(mask);
renderData.material = mask.getMaterial();
datas.push(renderData);
}
@@ -79,7 +79,7 @@ module.exports = {
if (vertDirty) {
this.updateVerts(sprite, fillStart, fillEnd);
}
if (vertDirty || batchData.worldMatUpdated) {
if (vertDirty || sprite.node._worldMatUpdated) {
this.updateWorldVerts(sprite);
}
}
@@ -66,7 +66,7 @@ const dynamicAtlasManager = require('../../utils/dynamic-atlas/manager');
if (vertDirty) {
this.updateVerts(sprite);
}
if (vertDirty || batchData.worldMatUpdated) {
if (vertDirty || sprite.node._worldMatUpdated) {
this.updateWorldVerts(sprite);
}
}
@@ -64,7 +64,7 @@ module.exports = {
if (vertDirty) {
this.updateVerts(sprite);
}
if (vertDirty || batchData.worldMatUpdated) {
if (vertDirty || sprite.node._worldMatUpdated) {
this.updateWorldVerts(sprite);
}
}
@@ -326,13 +326,15 @@ RenderComponentWalker.prototype = {
}
let batchData = this._batchData;
let dirtyBySelf = false;
// Transform
if (node._worldMatDirty) {
if (node._worldMatDirty && !batchData.worldMatUpdated) {
batchData.worldMatUpdated = true;
dirtyBySelf = true;
}
// Parent world mat dirty will be registered in worldMatUpdated, so children will be updated too
if (batchData.worldMatUpdated) {
node._updateWorldMatrix();
node._calculWorldMatrix();
}
// Culling mask
@@ -362,7 +364,10 @@ RenderComponentWalker.prototype = {
}
// Reset worldMatUpdated
batchData.worldMatUpdated = false;
node._worldMatUpdated = false;
if (dirtyBySelf) {
batchData.worldMatUpdated = false;
}
// Reset current camera node
if (this._curCameraNode === node) {
this._curCameraNode = null;