diff --git a/cocos/core/math/deprecated.ts b/cocos/core/math/deprecated.ts index 8eb893d344..a8df123aa1 100644 --- a/cocos/core/math/deprecated.ts +++ b/cocos/core/math/deprecated.ts @@ -24,7 +24,6 @@ deprecatedWrapper({ ['sqrDist', 'squaredDistance'], ['mag', 'len'], ['sqrMag', 'lengthSqr'], - ['divide', 'divideScalar'], ['scale', 'multiplyScalar'], ['exactEquals', 'strictEquals'], ], @@ -40,7 +39,6 @@ deprecatedWrapper({ ['magSqr', 'lengthSqr'], ['exactEquals', 'strictEquals'], ['scale', 'multiplyScalar'], - ['divide', 'divideScalar'], ], }); @@ -57,7 +55,6 @@ deprecatedWrapper({ ['sqrDist', 'squaredDistance'], ['mag', 'len'], ['sqrMag', 'lengthSqr'], - ['divide', 'divideScalar'], ['scale', 'multiplyScalar'], ['exactEquals', 'strictEquals'], ], @@ -73,7 +70,6 @@ deprecatedWrapper({ ['magSqr', 'lengthSqr'], ['exactEquals', 'strictEquals'], ['scale', 'multiplyScalar'], - ['divide', 'divideScalar'], ], }); @@ -90,7 +86,6 @@ deprecatedWrapper({ ['sqrDist', 'squaredDistance'], ['mag', 'len'], ['sqrMag', 'lengthSqr'], - ['divide', 'divideScalar'], ['scale', 'multiplyScalar'], ['exactEquals', 'strictEquals'], ], @@ -106,7 +101,6 @@ deprecatedWrapper({ ['magSqr', 'lengthSqr'], ['exactEquals', 'strictEquals'], ['scale', 'multiplyScalar'], - ['divide', 'divideScalar'], ], }); diff --git a/cocos/core/math/vec2.ts b/cocos/core/math/vec2.ts index d3a79c54ca..4f9e8a7a87 100644 --- a/cocos/core/math/vec2.ts +++ b/cocos/core/math/vec2.ts @@ -102,15 +102,6 @@ export class Vec2 extends ValueType { return out; } - /** - * @zh 逐元素向量除法 - */ - public static divideScalar (out: Out, a: Out, b: Out) { - out.x = a.x / b.x; - out.y = a.y / b.y; - return out; - } - /** * @zh 逐元素向量向上取整 */ @@ -558,16 +549,6 @@ export class Vec2 extends ValueType { return this; } - /** - * 将当前向量的各个分量除以指定标量。相当于 `this.scale(1 / scalar)`。 - * @param scalar 标量除数。 - */ - public divideScalar (scalar: number) { - this.x = this.x / scalar; - this.y = this.y / scalar; - return this; - } - public divide (other: Vec2) { this.x = this.x / other.x; this.y = this.y / other.y; diff --git a/cocos/core/math/vec3.ts b/cocos/core/math/vec3.ts index 65c17e0830..c1db19bf5b 100644 --- a/cocos/core/math/vec3.ts +++ b/cocos/core/math/vec3.ts @@ -117,16 +117,6 @@ export class Vec3 extends ValueType { return out; } - /** - * @zh 逐元素向量除法 - */ - public static divideScalar (out: Out, a: Out, b: Out) { - out.x = a.x / b.x; - out.y = a.y / b.y; - out.z = a.z / b.z; - return out; - } - /** * @zh 逐元素向量向上取整 */ @@ -754,17 +744,6 @@ export class Vec3 extends ValueType { return this; } - /** - * 将当前向量的各个分量除以指定标量。相当于 `this.scale(1 / scalar)`。 - * @param scalar 标量除数。 - */ - public divideScalar (scalar: number) { - this.x = this.x / scalar; - this.y = this.y / scalar; - this.z = this.z / scalar; - return this; - } - public divide (other: Vec3) { this.x = this.x / other.x; this.y = this.y / other.y; diff --git a/cocos/core/math/vec4.ts b/cocos/core/math/vec4.ts index 3f61712394..7b437239b4 100644 --- a/cocos/core/math/vec4.ts +++ b/cocos/core/math/vec4.ts @@ -110,17 +110,6 @@ export class Vec4 extends ValueType { return out; } - /** - * @zh 逐元素向量除法 - */ - public static divideScalar (out: Out, a: Out, b: Out) { - out.x = a.x / b.x; - out.y = a.y / b.y; - out.z = a.z / b.z; - out.w = a.w / b.w; - return out; - } - /** * @zh 逐元素向量向上取整 */ @@ -638,18 +627,6 @@ export class Vec4 extends ValueType { return this; } - /** - * 将当前向量的各个分量除以指定标量。相当于 `this.multiply(1 / scalar, out)`。 - * @param scalar 标量除数。 - */ - public divideScalar (scalar: number) { - this.x = this.x / scalar; - this.y = this.y / scalar; - this.z = this.z / scalar; - this.w = this.w / scalar; - return this; - } - public divide (other: Vec4) { this.x = this.x / other.x; this.y = this.y / other.y; diff --git a/cocos/core/platform/event-manager/CCTouch.ts b/cocos/core/platform/event-manager/CCTouch.ts index bb144f764b..971730359f 100644 --- a/cocos/core/platform/event-manager/CCTouch.ts +++ b/cocos/core/platform/event-manager/CCTouch.ts @@ -193,7 +193,8 @@ export default class Touch { _vec2.set(this._point); _vec2.subtract(this._prevPoint); Vec2.set(out, cc.view.getScaleX(), cc.view.getScaleY()); - Vec2.divideScalar(out, _vec2, out); + out.x = _vec2.x / out.x; + out.y = _vec2.y / out.y; return out; } diff --git a/cocos/scene-graph/node.ts b/cocos/scene-graph/node.ts index ccec3cb347..7d8f692580 100644 --- a/cocos/scene-graph/node.ts +++ b/cocos/scene-graph/node.ts @@ -170,9 +170,13 @@ export class Node extends BaseNode implements INode { parent.updateWorldTransform(); Vec3.subtract(local, this._pos, parent._pos); Vec3.transformQuat(local, local, Quat.conjugate(q_a, parent._rot)); - Vec3.divideScalar(local, local, parent._scale); + local.x /= parent._scale.x; + local.y /= parent._scale.y; + local.z /= parent._scale.z; Quat.multiply(this._lrot, Quat.conjugate(q_a, parent._rot), this._rot); - Vec3.divideScalar(this._lscale, this._scale, parent._scale); + this._lscale.x = this._scale.x / parent._scale.x; + this._lscale.y = this._scale.y / parent._scale.y; + this._lscale.z = this._scale.z / parent._scale.z; } else { Vec3.copy(this._lpos, this._pos); Quat.copy(this._lrot, this._rot); @@ -615,7 +619,9 @@ export class Node extends BaseNode implements INode { parent.updateWorldTransform(); Vec3.subtract(local, this._pos, parent._pos); Vec3.transformQuat(local, local, Quat.conjugate(q_a, parent._rot)); - Vec3.divideScalar(local, local, parent._scale); + local.x /= parent._scale.x; + local.y /= parent._scale.y; + local.z /= parent._scale.z; } else { Vec3.copy(local, this._pos); } @@ -764,7 +770,9 @@ export class Node extends BaseNode implements INode { } if (this._parent) { this._parent.getWorldScale(v3_a); - Vec3.divideScalar(this._lscale, this._scale, v3_a); + this._lscale.x = this._scale.x / v3_a.x; + this._lscale.y = this._scale.y / v3_a.y; + this._lscale.z = this._scale.z / v3_a.z; } else { Vec3.copy(this._lscale, this._scale); }