Fixes issue #11
This commit is contained in:
parent
9ee0ad84de
commit
977710d05b
|
@ -24,22 +24,6 @@ ACityMapGenerator::~ACityMapGenerator() {}
|
|||
// -- Map construction and update related methods ------------------------------
|
||||
// =============================================================================
|
||||
|
||||
void ACityMapGenerator::OnConstruction(const FTransform &Transform)
|
||||
{
|
||||
Super::OnConstruction(Transform);
|
||||
// UpdateMap(); /// @todo Do we need to update the map here?
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
void ACityMapGenerator::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||
{
|
||||
Super::PostEditChangeProperty(PropertyChangedEvent);
|
||||
if (PropertyChangedEvent.Property) {
|
||||
UpdateMap();
|
||||
}
|
||||
}
|
||||
#endif // WITH_EDITOR
|
||||
|
||||
void ACityMapGenerator::UpdateMap() {
|
||||
UpdateSeeds();
|
||||
GenerateGraph();
|
||||
|
|
|
@ -30,20 +30,10 @@ public:
|
|||
/// @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 // WITH_EDITOR
|
||||
|
||||
private:
|
||||
|
||||
/// Update the map based on the current settings.
|
||||
void UpdateMap();
|
||||
virtual void UpdateMap() override;
|
||||
|
||||
/// Update the random seeds. Generate random if no fixed seed is used.
|
||||
void UpdateSeeds();
|
||||
|
|
|
@ -36,11 +36,11 @@ void ACityMapMeshHolder::OnConstruction(const FTransform &Transform)
|
|||
{
|
||||
Super::OnConstruction(Transform);
|
||||
|
||||
for (tag_size_t i = 0u; i < NUMBER_OF_TAGS; ++i) {
|
||||
// Create an instantiator for each mesh.
|
||||
GetInstantiator(CityMapMeshTag::FromUInt(i));
|
||||
if (MeshInstatiators.Num() == 0) {
|
||||
ResetInstantiators();
|
||||
UpdateMapScale();
|
||||
UpdateMap();
|
||||
}
|
||||
UpdateMapScale();
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
|
@ -50,6 +50,7 @@ void ACityMapMeshHolder::PostEditChangeProperty(FPropertyChangedEvent& PropertyC
|
|||
if (PropertyChangedEvent.Property) {
|
||||
ResetInstantiators();
|
||||
UpdateMapScale();
|
||||
UpdateMap();
|
||||
}
|
||||
}
|
||||
#endif // WITH_EDITOR
|
||||
|
@ -101,11 +102,22 @@ void ACityMapMeshHolder::AddInstance(ECityMapMeshTag Tag, FTransform Transform)
|
|||
// -- Private methods ----------------------------------------------------------
|
||||
// =============================================================================
|
||||
|
||||
void ACityMapMeshHolder::UpdateMap() {}
|
||||
|
||||
void ACityMapMeshHolder::ResetInstantiators()
|
||||
{
|
||||
for (auto *instantiator : MeshInstatiators) {
|
||||
if (instantiator != nullptr) {
|
||||
instantiator->ClearInstances();
|
||||
}
|
||||
}
|
||||
if (MeshInstatiators.Num() != NUMBER_OF_TAGS) {
|
||||
MeshInstatiators.Empty();
|
||||
MeshInstatiators.Init(nullptr, NUMBER_OF_TAGS);
|
||||
}
|
||||
check(MeshInstatiators.Num() == NUMBER_OF_TAGS);
|
||||
for (tag_size_t i = 0u; i < NUMBER_OF_TAGS; ++i) {
|
||||
auto &instantiator = GetInstantiator(CityMapMeshTag::FromUInt(i));
|
||||
instantiator.ClearInstances();
|
||||
instantiator.SetStaticMesh(GetStaticMesh(CityMapMeshTag::FromUInt(i)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,9 @@ protected:
|
|||
// ===========================================================================
|
||||
private:
|
||||
|
||||
/// Here does nothing, implement in derived classes.
|
||||
virtual void UpdateMap();
|
||||
|
||||
/// Clear all instances in the instantiators and update the static meshes.
|
||||
void ResetInstantiators();
|
||||
|
||||
|
|
Loading…
Reference in New Issue