summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-06-04 03:31:04 +0200
committerSergeanur <s.anureev@yandex.ua>2020-06-04 03:31:04 +0200
commit12717917cc67c7fa854991b606b7ea71499ec602 (patch)
treeebfe654165164acaabdab8871dc3ced6bbef144d /src/core
parentfix accident~ (diff)
downloadre3-12717917cc67c7fa854991b606b7ea71499ec602.tar
re3-12717917cc67c7fa854991b606b7ea71499ec602.tar.gz
re3-12717917cc67c7fa854991b606b7ea71499ec602.tar.bz2
re3-12717917cc67c7fa854991b606b7ea71499ec602.tar.lz
re3-12717917cc67c7fa854991b606b7ea71499ec602.tar.xz
re3-12717917cc67c7fa854991b606b7ea71499ec602.tar.zst
re3-12717917cc67c7fa854991b606b7ea71499ec602.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Range2D.cpp8
-rw-r--r--src/core/Range3D.cpp11
2 files changed, 16 insertions, 3 deletions
diff --git a/src/core/Range2D.cpp b/src/core/Range2D.cpp
index daa36d6a..33eafd0e 100644
--- a/src/core/Range2D.cpp
+++ b/src/core/Range2D.cpp
@@ -18,5 +18,11 @@ CRange2D::DebugShowRange(float, int)
CVector2D
CRange2D::GetRandomPointInRange()
{
- return CVector2D(CGeneral::GetRandomNumberInRange(min.x, max.x), CGeneral::GetRandomNumberInRange(min.y, max.y));
+ int distX = Abs(max.x - min.x);
+ int distY = Abs(max.y - min.y);
+
+ float outX = CGeneral::GetRandomNumber() % distX + min.x;
+ float outY = CGeneral::GetRandomNumber() % distY + min.y;
+
+ return CVector2D(outX, outY);
}
diff --git a/src/core/Range3D.cpp b/src/core/Range3D.cpp
index 14d2dbd2..7fa28d67 100644
--- a/src/core/Range3D.cpp
+++ b/src/core/Range3D.cpp
@@ -18,6 +18,13 @@ CRange3D::DebugShowRange(float, int)
CVector
CRange3D::GetRandomPointInRange()
{
- return CVector(CGeneral::GetRandomNumberInRange(min.x, max.x), CGeneral::GetRandomNumberInRange(min.y, max.y),
- CGeneral::GetRandomNumberInRange(min.z, max.z));
+ int distX = Abs(max.x - min.x);
+ int distY = Abs(max.y - min.y);
+ int distZ = Abs(max.z - min.z);
+
+ float outX = CGeneral::GetRandomNumber() % distX + min.x;
+ float outY = CGeneral::GetRandomNumber() % distY + min.y;
+ float outZ = CGeneral::GetRandomNumber() % distZ + min.z;
+
+ return CVector(outX, outY, outZ);
}