summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-10-17 12:48:08 +0200
committerSergeanur <s.anureev@yandex.ua>2020-10-17 12:48:08 +0200
commit1f36b78c205202b605797e6e29ba045124066705 (patch)
treeccc41513de1253e20379ea8f319d514bd2f59400 /src
parentMerge pull request #767 from theR4K/master (diff)
downloadre3-1f36b78c205202b605797e6e29ba045124066705.tar
re3-1f36b78c205202b605797e6e29ba045124066705.tar.gz
re3-1f36b78c205202b605797e6e29ba045124066705.tar.bz2
re3-1f36b78c205202b605797e6e29ba045124066705.tar.lz
re3-1f36b78c205202b605797e6e29ba045124066705.tar.xz
re3-1f36b78c205202b605797e6e29ba045124066705.tar.zst
re3-1f36b78c205202b605797e6e29ba045124066705.zip
Diffstat (limited to 'src')
-rw-r--r--src/control/Pickups.cpp13
-rw-r--r--src/math/Vector.h8
2 files changed, 14 insertions, 7 deletions
diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp
index 9215b57e..83b31f6b 100644
--- a/src/control/Pickups.cpp
+++ b/src/control/Pickups.cpp
@@ -628,7 +628,7 @@ CPickups::Update()
#ifdef CAMERA_PICKUP
if ( bPickUpcamActivated ) // taken from PS2
{
- float dist = (FindPlayerCoors() - StaticCamCoors).Magnitude2D();
+ float dist = Distance2D(StaticCamCoors, FindPlayerCoors());
float mult;
if ( dist < 10.0f )
mult = 1.0f - (dist / 10.0f );
@@ -644,8 +644,7 @@ CPickups::Update()
TheCamera.TakeControl(FindPlayerVehicle(), CCam::MODE_FIXED, JUMP_CUT, CAMCONTROL_SCRIPT);
}
- if ( FindPlayerVehicle() != pPlayerVehicle
- || (FindPlayerCoors() - StaticCamCoors).Magnitude() > 40.0f
+ if ( FindPlayerVehicle() != pPlayerVehicle || Distance(StaticCamCoors, FindPlayerCoors()) > 40.0f
|| ((CTimer::GetTimeInMilliseconds() - StaticCamStartTime) > 60000) )
{
TheCamera.RestoreWithJumpCut();
@@ -715,7 +714,7 @@ CPickups::DoPickUpEffects(CEntity *entity)
CObject *object = (CObject*)entity;
if (object->bPickupObjWithMessage || object->bOutOfStock || object->m_nBonusValue) {
- float dist = (TheCamera.GetPosition() - pos).Magnitude();
+ float dist = Distance2D(pos, TheCamera.GetPosition());
const float MAXDIST = 12.0f;
if (dist < MAXDIST && NumMessages < NUMPICKUPMESSAGES) {
@@ -746,7 +745,7 @@ void
CPickups::DoMineEffects(CEntity *entity)
{
const CVector &pos = entity->GetPosition();
- float dist = (TheCamera.GetPosition() - pos).Magnitude();
+ float dist = Distance2D(pos, TheCamera.GetPosition());
const float MAXDIST = 20.0f;
if (dist < MAXDIST) {
@@ -765,7 +764,7 @@ void
CPickups::DoMoneyEffects(CEntity *entity)
{
const CVector &pos = entity->GetPosition();
- float dist = (TheCamera.GetPosition() - pos).Magnitude();
+ float dist = Distance2D(pos, TheCamera.GetPosition());
const float MAXDIST = 20.0f;
if (dist < MAXDIST) {
@@ -784,7 +783,7 @@ void
CPickups::DoCollectableEffects(CEntity *entity)
{
const CVector &pos = entity->GetPosition();
- float dist = (TheCamera.GetPosition() - pos).Magnitude();
+ float dist = Distance2D(pos, TheCamera.GetPosition());
const float MAXDIST = 14.0f;
if (dist < MAXDIST) {
diff --git a/src/math/Vector.h b/src/math/Vector.h
index 7ee01149..badc40e3 100644
--- a/src/math/Vector.h
+++ b/src/math/Vector.h
@@ -115,6 +115,14 @@ Distance(const CVector &v1, const CVector &v2)
return (v2 - v1).Magnitude();
}
+inline float
+Distance2D(const CVector &v1, const CVector &v2)
+{
+ float x = v2.x - v1.x;
+ float y = v2.y - v1.y;
+ return Sqrt(sq(x) + sq(y));
+}
+
class CMatrix;
CVector Multiply3x3(const CMatrix &mat, const CVector &vec);