diff options
55 files changed, 704 insertions, 282 deletions
diff --git a/build_files/build_environment/cmake/openvdb.cmake b/build_files/build_environment/cmake/openvdb.cmake index f432ade7dd1..f27d3f408a8 100644 --- a/build_files/build_environment/cmake/openvdb.cmake +++ b/build_files/build_environment/cmake/openvdb.cmake @@ -20,6 +20,14 @@ if(BUILD_MODE STREQUAL Debug) set(BLOSC_POST _d) endif() +if(WIN32) + set(OPENVDB_SHARED ON) + set(OPENVDB_STATIC OFF) +else() + set(OPENVDB_SHARED OFF) + set(OPENVDB_STATIC ON) +endif() + set(OPENVDB_EXTRA_ARGS -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING} -DBoost_USE_MULTITHREADED=ON @@ -42,8 +50,10 @@ set(OPENVDB_EXTRA_ARGS -DOPENEXR_LIBRARYDIR=${LIBDIR}/openexr/lib # All libs live in openexr, even the ilmbase ones -DILMBASE_LIBRARYDIR=${LIBDIR}/openexr/lib - -DOPENVDB_CORE_SHARED=Off + -DOPENVDB_CORE_SHARED=${OPENVDB_SHARED} + -DOPENVDB_CORE_STATIC=${OPENVDB_STATIC} -DOPENVDB_BUILD_BINARIES=Off + -DCMAKE_DEBUG_POSTFIX=_d ) if(WIN32) @@ -87,13 +97,15 @@ if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(openvdb after_install COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openvdb/include ${HARVEST_TARGET}/openvdb/include - COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/libopenvdb.lib ${HARVEST_TARGET}/openvdb/lib/openvdb.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/openvdb.lib ${HARVEST_TARGET}/openvdb/lib/openvdb.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/bin/openvdb.dll ${HARVEST_TARGET}/openvdb/bin/openvdb.dll DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(openvdb after_install - COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/libopenvdb.lib ${HARVEST_TARGET}/openvdb/lib/openvdb_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/openvdb_d.lib ${HARVEST_TARGET}/openvdb/lib/openvdb_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/bin/openvdb_d.dll ${HARVEST_TARGET}/openvdb/bin/openvdb_d.dll DEPENDEES install ) endif() diff --git a/build_files/build_environment/patches/openvdb.diff b/build_files/build_environment/patches/openvdb.diff index a9360cbafd3..db4506025ea 100644 --- a/build_files/build_environment/patches/openvdb.diff +++ b/build_files/build_environment/patches/openvdb.diff @@ -1,6 +1,6 @@ diff -Naur orig/cmake/FindIlmBase.cmake openvdb/cmake/FindIlmBase.cmake ---- orig/cmake/FindIlmBase.cmake 2019-12-06 13:11:33 -0700 -+++ openvdb/cmake/FindIlmBase.cmake 2020-01-16 09:06:32 -0700 +--- orig/cmake/FindIlmBase.cmake 2019-12-06 12:11:33 -0700 ++++ openvdb/cmake/FindIlmBase.cmake 2020-08-12 12:48:44 -0600 @@ -225,6 +225,12 @@ list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "-${IlmBase_VERSION_MAJOR}_${IlmBase_VERSION_MINOR}.lib" @@ -15,8 +15,8 @@ diff -Naur orig/cmake/FindIlmBase.cmake openvdb/cmake/FindIlmBase.cmake if(ILMBASE_USE_STATIC_LIBS) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES diff -Naur orig/cmake/FindOpenEXR.cmake openvdb/cmake/FindOpenEXR.cmake ---- orig/cmake/FindOpenEXR.cmake 2019-12-06 13:11:33 -0700 -+++ openvdb/cmake/FindOpenEXR.cmake 2020-01-16 09:06:39 -0700 +--- orig/cmake/FindOpenEXR.cmake 2019-12-06 12:11:33 -0700 ++++ openvdb/cmake/FindOpenEXR.cmake 2020-08-12 12:48:44 -0600 @@ -218,6 +218,12 @@ list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES "-${OpenEXR_VERSION_MAJOR}_${OpenEXR_VERSION_MINOR}.lib" @@ -31,9 +31,20 @@ diff -Naur orig/cmake/FindOpenEXR.cmake openvdb/cmake/FindOpenEXR.cmake if(OPENEXR_USE_STATIC_LIBS) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES diff -Naur orig/openvdb/CMakeLists.txt openvdb/openvdb/CMakeLists.txt ---- orig/openvdb/CMakeLists.txt 2019-12-06 13:11:33 -0700 -+++ openvdb/openvdb/CMakeLists.txt 2020-01-16 08:56:25 -0700 -@@ -193,11 +193,12 @@ +--- orig/openvdb/CMakeLists.txt 2019-12-06 12:11:33 -0700 ++++ openvdb/openvdb/CMakeLists.txt 2020-08-12 14:12:26 -0600 +@@ -105,7 +105,9 @@ + # http://boost.2283326.n4.nabble.com/CMake-config-scripts-broken-in-1-70-td4708957.html + # https://github.com/boostorg/boost_install/commit/160c7cb2b2c720e74463865ef0454d4c4cd9ae7c + set(BUILD_SHARED_LIBS ON) +- set(Boost_USE_STATIC_LIBS OFF) ++ if(NOT WIN32) # blender links boost statically on windows ++ set(Boost_USE_STATIC_LIBS OFF) ++ endif() + endif() + + find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS iostreams system) +@@ -193,6 +195,7 @@ if(OPENVDB_DISABLE_BOOST_IMPLICIT_LINKING) add_definitions(-DBOOST_ALL_NO_LIB) endif() @@ -41,33 +52,69 @@ diff -Naur orig/openvdb/CMakeLists.txt openvdb/openvdb/CMakeLists.txt endif() # @todo Should be target definitions - if(WIN32) -- add_definitions(-D_WIN32 -DNOMINMAX -DOPENVDB_DLL) -+ add_definitions(-D_WIN32 -DNOMINMAX -DOPENVDB_STATICLIB) - endif() - - ##### Core library configuration -diff -Naur orig/openvdb/cmd/CMakeLists.txt openvdb/openvdb/cmd/CMakeLists.txt ---- orig/openvdb/cmd/CMakeLists.txt 2019-12-06 13:11:33 -0700 -+++ openvdb/openvdb/cmd/CMakeLists.txt 2020-01-16 08:56:25 -0700 -@@ -53,7 +53,7 @@ - endif() - - if(WIN32) -- add_definitions(-D_WIN32 -DNOMINMAX -DOPENVDB_DLL) -+ add_definitions(-D_WIN32 -DNOMINMAX -DOPENVDB_STATICLIB) - endif() - - # rpath handling -diff -Naur orig/openvdb/unittest/CMakeLists.txt openvdb/openvdb/unittest/CMakeLists.txt ---- orig/openvdb/unittest/CMakeLists.txt 2019-12-06 13:11:33 -0700 -+++ openvdb/openvdb/unittest/CMakeLists.txt 2020-01-16 08:56:25 -0700 -@@ -49,7 +49,7 @@ - endif() +@@ -383,7 +386,12 @@ + # imported targets. - if(WIN32) -- add_definitions(-D_WIN32 -DNOMINMAX -DOPENVDB_DLL) -+ add_definitions(-D_WIN32 -DNOMINMAX -DOPENVDB_STATICLIB) + if(OPENVDB_CORE_SHARED) +- add_library(openvdb_shared SHARED ${OPENVDB_LIBRARY_SOURCE_FILES}) ++ if(WIN32) ++ configure_file(version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY) ++ add_library(openvdb_shared SHARED ${OPENVDB_LIBRARY_SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) ++ else() ++ add_library(openvdb_shared SHARED ${OPENVDB_LIBRARY_SOURCE_FILES}) ++ endif() endif() - ##### VDB unit tests + if(OPENVDB_CORE_STATIC) +diff -Naur orig/openvdb/version.rc.in openvdb/openvdb/version.rc.in +--- orig/openvdb/version.rc.in 1969-12-31 17:00:00 -0700 ++++ openvdb/openvdb/version.rc.in 2020-08-12 14:15:01 -0600 +@@ -0,0 +1,48 @@ ++#include <winver.h> ++ ++#define VER_FILEVERSION @OpenVDB_MAJOR_VERSION@,@OpenVDB_MINOR_VERSION@,@OpenVDB_PATCH_VERSION@,0 ++#define VER_FILEVERSION_STR "@OpenVDB_MAJOR_VERSION@.@OpenVDB_MINOR_VERSION@.@OpenVDB_PATCH_VERSION@.0\0" ++ ++#define VER_PRODUCTVERSION @OpenVDB_MAJOR_VERSION@,@OpenVDB_MINOR_VERSION@,@OpenVDB_PATCH_VERSION@,0 ++#define VER_PRODUCTVERSION_STR "@OpenVDB_MAJOR_VERSION@.@OpenVDB_MINOR_VERSION@\0" ++ ++#ifndef DEBUG ++#define VER_DEBUG 0 ++#else ++#define VER_DEBUG VS_FF_DEBUG ++#endif ++ ++VS_VERSION_INFO VERSIONINFO ++FILEVERSION VER_FILEVERSION ++PRODUCTVERSION VER_PRODUCTVERSION ++FILEFLAGSMASK VS_FFI_FILEFLAGSMASK ++FILEFLAGS (VER_DEBUG) ++FILEOS VOS__WINDOWS32 ++FILETYPE VFT_DLL ++FILESUBTYPE VFT2_UNKNOWN ++BEGIN ++ BLOCK "StringFileInfo" ++ BEGIN ++ BLOCK "040904E4" ++ BEGIN ++ VALUE "FileDescription", "OpenVDB" ++ VALUE "FileVersion", VER_FILEVERSION_STR ++ VALUE "InternalName", "OpenVDB" ++ VALUE "ProductName", "OpenVDB" ++ VALUE "ProductVersion", VER_PRODUCTVERSION_STR ++ END ++ END ++ ++ BLOCK "VarFileInfo" ++ BEGIN ++ /* The following line should only be modified for localized versions. */ ++ /* It consists of any number of WORD,WORD pairs, with each pair */ ++ /* describing a language,codepage combination supported by the file. */ ++ /* */ ++ /* For example, a file might have values "0x409,1252" indicating that it */ ++ /* supports English language (0x409) in the Windows ANSI codepage (1252). */ ++ ++ VALUE "Translation", 0x409, 1252 ++ ++ END ++END diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 5949e761551..ace5de3330c 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -373,8 +373,9 @@ if(WITH_CYCLES_OSL) list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -force_load ${OSL_LIB_EXEC} ${OSL_LIB_QUERY}) find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include) find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin) + find_path(OSL_SHADER_DIR NAMES stdosl.h PATHS ${CYCLES_OSL}/shaders) - if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER) + if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER AND OSL_SHADER_DIR) set(OSL_FOUND TRUE) else() message(STATUS "OSL not found") diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index dfcd5d75444..b8af2dfc961 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -416,9 +416,6 @@ if(WITH_BOOST) if(WITH_INTERNATIONAL) list(APPEND boost_extra_libs locale) endif() - if(WITH_OPENVDB) - list(APPEND boost_extra_libs iostreams) - endif() set(Boost_USE_STATIC_RUNTIME ON) # prefix lib set(Boost_USE_MULTITHREADED ON) # suffix -mt set(Boost_USE_STATIC_LIBS ON) # suffix -s @@ -524,12 +521,11 @@ if(WITH_OPENCOLORIO) endif() if(WITH_OPENVDB) - set(BLOSC_LIBRARIES optimized ${LIBDIR}/blosc/lib/libblosc.lib debug ${LIBDIR}/blosc/lib/libblosc_d.lib) set(OPENVDB ${LIBDIR}/openVDB) set(OPENVDB_LIBPATH ${OPENVDB}/lib) set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include) - set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib ${BLOSC_LIBRARIES}) - set(OPENVDB_DEFINITIONS -DNOMINMAX -DOPENVDB_STATICLIB -D_USE_MATH_DEFINES) + set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib ) + set(OPENVDB_DEFINITIONS -DNOMINMAX -D_USE_MATH_DEFINES) endif() if(WITH_OPENIMAGEDENOISE) diff --git a/extern/mantaflow/CMakeLists.txt b/extern/mantaflow/CMakeLists.txt index 9f66b42c6bf..989f45c69b4 100644 --- a/extern/mantaflow/CMakeLists.txt +++ b/extern/mantaflow/CMakeLists.txt @@ -64,7 +64,9 @@ endif() if(WITH_OPENVDB) add_definitions(-DOPENVDB=1) - add_definitions(-DOPENVDB_STATICLIB) + if(NOT WIN32) + add_definitions(-DOPENVDB_STATICLIB) + endif() endif() if(WITH_OPENVDB_BLOSC) diff --git a/intern/cycles/render/mesh_volume.cpp b/intern/cycles/render/mesh_volume.cpp index 0b57243fec1..2ee51f4b732 100644 --- a/intern/cycles/render/mesh_volume.cpp +++ b/intern/cycles/render/mesh_volume.cpp @@ -555,6 +555,7 @@ void GeometryManager::create_volume_mesh(Mesh *mesh, Progress &progress) mesh->clear(true); mesh->reserve_mesh(vertices.size(), indices.size() / 3); mesh->used_shaders.push_back(volume_shader); + mesh->need_update_rebuild = true; for (size_t i = 0; i < vertices.size(); ++i) { mesh->add_vertex(vertices[i]); diff --git a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h index de8bf9f1a5a..24b42c08e8a 100644 --- a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h +++ b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h @@ -21,15 +21,13 @@ #pragma once #include <memory> +#include <optional> #include <string> #include <vector> #include "GHOST_Xr_openxr_includes.h" class GHOST_IXrGraphicsBinding { - friend std::unique_ptr<GHOST_IXrGraphicsBinding> GHOST_XrGraphicsBindingCreateFromType( - GHOST_TXrGraphicsBinding type); - public: union { #if defined(WITH_GHOST_X11) @@ -49,18 +47,17 @@ class GHOST_IXrGraphicsBinding { * \param r_requirement_info Return argument to retrieve an informal string on the requirements * to be met. Useful for error/debug messages. */ - virtual bool checkVersionRequirements(class GHOST_Context *ghost_ctx, + virtual bool checkVersionRequirements(class GHOST_Context &ghost_ctx, XrInstance instance, XrSystemId system_id, std::string *r_requirement_info) const = 0; - virtual void initFromGhostContext(class GHOST_Context *ghost_ctx) = 0; - virtual bool chooseSwapchainFormat(const std::vector<int64_t> &runtime_formats, - int64_t &r_result, - bool &r_is_rgb_format) const = 0; + virtual void initFromGhostContext(class GHOST_Context &ghost_ctx) = 0; + virtual std::optional<int64_t> chooseSwapchainFormat(const std::vector<int64_t> &runtime_formats, + bool &r_is_rgb_format) const = 0; virtual std::vector<XrSwapchainImageBaseHeader *> createSwapchainImages( uint32_t image_count) = 0; - virtual void submitToSwapchainImage(XrSwapchainImageBaseHeader *swapchain_image, - const GHOST_XrDrawViewInfo *draw_info) = 0; + virtual void submitToSwapchainImage(XrSwapchainImageBaseHeader &swapchain_image, + const GHOST_XrDrawViewInfo &draw_info) = 0; virtual bool needsUpsideDownDrawing(GHOST_Context &ghost_ctx) const = 0; protected: @@ -69,4 +66,4 @@ class GHOST_IXrGraphicsBinding { }; std::unique_ptr<GHOST_IXrGraphicsBinding> GHOST_XrGraphicsBindingCreateFromType( - GHOST_TXrGraphicsBinding type, GHOST_Context *ghost_ctx); + GHOST_TXrGraphicsBinding type, GHOST_Context &ghost_ctx); diff --git a/intern/ghost/intern/GHOST_Xr.cpp b/intern/ghost/intern/GHOST_Xr.cpp index dc63aac217c..2c94aaab430 100644 --- a/intern/ghost/intern/GHOST_Xr.cpp +++ b/intern/ghost/intern/GHOST_Xr.cpp @@ -31,7 +31,7 @@ GHOST_XrContextHandle GHOST_XrContextCreate(const GHOST_XrContextCreateInfo *create_info) { - GHOST_XrContext *xr_context = new GHOST_XrContext(create_info); + auto xr_context = std::make_unique<GHOST_XrContext>(create_info); /* TODO GHOST_XrContext's should probably be owned by the GHOST_System, which will handle context * creation and destruction. Try-catch logic can be moved to C-API then. */ @@ -40,12 +40,11 @@ GHOST_XrContextHandle GHOST_XrContextCreate(const GHOST_XrContextCreateInfo *cre } catch (GHOST_XrException &e) { xr_context->dispatchErrorMessage(&e); - delete xr_context; - return nullptr; } - return (GHOST_XrContextHandle)xr_context; + /* Give ownership to the caller. */ + return (GHOST_XrContextHandle)xr_context.release(); } void GHOST_XrContextDestroy(GHOST_XrContextHandle xr_contexthandle) diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp index 16687c34679..c5fe3c3c113 100644 --- a/intern/ghost/intern/GHOST_XrContext.cpp +++ b/intern/ghost/intern/GHOST_XrContext.cpp @@ -23,6 +23,7 @@ #include <cassert> #include <sstream> #include <string> +#include <string_view> #include "GHOST_Types.h" #include "GHOST_XrException.h" @@ -58,7 +59,7 @@ void *GHOST_XrContext::s_error_handler_customdata = nullptr; * \{ */ GHOST_XrContext::GHOST_XrContext(const GHOST_XrContextCreateInfo *create_info) - : m_oxr(new OpenXRInstanceData()), + : m_oxr(std::make_unique<OpenXRInstanceData>()), m_debug(create_info->context_flag & GHOST_kXrContextDebug), m_debug_time(create_info->context_flag & GHOST_kXrContextDebugTime) { @@ -88,18 +89,26 @@ void GHOST_XrContext::initialize(const GHOST_XrContextCreateInfo *create_info) printAvailableAPILayersAndExtensionsInfo(); } - m_gpu_binding_type = determineGraphicsBindingTypeToEnable(create_info); + /* Multiple graphics binding extensions can be enabled, but only one will actually be used + * (determined later on). */ + const std::vector<GHOST_TXrGraphicsBinding> graphics_binding_types = + determineGraphicsBindingTypesToEnable(create_info); assert(m_oxr->instance == XR_NULL_HANDLE); - createOpenXRInstance(); + createOpenXRInstance(graphics_binding_types); storeInstanceProperties(); + + /* Multiple bindings may be enabled. Now that we know the runtime in use, settle for one. */ + m_gpu_binding_type = determineGraphicsBindingTypeToUse(graphics_binding_types); + printInstanceInfo(); if (isDebugMode()) { initDebugMessenger(); } } -void GHOST_XrContext::createOpenXRInstance() +void GHOST_XrContext::createOpenXRInstance( + const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types) { XrInstanceCreateInfo create_info = {XR_TYPE_INSTANCE_CREATE_INFO}; @@ -108,7 +117,7 @@ void GHOST_XrContext::createOpenXRInstance() create_info.applicationInfo.apiVersion = XR_CURRENT_API_VERSION; getAPILayersToEnable(m_enabled_layers); - getExtensionsToEnable(m_enabled_extensions); + getExtensionsToEnable(graphics_binding_types, m_enabled_extensions); create_info.enabledApiLayerCount = m_enabled_layers.size(); create_info.enabledApiLayerNames = m_enabled_layers.data(); create_info.enabledExtensionCount = m_enabled_extensions.size(); @@ -327,7 +336,7 @@ void GHOST_XrContext::initApiLayers() } } -static bool openxr_layer_is_available(const std::vector<XrApiLayerProperties> layers_info, +static bool openxr_layer_is_available(const std::vector<XrApiLayerProperties> &layers_info, const std::string &layer_name) { for (const XrApiLayerProperties &layer_info : layers_info) { @@ -339,8 +348,9 @@ static bool openxr_layer_is_available(const std::vector<XrApiLayerProperties> la return false; } -static bool openxr_extension_is_available(const std::vector<XrExtensionProperties> extensions_info, - const std::string &extension_name) +static bool openxr_extension_is_available( + const std::vector<XrExtensionProperties> &extensions_info, + const std::string_view &extension_name) { for (const XrExtensionProperties &ext_info : extensions_info) { if (ext_info.extensionName == extension_name) { @@ -393,32 +403,30 @@ static const char *openxr_ext_name_from_wm_gpu_binding(GHOST_TXrGraphicsBinding /** * Gather an array of names for the extensions to enable. */ -void GHOST_XrContext::getExtensionsToEnable(std::vector<const char *> &r_ext_names) +void GHOST_XrContext::getExtensionsToEnable( + const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types, + std::vector<const char *> &r_ext_names) { - assert(m_gpu_binding_type != GHOST_kXrGraphicsUnknown); - - const char *gpu_binding = openxr_ext_name_from_wm_gpu_binding(m_gpu_binding_type); - static std::vector<std::string> try_ext; - - try_ext.clear(); + std::vector<std::string_view> try_ext; /* Try enabling debug extension. */ -#ifndef WIN32 if (isDebugMode()) { try_ext.push_back(XR_EXT_DEBUG_UTILS_EXTENSION_NAME); } -#endif - r_ext_names.reserve(try_ext.size() + 1); /* + 1 for graphics binding extension. */ + r_ext_names.reserve(try_ext.size() + graphics_binding_types.size()); - /* Add graphics binding extension. */ - assert(gpu_binding); - assert(openxr_extension_is_available(m_oxr->extensions, gpu_binding)); - r_ext_names.push_back(gpu_binding); + /* Add graphics binding extensions (may be multiple ones, we'll settle for one to use later, once + * we have more info about the runtime). */ + for (GHOST_TXrGraphicsBinding type : graphics_binding_types) { + const char *gpu_binding = openxr_ext_name_from_wm_gpu_binding(type); + assert(openxr_extension_is_available(m_oxr->extensions, gpu_binding)); + r_ext_names.push_back(gpu_binding); + } - for (const std::string &ext : try_ext) { + for (const std::string_view &ext : try_ext) { if (openxr_extension_is_available(m_oxr->extensions, ext)) { - r_ext_names.push_back(ext.c_str()); + r_ext_names.push_back(ext.data()); } } } @@ -427,9 +435,10 @@ void GHOST_XrContext::getExtensionsToEnable(std::vector<const char *> &r_ext_nam * Decide which graphics binding extension to use based on * #GHOST_XrContextCreateInfo.gpu_binding_candidates and available extensions. */ -GHOST_TXrGraphicsBinding GHOST_XrContext::determineGraphicsBindingTypeToEnable( +std::vector<GHOST_TXrGraphicsBinding> GHOST_XrContext::determineGraphicsBindingTypesToEnable( const GHOST_XrContextCreateInfo *create_info) { + std::vector<GHOST_TXrGraphicsBinding> result; assert(create_info->gpu_binding_candidates != NULL); assert(create_info->gpu_binding_candidates_count > 0); @@ -438,11 +447,35 @@ GHOST_TXrGraphicsBinding GHOST_XrContext::determineGraphicsBindingTypeToEnable( const char *ext_name = openxr_ext_name_from_wm_gpu_binding( create_info->gpu_binding_candidates[i]); if (openxr_extension_is_available(m_oxr->extensions, ext_name)) { - return create_info->gpu_binding_candidates[i]; + result.push_back(create_info->gpu_binding_candidates[i]); + } + } + + if (result.empty()) { + throw GHOST_XrException("No supported graphics binding found."); + } + + return result; +} + +GHOST_TXrGraphicsBinding GHOST_XrContext::determineGraphicsBindingTypeToUse( + const std::vector<GHOST_TXrGraphicsBinding> &enabled_types) +{ + /* Return the first working type. */ + for (GHOST_TXrGraphicsBinding type : enabled_types) { +#if WIN32 + /* The SteamVR OpenGL backend fails currently. Disable it and allow falling back to the DirectX + * one. */ + if ((m_runtime_id == OPENXR_RUNTIME_STEAMVR) && (type == GHOST_kXrGraphicsOpenGL)) { + continue; } +#endif + + assert(type != GHOST_kXrGraphicsUnknown); + return type; } - return GHOST_kXrGraphicsUnknown; + throw GHOST_XrException("Failed to determine a graphics binding to use."); } /** \} */ /* OpenXR API-Layers and Extensions */ @@ -459,7 +492,7 @@ void GHOST_XrContext::startSession(const GHOST_XrSessionBeginInfo *begin_info) m_custom_funcs.session_exit_customdata = begin_info->exit_customdata; if (m_session == nullptr) { - m_session = std::unique_ptr<GHOST_XrSession>(new GHOST_XrSession(this)); + m_session = std::make_unique<GHOST_XrSession>(*this); } m_session->start(begin_info); } @@ -489,7 +522,7 @@ void GHOST_XrContext::drawSessionViews(void *draw_customdata) /** * Delegates event to session, allowing context to destruct the session if needed. */ -void GHOST_XrContext::handleSessionStateChange(const XrEventDataSessionStateChanged *lifecycle) +void GHOST_XrContext::handleSessionStateChange(const XrEventDataSessionStateChanged &lifecycle) { if (m_session && m_session->handleStateChangeEvent(lifecycle) == GHOST_XrSession::SESSION_DESTROY) { diff --git a/intern/ghost/intern/GHOST_XrContext.h b/intern/ghost/intern/GHOST_XrContext.h index d2edb40c080..59c7786ed7a 100644 --- a/intern/ghost/intern/GHOST_XrContext.h +++ b/intern/ghost/intern/GHOST_XrContext.h @@ -80,7 +80,7 @@ class GHOST_XrContext : public GHOST_IXrContext { void setDrawViewFunc(GHOST_XrDrawViewFn draw_view_fn) override; bool needsUpsideDownDrawing() const override; - void handleSessionStateChange(const XrEventDataSessionStateChanged *lifecycle); + void handleSessionStateChange(const XrEventDataSessionStateChanged &lifecycle); GHOST_TXrOpenXRRuntimeID getOpenXRRuntimeID() const; const GHOST_XrCustomFuncs &getCustomFuncs() const; @@ -114,7 +114,7 @@ class GHOST_XrContext : public GHOST_IXrContext { bool m_debug = false; bool m_debug_time = false; - void createOpenXRInstance(); + void createOpenXRInstance(const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types); void storeInstanceProperties(); void initDebugMessenger(); @@ -126,7 +126,10 @@ class GHOST_XrContext : public GHOST_IXrContext { void initExtensions(); void initExtensionsEx(std::vector<XrExtensionProperties> &extensions, const char *layer_name); void getAPILayersToEnable(std::vector<const char *> &r_ext_names); - void getExtensionsToEnable(std::vector<const char *> &r_ext_names); - GHOST_TXrGraphicsBinding determineGraphicsBindingTypeToEnable( + void getExtensionsToEnable(const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types, + std::vector<const char *> &r_ext_names); + std::vector<GHOST_TXrGraphicsBinding> determineGraphicsBindingTypesToEnable( const GHOST_XrContextCreateInfo *create_info); + GHOST_TXrGraphicsBinding determineGraphicsBindingTypeToUse( + const std::vector<GHOST_TXrGraphicsBinding> &enabled_types); }; diff --git a/intern/ghost/intern/GHOST_XrEvent.cpp b/intern/ghost/intern/GHOST_XrEvent.cpp index 30005055f9b..992f89fadeb 100644 --- a/intern/ghost/intern/GHOST_XrEvent.cpp +++ b/intern/ghost/intern/GHOST_XrEvent.cpp @@ -35,25 +35,25 @@ static bool GHOST_XrEventPollNext(XrInstance instance, XrEventDataBuffer &r_even GHOST_TSuccess GHOST_XrEventsHandle(GHOST_XrContextHandle xr_contexthandle) { - GHOST_XrContext *xr_context = (GHOST_XrContext *)xr_contexthandle; - XrEventDataBuffer event_buffer; /* Structure big enough to hold all possible events. */ - - if (xr_context == NULL) { + if (xr_contexthandle == nullptr) { return GHOST_kFailure; } - while (GHOST_XrEventPollNext(xr_context->getInstance(), event_buffer)) { + GHOST_XrContext &xr_context = *(GHOST_XrContext *)xr_contexthandle; + XrEventDataBuffer event_buffer; /* Structure big enough to hold all possible events. */ + + while (GHOST_XrEventPollNext(xr_context.getInstance(), event_buffer)) { XrEventDataBaseHeader *event = (XrEventDataBaseHeader *)&event_buffer; switch (event->type) { case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED: - xr_context->handleSessionStateChange((XrEventDataSessionStateChanged *)event); + xr_context.handleSessionStateChange((XrEventDataSessionStateChanged &)*event); return GHOST_kSuccess; case XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING: GHOST_XrContextDestroy(xr_contexthandle); return GHOST_kSuccess; default: - if (xr_context->isDebugMode()) { + if (xr_context.isDebugMode()) { printf("Unhandled event: %i\n", event->type); } return GHOST_kFailure; diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp index 7d7405a974d..39b7f0776e1 100644 --- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp +++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp @@ -34,12 +34,11 @@ #include "GHOST_IXrGraphicsBinding.h" -static bool choose_swapchain_format_from_candidates(std::vector<int64_t> gpu_binding_formats, - std::vector<int64_t> runtime_formats, - int64_t &r_result) +static std::optional<int64_t> choose_swapchain_format_from_candidates( + const std::vector<int64_t> &gpu_binding_formats, const std::vector<int64_t> &runtime_formats) { if (gpu_binding_formats.empty()) { - return false; + return std::nullopt; } auto res = std::find_first_of(gpu_binding_formats.begin(), @@ -47,11 +46,10 @@ static bool choose_swapchain_format_from_candidates(std::vector<int64_t> gpu_bin runtime_formats.begin(), runtime_formats.end()); if (res == gpu_binding_formats.end()) { - return false; + return std::nullopt; } - r_result = *res; - return true; + return *res; } class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { @@ -63,21 +61,21 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { } } - bool checkVersionRequirements(GHOST_Context *ghost_ctx, + bool checkVersionRequirements(GHOST_Context &ghost_ctx, XrInstance instance, XrSystemId system_id, std::string *r_requirement_info) const override { #if defined(WITH_GHOST_X11) - GHOST_ContextGLX *ctx_gl = static_cast<GHOST_ContextGLX *>(ghost_ctx); + GHOST_ContextGLX &ctx_gl = static_cast<GHOST_ContextGLX &>(ghost_ctx); #else - GHOST_ContextWGL *ctx_gl = static_cast<GHOST_ContextWGL *>(ghost_ctx); + GHOST_ContextWGL &ctx_gl = static_cast<GHOST_ContextWGL &>(ghost_ctx); #endif static PFN_xrGetOpenGLGraphicsRequirementsKHR s_xrGetOpenGLGraphicsRequirementsKHR_fn = nullptr; XrGraphicsRequirementsOpenGLKHR gpu_requirements = {XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_KHR}; const XrVersion gl_version = XR_MAKE_VERSION( - ctx_gl->m_contextMajorVersion, ctx_gl->m_contextMinorVersion, 0); + ctx_gl.m_contextMajorVersion, ctx_gl.m_contextMinorVersion, 0); if (!s_xrGetOpenGLGraphicsRequirementsKHR_fn && XR_FAILED(xrGetInstanceProcAddr( @@ -105,47 +103,45 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { (gl_version <= gpu_requirements.maxApiVersionSupported); } - void initFromGhostContext(GHOST_Context *ghost_ctx) override + void initFromGhostContext(GHOST_Context &ghost_ctx) override { #if defined(WITH_GHOST_X11) - GHOST_ContextGLX *ctx_glx = static_cast<GHOST_ContextGLX *>(ghost_ctx); - XVisualInfo *visual_info = glXGetVisualFromFBConfig(ctx_glx->m_display, ctx_glx->m_fbconfig); + GHOST_ContextGLX &ctx_glx = static_cast<GHOST_ContextGLX &>(ghost_ctx); + XVisualInfo *visual_info = glXGetVisualFromFBConfig(ctx_glx.m_display, ctx_glx.m_fbconfig); oxr_binding.glx.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR; - oxr_binding.glx.xDisplay = ctx_glx->m_display; - oxr_binding.glx.glxFBConfig = ctx_glx->m_fbconfig; - oxr_binding.glx.glxDrawable = ctx_glx->m_window; - oxr_binding.glx.glxContext = ctx_glx->m_context; + oxr_binding.glx.xDisplay = ctx_glx.m_display; + oxr_binding.glx.glxFBConfig = ctx_glx.m_fbconfig; + oxr_binding.glx.glxDrawable = ctx_glx.m_window; + oxr_binding.glx.glxContext = ctx_glx.m_context; oxr_binding.glx.visualid = visual_info->visualid; XFree(visual_info); #elif defined(WIN32) - GHOST_ContextWGL *ctx_wgl = static_cast<GHOST_ContextWGL *>(ghost_ctx); + GHOST_ContextWGL &ctx_wgl = static_cast<GHOST_ContextWGL &>(ghost_ctx); oxr_binding.wgl.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_WIN32_KHR; - oxr_binding.wgl.hDC = ctx_wgl->m_hDC; - oxr_binding.wgl.hGLRC = ctx_wgl->m_hGLRC; + oxr_binding.wgl.hDC = ctx_wgl.m_hDC; + oxr_binding.wgl.hGLRC = ctx_wgl.m_hGLRC; #endif /* Generate a framebuffer to use for blitting into the texture. */ glGenFramebuffers(1, &m_fbo); } - bool chooseSwapchainFormat(const std::vector<int64_t> &runtime_formats, - int64_t &r_result, - bool &r_is_srgb_format) const override + std::optional<int64_t> chooseSwapchainFormat(const std::vector<int64_t> &runtime_formats, + bool &r_is_srgb_format) const override { std::vector<int64_t> gpu_binding_formats = { GL_RGBA8, GL_SRGB8_ALPHA8, }; - if (choose_swapchain_format_from_candidates(gpu_binding_formats, runtime_formats, r_result)) { - r_is_srgb_format = (r_result == GL_SRGB8_ALPHA8); - return true; - } + std::optional result = choose_swapchain_format_from_candidates(gpu_binding_formats, + runtime_formats); + r_is_srgb_format = result ? (*result == GL_SRGB8_ALPHA8) : false; - return false; + return result; } std::vector<XrSwapchainImageBaseHeader *> createSwapchainImages(uint32_t image_count) override @@ -166,25 +162,25 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { return base_images; } - void submitToSwapchainImage(XrSwapchainImageBaseHeader *swapchain_image, - const GHOST_XrDrawViewInfo *draw_info) override + void submitToSwapchainImage(XrSwapchainImageBaseHeader &swapchain_image, + const GHOST_XrDrawViewInfo &draw_info) override { - XrSwapchainImageOpenGLKHR *ogl_swapchain_image = reinterpret_cast<XrSwapchainImageOpenGLKHR *>( + XrSwapchainImageOpenGLKHR &ogl_swapchain_image = reinterpret_cast<XrSwapchainImageOpenGLKHR &>( swapchain_image); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo); glFramebufferTexture2D( - GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ogl_swapchain_image->image, 0); - - glBlitFramebuffer(draw_info->ofsx, - draw_info->ofsy, - draw_info->ofsx + draw_info->width, - draw_info->ofsy + draw_info->height, - draw_info->ofsx, - draw_info->ofsy, - draw_info->ofsx + draw_info->width, - draw_info->ofsy + draw_info->height, + GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ogl_swapchain_image.image, 0); + + glBlitFramebuffer(draw_info.ofsx, + draw_info.ofsy, + draw_info.ofsx + draw_info.width, + draw_info.ofsy + draw_info.height, + draw_info.ofsx, + draw_info.ofsy, + draw_info.ofsx + draw_info.width, + draw_info.ofsy + draw_info.height, GL_COLOR_BUFFER_BIT, GL_LINEAR); @@ -204,8 +200,8 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { #ifdef WIN32 class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding { public: - GHOST_XrGraphicsBindingD3D(GHOST_Context *ghost_ctx) - : GHOST_IXrGraphicsBinding(), m_ghost_wgl_ctx(*static_cast<GHOST_ContextWGL *>(ghost_ctx)) + GHOST_XrGraphicsBindingD3D(GHOST_Context &ghost_ctx) + : GHOST_IXrGraphicsBinding(), m_ghost_wgl_ctx(static_cast<GHOST_ContextWGL &>(ghost_ctx)) { m_ghost_d3d_ctx = GHOST_SystemWin32::createOffscreenContextD3D(); } @@ -220,7 +216,7 @@ class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding { } bool checkVersionRequirements( - GHOST_Context * /*ghost_ctx*/, /* Remember: This is the OpenGL context! */ + GHOST_Context & /*ghost_ctx*/, /* Remember: This is the OpenGL context! */ XrInstance instance, XrSystemId system_id, std::string *r_requirement_info) const override @@ -250,27 +246,25 @@ class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding { } void initFromGhostContext( - GHOST_Context * /*ghost_ctx*/ /* Remember: This is the OpenGL context! */ + GHOST_Context & /*ghost_ctx*/ /* Remember: This is the OpenGL context! */ ) override { oxr_binding.d3d11.type = XR_TYPE_GRAPHICS_BINDING_D3D11_KHR; oxr_binding.d3d11.device = m_ghost_d3d_ctx->m_device; } - bool chooseSwapchainFormat(const std::vector<int64_t> &runtime_formats, - int64_t &r_result, - bool &r_is_srgb_format) const override + std::optional<int64_t> chooseSwapchainFormat(const std::vector<int64_t> &runtime_formats, + bool &r_is_srgb_format) const override { std::vector<int64_t> gpu_binding_formats = { DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, }; - if (choose_swapchain_format_from_candidates(gpu_binding_formats, runtime_formats, r_result)) { - r_is_srgb_format = (r_result == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB); - return true; - } - return false; + std::optional result = choose_swapchain_format_from_candidates(gpu_binding_formats, + runtime_formats); + r_is_srgb_format = result ? (*result == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB) : false; + return result; } std::vector<XrSwapchainImageBaseHeader *> createSwapchainImages(uint32_t image_count) override @@ -291,10 +285,10 @@ class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding { return base_images; } - void submitToSwapchainImage(XrSwapchainImageBaseHeader *swapchain_image, - const GHOST_XrDrawViewInfo *draw_info) override + void submitToSwapchainImage(XrSwapchainImageBaseHeader &swapchain_image, + const GHOST_XrDrawViewInfo &draw_info) override { - XrSwapchainImageD3D11KHR *d3d_swapchain_image = reinterpret_cast<XrSwapchainImageD3D11KHR *>( + XrSwapchainImageD3D11KHR &d3d_swapchain_image = reinterpret_cast<XrSwapchainImageD3D11KHR &>( swapchain_image); # if 0 @@ -308,22 +302,22 @@ class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding { CD3D11_RENDER_TARGET_VIEW_DESC rtv_desc(D3D11_RTV_DIMENSION_TEXTURE2D, DXGI_FORMAT_R8G8B8A8_UNORM); - m_ghost_ctx->m_device->CreateRenderTargetView(d3d_swapchain_image->texture, &rtv_desc, &rtv); + m_ghost_ctx->m_device->CreateRenderTargetView(d3d_swapchain_image.texture, &rtv_desc, &rtv); if (!m_shared_resource) { m_shared_resource = m_ghost_ctx->createSharedOpenGLResource( - draw_info->width, draw_info->height, rtv); + draw_info.width, draw_info.height, rtv); } - m_ghost_ctx->blitFromOpenGLContext(m_shared_resource, draw_info->width, draw_info->height); + m_ghost_ctx->blitFromOpenGLContext(m_shared_resource, draw_info.width, draw_info.height); # else if (!m_shared_resource) { - m_shared_resource = m_ghost_d3d_ctx->createSharedOpenGLResource(draw_info->width, - draw_info->height); + m_shared_resource = m_ghost_d3d_ctx->createSharedOpenGLResource(draw_info.width, + draw_info.height); } - m_ghost_d3d_ctx->blitFromOpenGLContext(m_shared_resource, draw_info->width, draw_info->height); + m_ghost_d3d_ctx->blitFromOpenGLContext(m_shared_resource, draw_info.width, draw_info.height); m_ghost_d3d_ctx->m_device_ctx->OMSetRenderTargets(0, nullptr, nullptr); m_ghost_d3d_ctx->m_device_ctx->CopyResource( - d3d_swapchain_image->texture, m_ghost_d3d_ctx->getSharedTexture2D(m_shared_resource)); + d3d_swapchain_image.texture, m_ghost_d3d_ctx->getSharedTexture2D(m_shared_resource)); # endif } @@ -345,14 +339,14 @@ class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding { #endif // WIN32 std::unique_ptr<GHOST_IXrGraphicsBinding> GHOST_XrGraphicsBindingCreateFromType( - GHOST_TXrGraphicsBinding type, GHOST_Context *context) + GHOST_TXrGraphicsBinding type, GHOST_Context &context) { switch (type) { case GHOST_kXrGraphicsOpenGL: - return std::unique_ptr<GHOST_XrGraphicsBindingOpenGL>(new GHOST_XrGraphicsBindingOpenGL()); + return std::make_unique<GHOST_XrGraphicsBindingOpenGL>(); #ifdef WIN32 case GHOST_kXrGraphicsD3D11: - return std::unique_ptr<GHOST_XrGraphicsBindingD3D>(new GHOST_XrGraphicsBindingD3D(context)); + return std::make_unique<GHOST_XrGraphicsBindingD3D>(context); #endif default: return nullptr; diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp index 5a747b1e787..e43991853cb 100644 --- a/intern/ghost/intern/GHOST_XrSession.cpp +++ b/intern/ghost/intern/GHOST_XrSession.cpp @@ -62,8 +62,8 @@ struct GHOST_XrDrawInfo { * * \{ */ -GHOST_XrSession::GHOST_XrSession(GHOST_XrContext *xr_context) - : m_context(xr_context), m_oxr(new OpenXRSessionData()) +GHOST_XrSession::GHOST_XrSession(GHOST_XrContext &xr_context) + : m_context(&xr_context), m_oxr(std::make_unique<OpenXRSessionData>()) { } @@ -113,7 +113,7 @@ void GHOST_XrSession::initSystem() * * \{ */ -static void create_reference_spaces(OpenXRSessionData *oxr, const GHOST_XrPose *base_pose) +static void create_reference_spaces(OpenXRSessionData &oxr, const GHOST_XrPose &base_pose) { XrReferenceSpaceCreateInfo create_info = {XR_TYPE_REFERENCE_SPACE_CREATE_INFO}; create_info.poseInReferenceSpace.orientation.w = 1.0f; @@ -142,11 +142,11 @@ static void create_reference_spaces(OpenXRSessionData *oxr, const GHOST_XrPose * (void)base_pose; #endif - CHECK_XR(xrCreateReferenceSpace(oxr->session, &create_info, &oxr->reference_space), + CHECK_XR(xrCreateReferenceSpace(oxr.session, &create_info, &oxr.reference_space), "Failed to create reference space."); create_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_VIEW; - CHECK_XR(xrCreateReferenceSpace(oxr->session, &create_info, &oxr->view_space), + CHECK_XR(xrCreateReferenceSpace(oxr.session, &create_info, &oxr.view_space), "Failed to create view reference space."); } @@ -173,15 +173,15 @@ void GHOST_XrSession::start(const GHOST_XrSessionBeginInfo *begin_info) std::string requirement_str; m_gpu_binding = GHOST_XrGraphicsBindingCreateFromType(m_context->getGraphicsBindingType(), - m_gpu_ctx); + *m_gpu_ctx); if (!m_gpu_binding->checkVersionRequirements( - m_gpu_ctx, m_context->getInstance(), m_oxr->system_id, &requirement_str)) { + *m_gpu_ctx, m_context->getInstance(), m_oxr->system_id, &requirement_str)) { std::ostringstream strstream; strstream << "Available graphics context version does not meet the following requirements: " << requirement_str; throw GHOST_XrException(strstream.str().c_str()); } - m_gpu_binding->initFromGhostContext(m_gpu_ctx); + m_gpu_binding->initFromGhostContext(*m_gpu_ctx); XrSessionCreateInfo create_info = {}; create_info.type = XR_TYPE_SESSION_CREATE_INFO; @@ -195,7 +195,7 @@ void GHOST_XrSession::start(const GHOST_XrSessionBeginInfo *begin_info) "detailed error information to the command line."); prepareDrawing(); - create_reference_spaces(m_oxr.get(), &begin_info->base_pose); + create_reference_spaces(*m_oxr, begin_info->base_pose); } void GHOST_XrSession::requestEnd() @@ -217,14 +217,14 @@ void GHOST_XrSession::endSession() } GHOST_XrSession::LifeExpectancy GHOST_XrSession::handleStateChangeEvent( - const XrEventDataSessionStateChanged *lifecycle) + const XrEventDataSessionStateChanged &lifecycle) { - m_oxr->session_state = lifecycle->state; + m_oxr->session_state = lifecycle.state; /* Runtime may send events for apparently destroyed session. Our handle should be NULL then. */ - assert((m_oxr->session == XR_NULL_HANDLE) || (m_oxr->session == lifecycle->session)); + assert((m_oxr->session == XR_NULL_HANDLE) || (m_oxr->session == lifecycle.session)); - switch (lifecycle->state) { + switch (lifecycle.state) { case XR_SESSION_STATE_READY: { beginSession(); break; @@ -272,7 +272,7 @@ void GHOST_XrSession::prepareDrawing() m_oxr->views.resize(view_count, {XR_TYPE_VIEW}); - m_draw_info = std::unique_ptr<GHOST_XrDrawInfo>(new GHOST_XrDrawInfo()); + m_draw_info = std::make_unique<GHOST_XrDrawInfo>(); } void GHOST_XrSession::beginFrameDrawing() @@ -295,43 +295,43 @@ void GHOST_XrSession::beginFrameDrawing() } } -static void print_debug_timings(GHOST_XrDrawInfo *draw_info) +static void print_debug_timings(GHOST_XrDrawInfo &draw_info) { /** Render time of last 8 frames (in ms) to calculate an average. */ std::chrono::duration<double, std::milli> duration = std::chrono::high_resolution_clock::now() - - draw_info->frame_begin_time; + draw_info.frame_begin_time; const double duration_ms = duration.count(); const int avg_frame_count = 8; double avg_ms_tot = 0.0; - if (draw_info->last_frame_times.size() >= avg_frame_count) { - draw_info->last_frame_times.pop_front(); - assert(draw_info->last_frame_times.size() == avg_frame_count - 1); + if (draw_info.last_frame_times.size() >= avg_frame_count) { + draw_info.last_frame_times.pop_front(); + assert(draw_info.last_frame_times.size() == avg_frame_count - 1); } - draw_info->last_frame_times.push_back(duration_ms); - for (double ms_iter : draw_info->last_frame_times) { + draw_info.last_frame_times.push_back(duration_ms); + for (double ms_iter : draw_info.last_frame_times) { avg_ms_tot += ms_iter; } printf("VR frame render time: %.0fms - %.2f FPS (%.2f FPS 8 frames average)\n", duration_ms, 1000.0 / duration_ms, - 1000.0 / (avg_ms_tot / draw_info->last_frame_times.size())); + 1000.0 / (avg_ms_tot / draw_info.last_frame_times.size())); } -void GHOST_XrSession::endFrameDrawing(std::vector<XrCompositionLayerBaseHeader *> *layers) +void GHOST_XrSession::endFrameDrawing(std::vector<XrCompositionLayerBaseHeader *> &layers) { XrFrameEndInfo end_info = {XR_TYPE_FRAME_END_INFO}; end_info.displayTime = m_draw_info->frame_state.predictedDisplayTime; end_info.environmentBlendMode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE; - end_info.layerCount = layers->size(); - end_info.layers = layers->data(); + end_info.layerCount = layers.size(); + end_info.layers = layers.data(); CHECK_XR(xrEndFrame(m_oxr->session, &end_info), "Failed to submit rendered frame."); if (m_context->isDebugTimeMode()) { - print_debug_timings(m_draw_info.get()); + print_debug_timings(*m_draw_info); } } @@ -349,7 +349,7 @@ void GHOST_XrSession::draw(void *draw_customdata) layers.push_back(reinterpret_cast<XrCompositionLayerBaseHeader *>(&proj_layer)); } - endFrameDrawing(&layers); + endFrameDrawing(layers); } static void copy_openxr_pose_to_ghost_pose(const XrPosef &oxr_pose, GHOST_XrPose &r_ghost_pose) @@ -399,7 +399,7 @@ void GHOST_XrSession::drawView(GHOST_XrSwapchain &swapchain, /* Draw! */ m_context->getCustomFuncs().draw_view_fn(&draw_view_info, draw_customdata); - m_gpu_binding->submitToSwapchainImage(swapchain_image, &draw_view_info); + m_gpu_binding->submitToSwapchainImage(*swapchain_image, draw_view_info); swapchain.releaseImage(); } diff --git a/intern/ghost/intern/GHOST_XrSession.h b/intern/ghost/intern/GHOST_XrSession.h index 74555c0c170..79a586411e9 100644 --- a/intern/ghost/intern/GHOST_XrSession.h +++ b/intern/ghost/intern/GHOST_XrSession.h @@ -37,13 +37,13 @@ class GHOST_XrSession { SESSION_DESTROY, }; - GHOST_XrSession(GHOST_XrContext *xr_context); + GHOST_XrSession(GHOST_XrContext &xr_context); ~GHOST_XrSession(); void start(const GHOST_XrSessionBeginInfo *begin_info); void requestEnd(); - LifeExpectancy handleStateChangeEvent(const XrEventDataSessionStateChanged *lifecycle); + LifeExpectancy handleStateChangeEvent(const XrEventDataSessionStateChanged &lifecycle); bool isRunning() const; bool needsUpsideDownDrawing() const; @@ -81,5 +81,5 @@ class GHOST_XrSession { XrView &view, void *draw_customdata); void beginFrameDrawing(); - void endFrameDrawing(std::vector<XrCompositionLayerBaseHeader *> *layers); + void endFrameDrawing(std::vector<XrCompositionLayerBaseHeader *> &layers); }; diff --git a/intern/ghost/intern/GHOST_XrSwapchain.cpp b/intern/ghost/intern/GHOST_XrSwapchain.cpp index f7808c20112..9973d99cc37 100644 --- a/intern/ghost/intern/GHOST_XrSwapchain.cpp +++ b/intern/ghost/intern/GHOST_XrSwapchain.cpp @@ -54,11 +54,10 @@ static OpenXRSwapchainData::ImageVec swapchain_images_create(XrSwapchain swapcha GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_IXrGraphicsBinding &gpu_binding, const XrSession &session, const XrViewConfigurationView &view_config) - : m_oxr(new OpenXRSwapchainData()) + : m_oxr(std::make_unique<OpenXRSwapchainData>()) { XrSwapchainCreateInfo create_info = {XR_TYPE_SWAPCHAIN_CREATE_INFO}; uint32_t format_count = 0; - int64_t chosen_format; CHECK_XR(xrEnumerateSwapchainFormats(session, 0, &format_count, nullptr), "Failed to get count of swapchain image formats."); @@ -68,14 +67,16 @@ GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_IXrGraphicsBinding &gpu_binding, "Failed to get swapchain image formats."); assert(swapchain_formats.size() == format_count); - if (!gpu_binding.chooseSwapchainFormat(swapchain_formats, chosen_format, m_is_srgb_buffer)) { + std::optional chosen_format = gpu_binding.chooseSwapchainFormat(swapchain_formats, + m_is_srgb_buffer); + if (!chosen_format) { throw GHOST_XrException( "Error: No format matching OpenXR runtime supported swapchain formats found."); } create_info.usageFlags = XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT; - create_info.format = chosen_format; + create_info.format = *chosen_format; create_info.sampleCount = view_config.recommendedSwapchainSampleCount; create_info.width = view_config.recommendedImageRectWidth; create_info.height = view_config.recommendedImageRectHeight; @@ -95,7 +96,8 @@ GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_IXrGraphicsBinding &gpu_binding, GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_XrSwapchain &&other) : m_oxr(std::move(other.m_oxr)), m_image_width(other.m_image_width), - m_image_height(other.m_image_height) + m_image_height(other.m_image_height), + m_is_srgb_buffer(other.m_is_srgb_buffer) { /* Prevent xrDestroySwapchain call for the moved out item. */ other.m_oxr = nullptr; diff --git a/release/datafiles/icons/brush.gpencil_draw.tint.dat b/release/datafiles/icons/brush.gpencil_draw.tint.dat Binary files differindex 016e4304498..32d8a5f04e4 100644 --- a/release/datafiles/icons/brush.gpencil_draw.tint.dat +++ b/release/datafiles/icons/brush.gpencil_draw.tint.dat diff --git a/release/datafiles/icons/brush.paint_vertex.replace.dat b/release/datafiles/icons/brush.paint_vertex.replace.dat Binary files differindex a37fdf2e1b1..676436548a7 100644 --- a/release/datafiles/icons/brush.paint_vertex.replace.dat +++ b/release/datafiles/icons/brush.paint_vertex.replace.dat diff --git a/release/datafiles/icons/brush.particle.add.dat b/release/datafiles/icons/brush.particle.add.dat Binary files differindex 3c4f65cf6e2..b66f4da5b71 100644 --- a/release/datafiles/icons/brush.particle.add.dat +++ b/release/datafiles/icons/brush.particle.add.dat diff --git a/release/datafiles/icons/brush.particle.comb.dat b/release/datafiles/icons/brush.particle.comb.dat Binary files differindex 8b656db622b..d6dd75a35d7 100644 --- a/release/datafiles/icons/brush.particle.comb.dat +++ b/release/datafiles/icons/brush.particle.comb.dat diff --git a/release/datafiles/icons/brush.particle.cut.dat b/release/datafiles/icons/brush.particle.cut.dat Binary files differindex 97dc3e6099b..e7ef86e2fbc 100644 --- a/release/datafiles/icons/brush.particle.cut.dat +++ b/release/datafiles/icons/brush.particle.cut.dat diff --git a/release/datafiles/icons/brush.particle.length.dat b/release/datafiles/icons/brush.particle.length.dat Binary files differindex d088110b432..e3aa3f2f9df 100644 --- a/release/datafiles/icons/brush.particle.length.dat +++ b/release/datafiles/icons/brush.particle.length.dat diff --git a/release/datafiles/icons/brush.sculpt.rotate.dat b/release/datafiles/icons/brush.sculpt.rotate.dat Binary files differindex d63f1e3d7d4..8d1723a8c71 100644 --- a/release/datafiles/icons/brush.sculpt.rotate.dat +++ b/release/datafiles/icons/brush.sculpt.rotate.dat diff --git a/release/datafiles/icons/ops.curve.draw.dat b/release/datafiles/icons/ops.curve.draw.dat Binary files differindex 8ae8ef5b1c8..cf2c8e31bcb 100644 --- a/release/datafiles/icons/ops.curve.draw.dat +++ b/release/datafiles/icons/ops.curve.draw.dat diff --git a/release/datafiles/icons/ops.gpencil.draw.dat b/release/datafiles/icons/ops.gpencil.draw.dat Binary files differindex d05e67d276c..e71644f4968 100644 --- a/release/datafiles/icons/ops.gpencil.draw.dat +++ b/release/datafiles/icons/ops.gpencil.draw.dat diff --git a/release/datafiles/icons/ops.gpencil.draw.eraser.dat b/release/datafiles/icons/ops.gpencil.draw.eraser.dat Binary files differindex 2dc1653f810..44f65c4581d 100644 --- a/release/datafiles/icons/ops.gpencil.draw.eraser.dat +++ b/release/datafiles/icons/ops.gpencil.draw.eraser.dat diff --git a/release/datafiles/icons/ops.gpencil.draw.line.dat b/release/datafiles/icons/ops.gpencil.draw.line.dat Binary files differindex 53fa0193fa9..bbfaf28bc5e 100644 --- a/release/datafiles/icons/ops.gpencil.draw.line.dat +++ b/release/datafiles/icons/ops.gpencil.draw.line.dat diff --git a/release/datafiles/icons/ops.gpencil.draw.poly.dat b/release/datafiles/icons/ops.gpencil.draw.poly.dat Binary files differindex a223c9eb90c..e3ca2f35ece 100644 --- a/release/datafiles/icons/ops.gpencil.draw.poly.dat +++ b/release/datafiles/icons/ops.gpencil.draw.poly.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_smooth.dat b/release/datafiles/icons/ops.gpencil.sculpt_smooth.dat Binary files differindex 90ba16d846a..d480913608d 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_smooth.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_smooth.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_strength.dat b/release/datafiles/icons/ops.gpencil.sculpt_strength.dat Binary files differindex d3f48931831..7fced673192 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_strength.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_strength.dat diff --git a/release/datafiles/icons/ops.gpencil.sculpt_weight.dat b/release/datafiles/icons/ops.gpencil.sculpt_weight.dat Binary files differindex d5441fcbeb9..01c9587ec2e 100644 --- a/release/datafiles/icons/ops.gpencil.sculpt_weight.dat +++ b/release/datafiles/icons/ops.gpencil.sculpt_weight.dat diff --git a/release/datafiles/icons/ops.paint.weight_sample.dat b/release/datafiles/icons/ops.paint.weight_sample.dat Binary files differindex e8d20582f9a..a428ae67e4c 100644 --- a/release/datafiles/icons/ops.paint.weight_sample.dat +++ b/release/datafiles/icons/ops.paint.weight_sample.dat diff --git a/release/datafiles/icons/ops.paint.weight_sample_group.dat b/release/datafiles/icons/ops.paint.weight_sample_group.dat Binary files differindex 7994db12d1b..863496f8908 100644 --- a/release/datafiles/icons/ops.paint.weight_sample_group.dat +++ b/release/datafiles/icons/ops.paint.weight_sample_group.dat diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 52e5bebefe4..679c0461567 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -3393,7 +3393,7 @@ def km_grease_pencil_stroke_paint_fill(params): ("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, {"properties": [("mode", 'DRAW'), ("wait_for_input", False), ("disable_straight", True), ("disable_stabilizer", True)]}), # If press alternative key, the brush now it's for drawing lines - ("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True, "shift": True}, + ("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True}, {"properties": [("mode", 'DRAW'), ("wait_for_input", False), ("disable_straight", True), ("disable_stabilizer", True), ("disable_fill", True)]}), ]) diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py index 04721a1704a..c72a7521557 100644 --- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py +++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py @@ -2471,7 +2471,7 @@ def km_grease_pencil_stroke_paint_fill(params): ("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, {"properties": [("mode", 'DRAW'), ("wait_for_input", False), ("disable_straight", True), ("disable_stabilizer", True)]}), # If press alternative key, the brush now it's for drawing lines - ("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True, "shift": True}, + ("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True}, {"properties": [("mode", 'DRAW'), ("wait_for_input", False), ("disable_straight", True), ("disable_stabilizer", True), ("disable_fill", True)]}), ]) diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index 7ff2688f2a7..64bc694d5ca 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -468,7 +468,7 @@ class DATA_PT_sculpt_vertex_colors(MeshButtonsPanel, Panel): @classmethod def poll(cls, context): - return context.preferences.experimental.use_sculpt_vertex_colors + return super().poll(context) and context.preferences.experimental.use_sculpt_vertex_colors def draw(self, context): layout = self.layout diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 1b8869d0bc8..48aac36fc7f 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -828,6 +828,7 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel): bl_context = ".sculpt_mode" # dot on purpose (access from topbar) bl_label = "Options" bl_options = {'DEFAULT_CLOSED'} + bl_ui_units_x = 12 @classmethod def poll(cls, context): diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index 12d7f0e9e8e..5b45148ed63 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -1146,7 +1146,15 @@ void BKE_lib_override_library_main_operations_create(Main *bmain, const bool for FOREACH_MAIN_ID_BEGIN (bmain, id) { if (ID_IS_OVERRIDE_LIBRARY_REAL(id) && (force_auto || (id->tag & LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH))) { - BLI_task_pool_push(task_pool, lib_override_library_operations_create_cb, id, false, NULL); + /* Only check overrides if we do have the real reference data available, and not some empty + * 'placeholder' for missing data (broken links). */ + if ((id->override_library->reference->tag & LIB_TAG_MISSING) == 0) { + BLI_task_pool_push(task_pool, lib_override_library_operations_create_cb, id, false, NULL); + } + else { + BKE_lib_override_library_properties_tag( + id->override_library, IDOVERRIDE_LIBRARY_TAG_UNUSED, false); + } } id->tag &= ~LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH; } diff --git a/source/blender/blenlib/BLI_array.hh b/source/blender/blenlib/BLI_array.hh index 9b307dc6a04..9d09bb3559e 100644 --- a/source/blender/blenlib/BLI_array.hh +++ b/source/blender/blenlib/BLI_array.hh @@ -288,7 +288,6 @@ class Array { { return data_; } - const T *end() const { return data_ + size_; @@ -298,12 +297,29 @@ class Array { { return data_; } - T *end() { return data_ + size_; } + std::reverse_iterator<T *> rbegin() + { + return std::reverse_iterator<T *>(this->end()); + } + std::reverse_iterator<T *> rend() + { + return std::reverse_iterator<T *>(this->begin()); + } + + std::reverse_iterator<const T *> rbegin() const + { + return std::reverse_iterator<T *>(this->end()); + } + std::reverse_iterator<const T *> rend() const + { + return std::reverse_iterator<T *>(this->begin()); + } + /** * Get an index range containing all valid indices for this array. */ diff --git a/source/blender/blenlib/BLI_span.hh b/source/blender/blenlib/BLI_span.hh index 165814cf23c..5b4d2769f57 100644 --- a/source/blender/blenlib/BLI_span.hh +++ b/source/blender/blenlib/BLI_span.hh @@ -213,12 +213,20 @@ template<typename T> class Span { { return data_; } - const T *end() const { return data_ + size_; } + std::reverse_iterator<const T *> rbegin() const + { + return std::reverse_iterator<const T *>(this->end()); + } + std::reverse_iterator<const T *> rend() const + { + return std::reverse_iterator<const T *>(this->begin()); + } + /** * Access an element in the array. This invokes undefined behavior when the index is out of * bounds. @@ -502,12 +510,20 @@ template<typename T> class MutableSpan { { return data_; } - T *end() const { return data_ + size_; } + std::reverse_iterator<T *> rbegin() const + { + return std::reverse_iterator<T *>(this->end()); + } + std::reverse_iterator<T *> rend() const + { + return std::reverse_iterator<T *>(this->begin()); + } + T &operator[](const int64_t index) const { BLI_assert(index < this->size()); diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh index 48110ef2814..74ce8dd42e7 100644 --- a/source/blender/blenlib/BLI_vector.hh +++ b/source/blender/blenlib/BLI_vector.hh @@ -178,17 +178,15 @@ class Vector { { } - /** - * Create a vector from any container. It must be possible to use the container in a - * range-for loop. - */ - template<typename ContainerT> static Vector FromContainer(const ContainerT &container) - { - Vector vector; - for (const auto &value : container) { - vector.append(value); + template<typename InputIt, + /* This constructor should not be called with e.g. Vector(3, 10), because that is + expected to produce the vector (10, 10, 10). */ + typename std::enable_if_t<!std::is_convertible_v<InputIt, int>> * = nullptr> + Vector(InputIt first, InputIt last, Allocator allocator = {}) : Vector(std::move(allocator)) + { + for (InputIt current = first; current != last; ++current) { + this->append(*current); } - return vector; } /** @@ -560,6 +558,78 @@ class Vector { UPDATE_VECTOR_SIZE(this); } + template<typename InputIt> void extend(InputIt first, InputIt last) + { + this->insert(this->end(), first, last); + } + + /** + * Insert elements into the vector at the specified position. This has a running time of O(n) + * where n is the number of values that have to be moved. Undefined behavior is invoked when the + * insert position is out of bounds. + */ + void insert(const int64_t insert_index, const T &value) + { + this->insert(insert_index, Span<T>(&value, 1)); + } + void insert(const int64_t insert_index, T &&value) + { + this->insert( + insert_index, std::make_move_iterator(&value), std::make_move_iterator(&value + 1)); + } + void insert(const int64_t insert_index, Span<T> array) + { + this->insert(begin_ + insert_index, array.begin(), array.end()); + } + template<typename InputIt> void insert(const T *insert_position, InputIt first, InputIt last) + { + const int64_t insert_index = insert_position - begin_; + this->insert(insert_index, first, last); + } + template<typename InputIt> void insert(const int64_t insert_index, InputIt first, InputIt last) + { + BLI_assert(insert_index >= 0); + BLI_assert(insert_index <= this->size()); + + const int64_t insert_amount = std::distance(first, last); + const int64_t old_size = this->size(); + const int64_t new_size = old_size + insert_amount; + const int64_t move_amount = old_size - insert_index; + + this->reserve(new_size); + for (int64_t i = 0; i < move_amount; i++) { + const int64_t src_index = insert_index + move_amount - i - 1; + const int64_t dst_index = new_size - i - 1; + new (static_cast<void *>(begin_ + dst_index)) T(std::move(begin_[src_index])); + begin_[src_index].~T(); + } + + std::uninitialized_copy_n(first, insert_amount, begin_ + insert_index); + end_ = begin_ + new_size; + UPDATE_VECTOR_SIZE(this); + } + + /** + * Insert values at the beginning of the vector. The has to move all the other elements, so it + * has a linear running time. + */ + void prepend(const T &&value) + { + this->insert(0, value); + } + void prepend(T &&value) + { + this->insert(0, std::move(value)); + } + void prepend(Span<T> values) + { + this->insert(0, values); + } + template<typename InputIt> void prepend(InputIt first, InputIt last) + { + this->insert(0, first, last); + } + /** * Return a reference to the last element in the vector. * This invokes undefined behavior when the vector is empty. @@ -746,6 +816,24 @@ class Vector { return end_; } + std::reverse_iterator<T *> rbegin() + { + return std::reverse_iterator<T *>(this->end()); + } + std::reverse_iterator<T *> rend() + { + return std::reverse_iterator<T *>(this->begin()); + } + + std::reverse_iterator<const T *> rbegin() const + { + return std::reverse_iterator<T *>(this->end()); + } + std::reverse_iterator<const T *> rend() const + { + return std::reverse_iterator<T *>(this->begin()); + } + /** * Get the current capacity of the vector, i.e. the maximum number of elements the vector can * hold, before it has to reallocate. diff --git a/source/blender/blenlib/tests/BLI_array_test.cc b/source/blender/blenlib/tests/BLI_array_test.cc index 7348a6f93f3..38ab695d238 100644 --- a/source/blender/blenlib/tests/BLI_array_test.cc +++ b/source/blender/blenlib/tests/BLI_array_test.cc @@ -2,6 +2,7 @@ #include "BLI_array.hh" #include "BLI_strict_flags.h" +#include "BLI_vector.hh" #include "testing/testing.h" namespace blender::tests { @@ -173,4 +174,18 @@ TEST(array, Fill) EXPECT_EQ(array[4], 3); } +TEST(array, ReverseIterator) +{ + Array<int> array = {3, 4, 5, 6}; + Vector<int> reversed_vec; + + for (auto it = array.rbegin(); it != array.rend(); ++it) { + reversed_vec.append(*it); + *it += 10; + } + + EXPECT_EQ_ARRAY(reversed_vec.data(), Span({6, 5, 4, 3}).data(), 4); + EXPECT_EQ_ARRAY(array.data(), Span({13, 14, 15, 16}).data(), 4); +} + } // namespace blender::tests diff --git a/source/blender/blenlib/tests/BLI_span_test.cc b/source/blender/blenlib/tests/BLI_span_test.cc index 6ad2a5633ad..82d21e53084 100644 --- a/source/blender/blenlib/tests/BLI_span_test.cc +++ b/source/blender/blenlib/tests/BLI_span_test.cc @@ -308,4 +308,32 @@ TEST(span, CopyFrom) EXPECT_EQ(dst[3], 8); } +TEST(span, ReverseIterator) +{ + std::array<int, 4> src = {4, 5, 6, 7}; + Span<int> span = src; + Vector<int> reversed_vec; + + for (auto it = span.rbegin(); it != span.rend(); ++it) { + reversed_vec.append(*it); + } + EXPECT_EQ(reversed_vec.size(), 4); + EXPECT_EQ_ARRAY(reversed_vec.data(), Span({7, 6, 5, 4}).data(), 4); +} + +TEST(span, MutableReverseIterator) +{ + std::array<int, 4> src = {4, 5, 6, 7}; + MutableSpan<int> span = src; + Vector<int> reversed_vec; + + for (auto it = span.rbegin(); it != span.rend(); ++it) { + reversed_vec.append(*it); + *it += 10; + } + EXPECT_EQ(reversed_vec.size(), 4); + EXPECT_EQ_ARRAY(reversed_vec.data(), Span({7, 6, 5, 4}).data(), 4); + EXPECT_EQ_ARRAY(src.data(), Span({14, 15, 16, 17}).data(), 4); +} + } // namespace blender::tests diff --git a/source/blender/blenlib/tests/BLI_vector_test.cc b/source/blender/blenlib/tests/BLI_vector_test.cc index f72dfc5deb8..792e120d2c0 100644 --- a/source/blender/blenlib/tests/BLI_vector_test.cc +++ b/source/blender/blenlib/tests/BLI_vector_test.cc @@ -98,14 +98,14 @@ TEST(vector, ListBaseConstructor) delete value3; } -TEST(vector, ContainerConstructor) +TEST(vector, IteratorConstructor) { std::forward_list<int> list; list.push_front(3); list.push_front(1); list.push_front(5); - Vector<int> vec = Vector<int>::FromContainer(list); + Vector<int> vec = Vector<int>(list.begin(), list.end()); EXPECT_EQ(vec.size(), 3); EXPECT_EQ(vec[0], 5); EXPECT_EQ(vec[1], 1); @@ -279,6 +279,15 @@ TEST(vector, ExtendNonDuplicates) EXPECT_EQ(vec.size(), 5); } +TEST(vector, ExtendIterator) +{ + Vector<int> vec = {3, 4, 5}; + std::forward_list<int> list = {8, 9}; + vec.extend(list.begin(), list.end()); + EXPECT_EQ(vec.size(), 5); + EXPECT_EQ_ARRAY(vec.data(), Span({3, 4, 5, 8, 9}).data(), 5); +} + TEST(vector, Iterator) { Vector<int> vec({1, 4, 9, 16}); @@ -636,4 +645,68 @@ TEST(vector, Fill) EXPECT_EQ(vec[4], 3); } +TEST(vector, InsertAtBeginning) +{ + Vector<int> vec = {1, 2, 3}; + vec.insert(0, {6, 7}); + EXPECT_EQ(vec.size(), 5); + EXPECT_EQ_ARRAY(vec.data(), Span({6, 7, 1, 2, 3}).data(), 5); +} + +TEST(vector, InsertAtEnd) +{ + Vector<int> vec = {1, 2, 3}; + vec.insert(3, {6, 7}); + EXPECT_EQ(vec.size(), 5); + EXPECT_EQ_ARRAY(vec.data(), Span({1, 2, 3, 6, 7}).data(), 5); +} + +TEST(vector, InsertInMiddle) +{ + Vector<int> vec = {1, 2, 3}; + vec.insert(1, {6, 7}); + EXPECT_EQ(vec.size(), 5); + EXPECT_EQ_ARRAY(vec.data(), Span({1, 6, 7, 2, 3}).data(), 5); +} + +TEST(vector, InsertAtIterator) +{ + Vector<std::string> vec = {"1", "2", "3"}; + Vector<std::string> other_vec = {"hello", "world"}; + vec.insert(vec.begin() + 1, other_vec.begin(), other_vec.end()); + EXPECT_EQ(vec.size(), 5); + EXPECT_EQ_ARRAY(vec.data(), Span<std::string>({"1", "hello", "world", "2", "3"}).data(), 5); +} + +TEST(vector, InsertMoveOnlyType) +{ + Vector<std::unique_ptr<int>> vec; + vec.append(std::make_unique<int>(1)); + vec.append(std::make_unique<int>(2)); + vec.insert(1, std::make_unique<int>(30)); + EXPECT_EQ(vec.size(), 3); + EXPECT_EQ(*vec[0], 1); + EXPECT_EQ(*vec[1], 30); + EXPECT_EQ(*vec[2], 2); +} + +TEST(vector, Prepend) +{ + Vector<int> vec = {1, 2, 3}; + vec.prepend({7, 8}); + EXPECT_EQ(vec.size(), 5); + EXPECT_EQ_ARRAY(vec.data(), Span({7, 8, 1, 2, 3}).data(), 5); +} + +TEST(vector, ReverseIterator) +{ + Vector<int> vec = {4, 5, 6, 7}; + Vector<int> reversed_vec; + for (auto it = vec.rbegin(); it != vec.rend(); ++it) { + reversed_vec.append(*it); + } + EXPECT_EQ(reversed_vec.size(), 4); + EXPECT_EQ_ARRAY(reversed_vec.data(), Span({7, 6, 5, 4}).data(), 4); +} + } // namespace blender::tests diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 12099956f4b..246d34a03ab 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -4953,8 +4953,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) const View3D *v3d_default = DNA_struct_default_get(View3D); wm->xr.session_settings.shading = v3d_default->shading; - /* Don't rotate light with the viewer by default, make it fixed. */ - wm->xr.session_settings.shading.flag |= V3D_SHADING_WORLD_ORIENTATION; wm->xr.session_settings.draw_flags = (V3D_OFSDRAW_SHOW_GRIDFLOOR | V3D_OFSDRAW_SHOW_ANNOTATION); wm->xr.session_settings.clip_start = v3d_default->clip_start; @@ -5112,6 +5110,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { + /* Don't rotate light with the viewer by default, make it fixed. Shading settings can't be + * edited and this flag should always be set. So we can always execute this. */ + wm->xr.session_settings.shading.flag |= V3D_SHADING_WORLD_ORIENTATION; + } + /* Keep this block, even when empty. */ } } diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 746920e38c6..015e631dc14 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -488,7 +488,8 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl, MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(iter->ob, gps->mat_nr + 1); bool hide_material = (gp_style->flag & GP_MATERIAL_HIDE) != 0; - bool show_stroke = (gp_style->flag & GP_MATERIAL_STROKE_SHOW) != 0; + bool show_stroke = ((gp_style->flag & GP_MATERIAL_STROKE_SHOW) != 0) || + ((gps->flag & GP_STROKE_NOFILL) != 0); bool show_fill = (gps->tot_triangles > 0) && ((gp_style->flag & GP_MATERIAL_FILL_SHOW) != 0) && (!iter->pd->simplify_fill) && ((gps->flag & GP_STROKE_NOFILL) == 0); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 22fbffa9030..2ee1ecccd56 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -767,8 +767,6 @@ static bool ui_but_update_from_old_block(const bContext *C, but->editstr = oldbut->editstr; but->editval = oldbut->editval; but->editvec = oldbut->editvec; - but->editcoba = oldbut->editcoba; - but->editcumap = oldbut->editcumap; but->selsta = oldbut->selsta; but->selend = oldbut->selend; but->softmin = oldbut->softmin; @@ -3797,6 +3795,18 @@ static void ui_but_alloc_info(const eButType type, alloc_size = sizeof(uiButHSVCube); alloc_str = "uiButHSVCube"; break; + case UI_BTYPE_COLORBAND: + alloc_size = sizeof(uiButColorBand); + alloc_str = "uiButColorBand"; + break; + case UI_BTYPE_CURVE: + alloc_size = sizeof(uiButCurveMapping); + alloc_str = "uiButCurveMapping"; + break; + case UI_BTYPE_CURVEPROFILE: + alloc_size = sizeof(uiButCurveProfile); + alloc_str = "uiButCurveProfile"; + break; default: alloc_size = sizeof(uiBut); alloc_str = "uiBut"; diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 44c3ccccda8..6cd274c8b15 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1639,7 +1639,9 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const struct ColorManagedDisplay *display = ui_block_cm_display_get(but->block); uint pos_id, col_id; - ColorBand *coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin); + uiButColorBand *but_coba = (uiButColorBand *)but; + ColorBand *coba = (but_coba->edit_coba == NULL) ? (ColorBand *)but->poin : but_coba->edit_coba; + if (coba == NULL) { return; } @@ -1888,14 +1890,9 @@ static void gl_shaded_color(const uchar *color, int shade) void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol, const rcti *rect) { - CurveMapping *cumap; - - if (but->editcumap) { - cumap = but->editcumap; - } - else { - cumap = (CurveMapping *)but->poin; - } + uiButCurveMapping *but_cumap = (uiButCurveMapping *)but; + CurveMapping *cumap = (but_cumap->edit_cumap == NULL) ? (CurveMapping *)but->poin : + but_cumap->edit_cumap; float clip_size_x = BLI_rctf_size_x(&cumap->curr); float clip_size_y = BLI_rctf_size_y(&cumap->curr); @@ -2179,13 +2176,10 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, { uint i; float fx, fy; - CurveProfile *profile; - if (but->editprofile) { - profile = but->editprofile; - } - else { - profile = (CurveProfile *)but->poin; - } + + uiButCurveProfile *but_profile = (uiButCurveProfile *)but; + CurveProfile *profile = (but_profile->edit_profile == NULL) ? (CurveProfile *)but->poin : + but_profile->edit_profile; /* Calculate offset and zoom. */ float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&profile->view_rect); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 2d3a6181f09..dcae3b9a104 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2086,15 +2086,33 @@ static void ui_apply_but( editstr = but->editstr; editval = but->editval; editvec = but->editvec; - editcoba = but->editcoba; - editcumap = but->editcumap; - editprofile = but->editprofile; + if (but->type == UI_BTYPE_COLORBAND) { + uiButColorBand *but_coba = (uiButColorBand *)but; + editcoba = but_coba->edit_coba; + } + else if (but->type == UI_BTYPE_CURVE) { + uiButCurveMapping *but_cumap = (uiButCurveMapping *)but; + editcumap = but_cumap->edit_cumap; + } + else if (but->type == UI_BTYPE_CURVEPROFILE) { + uiButCurveProfile *but_profile = (uiButCurveProfile *)but; + editprofile = but_profile->edit_profile; + } but->editstr = NULL; but->editval = NULL; but->editvec = NULL; - but->editcoba = NULL; - but->editcumap = NULL; - but->editprofile = NULL; + if (but->type == UI_BTYPE_COLORBAND) { + uiButColorBand *but_coba = (uiButColorBand *)but; + but_coba->edit_coba = NULL; + } + else if (but->type == UI_BTYPE_CURVE) { + uiButCurveMapping *but_cumap = (uiButCurveMapping *)but; + but_cumap->edit_cumap = NULL; + } + else if (but->type == UI_BTYPE_CURVEPROFILE) { + uiButCurveProfile *but_profile = (uiButCurveProfile *)but; + but_profile->edit_profile = NULL; + } /* handle different types */ switch (but->type) { @@ -2203,9 +2221,18 @@ static void ui_apply_but( but->editstr = editstr; but->editval = editval; but->editvec = editvec; - but->editcoba = editcoba; - but->editcumap = editcumap; - but->editprofile = editprofile; + if (but->type == UI_BTYPE_COLORBAND) { + uiButColorBand *but_coba = (uiButColorBand *)but; + but_coba->edit_coba = editcoba; + } + else if (but->type == UI_BTYPE_CURVE) { + uiButCurveMapping *but_cumap = (uiButCurveMapping *)but; + but_cumap->edit_cumap = editcumap; + } + else if (but->type == UI_BTYPE_CURVEPROFILE) { + uiButCurveProfile *but_profile = (uiButCurveProfile *)but; + but_profile->edit_profile = editprofile; + } } /** \} */ @@ -3848,14 +3875,17 @@ static void ui_do_but_textedit_select( static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data) { if (but->type == UI_BTYPE_CURVE) { - but->editcumap = (CurveMapping *)but->poin; + uiButCurveMapping *but_cumap = (uiButCurveMapping *)but; + but_cumap->edit_cumap = (CurveMapping *)but->poin; } - if (but->type == UI_BTYPE_CURVEPROFILE) { - but->editprofile = (CurveProfile *)but->poin; + else if (but->type == UI_BTYPE_CURVEPROFILE) { + uiButCurveProfile *but_profile = (uiButCurveProfile *)but; + but_profile->edit_profile = (CurveProfile *)but->poin; } else if (but->type == UI_BTYPE_COLORBAND) { + uiButColorBand *but_coba = (uiButColorBand *)but; data->coba = (ColorBand *)but->poin; - but->editcoba = data->coba; + but_coba->edit_coba = data->coba; } else if (ELEM(but->type, UI_BTYPE_UNITVEC, @@ -3941,10 +3971,18 @@ static void ui_numedit_end(uiBut *but, uiHandleButtonData *data) { but->editval = NULL; but->editvec = NULL; - but->editcoba = NULL; - but->editcumap = NULL; - but->editprofile = NULL; - + if (but->type == UI_BTYPE_COLORBAND) { + uiButColorBand *but_coba = (uiButColorBand *)but; + but_coba->edit_coba = NULL; + } + else if (but->type == UI_BTYPE_CURVE) { + uiButCurveMapping *but_cumap = (uiButCurveMapping *)but; + but_cumap->edit_cumap = NULL; + } + else if (but->type == UI_BTYPE_CURVEPROFILE) { + uiButCurveProfile *but_profile = (uiButCurveProfile *)but; + but_profile->edit_profile = NULL; + } data->dragstartx = 0; data->draglastx = 0; data->dragchange = false; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 6718db39e61..eb1bd1ba42e 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -33,6 +33,8 @@ struct AnimationEvalContext; struct ARegion; +struct CurveMapping; +struct CurveProfile; struct ID; struct ImBuf; struct Scene; @@ -266,9 +268,6 @@ struct uiBut { char *editstr; double *editval; float *editvec; - void *editcoba; - void *editcumap; - void *editprofile; uiButPushedStateFunc pushed_state_func; void *pushed_state_arg; @@ -320,6 +319,7 @@ typedef struct uiButDecorator { int rnaindex; } uiButDecorator; +/** Derived struct for #UI_BTYPE_PROGRESS_BAR. */ typedef struct uiButProgressbar { uiBut but; @@ -327,12 +327,34 @@ typedef struct uiButProgressbar { float progress; } uiButProgressbar; +/** Derived struct for #UI_BTYPE_HSVCUBE. */ typedef struct uiButHSVCube { uiBut but; eButGradientType gradient_type; } uiButHSVCube; +/** Derived struct for #UI_BTYPE_CURVEPROFILE. */ +typedef struct uiButColorBand { + uiBut but; + + struct ColorBand *edit_coba; +} uiButColorBand; + +/** Derived struct for #UI_BTYPE_CURVEPROFILE. */ +typedef struct uiButCurveProfile { + uiBut but; + + struct CurveProfile *edit_profile; +} uiButCurveProfile; + +/** Derived struct for #UI_BTYPE_CURVE. */ +typedef struct uiButCurveMapping { + uiBut but; + + struct CurveMapping *edit_cumap; +} uiButCurveMapping; + /** * Additional, superimposed icon for a button, invoking an operator. */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index ff9673a4262..b986ebb75b6 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1732,6 +1732,8 @@ void ED_view3d_xr_shading_update(wmWindowManager *wm, const View3D *v3d, const S { if (v3d->runtime.flag & V3D_RUNTIME_XR_SESSION_ROOT) { View3DShading *xr_shading = &wm->xr.session_settings.shading; + /* Flags that shouldn't be overridden by the 3D View shading. */ + const int flag_copy = V3D_SHADING_WORLD_ORIENTATION; BLI_assert(WM_xr_session_exists(&wm->xr)); @@ -1749,7 +1751,9 @@ void ED_view3d_xr_shading_update(wmWindowManager *wm, const View3D *v3d, const S } /* Copy shading from View3D to VR view. */ + const int old_xr_shading_flag = xr_shading->flag; *xr_shading = v3d->shading; + xr_shading->flag = (xr_shading->flag & ~flag_copy) | (old_xr_shading_flag & flag_copy); if (v3d->shading.prop) { xr_shading->prop = IDP_CopyProperty(xr_shading->prop); } diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 60b6cc40792..cfc20db12f4 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -1222,7 +1222,7 @@ static void rna_def_colormanage(BlenderRNA *brna) "rna_ColorManagedViewSettings_look_set", "rna_ColorManagedViewSettings_look_itemf"); RNA_def_property_ui_text( - prop, "Look", "Additional transform applied before view transform for an artistic needs"); + prop, "Look", "Additional transform applied before view transform for artistic needs"); RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update"); prop = RNA_def_property(srna, "view_transform", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 262c9f87b66..5d266e910ad 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -6465,7 +6465,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop = RNA_def_property(srna, "simplify_gpencil_shader_fx", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_FX); - RNA_def_property_ui_text(prop, "Shaders Effects", "Display Shader Effects"); + RNA_def_property_ui_text(prop, "Shader Effects", "Display Shader Effects"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "simplify_gpencil_tint", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index 075202e8a79..0790d40d56c 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -513,15 +513,15 @@ void RE_engine_active_view_set(RenderEngine *engine, const char *viewname) float RE_engine_get_camera_shift_x(RenderEngine *engine, Object *camera, bool use_spherical_stereo) { - Render *re = engine->re; - /* When using spherical stereo, get camera shift without multiview, * leaving stereo to be handled by the engine. */ - if (use_spherical_stereo) { - re = NULL; + Render *re = engine->re; + if (use_spherical_stereo || re == NULL) { + return BKE_camera_multiview_shift_x(NULL, camera, NULL); + } + else { + return BKE_camera_multiview_shift_x(&re->r, camera, re->viewname); } - - return BKE_camera_multiview_shift_x(re ? &re->r : NULL, camera, re->viewname); } void RE_engine_get_camera_model_matrix(RenderEngine *engine, @@ -529,16 +529,15 @@ void RE_engine_get_camera_model_matrix(RenderEngine *engine, bool use_spherical_stereo, float *r_modelmat) { - Render *re = engine->re; - /* When using spherical stereo, get model matrix without multiview, * leaving stereo to be handled by the engine. */ - if (use_spherical_stereo) { - re = NULL; + Render *re = engine->re; + if (use_spherical_stereo || re == NULL) { + BKE_camera_multiview_model_matrix(NULL, camera, NULL, (float(*)[4])r_modelmat); + } + else { + BKE_camera_multiview_model_matrix(&re->r, camera, re->viewname, (float(*)[4])r_modelmat); } - - BKE_camera_multiview_model_matrix( - re ? &re->r : NULL, camera, re->viewname, (float(*)[4])r_modelmat); } bool RE_engine_get_spherical_stereo(RenderEngine *engine, Object *camera) diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c b/source/blender/windowmanager/xr/intern/wm_xr_session.c index f3ce7be993f..78dadbf9513 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_session.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c @@ -250,9 +250,14 @@ void wm_xr_session_draw_data_update(const wmXrSessionState *state, switch (event) { case SESSION_STATE_EVENT_START: - /* We want to start the session exactly at landmark position. - * Run-times may have a non-[0,0,0] starting position that we have to subtract for that. */ - copy_v3_v3(draw_data->eye_position_ofs, draw_view->local_pose.position); + if (use_position_tracking) { + /* We want to start the session exactly at landmark position. + * Run-times may have a non-[0,0,0] starting position that we have to subtract for that. */ + copy_v3_v3(draw_data->eye_position_ofs, draw_view->local_pose.position); + } + else { + copy_v3_fl(draw_data->eye_position_ofs, 0.0f); + } break; /* This should be triggered by the VR add-on if a landmark changes. */ case SESSION_STATE_EVENT_RESET_TO_BASE_POSE: diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 8784d9f1744..f923c834e93 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -722,6 +722,19 @@ elseif(WIN32) endif() endif() + if(WITH_OPENVDB) + install( + FILES ${LIBDIR}/openvdb/bin/openvdb.dll + DESTINATION "." + CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel + ) + install( + FILES ${LIBDIR}/openvdb/bin/openvdb_d.dll + DESTINATION "." + CONFIGURATIONS Debug + ) + endif() + if(WITH_PYTHON) string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION}) |