Skip to content

Commit

Permalink
Allow underwater units to have LoS and set it to originate in water h…
Browse files Browse the repository at this point in the history
…eight

It allows underwater units to see ground units but it seems like it's the lesser of two evils with the current LoS system.
  • Loading branch information
ashdnazg committed Jan 26, 2017
1 parent bc2c029 commit 9fb8b24
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 1 addition & 1 deletion rts/Sim/Misc/LosHandler.cpp
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions rts/Sim/Misc/LosMap.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 9fb8b24

Please sign in to comment.