From 1cb4677b8da42124d59e6c295e42d22f5b2fbe51 Mon Sep 17 00:00:00 2001 From: William Lew Date: Thu, 24 Mar 2022 12:24:08 -0700 Subject: [PATCH 1/3] Added separate caches for each LOD Signed-off-by: William Lew --- gazebo/rendering/Heightmap.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gazebo/rendering/Heightmap.cc b/gazebo/rendering/Heightmap.cc index dc1b913e8e..f48b6f6020 100644 --- a/gazebo/rendering/Heightmap.cc +++ b/gazebo/rendering/Heightmap.cc @@ -523,7 +523,9 @@ void Heightmap::Load() { this->dataPtr->splitTerrain = true; nTerrains = this->dataPtr->numTerrainSubdivisions; - prefix = terrainDirPath / "gazebo_terrain_cache"; + std::string terrainName = "gazebo_terrain_cache" + + std::to_string(this->LOD()); + prefix = terrainDirPath / terrainName.c_str(); } else { @@ -542,7 +544,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_" + std::to_string(this->LOD()); + prefix = terrainDirPath / terrainName.c_str(); } double sqrtN = sqrt(nTerrains); From 70024270035c08ae3f605552a078ca668cd83e59 Mon Sep 17 00:00:00 2001 From: William Lew Date: Thu, 24 Mar 2022 14:56:52 -0700 Subject: [PATCH 2/3] Added code suggestions Signed-off-by: William Lew --- gazebo/rendering/Heightmap.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gazebo/rendering/Heightmap.cc b/gazebo/rendering/Heightmap.cc index f48b6f6020..dc69ad077f 100644 --- a/gazebo/rendering/Heightmap.cc +++ b/gazebo/rendering/Heightmap.cc @@ -518,13 +518,19 @@ 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; std::string terrainName = "gazebo_terrain_cache" + - std::to_string(this->LOD()); + terrainNameSuffix; prefix = terrainDirPath / terrainName.c_str(); } else @@ -544,7 +550,7 @@ void Heightmap::Load() gzmsg << "Large heightmap used with LOD. It will be subdivided into " << this->dataPtr->numTerrainSubdivisions << " terrains." << std::endl; } - std::string terrainName = "gazebo_terrain_" + std::to_string(this->LOD()); + std::string terrainName = "gazebo_terrain_" + terrainNameSuffix; prefix = terrainDirPath / terrainName.c_str(); } From 63056658be94bccf37d901f2f2ca4cb21587fda0 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Fri, 25 Mar 2022 12:11:53 -0700 Subject: [PATCH 3/3] Fix HeightmapCache test Signed-off-by: Steve Peters --- gazebo/rendering/Heightmap.cc | 2 +- test/integration/heightmap.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gazebo/rendering/Heightmap.cc b/gazebo/rendering/Heightmap.cc index dc69ad077f..4ef300709a 100644 --- a/gazebo/rendering/Heightmap.cc +++ b/gazebo/rendering/Heightmap.cc @@ -550,7 +550,7 @@ void Heightmap::Load() gzmsg << "Large heightmap used with LOD. It will be subdivided into " << this->dataPtr->numTerrainSubdivisions << " terrains." << std::endl; } - std::string terrainName = "gazebo_terrain_" + terrainNameSuffix; + std::string terrainName = "gazebo_terrain" + terrainNameSuffix; prefix = terrainDirPath / terrainName.c_str(); } diff --git a/test/integration/heightmap.cc b/test/integration/heightmap.cc index f5bbca7a53..202478550f 100644 --- a/test/integration/heightmap.cc +++ b/test/integration/heightmap.cc @@ -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";