@@ -1115,8 +1115,8 @@ Dictionary TerrainGen::generate(
1115
1115
1116
1116
for (int x = 0 ; x < width; x++) {
1117
1117
for (int y = 0 ; y < height; y++) {
1118
- int c_height = elevationMap[x][y];
1119
- int tile_id = myGridMap->get_cell_item (Vector3i (x, c_height , y));
1118
+ int t_height = elevationMap[x][y];
1119
+ int tile_id = myGridMap->get_cell_item (Vector3i (x, t_height , y));
1120
1120
if (tile_id == -1 || tile_id == GROUND)
1121
1121
continue ;
1122
1122
@@ -1141,44 +1141,75 @@ Dictionary TerrainGen::generate(
1141
1141
1142
1142
//
1143
1143
// +--------------------+---------------+--------------------+
1144
- // | SW (x - 1 , y - 1) | S (x , y - 1) | SE (x + 1, y - 1) |
1144
+ // | NE (x - 1 , y - 1) | E (x , y - 1) | SE (x + 1, y - 1) |
1145
1145
// +--------------------+---------------+--------------------+
1146
- // | W (x - 1 , y) | T (x,y) | E (x + 1) , y |
1146
+ // | N (x - 1 , y) | T (x,y) | S (x + 1) , y |
1147
1147
// +--------------------+---------------+--------------------+
1148
- // | NW (x - 1 , y + 1) | N (x , y + 1) | NE (x + 1 , y + 1) |
1148
+ // | NW (x - 1 , y + 1) | W (x , y + 1) | SW (x + 1 , y + 1) |
1149
1149
// +--------------------+---------------+--------------------+
1150
1150
//
1151
+ // +----+----+----+ +----+----+----+
1152
+ // | m1 | m2 | m3 | | NE | E | SE |
1153
+ // +----+----+----+ +----+----+----+
1154
+ // | m4 | T | m5 | | N | T | S |
1155
+ // +----+----+----+ +----+----+----+
1156
+ // | m6 | m7 | m8 | | NW | W | SW |
1157
+ // +----+----+----+ +----+----+----+
1151
1158
//
1152
1159
1153
1160
//
1154
1161
// Cardinal Neighbors
1155
1162
//
1156
1163
//
1157
- int sHeight = safe_height (x, y - 1 , c_height);
1158
- int sTile = safe_tile_at (x, y - 1 ); // m2
1164
+ // int nHeight = safe_height(x, y + 1, t_height);
1165
+ // int nTile = safe_tile_at(x, y + 1); // m7
1166
+
1167
+ // int eHeight = safe_height(x + 1, y, t_height);
1168
+ // int eTile = safe_tile_at(x + 1, y); // m5
1169
+
1170
+ // int sHeight = safe_height(x, y - 1, t_height);
1171
+ // int sTile = safe_tile_at(x, y - 1); // m2
1172
+
1173
+ // int wHeight = safe_height(x - 1, y, t_height);
1174
+ // int wTile = safe_tile_at(x - 1, y); // m4
1159
1175
1160
- int nHeight = safe_height (x, y + 1 , c_height );
1176
+ int nHeight = safe_height (x, y + 1 , t_height );
1161
1177
int nTile = safe_tile_at (x, y + 1 ); // m7
1162
1178
1163
- int eHeight = safe_height (x + 1 , y, c_height );
1179
+ int eHeight = safe_height (x + 1 , y, t_height );
1164
1180
int eTile = safe_tile_at (x + 1 , y); // m5
1165
1181
1166
- int wHeight = safe_height (x - 1 , y, c_height);
1182
+ int sHeight = safe_height (x, y - 1 , t_height);
1183
+ int sTile = safe_tile_at (x, y - 1 ); // m2
1184
+
1185
+ int wHeight = safe_height (x - 1 , y, t_height);
1167
1186
int wTile = safe_tile_at (x - 1 , y); // m4
1168
1187
1169
1188
//
1170
1189
// Diagonal Neighbors
1171
1190
//
1172
- int neHeight = safe_height (x + 1 , y + 1 , c_height);
1191
+ // int neHeight = safe_height(x + 1, y + 1, t_height);
1192
+ // int neTile = safe_tile_at(x + 1, y + 1); // m3
1193
+
1194
+ // int seHeight = safe_height(x + 1, y - 1, t_height);
1195
+ // int seTile = safe_tile_at(x + 1, y - 1); // m8
1196
+
1197
+ // int swHeight = safe_height(x - 1, y - 1, t_height);
1198
+ // int swTile = safe_tile_at(x - 1, y - 1); // m6
1199
+
1200
+ // int nwHeight = safe_height(x - 1, y + 1, t_height);
1201
+ // int nwTile = safe_tile_at(x - 1, y + 1); // m1
1202
+
1203
+ int neHeight = safe_height (x + 1 , y + 1 , t_height);
1173
1204
int neTile = safe_tile_at (x + 1 , y + 1 ); // m3
1174
1205
1175
- int seHeight = safe_height (x + 1 , y - 1 , c_height );
1206
+ int seHeight = safe_height (x + 1 , y - 1 , t_height );
1176
1207
int seTile = safe_tile_at (x + 1 , y - 1 ); // m8
1177
1208
1178
- int swHeight = safe_height (x - 1 , y - 1 , c_height );
1209
+ int swHeight = safe_height (x - 1 , y - 1 , t_height );
1179
1210
int swTile = safe_tile_at (x - 1 , y - 1 ); // m6
1180
1211
1181
- int nwHeight = safe_height (x - 1 , y + 1 , c_height );
1212
+ int nwHeight = safe_height (x - 1 , y + 1 , t_height );
1182
1213
int nwTile = safe_tile_at (x - 1 , y + 1 ); // m1
1183
1214
1184
1215
//
@@ -1354,37 +1385,134 @@ Dictionary TerrainGen::generate(
1354
1385
1355
1386
if (tile_id == RAMP_CORNER) {
1356
1387
// Place Ground under Ramp Tiles
1357
- myGridMap->set_cell_item (Vector3i (x, c_height - 1 , y), GROUND, rotation_val);
1388
+ myGridMap->set_cell_item (Vector3i (x, t_height - 1 , y), GROUND, rotation_val);
1358
1389
}
1359
1390
1360
- myGridMap->set_cell_item (Vector3i (x, c_height , y), tile_id, rotation_val);
1391
+ myGridMap->set_cell_item (Vector3i (x, t_height , y), tile_id, rotation_val);
1361
1392
1362
1393
// ? : Below is 2 Edge case's that need fixed
1363
1394
// TODO : Fix these Edge Case's
1364
1395
1365
- // EDGE CASE : Higher Ground has to connect to Cliffs
1366
- // nwTile = m1 (n1) | sTile = m2 (n2) | wTile = m4 (n3) | T = tile_id (n4)
1396
+ /* ****************************************************
1397
+
1398
+ EDGE CASE FIX :
1399
+
1400
+ Floating Ground Tile Fix
1401
+
1402
+ *****************************************************/
1403
+
1404
+ // EDGE CASE : Higher Ground has to connect to Cliffs 1
1405
+ //
1406
+ // +--------------------+---------------+--------------------+
1407
+ // | NE (x - 1 , y - 1) | E (x , y - 1) | SE (x + 1, y - 1) |
1408
+ // +--------------------+---------------+--------------------+
1409
+ // | N (x - 1 , y) | T (x,y) | S (x + 1) , y |
1410
+ // +--------------------+---------------+--------------------+
1411
+ // | NW (x - 1 , y + 1) | W (x , y + 1) | SW (x + 1 , y + 1) |
1412
+ // +--------------------+---------------+--------------------+
1367
1413
//
1368
- // +----+----+ +----+----+ +----+----+ +----+----+
1369
- // | n1 | n2 | | g1 | r2 | | r2 | g1 | | g1 | c2 |
1370
- // +----+----+ +----+----+ +----+----+ -> +----+----+
1371
- // | n3 | n4 | | r2 | g2 | | g2 | r2 | | c2 | g2 |
1372
- // +----+----+ +----+----+ +----+----+ +----+----+
1414
+ // +----+----+----+ +----+----+----+ +----+----+----+
1415
+ // | m1 | m2 | m3 | | G | R | X | | R | G | X |
1416
+ // +----+----+----+ +----+----+----+ +----+----+----+
1417
+ // | m4 | T | m5 | | R | G | X | | G | R | X |
1418
+ // +----+----+----+ +----+----+----+ +----+----+----+
1419
+ // | m6 | m7 | m8 | | X | X | X | | X | X | X |
1420
+ // +----+----+----+ +----+----+----+ +----+----+----+
1373
1421
//
1374
- if ((nwTile == GROUND && sTile == RAMP && wTile == RAMP && tile_id == GROUND)) {
1422
+
1423
+ if ((swTile == GROUND && sTile == RAMP && wTile == RAMP && tile_id == GROUND)) {
1424
+ // Set Floating Ground to Cliff Corner
1425
+ if (swHeight > t_height) {
1426
+ myGridMap->set_cell_item (Vector3i (x - 1 , swHeight, y - 1 ), CLIFF_CORNER, WEST); // m1
1427
+ } else {
1428
+ myGridMap->set_cell_item (Vector3i (x, t_height, y), CLIFF_CORNER, EAST); // T
1429
+ }
1430
+
1375
1431
// Get Orientation (Rotation) Value
1376
- int n1O = myGridMap->get_cell_item_orientation (Vector3i (x - 1 , nwHeight, y - 1 )); // m1
1377
- // int n2O = myGridMap->get_cell_item_orientation(Vector3i(x, sHeight, y - 1)); // m2
1378
- // int n3O = myGridMap->get_cell_item_orientation(Vector3i(x - 1, wHeight, y)); // m4
1379
- int n4O = myGridMap->get_cell_item_orientation (Vector3i (x, c_height, y)); // Target
1432
+ int rot1 = myGridMap->get_cell_item_orientation (Vector3i (x, sHeight , y - 1 )); // m2
1433
+ int rot2 = myGridMap->get_cell_item_orientation (Vector3i (x - 1 , wHeight, y)); // m4
1380
1434
1381
1435
// Set Ramps to Cliffs
1382
- myGridMap->set_cell_item (Vector3i (x - 1 , nwHeight, y - 1 ), CLIFF, n1O); // n1
1383
- // myGridMap->set_cell_item(Vector3i(x, sHeight, y - 1), CLIFF, n2O); // n2
1384
- // myGridMap->set_cell_item(Vector3i(x - 1, wHeight, y), CLIFF, n3O); // n3
1385
- myGridMap->set_cell_item (Vector3i (x, c_height, y), CLIFF, n4O); // n4
1436
+ myGridMap->set_cell_item (Vector3i (x, sHeight , y - 1 ), CLIFF, rot1); // m2
1437
+ myGridMap->set_cell_item (Vector3i (x - 1 , wHeight, y), CLIFF, rot2); // m4
1386
1438
}
1387
1439
1440
+ if ((swTile == RAMP && sTile == GROUND && wTile == GROUND && tile_id == RAMP)) {
1441
+ // Set Floating Ground to Cliff Corner
1442
+ if (sHeight > wHeight) {
1443
+ myGridMap->set_cell_item (Vector3i (x, sHeight , y - 1 ), CLIFF_CORNER, NORTH); // m3
1444
+ } else {
1445
+ myGridMap->set_cell_item (Vector3i (x - 1 , wHeight, y), CLIFF_CORNER, WEST); // m4
1446
+ }
1447
+
1448
+ // Get Orientation (Rotation) Value
1449
+ int rot1 = myGridMap->get_cell_item_orientation (Vector3i (x - 1 , swHeight, y - 1 )); // m3
1450
+ int rot2 = myGridMap->get_cell_item_orientation (Vector3i (x, t_height, y)); // T
1451
+
1452
+ // Set Ramps to Cliffs
1453
+ myGridMap->set_cell_item (Vector3i (x - 1 , swHeight, y - 1 ), CLIFF, rot1); // m3
1454
+ myGridMap->set_cell_item (Vector3i (x, t_height, y), CLIFF, rot2); // T
1455
+ }
1456
+
1457
+ // EDGE CASE : Higher Ground has to connect to Cliffs 2
1458
+ //
1459
+ // +--------------------+---------------+--------------------+
1460
+ // | NE (x - 1 , y - 1) | E (x , y - 1) | SE (x + 1, y - 1) |
1461
+ // +--------------------+---------------+--------------------+
1462
+ // | N (x - 1 , y) | T (x,y) | S (x + 1) , y |
1463
+ // +--------------------+---------------+--------------------+
1464
+ // | NW (x - 1 , y + 1) | W (x , y + 1) | SW (x + 1 , y + 1) |
1465
+ // +--------------------+---------------+--------------------+
1466
+ //
1467
+ // +----+----+----+ +----+----+----+ +----+----+----+
1468
+ // | m1 | m2 | m3 | | X | G | R | | X | R | G |
1469
+ // +----+----+----+ +----+----+----+ +----+----+----+
1470
+ // | m4 | T | m5 | | X | R | G | | X | G | R |
1471
+ // +----+----+----+ +----+----+----+ +----+----+----+
1472
+ // | m6 | m7 | m8 | | X | X | X | | X | X | X |
1473
+ // +----+----+----+ +----+----+----+ +----+----+----+
1474
+
1475
+ if ((seTile == RAMP && sTile == GROUND && eTile == GROUND && tile_id == RAMP)) {
1476
+ // Set Floating Ground to Cliff Corner
1477
+ if (sHeight > eHeight) {
1478
+ myGridMap->set_cell_item (Vector3i (x, sHeight , y - 1 ), CLIFF_CORNER, WEST); // m3
1479
+ } else {
1480
+ myGridMap->set_cell_item (Vector3i (x + 1 , eHeight, y), CLIFF_CORNER, EAST); // T
1481
+ }
1482
+
1483
+ // Get Orientation (Rotation) Value
1484
+ int rot1 = myGridMap->get_cell_item_orientation (Vector3i (x + 1 , seHeight, y - 1 )); // m3
1485
+ int rot2 = myGridMap->get_cell_item_orientation (Vector3i (x, t_height, y)); // T
1486
+
1487
+ // Set Ramps to Cliffs
1488
+ myGridMap->set_cell_item (Vector3i (x + 1 , seHeight, y - 1 ), CLIFF, rot1); // m3
1489
+ myGridMap->set_cell_item (Vector3i (x, t_height, y), CLIFF, rot2); // T
1490
+ }
1491
+
1492
+ if ((seTile == GROUND && sTile == RAMP && eTile == RAMP && tile_id == GROUND)) {
1493
+ // Set Floating Ground to Cliff Corner
1494
+ if (seHeight > t_height) {
1495
+ myGridMap->set_cell_item (Vector3i (x + 1 , seHeight, y - 1 ), CLIFF_CORNER, NORTH); // m3
1496
+ } else {
1497
+ myGridMap->set_cell_item (Vector3i (x, t_height, y), CLIFF_CORNER, SOUTH); // T
1498
+ }
1499
+
1500
+ // Set Ramp's to Cliffs
1501
+ int rot1 = myGridMap->get_cell_item_orientation (Vector3i (x, sHeight , y - 1 )); // m2
1502
+ int rot2 = myGridMap->get_cell_item_orientation (Vector3i (x + 1 , eHeight, y)); // m5
1503
+
1504
+ myGridMap->set_cell_item (Vector3i (x, sHeight , y - 1 ), CLIFF, rot1); // m2
1505
+ myGridMap->set_cell_item (Vector3i (x + 1 , eHeight, y), CLIFF, rot2); // m5
1506
+ }
1507
+
1508
+ /* ****************************************************
1509
+
1510
+ EDGE CASE FIX :
1511
+
1512
+
1513
+
1514
+ *****************************************************/
1515
+
1388
1516
// EDGE CASE : Higher Ground has to connect to Cliffs
1389
1517
//
1390
1518
// +----+----+ +----+----+ +----+----+ +----+----+ +----+----+ +----+----+
0 commit comments