mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-19 14:52:40 +08:00
Bug: deserialized scene should have node transforms invalidated at initial (#16353)
* Bug: deserialized scene should have node transforms invalidated * Remove transformFlags modification in _onBatchCreated
This commit is contained in:
committed by
GitHub
parent
5465d2bdb6
commit
767f44a313
@@ -1258,7 +1258,6 @@ nodeProto._onActiveNode = function (shouldActiveNow: boolean) {
|
||||
|
||||
nodeProto._onBatchCreated = function (dontSyncChildPrefab: boolean) {
|
||||
this.hasChangedFlags = TRANSFORMBIT_TRS;
|
||||
this._transformFlags |= TRANSFORMBIT_TRS;
|
||||
const children = this._children;
|
||||
const len = children.length;
|
||||
let child;
|
||||
|
||||
@@ -1525,7 +1525,7 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable {
|
||||
@serializable
|
||||
protected _euler = new Vec3();
|
||||
|
||||
protected _transformFlags = TransformBit.NONE; // does the world transform need to update?
|
||||
protected _transformFlags = TransformBit.TRS; // does the world transform need to update?
|
||||
protected _eulerDirty = false;
|
||||
|
||||
protected _flagChangeVersion = 0;
|
||||
@@ -1883,7 +1883,6 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable {
|
||||
*/
|
||||
public _onBatchCreated (dontSyncChildPrefab: boolean): void {
|
||||
this.hasChangedFlags = TransformBit.TRS;
|
||||
this._transformFlags |= TransformBit.TRS;
|
||||
const len = this._children.length;
|
||||
for (let i = 0; i < len; ++i) {
|
||||
this._children[i]._siblingIndex = i;
|
||||
|
||||
@@ -657,7 +657,7 @@ private:
|
||||
// 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
|
||||
index_t _siblingIndex{0}; // Int32: 0
|
||||
uint8_t _activeInHierarchy{0}; // Uint8: 0
|
||||
uint8_t _active{1}; // Uint8: 1
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { deserialize } from "../../cocos/serialization";
|
||||
import '../utils/matchers/value-type-asymmetric-matchers';
|
||||
import { v3 } from "../../cocos/core";
|
||||
import { Scene } from "../../cocos/scene-graph";
|
||||
|
||||
test(`Bugfix cocos/cocos-engine#16352: deserialized scene should have node transforms invalidated`, () => {
|
||||
const archive = [{
|
||||
__type__: 'cc.Scene',
|
||||
_children: [{
|
||||
__type__: 'cc.Node',
|
||||
_name: 'Node',
|
||||
_lscale: {
|
||||
__type__: 'cc.Vec3',
|
||||
x: 2,
|
||||
y: 1,
|
||||
z: 1,
|
||||
},
|
||||
}],
|
||||
}];
|
||||
|
||||
const scene = deserialize(archive) as Scene;
|
||||
|
||||
const node = scene.getChildByPath('Node')!;
|
||||
expect(node).not.toBeNull();
|
||||
expect(node.worldScale).toBeCloseToVec3(v3(2, 1, 1));
|
||||
});
|
||||
Reference in New Issue
Block a user