Files
PuzGame/src/game/Global.h
2025-02-12 01:24:28 +01:00

85 lines
1.2 KiB
C++

#pragma once
#include <bx/math.h>
#include <cstdint>
struct SharedData;
struct IVec2
{
int32_t X = 0;
int32_t Y = 0;
};
struct IVec3
{
int32_t X = 0;
int32_t Y = 0;
};
struct Vec2
{
float X = 0.0f;
float Y = 0.0f;
};
struct Vec3
{
float X = 0.0f;
float Y = 0.0f;
float Z = 0.0f;
bx::Vec3 ToBX()
{
return {X, Y, Z};
};
};
struct Quat
{
float X = 0.0f;
float Y = 0.0f;
float Z = 0.0f;
float W = 1.0f;
static Quat FromEuler(float x, float y, float z);
static Quat FromEuler(Vec3 rot);
};
struct Mat4
{
float M[16]{
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
};
static void CreateTransform(float* out, Vec3 pos, Quat rot = {}, Vec3 scale = {1.0f, 1.0f, 1.0f});
void Translate(Vec3 offset);
Vec3 Right();
Vec3 Up();
Vec3 Forward();
};
namespace Game
{
struct GameInstance;
SharedData& GetShared();
void SetShared(SharedData& instance);
GameInstance& GetInstance();
void SetInstance(GameInstance& instance);
} // namespace Game