Skip to content

Commit

Permalink
Finish updating Unreal plugin for refactored Tiled3D
Browse files Browse the repository at this point in the history
  • Loading branch information
heyx3 committed Jun 28, 2022
1 parent e91ec6a commit d9528a0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Binary file modified WFCunreal/Content/SimpleGenerator.uasset
Binary file not shown.
14 changes: 9 additions & 5 deletions WFCunreal/Source/WfcppRuntime/Private/WfcGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ float UWfcGenerator::GetProgress() const
}

bool UWfcGenerator::GetCell(const FIntVector& cellPos,
WfcTileID& out_tileIdx,
WfcTileID& out_tileID,
UObject*& out_tileData,
FWFC_Transform3D& out_tileTransform) const
{
Expand All @@ -40,15 +40,15 @@ bool UWfcGenerator::GetCell(const FIntVector& cellPos,

if (cell.IsSet())
{
out_tileIdx = cell.ChosenTile;
out_tileData = tileset->Tiles[out_tileIdx].Data;
out_tileID = wfcTileIDs[cell.ChosenTile];
out_tileData = tileset->Tiles[out_tileID].Data;
out_tileTransform = { static_cast<WFC_Rotations3D>(cell.ChosenPermutation.Rot),
cell.ChosenPermutation.Invert };
return true;
}
else
{
out_tileIdx = -1;
out_tileID = -1;
out_tileData = nullptr;
out_tileTransform = { WFC_Rotations3D::None, false };
return false;
Expand All @@ -66,6 +66,7 @@ void UWfcGenerator::Start(const UWfcTileset* tiles,
checkf(seed <= std::numeric_limits<uint32_t>().max(),
TEXT("Seed value is more than the max of %i: %i"),
std::numeric_limits<uint32_t>().max(), seed);
checkf(tileset->Tiles.Num() > 0, TEXT("Must have at least 1 tile in the tileset!"))

//Clean up from any previous runs.
if (IsRunning())
Expand All @@ -85,10 +86,13 @@ void UWfcGenerator::Start(const UWfcTileset* tiles,

//Convert each serialized UE4 tile into a WFC library tile.
wfcTileInputs.Clear();
wfcTileIDs.Empty();
TSet<FWFC_Transform3D> buffer_supportedTransforms;
for (const auto& tile : tiles->Tiles)
{
WFC::Tiled3D::Tile wfcTile{ { } };
wfcTileIDs.Add(tile.Key);
wfcTileInputs.PushBack({ { } });
auto& wfcTile = wfcTileInputs.GetBack();

wfcTile.Weight = static_cast<uint32_t>(tile.Value.WeightU32);

Expand Down
1 change: 1 addition & 0 deletions WFCunreal/Source/WfcppRuntime/Public/WfcGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ class UWfcGenerator : public UObject

//Arrays used to build sim inputs on startup.
WFC::List<WFC::Tiled3D::Tile> wfcTileInputs;
TArray<WfcTileID> wfcTileIDs;
};

0 comments on commit d9528a0

Please sign in to comment.