LFIZW6XIIEPON7ROE5CPKBNEHC7AMO2RSWI5ECF6C3RT2HCBRFSAC
#define TEST(...) \
do { \
int items[] = {__VA_ARGS__}; \
printf("("); \
for(int j = 0; j < sizeof(items) / sizeof(items[0]); j++) { \
printf("%i ", items[j]); \
} \
printf(") -> ("); \
tabula_qsort(items, sizeof(items[0]), (sizeof(items) / sizeof(items[0])), comp_int, NULL); \
tests_run++; \
for(int j = 0; j < sizeof(items) / sizeof(items[0]); j++) { \
printf("%i ", items[j]); \
} \
printf(")\n"); \
for(int i = 1; i < sizeof(items) / sizeof(items[0]); i++) { \
if(items[i - 1] > items[i]) { \
tests_failed++; \
break; \
} \
} \
#define TEST(...) \
do { \
int items[] = {__VA_ARGS__}; \
printf("("); \
for(int j = 0; j < sizeof(items) / sizeof(items[0]); j++) { \
printf("%i ", items[j]); \
} \
printf(") -> ("); \
tabula_qsort(items, sizeof(items[0]), (sizeof(items) / sizeof(items[0])), comp_int, NULL); \
tests_run++; \
for(int j = 0; j < sizeof(items) / sizeof(items[0]); j++) { \
printf("%i ", items[j]); \
} \
printf(")\n"); \
for(int i = 1; i < sizeof(items) / sizeof(items[0]); i++) { \
if(items[i - 1] > items[i]) { \
tests_failed++; \
break; \
} \
} \
color.f[0] = lightmap_rgb0[i * 3 + 0] - 0.5f;
color.f[4] = lightmap_rgb0[i * 3 + 1] - 0.5f;
color.f[8] = lightmap_rgb0[i * 3 + 2] - 0.5f;
color.f[0] = lightmap_rgb0[i * 3 + 0] - 0.5f;
color.f[4] = lightmap_rgb0[i * 3 + 1] - 0.5f;
color.f[8] = lightmap_rgb0[i * 3 + 2] - 0.5f;
if(!model->old_lightmap) {
color.f[1] *= newscale;
color.f[2] *= newscale;
color.f[3] *= newscale;
color.f[5] *= newscale;
color.f[6] *= newscale;
color.f[7] *= newscale;
color.f[9] *= newscale;
color.f[10] *= newscale;
color.f[11] *= newscale;
bl[i] = SH1_ColorScale(color, scale);
} else {
color.f[1] = 0.0f;
color.f[2] = 0.0f;
color.f[3] = 0.0f;
color.f[5] = 0.0f;
color.f[6] = 0.0f;
color.f[7] = 0.0f;
color.f[9] = 0.0f;
color.f[10] = 0.0f;
color.f[11] = 0.0f;
// skip to next lightmap
lightmap_rgb0 += size * 3 * newstride;
lightmap_r1 += size * 3 * newstride;
lightmap_g1 += size * 3 * newstride;
lightmap_b1 += size * 3 * newstride;
}
} else {
int maps;
memset(_.blocklights, 0, sizeof(_.blocklights[0]) * size);
for(maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++) {
bl = _.blocklights;
for(i = 0; i < 3; i++)
scale[i] = gl_modulate->value * r_newrefdef.lightstyles[surf->styles[maps]].rgb[i];
for(i = 0; i < size; i++) {
struct SH1 color;
color.f[0] = lightmap_rgb0[i * 3 + 0] - 0.5f;
color.f[4] = lightmap_rgb0[i * 3 + 1] - 0.5f;
color.f[8] = lightmap_rgb0[i * 3 + 2] - 0.5f;
color.f[1] = lightmap_r1[i * 3 + 0] - 0.5f;
color.f[2] = lightmap_r1[i * 3 + 1] - 0.5f;
color.f[3] = lightmap_r1[i * 3 + 2] - 0.5f;
color.f[5] = lightmap_g1[i * 3 + 0] - 0.5f;
color.f[6] = lightmap_g1[i * 3 + 1] - 0.5f;
color.f[7] = lightmap_g1[i * 3 + 2] - 0.5f;
color.f[9] = lightmap_b1[i * 3 + 0] - 0.5f;
color.f[10] = lightmap_b1[i * 3 + 1] - 0.5f;
color.f[11] = lightmap_b1[i * 3 + 2] - 0.5f;
for(int component = 0; component < 3; component++) {
for(int basis = 0; basis < 3; basis++) {
color.f[component * 4 + basis + 1] -= 127.0f;
color.f[component * 4 + basis + 1] *= 2;
}
}
color.f[1] *= newscale;
color.f[2] *= newscale;
color.f[3] *= newscale;
color.f[5] *= newscale;
color.f[6] *= newscale;
color.f[7] *= newscale;
color.f[9] *= newscale;
color.f[10] *= newscale;
color.f[11] *= newscale;
bl[i] = SH1_ColorScale(color, scale);
color = SH1_ColorScale(color, scale);
if(maps != 0) {
bl[i] = SH1_Add(bl[i], color);
} else {
bl[i] = color;
lightmap_r1 += size * 3 * newstride;
lightmap_g1 += size * 3 * newstride;
lightmap_b1 += size * 3 * newstride;
if(!model->old_lightmap) {
lightmap_r1 += size * 3 * newstride;
lightmap_g1 += size * 3 * newstride;
lightmap_b1 += size * 3 * newstride;
}