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

Function BuildEdgeLists

Descent3/terrainrender.cpp:2285–2460  ·  view source on GitHub ↗

Returns the number of points to rotate, plus the actual numbers of the points are returned in the "n" array

Source from the content-addressed store, hash-verified

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) {
2286 int lod, simplemul;
2287 int t, k;
2288 int smul_x, smul_z; // for tracing the very edge of the terrain
2289
2290 // Now match up all edges of the differing levels of detail
2291 int cx, cz;
2292 int transcount;
2293 int offset;
2294 int maplod;
2295 int start = 0;
2296 int seg;
2297 int answer;
2298 int edgecount = 0;
2299 int edge1, edge2;
2300 float delta, cury;
2301 int max_edge_size = 1 << (MAX_TERRAIN_LOD - 1);
2302
2303 t = Terrain_list[tlist_index].segment;
2304 lod = Terrain_list[tlist_index].lod;
2305 simplemul = 1 << ((MAX_TERRAIN_LOD - 1) - lod);
2306 ASSERT(simplemul <= max_edge_size);
2307 cx = t % TERRAIN_WIDTH;
2308 cz = t / TERRAIN_WIDTH;
2309 if (cx == TERRAIN_WIDTH - simplemul) {
2310 if (lod == MAX_TERRAIN_LOD - 1)
2311 return 0;
2312
2313 smul_x = simplemul - 1;
2314 } else
2315 smul_x = simplemul;
2316 if (cz == TERRAIN_DEPTH - simplemul) {
2317 if (lod == MAX_TERRAIN_LOD - 1)
2318 return 0;
2319
2320 smul_z = simplemul - 1;
2321 } else
2322 smul_z = simplemul;
2323 if (lod != MAX_TERRAIN_LOD - 1) {
2324 // Bottom edge
2325 // | |
2326 // 2-------1
2327
2328 Terrain_list[tlist_index].bottom_edge = 0;
2329 Terrain_list[tlist_index].bottom_count = 0;
2330 transcount = 0;
2331 if (cz != 0) {
2332 edge1 = t + smul_x;
2333 edge2 = t;
2334 delta = (Terrain_seg[edge2].mody - Terrain_seg[edge1].mody) / smul_x;
2335 cury = Terrain_seg[edge1].mody;
2336
2337 offset = ((cz - 1) * TERRAIN_WIDTH) + cx + smul_x;
2338 for (k = 0; k < smul_x; k++, cury += delta) {
2339 maplod = TerrainJoinMap[offset - k];
2340 answer = TerrainEdgeTest[maplod][k + simplemul - smul_x];
2341 if (answer || k == 0) {
2342 seg = t + smul_x - k;

Callers 1

RotateTerrainListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected