From 277707d89297e215744774ea6d4a678cd557d65d Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 12 Apr 2018 12:04:12 +0800 Subject: [PATCH] Fix setWorldDirty and Camera update --- cocos2d/core/CCNode.js | 7 ++----- cocos2d/core/camera/CCCamera.js | 6 ++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index f94064addb..b5e1921efa 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -1976,11 +1976,8 @@ var Node = cc.Class({ if (!this._worldMatDirty) { this._worldMatDirty = true; // Sync world mat dirty to sub tree - if (!this._worldMatDirty) { - this._worldMatDirty = true; - if (this._children.length > 0) { - _syncWorldDirty(this._children); - } + if (this._children.length > 0) { + _syncWorldDirty(this._children); } } }, diff --git a/cocos2d/core/camera/CCCamera.js b/cocos2d/core/camera/CCCamera.js index 3f07157585..d9eb84ff3e 100644 --- a/cocos2d/core/camera/CCCamera.js +++ b/cocos2d/core/camera/CCCamera.js @@ -292,6 +292,7 @@ let Camera = cc.Class({ onEnable () { this._matrixDirty = true; + cc.director.on(cc.Director.EVENT_BEFORE_DRAW, this.beforeDraw, this); if (game.renderType === game.RENDER_TYPE_WEBGL) { renderer.scene.addCamera(this._camera); } @@ -299,6 +300,7 @@ let Camera = cc.Class({ }, onDisable () { + cc.director.off(cc.Director.EVENT_BEFORE_DRAW, this.beforeDraw, this); if (game.renderType === game.RENDER_TYPE_WEBGL) { renderer.scene.removeCamera(this._camera); } @@ -430,12 +432,12 @@ let Camera = cc.Class({ // force update node world matrix this.node.getWorldMatrix(_mat4_temp_1); - this.lateUpdate(); + this.beforeDraw(); renderer._walker.visit(root); renderer._forward.renderCamera(this._camera, renderer.scene); }, - lateUpdate: !CC_EDITOR && function () { + beforeDraw: !CC_EDITOR && function () { let node = this.node; if (!this._matrixDirty && !node._worldMatDirty)