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

Function CheckCellOccupancy

Descent3/TerrainSearch.cpp:436–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434}
435
436__inline void CheckCellOccupancy(int x, int y, int *ccount, uint8_t lod) {
437 int n, simplemul, i;
438
439 if (*ccount >= MAX_CELLS_TO_RENDER) {
440 mprintf(0, "Trying to render too many cells! Cell limit=%d\n", MAX_CELLS_TO_RENDER);
441#ifndef NEWEDITOR
442 Detail_settings.Terrain_render_distance = 80.0 * TERRAIN_SIZE;
443#endif
444 return;
445 }
446
447 n = y * TERRAIN_WIDTH + x;
448
449 if (Show_invisible_terrain == 0 && lod == MAX_TERRAIN_LOD - 1 && Terrain_seg[n].flags & TF_INVISIBLE)
450 return;
451
452 (*ccount)++;
453
454 // Fill in our presorter
455 LOD_sort_bucket[lod][LOD_sort_num[lod]] = n;
456 LOD_sort_num[lod]++;
457
458 // Fill in the join map so we know what edges touch what edges
459 if (lod != MAX_TERRAIN_LOD - 1) {
460 simplemul = 1 << ((MAX_TERRAIN_LOD - 1) - lod);
461
462 for (i = 0; i < simplemul; i++) {
463 // Fill bottom edge
464 TerrainJoinMap[y * TERRAIN_WIDTH + x + i] = lod;
465
466 // Fill top edge
467 TerrainJoinMap[(y + simplemul - 1) * TERRAIN_WIDTH + x + i] = lod;
468
469 // Fill left edge
470 TerrainJoinMap[(y + i) * TERRAIN_WIDTH + x] = lod;
471
472 // Fill right edge
473 TerrainJoinMap[(y + i) * TERRAIN_WIDTH + x + (simplemul - 1)] = lod;
474 }
475 } else
476 TerrainJoinMap[y * TERRAIN_WIDTH + x] = lod;
477}
478
479#ifdef EDITOR
480extern int Tracing_drops, Drop_seg;

Callers 1

SearchQuadTreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected