Small bug fixes

This commit is contained in:
Sebastian Piwell
2016-05-26 09:49:24 -04:00
parent c374fa2ce4
commit 0e3749fcf9
6 changed files with 55 additions and 32 deletions
+13 -3
View File
@@ -32,6 +32,7 @@
namespace {
const std::string _loggerCat = "DataSphere";
const int MAX_TEXTURES = 6;
}
namespace openspace {
@@ -155,7 +156,11 @@ bool DataSphere::initialize(){
loadTexture();
});
_dataOptions.onChange([this](){ loadTexture();} );
_dataOptions.onChange([this](){
if(_dataOptions.value().size() > MAX_TEXTURES)
LWARNING("Too many options chosen, max is " + std::to_string(MAX_TEXTURES));
loadTexture();
});
_transferFunctionsFile.onChange([this](){
setTransferFunctions(_transferFunctionsFile.value());
@@ -257,8 +262,8 @@ bool DataSphere::readyToRender(){
void DataSphere::setUniformAndTextures(){
std::vector<int> selectedOptions = _dataOptions.value();
int activeTextures = selectedOptions.size();
int activeTransferfunctions = _transferFunctions.size();
int activeTextures = std::min((int)selectedOptions.size(), MAX_TEXTURES);
int activeTransferfunctions = std::min((int)_transferFunctions.size(), MAX_TEXTURES);
ghoul::opengl::TextureUnit txUnits[10];
int j = 0;
@@ -272,6 +277,8 @@ void DataSphere::setUniformAndTextures(){
);
j++;
if(j >= MAX_TEXTURES) break;
}
}
@@ -307,6 +314,7 @@ void DataSphere::setUniformAndTextures(){
);
j++;
if(j >= MAX_TEXTURES) break;
}
}
}
@@ -345,8 +353,10 @@ void DataSphere::setTransferFunctions(std::string tfPath){
tfs.push_back(tf);
}
}
tfFile.close();
}
if(!tfs.empty()){
_transferFunctions.clear();
_transferFunctions = tfs;