| 2572 | } |
| 2573 | |
| 2574 | void DisplayTerrainList(int cellcount, bool from_automap) { |
| 2575 | int total = 0, on, t, i, lod, simplemul; |
| 2576 | int bm_handle; |
| 2577 | bool draw_lightmap = false; |
| 2578 | int savecell; |
| 2579 | int obj_to_draw; |
| 2580 | Terrain_objects_drawn = 0; |
| 2581 | rend_SetWrapType(WT_WRAP); |
| 2582 | if (!UseHardware) |
| 2583 | rend_SetColorModel(CM_MONO); |
| 2584 | else { |
| 2585 | rend_SetColorModel(CM_RGB); |
| 2586 | rend_SetTextureType(TT_LINEAR); |
| 2587 | rend_SetAlphaType(ATF_CONSTANT + ATF_TEXTURE); |
| 2588 | rend_SetLighting(LS_NONE); |
| 2589 | if (!StateLimited || UseMultitexture) |
| 2590 | draw_lightmap = true; |
| 2591 | } |
| 2592 | RotateTerrainList(cellcount, from_automap); |
| 2593 | if (!UseHardware) { |
| 2594 | SortTerrainList(cellcount); |
| 2595 | SortTerrainObjectsForRendering(cellcount); |
| 2596 | } |
| 2597 | // If state limited, sort by texture |
| 2598 | if (StateLimited || from_automap) |
| 2599 | SortStates(State_elements, cellcount); |
| 2600 | if (from_automap) { |
| 2601 | savecell = cellcount; |
| 2602 | cellcount = 0; |
| 2603 | } |
| 2604 | |
| 2605 | for (i = 0; i < cellcount; i++) { |
| 2606 | int cx, cz; |
| 2607 | int seg_to_render; |
| 2608 | if (StateLimited) |
| 2609 | seg_to_render = State_elements[i].facenum; |
| 2610 | else |
| 2611 | seg_to_render = i; |
| 2612 | t = Terrain_list[seg_to_render].segment; |
| 2613 | lod = Terrain_list[seg_to_render].lod; |
| 2614 | simplemul = 1 << ((MAX_TERRAIN_LOD - 1) - lod); |
| 2615 | |
| 2616 | cx = t % TERRAIN_WIDTH; |
| 2617 | cz = t / TERRAIN_WIDTH; |
| 2618 | |
| 2619 | if (cx < TERRAIN_WIDTH - simplemul && cz < TERRAIN_DEPTH - simplemul || lod != (MAX_TERRAIN_LOD - 1)) { |
| 2620 | int ul, lr; // upper_left,lower_right |
| 2621 | if (Terrain_seg[t].flags & TF_INVISIBLE) |
| 2622 | if (!Show_invisible_terrain) |
| 2623 | goto draw_objects; // bad! No gotos! -JL |
| 2624 | // Check to see if these triangles are visible if they're the smallest lod |
| 2625 | TerrainCellVisible(seg_to_render, &ul, &lr); |
| 2626 | |
| 2627 | total += (ul + lr); |
| 2628 | if (ul == 0 && lr == 0) |
| 2629 | goto draw_objects; |
| 2630 | |
| 2631 | bm_handle = GetTextureBitmap(Terrain_tex_seg[Terrain_seg[t].texseg_index].tex_index, 0); |
no test coverage detected