TODO: MTS: unused? Softens the edges of lightmaps so there are fewer artifaces
| 194 | // TODO: MTS: unused? |
| 195 | // Softens the edges of lightmaps so there are fewer artifaces |
| 196 | void ShadeLightmapInfoEdges(int type) { |
| 197 | int i; |
| 198 | |
| 199 | for (i = 0; i < MAX_LIGHTMAP_INFOS; i++) { |
| 200 | if (LightmapInfo[i].used && LightmapInfo[i].type == type) { |
| 201 | uint16_t *src_data; |
| 202 | uint16_t *dest_data = lm_data(LightmapInfo[i].lm_handle); |
| 203 | int w = lmi_w(i); |
| 204 | int h = lmi_h(i); |
| 205 | int x, y; |
| 206 | |
| 207 | src_data = (uint16_t *)mem_malloc(w * h * 2); |
| 208 | ASSERT(src_data); |
| 209 | |
| 210 | memcpy(src_data, dest_data, w * h * 2); |
| 211 | |
| 212 | for (y = 0; y < h; y++) { |
| 213 | for (x = 0; x < w; x++) { |
| 214 | if (!(src_data[y * w + x] & OPAQUE_FLAG)) { |
| 215 | int r = 0, g = 0, b = 0; |
| 216 | int num = 0; |
| 217 | ddgr_color color; |
| 218 | uint16_t color16; |
| 219 | |
| 220 | // Left edge |
| 221 | if (x != 0) { |
| 222 | |
| 223 | color16 = src_data[y * w + (x - 1)]; |
| 224 | if (color16 & OPAQUE_FLAG) { |
| 225 | color = GR_16_TO_COLOR(color16); |
| 226 | r += GR_COLOR_RED(color); |
| 227 | g += GR_COLOR_GREEN(color); |
| 228 | b += GR_COLOR_BLUE(color); |
| 229 | num++; |
| 230 | } |
| 231 | |
| 232 | if (y != 0) { |
| 233 | color16 = src_data[(y - 1) * w + (x - 1)]; |
| 234 | if (color16 & OPAQUE_FLAG) { |
| 235 | color = GR_16_TO_COLOR(color16); |
| 236 | r += GR_COLOR_RED(color); |
| 237 | g += GR_COLOR_GREEN(color); |
| 238 | b += GR_COLOR_BLUE(color); |
| 239 | num++; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | if (y != h - 1) { |
| 244 | color16 = src_data[(y + 1) * w + (x - 1)]; |
| 245 | if (color16 & OPAQUE_FLAG) { |
| 246 | color = GR_16_TO_COLOR(color16); |
| 247 | r += GR_COLOR_RED(color); |
| 248 | g += GR_COLOR_GREEN(color); |
| 249 | b += GR_COLOR_BLUE(color); |
| 250 | num++; |
| 251 | } |
| 252 | } |
| 253 | } |
no test coverage detected