MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / SortTerrainList

Function SortTerrainList

Descent3/terrainrender.cpp:2257–2282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2255#endif
2256int TerrainSortingFunction(const terrain_render_info *a, terrain_render_info *b) { return b->z - a->z; }
2257void SortTerrainList(int cellcount) {
2258 int i, t, k;
2259 int lod, simplemul;
2260 int n[4];
2261
2262 for (i = 0; i < cellcount; i++) {
2263 t = Terrain_list[i].segment;
2264 lod = Terrain_list[i].lod;
2265#if (!defined(RELEASE) || defined(NEWEDITOR))
2266 Terrain_seg_render_objs[t] = -1;
2267#endif
2268
2269 simplemul = 1 << ((MAX_TERRAIN_LOD - 1) - lod);
2270 Terrain_list[i].z = 0.0f;
2271 n[0] = t;
2272 n[1] = t + (TERRAIN_WIDTH * simplemul);
2273 n[2] = t + (TERRAIN_WIDTH * simplemul) + simplemul;
2274 n[3] = t + simplemul;
2275 for (k = 0; k < 4; k++)
2276 if (n[k] <= 65535)
2277 Terrain_list[i].z += World_point_buffer[n[k]].p3_vec.z;
2278 Terrain_list[i].z /= 4;
2279 }
2280 // Sort the faces
2281 qsort(Terrain_list, cellcount, sizeof(*Terrain_list), (int (*)(const void *, const void *))TerrainSortingFunction);
2282}
2283// Returns the number of points to rotate, plus the actual numbers of the points
2284// are returned in the "n" array
2285int BuildEdgeLists(int *n, int tlist_index) {

Callers 1

DisplayTerrainListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected