diff options
author | eray orçunus <erayorcunus@gmail.com> | 2020-08-24 21:36:03 +0200 |
---|---|---|
committer | eray orçunus <erayorcunus@gmail.com> | 2020-08-24 21:36:03 +0200 |
commit | cb813bd1abdf7758a7893c354de6d9f81291c6cf (patch) | |
tree | 7639d3175c889f0e2469308d62e3d25ae6f32b4b /src/render | |
parent | Revert "remove CFO" (diff) | |
parent | small fix (diff) | |
download | re3-cb813bd1abdf7758a7893c354de6d9f81291c6cf.tar re3-cb813bd1abdf7758a7893c354de6d9f81291c6cf.tar.gz re3-cb813bd1abdf7758a7893c354de6d9f81291c6cf.tar.bz2 re3-cb813bd1abdf7758a7893c354de6d9f81291c6cf.tar.lz re3-cb813bd1abdf7758a7893c354de6d9f81291c6cf.tar.xz re3-cb813bd1abdf7758a7893c354de6d9f81291c6cf.tar.zst re3-cb813bd1abdf7758a7893c354de6d9f81291c6cf.zip |
Diffstat (limited to '')
-rw-r--r-- | src/render/Renderer.cpp | 83 | ||||
-rw-r--r-- | src/render/Weather.cpp | 12 |
2 files changed, 48 insertions, 47 deletions
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 8a93ee70..7a688ce8 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -825,6 +825,12 @@ CalcNewDelta(RwV2d *a, RwV2d *b) return (b->x - a->x) / (b->y - a->y); } +#ifdef FIX_BUGS +#define TOINT(x) ((int)Floor(x)) +#else +#define TOINT(x) ((int)(x)) +#endif + void CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrList *)) { @@ -850,13 +856,8 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL a2 = i; } } -#ifdef FIX_BUGS - y = Floor(miny); - yend = Floor(maxy); -#else - y = miny; - yend = maxy; -#endif + y = TOINT(miny); + yend = TOINT(maxy); // Go left in poly to find first edge b b2 = a2; @@ -864,8 +865,8 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL b1 = b2--; if(b2 < 0) b2 = numVertices-1; if(poly[b1].x < xstart) - xstart = poly[b1].x; - if((int)poly[b1].y != (int)poly[b2].y) + xstart = TOINT(poly[b1].x); + if(TOINT(poly[b1].y) != TOINT(poly[b2].y)) break; } // Go right to find first edge a @@ -873,8 +874,8 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL a1 = a2++; if(a2 == numVertices) a2 = 0; if(poly[a1].x > xend) - xend = poly[a1].x; - if((int)poly[a1].y != (int)poly[a2].y) + xend = TOINT(poly[a1].x); + if(TOINT(poly[a1].y) != TOINT(poly[a2].y)) break; } @@ -885,10 +886,10 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL xB = deltaB * (Ceil(poly[b1].y) - poly[b1].y) + poly[b1].x; if(y != yend){ - if(deltaB < 0.0f && (int)xB < xstart) - xstart = xB; - if(deltaA >= 0.0f && (int)xA > xend) - xend = xA; + if(deltaB < 0.0f && TOINT(xB) < xstart) + xstart = TOINT(xB); + if(deltaA >= 0.0f && TOINT(xA) > xend) + xend = TOINT(xA); } while(y <= yend && y < NUMSECTORS_Y){ @@ -904,74 +905,74 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL xB += deltaB; // update left side - if(y == (int)poly[b2].y){ + if(y == TOINT(poly[b2].y)){ // reached end of edge if(y == yend){ if(deltaB < 0.0f){ do{ - xstart = poly[b2--].x; + xstart = TOINT(poly[b2--].x); if(b2 < 0) b2 = numVertices-1; - }while(xstart > (int)poly[b2].x); + }while(xstart > TOINT(poly[b2].x)); }else - xstart = xB - deltaB; + xstart = TOINT(xB - deltaB); }else{ // switch edges if(deltaB < 0.0f) - xstart = poly[b2].x; + xstart = TOINT(poly[b2].x); else - xstart = xB - deltaB; + xstart = TOINT(xB - deltaB); do{ b1 = b2--; if(b2 < 0) b2 = numVertices-1; - if((int)poly[b1].x < xstart) - xstart = poly[b1].x; - }while(y == (int)poly[b2].y); + if(TOINT(poly[b1].x) < xstart) + xstart = TOINT(poly[b1].x); + }while(y == TOINT(poly[b2].y)); deltaB = CalcNewDelta(&poly[b1], &poly[b2]); xB = deltaB * (Ceil(poly[b1].y) - poly[b1].y) + poly[b1].x; - if(deltaB < 0.0f && (int)xB < xstart) - xstart = xB; + if(deltaB < 0.0f && TOINT(xB) < xstart) + xstart = TOINT(xB); } }else{ if(deltaB < 0.0f) - xstart = xB; + xstart = TOINT(xB); else - xstart = xB - deltaB; + xstart = TOINT(xB - deltaB); } // update right side - if(y == (int)poly[a2].y){ + if(y == TOINT(poly[a2].y)){ // reached end of edge if(y == yend){ if(deltaA < 0.0f) - xend = xA - deltaA; + xend = TOINT(xA - deltaA); else{ do{ - xend = poly[a2++].x; + xend = TOINT(poly[a2++].x); if(a2 == numVertices) a2 = 0; - }while(xend < (int)poly[a2].x); + }while(xend < TOINT(poly[a2].x)); } }else{ // switch edges if(deltaA < 0.0f) - xend = xA - deltaA; + xend = TOINT(xA - deltaA); else - xend = poly[a2].x; + xend = TOINT(poly[a2].x); do{ a1 = a2++; if(a2 == numVertices) a2 = 0; - if((int)poly[a1].x > xend) - xend = poly[a1].x; - }while(y == (int)poly[a2].y); + if(TOINT(poly[a1].x) > xend) + xend = TOINT(poly[a1].x); + }while(y == TOINT(poly[a2].y)); deltaA = CalcNewDelta(&poly[a1], &poly[a2]); xA = deltaA * (Ceil(poly[a1].y) - poly[a1].y) + poly[a1].x; - if(deltaA >= 0.0f && (int)xA > xend) - xend = xA; + if(deltaA >= 0.0f && TOINT(xA) > xend) + xend = TOINT(xA); } }else{ if(deltaA < 0.0f) - xend = xA - deltaA; + xend = TOINT(xA - deltaA); else - xend = xA; + xend = TOINT(xA); } } } diff --git a/src/render/Weather.cpp b/src/render/Weather.cpp index b4031705..2c0b27d2 100644 --- a/src/render/Weather.cpp +++ b/src/render/Weather.cpp @@ -69,7 +69,7 @@ const int16 WeatherTypesList[] = { WEATHER_SUNNY, WEATHER_SUNNY, WEATHER_RAINY, WEATHER_CLOUDY, }; -const float Windiness[] = { +const float Windyness[] = { 0.0f, // WEATHER_SUNNY 0.7f, // WEATHER_CLOUDY 1.0f, // WEATHER_RAINY @@ -243,7 +243,7 @@ void CWeather::Update(void) Rainbow = 1.0f - 4.0f * Abs(InterpolationValue - 0.25f) / 4.0f; else Rainbow = 0.0f; - Wind = InterpolationValue * Windiness[NewWeatherType] + (1.0f - InterpolationValue) * Windiness[OldWeatherType]; + Wind = InterpolationValue * Windyness[NewWeatherType] + (1.0f - InterpolationValue) * Windyness[OldWeatherType]; AddRain(); } @@ -278,8 +278,8 @@ void CWeather::AddRain() if (Rain <= 0.1f) return; static RwRGBA colour; - float screen_width = RsGlobal.width; - float screen_height = RsGlobal.height; + float screen_width = SCREEN_WIDTH; + float screen_height = SCREEN_HEIGHT; int cur_frame = (int)(3 * Rain) & 3; int num_drops = (int)(2 * Rain) + 2; static int STATIC_RAIN_ANGLE = -45; @@ -397,11 +397,11 @@ void RenderOneRainStreak(CVector pos, CVector unused, int intensity, bool scale, RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored + 0], 0, 0, 0, 0); RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 0], pos.x + 11.0f * TheCamera.GetUp().x, pos.y + 11.0f * TheCamera.GetUp().y, pos.z + 11.0f * TheCamera.GetUp().z); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored + 1], 0, 0, 0, 0); - RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 1], pos.x - 9.0f * TheCamera.GetRight().x, pos.y - 9.0f * TheCamera.GetRight().y, pos.z - 9.0f * TheCamera.GetUp().z); + RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 1], pos.x - 9.0f * TheCamera.GetRight().x, pos.y - 9.0f * TheCamera.GetRight().y, pos.z - 9.0f * TheCamera.GetRight().z); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored + 2], RAIN_COLOUR_R * intensity / 256, RAIN_COLOUR_G * intensity / 256, RAIN_COLOUR_B * intensity / 256, RAIN_ALPHA); RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 2], pos.x, pos.y, pos.z); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored + 3], 0, 0, 0, 0); - RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 3], pos.x + 9.0f * TheCamera.GetRight().x, pos.y + 9.0f * TheCamera.GetRight().y, pos.z + 9.0f * TheCamera.GetUp().z); + RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 3], pos.x + 9.0f * TheCamera.GetRight().x, pos.y + 9.0f * TheCamera.GetRight().y, pos.z + 9.0f * TheCamera.GetRight().z); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored + 4], 0, 0, 0, 0); RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 4], pos.x - 11.0f * TheCamera.GetUp().x, pos.y - 11.0f * TheCamera.GetUp().y, pos.z - 11.0f * TheCamera.GetUp().z); float u = STREAK_U; |