From 10929485184a8e4d30bf8bf6f24b353b921edcb2 Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Thu, 2 May 2024 11:08:59 +0200 Subject: [PATCH] Make `useCaching` for point cloud also affect color map Makes it so that changes can be done to the color map file without having to delete the cache, and decreases confusion about that one file is cached when the other isn't --- include/openspace/rendering/colormappingcomponent.h | 3 ++- .../rendering/pointcloud/renderablepointcloud.cpp | 13 +++++++------ src/rendering/colormappingcomponent.cpp | 11 +++++++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/include/openspace/rendering/colormappingcomponent.h b/include/openspace/rendering/colormappingcomponent.h index fb7881819e..f2e904cead 100644 --- a/include/openspace/rendering/colormappingcomponent.h +++ b/include/openspace/rendering/colormappingcomponent.h @@ -62,8 +62,9 @@ public: * Initialize the color map information (ranges, etc.) based on the input dataset. * * \param dataset The *loaded* input dataset + * \param useCaching Whether caching should be used when loading the color map file */ - void initialize(const dataloader::Dataset& dataset); + void initialize(const dataloader::Dataset& dataset, bool useCaching = true); /** * Initialize a 1D texture based on the entries in the color map file. diff --git a/modules/base/rendering/pointcloud/renderablepointcloud.cpp b/modules/base/rendering/pointcloud/renderablepointcloud.cpp index d15a2486a5..2577fca49c 100644 --- a/modules/base/rendering/pointcloud/renderablepointcloud.cpp +++ b/modules/base/rendering/pointcloud/renderablepointcloud.cpp @@ -362,11 +362,12 @@ namespace { // rendered. Can be either a CSV or SPECK file std::optional file; - // If true (default), the loaded dataset will be cached so that it can be loaded - // faster at a later time. This does however mean that any updates to the values - // in the dataset will not lead to changes in the rendering without first removing - // the cached file. Set it to false to disable caching. This can be useful for - // example when working on importing a new dataset + // If true (default), the loaded dataset and color map will be cached so that they + // can be loaded faster at a later time. This does however mean that any updates + // to the values in the dataset will not lead to changes in the rendering without + // first removing the cached file. Set it to false to disable caching. This can be + // useful for example when working on importing a new dataset or when making + // changes to the color map. std::optional useCaching; // A dictionary specifying details on how to load the dataset. Updating the data @@ -871,7 +872,7 @@ void RenderablePointCloud::initialize() { } if (_hasDataFile && _hasColorMapFile) { - _colorSettings.colorMapping->initialize(_dataset); + _colorSettings.colorMapping->initialize(_dataset, _useCaching); } if (_hasLabels) { diff --git a/src/rendering/colormappingcomponent.cpp b/src/rendering/colormappingcomponent.cpp index e3bc535ac2..7850452988 100644 --- a/src/rendering/colormappingcomponent.cpp +++ b/src/rendering/colormappingcomponent.cpp @@ -329,10 +329,17 @@ ghoul::opengl::Texture* ColorMappingComponent::texture() const { return _texture.get(); } -void ColorMappingComponent::initialize(const dataloader::Dataset& dataset) { +void ColorMappingComponent::initialize(const dataloader::Dataset& dataset, + bool useCaching) +{ ZoneScoped; - _colorMap = dataloader::color::loadFileWithCache(colorMapFile.value()); + if (useCaching) { + _colorMap = dataloader::color::loadFileWithCache(colorMapFile.value()); + } + else { + _colorMap = dataloader::color::loadFile(colorMapFile.value()); + } initializeParameterData(dataset);