Skip to content
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

[batcher-2d.ts] Add a new hook-method , to check whether 'node' can be walked. #17203

Open
wants to merge 1 commit into
base: v3.8.5
Choose a base branch
from

Conversation

finscn
Copy link
Contributor

@finscn finscn commented Jun 21, 2024

Add a new hook-method , to check whether 'node' can be walked.

Re: #

更多讨论详见
#17159 (comment)

此修改不会破坏和影响目前先有的 cocos的任何逻辑.
而且作为 给 高级cocos开发人员使用的方式, 也不需要针对这个修改更新文档.
是一个比较安全和保守的更新.
但是能满足很多开发者对高性能追求.

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

Add a new hook-method , to check whether 'node' can be walked.
@finscn finscn changed the title Update batcher-2d.ts [batcher-2d.ts] Add a new hook-method , to check whether 'node' can be walked. Jun 21, 2024
Copy link

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -3789,8 +3789,18 @@
          * @zh
          * 强制刷新材质。
          */
         flushMaterial(mat: Material): void;
+        /**
+         * @en
+         * check whether 'node' can be walked.
+         * Developers can override this method to implement custom behavior.
+         *
+         * @zh
+         * 判断 `node` 是否可以被 walk.
+         * 开发者可以重写该方法, 以实现自定义的行为.
+         */
+        canWalkNode(node: Node): boolean;
         walk(node: Node, level?: number): void;
         syncMeshBuffersToNative(accId: number, buffers: MeshBuffer[]): void;
     }
     /**

@yanjifa
Copy link
Contributor

yanjifa commented Jun 21, 2024

不改 Batcher2d.cpp 会导致 web 和原生平台表现不一样

@finscn
Copy link
Contributor Author

finscn commented Jun 22, 2024

不改 Batcher2d.cpp 会导致 web 和原生平台表现不一样

这个我不知道怎么改.... 希望引擎组的同学能考虑下这个PR, 并帮忙实现一个跨平台的版本

@whaqzhzd
Copy link

whaqzhzd commented Jun 24, 2024

这样修改相当于每一次walk都需要增加一次c++ call js的开销。因为你的can walk写在js里。

假如用户并不需要canWalkNode则每次渲染需要增加更多的的c++/js互调用开销。因为canWalkNode总是需要c++ call js

@finscn
Copy link
Contributor Author

finscn commented Jun 24, 2024

这样修改相当于每一次walk都需要增加一次c++ call js的开销。因为你的can walk写在js里。

假如用户并不需要canWalkNode则每次渲染需要增加更多的的c++/js互调用开销。因为canWalkNode总是需要c++ call js

那这么看来 还是加个属性是最好的 ....

@finscn
Copy link
Contributor Author

finscn commented Jun 24, 2024

不管怎样 这个属性我觉得是真的需要. 论坛里也有人说过这个事情 但是大家都是用一些不太好的hack手段来实现的.
以前 cocos 2.x 里有 renderFlag 能实现这个功能, 3.x里没有了. 性能是引擎很重要的特性. 希望官方能考虑下. @minggo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants