Builds the min max quadtree data for terrain VSD
| 305 | |
| 306 | // Builds the min max quadtree data for terrain VSD |
| 307 | void BuildMinMaxTerrain() { |
| 308 | int i, w, h, start, x, y, cell; |
| 309 | int row_width, xoffset, yoffset, total_rows; |
| 310 | int minheight, maxheight, cellheight; |
| 311 | |
| 312 | mprintf(0, "Building min/max terrain table.\n"); |
| 313 | |
| 314 | // Calculate our integer y positions (0-255) |
| 315 | for (i = 0; i < TERRAIN_WIDTH * TERRAIN_DEPTH; i++) { |
| 316 | float fl; |
| 317 | |
| 318 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 319 | Terrain_seg_render_objs[i] = -1; |
| 320 | #endif |
| 321 | |
| 322 | fl = Terrain_seg[i].ypos * TERRAIN_HEIGHT_INCREMENT; |
| 323 | |
| 324 | Terrain_seg[i].y = fl; |
| 325 | } |
| 326 | |
| 327 | int check = GetTerrainGeometryChecksum(); |
| 328 | |
| 329 | if (check == Terrain_checksum) |
| 330 | return; |
| 331 | |
| 332 | Terrain_checksum = check; |
| 333 | |
| 334 | // Generate level of detail deltas |
| 335 | if (!Dedicated_server) |
| 336 | GenerateLODDeltas(); |
| 337 | |
| 338 | for (i = 0; i < 7; i++) { |
| 339 | row_width = 1 << i; |
| 340 | total_rows = 1 << i; |
| 341 | int yspeed_offset = 0; |
| 342 | |
| 343 | for (yoffset = 0; yoffset < total_rows; yoffset++, yspeed_offset += row_width) { |
| 344 | for (xoffset = 0; xoffset < row_width; xoffset++) { |
| 345 | w = TERRAIN_WIDTH >> i; |
| 346 | h = TERRAIN_WIDTH >> i; |
| 347 | |
| 348 | start = ((yoffset * (TERRAIN_WIDTH >> i)) * TERRAIN_WIDTH); |
| 349 | start += (xoffset * (TERRAIN_WIDTH >> i)); |
| 350 | |
| 351 | minheight = 999; |
| 352 | maxheight = 0; |
| 353 | |
| 354 | if (h < TERRAIN_DEPTH) |
| 355 | h++; |
| 356 | if (w < TERRAIN_DEPTH) |
| 357 | w++; |
| 358 | |
| 359 | int terrain_offset = 0; |
| 360 | for (y = 0; y < h; y++, terrain_offset += TERRAIN_WIDTH) { |
| 361 | for (x = 0; x < w; x++) { |
| 362 | cell = start + (terrain_offset) + x; |
| 363 | cellheight = Terrain_seg[cell].ypos; |
| 364 |
no test coverage detected