diff options
Diffstat (limited to 'src/render/WaterLevel.cpp')
-rw-r--r-- | src/render/WaterLevel.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp index 6247c611..759a3595 100644 --- a/src/render/WaterLevel.cpp +++ b/src/render/WaterLevel.cpp @@ -73,7 +73,7 @@ RwRaster *gpWaterEnvBaseRaster; RwRaster *gpWaterWakeRaster; bool _bSeaLife; -float _fWaterZOffset = 0.5f; +float _fWaterZOffset = WATER_Z_OFFSET; #ifdef PC_WATER float fEnvScale = 0.25f; @@ -318,6 +318,7 @@ CWaterLevel::Shutdown() _DELETE_TEXTURE(gpWaterTex); _DELETE_TEXTURE(gpWaterEnvTex); + _DELETE_TEXTURE(gpWaterWakeTex); _DELETE_TEXTURE(gpWaterEnvBaseTex); #undef _DELETE_TEXTURE @@ -610,14 +611,14 @@ CWaterLevel::TestVisibilityForFineWaterBlocks(const CVector &worldPos) if ((lineEnd.x > WORLD_MIN_X && lineEnd.x < WORLD_MAX_X) && (lineEnd.y > WORLD_MIN_Y && lineEnd.y < WORLD_MAX_Y)) { - if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false, nil)) + if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false)) { lineStart.x += 0.4f; lineStart.y += 0.4f; lineEnd.x += 0.4f; lineEnd.y += 0.4f; - if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false, nil)) + if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false)) { return false; } @@ -714,9 +715,9 @@ CWaterLevel::GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool if ( y < 0 || y >= MAX_SMALL_SECTORS ) return false; #endif - uint8 nBlock = aWaterFineBlockList[x][y]; + int8 nBlock = aWaterFineBlockList[x][y]; - if ( nBlock == 0x80 ) + if ( nBlock == NO_WATER ) return false; ASSERT( pfOutLevel != nil ); @@ -756,9 +757,9 @@ CWaterLevel::GetWaterLevelNoWaves(float fX, float fY, float fZ, float *pfOutLeve if ( y < 0 || y >= MAX_SMALL_SECTORS ) return false; #endif - uint8 nBlock = aWaterFineBlockList[x][y]; + int8 nBlock = aWaterFineBlockList[x][y]; - if ( nBlock == 0x80 ) + if ( nBlock == NO_WATER ) return false; ASSERT( pfOutLevel != nil ); @@ -1013,7 +1014,7 @@ CWaterLevel::RenderWater() if ( fHugeSectorMaxRenderDistSqr > fHugeSectorDistToCamSqr ) { - if ( TheCamera.IsSphereVisible(CVector(vecHugeSectorCentre.x, vecHugeSectorCentre.y, 0.0f), SectorRadius(HUGE_SECTOR_SIZE), &TheCamera.GetCameraMatrix()) ) + if ( TheCamera.IsSphereVisible(CVector(vecHugeSectorCentre.x, vecHugeSectorCentre.y, 0.0f), SectorRadius(HUGE_SECTOR_SIZE)) ) { #ifndef PC_WATER WavesCalculatedThisFrame = true; @@ -1076,7 +1077,7 @@ CWaterLevel::RenderWater() { for ( int32 y = 0; y < 5; y++ ) { - float fX = WATER_SIGN_X(float(x) * EXTRAHUGE_SECTOR_SIZE) - 1280.0f - 400.0f; + float fX = WATER_SIGN_X(float(x) * EXTRAHUGE_SECTOR_SIZE) - 1280.0f - WATER_X_OFFSET; float fY = WATER_SIGN_Y(float(y) * EXTRAHUGE_SECTOR_SIZE) - 1280.0f; if ( !bUseCamStartY ) @@ -1087,7 +1088,7 @@ CWaterLevel::RenderWater() if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr ) { - if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE), &TheCamera.GetCameraMatrix()) ) + if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE)) ) { RenderOneFlatExtraHugeWaterPoly( vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2, @@ -1106,7 +1107,7 @@ CWaterLevel::RenderWater() if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr ) { - if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE), &TheCamera.GetCameraMatrix()) ) + if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE)) ) { RenderOneFlatExtraHugeWaterPoly( vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2, @@ -1135,7 +1136,7 @@ CWaterLevel::RenderWater() if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr ) { - if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE), &TheCamera.GetCameraMatrix()) ) + if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE)) ) { RenderOneFlatExtraHugeWaterPoly( vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2, @@ -1154,7 +1155,7 @@ CWaterLevel::RenderWater() if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr ) { - if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.x, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE), &TheCamera.GetCameraMatrix()) ) + if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.x, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE)) ) { RenderOneFlatExtraHugeWaterPoly( vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2, @@ -1201,6 +1202,8 @@ CWaterLevel::RenderTransparentWater(void) if ( !CGame::CanSeeWaterFromCurrArea() ) return; + PUSH_RENDERGROUP("CWaterLevel::RenderTransparentWater"); + float fWaterDrawDist = _GetWavyDrawDist(); float fWaterDrawDistLarge = fWaterDrawDist + 90.0f; float fWavySectorMaxRenderDistSqr = SQR(fWaterDrawDist); @@ -1284,7 +1287,7 @@ CWaterLevel::RenderTransparentWater(void) if ( fHugeSectorMaxRenderDistSqr > fHugeSectorDistToCamSqr ) { - if ( TheCamera.IsSphereVisible(CVector(vecHugeSectorCentre.x, vecHugeSectorCentre.y, 0.0f), SectorRadius(HUGE_SECTOR_SIZE), &TheCamera.GetCameraMatrix()) ) + if ( TheCamera.IsSphereVisible(CVector(vecHugeSectorCentre.x, vecHugeSectorCentre.y, 0.0f), SectorRadius(HUGE_SECTOR_SIZE)) ) { if ( fHugeSectorDistToCamSqr >= SQR(500.0f) ) { @@ -1308,7 +1311,7 @@ CWaterLevel::RenderTransparentWater(void) if ( fLargeSectorDistToCamSqr < fHugeSectorMaxRenderDistSqr ) { - if ( TheCamera.IsSphereVisible(CVector(vecLargeSectorCentre.x, vecLargeSectorCentre.y, 0.0f), SectorRadius(LARGE_SECTOR_SIZE), &TheCamera.GetCameraMatrix()) ) + if ( TheCamera.IsSphereVisible(CVector(vecLargeSectorCentre.x, vecLargeSectorCentre.y, 0.0f), SectorRadius(LARGE_SECTOR_SIZE)) ) { // Render four small(32x32) sectors, or one large(64x64). @@ -1462,7 +1465,7 @@ CWaterLevel::RenderTransparentWater(void) int32 nBlock; - int32 BlockX = WATER_TO_SMALL_SECTOR_X(fCamX + 400.0f) + 1; + int32 BlockX = WATER_TO_SMALL_SECTOR_X(fCamX + WATER_X_OFFSET) + 1; int32 BlockY = WATER_TO_SMALL_SECTOR_Y(fCamY) + 1; if (_IsColideWithBlock(BlockX, BlockY, nBlock)) @@ -1472,7 +1475,7 @@ CWaterLevel::RenderTransparentWater(void) float fMaskX = Floor(fCamX / 2.0f) * 2.0f; float fMaskY = Floor(fCamY / 2.0f) * 2.0f; float fWaterZ = CWaterLevel::ms_aWaterZs[nBlock]; - float fSectorX = WATER_FROM_SMALL_SECTOR_X(BlockX) - 400.0f; + float fSectorX = WATER_FROM_SMALL_SECTOR_X(BlockX) - WATER_X_OFFSET; float fSectorY = WATER_FROM_SMALL_SECTOR_Y(BlockY); RenderWavyMask(fMaskX, fMaskY, fWaterZ, @@ -1484,6 +1487,8 @@ CWaterLevel::RenderTransparentWater(void) DefinedState(); #endif + + POP_RENDERGROUP(); } void CWaterLevel::RenderOneFlatSmallWaterPoly(float fX, float fY, float fZ, RwRGBA const &color) @@ -3193,7 +3198,7 @@ CWaterLevel::HandleBeachToysStuff(void) vecPos.x += (fCos - fSin) * fAngle; vecPos.y += (fSin + fCos) * fAngle; - if ( TheCamera.IsSphereVisible(vecPos, 1.0f, &TheCamera.GetCameraMatrix()) ) + if ( TheCamera.IsSphereVisible(vecPos, 1.0f) ) { float fWaterLevel; @@ -3237,7 +3242,7 @@ CWaterLevel::HandleBeachToysStuff(void) vecPos.x += (fCos - fSin) * fAngle; vecPos.y += (fSin + fCos) * fAngle; - if ( TheCamera.IsSphereVisible(vecPos, 2.0f, &TheCamera.GetCameraMatrix()) ) + if ( TheCamera.IsSphereVisible(vecPos, 2.0f) ) { float fWaterLevel; |