mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 10:40:09 -06:00
Merge branch 'master' into thesis/2020/software-integration
This commit is contained in:
@@ -203,6 +203,12 @@ begin_header("Configuring Applications")
|
||||
add_subdirectory("${OPENSPACE_APPS_DIR}")
|
||||
end_header("End: Configuring Applications")
|
||||
|
||||
|
||||
if (MSVC AND TARGET OpenSpace)
|
||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT OpenSpace)
|
||||
endif()
|
||||
|
||||
|
||||
option(OPENSPACE_HAVE_TESTS "Activate the OpenSpace unit tests" ON)
|
||||
if (OPENSPACE_HAVE_TESTS)
|
||||
begin_header("Generating OpenSpace unit test")
|
||||
|
||||
@@ -660,6 +660,17 @@ void mainCharCallback(unsigned int codepoint, int modifiers) {
|
||||
|
||||
|
||||
|
||||
void mainDropCallback(int amount, const char** paths) {
|
||||
ghoul_assert(amount > 0, "Expected at least one file path");
|
||||
ghoul_assert(paths, "expected non-nullptr");
|
||||
|
||||
for (int i = 0; i < amount; ++i) {
|
||||
global::openSpaceEngine->handleDragDrop(paths[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<std::byte> mainEncodeFun() {
|
||||
ZoneScoped
|
||||
LTRACE("main::mainEncodeFun(begin)");
|
||||
@@ -1252,6 +1263,7 @@ int main(int argc, char* argv[]) {
|
||||
callbacks.mousePos = mainMousePosCallback;
|
||||
callbacks.mouseScroll = mainMouseScrollCallback;
|
||||
callbacks.character = mainCharCallback;
|
||||
callbacks.drop = mainDropCallback;
|
||||
callbacks.encode = mainEncodeFun;
|
||||
callbacks.decode = mainDecodeFun;
|
||||
Log::instance().setNotifyLevel(Log::Level::Debug);
|
||||
|
||||
@@ -11,7 +11,8 @@ local HabitableZone = {
|
||||
Texture = textures .. "/hot_to_cold_faded.png",
|
||||
EffectiveTemperature = 5780, -- Kelvin
|
||||
Luminosity = 1, -- solar
|
||||
Opacity = 0.1
|
||||
Opacity = 0.1,
|
||||
Optimistic = true
|
||||
},
|
||||
GUI = {
|
||||
Name = "Sun Habitable Zone",
|
||||
|
||||
Submodule ext/ghoul updated: 2f1bb7c483...6cc191d429
@@ -86,6 +86,7 @@ public:
|
||||
void touchDetectionCallback(TouchInput input);
|
||||
void touchUpdateCallback(TouchInput input);
|
||||
void touchExitCallback(TouchInput input);
|
||||
void handleDragDrop(const std::string& file);
|
||||
std::vector<std::byte> encode();
|
||||
void decode(std::vector<std::byte> data);
|
||||
|
||||
|
||||
@@ -438,13 +438,11 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
);
|
||||
_program->setUniform(
|
||||
_uniformCache.lightIntensities,
|
||||
_lightIntensitiesBuffer.data(),
|
||||
nLightSources
|
||||
_lightIntensitiesBuffer
|
||||
);
|
||||
_program->setUniform(
|
||||
_uniformCache.lightDirectionsViewSpace,
|
||||
_lightDirectionsViewSpaceBuffer.data(),
|
||||
nLightSources
|
||||
_lightDirectionsViewSpaceBuffer
|
||||
);
|
||||
_program->setUniform(
|
||||
_uniformCache.modelViewTransform,
|
||||
|
||||
@@ -407,7 +407,7 @@ float ExoplanetsDataPreparationTask::bvFromTeff(float teff) {
|
||||
float bv = 0.f;
|
||||
float bvUpper = 0.f;
|
||||
float bvLower = 0.f;
|
||||
float teffLower;
|
||||
float teffLower = 0.f;
|
||||
float teffUpper;
|
||||
std::string row;
|
||||
while (std::getline(teffToBvFile, row)) {
|
||||
|
||||
@@ -67,8 +67,8 @@
|
||||
#include "globebrowsingmodule_lua.inl"
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "GlobeBrowsingModule";
|
||||
constexpr const char* _factoryName = "TileProvider";
|
||||
constexpr const char _loggerCat[] = "GlobeBrowsingModule";
|
||||
constexpr const char _factoryName[] = "TileProvider";
|
||||
|
||||
constexpr const openspace::properties::Property::PropertyInfo WMSCacheEnabledInfo = {
|
||||
"WMSCacheEnabled",
|
||||
@@ -163,19 +163,19 @@ namespace {
|
||||
struct [[codegen::Dictionary(GlobeBrowsingModule)]] Parameters {
|
||||
// [[codegen::verbatim(WMSCacheEnabledInfo.description)]]
|
||||
std::optional<bool> cacheEnabled [[codegen::key("WMSCacheEnabled")]];
|
||||
|
||||
|
||||
// [[codegen::verbatim(OfflineModeInfo.description)]]
|
||||
std::optional<bool> offlineMode;
|
||||
|
||||
|
||||
// [[codegen::verbatim(WMSCacheLocationInfo.description)]]
|
||||
std::optional<std::string> cacheLocation [[codegen::key("WMSCacheLocation")]];
|
||||
|
||||
|
||||
// [[codegen::verbatim(WMSCacheSizeInfo.description)]]
|
||||
std::optional<int> wmsCacheSize [[codegen::key("WMSCacheSize")]];
|
||||
|
||||
|
||||
// [[codegen::verbatim(TileCacheSizeInfo.description)]]
|
||||
std::optional<int> tileCacheSize;
|
||||
|
||||
|
||||
// If you know what you are doing and you have WMS caching *disabled* but offline
|
||||
// mode *enabled*, you can set this value to 'true' to silence a warning that you
|
||||
// would otherwise get at startup
|
||||
|
||||
@@ -69,10 +69,10 @@ namespace {
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo KopparapuTeffIntervalInfo = {
|
||||
"KopparapuTeffInterval",
|
||||
"Effective Temperature Interval (Kopparapu's formula)" ,
|
||||
"The range for which Kopparapu's formula is used for the habitable zone "
|
||||
"computation. For stars with effective temperatures outside the range, a "
|
||||
"simpler method by Tom E. Harris is used. This method only uses the star "
|
||||
"Kopparapu TEFF" ,
|
||||
"The effective temperature interval for which Kopparapu's formula is used for "
|
||||
"the habitable zone computation. For stars with temperatures outside the range, "
|
||||
"a simpler method by Tom E. Harris is used. This method only uses the star "
|
||||
"luminosity and does not include computation of the optimistic boundaries."
|
||||
};
|
||||
} // namespace
|
||||
@@ -130,7 +130,7 @@ RenderableHabitableZone::RenderableHabitableZone(const ghoul::Dictionary& dictio
|
||||
, _teff(EffectiveTemperatureInfo, 5780.f, 0.f, 7.5e4f)
|
||||
, _luminosity(LuminosityInfo, 1.f, 0.f, 1e8f)
|
||||
, _showOptimistic(OptimisticInfo, false)
|
||||
, _kopparapuTeffInterval(KopparapuTeffIntervalInfo, glm::vec2(2000.f, 8000.f))
|
||||
, _kopparapuTeffInterval(KopparapuTeffIntervalInfo, glm::vec2(1000.f, 10000.f))
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
|
||||
@@ -481,7 +481,7 @@ void RenderablePlanetProjection::imageProjectGPU(
|
||||
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);
|
||||
_fboProgramObject->setUniform(_fboUniformCache.radius, *radius);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -135,8 +135,8 @@ void BasicVolumeRaycaster::preRaycast(const RaycastData& data,
|
||||
int nClips = static_cast<int>(clipNormals.size());
|
||||
|
||||
program.setUniform("nClips_" + id, nClips);
|
||||
program.setUniform("clipNormals_" + id, clipNormals.data(), nClips);
|
||||
program.setUniform("clipOffsets_" + id, clipOffsets.data(), nClips);
|
||||
program.setUniform("clipNormals_" + id, clipNormals);
|
||||
program.setUniform("clipOffsets_" + id, clipOffsets);
|
||||
program.setUniform("opacity_" + id, _opacity);
|
||||
program.setUniform("rNormalization_" + id, _rNormalization);
|
||||
program.setUniform("rUpperBound_" + id, _rUpperBound);
|
||||
|
||||
@@ -101,11 +101,15 @@ void GenerateRawVolumeTask::perform(const Task::ProgressCallback& progressCallba
|
||||
ghoul::lua::LuaState state;
|
||||
ghoul::lua::runScript(state, _valueFunctionLua);
|
||||
|
||||
#if (defined(NDEBUG) || defined(DEBUG))
|
||||
ghoul::lua::verifyStackSize(state, 1);
|
||||
#endif
|
||||
|
||||
int functionReference = luaL_ref(state, LUA_REGISTRYINDEX);
|
||||
|
||||
#if (defined(NDEBUG) || defined(DEBUG))
|
||||
ghoul::lua::verifyStackSize(state, 0);
|
||||
#endif
|
||||
|
||||
glm::vec3 domainSize = _upperDomainBound - _lowerDomainBound;
|
||||
|
||||
@@ -117,14 +121,18 @@ void GenerateRawVolumeTask::perform(const Task::ProgressCallback& progressCallba
|
||||
glm::vec3 coord = _lowerDomainBound +
|
||||
glm::vec3(cell) / glm::vec3(_dimensions) * domainSize;
|
||||
|
||||
#if (defined(NDEBUG) || defined(DEBUG))
|
||||
ghoul::lua::verifyStackSize(state, 0);
|
||||
#endif
|
||||
lua_rawgeti(state, LUA_REGISTRYINDEX, functionReference);
|
||||
|
||||
lua_pushnumber(state, coord.x);
|
||||
lua_pushnumber(state, coord.y);
|
||||
lua_pushnumber(state, coord.z);
|
||||
|
||||
#if (defined(NDEBUG) || defined(DEBUG))
|
||||
ghoul::lua::verifyStackSize(state, 4);
|
||||
#endif
|
||||
|
||||
if (lua_pcall(state, 3, 1, 0) != LUA_OK) {
|
||||
return;
|
||||
|
||||
43
scripts/drag_drop_handler.lua
Normal file
43
scripts/drag_drop_handler.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
-- This script gets two parameters in its global scope:
|
||||
-- filename: The full path for the file that was dropped on the application.
|
||||
-- Example: C:/OpenSpace/openspace.cfg
|
||||
-- basename: Only the name of the actual file with extension, but without the full rest
|
||||
-- of the path.
|
||||
-- Example: openspace.cfg
|
||||
-- extension: The extention of the file
|
||||
-- Example: .cfg
|
||||
--
|
||||
-- From this script, we need to return the script that we want to be executed in response
|
||||
-- to the drag event. If we don't want anything to happen, don't return anything or
|
||||
-- return an empty string
|
||||
|
||||
if filename == nil or filename == "" or
|
||||
basename == nil or basename == "" or
|
||||
extension == nil or extension == "" then
|
||||
do return "" end
|
||||
end
|
||||
|
||||
-- Lua doesn't enjoy \ that are used by Windows extensively. So we convert all \ into /
|
||||
filename = filename:gsub("\\", "/")
|
||||
basename = basename:gsub("\\", "/")
|
||||
basename_without_extension = basename:sub(0, #basename - extension:len())
|
||||
|
||||
is_image_file = function(extension)
|
||||
return extension == ".png" or extension == ".jpg" or extension == ".jpeg" or
|
||||
extension == ".tif" or extension == ".tga" or extension == ".bmp" or
|
||||
extension == ".psd" or extension == ".gif" or extension == ".hdr" or
|
||||
extension == ".pic" or extension == ".pnm"
|
||||
end
|
||||
|
||||
if is_image_file(extension) then
|
||||
identifier = basename_without_extension:gsub(" ", "_")
|
||||
return [[openspace.addScreenSpaceRenderable({
|
||||
Identifier = "]] .. identifier .. [[",
|
||||
Type = "ScreenSpaceImageLocal",
|
||||
TexturePath = "]] .. filename .. [["
|
||||
});]]
|
||||
elseif extension == ".asset" then
|
||||
return [[openspace.asset.add("]] .. filename .. [[")]]
|
||||
elseif extension == ".osrec" or extension == ".osrectxt" then
|
||||
return [[openspace.sessionRecording.startPlayback("]] .. basename .. [[")]]
|
||||
end
|
||||
@@ -129,17 +129,20 @@ namespace openspace::documentation {
|
||||
|
||||
const std::string DocumentationEntry::Wildcard = "*";
|
||||
|
||||
std::string concatenate(const std::vector<TestResult::Offense>& offenses) {
|
||||
std::string result = "Error in specification (";
|
||||
for (const TestResult::Offense& o : offenses) {
|
||||
result += o.offender + ',';
|
||||
}
|
||||
result.back() = ')';
|
||||
return result;
|
||||
}
|
||||
|
||||
SpecificationError::SpecificationError(TestResult res, std::string comp)
|
||||
: ghoul::RuntimeError("Error in specification", std::move(comp))
|
||||
: ghoul::RuntimeError(concatenate(res.offenses), std::move(comp))
|
||||
, result(std::move(res))
|
||||
{
|
||||
ghoul_assert(!result.success, "Result's success must be false");
|
||||
|
||||
message += " (";
|
||||
for (const TestResult::Offense& o : result.offenses) {
|
||||
message += o.offender + ',';
|
||||
}
|
||||
message.back() = ')';
|
||||
}
|
||||
|
||||
DocumentationEntry::DocumentationEntry(std::string k, std::shared_ptr<Verifier> v,
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
#include <ghoul/systemcapabilities/openglcapabilitiescomponent.h>
|
||||
#include <glbinding/glbinding.h>
|
||||
#include <glbinding-aux/types_to_string.h>
|
||||
#include <filesystem>
|
||||
#include <future>
|
||||
#include <numeric>
|
||||
#include <sstream>
|
||||
@@ -1444,6 +1445,52 @@ void OpenSpaceEngine::touchExitCallback(TouchInput input) {
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::handleDragDrop(const std::string& file) {
|
||||
std::filesystem::path f(file);
|
||||
|
||||
ghoul::lua::LuaState s(ghoul::lua::LuaState::IncludeStandardLibrary::Yes);
|
||||
std::string absolutePath = absPath("${SCRIPTS}/drag_drop_handler.lua");
|
||||
int status = luaL_loadfile(s, absolutePath.c_str());
|
||||
if (status != LUA_OK) {
|
||||
std::string error = lua_tostring(s, -1);
|
||||
LERROR(error);
|
||||
return;
|
||||
}
|
||||
|
||||
ghoul::lua::push(s, file);
|
||||
lua_setglobal(s, "filename");
|
||||
|
||||
std::string basename = f.filename().string();
|
||||
ghoul::lua::push(s, basename);
|
||||
lua_setglobal(s, "basename");
|
||||
|
||||
std::string extension = f.extension().string();
|
||||
std::transform(
|
||||
extension.begin(), extension.end(),
|
||||
extension.begin(),
|
||||
[](char c) { return static_cast<char>(::tolower(c)); }
|
||||
);
|
||||
ghoul::lua::push(s, extension);
|
||||
lua_setglobal(s, "extension");
|
||||
|
||||
status = lua_pcall(s, 0, 1, 0);
|
||||
if (status != LUA_OK) {
|
||||
std::string error = lua_tostring(s, -1);
|
||||
LERROR(error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lua_isnil(s, -1)) {
|
||||
LWARNING(fmt::format("Unhandled file dropped: {}", file));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string script = ghoul::lua::value<std::string>(s);
|
||||
global::scriptEngine->queueScript(
|
||||
script,
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
|
||||
std::vector<std::byte> OpenSpaceEngine::encode() {
|
||||
ZoneScoped
|
||||
|
||||
@@ -45,6 +45,9 @@ SceneGraphNode* sceneGraphNode(const std::string& name) {
|
||||
|
||||
const Renderable* renderable(const std::string& name) {
|
||||
SceneGraphNode* node = sceneGraphNode(name);
|
||||
if (!node) {
|
||||
return nullptr;
|
||||
}
|
||||
return node->renderable();
|
||||
}
|
||||
|
||||
|
||||
@@ -203,6 +203,7 @@ function (set_openspace_compile_settings target)
|
||||
"-Wlogical-op"
|
||||
"-Wint-in-bool-context"
|
||||
"-Wno-deprecated-copy"
|
||||
"-Wno-float-equal"
|
||||
"-Wno-write-strings"
|
||||
"-Wnon-virtual-dtor"
|
||||
"-Wold-style-cast"
|
||||
|
||||
Reference in New Issue
Block a user