New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed the findCamera problem #3642
Conversation
811493d
to
7016509
Compare
cocos2d/core/camera/CCCamera.js
Outdated
_getGroupIndex (node) { | ||
let groupIndex = node.groupIndex; | ||
if (groupIndex === 0 && node.parent) { | ||
groupIndex = this._getGroupIndex(node.parent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样就是 node.hitTest 里性能消耗比较大,@pandamicro 有其他建议吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group 设置如果是一个非常低频的操作,建议直接在 group setter 中刷新子节点树
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
还有修改 parent 的时候也要再计算,这样 render flow 中 culling mask 的计算可以去掉了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以啊,RenderFlow 的调用频率比 group setter, parent setter 高太多了
7016509
to
490e7ce
Compare
二改,增加了 cullingMask 判断避免非 default 分组的多次重复遍历。 |
490e7ce
to
baef257
Compare
|
cocos2d/core/CCNode.js
Outdated
this.groupIndex = cc.game.groupList.indexOf(value); | ||
this.groupIndex = this._getParentCullingMask(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个获取的包括父节点的信息,不要修改到当前节点。。
cocos2d/core/CCNode.js
Outdated
@@ -3053,6 +3059,15 @@ var Node = cc.Class({ | |||
eventManager.pauseTarget(this); | |||
} | |||
}, | |||
|
|||
// traversal the node tree, child cullingMask must keep the same with the parent. | |||
_getParentCullingMask (node) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数获取的是 groupIndex,不是 cullingmask,叫 _getParentGroupIndex 吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有道理,石乐志
baef257
to
fded43e
Compare
cocos2d/core/CCNode.js
Outdated
@@ -1308,6 +1311,9 @@ var Node = cc.Class({ | |||
|
|||
this._updateOrderOfArrival(); | |||
|
|||
// synchronize _cullingMask | |||
this._cullingMask = 1 << this._getParentGroupIndex(this);; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onBatchRestored 里面也需要做同样的逻辑
cocos2d/core/CCNode.js
Outdated
@@ -3053,6 +3059,15 @@ var Node = cc.Class({ | |||
eventManager.pauseTarget(this); | |||
} | |||
}, | |||
|
|||
// traversal the node tree, child cullingMask must keep the same with the parent. | |||
_getParentGroupIndex (node) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_getActualGroupIndex
fded43e
to
75237c5
Compare
_getActualGroupIndex (node) { | ||
let groupIndex = node.groupIndex; | ||
if (groupIndex === 0 && node.parent) { | ||
groupIndex = this._getActualGroupIndex(node.parent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
干嘛要传入参数啊,直接用 this 不就完事了吗?你都不用 this 的话,这个函数就改成局部函数呗
issue: https://github.com/cocos-creator/2d-tasks/issues/878
fixed the findCamera can't get the correct Camera target when node prop still not init.