mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-01 17:19:05 -06:00
Don't load all Histograms at startup for KameleonPlane
This commit is contained in:
@@ -30,11 +30,11 @@ function postInitialization()
|
||||
|
||||
openspace.printInfo("Done setting default values")
|
||||
|
||||
--openspace.iswa.addCygnet(0,"z", "Kameleon");
|
||||
openspace.iswa.addCygnet(0,"z", "Kameleon");
|
||||
--openspace.iswa.addCygnet(0,"y", "Kameleon");
|
||||
--openspace.iswa.addCygnet(0,"x", "Kameleon");
|
||||
|
||||
openspace.iswa.addCygnet(-4,"Data");
|
||||
--openspace.iswa.addCygnet(-4,"Data");
|
||||
|
||||
--openspace.iswa.addCygnet(-1,"Data");
|
||||
--openspace.iswa.addCygnet(-2,"Data");
|
||||
|
||||
@@ -38,6 +38,7 @@ IswaCygnet::IswaCygnet(const ghoul::Dictionary& dictionary)
|
||||
, _shader(nullptr)
|
||||
,_type(IswaManager::CygnetType::NoType)
|
||||
,_group(nullptr)
|
||||
,_textureDirty(false)
|
||||
{
|
||||
_data = std::make_shared<Metadata>();
|
||||
|
||||
@@ -119,7 +120,6 @@ bool IswaCygnet::initialize(){
|
||||
createShader();
|
||||
updateTexture();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -190,8 +190,10 @@ void IswaCygnet::update(const UpdateData& data){
|
||||
}
|
||||
|
||||
if(_futureObject.valid() && DownloadManager::futureReady(_futureObject)) {
|
||||
loadTexture();
|
||||
_textureDirty = true;
|
||||
}
|
||||
|
||||
if(_textureDirty) loadTexture();
|
||||
|
||||
if(!_transferFunctions.empty())
|
||||
for(auto tf : _transferFunctions)
|
||||
|
||||
@@ -128,6 +128,7 @@ protected:
|
||||
std::shared_ptr<IswaGroup> _group;
|
||||
|
||||
IswaManager::CygnetType _type;
|
||||
bool _textureDirty;
|
||||
};
|
||||
|
||||
}//namespace openspace
|
||||
|
||||
@@ -116,8 +116,12 @@ KameleonPlane::~KameleonPlane(){
|
||||
}
|
||||
|
||||
bool KameleonPlane::initialize(){
|
||||
_kw = std::make_shared<KameleonWrapper>(absPath(_kwPath));
|
||||
|
||||
// IswaCygnet::initialize();
|
||||
_textures.push_back(nullptr);
|
||||
|
||||
|
||||
if(!_data->groupName.empty()){
|
||||
_group = IswaManager::ref().registerToGroup(_data->groupName, _type, this);
|
||||
std::cout << "Register group " << (_group != nullptr) << std::endl;
|
||||
@@ -169,6 +173,7 @@ bool KameleonPlane::initialize(){
|
||||
});
|
||||
|
||||
_resolution.onChange([this](){
|
||||
|
||||
_dataProcessor->clear();
|
||||
updateTexture();
|
||||
});
|
||||
@@ -177,7 +182,11 @@ bool KameleonPlane::initialize(){
|
||||
updateTexture();
|
||||
});
|
||||
|
||||
fillOptions();
|
||||
|
||||
|
||||
updateTexture();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -189,13 +198,9 @@ void KameleonPlane::transferFunctionsFile(std::string tfPath){ _transferFunction
|
||||
void KameleonPlane::backgroundValues(glm::vec2 backgroundValues){ _backgroundValues.setValue(backgroundValues); };
|
||||
|
||||
bool KameleonPlane::loadTexture() {
|
||||
ghoul::opengl::Texture::FilterMode filtermode = ghoul::opengl::Texture::FilterMode::Linear;
|
||||
ghoul::opengl::Texture::WrappingMode wrappingmode = ghoul::opengl::Texture::WrappingMode::ClampToEdge;
|
||||
|
||||
std::vector<int> selectedOptions = _dataOptions.value();
|
||||
auto options = _dataOptions.options();
|
||||
float zSlice = 0.5f;
|
||||
|
||||
|
||||
for(int option : selectedOptions){
|
||||
if(!_dataSlices[option]){
|
||||
|
||||
@@ -205,7 +210,8 @@ bool KameleonPlane::loadTexture() {
|
||||
getline(memorystream, optionName, '/');
|
||||
// std::cout << options[option].description << std::endl;
|
||||
_dataSlices[option] = _kw->getUniformSliceValues(optionName, _dimensions, _slice.value());
|
||||
// _dataProcessor->addValuesFromKameleonData(_dataSlices[option], _dimensions, options.size(), option);
|
||||
if(!_textures[option])
|
||||
_dataProcessor->addValuesFromKameleonData(_dataSlices[option], _dimensions, options.size(), option);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,10 +222,7 @@ bool KameleonPlane::loadTexture() {
|
||||
|
||||
_backgroundValues.setValue(_dataProcessor->filterValues());
|
||||
|
||||
// std::cout << std::to_string(_backgroundValues.value()) << std::endl;
|
||||
|
||||
bool texturesReady = false;
|
||||
|
||||
for(int option: selectedOptions){
|
||||
float* values = data[option];
|
||||
if(!values) continue;
|
||||
@@ -251,11 +254,6 @@ bool KameleonPlane::loadTexture() {
|
||||
}
|
||||
|
||||
bool KameleonPlane::updateTexture(){
|
||||
|
||||
if(!_kw){
|
||||
_kw = std::make_shared<KameleonWrapper>(absPath(_kwPath));
|
||||
}
|
||||
|
||||
_dimensions = glm::size3_t(_resolution.value()*100);
|
||||
if(_data->scale.x == 0){
|
||||
_dimensions.x = 1;
|
||||
@@ -278,26 +276,6 @@ bool KameleonPlane::updateTexture(){
|
||||
_data->offset.z = _data->gridMin.z+_slice.value()*_scale;
|
||||
}
|
||||
|
||||
if(!_dataOptions.options().size()){
|
||||
fillOptions();
|
||||
|
||||
auto options = _dataOptions.options();
|
||||
for(auto option : options){
|
||||
std::stringstream memorystream(option.description);
|
||||
std::string optionName;
|
||||
getline(memorystream, optionName, '/');
|
||||
getline(memorystream, optionName, '/');
|
||||
float* data = _kw->getUniformSliceValues(optionName, _dimensions, _slice.value());
|
||||
_dataProcessor->addValuesFromKameleonData(data, _dimensions, options.size(), option.value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// std::cout << "Dimensions: " << _dimensions.x << " " << _dimensions.y << " " << _dimensions.z << std::endl;
|
||||
// std::cout << "Offset: " << std::to_string(_data->offset) << std::endl;
|
||||
// std::cout << _slice << std::endl;
|
||||
|
||||
for(int i=0; i<_dataSlices.size(); ++i){
|
||||
float* slice = _dataSlices[i];
|
||||
if(slice){
|
||||
@@ -306,15 +284,12 @@ bool KameleonPlane::updateTexture(){
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i<_textures.size(); ++i){
|
||||
_textures[i] = std::move(nullptr);
|
||||
}
|
||||
|
||||
loadTexture();
|
||||
_textureDirty = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool KameleonPlane::readyToRender(){
|
||||
return (!_textures.empty() && !_transferFunctions.empty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user