Merge remote-tracking branch 'origin/master' into feature/getting-started-tour

This commit is contained in:
Ylva Selling
2022-07-21 12:26:20 -04:00
41 changed files with 171 additions and 623 deletions

View File

@@ -23,6 +23,7 @@
##########################################################################################
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
cmake_policy(SET CMP0120 NEW)
project(OpenSpace)

View File

@@ -29,8 +29,6 @@
#include <ghoul/ghoul.h>
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/io/texture/texturereader.h>
#include <ghoul/io/texture/texturereaderdevil.h>
#include <ghoul/io/texture/texturereaderfreeimage.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/logging/consolelog.h>
@@ -64,19 +62,6 @@ namespace {
const std::string _loggerCat = "TaskRunner Main";
}
void initTextureReaders() {
#ifdef GHOUL_USE_DEVIL
ghoul::io::TextureReader::ref().addReader(
std::make_unique<ghoul::io::TextureReaderDevIL>()
);
#endif // GHOUL_USE_DEVIL
#ifdef GHOUL_USE_FREEIMAGE
ghoul::io::TextureReader::ref().addReader(
std::make_unique<ghoul::io::TextureReaderFreeImage>()
);
#endif // GHOUL_USE_FREEIMAGE
}
void performTasks(const std::string& path) {
using namespace openspace;

View File

@@ -29,11 +29,8 @@ local CharonProjection = {
},
Renderable = {
Type = "RenderablePlanetProjection",
Geometry = {
Type = "SimpleSphere",
Radius = charonRadius,
Segments = 350
},
Radius = charonRadius,
Segments = 350,
ColorTexturePaths = {
textures .. "NH_Charon_mosaic.png",
textures .. "NH_Charon_mosaic_8192.png"

View File

@@ -51,11 +51,7 @@ local PlutoProjection = {
Renderable = {
Type = "RenderablePlanetProjection",
Radius = plutoRadius,
Geometry = {
Type = "SimpleSphere",
Radius = plutoRadius,
Segments = 400
},
Segments = 400,
ColorTexturePaths = {
textures .. "pluto.png",
textures .. "NH_Pluto_mosaic_16384.png",

View File

@@ -91,7 +91,11 @@ void DashboardItemDate::render(glm::vec2& penPosition) {
);
try {
RenderFont(*_font, penPosition, fmt::format(_formatString.value().c_str(), time));
RenderFont(
*_font,
penPosition,
fmt::format(fmt::runtime(_formatString.value()), time)
);
}
catch (const fmt::format_error&) {
LERRORC("DashboardItemDate", "Illegal format string");
@@ -103,7 +107,7 @@ glm::vec2 DashboardItemDate::size() const {
ZoneScoped
std::string_view time = global::timeManager->time().UTC();
return _font->boundingBox(fmt::format(_formatString.value().c_str(), time));
return _font->boundingBox(fmt::format(fmt::runtime(_formatString.value()), time));
}
} // namespace openspace

View File

@@ -358,7 +358,7 @@ void DashboardItemDistance::render(glm::vec2& penPosition) {
try {
char* end = fmt::format_to(
_buffer.data(),
_formatString.value().c_str(),
fmt::runtime(_formatString.value()),
sourceInfo.second, destinationInfo.second, dist.first, dist.second
);

View File

@@ -96,7 +96,11 @@ void DashboardItemPropertyValue::render(glm::vec2& penPosition) {
std::string value;
_property->getStringValue(value);
RenderFont(*_font, penPosition, fmt::format(_displayString.value(), value));
RenderFont(
*_font,
penPosition,
fmt::format(fmt::runtime(_displayString.value()), value)
);
penPosition.y -= _font->height();
}
}

View File

@@ -182,7 +182,7 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) {
*_font,
penPosition,
fmt::format(
_transitionFormat.value().c_str(),
fmt::runtime(_transitionFormat.value()),
targetDeltaTime.first, targetDeltaTime.second,
pauseText,
currentDeltaTime.first, currentDeltaTime.second
@@ -194,7 +194,7 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) {
*_font,
penPosition,
fmt::format(
_regularFormat.value().c_str(),
fmt::runtime(_regularFormat.value()),
targetDeltaTime.first, targetDeltaTime.second, pauseText
)
);

View File

@@ -364,8 +364,8 @@ void prepareStateAndKameleonForExtras(ccmc::Kameleon* kameleon,
}
if (!success) {
LWARNING(fmt::format(
"Failed to load at least one of the magnitude variables: {}, {}, {} "
"& {}. Removing ability to store corresponding magnitude",
"Failed to load at least one of the magnitude variables: {}, {}, {}. "
"Removing ability to store corresponding magnitude",
s1, s2, s3
));
extraMagVars.erase(

View File

@@ -190,7 +190,7 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) {
{
end = fmt::format_to(
_buffer.data(),
_formatString, lat, lon, dist.first, dist.second
fmt::runtime(_formatString), lat, lon, dist.first, dist.second
);
break;
}
@@ -217,7 +217,7 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) {
end = fmt::format_to(
_buffer.data(),
_formatString,
fmt::runtime(_formatString),
latDeg, latMin, latSec, isNorth ? "N" : "S",
lonDeg, lonMin, lonSec, isEast ? "E" : "W",
dist.first, dist.second

View File

@@ -21,10 +21,12 @@ must not be misrepresented as being the original software.
distribution.
*/
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
#include "tinyxml2.h"
@@ -2990,4 +2992,6 @@ bool XMLPrinter::Visit( const XMLUnknown& unknown )
} // namespace tinyxml2
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

View File

@@ -29,11 +29,17 @@
#include <openspace/documentation/documentation.h>
#include <unordered_map>
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
#include <modules/skybrowser/ext/tinyxml2/tinyxml2.h>
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
namespace openspace::documentation { struct Documentation; }

View File

@@ -155,7 +155,7 @@ void parseWtmlsFromDisc(std::vector<tinyxml2::XMLDocument*>& xmls,
{
for (const auto& entry : std::filesystem::directory_iterator(directory)) {
tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument();
std::string path = entry.path().u8string();
std::string path = entry.path().string();
tinyxml2::XMLError successCode = document->LoadFile(path.c_str());
if (successCode == tinyxml2::XMLError::XML_SUCCESS) {

View File

@@ -27,7 +27,6 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
set(HEADER_FILES
horizonsfile.h
speckloader.h
rendering/planetgeometry.h
rendering/renderableconstellationbounds.h
rendering/renderablefluxnodes.h
rendering/renderablehabitablezone.h
@@ -37,7 +36,6 @@ set(HEADER_FILES
rendering/renderablesmallbody.h
rendering/renderablestars.h
rendering/renderabletravelspeed.h
rendering/simplespheregeometry.h
translation/keplertranslation.h
translation/spicetranslation.h
translation/tletranslation.h
@@ -50,7 +48,6 @@ set(SOURCE_FILES
horizonsfile.cpp
spacemodule_lua.inl
speckloader.cpp
rendering/planetgeometry.cpp
rendering/renderableconstellationbounds.cpp
rendering/renderablefluxnodes.cpp
rendering/renderablehabitablezone.cpp
@@ -60,7 +57,6 @@ set(SOURCE_FILES
rendering/renderablesmallbody.cpp
rendering/renderablestars.cpp
rendering/renderabletravelspeed.cpp
rendering/simplespheregeometry.cpp
translation/keplertranslation.cpp
translation/spicetranslation.cpp
translation/tletranslation.cpp

View File

@@ -30,6 +30,7 @@
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/fmt.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/misc.h>
#include <filesystem>
#include <fstream>
@@ -52,60 +53,6 @@ namespace {
constexpr std::string_view StartTime = "&START_TIME=";
constexpr std::string_view StopTime = "&STOP_TIME=";
constexpr std::string_view StepSize = "&STEP_SIZE=";
// URL encoding
constexpr std::string_view WhiteSpace = "%20";
constexpr std::string_view HashTag = "%23";
constexpr std::string_view DollarSign = "%24";
constexpr std::string_view Ampersand = "%26";
constexpr std::string_view PlusSign = "%2B";
constexpr std::string_view Comma = "%2C";
constexpr std::string_view Slash = "%2F";
constexpr std::string_view Colon = "%3A";
constexpr std::string_view Semicolon = "%3B";
constexpr std::string_view EqualsSign = "%3D";
constexpr std::string_view QuestionMark = "%3F";
constexpr std::string_view AtSymbol = "%40";
constexpr std::string_view LeftSquareBracket = "%5B";
constexpr std::string_view RightSquareBracket = "%5D";
std::string replaceAll(std::string string, const std::string& from,
const std::string& to)
{
if (from.empty()) {
return "";
}
size_t pos = string.find(from);
while (pos != std::string::npos) {
string.replace(pos, from.length(), to);
// In case 'to' contains 'from', ex replacing 'x' with 'yx'
size_t offset = pos + to.length();
pos = string.find(from, offset);
}
return string;
}
std::string urlEncode(const std::string& string) {
std::string result;
result = replaceAll(string, " ", static_cast<std::string>(WhiteSpace));
result = replaceAll(result, "#", static_cast<std::string>(HashTag));
result = replaceAll(result, "$", static_cast<std::string>(DollarSign));
result = replaceAll(result, "&", static_cast<std::string>(Ampersand));
result = replaceAll(result, "+", static_cast<std::string>(PlusSign));
result = replaceAll(result, ",", static_cast<std::string>(Comma));
result = replaceAll(result, "/", static_cast<std::string>(Slash));
result = replaceAll(result, ":", static_cast<std::string>(Colon));
result = replaceAll(result, ";", static_cast<std::string>(Semicolon));
result = replaceAll(result, "=", static_cast<std::string>(EqualsSign));
result = replaceAll(result, "?", static_cast<std::string>(QuestionMark));
result = replaceAll(result, "@", static_cast<std::string>(AtSymbol));
result = replaceAll(result, "[", static_cast<std::string>(LeftSquareBracket));
result = replaceAll(result, "]", static_cast<std::string>(RightSquareBracket));
return result;
}
} // namespace
namespace openspace {
@@ -117,7 +64,7 @@ HorizonsFile::HorizonsFile(std::filesystem::path file)
HorizonsFile::HorizonsFile(std::filesystem::path filePath, const std::string& result) {
// Write the response into a new file and save it
std::ofstream file(filePath);
file << replaceAll(result, "\\n", "\n") << std::endl;
file << ghoul::replaceAll(result, "\\n", "\n") << std::endl;
file.close();
_file = std::move(filePath);
}
@@ -153,16 +100,18 @@ std::string constructHorizonsUrl(HorizonsType type, const std::string& target,
throw ghoul::MissingCaseException();
}
url += fmt::format("{}'{}'", Command, urlEncode(target));
url += fmt::format("{}'{}'", Center, urlEncode(observer));
url += fmt::format("{}'{}'", StartTime, urlEncode(startTime));
url += fmt::format("{}'{}'", StopTime, urlEncode(stopTime));
url += fmt::format("{}'{}'", Command, ghoul::encodeUrl(target));
url += fmt::format("{}'{}'", Center, ghoul::encodeUrl(observer));
url += fmt::format("{}'{}'", StartTime, ghoul::encodeUrl(startTime));
url += fmt::format("{}'{}'", StopTime, ghoul::encodeUrl(stopTime));
if (unit.empty()) {
url += fmt::format("{}'{}'", StepSize, urlEncode(stepSize));
url += fmt::format("{}'{}'", StepSize, ghoul::encodeUrl(stepSize));
}
else {
url += fmt::format("{}'{}{}{}'", StepSize, urlEncode(stepSize), WhiteSpace, unit);
url += fmt::format(
"{}'{}%20{}'", StepSize, ghoul::encodeUrl(stepSize), unit
);
}
return url;

View File

@@ -1,64 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2022 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/space/rendering/planetgeometry.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/util/factorymanager.h>
#include <ghoul/misc/templatefactory.h>
namespace {
struct [[codegen::Dictionary(PlanetGeometry)]] Parameters {
// The type of the PlanetGeometry that will can be constructed
std::string type;
};
#include "planetgeometry_codegen.cpp"
} // namespace
namespace openspace::planetgeometry {
documentation::Documentation PlanetGeometry::Documentation() {
return codegen::doc<Parameters>("space_geometry_planet");
}
std::unique_ptr<PlanetGeometry> PlanetGeometry::createFromDictionary(
const ghoul::Dictionary& dictionary)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
ghoul::TemplateFactory<PlanetGeometry>* factory =
FactoryManager::ref().factory<PlanetGeometry>();
PlanetGeometry* result = factory->create(p.type, dictionary);
return std::unique_ptr<PlanetGeometry>(result);
}
PlanetGeometry::PlanetGeometry() : properties::PropertyOwner({ "PlanetGeometry" }) {}
void PlanetGeometry::initialize() {}
void PlanetGeometry::deinitialize() {}
} // namespace openspace::planetgeometry

View File

@@ -1,58 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2022 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_MODULE_SPACE___PLANETGEOMETRY___H__
#define __OPENSPACE_MODULE_SPACE___PLANETGEOMETRY___H__
#include <openspace/properties/propertyowner.h>
#include <ghoul/glm.h>
#include <memory>
namespace ghoul { class Dictionary; }
namespace openspace { class Renderable; }
namespace openspace::documentation { struct Documentation; }
namespace openspace::planetgeometry {
class PlanetGeometry : public properties::PropertyOwner {
public:
static std::unique_ptr<PlanetGeometry> createFromDictionary(
const ghoul::Dictionary& dictionary
);
PlanetGeometry();
~PlanetGeometry() override = default;
virtual void initialize();
virtual void deinitialize();
virtual void render() = 0;
virtual float boundingSphere() const = 0;
static documentation::Documentation Documentation();
};
} // namespace openspace::planetgeometry
#endif // __OPENSPACE_MODULE_SPACE___PLANETGEOMETRY___H__

View File

@@ -248,16 +248,18 @@ void RenderableSmallBody::readDataFile(const std::string& filename) {
sequentialLineErrors = 0;
}
catch (std::invalid_argument&) {
const char* errMsg = "Unable to convert field {} to double value "\
"(invalid_argument exception). Ignoring line {}/{} of {}.";
constexpr std::string_view errMsg = "Unable to convert field {} to "
"double value (invalid_argument exception). Ignoring line {}/{} "
"of {}.";
LINFO(fmt::format(
errMsg,
fieldCount, csvLine + 1, numberOfLines, filename
));
}
catch (std::out_of_range&) {
const char* errMsg = "Unable to convert field {} to double value "\
"(out_of_range exception). Ignoring line {}/{} of {}.";
constexpr std::string_view errMsg = "Unable to convert field {} to "
"double value (out_of_range exception). Ignoring line {}/{} of "
"{}.";
LINFO(fmt::format(
errMsg,
fieldCount, csvLine + 1, numberOfLines, filename

View File

@@ -1,116 +0,0 @@
/****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2022 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/space/rendering/simplespheregeometry.h>
#include <openspace/documentation/verifier.h>
#include <openspace/rendering/renderable.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/sphere.h>
namespace {
constexpr openspace::properties::Property::PropertyInfo RadiusInfo = {
"Radius",
"Radius",
"This value specifies the radius of this sphere in meters."
};
constexpr openspace::properties::Property::PropertyInfo SegmentsInfo = {
"Segments",
"Segments",
"This value specifies the number of segments that this sphere is split into."
};
struct [[codegen::Dictionary(SimpleSphereGeometry)]] Parameters {
// [[codegen::verbatim(RadiusInfo.description)]]
std::variant<float, glm::vec3> radius;
// [[codegen::verbatim(SegmentsInfo.description)]]
int segments;
};
#include "simplespheregeometry_codegen.cpp"
} // namespace
namespace openspace::planetgeometry {
documentation::Documentation SimpleSphereGeometry::Documentation() {
return codegen::doc<Parameters>("space_geometry_simplesphere");
}
SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary)
: _radius(RadiusInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(std::pow(10.f, 20.f)))
, _segments(SegmentsInfo, 20, 1, 5000)
, _sphere(nullptr)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
if (std::holds_alternative<float>(p.radius)) {
const float radius = std::get<float>(p.radius);
_radius = glm::dvec3(radius, radius, radius);
}
else {
_radius = std::get<glm::vec3>(p.radius);
}
_segments = p.segments;
// The shader need the radii values but they are not changeable runtime
// TODO: Possibly add a scaling property @AA
// Changing the radius/scaling should affect the shader but not the geometry? @AA
_radius.onChange([&]() { createSphere(); });
addProperty(_radius);
_segments.onChange([&]() { createSphere(); });
addProperty(_segments);
}
SimpleSphereGeometry::~SimpleSphereGeometry() {} // NOLINT
void SimpleSphereGeometry::initialize() {
createSphere();
}
void SimpleSphereGeometry::deinitialize() {
delete _sphere;
_sphere = nullptr;
}
void SimpleSphereGeometry::render() {
_sphere->render();
}
float SimpleSphereGeometry::boundingSphere() const {
const glm::vec3 radius = _radius;
return std::max(std::max(radius[0], radius[1]), radius[2]);
}
void SimpleSphereGeometry::createSphere() {
const glm::vec3 radius = _radius.value();
delete _sphere;
_sphere = new Sphere(radius, _segments);
_sphere->initialize();
}
} // namespace openspace::planetgeometry

View File

@@ -1,65 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2022 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_MODULE_SPACE___SIMPLESPHEREGEOMETRY___H__
#define __OPENSPACE_MODULE_SPACE___SIMPLESPHEREGEOMETRY___H__
#include <modules/space/rendering/planetgeometry.h>
#include <openspace/properties/scalar/intproperty.h>
#include <openspace/properties/vector/vec3property.h>
namespace openspace {
class Renderable;
class Sphere;
} // namespace openspace
namespace openspace::documentation { struct Documentation; }
namespace openspace::planetgeometry {
class SimpleSphereGeometry : public PlanetGeometry {
public:
SimpleSphereGeometry(const ghoul::Dictionary& dictionary);
~SimpleSphereGeometry() override;
void initialize() override;
void deinitialize() override;
void render() override;
float boundingSphere() const override;
static documentation::Documentation Documentation();
private:
void createSphere();
properties::Vec3Property _radius;
properties::IntProperty _segments;
Sphere* _sphere;
};
} // namespace openspace::planetgeometry
#endif // __OPENSPACE_MODULE_SPACE___SIMPLESPHEREGEOMETRY___H__

View File

@@ -32,7 +32,6 @@
#include <modules/space/rendering/renderablesmallbody.h>
#include <modules/space/rendering/renderablestars.h>
#include <modules/space/rendering/renderabletravelspeed.h>
#include <modules/space/rendering/simplespheregeometry.h>
#include <modules/space/translation/keplertranslation.h>
#include <modules/space/translation/spicetranslation.h>
#include <modules/space/translation/tletranslation.h>
@@ -74,8 +73,6 @@ SpaceModule::SpaceModule()
}
void SpaceModule::internalInitialize(const ghoul::Dictionary& dictionary) {
FactoryManager::ref().addFactory<planetgeometry::PlanetGeometry>("PlanetGeometry");
ghoul::TemplateFactory<Renderable>* fRenderable =
FactoryManager::ref().factory<Renderable>();
ghoul_assert(fRenderable, "Renderable factory was not created");
@@ -106,11 +103,6 @@ void SpaceModule::internalInitialize(const ghoul::Dictionary& dictionary) {
fRotation->registerClass<SpiceRotation>("SpiceRotation");
ghoul::TemplateFactory<planetgeometry::PlanetGeometry>* fGeometry =
FactoryManager::ref().factory<planetgeometry::PlanetGeometry>();
ghoul_assert(fGeometry, "Planet geometry factory was not created");
fGeometry->registerClass<planetgeometry::SimpleSphereGeometry>("SimpleSphere");
if (dictionary.hasValue<bool>(SpiceExceptionInfo.identifier)) {
_showSpiceExceptions = dictionary.value<bool>(SpiceExceptionInfo.identifier);
}
@@ -124,7 +116,6 @@ std::vector<documentation::Documentation> SpaceModule::documentations() const {
return {
HorizonsTranslation::Documentation(),
KeplerTranslation::Documentation(),
planetgeometry::PlanetGeometry::Documentation(),
RenderableConstellationBounds::Documentation(),
RenderableFluxNodes::Documentation(),
RenderableHabitableZone::Documentation(),
@@ -133,7 +124,6 @@ std::vector<documentation::Documentation> SpaceModule::documentations() const {
RenderableSmallBody::Documentation(),
RenderableStars::Documentation(),
RenderableTravelSpeed::Documentation(),
planetgeometry::SimpleSphereGeometry::Documentation(),
SpiceRotation::Documentation(),
SpiceTranslation::Documentation(),
TLETranslation::Documentation()

View File

@@ -24,13 +24,13 @@
#include <modules/spacecraftinstruments/rendering/renderableplanetprojection.h>
#include <modules/space/rendering/planetgeometry.h>
#include <modules/spacecraftinstruments/spacecraftinstrumentsmodule.h>
#include <modules/spacecraftinstruments/util/image.h>
#include <modules/spacecraftinstruments/util/imagesequencer.h>
#include <openspace/documentation/documentation.h>
#include <openspace/engine/globals.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/util/sphere.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/io/texture/texturereader.h>
@@ -130,10 +130,19 @@ namespace {
"Remove all pending projections from the buffer"
};
struct [[codegen::Dictionary(RenderablePlanetProjection)]] Parameters {
// The geometry that is used for rendering this planet
ghoul::Dictionary geometry [[codegen::reference("space_geometry_planet")]];
constexpr openspace::properties::Property::PropertyInfo RadiusInfo = {
"Radius",
"Radius",
"This value specifies the radius of this sphere in meters."
};
constexpr openspace::properties::Property::PropertyInfo SegmentsInfo = {
"Segments",
"Segments",
"This value specifies the number of segments that this sphere is split into."
};
struct [[codegen::Dictionary(RenderablePlanetProjection)]] Parameters {
// Contains information about projecting onto this planet
ghoul::Dictionary projection
[[codegen::reference("spacecraftinstruments_projectioncomponent")]];
@@ -155,6 +164,12 @@ namespace {
// [[codegen::verbatim(MaxProjectionsPerFrameInfo.description)]]
std::optional<int> maxProjectionsPerFrame;
// [[codegen::verbatim(RadiusInfo.description)]]
std::variant<float, glm::vec3> radius;
// [[codegen::verbatim(SegmentsInfo.description)]]
int segments;
};
#include "renderableplanetprojection_codegen.cpp"
} // namespace
@@ -177,10 +192,12 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
, _maxProjectionsPerFrame(MaxProjectionsPerFrameInfo, 3, 1, 64)
, _projectionsInBuffer(ProjectionsInBufferInfo, 0, 1, 32)
, _clearProjectionBuffer(ClearProjectionBufferInfo)
, _radius(RadiusInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(std::pow(10.f, 20.f)))
, _segments(SegmentsInfo, 20, 1, 5000)
, _sphere(nullptr)
{
const Parameters p = codegen::bake<Parameters>(dict);
_geometry = planetgeometry::PlanetGeometry::createFromDictionary(p.geometry);
_projectionComponent.initialize(identifier(), p.projection);
_colorTexturePaths.addOption(0, NoImageText);
@@ -251,7 +268,6 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
}
setBoundingSphere(radius);
addPropertySubOwner(_geometry.get());
addPropertySubOwner(_projectionComponent);
_heightExaggeration.setExponent(3.f);
@@ -270,6 +286,20 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
});
addProperty(_clearProjectionBuffer);
if (std::holds_alternative<float>(p.radius)) {
const float r = std::get<float>(p.radius);
_radius = glm::dvec3(r, r, r);
}
else {
_radius = std::get<glm::vec3>(p.radius);
}
_radius.onChange([&]() { createSphere(); });
addProperty(_radius);
_segments = p.segments;
_segments.onChange([&]() { createSphere(); });
addProperty(_segments);
}
RenderablePlanetProjection::~RenderablePlanetProjection() {} // NOLINT
@@ -322,8 +352,9 @@ void RenderablePlanetProjection::initializeGL() {
loadColorTexture();
loadHeightTexture();
_projectionComponent.initializeGL();
_geometry->initialize();
setBoundingSphere(_geometry->boundingSphere());
createSphere();
const glm::vec3 radius = _radius;
setBoundingSphere(std::max(std::max(radius[0], radius[1]), radius[2]));
// SCREEN-QUAD
const GLfloat vertexData[] = {
@@ -346,9 +377,10 @@ void RenderablePlanetProjection::initializeGL() {
}
void RenderablePlanetProjection::deinitializeGL() {
_sphere = nullptr;
_projectionComponent.deinitialize();
_baseTexture = nullptr;
_geometry = nullptr;
glDeleteVertexArrays(1, &_quad);
glDeleteBuffers(1, &_vertexPositionBuffer);
@@ -366,7 +398,7 @@ void RenderablePlanetProjection::deinitializeGL() {
}
bool RenderablePlanetProjection::isReady() const {
return _geometry && _programObject && _projectionComponent.isReady();
return _programObject && _projectionComponent.isReady();
}
void RenderablePlanetProjection::imageProjectGPU(
@@ -385,25 +417,8 @@ void RenderablePlanetProjection::imageProjectGPU(
_fboProgramObject->setUniform(_fboUniformCache.projectorMatrix, projectorMatrix);
_fboProgramObject->setUniform(_fboUniformCache.modelTransform, _transform);
_fboProgramObject->setUniform(_fboUniformCache.boresight, _boresight);
if (_geometry->hasProperty("Radius")) {
std::any r = _geometry->property("Radius")->get();
if (glm::vec3* radius = std::any_cast<glm::vec3>(&r)){
_fboProgramObject->setUniform(_fboUniformCache.radius, *radius);
}
}
else {
LERROR("Geometry object needs to provide radius");
}
if (_geometry->hasProperty("Segments")) {
std::any s = _geometry->property("Segments")->get();
if (int* segments = std::any_cast<int>(&s)) {
_fboProgramObject->setUniform(_fboUniformCache.segments, segments[0]);
}
}
else{
LERROR("Geometry object needs to provide segment count");
}
_fboProgramObject->setUniform(_fboUniformCache.radius, _radius);
_fboProgramObject->setUniform(_fboUniformCache.segments, _segments);
glBindVertexArray(_quad);
glDrawArrays(GL_TRIANGLES, 0, 6);
@@ -552,7 +567,7 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&)
_programObject->setUniform(_mainUniformCache.heightTexture, unit[2]);
}
_geometry->render();
_sphere->render();
_programObject->deactivate();
}
@@ -674,4 +689,9 @@ void RenderablePlanetProjection::loadHeightTexture() {
}
}
void RenderablePlanetProjection::createSphere() {
_sphere = std::make_unique<Sphere>(_radius, _segments);
_sphere->initialize();
}
} // namespace openspace

View File

@@ -31,6 +31,7 @@
#include <openspace/properties/optionproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/triggerproperty.h>
#include <openspace/properties/vector/vec3property.h>
#include <ghoul/opengl/uniformcache.h>
namespace openspace {
@@ -38,6 +39,7 @@ namespace openspace {
namespace documentation { struct Documentation; }
struct Image;
class Sphere;
namespace planetgeometry { class PlanetGeometry; }
@@ -59,6 +61,7 @@ public:
private:
void loadColorTexture();
void loadHeightTexture();
void createSphere();
glm::mat4 attitudeParameters(double time, const glm::vec3& up);
void imageProjectGPU(const ghoul::opengl::Texture& projectionTexture,
@@ -94,7 +97,9 @@ private:
properties::IntProperty _projectionsInBuffer;
properties::TriggerProperty _clearProjectionBuffer;
std::unique_ptr<planetgeometry::PlanetGeometry> _geometry;
properties::Vec3Property _radius;
properties::IntProperty _segments;
std::unique_ptr<Sphere> _sphere;
glm::mat4 _transform = glm::mat4(1.f);
glm::mat4 _projectorMatrix = glm::mat4(1.f);

View File

@@ -46,26 +46,13 @@ cmake_minimum_required(VERSION 2.8.12.1)
# Use folders in the resulting project files.
set_property(GLOBAL PROPERTY OS_FOLDERS ON)
# "OpenSpace Helper" is not a valid CMake target name under OLD
# https://cmake.org/cmake/help/git-stage/policy/CMP0037.html
cmake_policy(SET CMP0037 OLD)
# Use <PackageName>_ROOT variables
# https://cmake.org/cmake/help/git-stage/policy/CMP0074.html
cmake_policy(SET CMP0074 NEW)
# Specify the CEF distribution version.
# Release from 03/21/2022 verified to work on Windows.
set(CEF_VERSION "102.0.10+gf249b2e+chromium-102.0.5005.115")
# Removing - micahnyc 03/21/2022
# 73.1.13 has an issue on MacOS: The GUI freezing upon interaction.
# Therefore, we fall back to 3.3578.1867 from 01/29/2019
#if (APPLE)
# set(CEF_VERSION "3.3578.1867.g0f6d65a")
#endif ()
# CEF Sandbox is not working with the latest Visual Studio, so we disable it for now.
if (WIN32 OR UNIX)
option(USE_SANDBOX OFF)
@@ -107,7 +94,7 @@ add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper)
mark_as_advanced(CEF_DEBUG_INFO_FLAG USE_ATL USE_OFFICIAL_BUILD_SANDBOX USE_SANDBOX)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
# The CEF DLL wrapper is raising a lot of warnings on GCC
target_compile_options(libcef_dll_wrapper PRIVATE "-w")
endif ()
@@ -128,8 +115,8 @@ set(WEBBROWSER_SOURCES_WINDOWS
resource.h
simple_handler_win.cc
)
APPEND_PLATFORM_SOURCES(WEBBROWSER_SOURCES)
APPEND_PLATFORM_SOURCES(WEBBROWSER_RESOURCES_SOURCES)
append_platform_sources(WEBBROWSER_SOURCES)
append_platform_sources(WEBBROWSER_RESOURCES_SOURCES)
set(WEBBROWSER_SOURCES ${WEBBROWSER_SOURCES} ${WEBBROWSER_RESOURCES_SOURCES})
@@ -143,18 +130,18 @@ if (OS_LINUX)
list(APPEND WEBBROWSER_HELPER_SOURCES src/processhelperlinux.cpp)
set(WEBBROWSER_HELPER_SOURCES_LINUX src/processhelperlinux.cpp)
endif()
APPEND_PLATFORM_SOURCES(WEBBROWSER_HELPER_SOURCES)
append_platform_sources(WEBBROWSER_HELPER_SOURCES)
set(WEBBROWSER_RESOURCES_MAC_SOURCES_MACOSX
mac/Info.plist
)
APPEND_PLATFORM_SOURCES(WEBBROWSER_RESOURCES_MAC_SOURCES)
append_platform_sources(WEBBROWSER_RESOURCES_MAC_SOURCES)
set(WEBBROWSER_RESOURCES_MAC_ENGLISH_LPROJ_SRCS_MACOSX
mac/English.lproj/InfoPlist.strings
mac/English.lproj/MainMenu.xib
)
APPEND_PLATFORM_SOURCES(WEBBROWSER_RESOURCES_MAC_ENGLISH_LPROJ_SRCS)
append_platform_sources(WEBBROWSER_RESOURCES_MAC_ENGLISH_LPROJ_SRCS)
set(WEBBROWSER_RESOURCES_SRCS
${WEBBROWSER_RESOURCES_MAC_SOURCES}
@@ -163,19 +150,7 @@ set(WEBBROWSER_RESOURCES_SRCS
# Place Helper in separate executable
# The naming style "<ApplicationName> Helper" is required by Chromium.
set(CEF_HELPER_FILE_REQUIRES_RENAME FALSE)
if (UNIX AND (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles"))
# Linux builds that use GNU Make cannot handle spaces in filenames. For this type
# of build, the build file will have an underscore instead of a space, and this
# will be renamed back to a space when the build is complete.
set(CEF_HELPER_FILE_REQUIRES_RENAME TRUE)
endif()
if (CEF_HELPER_FILE_REQUIRES_RENAME)
# Use '_' instead of ' ' in helper filename
set(CEF_HELPER_TARGET "OpenSpace_Helper" CACHE INTERNAL "CEF_HELPER_TARGET")
else()
set(CEF_HELPER_TARGET "OpenSpace Helper" CACHE INTERNAL "CEF_HELPER_TARGET")
endif()
set(CEF_HELPER_TARGET "OpenSpace_Helper" CACHE INTERNAL "CEF_HELPER_TARGET")
set(CEF_HELPER_TARGET_GPU "OpenSpace Helper (GPU)" CACHE INTERNAL "CEF_HELPER_TARGET_GPU")
set(CEF_HELPER_TARGET_RENDERER "OpenSpace Helper (Renderer)" CACHE INTERNAL "CEF_HELPER_TARGET_RENDERER")
@@ -187,11 +162,11 @@ list(APPEND Targets ${CEF_HELPER_TARGET} ${CEF_HELPER_TARGET_GPU} ${CEF_HELPER_T
if (OS_MACOSX)
ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}")
add_logical_target("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}")
foreach(target IN LISTS Targets)
# Helper executable target.
add_executable(${target} MACOSX_BUNDLE ${WEBBROWSER_HELPER_SOURCES})
SET_EXECUTABLE_TARGET_PROPERTIES(${target})
set_executable_target_properties(${target})
# add_cef_logical_target("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}")
add_dependencies(${target} libcef_dll_wrapper)
target_link_libraries(${target} libcef_dll_wrapper ${CEF_STANDARD_LIBS})
@@ -214,7 +189,7 @@ else()
message(STATUS "Setting up WebBrowser CEF helper executable: ${CEF_HELPER_TARGET}")
set_openspace_cef_target_out_dir()
add_executable(${CEF_HELPER_TARGET} ${WEBBROWSER_HELPER_SOURCES})
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_HELPER_TARGET})
set_executable_target_properties(${CEF_HELPER_TARGET})
add_dependencies(${CEF_HELPER_TARGET} libcef_dll_wrapper)
# Logical target used to link the libcef library.
add_cef_logical_target("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}")
@@ -282,7 +257,7 @@ foreach (i ${CEF_BINARY_FILES})
list(APPEND deps "${CEF_BINARY_DIR}/${i}")
endforeach()
foreach (j ${CEF_RESOURCE_FILES})
list(APPEND deps "${CEF_RESOURCE_DIR}/${j}")
list(APPEND deps "${CEF_RESOURCE_DIR}/${j}")
endforeach()
add_external_library_dependencies("${deps}")
@@ -293,17 +268,13 @@ if (UNIX AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
DESTINATION ${CEF_ROOT}/${CMAKE_BUILD_TYPE}/
FILES_MATCHING PATTERN *
)
endif ()
if (CEF_HELPER_FILE_REQUIRES_RENAME)
# Rename to "OpenSpace Helper" after build & link in order to prevent GNU Make from
# having to deal with the space in the filename
ADD_CUSTOM_COMMAND(
TARGET ${CEF_HELPER_TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rename
"$<TARGET_FILE_DIR:${CEF_HELPER_TARGET}>/${CEF_HELPER_TARGET}"
"$<TARGET_FILE_DIR:${CEF_HELPER_TARGET}>/OpenSpace Helper"
COMMENT "Renaming ${CEF_HELPER_TARGET} to 'OpenSpace Helper'"
)
endif()
endif ()
# Rename to "OpenSpace Helper" after build & link as spaces in targets are not allowed
# add_custom_command(
# TARGET ${CEF_HELPER_TARGET} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E rename
# "$<TARGET_FILE_DIR:${CEF_HELPER_TARGET}>/${CEF_HELPER_TARGET}"
# "$<TARGET_FILE_DIR:${CEF_HELPER_TARGET}>/OpenSpace Helper"
# COMMENT "Renaming ${CEF_HELPER_TARGET} to 'OpenSpace Helper'"
# )

View File

@@ -131,7 +131,7 @@ function(run_cef_windows_config CEF_TARGET CEF_ROOT MODULE_PATH)
if (USE_SANDBOX)
# Logical target used to link the cef_sandbox library.
message(STATUS "Using CEF in Sandboxed mode.")
ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}")
add_logical_target("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}")
target_link_libraries(${CEF_TARGET} cef_sandbox_lib ${CEF_SANDBOX_STANDARD_LIBS})
endif ()
@@ -151,7 +151,7 @@ function(run_cef_linux_config CEF_TARGET CEF_ROOT)
if (USE_SANDBOX)
# Logical target used to link the cef_sandbox library.
message(STATUS "Using CEF in Sandboxed mode.")
ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}")
add_logical_target("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}")
target_link_libraries(${CEF_TARGET} cef_sandbox_lib ${CEF_SANDBOX_STANDARD_LIBS})
endif ()

View File

@@ -43,12 +43,12 @@ namespace {
constexpr const char* _loggerCat = "WebBrowser";
#ifdef _MSC_VER
constexpr const char* SubprocessPath = "OpenSpace Helper.exe";
constexpr const char* SubprocessPath = "OpenSpace_Helper.exe";
#elif defined(__APPLE__)
constexpr const char* SubprocessPath =
"../Frameworks/OpenSpace Helper.app/Contents/MacOS/OpenSpace Helper";
"../Frameworks/OpenSpace Helper.app/Contents/MacOS/OpenSpace_Helper";
#else
constexpr const char* SubprocessPath = "OpenSpace Helper";
constexpr const char* SubprocessPath = "OpenSpace_Helper";
#endif
constexpr openspace::properties::Property::PropertyInfo

View File

@@ -309,6 +309,7 @@ void parseLuaState(Configuration& configuration) {
lua_getglobal(s, "sgctconfiginitializeString");
c.sgctConfigNameInitialized = ghoul::lua::value<std::string>(
s,
1,
ghoul::lua::PopValue::Yes
);

View File

@@ -219,11 +219,6 @@ void OpenSpaceEngine::initialize() {
_printEvents = global::configuration->isPrintingEvents;
const std::string versionCheckUrl = global::configuration->versionCheckUrl;
if (!versionCheckUrl.empty()) {
global::versionChecker->requestLatestVersion(versionCheckUrl);
}
std::string cacheFolder = absPath("${CACHE}").string();
if (global::configuration->usePerProfileCache) {
std::string profile = global::configuration->profile;
@@ -463,6 +458,10 @@ void OpenSpaceEngine::initializeGL() {
);
SysCap.logCapabilities(verbosity);
const std::string versionCheckUrl = global::configuration->versionCheckUrl;
if (!versionCheckUrl.empty()) {
global::versionChecker->requestLatestVersion(versionCheckUrl);
}
// Check the required OpenGL versions of the registered modules
ghoul::systemcapabilities::Version version =

View File

@@ -538,8 +538,7 @@ void logAllEvents(const Event* e) {
log(i, *static_cast<const CustomEvent*>(e));
break;
default:
LINFO(fmt::format("[{}]: Unknown {}", typeid(e).name()));
break;
throw ghoul::MissingCaseException();
}
i++;

View File

@@ -58,6 +58,7 @@
#include <ghoul/io/model/modelreader.h>
#include <ghoul/io/model/modelreaderassimp.h>
#include <ghoul/io/model/modelreaderbinary.h>
#include <ghoul/io/texture/texturereaderstb.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/easing.h>
#include <ghoul/misc/profiling.h>
@@ -66,23 +67,6 @@
#include <ghoul/opengl/openglstatecache.h>
#include <ghoul/systemcapabilities/openglcapabilitiescomponent.h>
#ifdef GHOUL_USE_DEVIL
#include <ghoul/io/texture/texturereaderdevil.h>
#endif // GHOUL_USE_DEVIL
#ifdef GHOUL_USE_FREEIMAGE
#include <ghoul/io/texture/texturereaderfreeimage.h>
#endif // GHOUL_USE_FREEIMAGE
#ifdef GHOUL_USE_SOIL
#include <ghoul/io/texture/texturereadersoil.h>
#include <ghoul/io/texture/texturewriter.h>
#include <ghoul/io/texture/texturewritersoil.h>
#endif // GHOUL_USE_SOIL
#ifdef GHOUL_USE_STB_IMAGE
#include <ghoul/io/texture/texturereaderstb.h>
#endif // GHOUL_USE_STB_IMAGE
#include "renderengine_lua.inl"
namespace {
@@ -427,29 +411,9 @@ void RenderEngine::initialize() {
_disableMasterRendering = global::configuration->isRenderingOnMasterDisabled;
_screenshotUseDate = global::configuration->shouldUseScreenshotDate;
#ifdef GHOUL_USE_DEVIL
ghoul::io::TextureReader::ref().addReader(
std::make_unique<ghoul::io::TextureReaderDevIL>()
);
#endif // GHOUL_USE_DEVIL
#ifdef GHOUL_USE_FREEIMAGE
ghoul::io::TextureReader::ref().addReader(
std::make_unique<ghoul::io::TextureReaderFreeImage>()
);
#endif // GHOUL_USE_FREEIMAGE
#ifdef GHOUL_USE_SOIL
ghoul::io::TextureReader::ref().addReader(
std::make_unique<ghoul::io::TextureReaderSOIL>()
);
ghoul::io::TextureWriter::ref().addWriter(
std::make_unique<ghoul::io::TextureWriterSOIL>()
);
#endif // GHOUL_USE_SOIL
#ifdef GHOUL_USE_STB_IMAGE
ghoul::io::TextureReader::ref().addReader(
std::make_unique<ghoul::io::TextureReaderSTB>()
);
#endif // GHOUL_USE_STB_IMAGE
ghoul::io::TextureReader::ref().addReader(
std::make_unique<ghoul::io::TextureReaderCMAP>()

View File

@@ -863,13 +863,6 @@ scripting::LuaLibrary Scene::luaLibrary() {
"This is the same as calling the setValue method and passing 'single' as "
"the fourth argument to setPropertyValue."
},
{
"hasProperty",
&luascriptfunctions::propertyHasProperty,
{},
"",
"Returns whether a property with the given URI exists"
},
{
"getPropertyValue",
&luascriptfunctions::propertyGetValue,
@@ -877,14 +870,8 @@ scripting::LuaLibrary Scene::luaLibrary() {
"",
"Returns the value the property, identified by the provided URI."
},
{
"getProperty",
&luascriptfunctions::propertyGetProperty,
{},
"",
"Returns a list of property identifiers that match the passed regular "
"expression"
},
codegen::lua::HasProperty,
codegen::lua::GetProperty,
codegen::lua::AddCustomProperty,
codegen::lua::RemoveCustomProperty,
codegen::lua::AddSceneGraphNode,

View File

@@ -134,7 +134,6 @@ std::vector<openspace::properties::Property*> findMatchesInAllProperties(
// Stores whether we found at least one matching property. If this is false at the end
// of the loop, the property name regex was probably misspelled.
bool foundMatching = false;
for (properties::Property* prop : properties) {
// Check the regular expression for all properties
const std::string id = prop->fullyQualifiedIdentifier();
@@ -203,9 +202,6 @@ void applyRegularExpression(lua_State* L, const std::string& regex,
using ghoul::lua::errorLocation;
using ghoul::lua::luaTypeToString;
const bool isGroupMode = !groupName.empty();
bool isLiteral = false;
const int type = lua_type(L, -1);
std::vector<properties::Property*> matchingProps = findMatchesInAllProperties(
@@ -455,15 +451,6 @@ int propertySetValueSingle(lua_State* L) {
return propertySetValue(L);
}
int propertyHasProperty(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::propertyHasProperty");
const std::string uri = ghoul::lua::value<std::string>(L);
properties::Property* prop = property(uri);
ghoul::lua::push(L, prop != nullptr);
return 1;
}
int propertyGetValue(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::propertyGetValue");
const std::string uri = ghoul::lua::value<std::string>(L);
@@ -485,14 +472,23 @@ int propertyGetValue(lua_State* L) {
return 1;
}
} // namespace openspace::luascriptfunctions
namespace {
/**
* Returns whether a property with the given URI exists
*/
[[codegen::luawrap]] bool hasProperty(std::string uri) {
openspace::properties::Property* prop = openspace::property(uri);
return prop != nullptr;
}
/**
* \ingroup LuaScripts
* getProperty
* Returns a list of property identifiers that match the passed regular expression
*/
int propertyGetProperty(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::propertyGetProperty");
std::string regex = ghoul::lua::value<std::string>(L);
[[codegen::luawrap]] std::vector<std::string> getProperty(std::string regex) {
using namespace openspace;
std::string groupName;
if (doesUriContainGroupTag(regex, groupName)) {
@@ -511,26 +507,18 @@ int propertyGetProperty(lua_State* L) {
// If none then malformed regular expression
if (propertyName.empty() && nodeName.empty()) {
LERRORC(
"propertyGetProperty",
fmt::format(
"Malformed regular expression: '{}': Empty both before and after '*'",
regex
)
);
return 0;
throw ghoul::lua::LuaError(fmt::format(
"Malformed regular expression: '{}': Empty both before and after '*'",
regex
));
}
// Currently do not support several wildcards
if (regex.find_first_of("*", wildPos + 1) != std::string::npos) {
LERRORC(
"propertyGetProperty",
fmt::format(
"Malformed regular expression: '{}': "
"Currently only one '*' is supported", regex
)
);
return 0;
throw ghoul::lua::LuaError(fmt::format(
"Malformed regular expression: '{}': Currently only one '*' is supported",
regex
));
}
}
// Literal or tag
@@ -602,20 +590,9 @@ int propertyGetProperty(lua_State* L) {
res.push_back(id);
}
lua_newtable(L);
int number = 1;
for (const std::string& s : res) {
ghoul::lua::push(L, s);
lua_rawseti(L, -2, number);
++number;
}
return 1;
return res;
}
} // namespace openspace::luascriptfunctions
namespace {
/**
* Loads the SceneGraphNode described in the table and adds it to the SceneGraph.
*/

View File

@@ -27,6 +27,7 @@
#include <openspace/openspace.h>
#include <ghoul/fmt.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/misc.h>
#include <ghoul/systemcapabilities/systemcapabilities.h>
#include <ghoul/systemcapabilities/generalcapabilitiescomponent.h>
#include <sstream>
@@ -44,14 +45,7 @@ VersionChecker::~VersionChecker() {
void VersionChecker::requestLatestVersion(const std::string& url) {
using GCC = ghoul::systemcapabilities::GeneralCapabilitiesComponent;
std::string operatingSystem = SysCap.component<GCC>().operatingSystemString();
// Need to escape non-http characters when passing the operating system in the url
for (size_t i = 0; i < operatingSystem.size(); i++) {
if (operatingSystem[i] == ' ') {
operatingSystem.erase(i, 1);
operatingSystem.insert(i, "%20");
}
}
operatingSystem = ghoul::encodeUrl(operatingSystem);
std::string fullUrl = fmt::format(
"{}?client_version={}&commit_hash={}&operating_system={}",

View File

@@ -23,7 +23,7 @@
##########################################################################################
function (set_openspace_compile_settings target)
target_compile_features(${target} PRIVATE cxx_std_17)
target_compile_features(${target} PRIVATE cxx_std_20)
set(MSVC_WARNINGS
"/MP" # Multi-threading support