mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
Fix node move (#8177)
* Fix node-move bug in 2d-rendering-in-3d testcase * Fix node-move bug in 2d-rendering-in-3d testcase (update) * Fix node-move bug in 2d-rendering-in-3d testcase v2
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { ccclass, executeInEditMode, help, menu } from '../core/data/class-decorator';
|
||||
import { Renderable2D } from '../2d/framework/renderable-2d';
|
||||
import { Node, EventTarget, CCClass, Color, Enum, PrivateNode, ccenum, errorID, Texture2D, js, CCObject } from '../core';
|
||||
import { Node, EventTarget, CCClass, Color, Enum, PrivateNode, ccenum, errorID, Texture2D, js, CCObject, SystemEventType } from '../core';
|
||||
import { BlendFactor } from '../core/gfx';
|
||||
import { displayName, editable, serializable, tooltip, type, visible } from '../core/data/decorators';
|
||||
import { AnimationCache, ArmatureCache, ArmatureFrame } from './ArmatureCache';
|
||||
@@ -707,6 +707,20 @@ export class ArmatureDisplay extends Renderable2D {
|
||||
this._flushAssembler();
|
||||
}
|
||||
|
||||
public _onSyncTransform () {
|
||||
this.node.on(SystemEventType.TRANSFORM_CHANGED, this.syncTransform, this);
|
||||
this.node.on(SystemEventType.SIZE_CHANGED, this.syncTransform, this);
|
||||
}
|
||||
|
||||
public _offSyncTransform () {
|
||||
this.node.off(SystemEventType.TRANSFORM_CHANGED, this.syncTransform, this);
|
||||
this.node.off(SystemEventType.SIZE_CHANGED, this.syncTransform, this);
|
||||
}
|
||||
|
||||
private syncTransform () {
|
||||
|
||||
}
|
||||
|
||||
onDisable () {
|
||||
super.onDisable();
|
||||
// If cache mode is cache, no need to update by dragonbones library.
|
||||
|
||||
+15
-1
@@ -5,7 +5,7 @@ import SkeletonCache, { AnimationCache, AnimationFrame } from './skeleton-cache'
|
||||
import { AttachUtil } from './attach-util';
|
||||
import { ccclass, executeInEditMode, help, menu } from '../core/data/class-decorator';
|
||||
import { Renderable2D } from '../2d/framework/renderable-2d';
|
||||
import { Node, CCClass, CCObject, Color, Enum, Material, PrivateNode, Texture2D, builtinResMgr, ccenum, errorID, logID, warn } from '../core';
|
||||
import { Node, CCClass, CCObject, Color, Enum, Material, PrivateNode, Texture2D, builtinResMgr, ccenum, errorID, logID, warn, SystemEventType } from '../core';
|
||||
import { displayName, editable, override, serializable, tooltip, type, visible } from '../core/data/decorators';
|
||||
import { SkeletonData } from './skeleton-data';
|
||||
import { VertexEffectDelegate } from './vertex-effect-delegate';
|
||||
@@ -1265,6 +1265,20 @@ export class Skeleton extends Renderable2D {
|
||||
this._flushAssembler();
|
||||
}
|
||||
|
||||
public _onSyncTransform () {
|
||||
this.node.on(SystemEventType.TRANSFORM_CHANGED, this.syncTransform, this);
|
||||
this.node.on(SystemEventType.SIZE_CHANGED, this.syncTransform, this);
|
||||
}
|
||||
|
||||
public _offSyncTransform () {
|
||||
this.node.off(SystemEventType.TRANSFORM_CHANGED, this.syncTransform, this);
|
||||
this.node.off(SystemEventType.SIZE_CHANGED, this.syncTransform, this);
|
||||
}
|
||||
|
||||
private syncTransform () {
|
||||
|
||||
}
|
||||
|
||||
public onDestroy () {
|
||||
this.destroyRenderData();
|
||||
super.onDestroy();
|
||||
|
||||
@@ -519,6 +519,7 @@ const cacheManager = require('./jsb-cache-manager');
|
||||
if (this._armature && !this.isAnimationCached()) {
|
||||
this._factory.add(this._armature);
|
||||
}
|
||||
this._onSyncTransform();
|
||||
this.syncTransform(true);
|
||||
this._flushAssembler();
|
||||
middleware.retain();
|
||||
@@ -530,6 +531,7 @@ const cacheManager = require('./jsb-cache-manager');
|
||||
if (this._armature && !this.isAnimationCached()) {
|
||||
this._factory.remove(this._armature);
|
||||
}
|
||||
this._offSyncTransform();
|
||||
middleware.release();
|
||||
};
|
||||
|
||||
@@ -583,28 +585,26 @@ const cacheManager = require('./jsb-cache-manager');
|
||||
|
||||
let paramsBuffer = this._paramsBuffer;
|
||||
if (!paramsBuffer) return;
|
||||
|
||||
if (force || node.hasChangedFlags) {
|
||||
// sync node world matrix to native
|
||||
node.updateWorldTransform();
|
||||
let worldMat = node._mat;
|
||||
paramsBuffer[1] = worldMat.m00;
|
||||
paramsBuffer[2] = worldMat.m01;
|
||||
paramsBuffer[3] = worldMat.m02;
|
||||
paramsBuffer[4] = worldMat.m03;
|
||||
paramsBuffer[5] = worldMat.m04;
|
||||
paramsBuffer[6] = worldMat.m05;
|
||||
paramsBuffer[7] = worldMat.m06;
|
||||
paramsBuffer[8] = worldMat.m07;
|
||||
paramsBuffer[9] = worldMat.m08;
|
||||
paramsBuffer[10] = worldMat.m09;
|
||||
paramsBuffer[11] = worldMat.m10;
|
||||
paramsBuffer[12] = worldMat.m11;
|
||||
paramsBuffer[13] = worldMat.m12;
|
||||
paramsBuffer[14] = worldMat.m13;
|
||||
paramsBuffer[15] = worldMat.m14;
|
||||
paramsBuffer[16] = worldMat.m15;
|
||||
}
|
||||
|
||||
// sync node world matrix to native
|
||||
node.updateWorldTransform();
|
||||
let worldMat = node._mat;
|
||||
paramsBuffer[1] = worldMat.m00;
|
||||
paramsBuffer[2] = worldMat.m01;
|
||||
paramsBuffer[3] = worldMat.m02;
|
||||
paramsBuffer[4] = worldMat.m03;
|
||||
paramsBuffer[5] = worldMat.m04;
|
||||
paramsBuffer[6] = worldMat.m05;
|
||||
paramsBuffer[7] = worldMat.m06;
|
||||
paramsBuffer[8] = worldMat.m07;
|
||||
paramsBuffer[9] = worldMat.m08;
|
||||
paramsBuffer[10] = worldMat.m09;
|
||||
paramsBuffer[11] = worldMat.m10;
|
||||
paramsBuffer[12] = worldMat.m11;
|
||||
paramsBuffer[13] = worldMat.m12;
|
||||
paramsBuffer[14] = worldMat.m13;
|
||||
paramsBuffer[15] = worldMat.m14;
|
||||
paramsBuffer[16] = worldMat.m15;
|
||||
};
|
||||
|
||||
armatureDisplayProto.setAnimationCacheMode = function (cacheMode) {
|
||||
@@ -635,7 +635,6 @@ const cacheManager = require('./jsb-cache-manager');
|
||||
middleware.renderOrder++;
|
||||
}
|
||||
|
||||
this.syncTransform();
|
||||
|
||||
if (this.__preColor__ === undefined || !this.color.equals(this.__preColor__)) {
|
||||
let compColor = this.color;
|
||||
|
||||
@@ -378,6 +378,7 @@ const cacheManager = require('./jsb-cache-manager');
|
||||
let _onEnable = skeleton.onEnable;
|
||||
skeleton.onEnable = function () {
|
||||
_onEnable.call(this);
|
||||
this._onSyncTransform();
|
||||
this.syncTransform(true);
|
||||
|
||||
if (this._nativeSkeleton) {
|
||||
@@ -389,6 +390,8 @@ const cacheManager = require('./jsb-cache-manager');
|
||||
let _onDisable = skeleton.onDisable;
|
||||
skeleton.onDisable = function () {
|
||||
_onDisable.call(this);
|
||||
this._offSyncTransform();
|
||||
|
||||
if (this._nativeSkeleton) {
|
||||
this._nativeSkeleton.onDisable();
|
||||
}
|
||||
@@ -408,27 +411,25 @@ const cacheManager = require('./jsb-cache-manager');
|
||||
let paramsBuffer = this._paramsBuffer;
|
||||
if (!paramsBuffer) return;
|
||||
|
||||
if (force || node.hasChangedFlags) {
|
||||
// sync node world matrix to native
|
||||
node.updateWorldTransform();
|
||||
let worldMat = node._mat;
|
||||
paramsBuffer[1] = worldMat.m00;
|
||||
paramsBuffer[2] = worldMat.m01;
|
||||
paramsBuffer[3] = worldMat.m02;
|
||||
paramsBuffer[4] = worldMat.m03;
|
||||
paramsBuffer[5] = worldMat.m04;
|
||||
paramsBuffer[6] = worldMat.m05;
|
||||
paramsBuffer[7] = worldMat.m06;
|
||||
paramsBuffer[8] = worldMat.m07;
|
||||
paramsBuffer[9] = worldMat.m08;
|
||||
paramsBuffer[10] = worldMat.m09;
|
||||
paramsBuffer[11] = worldMat.m10;
|
||||
paramsBuffer[12] = worldMat.m11;
|
||||
paramsBuffer[13] = worldMat.m12;
|
||||
paramsBuffer[14] = worldMat.m13;
|
||||
paramsBuffer[15] = worldMat.m14;
|
||||
paramsBuffer[16] = worldMat.m15;
|
||||
}
|
||||
// sync node world matrix to native
|
||||
node.updateWorldTransform();
|
||||
let worldMat = node._mat;
|
||||
paramsBuffer[1] = worldMat.m00;
|
||||
paramsBuffer[2] = worldMat.m01;
|
||||
paramsBuffer[3] = worldMat.m02;
|
||||
paramsBuffer[4] = worldMat.m03;
|
||||
paramsBuffer[5] = worldMat.m04;
|
||||
paramsBuffer[6] = worldMat.m05;
|
||||
paramsBuffer[7] = worldMat.m06;
|
||||
paramsBuffer[8] = worldMat.m07;
|
||||
paramsBuffer[9] = worldMat.m08;
|
||||
paramsBuffer[10] = worldMat.m09;
|
||||
paramsBuffer[11] = worldMat.m10;
|
||||
paramsBuffer[12] = worldMat.m11;
|
||||
paramsBuffer[13] = worldMat.m12;
|
||||
paramsBuffer[14] = worldMat.m13;
|
||||
paramsBuffer[15] = worldMat.m14;
|
||||
paramsBuffer[16] = worldMat.m15;
|
||||
};
|
||||
|
||||
skeleton.update = function () {
|
||||
@@ -445,7 +446,6 @@ const cacheManager = require('./jsb-cache-manager');
|
||||
middleware.renderOrder++;
|
||||
}
|
||||
|
||||
this.syncTransform();
|
||||
|
||||
if (this.__preColor__ === undefined || !this.color.equals(this.__preColor__)) {
|
||||
let compColor = this.color;
|
||||
|
||||
Reference in New Issue
Block a user