新增MathHelper.toInt
This commit is contained in:
@@ -17,7 +17,7 @@ module es {
|
||||
res.range = this._points.length - 4;
|
||||
} else {
|
||||
t = MathHelper.clamp01(t) * this._curveCount;
|
||||
res.range = Math.floor(t);
|
||||
res.range = MathHelper.toInt(t);
|
||||
t -= res.range;
|
||||
res.range *= 3;
|
||||
}
|
||||
|
||||
@@ -471,7 +471,7 @@ module es {
|
||||
}
|
||||
|
||||
public static floorToInt(f: number) {
|
||||
return Math.trunc(Math.floor(f));
|
||||
return this.toInt(Math.floor(f));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -675,5 +675,9 @@ module es {
|
||||
public static fromAngle(angle: number) {
|
||||
return new Vector2(Math.cos(angle), Math.sin(angle)).normalizeEqual();
|
||||
}
|
||||
|
||||
public static toInt(val: number){
|
||||
return val>0 ? Math.floor(val):Math.ceil(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,8 +146,6 @@ module es {
|
||||
* @param layerMask
|
||||
*/
|
||||
public static linecast(start: Vector2, end: Vector2, layerMask: number = this.allLayers, ignoredColliders: Set<Collider> = null): RaycastHit {
|
||||
this._hitArray[0].reset();
|
||||
this.linecastAll(start, end, this._hitArray, layerMask);
|
||||
this._hitArray[0].reset();
|
||||
Physics.linecastAll(
|
||||
start,
|
||||
@@ -156,7 +154,7 @@ module es {
|
||||
layerMask,
|
||||
ignoredColliders
|
||||
);
|
||||
return this._hitArray[0].clone();
|
||||
return this._hitArray[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -183,11 +183,11 @@ module es {
|
||||
|
||||
while (currentCell.x != lastCell.x || currentCell.y != lastCell.y) {
|
||||
if (tMaxX < tMaxY) {
|
||||
currentCell.x = MathHelper.approach(currentCell.x, lastCell.x, Math.abs(stepX));
|
||||
currentCell.x = MathHelper.toInt(MathHelper.approach(currentCell.x, lastCell.x, Math.abs(stepX)));
|
||||
|
||||
tMaxX += tDeltaX;
|
||||
} else {
|
||||
currentCell.y = MathHelper.approach(currentCell.y, lastCell.y, Math.abs(stepY));
|
||||
currentCell.y = MathHelper.toInt(MathHelper.approach(currentCell.y, lastCell.y, Math.abs(stepY)));
|
||||
|
||||
tMaxY += tDeltaY;
|
||||
}
|
||||
@@ -427,7 +427,7 @@ module es {
|
||||
return false;
|
||||
|
||||
// 所有处理单元完成。对结果进行排序并将命中结果打包到结果数组中
|
||||
this._cellHits.sort(RaycastResultParser.compareRaycastHits);
|
||||
this._cellHits = this._cellHits.sort(RaycastResultParser.compareRaycastHits);
|
||||
for (let i = 0; i < this._cellHits.length; i++) {
|
||||
this._hits[this.hitCounter] = this._cellHits[i];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user