@@ -1141,76 +1141,56 @@ Dictionary TerrainGen::generate(
1141
1141
1142
1142
//
1143
1143
// +--------------------+---------------+--------------------+
1144
- // | NE (x - 1 , y - 1) | E (x , y - 1) | SE (x + 1, y - 1) |
1144
+ // | NW (x - 1 , y - 1) | N (x , y - 1) | NE (x + 1, y - 1) |
1145
1145
// +--------------------+---------------+--------------------+
1146
- // | N (x - 1 , y) | T (x,y) | S (x + 1) , y |
1146
+ // | W (x - 1 , y) | T (x,y) | E (x + 1) , y |
1147
1147
// +--------------------+---------------+--------------------+
1148
- // | NW (x - 1 , y + 1) | W (x , y + 1) | SW (x + 1 , y + 1) |
1148
+ // | SW (x - 1 , y + 1) | S (x , y + 1) | SE (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
+ // +----+----+----+ +----+----+----+ +----+----+----+
1152
+ // | m1 | m2 | m3 | | NW | N | NE | | | -Z | |
1153
+ // +----+----+----+ +----+----+----+ +----+----+----+
1154
+ // | m4 | T | m5 | | W | T | E | | -X | | X |
1155
+ // +----+----+----+ +----+----+----+ +----+----+----+
1156
+ // | m6 | m7 | m8 | | SW | S | SE | | | Z | |
1157
+ // +----+----+----+ +----+----+----+ +----+----+----+
1158
1158
//
1159
+ // Note : Cliff Corners point their ground toward game world : South East
1160
+ // Note : Ramp Corners point their high ground toward game world :
1159
1161
1160
1162
//
1161
1163
// Cardinal Neighbors
1162
1164
//
1163
1165
//
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
1175
1166
1176
- int nHeight = safe_height (x, y + 1 , t_height);
1177
- int nTile = safe_tile_at (x, y + 1 ); // m7
1167
+ int nHeight = safe_height (x, y - 1 , t_height);
1168
+ int nTile = safe_tile_at (x, y - 1 ); // m2
1178
1169
1179
1170
int eHeight = safe_height (x + 1 , y, t_height);
1180
1171
int eTile = safe_tile_at (x + 1 , y); // m5
1181
1172
1182
- int sHeight = safe_height (x, y - 1 , t_height);
1183
- int sTile = safe_tile_at (x, y - 1 ); // m2
1173
+ int sHeight = safe_height (x, y + 1 , t_height);
1174
+ int sTile = safe_tile_at (x, y + 1 ); // m7
1184
1175
1185
1176
int wHeight = safe_height (x - 1 , y, t_height);
1186
1177
int wTile = safe_tile_at (x - 1 , y); // m4
1187
1178
1188
1179
//
1189
1180
// Diagonal Neighbors
1190
1181
//
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
1182
1203
- int neHeight = safe_height (x + 1 , y + 1 , t_height);
1204
- int neTile = safe_tile_at (x + 1 , y + 1 ); // m3
1183
+ int neHeight = safe_height (x + 1 , y - 1 , t_height);
1184
+ int neTile = safe_tile_at (x + 1 , y - 1 ); // m3
1205
1185
1206
- int seHeight = safe_height (x + 1 , y - 1 , t_height);
1207
- int seTile = safe_tile_at (x + 1 , y - 1 ); // m8
1186
+ int seHeight = safe_height (x + 1 , y + 1 , t_height);
1187
+ int seTile = safe_tile_at (x + 1 , y + 1 ); // m8
1208
1188
1209
- int swHeight = safe_height (x - 1 , y - 1 , t_height);
1210
- int swTile = safe_tile_at (x - 1 , y - 1 ); // m6
1189
+ int swHeight = safe_height (x - 1 , y + 1 , t_height);
1190
+ int swTile = safe_tile_at (x - 1 , y + 1 ); // m6
1211
1191
1212
- int nwHeight = safe_height (x - 1 , y + 1 , t_height);
1213
- int nwTile = safe_tile_at (x - 1 , y + 1 ); // m1
1192
+ int nwHeight = safe_height (x - 1 , y - 1 , t_height);
1193
+ int nwTile = safe_tile_at (x - 1 , y - 1 ); // m1
1214
1194
1215
1195
//
1216
1196
// Water Tiles
@@ -1238,17 +1218,17 @@ Dictionary TerrainGen::generate(
1238
1218
}
1239
1219
1240
1220
if (tile_id == RAMP || tile_id == CLIFF || tile_id == WATER_EDGE) {
1241
- // +----+----+----+
1242
- // | m1 | m2 | m3 |
1243
- // +----+----+----+
1244
- // | m4 | T | m5 |
1245
- // +----+----+----+
1246
- // | m6 | m7 | m8 |
1247
- // +----+----+----+
1221
+ // +----+----+----+ +----+----+----+
1222
+ // | m1 | m2 | m3 | | NW | N | NE |
1223
+ // +----+----+----+ +----+----+----+
1224
+ // | m4 | T | m5 | | W | T | E |
1225
+ // +----+----+----+ +----+----+----+
1226
+ // | m6 | m7 | m8 | | SW | S | SE |
1227
+ // +----+----+----+ +----+----+----+
1248
1228
1249
1229
// Cardinal's
1250
1230
//
1251
- // N (m7 ), E (m5), S (m2 ), W (m4)
1231
+ // N (m2 ), E (m5), S (m7 ), W (m4)
1252
1232
//
1253
1233
// Only two possible combinations an edge piece can be placed
1254
1234
// Since an edge piece must connect from lower elevation to
@@ -1261,13 +1241,13 @@ Dictionary TerrainGen::generate(
1261
1241
// North is higher than South
1262
1242
// Point to m7
1263
1243
if (nHeight == sHeight + 1 && static_cast <TileType>(nTile) == GROUND) {
1264
- rotation_val = WEST ;
1244
+ rotation_val = EAST ;
1265
1245
}
1266
1246
1267
1247
// South is higher than North
1268
1248
// Point to m2
1269
1249
if (sHeight == nHeight + 1 && static_cast <TileType>(sTile ) == GROUND) {
1270
- rotation_val = EAST ;
1250
+ rotation_val = WEST ;
1271
1251
}
1272
1252
1273
1253
// East is higher than West
@@ -1284,13 +1264,13 @@ Dictionary TerrainGen::generate(
1284
1264
}
1285
1265
1286
1266
// T = Target Cell
1287
- // +----+----+----+
1288
- // | m1 | m2 | m3 |
1289
- // +----+----+----+
1290
- // | m4 | T | m5 |
1291
- // +----+----+----+
1292
- // | m6 | m7 | m8 |
1293
- // +----+----+----+
1267
+ // +----+----+----+ +----+----+----+
1268
+ // | m1 | m2 | m3 | | NW | N | NE |
1269
+ // +----+----+----+ +----+----+----+
1270
+ // | m4 | T | m5 | | W | T | E |
1271
+ // +----+----+----+ +----+----+----+
1272
+ // | m6 | m7 | m8 | | SW | S | SE |
1273
+ // +----+----+----+ +----+----+----+
1294
1274
//
1295
1275
// T should consider m2 + m5, m5 + m7, m7 + m4, and m4 + m2; for cliffs and ramps
1296
1276
// Then it should find the highest elevation of ground piece at, m3, m8, m6, m1
@@ -1325,13 +1305,13 @@ Dictionary TerrainGen::generate(
1325
1305
const bool swGround = (static_cast <TileType>(swTile) == GROUND);
1326
1306
const bool nwGround = (static_cast <TileType>(nwTile) == GROUND);
1327
1307
1328
- // +----+----+----+
1329
- // | m1 | m2 | m3 |
1330
- // +----+----+----+
1331
- // | m4 | T | m5 |
1332
- // +----+----+----+
1333
- // | m6 | m7 | m8 |
1334
- // +----+----+----+
1308
+ // +----+----+----+ +----+----+----+
1309
+ // | m1 | m2 | m3 | | NW | N | NE |
1310
+ // +----+----+----+ +----+----+----+
1311
+ // | m4 | T | m5 | | W | T | E |
1312
+ // +----+----+----+ +----+----+----+
1313
+ // | m6 | m7 | m8 | | SW | S | SE |
1314
+ // +----+----+----+ +----+----+----+
1335
1315
//
1336
1316
// Diagonal's
1337
1317
//
@@ -1345,41 +1325,41 @@ Dictionary TerrainGen::generate(
1345
1325
// North East
1346
1326
if (nEdge && eEdge && !sEdge && !wEdge) { // m2 + m5 | NOT m3
1347
1327
if (tile_id == CLIFF_CORNER)
1348
- rotation_val = WEST ;
1328
+ rotation_val = NORTH ;
1349
1329
if (tile_id == RAMP_CORNER)
1350
- rotation_val = EAST ;
1330
+ rotation_val = NORTH ;
1351
1331
if (tile_id == WATER_CORNER)
1352
- rotation_val = EAST ;
1332
+ rotation_val = NORTH ;
1353
1333
}
1354
1334
1355
1335
// South East
1356
1336
if (sEdge && eEdge && !nEdge && !wEdge) { // m5 + m7 | NOT m8
1357
1337
if (tile_id == CLIFF_CORNER)
1358
- rotation_val = NORTH ;
1338
+ rotation_val = EAST ;
1359
1339
if (tile_id == RAMP_CORNER)
1360
- rotation_val = SOUTH ;
1340
+ rotation_val = EAST ;
1361
1341
if (tile_id == WATER_CORNER)
1362
- rotation_val = SOUTH ;
1342
+ rotation_val = EAST ;
1363
1343
}
1364
1344
1365
1345
// South West
1366
1346
if (sEdge && wEdge && !nEdge && !eEdge) { // m4 + m7 | NOT m6
1367
1347
if (tile_id == CLIFF_CORNER)
1368
- rotation_val = EAST ;
1348
+ rotation_val = SOUTH ;
1369
1349
if (tile_id == RAMP_CORNER)
1370
- rotation_val = WEST ;
1350
+ rotation_val = SOUTH ;
1371
1351
if (tile_id == WATER_CORNER)
1372
- rotation_val = WEST ;
1352
+ rotation_val = SOUTH ;
1373
1353
}
1374
1354
1375
1355
// North West
1376
1356
if (nEdge && wEdge && !sEdge && !eEdge) { // m4 + m2 | NOT m1
1377
1357
if (tile_id == CLIFF_CORNER)
1378
- rotation_val = SOUTH ;
1358
+ rotation_val = WEST ;
1379
1359
if (tile_id == RAMP_CORNER)
1380
- rotation_val = NORTH ;
1360
+ rotation_val = WEST ;
1381
1361
if (tile_id == WATER_CORNER)
1382
- rotation_val = NORTH ;
1362
+ rotation_val = WEST ;
1383
1363
}
1384
1364
}
1385
1365
@@ -1404,13 +1384,21 @@ Dictionary TerrainGen::generate(
1404
1384
// EDGE CASE : Higher Ground has to connect to Cliffs 1
1405
1385
//
1406
1386
// +--------------------+---------------+--------------------+
1407
- // | NE (x - 1 , y - 1) | E (x , y - 1) | SE (x + 1, y - 1) |
1387
+ // | NW (x - 1 , y - 1) | N (x , y - 1) | NE (x + 1, y - 1) |
1408
1388
// +--------------------+---------------+--------------------+
1409
- // | N (x - 1 , y) | T (x,y) | S (x + 1) , y |
1389
+ // | W (x - 1 , y) | T (x,y) | E (x + 1) , y |
1410
1390
// +--------------------+---------------+--------------------+
1411
- // | NW (x - 1 , y + 1) | W (x , y + 1) | SW (x + 1 , y + 1) |
1391
+ // | SW (x - 1 , y + 1) | S (x , y + 1) | SE (x + 1 , y + 1) |
1412
1392
// +--------------------+---------------+--------------------+
1413
1393
//
1394
+ // +----+----+----+ +----+----+----+
1395
+ // | m1 | m2 | m3 | | NW | N | NE |
1396
+ // +----+----+----+ +----+----+----+
1397
+ // | m4 | T | m5 | | W | T | E |
1398
+ // +----+----+----+ +----+----+----+
1399
+ // | m6 | m7 | m8 | | SW | S | SE |
1400
+ // +----+----+----+ +----+----+----+
1401
+ //
1414
1402
// +----+----+----+ +----+----+----+ +----+----+----+
1415
1403
// | m1 | m2 | m3 | | G | R | X | | R | G | X |
1416
1404
// +----+----+----+ +----+----+----+ +----+----+----+
@@ -1420,50 +1408,58 @@ Dictionary TerrainGen::generate(
1420
1408
// +----+----+----+ +----+----+----+ +----+----+----+
1421
1409
//
1422
1410
1423
- if ((swTile == GROUND && sTile == RAMP && wTile == RAMP && tile_id == GROUND)) {
1411
+ if ((nwTile == GROUND && nTile == RAMP && wTile == RAMP && tile_id == GROUND)) {
1424
1412
// 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
1413
+ if (nwHeight > t_height) {
1414
+ myGridMap->set_cell_item (Vector3i (x - 1 , nwHeight , y - 1 ), CLIFF_CORNER_INNER, SOUTH ); // m1
1427
1415
} else {
1428
- myGridMap->set_cell_item (Vector3i (x, t_height, y), CLIFF_CORNER, EAST ); // T
1416
+ myGridMap->set_cell_item (Vector3i (x, t_height, y), CLIFF_CORNER_INNER, NORTH ); // T
1429
1417
}
1430
1418
1431
1419
// Get Orientation (Rotation) Value
1432
- int rot1 = myGridMap->get_cell_item_orientation (Vector3i (x, sHeight , y - 1 )); // m2
1420
+ int rot1 = myGridMap->get_cell_item_orientation (Vector3i (x, nHeight , y - 1 )); // m2
1433
1421
int rot2 = myGridMap->get_cell_item_orientation (Vector3i (x - 1 , wHeight, y)); // m4
1434
1422
1435
1423
// Set Ramps to Cliffs
1436
- myGridMap->set_cell_item (Vector3i (x, sHeight , y - 1 ), CLIFF, rot1); // m2
1424
+ myGridMap->set_cell_item (Vector3i (x, nHeight , y - 1 ), CLIFF, rot1); // m2
1437
1425
myGridMap->set_cell_item (Vector3i (x - 1 , wHeight, y), CLIFF, rot2); // m4
1438
1426
}
1439
1427
1440
- if ((swTile == RAMP && sTile == GROUND && wTile == GROUND && tile_id == RAMP)) {
1428
+ if ((nwTile == RAMP && nTile == GROUND && wTile == GROUND && tile_id == RAMP)) {
1441
1429
// Set Floating Ground to Cliff Corner
1442
- if (sHeight > wHeight) {
1443
- myGridMap->set_cell_item (Vector3i (x, sHeight , y - 1 ), CLIFF_CORNER, NORTH ); // m3
1430
+ if (nHeight > wHeight) {
1431
+ myGridMap->set_cell_item (Vector3i (x, nHeight , y - 1 ), CLIFF_CORNER_INNER, SOUTH ); // m2
1444
1432
} else {
1445
- myGridMap->set_cell_item (Vector3i (x - 1 , wHeight, y), CLIFF_CORNER, WEST ); // m4
1433
+ myGridMap->set_cell_item (Vector3i (x - 1 , wHeight, y), CLIFF_CORNER_INNER, NORTH ); // m4
1446
1434
}
1447
1435
1448
1436
// Get Orientation (Rotation) Value
1449
- int rot1 = myGridMap->get_cell_item_orientation (Vector3i (x - 1 , swHeight , y - 1 )); // m3
1437
+ int rot1 = myGridMap->get_cell_item_orientation (Vector3i (x - 1 , nwHeight , y - 1 )); // m1
1450
1438
int rot2 = myGridMap->get_cell_item_orientation (Vector3i (x, t_height, y)); // T
1451
1439
1452
1440
// Set Ramps to Cliffs
1453
- myGridMap->set_cell_item (Vector3i (x - 1 , swHeight , y - 1 ), CLIFF, rot1); // m3
1441
+ myGridMap->set_cell_item (Vector3i (x - 1 , nwHeight , y - 1 ), CLIFF, rot1); // m1
1454
1442
myGridMap->set_cell_item (Vector3i (x, t_height, y), CLIFF, rot2); // T
1455
1443
}
1456
1444
1457
1445
// EDGE CASE : Higher Ground has to connect to Cliffs 2
1458
1446
//
1459
1447
// +--------------------+---------------+--------------------+
1460
- // | NE (x - 1 , y - 1) | E (x , y - 1) | SE (x + 1, y - 1) |
1448
+ // | NW (x - 1 , y - 1) | N (x , y - 1) | NE (x + 1, y - 1) |
1461
1449
// +--------------------+---------------+--------------------+
1462
- // | N (x - 1 , y) | T (x,y) | S (x + 1) , y |
1450
+ // | W (x - 1 , y) | T (x,y) | E (x + 1) , y |
1463
1451
// +--------------------+---------------+--------------------+
1464
- // | NW (x - 1 , y + 1) | W (x , y + 1) | SW (x + 1 , y + 1) |
1452
+ // | SW (x - 1 , y + 1) | S (x , y + 1) | SE (x + 1 , y + 1) |
1465
1453
// +--------------------+---------------+--------------------+
1466
1454
//
1455
+ // +----+----+----+ +----+----+----+
1456
+ // | m1 | m2 | m3 | | NW | N | NE |
1457
+ // +----+----+----+ +----+----+----+
1458
+ // | m4 | T | m5 | | W | T | E |
1459
+ // +----+----+----+ +----+----+----+
1460
+ // | m6 | m7 | m8 | | SW | S | SE |
1461
+ // +----+----+----+ +----+----+----+
1462
+ //
1467
1463
// +----+----+----+ +----+----+----+ +----+----+----+
1468
1464
// | m1 | m2 | m3 | | X | G | R | | X | R | G |
1469
1465
// +----+----+----+ +----+----+----+ +----+----+----+
@@ -1472,36 +1468,36 @@ Dictionary TerrainGen::generate(
1472
1468
// | m6 | m7 | m8 | | X | X | X | | X | X | X |
1473
1469
// +----+----+----+ +----+----+----+ +----+----+----+
1474
1470
1475
- if ((seTile == RAMP && sTile == GROUND && eTile == GROUND && tile_id == RAMP)) {
1471
+ if ((neTile == RAMP && nTile == GROUND && eTile == GROUND && tile_id == RAMP)) {
1476
1472
// Set Floating Ground to Cliff Corner
1477
- if (sHeight > eHeight) {
1478
- myGridMap->set_cell_item (Vector3i (x, sHeight , y - 1 ), CLIFF_CORNER, WEST ); // m3
1473
+ if (nHeight > eHeight) {
1474
+ myGridMap->set_cell_item (Vector3i (x, nHeight , y - 1 ), CLIFF_CORNER_INNER, SOUTH ); // m2
1479
1475
} else {
1480
- myGridMap->set_cell_item (Vector3i (x + 1 , eHeight, y), CLIFF_CORNER, EAST ); // T
1476
+ myGridMap->set_cell_item (Vector3i (x + 1 , eHeight, y), CLIFF_CORNER_INNER, NORTH ); // m5
1481
1477
}
1482
1478
1483
1479
// Get Orientation (Rotation) Value
1484
- int rot1 = myGridMap->get_cell_item_orientation (Vector3i (x + 1 , seHeight , y - 1 )); // m3
1480
+ int rot1 = myGridMap->get_cell_item_orientation (Vector3i (x + 1 , neHeight , y - 1 )); // m3
1485
1481
int rot2 = myGridMap->get_cell_item_orientation (Vector3i (x, t_height, y)); // T
1486
1482
1487
1483
// Set Ramps to Cliffs
1488
- myGridMap->set_cell_item (Vector3i (x + 1 , seHeight , y - 1 ), CLIFF, rot1); // m3
1484
+ myGridMap->set_cell_item (Vector3i (x + 1 , neHeight , y - 1 ), CLIFF, rot1); // m3
1489
1485
myGridMap->set_cell_item (Vector3i (x, t_height, y), CLIFF, rot2); // T
1490
1486
}
1491
1487
1492
- if ((seTile == GROUND && sTile == RAMP && eTile == RAMP && tile_id == GROUND)) {
1488
+ if ((neTile == GROUND && nTile == RAMP && eTile == RAMP && tile_id == GROUND)) {
1493
1489
// 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
1490
+ if (neHeight > t_height) {
1491
+ myGridMap->set_cell_item (Vector3i (x + 1 , neHeight , y - 1 ), CLIFF_CORNER_INNER , NORTH); // m3
1496
1492
} else {
1497
- myGridMap->set_cell_item (Vector3i (x, t_height, y), CLIFF_CORNER , SOUTH); // T
1493
+ myGridMap->set_cell_item (Vector3i (x, t_height, y), CLIFF_CORNER_INNER , SOUTH); // T
1498
1494
}
1499
1495
1500
1496
// Set Ramp's to Cliffs
1501
- int rot1 = myGridMap->get_cell_item_orientation (Vector3i (x, sHeight , y - 1 )); // m2
1497
+ int rot1 = myGridMap->get_cell_item_orientation (Vector3i (x, nHeight , y - 1 )); // m2
1502
1498
int rot2 = myGridMap->get_cell_item_orientation (Vector3i (x + 1 , eHeight, y)); // m5
1503
1499
1504
- myGridMap->set_cell_item (Vector3i (x, sHeight , y - 1 ), CLIFF, rot1); // m2
1500
+ myGridMap->set_cell_item (Vector3i (x, nHeight , y - 1 ), CLIFF, rot1); // m2
1505
1501
myGridMap->set_cell_item (Vector3i (x + 1 , eHeight, y), CLIFF, rot2); // m5
1506
1502
}
1507
1503
0 commit comments