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

Fix LOD can not work normally while node's active changed dynamically #15641

Merged
merged 12 commits into from
Jul 13, 2023

Conversation

bofeng-song
Copy link
Contributor

Re: #

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.

@bofeng-song bofeng-song requested a review from minggo July 7, 2023 00:21
@github-actions
Copy link

github-actions bot commented Jul 7, 2023

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -5258,8 +5258,14 @@
          * @en Force LOD level to use.
          * lodLevel @en The LOD level to use. Passing lodLevel < 0 will return to standard LOD processing. @zh 要使用的LOD层级,为负数时使用标准的处理流程
          */
         forceLOD(lodLevel: number): void;
+        /**
+         * @en Force multi LOD level to use, This function is only called in editor.<br/>
+         * @zh 强制使用某几级的LOD,该接口只会在编辑器下调用。
+         * lodIndexArray @en The LOD level array. Passing [] will return to standard LOD processing. @zh 要使用的LOD层级数组,传[]时将使用标准的处理流程。
+         */
+        forceLODs(lodIndexArray: number[]): void;
         onLoad(): void;
         _onRemove(comp: Component): void;
         onRestore(): void;
         onEnable(): void;

@@ -609,6 +618,9 @@ export class LODGroup extends Component {

onDisable (): void {
this._detachFromScene();
if (this._forceUsedLevel >= 0) {
this.lodGroup.lockLODLevels([]);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to wrap it into a function to update lockedLODLevels of lodGroup.

@@ -628,6 +643,14 @@ export class LODGroup extends Component {
/**
* @engineInternal
*/
protected _updateLockedLODLevels (): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use private?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forceLODs will use it, as it is defined outside the class of LODGroup

this.lodGroup.lockLODLevels(this._forceUsedLevels);
} else {
this.lodGroup.clearLockedLODLevels();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just invoke this.lodGroup.lockLODLevels(this._forceUsedLevels); is enough.

@minggo minggo merged commit 7465cf6 into cocos:v3.8.1 Jul 13, 2023
9 of 10 checks passed
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.

3 participants