working sockets
This commit is contained in:
BIN
assets/blender/Channels.blend
LFS
BIN
assets/blender/Channels.blend
LFS
Binary file not shown.
@@ -320,6 +320,14 @@ namespace Gen
|
|||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mat4 RotationFromQuaternion(const Vec4& quaternion)
|
||||||
|
{
|
||||||
|
Mat4 mat;
|
||||||
|
bx::Quaternion quat{quaternion.x, quaternion.y, quaternion.z, quaternion.w};
|
||||||
|
bx::mtxFromQuaternion(mat.M, quat);
|
||||||
|
return mat;
|
||||||
|
}
|
||||||
|
|
||||||
float Magnitude(const Vec4& vec)
|
float Magnitude(const Vec4& vec)
|
||||||
{
|
{
|
||||||
return bx::sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z + vec.w * vec.w);
|
return bx::sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z + vec.w * vec.w);
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ namespace Gen
|
|||||||
|
|
||||||
Vec3 EulerFromRotation(const Mat4& rotation);
|
Vec3 EulerFromRotation(const Mat4& rotation);
|
||||||
Mat4 RotationFromEuler(const Vec3& euler);
|
Mat4 RotationFromEuler(const Vec3& euler);
|
||||||
|
Mat4 RotationFromQuaternion(const Vec4& quaternion);
|
||||||
|
|
||||||
float DotProduct(Vec3 a, Vec3 b);
|
float DotProduct(Vec3 a, Vec3 b);
|
||||||
Vec3 CrossProduct(Vec3 a, Vec3 b);
|
Vec3 CrossProduct(Vec3 a, Vec3 b);
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ namespace Game
|
|||||||
needReset |= Cubes.Setup(storagePtr, needReset);
|
needReset |= Cubes.Setup(storagePtr, needReset);
|
||||||
needReset |= Tests.Setup(storagePtr, needReset);
|
needReset |= Tests.Setup(storagePtr, needReset);
|
||||||
needReset |= PuzzleTiles.Setup(storagePtr, needReset);
|
needReset |= PuzzleTiles.Setup(storagePtr, needReset);
|
||||||
|
needReset |= PuzzleTileCovers.Setup(storagePtr, needReset);
|
||||||
needReset |= UIQuads.Setup(storagePtr, needReset);
|
needReset |= UIQuads.Setup(storagePtr, needReset);
|
||||||
needReset |= LevelEntities.Setup(storagePtr, needReset);
|
needReset |= LevelEntities.Setup(storagePtr, needReset);
|
||||||
|
|
||||||
@@ -179,6 +180,7 @@ namespace Game
|
|||||||
|
|
||||||
UIQuads.Count = 0;
|
UIQuads.Count = 0;
|
||||||
PuzzleTiles.Count = 0;
|
PuzzleTiles.Count = 0;
|
||||||
|
PuzzleTileCovers.Count = 0;
|
||||||
for (int32_t i = 0; i < BX_COUNTOF(Puzzles); ++i)
|
for (int32_t i = 0; i < BX_COUNTOF(Puzzles); ++i)
|
||||||
{
|
{
|
||||||
if (Puzzles[i].Data.ID != UINT16_MAX)
|
if (Puzzles[i].Data.ID != UINT16_MAX)
|
||||||
@@ -324,6 +326,7 @@ namespace Game
|
|||||||
Cubes.Render(models, materials, textures);
|
Cubes.Render(models, materials, textures);
|
||||||
Tests.Render(models, materials, textures);
|
Tests.Render(models, materials, textures);
|
||||||
PuzzleTiles.Render(models, materials, textures);
|
PuzzleTiles.Render(models, materials, textures);
|
||||||
|
PuzzleTileCovers.Render(models, materials, textures);
|
||||||
if (player.InteractionM == InteractionMode::ReadTablet)
|
if (player.InteractionM == InteractionMode::ReadTablet)
|
||||||
{
|
{
|
||||||
UIQuads.Render(models, materials, textures);
|
UIQuads.Render(models, materials, textures);
|
||||||
@@ -358,6 +361,14 @@ namespace Game
|
|||||||
auto& tile = level.PuzzleTiles.Get(TileHandles[i]);
|
auto& tile = level.PuzzleTiles.Get(TileHandles[i]);
|
||||||
tile.EData.MaterialHandle = EMaterial::Default;
|
tile.EData.MaterialHandle = EMaterial::Default;
|
||||||
|
|
||||||
|
for (int32_t j = 0; j < Puzzle::Config::MaxCoversInTile; ++j)
|
||||||
|
{
|
||||||
|
int32_t idx = i * Puzzle::Config::MaxCoversInTile + j;
|
||||||
|
CoverHandles[idx] = level.PuzzleTileCovers.New();
|
||||||
|
auto& cover = level.PuzzleTileCovers.Get(CoverHandles[idx]);
|
||||||
|
cover.EData.Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
UIPlacedCards[i] = level.UIQuads.New();
|
UIPlacedCards[i] = level.UIQuads.New();
|
||||||
auto& quad = level.UIQuads.Get(UIPlacedCards[i]);
|
auto& quad = level.UIQuads.Get(UIPlacedCards[i]);
|
||||||
quad.EData.ModelH = GameRendering::Get().GetModelHandleFromPath("models/plane.glb");
|
quad.EData.ModelH = GameRendering::Get().GetModelHandleFromPath("models/plane.glb");
|
||||||
@@ -518,11 +529,12 @@ namespace Game
|
|||||||
auto& quad = level.UIQuads.Get(UIPlacedCards[cardIdx]);
|
auto& quad = level.UIQuads.Get(UIPlacedCards[cardIdx]);
|
||||||
|
|
||||||
bool isValid = Puzzle::IsValid(card.RefCard);
|
bool isValid = Puzzle::IsValid(card.RefCard);
|
||||||
|
auto& staticCard = isValid ? staticCards[card.RefCard.Idx] : staticCards[0];
|
||||||
|
|
||||||
// World Tile
|
// World Tile
|
||||||
tile.EData.Visible = IsActive;
|
tile.EData.Visible = IsActive;
|
||||||
tile.EData.ModelH =
|
tile.EData.ModelH = staticCard.BaseModelHandle;
|
||||||
isValid ? staticCards[card.RefCard.Idx].BaseModelHandle : staticCards[0].BaseModelHandle;
|
|
||||||
tile.EData.DotColor = visuals.TileDotColor;
|
tile.EData.DotColor = visuals.TileDotColor;
|
||||||
tile.EData.BaseColor = visuals.TileBaseColor;
|
tile.EData.BaseColor = visuals.TileBaseColor;
|
||||||
|
|
||||||
@@ -538,6 +550,22 @@ namespace Game
|
|||||||
tile.EData.Transform.Position = cardPos;
|
tile.EData.Transform.Position = 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);
|
||||||
|
|
||||||
|
// Covers
|
||||||
|
if (IsValid(staticCard.BaseModelHandle))
|
||||||
|
{
|
||||||
|
auto& model = GameRendering::Get().Models[staticCard.BaseModelHandle.ModelIdx];
|
||||||
|
for (int32_t i = 0; i < model.SocketCount; ++i)
|
||||||
|
{
|
||||||
|
auto& cover =
|
||||||
|
level.PuzzleTileCovers.Get(CoverHandles[cardIdx * Puzzle::Config::MaxCoversInTile + i]);
|
||||||
|
cover.EData.Visible = true;
|
||||||
|
cover.EData.ModelH = staticCard.Sockets[i].Model;
|
||||||
|
cover.EData.Transform = tile.EData.Transform;
|
||||||
|
Gen::TranslateLocal(cover.EData.Transform, model.Sockets[i].Pos);
|
||||||
|
Gen::RotateLocal(cover.EData.Transform, Gen::EulerFromRotation(model.Sockets[i].Rot));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// UI Quad
|
// UI Quad
|
||||||
quad.EData.Visible = isValid && IsActive;
|
quad.EData.Visible = isValid && IsActive;
|
||||||
quad.EData.TextureHandle =
|
quad.EData.TextureHandle =
|
||||||
|
|||||||
@@ -57,6 +57,12 @@ namespace Game
|
|||||||
EntityRenderData EData;
|
EntityRenderData EData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ENTITY_HANDLE(PuzzleTileCoverHandle);
|
||||||
|
struct PuzzleTileCover
|
||||||
|
{
|
||||||
|
EntityRenderData EData;
|
||||||
|
};
|
||||||
|
|
||||||
ENTITY_HANDLE(UIQuadEntityHandle);
|
ENTITY_HANDLE(UIQuadEntityHandle);
|
||||||
struct UIQuadEntity
|
struct UIQuadEntity
|
||||||
{
|
{
|
||||||
@@ -148,6 +154,7 @@ namespace Game
|
|||||||
Gen::PuzzleData Data;
|
Gen::PuzzleData Data;
|
||||||
Gen::Vec3 WorldPosition;
|
Gen::Vec3 WorldPosition;
|
||||||
PuzzleTileEntityHandle TileHandles[Puzzle::Config::MaxCardsInPuzzle];
|
PuzzleTileEntityHandle TileHandles[Puzzle::Config::MaxCardsInPuzzle];
|
||||||
|
PuzzleTileCoverHandle CoverHandles[Puzzle::Config::MaxCardsInPuzzle * Puzzle::Config::MaxCoversInTile];
|
||||||
UIQuadEntityHandle UIPlacedCards[Puzzle::Config::MaxCardsInPuzzle];
|
UIQuadEntityHandle UIPlacedCards[Puzzle::Config::MaxCardsInPuzzle];
|
||||||
UIQuadEntityHandle UIAvailableCards[Puzzle::Config::MaxAvailableStacks * UIAvailableCardMaxStackPreview];
|
UIQuadEntityHandle UIAvailableCards[Puzzle::Config::MaxAvailableStacks * UIAvailableCardMaxStackPreview];
|
||||||
Gen::PuzPos DraggedCard{-1, -1};
|
Gen::PuzPos DraggedCard{-1, -1};
|
||||||
@@ -164,8 +171,9 @@ namespace Game
|
|||||||
public:
|
public:
|
||||||
EntityManager<Cube, CubeHandle, 1024> Cubes;
|
EntityManager<Cube, CubeHandle, 1024> Cubes;
|
||||||
EntityManager<TestEntity, TestEntityHandle, 32> Tests;
|
EntityManager<TestEntity, TestEntityHandle, 32> Tests;
|
||||||
EntityManager<PuzzleTileEntity, PuzzleTileEntityHandle, 1024> PuzzleTiles;
|
EntityManager<PuzzleTileEntity, PuzzleTileEntityHandle, Puzzle::Config::MaxTilesTotal> PuzzleTiles;
|
||||||
EntityManager<UIQuadEntity, UIQuadEntityHandle, 1024> UIQuads;
|
EntityManager<PuzzleTileCover, PuzzleTileCoverHandle, Puzzle::Config::MaxCoversTotal> PuzzleTileCovers;
|
||||||
|
EntityManager<UIQuadEntity, UIQuadEntityHandle, Puzzle::Config::MaxTilesInPuzzle * 2> UIQuads;
|
||||||
EntityManager<LevelEntity, LevelEntityHandle, 64> LevelEntities;
|
EntityManager<LevelEntity, LevelEntityHandle, 64> LevelEntities;
|
||||||
|
|
||||||
CubeHandle PlayerOutsideViewCube;
|
CubeHandle PlayerOutsideViewCube;
|
||||||
@@ -173,7 +181,7 @@ namespace Game
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Gen::StaticPuzzleData PuzzleData;
|
Gen::StaticPuzzleData PuzzleData;
|
||||||
WorldPuzzle Puzzles[3];
|
WorldPuzzle Puzzles[Puzzle::Config::MaxVisiblePuzzles];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Setup(GameData& data);
|
void Setup(GameData& data);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "Gen.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Mesh.h"
|
#include "Mesh.h"
|
||||||
@@ -92,6 +93,39 @@ namespace Game
|
|||||||
}
|
}
|
||||||
mesh.VertexBuffer = bgfx::createVertexBuffer(vbMem, mesh.VertLayout);
|
mesh.VertexBuffer = bgfx::createVertexBuffer(vbMem, mesh.VertLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto& node : model.nodes)
|
||||||
|
{
|
||||||
|
if (bx::strFindI(node.name.c_str(), "_slot_").getLength() > 0)
|
||||||
|
{
|
||||||
|
if (mesh.SocketCount >= mesh.MaxSocketCount)
|
||||||
|
{
|
||||||
|
LOG_WARN("Too many sockets on mesh!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto& socket = mesh.Sockets[mesh.SocketCount];
|
||||||
|
if (node.translation.size() >= 3)
|
||||||
|
{
|
||||||
|
socket.Pos.x = node.translation[0];
|
||||||
|
socket.Pos.y = node.translation[1];
|
||||||
|
socket.Pos.z = node.translation[2];
|
||||||
|
}
|
||||||
|
if (node.rotation.size() >= 4)
|
||||||
|
{
|
||||||
|
socket.Rot = Gen::RotationFromQuaternion({static_cast<float>(node.rotation[0]),
|
||||||
|
static_cast<float>(node.rotation[1]),
|
||||||
|
static_cast<float>(node.rotation[2]),
|
||||||
|
static_cast<float>(node.rotation[3])});
|
||||||
|
}
|
||||||
|
if (node.matrix.size() >= 0)
|
||||||
|
{
|
||||||
|
LOG_WARN("TODO: support matrix!");
|
||||||
|
}
|
||||||
|
bx::strCopy(&socket.Name[0], socket.MaxSocketNameLength, node.name.c_str());
|
||||||
|
++mesh.SocketCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,16 +12,19 @@ namespace Puzzle
|
|||||||
|
|
||||||
struct Config
|
struct Config
|
||||||
{
|
{
|
||||||
|
static constexpr uint32_t MaxVisiblePuzzles = 3;
|
||||||
static constexpr uint32_t CardSize = 2;
|
static constexpr uint32_t CardSize = 2;
|
||||||
static constexpr uint32_t NodesPerCard = CardSize * CardSize;
|
static constexpr uint32_t NodesPerCard = CardSize * CardSize;
|
||||||
static constexpr uint32_t MaxElementsPerTile = 4;
|
|
||||||
static constexpr uint32_t MaxPuzzleSizeCards = 16;
|
static constexpr uint32_t MaxPuzzleSizeCards = 16;
|
||||||
static constexpr uint32_t MaxCardsInPuzzle = MaxPuzzleSizeCards * MaxPuzzleSizeCards;
|
static constexpr uint32_t MaxCardsInPuzzle = MaxPuzzleSizeCards * MaxPuzzleSizeCards;
|
||||||
static constexpr uint32_t MaxPuzzleSizeTiles = 16 * CardSize;
|
static constexpr uint32_t MaxPuzzleSizeTiles = 16 * CardSize;
|
||||||
static constexpr uint32_t MaxTilesInPuzzle = MaxPuzzleSizeTiles * MaxPuzzleSizeTiles;
|
static constexpr uint32_t MaxTilesInPuzzle = MaxPuzzleSizeTiles * MaxPuzzleSizeTiles;
|
||||||
|
static constexpr uint32_t MaxTilesTotal = MaxTilesInPuzzle * MaxVisiblePuzzles;
|
||||||
static constexpr uint32_t MaxAvailableStacks = 16;
|
static constexpr uint32_t MaxAvailableStacks = 16;
|
||||||
static constexpr uint32_t MaxGoalPositions = 16;
|
static constexpr uint32_t MaxGoalPositions = 16;
|
||||||
static constexpr float CardScaleWorld = 10.0f;
|
static constexpr float CardScaleWorld = 10.0f;
|
||||||
|
static constexpr uint32_t MaxCoversInTile = 8;
|
||||||
|
static constexpr uint32_t MaxCoversTotal = MaxCoversInTile * MaxTilesTotal;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Setup();
|
void Setup();
|
||||||
|
|||||||
@@ -421,14 +421,17 @@ namespace Tools
|
|||||||
|
|
||||||
Tools::ModelDropdown(card.BaseModelHandle);
|
Tools::ModelDropdown(card.BaseModelHandle);
|
||||||
Tools::TextureDropdown(card.BoardTextureHandle);
|
Tools::TextureDropdown(card.BoardTextureHandle);
|
||||||
if (ImGui::TreeNodeEx("Covers"))
|
if (IsValid(card.BaseModelHandle))
|
||||||
{
|
{
|
||||||
Tools::ModelDropdown(card.NorthCoverHandle, "North Cover");
|
auto& mdl = rendering.Models[card.BaseModelHandle.ModelIdx];
|
||||||
Tools::ModelDropdown(card.EastCoverHandle, "East Cover");
|
if (mdl.SocketCount > 0 && ImGui::TreeNodeEx("Slots"))
|
||||||
Tools::ModelDropdown(card.SouthCoverHandle, "South Cover");
|
{
|
||||||
Tools::ModelDropdown(card.WestCoverHandle, "West Cover");
|
for (int32_t sIdx = 0; sIdx < mdl.SocketCount; ++sIdx)
|
||||||
|
{
|
||||||
ImGui::TreePop();
|
Tools::ModelDropdown(card.Sockets[sIdx].Model, mdl.Sockets[sIdx].Name);
|
||||||
|
}
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Text("Card");
|
ImGui::Text("Card");
|
||||||
|
|||||||
BIN
src/game/data/puzzles/0.pzl
LFS
BIN
src/game/data/puzzles/0.pzl
LFS
Binary file not shown.
Binary file not shown.
@@ -82,6 +82,11 @@ enum PuzzleElementType(u8)
|
|||||||
Bridge GameName("Bridge") ShortName("#")
|
Bridge GameName("Bridge") ShortName("#")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CardSocket
|
||||||
|
{
|
||||||
|
ModelHandle Model
|
||||||
|
}
|
||||||
|
|
||||||
type StaticPuzzleCard
|
type StaticPuzzleCard
|
||||||
{
|
{
|
||||||
PuzzleElementType Elements Arr(4)
|
PuzzleElementType Elements Arr(4)
|
||||||
@@ -90,6 +95,7 @@ type StaticPuzzleCard
|
|||||||
ModelHandle EastCoverHandle
|
ModelHandle EastCoverHandle
|
||||||
ModelHandle SouthCoverHandle
|
ModelHandle SouthCoverHandle
|
||||||
ModelHandle WestCoverHandle
|
ModelHandle WestCoverHandle
|
||||||
|
CardSocket Sockets Arr(16)
|
||||||
TextureHandle ModelTextureHandle
|
TextureHandle ModelTextureHandle
|
||||||
TextureHandle BoardTextureHandle
|
TextureHandle BoardTextureHandle
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,12 +32,23 @@ namespace Game
|
|||||||
Gen::TextureHandle TexHandle;
|
Gen::TextureHandle TexHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ModelSocket
|
||||||
|
{
|
||||||
|
static constexpr uint16_t MaxSocketNameLength = 64;
|
||||||
|
Gen::Vec3 Pos;
|
||||||
|
Gen::Mat4 Rot;
|
||||||
|
char Name[MaxSocketNameLength]{};
|
||||||
|
};
|
||||||
|
|
||||||
struct Model
|
struct Model
|
||||||
{
|
{
|
||||||
|
static constexpr uint16_t MaxSocketCount = 16;
|
||||||
bgfx::VertexBufferHandle VertexBuffer = {bgfx::kInvalidHandle};
|
bgfx::VertexBufferHandle VertexBuffer = {bgfx::kInvalidHandle};
|
||||||
bgfx::IndexBufferHandle IndexBuffer = {bgfx::kInvalidHandle};
|
bgfx::IndexBufferHandle IndexBuffer = {bgfx::kInvalidHandle};
|
||||||
bgfx::VertexLayout VertLayout;
|
bgfx::VertexLayout VertLayout;
|
||||||
Gen::ModelHandle Handle;
|
Gen::ModelHandle Handle;
|
||||||
|
uint16_t SocketCount = 0;
|
||||||
|
ModelSocket Sockets[MaxSocketCount];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Material
|
struct Material
|
||||||
|
|||||||
@@ -1275,6 +1275,92 @@ namespace Gen
|
|||||||
assert(isOk);
|
assert(isOk);
|
||||||
return isOk;
|
return isOk;
|
||||||
}
|
}
|
||||||
|
bool Save(const CardSocket* obj, uint32_t count, Serializer& serializer)
|
||||||
|
{
|
||||||
|
bool isOk = true;
|
||||||
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
isOk = Save(&obj[i].Model, 1, serializer) && isOk;
|
||||||
|
}
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
|
bool Load(CardSocket* obj, uint32_t count, Deserializer& serializer)
|
||||||
|
{
|
||||||
|
const char* typeName = Meta::Metadata.TypeDefinitions[CardSocket::TypeIdx].Name;
|
||||||
|
|
||||||
|
// Quick match
|
||||||
|
int32_t matchedHashIdx =
|
||||||
|
serializer.TypeBuf.FindHash(Meta::Metadata.TypeDefinitions[CardSocket::TypeIdx].Hash);
|
||||||
|
if (matchedHashIdx >= 0)
|
||||||
|
{
|
||||||
|
assert(bx::strCmp(serializer.TypeBuf.Defs[matchedHashIdx].Name, typeName) == 0);
|
||||||
|
bool isOk = true;
|
||||||
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
isOk = Load(&obj[i].Model, 1, serializer) && isOk;
|
||||||
|
}
|
||||||
|
// if we're not ok here, something went really wrong
|
||||||
|
assert(isOk);
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Failed to resolve hash, the type definition chaned since the file was saved! try to match by name.
|
||||||
|
int32_t nameMatchIdx = serializer.TypeBuf.FindDefByName(typeName);
|
||||||
|
if (nameMatchIdx < 0)
|
||||||
|
{
|
||||||
|
// Name match failed, caller has to handle this and potentially skip some bytes
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Successfully matched name, but we need to follow the definition of the file now!
|
||||||
|
const Meta::TypeDef& matchedDef = serializer.TypeBuf.Defs[nameMatchIdx];
|
||||||
|
|
||||||
|
// Figure out new member mapping
|
||||||
|
uint64_t WriteDestinations[64];
|
||||||
|
for (int32_t i = 0; i < BX_COUNTOF(WriteDestinations); ++i)
|
||||||
|
{
|
||||||
|
WriteDestinations[i] = UINT64_MAX;
|
||||||
|
}
|
||||||
|
for (uint32_t i = 0; i < matchedDef.ChildCount; ++i)
|
||||||
|
{
|
||||||
|
const bx::StringView memberName = {&serializer.MemberNameBuf[matchedDef.MemberNameIndices[i].Offset], matchedDef.MemberNameIndices[i].Size};
|
||||||
|
const char* memberTypeName = serializer.TypeBuf.Defs[matchedDef.ChildIndices[i]].Name;
|
||||||
|
if (bx::strCmp(memberName, "Model") == 0 && bx::strCmp(memberTypeName, "ModelHandle") == 0)
|
||||||
|
{
|
||||||
|
WriteDestinations[i] = offsetof(CardSocket, Model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start reading in file order, skipping things that we don't know by name and type
|
||||||
|
bool isOk = true;
|
||||||
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
uint8_t* objBasePtr = reinterpret_cast<uint8_t*>(&obj[i]);
|
||||||
|
|
||||||
|
for (uint32_t j = 0; j < matchedDef.ChildCount; ++j)
|
||||||
|
{
|
||||||
|
const Meta::TypeDef& childDef = serializer.TypeBuf.Defs[matchedDef.ChildIndices[j]];
|
||||||
|
const bx::StringView memberName = {&serializer.MemberNameBuf[matchedDef.MemberNameIndices[j].Offset], matchedDef.MemberNameIndices[j].Size};
|
||||||
|
if (WriteDestinations[j] == UINT64_MAX)
|
||||||
|
{
|
||||||
|
// Unknown member name or type changed
|
||||||
|
uint16_t count = bx::max(1, matchedDef.ChildArraySizes[matchedDef.ChildIndices[j]]);
|
||||||
|
serializer.Skip(childDef.Size * count);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bx::strCmp(memberName, "Model") == 0)
|
||||||
|
{
|
||||||
|
auto* fieldPtr = reinterpret_cast<ModelHandle*>(objBasePtr + WriteDestinations[j]);
|
||||||
|
isOk = Load(fieldPtr, 1, serializer) && isOk;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(isOk);
|
||||||
|
return isOk;
|
||||||
|
}
|
||||||
bool Save(const StaticPuzzleCard* obj, uint32_t count, Serializer& serializer)
|
bool Save(const StaticPuzzleCard* obj, uint32_t count, Serializer& serializer)
|
||||||
{
|
{
|
||||||
bool isOk = true;
|
bool isOk = true;
|
||||||
@@ -1286,6 +1372,7 @@ namespace Gen
|
|||||||
isOk = Save(&obj[i].EastCoverHandle, 1, serializer) && isOk;
|
isOk = Save(&obj[i].EastCoverHandle, 1, serializer) && isOk;
|
||||||
isOk = Save(&obj[i].SouthCoverHandle, 1, serializer) && isOk;
|
isOk = Save(&obj[i].SouthCoverHandle, 1, serializer) && isOk;
|
||||||
isOk = Save(&obj[i].WestCoverHandle, 1, serializer) && isOk;
|
isOk = Save(&obj[i].WestCoverHandle, 1, serializer) && isOk;
|
||||||
|
isOk = Save(obj[i].Sockets, 16, serializer) && isOk;
|
||||||
isOk = Save(&obj[i].ModelTextureHandle, 1, serializer) && isOk;
|
isOk = Save(&obj[i].ModelTextureHandle, 1, serializer) && isOk;
|
||||||
isOk = Save(&obj[i].BoardTextureHandle, 1, serializer) && isOk;
|
isOk = Save(&obj[i].BoardTextureHandle, 1, serializer) && isOk;
|
||||||
}
|
}
|
||||||
@@ -1310,6 +1397,7 @@ namespace Gen
|
|||||||
isOk = Load(&obj[i].EastCoverHandle, 1, serializer) && isOk;
|
isOk = Load(&obj[i].EastCoverHandle, 1, serializer) && isOk;
|
||||||
isOk = Load(&obj[i].SouthCoverHandle, 1, serializer) && isOk;
|
isOk = Load(&obj[i].SouthCoverHandle, 1, serializer) && isOk;
|
||||||
isOk = Load(&obj[i].WestCoverHandle, 1, serializer) && isOk;
|
isOk = Load(&obj[i].WestCoverHandle, 1, serializer) && isOk;
|
||||||
|
isOk = Load(obj[i].Sockets, 16, serializer) && isOk;
|
||||||
isOk = Load(&obj[i].ModelTextureHandle, 1, serializer) && isOk;
|
isOk = Load(&obj[i].ModelTextureHandle, 1, serializer) && isOk;
|
||||||
isOk = Load(&obj[i].BoardTextureHandle, 1, serializer) && isOk;
|
isOk = Load(&obj[i].BoardTextureHandle, 1, serializer) && isOk;
|
||||||
}
|
}
|
||||||
@@ -1363,6 +1451,10 @@ namespace Gen
|
|||||||
{
|
{
|
||||||
WriteDestinations[i] = offsetof(StaticPuzzleCard, WestCoverHandle);
|
WriteDestinations[i] = offsetof(StaticPuzzleCard, WestCoverHandle);
|
||||||
}
|
}
|
||||||
|
if (bx::strCmp(memberName, "Sockets") == 0 && bx::strCmp(memberTypeName, "CardSocket") == 0)
|
||||||
|
{
|
||||||
|
WriteDestinations[i] = offsetof(StaticPuzzleCard, Sockets);
|
||||||
|
}
|
||||||
if (bx::strCmp(memberName, "ModelTextureHandle") == 0 && bx::strCmp(memberTypeName, "TextureHandle") == 0)
|
if (bx::strCmp(memberName, "ModelTextureHandle") == 0 && bx::strCmp(memberTypeName, "TextureHandle") == 0)
|
||||||
{
|
{
|
||||||
WriteDestinations[i] = offsetof(StaticPuzzleCard, ModelTextureHandle);
|
WriteDestinations[i] = offsetof(StaticPuzzleCard, ModelTextureHandle);
|
||||||
@@ -1427,6 +1519,12 @@ namespace Gen
|
|||||||
isOk = Load(fieldPtr, 1, serializer) && isOk;
|
isOk = Load(fieldPtr, 1, serializer) && isOk;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (bx::strCmp(memberName, "Sockets") == 0)
|
||||||
|
{
|
||||||
|
auto* fieldPtr = reinterpret_cast<CardSocket*>(objBasePtr + WriteDestinations[j]);
|
||||||
|
isOk = Load(fieldPtr, 16, serializer) && isOk;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (bx::strCmp(memberName, "ModelTextureHandle") == 0)
|
if (bx::strCmp(memberName, "ModelTextureHandle") == 0)
|
||||||
{
|
{
|
||||||
auto* fieldPtr = reinterpret_cast<TextureHandle*>(objBasePtr + WriteDestinations[j]);
|
auto* fieldPtr = reinterpret_cast<TextureHandle*>(objBasePtr + WriteDestinations[j]);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Gen
|
|||||||
struct Deserializer;
|
struct Deserializer;
|
||||||
struct PuzzleElementType
|
struct PuzzleElementType
|
||||||
{
|
{
|
||||||
static constexpr uint16_t TypeIdx = 30;
|
static constexpr uint16_t TypeIdx = 31;
|
||||||
static constexpr int32_t EntryCount = 8;
|
static constexpr int32_t EntryCount = 8;
|
||||||
enum Enum : uint8_t
|
enum Enum : uint8_t
|
||||||
{
|
{
|
||||||
@@ -56,7 +56,7 @@ namespace Gen
|
|||||||
};
|
};
|
||||||
struct EMaterial
|
struct EMaterial
|
||||||
{
|
{
|
||||||
static constexpr uint16_t TypeIdx = 31;
|
static constexpr uint16_t TypeIdx = 32;
|
||||||
static constexpr int32_t EntryCount = 2;
|
static constexpr int32_t EntryCount = 2;
|
||||||
enum Enum : int32_t
|
enum Enum : int32_t
|
||||||
{
|
{
|
||||||
@@ -141,26 +141,32 @@ namespace Gen
|
|||||||
int8_t X = {};
|
int8_t X = {};
|
||||||
int8_t Y = {};
|
int8_t Y = {};
|
||||||
};
|
};
|
||||||
struct StaticPuzzleCard
|
struct CardSocket
|
||||||
{
|
{
|
||||||
static constexpr uint16_t TypeIdx = 22;
|
static constexpr uint16_t TypeIdx = 22;
|
||||||
|
ModelHandle Model = {};
|
||||||
|
};
|
||||||
|
struct StaticPuzzleCard
|
||||||
|
{
|
||||||
|
static constexpr uint16_t TypeIdx = 23;
|
||||||
PuzzleElementType::Enum Elements[4] = {};
|
PuzzleElementType::Enum Elements[4] = {};
|
||||||
ModelHandle BaseModelHandle = {};
|
ModelHandle BaseModelHandle = {};
|
||||||
ModelHandle NorthCoverHandle = {};
|
ModelHandle NorthCoverHandle = {};
|
||||||
ModelHandle EastCoverHandle = {};
|
ModelHandle EastCoverHandle = {};
|
||||||
ModelHandle SouthCoverHandle = {};
|
ModelHandle SouthCoverHandle = {};
|
||||||
ModelHandle WestCoverHandle = {};
|
ModelHandle WestCoverHandle = {};
|
||||||
|
CardSocket Sockets[16] = {};
|
||||||
TextureHandle ModelTextureHandle = {};
|
TextureHandle ModelTextureHandle = {};
|
||||||
TextureHandle BoardTextureHandle = {};
|
TextureHandle BoardTextureHandle = {};
|
||||||
};
|
};
|
||||||
struct StaticPuzzleCardHandle
|
struct StaticPuzzleCardHandle
|
||||||
{
|
{
|
||||||
static constexpr uint16_t TypeIdx = 23;
|
static constexpr uint16_t TypeIdx = 24;
|
||||||
uint16_t Idx = UINT16_MAX;
|
uint16_t Idx = UINT16_MAX;
|
||||||
};
|
};
|
||||||
struct PuzzleVisualSettings
|
struct PuzzleVisualSettings
|
||||||
{
|
{
|
||||||
static constexpr uint16_t TypeIdx = 24;
|
static constexpr uint16_t TypeIdx = 25;
|
||||||
Vec4 TileBaseColor = {};
|
Vec4 TileBaseColor = {};
|
||||||
Vec4 TileDotColor = {};
|
Vec4 TileDotColor = {};
|
||||||
Vec3 Test = {};
|
Vec3 Test = {};
|
||||||
@@ -168,20 +174,20 @@ namespace Gen
|
|||||||
};
|
};
|
||||||
struct StaticPuzzleData
|
struct StaticPuzzleData
|
||||||
{
|
{
|
||||||
static constexpr uint16_t TypeIdx = 25;
|
static constexpr uint16_t TypeIdx = 26;
|
||||||
StaticPuzzleCard Cards[64] = {};
|
StaticPuzzleCard Cards[64] = {};
|
||||||
PuzzleVisualSettings Visuals = {};
|
PuzzleVisualSettings Visuals = {};
|
||||||
};
|
};
|
||||||
struct PuzzleCardStack
|
struct PuzzleCardStack
|
||||||
{
|
{
|
||||||
static constexpr uint16_t TypeIdx = 26;
|
static constexpr uint16_t TypeIdx = 27;
|
||||||
StaticPuzzleCardHandle RefCard = {};
|
StaticPuzzleCardHandle RefCard = {};
|
||||||
uint8_t MaxAvailableCount = {};
|
uint8_t MaxAvailableCount = {};
|
||||||
uint8_t UsedCount = {};
|
uint8_t UsedCount = {};
|
||||||
};
|
};
|
||||||
struct PlacedPuzzleCard
|
struct PlacedPuzzleCard
|
||||||
{
|
{
|
||||||
static constexpr uint16_t TypeIdx = 27;
|
static constexpr uint16_t TypeIdx = 28;
|
||||||
StaticPuzzleCardHandle RefCard = {};
|
StaticPuzzleCardHandle RefCard = {};
|
||||||
PuzPos Position = {};
|
PuzPos Position = {};
|
||||||
uint8_t Rotation = {};
|
uint8_t Rotation = {};
|
||||||
@@ -189,7 +195,7 @@ namespace Gen
|
|||||||
};
|
};
|
||||||
struct PuzzleData
|
struct PuzzleData
|
||||||
{
|
{
|
||||||
static constexpr uint16_t TypeIdx = 28;
|
static constexpr uint16_t TypeIdx = 29;
|
||||||
uint16_t ID = {};
|
uint16_t ID = {};
|
||||||
char PuzzleName[64] = {};
|
char PuzzleName[64] = {};
|
||||||
uint8_t WidthTiles = {};
|
uint8_t WidthTiles = {};
|
||||||
@@ -203,7 +209,7 @@ namespace Gen
|
|||||||
};
|
};
|
||||||
struct SavedEntityRenderData
|
struct SavedEntityRenderData
|
||||||
{
|
{
|
||||||
static constexpr uint16_t TypeIdx = 29;
|
static constexpr uint16_t TypeIdx = 30;
|
||||||
Vec4 BaseColor = {};
|
Vec4 BaseColor = {};
|
||||||
Vec4 HighlightColor = {};
|
Vec4 HighlightColor = {};
|
||||||
Transform TF = {};
|
Transform TF = {};
|
||||||
@@ -260,6 +266,8 @@ namespace Gen
|
|||||||
bool Load(TextureHandle* obj, uint32_t count, Deserializer& serializer);
|
bool Load(TextureHandle* 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 CardSocket* obj, uint32_t count, Serializer& serializer);
|
||||||
|
bool Load(CardSocket* 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);
|
||||||
bool Load(StaticPuzzleCard* obj, uint32_t count, Deserializer& serializer);
|
bool Load(StaticPuzzleCard* obj, uint32_t count, Deserializer& serializer);
|
||||||
bool Save(const StaticPuzzleCardHandle* obj, uint32_t count, Serializer& serializer);
|
bool Save(const StaticPuzzleCardHandle* obj, uint32_t count, Serializer& serializer);
|
||||||
@@ -299,7 +307,7 @@ namespace Gen
|
|||||||
|
|
||||||
struct MetadataTable
|
struct MetadataTable
|
||||||
{
|
{
|
||||||
TypeDef TypeDefinitions[32]
|
TypeDef TypeDefinitions[33]
|
||||||
{
|
{
|
||||||
TypeDef{sizeof(int8_t), 0, "i8", 0, {}, {}, {}},
|
TypeDef{sizeof(int8_t), 0, "i8", 0, {}, {}, {}},
|
||||||
TypeDef{sizeof(int16_t), 1, "i16", 0, {}, {}, {}},
|
TypeDef{sizeof(int16_t), 1, "i16", 0, {}, {}, {}},
|
||||||
@@ -323,18 +331,19 @@ namespace Gen
|
|||||||
TypeDef{sizeof(ModelHandle), 298089627, "ModelHandle", 2, {5, 18}, {0, 0}, {{38, 8}, {46, 5}}},
|
TypeDef{sizeof(ModelHandle), 298089627, "ModelHandle", 2, {5, 18}, {0, 0}, {{38, 8}, {46, 5}}},
|
||||||
TypeDef{sizeof(TextureHandle), 1633273761, "TextureHandle", 2, {5, 18}, {0, 0}, {{51, 10}, {61, 5}}},
|
TypeDef{sizeof(TextureHandle), 1633273761, "TextureHandle", 2, {5, 18}, {0, 0}, {{51, 10}, {61, 5}}},
|
||||||
TypeDef{sizeof(PuzPos), 1834398141, "PuzPos", 2, {0, 0}, {0, 0}, {{66, 1}, {67, 1}}},
|
TypeDef{sizeof(PuzPos), 1834398141, "PuzPos", 2, {0, 0}, {0, 0}, {{66, 1}, {67, 1}}},
|
||||||
TypeDef{sizeof(StaticPuzzleCard), 3247750075, "StaticPuzzleCard", 8, {30, 19, 19, 19, 19, 19, 20, 20}, {4, 0, 0, 0, 0, 0, 0, 0}, {{68, 8}, {76, 15}, {91, 16}, {107, 15}, {122, 16}, {138, 15}, {153, 18}, {171, 18}}},
|
TypeDef{sizeof(CardSocket), 3485485756, "CardSocket", 1, {19}, {0}, {{68, 5}}},
|
||||||
TypeDef{sizeof(StaticPuzzleCardHandle), 1742502768, "StaticPuzzleCardHandle", 1, {5}, {0}, {{189, 3}}},
|
TypeDef{sizeof(StaticPuzzleCard), 1947091475, "StaticPuzzleCard", 9, {31, 19, 19, 19, 19, 19, 22, 20, 20}, {4, 0, 0, 0, 0, 0, 16, 0, 0}, {{73, 8}, {81, 15}, {96, 16}, {112, 15}, {127, 16}, {143, 15}, {158, 7}, {165, 18}, {183, 18}}},
|
||||||
TypeDef{sizeof(PuzzleVisualSettings), 2302077481, "PuzzleVisualSettings", 4, {14, 14, 13, 14}, {0, 0, 0, 0}, {{192, 13}, {205, 12}, {217, 4}, {221, 16}}},
|
TypeDef{sizeof(StaticPuzzleCardHandle), 1742502768, "StaticPuzzleCardHandle", 1, {5}, {0}, {{201, 3}}},
|
||||||
TypeDef{sizeof(StaticPuzzleData), 2707133860, "StaticPuzzleData", 2, {22, 24}, {64, 0}, {{237, 5}, {242, 7}}},
|
TypeDef{sizeof(PuzzleVisualSettings), 2302077481, "PuzzleVisualSettings", 4, {14, 14, 13, 14}, {0, 0, 0, 0}, {{204, 13}, {217, 12}, {229, 4}, {233, 16}}},
|
||||||
TypeDef{sizeof(PuzzleCardStack), 53538532, "PuzzleCardStack", 3, {23, 4, 4}, {0, 0, 0}, {{249, 7}, {256, 17}, {273, 9}}},
|
TypeDef{sizeof(StaticPuzzleData), 19690459, "StaticPuzzleData", 2, {23, 25}, {64, 0}, {{249, 5}, {254, 7}}},
|
||||||
TypeDef{sizeof(PlacedPuzzleCard), 3555575973, "PlacedPuzzleCard", 4, {23, 21, 4, 8}, {0, 0, 0, 0}, {{282, 7}, {289, 8}, {297, 8}, {305, 8}}},
|
TypeDef{sizeof(PuzzleCardStack), 53538532, "PuzzleCardStack", 3, {24, 4, 4}, {0, 0, 0}, {{261, 7}, {268, 17}, {285, 9}}},
|
||||||
TypeDef{sizeof(PuzzleData), 3349686056, "PuzzleData", 10, {5, 11, 4, 4, 6, 26, 27, 30, 6, 21}, {0, 64, 0, 0, 0, 16, 256, 1024, 0, 16}, {{313, 2}, {315, 10}, {325, 10}, {335, 11}, {346, 18}, {364, 14}, {378, 11}, {389, 15}, {404, 17}, {421, 13}}},
|
TypeDef{sizeof(PlacedPuzzleCard), 3555575973, "PlacedPuzzleCard", 4, {24, 21, 4, 8}, {0, 0, 0, 0}, {{294, 7}, {301, 8}, {309, 8}, {317, 8}}},
|
||||||
TypeDef{sizeof(SavedEntityRenderData), 3172756855, "SavedEntityRenderData", 7, {14, 14, 17, 31, 20, 19, 8}, {0, 0, 0, 0, 0, 0, 0}, {{434, 9}, {443, 14}, {457, 2}, {459, 8}, {467, 7}, {474, 5}, {479, 7}}},
|
TypeDef{sizeof(PuzzleData), 3349686056, "PuzzleData", 10, {5, 11, 4, 4, 6, 27, 28, 31, 6, 21}, {0, 64, 0, 0, 0, 16, 256, 1024, 0, 16}, {{325, 2}, {327, 10}, {337, 10}, {347, 11}, {358, 18}, {376, 14}, {390, 11}, {401, 15}, {416, 17}, {433, 13}}},
|
||||||
|
TypeDef{sizeof(SavedEntityRenderData), 3172756855, "SavedEntityRenderData", 7, {14, 14, 17, 32, 20, 19, 8}, {0, 0, 0, 0, 0, 0, 0}, {{446, 9}, {455, 14}, {469, 2}, {471, 8}, {479, 7}, {486, 5}, {491, 7}}},
|
||||||
TypeDef{sizeof(PuzzleElementType::Enum), 2983807453, "PuzzleElementType", 0, {}, {}, {}},
|
TypeDef{sizeof(PuzzleElementType::Enum), 2983807453, "PuzzleElementType", 0, {}, {}, {}},
|
||||||
TypeDef{sizeof(EMaterial::Enum), 2024002654, "EMaterial", 0, {}, {}, {}},
|
TypeDef{sizeof(EMaterial::Enum), 2024002654, "EMaterial", 0, {}, {}, {}},
|
||||||
};
|
};
|
||||||
char MemberNameBuffer[64*64*64]{"xyxyzxyzwMMMMIPositionRotationScaleIdxModelIdxAssetTextureIdxAssetXYElementsBaseModelHandleNorthCoverHandleEastCoverHandleSouthCoverHandleWestCoverHandleModelTextureHandleBoardTextureHandleIdxTileBaseColorTileDotColorTestDisabledCardTintCardsVisualsRefCardMaxAvailableCountUsedCountRefCardPositionRotationIsLockedIDPuzzleNameWidthTilesHeightTilesAvailableCardCountAvailableCardsPlacedCardsBackgroundTilesGoalPositionCountGoalPositionsBaseColorHighlightColorTFMaterialTextureModelVisible"};
|
char MemberNameBuffer[64*64*64]{"xyxyzxyzwMMMMIPositionRotationScaleIdxModelIdxAssetTextureIdxAssetXYModelElementsBaseModelHandleNorthCoverHandleEastCoverHandleSouthCoverHandleWestCoverHandleSocketsModelTextureHandleBoardTextureHandleIdxTileBaseColorTileDotColorTestDisabledCardTintCardsVisualsRefCardMaxAvailableCountUsedCountRefCardPositionRotationIsLockedIDPuzzleNameWidthTilesHeightTilesAvailableCardCountAvailableCardsPlacedCardsBackgroundTilesGoalPositionCountGoalPositionsBaseColorHighlightColorTFMaterialTextureModelVisible"};
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr MetadataTable Metadata;
|
constexpr MetadataTable Metadata;
|
||||||
|
|||||||
BIN
src/models/channel_cover_big.glb
LFS
BIN
src/models/channel_cover_big.glb
LFS
Binary file not shown.
Binary file not shown.
BIN
src/models/w straight.glb
LFS
BIN
src/models/w straight.glb
LFS
Binary file not shown.
Reference in New Issue
Block a user