diff --git a/Content/BP_IslandGenerator.uasset b/Content/BP_IslandGenerator.uasset index aa61093a24fc3ffbd983d4c520804997f2c745a6..08de14f3a70cd5d0b135551451f2ec93ed68933c 100644 GIT binary patch delta 3969 zcmZ3rk@5K|#t9ihIo1petPBhce))N+3=9k`41E);3>87H2q>X6B@%7BS3wGp~4a z9aAdP=HDz`ED90~3=E#dIf;2Gm`abVn>2lMD`y;|RDM!cYH|rfs`vE&>s!V7KwwL7LcErSK^+Ums*rql3&DNaNYLl=K0)H7^Q?57#J|k{`Qyk>1Jczxr~gQ zlQ;4UbDBcE1L1`r^Xg%K<%Ei=L+MBV|NoDIva!j50v;rdO)d>2!N9N|Np$G za`g-_3qg{g00YTm(8TMH5UXK;l))f{&!7sK zLcr#n6;~GnWiyyL)llgd5NS}*gF+=hLPQdz`}P0-|3Ccy|Ns5}|Nr0q|NsBZ|NsAA zO|F#K!MR8hVu$c#Lsrqv{*vX2PRUTSKorP)76uLmkk?@1U;qFA53(C14=b=h@*qCA z9!Z|eVQnu6Qw|aag>(JnH+Ire`%6K51_p*^DD4EL^Cu??NlZRuEz4Lt`GK_zTzf85 zK5cTNjR>b0oX2Y;Q;%Ug$bT^~B~TjfG?2$jpn@1WK_SwEOY+tK|Nrx#k}!8GF)%=K z9zV$8+DcGqIVg>wVBx?A6>6IN(MGc#CYl2k#cr>|_*SPBBMQ zD-PwuOyijBY0poLiSVS>1~nmV@_u_63s^Y9(+|kEFiS9_SqiGTdGZ+tjmg#y0&Xye zLM0erc@)E7P%|kBstOj20#JV1&75$jm71#!xspH$p-crW{_pfwUmobFf)!9sowr BbeI4D delta 4049 zcmaF9igDFO#t9ih$E+9_SQ!`?{POcs85kH?7`i7`88|BOF);8mFff=1F)+w8Ffd%; zV_@)+U|?WmU|{$l!NBlCf`NfUl7Zpe`N$iyG}n7fmMhP_ZmWMBBoETpJ@Iv@jHx68 z!?Fkl6!8E5|NkH>C$DFc-dxVe&bWC!Q!0~$00RSqQ+{b)N@7uEa6w{nW?nkOnH8%Z zZx&(gV%fZpGmcTpKPf9Uxr8Cr`z<3o0|P@oj641RWHatXo8NO!Vca~IcP?W+2h>7! zDE;*R|No{?Ha59nJaQp8hAi|NmW3HY_SKCNl~P!&6rVR2D=rg9xNZLzZK~BL~WNAZfS_APy9>L1{EO zNbG_#07xE95+nqVWNdPrU=@heh3rsR5Ma~C4b}JS|KuA&N=(PBCNK2Unk*p9GFeO5 zg6S19S7h=sVHKuuYq*ME!WJw_whRoDFSu(=juWwAiFSZ;K>AOKs7SOyO$XV$7RnZI zL{cI@9ElmA)ENEU-67#J8DptKW|&YjFC zEHT;JMwYP}q{B$bn}GplmMByWhP5D%SimGFU$7CWkB0G}G~9(CzZO9SG0Xu4LMJZC z*Z=?j&w)z9T&)D<^Fe7CHCaHIb8?O?hq5e81Wv;|!wVIupFG`G6CPaIP|?)M7i~rA z@rH9NR4J&c1TjGg2Smes1+JSxC5kIZl!1W(uR>7qqK2kWPX;Ow3#A!AF{uURz&v6P zU<5lD&w)Xo)#vM^=hpfdH7`@J$a}mzHE@09fk^=6~b_J6XXG6g`H1)>tCpoV%7JOcN-jfHE|wtOI3mnaRBV6_e-r zOEE@Gei*39*fROCe;$mzxh5cm5yqL!9pu3%H8~{604}mV=nANK0#{fvlMDSt$T#Q< zTPDb93=`|sCtnEWFviTS$UZ=3Yk>7JFr-fA4v}F@ovaZe!`L|4HN=#&9V!FL(UVt) zNYrDLDSA*9$mW$m#bBi}tN=nO7eVa?Q1=+5mY_ldkSYcS23435@ahO;46@w^o3-Wv E0E?YRrvLx| diff --git a/Content/BP_IslandMesh.uasset b/Content/BP_IslandMesh.uasset index f7b093fe86757e05c33065a64c855604ede4d8e0..b35158f2e0420d788184dae95dfef8ae949cc24e 100644 GIT binary patch delta 7223 zcmX@{i}BBI#t9RIHUuy*ure?(_~qxNGB7Z(Ff5+9$ig*Elz~Bufq~(i00Tpq90LO* z0|P^uJOe|WJOe|YJOe{=`akB)43pg!9&7G681R4(BrnFmz_1u>ge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oLL7v}iA0f4Q+Wj>#gq@u0s_5UCL*RLC5faFT~^aL zVgyfxi(5$Q*}JXG=IMBDS5{LzIi-lWNNR>hl6o=mnIxOha6ckZ!s-N2Mgh$gfI2gvCYb!>hBAp%V~{WdWU{8Ds5BKk z3JQ|OkO1k$DghdJ#VP^nn1dxI|1Fb{!Y~ljHit;-mrF>=qdNq|2lafdCMTAQGG6 zw+!8V)Uo~|NrYjB;_%OYe1P5G$;j9Fmw|i#jwi& diff --git a/Content/PoissonMeshBuilder.uasset b/Content/PoissonMeshBuilder.uasset new file mode 100644 index 0000000000000000000000000000000000000000..2244c04383320afe2c34962e515e041523bb75bd GIT binary patch literal 1212 zcmX@utTpfF|Ns9Jm>C#YnHa!;k%58XZN`QtFP)}*;l5?K$Z@xuo)iNELpBQo11kdq zgI|7LDp(;m0|SEsBLjmX0|SGLk%5tmnVYMLk%_aVxw)~ki>ra5sgtXPi;1hLv70$q zgC`RM1IUt{ObiSx3=9k)ekU_nieVx%0~jx4W?-=Mlzq}+H{Ex6tmo}R{dfO@Tm;ew zvXF&Al!1|9QK}n*FaraFwsxqiiFQzGPHJLts;-Hiks$*}0Ruyqk1H+(5c?Py*v!vA z2eI!mGcfD`IS0gn;{X5u{|EV3i-CbbKOjG+GCe;pF~>Ktz&$lDwJ5P9zeqnIKeMA%IW> zH+inkl2lNLV{yd>sV&W*C<28YG&ULj{{R0UC#YnHa!;k%58XZN`QtFP)}*;l5?K$Z@xuo)iNELmvwR11kdq zgI|7LDp(;e0|SEsBLjmX0|SG(ft!o5tC6vZp{0wPp}CW*lasT7o0F5Xxq+FbnWZII zLm?9b1IUtxObiSx3=9k){zhi76vIwt1~5L!%)qd4&T@N0FJt%qM|z&|tFLf@Tm;ew zvXF&Al!1|9QK}n*FaraFwsxqiiFQzGPHJLts;-Hiks$*}0Ruyqk1H+(5c?Py0uG&Q z1hJV}7#MzloCD%O@&Et-|AYLi$-uy%ACR9@nVz4QnB$vR;GUY7T9jClU!)&gSejUr z>YG}e;Z&NLlagA*Fz?O0ViAyr;N+srf)ah_{G!xQ|D>$ctzMh<~aGf?GIOXGy9M0|Nu5 z+rIr}eF}<7P#8mFo#F5Q|NlWg28p4|{rUg@Kgj9Gav;Bf_#g~Z52KOgK*(); - builder->Initialize(MapSize, BoundarySpacing); - builder->AddPoisson(Rng, MapSize - PoissonSize, PoissonSpacing, PoissonSamples); - Mesh = builder->Create(); + // Generate map points + Mesh = PointGenerator->GenerateDualMesh(Rng); // Reset all arrays @@ -157,25 +149,6 @@ void AIslandMap::Draw() const const FDualMesh& mesh = Mesh->GetRawMesh(); const TArray& _r_vertex = Mesh->GetPoints(); -/* const TArray& _t_vertex = Mesh->GetTriangleCentroids(); - - for (FTriangleIndex t = 0; t < _t_vertex.Num(); t++) - { - TArray trianglePoints = Mesh->t_circulate_r(t); - int count = 0; - for (FPointIndex r : trianglePoints) - { - if (r_ocean[r]) - { - count++; - } - } - // True if 2 or more points of the triangle are ocean - FColor color = count >= 2 ? FColor::Blue : FColor::Magenta; - DrawDebugPoint(world, FVector(_t_vertex[t].X, _t_vertex[t].Y, t_elevation[t] * 10000), 10.0f, color, false, 9999.0f); - } - - return;*/ for (FSideIndex e = 0; e < _halfedges.Num(); e++) { if (e < _halfedges[e]) diff --git a/Source/PolygonalMapGenerator/Private/IslandMeshBuilder.cpp b/Source/PolygonalMapGenerator/Private/IslandMeshBuilder.cpp new file mode 100644 index 0000000..d85344c --- /dev/null +++ b/Source/PolygonalMapGenerator/Private/IslandMeshBuilder.cpp @@ -0,0 +1,39 @@ +/* +* From http://www.redblobgames.com/maps/mapgen2/ +* Original work copyright 2017 Red Blob Games +* Unreal Engine 4 implementation copyright 2018 Jay Stevens +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "IslandMeshBuilder.h" +#include "DualMeshBuilder.h" + +UIslandMeshBuilder::UIslandMeshBuilder() +{ + MapSize = FVector2D(107500.0, 107500.0); + BoundarySpacing = 1000; +} + +void UIslandMeshBuilder::AddPoints_Implementation(UDualMeshBuilder* Builder, FRandomStream& Rng) const +{ + // Do nothing +} + +UTriangleDualMesh* UIslandMeshBuilder::GenerateDualMesh_Implementation(FRandomStream& Rng) const +{ + UDualMeshBuilder* builder = NewObject(); + builder->Initialize(MapSize, BoundarySpacing); + AddPoints(builder, Rng); + return builder->Create(); +} diff --git a/Source/PolygonalMapGenerator/Private/IslandPoissonMeshBuilder.cpp b/Source/PolygonalMapGenerator/Private/IslandPoissonMeshBuilder.cpp new file mode 100644 index 0000000..0c3fe74 --- /dev/null +++ b/Source/PolygonalMapGenerator/Private/IslandPoissonMeshBuilder.cpp @@ -0,0 +1,32 @@ +/* +* From http://www.redblobgames.com/maps/mapgen2/ +* Original work copyright 2017 Red Blob Games +* Unreal Engine 4 implementation copyright 2018 Jay Stevens +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "IslandPoissonMeshBuilder.h" +#include "DualMeshBuilder.h" + +UIslandPoissonMeshBuilder::UIslandPoissonMeshBuilder() +{ + PoissonSize = FVector2D(100000.0, 100000.0); + PoissonSpacing = 1075.0f; + PoissonSamples = 30; +} + +void UIslandPoissonMeshBuilder::AddPoints_Implementation(UDualMeshBuilder* Builder, FRandomStream& Rng) const +{ + Builder->AddPoisson(Rng, MapSize - PoissonSize, PoissonSpacing, PoissonSamples); +} diff --git a/Source/PolygonalMapGenerator/Private/IslandSquareMeshBuilder.cpp b/Source/PolygonalMapGenerator/Private/IslandSquareMeshBuilder.cpp new file mode 100644 index 0000000..543b64d --- /dev/null +++ b/Source/PolygonalMapGenerator/Private/IslandSquareMeshBuilder.cpp @@ -0,0 +1,37 @@ +/* +* From http://www.redblobgames.com/maps/mapgen2/ +* Original work copyright 2017 Red Blob Games +* Unreal Engine 4 implementation copyright 2018 Jay Stevens +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "IslandSquareMeshBuilder.h" +#include "DualMeshBuilder.h" + +UIslandSquareMeshBuilder::UIslandSquareMeshBuilder() +{ + NumberOfPoints = 1000; +} + +void UIslandSquareMeshBuilder::AddPoints_Implementation(UDualMeshBuilder* Builder, FRandomStream& Rng) const +{ + int32 gridSize = FMath::CeilToInt(FMath::Sqrt(NumberOfPoints)); + for (int32 x = 0; x < gridSize; x++) + { + for (int32 y = 0; y < gridSize; y++) + { + Builder->AddPoint(FVector2D((0.5f + x) / gridSize * MapSize.X, (0.5f + y) / gridSize * MapSize.Y)); + } + } +} diff --git a/Source/PolygonalMapGenerator/Public/IslandMap.h b/Source/PolygonalMapGenerator/Public/IslandMap.h index 9c9d68b..3964a65 100644 --- a/Source/PolygonalMapGenerator/Public/IslandMap.h +++ b/Source/PolygonalMapGenerator/Public/IslandMap.h @@ -26,6 +26,7 @@ #include "TriangleDualMesh.h" #include "IslandMapUtils.h" +#include "IslandMeshBuilder.h" #include "IslandBiome.h" #include "IslandElevation.h" #include "IslandMoisture.h" @@ -49,21 +50,6 @@ public: // Modifies how we calculate drainage. UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "RNG") int32 RiverSeed; - // The size of our map, starting at (0, 0). - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Map") - FVector2D MapSize; - // The size of our map, starting at (0, 0). - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Map") - FVector2D PoissonSize; - // The amount of spacing on the edge of the map. - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Edges", meta = (ClampMin = "0")) - int32 BoundarySpacing; - // How much spacing between Poisson points. - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Points", meta = (ClampMin = "0.0")) - float PoissonSpacing; - // Maximum samples to generate each step. - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Points", meta = (ClampMin = "0")) - int32 PoissonSamples; // Modifies the types of biomes we produce. UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Map") FBiomeBias BiomeBias; @@ -88,6 +74,8 @@ public: UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category = "RNG") FRandomStream DrainageRng; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Map") + const UIslandMeshBuilder* PointGenerator; UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Map") const UIslandBiome* Biomes; UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Map") diff --git a/Source/PolygonalMapGenerator/Public/IslandMeshBuilder.h b/Source/PolygonalMapGenerator/Public/IslandMeshBuilder.h new file mode 100644 index 0000000..079e677 --- /dev/null +++ b/Source/PolygonalMapGenerator/Public/IslandMeshBuilder.h @@ -0,0 +1,56 @@ +/* +* From http://www.redblobgames.com/maps/mapgen2/ +* Original work copyright 2017 Red Blob Games +* Unreal Engine 4 implementation copyright 2018 Jay Stevens +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#include "CoreMinimal.h" +#include "Engine/DataAsset.h" + +#include "TriangleDualMesh.h" + +#include "IslandMeshBuilder.generated.h" + +/** + * + */ +UCLASS(Abstract, Blueprintable) +class POLYGONALMAPGENERATOR_API UIslandMeshBuilder : public UDataAsset +{ + GENERATED_BODY() + +public: + // The size of our map, starting at (0, 0). + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Map") + FVector2D MapSize; + // The amount of spacing on the edge of the map. + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Edges", meta = (ClampMin = "0")) + int32 BoundarySpacing; + +public: + UIslandMeshBuilder(); + +protected: + UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Procedural Generation|Island Generation|Points") + void AddPoints(UDualMeshBuilder* Builder, UPARAM(ref) FRandomStream& Rng) const; + virtual void AddPoints_Implementation(UDualMeshBuilder* Builder, FRandomStream& Rng) const; + virtual UTriangleDualMesh* GenerateDualMesh_Implementation(FRandomStream& Rng) const; + +public: + UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Procedural Generation|Island Generation|Points") + UTriangleDualMesh* GenerateDualMesh(UPARAM(ref) FRandomStream& Rng) const; +}; diff --git a/Source/PolygonalMapGenerator/Public/IslandPoissonMeshBuilder.h b/Source/PolygonalMapGenerator/Public/IslandPoissonMeshBuilder.h new file mode 100644 index 0000000..d96677a --- /dev/null +++ b/Source/PolygonalMapGenerator/Public/IslandPoissonMeshBuilder.h @@ -0,0 +1,48 @@ +/* +* From http://www.redblobgames.com/maps/mapgen2/ +* Original work copyright 2017 Red Blob Games +* Unreal Engine 4 implementation copyright 2018 Jay Stevens +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#include "CoreMinimal.h" +#include "IslandMeshBuilder.h" +#include "IslandPoissonMeshBuilder.generated.h" + +/** + * + */ +UCLASS() +class POLYGONALMAPGENERATOR_API UIslandPoissonMeshBuilder : public UIslandMeshBuilder +{ + GENERATED_BODY() +public: + // The size of our map, starting at (0, 0). + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Map") + FVector2D PoissonSize; + // How much spacing between Poisson points. + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Points", meta = (ClampMin = "0.0")) + float PoissonSpacing; + // Maximum samples to generate each step. + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Points", meta = (ClampMin = "0")) + int32 PoissonSamples; + +public: + UIslandPoissonMeshBuilder(); + +protected: + virtual void AddPoints_Implementation(UDualMeshBuilder* Builder, FRandomStream& Rng) const override; +}; diff --git a/Source/PolygonalMapGenerator/Public/IslandSquareMeshBuilder.h b/Source/PolygonalMapGenerator/Public/IslandSquareMeshBuilder.h new file mode 100644 index 0000000..45c31b7 --- /dev/null +++ b/Source/PolygonalMapGenerator/Public/IslandSquareMeshBuilder.h @@ -0,0 +1,42 @@ +/* +* From http://www.redblobgames.com/maps/mapgen2/ +* Original work copyright 2017 Red Blob Games +* Unreal Engine 4 implementation copyright 2018 Jay Stevens +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#include "CoreMinimal.h" +#include "IslandMeshBuilder.h" +#include "IslandSquareMeshBuilder.generated.h" + +/** + * + */ +UCLASS() +class POLYGONALMAPGENERATOR_API UIslandSquareMeshBuilder : public UIslandMeshBuilder +{ + GENERATED_BODY() + +public: + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ClampMin = "1")) + int32 NumberOfPoints; + +public: + UIslandSquareMeshBuilder(); + +protected: + virtual void AddPoints_Implementation(UDualMeshBuilder* Builder, FRandomStream& Rng) const override; +};