2020-11-08 16:37:59 +01:00
|
|
|
#pragma once
|
|
|
|
|
2021-01-06 15:06:13 +01:00
|
|
|
class TBall;
|
|
|
|
|
2020-11-21 16:14:40 +01:00
|
|
|
struct vector_type
|
|
|
|
{
|
|
|
|
float X;
|
|
|
|
float Y;
|
2020-11-28 12:39:12 +01:00
|
|
|
float Z;
|
2020-11-21 16:14:40 +01:00
|
|
|
};
|
|
|
|
|
2020-11-08 16:37:59 +01:00
|
|
|
|
2021-01-29 14:42:05 +01:00
|
|
|
struct rectangle_type
|
2020-11-08 16:37:59 +01:00
|
|
|
{
|
|
|
|
int XPosition;
|
|
|
|
int YPosition;
|
|
|
|
int Width;
|
|
|
|
int Height;
|
|
|
|
};
|
|
|
|
|
2020-11-21 16:14:40 +01:00
|
|
|
struct circle_type
|
|
|
|
{
|
2020-12-27 16:19:36 +01:00
|
|
|
vector_type Center;
|
2020-11-21 16:14:40 +01:00
|
|
|
float RadiusSq;
|
|
|
|
};
|
|
|
|
|
2021-01-29 14:42:05 +01:00
|
|
|
struct ray_type
|
2020-11-21 16:14:40 +01:00
|
|
|
{
|
|
|
|
vector_type Origin;
|
|
|
|
vector_type Direction;
|
|
|
|
float MaxDistance;
|
2020-11-28 12:39:12 +01:00
|
|
|
float MinDistance;
|
2021-01-06 15:06:13 +01:00
|
|
|
float TimeNow;
|
|
|
|
float TimeDelta;
|
2021-01-07 17:00:38 +01:00
|
|
|
int FieldFlag;
|
2020-11-21 16:14:40 +01:00
|
|
|
};
|
|
|
|
|
2021-01-29 14:42:05 +01:00
|
|
|
struct line_type
|
2020-11-21 16:14:40 +01:00
|
|
|
{
|
|
|
|
vector_type PerpendicularL;
|
|
|
|
vector_type Direction;
|
|
|
|
float PreComp1;
|
2020-11-28 12:39:12 +01:00
|
|
|
float OriginX;
|
|
|
|
float OriginY;
|
2021-01-08 16:50:12 +01:00
|
|
|
vector_type RayIntersect;
|
2020-11-21 16:14:40 +01:00
|
|
|
};
|
|
|
|
|
2021-01-18 16:30:19 +01:00
|
|
|
struct vector_type2
|
|
|
|
{
|
2021-01-19 16:28:48 +01:00
|
|
|
float X;
|
|
|
|
float Y;
|
2021-01-18 16:30:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wall_point_type
|
|
|
|
{
|
|
|
|
float X0;
|
|
|
|
float Y0;
|
|
|
|
float X1;
|
|
|
|
float Y1;
|
|
|
|
};
|
|
|
|
|
2021-01-29 14:42:05 +01:00
|
|
|
struct ramp_plane_type
|
2021-01-18 16:30:19 +01:00
|
|
|
{
|
2021-01-19 16:28:48 +01:00
|
|
|
vector_type BallCollisionOffset;
|
2021-01-18 16:30:19 +01:00
|
|
|
vector_type2 V1;
|
|
|
|
vector_type2 V2;
|
|
|
|
vector_type2 V3;
|
|
|
|
float GravityAngle1;
|
|
|
|
float GravityAngle2;
|
2021-01-19 16:28:48 +01:00
|
|
|
vector_type2 FieldForce;
|
2021-01-18 16:30:19 +01:00
|
|
|
};
|
|
|
|
|
2020-11-21 16:14:40 +01:00
|
|
|
|
2020-11-08 16:37:59 +01:00
|
|
|
class maths
|
|
|
|
{
|
|
|
|
public:
|
2020-11-15 15:39:00 +01:00
|
|
|
static void enclosing_box(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
|
|
|
|
static int rectangle_clip(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
|
|
|
|
static int overlapping_box(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
|
2020-11-21 16:14:40 +01:00
|
|
|
static float ray_intersect_circle(ray_type* ray, circle_type* circle);
|
|
|
|
static float normalize_2d(vector_type* vec);
|
|
|
|
static void line_init(line_type* line, float x0, float y0, float x1, float y1);
|
|
|
|
static float ray_intersect_line(ray_type* ray, line_type* line);
|
2020-11-28 12:39:12 +01:00
|
|
|
static void cross(vector_type* vec1, vector_type* vec2, vector_type* dstVec);
|
2020-11-29 16:50:49 +01:00
|
|
|
static float magnitude(vector_type* vec);
|
2020-12-27 16:19:36 +01:00
|
|
|
static void vector_add(vector_type* vec1Dst, vector_type* vec2);
|
2021-01-29 14:42:05 +01:00
|
|
|
static float basic_collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float elasticity,
|
|
|
|
float smoothness,
|
2021-01-23 11:33:30 +01:00
|
|
|
float threshold, float boost);
|
2021-01-08 16:50:12 +01:00
|
|
|
static float Distance_Squared(vector_type vec1, vector_type vec2);
|
2021-01-09 17:11:03 +01:00
|
|
|
static float DotProduct(vector_type* vec1, vector_type* vec2);
|
|
|
|
static void vswap(vector_type* vec1, vector_type* vec2);
|
|
|
|
static float Distance(vector_type* vec1, vector_type* vec2);
|
|
|
|
static void SinCos(float angle, float* sinOut, float* cosOut);
|
|
|
|
static void RotatePt(vector_type* point, float sin, float cos, vector_type* origin);
|
|
|
|
static float distance_to_flipper(ray_type* ray1, ray_type* ray2);
|
2021-01-17 16:26:03 +01:00
|
|
|
static void RotateVector(vector_type* vec, float angle);
|
2021-01-18 16:30:19 +01:00
|
|
|
static void find_closest_edge(ramp_plane_type* plane, int planeCount, wall_point_type* wall, vector_type** lineEnd,
|
|
|
|
vector_type** lineStart);
|
2020-11-08 16:37:59 +01:00
|
|
|
};
|