diff --git a/Content/BP_BigIslandGenerator.uasset b/Content/BP_BigIslandGenerator.uasset index 8071e2462a47b4ddad80e0fb7a24cf8c079121b3..f4e9178f5f06d5a6480ddb228c6c278df26ed0da 100644 GIT binary patch delta 504 zcmZ26pK0F$rU}0Ulve9}6sYp>SbN-O(@EBX>yx<{lbEa~Y|dkxEz9J{Hkn&Kk14cb zag3lYYn2rk7#MsL3y@V~sGD7S)Z7H3PQf>|ID;#oC_gzhrL-t9 z2h3M+&d)8#&r8iK!L%c}?5F@Q0|P@;aB^Z!DwkVMeqzbw!W8?>S>}y7#Vpc zH?~DFa!!_QmuBRce5cK0az%&eX4g&=#>oX89FtYrB_`i*bDZ4U5xu#k?G5AR%pQAY E064U*e*gdg delta 429 zcmdnDfN8~irU}0U^zuB}E}HZ>EGqHH*vCFWY%&*P64R3Y&3TNoWtmp9PUe=+W7%KM zz%aR>RAI7!B+ulP@)j(5)kp%Gk|L8;6;xP`)glR2Dp;^Y)guXbDr!vTR1{!2+JGWx z!4lhyBmgq&sG=^Gte(k&C z3JZTPk|{ftEtsTx;il|V)|l+6BEZDh2N&v8v0&2dhjT%u2uQMQ=2W$^VPxLylE^JI zc}r#VZ4wAB$K>p82S(1xYr3Twc_s^VM=|nlR_HWm K-2A`Co*4ik?~2m^ diff --git a/README.md b/README.md index 4f57f2d..951963f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## Created for Unreal Engine 4.21 -![highresscreenshot00004](https://user-images.githubusercontent.com/2058763/50556437-f1503b80-0c8d-11e9-9686-be8d41c191dd.png) +![highresscreenshot00005](https://user-images.githubusercontent.com/2058763/50578306-17d8b880-0ded-11e9-8b8d-b7641fcd7479.png) This is a port of [the JavaScript code](https://github.com/amitp/mapgen2) of [Red Blob Games' *Polygonal Map Generation for Games*](http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/). @@ -95,6 +95,8 @@ There's also a number of places to "hook" into the island generation code if you As I mentioned, I tried to keep this port pretty close to the original. I've added a couple things for convenience, such as actual mesh generation as well as a data structure to keep track of rivers (`URiver`). However, while the rivers are placed, they do not get rendered and the underlying mesh is still the same -- you'll have to either roll your own option or look at [that downstream fork I mentioned earlier](https://github.com/Jay2645/IslandGenerator). +Speaking of mesh generation; it's not perfect -- it does its best to match each triangle to an individual biome for the purposes of assigning materials, but it comes out a bit jagged. + # Credits * The original code was released under the Apache 2.0 license; this C++ port of the code is also released under the Apache 2.0 license. Again, this was based on the [mapgen2](https://github.com/redblobgames/mapgen2) repository. diff --git a/Source/PolygonalMapGenerator/Private/IslandMapUtils.cpp b/Source/PolygonalMapGenerator/Private/IslandMapUtils.cpp index 74f62c8..f2d9821 100644 --- a/Source/PolygonalMapGenerator/Private/IslandMapUtils.cpp +++ b/Source/PolygonalMapGenerator/Private/IslandMapUtils.cpp @@ -402,7 +402,7 @@ void UIslandMapUtils::GenerateMesh(class AIslandMap* Map, UProceduralMeshCompone { return; } - GenerateMapMeshMultiMaterial(Map->Mesh, MapMesh, ZScale, Map->r_elevation, Map->r_biome); + GenerateMapMeshMultiMaterial(Map->Mesh, MapMesh, ZScale, Map->r_elevation, Map->r_coast, Map->r_biome); } void UIslandMapUtils::GenerateMapMeshSingleMaterial(UTriangleDualMesh* Mesh, UProceduralMeshComponent* MapMesh, float ZScale, const TArray& RegionElevation) @@ -447,7 +447,7 @@ void UIslandMapUtils::GenerateMapMeshSingleMaterial(UTriangleDualMesh* Mesh, UPr MapMesh->ContainsPhysicsTriMeshData(true); } -void UIslandMapUtils::GenerateMapMeshMultiMaterial(UTriangleDualMesh* Mesh, UProceduralMeshComponent* MapMesh, float ZScale, const TArray& RegionElevation, const TArray RegionBiomes) +void UIslandMapUtils::GenerateMapMeshMultiMaterial(UTriangleDualMesh* Mesh, UProceduralMeshComponent* MapMesh, float ZScale, const TArray& RegionElevation, const TArray& CostalRegions, const TArray RegionBiomes) { if (Mesh == NULL || MapMesh == NULL) { @@ -465,6 +465,7 @@ void UIslandMapUtils::GenerateMapMeshMultiMaterial(UTriangleDualMesh* Mesh, UPro FDelaunayTriangle triangle = UDelaunayHelper::ConvertTriangleIDToTriangle(rawMesh, t); // Determine which biome to use // If we're on the boundary, use the boundary biome + // If we're part coast, use the coast biome (this prevents jagged triangles along the water) // If 2+ points use the same biome, make the whole triangle that biome // Otherwise, just use point A's biome FBiomeData biome; @@ -480,8 +481,23 @@ void UIslandMapUtils::GenerateMapMeshMultiMaterial(UTriangleDualMesh* Mesh, UPro { biome = RegionBiomes[triangle.CIndex]; } + else if (CostalRegions[triangle.AIndex]) + { + // Coastal regions get handled after boundary regions + // This way, the boundary remains the same no matter what + biome = RegionBiomes[triangle.AIndex]; + } + else if (CostalRegions[triangle.BIndex]) + { + biome = RegionBiomes[triangle.BIndex]; + } + else if (CostalRegions[triangle.CIndex]) + { + biome = RegionBiomes[triangle.CIndex]; + } else if (RegionBiomes[triangle.AIndex].Tag == RegionBiomes[triangle.BIndex].Tag) { + // Finally, handle it based on biomes biome = RegionBiomes[triangle.AIndex]; } else if (RegionBiomes[triangle.BIndex].Tag == RegionBiomes[triangle.CIndex].Tag) diff --git a/Source/PolygonalMapGenerator/Public/IslandMapUtils.h b/Source/PolygonalMapGenerator/Public/IslandMapUtils.h index 030669b..7bf3d4f 100644 --- a/Source/PolygonalMapGenerator/Public/IslandMapUtils.h +++ b/Source/PolygonalMapGenerator/Public/IslandMapUtils.h @@ -216,5 +216,5 @@ public: UFUNCTION(BlueprintCallable, Category = "Procedural Generation|Island Generation") static void GenerateMapMeshSingleMaterial(UTriangleDualMesh* Mesh, UProceduralMeshComponent* MapMesh, float ZScale, const TArray& RegionElevation); UFUNCTION(BlueprintCallable, Category = "Procedural Generation|Island Generation") - static void GenerateMapMeshMultiMaterial(UTriangleDualMesh* Mesh, UProceduralMeshComponent* MapMesh, float ZScale, const TArray& RegionElevation, const TArray RegionBiomes); + static void GenerateMapMeshMultiMaterial(UTriangleDualMesh* Mesh, UProceduralMeshComponent* MapMesh, float ZScale, const TArray& RegionElevation, const TArray& CostalRegions, const TArray RegionBiomes); }; \ No newline at end of file