Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[12817] Improve GetHeightInRange, now we handle the case of two near …
…value of vmap and map height in better way.
- Loading branch information
Cyberium
committed
Jan 17, 2015
1 parent
fdc35fb
commit 5376545
Showing
2 changed files
with
35 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2027,28 +2027,52 @@ bool Map::GetHitPosition(float srcX, float srcY, float srcZ, float& destX, float | |
// Find an height within a reasonable range of provided Z. This method may fail so we have to handle that case. | ||
bool Map::GetHeightInRange(uint32 phasemask, float x, float y, float &z, float maxSearchDist /*= 4.0f*/) const | ||
{ | ||
float height; | ||
float height, vmapHeight, mapHeight; | ||
vmapHeight = VMAP_INVALID_HEIGHT_VALUE; | ||
|
||
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager(); | ||
if (!vmgr->isLineOfSightCalcEnabled()) | ||
vmgr = NULL; | ||
|
||
if (vmgr) | ||
{ | ||
height = VMAP_INVALID_HEIGHT_VALUE; | ||
|
||
// pure vmap search | ||
height = vmgr->getHeight(i_id, x, y, z + 1.0f, maxSearchDist); | ||
vmapHeight = vmgr->getHeight(i_id, x, y, z + 2.0f, maxSearchDist + 2.0f); | ||
} | ||
|
||
if (height < INVALID_HEIGHT || fabs(fabs(z) - fabs(height)) > maxSearchDist) | ||
// find raw height from .map file on X,Y coordinates | ||
if (GridMap* gmap = const_cast<TerrainInfo*>(m_TerrainData)->GetGrid(x, y)) // TODO:: find a way to remove that const_cast | ||
mapHeight = gmap->getHeight(x, y); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
evil-at-wow
Contributor
|
||
|
||
float diffMaps = fabs(fabs(z) - fabs(mapHeight)); | ||
float diffVmaps = fabs(fabs(z) - fabs(vmapHeight)); | ||
if (diffVmaps < maxSearchDist) | ||
{ | ||
// find raw height from .map file on X,Y coordinates | ||
if (GridMap* gmap = const_cast<TerrainInfo*>(m_TerrainData)->GetGrid(x, y)) // TODO:: find a way to remove that const_cast | ||
height = gmap->getHeight(x, y); | ||
if (diffMaps < maxSearchDist) | ||
{ | ||
// here we often have to take vmap value but sometime we have to take map value. | ||
if (vmapHeight > mapHeight || diffMaps > diffVmaps) | ||
height = vmapHeight; | ||
else | ||
height = mapHeight; | ||
|
||
if (fabs(fabs(z) - fabs(height)) > maxSearchDist) | ||
return false; // not found any good height | ||
//sLog.outString("vmap %5.4f, map %5.4f, height %5.4f", vmapHeight, mapHeight, height); | ||
} | ||
else | ||
{ | ||
//sLog.outString("vmap %5.4f", vmapHeight); | ||
height = vmapHeight; | ||
} | ||
} | ||
else | ||
{ | ||
if (diffMaps < maxSearchDist) | ||
{ | ||
//sLog.outString("map %5.4f", mapHeight); | ||
height = mapHeight; | ||
} | ||
else | ||
return false; | ||
} | ||
|
||
z = std::max<float>(height, m_dyn_tree.getHeight(x, y, height + 1.0f, maxSearchDist, phasemask)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#ifndef __REVISION_NR_H__ | ||
#define __REVISION_NR_H__ | ||
#define REVISION_NR "12816" | ||
#define REVISION_NR "12817" | ||
#endif // __REVISION_NR_H__ |
mapHeight
can be uninitialized if that check is not valid