Draws the 2 triangles of the Terrainlist[index] (hardware)
| 3387 | } |
| 3388 | // Draws the 2 triangles of the Terrainlist[index] (hardware) |
| 3389 | void DrawTerrainLightmapsHardware(int index, int upper_left, int lower_right) { |
| 3390 | int i; |
| 3391 | int cur_seg; |
| 3392 | int n = Terrain_list[index].segment; |
| 3393 | int lod = Terrain_list[index].lod; |
| 3394 | int bottom_start, left_start, right_start; |
| 3395 | int point_count = 0; |
| 3396 | int points_this_triangle = 0; |
| 3397 | |
| 3398 | terrain_segment *tseg = &Terrain_seg[n]; |
| 3399 | int simplemul = 1 << ((MAX_TERRAIN_LOD - 1) - lod); |
| 3400 | int cx, cz, smul_x, smul_z; |
| 3401 | cx = n % TERRAIN_WIDTH; |
| 3402 | cz = n / TERRAIN_WIDTH; |
| 3403 | |
| 3404 | // Get lightmap coordinates |
| 3405 | float lightmap_u = (cx % 128) / 128.0; |
| 3406 | float lightmap_v = (128 - ((cz % 128) + simplemul)) / 128.0; |
| 3407 | float uvadjust; |
| 3408 | int draw_big_square = 0; |
| 3409 | bool solid_square = 1; |
| 3410 | int testt = 0, testr = 0, testb = 0, testl = 0; |
| 3411 | // Check to make sure we don't access memory that is off the map |
| 3412 | if (cx + simplemul == TERRAIN_WIDTH) { |
| 3413 | smul_x = simplemul - 1; |
| 3414 | solid_square = 0; |
| 3415 | } else |
| 3416 | smul_x = simplemul; |
| 3417 | if (cz + simplemul == TERRAIN_DEPTH) { |
| 3418 | solid_square = 0; |
| 3419 | smul_z = simplemul - 1; |
| 3420 | } else |
| 3421 | smul_z = simplemul; |
| 3422 | // Build a list of points for our polygon. We must do it this way to |
| 3423 | // prevent tjoint cracking |
| 3424 | // Do simpler operation if at highest level of detail |
| 3425 | if (lod == (MAX_TERRAIN_LOD - 1)) { |
| 3426 | uvadjust = (simplemul / 128.0); |
| 3427 | cur_seg = n + (TERRAIN_WIDTH * smul_z); |
| 3428 | base[0] = World_point_buffer[cur_seg]; |
| 3429 | |
| 3430 | cur_seg = n + (TERRAIN_WIDTH * smul_z) + smul_x; |
| 3431 | base[1] = World_point_buffer[cur_seg]; |
| 3432 | |
| 3433 | cur_seg = n + smul_x; |
| 3434 | base[2] = World_point_buffer[cur_seg]; |
| 3435 | |
| 3436 | base[3] = World_point_buffer[n]; |
| 3437 | |
| 3438 | base[0].p3_u = lightmap_u; |
| 3439 | base[0].p3_v = lightmap_v; |
| 3440 | base[1].p3_u = lightmap_u + uvadjust; |
| 3441 | base[1].p3_v = lightmap_v; |
| 3442 | base[2].p3_u = lightmap_u + uvadjust; |
| 3443 | base[2].p3_v = lightmap_v + uvadjust; |
| 3444 | |
| 3445 | base[3].p3_u = lightmap_u; |
| 3446 | base[3].p3_v = lightmap_v + uvadjust; |
no test coverage detected