diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-06-26 17:07:39 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-06-26 17:07:39 +0300 |
commit | fbaf6e6fb3d2eb2f0c737b7d4713a5ea171738e6 (patch) | |
tree | 35bfa54eef6240693a13d594bb49ed7c8d33b32e | |
parent | bba0ad903cfa407368c78b0b8480b1a729474305 (diff) | |
parent | c07f2bc89196ea449a2875634eb85efa45733fb5 (diff) |
Merge remote-tracking branch 'origin/blender2.8' into temp-dynamic-overridestemp-dynamic-overrides
427 files changed, 7864 insertions, 4579 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 06d31e0e143..6c13703116c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -806,7 +806,8 @@ set(C_WARNINGS) set(CXX_WARNINGS) # for gcc -Wno-blah-blah -set(CC_REMOVE_STRICT_FLAGS) +set(C_REMOVE_STRICT_FLAGS) +set(CXX_REMOVE_STRICT_FLAGS) # libraries to link the binary with passed to target_link_libraries() # known as LLIBS to scons @@ -1415,16 +1416,22 @@ if(CMAKE_COMPILER_IS_GNUCC) endif() # flags to undo strict flags - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function) + 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_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CLASS_MEMACCESS -Wno-class-memaccess) if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0")) - ADD_CHECK_C_COMPILER_FLAG(CC_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(CC_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") @@ -1453,23 +1460,23 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") # ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_MACROS -Wunused-macros) # flags to undo strict flags - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS -Wno-unused-macros) - - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNDEF -Wno-undef) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn) - - ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field) - ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing) - ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor) - ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros) - ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_REORDER -Wno-reorder) + 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_MACROS -Wno-unused-macros) + + 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_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_REORDER -Wno-reorder) elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 8cf90d0d22c..ce2241a775d 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -1054,13 +1054,19 @@ macro(remove_cc_flag endmacro() -macro(add_cc_flag +macro(add_c_flag flag) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") endmacro() +macro(add_cxx_flag + flag) + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +endmacro() + macro(remove_strict_flags) if(CMAKE_COMPILER_IS_GNUCC) @@ -1083,7 +1089,8 @@ macro(remove_strict_flags) ) # negate flags implied by '-Wall' - add_cc_flag("${CC_REMOVE_STRICT_FLAGS}") + add_c_flag("${C_REMOVE_STRICT_FLAGS}") + add_cxx_flag("${CXX_REMOVE_STRICT_FLAGS}") endif() if(CMAKE_C_COMPILER_ID MATCHES "Clang") @@ -1095,7 +1102,8 @@ macro(remove_strict_flags) ) # negate flags implied by '-Wall' - add_cc_flag("${CC_REMOVE_STRICT_FLAGS}") + add_c_flag("${C_REMOVE_STRICT_FLAGS}") + add_cxx_flag("${CXX_REMOVE_STRICT_FLAGS}") endif() if(MSVC) @@ -1125,28 +1133,39 @@ endmacro() # note, we can only append flags on a single file so we need to negate the options. # at the moment we cant shut up ffmpeg deprecations, so use this, but will # probably add more removals here. -macro(remove_strict_flags_file +macro(remove_strict_c_flags_file filenames) - foreach(_SOURCE ${ARGV}) - if(CMAKE_COMPILER_IS_GNUCC OR - (CMAKE_C_COMPILER_ID MATCHES "Clang")) - + (CMAKE_C_COMPILER_ID MATCHES "Clang")) set_source_files_properties(${_SOURCE} PROPERTIES - COMPILE_FLAGS "${CC_REMOVE_STRICT_FLAGS}" + COMPILE_FLAGS "${C_REMOVE_STRICT_FLAGS}" ) endif() - if(MSVC) # TODO endif() - endforeach() - unset(_SOURCE) +endmacro() +macro(remove_strict_cxx_flags_file + filenames) + remove_strict_c_flags_file(${filenames} ${ARHV}) + foreach(_SOURCE ${ARGV}) + if(CMAKE_COMPILER_IS_GNUCC OR + (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) + set_source_files_properties(${_SOURCE} + PROPERTIES + COMPILE_FLAGS "${CXX_REMOVE_STRICT_FLAGS}" + ) + endif() + if(MSVC) + # TODO + endif() + endforeach() + unset(_SOURCE) endmacro() # External libs may need 'signed char' to be default. diff --git a/extern/xdnd/xdnd.c b/extern/xdnd/xdnd.c index 50d1fec4969..e8c51377e27 100644 --- a/extern/xdnd/xdnd.c +++ b/extern/xdnd/xdnd.c @@ -121,10 +121,10 @@ char *xdnd_debug_milliseconds (void) #define dnd_debug3(a,b,c) printf("%s: %d: %s: " a "\n", __FILE__, __LINE__, xdnd_debug_milliseconds (), b, c) #define dnd_debug4(a,b,c,d) printf("%s: %d: %s: " a "\n", __FILE__, __LINE__, xdnd_debug_milliseconds (), b, c, d) #else -#define dnd_debug1(a) -#define dnd_debug2(a,b) -#define dnd_debug3(a,b,c) -#define dnd_debug4(a,b,c,d) +#define dnd_debug1(a) do {} while (0) +#define dnd_debug2(a,b) do {} while (0) +#define dnd_debug3(a,b,c) do {} while (0) +#define dnd_debug4(a,b,c,d) do {} while (0) #endif #define dnd_warning(a) fprintf (stderr, a) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 2f9c486367a..0aac43e6969 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -193,7 +193,7 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel): row = layout.row(align=True) row.prop(cscene, "seed") - row.prop(cscene, "use_animated_seed", text="", icon="TIME") + row.prop(cscene, "use_animated_seed", text="", icon='TIME') layout.prop(cscene, "sampling_pattern", text="Pattern") @@ -1545,6 +1545,7 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel): def draw(self, context): layout = self.layout layout.use_property_split = True + layout.use_property_decorate = False # No animation.
scene = context.scene cscene = scene.cycles @@ -1573,7 +1574,7 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel): if cscene.bake_type == 'NORMAL': col.prop(cbk, "normal_space", text="Space") - sub = col.row(align=True) + sub = col.column(align=True)
sub.prop(cbk, "normal_r", text="Swizzle R") sub.prop(cbk, "normal_g", text="G") sub.prop(cbk, "normal_b", text="B") @@ -1595,6 +1596,7 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel): elif cscene.bake_type in {'DIFFUSE', 'GLOSSY', 'TRANSMISSION', 'SUBSURFACE'}: row = col.row(align=True) + row.use_property_split = False
row.prop(cbk, "use_pass_direct", toggle=True) row.prop(cbk, "use_pass_indirect", toggle=True) row.prop(cbk, "use_pass_color", toggle=True) @@ -1613,10 +1615,12 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel): sub.prop(cbk, "use_cage", text="Cage") if cbk.use_cage: sub.prop(cbk, "cage_extrusion", text="Extrusion") - sub.prop_search(cbk, "cage_object", scene, "objects", text="") + sub.prop_search(cbk, "cage_object", scene, "objects", text="Cage Object")
else: sub.prop(cbk, "cage_extrusion", text="Ray Distance") + layout.separator()
+
layout.operator("object.bake", icon='RENDER_STILL').type = cscene.bake_type @@ -1783,7 +1787,7 @@ def draw_pause(self, context): if view.shading.type == 'RENDERED': cscene = scene.cycles - layout.prop(cscene, "preview_pause", icon="PAUSE", text="") + layout.prop(cscene, "preview_pause", icon='PAUSE', text="") def get_panels(): diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py index d3948f8fbb5..3334ccd65fd 100644 --- a/intern/cycles/blender/addon/version_update.py +++ b/intern/cycles/blender/addon/version_update.py @@ -481,7 +481,7 @@ def do_versions(self): cworld = world.cycles # World MIS if not cworld.is_property_set("sampling_method"): - if cworld.get("sample_as_light", False): + if cworld.get("sample_as_light", True): cworld.sampling_method = 'MANUAL' else: cworld.sampling_method = 'NONE' diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index eec13d04d7d..cd55155e33b 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -54,6 +54,7 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine, BL::BlendData& b_data, bool preview_osl) : session(NULL), + sync(NULL), b_engine(b_engine), b_userpref(b_userpref), b_data(b_data), @@ -81,6 +82,7 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine, BL::RegionView3D& b_rv3d, int width, int height) : session(NULL), + sync(NULL), b_engine(b_engine), b_userpref(b_userpref), b_data(b_data), @@ -209,11 +211,8 @@ void BlenderSession::reset_session(BL::BlendData& b_data, BL::Depsgraph& b_depsg /* if scene or session parameters changed, it's easier to simply re-create * them rather than trying to distinguish which settings need to be updated */ - - delete session; - + free_session(); create_session(); - return; } @@ -449,11 +448,11 @@ void BlenderSession::render(BL::Depsgraph& b_depsgraph_) BL::Object b_camera_override(b_engine.camera_override()); sync->sync_camera(b_render, b_camera_override, width, height, b_rview_name.c_str()); sync->sync_data(b_render, - b_depsgraph, - b_v3d, - b_camera_override, - width, height, - &python_thread_state); + b_depsgraph, + b_v3d, + b_camera_override, + width, height, + &python_thread_state); builtin_images_load(); /* Make sure all views have different noise patterns. - hardcoded value just to make it random */ @@ -610,11 +609,11 @@ void BlenderSession::bake(BL::Depsgraph& b_depsgraph_, BL::Object b_camera_override(b_engine.camera_override()); sync->sync_camera(b_render, b_camera_override, width, height, ""); sync->sync_data(b_render, - b_depsgraph, - b_v3d, - b_camera_override, - width, height, - &python_thread_state); + b_depsgraph, + b_v3d, + b_camera_override, + width, height, + &python_thread_state); builtin_images_load(); } diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 0c27786f241..80aa68d9756 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -177,7 +177,7 @@ void BlenderSync::sync_recalc(BL::Depsgraph& b_depsgraph) } void BlenderSync::sync_data(BL::RenderSettings& b_render, - BL::Depsgraph& b_depsgraph, + BL::Depsgraph& b_depsgraph, BL::SpaceView3D& b_v3d, BL::Object& b_override, int width, int height, diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 6be60f8bbb6..3b0d0fb9806 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -21,7 +21,10 @@ #ifdef WITH_OSL /* So no context pollution happens from indirectly included windows.h */ # include "util/util_windows.h" +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-register" # include <OSL/oslexec.h> +# pragma clang diagnostic pop #endif #include "device/device.h" diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 3ba5a8de8ff..656ad07d657 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -385,7 +385,7 @@ public: VLOG(1) << "Found nvcc " << nvcc << ", CUDA version " << cuda_version << "."; - const int major = cuda_version / 10, minor = cuda_version & 10; + const int major = cuda_version / 10, minor = cuda_version % 10; if(cuda_version == 0) { cuda_error_message("CUDA nvcc compiler version could not be parsed."); return false; diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h index d8ff69ca241..c1b02cd4be1 100644 --- a/intern/cycles/kernel/closure/bsdf.h +++ b/intern/cycles/kernel/closure/bsdf.h @@ -72,15 +72,15 @@ ccl_device_inline float bsdf_get_roughness_squared(const ShaderClosure *sc) return bsdf_get_specular_roughness_squared(sc); } -ccl_device_forceinline int bsdf_sample(KernelGlobals *kg, - ShaderData *sd, - const ShaderClosure *sc, - float randu, - float randv, - float3 *eval, - float3 *omega_in, - differential3 *domega_in, - float *pdf) +ccl_device_inline int bsdf_sample(KernelGlobals *kg, + ShaderData *sd, + const ShaderClosure *sc, + float randu, + float randv, + float3 *eval, + float3 *omega_in, + differential3 *domega_in, + float *pdf) { int label; @@ -210,7 +210,7 @@ ccl_device_forceinline int bsdf_sample(KernelGlobals *kg, #ifndef __KERNEL_CUDA__ ccl_device #else -ccl_device_forceinline +ccl_device_inline #endif float3 bsdf_eval(KernelGlobals *kg, ShaderData *sd, diff --git a/intern/cycles/kernel/osl/osl_closures.cpp b/intern/cycles/kernel/osl/osl_closures.cpp index 6a1e52d7d16..e928006e41a 100644 --- a/intern/cycles/kernel/osl/osl_closures.cpp +++ b/intern/cycles/kernel/osl/osl_closures.cpp @@ -30,8 +30,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-register" +#pragma clang diagnostic ignored "-Wexpansion-to-defined" #include <OSL/genclosure.h> #include <OSL/oslclosure.h> +#pragma clang diagnostic pop #include "kernel/osl/osl_closures.h" #include "kernel/osl/osl_shader.h" diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp index b7d1c629291..8757b9a748b 100644 --- a/intern/cycles/kernel/osl/osl_shader.cpp +++ b/intern/cycles/kernel/osl/osl_shader.cpp @@ -14,7 +14,10 @@ * limitations under the License. */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-register" #include <OSL/oslexec.h> +#pragma clang diagnostic pop #include "kernel/kernel_compat_cpu.h" #include "kernel/kernel_montecarlo.h" diff --git a/intern/cycles/kernel/shaders/node_ambient_occlusion.osl b/intern/cycles/kernel/shaders/node_ambient_occlusion.osl index d7ffa3c1606..865ad4c9fb9 100644 --- a/intern/cycles/kernel/shaders/node_ambient_occlusion.osl +++ b/intern/cycles/kernel/shaders/node_ambient_occlusion.osl @@ -17,13 +17,13 @@ #include "stdosl.h" shader node_ambient_occlusion( - color ColorIn = color(0.8, 0.8, 0.8), + color ColorIn = color(1.0, 1.0, 1.0), int samples = 8, float Distance = 1.0, normal Normal = N, int inside = 0, int only_local = 1, - output color ColorOut = color(0.8, 0.8, 0.8), + output color ColorOut = color(1.0, 1.0, 1.0), output float AO = 1.0) { int global_radius = (Distance == 0.0 && !isconnected(Distance)); diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h index 10d5fe0e42b..2bee4bc7b69 100644 --- a/intern/cycles/kernel/svm/svm.h +++ b/intern/cycles/kernel/svm/svm.h @@ -144,7 +144,6 @@ CCL_NAMESPACE_END #include "kernel/svm/svm_color_util.h" #include "kernel/svm/svm_math_util.h" -#include "kernel/svm/svm_ao.h" #include "kernel/svm/svm_attribute.h" #include "kernel/svm/svm_gradient.h" #include "kernel/svm/svm_blackbody.h" @@ -185,6 +184,7 @@ CCL_NAMESPACE_END #include "kernel/svm/svm_bump.h" #ifdef __SHADER_RAYTRACE__ +# include "kernel/svm/svm_ao.h" # include "kernel/svm/svm_bevel.h" #endif diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 5a58ef1aa8e..94072d7da09 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -587,7 +587,7 @@ void LightManager::device_update_background(Device *device, double time_start = time_dt(); if(max(res.x, res.y) < 512) { /* Small enough resolution, faster to do single-threaded. */ - background_cdf(0, res.x, res.x, res.y, &pixels, cond_cdf); + background_cdf(0, res.y, res.x, res.y, &pixels, cond_cdf); } else { /* Threaded evaluation for large resolution. */ diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 59ac6257499..ea25056e9fd 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -2794,7 +2794,7 @@ NODE_DEFINE(AmbientOcclusionNode) SOCKET_INT(samples, "Samples", 8); - SOCKET_IN_COLOR(color, "Color", make_float3(0.8f, 0.8f, 0.8f)); + SOCKET_IN_COLOR(color, "Color", make_float3(1.0f, 1.0f, 1.0f)); SOCKET_IN_FLOAT(distance, "Distance", 1.0f); SOCKET_IN_NORMAL(normal, "Normal", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL); diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h index d787c3b266b..87bc3ddda28 100644 --- a/intern/cycles/render/shader.h +++ b/intern/cycles/render/shader.h @@ -20,7 +20,10 @@ #ifdef WITH_OSL /* So no context pollution happens from indirectly included windows.h */ # include "util/util_windows.h" +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-register" # include <OSL/oslexec.h> +# pragma clang diagnostic pop #endif #include "render/attribute.h" diff --git a/intern/cycles/util/util_image.h b/intern/cycles/util/util_image.h index 18876841b5b..38694c87d0e 100644 --- a/intern/cycles/util/util_image.h +++ b/intern/cycles/util/util_image.h @@ -19,7 +19,11 @@ /* OpenImageIO is used for all image file reading and writing. */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-register" +#pragma clang diagnostic ignored "-Wexpansion-to-defined" #include <OpenImageIO/imageio.h> +#pragma clang diagnostic pop #include "util/util_vector.h" diff --git a/intern/cycles/util/util_param.h b/intern/cycles/util/util_param.h index 69bcbf80a78..419a8010d5a 100644 --- a/intern/cycles/util/util_param.h +++ b/intern/cycles/util/util_param.h @@ -20,9 +20,13 @@ /* Parameter value lists from OpenImageIO are used to store custom properties * on various data, which can then later be used in shaders. */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-register" +#pragma clang diagnostic ignored "-Wexpansion-to-defined" #include <OpenImageIO/paramlist.h> #include <OpenImageIO/typedesc.h> #include <OpenImageIO/ustring.h> +#pragma clang diagnostic pop CCL_NAMESPACE_BEGIN diff --git a/intern/eigen/intern/matrix.cc b/intern/eigen/intern/matrix.cc index 5e00540f27c..bcd5273fd74 100644 --- a/intern/eigen/intern/matrix.cc +++ b/intern/eigen/intern/matrix.cc @@ -48,6 +48,9 @@ bool EIG_invert_m4_m4(float inverse[4][4], const float matrix[4][4]) Matrix4f R; bool invertible = true; M.computeInverseWithCheck(R, invertible, 0.0f); + if (!invertible) { + R = R.Zero(); + } memcpy(inverse, R.data(), sizeof(float)*4*4); return invertible; } diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index b97bf1d089c..17c41e96be4 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -325,7 +325,8 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext() ); HDC mHDC = GetDC(wnd); - + HDC prev_hdc = wglGetCurrentDC(); + HGLRC prev_context = wglGetCurrentContext(); #if defined(WITH_GL_PROFILE_CORE) for (int minor = 5; minor >= 0; --minor) { context = new GHOST_ContextWGL( @@ -337,7 +338,7 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext() GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY); if (context->initializeDrawingContext()) { - return context; + goto finished; } else { delete context; @@ -353,7 +354,7 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext() GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY); if (context->initializeDrawingContext()) { - return context; + goto finished; } else { MessageBox( @@ -386,8 +387,9 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext() #else # error // must specify either core or compat at build time #endif - - return NULL; +finished: + wglMakeCurrent(prev_hdc, prev_context); + return context; } /** diff --git a/release/datafiles/blender_icons.svg b/release/datafiles/blender_icons.svg index d389831e668..fe4e2015e79 100644 --- a/release/datafiles/blender_icons.svg +++ b/release/datafiles/blender_icons.svg @@ -31919,6 +31919,108 @@ y1="199.12067" x2="17.16466" y2="211.01585" /> + <mask + maskUnits="userSpaceOnUse" + id="mask25369-1"> + <g + id="g25371-3" + transform="translate(-21,-21)"> + <path + inkscape:connector-curvature="0" + style="fill:url(#linearGradient25381);fill-rule:evenodd;stroke:none" + d="m 341,302 8,8 -8,8 z" + id="path25373-1" + sodipodi:nodetypes="cccc" + inkscape:transform-center-x="4" /> + <path + inkscape:connector-curvature="0" + inkscape:transform-center-y="-4" + sodipodi:nodetypes="cccc" + id="path25375-1" + d="m 357,302 -8,8 -8,-8 z" + style="fill:url(#linearGradient25383-9);fill-rule:evenodd;stroke:none" /> + <path + inkscape:connector-curvature="0" + inkscape:transform-center-x="-4" + sodipodi:nodetypes="cccc" + id="path25377-0" + d="m 357,318 -8,-8 8,-8 z" + style="fill:url(#linearGradient25385-1);fill-rule:evenodd;stroke:none" /> + <path + inkscape:connector-curvature="0" + inkscape:transform-center-y="4" + sodipodi:nodetypes="cccc" + id="path25379-3" + d="m 341,318 8,-8 8,8 z" + style="fill:url(#linearGradient25387-9);fill-rule:evenodd;stroke:none" /> + </g> + </mask> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient16595" + id="linearGradient25383-9" + gradientUnits="userSpaceOnUse" + gradientTransform="rotate(90,339,299)" + x1="342" + y1="288.5" + x2="344.5" + y2="288.5" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient16595" + id="linearGradient25385-1" + gradientUnits="userSpaceOnUse" + gradientTransform="rotate(180,349.5,299.5)" + x1="342" + y1="288.5" + x2="344.5" + y2="288.5" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient16595" + id="linearGradient25387-9" + gradientUnits="userSpaceOnUse" + gradientTransform="rotate(-90,360,300)" + x1="342" + y1="288.5" + x2="344.5" + y2="288.5" /> + <mask + maskUnits="userSpaceOnUse" + id="mask25369-1-6"> + <g + id="g25371-3-4" + transform="translate(-21,-21)"> + <path + inkscape:connector-curvature="0" + style="fill:url(#linearGradient25381);fill-rule:evenodd;stroke:none" + d="m 341,302 8,8 -8,8 z" + id="path25373-1-0" + sodipodi:nodetypes="cccc" + inkscape:transform-center-x="4" /> + <path + inkscape:connector-curvature="0" + inkscape:transform-center-y="-4" + sodipodi:nodetypes="cccc" + id="path25375-1-0" + d="m 357,302 -8,8 -8,-8 z" + style="fill:url(#linearGradient25383-9);fill-rule:evenodd;stroke:none" /> + <path + inkscape:connector-curvature="0" + inkscape:transform-center-x="-4" + sodipodi:nodetypes="cccc" + id="path25377-0-4" + d="m 357,318 -8,-8 8,-8 z" + style="fill:url(#linearGradient25385-1);fill-rule:evenodd;stroke:none" /> + <path + inkscape:connector-curvature="0" + inkscape:transform-center-y="4" + sodipodi:nodetypes="cccc" + id="path25379-3-6" + d="m 341,318 8,-8 8,8 z" + style="fill:url(#linearGradient25387-9);fill-rule:evenodd;stroke:none" /> + </g> + </mask> </defs> <sodipodi:namedview id="base" @@ -92721,6 +92823,229 @@ sodipodi:nodetypes="ccccccc" /> </g> </g> + <g + style="display:inline;enable-background:new" + transform="translate(168.01766,170.03707)" + id="ICON_GRID-3" + mask="url(#mask25369-1)"> + <rect + y="281" + x="320" + height="16" + width="16" + id="rect36193-3" + style="display:inline;overflow:visible;visibility:visible;opacity:0.01000001;fill:#cccccc;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.70000005;marker:none;enable-background:accumulate" /> + <path + sodipodi:nodetypes="cccc" + d="m 324.5,295.75 v -13.5 m 7,13.5 v -13.5" + style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path36195-8" + inkscape:connector-curvature="0" /> + <path + id="path36197-0" + style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 321.25001,285.50001 334.75,285.5 M 321.25001,292.50001 334.75,292.5" + sodipodi:nodetypes="cccc" + inkscape:connector-curvature="0" /> + <path + id="path36199-5" + style="fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 324.5,296.5 v -14.99999 m 7,14.99999 v -14.99999" + sodipodi:nodetypes="cccc" + inkscape:connector-curvature="0" /> + <path + sodipodi:nodetypes="cccc" + d="m 320.5,285.50001 h 15 m -15,6.99999 h 15" + style="fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path36201-6" + inkscape:connector-curvature="0" /> + </g> + <g + style="display:inline;enable-background:new;opacity:0.25" + transform="translate(188.9552,170.08067)" + id="ICON_GRID-3-7" + mask="url(#mask25369-1-6)"> + <rect + y="281" + x="320" + height="16" + width="16" + id="rect36193-3-2" + style="display:inline;overflow:visible;visibility:visible;opacity:0.01000001;fill:#cccccc;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.70000005;marker:none;enable-background:accumulate" /> + <path + sodipodi:nodetypes="cccc" + d="m 324.5,295.75 v -13.5 m 7,13.5 v -13.5" + style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path36195-8-8" + inkscape:connector-curvature="0" /> + <path + id="path36197-0-2" + style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 321.25001,285.50001 334.75,285.5 M 321.25001,292.50001 334.75,292.5" + sodipodi:nodetypes="cccc" + inkscape:connector-curvature="0" /> + <path + id="path36199-5-9" + style="fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 324.5,296.5 v -14.99999 m 7,14.99999 v -14.99999" + sodipodi:nodetypes="cccc" + inkscape:connector-curvature="0" /> + <path + sodipodi:nodetypes="cccc" + d="m 320.5,285.50001 h 15 m -15,6.99999 h 15" + style="fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path36201-6-9" + inkscape:connector-curvature="0" /> + </g> + <g + transform="translate(-564,-55.99997)" + id="g10320" + style="display:inline;enable-background:new"> + <rect + style="opacity:0;vector-effect:none;fill:#d40000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" + id="rect10310" + width="15.999999" + height="15.999999" + x="-669" + y="506.99997" + transform="scale(-1,1)" /> + <path + transform="scale(-1,1)" + style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" + d="m -655.5,515.49997 v 4.0165 c 0,1.65287 -1.33066,2.98353 -2.98353,2.98353 h -4.03294 c -1.65287,0 -2.98353,-1.33066 -2.98353,-2.98353 v -9.03297 c 0,-1.65287 1.33066,-2.98353 2.98353,-2.98353 H -660.5" + id="rect10312" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cssssssc" /> + <g + id="g10318" + transform="translate(-20)" /> + <path + style="display:inline;opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:new" + d="m 658.5,507.49997 h -0.0165 c -1.65287,0 -2.98353,1.33066 -2.98353,2.98353 v 3.01647 l 3.00824,0.008 z" + id="rect10312-0" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cssccc" /> + </g> + <g + style="display:inline;enable-background:new" + id="g10350"> + <rect + y="451.5" + x="152.5" + height="15" + width="10" + id="rect10334" + style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" + rx="3.0625" + ry="3.0625" /> + <g + id="g10338" + transform="translate(-523,-55.999969)"> + <path + sodipodi:nodetypes="cc" + inkscape:connector-curvature="0" + d="m 680.5,513.49997 -0.01,-4.03235" + style="opacity:0.6;vector-effect:none;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" + id="path10336" /> + </g> + <path + sodipodi:nodetypes="cc" + inkscape:connector-curvature="0" + id="path10340" + d="M 165.5,459.5 V 455" + style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" /> + <path + sodipodi:open="true" + d="M 164.50114,451.52593 A 9.3798456,5.5 0 0 1 165.50372,454" + sodipodi:end="0" + sodipodi:start="5.8166094" + sodipodi:ry="5.5" + sodipodi:rx="9.3798456" + sodipodi:cy="454" + sodipodi:cx="156.12387" + sodipodi:type="arc" + id="path10342" + style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:fill markers stroke" /> + <path + style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" + d="m 167.50001,457.60147 v -4.05761" + id="path10344" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cc" /> + <path + style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" + d="M 165.5,459.5 V 454" + id="path10346" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cc" /> + <path + sodipodi:nodetypes="cc" + inkscape:connector-curvature="0" + id="path10348" + d="m 167.50001,457.60147 v -4.05761" + style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" /> + </g> + <g + style="display:inline;enable-background:new" + id="g10432" + transform="translate(-522,-55.99997)"> + <rect + transform="scale(-1,1)" + y="506.99997" + x="-669" + height="15.999999" + width="15.999999" + id="rect10424" + style="opacity:0;vector-effect:none;fill:#d40000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" /> + <path + sodipodi:nodetypes="cssssssc" + inkscape:connector-curvature="0" + id="path10426" + d="m 665.49995,515.49997 v 4.0165 c 0,1.65287 -1.33066,2.98353 -2.98353,2.98353 h -4.03294 c -1.65287,0 -2.98353,-1.33066 -2.98353,-2.98353 v -9.03297 c 0,-1.65287 1.33066,-2.98353 2.98353,-2.98353 h 2.01647" + style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" /> + <g + transform="translate(-20)" + id="g10428" /> + <path + sodipodi:nodetypes="cssccc" + inkscape:connector-curvature="0" + id="path10430" + d="m 662.49995,507.49997 h 0.0165 c 1.65287,0 2.98353,1.33066 2.98353,2.98353 v 3.01647 l -3.00824,0.008 z" + style="display:inline;opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:new" /> + </g> + <g + transform="translate(-563,-34.99997)" + id="g10308-9" + style="display:inline;enable-background:new"> + <rect + style="opacity:0;vector-effect:none;fill:#d40000;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" + id="rect10296-2" + width="15.999999" + height="15.999999" + x="673" + y="485.99997" /> + <rect + style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" + id="rect10298-7" + width="10" + height="14.999969" + x="675.5" + y="486.5" + rx="2.9835341" + ry="2.9835341" /> + <rect + ry="0.546875" + rx="0.546875" + y="489.49997" + x="679.5" + height="5.0000005" + width="2" + id="rect10300-9" + style="opacity:1;vector-effect:none;fill:#f9f9f9;fill-opacity:1;stroke:#ffffff;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" /> + <g + transform="translate(0,-21)" + id="g10306-4" /> + </g> </g> <g inkscape:groupmode="layer" diff --git a/release/datafiles/blender_icons16/icon16_hide_off.dat b/release/datafiles/blender_icons16/icon16_hide_off.dat Binary files differnew file mode 100644 index 00000000000..4feb0d26696 --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_hide_off.dat diff --git a/release/datafiles/blender_icons16/icon16_hide_on.dat b/release/datafiles/blender_icons16/icon16_hide_on.dat Binary files differnew file mode 100644 index 00000000000..906edb431dd --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_hide_on.dat diff --git a/release/datafiles/blender_icons16/icon16_mouse_drag.dat b/release/datafiles/blender_icons16/icon16_mouse_drag.dat Binary files differnew file mode 100644 index 00000000000..751421684b1 --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_mouse_drag.dat diff --git a/release/datafiles/blender_icons16/icon16_mouse_lmb.dat b/release/datafiles/blender_icons16/icon16_mouse_lmb.dat Binary files differnew file mode 100644 index 00000000000..2a0c42f4a6a --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_mouse_lmb.dat diff --git a/release/datafiles/blender_icons16/icon16_mouse_mmb.dat b/release/datafiles/blender_icons16/icon16_mouse_mmb.dat Binary files differnew file mode 100644 index 00000000000..300f6be4ee3 --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_mouse_mmb.dat diff --git a/release/datafiles/blender_icons16/icon16_mouse_rmb.dat b/release/datafiles/blender_icons16/icon16_mouse_rmb.dat Binary files differnew file mode 100644 index 00000000000..3f13b167eff --- /dev/null +++ b/release/datafiles/blender_icons16/icon16_mouse_rmb.dat diff --git a/release/datafiles/blender_icons16/icon16_restrict_view_off.dat b/release/datafiles/blender_icons16/icon16_restrict_view_off.dat Binary files differindex 730f5749104..320c1be5259 100644 --- a/release/datafiles/blender_icons16/icon16_restrict_view_off.dat +++ b/release/datafiles/blender_icons16/icon16_restrict_view_off.dat diff --git a/release/datafiles/blender_icons16/icon16_restrict_view_on.dat b/release/datafiles/blender_icons16/icon16_restrict_view_on.dat Binary files differindex edef3a356b2..279d744a012 100644 --- a/release/datafiles/blender_icons16/icon16_restrict_view_on.dat +++ b/release/datafiles/blender_icons16/icon16_restrict_view_on.dat diff --git a/release/datafiles/blender_icons32/icon32_hide_off.dat b/release/datafiles/blender_icons32/icon32_hide_off.dat Binary files differnew file mode 100644 index 00000000000..e13dd195ee6 --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_hide_off.dat diff --git a/release/datafiles/blender_icons32/icon32_hide_on.dat b/release/datafiles/blender_icons32/icon32_hide_on.dat Binary files differnew file mode 100644 index 00000000000..25c83fb165d --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_hide_on.dat diff --git a/release/datafiles/blender_icons32/icon32_mouse_drag.dat b/release/datafiles/blender_icons32/icon32_mouse_drag.dat Binary files differnew file mode 100644 index 00000000000..96d3e23181c --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_mouse_drag.dat diff --git a/release/datafiles/blender_icons32/icon32_mouse_lmb.dat b/release/datafiles/blender_icons32/icon32_mouse_lmb.dat Binary files differnew file mode 100644 index 00000000000..5cb01a4199b --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_mouse_lmb.dat diff --git a/release/datafiles/blender_icons32/icon32_mouse_mmb.dat b/release/datafiles/blender_icons32/icon32_mouse_mmb.dat Binary files differnew file mode 100644 index 00000000000..2c0bc4e1873 --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_mouse_mmb.dat diff --git a/release/datafiles/blender_icons32/icon32_mouse_rmb.dat b/release/datafiles/blender_icons32/icon32_mouse_rmb.dat Binary files differnew file mode 100644 index 00000000000..3e8bf43d306 --- /dev/null +++ b/release/datafiles/blender_icons32/icon32_mouse_rmb.dat diff --git a/release/datafiles/blender_icons32/icon32_restrict_view_off.dat b/release/datafiles/blender_icons32/icon32_restrict_view_off.dat Binary files differindex f9b3a48cfde..ec850df393e 100644 --- a/release/datafiles/blender_icons32/icon32_restrict_view_off.dat +++ b/release/datafiles/blender_icons32/icon32_restrict_view_off.dat diff --git a/release/datafiles/blender_icons32/icon32_restrict_view_on.dat b/release/datafiles/blender_icons32/icon32_restrict_view_on.dat Binary files differindex 482530bab58..07e66cc51a9 100644 --- a/release/datafiles/blender_icons32/icon32_restrict_view_on.dat +++ b/release/datafiles/blender_icons32/icon32_restrict_view_on.dat diff --git a/release/datafiles/blender_icons_geom.py b/release/datafiles/blender_icons_geom.py index e9155a91fc8..bb7a6568767 100644 --- a/release/datafiles/blender_icons_geom.py +++ b/release/datafiles/blender_icons_geom.py @@ -288,7 +288,7 @@ def main(): objects = [] if args.group: - group = bpy.data.groups.get(args.group) + group = bpy.data.collections.get(args.group) if group is None: print(f"Group {args.group!r} not found!") return diff --git a/release/scripts/presets/interface_theme/flatty_dark_blueberry.xml b/release/scripts/presets/interface_theme/flatty_dark_blueberry.xml index eb6c8e68511..fce74a4fac0 100644 --- a/release/scripts/presets/interface_theme/flatty_dark_blueberry.xml +++ b/release/scripts/presets/interface_theme/flatty_dark_blueberry.xml @@ -8,21 +8,21 @@ icon_saturation="0.4" widget_emboss="#00000005" editor_outline="#1c1d20" - axis_x="#dc4242" - axis_y="#42dc42" - axis_z="#4242dc" + axis_x="#ff3352" + axis_y="#8bdc00" + axis_z="#2890ff" manipulator_hi="#ffffff" - manipulator_primary="#e3ff33" - manipulator_secondary="#33ffff" - manipulator_a="#177f17" - manipulator_b="#7f1717"> + manipulator_primary="#f5f14d" + manipulator_secondary="#63ffff" + manipulator_a="#4da84d" + manipulator_b="#a33535"> <wcol_regular> <ThemeWidgetColors outline="#38393e" inner="#505158ff" - inner_sel="#407180ff" + inner_sel="#93989eff" item="#38393eff" text="#eeeeee" - text_sel="#ffffff" + text_sel="#e9e9ff" show_shaded="FALSE" shadetop="0" shadedown="-5" @@ -32,7 +32,7 @@ <wcol_tool> <ThemeWidgetColors outline="#2f2f34" inner="#505158ff" - inner_sel="#599eb3ff" + inner_sel="#2f2f34ff" item="#e6ebffff" text="#f2f2f2" text_sel="#ffffff" @@ -56,7 +56,7 @@ </ThemeWidgetColors> </wcol_toolbar_item> <wcol_radio> - <ThemeWidgetColors outline="#2d2e33" + <ThemeWidgetColors outline="#424352" inner="#505158ff" inner_sel="#2d2d33ff" item="#ffffffff" @@ -82,8 +82,8 @@ </ThemeWidgetColors> </wcol_text> <wcol_option> - <ThemeWidgetColors outline="#2d2e33" - inner="#2d2e33ff" + <ThemeWidgetColors outline="#424352" + inner="#222325b3" inner_sel="#595966ff" item="#ffffffff" text="#eeeeee" @@ -97,7 +97,7 @@ <wcol_toggle> <ThemeWidgetColors outline="#43434d" inner="#595966ff" - inner_sel="#599eb3ff" + inner_sel="#3f7d80ff" item="#191919ff" text="#eeeeee" text_sel="#ffffff" @@ -110,20 +110,20 @@ <wcol_num> <ThemeWidgetColors outline="#46464d" inner="#505158ff" - inner_sel="#3f7180ff" + inner_sel="#3f7780ff" item="#46464dff" text="#eeeeee" text_sel="#ffffff" - show_shaded="FALSE" + show_shaded="TRUE" shadetop="0" shadedown="0" - roundness="0.8"> + roundness="0.6"> </ThemeWidgetColors> </wcol_num> <wcol_numslider> <ThemeWidgetColors outline="#46464d" inner="#3f3f47ff" - inner_sel="#3f7180ff" + inner_sel="#3f7780ff" item="#505158ff" text="#eeeeee" text_sel="#ffffff" @@ -136,7 +136,7 @@ <wcol_box> <ThemeWidgetColors outline="#2d2e33" inner="#43454dff" - inner_sel="#599eb3ff" + inner_sel="#3f7780ff" item="#191919ff" text="#eeeeee" text_sel="#ffffff" @@ -173,7 +173,7 @@ </ThemeWidgetColors> </wcol_pulldown> <wcol_menu_back> - <ThemeWidgetColors outline="#1f1f1f" + <ThemeWidgetColors outline="#29282e" inner="#1f1f1fef" inner_sel="#505158ff" item="#646464ff" @@ -186,10 +186,10 @@ </ThemeWidgetColors> </wcol_menu_back> <wcol_pie_menu> - <ThemeWidgetColors outline="#4d4d4d" - inner="#1a1a1aff" - inner_sel="#599eb3ff" - item="#599eb3ff" + <ThemeWidgetColors outline="#29282e" + inner="#29282eff" + inner_sel="#505158ff" + item="#696a72ff" text="#eeeeee" text_sel="#ffffff" show_shaded="FALSE" @@ -199,10 +199,10 @@ </ThemeWidgetColors> </wcol_pie_menu> <wcol_tooltip> - <ThemeWidgetColors outline="#000000" - inner="#1f1f1fef" - inner_sel="#2d2d2de6" - item="#646464ff" + <ThemeWidgetColors outline="#2f3035" + inner="#19191aef" + inner_sel="#19191aef" + item="#19191aef" text="#eeeeee" text_sel="#ffffff" show_shaded="FALSE" @@ -277,10 +277,10 @@ </wcol_state> <wcol_tab> <ThemeWidgetColors outline="#28292d" - inner="#38393fff" + inner="#323239ff" inner_sel="#43444bff" item="#28292dff" - text="#ffffff" + text="#bebebe" text_sel="#ffffff" show_shaded="FALSE" shadetop="0" @@ -381,6 +381,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -436,6 +437,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -472,6 +474,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -517,6 +520,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -574,8 +578,9 @@ tab_back="#28292dff" tab_outline="#28292d"> <panelcolors> - <ThemePanelColors header="#29282eff" + <ThemePanelColors header="#2f3035ff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -652,6 +657,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -700,6 +706,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -711,11 +718,11 @@ <properties> <ThemeProperties> <space> - <ThemeSpaceGeneric back="#2f3035" - title="#ffffff" + <ThemeSpaceGeneric back="#3a3c42" + title="#eeeeee" text="#ffffff" text_hi="#ffffff" - header="#29282eff" + header="#3a3c42ff" header_text="#eeeeee" header_text_hi="#ffffff" button="#2f303599" @@ -724,11 +731,12 @@ button_text_hi="#ffffff" tab_active="#446499" tab_inactive="#28292d" - tab_back="#28292dff" + tab_back="#303034e6" tab_outline="#28292d"> <panelcolors> - <ThemePanelColors header="#29282eff" - back="#3e3f46ff" + <ThemePanelColors header="#3a3c42cc" + back="#2c2e33b3" + sub_back="#0000003e" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -768,6 +776,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -823,6 +832,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -840,13 +850,13 @@ </node_editor> <outliner> <ThemeOutliner match="#337f33" - selected_highlight="#7297d0"> + selected_highlight="#747a83"> <space> - <ThemeSpaceGeneric back="#2f3035" + <ThemeSpaceGeneric back="#3a3c42" title="#ffffff" - text="#ffffff" + text="#dedede" text_hi="#ffffff" - header="#29282eff" + header="#3f3f45ff" header_text="#eeeeee" header_text_hi="#ffffff" button="#2f303599" @@ -860,6 +870,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -898,6 +909,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -913,7 +925,7 @@ title="#ffffff" text="#ffffff" text_hi="#ffffff" - header="#29282eff" + header="#2f3035ff" header_text="#eeeeee" header_text_hi="#ffffff" button="#2f303599" @@ -927,6 +939,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -961,6 +974,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -1014,6 +1028,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000019" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -1036,7 +1051,7 @@ title="#ffffff" text="#ffffff" text_hi="#ffffff" - header="#29282eff" + header="#1f1f23ff" header_text="#eeeeee" header_text_hi="#ffffff" button="#2f303599" @@ -1050,6 +1065,7 @@ <panelcolors> <ThemePanelColors header="#29282eff" back="#3e3f46ff" + sub_back="#00000000" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> @@ -1061,24 +1077,25 @@ <statusbar> <ThemeStatusBar> <space> - <ThemeSpaceGeneric back="#09090a" - title="#8f8f8f" - text="#8f8f8f" + <ThemeSpaceGeneric back="#29282e" + title="#e4e8ff" + text="#747a83" text_hi="#ffffff" - header="#252528ff" - header_text="#cbcbcb" + header="#1f1f23ff" + header_text="#959eaa" header_text_hi="#ffffff" - button="#72727280" + button="#2f3035ff" button_title="#000000" button_text="#000000" button_text_hi="#ffffff" - tab_active="#727272" - tab_inactive="#535353" - tab_back="#404040ff" - tab_outline="#3c3c3c"> + tab_active="#666c76" + tab_inactive="#2f3035" + tab_back="#2f3035ff" + tab_outline="#2f3035"> <panelcolors> - <ThemePanelColors header="#5f5f5fff" + <ThemePanelColors header="#2f3035ff" back="#46464699" + sub_back="#00000000" show_header="TRUE" show_back="TRUE"> </ThemePanelColors> diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 074177bc4b7..5c1ca0ab2ad 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -297,7 +297,7 @@ class AddPresetRender(AddPresetBase, Operator): """Add or remove a Render Preset""" bl_idname = "render.preset_add" bl_label = "Add Render Preset" - preset_menu = "RENDER_MT_presets" + preset_menu = "RENDER_PT_presets" preset_defines = [ "scene = bpy.context.scene" @@ -320,7 +320,7 @@ class AddPresetCamera(AddPresetBase, Operator): """Add or remove a Camera Preset""" bl_idname = "camera.preset_add" bl_label = "Add Camera Preset" - preset_menu = "CAMERA_MT_presets" + preset_menu = "CAMERA_PT_presets" preset_defines = [ "cam = bpy.context.camera" @@ -351,7 +351,7 @@ class AddPresetSafeAreas(AddPresetBase, Operator): """Add or remove a Safe Areas Preset""" bl_idname = "safe_areas.preset_add" bl_label = "Add Safe Area Preset" - preset_menu = "SAFE_AREAS_MT_presets" + preset_menu = "SAFE_AREAS_PT_presets" preset_defines = [ "safe_areas = bpy.context.scene.safe_areas" @@ -371,7 +371,7 @@ class AddPresetCloth(AddPresetBase, Operator): """Add or remove a Cloth Preset""" bl_idname = "cloth.preset_add" bl_label = "Add Cloth Preset" - preset_menu = "CLOTH_MT_presets" + preset_menu = "CLOTH_PT_presets" preset_defines = [ "cloth = bpy.context.cloth" @@ -393,7 +393,7 @@ class AddPresetFluid(AddPresetBase, Operator): """Add or remove a Fluid Preset""" bl_idname = "fluid.preset_add" bl_label = "Add Fluid Preset" - preset_menu = "FLUID_MT_presets" + preset_menu = "FLUID_PT_presets" preset_defines = [ "fluid = bpy.context.fluid" @@ -411,7 +411,7 @@ class AddPresetHairDynamics(AddPresetBase, Operator): """Add or remove a Hair Dynamics Preset""" bl_idname = "particle.hair_dynamics_preset_add" bl_label = "Add Hair Dynamics Preset" - preset_menu = "PARTICLE_MT_hair_dynamics_presets" + preset_menu = "PARTICLE_PT_hair_dynamics_presets" preset_defines = [ "psys = bpy.context.particle_system", @@ -467,7 +467,7 @@ class AddPresetTrackingCamera(AddPresetBase, Operator): """Add or remove a Tracking Camera Intrinsics Preset""" bl_idname = "clip.camera_preset_add" bl_label = "Add Camera Preset" - preset_menu = "CLIP_MT_camera_presets" + preset_menu = "CLIP_PT_camera_presets" preset_defines = [ "camera = bpy.context.edit_movieclip.tracking.camera" @@ -501,7 +501,7 @@ class AddPresetTrackingTrackColor(AddPresetBase, Operator): """Add or remove a Clip Track Color Preset""" bl_idname = "clip.track_color_preset_add" bl_label = "Add Track Color Preset" - preset_menu = "CLIP_MT_track_color_presets" + preset_menu = "CLIP_PT_track_color_presets" preset_defines = [ "track = bpy.context.edit_movieclip.tracking.tracks.active" @@ -519,7 +519,7 @@ class AddPresetTrackingSettings(AddPresetBase, Operator): """Add or remove a motion tracking settings preset""" bl_idname = "clip.tracking_settings_preset_add" bl_label = "Add Tracking Settings Preset" - preset_menu = "CLIP_MT_tracking_settings_presets" + preset_menu = "CLIP_PT_tracking_settings_presets" preset_defines = [ "settings = bpy.context.edit_movieclip.tracking.settings" @@ -549,7 +549,7 @@ class AddPresetNodeColor(AddPresetBase, Operator): """Add or remove a Node Color Preset""" bl_idname = "node.node_color_preset_add" bl_label = "Add Node Color Preset" - preset_menu = "NODE_MT_node_color_presets" + preset_menu = "NODE_PT_node_color_presets" preset_defines = [ "node = bpy.context.active_node" @@ -662,7 +662,7 @@ class AddPresetUnitsLength(AddPresetBase, Operator): """Add or remove length units preset""" bl_idname = "scene.units_length_preset_add" bl_label = "Add Length Units Preset" - preset_menu = "SCENE_MT_units_length_presets" + preset_menu = "SCENE_PT_units_length_presets" preset_defines = [ "scene = bpy.context.scene" diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index b0a5e19d269..b6f77505410 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -2456,7 +2456,7 @@ class WM_OT_studiolight_install(Operator): for filepath in filepaths: shutil.copy(str(filepath), str(path_studiolights)) - userpref.studio_lights_refresh() + userpref.studio_lights.new(str(path_studiolights.joinpath(filepath.name)), self.orientation) # print message msg = ( @@ -2478,34 +2478,23 @@ class WM_OT_studiolight_uninstall(Operator): bl_label = "Uninstall Studio Light" index = bpy.props.IntProperty() + def _remove_path(self, path): + if path.exists(): + path.unlink() + def execute(self, context): import pathlib userpref = context.user_preferences for studio_light in userpref.studio_lights: if studio_light.index == self.index: - path = pathlib.Path(studio_light.path) - if path.exists(): - path.unlink() - userpref.studio_lights_refresh() - return {'FINISHED'} + self._remove_path(pathlib.Path(studio_light.path)) + self._remove_path(pathlib.Path(studio_light.path_irr_cache)) + self._remove_path(pathlib.Path(studio_light.path_sh_cache)) + userpref.studio_lights.remove(studio_light) + return {'FINISHED'} return {'CANCELLED'} -class WM_OT_studiolight_expand(Operator): - bl_idname = "wm.studiolight_expand" - bl_label = "Expand Studio Light" - index = bpy.props.IntProperty() - - def execute(self, context): - userpref = context.user_preferences - for studio_light in userpref.studio_lights: - if studio_light.index == self.index: - studio_light.show_expanded = not studio_light.show_expanded - break - - return {'FINISHED'} - - class WM_OT_studiolight_userpref_show(Operator): """Show light user preferences""" bl_idname = "wm.studiolight_userpref_show" @@ -2572,7 +2561,6 @@ classes = ( WM_OT_owner_disable, WM_OT_owner_enable, WM_OT_url_open, - WM_OT_studiolight_expand, WM_OT_studiolight_install, WM_OT_studiolight_uninstall, WM_OT_studiolight_userpref_show, diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index 22c7964173b..10709676b85 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -34,7 +34,7 @@ class CameraButtonsPanel: return context.camera and (engine in cls.COMPAT_ENGINES) -class CAMERA_MT_presets(PresetMenu): +class CAMERA_PT_presets(PresetMenu): bl_label = "Camera Presets" preset_subdir = "camera" preset_operator = "script.execute_preset" @@ -42,7 +42,7 @@ class CAMERA_MT_presets(PresetMenu): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} -class SAFE_AREAS_MT_presets(PresetMenu): +class SAFE_AREAS_PT_presets(PresetMenu): bl_label = "Camera Presets" preset_subdir = "safe_areas" preset_operator = "script.execute_preset" @@ -187,7 +187,7 @@ class DATA_PT_camera(CameraButtonsPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} def draw_header_preset(self, context): - CAMERA_MT_presets.draw_panel_header(self.layout) + CAMERA_PT_presets.draw_panel_header(self.layout) def draw(self, context): layout = self.layout @@ -409,7 +409,7 @@ class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel): self.layout.prop(cam, "show_safe_areas", text="") def draw_header_preset(self, context): - SAFE_AREAS_MT_presets.draw_panel_header(self.layout) + SAFE_AREAS_PT_presets.draw_panel_header(self.layout) def draw(self, context): layout = self.layout @@ -449,8 +449,8 @@ def draw_display_safe_settings(layout, safe_data, settings): classes = ( - CAMERA_MT_presets, - SAFE_AREAS_MT_presets, + CAMERA_PT_presets, + SAFE_AREAS_PT_presets, DATA_PT_context_camera, DATA_PT_lens, DATA_PT_camera, diff --git a/release/scripts/startup/bl_ui/properties_data_lightprobe.py b/release/scripts/startup/bl_ui/properties_data_lightprobe.py index f3ccc9f3176..10b66dd0033 100644 --- a/release/scripts/startup/bl_ui/properties_data_lightprobe.py +++ b/release/scripts/startup/bl_ui/properties_data_lightprobe.py @@ -155,7 +155,7 @@ class DATA_PT_lightprobe_display(DataButtonsPanel, Panel): col = layout.column() - if probe.type != "PLANAR": + if probe.type != 'PLANAR': col.prop(probe, "data_draw_size", text="Size") else: col.prop(ob, "empty_draw_size", text="Arrow Size") diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index 5ff9f83b1a9..e8015327c1d 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -353,19 +353,16 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel): row.active = enable_edit_value row.prop(kb, "value") - split = layout.split() + layout.use_property_split = True - col = split.column(align=True) - col.active = enable_edit_value - col.label(text="Range:") - col.prop(kb, "slider_min", text="Min") - col.prop(kb, "slider_max", text="Max") + col = layout.column() + sub.active = enable_edit_value + sub = col.column(align=True) + sub.prop(kb, "slider_min", text="Range Min") + sub.prop(kb, "slider_max", text="Max") - col = split.column(align=True) - col.active = enable_edit_value - col.label(text="Blend:") - col.prop_search(kb, "vertex_group", ob, "vertex_groups", text="") - col.prop_search(kb, "relative_key", key, "key_blocks", text="") + col.prop_search(kb, "vertex_group", ob, "vertex_groups", text="Vertex Group") + col.prop_search(kb, "relative_key", key, "key_blocks", text="Relative To") else: layout.prop(kb, "interpolation") @@ -419,6 +416,7 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel): def draw(self, context): layout = self.layout + layout.use_property_split = True obj = context.object me = context.mesh diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 2b298c560c7..fdbf0b240c4 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -198,14 +198,14 @@ class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel): layout.prop(mat, "blend_method") - if mat.blend_method != "OPAQUE": + if mat.blend_method != 'OPAQUE': layout.prop(mat, "transparent_shadow_method") row = layout.row() - row.active = ((mat.blend_method == "CLIP") or (mat.transparent_shadow_method == "CLIP")) + row.active = ((mat.blend_method == 'CLIP') or (mat.transparent_shadow_method == 'CLIP')) row.prop(mat, "alpha_threshold") - if mat.blend_method not in {"OPAQUE", "CLIP", "HASHED"}: + if mat.blend_method not in {'OPAQUE', 'CLIP', 'HASHED'}: layout.prop(mat, "show_transparent_backside") layout.prop(mat, "use_screen_refraction") diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index 153d6af9b24..17034689528 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -57,15 +57,17 @@ class OBJECT_PT_transform(ObjectButtonsPanel, Panel): col = flow.column() row = col.row(align=True) row.prop(ob, "location") - row.prop(ob, "lock_location", text="") + row.use_property_decorate = False + row.prop(ob, "lock_location", text="", emboss=False) if ob.rotation_mode == 'QUATERNION': col = flow.column() row = col.row(align=True) row.prop(ob, "rotation_quaternion", text="Rotation") sub = row.column(align=True) - sub.prop(ob, "lock_rotation_w", text="") - sub.prop(ob, "lock_rotation", text="") + sub.use_property_decorate = False + sub.prop(ob, "lock_rotation_w", text="", emboss=False) + sub.prop(ob, "lock_rotation", text="", emboss=False) elif ob.rotation_mode == 'AXIS_ANGLE': # row.column().label(text="Rotation") #row.column().prop(pchan, "rotation_angle", text="Angle") @@ -75,20 +77,25 @@ class OBJECT_PT_transform(ObjectButtonsPanel, Panel): row.prop(ob, "rotation_axis_angle", text="Rotation") sub = row.column(align=True) - sub.prop(ob, "lock_rotation_w", text="") - sub.prop(ob, "lock_rotation", text="") + sub.use_property_decorate = False + sub.prop(ob, "lock_rotation_w", text="", emboss=False) + sub.prop(ob, "lock_rotation", text="", emboss=False) else: col = flow.column() row = col.row(align=True) row.prop(ob, "rotation_euler", text="Rotation") - row.prop(ob, "lock_rotation", text="") + row.use_property_decorate = False + row.prop(ob, "lock_rotation", text="", emboss=False) col = flow.column() row = col.row(align=True) row.prop(ob, "scale") - row.prop(ob, "lock_scale", text="") + row.use_property_decorate = False + row.prop(ob, "lock_scale", text="", emboss=False) - layout.prop(ob, "rotation_mode") + row = layout.row(align=True) + row.prop(ob, "rotation_mode") + row.label(text="", icon='BLANK1') class OBJECT_PT_delta_transform(ObjectButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 76e490ad07a..fbc053a565f 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -83,7 +83,7 @@ class PARTICLE_MT_specials(Menu): layout.operator("particle.duplicate_particle_system") -class PARTICLE_MT_hair_dynamics_presets(PresetMenu): +class PARTICLE_PT_hair_dynamics_presets(PresetMenu): bl_label = "Hair Dynamics Presets" preset_subdir = "hair_dynamics" preset_operator = "script.execute_preset" @@ -349,7 +349,7 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel): layout = self.layout layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False - PARTICLE_MT_hair_dynamics_presets.draw_panel_header(layout) + PARTICLE_PT_hair_dynamics_presets.draw_panel_header(layout) def draw(self, context): layout = self.layout @@ -500,6 +500,7 @@ class PARTICLE_PT_cache(ParticleButtonsPanel, Panel): class PARTICLE_PT_velocity(ParticleButtonsPanel, Panel): bl_label = "Velocity" + bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} @classmethod @@ -626,6 +627,7 @@ class PARTICLE_PT_rotation_angular_velocity(ParticleButtonsPanel, Panel): class PARTICLE_PT_physics(ParticleButtonsPanel, Panel): bl_label = "Physics" + bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} @classmethod @@ -1012,6 +1014,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel): class PARTICLE_PT_render(ParticleButtonsPanel, Panel): bl_label = "Render" + bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} @classmethod @@ -1710,30 +1713,74 @@ class PARTICLE_PT_force_fields(ParticleButtonsPanel, Panel): def draw(self, context): layout = self.layout + layout.use_property_split = True part = particle_get_settings(context) - row = layout.row() - row.prop(part, "use_self_effect") - row.prop(part, "effector_amount", text="Amount") + col = layout.column() + col.prop(part, "use_self_effect") + col.prop(part, "effector_amount", text="Effector Amount") + + +class PARTICLE_PT_force_fields_type1(ParticleButtonsPanel, Panel): + bl_label = "Type 1" + bl_parent_id = "PARTICLE_PT_force_fields" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = True - split = layout.split(percentage=0.2) - split.label(text="Type 1:") - split.prop(part.force_field_1, "type", text="") + part = particle_get_settings(context) + + col = layout.column() + col.prop(part.force_field_1, "type", text="Type 1") basic_force_field_settings_ui(self, context, part.force_field_1) - if part.force_field_1.type != 'NONE': - layout.label(text="Falloff:") - basic_force_field_falloff_ui(self, context, part.force_field_1) - if part.force_field_1.type != 'NONE': - layout.label(text="") - split = layout.split(percentage=0.2) - split.label(text="Type 2:") - split.prop(part.force_field_2, "type", text="") +class PARTICLE_PT_force_fields_type2(ParticleButtonsPanel, Panel): + bl_label = "Type 2" + bl_parent_id = "PARTICLE_PT_force_fields" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + part = particle_get_settings(context) + + col = layout.column() + col.prop(part.force_field_2, "type", text="Type 2") basic_force_field_settings_ui(self, context, part.force_field_2) - if part.force_field_2.type != 'NONE': - layout.label(text="Falloff:") + + +class PARTICLE_PT_force_fields_type1_falloff(ParticleButtonsPanel, Panel): + bl_label = "Falloff" + bl_options = {'DEFAULT_CLOSED'} + bl_parent_id = "PARTICLE_PT_force_fields_type1" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + part = particle_get_settings(context) + + basic_force_field_falloff_ui(self, context, part.force_field_1) + + +class PARTICLE_PT_force_fields_type2_falloff(ParticleButtonsPanel, Panel): + bl_label = "Falloff" + bl_options = {'DEFAULT_CLOSED'} + bl_parent_id = "PARTICLE_PT_force_fields_type2" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + part = particle_get_settings(context) + basic_force_field_falloff_ui(self, context, part.force_field_2) @@ -1879,7 +1926,7 @@ class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, Panel): classes = ( PARTICLE_MT_specials, - PARTICLE_MT_hair_dynamics_presets, + PARTICLE_PT_hair_dynamics_presets, PARTICLE_UL_particle_systems, PARTICLE_PT_context_particles, PARTICLE_PT_emission, @@ -1916,6 +1963,10 @@ classes = ( PARTICLE_PT_hair_shape, PARTICLE_PT_field_weights, PARTICLE_PT_force_fields, + PARTICLE_PT_force_fields_type1, + PARTICLE_PT_force_fields_type1_falloff, + PARTICLE_PT_force_fields_type2, + PARTICLE_PT_force_fields_type2_falloff, PARTICLE_PT_vertexgroups, PARTICLE_PT_textures, PARTICLE_PT_custom_props, diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py index 82e93a240f1..2f659af3891 100644 --- a/release/scripts/startup/bl_ui/properties_physics_cloth.py +++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py @@ -31,7 +31,7 @@ def cloth_panel_enabled(md): return md.point_cache.is_baked is False -class CLOTH_MT_presets(PresetMenu): +class CLOTH_PT_presets(PresetMenu): bl_label = "Cloth Presets" preset_subdir = "cloth" preset_operator = "script.execute_preset" @@ -54,7 +54,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} def draw_header_preset(self, context): - CLOTH_MT_presets.draw_panel_header(self.layout) + CLOTH_PT_presets.draw_panel_header(self.layout) def draw(self, context): layout = self.layout @@ -258,7 +258,7 @@ class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel): classes = ( - CLOTH_MT_presets, + CLOTH_PT_presets, PHYSICS_PT_cloth, PHYSICS_PT_cloth_cache, PHYSICS_PT_cloth_collision, diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py index 05c72bf47ee..e071de0108b 100644 --- a/release/scripts/startup/bl_ui/properties_physics_common.py +++ b/release/scripts/startup/bl_ui/properties_physics_common.py @@ -139,14 +139,16 @@ def point_cache_ui(self, context, cache, enabled, cachetype): layout.enabled = False if not cache.use_external or cachetype == 'SMOKE': - row = layout.row(align=True) + col = layout.column(align=True) + col.use_property_split = True if cachetype not in {'PSYS', 'DYNAMIC_PAINT'}: - row.enabled = enabled - row.prop(cache, "frame_start") - row.prop(cache, "frame_end") + + col.enabled = enabled + col.prop(cache, "frame_start", text="Simulation Start") + col.prop(cache, "frame_end") if cachetype not in {'SMOKE', 'CLOTH', 'DYNAMIC_PAINT', 'RIGID_BODY'}: - row.prop(cache, "frame_step") + col.prop(cache, "frame_step") if cachetype != 'SMOKE': layout.label(text=cache.info) @@ -206,9 +208,12 @@ def point_cache_ui(self, context, cache, enabled, cachetype): def effector_weights_ui(self, context, weights, weight_type): layout = self.layout + layout.use_property_split = True layout.prop(weights, "group") + layout.use_property_split = False + split = layout.split() split.prop(weights, "gravity", slider=True) @@ -239,13 +244,12 @@ def effector_weights_ui(self, context, weights, weight_type): def basic_force_field_settings_ui(self, context, field): layout = self.layout - - split = layout.split() + layout.use_property_split = True if not field or field.type == 'NONE': return - col = split.column() + col = layout.column() if field.type == 'DRAG': col.prop(field, "linear_drag", text="Linear") @@ -265,10 +269,10 @@ def basic_force_field_settings_ui(self, context, field): else: col.prop(field, "flow") - col = split.column() + col = layout.column() sub = col.column(align=True) sub.prop(field, "noise") - sub.prop(field, "seed") + sub.prop(field, "seed", text="Noise Seed") if field.type == 'TURBULENCE': col.prop(field, "use_global_coords", text="Global") elif field.type == 'HARMONIC': @@ -276,46 +280,33 @@ def basic_force_field_settings_ui(self, context, field): if field.type == 'FORCE': col.prop(field, "use_gravity_falloff", text="Gravitation") - split = layout.split() - - col = split.column() - col.label(text="Effect point:") - col.prop(field, "apply_to_location") - col.prop(field, "apply_to_rotation") - - col = split.column() - col.label(text="Collision:") + col.prop(field, "apply_to_location", text="Affect Location") + col.prop(field, "apply_to_rotation", text="Affect Rotation") col.prop(field, "use_absorption") def basic_force_field_falloff_ui(self, context, field): layout = self.layout - split = layout.split(percentage=0.35) - if not field or field.type == 'NONE': return - col = split.column() - col.prop(field, "z_direction", text="") + col = layout.column() + col.prop(field, "z_direction") - col = split.column() col.prop(field, "falloff_power", text="Power") split = layout.split() - col = split.column() - row = col.row(align=True) - row.prop(field, "use_min_distance", text="") - sub = row.row(align=True) + split.prop(field, "use_min_distance", text="Min Distance") + sub = split.column(align=True) sub.active = field.use_min_distance - sub.prop(field, "distance_min", text="Minimum") + sub.prop(field, "distance_min", text="") - col = split.column() - row = col.row(align=True) - row.prop(field, "use_max_distance", text="") - sub = row.row(align=True) + split = layout.split() + split.prop(field, "use_max_distance", text="Max Distance") + sub = split.column(align=True) sub.active = field.use_max_distance - sub.prop(field, "distance_max", text="Maximum") + sub.prop(field, "distance_max", text="") classes = ( diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py index 476a448f978..6a66dafadf0 100644 --- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py +++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py @@ -127,7 +127,8 @@ class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel): class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel): - bl_label = "Dynamic Paint Advanced" + bl_label = "Advanced" + bl_parent_id = "PHYSICS_PT_dynamic_paint" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} @classmethod @@ -202,7 +203,8 @@ class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel): class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel): - bl_label = "Dynamic Paint Output" + bl_label = "Output" + bl_parent_id = "PHYSICS_PT_dynamic_paint" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} @@ -295,7 +297,8 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel): class PHYSICS_PT_dp_canvas_initial_color(PhysicButtonsPanel, Panel): - bl_label = "Dynamic Paint Initial Color" + bl_label = "Initial Color" + bl_parent_id = "PHYSICS_PT_dynamic_paint" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} @@ -331,7 +334,8 @@ class PHYSICS_PT_dp_canvas_initial_color(PhysicButtonsPanel, Panel): class PHYSICS_PT_dp_effects(PhysicButtonsPanel, Panel): - bl_label = "Dynamic Paint Effects" + bl_label = "Effects" + bl_parent_id = "PHYSICS_PT_dynamic_paint" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} @@ -380,7 +384,8 @@ class PHYSICS_PT_dp_effects(PhysicButtonsPanel, Panel): class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel): - bl_label = "Dynamic Paint Cache" + bl_label = "Cache" + bl_parent_id = "PHYSICS_PT_dynamic_paint" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} @@ -402,7 +407,8 @@ class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel): class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, Panel): - bl_label = "Dynamic Paint Source" + bl_label = "Source" + bl_parent_id = "PHYSICS_PT_dynamic_paint" COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} @classmethod @@ -454,7 +460,8 @@ class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, Panel): class PHYSICS_PT_dp_brush_velocity(PhysicButtonsPanel, Panel): - bl_label = "Dynamic Paint Velocity" + bl_label = "Velocity" + bl_parent_id = "PHYSICS_PT_dynamic_paint" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} @@ -490,7 +497,8 @@ class PHYSICS_PT_dp_brush_velocity(PhysicButtonsPanel, Panel): class PHYSICS_PT_dp_brush_wave(PhysicButtonsPanel, Panel): - bl_label = "Dynamic Paint Waves" + bl_label = "Waves" + bl_parent_id = "PHYSICS_PT_dynamic_paint" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py b/release/scripts/startup/bl_ui/properties_physics_field.py index 12e4feb8c0b..72b5d9f1574 100644 --- a/release/scripts/startup/bl_ui/properties_physics_field.py +++ b/release/scripts/startup/bl_ui/properties_physics_field.py @@ -47,44 +47,34 @@ class PHYSICS_PT_field(PhysicButtonsPanel, Panel): def draw(self, context): layout = self.layout + layout.use_property_split = True ob = context.object field = ob.field - split = layout.split(percentage=0.2) - split.label(text="Type:") - - split.prop(field, "type", text="") + layout.prop(field, "type") if field.type not in {'NONE', 'GUIDE', 'TEXTURE'}: - split = layout.split(percentage=0.2) - split.label(text="Shape:") - split.prop(field, "shape", text="") + layout.prop(field, "shape", text="Shape") elif field.type == 'TEXTURE': - split = layout.split(percentage=0.2) - split.label(text="Texture:") - split.row().template_ID(field, "texture", new="texture.new") - - split = layout.split() + layout.row().template_ID(field, "texture", new="texture.new") if field.type == 'NONE': return # nothing to draw elif field.type == 'GUIDE': - col = split.column() + col = layout.column() col.prop(field, "guide_minimum") col.prop(field, "guide_free") col.prop(field, "falloff_power") col.prop(field, "use_guide_path_add") col.prop(field, "use_guide_path_weight") - col = split.column() - col.label(text="Clumping:") + col.label(text="Clumping") col.prop(field, "guide_clump_amount") col.prop(field, "guide_clump_shape") - row = layout.row() - row.prop(field, "use_max_distance") - sub = row.row() + col.prop(field, "use_max_distance") + sub = col.column() sub.active = field.use_max_distance sub.prop(field, "distance_max") @@ -94,83 +84,86 @@ class PHYSICS_PT_field(PhysicButtonsPanel, Panel): if field.guide_kink_type != 'NONE': layout.prop(field, "guide_kink_axis") - split = layout.split() - - col = split.column() + col = layout.column() col.prop(field, "guide_kink_frequency") col.prop(field, "guide_kink_shape") - - col = split.column() col.prop(field, "guide_kink_amplitude") elif field.type == 'TEXTURE': - col = split.column() + col = layout.column() col.prop(field, "strength") - col.prop(field, "texture_mode", text="") + col.prop(field, "texture_mode") col.prop(field, "texture_nabla") - col = split.column() col.prop(field, "use_object_coords") col.prop(field, "use_2d_force") elif field.type == 'SMOKE_FLOW': - col = split.column() + col = layout.column() col.prop(field, "strength") col.prop(field, "flow") - col = split.column() - col.label(text="Domain Object:") - col.prop(field, "source_object", "") + col.prop(field, "source_object") col.prop(field, "use_smoke_density") else: basic_force_field_settings_ui(self, context, field) - if field.type not in {'NONE', 'GUIDE'}: - layout.label(text="Falloff:") - layout.row().prop(field, "falloff_type", expand=True) +class PHYSICS_PT_field_falloff(PhysicButtonsPanel, Panel): + bl_label = "Falloff" + bl_parent_id = "PHYSICS_PT_field" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + ob = context.object + return (context.engine in cls.COMPAT_ENGINES) and (ob.field) and (ob.field.type not in {'NONE', 'GUIDE'}) + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + ob = context.object + field = ob.field - basic_force_field_falloff_ui(self, context, field) + layout.prop(field, "falloff_type", text="Shape") - if field.falloff_type == 'CONE': - layout.separator() + basic_force_field_falloff_ui(self, context, field) - split = layout.split(percentage=0.35) + if field.falloff_type == 'CONE': + layout.separator() - col = split.column() - col.label(text="Angular:") - col.prop(field, "use_radial_min", text="Use Minimum") - col.prop(field, "use_radial_max", text="Use Maximum") + col = layout.column() + col.prop(field, "radial_falloff", text="Power") - col = split.column() - col.prop(field, "radial_falloff", text="Power") + col.label(text="Angular") - sub = col.column() - sub.active = field.use_radial_min - sub.prop(field, "radial_min", text="Angle") + col.prop(field, "use_radial_min", text="Use Min Angle") + sub = col.column() + sub.active = field.use_radial_min + sub.prop(field, "radial_min", text="Min Angle") - sub = col.column() - sub.active = field.use_radial_max - sub.prop(field, "radial_max", text="Angle") + col.prop(field, "use_radial_max", text="Use Max Angle") + sub = col.column() + sub.active = field.use_radial_max + sub.prop(field, "radial_max", text="Max Angle") - elif field.falloff_type == 'TUBE': - layout.separator() + elif field.falloff_type == 'TUBE': + layout.separator() - split = layout.split(percentage=0.35) + col = layout.column() - col = split.column() - col.label(text="Radial:") - col.prop(field, "use_radial_min", text="Use Minimum") - col.prop(field, "use_radial_max", text="Use Maximum") + col.prop(field, "radial_falloff", text="Power") - col = split.column() - col.prop(field, "radial_falloff", text="Power") + col.label(text="Radial") - sub = col.column() - sub.active = field.use_radial_min - sub.prop(field, "radial_min", text="Distance") + col.prop(field, "use_radial_min", text="Use Minimum") + sub = col.column() + sub.active = field.use_radial_min + sub.prop(field, "radial_min", text="Distance") - sub = col.column() - sub.active = field.use_radial_max - sub.prop(field, "radial_max", text="Distance") + col.prop(field, "use_radial_max", text="Use Maximum") + sub = col.column() + sub.active = field.use_radial_max + sub.prop(field, "radial_max", text="Distance") class PHYSICS_PT_collision(PhysicButtonsPanel, Panel): @@ -188,6 +181,7 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, Panel): md = context.collision split = layout.split() + layout.use_property_split = True coll = md.settings @@ -196,39 +190,90 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, Panel): layout.active = settings.use - split = layout.split() + col = layout.column() + col.prop(settings, "absorption", text="Force Field Absorption") + + +class PHYSICS_PT_collision_particle(PhysicButtonsPanel, Panel): + bl_label = "Particle" + bl_parent_id = "PHYSICS_PT_collision" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + ob = context.object + return (ob and ob.type == 'MESH') and (context.engine in cls.COMPAT_ENGINES) and (context.collision) + + def draw(self, context): + layout = self.layout + + md = context.collision + + layout.use_property_split = True + flow = layout.grid_flow(row_major=True, num_columns=0, even_columns=True, even_rows=False, align=False) + + coll = md.settings - col = split.column() - col.label(text="Particle:") + if coll: + settings = context.object.collision + + layout.active = settings.use + + col = flow.column() col.prop(settings, "permeability", slider=True) col.prop(settings, "stickiness") + col = flow.column() col.prop(settings, "use_particle_kill") - col.label(text="Particle Damping:") - sub = col.column(align=True) - sub.prop(settings, "damping_factor", text="Factor", slider=True) - sub.prop(settings, "damping_random", text="Random", slider=True) - col.label(text="Particle Friction:") + col = flow.column() sub = col.column(align=True) - sub.prop(settings, "friction_factor", text="Factor", slider=True) - sub.prop(settings, "friction_random", text="Random", slider=True) + sub.prop(settings, "damping_factor", text="Damping", slider=True) + sub.prop(settings, "damping_random", text="Randomize", slider=True) - col = split.column() - col.label(text="Soft Body and Cloth:") + col = flow.column() sub = col.column(align=True) - sub.prop(settings, "thickness_outer", text="Outer", slider=True) - sub.prop(settings, "thickness_inner", text="Inner", slider=True) + sub.prop(settings, "friction_factor", text="Friction", slider=True) + sub.prop(settings, "friction_random", text="Randomize", slider=True) + + +class PHYSICS_PT_collision_softbody(PhysicButtonsPanel, Panel): + bl_label = "Softbody" + bl_parent_id = "PHYSICS_PT_collision" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + ob = context.object + return (ob and ob.type == 'MESH') and (context.engine in cls.COMPAT_ENGINES) and (context.collision) + + def draw(self, context): + layout = self.layout + + layout.use_property_split = True + flow = layout.grid_flow(row_major=True, num_columns=0, even_columns=True, even_rows=False, align=False) + + md = context.collision + coll = md.settings + + if coll: + settings = context.object.collision + + layout.active = settings.use - col.label(text="Soft Body Damping:") - col.prop(settings, "damping", text="Factor", slider=True) + col = flow.column() + col.prop(settings, "damping", text="Damping", slider=True) - col.label(text="Force Fields:") - col.prop(settings, "absorption", text="Absorption") + col = flow.column() + col.prop(settings, "thickness_outer", text="Thickness Outer", slider=True) + col.prop(settings, "thickness_inner", text="Inner", slider=True) classes = ( PHYSICS_PT_field, + PHYSICS_PT_field_falloff, PHYSICS_PT_collision, + PHYSICS_PT_collision_particle, + PHYSICS_PT_collision_softbody, ) if __name__ == "__main__": # only for live edit. diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py index 26957c40ff3..94611808059 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fluid.py +++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py @@ -23,7 +23,7 @@ from bpy.app.translations import pgettext_iface as iface_ from bl_operators.presets import PresetMenu -class FLUID_MT_presets(PresetMenu): +class FLUID_PT_presets(PresetMenu): bl_label = "Fluid Presets" preset_subdir = "fluid" preset_operator = "script.execute_preset" @@ -242,7 +242,7 @@ class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, Panel): col.prop(fluid, "simulation_scale", text="Meters") col = split.column() - FLUID_MT_presets.draw_menu(col, text="Viscosity Presets") + FLUID_PT_presets.draw_menu(col, text="Viscosity Presets") sub = col.column(align=True) sub.prop(fluid, "viscosity_base", text="Base") @@ -306,7 +306,7 @@ class PHYSICS_PT_domain_particles(PhysicButtonsPanel, Panel): classes = ( - FLUID_MT_presets, + FLUID_PT_presets, PHYSICS_PT_fluid, PHYSICS_PT_domain_gravity, PHYSICS_PT_domain_boundary, diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 2e7a6b7ee23..5458b038d98 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -23,14 +23,14 @@ from bpy.types import Menu, Panel, UIList from bl_operators.presets import PresetMenu -class RENDER_MT_presets(PresetMenu): +class RENDER_PT_presets(PresetMenu): bl_label = "Render Presets" preset_subdir = "render" preset_operator = "script.execute_preset" preset_add_operator = "render.preset_add" -class RENDER_MT_ffmpeg_presets(PresetMenu): +class RENDER_PT_ffmpeg_presets(PresetMenu): bl_label = "FFMPEG Presets" preset_subdir = "ffmpeg" preset_operator = "script.python_file_run" @@ -85,7 +85,7 @@ class RENDER_PT_dimensions(RenderButtonsPanel, Panel): _preset_class = None def draw_header_preset(self, context): - RENDER_MT_presets.draw_panel_header(self.layout) + RENDER_PT_presets.draw_panel_header(self.layout) @staticmethod def _draw_framerate_label(*args): @@ -205,7 +205,8 @@ class RENDER_PT_stamp(RenderButtonsPanel, Panel): def draw(self, context): layout = self.layout - layout.use_property_split = False + layout.use_property_split = True
+ layout.use_property_decorate = False # No animation.
rd = context.scene.render @@ -300,7 +301,7 @@ class RENDER_PT_encoding(RenderButtonsPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} def draw_header_preset(self, context): - RENDER_MT_ffmpeg_presets.draw_panel_header(self.layout) + RENDER_PT_ffmpeg_presets.draw_panel_header(self.layout) @classmethod def poll(cls, context): @@ -764,8 +765,8 @@ class RENDER_PT_hair(RenderButtonsPanel, Panel): classes = ( - RENDER_MT_presets, - RENDER_MT_ffmpeg_presets, + RENDER_PT_presets, + RENDER_PT_ffmpeg_presets, RENDER_MT_framerate_presets, RENDER_PT_context, RENDER_PT_dimensions, diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index 2ee1c156935..43706c360da 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -33,7 +33,7 @@ from .properties_physics_common import ( ) -class SCENE_MT_units_length_presets(PresetMenu): +class SCENE_PT_units_length_presets(PresetMenu): """Unit of measure for properties that use length values""" bl_label = "Unit Presets" preset_subdir = "units_length" @@ -83,7 +83,7 @@ class SCENE_PT_unit(SceneButtonsPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'} def draw_header_preset(self, context): - SCENE_MT_units_length_presets.draw_panel_header(self.layout) + SCENE_PT_units_length_presets.draw_panel_header(self.layout) def draw(self, context): layout = self.layout @@ -369,6 +369,7 @@ class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel): def draw(self, context): layout = self.layout + layout.use_property_split = True scene = context.scene @@ -386,13 +387,11 @@ class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel): col.prop(rbw, "group") col.prop(rbw, "constraints") - split = col.split() - - col = split.column() + col = col.column() col.prop(rbw, "time_scale", text="Speed") col.prop(rbw, "use_split_impulse") - col = split.column() + col = col.column() col.prop(rbw, "steps_per_second", text="Steps Per Second") col.prop(rbw, "solver_iterations", text="Solver Iterations") @@ -503,7 +502,7 @@ class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel): classes = ( - SCENE_MT_units_length_presets, + SCENE_PT_units_length_presets, SCENE_UL_keying_set_paths, SCENE_PT_scene, SCENE_PT_unit, diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index e5bf2c910a0..16e29d1ecc8 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -211,30 +211,25 @@ class TEXTURE_PT_colors(TextureButtonsPanel, Panel): def draw(self, context): layout = self.layout + layout.use_property_split = True tex = context.texture - layout.prop(tex, "use_color_ramp", text="Ramp") - if tex.use_color_ramp: - layout.template_color_ramp(tex, "color_ramp", expand=True) - - split = layout.split() - - col = split.column() - col.label(text="RGB Multiply:") + col = layout.column() sub = col.column(align=True) - sub.prop(tex, "factor_red", text="R") + sub.prop(tex, "factor_red", text="Multiply R") sub.prop(tex, "factor_green", text="G") sub.prop(tex, "factor_blue", text="B") - col = split.column() - col.label(text="Adjust:") col.prop(tex, "intensity") col.prop(tex, "contrast") col.prop(tex, "saturation") - col = layout.column() col.prop(tex, "use_clamp", text="Clamp") + col.prop(tex, "use_color_ramp", text="Ramp") + if tex.use_color_ramp: + layout.use_property_split = False + layout.template_color_ramp(tex, "color_ramp", expand=True) class TextureTypePanel(TextureButtonsPanel): diff --git a/release/scripts/startup/bl_ui/properties_view_layer.py b/release/scripts/startup/bl_ui/properties_view_layer.py index 85fde8fb748..6ce53445299 100644 --- a/release/scripts/startup/bl_ui/properties_view_layer.py +++ b/release/scripts/startup/bl_ui/properties_view_layer.py @@ -38,6 +38,7 @@ class VIEWLAYER_PT_layer(ViewLayerButtonsPanel, Panel): def draw(self, context): layout = self.layout + layout.use_property_split = True scene = context.scene rd = scene.render @@ -54,26 +55,20 @@ class VIEWLAYER_PT_eevee_layer_passes(ViewLayerButtonsPanel, Panel): def draw(self, context): layout = self.layout + layout.use_property_split = True scene = context.scene rd = scene.render view_layer = context.view_layer - split = layout.split() - - col = split.column() + col = layout.column() col.prop(view_layer, "use_pass_combined") col.prop(view_layer, "use_pass_z") col.prop(view_layer, "use_pass_mist") col.prop(view_layer, "use_pass_normal") - col.separator() col.prop(view_layer, "use_pass_ambient_occlusion") - - col = split.column() - col.label(text="Subsurface:") - row = col.row(align=True) - row.prop(view_layer, "use_pass_subsurface_direct", text="Direct", toggle=True) - row.prop(view_layer, "use_pass_subsurface_color", text="Color", toggle=True) + col.prop(view_layer, "use_pass_subsurface_direct", text="Subsurface Direct") + col.prop(view_layer, "use_pass_subsurface_color", text="Subsurface Color") class VIEWLAYER_UL_override_sets(UIList): diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py index 1ec2d4774e8..bba7f9e132a 100644 --- a/release/scripts/startup/bl_ui/properties_world.py +++ b/release/scripts/startup/bl_ui/properties_world.py @@ -74,13 +74,12 @@ class EEVEE_WORLD_PT_mist(WorldButtonsPanel, Panel): def draw(self, context): layout = self.layout + layout.use_property_split = True world = context.world - split = layout.split(align=True) - split.prop(world.mist_settings, "start") - split.prop(world.mist_settings, "depth") - + layout.prop(world.mist_settings, "start") + layout.prop(world.mist_settings, "depth") layout.prop(world.mist_settings, "falloff") diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 91e725b451d..d4ae3121a88 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -279,7 +279,7 @@ class CLIP_PT_tracking_settings(CLIP_PT_tracking_panel, Panel): bl_category = "Track" def draw_header_preset(self, context): - CLIP_MT_tracking_settings_presets.draw_panel_header(self.layout) + CLIP_PT_tracking_settings_presets.draw_panel_header(self.layout) def draw(self, context): @@ -621,7 +621,7 @@ class CLIP_PT_track(CLIP_PT_tracking_panel, Panel): layout.separator() row = layout.row(align=True) - CLIP_MT_track_color_presets.draw_menu(row, 'Color Presets') + CLIP_PT_track_color_presets.draw_menu(row, 'Color Presets') row.menu('CLIP_MT_track_color_specials', text="", icon='DOWNARROW_HLT') row = layout.row() @@ -713,7 +713,7 @@ class CLIP_PT_tracking_camera(Panel): return False def draw_header_preset(self, context): - CLIP_MT_camera_presets.draw_panel_header(self.layout) + CLIP_PT_camera_presets.draw_panel_header(self.layout) def draw(self, context): layout = self.layout @@ -1419,7 +1419,7 @@ class CLIP_MT_tracking_specials(Menu): text="Unlock Tracks").action = 'UNLOCK' -class CLIP_MT_camera_presets(PresetMenu): +class CLIP_PT_camera_presets(PresetMenu): """Predefined tracking camera intrinsics""" bl_label = "Camera Presets" preset_subdir = "tracking_camera" @@ -1427,7 +1427,7 @@ class CLIP_MT_camera_presets(PresetMenu): preset_add_operator = "clip.camera_preset_add" -class CLIP_MT_track_color_presets(PresetMenu): +class CLIP_PT_track_color_presets(PresetMenu): """Predefined track color""" bl_label = "Color Presets" preset_subdir = "tracking_track_color" @@ -1435,7 +1435,7 @@ class CLIP_MT_track_color_presets(PresetMenu): preset_add_operator = "clip.track_color_preset_add" -class CLIP_MT_tracking_settings_presets(PresetMenu): +class CLIP_PT_tracking_settings_presets(PresetMenu): """Predefined tracking settings""" bl_label = "Tracking Presets" preset_subdir = "tracking_settings" @@ -1524,9 +1524,9 @@ classes = ( CLIP_MT_select, CLIP_MT_select_grouped, CLIP_MT_tracking_specials, - CLIP_MT_camera_presets, - CLIP_MT_track_color_presets, - CLIP_MT_tracking_settings_presets, + CLIP_PT_camera_presets, + CLIP_PT_track_color_presets, + CLIP_PT_tracking_settings_presets, CLIP_MT_track_color_specials, CLIP_MT_stabilize_2d_specials, CLIP_MT_stabilize_2d_rotation_specials, diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index a238e81d868..7208135f5e6 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -19,12 +19,12 @@ # <pep8 compliant> import bpy -from bpy.types import Header, Menu +from bpy.types import Header, Menu, Panel from .space_time import * ####################################### -# DopeSheet Filtering +# DopeSheet Filtering - Header Buttons # used for DopeSheet, NLA, and Graph Editors def dopesheet_filter(layout, context, genericFiltersOnly=False): @@ -43,66 +43,153 @@ def dopesheet_filter(layout, context, genericFiltersOnly=False): if not genericFiltersOnly: if bpy.data.collections: row = layout.row(align=True) - row.prop(dopesheet, "show_only_collection_objects", text="") - if dopesheet.show_only_collection_objects: - row.prop(dopesheet, "filter_collection", text="") + row.prop(dopesheet, "filter_collection", text="") if not is_nla: row = layout.row(align=True) - row.prop(dopesheet, "show_only_matching_fcurves", text="") - if dopesheet.show_only_matching_fcurves: - row.prop(dopesheet, "filter_fcurve_name", text="") - row.prop(dopesheet, "use_multi_word_filter", text="") + row.prop(dopesheet, "filter_fcurve_name", text="") + row.prop(dopesheet, "use_multi_word_filter", text="") else: row = layout.row(align=True) - row.prop(dopesheet, "use_filter_text", text="") - if dopesheet.use_filter_text: + row.prop(dopesheet, "filter_text", text="") + row.prop(dopesheet, "use_multi_word_filter", text="") + +####################################### +# Dopesheet Filtering Popovers + +# Generic Layout - Used as base for filtering popovers used in all animation editors +# Used for DopeSheet, NLA, and Graph Editors +class DopesheetFilterPopoverBase: + bl_region_type = 'HEADER' + bl_label = "Filters" + + # Generic = Affects all datatypes + # XXX: Perhaps we want these to stay in the header instead, for easy/fast access + @classmethod + def draw_generic_filters(cls, context, layout): + dopesheet = context.space_data.dopesheet + is_nla = context.area.type == 'NLA_EDITOR' + + col = layout.column(align=True) + col.prop(dopesheet, "show_only_selected", icon='NONE') + col.prop(dopesheet, "show_hidden", icon='NONE') + + if is_nla: + col.prop(dopesheet, "show_missing_nla", icon='NONE') + else: # graph and dopesheet editors - F-Curves and drivers only + col.prop(dopesheet, "show_only_errors", icon='NONE') + + # Name/Membership Filters + # XXX: Perhaps these should just stay in the headers (exclusively)? + @classmethod + def draw_search_filters(cls, context, layout, generic_filters_only=False): + dopesheet = context.space_data.dopesheet + is_nla = context.area.type == 'NLA_EDITOR' + + col = layout.column(align=True) + col.label("With Name:") + if not is_nla: + row = col.row(align=True) + row.prop(dopesheet, "filter_fcurve_name", text="") + row.prop(dopesheet, "use_multi_word_filter", text="") + else: + row = col.row(align=True) row.prop(dopesheet, "filter_text", text="") row.prop(dopesheet, "use_multi_word_filter", text="") - if not genericFiltersOnly: - row = layout.row(align=True) - row.prop(dopesheet, "show_datablock_filters", text="Filters") - - if dopesheet.show_datablock_filters: - row.prop(dopesheet, "show_scenes", text="") - row.prop(dopesheet, "show_worlds", text="") - row.prop(dopesheet, "show_nodes", text="") - - row.prop(dopesheet, "show_transforms", text="") - - if bpy.data.meshes: - row.prop(dopesheet, "show_meshes", text="") - if bpy.data.shape_keys: - row.prop(dopesheet, "show_shapekeys", text="") - if bpy.data.meshes: - row.prop(dopesheet, "show_modifiers", text="") - if bpy.data.materials: - row.prop(dopesheet, "show_materials", text="") - if bpy.data.lamps: - row.prop(dopesheet, "show_lamps", text="") - if bpy.data.textures: - row.prop(dopesheet, "show_textures", text="") - if bpy.data.cameras: - row.prop(dopesheet, "show_cameras", text="") - if bpy.data.curves: - row.prop(dopesheet, "show_curves", text="") - if bpy.data.metaballs: - row.prop(dopesheet, "show_metaballs", text="") - if bpy.data.lattices: - row.prop(dopesheet, "show_lattices", text="") - if bpy.data.armatures: - row.prop(dopesheet, "show_armatures", text="") - if bpy.data.particles: - row.prop(dopesheet, "show_particles", text="") - if bpy.data.speakers: - row.prop(dopesheet, "show_speakers", text="") - if bpy.data.linestyles: - row.prop(dopesheet, "show_linestyles", text="") - if bpy.data.grease_pencil: - row.prop(dopesheet, "show_gpencil", text="") - - layout.prop(dopesheet, "use_datablock_sort", text="") + if (not generic_filters_only) and (bpy.data.collections): + col = layout.column(align=True) + col.label("In Collection:") + col.prop(dopesheet, "filter_collection", text="") + + # Standard = Present in all panels + @classmethod + def draw_standard_filters(cls, context, layout): + dopesheet = context.space_data.dopesheet + + # Object Data Filters + layout.label("Include Sub-Object Data:") + split = layout.split() + + # TODO: Add per-channel/axis convenience toggles? + col = split.column() + col.prop(dopesheet, "show_transforms", text="Transforms") + + col = split.column() + col.prop(dopesheet, "show_modifiers", text="Modifiers") + + layout.separator() + + # datablock filters + layout.label("Include From Types:") + flow = layout.grid_flow(row_major=True, num_columns=2, even_rows=False, align=False) + + flow.prop(dopesheet, "show_scenes", text="Scenes") + flow.prop(dopesheet, "show_worlds", text="Worlds") + flow.prop(dopesheet, "show_nodes", text="Node Trees") + + if bpy.data.armatures: + flow.prop(dopesheet, "show_armatures", text="Armatures") + if bpy.data.cameras: + flow.prop(dopesheet, "show_cameras", text="Cameras") + if bpy.data.grease_pencil: + flow.prop(dopesheet, "show_gpencil", text="Grease Pencil Objects") + if bpy.data.lamps: + flow.prop(dopesheet, "show_lamps", text="Lamps") + if bpy.data.materials: + flow.prop(dopesheet, "show_materials", text="Materials") + if bpy.data.textures: + flow.prop(dopesheet, "show_textures", text="Textures") + if bpy.data.meshes: + flow.prop(dopesheet, "show_meshes", text="Meshes") + if bpy.data.shape_keys: + flow.prop(dopesheet, "show_shapekeys", text="Shape Keys") + if bpy.data.curves: + flow.prop(dopesheet, "show_curves", text="Curves") + if bpy.data.particles: + flow.prop(dopesheet, "show_particles", text="Particles") + if bpy.data.lattices: + flow.prop(dopesheet, "show_lattices", text="Lattices") + if bpy.data.linestyles: + flow.prop(dopesheet, "show_linestyles", text="Line Styles") + if bpy.data.metaballs: + flow.prop(dopesheet, "show_metaballs", text="Metas") + if bpy.data.speakers: + flow.prop(dopesheet, "show_speakers", text="Speakers") + + layout.separator() + + # performance-related options (users will mostly have these enabled) + col = layout.column(align=True) + col.label("Options:") + col.prop(dopesheet, "use_datablock_sort", icon='NONE') + + +# Popover for Dopesheet Editor(s) - Dopesheet, Action, Shapekey, GPencil, Mask, etc. +class DOPESHEET_PT_filters(DopesheetFilterPopoverBase, Panel): + bl_space_type = 'DOPESHEET_EDITOR' + bl_region_type = 'HEADER' + bl_label = "Filters" + + def draw(self, context): + layout = self.layout + + dopesheet = context.space_data.dopesheet + ds_mode = context.space_data.mode + + layout.prop(dopesheet, "show_summary", text="Summary") + + DopesheetFilterPopoverBase.draw_generic_filters(context, layout) + + if ds_mode in {'DOPESHEET', 'ACTION', 'GPENCIL'}: + layout.separator() + generic_filters_only = ds_mode != 'DOPESHEET' + DopesheetFilterPopoverBase.draw_search_filters(context, layout, + generic_filters_only=generic_filters_only) + + if ds_mode == 'DOPESHEET': + layout.separator() + DopesheetFilterPopoverBase.draw_standard_filters(context, layout) ####################################### @@ -119,19 +206,21 @@ class DOPESHEET_HT_header(Header): row = layout.row(align=True) row.template_header() - # XXX: perhaps our mode menu can be retired eventually when we get editor submodes in the main menu? - layout.prop(st, "mode", text="") - if st.mode == 'TIMELINE': TIME_MT_editor_menus.draw_collapsible(context, layout) TIME_HT_editor_buttons.draw_header(context, layout) else: + layout.prop(st, "ui_mode", text="") + layout.popover(space_type='DOPESHEET_EDITOR', + region_type='HEADER', + panel_type="DOPESHEET_PT_filters", + text="", + icon='FILTER') DOPESHEET_MT_editor_menus.draw_collapsible(context, layout) DOPESHEET_HT_editor_buttons.draw_header(context, layout) # Header for "normal" dopesheet editor modes (e.g. Dope Sheet, Action, Shape Keys, etc.) -# XXX: Temporary, until we have editor submodes in the actual editors menu class DOPESHEET_HT_editor_buttons(Header): bl_idname = "DOPESHEET_HT_editor_buttons" bl_space_type = 'DOPESHEET_EDITOR' @@ -146,6 +235,7 @@ class DOPESHEET_HT_editor_buttons(Header): toolsettings = context.tool_settings if st.mode in {'ACTION', 'SHAPEKEY'}: + # TODO: These buttons need some tidying up - Probably by using a popover, and bypassing the template_id() here row = layout.row(align=True) row.operator("action.layer_prev", text="", icon='TRIA_DOWN') row.operator("action.layer_next", text="", icon='TRIA_UP') @@ -156,7 +246,7 @@ class DOPESHEET_HT_editor_buttons(Header): row.operator("action.push_down", text="Push Down", icon='NLA_PUSHDOWN') row.operator("action.stash", text="Stash", icon='FREEZE') - layout.prop(st.dopesheet, "show_summary", text="Summary") + # layout.separator_spacer() if st.mode == 'DOPESHEET': dopesheet_filter(layout, context) @@ -174,10 +264,8 @@ class DOPESHEET_HT_editor_buttons(Header): row.prop(st.dopesheet, "show_hidden", text="") row = layout.row(align=True) - row.prop(st.dopesheet, "use_filter_text", text="") - if st.dopesheet.use_filter_text: - row.prop(st.dopesheet, "filter_text", text="") - row.prop(st.dopesheet, "use_multi_word_filter", text="") + row.prop(st.dopesheet, "filter_text", text="") + row.prop(st.dopesheet, "use_multi_word_filter", text="") layout.separator_spacer() @@ -545,6 +633,7 @@ classes = ( DOPESHEET_MT_delete, DOPESHEET_MT_specials, DOPESHEET_MT_channel_specials, + DOPESHEET_PT_filters, ) if __name__ == "__main__": # only for live edit. diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py index e655f9d5d15..9a22e0b4bd7 100644 --- a/release/scripts/startup/bl_ui/space_graph.py +++ b/release/scripts/startup/bl_ui/space_graph.py @@ -19,15 +19,17 @@ # <pep8 compliant> import bpy -from bpy.types import Header, Menu +from bpy.types import Header, Menu, Panel +from .space_dopesheet import ( + DopesheetFilterPopoverBase, + dopesheet_filter, + ) class GRAPH_HT_header(Header): bl_space_type = 'GRAPH_EDITOR' def draw(self, context): - from .space_dopesheet import dopesheet_filter - layout = self.layout toolsettings = context.tool_settings @@ -36,7 +38,14 @@ class GRAPH_HT_header(Header): row = layout.row(align=True) row.template_header() - layout.prop(st, "mode", text="") + # Now a exposed as a sub-space type + # layout.prop(st, "mode", text="") + + layout.popover(space_type='GRAPH_EDITOR', + region_type='HEADER', + panel_type="GRAPH_PT_filters", + text="", + icon='FILTER') GRAPH_MT_editor_menus.draw_collapsible(context, layout) @@ -71,6 +80,21 @@ class GRAPH_HT_header(Header): row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED') +class GRAPH_PT_filters(DopesheetFilterPopoverBase, Panel): + bl_space_type = 'GRAPH_EDITOR' + bl_region_type = 'HEADER' + bl_label = "Filters" + + def draw(self, context): + layout = self.layout + + DopesheetFilterPopoverBase.draw_generic_filters(context, layout) + layout.separator() + DopesheetFilterPopoverBase.draw_search_filters(context, layout) + layout.separator() + DopesheetFilterPopoverBase.draw_standard_filters(context, layout) + + class GRAPH_MT_editor_menus(Menu): bl_idname = "GRAPH_MT_editor_menus" bl_label = "" @@ -381,6 +405,7 @@ classes = ( GRAPH_MT_delete, GRAPH_MT_specials, GRAPH_MT_channel_specials, + GRAPH_PT_filters, ) if __name__ == "__main__": # only for live edit. diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py index 607e2d28d0f..9f23420298f 100644 --- a/release/scripts/startup/bl_ui/space_nla.py +++ b/release/scripts/startup/bl_ui/space_nla.py @@ -19,15 +19,17 @@ # <pep8 compliant> import bpy -from bpy.types import Header, Menu +from bpy.types import Header, Menu, Panel +from .space_dopesheet import ( + DopesheetFilterPopoverBase, + dopesheet_filter, + ) class NLA_HT_header(Header): bl_space_type = 'NLA_EDITOR' def draw(self, context): - from .space_dopesheet import dopesheet_filter - layout = self.layout st = context.space_data @@ -35,6 +37,12 @@ class NLA_HT_header(Header): row = layout.row(align=True) row.template_header() + layout.popover(space_type='NLA_EDITOR', + region_type='HEADER', + panel_type="NLA_PT_filters", + text="", + icon='FILTER') + NLA_MT_editor_menus.draw_collapsible(context, layout) dopesheet_filter(layout, context) @@ -43,6 +51,21 @@ class NLA_HT_header(Header): layout.prop(st, "auto_snap", text="") +class NLA_PT_filters(DopesheetFilterPopoverBase, Panel): + bl_space_type = 'NLA_EDITOR' + bl_region_type = 'HEADER' + bl_label = "Filters" + + def draw(self, context): + layout = self.layout + + DopesheetFilterPopoverBase.draw_generic_filters(context, layout) + layout.separator() + DopesheetFilterPopoverBase.draw_search_filters(context, layout) + layout.separator() + DopesheetFilterPopoverBase.draw_standard_filters(context, layout) + + class NLA_MT_editor_menus(Menu): bl_idname = "NLA_MT_editor_menus" bl_label = "" @@ -218,6 +241,7 @@ classes = ( NLA_MT_marker, NLA_MT_add, NLA_MT_edit_transform, + NLA_PT_filters, ) if __name__ == "__main__": # only for live edit. diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index 7c9c47f8eb8..521c510ad2d 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -290,7 +290,7 @@ class NODE_MT_node(Menu): layout.operator("node.read_fullsamplelayers") -class NODE_MT_node_color_presets(PresetMenu): +class NODE_PT_node_color_presets(PresetMenu): """Predefined node color""" bl_label = "Color Presets" preset_subdir = "node_color" @@ -375,7 +375,7 @@ class NODE_PT_active_node_color(Panel): self.layout.prop(node, "use_custom_color", text="") def draw_header_preset(self, context): - NODE_MT_node_color_presets.draw_panel_header(self.layout) + NODE_PT_node_color_presets.draw_panel_header(self.layout) def draw(self, context): layout = self.layout @@ -584,7 +584,7 @@ classes = ( NODE_MT_view, NODE_MT_select, NODE_MT_node, - NODE_MT_node_color_presets, + NODE_PT_node_color_presets, NODE_MT_node_color_specials, NODE_MT_specials, NODE_PT_active_node_generic, diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py index 9a27985a352..44813b699a2 100644 --- a/release/scripts/startup/bl_ui/space_outliner.py +++ b/release/scripts/startup/bl_ui/space_outliner.py @@ -35,7 +35,17 @@ class OUTLINER_HT_header(Header): row = layout.row(align=True) row.template_header() - layout.prop(space, "display_mode", text="") + layout.prop(space, "display_mode", icon_only=True) + + if display_mode in {'VIEW_LAYER'}: + layout.operator("outliner.collection_new", text="", icon='GROUP').nested = True + + layout.separator_spacer() + + row = layout.row(align=True) + row.prop(space, "filter_text", icon='VIEWZOOM', text="") + + layout.separator_spacer() row = layout.row(align=True) if display_mode in {'VIEW_LAYER'}: @@ -50,8 +60,6 @@ class OUTLINER_HT_header(Header): sub.active = space.use_filter_id_type sub.prop(space, "filter_id_type", text="", icon_only=True) - OUTLINER_MT_editor_menus.draw_collapsible(context, layout) - if space.display_mode == 'DATA_API': layout.separator() @@ -70,12 +78,7 @@ class OUTLINER_HT_header(Header): row = layout.row() row.label(text="No Keying Set Active") - row = layout.row(align=True) - row.prop(space, "use_filter_search", text="") - if space.use_filter_search: - row.prop(space, "filter_text", text="") - row.prop(space, "use_filter_complete", text="") - row.prop(space, "use_filter_case_sensitive", text="") + OUTLINER_MT_editor_menus.draw_collapsible(context, layout) class OUTLINER_MT_editor_menus(Menu): @@ -106,12 +109,19 @@ class OUTLINER_MT_view(Menu): space = context.space_data + layout.prop(space, "use_filter_complete", text="Exact Match Search") + layout.prop(space, "use_filter_case_sensitive", text="Case Sensitive Search") + + layout.separator() + if space.display_mode != 'DATA_API': layout.prop(space, "use_sort_alpha") layout.prop(space, "show_restrict_columns") layout.separator() layout.operator("outliner.show_active") + layout.separator() + layout.operator("outliner.show_one_level", text="Show One Level") layout.operator("outliner.show_one_level", text="Hide One Level").open = False layout.operator("outliner.show_hierarchy") @@ -205,6 +215,8 @@ class OUTLINER_MT_object(Menu): layout = self.layout space = context.space_data + obj = context.active_object + object_mode = 'OBJECT' if obj is None else obj.mode layout.operator("outliner.object_operation", text="Delete").type = 'DELETE' if space.display_mode == 'VIEW_LAYER' and not space.use_filter_collection: @@ -218,6 +230,14 @@ class OUTLINER_MT_object(Menu): layout.separator() + if object_mode in {'EDIT', 'POSE'}: + name = bpy.types.Object.bl_rna.properties["mode"].enum_items[object_mode].name + layout.operator("outliner.object_operation", text=f"{name} Set").type = 'OBJECT_MODE_ENTER' + layout.operator("outliner.object_operation", text=f"{name} Clear").type = 'OBJECT_MODE_EXIT' + del name + + layout.separator() + if not (space.display_mode == 'VIEW_LAYER' and not space.use_filter_collection): layout.operator("outliner.id_operation", text="Unlink").type = 'UNLINK' layout.separator() diff --git a/release/scripts/startup/bl_ui/space_statusbar.py b/release/scripts/startup/bl_ui/space_statusbar.py index 3a6fc4925d8..a738eb315e7 100644 --- a/release/scripts/startup/bl_ui/space_statusbar.py +++ b/release/scripts/startup/bl_ui/space_statusbar.py @@ -39,11 +39,7 @@ class STATUSBAR_HT_header(Header): def draw_left(self, context): layout = self.layout - row = layout.row(align=True) - if (bpy.data.filepath): - row.label(text=bpy.data.filepath, translate=False) - if bpy.data.is_dirty: - row.label("(Modified)") + layout.template_cursor_keymap() def draw_center(self, context): layout = self.layout diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index c1331425572..c5c17d2c3cb 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -83,6 +83,12 @@ def generate_from_brushes_ex( class _defs_view3d_generic: @ToolDef.from_fn def cursor(): + def draw_settings(context, layout, tool): + wm = context.window_manager + props = tool.operator_properties("view3d.cursor3d") + layout.prop(props, "use_depth") + layout.prop(props, "orientation") + return dict( text="Cursor", icon="ops.generic.cursor", @@ -93,6 +99,7 @@ class _defs_view3d_generic: dict(type='EVT_TWEAK_A', value='ANY'), ), ), + draw_settings=draw_settings, ) @ToolDef.from_fn @@ -166,11 +173,16 @@ class _defs_transform: @ToolDef.from_fn def transform(): + def draw_settings(context, layout, tool): + tool_settings = context.tool_settings + layout.prop(tool_settings, "use_manipulator_mode") + return dict( text="Transform", icon="ops.transform.transform", widget="TRANSFORM_WGT_manipulator", # No keymap default action, only for manipulators! + draw_settings=draw_settings, ) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index e7f667f5d5f..90917d52724 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -73,9 +73,9 @@ class USERPREF_HT_header(Header): layout.operator("wm.addon_refresh", icon='FILE_REFRESH') layout.menu("USERPREF_MT_addons_online_resources") elif userpref.active_section == 'LIGHTS': - layout.operator('wm.studiolight_install', text="Install MatCap").orientation='MATCAP' - layout.operator('wm.studiolight_install', text="Install World HDRI").orientation='WORLD' - layout.operator('wm.studiolight_install', text="Install Camera HDRI").orientation='CAMERA' + layout.operator('wm.studiolight_install', text="Install MatCap").orientation = 'MATCAP' + layout.operator('wm.studiolight_install', text="Install World HDRI").orientation = 'WORLD' + layout.operator('wm.studiolight_install', text="Install Camera HDRI").orientation = 'CAMERA' elif userpref.active_section == 'THEMES': layout.operator("ui.reset_default_theme") layout.operator("wm.theme_install") @@ -230,7 +230,6 @@ class USERPREF_PT_interface(Panel): col.prop(view, "ui_scale", text="Scale") col.prop(view, "ui_line_width", text="Line Width") col.prop(view, "show_tooltips") - col.prop(view, "show_tooltips_python") col.prop(view, "show_object_info", text="Object Info") col.prop(view, "show_large_cursors") col.prop(view, "show_view_name", text="View Name") @@ -238,19 +237,39 @@ class USERPREF_PT_interface(Panel): col.prop(view, "object_origin_size") col.separator() - col.separator() - col.separator() - col.prop(view, "show_mini_axis", text="Display Mini Axis") - sub = col.column() + col.prop(view, "show_manipulator_navigate") + + sub = col.column(align=True) + + sub.prop(view, "show_mini_axis", text="Display Mini Axis") + sub.active = not view.show_manipulator_navigate + + sub = col.column(align=True) sub.active = view.show_mini_axis sub.prop(view, "mini_axis_size", text="Size") sub.prop(view, "mini_axis_brightness", text="Brightness") col.separator() - col.label("Warnings") - col.prop(view, "use_quit_dialog") + # Toolbox doesn't exist yet + # col.label(text="Toolbox:") + #col.prop(view, "show_column_layout") + #col.label(text="Open Toolbox Delay:") + #col.prop(view, "open_left_mouse_delay", text="Hold LMB") + #col.prop(view, "open_right_mouse_delay", text="Hold RMB") + col.prop(view, "show_manipulator", text="Transform Manipulator") + # Currently not working + # col.prop(view, "show_manipulator_shaded") + sub = col.column() + sub.active = view.show_manipulator + sub.prop(view, "manipulator_size", text="Size") + + col.separator() + + col.label("Development") + col.prop(view, "show_tooltips_python") + col.prop(view, "show_developer_ui") row.separator() row.separator() @@ -286,24 +305,6 @@ class USERPREF_PT_interface(Panel): row.separator() col = row.column() - # Toolbox doesn't exist yet - # col.label(text="Toolbox:") - #col.prop(view, "show_column_layout") - #col.label(text="Open Toolbox Delay:") - #col.prop(view, "open_left_mouse_delay", text="Hold LMB") - #col.prop(view, "open_right_mouse_delay", text="Hold RMB") - col.prop(view, "show_manipulator") - # Currently not working - # col.prop(view, "show_manipulator_shaded") - sub = col.column() - sub.active = view.show_manipulator - sub.prop(view, "manipulator_size", text="Size") - - col.prop(view, "show_manipulator_navigate") - - col.separator() - col.separator() - col.separator() col.label(text="Menus:") col.prop(view, "use_mouse_over_open") @@ -324,6 +325,10 @@ class USERPREF_PT_interface(Panel): col.separator() col.prop(view, "show_splash") + + col.label("Warnings") + col.prop(view, "use_quit_dialog") + col.separator() col.label(text="App Template:") @@ -1440,12 +1445,13 @@ class USERPREF_PT_addons(Panel): continue # check if addon should be visible with current filters - if ((filter == "All") or - (filter == info["category"]) or - (filter == "Enabled" and is_enabled) or + if ( + (filter == "All") or + (filter == info["category"]) or + (filter == "Enabled" and is_enabled) or (filter == "Disabled" and not is_enabled) or (filter == "User" and (mod.__file__.startswith((scripts_addons_folder, userpref_addons_folder)))) - ): + ): if search and search not in info["name"].lower(): if info["author"]: if search not in info["author"].lower(): diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index c9768f54ba0..6645a1b12ef 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -65,9 +65,11 @@ class VIEW3D_HT_header(Header): row.prop(tool_settings.particle_edit, "select_mode", text="", expand=True) # Occlude geometry - if ((((shading.type not in {'SOLID', 'TEXTURED'}) or not shading.show_xray) and - (object_mode == 'PARTICLE_EDIT' or (object_mode == 'EDIT' and obj.type == 'MESH'))) or - (object_mode in {'WEIGHT_PAINT', 'VERTEX_PAINT'})): + if ( + (((shading.type not in {'SOLID', 'TEXTURED'}) or not shading.show_xray) and + (object_mode == 'PARTICLE_EDIT' or (object_mode == 'EDIT' and obj.type == 'MESH'))) or + (object_mode in {'WEIGHT_PAINT', 'VERTEX_PAINT'}) + ): row = layout.row() row.prop(view, "use_occlude_geometry", text="") @@ -195,7 +197,7 @@ class VIEW3D_HT_header(Header): sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_shading") row = layout.row(align=True) - row.prop(overlay, "show_overlays", icon="WIRE", text="") + row.prop(overlay, "show_overlays", icon='WIRE', text="") sub = row.row(align=True) sub.active = overlay.show_overlays @@ -1517,6 +1519,10 @@ class VIEW3D_MT_object(Menu): layout.separator() + layout.menu("VIEW3D_MT_object_showhide") + + layout.separator() + layout.operator("object.delete", text="Delete...").use_global = False @@ -1873,6 +1879,20 @@ class VIEW3D_MT_object_quick_effects(Menu): layout.operator("object.quick_fluid") +class VIEW3D_MT_object_showhide(Menu): + bl_label = "Show/Hide" + + def draw(self, context): + layout = self.layout + + layout.operator("object.hide_view_clear", text="Show Hidden") + + layout.separator() + + layout.operator("object.hide_view_set", text="Hide Selected").unselected = False + layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True + + class VIEW3D_MT_make_single_user(Menu): bl_label = "Make Single User" @@ -2626,7 +2646,7 @@ class VIEW3D_MT_edit_mesh_specials(Menu): layout.operator("mesh.merge", text="Merge Vertices...") layout.operator("mesh.remove_doubles", text="Remove Double Vertices") layout.operator("mesh.dissolve_verts") - layout.operator("mesh.delete", text="Delete Vertices").type = "VERT" + layout.operator("mesh.delete", text="Delete Vertices").type = 'VERT' # Edge Select Commands if select_mode[1]: @@ -2637,7 +2657,7 @@ class VIEW3D_MT_edit_mesh_specials(Menu): layout.separator() layout.operator("mesh.dissolve_edges") - layout.operator("mesh.delete", text="Delete Edges").type = "EDGE" + layout.operator("mesh.delete", text="Delete Edges").type = 'EDGE' # Face Select Commands if select_mode[2]: @@ -2667,7 +2687,7 @@ class VIEW3D_MT_edit_mesh_specials(Menu): layout.separator() layout.operator("mesh.dissolve_faces") - layout.operator("mesh.delete", text="Delete Faces").type = "FACE" + layout.operator("mesh.delete", text="Delete Faces").type = 'FACE' # General Mesh Commands @@ -2953,17 +2973,21 @@ class VIEW3D_MT_edit_mesh_shading(Menu): def draw(self, context): layout = self.layout - layout.label(text="Faces:") - layout.operator("mesh.faces_shade_smooth", text="Smooth") - layout.operator("mesh.faces_shade_flat", text="Flat") - layout.label(text="Edges:") - layout.operator("mesh.mark_sharp", text="Smooth").clear = True - layout.operator("mesh.mark_sharp", text="Sharp") - layout.label(text="Vertices:") - props = layout.operator("mesh.mark_sharp", text="Smooth") + layout.operator("mesh.faces_shade_smooth", text="Smooth Faces") + layout.operator("mesh.faces_shade_flat", text="Flat Faces") + + layout.separator() + + layout.operator("mesh.mark_sharp", text="Smooth Edges").clear = True + layout.operator("mesh.mark_sharp", text="Sharp Edges") + + layout.separator() + + props = layout.operator("mesh.mark_sharp", text="Smooth Vertices") props.use_verts = True props.clear = True - layout.operator("mesh.mark_sharp", text="Sharp").use_verts = True + + layout.operator("mesh.mark_sharp", text="Sharp Vertices").use_verts = True class VIEW3D_MT_edit_mesh_weights(Menu): @@ -3493,7 +3517,7 @@ class VIEW3D_MT_edit_gpencil_interpolate(Menu): layout.operator("gpencil.interpolate_sequence", text="Sequence") -class VIEW3D_PIE_object_mode(Menu): +class VIEW3D_MT_object_mode_pie(Menu): bl_label = "Mode" def draw(self, context): @@ -3503,9 +3527,9 @@ class VIEW3D_PIE_object_mode(Menu): pie.operator_enum("OBJECT_OT_mode_set", "mode") -class VIEW3D_PIE_view(Menu): +class VIEW3D_MT_view_pie(Menu): bl_label = "View" - bl_idname = "VIEW3D_PIE_view" + bl_idname = "VIEW3D_MT_view_pie" def draw(self, context): layout = self.layout @@ -3626,7 +3650,7 @@ class VIEW3D_PT_shading_lighting(Panel): view = context.space_data shading = view.shading - if shading.type in ('SOLID', 'TEXTURED'): + if shading.type == 'SOLID': layout.row().prop(shading, "light", expand=True) if shading.light == 'STUDIO': row = layout.row() @@ -3643,7 +3667,7 @@ class VIEW3D_PT_shading_lighting(Panel): sub.operator('VIEW3D_OT_toggle_matcap_flip', emboss=False, text="", icon='ARROW_LEFTRIGHT') sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES') - elif shading.type in ('MATERIAL'): + elif shading.type == 'MATERIAL': row = layout.row() row.template_icon_view(shading, "studio_light", show_labels=True) sub = row.column() @@ -3688,7 +3712,7 @@ class VIEW3D_PT_shading_options(Panel): def poll(cls, context): view = context.space_data shading = view.shading - return shading.type in ['SOLID', 'TEXTURED'] + return shading.type == 'SOLID' def draw(self, context): layout = self.layout @@ -3700,35 +3724,34 @@ class VIEW3D_PT_shading_options(Panel): row = layout.row() row.prop(shading, "show_specular_highlight") - if shading.type in ('SOLID', 'TEXTURED'): - row = layout.split(0.4) - row.prop(shading, "show_xray") - sub = row.row() - sub.active = shading.show_xray - sub.prop(shading, "xray_alpha", text="") - - row = layout.split(0.4) - row.active = not shading.show_xray - row.prop(shading, "show_shadows") - sub = row.row() - sub.active = shading.show_shadows and not shading.show_xray - sub.prop(shading, "shadow_intensity", text="") - - row = layout.split(0.4) - row.active = not shading.show_xray - row.prop(shading, "show_cavity") - sub = row.column(align=True) - sub.active = not shading.show_xray and shading.show_cavity - sub.prop(shading, "cavity_ridge_factor") - sub.prop(shading, "cavity_valley_factor") - - row = layout.split(0.4) - row.prop(shading, "show_object_outline") - sub = row.row() - sub.active = shading.show_object_outline - sub.prop(shading, "object_outline_color", text="") - - layout.prop(view, "show_world") + row = layout.split(0.4) + row.prop(shading, "show_xray") + sub = row.row() + sub.active = shading.show_xray + sub.prop(shading, "xray_alpha", text="") + + row = layout.split(0.4) + row.active = not shading.show_xray + row.prop(shading, "show_shadows") + sub = row.row() + sub.active = shading.show_shadows and not shading.show_xray + sub.prop(shading, "shadow_intensity", text="") + + row = layout.split(0.4) + row.active = not shading.show_xray + row.prop(shading, "show_cavity") + sub = row.column(align=True) + sub.active = not shading.show_xray and shading.show_cavity + sub.prop(shading, "cavity_ridge_factor") + sub.prop(shading, "cavity_valley_factor") + + row = layout.split(0.4) + row.prop(shading, "show_object_outline") + sub = row.row() + sub.active = shading.show_object_outline + sub.prop(shading, "object_outline_color", text="") + + layout.prop(view, "show_world") class VIEW3D_PT_overlay(Panel): @@ -3766,7 +3789,7 @@ class VIEW3D_PT_overlay(Panel): #sub.prop(overlay, "show_onion_skins") sub.prop(overlay, "show_face_orientation") sub.prop(overlay, "show_backface_culling") - if shading.type == "MATERIAL": + if shading.type == 'MATERIAL': sub.prop(overlay, "show_look_dev") row = col.row() @@ -3826,6 +3849,7 @@ class VIEW3D_PT_overlay_edit_mesh(Panel): data = context.active_object.data statvis = tool_settings.statvis with_freestyle = bpy.app.build_options.freestyle + show_developer_ui = context.user_preferences.view.show_developer_ui col = layout.column() col.active = display_all @@ -3848,7 +3872,7 @@ class VIEW3D_PT_overlay_edit_mesh(Panel): sub.prop(data, "show_extra_face_area", text="Face Area") sub.prop(data, "show_extra_face_angle", text="Face Angle") - if bpy.app.debug: + if show_developer_ui: sub.prop(data, "show_extra_indices", text="Indices") if with_freestyle: @@ -4001,12 +4025,20 @@ class VIEW3D_PT_overlay_paint(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' bl_parent_id = 'VIEW3D_PT_overlay' - bl_label = "Paint" + bl_label = "" @classmethod def poll(cls, context): return context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'} + def draw_header(self, context): + layout = self.layout + layout.label(text={ + 'PAINT_TEXTURE': "Texture Paint", + 'PAINT_VERTEX': "Vertex Paint", + 'PAINT_WEIGHT': "Weight Paint", + }[context.mode]) + def draw(self, context): layout = self.layout view = context.space_data @@ -4016,11 +4048,15 @@ class VIEW3D_PT_overlay_paint(Panel): col = layout.column() col.active = display_all + col.prop(overlay, { + 'PAINT_TEXTURE': "texture_paint_mode_opacity", + 'PAINT_VERTEX': "vertex_paint_mode_opacity", + 'PAINT_WEIGHT': "weight_paint_mode_opacity", + }[context.mode], text="Opacity") + if context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX'}: col.prop(overlay, "show_paint_wire") - col.prop(view, "show_mode_shade_override") - class VIEW3D_PT_quad_view(Panel): bl_space_type = 'VIEW_3D' @@ -4217,6 +4253,7 @@ classes = ( VIEW3D_MT_object_collection, VIEW3D_MT_object_constraints, VIEW3D_MT_object_quick_effects, + VIEW3D_MT_object_showhide, VIEW3D_MT_make_single_user, VIEW3D_MT_make_links, VIEW3D_MT_brush, @@ -4283,8 +4320,8 @@ classes = ( VIEW3D_MT_edit_armature_delete, VIEW3D_MT_edit_gpencil_transform, VIEW3D_MT_edit_gpencil_interpolate, - VIEW3D_PIE_object_mode, - VIEW3D_PIE_view, + VIEW3D_MT_object_mode_pie, + VIEW3D_MT_view_pie, VIEW3D_PT_grease_pencil, VIEW3D_PT_grease_pencil_palettecolor, VIEW3D_PT_view3d_properties, diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 53947a7d8af..864dcc4b0e9 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1021,7 +1021,6 @@ class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel): row.prop(sculpt, "lock_y", text="Y", toggle=True) row.prop(sculpt, "lock_z", text="Z", toggle=True) - split = layout.split() col = split.column() diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc index 45e2b68f94d..d050f3b78b1 100644 --- a/source/blender/alembic/intern/abc_exporter.cc +++ b/source/blender/alembic/intern/abc_exporter.cc @@ -158,7 +158,7 @@ static bool export_object(const ExportSettings * const settings, const Base * co return false; } // FIXME Sybren: handle these cleanly (maybe just remove code), now using active scene layer instead. - if (settings->visible_layers_only && (ob_base->flag & BASE_VISIBLED) == 0) { + if (settings->visible_layers_only && (ob_base->flag & BASE_VISIBLE) == 0) { return false; } } diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc index cc9923189c7..79dfb8c2b58 100644 --- a/source/blender/alembic/intern/alembic_capi.cc +++ b/source/blender/alembic/intern/alembic_capi.cc @@ -852,6 +852,7 @@ static void import_endjob(void *user_data) base = BKE_view_layer_base_find(view_layer, ob); BKE_view_layer_base_select(view_layer, base); + DEG_id_tag_update(&lc->collection->id, DEG_TAG_COPY_ON_WRITE); DEG_id_tag_update_ex(data->bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME | DEG_TAG_BASE_FLAGS_UPDATE); } diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 1289dc6c5a6..b3ab36f7bcc 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -183,16 +183,13 @@ void blf_batch_draw(void) if (g_batch.glyph_len == 0) return; - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* We need to flush widget base first to ensure correct ordering. */ UI_widgetbase_draw_cache_flush(); - BLI_assert(g_batch.tex_bind_state != 0); /* must still be valid */ - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, g_batch.tex_bind_state); - + GPU_texture_bind(g_batch.tex_bind_state, 0); GWN_vertbuf_vertex_count_set(g_batch.verts, g_batch.glyph_len); GWN_vertbuf_use(g_batch.verts); /* send data */ @@ -201,7 +198,7 @@ void blf_batch_draw(void) GWN_batch_uniform_1i(g_batch.batch, "glyph", 0); GWN_batch_draw(g_batch.batch); - glDisable(GL_BLEND); + GPU_blend(false); /* restart to 1st vertex data pointers */ GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step); @@ -655,7 +652,7 @@ size_t blf_font_width_to_strlen(FontBLF *font, const char *str, size_t len, floa int pen_x = 0; size_t i = 0, i_prev; GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table; - const int width_i = (int)width + 1; + const int width_i = (int)width; int width_new; BLF_KERNING_VARS(font, has_kerning, kern_mode); @@ -677,7 +674,7 @@ size_t blf_font_width_to_strlen(FontBLF *font, const char *str, size_t len, floa pen_x += g->advance_i; - if (width_i < pen_x) { + if (width_i <= pen_x) { break; } diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 5a87c726566..84388bedb7b 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -57,6 +57,7 @@ #ifndef BLF_STANDALONE # include "GPU_immediate.h" +# include "GPU_extensions.h" #endif #include "blf_internal_types.h" @@ -146,7 +147,7 @@ GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); - gc->textures = (GLuint *)MEM_mallocN(sizeof(GLuint) * 256, __func__); + gc->textures = (GPUTexture **)MEM_callocN(sizeof(GPUTexture *) * 256, __func__); gc->textures_len = 256; gc->texture_current = BLF_TEXTURE_UNSET; gc->offset_x = 3; /* enough padding for blur */ @@ -196,16 +197,17 @@ void blf_glyph_cache_clear(FontBLF *font) void blf_glyph_cache_free(GlyphCacheBLF *gc) { GlyphBLF *g; - int i; + unsigned int i; for (i = 0; i < 257; i++) { while ((g = BLI_pophead(&gc->bucket[i]))) { blf_glyph_free(g); } } - - if (gc->texture_current != BLF_TEXTURE_UNSET) { - glDeleteTextures((int)gc->texture_current + 1, gc->textures); + for (i = 0; i < gc->textures_len; i++) { + if (gc->textures[i]) { + GPU_texture_free(gc->textures[i]); + } } MEM_freeN(gc->textures); MEM_freeN(gc); @@ -214,13 +216,14 @@ void blf_glyph_cache_free(GlyphCacheBLF *gc) static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) { int i; + char error[256]; /* move the index. */ gc->texture_current++; if (UNLIKELY(gc->texture_current >= gc->textures_len)) { gc->textures_len *= 2; - gc->textures = MEM_reallocN((void *)gc->textures, sizeof(GLuint) * gc->textures_len); + gc->textures = MEM_recallocN((void *)gc->textures, sizeof(GPUTexture *) * gc->textures_len); } gc->p2_width = (int)blf_next_p2((unsigned int)((gc->glyphs_len_free * gc->glyph_width_max) + (gc->pad * 2))); @@ -235,16 +238,14 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) gc->p2_height = font->tex_size_max; } - glGenTextures(1, &gc->textures[gc->texture_current]); - glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = gc->textures[gc->texture_current])); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - unsigned char *pixels = MEM_callocN((size_t)gc->p2_width * (size_t)gc->p2_height, "BLF texture init"); - glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, gc->p2_width, gc->p2_height, 0, GL_RED, GL_UNSIGNED_BYTE, pixels); + GPUTexture *tex = GPU_texture_create_2D(gc->p2_width, gc->p2_height, GPU_R8, (const float *)pixels, error); MEM_freeN(pixels); + gc->textures[gc->texture_current] = tex; + GPU_texture_bind(tex, 0); + GPU_texture_wrap_mode(tex, false); + GPU_texture_filters(tex, GPU_NEAREST, GPU_LINEAR); + GPU_texture_unbind(tex); } GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c) @@ -437,13 +438,11 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) if ((!g->width) || (!g->height)) return; - glActiveTexture(GL_TEXTURE0); - if (g->build_tex == 0) { GlyphCacheBLF *gc = font->glyph_cache; if (font->tex_size_max == -1) - glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->tex_size_max); + font->tex_size_max = GPU_max_texture_size(); if (gc->texture_current == BLF_TEXTURE_UNSET) { blf_glyph_cache_texture(font, gc); @@ -477,22 +476,7 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) BLI_assert(g->height > 0); } - - GLint lsb_first, row_length, alignment; - glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsb_first); - glGetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length); - glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); - - glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glBindTexture(GL_TEXTURE_2D, g->tex); - glTexSubImage2D(GL_TEXTURE_2D, 0, g->offset_x, g->offset_y, g->width, g->height, GL_RED, GL_UNSIGNED_BYTE, g->bitmap); - - glPixelStorei(GL_UNPACK_LSB_FIRST, lsb_first); - glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); - glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); + GPU_texture_update_sub(g->tex, g->bitmap, g->offset_x, g->offset_y, 0, g->width, g->height, 0); g->uv[0][0] = ((float)g->offset_x) / ((float)gc->p2_width); g->uv[0][1] = ((float)g->offset_y) / ((float)gc->p2_height); @@ -520,7 +504,8 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) if (font->tex_bind_state != g->tex) { blf_batch_draw(); - glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = g->tex)); + font->tex_bind_state = g->tex; + GPU_texture_bind(font->tex_bind_state, 0); } g_batch.tex_bind_state = g->tex; diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index d7b526735d1..999773d0212 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -32,6 +32,7 @@ #define __BLF_INTERNAL_TYPES_H__ #include "../../../intern/gawain/gawain/gwn_vertex_buffer.h" +#include "GPU_texture.h" #define BLF_BATCH_DRAW_LEN_MAX 2048 /* in glyph */ @@ -45,7 +46,7 @@ typedef struct BatchBLF { float ofs[2]; /* copy of font->pos */ float mat[4][4]; /* previous call modelmatrix. */ bool enabled, active, simple_shader; - unsigned int tex_bind_state; + GPUTexture *tex_bind_state; } BatchBLF; extern BatchBLF g_batch; @@ -78,7 +79,7 @@ typedef struct GlyphCacheBLF { struct GlyphBLF *glyph_ascii_table[256]; /* texture array, to draw the glyphs. */ - unsigned int *textures; + GPUTexture **textures; /* size of the array. */ unsigned int textures_len; @@ -133,7 +134,7 @@ typedef struct GlyphBLF { int advance_i; /* texture id where this glyph is store. */ - unsigned int tex; + GPUTexture *tex; /* position inside the texture where this glyph is store. */ int offset_x; @@ -244,7 +245,7 @@ typedef struct FontBLF { int tex_size_max; /* cache current OpenGL texture to save calls into the API */ - unsigned int tex_bind_state; + GPUTexture *tex_bind_state; /* font options. */ int flags; diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 02410f624da..855707aa0b3 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -387,9 +387,6 @@ void DM_to_bmesh_ex(struct DerivedMesh *dm, struct BMesh *bm, const boo struct BMesh *DM_to_bmesh(struct DerivedMesh *dm, const bool calc_face_normal); -/** Utility function to convert a DerivedMesh to a shape key block */ -void DM_to_meshkey(DerivedMesh *dm, struct Mesh *me, struct KeyBlock *kb); - void DM_set_only_copy(DerivedMesh *dm, CustomDataMask mask); /* adds a vertex/edge/face custom data layer to a DerivedMesh, optionally @@ -518,9 +515,6 @@ void DM_interp_poly_data( int *src_indices, float *weights, int count, int dest_index); -/* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */ -void vDM_ColorBand_store(const struct ColorBand *coba, const char alert_color[4]); - /* UNUSED */ #if 0 /** Simple function to get me->totvert amount of vertices/normals, diff --git a/source/blender/blenkernel/BKE_addon.h b/source/blender/blenkernel/BKE_addon.h index e631d1d6537..3af6d3b61bf 100644 --- a/source/blender/blenkernel/BKE_addon.h +++ b/source/blender/blenkernel/BKE_addon.h @@ -51,7 +51,8 @@ void BKE_addon_pref_type_init(void); void BKE_addon_pref_type_free(void); struct bAddon *BKE_addon_new(void); -struct bAddon *BKE_addon_ensure(struct ListBase *addons, const char *module); +struct bAddon *BKE_addon_find(struct ListBase *addon_list, const char *module); +struct bAddon *BKE_addon_ensure(struct ListBase *addon_list, const char *module); void BKE_addon_free(struct bAddon *addon); #endif /* __BKE_ADDON_H__ */ diff --git a/source/blender/blenkernel/BKE_blender_user_menu.h b/source/blender/blenkernel/BKE_blender_user_menu.h new file mode 100644 index 00000000000..ff314314646 --- /dev/null +++ b/source/blender/blenkernel/BKE_blender_user_menu.h @@ -0,0 +1,49 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BKE_BLENDER_USER_MENU_H__ +#define __BKE_BLENDER_USER_MENU_H__ + +/** \file BKE_blender_user_menu.h + * \ingroup bke + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct ListBase; +struct bUserMenu; +struct bUserMenuItem; + +struct bUserMenu *BKE_blender_user_menu_find( + struct ListBase *lb, char space_type, const char *context); +struct bUserMenu *BKE_blender_user_menu_ensure( + struct ListBase *lb, char space_type, const char *context); + +struct bUserMenuItem *BKE_blender_user_menu_item_add(struct ListBase *lb, int type); +void BKE_blender_user_menu_item_free(struct bUserMenuItem *umi); +void BKE_blender_user_menu_item_free_list(struct ListBase *lb); + +#ifdef __cplusplus +} +#endif + +#endif /* __BKE_BLENDER_USER_MENU_H__ */ diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h index eb05e66cf06..476ecb012d8 100644 --- a/source/blender/blenkernel/BKE_camera.h +++ b/source/blender/blenkernel/BKE_camera.h @@ -126,7 +126,7 @@ void BKE_camera_view_frame( bool BKE_camera_view_frame_fit_to_scene( struct Depsgraph *depsgraph, - struct Scene *scene, struct ViewLayer *view_layer, struct Object *camera_ob, + struct Scene *scene, struct Object *camera_ob, float r_co[3], float *r_scale); bool BKE_camera_view_frame_fit_to_coords( const struct Depsgraph *depsgraph, @@ -155,4 +155,3 @@ void BKE_camera_background_image_clear(struct Camera *cam); #endif #endif - diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index f0d8e1a1d84..244054712f1 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -210,10 +210,10 @@ typedef struct ColliderContacts { } ColliderContacts; // needed for implicit.c -int cloth_bvh_objcollision (struct Object *ob, struct ClothModifierData *clmd, float step, float dt ); -int cloth_points_objcollision(struct Object *ob, struct ClothModifierData *clmd, float step, float dt); +int cloth_bvh_objcollision (struct Depsgraph *depsgraph, struct Object *ob, struct ClothModifierData *clmd, float step, float dt ); +int cloth_points_objcollision(struct Depsgraph *depsgraph, struct Object *ob, struct ClothModifierData *clmd, float step, float dt); -void cloth_find_point_contacts(struct Object *ob, struct ClothModifierData *clmd, float step, float dt, +void cloth_find_point_contacts(struct Depsgraph *depsgraph, struct Object *ob, struct ClothModifierData *clmd, float step, float dt, ColliderContacts **r_collider_contacts, int *r_totcolliders); void cloth_free_contacts(ColliderContacts *collider_contacts, int totcolliders); diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h index 7dce3b2c703..175ee61c690 100644 --- a/source/blender/blenkernel/BKE_collection.h +++ b/source/blender/blenkernel/BKE_collection.h @@ -96,10 +96,7 @@ bool BKE_collection_object_cyclic_check(struct Main *bmain, struct Object *objec struct ListBase BKE_collection_object_cache_get(struct Collection *collection); void BKE_collection_object_cache_free(struct Collection *collection); -struct Base *BKE_collection_or_layer_objects(const struct Depsgraph *depsgraph, - const struct Scene *scene, - const struct ViewLayer *view_layer, - struct Collection *collection); +struct Base *BKE_collection_or_layer_objects(const struct ViewLayer *view_layer, struct Collection *collection); /* Editing. */ @@ -141,7 +138,7 @@ void BKE_scene_objects_callback(struct Scene *scene, BKE_scene_objects_Cb callba #define FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(_collection, _object, _mode) \ { \ int _base_flag = (_mode == DAG_EVAL_VIEWPORT) ? \ - BASE_VISIBLE_VIEWPORT : BASE_VISIBLE_RENDER; \ + BASE_ENABLED_VIEWPORT : BASE_ENABLED_RENDER; \ int _base_id = 0; \ for (Base *_base = (Base*)BKE_collection_object_cache_get(_collection).first; \ _base; \ diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h index 2392c92bd84..a488851513c 100644 --- a/source/blender/blenkernel/BKE_collision.h +++ b/source/blender/blenkernel/BKE_collision.h @@ -49,6 +49,7 @@ struct MFace; struct MVert; struct Object; struct Scene; +struct Depsgraph; struct MVertTri; //////////////////////////////////////// @@ -143,14 +144,29 @@ void collision_move_object(struct CollisionModifierData *collmd, float step, flo void collision_get_collider_velocity(float vel_old[3], float vel_new[3], struct CollisionModifierData *collmd, struct CollPair *collpair); -///////////////////////////////////////////////// -// used in effect.c -///////////////////////////////////////////////// -/* explicit control over layer mask and dupli recursion */ -struct Object **get_collisionobjects_ext(struct Scene *scene, struct Object *self, struct Collection *collection, unsigned int *numcollobj, unsigned int modifier_type, bool dupli); +/* Collision relations for dependency graph build. */ + +typedef struct CollisionRelation { + struct CollisionRelation *next, *prev; + struct Object *ob; +} CollisionRelation; + +struct ListBase *BKE_collision_relations_create( + struct Depsgraph *depsgraph, + struct Collection *collection, + unsigned int modifier_type); +void BKE_collision_relations_free(struct ListBase *relations); + +/* Collision object lists for physics simulation evaluation. */ -struct Object **get_collisionobjects(struct Scene *scene, struct Object *self, struct Collection *collection, unsigned int *numcollobj, unsigned int modifier_type); +struct Object **BKE_collision_objects_create( + struct Depsgraph *depsgraph, + struct Object *self, + struct Collection *collection, + unsigned int *numcollobj, + unsigned int modifier_type); +void BKE_collision_objects_free(struct Object **objects); typedef struct ColliderCache { struct ColliderCache *next, *prev; @@ -158,8 +174,11 @@ typedef struct ColliderCache { struct CollisionModifierData *collmd; } ColliderCache; -struct ListBase *get_collider_cache(struct Scene *scene, struct Object *self, struct Collection *collection); -void free_collider_cache(struct ListBase **colliders); +struct ListBase *BKE_collider_cache_create( + struct Depsgraph *scene, + struct Object *self, + struct Collection *collection); +void BKE_collider_cache_free(struct ListBase **colliders); ///////////////////////////////////////////////// diff --git a/source/blender/blenkernel/BKE_data_transfer.h b/source/blender/blenkernel/BKE_data_transfer.h index 6559f9a954f..7d0bb67c54d 100644 --- a/source/blender/blenkernel/BKE_data_transfer.h +++ b/source/blender/blenkernel/BKE_data_transfer.h @@ -143,9 +143,9 @@ bool BKE_object_data_transfer_mesh( const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX], const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup, struct ReportList *reports); -bool BKE_object_data_transfer_dm( +bool BKE_object_data_transfer_ex( struct Depsgraph *depsgraph, struct Scene *scene, - struct Object *ob_src, struct Object *ob_dst, struct DerivedMesh *dm_dst, + struct Object *ob_src, struct Object *ob_dst, struct Mesh *me_dst, const int data_types, bool use_create, const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode, struct SpaceTransform *space_transform, const bool auto_transform, diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h index acb5e63d32f..12f61116f5f 100644 --- a/source/blender/blenkernel/BKE_dynamicpaint.h +++ b/source/blender/blenkernel/BKE_dynamicpaint.h @@ -28,6 +28,8 @@ */ struct Depsgraph; +struct DynamicPaintCanvasSettings; +struct DynamicPaintModifierData; struct Main; struct Scene; struct ViewLayer; diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h index 379ab3e81b5..484cf957be1 100644 --- a/source/blender/blenkernel/BKE_effect.h +++ b/source/blender/blenkernel/BKE_effect.h @@ -45,6 +45,7 @@ struct ParticleSimulationData; struct ParticleData; struct ParticleKey; struct Depsgraph; +struct ViewLayer; struct EffectorWeights *BKE_add_effector_weights(struct Collection *collection); struct PartDeflect *object_add_collision_fields(int type); @@ -111,13 +112,35 @@ typedef struct EffectorCache { int flag; } EffectorCache; -void free_partdeflect(struct PartDeflect *pd); -struct ListBase *pdInitEffectors( - struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src, - struct EffectorWeights *weights, bool for_simulation); -void pdEndEffectors(struct ListBase **effectors); -void pdPrecalculateEffectors(struct Depsgraph *depsgraph, struct ListBase *effectors); -void pdDoEffectors(struct ListBase *effectors, struct ListBase *colliders, struct EffectorWeights *weights, struct EffectedPoint *point, float *force, float *impulse); +typedef struct EffectorRelation { + struct EffectorRelation *next, *prev; + + struct Object *ob; + struct ParticleSystem *psys; + struct PartDeflect *pd; +} EffectorRelation; + +void free_partdeflect(struct PartDeflect *pd); + +struct ListBase *BKE_effector_relations_create( + struct Depsgraph *depsgraph, + struct ViewLayer *view_layer, + struct Collection *collection); +void BKE_effector_relations_free(struct ListBase *lb); + +struct ListBase *BKE_effectors_create( + struct Depsgraph *depsgraph, + struct Object *ob_src, + struct ParticleSystem *psys_src, + struct EffectorWeights *weights); +void BKE_effectors_apply( + struct ListBase *effectors, + struct ListBase *colliders, + struct EffectorWeights *weights, + struct EffectedPoint *point, + float *force, + float *impulse); +void BKE_effectors_free(struct ListBase *lb); void pd_point_from_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, struct EffectedPoint *point); void pd_point_from_loc(struct Scene *scene, float *loc, float *vel, int index, struct EffectedPoint *point); diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index 2f953e57d71..0af608a926d 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -102,7 +102,7 @@ void BKE_keyblock_convert_from_curve(struct Curve *cu, struct KeyBlock *kb, s void BKE_keyblock_convert_to_curve(struct KeyBlock *kb, struct Curve *cu, struct ListBase *nurb); void BKE_keyblock_update_from_mesh(struct Mesh *me, struct KeyBlock *kb); -void BKE_keyblock_convert_from_mesh(struct Mesh *me, struct KeyBlock *kb); +void BKE_keyblock_convert_from_mesh(struct Mesh *me, struct Key *key, struct KeyBlock *kb); void BKE_keyblock_convert_to_mesh(struct KeyBlock *kb, struct Mesh *me); void BKE_keyblock_mesh_calc_normals( struct KeyBlock *kb, struct Mesh *mesh, float (*r_vertnors)[3], float (*r_polynors)[3], float (*r_loopnors)[3]); diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index b722b7da6a0..c2ac5e98f76 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -41,7 +41,6 @@ struct Main; struct Mesh; struct Object; struct Scene; -struct DerivedMesh; struct BPoint; struct MDeformVert; struct Depsgraph; diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index c09dbe7dc08..d65969ef9c1 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -110,8 +110,15 @@ bool BKE_view_layer_has_collection( bool BKE_scene_has_object( struct Scene *scene, struct Object *ob); +/* selection and hiding */ + bool BKE_layer_collection_objects_select( struct ViewLayer *view_layer, struct LayerCollection *lc, bool deselect); +bool BKE_layer_collection_has_selected_objects( + struct ViewLayer *view_layer, struct LayerCollection *lc); + +void BKE_base_set_visible(struct Scene *scene, struct ViewLayer *view_layer, struct Base *base, bool extend); +void BKE_layer_collection_set_visible(struct Scene *scene, struct ViewLayer *view_layer, struct LayerCollection *lc, bool extend); /* override */ diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 28bc254f25a..aaf53a2396b 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -208,6 +208,8 @@ void BKE_library_make_local( void BKE_id_tag_set_atomic(struct ID *id, int tag); void BKE_id_tag_clear_atomic(struct ID *id, int tag); +bool BKE_id_is_in_gobal_main(struct ID *id); + /* use when "" is given to new_id() */ #define ID_FALLBACK_NAME N_("Untitled") diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 85ce4eb6cae..76205da9565 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -64,7 +64,6 @@ struct MDeformVert; struct MDisps; struct Object; struct CustomData; -struct DerivedMesh; struct Scene; struct MLoopUV; struct ReportList; diff --git a/source/blender/blenkernel/BKE_mesh_iterators.h b/source/blender/blenkernel/BKE_mesh_iterators.h new file mode 100644 index 00000000000..edd5ad783d2 --- /dev/null +++ b/source/blender/blenkernel/BKE_mesh_iterators.h @@ -0,0 +1,65 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is: all of this file. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef __BKE_MESH_ITERATORS_H__ +#define __BKE_MESH_ITERATORS_H__ + +/** \file BKE_mesh_iterators.h + * \ingroup bke + */ + +struct Mesh; +struct MVert; +struct MEdge; +struct MPoly; +struct MLoop; +struct MLoopUV; +struct MLoopTri; + +typedef enum MeshForeachFlag { + MESH_FOREACH_NOP = 0, + MESH_FOREACH_USE_NORMAL = (1 << 0), /* foreachMappedVert, foreachMappedLoop, foreachMappedFaceCenter */ +} MeshForeachFlag; + + +void BKE_mesh_foreach_mapped_vert( + struct Mesh *mesh, + void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]), + void *userData, + MeshForeachFlag flag); +void BKE_mesh_foreach_mapped_edge( + struct Mesh *mesh, + void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]), + void *userData); +void BKE_mesh_foreach_mapped_loop( + struct Mesh *mesh, + void (*func)(void *userData, int vertex_index, int face_index, const float co[3], const float no[3]), + void *userData, + MeshForeachFlag flag); +void BKE_mesh_foreach_mapped_face_center( + struct Mesh *mesh, + void (*func)(void *userData, int index, const float cent[3], const float no[3]), + void *userData, + MeshForeachFlag flag); + +#endif /* __BKE_MESH_ITERATORS_H__ */ diff --git a/source/blender/blenkernel/BKE_mesh_remap.h b/source/blender/blenkernel/BKE_mesh_remap.h index 5c77ab8a94e..7aea856ff34 100644 --- a/source/blender/blenkernel/BKE_mesh_remap.h +++ b/source/blender/blenkernel/BKE_mesh_remap.h @@ -26,7 +26,7 @@ */ struct CustomData; -struct DerivedMesh; +struct Mesh; struct MVert; struct MemArena; @@ -140,39 +140,37 @@ enum { MREMAP_MODE_TOPOLOGY = MREMAP_MODE_VERT | MREMAP_MODE_EDGE | MREMAP_MODE_LOOP | MREMAP_MODE_POLY, }; -float BKE_mesh_remap_calc_difference_from_dm( +float BKE_mesh_remap_calc_difference_from_mesh( const struct SpaceTransform *space_transform, - const struct MVert *verts_dst, const int numverts_dst, struct DerivedMesh *dm_src); + const struct MVert *verts_dst, const int numverts_dst, struct Mesh *me_src); -void BKE_mesh_remap_find_best_match_from_dm( - const struct MVert *verts_dst, const int numverts_dst, struct DerivedMesh *dm_src, +void BKE_mesh_remap_find_best_match_from_mesh( + const struct MVert *verts_dst, const int numverts_dst, struct Mesh *me_src, struct SpaceTransform *r_space_transform); -/* TODO add mesh2mesh versions (we'll need mesh versions of bvhtree funcs too, though!). */ - -void BKE_mesh_remap_calc_verts_from_dm( +void BKE_mesh_remap_calc_verts_from_mesh( const int mode, const struct SpaceTransform *space_transform, const float max_dist, const float ray_radius, const struct MVert *verts_dst, const int numverts_dst, const bool dirty_nors_dst, - struct DerivedMesh *dm_src, MeshPairRemap *r_map); + struct Mesh *me_src, MeshPairRemap *r_map); -void BKE_mesh_remap_calc_edges_from_dm( +void BKE_mesh_remap_calc_edges_from_mesh( const int mode, const struct SpaceTransform *space_transform, const float max_dist, const float ray_radius, const struct MVert *verts_dst, const int numverts_dst, const struct MEdge *edges_dst, const int numedges_dst, - const bool dirty_nors_dst, struct DerivedMesh *dm_src, MeshPairRemap *r_map); + const bool dirty_nors_dst, struct Mesh *me_src, MeshPairRemap *r_map); -void BKE_mesh_remap_calc_loops_from_dm( +void BKE_mesh_remap_calc_loops_from_mesh( const int mode, const struct SpaceTransform *space_transform, const float max_dist, const float ray_radius, struct MVert *verts_dst, const int numverts_dst, struct MEdge *edges_dst, const int numedges_dst, struct MLoop *loops_dst, const int numloops_dst, struct MPoly *polys_dst, const int numpolys_dst, struct CustomData *ldata_dst, struct CustomData *pdata_dst, const bool use_split_nors_dst, const float split_angle_dst, const bool dirty_nors_dst, - struct DerivedMesh *dm_src, const bool use_split_nors_src, const float split_angle_src, + struct Mesh *me_src, MeshRemapIslandsCalc gen_islands_src, const float islands_precision_src, struct MeshPairRemap *r_map); -void BKE_mesh_remap_calc_polys_from_dm( +void BKE_mesh_remap_calc_polys_from_mesh( const int mode, const struct SpaceTransform *space_transform, const float max_dist, const float ray_radius, struct MVert *verts_dst, const int numverts_dst, struct MLoop *loops_dst, const int numloops_dst, struct MPoly *polys_dst, const int numpolys_dst, struct CustomData *pdata_dst, const bool dirty_nors_dst, - struct DerivedMesh *dm_src, struct MeshPairRemap *r_map); + struct Mesh *me_src, struct MeshPairRemap *r_map); #endif /* __BKE_MESH_REMAP_H__ */ diff --git a/source/blender/blenkernel/BKE_mesh_runtime.h b/source/blender/blenkernel/BKE_mesh_runtime.h index 6904ad529de..f894f72e648 100644 --- a/source/blender/blenkernel/BKE_mesh_runtime.h +++ b/source/blender/blenkernel/BKE_mesh_runtime.h @@ -35,7 +35,10 @@ #include "BKE_customdata.h" /* for CustomDataMask */ +struct ColorBand; +struct CustomData; struct Depsgraph; +struct KeyBlock; struct Mesh; struct MLoop; struct MLoopTri; @@ -82,4 +85,17 @@ struct Mesh *mesh_get_eval_deform( struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, CustomDataMask dataMask); +void BKE_mesh_runtime_eval_to_meshkey(struct Mesh *me_deformed, struct Mesh *me, struct KeyBlock *kb); + +/* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */ +void BKE_mesh_runtime_color_band_store(const struct ColorBand *coba, const char alert_color[4]); + + +#ifndef NDEBUG +char *BKE_mesh_runtime_debug_info(struct Mesh *me_eval); +void BKE_mesh_runtime_debug_print(struct Mesh *me_eval); +void BKE_mesh_runtime_debug_print_cdlayers(struct CustomData *data); +bool BKE_mesh_runtime_is_valid(struct Mesh *me_eval); +#endif /* NDEBUG */ + #endif /* __BKE_MESH_RUNTIME_H__ */ diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 8a9e2f44604..b5d81bfe375 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -315,7 +315,7 @@ typedef struct ModifierTypeInfo { * * This function is optional (assumes never disabled if not present). */ - bool (*isDisabled)(struct ModifierData *md, int userRenderParams); + bool (*isDisabled)(const struct Scene *scene, struct ModifierData *md, int userRenderParams); /* Add the appropriate relations to the dependency graph. * @@ -397,7 +397,7 @@ bool modifier_couldBeCage(struct Scene *scene, struct ModifierData *md) bool modifier_isCorrectableDeformed(struct ModifierData *md); bool modifier_isSameTopology(ModifierData *md); bool modifier_isNonGeometrical(ModifierData *md); -bool modifier_isEnabled(struct Scene *scene, struct ModifierData *md, int required_mode); +bool modifier_isEnabled(const struct Scene *scene, struct ModifierData *md, int required_mode); void modifier_setError(struct ModifierData *md, const char *format, ...) ATTR_PRINTF_FORMAT(2, 3); bool modifier_isPreview(struct ModifierData *md); diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index cecea927e8a..3a70e145744 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -61,7 +61,7 @@ void multires_force_render_update(struct Object *ob); void multires_force_external_reload(struct Object *ob); /* internal, only called in subsurf_ccg.c */ -void multires_modifier_update_mdisps(struct DerivedMesh *dm); +void multires_modifier_update_mdisps(struct DerivedMesh *dm, struct Scene *scene); void multires_modifier_update_hidden(struct DerivedMesh *dm); void multiresModifier_set_levels_from_disps(struct MultiresModifierData *mmd, struct Object *ob); @@ -75,6 +75,7 @@ typedef enum { struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm, struct MultiresModifierData *mmd, + struct Scene *scene, struct Object *ob, MultiresFlags flags); @@ -83,11 +84,11 @@ struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene, struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, bool use_first); struct DerivedMesh *get_multires_dm(struct Depsgraph *depsgraph, struct Scene *scene, struct MultiresModifierData *mmd, struct Object *ob); -void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction); -void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Object *ob); -void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple); +void multiresModifier_del_levels(struct MultiresModifierData *mmd, struct Scene *scene, struct Object *object, int direction); +void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Scene *scene, struct Object *ob); +void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Scene *scene, struct Object *ob, int updateblock, int simple); void multiresModifier_sync_levels_ex( - struct Object *ob_dst, struct MultiresModifierData *mmd_src, struct MultiresModifierData *mmd_dst); + struct Scene *scene, struct Object *ob_dst, struct MultiresModifierData *mmd_src, struct MultiresModifierData *mmd_dst); int multiresModifier_reshape(struct Depsgraph *depsgraph, struct Scene *scene, struct MultiresModifierData *mmd, struct Object *dst, struct Object *src); int multiresModifier_reshapeFromDM(struct Depsgraph *depsgraph, struct Scene *scene, struct MultiresModifierData *mmd, diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index ab8327d354a..a54b244f5fd 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -73,7 +73,7 @@ void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData * bool BKE_object_support_modifier_type_check(const struct Object *ob, int modifier_type); -void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_src); +void BKE_object_link_modifiers(struct Scene *scene, struct Object *ob_dst, const struct Object *ob_src); void BKE_object_free_modifiers(struct Object *ob, const int flag); void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob); @@ -183,8 +183,6 @@ void BKE_object_foreach_display_point( void (*func_cb)(const float[3], void *), void *user_data); void BKE_scene_foreach_display_point( struct Depsgraph *depsgraph, - struct Scene *scene, - struct ViewLayer *view_layer, void (*func_cb)(const float[3], void *), void *user_data); bool BKE_object_parent_loop_check(const struct Object *parent, const struct Object *ob); diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 1b42ce97940..d2c2f9a254f 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -121,9 +121,6 @@ typedef struct SpaceType { /* region type definitions */ ListBase regiontypes; - /* tool shelf definitions */ - ListBase toolshelf; - /* read and write... */ /* default keymaps to add */ diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h index 8a809b606f1..d4df12783fa 100644 --- a/source/blender/blenkernel/BKE_shrinkwrap.h +++ b/source/blender/blenkernel/BKE_shrinkwrap.h @@ -47,7 +47,6 @@ */ struct Object; -struct DerivedMesh; struct Mesh; struct MVert; struct MDeformVert; @@ -77,7 +76,7 @@ typedef struct ShrinkwrapCalcData { } ShrinkwrapCalcData; -void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Object *ob, struct Mesh *mesh, +void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Scene *scene, struct Object *ob, struct Mesh *mesh, float (*vertexCos)[3], int numVerts); /* diff --git a/source/blender/blenkernel/BKE_studiolight.h b/source/blender/blenkernel/BKE_studiolight.h index f9d679b1b1a..e3edcca5aca 100644 --- a/source/blender/blenkernel/BKE_studiolight.h +++ b/source/blender/blenkernel/BKE_studiolight.h @@ -61,6 +61,22 @@ #define STUDIOLIGHT_ICON_SIZE 96 +#define STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL 2 +#define STUDIOLIGHT_SPHERICAL_HARMONICS_MAX_COMPONENTS 9 + +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL == 0 +# define STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS 1 +#endif + +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL == 1 +# define STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS 4 +#endif + +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL == 2 +# define STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS 9 +# define STUDIOLIGHT_SPHERICAL_HARMONICS_WINDOWING_TARGET_LAMPLACIAN 10.0f +#endif + struct GPUTexture; struct StudioLight; @@ -97,12 +113,12 @@ typedef struct StudioLight { char name[FILE_MAXFILE]; char path[FILE_MAX]; char *path_irr_cache; - char *path_sh2_cache; + char *path_sh_cache; int icon_id_irradiance; int icon_id_radiance; int icon_id_matcap; int icon_id_matcap_flipped; - float spherical_harmonics_coefs[9][3]; + float spherical_harmonics_coefs[STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS][3]; float light_direction[3]; ImBuf *equirectangular_radiance_buffer; ImBuf *equirectangular_irradiance_buffer; @@ -112,12 +128,12 @@ typedef struct StudioLight { float *gpu_matcap_3components; /* 3 channel buffer for GPU_R11F_G11F_B10F */ /* - Free function to clean up the running icons previews (wmJob) the usage is in - interface_icons. Please be aware that this was build to handle only one free function - that cleans up all icons. just to keep the code simple. - */ + * Free function to clean up the running icons previews (wmJob) the usage is in + * interface_icons. Please be aware that this was build to handle only one free function + * that cleans up all icons. just to keep the code simple. + */ StudioLightFreeFunction *free_function; - void* free_function_data; + void *free_function_data; } StudioLight; void BKE_studiolight_init(void); @@ -125,10 +141,12 @@ void BKE_studiolight_free(void); struct StudioLight *BKE_studiolight_find(const char *name, int flag); struct StudioLight *BKE_studiolight_findindex(int index, int flag); struct StudioLight *BKE_studiolight_find_first(int flag); -void BKE_studiolight_preview(uint* icon_buffer, StudioLight *sl, int icon_id_type); +void BKE_studiolight_preview(uint *icon_buffer, StudioLight *sl, int icon_id_type); struct ListBase *BKE_studiolight_listbase(void); void BKE_studiolight_ensure_flag(StudioLight *sl, int flag); void BKE_studiolight_refresh(void); +StudioLight *BKE_studiolight_new(const char *path, int orientation); +void BKE_studiolight_remove(StudioLight *sl); void BKE_studiolight_set_free_function(StudioLight *sl, StudioLightFreeFunction *free_function, void *data); void BKE_studiolight_unset_icon_id(StudioLight *sl, int icon_id); diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index 96320415b16..6cb09ff8822 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -67,6 +67,7 @@ typedef enum { struct DerivedMesh *subsurf_make_derived_from_derived( struct DerivedMesh *dm, struct SubsurfModifierData *smd, + struct Scene *scene, float (*vertCos)[3], SubsurfFlags flags); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 867b5884114..94a6fc45303 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -77,6 +77,7 @@ set(SRC intern/blender.c intern/blender_copybuffer.c intern/blender_undo.c + intern/blender_user_menu.c intern/blendfile.c intern/bmfont.c intern/boids.c @@ -140,6 +141,7 @@ set(SRC intern/mesh.c intern/mesh_convert.c intern/mesh_evaluate.c + intern/mesh_iterators.c intern/mesh_mapping.c intern/mesh_merge.c intern/mesh_remap.c @@ -272,6 +274,7 @@ set(SRC BKE_mball.h BKE_mball_tessellate.h BKE_mesh.h + BKE_mesh_iterators.h BKE_mesh_mapping.h BKE_mesh_remap.h BKE_mesh_tangent.h @@ -417,7 +420,7 @@ if(WITH_CODEC_FFMPEG) ) add_definitions(-DWITH_FFMPEG) - remove_strict_flags_file( + remove_strict_c_flags_file( intern/writeffmpeg.c ) endif() diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 5a4dc479c10..a77e6ec12c7 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -856,26 +856,18 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask, bool } } -void DM_to_meshkey(DerivedMesh *dm, Mesh *me, KeyBlock *kb) +/** Utility function to convert an (evaluated) Mesh to a shape key block. */ +/* Just a shallow wrapper around BKE_keyblock_convert_from_mesh, + * that ensures both evaluated mesh and original one has same number of vertices. */ +void BKE_mesh_runtime_eval_to_meshkey(Mesh *me_deformed, Mesh *me, KeyBlock *kb) { - int a, totvert = dm->getNumVerts(dm); - float *fp; - MVert *mvert; + const int totvert = me_deformed->totvert; if (totvert == 0 || me->totvert == 0 || me->totvert != totvert) { return; } - if (kb->data) MEM_freeN(kb->data); - kb->data = MEM_malloc_arrayN(me->key->elemsize, me->totvert, "kb->data"); - kb->totelem = totvert; - - fp = kb->data; - mvert = dm->getVertDataArray(dm, CD_MVERT); - - for (a = 0; a < kb->totelem; a++, fp += 3, mvert++) { - copy_v3_v3(fp, mvert->co); - } + BKE_keyblock_convert_from_mesh(me_deformed, me->key, kb); } /** @@ -1446,10 +1438,10 @@ enum { CALC_WP_MIRROR_X = (1 << 5), }; -typedef struct DMWeightColorInfo { +typedef struct MERuntimeWeightColorInfo { const ColorBand *coba; const char *alert_color; -} DMWeightColorInfo; +} MERuntimeWeightColorInfo; static int dm_drawflag_calc(const ToolSettings *ts, const Mesh *me) @@ -1461,7 +1453,7 @@ static int dm_drawflag_calc(const ToolSettings *ts, const Mesh *me) ((me->editflag & ME_EDIT_MIRROR_X) ? CALC_WP_MIRROR_X : 0)); } -static void weightpaint_color(unsigned char r_col[4], DMWeightColorInfo *dm_wcinfo, const float input) +static void weightpaint_color(unsigned char r_col[4], MERuntimeWeightColorInfo *dm_wcinfo, const float input) { float colf[4]; @@ -1484,7 +1476,7 @@ static void weightpaint_color(unsigned char r_col[4], DMWeightColorInfo *dm_wcin static void calc_weightpaint_vert_color( unsigned char r_col[4], const MDeformVert *dv, - DMWeightColorInfo *dm_wcinfo, + MERuntimeWeightColorInfo *dm_wcinfo, const int defbase_tot, const int defbase_act, const bool *defbase_sel, const int defbase_sel_tot, const int draw_flag) @@ -1529,12 +1521,12 @@ static void calc_weightpaint_vert_color( } } -static DMWeightColorInfo G_dm_wcinfo; +static MERuntimeWeightColorInfo G_me_runtime_wcinfo; -void vDM_ColorBand_store(const ColorBand *coba, const char alert_color[4]) +void BKE_mesh_runtime_color_band_store(const ColorBand *coba, const char alert_color[4]) { - G_dm_wcinfo.coba = coba; - G_dm_wcinfo.alert_color = alert_color; + G_me_runtime_wcinfo.coba = coba; + G_me_runtime_wcinfo.alert_color = alert_color; } /** @@ -1545,7 +1537,7 @@ void vDM_ColorBand_store(const ColorBand *coba, const char alert_color[4]) * so leave this as is - campbell */ static void calc_weightpaint_vert_array( - Object *ob, DerivedMesh *dm, int const draw_flag, DMWeightColorInfo *dm_wcinfo, + Object *ob, DerivedMesh *dm, int const draw_flag, MERuntimeWeightColorInfo *dm_wcinfo, unsigned char (*r_wtcol_v)[4]) { BMEditMesh *em = (dm->type == DM_TYPE_EDITBMESH) ? BKE_editmesh_from_object(ob) : NULL; @@ -1620,7 +1612,7 @@ static void calc_weightpaint_vert_array( } static void calc_weightpaint_vert_array_mesh( - Object *ob, Mesh *mesh, int const draw_flag, DMWeightColorInfo *dm_wcinfo, + Object *ob, Mesh *mesh, int const draw_flag, MERuntimeWeightColorInfo *dm_wcinfo, unsigned char (*r_wtcol_v)[4]) { BMEditMesh *em = BKE_editmesh_from_object(ob); @@ -1749,7 +1741,7 @@ void DM_update_weight_mcol( } else { /* No weights given, take them from active vgroup(s). */ - calc_weightpaint_vert_array(ob, dm, draw_flag, &G_dm_wcinfo, wtcol_v); + calc_weightpaint_vert_array(ob, dm, draw_flag, &G_me_runtime_wcinfo, wtcol_v); } if (dm->type == DM_TYPE_EDITBMESH) { @@ -1823,7 +1815,7 @@ static void mesh_update_weight_mcol( } else { /* No weights given, take them from active vgroup(s). */ - calc_weightpaint_vert_array_mesh(ob, mesh, draw_flag, &G_dm_wcinfo, wtcol_v); + calc_weightpaint_vert_array_mesh(ob, mesh, draw_flag, &G_me_runtime_wcinfo, wtcol_v); } if (em) { @@ -2101,8 +2093,6 @@ static void mesh_calc_modifiers( for (; md; md = md->next, curr = curr->next) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; - if (!modifier_isEnabled(scene, md, required_mode)) { continue; } @@ -2168,8 +2158,6 @@ static void mesh_calc_modifiers( for (; md; md = md->next, curr = curr->next) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; - if (!modifier_isEnabled(scene, md, required_mode)) { continue; } @@ -2646,8 +2634,6 @@ static void editbmesh_calc_modifiers( for (i = 0; md; i++, md = md->next, curr = curr->next) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; - if (!editbmesh_modifier_is_enabled(scene, md, dm)) { continue; } diff --git a/source/blender/blenkernel/intern/addon.c b/source/blender/blenkernel/intern/addon.c index 689e0fb5ee6..a9bb193a7a1 100644 --- a/source/blender/blenkernel/intern/addon.c +++ b/source/blender/blenkernel/intern/addon.c @@ -53,9 +53,14 @@ bAddon *BKE_addon_new(void) return addon; } +bAddon *BKE_addon_find(ListBase *addon_list, const char *module) +{ + return BLI_findstring(addon_list, module, offsetof(bAddon, module)); +} + bAddon *BKE_addon_ensure(ListBase *addon_list, const char *module) { - bAddon *addon = BLI_findstring(addon_list, module, offsetof(bAddon, module)); + bAddon *addon = BKE_addon_find(addon_list, module); if (addon == NULL) { addon = BKE_addon_new(); BLI_strncpy(addon->module, module, sizeof(addon->module)); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index ba45b5acb5d..bd9ee7c9e5f 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -60,7 +60,6 @@ #include "BKE_anim.h" #include "BKE_constraint.h" #include "BKE_curve.h" -#include "BKE_DerivedMesh.h" #include "BKE_deform.h" #include "BKE_displist.h" #include "BKE_idprop.h" diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index c366d822648..23c2147ff7e 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -48,6 +48,7 @@ #include "BKE_addon.h" #include "BKE_blender.h" /* own include */ #include "BKE_blender_version.h" /* own include */ +#include "BKE_blender_user_menu.h" #include "BKE_blendfile.h" #include "BKE_brush.h" #include "BKE_cachefile.h" @@ -206,6 +207,15 @@ static void userdef_free_keymaps(UserDef *userdef) BLI_listbase_clear(&userdef->user_keymaps); } +static void userdef_free_user_menus(UserDef *userdef) +{ + for (bUserMenu *um = userdef->user_menus.first, *um_next; um; um = um_next) { + um_next = um->next; + BKE_blender_user_menu_item_free_list(&um->items); + MEM_freeN(um); + } +} + static void userdef_free_addons(UserDef *userdef) { for (bAddon *addon = userdef->addons.first, *addon_next; addon; addon = addon_next) { @@ -226,6 +236,7 @@ void BKE_blender_userdef_data_free(UserDef *userdef, bool clear_fonts) #endif userdef_free_keymaps(userdef); + userdef_free_user_menus(userdef); userdef_free_addons(userdef); if (clear_fonts) { @@ -241,6 +252,7 @@ void BKE_blender_userdef_data_free(UserDef *userdef, bool clear_fonts) BLI_freelistN(&userdef->uifonts); BLI_freelistN(&userdef->themes); + #undef U } diff --git a/source/blender/blenkernel/intern/blender_user_menu.c b/source/blender/blenkernel/intern/blender_user_menu.c new file mode 100644 index 00000000000..3bb150b8fac --- /dev/null +++ b/source/blender/blenkernel/intern/blender_user_menu.c @@ -0,0 +1,114 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/blender_user_menu.c + * \ingroup bke + * + * User defined menu API. + */ + +#include <string.h> + +#include "MEM_guardedalloc.h" + +#include "BLI_listbase.h" +#include "BLI_string.h" + +#include "DNA_userdef_types.h" + +#include "BKE_blender_user_menu.h" +#include "BKE_idprop.h" + +/* -------------------------------------------------------------------- */ +/** \name Menu Type + * \{ */ + +bUserMenu *BKE_blender_user_menu_find( + ListBase *lb, char space_type, const char *context) +{ + for (bUserMenu *um = lb->first; um; um = um->next) { + if ((space_type == um->space_type) && + (STREQ(context, um->context))) + { + return um; + } + } + return NULL; +} + +bUserMenu *BKE_blender_user_menu_ensure( + ListBase *lb, char space_type, const char *context) +{ + bUserMenu *um = BKE_blender_user_menu_find(lb, space_type, context); + if (um == NULL) { + um = MEM_callocN(sizeof(bUserMenu), __func__); + um->space_type = space_type; + STRNCPY(um->context, context); + BLI_addhead(lb, um); + } + return um; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Menu Item + * \{ */ + +bUserMenuItem *BKE_blender_user_menu_item_add(ListBase *lb, int type) +{ + uint size; + + if (type == USER_MENU_TYPE_OPERATOR) { + size = sizeof(bUserMenuItem_Op); + } + else if (type == USER_MENU_TYPE_SEP) { + size = sizeof(bUserMenuItem); + } + else { + BLI_assert(0); + } + + bUserMenuItem *umi = MEM_callocN(size, __func__); + umi->type = type; + BLI_addtail(lb, umi); + return umi; +} + +void BKE_blender_user_menu_item_free(bUserMenuItem *umi) +{ + if (umi->type == USER_MENU_TYPE_OPERATOR) { + bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; + if (umi_op->prop) { + IDP_FreeProperty(umi_op->prop); + MEM_freeN(umi_op->prop); + } + } + MEM_freeN(umi); +} + +void BKE_blender_user_menu_item_free_list(ListBase *lb) +{ + for (bUserMenuItem *umi = lb->first, *umi_next; umi; umi = umi_next) { + umi_next = umi->next; + BKE_blender_user_menu_item_free(umi); + } + BLI_listbase_clear(lb); +} diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 8fdaf183b06..f47d09d7dc2 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -1265,7 +1265,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* account for effectors */ pd_point_from_particle(bbd->sim, pa, &pa->state, &epoint); - pdDoEffectors(bbd->sim->psys->effectors, bbd->sim->colliders, bbd->part->effector_weights, &epoint, force, NULL); + BKE_effectors_apply(bbd->sim->psys->effectors, bbd->sim->colliders, bbd->part->effector_weights, &epoint, force, NULL); if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) { float length = normalize_v3(force); diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index d1ab559515b..778eb17f822 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -649,7 +649,7 @@ static bool camera_frame_fit_calc_from_data( /* don't move the camera, just yield the fit location */ /* r_scale only valid/useful for ortho cameras */ bool BKE_camera_view_frame_fit_to_scene( - Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer, Object *camera_ob, float r_co[3], float *r_scale) + Depsgraph *depsgraph, Scene *scene, Object *camera_ob, float r_co[3], float *r_scale) { CameraParams params; CameraViewFrameData data_cb; @@ -660,7 +660,7 @@ bool BKE_camera_view_frame_fit_to_scene( camera_frame_fit_data_init(scene, camera_ob, ¶ms, &data_cb); /* run callback on all visible points */ - BKE_scene_foreach_display_point(depsgraph, scene, view_layer, camera_to_frame_view_cb, &data_cb); + BKE_scene_foreach_display_point(depsgraph, camera_to_frame_view_cb, &data_cb); return camera_frame_fit_calc_from_data(¶ms, &data_cb, r_co, r_scale); } diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index c5d9472ca4b..680c6860f4c 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -350,7 +350,7 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, Mesh *result, int return 1; } -static int do_step_cloth(struct Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, Mesh *result, int framenr) +static int do_step_cloth(Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, Mesh *result, int framenr) { ClothVertex *verts = NULL; Cloth *cloth; @@ -375,7 +375,7 @@ static int do_step_cloth(struct Depsgraph *depsgraph, Object *ob, ClothModifierD mul_m4_v3(ob->obmat, verts->xconst); } - effectors = pdInitEffectors(depsgraph, clmd->scene, ob, NULL, clmd->sim_parms->effector_weights, true); + effectors = BKE_effectors_create(depsgraph, ob, NULL, clmd->sim_parms->effector_weights); if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH ) cloth_update_verts ( ob, clmd, result ); @@ -391,11 +391,11 @@ static int do_step_cloth(struct Depsgraph *depsgraph, Object *ob, ClothModifierD // TIMEIT_START(cloth_step) /* call the solver. */ - ret = BPH_cloth_solve(ob, framenr, clmd, effectors); + ret = BPH_cloth_solve(depsgraph, ob, framenr, clmd, effectors); // TIMEIT_END(cloth_step) - pdEndEffectors(&effectors); + BKE_effectors_free(effectors); // printf ( "%f\n", ( float ) tval() ); @@ -405,7 +405,7 @@ static int do_step_cloth(struct Depsgraph *depsgraph, Object *ob, ClothModifierD /************************************************ * clothModifier_do - main simulation function ************************************************/ -void clothModifier_do(ClothModifierData *clmd, struct Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *mesh, float (*vertexCos)[3]) +void clothModifier_do(ClothModifierData *clmd, Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *mesh, float (*vertexCos)[3]) { PointCache *cache; PTCacheID pid; @@ -413,7 +413,6 @@ void clothModifier_do(ClothModifierData *clmd, struct Depsgraph *depsgraph, Scen int framenr, startframe, endframe; int cache_result; - clmd->scene= scene; /* nice to pass on later :) */ framenr = DEG_get_ctime(depsgraph); cache= clmd->point_cache; diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index dfb43812b49..1d9cc9bb8d0 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -309,15 +309,21 @@ static void collection_object_cache_fill(ListBase *lb, Collection *collection, i if (base == NULL) { base = MEM_callocN(sizeof(Base), "Object Base"); base->object = cob->ob; + BLI_addtail(lb, base); + } - if ((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) { - base->flag |= BASE_VISIBLE_VIEWPORT; - } - if ((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) { - base->flag |= BASE_VISIBLE_RENDER; - } + int object_restrict = base->object->restrictflag; - BLI_addtail(lb, base); + if (((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) && + ((object_restrict & OB_RESTRICT_VIEW) == 0)) + { + base->flag |= BASE_ENABLED_VIEWPORT; + } + + if (((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) && + ((object_restrict & OB_RESTRICT_RENDER) == 0)) + { + base->flag |= BASE_ENABLED_RENDER; } } @@ -358,36 +364,13 @@ void BKE_collection_object_cache_free(Collection *collection) collection_object_cache_free(collection); } -Base *BKE_collection_or_layer_objects(const Depsgraph *depsgraph, - const Scene *scene, - const ViewLayer *view_layer, - Collection *collection) +Base *BKE_collection_or_layer_objects(const ViewLayer *view_layer, Collection *collection) { - // TODO: this is used by physics to get objects from a collection, but the - // the physics systems are not all using the depsgraph correctly which means - // we try different things. Instead we should explicitly get evaluated or - // non-evaluated data and always have the depsgraph available when needed - if (collection) { return BKE_collection_object_cache_get(collection).first; } - else if (depsgraph) { - view_layer = DEG_get_evaluated_view_layer(depsgraph); - - if (view_layer) { - return FIRSTBASE(view_layer); - } - else { - view_layer = DEG_get_input_view_layer(depsgraph); - return FIRSTBASE(view_layer); - } - } - else if (view_layer) { - return FIRSTBASE(view_layer); - } else { - /* depsgraph is NULL during deg build */ - return FIRSTBASE(BKE_view_layer_context_active_PLACEHOLDER(scene)); + return FIRSTBASE(view_layer); } } @@ -897,7 +880,7 @@ static bool collection_objects_select(ViewLayer *view_layer, Collection *collect } } else { - if ((base->flag & BASE_SELECTABLED) && !(base->flag & BASE_SELECTED)) { + if ((base->flag & BASE_SELECTABLE) && !(base->flag & BASE_SELECTED)) { base->flag |= BASE_SELECTED; changed = true; } diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 38cb1a1de16..a734e140932 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -58,6 +58,10 @@ #include "BLI_kdopbvh.h" #include "BKE_collision.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_physics.h" +#include "DEG_depsgraph_query.h" + #ifdef WITH_ELTOPO #include "eltopo-capi.h" #endif @@ -479,147 +483,143 @@ static CollPair* cloth_collision(ModifierData *md1, ModifierData *md2, return collpair; } -static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned int *maxobj, Object *ob, Object *self, int level, unsigned int modifier_type) +static void add_collision_object(ListBase *relations, Object *ob, int level, unsigned int modifier_type) { CollisionModifierData *cmd= NULL; - if (ob == self) - return; - /* only get objects with collision modifier */ if (((modifier_type == eModifierType_Collision) && ob->pd && ob->pd->deflect) || (modifier_type != eModifierType_Collision)) cmd= (CollisionModifierData *)modifiers_findByType(ob, modifier_type); if (cmd) { - /* extend array */ - if (*numobj >= *maxobj) { - *maxobj *= 2; - *objs= MEM_reallocN(*objs, sizeof(Object *)*(*maxobj)); - } - - (*objs)[*numobj] = ob; - (*numobj)++; + CollisionRelation *relation = MEM_callocN(sizeof(CollisionRelation), "CollisionRelation"); + relation->ob = ob; + BLI_addtail(relations, relation); } /* objects in dupli groups, one level only for now */ + /* TODO: this doesn't really work, we are not taking into account the + * dupli transforms and can get objects in the list multiple times. */ if (ob->dup_group && level == 0) { Collection *collection= ob->dup_group; /* add objects */ FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, object) { - add_collision_object(objs, numobj, maxobj, object, self, level+1, modifier_type); + add_collision_object(relations, object, level+1, modifier_type); } FOREACH_COLLECTION_OBJECT_RECURSIVE_END; } } -// return all collision objects in scene -// collision object will exclude self -Object **get_collisionobjects_ext(Scene *scene, Object *self, Collection *collection, unsigned int *numcollobj, unsigned int modifier_type, bool dupli) +/* Create list of collision relations in the collection or entire scene. + * This is used by the depsgraph to build relations, as well as faster + * lookup of colliders during evaluation. */ +ListBase *BKE_collision_relations_create(Depsgraph *depsgraph, Collection *collection, unsigned int modifier_type) { - Object **objs; - unsigned int numobj= 0, maxobj= 100; - int level = dupli ? 0 : 1; + ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph); + Base *base = BKE_collection_or_layer_objects(view_layer, collection); + const bool for_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); + const int base_flag = (for_render) ? BASE_ENABLED_RENDER : BASE_ENABLED_VIEWPORT; - objs= MEM_callocN(sizeof(Object *)*maxobj, "CollisionObjectsArray"); + ListBase *relations = MEM_callocN(sizeof(ListBase), "CollisionRelation list"); - /* gather all collision objects */ - if (collection) { - /* use specified collection */ - FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, object) - { - add_collision_object(&objs, &numobj, &maxobj, object, self, level, modifier_type); + for (; base; base = base->next) { + if (base->flag & base_flag) { + add_collision_object(relations, base->object, 0, modifier_type); } - FOREACH_COLLECTION_OBJECT_RECURSIVE_END; } - else { - Scene *sce_iter; - Base *base; - /* add objects in same layer in scene */ - for (SETLOOPER(scene, sce_iter, base)) { - if ((base->flag & BASE_VISIBLED) != 0) { - add_collision_object(&objs, &numobj, &maxobj, base->object, self, level, modifier_type); - } - } - } - - *numcollobj= numobj; - return objs; + return relations; } -Object **get_collisionobjects(Scene *scene, Object *self, Collection *collection, unsigned int *numcollobj, unsigned int modifier_type) +void BKE_collision_relations_free(ListBase *relations) { - /* Need to check for active layers, too. - Otherwise this check fails if the objects are not on the same layer - DG */ - return get_collisionobjects_ext(scene, self, collection, numcollobj, modifier_type, true); + if (relations) { + BLI_freelistN(relations); + MEM_freeN(relations); + } } -static void add_collider_cache_object(ListBase **objs, Object *ob, Object *self, int level) +/* Create effective list of colliders from relations built beforehand. + * Self will be excluded. */ +Object **BKE_collision_objects_create(Depsgraph *depsgraph, Object *self, Collection *collection, unsigned int *numcollobj, unsigned int modifier_type) { - CollisionModifierData *cmd= NULL; - ColliderCache *col; + ListBase *relations = DEG_get_collision_relations(depsgraph, collection, modifier_type); - if (ob == self) - return; + if (!relations) { + *numcollobj = 0; + return NULL; + } - if (ob->pd && ob->pd->deflect) - cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision); + int maxnum = BLI_listbase_count(relations); + int num = 0; + Object **objects = MEM_callocN(sizeof(Object*) * maxnum, __func__); - if (cmd && cmd->bvhtree) { - if (*objs == NULL) - *objs = MEM_callocN(sizeof(ListBase), "ColliderCache array"); + for (CollisionRelation *relation = relations->first; relation; relation = relation->next) { + /* Get evaluated object. */ + Object *ob = (Object*)DEG_get_evaluated_id(depsgraph, &relation->ob->id); - col = MEM_callocN(sizeof(ColliderCache), "ColliderCache"); - col->ob = ob; - col->collmd = cmd; - /* make sure collider is properly set up */ - collision_move_object(cmd, 1.0, 0.0); - BLI_addtail(*objs, col); + if (ob != self) { + objects[num] = ob; + num++; + } } - /* objects in dupli collection, one level only for now */ - if (ob->dup_group && level == 0) { - Collection *collection= ob->dup_group; + if (num == 0) { + MEM_freeN(objects); + objects = NULL; + } - /* add objects */ - FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, object) - { - add_collider_cache_object(objs, object, self, level+1); - } - FOREACH_COLLECTION_OBJECT_RECURSIVE_END; + *numcollobj = num; + return objects; +} + +void BKE_collision_objects_free(Object **objects) +{ + if (objects) { + MEM_freeN(objects); } } -ListBase *get_collider_cache(Scene *scene, Object *self, Collection *collection) +/* Create effective list of colliders from relations built beforehand. + * Self will be excluded. */ +ListBase *BKE_collider_cache_create(Depsgraph *depsgraph, Object *self, Collection *collection) { - ListBase *objs= NULL; + ListBase *relations = DEG_get_collision_relations(depsgraph, collection, eModifierType_Collision); + ListBase *cache = NULL; - /* add object in same layer in scene */ - if (collection) { - FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, object) - { - add_collider_cache_object(&objs, object, self, 0); - } - FOREACH_COLLECTION_OBJECT_RECURSIVE_END; + if (!relations) { + return NULL; } - else { - Scene *sce_iter; - Base *base; - /* add objects in same layer in scene */ - for (SETLOOPER(scene, sce_iter, base)) { - if (!self || ((base->flag & BASE_VISIBLED) != 0)) - add_collider_cache_object(&objs, base->object, self, 0); + for (CollisionRelation *relation = relations->first; relation; relation = relation->next) { + /* Get evaluated object. */ + Object *ob = (Object*)DEG_get_evaluated_id(depsgraph, &relation->ob->id); + + if (ob == self) { + continue; + } + + CollisionModifierData *cmd = (CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision); + if (cmd && cmd->bvhtree) { + if (cache == NULL) { + cache = MEM_callocN(sizeof(ListBase), "ColliderCache array"); + } + ColliderCache *col = MEM_callocN(sizeof(ColliderCache), "ColliderCache"); + col->ob = ob; + col->collmd = cmd; + /* make sure collider is properly set up */ + collision_move_object(cmd, 1.0, 0.0); + BLI_addtail(cache, col); } } - return objs; + return cache; } -void free_collider_cache(ListBase **colliders) +void BKE_collider_cache_free(ListBase **colliders) { if (*colliders) { BLI_freelistN(*colliders); @@ -686,7 +686,7 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision } // cloth - object collisions -int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, float dt ) +int cloth_bvh_objcollision(Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, float step, float dt ) { Cloth *cloth= clmd->clothObject; BVHTree *cloth_bvh= cloth->bvhtree; @@ -712,7 +712,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa bvhtree_update_from_cloth ( clmd, 1 ); // 0 means STATIC, 1 means MOVING (see later in this function) bvhselftree_update_from_cloth ( clmd, 0 ); // 0 means STATIC, 1 means MOVING (see later in this function) - collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision); + collobjs = BKE_collision_objects_create(depsgraph, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision); if (!collobjs) return 0; @@ -894,8 +894,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa } while ( ret2 && ( clmd->coll_parms->loop_count>rounds ) ); - if (collobjs) - MEM_freeN(collobjs); + BKE_collision_objects_free(collobjs); return 1|MIN2 ( ret, 1 ); } @@ -1207,7 +1206,7 @@ static int cloth_points_objcollisions_resolve( } // cloth - object collisions -int cloth_points_objcollision(Object *ob, ClothModifierData *clmd, float step, float dt) +int cloth_points_objcollision(Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, float step, float dt) { Cloth *cloth= clmd->clothObject; BVHTree *cloth_bvh; @@ -1240,7 +1239,7 @@ int cloth_points_objcollision(Object *ob, ClothModifierData *clmd, float step, f /* balance tree */ BLI_bvhtree_balance(cloth_bvh); - collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision); + collobjs = BKE_collision_objects_create(depsgraph, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision); if (!collobjs) return 0; @@ -1321,15 +1320,14 @@ int cloth_points_objcollision(Object *ob, ClothModifierData *clmd, float step, f } while ( ret2 && ( clmd->coll_parms->loop_count>rounds ) ); - if (collobjs) - MEM_freeN(collobjs); + BKE_collision_objects_free(collobjs); BLI_bvhtree_free(cloth_bvh); return 1|MIN2 ( ret, 1 ); } -void cloth_find_point_contacts(Object *ob, ClothModifierData *clmd, float step, float dt, +void cloth_find_point_contacts(Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, float step, float dt, ColliderContacts **r_collider_contacts, int *r_totcolliders) { Cloth *cloth= clmd->clothObject; @@ -1363,7 +1361,7 @@ void cloth_find_point_contacts(Object *ob, ClothModifierData *clmd, float step, /* balance tree */ BLI_bvhtree_balance(cloth_bvh); - collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision); + collobjs = BKE_collision_objects_create(depsgraph, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision); if (!collobjs) { *r_collider_contacts = NULL; *r_totcolliders = 0; @@ -1421,8 +1419,7 @@ void cloth_find_point_contacts(Object *ob, ClothModifierData *clmd, float step, MEM_freeN(overlap); } - if (collobjs) - MEM_freeN(collobjs); + BKE_collision_objects_free(collobjs); BLI_bvhtree_free(cloth_bvh); diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c index 3639649eab5..7006e4ddaa6 100644 --- a/source/blender/blenkernel/intern/data_transfer.c +++ b/source/blender/blenkernel/intern/data_transfer.c @@ -42,12 +42,10 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BKE_cdderivedmesh.h" #include "BKE_context.h" #include "BKE_customdata.h" #include "BKE_data_transfer.h" #include "BKE_deform.h" -#include "BKE_DerivedMesh.h" #include "BKE_mesh.h" #include "BKE_mesh_mapping.h" #include "BKE_mesh_runtime.h" @@ -257,77 +255,76 @@ int BKE_object_data_transfer_dttype_to_srcdst_index(const int dtdata_type) /* Generic pre/post processing, only used by custom loop normals currently. */ static void data_transfer_dtdata_type_preprocess( - Object *UNUSED(ob_src), Object *UNUSED(ob_dst), DerivedMesh *dm_src, DerivedMesh *dm_dst, Mesh *me_dst, - const int dtdata_type, const bool dirty_nors_dst, const bool use_split_nors_src, const float split_angle_src) + Mesh *me_src, Mesh *me_dst, + const int dtdata_type, const bool dirty_nors_dst) { if (dtdata_type == DT_TYPE_LNOR) { /* Compute custom normals into regular loop normals, which will be used for the transfer. */ - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; - MEdge *edges_dst = dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge; - const int num_edges_dst = dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge; - MPoly *polys_dst = dm_dst ? dm_dst->getPolyArray(dm_dst) : me_dst->mpoly; - const int num_polys_dst = dm_dst ? dm_dst->getNumPolys(dm_dst) : me_dst->totpoly; - MLoop *loops_dst = dm_dst ? dm_dst->getLoopArray(dm_dst) : me_dst->mloop; - const int num_loops_dst = dm_dst ? dm_dst->getNumLoops(dm_dst) : me_dst->totloop; - CustomData *pdata_dst = dm_dst ? dm_dst->getPolyDataLayout(dm_dst) : &me_dst->pdata; - CustomData *ldata_dst = dm_dst ? dm_dst->getLoopDataLayout(dm_dst) : &me_dst->ldata; + MVert *verts_dst = me_dst->mvert; + const int num_verts_dst = me_dst->totvert; + MEdge *edges_dst = me_dst->medge; + const int num_edges_dst = me_dst->totedge; + MPoly *polys_dst = me_dst->mpoly; + const int num_polys_dst = me_dst->totpoly; + MLoop *loops_dst = me_dst->mloop; + const int num_loops_dst = me_dst->totloop; + CustomData *pdata_dst = &me_dst->pdata; + CustomData *ldata_dst = &me_dst->ldata; const bool use_split_nors_dst = (me_dst->flag & ME_AUTOSMOOTH) != 0; const float split_angle_dst = me_dst->smoothresh; - dm_src->calcLoopNormals(dm_src, use_split_nors_src, split_angle_src); + BKE_mesh_calc_normals_split(me_src); - if (dm_dst) { - dm_dst->calcLoopNormals(dm_dst, use_split_nors_dst, split_angle_dst); - } - else { - float (*poly_nors_dst)[3]; - float (*loop_nors_dst)[3]; - short (*custom_nors_dst)[2] = CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL); - - /* Cache poly nors into a temp CDLayer. */ - poly_nors_dst = CustomData_get_layer(pdata_dst, CD_NORMAL); - if (dirty_nors_dst || !poly_nors_dst) { - if (!poly_nors_dst) { - poly_nors_dst = CustomData_add_layer(pdata_dst, CD_NORMAL, CD_CALLOC, NULL, num_polys_dst); - CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); - } - BKE_mesh_calc_normals_poly(verts_dst, NULL, num_verts_dst, loops_dst, polys_dst, - num_loops_dst, num_polys_dst, poly_nors_dst, true); - } - /* Cache loop nors into a temp CDLayer. */ - loop_nors_dst = CustomData_get_layer(ldata_dst, CD_NORMAL); - if (dirty_nors_dst || loop_nors_dst) { - if (!loop_nors_dst) { - loop_nors_dst = CustomData_add_layer(ldata_dst, CD_NORMAL, CD_CALLOC, NULL, num_loops_dst); - CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); - } - BKE_mesh_normals_loop_split(verts_dst, num_verts_dst, edges_dst, num_edges_dst, - loops_dst, loop_nors_dst, num_loops_dst, - polys_dst, (const float (*)[3])poly_nors_dst, num_polys_dst, - use_split_nors_dst, split_angle_dst, NULL, custom_nors_dst, NULL); - } + float (*poly_nors_dst)[3]; + float (*loop_nors_dst)[3]; + short (*custom_nors_dst)[2] = CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL); + + /* Cache poly nors into a temp CDLayer. */ + poly_nors_dst = CustomData_get_layer(pdata_dst, CD_NORMAL); + const bool do_poly_nors_dst = (poly_nors_dst == NULL); + if (do_poly_nors_dst) { + poly_nors_dst = CustomData_add_layer(pdata_dst, CD_NORMAL, CD_CALLOC, NULL, num_polys_dst); + CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); + } + if (dirty_nors_dst || do_poly_nors_dst) { + BKE_mesh_calc_normals_poly( + verts_dst, NULL, num_verts_dst, loops_dst, polys_dst, + num_loops_dst, num_polys_dst, poly_nors_dst, true); + } + /* Cache loop nors into a temp CDLayer. */ + loop_nors_dst = CustomData_get_layer(ldata_dst, CD_NORMAL); + const bool do_loop_nors_dst = (loop_nors_dst == NULL); + if (do_loop_nors_dst) { + loop_nors_dst = CustomData_add_layer(ldata_dst, CD_NORMAL, CD_CALLOC, NULL, num_loops_dst); + CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); + } + if (dirty_nors_dst || do_loop_nors_dst) { + BKE_mesh_normals_loop_split( + verts_dst, num_verts_dst, edges_dst, num_edges_dst, + loops_dst, loop_nors_dst, num_loops_dst, + polys_dst, (const float (*)[3])poly_nors_dst, num_polys_dst, + use_split_nors_dst, split_angle_dst, NULL, custom_nors_dst, NULL); } } } static void data_transfer_dtdata_type_postprocess( - Object *UNUSED(ob_src), Object *UNUSED(ob_dst), DerivedMesh *UNUSED(dm_src), DerivedMesh *dm_dst, Mesh *me_dst, + Object *UNUSED(ob_src), Object *UNUSED(ob_dst), Mesh *UNUSED(me_src), Mesh *me_dst, const int dtdata_type, const bool changed) { if (dtdata_type == DT_TYPE_LNOR) { /* Bake edited destination loop normals into custom normals again. */ - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; - MEdge *edges_dst = dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge; - const int num_edges_dst = dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge; - MPoly *polys_dst = dm_dst ? dm_dst->getPolyArray(dm_dst) : me_dst->mpoly; - const int num_polys_dst = dm_dst ? dm_dst->getNumPolys(dm_dst) : me_dst->totpoly; - MLoop *loops_dst = dm_dst ? dm_dst->getLoopArray(dm_dst) : me_dst->mloop; - const int num_loops_dst = dm_dst ? dm_dst->getNumLoops(dm_dst) : me_dst->totloop; - CustomData *pdata_dst = dm_dst ? dm_dst->getPolyDataLayout(dm_dst) : &me_dst->pdata; - CustomData *ldata_dst = dm_dst ? dm_dst->getLoopDataLayout(dm_dst) : &me_dst->ldata; + MVert *verts_dst = me_dst->mvert; + const int num_verts_dst = me_dst->totvert; + MEdge *edges_dst = me_dst->medge; + const int num_edges_dst = me_dst->totedge; + MPoly *polys_dst = me_dst->mpoly; + const int num_polys_dst = me_dst->totpoly; + MLoop *loops_dst = me_dst->mloop; + const int num_loops_dst = me_dst->totloop; + CustomData *pdata_dst = &me_dst->pdata; + CustomData *ldata_dst = &me_dst->ldata; const float (*poly_nors_dst)[3] = CustomData_get_layer(pdata_dst, CD_NORMAL); float (*loop_nors_dst)[3] = CustomData_get_layer(ldata_dst, CD_NORMAL); @@ -531,7 +528,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst( continue; } data_src = CustomData_get_layer_n(cd_src, cddata_type, idx_src); - /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */ + /* If dest is a evaluated mesh (fro; ;odifier), we do not want to overwrite cdlayers of orig mesh! */ if (use_dupref_dst) { data_dst = CustomData_duplicate_referenced_layer_n(cd_dst, cddata_type, idx_src, num_elem_dst); } @@ -575,7 +572,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst( data_dst_to_delete[idx_dst] = false; } if (r_map) { - /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */ + /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */ if (use_dupref_dst) { data_dst = CustomData_duplicate_referenced_layer_n(cd_dst, cddata_type, idx_dst, num_elem_dst); } @@ -633,7 +630,7 @@ static bool data_transfer_layersmapping_cdlayers( data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst); } else if (use_dupref_dst && r_map) { - /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */ + /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */ data_dst = CustomData_duplicate_referenced_layer(cd_dst, cddata_type, num_elem_dst); } @@ -660,7 +657,7 @@ static bool data_transfer_layersmapping_cdlayers( if (tolayers >= 0) { /* Real-layer index */ idx_dst = tolayers; - /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */ + /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */ if (use_dupref_dst && r_map) { data_dst = CustomData_duplicate_referenced_layer_n(cd_dst, cddata_type, idx_dst, num_elem_dst); } @@ -676,7 +673,7 @@ static bool data_transfer_layersmapping_cdlayers( data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst); } else { - /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */ + /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */ if (use_dupref_dst && r_map) { data_dst = CustomData_duplicate_referenced_layer_n(cd_dst, cddata_type, idx_dst, num_elem_dst); } @@ -697,7 +694,7 @@ static bool data_transfer_layersmapping_cdlayers( CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst); } } - /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */ + /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */ if (use_dupref_dst && r_map) { data_dst = CustomData_duplicate_referenced_layer_n(cd_dst, cddata_type, idx_dst, num_elem_dst); } @@ -714,7 +711,7 @@ static bool data_transfer_layersmapping_cdlayers( CustomData_add_layer_named(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst, name); idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name); } - /* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */ + /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */ if (use_dupref_dst && r_map) { data_dst = CustomData_duplicate_referenced_layer_n(cd_dst, cddata_type, idx_dst, num_elem_dst); } @@ -763,7 +760,7 @@ static bool data_transfer_layersmapping_cdlayers( } static bool data_transfer_layersmapping_generate( - ListBase *r_map, Object *ob_src, Object *ob_dst, DerivedMesh *dm_src, DerivedMesh *dm_dst, Mesh *me_dst, + ListBase *r_map, Object *ob_src, Object *ob_dst, Mesh *me_src, Mesh *me_dst, const int elem_type, int cddata_type, int mix_mode, float mix_factor, const float *mix_weights, const int num_elem_dst, const bool use_create, const bool use_delete, const int fromlayers, const int tolayers, SpaceTransform *space_transform) @@ -775,12 +772,12 @@ static bool data_transfer_layersmapping_generate( if (elem_type == ME_VERT) { if (!(cddata_type & CD_FAKE)) { - cd_src = dm_src->getVertDataLayout(dm_src); - cd_dst = dm_dst ? dm_dst->getVertDataLayout(dm_dst) : &me_dst->vdata; + cd_src = &me_src->vdata; + cd_dst = &me_dst->vdata; if (!data_transfer_layersmapping_cdlayers(r_map, cddata_type, mix_mode, mix_factor, mix_weights, num_elem_dst, use_create, use_delete, - cd_src, cd_dst, dm_dst != NULL, + cd_src, cd_dst, me_dst != ob_dst->data, fromlayers, tolayers, interp, interp_data)) { @@ -795,24 +792,17 @@ static bool data_transfer_layersmapping_generate( const size_t data_offset = offsetof(MVert, bweight); const uint64_t data_flag = 0; - if (!(dm_src->cd_flag & ME_CDFLAG_VERT_BWEIGHT)) { - if (use_delete && !dm_dst) { + if (!(me_src->cd_flag & ME_CDFLAG_VERT_BWEIGHT)) { + if (use_delete) { me_dst->cd_flag &= ~ME_CDFLAG_VERT_BWEIGHT; } return true; } - if (dm_dst) { - dm_dst->cd_flag |= ME_CDFLAG_VERT_BWEIGHT; - } - else { - me_dst->cd_flag |= ME_CDFLAG_VERT_BWEIGHT; - } + me_dst->cd_flag |= ME_CDFLAG_VERT_BWEIGHT; if (r_map) { data_transfer_layersmapping_add_item(r_map, cddata_type, mix_mode, mix_factor, mix_weights, - dm_src->getVertArray(dm_src), - dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert, - dm_src->getNumVerts(dm_src), - dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert, + me_src->mvert, me_dst->mvert, + me_src->totvert, me_dst->totvert, elem_size, data_size, data_offset, data_flag, data_transfer_interp_char, interp_data); } @@ -821,12 +811,12 @@ static bool data_transfer_layersmapping_generate( else if (cddata_type == CD_FAKE_MDEFORMVERT) { bool ret; - cd_src = dm_src->getVertDataLayout(dm_src); - cd_dst = dm_dst ? dm_dst->getVertDataLayout(dm_dst) : &me_dst->vdata; + cd_src = &me_src->vdata; + cd_dst = &me_dst->vdata; ret = data_transfer_layersmapping_vgroups(r_map, mix_mode, mix_factor, mix_weights, num_elem_dst, use_create, use_delete, - ob_src, ob_dst, cd_src, cd_dst, dm_dst != NULL, + ob_src, ob_dst, cd_src, cd_dst, me_dst != ob_dst->data, fromlayers, tolayers); /* Mesh stores its dvert in a specific pointer too. :( */ @@ -840,12 +830,12 @@ static bool data_transfer_layersmapping_generate( } else if (elem_type == ME_EDGE) { if (!(cddata_type & CD_FAKE)) { /* Unused for edges, currently... */ - cd_src = dm_src->getEdgeDataLayout(dm_src); - cd_dst = dm_dst ? dm_dst->getEdgeDataLayout(dm_dst) : &me_dst->edata; + cd_src = &me_src->edata; + cd_dst = &me_dst->edata; if (!data_transfer_layersmapping_cdlayers(r_map, cddata_type, mix_mode, mix_factor, mix_weights, num_elem_dst, use_create, use_delete, - cd_src, cd_dst, dm_dst != NULL, + cd_src, cd_dst, me_dst != ob_dst->data, fromlayers, tolayers, interp, interp_data)) { @@ -860,24 +850,17 @@ static bool data_transfer_layersmapping_generate( const size_t data_offset = offsetof(MEdge, crease); const uint64_t data_flag = 0; - if (!(dm_src->cd_flag & ME_CDFLAG_EDGE_CREASE)) { - if (use_delete && !dm_dst) { + if (!(me_src->cd_flag & ME_CDFLAG_EDGE_CREASE)) { + if (use_delete && !me_dst) { me_dst->cd_flag &= ~ME_CDFLAG_EDGE_CREASE; } return true; } - if (dm_dst) { - dm_dst->cd_flag |= ME_CDFLAG_EDGE_CREASE; - } - else { - me_dst->cd_flag |= ME_CDFLAG_EDGE_CREASE; - } + 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, - dm_src->getEdgeArray(dm_src), - dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge, - dm_src->getNumEdges(dm_src), - dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge, + me_src->medge, me_dst->medge, + me_src->totedge, me_dst->totedge, elem_size, data_size, data_offset, data_flag, data_transfer_interp_char, interp_data); } @@ -889,24 +872,17 @@ static bool data_transfer_layersmapping_generate( const size_t data_offset = offsetof(MEdge, bweight); const uint64_t data_flag = 0; - if (!(dm_src->cd_flag & ME_CDFLAG_EDGE_BWEIGHT)) { - if (use_delete && !dm_dst) { + if (!(me_src->cd_flag & ME_CDFLAG_EDGE_BWEIGHT)) { + if (use_delete && !me_dst) { me_dst->cd_flag &= ~ME_CDFLAG_EDGE_BWEIGHT; } return true; } - if (dm_dst) { - dm_dst->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT; - } - else { - me_dst->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT; - } + me_dst->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT; if (r_map) { data_transfer_layersmapping_add_item(r_map, cddata_type, mix_mode, mix_factor, mix_weights, - dm_src->getEdgeArray(dm_src), - dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge, - dm_src->getNumEdges(dm_src), - dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge, + me_src->medge, me_dst->medge, + me_src->totedge, me_dst->totedge, elem_size, data_size, data_offset, data_flag, data_transfer_interp_char, interp_data); } @@ -920,10 +896,8 @@ static bool data_transfer_layersmapping_generate( data_transfer_layersmapping_add_item( r_map, cddata_type, mix_mode, mix_factor, mix_weights, - dm_src->getEdgeArray(dm_src), - dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge, - dm_src->getNumEdges(dm_src), - dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge, + me_src->medge, me_dst->medge, + me_src->totedge, me_dst->totedge, elem_size, data_size, data_offset, data_flag, NULL, interp_data); return true; } @@ -943,12 +917,12 @@ static bool data_transfer_layersmapping_generate( } if (!(cddata_type & CD_FAKE)) { - cd_src = dm_src->getLoopDataLayout(dm_src); - cd_dst = dm_dst ? dm_dst->getLoopDataLayout(dm_dst) : &me_dst->ldata; + cd_src = &me_src->ldata; + cd_dst = &me_dst->ldata; if (!data_transfer_layersmapping_cdlayers( r_map, cddata_type, mix_mode, mix_factor, mix_weights, - num_elem_dst, use_create, use_delete, cd_src, cd_dst, dm_dst != NULL, + num_elem_dst, use_create, use_delete, cd_src, cd_dst, me_dst != ob_dst->data, fromlayers, tolayers, interp, interp_data)) { @@ -967,12 +941,12 @@ static bool data_transfer_layersmapping_generate( } if (!(cddata_type & CD_FAKE)) { - cd_src = dm_src->getPolyDataLayout(dm_src); - cd_dst = dm_dst ? dm_dst->getPolyDataLayout(dm_dst) : &me_dst->pdata; + cd_src = &me_src->pdata; + cd_dst = &me_dst->pdata; if (!data_transfer_layersmapping_cdlayers( r_map, cddata_type, mix_mode, mix_factor, mix_weights, - num_elem_dst, use_create, use_delete, cd_src, cd_dst, dm_dst != NULL, + num_elem_dst, use_create, use_delete, cd_src, cd_dst, me_dst != ob_dst->data, fromlayers, tolayers, interp, interp_data)) { @@ -989,10 +963,8 @@ static bool data_transfer_layersmapping_generate( data_transfer_layersmapping_add_item( r_map, cddata_type, mix_mode, mix_factor, mix_weights, - dm_src->getPolyArray(dm_src), - dm_dst ? dm_dst->getPolyArray(dm_dst) : me_dst->mpoly, - dm_src->getNumPolys(dm_src), - dm_dst ? dm_dst->getNumPolys(dm_dst) : me_dst->totpoly, + me_src->mpoly, me_dst->mpoly, + me_src->totpoly, me_dst->totpoly, elem_size, data_size, data_offset, data_flag, NULL, interp_data); return true; } @@ -1015,22 +987,22 @@ void BKE_object_data_transfer_layout( Object *ob_src, Object *ob_dst, const int data_types, const bool use_delete, const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX]) { - DerivedMesh *dm_src; + Mesh *me_src; Mesh *me_dst; int i; const bool use_create = true; /* We always create needed layers here. */ - CustomDataMask dm_src_mask = CD_MASK_BAREMESH; + CustomDataMask me_src_mask = CD_MASK_BAREMESH; BLI_assert((ob_src != ob_dst) && (ob_src->type == OB_MESH) && (ob_dst->type == OB_MESH)); me_dst = ob_dst->data; - /* Get source DM.*/ - dm_src_mask |= BKE_object_data_transfer_dttypes_to_cdmask(data_types); - dm_src = mesh_get_derived_final(depsgraph, scene, ob_src, dm_src_mask); - if (!dm_src) { + /* Get source evaluated mesh.*/ + me_src_mask |= BKE_object_data_transfer_dttypes_to_cdmask(data_types); + me_src = mesh_get_eval_final(depsgraph, scene, ob_src, me_src_mask); + if (!me_src) { return; } @@ -1059,35 +1031,35 @@ void BKE_object_data_transfer_layout( const int num_elem_dst = me_dst->totvert; data_transfer_layersmapping_generate( - NULL, ob_src, ob_dst, dm_src, NULL, me_dst, ME_VERT, cddata_type, 0, 0.0f, NULL, + NULL, ob_src, ob_dst, me_src, me_dst, ME_VERT, cddata_type, 0, 0.0f, NULL, num_elem_dst, use_create, use_delete, fromlayers, tolayers, NULL); } if (DT_DATATYPE_IS_EDGE(dtdata_type)) { const int num_elem_dst = me_dst->totedge; data_transfer_layersmapping_generate( - NULL, ob_src, ob_dst, dm_src, NULL, me_dst, ME_EDGE, cddata_type, 0, 0.0f, NULL, + NULL, ob_src, ob_dst, me_src, me_dst, ME_EDGE, cddata_type, 0, 0.0f, NULL, num_elem_dst, use_create, use_delete, fromlayers, tolayers, NULL); } if (DT_DATATYPE_IS_LOOP(dtdata_type)) { const int num_elem_dst = me_dst->totloop; data_transfer_layersmapping_generate( - NULL, ob_src, ob_dst, dm_src, NULL, me_dst, ME_LOOP, cddata_type, 0, 0.0f, NULL, + NULL, ob_src, ob_dst, me_src, me_dst, ME_LOOP, cddata_type, 0, 0.0f, NULL, num_elem_dst, use_create, use_delete, fromlayers, tolayers, NULL); } if (DT_DATATYPE_IS_POLY(dtdata_type)) { const int num_elem_dst = me_dst->totpoly; data_transfer_layersmapping_generate( - NULL, ob_src, ob_dst, dm_src, NULL, me_dst, ME_POLY, cddata_type, 0, 0.0f, NULL, + NULL, ob_src, ob_dst, me_src, me_dst, ME_POLY, cddata_type, 0, 0.0f, NULL, num_elem_dst, use_create, use_delete, fromlayers, tolayers, NULL); } } } -bool BKE_object_data_transfer_dm( - struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, Object *ob_dst, DerivedMesh *dm_dst, +bool BKE_object_data_transfer_ex( + struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, Object *ob_dst, Mesh *me_dst, const int data_types, bool use_create, const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode, SpaceTransform *space_transform, const bool auto_transform, const float max_distance, const float ray_radius, const float islands_handling_precision, @@ -1103,9 +1075,8 @@ bool BKE_object_data_transfer_dm( SpaceTransform auto_space_transform; - DerivedMesh *dm_src; - Mesh *me_dst, *me_src; - bool dirty_nors_dst = true; /* Assumed always true if not using a dm as destination. */ + Mesh *me_src; + bool dirty_nors_dst = true; /* Assumed always true if not using an evaluated mesh as destination. */ int i; MDeformVert *mdef = NULL; @@ -1119,53 +1090,40 @@ bool BKE_object_data_transfer_dm( const bool use_delete = false; /* We never delete data layers from destination here. */ - CustomDataMask dm_src_mask = CD_MASK_BAREMESH; + CustomDataMask me_src_mask = CD_MASK_BAREMESH; BLI_assert((ob_src != ob_dst) && (ob_src->type == OB_MESH) && (ob_dst->type == OB_MESH)); - me_dst = ob_dst->data; - me_src = ob_src->data; - if (dm_dst) { - dirty_nors_dst = (dm_dst->dirty & DM_DIRTY_NORMALS) != 0; - use_create = false; /* Never create needed custom layers on DM (modifier case). */ + if (me_dst) { + dirty_nors_dst = (me_dst->runtime.cd_dirty_vert & CD_NORMAL) != 0; + /* Never create needed custom layers on passed destination mesh + * (assumed to *not* be ob_dst->data, aka modifier case). */ + use_create = false; + } + else { + me_dst = ob_dst->data; } if (vgroup_name) { - if (dm_dst) { - mdef = dm_dst->getVertDataArray(dm_dst, CD_MDEFORMVERT); - } - else { - mdef = CustomData_get_layer(&me_dst->vdata, CD_MDEFORMVERT); - } + mdef = CustomData_get_layer(&me_dst->vdata, CD_MDEFORMVERT); if (mdef) { vg_idx = defgroup_name_index(ob_dst, vgroup_name); } } - /* Get source DM.*/ - dm_src_mask |= BKE_object_data_transfer_dttypes_to_cdmask(data_types); - /* XXX Hack! In case this is being evaluated from dm stack, we cannot compute final dm, - * can lead to infinite recursion in case of dependency cycles of DataTransfer modifiers... - * Issue is, this means we cannot be sure to have requested cd layers in source. - * - * Also, we need to make a local copy of dm_src, otherwise we may end with concurrent creation - * of data in it (multi-threaded evaluation of the modifier stack, see T46672). - */ - dm_src = dm_dst ? ob_src->derivedFinal : mesh_get_derived_final(depsgraph, scene, ob_src, dm_src_mask); - if (!dm_src) { + /* Get source evaluated mesh.*/ + me_src_mask |= BKE_object_data_transfer_dttypes_to_cdmask(data_types); + me_src = mesh_get_eval_final(depsgraph, scene, ob_src, me_src_mask); + if (!me_src) { return changed; } - dm_src = CDDM_copy(dm_src); if (auto_transform) { - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; - if (space_transform == NULL) { space_transform = &auto_space_transform; } - BKE_mesh_remap_find_best_match_from_dm(verts_dst, num_verts_dst, dm_src, space_transform); + BKE_mesh_remap_find_best_match_from_mesh(me_dst->mvert, me_dst->totvert, me_src, space_transform); } /* Check all possible data types. @@ -1179,9 +1137,7 @@ bool BKE_object_data_transfer_dm( continue; } - data_transfer_dtdata_type_preprocess(ob_src, ob_dst, dm_src, dm_dst, me_dst, - dtdata_type, dirty_nors_dst, - (me_src->flag & ME_AUTOSMOOTH) != 0, me_src->smoothresh); + data_transfer_dtdata_type_preprocess(me_src, me_dst, dtdata_type, dirty_nors_dst); cddata_type = BKE_object_data_transfer_dttype_to_cdtype(dtdata_type); @@ -1195,11 +1151,11 @@ bool BKE_object_data_transfer_dm( } if (DT_DATATYPE_IS_VERT(dtdata_type)) { - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; + MVert *verts_dst = me_dst->mvert; + const int num_verts_dst = me_dst->totvert; if (!geom_map_init[VDATA]) { - const int num_verts_src = dm_src->getNumVerts(dm_src); + const int num_verts_src = me_src->totvert; if ((map_vert_mode == MREMAP_MODE_TOPOLOGY) && (num_verts_dst != num_verts_src)) { BKE_report(reports, RPT_ERROR, @@ -1207,13 +1163,13 @@ bool BKE_object_data_transfer_dm( "'Topology' mapping cannot be used in this case"); continue; } - if ((map_vert_mode & MREMAP_USE_EDGE) && (dm_src->getNumEdges(dm_src) == 0)) { + if ((map_vert_mode & MREMAP_USE_EDGE) && (me_src->totedge == 0)) { BKE_report(reports, RPT_ERROR, "Source mesh doesn't have any edges, " "None of the 'Edge' mappings can be used in this case"); continue; } - if ((map_vert_mode & MREMAP_USE_POLY) && (dm_src->getNumPolys(dm_src) == 0)) { + if ((map_vert_mode & MREMAP_USE_POLY) && (me_src->totpoly == 0)) { BKE_report(reports, RPT_ERROR, "Source mesh doesn't have any faces, " "None of the 'Face' mappings can be used in this case"); @@ -1225,9 +1181,9 @@ bool BKE_object_data_transfer_dm( continue; } - BKE_mesh_remap_calc_verts_from_dm( + BKE_mesh_remap_calc_verts_from_mesh( map_vert_mode, space_transform, max_distance, ray_radius, - verts_dst, num_verts_dst, dirty_nors_dst, dm_src, &geom_map[VDATA]); + verts_dst, num_verts_dst, dirty_nors_dst, me_src, &geom_map[VDATA]); geom_map_init[VDATA] = true; } @@ -1237,7 +1193,7 @@ bool BKE_object_data_transfer_dm( } if (data_transfer_layersmapping_generate( - &lay_map, ob_src, ob_dst, dm_src, dm_dst, me_dst, ME_VERT, + &lay_map, ob_src, ob_dst, me_src, me_dst, ME_VERT, cddata_type, mix_mode, mix_factor, weights[VDATA], num_verts_dst, use_create, use_delete, fromlayers, tolayers, space_transform)) { @@ -1253,13 +1209,13 @@ bool BKE_object_data_transfer_dm( } } if (DT_DATATYPE_IS_EDGE(dtdata_type)) { - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; - MEdge *edges_dst = dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge; - const int num_edges_dst = dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge; + MVert *verts_dst = me_dst->mvert; + const int num_verts_dst = me_dst->totvert; + MEdge *edges_dst = me_dst->medge; + const int num_edges_dst = me_dst->totedge; if (!geom_map_init[EDATA]) { - const int num_edges_src = dm_src->getNumEdges(dm_src); + const int num_edges_src = me_src->totedge; if ((map_edge_mode == MREMAP_MODE_TOPOLOGY) && (num_edges_dst != num_edges_src)) { BKE_report(reports, RPT_ERROR, @@ -1267,7 +1223,7 @@ bool BKE_object_data_transfer_dm( "'Topology' mapping cannot be used in this case"); continue; } - if ((map_edge_mode & MREMAP_USE_POLY) && (dm_src->getNumPolys(dm_src) == 0)) { + if ((map_edge_mode & MREMAP_USE_POLY) && (me_src->totpoly == 0)) { BKE_report(reports, RPT_ERROR, "Source mesh doesn't have any faces, " "None of the 'Face' mappings can be used in this case"); @@ -1279,10 +1235,10 @@ bool BKE_object_data_transfer_dm( continue; } - BKE_mesh_remap_calc_edges_from_dm( + BKE_mesh_remap_calc_edges_from_mesh( map_edge_mode, space_transform, max_distance, ray_radius, verts_dst, num_verts_dst, edges_dst, num_edges_dst, dirty_nors_dst, - dm_src, &geom_map[EDATA]); + me_src, &geom_map[EDATA]); geom_map_init[EDATA] = true; } @@ -1294,7 +1250,7 @@ bool BKE_object_data_transfer_dm( } if (data_transfer_layersmapping_generate( - &lay_map, ob_src, ob_dst, dm_src, dm_dst, me_dst, ME_EDGE, + &lay_map, ob_src, ob_dst, me_src, me_dst, ME_EDGE, cddata_type, mix_mode, mix_factor, weights[EDATA], num_edges_dst, use_create, use_delete, fromlayers, tolayers, space_transform)) { @@ -1310,21 +1266,21 @@ bool BKE_object_data_transfer_dm( } } if (DT_DATATYPE_IS_LOOP(dtdata_type)) { - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; - MEdge *edges_dst = dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge; - const int num_edges_dst = dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge; - MPoly *polys_dst = dm_dst ? dm_dst->getPolyArray(dm_dst) : me_dst->mpoly; - const int num_polys_dst = dm_dst ? dm_dst->getNumPolys(dm_dst) : me_dst->totpoly; - MLoop *loops_dst = dm_dst ? dm_dst->getLoopArray(dm_dst) : me_dst->mloop; - const int num_loops_dst = dm_dst ? dm_dst->getNumLoops(dm_dst) : me_dst->totloop; - CustomData *pdata_dst = dm_dst ? dm_dst->getPolyDataLayout(dm_dst) : &me_dst->pdata; - CustomData *ldata_dst = dm_dst ? dm_dst->getLoopDataLayout(dm_dst) : &me_dst->ldata; + MVert *verts_dst = me_dst->mvert; + const int num_verts_dst = me_dst->totvert; + MEdge *edges_dst = me_dst->medge; + const int num_edges_dst = me_dst->totedge; + MPoly *polys_dst = me_dst->mpoly; + const int num_polys_dst = me_dst->totpoly; + MLoop *loops_dst = me_dst->mloop; + const int num_loops_dst = me_dst->totloop; + CustomData *pdata_dst = &me_dst->pdata; + CustomData *ldata_dst = &me_dst->ldata; MeshRemapIslandsCalc island_callback = data_transfer_get_loop_islands_generator(cddata_type); if (!geom_map_init[LDATA]) { - const int num_loops_src = dm_src->getNumLoops(dm_src); + const int num_loops_src = me_src->totloop; if ((map_loop_mode == MREMAP_MODE_TOPOLOGY) && (num_loops_dst != num_loops_src)) { BKE_report(reports, RPT_ERROR, @@ -1332,7 +1288,7 @@ bool BKE_object_data_transfer_dm( "'Topology' mapping cannot be used in this case"); continue; } - if ((map_loop_mode & MREMAP_USE_EDGE) && (dm_src->getNumEdges(dm_src) == 0)) { + if ((map_loop_mode & MREMAP_USE_EDGE) && (me_src->totedge == 0)) { BKE_report(reports, RPT_ERROR, "Source mesh doesn't have any edges, " "None of the 'Edge' mappings can be used in this case"); @@ -1344,13 +1300,13 @@ bool BKE_object_data_transfer_dm( continue; } - BKE_mesh_remap_calc_loops_from_dm( + BKE_mesh_remap_calc_loops_from_mesh( map_loop_mode, space_transform, max_distance, ray_radius, verts_dst, num_verts_dst, edges_dst, num_edges_dst, loops_dst, num_loops_dst, polys_dst, num_polys_dst, ldata_dst, pdata_dst, (me_dst->flag & ME_AUTOSMOOTH) != 0, me_dst->smoothresh, dirty_nors_dst, - dm_src, (me_src->flag & ME_AUTOSMOOTH) != 0, me_src->smoothresh, + me_src, island_callback, islands_handling_precision, &geom_map[LDATA]); geom_map_init[LDATA] = true; } @@ -1363,7 +1319,7 @@ bool BKE_object_data_transfer_dm( } if (data_transfer_layersmapping_generate( - &lay_map, ob_src, ob_dst, dm_src, dm_dst, me_dst, ME_LOOP, + &lay_map, ob_src, ob_dst, me_src, me_dst, ME_LOOP, cddata_type, mix_mode, mix_factor, weights[LDATA], num_loops_dst, use_create, use_delete, fromlayers, tolayers, space_transform)) { @@ -1379,16 +1335,16 @@ bool BKE_object_data_transfer_dm( } } if (DT_DATATYPE_IS_POLY(dtdata_type)) { - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; - MPoly *polys_dst = dm_dst ? dm_dst->getPolyArray(dm_dst) : me_dst->mpoly; - const int num_polys_dst = dm_dst ? dm_dst->getNumPolys(dm_dst) : me_dst->totpoly; - MLoop *loops_dst = dm_dst ? dm_dst->getLoopArray(dm_dst) : me_dst->mloop; - const int num_loops_dst = dm_dst ? dm_dst->getNumLoops(dm_dst) : me_dst->totloop; - CustomData *pdata_dst = dm_dst ? dm_dst->getPolyDataLayout(dm_dst) : &me_dst->pdata; + MVert *verts_dst = me_dst->mvert; + const int num_verts_dst = me_dst->totvert; + MPoly *polys_dst = me_dst->mpoly; + const int num_polys_dst = me_dst->totpoly; + MLoop *loops_dst = me_dst->mloop; + const int num_loops_dst = me_dst->totloop; + CustomData *pdata_dst = &me_dst->pdata; if (!geom_map_init[PDATA]) { - const int num_polys_src = dm_src->getNumPolys(dm_src); + const int num_polys_src = me_src->totpoly; if ((map_poly_mode == MREMAP_MODE_TOPOLOGY) && (num_polys_dst != num_polys_src)) { BKE_report(reports, RPT_ERROR, @@ -1396,7 +1352,7 @@ bool BKE_object_data_transfer_dm( "'Topology' mapping cannot be used in this case"); continue; } - if ((map_poly_mode & MREMAP_USE_EDGE) && (dm_src->getNumEdges(dm_src) == 0)) { + if ((map_poly_mode & MREMAP_USE_EDGE) && (me_src->totedge == 0)) { BKE_report(reports, RPT_ERROR, "Source mesh doesn't have any edges, " "None of the 'Edge' mappings can be used in this case"); @@ -1408,11 +1364,11 @@ bool BKE_object_data_transfer_dm( continue; } - BKE_mesh_remap_calc_polys_from_dm( + BKE_mesh_remap_calc_polys_from_mesh( map_poly_mode, space_transform, max_distance, ray_radius, verts_dst, num_verts_dst, loops_dst, num_loops_dst, polys_dst, num_polys_dst, pdata_dst, dirty_nors_dst, - dm_src, &geom_map[PDATA]); + me_src, &geom_map[PDATA]); geom_map_init[PDATA] = true; } @@ -1424,7 +1380,7 @@ bool BKE_object_data_transfer_dm( } if (data_transfer_layersmapping_generate( - &lay_map, ob_src, ob_dst, dm_src, dm_dst, me_dst, ME_POLY, + &lay_map, ob_src, ob_dst, me_src, me_dst, ME_POLY, cddata_type, mix_mode, mix_factor, weights[PDATA], num_polys_dst, use_create, use_delete, fromlayers, tolayers, space_transform)) { @@ -1440,14 +1396,13 @@ bool BKE_object_data_transfer_dm( } } - data_transfer_dtdata_type_postprocess(ob_src, ob_dst, dm_src, dm_dst, me_dst, dtdata_type, changed); + data_transfer_dtdata_type_postprocess(ob_src, ob_dst, me_src, me_dst, dtdata_type, changed); } for (i = 0; i < DATAMAX; i++) { BKE_mesh_remap_free(&geom_map[i]); MEM_SAFE_FREE(weights[i]); } - dm_src->release(dm_src); return changed; @@ -1467,7 +1422,7 @@ bool BKE_object_data_transfer_mesh( const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup, ReportList *reports) { - return BKE_object_data_transfer_dm( + return BKE_object_data_transfer_ex( depsgraph, scene, ob_src, ob_dst, NULL, data_types, use_create, map_vert_mode, map_edge_mode, map_loop_mode, map_poly_mode, space_transform, auto_transform, diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index ad055a727a9..84bac76202a 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -855,8 +855,6 @@ static void curve_calc_modifiers_pre( for (; md; md = md->next) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; - if (!modifier_isEnabled(scene, md, required_mode)) continue; if (mti->type != eModifierTypeType_OnlyDeform) @@ -961,7 +959,6 @@ static void curve_calc_modifiers_post( for (; md; md = md->next) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; if (!modifier_isEnabled(scene, md, required_mode)) continue; diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index ed2566c9bb5..c1bdfc42a05 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -56,6 +56,7 @@ #include "BKE_armature.h" #include "BKE_bvhutils.h" /* bvh tree */ #include "BKE_collection.h" +#include "BKE_collision.h" #include "BKE_colorband.h" #include "BKE_cdderivedmesh.h" #include "BKE_constraint.h" @@ -490,28 +491,17 @@ static void scene_setSubframe(Scene *scene, float subframe) scene->r.subframe = subframe; } -static int surface_getBrushFlags(DynamicPaintSurface *surface, const Depsgraph *depsgraph) +static int surface_getBrushFlags(DynamicPaintSurface *surface, Depsgraph *depsgraph) { - Base *base = BKE_collection_or_layer_objects(depsgraph, NULL, NULL, surface->brush_group); - Object *brushObj = NULL; - ModifierData *md = NULL; + unsigned int numobjects; + Object **objects = BKE_collision_objects_create(depsgraph, NULL, surface->brush_group, &numobjects, eModifierType_DynamicPaint); int flags = 0; - while (base) { - brushObj = NULL; + for (int i = 0; i < numobjects; i++) { + Object *brushObj = objects[i]; - /* select object */ - brushObj = base->object; - - /* next item */ - base = base->next; - - if (!brushObj) { - continue; - } - - md = modifiers_findByType(brushObj, eModifierType_DynamicPaint); + ModifierData *md = modifiers_findByType(brushObj, eModifierType_DynamicPaint); if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) { DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md; @@ -524,6 +514,8 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, const Depsgraph * } } + BKE_collision_objects_free(objects); + return flags; } @@ -4886,7 +4878,7 @@ static void dynamic_paint_prepare_effect_cb( EffectedPoint epoint; pd_point_from_loc(scene, realCoord[bData->s_pos[index]].v, vel, index, &epoint); epoint.vel_to_sec = 1.0f; - pdDoEffectors(effectors, NULL, surface->effector_weights, &epoint, forc, NULL); + BKE_effectors_apply(effectors, NULL, surface->effector_weights, &epoint, forc, NULL); } /* if global gravity is enabled, add it too */ @@ -4926,7 +4918,7 @@ static int dynamicPaint_prepareEffectStep( /* Init force data if required */ if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) { - ListBase *effectors = pdInitEffectors(depsgraph, scene, ob, NULL, surface->effector_weights, true); + ListBase *effectors = BKE_effectors_create(depsgraph, ob, NULL, surface->effector_weights); /* allocate memory for force data (dir vector + strength) */ *force = MEM_mallocN(sData->total_points * 4 * sizeof(float), "PaintEffectForces"); @@ -4950,7 +4942,7 @@ static int dynamicPaint_prepareEffectStep( } average_force /= sData->total_points; } - pdEndEffectors(&effectors); + BKE_effectors_free(effectors); } /* Get number of required steps using average point distance @@ -5758,7 +5750,7 @@ static void dynamic_paint_generate_bake_data_cb( } } -static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const Depsgraph *depsgraph, Object *ob) +static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Depsgraph *depsgraph, Object *ob) { PaintSurfaceData *sData = surface->data; PaintBakeData *bData = sData->bData; @@ -5890,6 +5882,7 @@ static int dynamicPaint_doStep( PaintSurfaceData *sData = surface->data; PaintBakeData *bData = sData->bData; DynamicPaintCanvasSettings *canvas = surface->canvas; + const bool for_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); int ret = 1; if (sData->total_points < 1) @@ -5910,29 +5903,18 @@ static int dynamicPaint_doStep( * Loop through surface's target paint objects and do painting */ { - Object *brushObj = NULL; - ModifierData *md = NULL; - Base *base = BKE_collection_or_layer_objects(depsgraph, NULL, NULL, surface->brush_group); + unsigned int numobjects; + Object **objects = BKE_collision_objects_create(depsgraph, NULL, surface->brush_group, &numobjects, eModifierType_DynamicPaint); /* backup current scene frame */ int scene_frame = scene->r.cfra; float scene_subframe = scene->r.subframe; - while (base) { - brushObj = NULL; - /* select object */ - brushObj = base->object; - - /* next item */ - base = base->next; - - if (!brushObj) { - /* skip item */ - continue; - } + for (int i = 0; i < numobjects; i++) { + Object *brushObj = objects[i]; /* check if target has an active dp modifier */ - md = modifiers_findByType(brushObj, eModifierType_DynamicPaint); + ModifierData *md = modifiers_findByType(brushObj, eModifierType_DynamicPaint); if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) { DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md; /* make sure we're dealing with a brush */ @@ -5960,7 +5942,7 @@ static int dynamicPaint_doStep( /* Apply brush on the surface depending on it's collision type */ if (brush->psys && brush->psys->part && ELEM(brush->psys->part->type, PART_EMITTER, PART_FLUID) && - psys_check_enabled(brushObj, brush->psys, G.is_rendering)) + psys_check_enabled(brushObj, brush->psys, for_render)) { /* Paint a particle system */ BKE_animsys_evaluate_animdata(depsgraph, scene, &brush->psys->part->id, brush->psys->part->adt, @@ -5994,6 +5976,8 @@ static int dynamicPaint_doStep( } } } + + BKE_collision_objects_free(objects); } /* surfaces operations that use adjacency data */ diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 7e506570b7e..bb4cf1c5753 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -74,6 +74,7 @@ #include "BKE_smoke.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_physics.h" #include "DEG_depsgraph_query.h" #include "RE_render_ext.h" @@ -135,9 +136,8 @@ PartDeflect *object_add_collision_fields(int type) return pd; } -/* ***************** PARTICLES ***************** */ +/************************ PARTICLES ***************************/ -/* -------------------------- Effectors ------------------ */ void free_partdeflect(PartDeflect *pd) { if (!pd) @@ -149,111 +149,7 @@ void free_partdeflect(PartDeflect *pd) MEM_freeN(pd); } -static EffectorCache *new_effector_cache(struct Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd) -{ - EffectorCache *eff = MEM_callocN(sizeof(EffectorCache), "EffectorCache"); - eff->depsgraph = depsgraph; - eff->scene = scene; - eff->ob = ob; - eff->psys = psys; - eff->pd = pd; - eff->frame = -1; - return eff; -} -static void add_object_to_effectors(ListBase **effectors, struct Depsgraph *depsgraph, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation) -{ - EffectorCache *eff = NULL; - - if ( ob == ob_src ) - return; - - if (for_simulation) { - if (weights->weight[ob->pd->forcefield] == 0.0f ) - return; - - if (ob->pd->shape == PFIELD_SHAPE_POINTS && !ob->derivedFinal ) - return; - } - - if (*effectors == NULL) - *effectors = MEM_callocN(sizeof(ListBase), "effectors list"); - - eff = new_effector_cache(depsgraph, scene, ob, NULL, ob->pd); - - /* make sure imat is up to date */ - invert_m4_m4(ob->imat, ob->obmat); - - BLI_addtail(*effectors, eff); -} -static void add_particles_to_effectors(ListBase **effectors, struct Depsgraph *depsgraph, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation) -{ - ParticleSettings *part= psys->part; - - if ( !psys_check_enabled(ob, psys, G.is_rendering) ) - return; - - if ( psys == psys_src && (part->flag & PART_SELF_EFFECT) == 0) - return; - - if ( part->pd && part->pd->forcefield && (!for_simulation || weights->weight[part->pd->forcefield] != 0.0f)) { - if (*effectors == NULL) - *effectors = MEM_callocN(sizeof(ListBase), "effectors list"); - - BLI_addtail(*effectors, new_effector_cache(depsgraph, scene, ob, psys, part->pd)); - } - - if (part->pd2 && part->pd2->forcefield && (!for_simulation || weights->weight[part->pd2->forcefield] != 0.0f)) { - if (*effectors == NULL) - *effectors = MEM_callocN(sizeof(ListBase), "effectors list"); - - BLI_addtail(*effectors, new_effector_cache(depsgraph, scene, ob, psys, part->pd2)); - } -} - -/* returns ListBase handle with objects taking part in the effecting */ -ListBase *pdInitEffectors( - struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, ParticleSystem *psys_src, - EffectorWeights *weights, bool for_simulation) -{ - Base *base = BKE_collection_or_layer_objects(depsgraph, scene, NULL, weights->group); - ListBase *effectors = NULL; - - for (; base; base = base->next) { - if (base->object->pd && base->object->pd->forcefield) { - add_object_to_effectors(&effectors, depsgraph, scene, weights, base->object, ob_src, for_simulation); - } - - if (base->object->particlesystem.first) { - ParticleSystem *psys= base->object->particlesystem.first; - - for (; psys; psys=psys->next) { - add_particles_to_effectors(&effectors, depsgraph, scene, weights, base->object, psys, psys_src, for_simulation); - } - } - } - - if (for_simulation) { - pdPrecalculateEffectors(depsgraph, effectors); - } - - return effectors; -} - -void pdEndEffectors(ListBase **effectors) -{ - if (*effectors) { - EffectorCache *eff = (*effectors)->first; - - for (; eff; eff=eff->next) { - if (eff->guide_data) - MEM_freeN(eff->guide_data); - } - - BLI_freelistN(*effectors); - MEM_freeN(*effectors); - *effectors = NULL; - } -} +/******************** EFFECTOR RELATIONS ***********************/ static void precalculate_effector(struct Depsgraph *depsgraph, EffectorCache *eff) { @@ -296,12 +192,150 @@ static void precalculate_effector(struct Depsgraph *depsgraph, EffectorCache *ef } } -void pdPrecalculateEffectors(struct Depsgraph *depsgraph, ListBase *effectors) +static void add_effector_relation(ListBase *relations, Object *ob, ParticleSystem *psys, PartDeflect *pd) +{ + EffectorRelation *relation = MEM_callocN(sizeof(EffectorRelation), "EffectorRelation"); + relation->ob = ob; + relation->psys = psys; + relation->pd = pd; + + BLI_addtail(relations, relation); +} + +static void add_effector_evaluation(ListBase **effectors, Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd) { - if (effectors) { - EffectorCache *eff = effectors->first; - for (; eff; eff=eff->next) - precalculate_effector(depsgraph, eff); + if (*effectors == NULL) { + *effectors = MEM_callocN(sizeof(ListBase), "effector effectors"); + } + + EffectorCache *eff = MEM_callocN(sizeof(EffectorCache), "EffectorCache"); + eff->depsgraph = depsgraph; + eff->scene = scene; + eff->ob = ob; + eff->psys = psys; + eff->pd = pd; + eff->frame = -1; + BLI_addtail(*effectors, eff); + + precalculate_effector(depsgraph, eff); +} + +/* Create list of effector relations in the collection or entire scene. + * This is used by the depsgraph to build relations, as well as faster + * lookup of effectors during evaluation. */ +ListBase *BKE_effector_relations_create( + Depsgraph *depsgraph, + ViewLayer *view_layer, + Collection *collection) +{ + Base *base = BKE_collection_or_layer_objects(view_layer, collection); + const bool for_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); + const int base_flag = (for_render) ? BASE_ENABLED_RENDER : BASE_ENABLED_VIEWPORT; + + ListBase *relations = MEM_callocN(sizeof(ListBase), "effector relations"); + + for (; base; base = base->next) { + if (!(base->flag & base_flag)) { + continue; + } + + Object *ob = base->object; + + if (ob->pd && ob->pd->forcefield) { + add_effector_relation(relations, ob, NULL, ob->pd); + } + + for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) { + ParticleSettings *part = psys->part; + + if (psys_check_enabled(ob, psys, for_render)) { + if (part->pd && part->pd->forcefield) { + add_effector_relation(relations, ob, psys, part->pd); + } + if (part->pd2 && part->pd2->forcefield) { + add_effector_relation(relations, ob, psys, part->pd2); + } + } + } + } + + return relations; +} + +void BKE_effector_relations_free(ListBase *lb) +{ + if (lb) { + BLI_freelistN(lb); + MEM_freeN(lb); + } +} + +/* Create effective list of effectors from relations built beforehand. */ +ListBase *BKE_effectors_create( + Depsgraph *depsgraph, + Object *ob_src, + ParticleSystem *psys_src, + EffectorWeights *weights) +{ + Scene *scene = DEG_get_evaluated_scene(depsgraph); + ListBase *relations = DEG_get_effector_relations(depsgraph, weights->group); + ListBase *effectors = NULL; + + if (!relations) { + return NULL; + } + + for (EffectorRelation *relation = relations->first; relation; relation = relation->next) { + /* Get evaluated object. */ + Object *ob = (Object*)DEG_get_evaluated_id(depsgraph, &relation->ob->id); + + if (relation->psys) { + /* Get evaluated particle system. */ + ParticleSystem *psys = BLI_findstring(&ob->particlesystem, + relation->psys->name, offsetof(ParticleSystem, name)); + ParticleSettings *part = psys->part; + + if (psys == psys_src && (part->flag & PART_SELF_EFFECT) == 0) { + continue; + } + + PartDeflect *pd = (relation->pd == relation->psys->part->pd) ? part->pd : part->pd2; + if (weights->weight[pd->forcefield] == 0.0f) { + continue; + } + + add_effector_evaluation(&effectors, depsgraph, scene, ob, psys, pd); + } + else { + /* Object effector. */ + if (ob == ob_src) { + continue; + } + else if (weights->weight[ob->pd->forcefield] == 0.0f) { + continue; + } + else if (ob->pd->shape == PFIELD_SHAPE_POINTS && !ob->derivedFinal) { + continue; + } + + add_effector_evaluation(&effectors, depsgraph, scene, ob, NULL, ob->pd); + } + } + + return effectors; +} + +void BKE_effectors_free(ListBase *lb) +{ + if (lb) { + for (EffectorCache *eff = lb->first; eff; eff = eff->next) { + if (eff->guide_data) { + MEM_freeN(eff->guide_data); + } + } + + BLI_freelistN(lb); + MEM_freeN(lb); } } @@ -392,7 +426,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect return visibility; if (!colls) - colls = get_collider_cache(eff->scene, eff->ob, NULL); + colls = BKE_collider_cache_create(eff->depsgraph, eff->ob, NULL); if (!colls) return visibility; @@ -430,7 +464,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect } if (!colliders) - free_collider_cache(&colls); + BKE_collider_cache_free(&colls); return visibility; } @@ -960,7 +994,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected } } -/* -------- pdDoEffectors() -------- +/* -------- BKE_effectors_apply() -------- * generic force/speed system, now used for particles and softbodies * scene = scene where it runs in, for time and stuff * lb = listbase with objects that take part in effecting @@ -973,7 +1007,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected * flags = only used for softbody wind now * guide = old speed of particle */ -void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *weights, EffectedPoint *point, float *force, float *impulse) +void BKE_effectors_apply(ListBase *effectors, ListBase *colliders, EffectorWeights *weights, EffectedPoint *point, float *force, float *impulse) { /* * Modifies the force on a particle according to its diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 4689575655e..13f7716cd80 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1767,16 +1767,16 @@ void BKE_keyblock_update_from_mesh(Mesh *me, KeyBlock *kb) } } -void BKE_keyblock_convert_from_mesh(Mesh *me, KeyBlock *kb) +void BKE_keyblock_convert_from_mesh(Mesh *me, Key *key, KeyBlock *kb) { - int tot = me->totvert; + const int len = me->totvert; if (me->totvert == 0) return; MEM_SAFE_FREE(kb->data); - kb->data = MEM_mallocN(me->key->elemsize * tot, __func__); - kb->totelem = tot; + kb->data = MEM_malloc_arrayN((size_t)len, (size_t)key->elemsize, __func__); + kb->totelem = len; BKE_keyblock_update_from_mesh(me, kb); } diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index 0e81e6570e2..1d5b6de22f4 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -72,7 +72,7 @@ void BKE_lamp_init(Lamp *la) la->samp = 3; la->bias = 1.0f; la->soft = 3.0f; - la->area_size = la->area_sizey = la->area_sizez = 0.1f; + la->area_size = la->area_sizey = la->area_sizez = 0.25f; la->buffers = 1; la->preview = NULL; la->falloff_type = LA_FALLOFF_INVSQUARE; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index a885495f2bf..0af329449ca 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -1045,12 +1045,10 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec for (; md; md = md->next) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; - if (!(mti->flags & eModifierTypeFlag_AcceptsLattice)) continue; if (!(md->mode & eModifierMode_Realtime)) continue; if (editmode && !(md->mode & eModifierMode_Editmode)) continue; - if (mti->isDisabled && mti->isDisabled(md, 0)) continue; + if (mti->isDisabled && mti->isDisabled(scene, md, 0)) continue; if (mti->type != eModifierTypeType_OnlyDeform) continue; if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob_orig, &numVerts); diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 3c184ed5dcf..78139256b8b 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -379,7 +379,7 @@ void BKE_view_layer_base_deselect_all(ViewLayer *view_layer) void BKE_view_layer_base_select(struct ViewLayer *view_layer, Base *selbase) { view_layer->basact = selbase; - if ((selbase->flag & BASE_SELECTABLED) != 0) { + if ((selbase->flag & BASE_SELECTABLE) != 0) { selbase->flag |= BASE_SELECTED; } } @@ -493,7 +493,9 @@ static LayerCollection *collection_from_index(ListBase *lb, const int number, in } (*i)++; + } + for (LayerCollection *lc = lb->first; lc; lc = lc->next) { LayerCollection *lc_nested = collection_from_index(&lc->layer_collections, number, i); if (lc_nested) { return lc_nested; @@ -591,7 +593,9 @@ static int index_from_collection(ListBase *lb, const LayerCollection *lc, int *i } (*i)++; + } + for (LayerCollection *lcol = lb->first; lcol; lcol = lcol->next) { int i_nested = index_from_collection(&lcol->layer_collections, lc, i); if (i_nested != -1) { return i_nested; @@ -621,7 +625,7 @@ int BKE_layer_collection_findindex(ViewLayer *view_layer, const LayerCollection * in at least one layer collection. That list is also synchronized here, and * stores state like selection. */ -static void layer_collection_sync( +static int layer_collection_sync( ViewLayer *view_layer, const ListBase *lb_scene, ListBase *lb_layer, ListBase *new_object_bases, int parent_exclude, int parent_restrict) @@ -648,6 +652,7 @@ static void layer_collection_sync( /* Add layer collections for any new scene collections, and ensure order is the same. */ ListBase new_lb_layer = {NULL, NULL}; + int runtime_flag = 0; for (const CollectionChild *child = lb_scene->first; child; child = child->next) { Collection *collection = child->collection; @@ -669,15 +674,19 @@ static void layer_collection_sync( } /* Sync child collections. */ - layer_collection_sync( + int child_runtime_flag = layer_collection_sync( view_layer, &collection->children, &lc->layer_collections, new_object_bases, lc->flag, child_restrict); /* Layer collection exclude is not inherited. */ if (lc->flag & LAYER_COLLECTION_EXCLUDE) { + lc->runtime_flag = 0; continue; } + else { + lc->runtime_flag = child_runtime_flag; + } /* Sync objects, except if collection was excluded. */ for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { @@ -699,22 +708,50 @@ static void layer_collection_sync( BLI_ghash_insert(view_layer->object_bases_hash, base->object, base); } - if ((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) { - base->flag |= BASE_VISIBLED | BASE_VISIBLE_VIEWPORT; + int object_restrict = base->object->restrictflag; - if ((child_restrict & COLLECTION_RESTRICT_SELECT) == 0) { - base->flag |= BASE_SELECTABLED; + if (((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) && + ((object_restrict & OB_RESTRICT_VIEW) == 0)) + { + base->flag |= BASE_VISIBLE | BASE_ENABLED | BASE_ENABLED_VIEWPORT; + + if (((child_restrict & COLLECTION_RESTRICT_SELECT) == 0) && + ((object_restrict & OB_RESTRICT_SELECT) == 0)) + { + base->flag |= BASE_SELECTABLE; } } - if ((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) { - base->flag |= BASE_VISIBLE_RENDER; + + if (((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) && + ((object_restrict & OB_RESTRICT_RENDER) == 0)) + + { + base->flag |= BASE_ENABLED_RENDER; } + + /* Update runtime flags used for display and tools. */ + if (base->flag & BASE_VISIBLE) { + lc->runtime_flag |= LAYER_COLLECTION_HAS_ENABLED_OBJECTS; + } + + if (base->flag & BASE_HIDDEN) { + view_layer->runtime_flag |= VIEW_LAYER_HAS_HIDE; + } + else if (base->flag & BASE_VISIBLE) { + lc->runtime_flag |= LAYER_COLLECTION_HAS_VISIBLE_OBJECTS; + } + + lc->runtime_flag |= LAYER_COLLECTION_HAS_OBJECTS; } + + runtime_flag |= lc->runtime_flag; } /* Replace layer collection list with new one. */ *lb_layer = new_lb_layer; BLI_assert(BLI_listbase_count(lb_scene) == BLI_listbase_count(lb_layer)); + + return runtime_flag; } /** @@ -739,9 +776,11 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer) /* Clear visible and selectable flags to be reset. */ for (Base *base = view_layer->object_bases.first; base; base = base->next) { - base->flag &= ~(BASE_VISIBLED | BASE_SELECTABLED | BASE_VISIBLE_VIEWPORT | BASE_VISIBLE_RENDER); + base->flag &= ~(BASE_VISIBLE | BASE_ENABLED | BASE_SELECTABLE | BASE_ENABLED_VIEWPORT | BASE_ENABLED_RENDER); } + view_layer->runtime_flag = 0; + /* Generate new layer connections and object bases when collections changed. */ CollectionChild child = {NULL, NULL, scene->master_collection}; const ListBase collections = {&child, &child}; @@ -847,7 +886,7 @@ bool BKE_layer_collection_objects_select(ViewLayer *view_layer, LayerCollection } } else { - if ((base->flag & BASE_SELECTABLED) && !(base->flag & BASE_SELECTED)) { + if ((base->flag & BASE_SELECTABLE) && !(base->flag & BASE_SELECTED)) { base->flag |= BASE_SELECTED; changed = true; } @@ -863,6 +902,95 @@ bool BKE_layer_collection_objects_select(ViewLayer *view_layer, LayerCollection return changed; } +bool BKE_layer_collection_has_selected_objects(ViewLayer *view_layer, LayerCollection *lc) +{ + if (lc->collection->flag & COLLECTION_RESTRICT_SELECT) { + return false; + } + + if (!(lc->flag & LAYER_COLLECTION_EXCLUDE)) { + for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) { + Base *base = BKE_view_layer_base_find(view_layer, cob->ob); + + if (base && (base->flag & BASE_SELECTED)) { + return true; + } + } + } + + for (LayerCollection *iter = lc->layer_collections.first; iter; iter = iter->next) { + if (BKE_layer_collection_has_selected_objects(view_layer, iter)) { + return true; + } + } + + return false; +} + +/* ---------------------------------------------------------------------- */ + +/* Update after toggling visibility of an object base. */ +void BKE_base_set_visible(Scene *scene, ViewLayer *view_layer, Base *base, bool extend) +{ + if (!extend) { + /* Make only one base visible. */ + for (Base *other = view_layer->object_bases.first; other; other = other->next) { + other->flag |= BASE_HIDDEN; + } + + base->flag &= ~BASE_HIDDEN; + } + else { + /* Toggle visibility of one base. */ + base->flag ^= BASE_HIDDEN; + } + + BKE_layer_collection_sync(scene, view_layer); +} + +void BKE_layer_collection_set_visible(Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool extend) +{ + if (!extend) { + /* Make only objects from one collection visible. */ + for (Base *base = view_layer->object_bases.first; base; base = base->next) { + base->flag |= BASE_HIDDEN; + } + + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(lc->collection, ob) + { + Base *base = BLI_ghash_lookup(view_layer->object_bases_hash, ob); + + if (base) { + base->flag &= ~BASE_HIDDEN; + } + } + FOREACH_COLLECTION_OBJECT_RECURSIVE_END; + + BKE_layer_collection_activate(view_layer, lc); + } + else { + /* Toggle visibility of objects from collection. */ + bool hide = (lc->runtime_flag & LAYER_COLLECTION_HAS_VISIBLE_OBJECTS) != 0; + + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(lc->collection, ob) + { + Base *base = BLI_ghash_lookup(view_layer->object_bases_hash, ob); + + if (base) { + if (hide) { + base->flag |= BASE_HIDDEN; + } + else { + base->flag &= ~BASE_HIDDEN; + } + } + } + FOREACH_COLLECTION_OBJECT_RECURSIVE_END; + } + + BKE_layer_collection_sync(scene, view_layer); +} + /* ---------------------------------------------------------------------- */ static LayerCollection *find_layer_collection_by_scene_collection(LayerCollection *lc, const Collection *collection) @@ -1487,12 +1615,12 @@ void BKE_view_layer_selected_objects_iterator_end(BLI_Iterator *UNUSED(iter)) void BKE_view_layer_visible_objects_iterator_begin(BLI_Iterator *iter, void *data_in) { - objects_iterator_begin(iter, data_in, BASE_VISIBLED); + objects_iterator_begin(iter, data_in, BASE_VISIBLE); } void BKE_view_layer_visible_objects_iterator_next(BLI_Iterator *iter) { - objects_iterator_next(iter, BASE_VISIBLED); + objects_iterator_next(iter, BASE_VISIBLE); } void BKE_view_layer_visible_objects_iterator_end(BLI_Iterator *UNUSED(iter)) @@ -1563,12 +1691,12 @@ void BKE_view_layer_selected_bases_iterator_end(BLI_Iterator *UNUSED(iter)) void BKE_view_layer_visible_bases_iterator_begin(BLI_Iterator *iter, void *data_in) { - object_bases_iterator_begin(iter, data_in, BASE_VISIBLED); + object_bases_iterator_begin(iter, data_in, BASE_VISIBLE); } void BKE_view_layer_visible_bases_iterator_next(BLI_Iterator *iter) { - object_bases_iterator_next(iter, BASE_VISIBLED); + object_bases_iterator_next(iter, BASE_VISIBLE); } void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *UNUSED(iter)) @@ -1626,7 +1754,7 @@ void BKE_view_layer_renderable_objects_iterator_next(BLI_Iterator *iter) if (ob->id.flag & LIB_TAG_DOIT) { ob->id.flag &= ~LIB_TAG_DOIT; - if ((base->flag & BASE_VISIBLED) != 0) { + if ((base->flag & BASE_VISIBLE) != 0) { iter->skip = false; iter->current = ob; } @@ -1723,16 +1851,6 @@ void BKE_view_layer_bases_in_mode_iterator_end(BLI_Iterator *UNUSED(iter)) /** \} */ -static bool base_is_visible(Base *base, eEvaluationMode mode) -{ - if (mode == DAG_EVAL_VIEWPORT) { - return ((base->flag & BASE_VISIBLE_VIEWPORT) != 0); - } - else { - return ((base->flag & BASE_VISIBLE_RENDER) != 0); - } -} - /* Evaluation */ void BKE_layer_eval_view_layer( @@ -1744,6 +1862,7 @@ void BKE_layer_eval_view_layer( /* Visibility based on depsgraph mode. */ const eEvaluationMode mode = DEG_get_mode(depsgraph); + const int base_flag = (mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT : BASE_ENABLED_RENDER; /* Create array of bases, for fast index-based lookup. */ const int num_object_bases = BLI_listbase_count(&view_layer->object_bases); @@ -1752,26 +1871,29 @@ void BKE_layer_eval_view_layer( num_object_bases, sizeof(Base *), "view_layer->object_bases_array"); int base_index = 0; for (Base *base = view_layer->object_bases.first; base; base = base->next) { - /* Set visibility. */ - if (base_is_visible(base, mode)) { - base->flag |= BASE_VISIBLED; + /* Compute visibility for depsgraph evaluation mode. */ + if (base->flag & base_flag) { + base->flag |= BASE_ENABLED | BASE_VISIBLE; + + if (mode == DAG_EVAL_VIEWPORT && (base->flag & BASE_HIDDEN)) { + base->flag &= ~BASE_VISIBLE; + } } else { - base->flag &= ~(BASE_VISIBLED | BASE_SELECTABLED); + base->flag &= ~(BASE_ENABLED | BASE_VISIBLE | BASE_SELECTABLE); } /* If base is not selectabled, clear select. */ - if ((base->flag & BASE_SELECTABLED) == 0) { + if ((base->flag & BASE_SELECTABLE) == 0) { base->flag &= ~BASE_SELECTED; } view_layer->object_bases_array[base_index++] = base; } - /* Flush back base flag to the original view layer for editing. */ - ViewLayer *view_layer_orig = DEG_get_input_view_layer(depsgraph); if (view_layer == DEG_get_evaluated_view_layer(depsgraph)) { + ViewLayer *view_layer_orig = DEG_get_input_view_layer(depsgraph); Base *base_orig = view_layer_orig->object_bases.first; const Base *base_eval = view_layer->object_bases.first; while (base_orig != NULL) { @@ -1780,14 +1902,6 @@ void BKE_layer_eval_view_layer( base_eval = base_eval->next; } } - - /* Hidden objects can't be active. */ - if (view_layer->basact && !(view_layer->basact->flag & BASE_VISIBLED)) { - view_layer->basact = NULL; - } - if (view_layer_orig->basact && !(view_layer_orig->basact->flag & BASE_VISIBLED)) { - view_layer_orig->basact = NULL; - } } void BKE_layer_eval_view_layer_indexed( diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index c45903aa1fa..c2cdc8df1e6 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -2558,3 +2558,11 @@ void BKE_id_tag_clear_atomic(ID *id, int tag) { atomic_fetch_and_and_int32(&id->tag, ~tag); } + +/** Check that given ID pointer actually is in G_MAIN. + * Main intended use is for debug asserts in places we cannot easily get rid of G_Main... */ +bool BKE_id_is_in_gobal_main(ID *id) +{ + /* We do not want to fail when id is NULL here, even though this is a bit strange behavior... */ + return (id == NULL || BLI_findindex(which_libbase(G_MAIN, GS(id->name)), id) != -1); +} diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 21b2ab6b454..ab8c8695495 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -359,6 +359,7 @@ void BKE_material_resize_id(Main *bmain, ID *id, short totcol, bool do_id_user) } *totcolp = totcol; + DEG_id_tag_update(id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); } @@ -376,6 +377,8 @@ void BKE_material_append_id(Main *bmain, ID *id, Material *ma) id_us_plus((ID *)ma); test_all_objects_materials(bmain, id); + + DEG_id_tag_update(id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); } } @@ -410,6 +413,7 @@ Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i, bool update_data material_data_index_remove_id(id, index); } + DEG_id_tag_update(id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); } } @@ -437,6 +441,7 @@ void BKE_material_clear_id(Main *bmain, ID *id, bool update_data) material_data_index_clear_id(id); } + DEG_id_tag_update(id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); } } @@ -532,6 +537,7 @@ void BKE_material_resize_object(Main *bmain, Object *ob, const short totcol, boo if (ob->totcol && ob->actcol == 0) ob->actcol = 1; if (ob->actcol > ob->totcol) ob->actcol = ob->totcol; + DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE | DEG_TAG_GEOMETRY); DEG_relations_tag_update(bmain); } diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c index 33b38d60183..3fc5d1ca51c 100644 --- a/source/blender/blenkernel/intern/mesh_convert.c +++ b/source/blender/blenkernel/intern/mesh_convert.c @@ -817,7 +817,6 @@ void BKE_mesh_to_curve(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object * /* make new mesh data from the original copy */ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_MESH); ListBase nurblist = {NULL, NULL}; - bool needsFree = false; BKE_mesh_to_curve_nurblist(me_eval, &nurblist, 0); BKE_mesh_to_curve_nurblist(me_eval, &nurblist, 1); @@ -832,30 +831,7 @@ void BKE_mesh_to_curve(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object * ob->data = cu; ob->type = OB_CURVE; - /* curve objects can't contain DM in usual cases, we could free memory */ - needsFree = true; - } - - /* Just to avoid dangling pointer, dm will be removed. */ - { - DerivedMesh *dm = ob->derivedFinal; - if (dm != NULL) { - dm->needsFree = needsFree; - dm->release(dm); - } - } - - if (needsFree) { - BKE_mesh_free(me_eval); - - ob->derivedFinal = NULL; - ob->runtime.mesh_eval = NULL; - - /* curve object could have got bounding box only in special cases */ - if (ob->bb) { - MEM_freeN(ob->bb); - ob->bb = NULL; - } + BKE_object_free_derived_caches(ob); } } @@ -1150,13 +1126,11 @@ Mesh *BKE_mesh_create_derived_for_modifier( KeyBlock *kb; ModifierEvalContext mectx = {depsgraph, ob, 0}; - md->scene = scene; - if (!(md->mode & eModifierMode_Realtime)) { return NULL; } - if (mti->isDisabled && mti->isDisabled(md, 0)) { + if (mti->isDisabled && mti->isDisabled(scene, md, 0)) { return NULL; } @@ -1235,7 +1209,7 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act cos = CustomData_get_layer_n(&mesh_src->vdata, CD_SHAPEKEY, i); kb->totelem = mesh_src->totvert; - kb->data = kbcos = MEM_malloc_arrayN(kb->totelem, 3 * sizeof(float), "kbcos DerivedMesh.c"); + kb->data = kbcos = MEM_malloc_arrayN(kb->totelem, 3 * sizeof(float), __func__); if (kb->uid == actshape_uid) { MVert *mvert = mesh_src->mvert; @@ -1256,7 +1230,7 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act MEM_freeN(kb->data); kb->totelem = mesh_src->totvert; - kb->data = MEM_calloc_arrayN(kb->totelem, 3 * sizeof(float), "kb->data derivedmesh.c"); + kb->data = MEM_calloc_arrayN(kb->totelem, 3 * sizeof(float), __func__); fprintf(stderr, "%s: lost a shapekey layer: '%s'! (bmesh internal error)\n", __func__, kb->name); } } diff --git a/source/blender/blenkernel/intern/mesh_iterators.c b/source/blender/blenkernel/intern/mesh_iterators.c new file mode 100644 index 00000000000..48f6b1820f8 --- /dev/null +++ b/source/blender/blenkernel/intern/mesh_iterators.c @@ -0,0 +1,154 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/mesh_iterators.c + * \ingroup bke + * + * Functions for iterating mesh features. + */ + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BKE_customdata.h" +#include "BKE_mesh.h" +#include "BKE_mesh_iterators.h" + + +/* Copied from cdDM_foreachMappedVert */ +void BKE_mesh_foreach_mapped_vert( + Mesh *mesh, + void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]), + void *userData, + MeshForeachFlag flag) +{ + MVert *mv = mesh->mvert; + const int *index = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX); + int i; + + if (index) { + for (i = 0; i < mesh->totvert; i++, mv++) { + const short *no = (flag & MESH_FOREACH_USE_NORMAL) ? mv->no : NULL; + const int orig = *index++; + if (orig == ORIGINDEX_NONE) continue; + func(userData, orig, mv->co, NULL, no); + } + } + else { + for (i = 0; i < mesh->totvert; i++, mv++) { + const short *no = (flag & MESH_FOREACH_USE_NORMAL) ? mv->no : NULL; + func(userData, i, mv->co, NULL, no); + } + } +} + +/* Copied from cdDM_foreachMappedEdge */ +void BKE_mesh_foreach_mapped_edge( + Mesh *mesh, + void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]), + void *userData) +{ + MVert *mv = mesh->mvert; + MEdge *med = mesh->medge; + int i, orig, *index = CustomData_get_layer(&mesh->edata, CD_ORIGINDEX); + + for (i = 0; i < mesh->totedge; i++, med++) { + if (index) { + orig = *index++; + if (orig == ORIGINDEX_NONE) continue; + func(userData, orig, mv[med->v1].co, mv[med->v2].co); + } + else + func(userData, i, mv[med->v1].co, mv[med->v2].co); + } +} + +/* Copied from cdDM_foreachMappedLoop */ +void BKE_mesh_foreach_mapped_loop( + Mesh *mesh, + void (*func)(void *userData, int vertex_index, int face_index, const float co[3], const float no[3]), + void *userData, + MeshForeachFlag flag) +{ + /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData, EditDerivedBMesh would + * return loop data from bmesh itself. */ + const float (*lnors)[3] = (flag & MESH_FOREACH_USE_NORMAL) ? CustomData_get_layer(&mesh->ldata, CD_NORMAL) : NULL; + + const MVert *mv = mesh->mvert; + const MLoop *ml = mesh->mloop; + const MPoly *mp = mesh->mpoly; + const int *v_index = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX); + const int *f_index = CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX); + int p_idx, i; + + for (p_idx = 0; p_idx < mesh->totpoly; ++p_idx, ++mp) { + for (i = 0; i < mp->totloop; ++i, ++ml) { + const int v_idx = v_index ? v_index[ml->v] : ml->v; + const int f_idx = f_index ? f_index[p_idx] : p_idx; + const float *no = lnors ? *lnors++ : NULL; + if (!ELEM(ORIGINDEX_NONE, v_idx, f_idx)) { + func(userData, v_idx, f_idx, mv[ml->v].co, no); + } + } + } +} + +/* Copied from cdDM_foreachMappedFaceCenter */ +void BKE_mesh_foreach_mapped_face_center( + Mesh *mesh, + void (*func)(void *userData, int index, const float cent[3], const float no[3]), + void *userData, + MeshForeachFlag flag) +{ + MVert *mvert = mesh->mvert; + MPoly *mp; + MLoop *ml; + int i, orig, *index; + + index = CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX); + mp = mesh->mpoly; + for (i = 0; i < mesh->totpoly; i++, mp++) { + float cent[3]; + float *no, _no[3]; + + if (index) { + orig = *index++; + if (orig == ORIGINDEX_NONE) continue; + } + else { + orig = i; + } + + ml = &mesh->mloop[mp->loopstart]; + BKE_mesh_calc_poly_center(mp, ml, mvert, cent); + + if (flag & MESH_FOREACH_USE_NORMAL) { + BKE_mesh_calc_poly_normal(mp, ml, mvert, (no = _no)); + } + else { + no = NULL; + } + + func(userData, orig, cent, no); + } + +} diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c index eef8657482f..c882cc0a7fa 100644 --- a/source/blender/blenkernel/intern/mesh_remap.c +++ b/source/blender/blenkernel/intern/mesh_remap.c @@ -28,6 +28,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "BLI_utildefines.h" @@ -41,10 +42,10 @@ #include "BKE_bvhutils.h" #include "BKE_customdata.h" -#include "BKE_DerivedMesh.h" #include "BKE_mesh.h" #include "BKE_mesh_mapping.h" #include "BKE_mesh_remap.h" /* own include */ +#include "BKE_mesh_runtime.h" #include "BLI_strict_flags.h" @@ -121,8 +122,8 @@ static bool mesh_remap_bvhtree_query_raycast( * In other words, beyond a certain (relatively small) distance, all differences have more or less the same weight * in final result, which allows to reduce influence of a few high differences, in favor of a global good matching. */ -float BKE_mesh_remap_calc_difference_from_dm( - const SpaceTransform *space_transform, const MVert *verts_dst, const int numverts_dst, DerivedMesh *dm_src) +float BKE_mesh_remap_calc_difference_from_mesh( + const SpaceTransform *space_transform, const MVert *verts_dst, const int numverts_dst, Mesh *me_src) { BVHTreeFromMesh treedata = {NULL}; BVHTreeNearest nearest = {0}; @@ -131,7 +132,7 @@ float BKE_mesh_remap_calc_difference_from_dm( float result = 0.0f; int i; - bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS, 2); + BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_VERTS, 2); nearest.index = -1; for (i = 0; i < numverts_dst; i++) { @@ -250,8 +251,8 @@ static void mesh_calc_eigen_matrix( /** * Set r_space_transform so that best bbox of dst matches best bbox of src. */ -void BKE_mesh_remap_find_best_match_from_dm( - const MVert *verts_dst, const int numverts_dst, DerivedMesh *dm_src, SpaceTransform *r_space_transform) +void BKE_mesh_remap_find_best_match_from_mesh( + const MVert *verts_dst, const int numverts_dst, Mesh *me_src, SpaceTransform *r_space_transform) { /* Note that those are done so that we successively get actual mirror matrix (by multiplication of columns)... */ const float mirrors[][3] = { @@ -269,15 +270,14 @@ void BKE_mesh_remap_find_best_match_from_dm( float mat_src[4][4], mat_dst[4][4], best_mat_dst[4][4]; float best_match = FLT_MAX, match; - const int numverts_src = dm_src->getNumVerts(dm_src); - float (*vcos_src)[3] = MEM_mallocN(sizeof(*vcos_src) * (size_t)numverts_src, __func__); - dm_src->getVertCos(dm_src, vcos_src); + const int numverts_src = me_src->totvert; + float (*vcos_src)[3] = BKE_mesh_vertexCos_get(me_src, NULL); mesh_calc_eigen_matrix(NULL, (const float (*)[3])vcos_src, numverts_src, mat_src); mesh_calc_eigen_matrix(verts_dst, NULL, numverts_dst, mat_dst); BLI_space_transform_global_from_matrices(r_space_transform, mat_dst, mat_src); - match = BKE_mesh_remap_calc_difference_from_dm(r_space_transform, verts_dst, numverts_dst, dm_src); + match = BKE_mesh_remap_calc_difference_from_mesh(r_space_transform, verts_dst, numverts_dst, me_src); best_match = match; copy_m4_m4(best_mat_dst, mat_dst); @@ -288,7 +288,7 @@ void BKE_mesh_remap_find_best_match_from_dm( mul_v3_fl(mat_dst[2], (*mirr)[2]); BLI_space_transform_global_from_matrices(r_space_transform, mat_dst, mat_src); - match = BKE_mesh_remap_calc_difference_from_dm(r_space_transform, verts_dst, numverts_dst, dm_src); + match = BKE_mesh_remap_calc_difference_from_mesh(r_space_transform, verts_dst, numverts_dst, me_src); if (match < best_match) { best_match = match; copy_m4_m4(best_mat_dst, mat_dst); @@ -430,9 +430,9 @@ typedef struct IslandResult { /* Will be enough in 99% of cases. */ #define MREMAP_DEFAULT_BUFSIZE 32 -void BKE_mesh_remap_calc_verts_from_dm( +void BKE_mesh_remap_calc_verts_from_mesh( const int mode, const SpaceTransform *space_transform, const float max_dist, const float ray_radius, - const MVert *verts_dst, const int numverts_dst, const bool UNUSED(dirty_nors_dst), DerivedMesh *dm_src, + const MVert *verts_dst, const int numverts_dst, const bool UNUSED(dirty_nors_dst), Mesh *me_src, MeshPairRemap *r_map) { const float full_weight = 1.0f; @@ -444,7 +444,7 @@ void BKE_mesh_remap_calc_verts_from_dm( BKE_mesh_remap_init(r_map, numverts_dst); if (mode == MREMAP_MODE_TOPOLOGY) { - BLI_assert(numverts_dst == dm_src->getNumVerts(dm_src)); + BLI_assert(numverts_dst == me_src->totvert); for (i = 0; i < numverts_dst; i++) { mesh_remap_item_define(r_map, i, FLT_MAX, 0, 1, &i, &full_weight); } @@ -457,7 +457,7 @@ void BKE_mesh_remap_calc_verts_from_dm( float tmp_co[3], tmp_no[3]; if (mode == MREMAP_MODE_VERT_NEAREST) { - bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS, 2); + BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_VERTS, 2); nearest.index = -1; for (i = 0; i < numverts_dst; i++) { @@ -478,11 +478,10 @@ void BKE_mesh_remap_calc_verts_from_dm( } } else if (ELEM(mode, MREMAP_MODE_VERT_EDGE_NEAREST, MREMAP_MODE_VERT_EDGEINTERP_NEAREST)) { - MEdge *edges_src = dm_src->getEdgeArray(dm_src); - float (*vcos_src)[3] = MEM_mallocN(sizeof(*vcos_src) * (size_t)dm_src->getNumVerts(dm_src), __func__); - dm_src->getVertCos(dm_src, vcos_src); + MEdge *edges_src = me_src->medge; + float (*vcos_src)[3] = BKE_mesh_vertexCos_get(me_src, NULL); - bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_EDGES, 2); + BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_EDGES, 2); nearest.index = -1; for (i = 0; i < numverts_dst; i++) { @@ -530,18 +529,16 @@ void BKE_mesh_remap_calc_verts_from_dm( else if (ELEM(mode, MREMAP_MODE_VERT_POLY_NEAREST, MREMAP_MODE_VERT_POLYINTERP_NEAREST, MREMAP_MODE_VERT_POLYINTERP_VNORPROJ)) { - MPoly *polys_src = dm_src->getPolyArray(dm_src); - MLoop *loops_src = dm_src->getLoopArray(dm_src); - float (*vcos_src)[3] = MEM_mallocN(sizeof(*vcos_src) * (size_t)dm_src->getNumVerts(dm_src), __func__); + MPoly *polys_src = me_src->mpoly; + MLoop *loops_src = me_src->mloop; + float (*vcos_src)[3] = BKE_mesh_vertexCos_get(me_src, NULL); size_t tmp_buff_size = MREMAP_DEFAULT_BUFSIZE; float (*vcos)[3] = MEM_mallocN(sizeof(*vcos) * tmp_buff_size, __func__); int *indices = MEM_mallocN(sizeof(*indices) * tmp_buff_size, __func__); float *weights = MEM_mallocN(sizeof(*weights) * tmp_buff_size, __func__); - dm_src->getVertCos(dm_src, vcos_src); - - bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2); + BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_LOOPTRI, 2); if (mode == MREMAP_MODE_VERT_POLYINTERP_VNORPROJ) { for (i = 0; i < numverts_dst; i++) { @@ -625,10 +622,10 @@ void BKE_mesh_remap_calc_verts_from_dm( } } -void BKE_mesh_remap_calc_edges_from_dm( +void BKE_mesh_remap_calc_edges_from_mesh( const int mode, const SpaceTransform *space_transform, const float max_dist, const float ray_radius, const MVert *verts_dst, const int numverts_dst, const MEdge *edges_dst, const int numedges_dst, - const bool UNUSED(dirty_nors_dst), DerivedMesh *dm_src, MeshPairRemap *r_map) + const bool UNUSED(dirty_nors_dst), Mesh *me_src, MeshPairRemap *r_map) { const float full_weight = 1.0f; const float max_dist_sq = max_dist * max_dist; @@ -639,7 +636,7 @@ void BKE_mesh_remap_calc_edges_from_dm( BKE_mesh_remap_init(r_map, numedges_dst); if (mode == MREMAP_MODE_TOPOLOGY) { - BLI_assert(numedges_dst == dm_src->getNumEdges(dm_src)); + BLI_assert(numedges_dst == me_src->totedge); for (i = 0; i < numedges_dst; i++) { mesh_remap_item_define(r_map, i, FLT_MAX, 0, 1, &i, &full_weight); } @@ -652,10 +649,10 @@ void BKE_mesh_remap_calc_edges_from_dm( float tmp_co[3], tmp_no[3]; if (mode == MREMAP_MODE_EDGE_VERT_NEAREST) { - const int num_verts_src = dm_src->getNumVerts(dm_src); - const int num_edges_src = dm_src->getNumEdges(dm_src); - MEdge *edges_src = dm_src->getEdgeArray(dm_src); - float (*vcos_src)[3] = MEM_mallocN(sizeof(*vcos_src) * (size_t)dm_src->getNumVerts(dm_src), __func__); + const int num_verts_src = me_src->totvert; + const int num_edges_src = me_src->totedge; + MEdge *edges_src = me_src->medge; + float (*vcos_src)[3] = BKE_mesh_vertexCos_get(me_src, NULL); MeshElemMap *vert_to_edge_src_map; int *vert_to_edge_src_map_mem; @@ -672,9 +669,7 @@ void BKE_mesh_remap_calc_edges_from_dm( BKE_mesh_vert_edge_map_create(&vert_to_edge_src_map, &vert_to_edge_src_map_mem, edges_src, num_verts_src, num_edges_src); - dm_src->getVertCos(dm_src, vcos_src); - - bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_VERTS, 2); + BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_VERTS, 2); nearest.index = -1; for (i = 0; i < numedges_dst; i++) { @@ -774,7 +769,7 @@ void BKE_mesh_remap_calc_edges_from_dm( MEM_freeN(vert_to_edge_src_map_mem); } else if (mode == MREMAP_MODE_EDGE_NEAREST) { - bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_EDGES, 2); + BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_EDGES, 2); nearest.index = -1; for (i = 0; i < numedges_dst; i++) { @@ -795,13 +790,12 @@ void BKE_mesh_remap_calc_edges_from_dm( } } else if (mode == MREMAP_MODE_EDGE_POLY_NEAREST) { - MEdge *edges_src = dm_src->getEdgeArray(dm_src); - MPoly *polys_src = dm_src->getPolyArray(dm_src); - MLoop *loops_src = dm_src->getLoopArray(dm_src); - float (*vcos_src)[3] = MEM_mallocN(sizeof(*vcos_src) * (size_t)dm_src->getNumVerts(dm_src), __func__); + MEdge *edges_src = me_src->medge; + MPoly *polys_src = me_src->mpoly; + MLoop *loops_src = me_src->mloop; + float (*vcos_src)[3] = BKE_mesh_vertexCos_get(me_src, NULL); - dm_src->getVertCos(dm_src, vcos_src); - bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2); + BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_LOOPTRI, 2); for (i = 0; i < numedges_dst; i++) { interp_v3_v3v3(tmp_co, verts_dst[edges_dst[i].v1].co, verts_dst[edges_dst[i].v2].co, 0.5f); @@ -820,9 +814,9 @@ void BKE_mesh_remap_calc_edges_from_dm( int best_eidx_src = -1; for (; nloops--; ml_src++) { - MEdge *me_src = &edges_src[ml_src->e]; - float *co1_src = vcos_src[me_src->v1]; - float *co2_src = vcos_src[me_src->v2]; + MEdge *med_src = &edges_src[ml_src->e]; + float *co1_src = vcos_src[med_src->v1]; + float *co2_src = vcos_src[med_src->v2]; float co_src[3]; float dist_sq; @@ -847,14 +841,14 @@ void BKE_mesh_remap_calc_edges_from_dm( } else if (mode == MREMAP_MODE_EDGE_EDGEINTERP_VNORPROJ) { const int num_rays_min = 5, num_rays_max = 100; - const int numedges_src = dm_src->getNumEdges(dm_src); + const int numedges_src = me_src->totedge; /* Subtleness - this one we can allocate only max number of cast rays per edges! */ int *indices = MEM_mallocN(sizeof(*indices) * (size_t)min_ii(numedges_src, num_rays_max), __func__); /* Here it's simpler to just allocate for all edges :/ */ float *weights = MEM_mallocN(sizeof(*weights) * (size_t)numedges_src, __func__); - bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_EDGES, 2); + BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_EDGES, 2); for (i = 0; i < numedges_dst; i++) { /* For each dst edge, we sample some rays from it (interpolated from its vertices) @@ -1106,13 +1100,13 @@ static float mesh_remap_calc_loops_astar_f_cost( #define ASTAR_STEPS_MAX 64 -void BKE_mesh_remap_calc_loops_from_dm( +void BKE_mesh_remap_calc_loops_from_mesh( const int mode, const SpaceTransform *space_transform, const float max_dist, const float ray_radius, MVert *verts_dst, const int numverts_dst, MEdge *edges_dst, const int numedges_dst, MLoop *loops_dst, const int numloops_dst, MPoly *polys_dst, const int numpolys_dst, CustomData *ldata_dst, CustomData *pdata_dst, const bool use_split_nors_dst, const float split_angle_dst, const bool dirty_nors_dst, - DerivedMesh *dm_src, const bool use_split_nors_src, const float split_angle_src, + Mesh *me_src, MeshRemapIslandsCalc gen_islands_src, const float islands_precision_src, MeshPairRemap *r_map) { const float full_weight = 1.0f; @@ -1127,7 +1121,7 @@ void BKE_mesh_remap_calc_loops_from_dm( if (mode == MREMAP_MODE_TOPOLOGY) { /* In topology mapping, we assume meshes are identical, islands included! */ - BLI_assert(numloops_dst == dm_src->getNumLoops(dm_src)); + BLI_assert(numloops_dst == me_src->totloop); for (i = 0; i < numloops_dst; i++) { mesh_remap_item_define(r_map, i, FLT_MAX, 0, 1, &i, &full_weight); } @@ -1169,19 +1163,15 @@ void BKE_mesh_remap_calc_loops_from_dm( /* Unlike above, those are one-to-one mappings, simpler! */ int *loop_to_poly_map_src = NULL; - bool verts_allocated_src; - MVert *verts_src = DM_get_vert_array(dm_src, &verts_allocated_src); - const int num_verts_src = dm_src->getNumVerts(dm_src); + MVert *verts_src = me_src->mvert; + const int num_verts_src = me_src->totvert; float (*vcos_src)[3] = NULL; - bool edges_allocated_src; - MEdge *edges_src = DM_get_edge_array(dm_src, &edges_allocated_src); - const int num_edges_src = dm_src->getNumEdges(dm_src); - bool loops_allocated_src; - MLoop *loops_src = DM_get_loop_array(dm_src, &loops_allocated_src); - const int num_loops_src = dm_src->getNumLoops(dm_src); - bool polys_allocated_src; - MPoly *polys_src = DM_get_poly_array(dm_src, &polys_allocated_src); - const int num_polys_src = dm_src->getNumPolys(dm_src); + MEdge *edges_src = me_src->medge; + const int num_edges_src = me_src->totedge; + MLoop *loops_src = me_src->mloop; + const int num_loops_src = me_src->totloop; + MPoly *polys_src = me_src->mpoly; + const int num_polys_src = me_src->totpoly; const MLoopTri *looptri_src = NULL; int num_looptri_src = 0; @@ -1198,8 +1188,7 @@ void BKE_mesh_remap_calc_loops_from_dm( size_t islands_res_buff_size = MREMAP_DEFAULT_BUFSIZE; if (!use_from_vert) { - vcos_src = MEM_mallocN(sizeof(*vcos_src) * (size_t)num_verts_src, __func__); - dm_src->getVertCos(dm_src, vcos_src); + vcos_src = BKE_mesh_vertexCos_get(me_src, NULL); vcos_interp = MEM_mallocN(sizeof(*vcos_interp) * buff_size_interp, __func__); indices_interp = MEM_mallocN(sizeof(*indices_interp) * buff_size_interp, __func__); @@ -1215,11 +1204,12 @@ void BKE_mesh_remap_calc_loops_from_dm( if (need_pnors_dst) { /* Cache poly nors into a temp CDLayer. */ poly_nors_dst = CustomData_get_layer(pdata_dst, CD_NORMAL); + const bool do_poly_nors_dst = (poly_nors_dst == NULL); if (!poly_nors_dst) { poly_nors_dst = CustomData_add_layer(pdata_dst, CD_NORMAL, CD_CALLOC, NULL, numpolys_dst); CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); } - if (dirty_nors_dst) { + if (dirty_nors_dst || do_poly_nors_dst) { BKE_mesh_calc_normals_poly(verts_dst, NULL, numverts_dst, loops_dst, polys_dst, numloops_dst, numpolys_dst, poly_nors_dst, true); } @@ -1229,11 +1219,12 @@ void BKE_mesh_remap_calc_loops_from_dm( /* Cache poly nors into a temp CDLayer. */ loop_nors_dst = CustomData_get_layer(ldata_dst, CD_NORMAL); - if (dirty_nors_dst || !loop_nors_dst) { - if (!loop_nors_dst) { - loop_nors_dst = CustomData_add_layer(ldata_dst, CD_NORMAL, CD_CALLOC, NULL, numloops_dst); - CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); - } + const bool do_loop_nors_dst = (loop_nors_dst == NULL); + if (!loop_nors_dst) { + loop_nors_dst = CustomData_add_layer(ldata_dst, CD_NORMAL, CD_CALLOC, NULL, numloops_dst); + CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); + } + if (dirty_nors_dst || do_loop_nors_dst) { BKE_mesh_normals_loop_split(verts_dst, numverts_dst, edges_dst, numedges_dst, loops_dst, loop_nors_dst, numloops_dst, polys_dst, (const float (*)[3])poly_nors_dst, numpolys_dst, @@ -1242,13 +1233,17 @@ void BKE_mesh_remap_calc_loops_from_dm( } if (need_pnors_src || need_lnors_src) { /* Simpler for now, calcNormals never stores pnors :( */ - dm_src->calcLoopNormals(dm_src, use_split_nors_src, split_angle_src); + if (!CustomData_has_layer(&me_src->pdata, CD_NORMAL)) { + CustomData_add_layer(&me_src->pdata, CD_NORMAL, CD_CALLOC, NULL, me_src->totpoly); + CustomData_set_layer_flag(&me_src->pdata, CD_NORMAL, CD_FLAG_TEMPORARY); + } + BKE_mesh_calc_normals_split(me_src); if (need_pnors_src) { - poly_nors_src = dm_src->getPolyDataArray(dm_src, CD_NORMAL); + poly_nors_src = CustomData_get_layer(&me_src->pdata, CD_NORMAL); } if (need_lnors_src) { - loop_nors_src = dm_src->getLoopDataArray(dm_src, CD_NORMAL); + loop_nors_src = CustomData_get_layer(&me_src->ldata, CD_NORMAL); } } } @@ -1344,37 +1339,24 @@ void BKE_mesh_remap_calc_loops_from_dm( } } } - /* verts 'ownership' is transfered to treedata here, which will handle its freeing. */ - bvhtree_from_mesh_verts_ex(&treedata[tindex], verts_src, num_verts_src, verts_allocated_src, + bvhtree_from_mesh_verts_ex(&treedata[tindex], verts_src, num_verts_src, false, verts_active, num_verts_active, 0.0, 2, 6); - if (verts_allocated_src) { - verts_allocated_src = false; /* Only 'give' our verts once, to first tree! */ - } } MEM_freeN(verts_active); } else { BLI_assert(num_trees == 1); - bvhtree_from_mesh_get(&treedata[0], dm_src, BVHTREE_FROM_VERTS, 2); + BKE_bvhtree_from_mesh_get(&treedata[0], me_src, BVHTREE_FROM_VERTS, 2); } } else { /* We use polygons. */ if (use_islands) { /* bvhtree here uses looptri faces... */ - const unsigned int dirty_tess_flag = dm_src->dirty & DM_DIRTY_TESS_CDLAYERS; BLI_bitmap *looptri_active; - /* We do not care about tessellated data here, only geometry itself is important. */ - if (dirty_tess_flag) { - dm_src->dirty &= ~dirty_tess_flag; - } - if (dirty_tess_flag) { - dm_src->dirty |= dirty_tess_flag; - } - - looptri_src = dm_src->getLoopTriArray(dm_src); - num_looptri_src = dm_src->getNumLoopTri(dm_src); + looptri_src = BKE_mesh_runtime_looptri_ensure(me_src); + num_looptri_src = me_src->runtime.looptris.len; looptri_active = BLI_BITMAP_NEW((size_t)num_looptri_src, __func__); for (tindex = 0; tindex < num_trees; tindex++) { @@ -1387,26 +1369,19 @@ void BKE_mesh_remap_calc_loops_from_dm( num_looptri_active++; } } - /* verts and faces 'ownership' is transfered to treedata here, which will handle its freeing. */ bvhtree_from_mesh_looptri_ex( &treedata[tindex], - verts_src, verts_allocated_src, - loops_src, loops_allocated_src, + verts_src, false, + loops_src, false, looptri_src, num_looptri_src, false, looptri_active, num_looptri_active, 0.0, 2, 6); - if (verts_allocated_src) { - verts_allocated_src = false; /* Only 'give' our verts once, to first tree! */ - } - if (loops_allocated_src) { - loops_allocated_src = false; /* Only 'give' our loops once, to first tree! */ - } } MEM_freeN(looptri_active); } else { BLI_assert(num_trees == 1); - bvhtree_from_mesh_get(&treedata[0], dm_src, BVHTREE_FROM_LOOPTRI, 2); + BKE_bvhtree_from_mesh_get(&treedata[0], me_src, BVHTREE_FROM_LOOPTRI, 2); } } @@ -1905,21 +1880,9 @@ void BKE_mesh_remap_calc_loops_from_dm( BLI_astar_solution_free(&as_solution); } - if (verts_allocated_src) { - MEM_freeN(verts_src); - } if (vcos_src) { MEM_freeN(vcos_src); } - if (edges_allocated_src) { - MEM_freeN(edges_src); - } - if (loops_allocated_src) { - MEM_freeN(loops_src); - } - if (polys_allocated_src) { - MEM_freeN(polys_src); - } if (vert_to_loop_map_src) { MEM_freeN(vert_to_loop_map_src); } @@ -1962,11 +1925,11 @@ void BKE_mesh_remap_calc_loops_from_dm( } } -void BKE_mesh_remap_calc_polys_from_dm( +void BKE_mesh_remap_calc_polys_from_mesh( const int mode, const SpaceTransform *space_transform, const float max_dist, const float ray_radius, MVert *verts_dst, const int numverts_dst, MLoop *loops_dst, const int numloops_dst, MPoly *polys_dst, const int numpolys_dst, CustomData *pdata_dst, const bool dirty_nors_dst, - DerivedMesh *dm_src, MeshPairRemap *r_map) + Mesh *me_src, MeshPairRemap *r_map) { const float full_weight = 1.0f; const float max_dist_sq = max_dist * max_dist; @@ -1992,7 +1955,7 @@ void BKE_mesh_remap_calc_polys_from_dm( BKE_mesh_remap_init(r_map, numpolys_dst); if (mode == MREMAP_MODE_TOPOLOGY) { - BLI_assert(numpolys_dst == dm_src->getNumPolys(dm_src)); + BLI_assert(numpolys_dst == me_src->totpoly); for (i = 0; i < numpolys_dst; i++) { mesh_remap_item_define(r_map, i, FLT_MAX, 0, 1, &i, &full_weight); } @@ -2003,7 +1966,7 @@ void BKE_mesh_remap_calc_polys_from_dm( BVHTreeRayHit rayhit = {0}; float hit_dist; - bvhtree_from_mesh_get(&treedata, dm_src, BVHTREE_FROM_LOOPTRI, 2); + BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_LOOPTRI, 2); if (mode == MREMAP_MODE_POLY_NEAREST) { nearest.index = -1; @@ -2068,7 +2031,7 @@ void BKE_mesh_remap_calc_polys_from_dm( */ RNG *rng = BLI_rng_new(0); - const size_t numpolys_src = (size_t)dm_src->getNumPolys(dm_src); + const size_t numpolys_src = (size_t)me_src->totpoly; /* Here it's simpler to just allocate for all polys :/ */ int *indices = MEM_mallocN(sizeof(*indices) * numpolys_src, __func__); diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c index cd9db408d19..657cd3b6c52 100644 --- a/source/blender/blenkernel/intern/mesh_runtime.c +++ b/source/blender/blenkernel/intern/mesh_runtime.c @@ -226,3 +226,151 @@ void BKE_mesh_batch_cache_free(Mesh *me) } /** \} */ + +/** \name Mesh runtime debug helpers. + * \{ */ +/* evaluated mesh info printing function, + * to help track down differences output */ + +#ifndef NDEBUG +#include "BLI_dynstr.h" + +static void mesh_runtime_debug_info_layers( + DynStr *dynstr, CustomData *cd) +{ + int type; + + for (type = 0; type < CD_NUMTYPES; type++) { + if (CustomData_has_layer(cd, type)) { + /* note: doesnt account for multiple layers */ + const char *name = CustomData_layertype_name(type); + const int size = CustomData_sizeof(type); + const void *pt = CustomData_get_layer(cd, type); + const int pt_size = pt ? (int)(MEM_allocN_len(pt) / size) : 0; + const char *structname; + int structnum; + CustomData_file_write_info(type, &structname, &structnum); + BLI_dynstr_appendf(dynstr, + " dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n", + name, structname, type, (const void *)pt, size, pt_size); + } + } +} + +char *BKE_mesh_runtime_debug_info(Mesh *me_eval) +{ + DynStr *dynstr = BLI_dynstr_new(); + char *ret; + + BLI_dynstr_appendf(dynstr, "{\n"); + BLI_dynstr_appendf(dynstr, " 'ptr': '%p',\n", (void *)me_eval); +#if 0 + const char *tstr; + switch (me_eval->type) { + case DM_TYPE_CDDM: tstr = "DM_TYPE_CDDM"; break; + case DM_TYPE_EDITBMESH: tstr = "DM_TYPE_EDITMESH"; break; + case DM_TYPE_CCGDM: tstr = "DM_TYPE_CCGDM"; break; + default: tstr = "UNKNOWN"; break; + } + BLI_dynstr_appendf(dynstr, " 'type': '%s',\n", tstr); +#endif + BLI_dynstr_appendf(dynstr, " 'totvert': %d,\n", me_eval->totvert); + BLI_dynstr_appendf(dynstr, " 'totedge': %d,\n", me_eval->totedge); + BLI_dynstr_appendf(dynstr, " 'totface': %d,\n", me_eval->totface); + BLI_dynstr_appendf(dynstr, " 'totpoly': %d,\n", me_eval->totpoly); + BLI_dynstr_appendf(dynstr, " 'deformed_only': %d,\n", me_eval->runtime.deformed_only); + + BLI_dynstr_appendf(dynstr, " 'vertexLayers': (\n"); + mesh_runtime_debug_info_layers(dynstr, &me_eval->vdata); + BLI_dynstr_appendf(dynstr, " ),\n"); + + BLI_dynstr_appendf(dynstr, " 'edgeLayers': (\n"); + mesh_runtime_debug_info_layers(dynstr, &me_eval->edata); + BLI_dynstr_appendf(dynstr, " ),\n"); + + BLI_dynstr_appendf(dynstr, " 'loopLayers': (\n"); + mesh_runtime_debug_info_layers(dynstr, &me_eval->ldata); + BLI_dynstr_appendf(dynstr, " ),\n"); + + BLI_dynstr_appendf(dynstr, " 'polyLayers': (\n"); + mesh_runtime_debug_info_layers(dynstr, &me_eval->pdata); + BLI_dynstr_appendf(dynstr, " ),\n"); + + BLI_dynstr_appendf(dynstr, " 'tessFaceLayers': (\n"); + mesh_runtime_debug_info_layers(dynstr, &me_eval->fdata); + BLI_dynstr_appendf(dynstr, " ),\n"); + + BLI_dynstr_appendf(dynstr, "}\n"); + + ret = BLI_dynstr_get_cstring(dynstr); + BLI_dynstr_free(dynstr); + return ret; +} + +void BKE_mesh_runtime_debug_print(Mesh *me_eval) +{ + char *str = BKE_mesh_runtime_debug_info(me_eval); + puts(str); + fflush(stdout); + MEM_freeN(str); +} + +/* XXX Should go in customdata file? */ +void BKE_mesh_runtime_debug_print_cdlayers(CustomData *data) +{ + int i; + const CustomDataLayer *layer; + + printf("{\n"); + + for (i = 0, layer = data->layers; i < data->totlayer; i++, layer++) { + + const char *name = CustomData_layertype_name(layer->type); + const int size = CustomData_sizeof(layer->type); + const char *structname; + int structnum; + CustomData_file_write_info(layer->type, &structname, &structnum); + printf(" dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n", + name, structname, layer->type, (const void *)layer->data, size, (int)(MEM_allocN_len(layer->data) / size)); + } + + printf("}\n"); +} + +bool BKE_mesh_runtime_is_valid(Mesh *me_eval) +{ + const bool do_verbose = true; + const bool do_fixes = false; + + bool is_valid = true; + bool changed = true; + + if (do_verbose) { + printf("MESH: %s\n", me_eval->id.name + 2); + } + + is_valid &= BKE_mesh_validate_all_customdata( + &me_eval->vdata, &me_eval->edata, &me_eval->ldata, &me_eval->pdata, + false, /* setting mask here isn't useful, gives false positives */ + do_verbose, do_fixes, + &changed); + + is_valid &= BKE_mesh_validate_arrays( + me_eval, + me_eval->mvert, me_eval->totvert, + me_eval->medge, me_eval->totedge, + me_eval->mface, me_eval->totface, + me_eval->mloop, me_eval->totloop, + me_eval->mpoly, me_eval->totpoly, + me_eval->dvert, + do_verbose, do_fixes, + &changed); + + BLI_assert(changed == false); + + return is_valid; +} + +#endif /* NDEBUG */ + +/** \} */ diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 835b78e2a78..4c2a58e7126 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -349,9 +349,7 @@ bool modifier_supportsCage(struct Scene *scene, ModifierData *md) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; - - return ((!mti->isDisabled || !mti->isDisabled(md, 0)) && + return ((!mti->isDisabled || !mti->isDisabled(scene, md, 0)) && (mti->flags & eModifierTypeFlag_SupportsEditmode) && modifier_supportsMapping(md)); } @@ -360,11 +358,9 @@ bool modifier_couldBeCage(struct Scene *scene, ModifierData *md) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; - return ((md->mode & eModifierMode_Realtime) && (md->mode & eModifierMode_Editmode) && - (!mti->isDisabled || !mti->isDisabled(md, 0)) && + (!mti->isDisabled || !mti->isDisabled(scene, md, 0)) && modifier_supportsMapping(md)); } @@ -421,9 +417,7 @@ int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *r_lastPossibleC const ModifierTypeInfo *mti = modifierType_getInfo(md->type); bool supports_mapping; - md->scene = scene; - - if (mti->isDisabled && mti->isDisabled(md, 0)) continue; + if (mti->isDisabled && mti->isDisabled(scene, md, 0)) continue; if (!(mti->flags & eModifierTypeFlag_SupportsEditmode)) continue; if (md->mode & eModifierMode_DisableTemporary) continue; @@ -479,14 +473,12 @@ bool modifiers_isParticleEnabled(Object *ob) * * \param scene Current scene, may be NULL, in which case isDisabled callback of the modifier is never called. */ -bool modifier_isEnabled(struct Scene *scene, ModifierData *md, int required_mode) +bool modifier_isEnabled(const struct Scene *scene, ModifierData *md, int required_mode) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; - if ((md->mode & required_mode) != required_mode) return false; - if (scene != NULL && mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return false; + if (scene != NULL && mti->isDisabled && mti->isDisabled(scene, md, required_mode == eModifierMode_Render)) return false; if (md->mode & eModifierMode_DisableTemporary) return false; if ((required_mode & eModifierMode_Editmode) && !(mti->flags & eModifierTypeFlag_SupportsEditmode)) return false; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 5bd4a1a0475..00a3e5c77d0 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -337,17 +337,17 @@ MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, bool use_f return mmd; } -static int multires_get_level(Object *ob, MultiresModifierData *mmd, +static int multires_get_level(Scene *scene, Object *ob, MultiresModifierData *mmd, bool render, bool ignore_simplify) { if (render) - return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl, true) : mmd->renderlvl; + return (scene != NULL) ? get_render_subsurf_level(&scene->r, mmd->renderlvl, true) : mmd->renderlvl; else if (ob->mode == OB_MODE_SCULPT) return mmd->sculptlvl; else if (ignore_simplify) return mmd->lvl; else - return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl, false) : mmd->lvl; + return (scene != NULL) ? get_render_subsurf_level(&scene->r, mmd->lvl, false) : mmd->lvl; } void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) @@ -435,7 +435,7 @@ int multiresModifier_reshapeFromDeformMod(struct Depsgraph *depsgraph, Scene *sc float (*deformedVerts)[3]; const ModifierEvalContext mectx = {depsgraph, ob, 0}; - if (multires_get_level(ob, mmd, false, true) == 0) + if (multires_get_level(scene, ob, mmd, false, true) == 0) return 0; /* Create DerivedMesh for deformation modifier */ @@ -681,10 +681,10 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) } /* (direction = 1) for delete higher, (direction = 0) for lower (not implemented yet) */ -void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int direction) +void multiresModifier_del_levels(MultiresModifierData *mmd, Scene *scene, Object *ob, int direction) { Mesh *me = BKE_mesh_from_object(ob); - int lvl = multires_get_level(ob, mmd, false, true); + int lvl = multires_get_level(scene, ob, mmd, false, true); int levels = mmd->totlvl - lvl; MDisps *mdisps; @@ -701,7 +701,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire multires_set_tot_level(ob, mmd, lvl); } -static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple, bool alloc_paint_mask) +static DerivedMesh *multires_dm_create_local(Scene *scene, Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple, bool alloc_paint_mask) { MultiresModifierData mmd = {{NULL}}; MultiresFlags flags = MULTIRES_USE_LOCAL_MMD; @@ -715,10 +715,12 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv if (alloc_paint_mask) flags |= MULTIRES_ALLOC_PAINT_MASK; - return multires_make_derived_from_derived(dm, &mmd, ob, flags); + return multires_make_derived_from_derived(dm, &mmd, scene, ob, flags); } -static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal, int plain_uv, int alloc_paint_mask) +static DerivedMesh *subsurf_dm_create_local( + Scene *scene, Object *ob, DerivedMesh *dm, + int lvl, int simple, int optimal, int plain_uv, int alloc_paint_mask) { SubsurfModifierData smd = {{NULL}}; SubsurfFlags flags = 0; @@ -737,7 +739,7 @@ static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl if (alloc_paint_mask) flags |= SUBSURF_ALLOC_PAINT_MASK; - return subsurf_make_derived_from_derived(dm, &smd, NULL, flags); + return subsurf_make_derived_from_derived(dm, &smd, scene, NULL, flags); } @@ -751,7 +753,7 @@ static float v3_dist_from_plane(float v[3], float center[3], float no[3]) return dot_v3v3(s, no); } -void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) +void multiresModifier_base_apply(MultiresModifierData *mmd, Scene *scene, Object *ob) { DerivedMesh *cddm, *dispdm, *origdm; Mesh *me; @@ -773,7 +775,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) /* generate highest level with displacements */ cddm = CDDM_from_mesh(me); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - dispdm = multires_dm_create_local(ob, cddm, totlvl, totlvl, 0, 0); + dispdm = multires_dm_create_local(scene, ob, cddm, totlvl, totlvl, 0, 0); cddm->release(cddm); /* copy the new locations of the base verts into the mesh */ @@ -869,7 +871,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) /* subdivide the mesh to highest level without displacements */ cddm = CDDM_from_mesh(me); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - origdm = subsurf_dm_create_local(ob, cddm, totlvl, 0, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0); + origdm = subsurf_dm_create_local(scene, ob, cddm, totlvl, 0, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0); cddm->release(cddm); /* calc disps */ @@ -879,7 +881,9 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) dispdm->release(dispdm); } -static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl, int updateblock, int simple) +static void multires_subdivide( + MultiresModifierData *mmd, Scene *scene, Object *ob, + int totlvl, int updateblock, int simple) { Mesh *me = ob->data; MDisps *mdisps; @@ -908,11 +912,11 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl /* create subsurf DM from original mesh at high level */ cddm = CDDM_from_mesh(me); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask); + highdm = subsurf_dm_create_local(scene, ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask); ss = ((CCGDerivedMesh *)highdm)->ss; /* create multires DM from original mesh at low level */ - lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple, has_mask); + lowdm = multires_dm_create_local(scene, ob, cddm, lvl, lvl, simple, has_mask); BLI_assert(lowdm != cddm); cddm->release(cddm); @@ -962,9 +966,9 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl multires_set_tot_level(ob, mmd, totlvl); } -void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple) +void multiresModifier_subdivide(MultiresModifierData *mmd, Scene *scene, Object *ob, int updateblock, int simple) { - multires_subdivide(mmd, ob, mmd->totlvl + 1, updateblock, simple); + multires_subdivide(mmd, scene, ob, mmd->totlvl + 1, updateblock, simple); } static void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *grid, float t[3]) @@ -1197,7 +1201,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm } } -void multires_modifier_update_mdisps(struct DerivedMesh *dm) +void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; Object *ob; @@ -1229,11 +1233,11 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm) else cddm = CDDM_from_mesh(me); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask); + highdm = subsurf_dm_create_local(scene, ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask); ss = ((CCGDerivedMesh *)highdm)->ss; /* create multires DM from original mesh and displacements */ - lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple, has_mask); + lowdm = multires_dm_create_local(scene, ob, cddm, lvl, totlvl, mmd->simple, has_mask); cddm->release(cddm); /* gather grid data */ @@ -1291,7 +1295,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm) else cddm = CDDM_from_mesh(me); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask); + subdm = subsurf_dm_create_local(scene, ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask); cddm->release(cddm); multiresModifier_disp_run(dm, me, NULL, CALC_DISPLACEMENTS, subdm->getGridData(subdm), mmd->totlvl); @@ -1354,6 +1358,7 @@ void multires_stitch_grids(Object *ob) DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm, MultiresModifierData *mmd, + Scene *scene, Object *ob, MultiresFlags flags) { @@ -1364,13 +1369,13 @@ DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm, CCGKey key; const bool render = (flags & MULTIRES_USE_RENDER_PARAMS) != 0; const bool ignore_simplify = (flags & MULTIRES_IGNORE_SIMPLIFY) != 0; - int lvl = multires_get_level(ob, mmd, render, ignore_simplify); + int lvl = multires_get_level(scene, ob, mmd, render, ignore_simplify); int i, gridSize, numGrids; if (lvl == 0) return dm; - result = subsurf_dm_create_local(ob, dm, lvl, + result = subsurf_dm_create_local(scene, ob, dm, lvl, mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv, flags & MULTIRES_ALLOC_PAINT_MASK); @@ -2049,7 +2054,7 @@ void multires_load_old(Object *ob, Mesh *me) BLI_insertlinkbefore(&ob->modifiers, md, mmd); for (i = 0; i < me->mr->level_count - 1; ++i) - multiresModifier_subdivide(mmd, ob, 1, 0); + multiresModifier_subdivide(mmd, NULL, ob, 1, 0); mmd->lvl = mmd->totlvl; orig = CDDM_from_mesh(me); @@ -2058,7 +2063,7 @@ void multires_load_old(Object *ob, Mesh *me) * reference subsurfed dm with this option, before calling multiresModifier_disp_run(), * which implicitly expects both subsurfs from its first dm and oldGridData parameters to * be of the same "format"! */ - dm = multires_make_derived_from_derived(orig, mmd, ob, 0); + dm = multires_make_derived_from_derived(orig, mmd, NULL, ob, 0); multires_load_old_dm(dm, me, mmd->totlvl + 1); @@ -2073,14 +2078,14 @@ void multires_load_old(Object *ob, Mesh *me) /* If 'ob_src' and 'ob_dst' both have multires modifiers, synchronize them * such that 'ob_dst' has the same total number of levels as 'ob_src'. */ -void multiresModifier_sync_levels_ex(Object *ob_dst, MultiresModifierData *mmd_src, MultiresModifierData *mmd_dst) +void multiresModifier_sync_levels_ex(Scene *scene, Object *ob_dst, MultiresModifierData *mmd_src, MultiresModifierData *mmd_dst) { if (mmd_src->totlvl == mmd_dst->totlvl) { return; } if (mmd_src->totlvl > mmd_dst->totlvl) { - multires_subdivide(mmd_dst, ob_dst, mmd_src->totlvl, false, mmd_dst->simple); + multires_subdivide(mmd_dst, scene, ob_dst, mmd_src->totlvl, false, mmd_dst->simple); } else { multires_del_higher(mmd_dst, ob_dst, mmd_src->totlvl); @@ -2102,7 +2107,7 @@ static void multires_sync_levels(Scene *scene, Object *ob_src, Object *ob_dst) } if (mmd_src && mmd_dst) { - multiresModifier_sync_levels_ex(ob_dst, mmd_src, mmd_dst); + multiresModifier_sync_levels_ex(scene, ob_dst, mmd_src, mmd_dst); } } @@ -2195,7 +2200,7 @@ static void multires_apply_smat(struct Depsgraph *depsgraph, Scene *scene, Objec MEM_freeN(vertCos); /* scaled ccgDM for tangent space of object with applied scale */ - dm = subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0); + dm = subsurf_dm_create_local(scene, ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0); cddm->release(cddm); gridSize = dm->getGridSize(dm); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 6695d145a9a..9de31205504 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -314,7 +314,9 @@ void ntreeTypeAdd(bNodeTreeType *nt) { BLI_ghash_insert(nodetreetypes_hash, nt->idname, nt); /* XXX pass Main to register function? */ - update_typeinfo(G.main, NULL, nt, NULL, NULL, false); + /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all* + * active Mains, which we cannot do anyway currently. */ + update_typeinfo(G_MAIN, NULL, nt, NULL, NULL, false); } /* callback for hash value free function */ @@ -322,7 +324,9 @@ static void ntree_free_type(void *treetype_v) { bNodeTreeType *treetype = treetype_v; /* XXX pass Main to unregister function? */ - update_typeinfo(G.main, NULL, treetype, NULL, NULL, true); + /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all* + * active Mains, which we cannot do anyway currently. */ + update_typeinfo(G_MAIN, NULL, treetype, NULL, NULL, true); MEM_freeN(treetype); } @@ -371,7 +375,9 @@ static void node_free_type(void *nodetype_v) { bNodeType *nodetype = nodetype_v; /* XXX pass Main to unregister function? */ - update_typeinfo(G.main, NULL, NULL, nodetype, NULL, true); + /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all* + * active Mains, which we cannot do anyway currently. */ + update_typeinfo(G_MAIN, NULL, NULL, nodetype, NULL, true); /* XXX deprecated */ if (nodetype->type == NODE_DYNAMIC) @@ -389,7 +395,9 @@ void nodeRegisterType(bNodeType *nt) BLI_ghash_insert(nodetypes_hash, nt->idname, nt); /* XXX pass Main to register function? */ - update_typeinfo(G.main, NULL, NULL, nt, NULL, false); + /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all* + * active Mains, which we cannot do anyway currently. */ + update_typeinfo(G_MAIN, NULL, NULL, nt, NULL, false); } void nodeUnregisterType(bNodeType *nt) @@ -425,7 +433,9 @@ static void node_free_socket_type(void *socktype_v) { bNodeSocketType *socktype = socktype_v; /* XXX pass Main to unregister function? */ - update_typeinfo(G.main, NULL, NULL, NULL, socktype, true); + /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all* + * active Mains, which we cannot do anyway currently. */ + update_typeinfo(G_MAIN, NULL, NULL, NULL, socktype, true); MEM_freeN(socktype); } @@ -434,7 +444,9 @@ void nodeRegisterSocketType(bNodeSocketType *st) { BLI_ghash_insert(nodesockettypes_hash, (void *)st->idname, st); /* XXX pass Main to register function? */ - update_typeinfo(G.main, NULL, NULL, NULL, st, false); + /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all* + * active Mains, which we cannot do anyway currently. */ + update_typeinfo(G_MAIN, NULL, NULL, NULL, st, false); } void nodeUnregisterSocketType(bNodeSocketType *st) @@ -1789,7 +1801,6 @@ static void free_localized_node_groups(bNodeTree *ntree) /** Free (or release) any data used by this nodetree (does not free the nodetree itself). */ void ntreeFreeTree(bNodeTree *ntree) { - bNodeTree *tntree; bNode *node, *next; bNodeSocket *sock, *nextsock; @@ -1846,10 +1857,7 @@ void ntreeFreeTree(bNodeTree *ntree) BLI_mutex_free(ntree->duplilock); /* if ntree is not part of library, free the libblock data explicitly */ - for (tntree = G.main->nodetree.first; tntree; tntree = tntree->id.next) - if (tntree == ntree) - break; - if (tntree == NULL) { + if (ntree->id.tag & LIB_TAG_NO_MAIN) { BKE_libblock_free_data(&ntree->id, true); } } @@ -2603,7 +2611,8 @@ bool BKE_node_clipboard_validate(void) /* currently only validate the ID */ if (node->id) { - ListBase *lb = which_libbase(G.main, GS(node_info->id_name)); + /* We want to search into current blend file, so using G_MAIN is valid here too. */ + ListBase *lb = which_libbase(G_MAIN, GS(node_info->id_name)); BLI_assert(lb != NULL); if (BLI_findindex(lb, node_info->id) == -1) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 5ca9b9d2203..210e6f096b8 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -249,7 +249,7 @@ bool BKE_object_support_modifier_type_check(const Object *ob, int modifier_type) return true; } -void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_src) +void BKE_object_link_modifiers(Scene *scene, struct Object *ob_dst, const struct Object *ob_src) { ModifierData *md; BKE_object_free_modifiers(ob_dst, 0); @@ -288,7 +288,7 @@ void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_sr if (md->type == eModifierType_Multires) { /* Has to be done after mod creation, but *before* we actually copy its settings! */ - multiresModifier_sync_levels_ex(ob_dst, (MultiresModifierData *)md, (MultiresModifierData *)nmd); + multiresModifier_sync_levels_ex(scene, ob_dst, (MultiresModifierData *)md, (MultiresModifierData *)nmd); } modifier_copyData(md, nmd); @@ -404,6 +404,15 @@ void BKE_object_free_caches(Object *object) } } + /* NOTE: If object is coming from a duplicator, it might be a temporary + * object created by dependency graph, which shares pointers with original + * object. In this case we can not free anything. + */ + if ((object->base_flag & BASE_FROMDUPLI) == 0) { + BKE_object_free_derived_caches(object); + update_flag |= OB_RECALC_DATA; + } + /* Tag object for update, so once memory critical operation is over and * scene update routines are back to it's business the object will be * guaranteed to be in a known state. @@ -600,7 +609,7 @@ bool BKE_object_is_mode_compat(const struct Object *ob, eObjectMode object_mode) */ bool BKE_object_is_visible(Object *ob, const eObjectVisibilityCheck mode) { - if ((ob->base_flag & BASE_VISIBLED) == 0) { + if ((ob->base_flag & BASE_VISIBLE) == 0) { return false; } @@ -2530,13 +2539,11 @@ void BKE_object_foreach_display_point( { float co[3]; - if (ob->derivedFinal) { - DerivedMesh *dm = ob->derivedFinal; - MVert *mv = dm->getVertArray(dm); - int totvert = dm->getNumVerts(dm); - int i; - - for (i = 0; i < totvert; i++, mv++) { + if (ob->runtime.mesh_eval) { + const Mesh *me = ob->runtime.mesh_eval; + const MVert *mv = me->mvert; + const int totvert = me->totvert; + for (int i = 0; i < totvert; i++, mv++) { mul_v3_m4v3(co, obmat, mv->co); func_cb(co, user_data); } @@ -2558,33 +2565,20 @@ void BKE_object_foreach_display_point( } void BKE_scene_foreach_display_point( - Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer, + Depsgraph *depsgraph, void (*func_cb)(const float[3], void *), void *user_data) { - Base *base; - Object *ob; - - for (base = FIRSTBASE(view_layer); base; base = base->next) { - if (((base->flag & BASE_VISIBLED) != 0) && ((base->flag & BASE_SELECTED) != 0)) { - ob = base->object; - - if ((ob->transflag & OB_DUPLI) == 0) { - BKE_object_foreach_display_point(ob, ob->obmat, func_cb, user_data); - } - else { - ListBase *lb; - DupliObject *dob; - - lb = object_duplilist(depsgraph, scene, ob); - for (dob = lb->first; dob; dob = dob->next) { - if (dob->no_draw == 0) { - BKE_object_foreach_display_point(dob->ob, dob->mat, func_cb, user_data); - } - } - free_object_duplilist(lb); /* does restore */ - } + DEG_OBJECT_ITER_BEGIN( + depsgraph, ob, + DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | + DEG_ITER_OBJECT_FLAG_VISIBLE | + DEG_ITER_OBJECT_FLAG_DUPLI) + { + if ((ob->base_flag & BASE_SELECTED) != 0) { + BKE_object_foreach_display_point(ob, ob->obmat, func_cb, user_data); } } + DEG_OBJECT_ITER_END; } /* copied from DNA_object_types.h */ @@ -2956,7 +2950,7 @@ static KeyBlock *insert_meshkey(Main *bmain, Object *ob, const char *name, const if (newkey || from_mix == false) { /* create from mesh */ kb = BKE_keyblock_add_ctime(key, name, false); - BKE_keyblock_convert_from_mesh(me, kb); + BKE_keyblock_convert_from_mesh(me, key, kb); } else { /* copy from current values */ @@ -3528,6 +3522,7 @@ void BKE_object_groups_clear(Main *bmain, Object *ob) Collection *collection = NULL; while ((collection = BKE_collection_object_find(bmain, collection, ob))) { BKE_collection_object_remove(bmain, collection, ob, false); + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); } } diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index b7748039f62..33b65dbe4a3 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -837,7 +837,6 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem float (*obmat)[4]; int a, b, hair = 0; int totpart, totchild, totcollection = 0 /*, pa_num */; - RNG *rng; int no_draw_flag = PARS_UNEXIST; @@ -859,8 +858,6 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem totpart = psys->totpart; totchild = psys->totchild; - rng = BLI_rng_new_srandom(31415926u + (unsigned int)psys->seed); - if ((for_render || part->draw_as == PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { ParticleSimulationData sim = {NULL}; sim.depsgraph = ctx->depsgraph; @@ -901,6 +898,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem totpart = psys->totcached; } + RNG *rng = BLI_rng_new_srandom(31415926u + (unsigned int)psys->seed); psys_check_group_weights(part); psys->lattice_deform_data = psys_create_lattice_deform_data(&sim); @@ -1121,6 +1119,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem } else *ob = obcopy; + + BLI_rng_free(rng); } /* clean up */ @@ -1133,8 +1133,6 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem end_latt_deform(psys->lattice_deform_data); psys->lattice_deform_data = NULL; } - - BLI_rng_free(rng); } static void make_duplis_particles(const DupliContext *ctx) diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 4c38940b11d..3e72de3909f 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -166,7 +166,7 @@ void BKE_object_handle_data_update( /* TODO(sergey): Only used by legacy depsgraph. */ if (adt) { /* evaluate drivers - datalevel */ - /* XXX: for mesh types, should we push this to derivedmesh instead? */ + /* XXX: for mesh types, should we push this to evaluated mesh instead? */ BKE_animsys_evaluate_animdata(depsgraph, scene, data_id, adt, ctime, ADT_RECALC_DRIVERS); } @@ -401,7 +401,7 @@ void BKE_object_eval_flush_base_flags(Depsgraph *depsgraph, object->base_flag = base->flag; if (is_from_set) { object->base_flag |= BASE_FROM_SET; - object->base_flag &= ~(BASE_SELECTED | BASE_SELECTABLED); + object->base_flag &= ~(BASE_SELECTED | BASE_SELECTABLE); } /* Copy to original object datablock if needed. */ diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index c1c3cbf1ca3..404a1a656d9 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -719,7 +719,7 @@ void BKE_sculptsession_bm_to_me(Object *ob, bool reorder) if (ob && ob->sculpt) { sculptsession_bm_to_me_update_data_only(ob, reorder); - /* ensure the objects DerivedMesh mesh doesn't hold onto arrays now realloc'd in the mesh [#34473] */ + /* ensure the objects evaluated mesh doesn't hold onto arrays now realloc'd in the mesh [#34473] */ DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } } @@ -857,7 +857,7 @@ static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob) } /** - * \param need_mask So the DerivedMesh thats returned has mask data + * \param need_mask So taht the evaluated mesh that is returned has mask data. */ void BKE_sculpt_update_mesh_elements( Depsgraph *depsgraph, Scene *scene, Sculpt *sd, Object *ob, @@ -1107,7 +1107,7 @@ static bool check_sculpt_object_deformed(Object *object, const bool for_construc /* Active modifiers means extra deformation, which can't be handled correct * on birth of PBVH and sculpt "layer" levels, so use PBVH only for internal brush - * stuff and show final DerivedMesh so user would see actual object shape. + * stuff and show final evaluated mesh so user would see actual object shape. */ deformed |= object->sculpt->modifiers_active; @@ -1151,7 +1151,7 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Object *ob, Mesh *me_eval_deform) } /* always build pbvh from original mesh, and only use it for drawing if - * this derivedmesh is just original mesh. it's the multires subsurf dm + * this evaluated mesh is just original mesh. it's the multires subsurf dm * that this is actually for, to support a pbvh on a modified mesh */ if (!pbvh && ob->type == OB_MESH) { Mesh *me = BKE_object_get_original_mesh(ob); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 693d6ac587e..278a8ab9720 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -256,7 +256,8 @@ struct LatticeDeformData *psys_create_lattice_deform_data(ParticleSimulationData if (psys_in_edit_mode(sim->depsgraph, sim->psys) == 0) { Object *lattice = NULL; ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys); - int mode = G.is_rendering ? eModifierMode_Render : eModifierMode_Realtime; + bool for_render = DEG_get_mode(sim->depsgraph) == DAG_EVAL_RENDER; + int mode = for_render ? eModifierMode_Render : eModifierMode_Realtime; for (; md; md = md->next) { if (md->type == eModifierType_Lattice) { @@ -640,7 +641,7 @@ void psys_free(Object *ob, ParticleSystem *psys) if (psys->fluid_springs) MEM_freeN(psys->fluid_springs); - pdEndEffectors(&psys->effectors); + BKE_effectors_free(psys->effectors); if (psys->pdd) { psys_free_pdd(psys); @@ -1841,7 +1842,7 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK copy_qt_qt(eff_key.rot, (ca - 1)->rot); pd_point_from_particle(sim, sim->psys->particles + i, &eff_key, &epoint); - pdDoEffectors(sim->psys->effectors, sim->colliders, sim->psys->part->effector_weights, &epoint, force, NULL); + BKE_effectors_apply(sim->psys->effectors, sim->colliders, sim->psys->part->effector_weights, &epoint, force, NULL); mul_v3_fl(force, effector * powf((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 314a58647a9..e8dbf95e286 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -93,6 +93,7 @@ #include "BKE_bvhutils.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_physics.h" #include "DEG_depsgraph_query.h" #include "PIL_time.h" @@ -1307,9 +1308,10 @@ void psys_update_particle_tree(ParticleSystem *psys, float cfra) static void psys_update_effectors(ParticleSimulationData *sim) { - pdEndEffectors(&sim->psys->effectors); - sim->psys->effectors = pdInitEffectors(sim->depsgraph, sim->scene, sim->ob, sim->psys, - sim->psys->part->effector_weights, true); + BKE_effectors_free(sim->psys->effectors); + sim->psys->effectors = BKE_effectors_create(sim->depsgraph, + sim->ob, sim->psys, + sim->psys->part->effector_weights); precalc_guides(sim, sim->psys->effectors); } @@ -2066,7 +2068,7 @@ static void basic_force_cb(void *efdata_v, ParticleKey *state, float *force, flo /* add effectors */ pd_point_from_particle(efdata->sim, efdata->pa, state, &epoint); if (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR) - pdDoEffectors(sim->psys->effectors, sim->colliders, part->effector_weights, &epoint, force, impulse); + BKE_effectors_apply(sim->psys->effectors, sim->colliders, part->effector_weights, &epoint, force, impulse); mul_v3_fl(force, efdata->ptex.field); mul_v3_fl(impulse, efdata->ptex.field); @@ -2957,18 +2959,20 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra, cons /* particle instance modifier with "path" option need cached paths even if particle system doesn't */ - FOREACH_SCENE_OBJECT_BEGIN(sim->scene, ob) - { - ModifierData *md = modifiers_findByType(ob, eModifierType_ParticleInstance); - if (md) { - ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md; - if (pimd->flag & eParticleInstanceFlag_Path && pimd->ob == sim->ob && pimd->psys == (psys - (ParticleSystem*)sim->ob->particlesystem.first)) { - skip = 0; - break; + if (skip) { + FOREACH_SCENE_OBJECT_BEGIN(sim->scene, ob) + { + ModifierData *md = modifiers_findByType(ob, eModifierType_ParticleInstance); + if (md) { + ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md; + if (pimd->flag & eParticleInstanceFlag_Path && pimd->ob == sim->ob && pimd->psys == (psys - (ParticleSystem*)sim->ob->particlesystem.first)) { + skip = 0; + break; + } } } + FOREACH_SCENE_OBJECT_END; } - FOREACH_SCENE_OBJECT_END; if (!skip) { psys_cache_paths(sim, cfra, use_render_params); @@ -3536,7 +3540,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) psys_update_effectors(sim); if (part->type != PART_HAIR) - sim->colliders = get_collider_cache(sim->scene, sim->ob, part->collision_group); + sim->colliders = BKE_collider_cache_create(sim->depsgraph, sim->ob, part->collision_group); /* initialize physics type specific stuff */ switch (part->phystype) { @@ -3743,7 +3747,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) pa->state.time=cfra; } - free_collider_cache(&sim->colliders); + BKE_collider_cache_free(&sim->colliders); BLI_rng_free(sim->rng); sim->rng = NULL; } @@ -4221,16 +4225,6 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o if (!psys_check_enabled(ob, psys, use_render_params)) return; - if (DEG_is_active(depsgraph)) { - if (psys->orig_psys != NULL && - psys->orig_psys->edit != NULL && - psys->orig_psys->edit->psys == psys_orig_get(psys)) - { - psys->orig_psys->edit->psys_eval = psys; - psys->orig_psys->edit->psmd_eval = psmd; - } - } - cfra = DEG_get_ctime(depsgraph); sim.depsgraph = depsgraph; @@ -4385,6 +4379,18 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o psys_orig->edit->flags |= PT_CACHE_EDIT_UPDATE_PARTICLE_FROM_EVAL; } + if (DEG_is_active(depsgraph)) { + if (psys_orig != psys) { + if (psys_orig->edit != NULL && + psys_orig->edit->psys == psys_orig) + { + psys_orig->edit->psys_eval = psys; + psys_orig->edit->psmd_eval = psmd; + } + psys_orig->flag = psys->flag; + } + } + psys->cfra = cfra; psys->recalc = 0; diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 2374670b212..833ac0a88fa 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -238,17 +238,22 @@ RigidBodyCon *BKE_rigidbody_copy_constraint(const Object *ob, const int UNUSED(f /* get the appropriate DerivedMesh based on rigid body mesh source */ static Mesh *rigidbody_get_mesh(Object *ob) { - /* TODO(Sybren): turn this into a switch statement */ - if (ob->rigidbody_object->mesh_source == RBO_MESH_DEFORM) { - return ob->runtime.mesh_deform_eval; - } - else if (ob->rigidbody_object->mesh_source == RBO_MESH_FINAL) { - return ob->runtime.mesh_eval; - } - else { - BLI_assert(ob->rigidbody_object->mesh_source == RBO_MESH_BASE); - return ob->data; - } + switch (ob->rigidbody_object->mesh_source) { + case RBO_MESH_DEFORM: + return ob->runtime.mesh_deform_eval; + case RBO_MESH_FINAL: + return ob->runtime.mesh_eval; + case RBO_MESH_BASE: + /* This mesh may be used for computing looptris, which should be done + * on the original; otherwise every time the CoW is recreated it will + * have to be recomputed. */ + BLI_assert(ob->rigidbody_object->mesh_source == RBO_MESH_BASE); + return DEG_get_original_object(ob)->data; + } + + /* Just return something sensible so that at least Blender won't crash. */ + BLI_assert(!"Unknown mesh source"); + return ob->runtime.mesh_eval; } /* create collision shape of mesh - convex hull */ @@ -1278,7 +1283,7 @@ static void rigidbody_update_sim_ob(Depsgraph *depsgraph, Scene *scene, RigidBod ListBase *effectors; /* get effectors present in the group specified by effector_weights */ - effectors = pdInitEffectors(depsgraph, scene, ob, NULL, effector_weights, true); + effectors = BKE_effectors_create(depsgraph, ob, NULL, effector_weights); if (effectors) { float eff_force[3] = {0.0f, 0.0f, 0.0f}; float eff_loc[3], eff_vel[3]; @@ -1293,7 +1298,7 @@ static void rigidbody_update_sim_ob(Depsgraph *depsgraph, Scene *scene, RigidBod /* calculate net force of effectors, and apply to sim object * - we use 'central force' since apply force requires a "relative position" which we don't have... */ - pdDoEffectors(effectors, NULL, effector_weights, &epoint, eff_force, NULL); + BKE_effectors_apply(effectors, NULL, effector_weights, &epoint, eff_force, NULL); if (G.f & G_DEBUG) printf("\tapplying force (%f,%f,%f) to '%s'\n", eff_force[0], eff_force[1], eff_force[2], ob->id.name + 2); /* activate object in case it is deactivated */ @@ -1305,7 +1310,7 @@ static void rigidbody_update_sim_ob(Depsgraph *depsgraph, Scene *scene, RigidBod printf("\tno forces to apply to '%s'\n", ob->id.name + 2); /* cleanup */ - pdEndEffectors(&effectors); + BKE_effectors_free(effectors); } /* NOTE: passive objects don't need to be updated since they don't move */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index b1a0bde9746..35429496662 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -628,12 +628,15 @@ void BKE_scene_init(Scene *sce) CURVEMAP_SLOPE_POS_NEG); sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct"); + + sce->toolsettings->object_flag |= SCE_OBJECT_MODE_LOCK; sce->toolsettings->doublimit = 0.001; sce->toolsettings->vgroup_weight = 1.0f; sce->toolsettings->uvcalc_margin = 0.001f; sce->toolsettings->uvcalc_flag = UVCALC_TRANSFORM_CORRECT; sce->toolsettings->unwrapper = 1; sce->toolsettings->select_thresh = 0.01f; + sce->toolsettings->manipulator_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; sce->toolsettings->selectmode = SCE_SELECT_VERTEX; sce->toolsettings->uv_selectmode = UV_SELECT_VERTEX; @@ -1137,6 +1140,7 @@ int BKE_scene_camera_switch_update(Scene *scene) Object *camera = BKE_scene_camera_switch_find(scene); if (camera) { scene->camera = camera; + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); return 1; } #else @@ -1560,7 +1564,7 @@ void BKE_scene_object_base_flag_sync_from_object(Base *base) if ((ob->flag & SELECT) != 0) { base->flag |= BASE_SELECTED; - BLI_assert((base->flag & BASE_SELECTABLED) != 0); + BLI_assert((base->flag & BASE_SELECTABLE) != 0); } else { base->flag &= ~BASE_SELECTED; diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 5a6c55a9fcc..4a840b5ffbe 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -88,8 +88,6 @@ static void spacetype_free(SpaceType *st) } BLI_freelistN(&st->regiontypes); - BLI_freelistN(&st->toolshelf); - } void BKE_spacetypes_free(void) diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index f8615671384..9fa104dc04d 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -300,7 +300,7 @@ static void shrinkwrap_calc_normal_projection_cb_ex( } if (calc->vert) { - /* calc->vert contains verts from derivedMesh */ + /* calc->vert contains verts from evaluated mesh. */ /* this coordinated are deformed by vertexCos only for normal projection (to get correct normals) */ /* for other cases calc->varts contains undeformed coordinates and vertexCos should be used */ if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) { @@ -357,7 +357,7 @@ static void shrinkwrap_calc_normal_projection_cb_ex( /* don't set the initial dist (which is more efficient), * because its calculated in the targets space, we want the dist in our own space */ if (proj_limit_squared != 0.0f) { - if (len_squared_v3v3(hit->co, co) > proj_limit_squared) { + if (hit->index != -1 && len_squared_v3v3(hit->co, co) > proj_limit_squared) { hit->index = -1; } } @@ -448,7 +448,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) auxData = &auxdata_stack.dmtreedata; } } - /* After sucessufuly build the trees, start projection vertexs */ + /* After successfully build the trees, start projection vertices. */ ShrinkwrapCalcCBData data = { .calc = calc, .treeData = treeData, .targ_tree = targ_tree, .targ_callback = targ_callback, @@ -600,7 +600,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) } /* Main shrinkwrap function */ -void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, Mesh *mesh, +void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, struct Scene *scene, Object *ob, Mesh *mesh, float (*vertexCos)[3], int numVerts) { @@ -660,7 +660,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, Mesh *me /* TODO to be moved to Mesh once we are done with changes in subsurf code. */ DerivedMesh *dm = CDDM_from_mesh(mesh); - ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, NULL, (ob->mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : 0); + ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, scene, NULL, (ob->mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : 0); if (ss_mesh) { calc.vert = ss_mesh->getVertDataArray(ss_mesh, CD_MVERT); diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 6bdce647bd9..c9b10e36ed1 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -893,7 +893,7 @@ static void obstacles_from_derivedmesh( } /* Animated obstacles: dx_step = ((x_new - x_old) / totalsteps) * substep */ -static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt, +static void update_obstacles(Depsgraph *depsgraph, Object *ob, SmokeDomainSettings *sds, float dt, int UNUSED(substep), int UNUSED(totalsteps)) { Object **collobjs = NULL; @@ -933,7 +933,7 @@ static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds, } - collobjs = get_collisionobjects(scene, ob, sds->coll_group, &numcollobj, eModifierType_Smoke); + collobjs = BKE_collision_objects_create(depsgraph, ob, sds->coll_group, &numcollobj, eModifierType_Smoke); // update obstacle tags in cells for (collIndex = 0; collIndex < numcollobj; collIndex++) @@ -950,8 +950,7 @@ static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds, } } - if (collobjs) - MEM_freeN(collobjs); + BKE_collision_objects_free(collobjs); /* obstacle cells should not contain any velocity from the smoke simulation */ for (z = 0; z < sds->res[0] * sds->res[1] * sds->res[2]; z++) @@ -2151,7 +2150,7 @@ static void update_flowsfluids( sds->p1[2] = sds->p0[2] + sds->cell_size[2] * sds->base_res[2]; } - flowobjs = get_collisionobjects(scene, ob, sds->fluid_group, &numflowobj, eModifierType_Smoke); + flowobjs = BKE_collision_objects_create(depsgraph, ob, sds->fluid_group, &numflowobj, eModifierType_Smoke); /* init emission maps for each flow */ emaps = MEM_callocN(sizeof(struct EmissionMap) * numflowobj, "smoke_flow_maps"); @@ -2452,8 +2451,7 @@ static void update_flowsfluids( } } - if (flowobjs) - MEM_freeN(flowobjs); + BKE_collision_objects_free(flowobjs); if (emaps) MEM_freeN(emaps); } @@ -2512,7 +2510,7 @@ static void update_effectors_task_cb( mul_m4_v3(sds->obmat, voxelCenter); pd_point_from_loc(data->scene, voxelCenter, vel, index, &epoint); - pdDoEffectors(data->effectors, NULL, sds->effector_weights, &epoint, retvel, NULL); + BKE_effectors_apply(data->effectors, NULL, sds->effector_weights, &epoint, retvel, NULL); /* convert retvel to local space */ mag = len_v3(retvel); @@ -2533,7 +2531,7 @@ static void update_effectors(struct Depsgraph *depsgraph, Scene *scene, Object * ListBase *effectors; /* make sure smoke flow influence is 0.0f */ sds->effector_weights->weight[PFIELD_SMOKEFLOW] = 0.0f; - effectors = pdInitEffectors(depsgraph, scene, ob, NULL, sds->effector_weights, true); + effectors = BKE_effectors_create(depsgraph, ob, NULL, sds->effector_weights); if (effectors) { // precalculate wind forces @@ -2560,7 +2558,7 @@ static void update_effectors(struct Depsgraph *depsgraph, Scene *scene, Object * &settings); } - pdEndEffectors(&effectors); + BKE_effectors_free(effectors); } static void step( @@ -2636,7 +2634,7 @@ static void step( { // calc animated obstacle velocities update_flowsfluids(depsgraph, scene, ob, sds, dtSubdiv); - update_obstacles(scene, ob, sds, dtSubdiv, substep, totalSubsteps); + update_obstacles(depsgraph, ob, sds, dtSubdiv, substep, totalSubsteps); if (sds->total_cells > 1) { update_effectors(depsgraph, scene, ob, sds, dtSubdiv); // DG TODO? problem --> uses forces instead of velocity, need to check how they need to be changed with variable dt diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 31644cc2392..49280821667 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -72,6 +72,7 @@ variables on the UI for now #include "BLI_threads.h" #include "BKE_collection.h" +#include "BKE_collision.h" #include "BKE_curve.h" #include "BKE_effect.h" #include "BKE_global.h" @@ -139,7 +140,7 @@ typedef struct SB_thread_context { float timenow; int ifirst; int ilast; - ListBase *do_effector; + ListBase *effectors; int do_deflector; float fieldfactor; float windfactor; @@ -521,20 +522,18 @@ static void ccd_build_deflector_hash(Depsgraph *depsgraph, Collection *collectio { if (!hash) return; - /* Explicit collision collection. */ - Base *base = BKE_collection_or_layer_objects(depsgraph, NULL, NULL, collection); + unsigned int numobjects; + Object **objects = BKE_collision_objects_create(depsgraph, vertexowner, collection, &numobjects, eModifierType_Collision); - for (; base; base = base->next) { - /* Only proceed for mesh object in same layer. */ - if (base->object->type == OB_MESH) { - Object *ob = base->object; - if (ob == vertexowner) { - /* If vertexowner is given we don't want to check collision with owner object. */ - continue; - } + for (int i = 0; i < numobjects; i++) { + Object *ob = objects[i]; + + if (ob->type == OB_MESH) { ccd_build_deflector_hash_single(hash, ob); } } + + BKE_collision_objects_free(objects); } static void ccd_update_deflector_hash_single(GHash *hash, Object *ob) @@ -554,23 +553,19 @@ static void ccd_update_deflector_hash(Depsgraph *depsgraph, Collection *collecti { if ((!hash) || (!vertexowner)) return; - /* Explicit collision collection. */ - Base *base = BKE_collection_or_layer_objects(depsgraph, NULL, NULL, collection); + unsigned int numobjects; + Object **objects = BKE_collision_objects_create(depsgraph, vertexowner, collection, &numobjects, eModifierType_Collision); - for (; base; base = base->next) { - /* Only proceed for mesh object in same layer. */ - if (base->object->type == OB_MESH) { - Object *ob = base->object; - if (ob == vertexowner) { - /* If vertexowner is given we don't want to check collision with owner object. */ - continue; - } + for (int i = 0; i < numobjects; i++) { + Object *ob = objects[i]; + if (ob->type == OB_MESH) { ccd_update_deflector_hash_single(hash, ob); } } -} + BKE_collision_objects_free(objects); +} /*--- collider caching and dicing ---*/ @@ -959,21 +954,13 @@ static void free_softbody_intern(SoftBody *sb) /** * \note collection overrides scene when not NULL. */ -static bool are_there_deflectors(Base *first_base) -{ - for (Base *base = first_base; base; base = base->next) { - if (base->object->pd) { - if (base->object->pd->deflect) - return 1; - } - } - - return 0; -} - static int query_external_colliders(Depsgraph *depsgraph, Collection *collection) { - return(are_there_deflectors(BKE_collection_or_layer_objects(depsgraph, NULL, NULL, collection))); + unsigned int numobjects; + Object **objects = BKE_collision_objects_create(depsgraph, NULL, collection, &numobjects, eModifierType_Collision); + BKE_collision_objects_free(objects); + + return (numobjects != 0); } /* --- dependency information functions*/ @@ -1444,7 +1431,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3], float edge_v2[3], fl return deflected; } -static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, int ifirst, int ilast, struct ListBase *do_effector) +static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, int ifirst, int ilast, struct ListBase *effectors) { SoftBody *sb = ob->soft; int a; @@ -1478,14 +1465,14 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, float vel[3], sp[3], pr[3], force[3]; float f, windfactor = 0.25f; /*see if we have wind*/ - if (do_effector) { + if (effectors) { EffectedPoint epoint; float speed[3] = {0.0f, 0.0f, 0.0f}; float pos[3]; mid_v3_v3v3(pos, sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos); mid_v3_v3v3(vel, sb->bpoint[bs->v1].vec, sb->bpoint[bs->v2].vec); pd_point_from_soft(scene, pos, vel, -1, &epoint); - pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); + BKE_effectors_apply(effectors, NULL, sb->effector_weights, &epoint, force, speed); mul_v3_fl(speed, windfactor); add_v3_v3(vel, speed); @@ -1521,29 +1508,27 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, static void scan_for_ext_spring_forces(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float timenow) { SoftBody *sb = ob->soft; - ListBase *do_effector = NULL; - do_effector = pdInitEffectors(depsgraph, scene, ob, NULL, sb->effector_weights, true); - _scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector); - pdEndEffectors(&do_effector); + ListBase *effectors = BKE_effectors_create(depsgraph, ob, NULL, sb->effector_weights); + _scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, effectors); + BKE_effectors_free(effectors); } static void *exec_scan_for_ext_spring_forces(void *data) { SB_thread_context *pctx = (SB_thread_context*)data; - _scan_for_ext_spring_forces(pctx->scene, pctx->ob, pctx->timenow, pctx->ifirst, pctx->ilast, pctx->do_effector); + _scan_for_ext_spring_forces(pctx->scene, pctx->ob, pctx->timenow, pctx->ifirst, pctx->ilast, pctx->effectors); return NULL; } static void sb_sfesf_threads_run(struct Depsgraph *depsgraph, Scene *scene, struct Object *ob, float timenow, int totsprings, int *UNUSED(ptr_to_break_func(void))) { - ListBase *do_effector = NULL; ListBase threads; SB_thread_context *sb_threads; int i, totthread, left, dec; int lowsprings =100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */ - do_effector= pdInitEffectors(depsgraph, scene, ob, NULL, ob->soft->effector_weights, true); + ListBase *effectors = BKE_effectors_create(depsgraph, ob, NULL, ob->soft->effector_weights); /* figure the number of threads while preventing pretty pointless threading overhead */ totthread= BKE_scene_num_threads(scene); @@ -1568,7 +1553,7 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph, Scene *scene, stru } else sb_threads[i].ifirst = 0; - sb_threads[i].do_effector = do_effector; + sb_threads[i].effectors = effectors; sb_threads[i].do_deflector = false;// not used here sb_threads[i].fieldfactor = 0.0f;// not used here sb_threads[i].windfactor = 0.0f;// not used here @@ -1588,7 +1573,7 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph, Scene *scene, stru /* clean up */ MEM_freeN(sb_threads); - pdEndEffectors(&do_effector); + BKE_effectors_free(effectors); } @@ -1941,7 +1926,7 @@ static void sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, floa /* since this is definitely the most CPU consuming task here .. try to spread it */ /* core function _softbody_calc_forces_slice_in_a_thread */ /* result is int to be able to flag user break */ -static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, float forcetime, float timenow, int ifirst, int ilast, int *UNUSED(ptr_to_break_func(void)), ListBase *do_effector, int do_deflector, float fieldfactor, float windfactor) +static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, float forcetime, float timenow, int ifirst, int ilast, int *UNUSED(ptr_to_break_func(void)), ListBase *effectors, int do_deflector, float fieldfactor, float windfactor) { float iks; int bb, do_selfcollision, do_springcollision, do_aero; @@ -2060,14 +2045,14 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo } /* particle field & vortex */ - if (do_effector) { + if (effectors) { EffectedPoint epoint; float kd; float force[3] = {0.0f, 0.0f, 0.0f}; float speed[3] = {0.0f, 0.0f, 0.0f}; float eval_sb_fric_force_scale = sb_fric_force_scale(ob); /* just for calling function once */ pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint-bp, &epoint); - pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); + BKE_effectors_apply(effectors, NULL, sb->effector_weights, &epoint, force, speed); /* apply forcefield*/ mul_v3_fl(force, fieldfactor* eval_sb_fric_force_scale); @@ -2142,11 +2127,11 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo static void *exec_softbody_calc_forces(void *data) { SB_thread_context *pctx = (SB_thread_context*)data; - _softbody_calc_forces_slice_in_a_thread(pctx->scene, pctx->ob, pctx->forcetime, pctx->timenow, pctx->ifirst, pctx->ilast, NULL, pctx->do_effector, pctx->do_deflector, pctx->fieldfactor, pctx->windfactor); + _softbody_calc_forces_slice_in_a_thread(pctx->scene, pctx->ob, pctx->forcetime, pctx->timenow, pctx->ifirst, pctx->ilast, NULL, pctx->effectors, pctx->do_deflector, pctx->fieldfactor, pctx->windfactor); return NULL; } -static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow, int totpoint, int *UNUSED(ptr_to_break_func(void)), struct ListBase *do_effector, int do_deflector, float fieldfactor, float windfactor) +static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow, int totpoint, int *UNUSED(ptr_to_break_func(void)), struct ListBase *effectors, int do_deflector, float fieldfactor, float windfactor) { ListBase threads; SB_thread_context *sb_threads; @@ -2178,7 +2163,7 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t } else sb_threads[i].ifirst = 0; - sb_threads[i].do_effector = do_effector; + sb_threads[i].effectors = effectors; sb_threads[i].do_deflector = do_deflector; sb_threads[i].fieldfactor = fieldfactor; sb_threads[i].windfactor = windfactor; @@ -2208,7 +2193,6 @@ static void softbody_calc_forcesEx(struct Depsgraph *depsgraph, Scene *scene, Ob */ SoftBody *sb= ob->soft; /* is supposed to be there */ /*BodyPoint *bproot;*/ /* UNUSED */ - ListBase *do_effector = NULL; /* float gravity; */ /* UNUSED */ /* float iks; */ float fieldfactor = -1.0f, windfactor = 0.25; @@ -2229,20 +2213,20 @@ static void softbody_calc_forcesEx(struct Depsgraph *depsgraph, Scene *scene, Ob sb_sfesf_threads_run(depsgraph, scene, ob, timenow, sb->totspring, NULL); /* after spring scan because it uses Effoctors too */ - do_effector= pdInitEffectors(depsgraph, scene, ob, NULL, sb->effector_weights, true); + ListBase *effectors = BKE_effectors_create(depsgraph, ob, NULL, sb->effector_weights); if (do_deflector) { float defforce[3]; do_deflector = sb_detect_aabb_collisionCached(defforce, ob->lay, ob, timenow); } - sb_cf_threads_run(scene, ob, forcetime, timenow, sb->totpoint, NULL, do_effector, do_deflector, fieldfactor, windfactor); + sb_cf_threads_run(scene, ob, forcetime, timenow, sb->totpoint, NULL, effectors, do_deflector, fieldfactor, windfactor); /* finally add forces caused by face collision */ if (ob->softflag & OB_SB_FACECOLL) scan_for_ext_face_forces(ob, timenow); /* finish matrix and solve */ - pdEndEffectors(&do_effector); + BKE_effectors_free(effectors); } @@ -2269,7 +2253,6 @@ static void softbody_calc_forces(struct Depsgraph *depsgraph, Scene *scene, Obje BodyPoint *bp; /* BodyPoint *bproot; */ /* UNUSED */ BodySpring *bs; - ListBase *do_effector = NULL; float iks, ks, kd, gravity[3] = {0.0f, 0.0f, 0.0f}; float fieldfactor = -1.0f, windfactor = 0.25f; float tune = sb->ballstiff; @@ -2291,7 +2274,7 @@ static void softbody_calc_forces(struct Depsgraph *depsgraph, Scene *scene, Obje if (do_springcollision || do_aero) scan_for_ext_spring_forces(depsgraph, scene, ob, timenow); /* after spring scan because it uses Effoctors too */ - do_effector= pdInitEffectors(depsgraph, scene, ob, NULL, ob->soft->effector_weights, true); + ListBase *effectors = BKE_effectors_create(depsgraph, ob, NULL, ob->soft->effector_weights); if (do_deflector) { float defforce[3]; @@ -2394,13 +2377,13 @@ static void softbody_calc_forces(struct Depsgraph *depsgraph, Scene *scene, Obje /* particle field & vortex */ - if (do_effector) { + if (effectors) { EffectedPoint epoint; float force[3] = {0.0f, 0.0f, 0.0f}; float speed[3] = {0.0f, 0.0f, 0.0f}; float eval_sb_fric_force_scale = sb_fric_force_scale(ob); /* just for calling function once */ pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint-bp, &epoint); - pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); + BKE_effectors_apply(effectors, NULL, sb->effector_weights, &epoint, force, speed); /* apply forcefield*/ mul_v3_fl(force, fieldfactor* eval_sb_fric_force_scale); @@ -2492,7 +2475,7 @@ static void softbody_calc_forces(struct Depsgraph *depsgraph, Scene *scene, Obje /* finally add forces caused by face collision */ if (ob->softflag & OB_SB_FACECOLL) scan_for_ext_face_forces(ob, timenow); - pdEndEffectors(&do_effector); + BKE_effectors_free(effectors); } } @@ -3495,9 +3478,7 @@ static void softbody_step(struct Depsgraph *depsgraph, Scene *scene, Object *ob, ccd_update_deflector_hash(depsgraph, sb->collision_group, ob, sb->scratch->colliderhash); if (sb->scratch->needstobuildcollider) { - if (query_external_colliders(depsgraph, sb->collision_group)) { - ccd_build_deflector_hash(depsgraph, sb->collision_group, ob, sb->scratch->colliderhash); - } + ccd_build_deflector_hash(depsgraph, sb->collision_group, ob, sb->scratch->colliderhash); sb->scratch->needstobuildcollider=0; } diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index da370971715..b2a1785542c 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -39,6 +39,7 @@ #include "BLI_fileops_types.h" #include "BLI_listbase.h" #include "BLI_math.h" +#include "BLI_math_color.h" #include "BLI_path_util.h" #include "BLI_rand.h" #include "BLI_string.h" @@ -56,10 +57,33 @@ /* Statics */ static ListBase studiolights; +static int last_studiolight_id = 0; #define STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE 128 #define STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT 32 #define STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH (STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT * 2) +#define STUDIOLIGHT_IRRADIANCE_METHOD_RADIANCE 0 +#define STUDIOLIGHT_IRRADIANCE_METHOD_SPHERICAL_HARMONICS 1 +/* + * The method to calculate the irradiance buffers + * The irradiance buffer is only shown in the background when in LookDev. + * + * STUDIOLIGHT_IRRADIANCE_METHOD_RADIANCE is very slow, but very accurate + * STUDIOLIGHT_IRRADIANCE_METHOD_SPHERICAL_HARMONICS is faster but has artifacts + */ +// #define STUDIOLIGHT_IRRADIANCE_METHOD STUDIOLIGHT_IRRADIANCE_METHOD_RADIANCE +#define STUDIOLIGHT_IRRADIANCE_METHOD STUDIOLIGHT_IRRADIANCE_METHOD_SPHERICAL_HARMONICS + +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL == 2 +# define STUDIOLIGHT_SPHERICAL_HARMONICS_WINDOWING +#endif + +/* + * Disable this option so caches are not loaded from disk + * Do not checkin with this commented out + */ +#define STUDIOLIGHT_LOAD_CACHED_FILES + static const char *STUDIOLIGHT_CAMERA_FOLDER = "studiolights/camera/"; static const char *STUDIOLIGHT_WORLD_FOLDER = "studiolights/world/"; static const char *STUDIOLIGHT_MATCAP_FOLDER = "studiolights/matcap/"; @@ -104,7 +128,7 @@ static void studiolight_free(struct StudioLight *sl) IMB_SAFE_FREE(sl->equirectangular_radiance_buffer); IMB_SAFE_FREE(sl->equirectangular_irradiance_buffer); MEM_SAFE_FREE(sl->path_irr_cache); - MEM_SAFE_FREE(sl->path_sh2_cache); + MEM_SAFE_FREE(sl->path_sh_cache); MEM_SAFE_FREE(sl->gpu_matcap_3components); MEM_SAFE_FREE(sl); } @@ -115,10 +139,10 @@ static struct StudioLight *studiolight_create(int flag) sl->path[0] = 0x00; sl->name[0] = 0x00; sl->path_irr_cache = NULL; - sl->path_sh2_cache = NULL; + sl->path_sh_cache = NULL; sl->free_function = NULL; sl->flag = flag; - sl->index = BLI_listbase_count(&studiolights); + sl->index = ++last_studiolight_id; if (flag & STUDIOLIGHT_ORIENTATION_VIEWNORMAL) { sl->icon_id_matcap = BKE_icon_ensure_studio_light(sl, STUDIOLIGHT_ICON_ID_TYPE_MATCAP); sl->icon_id_matcap_flipped = BKE_icon_ensure_studio_light(sl, STUDIOLIGHT_ICON_ID_TYPE_MATCAP_FLIPPED); @@ -187,10 +211,13 @@ static void studiolight_load_equirectangular_image(StudioLight *sl) if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) { ImBuf *ibuf = NULL; ibuf = IMB_loadiffname(sl->path, 0, NULL); - if (ibuf) { - IMB_float_from_rect(ibuf); - sl->equirectangular_radiance_buffer = ibuf; + if (ibuf == NULL) { + float *colbuf = MEM_mallocN(sizeof(float[4]), __func__); + copy_v4_fl4(colbuf, 1.0f, 0.0f, 1.0f, 1.0f); + ibuf = IMB_allocFromBuffer(NULL, colbuf, 1, 1); } + IMB_float_from_rect(ibuf); + sl->equirectangular_radiance_buffer = ibuf; } sl->flag |= STUDIOLIGHT_EXTERNAL_IMAGE_LOADED; } @@ -325,6 +352,9 @@ BLI_INLINE void studiolight_evaluate_radiance_buffer( } +/* + * Spherical Harmonics + */ BLI_INLINE float studiolight_area_element(float x, float y) { return atan2(x * y, sqrtf(x * x + y * y + 1)); @@ -345,9 +375,9 @@ static void studiolight_calculate_cubemap_vector_weight(float normal[3], float * copy_v3_fl3(normal, x * 2.0f - 1.0f, y * 2.0f - 1.0f, 1.0f); const float conversion_matrices[6][3][3] = { { - {0.0f, 0.0f, -1.0f}, + {0.0f, 0.0f, 1.0f}, {0.0f, -1.0f, 0.0f}, - {-1.0f, 0.0f, 0.0f}, + {1.0f, 0.0f, 0.0f}, }, { {0.0f, 0.0f, -1.0f}, @@ -356,13 +386,13 @@ static void studiolight_calculate_cubemap_vector_weight(float normal[3], float * }, { {1.0f, 0.0f, 0.0f}, - {0.0f, 0.0f, 1.0f}, - {0.0f, -1.0f, 0.0f}, + {0.0f, 0.0f, -1.0f}, + {0.0f, 1.0f, 0.0f}, }, { {1.0f, 0.0f, 0.0f}, - {0.0f, 0.0f, -1.0f}, - {0.0f, 1.0f, 0.0f}, + {0.0f, 0.0f, 1.0f}, + {0.0f, -1.0f, 0.0f}, }, { {1.0f, 0.0f, 0.0f}, @@ -375,6 +405,7 @@ static void studiolight_calculate_cubemap_vector_weight(float normal[3], float * {0.0f, 0.0f, 1.0f}, } }; + mul_m3_v3(conversion_matrices[face], normal); normalize_v3(normal); const float halfpix = 1.0f / (2.0f * STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE); @@ -464,6 +495,103 @@ static void studiolight_calculate_spherical_harmonics_coefficient(StudioLight *s copy_v3_v3(sl->spherical_harmonics_coefs[sh_component], sh); } +#ifdef STUDIOLIGHT_SPHERICAL_HARMONICS_WINDOWING +static void studiolight_calculate_spherical_harmonics_luminance(StudioLight *sl, float luminance[STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS]) +{ + for (int index = 0; index < STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS; index++) { + luminance[index] = rgb_to_grayscale(sl->spherical_harmonics_coefs[index]); + } +} + +static void studiolight_apply_spherical_harmonics_windowing(StudioLight *sl, float max_lamplacian) +{ + /* From Peter-Pike Sloan's Stupid SH Tricks http://www.ppsloan.org/publications/StupidSH36.pdf */ + float table_l[STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL + 1]; + float table_b[STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL + 1]; + + table_l[0] = 0.0f; + table_b[0] = 0.0f; + + /* convert to luminance */ + float luminance[STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS]; + studiolight_calculate_spherical_harmonics_luminance(sl, luminance); + + int index = 1; + for (int level = 1; level <= STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL; level++) { + table_l[level] = (float)(SQUARE(level) * SQUARE(level + 1)); + + float b = 0.0f; + for (int m = -1; m <= level; m++) { + b += SQUARE(luminance[index++]); + } + table_b[level] = b; + } + + float squared_lamplacian = 0.0f; + for (int level = 1; level <= STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL; level++) { + squared_lamplacian += table_l[level] * table_b[level]; + } + + const float target_squared_laplacian = max_lamplacian * max_lamplacian; + if (squared_lamplacian <= target_squared_laplacian) { + return; + } + + float lambda = 0.0f; + + const int no_iterations = 10000000; + for (int i = 0; i < no_iterations; ++i) { + float f = 0.0f; + float fd = 0.0f; + + for (int level = 1; level <= (int)STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL; ++level) { + f += table_l[level] * table_b[level] / SQUARE(1.0f + lambda * table_l[level]); + fd += (2.0f * SQUARE(table_l[level]) * table_b[level]) / CUBE(1.0f + lambda * table_l[level]); + } + + f = target_squared_laplacian - f; + + float delta = -f / fd; + lambda += delta; + + if (ABS(delta) < 1e-6f) { + break; + } + } + + /* Apply windowing lambda */ + index = 0; + for (int level = 0; level <= STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL; level ++) { + float s = 1.0f / (1.0f + lambda * SQUARE(level) * SQUARE(level + 1.0f)); + + for (int m = -1; m <= level; m++) { + mul_v3_fl(sl->spherical_harmonics_coefs[index++], s); + } + } +} +#endif + +BLI_INLINE void studiolight_sample_spherical_harmonics(StudioLight *sl, float color[3], float normal[3]) +{ + copy_v3_fl(color, 0.0f); + madd_v3_v3fl(color, sl->spherical_harmonics_coefs[0], 0.282095f); + +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL > 0 + /* Spherical Harmonics L1 */ + madd_v3_v3fl(color, sl->spherical_harmonics_coefs[1], -0.488603f * normal[2]); + madd_v3_v3fl(color, sl->spherical_harmonics_coefs[2], 0.488603f * normal[1]); + madd_v3_v3fl(color, sl->spherical_harmonics_coefs[3], -0.488603f * normal[0]); +#endif + +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL > 1 + /* Spherical Harmonics L1 */ + madd_v3_v3fl(color, sl->spherical_harmonics_coefs[4], 1.092548f * normal[0] * normal[2]); + madd_v3_v3fl(color, sl->spherical_harmonics_coefs[5], -1.092548f * normal[2] * normal[1]); + madd_v3_v3fl(color, sl->spherical_harmonics_coefs[6], 0.315392f * (3.0f * normal[1] * normal[1] - 1.0f)); + madd_v3_v3fl(color, sl->spherical_harmonics_coefs[7], -1.092548 * normal[0] * normal[1]); + madd_v3_v3fl(color, sl->spherical_harmonics_coefs[8], 0.546274 * (normal[0] * normal[0] - normal[2] * normal[2])); +#endif +} static void studiolight_calculate_diffuse_light(StudioLight *sl) { @@ -471,14 +599,16 @@ static void studiolight_calculate_diffuse_light(StudioLight *sl) if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) { BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_RADIANCE_BUFFERS_CALCULATED); - for (int comp = 0; comp < 9; comp ++) { + for (int comp = 0; comp < STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS; comp ++) { studiolight_calculate_spherical_harmonics_coefficient(sl, comp); -#if 0 - print_v3("SH2", sl->spherical_harmonics_coefs[comp]); -#endif } + +#ifdef STUDIOLIGHT_SPHERICAL_HARMONICS_WINDOWING + studiolight_apply_spherical_harmonics_windowing(sl, STUDIOLIGHT_SPHERICAL_HARMONICS_WINDOWING_TARGET_LAMPLACIAN); +#endif + if (sl->flag & STUDIOLIGHT_USER_DEFINED) { - FILE *fp = BLI_fopen(sl->path_sh2_cache, "wb"); + FILE *fp = BLI_fopen(sl->path_sh_cache, "wb"); if (fp) { fwrite(sl->spherical_harmonics_coefs, sizeof(sl->spherical_harmonics_coefs), 1, fp); fclose(fp); @@ -488,11 +618,6 @@ static void studiolight_calculate_diffuse_light(StudioLight *sl) sl->flag |= STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED; } -static float area_element(float x, float y ) -{ - return atan2f(x * y, sqrt(x * x + y * y + 1)); -} - static float texel_coord_solid_angle(float a_U, float a_V, int a_Size) { //scale up to [-1, 1] range (inclusive), offset by 0.5 to point to texel center. @@ -507,7 +632,7 @@ static float texel_coord_solid_angle(float a_U, float a_V, int a_Size) float y0 = v - resolution_inv; float x1 = u + resolution_inv; float y1 = v + resolution_inv; - return area_element(x0, y0) - area_element(x0, y1) - area_element(x1, y0) + area_element(x1, y1); + return studiolight_area_element(x0, y0) - studiolight_area_element(x0, y1) - studiolight_area_element(x1, y0) + studiolight_area_element(x1, y1); } BLI_INLINE void studiolight_evaluate_specular_radiance_buffer( @@ -537,6 +662,7 @@ BLI_INLINE void studiolight_evaluate_specular_radiance_buffer( } +#if STUDIOLIGHT_IRRADIANCE_METHOD == STUDIOLIGHT_IRRADIANCE_METHOD_RADIANCE static void studiolight_calculate_specular_irradiance(StudioLight *sl, float color[3], const float normal[3]) { copy_v3_fl(color, 0.0f); @@ -564,9 +690,11 @@ static void studiolight_calculate_specular_irradiance(StudioLight *sl, float col mul_v3_fl(color, 1.0 / M_PI); } +#endif static bool studiolight_load_irradiance_equirectangular_image(StudioLight *sl) { +#ifdef STUDIOLIGHT_LOAD_CACHED_FILES if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) { ImBuf *ibuf = NULL; ibuf = IMB_loadiffname(sl->path_irr_cache, 0, NULL); @@ -577,32 +705,37 @@ static bool studiolight_load_irradiance_equirectangular_image(StudioLight *sl) return true; } } +#endif return false; } static bool studiolight_load_spherical_harmonics_coefficients(StudioLight *sl) { +#ifdef STUDIOLIGHT_LOAD_CACHED_FILES if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) { - FILE *fp = BLI_fopen(sl->path_sh2_cache, "rb"); + FILE *fp = BLI_fopen(sl->path_sh_cache, "rb"); if (fp) { - if (fread((void*)(sl->spherical_harmonics_coefs), sizeof(sl->spherical_harmonics_coefs), 1, fp)) - { + if (fread((void *)(sl->spherical_harmonics_coefs), sizeof(sl->spherical_harmonics_coefs), 1, fp)) { sl->flag |= STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED; - fclose(fp); + fclose(fp); return true; } fclose(fp); } } +#endif return false; } static void studiolight_calculate_irradiance_equirectangular_image(StudioLight *sl) { if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) { - /* check for cached irr file */ - +#if STUDIOLIGHT_IRRADIANCE_METHOD == STUDIOLIGHT_IRRADIANCE_METHOD_RADIANCE BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_RADIANCE_BUFFERS_CALCULATED); +#endif +#if STUDIOLIGHT_IRRADIANCE_METHOD == STUDIOLIGHT_IRRADIANCE_METHOD_SPHERICAL_HARMONICS + BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED); +#endif float *colbuf = MEM_mallocN(STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH * STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT * sizeof(float[4]), __func__); float *color = colbuf; @@ -613,20 +746,33 @@ static void studiolight_calculate_irradiance_equirectangular_image(StudioLight * float xf = x / (float)STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH; float dir[3]; equirectangular_to_direction(dir, xf, yf); + +#if STUDIOLIGHT_IRRADIANCE_METHOD == STUDIOLIGHT_IRRADIANCE_METHOD_RADIANCE studiolight_calculate_specular_irradiance(sl, color, dir); +#endif +#if STUDIOLIGHT_IRRADIANCE_METHOD == STUDIOLIGHT_IRRADIANCE_METHOD_SPHERICAL_HARMONICS + studiolight_sample_spherical_harmonics(sl, color, dir); +#endif + color[3] = 1.0f; color += 4; } } + sl->equirectangular_irradiance_buffer = IMB_allocFromBuffer( NULL, colbuf, STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH, STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT); MEM_freeN(colbuf); +#if STUDIOLIGHT_IRRADIANCE_METHOD == STUDIOLIGHT_IRRADIANCE_METHOD_RADIANCE + /* + * Only store cached files when using STUDIOLIGHT_IRRADIANCE_METHOD_RADIANCE + */ if (sl->flag & STUDIOLIGHT_USER_DEFINED) { IMB_saveiff(sl->equirectangular_irradiance_buffer, sl->path_irr_cache, IB_rectfloat); } +#endif } sl->flag |= STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_IMAGE_CALCULATED; } @@ -665,9 +811,24 @@ static void studiolight_calculate_light_direction(StudioLight *sl) sl->flag |= STUDIOLIGHT_LIGHT_DIRECTION_CALCULATED; } +static StudioLight *studiolight_add_file(const char *path, int flag) +{ + char filename[FILE_MAXFILE]; + BLI_split_file_part(path, filename, FILE_MAXFILE); + if (BLI_path_extension_check_array(filename, imb_ext_image)) { + StudioLight *sl = studiolight_create(STUDIOLIGHT_EXTERNAL_FILE | flag); + BLI_strncpy(sl->name, filename, FILE_MAXFILE); + BLI_strncpy(sl->path, path, FILE_MAXFILE); + sl->path_irr_cache = BLI_string_joinN(path, ".irr"); + sl->path_sh_cache = BLI_string_joinN(path, ".sh2"); + BLI_addtail(&studiolights, sl); + return sl; + } + return NULL; +} + static void studiolight_add_files_from_datafolder(const int folder_id, const char *subfolder, int flag) { - StudioLight *sl; struct direntry *dir; const char *folder = BKE_appdir_folder_id(folder_id, subfolder); if (folder) { @@ -675,16 +836,7 @@ static void studiolight_add_files_from_datafolder(const int folder_id, const cha int i; for (i = 0; i < totfile; i++) { if ((dir[i].type & S_IFREG)) { - const char *filename = dir[i].relname; - const char *path = dir[i].path; - if (BLI_path_extension_check_array(filename, imb_ext_image)) { - sl = studiolight_create(STUDIOLIGHT_EXTERNAL_FILE | flag); - BLI_strncpy(sl->name, filename, FILE_MAXFILE); - BLI_strncpy(sl->path, path, FILE_MAXFILE); - sl->path_irr_cache = BLI_string_joinN(path, ".irr"); - sl->path_sh2_cache = BLI_string_joinN(path, ".sh2"); - BLI_addtail(&studiolights, sl); - } + studiolight_add_file(dir[i].path, flag); } } BLI_filelist_free(dir, totfile); @@ -737,7 +889,7 @@ static uint alpha_circle_mask(float u, float v, float inner_edge, float outer_ed #define STUDIOLIGHT_DIAMETER 0.95f -static void studiolight_radiance_preview(uint* icon_buffer, StudioLight *sl) +static void studiolight_radiance_preview(uint *icon_buffer, StudioLight *sl) { BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED); @@ -782,7 +934,7 @@ static void studiolight_radiance_preview(uint* icon_buffer, StudioLight *sl) } } -static void studiolight_matcap_preview(uint* icon_buffer, StudioLight *sl, bool flipped) +static void studiolight_matcap_preview(uint *icon_buffer, StudioLight *sl, bool flipped) { BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED); @@ -813,7 +965,7 @@ static void studiolight_matcap_preview(uint* icon_buffer, StudioLight *sl, bool } } -static void studiolight_irradiance_preview(uint* icon_buffer, StudioLight *sl) +static void studiolight_irradiance_preview(uint *icon_buffer, StudioLight *sl) { BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED); @@ -838,21 +990,8 @@ static void studiolight_irradiance_preview(uint* icon_buffer, StudioLight *sl) normal[2] = -sqrtf(1.0f - SQUARE(dist)); SWAP(float, normal[1], normal[2]); - float color[3] = {0.0f, 0.0f, 0.0f}; - /* Spherical Harmonics L0 */ - madd_v3_v3fl(color, sl->spherical_harmonics_coefs[0], 0.282095f); - - /* Spherical Harmonics L1 */ - madd_v3_v3fl(color, sl->spherical_harmonics_coefs[1], -0.488603f * normal[2]); - madd_v3_v3fl(color, sl->spherical_harmonics_coefs[2], 0.488603f * normal[1]); - madd_v3_v3fl(color, sl->spherical_harmonics_coefs[3], -0.488603f * normal[0]); - - /* Spherical Harmonics L1 */ - madd_v3_v3fl(color, sl->spherical_harmonics_coefs[4], 1.092548f * normal[0] * normal[2]); - madd_v3_v3fl(color, sl->spherical_harmonics_coefs[5], -1.092548f * normal[2] * normal[1]); - madd_v3_v3fl(color, sl->spherical_harmonics_coefs[6], 0.315392f * (3.0f * normal[1] * normal[1] - 1.0f)); - madd_v3_v3fl(color, sl->spherical_harmonics_coefs[7], -1.092548 * normal[0] * normal[1]); - madd_v3_v3fl(color, sl->spherical_harmonics_coefs[8], 0.546274 * (normal[0] * normal[0] - normal[2] * normal[2])); + float color[3]; + studiolight_sample_spherical_harmonics(sl, color, normal); pixelresult = rgb_to_cpack( linearrgb_to_srgb(color[0]), linearrgb_to_srgb(color[1]), @@ -874,15 +1013,20 @@ void BKE_studiolight_init(void) sl = studiolight_create(STUDIOLIGHT_INTERNAL | STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED | STUDIOLIGHT_ORIENTATION_CAMERA); BLI_strncpy(sl->name, "Default", FILE_MAXFILE); + copy_v3_fl3(sl->spherical_harmonics_coefs[0], 1.03271556f, 1.07163882f, 1.11193657f); +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL > 0 copy_v3_fl3(sl->spherical_harmonics_coefs[1], -0.00480952f, 0.05290511f, 0.16394117f); copy_v3_fl3(sl->spherical_harmonics_coefs[2], -0.29686999f, -0.27378261f, -0.24797194f); copy_v3_fl3(sl->spherical_harmonics_coefs[3], 0.47932500f, 0.48242140f, 0.47190312f); +#endif +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL > 1 copy_v3_fl3(sl->spherical_harmonics_coefs[4], -0.00576984f, 0.00504886f, 0.01640534f); copy_v3_fl3(sl->spherical_harmonics_coefs[5], 0.15500379f, 0.15415503f, 0.16244425f); copy_v3_fl3(sl->spherical_harmonics_coefs[6], -0.02483751f, -0.02245096f, -0.00536885f); copy_v3_fl3(sl->spherical_harmonics_coefs[7], 0.11155496f, 0.11005443f, 0.10839636f); copy_v3_fl3(sl->spherical_harmonics_coefs[8], 0.01363425f, 0.01278363f, -0.00159006f); +#endif BLI_addtail(&studiolights, sl); @@ -948,7 +1092,7 @@ struct ListBase *BKE_studiolight_listbase(void) return &studiolights; } -void BKE_studiolight_preview(uint* icon_buffer, StudioLight *sl, int icon_id_type) +void BKE_studiolight_preview(uint *icon_buffer, StudioLight *sl, int icon_id_type) { switch (icon_id_type) { case STUDIOLIGHT_ICON_ID_TYPE_RADIANCE: @@ -1009,6 +1153,23 @@ void BKE_studiolight_ensure_flag(StudioLight *sl, int flag) } } +/* + * Python API Functions + */ +void BKE_studiolight_remove(StudioLight *sl) +{ + if (sl->flag & STUDIOLIGHT_USER_DEFINED) { + BLI_remlink(&studiolights, sl); + studiolight_free(sl); + } +} + +StudioLight *BKE_studiolight_new(const char *path, int orientation) +{ + StudioLight *sl = studiolight_add_file(path, orientation | STUDIOLIGHT_USER_DEFINED); + return sl; +} + void BKE_studiolight_refresh(void) { BKE_studiolight_free(); @@ -1036,4 +1197,4 @@ void BKE_studiolight_unset_icon_id(StudioLight *sl, int icon_id) if (sl->icon_id_matcap_flipped == icon_id) { sl->icon_id_matcap_flipped = 0; } -}
\ No newline at end of file +} diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index e4f08703dfc..9ea6ef62e4e 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1827,7 +1827,7 @@ static void ccgDM_release(DerivedMesh *dm) if (ccgdm->multires.mmd) { if (ccgdm->multires.modified_flags & MULTIRES_COORDS_MODIFIED) - multires_modifier_update_mdisps(dm); + multires_modifier_update_mdisps(dm, NULL); if (ccgdm->multires.modified_flags & MULTIRES_HIDDEN_MODIFIED) multires_modifier_update_hidden(dm); } @@ -2930,6 +2930,7 @@ static bool subsurf_use_gpu_backend(SubsurfFlags flags) struct DerivedMesh *subsurf_make_derived_from_derived( struct DerivedMesh *dm, struct SubsurfModifierData *smd, + struct Scene *scene, float (*vertCos)[3], SubsurfFlags flags) { @@ -2943,7 +2944,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( /* note: editmode calculation can only run once per * modifier stack evaluation (uses freed cache) [#36299] */ if (flags & SUBSURF_FOR_EDIT_MODE) { - int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels, false) : smd->levels; + int levels = (scene != NULL) ? get_render_subsurf_level(&scene->r, smd->levels, false) : smd->levels; /* TODO(sergey): Same as emCache below. */ if ((flags & SUBSURF_IN_EDIT_MODE) && smd->mCache) { @@ -2964,7 +2965,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( else if (flags & SUBSURF_USE_RENDER_PARAMS) { /* Do not use cache in render mode. */ CCGSubSurf *ss; - int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->renderLevels, true) : smd->renderLevels; + int levels = (scene != NULL) ? get_render_subsurf_level(&scene->r, smd->renderLevels, true) : smd->renderLevels; if (levels == 0) return dm; @@ -2980,7 +2981,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( } else { int useIncremental = (smd->flags & eSubsurfModifierFlag_Incremental); - int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels, false) : smd->levels; + int levels = (scene != NULL) ? get_render_subsurf_level(&scene->r, smd->levels, false) : smd->levels; CCGSubSurf *ss; /* It is quite possible there is a much better place to do this. It diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c index 99fb6b14a35..3a9a392da4a 100644 --- a/source/blender/blenkernel/intern/workspace.c +++ b/source/blender/blenkernel/intern/workspace.c @@ -235,6 +235,9 @@ WorkSpaceLayout *BKE_workspace_layout_add( WorkSpaceLayout *layout = MEM_callocN(sizeof(*layout), __func__); BLI_assert(!workspaces_is_screen_used(bmain, screen)); +#ifndef DEBUG + UNUSED_VARS(bmain); +#endif layout->screen = screen; workspace_layout_name_set(workspace, layout, name); BLI_addtail(&workspace->layouts, layout); diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h index 9029fff60e5..612151b7ea2 100644 --- a/source/blender/blenlib/BLI_rand.h +++ b/source/blender/blenlib/BLI_rand.h @@ -64,10 +64,6 @@ void BLI_rng_shuffle_array(struct RNG *rng, void *data, unsigned int elem /** Note that skipping is as slow as generating n numbers! */ void BLI_rng_skip(struct RNG *rng, int n) ATTR_NONNULL(1); -/** Return a pseudo-random number N where 0.0f<=N<1.0f */ -/* !!!!! NOTE: DO NOT USE IT IN NEW CODE !!!!! */ -float BLI_frand(void) ATTR_WARN_UNUSED_RESULT; - /** Return a pseudo-random (hash) float from an integer value */ float BLI_hash_frand(unsigned int seed) ATTR_WARN_UNUSED_RESULT; diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 36281ee0fcc..286e1cc6dd5 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -274,11 +274,15 @@ extern "C" { #define SQUARE(a) ({ \ typeof(a) a_ = (a); \ ((a_) * (a_)); }) +#define CUBE(a) ({ \ + typeof(a) a_ = (a); \ + ((a_) * (a_) * (a_)); }) #else #define ABS(a) ((a) < 0 ? (-(a)) : (a)) #define SQUARE(a) ((a) * (a)) +#define CUBE(a) ((a) * (a) * (a)) #endif diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c index 75b50caf367..9e56ce6b2cf 100644 --- a/source/blender/blenlib/intern/rand.c +++ b/source/blender/blenlib/intern/rand.c @@ -265,26 +265,6 @@ void BLI_rng_skip(RNG *rng, int n) /***/ -/* initialize with some non-zero seed */ -static RNG theBLI_rng = {611330372042337130}; - -static void ensure_rng_thread_safe(void) -{ - /* TODO(sergey): Ideally we will get rid of all rng functions which - * are using global generator. But for until then we need some way to - * catch "bad" calls at runtime. - * - * NOTE: Lots of areas are not ported, so we keep check disabled for now. - */ - // BLI_assert(BLI_thread_is_main()); -} - -float BLI_frand(void) -{ - ensure_rng_thread_safe(); - return BLI_rng_get_float(&theBLI_rng); -} - float BLI_hash_frand(unsigned int seed) { RNG rng; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a87cad1dccd..994a46929ca 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2944,6 +2944,7 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) { tref->runtime = NULL; tref->properties = newdataadr(fd, tref->properties); + IDP_DirectLinkGroup_OrFree(&tref->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); } } @@ -5031,7 +5032,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) for (md=lb->first; md; md=md->next) { md->error = NULL; - md->scene = NULL; /* if modifiers disappear, or for upward compatibility */ if (NULL == modifierType_getInfo(md->type)) @@ -5590,6 +5590,8 @@ static void direct_link_layer_collections(FileData *fd, ListBase *lb, bool maste lc->collection = newdataadr(fd, lc->collection); } + lc->runtime_flag = 0; + direct_link_layer_collections(fd, &lc->layer_collections, false); } } @@ -5612,6 +5614,7 @@ static void direct_link_view_layer(FileData *fd, ViewLayer *view_layer) BLI_listbase_clear(&view_layer->drawdata); view_layer->object_bases_array = NULL; view_layer->object_bases_hash = NULL; + view_layer->runtime_flag = 0; link_list(fd, &(view_layer->override_sets)); for (OverrideSet *override_set = view_layer->override_sets.first; override_set; override_set = override_set->next) { @@ -6986,6 +6989,7 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) win->ghostwin = NULL; win->gwnctx = NULL; win->eventstate = NULL; + win->cursor_keymap_status = NULL; win->tweak = NULL; #ifdef WIN32 win->ime_data = NULL; @@ -8719,6 +8723,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) link_list(fd, &user->themes); link_list(fd, &user->user_keymaps); + link_list(fd, &user->user_menus); link_list(fd, &user->addons); link_list(fd, &user->autoexec_paths); @@ -8744,6 +8749,17 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) direct_link_keymapitem(fd, kmi); } + for (bUserMenu *um = user->user_menus.first; um; um = um->next) { + link_list(fd, &um->items); + for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) { + if (umi->type == USER_MENU_TYPE_OPERATOR) { + bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; + umi_op->prop = newdataadr(fd, umi_op->prop); + IDP_DirectLinkGroup_OrFree(&umi_op->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + } + } + } + for (addon = user->addons.first; addon; addon = addon->next) { addon->prop = newdataadr(fd, addon->prop); IDP_DirectLinkGroup_OrFree(&addon->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); @@ -10080,7 +10096,7 @@ static void add_loose_objects_to_scene( if (flag & FILE_AUTOSELECT) { /* Note that link_object_postprocess() already checks for FILE_AUTOSELECT flag, * but it will miss objects from non-instantiated collections... */ - if (base->flag & BASE_SELECTABLED) { + if (base->flag & BASE_SELECTABLE) { base->flag |= BASE_SELECTED; BKE_scene_object_base_flag_sync_from_base(base); } @@ -10113,7 +10129,7 @@ static void add_collections_to_scene( BKE_collection_object_add(bmain, active_collection, ob); Base *base = BKE_view_layer_base_find(view_layer, ob); - if (base->flag & BASE_SELECTABLED) { + if (base->flag & BASE_SELECTABLE) { base->flag |= BASE_SELECTED; } @@ -10224,7 +10240,7 @@ static void link_object_postprocess(ID *id, Main *bmain, Scene *scene, ViewLayer BKE_scene_object_base_flag_sync_from_base(base); if (flag & FILE_AUTOSELECT) { - if (base->flag & BASE_SELECTABLED) { + if (base->flag & BASE_SELECTABLE) { base->flag |= BASE_SELECTED; BKE_scene_object_base_flag_sync_from_base(base); } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 74ff53a45d9..06017668c02 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -144,6 +144,7 @@ static void do_version_area_change_space_to_space_action(ScrArea *area, const Sc saction->mode = SACTCONT_TIMELINE; saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED; + saction->ads.filterflag |= ADS_FILTER_SUMMARY; } /** @@ -355,13 +356,6 @@ static void do_version_scene_collection_to_collection(Main *bmain, Scene *scene) #endif -enum { - DO_VERSION_COLLECTION_VISIBLE = 0, - DO_VERSION_COLLECTION_HIDE = 1, - DO_VERSION_COLLECTION_HIDE_RENDER = 2, - DO_VERSION_COLLECTION_HIDE_ALL = 3, -}; - static void do_version_layers_to_collections(Main *bmain, Scene *scene) { /* Since we don't have access to FileData we check the (always valid) first @@ -376,99 +370,26 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) /* Create collections from layers. */ Collection *collection_master = BKE_collection_master(scene); - - struct DoVersionSceneCollections { - Collection *collections[20]; - int created; - const char *suffix; - int flag; - } collections[] = - { - { - .collections = {NULL}, - .created = 0, - .suffix = "", - .flag = 0, - }, - { - .collections = {NULL}, - .created = 0, - .suffix = " - Hide Viewport", - .flag = COLLECTION_RESTRICT_VIEW, - }, - { - .collections = {NULL}, - .created = 0, - .suffix = " - Hide Render", - .flag = COLLECTION_RESTRICT_RENDER, - }, - { - .collections = {NULL}, - .created = 0, - .suffix = " - Hide Render All", - .flag = COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER, - } - }; + Collection *collections[20] = {NULL}; for (int layer = 0; layer < 20; layer++) { for (Base *base = scene->base.first; base; base = base->next) { if (base->lay & (1 << layer)) { - int collection_index = -1; - if ((base->object->restrictflag & OB_RESTRICT_VIEW) && - (base->object->restrictflag & OB_RESTRICT_RENDER)) - { - collection_index = DO_VERSION_COLLECTION_HIDE_ALL; - } - else if (base->object->restrictflag & OB_RESTRICT_VIEW) { - collection_index = DO_VERSION_COLLECTION_HIDE; - } - else if (base->object->restrictflag & OB_RESTRICT_RENDER) { - collection_index = DO_VERSION_COLLECTION_HIDE_RENDER; - } - else { - collection_index = DO_VERSION_COLLECTION_VISIBLE; - } - /* Create collections when needed only. */ - if ((collections[collection_index].created & (1 << layer)) == 0) { + if (collections[layer] == NULL) { char name[MAX_NAME]; - if ((collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) == 0) { - BLI_snprintf(name, - sizeof(collection_master->id.name), - "Collection %d%s", - layer + 1, - collections[DO_VERSION_COLLECTION_VISIBLE].suffix); - - Collection *collection = BKE_collection_add(bmain, collection_master, name); - collection->id.lib = scene->id.lib; - collection->flag |= collections[DO_VERSION_COLLECTION_VISIBLE].flag; - collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer] = collection; - collections[DO_VERSION_COLLECTION_VISIBLE].created |= (1 << layer); - - if (!(scene->lay & (1 << layer))) { - collection->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER; - } - } + BLI_snprintf(name, + sizeof(collection_master->id.name), + "Collection %d", + layer + 1); - if (collection_index != DO_VERSION_COLLECTION_VISIBLE) { - Collection *collection_parent; - collection_parent = collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer]; - BLI_snprintf(name, - sizeof(collection_master->id.name), - "Collection %d%s", - layer + 1, - collections[collection_index].suffix); - - Collection *collection = BKE_collection_add(bmain, collection_parent, name); - collection->id.lib = scene->id.lib; - collection->flag |= collections[collection_index].flag; - collections[collection_index].collections[layer] = collection; - collections[collection_index].created |= (1 << layer); - - if (!(scene->lay & (1 << layer))) { - collection->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER; - } + Collection *collection = BKE_collection_add(bmain, collection_master, name); + collection->id.lib = scene->id.lib; + collections[layer] = collection; + + if (!(scene->lay & (1 << layer))) { + collection->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER; } } @@ -476,7 +397,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) * but since no view layers exists yet at this point it's fast. */ BKE_collection_object_add( bmain, - collections[collection_index].collections[layer], base->object); + collections[layer], base->object); } if (base->flag & SELECT) { @@ -488,46 +409,6 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) } } - /* Re-order the nested hidden collections. */ - CollectionChild *child_parent = collection_master->children.first; - Collection *collection_parent = (child_parent) ? child_parent->collection : NULL; - - for (int layer = 0; layer < 20; layer++) { - if (collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) { - CollectionChild *hide_child = BLI_findptr( - &collection_parent->children, - collections[DO_VERSION_COLLECTION_HIDE].collections[layer], - offsetof(CollectionChild, collection)); - - if ((collections[DO_VERSION_COLLECTION_HIDE].created & (1 << layer)) && - (hide_child != collection_parent->children.first)) - { - BLI_listbase_swaplinks( - &collection_parent->children, - hide_child, - collection_parent->children.first); - } - - CollectionChild *hide_all_child = BLI_findptr( - &collection_parent->children, - collections[DO_VERSION_COLLECTION_HIDE_ALL].collections[layer], - offsetof(CollectionChild, collection)); - - if ((collections[DO_VERSION_COLLECTION_HIDE_ALL].created & (1 << layer)) && - (hide_all_child != collection_parent->children.last)) - { - BLI_listbase_swaplinks( - &collection_parent->children, - hide_all_child, - collection_parent->children.last); - } - - child_parent = child_parent->next; - collection_parent = (child_parent) ? child_parent->collection : NULL; - } - } - BLI_assert(collection_parent == NULL); - /* Handle legacy render layers. */ bool have_override = false; @@ -577,8 +458,8 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) /* Set exclusion and overrides. */ for (int layer = 0; layer < 20; layer++) { - if (collections[DO_VERSION_COLLECTION_VISIBLE].created & (1 << layer)) { - Collection *collection = collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer]; + Collection *collection = collections[layer]; + if (collection) { LayerCollection *lc = BKE_layer_collection_first_from_scene_collection(view_layer, collection); if (srl->lay_exclude & (1 << layer)) { @@ -612,14 +493,6 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) false); } } - - LayerCollection *nlc = lc->layer_collections.first; - for (int j = 1; j < 4; j++) { - if (collections[j].created & (1 << layer)) { - nlc = nlc->next; - } - } - BLI_assert(nlc == NULL); } } @@ -629,7 +502,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) } for (Base *base = view_layer->object_bases.first; base; base = base->next) { - if ((base->flag & BASE_SELECTABLED) && (base->object->flag & SELECT)) { + if ((base->flag & BASE_SELECTABLE) && (base->object->flag & SELECT)) { base->flag |= BASE_SELECTED; } } @@ -658,7 +531,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) /* convert selected bases */ for (Base *base = view_layer->object_bases.first; base; base = base->next) { - if ((base->flag & BASE_SELECTABLED) && (base->object->flag & SELECT)) { + if ((base->flag & BASE_SELECTABLE) && (base->object->flag & SELECT)) { base->flag |= BASE_SELECTED; } @@ -1602,5 +1475,60 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + if (!DNA_struct_elem_find(fd->filesdna, "SpaceAction", "char", "mode_prev")) { + for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_ACTION) { + SpaceAction *saction = (SpaceAction *)sl; + /* "Dopesheet" should be default here, unless it looks like the Action Editor was active instead */ + if ((saction->mode_prev == 0) && (saction->action == NULL)) { + saction->mode_prev = SACTCONT_DOPESHEET; + } + } + } + } + } + } + + for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + if (v3d->drawtype == OB_TEXTURE) { + v3d->drawtype = OB_SOLID; + v3d->shading.light = V3D_LIGHTING_STUDIO; + v3d->shading.color_type = V3D_SHADING_TEXTURE_COLOR; + } + } + } + } + } + + } + + { + if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "texture_paint_mode_opacity")) { + for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + float alpha = v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE ? 0.0f : 0.8f; + v3d->overlay.texture_paint_mode_opacity = alpha; + v3d->overlay.vertex_paint_mode_opacity = alpha; + v3d->overlay.weight_paint_mode_opacity = alpha; + } + } + } + } + } + + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { + if (scene->toolsettings->manipulator_flag == 0) { + scene->toolsettings->manipulator_flag = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; + } + } } } diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index a500c562e20..210dc07d7f2 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -141,6 +141,8 @@ void BLO_update_defaults_startup_blend(Main *bmain) if (scene->toolsettings) { ToolSettings *ts = scene->toolsettings; + ts->object_flag |= SCE_OBJECT_MODE_LOCK; + ts->uvcalc_flag |= UVCALC_TRANSFORM_CORRECT; if (ts->sculpt) { @@ -402,4 +404,3 @@ void BLO_update_defaults_startup_blend(Main *bmain) } } } - diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 4230cd01702..84d58b9e88c 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1244,6 +1244,22 @@ static void write_userdef(WriteData *wd, const UserDef *userdef) } } + for (const bUserMenu *um = userdef->user_menus.first; um; um = um->next) { + writestruct(wd, DATA, bUserMenu, 1, um); + for (const bUserMenuItem *umi = um->items.first; umi; umi = umi->next) { + if (umi->type == USER_MENU_TYPE_OPERATOR) { + const bUserMenuItem_Op *umi_op = (const bUserMenuItem_Op *)umi; + writestruct(wd, DATA, bUserMenuItem_Op, 1, umi_op); + if (umi_op->prop) { + IDP_WriteProperty(umi_op->prop, wd); + } + } + else { + writestruct(wd, DATA, bUserMenuItem, 1, umi); + } + } + } + for (const bAddon *bext = userdef->addons.first; bext; bext = bext->next) { writestruct(wd, DATA, bAddon, 1, bext); if (bext->prop) { diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 67468458f81..04cd78af830 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -42,7 +42,6 @@ extern "C" #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BKE_DerivedMesh.h" #include "BKE_fcurve.h" #include "BKE_animsys.h" #include "BKE_scene.h" diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 2f5c3237bf6..d3370172f60 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -882,7 +882,7 @@ void ArmatureImporter::make_shape_keys(bContext *C) //insert basis key kb = BKE_keyblock_add_ctime(key, "Basis", false); - BKE_keyblock_convert_from_mesh(source_me, kb); + BKE_keyblock_convert_from_mesh(source_me, key, kb); //insert other shape keys for (int i = 0 ; i < morphTargetIds.getCount() ; i++ ) { @@ -896,7 +896,7 @@ void ArmatureImporter::make_shape_keys(bContext *C) std::string morph_name = *this->mesh_importer->get_geometry_name(me->id.name); kb = BKE_keyblock_add_ctime(key, morph_name.c_str(), false); - BKE_keyblock_convert_from_mesh(me, kb); + BKE_keyblock_convert_from_mesh(me, key, kb); //apply weights weight = morphWeights.getFloatValues()->getData()[i]; diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp index 6cb1e58db6e..1a58bc9d1b8 100644 --- a/source/blender/collada/ControllerExporter.cpp +++ b/source/blender/collada/ControllerExporter.cpp @@ -199,8 +199,11 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) bool use_instantiation = this->export_settings->use_object_instantiation; Mesh *me; + if (((Mesh *)ob->data)->dvert == NULL) { + return; + } + me = bc_get_mesh_copy( - m_bmain, depsgraph, scene, ob, @@ -208,8 +211,6 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) this->export_settings->apply_modifiers, this->export_settings->triangulate); - if (!me->dvert) return; - std::string controller_name = id_name(ob_arm); std::string controller_id = get_controller_id(ob_arm, ob); @@ -293,7 +294,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) add_joints_element(&ob->defbase, joints_source_id, inv_bind_mat_source_id); add_vertex_weights_element(weights_source_id, joints_source_id, vcounts, joints); - BKE_libblock_free_us(m_bmain, me); + BKE_id_free(NULL, me); closeSkin(); closeController(); @@ -305,7 +306,6 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key) Mesh *me; me = bc_get_mesh_copy( - m_bmain, depsgraph, scene, ob, @@ -332,8 +332,7 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key) COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, morph_weights_id))); targets.add(); - BKE_libblock_free_us(m_bmain, me); - + BKE_id_free(NULL, me); //support for animations //can also try the base element and param alternative diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index 541f84f96f5..cc4ecd5649b 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -85,11 +85,11 @@ extern "C" #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BKE_DerivedMesh.h" #include "BKE_action.h" // pose functions #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_blender_version.h" +#include "BKE_customdata.h" #include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_image.h" diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index c6ba3b8f4ac..a382b7cca9c 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -232,11 +232,6 @@ void DocumentImporter::finish() objects_to_scale->insert(objects_to_scale->end(), objects_done->begin(), objects_done->end()); delete objects_done; } - - // update scene - DEG_relations_tag_update(bmain); - WM_event_add_notifier(mContext, NC_OBJECT | ND_TRANSFORM, NULL); - } @@ -245,7 +240,6 @@ void DocumentImporter::finish() armature_importer.set_tags_map(this->uid_tags_map); armature_importer.make_armatures(mContext, *objects_to_scale); armature_importer.make_shape_keys(mContext); - DEG_relations_tag_update(bmain); #if 0 armature_importer.fix_animation(); @@ -269,13 +263,16 @@ void DocumentImporter::finish() BKE_scene_collections_object_remove(bmain, sce, ob, true); } libnode_ob.clear(); - - DEG_relations_tag_update(bmain); } bc_match_scale(objects_to_scale, unit_converter, !this->import_settings->import_units); delete objects_to_scale; + + // update scene + DEG_id_tag_update(&sce->id, DEG_TAG_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); + WM_event_add_notifier(mContext, NC_OBJECT | ND_TRANSFORM, NULL); } diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index f59be97b545..fae1fc048c8 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -40,7 +40,6 @@ extern "C" { #include "BLI_utildefines.h" - #include "BKE_DerivedMesh.h" #include "BKE_main.h" #include "BKE_global.h" #include "BKE_library.h" @@ -72,14 +71,8 @@ void GeometryExporter::exportGeom(Main *bmain, struct Depsgraph *depsgraph, Scen void GeometryExporter::operator()(Object *ob) { - // XXX don't use DerivedMesh, Mesh instead? -#if 0 - DerivedMesh *dm = mesh_get_derived_final(mScene, ob, CD_MASK_BAREMESH); -#endif - bool use_instantiation = this->export_settings->use_object_instantiation; Mesh *me = bc_get_mesh_copy( - m_bmain, mDepsgraph, mScene, ob, @@ -170,8 +163,7 @@ void GeometryExporter::operator()(Object *ob) } } - BKE_libblock_free_us(m_bmain, me); - + BKE_id_free(NULL, me); } void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb) diff --git a/source/blender/collada/SceneExporter.h b/source/blender/collada/SceneExporter.h index 91f98063020..f7d56701961 100644 --- a/source/blender/collada/SceneExporter.h +++ b/source/blender/collada/SceneExporter.h @@ -48,7 +48,6 @@ extern "C" { #include "DNA_modifier_types.h" #include "DNA_userdef_types.h" -#include "BKE_DerivedMesh.h" #include "BKE_fcurve.h" #include "BKE_animsys.h" #include "BLI_path_util.h" diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index b07c6518050..8046efd2335 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -242,9 +242,6 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique invert_m4_m4(ob->parentinv, workob.obmat); DEG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA); - - DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); #endif copy_m4_m4(ob->obmat, bind_shape_matrix); BKE_object_apply_mat4(ob, ob->obmat, 0, 0); diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 4ded9bd2d86..86824800378 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -51,8 +51,8 @@ extern "C" { #include "BKE_global.h" #include "BKE_layer.h" #include "BKE_mesh.h" +#include "BKE_mesh_runtime.h" #include "BKE_scene.h" -#include "BKE_DerivedMesh.h" #include "BKE_main.h" #include "ED_armature.h" @@ -128,12 +128,6 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA); DEG_id_tag_update(&par->id, OB_RECALC_OB); - /** done once after import */ -#if 0 - DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); -#endif - return true; } @@ -166,13 +160,13 @@ Object *bc_add_object(Main *bmain, Scene *scene, ViewLayer *view_layer, int type } Mesh *bc_get_mesh_copy( - Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate) + Depsgraph *depsgraph, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate) { - Mesh *tmpmesh; CustomDataMask mask = CD_MASK_MESH; Mesh *mesh = (Mesh *)ob->data; - DerivedMesh *dm = NULL; + Mesh *tmpmesh = NULL; if (apply_modifiers) { +#if 0 /* Not supported by new system currently... */ switch (export_mesh_type) { case BC_MESH_TYPE_VIEW: { @@ -185,14 +179,20 @@ Mesh *bc_get_mesh_copy( break; } } +#else + tmpmesh = mesh_get_eval_final(depsgraph, scene, ob, mask); +#endif } else { - dm = mesh_create_derived((Mesh *)ob->data, NULL); + tmpmesh = mesh; } - tmpmesh = BKE_mesh_add(bmain, "ColladaMesh"); // name is not important here - DM_to_mesh(dm, tmpmesh, ob, CD_MASK_MESH, true); - tmpmesh->flag = mesh->flag; + BKE_id_copy_ex(NULL, &tmpmesh->id, (ID **)&tmpmesh, + LIB_ID_CREATE_NO_MAIN | + LIB_ID_CREATE_NO_USER_REFCOUNT | + LIB_ID_CREATE_NO_DEG_TAG | + LIB_ID_COPY_NO_PREVIEW, + false); if (triangulate) { bc_triangulate_mesh(tmpmesh); diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h index de9167efb07..89a5379d3c7 100644 --- a/source/blender/collada/collada_utils.h +++ b/source/blender/collada/collada_utils.h @@ -51,7 +51,6 @@ extern "C" { #include "BKE_context.h" #include "BKE_object.h" -#include "BKE_DerivedMesh.h" #include "BKE_scene.h" #include "BKE_idprop.h" } @@ -73,7 +72,7 @@ extern int bc_test_parent_loop(Object *par, Object *ob); extern int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space = true); extern Object *bc_add_object(Main *bmain, Scene *scene, ViewLayer *view_layer, int type, const char *name); extern Mesh *bc_get_mesh_copy( - Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate); + Depsgraph *depsgraph, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate); extern Object *bc_get_assigned_armature(Object *ob); extern Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob); diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index 8f6eee244f7..0673a3177b7 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -67,6 +67,7 @@ set(SRC intern/depsgraph_build.cc intern/depsgraph_debug.cc intern/depsgraph_eval.cc + intern/depsgraph_physics.cc intern/depsgraph_query.cc intern/depsgraph_query_foreach.cc intern/depsgraph_query_iter.cc @@ -76,6 +77,7 @@ set(SRC DEG_depsgraph.h DEG_depsgraph_build.h DEG_depsgraph_debug.h + DEG_depsgraph_physics.h DEG_depsgraph_query.h intern/builder/deg_builder.h diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h index 202e8ef3cf0..30fefb7d4e4 100644 --- a/source/blender/depsgraph/DEG_depsgraph_build.h +++ b/source/blender/depsgraph/DEG_depsgraph_build.h @@ -153,25 +153,6 @@ void DEG_add_object_cache_relation(struct DepsNodeHandle *handle, struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *handle); void DEG_add_special_eval_flag(struct Depsgraph *graph, struct ID *id, short flag); -/* Utility functions for physics modifiers */ -typedef bool (*DEG_CollobjFilterFunction)(struct Object *obj, struct ModifierData *md); - -void DEG_add_collision_relations(struct DepsNodeHandle *handle, - struct Scene *scene, - struct Object *object, - struct Collection *collection, - unsigned int modifier_type, - DEG_CollobjFilterFunction fn, - bool dupli, - const char *name); -void DEG_add_forcefield_relations(struct DepsNodeHandle *handle, - struct Scene *scene, - struct Object *object, - struct EffectorWeights *eff, - bool add_absorption, - int skip_forcefield, - const char *name); - /* ************************************************ */ #ifdef __cplusplus diff --git a/source/blender/depsgraph/DEG_depsgraph_physics.h b/source/blender/depsgraph/DEG_depsgraph_physics.h new file mode 100644 index 00000000000..fd35a7fb2c0 --- /dev/null +++ b/source/blender/depsgraph/DEG_depsgraph_physics.h @@ -0,0 +1,85 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 Blender Foundation. + * All rights reserved. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/depsgraph/DEG_depsgraph_physics.h + * \ingroup depsgraph + * + * Physics utilities for effectors and collision. + */ + +#ifndef __DEG_DEPSGRAPH_PHYSICS_H__ +#define __DEG_DEPSGRAPH_PHYSICS_H__ + +#include "DEG_depsgraph.h" + +struct Colllection; +struct Depsgraph; +struct DepsNodeHandle; +struct EffectorWeights; +struct ListBase; +struct Object; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum ePhysicsRelationType { + DEG_PHYSICS_EFFECTOR = 0, + DEG_PHYSICS_COLLISION = 1, + DEG_PHYSICS_SMOKE_COLLISION = 2, + DEG_PHYSICS_DYNAMIC_BRUSH = 3, + DEG_PHYSICS_RELATIONS_NUM = 4 +} ePhysicsRelationType; + +/* Get collision/effector relations from collection or entire scene. These + * created during depsgraph relations building and should only be accessed + * during evaluation. */ +struct ListBase *DEG_get_effector_relations(const struct Depsgraph *depsgraph, + struct Collection *collection); +struct ListBase *DEG_get_collision_relations(const struct Depsgraph *depsgraph, + struct Collection *collection, + unsigned int modifier_type); + + +/* Build collision/effector relations for depsgraph. */ +typedef bool (*DEG_CollobjFilterFunction)(struct Object *obj, + struct ModifierData *md); + +void DEG_add_collision_relations(struct DepsNodeHandle *handle, + struct Object *object, + struct Collection *collection, + unsigned int modifier_type, + DEG_CollobjFilterFunction fn, + const char *name); +void DEG_add_forcefield_relations(struct DepsNodeHandle *handle, + struct Object *object, + struct EffectorWeights *eff, + bool add_absorption, + int skip_forcefield, + const char *name); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __DEG_DEPSGRAPH_PHYSICS_H__ */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index 1b2dcd8fcf8..b6256e9ceb0 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -58,7 +58,7 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph) foreach (IDDepsNode *id_node, graph->id_nodes) { ID *id = id_node->id_orig; id_node->finalize_build(graph); - int flag = DEG_TAG_TRANSFORM | DEG_TAG_GEOMETRY; + int flag = 0; if ((id->recalc & ID_RECALC_ALL)) { AnimData *adt = BKE_animdata_from_id(id); if (adt != NULL && (adt->recalc & ADT_RECALC_ANIM) != 0) { @@ -68,7 +68,9 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph) if (!deg_copy_on_write_is_expanded(id_node->id_cow)) { flag |= DEG_TAG_COPY_ON_WRITE; } - DEG_id_tag_update_ex(bmain, id_node->id_orig, flag); + if (flag != 0) { + DEG_id_tag_update_ex(bmain, id_node->id_orig, flag); + } } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index d4a115cfb8b..cfb2f1bc8d6 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -65,6 +65,7 @@ extern "C" { #include "DNA_lightprobe_types.h" #include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" +#include "DNA_speaker_types.h" #include "DNA_texture_types.h" #include "DNA_world_types.h" @@ -431,6 +432,9 @@ void DepsgraphNodeBuilder::build_id(ID *id) { case ID_LT: build_object_data_geometry_datablock(id); break; + case ID_SPK: + build_speaker((Speaker *)id); + break; default: fprintf(stderr, "Unhandled ID %s\n", id->name); BLI_assert(!"Should never happen"); @@ -458,6 +462,15 @@ void DepsgraphNodeBuilder::build_collection( add_id_node(&collection->id); /* Build collection objects. */ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { + if (allow_restrict_flags) { + const int restrict_flag = ( + (graph_->mode == DAG_EVAL_VIEWPORT) ? + OB_RESTRICT_VIEW : + OB_RESTRICT_RENDER); + if (cob->ob->restrictflag & restrict_flag) { + continue; + } + } build_object(-1, cob->ob, DEG_ID_LINKED_INDIRECTLY); } /* Build child collections. */ @@ -530,9 +543,12 @@ void DepsgraphNodeBuilder::build_object(int base_index, build_gpencil(object->gpd); } /* Proxy object to copy from. */ - if (object->proxy_from) { + if (object->proxy_from != NULL) { build_object(-1, object->proxy_from, DEG_ID_LINKED_INDIRECTLY); } + if (object->proxy_group != NULL) { + build_object(-1, object->proxy_group, DEG_ID_LINKED_INDIRECTLY); + } /* Object dupligroup. */ if (object->dup_group != NULL) { build_collection(DEG_COLLECTION_OWNER_OBJECT, object->dup_group); @@ -604,6 +620,9 @@ void DepsgraphNodeBuilder::build_object_data(Object *object) case OB_LIGHTPROBE: build_object_data_lightprobe(object); break; + case OB_SPEAKER: + build_object_data_speaker(object); + break; default: { ID *obdata = (ID *)object->data; @@ -637,6 +656,16 @@ void DepsgraphNodeBuilder::build_object_data_lightprobe(Object *object) DEG_OPCODE_LIGHT_PROBE_EVAL); } +void DepsgraphNodeBuilder::build_object_data_speaker(Object *object) +{ + Speaker *speaker = (Speaker *)object->data; + build_speaker(speaker); + add_operation_node(&object->id, + DEG_NODE_TYPE_PARAMETERS, + NULL, + DEG_OPCODE_SPEAKER_EVAL); +} + void DepsgraphNodeBuilder::build_object_transform(Object *object) { OperationDepsNode *op_node; @@ -1453,6 +1482,19 @@ void DepsgraphNodeBuilder::build_lightprobe(LightProbe *probe) build_animdata(&probe->id); } +void DepsgraphNodeBuilder::build_speaker(Speaker *speaker) +{ + if (built_map_.checkIsBuiltAndTag(speaker)) { + return; + } + /* Placeholder so we can add relations and tag ID node for update. */ + add_operation_node(&speaker->id, + DEG_NODE_TYPE_PARAMETERS, + NULL, + DEG_OPCODE_SPEAKER_EVAL); + build_animdata(&speaker->id); +} + /* **** ID traversal callbacks functions **** */ void DepsgraphNodeBuilder::modifier_walk(void *user_data, diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 72aa5dbe003..487b834bd07 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -62,6 +62,7 @@ struct Probe; struct bPoseChannel; struct bConstraint; struct Scene; +struct Speaker; struct Tex; struct World; @@ -175,6 +176,7 @@ struct DepsgraphNodeBuilder { void build_object_data_geometry_datablock(ID *obdata); void build_object_data_lamp(Object *object); void build_object_data_lightprobe(Object *object); + void build_object_data_speaker(Object *object); void build_object_transform(Object *object); void build_object_constraints(Object *object); void build_pose_constraints(Object *object, bPoseChannel *pchan, int pchan_index); @@ -209,6 +211,7 @@ struct DepsgraphNodeBuilder { void build_mask(Mask *mask); void build_movieclip(MovieClip *clip); void build_lightprobe(LightProbe *probe); + void build_speaker(Speaker *speaker); protected: struct SavedEntryTag { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc index e2526272570..f1db05b7220 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc @@ -105,7 +105,7 @@ void DepsgraphNodeBuilder::build_view_layer( */ int base_index = 0; const int base_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ? - BASE_VISIBLE_VIEWPORT : BASE_VISIBLE_RENDER; + BASE_ENABLED_VIEWPORT : BASE_ENABLED_RENDER; LISTBASE_FOREACH(Base *, base, &view_layer->object_bases) { /* object itself */ if (base->flag & base_flag) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 861f2dff1d6..e39bf8aaa98 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -65,6 +65,7 @@ extern "C" { #include "DNA_object_types.h" #include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" +#include "DNA_speaker_types.h" #include "DNA_texture_types.h" #include "DNA_world_types.h" #include "DNA_object_force_types.h" @@ -297,87 +298,72 @@ DepsRelation *DepsgraphRelationBuilder::add_operation_relation( void DepsgraphRelationBuilder::add_collision_relations( const OperationKey &key, - Scene *scene, Object *object, Collection *collection, - bool dupli, const char *name) { - unsigned int numcollobj; - Object **collobjs = get_collisionobjects_ext(scene, - object, - collection, - &numcollobj, - eModifierType_Collision, - dupli); - for (unsigned int i = 0; i < numcollobj; i++) { - Object *ob1 = collobjs[i]; + ListBase *relations = deg_build_collision_relations(graph_, collection, eModifierType_Collision); - ComponentKey trf_key(&ob1->id, DEG_NODE_TYPE_TRANSFORM); - add_relation(trf_key, key, name); + LISTBASE_FOREACH (CollisionRelation *, relation, relations) { + if (relation->ob != object) { + ComponentKey trf_key(&relation->ob->id, DEG_NODE_TYPE_TRANSFORM); + add_relation(trf_key, key, name); - ComponentKey coll_key(&ob1->id, DEG_NODE_TYPE_GEOMETRY); - add_relation(coll_key, key, name); - } - if (collobjs != NULL) { - MEM_freeN(collobjs); + ComponentKey coll_key(&relation->ob->id, DEG_NODE_TYPE_GEOMETRY); + add_relation(coll_key, key, name); + } } } void DepsgraphRelationBuilder::add_forcefield_relations( const OperationKey &key, - Scene *scene, Object *object, ParticleSystem *psys, EffectorWeights *eff, bool add_absorption, const char *name) { - ListBase *effectors = pdInitEffectors(NULL, scene, object, psys, eff, false); - if (effectors == NULL) { - return; - } - LISTBASE_FOREACH (EffectorCache *, eff, effectors) { - if (eff->ob != object) { - ComponentKey eff_key(&eff->ob->id, DEG_NODE_TYPE_TRANSFORM); + ListBase *relations = deg_build_effector_relations(graph_, eff->group); + + LISTBASE_FOREACH (EffectorRelation *, relation, relations) { + if (relation->ob != object) { + ComponentKey eff_key(&relation->ob->id, DEG_NODE_TYPE_TRANSFORM); add_relation(eff_key, key, name); + + if (relation->pd->forcefield == PFIELD_SMOKEFLOW && relation->pd->f_source) { + ComponentKey trf_key(&relation->pd->f_source->id, + DEG_NODE_TYPE_TRANSFORM); + add_relation(trf_key, key, "Smoke Force Domain"); + ComponentKey eff_key(&relation->pd->f_source->id, + DEG_NODE_TYPE_GEOMETRY); + add_relation(eff_key, key, "Smoke Force Domain"); + } + if (add_absorption && (relation->pd->flag & PFIELD_VISIBILITY)) { + add_collision_relations(key, + object, + NULL, + "Force Absorption"); + } } - if (eff->psys != NULL) { - if (eff->ob != object) { - ComponentKey eff_key(&eff->ob->id, DEG_NODE_TYPE_EVAL_PARTICLES); + if (relation->psys) { + if (relation->ob != object) { + ComponentKey eff_key(&relation->ob->id, DEG_NODE_TYPE_EVAL_PARTICLES); add_relation(eff_key, key, name); /* TODO: remove this when/if EVAL_PARTICLES is sufficient * for up to date particles. */ - ComponentKey mod_key(&eff->ob->id, DEG_NODE_TYPE_GEOMETRY); + ComponentKey mod_key(&relation->ob->id, DEG_NODE_TYPE_GEOMETRY); add_relation(mod_key, key, name); } - else if (eff->psys != psys) { - OperationKey eff_key(&eff->ob->id, + else if (relation->psys != psys) { + OperationKey eff_key(&relation->ob->id, DEG_NODE_TYPE_EVAL_PARTICLES, DEG_OPCODE_PARTICLE_SYSTEM_EVAL, - eff->psys->name); + relation->psys->name); add_relation(eff_key, key, name); } } - if (eff->pd->forcefield == PFIELD_SMOKEFLOW && eff->pd->f_source) { - ComponentKey trf_key(&eff->pd->f_source->id, - DEG_NODE_TYPE_TRANSFORM); - add_relation(trf_key, key, "Smoke Force Domain"); - ComponentKey eff_key(&eff->pd->f_source->id, - DEG_NODE_TYPE_GEOMETRY); - add_relation(eff_key, key, "Smoke Force Domain"); - } - if (add_absorption && (eff->pd->flag & PFIELD_VISIBILITY)) { - add_collision_relations(key, - scene, - object, - NULL, - true, - "Force Absorption"); - } } - pdEndEffectors(&effectors); } Depsgraph *DepsgraphRelationBuilder::getGraph() @@ -442,6 +428,9 @@ void DepsgraphRelationBuilder::build_id(ID *id) case ID_LT: build_object_data_geometry_datablock(id); break; + case ID_SPK: + build_speaker((Speaker *)id); + break; default: fprintf(stderr, "Unhandled ID %s\n", id->name); BLI_assert(!"Should never happen"); @@ -464,11 +453,19 @@ void DepsgraphRelationBuilder::build_collection( } } const bool group_done = built_map_.checkIsBuiltAndTag(collection); - OperationKey object_local_transform_key(object != NULL ? &object->id : NULL, + OperationKey object_transform_final_key(object != NULL ? &object->id : NULL, DEG_NODE_TYPE_TRANSFORM, - DEG_OPCODE_TRANSFORM_LOCAL); + DEG_OPCODE_TRANSFORM_FINAL); if (!group_done) { LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { + if (allow_restrict_flags) { + const int restrict_flag = (graph_->mode == DAG_EVAL_VIEWPORT) + ? OB_RESTRICT_VIEW + : OB_RESTRICT_RENDER; + if (cob->ob->restrictflag & restrict_flag) { + continue; + } + } build_object(NULL, cob->ob); } LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { @@ -479,7 +476,7 @@ void DepsgraphRelationBuilder::build_collection( FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(collection, ob, graph_->mode) { ComponentKey dupli_transform_key(&ob->id, DEG_NODE_TYPE_TRANSFORM); - add_relation(dupli_transform_key, object_local_transform_key, "Dupligroup"); + add_relation(dupli_transform_key, object_transform_final_key, "Dupligroup"); } FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; } @@ -597,7 +594,13 @@ void DepsgraphRelationBuilder::build_object(Base *base, Object *object) ComponentKey proxy_transform_key(&object->id, DEG_NODE_TYPE_TRANSFORM); add_relation(ob_transform_key, proxy_transform_key, "Proxy Transform"); } - + if (object->proxy_group != NULL) { + build_object(NULL, object->proxy_group); + OperationKey proxy_group_ubereval_key(&object->proxy_group->id, + DEG_NODE_TYPE_TRANSFORM, + DEG_OPCODE_TRANSFORM_OBJECT_UBEREVAL); + add_relation(proxy_group_ubereval_key, final_transform_key, "Proxy Group Transform"); + } /* Object dupligroup. */ if (object->dup_group != NULL) { build_collection(DEG_COLLECTION_OWNER_OBJECT, object, object->dup_group); @@ -657,6 +660,9 @@ void DepsgraphRelationBuilder::build_object_data(Object *object) case OB_LIGHTPROBE: build_object_data_lightprobe(object); break; + case OB_SPEAKER: + build_object_data_speaker(object); + break; } Key *key = BKE_key_from_object(object); if (key != NULL) { @@ -698,6 +704,19 @@ void DepsgraphRelationBuilder::build_object_data_lightprobe(Object *object) add_relation(probe_key, object_key, "LightProbe Update"); } +void DepsgraphRelationBuilder::build_object_data_speaker(Object *object) +{ + Speaker *speaker = (Speaker *)object->data; + build_speaker(speaker); + OperationKey probe_key(&speaker->id, + DEG_NODE_TYPE_PARAMETERS, + DEG_OPCODE_SPEAKER_EVAL); + OperationKey object_key(&object->id, + DEG_NODE_TYPE_PARAMETERS, + DEG_OPCODE_SPEAKER_EVAL); + add_relation(probe_key, object_key, "Speaker Update"); +} + void DepsgraphRelationBuilder::build_object_parent(Object *object) { /* XXX: for now, need to use the component key (not just direct to the parent op), @@ -1563,10 +1582,8 @@ void DepsgraphRelationBuilder::build_particles(Object *object) /* Collisions */ if (part->type != PART_HAIR) { add_collision_relations(psys_key, - scene_, object, part->collision_group, - true, "Particle Collision"); } else if ((psys->flag & PSYS_HAIR_DYNAMICS) && @@ -1574,15 +1591,12 @@ void DepsgraphRelationBuilder::build_particles(Object *object) psys->clmd->coll_parms != NULL) { add_collision_relations(psys_key, - scene_, object, psys->clmd->coll_parms->group, - true, "Hair Collision"); } /* Effectors. */ add_forcefield_relations(psys_key, - scene_, object, psys, part->effector_weights, @@ -2119,6 +2133,14 @@ void DepsgraphRelationBuilder::build_lightprobe(LightProbe *probe) build_animdata(&probe->id); } +void DepsgraphRelationBuilder::build_speaker(Speaker *speaker) +{ + if (built_map_.checkIsBuiltAndTag(speaker)) { + return; + } + build_animdata(&speaker->id); +} + void DepsgraphRelationBuilder::build_copy_on_write_relations() { foreach (IDDepsNode *id_node, graph_->id_nodes) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index 3d3a73b6551..9996e420663 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -75,6 +75,7 @@ struct bConstraint; struct ParticleSystem; struct ParticleSettings; struct Scene; +struct Speaker; struct ViewLayer; struct Tex; struct World; @@ -212,6 +213,7 @@ struct DepsgraphRelationBuilder void build_object_data_geometry_datablock(ID *obdata); void build_object_data_lamp(Object *object); void build_object_data_lightprobe(Object *object); + void build_object_data_speaker(Object *object); void build_object_parent(Object *object); void build_constraints(ID *id, eDepsNode_Type component_type, @@ -263,19 +265,17 @@ struct DepsgraphRelationBuilder void build_mask(Mask *mask); void build_movieclip(MovieClip *clip); void build_lightprobe(LightProbe *probe); + void build_speaker(Speaker *speaker); void build_nested_datablock(ID *owner, ID *id); void build_nested_nodetree(ID *owner, bNodeTree *ntree); void build_nested_shapekey(ID *owner, Key *key); void add_collision_relations(const OperationKey &key, - Scene *scene, Object *object, Collection *collection, - bool dupli, const char *name); void add_forcefield_relations(const OperationKey &key, - Scene *scene, Object *object, ParticleSystem *psys, EffectorWeights *eff, diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc index b940fc3035e..f069c63f138 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc @@ -95,7 +95,7 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, ViewLayer *view_la * do NULL-pointer check of the base, so it's fine to pass original one. */ const int base_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ? - BASE_VISIBLE_VIEWPORT : BASE_VISIBLE_RENDER; + BASE_ENABLED_VIEWPORT : BASE_ENABLED_RENDER; LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (base->flag & base_flag) { build_object(base, base->object); diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index 16427d3eb59..ddc6e44ee1b 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -100,6 +100,7 @@ Depsgraph::Depsgraph(Scene *scene, entry_tags = BLI_gset_ptr_new("Depsgraph entry_tags"); debug_flags = G.debug; memset(id_type_updated, 0, sizeof(id_type_updated)); + memset(physics_relations, 0, sizeof(physics_relations)); } Depsgraph::~Depsgraph() @@ -360,6 +361,8 @@ void Depsgraph::clear_id_nodes() /* Clear containers. */ BLI_ghash_clear(id_hash, NULL, NULL); id_nodes.clear(); + /* Clear physics relation caches. */ + deg_clear_physics_relations(this); } /* Add new relationship between two nodes. */ diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h index a69be39c50b..804fd1b36c2 100644 --- a/source/blender/depsgraph/intern/depsgraph.h +++ b/source/blender/depsgraph/intern/depsgraph.h @@ -45,6 +45,7 @@ #include "BLI_threads.h" /* for SpinLock */ #include "DEG_depsgraph.h" +#include "DEG_depsgraph_physics.h" #include "intern/depsgraph_types.h" @@ -226,6 +227,10 @@ struct Depsgraph { /* NITE: Corresponds to G_DEBUG_DEPSGRAPH_* flags. */ int debug_flags; string debug_name; + + /* Cached list of colliders/effectors for collections and the scene + * created along with relations, for fast lookup during evaluation. */ + GHash *physics_relations[DEG_PHYSICS_RELATIONS_NUM]; }; } // namespace DEG diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index c39f6222a13..fccb5808711 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -43,12 +43,8 @@ extern "C" { #include "DNA_cachefile_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_object_force_types.h" #include "BKE_main.h" -#include "BKE_collision.h" -#include "BKE_effect.h" -#include "BKE_modifier.h" #include "BKE_scene.h" } /* extern "C" */ @@ -322,75 +318,3 @@ void DEG_relations_tag_update(Main *bmain) } } } - -void DEG_add_collision_relations(DepsNodeHandle *handle, - Scene *scene, - Object *object, - Collection *collection, - unsigned int modifier_type, - DEG_CollobjFilterFunction fn, - bool dupli, - const char *name) -{ - unsigned int numcollobj; - Object **collobjs = get_collisionobjects_ext(scene, object, collection, &numcollobj, modifier_type, dupli); - - for (unsigned int i = 0; i < numcollobj; i++) { - Object *ob1 = collobjs[i]; - - if (!fn || fn(ob1, modifiers_findByType(ob1, (ModifierType)modifier_type))) { - DEG_add_object_relation(handle, ob1, DEG_OB_COMP_TRANSFORM, name); - DEG_add_object_relation(handle, ob1, DEG_OB_COMP_GEOMETRY, name); - } - } - - if (collobjs) - MEM_freeN(collobjs); -} - -void DEG_add_forcefield_relations(DepsNodeHandle *handle, - Scene *scene, - Object *object, - EffectorWeights *effector_weights, - bool add_absorption, - int skip_forcefield, - const char *name) -{ - ListBase *effectors = pdInitEffectors(NULL, scene, object, NULL, effector_weights, false); - if (effectors == NULL) { - return; - } - for (EffectorCache *eff = (EffectorCache*)effectors->first; eff; eff = eff->next) { - if (eff->ob != object && eff->pd->forcefield != skip_forcefield) { - DEG_add_object_relation(handle, eff->ob, DEG_OB_COMP_TRANSFORM, name); - if (eff->psys) { - DEG_add_object_relation(handle, eff->ob, DEG_OB_COMP_EVAL_PARTICLES, name); - /* TODO: remove this when/if EVAL_PARTICLES is sufficient - * for up to date particles. - */ - DEG_add_object_relation(handle, eff->ob, DEG_OB_COMP_GEOMETRY, name); - } - if (eff->pd->forcefield == PFIELD_SMOKEFLOW && eff->pd->f_source) { - DEG_add_object_relation(handle, - eff->pd->f_source, - DEG_OB_COMP_TRANSFORM, - "Smoke Force Domain"); - DEG_add_object_relation(handle, - eff->pd->f_source, - DEG_OB_COMP_GEOMETRY, - "Smoke Force Domain"); - } - if (add_absorption && (eff->pd->flag & PFIELD_VISIBILITY)) { - DEG_add_collision_relations(handle, - scene, - object, - NULL, - eModifierType_Collision, - NULL, - true, - "Force Absorption"); - } - } - } - pdEndEffectors(&effectors); -} diff --git a/source/blender/depsgraph/intern/depsgraph_intern.h b/source/blender/depsgraph/intern/depsgraph_intern.h index 526cecde457..aa67226c47e 100644 --- a/source/blender/depsgraph/intern/depsgraph_intern.h +++ b/source/blender/depsgraph/intern/depsgraph_intern.h @@ -50,6 +50,7 @@ extern "C" { struct DEGEditorUpdateContext; struct Collection; +struct ListBase; struct Main; struct Scene; @@ -139,4 +140,10 @@ bool deg_terminal_do_color(void); string deg_color_for_pointer(const void *pointer); string deg_color_end(void); +/* Physics Utilities -------------------------------------------------- */ + +struct ListBase *deg_build_effector_relations(Depsgraph *graph, struct Collection *collection); +struct ListBase *deg_build_collision_relations(Depsgraph *graph, struct Collection *collection, unsigned int modifier_type); +void deg_clear_physics_relations(Depsgraph *graph); + } // namespace DEG diff --git a/source/blender/depsgraph/intern/depsgraph_physics.cc b/source/blender/depsgraph/intern/depsgraph_physics.cc new file mode 100644 index 00000000000..e542e0c48ae --- /dev/null +++ b/source/blender/depsgraph/intern/depsgraph_physics.cc @@ -0,0 +1,242 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2018 Blender Foundation. + * All rights reserved. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/depsgraph/intern/depsgraph_physics.cc + * \ingroup depsgraph + * + * Physics utilities for effectors and collision. + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_compiler_compat.h" +#include "BLI_ghash.h" +#include "BLI_listbase.h" + +extern "C" { +#include "BKE_collision.h" +#include "BKE_effect.h" +#include "BKE_modifier.h" +} /* extern "C" */ + +#include "DNA_group_types.h" +#include "DNA_object_types.h" +#include "DNA_object_force_types.h" + +#include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_physics.h" +#include "DEG_depsgraph_query.h" + +#include "depsgraph.h" +#include "depsgraph_intern.h" + +/*********************** Evaluation Query API *************************/ + +static ePhysicsRelationType modifier_to_relation_type(unsigned int modifier_type) +{ + switch (modifier_type) { + case eModifierType_Collision: + return DEG_PHYSICS_COLLISION; + case eModifierType_Smoke: + return DEG_PHYSICS_SMOKE_COLLISION; + case eModifierType_DynamicPaint: + return DEG_PHYSICS_DYNAMIC_BRUSH; + } + + BLI_assert(!"Unknown collision modifier type"); + return DEG_PHYSICS_RELATIONS_NUM; +} + +ListBase *DEG_get_effector_relations(const Depsgraph *graph, + Collection *collection) +{ + const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + if (deg_graph->physics_relations[DEG_PHYSICS_EFFECTOR] == NULL) { + return NULL; + } + + ID *collection_orig = DEG_get_original_id(&collection->id); + return (ListBase *)BLI_ghash_lookup(deg_graph->physics_relations[DEG_PHYSICS_EFFECTOR], collection_orig); +} + +ListBase *DEG_get_collision_relations(const Depsgraph *graph, + Collection *collection, + unsigned int modifier_type) +{ + const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const ePhysicsRelationType type = modifier_to_relation_type(modifier_type); + if (deg_graph->physics_relations[type] == NULL) { + return NULL; + } + + ID *collection_orig = DEG_get_original_id(&collection->id); + return (ListBase *)BLI_ghash_lookup(deg_graph->physics_relations[type], collection_orig); +} + +/********************** Depsgraph Building API ************************/ + +void DEG_add_collision_relations(DepsNodeHandle *handle, + Object *object, + Collection *collection, + unsigned int modifier_type, + DEG_CollobjFilterFunction fn, + const char *name) +{ + Depsgraph *depsgraph = DEG_get_graph_from_handle(handle); + DEG::Depsgraph *deg_graph = (DEG::Depsgraph *)depsgraph; + ListBase *relations = deg_build_collision_relations(deg_graph, collection, modifier_type); + + LISTBASE_FOREACH (CollisionRelation *, relation, relations) { + Object *ob1 = relation->ob; + if (ob1 != object) { + if (!fn || fn(ob1, modifiers_findByType(ob1, (ModifierType)modifier_type))) { + DEG_add_object_relation(handle, ob1, DEG_OB_COMP_TRANSFORM, name); + DEG_add_object_relation(handle, ob1, DEG_OB_COMP_GEOMETRY, name); + } + } + } +} + +void DEG_add_forcefield_relations(DepsNodeHandle *handle, + Object *object, + EffectorWeights *effector_weights, + bool add_absorption, + int skip_forcefield, + const char *name) +{ + Depsgraph *depsgraph = DEG_get_graph_from_handle(handle); + DEG::Depsgraph *deg_graph = (DEG::Depsgraph *)depsgraph; + ListBase *relations = deg_build_effector_relations(deg_graph, effector_weights->group); + + LISTBASE_FOREACH (EffectorRelation *, relation, relations) { + if (relation->ob != object && relation->pd->forcefield != skip_forcefield) { + DEG_add_object_relation(handle, relation->ob, DEG_OB_COMP_TRANSFORM, name); + if (relation->psys) { + DEG_add_object_relation(handle, relation->ob, DEG_OB_COMP_EVAL_PARTICLES, name); + /* TODO: remove this when/if EVAL_PARTICLES is sufficient + * for up to date particles. + */ + DEG_add_object_relation(handle, relation->ob, DEG_OB_COMP_GEOMETRY, name); + } + if (relation->pd->forcefield == PFIELD_SMOKEFLOW && relation->pd->f_source) { + DEG_add_object_relation(handle, + relation->pd->f_source, + DEG_OB_COMP_TRANSFORM, + "Smoke Force Domain"); + DEG_add_object_relation(handle, + relation->pd->f_source, + DEG_OB_COMP_GEOMETRY, + "Smoke Force Domain"); + } + if (add_absorption && (relation->pd->flag & PFIELD_VISIBILITY)) { + DEG_add_collision_relations(handle, + object, + NULL, + eModifierType_Collision, + NULL, + "Force Absorption"); + } + } + } +} + +/**************************** Internal API ****************************/ + +namespace DEG +{ + +ListBase *deg_build_effector_relations(Depsgraph *graph, + Collection *collection) +{ + GHash *hash = graph->physics_relations[DEG_PHYSICS_EFFECTOR]; + if (hash == NULL) { + graph->physics_relations[DEG_PHYSICS_EFFECTOR] = BLI_ghash_ptr_new("Depsgraph physics relations hash"); + hash = graph->physics_relations[DEG_PHYSICS_EFFECTOR]; + } + + ListBase *relations = reinterpret_cast<ListBase*>(BLI_ghash_lookup(hash, collection)); + if (relations == NULL) { + ::Depsgraph *depsgraph = reinterpret_cast<::Depsgraph*>(graph); + relations = BKE_effector_relations_create(depsgraph, graph->view_layer, collection); + BLI_ghash_insert(hash, &collection->id, relations); + } + + return relations; +} + +ListBase *deg_build_collision_relations(Depsgraph *graph, + Collection *collection, + unsigned int modifier_type) +{ + const ePhysicsRelationType type = modifier_to_relation_type(modifier_type); + GHash *hash = graph->physics_relations[type]; + if (hash == NULL) { + graph->physics_relations[type] = BLI_ghash_ptr_new("Depsgraph physics relations hash"); + hash = graph->physics_relations[type]; + } + + ListBase *relations = reinterpret_cast<ListBase*>(BLI_ghash_lookup(hash, collection)); + if (relations == NULL) { + ::Depsgraph *depsgraph = reinterpret_cast<::Depsgraph*>(graph); + relations = BKE_collision_relations_create(depsgraph, collection, modifier_type); + BLI_ghash_insert(hash, &collection->id, relations); + } + + return relations; +} + +static void free_effector_relations(void *value) +{ + BKE_effector_relations_free(reinterpret_cast<ListBase*>(value)); +} + +static void free_collision_relations(void *value) +{ + BKE_collision_relations_free(reinterpret_cast<ListBase*>(value)); +} + +void deg_clear_physics_relations(Depsgraph *graph) +{ + for (int i = 0; i < DEG_PHYSICS_RELATIONS_NUM; i++) { + if (graph->physics_relations[i]) { + ePhysicsRelationType type = (ePhysicsRelationType)i; + + switch (type) { + case DEG_PHYSICS_EFFECTOR: + BLI_ghash_free(graph->physics_relations[i], NULL, free_effector_relations); + break; + case DEG_PHYSICS_COLLISION: + case DEG_PHYSICS_SMOKE_COLLISION: + case DEG_PHYSICS_DYNAMIC_BRUSH: + BLI_ghash_free(graph->physics_relations[i], NULL, free_collision_relations); + break; + case DEG_PHYSICS_RELATIONS_NUM: + break; + } + + graph->physics_relations[i] = NULL; + } + } +} + +} diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index 1dd6f8b6a0b..a9492b48a1b 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -139,7 +139,7 @@ bool deg_objects_dupli_iterator_next(BLI_Iterator *iter) temp_dupli_object->base_flag = dupli_parent->base_flag | BASE_FROMDUPLI; /* Duplicated elements shouldn't care whether their original collection is visible or not. */ - temp_dupli_object->base_flag |= BASE_VISIBLED; + temp_dupli_object->base_flag |= BASE_VISIBLE; if (BKE_object_is_visible(temp_dupli_object, OB_VISIBILITY_CHECK_UNKNOWN_RENDER_MODE) == false) { continue; diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cc b/source/blender/depsgraph/intern/depsgraph_type_defines.cc index 9b1733bae8e..6d7f86581d9 100644 --- a/source/blender/depsgraph/intern/depsgraph_type_defines.cc +++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cc @@ -141,6 +141,7 @@ const char *operationCodeAsString(eDepsOperation_Code opcode) STRINGIFY_OPCODE(GEOMETRY_SHAPEKEY); /* Object data. */ STRINGIFY_OPCODE(LIGHT_PROBE_EVAL); + STRINGIFY_OPCODE(SPEAKER_EVAL); /* Pose. */ STRINGIFY_OPCODE(POSE_INIT); STRINGIFY_OPCODE(POSE_INIT_IK); diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h index c6eb0d57bac..6577e742266 100644 --- a/source/blender/depsgraph/intern/depsgraph_types.h +++ b/source/blender/depsgraph/intern/depsgraph_types.h @@ -211,6 +211,7 @@ typedef enum eDepsOperation_Code { /* Object data. ------------------------------------- */ DEG_OPCODE_LIGHT_PROBE_EVAL, + DEG_OPCODE_SPEAKER_EVAL, /* Pose. -------------------------------------------- */ /* Init pose, clear flags, etc. */ diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index d7c6684f086..d2400b8b651 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -128,16 +128,9 @@ static void eevee_cache_populate(void *vedata, Object *ob) EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); const DRWContextState *draw_ctx = DRW_context_state_get(); - const bool is_active = (ob == draw_ctx->obact); bool cast_shadow = false; - if (is_active) { - if (DRW_object_is_mode_shade(ob) == true) { - return; - } - } - - if (ob->base_flag & BASE_VISIBLED) { + if (ob->base_flag & BASE_VISIBLE) { EEVEE_hair_cache_populate(vedata, sldata, ob, &cast_shadow); } diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index 806fb65b8e8..e083c9b5eb5 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -45,7 +45,7 @@ void EEVEE_lookdev_cache_init( StudioLight *sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_INTERNAL | STUDIOLIGHT_ORIENTATION_WORLD); if ((sl->flag & STUDIOLIGHT_ORIENTATION_WORLD)) { struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); - GPUTexture *tex; + GPUTexture *tex = NULL; *grp = DRW_shgroup_create(shader, pass); axis_angle_to_mat3_single(stl->g_data->studiolight_matrix, 'Z', v3d->shading.studiolight_rot_z); @@ -59,15 +59,18 @@ void EEVEE_lookdev_cache_init( if (!pinfo) { /* Do not fadeout when doing probe rendering, only when drawing the background */ DRW_shgroup_uniform_float(*grp, "studioLightBackground", &v3d->shading.studiolight_background, 1); - - BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_GPUTEXTURE); - tex = sl->equirectangular_irradiance_gputexture; + if (v3d->shading.studiolight_background > 0.0f) { + BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_GPUTEXTURE); + tex = sl->equirectangular_irradiance_gputexture; + } } else { BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE); tex = sl->equirectangular_radiance_gputexture; } - DRW_shgroup_uniform_texture(*grp, "image", tex); + if (tex != NULL) { + DRW_shgroup_uniform_texture(*grp, "image", tex); + } /* Do we need to recalc the lightprobes? */ if (pinfo && diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index 1a5c26f1c31..5cc20adf961 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -1014,7 +1014,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) } { - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CLIP_PLANES | DRW_STATE_WIRE; + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES | DRW_STATE_WIRE; psl->material_pass = DRW_pass_create("Material Shader Pass", state); } diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c index d24551976f9..c650a6945ac 100644 --- a/source/blender/draw/engines/eevee/eevee_render.c +++ b/source/blender/draw/engines/eevee/eevee_render.c @@ -145,7 +145,7 @@ void EEVEE_render_cache( RE_engine_update_stats(engine, NULL, info); bool cast_shadow = false; - if (ob->base_flag & BASE_VISIBLED) { + if (ob->base_flag & BASE_VISIBLE) { EEVEE_hair_cache_populate(vedata, sldata, ob, &cast_shadow); } diff --git a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl index 2ba6e0e8e55..2d913c63b00 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl @@ -4,7 +4,7 @@ struct LightData { }; struct WorldData { - vec3 spherical_harmonics_coefs[9]; + vec3 spherical_harmonics_coefs[STUDIOLIGHT_SPHERICAL_HARMONICS_MAX_COMPONENTS]; vec4 background_color_low; vec4 background_color_high; vec4 object_outline_color; diff --git a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl index 4a1d88c29c1..c72df6b677d 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl @@ -106,7 +106,7 @@ void main() #endif #ifdef V3D_SHADING_SHADOW - float light_factor = -dot(normal_viewport, world_data.light_direction_vs.xyz); + float light_factor = -dot(normal_viewport, world_data.lights[0].light_direction_vs.xyz); /* The step function might be ok for meshes but it's * clearly not the case for hairs. Do smoothstep in this case. */ float shadow_mix = (diffuse_color.a == 1.0 || diffuse_color.a == 0.0) diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl index 4a7d195a56a..1b3737193b0 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl @@ -1,4 +1,4 @@ -#ifdef OB_TEXTURE +#ifdef V3D_SHADING_TEXTURE_COLOR uniform sampler2D image; #endif uniform mat4 ProjectionMatrix; @@ -10,7 +10,7 @@ uniform vec4 viewvecs[3]; #ifdef NORMAL_VIEWPORT_PASS_ENABLED in vec3 normal_viewport; #endif /* NORMAL_VIEWPORT_PASS_ENABLED */ -#ifdef OB_TEXTURE +#ifdef V3D_SHADING_TEXTURE_COLOR in vec2 uv_interp; #endif #ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL @@ -32,12 +32,12 @@ void main() { vec4 diffuse_color; vec3 diffuse_light = vec3(1.0); -#ifdef OB_SOLID - diffuse_color = material_data.diffuse_color; -#endif /* OB_SOLID */ -#ifdef OB_TEXTURE + +#ifdef V3D_SHADING_TEXTURE_COLOR diffuse_color = texture(image, uv_interp); -#endif /* OB_TEXTURE */ +#else + diffuse_color = material_data.diffuse_color; +#endif /* V3D_SHADING_TEXTURE_COLOR */ vec2 uv_viewport = gl_FragCoord.xy * invertedViewportSize; vec3 I_vs = view_vector_from_screen_uv(uv_viewport, viewvecs, ProjectionMatrix); diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl index 200850e3036..6aeb912377c 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl @@ -4,7 +4,7 @@ layout(std140) uniform material_block { MaterialData material_data; }; -#ifdef OB_TEXTURE +#ifdef V3D_SHADING_TEXTURE_COLOR uniform sampler2D image; #endif @@ -12,9 +12,9 @@ uniform sampler2D image; in vec3 normal_viewport; #endif /* NORMAL_VIEWPORT_PASS_ENABLED */ -#ifdef OB_TEXTURE +#ifdef V3D_SHADING_TEXTURE_COLOR in vec2 uv_interp; -#endif /* OB_TEXTURE */ +#endif /* V3D_SHADING_TEXTURE_COLOR */ #ifdef HAIR_SHADER flat in float hair_rand; @@ -40,17 +40,16 @@ void main() n = normalize(n); #endif -#ifdef OB_SOLID +#ifdef V3D_SHADING_TEXTURE_COLOR + diffuseColor = texture(image, uv_interp); +#else diffuseColor = vec4(material_data.diffuse_color.rgb, 0.0); # ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL - specularColor = vec4(material_data.diffuse_color.rgb, 0.0); + # endif -#endif /* OB_SOLID */ +#endif /* V3D_SHADING_TEXTURE_COLOR */ -#ifdef OB_TEXTURE - diffuseColor = texture(image, uv_interp); -#endif /* OB_TEXTURE */ #ifdef HAIR_SHADER float hair_color_variation = hair_rand * 0.1; diffuseColor.rgb = clamp(diffuseColor.rgb - hair_color_variation, 0.0, 1.0); diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl index 82443e7336b..66b529fcf5e 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl @@ -9,7 +9,7 @@ in vec3 pos; in vec3 nor; in vec2 uv; #else /* HAIR_SHADER */ -# ifdef OB_TEXTURE +# ifdef V3D_SHADING_TEXTURE_COLOR uniform samplerBuffer u; /* active texture layer */ # endif flat out float hair_rand; @@ -19,7 +19,7 @@ flat out float hair_rand; out vec3 normal_viewport; #endif -#ifdef OB_TEXTURE +#ifdef V3D_SHADING_TEXTURE_COLOR out vec2 uv_interp; #endif @@ -34,7 +34,7 @@ float integer_noise(int n) void main() { #ifdef HAIR_SHADER -# ifdef OB_TEXTURE +# ifdef V3D_SHADING_TEXTURE_COLOR vec2 uv = hair_get_customdata_vec2(u); # endif float time, thick_time, thickness; @@ -55,7 +55,7 @@ void main() #else gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); #endif -#ifdef OB_TEXTURE +#ifdef V3D_SHADING_TEXTURE_COLOR uv_interp = uv; #endif diff --git a/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl index 71adc751f0a..b13c4f1b43b 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl @@ -1,32 +1,36 @@ #define BLINN -vec3 spherical_harmonics_L2(vec3 N, vec3 spherical_harmonics_coefs[9]) +vec3 spherical_harmonics(vec3 N, vec3 spherical_harmonics_coefs[STUDIOLIGHT_SPHERICAL_HARMONICS_MAX_COMPONENTS]) { vec3 sh = vec3(0.0); sh += 0.282095 * spherical_harmonics_coefs[0]; +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL > 0 sh += -0.488603 * N.z * spherical_harmonics_coefs[1]; sh += 0.488603 * N.y * spherical_harmonics_coefs[2]; sh += -0.488603 * N.x * spherical_harmonics_coefs[3]; +#endif +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL > 1 sh += 1.092548 * N.x * N.z * spherical_harmonics_coefs[4]; sh += -1.092548 * N.z * N.y * spherical_harmonics_coefs[5]; sh += 0.315392 * (3.0 * N.y * N.y - 1.0) * spherical_harmonics_coefs[6]; sh += -1.092548 * N.x * N.y * spherical_harmonics_coefs[7]; sh += 0.546274 * (N.x * N.x - N.z * N.z) * spherical_harmonics_coefs[8]; +#endif return sh; } vec3 get_world_diffuse_light(WorldData world_data, vec3 N) { - return (spherical_harmonics_L2(vec3(N.x, N.y, -N.z), world_data.spherical_harmonics_coefs)); + return (spherical_harmonics(vec3(N.x, N.y, -N.z), world_data.spherical_harmonics_coefs)); } vec3 get_camera_diffuse_light(WorldData world_data, vec3 N) { - return (spherical_harmonics_L2(vec3(N.x, -N.z, -N.y), world_data.spherical_harmonics_coefs)); + return (spherical_harmonics(vec3(N.x, -N.z, -N.y), world_data.spherical_harmonics_coefs)); } /* N And I are in View Space. */ diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index b4a2330f173..d544e7614ab 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -15,7 +15,6 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) View3D *v3d = draw_ctx->v3d; if (v3d) { wpd->shading = v3d->shading; - wpd->drawtype = v3d->drawtype; if (wpd->shading.light == V3D_LIGHTING_MATCAP) { wpd->studio_light = BKE_studiolight_find( wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL); @@ -30,7 +29,6 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) wpd->shading.light = V3D_LIGHTING_STUDIO; wpd->shading.shadow_intensity = 0.5; copy_v3_fl(wpd->shading.single_color, 0.8f); - wpd->drawtype = OB_SOLID; wpd->studio_light = BKE_studiolight_find_first(STUDIOLIGHT_INTERNAL); } wpd->shadow_multiplier = 1.0 - wpd->shading.shadow_intensity; @@ -155,8 +153,7 @@ void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, floa copy_v3_v3(light_direction, scene->display.light_direction); negate_v3(light_direction); - - DRW_uniformbuffer_update(wpd->world_ubo, &wpd->world_data); + DRW_uniformbuffer_update(wpd->world_ubo, wd); } static void workbench_private_material_free(void *data) diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 3bf7c34d5eb..4fe3e92f10c 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -49,7 +49,7 @@ /* *********** STATIC *********** */ -// #define DEBUG_SHADOW_VOLUME +/* #define DEBUG_SHADOW_VOLUME */ #ifdef DEBUG_SHADOW_VOLUME # include "draw_debug.h" @@ -76,7 +76,6 @@ static struct { struct GPUTexture *effect_buffer_tx; /* ref only, not alloced */ SceneDisplay display; /* world light direction for shadows */ - float light_direction_vs[3]; int next_object_id; float normal_world_matrix[3][3]; @@ -176,17 +175,17 @@ static char *workbench_build_cavity_frag(void) return str; } -static void ensure_deferred_shaders(WORKBENCH_PrivateData *wpd, int index, int drawtype, bool is_hair) +static void ensure_deferred_shaders(WORKBENCH_PrivateData *wpd, int index, bool use_textures, bool is_hair) { if (e_data.prepass_sh_cache[index] == NULL) { - char *defines = workbench_material_build_defines(wpd, drawtype, is_hair); + char *defines = workbench_material_build_defines(wpd, use_textures, is_hair); char *composite_frag = workbench_build_composite_frag(wpd); char *prepass_vert = workbench_build_prepass_vert(); char *prepass_frag = workbench_build_prepass_frag(); e_data.prepass_sh_cache[index] = DRW_shader_create( prepass_vert, NULL, prepass_frag, defines); - if (drawtype == OB_SOLID && !is_hair) { + if (!use_textures && !is_hair) { e_data.composite_sh_cache[index] = DRW_shader_create_fullscreen(composite_frag, defines); } MEM_freeN(prepass_vert); @@ -198,15 +197,15 @@ static void ensure_deferred_shaders(WORKBENCH_PrivateData *wpd, int index, int d static void select_deferred_shaders(WORKBENCH_PrivateData *wpd) { - int index_solid = workbench_material_get_shader_index(wpd, OB_SOLID, false); - int index_solid_hair = workbench_material_get_shader_index(wpd, OB_SOLID, true); - int index_texture = workbench_material_get_shader_index(wpd, OB_TEXTURE, false); - int index_texture_hair = workbench_material_get_shader_index(wpd, OB_TEXTURE, true); + int index_solid = workbench_material_get_shader_index(wpd, false, false); + int index_solid_hair = workbench_material_get_shader_index(wpd, false, true); + int index_texture = workbench_material_get_shader_index(wpd, true, false); + int index_texture_hair = workbench_material_get_shader_index(wpd, true, true); - ensure_deferred_shaders(wpd, index_solid, OB_SOLID, false); - ensure_deferred_shaders(wpd, index_solid_hair, OB_SOLID, true); - ensure_deferred_shaders(wpd, index_texture, OB_TEXTURE, false); - ensure_deferred_shaders(wpd, index_texture_hair, OB_TEXTURE, true); + ensure_deferred_shaders(wpd, index_solid, false, false); + ensure_deferred_shaders(wpd, index_solid_hair, false, true); + ensure_deferred_shaders(wpd, index_texture, true, false); + ensure_deferred_shaders(wpd, index_texture_hair, true, true); wpd->prepass_solid_sh = e_data.prepass_sh_cache[index_solid]; wpd->prepass_solid_hair_sh = e_data.prepass_sh_cache[index_solid_hair]; @@ -485,8 +484,6 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata) WORKBENCH_PrivateData *wpd = stl->g_data; DRWShadingGroup *grp; const DRWContextState *draw_ctx = DRW_context_state_get(); - static float light_multiplier = 1.0f; - Scene *scene = draw_ctx->scene; @@ -494,9 +491,9 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata) /* Deferred Mix Pass */ { workbench_private_data_get_light_direction(wpd, e_data.display.light_direction); + studiolight_update_light(wpd, e_data.display.light_direction); e_data.display.shadow_shift = scene->display.shadow_shift; - copy_v3_v3(e_data.light_direction_vs, wpd->world_data.lights[0].light_direction_vs); if (SHADOW_ENABLED(wpd)) { psl->composite_pass = DRW_pass_create( @@ -504,7 +501,7 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata) grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_pass); workbench_composite_uniforms(wpd, grp); DRW_shgroup_stencil_mask(grp, 0x00); - DRW_shgroup_uniform_float(grp, "lightMultiplier", &light_multiplier, 1); + DRW_shgroup_uniform_float_copy(grp, "lightMultiplier", 1.0f); DRW_shgroup_uniform_float(grp, "shadowMultiplier", &wpd->shadow_multiplier, 1); DRW_shgroup_uniform_float(grp, "shadowShift", &scene->display.shadow_shift, 1); DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL); @@ -548,7 +545,6 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata) DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL); #endif - studiolight_update_light(wpd, e_data.display.light_direction); } else { psl->composite_pass = DRW_pass_create( @@ -561,7 +557,7 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata) } static WORKBENCH_MaterialData *get_or_create_material_data( - WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, int drawtype) + WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, int color_type) { WORKBENCH_StorageList *stl = vedata->stl; WORKBENCH_PassList *psl = vedata->psl; @@ -574,7 +570,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data( /* Solid */ workbench_material_update_data(wpd, ob, mat, &material_template); material_template.object_id = OBJECT_ID_PASS_ENABLED(wpd) ? engine_object_data->object_id : 1; - material_template.drawtype = drawtype; + material_template.color_type = color_type; material_template.ima = ima; uint hash = workbench_material_get_hash(&material_template); @@ -582,22 +578,15 @@ static WORKBENCH_MaterialData *get_or_create_material_data( if (material == NULL) { material = MEM_mallocN(sizeof(WORKBENCH_MaterialData), __func__); material->shgrp = DRW_shgroup_create( - drawtype == OB_SOLID ? wpd->prepass_solid_sh : wpd->prepass_texture_sh, psl->prepass_pass); + color_type == V3D_SHADING_TEXTURE_COLOR ? wpd->prepass_texture_sh: wpd->prepass_solid_sh, psl->prepass_pass); DRW_shgroup_stencil_mask(material->shgrp, 0xFF); material->object_id = material_template.object_id; copy_v4_v4(material->material_data.diffuse_color, material_template.material_data.diffuse_color); copy_v4_v4(material->material_data.specular_color, material_template.material_data.specular_color); material->material_data.roughness = material_template.material_data.roughness; - switch (drawtype) { - case OB_SOLID: - break; - - case OB_TEXTURE: - { - GPUTexture *tex = GPU_texture_from_blender(ima, NULL, GL_TEXTURE_2D, false, 0.0); - DRW_shgroup_uniform_texture(material->shgrp, "image", tex); - break; - } + if (color_type == V3D_SHADING_TEXTURE_COLOR) { + GPUTexture *tex = GPU_texture_from_blender(ima, NULL, GL_TEXTURE_2D, false, 0.0); + DRW_shgroup_uniform_texture(material->shgrp, "image", tex); } DRW_shgroup_uniform_int(material->shgrp, "object_id", &material->object_id, 1); material->material_ubo = DRW_uniformbuffer_create(sizeof(WORKBENCH_UBO_Material), &material->material_data); @@ -634,19 +623,11 @@ static void workbench_cache_populate_particles(WORKBENCH_Data *vedata, Object *o if (draw_as == PART_DRAW_PATH) { Image *image = NULL; Material *mat = give_current_material(ob, part->omat); - int mat_drawtype = OB_SOLID; + ED_object_get_active_image(ob, part->omat, &image, NULL, NULL, NULL); + int color_type = workbench_material_determine_color_type(wpd, image); + WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, mat, image, color_type); - if (wpd->drawtype == OB_TEXTURE) { - ED_object_get_active_image(ob, part->omat, &image, NULL, NULL, NULL); - /* use OB_SOLID when no texture could be determined */ - if (image) { - mat_drawtype = OB_TEXTURE; - } - } - - WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, mat, image, mat_drawtype); - - struct GPUShader *shader = (mat_drawtype == OB_SOLID) + struct GPUShader *shader = (color_type != V3D_SHADING_TEXTURE_COLOR) ? wpd->prepass_solid_hair_sh : wpd->prepass_texture_hair_sh; DRWShadingGroup *shgrp = DRW_shgroup_hair_create( @@ -686,7 +667,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) const bool is_active = (ob == draw_ctx->obact); const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0; bool is_drawn = false; - if (!is_sculpt_mode && wpd->drawtype == OB_TEXTURE && ELEM(ob->type, OB_MESH)) { + if (!is_sculpt_mode && TEXTURE_DRAWING_ENABLED(wpd) && ELEM(ob->type, OB_MESH)) { const Mesh *me = ob->data; if (me->mloopuv) { const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol)); @@ -701,12 +682,8 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) Material *mat = give_current_material(ob, i + 1); Image *image; ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL); - /* use OB_SOLID when no texture could be determined */ - int mat_drawtype = OB_SOLID; - if (image) { - mat_drawtype = OB_TEXTURE; - } - material = get_or_create_material_data(vedata, ob, mat, image, mat_drawtype); + int color_type = workbench_material_determine_color_type(wpd, image); + material = get_or_create_material_data(vedata, ob, mat, image, color_type); DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob); } is_drawn = true; @@ -716,11 +693,11 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) /* Fallback from not drawn OB_TEXTURE mode or just OB_SOLID mode */ if (!is_drawn) { - if ((wpd->shading.color_type != V3D_SHADING_MATERIAL_COLOR)) { + if (ELEM(wpd->shading.color_type, V3D_SHADING_SINGLE_COLOR, V3D_SHADING_RANDOM_COLOR)) { /* No material split needed */ struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); if (geom) { - material = get_or_create_material_data(vedata, ob, NULL, NULL, OB_SOLID); + material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type); if (is_sculpt_mode) { DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat); } @@ -745,7 +722,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) } Material *mat = give_current_material(ob, i + 1); - material = get_or_create_material_data(vedata, ob, mat, NULL, OB_SOLID); + material = get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR); if (is_sculpt_mode) { DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat); } diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index db07f9bb6f5..9f23cd5b43b 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -144,7 +144,7 @@ static void workbench_init_object_data(ObjectEngineData *engine_data) } static WORKBENCH_MaterialData *get_or_create_material_data( - WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, int drawtype) + WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, int color_type) { WORKBENCH_StorageList *stl = vedata->stl; WORKBENCH_PassList *psl = vedata->psl; @@ -158,7 +158,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data( /* Solid */ workbench_material_update_data(wpd, ob, mat, &material_template); material_template.object_id = OBJECT_ID_PASS_ENABLED(wpd) ? engine_object_data->object_id : 1; - material_template.drawtype = drawtype; + material_template.color_type = color_type; material_template.ima = ima; uint hash = workbench_material_get_hash(&material_template); @@ -168,7 +168,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data( /* transparent accum */ grp = DRW_shgroup_create( - drawtype == OB_SOLID ? wpd->transparent_accum_sh : wpd->transparent_accum_texture_sh, + color_type == V3D_SHADING_TEXTURE_COLOR ? wpd->transparent_accum_texture_sh: wpd->transparent_accum_sh, psl->transparent_accum_pass); DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo); DRW_shgroup_uniform_float(grp, "alpha", &wpd->shading.xray_alpha, 1); @@ -178,26 +178,19 @@ static WORKBENCH_MaterialData *get_or_create_material_data( copy_v4_v4(material->material_data.diffuse_color, material_template.material_data.diffuse_color); copy_v4_v4(material->material_data.specular_color, material_template.material_data.specular_color); material->material_data.roughness = material_template.material_data.roughness; - switch (drawtype) { - case OB_SOLID: - { - if (STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)) { - BKE_studiolight_ensure_flag(wpd->studio_light, STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE); - DRW_shgroup_uniform_texture(grp, "matcapImage", wpd->studio_light->equirectangular_radiance_gputexture); - } - if (SPECULAR_HIGHLIGHT_ENABLED(wpd) || MATCAP_ENABLED(wpd)) { - DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1); - } - break; - } - case OB_TEXTURE: - { - GPUTexture *tex = GPU_texture_from_blender(ima, NULL, GL_TEXTURE_2D, false, 0.0f); - DRW_shgroup_uniform_texture(grp, "image", tex); - break; - } + if (color_type == V3D_SHADING_TEXTURE_COLOR) { + GPUTexture *tex = GPU_texture_from_blender(ima, NULL, GL_TEXTURE_2D, false, 0.0f); + DRW_shgroup_uniform_texture(grp, "image", tex); } + if (STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)) { + BKE_studiolight_ensure_flag(wpd->studio_light, STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE); + DRW_shgroup_uniform_texture(grp, "matcapImage", wpd->studio_light->equirectangular_radiance_gputexture); + } + if (SPECULAR_HIGHLIGHT_ENABLED(wpd) || MATCAP_ENABLED(wpd)) { + DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1); + } + material->material_ubo = DRW_uniformbuffer_create(sizeof(WORKBENCH_UBO_Material), &material->material_data); DRW_shgroup_uniform_block(grp, "material_block", material->material_ubo); material->shgrp = grp; @@ -211,10 +204,10 @@ static WORKBENCH_MaterialData *get_or_create_material_data( return material; } -static void ensure_forward_shaders(WORKBENCH_PrivateData *wpd, int index, int drawtype, bool is_hair) +static void ensure_forward_shaders(WORKBENCH_PrivateData *wpd, int index, bool use_textures, bool is_hair) { - if (e_data.composite_sh_cache[index] == NULL && drawtype == OB_SOLID && !is_hair) { - char *defines = workbench_material_build_defines(wpd, drawtype, is_hair); + if (e_data.composite_sh_cache[index] == NULL && !use_textures && !is_hair) { + char *defines = workbench_material_build_defines(wpd, use_textures, is_hair); char *composite_frag = workbench_build_forward_composite_frag(); e_data.composite_sh_cache[index] = DRW_shader_create_fullscreen(composite_frag, defines); MEM_freeN(composite_frag); @@ -222,7 +215,7 @@ static void ensure_forward_shaders(WORKBENCH_PrivateData *wpd, int index, int dr } if (e_data.transparent_accum_sh_cache[index] == NULL) { - char *defines = workbench_material_build_defines(wpd, drawtype, is_hair); + char *defines = workbench_material_build_defines(wpd, use_textures, is_hair); char *transparent_accum_vert = workbench_build_forward_vert(); char *transparent_accum_frag = workbench_build_forward_transparent_accum_frag(); e_data.transparent_accum_sh_cache[index] = DRW_shader_create( @@ -236,15 +229,15 @@ static void ensure_forward_shaders(WORKBENCH_PrivateData *wpd, int index, int dr static void select_forward_shaders(WORKBENCH_PrivateData *wpd) { - int index_solid = workbench_material_get_shader_index(wpd, OB_SOLID, false); - int index_solid_hair = workbench_material_get_shader_index(wpd, OB_SOLID, true); - int index_texture = workbench_material_get_shader_index(wpd, OB_TEXTURE, false); - int index_texture_hair = workbench_material_get_shader_index(wpd, OB_TEXTURE, true); + int index_solid = workbench_material_get_shader_index(wpd, false, false); + int index_solid_hair = workbench_material_get_shader_index(wpd, false, true); + int index_texture = workbench_material_get_shader_index(wpd, true, false); + int index_texture_hair = workbench_material_get_shader_index(wpd, true, true); - ensure_forward_shaders(wpd, index_solid, OB_SOLID, false); - ensure_forward_shaders(wpd, index_solid_hair, OB_SOLID, true); - ensure_forward_shaders(wpd, index_texture, OB_TEXTURE, false); - ensure_forward_shaders(wpd, index_texture_hair, OB_TEXTURE, true); + ensure_forward_shaders(wpd, index_solid, false, false); + ensure_forward_shaders(wpd, index_solid_hair, false, true); + ensure_forward_shaders(wpd, index_texture, true, false); + ensure_forward_shaders(wpd, index_texture_hair, true, true); wpd->composite_sh = e_data.composite_sh_cache[index_solid]; wpd->transparent_accum_sh = e_data.transparent_accum_sh_cache[index_solid]; @@ -340,7 +333,9 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) psl->composite_pass = DRW_pass_create("Composite", state); grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_pass); - DRW_shgroup_uniform_texture_ref(grp, "objectId", &e_data.object_id_tx); + if (OBJECT_ID_PASS_ENABLED(wpd)) { + DRW_shgroup_uniform_texture_ref(grp, "objectId", &e_data.object_id_tx); + } DRW_shgroup_uniform_texture_ref(grp, "transparentAccum", &e_data.transparent_accum_tx); DRW_shgroup_uniform_texture_ref(grp, "transparentRevealage", &e_data.transparent_revealage_tx); DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo); @@ -399,19 +394,11 @@ static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, O if (draw_as == PART_DRAW_PATH) { Image *image = NULL; Material *mat = give_current_material(ob, part->omat); - int mat_drawtype = OB_SOLID; + ED_object_get_active_image(ob, part->omat, &image, NULL, NULL, NULL); + int color_type = workbench_material_determine_color_type(wpd, image); + WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, mat, image, color_type); - if (wpd->drawtype == OB_TEXTURE) { - ED_object_get_active_image(ob, part->omat, &image, NULL, NULL, NULL); - /* use OB_SOLID when no texture could be determined */ - if (image) { - mat_drawtype = OB_TEXTURE; - } - } - - WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, mat, image, mat_drawtype); - - struct GPUShader *shader = (mat_drawtype == OB_SOLID) + struct GPUShader *shader = (color_type != V3D_SHADING_TEXTURE_COLOR) ? wpd->transparent_accum_hair_sh : wpd->transparent_accum_texture_hair_sh; DRWShadingGroup *shgrp = DRW_shgroup_hair_create( @@ -461,14 +448,14 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) return; } + WORKBENCH_MaterialData *material; if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) { const DRWContextState *draw_ctx = DRW_context_state_get(); const bool is_active = (ob == draw_ctx->obact); const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0; bool is_drawn = false; - WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, NULL, NULL, OB_SOLID); - if (!is_sculpt_mode && wpd->drawtype == OB_TEXTURE && ELEM(ob->type, OB_MESH)) { + if (!is_sculpt_mode && TEXTURE_DRAWING_ENABLED(wpd) && ELEM(ob->type, OB_MESH)) { const Mesh *me = ob->data; if (me->mloopuv) { const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol)); @@ -484,11 +471,16 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) Image *image; ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL); /* use OB_SOLID when no texture could be determined */ - int mat_drawtype = OB_SOLID; - if (image) { - mat_drawtype = OB_TEXTURE; + + int color_type = wpd->shading.color_type; + if (color_type == V3D_SHADING_TEXTURE_COLOR) { + /* use OB_SOLID when no texture could be determined */ + if (image == NULL) { + color_type = V3D_SHADING_MATERIAL_COLOR; + } } - material = get_or_create_material_data(vedata, ob, mat, image, mat_drawtype); + + material = get_or_create_material_data(vedata, ob, mat, image, color_type); DRW_shgroup_call_object_add(material->shgrp_object_outline, geom_array[i], ob); DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob); } @@ -499,10 +491,11 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) /* Fallback from not drawn OB_TEXTURE mode or just OB_SOLID mode */ if (!is_drawn) { - if ((wpd->shading.color_type != V3D_SHADING_MATERIAL_COLOR)) { + if (ELEM(wpd->shading.color_type, V3D_SHADING_SINGLE_COLOR, V3D_SHADING_RANDOM_COLOR)) { /* No material split needed */ struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); if (geom) { + material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type); if (is_sculpt_mode) { DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat); DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat); @@ -529,7 +522,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) } Material *mat = give_current_material(ob, i + 1); - material = get_or_create_material_data(vedata, ob, mat, NULL, OB_SOLID); + material = get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR); if (is_sculpt_mode) { DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat); DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat); diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index 231d9a9582a..76599fdce99 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -9,15 +9,15 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Material *mat, WORKBENCH_MaterialData *data) { - /* When in OB_TEXTURE always uyse V3D_SHADING_MATERIAL_COLOR as fallback when no texture could be determined */ - int color_type = wpd->drawtype == OB_SOLID ? wpd->shading.color_type : V3D_SHADING_MATERIAL_COLOR; + /* When V3D_SHADING_TEXTURE_COLOR is active, use V3D_SHADING_MATERIAL_COLOR as fallback when no texture could be determined */ + int color_type = wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR ? V3D_SHADING_MATERIAL_COLOR : wpd->shading.color_type; static float default_diffuse_color[] = {0.8f, 0.8f, 0.8f, 1.0f}; static float default_specular_color[] = {0.5f, 0.5f, 0.5f, 0.5f}; copy_v4_v4(data->material_data.diffuse_color, default_diffuse_color); copy_v4_v4(data->material_data.specular_color, default_specular_color); data->material_data.roughness = 0.5f; - if (DRW_object_is_paint_mode(ob) || color_type == V3D_SHADING_SINGLE_COLOR) { + if (color_type == V3D_SHADING_SINGLE_COLOR) { copy_v3_v3(data->material_data.diffuse_color, wpd->shading.single_color); } else if (color_type == V3D_SHADING_RANDOM_COLOR) { @@ -40,7 +40,7 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Mate } } -char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, int drawtype, bool is_hair) +char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair) { char *str = NULL; @@ -79,15 +79,9 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, int drawtype, if (NORMAL_VIEWPORT_PASS_ENABLED(wpd)) { BLI_dynstr_appendf(ds, "#define NORMAL_VIEWPORT_PASS_ENABLED\n"); } - switch (drawtype) { - case OB_SOLID: - BLI_dynstr_appendf(ds, "#define OB_SOLID\n"); - break; - case OB_TEXTURE: - BLI_dynstr_appendf(ds, "#define OB_TEXTURE\n"); - break; + if (use_textures) { + BLI_dynstr_appendf(ds, "#define V3D_SHADING_TEXTURE_COLOR\n"); } - if (NORMAL_ENCODING_ENABLED()) { BLI_dynstr_appendf(ds, "#define WORKBENCH_ENCODE_NORMALS\n"); } @@ -95,6 +89,17 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, int drawtype, BLI_dynstr_appendf(ds, "#define HAIR_SHADER\n"); } +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL == 0 + BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL 0\n"); +#endif +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL == 1 + BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL 1\n"); +#endif +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL == 2 + BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL 2\n"); +#endif + BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_SPHERICAL_HARMONICS_MAX_COMPONENTS 9\n"); + str = BLI_dynstr_get_cstring(ds); BLI_dynstr_free(ds); return str; @@ -118,19 +123,19 @@ uint workbench_material_get_hash(WORKBENCH_MaterialData *material_template) input[3] = (uint)(material_template->material_data.roughness * 512); result += BLI_ghashutil_uinthash_v4_murmur(input); - if (material_template->drawtype == OB_TEXTURE) { + if (material_template->color_type == V3D_SHADING_TEXTURE_COLOR) { /* add texture reference */ result += BLI_ghashutil_inthash_p_murmur(material_template->ima); } return result; } -int workbench_material_get_shader_index(WORKBENCH_PrivateData *wpd, int drawtype, bool is_hair) +int workbench_material_get_shader_index(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair) { /* NOTE: change MAX_SHADERS accordingly when modifying this function. */ int index = 0; - /* 1 bit OB_SOLID and OB_TEXTURE */ - SET_FLAG_FROM_TEST(index, drawtype == OB_TEXTURE, 1 << 0); + /* 1 bit V3D_SHADING_TEXTURE_COLOR */ + SET_FLAG_FROM_TEST(index, use_textures, 1 << 0); /* 2 bits FLAT/STUDIO/MATCAP/SCENE */ SET_FLAG_FROM_TEST(index, wpd->shading.light, wpd->shading.light << 1); /* 1 bit V3D_SHADING_SPECULAR_HIGHLIGHT */ @@ -160,3 +165,12 @@ void workbench_material_set_normal_world_matrix( DRW_shgroup_uniform_mat3(grp, "normalWorldMatrix", persistent_matrix); } } + +int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *ima) +{ + int color_type = wpd->shading.color_type; + if (color_type == V3D_SHADING_TEXTURE_COLOR && ima == NULL) { + color_type = V3D_SHADING_MATERIAL_COLOR; + } + return color_type; +} diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 9e43a5c4a48..57cfd6b4718 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -41,11 +41,10 @@ #define M_GOLDEN_RATION_CONJUGATE 0.618033988749895 #define MAX_SHADERS (1 << 10) -#define OB_SOLID_ENABLED(wpd) (wpd->drawtype & OB_SOLID) -#define OB_TEXTURE_ENABLED(wpd) (wpd->drawtype & OB_TEXTURE) +#define TEXTURE_DRAWING_ENABLED(wpd) (wpd->color_type & V3D_SHADING_TEXTURE_COLOR) #define FLAT_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_FLAT) #define STUDIOLIGHT_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_STUDIO) -#define MATCAP_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_MATCAP && OB_SOLID_ENABLED(wpd)) +#define MATCAP_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_MATCAP) #define STUDIOLIGHT_ORIENTATION_WORLD_ENABLED(wpd) (STUDIOLIGHT_ENABLED(wpd) && (wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_WORLD)) #define STUDIOLIGHT_ORIENTATION_CAMERA_ENABLED(wpd) (STUDIOLIGHT_ENABLED(wpd) && (wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_CAMERA)) #define STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd) (MATCAP_ENABLED(wpd) && (wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_VIEWNORMAL)) @@ -57,6 +56,8 @@ #define NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) (MATCAP_ENABLED(wpd) || STUDIOLIGHT_ENABLED(wpd) || SHADOW_ENABLED(wpd) || SPECULAR_HIGHLIGHT_ENABLED(wpd)) #define NORMAL_VIEWPORT_PASS_ENABLED(wpd) (NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) || CAVITY_ENABLED(wpd)) #define NORMAL_ENCODING_ENABLED() (true) +#define TEXTURE_DRAWING_ENABLED(wpd) (wpd->color_type & V3D_SHADING_TEXTURE_COLOR) + typedef struct WORKBENCH_FramebufferList { /* Deferred render buffers */ @@ -112,7 +113,7 @@ typedef struct WORKBENCH_UBO_Light { } WORKBENCH_UBO_Light; typedef struct WORKBENCH_UBO_World { - float spherical_harmonics_coefs[9][4]; + float spherical_harmonics_coefs[STUDIOLIGHT_SPHERICAL_HARMONICS_MAX_COMPONENTS][4]; float background_color_low[4]; float background_color_high[4]; float object_outline_color[4]; @@ -147,7 +148,7 @@ typedef struct WORKBENCH_PrivateData { View3DShading shading; StudioLight *studio_light; UserDef *user_preferences; - int drawtype; + int color_type; struct GPUUniformBuffer *world_ubo; struct DRWShadingGroup *shadow_shgrp; struct DRWShadingGroup *depth_shgrp; @@ -176,7 +177,7 @@ typedef struct WORKBENCH_MaterialData { struct GPUUniformBuffer *material_ubo; int object_id; - int drawtype; + int color_type; Image *ima; /* Linked shgroup for drawing */ @@ -228,10 +229,11 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob); void workbench_forward_cache_finish(WORKBENCH_Data *vedata); /* workbench_materials.c */ -char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, int drawtype, bool is_hair); +int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *ima); +char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair); void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Material *mat, WORKBENCH_MaterialData *data); uint workbench_material_get_hash(WORKBENCH_MaterialData *material_template); -int workbench_material_get_shader_index(WORKBENCH_PrivateData *wpd, int drawtype, bool is_hair); +int workbench_material_get_shader_index(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair); void workbench_material_set_normal_world_matrix( DRWShadingGroup *grp, WORKBENCH_PrivateData *wpd, float persistent_matrix[3][3]); diff --git a/source/blender/draw/engines/workbench/workbench_studiolight.c b/source/blender/draw/engines/workbench/workbench_studiolight.c index e5e24cbb88a..f9e5df91388 100644 --- a/source/blender/draw/engines/workbench/workbench_studiolight.c +++ b/source/blender/draw/engines/workbench/workbench_studiolight.c @@ -34,10 +34,15 @@ void studiolight_update_world(StudioLight *sl, WORKBENCH_UBO_World *wd) { + int i; BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED); - for (int i = 0; i < 9; i++) { + + for (i = 0; i < STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS; i++) { copy_v3_v3(wd->spherical_harmonics_coefs[i], sl->spherical_harmonics_coefs[i]); } + for (; i < STUDIOLIGHT_SPHERICAL_HARMONICS_MAX_COMPONENTS; i++) { + copy_v3_fl(wd->spherical_harmonics_coefs[i], 0.0); + } } static void compute_parallel_lines_nor_and_dist(const float v1[2], const float v2[2], const float v3[2], float r_line[2]) @@ -121,6 +126,7 @@ static BoundBox *studiolight_object_shadow_bbox_get(WORKBENCH_PrivateData *wpd, for (int i = 0; i < 8; ++i) { mul_m4_v3(wpd->shadow_mat, oed->shadow_bbox.vec[i]); } + oed->shadow_bbox_dirty = false; } return &oed->shadow_bbox; diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index f79a2405c3f..d6187e32036 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -475,8 +475,6 @@ void DRW_lamp_engine_data_free(struct LampEngineData *led); bool DRW_object_is_renderable(struct Object *ob); bool DRW_check_object_visible_within_active_context(struct Object *ob); bool DRW_object_is_flat_normal(const struct Object *ob); -int DRW_object_is_mode_shade(const struct Object *ob); -int DRW_object_is_paint_mode(const struct Object *ob); bool DRW_check_psys_visible_within_active_context(struct Object *object, struct ParticleSystem *psys); diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index d1e05b525ef..28693b47c89 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -289,12 +289,12 @@ static void particle_calculate_parent_uvs( } ParticleData *particle = &psys->particles[parent_index]; int num = particle->num_dmcache; - if (num == DMCACHE_NOTFOUND) { + if (num == DMCACHE_NOTFOUND || num == DMCACHE_ISCHILD) { if (particle->num < psmd->mesh_final->totface) { num = particle->num; } } - if (num != DMCACHE_NOTFOUND) { + if (num != DMCACHE_NOTFOUND && num != DMCACHE_ISCHILD) { MFace *mface = &psmd->mesh_final->mface[num]; for (int j = 0; j < num_uv_layers; j++) { psys_interpolate_uvs( @@ -323,12 +323,12 @@ static void particle_calculate_parent_mcol( } ParticleData *particle = &psys->particles[parent_index]; int num = particle->num_dmcache; - if (num == DMCACHE_NOTFOUND) { + if (num == DMCACHE_NOTFOUND || num == DMCACHE_ISCHILD) { if (particle->num < psmd->mesh_final->totface) { num = particle->num; } } - if (num != DMCACHE_NOTFOUND) { + if (num != DMCACHE_NOTFOUND && num != DMCACHE_ISCHILD) { MFace *mface = &psmd->mesh_final->mface[num]; for (int j = 0; j < num_uv_layers; j++) { psys_interpolate_mcol( diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index fcdc4a3a016..bbbdcd31d9e 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -187,39 +187,6 @@ bool DRW_object_is_flat_normal(const Object *ob) return true; } -/** - * Return true if the object has its own draw mode. - * Caller must check this is active */ -int DRW_object_is_mode_shade(const Object *ob) -{ - BLI_assert(ob == DST.draw_ctx.obact); - UNUSED_VARS_NDEBUG(ob); - if ((DST.draw_ctx.object_mode & OB_MODE_EDIT) == 0) { - if ((DST.draw_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) > 0) { - if (ELEM(DST.draw_ctx.v3d->drawtype, OB_MATERIAL, OB_RENDER)) { - return false; - } - else if ((DST.draw_ctx.v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE) == 0) { - return true; - } - else { - return false; - } - } - } - return -1; -} - -int DRW_object_is_paint_mode(const Object *ob) -{ - if (ob == DST.draw_ctx.obact) { - if ((DST.draw_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) > 0) { - return true; - } - } - return false; -} - bool DRW_check_psys_visible_within_active_context( Object *object, struct ParticleSystem *psys) @@ -1024,7 +991,6 @@ static void drw_engines_enable_from_engine(RenderEngineType *engine_type, int dr break; case OB_SOLID: - case OB_TEXTURE: if (shading_flags & V3D_SHADING_XRAY) { use_drw_engine(&draw_engine_workbench_transparent); } @@ -1467,7 +1433,7 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) Render *render = engine->re; if (G.background && DST.gl_context == NULL) { - WM_init_opengl(); + WM_init_opengl(G_MAIN); } void *re_gl_context = RE_gl_context_get(render); @@ -1729,7 +1695,7 @@ void DRW_draw_select_loop( DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_DUPLI) { - if ((ob->base_flag & BASE_SELECTABLED) != 0) { + if ((ob->base_flag & BASE_SELECTABLE) != 0) { if (object_filter_fn != NULL) { if (ob->base_flag & BASE_FROMDUPLI) { diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 423b07cdb97..887a1cb7721 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -178,6 +178,7 @@ typedef struct OBJECT_PrivateData { DRWShadingGroup *lamp_distance; DRWShadingGroup *lamp_buflimit; DRWShadingGroup *lamp_buflimit_points; + DRWShadingGroup *lamp_area_sphere; DRWShadingGroup *lamp_area_square; DRWShadingGroup *lamp_area_disk; DRWShadingGroup *lamp_hemi; @@ -1199,6 +1200,9 @@ static void OBJECT_cache_init(void *vedata) stl->g_data->lamp_groundline = shgroup_groundlines_uniform_color(psl->non_meshes, ts.colorLamp); stl->g_data->lamp_groundpoint = shgroup_groundpoints_uniform_color(psl->non_meshes, ts.colorLamp); + geom = DRW_cache_screenspace_circle_get(); + stl->g_data->lamp_area_sphere = shgroup_instance_screen_aligned(psl->non_meshes, geom); + geom = DRW_cache_lamp_area_square_get(); stl->g_data->lamp_area_square = shgroup_instance(psl->non_meshes, geom); @@ -1450,6 +1454,15 @@ static void DRW_shgroup_lamp(OBJECT_StorageList *stl, Object *ob, ViewLayer *vie } } + if (ELEM(la->type, LA_LOCAL, LA_SPOT)) { + /* We only want position not scale. */ + shapemat[0][0] = shapemat[1][1] = shapemat[2][2] = 1.0f; + shapemat[0][1] = shapemat[0][2] = 0.0f; + shapemat[1][0] = shapemat[1][2] = 0.0f; + shapemat[2][0] = shapemat[2][1] = 0.0f; + DRW_shgroup_call_dynamic_add(stl->g_data->lamp_area_sphere, color, &la->area_size, shapemat); + } + /* Line and point going to the ground */ DRW_shgroup_call_dynamic_add(stl->g_data->lamp_groundline, ob->obmat[3]); DRW_shgroup_call_dynamic_add(stl->g_data->lamp_groundpoint, ob->obmat[3]); diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c index bd8a1c71a6a..85cff28b313 100644 --- a/source/blender/draw/modes/paint_texture_mode.c +++ b/source/blender/draw/modes/paint_texture_mode.c @@ -194,8 +194,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata) { /* Create a pass */ - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | - DRW_STATE_MULTIPLY | DRW_STATE_WIRE; + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND; psl->image_faces = DRW_pass_create("Image Color Pass", state); stl->g_data->shgroup_fallback = DRW_shgroup_create(e_data.fallback_sh, psl->image_faces); @@ -227,6 +226,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata) if (tex) { DRWShadingGroup *grp = DRW_shgroup_create(e_data.image_sh, psl->image_faces); DRW_shgroup_uniform_texture(grp, "image", tex); + DRW_shgroup_uniform_float(grp, "alpha", &draw_ctx->v3d->overlay.texture_paint_mode_opacity, 1); stl->g_data->shgroup_image_array[i] = grp; } else { @@ -242,6 +242,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata) if (tex) { DRWShadingGroup *grp = DRW_shgroup_create(e_data.image_sh, psl->image_faces); DRW_shgroup_uniform_texture(grp, "image", tex); + DRW_shgroup_uniform_float(grp, "alpha", &draw_ctx->v3d->overlay.texture_paint_mode_opacity, 1); stl->g_data->shgroup_image_array[0] = grp; } else { @@ -285,7 +286,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob) /* Get geometry cache */ const Mesh *me = ob->data; Scene *scene = draw_ctx->scene; - const bool use_surface = DRW_object_is_mode_shade(ob) == true; + const bool use_surface = draw_ctx->v3d->overlay.texture_paint_mode_opacity != 0.0; //DRW_object_is_mode_shade(ob) == true; const bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL); bool ok = false; diff --git a/source/blender/draw/modes/paint_vertex_mode.c b/source/blender/draw/modes/paint_vertex_mode.c index d335e0a4d70..9cf6ea52d33 100644 --- a/source/blender/draw/modes/paint_vertex_mode.c +++ b/source/blender/draw/modes/paint_vertex_mode.c @@ -101,6 +101,8 @@ static void PAINT_VERTEX_cache_init(void *vedata) { PAINT_VERTEX_PassList *psl = ((PAINT_VERTEX_Data *)vedata)->psl; PAINT_VERTEX_StorageList *stl = ((PAINT_VERTEX_Data *)vedata)->stl; + const DRWContextState *draw_ctx = DRW_context_state_get(); + const View3D *v3d = draw_ctx->v3d; if (!stl->g_data) { /* Alloc transient pointers */ @@ -111,9 +113,10 @@ static void PAINT_VERTEX_cache_init(void *vedata) /* Create a pass */ psl->vcolor_faces = DRW_pass_create( "Vert Color Pass", - DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_MULTIPLY); + DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND); stl->g_data->fvcolor_shgrp = DRW_shgroup_create(e_data.vcolor_face_shader, psl->vcolor_faces); + DRW_shgroup_uniform_float(stl->g_data->fvcolor_shgrp, "alpha", &v3d->overlay.vertex_paint_mode_opacity, 1); } { @@ -145,7 +148,7 @@ static void PAINT_VERTEX_cache_populate(void *vedata, Object *ob) if ((ob->type == OB_MESH) && (ob == draw_ctx->obact)) { const Mesh *me = ob->data; const bool use_wire = (v3d->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0; - const bool use_surface = DRW_object_is_mode_shade(ob) == true; + const bool use_surface = v3d->overlay.vertex_paint_mode_opacity != 0.0f; const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; struct Gwn_Batch *geom; diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c index 13ef42d8622..2b510a9a4c9 100644 --- a/source/blender/draw/modes/paint_weight_mode.c +++ b/source/blender/draw/modes/paint_weight_mode.c @@ -123,6 +123,8 @@ static void PAINT_WEIGHT_cache_init(void *vedata) { PAINT_WEIGHT_PassList *psl = ((PAINT_WEIGHT_Data *)vedata)->psl; PAINT_WEIGHT_StorageList *stl = ((PAINT_WEIGHT_Data *)vedata)->stl; + const DRWContextState *draw_ctx = DRW_context_state_get(); + const View3D *v3d = draw_ctx->v3d; if (!stl->g_data) { /* Alloc transient pointers */ @@ -133,15 +135,14 @@ static void PAINT_WEIGHT_cache_init(void *vedata) /* Create a pass */ psl->weight_faces = DRW_pass_create( "Weight Pass", - DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_MULTIPLY); + DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND); stl->g_data->fweights_shgrp = DRW_shgroup_create(e_data.weight_face_shader, psl->weight_faces); static float light[3] = {-0.3f, 0.5f, 1.0f}; - static float alpha = 1.0f; static float world_light = 1.0f; DRW_shgroup_uniform_vec3(stl->g_data->fweights_shgrp, "light", light, 1); - DRW_shgroup_uniform_float(stl->g_data->fweights_shgrp, "alpha", &alpha, 1); + DRW_shgroup_uniform_float(stl->g_data->fweights_shgrp, "alpha", &v3d->overlay.weight_paint_mode_opacity, 1); DRW_shgroup_uniform_float(stl->g_data->fweights_shgrp, "global", &world_light, 1); } @@ -182,7 +183,7 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob) if ((ob->type == OB_MESH) && (ob == draw_ctx->obact)) { const Mesh *me = ob->data; const bool use_wire = (v3d->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0; - const bool use_surface = DRW_object_is_mode_shade(ob) == true; + const bool use_surface = v3d->overlay.weight_paint_mode_opacity != 0.0f; const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; struct Gwn_Batch *geom; diff --git a/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl b/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl index 00ababc624d..5dfbb4352e4 100644 --- a/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl +++ b/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl @@ -7,7 +7,7 @@ flat in vec3 ssVec2; in float facing; #ifdef LIGHT_EDGES -in float edgeSharpness; +flat in vec3 edgeSharpness; #endif out vec4 fragColor; diff --git a/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl b/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl index 6e833a4e16b..eb69af92435 100644 --- a/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl +++ b/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl @@ -20,7 +20,7 @@ in vec3 obPos[]; in vec3 vNor[]; in float forceEdge[]; -out float edgeSharpness; +flat out vec3 edgeSharpness; #endif #define NO_EDGE vec3(10000.0); @@ -33,6 +33,14 @@ vec3 compute_vec(vec2 v0, vec2 v1) return vec3(v, -dot(v, v0)); } +vec3 get_edge_normal(vec3 n1, vec3 n2, vec3 edge) +{ + edge = normalize(edge); + vec3 n = n1 + n2; + float p = dot(edge, n); + return normalize(n - p * edge); +} + float get_edge_sharpness(vec3 fnor, vec3 vnor) { float sharpness = abs(dot(fnor, vnor)); @@ -50,27 +58,27 @@ void main(void) ssVec2 = do_edge.z ? compute_vec(ssPos[2], ssPos[0]) : NO_EDGE; #ifdef LIGHT_EDGES - vec3 fnor = normalize(cross(obPos[1] - obPos[0], obPos[2] - obPos[0])); - - edgeSharpness = get_edge_sharpness(fnor, vNor[0]); - edgeSharpness = (forceEdge[0] == 1.0 || forceEdge[2] == 1.0) ? 1.0 : edgeSharpness; + vec3 edges[3]; + edges[0] = obPos[1] - obPos[0]; + edges[1] = obPos[2] - obPos[1]; + edges[2] = obPos[0] - obPos[2]; + vec3 fnor = normalize(cross(edges[0], -edges[2])); + + edgeSharpness.x = get_edge_sharpness(fnor, get_edge_normal(vNor[0], vNor[1], edges[0])); + edgeSharpness.y = get_edge_sharpness(fnor, get_edge_normal(vNor[1], vNor[2], edges[1])); + edgeSharpness.z = get_edge_sharpness(fnor, get_edge_normal(vNor[2], vNor[0], edges[2])); + edgeSharpness.x = (forceEdge[0] == 1.0) ? 1.0 : edgeSharpness.x; + edgeSharpness.y = (forceEdge[1] == 1.0) ? 1.0 : edgeSharpness.y; + edgeSharpness.z = (forceEdge[2] == 1.0) ? 1.0 : edgeSharpness.z; #endif gl_Position = gl_in[0].gl_Position; facing = facings.x; EmitVertex(); -#ifdef LIGHT_EDGES - edgeSharpness = get_edge_sharpness(fnor, vNor[1]); - edgeSharpness = (forceEdge[1] == 1.0 || forceEdge[0] == 1.0) ? 1.0 : edgeSharpness; -#endif gl_Position = gl_in[1].gl_Position; facing = facings.y; EmitVertex(); -#ifdef LIGHT_EDGES - edgeSharpness = get_edge_sharpness(fnor, vNor[2]); - edgeSharpness = (forceEdge[2] == 1.0 || forceEdge[1] == 1.0) ? 1.0 : edgeSharpness; -#endif gl_Position = gl_in[2].gl_Position; facing = facings.z; EmitVertex(); diff --git a/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl b/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl index 616cd5379e9..fe3c2021b7e 100644 --- a/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl +++ b/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl @@ -27,7 +27,7 @@ out vec3 obPos; out vec3 vNor; out float forceEdge; #else -out float edgeSharpness; +flat out vec3 edgeSharpness; #endif #endif @@ -80,6 +80,14 @@ vec3 get_vertex_pos(uint id) return pos; } +vec3 get_edge_normal(vec3 n1, vec3 n2, vec3 edge) +{ + edge = normalize(edge); + vec3 n = n1 + n2; + float p = dot(edge, n); + return normalize(n - p * edge); +} + float get_edge_sharpness(vec3 fnor, vec3 vnor) { float sharpness = abs(dot(fnor, vnor)); @@ -152,24 +160,30 @@ void main() gl_Position = p_pos[v_n]; +# ifndef LIGHT_EDGES vec3 nor = get_vertex_nor(v_id[v_n]); - facing = normalize(NormalMatrix * nor).z; - -# ifdef LIGHT_EDGES - vec3 fnor = normalize(cross(pos[1] - pos[0], pos[2] - pos[0])); - edgeSharpness = get_edge_sharpness(fnor, nor); - - /* Fix disapearing edges. */ - if (v_n == 0) { - force_edge.xy = force_edge.xz; - } - else if (v_n == 2) { - force_edge.xy = force_edge.yz; - } - if (any(force_edge.xy)) { - edgeSharpness = 1.0; - } +# else + vec3 edges[3]; + edges[0] = pos[1] - pos[0]; + edges[1] = pos[2] - pos[1]; + edges[2] = pos[0] - pos[2]; + vec3 fnor = normalize(cross(edges[0], -edges[2])); + + vec3 nors[3]; + nors[0] = get_vertex_nor(v_id.x); + nors[1] = get_vertex_nor(v_id.y); + nors[2] = get_vertex_nor(v_id.z); + edgeSharpness.x = get_edge_sharpness(fnor, get_edge_normal(nors[0], nors[1], edges[0])); + edgeSharpness.y = get_edge_sharpness(fnor, get_edge_normal(nors[1], nors[2], edges[1])); + edgeSharpness.z = get_edge_sharpness(fnor, get_edge_normal(nors[2], nors[0], edges[2])); + edgeSharpness.x = force_edge.x ? 1.0 : edgeSharpness.x; + edgeSharpness.y = force_edge.y ? 1.0 : edgeSharpness.y; + edgeSharpness.z = force_edge.z ? 1.0 : edgeSharpness.z; + + vec3 nor = nors[v_n]; # endif + facing = normalize(NormalMatrix * nor).z; + #endif } diff --git a/source/blender/draw/modes/shaders/paint_texture_frag.glsl b/source/blender/draw/modes/shaders/paint_texture_frag.glsl index 18c58a54dca..4305e20ce7b 100644 --- a/source/blender/draw/modes/shaders/paint_texture_frag.glsl +++ b/source/blender/draw/modes/shaders/paint_texture_frag.glsl @@ -3,9 +3,9 @@ in vec2 uv_interp; out vec4 fragColor; uniform sampler2D image; - +uniform float alpha = 1.0; void main() { - fragColor = texture(image, uv_interp); + fragColor = vec4(texture(image, uv_interp).rgb, alpha); } diff --git a/source/blender/draw/modes/shaders/paint_vertex_frag.glsl b/source/blender/draw/modes/shaders/paint_vertex_frag.glsl index 5a00fec9c43..2c968dafa69 100644 --- a/source/blender/draw/modes/shaders/paint_vertex_frag.glsl +++ b/source/blender/draw/modes/shaders/paint_vertex_frag.glsl @@ -2,7 +2,7 @@ in vec3 finalColor; out vec4 fragColor; - +uniform float alpha = 1.0; vec3 linear_to_srgb_attrib(vec3 c) { c = max(c, vec3(0.0)); vec3 c1 = c * 12.92; @@ -13,5 +13,5 @@ vec3 linear_to_srgb_attrib(vec3 c) { void main() { fragColor.rgb = linear_to_srgb_attrib(finalColor); - fragColor.a = 1.0; + fragColor.a = alpha; } diff --git a/source/blender/draw/modes/shaders/paint_wire_frag.glsl b/source/blender/draw/modes/shaders/paint_wire_frag.glsl index e4214a4c6d1..b6637fea308 100644 --- a/source/blender/draw/modes/shaders/paint_wire_frag.glsl +++ b/source/blender/draw/modes/shaders/paint_wire_frag.glsl @@ -18,7 +18,5 @@ void main() const vec4 colSel = vec4(1.0, 1.0, 1.0, 1.0); #endif - const vec4 colUnsel = vec4(0.5, 0.5, 0.5, 1.0); - - fragColor = bool(finalFlag & VERTEX_SELECTED) ? colSel : colUnsel; + fragColor = bool(finalFlag & VERTEX_SELECTED) ? colSel : colorWire; } diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index ebe977420c6..ed4c574537b 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -2300,18 +2300,9 @@ static int animchannels_find_exec(bContext *C, wmOperator *op) if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - /* update filter text, and ensure that filter is enabled if there's something there - * NOTE: we turn the filter off if there's nothing (this is a quick shortcut for dismissing) - */ + /* update filter text */ RNA_string_get(op->ptr, "query", ac.ads->searchstr); - if (ac.ads->searchstr[0]) { - ac.ads->filterflag |= ADS_FILTER_BY_FCU_NAME; - } - else { - ac.ads->filterflag &= ~ADS_FILTER_BY_FCU_NAME; - } - /* redraw */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -2693,7 +2684,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, AnimData *adt = ob->adt; /* set selection status */ - if (base->flag & BASE_SELECTABLED) { + if (base->flag & BASE_SELECTABLE) { if (selectmode == SELECT_INVERT) { /* swap select */ ED_object_base_select(base, BA_INVERT); diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 8892fed025a..c59d24bbdf8 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -245,6 +245,18 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction) /* update scene-pointer (no need to check for pinning yet, as not implemented) */ saction->ads.source = (ID *)ac->scene; + /* sync scene's "selected keys only" flag with our "only selected" flag + * XXX: This is a workaround for T55525. We shouldn't really be syncing the flags like this, + * but it's a simpler fix for now than also figuring out how the next/prev keyframe tools + * should work in the 3D View if we allowed full access to the timeline's dopesheet filters + * (i.e. we'd have to figure out where to host those settings, to be on a scene level like + * this flag currently is, along with several other unknowns) + */ + if (ac->scene->flag & SCE_KEYS_NO_SELONLY) + saction->ads.filterflag &= ~ADS_FILTER_ONLYSEL; + else + saction->ads.filterflag |= ADS_FILTER_ONLYSEL; + ac->datatype = ANIMCONT_TIMELINE; ac->data = &saction->ads; @@ -1209,7 +1221,7 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, eAnim_Chan /* only include if this curve is active */ if (!(filter_mode & ANIMFILTER_ACTIVE) || (fcu->flag & FCURVE_ACTIVE)) { /* name based filtering... */ - if ( ((ads) && (ads->filterflag & ADS_FILTER_BY_FCU_NAME)) && (owner_id) ) { + if ( ((ads) && (ads->searchstr[0] != '\0')) && (owner_id) ) { if (skip_fcurve_with_name(ads, fcu, channel_type, owner, owner_id)) continue; } @@ -1441,7 +1453,7 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop /* only include if this track is active */ if (!(filter_mode & ANIMFILTER_ACTIVE) || (nlt->flag & NLATRACK_ACTIVE)) { /* name based filtering... */ - if (((ads) && (ads->filterflag & ADS_FILTER_BY_FCU_NAME)) && (owner_id)) { + if (((ads) && (ads->searchstr[0] != '\0')) && (owner_id)) { bool track_ok = false, strip_ok = false; /* check if the name of the track, or the strips it has are ok... */ @@ -1621,7 +1633,7 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data, bDopeShee /* active... */ if (!(filter_mode & ANIMFILTER_ACTIVE) || (gpl->flag & GP_LAYER_ACTIVE)) { /* skip layer if the name doesn't match the filter string */ - if ((ads) && (ads->filterflag & ADS_FILTER_BY_FCU_NAME)) { + if ((ads) && (ads->searchstr[0] != '\0')) { if (name_matches_dopesheet_filter(ads, gpl->info) == false) continue; } @@ -1713,7 +1725,7 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, voi */ if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) { /* layer visibility - we check both object and base, since these may not be in sync yet */ - if ((base->flag & BASE_VISIBLED) == 0) continue; + if ((base->flag & BASE_VISIBLE) == 0) continue; /* outliner restrict-flag */ if (ob->restrictflag & OB_RESTRICT_VIEW) continue; @@ -1729,7 +1741,7 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, voi * objects by the grouped status is on * - used to ease the process of doing multiple-character choreographies */ - if (ads->filterflag & ADS_FILTER_ONLYOBGROUP) { + if (ads->filter_grp != NULL) { if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0) continue; } @@ -2852,7 +2864,7 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m */ if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) { /* layer visibility - we check both object and base, since these may not be in sync yet */ - if ((base->flag & BASE_VISIBLED) == 0) + if ((base->flag & BASE_VISIBLE) == 0) return false; /* outliner restrict-flag */ @@ -2896,7 +2908,7 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m * objects by the grouped status is on * - used to ease the process of doing multiple-character choreographies */ - if (ads->filterflag & ADS_FILTER_ONLYOBGROUP) { + if (ads->filter_grp != NULL) { if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0) return false; } diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt index 98b57fcbd71..640239ccc60 100644 --- a/source/blender/editors/datafiles/CMakeLists.txt +++ b/source/blender/editors/datafiles/CMakeLists.txt @@ -202,6 +202,10 @@ set(ICON_NAMES group_uvs rna rna_add + mouse_lmb + mouse_mmb + mouse_rmb + mouse_drag outliner_ob_empty outliner_ob_mesh outliner_ob_curve diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 943191c8892..fee336ea768 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -690,6 +690,7 @@ void ANIM_list_elem_update(struct Main *bmain, struct Scene *scene, bAnimListEle void ANIM_sync_animchannels_to_data(const struct bContext *C); void ANIM_center_frame(struct bContext *C, int smooth_viewtx); + /* ************************************************* */ /* OPERATORS */ @@ -716,6 +717,10 @@ void ED_animedit_unlink_action(struct bContext *C, struct ID *id, struct AnimData *adt, struct bAction *act, struct ReportList *reports, bool force_delete); + +/* Drivers Editor - Utility to set up UI correctly */ +void ED_drivers_editor_init(struct bContext *C, struct ScrArea *sa); + /* ************************************************ */ #endif /* __ED_ANIM_API_H__ */ diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index a9c9e8c0fbd..32504db6498 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -225,14 +225,9 @@ typedef struct MirrTopoStore_t { } MirrTopoStore_t; bool ED_mesh_mirrtopo_recalc_check( - struct Mesh *me, struct DerivedMesh *dm, MirrTopoStore_t *mesh_topo_store); -bool ED_mesh_mirrtopo_recalc_check__real_mesh( - struct Mesh *me, struct Mesh *dm, MirrTopoStore_t *mesh_topo_store); + struct Mesh *me, struct Mesh *me_eval, MirrTopoStore_t *mesh_topo_store); void ED_mesh_mirrtopo_init( - struct Mesh *me, struct DerivedMesh *dm, MirrTopoStore_t *mesh_topo_store, - const bool skip_em_vert_array_init); -void ED_mesh_mirrtopo_init__real_mesh( - struct Mesh *me, struct Mesh *dm, MirrTopoStore_t *mesh_topo_store, + struct Mesh *me, struct Mesh *me_eval, MirrTopoStore_t *mesh_topo_store, const bool skip_em_vert_array_init); void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store); @@ -322,22 +317,17 @@ int join_mesh_shapes_exec(struct bContext *C, struct wmOperator *op); /* mirror lookup api */ int ED_mesh_mirror_spatial_table( - struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm, const float co[3], char mode); -int ED_mesh_mirror_spatial_table__real_mesh( - struct Object *ob, struct BMEditMesh *em, struct Mesh *mesh, const float co[3], char mode); -int ED_mesh_mirror_topo_table(struct Object *ob, struct DerivedMesh *dm, char mode); -int ED_mesh_mirror_topo_table__real_mesh(struct Object *ob, struct Mesh *mesh, char mode); + struct Object *ob, struct BMEditMesh *em, struct Mesh *me_eval, const float co[3], char mode); +int ED_mesh_mirror_topo_table(struct Object *ob, struct Mesh *me_eval, char mode); /* retrieves mirrored cache vert, or NULL if there isn't one. * note: calling this without ensuring the mirror cache state * is bad.*/ -int mesh_get_x_mirror_vert(struct Object *ob, struct DerivedMesh *dm, int index, const bool use_topology); -int mesh_get_x_mirror_vert__real_mesh(struct Object *ob, struct Mesh *mesh, int index, const bool use_topology); +int mesh_get_x_mirror_vert(struct Object *ob, struct Mesh *me_eval, int index, const bool use_topology); struct BMVert *editbmesh_get_x_mirror_vert(struct Object *ob, struct BMEditMesh *em, struct BMVert *eve, const float co[3], int index, const bool use_topology); -int *mesh_get_x_mirror_faces(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm); -int *mesh_get_x_mirror_faces__real_mesh(struct Object *ob, struct BMEditMesh *em, struct Mesh *mesh); +int *mesh_get_x_mirror_faces(struct Object *ob, struct BMEditMesh *em, struct Mesh *me_eval); int ED_mesh_mirror_get_vert(struct Object *ob, int index); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index d8a31e93a87..29f7edaebf0 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -40,6 +40,7 @@ struct Base; struct EnumPropertyItem; struct ID; struct Main; +struct Menu; struct ModifierData; struct Object; struct ReportList; @@ -58,12 +59,14 @@ struct PointerRNA; struct PropertyRNA; struct EnumPropertyItem; struct Depsgraph; +struct uiLayout; #include "DNA_object_enums.h" /* object_edit.c */ struct Object *ED_object_context(struct bContext *C); /* context.object */ struct Object *ED_object_active_context(struct bContext *C); /* context.object or context.active_object */ +void ED_hide_collections_menu_draw(const struct bContext *C, struct uiLayout *layout); /* object_ops.c */ void ED_operatortypes_object(void); diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 9fcefc1e4b1..cb4048ac63e 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -60,6 +60,8 @@ struct Main; struct wmMsgBus; struct wmMsgSubscribeKey; struct wmMsgSubscribeValue; +struct wmOperatorType; +struct IDProperty; /* regions */ void ED_region_do_listen( @@ -311,6 +313,21 @@ int ED_operator_posemode_local(struct bContext *C); int ED_operator_mask(struct bContext *C); int ED_operator_camera(struct bContext *C); +/* screen_user_menu.c */ + +struct bUserMenu *ED_screen_user_menu_find(struct bContext *C); +struct bUserMenu *ED_screen_user_menu_ensure(struct bContext *C); + + +struct bUserMenuItem_Op *ED_screen_user_menu_item_find_operator( + struct ListBase *lb, + struct wmOperatorType *ot, struct IDProperty *prop, short opcontext); +void ED_screen_user_menu_item_add_operator( + struct ListBase *lb, const char *ui_name, + struct wmOperatorType *ot, struct IDProperty *prop, short opcontext); +void ED_screen_user_menu_item_remove( + struct ListBase *lb, struct bUserMenuItem *umi); +void ED_screen_user_menu_register(void); /* Cache display helpers */ @@ -333,4 +350,3 @@ void ED_area_type_hud_ensure(struct bContext *C, struct ScrArea *sa); #define ED_KEYMAP_HEADER 64 #endif /* __ED_SCREEN_H__ */ - diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 343bffa0082..68aeccdcc32 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -98,11 +98,28 @@ typedef struct ViewDepths { bool damaged; } ViewDepths; + +/* Rotate 3D cursor on placement. */ +enum eV3DCursorOrient { + V3D_CURSOR_ORIENT_NONE = 0, + V3D_CURSOR_ORIENT_VIEW, + V3D_CURSOR_ORIENT_GEOM, +}; + struct View3DCursor *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d); -void ED_view3d_cursor3d_calc_mat3(const struct Scene *scene, const struct View3D *v3d, float mat[3][3]); -void ED_view3d_cursor3d_calc_mat4(const struct Scene *scene, const struct View3D *v3d, float mat[4][4]); -void ED_view3d_cursor3d_position(struct bContext *C, float fp[3], const int mval[2]); -void ED_view3d_cursor3d_update(struct bContext *C, const int mval[2]); +void ED_view3d_cursor3d_calc_mat3(const struct Scene *scene, const struct View3D *v3d, float mat[3][3]); +void ED_view3d_cursor3d_calc_mat4(const struct Scene *scene, const struct View3D *v3d, float mat[4][4]); +void ED_view3d_cursor3d_position( + struct bContext *C, const int mval[2], + const bool use_depth, + float cursor_co[3]); +void ED_view3d_cursor3d_position_rotation( + struct bContext *C, const int mval[2], + const bool use_depth, enum eV3DCursorOrient orientation, + float cursor_co[3], float cursor_quat[4]); +void ED_view3d_cursor3d_update( + struct bContext *C, const int mval[2], + bool use_depth, enum eV3DCursorOrient orientation); struct Camera *ED_view3d_camera_data_get(struct View3D *v3d, struct RegionView3D *rv3d); diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 659f6c97696..75e835ff1d3 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -273,10 +273,14 @@ DEF_ICON(RNA_ADD) DEF_ICON(BLANK093) DEF_ICON(BLANK094) DEF_ICON(BLANK095) - DEF_ICON(BLANK096) - DEF_ICON(BLANK097) - DEF_ICON(BLANK098) - DEF_ICON(BLANK099) +#endif + +DEF_ICON(MOUSE_LMB) +DEF_ICON(MOUSE_MMB) +DEF_ICON(MOUSE_RMB) +DEF_ICON(MOUSE_DRAG) + +#ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK100) DEF_ICON(BLANK101) DEF_ICON(BLANK102) @@ -292,8 +296,10 @@ DEF_ICON(RNA_ADD) DEF_ICON(BLANK112) DEF_ICON(BLANK113) DEF_ICON(BLANK114) - DEF_ICON(BLANK115) - DEF_ICON(BLANK116) +#endif +DEF_ICON(RESTRICT_VIEW_OFF) +DEF_ICON(RESTRICT_VIEW_ON) +#ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK116b) #endif @@ -319,8 +325,8 @@ DEF_ICON(OUTLINER_OB_LIGHTPROBE) #endif DEF_ICON(RESTRICT_COLOR_OFF) DEF_ICON(RESTRICT_COLOR_ON) -DEF_ICON(RESTRICT_VIEW_OFF) -DEF_ICON(RESTRICT_VIEW_ON) +DEF_ICON(HIDE_OFF) +DEF_ICON(HIDE_ON) DEF_ICON(RESTRICT_SELECT_OFF) DEF_ICON(RESTRICT_SELECT_ON) DEF_ICON(RESTRICT_RENDER_OFF) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 0b4817c8049..d4285f5a96e 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -418,6 +418,7 @@ uiPopupMenu *UI_popup_menu_begin_ex( struct bContext *C, const char *title, const char *block_name, int icon) ATTR_NONNULL(); void UI_popup_menu_end(struct bContext *C, struct uiPopupMenu *head); +bool UI_popup_menu_end_or_cancel(struct bContext *C, struct uiPopupMenu *head); struct uiLayout *UI_popup_menu_layout(uiPopupMenu *head); void UI_popup_menu_reports(struct bContext *C, struct ReportList *reports) ATTR_NONNULL(); @@ -534,6 +535,8 @@ void UI_block_flag_enable(uiBlock *block, int flag); void UI_block_flag_disable(uiBlock *block, int flag); void UI_block_translate(uiBlock *block, int x, int y); +bool UI_block_is_empty(const uiBlock *block); + int UI_but_return_value_get(uiBut *but); void UI_but_drag_set_id(uiBut *but, struct ID *id); @@ -1062,6 +1065,7 @@ void uiTemplateHeader3D_mode(uiLayout *layout, struct bContext *C); void uiTemplateHeader3D(uiLayout *layout, struct bContext *C); void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C); void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C); +void uiTemplateCursorKeymap(uiLayout *layout, struct bContext *C); void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr); void uiTemplateComponentMenu(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name); void uiTemplateNodeSocket(uiLayout *layout, struct bContext *C, float *color); diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index 07ba3b90e11..882db88879d 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -44,6 +44,7 @@ set(SRC interface.c interface_align.c interface_anim.c + interface_context_menu.c interface_draw.c interface_eyedropper.c interface_eyedropper_color.c @@ -56,7 +57,6 @@ set(SRC interface_layout.c interface_ops.c interface_panel.c - interface_regions.c interface_region_color_picker.c interface_region_hud.c interface_region_menu_pie.c @@ -65,6 +65,7 @@ set(SRC interface_region_popup.c interface_region_search.c interface_region_tooltip.c + interface_regions.c interface_style.c interface_templates.c interface_utils.c diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 8c37054098b..a36f534807c 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -4031,6 +4031,16 @@ int UI_blocklist_min_y_get(ListBase *lb) return min; } +bool UI_block_is_empty(const uiBlock *block) +{ + for (const uiBut *but = block->buttons.first; but; but = but->next) { + if (!ELEM(but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) { + return false; + } + } + return true; +} + void UI_block_direction_set(uiBlock *block, char direction) { block->direction = direction; @@ -4780,4 +4790,3 @@ void UI_exit(void) ui_resources_free(); ui_but_clipboard_free(); } - diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c new file mode 100644 index 00000000000..cda81ba79cf --- /dev/null +++ b/source/blender/editors/interface/interface_context_menu.c @@ -0,0 +1,756 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/interface/interface_context_menu.c + * \ingroup edinterface + * + * Generic context popup menus. + */ + +#include <string.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" + +#include "BLI_path_util.h" +#include "BLI_string.h" +#include "BLI_utildefines.h" + +#include "BLT_translation.h" + +#include "BKE_addon.h" +#include "BKE_context.h" +#include "BKE_idprop.h" +#include "BKE_screen.h" + +#include "ED_screen.h" +#include "ED_keyframing.h" + +#include "UI_interface.h" + +#include "interface_intern.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +/* This hack is needed because we don't have a good way to re-reference keymap items once added: T42944 */ +#define USE_KEYMAP_ADD_HACK + +/* -------------------------------------------------------------------- */ +/** \name Button Context Menu + * \{ */ + +static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) +{ + uiBut *but = (uiBut *)arg1; + + if (but->optype) { + char shortcut_str[128]; + + IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; + + /* complex code to change name of button */ + if (WM_key_event_operator_string( + C, but->optype->idname, but->opcontext, prop, true, + shortcut_str, sizeof(shortcut_str))) + { + ui_but_add_shortcut(but, shortcut_str, true); + } + else { + /* simply strip the shortcut */ + ui_but_add_shortcut(but, NULL, true); + } + } +} + +static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg) +{ + wmWindowManager *wm = CTX_wm_manager(C); + uiBlock *block; + uiBut *but = (uiBut *)arg; + wmKeyMap *km; + wmKeyMapItem *kmi; + PointerRNA ptr; + uiLayout *layout; + uiStyle *style = UI_style_get_dpi(); + IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; + + kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, true, &km); + BLI_assert(kmi != NULL); + + RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); + + block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); + UI_block_func_handle_set(block, but_shortcut_name_func, but); + UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); + UI_block_direction_set(block, UI_DIR_CENTER_Y); + + layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); + + uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); + + UI_block_bounds_set_popup(block, 6, -50, 26); + + return block; +} + +#ifdef USE_KEYMAP_ADD_HACK +static int g_kmi_id_hack; +#endif + +static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) +{ + wmWindowManager *wm = CTX_wm_manager(C); + uiBlock *block; + uiBut *but = (uiBut *)arg; + wmKeyMap *km; + wmKeyMapItem *kmi; + PointerRNA ptr; + uiLayout *layout; + uiStyle *style = UI_style_get_dpi(); + IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; + int kmi_id; + + /* XXX this guess_opname can potentially return a different keymap than being found on adding later... */ + km = WM_keymap_guess_opname(C, but->optype->idname); + kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0); + kmi_id = kmi->id; + + /* copy properties, prop can be NULL for reset */ + if (prop) + prop = IDP_CopyProperty(prop); + WM_keymap_properties_reset(kmi, prop); + + /* update and get pointers again */ + WM_keyconfig_update(wm); + + km = WM_keymap_guess_opname(C, but->optype->idname); + kmi = WM_keymap_item_find_id(km, kmi_id); + + RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); + + block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); + UI_block_func_handle_set(block, but_shortcut_name_func, but); + UI_block_direction_set(block, UI_DIR_CENTER_Y); + + layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); + + uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); + + UI_block_bounds_set_popup(block, 6, -50, 26); + +#ifdef USE_KEYMAP_ADD_HACK + g_kmi_id_hack = kmi_id; +#endif + return block; +} + +static void menu_add_shortcut_cancel(struct bContext *C, void *arg1) +{ + uiBut *but = (uiBut *)arg1; + wmKeyMap *km; + wmKeyMapItem *kmi; +#ifndef USE_KEYMAP_ADD_HACK + IDProperty *prop; +#endif + int kmi_id; + +#ifdef USE_KEYMAP_ADD_HACK + km = WM_keymap_guess_opname(C, but->optype->idname); + kmi_id = g_kmi_id_hack; + UNUSED_VARS(but); +#else + prop = (but->opptr) ? but->opptr->data : NULL; + kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, true, &km); +#endif + + kmi = WM_keymap_item_find_id(km, kmi_id); + WM_keymap_remove_item(km, kmi); +} + +static void popup_change_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) +{ + uiBut *but = (uiBut *)arg1; + UI_popup_block_invoke(C, menu_change_shortcut, but); +} + +static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) +{ + uiBut *but = (uiBut *)arg1; + wmKeyMap *km; + wmKeyMapItem *kmi; + IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; + + kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, true, &km); + BLI_assert(kmi != NULL); + + WM_keymap_remove_item(km, kmi); + + but_shortcut_name_func(C, but, 0); +} + +static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) +{ + uiBut *but = (uiBut *)arg1; + UI_popup_block_ex(C, menu_add_shortcut, NULL, menu_add_shortcut_cancel, but, NULL); +} + +static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void *UNUSED(arg2)) +{ + uiBut *but = arg1; + bUserMenu *um = ED_screen_user_menu_ensure(C); + + char drawstr[sizeof(but->drawstr)]; + STRNCPY(drawstr, but->drawstr); + if (but->flag & UI_BUT_HAS_SEP_CHAR) { + char *sep = strrchr(drawstr, UI_SEP_CHAR); + if (sep) { + *sep = '\0'; + } + } + ED_screen_user_menu_item_add_operator( + &um->items, drawstr, + but->optype, but->opptr ? but->opptr->data : NULL, but->opcontext); +} + +static void popup_user_menu_remove_func(bContext *UNUSED(C), void *arg1, void *arg2) +{ + bUserMenu *um = arg1; + bUserMenuItem *umi = arg2; + ED_screen_user_menu_item_remove(&um->items, umi); +} + +static void ui_but_menu_add_path_operators(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop) +{ + const PropertySubType subtype = RNA_property_subtype(prop); + wmOperatorType *ot = WM_operatortype_find("WM_OT_path_open", true); + char filepath[FILE_MAX]; + char dir[FILE_MAXDIR]; + char file[FILE_MAXFILE]; + PointerRNA props_ptr; + + BLI_assert(ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)); + UNUSED_VARS_NDEBUG(subtype); + + RNA_property_string_get(ptr, prop, filepath); + BLI_split_dirfile(filepath, dir, file, sizeof(dir), sizeof(file)); + + if (file[0]) { + BLI_assert(subtype == PROP_FILEPATH); + uiItemFullO_ptr( + layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open File Externally"), + ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr); + RNA_string_set(&props_ptr, "filepath", filepath); + } + + uiItemFullO_ptr( + layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Location Externally"), + ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr); + RNA_string_set(&props_ptr, "filepath", dir); +} + +bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) +{ + /* having this menu for some buttons makes no sense */ + if (but->type == UI_BTYPE_IMAGE) { + return false; + } + + uiPopupMenu *pup; + uiLayout *layout; + + { + uiStringInfo label = {BUT_GET_LABEL, NULL}; + + /* highly unlikely getting the label ever fails */ + UI_but_string_info_get(C, but, &label, NULL); + + pup = UI_popup_menu_begin(C, label.strinfo ? label.strinfo : "", ICON_NONE); + layout = UI_popup_menu_layout(pup); + if (label.strinfo) { + MEM_freeN(label.strinfo); + } + uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); + } + + if (but->rnapoin.data && but->rnaprop) { + PointerRNA *ptr = &but->rnapoin; + PropertyRNA *prop = but->rnaprop; + const PropertyType type = RNA_property_type(prop); + const PropertySubType subtype = RNA_property_subtype(prop); + bool is_anim = RNA_property_animateable(ptr, prop); + bool is_editable = RNA_property_editable(ptr, prop); + /*bool is_idprop = RNA_property_is_idprop(prop);*/ /* XXX does not work as expected, not strictly needed */ + bool is_set = RNA_property_is_set(ptr, prop); + + /* second slower test, saved people finding keyframe items in menus when its not possible */ + if (is_anim) + is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop); + + /* determine if we can key a single component of an array */ + const bool is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0; + const bool is_array_component = (is_array && but->rnaindex != -1); + + const int static_override_status = RNA_property_static_override_status(ptr, prop, -1); + const bool is_static_overridable = (static_override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE) != 0; + + const int dynamic_override_status = RNA_property_dynamic_override_status(ptr, prop, -1); + const bool is_dynamic_overridable = (dynamic_override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE) != 0; + + /* Keyframes */ + if (but->flag & UI_BUT_ANIMATED_KEY) { + /* Set the (button_pointer, button_prop) and pointer data for Python access to the hovered ui element. */ + uiLayoutSetContextFromBut(layout, but); + + /* replace/delete keyfraemes */ + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframes"), + ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Single Keyframe"), + ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframes"), + ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Keyframe"), + ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 0); + } + else { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframe"), + ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframe"), + ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1); + } + + /* keyframe settings */ + uiItemS(layout); + + + } + else if (but->flag & UI_BUT_DRIVEN) { + /* pass */ + } + else if (is_anim) { + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframes"), + ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Single Keyframe"), + ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); + } + else { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframe"), + ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); + } + } + + if ((but->flag & UI_BUT_ANIMATED) && (but->rnapoin.type != &RNA_NlaStrip)) { + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"), + ICON_KEY_DEHLT, "ANIM_OT_keyframe_clear_button", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Single Keyframes"), + ICON_NONE, "ANIM_OT_keyframe_clear_button", "all", 0); + } + else { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"), + ICON_KEY_DEHLT, "ANIM_OT_keyframe_clear_button", "all", 1); + } + } + + /* Drivers */ + if (but->flag & UI_BUT_DRIVEN) { + uiItemS(layout); + + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Drivers"), + ICON_X, "ANIM_OT_driver_button_remove", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Driver"), + ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0); + } + else { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Driver"), + ICON_X, "ANIM_OT_driver_button_remove", "all", 1); + } + + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Driver"), + ICON_NONE, "ANIM_OT_copy_driver_button"); + if (ANIM_driver_can_paste()) { + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), + ICON_NONE, "ANIM_OT_paste_driver_button"); + } + + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Edit Driver"), + ICON_DRIVER, "ANIM_OT_driver_button_edit"); + + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"), + ICON_NONE, "SCREEN_OT_drivers_editor_show"); + } + else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) { + /* pass */ + } + else if (is_anim) { + uiItemS(layout); + + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"), + ICON_DRIVER, "ANIM_OT_driver_button_add"); + + if (ANIM_driver_can_paste()) { + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), + ICON_NONE, "ANIM_OT_paste_driver_button"); + } + + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"), + ICON_NONE, "SCREEN_OT_drivers_editor_show"); + } + + /* Keying Sets */ + /* TODO: check on modifyability of Keying Set when doing this */ + if (is_anim) { + uiItemS(layout); + + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add All to Keying Set"), + ICON_KEYINGSET, "ANIM_OT_keyingset_button_add", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Single to Keying Set"), + ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 0); + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"), + ICON_NONE, "ANIM_OT_keyingset_button_remove"); + } + else { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Keying Set"), + ICON_KEYINGSET, "ANIM_OT_keyingset_button_add", "all", 1); + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"), + ICON_NONE, "ANIM_OT_keyingset_button_remove"); + } + } + + /* Dynamic Override Operators */ + if (is_editable && is_dynamic_overridable) { + uiItemS(layout); + uiItemFullO(layout, "SCENE_OT_view_layer_override_add", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL); + } + + if (is_static_overridable) { + wmOperatorType *ot; + PointerRNA op_ptr; + /* Override Operators */ + uiItemS(layout); + + if (but->flag & UI_BUT_OVERRIDEN) { + if (is_array_component) { +#if 0 /* Disabled for now. */ + ot = WM_operatortype_find("UI_OT_override_type_set_button", false); + uiItemFullO_ptr( + layout, ot, "Overrides Type", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); + RNA_boolean_set(&op_ptr, "all", true); + uiItemFullO_ptr( + layout, ot, "Single Override Type", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); + RNA_boolean_set(&op_ptr, "all", false); +#endif + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Overrides"), + ICON_X, "UI_OT_override_remove_button", "all", true); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Single Override"), + ICON_X, "UI_OT_override_remove_button", "all", false); + } + else { +#if 0 /* Disabled for now. */ + uiItemFullO( + layout, "UI_OT_override_type_set_button", "Override Type", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); + RNA_boolean_set(&op_ptr, "all", false); +#endif + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Override"), + ICON_X, "UI_OT_override_remove_button", "all", true); + } + } + else { + if (is_array_component) { + ot = WM_operatortype_find("UI_OT_override_type_set_button", false); + uiItemFullO_ptr( + layout, ot, "Define Overrides", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); + RNA_boolean_set(&op_ptr, "all", true); + uiItemFullO_ptr( + layout, ot, "Define Single Override", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); + RNA_boolean_set(&op_ptr, "all", false); + } + else { + uiItemFullO( + layout, "UI_OT_override_type_set_button", "Define Override", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); + RNA_boolean_set(&op_ptr, "all", false); + } + } + } + + uiItemS(layout); + + /* Property Operators */ + + /* Copy Property Value + * Paste Property Value */ + + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"), + ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset Single to Default Value"), + ICON_NONE, "UI_OT_reset_default_button", "all", 0); + } + else { + uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset to Default Value"), + ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1); + } + if (is_editable /*&& is_idprop*/ && is_set) { + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Unset"), + ICON_NONE, "UI_OT_unset_property_button"); + } + + if (is_array_component) { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy All To Selected"), + ICON_NONE, "UI_OT_copy_to_selected_button", "all", true); + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Single To Selected"), + ICON_NONE, "UI_OT_copy_to_selected_button", "all", false); + } + else { + uiItemBooleanO( + layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy To Selected"), + ICON_NONE, "UI_OT_copy_to_selected_button", "all", true); + } + + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Data Path"), + ICON_NONE, "UI_OT_copy_data_path_button"); + + uiItemS(layout); + + if (type == PROP_STRING && ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)) { + ui_but_menu_add_path_operators(layout, ptr, prop); + uiItemS(layout); + } + } + + /* Operator buttons */ + if (but->optype) { + uiBlock *block = uiLayoutGetBlock(layout); + uiBut *but2; + IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; + int w = uiLayoutGetWidth(layout); + wmKeyMap *km; + /* We want to know if this op has a shortcut, be it hotkey or not. */ + wmKeyMapItem *kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, false, &km); + + /* We do have a shortcut, but only keyboard ones are editbale that way... */ + if (kmi) { + if (ISKEYBOARD(kmi->type)) { +#if 0 /* would rather use a block but, but gets weirdly positioned... */ + uiDefBlockBut( + block, menu_change_shortcut, but, "Change Shortcut", + 0, 0, uiLayoutGetWidth(layout), UI_UNIT_Y, ""); +#endif + + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_HAND, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + UI_but_func_set(but2, popup_change_shortcut_func, but, NULL); + + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_NONE, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Shortcut"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + UI_but_func_set(but2, remove_shortcut_func, but, NULL); + } + else { + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_HAND, IFACE_("Non-Keyboard Shortcut"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, + TIP_("Only keyboard shortcuts can be edited that way, " + "please use User Preferences otherwise")); + UI_but_flag_enable(but2, UI_BUT_DISABLED); + } + } + /* only show 'add' if there's a suitable key map for it to go in */ + else if (WM_keymap_guess_opname(C, but->optype->idname)) { + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_HAND, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Shortcut"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + UI_but_func_set(but2, popup_add_shortcut_func, but, NULL); + } + + uiItemS(layout); + + { + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_MENU_PANEL, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Favorites Menu"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, + "Add to a user defined context menu (stored in the user preferences)"); + UI_but_func_set(but2, popup_user_menu_add_or_replace_func, but, NULL); + + bUserMenu *um = ED_screen_user_menu_find(C); + if (um) { + bUserMenuItem_Op *umi_op = ED_screen_user_menu_item_find_operator( + &um->items, but->optype, prop, but->opcontext); + if (umi_op != NULL) { + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_CANCEL, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Favorites Menu"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + UI_but_func_set(but2, popup_user_menu_remove_func, um, umi_op); + } + } + } + + /* Set the operator pointer for python access */ + uiLayoutSetContextFromBut(layout, but); + + uiItemS(layout); + } + + /* Show header tools for header buttons. */ + if (ui_block_is_menu(but->block) == false) { + ARegion *ar = CTX_wm_region(C); + if (ar && (ar->regiontype == RGN_TYPE_HEADER)) { + uiItemMenuF(layout, IFACE_("Header"), ICON_NONE, ED_screens_header_tools_menu_create, NULL); + uiItemS(layout); + } + } + + { /* Docs */ + char buf[512]; + + if (UI_but_online_manual_id(but, buf, sizeof(buf))) { + PointerRNA ptr_props; + uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Manual"), + ICON_URL, "WM_OT_doc_view_manual_ui_context"); + + uiItemFullO( + layout, "WM_OT_doc_view", + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Python Reference"), + ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &ptr_props); + RNA_string_set(&ptr_props, "doc_id", buf); + + /* XXX inactive option, not for public! */ +#if 0 + uiItemFullO( + layout, "WM_OT_doc_edit", "Submit Description", ICON_NONE, + NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr_props); + RNA_string_set(&ptr_props, "doc_id", buf); + RNA_string_set(&ptr_props, "doc_new", RNA_property_description(but->rnaprop)); +#endif + } + } + + if (but->optype) { + uiItemO(layout, NULL, + ICON_NONE, "UI_OT_copy_python_command_button"); + } + + /* perhaps we should move this into (G.debug & G_DEBUG) - campbell */ + if (U.flag & USER_DEVELOPER_UI) { + if (ui_block_is_menu(but->block) == false) { + uiItemFullO(layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL); + } + } + + if (BKE_addon_find(&U.addons, "ui_translate")) { + uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL); + } + + MenuType *mt = WM_menutype_find("WM_MT_button_context", true); + if (mt) { + UI_menutype_draw(C, mt, uiLayoutColumn(layout, false)); + } + + return UI_popup_menu_end_or_cancel(C, pup); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Panel Context Menu + * \{ */ + +/** + * menu to show when right clicking on the panel header + */ +void ui_popup_context_menu_for_panel(bContext *C, ARegion *ar, Panel *pa) +{ + bScreen *sc = CTX_wm_screen(C); + const bool has_panel_category = UI_panel_category_is_visible(ar); + const bool any_item_visible = has_panel_category; + PointerRNA ptr; + uiPopupMenu *pup; + uiLayout *layout; + + if (!any_item_visible) { + return; + } + + RNA_pointer_create(&sc->id, &RNA_Panel, pa, &ptr); + + pup = UI_popup_menu_begin(C, IFACE_("Panel"), ICON_NONE); + layout = UI_popup_menu_layout(pup); + + if (has_panel_category) { + char tmpstr[80]; + BLI_snprintf(tmpstr, sizeof(tmpstr), "%s" UI_SEP_CHAR_S "%s", IFACE_("Pin"), IFACE_("Shift+Left Mouse")); + uiItemR(layout, &ptr, "use_pin", 0, tmpstr, ICON_NONE); + + /* evil, force shortcut flag */ + { + uiBlock *block = uiLayoutGetBlock(layout); + uiBut *but = block->buttons.last; + but->flag |= UI_BUT_HAS_SEP_CHAR; + } + } + UI_popup_menu_end(C, pup); +} + +/** \} */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 1ff05fa85cc..bb54f26131a 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -27,7 +27,6 @@ * \ingroup edinterface */ - #include <float.h> #include <limits.h> #include <math.h> @@ -40,22 +39,18 @@ #include "DNA_brush_types.h" -#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BLI_math.h" #include "BLI_listbase.h" #include "BLI_linklist.h" -#include "BLI_path_util.h" #include "BLI_string.h" #include "BLI_string_utf8.h" #include "BLI_string_cursor_utf8.h" #include "BLI_rect.h" #include "BLI_utildefines.h" -#include "BLT_translation.h" - #include "PIL_time.h" #include "BKE_colorband.h" @@ -63,7 +58,6 @@ #include "BKE_brush.h" #include "BKE_colortools.h" #include "BKE_context.h" -#include "BKE_idprop.h" #include "BKE_report.h" #include "BKE_screen.h" #include "BKE_tracking.h" @@ -72,7 +66,6 @@ #include "ED_screen.h" #include "ED_undo.h" -#include "ED_keyframing.h" #include "UI_interface.h" #include "UI_view2d.h" @@ -89,6 +82,7 @@ #ifdef WITH_INPUT_IME # include "wm_window.h" +# include "BLT_translation.h" # include "BLT_lang.h" #endif @@ -111,9 +105,6 @@ #define UI_MAX_PASSWORD_STR 128 -/* This hack is needed because we don't have a good way to re-reference keymap items once added: T42944 */ -#define USE_KEYMAP_ADD_HACK - /* proto */ static int ui_do_but_EXIT(bContext *C, uiBut *but, struct uiHandleButtonData *data, const wmEvent *event); static bool ui_but_find_select_in_enum__cmp(const uiBut *but_a, const uiBut *but_b); @@ -1300,7 +1291,6 @@ typedef struct uiDragToggleHandle { bool is_init; bool is_set; float but_cent_start[2]; - eButType but_type_start; bool xy_lock[2]; int xy_init[2]; @@ -1308,7 +1298,7 @@ typedef struct uiDragToggleHandle { } uiDragToggleHandle; static bool ui_drag_toggle_set_xy_xy( - bContext *C, ARegion *ar, const bool is_set, const eButType but_type_start, + bContext *C, ARegion *ar, const bool is_set, const int xy_src[2], const int xy_dst[2]) { /* popups such as layers won't re-evaluate on redraw */ @@ -1332,7 +1322,7 @@ static bool ui_drag_toggle_set_xy_xy( if (BLI_rctf_isect_segment(&but->rect, xy_a_block, xy_b_block)) { /* execute the button */ - if (ui_drag_toggle_but_is_supported(but) && but->type == but_type_start) { + if (ui_drag_toggle_but_is_supported(but)) { /* is it pressed? */ bool is_set_but = ui_drag_toggle_but_is_pushed(but); if (is_set_but != is_set) { @@ -1404,7 +1394,7 @@ static void ui_drag_toggle_set(bContext *C, uiDragToggleHandle *drag_info, const /* touch all buttons between last mouse coord and this one */ - do_draw = ui_drag_toggle_set_xy_xy(C, ar, drag_info->is_set, drag_info->but_type_start, drag_info->xy_last, xy); + do_draw = ui_drag_toggle_set_xy_xy(C, ar, drag_info->is_set, drag_info->xy_last, xy); if (do_draw) { ED_region_tag_redraw(ar); @@ -1783,7 +1773,6 @@ static bool ui_but_drag_init( drag_info->is_set = ui_drag_toggle_but_is_pushed(but); drag_info->but_cent_start[0] = BLI_rctf_cent_x(&but->rect); drag_info->but_cent_start[1] = BLI_rctf_cent_y(&but->rect); - drag_info->but_type_start = but->type; copy_v2_v2_int(drag_info->xy_init, &event->x); copy_v2_v2_int(drag_info->xy_last, &event->x); @@ -6495,602 +6484,6 @@ static int ui_do_but_TRACKPREVIEW( return WM_UI_HANDLER_CONTINUE; } -static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) -{ - uiBut *but = (uiBut *)arg1; - - if (but->optype) { - char shortcut_str[128]; - - IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - - /* complex code to change name of button */ - if (WM_key_event_operator_string( - C, but->optype->idname, but->opcontext, prop, true, - shortcut_str, sizeof(shortcut_str))) - { - ui_but_add_shortcut(but, shortcut_str, true); - } - else { - /* simply strip the shortcut */ - ui_but_add_shortcut(but, NULL, true); - } - } -} - -static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg) -{ - wmWindowManager *wm = CTX_wm_manager(C); - uiBlock *block; - uiBut *but = (uiBut *)arg; - wmKeyMap *km; - wmKeyMapItem *kmi; - PointerRNA ptr; - uiLayout *layout; - uiStyle *style = UI_style_get_dpi(); - IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - - kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, true, &km); - BLI_assert(kmi != NULL); - - RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); - - block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); - UI_block_func_handle_set(block, but_shortcut_name_func, but); - UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); - UI_block_direction_set(block, UI_DIR_CENTER_Y); - - layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); - - uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); - - UI_block_bounds_set_popup(block, 6, -50, 26); - - return block; -} - -#ifdef USE_KEYMAP_ADD_HACK -static int g_kmi_id_hack; -#endif - -static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) -{ - wmWindowManager *wm = CTX_wm_manager(C); - uiBlock *block; - uiBut *but = (uiBut *)arg; - wmKeyMap *km; - wmKeyMapItem *kmi; - PointerRNA ptr; - uiLayout *layout; - uiStyle *style = UI_style_get_dpi(); - IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - int kmi_id; - - /* XXX this guess_opname can potentially return a different keymap than being found on adding later... */ - km = WM_keymap_guess_opname(C, but->optype->idname); - kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0); - kmi_id = kmi->id; - - /* copy properties, prop can be NULL for reset */ - if (prop) - prop = IDP_CopyProperty(prop); - WM_keymap_properties_reset(kmi, prop); - - /* update and get pointers again */ - WM_keyconfig_update(wm); - - km = WM_keymap_guess_opname(C, but->optype->idname); - kmi = WM_keymap_item_find_id(km, kmi_id); - - RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); - - block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); - UI_block_func_handle_set(block, but_shortcut_name_func, but); - UI_block_direction_set(block, UI_DIR_CENTER_Y); - - layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); - - uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); - - UI_block_bounds_set_popup(block, 6, -50, 26); - -#ifdef USE_KEYMAP_ADD_HACK - g_kmi_id_hack = kmi_id; -#endif - return block; -} - -static void menu_add_shortcut_cancel(struct bContext *C, void *arg1) -{ - uiBut *but = (uiBut *)arg1; - wmKeyMap *km; - wmKeyMapItem *kmi; -#ifndef USE_KEYMAP_ADD_HACK - IDProperty *prop; -#endif - int kmi_id; - -#ifdef USE_KEYMAP_ADD_HACK - km = WM_keymap_guess_opname(C, but->optype->idname); - kmi_id = g_kmi_id_hack; - UNUSED_VARS(but); -#else - prop = (but->opptr) ? but->opptr->data : NULL; - kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, true, &km); -#endif - - kmi = WM_keymap_item_find_id(km, kmi_id); - WM_keymap_remove_item(km, kmi); -} - -static void popup_change_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) -{ - uiBut *but = (uiBut *)arg1; - UI_popup_block_invoke(C, menu_change_shortcut, but); -} - -static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) -{ - uiBut *but = (uiBut *)arg1; - wmKeyMap *km; - wmKeyMapItem *kmi; - IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - - kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, true, &km); - BLI_assert(kmi != NULL); - - WM_keymap_remove_item(km, kmi); - - but_shortcut_name_func(C, but, 0); -} - -static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) -{ - uiBut *but = (uiBut *)arg1; - UI_popup_block_ex(C, menu_add_shortcut, NULL, menu_add_shortcut_cancel, but, NULL); -} - -/** - * menu to chow when right clicking on the panel header - */ -void ui_panel_menu(bContext *C, ARegion *ar, Panel *pa) -{ - bScreen *sc = CTX_wm_screen(C); - const bool has_panel_category = UI_panel_category_is_visible(ar); - const bool any_item_visible = has_panel_category; - PointerRNA ptr; - uiPopupMenu *pup; - uiLayout *layout; - - if (!any_item_visible) { - return; - } - - RNA_pointer_create(&sc->id, &RNA_Panel, pa, &ptr); - - pup = UI_popup_menu_begin(C, IFACE_("Panel"), ICON_NONE); - layout = UI_popup_menu_layout(pup); - - if (has_panel_category) { - char tmpstr[80]; - BLI_snprintf(tmpstr, sizeof(tmpstr), "%s" UI_SEP_CHAR_S "%s", IFACE_("Pin"), IFACE_("Shift+Left Mouse")); - uiItemR(layout, &ptr, "use_pin", 0, tmpstr, ICON_NONE); - - /* evil, force shortcut flag */ - { - uiBlock *block = uiLayoutGetBlock(layout); - uiBut *but = block->buttons.last; - but->flag |= UI_BUT_HAS_SEP_CHAR; - } - } - UI_popup_menu_end(C, pup); -} - -static void ui_but_menu_add_path_operators(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop) -{ - const PropertySubType subtype = RNA_property_subtype(prop); - wmOperatorType *ot = WM_operatortype_find("WM_OT_path_open", true); - char filepath[FILE_MAX]; - char dir[FILE_MAXDIR]; - char file[FILE_MAXFILE]; - PointerRNA props_ptr; - - BLI_assert(ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)); - UNUSED_VARS_NDEBUG(subtype); - - RNA_property_string_get(ptr, prop, filepath); - BLI_split_dirfile(filepath, dir, file, sizeof(dir), sizeof(file)); - - if (file[0]) { - BLI_assert(subtype == PROP_FILEPATH); - uiItemFullO_ptr( - layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open File Externally"), - ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr); - RNA_string_set(&props_ptr, "filepath", filepath); - } - - uiItemFullO_ptr( - layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Location Externally"), - ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr); - RNA_string_set(&props_ptr, "filepath", dir); -} - -static bool ui_but_menu(bContext *C, uiBut *but) -{ - uiPopupMenu *pup; - uiLayout *layout; - MenuType *mt = WM_menutype_find("WM_MT_button_context", true); - bool is_array, is_array_component; - uiStringInfo label = {BUT_GET_LABEL, NULL}; - wmOperatorType *ot; - PointerRNA op_ptr; - -/* if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)*/ -/* return 0;*/ - - /* having this menu for some buttons makes no sense */ - if (but->type == UI_BTYPE_IMAGE) { - return false; - } - - /* highly unlikely getting the label ever fails */ - UI_but_string_info_get(C, but, &label, NULL); - - pup = UI_popup_menu_begin(C, label.strinfo ? label.strinfo : "", ICON_NONE); - layout = UI_popup_menu_layout(pup); - if (label.strinfo) - MEM_freeN(label.strinfo); - - uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); - - if (but->rnapoin.data && but->rnaprop) { - PointerRNA *ptr = &but->rnapoin; - PropertyRNA *prop = but->rnaprop; - const PropertyType type = RNA_property_type(prop); - const PropertySubType subtype = RNA_property_subtype(prop); - bool is_anim = RNA_property_animateable(ptr, prop); - bool is_editable = RNA_property_editable(ptr, prop); - /*bool is_idprop = RNA_property_is_idprop(prop);*/ /* XXX does not work as expected, not strictly needed */ - bool is_set = RNA_property_is_set(ptr, prop); - - const int static_override_status = RNA_property_static_override_status(ptr, prop, -1); - const bool is_static_overridable = (static_override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE) != 0; - - const int dynamic_override_status = RNA_property_dynamic_override_status(ptr, prop, -1); - const bool is_dynamic_overridable = (dynamic_override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE) != 0; - - /* second slower test, saved people finding keyframe items in menus when its not possible */ - if (is_anim) - is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop); - - /* determine if we can key a single component of an array */ - is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0; - is_array_component = (is_array && but->rnaindex != -1); - - /* Keyframes */ - if (but->flag & UI_BUT_ANIMATED_KEY) { - /* replace/delete keyfraemes */ - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframes"), - ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Single Keyframe"), - ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframes"), - ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Keyframe"), - ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 0); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframe"), - ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframe"), - ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1); - } - - /* keyframe settings */ - uiItemS(layout); - - - } - else if (but->flag & UI_BUT_DRIVEN) { - /* pass */ - } - else if (is_anim) { - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframes"), - ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Single Keyframe"), - ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframe"), - ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1); - } - } - - if ((but->flag & UI_BUT_ANIMATED) && (but->rnapoin.type != &RNA_NlaStrip)) { - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"), - ICON_KEY_DEHLT, "ANIM_OT_keyframe_clear_button", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Single Keyframes"), - ICON_NONE, "ANIM_OT_keyframe_clear_button", "all", 0); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"), - ICON_KEY_DEHLT, "ANIM_OT_keyframe_clear_button", "all", 1); - } - } - - /* Drivers */ - if (but->flag & UI_BUT_DRIVEN) { - uiItemS(layout); - - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Drivers"), - ICON_X, "ANIM_OT_driver_button_remove", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Driver"), - ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Driver"), - ICON_X, "ANIM_OT_driver_button_remove", "all", 1); - } - - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Driver"), - ICON_NONE, "ANIM_OT_copy_driver_button"); - if (ANIM_driver_can_paste()) { - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), - ICON_NONE, "ANIM_OT_paste_driver_button"); - } - - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Edit Driver"), - ICON_DRIVER, "ANIM_OT_driver_button_edit"); - - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"), - ICON_NONE, "SCREEN_OT_drivers_editor_show"); - } - else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) { - /* pass */ - } - else if (is_anim) { - uiItemS(layout); - - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"), - ICON_DRIVER, "ANIM_OT_driver_button_add"); - - if (ANIM_driver_can_paste()) { - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), - ICON_NONE, "ANIM_OT_paste_driver_button"); - } - - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"), - ICON_NONE, "SCREEN_OT_drivers_editor_show"); - } - - /* Keying Sets */ - /* TODO: check on modifyability of Keying Set when doing this */ - if (is_anim) { - uiItemS(layout); - - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add All to Keying Set"), - ICON_KEYINGSET, "ANIM_OT_keyingset_button_add", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Single to Keying Set"), - ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 0); - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"), - ICON_NONE, "ANIM_OT_keyingset_button_remove"); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Keying Set"), - ICON_KEYINGSET, "ANIM_OT_keyingset_button_add", "all", 1); - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"), - ICON_NONE, "ANIM_OT_keyingset_button_remove"); - } - } - - /* Dynamic Override Operators */ - if (is_editable && is_dynamic_overridable) { - uiItemS(layout); - uiItemFullO(layout, "SCENE_OT_view_layer_override_add", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL); - } - - if (is_static_overridable) { - /* Static Override Operators */ - uiItemS(layout); - - if (but->flag & UI_BUT_OVERRIDEN) { - if (is_array_component) { -#if 0 /* Disabled for now. */ - ot = WM_operatortype_find("UI_OT_override_type_set_button", false); - uiItemFullO_ptr(layout, ot, "Overrides Type", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); - RNA_boolean_set(&op_ptr, "all", true); - uiItemFullO_ptr(layout, ot, "Single Override Type", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); - RNA_boolean_set(&op_ptr, "all", false); -#endif - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Overrides"), - ICON_X, "UI_OT_override_remove_button", "all", true); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Single Override"), - ICON_X, "UI_OT_override_remove_button", "all", false); - } - else { -#if 0 /* Disabled for now. */ - uiItemFullO(layout, "UI_OT_override_type_set_button", "Override Type", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); - RNA_boolean_set(&op_ptr, "all", false); -#endif - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Override"), - ICON_X, "UI_OT_override_remove_button", "all", true); - } - } - else { - if (is_array_component) { - ot = WM_operatortype_find("UI_OT_override_type_set_button", false); - uiItemFullO_ptr(layout, ot, "Define Overrides", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); - RNA_boolean_set(&op_ptr, "all", true); - uiItemFullO_ptr(layout, ot, "Define Single Override", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); - RNA_boolean_set(&op_ptr, "all", false); - } - else { - uiItemFullO(layout, "UI_OT_override_type_set_button", "Define Override", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); - RNA_boolean_set(&op_ptr, "all", false); - } - } - } - - uiItemS(layout); - - /* Property Operators */ - - /* Copy Property Value - * Paste Property Value */ - - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"), - ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset Single to Default Value"), - ICON_NONE, "UI_OT_reset_default_button", "all", 0); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset to Default Value"), - ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1); - } - if (is_editable /*&& is_idprop*/ && is_set) { - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Unset"), - ICON_NONE, "UI_OT_unset_property_button"); - } - - if (is_array_component) { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy All To Selected"), - ICON_NONE, "UI_OT_copy_to_selected_button", "all", true); - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Single To Selected"), - ICON_NONE, "UI_OT_copy_to_selected_button", "all", false); - } - else { - uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy To Selected"), - ICON_NONE, "UI_OT_copy_to_selected_button", "all", true); - } - - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Data Path"), - ICON_NONE, "UI_OT_copy_data_path_button"); - - uiItemS(layout); - - if (type == PROP_STRING && ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)) { - ui_but_menu_add_path_operators(layout, ptr, prop); - uiItemS(layout); - } - } - - /* Operator buttons */ - if (but->optype) { - uiBlock *block = uiLayoutGetBlock(layout); - uiBut *but2; - IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; - int w = uiLayoutGetWidth(layout); - wmKeyMap *km; - /* We want to know if this op has a shortcut, be it hotkey or not. */ - wmKeyMapItem *kmi = WM_key_event_operator(C, but->optype->idname, but->opcontext, prop, false, &km); - - /* We do have a shortcut, but only keyboard ones are editbale that way... */ - if (kmi) { - if (ISKEYBOARD(kmi->type)) { -#if 0 /* would rather use a block but, but gets weirdly positioned... */ - uiDefBlockBut(block, menu_change_shortcut, but, "Change Shortcut", - 0, 0, uiLayoutGetWidth(layout), UI_UNIT_Y, ""); -#endif - - but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_HAND, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), - 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - UI_but_func_set(but2, popup_change_shortcut_func, but, NULL); - - but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_NONE, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Shortcut"), - 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - UI_but_func_set(but2, remove_shortcut_func, but, NULL); - } - else { - but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_HAND, IFACE_("Non-Keyboard Shortcut"), - 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, - TIP_("Only keyboard shortcuts can be edited that way, " - "please use User Preferences otherwise")); - UI_but_flag_enable(but2, UI_BUT_DISABLED); - } - } - /* only show 'add' if there's a suitable key map for it to go in */ - else if (WM_keymap_guess_opname(C, but->optype->idname)) { - but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_HAND, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Shortcut"), - 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - UI_but_func_set(but2, popup_add_shortcut_func, but, NULL); - } - - /* Set the operator pointer for python access */ - uiLayoutSetContextFromBut(layout, but); - - uiItemS(layout); - } - - /* Show header tools for header buttons. */ - if (ui_block_is_menu(but->block) == false) { - ARegion *ar = CTX_wm_region(C); - if (ar && (ar->regiontype == RGN_TYPE_HEADER)) { - uiItemMenuF(layout, IFACE_("Header"), ICON_NONE, ED_screens_header_tools_menu_create, NULL); - uiItemS(layout); - } - } - - { /* Docs */ - char buf[512]; - - if (UI_but_online_manual_id(but, buf, sizeof(buf))) { - PointerRNA ptr_props; - uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Manual"), - ICON_URL, "WM_OT_doc_view_manual_ui_context"); - - uiItemFullO( - layout, "WM_OT_doc_view", - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Python Reference"), - ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &ptr_props); - RNA_string_set(&ptr_props, "doc_id", buf); - - /* XXX inactive option, not for public! */ -#if 0 - uiItemFullO( - layout, "WM_OT_doc_edit", "Submit Description", ICON_NONE, - NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr_props); - RNA_string_set(&ptr_props, "doc_id", buf); - RNA_string_set(&ptr_props, "doc_new", RNA_property_description(but->rnaprop)); -#endif - } - } - - if (but->optype) { - uiItemO(layout, NULL, - ICON_NONE, "UI_OT_copy_python_command_button"); - } - - /* perhaps we should move this into (G.debug & G_DEBUG) - campbell */ - if (ui_block_is_menu(but->block) == false) { - uiItemFullO(layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL); - } - uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL); - - mt = WM_menutype_find("WM_MT_button_context", true); - if (mt) { - UI_menutype_draw(C, mt, uiLayoutColumn(layout, false)); - } - - UI_popup_menu_end(C, pup); - - return true; -} - static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *event) { uiHandleButtonData *data; @@ -7134,7 +6527,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * (event->val == KM_PRESS)) { /* RMB has two options now */ - if (ui_but_menu(C, but)) { + if (ui_popup_context_menu_for_button(C, but)) { return WM_UI_HANDLER_BREAK; } } @@ -9602,6 +8995,11 @@ static int ui_handle_menu_event( } #endif + /* Don't handle double click events, rehandle as regular press/release. */ + if (retval == WM_UI_HANDLER_CONTINUE && event->val == KM_DBL_CLICK) { + return retval; + } + /* if we set a menu return value, ensure we continue passing this on to * lower menus and buttons, so always set continue then, and if we are * inside the region otherwise, ensure we swallow the event */ @@ -10182,6 +9580,7 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE { ARegion *ar; uiBut *but; + int retval = WM_UI_HANDLER_CONTINUE; ar = CTX_wm_menu(C); if (!ar) @@ -10225,29 +9624,32 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE if ((but_other->flag & UI_BUT_DISABLED) == 0) { ui_handle_button_activate(C, ar, but_other, BUTTON_ACTIVATE_OVER); button_activate_state(C, but_other, BUTTON_STATE_MENU_OPEN); + retval = WM_UI_HANDLER_BREAK; } } else if (data->state == BUTTON_STATE_MENU_OPEN) { - int retval; - /* handle events for menus and their buttons recursively, * this will handle events from the top to the bottom menu */ - if (data->menu) + if (data->menu) { retval = ui_handle_menus_recursive(C, event, data->menu, 0, false, false, false); + } /* handle events for the activated button */ if ((data->menu && (retval == WM_UI_HANDLER_CONTINUE)) || (event->type == TIMER)) { - if (data->menu && data->menu->menuretval) + if (data->menu && data->menu->menuretval) { ui_handle_button_return_submenu(C, event, but); - else - ui_handle_button_event(C, event, but); + retval = WM_UI_HANDLER_BREAK; + } + else { + retval = ui_handle_button_event(C, event, but); + } } } else { /* handle events for the activated button */ - ui_handle_button_event(C, event, but); + retval = ui_handle_button_event(C, event, but); } } @@ -10258,6 +9660,14 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE /* delayed apply callbacks */ ui_apply_but_funcs_after(C); + /* Don't handle double-click events, + * these will be converted into regular clicks which we handle. */ + if (retval == WM_UI_HANDLER_CONTINUE) { + if (event->val == KM_DBL_CLICK) { + return WM_UI_HANDLER_CONTINUE; + } + } + /* we block all events, this is modal interaction */ return WM_UI_HANDLER_BREAK; } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 539dd05b242..a8feaedf717 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -858,10 +858,10 @@ static void ui_studiolight_kill_icon_preview_job(wmWindowManager *wm, int icon_i icon->obj = NULL; } -static void ui_studiolight_free_function(StudioLight * sl, void* data) +static void ui_studiolight_free_function(StudioLight *sl, void *data) { wmWindowManager *wm = data; - + // get icons_id, get icons and kill wm jobs if (sl->icon_id_radiance) { ui_studiolight_kill_icon_preview_job(wm, sl->icon_id_radiance); @@ -920,7 +920,7 @@ void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool bi di->data.buffer.image = img; wmJob *wm_job = WM_jobs_get(wm, CTX_wm_window(C), icon, "StudioLight Icon", 0, WM_JOB_TYPE_STUDIOLIGHT); - Icon** tmp = MEM_callocN(sizeof(Icon*), __func__); + Icon **tmp = MEM_callocN(sizeof(Icon *), __func__); *tmp = icon; WM_jobs_customdata_set(wm_job, tmp, MEM_freeN); WM_jobs_timer(wm_job, 0.01, 0, NC_WINDOW); @@ -1647,4 +1647,3 @@ void UI_icon_draw_preview_aspect_size(float x, float y, int icon_id, float aspec { icon_draw_size(x, y, icon_id, aspect, alpha, NULL, ICON_SIZE_PREVIEW, size, false); } - diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 6f029b81e92..f29d73e564b 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -706,7 +706,6 @@ float ui_block_calc_pie_segment(struct uiBlock *block, const float event_xy[2]); void ui_but_add_shortcut(uiBut *but, const char *key_str, const bool do_strip); void ui_but_clipboard_free(void); -void ui_panel_menu(struct bContext *C, ARegion *ar, Panel *pa); uiBut *ui_but_find_old(uiBlock *block_old, const uiBut *but_new); uiBut *ui_but_find_new(uiBlock *block_old, const uiBut *but_new); @@ -818,6 +817,10 @@ void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, fl void ui_but_anim_decorate_cb(struct bContext *C, void *arg_but, void *arg_dummy); void ui_but_anim_decorate_update_from_flag(uiBut *but); +/* interface_context_menu.c */ +bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but); +void ui_popup_context_menu_for_panel(struct bContext *C, struct ARegion *ar, struct Panel *pa); + /* interface_eyedropper.c */ struct wmKeyMap *eyedropper_modal_keymap(struct wmKeyConfig *keyconf); struct wmKeyMap *eyedropper_colorband_modal_keymap(struct wmKeyConfig *keyconf); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 3784ab635be..05af133616e 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -67,6 +67,9 @@ /* Show an icon button after each RNA button to use to quickly set keyframes, * this is a way to display animation/driven/override status, see T54951. */ #define UI_PROP_DECORATE +/* Alternate draw mode where some buttons can use single icon width, + * giving more room for the text at the expense of nicely aligned text. */ +#define UI_PROP_SEP_ICON_WIDTH_EXCEPTION /************************ Structs and Defines *************************/ @@ -1595,9 +1598,19 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index } else { const PropertySubType subtype = RNA_property_subtype(prop); - uiLayout *layout_split = uiLayoutSplit( - layout_row ? layout_row : layout, - UI_ITEM_PROP_SEP_DIVIDE, true); + uiLayout *layout_split; +#ifdef UI_PROP_SEP_ICON_WIDTH_EXCEPTION + if (type == PROP_BOOLEAN && (icon == ICON_NONE) && !icon_only) { + w = UI_UNIT_X; + layout_split = uiLayoutRow(layout_row ? layout_row : layout, true); + } + else +#endif /* UI_PROP_SEP_ICON_WIDTH_EXCEPTION */ + { + layout_split = uiLayoutSplit( + layout_row ? layout_row : layout, + UI_ITEM_PROP_SEP_DIVIDE, true); + } layout_split->space = 0; uiLayout *layout_sub = uiLayoutColumn(layout_split, true); layout_sub->space = 0; @@ -3171,12 +3184,12 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem) .litem_y = litem->y, .space_x = space_x, .space_y = space_y, - }), + }), &((UILayoutGridFlowOutput) { .tot_items = &gflow->tot_items, .global_avg_w = &avg_w, .global_max_h = &max_h, - })); + })); if (gflow->tot_items == 0) { litem->w = litem->h = 0; @@ -3258,11 +3271,11 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem) .space_y = space_y, .tot_columns = gflow->tot_columns, .tot_rows = gflow->tot_rows, - }), + }), &((UILayoutGridFlowOutput) { .tot_w = &tot_w, .tot_h = &tot_h, - })); + })); litem->w = tot_w; litem->h = tot_h; @@ -3306,13 +3319,13 @@ static void ui_litem_layout_grid_flow(uiLayout *litem) .space_y = space_y, .tot_columns = gflow->tot_columns, .tot_rows = gflow->tot_rows, - }), + }), &((UILayoutGridFlowOutput) { .cos_x_array = cos_x, .cos_y_array = cos_y, .widths_array = widths, .heights_array = heights, - })); + })); for (item = litem->items.first, i = 0; item; item = item->next, i++) { const int col = gflow->row_major ? i % gflow->tot_columns : i / gflow->tot_rows; diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 6fcede58737..aad48d13277 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1004,6 +1004,7 @@ static int editsource_exec(bContext *C, wmOperator *op) ui_editsource_active_but_set(but); /* redraw and get active button python info */ + ED_region_do_layout(C, ar); ED_region_do_draw(C, ar); ar->do_draw = false; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index e383ae42f8c..5d029685810 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -2254,7 +2254,7 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons } else if (event->type == RIGHTMOUSE) { if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { - ui_panel_menu(C, ar, block->panel); + ui_popup_context_menu_for_panel(C, ar, block->panel); retval = WM_UI_HANDLER_BREAK; break; } diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c index 569f50a9c75..1a49010ad9d 100644 --- a/source/blender/editors/interface/interface_region_hud.c +++ b/source/blender/editors/interface/interface_region_hud.c @@ -329,7 +329,10 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa) /* We shouldn't need to do this every time :S */ /* XXX, this is evil! - it also makes the menu show on first draw. :( */ + ARegion *ar_prev = CTX_wm_region(C); + CTX_wm_region_set((bContext *)C, ar); hud_region_layout(C, ar); + CTX_wm_region_set((bContext *)C, ar_prev); } /** \} */ diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c index a6046e551c6..b9222a75803 100644 --- a/source/blender/editors/interface/interface_region_menu_popup.c +++ b/source/blender/editors/interface/interface_region_menu_popup.c @@ -458,6 +458,21 @@ void UI_popup_menu_end(bContext *C, uiPopupMenu *pup) MEM_freeN(pup); } +bool UI_popup_menu_end_or_cancel(bContext *C, uiPopupMenu *pup) +{ + if (!UI_block_is_empty(pup->block)) { + UI_popup_menu_end(C, pup); + return true; + } + else { + UI_block_layout_resolve(pup->block, NULL, NULL); + MEM_freeN(pup->block->handle); + UI_block_free(C, pup->block); + MEM_freeN(pup); + return false; + } +} + uiLayout *UI_popup_menu_layout(uiPopupMenu *pup) { return pup->layout; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 22487f29977..c2bea466015 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1356,8 +1356,7 @@ static uiLayout *draw_modifier( UI_block_emboss_set(block, UI_EMBOSS); /* modifier name */ - md->scene = scene; - if (mti->isDisabled && mti->isDisabled(md, 0)) { + if (mti->isDisabled && mti->isDisabled(scene, md, 0)) { uiLayoutSetRedAlert(row, true); } uiItemR(row, &ptr, "name", 0, "", ICON_NONE); @@ -1748,7 +1747,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) /* enabled */ UI_block_emboss_set(block, UI_EMBOSS_NONE); uiItemR(row, &ptr, "mute", 0, "", - (con->flag & CONSTRAINT_OFF) ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF); + (con->flag & CONSTRAINT_OFF) ? ICON_HIDE_ON : ICON_HIDE_OFF); UI_block_emboss_set(block, UI_EMBOSS); uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT); @@ -4263,18 +4262,18 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) /* make a box around the report to make it stand out */ UI_block_align_begin(block); - but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", 0, 0, UI_UNIT_X + 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); + but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", 0, 0, UI_UNIT_X + 5, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); /* set the report's bg color in but->col - UI_BTYPE_ROUNDBOX feature */ rgb_float_to_uchar(but->col, rti->col); but->col[3] = 255; - but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, + but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", UI_UNIT_X + 5, 0, UI_UNIT_X + width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); - but->col[0] = but->col[1] = but->col[2] = unit_float_to_uchar_clamp(rti->grayscale); - but->col[3] = 255; UI_block_align_end(block); + UI_GetThemeColorShade3ubv(TH_BACK, 20, but->col); + but->col[3] = 255; /* icon and report message on top */ icon = UI_icon_from_report_type(report->type); @@ -4292,10 +4291,28 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) UI_block_emboss_set(block, UI_EMBOSS); - uiDefBut(block, UI_BTYPE_LABEL, 0, report->message, UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, + uiDefBut(block, UI_BTYPE_LABEL, 0, report->message, UI_UNIT_X + 5, 0, UI_UNIT_X + width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); } + +void uiTemplateCursorKeymap(uiLayout *layout, struct bContext *C) +{ + wmWindow *win = CTX_wm_window(C); + for (int i = 0; i < 3; i++) { + uiLayout *box = uiLayoutRow(layout, true); + for (int j = 0; j < 2; j++) { + const char *msg = WM_window_cursor_keymap_status_get(win, i, j); + if ((j == 0) || (msg != NULL)) { + uiItemL(box, msg, j == 0 ? (ICON_MOUSE_LMB + i) : ICON_MOUSE_DRAG); + } + } + if (i != 2) { + uiItemSpacer(layout); + } + } +} + /********************************* Keymap *************************************/ static void keymap_item_modified(bContext *UNUSED(C), void *kmi_p, void *UNUSED(unused)) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 4bc3aaaf842..a6f58fc056a 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -230,16 +230,16 @@ static const uint g_shape_preset_hold_action_face[2][3] = {{2, 0, 1}, {3, 5, 4}} static const int tria_ofs[ROUNDBOX_TRIA_MAX] = { [ROUNDBOX_TRIA_NONE] = 0, [ROUNDBOX_TRIA_ARROWS] = 0, - [ROUNDBOX_TRIA_SCROLL] = 6, - [ROUNDBOX_TRIA_MENU] = 22, - [ROUNDBOX_TRIA_CHECK] = 28, - [ROUNDBOX_TRIA_HOLD_ACTION_ARROW] = 34, + [ROUNDBOX_TRIA_SCROLL] = 12, + [ROUNDBOX_TRIA_MENU] = 28, + [ROUNDBOX_TRIA_CHECK] = 34, + [ROUNDBOX_TRIA_HOLD_ACTION_ARROW] = 40, }; static const int tria_vcount[ROUNDBOX_TRIA_MAX] = { [ROUNDBOX_TRIA_NONE] = 0, - [ROUNDBOX_TRIA_ARROWS] = 3, + [ROUNDBOX_TRIA_ARROWS] = 6, [ROUNDBOX_TRIA_SCROLL] = 16, - [ROUNDBOX_TRIA_MENU] = 3, + [ROUNDBOX_TRIA_MENU] = 6, [ROUNDBOX_TRIA_CHECK] = 6, [ROUNDBOX_TRIA_HOLD_ACTION_ARROW] = 3, }; @@ -296,8 +296,8 @@ static uint32_t set_tria_vertex( int tria_type, int tria_v, int tria_id, int jit_v) { uint32_t *data = GWN_vertbuf_raw_step(vflag_step); - if (ELEM(tria_type, ROUNDBOX_TRIA_ARROWS, ROUNDBOX_TRIA_MENU)) { - tria_v += tria_id * 3; + if (ELEM(tria_type, ROUNDBOX_TRIA_ARROWS)) { + tria_v += tria_id * tria_vcount[ROUNDBOX_TRIA_ARROWS]; } *data = tria_ofs[tria_type] + tria_v; *data |= jit_v << 6; @@ -308,7 +308,7 @@ static uint32_t set_tria_vertex( static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32_t last_data) { - const int tria_num = ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW) ? 1 : 2; + const int tria_num = ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW, ROUNDBOX_TRIA_MENU) ? 1 : 2; /* for each tria */ for (int t = 0; t < tria_num; ++t) { for (int j = 0; j < WIDGET_AA_JITTER; j++) { @@ -335,7 +335,7 @@ Gwn_Batch *ui_batch_roundbox_widget_get(int tria) vcount += ((WIDGET_CURVE_RESOLU * 2) * 2) * WIDGET_AA_JITTER; /* emboss */ if (tria) { vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria1 */ - if (!ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW)) { + if (!ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW, ROUNDBOX_TRIA_MENU)) { vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria2 */ } } @@ -1500,6 +1500,8 @@ float UI_text_clip_middle_ex( BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); } + BLI_assert(strwidth <= okwidth); + return strwidth; } @@ -2657,18 +2659,22 @@ static void widget_state_pie_menu_item(uiWidgetType *wt, int state) copy_v4_v4_char(wt->wcol.inner, wt->wcol.item); wt->wcol.inner[3] = 64; } - /* regular disabled */ - else if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { - widget_state_blend(wt->wcol.text, wt->wcol.inner, 0.5f); - } - /* regular active */ - else if (state & UI_SELECT) { - copy_v4_v4_char(wt->wcol.outline, wt->wcol.inner_sel); - copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); - } - else if (state & UI_ACTIVE) { - copy_v4_v4_char(wt->wcol.inner, wt->wcol.item); - copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); + else { + /* regular active */ + if (state & (UI_SELECT | UI_ACTIVE)) { + copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); + } + else if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { + /* regular disabled */ + widget_state_blend(wt->wcol.text, wt->wcol.inner, 0.5f); + } + + if (state & UI_SELECT) { + copy_v4_v4_char(wt->wcol.outline, wt->wcol.inner_sel); + } + else if (state & UI_ACTIVE) { + copy_v4_v4_char(wt->wcol.inner, wt->wcol.item); + } } } @@ -2685,14 +2691,19 @@ static void widget_state_menu_item(uiWidgetType *wt, int state) copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); wt->wcol.inner[3] = 64; } - /* regular disabled */ - else if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { - widget_state_blend(wt->wcol.text, wt->wcol.inner, 0.5f); - } - /* regular active */ - else if (state & UI_ACTIVE) { - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); - copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); + else { + /* regular active */ + if (state & UI_ACTIVE) { + copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); + } + else if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { + /* regular disabled */ + widget_state_blend(wt->wcol.text, wt->wcol.inner, 0.5f); + } + + if (state & UI_ACTIVE) { + copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + } } } diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 8bd41b874f5..a04b25672de 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -48,9 +48,9 @@ #include "BKE_addon.h" #include "BKE_appdir.h" #include "BKE_colorband.h" -#include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_main.h" +#include "BKE_mesh_runtime.h" #include "BIF_gl.h" @@ -1856,9 +1856,9 @@ void init_userdef_do_versions(Main *bmain) U.fcu_inactive_alpha = 0.25f; } - /* signal for derivedmesh to use colorband */ + /* signal for evaluated mesh to use colorband */ /* run in case this was on and is now off in the user prefs [#28096] */ - vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, UI_GetTheme()->tv3d.vertex_unreferenced); + BKE_mesh_runtime_color_band_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, UI_GetTheme()->tv3d.vertex_unreferenced); if (!USER_VERSION_ATLEAST(192, 0)) { strcpy(U.sounddir, "/"); @@ -2920,7 +2920,7 @@ void init_userdef_do_versions(Main *bmain) U.flag &= ~( USER_FLAG_DEPRECATED_1 | USER_FLAG_DEPRECATED_2 | USER_FLAG_DEPRECATED_3 | USER_FLAG_DEPRECATED_6 | USER_FLAG_DEPRECATED_7 | - USER_FLAG_DEPRECATED_9 | USER_FLAG_DEPRECATED_10); + USER_FLAG_DEPRECATED_9 | USER_DEVELOPER_UI); U.uiflag &= ~( USER_UIFLAG_DEPRECATED_7); U.transopts &= ~( diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index cf4d8ebf05d..405c19f1c1d 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -33,13 +33,14 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "DNA_meshdata_types.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" -#include "BKE_DerivedMesh.h" +#include "BKE_context.h" +#include "BKE_customdata.h" #include "BKE_global.h" #include "BKE_mesh.h" -#include "BKE_context.h" #include "BIF_gl.h" @@ -61,7 +62,7 @@ void paintface_flush_flags(Object *ob, short flag) { Mesh *me = BKE_mesh_from_object(ob); - DerivedMesh *dm = ob->derivedFinal; + Mesh *me_eval = ob->runtime.mesh_eval; MPoly *polys, *mp_orig; const int *index_array = NULL; int totpoly; @@ -80,14 +81,14 @@ void paintface_flush_flags(Object *ob, short flag) BKE_mesh_flush_select_from_polys(me); } - if (dm == NULL) + if (me_eval == NULL) return; /* Mesh polys => Final derived polys */ - if ((index_array = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX))) { - polys = dm->getPolyArray(dm); - totpoly = dm->getNumPolys(dm); + if ((index_array = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX))) { + polys = me_eval->mpoly; + totpoly = me_eval->totpoly; /* loop over final derived polys */ for (i = 0; i < totpoly; i++) { @@ -474,8 +475,8 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten void paintvert_flush_flags(Object *ob) { Mesh *me = BKE_mesh_from_object(ob); - DerivedMesh *dm = ob->derivedFinal; - MVert *dm_mvert, *dm_mv; + Mesh *me_eval = ob->runtime.mesh_eval; + MVert *mvert_eval, *mv; const int *index_array = NULL; int totvert; int i; @@ -487,28 +488,28 @@ void paintvert_flush_flags(Object *ob) * since this could become slow for realtime updates (circle-select for eg) */ BKE_mesh_flush_select_from_verts(me); - if (dm == NULL) + if (me_eval == NULL) return; - index_array = dm->getVertDataArray(dm, CD_ORIGINDEX); + index_array = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX); - dm_mvert = dm->getVertArray(dm); - totvert = dm->getNumVerts(dm); + mvert_eval = me_eval->mvert; + totvert = me_eval->totvert; - dm_mv = dm_mvert; + mv = mvert_eval; if (index_array) { int orig_index; - for (i = 0; i < totvert; i++, dm_mv++) { + for (i = 0; i < totvert; i++, mv++) { orig_index = index_array[i]; if (orig_index != ORIGINDEX_NONE) { - dm_mv->flag = me->mvert[index_array[i]].flag; + mv->flag = me->mvert[index_array[i]].flag; } } } else { - for (i = 0; i < totvert; i++, dm_mv++) { - dm_mv->flag = me->mvert[i].flag; + for (i = 0; i < totvert; i++, mv++) { + mv->flag = me->mvert[i].flag; } } diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index c51a57e27b3..2041852c9ee 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -657,7 +657,7 @@ void MESH_OT_bevel(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR | OPTYPE_BLOCKING; RNA_def_enum(ot->srna, "offset_type", offset_type_items, 0, "Amount Type", "What distance Amount measures"); - prop = RNA_def_float(ot->srna, "offset", 0.0f, -1e6f, 1e6f, "Amount", "", 0.0f, 1.0f); + prop = RNA_def_float(ot->srna, "offset", 0.0f, -1e6f, 1e6f, "Amount", "", 0.0f, 100.0f); RNA_def_property_float_array_funcs_runtime(prop, NULL, NULL, mesh_ot_bevel_offset_range_func); RNA_def_int(ot->srna, "segments", 1, 1, SEGMENTS_HARD_MAX, "Segments", "Segments for curved edge", 1, 8); RNA_def_float(ot->srna, "profile", 0.5f, PROFILE_HARD_MIN, 1.0f, "Profile", diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 64e6b477abe..5481c52269d 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -1035,7 +1035,7 @@ void EDBM_verts_mirror_cache_begin_ex( BM_mesh_elem_index_ensure(bm, BM_VERT); if (use_topology) { - ED_mesh_mirrtopo_init__real_mesh(me, NULL, &mesh_topo_store, true); + ED_mesh_mirrtopo_init(me, NULL, &mesh_topo_store, true); } else { tree = BLI_kdtree_new(bm->totvert); diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 46b84f328cc..b4588257412 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -584,8 +584,8 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e MEM_freeN(me->edit_btmesh); me->edit_btmesh = NULL; - /* load_editMesh free's pointers used by CustomData layers which might be used by DerivedMesh too, - * so signal to re-create DerivedMesh here (sergey) */ + /* load_editMesh free's pointers used by CustomData layers which might be used by evaluated mesh too, + * so signal to re-create evaluated mesh here (sergey) */ DEG_id_tag_update(&me->id, 0); } diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c index 4c078d2ac8b..4b526915551 100644 --- a/source/blender/editors/mesh/mesh_mirror.c +++ b/source/blender/editors/mesh/mesh_mirror.c @@ -32,9 +32,9 @@ #include "BLI_bitmap.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" -#include "BKE_DerivedMesh.h" #include "BLI_kdtree.h" #include "BKE_editmesh.h" #include "BKE_library.h" @@ -52,11 +52,11 @@ static struct { void *tree; } MirrKdStore = {NULL}; /* mode is 's' start, or 'e' end, or 'u' use */ /* if end, ob can be NULL */ -int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, DerivedMesh *dm, const float co[3], char mode) +int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, Mesh *me_eval, const float co[3], char mode) { if (mode == 'u') { /* use table */ if (MirrKdStore.tree == NULL) - ED_mesh_mirror_spatial_table(ob, em, dm, NULL, 's'); + ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's'); if (MirrKdStore.tree) { KDTreeNearest nearest; @@ -72,11 +72,11 @@ int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, DerivedMesh *dm, co } else if (mode == 's') { /* start table */ Mesh *me = ob->data; - const bool use_em = (!dm && em && me->edit_btmesh == em); - const int totvert = use_em ? em->bm->totvert : dm ? dm->getNumVerts(dm) : me->totvert; + const bool use_em = (!me_eval && em && me->edit_btmesh == em); + const int totvert = use_em ? em->bm->totvert : me_eval ? me_eval->totvert : me->totvert; if (MirrKdStore.tree) /* happens when entering this call without ending it */ - ED_mesh_mirror_spatial_table(ob, em, dm, co, 'e'); + ED_mesh_mirror_spatial_table(ob, em, me_eval, co, 'e'); MirrKdStore.tree = BLI_kdtree_new(totvert); @@ -93,73 +93,7 @@ int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, DerivedMesh *dm, co } } else { - MVert *mvert = dm ? dm->getVertArray(dm) : me->mvert; - int i; - - for (i = 0; i < totvert; i++, mvert++) { - BLI_kdtree_insert(MirrKdStore.tree, i, mvert->co); - } - } - - BLI_kdtree_balance(MirrKdStore.tree); - } - else if (mode == 'e') { /* end table */ - if (MirrKdStore.tree) { - BLI_kdtree_free(MirrKdStore.tree); - MirrKdStore.tree = NULL; - } - } - else { - BLI_assert(0); - } - - return 0; -} - -/* mode is 's' start, or 'e' end, or 'u' use */ -/* if end, ob can be NULL */ -int ED_mesh_mirror_spatial_table__real_mesh(Object *ob, BMEditMesh *em, Mesh *mesh, const float co[3], char mode) -{ - if (mode == 'u') { /* use table */ - if (MirrKdStore.tree == NULL) - ED_mesh_mirror_spatial_table__real_mesh(ob, em, mesh, NULL, 's'); - - if (MirrKdStore.tree) { - KDTreeNearest nearest; - const int i = BLI_kdtree_find_nearest(MirrKdStore.tree, co, &nearest); - - if (i != -1) { - if (nearest.dist < KD_THRESH) { - return i; - } - } - } - return -1; - } - else if (mode == 's') { /* start table */ - Mesh *me = ob->data; - const bool use_em = (!mesh && em && me->edit_btmesh == em); - const int totvert = use_em ? em->bm->totvert : mesh ? mesh->totvert : me->totvert; - - if (MirrKdStore.tree) /* happens when entering this call without ending it */ - ED_mesh_mirror_spatial_table__real_mesh(ob, em, mesh, co, 'e'); - - MirrKdStore.tree = BLI_kdtree_new(totvert); - - if (use_em) { - BMVert *eve; - BMIter iter; - int i; - - /* this needs to be valid for index lookups later (callers need) */ - BM_mesh_elem_table_ensure(em->bm, BM_VERT); - - BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) { - BLI_kdtree_insert(MirrKdStore.tree, i, eve->co); - } - } - else { - MVert *mvert = mesh ? mesh->mvert : me->mvert; + MVert *mvert = me_eval ? me_eval->mvert : me->mvert; int i; for (i = 0; i < totvert; i++, mvert++) { @@ -209,46 +143,15 @@ static int mirrtopo_vert_sort(const void *v1, const void *v2) return 0; } -bool ED_mesh_mirrtopo_recalc_check(Mesh *me, DerivedMesh *dm, MirrTopoStore_t *mesh_topo_store) -{ - const bool is_editmode = (me->edit_btmesh != NULL); - int totvert; - int totedge; - - if (dm) { - totvert = dm->getNumVerts(dm); - totedge = dm->getNumEdges(dm); - } - else if (me->edit_btmesh) { - totvert = me->edit_btmesh->bm->totvert; - totedge = me->edit_btmesh->bm->totedge; - } - else { - totvert = me->totvert; - totedge = me->totedge; - } - - if ((mesh_topo_store->index_lookup == NULL) || - (mesh_topo_store->prev_is_editmode != is_editmode) || - (totvert != mesh_topo_store->prev_vert_tot) || - (totedge != mesh_topo_store->prev_edge_tot)) - { - return true; - } - else { - return false; - } - -} -bool ED_mesh_mirrtopo_recalc_check__real_mesh(Mesh *me, Mesh *dm, MirrTopoStore_t *mesh_topo_store) +bool ED_mesh_mirrtopo_recalc_check(Mesh *me, Mesh *me_eval, MirrTopoStore_t *mesh_topo_store) { const bool is_editmode = (me->edit_btmesh != NULL); int totvert; int totedge; - if (dm) { - totvert = dm->totvert; - totedge = dm->totedge; + if (me_eval) { + totvert = me_eval->totvert; + totedge = me_eval->totedge; } else if (me->edit_btmesh) { totvert = me->edit_btmesh->bm->totvert; @@ -272,33 +175,13 @@ bool ED_mesh_mirrtopo_recalc_check__real_mesh(Mesh *me, Mesh *dm, MirrTopoStore_ } - void ED_mesh_mirrtopo_init( - Mesh *me, DerivedMesh *dm, MirrTopoStore_t *mesh_topo_store, - const bool skip_em_vert_array_init) -{ - Mesh *fake_mesh = NULL; - - if (dm != NULL) { - /* ED_real_mesh_mirrtopo_init() only uses the counts, not the actual data */ - fake_mesh = BKE_mesh_new_nomain(dm->getNumVerts(dm), dm->getNumEdges(dm), dm->getNumTessFaces(dm), - dm->getNumLoops(dm), dm->getNumPolys(dm)); - } - - ED_mesh_mirrtopo_init__real_mesh(me, fake_mesh, mesh_topo_store, skip_em_vert_array_init); - - if (dm != NULL) { - BKE_id_free(NULL, fake_mesh); - } -} - -void ED_mesh_mirrtopo_init__real_mesh( - Mesh *me, Mesh *dm, MirrTopoStore_t *mesh_topo_store, + Mesh *me, Mesh *me_eval, MirrTopoStore_t *mesh_topo_store, const bool skip_em_vert_array_init) { const bool is_editmode = (me->edit_btmesh != NULL); MEdge *medge = NULL, *med; - BMEditMesh *em = dm ? NULL : me->edit_btmesh; + BMEditMesh *em = me_eval ? NULL : me->edit_btmesh; /* editmode*/ BMEdge *eed; @@ -327,7 +210,7 @@ void ED_mesh_mirrtopo_init__real_mesh( totvert = em->bm->totvert; } else { - totvert = dm ? dm->totvert : me->totvert; + totvert = me_eval ? me_eval->totvert : me->totvert; } topo_hash = MEM_callocN(totvert * sizeof(MirrTopoHash_t), "TopoMirr"); @@ -343,8 +226,8 @@ void ED_mesh_mirrtopo_init__real_mesh( } } else { - totedge = dm ? dm->totedge : me->totedge; - medge = dm ? dm->medge : me->medge; + totedge = me_eval ? me_eval->totedge : me->totedge; + medge = me_eval ? me_eval->medge : me->medge; for (a = 0, med = medge; a < totedge; a++, med++) { const unsigned int i1 = med->v1, i2 = med->v2; diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 6c8de1a481e..537056cd1ba 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -34,9 +34,10 @@ #include "MEM_guardedalloc.h" -#include "DNA_mesh_types.h" #include "DNA_key_types.h" #include "DNA_material_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -49,11 +50,11 @@ #include "BKE_context.h" #include "BKE_deform.h" -#include "BKE_DerivedMesh.h" #include "BKE_key.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_mesh.h" +#include "BKE_mesh_iterators.h" #include "BKE_mesh_runtime.h" #include "BKE_material.h" #include "BKE_object.h" @@ -612,7 +613,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) Depsgraph *depsgraph = CTX_data_depsgraph(C); Mesh *me = (Mesh *)ob->data; Mesh *selme = NULL; - DerivedMesh *dm = NULL; + Mesh *me_deformed = NULL; Key *key = me->key; KeyBlock *kb; bool ok = false, nonequal_verts = false; @@ -646,7 +647,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) /* first key added, so it was the basis. initialize it with the existing mesh */ kb = BKE_keyblock_add(key, NULL); - BKE_keyblock_convert_from_mesh(me, kb); + BKE_keyblock_convert_from_mesh(me, key, kb); } /* now ready to add new keys from selected meshes */ @@ -658,15 +659,15 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) selme = (Mesh *)base->object->data; if (selme->totvert == me->totvert) { - dm = mesh_get_derived_deform(depsgraph, scene, base->object, CD_MASK_BAREMESH); + me_deformed = mesh_get_eval_deform(depsgraph, scene, base->object, CD_MASK_BAREMESH); - if (!dm) continue; + if (!me_deformed) { + continue; + } kb = BKE_keyblock_add(key, base->object->id.name + 2); - DM_to_meshkey(dm, me, kb); - - dm->release(dm); + BKE_mesh_runtime_eval_to_meshkey(me_deformed, me, kb); } } } @@ -690,40 +691,15 @@ static MirrTopoStore_t mesh_topo_store = {NULL, -1. - 1, -1}; /* mode is 's' start, or 'e' end, or 'u' use */ /* if end, ob can be NULL */ /* note, is supposed return -1 on error, which callers are currently checking for, but is not used so far */ -int ED_mesh_mirror_topo_table( - Object *ob, DerivedMesh *dm, char mode) +int ED_mesh_mirror_topo_table(Object *ob, Mesh *me_eval, char mode) { if (mode == 'u') { /* use table */ - if (ED_mesh_mirrtopo_recalc_check(ob->data, dm, &mesh_topo_store)) { - ED_mesh_mirror_topo_table(ob, dm, 's'); + if (ED_mesh_mirrtopo_recalc_check(ob->data, me_eval, &mesh_topo_store)) { + ED_mesh_mirror_topo_table(ob, me_eval, 's'); } } else if (mode == 's') { /* start table */ - ED_mesh_mirrtopo_init(ob->data, dm, &mesh_topo_store, false); - } - else if (mode == 'e') { /* end table */ - ED_mesh_mirrtopo_free(&mesh_topo_store); - } - else { - BLI_assert(0); - } - - return 0; -} - -/* mode is 's' start, or 'e' end, or 'u' use */ -/* if end, ob can be NULL */ -/* note, is supposed return -1 on error, which callers are currently checking for, but is not used so far */ -int ED_mesh_mirror_topo_table__real_mesh( - Object *ob, Mesh *mesh, char mode) -{ - if (mode == 'u') { /* use table */ - if (ED_mesh_mirrtopo_recalc_check__real_mesh(ob->data, mesh, &mesh_topo_store)) { - ED_mesh_mirror_topo_table__real_mesh(ob, mesh, 's'); - } - } - else if (mode == 's') { /* start table */ - ED_mesh_mirrtopo_init__real_mesh(ob->data, mesh, &mesh_topo_store, false); + ED_mesh_mirrtopo_init(ob->data, me_eval, &mesh_topo_store, false); } else if (mode == 'e') { /* end table */ ED_mesh_mirrtopo_free(&mesh_topo_store); @@ -738,39 +714,7 @@ int ED_mesh_mirror_topo_table__real_mesh( /** \} */ -static int mesh_get_x_mirror_vert_spatial(Object *ob, DerivedMesh *dm, int index) -{ - Mesh *me = ob->data; - MVert *mvert = dm ? dm->getVertArray(dm) : me->mvert; - float vec[3]; - - mvert = &mvert[index]; - vec[0] = -mvert->co[0]; - vec[1] = mvert->co[1]; - vec[2] = mvert->co[2]; - - return ED_mesh_mirror_spatial_table(ob, NULL, dm, vec, 'u'); -} - -static int mesh_get_x_mirror_vert_topo(Object *ob, DerivedMesh *dm, int index) -{ - if (ED_mesh_mirror_topo_table(ob, dm, 'u') == -1) - return -1; - - return mesh_topo_store.index_lookup[index]; -} - -int mesh_get_x_mirror_vert(Object *ob, DerivedMesh *dm, int index, const bool use_topology) -{ - if (use_topology) { - return mesh_get_x_mirror_vert_topo(ob, dm, index); - } - else { - return mesh_get_x_mirror_vert_spatial(ob, dm, index); - } -} - -static int mesh_get_x_mirror_vert_spatial__real_mesh(Object *ob, Mesh *mesh, int index) +static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *mesh, int index) { Mesh *me = ob->data; MVert *mvert = mesh ? mesh->mvert : me->mvert; @@ -781,24 +725,24 @@ static int mesh_get_x_mirror_vert_spatial__real_mesh(Object *ob, Mesh *mesh, int vec[1] = mvert->co[1]; vec[2] = mvert->co[2]; - return ED_mesh_mirror_spatial_table__real_mesh(ob, NULL, mesh, vec, 'u'); + return ED_mesh_mirror_spatial_table(ob, NULL, mesh, vec, 'u'); } -static int mesh_get_x_mirror_vert_topo__real_mesh(Object *ob, Mesh *mesh, int index) +static int mesh_get_x_mirror_vert_topo(Object *ob, Mesh *mesh, int index) { - if (ED_mesh_mirror_topo_table__real_mesh(ob, mesh, 'u') == -1) + if (ED_mesh_mirror_topo_table(ob, mesh, 'u') == -1) return -1; return mesh_topo_store.index_lookup[index]; } -int mesh_get_x_mirror_vert__real_mesh(Object *ob, Mesh *mesh, int index, const bool use_topology) +int mesh_get_x_mirror_vert(Object *ob, Mesh *me_eval, int index, const bool use_topology) { if (use_topology) { - return mesh_get_x_mirror_vert_topo__real_mesh(ob, mesh, index); + return mesh_get_x_mirror_vert_topo(ob, me_eval, index); } else { - return mesh_get_x_mirror_vert_spatial__real_mesh(ob, mesh, index); + return mesh_get_x_mirror_vert_spatial(ob, me_eval, index); } } @@ -995,68 +939,8 @@ static bool mirror_facecmp(const void *a, const void *b) return (mirror_facerotation((MFace *)a, (MFace *)b) == -1); } -/* BMESH_TODO, convert to MPoly (functions above also) */ -int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, DerivedMesh *dm) -{ - Mesh *me = ob->data; - MVert *mv, *mvert; - MFace mirrormf, *mf, *hashmf, *mface; - GHash *fhash; - int *mirrorverts, *mirrorfaces; - - BLI_assert(em == NULL); /* Does not work otherwise, currently... */ - - const bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; - const int totvert = dm ? dm->getNumVerts(dm) : me->totvert; - const int totface = dm ? dm->getNumTessFaces(dm) : me->totface; - int a; - - mirrorverts = MEM_callocN(sizeof(int) * totvert, "MirrorVerts"); - mirrorfaces = MEM_callocN(sizeof(int) * 2 * totface, "MirrorFaces"); - - mvert = dm ? dm->getVertArray(dm) : me->mvert; - mface = dm ? dm->getTessFaceArray(dm) : me->mface; - - ED_mesh_mirror_spatial_table(ob, em, dm, NULL, 's'); - - for (a = 0, mv = mvert; a < totvert; a++, mv++) - mirrorverts[a] = mesh_get_x_mirror_vert(ob, dm, a, use_topology); - - ED_mesh_mirror_spatial_table(ob, em, dm, NULL, 'e'); - - fhash = BLI_ghash_new_ex(mirror_facehash, mirror_facecmp, "mirror_facehash gh", me->totface); - for (a = 0, mf = mface; a < totface; a++, mf++) - BLI_ghash_insert(fhash, mf, mf); - - for (a = 0, mf = mface; a < totface; a++, mf++) { - mirrormf.v1 = mirrorverts[mf->v3]; - mirrormf.v2 = mirrorverts[mf->v2]; - mirrormf.v3 = mirrorverts[mf->v1]; - mirrormf.v4 = (mf->v4) ? mirrorverts[mf->v4] : 0; - - /* make sure v4 is not 0 if a quad */ - if (mf->v4 && mirrormf.v4 == 0) { - SWAP(unsigned int, mirrormf.v1, mirrormf.v3); - SWAP(unsigned int, mirrormf.v2, mirrormf.v4); - } - - hashmf = BLI_ghash_lookup(fhash, &mirrormf); - if (hashmf) { - mirrorfaces[a * 2] = hashmf - mface; - mirrorfaces[a * 2 + 1] = mirror_facerotation(&mirrormf, hashmf); - } - else - mirrorfaces[a * 2] = -1; - } - - BLI_ghash_free(fhash, NULL, NULL); - MEM_freeN(mirrorverts); - - return mirrorfaces; -} - /* This is a Mesh-based copy of mesh_get_x_mirror_faces() */ -int *mesh_get_x_mirror_faces__real_mesh(Object *ob, BMEditMesh *em, Mesh *mesh) +int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) { Mesh *me = ob->data; MVert *mv, *mvert; @@ -1067,22 +951,22 @@ int *mesh_get_x_mirror_faces__real_mesh(Object *ob, BMEditMesh *em, Mesh *mesh) BLI_assert(em == NULL); /* Does not work otherwise, currently... */ const bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; - const int totvert = mesh ? mesh->totvert : me->totvert; - const int totface = mesh ? mesh->totface : me->totface; + const int totvert = me_eval ? me_eval->totvert : me->totvert; + const int totface = me_eval ? me_eval->totface : me->totface; int a; mirrorverts = MEM_callocN(sizeof(int) * totvert, "MirrorVerts"); mirrorfaces = MEM_callocN(sizeof(int) * 2 * totface, "MirrorFaces"); - mvert = mesh ? mesh->mvert : me->mvert; - mface = mesh ? mesh->mface : me->mface; + mvert = me_eval ? me_eval->mvert : me->mvert; + mface = me_eval ? me_eval->mface : me->mface; - ED_mesh_mirror_spatial_table__real_mesh(ob, em, mesh, NULL, 's'); + ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's'); for (a = 0, mv = mvert; a < totvert; a++, mv++) - mirrorverts[a] = mesh_get_x_mirror_vert__real_mesh(ob, mesh, a, use_topology); + mirrorverts[a] = mesh_get_x_mirror_vert(ob, me_eval, a, use_topology); - ED_mesh_mirror_spatial_table__real_mesh(ob, em, mesh, NULL, 'e'); + ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 'e'); fhash = BLI_ghash_new_ex(mirror_facehash, mirror_facecmp, "mirror_facehash gh", me->totface); for (a = 0, mf = mface; a < totface; a++, mf++) @@ -1322,7 +1206,7 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int } else { /* derived mesh to find deformed locations */ - DerivedMesh *dm = mesh_get_derived_final(vc.depsgraph, vc.scene, ob, CD_MASK_BAREMESH); + Mesh *me_eval = mesh_get_eval_final(vc.depsgraph, vc.scene, ob, CD_MASK_BAREMESH); ARegion *ar = vc.ar; RegionView3D *rv3d = ar->regiondata; @@ -1334,7 +1218,7 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int ED_view3d_init_mats_rv3d(ob, rv3d); - if (dm == NULL) { + if (me_eval == NULL) { return false; } @@ -1345,9 +1229,7 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int data.len_best = FLT_MAX; data.v_idx_best = -1; - dm->foreachMappedVert(dm, ed_mesh_pick_vert__mapFunc, &data, DM_FOREACH_NOP); - - dm->release(dm); + BKE_mesh_foreach_mapped_vert(me_eval, ed_mesh_pick_vert__mapFunc, &data, MESH_FOREACH_NOP); if (data.v_idx_best == -1) { return false; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index dd358b95722..ac3f8d58de8 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -946,7 +946,7 @@ static int empty_drop_named_image_invoke(bContext *C, wmOperator *op, const wmEv /* add under the mouse */ ED_object_location_from_view(C, ob->loc); - ED_view3d_cursor3d_position(C, ob->loc, event->mval); + ED_view3d_cursor3d_position(C, event->mval, false, ob->loc); } BKE_object_empty_draw_type_set(ob, OB_EMPTY_IMAGE); @@ -1013,7 +1013,21 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; ob = ED_object_add_type(C, OB_LAMP, get_lamp_defname(type), loc, rot, false, layer); - BKE_object_obdata_size_init(ob, RNA_float_get(op->ptr, "radius")); + + float size = RNA_float_get(op->ptr, "radius"); + /* Better defaults for lamp size. */ + switch (type) { + case LA_LOCAL: + case LA_SPOT: + break; + case LA_AREA: + size *= 4.0f; + break; + default: + size *= 0.5f; + break; + } + BKE_object_obdata_size_init(ob, size); la = (Lamp *)ob->data; la->type = type; @@ -1070,7 +1084,7 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op) const int mval[2] = {event->x - ar->winrct.xmin, event->y - ar->winrct.ymin}; ED_object_location_from_view(C, loc); - ED_view3d_cursor3d_position(C, loc, mval); + ED_view3d_cursor3d_position(C, mval, false, loc); RNA_float_set_array(op->ptr, "location", loc); } } @@ -1097,8 +1111,6 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op) /* works without this except if you try render right after, see: 22027 */ DEG_relations_tag_update(bmain); - DEG_id_tag_update(&collection->id, 0); - DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); @@ -2002,9 +2014,6 @@ static int convert_exec(bContext *C, wmOperator *op) } FOREACH_SCENE_OBJECT_END; } - - /* delete object should renew depsgraph */ - DEG_relations_tag_update(bmain); } // XXX ED_object_editmode_enter(C, 0); @@ -2079,7 +2088,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer DEG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA); base = BKE_view_layer_base_find(view_layer, ob); - if ((base != NULL) && (base->flag & BASE_VISIBLED)) { + if ((base != NULL) && (base->flag & BASE_VISIBLE)) { BKE_collection_object_add_from(bmain, scene, ob, obn); } else { @@ -2426,7 +2435,7 @@ static int add_named_exec(bContext *C, wmOperator *op) const int mval[2] = {event->x - ar->winrct.xmin, event->y - ar->winrct.ymin}; ED_object_location_from_view(C, basen->object->loc); - ED_view3d_cursor3d_position(C, basen->object->loc, mval); + ED_view3d_cursor3d_position(C, mval, false, basen->object->loc); } ED_object_base_select(basen, BA_SELECT); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index a8da5c038b4..8ad0d09a9fb 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -118,6 +118,7 @@ typedef struct MultiresBakerJobData { /* data passing to multires-baker job */ typedef struct { + Scene *scene; ListBase data; bool bake_clear; /* Clear the images before baking */ int bake_filter; /* Bake-filter, aka margin */ @@ -241,7 +242,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l tmp_mmd.lvl = *lvl; tmp_mmd.sculptlvl = *lvl; - dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0); + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, 0); cddm->release(cddm); return dm; @@ -268,7 +269,7 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l tmp_mmd.lvl = mmd->totlvl; tmp_mmd.sculptlvl = mmd->totlvl; - dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0); + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, 0); cddm->release(cddm); return dm; @@ -371,6 +372,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) multires_force_update(ob); /* copy data stored in job descriptor */ + bkr.scene = scene; bkr.bake_filter = scene->r.bake_filter; bkr.mode = scene->r.bake_mode; bkr.use_lores_mesh = scene->r.bake_flag & R_BAKE_LORES_MESH; @@ -413,6 +415,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) Object *ob; /* backup scene settings, so their changing in UI would take no effect on baker */ + bkj->scene = scene; bkj->bake_filter = scene->r.bake_filter; bkj->mode = scene->r.bake_mode; bkj->use_lores_mesh = scene->r.bake_flag & R_BAKE_LORES_MESH; @@ -474,6 +477,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa MultiresBakeRender bkr = {NULL}; /* copy data stored in job descriptor */ + bkr.scene = bkj->scene; bkr.bake_filter = bkj->bake_filter; bkr.mode = bkj->mode; bkr.use_lores_mesh = bkj->use_lores_mesh; diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index db81c51cc90..788f0826848 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -40,7 +40,6 @@ #include "BKE_context.h" #include "BKE_data_transfer.h" -#include "BKE_DerivedMesh.h" #include "BKE_mesh_mapping.h" #include "BKE_mesh_remap.h" #include "BKE_mesh_runtime.h" @@ -137,20 +136,17 @@ static const EnumPropertyItem *dt_layers_select_src_itemf( Scene *scene = CTX_data_scene(C); if (ob_src) { - DerivedMesh *dm_src; - CustomData *ldata; + Mesh *me_eval; int num_data, i; - /* XXX Is this OK? */ - dm_src = mesh_get_derived_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPUV); - ldata = dm_src->getLoopDataLayout(dm_src); - num_data = CustomData_number_of_layers(ldata, CD_MLOOPUV); + me_eval = mesh_get_eval_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPUV); + num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPUV); RNA_enum_item_add_separator(&item, &totitem); for (i = 0; i < num_data; i++) { tmp_item.value = i; - tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(ldata, CD_MLOOPUV, i); + tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(&me_eval->ldata, CD_MLOOPUV, i); RNA_enum_item_add(&item, &totitem, &tmp_item); } } @@ -160,20 +156,17 @@ static const EnumPropertyItem *dt_layers_select_src_itemf( Scene *scene = CTX_data_scene(C); if (ob_src) { - DerivedMesh *dm_src; - CustomData *ldata; + Mesh *me_eval; int num_data, i; - /* XXX Is this OK? */ - dm_src = mesh_get_derived_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPCOL); - ldata = dm_src->getLoopDataLayout(dm_src); - num_data = CustomData_number_of_layers(ldata, CD_MLOOPCOL); + me_eval = mesh_get_eval_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPCOL); + num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPCOL); RNA_enum_item_add_separator(&item, &totitem); for (i = 0; i < num_data; i++) { tmp_item.value = i; - tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(ldata, CD_MLOOPCOL, i); + tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(&me_eval->ldata, CD_MLOOPCOL, i); RNA_enum_item_add(&item, &totitem, &tmp_item); } } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 45ad4bfd196..e14842c0daa 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -146,6 +146,238 @@ Object *ED_object_active_context(bContext *C) return ob; } +/* ********************** object hiding *************************** */ + +static int object_hide_poll(bContext *C) +{ + if (CTX_wm_space_outliner(C) != NULL) { + return ED_outliner_collections_editor_poll(C); + } + else { + return ED_operator_view3d_active(C); + } +} + +static int object_hide_view_clear_exec(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + const bool select = RNA_boolean_get(op->ptr, "select"); + bool changed = false; + + for (Base *base = view_layer->object_bases.first; base; base = base->next) { + if (base->flag & BASE_HIDDEN) { + base->flag &= ~BASE_HIDDEN; + changed = true; + + if (select) { + ED_object_base_select(base, BA_SELECT); + } + } + } + + if (!changed) { + return OPERATOR_CANCELLED; + } + + BKE_layer_collection_sync(scene, view_layer); + DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_hide_view_clear(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Show Hidden Objects"; + ot->description = "Reveal temporarily hidden objects"; + ot->idname = "OBJECT_OT_hide_view_clear"; + + /* api callbacks */ + ot->exec = object_hide_view_clear_exec; + ot->poll = object_hide_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + PropertyRNA *prop = RNA_def_boolean(ot->srna, "select", false, "Select", ""); + RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); +} + +static int object_hide_view_set_exec(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + const bool unselected = RNA_boolean_get(op->ptr, "unselected"); + + /* Do nothing if no objects was selected. */ + bool have_selected = false; + for (Base *base = view_layer->object_bases.first; base; base = base->next) { + if (base->flag & BASE_VISIBLE) { + if (base->flag & BASE_SELECTED) { + have_selected = true; + break; + } + } + } + + if (!have_selected) { + return OPERATOR_CANCELLED; + } + + /* Hide selected or unselected objects. */ + for (Base *base = view_layer->object_bases.first; base; base = base->next) { + if (!(base->flag & BASE_VISIBLE)) { + continue; + } + + if (!unselected) { + if (base->flag & BASE_SELECTED) { + ED_object_base_select(base, BA_DESELECT); + base->flag |= BASE_HIDDEN; + } + } + else { + if (!(base->flag & BASE_SELECTED)) { + ED_object_base_select(base, BA_DESELECT); + base->flag |= BASE_HIDDEN; + } + } + } + + BKE_layer_collection_sync(scene, view_layer); + DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_hide_view_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Hide Objects"; + ot->description = "Temporarily hide objects from the viewport"; + ot->idname = "OBJECT_OT_hide_view_set"; + + /* api callbacks */ + ot->exec = object_hide_view_set_exec; + ot->poll = object_hide_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + PropertyRNA *prop; + prop = RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); +} + +static int object_hide_collection_exec(bContext *C, wmOperator *op) +{ + int index = RNA_int_get(op->ptr, "collection_index"); + bool extend = (CTX_wm_window(C)->eventstate->shift != 0); + + if (CTX_wm_window(C)->eventstate->alt != 0) { + index += 10; + } + + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + LayerCollection *lc = BKE_layer_collection_from_index(view_layer, index); + + if (!lc) { + return OPERATOR_CANCELLED; + } + + BKE_layer_collection_set_visible(scene, view_layer, lc, extend); + + DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); + + return OPERATOR_FINISHED; +} + +#define COLLECTION_INVALID_INDEX -1 + +void ED_hide_collections_menu_draw(const bContext *C, uiLayout *layout) +{ + ViewLayer *view_layer = CTX_data_view_layer(C); + LayerCollection *lc_scene = view_layer->layer_collections.first; + + uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); + + for (LayerCollection *lc = lc_scene->layer_collections.first; lc; lc = lc->next) { + int index = BKE_layer_collection_findindex(view_layer, lc); + uiLayout *row = uiLayoutRow(layout, false); + + if (lc->collection->flag & COLLECTION_RESTRICT_VIEW) { + continue; + } + + if ((view_layer->runtime_flag & VIEW_LAYER_HAS_HIDE) && + !(lc->runtime_flag & LAYER_COLLECTION_HAS_VISIBLE_OBJECTS)) + { + uiLayoutSetActive(row, false); + } + + int icon = ICON_NONE; + if (BKE_layer_collection_has_selected_objects(view_layer, lc)) { + icon = ICON_LAYER_ACTIVE; + } + else if (lc->runtime_flag & LAYER_COLLECTION_HAS_OBJECTS) { + icon = ICON_LAYER_USED; + } + + uiItemIntO(row, + lc->collection->id.name + 2, + icon, + "OBJECT_OT_hide_collection", + "collection_index", + index); + } +} + +static int object_hide_collection_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + /* Immediately execute if collection index was specified. */ + int index = RNA_int_get(op->ptr, "collection_index"); + if (index != COLLECTION_INVALID_INDEX) { + return object_hide_collection_exec(C, op); + } + + /* Open popup menu. */ + const char *title = CTX_IFACE_(op->type->translation_context, op->type->name); + uiPopupMenu *pup = UI_popup_menu_begin(C, title, ICON_GROUP); + uiLayout *layout = UI_popup_menu_layout(pup); + + ED_hide_collections_menu_draw(C, layout); + + UI_popup_menu_end(C, pup); + + return OPERATOR_INTERFACE; +} + +void OBJECT_OT_hide_collection(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Hide Objects By Collection"; + ot->description = "Show only objects in collection (Shift to extend)"; + ot->idname = "OBJECT_OT_hide_collection"; + + /* api callbacks */ + ot->exec = object_hide_collection_exec; + ot->invoke = object_hide_collection_invoke; + ot->poll = ED_operator_view3d_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* Properties. */ + PropertyRNA *prop; + prop = RNA_def_int(ot->srna, "collection_index", COLLECTION_INVALID_INDEX, COLLECTION_INVALID_INDEX, INT_MAX, + "Collection Index", "Index of the collection to change visibility", 0, INT_MAX); + RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); +} /* ******************* toggle editmode operator ***************** */ @@ -654,7 +886,6 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev Base *base; Curve *cu, *cu1; Nurb *nu; - bool do_depgraph_update = false; if (ID_IS_LINKED(scene)) return; @@ -811,8 +1042,8 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev else if (event == 22) { /* Copy the constraint channels over */ BKE_constraints_copy(&base->object->constraints, &ob->constraints, true); - - do_depgraph_update = true; + DEG_id_tag_update(&base->object->id, DEG_TAG_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); } else if (event == 23) { base->object->softflag = ob->softflag; @@ -823,6 +1054,9 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev if (!modifiers_findByType(base->object, eModifierType_Softbody)) { BLI_addhead(&base->object->modifiers, modifier_new(eModifierType_Softbody)); } + + DEG_id_tag_update(&base->object->id, DEG_TAG_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); } else if (event == 26) { #if 0 // XXX old animation system @@ -863,9 +1097,6 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, short ev } } } - - if (do_depgraph_update) - DEG_relations_tag_update(bmain); } static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, ViewLayer *view_layer, Object *obedit) @@ -1548,8 +1779,6 @@ bool ED_object_editmode_calc_active_center(Object *obedit, const bool select_onl return false; } -#define COLLECTION_INVALID_INDEX -1 - static int move_to_collection_poll(bContext *C) { if (CTX_wm_space_outliner(C) != NULL) { @@ -1630,7 +1859,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op) is_link ? "linked" : "moved", collection->id.name + 2); - DEG_relations_tag_update(CTX_data_main(C)); + DEG_relations_tag_update(bmain); DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE); WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); @@ -1869,5 +2098,3 @@ void OBJECT_OT_link_to_collection(wmOperatorType *ot) "Name of the newly added collection"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } - -#undef COLLECTION_INVALID_INDEX diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 8a52b6c5ef5..53cabe3759e 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -47,6 +47,7 @@ #include "BKE_report.h" #include "BKE_object.h" +#include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" #include "ED_screen.h" @@ -153,6 +154,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) if (!BKE_collection_object_cyclic_check(bmain, base->object, collection)) { BKE_collection_object_add(bmain, collection, base->object); + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); updated = true; } else { @@ -223,6 +225,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { BKE_collection_object_remove(bmain, collection, base->object, false); + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); ok = 1; } CTX_DATA_END; @@ -315,6 +318,7 @@ static int collection_objects_remove_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { BKE_collection_object_remove(bmain, collection, base->object, false); + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); updated = true; } CTX_DATA_END; @@ -366,6 +370,7 @@ static int collection_create_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, selected_bases) { BKE_collection_object_add(bmain, collection, base->object); + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); } CTX_DATA_END; @@ -555,7 +560,7 @@ static int select_grouped_exec(bContext *C, wmOperator *UNUSED(op)) /* Select o CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { if (BKE_collection_has_object_recursive(collection, base->object)) { ED_object_base_select(base, BA_SELECT); } diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 18251a25b73..f7179912f52 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -76,6 +76,9 @@ void OBJECT_OT_drop_named_material(struct wmOperatorType *ot); void OBJECT_OT_unlink_data(struct wmOperatorType *ot); /* object_edit.c */ +void OBJECT_OT_hide_view_set(struct wmOperatorType *ot); +void OBJECT_OT_hide_view_clear(struct wmOperatorType *ot); +void OBJECT_OT_hide_collection(struct wmOperatorType *ot); void OBJECT_OT_mode_set(struct wmOperatorType *ot); void OBJECT_OT_mode_set_or_submode(struct wmOperatorType *ot); void OBJECT_OT_editmode_toggle(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 425a0acff17..9d7ca44ce16 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -324,8 +324,6 @@ static bool object_modifier_remove(Main *bmain, Object *ob, ModifierData *md, ob->mode &= ~OB_MODE_PARTICLE_EDIT; } - DEG_relations_tag_update(bmain); - BLI_remlink(&ob->modifiers, md); modifier_free(md); BKE_object_free_derived_caches(ob); @@ -529,9 +527,7 @@ static int modifier_apply_shape( { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; - - if (mti->isDisabled && mti->isDisabled(md, 0)) { + if (mti->isDisabled && mti->isDisabled(scene, md, 0)) { BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); return 0; } @@ -570,7 +566,7 @@ static int modifier_apply_shape( /* if that was the first key block added, then it was the basis. * Initialize it with the mesh, and add another for the modifier */ kb = BKE_keyblock_add(key, NULL); - BKE_keyblock_convert_from_mesh(me, kb); + BKE_keyblock_convert_from_mesh(me, key, kb); } kb = BKE_keyblock_add(key, md->name); @@ -589,9 +585,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene = scene; - - if (mti->isDisabled && mti->isDisabled(md, 0)) { + if (mti->isDisabled && mti->isDisabled(scene, md, 0)) { BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); return 0; } @@ -1156,13 +1150,14 @@ static int multires_poll(bContext *C) static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; - multiresModifier_del_levels(mmd, ob, 1); + multiresModifier_del_levels(mmd, scene, ob, 1); ED_object_iter_other(CTX_data_main(C), ob, true, ED_object_multires_update_totlevels_cb, @@ -1200,13 +1195,14 @@ void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot) static int multires_subdivide_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; - multiresModifier_subdivide(mmd, ob, 0, mmd->simple); + multiresModifier_subdivide(mmd, scene, ob, 0, mmd->simple); ED_object_iter_other(CTX_data_main(C), ob, true, ED_object_multires_update_totlevels_cb, @@ -1423,13 +1419,14 @@ void OBJECT_OT_multires_external_pack(wmOperatorType *ot) /********************* multires apply base ***********************/ static int multires_base_apply_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; - multiresModifier_base_apply(mmd, ob); + multiresModifier_base_apply(mmd, scene, ob); DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index c5df7fc21f8..89dd54b6f64 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -247,6 +247,10 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_data_transfer); WM_operatortype_append(OBJECT_OT_datalayout_transfer); WM_operatortype_append(OBJECT_OT_surfacedeform_bind); + + WM_operatortype_append(OBJECT_OT_hide_view_clear); + WM_operatortype_append(OBJECT_OT_hide_view_set); + WM_operatortype_append(OBJECT_OT_hide_collection); } void ED_operatormacros_object(void) @@ -293,7 +297,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT); RNA_boolean_set(kmi->ptr, "toggle", true); - kmi = WM_keymap_add_menu_pie(keymap, "VIEW3D_PIE_object_mode", TABKEY, KM_CLICK_DRAG, 0, 0); + kmi = WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_object_mode_pie", TABKEY, KM_CLICK_DRAG, 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0); @@ -404,6 +408,19 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_move_to_collection", MKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_link_to_collection", MKEY, KM_PRESS, KM_SHIFT, 0); + + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_clear", HKEY, KM_PRESS, KM_ALT, 0); + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, 0, 0); + RNA_boolean_set(kmi->ptr, "unselected", false); + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "unselected", true); + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_collection", HKEY, KM_PRESS, KM_CTRL, 0); + + /* Collection switching. */ + for (int i = 0; i < 10; i++) { + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_collection", ZEROKEY + i, KM_PRESS, KM_ANY, 0); + RNA_int_set(kmi->ptr, "collection_index", (i == 0) ? 10 : i); + } } void ED_keymap_proportional_cycle(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap) diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index a114b2cc6d5..f2e996237cf 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1419,6 +1419,7 @@ static bool allow_make_links_data(const int type, Object *ob_src, Object *ob_dst static int make_links_data_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Main *bmain = CTX_data_main(C); const int type = RNA_enum_get(op->ptr, "type"); Object *ob_src; @@ -1503,7 +1504,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } break; case MAKE_LINKS_MODIFIERS: - BKE_object_link_modifiers(ob_dst, ob_src); + BKE_object_link_modifiers(scene, ob_dst, ob_src); DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); break; case MAKE_LINKS_FONTS: diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index ce29125ac79..7d7871c0326 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -100,7 +100,7 @@ void ED_object_base_select(Base *base, eObjectSelect_Mode mode) if (base) { switch (mode) { case BA_SELECT: - if ((base->flag & BASE_SELECTABLED) != 0) { + if ((base->flag & BASE_SELECTABLE) != 0) { base->flag |= BASE_SELECTED; } break; @@ -229,7 +229,7 @@ static bool object_select_all_by_obdata(bContext *C, void *obdata) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { if (base->object->data == obdata) { ED_object_base_select(base, BA_SELECT); changed = true; @@ -247,7 +247,7 @@ static bool object_select_all_by_material(bContext *C, Material *mat) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { Object *ob = base->object; Material *mat1; int a; @@ -274,7 +274,7 @@ static bool object_select_all_by_dup_group(bContext *C, Object *ob) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { Collection *dup_group_other = (base->object->transflag & OB_DUPLICOLLECTION) ? base->object->dup_group : NULL; if (dup_group == dup_group_other) { ED_object_base_select(base, BA_SELECT); @@ -294,7 +294,7 @@ static bool object_select_all_by_particle(bContext *C, Object *ob) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { /* loop through other particles*/ ParticleSystem *psys; @@ -322,7 +322,7 @@ static bool object_select_all_by_library(bContext *C, Library *lib) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { if (lib == base->object->id.lib) { ED_object_base_select(base, BA_SELECT); changed = true; @@ -340,7 +340,7 @@ static bool object_select_all_by_library_obdata(bContext *C, Library *lib) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { if (base->object->data && lib == ((ID *)base->object->data)->lib) { ED_object_base_select(base, BA_SELECT); changed = true; @@ -568,7 +568,7 @@ static bool select_grouped_collection(bContext *C, Object *ob) /* Select object collection = ob_collections[0]; CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { if (BKE_collection_has_object(collection, base->object)) { ED_object_base_select(base, BA_SELECT); changed = true; @@ -931,7 +931,7 @@ static int object_select_same_collection_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { if (BKE_collection_has_object(collection, base->object)) { ED_object_base_select(base, BA_SELECT); } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index e926540408e..cfdeeffc434 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -410,6 +410,8 @@ typedef struct PEData { BVHTreeFromMesh shape_bvh; Depsgraph *depsgraph; + RNG *rng; + const int *mval; rcti *rect; float rad; @@ -484,6 +486,22 @@ static void PE_free_shape_tree(PEData *data) free_bvhtree_from_mesh(&data->shape_bvh); } +static void PE_create_random_generator(PEData *data) +{ + uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX); + rng_seed ^= GET_UINT_FROM_POINTER(data->ob); + rng_seed ^= GET_UINT_FROM_POINTER(data->edit); + data->rng = BLI_rng_new(rng_seed); +} + +static void PE_free_random_generator(PEData *data) +{ + if (data->rng != NULL) { + BLI_rng_free(data->rng); + data->rng = NULL; + } +} + /*************************** selection utilities *******************************/ static bool key_test_depth(PEData *data, const float co[3], const int screen_co[2]) @@ -2999,7 +3017,7 @@ static void PE_mirror_x( /* Note: In case psys uses Mesh tessface indices, we mirror final Mesh itself, not orig mesh. Avoids an (impossible) * mesh -> orig -> mesh tessface indices conversion... */ - mirrorfaces = mesh_get_x_mirror_faces__real_mesh(ob, NULL, use_dm_final_indices ? psmd_eval->mesh_final : NULL); + mirrorfaces = mesh_get_x_mirror_faces(ob, NULL, use_dm_final_indices ? psmd_eval->mesh_final : NULL); if (!edit->mirror_cache) PE_update_mirror_cache(ob, psys); @@ -3181,8 +3199,11 @@ static void brush_cut(PEData *data, int pa_index) int k, cut, keys= (int)pow(2.0, (double)pset->draw_step); int screen_co[2]; + BLI_assert(data->rng != NULL); /* blunt scissors */ - if (BLI_frand() > data->cutfac) return; + if (BLI_rng_get_float(data->rng) > data->cutfac) { + return; + } /* don't cut hidden */ if (edit->points[pa_index].flag & PEP_HIDE) @@ -4040,6 +4061,7 @@ static int brush_edit_init(bContext *C, wmOperator *op) /* cache view depths and settings for re-use */ PE_set_view3d_data(C, &bedit->data); + PE_create_random_generator(&bedit->data); return 1; } @@ -4088,7 +4110,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) if (((pset->brushtype == PE_BRUSH_ADD) ? (sqrtf(dx * dx + dy * dy) > pset->brush[PE_BRUSH_ADD].step) : (dx != 0 || dy != 0)) || bedit->first) { - PEData data= bedit->data; + PEData data = bedit->data; data.context = C; // TODO(mai): why isnt this set in bedit->data? view3d_operator_needs_opengl(C); @@ -4273,6 +4295,7 @@ static void brush_edit_exit(wmOperator *op) { BrushEdit *bedit= op->customdata; + PE_free_random_generator(&bedit->data); MEM_freeN(bedit); } diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c index f62b72679d0..1b6325e31bf 100644 --- a/source/blender/editors/physics/rigidbody_constraint.c +++ b/source/blender/editors/physics/rigidbody_constraint.c @@ -94,6 +94,8 @@ bool ED_rigidbody_constraint_add(Main *bmain, Scene *scene, Object *ob, int type DEG_relations_tag_update(bmain); DEG_id_tag_update(&ob->id, OB_RECALC_OB); + DEG_id_tag_update(&rbw->constraints->id, DEG_TAG_COPY_ON_WRITE); + return true; } @@ -102,8 +104,10 @@ void ED_rigidbody_constraint_remove(Main *bmain, Scene *scene, Object *ob) RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene); BKE_rigidbody_remove_constraint(scene, ob); - if (rbw) + if (rbw) { BKE_collection_object_remove(bmain, rbw->constraints, ob, false); + DEG_id_tag_update(&rbw->constraints->id, DEG_TAG_COPY_ON_WRITE); + } DEG_relations_tag_update(bmain); DEG_id_tag_update(&ob->id, OB_RECALC_OB); diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index bdfbc47b22f..6ea0212199e 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -125,6 +125,7 @@ bool ED_rigidbody_object_add(Main *bmain, Scene *scene, Object *ob, int type, Re DEG_relations_tag_update(bmain); DEG_id_tag_update(&ob->id, OB_RECALC_OB); + DEG_id_tag_update(&rbw->group->id, DEG_TAG_COPY_ON_WRITE); return true; } diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 6a5844e323f..1385baa51ad 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -819,7 +819,7 @@ static void screen_render_cancel(bContext *C, wmOperator *op) static void clean_viewport_memory_base(Base *base) { - if ((base->flag & BASE_VISIBLED) == 0) { + if ((base->flag & BASE_VISIBLE) == 0) { return; } diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index cdd79f43a72..d47291ca82f 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -176,9 +176,6 @@ typedef struct ShaderPreview { Main *bmain; Main *pr_main; - - void *gl_context; - bool gl_context_owner; } ShaderPreview; typedef struct IconPreviewSize { @@ -194,8 +191,6 @@ typedef struct IconPreview { void *owner; ID *id; ListBase sizes; - - void *gl_context; } IconPreview; /* *************************** Preview for buttons *********************** */ @@ -428,7 +423,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty (*matar)[actcol] = mat; } else if (base->object->type == OB_LAMP) { - base->flag |= BASE_VISIBLED; + base->flag |= BASE_VISIBLE; } } } @@ -746,10 +741,6 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs /* set this for all previews, default is react to G.is_break still */ RE_test_break_cb(re, sp, shader_preview_break); - if (sp->gl_context) { - RE_gl_context_set(re, sp->gl_context); - } - /* lens adjust */ oldlens = ((Camera *)sce->camera->data)->lens; if (sizex > sp->sizey) @@ -869,10 +860,6 @@ static void shader_preview_free(void *customdata) } MEM_freeN(sp->lampcopy); } - if (sp->gl_context_owner && sp->gl_context) { - WM_opengl_context_dispose(sp->gl_context); - sp->gl_context = NULL; - } MEM_freeN(sp); } @@ -1088,8 +1075,6 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short sp->pr_rect = cur_size->rect; sp->id = ip->id; sp->bmain = ip->bmain; - sp->gl_context = ip->gl_context; - sp->gl_context_owner = false; if (is_render) { BLI_assert(ip->id); @@ -1106,11 +1091,6 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short common_preview_startjob(sp, stop, do_update, progress); shader_preview_free(sp); } - - if (ip->gl_context) { - WM_opengl_context_dispose(ip->gl_context); - ip->gl_context = NULL; - } } static void icon_preview_endjob(void *customdata) @@ -1194,17 +1174,8 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r /* render all resolutions from suspended job too */ old_ip = WM_jobs_customdata_get(wm_job); - if (old_ip) { + if (old_ip) BLI_movelisttolist(&ip->sizes, &old_ip->sizes); - /* NOTE: This assumes that it will be the same thread - * that will be used when resuming the job. */ - ip->gl_context = old_ip->gl_context; - } - - if (ip->gl_context == NULL) { - /* Create context in the main thread. */ - ip->gl_context = WM_opengl_context_create(); - } /* customdata for preview thread */ ip->bmain = CTX_data_main(C); @@ -1235,7 +1206,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M { Object *ob = CTX_data_active_object(C); wmJob *wm_job; - ShaderPreview *sp, *old_sp; + ShaderPreview *sp; Scene *scene = CTX_data_scene(C); short id_type = GS(id->name); @@ -1252,21 +1223,6 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M WM_JOB_EXCL_RENDER, WM_JOB_TYPE_RENDER_PREVIEW); sp = MEM_callocN(sizeof(ShaderPreview), "shader preview"); - /* Reuse previous gl context. */ - old_sp = WM_jobs_customdata_get(wm_job); - if (old_sp) { - /* NOTE: This assumes that it will be the same thread - * that will be used when resuming the job. */ - old_sp->gl_context_owner = false; /* Don't free it */ - sp->gl_context = old_sp->gl_context; - } - - if (sp->gl_context == NULL) { - /* Create context in the main thread. */ - sp->gl_context = WM_opengl_context_create(); - } - sp->gl_context_owner = true; - /* customdata for preview thread */ sp->scene = scene; sp->depsgraph = CTX_data_depsgraph(C); diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index 29b9971eabb..ee114eba3c5 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -47,6 +47,7 @@ set(SRC screen_draw.c screen_edit.c screen_ops.c + screen_user_menu.c screendump.c workspace_edit.c workspace_layout_edit.c diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 864150be9da..f56a27d1bb4 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -115,7 +115,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "selectable_objects")) { for (Base *base = view_layer->object_bases.first; base; base = base->next) { - if (((base->flag & BASE_VISIBLED) != 0) && ((base->flag & BASE_SELECTABLED) != 0)) { + if (((base->flag & BASE_VISIBLE) != 0) && ((base->flag & BASE_SELECTABLE) != 0)) { CTX_data_id_list_add(result, &base->object->id); } } @@ -165,7 +165,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "selectable_bases")) { for (Base *base = view_layer->object_bases.first; base; base = base->next) { - if ((base->flag & BASE_SELECTABLED) != 0) { + if ((base->flag & BASE_SELECTABLE) != 0) { CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); } } @@ -195,7 +195,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult else if (CTX_data_equals(member, "editable_bases")) { /* Visible + Editable, but not necessarily selected */ for (Base *base = view_layer->object_bases.first; base; base = base->next) { - if ((base->flag & BASE_VISIBLED) != 0) { + if ((base->flag & BASE_VISIBLE) != 0) { if (0 == BKE_object_is_libdata(base->object)) { CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 4d7533d575c..e4de3cdfa38 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -961,7 +961,7 @@ static void screen_cursor_set(wmWindow *win, const int xy[2]) ScrArea *sa; for (sa = screen->areabase.first; sa; sa = sa->next) - if ((az = is_in_area_actionzone(sa, xy))) + if ((az = ED_area_actionzone_find_xy(sa, xy))) break; if (sa) { @@ -1003,7 +1003,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) ED_screen_areas_iter(win, scr, area_iter) { if (xy[0] > area_iter->totrct.xmin && xy[0] < area_iter->totrct.xmax) { if (xy[1] > area_iter->totrct.ymin && xy[1] < area_iter->totrct.ymax) { - if (is_in_area_actionzone(area_iter, xy) == NULL) { + if (ED_area_actionzone_refresh_xy(area_iter, xy) == NULL) { sa = area_iter; break; } @@ -1073,7 +1073,7 @@ int ED_screen_area_active(const bContext *C) ScrArea *sa = CTX_wm_area(C); if (win && sc && sa) { - AZone *az = is_in_area_actionzone(sa, &win->eventstate->x); + AZone *az = ED_area_actionzone_find_xy(sa, &win->eventstate->x); ARegion *ar; if (az && az->type == AZONE_REGION) @@ -1680,6 +1680,7 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph) for (sc = bmain->screen.first; sc; sc = sc->id.next) { BKE_screen_view3d_scene_sync(sc, scene); } + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); } #endif diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index b02198764e0..2c343fb9d70 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -67,7 +67,8 @@ ScrEdge *screen_find_active_scredge( const wmWindow *win, const bScreen *screen, const int mx, const int my); -struct AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]); +struct AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2]); +struct AZone *ED_area_actionzone_refresh_xy(ScrArea *sa, const int xy[2]); /* screen_context.c */ int ed_screen_context( diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index c2dab7e22dd..d74a9ed288c 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -669,7 +669,7 @@ static void fullscreen_click_rcti_init(rcti *rect, const short x1, const short y BLI_rcti_init(rect, x, x + icon_size, y, y + icon_size); } -AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]) +static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const bool test_only) { AZone *az = NULL; @@ -677,102 +677,117 @@ AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]) if (BLI_rcti_isect_pt_v(&az->rect, xy)) { if (az->type == AZONE_AREA) { /* no triangle intersect but a hotspot circle based on corner */ - int radius = (xy[0] - az->x1) * (xy[0] - az->x1) + (xy[1] - az->y1) * (xy[1] - az->y1); - - if (radius <= AZONESPOT * AZONESPOT) + int radius_sq = SQUARE(xy[0] - az->x1) + SQUARE(xy[1] - az->y1); + if (radius_sq <= SQUARE(AZONESPOT)) { break; + } } else if (az->type == AZONE_REGION) { break; } else if (az->type == AZONE_FULLSCREEN) { - int mouse_radius, spot_radius, fadein_radius, fadeout_radius; rcti click_rect; - fullscreen_click_rcti_init(&click_rect, az->x1, az->y1, az->x2, az->y2); + const bool click_isect = BLI_rcti_isect_pt_v(&click_rect, xy); - if (BLI_rcti_isect_pt_v(&click_rect, xy)) { - az->alpha = 1.0f; + if (test_only) { + if (click_isect) { + break; + } } else { - mouse_radius = (xy[0] - az->x2) * (xy[0] - az->x2) + (xy[1] - az->y2) * (xy[1] - az->y2); - spot_radius = AZONESPOT * AZONESPOT; - fadein_radius = AZONEFADEIN * AZONEFADEIN; - fadeout_radius = AZONEFADEOUT * AZONEFADEOUT; - - if (mouse_radius < spot_radius) { + if (click_isect) { az->alpha = 1.0f; } - else if (mouse_radius < fadein_radius) { - az->alpha = 1.0f; - } - else if (mouse_radius < fadeout_radius) { - az->alpha = 1.0f - ((float)(mouse_radius - fadein_radius)) / ((float)(fadeout_radius - fadein_radius)); - } else { - az->alpha = 0.0f; + const int mouse_sq = SQUARE(xy[0] - az->x2) + SQUARE(xy[1] - az->y2); + const int spot_sq = SQUARE(AZONESPOT); + const int fadein_sq = SQUARE(AZONEFADEIN); + const int fadeout_sq = SQUARE(AZONEFADEOUT); + + if (mouse_sq < spot_sq) { + az->alpha = 1.0f; + } + else if (mouse_sq < fadein_sq) { + az->alpha = 1.0f; + } + else if (mouse_sq < fadeout_sq) { + az->alpha = 1.0f - ((float)(mouse_sq - fadein_sq)) / ((float)(fadeout_sq - fadein_sq)); + } + else { + az->alpha = 0.0f; + } + + /* fade in/out but no click */ + az = NULL; } - /* fade in/out but no click */ - az = NULL; + /* XXX force redraw to show/hide the action zone */ + ED_area_tag_redraw(sa); + break; } - - /* XXX force redraw to show/hide the action zone */ - ED_area_tag_redraw_no_rebuild(sa); - break; } else if (az->type == AZONE_REGION_SCROLL) { ARegion *ar = az->ar; View2D *v2d = &ar->v2d; const short isect_value = UI_view2d_mouse_in_scrollers(ar, v2d, xy[0], xy[1]); - bool redraw = false; - - if (isect_value == 'h') { - if (az->direction == AZ_SCROLL_HOR) { - az->alpha = 1.0f; - v2d->alpha_hor = 255; - v2d->size_hor = V2D_SCROLL_HEIGHT; - redraw = true; - } - } - else if (isect_value == 'v') { - if (az->direction == AZ_SCROLL_VERT) { - az->alpha = 1.0f; - v2d->alpha_vert = 255; - v2d->size_vert = V2D_SCROLL_WIDTH; - redraw = true; + if (test_only) { + if (isect_value != 0) { + break; } } else { - const int local_xy[2] = {xy[0] - ar->winrct.xmin, xy[1] - ar->winrct.ymin}; - float dist_fac = 0.0f, alpha = 0.0f; - - if (az->direction == AZ_SCROLL_HOR) { - dist_fac = BLI_rcti_length_y(&v2d->hor, local_xy[1]) / AZONEFADEIN; - CLAMP(dist_fac, 0.0f, 1.0f); - alpha = 1.0f - dist_fac; + bool redraw = false; - v2d->alpha_hor = alpha * 255; - v2d->size_hor = round_fl_to_int(V2D_SCROLL_HEIGHT - - ((V2D_SCROLL_HEIGHT - V2D_SCROLL_HEIGHT_MIN) * dist_fac)); + if (isect_value == 'h') { + if (az->direction == AZ_SCROLL_HOR) { + az->alpha = 1.0f; + v2d->alpha_hor = 255; + v2d->size_hor = V2D_SCROLL_HEIGHT; + redraw = true; + } } - else if (az->direction == AZ_SCROLL_VERT) { - dist_fac = BLI_rcti_length_x(&v2d->vert, local_xy[0]) / AZONEFADEIN; - CLAMP(dist_fac, 0.0f, 1.0f); - alpha = 1.0f - dist_fac; - - v2d->alpha_vert = alpha * 255; - v2d->size_vert = round_fl_to_int(V2D_SCROLL_WIDTH - - ((V2D_SCROLL_WIDTH - V2D_SCROLL_WIDTH_MIN) * dist_fac)); + else if (isect_value == 'v') { + if (az->direction == AZ_SCROLL_VERT) { + az->alpha = 1.0f; + v2d->alpha_vert = 255; + v2d->size_vert = V2D_SCROLL_WIDTH; + redraw = true; + } + } + else { + const int local_xy[2] = {xy[0] - ar->winrct.xmin, xy[1] - ar->winrct.ymin}; + float dist_fac = 0.0f, alpha = 0.0f; + + if (az->direction == AZ_SCROLL_HOR) { + dist_fac = BLI_rcti_length_y(&v2d->hor, local_xy[1]) / AZONEFADEIN; + CLAMP(dist_fac, 0.0f, 1.0f); + alpha = 1.0f - dist_fac; + + v2d->alpha_hor = alpha * 255; + v2d->size_hor = round_fl_to_int( + V2D_SCROLL_HEIGHT - + ((V2D_SCROLL_HEIGHT - V2D_SCROLL_HEIGHT_MIN) * dist_fac)); + } + else if (az->direction == AZ_SCROLL_VERT) { + dist_fac = BLI_rcti_length_x(&v2d->vert, local_xy[0]) / AZONEFADEIN; + CLAMP(dist_fac, 0.0f, 1.0f); + alpha = 1.0f - dist_fac; + + v2d->alpha_vert = alpha * 255; + v2d->size_vert = round_fl_to_int( + V2D_SCROLL_WIDTH - + ((V2D_SCROLL_WIDTH - V2D_SCROLL_WIDTH_MIN) * dist_fac)); + } + az->alpha = alpha; + redraw = true; } - az->alpha = alpha; - redraw = true; - } - if (redraw) { - ED_area_tag_redraw_no_rebuild(sa); + if (redraw) { + ED_area_tag_redraw_no_rebuild(sa); + } + /* Don't return! */ } - /* Don't return! */ } } } @@ -780,6 +795,15 @@ AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]) return az; } +AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2]) +{ + return area_actionzone_refresh_xy(sa, xy, true); +} + +AZone *ED_area_actionzone_refresh_xy(ScrArea *sa, const int xy[2]) +{ + return area_actionzone_refresh_xy(sa, xy, false); +} static void actionzone_exit(wmOperator *op) { @@ -817,7 +841,7 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type) static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ScrArea *sa = CTX_wm_area(C); - AZone *az = is_in_area_actionzone(sa, &event->x); + AZone *az = ED_area_actionzone_find_xy(sa, &event->x); sActionzoneData *sad; /* quick escape */ @@ -878,7 +902,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) WM_window_screen_rect_calc(win, &screen_rect); /* once we drag outside the actionzone, register a gesture * check we're not on an edge so join finds the other area */ - is_gesture = ((is_in_area_actionzone(sad->sa1, &event->x) != sad->az) && + is_gesture = ((ED_area_actionzone_find_xy(sad->sa1, &event->x) != sad->az) && (screen_area_map_find_active_scredge( AREAMAP_FROM_SCREEN(sc), &screen_rect, event->x, event->y) == NULL)); } @@ -4808,7 +4832,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) /* tests */ WM_keymap_add_item(keymap, "SCREEN_OT_region_quadview", QKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); - WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", F3KEY, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", RKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/screen/screen_user_menu.c b/source/blender/editors/screen/screen_user_menu.c new file mode 100644 index 00000000000..d942602c896 --- /dev/null +++ b/source/blender/editors/screen/screen_user_menu.c @@ -0,0 +1,164 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/screen/screen_user_menu.c + * \ingroup spview3d + */ + +#include <string.h> +#include <stdio.h> +#include <math.h> +#include <float.h> + +#include "DNA_scene_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" +#include "BLI_listbase.h" +#include "BLI_string.h" + +#include "BLT_translation.h" + +#include "BKE_blender_user_menu.h" +#include "BKE_context.h" +#include "BKE_screen.h" +#include "BKE_idprop.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +/* -------------------------------------------------------------------- */ +/** \name Menu Type + * \{ */ + +bUserMenu *ED_screen_user_menu_find(bContext *C) +{ + SpaceLink *sl = CTX_wm_space_data(C); + const char *context = CTX_data_mode_string(C); + return BKE_blender_user_menu_find(&U.user_menus, sl->spacetype, context); +} + +bUserMenu *ED_screen_user_menu_ensure(bContext *C) +{ + SpaceLink *sl = CTX_wm_space_data(C); + const char *context = CTX_data_mode_string(C); + return BKE_blender_user_menu_ensure(&U.user_menus, sl->spacetype, context); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Menu Item + * \{ */ + +bUserMenuItem_Op *ED_screen_user_menu_item_find_operator( + ListBase *lb, + wmOperatorType *ot, IDProperty *prop, short opcontext) +{ + for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) { + if (umi->type == USER_MENU_TYPE_OPERATOR) { + bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; + if (STREQ(ot->idname, umi_op->opname) && + (opcontext == umi_op->opcontext) && + (IDP_EqualsProperties(prop, umi_op->prop))) + { + return umi_op; + } + } + } + return NULL; +} + +void ED_screen_user_menu_item_add_operator( + ListBase *lb, const char *ui_name, + wmOperatorType *ot, IDProperty *prop, short opcontext) +{ + bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)BKE_blender_user_menu_item_add(lb, USER_MENU_TYPE_OPERATOR); + umi_op->opcontext = opcontext; + if (!STREQ(ui_name, ot->name)) { + BLI_strncpy(umi_op->item.ui_name, ui_name, OP_MAX_TYPENAME); + } + BLI_strncpy(umi_op->opname, ot->idname, OP_MAX_TYPENAME); + umi_op->prop = prop ? IDP_CopyProperty(prop) : NULL; +} + +void ED_screen_user_menu_item_remove(ListBase *lb, bUserMenuItem *umi) +{ + BLI_remlink(lb, umi); + BKE_blender_user_menu_item_free(umi); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Menu Definition + * \{ */ + +static void screen_user_menu_draw(const bContext *C, Menu *menu) +{ + SpaceLink *sl = CTX_wm_space_data(C); + const char *context = CTX_data_mode_string(C); + bUserMenu *um_array[] = { + BKE_blender_user_menu_find(&U.user_menus, sl->spacetype, context), + (sl->spacetype != SPACE_TOPBAR) ? BKE_blender_user_menu_find(&U.user_menus, SPACE_TOPBAR, context) : NULL, + }; + for (int um_index = 0; um_index < ARRAY_SIZE(um_array); um_index++) { + bUserMenu *um = um_array[um_index]; + if (um == NULL) { + continue; + } + for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) { + if (umi->type == USER_MENU_TYPE_OPERATOR) { + bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; + IDProperty *prop = umi_op->prop ? IDP_CopyProperty(umi_op->prop) : NULL; + uiItemFullO( + menu->layout, umi_op->opname, umi->ui_name[0] ? umi->ui_name : NULL, + ICON_NONE, prop, umi_op->opcontext, 0, NULL); + } + else if (umi->type == USER_MENU_TYPE_SEP) { + uiItemS(menu->layout); + } + } + } +} + +void ED_screen_user_menu_register(void) +{ + MenuType *mt = MEM_callocN(sizeof(MenuType), __func__); + strcpy(mt->idname, "SCREEN_MT_user_menu"); + strcpy(mt->label, "Quick Favorites"); + strcpy(mt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); + mt->draw = screen_user_menu_draw; + WM_menutype_add(mt); +} + +/** \} */ diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index af0b828ae39..e2100ceb066 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -714,7 +714,7 @@ static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const w break; } default: - ED_view3d_cursor3d_update(C, event->mval); + ED_view3d_cursor3d_update(C, event->mval, true, V3D_CURSOR_ORIENT_VIEW); break; } diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index ac5b0624d56..4deec54a5b3 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -46,7 +46,6 @@ #include "BKE_pbvh.h" #include "BKE_ccg.h" #include "BKE_context.h" -#include "BKE_DerivedMesh.h" #include "BKE_mesh.h" #include "BKE_mesh_runtime.h" #include "BKE_multires.h" diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 93fa3aac0d7..3c097095ddc 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -46,15 +46,16 @@ #include "IMB_imbuf_types.h" #include "DNA_brush_types.h" +#include "DNA_mesh_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "BKE_colorband.h" #include "BKE_context.h" -#include "BKE_DerivedMesh.h" #include "BKE_brush.h" #include "BKE_main.h" #include "BKE_material.h" +#include "BKE_mesh.h" #include "BKE_node.h" #include "BKE_paint.h" #include "BKE_undo_system.h" @@ -1055,6 +1056,7 @@ static int texture_paint_toggle_poll(bContext *C) static int texture_paint_toggle_exec(bContext *C, wmOperator *op) { struct wmMsgBus *mbus = CTX_wm_message_bus(C); + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); const int mode_flag = OB_MODE_TEXTURE_PAINT; @@ -1070,14 +1072,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) ob->mode &= ~mode_flag; if (U.glreslimit != 0) - GPU_free_images(); - GPU_paint_set_mipmap(1); + GPU_free_images(bmain); + GPU_paint_set_mipmap(bmain, 1); toggle_paint_cursor(C, 0); } else { bScreen *sc; - Main *bmain = CTX_data_main(C); Image *ima = NULL; ImagePaintSettings *imapaint = &scene->toolsettings->imapaint; @@ -1122,12 +1123,16 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) BKE_paint_init(bmain, scene, ePaintTextureProjective, PAINT_CURSOR_TEXTURE_PAINT); if (U.glreslimit != 0) - GPU_free_images(); - GPU_paint_set_mipmap(0); + GPU_free_images(bmain); + GPU_paint_set_mipmap(bmain, 0); toggle_paint_cursor(C, 1); } + Mesh *me = BKE_mesh_from_object(ob); + BLI_assert(me != NULL); + DEG_id_tag_update(&me->id, DEG_TAG_COPY_ON_WRITE); + WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene); WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 62bc379241f..bbf1da2d584 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -58,6 +58,7 @@ #include "DNA_brush_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" @@ -65,7 +66,6 @@ #include "BKE_colorband.h" #include "BKE_context.h" #include "BKE_colortools.h" -#include "BKE_DerivedMesh.h" #include "BKE_idprop.h" #include "BKE_brush.h" #include "BKE_image.h" diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index f22e6f514e6..4a338e65d79 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -45,7 +45,6 @@ #include "BKE_pbvh.h" #include "BKE_ccg.h" #include "BKE_context.h" -#include "BKE_DerivedMesh.h" #include "BKE_multires.h" #include "BKE_paint.h" #include "BKE_subsurf.h" diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c index cacfdc2dbba..602bfe1ab8e 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_proj.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.c @@ -28,7 +28,7 @@ * \ingroup edsculpt * * Utility functions for getting vertex locations while painting - * (since they may be instanced multiple times in a DerivedMesh) + * (since they may be instanced multiple times in an evaluated mesh) */ #include "MEM_guardedalloc.h" @@ -39,8 +39,9 @@ #include "DNA_mesh_types.h" #include "DNA_object_types.h" -#include "BKE_DerivedMesh.h" +#include "BKE_DerivedMesh.h" /* XXX To be removed, only used for DMCoNo struct */ #include "BKE_context.h" +#include "BKE_mesh_iterators.h" #include "BKE_mesh_runtime.h" #include "DEG_depsgraph.h" @@ -107,24 +108,10 @@ static void vpaint_proj_dm_map_cosnos_init( struct VertProjHandle *vp_handle) { Mesh *me = ob->data; - DerivedMesh *dm; + Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); - dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); - - if (dm->foreachMappedVert) { - memset(vp_handle->vcosnos, 0, sizeof(DMCoNo) * me->totvert); - dm->foreachMappedVert(dm, vpaint_proj_dm_map_cosnos_init__map_cb, vp_handle, DM_FOREACH_USE_NORMAL); - } - else { - DMCoNo *v_co_no = vp_handle->vcosnos; - int a; - for (a = 0; a < me->totvert; a++, v_co_no++) { - dm->getVertCo(dm, a, v_co_no->co); - dm->getVertNo(dm, a, v_co_no->no); - } - } - - dm->release(dm); + memset(vp_handle->vcosnos, 0, sizeof(*vp_handle->vcosnos) * me->totvert); + BKE_mesh_foreach_mapped_vert(me_eval, vpaint_proj_dm_map_cosnos_init__map_cb, vp_handle, MESH_FOREACH_USE_NORMAL); } @@ -185,21 +172,13 @@ static void vpaint_proj_dm_map_cosnos_update( Scene *scene = vp_handle->scene; Object *ob = vp_handle->ob; Mesh *me = ob->data; - DerivedMesh *dm; + Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); /* quick sanity check - we shouldn't have to run this if there are no modifiers */ BLI_assert(BLI_listbase_is_empty(&ob->modifiers) == false); - dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); - - /* highly unlikely this will become unavailable once painting starts (perhaps with animated modifiers) */ - if (LIKELY(dm->foreachMappedVert)) { - copy_vn_fl(vp_handle->dists_sq, me->totvert, FLT_MAX); - - dm->foreachMappedVert(dm, vpaint_proj_dm_map_cosnos_update__map_cb, &vp_update, DM_FOREACH_USE_NORMAL); - } - - dm->release(dm); + copy_vn_fl(vp_handle->dists_sq, me->totvert, FLT_MAX); + BKE_mesh_foreach_mapped_vert(me_eval, vpaint_proj_dm_map_cosnos_update__map_cb, &vp_update, MESH_FOREACH_USE_NORMAL); } diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index 7d241835b62..126b3b42e8f 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -35,8 +35,8 @@ #include "IMB_imbuf_types.h" #include "IMB_colormanagement.h" -//#include "DNA_armature_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_particle_types.h" #include "DNA_brush_types.h" #include "DNA_object_types.h" @@ -46,11 +46,11 @@ #include "RNA_define.h" #include "RNA_enum_types.h" -#include "BKE_DerivedMesh.h" #include "BKE_brush.h" #include "BKE_context.h" #include "BKE_deform.h" #include "BKE_mesh.h" +#include "BKE_mesh_iterators.h" #include "BKE_mesh_mapping.h" #include "BKE_mesh_runtime.h" #include "BKE_modifier.h" @@ -785,31 +785,16 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) ED_view3d_init_mats_rv3d(ob, ar->regiondata); Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, scene->customdata_mask | CD_MASK_ORIGINDEX); - int *mv_orig_indices = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX); - MVert *mv = me_eval->mvert; - /* NULL origindex is valid when wehave no generative modifiers... */ - BLI_assert(mv_orig_indices != NULL || me_eval->totvert == me->totvert); if (data.is_init) { data.vert_visit = BLI_BITMAP_NEW(me->totvert, __func__); - /* TODO add some similar helpers as DM's foreachMappedXXX callbacks, for evaluated mesh? */ - for (int mv_idx = 0; mv_idx < me_eval->totvert; mv_idx++, mv++) { - const int mv_orig_idx = mv_orig_indices != NULL ? mv_orig_indices[mv_idx] : mv_idx; - if (mv_orig_idx != ORIGINDEX_NONE) { - gradientVertInit__mapFunc(&data, mv_orig_idx, mv->co, NULL, NULL); - } - } + BKE_mesh_foreach_mapped_vert(me_eval, gradientVertInit__mapFunc, &data, MESH_FOREACH_NOP); MEM_freeN(data.vert_visit); data.vert_visit = NULL; } else { - for (int mv_idx = 0; mv_idx < me_eval->totvert; mv_idx++, mv++) { - const int mv_orig_idx = mv_orig_indices != NULL ? mv_orig_indices[mv_idx] : mv_idx; - if (mv_orig_idx != ORIGINDEX_NONE) { - gradientVertUpdate__mapFunc(&data, mv_orig_idx, mv->co, NULL, NULL); - } - } + BKE_mesh_foreach_mapped_vert(me_eval, gradientVertUpdate__mapFunc, &data, MESH_FOREACH_NOP); } DEG_id_tag_update(&ob->id, OB_RECALC_DATA); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 2872ad4fb9c..bc22147b15d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -561,7 +561,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb) else { BKE_pbvh_search_callback(ss->pbvh, NULL, NULL, update_cb, &rebuild); } - BKE_pbvh_update(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw, NULL); + BKE_pbvh_update(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw | PBVH_UpdateNormals, NULL); if (BKE_sculpt_multires_active(scene, ob)) { if (rebuild) diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 527e382ec1e..537f184c71c 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -47,6 +47,8 @@ #include "BKE_screen.h" #include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" #include "WM_api.h" #include "WM_types.h" @@ -102,6 +104,7 @@ static SpaceLink *action_new(const ScrArea *sa, const Scene *scene) saction->autosnap = SACTSNAP_FRAME; saction->mode = SACTCONT_DOPESHEET; + saction->mode_prev = SACTCONT_DOPESHEET; saction->ads.filterflag |= ADS_FILTER_SUMMARY; @@ -835,6 +838,37 @@ static void action_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, I } +/** + * \note Used for splitting out a subset of modes is more involved, + * The previous non-timeline mode is stored so switching back to the + * dope-sheet doesn't always reset the sub-mode. + */ +static int action_space_subtype_get(ScrArea *sa) +{ + SpaceAction *sact = sa->spacedata.first; + return sact->mode == SACTCONT_TIMELINE ? SACTCONT_TIMELINE : SACTCONT_DOPESHEET; +} + +static void action_space_subtype_set(ScrArea *sa, int value) +{ + SpaceAction *sact = sa->spacedata.first; + if (value == SACTCONT_TIMELINE) { + if (sact->mode != SACTCONT_TIMELINE) { + sact->mode_prev = sact->mode; + } + sact->mode = value; + } + else { + sact->mode = sact->mode_prev; + } +} + +static void action_space_subtype_item_extend( + bContext *UNUSED(C), EnumPropertyItem **item, int *totitem) +{ + RNA_enum_items_add(item, totitem, rna_enum_space_action_mode_items); +} + /* only called once, from space/spacetypes.c */ void ED_spacetype_action(void) { @@ -853,6 +887,9 @@ void ED_spacetype_action(void) st->listener = action_listener; st->refresh = action_refresh; st->id_remap = action_id_remap; + st->space_subtype_item_extend = action_space_subtype_item_extend; + st->space_subtype_get = action_space_subtype_get; + st->space_subtype_set = action_space_subtype_set; /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 33ec7f771ba..2ee791e81d6 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -127,6 +127,8 @@ void ED_spacetypes_init(void) ED_operatortypes_view2d(); ED_operatortypes_ui(); + ED_screen_user_menu_register(); + /* manipulator types */ ED_manipulatortypes_button_2d(); ED_manipulatortypes_dial_3d(); diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 469d94fed3a..f2fe06874d7 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -387,7 +387,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P else tip = TIP_("Marker is enabled at current frame"); - bt = uiDefIconButBitI(block, UI_BTYPE_TOGGLE_N, MARKER_DISABLED, 0, ICON_RESTRICT_VIEW_OFF, 0, 0, UI_UNIT_X, UI_UNIT_Y, + bt = uiDefIconButBitI(block, UI_BTYPE_TOGGLE_N, MARKER_DISABLED, 0, ICON_HIDE_OFF, 0, 0, UI_UNIT_X, UI_UNIT_Y, &cb->marker_flag, 0, 0, 1, 0, tip); UI_but_funcN_set(bt, marker_update_cb, cb, NULL); } diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index f55a5511e2d..e543111e662 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -44,17 +44,62 @@ #include "BKE_context.h" #include "BKE_fcurve.h" +#include "BKE_screen.h" #include "WM_api.h" #include "ED_anim_api.h" +#include "ED_screen.h" +#include "UI_interface.h" #include "graph_intern.h" // own include /* ************************************************************** */ +/* Set Up Drivers Editor */ + +/* Set up UI configuration for Drivers Editor */ +/* NOTE: Currently called from windowmanager (new drivers editor window) and RNA (mode switching) */ +void ED_drivers_editor_init(bContext *C, ScrArea *sa) +{ + SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; + + /* Set mode */ + sipo->mode = SIPO_MODE_DRIVERS; + + /* Show Properties Region (or else the settings can't be edited) */ + ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_UI); + if (ar_props) { + UI_panel_category_active_set(ar_props, "Drivers"); + + ar_props->flag &= ~RGN_FLAG_HIDDEN; + /* XXX: Adjust width of this too? */ + + ED_region_visibility_change_update(C, ar_props); + } + else { + printf("%s: Couldn't find properties region for Drivers Editor - %p\n", __func__, sa); + } + + /* Adjust framing in graph region */ + /* TODO: Have a way of not resetting this every time? + * (e.g. So that switching back and forth between editors doesn't keep jumping?) + */ + ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (ar_main) { + /* XXX: Ideally we recenter based on the range instead... */ + ar_main->v2d.tot.xmin = -2.0f; + ar_main->v2d.tot.ymin = -2.0f; + ar_main->v2d.tot.xmax = 2.0f; + ar_main->v2d.tot.ymax = 2.0f; + + ar_main->v2d.cur = ar_main->v2d.tot; + } +} + +/* ************************************************************** */ /* Active F-Curve */ /* Find 'active' F-Curve. It must be editable, since that's the purpose of these buttons (subject to change). diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 59d7d7500ae..7c3105843c5 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -60,6 +60,8 @@ #include "WM_message.h" #include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" #include "UI_resources.h" #include "UI_view2d.h" @@ -181,14 +183,14 @@ static void graph_free(SpaceLink *sl) /* spacetype; init callback */ -static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) +static void graph_init(struct wmWindowManager *wm, ScrArea *sa) { SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; /* init dopesheet data if non-existent (i.e. for old files) */ if (sipo->ads == NULL) { sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); - sipo->ads->source = (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now... + sipo->ads->source = (ID *)WM_window_get_active_scene(wm->winactive); } /* force immediate init of any invalid F-Curve colors */ @@ -799,6 +801,24 @@ static void graph_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID } } +static int graph_space_subtype_get(ScrArea *sa) +{ + SpaceIpo *sgraph = sa->spacedata.first; + return sgraph->mode; +} + +static void graph_space_subtype_set(ScrArea *sa, int value) +{ + SpaceIpo *sgraph = sa->spacedata.first; + sgraph->mode = value; +} + +static void graph_space_subtype_item_extend( + bContext *UNUSED(C), EnumPropertyItem **item, int *totitem) +{ + RNA_enum_items_add(item, totitem, rna_enum_space_graph_mode_items); +} + /* only called once, from space/spacetypes.c */ void ED_spacetype_ipo(void) { @@ -817,6 +837,9 @@ void ED_spacetype_ipo(void) st->listener = graph_listener; st->refresh = graph_refresh; st->id_remap = graph_id_remap; + st->space_subtype_item_extend = graph_space_subtype_item_extend; + st->space_subtype_get = graph_space_subtype_get; + st->space_subtype_set = graph_space_subtype_set; /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); @@ -867,4 +890,3 @@ void ED_spacetype_ipo(void) BKE_spacetype_register(st); } - diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 7236a99ad80..9475c159653 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -710,7 +710,7 @@ static void uiblock_layer_pass_buttons( if (render_slot) { char str[64]; RenderSlot *slot = BKE_image_get_renderslot(image, *render_slot); - if (slot->name[0] != '\0') { + if (slot && slot->name[0] != '\0') { BLI_strncpy(str, slot->name, sizeof(str)); } else { diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index e84b596530e..827c39b8033 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -301,7 +301,7 @@ static void image_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "IMAGE_OT_reload", RKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "IMAGE_OT_read_viewlayers", RKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "IMAGE_OT_save", SKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "IMAGE_OT_save_as", F3KEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "IMAGE_OT_save_as", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "IMAGE_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_toolshelf", TKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 481c9031a73..b0b0f6dee07 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -34,6 +34,7 @@ #include "DNA_curve_types.h" #include "DNA_group_types.h" #include "DNA_lattice_types.h" +#include "DNA_mesh_types.h" #include "DNA_meta_types.h" #include "DNA_scene_types.h" @@ -48,7 +49,6 @@ #include "BKE_blender_version.h" #include "BKE_curve.h" #include "BKE_displist.h" -#include "BKE_DerivedMesh.h" #include "BKE_key.h" #include "BKE_layer.h" #include "BKE_paint.h" @@ -92,15 +92,15 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) switch (ob->type) { case OB_MESH: { - /* we assume derivedmesh is already built, this strictly does stats now. */ - DerivedMesh *dm = ob->derivedFinal; + /* we assume evaluated mesh is already built, this strictly does stats now. */ + Mesh *me_eval = ob->runtime.mesh_eval; int totvert, totedge, totface, totloop; - if (dm) { - totvert = dm->getNumVerts(dm); - totedge = dm->getNumEdges(dm); - totface = dm->getNumPolys(dm); - totloop = dm->getNumLoops(dm); + if (me_eval) { + totvert = me_eval->totvert; + totedge = me_eval->totedge; + totface = me_eval->totpoly; + totloop = me_eval->totloop; stats->totvert += totvert * totob; stats->totedge += totedge * totob; @@ -387,7 +387,7 @@ static void stats_update(ViewLayer *view_layer) else { /* Objects */ for (base = view_layer->object_bases.first; base; base = base->next) - if (base->flag & BASE_VISIBLED) { + if (base->flag & BASE_VISIBLE) { stats_dupli_object(base, base->object, &stats); } } diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index d782fe4d7ef..d3725704636 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -129,7 +129,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe Object *ob = base->object; AnimData *adt = ob->adt; - if (nlaedit_is_tweakmode_on(ac) == 0 && (base->flag & BASE_SELECTABLED)) { + if (nlaedit_is_tweakmode_on(ac) == 0 && (base->flag & BASE_SELECTABLE)) { /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 639195c16ac..745cea37ea3 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -178,14 +178,14 @@ static void nla_free(SpaceLink *sl) /* spacetype; init callback */ -static void nla_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) +static void nla_init(struct wmWindowManager *wm, ScrArea *sa) { SpaceNla *snla = (SpaceNla *)sa->spacedata.first; /* init dopesheet data if non-existent (i.e. for old files) */ if (snla->ads == NULL) { snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); - snla->ads->source = (ID *)G.main->scene.first; // XXX this is bad, but we need this to be set correct + snla->ads->source = (ID *)WM_window_get_active_scene(wm->winactive); } ED_area_tag_refresh(sa); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 441ab03cb28..14ba9280a75 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -1045,4 +1045,3 @@ void ED_spacetype_node(void) BKE_spacetype_register(st); } - diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c index a700f8e20e0..b97cc13d713 100644 --- a/source/blender/editors/space_outliner/outliner_collections.c +++ b/source/blender/editors/space_outliner/outliner_collections.c @@ -164,8 +164,10 @@ static int collection_new_exec(bContext *C, wmOperator *op) data.collection, NULL); - outliner_cleanup_tree(soops); + DEG_id_tag_update(&data.collection->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); + + outliner_cleanup_tree(soops); WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); return OPERATOR_FINISHED; } @@ -236,18 +238,19 @@ static int collection_delete_exec(bContext *C, wmOperator *op) /* Effectively delete the collections. */ GSetIterator collections_to_edit_iter; GSET_ITER(collections_to_edit_iter, data.collections_to_edit) { - /* TODO: what if collection was child and got deleted in the meantime? */ Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter); - BKE_collection_delete(bmain, collection, hierarchy); + + /* Test in case collection got deleted as part of another one. */ + if (BLI_findindex(&bmain->collection, collection) != -1) { + BKE_collection_delete(bmain, collection, hierarchy); + } } BLI_gset_free(data.collections_to_edit, NULL); + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); - /* TODO(sergey): Use proper flag for tagging here. */ - DEG_id_tag_update(&scene->id, 0); - WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); return OPERATOR_FINISHED; @@ -462,11 +465,9 @@ static int collection_link_exec(bContext *C, wmOperator *UNUSED(op)) BLI_gset_free(data.collections_to_edit, NULL); + DEG_id_tag_update(&active_collection->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); - /* TODO(sergey): Use proper flag for tagging here. */ - DEG_id_tag_update(&scene->id, 0); - WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); return OPERATOR_FINISHED; @@ -527,9 +528,6 @@ static int collection_instance_exec(bContext *C, wmOperator *UNUSED(op)) DEG_relations_tag_update(bmain); - /* TODO(sergey): Use proper flag for tagging here. */ - DEG_id_tag_update(&scene->id, 0); - WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index e4f551b0004..e617bb40837 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -51,6 +51,7 @@ #include "BKE_deform.h" #include "BKE_fcurve.h" #include "BKE_global.h" +#include "BKE_idcode.h" #include "BKE_layer.h" #include "BKE_library.h" #include "BKE_main.h" @@ -278,6 +279,44 @@ static void restrictbutton_id_user_toggle(bContext *UNUSED(C), void *poin, void } } +static void hidebutton_base_flag_cb(bContext *C, void *poin, void *poin2) +{ + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = poin; + Base *base = poin2; + bool extend = (CTX_wm_window(C)->eventstate->ctrl == 0); + + /* Undo button toggle, let function do it. */ + base->flag ^= BASE_HIDDEN; + + BKE_base_set_visible(scene, view_layer, base, extend); + + if (!extend && (base->flag & BASE_VISIBLE)) { + /* Auto select solo-ed object. */ + ED_object_base_select(base, BA_SELECT); + view_layer->basact = base; + } + + DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); +} + +static void hidebutton_layer_collection_flag_cb(bContext *C, void *poin, void *poin2) +{ + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = poin; + LayerCollection *lc = poin2; + bool extend = (CTX_wm_window(C)->eventstate->ctrl == 0); + + /* Undo button toggle, let function do it. */ + lc->runtime_flag ^= LAYER_COLLECTION_HAS_VISIBLE_OBJECTS; + + BKE_layer_collection_set_visible(scene, view_layer, lc, extend); + + DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); +} + static void namebutton_cb(bContext *C, void *tsep, char *oldname) { Main *bmain = CTX_data_main(C); @@ -435,18 +474,25 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) } static void outliner_draw_restrictbuts( - uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, ListBase *lb) + uiBlock *block, Scene *scene, ViewLayer *view_layer, ARegion *ar, SpaceOops *soops, ListBase *lb) { uiBut *bt; /* get RNA properties (once for speed) */ - PropertyRNA *collection_prop_hide_viewport; - PropertyRNA *collection_prop_hide_select; - PropertyRNA *collection_prop_hide_render; + PropertyRNA *object_prop_hide_viewport, *object_prop_hide_select, *object_prop_hide_render; + PropertyRNA *collection_prop_hide_viewport, *collection_prop_hide_select, *collection_prop_hide_render; + + object_prop_hide_viewport = RNA_struct_type_find_property(&RNA_Object, "hide_viewport"); + object_prop_hide_select = RNA_struct_type_find_property(&RNA_Object, "hide_select"); + object_prop_hide_render = RNA_struct_type_find_property(&RNA_Object, "hide_render"); collection_prop_hide_select = RNA_struct_type_find_property(&RNA_Collection, "hide_select"); collection_prop_hide_viewport = RNA_struct_type_find_property(&RNA_Collection, "hide_viewport"); collection_prop_hide_render = RNA_struct_type_find_property(&RNA_Collection, "hide_render"); - BLI_assert(collection_prop_hide_viewport && + + BLI_assert(object_prop_hide_viewport && + object_prop_hide_select && + object_prop_hide_render && + collection_prop_hide_viewport && collection_prop_hide_select && collection_prop_hide_render); @@ -455,15 +501,51 @@ static void outliner_draw_restrictbuts( if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { if (tselem->type == TSE_R_LAYER && (soops->outlinevis == SO_SCENES)) { /* View layer render toggle. */ - ViewLayer *view_layer = te->directdata; + ViewLayer *layer = te->directdata; bt = uiDefIconButBitS( block, UI_BTYPE_ICON_TOGGLE_N, VIEW_LAYER_RENDER, 0, ICON_RESTRICT_RENDER_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, - UI_UNIT_Y, &view_layer->flag, 0, 0, 0, 0, TIP_("Use view layer for rendering")); + UI_UNIT_Y, &layer->flag, 0, 0, 0, 0, TIP_("Use view layer for rendering")); UI_but_func_set(bt, restrictbutton_r_lay_cb, tselem->id, NULL); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); } + else if (tselem->type == 0 && te->idcode == ID_OB) { + Object *ob = (Object *)tselem->id; + Base *base = BKE_view_layer_base_find(view_layer, ob); + + if (base) { + bt = uiDefIconButBitS( + block, UI_BTYPE_ICON_TOGGLE, BASE_HIDDEN, 0, ICON_HIDE_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), te->ys, UI_UNIT_X, + UI_UNIT_Y, &base->flag, 0, 0, 0, 0, + TIP_("Hide object in viewport (Ctrl to isolate)")); + UI_but_func_set(bt, hidebutton_base_flag_cb, view_layer, base); + UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); + } + + PointerRNA ptr; + RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ptr); + + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_VIEW_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y, + &ptr, object_prop_hide_viewport, -1, 0, 0, -1, -1, + TIP_("Restrict viewport visibility")); + UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); + + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_SELECT_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, + &ptr, object_prop_hide_select, -1, 0, 0, -1, -1, + TIP_("Restrict viewport selection")); + UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); + + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_RENDER_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y, + &ptr, object_prop_hide_render, -1, 0, 0, -1, -1, + TIP_("Restrict render visibility")); + UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); + + } else if (tselem->type == TSE_MODIFIER) { ModifierData *md = (ModifierData *)te->directdata; Object *ob = (Object *)tselem->id; @@ -489,7 +571,7 @@ static void outliner_draw_restrictbuts( Object *ob = (Object *)tselem->id; bt = uiDefIconButBitI( - block, UI_BTYPE_ICON_TOGGLE, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, + block, UI_BTYPE_ICON_TOGGLE, BONE_HIDDEN_P, 0, ICON_HIDE_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y, &(bone->flag), 0, 0, 0, 0, TIP_("Restrict/Allow visibility in the 3D View")); @@ -527,7 +609,7 @@ static void outliner_draw_restrictbuts( bGPDlayer *gpl = (bGPDlayer *)te->directdata; bt = uiDefIconButBitS( - block, UI_BTYPE_ICON_TOGGLE, GP_LAYER_HIDE, 0, ICON_RESTRICT_VIEW_OFF, + block, UI_BTYPE_ICON_TOGGLE, GP_LAYER_HIDE, 0, ICON_HIDE_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y, &gpl->flag, 0, 0, 0, 0, TIP_("Restrict/Allow visibility in the 3D View")); @@ -551,6 +633,16 @@ static void outliner_draw_restrictbuts( if ((!lc || !(lc->flag & LAYER_COLLECTION_EXCLUDE)) && !(collection->flag & COLLECTION_IS_MASTER)) { + if (lc && (lc->runtime_flag & LAYER_COLLECTION_HAS_ENABLED_OBJECTS)) { + bt = uiDefIconButBitS( + block, UI_BTYPE_ICON_TOGGLE_N, LAYER_COLLECTION_HAS_VISIBLE_OBJECTS, 0, ICON_HIDE_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), te->ys, UI_UNIT_X, + UI_UNIT_Y, &lc->runtime_flag, 0, 0, 0, 0, + TIP_("Hide collection in viewport (Ctrl to isolate)")); + UI_but_func_set(bt, hidebutton_layer_collection_flag_cb, view_layer, lc); + UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); + } + PointerRNA collection_ptr; RNA_id_pointer_create(&collection->id, &collection_ptr); @@ -576,7 +668,7 @@ static void outliner_draw_restrictbuts( } if (TSELEM_OPEN(tselem, soops)) { - outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree); + outliner_draw_restrictbuts(block, scene, view_layer, ar, soops, &te->subtree); } } } @@ -814,7 +906,7 @@ static void UNUSED_FUNCTION(tselem_draw_gp_icon_uibut)(struct DrawIconArg *arg, static void tselem_draw_icon( uiBlock *block, int xmax, float x, float y, TreeStoreElem *tselem, TreeElement *te, - float alpha) + float alpha, const bool is_clickable) { struct DrawIconArg arg; float aspect; @@ -835,6 +927,7 @@ static void tselem_draw_icon( arg.y = y; #define ICON_DRAW(_icon) UI_icon_draw_alpha(x, y, _icon, alpha) +#define ICON_CLICK_DRAW(_icon) if (!is_clickable) ICON_DRAW(_icon); else tselem_draw_icon_uibut(&arg, _icon) if (tselem->type) { switch (tselem->type) { @@ -1106,33 +1199,33 @@ static void tselem_draw_icon( Object *ob = (Object *)tselem->id; switch (ob->type) { case OB_LAMP: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LAMP); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_LAMP); break; case OB_MESH: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_MESH); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_MESH); break; case OB_CAMERA: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_CAMERA); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_CAMERA); break; case OB_CURVE: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_CURVE); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_CURVE); break; case OB_MBALL: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_META); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_META); break; case OB_LATTICE: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LATTICE); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_LATTICE); break; case OB_ARMATURE: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_ARMATURE); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_ARMATURE); break; case OB_FONT: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_FONT); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_FONT); break; case OB_SURF: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_SURFACE); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_SURFACE); break; case OB_SPEAKER: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_SPEAKER); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_SPEAKER); break; case OB_LIGHTPROBE: - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LIGHTPROBE); break; + ICON_CLICK_DRAW(ICON_OUTLINER_OB_LIGHTPROBE); break; case OB_EMPTY: if (ob->dup_group) { - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_GROUP_INSTANCE); + ICON_CLICK_DRAW(ICON_OUTLINER_OB_GROUP_INSTANCE); } else { - tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_EMPTY); + ICON_CLICK_DRAW(ICON_OUTLINER_OB_EMPTY); } break; } @@ -1240,13 +1333,137 @@ static void tselem_draw_icon( #undef ICON_DRAW } +/** + * For icon-only children of a collapsed tree, + * Draw small number over the icon to show how many items of this type are displayed. + */ +static void outliner_draw_iconrow_number( + const uiFontStyle *fstyle, + int offsx, int ys, + const eOLDrawState active, + const int num_elements) +{ + float color[4] = {0.4f, 0.4f, 0.4f, 0.9f}; + copy_v3_fl(color, 0.2f); + if (active != OL_DRAWSEL_NONE) { + copy_v3_fl(color, 0.65f); + color[3] = 1.0f; + } + + float ufac = 0.25f * UI_UNIT_X; + float offset_x = (float) offsx + UI_UNIT_X * 0.35f; + + UI_draw_roundbox_corner_set(UI_CNR_ALL); + UI_draw_roundbox_aa(true, + offset_x + ufac, + (float)ys - UI_UNIT_Y * 0.2f + ufac, + offset_x + UI_UNIT_X - ufac, + (float)ys - UI_UNIT_Y * 0.2f + UI_UNIT_Y - ufac, + (float)UI_UNIT_Y / 2.0f - ufac, + color); + + /* Now the numbers. */ + unsigned char text_col[4]; + + UI_GetThemeColor4ubv(TH_TEXT_HI, text_col); + text_col[3] = 255; + + uiFontStyle fstyle_small = *fstyle; + fstyle_small.points *= 0.8f; + + /* We treat +99 as 4 digits to make sure the (eyeballed) alignment looks nice. */ + int num_digits = 4; + char number_text[4] = "+99\0"; + if (num_elements < 100) { + BLI_snprintf(number_text, sizeof(number_text), "%d", num_elements); + num_digits = num_elements < 10 ? 1 : 2; + } + UI_fontstyle_draw_simple(&fstyle_small, + (offset_x + ufac + UI_UNIT_X * (2 - num_digits) * 0.12f), + (float)ys - UI_UNIT_Y * 0.095f + ufac, + number_text, text_col); + UI_fontstyle_set(fstyle); + glEnable(GL_BLEND); /* Roundbox and text drawing disables. */ +} + +static void outliner_draw_iconrow_doit( + uiBlock *block, TreeElement *te, + const uiFontStyle *fstyle, + int xmax, int *offsx, int ys, float alpha_fac, + const eOLDrawState active, + const int num_elements) +{ + TreeStoreElem *tselem = TREESTORE(te); + + if (active != OL_DRAWSEL_NONE) { + float ufac = UI_UNIT_X / 20.0f; + float color[4] = {1.0f, 1.0f, 1.0f, 0.4f}; + + UI_draw_roundbox_corner_set(UI_CNR_ALL); + color[3] *= alpha_fac; + + UI_draw_roundbox_aa(true, + (float) *offsx + 1.0f * ufac, + (float)ys + 1.0f * ufac, + (float)*offsx + UI_UNIT_X - 1.0f * ufac, + (float)ys + UI_UNIT_Y - ufac, + (float)UI_UNIT_Y / 2.0f - ufac, + color); + glEnable(GL_BLEND); /* Roundbox disables. */ + } + + /* No inlined icon should be clickable. */ + tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f * alpha_fac, false); + te->xs = *offsx; + te->ys = ys; + te->xend = (short)*offsx + UI_UNIT_X; + + if (num_elements > 1) { + outliner_draw_iconrow_number(fstyle, *offsx, ys, active, num_elements); + } + (*offsx) += UI_UNIT_X; +} + +/** + * Return the index to use based on the TreeElement ID and object type + * + * We use a continuum of indeces until we get to the object datablocks + * and we then make room for the object types. + */ +static int tree_element_id_type_to_index(TreeElement *te) +{ + TreeStoreElem *tselem = TREESTORE(te); + + const int id_index = tselem->type == 0 ? BKE_idcode_to_index(te->idcode) : INDEX_ID_GR; + if (id_index < INDEX_ID_OB) { + return id_index; + } + else if (id_index == INDEX_ID_OB) { + const Object *ob = (Object *)tselem->id; + return INDEX_ID_OB + ob->type; + } + else { + return id_index + OB_TYPE_MAX; + } +} + static void outliner_draw_iconrow( - bContext *C, uiBlock *block, Scene *scene, ViewLayer *view_layer, SpaceOops *soops, + bContext *C, uiBlock *block, const uiFontStyle *fstyle, Scene *scene, ViewLayer *view_layer, SpaceOops *soops, ListBase *lb, int level, int xmax, int *offsx, int ys, float alpha_fac) { eOLDrawState active; const Object *obact = OBACT(view_layer); + struct { + eOLDrawState active[INDEX_ID_MAX + OB_TYPE_MAX]; + int num_elements[INDEX_ID_MAX + OB_TYPE_MAX]; + TreeElement *tree_element[INDEX_ID_MAX + OB_TYPE_MAX]; + } data = { + .active = {0}, + .num_elements = {0}, + .tree_element = {NULL}, + }; + for (TreeElement *te = lb->first; te; te = te->next) { /* exit drawing early */ if ((*offsx) - UI_UNIT_X > xmax) @@ -1272,41 +1489,48 @@ static void outliner_draw_iconrow( active = tree_element_type_active(C, scene, view_layer, soops, te, tselem, OL_SETSEL_NONE, false); } - if (active != OL_DRAWSEL_NONE) { - float ufac = UI_UNIT_X / 20.0f; - float color[4] = {1.0f, 1.0f, 1.0f, 0.4f}; - - UI_draw_roundbox_corner_set(UI_CNR_ALL); - color[3] *= alpha_fac; - - UI_draw_roundbox_aa( - true, - (float) *offsx + 1.0f * ufac, - (float)ys + 1.0f * ufac, - (float)*offsx + UI_UNIT_X - 1.0f * ufac, - (float)ys + UI_UNIT_Y - ufac, - (float)UI_UNIT_Y / 2.0f - ufac, - color); - glEnable(GL_BLEND); /* roundbox disables */ + if (!ELEM(tselem->type, 0, TSE_LAYER_COLLECTION)) { + outliner_draw_iconrow_doit(block, te, fstyle, xmax, offsx, ys, alpha_fac, active, 1); + } + else { + const int index = tree_element_id_type_to_index(te); + data.num_elements[index]++; + if ((data.tree_element[index] == NULL) || + (active > data.active[index])) + { + data.tree_element[index] = te; + } + data.active[index] = MAX2(active, data.active[index]); } - - tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f * alpha_fac); - te->xs = *offsx; - te->ys = ys; - te->xend = (short)*offsx + UI_UNIT_X; - te->flag |= TE_ICONROW; // for click - - (*offsx) += UI_UNIT_X; } /* this tree element always has same amount of branches, so don't draw */ if (tselem->type != TSE_R_LAYER) { outliner_draw_iconrow( - C, block, scene, view_layer, soops, + C, block, fstyle, scene, view_layer, soops, &te->subtree, level + 1, xmax, offsx, ys, alpha_fac); } } + for (int i = 0; i < INDEX_ID_MAX; i++) { + const int num_subtypes = (i == INDEX_ID_OB) ? OB_TYPE_MAX : 1; + /* See tree_element_id_type_to_index for the index logic. */ + int index_base = i; + if (i > INDEX_ID_OB) { + index_base += OB_TYPE_MAX; + } + for (int j = 0; j < num_subtypes; j++) { + const int index = index_base + j; + if (data.num_elements[index] != 0) { + outliner_draw_iconrow_doit(block, + data.tree_element[index], + fstyle, + xmax, offsx, ys, alpha_fac, + data.active[index], + data.num_elements[index]); + } + } + } } /* closed tree element */ @@ -1447,7 +1671,7 @@ static void outliner_draw_tree_element( /* datatype icon */ if (!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM, TSE_ID_BASE))) { - tselem_draw_icon(block, xmax, (float)startx + offsx, (float)*starty, tselem, te, alpha_fac); + tselem_draw_icon(block, xmax, (float)startx + offsx, (float)*starty, tselem, te, alpha_fac, true); offsx += UI_UNIT_X + 2 * ufac; } else @@ -1531,7 +1755,7 @@ static void outliner_draw_tree_element( } outliner_draw_iconrow( - C, block, scene, view_layer, soops, &te->subtree, 0, xmax, &tempx, + C, block, fstyle, scene, view_layer, soops, &te->subtree, 0, xmax, &tempx, *starty, alpha_fac); glDisable(GL_BLEND); @@ -1736,7 +1960,6 @@ static void outliner_draw_highlights_recursive( const bool is_searching = ( SEARCHING_OUTLINER(soops) || (soops->outlinevis == SO_DATA_API && - (soops->filter & SO_FILTER_SEARCH) && soops->search_string[0] != 0)); for (TreeElement *te = lb->first; te; te = te->next) { @@ -1893,7 +2116,10 @@ static void outliner_draw_restrictcols(ARegion *ar) unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -15, -200); - immBegin(GWN_PRIM_LINES, 6); + immBegin(GWN_PRIM_LINES, 8); + + immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), (int)ar->v2d.cur.ymax); + immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), (int)ar->v2d.cur.ymin); immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymax); immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymin); @@ -1999,16 +2225,16 @@ void draw_outliner(const bContext *C) /* draw restriction columns */ outliner_draw_restrictcols(ar); - outliner_draw_restrictbuts(block, scene, ar, soops, &soops->tree); + outliner_draw_restrictbuts(block, scene, view_layer, ar, soops, &soops->tree); } + UI_block_emboss_set(block, UI_EMBOSS); + /* draw edit buttons if nessecery */ if (te_edit) { outliner_buttons(C, block, ar, te_edit); } - UI_block_emboss_set(block, UI_EMBOSS); - UI_block_end(C, block); UI_block_draw(C, block); } diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index c6288dc05ef..990d50ae42a 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -253,6 +253,55 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) RNA_def_boolean(ot->srna, "all", 1, "All", "Close or open all items"); } +/* -------------------------------------------------------------------- */ +/** \name Object Mode Enter/Exit + * \{ */ + +static void item_object_mode_enter_exit( + bContext *C, ReportList *reports, Object *ob, + bool enter) +{ + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *obact = OBACT(view_layer); + + if ((ob->type != obact->type) || ID_IS_LINKED(ob->data)) { + return; + } + if (((ob->mode & obact->mode) != 0) == enter) { + return; + } + + if (ob == obact) { + BKE_report(reports, RPT_WARNING, "Active object mode not changed"); + return; + } + + Base *base = BKE_view_layer_base_find(view_layer, ob); + if (base == NULL) { + return; + } + Scene *scene = CTX_data_scene(C); + outliner_object_mode_toggle(C, scene, view_layer, base); +} + +void item_object_mode_enter_cb( + bContext *C, ReportList *reports, Scene *UNUSED(scene), TreeElement *UNUSED(te), + TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) +{ + Object *ob = (Object *)tselem->id; + item_object_mode_enter_exit(C, reports, ob, true); +} + +void item_object_mode_exit_cb( + bContext *C, ReportList *reports, Scene *UNUSED(scene), TreeElement *UNUSED(te), + TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) +{ + Object *ob = (Object *)tselem->id; + item_object_mode_enter_exit(C, reports, ob, false); +} + +/** \} */ + /* Rename --------------------------------------------------- */ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, @@ -493,7 +542,7 @@ static int outliner_id_remap_exec(bContext *C, wmOperator *op) DEG_relations_tag_update(bmain); /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */ - GPU_materials_free(); + GPU_materials_free(bmain); WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -2317,6 +2366,7 @@ static int collection_drop_invoke(bContext *C, wmOperator *op, const wmEvent *ev Object *ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, childname); BKE_collection_object_add(bmain, collection, ob); + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 8ac09648d60..0ab22208841 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -151,11 +151,12 @@ typedef enum { /* size constants */ #define OL_Y_OFFSET 2 +#define OL_TOG_HIDEX (UI_UNIT_X * 4.0f) #define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X * 3.0f) #define OL_TOG_RESTRICT_VIEWX (UI_UNIT_X * 2.0f) #define OL_TOG_RESTRICT_RENDERX UI_UNIT_X -#define OL_TOGW OL_TOG_RESTRICT_SELECTX +#define OL_TOGW OL_TOG_HIDEX #define OL_RNA_COLX (UI_UNIT_X * 15) #define OL_RNA_COL_SIZEX (UI_UNIT_X * 7.5f) @@ -181,7 +182,7 @@ typedef enum { * - not searching into RNA items helps but isn't the complete solution */ -#define SEARCHING_OUTLINER(sov) ((sov->search_flags & SO_SEARCH_RECURSIVE) && (sov->filter & SO_FILTER_SEARCH)) +#define SEARCHING_OUTLINER(sov) (sov->search_flags & SO_SEARCH_RECURSIVE) /* is the currrent element open? if so we also show children */ #define TSELEM_OPEN(telm, sv) ( (telm->flag & TSE_CLOSED) == 0 || (SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH)) ) @@ -226,6 +227,10 @@ void outliner_item_select( struct SpaceOops *soops, const struct TreeElement *te, const bool extend, const bool toggle); +void outliner_object_mode_toggle( + struct bContext *C, Scene *scene, ViewLayer *view_layer, + Base *base); + /* outliner_edit.c ---------------------------------------------- */ typedef void (*outliner_operation_cb)( struct bContext *C, struct ReportList *, struct Scene *scene, @@ -271,6 +276,13 @@ void id_remap_cb( struct bContext *C, struct ReportList *reports, struct Scene *scene, struct TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem, void *user_data); +void item_object_mode_enter_cb( + struct bContext *C, struct ReportList *reports, struct Scene *scene, + TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem, void *user_data); +void item_object_mode_exit_cb( + struct bContext *C, struct ReportList *reports, struct Scene *scene, + TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem, void *user_data); + TreeElement *outliner_dropzone_find(const struct SpaceOops *soops, const float fmval[2], const bool children); void outliner_set_coordinates(struct ARegion *ar, struct SpaceOops *soops); diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index ecfd12618e5..316caf0e239 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -560,6 +560,13 @@ void outliner_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "OBJECT_OT_move_to_collection", MKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_link_to_collection", MKEY, KM_PRESS, KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_clear", HKEY, KM_PRESS, KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "select", false); + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, 0, 0); + RNA_boolean_set(kmi->ptr, "unselected", false); + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "unselected", true); + outliner_item_drag_drop_modal_keymap(keyconf); } diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 6a6a392e4a6..9b430b0af99 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -155,6 +155,20 @@ static void do_outliner_activate_pose(bContext *C, ViewLayer *view_layer, Base * } } +/* For draw callback to run mode switching */ +void outliner_object_mode_toggle( + bContext *C, Scene *scene, ViewLayer *view_layer, + Base *base) +{ + Object *obact = OBACT(view_layer); + if (obact->mode & OB_MODE_EDIT) { + do_outliner_activate_obdata(C, scene, view_layer, base); + } + else if (obact->mode & OB_MODE_POSE) { + do_outliner_activate_pose(C, view_layer, base); + } +} + /* ****************************************************** */ /* Outliner Element Selection/Activation on Click */ @@ -192,7 +206,7 @@ static void do_outliner_object_select_recursive(ViewLayer *view_layer, Object *o for (base = FIRSTBASE(view_layer); base; base = base->next) { Object *ob = base->object; - if ((((base->flag & BASE_VISIBLED) == 0) && BKE_object_is_child_recursive(ob_parent, ob))) { + if ((((base->flag & BASE_VISIBLE) == 0) && BKE_object_is_child_recursive(ob_parent, ob))) { ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT); } } @@ -986,7 +1000,7 @@ static void do_outliner_item_activate_tree_element( Object *ob = (Object *)outliner_search_back(soops, te, ID_OB); if ((ob != NULL) && (ob->data == tselem->id)) { Base *base = BKE_view_layer_base_find(view_layer, ob); - if ((base != NULL) && (base->flag & BASE_VISIBLED)) { + if ((base != NULL) && (base->flag & BASE_VISIBLE)) { do_outliner_activate_obdata(C, scene, view_layer, base); } } diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index f8d9877be6e..e2eb617278b 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -229,18 +229,22 @@ static void unlink_collection_cb( if (GS(tsep->id->name) == ID_OB) { Object *ob = (Object *)tsep->id; ob->dup_group = NULL; + DEG_id_tag_update(&ob->id, OB_RECALC_OB); DEG_relations_tag_update(bmain); } else if (GS(tsep->id->name) == ID_GR) { Collection *parent = (Collection *)tsep->id; id_fake_user_set(&collection->id); BKE_collection_child_remove(bmain, parent, collection); + DEG_id_tag_update(&parent->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); } else if (GS(tsep->id->name) == ID_SCE) { - Collection *parent = BKE_collection_master((Scene *)tsep->id); + Scene *scene = (Scene *)tsep->id; + Collection *parent = BKE_collection_master(scene); id_fake_user_set(&collection->id); BKE_collection_child_remove(bmain, parent, collection); + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); } } @@ -257,11 +261,14 @@ static void unlink_object_cb( if (GS(tsep->id->name) == ID_GR) { Collection *parent = (Collection *)tsep->id; BKE_collection_object_remove(bmain, parent, ob, true); + DEG_id_tag_update(&parent->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); } else if (GS(tsep->id->name) == ID_SCE) { - Collection *parent = BKE_collection_master((Scene *)tsep->id); + Scene *scene = (Scene *)tsep->id; + Collection *parent = BKE_collection_master(scene); BKE_collection_object_remove(bmain, parent, ob, true); + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); } } @@ -394,7 +401,7 @@ static void object_select_cb( Object *ob = (Object *)tselem->id; Base *base = BKE_view_layer_base_find(view_layer, ob); - if (base && ((base->flag & BASE_VISIBLED) != 0)) { + if (base && ((base->flag & BASE_VISIBLE) != 0)) { base->flag |= BASE_SELECTED; } } @@ -911,6 +918,8 @@ enum { OL_OP_TOGSEL, OL_OP_TOGREN, OL_OP_RENAME, + OL_OP_OBJECT_MODE_ENTER, + OL_OP_OBJECT_MODE_EXIT, }; static const EnumPropertyItem prop_object_op_types[] = { @@ -922,6 +931,8 @@ static const EnumPropertyItem prop_object_op_types[] = { {OL_OP_REMAP, "REMAP", 0, "Remap Users", "Make all users of selected data-blocks to use instead a new chosen one"}, {OL_OP_RENAME, "RENAME", 0, "Rename", ""}, + {OL_OP_OBJECT_MODE_ENTER, "OBJECT_MODE_ENTER", 0, "Enter Mode", ""}, + {OL_OP_OBJECT_MODE_EXIT, "OBJECT_MODE_EXIT", 0, "Exit Mode", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1005,6 +1016,14 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, item_rename_cb); str = "Rename Object"; } + else if (event == OL_OP_OBJECT_MODE_ENTER) { + outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, item_object_mode_enter_cb); + str = "Enter Current Mode"; + } + else if (event == OL_OP_OBJECT_MODE_EXIT) { + outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, item_object_mode_exit_cb); + str = "Exit Current Mode"; + } else { BLI_assert(0); return OPERATOR_CANCELLED; @@ -1574,8 +1593,8 @@ void OUTLINER_OT_animdata_operation(wmOperatorType *ot) /* **************************************** */ static const EnumPropertyItem prop_constraint_op_types[] = { - {OL_CONSTRAINTOP_ENABLE, "ENABLE", ICON_RESTRICT_VIEW_OFF, "Enable", ""}, - {OL_CONSTRAINTOP_DISABLE, "DISABLE", ICON_RESTRICT_VIEW_ON, "Disable", ""}, + {OL_CONSTRAINTOP_ENABLE, "ENABLE", ICON_HIDE_OFF, "Enable", ""}, + {OL_CONSTRAINTOP_DISABLE, "DISABLE", ICON_HIDE_ON, "Disable", ""}, {OL_CONSTRAINTOP_DELETE, "DELETE", ICON_X, "Delete", ""}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index d155457a208..9f6c944c914 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1469,6 +1469,10 @@ static void outliner_add_layer_collection_objects( Base *base = BKE_view_layer_base_find(layer, cob->ob); TreeElement *te_object = outliner_add_element(soops, tree, base->object, ten, 0, 0); te_object->directdata = base; + + if (!(base->flag & BASE_VISIBLE)) { + te_object->flag |= TE_DISABLED; + } } } @@ -1487,7 +1491,10 @@ static void outliner_add_layer_collections_recursive( ten->reinsert_poll = outliner_collections_reorder_poll; const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0; - if (exclude) { + if (exclude || + ((layer->runtime_flag & VIEW_LAYER_HAS_HIDE) && + !(lc->runtime_flag & LAYER_COLLECTION_HAS_VISIBLE_OBJECTS))) + { ten->flag |= TE_DISABLED; } @@ -1885,10 +1892,11 @@ static int outliner_exclude_filter_get(SpaceOops *soops) { int exclude_filter = soops->filter & ~SO_FILTER_OB_STATE; - if (soops->filter & SO_FILTER_SEARCH) { - if (soops->search_string[0] == 0) { - exclude_filter &= ~SO_FILTER_SEARCH; - } + if (soops->search_string[0] != 0) { + exclude_filter |= SO_FILTER_SEARCH; + } + else { + exclude_filter &= ~SO_FILTER_SEARCH; } /* Let's have this for the collection options at first. */ @@ -1976,7 +1984,7 @@ static bool outliner_element_visible_get(ViewLayer *view_layer, TreeElement *te, } if (exclude_filter & SO_FILTER_OB_STATE_VISIBLE) { - if ((base->flag & BASE_VISIBLED) == 0) { + if ((base->flag & BASE_VISIBLE) == 0) { return false; } } @@ -2262,5 +2270,3 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa BKE_main_id_clear_newpoins(mainvar); } - - diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 2d51a4b4554..6b95df7c917 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -335,6 +335,9 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->overlay.flag = V3D_OVERLAY_LOOK_DEV; v3d->overlay.wireframe_threshold = 0.5f; v3d->overlay.bone_selection_alpha = 0.5f; + v3d->overlay.texture_paint_mode_opacity = 0.8; + v3d->overlay.weight_paint_mode_opacity = 0.8; + v3d->overlay.vertex_paint_mode_opacity = 0.8; v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR; @@ -1410,7 +1413,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes if (view_layer->basact) { Object *ob = view_layer->basact->object; /* if hidden but in edit mode, we still display, can happen with animation */ - if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (ob->mode & OB_MODE_EDIT)) { + if ((view_layer->basact->flag & BASE_VISIBLE) != 0 || (ob->mode & OB_MODE_EDIT)) { CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, view_layer->basact); } } @@ -1422,7 +1425,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes if (view_layer->basact) { Object *ob = view_layer->basact->object; /* if hidden but in edit mode, we still display, can happen with animation */ - if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (ob->mode & OB_MODE_EDIT) != 0) { + if ((view_layer->basact->flag & BASE_VISIBLE) != 0 || (ob->mode & OB_MODE_EDIT) != 0) { CTX_data_id_pointer_set(result, &ob->id); } } @@ -1541,11 +1544,6 @@ void ED_spacetype_view3d(void) art->draw = view3d_tools_region_draw; BLI_addhead(&st->regiontypes, art); -#if 0 - /* unfinished still */ - view3d_toolshelf_register(art); -#endif - /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype view3d header region"); art->regionid = RGN_TYPE_HEADER; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 300b6fafd7a..6ebed88728e 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -69,6 +69,7 @@ #include "RNA_access.h" #include "ED_armature.h" +#include "ED_object.h" #include "ED_mesh.h" #include "ED_screen.h" @@ -1163,6 +1164,11 @@ static void view3d_panel_transform(const bContext *C, Panel *pa) } } +static void hide_collections_menu_draw(const bContext *C, Menu *menu) +{ + ED_hide_collections_menu_draw(C, menu->layout); +} + void view3d_buttons_register(ARegionType *art) { PanelType *pt; @@ -1182,6 +1188,15 @@ void view3d_buttons_register(ARegionType *art) pt->draw = view3d_panel_vgroup; pt->poll = view3d_panel_vgroup_poll; BLI_addtail(&art->paneltypes, pt); + + MenuType *mt; + + mt = MEM_callocN(sizeof(MenuType), "spacetype view3d menu collections"); + strcpy(mt->idname, "VIEW3D_MT_collection"); + strcpy(mt->label, N_("Collection")); + strcpy(mt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); + mt->draw = hide_collections_menu_draw; + WM_menutype_add(mt); } static int view3d_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index fd2f604651b..74554e8d62b 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -44,6 +44,7 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_key.h" +#include "BKE_main.h" #include "BKE_scene.h" #include "BKE_object.h" #include "BKE_paint.h" @@ -1182,7 +1183,7 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect) /** * Information drawn on top of the solid plates and composed data */ -void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset) +void view3d_draw_region_info(const bContext *C, ARegion *ar, const int UNUSED(offset)) { RegionView3D *rv3d = ar->regiondata; View3D *v3d = CTX_wm_view3d(C); @@ -1196,8 +1197,6 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset) rcti rect; ED_region_visible_rect(ar, &rect); - /* Leave room for previously drawn info. */ - rect.ymax -= offset; view3d_draw_border(C, ar); view3d_draw_grease_pencil(C); @@ -1271,11 +1270,12 @@ RenderEngineType *ED_view3d_engine_type(Scene *scene, int drawtype) void view3d_main_region_draw(const bContext *C, ARegion *ar) { + Main *bmain = CTX_data_main(C); View3D *v3d = CTX_wm_view3d(C); view3d_draw_view(C, ar); - GPU_free_images_old(); + GPU_free_images_old(bmain); GPU_pass_cache_garbage_collect(); /* XXX This is in order to draw UI batches with the DRW @@ -1348,7 +1348,7 @@ void ED_view3d_draw_offscreen( if ((v3d->flag2 & V3D_RENDER_SHADOW) == 0) { /* free images which can have changed on frame-change * warning! can be slow so only free animated images - campbell */ - GPU_free_images_anim(); + GPU_free_images_anim(G.main); /* XXX :((( */ } gpuPushProjectionMatrix(); diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 3a89c910ea8..b19001ab834 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -263,7 +263,7 @@ static void backdrawview3d( G.f |= G_BACKBUFSEL; - if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLED) != 0)) { + if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLE) != 0)) { draw_object_backbufsel(depsgraph, scene_eval, v3d, rv3d, obact_eval, select_mode); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index bae186097a8..88c7eabc62f 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4553,7 +4553,7 @@ void VIEW3D_OT_clip_border(wmOperatorType *ot) /* cursor position in vec, result in vec, mval in region coords */ /* note: cannot use event->mval here (called by object_add() */ -void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2]) +void ED_view3d_cursor3d_position(bContext *C, const int mval[2], bool use_depth, float cursor_co[3]) { ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); @@ -4566,32 +4566,35 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2]) if (rv3d == NULL) return; - ED_view3d_calc_zfac(rv3d, fp, &flip); + ED_view3d_calc_zfac(rv3d, cursor_co, &flip); /* reset the depth based on the view offset (we _know_ the offset is infront of us) */ if (flip) { - negate_v3_v3(fp, rv3d->ofs); + negate_v3_v3(cursor_co, rv3d->ofs); /* re initialize, no need to check flip again */ - ED_view3d_calc_zfac(rv3d, fp, NULL /* &flip */ ); + ED_view3d_calc_zfac(rv3d, cursor_co, NULL /* &flip */ ); } - if (U.uiflag & USER_DEPTH_CURSOR) { /* maybe this should be accessed some other way */ + if (use_depth) { /* maybe this should be accessed some other way */ struct Depsgraph *depsgraph = CTX_data_depsgraph(C); view3d_operator_needs_opengl(C); - if (ED_view3d_autodist(depsgraph, ar, v3d, mval, fp, true, NULL)) { + if (ED_view3d_autodist(depsgraph, ar, v3d, mval, cursor_co, true, NULL)) { depth_used = true; } } if (depth_used == false) { float depth_pt[3]; - copy_v3_v3(depth_pt, fp); - ED_view3d_win_to_3d_int(v3d, ar, depth_pt, mval, fp); + copy_v3_v3(depth_pt, cursor_co); + ED_view3d_win_to_3d_int(v3d, ar, depth_pt, mval, cursor_co); } } -void ED_view3d_cursor3d_update(bContext *C, const int mval[2]) +void ED_view3d_cursor3d_position_rotation( + bContext *C, const int mval[2], + const bool use_depth, enum eV3DCursorOrient orientation, + float cursor_co[3], float cursor_quat[4]) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); @@ -4599,16 +4602,26 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2]) ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; - View3DCursor *cursor_curr = ED_view3d_cursor3d_get(scene, v3d); - View3DCursor cursor_prev = *cursor_curr; + /* XXX, caller should check. */ + if (rv3d == NULL) + return; - ED_view3d_cursor3d_position(C, cursor_curr->location, mval); - copy_qt_qt(cursor_curr->rotation, rv3d->viewquat); - cursor_curr->rotation[0] *= -1.0f; + ED_view3d_cursor3d_position(C, mval, use_depth, cursor_co); + + if (orientation == V3D_CURSOR_ORIENT_NONE) { + /* pass */ + } + else if (orientation == V3D_CURSOR_ORIENT_VIEW) { + copy_qt_qt(cursor_quat, rv3d->viewquat); + cursor_quat[0] *= -1.0f; + } + else if (orientation == V3D_CURSOR_ORIENT_GEOM) { + copy_qt_qt(cursor_quat, rv3d->viewquat); + cursor_quat[0] *= -1.0f; - { const float mval_fl[2] = {UNPACK2(mval)}; float ray_no[3]; + float ray_co[3]; struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( bmain, scene, CTX_data_depsgraph(C), 0, ar, v3d); @@ -4624,16 +4637,21 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2]) .use_object_edit_cage = false, }, mval_fl, &dist_px, - cursor_curr->location, ray_no, NULL, + ray_co, ray_no, NULL, &ob_dummy, obmat)) { + if (use_depth) { + copy_v3_v3(cursor_co, ray_co); + } + float tquat[4]; + /* Math normal (Z). */ { float z_src[3] = {0, 0, 1}; - mul_qt_v3(cursor_curr->rotation, z_src); + mul_qt_v3(cursor_quat, z_src); rotation_between_vecs_to_quat(tquat, z_src, ray_no); - mul_qt_qtqt(cursor_curr->rotation, tquat, cursor_curr->rotation); + mul_qt_qtqt(cursor_quat, tquat, cursor_quat); } /* Match object matrix (X). */ @@ -4646,27 +4664,47 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2]) const int ortho_axis = axis_dominant_v3_ortho_single(ortho_axis_dot); float x_src[3] = {1, 0, 0}; float x_dst[3]; - mul_qt_v3(cursor_curr->rotation, x_src); + mul_qt_v3(cursor_quat, x_src); project_plane_v3_v3v3(x_dst, obmat[ortho_axis], ray_no); normalize_v3(x_dst); rotation_between_vecs_to_quat(tquat, x_src, x_dst); - mul_qt_qtqt(cursor_curr->rotation, tquat, cursor_curr->rotation); + mul_qt_qtqt(cursor_quat, tquat, cursor_quat); } } ED_transform_snap_object_context_destroy(snap_context); } +} + +void ED_view3d_cursor3d_update( + bContext *C, const int mval[2], + const bool use_depth, enum eV3DCursorOrient orientation) +{ + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); + RegionView3D *rv3d = ar->regiondata; + + View3DCursor *cursor_curr = ED_view3d_cursor3d_get(scene, v3d); + View3DCursor cursor_prev = *cursor_curr; + + ED_view3d_cursor3d_position_rotation( + C, mval, + use_depth, orientation, + cursor_curr->location, cursor_curr->rotation); /* offset the cursor lock to avoid jumping to new offset */ if (v3d->ob_centre_cursor) { if (U.uiflag & USER_LOCK_CURSOR_ADJUST) { - float co_curr[2], co_prev[2]; + float co_2d_curr[2], co_2d_prev[2]; - if ((ED_view3d_project_float_global(ar, cursor_prev.location, co_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && - (ED_view3d_project_float_global(ar, cursor_curr->location, co_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) + if ((ED_view3d_project_float_global( + ar, cursor_prev.location, co_2d_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && + (ED_view3d_project_float_global( + ar, cursor_curr->location, co_2d_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) { - rv3d->ofs_lock[0] += (co_curr[0] - co_prev[0]) / (ar->winx * 0.5f); - rv3d->ofs_lock[1] += (co_curr[1] - co_prev[1]) / (ar->winy * 0.5f); + rv3d->ofs_lock[0] += (co_2d_curr[0] - co_2d_prev[0]) / (ar->winx * 0.5f); + rv3d->ofs_lock[1] += (co_2d_curr[1] - co_2d_prev[1]) / (ar->winy * 0.5f); } } else { @@ -4689,9 +4727,20 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2]) DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); } -static int view3d_cursor3d_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) +static int view3d_cursor3d_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - ED_view3d_cursor3d_update(C, event->mval); + bool use_depth = (U.uiflag & USER_DEPTH_CURSOR); + { + PropertyRNA *prop = RNA_struct_find_property(op->ptr, "use_depth"); + if (RNA_property_is_set(op->ptr, prop)) { + use_depth = RNA_property_boolean_get(op->ptr, prop); + } + else { + RNA_property_boolean_set(op->ptr, prop, use_depth); + } + } + const enum eV3DCursorOrient orientation = RNA_enum_get(op->ptr, "orientation"); + ED_view3d_cursor3d_update(C, event->mval, use_depth, orientation); return OPERATOR_FINISHED; } @@ -4711,6 +4760,24 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot) /* flags */ // ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + + PropertyRNA *prop; + static const EnumPropertyItem orientation_items[] = { + {V3D_CURSOR_ORIENT_NONE, "NONE", 0, "None", "Leave orientation unchanged"}, + {V3D_CURSOR_ORIENT_VIEW, "VIEW", 0, "View", "Orient to the viewport"}, + {V3D_CURSOR_ORIENT_GEOM, "GEOM", 0, "Geometry", "Match the surface normal"}, + {0, NULL, 0, NULL, NULL} + }; + + prop = RNA_def_boolean( + ot->srna, "use_depth", true, "Surface Project", + "Project onto the surface"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + + prop = RNA_def_enum( + ot->srna, "orientation", orientation_items, V3D_CURSOR_ORIENT_VIEW, + "Orientation", "Preset viewpoint to use"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 017b31a0bf2..4eb2a016b94 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -235,7 +235,6 @@ struct Object *ED_view3d_cameracontrol_object_get( /* view3d_toolbar.c */ void VIEW3D_OT_toolshelf(struct wmOperatorType *ot); -void view3d_toolshelf_register(struct ARegionType *art); /* view3d_snap.c */ bool ED_view3d_minmax_verts(struct Object *obedit, float min[3], float max[3]); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index b3211ed1108..267712b3339 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -302,7 +302,7 @@ void view3d_keymap(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", CKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "center", true); - WM_keymap_add_menu_pie(keymap, "VIEW3D_PIE_view", ACCENTGRAVEKEY, KM_CLICK_DRAG, 0, 0); + WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_view_pie", ACCENTGRAVEKEY, KM_CLICK_DRAG, 0, 0); /* numpad view hotkeys*/ RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD0, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_CAMERA); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index b4f3be178aa..c0a133032ea 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1326,7 +1326,7 @@ static Base *mouse_select_eval_buffer( while (base) { /* skip objects with select restriction, to prevent prematurely ending this loop * with an un-selectable choice */ - if ((base->flag & BASE_SELECTABLED) == 0) { + if ((base->flag & BASE_SELECTABLE) == 0) { base = base->next; if (base == NULL) base = FIRSTBASE(view_layer); if (base == startbase) break; diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index acceb40beaa..707e0e7a394 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -28,153 +28,24 @@ * \ingroup spview3d */ - #include <string.h> #include <stdio.h> #include <math.h> #include <float.h> -#include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "MEM_guardedalloc.h" - -#include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BLI_ghash.h" - -#include "BLT_translation.h" #include "BKE_context.h" -#include "BKE_screen.h" - #include "WM_api.h" #include "WM_types.h" -#include "RNA_access.h" - #include "ED_screen.h" -#include "ED_undo.h" - -#include "UI_interface.h" -#include "UI_resources.h" #include "view3d_intern.h" /* own include */ -/* ******************* */ - -typedef struct CustomTool { - struct CustomTool *next, *prev; - char opname[OP_MAX_TYPENAME]; - char context[OP_MAX_TYPENAME]; -} CustomTool; - -static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) -{ - wmOperatorType *ot = arg2; - - if (ot) { - CustomTool *ct = MEM_callocN(sizeof(CustomTool), "CustomTool"); - - BLI_addtail(arg_listbase, ct); - BLI_strncpy(ct->opname, ot->idname, OP_MAX_TYPENAME); - BLI_strncpy(ct->context, CTX_data_mode_string(C), OP_MAX_TYPENAME); - } - -} - -static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) -{ - GHashIterator iter; - - for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { - wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); - - if (BLI_strcasestr(ot->name, str)) { - if (WM_operator_poll((bContext *)C, ot)) { - - if (false == UI_search_item_add(items, ot->name, ot, 0)) - break; - } - } - } -} - - -/* ID Search browse menu, open */ -static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) -{ - static char search[OP_MAX_TYPENAME]; - wmEvent event; - wmWindow *win = CTX_wm_window(C); - uiBlock *block; - uiBut *but; - - /* clear initial search string, then all items show */ - search[0] = 0; - - block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); - UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_SEARCH_MENU); - - /* fake button, it holds space for search items */ - uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 15, UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL); - - but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, ""); - UI_but_func_search_set(but, NULL, operator_search_cb, arg_listbase, operator_call_cb, NULL); - - UI_block_bounds_set_normal(block, 6); - UI_block_direction_set(block, UI_DIR_DOWN); - UI_block_end(C, block); - - wm_event_init_from_window(win, &event); - event.type = EVT_BUT_OPEN; - event.val = KM_PRESS; - event.customdata = but; - event.customdatafree = false; - wm_event_add(win, &event); - - return block; -} - - -static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) -{ - SpaceLink *sl = CTX_wm_space_data(C); - SpaceType *st = NULL; - uiLayout *col; - const char *context = CTX_data_mode_string(C); - - if (sl) - st = BKE_spacetype_from_id(sl->spacetype); - - if (st && st->toolshelf.first) { - CustomTool *ct; - - for (ct = st->toolshelf.first; ct; ct = ct->next) { - if (STREQLEN(context, ct->context, OP_MAX_TYPENAME)) { - col = uiLayoutColumn(pa->layout, true); - uiItemFullO(col, ct->opname, NULL, ICON_NONE, NULL, WM_OP_INVOKE_REGION_WIN, 0, NULL); - } - } - } - col = uiLayoutColumn(pa->layout, true); - uiDefBlockBut(uiLayoutGetBlock(pa->layout), tool_search_menu, &st->toolshelf, "Add Tool", 0, 0, UI_UNIT_X, UI_UNIT_Y, "Add Tool in shelf, gets saved in files"); -} - - -void view3d_toolshelf_register(ARegionType *art) -{ - PanelType *pt; - - pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel tools"); - strcpy(pt->idname, "VIEW3D_PT_tool_shelf"); - strcpy(pt->label, N_("Tool Shelf")); - strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); - pt->draw = view3d_panel_tool_shelf; - BLI_addtail(&art->paneltypes, pt); -} - /* ********** operator to open/close toolshelf region */ static int view3d_toolshelf_toggle_exec(bContext *C, wmOperator *UNUSED(op)) @@ -200,4 +71,3 @@ void VIEW3D_OT_toolshelf(wmOperatorType *ot) /* flags */ ot->flag = 0; } - diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index abb8c688e05..8b9ad387065 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -509,7 +509,6 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op) { Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); /* can be NULL */ Object *camera_ob = v3d ? v3d->camera : scene->camera; Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob); @@ -523,7 +522,7 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op) } /* this function does all the important stuff */ - if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, view_layer, camera_ob_eval, r_co, &r_scale)) { + if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, camera_ob_eval, r_co, &r_scale)) { ObjectTfmProtectedChannels obtfm; float obmat_new[4][4]; diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 3c70eaae2d3..93e644b9706 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -559,7 +559,7 @@ static void applyObjectConstraintRot( /* on setup call, use first object */ if (td == NULL) { - td = tc->data; + td = TRANS_DATA_CONTAINER_FIRST_OK(t)->data; } if (t->flag & T_EDIT) { diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c index 75da0fc2d23..ccf6cc8c7ce 100644 --- a/source/blender/editors/transform/transform_manipulator_3d.c +++ b/source/blender/editors/transform/transform_manipulator_3d.c @@ -159,18 +159,15 @@ enum { MAN_AXES_SCALE, }; -/* naming from old blender we may combine. */ -enum { - V3D_MANIP_TRANSLATE = 1, - V3D_MANIP_ROTATE = 2, - V3D_MANIP_SCALE = 4, -}; - - typedef struct ManipulatorGroup { bool all_hidden; int twtype; + /* Users may change the twtype, detect changes to re-setup manipulator options. */ + int twtype_init; + int twtype_prev; + int use_twtype_refresh; + struct wmManipulator *manipulators[MAN_AXIS_LAST]; } ManipulatorGroup; @@ -269,9 +266,9 @@ static bool manipulator_is_axis_visible( } } - if ((axis_type == MAN_AXES_TRANSLATE && !(twtype & V3D_MANIP_TRANSLATE)) || - (axis_type == MAN_AXES_ROTATE && !(twtype & V3D_MANIP_ROTATE)) || - (axis_type == MAN_AXES_SCALE && !(twtype & V3D_MANIP_SCALE))) + if ((axis_type == MAN_AXES_TRANSLATE && !(twtype & SCE_MANIP_TRANSLATE)) || + (axis_type == MAN_AXES_ROTATE && !(twtype & SCE_MANIP_ROTATE)) || + (axis_type == MAN_AXES_SCALE && !(twtype & SCE_MANIP_SCALE))) { return false; } @@ -301,34 +298,34 @@ static bool manipulator_is_axis_visible( case MAN_AXIS_SCALE_Z: return (rv3d->twdrawflag & MAN_SCALE_Z); case MAN_AXIS_SCALE_C: - return (rv3d->twdrawflag & MAN_SCALE_C && (twtype & V3D_MANIP_TRANSLATE) == 0); + return (rv3d->twdrawflag & MAN_SCALE_C && (twtype & SCE_MANIP_TRANSLATE) == 0); case MAN_AXIS_TRANS_XY: return (rv3d->twdrawflag & MAN_TRANS_X && rv3d->twdrawflag & MAN_TRANS_Y && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_TRANS_YZ: return (rv3d->twdrawflag & MAN_TRANS_Y && rv3d->twdrawflag & MAN_TRANS_Z && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_TRANS_ZX: return (rv3d->twdrawflag & MAN_TRANS_Z && rv3d->twdrawflag & MAN_TRANS_X && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_SCALE_XY: return (rv3d->twdrawflag & MAN_SCALE_X && rv3d->twdrawflag & MAN_SCALE_Y && - (twtype & V3D_MANIP_TRANSLATE) == 0 && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_TRANSLATE) == 0 && + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_SCALE_YZ: return (rv3d->twdrawflag & MAN_SCALE_Y && rv3d->twdrawflag & MAN_SCALE_Z && - (twtype & V3D_MANIP_TRANSLATE) == 0 && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_TRANSLATE) == 0 && + (twtype & SCE_MANIP_ROTATE) == 0); case MAN_AXIS_SCALE_ZX: return (rv3d->twdrawflag & MAN_SCALE_Z && rv3d->twdrawflag & MAN_SCALE_X && - (twtype & V3D_MANIP_TRANSLATE) == 0 && - (twtype & V3D_MANIP_ROTATE) == 0); + (twtype & SCE_MANIP_TRANSLATE) == 0 && + (twtype & SCE_MANIP_ROTATE) == 0); } return false; } @@ -1122,15 +1119,15 @@ static void manipulator_line_range(const int twtype, const short axis_type, floa switch (axis_type) { case MAN_AXES_TRANSLATE: - if (twtype & V3D_MANIP_SCALE) { + if (twtype & SCE_MANIP_SCALE) { *r_start = *r_len - ofs + 0.075f; } - if (twtype & V3D_MANIP_ROTATE) { + if (twtype & SCE_MANIP_ROTATE) { *r_len += ofs; } break; case MAN_AXES_SCALE: - if (twtype & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE)) { + if (twtype & (SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE)) { *r_len -= ofs + 0.025f; } break; @@ -1172,8 +1169,10 @@ static void manipulator_xform_message_subscribe( if (type_fn == TRANSFORM_WGT_manipulator) { extern PropertyRNA rna_ToolSettings_transform_pivot_point; + extern PropertyRNA rna_ToolSettings_use_manipulator_mode; const PropertyRNA *props[] = { - &rna_ToolSettings_transform_pivot_point + &rna_ToolSettings_transform_pivot_point, + &rna_ToolSettings_use_manipulator_mode, }; for (int i = 0; i < ARRAY_SIZE(props); i++) { WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); @@ -1285,41 +1284,12 @@ static int manipulator_modal( return OPERATOR_RUNNING_MODAL; } -static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup *mgroup) +static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgroup) { - ManipulatorGroup *man = manipulatorgroup_init(mgroup); struct { wmOperatorType *translate, *rotate, *trackball, *resize; } ot_store = {NULL}; - - mgroup->customdata = man; - - { - /* TODO: support mixing modes again? - it's supported but tool system makes it unobvious. */ - man->twtype = 0; - ScrArea *sa = CTX_wm_area(C); - bToolRef_Runtime *tref_rt = sa->runtime.tool ? sa->runtime.tool->runtime : NULL; - wmKeyMap *km = tref_rt ? WM_keymap_find_all(C, tref_rt->keymap, sa->spacetype, RGN_TYPE_WINDOW) : NULL; - /* Weak, check first event */ - wmKeyMapItem *kmi = km ? km->items.first : NULL; - - if (kmi == NULL) { - man->twtype |= V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE | V3D_MANIP_SCALE; - } - else if (STREQ(kmi->idname, "TRANSFORM_OT_translate")) { - man->twtype |= V3D_MANIP_TRANSLATE; - } - else if (STREQ(kmi->idname, "TRANSFORM_OT_rotate")) { - man->twtype |= V3D_MANIP_ROTATE; - } - else if (STREQ(kmi->idname, "TRANSFORM_OT_resize")) { - man->twtype |= V3D_MANIP_SCALE; - } - BLI_assert(man->twtype != 0); - } - - /* *** set properties for axes *** */ - + ManipulatorGroup *man = mgroup->customdata; MAN_ITER_AXES_BEGIN(axis, axis_idx) { const short axis_type = manipulator_get_axis_type(axis_idx); @@ -1340,7 +1310,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup case MAN_AXIS_SCALE_Z: if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { int draw_options = 0; - if ((man->twtype & (V3D_MANIP_ROTATE | V3D_MANIP_SCALE)) == 0) { + if ((man->twtype & (SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) { draw_options |= ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM; } RNA_enum_set(axis->ptr, "draw_options", draw_options); @@ -1434,6 +1404,42 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup MAN_ITER_AXES_END; } +static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup *mgroup) +{ + ManipulatorGroup *man = manipulatorgroup_init(mgroup); + + mgroup->customdata = man; + + { + man->twtype = 0; + ScrArea *sa = CTX_wm_area(C); + bToolRef_Runtime *tref_rt = sa->runtime.tool ? sa->runtime.tool->runtime : NULL; + wmKeyMap *km = tref_rt ? WM_keymap_find_all(C, tref_rt->keymap, sa->spacetype, RGN_TYPE_WINDOW) : NULL; + /* Weak, check first event */ + wmKeyMapItem *kmi = km ? km->items.first : NULL; + + if (kmi == NULL) { + /* Setup all manipulators, they can be toggled via 'ToolSettings.manipulator_flag' */ + man->twtype = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; + man->use_twtype_refresh = true; + } + else if (STREQ(kmi->idname, "TRANSFORM_OT_translate")) { + man->twtype |= SCE_MANIP_TRANSLATE; + } + else if (STREQ(kmi->idname, "TRANSFORM_OT_rotate")) { + man->twtype |= SCE_MANIP_ROTATE; + } + else if (STREQ(kmi->idname, "TRANSFORM_OT_resize")) { + man->twtype |= SCE_MANIP_SCALE; + } + BLI_assert(man->twtype != 0); + man->twtype_init = man->twtype; + } + + /* *** set properties for axes *** */ + manipulatorgroup_init_properties_from_twtype(mgroup); +} + static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGroup *mgroup) { ManipulatorGroup *man = mgroup->customdata; @@ -1443,6 +1449,15 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou RegionView3D *rv3d = ar->regiondata; struct TransformBounds tbounds; + if (man->use_twtype_refresh) { + Scene *scene = CTX_data_scene(C); + man->twtype = scene->toolsettings->manipulator_flag & man->twtype_init; + if (man->twtype != man->twtype_prev) { + man->twtype_prev = man->twtype; + manipulatorgroup_init_properties_from_twtype(mgroup); + } + } + /* skip, we don't draw anything anyway */ if ((man->all_hidden = (ED_transform_calc_manipulator_stats( @@ -1481,7 +1496,7 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou RNA_float_set(axis->ptr, "length", len); if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { - if (man->twtype & V3D_MANIP_ROTATE) { + if (man->twtype & SCE_MANIP_ROTATE) { /* Avoid rotate and translate arrows overlap. */ start_co[2] += 0.215f; } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 704582deaca..02855e0a809 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -51,7 +51,6 @@ #include "GPU_immediate.h" -#include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_object.h" #include "BKE_anim.h" /* for duplis */ diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index c4bfe83ed4c..478e004743d 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -411,7 +411,7 @@ static const EnumPropertyItem *rna_undo_itemf(bContext *C, int *totitem) item_tmp.identifier = us->name; item_tmp.name = IFACE_(us->name); if (us == wm->undo_stack->step_active) { - item_tmp.icon = ICON_RESTRICT_VIEW_OFF; + item_tmp.icon = ICON_HIDE_OFF; } else { item_tmp.icon = ICON_NONE; diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 4473922841f..b3f3d188851 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -502,7 +502,7 @@ static void draw_uvs_other(ViewLayer *view_layer, Object *obedit, const Image *c for (Base *base = view_layer->object_bases.first; base; base = base->next) { if (((base->flag & BASE_SELECTED) != 0) && - ((base->flag & BASE_VISIBLED) != 0)) + ((base->flag & BASE_VISIBLE) != 0)) { Object *ob = base->object; if ((ob->type == OB_MESH) && (ob != obedit) && ((Mesh *)ob->data)->mloopuv) { diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 78b412579e6..5f60a5a714a 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -496,7 +496,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B smd.subdivType = smd_real->subdivType; initialDerived = CDDM_from_editbmesh(em, false, false); - derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd, + derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd, scene, NULL, SUBSURF_IN_EDIT_MODE); initialDerived->release(initialDerived); diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h index 79ba9421cda..4f5e94ef7a0 100644 --- a/source/blender/freestyle/intern/system/PythonInterpreter.h +++ b/source/blender/freestyle/intern/system/PythonInterpreter.h @@ -81,7 +81,7 @@ public: bool ok = BPY_execute_filepath(_context, fn, reports); #else bool ok; - Text *text = BKE_text_load(&_freestyle_bmain, fn, G.main->name); + Text *text = BKE_text_load(&_freestyle_bmain, fn, G_MAIN->name); if (text) { ok = BPY_execute_text(_context, text, reports, false); BKE_libblock_delete(&_freestyle_bmain, text); diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 613a07dc869..448945cd7ba 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -39,6 +39,7 @@ extern "C" { struct ImBuf; struct Image; struct ImageUser; +struct Main; struct Object; struct Scene; struct ViewLayer; @@ -68,19 +69,19 @@ void GPU_disable_program_point_size(void); /* Mipmap settings * - these will free textures on changes */ -void GPU_set_mipmap(bool mipmap); +void GPU_set_mipmap(struct Main *bmain, bool mipmap); bool GPU_get_mipmap(void); void GPU_set_linear_mipmap(bool linear); bool GPU_get_linear_mipmap(void); -void GPU_paint_set_mipmap(bool mipmap); +void GPU_paint_set_mipmap(struct Main *bmain, bool mipmap); /* Anisotropic filtering settings * - these will free textures on changes */ -void GPU_set_anisotropic(float value); +void GPU_set_anisotropic(struct Main *bmain, float value); float GPU_get_anisotropic(void); /* enable gpu mipmapping */ -void GPU_set_gpu_mipmapping(int gpu_mipmap); +void GPU_set_gpu_mipmapping(struct Main *bmain, int gpu_mipmap); /* Image updates and free * - these deal with images bound as opengl textures */ @@ -94,16 +95,16 @@ void GPU_create_gl_tex_compressed( int textarget, struct Image *ima, struct ImBuf *ibuf); bool GPU_upload_dxt_texture(struct ImBuf *ibuf); void GPU_free_image(struct Image *ima); -void GPU_free_images(void); -void GPU_free_images_anim(void); -void GPU_free_images_old(void); +void GPU_free_images(struct Main *bmain); +void GPU_free_images_anim(struct Main *bmain); +void GPU_free_images_old(struct Main *bmain); /* smoke drawing functions */ void GPU_free_smoke(struct SmokeModifierData *smd); void GPU_create_smoke(struct SmokeModifierData *smd, int highres); /* Delayed free of OpenGL buffers by main thread */ -void GPU_free_unused_buffers(void); +void GPU_free_unused_buffers(struct Main *bmain); /* utilities */ void GPU_select_index_set(int index); diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index 0805cc25d04..a65c09152ee 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -44,6 +44,7 @@ extern "C" { struct Image; struct ImageUser; struct ListBase; +struct Main; struct Material; struct Object; struct Scene; @@ -251,7 +252,7 @@ GPUMaterial *GPU_material_from_nodetree( void GPU_material_compile(GPUMaterial *mat); void GPU_material_free(struct ListBase *gpumaterial); -void GPU_materials_free(void); +void GPU_materials_free(struct Main *bmain); void GPU_material_orphans_init(void); void GPU_material_orphans_exit(void); diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index e53693e7b40..07880df9dc0 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -142,6 +142,19 @@ typedef enum GPUTextureFormat { GPU_DEPTH_COMPONENT16, } GPUTextureFormat; +/* These map directly to the GL_ blend functions, to minimize API add as needed*/ +typedef enum GPUBlendFunction { + GPU_ONE, + GPU_SRC_ALPHA, + GPU_ONE_MINUS_SRC_ALPHA +} GPUBlendFunction; + +/* These map directly to the GL_ filter functions, to minimize API add as needed*/ +typedef enum GPUFilterFunction { + GPU_NEAREST, + GPU_LINEAR +} GPUFilterFunction; + unsigned int GPU_texture_memory_usage_get(void); GPUTexture *GPU_texture_create_1D( @@ -166,7 +179,10 @@ GPUTexture *GPU_texture_from_blender( struct Image *ima, struct ImageUser *iuser, int textarget, bool is_data, double time); GPUTexture *GPU_texture_from_preview(struct PreviewImage *prv, int mipmap); -void GPU_texture_update(GPUTexture *tex, const float *pixels); +void GPU_texture_update(GPUTexture *tex, const void *pixels); +void GPU_texture_update_sub( + GPUTexture *tex, const void *pixels, + int offset_x, int offset_y, int offset_z, int width, int height, int depth); void GPU_invalid_tex_init(void); void GPU_invalid_tex_bind(int mode); @@ -189,6 +205,7 @@ void GPU_texture_compare_mode(GPUTexture *tex, bool use_compare); void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter); void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter); void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat); +void GPU_texture_filters(GPUTexture *tex, GPUFilterFunction min_filter, GPUFilterFunction mag_filter); void GPU_texture_attach_framebuffer(GPUTexture *tex, struct GPUFrameBuffer *fb, int attachment); int GPU_texture_detach_framebuffer(GPUTexture *tex, struct GPUFrameBuffer *fb); @@ -204,6 +221,10 @@ bool GPU_texture_stencil(const GPUTexture *tex); bool GPU_texture_integer(const GPUTexture *tex); int GPU_texture_opengl_bindcode(const GPUTexture *tex); +void GPU_blend(bool enable); +void GPU_blend_set_func_separate(GPUBlendFunction src_rgb, GPUBlendFunction dst_rgb, GPUBlendFunction src_alpha, GPUBlendFunction dst_alpha); +void GPU_blend_set_func(GPUBlendFunction sfactor, GPUBlendFunction dfactor); + #ifdef __cplusplus } #endif diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index df8dbb03284..688386810ea 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -791,11 +791,14 @@ void GPU_pbvh_bmesh_buffers_update( tottri = gpu_bmesh_face_visible_count(bm_faces); if (buffers->smooth) { + /* Smooth needs to recreate index buffer, so we have to invalidate the batch. */ + GWN_BATCH_DISCARD_SAFE(buffers->triangles); /* Count visible vertices */ totvert = gpu_bmesh_vert_visible_count(bm_unique_verts, bm_other_verts); } - else + else { totvert = tottri * 3; + } if (!tottri) { buffers->tot_tri = 0; @@ -905,13 +908,11 @@ void GPU_pbvh_bmesh_buffers_update( BMFace *f = BLI_gsetIterator_getKey(&gs_iter); if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { - BMLoop *l_iter; - BMLoop *l_first; + BMVert *v[3]; - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { - GWN_indexbuf_add_generic_vert(&elb, BM_elem_index_get(l_iter->v)); - } while ((l_iter = l_iter->next) != l_first); + BM_face_as_array_vert_tri(f, v); + GWN_indexbuf_add_tri_verts( + &elb, BM_elem_index_get(v[0]), BM_elem_index_get(v[1]), BM_elem_index_get(v[2])); } } diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 83fd689e3b7..7383868843d 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -140,7 +140,7 @@ static struct GPUTextureState { /* Mipmap settings */ -void GPU_set_gpu_mipmapping(int gpu_mipmap) +void GPU_set_gpu_mipmapping(Main *bmain, int gpu_mipmap) { int old_value = GTS.gpu_mipmap; @@ -148,14 +148,14 @@ void GPU_set_gpu_mipmapping(int gpu_mipmap) GTS.gpu_mipmap = gpu_mipmap; if (old_value != GTS.gpu_mipmap) { - GPU_free_images(); + GPU_free_images(bmain); } } -void GPU_set_mipmap(bool mipmap) +void GPU_set_mipmap(Main *bmain, bool mipmap) { if (GTS.domipmap != mipmap) { - GPU_free_images(); + GPU_free_images(bmain); GTS.domipmap = mipmap; } } @@ -203,10 +203,10 @@ static GLenum gpu_get_mipmap_filter(bool mag) } /* Anisotropic filtering settings */ -void GPU_set_anisotropic(float value) +void GPU_set_anisotropic(Main *bmain, float value) { if (GTS.anisotropic != value) { - GPU_free_images(); + GPU_free_images(bmain); /* Clamp value to the maximum value the graphics card supports */ const float max = GPU_max_texture_anisotropy(); @@ -682,7 +682,7 @@ void GPU_create_gl_tex_compressed( * temporary disabling/enabling mipmapping on all images for quick texture * updates with glTexSubImage2D. images that didn't change don't have to be * re-uploaded to OpenGL */ -void GPU_paint_set_mipmap(bool mipmap) +void GPU_paint_set_mipmap(Main *bmain, bool mipmap) { if (!GTS.domipmap) return; @@ -690,7 +690,7 @@ void GPU_paint_set_mipmap(bool mipmap) GTS.texpaint = !mipmap; if (mipmap) { - for (Image *ima = G.main->image.first; ima; ima = ima->id.next) { + for (Image *ima = bmain->image.first; ima; ima = ima->id.next) { if (BKE_image_has_opengl_texture(ima)) { if (ima->tpageflag & IMA_MIPMAP_COMPLETE) { if (ima->gputexture[TEXTARGET_TEXTURE_2D]) { @@ -709,7 +709,7 @@ void GPU_paint_set_mipmap(bool mipmap) } else { - for (Image *ima = G.main->image.first; ima; ima = ima->id.next) { + for (Image *ima = bmain->image.first; ima; ima = ima->id.next) { if (BKE_image_has_opengl_texture(ima)) { if (ima->gputexture[TEXTARGET_TEXTURE_2D]) { GPU_texture_bind(ima->gputexture[TEXTARGET_TEXTURE_2D], 0); @@ -980,7 +980,7 @@ static void gpu_queue_image_for_free(Image *ima) BLI_thread_unlock(LOCK_OPENGL); } -void GPU_free_unused_buffers(void) +void GPU_free_unused_buffers(Main *bmain) { if (!BLI_thread_is_main()) return; @@ -992,7 +992,7 @@ void GPU_free_unused_buffers(void) Image *ima = node->link; /* check in case it was freed in the meantime */ - if (G.main && BLI_findindex(&G.main->image, ima) != -1) + if (bmain && BLI_findindex(&bmain->image, ima) != -1) GPU_free_image(ima); } @@ -1020,24 +1020,29 @@ void GPU_free_image(Image *ima) ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE | IMA_GLBIND_IS_DATA); } -void GPU_free_images(void) +void GPU_free_images(Main *bmain) { - if (G.main) - for (Image *ima = G.main->image.first; ima; ima = ima->id.next) + if (bmain) { + for (Image *ima = bmain->image.first; ima; ima = ima->id.next) { GPU_free_image(ima); + } + } } /* same as above but only free animated images */ -void GPU_free_images_anim(void) +void GPU_free_images_anim(Main *bmain) { - if (G.main) - for (Image *ima = G.main->image.first; ima; ima = ima->id.next) - if (BKE_image_is_animated(ima)) + if (bmain) { + for (Image *ima = bmain->image.first; ima; ima = ima->id.next) { + if (BKE_image_is_animated(ima)) { GPU_free_image(ima); + } + } + } } -void GPU_free_images_old(void) +void GPU_free_images_old(Main *bmain) { static int lasttime = 0; int ctime = (int)PIL_check_seconds_timer(); @@ -1055,7 +1060,7 @@ void GPU_free_images_old(void) lasttime = ctime; - Image *ima = G.main->image.first; + Image *ima = bmain->image.first; while (ima) { if ((ima->flag & IMA_NOCOLLECT) == 0 && ctime - ima->lastused > U.textimeout) { /* If it's in GL memory, deallocate and set time tag to current time diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 302ddc62188..9c776e64ba0 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -723,16 +723,16 @@ void GPU_material_compile(GPUMaterial *mat) } } -void GPU_materials_free(void) +void GPU_materials_free(Main *bmain) { Material *ma; World *wo; extern Material defmaterial; - for (ma = G.main->mat.first; ma; ma = ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) GPU_material_free(&ma->gpumaterial); - for (wo = G.main->world.first; wo; wo = wo->id.next) + for (wo = bmain->world.first; wo; wo = wo->id.next) GPU_material_free(&wo->gpumaterial); GPU_material_free(&defmaterial.gpumaterial); diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index ee00a1381f4..21a3aee5f57 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -171,6 +171,10 @@ static GLenum gpu_texture_get_format( default: break; } } + else if (ELEM(data_type, GPU_R8)) { + *data_format = GL_UNSIGNED_BYTE; + *format = GL_RED; + } else { *data_format = GL_FLOAT; *format_flag |= GPU_FORMAT_FLOAT; @@ -882,37 +886,58 @@ GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) return GPU_texture_create_buffer(data_type, vert->vbo_id); } -void GPU_texture_update(GPUTexture *tex, const float *pixels) +void GPU_texture_update_sub( + GPUTexture *tex, const void *pixels, + int offset_x, int offset_y, int offset_z, int width, int height, int depth) { - BLI_assert(tex->format > -1); + BLI_assert((int)tex->format > -1); BLI_assert(tex->components > -1); GLenum format, data_format; + GLint alignment; gpu_texture_get_format(tex->components, tex->format, &format, &data_format, - &tex->format_flag, &tex->bytesize); + &tex->format_flag, &tex->bytesize); - glBindTexture(tex->target, tex->bindcode); + /* The default pack size for textures is 4, which won't work for byte based textures */ + if (tex->bytesize == 1) { + glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + } + glBindTexture(tex->target, tex->bindcode); switch (tex->target) { case GL_TEXTURE_2D: case GL_TEXTURE_2D_MULTISAMPLE: case GL_TEXTURE_1D_ARRAY: - glTexSubImage2D(tex->target, 0, 0, 0, tex->w, tex->h, format, data_format, pixels); + glTexSubImage2D( + tex->target, 0, offset_x, offset_y, + width, height, format, data_format, pixels); break; case GL_TEXTURE_1D: - glTexSubImage1D(tex->target, 0, 0, tex->w, format, data_format, pixels); + glTexSubImage1D(tex->target, 0, offset_x, width, format, data_format, pixels); break; case GL_TEXTURE_3D: case GL_TEXTURE_2D_ARRAY: - glTexSubImage3D(tex->target, 0, 0, 0, 0, tex->w, tex->h, tex->d, format, data_format, pixels); + glTexSubImage3D( + tex->target, 0, offset_x, offset_y, offset_z, + width, height, depth, format, data_format, pixels); break; default: BLI_assert(!"tex->target mode not supported"); } + if (tex->bytesize == 1) { + glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); + } + glBindTexture(tex->target, 0); } +void GPU_texture_update(GPUTexture *tex, const void *pixels) +{ + GPU_texture_update_sub(tex, pixels, 0, 0, 0, tex->w, tex->h, tex->d); +} + void GPU_invalid_tex_init(void) { memory_usage = 0; @@ -1045,9 +1070,10 @@ void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter) BLI_assert((!use_filter && !use_mipmap) || !(GPU_texture_stencil(tex) || GPU_texture_integer(tex))); GLenum filter = (use_filter) ? GL_LINEAR : GL_NEAREST; - GLenum mipmap = (use_filter) - ? (use_mipmap) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR - : (use_mipmap) ? GL_NEAREST_MIPMAP_LINEAR : GL_NEAREST; + GLenum mipmap = ( + (use_filter) ? + (use_mipmap) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR : + (use_mipmap) ? GL_NEAREST_MIPMAP_LINEAR : GL_NEAREST); glActiveTexture(GL_TEXTURE0 + tex->number); glTexParameteri(tex->target_base, GL_TEXTURE_MIN_FILTER, mipmap); @@ -1068,6 +1094,33 @@ void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat) glTexParameteri(tex->target_base, GL_TEXTURE_WRAP_R, repeat); } +static GLenum gpu_get_gl_filterfunction(GPUFilterFunction filter) +{ + switch (filter) { + case GPU_NEAREST: + return GL_NEAREST; + case GPU_LINEAR: + return GL_LINEAR; + default: + BLI_assert(!"Unhandled filter mode"); + return GL_NEAREST; + } +} + +void GPU_texture_filters(GPUTexture *tex, GPUFilterFunction min_filter, GPUFilterFunction mag_filter) +{ + WARN_NOT_BOUND(tex); + + /* Stencil and integer format does not support filtering. */ + BLI_assert(!(GPU_texture_stencil(tex) || GPU_texture_integer(tex))); + BLI_assert(mag_filter == GPU_NEAREST || mag_filter == GPU_LINEAR); + + glActiveTexture(GL_TEXTURE0 + tex->number); + glTexParameteri(tex->target_base, GL_TEXTURE_MIN_FILTER, gpu_get_gl_filterfunction(min_filter)); + glTexParameteri(tex->target_base, GL_TEXTURE_MAG_FILTER, gpu_get_gl_filterfunction(mag_filter)); +} + + static void gpu_texture_delete(GPUTexture *tex) { if (tex->bindcode) @@ -1207,3 +1260,43 @@ int GPU_texture_detach_framebuffer(GPUTexture *tex, GPUFrameBuffer *fb) BLI_assert(!"Error: Texture: Framebuffer is not attached"); return 0; } + +void GPU_blend(bool enable) +{ + if (enable) { + glEnable(GL_BLEND); + } + else { + glDisable(GL_BLEND); + } +} + +static GLenum gpu_get_gl_blendfunction(GPUBlendFunction blend) +{ + switch (blend) { + case GPU_ONE: + return GL_ONE; + case GPU_SRC_ALPHA: + return GL_SRC_ALPHA; + case GPU_ONE_MINUS_SRC_ALPHA: + return GL_ONE_MINUS_SRC_ALPHA; + default: + BLI_assert(!"Unhandled blend mode"); + return GL_ZERO; + } +} + +void GPU_blend_set_func_separate( + GPUBlendFunction src_rgb, GPUBlendFunction dst_rgb, + GPUBlendFunction src_alpha, GPUBlendFunction dst_alpha) +{ + glBlendFuncSeparate(gpu_get_gl_blendfunction(src_rgb), + gpu_get_gl_blendfunction(dst_rgb), + gpu_get_gl_blendfunction(src_alpha), + gpu_get_gl_blendfunction(dst_alpha)); +} + +void GPU_blend_set_func(GPUBlendFunction sfactor, GPUBlendFunction dfactor) +{ + glBlendFunc(gpu_get_gl_blendfunction(sfactor), gpu_get_gl_blendfunction(dfactor)); +} diff --git a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl index dcd23413c77..9b63952db5c 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl @@ -47,10 +47,12 @@ const vec2 jit[9] = vec2[9]( /* We can reuse the CORNER_* bits for tria */ #define TRIA_VEC_RANGE BIT_RANGE(6) -const vec2 triavec[37] = vec2[37]( +const vec2 triavec[43] = vec2[43]( + /* ROUNDBOX_TRIA_ARROWS */ - vec2(-0.352077, 0.532607), vec2(-0.352077, -0.549313), vec2( 0.330000, -0.008353), - vec2( 0.352077, 0.532607), vec2( 0.352077, -0.549313), vec2(-0.330000, -0.008353), + vec2(-0.170000, 0.400000), vec2(-0.050000, 0.520000), vec2( 0.250000, 0.000000), vec2( 0.470000, -0.000000), vec2(-0.170000, -0.400000), vec2(-0.050000, -0.520000), + vec2( 0.170000, 0.400000), vec2( 0.050000, 0.520000), vec2(-0.250000, 0.000000), vec2(-0.470000, -0.000000), vec2( 0.170000, -0.400000), vec2( 0.050000, -0.520000), + /* ROUNDBOX_TRIA_SCROLL - circle tria (triangle strip) */ vec2(0.000000, 1.000000), vec2(0.382684, 0.923879), vec2(-0.382683, 0.923880), @@ -61,12 +63,16 @@ const vec2 triavec[37] = vec2[37]( vec2(0.707107, -0.707107), vec2(-0.707107, -0.707107), vec2(0.382684, -0.923879), vec2(-0.382683, -0.923880), vec2(0.000000, -1.000000), + /* ROUNDBOX_TRIA_MENU - menu arrows */ - vec2(-0.33, 0.16), vec2(0.33, 0.16), vec2(0.0, 0.82), - vec2(0.0, -0.82), vec2(-0.33, -0.16), vec2(0.33, -0.16), + vec2(-0.51, 0.08), vec2(-0.41, 0.20), vec2(-0.05, -0.39), + vec2(-0.05, -0.18), vec2(0.41, 0.08), vec2(0.3, 0.20), + + /* ROUNDBOX_TRIA_CHECK - check mark */ - vec2(-0.578579, 0.253369), vec2(-0.392773, 0.412794), vec2(-0.004241, -0.328551), - vec2(-0.003001, 0.034320), vec2(1.055313, 0.864744), vec2(0.866408, 1.026895), + vec2(-0.67000, 0.020000), vec2(-0.500000, 0.190000), vec2(-0.130000, -0.520000), + vec2(-0.130000, -0.170000), vec2(0.720000, 0.430000), vec2(0.530000, 0.590000), + /* ROUNDBOX_TRIA_HOLD_ACTION_ARROW - hold action arrows */ #define OY (-0.2 / 2) #define SC (0.35 * 2) diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index 44ff53cc020..8d932c5e79d 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -139,7 +139,7 @@ if(WITH_CODEC_FFMPEG) ) add_definitions(-DWITH_FFMPEG) - remove_strict_flags_file( + remove_strict_c_flags_file( intern/indexer.c intern/util.c intern/anim_movie.c diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index a52ae75e87b..13c033523fa 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -40,6 +40,9 @@ #include <algorithm> #include <iostream> + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-register" #include <half.h> #include <Iex.h> #include <ImfVersion.h> @@ -64,6 +67,7 @@ #include <ImfTiledOutputPart.h> #include <ImfPartType.h> #include <ImfPartHelper.h> +#pragma clang diagnostic pop #include "DNA_scene_types.h" /* For OpenEXR compression constants */ diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 62f8f1395c5..fa97fd53f32 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -576,6 +576,7 @@ enum { INDEX_ID_WM, INDEX_ID_MSK, INDEX_ID_NULL, + INDEX_ID_MAX, }; #ifdef __cplusplus diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index dac96b6ce5a..0546dcb1a6c 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -598,8 +598,8 @@ typedef struct bDopeSheet { ID *source; /* currently ID_SCE (for Dopesheet), and ID_SC (for Grease Pencil) */ ListBase chanbase; /* cache for channels (only initialized when pinned) */ // XXX not used! - struct Collection *filter_grp; /* object group for ADS_FILTER_ONLYOBGROUP filtering option */ - char searchstr[64]; /* string to search for in displayed names of F-Curves for ADS_FILTER_BY_FCU_NAME filtering option */ + struct Collection *filter_grp; /* object group for option to only include objects that belong to this Collection */ + char searchstr[64]; /* string to search for in displayed names of F-Curves, or NlaTracks/GP Layers/etc. */ int filterflag; /* flags to use for filtering data */ int flag; /* standard flags */ @@ -621,7 +621,6 @@ typedef enum eDopeSheet_FilterFlag { /* general filtering */ ADS_FILTER_SUMMARY = (1 << 4), /* for 'DopeSheet' Editors - include 'summary' line */ - ADS_FILTER_ONLYOBGROUP = (1 << 5), /* only the objects in the specified object group get used */ /* datatype-based filtering */ ADS_FILTER_NOSHAPEKEYS = (1 << 6), @@ -650,7 +649,6 @@ typedef enum eDopeSheet_FilterFlag { /* general filtering 3 */ ADS_FILTER_INCL_HIDDEN = (1 << 26), /* include 'hidden' channels too (i.e. those from hidden Objects/Bones) */ - ADS_FILTER_BY_FCU_NAME = (1 << 27), /* for F-Curves, filter by the displayed name (i.e. to isolate all Location curves only) */ ADS_FILTER_ONLY_ERRORS = (1 << 28), /* show only F-Curves which are disabled/have errors - for debugging drivers */ /* GPencil Mode */ @@ -687,12 +685,16 @@ typedef struct SpaceAction { bAction *action; /* the currently active action */ bDopeSheet ads; /* the currently active context (when not showing action) */ - char mode, autosnap; /* mode: editing context; autosnap: automatic keyframe snapping mode */ - short flag; /* flag: bitmapped settings; */ float timeslide; /* for Time-Slide transform mode drawing - current frame? */ - int cache_display; /* (eTimeline_Cache_Flag) */ - int pad; + short flag; + /* Editing context */ + char mode; + /* Storage for sub-space types. */ + char mode_prev; + char autosnap; /* automatic keyframe snapping mode */ + char cache_display; /* (eTimeline_Cache_Flag) */ + char _pad1[6]; } SpaceAction; /* SpaceAction flag */ diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h index df2db80fdba..09698716cb3 100644 --- a/source/blender/makesdna/DNA_layer_types.h +++ b/source/blender/makesdna/DNA_layer_types.h @@ -56,7 +56,8 @@ typedef struct LayerCollection { struct Collection *collection; struct SceneCollection *scene_collection DNA_DEPRECATED; short flag; - short pad[3]; + short runtime_flag; + short pad[2]; ListBase layer_collections; /* synced with collection->children */ } LayerCollection; @@ -101,7 +102,8 @@ typedef struct ViewLayer { struct ViewLayer *next, *prev; char name[64]; /* MAX_NAME */ short flag; - short pad[3]; + short runtime_flag; + short pad[2]; ListBase object_bases; /* ObjectBase */ struct SceneStats *stats; /* default allocated now */ struct Base *basact; @@ -130,14 +132,19 @@ typedef struct ViewLayer { /* Base->flag */ enum { - BASE_SELECTED = (1 << 0), - BASE_VISIBLED = (1 << 1), - BASE_SELECTABLED = (1 << 2), - BASE_FROMDUPLI = (1 << 3), + /* User controlled flags. */ + BASE_SELECTED = (1 << 0), /* Object is selected. */ + BASE_HIDDEN = (1 << 8), /* Object is hidden for editing. */ + + /* Runtime evaluated flags. */ + BASE_VISIBLE = (1 << 1), /* Object is enabled and visible. */ + BASE_SELECTABLE = (1 << 2), /* Object can be selected. */ + BASE_FROMDUPLI = (1 << 3), /* Object comes from duplicator. */ /* BASE_DEPRECATED = (1 << 4), */ - BASE_FROM_SET = (1 << 5), /* To be set only by the depsgraph */ - BASE_VISIBLE_VIEWPORT = (1 << 6), - BASE_VISIBLE_RENDER = (1 << 7), + BASE_FROM_SET = (1 << 5), /* Object comes from set. */ + BASE_ENABLED_VIEWPORT = (1 << 6), /* Object is enabled in viewport. */ + BASE_ENABLED_RENDER = (1 << 7), /* Object is enabled in final render */ + BASE_ENABLED = (1 << 9), /* Object is enabled. */ }; /* LayerCollection->flag */ @@ -149,6 +156,13 @@ enum { LAYER_COLLECTION_EXCLUDE = (1 << 4), }; +/* Layer Collection->runtime_flag */ +enum { + LAYER_COLLECTION_HAS_OBJECTS = (1 << 0), + LAYER_COLLECTION_HAS_VISIBLE_OBJECTS = (1 << 1), + LAYER_COLLECTION_HAS_ENABLED_OBJECTS = (1 << 2), +}; + /* ViewLayer->flag */ enum { VIEW_LAYER_RENDER = (1 << 0), @@ -156,6 +170,11 @@ enum { VIEW_LAYER_FREESTYLE = (1 << 2), }; +/* ViewLayer->runtime_flag */ +enum { + VIEW_LAYER_HAS_HIDE = (1 << 0), +}; + /****************************** Deprecated ******************************/ /* Compatibility with collections saved in early 2.8 versions, diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index d9792faf0cb..712958deca1 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -33,6 +33,7 @@ */ struct Mesh; +struct Scene; typedef enum ModifierType { eModifierType_None = 0, @@ -112,9 +113,6 @@ typedef struct ModifierData { short pad; char name[64]; /* MAX_NAME */ - /* XXX for timing info set by caller... solve later? (ton) */ - struct Scene *scene; - char *error; } ModifierData; @@ -607,7 +605,6 @@ typedef struct SoftbodyModifierData { typedef struct ClothModifierData { ModifierData modifier; - struct Scene *scene; /* the context is here */ struct Cloth *clothObject; /* The internal data structure for cloth. */ struct ClothSimSettings *sim_parms; /* definition is in DNA_cloth_types.h */ struct ClothCollSettings *coll_parms; /* definition is in DNA_cloth_types.h */ diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 45029e8d412..7eb920002f3 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -367,6 +367,7 @@ enum { /* 23 and 24 are for life and sector (old file compat.) */ OB_ARMATURE = 25, + OB_TYPE_MAX, }; /* ObjectDisplay.flag */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 3a0568112a0..dc3dee8f9a3 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1236,6 +1236,9 @@ typedef struct ToolSettings { /* Auto-IK */ short autoik_chainlen; /* runtime only */ + /* SCE_MPR_LOC/SCAL */ + char manipulator_flag; + /* Grease Pencil */ char gpencil_flags; /* flags/options for how the tool works */ char gpencil_src; /* for main 3D view Grease Pencil, where data comes from */ @@ -1245,7 +1248,7 @@ typedef struct ToolSettings { char gpencil_seq_align; /* : Sequencer Preview */ char gpencil_ima_align; /* : Image Editor */ - char _pad3[4]; + char _pad3[3]; /* Grease Pencil Sculpt */ struct GP_BrushEdit_Settings gp_sculpt; @@ -1720,22 +1723,22 @@ extern const char *RE_engine_id_CYCLES; /* deprecate this! */ #define TESTBASE(base) ( \ (((base)->flag & BASE_SELECTED) != 0) && \ - (((base)->flag & BASE_VISIBLED) != 0)) + (((base)->flag & BASE_VISIBLE) != 0)) #define TESTBASELIB(base) ( \ (((base)->flag & BASE_SELECTED) != 0) && \ ((base)->object->id.lib == NULL) && \ - (((base)->flag & BASE_VISIBLED) != 0)) + (((base)->flag & BASE_VISIBLE) != 0)) #define TESTBASELIB_BGMODE(base) ( \ (((base)->flag & BASE_SELECTED) != 0) && \ ((base)->object->id.lib == NULL) && \ - (((base)->flag & BASE_VISIBLED) != 0)) + (((base)->flag & BASE_VISIBLE) != 0)) #define BASE_EDITABLE_BGMODE(base) ( \ ((base)->object->id.lib == NULL) && \ - (((base)->flag & BASE_VISIBLED) != 0)) + (((base)->flag & BASE_VISIBLE) != 0)) #define BASE_SELECTABLE(base) \ - (((base)->flag & BASE_SELECTABLED) != 0) + (((base)->flag & BASE_SELECTABLE) != 0) #define BASE_VISIBLE(base) ( \ - ((base)->flag & BASE_VISIBLED) != 0) + ((base)->flag & BASE_VISIBLE) != 0) #define FIRSTBASE(_view_layer) ((_view_layer)->object_bases.first) #define LASTBASE(_view_layer) ((_view_layer)->object_bases.last) @@ -2000,6 +2003,11 @@ typedef enum eImagePaintMode { #define EDGE_MODE_TAG_BEVEL 4 #define EDGE_MODE_TAG_FREESTYLE 5 +/* ToolSettings.manipulator_flag */ +#define SCE_MANIP_TRANSLATE 1 +#define SCE_MANIP_ROTATE 2 +#define SCE_MANIP_SCALE 4 + /* ToolSettings.gpencil_flags */ typedef enum eGPencil_Flags { /* "Continuous Drawing" - The drawing operator enters a mode where multiple strokes can be drawn */ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 4f07a30ed70..bbfbf660774 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -274,7 +274,7 @@ typedef enum eSpaceOutliner_Flag { /* SpaceOops.filter */ typedef enum eSpaceOutliner_Filter { - SO_FILTER_SEARCH = (1 << 0), + SO_FILTER_SEARCH = (1 << 0), /* Run-time flag. */ /* SO_FILTER_ENABLE = (1 << 1), */ /* Deprecated */ SO_FILTER_NO_OBJECT = (1 << 2), SO_FILTER_NO_OB_CONTENT = (1 << 3), /* Not only mesh, but modifiers, constraints, ... */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index f4e8d5e0000..c24895e3640 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -430,6 +430,36 @@ typedef struct bPathCompare { char flag, pad[7]; } bPathCompare; +typedef struct bUserMenu { + struct bUserMenu *next, *prev; + char space_type; + char _pad0[7]; + char context[64]; + /* bUserMenuItem */ + ListBase items; +} bUserMenu; + +/* May be part of bUserMenu or other list. */ +typedef struct bUserMenuItem { + struct bUserMenuItem *next, *prev; + char ui_name[64]; + char type; + char _pad0[7]; +} bUserMenuItem; + +typedef struct bUserMenuItem_Op { + bUserMenuItem item; + char opname[64]; + struct IDProperty *prop; + char opcontext; + char _pad0[7]; +} bUserMenuItem_Op; + +enum { + USER_MENU_TYPE_SEP = 1, + USER_MENU_TYPE_OPERATOR = 2, +}; + typedef struct SolidLight { int flag, pad; float col[4], spec[4], vec[4]; @@ -511,6 +541,8 @@ typedef struct UserDef { struct ListBase user_keymaps; struct ListBase addons; struct ListBase autoexec_paths; + struct ListBase user_menus; /* bUserMenu */ + char keyconfigstr[64]; short undosteps; @@ -632,7 +664,7 @@ typedef enum eUserPref_Flag { USER_FLAG_DEPRECATED_7 = (1 << 7), /* cleared */ USER_MAT_ON_OB = (1 << 8), USER_FLAG_DEPRECATED_9 = (1 << 9), /* cleared */ - USER_FLAG_DEPRECATED_10 = (1 << 10), /* cleared */ + USER_DEVELOPER_UI = (1 << 10), USER_TOOLTIPS = (1 << 11), USER_TWOBUTTONMOUSE = (1 << 12), USER_NONUMPAD = (1 << 13), diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index b7ad9f7d921..c3e0fe38296 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -167,12 +167,19 @@ typedef struct View3DOverlay { /* Paint mode settings */ int paint_flag; + /* Alpha for texture, weight, vertex paint overlay */ + float texture_paint_mode_opacity; + float vertex_paint_mode_opacity; + float weight_paint_mode_opacity; + /* Armature edit/pose mode settings */ int arm_flag; float bone_selection_alpha; /* Other settings */ float wireframe_threshold; + + int pad; } View3DOverlay; /* 3D ViewPort Struct */ @@ -331,7 +338,7 @@ typedef struct View3D { #define V3D_SOLID_MATCAP (1 << 12) /* user flag */ #define V3D_SHOW_SOLID_MATCAP (1 << 13) /* runtime flag */ #define V3D_OCCLUDE_WIRE (1 << 14) -#define V3D_SHOW_MODE_SHADE_OVERRIDE (1 << 15) +#define V3D_SHOW_MODE_SHADE_OVERRIDE (1 << 15) /* XXX: DNA deprecated */ /* View3d->flag3 (short) */ @@ -355,11 +362,12 @@ enum { V3D_SHADING_MATCAP_FLIP_X = (1 << 6), }; -/* View3DShading->single_color_type */ +/* View3DShading->color_type */ enum { V3D_SHADING_MATERIAL_COLOR = 0, V3D_SHADING_RANDOM_COLOR = 1, V3D_SHADING_SINGLE_COLOR = 2, + V3D_SHADING_TEXTURE_COLOR = 3, }; /* View3DOverlay->flag */ diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 19d4ab10165..e41058f356b 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -232,6 +232,9 @@ typedef struct wmWindow { /* custom drawing callbacks */ ListBase drawcalls; + + /* Private runtime info to show text in the status bar. */ + void *cursor_keymap_status; } wmWindow; #ifdef ime_data diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 71662d86dcd..4ca8f075ae1 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -56,8 +56,10 @@ extern const EnumPropertyItem rna_enum_snap_node_element_items[]; extern const EnumPropertyItem rna_enum_curve_fit_method_items[]; extern const EnumPropertyItem rna_enum_mesh_select_mode_items[]; extern const EnumPropertyItem rna_enum_mesh_delimit_mode_items[]; +extern const EnumPropertyItem rna_enum_space_graph_mode_items[]; extern const EnumPropertyItem rna_enum_space_type_items[]; extern const EnumPropertyItem rna_enum_space_image_mode_items[]; +extern const EnumPropertyItem rna_enum_space_action_mode_items[]; extern const EnumPropertyItem rna_enum_region_type_items[]; extern const EnumPropertyItem rna_enum_object_modifier_type_items[]; extern const EnumPropertyItem rna_enum_constraint_type_items[]; diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 11e45bc688d..5473eec39c5 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -150,7 +150,8 @@ void rna_ID_name_set(PointerRNA *ptr, const char *value) { ID *id = (ID *)ptr->data; BLI_strncpy_utf8(id->name + 2, value, sizeof(id->name) - 2); - BLI_libblock_ensure_unique_name(G.main, id->name); + BLI_assert(BKE_id_is_in_gobal_main(id)); + BLI_libblock_ensure_unique_name(G_MAIN, id->name); } static int rna_ID_name_editable(PointerRNA *ptr, const char **UNUSED(r_info)) @@ -456,7 +457,9 @@ int rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assig short *totcol = give_totcolp_id(id); Material *mat_id = assign_ptr->id.data; if (totcol && (key >= 0 && key < *totcol)) { - assign_material_id(G.main, id, mat_id, key + 1); + BLI_assert(BKE_id_is_in_gobal_main(id)); + BLI_assert(BKE_id_is_in_gobal_main(&mat_id->id)); + assign_material_id(G_MAIN, id, mat_id, key + 1); return 1; } else { @@ -512,7 +515,8 @@ static void rna_IDMaterials_clear_id(ID *id, Main *bmain, int remove_material_sl static void rna_Library_filepath_set(PointerRNA *ptr, const char *value) { Library *lib = (Library *)ptr->data; - BKE_library_filepath_set(G.main, lib, value); + BLI_assert(BKE_id_is_in_gobal_main(&lib->id)); + BKE_library_filepath_set(G_MAIN, lib, value); } /* ***** ImagePreview ***** */ diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 5b225b18a78..4f2654bb30e 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -326,13 +326,6 @@ static void rna_def_dopesheet(BlenderRNA *brna) RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* Object Collection Filtering Settings */ - prop = RNA_def_property(srna, "show_only_collection_objects", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYOBGROUP); - RNA_def_property_ui_text(prop, "Only Objects in Collection", - "Only include channels from objects in the specified collection"); - RNA_def_property_ui_icon(prop, ICON_GROUP, 0); - RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - prop = RNA_def_property(srna, "filter_collection", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "filter_grp"); RNA_def_property_flag(prop, PROP_EDITABLE); @@ -340,31 +333,19 @@ static void rna_def_dopesheet(BlenderRNA *brna) RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* FCurve Display Name Search Settings */ - prop = RNA_def_property(srna, "show_only_matching_fcurves", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_BY_FCU_NAME); - RNA_def_property_ui_text(prop, "Only Matching F-Curves", - "Only include F-Curves with names containing search text"); - RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0); - RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - prop = RNA_def_property(srna, "filter_fcurve_name", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "searchstr"); RNA_def_property_ui_text(prop, "F-Curve Name Filter", "F-Curve live filtering string"); + RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0); RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* NLA Name Search Settings (Shared with FCurve setting, but with different labels) */ - prop = RNA_def_property(srna, "use_filter_text", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_BY_FCU_NAME); - RNA_def_property_ui_text(prop, "Only Matching Channels", - "Only include channels with names containing search text"); - RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0); - RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - prop = RNA_def_property(srna, "filter_text", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "searchstr"); RNA_def_property_ui_text(prop, "Name Filter", "Live filtering string"); RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE); + RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* Multi-word fuzzy search option for name/text filters */ diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 44a21e797f1..7e936fd1e5c 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -341,7 +341,8 @@ static void rna_EditBone_name_set(PointerRNA *ptr, const char *value) BLI_strncpy_utf8(newname, value, sizeof(ebone->name)); BLI_strncpy(oldname, ebone->name, sizeof(ebone->name)); - ED_armature_bone_rename(G.main, arm, oldname, newname); + BLI_assert(BKE_id_is_in_gobal_main(&arm->id)); + ED_armature_bone_rename(G_MAIN, arm, oldname, newname); } static void rna_Bone_name_set(PointerRNA *ptr, const char *value) @@ -354,7 +355,8 @@ static void rna_Bone_name_set(PointerRNA *ptr, const char *value) BLI_strncpy_utf8(newname, value, sizeof(bone->name)); BLI_strncpy(oldname, bone->name, sizeof(bone->name)); - ED_armature_bone_rename(G.main, arm, oldname, newname); + BLI_assert(BKE_id_is_in_gobal_main(&arm->id)); + ED_armature_bone_rename(G_MAIN, arm, oldname, newname); } static void rna_EditBone_layer_set(PointerRNA *ptr, const int values[]) diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 51aed1ff296..cd7081d07a8 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -1271,7 +1271,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) /* Flags */ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_HIDE); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); + RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, 1); RNA_def_property_ui_text(prop, "Hide", "Set layer Visibility"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); @@ -1457,7 +1457,7 @@ static void rna_def_gpencil_palettecolor(BlenderRNA *brna) /* Flags */ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PC_COLOR_HIDE); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); + RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, 1); RNA_def_property_ui_text(prop, "Hide", "Set color Visibility"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index de6c6883977..de773e1f20d 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -87,6 +87,7 @@ static void rna_Collection_objects_link(Collection *collection, Main *bmain, Rep return; } + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); WM_main_add_notifier(NC_OBJECT | ND_DRAW, &object->id); } @@ -98,6 +99,7 @@ static void rna_Collection_objects_unlink(Collection *collection, Main *bmain, R return; } + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); WM_main_add_notifier(NC_OBJECT | ND_DRAW, &object->id); } @@ -124,6 +126,7 @@ static void rna_Collection_children_link(Collection *collection, Main *bmain, Re return; } + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); WM_main_add_notifier(NC_OBJECT | ND_DRAW, &child->id); } @@ -135,6 +138,7 @@ static void rna_Collection_children_unlink(Collection *collection, Main *bmain, return; } + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); WM_main_add_notifier(NC_OBJECT | ND_DRAW, &child->id); } @@ -145,8 +149,8 @@ static void rna_Collection_flag_update(Main *bmain, Scene *scene, PointerRNA *pt BKE_collection_object_cache_free(collection); BKE_main_collection_sync(bmain); + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); - DEG_id_tag_update(&collection->id, 0); WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene); } @@ -260,21 +264,21 @@ void RNA_def_collections(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_SELECT); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1); - RNA_def_property_ui_text(prop, "Restrict Select", "Disable collection object selection in the 3D viewport"); + RNA_def_property_ui_text(prop, "Disable Select", "Disable collection for viewport selection"); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update"); prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_VIEW); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); - RNA_def_property_ui_text(prop, "Restrict Viewport", "Hide collection objects in the 3D viewport"); + RNA_def_property_ui_text(prop, "Disable Viewport", "Disable collection in viewport"); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update"); prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_RENDER); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - RNA_def_property_ui_text(prop, "Restrict Render", "Hide collection objects in renders"); + RNA_def_property_ui_text(prop, "Disable Render", "Disable collection in renders"); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update"); } diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index e71bd52593e..2570f88d09f 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -93,7 +93,8 @@ static void rna_Image_source_set(PointerRNA *ptr, int value) if (value != ima->source) { ima->source = value; - BKE_image_signal(G.main, ima, NULL, IMA_SIGNAL_SRC_CHANGE); + BLI_assert(BKE_id_is_in_gobal_main(&ima->id)); + BKE_image_signal(G_MAIN, ima, NULL, IMA_SIGNAL_SRC_CHANGE); DEG_id_tag_update(&ima->id, 0); } } diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 11fb5f7f94b..05efe350a2f 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -722,7 +722,7 @@ static void rna_def_keyblock(BlenderRNA *brna) prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYBLOCK_MUTE); RNA_def_property_ui_text(prop, "Mute", "Mute this shape key"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); + RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, 1); RNA_def_property_update(prop, 0, "rna_Key_update_data"); prop = RNA_def_property(srna, "slider_min", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index 4a86789b0e0..e794e479390 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -388,8 +388,7 @@ static void rna_LayerCollection_use_update(Main *bmain, Scene *UNUSED(scene), Po BKE_layer_collection_sync(scene, view_layer); - /* TODO(sergey): Use proper flag for tagging here. */ - DEG_id_tag_update(&scene->id, 0); + DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE); DEG_relations_tag_update(bmain); WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, NULL); } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 6ff3849e295..835d6e5117f 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -53,7 +53,6 @@ #include "BKE_camera.h" #include "BKE_collection.h" #include "BKE_curve.h" -#include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_mesh.h" #include "BKE_armature.h" diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 858dd0ec972..26c281ad9e1 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -180,6 +180,7 @@ static void rna_Material_use_nodes_update(bContext *C, PointerRNA *ptr) if (ma->use_nodes && ma->nodetree == NULL) ED_node_shader_default(C, &ma->id); + DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE); DEG_relations_tag_update(bmain); rna_Material_draw_update(bmain, CTX_data_scene(C), ptr); } diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index e41fe513314..48ebc02cee0 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -45,7 +45,6 @@ #include "BKE_animsys.h" #include "BKE_data_transfer.h" -#include "BKE_DerivedMesh.h" #include "BKE_dynamicpaint.h" #include "BKE_effect.h" #include "BKE_mesh_mapping.h" @@ -287,6 +286,7 @@ const EnumPropertyItem rna_enum_axis_flag_xyz_items[] = { #include "BKE_cachefile.h" #include "BKE_context.h" #include "BKE_library.h" +#include "BKE_mesh_runtime.h" #include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_particle.h" @@ -901,6 +901,9 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( return rna_enum_dt_layers_select_src_items; } + Depsgraph *depsgraph = CTX_data_depsgraph(C); + Scene *scene = CTX_data_scene(C); + /* No active here! */ RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC); @@ -934,22 +937,18 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( Object *ob_src = dtmd->ob_source; if (ob_src) { - DerivedMesh *dm_src; - CustomData *ldata; + Mesh *me_eval; int num_data, i; - dm_src = object_get_derived_final(ob_src, false); - if (dm_src != NULL) { - ldata = dm_src->getLoopDataLayout(dm_src); - num_data = CustomData_number_of_layers(ldata, CD_MLOOPUV); + me_eval = mesh_get_eval_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPUV); + num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPUV); - RNA_enum_item_add_separator(&item, &totitem); + RNA_enum_item_add_separator(&item, &totitem); - for (i = 0; i < num_data; i++) { - tmp_item.value = i; - tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(ldata, CD_MLOOPUV, i); - RNA_enum_item_add(&item, &totitem, &tmp_item); - } + for (i = 0; i < num_data; i++) { + tmp_item.value = i; + tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(&me_eval->ldata, CD_MLOOPUV, i); + RNA_enum_item_add(&item, &totitem, &tmp_item); } } } @@ -957,22 +956,18 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( Object *ob_src = dtmd->ob_source; if (ob_src) { - DerivedMesh *dm_src; - CustomData *ldata; + Mesh *me_eval; int num_data, i; - dm_src = object_get_derived_final(ob_src, false); - if (dm_src != NULL) { - ldata = dm_src->getLoopDataLayout(dm_src); - num_data = CustomData_number_of_layers(ldata, CD_MLOOPCOL); + me_eval = mesh_get_eval_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPCOL); + num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPCOL); - RNA_enum_item_add_separator(&item, &totitem); + RNA_enum_item_add_separator(&item, &totitem); - for (i = 0; i < num_data; i++) { - tmp_item.value = i; - tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(ldata, CD_MLOOPCOL, i); - RNA_enum_item_add(&item, &totitem, &tmp_item); - } + for (i = 0; i < num_data; i++) { + tmp_item.value = i; + tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(&me_eval->ldata, CD_MLOOPCOL, i); + RNA_enum_item_add(&item, &totitem, &tmp_item); } } } diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index edbf67b41cf..bbcf55df84b 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -46,6 +46,7 @@ #include "BKE_paint.h" #include "BKE_editlattice.h" #include "BKE_editmesh.h" +#include "BKE_layer.h" #include "BKE_object_deform.h" #include "BKE_object_facemap.h" @@ -220,9 +221,13 @@ static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA rna_Object_internal_update(bmain, scene, ptr); } -static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { - DEG_id_type_tag(bmain, ID_OB); + Object *ob = ptr->id.data; + BKE_main_collection_sync(bmain); + DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id); } static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) @@ -323,6 +328,9 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) return; } + BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); + BLI_assert(BKE_id_is_in_gobal_main(id)); + if (ob->type == OB_EMPTY) { if (ob->data) { id_us_min((ID *)ob->data); @@ -335,7 +343,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) } } else if (ob->type == OB_MESH) { - BKE_mesh_assign_object(G.main, ob, (Mesh *)id); + BKE_mesh_assign_object(G_MAIN, ob, (Mesh *)id); } else { if (ob->data) { @@ -347,7 +355,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) id_us_plus(id); ob->data = id; - test_object_materials(G.main, ob, id); + test_object_materials(G_MAIN, ob, id); if (GS(id->name) == ID_CU) BKE_curve_type_test(ob); @@ -734,7 +742,9 @@ static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value) Object *ob = (Object *)ptr->id.data; DEG_id_tag_update(value.data, 0); - assign_material(G.main, ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING); + BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); + BLI_assert(BKE_id_is_in_gobal_main(value.data)); + assign_material(G_MAIN, ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING); } static int rna_Object_active_material_editable(PointerRNA *ptr, const char **UNUSED(r_info)) @@ -926,7 +936,9 @@ static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value) Object *ob = (Object *)ptr->id.data; int index = (Material **)ptr->data - ob->mat; - assign_material(G.main, ob, value.data, index + 1, BKE_MAT_ASSIGN_EXISTING); + BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); + BLI_assert(BKE_id_is_in_gobal_main(value.data)); + assign_material(G_MAIN, ob, value.data, index + 1, BKE_MAT_ASSIGN_EXISTING); } static int rna_MaterialSlot_link_get(PointerRNA *ptr) @@ -2307,9 +2319,21 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Rigid Body Constraint", "Constraint constraining rigid bodies"); /* restrict */ + prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW); + RNA_def_property_ui_text(prop, "Disable View", "Disable object in the viewport"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update"); + + prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT); + RNA_def_property_ui_text(prop, "Disable Select", "Disable object selection in the viewport"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER); - RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability"); + RNA_def_property_ui_text(prop, "Disable Render", "Disable object in renders"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update"); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index f86a3d8236a..4ba7ae4b6d8 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -68,7 +68,6 @@ static const EnumPropertyItem space_items[] = { #include "BKE_anim.h" #include "BKE_bvhutils.h" -#include "BKE_cdderivedmesh.h" #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_customdata.h" @@ -146,7 +145,7 @@ static int rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports) return -1; } - return ((base->flag & BASE_VISIBLED) != 0) ? 1 : 0; + return ((base->flag & BASE_VISIBLE) != 0) ? 1 : 0; } /* Convert a given matrix from a space to another (using the object and/or a bone as reference). */ @@ -289,9 +288,9 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int #endif /* don't call inside a loop */ -static int dm_looptri_to_poly_index(DerivedMesh *dm, const MLoopTri *lt) +static int mesh_looptri_to_poly_index(Mesh *me_eval, const MLoopTri *lt) { - const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); + const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX); return index_mp_to_orig ? index_mp_to_orig[lt->poly] : lt->poly; } @@ -302,7 +301,7 @@ static void rna_Object_ray_cast( { bool success = false; - if (ob->derivedFinal == NULL) { + if (ob->runtime.mesh_eval == NULL) { BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for ray casting", ob->id.name + 2); return; } @@ -315,7 +314,7 @@ static void rna_Object_ray_cast( BVHTreeFromMesh treeData = {NULL}; /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */ - bvhtree_from_mesh_get(&treeData, ob->derivedFinal, BVHTREE_FROM_LOOPTRI, 4); + BKE_bvhtree_from_mesh_get(&treeData, ob->runtime.mesh_eval, BVHTREE_FROM_LOOPTRI, 4); /* may fail if the mesh has no faces, in that case the ray-cast misses */ if (treeData.tree != NULL) { @@ -335,7 +334,7 @@ static void rna_Object_ray_cast( copy_v3_v3(r_location, hit.co); copy_v3_v3(r_normal, hit.no); - *r_index = dm_looptri_to_poly_index(ob->derivedFinal, &treeData.looptri[hit.index]); + *r_index = mesh_looptri_to_poly_index(ob->runtime.mesh_eval, &treeData.looptri[hit.index]); } } @@ -357,14 +356,14 @@ static void rna_Object_closest_point_on_mesh( { BVHTreeFromMesh treeData = {NULL}; - if (ob->derivedFinal == NULL) { + if (ob->runtime.mesh_eval == NULL) { BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for finding nearest point", ob->id.name + 2); return; } /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */ - bvhtree_from_mesh_get(&treeData, ob->derivedFinal, BVHTREE_FROM_LOOPTRI, 4); + BKE_bvhtree_from_mesh_get(&treeData, ob->runtime.mesh_eval, BVHTREE_FROM_LOOPTRI, 4); if (treeData.tree == NULL) { BKE_reportf(reports, RPT_ERROR, "Object '%s' could not create internal data for finding nearest point", @@ -382,7 +381,7 @@ static void rna_Object_closest_point_on_mesh( copy_v3_v3(r_location, nearest.co); copy_v3_v3(r_normal, nearest.no); - *r_index = dm_looptri_to_poly_index(ob->derivedFinal, &treeData.looptri[nearest.index]); + *r_index = mesh_looptri_to_poly_index(ob->runtime.mesh_eval, &treeData.looptri[nearest.index]); goto finally; } @@ -409,10 +408,12 @@ static int rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings) } #ifndef NDEBUG -void rna_Object_dm_info(struct Object *ob, int type, char *result) + +#include "BKE_mesh_runtime.h" + +void rna_Object_me_eval_info(struct Object *ob, int type, char *result) { - DerivedMesh *dm = NULL; - bool dm_release = false; + Mesh *me_eval = NULL; char *ret = NULL; result[0] = '\0'; @@ -420,24 +421,19 @@ void rna_Object_dm_info(struct Object *ob, int type, char *result) switch (type) { case 0: if (ob->type == OB_MESH) { - dm = CDDM_from_mesh(ob->data); - ret = DM_debug_info(dm); - dm_release = true; + me_eval = ob->data; } break; case 1: - dm = ob->derivedDeform; + me_eval = ob->runtime.mesh_deform_eval; break; case 2: - dm = ob->derivedFinal; + me_eval = ob->runtime.mesh_eval; break; } - if (dm) { - ret = DM_debug_info(dm); - if (dm_release) { - dm->release(dm); - } + if (me_eval) { + ret = BKE_mesh_runtime_debug_info(me_eval); if (ret) { strcpy(result, ret); MEM_freeN(ret); @@ -664,7 +660,7 @@ void RNA_api_object(StructRNA *srna) #ifndef NDEBUG /* mesh */ - func = RNA_def_function(srna, "dm_info", "rna_Object_dm_info"); + func = RNA_def_function(srna, "dm_info", "rna_Object_me_eval_info"); RNA_def_function_ui_description(func, "Returns a string for derived mesh data"); parm = RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply"); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 573bbb5345b..08bc373b690 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -139,8 +139,6 @@ static const EnumPropertyItem part_hair_ren_as_items[] = { #include "BKE_cloth.h" #include "BKE_colortools.h" #include "BKE_deform.h" -#include "BKE_DerivedMesh.h" -#include "BKE_cdderivedmesh.h" #include "BKE_effect.h" #include "BKE_material.h" #include "BKE_modifier.h" @@ -3087,7 +3085,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Dupli Collection", "Show Objects in this collection in place of particles"); - RNA_def_property_update(prop, 0, "rna_Particle_redo"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_dependency"); prop = RNA_def_property(srna, "dupli_weights", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "dupliweights", NULL); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 059c91b2bc6..5f136d0711e 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -293,7 +293,9 @@ static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value) BLI_strncpy_utf8(newname, value, sizeof(pchan->name)); BLI_strncpy(oldname, pchan->name, sizeof(pchan->name)); - ED_armature_bone_rename(G.main, ob->data, oldname, newname); + BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); + BLI_assert(BKE_id_is_in_gobal_main(ob->data)); + ED_armature_bone_rename(G_MAIN, ob->data, oldname, newname); } static int rna_PoseChannel_has_ik_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 84b4e882b66..1fbb416f3d8 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -413,6 +413,13 @@ const EnumPropertyItem rna_enum_bake_pass_filter_type_items[] = { {0, NULL, 0, NULL, NULL} }; +static const EnumPropertyItem rna_enum_manipulator_items[] = { + {SCE_MANIP_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, + {SCE_MANIP_ROTATE, "ROTATE", 0, "Rotate", ""}, + {SCE_MANIP_SCALE, "SCALE", 0, "Scale", ""}, + {0, NULL, 0, NULL, NULL} +}; + #ifndef RNA_RUNTIME static const EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = { /* interpolation */ @@ -640,6 +647,14 @@ static void rna_GPencilBrush_name_set(PointerRNA *ptr, const char *value) /* ----------------- end of Grease pencil drawing brushes ------------*/ +static void rna_ToolSettings_manipulator_flag_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +{ + ToolSettings *ts = scene->toolsettings; + if ((ts->manipulator_flag & (SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) { + ts->manipulator_flag |= SCE_MANIP_TRANSLATE; + } +} + static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr)) { ED_space_image_uv_sculpt_update(bmain, bmain->wm.first, scene); @@ -1485,7 +1500,8 @@ void rna_ViewLayer_name_set(PointerRNA *ptr, const char *value) { Scene *scene = (Scene *)ptr->id.data; ViewLayer *view_layer = (ViewLayer *)ptr->data; - BKE_view_layer_rename(G.main, scene, view_layer, value); + BLI_assert(BKE_id_is_in_gobal_main(&scene->id)); + BKE_view_layer_rename(G_MAIN, scene, view_layer, value); } static void rna_SceneRenderView_name_set(PointerRNA *ptr, const char *value) @@ -1541,7 +1557,7 @@ static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const int *value ts->selectmode = flag; /* Update select mode in all the workspaces in mesh edit mode. */ - wmWindowManager *wm = G.main->wm.first; + wmWindowManager *wm = G_MAIN->wm.first; for (wmWindow *win = wm->windows.first; win; win = win->next) { ViewLayer *view_layer = WM_window_get_active_view_layer(win); @@ -2670,6 +2686,13 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_ORTHO, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ + prop = RNA_def_property(srna, "use_manipulator_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "manipulator_flag"); + RNA_def_property_enum_items(prop, rna_enum_manipulator_items); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_ui_text(prop, "Manipulator", ""); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ToolSettings_manipulator_flag_update"); + /* Grease Pencil */ prop = RNA_def_property(srna, "use_gpencil_continuous_drawing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_PAINTSESSIONS_ON); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index e30b75b27bd..2a16d2a41ee 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -82,7 +82,7 @@ static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr)) { /* can be NULL on file load, T42619 */ - wmWindowManager *wm = G.main->wm.first; + wmWindowManager *wm = G_MAIN->wm.first; return wm ? (ED_screen_animation_playing(wm) != NULL) : 0; } @@ -95,7 +95,7 @@ static int rna_region_alignment_get(PointerRNA *ptr) static void rna_Screen_layout_name_get(PointerRNA *ptr, char *value) { const bScreen *screen = ptr->data; - const WorkSpaceLayout *layout = BKE_workspace_layout_find_global(G.main, screen, NULL); + const WorkSpaceLayout *layout = BKE_workspace_layout_find_global(G_MAIN, screen, NULL); if (layout) { const char *name = BKE_workspace_layout_name_get(layout); @@ -109,7 +109,7 @@ static void rna_Screen_layout_name_get(PointerRNA *ptr, char *value) static int rna_Screen_layout_name_length(PointerRNA *ptr) { const bScreen *screen = ptr->data; - const WorkSpaceLayout *layout = BKE_workspace_layout_find_global(G.main, screen, NULL); + const WorkSpaceLayout *layout = BKE_workspace_layout_find_global(G_MAIN, screen, NULL); if (layout) { const char *name = BKE_workspace_layout_name_get(layout); @@ -123,7 +123,7 @@ static void rna_Screen_layout_name_set(PointerRNA *ptr, const char *value) { bScreen *screen = ptr->data; WorkSpace *workspace; - WorkSpaceLayout *layout = BKE_workspace_layout_find_global(G.main, screen, &workspace); + WorkSpaceLayout *layout = BKE_workspace_layout_find_global(G_MAIN, screen, &workspace); if (layout) { BKE_workspace_layout_name_set(workspace, layout, value); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index b89b2185a38..b1118e79354 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -104,7 +104,6 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = { #include "MEM_guardedalloc.h" #include "BKE_context.h" -#include "BKE_DerivedMesh.h" #include "BKE_particle.h" #include "BKE_pbvh.h" #include "BKE_pointcache.h" diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index fb6953904b3..0dbec5b5355 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1504,7 +1504,7 @@ static void rna_def_sequence(BlenderRNA *brna) prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_MUTE); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, true); + RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, true); RNA_def_property_ui_text(prop, "Mute", "Disable strip so that it cannot be viewed in the output"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_mute_update"); @@ -2581,7 +2581,7 @@ static void rna_def_modifier(BlenderRNA *brna) prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQUENCE_MODIFIER_MUTE); RNA_def_property_ui_text(prop, "Mute", "Mute this modifier"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); + RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, 1); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 34d393c7b62..68af5795d49 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -79,9 +79,9 @@ const EnumPropertyItem rna_enum_space_type_items[] = { /* Animation */ {0, "", ICON_NONE, "Animation", ""}, //{SPACE_ACTION, "TIMELINE", ICON_TIME, "Timeline", "Timeline and playback controls (NOTE: Switch to 'Timeline' mode)"}, /* XXX */ - {SPACE_IPO, "GRAPH_EDITOR", ICON_IPO, "Graph Editor", "Edit drivers and keyframe interpolation"}, {SPACE_ACTION, "DOPESHEET_EDITOR", ICON_ACTION, "Dope Sheet", "Adjust timing of keyframes"}, - {SPACE_NLA, "NLA_EDITOR", ICON_NLA, "NLA Editor", "Combine and layer Actions"}, + {SPACE_IPO, "GRAPH_EDITOR", ICON_IPO, "Graph Editor", "Edit drivers and keyframe interpolation"}, + {SPACE_NLA, "NLA_EDITOR", ICON_NLA, "Nonlinear Animation", "Combine and layer Actions"}, /* Scripting */ {0, "", ICON_NONE, "Scripting", ""}, @@ -106,6 +106,65 @@ const EnumPropertyItem rna_enum_space_type_items[] = { {0, NULL, 0, NULL, NULL} }; +const EnumPropertyItem rna_enum_space_graph_mode_items[] = { + {SIPO_MODE_ANIMATION, "FCURVES", ICON_IPO, "Graph Editor", + "Edit animation/keyframes displayed as 2D curves"}, + {SIPO_MODE_DRIVERS, "DRIVERS", ICON_DRIVER, "Drivers", "Edit drivers"}, + {0, NULL, 0, NULL, NULL} +}; + +#define SACT_ITEM_DOPESHEET \ + {SACTCONT_DOPESHEET, "DOPESHEET", ICON_ACTION, "Dope Sheet", "Edit all keyframes in scene"} +#define SACT_ITEM_TIMELINE \ + {SACTCONT_TIMELINE, "TIMELINE", ICON_TIME, "Timeline", "Timeline and playback controls"} +#define SACT_ITEM_ACTION \ + {SACTCONT_ACTION, "ACTION", ICON_OBJECT_DATA, "Action Editor", "Edit keyframes in active object's Object-level action"} +#define SACT_ITEM_SHAPEKEY \ + {SACTCONT_SHAPEKEY, "SHAPEKEY", ICON_SHAPEKEY_DATA, "Shape Key Editor", "Edit keyframes in active object's Shape Keys action"} +#define SACT_ITEM_GPENCIL \ + {SACTCONT_GPENCIL, "GPENCIL", ICON_GREASEPENCIL, "Grease Pencil", "Edit timings for all Grease Pencil sketches in file"} +#define SACT_ITEM_MASK \ + {SACTCONT_MASK, "MASK", ICON_MOD_MASK, "Mask", "Edit timings for Mask Editor splines"} +#define SACT_ITEM_CACHEFILE \ + {SACTCONT_CACHEFILE, "CACHEFILE", ICON_FILE, "Cache File", "Edit timings for Cache File data-blocks"} + +#ifndef RNA_RUNTIME +/* XXX: action-editor is currently for object-level only actions, so show that using object-icon hint */ +static EnumPropertyItem rna_enum_space_action_mode_all_items[] = { + SACT_ITEM_DOPESHEET, + SACT_ITEM_TIMELINE, + SACT_ITEM_ACTION, + SACT_ITEM_SHAPEKEY, + SACT_ITEM_GPENCIL, + SACT_ITEM_MASK, + SACT_ITEM_CACHEFILE, + {0, NULL, 0, NULL, NULL} +}; +static EnumPropertyItem rna_enum_space_action_ui_mode_items[] = { + SACT_ITEM_DOPESHEET, + /* SACT_ITEM_TIMELINE, */ + SACT_ITEM_ACTION, + SACT_ITEM_SHAPEKEY, + SACT_ITEM_GPENCIL, + SACT_ITEM_MASK, + SACT_ITEM_CACHEFILE, + {0, NULL, 0, NULL, NULL} +}; +#endif +/* expose as ui_mode */ +const EnumPropertyItem rna_enum_space_action_mode_items[] = { + SACT_ITEM_DOPESHEET, + SACT_ITEM_TIMELINE, + {0, NULL, 0, NULL, NULL} +}; + +#undef SACT_ITEM_DOPESHEET +#undef SACT_ITEM_TIMELINE +#undef SACT_ITEM_ACTION +#undef SACT_ITEM_SHAPEKEY +#undef SACT_ITEM_GPENCIL +#undef SACT_ITEM_MASK +#undef SACT_ITEM_CACHEFILE const EnumPropertyItem rna_enum_space_image_mode_items[] = { {SI_MODE_VIEW, "VIEW", ICON_FILE_IMAGE, "View", "View the image and UV edit in mesh editmode"}, @@ -178,11 +237,9 @@ static const EnumPropertyItem autosnap_items[] = { #endif const EnumPropertyItem rna_enum_shading_type_items[] = { - {OB_WIRE, "WIREFRAME", ICON_WIRE, "Wireframe", "Display the object as wire edges"}, - {OB_SOLID, "SOLID", ICON_SOLID, "Single Color", "Display the object or material in a single color"}, - {OB_TEXTURE, "TEXTURED", ICON_POTATO, "Texture", "Display the object solid, with a texture"}, - {OB_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "Material", "Display objects solid, with GLSL material"}, - {OB_RENDER, "RENDERED", ICON_SMOOTH, "Rendered", "Display render preview"}, + {OB_SOLID, "SOLID", ICON_SOLID, "Solid", "Display in solid mode"}, + {OB_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "LookDev", "Display in LookDev mode"}, + {OB_RENDER, "RENDERED", ICON_SMOOTH, "Rendered", "Display render preview"}, {0, NULL, 0, NULL, NULL} }; @@ -193,6 +250,15 @@ const EnumPropertyItem rna_enum_viewport_lighting_items[] = { {0, NULL, 0, NULL, NULL} }; +static const EnumPropertyItem rna_enum_shading_color_type_items[] = { + {V3D_SHADING_SINGLE_COLOR, "SOLID", 0, "Single", "Show scene in a single color"}, + {V3D_SHADING_MATERIAL_COLOR, "MATERIAL", 0, "Material", "Show material color"}, + {V3D_SHADING_RANDOM_COLOR, "RANDOM", 0, "Random", "Show random object color"}, + {V3D_SHADING_TEXTURE_COLOR, "TEXTURE", 0, "Texture", "Show texture"}, + {0, NULL, 0, NULL, NULL} +}; + + static const EnumPropertyItem rna_enum_studio_light_items[] = { {0, "DEFAULT", 0, "Default", ""}, {0, NULL, 0, NULL, NULL} @@ -268,6 +334,7 @@ const EnumPropertyItem rna_enum_file_sort_items[] = { #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" +#include "ED_anim_api.h" #include "ED_buttons.h" #include "ED_fileselect.h" #include "ED_image.h" @@ -428,7 +495,7 @@ static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, int valu v3d->scenelock = value; if (value) { - Scene *scene = ED_screen_scene_find(sc, G.main->wm.first); + Scene *scene = ED_screen_scene_find(sc, G_MAIN->wm.first); int bit; v3d->lay = scene->lay; @@ -450,7 +517,7 @@ static View3DCursor *rna_View3D_Cursor_get_from_scene_or_localview(PointerRNA *p { View3D *v3d = (View3D *)(ptr->data); bScreen *screen = ptr->id.data; - Scene *scene = ED_screen_scene_find(screen, G.main->wm.first); + Scene *scene = ED_screen_scene_find(screen, G_MAIN->wm.first); return ED_view3d_cursor3d_get(scene, v3d); } @@ -482,7 +549,7 @@ static float rna_View3DOverlay_GridScaleUnit_get(PointerRNA *ptr) { View3D *v3d = (View3D *)(ptr->data); bScreen *screen = ptr->id.data; - Scene *scene = ED_screen_scene_find(screen, G.main->wm.first); + Scene *scene = ED_screen_scene_find(screen, G_MAIN->wm.first); return ED_view3d_grid_scale(scene, v3d, NULL); } @@ -613,7 +680,7 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value static int rna_3DViewShading_type_get(PointerRNA *ptr) { bScreen *screen = ptr->id.data; - Scene *scene = WM_windows_scene_get_from_screen(G.main->wm.first, screen); + Scene *scene = WM_windows_scene_get_from_screen(G_MAIN->wm.first, screen); RenderEngineType *type = RE_engines_find(scene->r.engine); View3D *v3d = (View3D *)ptr->data; @@ -632,9 +699,6 @@ static void rna_3DViewShading_type_set(PointerRNA *ptr, int value) if (value != v3d->drawtype && value == OB_RENDER) { v3d->prev_drawtype = v3d->drawtype; } - if (value == OB_TEXTURE && v3d->shading.light == V3D_LIGHTING_MATCAP) { - v3d->shading.light = V3D_LIGHTING_STUDIO; - } v3d->drawtype = value; } @@ -650,7 +714,6 @@ static const EnumPropertyItem *rna_3DViewShading_type_itemf( int totitem = 0; RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_SOLID); - RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_TEXTURE); if (BKE_scene_uses_blender_eevee(scene)) { RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_MATERIAL); @@ -693,10 +756,13 @@ static int rna_View3DShading_light_get(PointerRNA *ptr) static void rna_View3DShading_light_set(PointerRNA *ptr, int value) { View3D *v3d = (View3D *)ptr->data; + if (value == V3D_LIGHTING_MATCAP && v3d->shading.color_type == V3D_SHADING_TEXTURE_COLOR) { + v3d->shading.color_type = V3D_SHADING_MATERIAL_COLOR; + } v3d->shading.light = value; } -static const EnumPropertyItem *rna_View3DShading_light_itemf( +static const EnumPropertyItem *rna_View3DShading_color_type_itemf( bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { @@ -705,14 +771,15 @@ static const EnumPropertyItem *rna_View3DShading_light_itemf( int totitem = 0; EnumPropertyItem *item = NULL; - if (v3d->drawtype == OB_SOLID || v3d->drawtype == OB_TEXTURE) { - RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_lighting_items, V3D_LIGHTING_FLAT); - RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_lighting_items, V3D_LIGHTING_STUDIO); - } - if (v3d->drawtype == OB_SOLID) { - RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_lighting_items, V3D_LIGHTING_MATCAP); + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_SINGLE_COLOR); + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_MATERIAL_COLOR); + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_RANDOM_COLOR); + if (v3d->shading.light != V3D_LIGHTING_MATCAP) { + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_TEXTURE_COLOR); + } } + RNA_enum_item_end(&item, &totitem); *r_free = true; return item; @@ -900,7 +967,7 @@ static int rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; - wmWindow *win = ED_screen_window_find(sc, G.main->wm.first); + wmWindow *win = ED_screen_window_find(sc, G_MAIN->wm.first); ViewLayer *view_layer = WM_window_get_active_view_layer(win); Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); return ED_space_image_show_uvedit(sima, obedit); @@ -910,7 +977,7 @@ static int rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; - wmWindow *win = ED_screen_window_find(sc, G.main->wm.first); + wmWindow *win = ED_screen_window_find(sc, G_MAIN->wm.first); ViewLayer *view_layer = WM_window_get_active_view_layer(win); return ED_space_image_check_show_maskedit(sima, view_layer); } @@ -920,10 +987,12 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value) SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; wmWindow *win; - Scene *scene = ED_screen_scene_find_with_window(sc, G.main->wm.first, &win); + Scene *scene = ED_screen_scene_find_with_window(sc, G_MAIN->wm.first, &win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); - ED_space_image_set(G.main, sima, scene, obedit, (Image *)value.data); + + BLI_assert(BKE_id_is_in_gobal_main(value.data)); + ED_space_image_set(G_MAIN, sima, scene, obedit, (Image *)value.data); } static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value) @@ -1440,9 +1509,10 @@ static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr) saction->action = NULL; } - /* Collapse summary channel and hide channel list for timeline */ + /* Collapse (and show) summary channel and hide channel list for timeline */ if (saction->mode == SACTCONT_TIMELINE) { saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED; + saction->ads.filterflag |= ADS_FILTER_SUMMARY; } if (sa && sa->spacedata.first == saction) { @@ -1460,13 +1530,25 @@ static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr) /* recalculate extents of channel list */ saction->flag |= SACTION_TEMP_NEEDCHANSYNC; + + /* store current mode as "old mode", so that returning from other editors doesn't always reset to "Action Editor" */ + if (saction->mode != SACTCONT_TIMELINE) { + saction->mode_prev = saction->mode; + } } /* Space Graph Editor */ -static void rna_SpaceGraphEditor_display_mode_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_SpaceGraphEditor_display_mode_update(bContext *C, PointerRNA *ptr) { ScrArea *sa = rna_area_from_space(ptr); + SpaceIpo *sipo = (SpaceIpo *)ptr->data; + + /* for "Drivers" mode, enable all the necessary bits and pieces */ + if (sipo->mode == SIPO_MODE_DRIVERS) { + ED_drivers_editor_init(C, sa); + ED_area_tag_redraw(sa); + } /* after changing view mode, must force recalculation of F-Curve colors * which can only be achieved using refresh as opposed to redraw @@ -2155,12 +2237,12 @@ static void rna_def_space_outliner(BlenderRNA *brna) PropertyRNA *prop; static const EnumPropertyItem display_mode_items[] = { - {SO_SCENES, "SCENES", 0, "Scenes", "Display scenes and their view layers, collections and objects"}, - {SO_VIEW_LAYER, "VIEW_LAYER", 0, "View Layer", "Display collections and objects in the view layer"}, - {SO_SEQUENCE, "SEQUENCE", 0, "Sequence", "Display sequence data-blocks"}, - {SO_LIBRARIES, "LIBRARIES", 0, "Blender File", "Display data of current file and linked libraries"}, - {SO_DATA_API, "DATA_API", 0, "Data API", "Display low level Blender data and its properties"}, - {SO_ID_ORPHANS, "ORPHAN_DATA", 0, "Orphan Data", + {SO_SCENES, "SCENES", ICON_SCENE_DATA, "Scenes", "Display scenes and their view layers, collections and objects"}, + {SO_VIEW_LAYER, "VIEW_LAYER", ICON_RENDER_RESULT, "View Layer", "Display collections and objects in the view layer"}, + {SO_SEQUENCE, "SEQUENCE", ICON_SEQUENCE, "Sequence", "Display sequence data-blocks"}, + {SO_LIBRARIES, "LIBRARIES", ICON_FILE_BLEND, "Blender File", "Display data of current file and linked libraries"}, + {SO_DATA_API, "DATA_API", ICON_RNA, "Data API", "Display low level Blender data and its properties"}, + {SO_ID_ORPHANS, "ORPHAN_DATA", ICON_EXTERNAL_DATA, "Orphan Data", "Display data-blocks which are unused and/or will be lost when the file is reloaded"}, {0, NULL, 0, NULL, NULL} }; @@ -2213,12 +2295,6 @@ static void rna_def_space_outliner(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); /* Filters. */ - prop = RNA_def_property(srna, "use_filter_search", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filter", SO_FILTER_SEARCH); - RNA_def_property_ui_text(prop, "Search Name", "Filter searched elements"); - RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); - prop = RNA_def_property(srna, "use_filter_object", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_OBJECT); RNA_def_property_ui_text(prop, "Filter Objects", "Show objects"); @@ -2294,13 +2370,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem color_type_items[] = { - {V3D_SHADING_SINGLE_COLOR, "SINGLE", 0, "Single", "Show scene in a single color"}, - {V3D_SHADING_MATERIAL_COLOR, "MATERIAL", 0, "Material", "Show material color"}, - {V3D_SHADING_RANDOM_COLOR, "RANDOM", 0, "Random", "Show random object color"}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "View3DShading", NULL); RNA_def_struct_sdna(srna, "View3D"); RNA_def_struct_nested(brna, srna, "SpaceView3D"); @@ -2318,7 +2387,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) prop = RNA_def_property(srna, "light", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "shading.light"); RNA_def_property_enum_items(prop, rna_enum_viewport_lighting_items); - RNA_def_property_enum_funcs(prop, "rna_View3DShading_light_get", "rna_View3DShading_light_set", "rna_View3DShading_light_itemf"); + RNA_def_property_enum_funcs(prop, "rna_View3DShading_light_get", "rna_View3DShading_light_set", NULL); RNA_def_property_ui_text(prop, "Lighting", "Lighting Method for Solid/Texture Viewport Shading"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); @@ -2377,7 +2446,8 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) prop = RNA_def_property(srna, "color_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "shading.color_type"); - RNA_def_property_enum_items(prop, color_type_items); + RNA_def_property_enum_items(prop, rna_enum_shading_color_type_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_View3DShading_color_type_itemf"); RNA_def_property_ui_text(prop, "Color", "Color Type"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); @@ -2642,6 +2712,27 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "overlay.arm_flag", V3D_OVERLAY_ARM_TRANSP_BONES); RNA_def_property_ui_text(prop, "Transparent Bones", "Display bones as transparent"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "texture_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.texture_paint_mode_opacity"); + RNA_def_property_float_default(prop, 0.8f); + RNA_def_property_ui_text(prop, "Texture Opacity", "Opacity of the texture paint mode overlay"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "vertex_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.vertex_paint_mode_opacity"); + RNA_def_property_float_default(prop, 0.8f); + RNA_def_property_ui_text(prop, "Vertex Paint Opacity", "Opacity of the vertex paint mode overlay"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "weight_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.weight_paint_mode_opacity"); + RNA_def_property_float_default(prop, 0.8f); + RNA_def_property_ui_text(prop, "Weight Paint Opacity", "Opacity of the weight paint mode overlay"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); } static void rna_def_space_view3d(BlenderRNA *brna) @@ -2779,11 +2870,6 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Textured Solid", "Display face-assigned textures in solid view"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_mode_shade_override", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_MODE_SHADE_OVERRIDE); - RNA_def_property_ui_text(prop, "Full Shading", "Use full shading for mode drawing (to view final result)"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_occlude_wire", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_OCCLUDE_WIRE); RNA_def_property_ui_text(prop, "Hidden Wire", "Use hidden wireframe display"); @@ -3536,19 +3622,6 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - /* XXX: action-editor is currently for object-level only actions, so show that using object-icon hint */ - static EnumPropertyItem mode_items[] = { - {SACTCONT_TIMELINE, "TIMELINE", ICON_TIME, "Timeline", "Timeline and playback controls"}, - {SACTCONT_DOPESHEET, "DOPESHEET", ICON_OOPS, "Dope Sheet", "Edit all keyframes in scene"}, - {SACTCONT_ACTION, "ACTION", ICON_OBJECT_DATA, "Action Editor", "Edit keyframes in active object's Object-level action"}, - {SACTCONT_SHAPEKEY, "SHAPEKEY", ICON_SHAPEKEY_DATA, "Shape Key Editor", "Edit keyframes in active object's Shape Keys action"}, - {SACTCONT_GPENCIL, "GPENCIL", ICON_GREASEPENCIL, "Grease Pencil", "Edit timings for all Grease Pencil sketches in file"}, - {SACTCONT_MASK, "MASK", ICON_MOD_MASK, "Mask", "Edit timings for Mask Editor splines"}, - {SACTCONT_CACHEFILE, "CACHEFILE", ICON_FILE, "Cache File", "Edit timings for Cache File data-blocks"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "SpaceDopeSheetEditor", "Space"); RNA_def_struct_sdna(srna, "SpaceAction"); RNA_def_struct_ui_text(srna, "Space Dope Sheet Editor", "Dope Sheet space data"); @@ -3562,10 +3635,17 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_SpaceDopeSheetEditor_action_update"); - /* mode */ + /* mode (hidden in the UI, see 'ui_mode') */ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_enum_items(prop, rna_enum_space_action_mode_all_items); + RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, "rna_SpaceDopeSheetEditor_mode_update"); + + prop = RNA_def_property(srna, "ui_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, rna_enum_space_action_ui_mode_items); RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, "rna_SpaceDopeSheetEditor_mode_update"); @@ -3672,13 +3752,6 @@ static void rna_def_space_graph(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem mode_items[] = { - {SIPO_MODE_ANIMATION, "FCURVES", ICON_IPO, "F-Curve", - "Edit animation/keyframes displayed as 2D curves"}, - {SIPO_MODE_DRIVERS, "DRIVERS", ICON_DRIVER, "Drivers", "Edit drivers"}, - {0, NULL, 0, NULL, NULL} - }; - /* this is basically the same as the one for the 3D-View, but with some entries omitted */ static const EnumPropertyItem gpivot_items[] = { {V3D_AROUND_CENTER_BOUNDS, "BOUNDING_BOX_CENTER", ICON_ROTATE, "Bounding Box Center", ""}, @@ -3697,8 +3770,9 @@ static void rna_def_space_graph(BlenderRNA *brna) /* mode */ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_enum_items(prop, rna_enum_space_graph_mode_items); RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, "rna_SpaceGraphEditor_display_mode_update"); /* display */ diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 9377ef8a925..702bcf15462 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -1021,6 +1021,9 @@ void RNA_api_ui_layout(StructRNA *srna) func = RNA_def_function(srna, "template_reports_banner", "uiTemplateReportsBanner"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); + func = RNA_def_function(srna, "template_cursor_keymap", "uiTemplateCursorKeymap"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + func = RNA_def_function(srna, "template_node_link", "uiTemplateNodeLink"); parm = RNA_def_pointer(func, "ntree", "NodeTree", "", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 2dbdb1bbb1c..95ca742e8da 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -36,9 +36,9 @@ #include "BLI_utildefines.h" #include "BLI_math_base.h" +#include "BLI_math_vector.h" #include "BKE_appdir.h" -#include "BKE_DerivedMesh.h" #include "BKE_sound.h" #include "BKE_addon.h" #include "BKE_studiolight.h" @@ -86,15 +86,25 @@ static const EnumPropertyItem rna_enum_language_default_items[] = { }; #endif +static const EnumPropertyItem rna_enum_studio_light_orientation_items[] = { + {STUDIOLIGHT_ORIENTATION_CAMERA, "CAMERA", 0, "Camera", ""}, + {STUDIOLIGHT_ORIENTATION_WORLD, "WORLD", 0, "World", ""}, + {STUDIOLIGHT_ORIENTATION_VIEWNORMAL, "MATCAP", 0, "MatCap", ""}, + {0, NULL, 0, NULL, NULL} +}; + + #ifdef RNA_RUNTIME #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "BKE_blender.h" +#include "BKE_DerivedMesh.h" #include "BKE_global.h" -#include "BKE_main.h" #include "BKE_idprop.h" +#include "BKE_main.h" +#include "BKE_mesh_runtime.h" #include "BKE_pbvh.h" #include "BKE_paint.h" @@ -207,25 +217,25 @@ static void rna_userdef_load_ui_update(Main *UNUSED(bmain), Scene *UNUSED(scene) static void rna_userdef_anisotropic_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - GPU_set_anisotropic(U.anisotropic_filter); + GPU_set_anisotropic(bmain, U.anisotropic_filter); rna_userdef_update(bmain, scene, ptr); } static void rna_userdef_gl_gpu_mipmaps(Main *bmain, Scene *scene, PointerRNA *ptr) { - GPU_set_gpu_mipmapping(U.use_gpu_mipmap); + GPU_set_gpu_mipmapping(bmain, U.use_gpu_mipmap); rna_userdef_update(bmain, scene, ptr); } static void rna_userdef_gl_texture_limit_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - GPU_free_images(); + GPU_free_images(bmain); rna_userdef_update(bmain, scene, ptr); } static void rna_userdef_gl_use_16bit_textures(Main *bmain, Scene *scene, PointerRNA *ptr) { - GPU_free_images(); + GPU_free_images(bmain); rna_userdef_update(bmain, scene, ptr); } @@ -356,7 +366,7 @@ static void rna_UserDef_weight_color_update(Main *bmain, Scene *scene, PointerRN Object *ob; bTheme *btheme = UI_GetTheme(); - vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, btheme->tv3d.vertex_unreferenced); + BKE_mesh_runtime_color_band_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, btheme->tv3d.vertex_unreferenced); for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->mode & OB_MODE_WEIGHT_PAINT) @@ -661,11 +671,21 @@ static void rna_UserDef_studiolight_begin(CollectionPropertyIterator *iter, Poin rna_iterator_listbase_begin(iter, BKE_studiolight_listbase(), NULL); } -static void rna_UserDef_studiolight_refresh(UserDef *UNUSED(userdef)) +static void rna_StudioLights_refresh(UserDef *UNUSED(userdef)) { BKE_studiolight_refresh(); } +static void rna_StudioLights_remove(UserDef *UNUSED(userdef), StudioLight *studio_light) +{ + BKE_studiolight_remove(studio_light); +} + +static StudioLight *rna_StudioLights_new(UserDef *UNUSED(userdef), const char *path, int orientation) +{ + return BKE_studiolight_new(path, orientation); +} + /* StudioLight.name */ static void rna_UserDef_studiolight_name_get(PointerRNA *ptr, char *value) { @@ -692,6 +712,44 @@ static int rna_UserDef_studiolight_path_length(PointerRNA *ptr) return strlen(sl->path); } +/* StudioLight.path_irr_cache */ +static void rna_UserDef_studiolight_path_irr_cache_get(PointerRNA *ptr, char *value) +{ + StudioLight *sl = (StudioLight *)ptr->data; + if (sl->path_irr_cache) { + BLI_strncpy(value, sl->path_irr_cache, FILE_MAX); + } + value[0] = 0x00; +} + +static int rna_UserDef_studiolight_path_irr_cache_length(PointerRNA *ptr) +{ + StudioLight *sl = (StudioLight *)ptr->data; + if (sl->path_irr_cache) { + return strlen(sl->path_irr_cache); + } + return 0; +} + +/* StudioLight.path_sh_cache */ +static void rna_UserDef_studiolight_path_sh_cache_get(PointerRNA *ptr, char *value) +{ + StudioLight *sl = (StudioLight *)ptr->data; + if (sl->path_sh_cache) { + BLI_strncpy(value, sl->path_sh_cache, FILE_MAX); + } + value[0] = 0x00; +} + +static int rna_UserDef_studiolight_path_sh_cache_length(PointerRNA *ptr) +{ + StudioLight *sl = (StudioLight *)ptr->data; + if (sl->path_sh_cache) { + return strlen(sl->path_sh_cache); + } + return 0; +} + /* StudioLight.index */ static int rna_UserDef_studiolight_index_get(PointerRNA *ptr) { @@ -714,11 +772,16 @@ static int rna_UserDef_studiolight_orientation_get(PointerRNA *ptr) return sl->flag & STUDIOLIGHT_FLAG_ORIENTATIONS; } -static void rna_UserDef_studiolight_orientation_set(PointerRNA *UNUSED(ptr), const int UNUSED(value)) +static void rna_UserDef_studiolight_spherical_harmonics_coefficients_get(PointerRNA *ptr, float *values) { + StudioLight *sl = (StudioLight *)ptr->data; + float *value = values; + for (int i = 0; i < STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS; i++) { + copy_v3_v3(value, sl->spherical_harmonics_coefs[i]); + value += 3; + } } - #else /* TODO(sergey): This technically belongs to blenlib, but we don't link @@ -2788,7 +2851,7 @@ static void rna_def_userdef_theme_space_nla(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeNLAEditor", NULL); RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_clear_flag(srna, STRUCT_UNDO); - RNA_def_struct_ui_text(srna, "Theme NLA Editor", "Theme settings for the NLA Editor"); + RNA_def_struct_ui_text(srna, "Theme Nonlinear Animation", "Theme settings for the NLA Editor"); rna_def_userdef_theme_spaces_main(srna); rna_def_userdef_theme_spaces_list_main(srna); @@ -3058,7 +3121,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna) {1, "VIEW_3D", ICON_VIEW3D, "3D View", ""}, {3, "GRAPH_EDITOR", ICON_IPO, "Graph Editor", ""}, {4, "DOPESHEET_EDITOR", ICON_ACTION, "Dope Sheet", ""}, - {5, "NLA_EDITOR", ICON_NLA, "NLA Editor", ""}, + {5, "NLA_EDITOR", ICON_NLA, "Nonlinear Animation", ""}, {6, "IMAGE_EDITOR", ICON_IMAGE_COL, "UV/Image Editor", ""}, {7, "SEQUENCE_EDITOR", ICON_SEQUENCE, "Video Sequence Editor", ""}, {8, "TEXT_EDITOR", ICON_TEXT, "Text Editor", ""}, @@ -3120,7 +3183,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "tnla"); RNA_def_property_struct_type(prop, "ThemeNLAEditor"); - RNA_def_property_ui_text(prop, "NLA Editor", ""); + RNA_def_property_ui_text(prop, "Nonlinear Animation", ""); prop = RNA_def_property(srna, "dopesheet_editor", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); @@ -3227,18 +3290,39 @@ static void rna_def_userdef_addon(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, "rna_Addon_preferences_get", NULL, NULL, NULL); } +static void rna_def_userdef_studiolights(BlenderRNA *brna) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + srna = RNA_def_struct(brna, "StudioLights", NULL); + RNA_def_struct_sdna(srna, "UserDef"); + RNA_def_struct_ui_text(srna, "Studio Lights", "Collection of studio lights"); + + func = RNA_def_function(srna, "new", "rna_StudioLights_new"); + RNA_def_function_ui_description(func, "Create a new studiolight"); + parm = RNA_def_string(func, "path", NULL, 0, "File Path", "File path where the studio light file can be found"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_enum(func, "orientation", rna_enum_studio_light_orientation_items, STUDIOLIGHT_ORIENTATION_WORLD, "Orientation", "The orientation for the new studio light"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, "studio_light", "StudioLight", "", "Newly created StudioLight"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_StudioLights_remove"); + RNA_def_function_ui_description(func, "Remove a studio light"); + parm = RNA_def_pointer(func, "studio_light", "StudioLight", "", "The studio light to remove"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + func = RNA_def_function(srna, "refresh", "rna_StudioLights_refresh"); + RNA_def_function_ui_description(func, "Refresh Studio Lights from disk"); +} + static void rna_def_userdef_studiolight(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem rna_enum_studio_light_orientation_items[] = { - {STUDIOLIGHT_ORIENTATION_CAMERA, "CAMERA", 0, "Camera", ""}, - {STUDIOLIGHT_ORIENTATION_WORLD, "WORLD", 0, "World", ""}, - {STUDIOLIGHT_ORIENTATION_VIEWNORMAL, "MATCAP", 0, "MatCap", ""}, - {0, NULL, 0, NULL, NULL} - }; - RNA_define_verify_sdna(false); srna = RNA_def_struct(brna, "StudioLight", NULL); RNA_def_struct_clear_flag(srna, STRUCT_UNDO); @@ -3256,7 +3340,8 @@ static void rna_def_userdef_studiolight(BlenderRNA *brna) prop = RNA_def_property(srna, "orientation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, rna_enum_studio_light_orientation_items); - RNA_def_property_enum_funcs(prop, "rna_UserDef_studiolight_orientation_get", "rna_UserDef_studiolight_orientation_set", NULL); + RNA_def_property_enum_funcs(prop, "rna_UserDef_studiolight_orientation_get", NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Orientation", ""); prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); @@ -3270,8 +3355,23 @@ static void rna_def_userdef_studiolight(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Path", ""); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_define_verify_sdna(true); + prop = RNA_def_property(srna, "path_irr_cache", PROP_STRING, PROP_DIRPATH); + RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_path_irr_cache_get", "rna_UserDef_studiolight_path_irr_cache_length", NULL); + RNA_def_property_ui_text(prop, "Irradiance Cache Path", "Path where the irradiance cache is stored"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop = RNA_def_property(srna, "path_sh_cache", PROP_STRING, PROP_DIRPATH); + RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_path_sh_cache_get", "rna_UserDef_studiolight_path_sh_cache_length", NULL); + RNA_def_property_ui_text(prop, "SH Cache Path", "Path where the spherical harmonics cache is stored"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + const int spherical_harmonics_dim[] = {STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS, 3}; + prop = RNA_def_property(srna, "spherical_harmonics_coefficients", PROP_FLOAT, PROP_COLOR); + RNA_def_property_multi_array(prop, 2, spherical_harmonics_dim); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_float_funcs(prop, "rna_UserDef_studiolight_spherical_harmonics_coefficients_get", NULL, NULL); + + RNA_define_verify_sdna(true); } static void rna_def_userdef_pathcompare(BlenderRNA *brna) @@ -3492,6 +3592,12 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_TOOLTIPS_PYTHON); RNA_def_property_ui_text(prop, "Python Tooltips", "Show Python references in tooltips"); + prop = RNA_def_property(srna, "show_developer_ui", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_DEVELOPER_UI); + RNA_def_property_ui_text( + prop, "Developer Extras", + "Show options for developers (edit source in context menu, geometry indices)"); + prop = RNA_def_property(srna, "show_object_info", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_DRAWVIEWINFO); RNA_def_property_ui_text(prop, "Display Object Info", "Display objects name and frame number in 3D view"); @@ -4791,7 +4897,6 @@ void RNA_def_userdef(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - FunctionRNA *func; static const EnumPropertyItem user_pref_sections[] = { {USER_SECTION_INTERFACE, "INTERFACE", 0, "Interface", ""}, @@ -4885,16 +4990,14 @@ void RNA_def_userdef(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_flag(prop, PROP_THICK_WRAP); + /* StudioLight Collection */ prop = RNA_def_property(srna, "studio_lights", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "StudioLight"); + RNA_def_property_srna(prop, "StudioLights"); RNA_def_property_collection_funcs( prop, "rna_UserDef_studiolight_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", NULL, NULL, NULL, NULL); - - func = RNA_def_function(srna, "studio_lights_refresh", "rna_UserDef_studiolight_refresh"); - RNA_def_function_ui_description(func, "Refresh Studio Lights"); - RNA_def_property_ui_text(prop, "Studio Lights", ""); rna_def_userdef_view(brna); @@ -4904,6 +5007,7 @@ void RNA_def_userdef(BlenderRNA *brna) rna_def_userdef_system(brna); rna_def_userdef_addon(brna); rna_def_userdef_addon_pref(brna); + rna_def_userdef_studiolights(brna); rna_def_userdef_studiolight(brna); rna_def_userdef_pathcompare(brna); diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c index 4ae1e107e28..6cfee512ff7 100644 --- a/source/blender/makesrna/intern/rna_wm_manipulator.c +++ b/source/blender/makesrna/intern/rna_wm_manipulator.c @@ -261,7 +261,7 @@ static wmManipulator *rna_ManipulatorProperties_find_operator(PointerRNA *ptr) #endif /* We could try workaruond this lookup, but not trivial. */ - for (bScreen *screen = G.main->screen.first; screen; screen = screen->id.next) { + for (bScreen *screen = G_MAIN->screen.first; screen; screen = screen->id.next) { IDProperty *properties = ptr->data; for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 40d568537a0..574a62ffd3a 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -85,7 +85,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED( return dataMask; } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { ArmatureModifierData *amd = (ArmatureModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index c1268157d58..5ae0013aab0 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -46,7 +46,6 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BKE_cdderivedmesh.h" #include "BKE_displist.h" #include "BKE_curve.h" #include "BKE_library.h" diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 74cbbb65e80..546fde3968a 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -32,14 +32,14 @@ * \ingroup modifiers */ -#include "DNA_object_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" #include "BLI_utildefines.h" #include "BLI_math.h" #include "BLI_string.h" -#include "BKE_cdderivedmesh.h" #include "BKE_deform.h" #include "BKE_mesh.h" #include "BKE_modifier.h" diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index f7b16431c48..6cea7b8fece 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -76,7 +76,7 @@ static void initData(ModifierData *md) bmd->double_threshold = 1e-6f; } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { BooleanModifierData *bmd = (BooleanModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index 9b491d4333f..902a9e7f14f 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -46,7 +46,6 @@ #include "DEG_depsgraph_query.h" -#include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_particle.h" diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index 4441af57c93..67294c77c05 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -63,7 +63,7 @@ static void initData(ModifierData *md) cmd->object = NULL; } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { CastModifierData *cmd = (CastModifierData *) md; short flag; diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 19afe30acae..979faacc809 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -54,6 +54,9 @@ #include "BKE_modifier.h" #include "BKE_pointcache.h" +#include "DEG_depsgraph_physics.h" +#include "DEG_depsgraph_query.h" + #include "MOD_util.h" static void initData(ModifierData *md) @@ -78,6 +81,7 @@ static void deformVerts( { Mesh *mesh_src; ClothModifierData *clmd = (ClothModifierData *) md; + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); /* check for alloc failing */ if (!clmd->sim_parms || !clmd->coll_parms) { @@ -123,7 +127,7 @@ static void deformVerts( BKE_mesh_apply_vert_coords(mesh_src, vertexCos); - clothModifier_do(clmd, ctx->depsgraph, md->scene, ctx->object, mesh_src, vertexCos); + clothModifier_do(clmd, ctx->depsgraph, scene, ctx->object, mesh_src, vertexCos); BKE_id_free(NULL, mesh_src); } @@ -132,10 +136,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte { ClothModifierData *clmd = (ClothModifierData *)md; if (clmd != NULL) { - /* Actual code uses get_collisionobjects */ - DEG_add_collision_relations(ctx->node, ctx->scene, ctx->object, clmd->coll_parms->group, eModifierType_Collision, NULL, true, "Cloth Collision"); - - DEG_add_forcefield_relations(ctx->node, ctx->scene, ctx->object, clmd->sim_parms->effector_weights, true, 0, "Cloth Field"); + DEG_add_collision_relations(ctx->node, ctx->object, clmd->coll_parms->group, eModifierType_Collision, NULL, "Cloth Collision"); + DEG_add_forcefield_relations(ctx->node, ctx->object, clmd->sim_parms->effector_weights, true, 0, "Cloth Field"); } } diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index deda8213a65..55837eb00e4 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -71,7 +71,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static bool isDisabled(ModifierData *md, int UNUSED(userRenderParams)) +static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, int UNUSED(userRenderParams)) { CurveModifierData *cmd = (CurveModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c index 21d1a6a865d..8e025059d6c 100644 --- a/source/blender/modifiers/intern/MOD_datatransfer.c +++ b/source/blender/modifiers/intern/MOD_datatransfer.c @@ -37,9 +37,7 @@ #include "DNA_object_types.h" #include "BKE_customdata.h" -#include "BKE_cdderivedmesh.h" #include "BKE_data_transfer.h" -#include "BKE_DerivedMesh.h" #include "BKE_library.h" #include "BKE_library_query.h" #include "BKE_mesh_mapping.h" @@ -47,6 +45,8 @@ #include "BKE_modifier.h" #include "BKE_report.h" +#include "DEG_depsgraph_query.h" + #include "MEM_guardedalloc.h" #include "MOD_util.h" @@ -133,7 +133,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { DataTransferModifierData *dtmd = (DataTransferModifierData *) md; /* If no source object, bypass. */ @@ -148,10 +148,11 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) DT_TYPE_SHARP_FACE \ ) -static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, DerivedMesh *derivedData) +static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mesh *me_mod) { DataTransferModifierData *dtmd = (DataTransferModifierData *) md; - DerivedMesh *dm = derivedData; + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); + Mesh *result = me_mod; ReportList reports; /* Only used to check wehther we are operating on org data or not... */ @@ -168,18 +169,24 @@ static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *c BLI_SPACE_TRANSFORM_SETUP(space_transform, ctx->object, dtmd->ob_source); } - MVert *mvert = dm->getVertArray(dm); - MEdge *medge = dm->getEdgeArray(dm); - if (((me->mvert == mvert) || (me->medge == medge)) && (dtmd->data_types & DT_TYPES_AFFECT_MESH)) { + if ((result == me_mod || (me->mvert == result->mvert) || (me->medge == result->medge)) && + (dtmd->data_types & DT_TYPES_AFFECT_MESH)) + { /* We need to duplicate data here, otherwise setting custom normals, edges' shaprness, etc., could * modify org mesh, see T43671. */ - dm = CDDM_copy(dm); + BKE_id_copy_ex( + NULL, &me_mod->id, (ID **)&result, + LIB_ID_CREATE_NO_MAIN | + LIB_ID_CREATE_NO_USER_REFCOUNT | + LIB_ID_CREATE_NO_DEG_TAG | + LIB_ID_COPY_NO_PREVIEW, + false); } BKE_reports_init(&reports, RPT_STORE); /* Note: no islands precision for now here. */ - BKE_object_data_transfer_dm(ctx->depsgraph, md->scene, dtmd->ob_source, ctx->object, dm, dtmd->data_types, false, + BKE_object_data_transfer_ex(ctx->depsgraph, scene, dtmd->ob_source, ctx->object, result, dtmd->data_types, false, dtmd->vmap_mode, dtmd->emap_mode, dtmd->lmap_mode, dtmd->pmap_mode, space_transform, false, max_dist, dtmd->map_ray_radius, 0.0f, dtmd->layers_select_src, dtmd->layers_select_dst, @@ -191,11 +198,11 @@ static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *c else if ((dtmd->data_types & DT_TYPE_LNOR) && !(me->flag & ME_AUTOSMOOTH)) { modifier_setError((ModifierData *)dtmd, "Enable 'Auto Smooth' option in mesh settings"); } - else if (dm->getNumVerts(dm) > HIGH_POLY_WARNING || ((Mesh *)(dtmd->ob_source->data))->totvert > HIGH_POLY_WARNING) { + else if (result->totvert > HIGH_POLY_WARNING || ((Mesh *)(dtmd->ob_source->data))->totvert > HIGH_POLY_WARNING) { modifier_setError(md, "You are using a rather high poly as source or destination, computation might be slow"); } - return dm; + return result; } #undef HIGH_POLY_WARNING @@ -217,14 +224,14 @@ ModifierTypeInfo modifierType_DataTransfer = { /* deformMatrices_DM */ NULL, /* deformVertsEM_DM */ NULL, /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ applyModifier, + /* applyModifier_DM */ NULL, /* applyModifierEM_DM */NULL, /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, /* deformMatricesEM */ NULL, - /* applyModifier */ NULL, + /* applyModifier */ applyModifier, /* applyModifierEM */ NULL, /* initData */ initData, diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index ef15b5fbf7a..351a496daa1 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -53,6 +53,7 @@ #include "BKE_object.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "MEM_guardedalloc.h" @@ -137,7 +138,7 @@ static void foreachTexLink( walk(userData, ob, md, "texture"); } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { DisplaceModifierData *dmd = (DisplaceModifierData *) md; return ((!dmd->texture && dmd->direction == MOD_DISP_DIR_RGB_XYZ) || dmd->strength == 0.0f); @@ -159,6 +160,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte typedef struct DisplaceUserdata { /*const*/ DisplaceModifierData *dmd; + struct Scene *scene; struct ImagePool *pool; MDeformVert *dvert; float weight; @@ -205,7 +207,7 @@ static void displaceModifier_do_task( if (dmd->texture) { texres.nor = NULL; - BKE_texture_get_value_ex(dmd->modifier.scene, dmd->texture, tex_co[iter], &texres, data->pool, false); + BKE_texture_get_value_ex(data->scene, dmd->texture, tex_co[iter], &texres, data->pool, false); delta = texres.tin - dmd->midlevel; } else { @@ -330,6 +332,7 @@ static void displaceModifier_do( } DisplaceUserdata data = {NULL}; + data.scene = DEG_get_evaluated_scene(ctx->depsgraph); data.dmd = dmd; data.dvert = dvert; data.weight = weight; diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index 5ca367e342a..9131bc0659f 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -42,8 +42,9 @@ #include "BKE_modifier.h" #include "DEG_depsgraph.h" - #include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_physics.h" +#include "DEG_depsgraph_query.h" #include "MOD_modifiertypes.h" @@ -107,7 +108,8 @@ static DerivedMesh *applyModifier( /* dont apply dynamic paint on orco dm stack */ if (!(ctx->flag & MOD_APPLY_ORCO)) { - return dynamicPaint_Modifier_do(pmd, ctx->depsgraph, md->scene, ctx->object, dm); + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); + return dynamicPaint_Modifier_do(pmd, ctx->depsgraph, scene, ctx->object, dm); } return dm; } @@ -124,11 +126,11 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte if (pmd->canvas != NULL) { for (DynamicPaintSurface *surface = pmd->canvas->surfaces.first; surface; surface = surface->next) { if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) { - DEG_add_forcefield_relations(ctx->node, ctx->scene, ctx->object, surface->effector_weights, true, 0, "Dynamic Paint Field"); + DEG_add_forcefield_relations(ctx->node, ctx->object, surface->effector_weights, true, 0, "Dynamic Paint Field"); } /* Actual code uses custom loop over group/scene without layer checks in dynamicPaint_doStep */ - DEG_add_collision_relations(ctx->node, ctx->scene, ctx->object, surface->brush_group, eModifierType_DynamicPaint, is_brush_cb, false, "Dynamic Paint Brush"); + DEG_add_collision_relations(ctx->node, ctx->object, surface->brush_group, eModifierType_DynamicPaint, is_brush_cb, "Dynamic Paint Brush"); } } } diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index e1806dc8283..a8d4d55c5d3 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -40,7 +40,6 @@ #include "BLI_utildefines.h" #include "BLI_math.h" -#include "BKE_cdderivedmesh.h" #include "BKE_library.h" #include "BKE_mesh.h" #include "BKE_modifier.h" diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index cbb15665bef..948aaf0751e 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -51,6 +51,8 @@ #include "BKE_particle.h" #include "BKE_scene.h" +#include "DEG_depsgraph_query.h" + #include "MEM_guardedalloc.h" #include "MOD_modifiertypes.h" @@ -1028,18 +1030,20 @@ static DerivedMesh *applyModifier( createFacepa(emd, psmd, derivedData); } /* 2. create new mesh */ + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); if (emd->flag & eExplodeFlag_EdgeCut) { int *facepa = emd->facepa; DerivedMesh *splitdm = cutEdges(emd, dm); - DerivedMesh *explode = explodeMesh(emd, psmd, ctx, md->scene, splitdm); + DerivedMesh *explode = explodeMesh(emd, psmd, ctx, scene, splitdm); MEM_freeN(emd->facepa); emd->facepa = facepa; splitdm->release(splitdm); return explode; } - else - return explodeMesh(emd, psmd, ctx, md->scene, derivedData); + else { + return explodeMesh(emd, psmd, ctx, scene, derivedData); + } } return derivedData; } diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 76df31823a7..f80cb9d6073 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -96,7 +96,7 @@ static void freeData(ModifierData *md) MEM_SAFE_FREE(hmd->indexar); } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { HookModifierData *hmd = (HookModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c index 63b4e950697..6ece9fb1f1b 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.c +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c @@ -715,7 +715,7 @@ static void copyData(const ModifierData *md, ModifierData *target) tlmd->cache_system = NULL; } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md; if (lmd->anchor_grp_name[0]) return 0; diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c index 59e4faee633..e903dd0de58 100644 --- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c @@ -81,7 +81,7 @@ struct BLaplacianSystem { typedef struct BLaplacianSystem LaplacianSystem; static CustomDataMask required_data_mask(Object *ob, ModifierData *md); -static bool is_disabled(ModifierData *md, int useRenderParams); +static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, int useRenderParams); static float compute_volume(const float center[3], float (*vertexCos)[3], const MPoly *mpoly, int numPolys, const MLoop *mloop); static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numPolys, int a_numLoops, int a_numVerts); static void delete_laplacian_system(LaplacianSystem *sys); @@ -474,7 +474,7 @@ static void init_data(ModifierData *md) smd->defgrp_name[0] = '\0'; } -static bool is_disabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *) md; short flag; diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index 219d08fc0f6..695e14a69df 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -67,7 +67,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static bool isDisabled(ModifierData *md, int UNUSED(userRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(userRenderParams)) { LatticeModifierData *lmd = (LatticeModifierData *) md; diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c index 50765079785..9d6dfc0e1eb 100644 --- a/source/blender/modifiers/intern/MOD_meshcache.c +++ b/source/blender/modifiers/intern/MOD_meshcache.c @@ -42,6 +42,8 @@ #include "BKE_mesh.h" #include "BKE_main.h" +#include "DEG_depsgraph_query.h" + #include "MEM_guardedalloc.h" #include "MOD_meshcache_util.h" /* utility functions */ @@ -70,7 +72,7 @@ static bool dependsOnTime(ModifierData *md) return (mcmd->play_mode == MOD_MESHCACHE_PLAY_CFEA); } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { MeshCacheModifierData *mcmd = (MeshCacheModifierData *) md; @@ -80,7 +82,7 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) static void meshcache_do( - MeshCacheModifierData *mcmd, Object *ob, DerivedMesh *UNUSED(dm), + MeshCacheModifierData *mcmd, Scene *scene, Object *ob, DerivedMesh *UNUSED(dm), float (*vertexCos_Real)[3], int numVerts) { const bool use_factor = mcmd->factor < 1.0f; @@ -88,7 +90,6 @@ static void meshcache_do( MEM_malloc_arrayN(numVerts, sizeof(*vertexCos_Store), __func__) : NULL; float (*vertexCos)[3] = vertexCos_Store ? vertexCos_Store : vertexCos_Real; - Scene *scene = mcmd->modifier.scene; const float fps = FPS; char filepath[FILE_MAX]; @@ -270,8 +271,9 @@ static void deformVerts( int numVerts) { MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md; + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); - meshcache_do(mcmd, ctx->object, derivedData, vertexCos, numVerts); + meshcache_do(mcmd, scene, ctx->object, derivedData, vertexCos, numVerts); } static void deformVertsEM( @@ -279,8 +281,9 @@ static void deformVertsEM( DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md; + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); - meshcache_do(mcmd, ctx->object, derivedData, vertexCos, numVerts); + meshcache_do(mcmd, scene, ctx->object, derivedData, vertexCos, numVerts); } diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index b50672e4160..15203f4fc2e 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -52,6 +52,7 @@ #include "MEM_guardedalloc.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "MOD_util.h" @@ -108,7 +109,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; @@ -294,7 +295,7 @@ static void meshdeformModifier_do( if (!mmd->object || (!mmd->bindcagecos && !mmd->bindfunc)) return; - /* Get cage derivedmesh. + /* Get cage mesh. * * Only do this is the target object is in edit mode by itself, meaning * we don't allow linked edit meshes here. @@ -324,8 +325,9 @@ static void meshdeformModifier_do( /* progress bar redraw can make this recursive .. */ if (!recursive) { + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); recursive = 1; - mmd->bindfunc(md->scene, mmd, cagemesh, (float *)vertexCos, numVerts, cagemat); + mmd->bindfunc(scene, mmd, cagemesh, (float *)vertexCos, numVerts, cagemat); recursive = 0; } } @@ -392,7 +394,7 @@ static void meshdeformModifier_do( meshdeform_vert_task, &settings); - /* release cage derivedmesh */ + /* release cage mesh */ MEM_freeN(dco); MEM_freeN(cagecos); if (cagemesh != NULL && free_cagemesh) { diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c index abd84799457..a6c9f865e4c 100644 --- a/source/blender/modifiers/intern/MOD_meshsequencecache.c +++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c @@ -26,12 +26,12 @@ #include "DNA_cachefile_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "BKE_cachefile.h" -#include "BKE_cdderivedmesh.h" #include "BKE_library.h" #include "BKE_library_query.h" #include "BKE_scene.h" @@ -79,7 +79,7 @@ static void freeData(ModifierData *md) } } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *) md; @@ -98,7 +98,7 @@ static Mesh *applyModifier( Mesh *me = (ctx->object->type == OB_MESH) ? ctx->object->data : NULL; Mesh *org_mesh = mesh; - Scene *scene = md->scene; /* for FPS macro */ + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); const float frame = DEG_get_ctime(ctx->depsgraph); const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS); const char *err_str = NULL; diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index a23511ff87a..aa9bc0dbc20 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -46,6 +46,8 @@ #include "BKE_modifier.h" #include "BKE_subsurf.h" +#include "DEG_depsgraph_query.h" + #include "MOD_modifiertypes.h" static void initData(ModifierData *md) @@ -63,6 +65,7 @@ static DerivedMesh *applyModifier( DerivedMesh *dm) { MultiresModifierData *mmd = (MultiresModifierData *)md; + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); DerivedMesh *result; Mesh *me = (Mesh *)ctx->object->data; const bool useRenderParams = (ctx->flag & MOD_APPLY_RENDER) != 0; @@ -86,7 +89,7 @@ static DerivedMesh *applyModifier( if (ignore_simplify) flags |= MULTIRES_IGNORE_SIMPLIFY; - result = multires_make_derived_from_derived(dm, mmd, ctx->object, flags); + result = multires_make_derived_from_derived(dm, mmd, scene, ctx->object, flags); if (result == dm) return dm; diff --git a/source/blender/modifiers/intern/MOD_none.c b/source/blender/modifiers/intern/MOD_none.c index b22b1768515..c973bd18830 100644 --- a/source/blender/modifiers/intern/MOD_none.c +++ b/source/blender/modifiers/intern/MOD_none.c @@ -43,7 +43,7 @@ * no other functions will be called */ -static bool isDisabled(ModifierData *UNUSED(md), int UNUSED(userRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *UNUSED(md), int UNUSED(userRenderParams)) { return true; } diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c index 935d99e4a21..b9d5bc7703e 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.c +++ b/source/blender/modifiers/intern/MOD_normal_edit.c @@ -37,7 +37,6 @@ #include "BLI_utildefines.h" #include "BLI_bitmap.h" -#include "BKE_cdderivedmesh.h" #include "BKE_library.h" #include "BKE_library_query.h" #include "BKE_mesh.h" @@ -525,7 +524,7 @@ static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, walk(userData, ob, &enmd->target, IDWALK_CB_NOP); } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { NormalEditModifierData *enmd = (NormalEditModifierData *)md; diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index af5b537ca52..702e557ccb1 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -46,6 +46,8 @@ #include "BKE_modifier.h" #include "BKE_ocean.h" +#include "DEG_depsgraph_query.h" + #include "MOD_modifiertypes.h" #ifdef WITH_OCEANSIM @@ -406,7 +408,7 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) } static DerivedMesh *doOcean( - ModifierData *md, Object *ob, + ModifierData *md, Scene *scene, Object *ob, DerivedMesh *derivedData, int UNUSED(useRenderParams)) { @@ -450,7 +452,7 @@ static DerivedMesh *doOcean( if (!omd->oceancache) { init_cache_data(ob, omd); } - BKE_ocean_simulate_cache(omd->oceancache, md->scene->r.cfra); + BKE_ocean_simulate_cache(omd->oceancache, scene->r.cfra); } else { simulate_ocean_modifier(omd); @@ -464,7 +466,7 @@ static DerivedMesh *doOcean( dm = CDDM_copy(derivedData); } - cfra = md->scene->r.cfra; + cfra = scene->r.cfra; CLAMP(cfra, omd->bakestart, omd->bakeend); cfra -= omd->bakestart; /* shift to 0 based */ @@ -547,12 +549,11 @@ static DerivedMesh *doOcean( } #else /* WITH_OCEANSIM */ static DerivedMesh *doOcean( - ModifierData *md, Object *UNUSED(ob), + ModifierData *UNUSED(md), Scene *UNUSED(scene), Object *UNUSED(ob), DerivedMesh *derivedData, int UNUSED(useRenderParams)) { /* unused */ - (void)md; return derivedData; } #endif /* WITH_OCEANSIM */ @@ -562,8 +563,10 @@ static DerivedMesh *applyModifier( DerivedMesh *derivedData) { DerivedMesh *result; + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); + - result = doOcean(md, ctx->object, derivedData, 0); + result = doOcean(md, scene, ctx->object, derivedData, 0); if (result != derivedData) result->dirty |= DM_DIRTY_NORMALS; diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c index 0aafcf33202..bb6ed8e8344 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.c +++ b/source/blender/modifiers/intern/MOD_particleinstance.c @@ -54,6 +54,7 @@ #include "BKE_pointcache.h" #include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" static void initData(ModifierData *md) { @@ -87,7 +88,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) } -static bool isDisabled(ModifierData *md, int useRenderParams) +static bool isDisabled(const struct Scene *scene, ModifierData *md, int useRenderParams) { ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md; ParticleSystem *psys; @@ -112,7 +113,7 @@ static bool isDisabled(ModifierData *md, int useRenderParams) if (useRenderParams) required_mode = eModifierMode_Render; else required_mode = eModifierMode_Realtime; - if (!modifier_isEnabled(md->scene, ob_md, required_mode)) + if (!modifier_isEnabled(scene, ob_md, required_mode)) return true; break; @@ -202,6 +203,7 @@ static Mesh *applyModifier( { Mesh *result; ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md; + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); ParticleSimulationData sim; ParticleSystem *psys = NULL; ParticleData *pa = NULL; @@ -247,7 +249,7 @@ static Mesh *applyModifier( return mesh; sim.depsgraph = ctx->depsgraph; - sim.scene = md->scene; + sim.scene = scene; sim.ob = pimd->ob; sim.psys = psys; sim.psmd = psys_get_modifier(pimd->ob, psys); diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index cbdeeebaa04..784e44f5758 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -48,8 +48,9 @@ #include "BKE_modifier.h" #include "BKE_particle.h" -#include "MOD_util.h" +#include "DEG_depsgraph_query.h" +#include "MOD_util.h" static void initData(ModifierData *md) { @@ -210,8 +211,9 @@ static void deformVerts( } if (!(ctx->object->transflag & OB_NO_PSYS_UPDATE)) { + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); psmd->flag &= ~eParticleSystemFlag_psys_updated; - particle_system_update(ctx->depsgraph, md->scene, ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0); + particle_system_update(ctx->depsgraph, scene, ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0); psmd->flag |= eParticleSystemFlag_psys_updated; } } diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c index 90c339361b7..a6c7419da49 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.c +++ b/source/blender/modifiers/intern/MOD_shapekey.c @@ -34,11 +34,11 @@ #include "BLI_math.h" +#include "DNA_mesh_types.h" #include "DNA_key_types.h" #include "BLI_utildefines.h" -#include "BKE_cdderivedmesh.h" #include "BKE_key.h" #include "BKE_particle.h" @@ -46,7 +46,7 @@ static void deformVerts( ModifierData *UNUSED(md), const ModifierEvalContext *ctx, - DerivedMesh *UNUSED(derivedData), + Mesh *UNUSED(mesh), float (*vertexCos)[3], int numVerts) { @@ -62,7 +62,7 @@ static void deformVerts( } static void deformMatrices( - ModifierData *md, const ModifierEvalContext *ctx, DerivedMesh *derivedData, + ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) { Key *key = BKE_key_from_object(ctx->object); @@ -81,26 +81,26 @@ static void deformMatrices( copy_m3_m3(defMats[a], scale); } - deformVerts(md, ctx, derivedData, vertexCos, numVerts); + deformVerts(md, ctx, mesh, vertexCos, numVerts); } static void deformVertsEM( ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData, + Mesh *mesh, float (*vertexCos)[3], int numVerts) { Key *key = BKE_key_from_object(ctx->object); if (key && key->type == KEY_RELATIVE) - deformVerts(md, ctx, derivedData, vertexCos, numVerts); + deformVerts(md, ctx, mesh, vertexCos, numVerts); } static void deformMatricesEM( ModifierData *UNUSED(md), const ModifierEvalContext *ctx, struct BMEditMesh *UNUSED(editData), - DerivedMesh *UNUSED(derivedData), + Mesh *UNUSED(mesh), float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) @@ -132,17 +132,17 @@ ModifierTypeInfo modifierType_ShapeKey = { /* copyData */ NULL, - /* deformVerts_DM */ deformVerts, - /* deformMatrices_DM */ deformMatrices, - /* deformVertsEM_DM */ deformVertsEM, - /* deformMatricesEM_DM*/deformMatricesEM, + /* deformVerts_DM */ NULL, + /* deformMatrices_DM */ NULL, + /* deformVertsEM_DM */ NULL, + /* deformMatricesEM_DM*/NULL, /* applyModifier_DM */ NULL, /* applyModifierEM_DM */NULL, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, + /* deformVerts */ deformVerts, + /* deformMatrices */ deformMatrices, + /* deformVertsEM */ deformVertsEM, + /* deformMatricesEM */ deformMatricesEM, /* applyModifier */ NULL, /* applyModifierEM */ NULL, diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c index da31de911e4..72c1c1552c7 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.c +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c @@ -48,6 +48,8 @@ #include "BKE_modifier.h" #include "BKE_shrinkwrap.h" +#include "DEG_depsgraph_query.h" + #include "MOD_util.h" static bool dependsOnNormals(ModifierData *md); @@ -82,7 +84,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *) md; return !smd->target; @@ -103,6 +105,7 @@ static void deformVerts( float (*vertexCos)[3], int numVerts) { + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); Mesh *mesh_src = mesh; if (mesh_src == NULL) { @@ -111,7 +114,7 @@ static void deformVerts( BLI_assert(mesh_src->totvert == numVerts); - shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts); + shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, scene, ctx->object, mesh_src, vertexCos, numVerts); } static void deformVertsEM( @@ -119,6 +122,7 @@ static void deformVertsEM( struct BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], int numVerts) { + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); Mesh *mesh_src = mesh; if (mesh_src == NULL) { @@ -127,7 +131,7 @@ static void deformVertsEM( BLI_assert(mesh_src->totvert == numVerts); - shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts); + shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, scene, ctx->object, mesh_src, vertexCos, numVerts); if (!mesh) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index 3f62351bceb..22fe0bacf87 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -39,7 +39,6 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#include "BKE_cdderivedmesh.h" #include "BKE_editmesh.h" #include "BKE_mesh.h" #include "BKE_library.h" diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 323994e6738..31d556292f8 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -864,7 +864,7 @@ static Mesh *subdivide_base(Mesh *orig) MEM_freeN(degree); - /* Allocate output derivedmesh */ + /* Allocate output mesh */ result = BKE_mesh_new_nomain_from_template( orig, totorigvert + totsubd, diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index 4c10df71f92..e81c760ed67 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -55,6 +55,8 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_physics.h" +#include "DEG_depsgraph_query.h" #include "MOD_modifiertypes.h" @@ -108,10 +110,12 @@ static DerivedMesh *applyModifier( { SmokeModifierData *smd = (SmokeModifierData *) md; - if (ctx->flag & MOD_APPLY_ORCO) + if (ctx->flag & MOD_APPLY_ORCO) { return dm; + } - return smokeModifier_do(smd, ctx->depsgraph, md->scene, ctx->object, dm); + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); + return smokeModifier_do(smd, ctx->depsgraph, scene, ctx->object, dm); } static bool dependsOnTime(ModifierData *UNUSED(md)) @@ -136,11 +140,9 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte SmokeModifierData *smd = (SmokeModifierData *)md; if (smd && (smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { - /* Actual code uses get_collisionobjects */ - DEG_add_collision_relations(ctx->node, ctx->scene, ctx->object, smd->domain->fluid_group, eModifierType_Smoke, is_flow_cb, true, "Smoke Flow"); - DEG_add_collision_relations(ctx->node, ctx->scene, ctx->object, smd->domain->coll_group, eModifierType_Smoke, is_coll_cb, true, "Smoke Coll"); - - DEG_add_forcefield_relations(ctx->node, ctx->scene, ctx->object, smd->domain->effector_weights, true, PFIELD_SMOKEFLOW, "Smoke Force Field"); + DEG_add_collision_relations(ctx->node, ctx->object, smd->domain->fluid_group, eModifierType_Smoke, is_flow_cb, "Smoke Flow"); + DEG_add_collision_relations(ctx->node, ctx->object, smd->domain->coll_group, eModifierType_Smoke, is_coll_cb, "Smoke Coll"); + DEG_add_forcefield_relations(ctx->node, ctx->object, smd->domain->effector_weights, true, PFIELD_SMOKEFLOW, "Smoke Force Field"); } } diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index e44ead73ced..2d5084abac3 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -61,7 +61,7 @@ static void initData(ModifierData *md) smd->defgrp_name[0] = '\0'; } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { SmoothModifierData *smd = (SmoothModifierData *) md; short flag; diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c index 30f9829ae20..55df32b0e18 100644 --- a/source/blender/modifiers/intern/MOD_softbody.c +++ b/source/blender/modifiers/intern/MOD_softbody.c @@ -46,17 +46,19 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_physics.h" #include "DEG_depsgraph_query.h" #include "MOD_modifiertypes.h" static void deformVerts( - ModifierData *md, const ModifierEvalContext *ctx, + ModifierData *UNUSED(md), const ModifierEvalContext *ctx, Mesh *UNUSED(derivedData), float (*vertexCos)[3], int numVerts) { - sbObjectStep(ctx->depsgraph, md->scene, ctx->object, DEG_get_ctime(ctx->depsgraph), vertexCos, numVerts); + Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); + sbObjectStep(ctx->depsgraph, scene, ctx->object, DEG_get_ctime(ctx->depsgraph), vertexCos, numVerts); } static bool dependsOnTime(ModifierData *UNUSED(md)) @@ -68,9 +70,8 @@ static void updateDepsgraph(ModifierData *UNUSED(md), const ModifierUpdateDepsgr { if (ctx->object->soft) { /* Actual code uses ccd_build_deflector_hash */ - DEG_add_collision_relations(ctx->node, ctx->scene, ctx->object, ctx->object->soft->collision_group, eModifierType_Collision, NULL, false, "Softbody Collision"); - - DEG_add_forcefield_relations(ctx->node, ctx->scene, ctx->object, ctx->object->soft->effector_weights, true, 0, "Softbody Field"); + DEG_add_collision_relations(ctx->node, ctx->object, ctx->object->soft->collision_group, eModifierType_Collision, NULL, "Softbody Collision"); + DEG_add_forcefield_relations(ctx->node, ctx->object, ctx->object->soft->effector_weights, true, 0, "Softbody Field"); } } diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index b99b35bbb8e..180c25dcd84 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -40,7 +40,6 @@ #include "BLI_bitmap.h" #include "BLI_math.h" -#include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_particle.h" #include "BKE_deform.h" diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index c4eb99840fb..63c6f16449d 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -91,12 +91,12 @@ static void freeData(ModifierData *md) } } -static bool isDisabled(ModifierData *md, int useRenderParams) +static bool isDisabled(const Scene *scene, ModifierData *md, int useRenderParams) { SubsurfModifierData *smd = (SubsurfModifierData *) md; int levels = (useRenderParams) ? smd->renderLevels : smd->levels; - return get_render_subsurf_level(&md->scene->r, levels, useRenderParams != 0) == 0; + return get_render_subsurf_level(&scene->r, levels, useRenderParams != 0) == 0; } static DerivedMesh *applyModifier( @@ -104,6 +104,7 @@ static DerivedMesh *applyModifier( DerivedMesh *derivedData) { SubsurfModifierData *smd = (SubsurfModifierData *) md; + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); SubsurfFlags subsurf_flags = 0; DerivedMesh *result; const bool useRenderParams = (ctx->flag & MOD_APPLY_RENDER) != 0; @@ -146,7 +147,7 @@ static DerivedMesh *applyModifier( } #endif - result = subsurf_make_derived_from_derived(derivedData, smd, NULL, subsurf_flags); + result = subsurf_make_derived_from_derived(derivedData, smd, scene, NULL, subsurf_flags); result->cd_flag = derivedData->cd_flag; { @@ -168,6 +169,7 @@ static DerivedMesh *applyModifierEM( DerivedMesh *derivedData) { SubsurfModifierData *smd = (SubsurfModifierData *) md; + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); DerivedMesh *result; /* 'orco' using editmode flags would cause cache to be used twice in editbmesh_calc_modifiers */ SubsurfFlags ss_flags = (ctx->flag & MOD_APPLY_ORCO) ? 0 : (SUBSURF_FOR_EDIT_MODE | SUBSURF_IN_EDIT_MODE); @@ -178,7 +180,7 @@ static DerivedMesh *applyModifierEM( } #endif - result = subsurf_make_derived_from_derived(derivedData, smd, NULL, ss_flags); + result = subsurf_make_derived_from_derived(derivedData, smd, scene, NULL, ss_flags); return result; } diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index e964da0a8d1..a3ab2d74602 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -1195,7 +1195,7 @@ static void deformVertsEM( surfacedeformModifier_do(md, ctx, vertexCos, numVerts, ctx->object); } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c index c650ae995db..2b2d1709b15 100644 --- a/source/blender/modifiers/intern/MOD_uvwarp.c +++ b/source/blender/modifiers/intern/MOD_uvwarp.c @@ -27,6 +27,7 @@ #include <string.h> +#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" @@ -35,7 +36,6 @@ #include "BLI_utildefines.h" #include "BKE_action.h" /* BKE_pose_channel_find_name */ -#include "BKE_cdderivedmesh.h" #include "BKE_deform.h" #include "BKE_library_query.h" #include "BKE_modifier.h" @@ -138,9 +138,9 @@ static void uv_warp_compute( } } -static DerivedMesh *applyModifier( +static Mesh *applyModifier( ModifierData *md, const ModifierEvalContext *ctx, - DerivedMesh *dm) + Mesh *mesh) { UVWarpModifierData *umd = (UVWarpModifierData *) md; int numPolys, numLoops; @@ -158,12 +158,12 @@ static DerivedMesh *applyModifier( const int axis_v = umd->axis_v; /* make sure there are UV Maps available */ - if (!CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) { - return dm; + if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPUV)) { + return mesh; } else if (ELEM(NULL, umd->object_src, umd->object_dst)) { modifier_setError(md, "From/To objects must be set"); - return dm; + return mesh; } /* make sure anything moving UVs is available */ @@ -189,16 +189,16 @@ static DerivedMesh *applyModifier( } /* make sure we're using an existing layer */ - CustomData_validate_layer_name(&dm->loopData, CD_MLOOPUV, umd->uvlayer_name, uvname); + CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, umd->uvlayer_name, uvname); - numPolys = dm->getNumPolys(dm); - numLoops = dm->getNumLoops(dm); + numPolys = mesh->totpoly; + numLoops = mesh->totloop; - mpoly = dm->getPolyArray(dm); - mloop = dm->getLoopArray(dm); + mpoly = mesh->mpoly; + mloop = mesh->mloop; /* make sure we are not modifying the original UV map */ - mloopuv = CustomData_duplicate_referenced_layer_named(&dm->loopData, CD_MLOOPUV, uvname, numLoops); - modifier_get_vgroup(ctx->object, dm, umd->vgroup_name, &dvert, &defgrp_index); + mloopuv = CustomData_duplicate_referenced_layer_named(&mesh->ldata, CD_MLOOPUV, uvname, numLoops); + modifier_get_vgroup_mesh(ctx->object, mesh, umd->vgroup_name, &dvert, &defgrp_index); UVWarpData data = {.mpoly = mpoly, .mloop = mloop, .mloopuv = mloopuv, .dvert = dvert, .defgrp_index = defgrp_index, @@ -211,9 +211,10 @@ static DerivedMesh *applyModifier( uv_warp_compute, &settings); - dm->dirty |= DM_DIRTY_TESS_CDLAYERS; + /* XXX TODO is this still needed? */ +// me_eval->dirty |= DM_DIRTY_TESS_CDLAYERS; - return dm; + return mesh; } static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, void *userData) @@ -260,14 +261,14 @@ ModifierTypeInfo modifierType_UVWarp = { /* deformMatrices_DM */ NULL, /* deformVertsEM_DM */ NULL, /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ applyModifier, + /* applyModifier_DM */ NULL, /* applyModifierEM_DM */NULL, /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, /* deformMatricesEM */ NULL, - /* applyModifier */ NULL, + /* applyModifier */ applyModifier, /* applyModifierEM */ NULL, /* initData */ initData, diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 4df71d91e3e..a6781cccb50 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -46,6 +46,7 @@ #include "BKE_colortools.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "RE_shader_ext.h" @@ -108,7 +109,7 @@ static void freeData(ModifierData *md) } -static bool isDisabled(ModifierData *md, int UNUSED(userRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(userRenderParams)) { WarpModifierData *wmd = (WarpModifierData *) md; @@ -271,9 +272,10 @@ static void warpModifier_do( fac *= weight; if (tex_co) { + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); TexResult texres; texres.nor = NULL; - BKE_texture_get_value(wmd->modifier.scene, wmd->texture, tex_co[i], &texres, false); + BKE_texture_get_value(scene, wmd->texture, tex_co[i], &texres, false); fac *= texres.tin; } diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index 552746634c5..c1b85336774 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -265,9 +265,10 @@ static void waveModifier_do( /*apply texture*/ if (wmd->texture) { + Scene *scene = DEG_get_evaluated_scene(depsgraph); TexResult texres; texres.nor = NULL; - BKE_texture_get_value(wmd->modifier.scene, wmd->texture, tex_co[i], &texres, false); + BKE_texture_get_value(scene, wmd->texture, tex_co[i], &texres, false); amplit *= texres.tin; } diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.h index f69659e46a3..93594fd8b29 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.h +++ b/source/blender/modifiers/intern/MOD_weightvg_util.h @@ -44,7 +44,7 @@ struct RNG; /* * XXX I'd like to make modified weights visible in WeightPaint mode, * but couldn't figure a way to do this... - * Maybe this will need changes in mesh_calc_modifiers (DerivedMesh.c)? + * Maybe this will need changes in mesh_calc_modifiers? * Or the WeightPaint mode code itself? */ diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index 00bc8a05cee..a26cb73d823 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -47,6 +47,7 @@ #include "BKE_texture.h" /* Texture masking. */ #include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" #include "MEM_guardedalloc.h" @@ -147,7 +148,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; /* If no vertex group, bypass. */ @@ -247,8 +248,9 @@ static Mesh *applyModifier( } /* Do masking. */ + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); weightvg_do_mask(ctx, numVerts, NULL, org_w, new_w, ctx->object, result, wmd->mask_constant, - wmd->mask_defgrp_name, wmd->modifier.scene, wmd->mask_texture, + wmd->mask_defgrp_name, scene, wmd->mask_texture, wmd->mask_tex_use_channel, wmd->mask_tex_mapping, wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name); diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index 2b0f90008cf..90bd5acff62 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -45,13 +45,13 @@ #include "BKE_texture.h" /* Texture masking. */ #include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" #include "MEM_guardedalloc.h" #include "MOD_weightvg_util.h" #include "MOD_modifiertypes.h" - /** * This mixes the old weight with the new weight factor. */ @@ -185,7 +185,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; /* If no vertex group, bypass. */ @@ -359,8 +359,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes } /* Do masking. */ + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); weightvg_do_mask(ctx, numIdx, indices, org_w, new_w, ctx->object, result, wmd->mask_constant, - wmd->mask_defgrp_name, wmd->modifier.scene, wmd->mask_texture, + wmd->mask_defgrp_name, scene, wmd->mask_texture, wmd->mask_tex_use_channel, wmd->mask_tex_mapping, wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name); diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 1a69ae13120..88e33f28eaf 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -40,7 +40,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_types.h" -#include "BKE_cdderivedmesh.h" +#include "BKE_bvhutils.h" #include "BKE_curve.h" #include "BKE_customdata.h" #include "BKE_deform.h" @@ -51,6 +51,7 @@ #include "BKE_texture.h" /* Texture masking. */ #include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" #include "MEM_guardedalloc.h" @@ -357,7 +358,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } } -static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) +static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams)) { WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; /* If no vertex group, bypass. */ @@ -542,8 +543,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes do_map(ob, new_w, numIdx, wmd->min_dist, wmd->max_dist, wmd->falloff_type); /* Do masking. */ + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); weightvg_do_mask(ctx, numIdx, indices, org_w, new_w, ob, result, wmd->mask_constant, - wmd->mask_defgrp_name, wmd->modifier.scene, wmd->mask_texture, + wmd->mask_defgrp_name, scene, wmd->mask_texture, wmd->mask_tex_use_channel, wmd->mask_tex_mapping, wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name); diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c index 9dfc23fbf5f..cc846d08040 100644 --- a/source/blender/modifiers/intern/MOD_wireframe.c +++ b/source/blender/modifiers/intern/MOD_wireframe.c @@ -28,7 +28,6 @@ #include "BLI_utildefines.h" -#include "BKE_cdderivedmesh.h" #include "BKE_deform.h" #include "BKE_mesh.h" diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 43beb1656a2..4f796da58dc 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -280,7 +280,10 @@ void ntreeCompositTagRender(Scene *curscene) { Scene *sce; - for (sce = G.main->scene.first; sce; sce = sce->id.next) { + /* XXX Think using G_MAIN here is valid, since you want to update current file's scene nodes, + * not the ones in temp main generated for rendering? + * This is still rather weak though, ideally render struct would store own main AND original G_MAIN... */ + for (sce = G_MAIN->scene.first; sce; sce = sce->id.next) { if (sce->nodetree) { bNode *node; diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c index 3708a7663ed..09c06e00382 100644 --- a/source/blender/nodes/intern/node_exec.c +++ b/source/blender/nodes/intern/node_exec.c @@ -163,6 +163,8 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNo /* XXX texnodes have threading issues with muting, have to disable it there ... */ /* ensure all sock->link pointers and node levels are correct */ + /* Using global main here is likely totally wrong, not sure what to do about that one though... + * We cannot even check ntree is in global main, since most of the time it won't be (thanks to ntree design)!!! */ ntreeUpdateTree(G.main, ntree); /* get a dependency-sorted list of nodes */ diff --git a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c index eae35b4cd22..0ccfb64a37d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c +++ b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c @@ -30,14 +30,14 @@ /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_ambient_occlusion_in[] = { - { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Distance"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { -1, 0, "" } }; static bNodeSocketTemplate sh_node_ambient_occlusion_out[] = { - { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("AO"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/physics/BPH_mass_spring.h b/source/blender/physics/BPH_mass_spring.h index e89aec1456e..f1eb049dd52 100644 --- a/source/blender/physics/BPH_mass_spring.h +++ b/source/blender/physics/BPH_mass_spring.h @@ -40,6 +40,7 @@ struct Implicit_Data; struct Object; struct ClothModifierData; struct ListBase; +struct Depsgraph; struct VoxelData; typedef enum eMassSpringSolverStatus { @@ -55,7 +56,7 @@ int BPH_mass_spring_solver_numvert(struct Implicit_Data *id); int BPH_cloth_solver_init(struct Object *ob, struct ClothModifierData *clmd); void BPH_cloth_solver_free(struct ClothModifierData *clmd); -int BPH_cloth_solve(struct Object *ob, float frame, struct ClothModifierData *clmd, struct ListBase *effectors); +int BPH_cloth_solve(struct Depsgraph *depsgraph, struct Object *ob, float frame, struct ClothModifierData *clmd, struct ListBase *effectors); void BKE_cloth_solver_set_positions(struct ClothModifierData *clmd); #ifdef __cplusplus diff --git a/source/blender/physics/CMakeLists.txt b/source/blender/physics/CMakeLists.txt index 0a4ff3fe0f0..b8663a384a7 100644 --- a/source/blender/physics/CMakeLists.txt +++ b/source/blender/physics/CMakeLists.txt @@ -28,6 +28,7 @@ set(INC intern ../blenlib ../blenkernel + ../depsgraph ../imbuf ../makesdna ../../../intern/guardedalloc diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp index c8932045c52..2f24231f992 100644 --- a/source/blender/physics/intern/BPH_mass_spring.cpp +++ b/source/blender/physics/intern/BPH_mass_spring.cpp @@ -51,6 +51,9 @@ extern "C" { #include "BPH_mass_spring.h" #include "implicit.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" + static float I3[3][3] = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}; /* Number of off-diagonal non-zero matrix blocks. @@ -433,7 +436,7 @@ static void hair_get_boundbox(ClothModifierData *clmd, float gmin[3], float gmax } } -static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListBase *effectors, float time) +static void cloth_calc_force(Scene *scene, ClothModifierData *clmd, float UNUSED(frame), ListBase *effectors, float time) { /* Collect forces and derivatives: F, dFdX, dFdV */ Cloth *cloth = clmd->clothObject; @@ -447,9 +450,9 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB #ifdef CLOTH_FORCE_GRAVITY /* global acceleration (gravitation) */ - if (clmd->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { + if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { /* scale gravity force */ - mul_v3_v3fl(gravity, clmd->scene->physics_settings.gravity, 0.001f * clmd->sim_parms->effector_weights->global_gravity); + mul_v3_v3fl(gravity, scene->physics_settings.gravity, 0.001f * clmd->sim_parms->effector_weights->global_gravity); } vert = cloth->verts; @@ -487,8 +490,8 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB EffectedPoint epoint; BPH_mass_spring_get_motion_state(data, i, x, v); - pd_point_from_loc(clmd->scene, x, v, i, &epoint); - pdDoEffectors(effectors, NULL, clmd->sim_parms->effector_weights, &epoint, winvec[i], NULL); + pd_point_from_loc(scene, x, v, i, &epoint); + BKE_effectors_apply(effectors, NULL, clmd->sim_parms->effector_weights, &epoint, winvec[i], NULL); } for (i = 0; i < cloth->tri_num; i++) { @@ -847,7 +850,9 @@ static void cloth_calc_volume_force(ClothModifierData *clmd) /* old collision stuff for cloth, use for continuity * until a good replacement is ready */ -static void cloth_collision_solve_extra(Object *ob, ClothModifierData *clmd, ListBase *effectors, float frame, float step, float dt) +static void cloth_collision_solve_extra( + Depsgraph *depsgraph, Scene *scene, Object *ob, ClothModifierData *clmd, ListBase *effectors, + float frame, float step, float dt) { Cloth *cloth = clmd->clothObject; Implicit_Data *id = cloth->implicit; @@ -879,7 +884,8 @@ static void cloth_collision_solve_extra(Object *ob, ClothModifierData *clmd, Lis // call collision function // TODO: check if "step" or "step+dt" is correct - dg - do_extra_solve = cloth_bvh_objcollision(ob, clmd, step / clmd->sim_parms->timescale, dt / clmd->sim_parms->timescale); + do_extra_solve = cloth_bvh_objcollision( + depsgraph, ob, clmd, step / clmd->sim_parms->timescale, dt / clmd->sim_parms->timescale); // copy corrected positions back to simulation for (i = 0; i < mvert_num; i++) { @@ -915,7 +921,7 @@ static void cloth_collision_solve_extra(Object *ob, ClothModifierData *clmd, Lis BPH_mass_spring_clear_forces(id); // calculate forces - cloth_calc_force(clmd, frame, effectors, step); + cloth_calc_force(scene, clmd, frame, effectors, step); // calculate new velocity and position BPH_mass_spring_solve_velocities(id, dt, &result); @@ -967,12 +973,13 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r sres->status |= result->status; } -int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors) +int BPH_cloth_solve(Depsgraph *depsgraph, Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors) { /* Hair currently is a cloth sim in disguise ... * Collision detection and volumetrics work differently then. * Bad design, TODO */ + Scene *scene = DEG_get_evaluated_scene(depsgraph); const bool is_hair = (clmd->hairdata != NULL); unsigned int i=0; @@ -1017,7 +1024,7 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase * if (is_hair) { /* determine contact points */ if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) { - cloth_find_point_contacts(ob, clmd, 0.0f, tf, &contacts, &totcolliders); + cloth_find_point_contacts(depsgraph, ob, clmd, 0.0f, tf, &contacts, &totcolliders); } /* setup vertex constraints for pinned vertices and contacts */ @@ -1043,7 +1050,7 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase * } // calculate forces - cloth_calc_force(clmd, frame, effectors, step); + cloth_calc_force(scene, clmd, frame, effectors, step); // calculate new velocity and position BPH_mass_spring_solve_velocities(id, dt, &result); @@ -1056,7 +1063,7 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase * BPH_mass_spring_solve_positions(id, dt); if (!is_hair) { - cloth_collision_solve_extra(ob, clmd, effectors, frame, step, dt); + cloth_collision_solve_extra(depsgraph, scene, ob, clmd, effectors, frame, step, dt); } BPH_mass_spring_apply_result(id); diff --git a/source/blender/physics/intern/hair_volume.cpp b/source/blender/physics/intern/hair_volume.cpp index b59ac46abbc..d2d43882a2d 100644 --- a/source/blender/physics/intern/hair_volume.cpp +++ b/source/blender/physics/intern/hair_volume.cpp @@ -1054,7 +1054,7 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd, } /* gather colliders */ - colliders = get_collider_cache(clmd->scene, NULL, NULL); + colliders = BKE_collider_cache_create(depsgraph, NULL, NULL); if (colliders && collfac > 0.0f) { for (col = colliders->first; col; col = col->next) { MVert *loc0 = col->collmd->x; @@ -1087,7 +1087,7 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd, } } } - free_collider_cache(&colliders); + BKE_collider_cache_free(&colliders); /* divide velocity with density */ for (i = 0; i < size; i++) { diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index d32b8696c9c..394adb1dd3b 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -37,6 +37,7 @@ #include "BKE_customdata.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" +#include "BKE_library.h" #include "DEG_depsgraph.h" @@ -903,8 +904,9 @@ static PyObject *bpy_bmesh_to_mesh(BPy_BMesh *self, PyObject *args) bm = self->bm; + BLI_assert(BKE_id_is_in_gobal_main(&me->id)); BM_mesh_bm_to_me( - G.main, /* XXX UGLY! */ + G_MAIN, /* XXX UGLY! */ bm, me, (&(struct BMeshToMeshParams){ .calc_object_remap = true, diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c index 2305d448e04..d0f708b7e3c 100644 --- a/source/blender/python/generic/blf_py_api.c +++ b/source/blender/python/generic/blf_py_api.c @@ -114,6 +114,40 @@ static PyObject *py_blf_aspect(PyObject *UNUSED(self), PyObject *args) } +PyDoc_STRVAR(py_blf_color_doc, +".. function:: color(fontid, level, r, g, b, a)\n" +"\n" +" Set the color for drawing text.\n" +"\n" +" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default font use 0.\n" +" :type fontid: int\n" +" :arg r: red channel 0.0 - 1.0.\n" +" :type r: float\n" +" :arg g: green channel 0.0 - 1.0.\n" +" :type g: float\n" +" :arg b: blue channel 0.0 - 1.0.\n" +" :type b: float\n" +" :arg a: alpha channel 0.0 - 1.0.\n" +" :type a: float\n" +); +static PyObject *py_blf_color(PyObject *UNUSED(self), PyObject *args) +{ + int fontid; + float rgba[4]; + + if (!PyArg_ParseTuple( + args, "iffff:blf.color", + &fontid, &rgba[0], &rgba[1], &rgba[2], &rgba[3])) + { + return NULL; + } + + BLF_color4fv(fontid, rgba); + + Py_RETURN_NONE; +} + + #if BLF_BLUR_ENABLE PyDoc_STRVAR(py_blf_blur_doc, ".. function:: blur(fontid, radius)\n" @@ -434,6 +468,7 @@ static PyMethodDef BLF_methods[] = { {"shadow", (PyCFunction) py_blf_shadow, METH_VARARGS, py_blf_shadow_doc}, {"shadow_offset", (PyCFunction) py_blf_shadow_offset, METH_VARARGS, py_blf_shadow_offset_doc}, {"size", (PyCFunction) py_blf_size, METH_VARARGS, py_blf_size_doc}, + {"color", (PyCFunction) py_blf_color, METH_VARARGS, py_blf_color_doc}, {"load", (PyCFunction) py_blf_load, METH_VARARGS, py_blf_load_doc}, {"unload", (PyCFunction) py_blf_unload, METH_VARARGS, py_blf_unload_doc}, {NULL, NULL, 0, NULL} diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index 0211e7bd880..c1e5f947110 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -175,7 +175,7 @@ PyObject *bpy_text_import_name(const char *name, int *found) Text *text; char txtname[MAX_ID_NAME - 2]; int namelen = strlen(name); -//XXX Main *maggie = bpy_import_main ? bpy_import_main:G.main; +//XXX Main *maggie = bpy_import_main ? bpy_import_main : G_MAIN; Main *maggie = bpy_import_main; *found = 0; @@ -224,7 +224,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found) Text *text; const char *name; const char *filepath; -//XXX Main *maggie = bpy_import_main ? bpy_import_main:G.main; +//XXX Main *maggie = bpy_import_main ? bpy_import_main : G_MAIN; Main *maggie = bpy_import_main; if (!maggie) { diff --git a/source/blender/python/generic/imbuf_py_api.c b/source/blender/python/generic/imbuf_py_api.c index 2e32829bf6c..dfe4007e404 100644 --- a/source/blender/python/generic/imbuf_py_api.c +++ b/source/blender/python/generic/imbuf_py_api.c @@ -45,6 +45,8 @@ #include <errno.h> #include "BLI_fileops.h" +static PyObject *Py_ImBuf_CreatePyObject(ImBuf *ibuf); + /* -------------------------------------------------------------------- */ /** \name Type & Utilities * \{ */ @@ -109,6 +111,27 @@ static PyObject *py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw) Py_RETURN_NONE; } +PyDoc_STRVAR(py_imbuf_copy_doc, +".. method:: copy()\n" +"\n" +" :return: A copy of the image.\n" +" :rtype: :class:`ImBuf`\n" +); +static PyObject *py_imbuf_copy(Py_ImBuf *self) +{ + PY_IMBUF_CHECK_OBJ(self); + return Py_ImBuf_CreatePyObject(self->ibuf); +} + +static PyObject *py_imbuf_deepcopy(Py_ImBuf *self, PyObject *args) +{ + if (!PyC_CheckArgs_DeepCopy(args)) { + return NULL; + } + return py_imbuf_copy(self); +} + + PyDoc_STRVAR(py_imbuf_free_doc, ".. method:: free()\n" "\n" @@ -126,6 +149,9 @@ static PyObject *py_imbuf_free(Py_ImBuf *self) static struct PyMethodDef Py_ImBuf_methods[] = { {"resize", (PyCFunction)py_imbuf_resize, METH_VARARGS | METH_KEYWORDS, (char *)py_imbuf_resize_doc}, {"free", (PyCFunction)py_imbuf_free, METH_NOARGS, (char *)py_imbuf_free_doc}, + {"copy", (PyCFunction)py_imbuf_copy, METH_NOARGS, (char *)py_imbuf_copy_doc}, + {"__copy__", (PyCFunction)py_imbuf_copy, METH_NOARGS, (char *)py_imbuf_copy_doc}, + {"__deepcopy__", (PyCFunction)py_imbuf_deepcopy, METH_VARARGS, (char *)py_imbuf_copy_doc}, {NULL, NULL, 0, NULL} }; diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 22646462163..cee9ad3b477 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -230,6 +230,12 @@ int PyC_ParseBool(PyObject *o, void *p) return 1; } +/* silly function, we dont use arg. just check its compatible with __deepcopy__ */ +int PyC_CheckArgs_DeepCopy(PyObject *args) +{ + PyObject *dummy_pydict; + return PyArg_ParseTuple(args, "|O!:__deepcopy__", &PyDict_Type, &dummy_pydict) != 0; +} #ifndef MATH_STANDALONE diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h index 9f3c10bfd67..fef9171b4d4 100644 --- a/source/blender/python/generic/py_capi_utils.h +++ b/source/blender/python/generic/py_capi_utils.h @@ -106,6 +106,7 @@ bool PyC_RunString_AsString(const char *expr, const char *filename, char **r_val int PyC_ParseBool(PyObject *o, void *p); +int PyC_CheckArgs_DeepCopy(PyObject *args); /* Integer parsing (with overflow checks), -1 on error. */ int PyC_Long_AsBool(PyObject *value); diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index a0461ed945d..751625e378b 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -34,7 +34,7 @@ #include "BLI_string.h" #include "BKE_appdir.h" -#include "BKE_global.h" /* XXX, G.main only */ +#include "BKE_global.h" /* XXX, G_MAIN only */ #include "BKE_blender_version.h" #include "BKE_bpath.h" @@ -138,7 +138,7 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec list = PyList_New(0); - BKE_bpath_traverse_main(G.main, bpy_blend_paths_visit_cb, flag, (void *)list); + BKE_bpath_traverse_main(G_MAIN, bpy_blend_paths_visit_cb, flag, (void *)list); return list; } diff --git a/source/blender/python/intern/bpy_library_write.c b/source/blender/python/intern/bpy_library_write.c index ead10efb212..76b7ccf72fa 100644 --- a/source/blender/python/intern/bpy_library_write.c +++ b/source/blender/python/intern/bpy_library_write.c @@ -95,7 +95,7 @@ static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject return NULL; } - Main *bmain_src = G.main; + Main *bmain_src = G_MAIN; int write_flags = 0; if (use_relative_remap) { diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index aa808118613..be0e9771a0a 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -7090,7 +7090,7 @@ PyObject *BPY_rna_module(void) PointerRNA ptr; /* for now, return the base RNA type rather than a real module */ - RNA_main_pointer_create(G.main, &ptr); + RNA_main_pointer_create(G_MAIN, &ptr); pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr); rna_module_ptr = &pyrna->ptr; @@ -7101,9 +7101,9 @@ void BPY_update_rna_module(void) { if (rna_module_ptr) { #if 0 - RNA_main_pointer_create(G.main, rna_module_ptr); + RNA_main_pointer_create(G_MAIN, rna_module_ptr); #else - rna_module_ptr->data = G.main; /* just set data is enough */ + rna_module_ptr->data = G_MAIN; /* just set data is enough */ #endif } } diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index 7903f92265b..7012e04628c 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -45,6 +45,7 @@ #include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_idcode.h" +#include "BKE_library.h" #include "BKE_report.h" #include "RNA_access.h" @@ -267,13 +268,15 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb return PyBool_FromLong(result); } else { + ID *id = self->ptr.id.data; struct Depsgraph *depsgraph = CTX_data_depsgraph(BPy_GetContext()); ReportList reports; short result; BKE_reports_init(&reports, RPT_STORE); - result = insert_keyframe(G.main, depsgraph, &reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, keytype, options); + BLI_assert(BKE_id_is_in_gobal_main(id)); + result = insert_keyframe(G_MAIN, depsgraph, &reports, id, NULL, group_name, path_full, index, cfra, keytype, options); MEM_freeN((void *)path_full); if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c index ee40d30d73b..4806c2266ba 100644 --- a/source/blender/python/intern/bpy_rna_id_collection.c +++ b/source/blender/python/intern/bpy_rna_id_collection.c @@ -160,7 +160,7 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject * BPy_StructRNA *pyrna = (BPy_StructRNA *)self; Main *bmain = pyrna->ptr.data; #else - Main *bmain = G.main; /* XXX Ugly, but should work! */ + Main *bmain = G_MAIN; /* XXX Ugly, but should work! */ #endif PyObject *subset = NULL; @@ -230,7 +230,6 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject * lb_index = set_listbasepointers(bmain, lb_array); while (lb_index--) { - if (val_types_bitmap && lb_array[lb_index]->first) { if (!id_check_type(lb_array[lb_index]->first, val_types_bitmap)) { continue; diff --git a/source/blender/python/intern/gpu_offscreen.c b/source/blender/python/intern/gpu_offscreen.c index a65469ea739..f0bc4b79296 100644 --- a/source/blender/python/intern/gpu_offscreen.c +++ b/source/blender/python/intern/gpu_offscreen.c @@ -36,6 +36,7 @@ #include "WM_types.h" #include "BKE_global.h" +#include "BKE_library.h" #include "ED_screen.h" @@ -195,6 +196,8 @@ static PyObject *pygpu_offscreen_draw_view3d(BPy_GPUOffScreen *self, PyObject *a return NULL; } + BLI_assert(BKE_id_is_in_gobal_main(&scene->id)); + fx = GPU_fx_compositor_create(); fx_settings = v3d->fx_settings; /* full copy */ diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 96ae0a9e50f..0c365ad192c 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -419,13 +419,6 @@ PyObject *mathutils_dynstr_to_py(struct DynStr *ds) } #endif -/* silly function, we dont use arg. just check its compatible with __deepcopy__ */ -int mathutils_deepcopy_args_check(PyObject *args) -{ - PyObject *dummy_pydict; - return PyArg_ParseTuple(args, "|O!:__deepcopy__", &PyDict_Type, &dummy_pydict) != 0; -} - /* Mathutils Callbacks */ /* for mathutils internal use only, eventually should re-alloc but to start with we only have a few users */ diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h index 01d2350d7fd..31ad75b3906 100644 --- a/source/blender/python/mathutils/mathutils.h +++ b/source/blender/python/mathutils/mathutils.h @@ -174,6 +174,4 @@ int column_vector_multiplication(float rvec[4], VectorObject *vec, MatrixObject PyObject *mathutils_dynstr_to_py(struct DynStr *ds); #endif -int mathutils_deepcopy_args_check(PyObject *args); - #endif /* __MATHUTILS_H__ */ diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 9997cd9c1f5..4c1163a6181 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -33,6 +33,7 @@ #include "BLI_utildefines.h" #include "../generic/python_utildefines.h" +#include "../generic/py_capi_utils.h" #ifndef MATH_STANDALONE # include "BLI_dynstr.h" @@ -113,8 +114,9 @@ static PyObject *Color_copy(ColorObject *self) } static PyObject *Color_deepcopy(ColorObject *self, PyObject *args) { - if (!mathutils_deepcopy_args_check(args)) + if (!PyC_CheckArgs_DeepCopy(args)) { return NULL; + } return Color_copy(self); } diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 026384743bd..8be3de42226 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -32,6 +32,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" #include "../generic/python_utildefines.h" +#include "../generic/py_capi_utils.h" #ifndef MATH_STANDALONE # include "BLI_dynstr.h" @@ -312,8 +313,9 @@ static PyObject *Euler_copy(EulerObject *self) } static PyObject *Euler_deepcopy(EulerObject *self, PyObject *args) { - if (!mathutils_deepcopy_args_check(args)) + if (!PyC_CheckArgs_DeepCopy(args)) { return NULL; + } return Euler_copy(self); } diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index cc6a5367895..70c400f99b8 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -33,6 +33,7 @@ #include "BLI_utildefines.h" #include "../generic/python_utildefines.h" +#include "../generic/py_capi_utils.h" #ifndef MATH_STANDALONE # include "BLI_string.h" @@ -1945,8 +1946,9 @@ static PyObject *Matrix_copy(MatrixObject *self) } static PyObject *Matrix_deepcopy(MatrixObject *self, PyObject *args) { - if (!mathutils_deepcopy_args_check(args)) + if (!PyC_CheckArgs_DeepCopy(args)) { return NULL; + } return Matrix_copy(self); } diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index d283c717a46..1a6fd0ee86f 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -33,6 +33,7 @@ #include "BLI_utildefines.h" #include "../generic/python_utildefines.h" +#include "../generic/py_capi_utils.h" #ifndef MATH_STANDALONE # include "BLI_dynstr.h" @@ -496,8 +497,9 @@ static PyObject *Quaternion_copy(QuaternionObject *self) } static PyObject *Quaternion_deepcopy(QuaternionObject *self, PyObject *args) { - if (!mathutils_deepcopy_args_check(args)) + if (!PyC_CheckArgs_DeepCopy(args)) { return NULL; + } return Quaternion_copy(self); } @@ -1393,4 +1395,3 @@ PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user, return (PyObject *)self; } - diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 65450505e08..a06a63c8067 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -1331,8 +1331,9 @@ static PyObject *Vector_copy(VectorObject *self) } static PyObject *Vector_deepcopy(VectorObject *self, PyObject *args) { - if (!mathutils_deepcopy_args_check(args)) + if (!PyC_CheckArgs_DeepCopy(args)) { return NULL; + } return Vector_copy(self); } diff --git a/source/blender/render/extern/include/RE_multires_bake.h b/source/blender/render/extern/include/RE_multires_bake.h index 25a87969b58..983e95639b4 100644 --- a/source/blender/render/extern/include/RE_multires_bake.h +++ b/source/blender/render/extern/include/RE_multires_bake.h @@ -34,8 +34,10 @@ #define __RE_MULTIRES_BAKE_H__ struct MultiresBakeRender; +struct Scene; typedef struct MultiresBakeRender { + Scene *scene; DerivedMesh *lores_dm, *hires_dm; bool simple; int bake_filter; /* Bake-filter, aka margin */ diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index bde3c1c8cb3..a51e7af9d9d 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -312,10 +312,8 @@ void RE_draw_lock_cb (struct Render *re, void *handle, void (*f)(void *handle, void RE_test_break_cb (struct Render *re, void *handle, int (*f)(void *handle)); void RE_current_scene_update_cb(struct Render *re, void *handle, void (*f)(void *handle, struct Scene *scene)); -/* TODO replace by a simple set and get draw manager. */ void RE_gl_context_create(Render *re); void RE_gl_context_destroy(Render *re); -void RE_gl_context_set(Render *re, void *gl_context); void *RE_gl_context_get(Render *re); void *RE_gwn_context_get(Render *re); diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 134fa56f01c..34535fba1e0 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -161,7 +161,6 @@ struct Render { /* TODO replace by a whole draw manager. */ void *gl_context; void *gwn_context; - bool gl_context_ownership; }; /* **************** defines ********************* */ diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c index d506028e306..0cb9fd7324b 100644 --- a/source/blender/render/intern/source/multires_bake.c +++ b/source/blender/render/intern/source/multires_bake.c @@ -688,7 +688,7 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) if (bkr->simple) smd.subdivType = ME_SIMPLE_SUBSURF; - height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, NULL, 0); + height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, bkr->scene, NULL, 0); init_ccgdm_arrays(height_data->ssdm); } } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 14ef7a3cb94..361324bf07c 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1030,13 +1030,10 @@ void RE_test_break_cb(Render *re, void *handle, int (*f)(void *handle)) /* ********* GL Context ******** */ -/* Create the gl context of the Render. - * It will be free by the render itself. */ void RE_gl_context_create(Render *re) { /* Needs to be created in the main ogl thread. */ re->gl_context = WM_opengl_context_create(); - re->gl_context_ownership = true; } void RE_gl_context_destroy(Render *re) @@ -1048,22 +1045,11 @@ void RE_gl_context_destroy(Render *re) re->gwn_context = NULL; } if (re->gl_context) { - if (re->gl_context_ownership) { - WM_opengl_context_dispose(re->gl_context); - } + WM_opengl_context_dispose(re->gl_context); re->gl_context = NULL; } } -/* Manually set the gl context of the Render. - * It won't be free by the render itself. */ -void RE_gl_context_set(Render *re, void *gl_context) -{ - BLI_assert(gl_context); /* Cannot set NULL */ - re->gl_context = gl_context; - re->gl_context_ownership = false; -} - void *RE_gl_context_get(Render *re) { return re->gl_context; @@ -2646,9 +2632,6 @@ void RE_PreviewRender(Render *re, Main *bmain, Scene *sce) RE_SetCamera(re, camera); do_render_3d(re); - - /* Destroy the opengl context in the correct thread. */ - RE_gl_context_destroy(re); } /* note; repeated win/disprect calc... solve that nicer, also in compo */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index a2142b2d569..ace9acf0e8a 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -96,7 +96,7 @@ void WM_main (struct bContext *C) ATTR_NORETURN; void WM_init_splash (struct bContext *C); -void WM_init_opengl (void); +void WM_init_opengl (struct Main *bmain); void WM_check (struct bContext *C); @@ -602,6 +602,9 @@ bool WM_event_is_tablet(const struct wmEvent *event); bool WM_event_is_ime_switch(const struct wmEvent *event); #endif +const char *WM_window_cursor_keymap_status_get(const struct wmWindow *win, int button_index, int type_index); +void WM_window_cursor_keymap_status_refresh(struct bContext *C, struct wmWindow *win); + /* wm_tooltip.c */ typedef struct ARegion *(*wmTooltipInitFn)(struct bContext *, struct ARegion *, bool *); @@ -618,4 +621,3 @@ void WM_tooltip_refresh(struct bContext *C, struct wmWindow *win); #endif #endif /* __WM_API_H__ */ - diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 5efe9330f52..a7500a55bda 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -782,6 +782,7 @@ void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *UNUSED(ar)) void wm_draw_update(bContext *C) { + Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win; @@ -789,7 +790,7 @@ void wm_draw_update(bContext *C) BKE_subsurf_free_unused_buffers(); #endif - GPU_free_unused_buffers(); + GPU_free_unused_buffers(bmain); for (win = wm->windows.first; win; win = win->next) { #ifdef WIN32 diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index e700a17b1ca..55e8970c77e 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -499,6 +499,14 @@ void wm_event_do_notifiers(bContext *C) } wm_event_do_refresh_wm_and_depsgraph(C); + + /* Status bar */ + if (wm->winactive) { + win = wm->winactive; + CTX_wm_window_set(C, win); + WM_window_cursor_keymap_status_refresh(C, win); + CTX_wm_window_set(C, NULL); + } } static int wm_event_always_pass(const wmEvent *event) @@ -521,7 +529,7 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, const wmEven /* UI code doesn't handle return values - it just always returns break. * to make the DBL_CLICK conversion work, we just don't send this to UI, except mouse clicks */ if (((handler->flag & WM_HANDLER_ACCEPT_DBL_CLICK) == 0) && - (event->type != LEFTMOUSE) && + !ISMOUSE_BUTTON(event->type) && (event->val == KM_DBL_CLICK)) { return WM_HANDLER_CONTINUE; @@ -2622,6 +2630,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) } } else if (event->val == KM_DBL_CLICK) { + /* The underlying event is a press, so try and handle this. */ event->val = KM_PRESS; action |= wm_handlers_do_intern(C, event, handlers); @@ -2772,6 +2781,40 @@ static bool wm_event_pie_filter(wmWindow *win, const wmEvent *event) } } +#ifdef USE_WORKSPACE_TOOL +static void wm_event_manipulator_temp_handler_apply( + bContext *C, ScrArea *sa, ARegion *ar, wmEventHandler *sneaky_handler) +{ + if (ar->regiontype == RGN_TYPE_WINDOW) { + bToolRef_Runtime *tref_rt = sa->runtime.tool ? sa->runtime.tool->runtime : NULL; + if (tref_rt && tref_rt->keymap[0]) { + wmKeyMap *km = WM_keymap_find_all( + C, tref_rt->keymap, sa->spacetype, RGN_TYPE_WINDOW); + if (km != NULL) { + sneaky_handler->keymap = km; + sneaky_handler->keymap_tool = sa->runtime.tool; + + /* Handle widgets first. */ + wmEventHandler *handler_last = ar->handlers.last; + while (handler_last && handler_last->manipulator_map == NULL) { + handler_last = handler_last->prev; + } + /* Head of list or after last manipulator. */ + BLI_insertlinkafter(&ar->handlers, handler_last, sneaky_handler); + } + } + } +} + +static void wm_event_manipulator_temp_handler_clear( + bContext *UNUSED(C), ScrArea *UNUSED(sa), ARegion *ar, wmEventHandler *sneaky_handler) +{ + if (sneaky_handler->keymap) { + BLI_remlink(&ar->handlers, sneaky_handler); + } +} +#endif /* USE_WORKSPACE_TOOL */ + /* called in main loop */ /* goes over entire hierarchy: events -> window -> screen -> area -> region */ void wm_event_do_handlers(bContext *C) @@ -2956,33 +2999,13 @@ void wm_event_do_handlers(bContext *C) * to fetch its current keymap. */ wmEventHandler sneaky_handler = {NULL}; - if (ar->regiontype == RGN_TYPE_WINDOW) { - bToolRef_Runtime *tref_rt = sa->runtime.tool ? sa->runtime.tool->runtime : NULL; - if (tref_rt && tref_rt->keymap[0]) { - wmKeyMap *km = WM_keymap_find_all( - C, tref_rt->keymap, sa->spacetype, RGN_TYPE_WINDOW); - if (km != NULL) { - sneaky_handler.keymap = km; - sneaky_handler.keymap_tool = sa->runtime.tool; - - /* Handle widgets first. */ - wmEventHandler *handler_last = ar->handlers.last; - while (handler_last && handler_last->manipulator_map == NULL) { - handler_last = handler_last->prev; - } - /* Head of list or after last manipulator. */ - BLI_insertlinkafter(&ar->handlers, handler_last, &sneaky_handler); - } - } - } + wm_event_manipulator_temp_handler_apply(C, sa, ar, &sneaky_handler); #endif /* USE_WORKSPACE_TOOL */ action |= wm_handlers_do(C, event, &ar->handlers); #ifdef USE_WORKSPACE_TOOL - if (sneaky_handler.keymap) { - BLI_remlink(&ar->handlers, &sneaky_handler); - } + wm_event_manipulator_temp_handler_clear(C, sa, ar, &sneaky_handler); #endif /* USE_WORKSPACE_TOOL */ /* fileread case (python), [#29489] */ @@ -3946,7 +3969,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U /* if previous event was same type, and previous was release, and now it presses... */ if (wm_event_is_double_click(&event, evt)) { CLOG_INFO(WM_LOG_HANDLERS, 1, "Send double click"); - evt->val = event.val = KM_DBL_CLICK; + event.val = KM_DBL_CLICK; } /* this case happens on holding a key pressed, it should not generate @@ -4205,3 +4228,232 @@ bool WM_event_is_ime_switch(const struct wmEvent *event) #endif /** \} */ + + +static wmKeyMapItem *wm_kmi_from_event( + bContext *C, wmWindowManager *wm, + ListBase *handlers, const wmEvent *event) +{ + for (wmEventHandler *handler = handlers->first; handler; handler = handler->next) { + /* during this loop, ui handlers for nested menus can tag multiple handlers free */ + if (handler->flag & WM_HANDLER_DO_FREE) { + /* pass */ + } + else if (handler_boundbox_test(handler, event)) { /* optional boundbox */ + if (handler->keymap) { + wmKeyMap *keymap = WM_keymap_active(wm, handler->keymap); + if (WM_keymap_poll(C, keymap)) { + for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + if (wm_eventmatch(event, kmi)) { + wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); + if (WM_operator_poll_context(C, ot, WM_OP_INVOKE_DEFAULT)) { + return kmi; + } + } + } + } + } + } + } + return NULL; +} + +/* -------------------------------------------------------------------- */ +/** \name Cursor Keymap Status + * + * Show cursor keys in the status bar. + * This is done by detecting changes to the state - full keymap lookups are expensive + * so only perform this on changing tools, space types, pressing different modifier keys... etc. + * \{ */ + +/** State storage to detect changes between calls to refresh the information. */ +struct CursorKeymapInfo_State { + struct { + short shift, ctrl, alt, oskey; + } modifiers; + short space_type; + short region_type; + /* Never use, just compare memory for changes. */ + bToolRef tref; +}; + +struct CursorKeymapInfo { + /* 0: mouse button index + * 1: event type (click/press, drag) + * 2: text. + */ + char text[3][2][128]; + wmEvent state_event; + struct CursorKeymapInfo_State state; +}; + +static void wm_event_cursor_store( + struct CursorKeymapInfo_State *state, + const wmEvent *event, + short space_type, short region_type, + const bToolRef *tref) +{ + state->modifiers.shift = event->shift; + state->modifiers.ctrl = event->ctrl; + state->modifiers.alt = event->alt; + state->modifiers.oskey = event->oskey; + state->space_type = space_type; + state->region_type = region_type; + state->tref = tref ? *tref : (bToolRef){0}; +} + +const char *WM_window_cursor_keymap_status_get(const wmWindow *win, int button_index, int type_index) +{ + if (win->cursor_keymap_status != NULL) { + struct CursorKeymapInfo *cd = win->cursor_keymap_status; + const char *msg = cd->text[button_index][type_index]; + if (*msg) { + return msg; + } + } + return NULL; +} + +void WM_window_cursor_keymap_status_refresh(bContext *C, struct wmWindow *win) +{ + bScreen *screen = WM_window_get_active_screen(win); + if (screen->state == SCREENFULL) { + return; + } + ScrArea *sa_statusbar = NULL; + for (ScrArea *sa = win->global_areas.areabase.first; sa; sa = sa->next) { + if (sa->spacetype == SPACE_STATUSBAR) { + sa_statusbar = sa; + break; + } + } + if (sa_statusbar == NULL) { + return; + } + + struct CursorKeymapInfo *cd; + if (UNLIKELY(win->cursor_keymap_status == NULL)) { + win->cursor_keymap_status = MEM_callocN(sizeof(struct CursorKeymapInfo), __func__); + } + cd = win->cursor_keymap_status; + + /* Detect unchanged state (early exit). */ + if (memcmp(&cd->state_event, win->eventstate, sizeof(wmEvent)) == 0) { + return; + } + + /* Now perform more comprehensive check, + * still keep this fast since it happens on mouse-move. */ + struct CursorKeymapInfo cd_prev = *((struct CursorKeymapInfo *)win->cursor_keymap_status); + cd->state_event = *win->eventstate; + + ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, win->eventstate->x, win->eventstate->y); + if (sa == NULL) { + return; + } + ARegion *ar = BKE_area_find_region_xy(sa, RGN_TYPE_ANY, win->eventstate->x, win->eventstate->y); + if (ar == NULL) { + return; + } + /* Keep as-is. */ + if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TEMPORARY, RGN_TYPE_HUD)) { + return; + } + /* Fallback to window. */ + if (ELEM(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) { + ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + } + + /* Detect changes to the state. */ + { + bToolRef *tref = NULL; + if (ar->regiontype == RGN_TYPE_WINDOW) { + Scene *scene = WM_window_get_active_scene(win); + WorkSpace *workspace = WM_window_get_active_workspace(win); + const bToolKey tkey = { + .space_type = sa->spacetype, + .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype), + }; + tref = WM_toolsystem_ref_find(workspace, &tkey); + } + wm_event_cursor_store(&cd->state, win->eventstate, sa->spacetype, ar->regiontype, tref); + if (memcmp(&cd->state, &cd_prev.state, sizeof(cd->state)) == 0) { + return; + } + } + + /* Changed context found, detect changes to keymap and refresh the status bar. */ + const struct { + int button_index; + int type_index; /* 0: press or click, 1: drag. */ + int event_type; + int event_value; + } event_data[] = { + {0, 0, LEFTMOUSE, KM_PRESS}, + {0, 0, LEFTMOUSE, KM_CLICK}, + {0, 1, EVT_TWEAK_L, KM_ANY}, + + {1, 0, MIDDLEMOUSE, KM_PRESS}, + {1, 0, MIDDLEMOUSE, KM_CLICK}, + {1, 1, EVT_TWEAK_M, KM_ANY}, + + {2, 0, RIGHTMOUSE, KM_PRESS}, + {2, 0, RIGHTMOUSE, KM_CLICK}, + {2, 1, EVT_TWEAK_R, KM_ANY}, + }; + + for (int button_index = 0; button_index < 3; button_index++) { + cd->text[button_index][0][0] = '\0'; + cd->text[button_index][1][0] = '\0'; + } + + CTX_wm_window_set(C, win); + CTX_wm_area_set(C, sa); + CTX_wm_region_set(C, ar); + +#ifdef USE_WORKSPACE_TOOL + wmEventHandler sneaky_handler = {NULL}; + wm_event_manipulator_temp_handler_apply(C, sa, ar, &sneaky_handler); +#endif + + ListBase *handlers[] = { + &ar->handlers, + &sa->handlers, + &win->handlers, + }; + + wmWindowManager *wm = CTX_wm_manager(C); + for (int data_index = 0; data_index < ARRAY_SIZE(event_data); data_index++) { + const int button_index = event_data[data_index].button_index; + const int type_index = event_data[data_index].type_index; + if (cd->text[button_index][type_index][0] != 0) { + continue; + } + wmEvent test_event = *win->eventstate; + test_event.type = event_data[data_index].event_type; + test_event.val = event_data[data_index].event_value; + wmKeyMapItem *kmi = NULL; + for (int handler_index = 0; handler_index < ARRAY_SIZE(handlers); handler_index++) { + kmi = wm_kmi_from_event(C, wm, handlers[handler_index], &test_event); + if (kmi) { + break; + } + } + if (kmi) { + wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); + STRNCPY(cd->text[button_index][type_index], ot ? ot->name : kmi->idname); + } + } + +#ifdef USE_WORKSPACE_TOOL + wm_event_manipulator_temp_handler_clear(C, sa, ar, &sneaky_handler); +#endif + + if (memcmp(&cd_prev.text, &cd->text, sizeof(cd_prev.text)) != 0) { + ED_area_tag_redraw(sa_statusbar); + } + + CTX_wm_window_set(C, NULL); +} + +/** \} */ diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index a14cbed6381..cae0bc06691 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -167,7 +167,7 @@ bool wm_start_with_console = false; /* used in creator.c */ **/ static bool opengl_is_init = false; -void WM_init_opengl(void) +void WM_init_opengl(Main *bmain) { /* must be called only once */ BLI_assert(opengl_is_init == false); @@ -181,10 +181,10 @@ void WM_init_opengl(void) DRW_opengl_context_create(); GPU_init(); - GPU_set_mipmap(true); + GPU_set_mipmap(bmain, true); GPU_set_linear_mipmap(true); - GPU_set_anisotropic(U.anisotropic_filter); - GPU_set_gpu_mipmapping(U.use_gpu_mipmap); + GPU_set_anisotropic(bmain, U.anisotropic_filter); + GPU_set_gpu_mipmapping(bmain, U.use_gpu_mipmap); GPU_pass_cache_init(); @@ -250,7 +250,7 @@ void WM_init(bContext *C, int argc, const char **argv) /* sets 3D mouse deadzone */ WM_ndof_deadzone_set(U.ndof_deadzone); #endif - WM_init_opengl(); + WM_init_opengl(G_MAIN); UI_init(); BKE_studiolight_init(); @@ -491,7 +491,7 @@ void WM_exit_ext(bContext *C, const bool do_python) BKE_subsurf_osd_cleanup(); #endif - GPU_free_unused_buffers(); + GPU_free_unused_buffers(G_MAIN); GPU_exit(); } diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index bbc7e6fbb69..bcb4fffea87 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -992,11 +992,7 @@ int WM_keymap_item_raw_to_string( alt == KM_ANY && oskey == KM_ANY) { - /* make it implicit in case of compact result expected. */ - if (!compact) { - ADD_SEP; - p += BLI_strcpy_rlen(p, IFACE_("Any")); - } + /* Don't show anything for any mapping. */ } else { if (shift) { diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 20c4d2700aa..d83d4b7320a 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3989,7 +3989,10 @@ void wm_window_keymap(wmKeyConfig *keyconf) /* menus that can be accessed anywhere in blender */ - WM_keymap_verify_item(keymap, "WM_OT_search_menu", ACCENTGRAVEKEY, KM_RELEASE, 0, 0); + WM_keymap_add_item(keymap, "WM_OT_search_menu", F3KEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "WM_OT_search_menu", ACCENTGRAVEKEY, KM_CLICK, 0, 0); + + WM_keymap_add_menu(keymap, "SCREEN_MT_user_menu", QKEY, KM_PRESS, 0, 0); #ifdef WITH_INPUT_NDOF WM_keymap_add_menu(keymap, "USERPREF_MT_ndof_settings", NDOF_BUTTON_MENU, KM_PRESS, 0, 0); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 076514cd73f..b03b156b78c 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -70,6 +70,7 @@ #include "wm_window.h" #include "wm_event_system.h" +#include "ED_anim_api.h" #include "ED_scene.h" #include "ED_screen.h" #include "ED_fileselect.h" @@ -228,6 +229,10 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win) if (win->eventstate) MEM_freeN(win->eventstate); + if (win->cursor_keymap_status) { + MEM_freeN(win->cursor_keymap_status); + } + wm_event_free_all(win); wm_ghostwindow_destroy(wm, win); @@ -953,30 +958,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i /* do additional setup for specific editor type */ if (type == WM_WINDOW_DRIVERS) { - /* Configure editor - mode, tabs, framing */ - SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; - sipo->mode = SIPO_MODE_DRIVERS; - - ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_UI); - if (ar_props) { - UI_panel_category_active_set(ar_props, "Drivers"); - - ar_props->flag &= ~RGN_FLAG_HIDDEN; - /* XXX: Adjust width of this too? */ - - ED_region_visibility_change_update(C, ar_props); - } - - ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if (ar_main) { - /* XXX: Ideally we recenter based on the range instead... */ - ar_main->v2d.tot.xmin = -2.0f; - ar_main->v2d.tot.ymin = -2.0f; - ar_main->v2d.tot.xmax = 2.0f; - ar_main->v2d.tot.ymax = 2.0f; - - ar_main->v2d.cur = ar_main->v2d.tot; - } + ED_drivers_editor_init(C, sa); } if (sa->spacetype == SPACE_IMAGE) @@ -2318,14 +2300,13 @@ void *WM_opengl_context_create(void) * So we should call this function only on the main thread. */ BLI_assert(BLI_thread_is_main()); - // BLI_assert(GPU_framebuffer_current_get() == 0); + BLI_assert(GPU_framebuffer_current_get() == 0); return GHOST_CreateOpenGLContext(g_system); } void WM_opengl_context_dispose(void *context) { - // BLI_assert(BLI_thread_is_main()); - // BLI_assert(GPU_framebuffer_current_get() == 0); + BLI_assert(GPU_framebuffer_current_get() == 0); GHOST_DisposeOpenGLContext(g_system, (GHOST_ContextHandle)context); } |