summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorerorcun <erayorcunus@gmail.com>2020-06-14 21:59:02 +0200
committerGitHub <noreply@github.com>2020-06-14 21:59:02 +0200
commitf64d3ad7de85bfd2f3e9aac4530f1e255b542295 (patch)
tree8d0c6b4e752fcfaf4d2d0237bed786c2de9e7e84 /src/core
parentMerge pull request #625 from aap/miami (diff)
parentPeds, mission switcher & fixes (diff)
downloadre3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.tar
re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.tar.gz
re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.tar.bz2
re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.tar.lz
re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.tar.xz
re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.tar.zst
re3-f64d3ad7de85bfd2f3e9aac4530f1e255b542295.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Collision.cpp15
-rw-r--r--src/core/Collision.h1
-rw-r--r--src/core/General.h12
-rw-r--r--src/core/config.h3
-rw-r--r--src/core/re3.cpp15
5 files changed, 43 insertions, 3 deletions
diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp
index b68214af..77e28a10 100644
--- a/src/core/Collision.cpp
+++ b/src/core/Collision.cpp
@@ -1801,6 +1801,21 @@ CColSphere::Set(float radius, const CVector &center, uint8 surf, uint8 piece)
this->piece = piece;
}
+bool
+CColSphere::IntersectRay(CVector const& from, CVector const& dir, CVector &entry, CVector &exit)
+{
+ CVector distToCenter = from - center;
+ float distToTouchSqr = distToCenter.MagnitudeSqr() - sq(radius);
+ float root1, root2;
+
+ if (!CGeneral::SolveQuadratic(1.0f, DotProduct(distToCenter, dir) * 2.f, distToTouchSqr, root1, root2))
+ return false;
+
+ entry = from + dir * root1;
+ exit = from + dir * root2;
+ return true;
+}
+
void
CColBox::Set(const CVector &min, const CVector &max, uint8 surf, uint8 piece)
{
diff --git a/src/core/Collision.h b/src/core/Collision.h
index 12af5225..9f08ccd6 100644
--- a/src/core/Collision.h
+++ b/src/core/Collision.h
@@ -31,6 +31,7 @@ struct CColSphere : public CSphere
uint8 piece;
void Set(float radius, const CVector &center, uint8 surf, uint8 piece);
+ bool IntersectRay(CVector const &from, CVector const &dir, CVector &entry, CVector &exit);
using CSphere::Set;
};
diff --git a/src/core/General.h b/src/core/General.h
index 3188d82b..dbf169e9 100644
--- a/src/core/General.h
+++ b/src/core/General.h
@@ -134,6 +134,18 @@ public:
return *str2 != '\0';
}
+ static bool SolveQuadratic(float a, float b, float c, float &root1, float &root2)
+ {
+ float discriminant = b * b - 4.f * a * c;
+ if (discriminant < 0.f)
+ return false;
+
+ float discriminantSqrt = Sqrt(discriminant);
+ root2 = (-b + discriminantSqrt) / (2.f * a);
+ root1 = (-b - discriminantSqrt) / (2.f * a);
+ return true;
+ }
+
// not too sure about all these...
static uint16 GetRandomNumber(void)
{ return myrand() & MYRAND_MAX; }
diff --git a/src/core/config.h b/src/core/config.h
index e23b0a90..ad5c0064 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -202,12 +202,11 @@ enum Config {
#define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible
#define FIX_HIGH_FPS_BUGS_ON_FRONTEND
-// Rendering/display
-#define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios
// Just debug menu entries
#ifdef DEBUGMENU
#define TOGGLEABLE_BETA_FEATURES // not too many things
#define RELOADABLES // some debug menu options to reload TXD files
+#define MISSION_SWITCHER // from debug menu
#endif
// Rendering/display
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index 13db1f6a..76865339 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -31,6 +31,7 @@
#include "Text.h"
#include "WaterLevel.h"
#include "main.h"
+#include "Script.h"
#ifndef _WIN32
#include "assert.h"
@@ -309,6 +310,15 @@ ResetCamStatics(void)
TheCamera.Cams[TheCamera.ActiveCam].ResetStatics = true;
}
+#ifdef MISSION_SWITCHER
+int8 nextMissionToSwitch = 0;
+static void
+SwitchToMission(void)
+{
+ switchMissionTo = nextMissionToSwitch;
+}
+#endif
+
static const char *carnames[] = {
"landstal", "idaho", "stinger", "linerun", "peren", "sentinel", "rio", "firetruk", "trash", "stretch", "manana",
"infernus", "voodoo", "pony", "mule", "cheetah", "ambulan", "fbicar", "moonbeam", "esperant", "taxi", "washing",
@@ -512,7 +522,10 @@ DebugMenuPopulate(void)
#ifdef TIMEBARS
DebugMenuAddVarBool8("Debug", "Show Timebars", &gbShowTimebars, nil);
#endif
-
+#ifdef MISSION_SWITCHER
+ DebugMenuAddInt8("Debug", "Select mission no", &nextMissionToSwitch, nil, 1, 0, 96, nil);
+ DebugMenuAddCmd("Debug", "Start selected mission ", SwitchToMission);
+#endif
extern bool PrintDebugCode;
extern int16 DebugCamMode;
DebugMenuAddVarBool8("Cam", "Use mouse Cam", &CCamera::m_bUseMouse3rdPerson, nil);