@@ -1141,76 +1141,56 @@ Dictionary TerrainGen::generate(
11411141
11421142 //
11431143 // +--------------------+---------------+--------------------+
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) |
11451145 // +--------------------+---------------+--------------------+
1146- // | N (x - 1 , y) | T (x,y) | S (x + 1) , y |
1146+ // | W (x - 1 , y) | T (x,y) | E (x + 1) , y |
11471147 // +--------------------+---------------+--------------------+
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) |
11491149 // +--------------------+---------------+--------------------+
11501150 //
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+ // +----+----+----+ +----+----+----+ +----+----+----+
11581158 //
1159+ // Note : Cliff Corners point their ground toward game world : South East
1160+ // Note : Ramp Corners point their high ground toward game world :
11591161
11601162 //
11611163 // Cardinal Neighbors
11621164 //
11631165 //
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
11751166
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
11781169
11791170 int eHeight = safe_height (x + 1 , y, t_height);
11801171 int eTile = safe_tile_at (x + 1 , y); // m5
11811172
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
11841175
11851176 int wHeight = safe_height (x - 1 , y, t_height);
11861177 int wTile = safe_tile_at (x - 1 , y); // m4
11871178
11881179 //
11891180 // Diagonal Neighbors
11901181 //
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
12021182
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
12051185
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
12081188
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
12111191
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
12141194
12151195 //
12161196 // Water Tiles
@@ -1238,17 +1218,17 @@ Dictionary TerrainGen::generate(
12381218 }
12391219
12401220 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+ // +----+----+----+ +----+----+----+
12481228
12491229 // Cardinal's
12501230 //
1251- // N (m7 ), E (m5), S (m2 ), W (m4)
1231+ // N (m2 ), E (m5), S (m7 ), W (m4)
12521232 //
12531233 // Only two possible combinations an edge piece can be placed
12541234 // Since an edge piece must connect from lower elevation to
@@ -1261,13 +1241,13 @@ Dictionary TerrainGen::generate(
12611241 // North is higher than South
12621242 // Point to m7
12631243 if (nHeight == sHeight + 1 && static_cast <TileType>(nTile) == GROUND) {
1264- rotation_val = WEST ;
1244+ rotation_val = EAST ;
12651245 }
12661246
12671247 // South is higher than North
12681248 // Point to m2
12691249 if (sHeight == nHeight + 1 && static_cast <TileType>(sTile ) == GROUND) {
1270- rotation_val = EAST ;
1250+ rotation_val = WEST ;
12711251 }
12721252
12731253 // East is higher than West
@@ -1284,13 +1264,13 @@ Dictionary TerrainGen::generate(
12841264 }
12851265
12861266 // 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+ // +----+----+----+ +----+----+----+
12941274 //
12951275 // T should consider m2 + m5, m5 + m7, m7 + m4, and m4 + m2; for cliffs and ramps
12961276 // Then it should find the highest elevation of ground piece at, m3, m8, m6, m1
@@ -1325,13 +1305,13 @@ Dictionary TerrainGen::generate(
13251305 const bool swGround = (static_cast <TileType>(swTile) == GROUND);
13261306 const bool nwGround = (static_cast <TileType>(nwTile) == GROUND);
13271307
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+ // +----+----+----+ +----+----+----+
13351315 //
13361316 // Diagonal's
13371317 //
@@ -1345,41 +1325,41 @@ Dictionary TerrainGen::generate(
13451325 // North East
13461326 if (nEdge && eEdge && !sEdge && !wEdge) { // m2 + m5 | NOT m3
13471327 if (tile_id == CLIFF_CORNER)
1348- rotation_val = WEST ;
1328+ rotation_val = NORTH ;
13491329 if (tile_id == RAMP_CORNER)
1350- rotation_val = EAST ;
1330+ rotation_val = NORTH ;
13511331 if (tile_id == WATER_CORNER)
1352- rotation_val = EAST ;
1332+ rotation_val = NORTH ;
13531333 }
13541334
13551335 // South East
13561336 if (sEdge && eEdge && !nEdge && !wEdge) { // m5 + m7 | NOT m8
13571337 if (tile_id == CLIFF_CORNER)
1358- rotation_val = NORTH ;
1338+ rotation_val = EAST ;
13591339 if (tile_id == RAMP_CORNER)
1360- rotation_val = SOUTH ;
1340+ rotation_val = EAST ;
13611341 if (tile_id == WATER_CORNER)
1362- rotation_val = SOUTH ;
1342+ rotation_val = EAST ;
13631343 }
13641344
13651345 // South West
13661346 if (sEdge && wEdge && !nEdge && !eEdge) { // m4 + m7 | NOT m6
13671347 if (tile_id == CLIFF_CORNER)
1368- rotation_val = EAST ;
1348+ rotation_val = SOUTH ;
13691349 if (tile_id == RAMP_CORNER)
1370- rotation_val = WEST ;
1350+ rotation_val = SOUTH ;
13711351 if (tile_id == WATER_CORNER)
1372- rotation_val = WEST ;
1352+ rotation_val = SOUTH ;
13731353 }
13741354
13751355 // North West
13761356 if (nEdge && wEdge && !sEdge && !eEdge) { // m4 + m2 | NOT m1
13771357 if (tile_id == CLIFF_CORNER)
1378- rotation_val = SOUTH ;
1358+ rotation_val = WEST ;
13791359 if (tile_id == RAMP_CORNER)
1380- rotation_val = NORTH ;
1360+ rotation_val = WEST ;
13811361 if (tile_id == WATER_CORNER)
1382- rotation_val = NORTH ;
1362+ rotation_val = WEST ;
13831363 }
13841364 }
13851365
@@ -1404,13 +1384,21 @@ Dictionary TerrainGen::generate(
14041384 // EDGE CASE : Higher Ground has to connect to Cliffs 1
14051385 //
14061386 // +--------------------+---------------+--------------------+
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) |
14081388 // +--------------------+---------------+--------------------+
1409- // | N (x - 1 , y) | T (x,y) | S (x + 1) , y |
1389+ // | W (x - 1 , y) | T (x,y) | E (x + 1) , y |
14101390 // +--------------------+---------------+--------------------+
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) |
14121392 // +--------------------+---------------+--------------------+
14131393 //
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+ //
14141402 // +----+----+----+ +----+----+----+ +----+----+----+
14151403 // | m1 | m2 | m3 | | G | R | X | | R | G | X |
14161404 // +----+----+----+ +----+----+----+ +----+----+----+
@@ -1420,50 +1408,58 @@ Dictionary TerrainGen::generate(
14201408 // +----+----+----+ +----+----+----+ +----+----+----+
14211409 //
14221410
1423- if ((swTile == GROUND && sTile == RAMP && wTile == RAMP && tile_id == GROUND)) {
1411+ if ((nwTile == GROUND && nTile == RAMP && wTile == RAMP && tile_id == GROUND)) {
14241412 // 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
14271415 } 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
14291417 }
14301418
14311419 // 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
14331421 int rot2 = myGridMap->get_cell_item_orientation (Vector3i (x - 1 , wHeight, y)); // m4
14341422
14351423 // 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
14371425 myGridMap->set_cell_item (Vector3i (x - 1 , wHeight, y), CLIFF, rot2); // m4
14381426 }
14391427
1440- if ((swTile == RAMP && sTile == GROUND && wTile == GROUND && tile_id == RAMP)) {
1428+ if ((nwTile == RAMP && nTile == GROUND && wTile == GROUND && tile_id == RAMP)) {
14411429 // 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
14441432 } 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
14461434 }
14471435
14481436 // 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
14501438 int rot2 = myGridMap->get_cell_item_orientation (Vector3i (x, t_height, y)); // T
14511439
14521440 // 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
14541442 myGridMap->set_cell_item (Vector3i (x, t_height, y), CLIFF, rot2); // T
14551443 }
14561444
14571445 // EDGE CASE : Higher Ground has to connect to Cliffs 2
14581446 //
14591447 // +--------------------+---------------+--------------------+
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) |
14611449 // +--------------------+---------------+--------------------+
1462- // | N (x - 1 , y) | T (x,y) | S (x + 1) , y |
1450+ // | W (x - 1 , y) | T (x,y) | E (x + 1) , y |
14631451 // +--------------------+---------------+--------------------+
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) |
14651453 // +--------------------+---------------+--------------------+
14661454 //
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+ //
14671463 // +----+----+----+ +----+----+----+ +----+----+----+
14681464 // | m1 | m2 | m3 | | X | G | R | | X | R | G |
14691465 // +----+----+----+ +----+----+----+ +----+----+----+
@@ -1472,36 +1468,36 @@ Dictionary TerrainGen::generate(
14721468 // | m6 | m7 | m8 | | X | X | X | | X | X | X |
14731469 // +----+----+----+ +----+----+----+ +----+----+----+
14741470
1475- if ((seTile == RAMP && sTile == GROUND && eTile == GROUND && tile_id == RAMP)) {
1471+ if ((neTile == RAMP && nTile == GROUND && eTile == GROUND && tile_id == RAMP)) {
14761472 // 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
14791475 } 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
14811477 }
14821478
14831479 // 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
14851481 int rot2 = myGridMap->get_cell_item_orientation (Vector3i (x, t_height, y)); // T
14861482
14871483 // 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
14891485 myGridMap->set_cell_item (Vector3i (x, t_height, y), CLIFF, rot2); // T
14901486 }
14911487
1492- if ((seTile == GROUND && sTile == RAMP && eTile == RAMP && tile_id == GROUND)) {
1488+ if ((neTile == GROUND && nTile == RAMP && eTile == RAMP && tile_id == GROUND)) {
14931489 // 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
14961492 } 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
14981494 }
14991495
15001496 // 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
15021498 int rot2 = myGridMap->get_cell_item_orientation (Vector3i (x + 1 , eHeight, y)); // m5
15031499
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
15051501 myGridMap->set_cell_item (Vector3i (x + 1 , eHeight, y), CLIFF, rot2); // m5
15061502 }
15071503
0 commit comments