aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
blob: b7630c5ad9e5bb60dccd9be2a4efd7c648d76aa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "gameCommon.h"

#ifndef UTIL_H
#define UTIL_H

// Bit shit.
#define SET_BIT(b, n) (b | (0x1 << n))
#define CLEAR_BIT(b, n) (b & ~(0x1 << n))
#define IS_BIT_SET(b, n) ((b >> n) & 0x1)
#define TOGGLE_BIT(b, n) (b ^ (0x1 << n))
#define HAS_FLAG(v, f) ((v & f) == f)

typedef struct AxisAngle {
	Vector3 axis;
	float angle;
} AxisAngle;

AxisAngle AxisAngleIdentity();

// boring math shit.
float signum(float n);

// Debugging stuff.
void printVector3(Vector3 v);

typedef struct Triangle3D {
    Vector3 v1;
    Vector3 v2;
    Vector3 v3;
} Triangle3D;

// Thank you chatgpt.
bool checkTriangleCollision3D(const Vector3 triangleA[3], const Vector3 triangleB[3], Vector3 normalA, Vector3 normalB);

#endif