#18051: Remove redundant parenthesis

This commit is contained in:
Xavier Cho 2018-04-08 12:39:35 +09:00
parent 93dd59d763
commit 9097c71255
13 changed files with 94 additions and 91 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -145,7 +145,7 @@ namespace Godot
return x % y; 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) 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) 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) 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) 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) 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) public static int NearestPo2(int value)
@ -227,12 +227,12 @@ namespace Godot
public static int Sign(int s) public static int Sign(int s)
{ {
return (s < 0) ? -1 : 1; return s < 0 ? -1 : 1;
} }
public static real_t Sign(real_t s) 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) public static real_t Sin(real_t s)
@ -273,13 +273,13 @@ namespace Godot
public static int Wrap(int value, int min, int max) public static int Wrap(int value, int min, int max)
{ {
int rng = max - min; 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) public static real_t Wrap(real_t value, real_t min, real_t max)
{ {
real_t rng = max - min; 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) if (Mathf.Abs(denom) <= Mathf.Epsilon)
return new Vector3(); return new Vector3();
Vector3 result = (b.normal.Cross(c.normal) * d) + Vector3 result = b.normal.Cross(c.normal) * d +
(c.normal.Cross(normal) * b.d) + c.normal.Cross(normal) * b.d +
(normal.Cross(b.normal) * c.d); normal.Cross(b.normal) * c.d;
return result / denom; return result / denom;
} }
@ -113,7 +113,7 @@ namespace Godot
real_t dist = (normal.Dot(begin) - d) / den; 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 new Vector3();
return begin + segment * -dist; return begin + segment * -dist;

View File

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

View File

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

View File

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

View File

@ -97,9 +97,9 @@ namespace Godot
return new Vector3 return new Vector3
( (
(basis[0, 0] * vInv.x) + (basis[1, 0] * vInv.y) + (basis[2, 0] * 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, 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, 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); real_t dot = v1.Dot(v2);
// Clamp dot to [-1, 1] // 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; Vector2 v;
@ -214,7 +214,7 @@ namespace Godot
Vector2 onY = on.y; Vector2 onY = on.y;
onX.Normalize(); onX.Normalize();
onY = onY - onX * (onX.Dot(onY)); onY = onY - onX * onX.Dot(onY);
onY.Normalize(); onY.Normalize();
on.x = onX; on.x = onX;

View File

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

View File

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