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

V2.2.1 release optimize skew2 #5629

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions cocos2d/core/CCNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,19 @@ var _mouseEvents = [
EventType.MOUSE_WHEEL,
];

var _skewNeedWarn = true;
var _skewWarn = function (value, node) {
if (value !== 0) {
var nodePath = "";
if (CC_EDITOR) {
var NodeUtils = Editor.require('scene://utils/node');
nodePath = `Node: ${NodeUtils.getNodePath(node)}.`
}
_skewNeedWarn && cc.warn("`cc.Node.skewX/Y` is deprecated since v2.2.1, please use 3D node instead.", nodePath);
!CC_EDITOR && (_skewNeedWarn = false);
}
}

var _currentHovered = null;

var _touchStartHandler = function (touch, event) {
Expand Down Expand Up @@ -996,14 +1009,20 @@ let NodeDefines = {
* @example
* node.skewX = 0;
* cc.log("Node SkewX: " + node.skewX);
* @deprecated since v2.2.1
*/
skewX: {
get () {
return this._skewX;
},
set (value) {
_skewWarn(value, this);

this._skewX = value;
this.setLocalDirty(LocalDirtyFlag.SKEW);
if (CC_JSB && CC_NATIVERENDERER) {
this._proxy.updateSkew();
}
}
},

Expand All @@ -1015,14 +1034,20 @@ let NodeDefines = {
* @example
* node.skewY = 0;
* cc.log("Node SkewY: " + node.skewY);
* @deprecated since v2.2.1
*/
skewY: {
get () {
return this._skewY;
},
set (value) {
_skewWarn(value, this);

this._skewY = value;
this.setLocalDirty(LocalDirtyFlag.SKEW);
if (CC_JSB && CC_NATIVERENDERER) {
this._proxy.updateSkew();
}
}
},

Expand Down Expand Up @@ -1468,6 +1493,13 @@ let NodeDefines = {
this._zIndex = undefined;
}

if (CC_EDITOR) {
if (this._skewX !== 0 || this._skewY !== 0) {
var NodeUtils = Editor.require('scene://utils/node');
cc.warn("`cc.Node.skewX/Y` is deprecated since v2.2.1, please use 3D node instead.", `Node: ${NodeUtils.getNodePath(this)}.`);
}
}

this._fromEuler();

if (this._localZOrder !== 0) {
Expand Down
10 changes: 9 additions & 1 deletion cocos2d/core/utils/trans-pool/node-unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ const Is3D_Stride = Is3D_Members * Uint8_Bytes;
const Node_Type = Uint32Array;
const Node_Members = 2;

// Space : [Skew] [Size:4 * 2 Float32]
const Skew_Type = Float32Array;
const Skew_Members = 2;
const Skew_Stride = Skew_Members * Float32_Bytes;

let UnitBase = require('./unit-base');
let NodeUnit = function (unitID, memPool) {
UnitBase.call(this, unitID, memPool);
Expand All @@ -94,6 +99,7 @@ let NodeUnit = function (unitID, memPool) {
this.opacityList = new Opacity_Type(contentNum * Opacity_Members);
this.is3DList = new Is3D_Type(contentNum * Is3D_Members);
this.nodeList = new Node_Type(contentNum * Node_Members);
this.skewList = new Skew_Type(contentNum * Skew_Members);

this._memPool._nativeMemPool.updateNodeData(
unitID,
Expand All @@ -106,7 +112,8 @@ let NodeUnit = function (unitID, memPool) {
this.cullingMaskList,
this.opacityList,
this.is3DList,
this.nodeList
this.nodeList,
this.skewList
);
}

Expand All @@ -124,6 +131,7 @@ let NodeUnit = function (unitID, memPool) {
space.cullingMask = new CullingMask_Type(this.cullingMaskList.buffer, i * CullingMask_Stride, CullingMask_Members);
space.opacity = new Opacity_Type(this.opacityList.buffer, i * Opacity_Stride, Opacity_Members);
space.is3D = new Is3D_Type(this.is3DList.buffer, i * Is3D_Stride, Is3D_Members);
space.skew = new Skew_Type(this.skewList.buffer, i * Skew_Stride, Skew_Members);
}
}
};
Expand Down