forked from mirrors/nixpkgs
cb597c229b
This adds a new package: OpenSpace, an open source astrovisualization project, and one of its dependencies: SOIL (Simple OpenGL Image Library). This kind of works for me, but please note that this build is not very usable for now. This is a first attempt. Also, Linux doesn't seem to be well supported upstream, hence the various patches (I will open an issue upstream to discuss them). Squashed commits: openspace: fetch upstream glm "patch" openspace: add missing dependency (libXxf86vm) soil: mesa -> mesa_noglu
92 lines
2.7 KiB
Diff
92 lines
2.7 KiB
Diff
diff --git a/include/openspace/util/distanceconversion.h b/include/openspace/util/distanceconversion.h
|
|
index 80a3a96..7059752 100755
|
|
--- a/include/openspace/util/distanceconversion.h
|
|
+++ b/include/openspace/util/distanceconversion.h
|
|
@@ -159,24 +159,34 @@ constexpr const char* nameForDistanceUnit(DistanceUnit unit, bool pluralForm = f
|
|
}
|
|
|
|
constexpr DistanceUnit distanceUnitFromString(const char* unitName) {
|
|
+ int result = -1;
|
|
+
|
|
int i = 0;
|
|
for (const char* val : DistanceUnitNamesSingular) {
|
|
if (ghoul::equal(unitName, val)) {
|
|
- return static_cast<DistanceUnit>(i);
|
|
+ result = i;
|
|
+ break;
|
|
}
|
|
++i;
|
|
}
|
|
|
|
- i = 0;
|
|
- for (const char* val : DistanceUnitNamesPlural) {
|
|
- if (ghoul::equal(unitName, val)) {
|
|
- return static_cast<DistanceUnit>(i);
|
|
+ if (result == -1) {
|
|
+ i = 0;
|
|
+ for (const char* val : DistanceUnitNamesPlural) {
|
|
+ if (ghoul::equal(unitName, val)) {
|
|
+ result = i;
|
|
+ break;
|
|
+ }
|
|
+ ++i;
|
|
}
|
|
- ++i;
|
|
}
|
|
|
|
- ghoul_assert(false, "Unit name is not a valid name");
|
|
- throw ghoul::MissingCaseException();
|
|
+ if (result != -1)
|
|
+ return static_cast<DistanceUnit>(result);
|
|
+ else {
|
|
+ ghoul_assert(false, "Unit name is not a valid name");
|
|
+ throw ghoul::MissingCaseException();
|
|
+ }
|
|
}
|
|
|
|
|
|
diff --git a/include/openspace/util/timeconversion.h b/include/openspace/util/timeconversion.h
|
|
index a36c92a..699bca9 100755
|
|
--- a/include/openspace/util/timeconversion.h
|
|
+++ b/include/openspace/util/timeconversion.h
|
|
@@ -142,23 +142,32 @@ constexpr const char* nameForTimeUnit(TimeUnit unit, bool pluralForm = false) {
|
|
}
|
|
|
|
constexpr TimeUnit timeUnitFromString(const char* unitName) {
|
|
+ int result = -1;
|
|
+
|
|
int i = 0;
|
|
for (const char* val : TimeUnitNamesSingular) {
|
|
if (ghoul::equal(unitName, val)) {
|
|
- return static_cast<TimeUnit>(i);
|
|
+ result = i;
|
|
+ break;
|
|
}
|
|
++i;
|
|
}
|
|
|
|
- i = 0;
|
|
- for (const char* val : TimeUnitNamesPlural) {
|
|
- if (ghoul::equal(unitName, val)) {
|
|
- return static_cast<TimeUnit>(i);
|
|
+ if (result == -1) {
|
|
+ i = 0;
|
|
+ for (const char* val : TimeUnitNamesPlural) {
|
|
+ if (ghoul::equal(unitName, val)) {
|
|
+ result = i;
|
|
+ break;
|
|
+ }
|
|
+ ++i;
|
|
}
|
|
- ++i;
|
|
}
|
|
|
|
- throw ghoul::MissingCaseException();
|
|
+ if (result != -1)
|
|
+ return static_cast<TimeUnit>(result);
|
|
+ else
|
|
+ throw ghoul::MissingCaseException();
|
|
}
|
|
|
|
std::pair<double, std::string> simplifyTime(double seconds,
|