diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2019-06-26 22:34:14 +0200 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2019-06-26 22:34:14 +0200 |
commit | 08b053a568e15dd318dcfc46eaa6393af4a5f8c4 (patch) | |
tree | 7e6a0bc15376f347c13029b99f2f0ec1427bf2c1 /src/Placeable.cpp | |
parent | More replay stuff (diff) | |
parent | bla (diff) | |
download | re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.tar re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.tar.gz re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.tar.bz2 re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.tar.lz re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.tar.xz re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.tar.zst re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.zip |
Diffstat (limited to 'src/Placeable.cpp')
-rw-r--r-- | src/Placeable.cpp | 71 |
1 files changed, 31 insertions, 40 deletions
diff --git a/src/Placeable.cpp b/src/Placeable.cpp index 43708d3e..b4b2a37b 100644 --- a/src/Placeable.cpp +++ b/src/Placeable.cpp @@ -20,56 +20,47 @@ CPlaceable::SetHeading(float angle) bool CPlaceable::IsWithinArea(float x1, float y1, float x2, float y2) { - float x, xmin, xmax; - float y, ymin, ymax; - xmin = x1; - xmax = x2; - ymin = y1; - ymax = y2; - if(x2 > x1){ - xmin = x2; - xmax = x1; + float tmp; + + if(x1 > x2){ + tmp = x1; + x1 = x2; + x2 = tmp; } - if(y2 > y1){ - ymin = y2; - ymax = y1; + if(y1 > y2){ + tmp = y1; + y1 = y2; + y2 = tmp; } - x = GetPosition().x; - y = GetPosition().y; - return xmin <= x && x <= xmax && - ymin <= y && y <= ymax; + + return x1 <= GetPosition().x && GetPosition().x <= x2 && + y1 <= GetPosition().y && GetPosition().y <= y2; } bool CPlaceable::IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2) { - float x, xmin, xmax; - float y, ymin, ymax; - float z, zmin, zmax; - xmin = x1; - xmax = x2; - ymin = y1; - ymax = y2; - zmin = z1; - zmax = z2; - if(x2 > x1){ - xmin = x2; - xmax = x1; + float tmp; + + if(x1 > x2){ + tmp = x1; + x1 = x2; + x2 = tmp; } - if(y2 > y1){ - ymin = y2; - ymax = y1; + if(y1 > y2){ + tmp = y1; + y1 = y2; + y2 = tmp; } - if(z2 > z1){ - zmin = z2; - zmax = z1; + if(z1 > z2){ + tmp = z1; + z1 = z2; + z2 = tmp; } - x = GetPosition().x; - y = GetPosition().y; - z = GetPosition().z; - return xmin <= x && x <= xmax && - ymin <= y && y <= ymax && - zmin <= z && z <= zmax; + + return x1 <= GetPosition().x && GetPosition().x <= x2 && + y1 <= GetPosition().y && GetPosition().y <= y2 && + z1 <= GetPosition().z && GetPosition().z <= z2; } STARTPATCHES |