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

Bug: deserialized scene should have node transforms invalidated at initial #16353

Merged
merged 3 commits into from
Oct 9, 2023

Conversation

shrinktofit
Copy link
Contributor

Re: #16352

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.

@shrinktofit
Copy link
Contributor Author

@cocos-robot run test cases

@github-actions
Copy link

github-actions bot commented Oct 7, 2023

Interface Check Report

This pull request does not change any public interfaces !

@@ -657,7 +657,7 @@ class Node : public CCObject {
// NOTE: TypeArray created in node.jsb.ts _ctor should have the same memory layout
uint32_t _eventMask{0}; // Uint32: 0
uint32_t _layer{static_cast<uint32_t>(Layers::LayerList::DEFAULT)}; // Uint32: 1
uint32_t _transformFlags{0}; // Uint32: 2
uint32_t _transformFlags{static_cast<uint32_t>(TransformBit::TRS)}; // Uint32: 2
Copy link
Contributor

Choose a reason for hiding this comment

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

this._transformFlags |= TransformBit.TRS; was set in _onBatchCreated.

If we modify the initialized value to TRS, will it mark it as dirty twice and call updateWorldTransform twice?

For instance,

const scene = deserialize(archive) as Scene;
const node = scene.getChildByPath('Node')!;
const worldScale = node.worldScale;  // call updateWorldTransform internally, and reset child._transformFlags = TransformBit.NONE;

// Use worldScale 

director.runScene(scene); // call scene._load -> scene._onBatchCreated -> node._onBatchCreated -> this._transformFlags |= TransformBit.TRS; 
//  this._transformFlags is set to TransformBit.TRS again, so updateWorldTransform will be invoked twice, but in fact, the world transform was not changed at all.

Copy link
Contributor Author

@shrinktofit shrinktofit Oct 8, 2023

Choose a reason for hiding this comment

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

I'd recommend deleting transform flags modification in Node._onBatchCreated.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's ok for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shrinktofit shrinktofit requested a review from dogeFu October 8, 2023 10:12
@shrinktofit
Copy link
Contributor Author

@cocos-robot run test cases

@shrinktofit shrinktofit removed the request for review from LinYunMo October 9, 2023 08:48
@SantyWang SantyWang merged commit 767f44a into cocos:v3.8.2 Oct 9, 2023
22 of 23 checks passed
@shrinktofit shrinktofit deleted the FixSceneDirty branch October 9, 2023 08:53
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.

4 participants