Skip to content

Commit

Permalink
Merge pull request #13 from shun126/1.6.12
Browse files Browse the repository at this point in the history
version 1.6.12
  • Loading branch information
shun126 authored Oct 27, 2024
2 parents be27e1f + 4824b3c commit 62a8f5f
Show file tree
Hide file tree
Showing 50 changed files with 1,430 additions and 415 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# Change Log - Procedural 3D Dungeon Generator Plug-in

## Unreleased-1.6.* (41)
## Unreleased-1.6.* (42)
### Changes
### 変更点

## 20241027-1.6.12 (41)
### Changes
* Deprecated DungeonAisleMeshSetDatabase and DungeonRoomMeshSetDatabase, and introduced DungeonMeshDatabase.
* Fixed an issue where rooms could exceed the maximum size.
* Resolved an issue where sublevels were not unloading properly.
* Fixed activation of main level partitioning during multiplayer
* Fixed several bugs
### 変更点
* DungeonAisleMeshSetDatabaseとDungeonRoomMeshSetDatabaseを非推奨にしてDungeonMeshDatabaseを新設しました
* 部屋が最大サイズよりも大きくなる問題を修正
* サブレベルが解放されない問題を修正
* マルチプレイヤー時のメインレベルのパーティエーションの有効化を修正
* いくつかの不具合を修正

## 20241017-1.6.11 (40)
### Changes
* Added demo map
Expand Down
6 changes: 3 additions & 3 deletions DungeonGenerator.uplugin
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"FileVersion": 3,
"Version": 40,
"VersionName": "1.6.11",
"Version": 41,
"VersionName": "1.6.12",
"FriendlyName": "Procedural Dungeon Generator",
"Description": "Procedural dungeon generator plugin. Easy generation of levels, mini-maps and missions.",
"Description": "Procedural 3d dungeon generator plugin. Easy generation of levels, mini-maps and missions.",
"Category": "Procedural",
"CreatedBy": "Narcis Software",
"CreatedByURL": "https://github.com/shun126/UE5-DungeonGeneratorDemo",
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![stars](https://img.shields.io/github/stars/shun126/DungeonGenerator?style=social)](https://github.com/shun126/DungeonGenerator/stargazers)
[![youtube](https://img.shields.io/youtube/views/HIW4mRt2_AA?style=social)](https://youtu.be/HIW4mRt2_AA)

Please also take a look at the [Unreal Engine marketplace](https://www.unrealengine.com/marketplace/slug/36a8b87d859f44439cfe1515975d7197) version.
Please also take a look at the [Fab](https://www.fab.com/ja/listings/11fce4d9-8996-4323-9aac-9cfacbfb95eb) version.

* Trailer video: [YouTube](https://youtu.be/HIW4mRt2_AA)
* Tutorial videos: [YouTube](https://www.youtube.com/playlist?list=PLlMDkSa8bQnK4PDIfkXYorQIucn47ifKO)
Expand Down Expand Up @@ -39,7 +39,7 @@ The dungeon generator was based on Vazgriz's algorithm. You can read more about
* Users can easily generate dungeons by preparing meshes for floors, walls, ceilings, and stairs.
* Supports dungeon replication
* Generates actors for doors and keys by MissionGraph.
* The following features are supported only in the [Unreal Engine marketplace](https://www.unrealengine.com/marketplace/slug/36a8b87d859f44439cfe1515975d7197) version
* The following features are supported only in the [Fab](https://www.fab.com/ja/listings/11fce4d9-8996-4323-9aac-9cfacbfb95eb) version
* Sub-levels can be applied as dungeon rooms
* A mini-map of the dungeon can be generated.
* Interior decoration. [beta version]
Expand All @@ -56,7 +56,7 @@ you can redistribute it and/or modify it under the terms of the GNU General Publ

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied arranty of MERCHANTABILITY or FITNESS FOR A ARTICULAR PURPOSE. See the GNU General Public License for more details.

Or, [Unreal Engine marketplace](https://www.unrealengine.com/marketplace/slug/36a8b87d859f44439cfe1515975d7197) is releasing it under Epic license. If you need a license other than the GPL, please consider it. Proceeds will be used to fund the development of our game.
Or, [Fab](https://www.fab.com/ja/listings/11fce4d9-8996-4323-9aac-9cfacbfb95eb) is releasing it under Epic license. If you need a license other than the GPL, please consider it. Proceeds will be used to fund the development of our game.

# 👾 Demo
[DungeonGenerator Demo](https://github.com/shun126/UE5-DungeonGeneratorDemo) is a BluePrint sample project for first-person exploration.
Expand All @@ -68,7 +68,7 @@ This is an easy to use. Simply drop the DungeonGenerateActor into your level, se
* [Discussions](https://github.com/shun126/UE5-DungeonGeneratorDemo/discussions)
* [Wiki](https://github.com/shun126/UE5-DungeonGeneratorDemo/wiki)

The [Unreal Engine marketplace](https://www.unrealengine.com/marketplace/slug/36a8b87d859f44439cfe1515975d7197) version includes the following enhancements.
The [Fab](https://www.fab.com/ja/listings/11fce4d9-8996-4323-9aac-9cfacbfb95eb) version includes the following enhancements.
* Sub-levels can be applied as dungeon rooms
* A mini-map of the dungeon can be generated.
* Interior decoration. [beta version]
Expand Down
21 changes: 18 additions & 3 deletions Source/DungeonGenerator/Private/Core/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ namespace dungeon
// 部屋のパーツ(役割)をリセットする
// TODO:MinimumSpanningTreeで統合できそう
room->SetParts(Room::Parts::Unidentified);
room->SetReservationNumber(0);
room->ResetReservationNumber();

// Room::GetGroundCenterリストを作成
// cppcheck-suppress [useStlAlgorithm]
Expand Down Expand Up @@ -1080,13 +1080,28 @@ namespace dungeon
if (room->GetParts() == Room::Parts::Goal && mGenerateParameter.IsGenerateGoalRoomReserved())
continue;

uint32_t width = room->GetWidth();
uint32_t depth = room->GetDepth();
// 部屋の最大サイズにあわせる
uint32_t width = room->GetWidth();
if (width > mGenerateParameter.GetMaxRoomWidth())
{
width = mGenerateParameter.GetMaxRoomWidth();
room->SetWidth(width);
}

uint32_t depth = room->GetDepth();
if (depth > mGenerateParameter.GetMaxRoomDepth())
{
depth = mGenerateParameter.GetMaxRoomDepth();
room->SetDepth(depth);
}

uint32_t height = room->GetHeight();
if (height > mGenerateParameter.GetMaxRoomHeight())
{
height = mGenerateParameter.GetMaxRoomHeight();
room->SetHeight(height);
}

// ドアに対して部屋が小さい場合は広げる
const uint32_t minimumArea = dungeon::math::Square<uint32_t>(room->GetGateCount());
const uint32_t requiredArea = std::max(2u, minimumArea);
Expand Down
1 change: 1 addition & 0 deletions Source/DungeonGenerator/Private/Core/RoomGeneration/Room.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ namespace dungeon
bool IsValidReservationNumber() const noexcept;
uint32_t GetReservationNumber() const noexcept;
void SetReservationNumber(const uint32_t reservationNumber) noexcept;
void ResetReservationNumber() noexcept;


private:
Expand Down
5 changes: 5 additions & 0 deletions Source/DungeonGenerator/Private/Core/RoomGeneration/Room.inl
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,9 @@ namespace dungeon
{
mReservationNumber = reservationNumber;
}

inline void Room::ResetReservationNumber() noexcept
{
SetReservationNumber(0);
}
}
11 changes: 11 additions & 0 deletions Source/DungeonGenerator/Private/Core/Voxelization/Grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ namespace dungeon
*/
bool CanMergeAisle() const noexcept;

/**
* 中二階通路か設定します
*/
void Catwalk(const bool enable) noexcept;

/**
* 中二階通路か取得します
*/
bool IsCatwalk() const noexcept;

public:
/**
グリッドの種類の色を取得します
Expand Down Expand Up @@ -367,6 +377,7 @@ namespace dungeon
NoFloorMeshGeneration,
NoRoofMeshGeneration,
MergeAisle,
Catwalk,
};
static constexpr size_t AttributeSize = static_cast<size_t>(Attribute::MergeAisle) + 1;

Expand Down
11 changes: 11 additions & 0 deletions Source/DungeonGenerator/Private/Core/Voxelization/Grid.inl
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,17 @@ namespace dungeon
return mPack.IsAttributeEnabled(Attribute::MergeAisle);
}

inline void Grid::Catwalk(const bool enable) noexcept
{
mPack.SetAttribute(Attribute::Catwalk, enable);
}

inline bool Grid::IsCatwalk() const noexcept
{
return mPack.IsAttributeEnabled(Attribute::Catwalk);
}



inline Grid::Pack::Pack()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,17 @@ namespace dungeon
if (mValid == false)
return;

// グリッドを生成
// 中二階グリッド属性のみ設定
static_assert(Offsets.empty() == false);
if (Offsets[0].mZ > 0)
{
const FIntVector location = mLocation + FIntVector(Offsets[0].mX, 0, Offsets[0].mZ);
auto grid = voxel->Get(location);
grid.Catwalk(true);
voxel->Set(location, grid);
}

// 中二階グリッドを生成
for (size_t i = 1; i < Offsets.size(); ++i)
{
const auto& offset = Offsets[i];
Expand Down Expand Up @@ -205,6 +215,8 @@ namespace dungeon
auto grid = voxel->Get(ox, oy, oz);
grid.SetType(offset.mGridType);
grid.SetDirection(direction);
if (offset.mZ > 0)
grid.Catwalk(true);
voxel->Set(ox, oy, oz, grid);
}
}
Expand Down
7 changes: 7 additions & 0 deletions Source/DungeonGenerator/Private/Core/Voxelization/Voxel.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ namespace dungeon
*/
void Set(const uint32_t x, const uint32_t y, const uint32_t z, const Grid& grid) const noexcept;

/**
グリッド内のグリッドを設定します
@param[in] location グリッド座標
@param[in] grid グリッド
*/
void Set(const FIntVector& location, const Grid& grid) const noexcept;

/**
矩形の範囲にGridを書き込みます
@param[in] min 最小座標
Expand Down
5 changes: 5 additions & 0 deletions Source/DungeonGenerator/Private/Core/Voxelization/Voxel.inl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ namespace dungeon
return mGrids.get()[index];
}

inline void Voxel::Set(const FIntVector& location, const Grid& grid) const noexcept
{
Set(location.X, location.Y, location.Z, grid);
}

inline Grid& Voxel::operator[](const size_t index) noexcept
{
check(index < static_cast<size_t>(mWidth) * mDepth * mHeight);
Expand Down
11 changes: 0 additions & 11 deletions Source/DungeonGenerator/Private/DungeonActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,3 @@ void ADungeonActor::DestroySpawnedActors(UWorld* world)
Super::DestroySpawnedActors(world);
}

#if WITH_EDITOR
void ADungeonActor::SyncLoadStreamLevels()
{
Super::SyncLoadStreamLevels();
}
#endif

void ADungeonActor::UnloadStreamLevels()
{
Super::UnloadStreamLevels();
}
73 changes: 37 additions & 36 deletions Source/DungeonGenerator/Private/DungeonGenerateActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ void ADungeonGenerateActor::PostInitializeComponents()
// Calling the parent class
Super::PostInitializeComponents();

if (GetNetMode() != NM_Standalone)
//if (GetNetMode() != NM_Standalone)
if (GetLocalRole() == ROLE_Authority)
{
SetReplicates(true);
SetAutonomousProxy(true);
Expand All @@ -82,14 +83,6 @@ void ADungeonGenerateActor::BeginPlay()
#endif
}

void ADungeonGenerateActor::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
DestroyImplementation();

// Calling the parent class
Super::EndPlay(EndPlayReason);
}

void ADungeonGenerateActor::Tick(float DeltaSeconds)
{
// Calling the parent class
Expand Down Expand Up @@ -230,8 +223,6 @@ void ADungeonGenerateActor::SetInstancedMeshCullDistance(const double cullDistan
/********** 生成と破棄 **********/
void ADungeonGenerateActor::PreGenerateImplementation()
{
DestroyImplementation();

if (!IsValid(DungeonGenerateParameter))
{
DUNGEON_GENERATOR_ERROR(TEXT("DungeonGenerateParameter is not set"));
Expand All @@ -248,6 +239,8 @@ void ADungeonGenerateActor::PreGenerateImplementation()
DUNGEON_GENERATOR_ERROR(TEXT("The actor's scale is not applied in the generated dungeon."));
}

Dispose(true);

if (DungeonMeshGenerationMethod != EDungeonMeshGenerationMethod::StaticMesh)
{
// StaticMeshを先に登録
Expand Down Expand Up @@ -305,35 +298,35 @@ void ADungeonGenerateActor::PreGenerateImplementation()
);
}

if (Create(DungeonGenerateParameter, HasAuthority()))
{
if (DungeonMeshGenerationMethod != EDungeonMeshGenerationMethod::StaticMesh)
CommitAddInstance();

/*
List of PlayerStart, not including PlayerStartPIE.
PlayerStartの一覧。PlayerStartPIEは含まない。
*/
TArray<APlayerStart*> playerStart;
CollectPlayerStartExceptPlayerStartPIE(playerStart);
MovePlayerStart(playerStart);

// スタート部屋とゴール部屋の位置を記録
StartRoomLocation = GetStartLocation();
GoalRoomLocation = GetGoalLocation();

// 成功を通知
OnGenerationSuccess.Broadcast();
}
else
if (Create(DungeonGenerateParameter, HasAuthority()) == false)
{
DUNGEON_GENERATOR_ERROR(TEXT("Failed to generate dungeon. Seed(%d)"), DungeonGenerateParameter->GetRandomSeed());
DestroyImplementation();

// 失敗を通知
OnGenerationFailure.Broadcast();

Dispose(false);
return;
}

if (DungeonMeshGenerationMethod != EDungeonMeshGenerationMethod::StaticMesh)
CommitAddInstance();

/*
List of PlayerStart, not including PlayerStartPIE.
PlayerStartの一覧。PlayerStartPIEは含まない。
*/
TArray<APlayerStart*> playerStart;
CollectPlayerStartExceptPlayerStartPIE(playerStart);
MovePlayerStart(playerStart);

// スタート部屋とゴール部屋の位置を記録
StartRoomLocation = GetStartLocation();
GoalRoomLocation = GetGoalLocation();

// 成功を通知
OnGenerationSuccess.Broadcast();

#if WITH_EDITOR
// Record dungeon-generated random numbers
GeneratedRandomSeed = DungeonGenerateParameter->GetGeneratedRandomSeed();
Expand Down Expand Up @@ -365,10 +358,14 @@ void ADungeonGenerateActor::PreGenerateImplementation()
#endif
}

void ADungeonGenerateActor::DestroyImplementation()
void ADungeonGenerateActor::Dispose(const bool flushStreamLevels)
{
ClearInstancedMeshComponents();
if (IsCreated())
{
ClearInstancedMeshComponents();
}

Super::Dispose(flushStreamLevels);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -399,7 +396,7 @@ void ADungeonGenerateActor::GenerateDungeonWithParameter(UDungeonGenerateParamet

void ADungeonGenerateActor::DestroyDungeon()
{
DestroyImplementation();
Dispose(false);
}

int32 ADungeonGenerateActor::FindFloorHeight(const float z) const
Expand Down Expand Up @@ -504,6 +501,8 @@ void ADungeonGenerateActor::DrawDebugInformation() const
message.Append(TEXT("Identifier:") + FString::FromInt(grid.GetIdentifier()) + TEXT("\n"));
message.Append(TEXT("Type: ") + grid.GetTypeName() + TEXT("\n"));
message.Append(TEXT("Props: ") + grid.GetPropsName() + TEXT("\n"));
if (grid.IsCatwalk())
message.Append(TEXT("Catwalk\n"));
message.Append(grid.GetNoMeshGenerationName());
DrawDebugString(
GetWorld(),
Expand Down Expand Up @@ -541,6 +540,8 @@ void ADungeonGenerateActor::DrawDebugInformation() const
output.Add(TEXT("Identifier:") + FString::FromInt(grid.GetIdentifier()));
output.Add(TEXT("Type: ") + grid.GetTypeName());
output.Add(TEXT("Props: ") + grid.GetPropsName());
if (grid.IsCatwalk())
output.Add(TEXT("Catwalk"));

FString message;
for (const FString& line : output)
Expand Down
Loading

0 comments on commit 62a8f5f

Please sign in to comment.