mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
Merge pull request #2133 from 2youyou2/next
mark node affine transform operation deprecated
This commit is contained in:
+20
-20
@@ -50,6 +50,7 @@ var Event = require('./event/event');
|
||||
var ActionManagerExist = !!cc.ActionManager;
|
||||
var emptyFunc = function () {};
|
||||
var _mat4_temp = math.mat4.create();
|
||||
var _vec3_temp = math.vec3.create();
|
||||
var _trans = affineTrans.make();
|
||||
var _globalOrderOfArrival = 1;
|
||||
|
||||
@@ -1875,7 +1876,14 @@ var Node = cc.Class({
|
||||
out = affineTrans.makeIdentity();
|
||||
}
|
||||
this._updateLocalMatrix();
|
||||
return affineTrans.fromMatrix(this._matrix, out);
|
||||
|
||||
var contentSize = this._contentSize;
|
||||
_vec3_temp.x = -this._anchorPoint.x * contentSize.width;
|
||||
_vec3_temp.y = -this._anchorPoint.y * contentSize.height;
|
||||
|
||||
math.mat4.copy(_mat4_temp, this._matrix);
|
||||
math.mat4.translate(_mat4_temp, _mat4_temp, _vec3_temp);
|
||||
return affineTrans.fromMatrix(_mat4_temp, out);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1899,15 +1907,7 @@ var Node = cc.Class({
|
||||
out = affineTrans.makeIdentity();
|
||||
}
|
||||
this._updateLocalMatrix();
|
||||
|
||||
var contentSize = this._contentSize;
|
||||
// see getNodeToWorldTransform
|
||||
var tx = this._anchorPoint.x * contentSize.x;
|
||||
var ty = this._anchorPoint.y * contentSize.y;
|
||||
|
||||
math.mat4.copy(_mat4_temp, this._matrix);
|
||||
math.mat4.translate(_mat4_temp, tx, ty);
|
||||
return affineTrans.fromMatrix(_mat4_temp, out);
|
||||
return affineTrans.fromMatrix(this._matrix, out);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1925,7 +1925,15 @@ var Node = cc.Class({
|
||||
out = affineTrans.makeIdentity();
|
||||
}
|
||||
this._updateWorldMatrix();
|
||||
return affineTrans.fromMatrix(this._worldMatrix, out);
|
||||
|
||||
var contentSize = this._contentSize;
|
||||
_vec3_temp.x = -this._anchorPoint.x * contentSize.width;
|
||||
_vec3_temp.y = -this._anchorPoint.y * contentSize.height;
|
||||
|
||||
math.mat4.copy(_mat4_temp, this._worldMatrix);
|
||||
math.mat4.translate(_mat4_temp, _mat4_temp, _vec2_temp);
|
||||
|
||||
return affineTrans.fromMatrix(_mat4_temp, out);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1947,15 +1955,7 @@ var Node = cc.Class({
|
||||
out = affineTrans.makeIdentity();
|
||||
}
|
||||
this._updateWorldMatrix();
|
||||
|
||||
var contentSize = this._contentSize;
|
||||
// see getNodeToWorldTransform
|
||||
var tx = this._anchorPoint.x * contentSize.width;
|
||||
var ty = this._anchorPoint.y * contentSize.height;
|
||||
|
||||
math.mat4.copy(_mat4_temp, this._worldMatrix);
|
||||
math.mat4.translate(_mat4_temp, tx, ty);
|
||||
return affineTrans.fromMatrix(_mat4_temp, out);
|
||||
return affineTrans.fromMatrix(this._matrix, out);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,4 +32,6 @@ require('./CCRect');
|
||||
require('./CCColor');
|
||||
require('./CCTypes');
|
||||
require('./CCAffineTransform');
|
||||
require('./CCTypesWebGL');
|
||||
require('./CCTypesWebGL');
|
||||
|
||||
cc.vmath = require('../renderer/render-engine').math;
|
||||
|
||||
+31
-2
@@ -317,6 +317,25 @@ if (CC_DEV) {
|
||||
}
|
||||
}
|
||||
|
||||
function markFunctionWarning (ownerCtor, obj, ownerName) {
|
||||
if (!ownerCtor) {
|
||||
// 可能被裁剪了
|
||||
return;
|
||||
}
|
||||
ownerName = ownerName || js.getClassName(ownerCtor);
|
||||
for (var prop in obj) {
|
||||
var originFunc = ownerCtor[prop];
|
||||
if (!originFunc) return;
|
||||
|
||||
function warn () {
|
||||
cc.warn('Sorry, %s.%s is deprecated. Please use %s instead', ownerName, prop, obj[prop]);
|
||||
return originFunc.apply(this, arguments);
|
||||
}
|
||||
|
||||
ownerCtor[prop] = warn;
|
||||
}
|
||||
}
|
||||
|
||||
// cc.director
|
||||
|
||||
provideClearError(cc.Director.prototype, {
|
||||
@@ -409,8 +428,18 @@ if (CC_DEV) {
|
||||
'setCascadeColorEnabled',
|
||||
'ignoreAnchor',
|
||||
'isIgnoreAnchorPointForPosition',
|
||||
'ignoreAnchorPointForPosition'
|
||||
'ignoreAnchorPointForPosition',
|
||||
]);
|
||||
|
||||
markFunctionWarning(cc.Node.prototype, {
|
||||
'getNodeToParentTransform': 'getLocalMatrix',
|
||||
'getNodeToParentTransformAR': 'getLocalMatrix',
|
||||
'getNodeToWorldTransform': 'getWorldMatrix',
|
||||
'getNodeToWorldTransformAR': 'getWorldMatrix',
|
||||
'getParentToNodeTransform': 'getLocalMatrix',
|
||||
'getWorldToNodeTransform': 'getWorldMatrix',
|
||||
});
|
||||
|
||||
provideClearError(cc.Node.prototype, {
|
||||
arrivalOrder: 'getSiblingIndex, setSiblingIndex',
|
||||
_visible: '_activeInHierarchy, active',
|
||||
@@ -431,7 +460,7 @@ if (CC_DEV) {
|
||||
worldToNodeTransform: 'getWorldToNodeTransform',
|
||||
nodeToParentTransform: 'getNodeToParentTransform',
|
||||
removeAllComponents: 'removeComponent',
|
||||
getNodeToParentAffineTransform: 'getNodeToParentTransform',
|
||||
getNodeToParentAffineTransform: 'getNodeToParentTransform'
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user