修复Vector2.zero引起的引用混乱问题
This commit is contained in:
@@ -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++) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user