move vec to generated
This commit is contained in:
@@ -6,12 +6,52 @@
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
using namespace Generated;
|
||||
|
||||
namespace
|
||||
{
|
||||
SharedData* SharedInstance = nullptr;
|
||||
Game::GameInstance* GameInst = nullptr;
|
||||
} // namespace
|
||||
|
||||
namespace Game
|
||||
{
|
||||
SharedData& GetShared()
|
||||
{
|
||||
assert(SharedInstance != nullptr);
|
||||
return *SharedInstance;
|
||||
}
|
||||
|
||||
void SetShared(SharedData& instance)
|
||||
{
|
||||
SharedInstance = &instance;
|
||||
}
|
||||
|
||||
GameInstance& GetInstance()
|
||||
{
|
||||
assert(GameInst != nullptr);
|
||||
return *GameInst;
|
||||
}
|
||||
|
||||
void SetInstance(Game::GameInstance& instance)
|
||||
{
|
||||
GameInst = &instance;
|
||||
}
|
||||
|
||||
void* AllocateScratch(size_t byteCount, size_t align)
|
||||
{
|
||||
size_t offset = GetInstance().UsedScratchAmount;
|
||||
uint8_t* base = static_cast<uint8_t*>(GetShared().Game.TransientStorage);
|
||||
uint8_t* current = base + offset;
|
||||
size_t offsetAligned = ((offset + align - 1) / align) * align;
|
||||
uint8_t* ptrAligned = base + offsetAligned;
|
||||
size_t newOffset = offsetAligned + byteCount;
|
||||
if (newOffset > GetShared().Game.TransientStorageSize) return nullptr;
|
||||
GetInstance().UsedScratchAmount = newOffset;
|
||||
return reinterpret_cast<void*>(ptrAligned);
|
||||
}
|
||||
} // namespace Game
|
||||
|
||||
void Transform::CreateTransform(float* out, bx::Vec3 pos, bx::Quaternion rot, bx::Vec3 scale)
|
||||
{
|
||||
if (out == nullptr) return;
|
||||
@@ -82,49 +122,12 @@ void Transform::UpdateMatrix()
|
||||
bx::mtxInverse(MI.M, M.M);
|
||||
}
|
||||
|
||||
namespace Game
|
||||
{
|
||||
SharedData& GetShared()
|
||||
{
|
||||
assert(SharedInstance != nullptr);
|
||||
return *SharedInstance;
|
||||
}
|
||||
|
||||
void SetShared(SharedData& instance)
|
||||
{
|
||||
SharedInstance = &instance;
|
||||
}
|
||||
|
||||
GameInstance& GetInstance()
|
||||
{
|
||||
assert(GameInst != nullptr);
|
||||
return *GameInst;
|
||||
}
|
||||
|
||||
void SetInstance(Game::GameInstance& instance)
|
||||
{
|
||||
GameInst = &instance;
|
||||
}
|
||||
|
||||
void* AllocateScratch(size_t byteCount, size_t align)
|
||||
{
|
||||
size_t offset = GetInstance().UsedScratchAmount;
|
||||
uint8_t* base = static_cast<uint8_t*>(GetShared().Game.TransientStorage);
|
||||
uint8_t* current = base + offset;
|
||||
size_t offsetAligned = ((offset + align - 1) / align) * align;
|
||||
uint8_t* ptrAligned = base + offsetAligned;
|
||||
size_t newOffset = offsetAligned + byteCount;
|
||||
if (newOffset > GetShared().Game.TransientStorageSize) return nullptr;
|
||||
GetInstance().UsedScratchAmount = newOffset;
|
||||
return reinterpret_cast<void*>(ptrAligned);
|
||||
}
|
||||
} // namespace Game
|
||||
Vec3 Transform::GlobalToLocalDirection(Vec3 global)
|
||||
{
|
||||
UpdateMatrix();
|
||||
float in[4]{global.x, global.y, global.z, 0.0f};
|
||||
float out[4]{0.0f};
|
||||
bx::vec4MulMtx(out, in, MI.Transpose().M);
|
||||
bx::vec4MulMtx(out, in, Transpose(MI).M);
|
||||
return {out[0], out[1], out[2]};
|
||||
}
|
||||
Vec3 Transform::GlobalToLocalPoint(Vec3 global)
|
||||
@@ -140,7 +143,7 @@ Vec3 Transform::LocalToGlobalDirection(Vec3 local)
|
||||
UpdateMatrix();
|
||||
float in[4]{local.x, local.y, local.z, 0.0f};
|
||||
float out[4]{0.0f};
|
||||
bx::vec4MulMtx(out, in, M.Transpose().M);
|
||||
bx::vec4MulMtx(out, in, Transpose(M).M);
|
||||
return {out[0], out[1], out[2]};
|
||||
}
|
||||
Vec3 Transform::LocalToGlobalPoint(Vec3 local)
|
||||
@@ -159,24 +162,286 @@ Vec3 Transform::GetPosition()
|
||||
{
|
||||
return {Position.x, Position.y, Position.z};
|
||||
}
|
||||
Mat4 Mat4::Inverse()
|
||||
|
||||
// Vec4
|
||||
Vec4& operator+=(Vec4& lhs, const Vec4& rhs)
|
||||
{
|
||||
lhs.x += rhs.x;
|
||||
lhs.y += rhs.y;
|
||||
lhs.z += rhs.z;
|
||||
lhs.w += rhs.w;
|
||||
return lhs;
|
||||
}
|
||||
Vec4 operator+(const Vec4& lhs, const Vec4& rhs)
|
||||
{
|
||||
Vec4 out = lhs;
|
||||
return out += rhs;
|
||||
}
|
||||
Vec4& operator+=(Vec4& lhs, float rhs)
|
||||
{
|
||||
lhs.x += rhs;
|
||||
lhs.y += rhs;
|
||||
lhs.z += rhs;
|
||||
lhs.w += rhs;
|
||||
return lhs;
|
||||
}
|
||||
Vec4 operator+(Vec4& lhs, float rhs)
|
||||
{
|
||||
Vec4 out = lhs;
|
||||
return out += rhs;
|
||||
}
|
||||
|
||||
Vec4& operator-=(Vec4& lhs, const Vec4& rhs)
|
||||
{
|
||||
lhs.x -= rhs.x;
|
||||
lhs.y -= rhs.y;
|
||||
lhs.z -= rhs.z;
|
||||
lhs.w -= rhs.w;
|
||||
return lhs;
|
||||
}
|
||||
Vec4 operator-(const Vec4& lhs, const Vec4& rhs)
|
||||
{
|
||||
Vec4 out = lhs;
|
||||
return out -= rhs;
|
||||
}
|
||||
Vec4& operator-=(Vec4& lhs, float rhs)
|
||||
{
|
||||
lhs.x -= rhs;
|
||||
lhs.y -= rhs;
|
||||
lhs.z -= rhs;
|
||||
lhs.w -= rhs;
|
||||
return lhs;
|
||||
}
|
||||
Vec4 operator-(const Vec4& lhs, float rhs)
|
||||
{
|
||||
Vec4 out = lhs;
|
||||
return out -= rhs;
|
||||
}
|
||||
|
||||
Vec4& operator*=(Vec4& lhs, float rhs)
|
||||
{
|
||||
lhs.x *= rhs;
|
||||
lhs.y *= rhs;
|
||||
lhs.z *= rhs;
|
||||
lhs.w *= rhs;
|
||||
return lhs;
|
||||
}
|
||||
Vec4 operator*(const Vec4& lhs, float rhs)
|
||||
{
|
||||
Vec4 out = lhs;
|
||||
return out *= rhs;
|
||||
}
|
||||
|
||||
Vec4& operator/=(Vec4& lhs, float rhs)
|
||||
{
|
||||
lhs.x /= rhs;
|
||||
lhs.y /= rhs;
|
||||
lhs.z /= rhs;
|
||||
lhs.w /= rhs;
|
||||
return lhs;
|
||||
}
|
||||
Vec4 operator/(const Vec4& lhs, float rhs)
|
||||
{
|
||||
Vec4 out = lhs;
|
||||
return out /= rhs;
|
||||
}
|
||||
|
||||
// Vec3
|
||||
Vec3& operator+=(Vec3& lhs, const Vec3& rhs)
|
||||
{
|
||||
lhs.x += rhs.x;
|
||||
lhs.y += rhs.y;
|
||||
lhs.z += rhs.z;
|
||||
return lhs;
|
||||
}
|
||||
Vec3 operator+(const Vec3& lhs, const Vec3& rhs)
|
||||
{
|
||||
Vec3 out = lhs;
|
||||
return out += rhs;
|
||||
}
|
||||
Vec3& operator+=(Vec3& lhs, float rhs)
|
||||
{
|
||||
lhs.x += rhs;
|
||||
lhs.y += rhs;
|
||||
lhs.z += rhs;
|
||||
return lhs;
|
||||
}
|
||||
Vec3 operator+(Vec3& lhs, float rhs)
|
||||
{
|
||||
Vec3 out = lhs;
|
||||
return out += rhs;
|
||||
}
|
||||
|
||||
Vec3& operator-=(Vec3& lhs, const Vec3& rhs)
|
||||
{
|
||||
lhs.x -= rhs.x;
|
||||
lhs.y -= rhs.y;
|
||||
lhs.z -= rhs.z;
|
||||
return lhs;
|
||||
}
|
||||
Vec3 operator-(const Vec3& lhs, const Vec3& rhs)
|
||||
{
|
||||
Vec3 out = lhs;
|
||||
return out -= rhs;
|
||||
}
|
||||
Vec3& operator-=(Vec3& lhs, float rhs)
|
||||
{
|
||||
lhs.x -= rhs;
|
||||
lhs.y -= rhs;
|
||||
lhs.z -= rhs;
|
||||
return lhs;
|
||||
}
|
||||
Vec3 operator-(const Vec3& lhs, float rhs)
|
||||
{
|
||||
Vec3 out = lhs;
|
||||
return out -= rhs;
|
||||
}
|
||||
|
||||
Vec3& operator*=(Vec3& lhs, float rhs)
|
||||
{
|
||||
lhs.x *= rhs;
|
||||
lhs.y *= rhs;
|
||||
lhs.z *= rhs;
|
||||
return lhs;
|
||||
}
|
||||
Vec3 operator*(const Vec3& lhs, float rhs)
|
||||
{
|
||||
Vec3 out = lhs;
|
||||
return out *= rhs;
|
||||
}
|
||||
|
||||
Vec3& operator/=(Vec3& lhs, float rhs)
|
||||
{
|
||||
lhs.x /= rhs;
|
||||
lhs.y /= rhs;
|
||||
lhs.z /= rhs;
|
||||
return lhs;
|
||||
}
|
||||
Vec3 operator/(const Vec3& lhs, float rhs)
|
||||
{
|
||||
Vec3 out = lhs;
|
||||
return out /= rhs;
|
||||
}
|
||||
|
||||
// Vec2
|
||||
Vec2& operator+=(Vec2& lhs, const Vec2& rhs)
|
||||
{
|
||||
lhs.x += rhs.x;
|
||||
lhs.y += rhs.y;
|
||||
return lhs;
|
||||
}
|
||||
Vec2 operator+(const Vec2& lhs, const Vec2& rhs)
|
||||
{
|
||||
Vec2 out = lhs;
|
||||
return out += rhs;
|
||||
}
|
||||
Vec2& operator+=(Vec2& lhs, float rhs)
|
||||
{
|
||||
lhs.x += rhs;
|
||||
lhs.y += rhs;
|
||||
return lhs;
|
||||
}
|
||||
Vec2 operator+(Vec2& lhs, float rhs)
|
||||
{
|
||||
Vec2 out = lhs;
|
||||
return out += rhs;
|
||||
}
|
||||
|
||||
Vec2& operator-=(Vec2& lhs, const Vec2& rhs)
|
||||
{
|
||||
lhs.x -= rhs.x;
|
||||
lhs.y -= rhs.y;
|
||||
return lhs;
|
||||
}
|
||||
Vec2 operator-(const Vec2& lhs, const Vec2& rhs)
|
||||
{
|
||||
Vec2 out = lhs;
|
||||
return out -= rhs;
|
||||
}
|
||||
Vec2& operator-=(Vec2& lhs, float rhs)
|
||||
{
|
||||
lhs.x -= rhs;
|
||||
lhs.y -= rhs;
|
||||
return lhs;
|
||||
}
|
||||
Vec2 operator-(const Vec2& lhs, float rhs)
|
||||
{
|
||||
Vec2 out = lhs;
|
||||
return out -= rhs;
|
||||
}
|
||||
|
||||
Vec2& operator*=(Vec2& lhs, float rhs)
|
||||
{
|
||||
lhs.x *= rhs;
|
||||
lhs.y *= rhs;
|
||||
return lhs;
|
||||
}
|
||||
Vec2 operator*(const Vec2& lhs, float rhs)
|
||||
{
|
||||
Vec2 out = lhs;
|
||||
return out *= rhs;
|
||||
}
|
||||
|
||||
Vec2& operator/=(Vec2& lhs, float rhs)
|
||||
{
|
||||
lhs.x /= rhs;
|
||||
lhs.y /= rhs;
|
||||
return lhs;
|
||||
}
|
||||
Vec2 operator/(const Vec2& lhs, float rhs)
|
||||
{
|
||||
Vec2 out = lhs;
|
||||
return out /= rhs;
|
||||
}
|
||||
|
||||
Mat4 Inverse(const Mat4& mat)
|
||||
{
|
||||
Mat4 result;
|
||||
bx::mtxInverse(result.M, M);
|
||||
bx::mtxInverse(result.M, &mat.M[0]);
|
||||
return result;
|
||||
}
|
||||
Mat4 Mat4::Transpose()
|
||||
Mat4 Transpose(const Mat4& mat)
|
||||
{
|
||||
Mat4 result;
|
||||
bx::mtxTranspose(result.M, M);
|
||||
bx::mtxTranspose(result.M, &mat.M[0]);
|
||||
return result;
|
||||
}
|
||||
Vec4 Mat4::Mul(const Vec4& vec)
|
||||
Vec4 Mul(const Mat4& mat, const Vec4& vec)
|
||||
{
|
||||
Vec4 out;
|
||||
bx::vec4MulMtx(&out.x, &vec.x, &M[0]);
|
||||
bx::vec4MulMtx(&out.x, &vec.x, &mat.M[0]);
|
||||
return out;
|
||||
}
|
||||
|
||||
float Magnitude(const Vec4& vec)
|
||||
{
|
||||
return bx::sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z + vec.w * vec.w);
|
||||
}
|
||||
float Magnitude(const Vec3& vec)
|
||||
{
|
||||
return bx::sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z);
|
||||
}
|
||||
float Magnitude(const Vec2& vec)
|
||||
{
|
||||
return bx::sqrt(vec.x * vec.x + vec.y * vec.y);
|
||||
}
|
||||
|
||||
Vec4 Normalized(const Vec4& vec)
|
||||
{
|
||||
Vec4 res = vec;
|
||||
return res /= Magnitude(vec);
|
||||
}
|
||||
Vec3 Normalized(const Vec3& vec)
|
||||
{
|
||||
Vec3 res = vec;
|
||||
return res /= Magnitude(vec);
|
||||
}
|
||||
Vec2 Normalized(const Vec2& vec)
|
||||
{
|
||||
Vec2 res = vec;
|
||||
return res /= Magnitude(vec);
|
||||
}
|
||||
|
||||
float DotProduct(Vec3 a, Vec3 b)
|
||||
{
|
||||
return a.x * b.x + a.y * b.y + a.z * b.z;
|
||||
@@ -191,8 +456,8 @@ Vec3 CrossProduct(Vec3 a, Vec3 b)
|
||||
Vec3 CrossProductFromPlane(Vec3 a, Vec3 b, Vec3 c)
|
||||
{
|
||||
// TODO: normalize might not be necessary
|
||||
Vec3 lineA = (b - a).Normalize();
|
||||
Vec3 lineB = (c - a).Normalize();
|
||||
Vec3 lineA = Normalized(b - a);
|
||||
Vec3 lineB = Normalized(c - a);
|
||||
return CrossProduct(lineA, lineB);
|
||||
}
|
||||
bool RayPlaneIntersect(Vec3 l1, Vec3 l2, Vec3 p1, Vec3 p2, Vec3 p3, Vec3& out)
|
||||
|
||||
@@ -1,214 +1,215 @@
|
||||
#pragma once
|
||||
|
||||
#include "Gen.h"
|
||||
#include "bx/math.h"
|
||||
#include <cfloat>
|
||||
|
||||
struct Vec2
|
||||
{
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
using namespace Generated;
|
||||
// struct Vec2
|
||||
// {
|
||||
// float x = 0.0f;
|
||||
// float y = 0.0f;
|
||||
|
||||
Vec2& operator+=(const Vec2& rhs)
|
||||
{
|
||||
x += rhs.x;
|
||||
y += rhs.y;
|
||||
return *this;
|
||||
}
|
||||
// Vec2& operator+=(const Vec2& rhs)
|
||||
// {
|
||||
// x += rhs.x;
|
||||
// y += rhs.y;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
friend Vec2 operator+(Vec2 lhs, const Vec2& rhs)
|
||||
{
|
||||
lhs += rhs;
|
||||
return lhs;
|
||||
}
|
||||
// friend Vec2 operator+(Vec2 lhs, const Vec2& rhs)
|
||||
// {
|
||||
// lhs += rhs;
|
||||
// return lhs;
|
||||
// }
|
||||
|
||||
Vec2& operator+=(const float& rhs)
|
||||
{
|
||||
x += rhs;
|
||||
y += rhs;
|
||||
return *this;
|
||||
}
|
||||
// Vec2& operator+=(const float& rhs)
|
||||
// {
|
||||
// x += rhs;
|
||||
// y += rhs;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
friend Vec2 operator+(Vec2 lhs, const float& rhs)
|
||||
{
|
||||
lhs += rhs;
|
||||
return lhs;
|
||||
}
|
||||
// friend Vec2 operator+(Vec2 lhs, const float& rhs)
|
||||
// {
|
||||
// lhs += rhs;
|
||||
// return lhs;
|
||||
// }
|
||||
|
||||
Vec2& operator-=(const Vec2& rhs)
|
||||
{
|
||||
x -= rhs.x;
|
||||
y -= rhs.y;
|
||||
return *this;
|
||||
}
|
||||
// Vec2& operator-=(const Vec2& rhs)
|
||||
// {
|
||||
// x -= rhs.x;
|
||||
// y -= rhs.y;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
friend Vec2 operator-(Vec2 lhs, const Vec2& rhs)
|
||||
{
|
||||
lhs -= rhs;
|
||||
return lhs;
|
||||
}
|
||||
// friend Vec2 operator-(Vec2 lhs, const Vec2& rhs)
|
||||
// {
|
||||
// lhs -= rhs;
|
||||
// return lhs;
|
||||
// }
|
||||
|
||||
Vec2& operator-=(const float& rhs)
|
||||
{
|
||||
x -= rhs;
|
||||
y -= rhs;
|
||||
return *this;
|
||||
}
|
||||
// Vec2& operator-=(const float& rhs)
|
||||
// {
|
||||
// x -= rhs;
|
||||
// y -= rhs;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
friend Vec2 operator-(Vec2 lhs, const float& rhs)
|
||||
{
|
||||
lhs -= rhs;
|
||||
return lhs;
|
||||
}
|
||||
// friend Vec2 operator-(Vec2 lhs, const float& rhs)
|
||||
// {
|
||||
// lhs -= rhs;
|
||||
// return lhs;
|
||||
// }
|
||||
|
||||
Vec2& operator*=(const float rhs)
|
||||
{
|
||||
x *= rhs;
|
||||
y *= rhs;
|
||||
return *this;
|
||||
}
|
||||
// Vec2& operator*=(const float rhs)
|
||||
// {
|
||||
// x *= rhs;
|
||||
// y *= rhs;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
friend Vec2 operator*(Vec2 lhs, const float rhs)
|
||||
{
|
||||
lhs *= rhs;
|
||||
return lhs;
|
||||
}
|
||||
// friend Vec2 operator*(Vec2 lhs, const float rhs)
|
||||
// {
|
||||
// lhs *= rhs;
|
||||
// return lhs;
|
||||
// }
|
||||
|
||||
Vec2& operator/=(const float rhs)
|
||||
{
|
||||
x /= rhs;
|
||||
y /= rhs;
|
||||
return *this;
|
||||
}
|
||||
// Vec2& operator/=(const float rhs)
|
||||
// {
|
||||
// x /= rhs;
|
||||
// y /= rhs;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
friend Vec2 operator/(Vec2 lhs, const float rhs)
|
||||
{
|
||||
lhs /= rhs;
|
||||
return lhs;
|
||||
}
|
||||
// friend Vec2 operator/(Vec2 lhs, const float rhs)
|
||||
// {
|
||||
// lhs /= rhs;
|
||||
// return lhs;
|
||||
// }
|
||||
|
||||
float Magnitude()
|
||||
{
|
||||
return bx::sqrt(x * x + y * y);
|
||||
}
|
||||
// float Magnitude()
|
||||
// {
|
||||
// return bx::sqrt(x * x + y * y);
|
||||
// }
|
||||
|
||||
Vec2 Normalize()
|
||||
{
|
||||
float mag = Magnitude();
|
||||
if (mag < FLT_EPSILON) return {};
|
||||
return {x / mag, y / mag};
|
||||
}
|
||||
};
|
||||
// Vec2 Normalize()
|
||||
// {
|
||||
// float mag = Magnitude();
|
||||
// if (mag < FLT_EPSILON) return {};
|
||||
// return {x / mag, y / mag};
|
||||
// }
|
||||
// };
|
||||
|
||||
struct Vec3
|
||||
{
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
float z = 0.0f;
|
||||
// struct Vec3
|
||||
// {
|
||||
// float x = 0.0f;
|
||||
// float y = 0.0f;
|
||||
// float z = 0.0f;
|
||||
|
||||
Vec3& operator+=(const Vec3& rhs)
|
||||
{
|
||||
x += rhs.x;
|
||||
y += rhs.y;
|
||||
z += rhs.z;
|
||||
return *this;
|
||||
}
|
||||
// Vec3& operator+=(const Vec3& rhs)
|
||||
// {
|
||||
// x += rhs.x;
|
||||
// y += rhs.y;
|
||||
// z += rhs.z;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
friend Vec3 operator+(Vec3 lhs, const Vec3& rhs)
|
||||
{
|
||||
lhs += rhs;
|
||||
return lhs;
|
||||
}
|
||||
// friend Vec3 operator+(Vec3 lhs, const Vec3& rhs)
|
||||
// {
|
||||
// lhs += rhs;
|
||||
// return lhs;
|
||||
// }
|
||||
|
||||
Vec3& operator-=(const Vec3& rhs)
|
||||
{
|
||||
x -= rhs.x;
|
||||
y -= rhs.y;
|
||||
z -= rhs.z;
|
||||
return *this;
|
||||
}
|
||||
// Vec3& operator-=(const Vec3& rhs)
|
||||
// {
|
||||
// x -= rhs.x;
|
||||
// y -= rhs.y;
|
||||
// z -= rhs.z;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
friend Vec3 operator-(Vec3 lhs, const Vec3& rhs)
|
||||
{
|
||||
lhs -= rhs;
|
||||
return lhs;
|
||||
}
|
||||
// friend Vec3 operator-(Vec3 lhs, const Vec3& rhs)
|
||||
// {
|
||||
// lhs -= rhs;
|
||||
// return lhs;
|
||||
// }
|
||||
|
||||
Vec3& operator*=(const float rhs)
|
||||
{
|
||||
x *= rhs;
|
||||
y *= rhs;
|
||||
z *= rhs;
|
||||
return *this;
|
||||
}
|
||||
// Vec3& operator*=(const float rhs)
|
||||
// {
|
||||
// x *= rhs;
|
||||
// y *= rhs;
|
||||
// z *= rhs;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
friend Vec3 operator*(Vec3 lhs, const float rhs)
|
||||
{
|
||||
lhs *= rhs;
|
||||
return lhs;
|
||||
}
|
||||
// friend Vec3 operator*(Vec3 lhs, const float rhs)
|
||||
// {
|
||||
// lhs *= rhs;
|
||||
// return lhs;
|
||||
// }
|
||||
|
||||
Vec3& operator/=(const float rhs)
|
||||
{
|
||||
x /= rhs;
|
||||
y /= rhs;
|
||||
z /= rhs;
|
||||
return *this;
|
||||
}
|
||||
// Vec3& operator/=(const float rhs)
|
||||
// {
|
||||
// x /= rhs;
|
||||
// y /= rhs;
|
||||
// z /= rhs;
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
friend Vec3 operator/(Vec3 lhs, const float rhs)
|
||||
{
|
||||
lhs /= rhs;
|
||||
return lhs;
|
||||
}
|
||||
// friend Vec3 operator/(Vec3 lhs, const float rhs)
|
||||
// {
|
||||
// lhs /= rhs;
|
||||
// return lhs;
|
||||
// }
|
||||
|
||||
float Magnitude()
|
||||
{
|
||||
return bx::sqrt(x * x + y * y + z * z);
|
||||
}
|
||||
// float Magnitude()
|
||||
// {
|
||||
// return bx::sqrt(x * x + y * y + z * z);
|
||||
// }
|
||||
|
||||
Vec3 Normalize()
|
||||
{
|
||||
float mag = Magnitude();
|
||||
if (mag < FLT_EPSILON) return {};
|
||||
return {x / mag, y / mag, z / mag};
|
||||
}
|
||||
};
|
||||
// Vec3 Normalize()
|
||||
// {
|
||||
// float mag = Magnitude();
|
||||
// if (mag < FLT_EPSILON) return {};
|
||||
// return {x / mag, y / mag, z / mag};
|
||||
// }
|
||||
// };
|
||||
|
||||
struct Vec4
|
||||
{
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
float z = 0.0f;
|
||||
float w = 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 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
|
||||
|
||||
Mat4 Inverse();
|
||||
Mat4 Transpose();
|
||||
Vec4 Mul(const Vec4& vec);
|
||||
};
|
||||
// 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
|
||||
|
||||
// Mat4 Inverse();
|
||||
// Mat4 Transpose();
|
||||
// Vec4 Mul(const Vec4& vec);
|
||||
// };
|
||||
//
|
||||
inline int32_t SetFlags(int32_t in, int32_t flags)
|
||||
{
|
||||
return in | flags;
|
||||
@@ -257,6 +258,67 @@ struct Transform
|
||||
void UpdateMatrixForCam();
|
||||
};
|
||||
|
||||
Vec4& operator+=(Vec4& lhs, const Vec4& rhs);
|
||||
Vec4 operator+(const Vec4& lhs, const Vec4& rhs);
|
||||
Vec4& operator+=(Vec4& lhs, float rhs);
|
||||
Vec4 operator+(Vec4& lhs, float rhs);
|
||||
|
||||
Vec4& operator-=(Vec4& lhs, const Vec4& rhs);
|
||||
Vec4 operator-(const Vec4& lhs, const Vec4& rhs);
|
||||
Vec4& operator-=(Vec4& lhs, float rhs);
|
||||
Vec4 operator-(const Vec4& lhs, float rhs);
|
||||
|
||||
Vec4& operator*=(Vec4& lhs, float rhs);
|
||||
Vec4 operator*(const Vec4& lhs, float rhs);
|
||||
|
||||
Vec4& operator/=(Vec4& lhs, float rhs);
|
||||
Vec4 operator/(const Vec4& lhs, float rhs);
|
||||
|
||||
Vec3& operator+=(Vec3& lhs, const Vec3& rhs);
|
||||
Vec3 operator+(const Vec3& lhs, const Vec3& rhs);
|
||||
Vec3& operator+=(Vec3& lhs, float rhs);
|
||||
Vec3 operator+(Vec3& lhs, float rhs);
|
||||
|
||||
Vec3& operator-=(Vec3& lhs, const Vec3& rhs);
|
||||
Vec3 operator-(const Vec3& lhs, const Vec3& rhs);
|
||||
Vec3& operator-=(Vec3& lhs, float rhs);
|
||||
Vec3 operator-(const Vec3& lhs, float rhs);
|
||||
|
||||
Vec3& operator*=(Vec3& lhs, float rhs);
|
||||
Vec3 operator*(const Vec3& lhs, float rhs);
|
||||
|
||||
Vec3& operator/=(Vec3& lhs, float rhs);
|
||||
Vec3 operator/(const Vec3& lhs, float rhs);
|
||||
|
||||
Vec2& operator+=(Vec2& lhs, const Vec2& rhs);
|
||||
Vec2 operator+(const Vec2& lhs, const Vec2& rhs);
|
||||
Vec2& operator+=(Vec2& lhs, float rhs);
|
||||
Vec2 operator+(Vec2& lhs, float rhs);
|
||||
|
||||
Vec2& operator-=(Vec2& lhs, const Vec2& rhs);
|
||||
Vec2 operator-(const Vec2& lhs, const Vec2& rhs);
|
||||
Vec2& operator-=(Vec2& lhs, float rhs);
|
||||
Vec2 operator-(const Vec2& lhs, float rhs);
|
||||
|
||||
Vec2& operator*=(Vec2& lhs, float rhs);
|
||||
Vec2 operator*(const Vec2& lhs, float rhs);
|
||||
|
||||
Vec2& operator/=(Vec2& lhs, float rhs);
|
||||
Vec2 operator/(const Vec2& lhs, float rhs);
|
||||
|
||||
float Magnitude(const Vec4& vec);
|
||||
float Magnitude(const Vec3& vec);
|
||||
float Magnitude(const Vec2& vec);
|
||||
|
||||
Vec4 Normalized(const Vec4& vec);
|
||||
Vec3 Normalized(const Vec3& vec);
|
||||
Vec2 Normalized(const Vec2& vec);
|
||||
|
||||
Mat4 Inverse(const Mat4& mat);
|
||||
Mat4 Transpose(const Mat4& mat);
|
||||
Vec4 Mul(const Mat4& mat, const Vec4& vec);
|
||||
|
||||
float DotProduct(Vec3 a, Vec3 b);
|
||||
Vec3 CrossProduct(Vec3 a, Vec3 b);
|
||||
Vec3 CrossProductFromPlane(Vec3 a, Vec3 b, Vec3 c);
|
||||
bool RayPlaneIntersect(Vec3 l1, Vec3 l2, Vec3 p1, Vec3 p2, Vec3 p3, Vec3& out);
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include <cstdint>
|
||||
#include <tracy/Tracy.hpp>
|
||||
|
||||
using namespace Generated;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
void EntityRenderData::Render(const Model* models, const Material* materials, const Texture* textures)
|
||||
@@ -66,7 +68,7 @@ namespace Game
|
||||
bgfx::setTexture(1, rendering.DitherTextures.DitherSampler, rendering.DitherTextures.FinalTex);
|
||||
bgfx::setTexture(2, rendering.DitherTextures.RampSampler, rendering.DitherTextures.RampTex);
|
||||
bgfx::setUniform(currentMaterial.Uniforms[Material::UTime], timeValues);
|
||||
bgfx::setUniform(currentMaterial.Uniforms[Material::UDotColor], &TestColor.x);
|
||||
bgfx::setUniform(currentMaterial.Uniforms[Material::UDotColor], &DotColor.x);
|
||||
bgfx::setUniform(currentMaterial.Uniforms[Material::UTexInfo], texInfo);
|
||||
bgfx::setUniform(currentMaterial.Uniforms[Material::UBaseColor], &BaseColor.x);
|
||||
|
||||
@@ -154,10 +156,6 @@ namespace Game
|
||||
Cubes.Get(PlayerOutsideViewCube).Setup();
|
||||
}
|
||||
|
||||
if (Tests.Count == 0)
|
||||
{
|
||||
Tests.Get(Tests.New()).Setup();
|
||||
}
|
||||
UIQuads.Count = 0;
|
||||
PuzzleTiles.Count = 0;
|
||||
for (int32_t i = 0; i < BX_COUNTOF(Puzzles); ++i)
|
||||
@@ -343,7 +341,7 @@ namespace Game
|
||||
mousePos *= 2.0f;
|
||||
mousePos -= 1.0f;
|
||||
Vec4 mousePosView = {mousePos.x, -mousePos.y, 0.0f, 1.0f};
|
||||
Vec4 mousePosCam4 = GetInstance().Player.ProjectionInverse.Mul(mousePosView);
|
||||
Vec4 mousePosCam4 = Mul(GetInstance().Player.ProjectionInverse, mousePosView);
|
||||
Vec3 mousePosCam = Vec3{
|
||||
mousePosCam4.x /= mousePosCam4.w,
|
||||
mousePosCam4.y /= mousePosCam4.w,
|
||||
@@ -381,12 +379,13 @@ namespace Game
|
||||
quad.EData.Visible = isValid;
|
||||
quad.EData.TextureHandle =
|
||||
isValid ? staticCards[card.RefCard.Idx].BoardTextureHandle : Generated::TextureHandle{};
|
||||
quad.EData.DotColor = card.IsLocked ? Vec4{0.0f, 0.0f, 0.0f, 0.0f} : Vec4{1.0f, 1.0f, 1.0f, 1.0f};
|
||||
|
||||
quad.EData.Transform = boardTransform;
|
||||
quad.EData.Transform.TranslateLocal(Vec3{(float)card.Position.X, (float)card.Position.Y, 0.0f} *
|
||||
UICardOffset);
|
||||
quad.EData.Transform.Scale = {0.1f, 0.1f, 0.1f};
|
||||
quad.EData.Transform.Rotate(Vec3{bx::kPi * 0.5f, 0.0f, (1.0f + card.Rotation * 0.5f) * bx::kPi});
|
||||
quad.EData.Transform.Rotate(Vec3{bx::kPi * 0.5f, 0.0f, (1.0f - card.Rotation * 0.5f) * bx::kPi});
|
||||
|
||||
Vec3 quadPosWorld = quad.EData.Transform.GetPosition();
|
||||
Vec3 quadXWorld = quad.EData.Transform.LocalToGlobalPoint({1, 0, 0});
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Game
|
||||
{
|
||||
struct EntityRenderData
|
||||
{
|
||||
Vec4 TestColor{1.0f, 1.0f, 1.0f, 1.0f};
|
||||
Vec4 DotColor{1.0f, 1.0f, 1.0f, 1.0f};
|
||||
Vec4 BaseColor{0.0f, 0.0f, 0.0f, 1.0f};
|
||||
Transform Transform;
|
||||
EMaterial MaterialHandle = EMaterial::UNDEFINED;
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#include "Global.h"
|
||||
#include "Instance.h"
|
||||
#include "Mesh.h"
|
||||
#include "Puzzle.h"
|
||||
#include "Tools.h"
|
||||
#include "bx/timer.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <tracy/Tracy.hpp>
|
||||
|
||||
using namespace Generated;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr int32_t FrameTimeBufSize = 512;
|
||||
@@ -193,20 +196,21 @@ namespace Tools
|
||||
Vec3 quadPos = level.UIQuads.Get({0}).EData.Transform.GetPosition();
|
||||
ImGui::Text("%f %f %f", quadPos.x, quadPos.y, quadPos.z);
|
||||
|
||||
if (ImGui::ColorEdit3("Base Color", &rendering.DefaultBaseColor.x))
|
||||
auto& puzzleVisuals = Puzzle::GetStaticPuzzleData().Visuals;
|
||||
if (ImGui::ColorEdit3("Tile Base Color", &puzzleVisuals.TileBaseColor.x))
|
||||
{
|
||||
auto& tiles = level.PuzzleTiles;
|
||||
for (int32_t i = 0; i < tiles.Count; ++i)
|
||||
{
|
||||
tiles.Data[i].EData.BaseColor = rendering.DefaultBaseColor;
|
||||
tiles.Data[i].EData.BaseColor = puzzleVisuals.TileBaseColor;
|
||||
}
|
||||
}
|
||||
if (ImGui::ColorEdit3("Dot Color", &rendering.DefaultTileColor.x))
|
||||
if (ImGui::ColorEdit3("Tile Dot Color", &puzzleVisuals.TileDotColor.x))
|
||||
{
|
||||
auto& tiles = level.PuzzleTiles;
|
||||
for (int32_t i = 0; i < tiles.Count; ++i)
|
||||
{
|
||||
tiles.Data[i].EData.TestColor = rendering.DefaultTileColor;
|
||||
tiles.Data[i].EData.DotColor = puzzleVisuals.TileDotColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,22 +1,22 @@
|
||||
type Vec2
|
||||
{
|
||||
f32 X
|
||||
f32 Y
|
||||
f32 x
|
||||
f32 y
|
||||
}
|
||||
|
||||
type Vec3
|
||||
{
|
||||
f32 X
|
||||
f32 Y
|
||||
f32 Z
|
||||
f32 x
|
||||
f32 y
|
||||
f32 z
|
||||
}
|
||||
|
||||
type Vec4
|
||||
{
|
||||
f32 X
|
||||
f32 Y
|
||||
f32 Z
|
||||
f32 W
|
||||
f32 x
|
||||
f32 y
|
||||
f32 z
|
||||
f32 w
|
||||
}
|
||||
|
||||
type Mat3
|
||||
@@ -85,9 +85,17 @@ type StaticPuzzleCardHandle
|
||||
u16 Idx Default("UINT16_MAX")
|
||||
}
|
||||
|
||||
type PuzzleVisualSettings
|
||||
{
|
||||
Vec4 TileBaseColor
|
||||
Vec4 TileDotColor
|
||||
Vec4 DisabledCardTint
|
||||
}
|
||||
|
||||
type StaticPuzzleData
|
||||
{
|
||||
StaticPuzzleCard Cards Arr(64)
|
||||
PuzzleVisualSettings Visuals
|
||||
}
|
||||
|
||||
type PuzzleCardStack
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "../Log.h"
|
||||
#include "Dither.h"
|
||||
|
||||
using namespace Generated;
|
||||
|
||||
void DitherGen(DitherData& data, int32_t recursion)
|
||||
{
|
||||
data.Points[0] = {0.0f, 0.0f};
|
||||
@@ -55,7 +57,7 @@ void DitherGen(DitherData& data, int32_t recursion)
|
||||
{
|
||||
Vec2 vec = point - data.Points[i];
|
||||
Vec2 wrappedVec{bx::mod(vec.x + 0.5f, 1.0f) - 0.5f, bx::mod(vec.y + 0.5f, 1.0f) - 0.5f};
|
||||
float curDist = wrappedVec.Magnitude();
|
||||
float curDist = Magnitude(wrappedVec);
|
||||
dist = bx::min(dist, curDist);
|
||||
}
|
||||
|
||||
|
||||
@@ -463,7 +463,7 @@ namespace Game
|
||||
mat.State = 0 | BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A | BGFX_STATE_WRITE_Z | BGFX_STATE_DEPTH_TEST_LESS |
|
||||
BGFX_STATE_CULL_CCW | BGFX_STATE_MSAA;
|
||||
mat.Uniforms[Material::UTime] = bgfx::createUniform("u_time", bgfx::UniformType::Vec4);
|
||||
mat.Uniforms[Material::UDotColor] = bgfx::createUniform("u_testColor", bgfx::UniformType::Vec4);
|
||||
mat.Uniforms[Material::UDotColor] = bgfx::createUniform("u_dotColor", bgfx::UniformType::Vec4);
|
||||
mat.Uniforms[Material::UTexInfo] = bgfx::createUniform("u_texInfo", bgfx::UniformType::Vec4);
|
||||
mat.Uniforms[Material::UBaseColor] = bgfx::createUniform("u_baseColor", bgfx::UniformType::Vec4);
|
||||
mat.ViewID = view;
|
||||
|
||||
@@ -95,8 +95,6 @@ namespace Game
|
||||
uint16_t MainViewID = 10;
|
||||
float LastShaderLoadTime = 0.0f;
|
||||
int32_t DitherRecursion = 1;
|
||||
Vec4 DefaultBaseColor;
|
||||
Vec4 DefaultTileColor;
|
||||
|
||||
public:
|
||||
void Setup();
|
||||
|
||||
@@ -9,7 +9,7 @@ SAMPLER2D(s_texColor, 0);
|
||||
SAMPLER3D(s_ditherSampler, 1);
|
||||
SAMPLER2D(s_rampSampler, 2);
|
||||
uniform vec4 u_time;
|
||||
uniform vec4 u_testColor;
|
||||
uniform vec4 u_dotColor;
|
||||
uniform vec4 u_texInfo;
|
||||
uniform vec4 u_baseColor;
|
||||
|
||||
@@ -92,7 +92,7 @@ void main()
|
||||
float testSpeed = 1.0;
|
||||
vec3 testOffset = vec3(0.0, 0.0, 50.0);
|
||||
float3 lightPos = vec3(sin(u_time.x * testSpeed) * testRadius, 5.0, cos(u_time.x * testSpeed) * testRadius);
|
||||
vec3 texColor = u_testColor.x > 0.1 ? u_testColor.xyz : texture2D(s_texColor, v_uv0).xyz;
|
||||
vec3 texColor = u_dotColor.x > 0.1 ? u_dotColor.xyz : texture2D(s_texColor, v_uv0).xyz;
|
||||
|
||||
// lighting
|
||||
// float brightness = calcBrightness(lightPos, v_wpos, v_normal);
|
||||
|
||||
@@ -9,7 +9,7 @@ SAMPLER2D(s_texColor, 0);
|
||||
SAMPLER3D(s_ditherSampler, 1);
|
||||
SAMPLER2D(s_rampSampler, 2);
|
||||
uniform vec4 u_time;
|
||||
uniform vec4 u_testColor;
|
||||
uniform vec4 u_dotColor;
|
||||
uniform vec4 u_texInfo;
|
||||
uniform vec4 u_baseColor;
|
||||
|
||||
@@ -89,6 +89,7 @@ void main()
|
||||
{
|
||||
vec2 uv = vec2(1.0 - v_uv0.x, v_uv0.y);
|
||||
vec3 rawTex = texture2D(s_texColor, uv).xyz;
|
||||
vec3 col = rawTex * u_dotColor.xyz;
|
||||
float brightness = lerp(0.5, 0.9, calcBrightnessDirectional(vec3(0.5, 0.3, 1.0), v_normal));
|
||||
gl_FragColor = vec4(rawTex, 1.0);
|
||||
gl_FragColor = vec4(col * brightness, 1.0);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace Generated
|
||||
bool isOk = true;
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
{
|
||||
isOk = Save(&obj[i].X, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].Y, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].x, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].y, 1, serializer) && isOk;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
@@ -37,8 +37,8 @@ namespace Generated
|
||||
bool isOk = true;
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
{
|
||||
isOk = Load(&obj[i].X, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].Y, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].x, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].y, 1, serializer) && isOk;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
@@ -47,9 +47,9 @@ namespace Generated
|
||||
bool isOk = true;
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
{
|
||||
isOk = Save(&obj[i].X, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].Y, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].Z, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].x, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].y, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].z, 1, serializer) && isOk;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
@@ -58,9 +58,9 @@ namespace Generated
|
||||
bool isOk = true;
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
{
|
||||
isOk = Load(&obj[i].X, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].Y, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].Z, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].x, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].y, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].z, 1, serializer) && isOk;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
@@ -69,10 +69,10 @@ namespace Generated
|
||||
bool isOk = true;
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
{
|
||||
isOk = Save(&obj[i].X, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].Y, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].Z, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].W, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].x, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].y, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].z, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].w, 1, serializer) && isOk;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
@@ -81,10 +81,10 @@ namespace Generated
|
||||
bool isOk = true;
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
{
|
||||
isOk = Load(&obj[i].X, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].Y, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].Z, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].W, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].x, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].y, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].z, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].w, 1, serializer) && isOk;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
@@ -242,12 +242,35 @@ namespace Generated
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
bool Save(const PuzzleVisualSettings* obj, uint32_t count, Serializer& serializer)
|
||||
{
|
||||
bool isOk = true;
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
{
|
||||
isOk = Save(&obj[i].TileBaseColor, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].TileDotColor, 1, serializer) && isOk;
|
||||
isOk = Save(&obj[i].DisabledCardTint, 1, serializer) && isOk;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
bool Load(PuzzleVisualSettings* obj, uint32_t count, Deserializer& serializer)
|
||||
{
|
||||
bool isOk = true;
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
{
|
||||
isOk = Load(&obj[i].TileBaseColor, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].TileDotColor, 1, serializer) && isOk;
|
||||
isOk = Load(&obj[i].DisabledCardTint, 1, serializer) && isOk;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
bool Save(const StaticPuzzleData* obj, uint32_t count, Serializer& serializer)
|
||||
{
|
||||
bool isOk = true;
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
{
|
||||
isOk = Save(obj[i].Cards, 64, serializer) && isOk;
|
||||
isOk = Save(&obj[i].Visuals, 1, serializer) && isOk;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
@@ -257,6 +280,7 @@ namespace Generated
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
{
|
||||
isOk = Load(obj[i].Cards, 64, serializer) && isOk;
|
||||
isOk = Load(&obj[i].Visuals, 1, serializer) && isOk;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
@@ -54,24 +54,24 @@ namespace Generated
|
||||
};
|
||||
struct Vec2
|
||||
{
|
||||
static constexpr uint32_t Hash = 4242122113;
|
||||
float X = {};
|
||||
float Y = {};
|
||||
static constexpr uint32_t Hash = 2667033957;
|
||||
float x = {};
|
||||
float y = {};
|
||||
};
|
||||
struct Vec3
|
||||
{
|
||||
static constexpr uint32_t Hash = 1694997017;
|
||||
float X = {};
|
||||
float Y = {};
|
||||
float Z = {};
|
||||
static constexpr uint32_t Hash = 473740858;
|
||||
float x = {};
|
||||
float y = {};
|
||||
float z = {};
|
||||
};
|
||||
struct Vec4
|
||||
{
|
||||
static constexpr uint32_t Hash = 447058821;
|
||||
float X = {};
|
||||
float Y = {};
|
||||
float Z = {};
|
||||
float W = {};
|
||||
static constexpr uint32_t Hash = 2507696603;
|
||||
float x = {};
|
||||
float y = {};
|
||||
float z = {};
|
||||
float w = {};
|
||||
};
|
||||
struct Mat3
|
||||
{
|
||||
@@ -127,10 +127,18 @@ namespace Generated
|
||||
static constexpr uint32_t Hash = 1742502768;
|
||||
uint16_t Idx = UINT16_MAX;
|
||||
};
|
||||
struct PuzzleVisualSettings
|
||||
{
|
||||
static constexpr uint32_t Hash = 4208425878;
|
||||
Vec4 TileBaseColor = {};
|
||||
Vec4 TileDotColor = {};
|
||||
Vec4 DisabledCardTint = {};
|
||||
};
|
||||
struct StaticPuzzleData
|
||||
{
|
||||
static constexpr uint32_t Hash = 1497693577;
|
||||
static constexpr uint32_t Hash = 1076634601;
|
||||
StaticPuzzleCard Cards[64] = {};
|
||||
PuzzleVisualSettings Visuals = {};
|
||||
};
|
||||
struct PuzzleCardStack
|
||||
{
|
||||
@@ -185,6 +193,8 @@ namespace Generated
|
||||
bool Load(StaticPuzzleCard* obj, uint32_t count, Deserializer& serializer);
|
||||
bool Save(const StaticPuzzleCardHandle* obj, uint32_t count, Serializer& serializer);
|
||||
bool Load(StaticPuzzleCardHandle* obj, uint32_t count, Deserializer& serializer);
|
||||
bool Save(const PuzzleVisualSettings* obj, uint32_t count, Serializer& serializer);
|
||||
bool Load(PuzzleVisualSettings* obj, uint32_t count, Deserializer& serializer);
|
||||
bool Save(const StaticPuzzleData* obj, uint32_t count, Serializer& serializer);
|
||||
bool Load(StaticPuzzleData* obj, uint32_t count, Deserializer& serializer);
|
||||
bool Save(const PuzzleCardStack* obj, uint32_t count, Serializer& serializer);
|
||||
|
||||
Reference in New Issue
Block a user