Code Monkey home page Code Monkey logo

Comments (3)

finscn avatar finscn commented on September 27, 2024

在 _onPostActivated() (active为true) 和 _onSetParent() (parent不为null) 中的 invalidateChildren() 可以考虑强制执行, 其他的情况 是否可以不执行invalidateChildren() ?

另外 invalidateChildren() 会往 dirtyNodes 里添加很多节点.
然后 updateWorldTransform() 方法又会对 dirtyNodes 中的节点进行较复杂的计算 , 计算时同样不会判断节点是否是 active 的 , 这里应该也会引起性能问题吧 ?


还没有对 3.x 做深入研究, 以上两条观点只是猜测.
但是用chrome做性能检测 , 在我的场景里, invalidateChildren() 确实是性能热点之一 .

from cocos-engine.

finscn avatar finscn commented on September 27, 2024

我测试了下, 在 updateWorldTransform() 前面 加上

        if (!this._active || !this._activeInHierarchy) {
            return;
        }

似乎没什么问题, 不过只针对我的项目, 不知道是否有通用性.

另外我打印了 updateWorldTransform 里的 dirtyNodes 的状态, 其中大量的 active=false的节点. 这些节点在active=false时, 应该无需计算矩阵吧?

from cocos-engine.

finscn avatar finscn commented on September 27, 2024

如果 invalidateChildren 和 updateWorldTransform 方法不能改动的话, 希望能把 dirtyNodes 变量暴路出来 .
这样我可以自己重写 invalidateChildren 和 updateWorldTransform , 目前 因为 dirtyNodes 等变量的作用域限制 , 我无法自己重写这两个方法.

目前看下来, 问题的关键点是 _active / _activeInHierarchy = false 的节点也被放入 dirtyNodes , 导致性能问题

from cocos-engine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.