Fix issues when running on Linux
This commit is contained in:
parent
a1c5d3a444
commit
a7777aff67
|
@ -1,6 +1,7 @@
|
|||
# Unreal folders
|
||||
Binaries
|
||||
Build
|
||||
Debug
|
||||
DerivedDataCache
|
||||
Intermediate
|
||||
Saved
|
||||
|
|
|
@ -16,17 +16,20 @@
|
|||
// =============================================================================
|
||||
|
||||
ACityMapGenerator::ACityMapGenerator(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
UpdateMap();
|
||||
}
|
||||
: Super(ObjectInitializer) {}
|
||||
|
||||
ACityMapGenerator::~ACityMapGenerator() {}
|
||||
|
||||
// =============================================================================
|
||||
// -- Private methods ----------------------------------------------------------
|
||||
// -- Map construction and update related methods ------------------------------
|
||||
// =============================================================================
|
||||
|
||||
void ACityMapGenerator::OnConstruction(const FTransform &Transform)
|
||||
{
|
||||
Super::OnConstruction(Transform);
|
||||
UpdateMap();
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
void ACityMapGenerator::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||
{
|
||||
|
@ -54,7 +57,6 @@ void ACityMapGenerator::UpdateSeeds() {
|
|||
}
|
||||
if (!bUseMultipleFixedSeeds) {
|
||||
RoadPlanningSeed = Seed;
|
||||
BuildingGenerationSeed = Seed;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,24 +7,41 @@
|
|||
#include "MapGen/GraphParser.h"
|
||||
#include "CityMapGenerator.generated.h"
|
||||
|
||||
/// Generates a random city using the meshes provided.
|
||||
///
|
||||
/// @note At this point it only generates roads and sidewalks.
|
||||
UCLASS(HideCategories=(Rendering, Input))
|
||||
class CARLA_API ACityMapGenerator : public ACityMapMeshHolder
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// ===========================================================================
|
||||
/// @name Constructor and destructor
|
||||
// ===========================================================================
|
||||
/// @{
|
||||
public:
|
||||
|
||||
ACityMapGenerator(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
~ACityMapGenerator();
|
||||
|
||||
private:
|
||||
/// @}
|
||||
// ===========================================================================
|
||||
/// @name Map construction and update related methods
|
||||
// ===========================================================================
|
||||
/// @{
|
||||
protected:
|
||||
|
||||
/// Called after the actor has been constructed and spawned.
|
||||
virtual void OnConstruction(const FTransform &Transform) override;
|
||||
|
||||
#if WITH_EDITOR
|
||||
/// Called after a property change in editor.
|
||||
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
/// Update the map based on the current settings.
|
||||
void UpdateMap();
|
||||
|
||||
|
@ -37,8 +54,13 @@ private:
|
|||
/// Add the road meshes to the scene based on the current DCEL.
|
||||
void GenerateRoads();
|
||||
|
||||
/// @name Map Generation
|
||||
/// @}
|
||||
// ===========================================================================
|
||||
/// @name Map generation properties
|
||||
// ===========================================================================
|
||||
/// @{
|
||||
private:
|
||||
|
||||
UPROPERTY(Category = "Map Generation", EditAnywhere, meta = (ClampMin = "10", ClampMax = "200"))
|
||||
uint32 MapSizeX = 20u;
|
||||
|
||||
|
@ -53,22 +75,27 @@ private:
|
|||
|
||||
UPROPERTY(Category = "Map Generation", EditAnywhere, meta = (EditCondition = bUseFixedSeed))
|
||||
int32 Seed = 123456789;
|
||||
/// @}
|
||||
|
||||
/// @name Map Generation - Advance Display
|
||||
/// @}
|
||||
// ===========================================================================
|
||||
/// @name Map generation properties - advance display
|
||||
// ===========================================================================
|
||||
/// @{
|
||||
private:
|
||||
|
||||
UPROPERTY(Category = "Map Generation", EditAnywhere, AdvancedDisplay, meta = (EditCondition = bUseFixedSeed))
|
||||
bool bUseMultipleFixedSeeds = false;
|
||||
|
||||
UPROPERTY(Category = "Map Generation", EditAnywhere, AdvancedDisplay, meta = (EditCondition = bUseMultipleFixedSeeds))
|
||||
int32 RoadPlanningSeed;
|
||||
|
||||
UPROPERTY(Category = "Map Generation", EditAnywhere, AdvancedDisplay, meta = (EditCondition = bUseMultipleFixedSeeds))
|
||||
int32 BuildingGenerationSeed;
|
||||
/// @}
|
||||
|
||||
// ===========================================================================
|
||||
/// @name Other private members
|
||||
// ===========================================================================
|
||||
/// @{
|
||||
private:
|
||||
|
||||
TUniquePtr<MapGen::DoublyConnectedEdgeList> Dcel;
|
||||
|
||||
TUniquePtr<MapGen::GraphParser> DcelParser;
|
||||
|
|
|
@ -13,7 +13,7 @@ using tag_size_t = std::underlying_type<ECityMapMeshTag>::type;
|
|||
constexpr static tag_size_t NUMBER_OF_TAGS = CityMapMeshTag::GetNumberOfTags();
|
||||
|
||||
// =============================================================================
|
||||
// -- Constructor --------------------------------------------------------------
|
||||
// -- Construction and update related methods ----------------------------------
|
||||
// =============================================================================
|
||||
|
||||
ACityMapMeshHolder::ACityMapMeshHolder(const FObjectInitializer& ObjectInitializer)
|
||||
|
@ -29,28 +29,24 @@ ACityMapMeshHolder::ACityMapMeshHolder(const FObjectInitializer& ObjectInitializ
|
|||
for (tag_size_t i = 0u; i < NUMBER_OF_TAGS; ++i) {
|
||||
// Add static mesh holder.
|
||||
StaticMeshes.Add(CityMapMeshTag::FromUInt(i));
|
||||
// Create an instantiator for each mesh.
|
||||
const FString name = CityMapMeshTag::ToString(i) + "Instantiator";
|
||||
auto instantiator = CreateDefaultSubobject<UInstancedStaticMeshComponent>(*name);
|
||||
instantiator->SetMobility(EComponentMobility::Static);
|
||||
instantiator->SetupAttachment(SceneRootComponent);
|
||||
MeshInstatiators.Add(instantiator);
|
||||
instantiator->RegisterComponent();
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// -- Public methods -----------------------------------------------------------
|
||||
// =============================================================================
|
||||
|
||||
FVector ACityMapMeshHolder::GetTileLocation(uint32 X, uint32 Y) const
|
||||
void ACityMapMeshHolder::OnConstruction(const FTransform &Transform)
|
||||
{
|
||||
return {X * MapScale, Y * MapScale, 0.0f};
|
||||
}
|
||||
Super::OnConstruction(Transform);
|
||||
|
||||
// =============================================================================
|
||||
// -- Protected methods --------------------------------------------------------
|
||||
// =============================================================================
|
||||
for (tag_size_t i = 0u; i < NUMBER_OF_TAGS; ++i) {
|
||||
// Create an instantiator for each mesh.
|
||||
auto instantiator = NewObject<UInstancedStaticMeshComponent>(this);
|
||||
instantiator->SetMobility(EComponentMobility::Static);
|
||||
instantiator->SetupAttachment(SceneRootComponent);
|
||||
instantiator->SetStaticMesh(GetStaticMesh(CityMapMeshTag::FromUInt(i)));
|
||||
MeshInstatiators.Add(instantiator);
|
||||
instantiator->RegisterComponent();
|
||||
}
|
||||
UpdateMapScale();
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
void ACityMapMeshHolder::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||
|
@ -63,11 +59,25 @@ void ACityMapMeshHolder::PostEditChangeProperty(FPropertyChangedEvent& PropertyC
|
|||
}
|
||||
#endif
|
||||
|
||||
// =============================================================================
|
||||
// -- Other protected methods --------------------------------------------------
|
||||
// =============================================================================
|
||||
|
||||
FVector ACityMapMeshHolder::GetTileLocation(uint32 X, uint32 Y) const
|
||||
{
|
||||
return {X * MapScale, Y * MapScale, 0.0f};
|
||||
}
|
||||
|
||||
void ACityMapMeshHolder::SetStaticMesh(ECityMapMeshTag Tag, UStaticMesh *Mesh)
|
||||
{
|
||||
StaticMeshes[Tag] = Mesh;
|
||||
}
|
||||
|
||||
UStaticMesh *ACityMapMeshHolder::GetStaticMesh(ECityMapMeshTag Tag)
|
||||
{
|
||||
return StaticMeshes[Tag];
|
||||
}
|
||||
|
||||
const UStaticMesh *ACityMapMeshHolder::GetStaticMesh(ECityMapMeshTag Tag) const
|
||||
{
|
||||
return StaticMeshes[Tag];
|
||||
|
@ -103,7 +113,7 @@ void ACityMapMeshHolder::ResetInstantiators()
|
|||
UInstancedStaticMeshComponent *instantiator = MeshInstatiators[i];
|
||||
check(instantiator != nullptr);
|
||||
instantiator->ClearInstances();
|
||||
instantiator->SetStaticMesh(StaticMeshes[CityMapMeshTag::FromUInt(i)]);
|
||||
instantiator->SetStaticMesh(GetStaticMesh(CityMapMeshTag::FromUInt(i)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,24 +8,36 @@
|
|||
|
||||
class UInstancedStaticMeshComponent;
|
||||
|
||||
/// Holds the static meshes and instances necessary for building the city map.
|
||||
/// Holds the static meshes and instances necessary for building a city map.
|
||||
UCLASS(Abstract)
|
||||
class CARLA_API ACityMapMeshHolder : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// ===========================================================================
|
||||
// -- Construction and update related methods --------------------------------
|
||||
// ===========================================================================
|
||||
public:
|
||||
|
||||
// Sets default values for this actor's properties
|
||||
/// Initializes the mesh holders. It is safe to call SetStaticMesh after this.
|
||||
/// However, instances cannot be added until OnConstruction is called.
|
||||
ACityMapMeshHolder(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
protected:
|
||||
|
||||
/// Initializes the instantiators.
|
||||
virtual void OnConstruction(const FTransform &Transform) override;
|
||||
|
||||
#if WITH_EDITOR
|
||||
/// Called after a property change in editor.
|
||||
/// Clears and updates the instantiators.
|
||||
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||
#endif
|
||||
|
||||
// ===========================================================================
|
||||
// -- Other protected methods ------------------------------------------------
|
||||
// ===========================================================================
|
||||
protected:
|
||||
|
||||
/// Return the 3D world location (relative to this actor) of the given 2D
|
||||
/// tile.
|
||||
FVector GetTileLocation(uint32 X, uint32 Y) const;
|
||||
|
@ -33,6 +45,9 @@ protected:
|
|||
/// Set the static mesh associated with @a Tag.
|
||||
void SetStaticMesh(ECityMapMeshTag Tag, UStaticMesh *Mesh);
|
||||
|
||||
/// Return the static mesh corresponding to @a Tag.
|
||||
UStaticMesh *GetStaticMesh(ECityMapMeshTag Tag);
|
||||
|
||||
/// Return the static mesh corresponding to @a Tag.
|
||||
const UStaticMesh *GetStaticMesh(ECityMapMeshTag Tag) const;
|
||||
|
||||
|
@ -54,6 +69,9 @@ protected:
|
|||
/// @param Transform Transform that will be applied to the mesh
|
||||
void AddInstance(ECityMapMeshTag Tag, FTransform Transform);
|
||||
|
||||
// ===========================================================================
|
||||
// -- Private methods and members --------------------------------------------
|
||||
// ===========================================================================
|
||||
private:
|
||||
|
||||
/// Clear all instances in the instantiators and update the static meshes.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "Carla.h"
|
||||
#include "DoublyConnectedEdgeList.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
|
||||
#ifdef WITH_EDITOR
|
||||
|
|
Loading…
Reference in New Issue