summaryrefslogtreecommitdiff
path: root/src/engine/CoreMath.h
diff options
context:
space:
mode:
authorMegaMech <7255464+MegaMech@users.noreply.github.com>2025-01-05 12:26:27 -0700
committerMegaMech <7255464+MegaMech@users.noreply.github.com>2025-01-05 12:26:27 -0700
commite993944089e1aa8d967568a84107aa4b9c727228 (patch)
tree0009e5db3d9016ca112cb0445fe15de25efa2f30 /src/engine/CoreMath.h
parent5ee24ab2aaa451442199bceccf519d9bb9e58dcf (diff)
Finishwide screen. Impl IVector2D MinimapDimensions
Diffstat (limited to 'src/engine/CoreMath.h')
-rw-r--r--src/engine/CoreMath.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/engine/CoreMath.h b/src/engine/CoreMath.h
new file mode 100644
index 000000000..551d8083b
--- /dev/null
+++ b/src/engine/CoreMath.h
@@ -0,0 +1,99 @@
+#pragma once
+
+#include <libultraship.h>
+
+/**
+ * @file CoreMath.h
+ *
+ * Basic vector structs for manipulating 2D and 3D coordinates
+ *
+ */
+
+
+struct FVector {
+ float x, y, z;
+
+ FVector& operator=(const FVector& other) {
+ x = other.x;
+ y = other.y;
+ z = other.z;
+ return *this;
+ }
+};
+
+/**
+ * For providing X and Z when you do not need Y
+ * Some actors set themselves on the surface automatically
+ * which means it does not use a Y coordinate
+ * The train follows a set Y value. The hedgehog's patrolPoint only uses X and Z.
+ */
+struct FVector2D {
+ float x, z;
+
+ FVector2D& operator=(const FVector2D& other) {
+ x = other.x;
+ z = other.z;
+ return *this;
+ }
+};
+
+// Sets integer X Z coordinates
+struct IVector2D {
+ int32_t X, Z;
+
+ IVector2D() : X(0), Z(0) {} // Default constructor
+
+ IVector2D(int32_t x, int32_t z) : X(x), Z(z) {} // Constructor to initialize with values
+
+
+ IVector2D& operator=(const IVector2D& other) {
+ X = other.X;
+ Z = other.Z;
+ return *this;
+ }
+};
+
+struct FRotation {
+ float pitch, yaw, roll;
+
+ FRotation& operator=(const FRotation& other) {
+ pitch = other.pitch;
+ yaw = other.yaw;
+ roll = other.roll;
+ return *this;
+ }
+};
+
+/**
+ * For selecting a section of a course path
+ * Usage: IPathSpan(point1, point2) --> IPathSpan(40, 65)
+ */
+struct IPathSpan {
+ int Start, End;
+
+ // Default Constructor
+ IPathSpan() : Start(0), End(0) {}
+
+ // Parameterized Constructor
+ IPathSpan(int InStart, int InEnd)
+ : Start(InStart), End(InEnd) {}
+
+ // Copy Assignment Operator
+ IPathSpan& operator=(const IPathSpan& Other) {
+ if (this != &Other) { // Avoid self-assignment
+ Start = Other.Start;
+ End = Other.End;
+ }
+ return *this;
+ }
+
+ // Equality Operator
+ bool operator==(const IPathSpan& Other) const {
+ return Start == Other.Start && End == Other.End;
+ }
+
+ // Inequality Operator
+ bool operator!=(const IPathSpan& Other) const {
+ return !(*this == Other);
+ }
+};