diff --git a/src/rendering/swrenderer/drawers/r_draw.cpp b/src/rendering/swrenderer/drawers/r_draw.cpp index 797f65626..01b79134a 100644 --- a/src/rendering/swrenderer/drawers/r_draw.cpp +++ b/src/rendering/swrenderer/drawers/r_draw.cpp @@ -109,7 +109,7 @@ namespace swrenderer for (int k = 0; k < 256; ++k) { uint8_t v = (((k + 2) * a) + 256) >> 14; - table[k] = MIN(v, 64); + table[k] = min(v, 64); } table += 256; } @@ -212,8 +212,8 @@ namespace swrenderer { if (!r_fuzzscale) { - int yl = MAX(args.FuzzY1(), 1); - int yh = MIN(args.FuzzY2(), fuzzviewheight); + int yl = max(args.FuzzY1(), 1); + int yh = min(args.FuzzY2(), fuzzviewheight); if (yl <= yh) fuzzpos = (fuzzpos + yh - yl + 1) % FUZZTABLE; } diff --git a/src/rendering/swrenderer/drawers/r_draw_pal.cpp b/src/rendering/swrenderer/drawers/r_draw_pal.cpp index 8cc7a0fc8..0d6b97f2f 100644 --- a/src/rendering/swrenderer/drawers/r_draw_pal.cpp +++ b/src/rendering/swrenderer/drawers/r_draw_pal.cpp @@ -107,7 +107,7 @@ namespace swrenderer // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) float Lxy2 = lights[i].x; // L.x*L.x + L.y*L.y float Lz = lights[i].z - viewpos_z; float dist2 = Lxy2 + Lz * Lz; @@ -117,7 +117,7 @@ namespace swrenderer float rcp_dist = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(dist2))); #endif float dist = dist2 * rcp_dist; - float distance_attenuation = (256.0f - MIN(dist * lights[i].radius, 256.0f)); + float distance_attenuation = (256.0f - min(dist * lights[i].radius, 256.0f)); // The simple light type float simple_attenuation = distance_attenuation; @@ -139,9 +139,9 @@ namespace swrenderer uint32_t material_g = GPalette.BaseColors[material].g; uint32_t material_b = GPalette.BaseColors[material].b; - lit_r = MIN(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255); - lit_g = MIN(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255); - lit_b = MIN(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255); + lit_r = min(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255); + lit_g = min(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255); + lit_b = min(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255); return RGB256k.All[((lit_r >> 2) << 12) | ((lit_g >> 2) << 6) | (lit_b >> 2)]; } @@ -286,9 +286,9 @@ namespace swrenderer { uint8_t lit = colormap[pix]; - uint32_t r = MIN(GPalette.BaseColors[lit].r + GPalette.BaseColors[*dest].r, 255); - uint32_t g = MIN(GPalette.BaseColors[lit].g + GPalette.BaseColors[*dest].g, 255); - uint32_t b = MIN(GPalette.BaseColors[lit].b + GPalette.BaseColors[*dest].b, 255); + uint32_t r = min(GPalette.BaseColors[lit].r + GPalette.BaseColors[*dest].r, 255); + uint32_t g = min(GPalette.BaseColors[lit].g + GPalette.BaseColors[*dest].g, 255); + uint32_t b = min(GPalette.BaseColors[lit].b + GPalette.BaseColors[*dest].b, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } frac += fracstep; @@ -352,9 +352,9 @@ namespace swrenderer { uint8_t lit = num_dynlights != 0 ? AddLightsColumn(dynlights, num_dynlights, viewpos_z, colormap[pix], pix) : colormap[pix]; - uint32_t r = MIN(GPalette.BaseColors[lit].r + GPalette.BaseColors[*dest].r, 255); - uint32_t g = MIN(GPalette.BaseColors[lit].g + GPalette.BaseColors[*dest].g, 255); - uint32_t b = MIN(GPalette.BaseColors[lit].b + GPalette.BaseColors[*dest].b, 255); + uint32_t r = min(GPalette.BaseColors[lit].r + GPalette.BaseColors[*dest].r, 255); + uint32_t g = min(GPalette.BaseColors[lit].g + GPalette.BaseColors[*dest].g, 255); + uint32_t b = min(GPalette.BaseColors[lit].b + GPalette.BaseColors[*dest].b, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } viewpos_z += step_viewpos_z; @@ -567,7 +567,7 @@ namespace swrenderer uint8_t fg = source0[sample_index]; uint32_t c = palette[fg]; - int alpha_top = MAX(MIN(frac >> (16 - start_fade), 256), 0); + int alpha_top = max(min(frac >> (16 - start_fade), 256), 0); int inv_alpha_top = 256 - alpha_top; int c_red = RPART(c); int c_green = GPART(c); @@ -600,7 +600,7 @@ namespace swrenderer uint8_t fg = source0[sample_index]; uint32_t c = palette[fg]; - int alpha_bottom = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + int alpha_bottom = max(min(((2 << 24) - frac) >> (16 - start_fade), 256), 0); int inv_alpha_bottom = 256 - alpha_bottom; int c_red = RPART(c); int c_green = GPART(c); @@ -645,7 +645,7 @@ namespace swrenderer uint8_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } @@ -701,12 +701,12 @@ namespace swrenderer uint8_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } uint32_t c = palette[fg]; - int alpha_top = MAX(MIN(frac >> (16 - start_fade), 256), 0); + int alpha_top = max(min(frac >> (16 - start_fade), 256), 0); int inv_alpha_top = 256 - alpha_top; int c_red = RPART(c); int c_green = GPART(c); @@ -728,7 +728,7 @@ namespace swrenderer uint8_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } *dest = fg; @@ -745,12 +745,12 @@ namespace swrenderer uint8_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } uint32_t c = palette[fg]; - int alpha_bottom = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + int alpha_bottom = max(min(((2 << 24) - frac) >> (16 - start_fade), 256), 0); int inv_alpha_bottom = 256 - alpha_bottom; int c_red = RPART(c); int c_green = GPART(c); @@ -785,9 +785,9 @@ namespace swrenderer uint32_t material_g = GPalette.BaseColors[material].g; uint32_t material_b = GPalette.BaseColors[material].b; - lit_r = MIN(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255); - lit_g = MIN(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255); - lit_b = MIN(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255); + lit_r = min(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255); + lit_g = min(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255); + lit_b = min(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255); return RGB256k.All[((lit_r >> 2) << 12) | ((lit_g >> 2) << 6) | (lit_b >> 2)]; } @@ -836,9 +836,9 @@ namespace swrenderer uint32_t lit_g = GPART(dynlight); uint32_t lit_b = BPART(dynlight); uint32_t light = 256 - (args.Light() >> (FRACBITS - 8)); - lit_r = MIN(light + lit_r, 256); - lit_g = MIN(light + lit_g, 256); - lit_b = MIN(light + lit_b, 256); + lit_r = min(light + lit_r, 256); + lit_g = min(light + lit_g, 256); + lit_b = min(light + lit_b, 256); lit_r = lit_r - light; lit_g = lit_g - light; lit_b = lit_b - light; @@ -1011,9 +1011,9 @@ namespace swrenderer int src_g = ((srccolor >> 0) & 0xff) * srcalpha; int src_b = ((srccolor >> 8) & 0xff) * srcalpha; int bg = *dest; - int r = MAX((-src_r + palette[bg].r * destalpha)>>18, 0); - int g = MAX((-src_g + palette[bg].g * destalpha)>>18, 0); - int b = MAX((-src_b + palette[bg].b * destalpha)>>18, 0); + int r = max((-src_r + palette[bg].r * destalpha)>>18, 0); + int g = max((-src_g + palette[bg].g * destalpha)>>18, 0); + int b = max((-src_b + palette[bg].b * destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; @@ -1061,9 +1061,9 @@ namespace swrenderer int src_g = ((srccolor >> 0) & 0xff) * srcalpha; int src_b = ((srccolor >> 8) & 0xff) * srcalpha; int bg = *dest; - int r = MAX((src_r - palette[bg].r * destalpha)>>18, 0); - int g = MAX((src_g - palette[bg].g * destalpha)>>18, 0); - int b = MAX((src_b - palette[bg].b * destalpha)>>18, 0); + int r = max((src_r - palette[bg].r * destalpha)>>18, 0); + int g = max((src_g - palette[bg].g * destalpha)>>18, 0); + int b = max((src_b - palette[bg].b * destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; @@ -1113,9 +1113,9 @@ namespace swrenderer { uint32_t fg = colormap[source[frac >> FRACBITS]]; uint32_t bg = *dest; - uint32_t r = MIN((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); - uint32_t g = MIN((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); - uint32_t b = MIN((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); + uint32_t r = min((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); + uint32_t g = min((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); + uint32_t b = min((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1192,9 +1192,9 @@ namespace swrenderer { uint32_t fg = colormap[translation[source[frac >> FRACBITS]]]; uint32_t bg = *dest; - uint32_t r = MIN((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); - uint32_t g = MIN((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); - uint32_t b = MIN((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); + uint32_t r = min((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); + uint32_t g = min((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); + uint32_t b = min((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1331,9 +1331,9 @@ namespace swrenderer { int fg = colormap[source[frac >> FRACBITS]]; int bg = *dest; - int r = MIN((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); - int g = MIN((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); - int b = MIN((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); + int r = min((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); + int g = min((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); + int b = min((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1385,9 +1385,9 @@ namespace swrenderer { int fg = colormap[translation[source[frac >> FRACBITS]]]; int bg = *dest; - int r = MIN((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); - int g = MIN((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); - int b = MIN((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); + int r = min((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); + int g = min((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); + int b = min((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1437,9 +1437,9 @@ namespace swrenderer { int fg = colormap[source[frac >> FRACBITS]]; int bg = *dest; - int r = MAX((palette[fg].r * srcalpha - palette[bg].r * destalpha)>>18, 0); - int g = MAX((palette[fg].g * srcalpha - palette[bg].g * destalpha)>>18, 0); - int b = MAX((palette[fg].b * srcalpha - palette[bg].b * destalpha)>>18, 0); + int r = max((palette[fg].r * srcalpha - palette[bg].r * destalpha)>>18, 0); + int g = max((palette[fg].g * srcalpha - palette[bg].g * destalpha)>>18, 0); + int b = max((palette[fg].b * srcalpha - palette[bg].b * destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1490,9 +1490,9 @@ namespace swrenderer { int fg = colormap[translation[source[frac >> FRACBITS]]]; int bg = *dest; - int r = MAX((palette[fg].r * srcalpha - palette[bg].r * destalpha)>>18, 0); - int g = MAX((palette[fg].g * srcalpha - palette[bg].g * destalpha)>>18, 0); - int b = MAX((palette[fg].b * srcalpha - palette[bg].b * destalpha)>>18, 0); + int r = max((palette[fg].r * srcalpha - palette[bg].r * destalpha)>>18, 0); + int g = max((palette[fg].g * srcalpha - palette[bg].g * destalpha)>>18, 0); + int b = max((palette[fg].b * srcalpha - palette[bg].b * destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1542,9 +1542,9 @@ namespace swrenderer { int fg = colormap[source[frac >> FRACBITS]]; int bg = *dest; - int r = MAX((-palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 0); - int g = MAX((-palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 0); - int b = MAX((-palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 0); + int r = max((-palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 0); + int g = max((-palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 0); + int b = max((-palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1595,9 +1595,9 @@ namespace swrenderer { int fg = colormap[translation[source[frac >> FRACBITS]]]; int bg = *dest; - int r = MAX((-palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 0); - int g = MAX((-palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 0); - int b = MAX((-palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 0); + int r = max((-palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 0); + int g = max((-palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 0); + int b = max((-palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1618,8 +1618,8 @@ namespace swrenderer int _fuzzviewheight = fuzzviewheight; int x = _x; - int yl = MAX(_yl, 1); - int yh = MIN(_yh, _fuzzviewheight); + int yl = max(_yl, 1); + int yh = min(_yh, _fuzzviewheight); int count = yh - yl + 1; if (count <= 0) return; @@ -1661,8 +1661,8 @@ namespace swrenderer int _fuzzpos = fuzzpos; int _fuzzviewheight = fuzzviewheight; - int yl = MAX(_yl, 1); - int yh = MIN(_yh, _fuzzviewheight); + int yl = max(_yl, 1); + int yh = min(_yh, _fuzzviewheight); int count = yh - yl + 1; @@ -1687,7 +1687,7 @@ namespace swrenderer if (available % fuzzstep != 0) next_wrap++; - int cnt = MIN(count, next_wrap); + int cnt = min(count, next_wrap); count -= cnt; do { @@ -1733,7 +1733,7 @@ namespace swrenderer if (available % fuzzstep != 0) next_wrap++; - int cnt = MIN(count, next_wrap); + int cnt = min(count, next_wrap); count -= cnt; do { @@ -1775,7 +1775,7 @@ namespace swrenderer // L = light-pos // dist = sqrt(dot(L, L)) - // attenuation = 1 - MIN(dist * (1/radius), 1) + // attenuation = 1 - min(dist * (1/radius), 1) float Lyz2 = lights[i].y; // L.y*L.y + L.z*L.z float Lx = lights[i].x - viewpos_x; float dist2 = Lyz2 + Lx * Lx; @@ -1785,7 +1785,7 @@ namespace swrenderer float rcp_dist = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_load_ss(&dist2))); #endif float dist = dist2 * rcp_dist; - float distance_attenuation = (256.0f - MIN(dist * lights[i].radius, 256.0f)); + float distance_attenuation = (256.0f - min(dist * lights[i].radius, 256.0f)); // The simple light type float simple_attenuation = distance_attenuation; @@ -1807,9 +1807,9 @@ namespace swrenderer uint32_t material_g = GPalette.BaseColors[material].g; uint32_t material_b = GPalette.BaseColors[material].b; - lit_r = MIN(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255); - lit_g = MIN(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255); - lit_b = MIN(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255); + lit_r = min(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255); + lit_g = min(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255); + lit_b = min(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255); return RGB256k.All[((lit_r >> 2) << 12) | ((lit_g >> 2) << 6) | (lit_b >> 2)]; } @@ -2113,9 +2113,9 @@ namespace swrenderer spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest++ = RGB256k.RGB[r][g][b]; xfrac += xstep; @@ -2133,9 +2133,9 @@ namespace swrenderer spot = (((xfrac >> 16) * srcwidth) >> 16) * srcheight + (((yfrac >> 16) * srcheight) >> 16); uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest++ = RGB256k.RGB[r][g][b]; xfrac += xstep; @@ -2267,9 +2267,9 @@ namespace swrenderer { uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; } dest++; @@ -2293,9 +2293,9 @@ namespace swrenderer { uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; } dest++; @@ -2416,9 +2416,9 @@ namespace swrenderer spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest++ = RGB256k.RGB[r][g][b]; xfrac += xstep; @@ -2436,9 +2436,9 @@ namespace swrenderer spot = (((xfrac >> 16) * srcwidth) >> 16) * srcheight + (((yfrac >> 16) * srcheight) >> 16); uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest++ = RGB256k.RGB[r][g][b]; xfrac += xstep; @@ -2577,9 +2577,9 @@ namespace swrenderer { uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; } dest++; @@ -2603,9 +2603,9 @@ namespace swrenderer { uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; } dest++; @@ -2859,7 +2859,7 @@ namespace swrenderer if (count <= 0) return; - int particle_texture_index = MIN(gl_particles_style, NUM_PARTICLE_TEXTURES - 1); + int particle_texture_index = min(gl_particles_style, NUM_PARTICLE_TEXTURES - 1); const uint32_t *source = &particle_texture[particle_texture_index][(_fracposx >> FRACBITS) * PARTICLE_TEXTURE_SIZE]; uint32_t particle_alpha = _alpha; @@ -3122,7 +3122,7 @@ namespace swrenderer uint32_t next_uv_wrap = available / texelStepY; if (available % texelStepY != 0) next_uv_wrap++; - uint32_t count = MIN(left, next_uv_wrap); + uint32_t count = min(left, next_uv_wrap); drawerargs.SetDest(x, y); drawerargs.SetCount(count); diff --git a/src/rendering/swrenderer/drawers/r_draw_rgba.cpp b/src/rendering/swrenderer/drawers/r_draw_rgba.cpp index b6360981c..c8d87ef9e 100644 --- a/src/rendering/swrenderer/drawers/r_draw_rgba.cpp +++ b/src/rendering/swrenderer/drawers/r_draw_rgba.cpp @@ -257,8 +257,8 @@ namespace swrenderer int _fuzzviewheight = fuzzviewheight; int x = _x; - int yl = MAX(_yl, 1); - int yh = MIN(_yh, _fuzzviewheight); + int yl = max(_yl, 1); + int yh = min(_yh, _fuzzviewheight); int count = yh - yl + 1; if (count <= 0) return; @@ -304,8 +304,8 @@ namespace swrenderer int _fuzzpos = fuzzpos; int _fuzzviewheight = fuzzviewheight; - int yl = MAX(_yl, 1); - int yh = MIN(_yh, _fuzzviewheight); + int yl = max(_yl, 1); + int yh = min(_yh, _fuzzviewheight); int count = yh - yl + 1; @@ -328,7 +328,7 @@ namespace swrenderer if (available % fuzzstep != 0) next_wrap++; - int cnt = MIN(count, next_wrap); + int cnt = min(count, next_wrap); count -= cnt; do { @@ -383,7 +383,7 @@ namespace swrenderer if (available % fuzzstep != 0) next_wrap++; - int cnt = MIN(count, next_wrap); + int cnt = min(count, next_wrap); count -= cnt; do { @@ -810,7 +810,7 @@ namespace swrenderer if (count <= 0) return; - int particle_texture_index = MIN(gl_particles_style, NUM_PARTICLE_TEXTURES - 1); + int particle_texture_index = min(gl_particles_style, NUM_PARTICLE_TEXTURES - 1); const uint32_t *source = &particle_texture[particle_texture_index][(_fracposx >> FRACBITS) * PARTICLE_TEXTURE_SIZE]; uint32_t particle_alpha = _alpha; @@ -991,9 +991,9 @@ namespace swrenderer double xmagnitude = fabs(static_cast(texelStepX) * (1.0 / 0x1'0000'0000LL)); double ymagnitude = fabs(static_cast(texelStepY) * (1.0 / 0x1'0000'0000LL)); - double magnitude = MAX(ymagnitude, xmagnitude); + double magnitude = max(ymagnitude, xmagnitude); double min_lod = -1000.0; - double lod = MAX(log2(magnitude) + r_lod_bias, min_lod); + double lod = max(log2(magnitude) + r_lod_bias, min_lod); bool magnifying = lod < 0.0f; int mipmap_offset = 0; @@ -1006,8 +1006,8 @@ namespace swrenderer { mipmap_offset += mip_width * mip_height; level--; - mip_width = MAX(mip_width >> 1, 1); - mip_height = MAX(mip_height >> 1, 1); + mip_width = max(mip_width >> 1, 1); + mip_height = max(mip_height >> 1, 1); } } diff --git a/src/rendering/swrenderer/drawers/r_draw_sky32.h b/src/rendering/swrenderer/drawers/r_draw_sky32.h index df208afab..ea9dff4f7 100644 --- a/src/rendering/swrenderer/drawers/r_draw_sky32.h +++ b/src/rendering/swrenderer/drawers/r_draw_sky32.h @@ -91,7 +91,7 @@ namespace swrenderer uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; uint32_t fg = source0[sample_index]; - uint32_t alpha = MAX(MIN(frac >> (16 - start_fade), 256), 0); + uint32_t alpha = max(min(frac >> (16 - start_fade), 256), 0); uint32_t inv_alpha = 256 - alpha; BgraColor c = fg; @@ -122,7 +122,7 @@ namespace swrenderer uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; uint32_t fg = source0[sample_index]; - uint32_t alpha = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + uint32_t alpha = max(min(((2 << 24) - frac) >> (16 - start_fade), 256), 0); uint32_t inv_alpha = 256 - alpha; BgraColor c = fg; @@ -187,7 +187,7 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } @@ -220,11 +220,11 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } - uint32_t alpha = MAX(MIN(frac >> (16 - start_fade), 256), 0); + uint32_t alpha = max(min(frac >> (16 - start_fade), 256), 0); uint32_t inv_alpha = 256 - alpha; BgraColor c = fg; @@ -243,7 +243,7 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } *dest = fg; @@ -260,11 +260,11 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } - uint32_t alpha = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + uint32_t alpha = max(min(((2 << 24) - frac) >> (16 - start_fade), 256), 0); uint32_t inv_alpha = 256 - alpha; BgraColor c = fg; diff --git a/src/rendering/swrenderer/drawers/r_draw_sky32_sse2.h b/src/rendering/swrenderer/drawers/r_draw_sky32_sse2.h index 998833416..bc2411b83 100644 --- a/src/rendering/swrenderer/drawers/r_draw_sky32_sse2.h +++ b/src/rendering/swrenderer/drawers/r_draw_sky32_sse2.h @@ -91,7 +91,7 @@ namespace swrenderer uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; uint32_t fg = source0[sample_index]; - __m128i alpha = _mm_set1_epi16(MAX(MIN(frac >> (16 - start_fade), 256), 0)); + __m128i alpha = _mm_set1_epi16(max(min(frac >> (16 - start_fade), 256), 0)); __m128i inv_alpha = _mm_sub_epi16(_mm_set1_epi16(256), alpha); __m128i c = _mm_unpacklo_epi8(_mm_cvtsi32_si128(fg), _mm_setzero_si128()); @@ -120,7 +120,7 @@ namespace swrenderer uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; uint32_t fg = source0[sample_index]; - __m128i alpha = _mm_set1_epi16(MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0)); + __m128i alpha = _mm_set1_epi16(max(min(((2 << 24) - frac) >> (16 - start_fade), 256), 0)); __m128i inv_alpha = _mm_sub_epi16(_mm_set1_epi16(256), alpha); __m128i c = _mm_unpacklo_epi8(_mm_cvtsi32_si128(fg), _mm_setzero_si128()); @@ -171,7 +171,7 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } @@ -216,11 +216,11 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } - __m128i alpha = _mm_set1_epi16(MAX(MIN(frac >> (16 - start_fade), 256), 0)); + __m128i alpha = _mm_set1_epi16(max(min(frac >> (16 - start_fade), 256), 0)); __m128i inv_alpha = _mm_sub_epi16(_mm_set1_epi16(256), alpha); __m128i c = _mm_unpacklo_epi8(_mm_cvtsi32_si128(fg), _mm_setzero_si128()); @@ -239,7 +239,7 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } *dest = fg; @@ -256,11 +256,11 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } - __m128i alpha = _mm_set1_epi16(MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0)); + __m128i alpha = _mm_set1_epi16(max(min(((2 << 24) - frac) >> (16 - start_fade), 256), 0)); __m128i inv_alpha = _mm_sub_epi16(_mm_set1_epi16(256), alpha); __m128i c = _mm_unpacklo_epi8(_mm_cvtsi32_si128(fg), _mm_setzero_si128()); diff --git a/src/rendering/swrenderer/drawers/r_draw_span32.h b/src/rendering/swrenderer/drawers/r_draw_span32.h index 9534c496b..1c1e3e55d 100644 --- a/src/rendering/swrenderer/drawers/r_draw_span32.h +++ b/src/rendering/swrenderer/drawers/r_draw_span32.h @@ -94,8 +94,8 @@ namespace swrenderer break; texdata.source += texdata.width * texdata.height; - texdata.width = MAX(texdata.width / 2, 1); - texdata.height = MAX(texdata.height / 2, 1); + texdata.width = max(texdata.width / 2, 1); + texdata.height = max(texdata.height / 2, 1); level--; } } @@ -324,13 +324,13 @@ namespace swrenderer // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) float Lyz2 = light_y; // L.y*L.y + L.z*L.z float Lx = light_x - viewpos_x; float dist2 = Lyz2 + Lx * Lx; float rcp_dist = 1.f/sqrt(dist2); float dist = dist2 * rcp_dist; - float distance_attenuation = 256.0f - MIN(dist * light_radius, 256.0f); + float distance_attenuation = 256.0f - min(dist * light_radius, 256.0f); // The simple light type float simple_attenuation = distance_attenuation; @@ -348,13 +348,13 @@ namespace swrenderer lit.b += (light_color.b * attenuation) >> 8; } - lit.r = MIN(lit.r, 256); - lit.g = MIN(lit.g, 256); - lit.b = MIN(lit.b, 256); + lit.r = min(lit.r, 256); + lit.g = min(lit.g, 256); + lit.b = min(lit.b, 256); - fgcolor.r = MIN(fgcolor.r + ((material.r * lit.r) >> 8), 255); - fgcolor.g = MIN(fgcolor.g + ((material.g * lit.g) >> 8), 255); - fgcolor.b = MIN(fgcolor.b + ((material.b * lit.b) >> 8), 255); + fgcolor.r = min(fgcolor.r + ((material.r * lit.r) >> 8), 255); + fgcolor.g = min(fgcolor.g + ((material.g * lit.g) >> 8), 255); + fgcolor.b = min(fgcolor.b + ((material.b * lit.b) >> 8), 255); return fgcolor; } @@ -381,9 +381,9 @@ namespace swrenderer bgcolor.b = bgcolor.b * destalpha; BgraColor outcolor; - outcolor.r = MIN((fgcolor.r + bgcolor.r) >> 8, 255); - outcolor.g = MIN((fgcolor.g + bgcolor.g) >> 8, 255); - outcolor.b = MIN((fgcolor.b + bgcolor.b) >> 8, 255); + outcolor.r = min((fgcolor.r + bgcolor.r) >> 8, 255); + outcolor.g = min((fgcolor.g + bgcolor.g) >> 8, 255); + outcolor.b = min((fgcolor.b + bgcolor.b) >> 8, 255); return outcolor; } else @@ -405,21 +405,21 @@ namespace swrenderer BgraColor outcolor; if (BlendT::Mode == (int)SpanBlendModes::AddClamp) { - outcolor.r = MIN((fgcolor.r + bgcolor.r) >> 8, 255); - outcolor.g = MIN((fgcolor.g + bgcolor.g) >> 8, 255); - outcolor.b = MIN((fgcolor.b + bgcolor.b) >> 8, 255); + outcolor.r = min((fgcolor.r + bgcolor.r) >> 8, 255); + outcolor.g = min((fgcolor.g + bgcolor.g) >> 8, 255); + outcolor.b = min((fgcolor.b + bgcolor.b) >> 8, 255); } else if (BlendT::Mode == (int)SpanBlendModes::SubClamp) { - outcolor.r = MAX(int32_t(fgcolor.r - bgcolor.r) >> 8, 0); - outcolor.g = MAX(int32_t(fgcolor.g - bgcolor.g) >> 8, 0); - outcolor.b = MAX(int32_t(fgcolor.b - bgcolor.b) >> 8, 0); + outcolor.r = max(int32_t(fgcolor.r - bgcolor.r) >> 8, 0); + outcolor.g = max(int32_t(fgcolor.g - bgcolor.g) >> 8, 0); + outcolor.b = max(int32_t(fgcolor.b - bgcolor.b) >> 8, 0); } else if (BlendT::Mode == (int)SpanBlendModes::RevSubClamp) { - outcolor.r = MAX(int32_t(bgcolor.r - fgcolor.r) >> 8, 0); - outcolor.g = MAX(int32_t(bgcolor.g - fgcolor.g) >> 8, 0); - outcolor.b = MAX(int32_t(bgcolor.b - fgcolor.b) >> 8, 0); + outcolor.r = max(int32_t(bgcolor.r - fgcolor.r) >> 8, 0); + outcolor.g = max(int32_t(bgcolor.g - fgcolor.g) >> 8, 0); + outcolor.b = max(int32_t(bgcolor.b - fgcolor.b) >> 8, 0); } outcolor.a = 255; return outcolor; diff --git a/src/rendering/swrenderer/drawers/r_draw_span32_sse2.h b/src/rendering/swrenderer/drawers/r_draw_span32_sse2.h index 527545a9d..230ba8c13 100644 --- a/src/rendering/swrenderer/drawers/r_draw_span32_sse2.h +++ b/src/rendering/swrenderer/drawers/r_draw_span32_sse2.h @@ -94,8 +94,8 @@ namespace swrenderer break; texdata.source += texdata.width * texdata.height; - texdata.width = MAX(texdata.width / 2, 1); - texdata.height = MAX(texdata.height / 2, 1); + texdata.width = max(texdata.width / 2, 1); + texdata.height = max(texdata.height / 2, 1); level--; } } @@ -366,7 +366,7 @@ namespace swrenderer // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) __m128 Lyz2 = light_y; // L.y*L.y + L.z*L.z __m128 Lx = _mm_sub_ps(light_x, viewpos_x); __m128 dist2 = _mm_add_ps(Lyz2, _mm_mul_ps(Lx, Lx)); diff --git a/src/rendering/swrenderer/drawers/r_draw_sprite32.h b/src/rendering/swrenderer/drawers/r_draw_sprite32.h index 7fa300f82..6ae563dc6 100644 --- a/src/rendering/swrenderer/drawers/r_draw_sprite32.h +++ b/src/rendering/swrenderer/drawers/r_draw_sprite32.h @@ -143,9 +143,9 @@ namespace swrenderer shade_light.g = shade_constants.light_green; shade_light.b = shade_constants.light_blue; desaturate = shade_constants.desaturate; - lightcontrib.r = MIN(light + dynlight.r, 256) - light; - lightcontrib.g = MIN(light + dynlight.g, 256) - light; - lightcontrib.b = MIN(light + dynlight.b, 256) - light; + lightcontrib.r = min(light + dynlight.r, 256) - light; + lightcontrib.g = min(light + dynlight.g, 256) - light; + lightcontrib.b = min(light + dynlight.b, 256) - light; mlight.r = light; mlight.g = light; mlight.b = light; @@ -161,9 +161,9 @@ namespace swrenderer shade_light.b = 0; desaturate = 0; lightcontrib = 0; - mlight.r = MIN(light + dynlight.r, 256); - mlight.g = MIN(light + dynlight.g, 256); - mlight.b = MIN(light + dynlight.b, 256); + mlight.r = min(light + dynlight.r, 256); + mlight.g = min(light + dynlight.g, 256); + mlight.b = min(light + dynlight.b, 256); } int count = args.Count(); @@ -300,9 +300,9 @@ namespace swrenderer fgcolor.g = (((shade_fade.g + ((fgcolor.g * inv_desaturate + intensity) >> 8) * mlight.g) >> 8) * shade_light.g) >> 8; fgcolor.b = (((shade_fade.b + ((fgcolor.b * inv_desaturate + intensity) >> 8) * mlight.b) >> 8) * shade_light.b) >> 8; - fgcolor.r = MIN(fgcolor.r + lit_dynlight.r, 255); - fgcolor.g = MIN(fgcolor.g + lit_dynlight.g, 255); - fgcolor.b = MIN(fgcolor.b + lit_dynlight.b, 255); + fgcolor.r = min(fgcolor.r + lit_dynlight.r, 255); + fgcolor.g = min(fgcolor.g + lit_dynlight.g, 255); + fgcolor.b = min(fgcolor.b + lit_dynlight.b, 255); return fgcolor; } } @@ -332,9 +332,9 @@ namespace swrenderer { uint32_t alpha = ifgshade; BgraColor outcolor; - outcolor.r = MIN(((fgcolor.r * alpha) >> 8) + bgcolor.r, 255); - outcolor.g = MIN(((fgcolor.g * alpha) >> 8) + bgcolor.g, 255); - outcolor.b = MIN(((fgcolor.b * alpha) >> 8) + bgcolor.b, 255); + outcolor.r = min(((fgcolor.r * alpha) >> 8) + bgcolor.r, 255); + outcolor.g = min(((fgcolor.g * alpha) >> 8) + bgcolor.g, 255); + outcolor.b = min(((fgcolor.b * alpha) >> 8) + bgcolor.b, 255); outcolor.a = 255; return outcolor; } @@ -357,21 +357,21 @@ namespace swrenderer BgraColor outcolor; if (BlendT::Mode == (int)SpriteBlendModes::AddClamp) { - outcolor.r = MIN((fgcolor.r + bgcolor.r) >> 8, 255); - outcolor.g = MIN((fgcolor.g + bgcolor.g) >> 8, 255); - outcolor.b = MIN((fgcolor.b + bgcolor.b) >> 8, 255); + outcolor.r = min((fgcolor.r + bgcolor.r) >> 8, 255); + outcolor.g = min((fgcolor.g + bgcolor.g) >> 8, 255); + outcolor.b = min((fgcolor.b + bgcolor.b) >> 8, 255); } else if (BlendT::Mode == (int)SpriteBlendModes::SubClamp) { - outcolor.r = MAX(int32_t(fgcolor.r - bgcolor.r) >> 8, 0); - outcolor.g = MAX(int32_t(fgcolor.g - bgcolor.g) >> 8, 0); - outcolor.b = MAX(int32_t(fgcolor.b - bgcolor.b) >> 8, 0); + outcolor.r = max(int32_t(fgcolor.r - bgcolor.r) >> 8, 0); + outcolor.g = max(int32_t(fgcolor.g - bgcolor.g) >> 8, 0); + outcolor.b = max(int32_t(fgcolor.b - bgcolor.b) >> 8, 0); } else if (BlendT::Mode == (int)SpriteBlendModes::RevSubClamp) { - outcolor.r = MAX(int32_t(bgcolor.r - fgcolor.r) >> 8, 0); - outcolor.g = MAX(int32_t(bgcolor.g - fgcolor.g) >> 8, 0); - outcolor.b = MAX(int32_t(bgcolor.b - fgcolor.b) >> 8, 0); + outcolor.r = max(int32_t(bgcolor.r - fgcolor.r) >> 8, 0); + outcolor.g = max(int32_t(bgcolor.g - fgcolor.g) >> 8, 0); + outcolor.b = max(int32_t(bgcolor.b - fgcolor.b) >> 8, 0); } outcolor.a = 255; return outcolor; diff --git a/src/rendering/swrenderer/drawers/r_draw_wall32.h b/src/rendering/swrenderer/drawers/r_draw_wall32.h index 65f7025b2..92056a9b7 100644 --- a/src/rendering/swrenderer/drawers/r_draw_wall32.h +++ b/src/rendering/swrenderer/drawers/r_draw_wall32.h @@ -236,13 +236,13 @@ namespace swrenderer // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) float Lxy2 = light_x; // L.x*L.x + L.y*L.y float Lz = light_z - viewpos_z; float dist2 = Lxy2 + Lz * Lz; float rcp_dist = 1.f/sqrt(dist2); float dist = dist2 * rcp_dist; - float distance_attenuation = 256.0f - MIN(dist * light_radius, 256.0f); + float distance_attenuation = 256.0f - min(dist * light_radius, 256.0f); // The simple light type float simple_attenuation = distance_attenuation; @@ -260,13 +260,13 @@ namespace swrenderer lit.b += (light_color.b * attenuation) >> 8; } - lit.r = MIN(lit.r, 256); - lit.g = MIN(lit.g, 256); - lit.b = MIN(lit.b, 256); + lit.r = min(lit.r, 256); + lit.g = min(lit.g, 256); + lit.b = min(lit.b, 256); - fgcolor.r = MIN(fgcolor.r + ((material.r * lit.r) >> 8), 255); - fgcolor.g = MIN(fgcolor.g + ((material.g * lit.g) >> 8), 255); - fgcolor.b = MIN(fgcolor.b + ((material.b * lit.b) >> 8), 255); + fgcolor.r = min(fgcolor.r + ((material.r * lit.r) >> 8), 255); + fgcolor.g = min(fgcolor.g + ((material.g * lit.g) >> 8), 255); + fgcolor.b = min(fgcolor.b + ((material.b * lit.b) >> 8), 255); return fgcolor; } @@ -302,21 +302,21 @@ namespace swrenderer BgraColor outcolor; if (BlendT::Mode == (int)WallBlendModes::AddClamp) { - outcolor.r = MIN((fgcolor.r + bgcolor.r) >> 8, 255); - outcolor.g = MIN((fgcolor.g + bgcolor.g) >> 8, 255); - outcolor.b = MIN((fgcolor.b + bgcolor.b) >> 8, 255); + outcolor.r = min((fgcolor.r + bgcolor.r) >> 8, 255); + outcolor.g = min((fgcolor.g + bgcolor.g) >> 8, 255); + outcolor.b = min((fgcolor.b + bgcolor.b) >> 8, 255); } else if (BlendT::Mode == (int)WallBlendModes::SubClamp) { - outcolor.r = MAX(int32_t(fgcolor.r - bgcolor.r) >> 8, 0); - outcolor.g = MAX(int32_t(fgcolor.g - bgcolor.g) >> 8, 0); - outcolor.b = MAX(int32_t(fgcolor.b - bgcolor.b) >> 8, 0); + outcolor.r = max(int32_t(fgcolor.r - bgcolor.r) >> 8, 0); + outcolor.g = max(int32_t(fgcolor.g - bgcolor.g) >> 8, 0); + outcolor.b = max(int32_t(fgcolor.b - bgcolor.b) >> 8, 0); } else if (BlendT::Mode == (int)WallBlendModes::RevSubClamp) { - outcolor.r = MAX(int32_t(bgcolor.r - fgcolor.r) >> 8, 0); - outcolor.g = MAX(int32_t(bgcolor.g - fgcolor.g) >> 8, 0); - outcolor.b = MAX(int32_t(bgcolor.b - fgcolor.b) >> 8, 0); + outcolor.r = max(int32_t(bgcolor.r - fgcolor.r) >> 8, 0); + outcolor.g = max(int32_t(bgcolor.g - fgcolor.g) >> 8, 0); + outcolor.b = max(int32_t(bgcolor.b - fgcolor.b) >> 8, 0); } outcolor.a = 255; return outcolor; diff --git a/src/rendering/swrenderer/drawers/r_draw_wall32_sse2.h b/src/rendering/swrenderer/drawers/r_draw_wall32_sse2.h index 4ea8d4d75..1860ba667 100644 --- a/src/rendering/swrenderer/drawers/r_draw_wall32_sse2.h +++ b/src/rendering/swrenderer/drawers/r_draw_wall32_sse2.h @@ -280,7 +280,7 @@ namespace swrenderer // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) __m128 Lxy2 = light_x; // L.x*L.x + L.y*L.y __m128 Lz = _mm_sub_ps(light_z, viewpos_z); __m128 dist2 = _mm_add_ps(Lxy2, _mm_mul_ps(Lz, Lz)); diff --git a/src/rendering/swrenderer/line/r_farclip_line.cpp b/src/rendering/swrenderer/line/r_farclip_line.cpp index e0f027578..1583ed90a 100644 --- a/src/rendering/swrenderer/line/r_farclip_line.cpp +++ b/src/rendering/swrenderer/line/r_farclip_line.cpp @@ -155,7 +155,7 @@ namespace swrenderer for (int x = x1; x < x2; ++x) { short top = (clip3d->fakeFloor && m3DFloor.type == Fake3DOpaque::FakeCeiling) ? clip3d->fakeFloor->ceilingclip[x] : ceilingclip[x]; - short bottom = MIN(walltop.ScreenY[x], floorclip[x]); + short bottom = min(walltop.ScreenY[x], floorclip[x]); if (top < bottom) { mCeilingPlane->top[x] = top; @@ -177,7 +177,7 @@ namespace swrenderer for (int x = x1; x < x2; ++x) { - short top = MAX(wallbottom.ScreenY[x], ceilingclip[x]); + short top = max(wallbottom.ScreenY[x], ceilingclip[x]); short bottom = (clip3d->fakeFloor && m3DFloor.type == Fake3DOpaque::FakeFloor) ? clip3d->fakeFloor->floorclip[x] : floorclip[x]; if (top < bottom) { diff --git a/src/rendering/swrenderer/line/r_fogboundary.cpp b/src/rendering/swrenderer/line/r_fogboundary.cpp index 1a6e40519..46cf673bd 100644 --- a/src/rendering/swrenderer/line/r_fogboundary.cpp +++ b/src/rendering/swrenderer/line/r_fogboundary.cpp @@ -110,13 +110,13 @@ namespace swrenderer { if (fake_dc_colormap != basecolormapdata) { - stop = MIN(t1, b2); + stop = min(t1, b2); while (t2 < stop) { int y = t2++; drawerargs.DrawFogBoundaryLine(thread, y, xr, spanend[y]); } - stop = MAX(b1, t2); + stop = max(b1, t2); while (b2 > stop) { int y = --b2; @@ -125,16 +125,16 @@ namespace swrenderer } else { - t2 = MAX(t2, MIN(t1, b2)); - b2 = MIN(b2, MAX(b1, t2)); + t2 = max(t2, min(t1, b2)); + b2 = min(b2, max(b1, t2)); } - stop = MIN(t2, b1); + stop = min(t2, b1); while (t1 < stop) { spanend[t1++] = x; } - stop = MAX(b2, t2); + stop = max(b2, t2); while (b1 > stop) { spanend[--b1] = x; diff --git a/src/rendering/swrenderer/line/r_line.cpp b/src/rendering/swrenderer/line/r_line.cpp index e2e08b268..de4f4f307 100644 --- a/src/rendering/swrenderer/line/r_line.cpp +++ b/src/rendering/swrenderer/line/r_line.cpp @@ -752,7 +752,7 @@ namespace swrenderer for (int x = x1; x < x2; ++x) { short top = (clip3d->fakeFloor && m3DFloor.type == Fake3DOpaque::FakeCeiling) ? clip3d->fakeFloor->ceilingclip[x] : ceilingclip[x]; - short bottom = MIN(walltop.ScreenY[x], floorclip[x]); + short bottom = min(walltop.ScreenY[x], floorclip[x]); if (top < bottom) { mCeilingPlane->top[x] = top; @@ -774,7 +774,7 @@ namespace swrenderer for (int x = x1; x < x2; ++x) { - short top = MAX(wallbottom.ScreenY[x], ceilingclip[x]); + short top = max(wallbottom.ScreenY[x], ceilingclip[x]); short bottom = (clip3d->fakeFloor && m3DFloor.type == Fake3DOpaque::FakeFloor) ? clip3d->fakeFloor->floorclip[x] : floorclip[x]; if (top < bottom) { @@ -804,7 +804,7 @@ namespace swrenderer { for (int x = x1; x < x2; ++x) { - walllower.ScreenY[x] = MIN(MAX(walllower.ScreenY[x], ceilingclip[x]), wallbottom.ScreenY[x]); + walllower.ScreenY[x] = min(max(walllower.ScreenY[x], ceilingclip[x]), wallbottom.ScreenY[x]); } memcpy(clip3d->fakeFloor->floorclip + x1, walllower.ScreenY + x1, (x2 - x1) * sizeof(short)); } @@ -816,7 +816,7 @@ namespace swrenderer { for (int x = x1; x < x2; ++x) { - wallupper.ScreenY[x] = MAX(MIN(wallupper.ScreenY[x], floorclip[x]), walltop.ScreenY[x]); + wallupper.ScreenY[x] = max(min(wallupper.ScreenY[x], floorclip[x]), walltop.ScreenY[x]); } memcpy(clip3d->fakeFloor->ceilingclip + x1, wallupper.ScreenY + x1, (x2 - x1) * sizeof(short)); } @@ -839,7 +839,7 @@ namespace swrenderer { // top wall for (int x = x1; x < x2; ++x) { - wallupper.ScreenY[x] = MAX(MIN(wallupper.ScreenY[x], floorclip[x]), walltop.ScreenY[x]); + wallupper.ScreenY[x] = max(min(wallupper.ScreenY[x], floorclip[x]), walltop.ScreenY[x]); } memcpy(ceilingclip + x1, wallupper.ScreenY + x1, (x2 - x1) * sizeof(short)); } @@ -852,7 +852,7 @@ namespace swrenderer { // bottom wall for (int x = x1; x < x2; ++x) { - walllower.ScreenY[x] = MIN(MAX(walllower.ScreenY[x], ceilingclip[x]), wallbottom.ScreenY[x]); + walllower.ScreenY[x] = min(max(walllower.ScreenY[x], ceilingclip[x]), wallbottom.ScreenY[x]); } memcpy(floorclip + x1, walllower.ScreenY + x1, (x2 - x1) * sizeof(short)); } diff --git a/src/rendering/swrenderer/line/r_renderdrawsegment.cpp b/src/rendering/swrenderer/line/r_renderdrawsegment.cpp index b4c5fa544..bd67b88f0 100644 --- a/src/rendering/swrenderer/line/r_renderdrawsegment.cpp +++ b/src/rendering/swrenderer/line/r_renderdrawsegment.cpp @@ -122,20 +122,20 @@ namespace swrenderer top -= Thread->Viewport->viewpoint.Pos.Z; bot -= Thread->Viewport->viewpoint.Pos.Z; - ceilZ = MIN(ceilZ, top); - floorZ = MAX(floorZ, bot); + ceilZ = min(ceilZ, top); + floorZ = max(floorZ, bot); } // Clip wall by the current 3D floor render range. if (m3DFloor.clipTop) { double clipZ = m3DFloor.sclipTop - Thread->Viewport->viewpoint.Pos.Z; - ceilZ = MIN(ceilZ, clipZ); + ceilZ = min(ceilZ, clipZ); } if (m3DFloor.clipBottom) { double clipZ = m3DFloor.sclipBottom - Thread->Viewport->viewpoint.Pos.Z; - floorZ = MAX(floorZ, clipZ); + floorZ = max(floorZ, clipZ); } wallupper.Project(Thread->Viewport.get(), ceilZ, &ds->WallC); @@ -191,7 +191,7 @@ namespace swrenderer sector_t tempsec; const sector_t* lightsector = Thread->OpaquePass->FakeFlat(frontsector, &tempsec, nullptr, nullptr, nullptr, 0, 0, 0, 0); - fixed_t alpha = FLOAT2FIXED((float)MIN(curline->linedef->alpha, 1.)); + fixed_t alpha = FLOAT2FIXED((float)min(curline->linedef->alpha, 1.)); bool additive = (curline->linedef->flags & ML_ADDTRANS) != 0; RenderWallPart renderWallpart(Thread); @@ -614,16 +614,16 @@ namespace swrenderer double frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1); double frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2); double frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2); - top = MAX(frontcz1, frontcz2); - bot = MIN(frontfz1, frontfz2); + top = max(frontcz1, frontcz2); + bot = min(frontfz1, frontfz2); if (m3DFloor.clipTop) { - top = MIN(top, m3DFloor.sclipTop); + top = min(top, m3DFloor.sclipTop); } if (m3DFloor.clipBottom) { - bot = MAX(bot, m3DFloor.sclipBottom); + bot = max(bot, m3DFloor.sclipBottom); } } @@ -632,9 +632,9 @@ namespace swrenderer double texheight = tex->GetScaledHeight() / fabs(curline->sidedef->GetTextureYScale(side_t::mid)); double texturemid; if (curline->linedef->flags & ML_DONTPEGBOTTOM) - texturemid = MAX(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)) + texheight; + texturemid = max(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)) + texheight; else - texturemid = MIN(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling)); + texturemid = min(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling)); double rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid); if (tex->useWorldPanning(curline->GetLevel())) rowoffset /= fabs(tex->GetScale().Y * curline->sidedef->GetTextureYScale(side_t::mid)); diff --git a/src/rendering/swrenderer/line/r_wallsetup.cpp b/src/rendering/swrenderer/line/r_wallsetup.cpp index 2f864581e..f1bf6aff2 100644 --- a/src/rendering/swrenderer/line/r_wallsetup.cpp +++ b/src/rendering/swrenderer/line/r_wallsetup.cpp @@ -441,8 +441,8 @@ namespace swrenderer float yscale = GetYScale(sidedef, pic, side_t::mid); double cameraZ = viewport->viewpoint.Pos.Z; - double texZFloor = MAX(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)); - double texZCeiling = MIN(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling)); + double texZFloor = max(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)); + double texZCeiling = min(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling)); double texturemid; if (yscale >= 0) diff --git a/src/rendering/swrenderer/plane/r_flatplane.cpp b/src/rendering/swrenderer/plane/r_flatplane.cpp index 9075fe910..c17c9ed6b 100644 --- a/src/rendering/swrenderer/plane/r_flatplane.cpp +++ b/src/rendering/swrenderer/plane/r_flatplane.cpp @@ -178,9 +178,9 @@ namespace swrenderer double distance2 = viewport->PlaneDepth(y + 1, planeheight); double xmagnitude = fabs(ystepscale * (distance2 - distance) * viewport->FocalLengthX); double ymagnitude = fabs(xstepscale * (distance2 - distance) * viewport->FocalLengthX); - double magnitude = MAX(ymagnitude, xmagnitude); + double magnitude = max(ymagnitude, xmagnitude); double min_lod = -1000.0; - drawerargs.SetTextureLOD(MAX(log2(magnitude) + r_lod_bias, min_lod)); + drawerargs.SetTextureLOD(max(log2(magnitude) + r_lod_bias, min_lod)); } if (plane_shade) diff --git a/src/rendering/swrenderer/plane/r_planerenderer.cpp b/src/rendering/swrenderer/plane/r_planerenderer.cpp index f251d5c71..35919a59f 100644 --- a/src/rendering/swrenderer/plane/r_planerenderer.cpp +++ b/src/rendering/swrenderer/plane/r_planerenderer.cpp @@ -65,14 +65,14 @@ namespace swrenderer int stop; // Draw any spans that have just closed - stop = MIN(t1, b2); + stop = min(t1, b2); while (t2 < stop) { int y = t2++; int x2 = spanend[y]; RenderLine(y, xr, x2); } - stop = MAX(b1, t2); + stop = max(b1, t2); while (b2 > stop) { int y = --b2; @@ -81,12 +81,12 @@ namespace swrenderer } // Mark any spans that have just opened - stop = MIN(t2, b1); + stop = min(t2, b1); while (t1 < stop) { spanend[t1++] = x; } - stop = MAX(b2, t2); + stop = max(b2, t2); while (b1 > stop) { spanend[--b1] = x; diff --git a/src/rendering/swrenderer/plane/r_skyplane.cpp b/src/rendering/swrenderer/plane/r_skyplane.cpp index cc59301ad..cf88e0439 100644 --- a/src/rendering/swrenderer/plane/r_skyplane.cpp +++ b/src/rendering/swrenderer/plane/r_skyplane.cpp @@ -109,8 +109,8 @@ namespace swrenderer // giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024, // we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of // the texture as the cylinder's circumfrence. - sky1cyl = MAX(sskytex1->GetWidth(), fixed_t(sskytex1->GetScale().X * 1024)); - sky2cyl = MAX(sskytex2->GetWidth(), fixed_t(sskytex2->GetScale().Y * 1024)); + sky1cyl = max(sskytex1->GetWidth(), fixed_t(sskytex1->GetScale().X * 1024)); + sky2cyl = max(sskytex2->GetWidth(), fixed_t(sskytex2->GetScale().Y * 1024)); } void RenderSkyPlane::Render(VisiblePlane *pl) @@ -199,7 +199,7 @@ namespace swrenderer skyflip = l->args[2] ? 0u : ~0u; int frontxscale = int(frontskytex->GetScale().X * 1024); - frontcyl = MAX(frontskytex->GetWidth(), frontxscale); + frontcyl = max(frontskytex->GetWidth(), frontxscale); if (Level->skystretch) { skymid = skymid * frontskytex->GetScaledHeight() / (SKYSTRETCH_HEIGHT + skyoffset); diff --git a/src/rendering/swrenderer/scene/r_light.cpp b/src/rendering/swrenderer/scene/r_light.cpp index 5b8a689b2..4a8de1950 100644 --- a/src/rendering/swrenderer/scene/r_light.cpp +++ b/src/rendering/swrenderer/scene/r_light.cpp @@ -149,7 +149,7 @@ namespace swrenderer bool nolightfade = !foggy && ((viewport->Level()->flags3 & LEVEL3_NOLIGHTFADE)); if (nolightfade) { - return (MAX(255 - lightlevel, 0) * NUMCOLORMAPS) << (FRACBITS - 8); + return (max(255 - lightlevel, 0) * NUMCOLORMAPS) << (FRACBITS - 8); } else { diff --git a/src/rendering/swrenderer/scene/r_light.h b/src/rendering/swrenderer/scene/r_light.h index d14c73b55..8f1d6adcc 100644 --- a/src/rendering/swrenderer/scene/r_light.h +++ b/src/rendering/swrenderer/scene/r_light.h @@ -43,12 +43,12 @@ // Convert a shade and visibility to a clamped colormap index. // Result is not fixed point. // Change R_CalcTiltedLighting() when this changes. -#define GETPALOOKUP(vis,shade) (clamp (((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis))))>>FRACBITS, 0, NUMCOLORMAPS-1)) +#define GETPALOOKUP(vis,shade) (clamp (((shade)-FLOAT2FIXED(min(MAXLIGHTVIS,double(vis))))>>FRACBITS, 0, NUMCOLORMAPS-1)) // Calculate the light multiplier for dc_light/ds_light // This is used instead of GETPALOOKUP when ds_colormap/dc_colormap is set to the base colormap // Returns a value between 0 and 1 in fixed point -#define LIGHTSCALE(vis,shade) FLOAT2FIXED(clamp((FIXED2DBL(shade) - (MIN(MAXLIGHTVIS,double(vis)))) / NUMCOLORMAPS, 0.0, (NUMCOLORMAPS-1)/(double)NUMCOLORMAPS)) +#define LIGHTSCALE(vis,shade) FLOAT2FIXED(clamp((FIXED2DBL(shade) - (min(MAXLIGHTVIS,double(vis)))) / NUMCOLORMAPS, 0.0, (NUMCOLORMAPS-1)/(double)NUMCOLORMAPS)) struct FSWColormap; @@ -82,7 +82,7 @@ namespace swrenderer // The vis value to pass into the GETPALOOKUP or LIGHTSCALE macros double WallVis(double screenZ, bool foggy) const { return WallGlobVis(foggy) / screenZ; } - double SpriteVis(double screenZ, bool foggy) const { return SpriteGlobVis(foggy) / MAX(screenZ, MINZ); } + double SpriteVis(double screenZ, bool foggy) const { return SpriteGlobVis(foggy) / max(screenZ, MINZ); } double FlatPlaneVis(int screenY, double planeheight, bool foggy, RenderViewport *viewport) const { return FlatPlaneGlobVis(foggy) / planeheight * fabs(viewport->CenterY - screenY); } double SlopePlaneGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : TiltVisibility; } diff --git a/src/rendering/swrenderer/scene/r_opaque_pass.cpp b/src/rendering/swrenderer/scene/r_opaque_pass.cpp index 9bb69562c..5c7e60e6d 100644 --- a/src/rendering/swrenderer/scene/r_opaque_pass.cpp +++ b/src/rendering/swrenderer/scene/r_opaque_pass.cpp @@ -700,7 +700,7 @@ namespace swrenderer if (!(clip3d->fakeFloor->fakeFloor->flags & FF_RENDERPLANES)) continue; if (clip3d->fakeFloor->fakeFloor->alpha == 0) continue; if (clip3d->fakeFloor->fakeFloor->flags & FF_THISINSIDE && clip3d->fakeFloor->fakeFloor->flags & FF_INVERTSECTOR) continue; - fixed_t fakeAlpha = MIN(Scale(clip3d->fakeFloor->fakeFloor->alpha, OPAQUE, 255), OPAQUE); + fixed_t fakeAlpha = min(Scale(clip3d->fakeFloor->fakeFloor->alpha, OPAQUE, 255), OPAQUE); if (clip3d->fakeFloor->validcount != validcount) { clip3d->fakeFloor->validcount = validcount; @@ -764,7 +764,7 @@ namespace swrenderer if (!(clip3d->fakeFloor->fakeFloor->flags & FF_RENDERPLANES)) continue; if (clip3d->fakeFloor->fakeFloor->alpha == 0) continue; if (!(clip3d->fakeFloor->fakeFloor->flags & FF_THISINSIDE) && (clip3d->fakeFloor->fakeFloor->flags & (FF_SWIMMABLE | FF_INVERTSECTOR)) == (FF_SWIMMABLE | FF_INVERTSECTOR)) continue; - fixed_t fakeAlpha = MIN(Scale(clip3d->fakeFloor->fakeFloor->alpha, OPAQUE, 255), OPAQUE); + fixed_t fakeAlpha = min(Scale(clip3d->fakeFloor->fakeFloor->alpha, OPAQUE, 255), OPAQUE); if (clip3d->fakeFloor->validcount != validcount) { diff --git a/src/rendering/swrenderer/segments/r_drawsegment.cpp b/src/rendering/swrenderer/segments/r_drawsegment.cpp index fd7517d72..ce704b387 100644 --- a/src/rendering/swrenderer/segments/r_drawsegment.cpp +++ b/src/rendering/swrenderer/segments/r_drawsegment.cpp @@ -104,21 +104,21 @@ namespace swrenderer DrawSegmentGroup group; group.BeginIndex = index; - group.EndIndex = MIN(index + groupSize, SegmentsCount()); + group.EndIndex = min(index + groupSize, SegmentsCount()); group.x1 = ds->x1; group.x2 = ds->x2; - group.neardepth = MIN(ds->WallC.sz1, ds->WallC.sz2); - group.fardepth = MAX(ds->WallC.sz1, ds->WallC.sz2); + group.neardepth = min(ds->WallC.sz1, ds->WallC.sz2); + group.fardepth = max(ds->WallC.sz1, ds->WallC.sz2); for (unsigned int groupIndex = group.BeginIndex + 1; groupIndex < group.EndIndex; groupIndex++) { ds = Segment(groupIndex); - group.x1 = MIN(group.x1, ds->x1); - group.x2 = MAX(group.x2, ds->x2); - group.neardepth = MIN(group.neardepth, ds->WallC.sz1); - group.neardepth = MIN(group.neardepth, ds->WallC.sz2); - group.fardepth = MAX(ds->WallC.sz1, group.fardepth); - group.fardepth = MAX(ds->WallC.sz2, group.fardepth); + group.x1 = min(group.x1, ds->x1); + group.x2 = max(group.x2, ds->x2); + group.neardepth = min(group.neardepth, ds->WallC.sz1); + group.neardepth = min(group.neardepth, ds->WallC.sz2); + group.fardepth = max(ds->WallC.sz1, group.fardepth); + group.fardepth = max(ds->WallC.sz2, group.fardepth); } for (int x = group.x1; x < group.x2; x++) diff --git a/src/rendering/swrenderer/textures/r_swtexture.cpp b/src/rendering/swrenderer/textures/r_swtexture.cpp index 662c12d57..1336abfd2 100644 --- a/src/rendering/swrenderer/textures/r_swtexture.cpp +++ b/src/rendering/swrenderer/textures/r_swtexture.cpp @@ -364,8 +364,8 @@ void FSoftwareTexture::CreatePixelsBgraWithMipmaps() int buffersize = 0; for (int i = 0; i < levels; i++) { - int w = MAX(GetPhysicalWidth() >> i, 1); - int h = MAX(GetPhysicalHeight() >> i, 1); + int w = max(GetPhysicalWidth() >> i, 1); + int h = max(GetPhysicalHeight() >> i, 1); buffersize += w * h; } PixelsBgra.Resize(buffersize); @@ -379,7 +379,7 @@ int FSoftwareTexture::MipmapLevels() int heightbits = 0; while ((GetPhysicalHeight() >> heightbits) != 0) heightbits++; - return MAX(widthbits, heightbits); + return max(widthbits, heightbits); } //========================================================================== @@ -430,20 +430,20 @@ void FSoftwareTexture::GenerateBgraMipmaps() Color4f *dest = src + GetPhysicalWidth() * GetPhysicalHeight(); for (int i = 1; i < levels; i++) { - int srcw = MAX(GetPhysicalWidth() >> (i - 1), 1); - int srch = MAX(GetPhysicalHeight() >> (i - 1), 1); - int w = MAX(GetPhysicalWidth() >> i, 1); - int h = MAX(GetPhysicalHeight() >> i, 1); + int srcw = max(GetPhysicalWidth() >> (i - 1), 1); + int srch = max(GetPhysicalHeight() >> (i - 1), 1); + int w = max(GetPhysicalWidth() >> i, 1); + int h = max(GetPhysicalHeight() >> i, 1); // Downscale for (int x = 0; x < w; x++) { int sx0 = x * 2; - int sx1 = MIN((x + 1) * 2, srcw - 1); + int sx1 = min((x + 1) * 2, srcw - 1); for (int y = 0; y < h; y++) { int sy0 = y * 2; - int sy1 = MIN((y + 1) * 2, srch - 1); + int sy1 = min((y + 1) * 2, srch - 1); Color4f src00 = src[sy0 + sx0 * srch]; Color4f src01 = src[sy1 + sx0 * srch]; @@ -493,14 +493,14 @@ void FSoftwareTexture::GenerateBgraMipmaps() uint32_t *dest = PixelsBgra.Data() + GetPhysicalWidth() * GetPhysicalHeight(); for (int i = 1; i < levels; i++) { - int w = MAX(GetPhysicalWidth() >> i, 1); - int h = MAX(GetPhysicalHeight() >> i, 1); + int w = max(GetPhysicalWidth() >> i, 1); + int h = max(GetPhysicalHeight() >> i, 1); for (int j = 0; j < w * h; j++) { - uint32_t a = (uint32_t)clamp(powf(MAX(src[j].a, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t r = (uint32_t)clamp(powf(MAX(src[j].r, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t g = (uint32_t)clamp(powf(MAX(src[j].g, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t b = (uint32_t)clamp(powf(MAX(src[j].b, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t a = (uint32_t)clamp(powf(max(src[j].a, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t r = (uint32_t)clamp(powf(max(src[j].r, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t g = (uint32_t)clamp(powf(max(src[j].g, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t b = (uint32_t)clamp(powf(max(src[j].b, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); dest[j] = (a << 24) | (r << 16) | (g << 8) | b; } src += w * h; diff --git a/src/rendering/swrenderer/textures/warpbuffer.h b/src/rendering/swrenderer/textures/warpbuffer.h index 114b8af00..778706850 100644 --- a/src/rendering/swrenderer/textures/warpbuffer.h +++ b/src/rendering/swrenderer/textures/warpbuffer.h @@ -43,7 +43,7 @@ void WarpBuffer(TYPE *Pixels, const TYPE *source, int width, int height, int xmu if (warptype == 1) { - TYPE *buffer = (TYPE *)alloca(sizeof(TYPE) * MAX(width, height)); + TYPE *buffer = (TYPE *)alloca(sizeof(TYPE) * max(width, height)); // [mxd] Rewrote to fix animation for NPo2 textures unsigned timebase = unsigned(time * Speed * 32 / 28); for (y = height - 1; y >= 0; y--) diff --git a/src/rendering/swrenderer/textures/warptexture.cpp b/src/rendering/swrenderer/textures/warptexture.cpp index ce3cb2f52..10e51ddb0 100644 --- a/src/rendering/swrenderer/textures/warptexture.cpp +++ b/src/rendering/swrenderer/textures/warptexture.cpp @@ -126,20 +126,20 @@ void FWarpTexture::GenerateBgraMipmapsFast() int levels = MipmapLevels(); for (int i = 1; i < levels; i++) { - int srcw = MAX(GetPhysicalWidth() >> (i - 1), 1); - int srch = MAX(GetPhysicalHeight() >> (i - 1), 1); - int w = MAX(GetPhysicalWidth() >> i, 1); - int h = MAX(GetPhysicalHeight() >> i, 1); + int srcw = max(GetPhysicalWidth() >> (i - 1), 1); + int srch = max(GetPhysicalHeight() >> (i - 1), 1); + int w = max(GetPhysicalWidth() >> i, 1); + int h = max(GetPhysicalHeight() >> i, 1); for (int x = 0; x < w; x++) { int sx0 = x * 2; - int sx1 = MIN((x + 1) * 2, srcw - 1); + int sx1 = min((x + 1) * 2, srcw - 1); for (int y = 0; y < h; y++) { int sy0 = y * 2; - int sy1 = MIN((y + 1) * 2, srch - 1); + int sy1 = min((y + 1) * 2, srch - 1); uint32_t src00 = src[sy0 + sx0 * srch]; uint32_t src01 = src[sy1 + sx0 * srch]; diff --git a/src/rendering/swrenderer/things/r_particle.cpp b/src/rendering/swrenderer/things/r_particle.cpp index 6e9f2b00e..85374269c 100644 --- a/src/rendering/swrenderer/things/r_particle.cpp +++ b/src/rendering/swrenderer/things/r_particle.cpp @@ -120,8 +120,8 @@ namespace swrenderer // calculate edges of the shape double psize = particle->size / 8.0; - x1 = MAX(renderportal->WindowLeft, thread->Viewport->viewwindow.centerx + xs_RoundToInt((tx - psize) * xscale)); - x2 = MIN(renderportal->WindowRight, thread->Viewport->viewwindow.centerx + xs_RoundToInt((tx + psize) * xscale)); + x1 = max(renderportal->WindowLeft, thread->Viewport->viewwindow.centerx + xs_RoundToInt((tx - psize) * xscale)); + x2 = min(renderportal->WindowRight, thread->Viewport->viewwindow.centerx + xs_RoundToInt((tx + psize) * xscale)); if (x1 >= x2) return; @@ -285,7 +285,7 @@ namespace swrenderer if (ds->drawsegclip.CurrentPortalUniq == CurrentPortalUniq) { RenderDrawSegment renderer(thread); - renderer.Render(ds, MAX(ds->x1, x1), MIN(ds->x2, x2), clip3DFloor); + renderer.Render(ds, max(ds->x1, x1), min(ds->x2, x2), clip3DFloor); } } } diff --git a/src/rendering/swrenderer/things/r_visiblesprite.cpp b/src/rendering/swrenderer/things/r_visiblesprite.cpp index 16e3435c5..d9ecacda6 100644 --- a/src/rendering/swrenderer/things/r_visiblesprite.cpp +++ b/src/rendering/swrenderer/things/r_visiblesprite.cpp @@ -61,8 +61,8 @@ namespace swrenderer DrawSegment *ds = segmentlist->TranslucentSegment(index); if (ds->drawsegclip.SubsectorDepth >= SubsectorDepth && ds->drawsegclip.CurrentPortalUniq == renderportal->CurrentPortalUniq) { - int r1 = MAX(ds->x1, 0); - int r2 = MIN(ds->x2, viewwidth - 1); + int r1 = max(ds->x1, 0); + int r2 = min(ds->x2, viewwidth - 1); RenderDrawSegment renderer(thread); renderer.Render(ds, r1, r2, clip3DFloor); @@ -200,17 +200,17 @@ namespace swrenderer { // seen below floor: clip top if (!spr->IsVoxel() && h > topclip) { - topclip = short(MIN(h, viewheight)); + topclip = short(min(h, viewheight)); } - hzt = MIN(hzt, hz); + hzt = min(hzt, hz); } else { // seen in the middle: clip bottom if (!spr->IsVoxel() && h < botclip) { - botclip = MAX(0, h); + botclip = max(0, h); } - hzb = MAX(hzb, hz); + hzb = max(hzb, hz); } } if (spr->FakeFlatStat != WaterFakeSide::BelowFloor && !(spr->heightsec->MoreFlags & SECMF_FAKEFLOORONLY)) @@ -222,17 +222,17 @@ namespace swrenderer { // seen above ceiling: clip bottom if (!spr->IsVoxel() && h < botclip) { - botclip = MAX(0, h); + botclip = max(0, h); } - hzb = MAX(hzb, hz); + hzb = max(hzb, hz); } else { // seen in the middle: clip top if (!spr->IsVoxel() && h > topclip) { - topclip = MIN(h, viewheight); + topclip = min(h, viewheight); } - hzt = MIN(hzt, hz); + hzt = min(hzt, hz); } } } @@ -242,7 +242,7 @@ namespace swrenderer int clip = xs_RoundToInt(viewport->CenterY - (spr->texturemid - spr->pic->GetHeight() + spr->floorclip) * spr->yscale); if (clip < botclip) { - botclip = MAX(0, clip); + botclip = max(0, clip); } } @@ -262,10 +262,10 @@ namespace swrenderer int h = xs_RoundToInt(viewport->CenterY - (hz - viewport->viewpoint.Pos.Z) * scale); if (h < botclip) { - botclip = MAX(0, h); + botclip = max(0, h); } } - hzb = MAX(hzb, clip3DFloor.sclipBottom); + hzb = max(hzb, clip3DFloor.sclipBottom); } if (clip3DFloor.clipTop) { @@ -283,10 +283,10 @@ namespace swrenderer int h = xs_RoundToInt(viewport->CenterY - (hz - viewport->viewpoint.Pos.Z) * scale); if (h > topclip) { - topclip = short(MIN(h, viewheight)); + topclip = short(min(h, viewheight)); } } - hzt = MIN(hzt, clip3DFloor.sclipTop); + hzt = min(hzt, clip3DFloor.sclipTop); } if (topclip >= botclip) @@ -322,8 +322,8 @@ namespace swrenderer DrawSegment *ds = segmentlist->TranslucentSegment(index); if (ds->drawsegclip.SubsectorDepth >= subsectordepth && ds->drawsegclip.CurrentPortalUniq == renderportal->CurrentPortalUniq) { - int r1 = MAX(ds->x1, 0); - int r2 = MIN(ds->x2, viewwidth - 1); + int r1 = max(ds->x1, 0); + int r2 = min(ds->x2, viewwidth - 1); RenderDrawSegment renderer(thread); renderer.Render(ds, r1, r2, clip3DFloor); @@ -341,8 +341,8 @@ namespace swrenderer continue; } - float neardepth = MIN(ds->WallC.sz1, ds->WallC.sz2); - float fardepth = MAX(ds->WallC.sz1, ds->WallC.sz2); + float neardepth = min(ds->WallC.sz1, ds->WallC.sz2); + float fardepth = max(ds->WallC.sz1, ds->WallC.sz2); // Check if sprite is in front of draw seg: if ((!spr->IsWallSprite() && neardepth > spr->depth) || ((spr->IsWallSprite() || fardepth > spr->depth) && @@ -351,8 +351,8 @@ namespace swrenderer { if (ds->drawsegclip.CurrentPortalUniq == renderportal->CurrentPortalUniq) { - int r1 = MAX(ds->x1, x1); - int r2 = MIN(ds->x2, x2); + int r1 = max(ds->x1, x1); + int r2 = min(ds->x2, x2); RenderDrawSegment renderer(thread); renderer.Render(ds, r1, r2, clip3DFloor); @@ -370,8 +370,8 @@ namespace swrenderer if (group.fardepth < spr->depth) { - int r1 = MAX(group.x1, x1); - int r2 = MIN(group.x2, x2); + int r1 = max(group.x1, x1); + int r2 = min(group.x2, x2); // Clip bottom short *clip1 = clipbot + r1; @@ -410,11 +410,11 @@ namespace swrenderer continue; } - int r1 = MAX(ds->x1, x1); - int r2 = MIN(ds->x2, x2); + int r1 = max(ds->x1, x1); + int r2 = min(ds->x2, x2); - float neardepth = MIN(ds->WallC.sz1, ds->WallC.sz2); - float fardepth = MAX(ds->WallC.sz1, ds->WallC.sz2); + float neardepth = min(ds->WallC.sz1, ds->WallC.sz2); + float fardepth = max(ds->WallC.sz1, ds->WallC.sz2); // Check if sprite is in front of draw seg: if ((!spr->IsWallSprite() && neardepth > spr->depth) || ((spr->IsWallSprite() || fardepth > spr->depth) && diff --git a/src/rendering/swrenderer/things/r_voxel.cpp b/src/rendering/swrenderer/things/r_voxel.cpp index dc8ef9de1..ee343d2c2 100644 --- a/src/rendering/swrenderer/things/r_voxel.cpp +++ b/src/rendering/swrenderer/things/r_voxel.cpp @@ -324,7 +324,7 @@ namespace swrenderer // Select mip level i = abs(DMulScale(dasprx - globalposx, cosang, daspry - globalposy, sinang, 6)); - i = DivScale(i, MIN(daxscale, dayscale), 6); + i = DivScale(i, min(daxscale, dayscale), 6); j = xs_Fix<13>::ToFix(viewport->FocalLengthX); for (k = 0; i >= j && k < voxobj->NumMips; ++k) { @@ -372,7 +372,7 @@ namespace swrenderer gyinc = DMulScale(sprcosang, cosang, sprsinang, sinang, 10); if ((abs(globalposz - dasprz) >> 10) >= abs(dazscale)) return; - x = 0; y = 0; j = MAX(mip->SizeX, mip->SizeY); + x = 0; y = 0; j = max(mip->SizeX, mip->SizeY); fixed_t *ggxinc = (fixed_t *)alloca((j + 1) * sizeof(fixed_t) * 2); fixed_t *ggyinc = ggxinc + (j + 1); for (i = 0; i <= j; i++) @@ -487,8 +487,8 @@ namespace swrenderer if (flags & DVF_FIND_X1X2) { - coverageX1 = MIN(coverageX1, lx); - coverageX2 = MAX(coverageX2, rx); + coverageX1 = min(coverageX1, lx); + coverageX2 = max(coverageX2, rx); continue; } @@ -550,9 +550,9 @@ namespace swrenderer else yinc = (((1 << 24) - 1) / (z2 - z1)) * zleng >> 8; } // [RH] Clip each column separately, not just by the first one. - for (int stripwidth = MIN(countof(z1a), rx - lx), lxt = lx; + for (int stripwidth = min(countof(z1a), rx - lx), lxt = lx; lxt < rx; - (lxt += countof(z1a)), stripwidth = MIN(countof(z1a), rx - lxt)) + (lxt += countof(z1a)), stripwidth = min(countof(z1a), rx - lxt)) { // Calculate top and bottom pixels locations for (int xxx = 0; xxx < stripwidth; ++xxx) @@ -560,7 +560,7 @@ namespace swrenderer if (zleng == 1) { yplc[xxx] = 0; - z1a[xxx] = MAX(z1, daumost[lxt + xxx]); + z1a[xxx] = max(z1, daumost[lxt + xxx]); } else { @@ -575,7 +575,7 @@ namespace swrenderer z1a[xxx] = z1; } } - z2a[xxx] = MIN(z2, dadmost[lxt + xxx]); + z2a[xxx] = min(z2, dadmost[lxt + xxx]); } const uint8_t *columnColors = col; @@ -991,8 +991,8 @@ namespace swrenderer int ztop = slab->ztop; int zbottom = ztop + slab->zleng; - //ztop = MAX(ztop, minZ); - //zbottom = MIN(zbottom, maxZ); + //ztop = max(ztop, minZ); + //zbottom = min(zbottom, maxZ); for (int z = ztop; z < zbottom; z++) { @@ -1023,10 +1023,10 @@ namespace swrenderer DVector3 screenPos = viewport->PointViewToScreen(viewPos); DVector2 screenExtent = viewport->ScaleViewToScreen({ extentX, extentY }, viewPos.Z, pixelstretch); - int x1 = MAX((int)(screenPos.X - screenExtent.X), 0); - int x2 = MIN((int)(screenPos.X + screenExtent.X + 0.5f), viewwidth - 1); - int y1 = MAX((int)(screenPos.Y - screenExtent.Y), 0); - int y2 = MIN((int)(screenPos.Y + screenExtent.Y + 0.5f), viewheight - 1); + int x1 = max((int)(screenPos.X - screenExtent.X), 0); + int x2 = min((int)(screenPos.X + screenExtent.X + 0.5f), viewwidth - 1); + int y1 = max((int)(screenPos.Y - screenExtent.Y), 0); + int y2 = min((int)(screenPos.Y + screenExtent.Y + 0.5f), viewheight - 1); int pixelsize = viewport->RenderTarget->IsBgra() ? 4 : 1; @@ -1034,8 +1034,8 @@ namespace swrenderer { for (int x = x1; x < x2; x++) { - int columnY1 = MAX(y1, (int)cliptop[x]); - int columnY2 = MIN(y2, (int)clipbottom[x]); + int columnY1 = max(y1, (int)cliptop[x]); + int columnY2 = min(y2, (int)clipbottom[x]); if (columnY1 < columnY2) { drawerargs.SetDest(x, columnY1); diff --git a/src/rendering/swrenderer/things/r_wallsprite.cpp b/src/rendering/swrenderer/things/r_wallsprite.cpp index bc14fc148..971f42b2e 100644 --- a/src/rendering/swrenderer/things/r_wallsprite.cpp +++ b/src/rendering/swrenderer/things/r_wallsprite.cpp @@ -159,8 +159,8 @@ namespace swrenderer { auto spr = this; - int x1 = MAX(spr->x1, spr->wallc.sx1); - int x2 = MIN(spr->x2, spr->wallc.sx2); + int x1 = max(spr->x1, spr->wallc.sx1); + int x2 = min(spr->x2, spr->wallc.sx2); if (x1 >= x2) return; diff --git a/src/rendering/swrenderer/viewport/r_drawerargs.cpp b/src/rendering/swrenderer/viewport/r_drawerargs.cpp index cf12dc41f..9591b4498 100644 --- a/src/rendering/swrenderer/viewport/r_drawerargs.cpp +++ b/src/rendering/swrenderer/viewport/r_drawerargs.cpp @@ -81,7 +81,7 @@ namespace swrenderer shadeConstants.fade_green = mBaseColormap->Fade.g; shadeConstants.fade_blue = mBaseColormap->Fade.b; shadeConstants.fade_alpha = mBaseColormap->Fade.a; - shadeConstants.desaturate = MIN(abs(mBaseColormap->Desaturate), 255) * 255 / 256; + shadeConstants.desaturate = min(abs(mBaseColormap->Desaturate), 255) * 255 / 256; shadeConstants.simple_shade = (mBaseColormap->Color.d == 0x00ffffff && mBaseColormap->Fade.d == 0x00000000 && mBaseColormap->Desaturate == 0); } else diff --git a/src/rendering/swrenderer/viewport/r_spritedrawer.cpp b/src/rendering/swrenderer/viewport/r_spritedrawer.cpp index 316f6af91..442237852 100644 --- a/src/rendering/swrenderer/viewport/r_spritedrawer.cpp +++ b/src/rendering/swrenderer/viewport/r_spritedrawer.cpp @@ -70,8 +70,8 @@ namespace swrenderer iscale = -iscale; float vstepY = iscale / WallC.sz1 / (viewport->InvZtoScale / WallC.sz1); - int x1 = MAX(WallC.sx1, clipx1); - int x2 = MIN(WallC.sx2, clipx2); + int x1 = max(WallC.sx1, clipx1); + int x2 = min(WallC.sx2, clipx2); if (x1 >= x2) return; @@ -127,10 +127,10 @@ namespace swrenderer void SpriteDrawerArgs::DrawMasked2D(RenderThread* thread, double x0, double x1, double y0, double y1, FSoftwareTexture* tex, FRenderStyle style) { - int sx0 = MAX((int)x0, 0); - int sx1 = MIN((int)x1, viewwidth); - int sy0 = MAX((int)y0, 0); - int sy1 = MIN((int)y1, viewheight); + int sx0 = max((int)x0, 0); + int sx1 = min((int)x1, viewwidth); + int sy0 = max((int)y0, 0); + int sy1 = min((int)y1, viewheight); if (sx0 >= sx1 || sy0 >= sy1) return; @@ -169,9 +169,9 @@ namespace swrenderer { double xmagnitude = fabs(static_cast(texelStepX)* (1.0 / 0x1'0000'0000LL)); double ymagnitude = fabs(static_cast(texelStepY)* (1.0 / 0x1'0000'0000LL)); - double magnitude = MAX(ymagnitude, xmagnitude); + double magnitude = max(ymagnitude, xmagnitude); double min_lod = -1000.0; - double lod = MAX(log2(magnitude) + r_lod_bias, min_lod); + double lod = max(log2(magnitude) + r_lod_bias, min_lod); bool magnifying = lod < 0.0f; int mipmap_offset = 0; @@ -184,8 +184,8 @@ namespace swrenderer { mipmap_offset += mip_width * mip_height; level--; - mip_width = MAX(mip_width >> 1, 1); - mip_height = MAX(mip_height >> 1, 1); + mip_width = max(mip_width >> 1, 1); + mip_height = max(mip_height >> 1, 1); } } @@ -195,7 +195,7 @@ namespace swrenderer bool filter_nearest = (magnifying && !r_magfilter) || (!magnifying && !r_minfilter); if (filter_nearest) { - xoffset = MAX(MIN(xoffset, (mip_width << FRACBITS) - 1), 0); + xoffset = max(min(xoffset, (mip_width << FRACBITS) - 1), 0); int tx = xoffset >> FRACBITS; dc_source = (uint8_t*)(pixels + tx * mip_height); @@ -205,10 +205,10 @@ namespace swrenderer } else { - xoffset = MAX(MIN(xoffset - (FRACUNIT / 2), (mip_width << FRACBITS) - 1), 0); + xoffset = max(min(xoffset - (FRACUNIT / 2), (mip_width << FRACBITS) - 1), 0); int tx0 = xoffset >> FRACBITS; - int tx1 = MIN(tx0 + 1, mip_width - 1); + int tx1 = min(tx0 + 1, mip_width - 1); dc_source = (uint8_t*)(pixels + tx0 * mip_height); dc_source2 = (uint8_t*)(pixels + tx1 * mip_height); dc_textureheight = mip_height; @@ -282,12 +282,12 @@ namespace swrenderer dc_yl--; fixed_t maxfrac = ((top + length) << FRACBITS) - 1; - dc_texturefrac = MAX(dc_texturefrac, 0); - dc_texturefrac = MIN(dc_texturefrac, maxfrac); + dc_texturefrac = max(dc_texturefrac, 0); + dc_texturefrac = min(dc_texturefrac, maxfrac); if (dc_iscale > 0) - dc_count = MIN(dc_count, (maxfrac - dc_texturefrac + dc_iscale - 1) / dc_iscale); + dc_count = min(dc_count, (maxfrac - dc_texturefrac + dc_iscale - 1) / dc_iscale); else if (dc_iscale < 0) - dc_count = MIN(dc_count, (dc_texturefrac - dc_iscale) / (-dc_iscale)); + dc_count = min(dc_count, (dc_texturefrac - dc_iscale) / (-dc_iscale)); (thread->Drawers(dc_viewport)->*colfunc)(*this); }