修复Vector2.zero引起的引用混乱问题

This commit is contained in:
yhh
2020-08-26 19:56:48 +08:00
parent 1997b3f348
commit e81f98ff17
33 changed files with 1663 additions and 4645 deletions

View File

@@ -219,7 +219,7 @@ module es {
let tempMat: Matrix2D;
let combinedMatrix = Matrix2D.create().translate(-this._polygonCenter.x, -this._polygonCenter.y);
if (collider.entity.transform.scale != Vector2.zero) {
if (collider.entity.transform.scale != Vector2.one) {
tempMat = Matrix2D.create().scale(collider.entity.transform.scale.x, collider.entity.transform.scale.y);
combinedMatrix = combinedMatrix.multiply(tempMat);
hasUnitScale = false;
@@ -238,7 +238,7 @@ module es {
let offsetLength = hasUnitScale ? collider._localOffsetLength :
Vector2.multiply(collider.localOffset, collider.entity.transform.scale).length();
this.center = MathHelper.pointOnCirlce(Vector2.zero, offsetLength,
collider.entity.transform.rotation + offsetAngle);
collider.entity.transform.rotationDegrees + offsetAngle);
}
tempMat = Matrix2D.create().translate(this._polygonCenter.x, this._polygonCenter.y);
@@ -256,7 +256,7 @@ module es {
this.position = Vector2.add(collider.entity.transform.position, this.center);
this.bounds = Rectangle.rectEncompassingPoints(this.points);
this.bounds.location = this.bounds.location.add(this.position);
this.bounds.location.add(this.position);
}
public overlaps(other: Shape) {
@@ -304,7 +304,7 @@ module es {
*/
public containsPoint(point: Vector2) {
// 将点归一化到多边形坐标空间中
point = Vector2.subtract(point, this.position);
point.subtract(this.position);
let isInside = false;
for (let i = 0, j = this.points.length - 1; i < this.points.length; j = i++) {

View File

@@ -311,21 +311,16 @@ module es {
return this._store.get(this.getKey(x, y));
}
public getKey(x: number, y: number){
return `${x}_${y}`;
}
/**
* 清除字典数据
*/
public clear() {
this._store.clear();
}
/**
* 根据x和y值计算并返回散列键
* @param x
* @param y
*/
private getKey(x: number, y: number): string {
return Long.fromNumber(x).shiftLeft(32).or(Long.fromNumber(y, true)).toString();
}
}
export class RaycastResultParser {