Changeset 18710
- Timestamp:
- Sep 6, 2016, 11:49:57 PM (8 years ago)
- Location:
- ps/trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/LICENSE.txt
r16705 r18710 38 38 39 39 /build/premake/*.lua 40 MIT 40 MIT 41 41 42 42 /docs … … 50 50 51 51 /source/lib 52 MIT 52 MIT 53 53 54 54 /source/scriptinterface/third_party … … 61 61 GPL version 2 (or later) 62 62 ISC (pkcs5_pbkdf2.cpp) 63 MIT (pkcs5_pbkdf2.h) 63 MIT (pkcs5_pbkdf2.h) 64 64 65 65 /source/third-party/jsonspirit 66 MIT 66 MIT 67 67 68 68 /source/third_party/mikktspace … … 70 70 71 71 /source/third_party/mongoose 72 MIT 72 MIT 73 73 74 74 /source/third_party/tinygettext … … 80 80 /source/tools/atlas 81 81 GPL version 2 (or later) - see license_gpl-2.0.txt 82 83 84 -
ps/trunk/binaries/data/mods/public/maps/random/rmgen2/gaia.js
r18650 r18710 1275 1275 * @param tilemap - The IDs of the palletmap to be painted for each heightmap tile 1276 1276 * @param pallet - The tile texture names used by the tilemap. 1277 * @return sthe ratio of heightmap tiles per map size tiles1277 * @return the ratio of heightmap tiles per map size tiles 1278 1278 */ 1279 1279 function paintHeightmap(heightmap, tilemap, pallet, func = undefined) 1280 1280 { 1281 let lastI = -1; 1282 let mapSize = getMapSize(); 1281 let mapSize = getMapSize(); // Width of the map in terrain tiles 1283 1282 let hmSize = Math.sqrt(heightmap.length); 1284 let scale = hmSize / mapSize; 1285 1286 for (let y = 0; y < mapSize; ++y) 1287 for (let x = 0; x < mapSize; ++x) 1288 { 1289 let i = Math.floor(x * scale) * hmSize + Math.floor(y * scale); 1290 1291 let height = heightmap[i]; 1292 let tile = pallet[tilemap[i]]; 1293 1294 if (i == lastI) 1283 let scale = hmSize / (mapSize + 1); // There are mapSize + 1 vertices (each 1 tile is surrounded by 2x2 vertices) 1284 1285 for (let x = 0; x <= mapSize; ++x) 1286 for (let y = 0; y <= mapSize; ++y) 1287 { 1288 let hmPoint = { "x": x * scale, "y": y * scale }; 1289 let hmTile = { "x": Math.floor(hmPoint.x), "y": Math.floor(hmPoint.y) }; 1290 let shift = { "x": 0, "y": 0 }; 1291 1292 if (hmTile.x == 0) 1293 shift.x = 1; 1294 else if (hmTile.x == hmSize - 1) 1295 shift.x = - 2; 1296 else if (hmTile.x == hmSize - 2) 1297 shift.x = - 1; 1298 1299 if (hmTile.y == 0) 1300 shift.y = 1; 1301 else if (hmTile.y == hmSize - 1) 1302 shift.y = - 2; 1303 else if (hmTile.y == hmSize - 2) 1304 shift.y = - 1; 1305 1306 let neighbors = []; 1307 for (let localYi = 0; localYi < 4; ++localYi) 1308 for (let localXi = 0; localXi < 4; ++localXi) 1309 neighbors.push(heightmap[(hmTile.x + localXi + shift.x - 1) * hmSize + (hmTile.y + localYi + shift.y - 1)]); 1310 1311 setHeight(x, y, bicubicInterpolation(hmPoint.x - hmTile.x - shift.x, hmPoint.y - hmTile.y - shift.y, ...neighbors) / scale); 1312 1313 if (x < mapSize && y < mapSize) 1295 1314 { 1296 let nearby = [i]; 1297 1298 if (i + hmSize < heightmap.length) 1299 { 1300 nearby.push(i + hmSize); 1301 height = (heightmap[nearby[0]] + heightmap[nearby[1]]) / 2; 1302 } 1303 1304 tile = pallet[tilemap[nearby[randInt(0, nearby.length - 1)]]]; 1315 let i = hmTile.x * hmSize + hmTile.y; 1316 let tile = pallet[tilemap[i]]; 1317 placeTerrain(x, y, tile); 1318 1319 if (func) 1320 func(tile, x, y); 1305 1321 } 1306 1307 setHeight(x, y, height / scale);1308 placeTerrain(x, y, tile);1309 1310 if (func)1311 func(tile, x, y);1312 1313 lastI = i;1314 1322 } 1315 1323
Note:
See TracChangeset
for help on using the changeset viewer.