Add Map::FindClosestLoS()

This will return true if LOS failed and you should use the outloc
This commit is contained in:
Michael Cook (mackal) 2018-03-06 23:02:49 -05:00
parent b3ac1001c9
commit 7e7f5f0bd6
2 changed files with 9 additions and 0 deletions

View File

@ -268,6 +268,14 @@ bool Map::CheckLoS(glm::vec3 myloc, glm::vec3 oloc) const {
return !imp->rm->raycast((const RmReal*)&myloc, (const RmReal*)&oloc, nullptr, nullptr, nullptr);
}
// returns true if outloc should be used
bool Map::FindClosestLoS(glm::vec3 myloc, glm::vec3 oloc, glm::vec3 &outloc) const {
if(!imp)
return false;
return imp->rm->raycast((const RmReal*)&myloc, (const RmReal*)&oloc, (RmReal *)&outloc, nullptr, nullptr);
}
inline bool file_exists(const std::string& name) {
std::ifstream f(name.c_str());
return f.good();

View File

@ -42,6 +42,7 @@ public:
bool LineIntersectsZone(glm::vec3 start, glm::vec3 end, float step, glm::vec3 *result) const;
bool LineIntersectsZoneNoZLeaps(glm::vec3 start, glm::vec3 end, float step_mag, glm::vec3 *result) const;
bool CheckLoS(glm::vec3 myloc, glm::vec3 oloc) const;
bool FindClosestLoS(glm::vec3 myloc, glm::vec3 oloc, glm::vec3 &outloc) const;
#ifdef USE_MAP_MMFS
bool Load(std::string filename, bool force_mmf_overwrite = false);