fixing stuff
This commit is contained in:
48
src/game/Gen.cpp
Normal file
48
src/game/Gen.cpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#include "Gen.h"
|
||||||
|
|
||||||
|
namespace Generated
|
||||||
|
{
|
||||||
|
bool IsValid(const ModelHandle& h)
|
||||||
|
{
|
||||||
|
return h.ModelIdx != UINT16_MAX && IsValid(h.Asset);
|
||||||
|
}
|
||||||
|
bool IsValid(const AssetHandle& h)
|
||||||
|
{
|
||||||
|
return h.Idx != UINT32_MAX;
|
||||||
|
}
|
||||||
|
bool operator==(const AssetHandle& lhs, const AssetHandle& rhs)
|
||||||
|
{
|
||||||
|
return lhs.Idx == rhs.Idx;
|
||||||
|
}
|
||||||
|
bool operator==(const ModelHandle& lhs, const ModelHandle& rhs)
|
||||||
|
{
|
||||||
|
if (!IsValid(lhs) || !IsValid(rhs)) return IsValid(lhs) == IsValid(rhs);
|
||||||
|
return lhs.ModelIdx == rhs.ModelIdx && lhs.Asset == rhs.Asset;
|
||||||
|
}
|
||||||
|
PuzPos operator+=(PuzPos lhs, const PuzPos& rhs)
|
||||||
|
{
|
||||||
|
lhs.X += rhs.X;
|
||||||
|
lhs.Y += rhs.Y;
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
PuzPos operator+(PuzPos lhs, const PuzPos& rhs)
|
||||||
|
{
|
||||||
|
PuzPos res = lhs;
|
||||||
|
res.X += rhs.X;
|
||||||
|
res.Y += rhs.Y;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
PuzPos operator-=(PuzPos lhs, const PuzPos& rhs)
|
||||||
|
{
|
||||||
|
lhs.X -= rhs.X;
|
||||||
|
lhs.Y -= rhs.Y;
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
PuzPos operator-(PuzPos lhs, const PuzPos& rhs)
|
||||||
|
{
|
||||||
|
PuzPos res = lhs;
|
||||||
|
res.X += rhs.X;
|
||||||
|
res.Y += rhs.Y;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
} // namespace Generated
|
||||||
14
src/game/Gen.h
Normal file
14
src/game/Gen.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../gen/Generated.h"
|
||||||
|
|
||||||
|
namespace Generated
|
||||||
|
{
|
||||||
|
bool IsValid(const AssetHandle& h);
|
||||||
|
bool IsValid(const ModelHandle& 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 Generated
|
||||||
@@ -45,7 +45,7 @@ namespace Game
|
|||||||
char ImguiIni[4096]{0};
|
char ImguiIni[4096]{0};
|
||||||
static constexpr uint32_t MaxAssets = 128;
|
static constexpr uint32_t MaxAssets = 128;
|
||||||
uint32_t AssetCount = 0;
|
uint32_t AssetCount = 0;
|
||||||
uint32_t AssetHandles[MaxAssets]{0};
|
Generated::AssetHandle AssetHandles[MaxAssets]{0};
|
||||||
char AssetHandlePaths[MaxAssets][128];
|
char AssetHandlePaths[MaxAssets][128];
|
||||||
bool ShowImguiDemo = false;
|
bool ShowImguiDemo = false;
|
||||||
uint8_t DebugCardRotation = 0;
|
uint8_t DebugCardRotation = 0;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "../gen/Def.h"
|
#include "../gen/Def.h"
|
||||||
|
#include "Gen.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Input.h"
|
#include "Input.h"
|
||||||
#include "Instance.h"
|
#include "Instance.h"
|
||||||
@@ -23,14 +24,14 @@ namespace Game
|
|||||||
{
|
{
|
||||||
void EntityRenderData::Render(const Model* models, const Material* materials)
|
void EntityRenderData::Render(const Model* models, const Material* materials)
|
||||||
{
|
{
|
||||||
if (ModelHandle == UINT16_MAX || MaterialHandle == UINT16_MAX) return;
|
if (!Generated::IsValid(ModelH) || MaterialHandle == UINT16_MAX) return;
|
||||||
if (!Visible) return;
|
if (!Visible) return;
|
||||||
auto& rendering = GameRendering::Get();
|
auto& rendering = GameRendering::Get();
|
||||||
|
|
||||||
Transform.UpdateMatrix();
|
Transform.UpdateMatrix();
|
||||||
bgfx::setTransform(Transform.M.M);
|
bgfx::setTransform(Transform.M.M);
|
||||||
|
|
||||||
const Model& currentModel = models[ModelHandle];
|
const Model& currentModel = models[ModelH.ModelIdx];
|
||||||
const Material& currentMaterial = materials[MaterialHandle];
|
const Material& currentMaterial = materials[MaterialHandle];
|
||||||
bgfx::setVertexBuffer(0, currentModel.VertexBuffer);
|
bgfx::setVertexBuffer(0, currentModel.VertexBuffer);
|
||||||
bgfx::setIndexBuffer(currentModel.IndexBuffer);
|
bgfx::setIndexBuffer(currentModel.IndexBuffer);
|
||||||
@@ -277,7 +278,7 @@ namespace Game
|
|||||||
void Cube::Setup()
|
void Cube::Setup()
|
||||||
{
|
{
|
||||||
EData.MaterialHandle = 0;
|
EData.MaterialHandle = 0;
|
||||||
EData.ModelHandle = GameRendering::Get().GetModelHandleFromPath("models/cube.gltf");
|
EData.ModelH = GameRendering::Get().GetModelHandleFromPath("models/cube.gltf");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cube::Update()
|
void Cube::Update()
|
||||||
@@ -300,7 +301,7 @@ namespace Game
|
|||||||
void TestEntity::Setup()
|
void TestEntity::Setup()
|
||||||
{
|
{
|
||||||
EData.MaterialHandle = 0;
|
EData.MaterialHandle = 0;
|
||||||
EData.ModelHandle = GameRendering::Get().GetModelHandleFromPath("models/zurg.gltf");
|
EData.ModelH = GameRendering::Get().GetModelHandleFromPath("models/zurg.gltf");
|
||||||
|
|
||||||
EData.Transform.Position = {0.0f, 0.0f, 0.0f};
|
EData.Transform.Position = {0.0f, 0.0f, 0.0f};
|
||||||
}
|
}
|
||||||
@@ -326,7 +327,7 @@ namespace Game
|
|||||||
Level& level = GetInstance().GameLevel;
|
Level& level = GetInstance().GameLevel;
|
||||||
auto& staticCards = Puzzle::GetStaticPuzzleData().Cards;
|
auto& staticCards = Puzzle::GetStaticPuzzleData().Cards;
|
||||||
|
|
||||||
for (int8_t y = 0; y < Data.WidthTiles / Puzzle::Config::CardSize; ++y)
|
for (int8_t y = 0; y < Data.HeightTiles / Puzzle::Config::CardSize; ++y)
|
||||||
{
|
{
|
||||||
for (int8_t x = 0; x < Data.WidthTiles / Puzzle::Config::CardSize; ++x)
|
for (int8_t x = 0; x < Data.WidthTiles / Puzzle::Config::CardSize; ++x)
|
||||||
{
|
{
|
||||||
@@ -336,21 +337,24 @@ namespace Game
|
|||||||
|
|
||||||
bool IsValid = Puzzle::IsValid(card.RefCard);
|
bool IsValid = Puzzle::IsValid(card.RefCard);
|
||||||
tile.EData.Visible = true;
|
tile.EData.Visible = true;
|
||||||
quad.EData.Visible = IsValid;
|
quad.EData.Visible = true;
|
||||||
|
|
||||||
// const Generated::StaticPuzzleCard& cData = Puzzle::GetCard(card.RefCard);
|
tile.EData.ModelH = IsValid ? staticCards[card.RefCard.Idx].ModelHandle : staticCards[0].ModelHandle;
|
||||||
tile.EData.ModelHandle =
|
Vec3 cardPos = {
|
||||||
IsValid ? staticCards[card.RefCard.Idx].ModelHandle : staticCards[0].ModelHandle;
|
|
||||||
tile.EData.Transform.SetPosition({
|
|
||||||
(float)card.Position.X * Puzzle::Config::CardScaleWorld,
|
(float)card.Position.X * Puzzle::Config::CardScaleWorld,
|
||||||
-5.0f,
|
-5.0f,
|
||||||
(float)card.Position.Y * Puzzle::Config::CardScaleWorld,
|
(float)card.Position.Y * Puzzle::Config::CardScaleWorld,
|
||||||
});
|
};
|
||||||
|
if (!IsValid)
|
||||||
|
{
|
||||||
|
cardPos = {x * Puzzle::Config::CardScaleWorld, -5.0f, y * Puzzle::Config::CardScaleWorld};
|
||||||
|
}
|
||||||
|
tile.EData.Transform.SetPosition(cardPos);
|
||||||
bx::mtxRotateY(tile.EData.Transform.Rotation.M, card.Rotation * bx::kPi * 0.5f);
|
bx::mtxRotateY(tile.EData.Transform.Rotation.M, card.Rotation * bx::kPi * 0.5f);
|
||||||
|
|
||||||
Vec3 fw = {0, -1, 0};
|
Vec3 fw = {0, -1, 0};
|
||||||
quad.EData.Transform.SetPosition({});
|
quad.EData.Transform.SetPosition(fw);
|
||||||
quad.EData.Transform.Rotation = camTransform.Rotation;
|
quad.EData.Transform.Rotation = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Game
|
|||||||
Vec4 BaseColor{0.0f, 0.0f, 0.0f, 1.0f};
|
Vec4 BaseColor{0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
Transform Transform;
|
Transform Transform;
|
||||||
uint16_t MaterialHandle = UINT16_MAX;
|
uint16_t MaterialHandle = UINT16_MAX;
|
||||||
uint16_t ModelHandle = UINT16_MAX;
|
Generated::ModelHandle ModelH;
|
||||||
bool Visible = true;
|
bool Visible = true;
|
||||||
|
|
||||||
void Render(const Model* models, const Material* materials);
|
void Render(const Model* models, const Material* materials);
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ namespace Game
|
|||||||
}
|
}
|
||||||
LOG("Found %u models!", modelFilePathCount);
|
LOG("Found %u models!", modelFilePathCount);
|
||||||
|
|
||||||
|
auto& inst = GetInstance();
|
||||||
int32_t writeI = 0;
|
int32_t writeI = 0;
|
||||||
for (int32_t i = 0; i < modelFilePathCount; ++i)
|
for (int32_t i = 0; i < modelFilePathCount; ++i)
|
||||||
{
|
{
|
||||||
@@ -141,11 +142,11 @@ namespace Game
|
|||||||
Model& mod = models[writeI];
|
Model& mod = models[writeI];
|
||||||
if (LoadMesh(mod, fullPath.getCPtr(), modelFileIsBinary[i]))
|
if (LoadMesh(mod, fullPath.getCPtr(), modelFileIsBinary[i]))
|
||||||
{
|
{
|
||||||
mod.AssetHandle = CrcPath(fullPath.getCPtr());
|
mod.Handle.Asset.Idx = CrcPath(fullPath.getCPtr());
|
||||||
auto& inst = GetInstance();
|
mod.Handle.ModelIdx = inst.DebugData.AssetCount;
|
||||||
if (inst.DebugData.AssetCount < inst.DebugData.MaxAssets)
|
if (inst.DebugData.AssetCount < inst.DebugData.MaxAssets)
|
||||||
{
|
{
|
||||||
inst.DebugData.AssetHandles[inst.DebugData.AssetCount] = mod.AssetHandle;
|
inst.DebugData.AssetHandles[inst.DebugData.AssetCount] = mod.Handle.Asset;
|
||||||
bx::strCopy(inst.DebugData.AssetHandlePaths[inst.DebugData.AssetCount],
|
bx::strCopy(inst.DebugData.AssetHandlePaths[inst.DebugData.AssetCount],
|
||||||
sizeof(inst.DebugData.AssetHandlePaths[inst.DebugData.AssetCount]),
|
sizeof(inst.DebugData.AssetHandlePaths[inst.DebugData.AssetCount]),
|
||||||
fullPath.getCPtr());
|
fullPath.getCPtr());
|
||||||
|
|||||||
@@ -588,33 +588,3 @@ namespace Puzzle
|
|||||||
return isVisible;
|
return isVisible;
|
||||||
}
|
}
|
||||||
} // namespace Puzzle
|
} // namespace Puzzle
|
||||||
|
|
||||||
namespace Generated
|
|
||||||
{
|
|
||||||
PuzPos operator+=(PuzPos lhs, const PuzPos& rhs)
|
|
||||||
{
|
|
||||||
lhs.X += rhs.X;
|
|
||||||
lhs.Y += rhs.Y;
|
|
||||||
return lhs;
|
|
||||||
}
|
|
||||||
PuzPos operator+(PuzPos lhs, const PuzPos& rhs)
|
|
||||||
{
|
|
||||||
PuzPos res = lhs;
|
|
||||||
res.X += rhs.X;
|
|
||||||
res.Y += rhs.Y;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
PuzPos operator-=(PuzPos lhs, const PuzPos& rhs)
|
|
||||||
{
|
|
||||||
lhs.X -= rhs.X;
|
|
||||||
lhs.Y -= rhs.Y;
|
|
||||||
return lhs;
|
|
||||||
}
|
|
||||||
PuzPos operator-(PuzPos lhs, const PuzPos& rhs)
|
|
||||||
{
|
|
||||||
PuzPos res = lhs;
|
|
||||||
res.X += rhs.X;
|
|
||||||
res.Y += rhs.Y;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} // namespace Generated
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
#include "../../gen/Generated.h"
|
#include "Gen.h"
|
||||||
|
|
||||||
namespace Puzzle
|
namespace Puzzle
|
||||||
{
|
{
|
||||||
@@ -50,9 +50,3 @@ namespace Puzzle
|
|||||||
};
|
};
|
||||||
bool RenderDebugUI(PuzzleData& obj);
|
bool RenderDebugUI(PuzzleData& obj);
|
||||||
} // namespace Puzzle
|
} // namespace Puzzle
|
||||||
|
|
||||||
namespace Generated
|
|
||||||
{
|
|
||||||
PuzPos operator+=(PuzPos lhs, const PuzPos& rhs);
|
|
||||||
PuzPos operator+(PuzPos lhs, const PuzPos& rhs);
|
|
||||||
} // namespace Generated
|
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Instance.h"
|
#include "Instance.h"
|
||||||
#include "Tools.h"
|
#include "Tools.h"
|
||||||
#include "bx/string.h"
|
|
||||||
#include "rendering/Rendering.h"
|
#include "rendering/Rendering.h"
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace Tools
|
namespace Tools
|
||||||
{
|
{
|
||||||
const char* GetAssetPath(uint32_t assetHandle)
|
const char* GetAssetPath(Generated::AssetHandle assetHandle)
|
||||||
{
|
{
|
||||||
const auto& inst = Game::GetInstance();
|
const auto& inst = Game::GetInstance();
|
||||||
for (int32_t j = 0; j < inst.DebugData.AssetCount; ++j)
|
for (int32_t j = 0; j < inst.DebugData.AssetCount; ++j)
|
||||||
@@ -21,26 +20,17 @@ namespace Tools
|
|||||||
return "---";
|
return "---";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelDropdown(uint32_t& modelHandle)
|
void ModelDropdown(Generated::ModelHandle& modelHandle)
|
||||||
{
|
{
|
||||||
auto& R = Game::GameRendering::Get();
|
auto& R = Game::GameRendering::Get();
|
||||||
const char* name = GetAssetPath(modelHandle);
|
const char* name = GetAssetPath(modelHandle.Asset);
|
||||||
int32_t idx = -1;
|
|
||||||
for (int32_t i = 0; i < R.ModelCount; ++i)
|
|
||||||
{
|
|
||||||
if (R.Models[i].AssetHandle == modelHandle)
|
|
||||||
{
|
|
||||||
idx = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ImGui::BeginCombo("Models", name))
|
if (ImGui::BeginCombo("Models", name))
|
||||||
{
|
{
|
||||||
for (int32_t i = 0; i < R.ModelCount; ++i)
|
for (int32_t i = 0; i < R.ModelCount; ++i)
|
||||||
{
|
{
|
||||||
if (ImGui::Selectable(GetAssetPath(R.Models[i].AssetHandle), i == idx))
|
if (ImGui::Selectable(GetAssetPath(R.Models[i].Handle.Asset), i == modelHandle.ModelIdx))
|
||||||
{
|
{
|
||||||
modelHandle = i;
|
modelHandle = R.Models[i].Handle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include "Gen.h"
|
||||||
|
|
||||||
namespace Tools
|
namespace Tools
|
||||||
{
|
{
|
||||||
void ModelDropdown(uint32_t& modelHandle);
|
void ModelDropdown(Generated::ModelHandle& modelHandle);
|
||||||
} // namespace Tools
|
} // namespace Tools
|
||||||
|
|||||||
BIN
src/game/data/puzzles/0.pzl
LFS
BIN
src/game/data/puzzles/0.pzl
LFS
Binary file not shown.
Binary file not shown.
@@ -38,6 +38,17 @@ type Mat4
|
|||||||
}")
|
}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AssetHandle
|
||||||
|
{
|
||||||
|
u32 Idx Default("UINT32_MAX")
|
||||||
|
}
|
||||||
|
|
||||||
|
type ModelHandle
|
||||||
|
{
|
||||||
|
u16 ModelIdx Default("UINT16_MAX")
|
||||||
|
AssetHandle Asset
|
||||||
|
}
|
||||||
|
|
||||||
type PuzPos
|
type PuzPos
|
||||||
{
|
{
|
||||||
i8 X
|
i8 X
|
||||||
@@ -59,7 +70,8 @@ enum PuzzleElementType(u8)
|
|||||||
type StaticPuzzleCard
|
type StaticPuzzleCard
|
||||||
{
|
{
|
||||||
PuzzleElementType Elements Arr(4)
|
PuzzleElementType Elements Arr(4)
|
||||||
u32 ModelHandle
|
ModelHandle ModelHandle
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type StaticPuzzleCardHandle
|
type StaticPuzzleCardHandle
|
||||||
|
|||||||
@@ -731,17 +731,17 @@ namespace Game
|
|||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t GameRendering::GetModelHandleFromPath(const char* path)
|
Generated::ModelHandle GameRendering::GetModelHandleFromPath(const char* path)
|
||||||
{
|
{
|
||||||
uint32_t AssetHandle = CrcPath(path);
|
uint32_t AssetHandle = CrcPath(path);
|
||||||
for (int32_t i = 0; i < ModelCount; ++i)
|
for (int32_t i = 0; i < ModelCount; ++i)
|
||||||
{
|
{
|
||||||
if (Models[i].AssetHandle == AssetHandle)
|
if (Models[i].Handle.Asset.Idx == AssetHandle)
|
||||||
{
|
{
|
||||||
return i;
|
return Models[i].Handle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Game
|
} // namespace Game
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "bgfx/defines.h"
|
#include "bgfx/defines.h"
|
||||||
|
#include "imgui.h"
|
||||||
#include <bgfx/bgfx.h>
|
#include <bgfx/bgfx.h>
|
||||||
#include <bx/string.h>
|
#include <bx/string.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "../Gen.h"
|
||||||
#include "../Global.h"
|
#include "../Global.h"
|
||||||
#include "imgui.h"
|
|
||||||
|
|
||||||
union SDL_Event;
|
union SDL_Event;
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ namespace Game
|
|||||||
bgfx::VertexBufferHandle VertexBuffer;
|
bgfx::VertexBufferHandle VertexBuffer;
|
||||||
bgfx::IndexBufferHandle IndexBuffer;
|
bgfx::IndexBufferHandle IndexBuffer;
|
||||||
bgfx::VertexLayout VertLayout;
|
bgfx::VertexLayout VertLayout;
|
||||||
uint32_t AssetHandle = UINT16_MAX;
|
Generated::ModelHandle Handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Material
|
struct Material
|
||||||
@@ -118,6 +119,6 @@ namespace Game
|
|||||||
void HandleEvents();
|
void HandleEvents();
|
||||||
void RenderDebugUI();
|
void RenderDebugUI();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
uint16_t GetModelHandleFromPath(const char* path);
|
Generated::ModelHandle GetModelHandleFromPath(const char* path);
|
||||||
};
|
};
|
||||||
} // namespace Game
|
} // namespace Game
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "Def.h"
|
|
||||||
#include "Generated.h"
|
#include "Generated.h"
|
||||||
|
|
||||||
namespace Generated
|
namespace Generated
|
||||||
@@ -125,6 +124,44 @@ namespace Generated
|
|||||||
}
|
}
|
||||||
return isOk;
|
return isOk;
|
||||||
}
|
}
|
||||||
|
bool Save(const AssetHandle* obj, uint32_t count, Serializer& serializer)
|
||||||
|
{
|
||||||
|
bool isOk = true;
|
||||||
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
isOk = Save(&obj[i].Idx, 1, serializer) && isOk;
|
||||||
|
}
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
|
bool Load(AssetHandle* obj, uint32_t count, Deserializer& serializer)
|
||||||
|
{
|
||||||
|
bool isOk = true;
|
||||||
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
isOk = Load(&obj[i].Idx, 1, serializer) && isOk;
|
||||||
|
}
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
|
bool Save(const ModelHandle* obj, uint32_t count, Serializer& serializer)
|
||||||
|
{
|
||||||
|
bool isOk = true;
|
||||||
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
isOk = Save(&obj[i].ModelIdx, 1, serializer) && isOk;
|
||||||
|
isOk = Save(&obj[i].Asset, 1, serializer) && isOk;
|
||||||
|
}
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
|
bool Load(ModelHandle* obj, uint32_t count, Deserializer& serializer)
|
||||||
|
{
|
||||||
|
bool isOk = true;
|
||||||
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
isOk = Load(&obj[i].ModelIdx, 1, serializer) && isOk;
|
||||||
|
isOk = Load(&obj[i].Asset, 1, serializer) && isOk;
|
||||||
|
}
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
bool Save(const PuzPos* obj, uint32_t count, Serializer& serializer)
|
bool Save(const PuzPos* obj, uint32_t count, Serializer& serializer)
|
||||||
{
|
{
|
||||||
bool isOk = true;
|
bool isOk = true;
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include "Def.h"
|
||||||
|
|
||||||
namespace Generated
|
namespace Generated
|
||||||
{
|
{
|
||||||
struct Serializer;
|
|
||||||
struct Deserializer;
|
|
||||||
struct PuzzleElementType
|
struct PuzzleElementType
|
||||||
{
|
{
|
||||||
static constexpr int32_t EntryCount = 8;
|
|
||||||
static constexpr uint32_t Hash = 2024002654;
|
static constexpr uint32_t Hash = 2024002654;
|
||||||
|
static constexpr int32_t EntryCount = 8;
|
||||||
enum Enum : int32_t
|
enum Enum : int32_t
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
@@ -94,6 +92,17 @@ namespace Generated
|
|||||||
0.0f, 0.0f, 0.0f, 1.0f
|
0.0f, 0.0f, 0.0f, 1.0f
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
struct AssetHandle
|
||||||
|
{
|
||||||
|
static constexpr uint32_t Hash = 2609735487;
|
||||||
|
uint32_t Idx = UINT32_MAX;
|
||||||
|
};
|
||||||
|
struct ModelHandle
|
||||||
|
{
|
||||||
|
static constexpr uint32_t Hash = 298089627;
|
||||||
|
uint16_t ModelIdx = UINT16_MAX;
|
||||||
|
AssetHandle Asset = {};
|
||||||
|
};
|
||||||
struct PuzPos
|
struct PuzPos
|
||||||
{
|
{
|
||||||
static constexpr uint32_t Hash = 1834398141;
|
static constexpr uint32_t Hash = 1834398141;
|
||||||
@@ -102,9 +111,9 @@ namespace Generated
|
|||||||
};
|
};
|
||||||
struct StaticPuzzleCard
|
struct StaticPuzzleCard
|
||||||
{
|
{
|
||||||
static constexpr uint32_t Hash = 1414289929;
|
static constexpr uint32_t Hash = 2851442461;
|
||||||
PuzzleElementType::Enum Elements[4] = {};
|
PuzzleElementType::Enum Elements[4] = {};
|
||||||
uint32_t ModelHandle = {};
|
ModelHandle ModelHandle = {};
|
||||||
};
|
};
|
||||||
struct StaticPuzzleCardHandle
|
struct StaticPuzzleCardHandle
|
||||||
{
|
{
|
||||||
@@ -113,7 +122,7 @@ namespace Generated
|
|||||||
};
|
};
|
||||||
struct StaticPuzzleData
|
struct StaticPuzzleData
|
||||||
{
|
{
|
||||||
static constexpr uint32_t Hash = 84985581;
|
static constexpr uint32_t Hash = 4204694691;
|
||||||
StaticPuzzleCard Cards[64] = {};
|
StaticPuzzleCard Cards[64] = {};
|
||||||
};
|
};
|
||||||
struct PuzzleCardStack
|
struct PuzzleCardStack
|
||||||
@@ -157,6 +166,10 @@ namespace Generated
|
|||||||
bool Load(Mat3* obj, uint32_t count, Deserializer& serializer);
|
bool Load(Mat3* obj, uint32_t count, Deserializer& serializer);
|
||||||
bool Save(const Mat4* obj, uint32_t count, Serializer& serializer);
|
bool Save(const Mat4* obj, uint32_t count, Serializer& serializer);
|
||||||
bool Load(Mat4* obj, uint32_t count, Deserializer& serializer);
|
bool Load(Mat4* obj, uint32_t count, Deserializer& serializer);
|
||||||
|
bool Save(const AssetHandle* obj, uint32_t count, Serializer& serializer);
|
||||||
|
bool Load(AssetHandle* obj, uint32_t count, Deserializer& serializer);
|
||||||
|
bool Save(const ModelHandle* obj, uint32_t count, Serializer& serializer);
|
||||||
|
bool Load(ModelHandle* obj, uint32_t count, Deserializer& serializer);
|
||||||
bool Save(const PuzPos* obj, uint32_t count, Serializer& serializer);
|
bool Save(const PuzPos* obj, uint32_t count, Serializer& serializer);
|
||||||
bool Load(PuzPos* obj, uint32_t count, Deserializer& serializer);
|
bool Load(PuzPos* obj, uint32_t count, Deserializer& serializer);
|
||||||
bool Save(const StaticPuzzleCard* obj, uint32_t count, Serializer& serializer);
|
bool Save(const StaticPuzzleCard* obj, uint32_t count, Serializer& serializer);
|
||||||
|
|||||||
Reference in New Issue
Block a user