Merge branch 'master' into feature/horizons-framework

This commit is contained in:
Malin E
2022-03-30 13:52:03 +02:00
64 changed files with 3189 additions and 156 deletions
@@ -235,6 +235,8 @@ void RenderableBoxGrid::update(const UpdateData&) {
_varray.push_back({ v7.x, v7.y, v7.z });
_varray.push_back({ v3.x, v3.y, v3.z });
setBoundingSphere(glm::length(glm::dvec3(urb)));
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(
@@ -243,6 +243,8 @@ void RenderableGrid::update(const UpdateData&) {
_varray[nr++] = { halfSize.x, y1, 0.f };
}
setBoundingSphere(glm::length(glm::dvec2(halfSize)));
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(
@@ -274,6 +274,8 @@ void RenderableRadialGrid::update(const UpdateData&) {
}
_lines.update();
setBoundingSphere(static_cast<double>(outerRadius));
_gridIsDirty = false;
}
@@ -103,6 +103,9 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
_lineWidth = p.lineWidth.value_or(_lineWidth);
addProperty(_lineWidth);
// Radius is always 1
setBoundingSphere(1.0);
}
bool RenderableSphericalGrid::isReady() const {
@@ -460,6 +460,9 @@ bool RenderableDUMeshes::readSpeckFile() {
return false;
}
const float scale = static_cast<float>(toMeter(_unit));
double maxRadius = 0.0;
int meshIndex = 0;
// The beginning of the speck file has a header that either contains comments
@@ -540,23 +543,55 @@ bool RenderableDUMeshes::readSpeckFile() {
// We can now read the vertices data:
for (int l = 0; l < mesh.numU * mesh.numV; ++l) {
std::getline(file, line);
if (line.substr(0, 1) != "}") {
std::stringstream lineData(line);
for (int i = 0; i < 7; ++i) {
GLfloat value;
lineData >> value;
bool errorReading = lineData.rdstate() & std::ifstream::failbit;
if (!errorReading) {
mesh.vertices.push_back(value);
}
else {
break;
}
}
}
else {
if (line.substr(0, 1) == "}") {
break;
}
std::stringstream lineData(line);
// Try to read three values for the position
glm::vec3 pos;
bool success = true;
for (int i = 0; i < 3; ++i) {
GLfloat value;
lineData >> value;
bool errorReading = lineData.rdstate() & std::ifstream::failbit;
if (errorReading) {
success = false;
break;
}
GLfloat scaledValue = value * scale;
pos[i] = scaledValue;
mesh.vertices.push_back(scaledValue);
}
if (!success) {
LERROR(fmt::format(
"Failed reading position on line {} of mesh {} in file: '{}'. "
"Stopped reading mesh data", l, meshIndex, _speckFile
));
break;
}
// Check if new max radius
const double r = glm::length(glm::dvec3(pos));
maxRadius = std::max(maxRadius, r);
// OLD CODE:
// (2022-03-23, emmbr) None of our files included texture coordinates,
// and if they would they would still not be used by the shader
//for (int i = 0; i < 7; ++i) {
// GLfloat value;
// lineData >> value;
// bool errorReading = lineData.rdstate() & std::ifstream::failbit;
// if (!errorReading) {
// mesh.vertices.push_back(value);
// }
// else {
// break;
// }
//}
}
std::getline(file, line);
@@ -569,6 +604,8 @@ bool RenderableDUMeshes::readSpeckFile() {
}
}
setBoundingSphere(maxRadius);
return true;
}
@@ -579,12 +616,6 @@ void RenderableDUMeshes::createMeshes() {
LDEBUG("Creating planes");
for (std::pair<const int, RenderingMesh>& p : _renderingMeshesMap) {
float scale = static_cast<float>(toMeter(_unit));
for (GLfloat& v : p.second.vertices) {
v *= scale;
}
for (int i = 0; i < p.second.numU; ++i) {
GLuint vao;
glGenVertexArrays(1, &vao);
@@ -605,29 +636,32 @@ void RenderableDUMeshes::createMeshes() {
);
// in_position
glEnableVertexAttribArray(0);
// U and V may not be given by the user
if (p.second.vertices.size() / (p.second.numU * p.second.numV) > 3) {
glVertexAttribPointer(
0,
3,
GL_FLOAT,
GL_FALSE,
sizeof(GLfloat) * 5,
reinterpret_cast<GLvoid*>(sizeof(GLfloat) * i * p.second.numV)
);
// (2022-03-23, emmbr) This code was actually never used. We only read three
// values per line and di not handle any texture cooridnates, even if there
// would have been some in the file
//// U and V may not be given by the user
//if (p.second.vertices.size() / (p.second.numU * p.second.numV) > 3) {
// glVertexAttribPointer(
// 0,
// 3,
// GL_FLOAT,
// GL_FALSE,
// sizeof(GLfloat) * 5,
// reinterpret_cast<GLvoid*>(sizeof(GLfloat) * i * p.second.numV)
// );
// texture coords
glEnableVertexAttribArray(1);
glVertexAttribPointer(
1,
2,
GL_FLOAT,
GL_FALSE,
sizeof(GLfloat) * 7,
reinterpret_cast<GLvoid*>(sizeof(GLfloat) * 3 * i * p.second.numV)
);
}
else { // no U and V:
// // texture coords
// glEnableVertexAttribArray(1);
// glVertexAttribPointer(
// 1,
// 2,
// GL_FLOAT,
// GL_FALSE,
// sizeof(GLfloat) * 7,
// reinterpret_cast<GLvoid*>(sizeof(GLfloat) * 3 * i * p.second.numV)
// );
//}
//else { // no U and V:
glVertexAttribPointer(
0,
3,
@@ -636,7 +670,7 @@ void RenderableDUMeshes::createMeshes() {
0,
reinterpret_cast<GLvoid*>(sizeof(GLfloat) * 3 * i * p.second.numV)
);
}
//}
}
// Grid: we need columns
@@ -397,12 +397,17 @@ std::vector<double> RenderablePoints::createDataSlice() {
slice.reserve(4 * _dataset.entries.size());
}
double maxRadius = 0.0;
int colorIndex = 0;
for (const speck::Dataset::Entry& e : _dataset.entries) {
glm::dvec3 p = e.position;
double scale = toMeter(_unit);
p *= scale;
const double r = glm::length(p);
maxRadius = std::max(maxRadius, r);
glm::dvec4 position(p, 1.0);
if (_hasColorMapFile) {
@@ -423,6 +428,7 @@ std::vector<double> RenderablePoints::createDataSlice() {
0 :
colorIndex + 1;
}
setBoundingSphere(maxRadius);
return slice;
}
@@ -48,6 +48,7 @@
#include <ghoul/opengl/texture.h>
#include <ghoul/opengl/textureunit.h>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/component_wise.hpp>
#include <filesystem>
#include <fstream>
#include <optional>
@@ -318,6 +319,10 @@ RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary)
_downScaleVolumeRendering.setVisibility(properties::Property::Visibility::Developer);
addProperty(_downScaleVolumeRendering);
addProperty(_numberOfRayCastingSteps);
// Use max component instead of length, to avoid problems with taking square
// of huge value
setBoundingSphere(glm::compMax(0.5f * _volumeSize));
}
void RenderableGalaxy::initialize() {
@@ -716,7 +716,7 @@ scripting::LuaLibrary GlobeBrowsingModule::luaLibrary() const {
codegen::lua::GetGeoPositionForCamera,
codegen::lua::LoadWMSCapabilities,
codegen::lua::RemoveWMSServer,
codegen::lua::Capabilities
codegen::lua::CapabilitiesWMS
};
res.scripts = {
absPath("${MODULE_GLOBEBROWSING}/scripts/layer_support.lua")
@@ -437,7 +437,7 @@ getLocalPositionFromGeo(std::string globeIdentifier, double latitude, double lon
* can be used in the 'FilePath' argument for a call to the 'addLayer' function to add the
* value to a globe.
*/
[[codegen::luawrap]] std::vector<ghoul::Dictionary> capabilities(std::string name) {
[[codegen::luawrap]] std::vector<ghoul::Dictionary> capabilitiesWMS(std::string name) {
using namespace openspace;
using namespace globebrowsing;
@@ -131,8 +131,9 @@ void DashboardItemInstruments::render(glm::vec2& penPosition) {
double previous = sequencer.prevCaptureTime(currentTime);
double next = sequencer.nextCaptureTime(currentTime);
double remaining = sequencer.nextCaptureTime(currentTime) - currentTime;
const float t = static_cast<float>(1.0 - remaining / (next - previous));
double remaining = next - currentTime;
float t = static_cast<float>(1.0 - remaining / (next - previous));
t = std::clamp(t, 0.f, 1.f);
if (remaining > 0.0) {
RenderFont(
+36 -22
View File
@@ -55,14 +55,15 @@ cmake_policy(SET CMP0074 NEW)
# Specify the CEF distribution version.
# Release from 04/24/2019 verified to work on Windows.
set(CEF_VERSION "73.1.13+g6e3c989+chromium-73.0.3683.75")
# Release from 03/21/2022 verified to work on Windows.
set(CEF_VERSION "91.1.23+g04c8d56+chromium-91.0.4472.164")
# 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 ()
#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)
@@ -128,7 +129,9 @@ set(WEBBROWSER_SOURCES ${WEBBROWSER_SOURCES} ${WEBBROWSER_RESOURCES_SOURCES})
# CEF helper sources
set(WEBBROWSER_HELPER_SOURCES src/webbrowserapp.cpp)
set(WEBBROWSER_HELPER_SOURCES_MACOSX src/processhelpermac.cpp)
if (OS_MACOSX)
list(APPEND WEBBROWSER_HELPER_SOURCES src/processhelpermac.cpp)
endif()
set(WEBBROWSER_HELPER_SOURCES_WINDOWS src/processhelperwindows.cpp)
APPEND_PLATFORM_SOURCES(WEBBROWSER_HELPER_SOURCES)
@@ -151,30 +154,41 @@ set(WEBBROWSER_RESOURCES_SRCS
# Place Helper in separate executable
# The naming style "<ApplicionName> Helper" is required by Chromium.
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")
#
# CEF platform-specific config
#
list(APPEND Targets ${CEF_HELPER_TARGET} ${CEF_HELPER_TARGET_GPU} ${CEF_HELPER_TARGET_RENDERER})
if (OS_MACOSX)
# Helper executable target.
add_executable(${CEF_HELPER_TARGET} MACOSX_BUNDLE ${WEBBROWSER_HELPER_SOURCES})
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_HELPER_TARGET})
# add_cef_logical_target("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}")
add_dependencies(${CEF_HELPER_TARGET} libcef_dll_wrapper)
target_link_libraries(${CEF_HELPER_TARGET} libcef_dll_wrapper ${CEF_STANDARD_LIBS})
set_target_properties(${CEF_HELPER_TARGET} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/helper-Info.plist
)
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})
# 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})
set_target_properties(${target} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/helper-Info.plist
)
target_compile_options(${CEF_HELPER_TARGET} PRIVATE -Wno-deprecated-declarations)
target_compile_options(libcef_dll_wrapper PRIVATE -Wno-deprecated-declarations)
target_compile_options(${target} PRIVATE -Wno-deprecated-declarations)
target_compile_options(libcef_dll_wrapper PRIVATE -Wno-deprecated-declarations)
if (USE_SANDBOX)
# Logical target used to link the cef_sandbox library.
target_link_libraries(${target} cef_sandbox_lib)
endif ()
endforeach()
set_property(TARGET ${CEF_HELPER_TARGET_GPU} PROPERTY FOLDER "Helper")
set_property(TARGET ${CEF_HELPER_TARGET_RENDERER} PROPERTY FOLDER "Helper")
if (USE_SANDBOX)
# Logical target used to link the cef_sandbox library.
ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}")
target_link_libraries(${CEF_HELPER_TARGET} cef_sandbox_lib)
endif ()
endif ()
if (OS_WINDOWS)
@@ -100,7 +100,7 @@ if(OS_LINUX)
-fno-rtti # Disable real-time type information
-fno-threadsafe-statics # Don't generate thread-safe statics
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
-std=gnu++11 # Use the C++11 language standard including GNU extensions
-std=gnu++14 # Use the C++14 language standard including GNU extensions
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
)
list(APPEND CEF_COMPILER_FLAGS_DEBUG
@@ -259,7 +259,7 @@ if(OS_MACOSX)
-fno-threadsafe-statics # Don't generate thread-safe statics
-fobjc-call-cxx-cdtors # Call the constructor/destructor of C++ instance variables in ObjC objects
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
-std=gnu++11 # Use the C++11 language standard including GNU extensions
-std=gnu++14 # Use the C++14 language standard including GNU extensions
-Wno-narrowing # Don't warn about type narrowing
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
)
@@ -456,12 +456,10 @@ if(OS_WINDOWS)
# List of CEF binary files.
set(CEF_BINARY_FILES
chrome_elf.dll
d3dcompiler_43.dll
d3dcompiler_47.dll
libcef.dll
libEGL.dll
libGLESv2.dll
natives_blob.bin
snapshot_blob.bin
v8_context_snapshot.bin
#swiftshader
@@ -469,11 +467,9 @@ if(OS_WINDOWS)
# List of CEF resource files.
set(CEF_RESOURCE_FILES
cef.pak
cef_100_percent.pak
cef_200_percent.pak
cef_extensions.pak
devtools_resources.pak
chrome_100_percent.pak
chrome_200_percent.pak
resources.pak
icudtl.dat
locales
)
@@ -69,12 +69,16 @@ function(run_cef_macosx_config CEF_ROOT module_path)
set(CEF_FINAL_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CEF_OUTPUT_PREFIX}${CEF_TARGET}.app")
set(CEF_INTERMEDIATE_HELPER_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CEF_OUTPUT_PREFIX}${CEF_HELPER_TARGET}.app")
set(CEF_INTERMEDIATE_HELPER_APP_GPU "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CEF_OUTPUT_PREFIX}${CEF_HELPER_TARGET_GPU}.app")
set(CEF_INTERMEDIATE_HELPER_APP_RENDERER "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CEF_OUTPUT_PREFIX}${CEF_HELPER_TARGET_RENDERER}.app")
set(CEF_FINAL_HELPER_APP "${CEF_FINAL_APP}/Contents/Frameworks/${CEF_HELPER_TARGET}.app")
set(CEF_FINAL_HELPER_APP_GPU "${CEF_FINAL_APP}/Contents/Frameworks/${CEF_HELPER_TARGET_GPU}.app")
set(CEF_FINAL_HELPER_APP_RENDERER "${CEF_FINAL_APP}/Contents/Frameworks/${CEF_HELPER_TARGET_RENDERER}.app")
set(CEF_FRAMEWORK_LOCATION "${CEF_BINARY_DIR}/Chromium Embedded Framework.framework")
set(CEF_FRAMEWORK_FINAL_LOCATION "${CEF_FINAL_APP}/Contents/Frameworks/Chromium Embedded Framework.framework")
add_dependencies(${CEF_TARGET} libcef_dll_wrapper "${CEF_HELPER_TARGET}")
add_dependencies(${CEF_TARGET} libcef_dll_wrapper "${CEF_HELPER_TARGET}" "${CEF_HELPER_TARGET_GPU}" "${CEF_HELPER_TARGET_RENDERER}")
# target_link_libraries(${CEF_TARGET} PUBLIC libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
target_link_libraries(${CEF_TARGET} PUBLIC libcef_dll_wrapper ${CEF_STANDARD_LIBS})
@@ -89,6 +93,8 @@ function(run_cef_macosx_config CEF_ROOT module_path)
POST_BUILD
# Copy the helper app bundle into the Frameworks directory.
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CEF_INTERMEDIATE_HELPER_APP}" "${CEF_FINAL_HELPER_APP}"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CEF_INTERMEDIATE_HELPER_APP_GPU}" "${CEF_FINAL_HELPER_APP_GPU}"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CEF_INTERMEDIATE_HELPER_APP_RENDERER}" "${CEF_FINAL_HELPER_APP_RENDERER}"
# Copy the CEF framework into the Frameworks directory.
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CEF_FRAMEWORK_LOCATION}" "${CEF_FRAMEWORK_FINAL_LOCATION}"
VERBATIM
@@ -41,11 +41,17 @@ namespace openspace {
class DefaultBrowserLauncher : public CefLifeSpanHandler, public CefRequestHandler {
public:
bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
const CefString& targetUrl, const CefString& targetFrameName,
CefLifeSpanHandler::WindowOpenDisposition targetDisposition, bool userGesture,
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client, CefBrowserSettings& settings,
bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& targetUrl,
const CefString& targetFrameName,
CefLifeSpanHandler::WindowOpenDisposition targetDisposition,
bool userGesture,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue>& extra_info,
bool* noJavascriptAccess) override;
//bool OnOpenURLFromTab(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
+2 -1
View File
@@ -48,7 +48,7 @@ BrowserInstance::BrowserInstance(WebRenderHandler* renderer,
: _renderHandler(renderer)
, _keyboardHandler(keyboardHandler)
{
_client = new BrowserClient(_renderHandler, _keyboardHandler);
_client = new BrowserClient(_renderHandler.get(), _keyboardHandler.get());
CefWindowInfo windowInfo;
windowInfo.SetAsWindowless(nullptr);
@@ -62,6 +62,7 @@ BrowserInstance::BrowserInstance(WebRenderHandler* renderer,
_client.get(),
url,
browserSettings,
nullptr,
nullptr
);
@@ -38,6 +38,7 @@ bool DefaultBrowserLauncher::OnBeforePopup(CefRefPtr<CefBrowser>, CefRefPtr<CefF
CefLifeSpanHandler::WindowOpenDisposition,
bool, const CefPopupFeatures&, CefWindowInfo&,
CefRefPtr<CefClient>&, CefBrowserSettings&,
CefRefPtr<CefDictionaryValue>&,
bool*)
{
// never permit CEF popups, always launch in default browser
@@ -94,8 +94,8 @@ ScreenSpaceBrowser::ScreenSpaceBrowser(const ghoul::Dictionary& dictionary)
_renderHandler = new ScreenSpaceRenderHandler;
_keyboardHandler = new WebKeyboardHandler();
_browserInstance = std::make_unique<BrowserInstance>(
_renderHandler,
_keyboardHandler
_renderHandler.get(),
_keyboardHandler.get()
);
_url.onChange([this]() { _isUrlDirty = true; });
+4 -2
View File
@@ -42,8 +42,10 @@ void WebBrowserApp::OnContextCreated(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>,
void WebBrowserApp::OnBeforeCommandLineProcessing(const CefString&,
CefRefPtr<CefCommandLine> commandLine)
{
commandLine->AppendSwitch("disable-gpu");
commandLine->AppendSwitch("disable-gpu-compositing");
commandLine->AppendSwitch("use-gl=desktop");
commandLine->AppendSwitch("ignore-gpu-blacklist");
commandLine->AppendSwitch("log-gpu-control-list-decisions");
commandLine->AppendSwitch("use-mock-keychain");
commandLine->AppendSwitch("enable-begin-frame-scheduling");
commandLine->AppendSwitchWithValue("autoplay-policy", "no-user-gesture-required");
}