TODO: MTS: unused? Blurs the lightmaps so a dithering pattern is less noticeable
| 326 | // TODO: MTS: unused? |
| 327 | // Blurs the lightmaps so a dithering pattern is less noticeable |
| 328 | void BlurLightmapInfos(int type) { |
| 329 | int i; |
| 330 | |
| 331 | for (i = 0; i < MAX_LIGHTMAP_INFOS; i++) { |
| 332 | if (LightmapInfo[i].used && LightmapInfo[i].type == type) { |
| 333 | uint16_t *src_data; |
| 334 | uint16_t *dest_data = lm_data(LightmapInfo[i].lm_handle); |
| 335 | int w = lmi_w(i); |
| 336 | int h = lmi_h(i); |
| 337 | int x, y; |
| 338 | |
| 339 | src_data = (uint16_t *)mem_malloc(w * h * 2); |
| 340 | ASSERT(src_data); |
| 341 | |
| 342 | memcpy(src_data, dest_data, w * h * 2); |
| 343 | |
| 344 | for (y = 0; y < h; y++) { |
| 345 | for (x = 0; x < w; x++) { |
| 346 | if (src_data[y * w + x] & OPAQUE_FLAG) { |
| 347 | int r = 0, g = 0, b = 0; |
| 348 | int num = 0; |
| 349 | ddgr_color color; |
| 350 | uint16_t color16; |
| 351 | |
| 352 | color16 = src_data[y * w + (x)]; |
| 353 | color = GR_16_TO_COLOR(color16); |
| 354 | r += GR_COLOR_RED(color); |
| 355 | g += GR_COLOR_GREEN(color); |
| 356 | b += GR_COLOR_BLUE(color); |
| 357 | num++; |
| 358 | |
| 359 | // Left edge |
| 360 | if (x != 0) { |
| 361 | |
| 362 | color16 = src_data[y * w + (x - 1)]; |
| 363 | if (color16 & OPAQUE_FLAG) { |
| 364 | color = GR_16_TO_COLOR(color16); |
| 365 | r += GR_COLOR_RED(color); |
| 366 | g += GR_COLOR_GREEN(color); |
| 367 | b += GR_COLOR_BLUE(color); |
| 368 | num++; |
| 369 | } |
| 370 | |
| 371 | if (y != 0) { |
| 372 | color16 = src_data[(y - 1) * w + (x - 1)]; |
| 373 | if (color16 & OPAQUE_FLAG) { |
| 374 | color = GR_16_TO_COLOR(color16); |
| 375 | r += GR_COLOR_RED(color); |
| 376 | g += GR_COLOR_GREEN(color); |
| 377 | b += GR_COLOR_BLUE(color); |
| 378 | num++; |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | if (y != h - 1) { |
| 383 | color16 = src_data[(y + 1) * w + (x - 1)]; |
| 384 | if (color16 & OPAQUE_FLAG) { |
| 385 | color = GR_16_TO_COLOR(color16); |
no test coverage detected