Fix Mask reenable render issue (#2834)

* Improve hash calculation in Mask

* Fix Mask reenable render issue
This commit is contained in:
pandamicro
2018-06-08 14:11:53 +08:00
committed by GitHub
parent 056b9e68ee
commit 040c79fc2f
+5 -6
View File
@@ -177,10 +177,9 @@ let Mask = cc.Class({
}
if (this._frontMaterial) {
this._frontMaterial.alphaThreshold = this.alphaThreshold;
this._frontMaterial.updateHash();
this._endMaterial.alphaThreshold = this.alphaThreshold;
this._endMaterial.updateHash();
this._endMaterial._hash = -this._endMaterial._hash;
this._frontMaterial.updateHash();
this._endMaterial._hash = -this._frontMaterial._hash;
}
}
},
@@ -308,9 +307,8 @@ let Mask = cc.Class({
this._endMaterial.useColor = false;
}
this._frontMaterial.updateHash();
this._endMaterial.updateHash();
// Avoid next up mask material to be batch with the exit one
this._endMaterial._hash = -this._endMaterial._hash;
this._endMaterial._hash = -this._frontMaterial._hash;
this.markForRender(true);
},
@@ -353,7 +351,8 @@ let Mask = cc.Class({
markForRender (enable) {
if (enable && this.enabledInHierarchy) {
this.node._renderFlag |= RenderFlow.FLAG_RENDER | RenderFlow.FLAG_POST_RENDER;
this.node._renderFlag |= (RenderFlow.FLAG_RENDER | RenderFlow.FLAG_UPDATE_RENDER_DATA |
RenderFlow.FLAG_POST_RENDER | RenderFlow.FLAG_POST_UPDATE_RENDER_DATA);
}
else if (!enable) {
this.node._renderFlag &= ~(RenderFlow.FLAG_RENDER | RenderFlow.FLAG_POST_RENDER);