#18051: Remove redundant parenthesis

(cherry picked from commit 9097c71255)
This commit is contained in:
Xavier Cho 2018-04-08 12:39:35 +09:00 committed by Hein-Pieter van Braam
parent 58f2953ddf
commit 57f18194f5
13 changed files with 94 additions and 91 deletions

View file

@ -49,12 +49,12 @@ namespace Godot
Vector3 dst_min = with.position;
Vector3 dst_max = with.position + with.size;
return ((src_min.x <= dst_min.x) &&
(src_max.x > dst_max.x) &&
(src_min.y <= dst_min.y) &&
(src_max.y > dst_max.y) &&
(src_min.z <= dst_min.z) &&
(src_max.z > dst_max.z));
return src_min.x <= dst_min.x &&
src_max.x > dst_max.x &&
src_min.y <= dst_min.y &&
src_max.y > dst_max.y &&
src_min.z <= dst_min.z &&
src_max.z > dst_max.z;
}
public AABB Expand(Vector3 to_point)
@ -217,9 +217,9 @@ namespace Godot
Vector3 ofs = position + half_extents;
return ofs + new Vector3(
(dir.x > 0f) ? -half_extents.x : half_extents.x,
(dir.y > 0f) ? -half_extents.y : half_extents.y,
(dir.z > 0f) ? -half_extents.z : half_extents.z);
dir.x > 0f ? -half_extents.x : half_extents.x,
dir.y > 0f ? -half_extents.y : half_extents.y,
dir.z > 0f ? -half_extents.z : half_extents.z);
}
public AABB Grow(real_t by)
@ -278,41 +278,41 @@ namespace Godot
return new AABB();
}
min.x = (src_min.x > dst_min.x) ? src_min.x : dst_min.x;
max.x = (src_max.x < dst_max.x) ? src_max.x : dst_max.x;
min.x = src_min.x > dst_min.x ? src_min.x : dst_min.x;
max.x = src_max.x < dst_max.x ? src_max.x : dst_max.x;
if (src_min.y > dst_max.y || src_max.y < dst_min.y)
{
return new AABB();
}
min.y = (src_min.y > dst_min.y) ? src_min.y : dst_min.y;
max.y = (src_max.y < dst_max.y) ? src_max.y : dst_max.y;
min.y = src_min.y > dst_min.y ? src_min.y : dst_min.y;
max.y = src_max.y < dst_max.y ? src_max.y : dst_max.y;
if (src_min.z > dst_max.z || src_max.z < dst_min.z)
{
return new AABB();
}
min.z = (src_min.z > dst_min.z) ? src_min.z : dst_min.z;
max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z;
min.z = src_min.z > dst_min.z ? src_min.z : dst_min.z;
max.z = src_max.z < dst_max.z ? src_max.z : dst_max.z;
return new AABB(min, max - min);
}
public bool Intersects(AABB with)
{
if (position.x >= (with.position.x + with.size.x))
if (position.x >= with.position.x + with.size.x)
return false;
if ((position.x + size.x) <= with.position.x)
if (position.x + size.x <= with.position.x)
return false;
if (position.y >= (with.position.y + with.size.y))
if (position.y >= with.position.y + with.size.y)
return false;
if ((position.y + size.y) <= with.position.y)
if (position.y + size.y <= with.position.y)
return false;
if (position.z >= (with.position.z + with.size.z))
if (position.z >= with.position.z + with.size.z)
return false;
if ((position.z + size.z) <= with.position.z)
if (position.z + size.z <= with.position.z)
return false;
return true;
@ -400,15 +400,15 @@ namespace Godot
var end_2 = new Vector3(with.size.x, with.size.y, with.size.z) + beg_2;
var min = new Vector3(
(beg_1.x < beg_2.x) ? beg_1.x : beg_2.x,
(beg_1.y < beg_2.y) ? beg_1.y : beg_2.y,
(beg_1.z < beg_2.z) ? beg_1.z : beg_2.z
beg_1.x < beg_2.x ? beg_1.x : beg_2.x,
beg_1.y < beg_2.y ? beg_1.y : beg_2.y,
beg_1.z < beg_2.z ? beg_1.z : beg_2.z
);
var max = new Vector3(
(end_1.x > end_2.x) ? end_1.x : end_2.x,
(end_1.y > end_2.y) ? end_1.y : end_2.y,
(end_1.z > end_2.z) ? end_1.z : end_2.z
end_1.x > end_2.x ? end_1.x : end_2.x,
end_1.y > end_2.y ? end_1.y : end_2.y,
end_1.z > end_2.z ? end_1.z : end_2.z
);
return new AABB(min, max - min);

View file

@ -296,9 +296,9 @@ namespace Godot
Vector3 zAxis = GetAxis(2);
xAxis.Normalize();
yAxis = (yAxis - xAxis * (xAxis.Dot(yAxis)));
yAxis = yAxis - xAxis * xAxis.Dot(yAxis);
yAxis.Normalize();
zAxis = (zAxis - xAxis * (xAxis.Dot(zAxis)) - yAxis * (yAxis.Dot(zAxis)));
zAxis = zAxis - xAxis * xAxis.Dot(zAxis) - yAxis * yAxis.Dot(zAxis);
zAxis.Normalize();
return CreateFromAxes(xAxis, yAxis, zAxis);
@ -374,9 +374,9 @@ namespace Godot
{
return new Vector3
(
(this[0, 0] * v.x) + (this[1, 0] * v.y) + (this[2, 0] * v.z),
(this[0, 1] * v.x) + (this[1, 1] * v.y) + (this[2, 1] * v.z),
(this[0, 2] * v.x) + (this[1, 2] * v.y) + (this[2, 2] * v.z)
this[0, 0] * v.x + this[1, 0] * v.y + this[2, 0] * v.z,
this[0, 1] * v.x + this[1, 1] * v.y + this[2, 1] * v.z,
this[0, 2] * v.x + this[1, 2] * v.y + this[2, 2] * v.z
);
}

View file

@ -180,7 +180,7 @@ namespace Godot
hue += 1.0f;
}
saturation = (max == 0) ? 0 : 1f - (1f * min / max);
saturation = max == 0 ? 0 : 1f - 1f * min / max;
value = max / 255f;
}
@ -267,10 +267,10 @@ namespace Godot
{
var res = this;
res.r += (t * (b.r - r));
res.g += (t * (b.g - g));
res.b += (t * (b.b - this.b));
res.a += (t * (b.a - a));
res.r += t * (b.r - r);
res.g += t * (b.g - g);
res.b += t * (b.b - this.b);
res.a += t * (b.a - a);
return res;
}
@ -511,8 +511,8 @@ namespace Godot
if (left.g == right.g)
{
if (left.b == right.b)
return (left.a < right.a);
return (left.b < right.b);
return left.a < right.a;
return left.b < right.b;
}
return left.g < right.g;
@ -528,8 +528,8 @@ namespace Godot
if (left.g == right.g)
{
if (left.b == right.b)
return (left.a > right.a);
return (left.b > right.b);
return left.a > right.a;
return left.b > right.b;
}
return left.g > right.g;

View file

@ -127,9 +127,9 @@ namespace Godot
int count;
if (increment > 0)
count = ((to - from - 1) / increment) + 1;
count = (to - @from - 1) / increment + 1;
else
count = ((from - to - 1) / -increment) + 1;
count = (@from - to - 1) / -increment + 1;
var ret = new int[count];

View file

@ -145,7 +145,7 @@ namespace Godot
return x % y;
}
return y - (-x % y);
return y - -x % y;
}
public static real_t InverseLerp(real_t from, real_t to, real_t weight)
@ -175,22 +175,22 @@ namespace Godot
public static int Max(int a, int b)
{
return (a > b) ? a : b;
return a > b ? a : b;
}
public static real_t Max(real_t a, real_t b)
{
return (a > b) ? a : b;
return a > b ? a : b;
}
public static int Min(int a, int b)
{
return (a < b) ? a : b;
return a < b ? a : b;
}
public static real_t Min(real_t a, real_t b)
{
return (a < b) ? a : b;
return a < b ? a : b;
}
public static int NearestPo2(int value)
@ -232,12 +232,12 @@ namespace Godot
public static int Sign(int s)
{
return (s < 0) ? -1 : 1;
return s < 0 ? -1 : 1;
}
public static real_t Sign(real_t s)
{
return (s < 0f) ? -1f : 1f;
return s < 0f ? -1f : 1f;
}
public static real_t Sin(real_t s)
@ -278,13 +278,13 @@ namespace Godot
public static int Wrap(int value, int min, int max)
{
int rng = max - min;
return min + ((((value - min) % rng) + rng) % rng);
return min + ((value - min) % rng + rng) % rng;
}
public static real_t Wrap(real_t value, real_t min, real_t max)
{
real_t rng = max - min;
return min + ((((value - min) % rng) + rng) % rng);
return min + ((value - min) % rng + rng) % rng;
}
}
}

View file

@ -80,9 +80,9 @@ namespace Godot
if (Mathf.Abs(denom) <= Mathf.Epsilon)
return new Vector3();
Vector3 result = (b.normal.Cross(c.normal) * d) +
(c.normal.Cross(normal) * b.d) +
(normal.Cross(b.normal) * c.d);
Vector3 result = b.normal.Cross(c.normal) * d +
c.normal.Cross(normal) * b.d +
normal.Cross(b.normal) * c.d;
return result / denom;
}
@ -113,7 +113,7 @@ namespace Godot
real_t dist = (normal.Dot(begin) - d) / den;
if (dist < -Mathf.Epsilon || dist > (1.0f + Mathf.Epsilon))
if (dist < -Mathf.Epsilon || dist > 1.0f + Mathf.Epsilon)
return new Vector3();
return begin + segment * -dist;

View file

@ -137,7 +137,7 @@ namespace Godot
real_t sinom, scale0, scale1;
// Calculate coefficients
if ((1.0 - cosom) > Mathf.Epsilon)
if (1.0 - cosom > Mathf.Epsilon)
{
// Standard case (Slerp)
real_t omega = Mathf.Acos(cosom);

View file

@ -57,9 +57,9 @@ namespace Godot
public bool Encloses(Rect2 b)
{
return (b.position.x >= position.x) && (b.position.y >= position.y) &&
((b.position.x + b.size.x) < (position.x + size.x)) &&
((b.position.y + b.size.y) < (position.y + size.y));
return b.position.x >= position.x && b.position.y >= position.y &&
b.position.x + b.size.x < position.x + size.x &&
b.position.y + b.size.y < position.y + size.y;
}
public Rect2 Expand(Vector2 to)
@ -118,10 +118,10 @@ namespace Godot
{
var g = this;
g.GrowIndividual((Margin.Left == margin) ? by : 0,
(Margin.Top == margin) ? by : 0,
(Margin.Right == margin) ? by : 0,
(Margin.Bottom == margin) ? by : 0);
g.GrowIndividual(Margin.Left == margin ? by : 0,
Margin.Top == margin ? by : 0,
Margin.Right == margin ? by : 0,
Margin.Bottom == margin ? by : 0);
return g;
}
@ -138,9 +138,9 @@ namespace Godot
if (point.y < position.y)
return false;
if (point.x >= (position.x + size.x))
if (point.x >= position.x + size.x)
return false;
if (point.y >= (position.y + size.y))
if (point.y >= position.y + size.y)
return false;
return true;
@ -148,13 +148,13 @@ namespace Godot
public bool Intersects(Rect2 b)
{
if (position.x > (b.position.x + b.size.x))
if (position.x > b.position.x + b.size.x)
return false;
if ((position.x + size.x) < b.position.x)
if (position.x + size.x < b.position.x)
return false;
if (position.y > (b.position.y + b.size.y))
if (position.y > b.position.y + b.size.y)
return false;
if ((position.y + size.y) < b.position.y)
if (position.y + size.y < b.position.y)
return false;
return true;

View file

@ -312,7 +312,7 @@ namespace Godot
int c;
while ((c = instance[index++]) != 0)
hashv = ((hashv << 5) + hashv) + c; // hash * 33 + c
hashv = (hashv << 5) + hashv + c; // hash * 33 + c
return hashv;
}
@ -454,7 +454,10 @@ namespace Godot
return false; // Don't start with number plz
}
bool valid_char = (instance[i] >= '0' && instance[i] <= '9') || (instance[i] >= 'a' && instance[i] <= 'z') || (instance[i] >= 'A' && instance[i] <= 'Z') || instance[i] == '_';
bool valid_char = instance[i] >= '0' &&
instance[i] <= '9' || instance[i] >= 'a' &&
instance[i] <= 'z' || instance[i] >= 'A' &&
instance[i] <= 'Z' || instance[i] == '_';
if (!valid_char)
return false;
@ -550,7 +553,7 @@ namespace Godot
case '\0':
return instance[0] == 0;
case '*':
return ExprMatch(expr + 1, instance, caseSensitive) || (instance[0] != 0 && ExprMatch(expr, instance + 1, caseSensitive));
return ExprMatch(expr + 1, instance, caseSensitive) || instance[0] != 0 && ExprMatch(expr, instance + 1, caseSensitive);
case '?':
return instance[0] != 0 && instance[0] != '.' && ExprMatch(expr + 1, instance + 1, caseSensitive);
default:
@ -769,7 +772,7 @@ namespace Godot
if (pos < 0)
return string.Empty;
return instance.Substring(pos, (instance.Length - pos));
return instance.Substring(pos, instance.Length - pos);
}
public static byte[] Sha256Buffer(this string instance)
@ -822,7 +825,7 @@ namespace Godot
}
}
return (2.0f * inter) / sum;
return 2.0f * inter / sum;
}
// <summary>
@ -847,7 +850,7 @@ namespace Godot
int end = instance.Find(divisor, from);
if (end < 0)
end = len;
if (allow_empty || (end > from))
if (allow_empty || end > @from)
ret.Add(float.Parse(instance.Substring(from)));
if (end == len)
break;

View file

@ -97,9 +97,9 @@ namespace Godot
return new Vector3
(
(basis[0, 0] * vInv.x) + (basis[1, 0] * vInv.y) + (basis[2, 0] * vInv.z),
(basis[0, 1] * vInv.x) + (basis[1, 1] * vInv.y) + (basis[2, 1] * vInv.z),
(basis[0, 2] * vInv.x) + (basis[1, 2] * vInv.y) + (basis[2, 2] * vInv.z)
basis[0, 0] * vInv.x + basis[1, 0] * vInv.y + basis[2, 0] * vInv.z,
basis[0, 1] * vInv.x + basis[1, 1] * vInv.y + basis[2, 1] * vInv.z,
basis[0, 2] * vInv.x + basis[1, 2] * vInv.y + basis[2, 2] * vInv.z
);
}

View file

@ -163,7 +163,7 @@ namespace Godot
real_t dot = v1.Dot(v2);
// Clamp dot to [-1, 1]
dot = (dot < -1.0f) ? -1.0f : ((dot > 1.0f) ? 1.0f : dot);
dot = dot < -1.0f ? -1.0f : (dot > 1.0f ? 1.0f : dot);
Vector2 v;
@ -214,7 +214,7 @@ namespace Godot
Vector2 onY = on.y;
onX.Normalize();
onY = onY - onX * (onX.Dot(onY));
onY = onY - onX * onX.Dot(onY);
onY.Normalize();
on.x = onX;

View file

@ -121,7 +121,7 @@ namespace Godot
real_t t2 = t * t;
real_t t3 = t2 * t;
return 0.5f * ((p1 * 2.0f) +
return 0.5f * (p1 * 2.0f +
(-p0 + p2) * t +
(2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 +
(-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
@ -166,8 +166,8 @@ namespace Godot
{
var res = this;
res.x += (t * (b.x - x));
res.y += (t * (b.y - y));
res.x += t * (b.x - x);
res.y += t * (b.y - y);
return res;
}

View file

@ -103,9 +103,9 @@ namespace Godot
{
return new Vector3
(
(y * b.z) - (z * b.y),
(z * b.x) - (x * b.z),
(x * b.y) - (y * b.x)
y * b.z - z * b.y,
z * b.x - x * b.z,
x * b.y - y * b.x
);
}
@ -120,7 +120,7 @@ namespace Godot
real_t t3 = t2 * t;
return 0.5f * (
(p1 * 2.0f) + (-p0 + p2) * t +
p1 * 2.0f + (-p0 + p2) * t +
(2.0f * p0 - 5.0f * p1 + 4f * p2 - p3) * t2 +
(-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3
);
@ -178,9 +178,9 @@ namespace Godot
{
return new Vector3
(
x + (t * (b.x - x)),
y + (t * (b.y - y)),
z + (t * (b.z - z))
x + t * (b.x - x),
y + t * (b.y - y),
z + t * (b.z - z)
);
}