From 9fb8b24bbaf0a1d8904b45d8d22422a12fd07eb7 Mon Sep 17 00:00:00 2001 From: Eshed Date: Thu, 26 Jan 2017 13:38:15 +0200 Subject: [PATCH] Allow underwater units to have LoS and set it to originate in water height It allows underwater units to see ground units but it seems like it's the lesser of two evils with the current LoS system. --- rts/Sim/Misc/LosHandler.cpp | 2 +- rts/Sim/Misc/LosMap.cpp | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/rts/Sim/Misc/LosHandler.cpp b/rts/Sim/Misc/LosHandler.cpp index 0d8e9afb1de..3020eeeb428 100644 --- a/rts/Sim/Misc/LosHandler.cpp +++ b/rts/Sim/Misc/LosHandler.cpp @@ -112,7 +112,7 @@ float ILosType::GetHeight(const CUnit* unit) const return 0.f; } const float emitHeight = (type == LOS_TYPE_LOS || type == LOS_TYPE_AIRLOS) ? unit->unitDef->losHeight : unit->unitDef->radarHeight; - const float losHeight = unit->midPos.y + emitHeight; + const float losHeight = std::max(unit->midPos.y + emitHeight, 0.0f); const int bucketSize = 1 << (mipLevel + 2); const float iLosHeight = (int(losHeight) / bucketSize + 0.5f) * bucketSize; // save losHeight in buckets return iLosHeight; diff --git a/rts/Sim/Misc/LosMap.cpp b/rts/Sim/Misc/LosMap.cpp index 373c08ac595..945c02823e8 100644 --- a/rts/Sim/Misc/LosMap.cpp +++ b/rts/Sim/Misc/LosMap.cpp @@ -475,10 +475,6 @@ void CLosMap::LosAdd(SLosInstance* li) const return ipos.y * mapDims.mapx + ipos.x; }; - // skip when unit is underground/underwater - if (li->baseHeight < 0.0f) - return; - const float* heightmapFull = readMap->GetCenterHeightMapSynced(); if (SRectangle(0,0,size.x,size.y).Inside(li->basePos) && li->baseHeight <= heightmapFull[MAP_SQUARE_FULLRES(li->basePos)]) return;