generating number of roads dynamically
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
"tree_clumpiness": 99,
|
||||
"min_road_width": 0.2,
|
||||
"max_road_width": 0.6,
|
||||
"buildings_per_road": 5,
|
||||
"road_exits": 1,
|
||||
"road_curvyness": 45,
|
||||
"road_distribution": 70,
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
"tree_clumpiness": 99,
|
||||
"min_road_width": 0.2,
|
||||
"max_road_width": 0.6,
|
||||
"buildings_per_road": 3,
|
||||
"road_exits": 1,
|
||||
"road_curvyness": 45,
|
||||
"road_distribution": 40,
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
"tree_clumpiness": 99,
|
||||
"min_road_width": 0.2,
|
||||
"max_road_width": 0.30000000000000004,
|
||||
"buildings_per_road": 6,
|
||||
"road_exits": 3,
|
||||
"road_curvyness": 45,
|
||||
"road_distribution": 70,
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
"tree_clumpiness": 99,
|
||||
"min_road_width": 0.2,
|
||||
"max_road_width": 0.6,
|
||||
"buildings_per_road": 5,
|
||||
"road_exits": 1,
|
||||
"road_curvyness": 45,
|
||||
"road_distribution": 70,
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
"tree_clumpiness": 99,
|
||||
"min_road_width": 0.2,
|
||||
"max_road_width": 0.6,
|
||||
"buildings_per_road": 6,
|
||||
"road_exits": 1,
|
||||
"road_curvyness": 45,
|
||||
"road_distribution": 19,
|
||||
|
||||
@@ -64,7 +64,6 @@ All settings below are currently implemented in the UI.
|
||||
| **Tree Clumpiness** | Distribution style of trees (spread vs clustered forest). | `0%` to `100%` |
|
||||
| **Min Road Width** | Minimum road width as % of average image dimension `((width+height)/2)`. | `0.1%` to `5%` in `0.1%` steps |
|
||||
| **Max Road Width** | Maximum road width as % of average image dimension `((width+height)/2)`. | `0.1%` to `5%` in `0.1%` steps |
|
||||
| **Buildings Per Road** | Number of buildings represented by one internal road segment (lower = more roads). | `1` to `20` |
|
||||
| **Road Exits** | Number of edge-connected exit roads. | `0` to `100` |
|
||||
| **Minimum Road Angle** | Minimum allowed angle between roads at a junction. | `0°` to `180°` |
|
||||
| **Road Curvyness** | Curviness of generated roads. | `0%` to `100%` |
|
||||
|
||||
@@ -997,28 +997,19 @@ func estimateRoadTarget(settings *Settings) int {
|
||||
if settings.NumBuildings < 10 {
|
||||
return settings.NumBuildings
|
||||
}
|
||||
divisor := float64(max(settings.BuildingsPerRoad, 1))
|
||||
buildings := float64(max(settings.NumBuildings, 1))
|
||||
baseRoads := buildings / divisor
|
||||
scale := 1.0
|
||||
if buildings > 400 {
|
||||
scale *= 0.96
|
||||
roads := buildings / 5.25
|
||||
if buildings > 80 {
|
||||
roads += math.Pow(buildings-80.0, 0.70) * 0.28
|
||||
}
|
||||
if buildings > 1200 {
|
||||
scale *= 0.92
|
||||
if buildings > 500 {
|
||||
roads += math.Pow((buildings-500.0)/2.2, 0.66) * 0.18
|
||||
}
|
||||
if buildings > 3000 {
|
||||
scale *= 0.88
|
||||
if buildings > 1800 {
|
||||
roads *= 0.95
|
||||
}
|
||||
roads := baseRoads * scale
|
||||
if buildings > 200 {
|
||||
roads += math.Pow((buildings-200.0)/divisor, 0.72) * 0.35
|
||||
}
|
||||
if buildings > 1200 {
|
||||
roads += math.Pow((buildings-1200.0)/(divisor*1.8), 0.68) * 0.22
|
||||
}
|
||||
if buildings > 1000 {
|
||||
roads *= 0.97
|
||||
if buildings > 4000 {
|
||||
roads *= 0.90
|
||||
}
|
||||
result := int(math.Round(roads))
|
||||
if result < 1 {
|
||||
|
||||
@@ -39,7 +39,6 @@ type Settings struct {
|
||||
// Road settings
|
||||
MinRoadWidth float64 `json:"min_road_width"`
|
||||
MaxRoadWidth float64 `json:"max_road_width"`
|
||||
BuildingsPerRoad int `json:"buildings_per_road"`
|
||||
RoadExits int `json:"road_exits"`
|
||||
RoadCurvyness float64 `json:"road_curvyness"`
|
||||
RoadDistribution float64 `json:"road_distribution"`
|
||||
@@ -148,7 +147,6 @@ func LoadSettings() (*Settings, error) {
|
||||
RiverEdgeRoughness: 50,
|
||||
MinRoadWidth: 0.7,
|
||||
MaxRoadWidth: 2.7,
|
||||
BuildingsPerRoad: 6,
|
||||
RoadExits: 5,
|
||||
RoadCurvyness: 50,
|
||||
RoadDistribution: 50,
|
||||
@@ -232,9 +230,6 @@ func normalizeSettings(settings *Settings, rawKeys map[string]json.RawMessage) {
|
||||
if settings.BuildingComplexityRatio == 0 {
|
||||
settings.BuildingComplexityRatio = 50
|
||||
}
|
||||
if settings.BuildingsPerRoad == 0 {
|
||||
settings.BuildingsPerRoad = 6
|
||||
}
|
||||
if _, ok := rawKeys["min_wall_width"]; !ok {
|
||||
settings.MinWallWidth = 1.5
|
||||
}
|
||||
|
||||
@@ -653,19 +653,6 @@ func main() {
|
||||
markPresetDirty()
|
||||
}))
|
||||
|
||||
buildingsPerRoadSlider := newNumericInputSlider(1, 20, float64(settings.BuildingsPerRoad), "%.0f", "Buildings Per Road")
|
||||
buildingsPerRoadSlider.entry.OnChanged = func(s string) {
|
||||
buildingsPerRoadSlider.validate(s, func(hasError bool) {
|
||||
errorStates["buildingsPerRoad"] = hasError
|
||||
updateGenerateBtnState()
|
||||
})
|
||||
}
|
||||
buildingsPerRoadSlider.value.AddListener(binding.NewDataListener(func() {
|
||||
val, _ := buildingsPerRoadSlider.value.Get()
|
||||
settings.BuildingsPerRoad = int(val)
|
||||
markPresetDirty()
|
||||
}))
|
||||
|
||||
roadExitsSlider := newNumericInputSlider(0, 100, float64(settings.RoadExits), "%.0f", "Road Exits")
|
||||
roadExitsSlider.entry.OnChanged = func(s string) {
|
||||
roadExitsSlider.validate(s, func(hasError bool) {
|
||||
@@ -1269,7 +1256,6 @@ func main() {
|
||||
roadsTab := container.NewTabItem("Roads", container.NewVBox(
|
||||
minRoadWidthSlider,
|
||||
maxRoadWidthSlider,
|
||||
buildingsPerRoadSlider,
|
||||
roadExitsSlider,
|
||||
minRoadAngleSlider,
|
||||
roadCurvynessSlider,
|
||||
@@ -1584,7 +1570,6 @@ func main() {
|
||||
|
||||
minRoadWidthSlider.value.Set(settings.MinRoadWidth)
|
||||
maxRoadWidthSlider.value.Set(settings.MaxRoadWidth)
|
||||
buildingsPerRoadSlider.value.Set(float64(settings.BuildingsPerRoad))
|
||||
roadExitsSlider.value.Set(float64(settings.RoadExits))
|
||||
roadCurvynessSlider.value.Set(settings.RoadCurvyness)
|
||||
roadDistributionSlider.value.Set(settings.RoadDistribution)
|
||||
|
||||
Reference in New Issue
Block a user