Skip to content

Commit

Permalink
Separate cache files for each heightmap LOD (#3200)
Browse files Browse the repository at this point in the history
* Added separate caches for LOD0

Signed-off-by: William Lew <WilliamMilesLew@gmail.com>

* Fix HeightmapCache test

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Co-authored-by: Steve Peters <scpeters@openrobotics.org>
  • Loading branch information
WilliamLewww and scpeters authored Mar 28, 2022
1 parent 9747cc1 commit 212fae8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions gazebo/rendering/Heightmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,20 @@ void Heightmap::Load()
}
}

std::string terrainNameSuffix = "";
if (this->LOD() == 0)
{
terrainNameSuffix = "_LOD0";
}

// If the paging is enabled we modify the number of subterrains
if (this->dataPtr->useTerrainPaging)
{
this->dataPtr->splitTerrain = true;
nTerrains = this->dataPtr->numTerrainSubdivisions;
prefix = terrainDirPath / "gazebo_terrain_cache";
std::string terrainName = "gazebo_terrain_cache" +
terrainNameSuffix;
prefix = terrainDirPath / terrainName.c_str();
}
else
{
Expand All @@ -542,7 +550,8 @@ void Heightmap::Load()
gzmsg << "Large heightmap used with LOD. It will be subdivided into " <<
this->dataPtr->numTerrainSubdivisions << " terrains." << std::endl;
}
prefix = terrainDirPath / "gazebo_terrain";
std::string terrainName = "gazebo_terrain" + terrainNameSuffix;
prefix = terrainDirPath / terrainName.c_str();
}

double sqrtN = sqrt(nTerrains);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/heightmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ void HeightmapTest::HeightmapCache()
+ "/paging");
std::string shaPath = heightmapDir + "/" + heightmapName + "/gzterrain.SHA1";
std::string cachePath = heightmapDir +
"/" + heightmapName + "/gazebo_terrain_00000000.dat";
"/" + heightmapName + "/gazebo_terrain_LOD0_00000000.dat";

// temporary backup files for testing if cache files exist.
std::string shaPathBk = shaPath + ".bk";
Expand Down

0 comments on commit 212fae8

Please sign in to comment.