Mesh: Replace MLoop struct with generic attributes #104424

Merged
Hans Goudey merged 261 commits from refactor-mesh-corners-generic into main 2023-03-20 15:55:25 +01:00
258 changed files with 6737 additions and 2041 deletions
Showing only changes of commit b59f40972b - Show all commits

View File

@ -1022,9 +1022,9 @@ if(WITH_CPU_SIMD)
set(COMPILER_SSE2_FLAG)
# Test Neon first since macOS Arm can compile and run x86-64 SSE binaries.
TEST_NEON_SUPPORT()
test_neon_support()
if(NOT SUPPORT_NEON_BUILD)
TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
test_sse_support(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
endif()
endif()
@ -1089,7 +1089,7 @@ if(WITH_INTERNATIONAL)
endif()
endif()
# Enable SIMD support if detected by TEST_SSE_SUPPORT() or TEST_NEON_SUPPORT().
# Enable SIMD support if detected by `test_sse_support()` or `test_neon_support()`.
#
# This is done globally, so that all modules can use it if available, and
# because these are used in headers used by many modules.
@ -1403,89 +1403,89 @@ endif()
if(CMAKE_COMPILER_IS_GNUCC)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_VLA -Werror=vla)
add_check_c_compiler_flag(C_WARNINGS C_WARN_ALL -Wall)
add_check_c_compiler_flag(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
add_check_c_compiler_flag(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
add_check_c_compiler_flag(C_WARNINGS C_WARN_ERROR_VLA -Werror=vla)
# system headers sometimes do this, disable for now, was: -Werror=strict-prototypes
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_LOGICAL_OP -Wlogical-op)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNDEF -Wundef)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_INIT_SELF -Winit-self) # needs -Wuninitialized
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_TYPE_LIMITS -Wtype-limits)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_FORMAT_SIGN -Wformat-signedness)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_RESTRICT -Wrestrict)
add_check_c_compiler_flag(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes)
add_check_c_compiler_flag(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
add_check_c_compiler_flag(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
add_check_c_compiler_flag(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
add_check_c_compiler_flag(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
add_check_c_compiler_flag(C_WARNINGS C_WARN_LOGICAL_OP -Wlogical-op)
add_check_c_compiler_flag(C_WARNINGS C_WARN_UNDEF -Wundef)
add_check_c_compiler_flag(C_WARNINGS C_WARN_INIT_SELF -Winit-self) # needs -Wuninitialized
add_check_c_compiler_flag(C_WARNINGS C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
add_check_c_compiler_flag(C_WARNINGS C_WARN_TYPE_LIMITS -Wtype-limits)
add_check_c_compiler_flag(C_WARNINGS C_WARN_FORMAT_SIGN -Wformat-signedness)
add_check_c_compiler_flag(C_WARNINGS C_WARN_RESTRICT -Wrestrict)
# C-only.
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_NULL -Wnonnull)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ABSOLUTE_VALUE -Wabsolute-value)
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_NULL -Wnonnull)
add_check_c_compiler_flag(C_WARNINGS C_WARN_ABSOLUTE_VALUE -Wabsolute-value)
# gcc 4.2 gives annoying warnings on every file with this
if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
add_check_c_compiler_flag(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
endif()
# versions before gcc4.6 give many BLI_math warnings
if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.6")
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_REDUNDANT_DECLS -Wredundant-decls)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls)
add_check_c_compiler_flag(C_WARNINGS C_WARN_REDUNDANT_DECLS -Wredundant-decls)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls)
endif()
# versions before gcc4.8 include global name-space.
if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.8")
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_SHADOW -Wshadow)
add_check_c_compiler_flag(C_WARNINGS C_WARN_SHADOW -Wshadow)
endif()
# disable because it gives warnings for printf() & friends.
# ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
# add_check_c_compiler_flag(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
if(NOT APPLE)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
endif()
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_LOGICAL_OP -Wlogical-op)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_INIT_SELF -Winit-self) # needs -Wuninitialized
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_TYPE_LIMITS -Wtype-limits)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ERROR_RETURN_TYPE -Werror=return-type)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_POINTER_ARITH -Wpointer-arith)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_PARAMETER -Wunused-parameter)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_WRITE_STRINGS -Wwrite-strings)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_FORMAT_SIGN -Wformat-signedness)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_RESTRICT -Wrestrict)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_ALL -Wall)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_LOGICAL_OP -Wlogical-op)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_INIT_SELF -Winit-self) # needs -Wuninitialized
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_TYPE_LIMITS -Wtype-limits)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_ERROR_RETURN_TYPE -Werror=return-type)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_POINTER_ARITH -Wpointer-arith)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNUSED_PARAMETER -Wunused-parameter)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_WRITE_STRINGS -Wwrite-strings)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_FORMAT_SIGN -Wformat-signedness)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_RESTRICT -Wrestrict)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override)
# gcc 4.2 gives annoying warnings on every file with this
if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
endif()
# causes too many warnings
if(NOT APPLE)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
endif()
# Use 'ATTR_FALLTHROUGH' macro to suppress.
if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0"))
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5)
add_check_c_compiler_flag(C_WARNINGS C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5)
endif()
@ -1501,102 +1501,102 @@ if(CMAKE_COMPILER_IS_GNUCC)
# If code in `./extern/` needs to suppress these flags that can be done on a case-by-case basis.
# flags to undo strict flags
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_TYPE_LIMITS -Wno-type-limits)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_INT_IN_BOOL_CONTEXT -Wno-int-in-bool-context)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_FORMAT -Wno-format)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_SWITCH -Wno-switch)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_TYPE_LIMITS -Wno-type-limits)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_INT_IN_BOOL_CONTEXT -Wno-int-in-bool-context)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_FORMAT -Wno-format)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_SWITCH -Wno-switch)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CLASS_MEMACCESS -Wno-class-memaccess)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_COMMENT -Wno-comment)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CLASS_MEMACCESS -Wno-class-memaccess)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_COMMENT -Wno-comment)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized)
if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0"))
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough)
endif()
if(NOT APPLE)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
endif()
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
# strange, clang complains these are not supported, but then uses them.
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
add_check_c_compiler_flag(C_WARNINGS C_WARN_ALL -Wall)
add_check_c_compiler_flag(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
add_check_c_compiler_flag(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
add_check_c_compiler_flag(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes)
add_check_c_compiler_flag(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
add_check_c_compiler_flag(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_ALL -Wall)
# Using C++20 features while having C++17 as the project language isn't allowed by MSVC.
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_CXX20_DESIGNATOR -Wc++20-designator)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_CXX20_DESIGNATOR -Wc++20-designator)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_OVERLOADED_VIRTUAL -Wno-overloaded-virtual) # we get a lot of these, if its a problem a dev needs to look into it.
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_OVERLOADED_VIRTUAL -Wno-overloaded-virtual) # we get a lot of these, if its a problem a dev needs to look into it.
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
# Apple Clang (tested on version 12) doesn't support this flag while LLVM Clang 11 does.
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override)
# gives too many unfixable warnings
# ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_MACROS -Wunused-macros)
# ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_MACROS -Wunused-macros)
# add_check_c_compiler_flag(C_WARNINGS C_WARN_UNUSED_MACROS -Wunused-macros)
# add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNUSED_MACROS -Wunused-macros)
# ---------------------
# Suppress Strict Flags
# flags to undo strict flags
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNDEF -Wno-undef)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_BUT_SET_VARIABLE -Wno-unused-but-set-variable)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNDEF -Wno-undef)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_BUT_SET_VARIABLE -Wno-unused-but-set-variable)
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_REORDER -Wno-reorder)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_COMMENT -Wno-comment)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNDEFINED_VAR_TEMPLATE -Wno-undefined-var-template)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_INSTANTIATION_AFTER_SPECIALIZATION -Wno-instantiation-after-specialization)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_REORDER -Wno-reorder)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_COMMENT -Wno-comment)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNDEFINED_VAR_TEMPLATE -Wno-undefined-var-template)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_INSTANTIATION_AFTER_SPECIALIZATION -Wno-instantiation-after-specialization)
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation)
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
add_check_c_compiler_flag(C_WARNINGS C_WARN_ALL -Wall)
add_check_c_compiler_flag(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_ALL -Wall)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
# disable numbered, false positives
string(APPEND C_WARNINGS " -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199")
@ -1709,8 +1709,8 @@ endif()
if(WITH_COMPILER_SHORT_FILE_MACRO)
# Use '-fmacro-prefix-map' for Clang and GCC (MSVC doesn't support this).
ADD_CHECK_C_COMPILER_FLAG(C_PREFIX_MAP_FLAGS C_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_PREFIX_MAP_FLAGS CXX_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar)
add_check_c_compiler_flag(C_PREFIX_MAP_FLAGS C_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar)
add_check_cxx_compiler_flag(CXX_PREFIX_MAP_FLAGS CXX_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar)
if(C_MACRO_PREFIX_MAP AND CXX_MACRO_PREFIX_MAP)
if(APPLE)
if(XCODE AND ${XCODE_VERSION} VERSION_LESS 12.0)

View File

@ -150,10 +150,10 @@ endif()
# BUILD_PLATFORM is taken from CMake
# but BUILD_DATE and BUILD_TIME are platform dependent
if(NOT BUILD_DATE)
STRING(TIMESTAMP BUILD_DATE "%Y-%m-%d" UTC)
string(TIMESTAMP BUILD_DATE "%Y-%m-%d" UTC)
endif()
if(NOT BUILD_TIME)
STRING(TIMESTAMP BUILD_TIME "%H:%M:%S" UTC)
string(TIMESTAMP BUILD_TIME "%H:%M:%S" UTC)
endif()
# Write a file with the BUILD_HASH define

View File

@ -381,7 +381,7 @@ function(blender_add_test_suite)
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Figure out the release dir, as some tests need files from there.
GET_BLENDER_TEST_INSTALL_DIR(TEST_INSTALL_DIR)
get_blender_test_install_dir(TEST_INSTALL_DIR)
if(APPLE)
set(_test_release_dir ${TEST_INSTALL_DIR}/Blender.app/Contents/Resources/${BLENDER_VERSION})
else()
@ -424,10 +424,10 @@ function(blender_add_test_lib
# This duplicates logic that's also in GTestTesting.cmake, macro BLENDER_SRC_GTEST_EX.
# TODO(Sybren): deduplicate after the general approach in D7649 has been approved.
LIST(APPEND includes
list(APPEND includes
${CMAKE_SOURCE_DIR}/tests/gtests
)
LIST(APPEND includes_sys
list(APPEND includes_sys
${GLOG_INCLUDE_DIRS}
${GFLAGS_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/extern/gtest/include
@ -468,7 +468,7 @@ function(blender_add_test_executable
## Otherwise external projects will produce warnings that we cannot fix.
remove_strict_flags()
BLENDER_SRC_GTEST_EX(
blender_src_gtest_ex(
NAME ${name}
SRC "${sources}"
EXTRA_LIBS "${library_deps}"
@ -764,7 +764,7 @@ function(ADD_CHECK_C_COMPILER_FLAG
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
check_c_compiler_flag("${_FLAG}" "${_CACHE_VAR}")
if(${_CACHE_VAR})
# message(STATUS "Using CFLAG: ${_FLAG}")
set(${_CFLAGS} "${${_CFLAGS}} ${_FLAG}" PARENT_SCOPE)
@ -781,7 +781,7 @@ function(ADD_CHECK_CXX_COMPILER_FLAG
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
check_cxx_compiler_flag("${_FLAG}" "${_CACHE_VAR}")
if(${_CACHE_VAR})
# message(STATUS "Using CXXFLAG: ${_FLAG}")
set(${_CXXFLAGS} "${${_CXXFLAGS}} ${_FLAG}" PARENT_SCOPE)
@ -799,9 +799,11 @@ function(get_blender_version)
# - BLENDER_VERSION_PATCH
# - BLENDER_VERSION_CYCLE (alpha, beta, rc, release)
# So cmake depends on BKE_blender.h, beware of inf-loops!
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender_version.h
${CMAKE_BINARY_DIR}/source/blender/blenkernel/BKE_blender_version.h.done)
# So CMAKE depends on `BKE_blender.h`, beware of infinite-loops!
configure_file(
${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender_version.h
${CMAKE_BINARY_DIR}/source/blender/blenkernel/BKE_blender_version.h.done
)
file(STRINGS ${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender_version.h _contents REGEX "^#define[ \t]+BLENDER_.*$")

View File

@ -17,9 +17,9 @@ set(CPACK_PACKAGE_VENDOR ${PROJECT_VENDOR})
set(CPACK_PACKAGE_CONTACT ${PROJECT_CONTACT})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
SET(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
set(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
set(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
# Get the build revision, note that this can get out-of-sync, so for packaging run cmake first.

View File

@ -1089,7 +1089,7 @@ function(CONFIGURE_ATOMIC_LIB_IF_NEEDED)
endif()
endfunction()
CONFIGURE_ATOMIC_LIB_IF_NEEDED()
configure_atomic_lib_if_needed()
if(PLATFORM_BUNDLED_LIBRARIES)
# For the installed Python module and installed Blender executable, we set the

View File

@ -26,7 +26,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(OPENMP_FOUND ON)
set(OpenMP_C_FLAGS "/clang:-fopenmp")
set(OpenMP_CXX_FLAGS "/clang:-fopenmp")
GET_FILENAME_COMPONENT(LLVMROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\LLVM\\LLVM;]" ABSOLUTE CACHE)
get_filename_component(LLVMROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\LLVM\\LLVM;]" ABSOLUTE CACHE)
set(CLANG_OPENMP_DLL "${LLVMROOT}/bin/libomp.dll")
set(CLANG_OPENMP_LIB "${LLVMROOT}/lib/libomp.lib")
if(NOT EXISTS "${CLANG_OPENMP_DLL}")
@ -874,8 +874,8 @@ endif()
if(WINDOWS_PYTHON_DEBUG)
# Include the system scripts in the blender_python_system_scripts project.
FILE(GLOB_RECURSE inFiles "${CMAKE_SOURCE_DIR}/release/scripts/*.*" )
ADD_CUSTOM_TARGET(blender_python_system_scripts SOURCES ${inFiles})
file(GLOB_RECURSE inFiles "${CMAKE_SOURCE_DIR}/release/scripts/*.*" )
add_custom_target(blender_python_system_scripts SOURCES ${inFiles})
foreach(_source IN ITEMS ${inFiles})
get_filename_component(_source_path "${_source}" PATH)
string(REPLACE "${CMAKE_SOURCE_DIR}/release/scripts/" "" _source_path "${_source_path}")
@ -895,8 +895,8 @@ if(WINDOWS_PYTHON_DEBUG)
endif()
file(TO_CMAKE_PATH ${USER_SCRIPTS_ROOT} USER_SCRIPTS_ROOT)
FILE(GLOB_RECURSE inFiles "${USER_SCRIPTS_ROOT}/*.*" )
ADD_CUSTOM_TARGET(blender_python_user_scripts SOURCES ${inFiles})
file(GLOB_RECURSE inFiles "${USER_SCRIPTS_ROOT}/*.*" )
add_custom_target(blender_python_user_scripts SOURCES ${inFiles})
foreach(_source IN ITEMS ${inFiles})
get_filename_component(_source_path "${_source}" PATH)
string(REPLACE "${USER_SCRIPTS_ROOT}" "" _source_path "${_source_path}")

View File

@ -78,9 +78,10 @@ Signal Handlers
to cancel a render and a crash log is not written in the event of a crash.
Startup and Preferences
When the ``bpy`` module loads, the file is not empty as you might expect,
there is a default cube, camera and light. If you wish to start from a blank file use:
``bpy.ops.wm.read_factory_settings(use_empty=True)``.
When the ``bpy`` module loads it contains the default startup scene
(instead of an "empty" blend-file as you might expect), so there is a default cube, camera and light.
If you wish to start from an empty file use: ``bpy.ops.wm.read_factory_settings(use_empty=True)``.
The users startup and preferences are ignored to prevent your local configuration from impacting scripts behavior.
The Python module behaves as if ``--factory-startup`` was passed as a command line argument.
@ -101,9 +102,10 @@ Limitations
Most constraints of Blender as an application still apply:
Reloading Unsupported
Reloading via ``importlib.reload`` will raise an exception instead of reloading and resetting the module.
Reloading the ``bpy`` module via ``importlib.reload`` will raise an exception
instead of reloading and resetting the module.
The operator ``bpy.ops.wm.read_factory_settings()`` can be used to reset the internal state.
Instead, the operator ``bpy.ops.wm.read_factory_settings()`` can be used to reset the internal state.
Single Blend File Restriction
Only a single ``.blend`` file can be edited at a time.

View File

@ -36,7 +36,7 @@ if(WITH_CYCLES_NATIVE_ONLY)
)
if(NOT MSVC)
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_march_native "-march=native")
add_check_cxx_compiler_flag(CMAKE_CXX_FLAGS _has_march_native "-march=native")
if(_has_march_native)
set(CYCLES_KERNEL_FLAGS "-march=native")
else()
@ -45,18 +45,18 @@ if(WITH_CYCLES_NATIVE_ONLY)
unset(_has_march_native)
else()
if(NOT MSVC_NATIVE_ARCH_FLAGS)
TRY_RUN(
arch_run_result
arch_compile_result
${CMAKE_CURRENT_BINARY_DIR}/
${CMAKE_CURRENT_SOURCE_DIR}/cmake/msvc_arch_flags.c
COMPILE_OUTPUT_VARIABLE arch_compile_output
RUN_OUTPUT_VARIABLE arch_run_output
)
if(arch_compile_result AND "${arch_run_result}" EQUAL "0")
string(STRIP ${arch_run_output} arch_run_output)
set(MSVC_NATIVE_ARCH_FLAGS ${arch_run_output} CACHE STRING "MSVC Native architecture flags")
endif()
try_run(
arch_run_result
arch_compile_result
${CMAKE_CURRENT_BINARY_DIR}/
${CMAKE_CURRENT_SOURCE_DIR}/cmake/msvc_arch_flags.c
COMPILE_OUTPUT_VARIABLE arch_compile_output
RUN_OUTPUT_VARIABLE arch_run_output
)
if(arch_compile_result AND "${arch_run_result}" EQUAL "0")
string(STRIP ${arch_run_output} arch_run_output)
set(MSVC_NATIVE_ARCH_FLAGS ${arch_run_output} CACHE STRING "MSVC Native architecture flags")
endif()
endif()
set(CYCLES_KERNEL_FLAGS "${MSVC_NATIVE_ARCH_FLAGS}")
endif()
@ -364,7 +364,7 @@ endif()
# Warnings
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang")
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_no_error_unused_macros "-Wno-error=unused-macros")
add_check_cxx_compiler_flag(CMAKE_CXX_FLAGS _has_no_error_unused_macros "-Wno-error=unused-macros")
unset(_has_no_error_unused_macros)
endif()

View File

@ -1081,23 +1081,23 @@ static void create_subd_mesh(Scene *scene,
const int edges_num = b_mesh.edges.length();
if (edges_num != 0) {
if (edges_num != 0 && b_mesh.edge_creases.length() > 0) {
size_t num_creases = 0;
const MEdge *edges = static_cast<MEdge *>(b_mesh.edges[0].ptr.data);
const float *creases = static_cast<float *>(b_mesh.edge_creases[0].ptr.data);
for (int i = 0; i < edges_num; i++) {
const MEdge &b_edge = edges[i];
if (b_edge.crease != 0) {
if (creases[i] != 0.0f) {
num_creases++;
}
}
mesh->reserve_subd_creases(num_creases);
const MEdge *edges = static_cast<MEdge *>(b_mesh.edges[0].ptr.data);
for (int i = 0; i < edges_num; i++) {
const MEdge &b_edge = edges[i];
if (b_edge.crease != 0) {
mesh->add_edge_crease(b_edge.v1, b_edge.v2, float(b_edge.crease) / 255.0f);
if (creases[i] != 0.0f) {
const MEdge &b_edge = edges[i];
mesh->add_edge_crease(b_edge.v1, b_edge.v2, creases[i]);
}
}

View File

@ -529,7 +529,7 @@ if(WITH_CYCLES_CUDA_BINARIES)
endif()
if(DEFINED cuda_nvcc_executable AND DEFINED cuda_toolkit_root_dir)
# Compile regular kernel
CYCLES_CUDA_KERNEL_ADD(${arch} ${prev_arch} kernel "" "${cuda_sources}" FALSE)
cycles_cuda_kernel_add(${arch} ${prev_arch} kernel "" "${cuda_sources}" FALSE)
if(WITH_CYCLES_CUDA_BUILD_SERIAL)
set(prev_arch ${arch})
@ -611,7 +611,7 @@ if(WITH_CYCLES_HIP_BINARIES AND WITH_CYCLES_DEVICE_HIP)
foreach(arch ${CYCLES_HIP_BINARIES_ARCH})
# Compile regular kernel
CYCLES_HIP_KERNEL_ADD(${arch} kernel "" "${hip_sources}" FALSE)
cycles_hip_kernel_add(${arch} kernel "" "${hip_sources}" FALSE)
endforeach()
add_custom_target(cycles_kernel_hip ALL DEPENDS ${hip_fatbins})
@ -696,11 +696,11 @@ if(WITH_CYCLES_DEVICE_OPTIX AND WITH_CYCLES_CUDA_BINARIES)
delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${output}" ${CYCLES_INSTALL_PATH}/lib)
endmacro()
CYCLES_OPTIX_KERNEL_ADD(
cycles_optix_kernel_add(
kernel_optix
"device/optix/kernel.cu"
"")
CYCLES_OPTIX_KERNEL_ADD(
cycles_optix_kernel_add(
kernel_optix_shader_raytrace
"device/optix/kernel_shader_raytrace.cu"
"--keep-device-functions")
@ -950,8 +950,8 @@ endif()
# Warnings to avoid using doubles in the kernel.
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang")
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_cxxflag_float_conversion "-Werror=float-conversion")
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_cxxflag_double_promotion "-Werror=double-promotion")
add_check_cxx_compiler_flag(CMAKE_CXX_FLAGS _has_cxxflag_float_conversion "-Werror=float-conversion")
add_check_cxx_compiler_flag(CMAKE_CXX_FLAGS _has_cxxflag_double_promotion "-Werror=double-promotion")
unset(_has_cxxflag_float_conversion)
unset(_has_cxxflag_double_promotion)
endif()

View File

@ -10,6 +10,7 @@
#define CCL_NAMESPACE_END
#include <cstdint>
#include <math.h>
#ifndef __NODES_MAX_GROUP__
# define __NODES_MAX_GROUP__ NODE_GROUP_LEVEL_MAX
@ -174,21 +175,15 @@ using sycl::half;
#define fmodf(x, y) sycl::fmod((x), (y))
#define lgammaf(x) sycl::lgamma((x))
#define __forceinline __attribute__((always_inline))
/* Types */
#include "util/half.h"
#include "util/types.h"
/* NOTE(@nsirgien): Declaring these functions after types headers is very important because they
* include oneAPI headers, which transitively include math.h headers which will cause redefinitions
* of the math defines because math.h also uses them and having them defined before math.h include
* is actually UB. */
/* Use fast math functions - get them from sycl::native namespace for native math function
* implementations */
#define cosf(x) sycl::native::cos(((float)(x)))
#define sinf(x) sycl::native::sin(((float)(x)))
#define powf(x, y) sycl::native::powr(((float)(x)), ((float)(y)))
#define tanf(x) sycl::native::tan(((float)(x)))
#define logf(x) sycl::native::log(((float)(x)))
#define expf(x) sycl::native::exp(((float)(x)))
#define __forceinline __attribute__((always_inline))
/* Types */
#include "util/half.h"
#include "util/types.h"

View File

@ -101,7 +101,7 @@ if(WITH_CYCLES_OSL)
cycles_kernel_osl
)
SET_PROPERTY(SOURCE osl.cpp PROPERTY COMPILE_FLAGS ${RTTI_DISABLE_FLAGS})
set_property(SOURCE osl.cpp PROPERTY COMPILE_FLAGS ${RTTI_DISABLE_FLAGS})
endif()
if(WITH_OPENCOLORIO)

View File

@ -59,5 +59,5 @@ if(NOT APPLE)
endif()
if(WITH_GTESTS)
BLENDER_SRC_GTEST(cycles "${SRC}" "${LIB}")
blender_src_gtest(cycles "${SRC}" "${LIB}")
endif()

View File

@ -36,19 +36,19 @@ class GHOST_Context : public GHOST_IContext {
* Swaps front and back buffers of a window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess swapBuffers() = 0;
virtual GHOST_TSuccess swapBuffers() override = 0;
/**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess activateDrawingContext() = 0;
virtual GHOST_TSuccess activateDrawingContext() override = 0;
/**
* Release the drawing context of the calling thread.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess releaseDrawingContext() = 0;
virtual GHOST_TSuccess releaseDrawingContext() override = 0;
/**
* Call immediately after new to initialize. If this fails then immediately delete the object.
@ -130,7 +130,7 @@ class GHOST_Context : public GHOST_IContext {
* Gets the OpenGL frame-buffer associated with the OpenGL context
* \return The ID of an OpenGL frame-buffer object.
*/
virtual unsigned int getDefaultFramebuffer()
virtual unsigned int getDefaultFramebuffer() override
{
return 0;
}

View File

@ -9,8 +9,13 @@
#include "GHOST_Context.h"
#include <Cocoa/Cocoa.h>
#include <Metal/Metal.h>
#include <QuartzCore/QuartzCore.h>
@class CAMetalLayer;
@class MTLCommandQueue;
@class MTLDevice;
@class MTLRenderPipelineState;
@class MTLTexture;
@class NSOpenGLContext;
@ -36,62 +41,89 @@ class GHOST_ContextCGL : public GHOST_Context {
* Swaps front and back buffers of a window.
* \return A boolean success indicator.
*/
GHOST_TSuccess swapBuffers();
GHOST_TSuccess swapBuffers() override;
/**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
GHOST_TSuccess activateDrawingContext();
GHOST_TSuccess activateDrawingContext() override;
/**
* Release the drawing context of the calling thread.
* \return A boolean success indicator.
*/
GHOST_TSuccess releaseDrawingContext();
GHOST_TSuccess releaseDrawingContext() override;
unsigned int getDefaultFramebuffer();
unsigned int getDefaultFramebuffer() override;
/**
* Call immediately after new to initialize. If this fails then immediately delete the object.
* \return Indication as to whether initialization has succeeded.
*/
GHOST_TSuccess initializeDrawingContext();
GHOST_TSuccess initializeDrawingContext() override;
/**
* Removes references to native handles from this context and then returns
* \return GHOST_kSuccess if it is OK for the parent to release the handles and
* GHOST_kFailure if releasing the handles will interfere with sharing
*/
GHOST_TSuccess releaseNativeHandles();
GHOST_TSuccess releaseNativeHandles() override;
/**
* Sets the swap interval for #swapBuffers.
* \param interval: The swap interval to use.
* \return A boolean success indicator.
*/
GHOST_TSuccess setSwapInterval(int interval);
GHOST_TSuccess setSwapInterval(int interval) override;
/**
* Gets the current swap interval for #swapBuffers.
* \param intervalOut: Variable to store the swap interval if it can be read.
* \return Whether the swap interval can be read.
*/
GHOST_TSuccess getSwapInterval(int &);
GHOST_TSuccess getSwapInterval(int &) override;
/**
* Updates the drawing context of this window.
* Needed whenever the window is changed.
* \return Indication of success.
*/
GHOST_TSuccess updateDrawingContext();
GHOST_TSuccess updateDrawingContext() override;
/**
* Returns a texture that Metal code can use as a render target. The current
* contents of this texture will be composited on top of the frame-buffer
* each time `swapBuffers` is called.
*/
id<MTLTexture> metalOverlayTexture();
/**
* Return a pointer to the Metal command queue used by this context.
*/
MTLCommandQueue *metalCommandQueue();
/**
* Return a pointer to the Metal device associated with this context.
*/
MTLDevice *metalDevice();
/**
* Register present callback
*/
void metalRegisterPresentCallback(void (*callback)(
MTLRenderPassDescriptor *, id<MTLRenderPipelineState>, id<MTLTexture>, id<CAMetalDrawable>));
private:
/** Metal state */
/* Set this flag to `true` when rendering with Metal API for Viewport.
* TODO(Metal): This should be assigned to externally. */
bool m_useMetalForRendering = false;
NSView *m_metalView;
CAMetalLayer *m_metalLayer;
MTLCommandQueue *m_metalCmdQueue;
MTLRenderPipelineState *m_metalRenderPipeline;
bool m_ownsMetalDevice;
/** OpenGL state, for GPUs that don't support Metal */
NSOpenGLView *m_openGLView;
@ -103,8 +135,30 @@ class GHOST_ContextCGL : public GHOST_Context {
unsigned int m_defaultFramebuffer;
/** The virtualized default frame-buffer's texture. */
MTLTexture *m_defaultFramebufferMetalTexture;
/**
* Texture that you can render into with Metal. The texture will be
* composited on top of `m_defaultFramebufferMetalTexture` whenever
* `swapBuffers` is called.
*/
static const int METAL_SWAPCHAIN_SIZE = 3;
struct MTLSwapchainTexture {
id<MTLTexture> texture;
unsigned int index;
};
MTLSwapchainTexture m_defaultFramebufferMetalTexture[METAL_SWAPCHAIN_SIZE];
unsigned int current_swapchain_index = 0;
/* Present callback.
* We use this such that presentation can be controlled from within the Metal
* Context. This is required for optimal performance and clean control flow.
* Also helps ensure flickering does not occur by present being dependent
* on existing submissions. */
void (*contextPresentCallback)(MTLRenderPassDescriptor *,
id<MTLRenderPipelineState>,
id<MTLTexture>,
id<CAMetalDrawable>);
int mtl_SwapInterval;
const bool m_debug;
/** The first created OpenGL context (for sharing display lists) */
@ -117,4 +171,5 @@ class GHOST_ContextCGL : public GHOST_Context {
void metalInitFramebuffer();
void metalUpdateFramebuffer();
void metalSwapBuffers();
void initClear();
};

File diff suppressed because it is too large Load Diff

View File

@ -114,7 +114,7 @@ void *GHOST_DropTargetX11::getURIListGhostData(unsigned char *dropBuffer, int dr
/* Count total number of file paths in buffer. */
for (int i = 0; i <= dropBufferSize; i++) {
if (dropBuffer[i] == 0 || dropBuffer[i] == '\n' || dropBuffer[i] == '\r') {
if (ELEM(dropBuffer[i], 0, '\n', '\r')) {
if (curLength) {
totPaths++;
curLength = 0;
@ -131,7 +131,7 @@ void *GHOST_DropTargetX11::getURIListGhostData(unsigned char *dropBuffer, int dr
curLength = 0;
for (int i = 0; i <= dropBufferSize; i++) {
if (dropBuffer[i] == 0 || dropBuffer[i] == '\n' || dropBuffer[i] == '\r') {
if (ELEM(dropBuffer[i], 0, '\n', '\r')) {
if (curLength) {
char *curPath = (char *)malloc(curLength + 1);
char *decodedPath;
@ -182,7 +182,7 @@ void *GHOST_DropTargetX11::getGhostData(Atom dropType,
data = decodedPath;
}
}
else if (dropType == dndTypePlainText || dropType == dndTypeOctetStream) {
else if (ELEM(dropType, dndTypePlainText, dndTypeOctetStream)) {
m_draggedObjectType = GHOST_kDragnDropTypeString;
data = tmpBuffer;
needsFree = false;

View File

@ -10,6 +10,7 @@
*/
#include "GHOST_ModifierKeys.h"
#include "GHOST_Debug.h"
GHOST_ModifierKeys::GHOST_ModifierKeys()
{
@ -49,7 +50,8 @@ GHOST_TKey GHOST_ModifierKeys::getModifierKeyCode(GHOST_TModifierKey mask)
key = GHOST_kKeyRightOS;
break;
default:
// Should not happen
/* Should not happen. */
GHOST_ASSERT(0, "Invalid key!");
key = GHOST_kKeyUnknown;
break;
}
@ -76,6 +78,7 @@ bool GHOST_ModifierKeys::get(GHOST_TModifierKey mask) const
case GHOST_kModifierKeyRightOS:
return m_RightOS;
default:
GHOST_ASSERT(0, "Invalid key!");
return false;
}
}
@ -108,6 +111,7 @@ void GHOST_ModifierKeys::set(GHOST_TModifierKey mask, bool down)
m_RightOS = down;
break;
default:
GHOST_ASSERT(0, "Invalid key!");
break;
}
}

View File

@ -5,22 +5,17 @@
* \ingroup GHOST
*/
#include <cstdio>
#include <sstream>
#include "GHOST_SystemPathsUnix.h"
#include "GHOST_Debug.h"
// For timing
/* For timing. */
#include <sys/time.h>
#include <unistd.h>
#include <cstdio> /* for fprintf only */
#include <cstdlib> /* for exit */
#include <pwd.h> /* for get home without use getenv() */
#include <pwd.h> /* For get home without use `getenv()`. */
#include <string>
using std::string;

View File

@ -122,6 +122,69 @@ static bool use_gnome_confine_hack = false;
/** \} */
/* -------------------------------------------------------------------- */
/** \name Modifier Table
*
* Convenient access to modifier key values, allow looping over modifier keys.
* \{ */
enum {
MOD_INDEX_SHIFT = 0,
MOD_INDEX_ALT = 1,
MOD_INDEX_CTRL = 2,
MOD_INDEX_OS = 3,
};
#define MOD_INDEX_NUM (MOD_INDEX_OS + 1)
struct GWL_ModifierInfo {
/** Only for printing messages. */
const char *display_name;
const char *xkb_id;
GHOST_TKey key_l, key_r;
GHOST_TModifierKey mod_l, mod_r;
};
static const GWL_ModifierInfo g_modifier_info_table[MOD_INDEX_NUM] = {
[MOD_INDEX_SHIFT] =
{
.display_name = "Shift",
.xkb_id = XKB_MOD_NAME_SHIFT,
.key_l = GHOST_kKeyLeftShift,
.key_r = GHOST_kKeyRightShift,
.mod_l = GHOST_kModifierKeyLeftShift,
.mod_r = GHOST_kModifierKeyRightShift,
},
[MOD_INDEX_ALT] =
{
.display_name = "Alt",
.xkb_id = XKB_MOD_NAME_ALT,
.key_l = GHOST_kKeyLeftAlt,
.key_r = GHOST_kKeyRightAlt,
.mod_l = GHOST_kModifierKeyLeftAlt,
.mod_r = GHOST_kModifierKeyRightAlt,
},
[MOD_INDEX_CTRL] =
{
.display_name = "Control",
.xkb_id = XKB_MOD_NAME_CTRL,
.key_l = GHOST_kKeyLeftControl,
.key_r = GHOST_kKeyRightControl,
.mod_l = GHOST_kModifierKeyLeftControl,
.mod_r = GHOST_kModifierKeyRightControl,
},
[MOD_INDEX_OS] =
{
.display_name = "OS",
.xkb_id = XKB_MOD_NAME_LOGO,
.key_l = GHOST_kKeyLeftOS,
.key_r = GHOST_kKeyRightOS,
.mod_l = GHOST_kModifierKeyLeftOS,
.mod_r = GHOST_kModifierKeyRightOS,
},
};
/** \} */
/* -------------------------------------------------------------------- */
/** \name Private Types & Defines
* \{ */
@ -327,14 +390,7 @@ struct GWL_Seat {
* so every time a modifier is accessed a string lookup isn't required.
* Be sure to check for #XKB_MOD_INVALID before using.
*/
struct {
xkb_mod_index_t shift; /* #XKB_MOD_NAME_SHIFT */
xkb_mod_index_t caps; /* #XKB_MOD_NAME_CAPS */
xkb_mod_index_t ctrl; /* #XKB_MOD_NAME_CTRL */
xkb_mod_index_t alt; /* #XKB_MOD_NAME_ALT */
xkb_mod_index_t num; /* #XKB_MOD_NAME_NUM */
xkb_mod_index_t logo; /* #XKB_MOD_NAME_LOGO */
} xkb_keymap_mod_index;
xkb_mod_index_t xkb_keymap_mod_index[MOD_INDEX_NUM];
struct {
/** Key repetition in character per second. */
@ -2207,12 +2263,10 @@ static void keyboard_handle_keymap(void *data,
}
}
seat->xkb_keymap_mod_index.shift = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_SHIFT);
seat->xkb_keymap_mod_index.caps = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_CAPS);
seat->xkb_keymap_mod_index.ctrl = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_CTRL);
seat->xkb_keymap_mod_index.alt = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_ALT);
seat->xkb_keymap_mod_index.num = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_NUM);
seat->xkb_keymap_mod_index.logo = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_LOGO);
for (int i = 0; i < MOD_INDEX_NUM; i++) {
const GWL_ModifierInfo &mod_info = g_modifier_info_table[i];
seat->xkb_keymap_mod_index[i] = xkb_keymap_mod_get_index(keymap, mod_info.xkb_id);
}
keyboard_depressed_state_reset(seat);
@ -2877,24 +2931,24 @@ static void global_handle_add(void *data,
bool found = true;
struct GWL_Display *display = static_cast<struct GWL_Display *>(data);
if (!strcmp(interface, wl_compositor_interface.name)) {
if (STREQ(interface, wl_compositor_interface.name)) {
display->compositor = static_cast<wl_compositor *>(
wl_registry_bind(wl_registry, name, &wl_compositor_interface, 3));
}
#ifdef WITH_GHOST_WAYLAND_LIBDECOR
/* Pass. */
#else
else if (!strcmp(interface, xdg_wm_base_interface.name)) {
else if (STREQ(interface, xdg_wm_base_interface.name)) {
display->xdg_shell = static_cast<xdg_wm_base *>(
wl_registry_bind(wl_registry, name, &xdg_wm_base_interface, 1));
xdg_wm_base_add_listener(display->xdg_shell, &shell_listener, nullptr);
}
else if (!strcmp(interface, zxdg_decoration_manager_v1_interface.name)) {
else if (STREQ(interface, zxdg_decoration_manager_v1_interface.name)) {
display->xdg_decoration_manager = static_cast<zxdg_decoration_manager_v1 *>(
wl_registry_bind(wl_registry, name, &zxdg_decoration_manager_v1_interface, 1));
}
#endif /* !WITH_GHOST_WAYLAND_LIBDECOR. */
else if (!strcmp(interface, zxdg_output_manager_v1_interface.name)) {
else if (STREQ(interface, zxdg_output_manager_v1_interface.name)) {
display->xdg_output_manager = static_cast<zxdg_output_manager_v1 *>(
wl_registry_bind(wl_registry, name, &zxdg_output_manager_v1_interface, 2));
for (GWL_Output *output : display->outputs) {
@ -2903,7 +2957,7 @@ static void global_handle_add(void *data,
zxdg_output_v1_add_listener(output->xdg_output, &xdg_output_listener, output);
}
}
else if (!strcmp(interface, wl_output_interface.name)) {
else if (STREQ(interface, wl_output_interface.name)) {
GWL_Output *output = new GWL_Output;
output->wl_output = static_cast<wl_output *>(
wl_registry_bind(wl_registry, name, &wl_output_interface, 2));
@ -2919,7 +2973,7 @@ static void global_handle_add(void *data,
zxdg_output_v1_add_listener(output->xdg_output, &xdg_output_listener, output);
}
}
else if (!strcmp(interface, wl_seat_interface.name)) {
else if (STREQ(interface, wl_seat_interface.name)) {
GWL_Seat *seat = new GWL_Seat;
seat->system = display->system;
seat->xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
@ -2929,23 +2983,23 @@ static void global_handle_add(void *data,
display->seats.push_back(seat);
wl_seat_add_listener(seat->wl_seat, &seat_listener, seat);
}
else if (!strcmp(interface, wl_shm_interface.name)) {
else if (STREQ(interface, wl_shm_interface.name)) {
display->shm = static_cast<wl_shm *>(
wl_registry_bind(wl_registry, name, &wl_shm_interface, 1));
}
else if (!strcmp(interface, wl_data_device_manager_interface.name)) {
else if (STREQ(interface, wl_data_device_manager_interface.name)) {
display->data_device_manager = static_cast<wl_data_device_manager *>(
wl_registry_bind(wl_registry, name, &wl_data_device_manager_interface, 3));
}
else if (!strcmp(interface, zwp_tablet_manager_v2_interface.name)) {
else if (STREQ(interface, zwp_tablet_manager_v2_interface.name)) {
display->tablet_manager = static_cast<zwp_tablet_manager_v2 *>(
wl_registry_bind(wl_registry, name, &zwp_tablet_manager_v2_interface, 1));
}
else if (!strcmp(interface, zwp_relative_pointer_manager_v1_interface.name)) {
else if (STREQ(interface, zwp_relative_pointer_manager_v1_interface.name)) {
display->relative_pointer_manager = static_cast<zwp_relative_pointer_manager_v1 *>(
wl_registry_bind(wl_registry, name, &zwp_relative_pointer_manager_v1_interface, 1));
}
else if (!strcmp(interface, zwp_pointer_constraints_v1_interface.name)) {
else if (STREQ(interface, zwp_pointer_constraints_v1_interface.name)) {
display->pointer_constraints = static_cast<zwp_pointer_constraints_v1 *>(
wl_registry_bind(wl_registry, name, &zwp_pointer_constraints_v1_interface, 1));
}
@ -3107,67 +3161,43 @@ GHOST_TSuccess GHOST_SystemWayland::getModifierKeys(GHOST_ModifierKeys &keys) co
GWL_Seat *seat = d->seats[0];
bool val, val_l, val_r;
const xkb_mod_mask_t state = xkb_state_serialize_mods(seat->xkb_state, XKB_STATE_MODS_DEPRESSED);
#define MOD_TEST(state, mod) ((mod != XKB_MOD_INVALID) && (state & (1 << mod)))
/* Use local #WGL_KeyboardDepressedState to check which key is pressed.
* Use XKB as the source of truth, if there is any discrepancy. */
#define MOD_VALIDATE(mod_string) \
if (val) { \
if (!(val_l || val_r)) { \
CLOG_WARN(&LOG_WL_KEYBOARD_DEPRESSED_STATE, \
"modifier (%s) state is inconsistent (held keys do not match XKB)", \
mod_string); \
val_l = true; /* Set one because XKB should have priority. */ \
} \
} \
else { \
if (val_l || val_r) { \
CLOG_WARN(&LOG_WL_KEYBOARD_DEPRESSED_STATE, \
"modifier (%s) state is inconsistent (released keys do not match XKB)", \
mod_string); \
val_l = false; \
val_r = false; \
} \
} \
((void)0)
for (int i = 0; i < MOD_INDEX_NUM; i++) {
if (UNLIKELY(seat->xkb_keymap_mod_index[i] == XKB_MOD_INVALID)) {
continue;
}
const GWL_ModifierInfo &mod_info = g_modifier_info_table[i];
const bool val = (state & (1 << seat->xkb_keymap_mod_index[i])) != 0;
bool val_l = seat->key_depressed.mods[GHOST_KEY_MODIFIER_TO_INDEX(mod_info.key_l)] > 0;
bool val_r = seat->key_depressed.mods[GHOST_KEY_MODIFIER_TO_INDEX(mod_info.key_r)] > 0;
val = MOD_TEST(state, seat->xkb_keymap_mod_index.shift);
val_l = seat->key_depressed.mods[GHOST_KEY_MODIFIER_TO_INDEX(GHOST_kKeyLeftShift)] > 0;
val_r = seat->key_depressed.mods[GHOST_KEY_MODIFIER_TO_INDEX(GHOST_kKeyRightShift)] > 0;
MOD_VALIDATE("Shift");
keys.set(GHOST_kModifierKeyLeftShift, val_l);
keys.set(GHOST_kModifierKeyRightShift, val_r);
/* This shouldn't be needed, but guard against any possibility of modifiers being stuck.
* Warn so if this happens it can be investigated. */
if (val) {
if (UNLIKELY(!(val_l || val_r))) {
CLOG_WARN(&LOG_WL_KEYBOARD_DEPRESSED_STATE,
"modifier (%s) state is inconsistent (held keys do not match XKB)",
mod_info.display_name);
/* Picking the left is arbitrary. */
val_l = true;
}
}
else {
if (UNLIKELY(val_l || val_r)) {
CLOG_WARN(&LOG_WL_KEYBOARD_DEPRESSED_STATE,
"modifier (%s) state is inconsistent (released keys do not match XKB)",
mod_info.display_name);
val_l = false;
val_r = false;
}
}
val = MOD_TEST(state, seat->xkb_keymap_mod_index.alt);
val_l = seat->key_depressed.mods[GHOST_KEY_MODIFIER_TO_INDEX(GHOST_kKeyLeftAlt)] > 0;
val_r = seat->key_depressed.mods[GHOST_KEY_MODIFIER_TO_INDEX(GHOST_kKeyRightAlt)] > 0;
MOD_VALIDATE("Alt");
keys.set(GHOST_kModifierKeyLeftAlt, val_l);
keys.set(GHOST_kModifierKeyRightAlt, val_r);
val = MOD_TEST(state, seat->xkb_keymap_mod_index.ctrl);
val_l = seat->key_depressed.mods[GHOST_KEY_MODIFIER_TO_INDEX(GHOST_kKeyLeftControl)] > 0;
val_r = seat->key_depressed.mods[GHOST_KEY_MODIFIER_TO_INDEX(GHOST_kKeyRightControl)] > 0;
MOD_VALIDATE("Control");
keys.set(GHOST_kModifierKeyLeftControl, val_l);
keys.set(GHOST_kModifierKeyRightControl, val_r);
val = MOD_TEST(state, seat->xkb_keymap_mod_index.logo);
val_l = seat->key_depressed.mods[GHOST_KEY_MODIFIER_TO_INDEX(GHOST_kKeyLeftOS)] > 0;
val_r = seat->key_depressed.mods[GHOST_KEY_MODIFIER_TO_INDEX(GHOST_kKeyRightOS)] > 0;
MOD_VALIDATE("OS");
keys.set(GHOST_kModifierKeyLeftOS, val_l);
keys.set(GHOST_kModifierKeyRightOS, val_r);
val = MOD_TEST(state, seat->xkb_keymap_mod_index.num);
keys.set(GHOST_kModifierKeyNum, val);
#undef MOD_VALIDATE
#undef MOD_TEST
keys.set(mod_info.mod_l, val_l);
keys.set(mod_info.mod_r, val_r);
}
return GHOST_kSuccess;
}

View File

@ -92,6 +92,11 @@ GHOST_TSuccess GHOST_Window::getSwapInterval(int &intervalOut)
return m_context->getSwapInterval(intervalOut);
}
GHOST_Context *GHOST_Window::getContext()
{
return m_context;
}
unsigned int GHOST_Window::getDefaultFramebuffer()
{
return (m_context) ? m_context->getDefaultFramebuffer() : 0;

View File

@ -72,7 +72,7 @@ class GHOST_Window : public GHOST_IWindow {
* Returns indication as to whether the window is valid.
* \return The validity of the window.
*/
virtual bool getValid() const
virtual bool getValid() const override
{
return m_context != NULL;
}
@ -81,15 +81,15 @@ class GHOST_Window : public GHOST_IWindow {
* Returns the associated OS object/handle
* \return The associated OS object/handle
*/
virtual void *getOSWindow() const;
virtual void *getOSWindow() const override;
/**
* Returns the current cursor shape.
* \return The current cursor shape.
*/
inline GHOST_TStandardCursor getCursorShape() const;
inline GHOST_TStandardCursor getCursorShape() const override;
inline bool isDialog() const
inline bool isDialog() const override
{
return false;
}
@ -99,7 +99,7 @@ class GHOST_Window : public GHOST_IWindow {
* \param cursorShape: The new cursor shape type id.
* \return Indication of success.
*/
GHOST_TSuccess setCursorShape(GHOST_TStandardCursor cursorShape);
GHOST_TSuccess setCursorShape(GHOST_TStandardCursor cursorShape) override;
/**
* Set the shape of the cursor to a custom cursor.
@ -115,15 +115,15 @@ class GHOST_Window : public GHOST_IWindow {
int sizey,
int hotX,
int hotY,
bool canInvertColor);
bool canInvertColor) override;
GHOST_TSuccess getCursorBitmap(GHOST_CursorBitmapRef *bitmap);
GHOST_TSuccess getCursorBitmap(GHOST_CursorBitmapRef *bitmap) override;
/**
* Returns the visibility state of the cursor.
* \return The visibility state of the cursor.
*/
inline bool getCursorVisibility() const;
inline bool getCursorVisibility() const override;
inline GHOST_TGrabCursorMode getCursorGrabMode() const;
inline bool getCursorGrabModeIsWarp() const;
inline GHOST_TAxisFlag getCursorGrabAxis() const;
@ -136,7 +136,7 @@ class GHOST_Window : public GHOST_IWindow {
* \param visible: The new visibility state of the cursor.
* \return Indication of success.
*/
GHOST_TSuccess setCursorVisibility(bool visible);
GHOST_TSuccess setCursorVisibility(bool visible) override;
/**
* Sets the cursor grab.
@ -146,28 +146,28 @@ class GHOST_Window : public GHOST_IWindow {
GHOST_TSuccess setCursorGrab(GHOST_TGrabCursorMode mode,
GHOST_TAxisFlag wrap_axis,
GHOST_Rect *bounds,
int32_t mouse_ungrab_xy[2]);
int32_t mouse_ungrab_xy[2]) override;
/**
* Gets the cursor grab region, if unset the window is used.
* reset when grab is disabled.
*/
GHOST_TSuccess getCursorGrabBounds(GHOST_Rect &bounds);
GHOST_TSuccess getCursorGrabBounds(GHOST_Rect &bounds) override;
void getCursorGrabState(GHOST_TGrabCursorMode &mode,
GHOST_TAxisFlag &axis_flag,
GHOST_Rect &bounds,
bool &use_software_cursor);
bool &use_software_cursor) override;
/**
* Return true when a software cursor should be used.
*/
bool getCursorGrabUseSoftwareDisplay();
bool getCursorGrabUseSoftwareDisplay() override;
/**
* Sets the progress bar value displayed in the window/application icon
* \param progress: The progress percentage (0.0 to 1.0).
*/
virtual GHOST_TSuccess setProgressBar(float /*progress*/)
virtual GHOST_TSuccess setProgressBar(float /*progress*/) override
{
return GHOST_kFailure;
}
@ -175,7 +175,7 @@ class GHOST_Window : public GHOST_IWindow {
/**
* Hides the progress bar in the icon
*/
virtual GHOST_TSuccess endProgressBar()
virtual GHOST_TSuccess endProgressBar() override
{
return GHOST_kFailure;
}
@ -185,43 +185,43 @@ class GHOST_Window : public GHOST_IWindow {
* \param interval: The swap interval to use.
* \return A boolean success indicator.
*/
GHOST_TSuccess setSwapInterval(int interval);
GHOST_TSuccess setSwapInterval(int interval) override;
/**
* Gets the current swap interval for #swapBuffers.
* \return An integer.
*/
GHOST_TSuccess getSwapInterval(int &intervalOut);
GHOST_TSuccess getSwapInterval(int &intervalOut) override;
/**
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
*/
void setAcceptDragOperation(bool canAccept);
void setAcceptDragOperation(bool canAccept) override;
/**
* Returns acceptance of the dropped object
* Usually called by the "object dropped" event handling function
*/
bool canAcceptDragOperation() const;
bool canAcceptDragOperation() const override;
/**
* Sets the window "modified" status, indicating unsaved changes
* \param isUnsavedChanges: Unsaved changes or not.
* \return Indication of success.
*/
virtual GHOST_TSuccess setModifiedState(bool isUnsavedChanges);
virtual GHOST_TSuccess setModifiedState(bool isUnsavedChanges) override;
/**
* Gets the window "modified" status, indicating unsaved changes
* \return True if there are unsaved changes
*/
virtual bool getModifiedState();
virtual bool getModifiedState() override;
/**
* Returns the type of drawing context used in this window.
* \return The current type of drawing context.
*/
inline GHOST_TDrawingContextType getDrawingContextType();
inline GHOST_TDrawingContextType getDrawingContextType() override;
/**
* Tries to install a rendering context in this window.
@ -230,19 +230,19 @@ class GHOST_Window : public GHOST_IWindow {
* \param type: The type of rendering context installed.
* \return Indication as to whether installation has succeeded.
*/
GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type);
GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type) override;
/**
* Swaps front and back buffers of a window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess swapBuffers();
virtual GHOST_TSuccess swapBuffers() override;
/**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess activateDrawingContext();
virtual GHOST_TSuccess activateDrawingContext() override;
/**
* Updates the drawing context of this window. Needed
@ -251,17 +251,23 @@ class GHOST_Window : public GHOST_IWindow {
*/
GHOST_TSuccess updateDrawingContext();
/**
* Get the drawing context associated with this window.
*\return Pointer to the context object.
*/
GHOST_Context *getContext();
/**
* Gets the OpenGL frame-buffer associated with the window's contents.
* \return The ID of an OpenGL frame-buffer object.
*/
virtual unsigned int getDefaultFramebuffer();
virtual unsigned int getDefaultFramebuffer() override;
/**
* Returns the window user data.
* \return The window user data.
*/
inline GHOST_TUserDataPtr getUserData() const
inline GHOST_TUserDataPtr getUserData() const override
{
return m_userData;
}
@ -270,12 +276,12 @@ class GHOST_Window : public GHOST_IWindow {
* Changes the window user data.
* \param userData: The window user data.
*/
void setUserData(const GHOST_TUserDataPtr userData)
void setUserData(const GHOST_TUserDataPtr userData) override
{
m_userData = userData;
}
float getNativePixelSize(void)
float getNativePixelSize(void) override
{
if (m_nativePixelSize > 0.0f)
return m_nativePixelSize;
@ -286,18 +292,18 @@ class GHOST_Window : public GHOST_IWindow {
* Returns the recommended DPI for this window.
* \return The recommended DPI for this window.
*/
virtual inline uint16_t getDPIHint()
virtual inline uint16_t getDPIHint() override
{
return 96;
}
#ifdef WITH_INPUT_IME
virtual void beginIME(int32_t x, int32_t y, int32_t w, int32_t h, bool completed)
virtual void beginIME(int32_t x, int32_t y, int32_t w, int32_t h, bool completed) override
{
/* do nothing temporarily if not in windows */
}
virtual void endIME()
virtual void endIME() override
{
/* do nothing temporarily if not in windows */
}

View File

@ -217,7 +217,7 @@ GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system,
* So, m_post_init indicate that we need wait for the MapNotify
* event and then set the Window state to the m_post_state.
*/
else if ((state != GHOST_kWindowStateNormal) && (state != GHOST_kWindowStateMinimized)) {
else if (!ELEM(state, GHOST_kWindowStateNormal, GHOST_kWindowStateMinimized)) {
m_post_init = True;
m_post_state = state;
}
@ -1605,7 +1605,7 @@ uint16_t GHOST_WindowX11::getDPIHint()
int success = XrmGetResource(xrdb, "Xft.dpi", "Xft.Dpi", &type, &val);
if (success && type) {
if (strcmp(type, "String") == 0) {
if (STREQ(type, "String")) {
return atoi((char *)val.addr);
}
}

View File

@ -208,3 +208,32 @@
(void)0
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Macros
* \{ */
/* Macro to convert a value to string in the preprocessor:
* - `STRINGIFY_ARG`: gives the argument as a string
* - `STRINGIFY_APPEND`: appends any argument 'b' onto the string argument 'a',
* used by `STRINGIFY` because some preprocessors warn about zero arguments.
* - `STRINGIFY`: gives the argument's value as a string. */
#define STRINGIFY_ARG(x) "" #x
#define STRINGIFY_APPEND(a, b) "" a #b
#define STRINGIFY(x) STRINGIFY_APPEND("", x)
/* generic strcmp macros */
#if defined(_MSC_VER)
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
#endif
#define STREQ(a, b) (strcmp(a, b) == 0)
#define STRCASEEQ(a, b) (strcasecmp(a, b) == 0)
#define STREQLEN(a, b, n) (strncmp(a, b, n) == 0)
#define STRCASEEQLEN(a, b, n) (strncasecmp(a, b, n) == 0)
#define STRPREFIX(a, b) (strncmp((a), (b), strlen(b)) == 0)
/** \} */

View File

@ -323,7 +323,7 @@ MainWindow *mainwindow_new(MultiTestApp *app)
if (win) {
MainWindow *mw = MEM_callocN(sizeof(*mw), "mainwindow_new");
mw->gpu_context = GPU_context_create(win);
mw->gpu_context = GPU_context_create(win, NULL);
GPU_init();
mw->app = app;
@ -578,7 +578,7 @@ LoggerWindow *loggerwindow_new(MultiTestApp *app)
if (win) {
LoggerWindow *lw = MEM_callocN(sizeof(*lw), "loggerwindow_new");
lw->gpu_context = GPU_context_create(win);
lw->gpu_context = GPU_context_create(win, NULL);
GPU_init();
int bbox[2][2];
@ -780,7 +780,7 @@ ExtraWindow *extrawindow_new(MultiTestApp *app)
if (win) {
ExtraWindow *ew = MEM_callocN(sizeof(*ew), "mainwindow_new");
ew->gpu_context = GPU_context_create(win);
ew->gpu_context = GPU_context_create(win, NULL);
GPU_init();
ew->app = app;

View File

@ -139,8 +139,8 @@ void radixsort(std::vector<T> &data, std::vector<T> &data2, KeyGetter getKey)
static void float_add_atomic(float *val, float add)
{
/* Hacky, but atomic floats are only supported from C++20 onwards.
* This works in practise since std::atomic<uint32_t> is really just an uint32_t in memory,
/* Hacky, but atomic floats are only supported from C++20 onward.
* This works in practice since `std::atomic<uint32_t>` is really just an `uint32_t` in memory,
* so this cast lets us do a 32-bit CAS operation (which is used to build the atomic float
* operation) without needing any external libraries or compiler-specific builtins. */
std::atomic<uint32_t> *atomic_val = reinterpret_cast<std::atomic<uint32_t> *>(val);

View File

@ -130,8 +130,10 @@ vec4 apply_dither(vec4 col, vec2 uv)
* \{ */
/* Prototypes: Implementation is generaterd and defined after. */
#ifndef GPU_METAL /* Forward declaration invalid in MSL. */
vec4 OCIO_to_scene_linear(vec4 pixel);
vec4 OCIO_to_display(vec4 pixel);
#endif
vec4 OCIO_ProcessColor(vec4 col, vec4 col_overlay)
{

View File

@ -81,11 +81,11 @@ if(WITH_OPENSUBDIV)
)
endif()
OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_OPENMP)
OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_OPENCL)
OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_CUDA)
OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK)
OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_COMPUTE)
opensubdiv_define_component(OPENSUBDIV_HAS_OPENMP)
opensubdiv_define_component(OPENSUBDIV_HAS_OPENCL)
opensubdiv_define_component(OPENSUBDIV_HAS_CUDA)
opensubdiv_define_component(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK)
opensubdiv_define_component(OPENSUBDIV_HAS_GLSL_COMPUTE)
if(WIN32)
add_definitions(-DNOMINMAX)

View File

@ -503,11 +503,15 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel):
else:
col.operator("mesh.customdata_bevel_weight_vertex_add", icon='ADD')
col = layout.column(heading="Store")
if me.has_crease_edge:
col.operator("mesh.customdata_crease_edge_clear", icon='X')
else:
col.operator("mesh.customdata_crease_edge_add", icon='ADD')
col.enabled = obj is not None and obj.mode != 'EDIT'
col.prop(me, "use_customdata_vertex_crease", text="Vertex Crease")
col.prop(me, "use_customdata_edge_crease", text="Edge Crease")
if me.has_crease_vertex:
col.operator("mesh.customdata_crease_vertex_clear", icon='X')
else:
col.operator("mesh.customdata_crease_vertex_add", icon='ADD')
class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, Panel):

View File

@ -537,10 +537,12 @@ class IMAGE_MT_pivot_pie(Menu):
layout = self.layout
pie = layout.menu_pie()
pie.prop_enum(context.space_data, "pivot_point", value='CENTER')
pie.prop_enum(context.space_data, "pivot_point", value='CURSOR')
pie.prop_enum(context.space_data, "pivot_point", value='INDIVIDUAL_ORIGINS')
pie.prop_enum(context.space_data, "pivot_point", value='MEDIAN')
sima = context.space_data
pie.prop_enum(sima, "pivot_point", value='CENTER')
pie.prop_enum(sima, "pivot_point", value='CURSOR')
pie.prop_enum(sima, "pivot_point", value='INDIVIDUAL_ORIGINS')
pie.prop_enum(sima, "pivot_point", value='MEDIAN')
class IMAGE_MT_uvs_snap_pie(Menu):
@ -1531,6 +1533,14 @@ class IMAGE_PT_overlay_guides(Panel):
if overlay.show_grid_background:
layout.use_property_split = True
col = layout.column(align=False, heading="Grid Over Image")
col.use_property_decorate = False
row = col.row(align=True)
sub = row.row(align=True)
sub.prop(uvedit, "show_grid_over_image", text="")
sub.active = sima.image is not None
col = layout.column(align=False, heading="Fixed Subdivisions")
col.use_property_decorate = False

View File

@ -1346,7 +1346,9 @@ bool blf_ensure_face(FontBLF *font)
if (font->mem) {
err = FT_New_Memory_Face(font->ft_lib, font->mem, (FT_Long)font->mem_size, 0, &font->face);
}
font->face->generic.data = font;
if (!err) {
font->face->generic.data = font;
}
BLI_mutex_unlock(&ft_lib_mutex);
}

View File

@ -103,9 +103,6 @@ struct DerivedMesh {
int num_alloc;
} looptris;
/* use for converting to BMesh which doesn't store bevel weight and edge crease by default */
char cd_flag;
short tangent_mask; /* which tangent layers are calculated */
/** Loop tessellation cache (WARNING! Only call inside threading-protected code!) */

View File

@ -30,8 +30,8 @@ extern "C" {
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file
* was written with too new a version. */
#define BLENDER_FILE_MIN_VERSION 300
#define BLENDER_FILE_MIN_SUBVERSION 43
#define BLENDER_FILE_MIN_VERSION 304
#define BLENDER_FILE_MIN_SUBVERSION 0
/** User readable version string. */
const char *BKE_blender_version_string(void);

View File

@ -634,8 +634,7 @@ enum {
CD_SHAPEKEY, /* Not available as real CD layer in non-bmesh context. */
/* Edges. */
CD_FAKE_SEAM = CD_FAKE | 100, /* UV seam flag for edges. */
CD_FAKE_CREASE = CD_FAKE | CD_CREASE, /* *sigh*. */
CD_FAKE_SEAM = CD_FAKE | 100, /* UV seam flag for edges. */
/* Multiple types of mesh elements... */
CD_FAKE_UV = CD_FAKE |

View File

@ -24,6 +24,24 @@ struct CustomData;
struct Mesh;
struct MFace;
/**
* Move face sets to the legacy type from a generic type.
*/
void BKE_mesh_legacy_face_set_from_generic(struct Mesh *mesh);
/**
* Copy face sets to the generic data type from the legacy type.
*/
void BKE_mesh_legacy_face_set_to_generic(struct Mesh *mesh);
/**
* Copy edge creases from a separate layer into edges.
*/
void BKE_mesh_legacy_edge_crease_from_layers(struct Mesh *mesh);
/**
* Copy edge creases from edges to a separate layer.
*/
void BKE_mesh_legacy_edge_crease_to_layers(struct Mesh *mesh);
/**
* Copy bevel weights from separate layers into vertices and edges.
*/

View File

@ -92,7 +92,7 @@ typedef struct MeshElemMap {
/* mapping */
UvVertMap *BKE_mesh_uv_vert_map_create(const struct MPoly *mpoly,
const bool *hide_poly,
const bool *selection_poly,
const bool *select_poly,
const struct MLoop *mloop,
const struct MLoopUV *mloopuv,
unsigned int totpoly,

View File

@ -960,8 +960,8 @@ void nodeLabel(const struct bNodeTree *ntree, const struct bNode *node, char *la
*/
const char *nodeSocketLabel(const struct bNodeSocket *sock);
bool nodeGroupPoll(struct bNodeTree *nodetree,
struct bNodeTree *grouptree,
bool nodeGroupPoll(const struct bNodeTree *nodetree,
const struct bNodeTree *grouptree,
const char **r_disabled_hint);
/**
@ -1527,6 +1527,7 @@ struct TexResult;
#define GEO_NODE_EDGE_PATHS_TO_SELECTION 1170
#define GEO_NODE_MESH_FACE_SET_BOUNDARIES 1171
#define GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME 1172
#define GEO_NODE_SELF_OBJECT 1173
/** \} */

View File

@ -307,7 +307,6 @@ BLI_INLINE void BKE_subdiv_rotate_grid_to_quad(
/* Convert Blender edge crease value to OpenSubdiv sharpness. */
BLI_INLINE float BKE_subdiv_crease_to_sharpness_f(float edge_crease);
BLI_INLINE float BKE_subdiv_crease_to_sharpness_char(char edge_crease);
#ifdef __cplusplus
}

View File

@ -241,8 +241,6 @@ void DM_from_template(DerivedMesh *dm,
CustomData_copy(&source->loopData, &dm->loopData, mask->lmask, CD_SET_DEFAULT, numLoops);
CustomData_copy(&source->polyData, &dm->polyData, mask->pmask, CD_SET_DEFAULT, numPolys);
dm->cd_flag = source->cd_flag;
dm->type = type;
dm->numVertData = numVerts;
dm->numEdgeData = numEdges;

View File

@ -659,6 +659,8 @@ void BKE_animdata_transfer_by_basepath(Main *bmain, ID *srcID, ID *dstID, ListBa
srcAdt, dstAdt, basepath_change->src_basepath, basepath_change->dst_basepath);
}
}
/* Tag source action because list of fcurves changed. */
DEG_id_tag_update(&srcAdt->action->id, ID_RECALC_COPY_ON_WRITE);
}
/* Path Validation -------------------------------------------- */

View File

@ -58,7 +58,7 @@ const char *no_procedural_access_message =
bool allow_procedural_attribute_access(StringRef attribute_name)
{
return !attribute_name.startswith(".sculpt") && !attribute_name.startswith(".selection") &&
return !attribute_name.startswith(".sculpt") && !attribute_name.startswith(".select") &&
!attribute_name.startswith(".hide");
}

View File

@ -206,7 +206,6 @@ static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh,
* but only if the original mesh had its deformed_only flag correctly set
* (which isn't generally the case). */
dm->deformedOnly = 1;
dm->cd_flag = mesh->cd_flag;
CustomData_merge(&mesh->vdata, &dm->vertData, cddata_masks.vmask, alloctype, mesh->totvert);
CustomData_merge(&mesh->edata, &dm->edgeData, cddata_masks.emask, alloctype, mesh->totedge);

View File

@ -1869,9 +1869,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
/* 29: CD_BWEIGHT */
{sizeof(MFloatProperty), "MFloatProperty", 1, nullptr, nullptr, nullptr, layerInterp_bweight},
/* 30: CD_CREASE */
/* NOTE: we do not interpolate crease data as it should be either inherited for subdivided
* edges, or for vertex creases, only present on the original vertex. */
{sizeof(float), "", 0, N_("SubSurfCrease"), nullptr, nullptr, nullptr},
{sizeof(float), "", 0, N_("SubSurfCrease"), nullptr, nullptr, layerInterp_propFloat},
/* 31: CD_ORIGSPACE_MLOOP */
{sizeof(OrigSpaceLoop),
"OrigSpaceLoop",
@ -1967,7 +1965,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
{sizeof(short[4][3]), "", 0, nullptr, nullptr, nullptr, nullptr, layerSwap_flnor, nullptr},
/* 41: CD_CUSTOMLOOPNORMAL */
{sizeof(short[2]), "vec2s", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr},
/* 42: CD_SCULPT_FACE_SETS */
/* 42: CD_SCULPT_FACE_SETS */ /* DEPRECATED */
{sizeof(int), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr},
/* 43: CD_LOCATION */
{sizeof(float[3]), "vec3f", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr},
@ -2125,13 +2123,13 @@ const CustomData_MeshMasks CD_MASK_BAREMESH_ORIGINDEX = {
/* lmask */ CD_MASK_MLOOP,
};
const CustomData_MeshMasks CD_MASK_MESH = {
/* vmask */ (CD_MASK_PROP_FLOAT3 | CD_MASK_MDEFORMVERT | CD_MASK_MVERT_SKIN |
CD_MASK_PAINT_MASK | CD_MASK_PROP_ALL | CD_MASK_CREASE | CD_MASK_BWEIGHT),
/* emask */ (CD_MASK_MEDGE | CD_MASK_FREESTYLE_EDGE | CD_MASK_PROP_ALL | CD_MASK_BWEIGHT),
/* vmask */ (CD_MASK_PROP_FLOAT3 | CD_MASK_MDEFORMVERT | CD_MASK_MVERT_SKIN | CD_MASK_PAINT_MASK |
CD_MASK_PROP_ALL | CD_MASK_CREASE | CD_MASK_BWEIGHT),
/* emask */
(CD_MASK_MEDGE | CD_MASK_FREESTYLE_EDGE | CD_MASK_PROP_ALL | CD_MASK_BWEIGHT | CD_MASK_CREASE),
/* fmask */ 0,
/* pmask */
(CD_MASK_MPOLY | CD_MASK_FACEMAP | CD_MASK_FREESTYLE_FACE | CD_MASK_PROP_ALL |
CD_MASK_SCULPT_FACE_SETS),
(CD_MASK_MPOLY | CD_MASK_FACEMAP | CD_MASK_FREESTYLE_FACE | CD_MASK_PROP_ALL),
/* lmask */
(CD_MASK_MLOOP | CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_CUSTOMLOOPNORMAL |
CD_MASK_GRID_PAINT_MASK | CD_MASK_PROP_ALL),
@ -2140,11 +2138,12 @@ const CustomData_MeshMasks CD_MASK_DERIVEDMESH = {
/* vmask */ (CD_MASK_ORIGINDEX | CD_MASK_MDEFORMVERT | CD_MASK_SHAPEKEY | CD_MASK_MVERT_SKIN |
CD_MASK_PAINT_MASK | CD_MASK_ORCO | CD_MASK_CLOTH_ORCO | CD_MASK_PROP_ALL |
CD_MASK_CREASE | CD_MASK_BWEIGHT),
/* emask */ (CD_MASK_ORIGINDEX | CD_MASK_FREESTYLE_EDGE | CD_MASK_BWEIGHT | CD_MASK_PROP_ALL),
/* emask */
(CD_MASK_ORIGINDEX | CD_MASK_FREESTYLE_EDGE | CD_MASK_BWEIGHT | CD_MASK_PROP_ALL |
CD_MASK_CREASE),
/* fmask */ (CD_MASK_ORIGINDEX | CD_MASK_ORIGSPACE | CD_MASK_PREVIEW_MCOL | CD_MASK_TANGENT),
/* pmask */
(CD_MASK_ORIGINDEX | CD_MASK_FREESTYLE_FACE | CD_MASK_FACEMAP | CD_MASK_PROP_ALL |
CD_MASK_SCULPT_FACE_SETS),
(CD_MASK_ORIGINDEX | CD_MASK_FREESTYLE_FACE | CD_MASK_FACEMAP | CD_MASK_PROP_ALL),
/* lmask */
(CD_MASK_MLOOPUV | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_PREVIEW_MLOOPCOL |
CD_MASK_ORIGSPACE_MLOOP | CD_MASK_PROP_ALL), /* XXX MISSING CD_MASK_MLOOPTANGENT ? */
@ -2155,7 +2154,7 @@ const CustomData_MeshMasks CD_MASK_BMESH = {
/* emask */ (CD_MASK_BWEIGHT | CD_MASK_CREASE | CD_MASK_FREESTYLE_EDGE | CD_MASK_PROP_ALL),
/* fmask */ 0,
/* pmask */
(CD_MASK_FREESTYLE_FACE | CD_MASK_FACEMAP | CD_MASK_PROP_ALL | CD_MASK_SCULPT_FACE_SETS),
(CD_MASK_FREESTYLE_FACE | CD_MASK_FACEMAP | CD_MASK_PROP_ALL),
/* lmask */
(CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_GRID_PAINT_MASK |
CD_MASK_PROP_ALL),
@ -2174,7 +2173,7 @@ const CustomData_MeshMasks CD_MASK_EVERYTHING = {
CD_MASK_PROP_ALL),
/* pmask */
(CD_MASK_MPOLY | CD_MASK_BM_ELEM_PYPTR | CD_MASK_ORIGINDEX | CD_MASK_FACEMAP |
CD_MASK_FREESTYLE_FACE | CD_MASK_PROP_ALL | CD_MASK_SCULPT_FACE_SETS),
CD_MASK_FREESTYLE_FACE | CD_MASK_PROP_ALL),
/* lmask */
(CD_MASK_MLOOP | CD_MASK_BM_ELEM_PYPTR | CD_MASK_MDISPS | CD_MASK_NORMAL | CD_MASK_MLOOPUV |
CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_MLOOPTANGENT | CD_MASK_PREVIEW_MLOOPCOL |
@ -2381,9 +2380,9 @@ static bool attribute_stored_in_bmesh_flag(const StringRef name)
".hide_vert",
".hide_edge",
".hide_poly",
".selection_vert",
".selection_edge",
".selection_poly",
".select_vert",
".select_edge",
".select_poly",
"material_index");
}

View File

@ -199,7 +199,7 @@ int BKE_object_data_transfer_dttype_to_cdtype(const int dtdata_type)
case DT_TYPE_SEAM:
return CD_FAKE_SEAM;
case DT_TYPE_CREASE:
return CD_FAKE_CREASE;
return CD_CREASE;
case DT_TYPE_BWEIGHT_EDGE:
return CD_BWEIGHT;
case DT_TYPE_FREESTYLE_EDGE:
@ -981,39 +981,6 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
}
return true;
}
if (cddata_type == CD_FAKE_CREASE) {
const size_t elem_size = sizeof(*((MEdge *)NULL));
const size_t data_size = sizeof(((MEdge *)NULL)->crease);
const size_t data_offset = offsetof(MEdge, crease);
const uint64_t data_flag = 0;
if (!(me_src->cd_flag & ME_CDFLAG_EDGE_CREASE)) {
if (use_delete) {
me_dst->cd_flag &= ~ME_CDFLAG_EDGE_CREASE;
}
return true;
}
me_dst->cd_flag |= ME_CDFLAG_EDGE_CREASE;
if (r_map) {
data_transfer_layersmapping_add_item(r_map,
cddata_type,
mix_mode,
mix_factor,
mix_weights,
BKE_mesh_edges(me_src),
BKE_mesh_edges_for_write(me_dst),
me_src->totedge,
me_dst->totedge,
elem_size,
data_size,
data_offset,
data_flag,
data_transfer_interp_char,
interp_data);
}
return true;
}
if (r_map && ELEM(cddata_type, CD_FAKE_SHARP, CD_FAKE_SEAM)) {
const size_t elem_size = sizeof(*((MEdge *)NULL));
const size_t data_size = sizeof(((MEdge *)NULL)->flag);

View File

@ -894,14 +894,14 @@ static void set_loop_uv(MLoopUV &uv, float2 co)
copy_v2_v2(uv.uv, co);
}
static float get_crease(const MEdge &edge)
static float get_crease(const float &crease)
{
return edge.crease / 255.0f;
return crease;
}
static void set_crease(MEdge &edge, float value)
static void set_crease(float &crease, const float value)
{
edge.crease = round_fl_to_uchar_clamp(value * 255.0f);
crease = std::clamp(value, 0.0f, 1.0f);
}
class VArrayImpl_For_VertexWeights final : public VMutableArrayImpl<float> {
@ -1245,13 +1245,13 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
"crease",
ATTR_DOMAIN_EDGE,
CD_PROP_FLOAT,
CD_MEDGE,
BuiltinAttributeProvider::NonCreatable,
CD_CREASE,
BuiltinAttributeProvider::Creatable,
BuiltinAttributeProvider::Writable,
BuiltinAttributeProvider::NonDeletable,
BuiltinAttributeProvider::Deletable,
edge_access,
make_derived_read_attribute<MEdge, float, get_crease>,
make_derived_write_attribute<MEdge, float, get_crease, set_crease>,
make_array_read_attribute<float>,
make_derived_write_attribute<float, float, get_crease, set_crease>,
nullptr);
static NamedLegacyCustomDataProvider uvs(

View File

@ -677,7 +677,7 @@ static void copy_frame_to_eval_cb(bGPDlayer *gpl,
* - When the frame is the layer's active frame (already handled in
* gpencil_copy_visible_frames_to_eval).
*/
if (gpf == NULL || gpf == gpl->actframe) {
if (ELEM(gpf, NULL, gpl->actframe)) {
return;
}

View File

@ -5148,7 +5148,7 @@ bool BKE_image_has_alpha(Image *image)
const int planes = (ibuf ? ibuf->planes : 0);
BKE_image_release_ibuf(image, ibuf, lock);
if (planes == 32 || planes == 16) {
if (ELEM(planes, 32, 16)) {
return true;
}

View File

@ -151,8 +151,6 @@ static void mesh_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int
mesh_tessface_clear_intern(mesh_dst, false);
}
mesh_dst->cd_flag = mesh_src->cd_flag;
mesh_dst->edit_mesh = nullptr;
mesh_dst->mselect = (MSelect *)MEM_dupallocN(mesh_dst->mselect);
@ -259,9 +257,9 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
".hide_edge",
".hide_poly",
"material_index",
".selection_vert",
".selection_edge",
".selection_poly"});
".select_vert",
".select_edge",
".select_poly"});
mesh->mvert = BKE_mesh_legacy_convert_positions_to_verts(
mesh, temp_arrays_for_legacy_format, vert_layers);
@ -269,6 +267,8 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
BKE_mesh_legacy_convert_selection_layers_to_flags(mesh);
BKE_mesh_legacy_convert_material_indices_to_mpoly(mesh);
BKE_mesh_legacy_bevel_weight_from_layers(mesh);
BKE_mesh_legacy_face_set_from_generic(mesh);
BKE_mesh_legacy_edge_crease_from_layers(mesh);
/* Set deprecated mesh data pointers for forward compatibility. */
mesh->medge = const_cast<MEdge *>(mesh->edges().data());
@ -686,11 +686,6 @@ static int customdata_compare(
case CD_PROP_BOOL: {
const bool *l1_data = (bool *)l1->data;
const bool *l2_data = (bool *)l2->data;
/* TODO(@HooglyBoogly): Remove this after test files have been updated for selection
* attribute changes. */
if (StringRef(l1->name).startswith(".selection")) {
continue;
}
for (int i = 0; i < total_length; i++) {
if (l1_data[i] != l2_data[i]) {
return MESHCMP_ATTRIBUTE_VALUE_MISMATCH;
@ -1024,7 +1019,6 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
me_dst->totloop = loops_len;
me_dst->totpoly = polys_len;
me_dst->cd_flag = me_src->cd_flag;
BKE_mesh_copy_parameters_for_eval(me_dst, me_src);
CustomData_copy(&me_src->vdata, &me_dst->vdata, mask.vmask, CD_SET_DEFAULT, verts_len);
@ -1607,7 +1601,7 @@ void BKE_mesh_do_versions_cd_flag_init(Mesh *mesh)
break;
}
}
if (edge.crease != 0) {
if (edge.crease_legacy != 0) {
mesh->cd_flag |= ME_CDFLAG_EDGE_CREASE;
if (mesh->cd_flag & ME_CDFLAG_EDGE_BWEIGHT) {
break;
@ -1641,32 +1635,32 @@ void BKE_mesh_mselect_validate(Mesh *me)
(me->totselect), sizeof(MSelect), "Mesh selection history");
const AttributeAccessor attributes = me->attributes();
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
const VArray<bool> selection_edge = attributes.lookup_or_default<bool>(
".selection_edge", ATTR_DOMAIN_EDGE, false);
const VArray<bool> selection_poly = attributes.lookup_or_default<bool>(
".selection_poly", ATTR_DOMAIN_FACE, false);
const VArray<bool> select_vert = attributes.lookup_or_default<bool>(
".select_vert", ATTR_DOMAIN_POINT, false);
const VArray<bool> select_edge = attributes.lookup_or_default<bool>(
".select_edge", ATTR_DOMAIN_EDGE, false);
const VArray<bool> select_poly = attributes.lookup_or_default<bool>(
".select_poly", ATTR_DOMAIN_FACE, false);
for (i_src = 0, i_dst = 0; i_src < me->totselect; i_src++) {
int index = mselect_src[i_src].index;
switch (mselect_src[i_src].type) {
case ME_VSEL: {
if (selection_vert[index]) {
if (select_vert[index]) {
mselect_dst[i_dst] = mselect_src[i_src];
i_dst++;
}
break;
}
case ME_ESEL: {
if (selection_edge[index]) {
if (select_edge[index]) {
mselect_dst[i_dst] = mselect_src[i_src];
i_dst++;
}
break;
}
case ME_FSEL: {
if (selection_poly[index]) {
if (select_poly[index]) {
mselect_dst[i_dst] = mselect_src[i_src];
i_dst++;
}

View File

@ -438,7 +438,6 @@ static void copy_edge_attributes(Mesh *dest_mesh,
int medge_index,
int index_in_orig_me)
{
medge->crease = orig_medge->crease;
medge->flag = orig_medge->flag;
CustomData *target_cd = &dest_mesh->edata;
const CustomData *source_cd = &orig_me->edata;

View File

@ -247,19 +247,19 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool keep_existing_edges, const bool select
if (select_new_edges) {
MutableAttributeAccessor attributes = mesh->attributes_for_write();
SpanAttributeWriter<bool> selection_edge = attributes.lookup_or_add_for_write_span<bool>(
".selection_edge", ATTR_DOMAIN_EDGE);
if (selection_edge) {
SpanAttributeWriter<bool> select_edge = attributes.lookup_or_add_for_write_span<bool>(
".select_edge", ATTR_DOMAIN_EDGE);
if (select_edge) {
int new_edge_index = 0;
for (const EdgeMap &edge_map : edge_maps) {
for (EdgeMap::Item item : edge_map.items()) {
if (item.value.original_edge == nullptr) {
selection_edge.span[new_edge_index] = true;
select_edge.span[new_edge_index] = true;
}
new_edge_index++;
}
}
selection_edge.finish();
select_edge.finish();
}
}

View File

@ -119,7 +119,6 @@ static void make_edges_mdata_extend(Mesh &mesh)
BLI_edgehashIterator_getKey(ehi, &medge->v1, &medge->v2);
BLI_edgehashIterator_setValue(ehi, POINTER_FROM_UINT(e_index));
medge->crease = 0;
medge->flag = ME_EDGEDRAW | ME_EDGERENDER;
}
BLI_edgehashIterator_free(ehi);
@ -1306,7 +1305,6 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob)
BLI_listbase_clear(&mesh_src->vertex_group_names);
BKE_mesh_copy_parameters(mesh_dst, mesh_src);
mesh_dst->cd_flag = mesh_src->cd_flag;
/* For original meshes, shape key data is stored in the #Key data-block, so it
* must be moved from the storage in #CustomData layers used for evaluation. */

View File

@ -27,21 +27,11 @@
# include "BLI_dynstr.h"
static void mesh_debug_info_from_cd_flag(const Mesh *me, DynStr *dynstr)
{
BLI_dynstr_append(dynstr, "'cd_flag': {");
if (me->cd_flag & ME_CDFLAG_EDGE_CREASE) {
BLI_dynstr_append(dynstr, "'EDGE_CREASE', ");
}
BLI_dynstr_append(dynstr, "},\n");
}
char *BKE_mesh_debug_info(const Mesh *me)
{
DynStr *dynstr = BLI_dynstr_new();
char *ret;
const char *indent4 = " ";
const char *indent8 = " ";
BLI_dynstr_append(dynstr, "{\n");
@ -75,9 +65,6 @@ char *BKE_mesh_debug_info(const Mesh *me)
CustomData_debug_info_from_layers(&me->fdata, indent8, dynstr);
BLI_dynstr_append(dynstr, " ),\n");
BLI_dynstr_append(dynstr, indent4);
mesh_debug_info_from_cd_flag(me, dynstr);
BLI_dynstr_append(dynstr, "}\n");
ret = BLI_dynstr_get_cstring(dynstr);

View File

@ -825,27 +825,27 @@ void BKE_mesh_flush_select_from_polys(Mesh *me)
{
using namespace blender::bke;
MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> selection_poly = attributes.lookup_or_default<bool>(
".selection_poly", ATTR_DOMAIN_FACE, false);
if (selection_poly.is_single() && !selection_poly.get_internal_single()) {
attributes.remove(".selection_vert");
attributes.remove(".selection_edge");
const VArray<bool> select_poly = attributes.lookup_or_default<bool>(
".select_poly", ATTR_DOMAIN_FACE, false);
if (select_poly.is_single() && !select_poly.get_internal_single()) {
attributes.remove(".select_vert");
attributes.remove(".select_edge");
return;
}
SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_only_span<bool>(
".selection_vert", ATTR_DOMAIN_POINT);
SpanAttributeWriter<bool> selection_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".selection_edge", ATTR_DOMAIN_EDGE);
SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_only_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
SpanAttributeWriter<bool> select_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".select_edge", ATTR_DOMAIN_EDGE);
/* Use generic domain interpolation to read the polygon attribute on the other domains.
* Assume selected faces are not hidden and none of their vertices/edges are hidden. */
attributes.lookup_or_default<bool>(".selection_poly", ATTR_DOMAIN_POINT, false)
.materialize(selection_vert.span);
attributes.lookup_or_default<bool>(".selection_poly", ATTR_DOMAIN_EDGE, false)
.materialize(selection_edge.span);
attributes.lookup_or_default<bool>(".select_poly", ATTR_DOMAIN_POINT, false)
.materialize(select_vert.span);
attributes.lookup_or_default<bool>(".select_poly", ATTR_DOMAIN_EDGE, false)
.materialize(select_edge.span);
selection_vert.finish();
selection_edge.finish();
select_vert.finish();
select_edge.finish();
}
static void mesh_flush_select_from_verts(const Span<MEdge> edges,
@ -853,15 +853,15 @@ static void mesh_flush_select_from_verts(const Span<MEdge> edges,
const Span<MLoop> loops,
const VArray<bool> &hide_edge,
const VArray<bool> &hide_poly,
const VArray<bool> &selection_vert,
MutableSpan<bool> selection_edge,
MutableSpan<bool> selection_poly)
const VArray<bool> &select_vert,
MutableSpan<bool> select_edge,
MutableSpan<bool> select_poly)
{
/* Select visible edges that have both of their vertices selected. */
for (const int i : edges.index_range()) {
if (!hide_edge[i]) {
const MEdge &edge = edges[i];
selection_edge[i] = selection_vert[edge.v1] && selection_vert[edge.v2];
select_edge[i] = select_vert[edge.v1] && select_vert[edge.v2];
}
}
@ -870,9 +870,9 @@ static void mesh_flush_select_from_verts(const Span<MEdge> edges,
if (!hide_poly[i]) {
const MPoly &poly = polys[i];
const Span<MLoop> poly_loops = loops.slice(poly.loopstart, poly.totloop);
selection_poly[i] = std::all_of(poly_loops.begin(),
poly_loops.end(),
[&](const MLoop &loop) { return selection_vert[loop.v]; });
select_poly[i] = std::all_of(poly_loops.begin(), poly_loops.end(), [&](const MLoop &loop) {
return select_vert[loop.v];
});
}
}
}
@ -881,28 +881,28 @@ void BKE_mesh_flush_select_from_verts(Mesh *me)
{
using namespace blender::bke;
MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
if (selection_vert.is_single() && !selection_vert.get_internal_single()) {
attributes.remove(".selection_edge");
attributes.remove(".selection_poly");
const VArray<bool> select_vert = attributes.lookup_or_default<bool>(
".select_vert", ATTR_DOMAIN_POINT, false);
if (select_vert.is_single() && !select_vert.get_internal_single()) {
attributes.remove(".select_edge");
attributes.remove(".select_poly");
return;
}
SpanAttributeWriter<bool> selection_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".selection_edge", ATTR_DOMAIN_EDGE);
SpanAttributeWriter<bool> selection_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".selection_poly", ATTR_DOMAIN_FACE);
SpanAttributeWriter<bool> select_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".select_edge", ATTR_DOMAIN_EDGE);
SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
mesh_flush_select_from_verts(
me->edges(),
me->polys(),
me->loops(),
attributes.lookup_or_default<bool>(".hide_edge", ATTR_DOMAIN_EDGE, false),
attributes.lookup_or_default<bool>(".hide_poly", ATTR_DOMAIN_FACE, false),
selection_vert,
selection_edge.span,
selection_poly.span);
selection_edge.finish();
selection_poly.finish();
select_vert,
select_edge.span,
select_poly.span);
select_edge.finish();
select_poly.finish();
}
/** \} */

View File

@ -923,6 +923,33 @@ void BKE_mesh_add_mface_layers(CustomData *fdata, CustomData *ldata, int total)
/** \} */
/* -------------------------------------------------------------------- */
/** \name Face Set Conversion
* \{ */
void BKE_mesh_legacy_face_set_from_generic(Mesh *mesh)
{
using namespace blender;
for (CustomDataLayer &layer : MutableSpan(mesh->pdata.layers, mesh->pdata.totlayer)) {
if (StringRef(layer.name) == ".sculpt_face_set") {
layer.type = CD_SCULPT_FACE_SETS;
}
}
}
void BKE_mesh_legacy_face_set_to_generic(Mesh *mesh)
{
using namespace blender;
for (CustomDataLayer &layer : MutableSpan(mesh->pdata.layers, mesh->pdata.totlayer)) {
if (layer.type == CD_SCULPT_FACE_SETS) {
BLI_strncpy(layer.name, ".sculpt_face_set", sizeof(layer.name));
layer.type = CD_PROP_INT32;
}
}
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Bevel Weight Conversion
* \{ */
@ -984,6 +1011,44 @@ void BKE_mesh_legacy_bevel_weight_to_layers(Mesh *mesh)
/** \} */
/* -------------------------------------------------------------------- */
/** \name Edge Crease Conversion
* \{ */
void BKE_mesh_legacy_edge_crease_from_layers(Mesh *mesh)
{
using namespace blender;
MutableSpan<MEdge> edges = mesh->edges_for_write();
if (const float *creases = static_cast<const float *>(
CustomData_get_layer(&mesh->edata, CD_CREASE))) {
mesh->cd_flag |= ME_CDFLAG_EDGE_CREASE;
for (const int i : edges.index_range()) {
edges[i].crease_legacy = std::clamp(creases[i], 0.0f, 1.0f) * 255.0f;
}
}
else {
mesh->cd_flag &= ~ME_CDFLAG_EDGE_CREASE;
for (const int i : edges.index_range()) {
edges[i].crease_legacy = 0;
}
}
}
void BKE_mesh_legacy_edge_crease_to_layers(Mesh *mesh)
{
using namespace blender;
const Span<MEdge> edges = mesh->edges();
if (mesh->cd_flag & ME_CDFLAG_EDGE_CREASE) {
float *creases = static_cast<float *>(
CustomData_add_layer(&mesh->edata, CD_CREASE, CD_CONSTRUCT, nullptr, edges.size()));
for (const int i : edges.index_range()) {
creases[i] = edges[i].crease_legacy / 255.0f;
}
}
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Hide Attribute and Legacy Flag Conversion
* \{ */
@ -999,7 +1064,7 @@ void BKE_mesh_legacy_convert_hide_layers_to_flags(Mesh *mesh)
".hide_vert", ATTR_DOMAIN_POINT, false);
threading::parallel_for(verts.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
SET_FLAG_FROM_TEST(verts[i].flag, hide_vert[i], ME_HIDE);
SET_FLAG_FROM_TEST(verts[i].flag_legacy, hide_vert[i], ME_HIDE);
}
});
@ -1029,13 +1094,14 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh)
MutableAttributeAccessor attributes = mesh->attributes_for_write();
const Span<MVert> verts(mesh->mvert, mesh->totvert);
if (std::any_of(
verts.begin(), verts.end(), [](const MVert &vert) { return vert.flag & ME_HIDE; })) {
if (std::any_of(verts.begin(), verts.end(), [](const MVert &vert) {
return vert.flag_legacy & ME_HIDE;
})) {
SpanAttributeWriter<bool> hide_vert = attributes.lookup_or_add_for_write_only_span<bool>(
".hide_vert", ATTR_DOMAIN_POINT);
threading::parallel_for(verts.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
hide_vert.span[i] = verts[i].flag & ME_HIDE;
hide_vert.span[i] = verts[i].flag_legacy & ME_HIDE;
}
});
hide_vert.finish();
@ -1121,29 +1187,29 @@ void BKE_mesh_legacy_convert_selection_layers_to_flags(Mesh *mesh)
const AttributeAccessor attributes = mesh->attributes();
MutableSpan<MVert> verts(mesh->mvert, mesh->totvert);
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
const VArray<bool> select_vert = attributes.lookup_or_default<bool>(
".select_vert", ATTR_DOMAIN_POINT, false);
threading::parallel_for(verts.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
SET_FLAG_FROM_TEST(verts[i].flag, selection_vert[i], SELECT);
SET_FLAG_FROM_TEST(verts[i].flag_legacy, select_vert[i], SELECT);
}
});
MutableSpan<MEdge> edges = mesh->edges_for_write();
const VArray<bool> selection_edge = attributes.lookup_or_default<bool>(
".selection_edge", ATTR_DOMAIN_EDGE, false);
const VArray<bool> select_edge = attributes.lookup_or_default<bool>(
".select_edge", ATTR_DOMAIN_EDGE, false);
threading::parallel_for(edges.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
SET_FLAG_FROM_TEST(edges[i].flag, selection_edge[i], SELECT);
SET_FLAG_FROM_TEST(edges[i].flag, select_edge[i], SELECT);
}
});
MutableSpan<MPoly> polys = mesh->polys_for_write();
const VArray<bool> selection_poly = attributes.lookup_or_default<bool>(
".selection_poly", ATTR_DOMAIN_FACE, false);
const VArray<bool> select_poly = attributes.lookup_or_default<bool>(
".select_poly", ATTR_DOMAIN_FACE, false);
threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
SET_FLAG_FROM_TEST(polys[i].flag, selection_poly[i], ME_FACE_SEL);
SET_FLAG_FROM_TEST(polys[i].flag, select_poly[i], ME_FACE_SEL);
}
});
}
@ -1155,42 +1221,43 @@ void BKE_mesh_legacy_convert_flags_to_selection_layers(Mesh *mesh)
MutableAttributeAccessor attributes = mesh->attributes_for_write();
const Span<MVert> verts(mesh->mvert, mesh->totvert);
if (std::any_of(
verts.begin(), verts.end(), [](const MVert &vert) { return vert.flag & SELECT; })) {
SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_only_span<bool>(
".selection_vert", ATTR_DOMAIN_POINT);
if (std::any_of(verts.begin(), verts.end(), [](const MVert &vert) {
return vert.flag_legacy & SELECT;
})) {
SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_only_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
threading::parallel_for(verts.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
selection_vert.span[i] = verts[i].flag & SELECT;
select_vert.span[i] = verts[i].flag_legacy & SELECT;
}
});
selection_vert.finish();
select_vert.finish();
}
const Span<MEdge> edges = mesh->edges();
if (std::any_of(
edges.begin(), edges.end(), [](const MEdge &edge) { return edge.flag & SELECT; })) {
SpanAttributeWriter<bool> selection_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".selection_edge", ATTR_DOMAIN_EDGE);
SpanAttributeWriter<bool> select_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".select_edge", ATTR_DOMAIN_EDGE);
threading::parallel_for(edges.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
selection_edge.span[i] = edges[i].flag & SELECT;
select_edge.span[i] = edges[i].flag & SELECT;
}
});
selection_edge.finish();
select_edge.finish();
}
const Span<MPoly> polys = mesh->polys();
if (std::any_of(
polys.begin(), polys.end(), [](const MPoly &poly) { return poly.flag & ME_FACE_SEL; })) {
SpanAttributeWriter<bool> selection_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".selection_poly", ATTR_DOMAIN_FACE);
SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
selection_poly.span[i] = polys[i].flag & ME_FACE_SEL;
select_poly.span[i] = polys[i].flag & ME_FACE_SEL;
}
});
selection_poly.finish();
select_poly.finish();
}
}

View File

@ -31,7 +31,7 @@
/* ngon version wip, based on BM_uv_vert_map_create */
UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
const bool *hide_poly,
const bool *selection_poly,
const bool *select_poly,
const MLoop *mloop,
const MLoopUV *mloopuv,
uint totpoly,
@ -54,7 +54,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
/* generate UvMapVert array */
mp = mpoly;
for (a = 0; a < totpoly; a++, mp++) {
if (!selected || (!(hide_poly && hide_poly[a]) && (selection_poly && selection_poly[a]))) {
if (!selected || (!(hide_poly && hide_poly[a]) && (select_poly && select_poly[a]))) {
totuv += mp->totloop;
}
}
@ -77,7 +77,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
mp = mpoly;
for (a = 0; a < totpoly; a++, mp++) {
if (!selected || (!(hide_poly && hide_poly[a]) && (selection_poly && selection_poly[a]))) {
if (!selected || (!(hide_poly && hide_poly[a]) && (select_poly && select_poly[a]))) {
float(*tf_uv)[2] = NULL;
if (use_winding) {

View File

@ -24,6 +24,7 @@
#include "DNA_meshdata_types.h"
#include "BKE_attribute.h"
#include "BKE_attribute.hh"
#include "BKE_bvhutils.h"
#include "BKE_customdata.h"
#include "BKE_editmesh.h"
@ -310,23 +311,27 @@ void BKE_mesh_remesh_reproject_paint_mask(Mesh *target, const Mesh *source)
void BKE_remesh_reproject_sculpt_face_sets(Mesh *target, const Mesh *source)
{
using namespace blender;
using namespace blender::bke;
const AttributeAccessor src_attributes = source->attributes();
MutableAttributeAccessor dst_attributes = target->attributes_for_write();
const MPoly *target_polys = (const MPoly *)CustomData_get_layer(&target->pdata, CD_MPOLY);
const Span<float3> target_positions = target->positions();
const MLoop *target_loops = (const MLoop *)CustomData_get_layer(&target->ldata, CD_MLOOP);
const int *source_face_sets = (const int *)CustomData_get_layer(&source->pdata,
CD_SCULPT_FACE_SETS);
if (source_face_sets == nullptr) {
const VArray<int> src_face_sets = src_attributes.lookup<int>(".sculpt_face_set",
ATTR_DOMAIN_FACE);
if (!src_face_sets) {
return;
}
SpanAttributeWriter<int> dst_face_sets = dst_attributes.lookup_or_add_for_write_only_span<int>(
".sculpt_face_set", ATTR_DOMAIN_FACE);
if (!dst_face_sets) {
return;
}
int *target_face_sets;
if (CustomData_has_layer(&target->pdata, CD_SCULPT_FACE_SETS)) {
target_face_sets = (int *)CustomData_get_layer(&target->pdata, CD_SCULPT_FACE_SETS);
}
else {
target_face_sets = (int *)CustomData_add_layer(
&target->pdata, CD_SCULPT_FACE_SETS, CD_CONSTRUCT, nullptr, target->totpoly);
}
const VArraySpan<int> src(src_face_sets);
MutableSpan<int> dst = dst_face_sets.span;
const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(source);
BVHTreeFromMesh bvhtree = {nullptr};
@ -344,13 +349,14 @@ void BKE_remesh_reproject_sculpt_face_sets(Mesh *target, const Mesh *source)
from_co);
BLI_bvhtree_find_nearest(bvhtree.tree, from_co, &nearest, bvhtree.nearest_callback, &bvhtree);
if (nearest.index != -1) {
target_face_sets[i] = source_face_sets[looptri[nearest.index].poly];
dst[i] = src[looptri[nearest.index].poly];
}
else {
target_face_sets[i] = 1;
dst[i] = 1;
}
}
free_bvhtree_from_mesh(&bvhtree);
dst_face_sets.finish();
}
void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source)

View File

@ -155,12 +155,23 @@ void BKE_mesh_runtime_looptri_recalc(Mesh *mesh)
const Span<MPoly> polys = mesh->polys();
const Span<MLoop> loops = mesh->loops();
BKE_mesh_recalc_looptri(loops.data(),
polys.data(),
reinterpret_cast<const float(*)[3]>(positions.data()),
mesh->totloop,
mesh->totpoly,
mesh->runtime.looptris.array_wip);
if (BKE_mesh_poly_normals_are_dirty(mesh)) {
BKE_mesh_recalc_looptri_with_normals(loops.data(),
polys.data(),
reinterpret_cast<const float(*)[3]>(positions.data()),
mesh->totloop,
mesh->totpoly,
mesh->runtime.looptris.array_wip,
BKE_mesh_poly_normals_ensure(mesh));
}
else {
BKE_mesh_recalc_looptri(loops.data(),
polys.data(),
reinterpret_cast<const float(*)[3]>(positions.data()),
mesh->totloop,
mesh->totpoly,
mesh->runtime.looptris.array_wip);
}
BLI_assert(mesh->runtime.looptris.array == nullptr);
atomic_cas_ptr((void **)&mesh->runtime.looptris.array,

View File

@ -100,6 +100,8 @@ typedef struct MultiresReshapeContext {
/* Vertex crease custom data layer, null if none is present. */
const float *cd_vertex_crease;
/* Edge crease custom data layer, null if none is present. */
const float *cd_edge_crease;
} MultiresReshapeContext;
/**

View File

@ -482,13 +482,14 @@ static bool is_crease_supported(const MultiresReshapeSmoothContext *reshape_smoo
/* Get crease which will be used for communication to OpenSubdiv topology.
* Note that simple subdivision treats all base edges as infinitely sharp. */
static char get_effective_crease_char(const MultiresReshapeSmoothContext *reshape_smooth_context,
const MEdge *base_edge)
static float get_effective_crease(const MultiresReshapeSmoothContext *reshape_smooth_context,
const int base_edge_index)
{
if (!is_crease_supported(reshape_smooth_context)) {
return 255;
}
return base_edge->crease;
const float *creases = reshape_smooth_context->reshape_context->cd_vertex_crease;
return creases ? creases[base_edge_index] : 0.0f;
}
static float get_effective_crease_float(const MultiresReshapeSmoothContext *reshape_smooth_context,
@ -812,7 +813,6 @@ static void foreach_edge(const struct SubdivForeachContext *foreach_context,
const int subdiv_v2)
{
MultiresReshapeSmoothContext *reshape_smooth_context = foreach_context->user_data;
const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context;
if (reshape_smooth_context->smoothing_type == MULTIRES_SUBDIVIDE_LINEAR) {
if (!is_loose) {
@ -832,8 +832,7 @@ static void foreach_edge(const struct SubdivForeachContext *foreach_context,
return;
}
/* Edges without crease are to be ignored as well. */
const MEdge *base_edge = &reshape_context->base_edges[coarse_edge_index];
const char crease = get_effective_crease_char(reshape_smooth_context, base_edge);
const char crease = get_effective_crease(reshape_smooth_context, coarse_edge_index);
if (crease == 0) {
return;
}
@ -846,7 +845,6 @@ static void geometry_init_loose_information(MultiresReshapeSmoothContext *reshap
const Mesh *base_mesh = reshape_context->base_mesh;
const MPoly *base_mpoly = reshape_context->base_polys;
const MLoop *base_mloop = reshape_context->base_loops;
const MEdge *base_edge = reshape_context->base_edges;
reshape_smooth_context->non_loose_base_edge_map = BLI_BITMAP_NEW(base_mesh->totedge,
"non_loose_base_edge_map");
@ -859,8 +857,8 @@ static void geometry_init_loose_information(MultiresReshapeSmoothContext *reshap
if (!BLI_BITMAP_TEST_BOOL(reshape_smooth_context->non_loose_base_edge_map, loop->e)) {
BLI_BITMAP_ENABLE(reshape_smooth_context->non_loose_base_edge_map, loop->e);
const char crease = get_effective_crease_char(reshape_smooth_context, &base_edge[loop->e]);
if (crease != 0) {
const float crease = get_effective_crease(reshape_smooth_context, loop->e);
if (crease > 0.0f) {
++num_used_edges;
}
}

View File

@ -206,6 +206,7 @@ bool multires_reshape_context_create_from_object(MultiresReshapeContext *reshape
reshape_context->top.grid_size = BKE_subdiv_grid_size_from_level(reshape_context->top.level);
reshape_context->cd_vertex_crease = CustomData_get_layer(&base_mesh->vdata, CD_CREASE);
reshape_context->cd_edge_crease = CustomData_get_layer(&base_mesh->edata, CD_CREASE);
context_init_commoon(reshape_context);
@ -271,6 +272,8 @@ bool multires_reshape_context_create_from_subdiv(MultiresReshapeContext *reshape
reshape_context->base_edges = BKE_mesh_edges(base_mesh);
reshape_context->base_polys = BKE_mesh_polys(base_mesh);
reshape_context->base_loops = BKE_mesh_loops(base_mesh);
reshape_context->cd_vertex_crease = (const float *)CustomData_get_layer(&base_mesh->edata,
CD_CREASE);
reshape_context->subdiv = subdiv;
reshape_context->need_free_subdiv = false;

View File

@ -2178,7 +2178,7 @@ bNode *nodeAddNode(const struct bContext *C, bNodeTree *ntree, const char *idnam
BKE_ntree_update_tag_node_new(ntree, node);
if (node->type == GEO_NODE_INPUT_SCENE_TIME) {
if (ELEM(node->type, GEO_NODE_INPUT_SCENE_TIME, GEO_NODE_SELF_OBJECT)) {
DEG_relations_tag_update(CTX_data_main(C));
}
@ -3021,7 +3021,7 @@ void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, bool do_id_user)
/* Also update relations for the scene time node, which causes a dependency
* on time that users expect to be removed when the node is removed. */
if (node_has_id || node->type == GEO_NODE_INPUT_SCENE_TIME) {
if (node_has_id || ELEM(node->type, GEO_NODE_INPUT_SCENE_TIME, GEO_NODE_SELF_OBJECT)) {
if (bmain != nullptr) {
DEG_relations_tag_update(bmain);
}
@ -4804,6 +4804,7 @@ static void registerGeometryNodes()
register_node_type_geo_scale_instances();
register_node_type_geo_separate_components();
register_node_type_geo_separate_geometry();
register_node_type_geo_self_object();
register_node_type_geo_set_curve_handles();
register_node_type_geo_set_curve_radius();
register_node_type_geo_set_curve_tilt();

View File

@ -4186,10 +4186,11 @@ void BKE_scene_foreach_display_point(Depsgraph *depsgraph,
void (*func_cb)(const float[3], void *),
void *user_data)
{
DEG_OBJECT_ITER_BEGIN (depsgraph,
ob,
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_VISIBLE |
DEG_ITER_OBJECT_FLAG_DUPLI) {
DEGObjectIterSettings deg_iter_settings{};
deg_iter_settings.depsgraph = depsgraph;
deg_iter_settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_VISIBLE |
DEG_ITER_OBJECT_FLAG_DUPLI;
DEG_OBJECT_ITER_BEGIN (&deg_iter_settings, ob) {
if ((ob->base_flag & BASE_SELECTED) != 0) {
BKE_object_foreach_display_point(ob, ob->obmat, func_cb, user_data);
}

View File

@ -163,14 +163,14 @@ bool BKE_object_defgroup_clear(Object *ob, bDeformGroup *dg, const bool use_sele
}
else {
if (BKE_mesh_deform_verts(me)) {
const bool *selection_vert = (const bool *)CustomData_get_layer_named(
&me->vdata, CD_PROP_BOOL, ".selection_vert");
const bool *select_vert = (const bool *)CustomData_get_layer_named(
&me->vdata, CD_PROP_BOOL, ".select_vert");
int i;
dv = BKE_mesh_deform_verts_for_write(me);
for (i = 0; i < me->totvert; i++, dv++) {
if (dv->dw && (!use_selection || (selection_vert && selection_vert[i]))) {
if (dv->dw && (!use_selection || (select_vert && select_vert[i]))) {
MDeformWeight *dw = BKE_defvert_find_index(dv, def_nr);
BKE_defvert_remove_group(dv, dw); /* dw can be NULL */
changed = true;

View File

@ -311,12 +311,13 @@ static void make_child_duplis(const DupliContext *ctx,
/* FIXME: using a mere counter to generate a 'persistent' dupli id is very weak. One possible
* better solution could be to use `session_uuid` of ID's instead? */
int persistent_dupli_id = 0;
DEGObjectIterSettings deg_iter_settings{};
deg_iter_settings.depsgraph = ctx->depsgraph;
/* NOTE: this set of flags ensure we only iterate over objects that have a base in either the
* current scene, or the set (background) scene. */
int deg_objects_visibility_flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
DEG_OBJECT_ITER_BEGIN (ctx->depsgraph, ob, deg_objects_visibility_flags) {
deg_iter_settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
DEG_OBJECT_ITER_BEGIN (&deg_iter_settings, ob) {
if ((ob != ctx->obedit) && is_child(ob, parent)) {
DupliContext pctx;
if (copy_dupli_context(&pctx, ctx, ctx->object, nullptr, persistent_dupli_id)) {

View File

@ -1740,7 +1740,8 @@ static void sculpt_update_object(
/* Sculpt Face Sets. */
if (use_face_sets) {
ss->face_sets = static_cast<int *>(CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS));
ss->face_sets = static_cast<int *>(
CustomData_get_layer_named(&me->pdata, CD_PROP_INT32, ".sculpt_face_set"));
}
else {
ss->face_sets = nullptr;
@ -1967,22 +1968,17 @@ int *BKE_sculpt_face_sets_ensure(Mesh *mesh)
{
using namespace blender;
using namespace blender::bke;
if (CustomData_has_layer(&mesh->pdata, CD_SCULPT_FACE_SETS)) {
return static_cast<int *>(CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS));
MutableAttributeAccessor attributes = mesh->attributes_for_write();
if (!attributes.contains(".sculpt_face_set")) {
SpanAttributeWriter<int> face_sets = attributes.lookup_or_add_for_write_only_span<int>(
".sculpt_face_set", ATTR_DOMAIN_FACE);
face_sets.span.fill(1);
mesh->face_sets_color_default = 1;
face_sets.finish();
}
const AttributeAccessor attributes = mesh->attributes_for_write();
const VArray<bool> hide_poly = attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
MutableSpan<int> face_sets = {
static_cast<int *>(CustomData_add_layer(
&mesh->pdata, CD_SCULPT_FACE_SETS, CD_CONSTRUCT, nullptr, mesh->totpoly)),
mesh->totpoly};
face_sets.fill(1);
mesh->face_sets_color_default = 1;
return face_sets.data();
return static_cast<int *>(
CustomData_get_layer_named(&mesh->pdata, CD_PROP_INT32, ".sculpt_face_set"));
}
bool *BKE_sculpt_hide_poly_ensure(Mesh *mesh)

View File

@ -1326,16 +1326,17 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
case PBVH_FACES: {
/* Pass vertices separately because they may be not be the same as the mesh's vertices,
* and pass normals separately because they are managed by the PBVH. */
GPU_pbvh_mesh_buffers_update(pbvh->vbo_id,
node->draw_buffers,
pbvh->mesh,
pbvh->mesh_positions,
CustomData_get_layer(pbvh->vdata, CD_PAINT_MASK),
CustomData_get_layer(pbvh->pdata, CD_SCULPT_FACE_SETS),
pbvh->face_sets_color_seed,
pbvh->face_sets_color_default,
update_flags,
pbvh->vert_normals);
GPU_pbvh_mesh_buffers_update(
pbvh->vbo_id,
node->draw_buffers,
pbvh->mesh,
pbvh->mesh_positions,
CustomData_get_layer(pbvh->vdata, CD_PAINT_MASK),
CustomData_get_layer_named(pbvh->pdata, CD_PROP_INT32, ".sculpt_face_set"),
pbvh->face_sets_color_seed,
pbvh->face_sets_color_default,
update_flags,
pbvh->vert_normals);
break;
}
case PBVH_BMESH:
@ -3117,9 +3118,9 @@ bool pbvh_has_face_sets(PBVH *pbvh)
{
switch (pbvh->header.type) {
case PBVH_GRIDS:
return (pbvh->pdata && CustomData_get_layer(pbvh->pdata, CD_SCULPT_FACE_SETS));
case PBVH_FACES:
return (pbvh->pdata && CustomData_get_layer(pbvh->pdata, CD_SCULPT_FACE_SETS));
return pbvh->pdata &&
CustomData_get_layer_named(pbvh->pdata, CD_PROP_INT32, ".sculpt_face_set") != NULL;
case PBVH_BMESH:
return false;
}

View File

@ -1228,7 +1228,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
}
/* Active channels root pointer. */
if (ed->displayed_channels == old_displayed_channels || ed->displayed_channels == nullptr) {
if (ELEM(ed->displayed_channels, old_displayed_channels, nullptr)) {
ed->displayed_channels = &ed->channels;
}
else {
@ -1263,7 +1263,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
}
}
if (ms->old_channels == old_displayed_channels || ms->old_channels == nullptr) {
if (ELEM(ms->old_channels, old_displayed_channels, nullptr)) {
ms->old_channels = &ed->channels;
}
else {

View File

@ -1155,11 +1155,12 @@ void BKE_sound_update_scene(Depsgraph *depsgraph, Scene *scene)
/* cheap test to skip looping over all objects (no speakers is a common case) */
if (DEG_id_type_any_exists(depsgraph, ID_SPK)) {
DEG_OBJECT_ITER_BEGIN (depsgraph,
object,
(DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY |
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET)) {
DEGObjectIterSettings deg_iter_settings = {0};
deg_iter_settings.depsgraph = depsgraph;
deg_iter_settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY |
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
DEG_OBJECT_ITER_BEGIN (&deg_iter_settings, object) {
sound_update_base(scene, object, new_set);
}
DEG_OBJECT_ITER_END;

View File

@ -41,6 +41,8 @@ typedef struct ConverterStorage {
/* CustomData layer for vertex sharpnesses. */
const float *cd_vertex_crease;
/* CustomData layer for edge sharpness. */
const float *cd_edge_crease;
/* Indexed by loop index, value denotes index of face-varying vertex
* which corresponds to the UV coordinate.
*/
@ -157,12 +159,11 @@ static float get_edge_sharpness(const OpenSubdiv_Converter *converter, int manif
return 10.0f;
}
#endif
if (!storage->settings.use_creases) {
if (!storage->settings.use_creases || storage->cd_edge_crease == NULL) {
return 0.0f;
}
const int edge_index = storage->manifold_edge_index_reverse[manifold_edge_index];
const MEdge *medge = storage->edges;
return BKE_subdiv_crease_to_sharpness_char(medge[edge_index].crease);
return BKE_subdiv_crease_to_sharpness_f(storage->cd_edge_crease[edge_index]);
}
static bool is_infinite_sharp_vertex(const OpenSubdiv_Converter *converter,
@ -211,7 +212,7 @@ static void precalc_uv_layer(const OpenSubdiv_Converter *converter, const int la
UvVertMap *uv_vert_map = BKE_mesh_uv_vert_map_create(
storage->polys,
(const bool *)CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, ".hide_poly"),
(const bool *)CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, ".selection_poly"),
(const bool *)CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, ".select_poly"),
storage->loops,
mloopuv,
num_poly,
@ -399,6 +400,7 @@ static void init_user_data(OpenSubdiv_Converter *converter,
user_data->polys = BKE_mesh_polys(mesh);
user_data->loops = BKE_mesh_loops(mesh);
user_data->cd_vertex_crease = CustomData_get_layer(&mesh->vdata, CD_CREASE);
user_data->cd_edge_crease = CustomData_get_layer(&mesh->edata, CD_CREASE);
user_data->loop_uv_indices = NULL;
initialize_manifold_indices(user_data);
converter->user_data = user_data;

View File

@ -519,9 +519,11 @@ static bool subdiv_mesh_topology_info(const SubdivForeachContext *foreach_contex
const int *UNUSED(subdiv_polygon_offset))
{
/* Multi-resolution grid data will be applied or become invalid after subdivision,
* so don't try to preserve it and use memory. */
* so don't try to preserve it and use memory. Crease values should also not be interpolated. */
CustomData_MeshMasks mask = CD_MASK_EVERYTHING;
mask.lmask &= ~CD_MASK_MULTIRES_GRIDS;
mask.vmask &= ~CD_MASK_CREASE;
mask.emask &= ~CD_MASK_CREASE;
SubdivMeshContext *subdiv_context = static_cast<SubdivMeshContext *>(foreach_context->user_data);
subdiv_context->subdiv_mesh = BKE_mesh_new_nomain_from_template_ex(
@ -784,7 +786,7 @@ static void subdiv_copy_edge_data(SubdivMeshContext *ctx,
{
const int subdiv_edge_index = subdiv_edge - ctx->subdiv_edges;
if (coarse_edge == nullptr) {
subdiv_edge->crease = 0;
/* TODO: Ensure crease layer isn't copied to result. */
subdiv_edge->flag = 0;
if (!ctx->settings->use_optimal_display) {
subdiv_edge->flag |= ME_EDGERENDER;

View File

@ -590,11 +590,12 @@ static void ss_sync_ccg_from_derivedmesh(CCGSubSurf *ss,
me = medge;
index = (int *)dm->getEdgeDataArray(dm, CD_ORIGINDEX);
const float *creases = (const float *)dm->getEdgeDataArray(dm, CD_CREASE);
for (i = 0; i < totedge; i++, me++) {
CCGEdge *e;
float crease;
crease = useFlatSubdiv ? creaseFactor : me->crease * creaseFactor / 255.0f;
crease = useFlatSubdiv ? creaseFactor : (creases ? creases[i] * creaseFactor : 0.0f);
ccgSubSurf_syncEdge(
ss, POINTER_FROM_INT(i), POINTER_FROM_UINT(me->v1), POINTER_FROM_UINT(me->v2), crease, &e);
@ -946,7 +947,6 @@ BLI_INLINE void ccgDM_to_MEdge(MEdge *med, const int v1, const int v2, const sho
{
med->v1 = v1;
med->v2 = v2;
med->crease = 0;
med->flag = flag;
}

View File

@ -458,7 +458,7 @@ int BLI_string_search_query(StringSearch *search, const char *query, void ***r_d
if (score == found_scores[0] && !query_str.is_empty()) {
/* Sort items with best score by length. Shorter items are more likely the ones you are
* looking for. This also ensures that exact matches will be at the top, even if the query is
* a substring of another item. */
* a sub-string of another item. */
std::sort(indices.begin(), indices.end(), [&](int a, int b) {
return search->items[a].length < search->items[b].length;
});

View File

@ -12,5 +12,5 @@ set(INC
include_directories(${INC})
BLENDER_TEST_PERFORMANCE(BLI_ghash_performance "bf_blenlib")
BLENDER_TEST_PERFORMANCE(BLI_task_performance "bf_blenlib")
blender_test_performance(BLI_ghash_performance "bf_blenlib")
blender_test_performance(BLI_task_performance "bf_blenlib")

View File

@ -25,6 +25,8 @@ static void version_mesh_legacy_to_struct_of_array_format(Mesh &mesh)
BKE_mesh_legacy_convert_flags_to_hide_layers(&mesh);
BKE_mesh_legacy_convert_mpoly_to_material_indices(&mesh);
BKE_mesh_legacy_bevel_weight_to_layers(&mesh);
BKE_mesh_legacy_face_set_to_generic(&mesh);
BKE_mesh_legacy_edge_crease_to_layers(&mesh);
BKE_mesh_legacy_convert_verts_to_positions(&mesh);
}

View File

@ -505,8 +505,6 @@ void BM_mesh_copy_init_customdata_from_mesh_array(BMesh *bm_dst,
allocsize = &bm_mesh_allocsize_default;
}
char cd_flag = 0;
for (int i = 0; i < me_src_array_len; i++) {
const Mesh *me_src = me_src_array[i];
if (i == 0) {
@ -529,18 +527,12 @@ void BM_mesh_copy_init_customdata_from_mesh_array(BMesh *bm_dst,
CustomData_merge_mesh_to_bmesh(
&me_src->pdata, &bm_dst->pdata, CD_MASK_BMESH.pmask, CD_SET_DEFAULT, 0);
}
cd_flag |= me_src->cd_flag;
}
cd_flag |= BM_mesh_cd_flag_from_bmesh(bm_dst);
CustomData_bmesh_init_pool(&bm_dst->vdata, allocsize->totvert, BM_VERT);
CustomData_bmesh_init_pool(&bm_dst->edata, allocsize->totedge, BM_EDGE);
CustomData_bmesh_init_pool(&bm_dst->ldata, allocsize->totloop, BM_LOOP);
CustomData_bmesh_init_pool(&bm_dst->pdata, allocsize->totface, BM_FACE);
BM_mesh_cd_flag_apply(bm_dst, cd_flag);
}
void BM_mesh_copy_init_customdata_from_mesh(BMesh *bm_dst,

View File

@ -288,7 +288,8 @@ static void bm_log_verts_restore(BMesh *bm, BMLog *log, GHash *verts)
static void bm_log_faces_restore(BMesh *bm, BMLog *log, GHash *faces)
{
GHashIterator gh_iter;
const int cd_face_sets = CustomData_get_offset(&bm->pdata, CD_SCULPT_FACE_SETS);
const int cd_face_sets = CustomData_get_offset_named(
&bm->pdata, CD_PROP_INT32, ".sculpt_face_set");
GHASH_ITER (gh_iter, faces) {
void *key = BLI_ghashIterator_getKey(&gh_iter);

View File

@ -111,57 +111,6 @@ using blender::MutableSpan;
using blender::Span;
using blender::StringRef;
void BM_mesh_cd_flag_ensure(BMesh *bm, Mesh *mesh, const char cd_flag)
{
const char cd_flag_all = BM_mesh_cd_flag_from_bmesh(bm) | cd_flag;
BM_mesh_cd_flag_apply(bm, cd_flag_all);
if (mesh) {
mesh->cd_flag = cd_flag_all;
}
}
void BM_mesh_cd_flag_apply(BMesh *bm, const char cd_flag)
{
/* CustomData_bmesh_init_pool() must run first */
BLI_assert(bm->vdata.totlayer == 0 || bm->vdata.pool != nullptr);
BLI_assert(bm->edata.totlayer == 0 || bm->edata.pool != nullptr);
BLI_assert(bm->pdata.totlayer == 0 || bm->pdata.pool != nullptr);
if (cd_flag & ME_CDFLAG_VERT_CREASE) {
if (!CustomData_has_layer(&bm->vdata, CD_CREASE)) {
BM_data_layer_add(bm, &bm->vdata, CD_CREASE);
}
}
else {
if (CustomData_has_layer(&bm->vdata, CD_CREASE)) {
BM_data_layer_free(bm, &bm->vdata, CD_CREASE);
}
}
if (cd_flag & ME_CDFLAG_EDGE_CREASE) {
if (!CustomData_has_layer(&bm->edata, CD_CREASE)) {
BM_data_layer_add(bm, &bm->edata, CD_CREASE);
}
}
else {
if (CustomData_has_layer(&bm->edata, CD_CREASE)) {
BM_data_layer_free(bm, &bm->edata, CD_CREASE);
}
}
}
char BM_mesh_cd_flag_from_bmesh(BMesh *bm)
{
char cd_flag = 0;
if (CustomData_has_layer(&bm->vdata, CD_CREASE)) {
cd_flag |= ME_CDFLAG_VERT_CREASE;
}
if (CustomData_has_layer(&bm->edata, CD_CREASE)) {
cd_flag |= ME_CDFLAG_EDGE_CREASE;
}
return cd_flag;
}
/* Static function for alloc (duplicate in modifiers_bmesh.c) */
static BMFace *bm_face_create_from_mpoly(BMesh &bm,
Span<MLoop> loops,
@ -311,25 +260,21 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshPar
CustomData_bmesh_init_pool(&bm->ldata, me->totloop, BM_LOOP);
CustomData_bmesh_init_pool(&bm->pdata, me->totpoly, BM_FACE);
}
BM_mesh_cd_flag_apply(bm, me->cd_flag | (is_new ? 0 : BM_mesh_cd_flag_from_bmesh(bm)));
/* Only copy these values over if the source mesh is flagged to be using them.
* Even if `bm` has these layers, they may have been added from another mesh, when `!is_new`. */
const int cd_edge_crease_offset = (me->cd_flag & ME_CDFLAG_EDGE_CREASE) ?
CustomData_get_offset(&bm->edata, CD_CREASE) :
-1;
const int cd_shape_key_offset = tot_shape_keys ? CustomData_get_offset(&bm->vdata, CD_SHAPEKEY) :
-1;
const int cd_shape_keyindex_offset = is_new && (tot_shape_keys || params->add_key_index) ?
CustomData_get_offset(&bm->vdata, CD_SHAPE_KEYINDEX) :
-1;
const bool *selection_vert = (const bool *)CustomData_get_layer_named(
&me->vdata, CD_PROP_BOOL, ".selection_vert");
const bool *selection_edge = (const bool *)CustomData_get_layer_named(
&me->edata, CD_PROP_BOOL, ".selection_edge");
const bool *selection_poly = (const bool *)CustomData_get_layer_named(
&me->pdata, CD_PROP_BOOL, ".selection_poly");
const bool *select_vert = (const bool *)CustomData_get_layer_named(
&me->vdata, CD_PROP_BOOL, ".select_vert");
const bool *select_edge = (const bool *)CustomData_get_layer_named(
&me->edata, CD_PROP_BOOL, ".select_edge");
const bool *select_poly = (const bool *)CustomData_get_layer_named(
&me->pdata, CD_PROP_BOOL, ".select_poly");
const bool *hide_vert = (const bool *)CustomData_get_layer_named(
&me->vdata, CD_PROP_BOOL, ".hide_vert");
const bool *hide_edge = (const bool *)CustomData_get_layer_named(
@ -349,7 +294,7 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshPar
if (hide_vert && hide_vert[i]) {
BM_elem_flag_enable(v, BM_ELEM_HIDDEN);
}
if (selection_vert && selection_vert[i]) {
if (select_vert && select_vert[i]) {
BM_vert_select_set(bm, v, true);
}
@ -389,16 +334,12 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshPar
if (hide_edge && hide_edge[i]) {
BM_elem_flag_enable(e, BM_ELEM_HIDDEN);
}
if (selection_edge && selection_edge[i]) {
if (select_edge && select_edge[i]) {
BM_edge_select_set(bm, e, true);
}
/* Copy Custom Data */
CustomData_to_bmesh_block(&me->edata, &bm->edata, i, &e->head.data, true);
if (cd_edge_crease_offset != -1) {
BM_ELEM_CD_SET_FLOAT(e, cd_edge_crease_offset, (float)medge[i].crease / 255.0f);
}
}
if (is_new) {
bm->elem_index_dirty &= ~BM_EDGE; /* Added in order, clear dirty flag. */
@ -440,7 +381,7 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshPar
if (hide_poly && hide_poly[i]) {
BM_elem_flag_enable(f, BM_ELEM_HIDDEN);
}
if (selection_poly && selection_poly[i]) {
if (select_poly && select_poly[i]) {
BM_face_select_set(bm, f, true);
}
@ -900,7 +841,7 @@ static void write_fn_to_attribute(blender::bke::MutableAttributeAccessor attribu
attribute.finish();
}
static void assert_bmesh_has_no_mesh_only_attributes(BMesh &bm)
static void assert_bmesh_has_no_mesh_only_attributes(const BMesh &bm)
{
(void)bm; /* Unused in the release builds. */
@ -909,9 +850,9 @@ static void assert_bmesh_has_no_mesh_only_attributes(BMesh &bm)
BLI_assert(CustomData_get_layer_named(&bm.edata, CD_PROP_BOOL, ".hide_edge") == nullptr);
BLI_assert(CustomData_get_layer_named(&bm.pdata, CD_PROP_BOOL, ".hide_poly") == nullptr);
/* The "selection" attributes are stored as flags on #BMesh. */
BLI_assert(CustomData_get_layer_named(&bm.vdata, CD_PROP_BOOL, ".selection_vert") == nullptr);
BLI_assert(CustomData_get_layer_named(&bm.edata, CD_PROP_BOOL, ".selection_edge") == nullptr);
BLI_assert(CustomData_get_layer_named(&bm.pdata, CD_PROP_BOOL, ".selection_poly") == nullptr);
BLI_assert(CustomData_get_layer_named(&bm.vdata, CD_PROP_BOOL, ".select_vert") == nullptr);
BLI_assert(CustomData_get_layer_named(&bm.edata, CD_PROP_BOOL, ".select_edge") == nullptr);
BLI_assert(CustomData_get_layer_named(&bm.pdata, CD_PROP_BOOL, ".select_poly") == nullptr);
}
static void convert_bmesh_hide_flags_to_mesh_attributes(BMesh &bm,
@ -949,32 +890,31 @@ static void convert_bmesh_hide_flags_to_mesh_attributes(BMesh &bm,
}
static void convert_bmesh_selection_flags_to_mesh_attributes(BMesh &bm,
const bool need_selection_vert,
const bool need_selection_edge,
const bool need_selection_poly,
const bool need_select_vert,
const bool need_select_edge,
const bool need_select_poly,
Mesh &mesh)
{
using namespace blender;
if (!(need_selection_vert || need_selection_edge || need_selection_poly)) {
if (!(need_select_vert || need_select_edge || need_select_poly)) {
return;
}
bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
BM_mesh_elem_table_ensure(&bm, BM_VERT | BM_EDGE | BM_FACE);
if (need_selection_vert) {
write_fn_to_attribute<bool>(
attributes, ".selection_vert", ATTR_DOMAIN_POINT, [&](const int i) {
return BM_elem_flag_test(BM_vert_at_index(&bm, i), BM_ELEM_SELECT);
});
if (need_select_vert) {
write_fn_to_attribute<bool>(attributes, ".select_vert", ATTR_DOMAIN_POINT, [&](const int i) {
return BM_elem_flag_test(BM_vert_at_index(&bm, i), BM_ELEM_SELECT);
});
}
if (need_selection_edge) {
write_fn_to_attribute<bool>(attributes, ".selection_edge", ATTR_DOMAIN_EDGE, [&](const int i) {
if (need_select_edge) {
write_fn_to_attribute<bool>(attributes, ".select_edge", ATTR_DOMAIN_EDGE, [&](const int i) {
return BM_elem_flag_test(BM_edge_at_index(&bm, i), BM_ELEM_SELECT);
});
}
if (need_selection_poly) {
write_fn_to_attribute<bool>(attributes, ".selection_poly", ATTR_DOMAIN_FACE, [&](const int i) {
if (need_select_poly) {
write_fn_to_attribute<bool>(attributes, ".select_poly", ATTR_DOMAIN_FACE, [&](const int i) {
return BM_elem_flag_test(BM_face_at_index(&bm, i), BM_ELEM_SELECT);
});
}
@ -988,7 +928,6 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
BMIter iter;
int i, j;
const int cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
const int cd_shape_keyindex_offset = CustomData_get_offset(&bm->vdata, CD_SHAPE_KEYINDEX);
const int ototvert = me->totvert;
@ -1029,9 +968,9 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
MutableSpan<MPoly> mpoly = me->polys_for_write();
MutableSpan<MLoop> mloop = me->loops_for_write();
bool need_selection_vert = false;
bool need_selection_edge = false;
bool need_selection_poly = false;
bool need_select_vert = false;
bool need_select_edge = false;
bool need_select_poly = false;
bool need_hide_vert = false;
bool need_hide_edge = false;
bool need_hide_poly = false;
@ -1041,8 +980,6 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
* different than the BMesh's. */
BKE_mesh_clear_derived_normals(me);
me->cd_flag = BM_mesh_cd_flag_from_bmesh(bm);
i = 0;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
copy_v3_v3(positions[i], v->co);
@ -1051,7 +988,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
need_hide_vert = true;
}
if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
need_selection_vert = true;
need_select_vert = true;
}
BM_elem_index_set(v, i); /* set_inline */
@ -1075,7 +1012,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
need_hide_edge = true;
}
if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
need_selection_edge = true;
need_select_edge = true;
}
BM_elem_index_set(e, i); /* set_inline */
@ -1085,10 +1022,6 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
bmesh_quick_edgedraw_flag(&medge[i], e);
if (cd_edge_crease_offset != -1) {
medge[i].crease = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(e, cd_edge_crease_offset);
}
i++;
BM_CHECK_ELEMENT(e);
}
@ -1108,7 +1041,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
need_hide_poly = true;
}
if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
need_selection_poly = true;
need_select_poly = true;
}
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
@ -1211,7 +1144,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
convert_bmesh_hide_flags_to_mesh_attributes(
*bm, need_hide_vert, need_hide_edge, need_hide_poly, *me);
convert_bmesh_selection_flags_to_mesh_attributes(
*bm, need_selection_vert, need_selection_edge, need_selection_poly, *me);
*bm, need_select_vert, need_select_edge, need_select_poly, *me);
{
me->totselect = BLI_listbase_count(&(bm->selected));
@ -1304,8 +1237,6 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
MLoop *mloop = loops.data();
unsigned int i, j;
const int cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
/* Clear normals on the mesh completely, since the original vertex and polygon count might be
* different than the BMesh's. */
BKE_mesh_clear_derived_normals(me);
@ -1315,7 +1246,7 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
bke::MutableAttributeAccessor mesh_attributes = me->attributes_for_write();
bke::SpanAttributeWriter<bool> hide_vert_attribute;
bke::SpanAttributeWriter<bool> selection_vert_attribute;
bke::SpanAttributeWriter<bool> select_vert_attribute;
BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
copy_v3_v3(positions[i], eve->co);
@ -1329,11 +1260,11 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
hide_vert_attribute.span[i] = true;
}
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
if (!selection_vert_attribute) {
selection_vert_attribute = mesh_attributes.lookup_or_add_for_write_only_span<bool>(
".selection_vert", ATTR_DOMAIN_POINT);
if (!select_vert_attribute) {
select_vert_attribute = mesh_attributes.lookup_or_add_for_write_only_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
}
selection_vert_attribute.span[i] = true;
select_vert_attribute.span[i] = true;
}
CustomData_from_bmesh_block(&bm->vdata, &me->vdata, eve->head.data, i);
@ -1341,7 +1272,7 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
bm->elem_index_dirty &= ~BM_VERT;
bke::SpanAttributeWriter<bool> hide_edge_attribute;
bke::SpanAttributeWriter<bool> selection_edge_attribute;
bke::SpanAttributeWriter<bool> select_edge_attribute;
BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) {
MEdge *med = &medge[i];
@ -1359,11 +1290,11 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
hide_edge_attribute.span[i] = true;
}
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
if (!selection_edge_attribute) {
selection_edge_attribute = mesh_attributes.lookup_or_add_for_write_only_span<bool>(
".selection_edge", ATTR_DOMAIN_EDGE);
if (!select_edge_attribute) {
select_edge_attribute = mesh_attributes.lookup_or_add_for_write_only_span<bool>(
".select_edge", ATTR_DOMAIN_EDGE);
}
selection_edge_attribute.span[i] = true;
select_edge_attribute.span[i] = true;
}
/* Handle this differently to editmode switching,
@ -1374,10 +1305,6 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
}
}
if (cd_edge_crease_offset != -1) {
med->crease = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_crease_offset);
}
CustomData_from_bmesh_block(&bm->edata, &me->edata, eed->head.data, i);
}
bm->elem_index_dirty &= ~BM_EDGE;
@ -1385,7 +1312,7 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
j = 0;
bke::SpanAttributeWriter<int> material_index_attribute;
bke::SpanAttributeWriter<bool> hide_poly_attribute;
bke::SpanAttributeWriter<bool> selection_poly_attribute;
bke::SpanAttributeWriter<bool> select_poly_attribute;
BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) {
BMLoop *l_iter;
BMLoop *l_first;
@ -1403,11 +1330,11 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
hide_poly_attribute.span[i] = true;
}
if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
if (!selection_poly_attribute) {
selection_poly_attribute = mesh_attributes.lookup_or_add_for_write_only_span<bool>(
".selection_poly", ATTR_DOMAIN_FACE);
if (!select_poly_attribute) {
select_poly_attribute = mesh_attributes.lookup_or_add_for_write_only_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
}
selection_poly_attribute.span[i] = true;
select_poly_attribute.span[i] = true;
}
mp->loopstart = j;
@ -1441,9 +1368,7 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
hide_vert_attribute.finish();
hide_edge_attribute.finish();
hide_poly_attribute.finish();
selection_vert_attribute.finish();
selection_edge_attribute.finish();
selection_poly_attribute.finish();
me->cd_flag = BM_mesh_cd_flag_from_bmesh(bm);
select_vert_attribute.finish();
select_edge_attribute.finish();
select_poly_attribute.finish();
}

View File

@ -13,10 +13,6 @@ struct CustomData_MeshMasks;
struct Main;
struct Mesh;
void BM_mesh_cd_flag_ensure(BMesh *bm, struct Mesh *mesh, char cd_flag);
void BM_mesh_cd_flag_apply(BMesh *bm, char cd_flag);
char BM_mesh_cd_flag_from_bmesh(BMesh *bm);
struct BMeshFromMeshParams {
bool calc_face_normal;
bool calc_vert_normal;

View File

@ -4799,7 +4799,7 @@ static float projected_boundary_area(BevVert *bv, BMFace *f)
find_face_internal_boundverts(bv, f, unsnapped);
do {
float *co = v->nv.v->co;
if (v == unsnapped[0] || v == unsnapped[1] || v == unsnapped[2]) {
if (ELEM(v, unsnapped[0], unsnapped[1], unsnapped[2])) {
mul_v2_m3v3(proj_co[i], axis_mat, co);
}
else {
@ -4922,7 +4922,7 @@ static void build_center_ngon(BevelParams *bp, BMesh *bm, BevVert *bv, int mat_n
BLI_array_append(vv, mesh_vert(vm, i, ns2, ns2)->v);
if (frep) {
BLI_array_append(vf, frep);
if (v == frep_unsnapped[0] || v == frep_unsnapped[1] || v == frep_unsnapped[2]) {
if (ELEM(v, frep_unsnapped[0], frep_unsnapped[1], frep_unsnapped[2])) {
BLI_array_append(ve, NULL);
}
else {
@ -5299,7 +5299,7 @@ static void snap_edges_for_vmesh_vert(int i,
int previ = (i + n_bndv - 1) % n_bndv;
/* Make jj and kk be the j and k indices for this corner. */
int jj = corner < 2 ? j : j + 1;
int kk = (corner == 0 || corner == 3) ? k : k + 1;
int kk = ELEM(corner, 0, 3) ? k : k + 1;
if (jj < ns2 && kk < ns2) {
; /* No snap. */
}
@ -5765,7 +5765,7 @@ static BMFace *bevel_build_poly(BevelParams *bp, BMesh *bm, BevVert *bv)
BLI_array_append(bmverts, bndv->nv.v);
if (repface) {
BLI_array_append(bmfaces, repface);
if (bndv == unsnapped[0] || bndv == unsnapped[1] || bndv == unsnapped[2]) {
if (ELEM(bndv, unsnapped[0], unsnapped[1], unsnapped[2])) {
BLI_array_append(bmedges, NULL);
}
else {

View File

@ -10,6 +10,7 @@
#pragma once
#include "BLI_iterator.h"
#include "BLI_utildefines.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@ -132,15 +133,36 @@ bool DEG_is_fully_evaluated(const struct Depsgraph *depsgraph);
/** \name DEG object iterators
* \{ */
enum {
typedef enum DegIterFlag {
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY = (1 << 0),
DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY = (1 << 1),
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET = (1 << 2),
DEG_ITER_OBJECT_FLAG_VISIBLE = (1 << 3),
DEG_ITER_OBJECT_FLAG_DUPLI = (1 << 4),
};
} DegIterFlag;
ENUM_OPERATORS(DegIterFlag, DEG_ITER_OBJECT_FLAG_DUPLI)
typedef struct DEGObjectIterSettings {
struct Depsgraph *depsgraph;
/**
* Bitfield of the #DegIterFlag.
*
* NOTE: Be careful with DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY objects.
* Although they are available they have no overrides (collection_properties)
* and will crash if you try to access it.
*/
uint32_t flags;
} DEGObjectIterSettings;
/**
* Flags to to get objects for draw manager and final render.
*/
#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_FLAGS \
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | \
DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_DUPLI
typedef struct DEGObjectIterData {
DEGObjectIterSettings *settings;
struct Depsgraph *graph;
int flag;
@ -174,16 +196,12 @@ void DEG_iterator_objects_begin(struct BLI_Iterator *iter, DEGObjectIterData *da
void DEG_iterator_objects_next(struct BLI_Iterator *iter);
void DEG_iterator_objects_end(struct BLI_Iterator *iter);
/**
* NOTE: Be careful with DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY objects.
* Although they are available they have no overrides (collection_properties)
* and will crash if you try to access it.
*/
#define DEG_OBJECT_ITER_BEGIN(graph_, instance_, flag_) \
#define DEG_OBJECT_ITER_BEGIN(settings_, instance_) \
{ \
DEGObjectIterData data_ = { \
graph_, \
flag_, \
(settings_), \
(settings_)->depsgraph, \
(int)(settings_)->flags, \
}; \
\
ITER_BEGIN (DEG_iterator_objects_begin, \
@ -198,18 +216,6 @@ void DEG_iterator_objects_end(struct BLI_Iterator *iter);
} \
((void)0)
/**
* Depsgraph objects iterator for draw manager and final render
*/
#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(graph_, instance_) \
DEG_OBJECT_ITER_BEGIN (graph_, \
instance_, \
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | \
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE | \
DEG_ITER_OBJECT_FLAG_DUPLI)
#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END DEG_OBJECT_ITER_END
/** \} */
/* -------------------------------------------------------------------- */

View File

@ -138,8 +138,8 @@ bool RNANodeQuery::contains(const char *prop_identifier, const char *rna_path_co
return false;
}
/* If substr != prop_identifier, it means that the substring is found further in prop_identifier,
* and that thus index -1 is a valid memory location. */
/* If `substr != prop_identifier`, it means that the sub-string is found further in
* `prop_identifier`, and that thus index -1 is a valid memory location. */
const bool start_ok = substr == prop_identifier || substr[-1] == '.';
if (!start_ok) {
return false;

View File

@ -555,6 +555,7 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_armature_envelope_solid_vert.glsl
engines/overlay/shaders/overlay_armature_shape_outline_geom.glsl
engines/overlay/shaders/overlay_armature_shape_outline_vert.glsl
engines/overlay/shaders/overlay_armature_shape_outline_vert_no_geom.glsl
engines/overlay/shaders/overlay_armature_shape_solid_frag.glsl
engines/overlay/shaders/overlay_armature_shape_solid_vert.glsl
engines/overlay/shaders/overlay_armature_shape_wire_vert.glsl
@ -572,6 +573,7 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_depth_only_vert.glsl
engines/overlay/shaders/overlay_edit_curve_handle_geom.glsl
engines/overlay/shaders/overlay_edit_curve_handle_vert.glsl
engines/overlay/shaders/overlay_edit_curve_handle_vert_no_geom.glsl
engines/overlay/shaders/overlay_edit_curve_point_vert.glsl
engines/overlay/shaders/overlay_edit_curve_wire_vert.glsl
engines/overlay/shaders/overlay_edit_gpencil_canvas_vert.glsl
@ -587,6 +589,7 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_edit_mesh_normal_vert.glsl
engines/overlay/shaders/overlay_edit_mesh_skin_root_vert.glsl
engines/overlay/shaders/overlay_edit_mesh_vert.glsl
engines/overlay/shaders/overlay_edit_mesh_vert_no_geom.glsl
engines/overlay/shaders/overlay_edit_particle_point_vert.glsl
engines/overlay/shaders/overlay_edit_particle_strand_vert.glsl
engines/overlay/shaders/overlay_edit_uv_edges_frag.glsl
@ -619,6 +622,7 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_motion_path_line_frag.glsl
engines/overlay/shaders/overlay_motion_path_line_geom.glsl
engines/overlay/shaders/overlay_motion_path_line_vert.glsl
engines/overlay/shaders/overlay_motion_path_line_vert_no_geom.glsl
engines/overlay/shaders/overlay_motion_path_point_vert.glsl
engines/overlay/shaders/overlay_outline_detect_frag.glsl
engines/overlay/shaders/overlay_outline_prepass_curves_vert.glsl

View File

@ -201,6 +201,7 @@ void DRW_gpu_render_context_enable(void *re_gpu_context);
void DRW_gpu_render_context_disable(void *re_gpu_context);
void DRW_deferred_shader_remove(struct GPUMaterial *mat);
void DRW_deferred_shader_optimize_remove(struct GPUMaterial *mat);
/**
* Get DrawData from the given ID-block. In order for this to work, we assume that

View File

@ -591,23 +591,26 @@ static void eevee_lightbake_context_enable(EEVEE_LightBake *lbake)
if (GPU_use_main_context_workaround() && !BLI_thread_is_main()) {
GPU_context_main_lock();
DRW_opengl_context_enable();
GPU_render_begin();
return;
}
if (lbake->gl_context) {
DRW_opengl_render_context_enable(lbake->gl_context);
if (lbake->gpu_context == NULL) {
lbake->gpu_context = GPU_context_create(NULL);
lbake->gpu_context = GPU_context_create(NULL, lbake->gl_context);
}
DRW_gpu_render_context_enable(lbake->gpu_context);
}
else {
DRW_opengl_context_enable();
}
GPU_render_begin();
}
static void eevee_lightbake_context_disable(EEVEE_LightBake *lbake)
{
GPU_render_end();
if (GPU_use_main_context_workaround() && !BLI_thread_is_main()) {
DRW_opengl_context_disable();
GPU_context_main_unlock();
@ -636,7 +639,10 @@ static void eevee_lightbake_count_probes(EEVEE_LightBake *lbake)
/* At least one of each for the world */
lbake->grid_len = lbake->cube_len = lbake->total_irr_samples = 1;
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN (depsgraph, ob) {
DEGObjectIterSettings deg_iter_settings = {0};
deg_iter_settings.depsgraph = depsgraph;
deg_iter_settings.flags = DEG_OBJECT_ITER_FOR_RENDER_ENGINE_FLAGS;
DEG_OBJECT_ITER_BEGIN (&deg_iter_settings, ob) {
const int ob_visibility = BKE_object_visibility(ob, DAG_EVAL_RENDER);
if ((ob_visibility & OB_VISIBLE_SELF) == 0) {
continue;
@ -655,7 +661,7 @@ static void eevee_lightbake_count_probes(EEVEE_LightBake *lbake)
}
}
}
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
DEG_OBJECT_ITER_END;
}
static void eevee_lightbake_create_render_target(EEVEE_LightBake *lbake, int rt_res)
@ -1279,7 +1285,10 @@ static void eevee_lightbake_gather_probes(EEVEE_LightBake *lbake)
/* Convert all lightprobes to tight UBO data from all lightprobes in the scene.
* This allows a large number of probe to be precomputed (even dupli ones). */
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN (depsgraph, ob) {
DEGObjectIterSettings deg_iter_settings = {0};
deg_iter_settings.depsgraph = depsgraph;
deg_iter_settings.flags = DEG_OBJECT_ITER_FOR_RENDER_ENGINE_FLAGS;
DEG_OBJECT_ITER_BEGIN (&deg_iter_settings, ob) {
const int ob_visibility = BKE_object_visibility(ob, DAG_EVAL_RENDER);
if ((ob_visibility & OB_VISIBLE_SELF) == 0) {
continue;
@ -1300,7 +1309,7 @@ static void eevee_lightbake_gather_probes(EEVEE_LightBake *lbake)
}
}
}
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
DEG_OBJECT_ITER_END;
SORT_PROBE(EEVEE_LightGrid,
lbake->grid_prb + 1,

View File

@ -51,7 +51,8 @@ void raytrace_screenspace_ray_finalize(inout ScreenSpaceRay ray)
}
float ray_len_sqr = len_squared(ray.direction.xyz);
/* Make ray.direction cover one pixel. */
bool is_more_vertical = abs(ray.direction.x) < abs(ray.direction.y);
bool is_more_vertical = abs(ray.direction.x / ssrPixelSize.x) <
abs(ray.direction.y / ssrPixelSize.y);
ray.direction /= (is_more_vertical) ? abs(ray.direction.y) : abs(ray.direction.x);
ray.direction *= (is_more_vertical) ? ssrPixelSize.y : ssrPixelSize.x;
/* Clip to segment's end. */

View File

@ -471,6 +471,8 @@ GPUMaterial *ShaderModule::material_shader_get(const char *name,
this);
GPU_material_status_set(gpumat, GPU_MAT_QUEUED);
GPU_material_compile(gpumat);
/* Queue deferred material optimization. */
DRW_shader_queue_optimize_material(gpumat);
return gpumat;
}

View File

@ -140,11 +140,11 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata)
pd->armature_bone_select_act_grp = grp = DRW_shgroup_create(sh, psl->armature_bone_select_ps);
float4 color = {0.0f, 0.0f, 0.0f, alpha};
DRW_shgroup_uniform_vec4_copy(grp, "color", color);
DRW_shgroup_uniform_vec4_copy(grp, "ucolor", color);
pd->armature_bone_select_grp = grp = DRW_shgroup_create(sh, psl->armature_bone_select_ps);
color = {0.0f, 0.0f, 0.0f, powf(alpha, 4)};
DRW_shgroup_uniform_vec4_copy(grp, "color", color);
DRW_shgroup_uniform_vec4_copy(grp, "ucolor", color);
}
for (int i = 0; i < 2; i++) {

View File

@ -89,7 +89,7 @@ void OVERLAY_background_cache_init(OVERLAY_Data *vedata)
GPUShader *sh = OVERLAY_shader_clipbound();
DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->clipping_frustum_ps);
DRW_shgroup_uniform_vec4_copy(grp, "color", G_draw.block.color_clipping_border);
DRW_shgroup_uniform_vec4_copy(grp, "ucolor", G_draw.block.color_clipping_border);
DRW_shgroup_uniform_vec3(grp, "boundbox", &bb->vec[0][0], 8);
struct GPUBatch *cube = DRW_cache_cube_get();

View File

@ -37,7 +37,7 @@ void OVERLAY_edit_text_cache_init(OVERLAY_Data *vedata)
sh = OVERLAY_shader_uniform_color();
pd->edit_text_wire_grp[i] = grp = DRW_shgroup_create(sh, psl->edit_text_wire_ps[i]);
DRW_shgroup_uniform_vec4_copy(grp, "color", G_draw.block.color_wire);
DRW_shgroup_uniform_vec4_copy(grp, "ucolor", G_draw.block.color_wire);
}
{
/* Cursor (text caret). */
@ -45,14 +45,14 @@ void OVERLAY_edit_text_cache_init(OVERLAY_Data *vedata)
DRW_PASS_CREATE(psl->edit_text_cursor_ps, state | pd->clipping_state);
sh = OVERLAY_shader_uniform_color();
pd->edit_text_cursor_grp = grp = DRW_shgroup_create(sh, psl->edit_text_cursor_ps);
DRW_shgroup_uniform_vec4(grp, "color", pd->edit_text.cursor_color, 1);
DRW_shgroup_uniform_vec4(grp, "ucolor", pd->edit_text.cursor_color, 1);
/* Selection boxes. */
state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA;
DRW_PASS_CREATE(psl->edit_text_selection_ps, state | pd->clipping_state);
sh = OVERLAY_shader_uniform_color();
pd->edit_text_selection_grp = grp = DRW_shgroup_create(sh, psl->edit_text_selection_ps);
DRW_shgroup_uniform_vec4(grp, "color", pd->edit_text.selection_color, 1);
DRW_shgroup_uniform_vec4(grp, "ucolor", pd->edit_text.selection_color, 1);
/* Highlight text within selection boxes. */
state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA | DRW_STATE_DEPTH_GREATER_EQUAL |

View File

@ -301,7 +301,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata)
srgb_to_linearrgb_v4(selected_color, selected_color);
DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->edit_uv_tiled_image_borders_ps);
DRW_shgroup_uniform_vec4_copy(grp, "color", theme_color);
DRW_shgroup_uniform_vec4_copy(grp, "ucolor", theme_color);
const float3 offset = {0.0f, 0.0f, 0.0f};
DRW_shgroup_uniform_vec3_copy(grp, "offset", offset);

View File

@ -195,23 +195,23 @@ void OVERLAY_extra_cache_init(OVERLAY_Data *vedata)
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
grp_sub = DRW_shgroup_create_sub(grp);
DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.color_active);
DRW_shgroup_uniform_vec4_copy(grp_sub, "ucolor", G_draw.block.color_active);
cb->center_active = BUF_POINT(grp_sub, format);
grp_sub = DRW_shgroup_create_sub(grp);
DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.color_select);
DRW_shgroup_uniform_vec4_copy(grp_sub, "ucolor", G_draw.block.color_select);
cb->center_selected = BUF_POINT(grp_sub, format);
grp_sub = DRW_shgroup_create_sub(grp);
DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.color_deselect);
DRW_shgroup_uniform_vec4_copy(grp_sub, "ucolor", G_draw.block.color_deselect);
cb->center_deselected = BUF_POINT(grp_sub, format);
grp_sub = DRW_shgroup_create_sub(grp);
DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.color_library_select);
DRW_shgroup_uniform_vec4_copy(grp_sub, "ucolor", G_draw.block.color_library_select);
cb->center_selected_lib = BUF_POINT(grp_sub, format);
grp_sub = DRW_shgroup_create_sub(grp);
DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.color_library);
DRW_shgroup_uniform_vec4_copy(grp_sub, "ucolor", G_draw.block.color_library);
cb->center_deselected_lib = BUF_POINT(grp_sub, format);
}
}

View File

@ -36,7 +36,7 @@ void OVERLAY_fade_cache_init(OVERLAY_Data *vedata)
if (draw_ctx->v3d->shading.background_type == V3D_SHADING_BACKGROUND_THEME) {
srgb_to_linearrgb_v4(color, color);
}
DRW_shgroup_uniform_vec4_copy(pd->fade_grp[i], "color", color);
DRW_shgroup_uniform_vec4_copy(pd->fade_grp[i], "ucolor", color);
}
if (!pd->use_in_front) {

View File

@ -51,6 +51,9 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata)
true;
if (background_enabled) {
grid_flag = GRID_BACK | PLANE_IMAGE;
if (sima->flag & SI_GRID_OVER_IMAGE) {
grid_flag = PLANE_IMAGE;
}
}
const bool draw_grid = is_uv_edit || !ED_space_image_has_buffer(sima);
@ -287,7 +290,7 @@ void OVERLAY_grid_cache_init(OVERLAY_Data *ved)
/* add wire border */
GPUShader *sh = OVERLAY_shader_grid_image();
DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->grid_ps);
DRW_shgroup_uniform_vec4_copy(grp, "color", theme_color);
DRW_shgroup_uniform_vec4_copy(grp, "ucolor", theme_color);
unit_m4(mat);
for (int x = 0; x < grid->size[0]; x++) {
mat[3][0] = x;

View File

@ -349,7 +349,7 @@ void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob)
DRW_shgroup_uniform_bool_copy(grp, "imgAlphaBlend", true);
DRW_shgroup_uniform_bool_copy(grp, "isCameraBackground", true);
DRW_shgroup_uniform_bool_copy(grp, "depthSet", true);
DRW_shgroup_uniform_vec4_copy(grp, "color", color_premult_alpha);
DRW_shgroup_uniform_vec4_copy(grp, "ucolor", color_premult_alpha);
DRW_shgroup_call_obmat(grp, DRW_cache_quad_get(), mat);
}
}
@ -435,7 +435,7 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob)
DRW_shgroup_uniform_bool_copy(grp, "imgAlphaBlend", use_alpha_blend);
DRW_shgroup_uniform_bool_copy(grp, "isCameraBackground", false);
DRW_shgroup_uniform_bool_copy(grp, "depthSet", depth_mode != OB_EMPTY_IMAGE_DEPTH_DEFAULT);
DRW_shgroup_uniform_vec4_copy(grp, "color", ob->color);
DRW_shgroup_uniform_vec4_copy(grp, "ucolor", ob->color);
DRW_shgroup_call_obmat(grp, DRW_cache_quad_get(), mat);
}
}

View File

@ -100,7 +100,7 @@ void OVERLAY_mode_transfer_cache_populate(OVERLAY_Data *vedata, Object *ob)
UI_GetThemeColor3fv(TH_VERTEX_SELECT, color);
color[3] = mode_transfer_alpha_for_animation_time_get(animation_time);
srgb_to_linearrgb_v4(color, color);
DRW_shgroup_uniform_vec4_copy(mode_transfer_grp[i], "color", color);
DRW_shgroup_uniform_vec4_copy(mode_transfer_grp[i], "ucolor", color);
}
if (!pd->use_in_front) {

View File

@ -168,7 +168,7 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata)
sh = OVERLAY_shader_paint_face();
pd->paint_face_grp = grp = DRW_shgroup_create(sh, psl->paint_overlay_ps);
const float4 color = {1.0f, 1.0f, 1.0f, 0.2f};
DRW_shgroup_uniform_vec4_copy(grp, "color", color);
DRW_shgroup_uniform_vec4_copy(grp, "ucolor", color);
DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ALPHA);
sh = OVERLAY_shader_paint_wire();

View File

@ -69,6 +69,11 @@ GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_outline_iface, "geom_in")
.smooth(Type::VEC4, "vColSize")
.flat(Type::INT, "inverted");
GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_outline_no_geom_iface, "")
.flat(Type::VEC4, "finalColor")
.flat(Type::VEC2, "edgeStart")
.no_perspective(Type::VEC2, "edgePos");
GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline)
.do_static_compilation(true)
.vertex_in(0, Type::VEC3, "pos")
@ -84,10 +89,26 @@ GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline)
.fragment_source("overlay_armature_wire_frag.glsl")
.additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals");
GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline_no_geom)
.do_static_compilation(true)
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::VEC3, "snor")
/* Per instance. */
.vertex_in(2, Type::VEC4, "color")
.vertex_in(3, Type::MAT4, "inst_obmat")
.vertex_out(overlay_armature_shape_outline_no_geom_iface)
.vertex_source("overlay_armature_shape_outline_vert_no_geom.glsl")
.fragment_source("overlay_armature_wire_frag.glsl")
.additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals");
GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline_clipped)
.do_static_compilation(true)
.additional_info("overlay_armature_shape_outline", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline_clipped_no_geom)
.do_static_compilation(true)
.additional_info("overlay_armature_shape_outline_no_geom", "drw_clipped");
GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_solid_iface, "")
.smooth(Type::VEC4, "finalColor")
.flat(Type::INT, "inverted");

View File

@ -15,7 +15,7 @@ GPU_SHADER_CREATE_INFO(overlay_background)
GPU_SHADER_CREATE_INFO(overlay_clipbound)
.do_static_compilation(true)
.push_constant(Type::VEC4, "color")
.push_constant(Type::VEC4, "ucolor")
.push_constant(Type::VEC3, "boundbox", 8)
.vertex_source("overlay_clipbound_vert.glsl")
.fragment_out(0, Type::VEC4, "fragColor")

View File

@ -22,6 +22,17 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_common)
.vertex_source("overlay_edit_mesh_vert.glsl")
.additional_info("draw_modelmat", "draw_globals");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_common_no_geom)
.define("blender_srgb_to_framebuffer_space(a)", "a")
.sampler(0, ImageType::DEPTH_2D, "depthTex")
.fragment_out(0, Type::VEC4, "fragColor")
.push_constant(Type::BOOL, "selectFaces")
.push_constant(Type::BOOL, "selectEdges")
.push_constant(Type::FLOAT, "alpha")
.push_constant(Type::IVEC4, "dataMask")
.vertex_source("overlay_edit_mesh_vert_no_geom.glsl")
.additional_info("draw_modelmat", "draw_globals");
GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_vert_iface, "")
.smooth(Type::VEC4, "finalColor")
.smooth(Type::FLOAT, "vertexCrease");
@ -61,11 +72,28 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge)
.fragment_source("overlay_edit_mesh_frag.glsl")
.additional_info("overlay_edit_mesh_common");
/* The Non-Geometry shader variant passes directly to fragment. */
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_no_geom)
.do_static_compilation(true)
.define("EDGE")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::UCHAR4, "data")
.vertex_in(2, Type::VEC3_101010I2, "vnor")
.push_constant(Type::BOOL, "do_smooth_wire")
.vertex_out(overlay_edit_mesh_edge_geom_iface)
.fragment_source("overlay_edit_mesh_frag.glsl")
.additional_info("overlay_edit_mesh_common_no_geom");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat)
.do_static_compilation(true)
.define("FLAT")
.additional_info("overlay_edit_mesh_edge");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat_no_geom)
.do_static_compilation(true)
.define("FLAT")
.additional_info("overlay_edit_mesh_edge_no_geom");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face)
.do_static_compilation(true)
.define("FACE")
@ -136,10 +164,18 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_clipped)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_edge", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_clipped_no_geom)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_edge_no_geom", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat_clipped)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_edge_flat", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat_clipped_no_geom)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_edge_flat_no_geom", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face_clipped)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_face", "drw_clipped");
@ -242,7 +278,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_uv_verts)
GPU_SHADER_CREATE_INFO(overlay_edit_uv_tiled_image_borders)
.do_static_compilation(true)
.vertex_in(0, Type::VEC3, "pos")
.push_constant(Type::VEC4, "color")
.push_constant(Type::VEC4, "ucolor")
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("overlay_edit_uv_tiled_image_borders_vert.glsl")
.fragment_source("overlay_uniform_color_frag.glsl")
@ -258,7 +294,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_uv_stencil_image)
.sampler(0, ImageType::FLOAT_2D, "imgTexture")
.push_constant(Type::BOOL, "imgPremultiplied")
.push_constant(Type::BOOL, "imgAlphaBlend")
.push_constant(Type::VEC4, "color")
.push_constant(Type::VEC4, "ucolor")
.fragment_out(0, Type::VEC4, "fragColor")
.fragment_source("overlay_image_frag.glsl")
.additional_info("draw_mesh");
@ -326,10 +362,29 @@ GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle)
.fragment_source("overlay_varying_color.glsl")
.additional_info("draw_mesh", "draw_globals");
GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_no_geom)
.do_static_compilation(true)
.typedef_source("overlay_shader_shared.h")
/* NOTE: Color already in Linear space. Which is what we want. */
.define("srgbTarget", "false")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::INT, "data")
.vertex_out(overlay_edit_curve_handle_iface)
.push_constant(Type::BOOL, "showCurveHandles")
.push_constant(Type::INT, "curveHandleDisplay")
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("overlay_edit_curve_handle_vert_no_geom.glsl")
.fragment_source("overlay_varying_color.glsl")
.additional_info("draw_mesh", "draw_globals");
GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_clipped)
.do_static_compilation(true)
.additional_info("overlay_edit_curve_handle", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_clipped_no_geom)
.do_static_compilation(true)
.additional_info("overlay_edit_curve_handle_no_geom", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_curve_point)
.do_static_compilation(true)
.typedef_source("overlay_shader_shared.h")
@ -526,7 +581,7 @@ GPU_SHADER_CREATE_INFO(overlay_depth_only_clipped)
GPU_SHADER_CREATE_INFO(overlay_uniform_color)
.do_static_compilation(true)
.vertex_in(0, Type::VEC3, "pos")
.push_constant(Type::VEC4, "color")
.push_constant(Type::VEC4, "ucolor")
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("overlay_depth_only_vert.glsl")
.fragment_source("overlay_uniform_color_frag.glsl")

View File

@ -145,7 +145,7 @@ GPU_SHADER_CREATE_INFO(overlay_extra_point)
/* TODO(fclem): Move the vertex shader to Overlay engine and remove this bypass. */
.define("blender_srgb_to_framebuffer_space(a)", "a")
.vertex_in(0, Type::VEC3, "pos")
.push_constant(Type::VEC4, "color")
.push_constant(Type::VEC4, "ucolor")
.vertex_out(overlay_extra_point_iface)
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("overlay_extra_point_vert.glsl")
@ -161,7 +161,7 @@ GPU_SHADER_INTERFACE_INFO(overlay_extra_loose_point_iface, "").smooth(Type::VEC4
GPU_SHADER_CREATE_INFO(overlay_extra_loose_point)
.do_static_compilation(true)
.vertex_in(0, Type::VEC3, "pos")
.push_constant(Type::VEC4, "color")
.push_constant(Type::VEC4, "ucolor")
.vertex_out(overlay_extra_loose_point_iface)
.fragment_out(0, Type::VEC4, "fragColor")
.fragment_out(1, Type::VEC4, "lineOutput")
@ -183,6 +183,9 @@ GPU_SHADER_INTERFACE_INFO(overlay_motion_path_line_iface, "interp")
.flat(Type::VEC2, "ss_pos")
.smooth(Type::VEC4, "color");
GPU_SHADER_INTERFACE_INFO(overlay_motion_path_line_no_geom_iface, "interp")
.smooth(Type::VEC4, "color");
GPU_SHADER_CREATE_INFO(overlay_motion_path_line)
.do_static_compilation(true)
.vertex_in(0, Type::VEC3, "pos")
@ -199,10 +202,27 @@ GPU_SHADER_CREATE_INFO(overlay_motion_path_line)
.fragment_source("overlay_motion_path_line_frag.glsl")
.additional_info("draw_view", "draw_globals");
GPU_SHADER_CREATE_INFO(overlay_motion_path_line_no_geom)
.do_static_compilation(true)
.vertex_in(0, Type::VEC3, "pos")
.push_constant(Type::IVEC4, "mpathLineSettings")
.push_constant(Type::BOOL, "selected")
.push_constant(Type::VEC3, "customColor")
.push_constant(Type::INT, "lineThickness") /* In pixels. */
.vertex_out(overlay_motion_path_line_no_geom_iface)
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("overlay_motion_path_line_vert_no_geom.glsl")
.fragment_source("overlay_motion_path_line_frag.glsl")
.additional_info("draw_view", "draw_globals");
GPU_SHADER_CREATE_INFO(overlay_motion_path_line_clipped)
.do_static_compilation(true)
.additional_info("overlay_motion_path_line", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_motion_path_line_clipped_no_geom)
.do_static_compilation(true)
.additional_info("overlay_motion_path_line_no_geom", "drw_clipped");
GPU_SHADER_INTERFACE_INFO(overlay_motion_path_point_iface, "").flat(Type::VEC4, "finalColor");
GPU_SHADER_CREATE_INFO(overlay_motion_path_point)
@ -237,7 +257,7 @@ GPU_SHADER_CREATE_INFO(overlay_image)
.push_constant(Type::BOOL, "isCameraBackground")
.push_constant(Type::BOOL, "imgPremultiplied")
.push_constant(Type::BOOL, "imgAlphaBlend")
.push_constant(Type::VEC4, "color")
.push_constant(Type::VEC4, "ucolor")
.vertex_in(0, Type::VEC3, "pos")
.vertex_out(overlay_image_iface)
.sampler(0, ImageType::FLOAT_2D, "imgTexture")
@ -284,7 +304,7 @@ GPU_SHADER_INTERFACE_INFO(overlay_particle_iface, "").flat(Type::VEC4, "finalCol
GPU_SHADER_CREATE_INFO(overlay_particle)
.sampler(0, ImageType::FLOAT_1D, "weightTex")
.push_constant(Type::VEC4, "color") /* Draw-size packed in alpha. */
.push_constant(Type::VEC4, "ucolor") /* Draw-size packed in alpha. */
.vertex_in(0, Type::VEC3, "part_pos")
.vertex_in(1, Type::VEC4, "part_rot")
.vertex_in(2, Type::FLOAT, "part_val")

Some files were not shown because too many files have changed in this diff Show More