Files
PuzGame/src/game/Global.h
2025-02-17 18:25:39 +01:00

81 lines
1.4 KiB
C++

#pragma once
#include "bx/math.h"
struct Vec2
{
float x = 0.0f;
float y = 0.0f;
};
struct Vec3
{
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;
};
struct Vec4
{
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;
float w = 0.0f;
};
struct Mat3
{
// clang-format off
float M[9]{
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f,
};
// clang-format on
};
struct Mat4
{
// clang-format off
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,
};
// clang-format on
};
struct Transform
{
Mat4 M;
Mat4 MI;
bx::Vec3 Position{0.0f, 0.0f, 0.0f};
Mat4 Rotation;
bx::Vec3 Scale{1.0f, 1.0f, 1.0f};
static void CreateTransform(float* out, bx::Vec3 pos, bx::Quaternion rot, bx::Vec3 scale);
void Translate(bx::Vec3 offset);
void TranslateLocal(bx::Vec3 offset);
void Rotate(bx::Vec3 rotation);
void RotateLocal(bx::Vec3 rotation);
bx::Vec3 Right() const;
bx::Vec3 Up() const;
bx::Vec3 Forward() const;
const float* GetPtr();
void UpdateMatrix();
};
struct SharedData;
namespace Game
{
struct GameInstance;
SharedData& GetShared();
void SetShared(SharedData& instance);
GameInstance& GetInstance();
void SetInstance(GameInstance& instance);
void* AllocateScratch(size_t byteCount, size_t align = 16);
} // namespace Game