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

Function UpdateSingleTerrainLightmap

Descent3/terrain.cpp:1027–1050  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1025}
1026
1027void UpdateSingleTerrainLightmap(int which) {
1028 int w = lm_w(TerrainLightmaps[which]);
1029 int i, t;
1030
1031 GameLightmaps[TerrainLightmaps[which]].flags |= LF_CHANGED;
1032
1033 int sx = (which % 2) * 128;
1034 int sz = (which / 2) * 128;
1035
1036 for (i = sz; i < sz + 128; i++) {
1037 for (t = sx; t < sx + 128; t++) {
1038 int tseg = i * TERRAIN_WIDTH + t;
1039 terrain_segment *tp = &Terrain_seg[tseg];
1040
1041 uint16_t color = GR_RGB16(tp->r, tp->g, tp->b);
1042 uint16_t *data = lm_data(TerrainLightmaps[which]);
1043
1044 int x = t % 128;
1045 int y = 127 - (i % 128);
1046
1047 data[y * w + x] = OPAQUE_FLAG | color;
1048 }
1049 }
1050}
1051
1052// Generates lightmaps based on the info given by the .light field of each Terrain_seg
1053void UpdateTerrainLightmaps() {

Callers 1

DeformTerrainFunction · 0.85

Calls 3

lm_wFunction · 0.85
GR_RGB16Function · 0.85
lm_dataFunction · 0.85

Tested by

no test coverage detected