include cleanup

This commit is contained in:
Asuro
2025-03-30 20:17:32 +02:00
parent 052fc2cc07
commit 6d170be57a
28 changed files with 173 additions and 379 deletions

View File

@@ -1,6 +1,6 @@
#include "Gen.h"
namespace Generated
namespace Gen
{
bool IsValid(const ModelHandle& h)
{
@@ -49,4 +49,4 @@ namespace Generated
res.Y += rhs.Y;
return res;
}
} // namespace Generated
} // namespace Gen

View File

@@ -1,7 +1,7 @@
#pragma once
#include "../gen/Generated.h"
namespace Generated
namespace Gen
{
bool IsValid(const AssetHandle& h);
bool IsValid(const ModelHandle& h);
@@ -12,4 +12,4 @@ namespace Generated
PuzPos operator+=(PuzPos lhs, const PuzPos& rhs);
PuzPos operator+(PuzPos lhs, const PuzPos& rhs);
} // namespace Generated
} // namespace Gen

View File

@@ -6,7 +6,7 @@
#include <cassert>
#include <cstdint>
using namespace Generated;
using namespace Gen;
namespace
{

View File

@@ -1,215 +1,8 @@
#pragma once
#include "Gen.h"
#include "../gen/Generated.h"
#include "bx/math.h"
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;
// }
// friend Vec2 operator+(Vec2 lhs, const Vec2& rhs)
// {
// lhs += rhs;
// return lhs;
// }
// Vec2& operator+=(const float& rhs)
// {
// x += rhs;
// y += rhs;
// return *this;
// }
// 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;
// }
// friend Vec2 operator-(Vec2 lhs, const Vec2& rhs)
// {
// lhs -= rhs;
// return lhs;
// }
// Vec2& operator-=(const float& rhs)
// {
// x -= rhs;
// y -= rhs;
// return *this;
// }
// friend Vec2 operator-(Vec2 lhs, const float& rhs)
// {
// lhs -= rhs;
// return lhs;
// }
// Vec2& operator*=(const float rhs)
// {
// x *= rhs;
// y *= rhs;
// return *this;
// }
// friend Vec2 operator*(Vec2 lhs, const float rhs)
// {
// lhs *= rhs;
// return lhs;
// }
// Vec2& operator/=(const float rhs)
// {
// x /= rhs;
// y /= rhs;
// return *this;
// }
// friend Vec2 operator/(Vec2 lhs, const float rhs)
// {
// lhs /= rhs;
// return lhs;
// }
// float Magnitude()
// {
// return bx::sqrt(x * x + y * y);
// }
// 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;
// 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;
// }
// 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;
// }
// 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;
// }
// 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;
// }
// 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};
// }
// };
// 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
// Mat4 Inverse();
// Mat4 Transpose();
// Vec4 Mul(const Vec4& vec);
// };
//
inline int32_t SetFlags(int32_t in, int32_t flags)
{
return in | flags;
@@ -231,97 +24,110 @@ inline bool GetFlag(int32_t in, int32_t flags)
return (in & flags) > 0;
}
namespace Gen
{
bool IsValid(const AssetHandle& h);
bool IsValid(const ModelHandle& h);
bool IsValid(const TextureHandle& h);
bool operator==(const AssetHandle& lhs, const AssetHandle& rhs);
bool operator==(const ModelHandle& lhs, const ModelHandle& rhs);
PuzPos operator+=(PuzPos lhs, const PuzPos& rhs);
PuzPos operator+(PuzPos lhs, const PuzPos& rhs);
} // namespace Gen
struct Transform
{
Mat4 M;
Mat4 MI;
Gen::Mat4 M;
Gen::Mat4 MI;
bx::Vec3 Position{0.0f, 0.0f, 0.0f};
Mat4 Rotation;
Gen::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(Vec3 offset);
void TranslateLocal(Vec3 offset);
void Rotate(Vec3 rotation);
void RotateLocal(Vec3 rotation);
Vec3 LocalToGlobalPoint(Vec3 local);
Vec3 LocalToGlobalDirection(Vec3 local);
Vec3 GlobalToLocalPoint(Vec3 global);
Vec3 GlobalToLocalDirection(Vec3 global);
Vec3 Right() const;
Vec3 Up() const;
Vec3 Forward() const;
void SetPosition(Vec3 pos);
Vec3 GetPosition();
void Translate(Gen::Vec3 offset);
void TranslateLocal(Gen::Vec3 offset);
void Rotate(Gen::Vec3 rotation);
void RotateLocal(Gen::Vec3 rotation);
Gen::Vec3 LocalToGlobalPoint(Gen::Vec3 local);
Gen::Vec3 LocalToGlobalDirection(Gen::Vec3 local);
Gen::Vec3 GlobalToLocalPoint(Gen::Vec3 global);
Gen::Vec3 GlobalToLocalDirection(Gen::Vec3 global);
Gen::Vec3 Right() const;
Gen::Vec3 Up() const;
Gen::Vec3 Forward() const;
void SetPosition(Gen::Vec3 pos);
Gen::Vec3 GetPosition();
const float* GetPtr();
void UpdateMatrix();
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);
Gen::Vec4& operator+=(Gen::Vec4& lhs, const Gen::Vec4& rhs);
Gen::Vec4 operator+(const Gen::Vec4& lhs, const Gen::Vec4& rhs);
Gen::Vec4& operator+=(Gen::Vec4& lhs, float rhs);
Gen::Vec4 operator+(Gen::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);
Gen::Vec4& operator-=(Gen::Vec4& lhs, const Gen::Vec4& rhs);
Gen::Vec4 operator-(const Gen::Vec4& lhs, const Gen::Vec4& rhs);
Gen::Vec4& operator-=(Gen::Vec4& lhs, float rhs);
Gen::Vec4 operator-(const Gen::Vec4& lhs, float rhs);
Vec4& operator*=(Vec4& lhs, float rhs);
Vec4 operator*(const Vec4& lhs, float rhs);
Gen::Vec4& operator*=(Gen::Vec4& lhs, float rhs);
Gen::Vec4 operator*(const Gen::Vec4& lhs, float rhs);
Vec4& operator/=(Vec4& lhs, float rhs);
Vec4 operator/(const Vec4& lhs, float rhs);
Gen::Vec4& operator/=(Gen::Vec4& lhs, float rhs);
Gen::Vec4 operator/(const Gen::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);
Gen::Vec3& operator+=(Gen::Vec3& lhs, const Gen::Vec3& rhs);
Gen::Vec3 operator+(const Gen::Vec3& lhs, const Gen::Vec3& rhs);
Gen::Vec3& operator+=(Gen::Vec3& lhs, float rhs);
Gen::Vec3 operator+(Gen::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);
Gen::Vec3& operator-=(Gen::Vec3& lhs, const Gen::Vec3& rhs);
Gen::Vec3 operator-(const Gen::Vec3& lhs, const Gen::Vec3& rhs);
Gen::Vec3& operator-=(Gen::Vec3& lhs, float rhs);
Gen::Vec3 operator-(const Gen::Vec3& lhs, float rhs);
Vec3& operator*=(Vec3& lhs, float rhs);
Vec3 operator*(const Vec3& lhs, float rhs);
Gen::Vec3& operator*=(Gen::Vec3& lhs, float rhs);
Gen::Vec3 operator*(const Gen::Vec3& lhs, float rhs);
Vec3& operator/=(Vec3& lhs, float rhs);
Vec3 operator/(const Vec3& lhs, float rhs);
Gen::Vec3& operator/=(Gen::Vec3& lhs, float rhs);
Gen::Vec3 operator/(const Gen::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);
Gen::Vec2& operator+=(Gen::Vec2& lhs, const Gen::Vec2& rhs);
Gen::Vec2 operator+(const Gen::Vec2& lhs, const Gen::Vec2& rhs);
Gen::Vec2& operator+=(Gen::Vec2& lhs, float rhs);
Gen::Vec2 operator+(Gen::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);
Gen::Vec2& operator-=(Gen::Vec2& lhs, const Gen::Vec2& rhs);
Gen::Vec2 operator-(const Gen::Vec2& lhs, const Gen::Vec2& rhs);
Gen::Vec2& operator-=(Gen::Vec2& lhs, float rhs);
Gen::Vec2 operator-(const Gen::Vec2& lhs, float rhs);
Vec2& operator*=(Vec2& lhs, float rhs);
Vec2 operator*(const Vec2& lhs, float rhs);
Gen::Vec2& operator*=(Gen::Vec2& lhs, float rhs);
Gen::Vec2 operator*(const Gen::Vec2& lhs, float rhs);
Vec2& operator/=(Vec2& lhs, float rhs);
Vec2 operator/(const Vec2& lhs, float rhs);
Gen::Vec2& operator/=(Gen::Vec2& lhs, float rhs);
Gen::Vec2 operator/(const Gen::Vec2& lhs, float rhs);
float Magnitude(const Vec4& vec);
float Magnitude(const Vec3& vec);
float Magnitude(const Vec2& vec);
float Magnitude(const Gen::Vec4& vec);
float Magnitude(const Gen::Vec3& vec);
float Magnitude(const Gen::Vec2& vec);
Vec4 Normalized(const Vec4& vec);
Vec3 Normalized(const Vec3& vec);
Vec2 Normalized(const Vec2& vec);
Gen::Vec4 Normalized(const Gen::Vec4& vec);
Gen::Vec3 Normalized(const Gen::Vec3& vec);
Gen::Vec2 Normalized(const Gen::Vec2& vec);
Mat4 Inverse(const Mat4& mat);
Mat4 Transpose(const Mat4& mat);
Vec4 Mul(const Mat4& mat, const Vec4& vec);
Gen::Mat4 Inverse(const Gen::Mat4& mat);
Gen::Mat4 Transpose(const Gen::Mat4& mat);
Gen::Vec4 Mul(const Gen::Mat4& mat, const Gen::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);
float DotProduct(Gen::Vec3 a, Gen::Vec3 b);
Gen::Vec3 CrossProduct(Gen::Vec3 a, Gen::Vec3 b);
Gen::Vec3 CrossProductFromPlane(Gen::Vec3 a, Gen::Vec3 b, Gen::Vec3 c);
bool RayPlaneIntersect(Gen::Vec3 l1, Gen::Vec3 l2, Gen::Vec3 p1, Gen::Vec3 p2, Gen::Vec3 p3, Gen::Vec3& out);
struct SharedData;

View File

@@ -5,6 +5,8 @@
namespace Game
{
using namespace Gen;
bool IsKeyboardAllowed()
{
auto& IO = ImGui::GetIO();

View File

@@ -1,5 +1,5 @@
#pragma once
#include "Global.h"
#include "../gen/Generated.h"
enum class MouseButton
{
@@ -393,6 +393,6 @@ namespace Game
bool GetMouseButton(MouseButton button);
bool GetMouseButtonPressedNow(MouseButton button);
bool GetMouseButtonReleasedNow(MouseButton button);
Vec2 GetMouseMovement();
Vec2 GetMousePos();
Gen::Vec2 GetMouseMovement();
Gen::Vec2 GetMousePos();
} // namespace Game

View File

@@ -30,8 +30,8 @@ namespace Game
{
Transform PlayerCamTransform;
Transform FreeflyCamTransform;
Mat4 Projection;
Mat4 ProjectionInverse;
Gen::Mat4 Projection;
Gen::Mat4 ProjectionInverse;
float FreeflyXRot = 0.0f;
float FreeflyYRot = 0.0f;
float WalkXRot = 0.0f;
@@ -49,7 +49,7 @@ namespace Game
char ImguiIni[4096]{0};
static constexpr uint32_t MaxAssets = 128;
uint32_t AssetCount = 0;
Generated::AssetHandle AssetHandles[MaxAssets]{0};
Gen::AssetHandle AssetHandles[MaxAssets]{0};
char AssetHandlePaths[MaxAssets][128];
bool ShowImguiDemo = false;
uint8_t DebugCardRotation = 0;

View File

@@ -6,7 +6,6 @@
#include "Level.h"
#include "Log.h"
#include "Puzzle.h"
#include "bx/constants.h"
#include "rendering/Rendering.h"
#include "SDL3/SDL_mouse.h"
@@ -21,14 +20,14 @@
#include <cstdint>
#include <tracy/Tracy.hpp>
using namespace Generated;
using namespace Gen;
namespace Game
{
void EntityRenderData::Render(const Model* models, const Material* materials, const Texture* textures)
{
if (models == nullptr || materials == nullptr || textures == nullptr) return;
if (!Generated::IsValid(ModelH) || MaterialHandle == EMaterial::UNDEFINED) return;
if (!Gen::IsValid(ModelH) || MaterialHandle == EMaterial::UNDEFINED) return;
if (!Visible) return;
auto& rendering = GameRendering::Get();
@@ -119,8 +118,8 @@ namespace Game
fullPath.join(info.filePath);
LOG("Loading %s", fullPath.getCPtr());
Generated::Deserializer ser;
Generated::PuzzleData dataBuf;
Gen::Deserializer ser;
Gen::PuzzleData dataBuf;
if (ser.Init(fullPath, "PZZL") && ser.ReadT(dataBuf))
{
if (dataBuf.ID >= BX_COUNTOF(Puzzles))
@@ -355,7 +354,7 @@ namespace Game
for (int8_t x = 0; x < Data.WidthTiles / Puzzle::Config::CardSize; ++x)
{
int32_t cardIdx = y * Puzzle::Config::MaxPuzzleSizeCards + x;
Generated::PlacedPuzzleCard& card = Data.PlacedCards[cardIdx];
Gen::PlacedPuzzleCard& card = Data.PlacedCards[cardIdx];
auto& tile = level.PuzzleTiles.Get(TileHandles[cardIdx]);
auto& quad = level.UIQuads.Get(UIPlacedCards[cardIdx]);
@@ -378,7 +377,7 @@ namespace Game
quad.EData.Visible = isValid;
quad.EData.TextureHandle =
isValid ? staticCards[card.RefCard.Idx].BoardTextureHandle : Generated::TextureHandle{};
isValid ? staticCards[card.RefCard.Idx].BoardTextureHandle : Gen::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;
@@ -416,8 +415,8 @@ namespace Game
Vec3 boardTilePos = boardPos / UICardOffset;
int32_t xPos = (int32_t)bx::round(boardTilePos.x);
int32_t yPos = (int32_t)bx::round(boardTilePos.y);
Generated::PuzPos srcCardPos = {(int8_t)DraggedCard.X, (int8_t)DraggedCard.Y};
Generated::PlacedPuzzleCard& srcCard =
Gen::PuzPos srcCardPos = {(int8_t)DraggedCard.X, (int8_t)DraggedCard.Y};
Gen::PlacedPuzzleCard& srcCard =
Data.PlacedCards[srcCardPos.Y * Puzzle::Config::MaxPuzzleSizeCards + srcCardPos.X];
if (GetMouseButtonPressedNow(MouseButton::Right))
@@ -428,11 +427,11 @@ namespace Game
if (!GetMouseButton(MouseButton::Left))
{
Generated::PuzPos targetCardPos = {(int8_t)xPos, (int8_t)yPos};
Gen::PuzPos targetCardPos = {(int8_t)xPos, (int8_t)yPos};
if (xPos >= 0 && xPos < Data.WidthTiles / Puzzle::Config::CardSize && yPos >= 0 &&
yPos < Data.HeightTiles / Puzzle::Config::CardSize)
{
Generated::PlacedPuzzleCard& targetCard =
Gen::PlacedPuzzleCard& targetCard =
Data.PlacedCards[yPos * Puzzle::Config::MaxPuzzleSizeCards + xPos];
bool canBeReplaced = !Puzzle::IsValid(targetCard.RefCard) || targetCard.RefCard.Idx == 0;
if (canBeReplaced && Puzzle::ReturnPlacedCard(Data, srcCardPos))

View File

@@ -21,12 +21,12 @@ namespace Game
{
struct EntityRenderData
{
Vec4 DotColor{1.0f, 1.0f, 1.0f, 1.0f};
Vec4 BaseColor{0.0f, 0.0f, 0.0f, 1.0f};
Gen::Vec4 DotColor{1.0f, 1.0f, 1.0f, 1.0f};
Gen::Vec4 BaseColor{0.0f, 0.0f, 0.0f, 1.0f};
Transform Transform;
EMaterial MaterialHandle = EMaterial::UNDEFINED;
Generated::TextureHandle TextureHandle;
Generated::ModelHandle ModelH;
Gen::TextureHandle TextureHandle;
Gen::ModelHandle ModelH;
bool Visible = true;
void Render(const Model* models, const Material* materials, const Texture* textures);
@@ -135,13 +135,13 @@ namespace Game
struct WorldPuzzle
{
static constexpr Vec2 WorldCardSize{10.0f, 10.0f};
static constexpr Gen::Vec2 WorldCardSize{10.0f, 10.0f};
static constexpr float UICardOffset = 0.21f;
Generated::PuzzleData Data;
Vec3 WorldPosition;
Gen::PuzzleData Data;
Gen::Vec3 WorldPosition;
PuzzleTileEntityHandle TileHandles[Puzzle::Config::MaxCardsInPuzzle];
UIQuadEntityHandle UIPlacedCards[Puzzle::Config::MaxCardsInPuzzle];
Generated::PuzPos DraggedCard{-1, -1};
Gen::PuzPos DraggedCard{-1, -1};
bool IsSetup = false;
void Setup();
@@ -158,7 +158,7 @@ namespace Game
CubeHandle PlayerOutsideViewCube;
public:
Generated::StaticPuzzleData PuzzleData;
Gen::StaticPuzzleData PuzzleData;
WorldPuzzle Puzzles[1];
public:

View File

@@ -8,25 +8,25 @@
#include "bx/string.h"
#include "imgui.h"
#include <cassert>
#include <cstdio>
namespace
{
static constexpr Generated::PuzPos Dirs[4]{
using namespace Gen;
static constexpr PuzPos Dirs[4]{
{-1, 0},
{0, -1},
{0, 1},
{1, 0},
};
Generated::StaticPuzzleData StaticData;
Generated::StaticPuzzleCard InvalidCard;
StaticPuzzleData StaticData;
StaticPuzzleCard InvalidCard;
} // namespace
namespace Puzzle
{
constexpr float UIPuzBoxSize = 26;
using namespace Generated;
using namespace Gen;
void Setup()
{
@@ -339,7 +339,7 @@ namespace Puzzle
{
char filepath[128]{0};
WritePuzzleFilePath(filepath, sizeof(filepath), obj.ID);
remove(filepath);
bx::remove(filepath);
obj.ID = UINT16_MAX;
ImGui::End();
return false;

View File

@@ -2,11 +2,11 @@
#include <cstdint>
#include <imgui.h>
#include "Gen.h" // IWYU pragma: keep
#include "../gen/Generated.h"
namespace Puzzle
{
using namespace Generated;
using namespace Gen;
constexpr const char* PuzzleFileDir = "game/data/puzzles/";
@@ -43,11 +43,11 @@ namespace Puzzle
struct PuzzleSolver
{
bool IsPuzzleSolved(const Generated::PuzzleData& puzzle);
bool IsExitSatisfied(const Generated::PuzzleData& puzzle, PuzPos pos);
bool IsPuzzleSolved(const PuzzleData& puzzle);
bool IsExitSatisfied(const PuzzleData& puzzle, PuzPos pos);
// This assumes flowFrom is already verified to be connected.
bool IsValidGoalConnection(const Generated::PuzzleData& puzzle,
bool IsValidGoalConnection(const PuzzleData& puzzle,
PuzPos flowFrom,
PuzPos flowTo,
PuzzleElementType::Enum goalType);

View File

@@ -8,7 +8,7 @@
#include <imgui.h>
#include <tracy/Tracy.hpp>
using namespace Generated;
using namespace Gen;
namespace
{
@@ -19,7 +19,7 @@ namespace
namespace Tools
{
const char* GetAssetPath(Generated::AssetHandle assetHandle)
const char* GetAssetPath(Gen::AssetHandle assetHandle)
{
const auto& inst = Game::GetInstance();
for (int32_t j = 0; j < inst.DebugData.AssetCount; ++j)
@@ -32,7 +32,7 @@ namespace Tools
return "---";
}
void ModelDropdown(Generated::ModelHandle& modelHandle)
void ModelDropdown(Gen::ModelHandle& modelHandle)
{
auto& R = Game::GameRendering::Get();
const char* name = GetAssetPath(modelHandle.Asset);
@@ -49,7 +49,7 @@ namespace Tools
}
}
void TextureDropdown(Generated::TextureHandle& texHandle)
void TextureDropdown(Gen::TextureHandle& texHandle)
{
auto& R = Game::GameRendering::Get();
const char* name = GetAssetPath(texHandle.Asset);
@@ -280,7 +280,7 @@ namespace Tools
}
if (ImGui::Begin("Cards"))
{
Generated::StaticPuzzleData& staticData = Puzzle::GetStaticPuzzleData();
Gen::StaticPuzzleData& staticData = Puzzle::GetStaticPuzzleData();
if (ImGui::Button("Save"))
{
Puzzle::SaveStaticPuzzleData();
@@ -295,7 +295,7 @@ namespace Tools
{
ImGui::Separator();
Generated::StaticPuzzleCard& card = staticData.Cards[i];
Gen::StaticPuzzleCard& card = staticData.Cards[i];
ImGui::PushID(i);
char cardName[64]{0};
bx::snprintf(cardName, sizeof(cardName), "%i", i);
@@ -317,14 +317,14 @@ namespace Tools
if (x > 0) ImGui::SameLine();
ImGui::PushID(x);
auto& node = Puzzle::EditCardNodeAt(card, 0, x, y);
if (ImGui::Button(Generated::PuzzleElementType::ShortName[node], {26, 24}))
if (ImGui::Button(Gen::PuzzleElementType::ShortName[node], {26, 24}))
{
int32_t newVal = int32_t(node) + 1;
if (newVal >= Generated::PuzzleElementType::EntryCount)
if (newVal >= Gen::PuzzleElementType::EntryCount)
{
newVal = 0;
}
node = Generated::PuzzleElementType::Enum(newVal);
node = Gen::PuzzleElementType::Enum(newVal);
}
ImGui::PopID();
}

View File

@@ -1,11 +1,11 @@
#pragma once
#include "Gen.h"
#include "../gen/Generated.h"
#include "rendering/Rendering.h"
namespace Tools
{
void ModelDropdown(Generated::ModelHandle& modelHandle);
void TextureDropdown(Generated::TextureHandle& texHandle);
void ModelDropdown(Gen::ModelHandle& modelHandle);
void TextureDropdown(Gen::TextureHandle& texHandle);
void RenderDebugUI(Game::GameRendering& rendering);
void MeasureFrameEnd();
} // namespace Tools

View File

@@ -1,7 +1,8 @@
#include "../Global.h"
#include "../Log.h"
#include "Dither.h"
using namespace Generated;
using namespace Gen;
void DitherGen(DitherData& data, int32_t recursion)
{

View File

@@ -1,5 +1,5 @@
#pragma once
#include "../Global.h"
#include "../../gen/Generated.h"
#include <bgfx/bgfx.h>
#include <imgui.h>
@@ -7,9 +7,9 @@
struct DitherData
{
static constexpr uint32_t BrightnessBucketCount = 256;
Vec2 Points[4096];
Gen::Vec2 Points[4096];
uint32_t PointCount = 0;
Vec4 DitherTex[256 * 256 * 64];
Gen::Vec4 DitherTex[256 * 256 * 64];
uint32_t DitherTexWH = 0;
uint32_t DitherTexDepth = 0;
int32_t BrightnessBuckets[BrightnessBucketCount];

View File

@@ -470,7 +470,7 @@ namespace Game
return mat;
}
Generated::ModelHandle GameRendering::GetModelHandleFromPath(const char* path)
Gen::ModelHandle GameRendering::GetModelHandleFromPath(const char* path)
{
uint32_t AssetHandle = CrcPath(path);
for (int32_t i = 0; i < ModelCount; ++i)

View File

@@ -4,8 +4,7 @@
#include <bx/string.h>
#include <cstdint>
#include "../Gen.h" // IWYU pragma: keep
#include "../Global.h"
#include "../../gen/Generated.h"
#include "Dither.h"
union SDL_Event;
@@ -30,7 +29,7 @@ namespace Game
bgfx::UniformHandle SamplerHandle = {bgfx::kInvalidHandle};
bgfx::TextureHandle RenderHandle = {bgfx::kInvalidHandle};
bgfx::TextureInfo Info;
Generated::TextureHandle TexHandle;
Gen::TextureHandle TexHandle;
};
struct Model
@@ -38,7 +37,7 @@ namespace Game
bgfx::VertexBufferHandle VertexBuffer = {bgfx::kInvalidHandle};
bgfx::IndexBufferHandle IndexBuffer = {bgfx::kInvalidHandle};
bgfx::VertexLayout VertLayout;
Generated::ModelHandle Handle;
Gen::ModelHandle Handle;
};
struct Material
@@ -103,6 +102,6 @@ namespace Game
void LoadTextures();
void ReloadShaders();
void Shutdown();
Generated::ModelHandle GetModelHandleFromPath(const char* path);
Gen::ModelHandle GetModelHandleFromPath(const char* path);
};
} // namespace Game