Introduction of new Dictionary class (#1446)

* Adapting to introduction of new Dictionary class in Ghoul
 * Mainly replacing usage of float instead of doubles as expected
 * Adjust to the lack of the hasKeyAndValue function
This commit is contained in:
Alexander Bock
2021-01-02 15:07:11 +01:00
committed by GitHub
parent 7bf7a25401
commit 067c0f4b27
121 changed files with 2299 additions and 2160 deletions
+31 -26
View File
@@ -550,25 +550,26 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
_generalProperties.currentLodScaleFactor.setReadOnly(true);
// Read the radii in to its own dictionary
if (dictionary.hasKeyAndValue<glm::dvec3>(KeyRadii)) {
_ellipsoid = Ellipsoid(dictionary.value<glm::vec3>(KeyRadii));
if (dictionary.hasValue<glm::dvec3>(KeyRadii)) {
_ellipsoid = Ellipsoid(dictionary.value<glm::dvec3>(KeyRadii));
setBoundingSphere(static_cast<float>(_ellipsoid.maximumRadius()));
}
else if (dictionary.hasKeyAndValue<double>(KeyRadii)) {
else if (dictionary.hasValue<double>(KeyRadii)) {
const double radius = dictionary.value<double>(KeyRadii);
_ellipsoid = Ellipsoid({ radius, radius, radius });
setBoundingSphere(static_cast<float>(_ellipsoid.maximumRadius()));
}
if (dictionary.hasValue<bool>("PerformShading")) {
if (dictionary.hasKey("PerformShading")) {
_generalProperties.performShading = dictionary.value<bool>("PerformShading");
}
// Init layer manager
ghoul::Dictionary layersDictionary;
if (!dictionary.getValue(KeyLayers, layersDictionary)) {
if (!dictionary.hasValue<ghoul::Dictionary>(KeyLayers)) {
throw ghoul::RuntimeError(std::string(KeyLayers) + " must be specified");
}
layersDictionary = dictionary.value<ghoul::Dictionary>(KeyLayers);
_layerManager.initialize(layersDictionary);
@@ -635,21 +636,25 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
//================================================================
//======== Reads Shadow (Eclipses) Entries in mod file ===========
//================================================================
ghoul::Dictionary shadowDictionary;
bool success = dictionary.getValue(KeyShadowGroup, shadowDictionary);
bool success = dictionary.hasValue<ghoul::Dictionary>(KeyShadowGroup);
bool disableShadows = false;
if (success) {
ghoul::Dictionary shadowDictionary =
dictionary.value<ghoul::Dictionary>(KeyShadowGroup);
std::vector<std::pair<std::string, double>> sourceArray;
unsigned int sourceCounter = 1;
while (success) {
std::string sourceName;
success = shadowDictionary.getValue(KeyShadowSource +
std::to_string(sourceCounter) + ".Name", sourceName);
std::string keyName =
KeyShadowSource + std::to_string(sourceCounter) + ".Name";
std::string keyRadius =
KeyShadowSource + std::to_string(sourceCounter) + ".Radius";
success = shadowDictionary.hasValue<std::string>(keyName);
if (success) {
double sourceRadius;
success = shadowDictionary.getValue(KeyShadowSource +
std::to_string(sourceCounter) + ".Radius", sourceRadius);
std::string sourceName = shadowDictionary.value<std::string>(keyName);
success = shadowDictionary.hasValue<double>(keyRadius);
if (success) {
double sourceRadius = shadowDictionary.value<double>(keyRadius);
sourceArray.emplace_back(sourceName, sourceRadius);
}
else {
@@ -668,14 +673,17 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
std::vector<std::pair<std::string, double>> casterArray;
unsigned int casterCounter = 1;
while (success) {
std::string casterName;
success = shadowDictionary.getValue(KeyShadowCaster +
std::to_string(casterCounter) + ".Name", casterName);
std::string keyName =
KeyShadowCaster + std::to_string(casterCounter) + ".Name";
std::string keyRadius =
KeyShadowCaster + std::to_string(casterCounter) + ".Radius";
success = shadowDictionary.hasValue<std::string>(keyName);
if (success) {
double casterRadius;
success = shadowDictionary.getValue(KeyShadowCaster +
std::to_string(casterCounter) + ".Radius", casterRadius);
std::string casterName = shadowDictionary.value<std::string>(keyName);
success = shadowDictionary.hasValue<double>(keyRadius);
if (success) {
double casterRadius = shadowDictionary.value<double>(keyRadius);
casterArray.emplace_back(casterName, casterRadius);
}
else {
@@ -706,18 +714,15 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
}
// Labels Dictionary
if (dictionary.hasKeyAndValue<ghoul::Dictionary>(KeyLabels)) {
if (dictionary.hasValue<ghoul::Dictionary>(KeyLabels)) {
_labelsDictionary = dictionary.value<ghoul::Dictionary>(KeyLabels);
}
// Components
if (dictionary.hasKey("Rings")) {
if (dictionary.hasValue<ghoul::Dictionary>("Rings")) {
_ringsComponent.initialize();
addPropertySubOwner(_ringsComponent);
_hasRings = true;
ghoul::Dictionary ringsDic;
dictionary.getValue("Rings", ringsDic);
}
if (dictionary.hasKey("Shadows")) {
@@ -730,7 +735,7 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
}
void RenderableGlobe::initializeGL() {
if (!_labelsDictionary.empty()) {
if (!_labelsDictionary.isEmpty()) {
_globeLabelsComponent.initialize(_labelsDictionary, this);
addPropertySubOwner(_globeLabelsComponent);
}
@@ -1796,7 +1801,7 @@ void RenderableGlobe::recompileShaders() {
for (int i = 0; i < layergroupid::NUM_LAYER_GROUPS; ++i) {
layerGroupNames.setValue(
std::to_string(i),
layergroupid::LAYER_GROUP_IDENTIFIERS[i]
std::string(layergroupid::LAYER_GROUP_IDENTIFIERS[i])
);
}
shaderDictionary.setValue("layerGroups", layerGroupNames);