Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt16
-rw-r--r--build_files/build_environment/cmake/versions.cmake4
-rwxr-xr-xbuild_files/build_environment/install_deps.sh2
-rw-r--r--build_files/buildbot/slave_compile.py21
-rwxr-xr-xbuild_files/cmake/cmake_consistency_check.py40
-rw-r--r--build_files/cmake/cmake_consistency_check_config.py13
-rw-r--r--build_files/cmake/config/blender_full.cmake5
-rw-r--r--build_files/cmake/config/blender_lite.cmake1
-rw-r--r--build_files/cmake/config/blender_release.cmake7
-rw-r--r--build_files/cmake/macros.cmake3
-rw-r--r--build_files/cmake/platform/platform_apple.cmake2
-rw-r--r--build_files/cmake/platform/platform_unix.cmake3
-rw-r--r--build_files/cmake/platform/platform_win32.cmake2
-rw-r--r--doc/python_api/examples/bpy.app.timers.1.py10
-rw-r--r--doc/python_api/examples/bpy.app.timers.2.py11
-rw-r--r--doc/python_api/examples/bpy.app.timers.3.py17
-rw-r--r--doc/python_api/examples/bpy.app.timers.4.py12
-rw-r--r--doc/python_api/examples/bpy.app.timers.5.py25
-rw-r--r--doc/python_api/rst/info_api_reference.rst1
-rw-r--r--doc/python_api/rst/info_best_practice.rst5
-rw-r--r--doc/python_api/rst/info_gotcha.rst20
-rw-r--r--doc/python_api/rst/info_quickstart.rst25
-rw-r--r--doc/python_api/rst/info_tips_and_tricks.rst1
-rw-r--r--doc/python_api/sphinx_doc_gen.py3
-rw-r--r--extern/cuew/src/cuew.c6
-rw-r--r--intern/CMakeLists.txt1
-rw-r--r--intern/atomic/intern/atomic_ops_ext.h2
-rw-r--r--intern/atomic/intern/atomic_ops_utils.h14
-rw-r--r--intern/cycles/CMakeLists.txt11
-rw-r--r--intern/cycles/app/CMakeLists.txt2
-rw-r--r--intern/cycles/blender/addon/engine.py4
-rw-r--r--intern/cycles/blender/addon/properties.py8
-rw-r--r--intern/cycles/blender/addon/ui.py109
-rw-r--r--intern/cycles/blender/blender_mesh.cpp7
-rw-r--r--intern/cycles/blender/blender_object.cpp22
-rw-r--r--intern/cycles/blender/blender_session.cpp2
-rw-r--r--intern/cycles/blender/blender_shader.cpp4
-rw-r--r--intern/cycles/blender/blender_sync.cpp8
-rw-r--r--intern/cycles/device/device.cpp14
-rw-r--r--intern/cycles/device/device.h9
-rw-r--r--intern/cycles/device/device_cpu.cpp32
-rw-r--r--intern/cycles/device/device_cuda.cpp8
-rw-r--r--intern/cycles/device/device_denoising.cpp1
-rw-r--r--intern/cycles/device/device_denoising.h4
-rw-r--r--intern/cycles/device/device_intern.h10
-rw-r--r--intern/cycles/device/device_multi.cpp12
-rw-r--r--intern/cycles/device/device_network.cpp8
-rw-r--r--intern/cycles/device/device_opencl.cpp6
-rw-r--r--intern/cycles/device/opencl/opencl.h6
-rw-r--r--intern/cycles/device/opencl/opencl_base.cpp4
-rw-r--r--intern/cycles/device/opencl/opencl_mega.cpp8
-rw-r--r--intern/cycles/device/opencl/opencl_split.cpp10
-rw-r--r--intern/cycles/device/opencl/opencl_util.cpp2
-rw-r--r--intern/cycles/kernel/CMakeLists.txt29
-rw-r--r--intern/cycles/kernel/bvh/bvh.h10
-rw-r--r--intern/cycles/kernel/kernel_globals.h4
-rw-r--r--intern/cycles/kernel/kernel_passes.h3
-rw-r--r--intern/cycles/kernel/kernel_path.h14
-rw-r--r--intern/cycles/kernel/kernel_path_subsurface.h2
-rw-r--r--intern/cycles/kernel/kernel_path_surface.h4
-rw-r--r--intern/cycles/kernel/kernel_profiling.h40
-rw-r--r--intern/cycles/kernel/kernel_shader.h38
-rw-r--r--intern/cycles/kernel/kernels/cuda/kernel_config.h18
-rw-r--r--intern/cycles/kernel/shaders/node_brick_texture.osl6
-rw-r--r--intern/cycles/kernel/shaders/node_checker_texture.osl9
-rw-r--r--intern/cycles/kernel/shaders/node_environment_texture.osl3
-rw-r--r--intern/cycles/kernel/shaders/node_musgrave_texture.osl15
-rw-r--r--intern/cycles/kernel/shaders/node_noise_texture.osl7
-rw-r--r--intern/cycles/kernel/svm/svm_ao.h5
-rw-r--r--intern/cycles/kernel/svm/svm_bevel.h5
-rw-r--r--intern/cycles/render/object.cpp57
-rw-r--r--intern/cycles/render/object.h14
-rw-r--r--intern/cycles/render/session.cpp32
-rw-r--r--intern/cycles/render/session.h11
-rw-r--r--intern/cycles/render/stats.cpp192
-rw-r--r--intern/cycles/render/stats.h56
-rw-r--r--intern/cycles/test/CMakeLists.txt7
-rw-r--r--intern/cycles/test/render_graph_finalize_test.cpp3
-rw-r--r--intern/cycles/util/CMakeLists.txt2
-rw-r--r--intern/cycles/util/util_profiling.cpp178
-rw-r--r--intern/cycles/util/util_profiling.h175
-rw-r--r--intern/cycles/util/util_stats.h1
-rw-r--r--intern/ghost/intern/GHOST_Context.cpp9
-rw-r--r--intern/ghost/intern/GHOST_Context.h3
-rw-r--r--intern/ghost/intern/GHOST_ContextCGL.mm2
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.cpp5
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp14
-rw-r--r--intern/numaapi/AUTHORS1
-rw-r--r--intern/numaapi/CMakeLists.txt39
-rw-r--r--intern/numaapi/LICENSE19
-rw-r--r--intern/numaapi/README7
-rw-r--r--intern/numaapi/README.blender5
-rw-r--r--intern/numaapi/include/numaapi.h108
-rw-r--r--intern/numaapi/source/build_config.h379
-rw-r--r--intern/numaapi/source/numaapi.c36
-rw-r--r--intern/numaapi/source/numaapi_linux.c272
-rw-r--r--intern/numaapi/source/numaapi_stub.c87
-rw-r--r--intern/numaapi/source/numaapi_win32.c253
-rw-r--r--intern/opencolorio/ocio_impl.cc130
-rw-r--r--release/datafiles/icons/brush.uv_sculpt.grab.datbin0 -> 3176 bytes
-rw-r--r--release/datafiles/icons/brush.uv_sculpt.pinch.datbin0 -> 3968 bytes
-rw-r--r--release/datafiles/icons/brush.uv_sculpt.relax.datbin0 -> 2024 bytes
-rw-r--r--release/datafiles/icons/ops.gpencil.primitive_arc.datbin0 -> 584 bytes
-rw-r--r--release/datafiles/splash.pngbin155397 -> 169093 bytes
-rw-r--r--release/datafiles/splash_2x.pngbin400745 -> 481810 bytes
-rw-r--r--release/datafiles/studiolights/studio/outdoor.sl48
-rw-r--r--release/datafiles/studiolights/studio/soft.sl48
-rw-r--r--release/datafiles/studiolights/studio/studio.sl48
-rw-r--r--release/datafiles/studiolights/studio/warm.sl48
-rw-r--r--release/datafiles/userdef/userdef_default_theme.c15
m---------release/scripts/addons0
m---------release/scripts/addons_contrib0
-rw-r--r--release/scripts/freestyle/modules/parameter_editor.py12
-rw-r--r--release/scripts/modules/bl_app_template_utils.py5
-rw-r--r--release/scripts/modules/bl_keymap_utils/io.py2
-rw-r--r--release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py381
-rw-r--r--release/scripts/modules/bl_previews_utils/bl_previews_render.py10
-rw-r--r--release/scripts/modules/bpy/utils/__init__.py42
-rw-r--r--release/scripts/modules/bpy_extras/io_utils.py9
-rw-r--r--release/scripts/modules/bpy_extras/object_utils.py5
-rw-r--r--release/scripts/modules/bpy_types.py4
-rw-r--r--release/scripts/modules/rna_info.py4
-rw-r--r--release/scripts/modules/rna_xml.py2
-rw-r--r--release/scripts/presets/cloth/cotton.py8
-rw-r--r--release/scripts/presets/cloth/denim.py8
-rw-r--r--release/scripts/presets/cloth/leather.py8
-rw-r--r--release/scripts/presets/cloth/rubber.py8
-rw-r--r--release/scripts/presets/cloth/silk.py8
-rw-r--r--release/scripts/presets/interface_theme/blender_light.xml160
-rw-r--r--release/scripts/presets/keyconfig/blender.py34
-rw-r--r--release/scripts/presets/keyconfig/blender_27x.py15
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/blender_default.py634
-rw-r--r--release/scripts/startup/bl_app_templates_system/Sculpting/__init__.py35
-rw-r--r--release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py39
-rw-r--r--release/scripts/startup/bl_operators/clip.py2
-rw-r--r--release/scripts/startup/bl_operators/object.py13
-rw-r--r--release/scripts/startup/bl_operators/object_align.py3
-rw-r--r--release/scripts/startup/bl_operators/rigidbody.py2
-rw-r--r--release/scripts/startup/bl_operators/view3d.py91
-rw-r--r--release/scripts/startup/bl_operators/wm.py151
-rw-r--r--release/scripts/startup/bl_ui/properties_data_armature.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_bone.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_camera.py22
-rw-r--r--release/scripts/startup/bl_ui/properties_data_curve.py5
-rw-r--r--release/scripts/startup/bl_ui/properties_data_gpencil.py15
-rw-r--r--release/scripts/startup/bl_ui/properties_data_lattice.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_light.py10
-rw-r--r--release/scripts/startup/bl_ui/properties_data_mesh.py20
-rw-r--r--release/scripts/startup/bl_ui/properties_data_metaball.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py6
-rw-r--r--release/scripts/startup/bl_ui/properties_data_speaker.py10
-rw-r--r--release/scripts/startup/bl_ui/properties_freestyle.py10
-rw-r--r--release/scripts/startup/bl_ui/properties_grease_pencil_common.py114
-rw-r--r--release/scripts/startup/bl_ui/properties_material.py30
-rw-r--r--release/scripts/startup/bl_ui/properties_material_gpencil.py75
-rw-r--r--release/scripts/startup/bl_ui/properties_object.py46
-rw-r--r--release/scripts/startup/bl_ui/properties_output.py26
-rw-r--r--release/scripts/startup/bl_ui/properties_particle.py148
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_cloth.py24
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_common.py4
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py46
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_field.py20
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_rigidbody.py18
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py26
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_smoke.py32
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_softbody.py32
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py21
-rw-r--r--release/scripts/startup/bl_ui/properties_scene.py22
-rw-r--r--release/scripts/startup/bl_ui/properties_texture.py44
-rw-r--r--release/scripts/startup/bl_ui/properties_view_layer.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_world.py4
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py10
-rw-r--r--release/scripts/startup/bl_ui/space_dopesheet.py6
-rw-r--r--release/scripts/startup/bl_ui/space_graph.py6
-rw-r--r--release/scripts/startup/bl_ui/space_image.py3
-rw-r--r--release/scripts/startup/bl_ui/space_node.py43
-rw-r--r--release/scripts/startup/bl_ui/space_sequencer.py14
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_common.py25
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_toolbar.py461
-rw-r--r--release/scripts/startup/bl_ui/space_topbar.py26
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py123
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py257
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py6
-rw-r--r--release/scripts/templates_py/gizmo_operator.py4
-rw-r--r--release/scripts/templates_py/operator_modal_view3d_raycast.py2
-rw-r--r--release/scripts/templates_py/ui_tool_simple.py35
-rw-r--r--source/blender/alembic/intern/abc_customdata.cc69
-rw-r--r--source/blender/alembic/intern/alembic_capi.cc6
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h11
-rw-r--r--source/blender/blenkernel/BKE_appdir.h1
-rw-r--r--source/blender/blenkernel/BKE_armature.h28
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h4
-rw-r--r--source/blender/blenkernel/BKE_colortools.h39
-rw-r--r--source/blender/blenkernel/BKE_customdata.h4
-rw-r--r--source/blender/blenkernel/BKE_displist.h3
-rw-r--r--source/blender/blenkernel/BKE_effect.h7
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h6
-rw-r--r--source/blender/blenkernel/BKE_global.h2
-rw-r--r--source/blender/blenkernel/BKE_keyconfig.h2
-rw-r--r--source/blender/blenkernel/BKE_lattice.h5
-rw-r--r--source/blender/blenkernel/BKE_layer.h109
-rw-r--r--source/blender/blenkernel/BKE_library.h2
-rw-r--r--source/blender/blenkernel/BKE_mesh.h6
-rw-r--r--source/blender/blenkernel/BKE_mesh_runtime.h10
-rw-r--r--source/blender/blenkernel/BKE_modifier.h2
-rw-r--r--source/blender/blenkernel/BKE_node.h16
-rw-r--r--source/blender/blenkernel/BKE_object.h17
-rw-r--r--source/blender/blenkernel/BKE_scene.h2
-rw-r--r--source/blender/blenkernel/BKE_screen.h6
-rw-r--r--source/blender/blenkernel/BKE_sequencer.h2
-rw-r--r--source/blender/blenkernel/BKE_shrinkwrap.h7
-rw-r--r--source/blender/blenkernel/BKE_studiolight.h21
-rw-r--r--source/blender/blenkernel/BKE_subdiv_mesh.h2
-rw-r--r--source/blender/blenkernel/CMakeLists.txt7
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c116
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c8
-rw-r--r--source/blender/blenkernel/intern/appdir.c4
-rw-r--r--source/blender/blenkernel/intern/armature.c138
-rw-r--r--source/blender/blenkernel/intern/armature_update.c15
-rw-r--r--source/blender/blenkernel/intern/blender.c2
-rw-r--r--source/blender/blenkernel/intern/boolean.c381
-rw-r--r--source/blender/blenkernel/intern/bpath.c4
-rw-r--r--source/blender/blenkernel/intern/cloth.c3
-rw-r--r--source/blender/blenkernel/intern/collection.c4
-rw-r--r--source/blender/blenkernel/intern/colortools.c36
-rw-r--r--source/blender/blenkernel/intern/constraint.c43
-rw-r--r--source/blender/blenkernel/intern/crazyspace.c43
-rw-r--r--source/blender/blenkernel/intern/curve.c20
-rw-r--r--source/blender/blenkernel/intern/customdata.c98
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c14
-rw-r--r--source/blender/blenkernel/intern/deform.c4
-rw-r--r--source/blender/blenkernel/intern/displist.c9
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c2
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c4
-rw-r--r--source/blender/blenkernel/intern/effect.c8
-rw-r--r--source/blender/blenkernel/intern/fcurve.c20
-rw-r--r--source/blender/blenkernel/intern/font.c320
-rw-r--r--source/blender/blenkernel/intern/gpencil.c7
-rw-r--r--source/blender/blenkernel/intern/image.c39
-rw-r--r--source/blender/blenkernel/intern/ipo.c3
-rw-r--r--source/blender/blenkernel/intern/keyconfig.c14
-rw-r--r--source/blender/blenkernel/intern/lamp.c2
-rw-r--r--source/blender/blenkernel/intern/lattice.c26
-rw-r--r--source/blender/blenkernel/intern/layer.c116
-rw-r--r--source/blender/blenkernel/intern/layer_utils.c16
-rw-r--r--source/blender/blenkernel/intern/library.c20
-rw-r--r--source/blender/blenkernel/intern/library_query.c14
-rw-r--r--source/blender/blenkernel/intern/library_remap.c10
-rw-r--r--source/blender/blenkernel/intern/material.c12
-rw-r--r--source/blender/blenkernel/intern/mesh.c26
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c6
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.c5
-rw-r--r--source/blender/blenkernel/intern/mesh_tangent.c3
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c37
-rw-r--r--source/blender/blenkernel/intern/modifier.c12
-rw-r--r--source/blender/blenkernel/intern/multires_reshape.c5
-rw-r--r--source/blender/blenkernel/intern/multires_subdiv.c6
-rw-r--r--source/blender/blenkernel/intern/node.c22
-rw-r--r--source/blender/blenkernel/intern/object.c62
-rw-r--r--source/blender/blenkernel/intern/object_update.c46
-rw-r--r--source/blender/blenkernel/intern/paint.c16
-rw-r--r--source/blender/blenkernel/intern/particle.c23
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c6
-rw-r--r--source/blender/blenkernel/intern/particle_system.c20
-rw-r--r--source/blender/blenkernel/intern/pointcache.c5
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c4
-rw-r--r--source/blender/blenkernel/intern/scene.c18
-rw-r--r--source/blender/blenkernel/intern/screen.c42
-rw-r--r--source/blender/blenkernel/intern/sequencer.c3
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c68
-rw-r--r--source/blender/blenkernel/intern/smoke.c2
-rw-r--r--source/blender/blenkernel/intern/softbody.c2
-rw-r--r--source/blender/blenkernel/intern/studiolight.c304
-rw-r--r--source/blender/blenkernel/intern/subdiv_converter_mesh.c20
-rw-r--r--source/blender/blenkernel/intern/subdiv_mesh.c11
-rw-r--r--source/blender/blenkernel/intern/texture.c2
-rw-r--r--source/blender/blenkernel/intern/world.c2
-rw-r--r--source/blender/blenlib/BLI_callbacks.h1
-rw-r--r--source/blender/blenlib/BLI_math_color.h2
-rw-r--r--source/blender/blenlib/BLI_system.h16
-rw-r--r--source/blender/blenlib/BLI_task.h2
-rw-r--r--source/blender/blenlib/BLI_threads.h6
-rw-r--r--source/blender/blenlib/BLI_timer.h58
-rw-r--r--source/blender/blenlib/CMakeLists.txt3
-rw-r--r--source/blender/blenlib/intern/BLI_timer.c184
-rw-r--r--source/blender/blenlib/intern/system.c63
-rw-r--r--source/blender/blenlib/intern/task.c22
-rw-r--r--source/blender/blenlib/intern/threads.c102
-rw-r--r--source/blender/blenloader/intern/readblenentry.c22
-rw-r--r--source/blender/blenloader/intern/readfile.c962
-rw-r--r--source/blender/blenloader/intern/undofile.c2
-rw-r--r--source/blender/blenloader/intern/versioning_250.c383
-rw-r--r--source/blender/blenloader/intern/versioning_260.c85
-rw-r--r--source/blender/blenloader/intern/versioning_270.c44
-rw-r--r--source/blender/blenloader/intern/versioning_280.c126
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c44
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c193
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c51
-rw-r--r--source/blender/blenloader/intern/writefile.c34
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c41
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_opdefines.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_query.c34
-rw-r--r--source/blender/bmesh/intern/bmesh_query.h1
-rw-r--r--source/blender/bmesh/operators/bmo_bevel.c3
-rw-r--r--source/blender/bmesh/operators/bmo_dupe.c15
-rw-r--r--source/blender/collada/AnimationCurveCache.cpp391
-rw-r--r--source/blender/collada/AnimationCurveCache.h130
-rw-r--r--source/blender/collada/AnimationImporter.cpp4
-rw-r--r--source/blender/collada/ArmatureExporter.cpp2
-rw-r--r--source/blender/collada/ArmatureImporter.cpp6
-rw-r--r--source/blender/collada/BCAnimationCurve.cpp8
-rw-r--r--source/blender/collada/BCAnimationSampler.h2
-rw-r--r--source/blender/collada/BlenderContext.cpp20
-rw-r--r--source/blender/collada/BlenderContext.h2
-rw-r--r--source/blender/collada/CMakeLists.txt14
-rw-r--r--source/blender/collada/ControllerExporter.cpp10
-rw-r--r--source/blender/collada/DocumentImporter.cpp17
-rw-r--r--source/blender/collada/DocumentImporter.h7
-rw-r--r--source/blender/collada/EffectExporter.cpp4
-rw-r--r--source/blender/collada/GeometryExporter.cpp15
-rw-r--r--source/blender/collada/InstanceWriter.cpp9
-rw-r--r--source/blender/collada/SceneExporter.cpp11
-rw-r--r--source/blender/collada/SkinInfo.cpp2
-rw-r--r--source/blender/collada/TransformWriter.cpp25
-rw-r--r--source/blender/collada/TransformWriter.h15
-rw-r--r--source/blender/collada/collada_utils.cpp42
-rw-r--r--source/blender/collada/collada_utils.h4
-rw-r--r--source/blender/depsgraph/DEG_depsgraph.h41
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_build.h12
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_query.h4
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.cc12
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc31
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.h2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc50
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc49
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc9
-rw-r--r--source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph.cc13
-rw-r--r--source/blender/depsgraph/intern/depsgraph.h2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc39
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query.cc22
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_iter.cc1
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc100
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type_defines.cc8
-rw-r--r--source/blender/depsgraph/intern/depsgraph_types.h46
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.cc20
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc34
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_flush.cc4
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_component.cc19
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_component.h2
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_id.cc2
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_id.h4
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_operation.cc3
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_operation.h3
-rw-r--r--source/blender/draw/CMakeLists.txt4
-rw-r--r--source/blender/draw/engines/basic/basic_engine.c5
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_lookdev.c4
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c3
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_cache_utils.c8
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c9
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_utils.c127
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c127
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h22
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_shader_fx.c3
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl155
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl25
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl66
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_curvature_lib.glsl41
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl11
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_deferred_background_frag.glsl39
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl127
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl10
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl39
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl92
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl207
-rw-r--r--source/blender/draw/engines/workbench/workbench_data.c50
-rw-r--r--source/blender/draw/engines/workbench/workbench_deferred.c304
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_taa.c3
-rw-r--r--source/blender/draw/engines/workbench/workbench_engine.c6
-rw-r--r--source/blender/draw/engines/workbench/workbench_engine.h2
-rw-r--r--source/blender/draw/engines/workbench/workbench_forward.c81
-rw-r--r--source/blender/draw/engines/workbench/workbench_materials.c127
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h62
-rw-r--r--source/blender/draw/engines/workbench/workbench_studiolight.c43
-rw-r--r--source/blender/draw/intern/DRW_render.h6
-rw-r--r--source/blender/draw/intern/draw_armature.c6
-rw-r--r--source/blender/draw/intern/draw_cache.c88
-rw-r--r--source/blender/draw/intern/draw_cache.h32
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h23
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c59
-rw-r--r--source/blender/draw/intern/draw_cache_impl_displist.c86
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c459
-rw-r--r--source/blender/draw/intern/draw_cache_impl_metaball.c66
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c210
-rw-r--r--source/blender/draw/intern/draw_hair.c35
-rw-r--r--source/blender/draw/intern/draw_manager.c125
-rw-r--r--source/blender/draw/intern/draw_manager.h2
-rw-r--r--source/blender/draw/intern/draw_manager_data.c6
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c13
-rw-r--r--source/blender/draw/intern/draw_manager_shader.c7
-rw-r--r--source/blender/draw/intern/draw_manager_texture.c3
-rw-r--r--source/blender/draw/intern/draw_view.c3
-rw-r--r--source/blender/draw/modes/edit_curve_mode.c1
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c16
-rw-r--r--source/blender/draw/modes/edit_text_mode.c2
-rw-r--r--source/blender/draw/modes/object_mode.c55
-rw-r--r--source/blender/draw/modes/overlay_mode.c191
-rw-r--r--source/blender/draw/modes/paint_texture_mode.c18
-rw-r--r--source/blender/draw/modes/paint_weight_mode.c6
-rw-r--r--source/blender/draw/modes/particle_mode.c54
-rw-r--r--source/blender/draw/modes/pose_mode.c4
-rw-r--r--source/blender/draw/modes/shaders/common_fullscreen_vert.glsl2
-rw-r--r--source/blender/draw/modes/shaders/common_hair_lib.glsl5
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl16
-rw-r--r--source/blender/draw/modes/shaders/object_empty_image_vert.glsl1
-rw-r--r--source/blender/draw/modes/shaders/object_grid_vert.glsl4
-rw-r--r--source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl16
-rw-r--r--source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl111
-rw-r--r--source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl186
-rw-r--r--source/blender/draw/modes/shaders/paint_wire_frag.glsl3
-rw-r--r--source/blender/draw/modes/shaders/paint_wire_vert.glsl3
-rw-r--r--source/blender/draw/modes/shaders/particle_strand_frag.glsl23
-rw-r--r--source/blender/draw/modes/shaders/particle_strand_vert.glsl79
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c6
-rw-r--r--source/blender/editors/animation/anim_deps.c10
-rw-r--r--source/blender/editors/animation/anim_filter.c4
-rw-r--r--source/blender/editors/animation/anim_markers.c2
-rw-r--r--source/blender/editors/animation/drivers.c4
-rw-r--r--source/blender/editors/animation/keyframing.c40
-rw-r--r--source/blender/editors/animation/keyingsets.c4
-rw-r--r--source/blender/editors/armature/armature_add.c14
-rw-r--r--source/blender/editors/armature/armature_edit.c27
-rw-r--r--source/blender/editors/armature/armature_naming.c12
-rw-r--r--source/blender/editors/armature/armature_relations.c14
-rw-r--r--source/blender/editors/armature/armature_select.c45
-rw-r--r--source/blender/editors/armature/armature_skinning.c9
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c2644
-rw-r--r--source/blender/editors/armature/editarmature_undo.c4
-rw-r--r--source/blender/editors/armature/meshlaplacian.c6
-rw-r--r--source/blender/editors/armature/pose_edit.c40
-rw-r--r--source/blender/editors/armature/pose_group.c8
-rw-r--r--source/blender/editors/armature/pose_lib.c10
-rw-r--r--source/blender/editors/armature/pose_select.c30
-rw-r--r--source/blender/editors/armature/pose_slide.c4
-rw-r--r--source/blender/editors/armature/pose_transform.c19
-rw-r--r--source/blender/editors/armature/pose_utils.c9
-rw-r--r--source/blender/editors/curve/editcurve.c63
-rw-r--r--source/blender/editors/curve/editcurve_add.c11
-rw-r--r--source/blender/editors/curve/editcurve_paint.c4
-rw-r--r--source/blender/editors/curve/editcurve_select.c50
-rw-r--r--source/blender/editors/curve/editcurve_undo.c4
-rw-r--r--source/blender/editors/curve/editfont.c2
-rw-r--r--source/blender/editors/curve/editfont_undo.c2
-rw-r--r--source/blender/editors/datafiles/CMakeLists.txt4
-rw-r--r--source/blender/editors/gizmo_library/gizmo_library_intern.h10
-rw-r--r--source/blender/editors/gizmo_library/gizmo_library_utils.c4
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c9
-rw-r--r--source/blender/editors/gpencil/annotate_draw.c112
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c88
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c22
-rw-r--r--source/blender/editors/gpencil/gpencil_add_monkey.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_add_stroke.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_armature.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c44
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c106
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c71
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c26
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h10
-rw-r--r--source/blender/editors/gpencil/gpencil_interpolate.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c133
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c182
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c101
-rw-r--r--source/blender/editors/gpencil/gpencil_undo.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c48
-rw-r--r--source/blender/editors/include/ED_armature.h4
-rw-r--r--source/blender/editors/include/ED_gpencil.h17
-rw-r--r--source/blender/editors/include/ED_keyframing.h6
-rw-r--r--source/blender/editors/include/ED_mesh.h11
-rw-r--r--source/blender/editors/include/ED_object.h14
-rw-r--r--source/blender/editors/include/ED_transform.h2
-rw-r--r--source/blender/editors/include/ED_uvedit.h6
-rw-r--r--source/blender/editors/include/ED_view3d.h5
-rw-r--r--source/blender/editors/include/UI_interface.h5
-rw-r--r--source/blender/editors/interface/interface.c149
-rw-r--r--source/blender/editors/interface/interface_anim.c4
-rw-r--r--source/blender/editors/interface/interface_context_menu.c28
-rw-r--r--source/blender/editors/interface/interface_draw.c2
-rw-r--r--source/blender/editors/interface/interface_eyedropper_driver.c2
-rw-r--r--source/blender/editors/interface/interface_handlers.c2
-rw-r--r--source/blender/editors/interface/interface_icons.c6
-rw-r--r--source/blender/editors/interface/interface_layout.c15
-rw-r--r--source/blender/editors/interface/interface_panel.c6
-rw-r--r--source/blender/editors/interface/interface_region_hud.c38
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c6
-rw-r--r--source/blender/editors/interface/interface_templates.c8
-rw-r--r--source/blender/editors/interface/interface_widgets.c72
-rw-r--r--source/blender/editors/io/io_collada.c9
-rw-r--r--source/blender/editors/lattice/editlattice_select.c28
-rw-r--r--source/blender/editors/lattice/editlattice_tools.c13
-rw-r--r--source/blender/editors/lattice/editlattice_undo.c4
-rw-r--r--source/blender/editors/mask/mask_shapekey.c2
-rw-r--r--source/blender/editors/mesh/editface.c89
-rw-r--r--source/blender/editors/mesh/editmesh_add.c67
-rw-r--r--source/blender/editors/mesh/editmesh_add_gizmo.c3
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c2
-rw-r--r--source/blender/editors/mesh/editmesh_bisect.c7
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c16
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_screw.c5
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin.c4
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c3
-rw-r--r--source/blender/editors/mesh/editmesh_inset.c2
-rw-r--r--source/blender/editors/mesh/editmesh_intersect.c6
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c12
-rw-r--r--source/blender/editors/mesh/editmesh_knife_project.c11
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c6
-rw-r--r--source/blender/editors/mesh/editmesh_path.c4
-rw-r--r--source/blender/editors/mesh/editmesh_polybuild.c20
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c2
-rw-r--r--source/blender/editors/mesh/editmesh_rip_edge.c2
-rw-r--r--source/blender/editors/mesh/editmesh_select.c103
-rw-r--r--source/blender/editors/mesh/editmesh_select_similar.c7
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c156
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c4
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c4
-rw-r--r--source/blender/editors/mesh/meshtools.c22
-rw-r--r--source/blender/editors/metaball/editmball_undo.c4
-rw-r--r--source/blender/editors/metaball/mball_edit.c24
-rw-r--r--source/blender/editors/object/object_add.c194
-rw-r--r--source/blender/editors/object/object_bake_api.c16
-rw-r--r--source/blender/editors/object/object_collection.c18
-rw-r--r--source/blender/editors/object/object_constraint.c24
-rw-r--r--source/blender/editors/object/object_data_transfer.c38
-rw-r--r--source/blender/editors/object/object_edit.c54
-rw-r--r--source/blender/editors/object/object_facemap_ops.c14
-rw-r--r--source/blender/editors/object/object_gpencil_modifier.c18
-rw-r--r--source/blender/editors/object/object_hook.c12
-rw-r--r--source/blender/editors/object/object_modes.c17
-rw-r--r--source/blender/editors/object/object_modifier.c160
-rw-r--r--source/blender/editors/object/object_random.c2
-rw-r--r--source/blender/editors/object/object_relations.c56
-rw-r--r--source/blender/editors/object/object_select.c63
-rw-r--r--source/blender/editors/object/object_shader_fx.c12
-rw-r--r--source/blender/editors/object/object_shapekey.c12
-rw-r--r--source/blender/editors/object/object_transform.c26
-rw-r--r--source/blender/editors/object/object_vgroup.c56
-rw-r--r--source/blender/editors/object/object_warp.c8
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c4
-rw-r--r--source/blender/editors/physics/particle_boids.c12
-rw-r--r--source/blender/editors/physics/particle_edit.c43
-rw-r--r--source/blender/editors/physics/particle_edit_undo.c2
-rw-r--r--source/blender/editors/physics/particle_object.c28
-rw-r--r--source/blender/editors/physics/rigidbody_constraint.c8
-rw-r--r--source/blender/editors/physics/rigidbody_object.c10
-rw-r--r--source/blender/editors/physics/rigidbody_world.c4
-rw-r--r--source/blender/editors/render/render_shading.c175
-rw-r--r--source/blender/editors/screen/area.c56
-rw-r--r--source/blender/editors/screen/screen_context.c55
-rw-r--r--source/blender/editors/screen/screen_draw.c42
-rw-r--r--source/blender/editors/screen/screen_edit.c2
-rw-r--r--source/blender/editors/screen/screen_intern.h2
-rw-r--r--source/blender/editors/screen/screen_ops.c105
-rw-r--r--source/blender/editors/screen/screen_user_menu.c9
-rw-r--r--source/blender/editors/screen/workspace_edit.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c105
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c1
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c9
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c14
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_ops.c15
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_proj.c12
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c26
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c30
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c23
-rw-r--r--source/blender/editors/sound/sound_ops.c3
-rw-r--r--source/blender/editors/space_action/space_action.c21
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c16
-rw-r--r--source/blender/editors/space_clip/clip_ops.c1
-rw-r--r--source/blender/editors/space_clip/tracking_ops_orient.c8
-rw-r--r--source/blender/editors/space_clip/tracking_select.c14
-rw-r--r--source/blender/editors/space_file/file_ops.c4
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c6
-rw-r--r--source/blender/editors/space_graph/graph_draw.c4
-rw-r--r--source/blender/editors/space_graph/graph_edit.c10
-rw-r--r--source/blender/editors/space_graph/space_graph.c28
-rw-r--r--source/blender/editors/space_image/image_draw.c25
-rw-r--r--source/blender/editors/space_image/image_ops.c4
-rw-r--r--source/blender/editors/space_image/space_image.c40
-rw-r--r--source/blender/editors/space_info/info_stats.c52
-rw-r--r--source/blender/editors/space_logic/space_logic.c363
-rw-r--r--source/blender/editors/space_nla/nla_channels.c2
-rw-r--r--source/blender/editors/space_node/drawnode.c10
-rw-r--r--source/blender/editors/space_node/node_draw.c4
-rw-r--r--source/blender/editors/space_node/node_edit.c12
-rw-r--r--source/blender/editors/space_node/node_gizmo.c16
-rw-r--r--source/blender/editors/space_node/node_intern.h1
-rw-r--r--source/blender/editors/space_node/node_select.c19
-rw-r--r--source/blender/editors/space_node/node_templates.c3
-rw-r--r--source/blender/editors/space_node/space_node.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c12
-rw-r--r--source/blender/editors/space_outliner/outliner_dragdrop.c6
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c6
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c6
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c18
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c26
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c24
-rw-r--r--source/blender/editors/space_sequencer/sequencer_modifier.c3
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c4
-rw-r--r--source/blender/editors/space_text/text_ops.c2
-rw-r--r--source/blender/editors/space_time/space_time.c834
-rw-r--r--source/blender/editors/space_time/time_ops.c218
-rw-r--r--source/blender/editors/space_userpref/space_userpref.c40
-rw-r--r--source/blender/editors/space_view3d/CMakeLists.txt1
-rw-r--r--source/blender/editors/space_view3d/drawobject.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_camera_control.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c31
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c5
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_armature.c5
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_camera.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_empty.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_ruler.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h3
-rw-r--r--source/blender/editors/space_view3d/view3d_iterators.c11
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c1123
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c140
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c52
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c22
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c369
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c2
-rw-r--r--source/blender/editors/transform/transform.c82
-rw-r--r--source/blender/editors/transform/transform.h11
-rw-r--r--source/blender/editors/transform/transform_constraints.c2
-rw-r--r--source/blender/editors/transform/transform_conversions.c230
-rw-r--r--source/blender/editors/transform/transform_generics.c66
-rw-r--r--source/blender/editors/transform/transform_gizmo_2d.c2
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c60
-rw-r--r--source/blender/editors/transform/transform_orientations.c8
-rw-r--r--source/blender/editors/transform/transform_snap.c2
-rw-r--r--source/blender/editors/transform/transform_snap_object.c197
-rw-r--r--source/blender/editors/util/ed_util.c18
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c52
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c3
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c31
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c4
-rw-r--r--source/blender/gpu/CMakeLists.txt1
-rw-r--r--source/blender/gpu/GPU_batch.h2
-rw-r--r--source/blender/gpu/GPU_extensions.h6
-rw-r--r--source/blender/gpu/GPU_immediate.h2
-rw-r--r--source/blender/gpu/GPU_vertex_format.h10
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c46
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c68
-rw-r--r--source/blender/gpu/intern/gpu_select_pick.c2
-rw-r--r--source/blender/gpu/intern/gpu_shader.c8
-rw-r--r--source/blender/gpu/intern/gpu_texture.c14
-rw-r--r--source/blender/gpu/intern/gpu_vertex_format.c59
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_area_borders_frag.glsl16
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_area_borders_vert.glsl31
-rw-r--r--source/blender/imbuf/IMB_colormanagement.h15
-rw-r--r--source/blender/imbuf/intern/IMB_colormanagement_intern.h2
-rw-r--r--source/blender/imbuf/intern/colormanagement.c88
-rw-r--r--source/blender/makesdna/DNA_ID.h69
-rw-r--r--source/blender/makesdna/DNA_action_types.h16
-rw-r--r--source/blender/makesdna/DNA_curve_types.h17
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h23
-rw-r--r--source/blender/makesdna/DNA_layer_types.h2
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h6
-rw-r--r--source/blender/makesdna/DNA_node_types.h2
-rw-r--r--source/blender/makesdna/DNA_object_types.h27
-rw-r--r--source/blender/makesdna/DNA_particle_types.h22
-rw-r--r--source/blender/makesdna/DNA_scene_types.h27
-rw-r--r--source/blender/makesdna/DNA_screen_types.h2
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h4
-rw-r--r--source/blender/makesdna/DNA_space_types.h26
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h43
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h19
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c40
-rw-r--r--source/blender/makesrna/RNA_access.h2
-rw-r--r--source/blender/makesrna/RNA_enum_types.h1
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt4
-rw-r--r--source/blender/makesrna/intern/rna_ID.c18
-rw-r--r--source/blender/makesrna/intern/rna_access.c4
-rw-r--r--source/blender/makesrna/intern/rna_animation.c4
-rw-r--r--source/blender/makesrna/intern/rna_armature.c14
-rw-r--r--source/blender/makesrna/intern/rna_armature_api.c53
-rw-r--r--source/blender/makesrna/intern/rna_boid.c12
-rw-r--r--source/blender/makesrna/intern/rna_cloth.c9
-rw-r--r--source/blender/makesrna/intern/rna_collection.c15
-rw-r--r--source/blender/makesrna/intern/rna_color.c2
-rw-r--r--source/blender/makesrna/intern/rna_curve.c19
-rw-r--r--source/blender/makesrna/intern/rna_dynamicpaint.c16
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c10
-rw-r--r--source/blender/makesrna/intern/rna_fluidsim.c2
-rw-r--r--source/blender/makesrna/intern/rna_fracture.c6
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c68
-rw-r--r--source/blender/makesrna/intern/rna_gpencil_modifier.c2
-rw-r--r--source/blender/makesrna/intern/rna_image.c4
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_key.c290
-rw-r--r--source/blender/makesrna/intern/rna_layer.c2
-rw-r--r--source/blender/makesrna/intern/rna_lightprobe.c2
-rw-r--r--source/blender/makesrna/intern/rna_mask.c2
-rw-r--r--source/blender/makesrna/intern/rna_material.c6
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c24
-rw-r--r--source/blender/makesrna/intern/rna_nla.c4
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c41
-rw-r--r--source/blender/makesrna/intern/rna_object.c121
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c11
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c30
-rw-r--r--source/blender/makesrna/intern/rna_particle.c71
-rw-r--r--source/blender/makesrna/intern/rna_pose.c10
-rw-r--r--source/blender/makesrna/intern/rna_pose_api.c71
-rw-r--r--source/blender/makesrna/intern/rna_rigidbody.c9
-rw-r--r--source/blender/makesrna/intern/rna_scene.c60
-rw-r--r--source/blender/makesrna/intern/rna_screen.c6
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c14
-rw-r--r--source/blender/makesrna/intern/rna_sensor.c939
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c2
-rw-r--r--source/blender/makesrna/intern/rna_shader_fx.c2
-rw-r--r--source/blender/makesrna/intern/rna_smoke.c10
-rw-r--r--source/blender/makesrna/intern/rna_space.c194
-rw-r--r--source/blender/makesrna/intern/rna_texture.c8
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c167
-rw-r--r--source/blender/makesrna/intern/rna_vfont.c2
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c30
-rw-r--r--source/blender/makesrna/intern/rna_workspace.c15
-rw-r--r--source/blender/modifiers/CMakeLists.txt4
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c20
-rw-r--r--source/blender/modifiers/intern/MOD_array.c30
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c2
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c9
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c31
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c2
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c4
-rw-r--r--source/blender/modifiers/intern/MOD_correctivesmooth.c6
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c23
-rw-r--r--source/blender/modifiers/intern/MOD_datatransfer.c18
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c36
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c10
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c24
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c11
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c10
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c15
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c4
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c75
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c2
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c24
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c96
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c28
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c2
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c8
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c16
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c39
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c34
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c32
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c58
-rw-r--r--source/blender/modifiers/intern/MOD_surface.c6
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c53
-rw-r--r--source/blender/modifiers/intern/MOD_util.c35
-rw-r--r--source/blender/modifiers/intern/MOD_util.h10
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c22
-rw-r--r--source/blender/modifiers/intern/MOD_uvwarp.c8
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c46
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c84
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.c9
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c4
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c8
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c91
-rw-r--r--source/blender/physics/intern/BPH_mass_spring.cpp44
-rw-r--r--source/blender/physics/intern/eigen_utils.h10
-rw-r--r--source/blender/physics/intern/hair_volume.cpp224
-rw-r--r--source/blender/physics/intern/implicit.h10
-rw-r--r--source/blender/physics/intern/implicit_blender.c200
-rw-r--r--source/blender/physics/intern/implicit_eigen.cpp68
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c2
-rw-r--r--source/blender/python/intern/CMakeLists.txt2
-rw-r--r--source/blender/python/intern/bpy_app.c4
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c1
-rw-r--r--source/blender/python/intern/bpy_app_timers.c199
-rw-r--r--source/blender/python/intern/bpy_app_timers.h (renamed from source/blender/editors/include/ED_keymap_templates.h)14
-rw-r--r--source/blender/python/mathutils/CMakeLists.txt1
-rw-r--r--source/blender/python/mathutils/mathutils_bvhtree.c57
-rw-r--r--source/blender/python/mathutils/mathutils_noise.c1
-rw-r--r--source/blender/render/extern/include/RE_bake.h1
-rw-r--r--source/blender/render/intern/source/bake_api.c9
-rw-r--r--source/blender/render/intern/source/pipeline.c19
-rw-r--r--source/blender/render/intern/source/voxeldata.c571
-rw-r--r--source/blender/shader_fx/intern/FX_shader_shadow.c2
-rw-r--r--source/blender/windowmanager/WM_keymap.h2
-rw-r--r--source/blender/windowmanager/WM_toolsystem.h12
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c3
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c4
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c14
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c37
-rw-r--r--source/blender/windowmanager/intern/wm_files.c61
-rw-r--r--source/blender/windowmanager/intern/wm_gesture_ops.c14
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c11
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c1
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c19
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c98
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c69
-rw-r--r--source/blender/windowmanager/intern/wm_window.c4
-rw-r--r--source/blender/windowmanager/wm_files.h7
-rw-r--r--source/creator/creator.c6
-rw-r--r--source/creator/creator_args.c2
-rw-r--r--tests/gtests/blenlib/CMakeLists.txt6
-rwxr-xr-xtests/python/alembic_tests.py10
-rw-r--r--tests/python/batch_import.py2
-rw-r--r--tests/python/bl_alembic_import_test.py3
-rw-r--r--tests/python/bl_load_addons.py2
-rw-r--r--tests/python/bl_load_py_modules.py2
-rw-r--r--tests/python/bl_mesh_validate.py2
-rw-r--r--tests/python/bl_run_operators.py4
-rwxr-xr-xtests/python/ffmpeg_tests.py4
-rwxr-xr-xtests/python/modules/test_utils.py3
-rw-r--r--tests/python/pep8.py2
-rw-r--r--tests/python/rna_info_dump.py4
-rw-r--r--tests/python/view_layer/test_group_e.py4
828 files changed, 17580 insertions, 16647 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 399181838c8..0b11e4a5a1a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -157,7 +157,6 @@ option_defaults_init(
_init_BUILDINFO
_init_CODEC_FFMPEG
_init_CYCLES_OSL
- _init_CYCLES_OPENSUBDIV
_init_IMAGE_OPENEXR
_init_INPUT_NDOF
_init_JACK
@@ -174,7 +173,6 @@ if(UNIX AND NOT APPLE)
# disable less important dependencies by default
set(_init_CODEC_FFMPEG OFF)
set(_init_CYCLES_OSL OFF)
- set(_init_CYCLES_OPENSUBDIV OFF)
set(_init_IMAGE_OPENEXR OFF)
set(_init_JACK OFF)
set(_init_OPENCOLLADA OFF)
@@ -186,7 +184,6 @@ elseif(WIN32)
set(_init_JACK OFF)
elseif(APPLE)
set(_init_JACK OFF)
- set(_init_OPENSUBDIV OFF)
endif()
@@ -240,10 +237,7 @@ option(WITH_VORO "Enable Voronoi Fracture based on Voro++" ON)
# Compositor
option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
-option(WITH_OPENSUBDIV "Enable OpenSubdiv for surface subdivision" _init_OPENSUBDIV)
-
-option(WITH_OPENSUBDIV_MODIFIER "Use OpenSubdiv for CPU side of Subsurf/Multires modifiers" OFF)
-mark_as_advanced(WITH_OPENSUBDIV_MODIFIER)
+option(WITH_OPENSUBDIV "Enable OpenSubdiv for surface subdivision" ${_init_OPENSUBDIV})
option(WITH_OPENVDB "Enable features relying on OpenVDB" OFF)
option(WITH_OPENVDB_BLOSC "Enable blosc compression for OpenVDB, only enable if OpenVDB was built with blosc support" OFF)
@@ -407,12 +401,11 @@ option(WITH_CYCLES_STANDALONE "Build Cycles standalone application" OFF)
option(WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF)
option(WITH_CYCLES_OSL "Build Cycles with OSL support" ${_init_CYCLES_OSL})
option(WITH_CYCLES_EMBREE "Build Cycles with Embree support" OFF)
-option(WITH_CYCLES_OPENSUBDIV "Build Cycles with OpenSubdiv support" ${_init_CYCLES_OPENSUBDIV})
option(WITH_CYCLES_CUDA_BINARIES "Build Cycles CUDA binaries" OFF)
option(WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF)
option(WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful on machines with limited RAM)" OFF)
mark_as_advanced(WITH_CYCLES_CUDA_BUILD_SERIAL)
-set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 CACHE STRING "CUDA architectures to build binaries for")
+set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_72 sm_75 CACHE STRING "CUDA architectures to build binaries for")
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
unset(PLATFORM_DEFAULT)
option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON)
@@ -1466,6 +1459,11 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
"/we4431" # missing type specifier - int assumed
)
+ if(MSVC_VERSION GREATER_EQUAL 1911)
+ # see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038?view=vs-2017
+ set(_WARNINGS "${_WARNINGS} /w35038") #order of initialisation in c++ constructors
+ endif()
+
string(REPLACE ";" " " _WARNINGS "${_WARNINGS}")
set(C_WARNINGS "${_WARNINGS}")
set(CXX_WARNINGS "${_WARNINGS}")
diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake
index 85f59762ef2..3b4b5da26f4 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -113,9 +113,9 @@ set(SDL_VERSION 2.0.8)
set(SDL_URI https://www.libsdl.org/release/SDL2-${SDL_VERSION}.tar.gz)
set(SDL_HASH 3800d705cef742c6a634f202c37f263f)
-set(OPENCOLLADA_VERSION v1.6.63)
+set(OPENCOLLADA_VERSION v1.6.68)
set(OPENCOLLADA_URI https://github.com/KhronosGroup/OpenCOLLADA/archive/${OPENCOLLADA_VERSION}.tar.gz)
-set(OPENCOLLADA_HASH e937c3897b86fc0da53cde97257f5156)
+set(OPENCOLLADA_HASH ee7dae874019fea7be11613d07567493)
set(OPENCOLORIO_VERSION 1.1.0)
set(OPENCOLORIO_URI https://github.com/imageworks/OpenColorIO/archive/v${OPENCOLORIO_VERSION}.tar.gz)
diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
index 6ce5fd9a8fb..b480f4a9c4e 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -378,7 +378,7 @@ ALEMBIC_FORCE_BUILD=false
ALEMBIC_FORCE_REBUILD=false
ALEMBIC_SKIP=false
-OPENCOLLADA_VERSION="1.6.63"
+OPENCOLLADA_VERSION="1.6.68"
OPENCOLLADA_FORCE_BUILD=false
OPENCOLLADA_FORCE_REBUILD=false
OPENCOLLADA_SKIP=false
diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py
index 61ce11bbe0c..102fbd903e2 100644
--- a/build_files/buildbot/slave_compile.py
+++ b/build_files/buildbot/slave_compile.py
@@ -72,9 +72,6 @@ if 'cmake' in builder:
if builder.endswith('x86_64_10_9_cmake'):
cmake_extra_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64')
cmake_extra_options.append('-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9')
- # Used to trick CUDFA to see CLang as an older version.
- # cmake_extra_options.append('-DCUDA_HOST_COMPILER=/usr/local/cuda-hack/clang')
- # cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-hack/nvcc')
elif builder.startswith('win'):
if builder.endswith('_vs2017'):
@@ -119,12 +116,28 @@ if 'cmake' in builder:
cmake_extra_options.extend(["-DCMAKE_C_COMPILER=/usr/bin/gcc-7",
"-DCMAKE_CXX_COMPILER=/usr/bin/g++-7"])
+ # Workaround to build only sm_7x kernels with CUDA 10, until
+ # older kernels work well with this version.
+ if builder.startswith('win'):
+ cmake_extra_options.append('-DCUDA_VERSION=9.1')
+ cmake_extra_options.append('-DCUDA_TOOLKIT_INCLUDE:PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/include')
+ cmake_extra_options.append('-DCUDA_TOOLKIT_ROOT_DIR:PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1')
+ cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE:FILEPATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin/nvcc.exe')
+ cmake_extra_options.append('-DCUDA10_NVCC_EXECUTABLE:FILEPATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/bin/nvcc.exe')
+ cmake_extra_options.append('-DCUDA10_TOOLKIT_ROOT_DIR:PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0')
+ elif builder.startswith('linux'):
+ cmake_extra_options.append('-DCUDA_VERSION=9.1')
+ cmake_extra_options.append('-DCUDA_TOOLKIT_INCLDUE:PATH=/usr/local/cuda-9.1/include')
+ cmake_extra_options.append('-DCUDA_TOOLKIT_ROOT_DIR:PATH=/usr/local/cuda-9.1')
+ cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE:FILEPATH=/usr/local/cuda-9.1/bin/nvcc')
+ cmake_extra_options.append('-DCUDA10_NVCC_EXECUTABLE:FILEPATH=/usr/local/cuda-10.0/bin/nvcc')
+ cmake_extra_options.append('-DCUDA10_TOOLKIT_ROOT_DIR:PATH=/usr/local/cuda-10.0')
+
cmake_options.append("-C" + os.path.join(blender_dir, cmake_config_file))
# Prepare CMake options needed to configure cuda binaries compilation, 64bit only.
if bits == 64:
cuda_cmake_options.append("-DWITH_CYCLES_CUDA_BINARIES=%s" % ('ON' if build_cubins else 'OFF'))
- cuda_cmake_options.append("-DCYCLES_CUDA_BINARIES_ARCH=sm_30;sm_35;sm_37;sm_50;sm_52;sm_60;sm_61;sm_70")
if build_cubins or 'cuda' in targets:
cuda_cmake_options.append("-DCUDA_64_BIT_DEVICE_CODE=ON")
diff --git a/build_files/cmake/cmake_consistency_check.py b/build_files/cmake/cmake_consistency_check.py
index ab87095874f..90a9631fe79 100755
--- a/build_files/cmake/cmake_consistency_check.py
+++ b/build_files/cmake/cmake_consistency_check.py
@@ -29,7 +29,8 @@ if not sys.version.startswith("3"):
sys.exit(1)
from cmake_consistency_check_config import (
- IGNORE,
+ IGNORE_SOURCE,
+ IGNORE_CMAKE,
UTF8_CHECK,
SOURCE_DIR,
BUILD_DIR,
@@ -156,6 +157,7 @@ def cmake_get_src(f):
break
# replace dirs
+ l = l.replace("${CMAKE_SOURCE_DIR}", SOURCE_DIR)
l = l.replace("${CMAKE_CURRENT_SOURCE_DIR}", cmake_base)
l = l.replace("${CMAKE_CURRENT_BINARY_DIR}", cmake_base_bin)
l = l.strip('"')
@@ -238,8 +240,16 @@ def cmake_get_src(f):
filen.close()
-def is_ignore(f, ignore_used):
- for index, ig in enumerate(IGNORE):
+def is_ignore_source(f, ignore_used):
+ for index, ig in enumerate(IGNORE_SOURCE):
+ if ig in f:
+ ignore_used[index] = True
+ return True
+ return False
+
+
+def is_ignore_cmake(f, ignore_used):
+ for index, ig in enumerate(IGNORE_CMAKE):
if ig in f:
ignore_used[index] = True
return True
@@ -250,8 +260,12 @@ def main():
print("Scanning:", SOURCE_DIR)
+ ignore_used_source = [False] * len(IGNORE_SOURCE)
+ ignore_used_cmake = [False] * len(IGNORE_CMAKE)
+
for cmake in source_list(SOURCE_DIR, is_cmake):
- cmake_get_src(cmake)
+ if not is_ignore_cmake(cmake, ignore_used_cmake):
+ cmake_get_src(cmake)
# First do stupid check, do these files exist?
print("\nChecking for missing references:")
@@ -282,12 +296,10 @@ def main():
del is_err
del errs
- ignore_used = [False] * len(IGNORE)
-
# now check on files not accounted for.
print("\nC/C++ Files CMake does not know about...")
for cf in sorted(source_list(SOURCE_DIR, is_c)):
- if not is_ignore(cf, ignore_used):
+ if not is_ignore_source(cf, ignore_used_source):
if cf not in global_c:
print("missing_c: ", cf)
@@ -304,7 +316,7 @@ def main():
print("\nC/C++ Headers CMake does not know about...")
for hf in sorted(source_list(SOURCE_DIR, is_c_header)):
- if not is_ignore(hf, ignore_used):
+ if not is_ignore_source(hf, ignore_used_source):
if hf not in global_h:
print("missing_h: ", hf)
@@ -326,9 +338,15 @@ def main():
traceback.print_exc()
# Check ignores aren't stale
- print("\nCheck for unused 'IGNORE' paths...")
- for index, ig in enumerate(IGNORE):
- if not ignore_used[index]:
+ print("\nCheck for unused 'IGNORE_SOURCE' paths...")
+ for index, ig in enumerate(IGNORE_SOURCE):
+ if not ignore_used_source[index]:
+ print("unused ignore: %r" % ig)
+
+ # Check ignores aren't stale
+ print("\nCheck for unused 'IGNORE_CMAKE' paths...")
+ for index, ig in enumerate(IGNORE_CMAKE):
+ if not ignore_used_cmake[index]:
print("unused ignore: %r" % ig)
diff --git a/build_files/cmake/cmake_consistency_check_config.py b/build_files/cmake/cmake_consistency_check_config.py
index 2fbf855c386..7ecfe6f1e5f 100644
--- a/build_files/cmake/cmake_consistency_check_config.py
+++ b/build_files/cmake/cmake_consistency_check_config.py
@@ -1,11 +1,14 @@
import os
-IGNORE = (
+IGNORE_SOURCE = (
"/test/",
"/tests/gtests/",
"/release/",
# specific source files
+ "extern/audaspace/",
+
+ # specific source files
"extern/bullet2/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp",
"extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp",
"extern/bullet2/src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp",
@@ -17,6 +20,10 @@ IGNORE = (
"intern/audaspace/SRC/AUD_SRCResampleFactory.cpp",
"intern/audaspace/SRC/AUD_SRCResampleReader.cpp",
+ "doc/doxygen/doxygen.extern.h",
+ "doc/doxygen/doxygen.intern.h",
+ "doc/doxygen/doxygen.main.h",
+ "doc/doxygen/doxygen.source.h",
"extern/bullet2/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h",
"extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h",
"extern/bullet2/src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.h",
@@ -29,6 +36,10 @@ IGNORE = (
"intern/audaspace/SRC/AUD_SRCResampleReader.h",
)
+IGNORE_CMAKE = (
+ "extern/audaspace/CMakeLists.txt",
+)
+
UTF8_CHECK = True
SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), "..", ".."))))
diff --git a/build_files/cmake/config/blender_full.cmake b/build_files/cmake/config/blender_full.cmake
index e645fcf4932..9dffc01cf2a 100644
--- a/build_files/cmake/config/blender_full.cmake
+++ b/build_files/cmake/config/blender_full.cmake
@@ -12,7 +12,6 @@ set(WITH_CODEC_FFMPEG ON CACHE BOOL "" FORCE)
set(WITH_CODEC_SNDFILE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
-set(WITH_CYCLES_OPENSUBDIV ON CACHE BOOL "" FORCE)
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
set(WITH_LIBMV ON CACHE BOOL "" FORCE)
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS ON CACHE BOOL "" FORCE)
@@ -41,6 +40,7 @@ set(WITH_OPENAL ON CACHE BOOL "" FORCE)
set(WITH_OPENCOLLADA ON CACHE BOOL "" FORCE)
set(WITH_OPENCOLORIO ON CACHE BOOL "" FORCE)
set(WITH_OPENMP ON CACHE BOOL "" FORCE)
+set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
set(WITH_OPENVDB ON CACHE BOOL "" FORCE)
set(WITH_OPENVDB_BLOSC ON CACHE BOOL "" FORCE)
set(WITH_PYTHON_INSTALL ON CACHE BOOL "" FORCE)
@@ -56,13 +56,10 @@ set(WITH_MEM_JEMALLOC ON CACHE BOOL "" FORCE)
if(UNIX AND NOT APPLE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
set(WITH_DOC_MANPAGE ON CACHE BOOL "" FORCE)
- set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
elseif(WIN32)
set(WITH_JACK OFF CACHE BOOL "" FORCE)
- set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
elseif(APPLE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
- set(WITH_OPENSUBDIV OFF CACHE BOOL "" FORCE)
# include("${CMAKE_CURRENT_SOURCE_DIR}/../platform/platform_apple_xcode.cmake")
endif()
diff --git a/build_files/cmake/config/blender_lite.cmake b/build_files/cmake/config/blender_lite.cmake
index b96354847f7..d440dbf2821 100644
--- a/build_files/cmake/config/blender_lite.cmake
+++ b/build_files/cmake/config/blender_lite.cmake
@@ -17,7 +17,6 @@ set(WITH_CODEC_FFMPEG OFF CACHE BOOL "" FORCE)
set(WITH_CODEC_SNDFILE OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_OSL OFF CACHE BOOL "" FORCE)
-set(WITH_CYCLES_OPENSUBDIV OFF CACHE BOOL "" FORCE)
set(WITH_FFTW3 OFF CACHE BOOL "" FORCE)
set(WITH_LIBMV OFF CACHE BOOL "" FORCE)
set(WITH_LLVM OFF CACHE BOOL "" FORCE)
diff --git a/build_files/cmake/config/blender_release.cmake b/build_files/cmake/config/blender_release.cmake
index 8edbd1b9b85..ac19ed29997 100644
--- a/build_files/cmake/config/blender_release.cmake
+++ b/build_files/cmake/config/blender_release.cmake
@@ -13,7 +13,6 @@ set(WITH_CODEC_FFMPEG ON CACHE BOOL "" FORCE)
set(WITH_CODEC_SNDFILE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
-set(WITH_CYCLES_OPENSUBDIV ON CACHE BOOL "" FORCE)
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
set(WITH_LIBMV ON CACHE BOOL "" FORCE)
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS ON CACHE BOOL "" FORCE)
@@ -42,6 +41,7 @@ set(WITH_OPENAL ON CACHE BOOL "" FORCE)
set(WITH_OPENCOLLADA ON CACHE BOOL "" FORCE)
set(WITH_OPENCOLORIO ON CACHE BOOL "" FORCE)
set(WITH_OPENMP ON CACHE BOOL "" FORCE)
+set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
set(WITH_OPENVDB ON CACHE BOOL "" FORCE)
set(WITH_OPENVDB_BLOSC ON CACHE BOOL "" FORCE)
set(WITH_PYTHON_INSTALL ON CACHE BOOL "" FORCE)
@@ -52,19 +52,16 @@ set(WITH_X11_XF86VMODE ON CACHE BOOL "" FORCE)
set(WITH_MEM_JEMALLOC ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_CUDA_BINARIES ON CACHE BOOL "" FORCE)
-set(CYCLES_CUDA_BINARIES_ARCH sm_30;sm_35;sm_37;sm_50;sm_52;sm_60;sm_61 CACHE STRING "" FORCE)
+set(CYCLES_CUDA_BINARIES_ARCH sm_30;sm_35;sm_37;sm_50;sm_52;sm_60;sm_61;sm_70;sm_72;sm_75 CACHE STRING "" FORCE)
# platform dependent options
if(UNIX AND NOT APPLE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
set(WITH_DOC_MANPAGE ON CACHE BOOL "" FORCE)
- set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
elseif(WIN32)
set(WITH_JACK OFF CACHE BOOL "" FORCE)
- set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
elseif(APPLE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
- set(WITH_OPENSUBDIV OFF CACHE BOOL "" FORCE)
# include("${CMAKE_CURRENT_SOURCE_DIR}/../platform/platform_apple_xcode.cmake")
endif()
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index d965536dd87..ec2e3e5ae5e 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -431,7 +431,7 @@ function(setup_liblinks
if(WITH_OPENCOLORIO)
target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
endif()
- if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)
+ if(WITH_OPENSUBDIV)
target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
endif()
if(WITH_OPENVDB)
@@ -695,6 +695,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_intern_glew_mx
bf_intern_clog
bf_intern_opensubdiv
+ bf_intern_numaapi
)
if(NOT WITH_SYSTEM_GLOG)
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index bbd1b1fcac6..55642b534c2 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -59,7 +59,7 @@ if(WITH_ALEMBIC)
set(ALEMBIC_FOUND ON)
endif()
-if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)
+if(WITH_OPENSUBDIV)
set(OPENSUBDIV ${LIBDIR}/opensubdiv)
set(OPENSUBDIV_LIBPATH ${OPENSUBDIV}/lib)
find_library(OSD_LIB_CPU NAMES osdCPU PATHS ${OPENSUBDIV_LIBPATH})
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index 14bcf4090ad..f9ea9420e97 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -390,7 +390,7 @@ if(WITH_LLVM OR WITH_SDL_DYNLOAD)
)
endif()
-if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)
+if(WITH_OPENSUBDIV)
find_package_wrapper(OpenSubdiv)
set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBRARIES})
@@ -398,7 +398,6 @@ if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)
if(NOT OPENSUBDIV_FOUND)
set(WITH_OPENSUBDIV OFF)
- set(WITH_CYCLES_OPENSUBDIV OFF)
message(STATUS "OpenSubdiv not found")
endif()
endif()
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 8c3ddefa68e..5eeda2d1926 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -502,7 +502,7 @@ if(WITH_IMAGE_OPENJPEG)
set(OPENJPEG_LIBRARIES ${OPENJPEG}/lib/openjp2.lib)
endif()
-if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)
+if(WITH_OPENSUBDIV)
set(OPENSUBDIV_INCLUDE_DIR ${LIBDIR}/opensubdiv/include)
set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib)
set(OPENSUBDIV_LIBRARIES
diff --git a/doc/python_api/examples/bpy.app.timers.1.py b/doc/python_api/examples/bpy.app.timers.1.py
new file mode 100644
index 00000000000..bae3b94b24a
--- /dev/null
+++ b/doc/python_api/examples/bpy.app.timers.1.py
@@ -0,0 +1,10 @@
+"""
+Run a Function in x Seconds
+---------------------------
+"""
+import bpy
+
+def in_5_seconds():
+ print("Hello World")
+
+bpy.app.timers.register(in_5_seconds, first_interval=5)
diff --git a/doc/python_api/examples/bpy.app.timers.2.py b/doc/python_api/examples/bpy.app.timers.2.py
new file mode 100644
index 00000000000..c663959c209
--- /dev/null
+++ b/doc/python_api/examples/bpy.app.timers.2.py
@@ -0,0 +1,11 @@
+"""
+Run a Function every x Seconds
+------------------------------
+"""
+import bpy
+
+def every_2_seconds():
+ print("Hello World")
+ return 2.0
+
+bpy.app.timers.register(every_2_seconds)
diff --git a/doc/python_api/examples/bpy.app.timers.3.py b/doc/python_api/examples/bpy.app.timers.3.py
new file mode 100644
index 00000000000..79daf6a7740
--- /dev/null
+++ b/doc/python_api/examples/bpy.app.timers.3.py
@@ -0,0 +1,17 @@
+"""
+Run a Function n times every x seconds
+--------------------------------------
+"""
+import bpy
+
+counter = 0
+
+def run_10_times():
+ global counter
+ counter += 1
+ print(counter)
+ if counter == 10:
+ return None
+ return 0.1
+
+bpy.app.timers.register(run_10_times)
diff --git a/doc/python_api/examples/bpy.app.timers.4.py b/doc/python_api/examples/bpy.app.timers.4.py
new file mode 100644
index 00000000000..6cdee564bb5
--- /dev/null
+++ b/doc/python_api/examples/bpy.app.timers.4.py
@@ -0,0 +1,12 @@
+"""
+Assign parameters to functions
+------------------------------
+"""
+import bpy
+import functools
+
+def print_message(message):
+ print("Message:", message)
+
+bpy.app.timers.register(functools.partial(print_message, "Hello"), first_interval=2.0)
+bpy.app.timers.register(functools.partial(print_message, "World"), first_interval=3.0)
diff --git a/doc/python_api/examples/bpy.app.timers.5.py b/doc/python_api/examples/bpy.app.timers.5.py
new file mode 100644
index 00000000000..821a047d7c7
--- /dev/null
+++ b/doc/python_api/examples/bpy.app.timers.5.py
@@ -0,0 +1,25 @@
+"""
+Use a Timer to react to events in another thread
+------------------------------------------------
+
+You should never modify Blender data at arbitrary points in time in separate threads.
+However you can use a queue to collect all the actions that should be executed when Blender is in the right state again.
+Pythons `queue.Queue` can be used here, because it implements the required locking semantics.
+"""
+import bpy
+import queue
+
+execution_queue = queue.Queue()
+
+# This function can savely be called in another thread.
+# The function will be executed when the timer runs the next time.
+def run_in_main_thread(function):
+ execution_queue.put(function)
+
+def execute_queued_functions():
+ while not execution_queue.empty():
+ function = execution_queue.get()
+ function()
+ return 1.0
+
+bpy.app.timers.register(execute_queued_functions)
diff --git a/doc/python_api/rst/info_api_reference.rst b/doc/python_api/rst/info_api_reference.rst
index cc7128f3b5d..7d8eaade0f2 100644
--- a/doc/python_api/rst/info_api_reference.rst
+++ b/doc/python_api/rst/info_api_reference.rst
@@ -298,4 +298,3 @@ then copied :kbd:`Control-C`, usually to paste in the text editor or python cons
zooming the view for example isn't so useful to repeat so its excluded from the output.
To display *every* operator that runs see :ref:`Show All Operators <info_show_all_operators>`
-
diff --git a/doc/python_api/rst/info_best_practice.rst b/doc/python_api/rst/info_best_practice.rst
index b9c9f234b72..8b64bacd50e 100644
--- a/doc/python_api/rst/info_best_practice.rst
+++ b/doc/python_api/rst/info_best_practice.rst
@@ -297,13 +297,13 @@ Here are 3 ways of joining multiple strings into one string for writing.
This also applies to any area of your code that involves a lot of string joining.
-``String addition`` -
+``String addition`` -
this is the slowest option, *don't use if you can help it, especially when writing data in a loop*.
>>> file.write(str1 + " " + str2 + " " + str3 + "\n")
-``String formatting`` -
+``String formatting`` -
use this when you are writing string data from floats and ints.
>>> file.write("%s %s %s\n" % (str1, str2, str3))
@@ -392,4 +392,3 @@ While developing a script it is good to time it to be aware of any changes in pe
# do something...
print("My Script Finished: %.4f sec" % (time.time() - time_start))
-
diff --git a/doc/python_api/rst/info_gotcha.rst b/doc/python_api/rst/info_gotcha.rst
index bbccc27b227..057fe22ae68 100644
--- a/doc/python_api/rst/info_gotcha.rst
+++ b/doc/python_api/rst/info_gotcha.rst
@@ -205,8 +205,8 @@ Support Overview
* - Usage
- :class:`bpy.types.MeshPolygon`
- - :class:`bpy.types.MeshTessFace`
- - :class:`bmesh.types.BMFace`
+ - :class:`bpy.types.MeshTessFace`
+ - :class:`bmesh.types.BMFace`
* - Import/Create
- Poor *(inflexible)*
- Good *(supported as upgrade path)*
@@ -288,7 +288,7 @@ Example using :class:`bpy.types.EditBone` in armature editmode:
This is only possible in edit mode.
- >>> bpy.context.object.data.edit_bones["Bone"].head = Vector((1.0, 2.0, 3.0))
+ >>> bpy.context.object.data.edit_bones["Bone"].head = Vector((1.0, 2.0, 3.0))
This will be empty outside of editmode.
@@ -333,7 +333,7 @@ Examples using :class:`bpy.types.PoseBone` in object or pose mode:
.. code-block:: python
# Gets the name of the first constraint (if it exists)
- bpy.context.object.pose.bones["Bone"].constraints[0].name
+ bpy.context.object.pose.bones["Bone"].constraints[0].name
# Gets the last selected pose bone (pose mode only)
bpy.context.active_pose_bone
@@ -378,7 +378,7 @@ This can cause bugs when you add some data (normally imported) then reference it
.. code-block:: python
bpy.data.meshes.new(name=meshid)
-
+
# normally some code, function calls...
bpy.data.meshes[meshid]
@@ -388,7 +388,7 @@ Or with name assignment...
.. code-block:: python
obj.name = objname
-
+
# normally some code, function calls...
obj = bpy.data.meshes[objname]
@@ -408,12 +408,12 @@ this way you don't run this risk of referencing existing data from the blend fil
# typically declared in the main body of the function.
mesh_name_mapping = {}
-
+
mesh = bpy.data.meshes.new(name=meshid)
mesh_name_mapping[meshid] = mesh
-
+
# normally some code, or function calls...
-
+
# use own dictionary rather than bpy.data
mesh = mesh_name_mapping[meshid]
@@ -741,7 +741,7 @@ Removing Data
**Any** data that you remove shouldn't be modified or accessed afterwards,
this includes f-curves, drivers, render layers, timeline markers, modifiers, constraints
-along with objects, scenes, groups, bones.. etc.
+along with objects, scenes, collections, bones.. etc.
The ``remove()`` api calls will invalidate the data they free to prevent common mistakes.
diff --git a/doc/python_api/rst/info_quickstart.rst b/doc/python_api/rst/info_quickstart.rst
index bbedb3f4fd4..7bab69ab52d 100644
--- a/doc/python_api/rst/info_quickstart.rst
+++ b/doc/python_api/rst/info_quickstart.rst
@@ -120,12 +120,12 @@ however, the index of a member may change while running Blender.
Accessing Attributes
^^^^^^^^^^^^^^^^^^^^
-Once you have a data block, such as a material, object, groups etc.,
+Once you have a data block, such as a material, object, collections etc.,
its attributes can be accessed much like you would change a setting using the graphical interface.
In fact, the tooltip for each button also displays the Python attribute
which can help in finding what settings to change in a script.
- >>> bpy.data.objects[0].name
+ >>> bpy.data.objects[0].name
'Camera'
>>> bpy.data.scenes["Scene"]
@@ -195,10 +195,10 @@ Example:
value = bpy.data.scenes["Scene"].get("test_prop", "fallback value")
# dictionaries can be assigned as long as they only use basic types.
- group = bpy.data.groups.new("MyTestGroup")
- group["MySettings"] = {"foo": 10, "bar": "spam", "baz": {}}
+ collection = bpy.data.collections.new("MyTestCollection")
+ collection["MySettings"] = {"foo": 10, "bar": "spam", "baz": {}}
- del group["MySettings"]
+ del collection["MySettings"]
Note that these properties can only be assigned basic Python types.
@@ -267,7 +267,7 @@ Operator Poll()
^^^^^^^^^^^^^^^
Many operators have a "poll" function which may check that the cursor
-is in a valid area or that the object is in the correct mode (Edit Mode, Weight Paint etc).
+is in a valid area or that the object is in the correct mode (Edit Mode, Weight Paint etc).
When an operator's poll function fails within Python, an exception is raised.
For example, calling ``bpy.ops.view3d.render_border()`` from the console raises the following error:
@@ -339,11 +339,11 @@ Notice the extra ``bl_`` variables used to set the context they display in.
To run the script:
-#. Highlight the above code then press :kbd:`Ctrl-C` to copy it
-#. Start Blender
-#. Press :kbd:`Ctrl-Right` twice to change to the Scripting layout
-#. Click the button labeled ``New`` and the confirmation pop up in order to create a new text block.
-#. Press :kbd:`Ctrl-V` to paste the code into the text panel (the upper left frame)
+#. Highlight the above code then press :kbd:`Ctrl-C` to copy it.
+#. Start Blender.
+#. Click on the tab for the *Scripting* workspace.
+#. Click the button labeled ``New`` to create a new text block.
+#. Press :kbd:`Ctrl-V` to paste the code into the text panel (the upper left frame).
#. Click on the button **Run Script**.
@@ -394,7 +394,7 @@ Internal Types
Used for Blender data-blocks and collections: :class:`bpy.types.bpy_struct`
-For data that contains its own attributes groups/meshes/bones/scenes... etc.
+For data that contains its own attributes collections/meshes/bones/scenes... etc.
There are 2 main types that wrap Blenders data, one for data-blocks
(known internally as ``bpy_struct``), another for properties.
@@ -477,4 +477,3 @@ Using Low-Level Functions:
fcu_z.keyframe_points.add(2)
fcu_z.keyframe_points[0].co = 10.0, 0.0
fcu_z.keyframe_points[1].co = 20.0, 1.0
-
diff --git a/doc/python_api/rst/info_tips_and_tricks.rst b/doc/python_api/rst/info_tips_and_tricks.rst
index 332716087a7..63f7b9410c8 100644
--- a/doc/python_api/rst/info_tips_and_tricks.rst
+++ b/doc/python_api/rst/info_tips_and_tricks.rst
@@ -315,4 +315,3 @@ enable the CMake build option ``WITH_PYTHON_SAFETY``.
This enables data tracking which makes data access about 2x slower
which is why the option isn't enabled in release builds.
-
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index 299eebfe295..59d13acab4a 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -224,6 +224,7 @@ else:
"bmesh.geometry",
"bpy.app",
"bpy.app.handlers",
+ "bpy.app.timers",
"bpy.app.translations",
"bpy.context",
"bpy.data",
@@ -238,6 +239,7 @@ else:
"gpu.types",
"gpu.matrix",
"gpu.select",
+ "gpu_extras",
"idprop.types",
"mathutils",
"mathutils.bvhtree",
@@ -1842,6 +1844,7 @@ def write_rst_importable_modules(basepath):
"bpy.app.handlers": "Application Handlers",
"bpy.app.translations": "Application Translations",
"bpy.app.icons": "Application Icons",
+ "bpy.app.timers": "Application Timers",
"bpy.props": "Property Definitions",
"idprop.types": "ID Property Access",
"mathutils": "Math Types & Utilities",
diff --git a/extern/cuew/src/cuew.c b/extern/cuew/src/cuew.c
index ad216e66452..a22f6fda570 100644
--- a/extern/cuew/src/cuew.c
+++ b/extern/cuew/src/cuew.c
@@ -619,7 +619,11 @@ static int cuewNvrtcInit(void) {
/* Library paths. */
#ifdef _WIN32
/* Expected in c:/windows/system or similar, no path needed. */
- const char *nvrtc_paths[] = {"nvrtc64_80.dll", "nvrtc64_90.dll", "nvrtc64_91.dll", NULL};
+ const char *nvrtc_paths[] = {"nvrtc64_80.dll",
+ "nvrtc64_90.dll",
+ "nvrtc64_91.dll",
+ "nvrtc64_10_0.dll",
+ NULL};
#elif defined(__APPLE__)
/* Default installation path. */
const char *nvrtc_paths[] = {"/usr/local/cuda/lib/libnvrtc.dylib", NULL};
diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt
index c7f0f414fb1..16bbefc1c45 100644
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@ -30,6 +30,7 @@ add_subdirectory(ghost)
add_subdirectory(guardedalloc)
add_subdirectory(libmv)
add_subdirectory(memutil)
+add_subdirectory(numaapi)
add_subdirectory(opencolorio)
add_subdirectory(opensubdiv)
add_subdirectory(mikktspace)
diff --git a/intern/atomic/intern/atomic_ops_ext.h b/intern/atomic/intern/atomic_ops_ext.h
index 1b1fea9642d..9c3104108b1 100644
--- a/intern/atomic/intern/atomic_ops_ext.h
+++ b/intern/atomic/intern/atomic_ops_ext.h
@@ -206,7 +206,7 @@ ATOMIC_INLINE float atomic_add_and_fetch_fl(float *p, const float x)
oldval = *p;
newval = oldval + x;
prevval = atomic_cas_uint32((uint32_t *)p, *(uint32_t *)(&oldval), *(uint32_t *)(&newval));
- } while (UNLIKELY(prevval != *(uint32_t *)(&oldval)));
+ } while (_ATOMIC_UNLIKELY(prevval != *(uint32_t *)(&oldval)));
return newval;
}
diff --git a/intern/atomic/intern/atomic_ops_utils.h b/intern/atomic/intern/atomic_ops_utils.h
index 621b3e95906..413983bc9a6 100644
--- a/intern/atomic/intern/atomic_ops_utils.h
+++ b/intern/atomic/intern/atomic_ops_utils.h
@@ -66,14 +66,12 @@
# define ATOMIC_INLINE static inline __attribute__((always_inline))
#endif
-#ifndef LIKELY
-# ifdef __GNUC__
-# define LIKELY(x) __builtin_expect(!!(x), 1)
-# define UNLIKELY(x) __builtin_expect(!!(x), 0)
-# else
-# define LIKELY(x) (x)
-# define UNLIKELY(x) (x)
-# endif
+#ifdef __GNUC__
+# define _ATOMIC_LIKELY(x) __builtin_expect(!!(x), 1)
+# define _ATOMIC_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#else
+# define _ATOMIC_LIKELY(x) (x)
+# define _ATOMIC_UNLIKELY(x) (x)
#endif
#if defined(__SIZEOF_POINTER__)
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index 873bbfa36fa..6fe4546ae8c 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -226,7 +226,7 @@ if(WITH_CYCLES_EMBREE)
)
endif()
-if(WITH_CYCLES_OPENSUBDIV)
+if(WITH_OPENSUBDIV)
add_definitions(-DWITH_OPENSUBDIV)
include_directories(
SYSTEM
@@ -308,13 +308,20 @@ if(WITH_CYCLES_CUDA_BINARIES AND (NOT WITH_CYCLES_CUBIN_COMPILER))
endif()
unset(MAX_MSVC)
elseif(APPLE)
- if(${XCODE_VERSION} VERSION_GREATER_EQUAL 10.0)
+ if(NOT (${XCODE_VERSION} VERSION_LESS 10.0))
message(STATUS "nvcc not supported for this compiler version, using cycles_cubin_cc instead.")
set(WITH_CYCLES_CUBIN_COMPILER ON)
endif()
endif()
endif()
+# NVRTC gives wrong rendering result in CUDA 10.0, so we must use NVCC.
+if(WITH_CYCLES_CUDA_BINARIES AND WITH_CYCLES_CUBIN_COMPILER)
+ if(NOT (${CUDA_VERSION} VERSION_LESS 10.0))
+ message(STATUS "cycles_cubin_cc not supported for CUDA 10.0+, using nvcc instead.")
+ set(WITH_CYCLES_CUBIN_COMPILER OFF)
+ endif()
+endif()
# Subdirectories
diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt
index 35c54fff8a4..f6052dcb275 100644
--- a/intern/cycles/app/CMakeLists.txt
+++ b/intern/cycles/app/CMakeLists.txt
@@ -84,7 +84,7 @@ macro(cycles_target_link_libraries target)
if(WITH_CYCLES_EMBREE)
target_link_libraries(${target} ${EMBREE_LIBRARIES})
endif()
- if(WITH_CYCLES_OPENSUBDIV)
+ if(WITH_OPENSUBDIV)
target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
endif()
if(WITH_OPENCOLORIO)
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py
index 0b74150f981..28b92edf489 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -81,7 +81,7 @@ def _parse_command_line():
return
parser = _configure_argument_parser()
- args, unknown = parser.parse_known_args(argv[argv.index("--") + 1:])
+ args, _ = parser.parse_known_args(argv[argv.index("--") + 1:])
if args.cycles_resumable_num_chunks is not None:
if args.cycles_resumable_current_chunk is not None:
@@ -256,8 +256,6 @@ def register_passes(engine, scene, srl):
if crl.use_pass_volume_direct: engine.register_pass(scene, srl, "VolumeDir", 3, "RGB", 'COLOR')
if crl.use_pass_volume_indirect: engine.register_pass(scene, srl, "VolumeInd", 3, "RGB", 'COLOR')
- cscene = scene.cycles
-
if crl.use_pass_crypto_object:
for i in range(0, crl.pass_crypto_depth, 2):
engine.register_pass(scene, srl, "CryptoObject" + '{:02d}'.format(i), 4, "RGBA", 'COLOR')
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 0d68138ffb4..e0b5c1446a4 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -839,8 +839,6 @@ class CyclesCameraSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
- import math
-
bpy.types.Camera.cycles = PointerProperty(
name="Cycles Camera Settings",
description="Cycles camera settings",
@@ -1226,8 +1224,6 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
def update_render_passes(self, context):
- scene = context.scene
- rd = scene.render
view_layer = context.view_layer
view_layer.update_render_passes()
@@ -1488,7 +1484,11 @@ class CyclesPreferences(bpy.types.AddonPreferences):
return self.get_num_gpu_devices() > 0
def draw_impl(self, layout, context):
+ available_device_types = self.get_device_types(context)
layout.label(text="Cycles Compute Device:")
+ if len(available_device_types) == 1:
+ layout.label(text="No compatible GPUs found", icon='INFO')
+ return
layout.row().prop(self, "compute_device_type", expand=True)
cuda_devices, opencl_devices = self.get_devices()
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index e0bea93e1c2..19d3a0fcf54 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -23,7 +23,6 @@ import _cycles
from bpy.types import (
Panel,
- Menu,
Operator,
)
@@ -55,6 +54,16 @@ class CyclesButtonsPanel:
return context.engine in cls.COMPAT_ENGINES
+class CyclesNodeButtonsPanel:
+ bl_space_type = "NODE_EDITOR"
+ bl_region_type = "UI"
+ COMPAT_ENGINES = {'CYCLES'}
+
+ @classmethod
+ def poll(cls, context):
+ return context.engine in cls.COMPAT_ENGINES
+
+
def get_device_type(context):
return context.user_preferences.addons[__package__].preferences.compute_device_type
@@ -328,7 +337,6 @@ class CYCLES_RENDER_PT_hair(CyclesButtonsPanel, Panel):
def draw_header(self, context):
layout = self.layout
scene = context.scene
- cscene = scene.cycles
ccscene = scene.cycles_curves
layout.prop(ccscene, "use_curves", text="")
@@ -339,7 +347,6 @@ class CYCLES_RENDER_PT_hair(CyclesButtonsPanel, Panel):
layout.use_property_decorate = False
scene = context.scene
- cscene = scene.cycles
ccscene = scene.cycles_curves
layout.active = ccscene.use_curves
@@ -369,7 +376,6 @@ class CYCLES_RENDER_PT_volumes(CyclesButtonsPanel, Panel):
scene = context.scene
cscene = scene.cycles
- ccscene = scene.cycles_curves
col = layout.column()
col.prop(cscene, "volume_step_size", text="Step Size")
@@ -485,7 +491,6 @@ class CYCLES_RENDER_PT_motion_blur_curve(CyclesButtonsPanel, Panel):
layout.use_property_decorate = False
scene = context.scene
- cscene = scene.cycles
rd = scene.render
layout.active = rd.use_motion_blur
@@ -524,7 +529,6 @@ class CYCLES_RENDER_PT_film_transparency(CyclesButtonsPanel, Panel):
def draw_header(self, context):
layout = self.layout
- rd = context.scene.render
scene = context.scene
cscene = scene.cycles
@@ -584,7 +588,6 @@ class CYCLES_RENDER_PT_performance_threads(CyclesButtonsPanel, Panel):
scene = context.scene
rd = scene.render
- cscene = scene.cycles
col = layout.column()
@@ -632,7 +635,6 @@ class CYCLES_RENDER_PT_performance_acceleration_structure(CyclesButtonsPanel, Pa
layout.use_property_decorate = False
scene = context.scene
- rd = scene.render
cscene = scene.cycles
col = layout.column()
@@ -661,7 +663,6 @@ class CYCLES_RENDER_PT_performance_final_render(CyclesButtonsPanel, Panel):
scene = context.scene
rd = scene.render
- cscene = scene.cycles
col = layout.column()
@@ -785,7 +786,6 @@ class CYCLES_RENDER_PT_passes_light(CyclesButtonsPanel, Panel):
layout.use_property_split = True
layout.use_property_decorate = False
- scene = context.scene
view_layer = context.view_layer
cycles_view_layer = view_layer.cycles
@@ -894,7 +894,6 @@ class CYCLES_RENDER_PT_denoising(CyclesButtonsPanel, Panel):
scene = context.scene
view_layer = context.view_layer
cycles_view_layer = view_layer.cycles
- cscene = scene.cycles
layout = self.layout
layout.prop(cycles_view_layer, "use_denoising", text="")
@@ -905,7 +904,6 @@ class CYCLES_RENDER_PT_denoising(CyclesButtonsPanel, Panel):
layout.use_property_decorate = False
scene = context.scene
- cscene = scene.cycles
view_layer = context.view_layer
cycles_view_layer = view_layer.cycles
@@ -999,8 +997,6 @@ class CYCLES_CAMERA_PT_dof(CyclesButtonsPanel, Panel):
layout.use_property_split = True
cam = context.camera
- ccam = cam.cycles
- dof_options = cam.gpu_dof
split = layout.split()
@@ -1027,7 +1023,6 @@ class CYCLES_CAMERA_PT_dof_aperture(CyclesButtonsPanel, Panel):
cam = context.camera
ccam = cam.cycles
- dof_options = cam.gpu_dof
col = flow.column()
col.prop(ccam, "aperture_type")
@@ -1138,7 +1133,7 @@ class CYCLES_OBJECT_PT_motion_blur(CyclesButtonsPanel, Panel):
if CyclesButtonsPanel.poll(context) and ob:
if ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META', 'CAMERA'}:
return True
- if ob.dupli_type == 'COLLECTION' and ob.dupli_group:
+ if ob.instance_type == 'COLLECTION' and ob.instance_collection:
return True
# TODO(sergey): More duplicator types here?
return False
@@ -1183,7 +1178,7 @@ class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel):
ob = context.object
return (CyclesButtonsPanel.poll(context) and
ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LIGHT'}) or
- (ob.dupli_type == 'COLLECTION' and ob.dupli_group)))
+ (ob.instance_type == 'COLLECTION' and ob.instance_collection)))
def draw(self, context):
pass
@@ -1200,7 +1195,6 @@ class CYCLES_OBJECT_PT_cycles_settings_ray_visibility(CyclesButtonsPanel, Panel)
layout.use_property_decorate = False
scene = context.scene
- cscene = scene.cycles
ob = context.object
cob = ob.cycles
visibility = ob.cycles_visibility
@@ -1247,7 +1241,6 @@ class CYCLES_OBJECT_PT_cycles_settings_performance(CyclesButtonsPanel, Panel):
cscene = scene.cycles
ob = context.object
cob = ob.cycles
- visibility = ob.cycles_visibility
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
@@ -1551,11 +1544,7 @@ class CYCLES_WORLD_PT_settings(CyclesButtonsPanel, Panel):
layout.use_property_split = True
layout.use_property_decorate = False
- world = context.world
- cworld = world.cycles
- # cscene = context.scene.cycles
-
- col = layout.column()
+ layout.column()
class CYCLES_WORLD_PT_settings_surface(CyclesButtonsPanel, Panel):
@@ -1689,32 +1678,29 @@ class CYCLES_MATERIAL_PT_settings(CyclesButtonsPanel, Panel):
def poll(cls, context):
return context.material and CyclesButtonsPanel.poll(context)
- def draw(self, context):
+ @staticmethod
+ def draw_shared(self, mat):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
- mat = context.material
- cmat = mat.cycles
-
layout.prop(mat, "pass_index")
+ def draw(self, context):
+ self.draw_shared(self, context.material)
+
class CYCLES_MATERIAL_PT_settings_surface(CyclesButtonsPanel, Panel):
bl_label = "Surface"
bl_parent_id = "CYCLES_MATERIAL_PT_settings"
bl_context = "material"
- @classmethod
- def poll(cls, context):
- return context.material and CyclesButtonsPanel.poll(context)
-
- def draw(self, context):
+ @staticmethod
+ def draw_shared(self, mat):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
- mat = context.material
cmat = mat.cycles
col = layout.column()
@@ -1722,22 +1708,21 @@ class CYCLES_MATERIAL_PT_settings_surface(CyclesButtonsPanel, Panel):
col.prop(cmat, "use_transparent_shadow")
col.prop(cmat, "displacement_method", text="Displacement Method")
+ def draw(self, context):
+ self.draw_shared(self, context.material)
+
class CYCLES_MATERIAL_PT_settings_volume(CyclesButtonsPanel, Panel):
bl_label = "Volume"
bl_parent_id = "CYCLES_MATERIAL_PT_settings"
bl_context = "material"
- @classmethod
- def poll(cls, context):
- return context.material and CyclesButtonsPanel.poll(context)
-
- def draw(self, context):
+ @staticmethod
+ def draw_shared(self, context, mat):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
- mat = context.material
cmat = mat.cycles
col = layout.column()
@@ -1747,6 +1732,9 @@ class CYCLES_MATERIAL_PT_settings_volume(CyclesButtonsPanel, Panel):
col.prop(cmat, "volume_interpolation", text="Interpolation")
col.prop(cmat, "homogeneous_volume", text="Homogeneous")
+ def draw(self, context):
+ self.draw_shared(self, context, context.material)
+
class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
bl_label = "Bake"
@@ -1827,7 +1815,7 @@ 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="Cage Object")
+ sub.prop(cbk, "cage_object", text="Cage Object")
else:
sub.prop(cbk, "cage_extrusion", text="Ray Distance")
@@ -1981,6 +1969,42 @@ class CYCLES_RENDER_PT_simplify_culling(CyclesButtonsPanel, Panel):
sub.prop(cscene, "distance_cull_margin", text="Distance")
+class CYCLES_NODE_PT_settings(CyclesNodeButtonsPanel, Panel):
+ bl_label = "Settings"
+ bl_category = "Node"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ @classmethod
+ def poll(cls, context):
+ snode = context.space_data
+ return CyclesNodeButtonsPanel.poll(context) and \
+ snode.tree_type == 'ShaderNodeTree' and snode.id
+
+ def draw(self, context):
+ material = context.space_data.id
+ CYCLES_MATERIAL_PT_settings.draw_shared(self, material)
+
+
+class CYCLES_NODE_PT_settings_surface(CyclesNodeButtonsPanel, Panel):
+ bl_label = "Surface"
+ bl_category = "Node"
+ bl_parent_id = "CYCLES_NODE_PT_settings"
+
+ def draw(self, context):
+ material = context.space_data.id
+ CYCLES_MATERIAL_PT_settings_surface.draw_shared(self, material)
+
+
+class CYCLES_NODE_PT_settings_volume(CyclesNodeButtonsPanel, Panel):
+ bl_label = "Volume"
+ bl_category = "Node"
+ bl_parent_id = "CYCLES_NODE_PT_settings"
+
+ def draw(self, context):
+ material = context.space_data.id
+ CYCLES_MATERIAL_PT_settings_volume.draw_shared(self, context, material)
+
+
def draw_device(self, context):
scene = context.scene
layout = self.layout
@@ -2109,6 +2133,9 @@ classes = (
CYCLES_MATERIAL_PT_settings_volume,
CYCLES_RENDER_PT_bake,
CYCLES_RENDER_PT_debug,
+ CYCLES_NODE_PT_settings,
+ CYCLES_NODE_PT_settings_surface,
+ CYCLES_NODE_PT_settings_volume,
)
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index b97c250adf6..b27de775c54 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -1061,9 +1061,12 @@ Mesh *BlenderSync::sync_mesh(BL::Depsgraph& b_depsgraph,
* updating meshes here will end up having derived mesh referencing
* freed data from the blender side.
*/
- if(preview && b_ob.type() != BL::Object::type_MESH)
+ if(preview && b_ob.type() != BL::Object::type_MESH) {
b_ob.update_from_editmode(b_data);
+ }
+ /* For some reason, meshes do not need this... */
+ bool apply_modifiers = (b_ob.type() != BL::Object::type_MESH);
bool need_undeformed = mesh->need_attribute(scene, ATTR_STD_GENERATED);
mesh->subdivision_type = object_subdivision_type(b_ob, preview, experimental);
@@ -1078,7 +1081,7 @@ Mesh *BlenderSync::sync_mesh(BL::Depsgraph& b_depsgraph,
BL::Mesh b_mesh = object_to_mesh(b_data,
b_ob,
b_depsgraph,
- false,
+ apply_modifiers,
need_undeformed,
mesh->subdivision_type);
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index a57edf9b940..bcab5276060 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -506,15 +506,15 @@ Object *BlenderSync::sync_object(BL::Depsgraph& b_depsgraph,
}
static bool object_render_hide_original(BL::Object::type_enum ob_type,
- BL::Object::dupli_type_enum dupli_type)
+ BL::Object::instance_type_enum dupli_type)
{
/* metaball exception, they duplicate self */
if(ob_type == BL::Object::type_META)
return false;
- return (dupli_type == BL::Object::dupli_type_VERTS ||
- dupli_type == BL::Object::dupli_type_FACES ||
- dupli_type == BL::Object::dupli_type_FRAMES);
+ return (dupli_type == BL::Object::instance_type_VERTS ||
+ dupli_type == BL::Object::instance_type_FACES ||
+ dupli_type == BL::Object::instance_type_FRAMES);
}
static bool object_render_hide(BL::Object& b_ob,
@@ -541,15 +541,15 @@ static bool object_render_hide(BL::Object& b_ob,
}
/* Both mode_PREVIEW and mode_VIEWPORT are treated the same here.*/
- const bool show_duplicator = depsgraph_mode == BL::Depsgraph::mode_RENDER
- ? b_ob.show_duplicator_for_render()
- : b_ob.show_duplicator_for_viewport();
+ const bool show_instancer = depsgraph_mode == BL::Depsgraph::mode_RENDER
+ ? b_ob.show_instancer_for_render()
+ : b_ob.show_instancer_for_viewport();
if(has_particles) {
- show_emitter = show_duplicator;
+ show_emitter = show_instancer;
hide_emitter = !show_emitter;
- } else if(b_ob.is_duplicator()) {
- if(top_level || show_duplicator) {
+ } else if(b_ob.is_instancer()) {
+ if(top_level || show_instancer) {
hide_as_dupli_parent = true;
}
}
@@ -558,7 +558,7 @@ static bool object_render_hide(BL::Object& b_ob,
BL::Object parent = b_ob.parent();
while(parent) {
if(object_render_hide_original(b_ob.type(),
- parent.dupli_type()))
+ parent.instance_type()))
{
if(parent_hide) {
hide_as_dupli_child_original = true;
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index cbead20488a..d031d12b507 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -501,7 +501,7 @@ void BlenderSession::render(BL::Depsgraph& b_depsgraph_)
if(!b_engine.is_preview() && background && print_render_stats) {
RenderStats stats;
- session->scene->collect_statistics(&stats);
+ session->collect_statistics(&stats);
printf("Render statistics:\n%s\n", stats.full_report().c_str());
}
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 604c134a2f7..b04a0394141 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -812,7 +812,7 @@ static ShaderNode *add_node(Scene *scene,
else if(b_node.is_a(&RNA_ShaderNodeTexCoord)) {
BL::ShaderNodeTexCoord b_tex_coord_node(b_node);
TextureCoordinateNode *tex_coord = new TextureCoordinateNode();
- tex_coord->from_dupli = b_tex_coord_node.from_dupli();
+ tex_coord->from_dupli = b_tex_coord_node.from_instancer();
if(b_tex_coord_node.object()) {
tex_coord->use_transform = true;
tex_coord->ob_tfm = get_transform(b_tex_coord_node.object().matrix_world());
@@ -865,7 +865,7 @@ static ShaderNode *add_node(Scene *scene,
BL::ShaderNodeUVMap b_uvmap_node(b_node);
UVMapNode *uvm = new UVMapNode();
uvm->attribute = b_uvmap_node.uv_map();
- uvm->from_dupli = b_uvmap_node.from_dupli();
+ uvm->from_dupli = b_uvmap_node.from_instancer();
node = uvm;
}
else if(b_node.is_a(&RNA_ShaderNodeTexPointDensity)) {
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index 8a9b881b7d4..fd45bac645d 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -780,7 +780,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
}
}
}
- } RNA_END
+ } RNA_END;
if(used_devices.size() == 1) {
params.device = used_devices[0];
@@ -830,7 +830,8 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
}
/* tiles */
- if(params.device.type != DEVICE_CPU && !background) {
+ const bool is_cpu = (params.device.type == DEVICE_CPU);
+ if(!is_cpu && !background) {
/* currently GPU could be much slower than CPU when using tiles,
* still need to be investigated, but meanwhile make it possible
* to work in viewport smoothly
@@ -907,6 +908,9 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
params.progressive_update_timeout = 0.1;
}
+ params.use_profiling = params.device.has_profiling && !b_engine.is_preview() &&
+ background && BlenderSession::print_render_stats;
+
return params;
}
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index 565f8f5404c..be35b90bff0 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -349,36 +349,36 @@ void Device::draw_pixels(
}
}
-Device *Device::create(DeviceInfo& info, Stats &stats, bool background)
+Device *Device::create(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background)
{
Device *device;
switch(info.type) {
case DEVICE_CPU:
- device = device_cpu_create(info, stats, background);
+ device = device_cpu_create(info, stats, profiler, background);
break;
#ifdef WITH_CUDA
case DEVICE_CUDA:
if(device_cuda_init())
- device = device_cuda_create(info, stats, background);
+ device = device_cuda_create(info, stats, profiler, background);
else
device = NULL;
break;
#endif
#ifdef WITH_MULTI
case DEVICE_MULTI:
- device = device_multi_create(info, stats, background);
+ device = device_multi_create(info, stats, profiler, background);
break;
#endif
#ifdef WITH_NETWORK
case DEVICE_NETWORK:
- device = device_network_create(info, stats, "127.0.0.1");
+ device = device_network_create(info, stats, profiler, "127.0.0.1");
break;
#endif
#ifdef WITH_OPENCL
case DEVICE_OPENCL:
if(device_opencl_init())
- device = device_opencl_create(info, stats, background);
+ device = device_opencl_create(info, stats, profiler, background);
else
device = NULL;
break;
@@ -505,6 +505,7 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo>& subdevices, int th
info.has_half_images = true;
info.has_volume_decoupled = true;
info.has_osl = true;
+ info.has_profiling = true;
foreach(const DeviceInfo &device, subdevices) {
/* Ensure CPU device does not slow down GPU. */
@@ -539,6 +540,7 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo>& subdevices, int th
info.has_half_images &= device.has_half_images;
info.has_volume_decoupled &= device.has_volume_decoupled;
info.has_osl &= device.has_osl;
+ info.has_profiling &= device.has_profiling;
}
return info;
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 5d1308c3030..fc9e57dc565 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -60,6 +60,7 @@ public:
bool has_volume_decoupled; /* Decoupled volume shading. */
bool has_osl; /* Support Open Shading Language. */
bool use_split_kernel; /* Use split or mega kernel. */
+ bool has_profiling; /* Supports runtime collection of profiling info. */
int cpu_threads;
vector<DeviceInfo> multi_devices;
@@ -75,6 +76,7 @@ public:
has_volume_decoupled = false;
has_osl = false;
use_split_kernel = false;
+ has_profiling = false;
}
bool operator==(const DeviceInfo &info) {
@@ -253,10 +255,10 @@ protected:
FALLBACK_SHADER_STATUS_SUCCESS,
};
- Device(DeviceInfo& info_, Stats &stats_, bool background) : background(background),
+ Device(DeviceInfo& info_, Stats &stats_, Profiler &profiler_, bool background) : background(background),
vertex_buffer(0),
fallback_status(FALLBACK_SHADER_STATUS_NONE), fallback_shader_program(0),
- info(info_), stats(stats_) {}
+ info(info_), stats(stats_), profiler(profiler_) {}
bool background;
string error_msg;
@@ -296,6 +298,7 @@ public:
/* statistics */
Stats &stats;
+ Profiler &profiler;
/* memory alignment */
virtual int mem_sub_ptr_alignment() { return MIN_ALIGNMENT_CPU_DATA_TYPES; }
@@ -335,7 +338,7 @@ public:
virtual void unmap_neighbor_tiles(Device * /*sub_device*/, RenderTile * /*tiles*/) {}
/* static */
- static Device *create(DeviceInfo& info, Stats &stats, bool background = true);
+ static Device *create(DeviceInfo& info, Stats &stats, Profiler& profiler, bool background = true);
static DeviceType type_from_string(const char *name);
static string string_from_type(DeviceType type);
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index 36fe9bfc92b..16908b0244a 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -208,8 +208,8 @@ public:
KERNEL_NAME_EVAL(cpu_avx, name), \
KERNEL_NAME_EVAL(cpu_avx2, name)
- CPUDevice(DeviceInfo& info_, Stats &stats_, bool background_)
- : Device(info_, stats_, background_),
+ CPUDevice(DeviceInfo& info_, Stats &stats_, Profiler &profiler_, bool background_)
+ : Device(info_, stats_, profiler_, background_),
texture_info(this, "__texture_info", MEM_TEXTURE),
#define REGISTER_KERNEL(name) name ## _kernel(KERNEL_FUNCTIONS(name))
REGISTER_KERNEL(path_trace),
@@ -477,6 +477,8 @@ public:
bool denoising_non_local_means(device_ptr image_ptr, device_ptr guide_ptr, device_ptr variance_ptr, device_ptr out_ptr,
DenoisingTask *task)
{
+ ProfilingHelper profiling(task->profiler, PROFILING_DENOISING_NON_LOCAL_MEANS);
+
int4 rect = task->rect;
int r = task->nlm_state.r;
int f = task->nlm_state.f;
@@ -529,6 +531,8 @@ public:
bool denoising_construct_transform(DenoisingTask *task)
{
+ ProfilingHelper profiling(task->profiler, PROFILING_DENOISING_CONSTRUCT_TRANSFORM);
+
for(int y = 0; y < task->filter_area.w; y++) {
for(int x = 0; x < task->filter_area.z; x++) {
filter_construct_transform_kernel()((float*) task->buffer.mem.device_pointer,
@@ -551,6 +555,8 @@ public:
device_ptr output_ptr,
DenoisingTask *task)
{
+ ProfilingHelper profiling(task->profiler, PROFILING_DENOISING_RECONSTRUCT);
+
mem_zero(task->storage.XtWX);
mem_zero(task->storage.XtWY);
@@ -609,8 +615,10 @@ public:
bool denoising_combine_halves(device_ptr a_ptr, device_ptr b_ptr,
device_ptr mean_ptr, device_ptr variance_ptr,
- int r, int4 rect, DenoisingTask * /*task*/)
+ int r, int4 rect, DenoisingTask *task)
{
+ ProfilingHelper profiling(task->profiler, PROFILING_DENOISING_COMBINE_HALVES);
+
for(int y = rect.y; y < rect.w; y++) {
for(int x = rect.x; x < rect.z; x++) {
filter_combine_halves_kernel()(x, y,
@@ -629,6 +637,8 @@ public:
device_ptr sample_variance_ptr, device_ptr sv_variance_ptr,
device_ptr buffer_variance_ptr, DenoisingTask *task)
{
+ ProfilingHelper profiling(task->profiler, PROFILING_DENOISING_DIVIDE_SHADOW);
+
for(int y = task->rect.y; y < task->rect.w; y++) {
for(int x = task->rect.x; x < task->rect.z; x++) {
filter_divide_shadow_kernel()(task->render_buffer.samples,
@@ -653,6 +663,8 @@ public:
device_ptr variance_ptr,
DenoisingTask *task)
{
+ ProfilingHelper profiling(task->profiler, PROFILING_DENOISING_GET_FEATURE);
+
for(int y = task->rect.y; y < task->rect.w; y++) {
for(int x = task->rect.x; x < task->rect.z; x++) {
filter_get_feature_kernel()(task->render_buffer.samples,
@@ -676,6 +688,8 @@ public:
device_ptr output_ptr,
DenoisingTask *task)
{
+ ProfilingHelper profiling(task->profiler, PROFILING_DENOISING_DETECT_OUTLIERS);
+
for(int y = task->rect.y; y < task->rect.w; y++) {
for(int x = task->rect.x; x < task->rect.z; x++) {
filter_detect_outliers_kernel()(x, y,
@@ -735,6 +749,8 @@ public:
void denoise(DenoisingTask& denoising, RenderTile &tile)
{
+ ProfilingHelper profiling(denoising.profiler, PROFILING_DENOISING);
+
tile.sample = tile.start_sample + tile.num_samples;
denoising.functions.construct_transform = function_bind(&CPUDevice::denoising_construct_transform, this, &denoising);
@@ -765,6 +781,8 @@ public:
KernelGlobals *kg = new ((void*) kgbuffer.device_pointer) KernelGlobals(thread_kernel_globals_init());
+ profiler.add_state(&kg->profiler);
+
CPUSplitKernel *split_kernel = NULL;
if(use_split_kernel) {
split_kernel = new CPUSplitKernel(this);
@@ -778,6 +796,7 @@ public:
RenderTile tile;
DenoisingTask denoising(this, task);
+ denoising.profiler = &kg->profiler;
while(task.acquire_tile(this, tile)) {
if(tile.task == RenderTile::PATH_TRACE) {
@@ -802,6 +821,8 @@ public:
}
}
+ profiler.remove_state(&kg->profiler);
+
thread_kernel_globals_free((KernelGlobals*)kgbuffer.device_pointer);
kg->~KernelGlobals();
kgbuffer.free();
@@ -1044,9 +1065,9 @@ uint64_t CPUSplitKernel::state_buffer_size(device_memory& kernel_globals, device
return split_data_buffer_size(kg, num_threads);
}
-Device *device_cpu_create(DeviceInfo& info, Stats &stats, bool background)
+Device *device_cpu_create(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background)
{
- return new CPUDevice(info, stats, background);
+ return new CPUDevice(info, stats, profiler, background);
}
void device_cpu_info(vector<DeviceInfo>& devices)
@@ -1061,6 +1082,7 @@ void device_cpu_info(vector<DeviceInfo>& devices)
info.has_volume_decoupled = true;
info.has_osl = true;
info.has_half_images = true;
+ info.has_profiling = true;
devices.insert(devices.begin(), info);
}
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 2da113f2edb..a788a8627d8 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -236,8 +236,8 @@ public:
cuda_error_documentation();
}
- CUDADevice(DeviceInfo& info, Stats &stats, bool background_)
- : Device(info, stats, background_),
+ CUDADevice(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background_)
+ : Device(info, stats, profiler, background_),
texture_info(this, "__texture_info", MEM_TEXTURE)
{
first_error = true;
@@ -2414,9 +2414,9 @@ bool device_cuda_init()
#endif /* WITH_CUDA_DYNLOAD */
}
-Device *device_cuda_create(DeviceInfo& info, Stats &stats, bool background)
+Device *device_cuda_create(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background)
{
- return new CUDADevice(info, stats, background);
+ return new CUDADevice(info, stats, profiler, background);
}
static CUresult device_cuda_safe_init()
diff --git a/intern/cycles/device/device_denoising.cpp b/intern/cycles/device/device_denoising.cpp
index 78c65a3d22d..433cbd3c265 100644
--- a/intern/cycles/device/device_denoising.cpp
+++ b/intern/cycles/device/device_denoising.cpp
@@ -22,6 +22,7 @@ CCL_NAMESPACE_BEGIN
DenoisingTask::DenoisingTask(Device *device, const DeviceTask &task)
: tile_info_mem(device, "denoising tile info mem", MEM_READ_WRITE),
+ profiler(NULL),
storage(device),
buffer(device),
device(device)
diff --git a/intern/cycles/device/device_denoising.h b/intern/cycles/device/device_denoising.h
index 8e0666d0e59..beae60c220f 100644
--- a/intern/cycles/device/device_denoising.h
+++ b/intern/cycles/device/device_denoising.h
@@ -23,6 +23,8 @@
#include "kernel/filter/filter_defines.h"
+#include "util/util_profiling.h"
+
CCL_NAMESPACE_BEGIN
class DenoisingTask {
@@ -51,6 +53,8 @@ public:
TileInfo *tile_info;
device_vector<int> tile_info_mem;
+ ProfilingState *profiler;
+
int4 rect;
int4 filter_area;
diff --git a/intern/cycles/device/device_intern.h b/intern/cycles/device/device_intern.h
index e6495c2bff3..0b26057c3ba 100644
--- a/intern/cycles/device/device_intern.h
+++ b/intern/cycles/device/device_intern.h
@@ -21,13 +21,13 @@ CCL_NAMESPACE_BEGIN
class Device;
-Device *device_cpu_create(DeviceInfo& info, Stats &stats, bool background);
+Device *device_cpu_create(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background);
bool device_opencl_init();
-Device *device_opencl_create(DeviceInfo& info, Stats &stats, bool background);
+Device *device_opencl_create(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background);
bool device_cuda_init();
-Device *device_cuda_create(DeviceInfo& info, Stats &stats, bool background);
-Device *device_network_create(DeviceInfo& info, Stats &stats, const char *address);
-Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background);
+Device *device_cuda_create(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background);
+Device *device_network_create(DeviceInfo& info, Stats &stats, Profiler &profiler, const char *address);
+Device *device_multi_create(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background);
void device_cpu_info(vector<DeviceInfo>& devices);
void device_opencl_info(vector<DeviceInfo>& devices);
diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp
index 67f0f880287..3308af4f53f 100644
--- a/intern/cycles/device/device_multi.cpp
+++ b/intern/cycles/device/device_multi.cpp
@@ -45,11 +45,11 @@ public:
list<SubDevice> devices;
device_ptr unique_key;
- MultiDevice(DeviceInfo& info, Stats &stats, bool background_)
- : Device(info, stats, background_), unique_key(1)
+ MultiDevice(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background_)
+ : Device(info, stats, profiler, background_), unique_key(1)
{
foreach(DeviceInfo& subinfo, info.multi_devices) {
- Device *device = Device::create(subinfo, sub_stats_, background);
+ Device *device = Device::create(subinfo, sub_stats_, profiler, background);
/* Always add CPU devices at the back since GPU devices can change
* host memory pointers, which CPU uses as device pointer. */
@@ -69,7 +69,7 @@ public:
vector<string> servers = discovery.get_server_list();
foreach(string& server, servers) {
- Device *device = device_network_create(info, stats, server.c_str());
+ Device *device = device_network_create(info, stats, profiler, server.c_str());
if(device)
devices.push_back(SubDevice(device));
}
@@ -381,9 +381,9 @@ protected:
Stats sub_stats_;
};
-Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background)
+Device *device_multi_create(DeviceInfo& info, Stats &stats, Profiler& profiler, bool background)
{
- return new MultiDevice(info, stats, background);
+ return new MultiDevice(info, stats, profiler, background);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp
index b6e18621f12..91628490b51 100644
--- a/intern/cycles/device/device_network.cpp
+++ b/intern/cycles/device/device_network.cpp
@@ -56,8 +56,8 @@ public:
return false;
}
- NetworkDevice(DeviceInfo& info, Stats &stats, const char *address)
- : Device(info, stats, true), socket(io_service)
+ NetworkDevice(DeviceInfo& info, Stats &stats, Profiler &profiler, const char *address)
+ : Device(info, stats, profiler, true), socket(io_service)
{
error_func = NetworkError();
stringstream portstr;
@@ -293,9 +293,9 @@ private:
NetworkError error_func;
};
-Device *device_network_create(DeviceInfo& info, Stats &stats, const char *address)
+Device *device_network_create(DeviceInfo& info, Stats &stats, Profiler &profiler, const char *address)
{
- return new NetworkDevice(info, stats, address);
+ return new NetworkDevice(info, stats, profiler, address);
}
void device_network_info(vector<DeviceInfo>& devices)
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 71410f80d57..1e8c6b2dd0e 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -27,7 +27,7 @@
CCL_NAMESPACE_BEGIN
-Device *device_opencl_create(DeviceInfo& info, Stats &stats, bool background)
+Device *device_opencl_create(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background)
{
vector<OpenCLPlatformDevice> usable_devices;
OpenCLInfo::get_usable_devices(&usable_devices);
@@ -37,10 +37,10 @@ Device *device_opencl_create(DeviceInfo& info, Stats &stats, bool background)
const cl_device_type device_type = platform_device.device_type;
if(OpenCLInfo::kernel_use_split(platform_name, device_type)) {
VLOG(1) << "Using split kernel.";
- return opencl_create_split_device(info, stats, background);
+ return opencl_create_split_device(info, stats, profiler, background);
} else {
VLOG(1) << "Using mega kernel.";
- return opencl_create_mega_device(info, stats, background);
+ return opencl_create_mega_device(info, stats, profiler, background);
}
}
diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h
index 8cb7f6d0b82..ea7ed4f1909 100644
--- a/intern/cycles/device/opencl/opencl.h
+++ b/intern/cycles/device/opencl/opencl.h
@@ -333,7 +333,7 @@ public:
void opencl_error(const string& message);
void opencl_assert_err(cl_int err, const char* where);
- OpenCLDeviceBase(DeviceInfo& info, Stats &stats, bool background_);
+ OpenCLDeviceBase(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background_);
~OpenCLDeviceBase();
static void CL_CALLBACK context_notify_callback(const char *err_info,
@@ -568,8 +568,8 @@ protected:
void flush_texture_buffers();
};
-Device *opencl_create_mega_device(DeviceInfo& info, Stats& stats, bool background);
-Device *opencl_create_split_device(DeviceInfo& info, Stats& stats, bool background);
+Device *opencl_create_mega_device(DeviceInfo& info, Stats& stats, Profiler &profiler, bool background);
+Device *opencl_create_split_device(DeviceInfo& info, Stats& stats, Profiler &profiler, bool background);
CCL_NAMESPACE_END
diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp
index 1e73d37d7a4..d4d7c0f74bc 100644
--- a/intern/cycles/device/opencl/opencl_base.cpp
+++ b/intern/cycles/device/opencl/opencl_base.cpp
@@ -72,8 +72,8 @@ void OpenCLDeviceBase::opencl_assert_err(cl_int err, const char* where)
}
}
-OpenCLDeviceBase::OpenCLDeviceBase(DeviceInfo& info, Stats &stats, bool background_)
-: Device(info, stats, background_),
+OpenCLDeviceBase::OpenCLDeviceBase(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background_)
+: Device(info, stats, profiler, background_),
memory_manager(this),
texture_info(this, "__texture_info", MEM_TEXTURE)
{
diff --git a/intern/cycles/device/opencl/opencl_mega.cpp b/intern/cycles/device/opencl/opencl_mega.cpp
index 89001366d9d..0a7bf96fed7 100644
--- a/intern/cycles/device/opencl/opencl_mega.cpp
+++ b/intern/cycles/device/opencl/opencl_mega.cpp
@@ -33,8 +33,8 @@ class OpenCLDeviceMegaKernel : public OpenCLDeviceBase
public:
OpenCLProgram path_trace_program;
- OpenCLDeviceMegaKernel(DeviceInfo& info, Stats &stats, bool background_)
- : OpenCLDeviceBase(info, stats, background_),
+ OpenCLDeviceMegaKernel(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background_)
+ : OpenCLDeviceBase(info, stats, profiler, background_),
path_trace_program(this, "megakernel", "kernel.cl", "-D__COMPILE_ONLY_MEGAKERNEL__ ")
{
}
@@ -160,9 +160,9 @@ public:
}
};
-Device *opencl_create_mega_device(DeviceInfo& info, Stats& stats, bool background)
+Device *opencl_create_mega_device(DeviceInfo& info, Stats& stats, Profiler &profiler, bool background)
{
- return new OpenCLDeviceMegaKernel(info, stats, background);
+ return new OpenCLDeviceMegaKernel(info, stats, profiler, background);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp
index adb73bc6e2c..5a2555f9f80 100644
--- a/intern/cycles/device/opencl/opencl_split.cpp
+++ b/intern/cycles/device/opencl/opencl_split.cpp
@@ -79,7 +79,7 @@ public:
OpenCLProgram program_data_init;
OpenCLProgram program_state_buffer_size;
- OpenCLDeviceSplitKernel(DeviceInfo& info, Stats &stats, bool background_);
+ OpenCLDeviceSplitKernel(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background_);
~OpenCLDeviceSplitKernel()
{
@@ -448,17 +448,17 @@ public:
}
};
-OpenCLDeviceSplitKernel::OpenCLDeviceSplitKernel(DeviceInfo& info, Stats &stats, bool background_)
-: OpenCLDeviceBase(info, stats, background_)
+OpenCLDeviceSplitKernel::OpenCLDeviceSplitKernel(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background_)
+: OpenCLDeviceBase(info, stats, profiler, background_)
{
split_kernel = new OpenCLSplitKernel(this);
background = background_;
}
-Device *opencl_create_split_device(DeviceInfo& info, Stats& stats, bool background)
+Device *opencl_create_split_device(DeviceInfo& info, Stats& stats, Profiler &profiler, bool background)
{
- return new OpenCLDeviceSplitKernel(info, stats, background);
+ return new OpenCLDeviceSplitKernel(info, stats, profiler, background);
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/device/opencl/opencl_util.cpp b/intern/cycles/device/opencl/opencl_util.cpp
index 4c9f3cd6ef7..f43aa5f350a 100644
--- a/intern/cycles/device/opencl/opencl_util.cpp
+++ b/intern/cycles/device/opencl/opencl_util.cpp
@@ -645,7 +645,7 @@ bool OpenCLInfo::device_supported(const string& platform_name,
return true;
}
if(platform_name == "Apple" && device_type == CL_DEVICE_TYPE_GPU) {
- return true;
+ return false;
}
return false;
}
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 92cb66bdec9..78e03a7f066 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -110,6 +110,7 @@ set(SRC_HEADERS
kernel_path_surface.h
kernel_path_subsurface.h
kernel_path_volume.h
+ kernel_profiling.h
kernel_projection.h
kernel_queues.h
kernel_random.h
@@ -342,11 +343,11 @@ if(WITH_CYCLES_CUDA_BINARIES)
set(CUDA_VERSION "${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}")
# warn for other versions
- if(CUDA_VERSION MATCHES "90" OR CUDA_VERSION MATCHES "91")
+ if(CUDA_VERSION MATCHES "90" OR CUDA_VERSION MATCHES "91" OR CUDA_VERSION MATCHES "100")
else()
message(WARNING
"CUDA version ${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} detected, "
- "build may succeed but only CUDA 9.0 and 9.1 are officially supported")
+ "build may succeed but only CUDA 9.0, 9.1 and 10.0 are officially supported")
endif()
# build for each arch
@@ -396,17 +397,29 @@ if(WITH_CYCLES_CUDA_BINARIES)
set(cuda_flags ${cuda_flags} -D __KERNEL_DEBUG__)
endif()
- if(WITH_CYCLES_CUBIN_COMPILER)
+ # Workaround to build only sm_7x kernels with CUDA 10, until
+ # older kernels work well with this version.
+ if(DEFINED CUDA10_NVCC_EXECUTABLE AND (${arch} MATCHES "sm_7."))
+ set(with_cubin_compiler OFF)
+ set(cuda_nvcc_executable "${CUDA10_NVCC_EXECUTABLE}")
+ set(cuda_toolkit_root_dir "${CUDA10_TOOLKIT_ROOT_DIR}")
+ else()
+ set(with_cubin_compiler ${WITH_CYCLES_CUBIN_COMPILER})
+ set(cuda_nvcc_executable "${CUDA_NVCC_EXECUTABLE}")
+ set(cuda_toolkit_root_dir "${CUDA_TOOLKIT_ROOT_DIR}")
+ endif()
+
+ if(with_cubin_compiler)
string(SUBSTRING ${arch} 3 -1 CUDA_ARCH)
# Needed to find libnvrtc-builtins.so. Can't do it from inside
# cycles_cubin_cc since the env variable is read before main()
if(APPLE)
set(CUBIN_CC_ENV ${CMAKE_COMMAND}
- -E env DYLD_LIBRARY_PATH="${CUDA_TOOLKIT_ROOT_DIR}/lib")
+ -E env DYLD_LIBRARY_PATH="${cuda_toolkit_root_dir}/lib")
elseif(UNIX)
set(CUBIN_CC_ENV ${CMAKE_COMMAND}
- -E env LD_LIBRARY_PATH="${CUDA_TOOLKIT_ROOT_DIR}/lib64")
+ -E env LD_LIBRARY_PATH="${cuda_toolkit_root_dir}/lib64")
endif()
add_custom_command(
@@ -417,12 +430,12 @@ if(WITH_CYCLES_CUDA_BINARIES)
-i ${CMAKE_CURRENT_SOURCE_DIR}${cuda_kernel_src}
${cuda_flags}
-v
- -cuda-toolkit-dir "${CUDA_TOOLKIT_ROOT_DIR}"
+ -cuda-toolkit-dir "${cuda_toolkit_root_dir}"
DEPENDS ${kernel_sources} cycles_cubin_cc)
else()
add_custom_command(
OUTPUT ${cuda_cubin}
- COMMAND ${CUDA_NVCC_EXECUTABLE}
+ COMMAND ${cuda_nvcc_executable}
-arch=${arch}
${CUDA_NVCC_FLAGS}
--cubin
@@ -441,6 +454,8 @@ if(WITH_CYCLES_CUDA_BINARIES)
foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
if(${arch} MATCHES "sm_2.")
message(STATUS "CUDA binaries for ${arch} are no longer supported, skipped.")
+ elseif(${arch} MATCHES "sm_7." AND (${CUDA_VERSION} VERSION_LESS 10.0))
+ message(STATUS "CUDA binaries for ${arch} require CUDA 10.0+, skipped.")
else()
# Compile regular kernel
CYCLES_CUDA_KERNEL_ADD(${arch} ${prev_arch} filter "" "${cuda_filter_sources}" FALSE)
diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h
index 6708a3efac1..284b1e9208c 100644
--- a/intern/cycles/kernel/bvh/bvh.h
+++ b/intern/cycles/kernel/bvh/bvh.h
@@ -186,6 +186,8 @@ ccl_device_intersect bool scene_intersect(KernelGlobals *kg,
float difl,
float extmax)
{
+ PROFILING_INIT(kg, PROFILING_INTERSECT);
+
if(!scene_intersect_valid(&ray)) {
return false;
}
@@ -248,6 +250,8 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals *kg,
uint *lcg_state,
int max_hits)
{
+ PROFILING_INIT(kg, PROFILING_INTERSECT_LOCAL);
+
if(!scene_intersect_valid(&ray)) {
return false;
}
@@ -327,6 +331,8 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg,
uint max_hits,
uint *num_hits)
{
+ PROFILING_INIT(kg, PROFILING_INTERSECT_SHADOW_ALL);
+
if(!scene_intersect_valid(ray)) {
return false;
}
@@ -407,6 +413,8 @@ ccl_device_intersect bool scene_intersect_volume(KernelGlobals *kg,
Intersection *isect,
const uint visibility)
{
+ PROFILING_INIT(kg, PROFILING_INTERSECT_VOLUME);
+
if(!scene_intersect_valid(ray)) {
return false;
}
@@ -438,6 +446,8 @@ ccl_device_intersect uint scene_intersect_volume_all(KernelGlobals *kg,
const uint max_hits,
const uint visibility)
{
+ PROFILING_INIT(kg, PROFILING_INTERSECT_VOLUME_ALL);
+
if(!scene_intersect_valid(ray)) {
return false;
}
diff --git a/intern/cycles/kernel/kernel_globals.h b/intern/cycles/kernel/kernel_globals.h
index 37402f42863..59f1e252d21 100644
--- a/intern/cycles/kernel/kernel_globals.h
+++ b/intern/cycles/kernel/kernel_globals.h
@@ -19,6 +19,8 @@
#ifndef __KERNEL_GLOBALS_H__
#define __KERNEL_GLOBALS_H__
+#include "kernel/kernel_profiling.h"
+
#ifdef __KERNEL_CPU__
# include "util/util_vector.h"
# include "util/util_map.h"
@@ -82,6 +84,8 @@ typedef struct KernelGlobals {
int2 global_size;
int2 global_id;
+
+ ProfilingState profiler;
} KernelGlobals;
#endif /* __KERNEL_CPU__ */
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h
index 1f5929e4938..08e9db05c39 100644
--- a/intern/cycles/kernel/kernel_passes.h
+++ b/intern/cycles/kernel/kernel_passes.h
@@ -376,6 +376,9 @@ ccl_device_inline void kernel_write_result(KernelGlobals *kg,
int sample,
PathRadiance *L)
{
+ PROFILING_INIT(kg, PROFILING_WRITE_RESULT);
+ PROFILING_OBJECT(PRIM_NONE);
+
float alpha;
float3 L_sum = path_radiance_clamp_and_sum(kg, L, &alpha);
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index cb1f410b09f..a1fc6028293 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -57,6 +57,8 @@ ccl_device_forceinline bool kernel_path_scene_intersect(
Intersection *isect,
PathRadiance *L)
{
+ PROFILING_INIT(kg, PROFILING_SCENE_INTERSECT);
+
uint visibility = path_state_ray_visibility(kg, state);
if(path_state_ao_bounce(kg, state)) {
@@ -105,6 +107,8 @@ ccl_device_forceinline void kernel_path_lamp_emission(
ShaderData *emission_sd,
PathRadiance *L)
{
+ PROFILING_INIT(kg, PROFILING_INDIRECT_EMISSION);
+
#ifdef __LAMP_MIS__
if(kernel_data.integrator.use_lamp_mis && !(state->flag & PATH_RAY_CAMERA)) {
/* ray starting from previous non-transparent bounce */
@@ -172,6 +176,8 @@ ccl_device_forceinline VolumeIntegrateResult kernel_path_volume(
ShaderData *emission_sd,
PathRadiance *L)
{
+ PROFILING_INIT(kg, PROFILING_VOLUME);
+
/* Sanitize volume stack. */
if(!hit) {
kernel_volume_clean_stack(kg, state->volume_stack);
@@ -278,6 +284,8 @@ ccl_device_forceinline bool kernel_path_shader_apply(
PathRadiance *L,
ccl_global float *buffer)
{
+ PROFILING_INIT(kg, PROFILING_SHADER_APPLY);
+
#ifdef __SHADOW_TRICKS__
if((sd->object_flag & SD_OBJECT_SHADOW_CATCHER)) {
if(state->flag & PATH_RAY_TRANSPARENT_BACKGROUND) {
@@ -355,6 +363,8 @@ ccl_device_noinline void kernel_path_ao(KernelGlobals *kg,
float3 throughput,
float3 ao_alpha)
{
+ PROFILING_INIT(kg, PROFILING_AO);
+
/* todo: solve correlation */
float bsdf_u, bsdf_v;
@@ -568,6 +578,8 @@ ccl_device_forceinline void kernel_path_integrate(
ccl_global float *buffer,
ShaderData *emission_sd)
{
+ PROFILING_INIT(kg, PROFILING_PATH_INTEGRATE);
+
/* Shader data memory used for both volumes and surfaces, saves stack space. */
ShaderData sd;
@@ -719,6 +731,8 @@ ccl_device void kernel_path_trace(KernelGlobals *kg,
ccl_global float *buffer,
int sample, int x, int y, int offset, int stride)
{
+ PROFILING_INIT(kg, PROFILING_RAY_SETUP);
+
/* buffer offset */
int index = offset + x + y*stride;
int pass_stride = kernel_data.film.pass_stride;
diff --git a/intern/cycles/kernel/kernel_path_subsurface.h b/intern/cycles/kernel/kernel_path_subsurface.h
index ff4a8a9d580..962776f21c1 100644
--- a/intern/cycles/kernel/kernel_path_subsurface.h
+++ b/intern/cycles/kernel/kernel_path_subsurface.h
@@ -32,6 +32,8 @@ bool kernel_path_subsurface_scatter(
ccl_addr_space float3 *throughput,
ccl_addr_space SubsurfaceIndirectRays *ss_indirect)
{
+ PROFILING_INIT(kg, PROFILING_SUBSURFACE);
+
float bssrdf_u, bssrdf_v;
path_state_rng_2D(kg, state, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h
index c9202ccb16d..0d18a1e8c77 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -217,6 +217,8 @@ ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg,
ShaderData *sd, ShaderData *emission_sd, float3 throughput, ccl_addr_space PathState *state,
PathRadiance *L)
{
+ PROFILING_INIT(kg, PROFILING_CONNECT_LIGHT);
+
#ifdef __EMISSION__
if(!(kernel_data.integrator.use_direct_light && (sd->flag & SD_BSDF_HAS_EVAL)))
return;
@@ -274,6 +276,8 @@ ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg,
PathRadianceState *L_state,
ccl_addr_space Ray *ray)
{
+ PROFILING_INIT(kg, PROFILING_SURFACE_BOUNCE);
+
/* no BSDF? we can stop here */
if(sd->flag & SD_BSDF) {
/* sample BSDF */
diff --git a/intern/cycles/kernel/kernel_profiling.h b/intern/cycles/kernel/kernel_profiling.h
new file mode 100644
index 00000000000..a46d6376473
--- /dev/null
+++ b/intern/cycles/kernel/kernel_profiling.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2011-2018 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __KERNEL_PROFILING_H__
+#define __KERNEL_PROFILING_H__
+
+#ifdef __KERNEL_CPU__
+# include "util/util_profiling.h"
+#endif
+
+CCL_NAMESPACE_BEGIN
+
+#ifdef __KERNEL_CPU__
+# define PROFILING_INIT(kg, event) ProfilingHelper profiling_helper(&kg->profiler, event)
+# define PROFILING_EVENT(event) profiling_helper.set_event(event)
+# define PROFILING_SHADER(shader) if((shader) != SHADER_NONE) { profiling_helper.set_shader((shader) & SHADER_MASK); }
+# define PROFILING_OBJECT(object) if((object) != PRIM_NONE) { profiling_helper.set_object(object); }
+#else
+# define PROFILING_INIT(kg, event)
+# define PROFILING_EVENT(event)
+# define PROFILING_SHADER(shader)
+# define PROFILING_OBJECT(object)
+#endif /* __KERNEL_CPU__ */
+
+CCL_NAMESPACE_END
+
+#endif /* __KERNEL_PROFILING_H__ */
diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h
index af883aa715b..4b2e675bb21 100644
--- a/intern/cycles/kernel/kernel_shader.h
+++ b/intern/cycles/kernel/kernel_shader.h
@@ -54,6 +54,8 @@ ccl_device_noinline void shader_setup_from_ray(KernelGlobals *kg,
const Intersection *isect,
const Ray *ray)
{
+ PROFILING_INIT(kg, PROFILING_SHADER_SETUP);
+
#ifdef __INSTANCING__
sd->object = (isect->object == PRIM_NONE)? kernel_tex_fetch(__prim_object, isect->prim): isect->object;
#endif
@@ -147,6 +149,9 @@ ccl_device_noinline void shader_setup_from_ray(KernelGlobals *kg,
differential_incoming(&sd->dI, ray->dD);
differential_dudv(&sd->du, &sd->dv, sd->dPdu, sd->dPdv, sd->dP, sd->Ng);
#endif
+
+ PROFILING_SHADER(sd->shader);
+ PROFILING_OBJECT(sd->object);
}
/* ShaderData setup from BSSRDF scatter */
@@ -163,6 +168,8 @@ void shader_setup_from_subsurface(
const Intersection *isect,
const Ray *ray)
{
+ PROFILING_INIT(kg, PROFILING_SHADER_SETUP);
+
const bool backfacing = sd->flag & SD_BACKFACING;
/* object, matrices, time, ray_length stay the same */
@@ -233,6 +240,8 @@ void shader_setup_from_subsurface(
differential_dudv(&sd->du, &sd->dv, sd->dPdu, sd->dPdv, sd->dP, sd->Ng);
/* don't modify dP and dI */
# endif
+
+ PROFILING_SHADER(sd->shader);
}
#endif
@@ -249,6 +258,8 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals *kg,
bool object_space,
int lamp)
{
+ PROFILING_INIT(kg, PROFILING_SHADER_SETUP);
+
/* vectors */
sd->P = P;
sd->N = Ng;
@@ -353,6 +364,9 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals *kg,
sd->du = differential_zero();
sd->dv = differential_zero();
#endif
+
+ PROFILING_SHADER(sd->shader);
+ PROFILING_OBJECT(sd->object);
}
/* ShaderData setup for displacement */
@@ -380,6 +394,8 @@ ccl_device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray)
{
+ PROFILING_INIT(kg, PROFILING_SHADER_SETUP);
+
/* vectors */
sd->P = ray->D;
sd->N = -ray->D;
@@ -414,6 +430,9 @@ ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderDat
sd->du = differential_zero();
sd->dv = differential_zero();
#endif
+
+ PROFILING_SHADER(sd->shader);
+ PROFILING_OBJECT(sd->object);
}
/* ShaderData setup from point inside volume */
@@ -421,6 +440,8 @@ ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderDat
#ifdef __VOLUME__
ccl_device_inline void shader_setup_from_volume(KernelGlobals *kg, ShaderData *sd, const Ray *ray)
{
+ PROFILING_INIT(kg, PROFILING_SHADER_SETUP);
+
/* vectors */
sd->P = ray->P;
sd->N = -ray->D;
@@ -461,6 +482,9 @@ ccl_device_inline void shader_setup_from_volume(KernelGlobals *kg, ShaderData *s
/* for NDC coordinates */
sd->ray_P = ray->P;
sd->ray_dP = ray->dP;
+
+ PROFILING_SHADER(sd->shader);
+ PROFILING_OBJECT(sd->object);
}
#endif /* __VOLUME__ */
@@ -591,6 +615,8 @@ void shader_bsdf_eval(KernelGlobals *kg,
float light_pdf,
bool use_mis)
{
+ PROFILING_INIT(kg, PROFILING_CLOSURE_EVAL);
+
bsdf_eval_init(eval, NBUILTIN_CLOSURES, make_float3(0.0f, 0.0f, 0.0f), kernel_data.film.use_light_pass);
#ifdef __BRANCHED_PATH__
@@ -720,6 +746,8 @@ ccl_device_inline int shader_bsdf_sample(KernelGlobals *kg,
differential3 *domega_in,
float *pdf)
{
+ PROFILING_INIT(kg, PROFILING_CLOSURE_SAMPLE);
+
const ShaderClosure *sc = shader_bsdf_pick(sd, &randu);
if(sc == NULL) {
*pdf = 0.0f;
@@ -751,6 +779,8 @@ ccl_device int shader_bsdf_sample_closure(KernelGlobals *kg, ShaderData *sd,
const ShaderClosure *sc, float randu, float randv, BsdfEval *bsdf_eval,
float3 *omega_in, differential3 *domega_in, float *pdf)
{
+ PROFILING_INIT(kg, PROFILING_CLOSURE_SAMPLE);
+
int label;
float3 eval;
@@ -984,6 +1014,8 @@ ccl_device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
ccl_addr_space PathState *state, int path_flag)
{
+ PROFILING_INIT(kg, PROFILING_SHADER_EVAL);
+
/* If path is being terminated, we are tracing a shadow ray or evaluating
* emission, then we don't need to store closures. The emission and shadow
* shader data also do not have a closure array to save GPU memory. */
@@ -1084,6 +1116,8 @@ ccl_device_inline void _shader_volume_phase_multi_eval(const ShaderData *sd, con
ccl_device void shader_volume_phase_eval(KernelGlobals *kg, const ShaderData *sd,
const float3 omega_in, BsdfEval *eval, float *pdf)
{
+ PROFILING_INIT(kg, PROFILING_CLOSURE_VOLUME_EVAL);
+
bsdf_eval_init(eval, NBUILTIN_CLOSURES, make_float3(0.0f, 0.0f, 0.0f), kernel_data.film.use_light_pass);
_shader_volume_phase_multi_eval(sd, omega_in, pdf, -1, eval, 0.0f, 0.0f);
@@ -1093,6 +1127,8 @@ ccl_device int shader_volume_phase_sample(KernelGlobals *kg, const ShaderData *s
float randu, float randv, BsdfEval *phase_eval,
float3 *omega_in, differential3 *domega_in, float *pdf)
{
+ PROFILING_INIT(kg, PROFILING_CLOSURE_VOLUME_SAMPLE);
+
int sampled = 0;
if(sd->num_closure > 1) {
@@ -1151,6 +1187,8 @@ ccl_device int shader_phase_sample_closure(KernelGlobals *kg, const ShaderData *
const ShaderClosure *sc, float randu, float randv, BsdfEval *phase_eval,
float3 *omega_in, differential3 *domega_in, float *pdf)
{
+ PROFILING_INIT(kg, PROFILING_CLOSURE_VOLUME_SAMPLE);
+
int label;
float3 eval;
diff --git a/intern/cycles/kernel/kernels/cuda/kernel_config.h b/intern/cycles/kernel/kernels/cuda/kernel_config.h
index 3808898c5ca..6d41dc15785 100644
--- a/intern/cycles/kernel/kernels/cuda/kernel_config.h
+++ b/intern/cycles/kernel/kernels/cuda/kernel_config.h
@@ -52,8 +52,8 @@
# define CUDA_KERNEL_MAX_REGISTERS 63
# define CUDA_KERNEL_BRANCHED_MAX_REGISTERS 63
-/* 5.0, 5.2, 5.3, 6.0, 6.1 */
-#elif __CUDA_ARCH__ >= 500
+/* 5.x, 6.x */
+#elif __CUDA_ARCH__ <= 699
# define CUDA_MULTIPRESSOR_MAX_REGISTERS 65536
# define CUDA_MULTIPROCESSOR_MAX_BLOCKS 32
# define CUDA_BLOCK_MAX_THREADS 1024
@@ -62,13 +62,25 @@
/* tunable parameters */
# define CUDA_THREADS_BLOCK_WIDTH 16
/* CUDA 9.0 seems to cause slowdowns on high-end Pascal cards unless we increase the number of registers */
-# if __CUDACC_VER_MAJOR__ == 9 && __CUDA_ARCH__ >= 600
+# if __CUDACC_VER_MAJOR__ >= 9 && __CUDA_ARCH__ >= 600
# define CUDA_KERNEL_MAX_REGISTERS 64
# else
# define CUDA_KERNEL_MAX_REGISTERS 48
# endif
# define CUDA_KERNEL_BRANCHED_MAX_REGISTERS 63
+/* 7.x */
+#elif __CUDA_ARCH__ <= 799
+# define CUDA_MULTIPRESSOR_MAX_REGISTERS 65536
+# define CUDA_MULTIPROCESSOR_MAX_BLOCKS 32
+# define CUDA_BLOCK_MAX_THREADS 1024
+# define CUDA_THREAD_MAX_REGISTERS 255
+
+/* tunable parameters */
+# define CUDA_THREADS_BLOCK_WIDTH 16
+# define CUDA_KERNEL_MAX_REGISTERS 64
+# define CUDA_KERNEL_BRANCHED_MAX_REGISTERS 72
+
/* unknown architecture */
#else
diff --git a/intern/cycles/kernel/shaders/node_brick_texture.osl b/intern/cycles/kernel/shaders/node_brick_texture.osl
index c303594681c..9d2e5b74ce6 100644
--- a/intern/cycles/kernel/shaders/node_brick_texture.osl
+++ b/intern/cycles/kernel/shaders/node_brick_texture.osl
@@ -19,10 +19,10 @@
/* Brick */
-float brick_noise(int n) /* fast integer noise */
+float brick_noise(int ns) /* fast integer noise */
{
int nn;
- n = (n + 1013) & 2147483647;
+ int n = (ns + 1013) & 2147483647;
n = (n >> 13) ^ n;
nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 2147483647;
return 0.5 * ((float)nn / 1073741824.0);
@@ -30,7 +30,7 @@ float brick_noise(int n) /* fast integer noise */
float brick(point p, float mortar_size, float mortar_smooth, float bias,
float BrickWidth, float row_height, float offset_amount, int offset_frequency,
- float squash_amount, int squash_frequency, float tint)
+ float squash_amount, int squash_frequency, output float tint)
{
int bricknum, rownum;
float offset = 0.0;
diff --git a/intern/cycles/kernel/shaders/node_checker_texture.osl b/intern/cycles/kernel/shaders/node_checker_texture.osl
index ae84c71dd42..e745cfaee06 100644
--- a/intern/cycles/kernel/shaders/node_checker_texture.osl
+++ b/intern/cycles/kernel/shaders/node_checker_texture.osl
@@ -19,11 +19,12 @@
/* Checker */
-float checker(point p)
+float checker(point ip)
{
- p[0] = (p[0] + 0.000001) * 0.999999;
- p[1] = (p[1] + 0.000001) * 0.999999;
- p[2] = (p[2] + 0.000001) * 0.999999;
+ point p;
+ p[0] = (ip[0] + 0.000001) * 0.999999;
+ p[1] = (ip[1] + 0.000001) * 0.999999;
+ p[2] = (ip[2] + 0.000001) * 0.999999;
int xi = (int)fabs(floor(p[0]));
int yi = (int)fabs(floor(p[1]));
diff --git a/intern/cycles/kernel/shaders/node_environment_texture.osl b/intern/cycles/kernel/shaders/node_environment_texture.osl
index 0a7f602226d..95d9d813969 100644
--- a/intern/cycles/kernel/shaders/node_environment_texture.osl
+++ b/intern/cycles/kernel/shaders/node_environment_texture.osl
@@ -25,8 +25,9 @@ vector environment_texture_direction_to_equirectangular(vector dir)
return vector(u, v, 0.0);
}
-vector environment_texture_direction_to_mirrorball(vector dir)
+vector environment_texture_direction_to_mirrorball(vector idir)
{
+ vector dir = idir;
dir[1] -= 1.0;
float div = 2.0 * sqrt(max(-0.5 * dir[1], 0.0));
diff --git a/intern/cycles/kernel/shaders/node_musgrave_texture.osl b/intern/cycles/kernel/shaders/node_musgrave_texture.osl
index 91f4fba5898..454b3834081 100644
--- a/intern/cycles/kernel/shaders/node_musgrave_texture.osl
+++ b/intern/cycles/kernel/shaders/node_musgrave_texture.osl
@@ -26,13 +26,14 @@
* from "Texturing and Modelling: A procedural approach"
*/
-float noise_musgrave_fBm(point p, float H, float lacunarity, float octaves)
+float noise_musgrave_fBm(point ip, float H, float lacunarity, float octaves)
{
float rmd;
float value = 0.0;
float pwr = 1.0;
float pwHL = pow(lacunarity, -H);
int i;
+ point p = ip;
for (i = 0; i < (int)octaves; i++) {
value += safe_noise(p, "signed") * pwr;
@@ -54,13 +55,14 @@ float noise_musgrave_fBm(point p, float H, float lacunarity, float octaves)
* octaves: number of frequencies in the fBm
*/
-float noise_musgrave_multi_fractal(point p, float H, float lacunarity, float octaves)
+float noise_musgrave_multi_fractal(point ip, float H, float lacunarity, float octaves)
{
float rmd;
float value = 1.0;
float pwr = 1.0;
float pwHL = pow(lacunarity, -H);
int i;
+ point p = ip;
for (i = 0; i < (int)octaves; i++) {
value *= (pwr * safe_noise(p, "signed") + 1.0);
@@ -83,12 +85,13 @@ float noise_musgrave_multi_fractal(point p, float H, float lacunarity, float oct
* offset: raises the terrain from `sea level'
*/
-float noise_musgrave_hetero_terrain(point p, float H, float lacunarity, float octaves, float offset)
+float noise_musgrave_hetero_terrain(point ip, float H, float lacunarity, float octaves, float offset)
{
float value, increment, rmd;
float pwHL = pow(lacunarity, -H);
float pwr = pwHL;
int i;
+ point p = ip;
/* first unscaled octave of function; later octaves are scaled */
value = offset + safe_noise(p, "signed");
@@ -118,13 +121,14 @@ float noise_musgrave_hetero_terrain(point p, float H, float lacunarity, float oc
* offset: raises the terrain from `sea level'
*/
-float noise_musgrave_hybrid_multi_fractal(point p, float H, float lacunarity,
+float noise_musgrave_hybrid_multi_fractal(point ip, float H, float lacunarity,
float octaves, float offset, float gain)
{
float result, signal, weight, rmd;
float pwHL = pow(lacunarity, -H);
float pwr = pwHL;
int i;
+ point p = ip;
result = safe_noise(p, "signed") + offset;
weight = gain * result;
@@ -156,13 +160,14 @@ float noise_musgrave_hybrid_multi_fractal(point p, float H, float lacunarity,
* offset: raises the terrain from `sea level'
*/
-float noise_musgrave_ridged_multi_fractal(point p, float H, float lacunarity,
+float noise_musgrave_ridged_multi_fractal(point ip, float H, float lacunarity,
float octaves, float offset, float gain)
{
float result, signal, weight;
float pwHL = pow(lacunarity, -H);
float pwr = pwHL;
int i;
+ point p = ip;
signal = offset - fabs(safe_noise(p, "signed"));
signal *= signal;
diff --git a/intern/cycles/kernel/shaders/node_noise_texture.osl b/intern/cycles/kernel/shaders/node_noise_texture.osl
index e83e5b5b211..42a30897341 100644
--- a/intern/cycles/kernel/shaders/node_noise_texture.osl
+++ b/intern/cycles/kernel/shaders/node_noise_texture.osl
@@ -19,9 +19,10 @@
/* Noise */
-float noise(point p, float distortion, float detail, float fac, color Color)
+float noise(point ip, float distortion, float detail, output color Color)
{
point r;
+ point p = ip;
int hard = 0;
if (distortion != 0.0) {
@@ -32,7 +33,7 @@ float noise(point p, float distortion, float detail, float fac, color Color)
p += r;
}
- fac = noise_turbulence(p, detail, hard);
+ float fac = noise_turbulence(p, detail, hard);
Color = color(fac, noise_turbulence(point(p[1], p[0], p[2]), detail, hard),
noise_turbulence(point(p[1], p[2], p[0]), detail, hard));
@@ -55,6 +56,6 @@ shader node_noise_texture(
if (use_mapping)
p = transform(mapping, p);
- Fac = noise(p * Scale, Distortion, Detail, Fac, Color);
+ Fac = noise(p * Scale, Distortion, Detail, Color);
}
diff --git a/intern/cycles/kernel/svm/svm_ao.h b/intern/cycles/kernel/svm/svm_ao.h
index 0337c88a543..15d074780c4 100644
--- a/intern/cycles/kernel/svm/svm_ao.h
+++ b/intern/cycles/kernel/svm/svm_ao.h
@@ -33,6 +33,11 @@ ccl_device_noinline float svm_ao(KernelGlobals *kg,
return 1.0f;
}
+ /* Can't raytrace from shaders like displacement, before BVH exists. */
+ if (kernel_data.bvh.bvh_layout == BVH_LAYOUT_NONE) {
+ return 1.0f;
+ }
+
if(flags & NODE_AO_INSIDE) {
N = -N;
}
diff --git a/intern/cycles/kernel/svm/svm_bevel.h b/intern/cycles/kernel/svm/svm_bevel.h
index 79d0fb6ddbe..96d132acd73 100644
--- a/intern/cycles/kernel/svm/svm_bevel.h
+++ b/intern/cycles/kernel/svm/svm_bevel.h
@@ -34,6 +34,11 @@ ccl_device_noinline float3 svm_bevel(
return sd->N;
}
+ /* Can't raytrace from shaders like displacement, before BVH exists. */
+ if (kernel_data.bvh.bvh_layout == BVH_LAYOUT_NONE) {
+ return sd->N;
+ }
+
/* Don't bevel for blurry indirect rays. */
if(state->min_ray_pdf < 8.0f) {
return sd->N;
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index dc7a1043208..b34d16c438b 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -335,6 +335,11 @@ uint Object::visibility_for_tracing() const {
return trace_visibility;
}
+int Object::get_device_index() const
+{
+ return index;
+}
+
/* Object Manager */
ObjectManager::ObjectManager()
@@ -348,10 +353,9 @@ ObjectManager::~ObjectManager()
}
void ObjectManager::device_update_object_transform(UpdateObjectTransformState *state,
- Object *ob,
- int object_index)
+ Object *ob)
{
- KernelObject& kobject = state->objects[object_index];
+ KernelObject& kobject = state->objects[ob->index];
Transform *object_motion_pass = state->object_motion_pass;
Mesh *mesh = ob->mesh;
@@ -457,13 +461,13 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
tfm_post = tfm_post * itfm;
}
- int motion_pass_offset = object_index*OBJECT_MOTION_PASS_SIZE;
+ int motion_pass_offset = ob->index*OBJECT_MOTION_PASS_SIZE;
object_motion_pass[motion_pass_offset + 0] = tfm_pre;
object_motion_pass[motion_pass_offset + 1] = tfm_post;
}
else if(state->need_motion == Scene::MOTION_BLUR) {
if(ob->use_motion()) {
- kobject.motion_offset = state->motion_offset[object_index];
+ kobject.motion_offset = state->motion_offset[ob->index];
/* Decompose transforms for interpolation. */
DecomposedTransform *decomp = state->object_motion + kobject.motion_offset;
@@ -494,7 +498,7 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
if(ob->use_holdout) {
flag |= SD_OBJECT_HOLDOUT_MASK;
}
- state->object_flag[object_index] = flag;
+ state->object_flag[ob->index] = flag;
/* Have curves. */
if(mesh->num_curves()) {
@@ -538,7 +542,7 @@ void ObjectManager::device_update_object_transform_task(
for(int i = 0; i < num_objects; ++i) {
const int object_index = start_index + i;
Object *ob = state->scene->objects[object_index];
- device_update_object_transform(state, ob, object_index);
+ device_update_object_transform(state, ob);
}
}
}
@@ -593,10 +597,8 @@ void ObjectManager::device_update_transforms(DeviceScene *dscene,
* need some tweaks to make mid-complex scenes optimal.
*/
if(scene->objects.size() < 64) {
- int object_index = 0;
foreach(Object *ob, scene->objects) {
- device_update_object_transform(&state, ob, object_index);
- object_index++;
+ device_update_object_transform(&state, ob);
if(progress.get_cancel()) {
return;
}
@@ -642,6 +644,12 @@ void ObjectManager::device_update(Device *device, DeviceScene *dscene, Scene *sc
if(scene->objects.size() == 0)
return;
+ /* Assign object IDs. */
+ int index = 0;
+ foreach(Object *object, scene->objects) {
+ object->index = index++;
+ }
+
/* set object transform matrices, before applying static transforms */
progress.set_status("Updating Objects", "Copying Transformations to device");
device_update_transforms(dscene, scene, progress);
@@ -686,26 +694,25 @@ void ObjectManager::device_update_flags(Device *,
}
}
- int object_index = 0;
foreach(Object *object, scene->objects) {
if(object->mesh->has_volume) {
- object_flag[object_index] |= SD_OBJECT_HAS_VOLUME;
- object_flag[object_index] &= ~SD_OBJECT_HAS_VOLUME_ATTRIBUTES;
+ object_flag[object->index] |= SD_OBJECT_HAS_VOLUME;
+ object_flag[object->index] &= ~SD_OBJECT_HAS_VOLUME_ATTRIBUTES;
foreach(Attribute& attr, object->mesh->attributes.attributes) {
if(attr.element == ATTR_ELEMENT_VOXEL) {
- object_flag[object_index] |= SD_OBJECT_HAS_VOLUME_ATTRIBUTES;
+ object_flag[object->index] |= SD_OBJECT_HAS_VOLUME_ATTRIBUTES;
}
}
}
else {
- object_flag[object_index] &= ~(SD_OBJECT_HAS_VOLUME|SD_OBJECT_HAS_VOLUME_ATTRIBUTES);
+ object_flag[object->index] &= ~(SD_OBJECT_HAS_VOLUME|SD_OBJECT_HAS_VOLUME_ATTRIBUTES);
}
if(object->is_shadow_catcher) {
- object_flag[object_index] |= SD_OBJECT_SHADOW_CATCHER;
+ object_flag[object->index] |= SD_OBJECT_SHADOW_CATCHER;
}
else {
- object_flag[object_index] &= ~SD_OBJECT_SHADOW_CATCHER;
+ object_flag[object->index] &= ~SD_OBJECT_SHADOW_CATCHER;
}
if(bounds_valid) {
@@ -714,7 +721,7 @@ void ObjectManager::device_update_flags(Device *,
continue;
}
if(object->bounds.intersects(volume_object->bounds)) {
- object_flag[object_index] |= SD_OBJECT_INTERSECTS_VOLUME;
+ object_flag[object->index] |= SD_OBJECT_INTERSECTS_VOLUME;
break;
}
}
@@ -723,9 +730,8 @@ void ObjectManager::device_update_flags(Device *,
/* Not really valid, but can't make more reliable in the case
* of bounds not being up to date.
*/
- object_flag[object_index] |= SD_OBJECT_INTERSECTS_VOLUME;
+ object_flag[object->index] |= SD_OBJECT_INTERSECTS_VOLUME;
}
- ++object_index;
}
/* Copy object flag. */
@@ -741,7 +747,6 @@ void ObjectManager::device_update_mesh_offsets(Device *, DeviceScene *dscene, Sc
KernelObject *kobjects = dscene->objects.data();
bool update = false;
- int object_index = 0;
foreach(Object *object, scene->objects) {
Mesh* mesh = object->mesh;
@@ -750,18 +755,16 @@ void ObjectManager::device_update_mesh_offsets(Device *, DeviceScene *dscene, Sc
uint patch_map_offset = 2*(mesh->patch_table_offset + mesh->patch_table->total_size() -
mesh->patch_table->num_nodes * PATCH_NODE_SIZE) - mesh->patch_offset;
- if(kobjects[object_index].patch_map_offset != patch_map_offset) {
- kobjects[object_index].patch_map_offset = patch_map_offset;
+ if(kobjects[object->index].patch_map_offset != patch_map_offset) {
+ kobjects[object->index].patch_map_offset = patch_map_offset;
update = true;
}
}
- if(kobjects[object_index].attribute_map_offset != mesh->attr_map_offset) {
- kobjects[object_index].attribute_map_offset = mesh->attr_map_offset;
+ if(kobjects[object->index].attribute_map_offset != mesh->attr_map_offset) {
+ kobjects[object->index].attribute_map_offset = mesh->attr_map_offset;
update = true;
}
-
- object_index++;
}
if(update) {
diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h
index 87e6e6652ad..134f0bc3577 100644
--- a/intern/cycles/render/object.h
+++ b/intern/cycles/render/object.h
@@ -38,6 +38,7 @@ class Progress;
class Scene;
struct Transform;
struct UpdateObjectTransformState;
+class ObjectManager;
/* Object */
@@ -88,6 +89,16 @@ public:
* determined flags which denotes trace-time visibility.
*/
uint visibility_for_tracing() const;
+
+ /* Returns the index that is used in the kernel for this object. */
+ int get_device_index() const;
+
+protected:
+ /* Specifies the position of the object in scene->objects and
+ * in the device vectors. Gets set in device_update. */
+ int index;
+
+ friend class ObjectManager;
};
/* Object Manager */
@@ -123,8 +134,7 @@ public:
protected:
void device_update_object_transform(UpdateObjectTransformState *state,
- Object *ob,
- const int object_index);
+ Object *ob);
void device_update_object_transform_task(UpdateObjectTransformState *state);
bool device_update_object_transform_pop_work(
UpdateObjectTransformState *state,
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index db13564037e..2d1f60c722b 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -47,13 +47,14 @@ Session::Session(const SessionParams& params_)
tile_manager(params.progressive, params.samples, params.tile_size, params.start_resolution,
params.background == false || params.progressive_refine, params.background, params.tile_order,
max(params.device.multi_devices.size(), 1), params.pixel_size),
- stats()
+ stats(),
+ profiler()
{
device_use_gl = ((params.device.type != DEVICE_CPU) && !params.background);
TaskScheduler::init(params.threads);
- device = Device::create(params.device, stats, params.background);
+ device = Device::create(params.device, stats, profiler, params.background);
if(params.background && !params.write_render_cb) {
buffers = NULL;
@@ -250,7 +251,9 @@ void Session::run_gpu()
if(!no_tiles) {
/* update scene */
scoped_timer update_timer;
- update_scene();
+ if(update_scene()) {
+ profiler.reset(scene->shaders.size(), scene->objects.size());
+ }
progress.add_skip_time(update_timer, params.background);
if(!device->error_message().empty())
@@ -585,7 +588,9 @@ void Session::run_cpu()
/* update scene */
scoped_timer update_timer;
- update_scene();
+ if(update_scene()) {
+ profiler.reset(scene->shaders.size(), scene->objects.size());
+ }
progress.add_skip_time(update_timer, params.background);
if(!device->error_message().empty())
@@ -729,6 +734,10 @@ void Session::run()
/* load kernels */
load_kernels();
+ if(params.use_profiling && (params.device.type == DEVICE_CPU)) {
+ profiler.start();
+ }
+
/* session thread loop */
progress.set_status("Waiting for render to start");
@@ -743,6 +752,8 @@ void Session::run()
run_cpu();
}
+ profiler.stop();
+
/* progress update */
if(progress.get_cancel())
progress.set_status("Cancel", progress.get_cancel_message());
@@ -825,7 +836,7 @@ void Session::wait()
session_thread = NULL;
}
-void Session::update_scene()
+bool Session::update_scene()
{
thread_scoped_lock scene_lock(scene->mutex);
@@ -876,7 +887,10 @@ void Session::update_scene()
progress.set_status("Updating Scene");
MEM_GUARDED_CALL(&progress, scene->device_update, device, progress);
+
+ return true;
}
+ return false;
}
void Session::update_status_time(bool show_pause, bool show_done)
@@ -1052,6 +1066,14 @@ void Session::device_free()
*/
}
+void Session::collect_statistics(RenderStats *render_stats)
+{
+ scene->collect_statistics(render_stats);
+ if(params.use_profiling && (params.device.type == DEVICE_CPU)) {
+ render_stats->collect_profiling(scene, profiler);
+ }
+}
+
int Session::get_max_closure_count()
{
int max_closures = 0;
diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h
index 56a69919a7a..c7f590915e7 100644
--- a/intern/cycles/render/session.h
+++ b/intern/cycles/render/session.h
@@ -20,6 +20,7 @@
#include "render/buffers.h"
#include "device/device.h"
#include "render/shader.h"
+#include "render/stats.h"
#include "render/tile.h"
#include "util/util_progress.h"
@@ -55,6 +56,8 @@ public:
int pixel_size;
int threads;
+ bool use_profiling;
+
bool display_buffer_linear;
bool use_denoising;
@@ -89,6 +92,8 @@ public:
pixel_size = 1;
threads = 0;
+ use_profiling = false;
+
use_denoising = false;
denoising_passes = false;
denoising_radius = 8;
@@ -118,6 +123,7 @@ public:
&& start_resolution == params.start_resolution
&& pixel_size == params.pixel_size
&& threads == params.threads
+ && use_profiling == params.use_profiling
&& display_buffer_linear == params.display_buffer_linear
&& cancel_timeout == params.cancel_timeout
&& reset_timeout == params.reset_timeout
@@ -143,6 +149,7 @@ public:
SessionParams params;
TileManager tile_manager;
Stats stats;
+ Profiler profiler;
function<void(RenderTile&)> write_render_tile_cb;
function<void(RenderTile&, bool)> update_render_tile_cb;
@@ -159,7 +166,7 @@ public:
void set_samples(int samples);
void set_pause(bool pause);
- void update_scene();
+ bool update_scene();
void load_kernels(bool lock_scene=true);
void device_free();
@@ -168,6 +175,8 @@ public:
* (for example, when rendering with unlimited samples). */
float get_progress();
+ void collect_statistics(RenderStats *stats);
+
protected:
struct DelayedReset {
thread_mutex mutex;
diff --git a/intern/cycles/render/stats.cpp b/intern/cycles/render/stats.cpp
index 101d33fcf65..4245745944d 100644
--- a/intern/cycles/render/stats.cpp
+++ b/intern/cycles/render/stats.cpp
@@ -15,6 +15,7 @@
*/
#include "render/stats.h"
+#include "render/object.h"
#include "util/util_algorithm.h"
#include "util/util_foreach.h"
#include "util/util_string.h"
@@ -33,6 +34,16 @@ bool namedSizeEntryComparator(const NamedSizeEntry& a, const NamedSizeEntry& b)
return a.size > b.size;
}
+bool namedTimeSampleEntryComparator(const NamedNestedSampleStats& a, const NamedNestedSampleStats& b)
+{
+ return a.sum_samples > b.sum_samples;
+}
+
+bool namedSampleCountPairComparator(const NamedSampleCountPair& a, const NamedSampleCountPair& b)
+{
+ return a.samples > b.samples;
+}
+
} // namespace
NamedSizeEntry::NamedSizeEntry()
@@ -77,6 +88,113 @@ string NamedSizeStats::full_report(int indent_level)
return result;
}
+/* Named time sample statistics. */
+
+NamedNestedSampleStats::NamedNestedSampleStats()
+ : name(""), self_samples(0), sum_samples(0)
+{}
+
+NamedNestedSampleStats::NamedNestedSampleStats(const string& name, uint64_t samples)
+ : name(name), self_samples(samples), sum_samples(samples)
+{}
+
+NamedNestedSampleStats& NamedNestedSampleStats::add_entry(const string& name_, uint64_t samples_)
+{
+ entries.push_back(NamedNestedSampleStats(name_, samples_));
+ return entries[entries.size()-1];
+}
+
+void NamedNestedSampleStats::update_sum()
+{
+ sum_samples = self_samples;
+ foreach(NamedNestedSampleStats& entry, entries) {
+ entry.update_sum();
+ sum_samples += entry.sum_samples;
+ }
+}
+
+string NamedNestedSampleStats::full_report(int indent_level, uint64_t total_samples)
+{
+ update_sum();
+
+ if(total_samples == 0) {
+ total_samples = sum_samples;
+ }
+
+ const string indent(indent_level * kIndentNumSpaces, ' ');
+
+ const double sum_percent = 100*((double) sum_samples) / total_samples;
+ const double sum_seconds = sum_samples * 0.001;
+ const double self_percent = 100*((double) self_samples) / total_samples;
+ const double self_seconds = self_samples * 0.001;
+ string info = string_printf("%-32s: Total %3.2f%% (%.2fs), Self %3.2f%% (%.2fs)\n",
+ name.c_str(),
+ sum_percent,
+ sum_seconds,
+ self_percent,
+ self_seconds);
+ string result = indent + info;
+
+ sort(entries.begin(), entries.end(), namedTimeSampleEntryComparator);
+ foreach(NamedNestedSampleStats& entry, entries) {
+ result += entry.full_report(indent_level + 1, total_samples);
+ }
+ return result;
+}
+
+/* Named sample count pairs. */
+
+NamedSampleCountPair::NamedSampleCountPair(const ustring& name, uint64_t samples, uint64_t hits)
+ : name(name), samples(samples), hits(hits)
+{}
+
+NamedSampleCountStats::NamedSampleCountStats()
+{}
+
+void NamedSampleCountStats::add(const ustring& name, uint64_t samples, uint64_t hits)
+{
+ entry_map::iterator entry = entries.find(name);
+ if(entry != entries.end()) {
+ entry->second.samples += samples;
+ entry->second.hits += hits;
+ return;
+ }
+ entries.emplace(name, NamedSampleCountPair(name, samples, hits));
+}
+
+string NamedSampleCountStats::full_report(int indent_level)
+{
+ const string indent(indent_level * kIndentNumSpaces, ' ');
+
+ vector<NamedSampleCountPair> sorted_entries;
+ sorted_entries.reserve(entries.size());
+
+ uint64_t total_hits = 0, total_samples = 0;
+ foreach(entry_map::const_reference entry, entries) {
+ const NamedSampleCountPair &pair = entry.second;
+
+ total_hits += pair.hits;
+ total_samples += pair.samples;
+
+ sorted_entries.push_back(pair);
+ }
+ const double avg_samples_per_hit = ((double) total_samples) / total_hits;
+
+ sort(sorted_entries.begin(), sorted_entries.end(), namedSampleCountPairComparator);
+
+ string result = "";
+ foreach(const NamedSampleCountPair& entry, sorted_entries) {
+ const double seconds = entry.samples * 0.001;
+ const double relative = ((double) entry.samples) / (entry.hits * avg_samples_per_hit);
+
+ result += indent + string_printf("%-32s: %.2fs (Relative cost: %.2f)\n",
+ entry.name.c_str(),
+ seconds,
+ relative);
+ }
+ return result;
+}
+
/* Mesh statistics. */
MeshStats::MeshStats() {
@@ -106,6 +224,72 @@ string ImageStats::full_report(int indent_level)
/* Overall statistics. */
RenderStats::RenderStats() {
+ has_profiling = false;
+}
+
+void RenderStats::collect_profiling(Scene *scene, Profiler& prof)
+{
+ has_profiling = true;
+
+ kernel = NamedNestedSampleStats("Total render time", prof.get_event(PROFILING_UNKNOWN));
+
+ kernel.add_entry("Ray setup", prof.get_event(PROFILING_RAY_SETUP));
+ kernel.add_entry("Result writing", prof.get_event(PROFILING_WRITE_RESULT));
+
+ NamedNestedSampleStats &integrator = kernel.add_entry("Path integration", prof.get_event(PROFILING_PATH_INTEGRATE));
+ integrator.add_entry("Scene intersection", prof.get_event(PROFILING_SCENE_INTERSECT));
+ integrator.add_entry("Indirect emission", prof.get_event(PROFILING_INDIRECT_EMISSION));
+ integrator.add_entry("Volumes", prof.get_event(PROFILING_VOLUME));
+
+ NamedNestedSampleStats &shading = integrator.add_entry("Shading", 0);
+ shading.add_entry("Shader Setup", prof.get_event(PROFILING_SHADER_SETUP));
+ shading.add_entry("Shader Eval", prof.get_event(PROFILING_SHADER_EVAL));
+ shading.add_entry("Shader Apply", prof.get_event(PROFILING_SHADER_APPLY));
+ shading.add_entry("Ambient Occlusion", prof.get_event(PROFILING_AO));
+ shading.add_entry("Subsurface", prof.get_event(PROFILING_SUBSURFACE));
+
+ integrator.add_entry("Connect Light", prof.get_event(PROFILING_CONNECT_LIGHT));
+ integrator.add_entry("Surface Bounce", prof.get_event(PROFILING_SURFACE_BOUNCE));
+
+ NamedNestedSampleStats &intersection = kernel.add_entry("Intersection", 0);
+ intersection.add_entry("Full Intersection", prof.get_event(PROFILING_INTERSECT));
+ intersection.add_entry("Local Intersection", prof.get_event(PROFILING_INTERSECT_LOCAL));
+ intersection.add_entry("Shadow All Intersection", prof.get_event(PROFILING_INTERSECT_SHADOW_ALL));
+ intersection.add_entry("Volume Intersection", prof.get_event(PROFILING_INTERSECT_VOLUME));
+ intersection.add_entry("Volume All Intersection", prof.get_event(PROFILING_INTERSECT_VOLUME_ALL));
+
+ NamedNestedSampleStats &closure = kernel.add_entry("Closures", 0);
+ closure.add_entry("Surface Closure Evaluation", prof.get_event(PROFILING_CLOSURE_EVAL));
+ closure.add_entry("Surface Closure Sampling", prof.get_event(PROFILING_CLOSURE_SAMPLE));
+ closure.add_entry("Volume Closure Evaluation", prof.get_event(PROFILING_CLOSURE_VOLUME_EVAL));
+ closure.add_entry("Volume Closure Sampling", prof.get_event(PROFILING_CLOSURE_VOLUME_SAMPLE));
+
+ NamedNestedSampleStats &denoising = kernel.add_entry("Denoising", prof.get_event(PROFILING_DENOISING));
+ denoising.add_entry("Construct Transform", prof.get_event(PROFILING_DENOISING_CONSTRUCT_TRANSFORM));
+ denoising.add_entry("Reconstruct", prof.get_event(PROFILING_DENOISING_RECONSTRUCT));
+
+ NamedNestedSampleStats &prefilter = denoising.add_entry("Prefiltering", 0);
+ prefilter.add_entry("Divide Shadow", prof.get_event(PROFILING_DENOISING_DIVIDE_SHADOW));
+ prefilter.add_entry("Non-Local means", prof.get_event(PROFILING_DENOISING_NON_LOCAL_MEANS));
+ prefilter.add_entry("Get Feature", prof.get_event(PROFILING_DENOISING_GET_FEATURE));
+ prefilter.add_entry("Detect Outliers", prof.get_event(PROFILING_DENOISING_DETECT_OUTLIERS));
+ prefilter.add_entry("Combine Halves", prof.get_event(PROFILING_DENOISING_COMBINE_HALVES));
+
+ shaders.entries.clear();
+ foreach(Shader *shader, scene->shaders) {
+ uint64_t samples, hits;
+ if(prof.get_shader(shader->id, samples, hits)) {
+ shaders.add(shader->name, samples, hits);
+ }
+ }
+
+ objects.entries.clear();
+ foreach(Object *object, scene->objects) {
+ uint64_t samples, hits;
+ if(prof.get_object(object->get_device_index(), samples, hits)) {
+ objects.add(object->name, samples, hits);
+ }
+ }
}
string RenderStats::full_report()
@@ -113,6 +297,14 @@ string RenderStats::full_report()
string result = "";
result += "Mesh statistics:\n" + mesh.full_report(1);
result += "Image statistics:\n" + image.full_report(1);
+ if(has_profiling) {
+ result += "Kernel statistics:\n" + kernel.full_report(1);
+ result += "Shader statistics:\n" + shaders.full_report(1);
+ result += "Object statistics:\n" + objects.full_report(1);
+ }
+ else {
+ result += "Profiling information not available (only works with CPU rendering)";
+ }
return result;
}
diff --git a/intern/cycles/render/stats.h b/intern/cycles/render/stats.h
index 2ff0ec3e0e9..33fe1f4b185 100644
--- a/intern/cycles/render/stats.h
+++ b/intern/cycles/render/stats.h
@@ -17,6 +17,9 @@
#ifndef __RENDER_STATS_H__
#define __RENDER_STATS_H__
+#include "render/scene.h"
+
+#include "util/util_stats.h"
#include "util/util_string.h"
#include "util/util_vector.h"
@@ -61,6 +64,51 @@ public:
vector<NamedSizeEntry> entries;
};
+class NamedNestedSampleStats {
+public:
+ NamedNestedSampleStats();
+ NamedNestedSampleStats(const string& name, uint64_t samples);
+
+ NamedNestedSampleStats& add_entry(const string& name, uint64_t samples);
+
+ /* Updates sum_samples recursively. */
+ void update_sum();
+
+ string full_report(int indent_level = 0, uint64_t total_samples = 0);
+
+ string name;
+
+ /* self_samples contains only the samples that this specific event got,
+ * while sum_samples also includes the samples of all sub-entries. */
+ uint64_t self_samples, sum_samples;
+
+ vector<NamedNestedSampleStats> entries;
+};
+
+/* Named entry containing both a time-sample count for objects of a type and a
+ * total count of processed items.
+ * This allows to estimate the time spent per item. */
+class NamedSampleCountPair {
+public:
+ NamedSampleCountPair(const ustring& name, uint64_t samples, uint64_t hits);
+
+ ustring name;
+ uint64_t samples;
+ uint64_t hits;
+};
+
+/* Contains statistics about pairs of samples and counts as described above. */
+class NamedSampleCountStats {
+public:
+ NamedSampleCountStats();
+
+ string full_report(int indent_level = 0);
+ void add(const ustring& name, uint64_t samples, uint64_t hits);
+
+ typedef unordered_map<ustring, NamedSampleCountPair, ustringHash> entry_map;
+ entry_map entries;
+};
+
/* Statistics about mesh in the render database. */
class MeshStats {
public:
@@ -95,8 +143,16 @@ public:
/* Return full report as string. */
string full_report();
+ /* Collect kernel sampling information from Stats. */
+ void collect_profiling(Scene *scene, Profiler& prof);
+
+ bool has_profiling;
+
MeshStats mesh;
ImageStats image;
+ NamedNestedSampleStats kernel;
+ NamedSampleCountStats shaders;
+ NamedSampleCountStats objects;
};
CCL_NAMESPACE_END
diff --git a/intern/cycles/test/CMakeLists.txt b/intern/cycles/test/CMakeLists.txt
index a2e527c7144..61605535e62 100644
--- a/intern/cycles/test/CMakeLists.txt
+++ b/intern/cycles/test/CMakeLists.txt
@@ -50,7 +50,7 @@ endif()
if(WITH_IMAGE_OPENJPEG)
list(APPEND ALL_CYCLES_LIBRARIES ${OPENJPEG_LIBRARIES})
endif()
-if(WITH_CYCLES_OPENSUBDIV)
+if(WITH_OPENSUBDIV)
add_definitions(-DWITH_OPENSUBDIV)
include_directories(
SYSTEM
@@ -60,6 +60,11 @@ if(WITH_CYCLES_OPENSUBDIV)
${OPENSUBDIV_LIBRARIES}
)
endif()
+if(WITH_CYCLES_EMBREE)
+ list(APPEND ALL_CYCLES_LIBRARIES
+ ${EMBREE_LIBRARIES}
+ )
+endif()
if(WITH_CUDA_DYNLOAD)
list(APPEND ALL_CYCLES_LIBRARIES extern_cuew)
else()
diff --git a/intern/cycles/test/render_graph_finalize_test.cpp b/intern/cycles/test/render_graph_finalize_test.cpp
index cfdab7a6433..5f60411758d 100644
--- a/intern/cycles/test/render_graph_finalize_test.cpp
+++ b/intern/cycles/test/render_graph_finalize_test.cpp
@@ -161,6 +161,7 @@ class RenderGraph : public testing::Test
protected:
ScopedMockLog log;
Stats stats;
+ Profiler profiler;
DeviceInfo device_info;
Device *device_cpu;
SceneParams scene_params;
@@ -179,7 +180,7 @@ protected:
util_logging_start();
util_logging_verbosity_set(1);
- device_cpu = Device::create(device_info, stats, true);
+ device_cpu = Device::create(device_info, stats, profiler, true);
scene = new Scene(scene_params, device_cpu);
}
diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt
index 77d47984ee7..92dfc9fa85d 100644
--- a/intern/cycles/util/CMakeLists.txt
+++ b/intern/cycles/util/CMakeLists.txt
@@ -17,6 +17,7 @@ set(SRC
util_md5.cpp
util_murmurhash.cpp
util_path.cpp
+ util_profiling.cpp
util_string.cpp
util_simd.cpp
util_system.cpp
@@ -71,6 +72,7 @@ set(SRC_HEADERS
util_optimization.h
util_param.h
util_path.h
+ util_profiling.h
util_progress.h
util_projection.h
util_queue.h
diff --git a/intern/cycles/util/util_profiling.cpp b/intern/cycles/util/util_profiling.cpp
new file mode 100644
index 00000000000..30aaef69310
--- /dev/null
+++ b/intern/cycles/util/util_profiling.cpp
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2011-2018 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "util/util_algorithm.h"
+#include "util/util_profiling.h"
+#include "util/util_set.h"
+
+CCL_NAMESPACE_BEGIN
+
+Profiler::Profiler()
+ : do_stop_worker(true), worker(NULL)
+{
+}
+
+Profiler::~Profiler()
+{
+ assert(worker == NULL);
+}
+
+void Profiler::run()
+{
+ uint64_t updates = 0;
+ auto start_time = std::chrono::system_clock::now();
+ while(!do_stop_worker) {
+ thread_scoped_lock lock(mutex);
+ foreach(ProfilingState *state, states) {
+ uint32_t cur_event = state->event;
+ int32_t cur_shader = state->shader;
+ int32_t cur_object = state->object;
+
+ /* The state reads/writes should be atomic, but just to be sure
+ * check the values for validity anyways. */
+ if(cur_event < PROFILING_NUM_EVENTS) {
+ event_samples[cur_event]++;
+ }
+
+ if(cur_shader >= 0 && cur_shader < shader_samples.size()) {
+ /* Only consider the active shader during events whose runtime significantly depends on it. */
+ if(((cur_event >= PROFILING_SHADER_EVAL ) && (cur_event <= PROFILING_SUBSURFACE)) ||
+ ((cur_event >= PROFILING_CLOSURE_EVAL) && (cur_event <= PROFILING_CLOSURE_VOLUME_SAMPLE))) {
+ shader_samples[cur_shader]++;
+ }
+ }
+
+ if(cur_object >= 0 && cur_object < object_samples.size()) {
+ object_samples[cur_object]++;
+ }
+ }
+ lock.unlock();
+
+ /* Relative waits always overshoot a bit, so just waiting 1ms every
+ * time would cause the sampling to drift over time.
+ * By keeping track of the absolute time, the wait times correct themselves -
+ * if one wait overshoots a lot, the next one will be shorter to compensate. */
+ updates++;
+ std::this_thread::sleep_until(start_time + updates*std::chrono::milliseconds(1));
+ }
+}
+
+void Profiler::reset(int num_shaders, int num_objects)
+{
+ bool running = (worker != NULL);
+ if(running) {
+ stop();
+ }
+
+ /* Resize and clear the accumulation vectors. */
+ shader_hits.assign(num_shaders, 0);
+ object_hits.assign(num_objects, 0);
+
+ event_samples.assign(PROFILING_NUM_EVENTS, 0);
+ shader_samples.assign(num_shaders, 0);
+ object_samples.assign(num_objects, 0);
+
+ if(running) {
+ start();
+ }
+}
+
+void Profiler::start()
+{
+ assert(worker == NULL);
+ do_stop_worker = false;
+ worker = new thread(function_bind(&Profiler::run, this));
+}
+
+void Profiler::stop()
+{
+ if(worker != NULL) {
+ do_stop_worker = true;
+
+ worker->join();
+ delete worker;
+ worker = NULL;
+ }
+}
+
+void Profiler::add_state(ProfilingState *state)
+{
+ thread_scoped_lock lock(mutex);
+
+ /* Add the ProfilingState from the list of sampled states. */
+ assert(std::find(states.begin(), states.end(), state) == states.end());
+ states.push_back(state);
+
+ /* Resize thread-local hit counters. */
+ state->shader_hits.assign(shader_hits.size(), 0);
+ state->object_hits.assign(object_hits.size(), 0);
+
+ /* Initialize the state. */
+ state->event = PROFILING_UNKNOWN;
+ state->shader = -1;
+ state->object = -1;
+ state->active = true;
+}
+
+void Profiler::remove_state(ProfilingState *state)
+{
+ thread_scoped_lock lock(mutex);
+
+ /* Remove the ProfilingState from the list of sampled states. */
+ states.erase(std::remove(states.begin(), states.end(), state), states.end());
+ state->active = false;
+
+ /* Merge thread-local hit counters. */
+ assert(shader_hits.size() == state->shader_hits.size());
+ for(int i = 0; i < shader_hits.size(); i++) {
+ shader_hits[i] += state->shader_hits[i];
+ }
+
+ assert(object_hits.size() == state->object_hits.size());
+ for(int i = 0; i < object_hits.size(); i++) {
+ object_hits[i] += state->object_hits[i];
+ }
+}
+
+uint64_t Profiler::get_event(ProfilingEvent event)
+{
+ assert(worker == NULL);
+ return event_samples[event];
+}
+
+bool Profiler::get_shader(int shader, uint64_t &samples, uint64_t &hits)
+{
+ assert(worker == NULL);
+ if(shader_samples[shader] == 0) {
+ return false;
+ }
+ samples = shader_samples[shader];
+ hits = shader_hits[shader];
+ return true;
+}
+
+bool Profiler::get_object(int object, uint64_t &samples, uint64_t &hits)
+{
+ assert(worker == NULL);
+ if(object_samples[object] == 0) {
+ return false;
+ }
+ samples = object_samples[object];
+ hits = object_hits[object];
+ return true;
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_profiling.h b/intern/cycles/util/util_profiling.h
new file mode 100644
index 00000000000..77cdbb0b325
--- /dev/null
+++ b/intern/cycles/util/util_profiling.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2011-2018 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UTIL_PROFILING_H__
+#define __UTIL_PROFILING_H__
+
+#include <atomic>
+
+#include "util/util_foreach.h"
+#include "util/util_map.h"
+#include "util/util_thread.h"
+#include "util/util_vector.h"
+
+CCL_NAMESPACE_BEGIN
+
+enum ProfilingEvent : uint32_t {
+ PROFILING_UNKNOWN,
+ PROFILING_RAY_SETUP,
+ PROFILING_PATH_INTEGRATE,
+ PROFILING_SCENE_INTERSECT,
+ PROFILING_INDIRECT_EMISSION,
+ PROFILING_VOLUME,
+ PROFILING_SHADER_SETUP,
+ PROFILING_SHADER_EVAL,
+ PROFILING_SHADER_APPLY,
+ PROFILING_AO,
+ PROFILING_SUBSURFACE,
+ PROFILING_CONNECT_LIGHT,
+ PROFILING_SURFACE_BOUNCE,
+ PROFILING_WRITE_RESULT,
+
+ PROFILING_INTERSECT,
+ PROFILING_INTERSECT_LOCAL,
+ PROFILING_INTERSECT_SHADOW_ALL,
+ PROFILING_INTERSECT_VOLUME,
+ PROFILING_INTERSECT_VOLUME_ALL,
+
+ PROFILING_CLOSURE_EVAL,
+ PROFILING_CLOSURE_SAMPLE,
+ PROFILING_CLOSURE_VOLUME_EVAL,
+ PROFILING_CLOSURE_VOLUME_SAMPLE,
+
+ PROFILING_DENOISING,
+ PROFILING_DENOISING_CONSTRUCT_TRANSFORM,
+ PROFILING_DENOISING_RECONSTRUCT,
+ PROFILING_DENOISING_DIVIDE_SHADOW,
+ PROFILING_DENOISING_NON_LOCAL_MEANS,
+ PROFILING_DENOISING_COMBINE_HALVES,
+ PROFILING_DENOISING_GET_FEATURE,
+ PROFILING_DENOISING_DETECT_OUTLIERS,
+
+ PROFILING_NUM_EVENTS,
+};
+
+/* Contains the current execution state of a worker thread.
+ * These values are constantly updated by the worker.
+ * Periodically the profiler thread will wake up, read them
+ * and update its internal counters based on it.
+ *
+ * Atomics aren't needed here since we're only doing direct
+ * writes and reads to (4-byte-aligned) uint32_t, which is
+ * guaranteed to be atomic on x86 since the 486.
+ * Memory ordering is not guaranteed but does not matter.
+ *
+ * And even on other architectures, the extremely rare corner
+ * case of reading an intermediate state could at worst result
+ * in a single incorrect sample. */
+struct ProfilingState {
+ volatile uint32_t event = PROFILING_UNKNOWN;
+ volatile int32_t shader = -1;
+ volatile int32_t object = -1;
+ volatile bool active = false;
+
+ vector<uint64_t> shader_hits;
+ vector<uint64_t> object_hits;
+};
+
+class Profiler {
+public:
+ Profiler();
+ ~Profiler();
+
+ void reset(int num_shaders, int num_objects);
+
+ void start();
+ void stop();
+
+ void add_state(ProfilingState *state);
+ void remove_state(ProfilingState *state);
+
+ uint64_t get_event(ProfilingEvent event);
+ bool get_shader(int shader, uint64_t &samples, uint64_t &hits);
+ bool get_object(int object, uint64_t &samples, uint64_t &hits);
+
+protected:
+ void run();
+
+ /* Tracks how often the worker was in each ProfilingEvent while sampling,
+ * so multiplying the values by the sample frequency (currently 1ms)
+ * gives the approximate time spent in each state. */
+ vector<uint64_t> event_samples;
+ vector<uint64_t> shader_samples;
+ vector<uint64_t> object_samples;
+
+ /* Tracks the total amounts every object/shader was hit.
+ * Used to evaluate relative cost, written by the render thread.
+ * Indexed by the shader and object IDs that the kernel also uses
+ * to index __object_flag and __shaders. */
+ vector<uint64_t> shader_hits;
+ vector<uint64_t> object_hits;
+
+ volatile bool do_stop_worker;
+ thread *worker;
+
+ thread_mutex mutex;
+ vector<ProfilingState*> states;
+};
+
+class ProfilingHelper {
+public:
+ ProfilingHelper(ProfilingState *state, ProfilingEvent event)
+ : state(state)
+ {
+ previous_event = state->event;
+ state->event = event;
+ }
+
+ inline void set_event(ProfilingEvent event)
+ {
+ state->event = event;
+ }
+
+ inline void set_shader(int shader)
+ {
+ state->shader = shader;
+ if(state->active) {
+ assert(shader < state->shader_hits.size());
+ state->shader_hits[shader]++;
+ }
+ }
+
+ inline void set_object(int object)
+ {
+ state->object = object;
+ if(state->active) {
+ assert(object < state->object_hits.size());
+ state->object_hits[object]++;
+ }
+ }
+
+ ~ProfilingHelper()
+ {
+ state->event = previous_event;
+ }
+private:
+ ProfilingState *state;
+ uint32_t previous_event;
+};
+
+CCL_NAMESPACE_END
+
+#endif /* __UTIL_PROFILING_H__ */
diff --git a/intern/cycles/util/util_stats.h b/intern/cycles/util/util_stats.h
index 0ba58422a67..f1f2df94e33 100644
--- a/intern/cycles/util/util_stats.h
+++ b/intern/cycles/util/util_stats.h
@@ -18,6 +18,7 @@
#define __UTIL_STATS_H__
#include "util/util_atomic.h"
+#include "util/util_profiling.h"
CCL_NAMESPACE_BEGIN
diff --git a/intern/ghost/intern/GHOST_Context.cpp b/intern/ghost/intern/GHOST_Context.cpp
index e02f73ad12a..775492755a9 100644
--- a/intern/ghost/intern/GHOST_Context.cpp
+++ b/intern/ghost/intern/GHOST_Context.cpp
@@ -48,6 +48,15 @@
#ifdef _WIN32
+bool win32_silent_chk(bool result)
+{
+ if (!result) {
+ SetLastError(NO_ERROR);
+ }
+
+ return result;
+}
+
bool win32_chk(bool result, const char *file, int line, const char *text)
{
if (!result) {
diff --git a/intern/ghost/intern/GHOST_Context.h b/intern/ghost/intern/GHOST_Context.h
index 327ecd4b245..842736691e3 100644
--- a/intern/ghost/intern/GHOST_Context.h
+++ b/intern/ghost/intern/GHOST_Context.h
@@ -148,12 +148,15 @@ protected:
#ifdef _WIN32
bool win32_chk(bool result, const char *file = NULL, int line = 0, const char *text = NULL);
+bool win32_silent_chk(bool result);
# ifndef NDEBUG
# define WIN32_CHK(x) win32_chk((x), __FILE__, __LINE__, #x)
# else
# define WIN32_CHK(x) win32_chk(x)
# endif
+
+#define WIN32_CHK_SILENT(x, silent) ((silent) ? win32_silent_chk(x) : WIN32_CHK(x))
#endif /* _WIN32 */
diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm b/intern/ghost/intern/GHOST_ContextCGL.mm
index 46993a1cd1d..d95eba339f7 100644
--- a/intern/ghost/intern/GHOST_ContextCGL.mm
+++ b/intern/ghost/intern/GHOST_ContextCGL.mm
@@ -143,7 +143,7 @@ GHOST_TSuccess GHOST_ContextCGL::getSwapInterval(int &intervalOut)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [m_openGLContext setValues:&interval forParameter:NSOpenGLCPSwapInterval];
+ [m_openGLContext getValues:&interval forParameter:NSOpenGLCPSwapInterval];
[pool drain];
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp
index 9605f7ddff2..6cb92567b99 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -789,7 +789,10 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
m_hGLRC = ::wglCreateContextAttribsARB(m_hDC, NULL, &(iAttributes[0]));
}
- if (!WIN32_CHK(m_hGLRC != NULL)) {
+ /* Silence warnings interpreted as errors by users when trying to get
+ * a context with version higher than 3.3 Core. */
+ const bool silent = m_contextMajorVersion > 3;
+ if (!WIN32_CHK_SILENT(m_hGLRC != NULL, silent)) {
goto error;
}
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index e228a11dac2..ce056ef2c62 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -2367,6 +2367,8 @@ void GHOST_SystemX11::refreshXInputDevices()
if (m_xtablet.StylusDevice != NULL) {
/* Find how many pressure levels tablet has */
XAnyClassPtr ici = device_info[i].inputclassinfo;
+ bool found_valuator_class = false;
+
for (int j = 0; j < m_xtablet.StylusDevice->num_classes; ++j) {
if (ici->c_class == ValuatorClass) {
// printf("\t\tfound ValuatorClass\n");
@@ -2384,11 +2386,23 @@ void GHOST_SystemX11::refreshXInputDevices()
m_xtablet.YtiltLevels = 0;
}
+ found_valuator_class = true;
+
break;
}
ici = (XAnyClassPtr)(((char *)ici) + ici->length);
}
+
+ if (!found_valuator_class) {
+ /* In case our name matching detects a device that
+ * isn't actually a stylus. For example there can
+ * be "XPPEN Tablet" and "XPPEN Tablet Pen", but
+ * only the latter is a stylus. */
+ XCloseDevice(m_display, m_xtablet.StylusDevice);
+ m_xtablet.StylusDevice = NULL;
+ m_xtablet.StylusID = 0;
+ }
}
else {
m_xtablet.StylusID = 0;
diff --git a/intern/numaapi/AUTHORS b/intern/numaapi/AUTHORS
new file mode 100644
index 00000000000..a824c03d9ff
--- /dev/null
+++ b/intern/numaapi/AUTHORS
@@ -0,0 +1 @@
+Sergey Sharybin <sergey.vfx@gmail.com>
diff --git a/intern/numaapi/CMakeLists.txt b/intern/numaapi/CMakeLists.txt
new file mode 100644
index 00000000000..6d8edb5e1eb
--- /dev/null
+++ b/intern/numaapi/CMakeLists.txt
@@ -0,0 +1,39 @@
+# ***** 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 *****
+
+set(INC
+ include
+)
+
+set(INC_SYS
+
+)
+
+set(SRC
+ source/numaapi.c
+ source/numaapi_linux.c
+ source/numaapi_stub.c
+ source/numaapi_win32.c
+
+ include/numaapi.h
+ source/build_config.h
+)
+
+add_definitions(-DWITH_DYNLOAD)
+
+blender_add_lib(bf_intern_numaapi "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/intern/numaapi/LICENSE b/intern/numaapi/LICENSE
new file mode 100644
index 00000000000..3562d7ac274
--- /dev/null
+++ b/intern/numaapi/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2016 libnumaapi authors.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
diff --git a/intern/numaapi/README b/intern/numaapi/README
new file mode 100644
index 00000000000..a510ff12548
--- /dev/null
+++ b/intern/numaapi/README
@@ -0,0 +1,7 @@
+LibNumaAPI is aimed to provide one common cross-platform API for all
+possible platforms, so cross-platform applications might not worry
+about implementation details.
+
+LICENSE
+
+LibNumaAPI library is released under the MIT license.
diff --git a/intern/numaapi/README.blender b/intern/numaapi/README.blender
new file mode 100644
index 00000000000..661073712b9
--- /dev/null
+++ b/intern/numaapi/README.blender
@@ -0,0 +1,5 @@
+Project: LibNumaAPI
+URL: https://github.com/Nazg-Gul/libNumaAPI
+License: MIT
+Upstream version: f83d41ec4d7
+Local modifications: None
diff --git a/intern/numaapi/include/numaapi.h b/intern/numaapi/include/numaapi.h
new file mode 100644
index 00000000000..a4f32d88458
--- /dev/null
+++ b/intern/numaapi/include/numaapi.h
@@ -0,0 +1,108 @@
+// Copyright (c) 2016, libnumaapi authors
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//
+// Author: Sergey Sharybin (sergey.vfx@gmail.com)
+
+#ifndef __LIBNUMAAPI_H__
+#define __LIBNUMAAPI_H__
+
+#include <stdbool.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NUMAAPI_VERSION_MAJOR 1
+#define NUMAAPI_VERSION_MINOR 0
+
+typedef enum NUMAAPI_Result {
+ NUMAAPI_SUCCESS = 0,
+ // NUMA is not available on this platform.
+ NUMAAPI_NOT_AVAILABLE = 1,
+ // Generic error, no real details are available,
+ NUMAAPI_ERROR = 2,
+ // Error installing atexit() handlers.
+ NUMAAPI_ERROR_ATEXIT = 3,
+} NUMAAPI_Result;
+
+////////////////////////////////////////////////////////////////////////////////
+// Initialization.
+
+// Initialize NUMA API.
+//
+// This is first call which should be called before any other NUMA functions
+// can be used.
+NUMAAPI_Result numaAPI_Initialize(void);
+
+// Get string representation of NUMAPIResult.
+const char* numaAPI_ResultAsString(NUMAAPI_Result result);
+
+////////////////////////////////////////////////////////////////////////////////
+// Topology query.
+
+// Get number of available nodes.
+//
+// This is in fact an index of last node plus one and it's not guaranteed
+// that all nodes up to this one are available.
+int numaAPI_GetNumNodes(void);
+
+// Returns truth if the given node is available for compute.
+bool numaAPI_IsNodeAvailable(int node);
+
+// Getnumber of available processors on a given node.
+int numaAPI_GetNumNodeProcessors(int node);
+
+////////////////////////////////////////////////////////////////////////////////
+// Affinities.
+
+// Runs the current process and its children on a specific node.
+//
+// Returns truth if affinity has successfully changed.
+//
+// NOTE: This function can not change active CPU group. Mainly designed to deal
+// with Threadripper 2 topology, to make it possible to gain maximum performance
+// for the main application thread.
+bool numaAPI_RunProcessOnNode(int node);
+
+// Runs the current thread and its children on a specific node.
+//
+// Returns truth if affinity has successfully changed.
+bool numaAPI_RunThreadOnNode(int node);
+
+////////////////////////////////////////////////////////////////////////////////
+// Memory management.
+
+// Allocate memory on a given node,
+void* numaAPI_AllocateOnNode(size_t size, int node);
+
+// Allocate memory in the local memory, closest to the current node.
+void* numaAPI_AllocateLocal(size_t size);
+
+// Frees size bytes of memory starting at start.
+//
+// TODO(sergey): Consider making it regular free() semantic.
+void numaAPI_Free(void* start, size_t size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __LIBNUMAAPI_H__
diff --git a/intern/numaapi/source/build_config.h b/intern/numaapi/source/build_config.h
new file mode 100644
index 00000000000..444adcc0c71
--- /dev/null
+++ b/intern/numaapi/source/build_config.h
@@ -0,0 +1,379 @@
+// Copyright (c) 2018, libnumaapi authors
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//
+// Author: Sergey Sharybin (sergey.vfx@gmail.com)
+
+#ifndef __BUILD_CONFIG_H__
+#define __BUILD_CONFIG_H__
+
+#include <limits.h>
+#include <stdint.h>
+
+// Initially is based on Chromium's build_config.h, with tweaks and extensions
+// needed for this project.
+//
+// NOTE: All commonly used symbols (which are checked on a "top" level, from
+// outside of any platform-specific ifdef block) are to be explicitly defined
+// to 0 when they are not "active". This is extra lines of code in this file,
+// but is not being edited that often. Such approach helps catching cases when
+// one attempted to access build configuration variable without including the
+// header by simply using -Wundef compiler attribute.
+//
+// NOTE: Not having things explicitly defined to 0 is harmless (in terms it
+// follows same rules as Google projects) and will simply cause compiler to
+// become more noisy, which is simple to correct.
+
+////////////////////////////////////////////////////////////////////////////////
+// A set of macros to use for platform detection.
+
+#if defined(__native_client__)
+// __native_client__ must be first, so that other OS_ defines are not set.
+# define OS_NACL 1
+#elif defined(_AIX)
+# define OS_AIX 1
+#elif defined(ANDROID)
+# define OS_ANDROID 1
+#elif defined(__APPLE__)
+// Only include TargetConditions after testing ANDROID as some android builds
+// on mac don't have this header available and it's not needed unless the target
+// is really mac/ios.
+# include <TargetConditionals.h>
+# define OS_MACOSX 1
+# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
+# define OS_IOS 1
+# endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
+#elif defined(__HAIKU__)
+# define OS_HAIKU 1
+#elif defined(__hpux)
+# define OS_HPUX 1
+#elif defined(__linux__)
+# define OS_LINUX 1
+// Include a system header to pull in features.h for glibc/uclibc macros.
+# include <unistd.h>
+# if defined(__GLIBC__) && !defined(__UCLIBC__)
+// We really are using glibc, not uClibc pretending to be glibc.
+# define LIBC_GLIBC 1
+# endif
+#elif defined(__sgi)
+# define OS_IRIX 1
+#elif defined(_WIN32)
+# define OS_WIN 1
+#elif defined(__FreeBSD__)
+# define OS_FREEBSD 1
+#elif defined(__NetBSD__)
+# define OS_NETBSD 1
+#elif defined(__OpenBSD__)
+# define OS_OPENBSD 1
+#elif defined(__sun)
+# define OS_SOLARIS 1
+#elif defined(__QNXNTO__)
+# define OS_QNX 1
+#else
+# error Please add support for your platform in build_config.h
+#endif
+
+#if !defined(OS_AIX)
+# define OS_AIX 0
+#endif
+#if !defined(OS_NACL)
+# define OS_NACL 0
+#endif
+#if !defined(OS_ANDROID)
+# define OS_ANDROID 0
+#endif
+#if !defined(OS_MACOSX)
+# define OS_MACOSX 0
+#endif
+#if !defined(OS_IOS)
+# define OS_IOS 0
+#endif
+#if !defined(OS_HAIKU)
+# define OS_HAIKU 0
+#endif
+#if !defined(OS_HPUX)
+# define OS_HPUX 0
+#endif
+#if !defined(OS_IRIX)
+# define OS_IRIX 0
+#endif
+#if !defined(OS_LINUX)
+# define OS_LINUX 0
+#endif
+#if !defined(LIBC_GLIBC)
+# define LIBC_GLIBC 0
+#endif
+#if !defined(OS_WIN)
+# define OS_WIN 0
+#endif
+#if !defined(OS_FREEBSD)
+# define OS_FREEBSD 0
+#endif
+#if !defined(OS_NETBSD)
+# define OS_NETBSD 0
+#endif
+#if !defined(OS_OPENBSD)
+# define OS_OPENBSD 0
+#endif
+#if !defined(OS_SOLARIS)
+# define OS_SOLARIS 0
+#endif
+#if !defined(OS_QNX)
+# define OS_QNX 0
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// *BSD OS family detection.
+//
+// For access to standard BSD features, use OS_BSD instead of a
+// more specific macro.
+#if OS_FREEBSD || OS_OPENBSD || OS_NETBSD
+# define OS_BSD 1
+#else
+# define OS_BSD 0
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// POSIX system detection.
+//
+// For access to standard POSIXish features use OS_POSIX instead of a
+// more specific macro.
+#if OS_MACOSX || OS_LINUX || OS_BSD || OS_SOLARIS ||OS_ANDROID || OS_NACL || \
+ OS_QNX || OS_HAIKU || OS_AIX || OS_HPUX || OS_IRIX
+# define OS_POSIX 1
+#else
+# define OS_POSIX 0
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// Compiler detection, including its capabilities.
+
+#if defined(__clang__)
+# define COMPILER_CLANG 1
+#elif defined(__GNUC__)
+# define COMPILER_GCC 1
+# define COMPILER_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+#elif defined(_MSC_VER)
+# define COMPILER_MSVC 1
+# define COMPILER_MSVC_VERSION (_MSC_VER)
+#elif defined(__MINGW32__)
+# define COMPILER_MINGW32 1
+#elif defined(__MINGW64__)
+# define COMPILER_MINGW64 1
+#else
+# error Please add support for your compiler in build_config.h
+#endif
+
+#if !defined(COMPILER_CLANG)
+# define COMPILER_CLANG 0
+#endif
+#if !defined(COMPILER_GCC)
+# define COMPILER_GCC 0
+#endif
+#if !defined(COMPILER_MSVC)
+# define COMPILER_MSVC 0
+#endif
+#if !defined(COMPILER_MINGW32)
+# define COMPILER_MINGW32 0
+#endif
+#if !defined(COMPILER_MINGW64)
+# define COMPILER_MINGW64 0
+#endif
+
+// Compiler is any of MinGW family.
+#if COMPILER_MINGW32 || COMPILER_MINGW64
+# define COMPILER_MINGW 1
+#else
+# define COMPILER_MINGW 0
+#endif
+
+// Check what is the latest C++ specification the compiler supports.
+//
+// NOTE: Use explicit definition here to avoid expansion-to-defined warning from
+// being geenrated. While this will most likely a false-positive warning in this
+// particular case, that warning might be helpful to catch errors elsewhere.
+
+// C++11 check.
+#if ((defined(__cplusplus) && (__cplusplus > 199711L)) || \
+ (defined(_MSC_VER) && (_MSC_VER >= 1800)))
+# define COMPILER_SUPPORTS_CXX11 1
+#else
+# define COMPILER_SUPPORTS_CXX11 0
+#endif
+// C++14 check.
+#if (defined(__cplusplus) && (__cplusplus > 201311L))
+# define COMPILER_SUPPORTS_CXX14 1
+#else
+# define COMPILER_SUPPORTS_CXX14 0
+#endif
+// C++17 check.
+#if (defined(__cplusplus) && (__cplusplus > 201611L))
+# define COMPILER_SUPPORTS_CXX17 1
+#else
+# define COMPILER_SUPPORTS_CXX17 0
+#endif
+// C++20 check.
+#if (defined(__cplusplus) && (__cplusplus > 201911L))
+# define COMPILER_SUPPORTS_CXX20 1
+#else
+# define COMPILER_SUPPORTS_CXX20 0
+#endif
+
+// COMPILER_USE_ADDRESS_SANITIZER is defined when program is detected that
+// compilation happened wit haddress sanitizer enabled. This allows to give
+// tips to sanitizer, or maybe work around some known issues with third party
+// libraries.
+#if !defined(COMPILER_USE_ADDRESS_SANITIZER)
+# if defined(__has_feature)
+# define COMPILER_USE_ADDRESS_SANITIZER 1
+# elif defined(__SANITIZE_ADDRESS__)
+# define COMPILER_USE_ADDRESS_SANITIZER 1
+# endif
+#endif
+
+#if !defined(COMPILER_USE_ADDRESS_SANITIZER)
+# define COMPILER_USE_ADDRESS_SANITIZER 0
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// Processor architecture detection.
+//
+// For more info on what's defined, see:
+//
+// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
+// http://www.agner.org/optimize/calling_conventions.pdf
+//
+// or with gcc, run: "echo | gcc -E -dM -"
+#if defined(_M_X64) || defined(__x86_64__)
+# define ARCH_CPU_X86_FAMILY 1
+# define ARCH_CPU_X86_64 1
+# define ARCH_CPU_64_BITS 1
+# define ARCH_CPU_LITTLE_ENDIAN 1
+#elif defined(_M_IX86) || defined(__i386__)
+# define ARCH_CPU_X86_FAMILY 1
+# define ARCH_CPU_X86 1
+# define ARCH_CPU_32_BITS 1
+# define ARCH_CPU_LITTLE_ENDIAN 1
+#elif defined(__ARMEL__)
+# define ARCH_CPU_ARM_FAMILY 1
+# define ARCH_CPU_ARMEL 1
+# define ARCH_CPU_32_BITS 1
+# define ARCH_CPU_LITTLE_ENDIAN 1
+#elif defined(__aarch64__)
+# define ARCH_CPU_ARM_FAMILY 1
+# define ARCH_CPU_ARM64 1
+# define ARCH_CPU_64_BITS 1
+# define ARCH_CPU_LITTLE_ENDIAN 1
+#elif defined(__pnacl__)
+# define ARCH_CPU_32_BITS 1
+# define ARCH_CPU_LITTLE_ENDIAN 1
+#elif defined(__MIPSEL__)
+# if defined(__LP64__)
+# define ARCH_CPU_MIPS64_FAMILY 1
+# define ARCH_CPU_MIPS64EL 1
+# define ARCH_CPU_64_BITS 1
+# define ARCH_CPU_LITTLE_ENDIAN 1
+# else
+# define ARCH_CPU_MIPS_FAMILY 1
+# define ARCH_CPU_MIPSEL 1
+# define ARCH_CPU_32_BITS 1
+# define ARCH_CPU_LITTLE_ENDIAN 1
+# endif
+#elif defined(__MIPSEB__)
+# if defined(__LP64__)
+# define ARCH_CPU_MIPS64_FAMILY 1
+# define ARCH_CPU_MIPS64EB 1
+# define ARCH_CPU_64_BITS 1
+# define ARCH_CPU_BIG_ENDIAN 1
+# else
+# define ARCH_CPU_MIPS_FAMILY 1
+# define ARCH_CPU_MIPSEB 1
+# define ARCH_CPU_32_BITS 1
+# define ARCH_CPU_BIG_ENDIAN 1
+# endif
+#else
+# error Please add support for your architecture in build_config.h
+#endif
+
+#if !defined(ARCH_CPU_LITTLE_ENDIAN)
+# define ARCH_CPU_LITTLE_ENDIAN 0
+#endif
+#if !defined(ARCH_CPU_BIG_ENDIAN)
+# define ARCH_CPU_BIG_ENDIAN 0
+#endif
+
+#if !defined(ARCH_CPU_32_BITS)
+# define ARCH_CPU_32_BITS 0
+#endif
+#if !defined(ARCH_CPU_64_BITS)
+# define ARCH_CPU_64_BITS 0
+#endif
+
+#if !defined(ARCH_CPU_X86_FAMILY)
+# define ARCH_CPU_X86_FAMILY 0
+#endif
+#if !defined(ARCH_CPU_ARM_FAMILY)
+# define ARCH_CPU_ARM_FAMILY 0
+#endif
+#if !defined(ARCH_CPU_MIPS_FAMILY)
+# define ARCH_CPU_MIPS_FAMILY 0
+#endif
+#if !defined(ARCH_CPU_MIPS64_FAMILY)
+# define ARCH_CPU_MIPS64_FAMILY 0
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// Sizes of platform-dependent types.
+
+#if defined(__SIZEOF_POINTER__)
+# define PLATFORM_SIZEOF_PTR __SIZEOF_POINTER__
+#elif defined(UINTPTR_MAX)
+# if (UINTPTR_MAX == 0xffffffff)
+# define PLATFORM_SIZEOF_PTR 4
+# elif (UINTPTR_MAX == 0xffffffffffffffff) // NOLINT
+# define PLATFORM_SIZEOF_PTR 8
+# endif
+#elif defined(__WORDSIZE)
+# if (__WORDSIZE == 32)
+# define PLATFORM_SIZEOF_PTR 4
+# else if (__WORDSIZE == 64)
+# define PLATFORM_SIZEOF_PTR 8
+# endif
+#endif
+#if !defined(PLATFORM_SIZEOF_PTR)
+# error "Cannot find pointer size"
+#endif
+
+#if (UINT_MAX == 0xffffffff)
+# define PLATFORM_SIZEOF_INT 4
+#elif (UINT_MAX == 0xffffffffffffffff) // NOLINT
+# define PLATFORM_SIZEOF_INT 8
+#else
+# error "Cannot find int size"
+#endif
+
+#if (USHRT_MAX == 0xffffffff)
+# define PLATFORM_SIZEOF_SHORT 4
+#elif (USHRT_MAX == 0xffff) // NOLINT
+# define PLATFORM_SIZEOF_SHORT 2
+#else
+# error "Cannot find short size"
+#endif
+
+#endif // __BUILD_CONFIG_H__
diff --git a/intern/numaapi/source/numaapi.c b/intern/numaapi/source/numaapi.c
new file mode 100644
index 00000000000..11b14d03451
--- /dev/null
+++ b/intern/numaapi/source/numaapi.c
@@ -0,0 +1,36 @@
+// Copyright (c) 2018, libnumaapi authors
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//
+// Author: Sergey Sharybin (sergey.vfx@gmail.com)
+
+#include "numaapi.h"
+
+#include <assert.h>
+
+const char* numaAPI_ResultAsString(NUMAAPI_Result result) {
+ switch (result) {
+ case NUMAAPI_SUCCESS: return "SUCCESS";
+ case NUMAAPI_NOT_AVAILABLE: return "NOT_AVAILABLE";
+ case NUMAAPI_ERROR: return "ERROR";
+ case NUMAAPI_ERROR_ATEXIT: return "ERROR_AT_EXIT";
+ }
+ assert(!"Unknown result was passed to numapi_ResultAsString().");
+ return "UNKNOWN";
+}
diff --git a/intern/numaapi/source/numaapi_linux.c b/intern/numaapi/source/numaapi_linux.c
new file mode 100644
index 00000000000..559e97b67d3
--- /dev/null
+++ b/intern/numaapi/source/numaapi_linux.c
@@ -0,0 +1,272 @@
+// Copyright (c) 2016, libnumaapi authors
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//
+// Author: Sergey Sharybin (sergey.vfx@gmail.com)
+
+#include "build_config.h"
+
+#if OS_LINUX
+
+#include "numaapi.h"
+
+#include <stdlib.h>
+
+#ifndef WITH_DYNLOAD
+# include <numa.h>
+#else
+# include <dlfcn.h>
+#endif
+
+#ifdef WITH_DYNLOAD
+
+// Descriptor numa library.
+static void* numa_lib;
+
+// Types of all symbols which are read from the library.
+struct bitmask;
+typedef int tnuma_available(void);
+typedef int tnuma_max_node(void);
+typedef int tnuma_node_to_cpus(int node, struct bitmask* mask);
+typedef long tnuma_node_size(int node, long* freep);
+typedef int tnuma_run_on_node(int node);
+typedef void* tnuma_alloc_onnode(size_t size, int node);
+typedef void* tnuma_alloc_local(size_t size);
+typedef void tnuma_free(void* start, size_t size);
+typedef struct bitmask* tnuma_bitmask_clearall(struct bitmask *bitmask);
+typedef int tnuma_bitmask_isbitset(const struct bitmask *bitmask,
+ unsigned int n);
+typedef struct bitmask* tnuma_bitmask_setbit(struct bitmask *bitmask,
+ unsigned int n);
+typedef unsigned int tnuma_bitmask_nbytes(struct bitmask *bitmask);
+typedef void tnuma_bitmask_free(struct bitmask *bitmask);
+typedef struct bitmask* tnuma_allocate_cpumask(void);
+typedef struct bitmask* tnuma_allocate_nodemask(void);
+typedef void tnuma_free_cpumask(struct bitmask* bitmask);
+typedef void tnuma_free_nodemask(struct bitmask* bitmask);
+typedef int tnuma_run_on_node_mask(struct bitmask *nodemask);
+typedef void tnuma_set_interleave_mask(struct bitmask *nodemask);
+typedef void tnuma_set_localalloc(void);
+
+// Actual symbols.
+static tnuma_available* numa_available;
+static tnuma_max_node* numa_max_node;
+static tnuma_node_to_cpus* numa_node_to_cpus;
+static tnuma_node_size* numa_node_size;
+static tnuma_run_on_node* numa_run_on_node;
+static tnuma_alloc_onnode* numa_alloc_onnode;
+static tnuma_alloc_local* numa_alloc_local;
+static tnuma_free* numa_free;
+static tnuma_bitmask_clearall* numa_bitmask_clearall;
+static tnuma_bitmask_isbitset* numa_bitmask_isbitset;
+static tnuma_bitmask_setbit* numa_bitmask_setbit;
+static tnuma_bitmask_nbytes* numa_bitmask_nbytes;
+static tnuma_bitmask_free* numa_bitmask_free;
+static tnuma_allocate_cpumask* numa_allocate_cpumask;
+static tnuma_allocate_nodemask* numa_allocate_nodemask;
+static tnuma_free_nodemask* numa_free_nodemask;
+static tnuma_free_cpumask* numa_free_cpumask;
+static tnuma_run_on_node_mask* numa_run_on_node_mask;
+static tnuma_set_interleave_mask* numa_set_interleave_mask;
+static tnuma_set_localalloc* numa_set_localalloc;
+
+static void* findLibrary(const char** paths) {
+ int i = 0;
+ while (paths[i] != NULL) {
+ void* lib = dlopen(paths[i], RTLD_LAZY);
+ if (lib != NULL) {
+ return lib;
+ }
+ ++i;
+ }
+ return NULL;
+}
+
+static void numaExit(void) {
+ if (numa_lib == NULL) {
+ return;
+ }
+ dlclose(numa_lib);
+ numa_lib = NULL;
+}
+
+static NUMAAPI_Result loadNumaSymbols(void) {
+ // Prevent multiple initializations.
+ static bool initialized = false;
+ static NUMAAPI_Result result = NUMAAPI_NOT_AVAILABLE;
+ if (initialized) {
+ return result;
+ }
+ initialized = true;
+ // Find appropriate .so library.
+ const char* numa_paths[] = {
+ "libnuma.so.1",
+ "libnuma.so",
+ NULL};
+ // Register de-initialization.
+ const int error = atexit(numaExit);
+ if (error) {
+ result = NUMAAPI_ERROR_ATEXIT;
+ return result;
+ }
+ // Load library.
+ numa_lib = findLibrary(numa_paths);
+ if (numa_lib == NULL) {
+ result = NUMAAPI_NOT_AVAILABLE;
+ return result;
+ }
+ // Load symbols.
+
+#define _LIBRARY_FIND(lib, name) \
+ do { \
+ name = (t##name *)dlsym(lib, #name); \
+ } while (0)
+#define NUMA_LIBRARY_FIND(name) _LIBRARY_FIND(numa_lib, name)
+
+ NUMA_LIBRARY_FIND(numa_available);
+ NUMA_LIBRARY_FIND(numa_max_node);
+ NUMA_LIBRARY_FIND(numa_node_to_cpus);
+ NUMA_LIBRARY_FIND(numa_node_size);
+ NUMA_LIBRARY_FIND(numa_run_on_node);
+ NUMA_LIBRARY_FIND(numa_alloc_onnode);
+ NUMA_LIBRARY_FIND(numa_alloc_local);
+ NUMA_LIBRARY_FIND(numa_free);
+ NUMA_LIBRARY_FIND(numa_bitmask_clearall);
+ NUMA_LIBRARY_FIND(numa_bitmask_isbitset);
+ NUMA_LIBRARY_FIND(numa_bitmask_setbit);
+ NUMA_LIBRARY_FIND(numa_bitmask_nbytes);
+ NUMA_LIBRARY_FIND(numa_bitmask_free);
+ NUMA_LIBRARY_FIND(numa_allocate_cpumask);
+ NUMA_LIBRARY_FIND(numa_allocate_nodemask);
+ NUMA_LIBRARY_FIND(numa_free_cpumask);
+ NUMA_LIBRARY_FIND(numa_free_nodemask);
+ NUMA_LIBRARY_FIND(numa_run_on_node_mask);
+ NUMA_LIBRARY_FIND(numa_set_interleave_mask);
+ NUMA_LIBRARY_FIND(numa_set_localalloc);
+
+#undef NUMA_LIBRARY_FIND
+#undef _LIBRARY_FIND
+
+ result = NUMAAPI_SUCCESS;
+ return result;
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// Initialization.
+
+NUMAAPI_Result numaAPI_Initialize(void) {
+#ifdef WITH_DYNLOAD
+ NUMAAPI_Result result = loadNumaSymbols();
+ if (result != NUMAAPI_SUCCESS) {
+ return result;
+ }
+#endif
+ if (numa_available() < 0) {
+ return NUMAAPI_NOT_AVAILABLE;
+ }
+ return NUMAAPI_SUCCESS;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Topology query.
+
+int numaAPI_GetNumNodes(void) {
+ return numa_max_node() + 1;
+}
+
+bool numaAPI_IsNodeAvailable(int node) {
+ if (numa_node_size(node, NULL) > 0) {
+ return true;
+ }
+ return false;
+}
+
+int numaAPI_GetNumNodeProcessors(int node) {
+ struct bitmask* cpu_mask = numa_allocate_cpumask();
+ numa_node_to_cpus(node, cpu_mask);
+ const unsigned int num_bytes = numa_bitmask_nbytes(cpu_mask);
+ const unsigned int num_bits = num_bytes *8;
+ // TODO(sergey): There might be faster way calculating number of set bits.
+ int num_processors = 0;
+ for (unsigned int bit = 0; bit < num_bits; ++bit) {
+ if (numa_bitmask_isbitset(cpu_mask, bit)) {
+ ++num_processors;
+ }
+ }
+#ifdef WITH_DYNLOAD
+ if (numa_free_cpumask != NULL) {
+ numa_free_cpumask(cpu_mask);
+ } else {
+ numa_bitmask_free(cpu_mask);
+ }
+#else
+ numa_free_cpumask(cpu_mask);
+#endif
+ return num_processors;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Affinities.
+
+bool numaAPI_RunProcessOnNode(int node) {
+ numaAPI_RunThreadOnNode(node);
+ return true;
+}
+
+bool numaAPI_RunThreadOnNode(int node) {
+ // Construct bit mask from node index.
+ struct bitmask* node_mask = numa_allocate_nodemask();
+ numa_bitmask_clearall(node_mask);
+ numa_bitmask_setbit(node_mask, node);
+ numa_run_on_node_mask(node_mask);
+ // TODO(sergey): The following commands are based on x265 code, we might want
+ // to make those optional, or require to call those explicitly.
+ //
+ // Current assumption is that this is similar to SetThreadGroupAffinity().
+ numa_set_interleave_mask(node_mask);
+ numa_set_localalloc();
+#ifdef WITH_DYNLOAD
+ if (numa_free_nodemask != NULL) {
+ numa_free_nodemask(node_mask);
+ } else {
+ numa_bitmask_free(node_mask);
+ }
+#else
+ numa_free_nodemask(node_mask);
+#endif
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Memory management.
+
+void* numaAPI_AllocateOnNode(size_t size, int node) {
+ return numa_alloc_onnode(size, node);
+}
+
+void* numaAPI_AllocateLocal(size_t size) {
+ return numa_alloc_local(size);
+}
+
+void numaAPI_Free(void* start, size_t size) {
+ numa_free(start, size);
+}
+
+#endif // OS_LINUX
diff --git a/intern/numaapi/source/numaapi_stub.c b/intern/numaapi/source/numaapi_stub.c
new file mode 100644
index 00000000000..e054d71018c
--- /dev/null
+++ b/intern/numaapi/source/numaapi_stub.c
@@ -0,0 +1,87 @@
+// Copyright (c) 2016, libnumaapi authors
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//
+// Author: Sergey Sharybin (sergey.vfx@gmail.com)
+
+#include "numaapi.h"
+
+#include "build_config.h"
+
+// Stub implementation for platforms which doesn't have NUMA support.
+
+#if !OS_LINUX && !OS_WIN
+
+////////////////////////////////////////////////////////////////////////////////
+// Initialization.
+
+NUMAAPI_Result numaAPI_Initialize(void) {
+ return NUMAAPI_NOT_AVAILABLE;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Topology query.
+
+int numaAPI_GetNumNodes(void) {
+ return 0;
+}
+
+bool numaAPI_IsNodeAvailable(int node) {
+ (void) node; // Ignored.
+ return false;
+}
+
+int numaAPI_GetNumNodeProcessors(int node) {
+ (void) node; // Ignored.
+ return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Affinities.
+
+bool numaAPI_RunProcessOnNode(int node) {
+ (void) node; // Ignored.
+ return false;
+}
+
+bool numaAPI_RunThreadOnNode(int node) {
+ (void) node; // Ignored.
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Memory management.
+
+void* numaAPI_AllocateOnNode(size_t size, int node) {
+ (void) size; // Ignored.
+ (void) node; // Ignored.
+ return 0;
+}
+
+void* numaAPI_AllocateLocal(size_t size) {
+ (void) size; // Ignored.
+ return NULL;
+}
+
+void numaAPI_Free(void* start, size_t size) {
+ (void) start; // Ignored.
+ (void) size; // Ignored.
+}
+
+#endif // !OS_LINUX && !OS_WIN
diff --git a/intern/numaapi/source/numaapi_win32.c b/intern/numaapi/source/numaapi_win32.c
new file mode 100644
index 00000000000..33cbc797bd0
--- /dev/null
+++ b/intern/numaapi/source/numaapi_win32.c
@@ -0,0 +1,253 @@
+// Copyright (c) 2016, libnumaapi authors
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//
+// Author: Sergey Sharybin (sergey.vfx@gmail.com)
+
+#include "build_config.h"
+
+#if OS_WIN
+
+#include "numaapi.h"
+
+#ifndef NOGDI
+# define NOGDI
+#endif
+#ifndef NOMINMAX
+# define NOMINMAX
+#endif
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+#ifndef NOCOMM
+# define NOCOMM
+#endif
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <windows.h>
+
+#if ARCH_CPU_64_BITS
+# include <VersionHelpers.h>
+#endif
+
+#include <stdio.h>
+
+////////////////////////////////////////////////////////////////////////////////
+// Initialization.
+
+// Kernel library, from where the symbols come.
+static HMODULE kernel_lib;
+
+// Types of all symbols which are read from the library.
+
+// NUMA function types.
+typedef BOOL t_GetNumaHighestNodeNumber(PULONG highest_node_number);
+typedef BOOL t_GetNumaNodeProcessorMask(UCHAR node, ULONGLONG* processor_mask);
+typedef BOOL t_GetNumaNodeProcessorMaskEx(USHORT node,
+ GROUP_AFFINITY* processor_mask);
+typedef BOOL t_GetNumaProcessorNode(UCHAR processor, UCHAR* node_number);
+typedef void* t_VirtualAllocExNuma(HANDLE process_handle,
+ LPVOID address,
+ SIZE_T size,
+ DWORD allocation_type,
+ DWORD protect,
+ DWORD preferred);
+typedef BOOL t_VirtualFree(void* address, SIZE_T size, DWORD free_type);
+// Threading function types.
+typedef BOOL t_SetProcessAffinityMask(HANDLE process_handle,
+ DWORD_PTR process_affinity_mask);
+typedef BOOL t_SetThreadGroupAffinity(HANDLE thread_handle,
+ const GROUP_AFFINITY* GroupAffinity,
+ GROUP_AFFINITY* PreviousGroupAffinity);
+typedef DWORD t_GetCurrentProcessorNumber(void);
+
+// NUMA symbols.
+static t_GetNumaHighestNodeNumber* _GetNumaHighestNodeNumber;
+static t_GetNumaNodeProcessorMask* _GetNumaNodeProcessorMask;
+static t_GetNumaNodeProcessorMaskEx* _GetNumaNodeProcessorMaskEx;
+static t_GetNumaProcessorNode* _GetNumaProcessorNode;
+static t_VirtualAllocExNuma* _VirtualAllocExNuma;
+static t_VirtualFree* _VirtualFree;
+// Threading symbols.
+static t_SetProcessAffinityMask* _SetProcessAffinityMask;
+static t_SetThreadGroupAffinity* _SetThreadGroupAffinity;
+static t_GetCurrentProcessorNumber* _GetCurrentProcessorNumber;
+
+static void numaExit(void) {
+ // TODO(sergey): Consider closing library here.
+}
+
+static NUMAAPI_Result loadNumaSymbols(void) {
+ // Prevent multiple initializations.
+ static bool initialized = false;
+ static NUMAAPI_Result result = NUMAAPI_NOT_AVAILABLE;
+ if (initialized) {
+ return result;
+ }
+ initialized = true;
+ // Register de-initialization.
+ const int error = atexit(numaExit);
+ if (error) {
+ result = NUMAAPI_ERROR_ATEXIT;
+ return result;
+ }
+ // Load library.
+ kernel_lib = LoadLibraryA("Kernel32.dll");
+ // Load symbols.
+
+#define _LIBRARY_FIND(lib, name) \
+ do { \
+ _##name = (t_##name *)GetProcAddress(lib, #name); \
+ } while (0)
+#define KERNEL_LIBRARY_FIND(name) _LIBRARY_FIND(kernel_lib, name)
+
+ // NUMA.
+ KERNEL_LIBRARY_FIND(GetNumaHighestNodeNumber);
+ KERNEL_LIBRARY_FIND(GetNumaNodeProcessorMask);
+ KERNEL_LIBRARY_FIND(GetNumaNodeProcessorMaskEx);
+ KERNEL_LIBRARY_FIND(GetNumaProcessorNode);
+ KERNEL_LIBRARY_FIND(VirtualAllocExNuma);
+ KERNEL_LIBRARY_FIND(VirtualFree);
+ // Threading.
+ KERNEL_LIBRARY_FIND(SetProcessAffinityMask);
+ KERNEL_LIBRARY_FIND(SetThreadGroupAffinity);
+ KERNEL_LIBRARY_FIND(GetCurrentProcessorNumber);
+
+#undef KERNEL_LIBRARY_FIND
+#undef _LIBRARY_FIND
+
+ result = NUMAAPI_SUCCESS;
+ return result;
+}
+
+NUMAAPI_Result numaAPI_Initialize(void) {
+#if !ARCH_CPU_64_BITS
+ // No NUMA on 32 bit platforms.
+ return NUMAAPI_NOT_AVAILABLE;
+#else
+ if (!IsWindows7OrGreater()) {
+ // Require Windows 7 or higher.
+ NUMAAPI_NOT_AVAILABLE;
+ }
+ loadNumaSymbols();
+ return NUMAAPI_SUCCESS;
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Topology query.
+
+int numaAPI_GetNumNodes(void) {
+ ULONG highest_node_number;
+ if (!_GetNumaHighestNodeNumber(&highest_node_number)) {
+ return 0;
+ }
+ // TODO(sergey): Resolve the type narrowing.
+ // NOTE: This is not necessarily a total amount of nodes in the system.
+ return (int)highest_node_number + 1;
+}
+
+bool numaAPI_IsNodeAvailable(int node) {
+ // Trick to detect whether the node is usable or not: check whether
+ // there are any processors associated with it.
+ //
+ // This is needed because numaApiGetNumNodes() is not guaranteed to
+ // give total amount of nodes and some nodes might be unavailable.
+ ULONGLONG processor_mask;
+ if (!_GetNumaNodeProcessorMask(node, &processor_mask)) {
+ return false;
+ }
+ if (processor_mask == 0) {
+ return false;
+ }
+ return true;
+}
+
+int numaAPI_GetNumNodeProcessors(int node) {
+ ULONGLONG processor_mask;
+ if (!_GetNumaNodeProcessorMask(node, &processor_mask)) {
+ return 0;
+ }
+ // TODO(sergey): There might be faster way calculating number of set bits.
+ int num_processors = 0;
+ while (processor_mask != 0) {
+ num_processors += (processor_mask & 1);
+ processor_mask = (processor_mask >> 1);
+ }
+ return num_processors;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Affinities.
+
+bool numaAPI_RunProcessOnNode(int node) {
+ // TODO(sergey): Make sure requested node is within active CPU group.
+ // Change affinity of the proces to make it to run on a given node.
+ HANDLE process_handle = GetCurrentProcess();
+ ULONGLONG processor_mask;
+ if (_GetNumaNodeProcessorMask(node, &processor_mask) == 0) {
+ return false;
+ }
+ if (_SetProcessAffinityMask(process_handle, processor_mask) == 0) {
+ return false;
+ }
+ return true;
+}
+
+bool numaAPI_RunThreadOnNode(int node) {
+ HANDLE thread_handle = GetCurrentThread();
+ GROUP_AFFINITY group_affinity = { 0 };
+ if (_GetNumaNodeProcessorMaskEx(node, &group_affinity) == 0) {
+ return false;
+ }
+ if (_SetThreadGroupAffinity(thread_handle, &group_affinity, NULL) == 0) {
+ return false;
+ }
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Memory management.
+
+void* numaAPI_AllocateOnNode(size_t size, int node) {
+ return _VirtualAllocExNuma(GetCurrentProcess(),
+ NULL,
+ size,
+ MEM_RESERVE | MEM_COMMIT,
+ PAGE_READWRITE,
+ node);
+}
+
+void* numaAPI_AllocateLocal(size_t size) {
+ UCHAR current_processor = (UCHAR)_GetCurrentProcessorNumber();
+ UCHAR node;
+ if (!_GetNumaProcessorNode(current_processor, &node)) {
+ return NULL;
+ }
+ return numaAPI_AllocateOnNode(size, node);
+}
+
+void numaAPI_Free(void* start, size_t size) {
+ if (!_VirtualFree(start, size, MEM_RELEASE)) {
+ // TODO(sergey): Throw an error!
+ }
+}
+
+#endif // OS_WIN
diff --git a/intern/opencolorio/ocio_impl.cc b/intern/opencolorio/ocio_impl.cc
index 82536a74159..4c9115af810 100644
--- a/intern/opencolorio/ocio_impl.cc
+++ b/intern/opencolorio/ocio_impl.cc
@@ -55,6 +55,27 @@ using namespace OCIO_NAMESPACE;
# define __func__ __FUNCTION__
#endif
+/* NOTE: This is because OCIO 1.1.0 has a bug which makes default
+ * display to be the one which is first alphabetically.
+ *
+ * Fix has been submitted as a patch
+ * https://github.com/imageworks/OpenColorIO/pull/638
+ *
+ * For until then we use first usable display instead. */
+#define DEFAULT_DISPLAY_WORKAROUND
+#ifdef DEFAULT_DISPLAY_WORKAROUND
+# include <algorithm>
+# include <map>
+# include <mutex>
+# include <vector>
+# include <string>
+# include <set>
+using std::vector;
+using std::set;
+using std::string;
+using std::map;
+#endif
+
static void OCIO_reportError(const char *err)
{
std::cerr << "OpenColorIO Error: " << err << std::endl;
@@ -197,6 +218,31 @@ int OCIOImpl::configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const c
const char *OCIOImpl::configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config)
{
+#ifdef DEFAULT_DISPLAY_WORKAROUND
+ if (getenv("OCIO_ACTIVE_DISPLAYS") == NULL) {
+ const char *active_displays =
+ (*(ConstConfigRcPtr *) config)->getActiveDisplays();
+ if (active_displays[0] != '\0') {
+ const char *separator_pos = strchr(active_displays, ',');
+ if (separator_pos == NULL) {
+ return active_displays;
+ }
+ static std::string active_display;
+ /* NOTE: Configuration is shared and is never changed during
+ * runtime, so we only guarantee two threads don't initialize at the
+ * same. */
+ static std::mutex mutex;
+ mutex.lock();
+ if (active_display.empty()) {
+ active_display = active_displays;
+ active_display[separator_pos - active_displays] = '\0';
+ }
+ mutex.unlock();
+ return active_display.c_str();
+ }
+ }
+#endif
+
try {
return (*(ConstConfigRcPtr *) config)->getDefaultDisplay();
}
@@ -231,8 +277,92 @@ const char *OCIOImpl::configGetDisplay(OCIO_ConstConfigRcPtr *config, int index)
return NULL;
}
+#ifdef DEFAULT_DISPLAY_WORKAROUND
+namespace {
+
+void splitStringEnvStyle(vector<string>* tokens, const string& str)
+{
+ tokens->clear();
+ const int len = str.length();
+ int token_start = 0, token_length = 0;
+ for (int i = 0; i < len; ++i) {
+ const char ch = str[i];
+ if (ch != ',' && ch != ':') {
+ /* Append non-separator char to a token. */
+ ++token_length;
+ } else {
+ /* Append current token to the list (if any). */
+ if (token_length > 0) {
+ string token = str.substr(token_start, token_length);
+ tokens->push_back(token);
+ }
+ /* Re-set token pointers. */
+ token_start = i + 1;
+ token_length = 0;
+ }
+ }
+ /* Append token which might be at the end of the string. */
+ if (token_length != 0) {
+ string token = str.substr(token_start, token_length);
+ tokens->push_back(token);
+ }
+}
+
+string stringToLower(const string& str) {
+ string lower = str;
+ std::transform(lower.begin(), lower.end(), lower.begin(), tolower);
+ return lower;
+}
+
+} // namespace
+#endif
+
const char *OCIOImpl::configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display)
{
+#ifdef DEFAULT_DISPLAY_WORKAROUND
+ /* NOTE: We assume that first active view always exists for a default
+ * display. */
+ if (getenv("OCIO_ACTIVE_VIEWS") == NULL) {
+ ConstConfigRcPtr config_ptr = *((ConstConfigRcPtr *) config);
+ const char *active_views_encoded = config_ptr->getActiveViews();
+ if (active_views_encoded[0] != '\0') {
+ const string display_lower = stringToLower(display);
+ static map<string, string> default_display_views;
+ static std::mutex mutex;
+ mutex.lock();
+ /* Check if the view is already known. */
+ map<string, string>::const_iterator it =
+ default_display_views.find(display_lower);
+ if (it != default_display_views.end()) {
+ mutex.unlock();
+ return it->second.c_str();
+ }
+ /* Active views. */
+ vector<string> active_views;
+ splitStringEnvStyle(&active_views, active_views_encoded);
+ /* Get all views supported by tge display. */
+ set<string> display_views;
+ const int num_display_views = config_ptr->getNumViews(display);
+ for (int view_index = 0;
+ view_index < num_display_views;
+ ++view_index)
+ {
+ const char *view = config_ptr->getView(display, view_index);
+ display_views.insert(stringToLower(view));
+ }
+ /* Get first view which is supported by tge display. */
+ for (const string& view : active_views) {
+ const string view_lower = stringToLower(view);
+ if (display_views.find(view_lower) != display_views.end()) {
+ default_display_views[display_lower] = view;
+ mutex.unlock();
+ return default_display_views[display_lower].c_str();
+ }
+ }
+ mutex.unlock();
+ }
+ }
+#endif
try {
return (*(ConstConfigRcPtr *) config)->getDefaultView(display);
}
diff --git a/release/datafiles/icons/brush.uv_sculpt.grab.dat b/release/datafiles/icons/brush.uv_sculpt.grab.dat
new file mode 100644
index 00000000000..8f265b1af21
--- /dev/null
+++ b/release/datafiles/icons/brush.uv_sculpt.grab.dat
Binary files differ
diff --git a/release/datafiles/icons/brush.uv_sculpt.pinch.dat b/release/datafiles/icons/brush.uv_sculpt.pinch.dat
new file mode 100644
index 00000000000..06af3ddb801
--- /dev/null
+++ b/release/datafiles/icons/brush.uv_sculpt.pinch.dat
Binary files differ
diff --git a/release/datafiles/icons/brush.uv_sculpt.relax.dat b/release/datafiles/icons/brush.uv_sculpt.relax.dat
new file mode 100644
index 00000000000..3a30ac72cb6
--- /dev/null
+++ b/release/datafiles/icons/brush.uv_sculpt.relax.dat
Binary files differ
diff --git a/release/datafiles/icons/ops.gpencil.primitive_arc.dat b/release/datafiles/icons/ops.gpencil.primitive_arc.dat
new file mode 100644
index 00000000000..826748bba4d
--- /dev/null
+++ b/release/datafiles/icons/ops.gpencil.primitive_arc.dat
Binary files differ
diff --git a/release/datafiles/splash.png b/release/datafiles/splash.png
index 124e7cb7157..9b78a2d9841 100644
--- a/release/datafiles/splash.png
+++ b/release/datafiles/splash.png
Binary files differ
diff --git a/release/datafiles/splash_2x.png b/release/datafiles/splash_2x.png
index ab45828c837..4100d73b99e 100644
--- a/release/datafiles/splash_2x.png
+++ b/release/datafiles/splash_2x.png
Binary files differ
diff --git a/release/datafiles/studiolights/studio/outdoor.sl b/release/datafiles/studiolights/studio/outdoor.sl
new file mode 100644
index 00000000000..97d6508e756
--- /dev/null
+++ b/release/datafiles/studiolights/studio/outdoor.sl
@@ -0,0 +1,48 @@
+version 1
+light_ambient.x 0.049787
+light_ambient.y 0.069830
+light_ambient.z 0.080005
+light[0].flag 1
+light[0].smooth 0.756566
+light[0].col.x 0.371252
+light[0].col.y 0.666429
+light[0].col.z 0.685957
+light[0].spec.x 0.345702
+light[0].spec.y 0.518647
+light[0].spec.z 0.685957
+light[0].vec.x 0.000000
+light[0].vec.y 0.972477
+light[0].vec.z 0.232999
+light[1].flag 1
+light[1].smooth 0.040404
+light[1].col.x 0.638271
+light[1].col.y 0.618157
+light[1].col.z 0.560056
+light[1].spec.x 0.570470
+light[1].spec.y 0.552550
+light[1].spec.z 0.500779
+light[1].vec.x 0.348624
+light[1].vec.y 0.403670
+light[1].vec.z 0.845879
+light[2].flag 1
+light[2].smooth 0.694915
+light[2].col.x 0.070415
+light[2].col.y 0.095507
+light[2].col.z 0.068441
+light[2].spec.x 0.069250
+light[2].spec.y 0.095506
+light[2].spec.z 0.067197
+light[2].vec.x -0.023438
+light[2].vec.y -0.992188
+light[2].vec.z 0.122534
+light[3].flag 0
+light[3].smooth 0.000000
+light[3].col.x 0.000000
+light[3].col.y 0.000000
+light[3].col.z 0.000000
+light[3].spec.x 0.000000
+light[3].spec.y 0.000000
+light[3].spec.z 0.000000
+light[3].vec.x 0.000000
+light[3].vec.y 0.000000
+light[3].vec.z 0.000000
diff --git a/release/datafiles/studiolights/studio/soft.sl b/release/datafiles/studiolights/studio/soft.sl
new file mode 100644
index 00000000000..c324eb2acaf
--- /dev/null
+++ b/release/datafiles/studiolights/studio/soft.sl
@@ -0,0 +1,48 @@
+version 1
+light_ambient.x 0.046702
+light_ambient.y 0.055241
+light_ambient.z 0.080012
+light[0].flag 1
+light[0].smooth 0.615152
+light[0].col.x 0.685956
+light[0].col.y 0.685956
+light[0].col.z 0.685956
+light[0].spec.x 0.393114
+light[0].spec.y 0.393114
+light[0].spec.z 0.393114
+light[0].vec.x -0.091743
+light[0].vec.y 0.366972
+light[0].vec.z 0.925697
+light[1].flag 1
+light[1].smooth 0.040404
+light[1].col.x 0.376072
+light[1].col.y 0.380086
+light[1].col.z 0.507068
+light[1].spec.x 0.467201
+light[1].spec.y 0.467201
+light[1].spec.z 0.467201
+light[1].vec.x -0.082569
+light[1].vec.y 0.431193
+light[1].vec.z 0.898474
+light[2].flag 1
+light[2].smooth 0.694915
+light[2].col.x 0.095513
+light[2].col.y 0.043908
+light[2].col.z 0.047173
+light[2].spec.x 0.208851
+light[2].spec.y 0.054585
+light[2].spec.z 0.054585
+light[2].vec.x 0.800234
+light[2].vec.y -0.378405
+light[2].vec.z -0.465227
+light[3].flag 0
+light[3].smooth 0.000000
+light[3].col.x 0.000000
+light[3].col.y 0.000000
+light[3].col.z 0.000000
+light[3].spec.x 0.000000
+light[3].spec.y 0.000000
+light[3].spec.z 0.000000
+light[3].vec.x 0.000000
+light[3].vec.y 0.000000
+light[3].vec.z 0.000000
diff --git a/release/datafiles/studiolights/studio/studio.sl b/release/datafiles/studiolights/studio/studio.sl
new file mode 100644
index 00000000000..ffbe67d2ad8
--- /dev/null
+++ b/release/datafiles/studiolights/studio/studio.sl
@@ -0,0 +1,48 @@
+version 1
+light_ambient.x 0.000000
+light_ambient.y 0.000000
+light_ambient.z 0.000000
+light[0].flag 1
+light[0].smooth 0.200000
+light[0].col.x 0.723042
+light[0].col.y 0.723042
+light[0].col.z 0.723042
+light[0].spec.x 0.685956
+light[0].spec.y 0.685956
+light[0].spec.z 0.685956
+light[0].vec.x -0.854701
+light[0].vec.y 0.111111
+light[0].vec.z 0.507091
+light[1].flag 1
+light[1].smooth 0.719626
+light[1].col.x 0.202750
+light[1].col.y 0.226584
+light[1].col.z 0.219549
+light[1].spec.x 0.313047
+light[1].spec.y 0.350555
+light[1].spec.z 0.339481
+light[1].vec.x 0.058607
+light[1].vec.y -0.987943
+light[1].vec.z -0.143295
+light[2].flag 1
+light[2].smooth 0.281250
+light[2].col.x 0.391353
+light[2].col.y 0.406801
+light[2].col.z 0.538224
+light[2].spec.x 0.252943
+light[2].spec.y 0.231462
+light[2].spec.z 0.231462
+light[2].vec.x 0.972202
+light[2].vec.y 0.075846
+light[2].vec.z -0.221518
+light[3].flag 0
+light[3].smooth 0.000000
+light[3].col.x 0.000000
+light[3].col.y 0.000000
+light[3].col.z 0.000000
+light[3].spec.x 0.000000
+light[3].spec.y 0.000000
+light[3].spec.z 0.000000
+light[3].vec.x 0.000000
+light[3].vec.y 0.000000
+light[3].vec.z 0.000000
diff --git a/release/datafiles/studiolights/studio/warm.sl b/release/datafiles/studiolights/studio/warm.sl
new file mode 100644
index 00000000000..8d343c4730c
--- /dev/null
+++ b/release/datafiles/studiolights/studio/warm.sl
@@ -0,0 +1,48 @@
+version 1
+light_ambient.x 0.012217
+light_ambient.y 0.012217
+light_ambient.z 0.012217
+light[0].flag 1
+light[0].smooth 0.906542
+light[0].col.x 0.358840
+light[0].col.y 0.358840
+light[0].col.z 0.358840
+light[0].spec.x 0.303197
+light[0].spec.y 0.303197
+light[0].spec.z 0.303197
+light[0].vec.x -0.002739
+light[0].vec.y 0.048039
+light[0].vec.z -0.998842
+light[1].flag 1
+light[1].smooth 0.264703
+light[1].col.x 1.000000
+light[1].col.y 0.708151
+light[1].col.z 0.505119
+light[1].spec.x 1.000000
+light[1].spec.y 0.825295
+light[1].spec.z 0.692071
+light[1].vec.x 0.846154
+light[1].vec.y 0.384615
+light[1].vec.z 0.368910
+light[2].flag 1
+light[2].smooth 0.413665
+light[2].col.x 0.260050
+light[2].col.y 0.323405
+light[2].col.z 0.447978
+light[2].spec.x 0.214064
+light[2].spec.y 0.265743
+light[2].spec.z 0.367238
+light[2].vec.x -0.963768
+light[2].vec.y 0.036232
+light[2].vec.z 0.264269
+light[3].flag 0
+light[3].smooth 0.000000
+light[3].col.x 0.000000
+light[3].col.y 0.000000
+light[3].col.z 0.000000
+light[3].spec.x 0.000000
+light[3].spec.y 0.000000
+light[3].spec.z 0.000000
+light[3].vec.x 0.000000
+light[3].vec.y 0.000000
+light[3].vec.z 0.000000
diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c
index b7b9c1aa9b8..90e8ca256aa 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -62,7 +62,7 @@ const bTheme U_theme_default = {
.wcol_radio = {
.outline = RGBA(0x373737ff),
.inner = RGBA(0x595959ff),
- .inner_sel = RGBA(0x597cb3e6),
+ .inner_sel = RGBA(0x5680c2e6),
.item = RGBA(0xffffffff),
.text = RGBA(0xe6e6e6ff),
.text_sel = RGBA(0xffffffff),
@@ -132,7 +132,7 @@ const bTheme U_theme_default = {
.wcol_pulldown = {
.outline = RGBA(0x4d4d4dff),
.inner = RGBA(0x2e2e2ecc),
- .inner_sel = RGBA(0x597cb3ff),
+ .inner_sel = RGBA(0x5680c2e6),
.item = RGBA(0x727272ff),
.text = RGBA(0xd9d9d9ff),
.text_sel = RGBA(0xffffffff),
@@ -152,7 +152,7 @@ const bTheme U_theme_default = {
.roundness = 0.2f,
},
.wcol_menu_item = {
- .inner_sel = RGBA(0x597cb3e6),
+ .inner_sel = RGBA(0x5680c2e6),
.item = RGBA(0xffffff8f),
.text = RGBA(0xe6e6e6ff),
.text_sel = RGBA(0xffffffff),
@@ -211,7 +211,7 @@ const bTheme U_theme_default = {
.wcol_pie_menu = {
.outline = RGBA(0x333333ff),
.inner = RGBA(0x212121ef),
- .inner_sel = RGBA(0x597cb3ff),
+ .inner_sel = RGBA(0x5680c2e6),
.item = RGBA(0x585858ff),
.text = RGBA(0xd9d9d9ff),
.text_sel = RGBA(0xffffffff),
@@ -228,6 +228,8 @@ const bTheme U_theme_default = {
.inner_driven_sel = RGBA(0x9900e6ff),
.inner_overridden = RGBA(0x19c3c300),
.inner_overridden_sel = RGBA(0x118f8f00),
+ .inner_changed = RGBA(0xcc7529ff),
+ .inner_changed_sel = RGBA(0xe6852dff),
.blend = 0.5f,
},
.widget_emboss = RGBA(0x00000005),
@@ -638,7 +640,7 @@ const bTheme U_theme_default = {
.tab_inactive = RGBA(0x2b2b2bff),
.tab_back = RGBA(0x232323ff),
.tab_outline = RGBA(0x232323ff),
- .button = RGBA(0x424242ff),
+ .button = RGBA(0x35353500),
.button_title = RGBA(0xffffffff),
.button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
@@ -760,7 +762,7 @@ const bTheme U_theme_default = {
.tab_inactive = RGBA(0x2b2b2bff),
.tab_back = RGBA(0x232323ff),
.tab_outline = RGBA(0x232323ff),
- .button = RGBA(0x424242ff),
+ .button = RGBA(0x42424200),
.button_title = RGBA(0xffffffff),
.button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
@@ -819,6 +821,7 @@ const bTheme U_theme_default = {
.button_title = RGBA(0xffffffff),
.button_text = RGBA(0xe5e5e5ff),
.button_text_hi = RGBA(0xffffffff),
+ .navigation_bar = RGBA(0x373737ff),
.panelcolors = {
.header = RGBA(0x42424200),
.back = RGBA(0x333333b3),
diff --git a/release/scripts/addons b/release/scripts/addons
-Subproject be2df5249105015aaafb06def0d1279c559c56f
+Subproject 0c24f02293da33e50cf79f125545a3089b75754
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
-Subproject 41d528d76b99e689e09915f5dcd589480579ef3
+Subproject 5f6f675fc196949ac9210dc5094bed6ab65300a
diff --git a/release/scripts/freestyle/modules/parameter_editor.py b/release/scripts/freestyle/modules/parameter_editor.py
index f2001a1ae50..3e695f4d389 100644
--- a/release/scripts/freestyle/modules/parameter_editor.py
+++ b/release/scripts/freestyle/modules/parameter_editor.py
@@ -1188,8 +1188,8 @@ def get_dashed_pattern(linestyle):
def get_grouped_objects(group):
for ob in group.objects:
- if ob.dupli_type == 'GROUP' and ob.dupli_group is not None:
- for dupli in get_grouped_objects(ob.dupli_group):
+ if ob.instance_type == 'COLLECTION' and ob.instance_collection is not None:
+ for dupli in get_grouped_objects(ob.instance_collection):
yield dupli
else:
yield ob
@@ -1275,10 +1275,10 @@ def process(layer_name, lineset_name):
upred = NotUP1D(upred)
selection_criteria.append(upred)
# prepare selection criteria by group of objects
- if lineset.select_by_group:
- if lineset.group is not None:
- names = {getQualifiedObjectName(ob): True for ob in get_grouped_objects(lineset.group)}
- upred = ObjectNamesUP1D(names, lineset.group_negation == 'EXCLUSIVE')
+ if lineset.select_by_collection:
+ if lineset.collection is not None:
+ names = {getQualifiedObjectName(ob): True for ob in get_grouped_objects(lineset.collection)}
+ upred = ObjectNamesUP1D(names, lineset.collection_negation == 'EXCLUSIVE')
selection_criteria.append(upred)
# prepare selection criteria by image border
if lineset.select_by_image_border:
diff --git a/release/scripts/modules/bl_app_template_utils.py b/release/scripts/modules/bl_app_template_utils.py
index b81971b98b6..66ed7327b31 100644
--- a/release/scripts/modules/bl_app_template_utils.py
+++ b/release/scripts/modules/bl_app_template_utils.py
@@ -51,8 +51,6 @@ _modules = {}
def _enable(template_id, *, handle_error=None, ignore_not_found=False):
- import os
- import sys
from bpy_restrict_state import RestrictBlend
if handle_error is None:
@@ -107,7 +105,6 @@ def _disable(template_id, *, handle_error=None):
taking an exception argument.
:type handle_error: function
"""
- import sys
if handle_error is None:
def handle_error(ex):
@@ -178,7 +175,7 @@ def activate(template_id=None):
addon_utils.disable_all()
# ignore_not_found so modules that don't contain scripts don't raise errors
- mod = _enable(template_id, ignore_not_found=True) if template_id else None
+ _mod = _enable(template_id, ignore_not_found=True) if template_id else None
_app_template["id"] = template_id
diff --git a/release/scripts/modules/bl_keymap_utils/io.py b/release/scripts/modules/bl_keymap_utils/io.py
index 7135d4bf7bd..ee08a2d7fb0 100644
--- a/release/scripts/modules/bl_keymap_utils/io.py
+++ b/release/scripts/modules/bl_keymap_utils/io.py
@@ -227,6 +227,7 @@ def _kmi_props_setattr(kmi_props, attr, value):
def keymap_init_from_data(km, km_items, is_modal=False):
+ assert type(km_items) is list
new_fn = getattr(km.keymap_items, "new_modal" if is_modal else "new")
for (kmi_idname, kmi_args, kmi_data) in km_items:
kmi = new_fn(kmi_idname, **kmi_args)
@@ -236,6 +237,7 @@ def keymap_init_from_data(km, km_items, is_modal=False):
kmi_props_data = kmi_data.get("properties", None)
if kmi_props_data is not None:
kmi_props = kmi.properties
+ assert type(kmi_props_data) is list
for attr, value in kmi_props_data:
_kmi_props_setattr(kmi_props, attr, value)
diff --git a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
index 4952dfa992b..501b15c3dc3 100644
--- a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
+++ b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
@@ -61,8 +61,6 @@ def generate(context, space_type):
]
items_all_text = {item_container[0].text for item_container in items_all}
- use_simple_keymap = False
-
# Press the toolbar popup key again to set the default tool,
# this is useful because the select box tool is useful as a way
# to 'drop' currently active tools (it's basically a 'none' tool).
@@ -165,212 +163,231 @@ def generate(context, space_type):
if item_container[0].text != tap_reset_tool
]
- if use_simple_keymap:
- # Simply assign a key from A-Z.
- for i, (item, _, _) in enumerate(items_all):
- key = chr(ord('A') + i)
- kmi = keymap.keymap_items.new("wm.tool_set_by_name", key, 'PRESS')
- kmi.properties.name = item.text
- else:
- for item_container in items_all:
- item = item_container[0]
- # Only check the first item in the tools key-map (a little arbitrary).
- if use_hack_properties:
- # First check for direct assignment.
- kmi_hack_properties.name = item.text
- kmi_found = wm.keyconfigs.find_item_from_operator(
- idname="wm.tool_set_by_name",
- context='INVOKE_REGION_WIN',
- # properties={"name": item.text},
- properties=kmi_hack_properties,
- )[1]
-
- if kmi_found is None:
- if item.data_block:
- # PAINT_OT_brush_select
- mode = context.active_object.mode
- # See: BKE_paint_get_tool_prop_id_from_paintmode
- attr = {
- 'SCULPT': "sculpt_tool",
- 'VERTEX_PAINT': "vertex_tool",
- 'WEIGHT_PAINT': "weight_tool",
- 'TEXTURE_PAINT': "image_tool",
- 'GPENCIL_PAINT': "gpencil_tool",
- }.get(mode, None)
- if attr is not None:
- setattr(kmi_hack_brush_select_properties, attr, item.data_block)
- kmi_found = wm.keyconfigs.find_item_from_operator(
- idname="paint.brush_select",
- context='INVOKE_REGION_WIN',
- properties=kmi_hack_brush_select_properties,
- )[1]
- else:
- print("Unsupported mode:", mode)
- del mode, attr
+ # -----------------------
+ # Begin Keymap Generation
- else:
- kmi_found = None
+ # -------------------------------------------------------------------------
+ # Direct Tool Assignment & Brushes
- if kmi_found is not None:
- pass
- elif item.operator is not None:
- kmi_found = wm.keyconfigs.find_item_from_operator(
- idname=item.operator,
- context='INVOKE_REGION_WIN',
- )[1]
- elif item.keymap is not None:
- km = keyconf.keymaps.get(item.keymap[0])
- if km is None:
- print("Keymap", repr(item.keymap[0]), "not found for tool", item.text)
- kmi_found = None
- else:
- kmi_first = km.keymap_items
- kmi_first = kmi_first[0] if kmi_first else None
- if kmi_first is not None:
+ for item_container in items_all:
+ item = item_container[0]
+ # Only check the first item in the tools key-map (a little arbitrary).
+ if use_hack_properties:
+ # First check for direct assignment.
+ kmi_hack_properties.name = item.text
+ kmi_found = wm.keyconfigs.find_item_from_operator(
+ idname="wm.tool_set_by_name",
+ context='INVOKE_REGION_WIN',
+ # properties={"name": item.text},
+ properties=kmi_hack_properties,
+ )[1]
+
+ if kmi_found is None:
+ if item.data_block:
+ # PAINT_OT_brush_select
+ mode = context.active_object.mode
+ # See: BKE_paint_get_tool_prop_id_from_paintmode
+ attr = {
+ 'SCULPT': "sculpt_tool",
+ 'VERTEX_PAINT': "vertex_tool",
+ 'WEIGHT_PAINT': "weight_tool",
+ 'TEXTURE_PAINT': "image_tool",
+ 'GPENCIL_PAINT': "gpencil_tool",
+ }.get(mode, None)
+ if attr is not None:
+ setattr(kmi_hack_brush_select_properties, attr, item.data_block)
kmi_found = wm.keyconfigs.find_item_from_operator(
- idname=kmi_first.idname,
- # properties=kmi_first.properties, # prevents matches, don't use.
+ idname="paint.brush_select",
context='INVOKE_REGION_WIN',
+ properties=kmi_hack_brush_select_properties,
)[1]
else:
- kmi_found = None
- del kmi_first
- del km
- else:
- kmi_found = None
- item_container[1] = kmi_found
+ print("Unsupported mode:", mode)
+ del mode, attr
- # More complex multi-pass test.
- for item_container in items_all:
- item, kmi_found = item_container[:2]
- if kmi_found is None:
- continue
- kmi_found_type = kmi_found.type
+ else:
+ kmi_found = None
- # Only for single keys.
- if (
- (len(kmi_found_type) == 1) or
- # When a tool is being activated instead of running an operator, just copy the shortcut.
- (kmi_found.idname in {"wm.tool_set_by_name", "WM_OT_tool_set_by_name"})
- ):
+ if kmi_found is not None:
+ pass
+ elif item.operator is not None:
+ kmi_found = wm.keyconfigs.find_item_from_operator(
+ idname=item.operator,
+ context='INVOKE_REGION_WIN',
+ )[1]
+ elif item.keymap is not None:
+ km = keyconf.keymaps.get(item.keymap[0])
+ if km is None:
+ print("Keymap", repr(item.keymap[0]), "not found for tool", item.text)
+ kmi_found = None
+ else:
+ kmi_first = km.keymap_items
+ kmi_first = kmi_first[0] if kmi_first else None
+ if kmi_first is not None:
+ kmi_found = wm.keyconfigs.find_item_from_operator(
+ idname=kmi_first.idname,
+ # properties=kmi_first.properties, # prevents matches, don't use.
+ context='INVOKE_REGION_WIN',
+ )[1]
+ else:
+ kmi_found = None
+ del kmi_first
+ del km
+ else:
+ kmi_found = None
+ item_container[1] = kmi_found
+
+ # -------------------------------------------------------------------------
+ # Single Key Access
+
+ # More complex multi-pass test.
+ for item_container in items_all:
+ item, kmi_found = item_container[:2]
+ if kmi_found is None:
+ continue
+ kmi_found_type = kmi_found.type
+
+ # Only for single keys.
+ if (
+ (len(kmi_found_type) == 1) or
+ # When a tool is being activated instead of running an operator, just copy the shortcut.
+ (kmi_found.idname in {"wm.tool_set_by_name", "WM_OT_tool_set_by_name"})
+ ):
+ kmi_args = {"type": kmi_found_type, **modifier_keywords_from_item(kmi_found)}
+ if kmi_unique_or_pass(kmi_args):
+ kmi = keymap.keymap_items.new(idname="wm.tool_set_by_name", value='PRESS', **kmi_args)
+ kmi.properties.name = item.text
+ item_container[2] = kmi
+
+ # -------------------------------------------------------------------------
+ # Single Key Modifier
+ #
+ #
+ # Test for key_modifier, where alpha key is used as a 'key_modifier'
+ # (grease pencil holding 'D' for example).
+
+ for item_container in items_all:
+ item, kmi_found, kmi_exist = item_container
+ if kmi_found is None or kmi_exist:
+ continue
+
+ kmi_found_type = kmi_found.type
+ if kmi_found_type in {
+ 'LEFTMOUSE',
+ 'RIGHTMOUSE',
+ 'MIDDLEMOUSE',
+ 'BUTTON4MOUSE',
+ 'BUTTON5MOUSE',
+ 'BUTTON6MOUSE',
+ 'BUTTON7MOUSE',
+ }:
+ kmi_found_type = kmi_found.key_modifier
+ # excludes 'NONE'
+ if len(kmi_found_type) == 1:
kmi_args = {"type": kmi_found_type, **modifier_keywords_from_item(kmi_found)}
+ del kmi_args["key_modifier"]
if kmi_unique_or_pass(kmi_args):
kmi = keymap.keymap_items.new(idname="wm.tool_set_by_name", value='PRESS', **kmi_args)
kmi.properties.name = item.text
item_container[2] = kmi
- # Test for key_modifier, where alpha key is used as a 'key_modifier'
- # (grease pencil holding 'D' for example).
+ # -------------------------------------------------------------------------
+ # Assign A-Z to Keys
+ #
+ # When th keys are free.
+
+ if use_auto_keymap_alpha:
+ # Map all unmapped keys to numbers,
+ # while this is a bit strange it means users will not confuse regular key bindings to ordered bindings.
+
+ # First map A-Z.
+ kmi_type_alpha_char = [chr(i) for i in range(65, 91)]
+ kmi_type_alpha_args = {c: {"type": c} for c in kmi_type_alpha_char}
+ kmi_type_alpha_args_tuple = {c: dict_as_tuple(kmi_type_alpha_args[c]) for c in kmi_type_alpha_char}
for item_container in items_all:
item, kmi_found, kmi_exist = item_container
- if kmi_found is None or kmi_exist:
+ if kmi_exist:
continue
+ kmi_type = item.text[0].upper()
+ kmi_tuple = kmi_type_alpha_args_tuple.get(kmi_type)
+ if kmi_tuple and kmi_tuple not in kmi_unique_args:
+ kmi_unique_args.add(kmi_tuple)
+ kmi = keymap.keymap_items.new(
+ idname="wm.tool_set_by_name",
+ value='PRESS',
+ **kmi_type_alpha_args[kmi_type],
+ )
+ kmi.properties.name = item.text
+ item_container[2] = kmi
+ del kmi_type_alpha_char, kmi_type_alpha_args, kmi_type_alpha_args_tuple
+
+ # -------------------------------------------------------------------------
+ # Assign Numbers to Keys
+
+ if use_auto_keymap_num:
+ # Free events (last used first).
+ kmi_type_auto = ('ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE', 'ZERO')
+ # Map both numbers and num-pad.
+ kmi_type_dupe = {
+ 'ONE': 'NUMPAD_1',
+ 'TWO': 'NUMPAD_2',
+ 'THREE': 'NUMPAD_3',
+ 'FOUR': 'NUMPAD_4',
+ 'FIVE': 'NUMPAD_5',
+ 'SIX': 'NUMPAD_6',
+ 'SEVEN': 'NUMPAD_7',
+ 'EIGHT': 'NUMPAD_8',
+ 'NINE': 'NUMPAD_9',
+ 'ZERO': 'NUMPAD_0',
+ }
+
+ def iter_free_events():
+ for mod in ({}, {"shift": True}, {"ctrl": True}, {"alt": True}):
+ for e in kmi_type_auto:
+ yield (e, mod)
+
+ iter_events = iter(iter_free_events())
- kmi_found_type = kmi_found.type
- if kmi_found_type in {
- 'LEFTMOUSE',
- 'RIGHTMOUSE',
- 'MIDDLEMOUSE',
- 'BUTTON4MOUSE',
- 'BUTTON5MOUSE',
- 'BUTTON6MOUSE',
- 'BUTTON7MOUSE',
- }:
- kmi_found_type = kmi_found.key_modifier
- # excludes 'NONE'
- if len(kmi_found_type) == 1:
- kmi_args = {"type": kmi_found_type, **modifier_keywords_from_item(kmi_found)}
- del kmi_args["key_modifier"]
- if kmi_unique_or_pass(kmi_args):
+ for item_container in items_all:
+ item, kmi_found, kmi_exist = item_container
+ if kmi_exist:
+ continue
+ kmi_args = None
+ while True:
+ key, mod = next(iter_events, (None, None))
+ if key is None:
+ break
+ kmi_args = {"type": key, **mod}
+ kmi_tuple = dict_as_tuple(kmi_args)
+ if kmi_tuple in kmi_unique_args:
+ kmi_args = None
+ else:
+ break
+
+ if kmi_args is not None:
+ kmi = keymap.keymap_items.new(idname="wm.tool_set_by_name", value='PRESS', **kmi_args)
+ kmi.properties.name = item.text
+ item_container[2] = kmi
+ kmi_unique_args.add(kmi_tuple)
+
+ key = kmi_type_dupe.get(kmi_args["type"])
+ if key is not None:
+ kmi_args["type"] = key
+ kmi_tuple = dict_as_tuple(kmi_args)
+ if not kmi_tuple in kmi_unique_args:
kmi = keymap.keymap_items.new(idname="wm.tool_set_by_name", value='PRESS', **kmi_args)
kmi.properties.name = item.text
- item_container[2] = kmi
-
- if use_auto_keymap_alpha:
- # Map all unmapped keys to numbers,
- # while this is a bit strange it means users will not confuse regular key bindings to ordered bindings.
-
- # First map A-Z.
- kmi_type_alpha_char = [chr(i) for i in range(65, 91)]
- kmi_type_alpha_args = {c: {"type": c} for c in kmi_type_alpha_char}
- kmi_type_alpha_args_tuple = {c: dict_as_tuple(kmi_type_alpha_args[c]) for c in kmi_type_alpha_char}
- for item_container in items_all:
- item, kmi_found, kmi_exist = item_container
- if kmi_exist:
- continue
- kmi_type = item.text[0].upper()
- kmi_tuple = kmi_type_alpha_args_tuple.get(kmi_type)
- if kmi_tuple and kmi_tuple not in kmi_unique_args:
- kmi_unique_args.add(kmi_tuple)
- kmi = keymap.keymap_items.new(
- idname="wm.tool_set_by_name",
- value='PRESS',
- **kmi_type_alpha_args[kmi_type],
- )
- kmi.properties.name = item.text
- item_container[2] = kmi
- del kmi_type_alpha_char, kmi_type_alpha_args, kmi_type_alpha_args_tuple
-
- if use_auto_keymap_num:
- # Free events (last used first).
- kmi_type_auto = ('ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE', 'ZERO')
- # Map both numbers and num-pad.
- kmi_type_dupe = {
- 'ONE': 'NUMPAD_1',
- 'TWO': 'NUMPAD_2',
- 'THREE': 'NUMPAD_3',
- 'FOUR': 'NUMPAD_4',
- 'FIVE': 'NUMPAD_5',
- 'SIX': 'NUMPAD_6',
- 'SEVEN': 'NUMPAD_7',
- 'EIGHT': 'NUMPAD_8',
- 'NINE': 'NUMPAD_9',
- 'ZERO': 'NUMPAD_0',
- }
-
- def iter_free_events():
- for mod in ({}, {"shift": True}, {"ctrl": True}, {"alt": True}):
- for e in kmi_type_auto:
- yield (e, mod)
-
- iter_events = iter(iter_free_events())
-
- for item_container in items_all:
- item, kmi_found, kmi_exist = item_container
- if kmi_exist:
- continue
- kmi_args = None
- while True:
- key, mod = next(iter_events, (None, None))
- if key is None:
- break
- kmi_args = {"type": key, **mod}
- kmi_tuple = dict_as_tuple(kmi_args)
- if kmi_tuple in kmi_unique_args:
- kmi_args = None
- else:
- break
+ kmi_unique_args.add(kmi_tuple)
- if kmi_args is not None:
- kmi = keymap.keymap_items.new(idname="wm.tool_set_by_name", value='PRESS', **kmi_args)
- kmi.properties.name = item.text
- item_container[2] = kmi
- kmi_unique_args.add(kmi_tuple)
- key = kmi_type_dupe.get(kmi_args["type"])
- if key is not None:
- kmi_args["type"] = key
- kmi_tuple = dict_as_tuple(kmi_args)
- if not kmi_tuple in kmi_unique_args:
- kmi = keymap.keymap_items.new(idname="wm.tool_set_by_name", value='PRESS', **kmi_args)
- kmi.properties.name = item.text
- kmi_unique_args.add(kmi_tuple)
+ # ---------------------
+ # End Keymap Generation
if use_hack_properties:
keymap.keymap_items.remove(kmi_hack)
+ keymap.keymap_items.remove(kmi_hack_brush_select)
-
- # Keepo last so we can try add a key without any modifiers
+ # Keep last so we can try add a key without any modifiers
# in the case this toolbar was activated with modifiers.
if use_tap_reset:
if len(kmi_toolbar_args_type_only) == len(kmi_toolbar_args):
diff --git a/release/scripts/modules/bl_previews_utils/bl_previews_render.py b/release/scripts/modules/bl_previews_utils/bl_previews_render.py
index 16b0b107927..084937f0369 100644
--- a/release/scripts/modules/bl_previews_utils/bl_previews_render.py
+++ b/release/scripts/modules/bl_previews_utils/bl_previews_render.py
@@ -229,13 +229,13 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
def object_bbox_merge(bbox, ob, ob_space, offset_matrix):
# Take collections instances into account (including linked one in this case).
- if ob.type == 'EMPTY' and ob.dupli_type == 'COLLECTION':
- grp_objects = tuple((ob.name, ob.library.filepath if ob.library else None) for ob in ob.dupli_group.all_objects)
+ if ob.type == 'EMPTY' and ob.instance_type == 'COLLECTION':
+ grp_objects = tuple((ob.name, ob.library.filepath if ob.library else None) for ob in ob.instance_collection.all_objects)
if (len(grp_objects) == 0):
ob_bbox = ob.bound_box
else:
coords = objects_bbox_calc(ob_space, grp_objects,
- Matrix.Translation(ob.dupli_group.dupli_offset).inverted())
+ Matrix.Translation(ob.instance_collection.instance_offset).inverted())
ob_bbox = ((coords[0], coords[1], coords[2]), (coords[21], coords[22], coords[23]))
elif ob.bound_box:
ob_bbox = ob.bound_box
@@ -390,11 +390,11 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
bpy.context.screen.scene = scene
bpy.ops.object.collection_instance_add(collection=grp.name)
- grp_ob = next((ob for ob in scene.objects if ob.dupli_group and ob.dupli_group.name == grp.name))
+ grp_ob = next((ob for ob in scene.objects if ob.instance_collection and ob.instance_collection.name == grp.name))
grp_obname = grp_ob.name
scene.update()
- offset_matrix = Matrix.Translation(grp.dupli_offset).inverted()
+ offset_matrix = Matrix.Translation(grp.instance_offset).inverted()
preview_render_do(render_context, 'collections', grp.name, objects, offset_matrix)
diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py
index 9889b16829b..75044d9d85c 100644
--- a/release/scripts/modules/bpy/utils/__init__.py
+++ b/release/scripts/modules/bpy/utils/__init__.py
@@ -718,48 +718,6 @@ def register_submodule_factory(module_name, submodule_names):
# -----------------------------------------------------------------------------
-# Tool Registraion
-
-def register_tool(space_type, context_mode, tool_def):
- from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
- cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
- if cls is None:
- raise Exception(f"Space type {space_type!r} has no toolbar")
- tools = cls._tools[context_mode]
-
- keymap_data = tool_def.keymap
- if keymap_data is not None:
- if context_mode is None:
- context_descr = "All"
- else:
- context_descr = context_mode.replace("_", " ").title()
- from bpy import context
- wm = context.window_manager
- kc = wm.keyconfigs.default
- if callable(keymap_data[0]):
- cls._km_action_simple(kc, context_descr, tool_def.text, keymap_data)
-
- tools.append(tool_def)
-
-
-def unregister_tool(space_type, context_mode, tool_def):
- from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
- cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
- if cls is None:
- raise Exception(f"Space type {space_type!r} has no toolbar")
- tools = cls._tools[context_mode]
- tools.remove(tool_def)
-
- keymap_data = tool_def.keymap
- if keymap_data is not None:
- from bpy import context
- wm = context.window_manager
- kc = wm.keyconfigs.default
- km = keymap_data[0]
- kc.keymaps.remove(km)
-
-
-# -----------------------------------------------------------------------------
# Manual lookups, each function has to return a basepath and a sequence
# of...
diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py
index e74631256e3..d7cca7cc896 100644
--- a/release/scripts/modules/bpy_extras/io_utils.py
+++ b/release/scripts/modules/bpy_extras/io_utils.py
@@ -127,6 +127,11 @@ def orientation_helper(axis_forward='Y', axis_up='Z'):
with specified default values (axes).
"""
def wrapper(cls):
+ # Without that, we may end up adding those fields to some **parent** class' __annotations__ property
+ # (like the ImportHelper or ExportHelper ones)! See T58772.
+ if "__annotations__" not in cls.__dict__:
+ setattr(cls, "__annotations__", {})
+
def _update_axis_forward(self, context):
if self.axis_forward[-1] == self.axis_up[-1]:
self.axis_up = (self.axis_up[0:-1] +
@@ -341,10 +346,10 @@ def axis_conversion_ensure(operator, forward_attr, up_attr):
# return a tuple (free, object list), free is True if memory should be freed
# later with free_derived_objects()
def create_derived_objects(scene, ob):
- if ob.parent and ob.parent.dupli_type in {'VERTS', 'FACES'}:
+ if ob.parent and ob.parent.instance_type in {'VERTS', 'FACES'}:
return False, None
- if ob.dupli_type != 'NONE':
+ if ob.instance_type != 'NONE':
ob.dupli_list_create(scene)
return True, [(dob.object, dob.matrix) for dob in ob.dupli_list]
else:
diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py
index 4fa090b7336..ea7a4a5cd57 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -61,10 +61,7 @@ def add_object_align_init(context, operator):
if operator and properties.is_property_set("location"):
location = Matrix.Translation(Vector(properties.location))
else:
- if space_data: # local view cursor is detected below
- location = Matrix.Translation(space_data.cursor_location)
- else:
- location = Matrix.Translation(context.scene.cursor_location)
+ location = Matrix.Translation(context.scene.cursor_location)
if operator:
properties.location = location.to_translation()
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index dda1ab7b4ed..c6552334dcf 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -104,7 +104,7 @@ class Collection(bpy_types.ID):
"""The collection instance objects this collection is used in"""
import bpy
return tuple(obj for obj in bpy.data.objects
- if self == obj.dupli_group)
+ if self == obj.instance_collection)
class Object(bpy_types.ID):
@@ -645,7 +645,7 @@ class Gizmo(StructRNA):
# Only defined so operators members can be used by accessing self.order
# with doc generation 'self.properties.bl_rna.properties' can fail
-class Operator(StructRNA):
+class Operator(StructRNA, metaclass=RNAMeta):
__slots__ = ()
def __getattribute__(self, attr):
diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py
index 535f2cda626..490aae1c640 100644
--- a/release/scripts/modules/rna_info.py
+++ b/release/scripts/modules/rna_info.py
@@ -754,14 +754,14 @@ def main():
import rna_info
struct = rna_info.BuildRNAInfo()[0]
data = []
- for struct_id, v in sorted(struct.items()):
+ for _struct_id, v in sorted(struct.items()):
struct_id_str = v.identifier # "".join(sid for sid in struct_id if struct_id)
for base in v.get_bases():
struct_id_str = base.identifier + "|" + struct_id_str
props = [(prop.identifier, prop) for prop in v.properties]
- for prop_id, prop in sorted(props):
+ for _prop_id, prop in sorted(props):
# if prop.type == "boolean":
# continue
prop_type = prop.type
diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py
index 7fc9bcb0261..f803a5b9f81 100644
--- a/release/scripts/modules/rna_xml.py
+++ b/release/scripts/modules/rna_xml.py
@@ -396,7 +396,7 @@ def xml_file_write(context, filepath, rna_map, skip_typemap=None):
fw("<bpy>\n")
- for rna_path, xml_tag in rna_map:
+ for rna_path, _xml_tag in rna_map:
# xml_tag is ignored, we get this from the rna
value = _get_context_val(context, rna_path)
rna2xml(fw,
diff --git a/release/scripts/presets/cloth/cotton.py b/release/scripts/presets/cloth/cotton.py
index 695050cf195..9e766416a75 100644
--- a/release/scripts/presets/cloth/cotton.py
+++ b/release/scripts/presets/cloth/cotton.py
@@ -1,7 +1,11 @@
import bpy
bpy.context.cloth.settings.quality = 5
bpy.context.cloth.settings.mass = 0.300
-bpy.context.cloth.settings.structural_stiffness = 15.000
+bpy.context.cloth.settings.tension_stiffness = 15
+bpy.context.cloth.settings.compression_stiffness = 15
+bpy.context.cloth.settings.shear_stiffness = 15
bpy.context.cloth.settings.bending_stiffness = 0.500
-bpy.context.cloth.settings.spring_damping = 5.000
+bpy.context.cloth.settings.tension_damping = 5
+bpy.context.cloth.settings.compression_damping = 5
+bpy.context.cloth.settings.shear_damping = 5
bpy.context.cloth.settings.air_damping = 1.000
diff --git a/release/scripts/presets/cloth/denim.py b/release/scripts/presets/cloth/denim.py
index bd72fa873da..7abf4469709 100644
--- a/release/scripts/presets/cloth/denim.py
+++ b/release/scripts/presets/cloth/denim.py
@@ -1,7 +1,11 @@
import bpy
bpy.context.cloth.settings.quality = 12
bpy.context.cloth.settings.mass = 1
-bpy.context.cloth.settings.structural_stiffness = 40
+bpy.context.cloth.settings.tension_stiffness = 40
+bpy.context.cloth.settings.compression_stiffness = 40
+bpy.context.cloth.settings.shear_stiffness = 40
bpy.context.cloth.settings.bending_stiffness = 10
-bpy.context.cloth.settings.spring_damping = 25
+bpy.context.cloth.settings.tension_damping = 25
+bpy.context.cloth.settings.compression_damping = 25
+bpy.context.cloth.settings.shear_damping = 25
bpy.context.cloth.settings.air_damping = 1
diff --git a/release/scripts/presets/cloth/leather.py b/release/scripts/presets/cloth/leather.py
index b85f504b0bb..8ba9ff7dabe 100644
--- a/release/scripts/presets/cloth/leather.py
+++ b/release/scripts/presets/cloth/leather.py
@@ -1,7 +1,11 @@
import bpy
bpy.context.cloth.settings.quality = 15
bpy.context.cloth.settings.mass = 0.4
-bpy.context.cloth.settings.structural_stiffness = 80
+bpy.context.cloth.settings.tension_stiffness = 80
+bpy.context.cloth.settings.compression_stiffness = 80
+bpy.context.cloth.settings.shear_stiffness = 80
bpy.context.cloth.settings.bending_stiffness = 150
-bpy.context.cloth.settings.spring_damping = 25
+bpy.context.cloth.settings.tension_damping = 25
+bpy.context.cloth.settings.compression_damping = 25
+bpy.context.cloth.settings.shear_damping = 25
bpy.context.cloth.settings.air_damping = 1
diff --git a/release/scripts/presets/cloth/rubber.py b/release/scripts/presets/cloth/rubber.py
index cb354168daa..0d791fab2a9 100644
--- a/release/scripts/presets/cloth/rubber.py
+++ b/release/scripts/presets/cloth/rubber.py
@@ -1,7 +1,11 @@
import bpy
bpy.context.cloth.settings.quality = 7
bpy.context.cloth.settings.mass = 3
-bpy.context.cloth.settings.structural_stiffness = 15
+bpy.context.cloth.settings.tension_stiffness = 15
+bpy.context.cloth.settings.compression_stiffness = 15
+bpy.context.cloth.settings.shear_stiffness = 15
bpy.context.cloth.settings.bending_stiffness = 25
-bpy.context.cloth.settings.spring_damping = 25
+bpy.context.cloth.settings.tension_damping = 25
+bpy.context.cloth.settings.compression_damping = 25
+bpy.context.cloth.settings.shear_damping = 25
bpy.context.cloth.settings.air_damping = 1
diff --git a/release/scripts/presets/cloth/silk.py b/release/scripts/presets/cloth/silk.py
index c2a98c270b8..af867cf9c60 100644
--- a/release/scripts/presets/cloth/silk.py
+++ b/release/scripts/presets/cloth/silk.py
@@ -1,7 +1,11 @@
import bpy
bpy.context.cloth.settings.quality = 5
bpy.context.cloth.settings.mass = 0.150
-bpy.context.cloth.settings.structural_stiffness = 5
+bpy.context.cloth.settings.tension_stiffness = 5
+bpy.context.cloth.settings.compression_stiffness = 5
+bpy.context.cloth.settings.shear_stiffness = 5
bpy.context.cloth.settings.bending_stiffness = 0.05
-bpy.context.cloth.settings.spring_damping = 0
+bpy.context.cloth.settings.tension_damping = 0
+bpy.context.cloth.settings.compression_damping = 0
+bpy.context.cloth.settings.shear_damping = 0
bpy.context.cloth.settings.air_damping = 1
diff --git a/release/scripts/presets/interface_theme/blender_light.xml b/release/scripts/presets/interface_theme/blender_light.xml
index 497b6575731..1cd93d7f0fe 100644
--- a/release/scripts/presets/interface_theme/blender_light.xml
+++ b/release/scripts/presets/interface_theme/blender_light.xml
@@ -11,11 +11,11 @@
axis_x="#ff3352"
axis_y="#8bdc00"
axis_z="#046bdc"
- manipulator_hi="#ffffff"
- manipulator_primary="#ffd842"
- manipulator_secondary="#43c2ff"
- manipulator_a="#2b9757"
- manipulator_b="#c43164">
+ icon_collection="#000000"
+ icon_object="#000000"
+ icon_object_data="#000000"
+ icon_modifier="#000000"
+ icon_shading="#000000">
<wcol_regular>
<ThemeWidgetColors outline="#9d9d9d"
inner="#b3b3b3ff"
@@ -25,8 +25,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="0"
- shadedown="-5"
- roundness="0.5">
+ shadedown="-5">
</ThemeWidgetColors>
</wcol_regular>
<wcol_tool>
@@ -38,21 +37,19 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="0"
- shadedown="-5"
- roundness="0.5">
+ shadedown="-5">
</ThemeWidgetColors>
</wcol_tool>
<wcol_toolbar_item>
<ThemeWidgetColors outline="#808080"
- inner="#b3b3b3ff"
- inner_sel="#dbdbdbff"
- item="#1a1a1aff"
- text="#1a1a1a"
- text_sel="#000000"
+ inner="#434343ff"
+ inner_sel="#5680c2ff"
+ item="#ffffff8f"
+ text="#e6e6e6"
+ text_sel="#ffffff"
show_shaded="FALSE"
shadetop="0"
- shadedown="0"
- roundness="0.5">
+ shadedown="0">
</ThemeWidgetColors>
</wcol_toolbar_item>
<wcol_radio>
@@ -64,8 +61,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="5"
- shadedown="-5"
- roundness="0.5">
+ shadedown="-5">
</ThemeWidgetColors>
</wcol_radio>
<wcol_text>
@@ -77,8 +73,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="-8"
- shadedown="0"
- roundness="0.5">
+ shadedown="0">
</ThemeWidgetColors>
</wcol_text>
<wcol_option>
@@ -90,8 +85,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="0"
- shadedown="-15"
- roundness="0.5">
+ shadedown="-15">
</ThemeWidgetColors>
</wcol_option>
<wcol_toggle>
@@ -103,8 +97,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="0"
- shadedown="0"
- roundness="0.5">
+ shadedown="0">
</ThemeWidgetColors>
</wcol_toggle>
<wcol_num>
@@ -116,8 +109,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="-10"
- shadedown="0"
- roundness="0.7">
+ shadedown="0">
</ThemeWidgetColors>
</wcol_num>
<wcol_numslider>
@@ -129,8 +121,7 @@
text_sel="#ffffff"
show_shaded="TRUE"
shadetop="-4"
- shadedown="0"
- roundness="0.7">
+ shadedown="0">
</ThemeWidgetColors>
</wcol_numslider>
<wcol_box>
@@ -142,8 +133,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="0"
- shadedown="0"
- roundness="0.4">
+ shadedown="0">
</ThemeWidgetColors>
</wcol_box>
<wcol_menu>
@@ -155,8 +145,7 @@
text_sel="#cccccc"
show_shaded="FALSE"
shadetop="10"
- shadedown="-10"
- roundness="0.4">
+ shadedown="-10">
</ThemeWidgetColors>
</wcol_menu>
<wcol_pulldown>
@@ -168,8 +157,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="25"
- shadedown="-20"
- roundness="0.3">
+ shadedown="-20">
</ThemeWidgetColors>
</wcol_pulldown>
<wcol_menu_back>
@@ -181,8 +169,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="25"
- shadedown="-20"
- roundness="0.5">
+ shadedown="-20">
</ThemeWidgetColors>
</wcol_menu_back>
<wcol_pie_menu>
@@ -194,8 +181,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="10"
- shadedown="-10"
- roundness="1">
+ shadedown="-10">
</ThemeWidgetColors>
</wcol_pie_menu>
<wcol_tooltip>
@@ -207,8 +193,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="25"
- shadedown="-20"
- roundness="0.5">
+ shadedown="-20">
</ThemeWidgetColors>
</wcol_tooltip>
<wcol_menu_item>
@@ -220,8 +205,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="38"
- shadedown="0"
- roundness="0.5">
+ shadedown="0">
</ThemeWidgetColors>
</wcol_menu_item>
<wcol_scroll>
@@ -233,8 +217,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="5"
- shadedown="-5"
- roundness="1">
+ shadedown="-5">
</ThemeWidgetColors>
</wcol_scroll>
<wcol_progress>
@@ -246,8 +229,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="0"
- shadedown="0"
- roundness="0.5">
+ shadedown="0">
</ThemeWidgetColors>
</wcol_progress>
<wcol_list_item>
@@ -259,8 +241,7 @@
text_sel="#ffffff"
show_shaded="FALSE"
shadetop="0"
- shadedown="0"
- roundness="0.4">
+ shadedown="0">
</ThemeWidgetColors>
</wcol_list_item>
<wcol_state>
@@ -284,8 +265,7 @@
text_sel="#000000"
show_shaded="FALSE"
shadetop="0"
- shadedown="0"
- roundness="0.3">
+ shadedown="0">
</ThemeWidgetColors>
</wcol_tab>
</ThemeUserInterface>
@@ -380,9 +360,7 @@
</gradients>
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#999999cc"
- show_header="TRUE"
- show_back="TRUE">
+ back="#999999cc">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGradient>
@@ -435,9 +413,7 @@
tab_outline="#999999">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#999999ff"
- show_header="TRUE"
- show_back="TRUE">
+ back="#999999ff">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -471,9 +447,7 @@
tab_outline="#999999">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#99999980"
- show_header="TRUE"
- show_back="TRUE">
+ back="#99999980">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -516,9 +490,7 @@
tab_outline="#3c3c3c">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#99999980"
- show_header="TRUE"
- show_back="TRUE">
+ back="#99999980">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -575,9 +547,7 @@
tab_outline="#3c3c3c">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#99999980"
- show_header="TRUE"
- show_back="TRUE">
+ back="#99999980">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -651,9 +621,7 @@
tab_outline="#3c3c3c">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#99999980"
- show_header="TRUE"
- show_back="TRUE">
+ back="#99999980">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -699,9 +667,7 @@
tab_outline="#3c3c3c">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#99999980"
- show_header="TRUE"
- show_back="TRUE">
+ back="#99999980">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -725,12 +691,11 @@
tab_active="#6697e6"
tab_inactive="#535353"
tab_back="#404040ff"
- tab_outline="#3c3c3c">
+ tab_outline="#3c3c3c"
+ navigation_bar="#808080ff">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#99999980"
- show_header="TRUE"
- show_back="TRUE">
+ back="#99999980">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -767,9 +732,7 @@
tab_outline="#3c3c3c">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#99999980"
- show_header="TRUE"
- show_back="TRUE">
+ back="#99999980">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -822,9 +785,7 @@
tab_outline="#999999">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#999999ff"
- show_header="TRUE"
- show_back="TRUE">
+ back="#999999ff">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -859,9 +820,7 @@
tab_outline="#3c3c3c">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#99999980"
- show_header="TRUE"
- show_back="TRUE">
+ back="#99999980">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -897,9 +856,7 @@
tab_outline="#3c3c3c">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#99999980"
- show_header="TRUE"
- show_back="TRUE">
+ back="#99999980">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -923,12 +880,11 @@
tab_active="#6697e6"
tab_inactive="#535353"
tab_back="#404040ff"
- tab_outline="#3c3c3c">
+ tab_outline="#3c3c3c"
+ navigation_bar="#808080ff">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#99999980"
- show_header="TRUE"
- show_back="TRUE">
+ back="#99999980">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -960,9 +916,7 @@
tab_outline="#3c3c3c">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#99999980"
- show_header="TRUE"
- show_back="TRUE">
+ back="#99999980">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -1013,9 +967,7 @@
tab_outline="#3c3c3c">
<panelcolors>
<ThemePanelColors header="#c2c2c2ea"
- back="#99999980"
- show_header="TRUE"
- show_back="TRUE">
+ back="#99999980">
</ThemePanelColors>
</panelcolors>
</ThemeSpaceGeneric>
@@ -1047,13 +999,6 @@
tab_inactive="#28292d"
tab_back="#28292dff"
tab_outline="#28292d">
- <panelcolors>
- <ThemePanelColors header="#29282eff"
- back="#3e3f46ff"
- show_header="TRUE"
- show_back="TRUE">
- </ThemePanelColors>
- </panelcolors>
</ThemeSpaceGeneric>
</space>
</ThemeTopBar>
@@ -1076,13 +1021,6 @@
tab_inactive="#28292d"
tab_back="#28292dff"
tab_outline="#28292d">
- <panelcolors>
- <ThemePanelColors header="#29282eff"
- back="#3e3f46ff"
- show_header="TRUE"
- show_back="TRUE">
- </ThemePanelColors>
- </panelcolors>
</ThemeSpaceGeneric>
</space>
</ThemeStatusBar>
diff --git a/release/scripts/presets/keyconfig/blender.py b/release/scripts/presets/keyconfig/blender.py
index eb5444eb77a..ff8edbdede7 100644
--- a/release/scripts/presets/keyconfig/blender.py
+++ b/release/scripts/presets/keyconfig/blender.py
@@ -18,32 +18,41 @@ class Prefs(bpy.types.KeyConfigPreferences):
select_mouse: EnumProperty(
name="Select Mouse",
items=(
- ('LEFT', "Left", "Use left Mouse Button for selection"),
- ('RIGHT', "Right", "Use Right Mouse Button for selection"),
+ ('LEFT', "Left",
+ "Use left mouse button for selection. "
+ "The standard behavior that works well for mouse, trackpad and tablet devices"),
+ ('RIGHT', "Right",
+ "Use right mouse button for selection, and left mouse button for actions. "
+ "This works well primarily for keyboard and mouse devices"),
),
description=(
"Mouse button used for selection"
),
- default='RIGHT',
+ default='LEFT',
update=update_fn,
)
spacebar_action: EnumProperty(
name="Spacebar",
items=(
- ('TOOL', "Tool-Bar",
+ ('PLAY', "Play",
+ "Toggle animation playback "
+ "('Shift-Space' for Tools)",
+ 1),
+ ('TOOL', "Tools",
"Open the popup tool-bar\n"
"When 'Space' is held and used as a modifier:\n"
"\u2022 Pressing the tools binding key switches to it immediately.\n"
"\u2022 Dragging the cursor over a tool and releasing activates it (like a pie menu).\n"
- ),
- ('PLAY', "Playback",
- "Toggle animation playback"
- ),
+ "For Play use 'Shift-Space'",
+ 0),
+ ('SEARCH', "Search",
+ "Open the operator search popup",
+ 2),
),
description=(
- "Action when 'Space' is pressed ('Shift-Space' is used for the other action)"
+ "Action when 'Space' is pressed"
),
- default='TOOL',
+ default='PLAY',
update=update_fn,
)
use_select_all_toggle: BoolProperty(
@@ -96,14 +105,17 @@ blender_default = bpy.utils.execfile(os.path.join(dirname, "keymap_data", "blend
def load():
+ from bpy import context
from bl_keymap_utils.io import keyconfig_init_from_data
- kc = bpy.context.window_manager.keyconfigs.new(idname)
+ prefs = context.user_preferences
+ kc = context.window_manager.keyconfigs.new(idname)
kc_prefs = kc.preferences
keyconfig_data = blender_default.generate_keymaps(
blender_default.Params(
select_mouse=kc_prefs.select_mouse,
+ use_mouse_emulate_3_button=prefs.inputs.use_mouse_emulate_3_button,
spacebar_action=kc_prefs.spacebar_action,
use_select_all_toggle=kc_prefs.use_select_all_toggle,
use_v3d_tab_menu=kc_prefs.use_v3d_tab_menu,
diff --git a/release/scripts/presets/keyconfig/blender_27x.py b/release/scripts/presets/keyconfig/blender_27x.py
index 54f10e89402..d60324f22d6 100644
--- a/release/scripts/presets/keyconfig/blender_27x.py
+++ b/release/scripts/presets/keyconfig/blender_27x.py
@@ -17,8 +17,12 @@ class Prefs(bpy.types.KeyConfigPreferences):
select_mouse: EnumProperty(
name="Select Mouse",
items=(
- ('LEFT', "Left", "Use left Mouse Button for selection"),
- ('RIGHT', "Right", "Use Right Mouse Button for selection"),
+ ('LEFT', "Left",
+ "Use left mouse button for selection. "
+ "The standard behavior that works well for mouse, trackpad and tablet devices"),
+ ('RIGHT', "Right",
+ "Use right mouse button for selection, and left mouse button for actions. "
+ "This works well primarily for keyboard and mouse devices"),
),
description=(
"Mouse button used for selection"
@@ -38,14 +42,19 @@ class Prefs(bpy.types.KeyConfigPreferences):
blender_default = bpy.utils.execfile(os.path.join(dirname, "keymap_data", "blender_default.py"))
def load():
+ from bpy import context
from bl_keymap_utils.io import keyconfig_init_from_data
- kc = bpy.context.window_manager.keyconfigs.new(idname)
+ prefs = context.user_preferences
+ kc = context.window_manager.keyconfigs.new(idname)
kc_prefs = kc.preferences
keyconfig_data = blender_default.generate_keymaps(
blender_default.Params(
select_mouse=kc_prefs.select_mouse,
+ use_mouse_emulate_3_button=prefs.inputs.use_mouse_emulate_3_button,
+ spacebar_action='SEARCH',
+ use_select_all_toggle=True,
legacy=True,
),
)
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 2b83b03f322..efa48d69b31 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -34,6 +34,7 @@ class Params:
"context_menu_event",
"cursor_set_event",
"cursor_tweak_event",
+ "use_mouse_emulate_3_button",
# User preferences.
#
@@ -52,6 +53,7 @@ class Params:
*,
legacy=False,
select_mouse='RIGHT',
+ use_mouse_emulate_3_button=False,
# User preferences.
spacebar_action='TOOL',
@@ -97,6 +99,8 @@ class Params:
self.cursor_set_event = {"type": 'RIGHTMOUSE', "value": 'PRESS', "shift": True}
self.cursor_tweak_event = {"type": 'EVT_TWEAK_R', "value": 'ANY', "shift": True}
+ self.use_mouse_emulate_3_button = use_mouse_emulate_3_button
+
# User preferences
self.spacebar_action = spacebar_action
self.use_select_all_toggle = use_select_all_toggle
@@ -133,6 +137,10 @@ def op_tool(tool, kmi_args):
return ("wm.tool_set_by_name", kmi_args, {"properties": [("name", tool)]})
+def op_tool_cycle(tool, kmi_args):
+ return ("wm.tool_set_by_name", kmi_args, {"properties": [("name", tool), ("cycle", True)]})
+
+
# ------------------------------------------------------------------------------
# Keymap Templates
@@ -156,7 +164,7 @@ def _template_items_object_subdivision_set():
return [
("object.subdivision_set",
{"type": NUMBERS_0[i], "value": 'PRESS', "ctrl": True},
- {"properties": [("level", i)]})
+ {"properties": [("level", i), ("relative", False)]})
for i in range(6)
]
@@ -211,6 +219,19 @@ def _template_items_proportional_editing(*, connected=False):
# Tool System Templates
+def _template_items_tool_select(params, operator, cursor_operator):
+ if params.select_mouse == 'LEFTMOUSE':
+ # Immediate select without quick delay.
+ return [(operator, {"type": 'LEFTMOUSE', "value": 'PRESS'}, None)]
+ else:
+ # For right mouse, set the cursor.
+ return [
+ (cursor_operator, {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+ ("transform.translate", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+ {"properties": [("release_confirm", True), ("cursor_transform", True)]}),
+ ]
+
+
def _template_items_tool_select_actions(operator, *, type, value):
kmi_args = {"type": type, "value": value}
return [
@@ -275,9 +296,9 @@ def km_window(params):
# Fast editor switching
*(
- ("wm.context_set_enum",
+ ("screen.space_type_set_or_cycle",
{"type": k, "value": 'PRESS', "shift": True},
- {"properties": [("data_path", 'area.type'), ("value", t)]})
+ {"properties": [("space_type", t)]})
for k, t in (
('F4', 'CONSOLE'),
('F5', 'VIEW_3D'),
@@ -321,6 +342,10 @@ def km_window(params):
items.append(
("wm.toolbar", {"type": 'SPACE', "value": 'PRESS', "shift": True}, None),
)
+ elif params.spacebar_action == 'SEARCH':
+ items.append(
+ ("wm.search_menu", {"type": 'SPACE', "value": 'PRESS'}, None),
+ )
else:
assert False
@@ -767,7 +792,7 @@ def km_uv_editor(params):
# Quick switch to select tool, since left select can't easily
# select with any tool active.
items.extend([
- op_tool("Select Box", {"type": 'W', "value": 'PRESS'}),
+ op_tool_cycle("Select Box", {"type": 'W', "value": 'PRESS'}),
])
return keymap
@@ -845,6 +870,10 @@ def km_view3d(params):
])
items.extend([
+ # Visibility.
+ ("view3d.localview", {"type": 'NUMPAD_SLASH', "value": 'PRESS'}, None),
+ ("view3d.localview", {"type": 'SLASH', "value": 'PRESS'}, None),
+ ("view3d.localview_remove_from", {"type": 'M', "value": 'PRESS'}, None),
# Navigation.
("view3d.rotate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
("view3d.move", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
@@ -886,6 +915,8 @@ def km_view3d(params):
{"properties": [("center", False)]}),
("view3d.view_all", {"type": 'HOME', "value": 'PRESS', "ctrl": True},
{"properties": [("use_all_regions", True), ("center", False)]}),
+ ("view3d.view_all", {"type": 'C', "value": 'PRESS', "shift": True},
+ {"properties": [("center", True)]}),
op_menu_pie("VIEW3D_MT_view_pie", {"type": 'ACCENT_GRAVE', "value": 'PRESS'}),
("view3d.navigate", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "shift": True}, None),
# Numpad views.
@@ -945,6 +976,7 @@ def km_view3d(params):
{"properties": [("type", 'RIGHT'), ("relative", True)]}),
("view3d.view_axis", {"type": 'EVT_TWEAK_M', "value": 'WEST', "alt": True},
{"properties": [("type", 'LEFT'), ("relative", True)]}),
+ ("view3d.view_center_pick", {"type": 'MIDDLEMOUSE', "value": 'CLICK', "alt": True}, None),
("view3d.ndof_orbit_zoom", {"type": 'NDOF_MOTION', "value": 'ANY'}, None),
("view3d.ndof_orbit", {"type": 'NDOF_MOTION', "value": 'ANY', "ctrl": True}, None),
("view3d.ndof_pan", {"type": 'NDOF_MOTION', "value": 'ANY', "shift": True}, None),
@@ -974,18 +1006,18 @@ def km_view3d(params):
("view3d.view_axis", {"type": 'NDOF_BUTTON_TOP', "value": 'PRESS', "shift": True},
{"properties": [("type", 'TOP'), ("align_active", True)]}),
# Selection.
- *(("view3d.select",
+ *((operator,
{"type": params.select_mouse, "value": params.select_mouse_value, **{m: True for m in mods}},
{"properties": [(c, True) for c in props]},
- ) for props, mods in (
- ((), ()),
- (("toggle",), ("shift",)),
- (("center", "object"), ("ctrl",)),
- (("enumerate",), ("alt",)),
- (("extend", "toggle", "center"), ("shift", "ctrl")),
- (("center", "enumerate"), ("ctrl", "alt")),
- (("toggle", "enumerate"), ("shift", "alt")),
- (("toggle", "center", "enumerate"), ("shift", "ctrl", "alt")),
+ ) for operator, props, mods in (
+ ("view3d.select_or_deselect_all" if not params.legacy else "view3d.select", (), ()),
+ ("view3d.select", ("toggle",), ("shift",)),
+ ("view3d.select", ("center", "object"), ("ctrl",)),
+ ("view3d.select", ("enumerate",), ("alt",)),
+ ("view3d.select", ("extend", "toggle", "center"), ("shift", "ctrl")),
+ ("view3d.select", ("center", "enumerate"), ("ctrl", "alt")),
+ ("view3d.select", ("toggle", "enumerate"), ("shift", "alt")),
+ ("view3d.select", ("toggle", "center", "enumerate"), ("shift", "ctrl", "alt")),
)),
("view3d.select_box", {"type": 'B', "value": 'PRESS'}, None),
("view3d.select_lasso", {"type": params.action_tweak, "value": 'ANY', "ctrl": True},
@@ -1057,8 +1089,6 @@ def km_view3d(params):
("view3d.zoom_camera_1_to_1", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "shift": True}, None),
("view3d.view_center_cursor", {"type": 'HOME', "value": 'PRESS', "alt": True}, None),
("view3d.view_center_pick", {"type": 'F', "value": 'PRESS', "alt": True}, None),
- ("view3d.view_all", {"type": 'C', "value": 'PRESS', "shift": True},
- {"properties": [("center", True)]}),
("view3d.view_pan", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True},
{"properties": [("type", 'PANRIGHT')]}),
("view3d.view_pan", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True},
@@ -1113,7 +1143,7 @@ def km_view3d(params):
# Quick switch to select tool, since left select can't easily
# select with any tool active.
items.extend([
- op_tool("Select Box", {"type": 'W', "value": 'PRESS'}),
+ op_tool_cycle("Select Box", {"type": 'W', "value": 'PRESS'}),
])
return keymap
@@ -2446,10 +2476,6 @@ def km_clip(_params):
("wm.context_toggle_enum", {"type": 'TAB', "value": 'PRESS'},
{"properties": [("data_path", 'space_data.mode'), ("value_1", 'TRACKING'), ("value_2", 'MASK')]}),
("clip.solve_camera", {"type": 'S', "value": 'PRESS', "shift": True}, None),
- ("clip.set_solver_keyframe", {"type": 'Q', "value": 'PRESS'},
- {"properties": [("keyframe", 'KEYFRAME_A')]}),
- ("clip.set_solver_keyframe", {"type": 'E', "value": 'PRESS'},
- {"properties": [("keyframe", 'KEYFRAME_B')]}),
("clip.prefetch", {"type": 'P', "value": 'PRESS'}, None),
])
@@ -2665,7 +2691,7 @@ def km_frames(params):
if not params.legacy:
# New playback
- if params.spacebar_action == 'TOOL':
+ if params.spacebar_action in {'TOOL', 'SEARCH'}:
items.append(
("screen.animation_play", {"type": 'SPACE', "value": 'PRESS', "shift": True}, None),
)
@@ -2951,8 +2977,6 @@ def km_grease_pencil_stroke_edit_mode(params):
("object.gpencil_add", {"type": 'A', "value": 'PRESS', "shift": True}, None),
# Vertex group menu
op_menu("GPENCIL_MT_gpencil_vertex_group", {"type": 'G', "value": 'PRESS', "ctrl": True}),
- # Toggle edit mode
- ("gpencil.editmode_toggle", {"type": 'TAB', "value": 'PRESS'}, None),
# Select mode
("gpencil.selectmode_toggle", {"type": 'ONE', "value": 'PRESS'},
{"properties": [("mode", 0)]}),
@@ -3620,6 +3644,12 @@ def km_weight_paint(params):
{"properties": [("data_path", 'tool_settings.weight_paint.brush.use_smooth_stroke')]}),
])
+ if params.select_mouse == 'LEFTMOUSE':
+ # Bone selection for combined weight paint + pose mode.
+ items.extend([
+ ("view3d.select", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None),
+ ])
+
return keymap
@@ -3738,13 +3768,7 @@ def km_mesh(params):
{"properties": [("vertex_only", True)]}),
# Selection modes.
*_template_items_editmode_mesh_select_mode(),
- # Loop Select with alt, and double click in case MMB emulation is on.
- ("mesh.loop_select", {"type": params.select_mouse, "value": 'DOUBLE_CLICK'},
- {"properties": [("extend", False), ("deselect", False), ("toggle", False)]}),
- ("mesh.loop_select", {"type": params.select_mouse, "value": 'DOUBLE_CLICK', "shift": True},
- {"properties": [("extend", True), ("deselect", False), ("toggle", False)]}),
- ("mesh.loop_select", {"type": params.select_mouse, "value": 'DOUBLE_CLICK', "alt": True},
- {"properties": [("extend", False), ("deselect", True), ("toggle", False)]}),
+ # Loop Select with alt. Double click in case MMB emulation is on (below).
("mesh.loop_select", {"type": params.select_mouse, "value": params.select_mouse_value, "alt": True},
{"properties": [("extend", False), ("deselect", False), ("toggle", False)]}),
("mesh.loop_select", {"type": params.select_mouse, "value": params.select_mouse_value, "shift": True, "alt": True},
@@ -3828,6 +3852,16 @@ def km_mesh(params):
*_template_items_proportional_editing(connected=True),
])
+ if params.use_mouse_emulate_3_button:
+ items.extend([
+ ("mesh.loop_select", {"type": params.select_mouse, "value": 'DOUBLE_CLICK'},
+ {"properties": [("extend", False), ("deselect", False), ("toggle", False)]}),
+ ("mesh.loop_select", {"type": params.select_mouse, "value": 'DOUBLE_CLICK', "shift": True},
+ {"properties": [("extend", True), ("deselect", False), ("toggle", False)]}),
+ ("mesh.loop_select", {"type": params.select_mouse, "value": 'DOUBLE_CLICK', "alt": True},
+ {"properties": [("extend", False), ("deselect", True), ("toggle", False)]}),
+ ])
+
if params.legacy:
items.extend([
("mesh.poke", {"type": 'P', "value": 'PRESS', "alt": True}, None),
@@ -3884,7 +3918,10 @@ def km_armature(params):
("armature.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
("armature.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
("armature.select_similar", {"type": 'G', "value": 'PRESS', "shift": True}, None),
- ("armature.select_linked", {"type": 'L', "value": 'PRESS'}, None),
+ ("armature.select_linked", {"type": 'L', "value": 'PRESS'},
+ {"properties": [("deselect", False)]}),
+ ("armature.select_linked", {"type": 'L', "value": 'PRESS', "shift": True},
+ {"properties": [("deselect", True)]}),
("armature.shortest_path_pick", {"type": params.select_mouse, "value": params.select_mouse_value, "ctrl": True}, None),
# Editing.
op_menu("VIEW3D_MT_edit_armature_delete", {"type": 'X', "value": 'PRESS'}),
@@ -4900,8 +4937,8 @@ def km_popup_toolbar(params):
"Toolbar Popup",
{"space_type": 'EMPTY', "region_type": 'TEMPORARY'},
{"items": [
+ op_tool("Select", {"type": 'W', "value": 'PRESS'}),
op_tool("Transform", {"type": 'T', "value": 'PRESS'}),
- op_tool("Annotate", {"type": 'D', "value": 'PRESS'}),
op_tool("Measure", {"type": 'M', "value": 'PRESS'}),
]},
)
@@ -4912,16 +4949,75 @@ def km_popup_toolbar(params):
#
# Named are auto-generated based on the tool name and it's toolbar.
+
+def km_generic_tool_annotate(params):
+ return (
+ "Generic Tool: Annotate",
+ {"region_type": 'WINDOW'},
+ {"items": [
+ ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS'},
+ {"properties": [("mode", 'DRAW'), ("wait_for_input", False)]}),
+ ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
+ {"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
+ ]},
+ )
+
+
+def km_generic_tool_annotate_line(params):
+ return (
+ "Generic Tool: Annotate Line",
+ {"region_type": 'WINDOW'},
+ {"items": [
+ ("gpencil.annotate", {"type": params.tool_tweak, "value": 'ANY'},
+ {"properties": [("mode", 'DRAW_STRAIGHT'), ("wait_for_input", False)]}),
+ ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
+ {"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
+ ]},
+ )
+
+
+def km_generic_tool_annotate_polygon(params):
+ return (
+ "Generic Tool: Annotate Polygon",
+ {"region_type": 'WINDOW'},
+ {"items": [
+ ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS'},
+ {"properties": [("mode", 'DRAW_POLY'), ("wait_for_input", False)]}),
+ ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
+ {"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
+ ]},
+ )
+
+
+def km_generic_tool_annotate_eraser(params):
+ return (
+ "Generic Tool: Annotate Eraser",
+ {"region_type": 'WINDOW'},
+ {"items": [
+ ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS'},
+ {"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
+ ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
+ {"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
+ ]},
+ )
+
def km_image_editor_tool_uv_cursor(params):
return (
"Image Editor Tool: Uv, Cursor",
{"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("uv.cursor_set", {"type": params.tool_mouse, "value": 'PRESS'}, None),
("transform.translate", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True), ("cursor_transform", True)]}),
- ),
- },
+ ]},
+ )
+
+
+def km_image_editor_tool_uv_select(params):
+ return (
+ "Image Editor Tool: Uv, Select",
+ {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
+ {"items": _template_items_tool_select(params, "uv.select", "uv.cursor_set")},
)
@@ -4937,13 +5033,12 @@ def km_image_editor_tool_uv_select_circle(params):
return (
"Image Editor Tool: Uv, Select Circle",
{"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("uv.select_circle", {"type": params.tool_mouse, "value": 'PRESS'},
{"properties": [("deselect", False)]}),
("uv.select_circle", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
{"properties": [("deselect", True)]}),
- ),
- },
+ ]},
)
@@ -4955,64 +5050,71 @@ def km_image_editor_tool_uv_select_lasso(params):
)
-def km_image_editor_tool_uv_annotate(params):
+def km_node_editor_tool_select(params):
return (
- "Image Editor Tool: Uv, Annotate",
- {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
- {"items": (
- ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS'},
- {"properties": [("mode", 'DRAW'), ("wait_for_input", False)]}),
- ),
- },
+ "Node Tool: Select",
+ {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'},
+ {"items": [
+ ("node.select", {"type": params.select_mouse, "value": 'PRESS'},
+ {"properties": [("extend", False)]}),
+ ]},
)
-def km_image_editor_tool_uv_annotate_line(params):
+def km_node_editor_tool_select_box(params):
return (
- "Image Editor Tool: Uv, Annotate Line",
- {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
- {"items": (
- ("gpencil.annotate", {"type": params.tool_tweak, "value": 'ANY'},
- {"properties": [("mode", 'DRAW_STRAIGHT'), ("wait_for_input", False)]}),
- ),
- },
+ "Node Tool: Select Box",
+ {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'},
+ {"items": [
+ ("node.select_box", {"type": params.tool_mouse, "value": 'PRESS'},
+ {"properties": [("deselect", False), ("tweak", True)]}),
+ ("node.select_box", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
+ {"properties": [("deselect", True), ("tweak", True)]}),
+ ]},
)
-def km_image_editor_tool_uv_annotate_polygon(params):
+def km_node_editor_tool_select_lasso(params):
return (
- "Image Editor Tool: Uv, Annotate Polygon",
- {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
- {"items": (
- ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS'},
- {"properties": [("mode", 'DRAW_POLY'), ("wait_for_input", False)]}),
- ),
- },
+ "Node Tool: Select Lasso",
+ {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'},
+ {"items": [
+ ("node.select_lasso", {"type": params.tool_mouse, "value": 'PRESS'},
+ {"properties": [("deselect", False)]}),
+ ("node.select_lasso", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
+ {"properties": [("deselect", True)]}),
+ ]},
)
-def km_image_editor_tool_uv_annotate_eraser(params):
+def km_node_editor_tool_links_cut(params):
return (
- "Image Editor Tool: Uv, Annotate Eraser",
- {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
- {"items": (
- ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS'},
- {"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
- ),
- },
+ "Node Tool: Links Cut",
+ {"space_type": 'NODE_EDITOR', "region_type": 'WINDOW'},
+ {"items": [
+ ("node.links_cut", {"type": params.tool_mouse, "value": 'PRESS'}, None),
+ ]},
)
+
def km_3d_view_tool_object_cursor(params):
return (
"3D View Tool: Object, Cursor",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("view3d.cursor3d", {"type": params.tool_mouse, "value": 'PRESS'}, None),
("transform.translate", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True), ("cursor_transform", True)]}),
- ),
- },
+ ]},
+ )
+
+
+def km_3d_view_tool_object_select(params):
+ return (
+ "3D View Tool: Object, Select",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items": _template_items_tool_select(params, "view3d.select", "view3d.cursor3d")},
)
@@ -5028,13 +5130,12 @@ def km_3d_view_tool_object_select_circle(params):
return (
"3D View Tool: Object, Select Circle",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("view3d.select_circle", {"type": params.tool_mouse, "value": 'PRESS'},
{"properties": [("deselect", False)]}),
("view3d.select_circle", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
{"properties": [("deselect", True)]}),
- ),
- },
+ ]},
)
@@ -5050,10 +5151,9 @@ def km_3d_view_tool_object_transform(params):
return (
"3D View Tool: Object, Transform",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.from_gizmo", {"type": params.tool_tweak, "value": 'ANY'}, None),
- ),
- },
+ ]},
)
@@ -5061,11 +5161,10 @@ def km_3d_view_tool_object_move(params):
return (
"3D View Tool: Object, Move",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.translate", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5073,11 +5172,10 @@ def km_3d_view_tool_object_rotate(params):
return (
"3D View Tool: Object, Rotate",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.rotate", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5085,67 +5183,10 @@ def km_3d_view_tool_object_scale(params):
return (
"3D View Tool: Object, Scale",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.resize", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
- )
-
-
-def km_3d_view_tool_object_annotate(params):
- return (
- "3D View Tool: Object, Annotate",
- {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
- ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS'},
- {"properties": [("mode", 'DRAW'), ("wait_for_input", False)]}),
- ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS', "alt": True},
- {"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
- ),
- },
- )
-
-
-def km_3d_view_tool_object_annotate_line(params):
- return (
- "3D View Tool: Object, Annotate Line",
- {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
- ("gpencil.annotate", {"type": params.tool_tweak, "value": 'ANY'},
- {"properties": [("mode", 'DRAW_STRAIGHT'), ("wait_for_input", False)]}),
- ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS', "alt": True},
- {"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
- ),
- },
- )
-
-
-def km_3d_view_tool_object_annotate_polygon(params):
- return (
- "3D View Tool: Object, Annotate Polygon",
- {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
- ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS'},
- {"properties": [("mode", 'DRAW_POLY'), ("wait_for_input", False)]}),
- ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS', "alt": True},
- {"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
- ),
- },
- )
-
-
-def km_3d_view_tool_object_annotate_eraser(params):
- return (
- "3D View Tool: Object, Annotate Eraser",
- {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
- ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS'},
- {"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
- ("gpencil.annotate", {"type": params.tool_mouse, "value": 'PRESS', "alt": True},
- {"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
- ),
- },
+ ]},
)
@@ -5153,10 +5194,9 @@ def km_3d_view_tool_object_measure(params):
return (
"3D View Tool: Object, Measure",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("view3d.ruler_add", {"type": params.tool_tweak, "value": 'ANY'}, None),
- ),
- },
+ ]},
)
@@ -5164,10 +5204,9 @@ def km_3d_view_tool_pose_breakdowner(params):
return (
"3D View Tool: Pose, Breakdowner",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("pose.breakdown", {"type": params.tool_tweak, "value": 'ANY'}, None),
- ),
- },
+ ]},
)
@@ -5175,10 +5214,9 @@ def km_3d_view_tool_pose_push(params):
return (
"3D View Tool: Pose, Push",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("pose.push", {"type": params.tool_tweak, "value": 'ANY'}, None),
- ),
- },
+ ]},
)
@@ -5186,10 +5224,9 @@ def km_3d_view_tool_pose_relax(params):
return (
"3D View Tool: Pose, Relax",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("pose.relax", {"type": params.tool_tweak, "value": 'ANY'}, None),
- ),
- },
+ ]},
)
@@ -5197,11 +5234,10 @@ def km_3d_view_tool_edit_armature_roll(params):
return (
"3D View Tool: Edit Armature, Roll",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.transform", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True), ("mode", 'BONE_ROLL')]}),
- ),
- },
+ ]},
)
@@ -5209,11 +5245,10 @@ def km_3d_view_tool_edit_armature_bone_size(params):
return (
"3D View Tool: Edit Armature, Bone Size",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.transform", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True), ("mode", 'BONE_SIZE')]}),
- ),
- },
+ ]},
)
@@ -5221,11 +5256,10 @@ def km_3d_view_tool_edit_armature_bone_envelope(params):
return (
"3D View Tool: Edit Armature, Bone Envelope",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.transform", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True), ("mode", 'BONE_ENVELOPE')]}),
- ),
- },
+ ]},
)
@@ -5233,11 +5267,10 @@ def km_3d_view_tool_edit_armature_extrude(params):
return (
"3D View Tool: Edit Armature, Extrude",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("armature.extrude_move", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("TRANSFORM_OT_translate", [("release_confirm", True)])]}),
- ),
- },
+ ]},
)
@@ -5245,10 +5278,9 @@ def km_3d_view_tool_edit_armature_extrude_to_cursor(params):
return (
"3D View Tool: Edit Armature, Extrude to Cursor",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("armature.click_extrude", {"type": params.tool_mouse, "value": 'PRESS'}, None),
- ),
- },
+ ]},
)
@@ -5256,11 +5288,10 @@ def km_3d_view_tool_edit_mesh_add_cube(params):
return (
"3D View Tool: Edit Mesh, Add Cube",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("view3d.cursor3d", {"type": params.tool_mouse, "value": 'CLICK'}, None),
("mesh.primitive_cube_add_gizmo", {"type": params.tool_tweak, "value": 'ANY'}, None),
- ),
- },
+ ]},
)
@@ -5268,11 +5299,10 @@ def km_3d_view_tool_edit_mesh_extrude_region(params):
return (
"3D View Tool: Edit Mesh, Extrude Region",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.extrude_context_move", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("TRANSFORM_OT_translate", [("release_confirm", True)])]}),
- ),
- },
+ ]},
)
@@ -5280,11 +5310,10 @@ def km_3d_view_tool_edit_mesh_extrude_along_normals(params):
return (
"3D View Tool: Edit Mesh, Extrude Along Normals",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.extrude_region_shrink_fatten", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("TRANSFORM_OT_shrink_fatten", [("release_confirm", True)])]}),
- ),
- },
+ ]},
)
@@ -5292,11 +5321,10 @@ def km_3d_view_tool_edit_mesh_extrude_individual(params):
return (
"3D View Tool: Edit Mesh, Extrude Individual",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.extrude_faces_move", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("TRANSFORM_OT_shrink_fatten", [("release_confirm", True)])]}),
- ),
- },
+ ]},
)
@@ -5304,10 +5332,9 @@ def km_3d_view_tool_edit_mesh_extrude_to_cursor(params):
return (
"3D View Tool: Edit Mesh, Extrude to Cursor",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.dupli_extrude_cursor", {"type": params.tool_mouse, "value": 'PRESS'}, None),
- ),
- },
+ ]},
)
@@ -5315,11 +5342,10 @@ def km_3d_view_tool_edit_mesh_inset_faces(params):
return (
"3D View Tool: Edit Mesh, Inset Faces",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.inset", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5327,11 +5353,10 @@ def km_3d_view_tool_edit_mesh_bevel(params):
return (
"3D View Tool: Edit Mesh, Bevel",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.bevel", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5339,11 +5364,10 @@ def km_3d_view_tool_edit_mesh_loop_cut(params):
return (
"3D View Tool: Edit Mesh, Loop Cut",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.loopcut_slide", {"type": params.tool_mouse, "value": 'PRESS'},
{"properties": [("TRANSFORM_OT_edge_slide", [("release_confirm", True)])]}),
- ),
- },
+ ]},
)
@@ -5351,10 +5375,9 @@ def km_3d_view_tool_edit_mesh_offset_edge_loop_cut(params):
return (
"3D View Tool: Edit Mesh, Offset Edge Loop Cut",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.offset_edge_loops_slide", {"type": params.tool_mouse, "value": 'PRESS'}, None),
- ),
- },
+ ]},
)
@@ -5362,11 +5385,10 @@ def km_3d_view_tool_edit_mesh_knife(params):
return (
"3D View Tool: Edit Mesh, Knife",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.knife_tool", {"type": params.tool_mouse, "value": 'PRESS'},
{"properties": [("wait_for_input", False)]}),
- ),
- },
+ ]},
)
@@ -5374,10 +5396,9 @@ def km_3d_view_tool_edit_mesh_bisect(params):
return (
"3D View Tool: Edit Mesh, Bisect",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.bisect", {"type": params.tool_tweak, "value": 'ANY'}, None),
- ),
- },
+ ]},
)
@@ -5385,14 +5406,13 @@ def km_3d_view_tool_edit_mesh_poly_build(params):
return (
"3D View Tool: Edit Mesh, Poly Build",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.polybuild_face_at_cursor_move", {"type": params.tool_mouse, "value": 'PRESS'},
{"properties": [("TRANSFORM_OT_translate", [("release_confirm", True)])]}),
("mesh.polybuild_split_at_cursor_move", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
{"properties": [("TRANSFORM_OT_translate", [("release_confirm", True)])]}),
("mesh.polybuild_dissolve_at_cursor", {"type": params.tool_mouse, "value": 'CLICK', "alt": True}, None),
- ),
- },
+ ]},
)
@@ -5400,10 +5420,9 @@ def km_3d_view_tool_edit_mesh_spin(params):
return (
"3D View Tool: Edit Mesh, Spin",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.spin", {"type": params.tool_tweak, "value": 'ANY'}, None),
- ),
- },
+ ]},
)
@@ -5411,11 +5430,10 @@ def km_3d_view_tool_edit_mesh_spin_duplicate(params):
return (
"3D View Tool: Edit Mesh, Spin (Duplicate)",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.spin", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("dupli", True)]}),
- ),
- },
+ ]},
)
@@ -5423,11 +5441,10 @@ def km_3d_view_tool_edit_mesh_smooth(params):
return (
"3D View Tool: Edit Mesh, Smooth",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.vertices_smooth", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("factor", 0.0)]}),
- ),
- },
+ ]},
)
@@ -5435,11 +5452,10 @@ def km_3d_view_tool_edit_mesh_randomize(params):
return (
"3D View Tool: Edit Mesh, Randomize",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.vertex_random", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("offset", 0.0)]}),
- ),
- },
+ ]},
)
@@ -5447,11 +5463,10 @@ def km_3d_view_tool_edit_mesh_edge_slide(params):
return (
"3D View Tool: Edit Mesh, Edge Slide",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.edge_slide", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5459,11 +5474,10 @@ def km_3d_view_tool_edit_mesh_vertex_slide(params):
return (
"3D View Tool: Edit Mesh, Vertex Slide",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.vert_slide", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5471,11 +5485,10 @@ def km_3d_view_tool_edit_mesh_shrink_fatten(params):
return (
"3D View Tool: Edit Mesh, Shrink/Fatten",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.shrink_fatten", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5483,11 +5496,10 @@ def km_3d_view_tool_edit_mesh_push_pull(params):
return (
"3D View Tool: Edit Mesh, Push/Pull",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.push_pull", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5495,11 +5507,10 @@ def km_3d_view_tool_edit_mesh_shear(params):
return (
"3D View Tool: Edit Mesh, Shear",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.shear", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5507,11 +5518,10 @@ def km_3d_view_tool_edit_mesh_to_sphere(params):
return (
"3D View Tool: Edit Mesh, To Sphere",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.tosphere", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5519,11 +5529,10 @@ def km_3d_view_tool_edit_mesh_rip_region(params):
return (
"3D View Tool: Edit Mesh, Rip Region",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.rip_move", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("TRANSFORM_OT_translate", [("release_confirm", True)])]}),
- ),
- },
+ ]},
)
@@ -5531,11 +5540,10 @@ def km_3d_view_tool_edit_mesh_rip_edge(params):
return (
"3D View Tool: Edit Mesh, Rip Edge",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("mesh.rip_edge_move", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("TRANSFORM_OT_translate", [("release_confirm", True)])]}),
- ),
- },
+ ]},
)
@@ -5543,11 +5551,10 @@ def km_3d_view_tool_edit_curve_draw(params):
return (
"3D View Tool: Edit Curve, Draw",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("curve.draw", {"type": params.tool_mouse, "value": 'PRESS'},
{"properties": [("wait_for_input", False)]}),
- ),
- },
+ ]},
)
@@ -5555,11 +5562,10 @@ def km_3d_view_tool_edit_curve_tilt(params):
return (
"3D View Tool: Edit Curve, Tilt",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
- ("transform.tilt", {"type": params.action_tweak, "value": 'ANY'},
+ {"items": [
+ ("transform.tilt", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5567,11 +5573,10 @@ def km_3d_view_tool_edit_curve_extrude(params):
return (
"3D View Tool: Edit Curve, Extrude",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("curve.extrude_move", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("TRANSFORM_OT_translate", [("release_confirm", True)])]}),
- ),
- },
+ ]},
)
@@ -5579,10 +5584,9 @@ def km_3d_view_tool_edit_curve_extrude_cursor(params):
return (
"3D View Tool: Edit Curve, Extrude Cursor",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("curve.vertex_add", {"type": params.tool_mouse, "value": 'PRESS'}, None),
- ),
- },
+ ]},
)
@@ -5590,15 +5594,14 @@ def km_3d_view_tool_sculpt_box_hide(params):
return (
"3D View Tool: Sculpt, Box Hide",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("paint.hide_show", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("action", 'HIDE')]}),
("paint.hide_show", {"type": params.tool_tweak, "value": 'ANY', "ctrl": True},
{"properties": [("action", 'SHOW')]}),
("paint.hide_show", {"type": params.select_mouse, "value": 'PRESS'},
{"properties": [("action", 'SHOW'), ("area", 'ALL')]}),
- ),
- },
+ ]},
)
@@ -5606,13 +5609,12 @@ def km_3d_view_tool_sculpt_box_mask(params):
return (
"3D View Tool: Sculpt, Box Mask",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("view3d.select_box", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("mode", 'ADD')]}),
("view3d.select_box", {"type": params.tool_tweak, "value": 'ANY', "ctrl": True},
{"properties": [("mode", 'SUB')]}),
- ),
- },
+ ]},
)
@@ -5620,10 +5622,9 @@ def km_3d_view_tool_paint_weight_sample_weight(params):
return (
"3D View Tool: Paint Weight, Sample Weight",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("paint.weight_sample", {"type": params.tool_mouse, "value": 'PRESS'}, None),
- ),
- },
+ ]},
)
@@ -5631,10 +5632,9 @@ def km_3d_view_tool_paint_weight_sample_vertex_group(params):
return (
"3D View Tool: Paint Weight, Sample Vertex Group",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("paint.weight_sample_group", {"type": params.tool_mouse, "value": 'PRESS'}, None),
- ),
- },
+ ]},
)
@@ -5642,10 +5642,9 @@ def km_3d_view_tool_paint_weight_gradient(params):
return (
"3D View Tool: Paint Weight, Gradient",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("paint.weight_gradient", {"type": params.tool_tweak, "value": 'ANY'}, None),
- ),
- },
+ ]},
)
@@ -5653,11 +5652,14 @@ def km_3d_view_tool_gpencil_paint_line(params):
return (
"3D View Tool: Gpencil Paint, Line",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("gpencil.primitive", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("type", 'LINE'), ("wait_for_input", False)]}),
- ),
- },
+ ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties": [("type", 'LINE'), ("wait_for_input", False)]}),
+ ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties": [("type", 'LINE'), ("wait_for_input", False)]}),
+ ]},
)
@@ -5665,11 +5667,14 @@ def km_3d_view_tool_gpencil_paint_box(params):
return (
"3D View Tool: Gpencil Paint, Box",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("gpencil.primitive", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("type", 'BOX'), ("wait_for_input", False)]}),
- ),
- },
+ ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties": [("type", 'BOX'), ("wait_for_input", False)]}),
+ ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties": [("type", 'BOX'), ("wait_for_input", False)]}),
+ ]},
)
@@ -5677,11 +5682,37 @@ def km_3d_view_tool_gpencil_paint_circle(params):
return (
"3D View Tool: Gpencil Paint, Circle",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("gpencil.primitive", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("type", 'CIRCLE'), ("wait_for_input", False)]}),
- ),
- },
+ ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties": [("type", 'CIRCLE'), ("wait_for_input", False)]}),
+ ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties": [("type", 'CIRCLE'), ("wait_for_input", False)]}),
+ ]},
+ )
+
+
+def km_3d_view_tool_gpencil_paint_arc(params):
+ return (
+ "3D View Tool: Gpencil Paint, Arc",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items": [
+ ("gpencil.primitive", {"type": params.tool_tweak, "value": 'ANY'},
+ {"properties": [("type", 'ARC'), ("wait_for_input", False)]}),
+ ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+ {"properties": [("type", 'ARC'), ("wait_for_input", False)]}),
+ ("gpencil.primitive", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
+ {"properties": [("type", 'ARC'), ("wait_for_input", False)]}),
+ ]},
+ )
+
+
+def km_3d_view_tool_gpencil_edit_select(params):
+ return (
+ "3D View Tool: Gpencil Edit, Select",
+ {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+ {"items": _template_items_tool_select(params, "gpencil.select", "view3d.cursor3d")},
)
@@ -5697,12 +5728,11 @@ def km_3d_view_tool_gpencil_edit_select_circle(params):
return (
"3D View Tool: Gpencil Edit, Select Circle",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("gpencil.select_circle", {"type": params.tool_tweak, "value": 'ANY'}, None),
("gpencil.select_circle", {"type": params.tool_mouse, "value": 'PRESS', "ctrl": True},
{"properties": [("deselect", True)]}),
- ),
- },
+ ]},
)
@@ -5718,11 +5748,10 @@ def km_3d_view_tool_gpencil_edit_bend(params):
return (
"3D View Tool: Gpencil Edit, Bend",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.bend", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5730,11 +5759,10 @@ def km_3d_view_tool_gpencil_edit_shear(params):
return (
"3D View Tool: Gpencil Edit, Shear",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.shear", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5742,11 +5770,10 @@ def km_3d_view_tool_gpencil_edit_to_sphere(params):
return (
"3D View Tool: Gpencil Edit, To Sphere",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
- {"items": (
+ {"items": [
("transform.tosphere", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True)]}),
- ),
- },
+ ]},
)
@@ -5885,15 +5912,22 @@ def generate_keymaps(params=None):
km_popup_toolbar(params),
# Tool System.
+ km_generic_tool_annotate(params),
+ km_generic_tool_annotate_line(params),
+ km_generic_tool_annotate_polygon(params),
+ km_generic_tool_annotate_eraser(params),
+
km_image_editor_tool_uv_cursor(params),
+ km_image_editor_tool_uv_select(params),
km_image_editor_tool_uv_select_box(params),
km_image_editor_tool_uv_select_circle(params),
km_image_editor_tool_uv_select_lasso(params),
- km_image_editor_tool_uv_annotate(params),
- km_image_editor_tool_uv_annotate_line(params),
- km_image_editor_tool_uv_annotate_polygon(params),
- km_image_editor_tool_uv_annotate_eraser(params),
+ km_node_editor_tool_select(params),
+ km_node_editor_tool_select_box(params),
+ km_node_editor_tool_select_lasso(params),
+ km_node_editor_tool_links_cut(params),
km_3d_view_tool_object_cursor(params),
+ km_3d_view_tool_object_select(params),
km_3d_view_tool_object_select_box(params),
km_3d_view_tool_object_select_circle(params),
km_3d_view_tool_object_select_lasso(params),
@@ -5901,10 +5935,6 @@ def generate_keymaps(params=None):
km_3d_view_tool_object_move(params),
km_3d_view_tool_object_rotate(params),
km_3d_view_tool_object_scale(params),
- km_3d_view_tool_object_annotate(params),
- km_3d_view_tool_object_annotate_line(params),
- km_3d_view_tool_object_annotate_polygon(params),
- km_3d_view_tool_object_annotate_eraser(params),
km_3d_view_tool_object_measure(params),
km_3d_view_tool_pose_breakdowner(params),
km_3d_view_tool_pose_push(params),
@@ -5950,6 +5980,8 @@ def generate_keymaps(params=None):
km_3d_view_tool_gpencil_paint_line(params),
km_3d_view_tool_gpencil_paint_box(params),
km_3d_view_tool_gpencil_paint_circle(params),
+ km_3d_view_tool_gpencil_paint_arc(params),
+ km_3d_view_tool_gpencil_edit_select(params),
km_3d_view_tool_gpencil_edit_select_box(params),
km_3d_view_tool_gpencil_edit_select_circle(params),
km_3d_view_tool_gpencil_edit_select_lasso(params),
diff --git a/release/scripts/startup/bl_app_templates_system/Sculpting/__init__.py b/release/scripts/startup/bl_app_templates_system/Sculpting/__init__.py
index 77f879addae..bf32d6672ca 100644
--- a/release/scripts/startup/bl_app_templates_system/Sculpting/__init__.py
+++ b/release/scripts/startup/bl_app_templates_system/Sculpting/__init__.py
@@ -1,3 +1,20 @@
+# ##### 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 #####
import bpy
from bpy.app.handlers import persistent
@@ -6,18 +23,20 @@ from bpy.app.handlers import persistent
@persistent
def load_handler(dummy):
import bpy
- if bpy.data.filepath == "":
- # Apply subdivision modifier on startup
- bpy.ops.object.mode_set(mode='OBJECT')
+ # Apply subdivision modifier on startup
+ bpy.ops.object.mode_set(mode='OBJECT')
+ if bpy.app.opensubdiv.supported:
bpy.ops.object.modifier_apply(modifier="Subdivision")
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.transform.tosphere(value=1.0)
- bpy.ops.object.mode_set(mode='SCULPT')
+ else:
+ bpy.ops.object.modifier_remove(modifier="Subdivision")
+ bpy.ops.object.mode_set(mode='EDIT')
+ bpy.ops.mesh.subdivide(number_cuts=6, smoothness=1.0)
+ bpy.ops.object.mode_set(mode='SCULPT')
def register():
- import bpy
- bpy.app.handlers.load_post.append(load_handler)
+ bpy.app.handlers.load_factory_startup_post.append(load_handler)
def unregister():
- import bpy
- bpy.app.handlers.load_post.remove(load_handler)
+ bpy.app.handlers.load_factory_startup_post.remove(load_handler)
diff --git a/release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py b/release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py
new file mode 100644
index 00000000000..fe8546cfbfc
--- /dev/null
+++ b/release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py
@@ -0,0 +1,39 @@
+# ##### 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 #####
+
+import bpy
+from bpy.app.handlers import persistent
+
+
+@persistent
+def load_handler(dummy):
+ import os
+ from bpy import context
+ screen = context.screen
+ for area in screen.areas:
+ if area.type == 'FILE_BROWSER':
+ space = area.spaces.active
+ params = space.params
+ params.directory = os.path.expanduser("~")
+ params.use_filter_folder = True
+
+def register():
+ bpy.app.handlers.load_factory_startup_post.append(load_handler)
+
+def unregister():
+ bpy.app.handlers.load_factory_startup_post.remove(load_handler)
diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py
index 74b3e420cdf..df8f2d1c089 100644
--- a/release/scripts/startup/bl_operators/clip.py
+++ b/release/scripts/startup/bl_operators/clip.py
@@ -299,7 +299,7 @@ class CLIP_OT_bundles_to_mesh(Operator):
if camera:
reconstruction = tracking_object.reconstruction
framenr = scene.frame_current - clip.frame_start + 1
- reconstructed_matrix = reconstruction.cameras.matrix_from_frame(framenr)
+ reconstructed_matrix = reconstruction.cameras.matrix_from_frame(frame=framenr)
matrix = camera.matrix_world @ reconstructed_matrix.inverted()
for track in tracking_object.tracks:
diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py
index 72fb1849c76..ad1488339df 100644
--- a/release/scripts/startup/bl_operators/object.py
+++ b/release/scripts/startup/bl_operators/object.py
@@ -23,7 +23,6 @@ from bpy.types import Operator
from bpy.props import (
BoolProperty,
EnumProperty,
- FloatProperty,
IntProperty,
StringProperty,
)
@@ -641,10 +640,10 @@ class MakeDupliFace(Operator):
for obj in objects:
scene.objects.unlink(obj)
- ob_new.dupli_type = 'FACES'
+ ob_new.instance_type = 'FACES'
ob_inst.parent = ob_new
- ob_new.use_dupli_faces_scale = True
- ob_new.dupli_faces_scale = 1.0 / SCALE_FAC
+ ob_new.use_instance_faces_scale = True
+ ob_new.instance_faces_scale = 1.0 / SCALE_FAC
ob_inst.select_set(True)
ob_new.select_set(True)
@@ -853,7 +852,7 @@ class TransformsToDeltasAnim(Operator):
class DupliOffsetFromCursor(Operator):
"""Set offset used for collection instances based on cursor position"""
- bl_idname = "object.dupli_offset_from_cursor"
+ bl_idname = "object.instance_offset_from_cursor"
bl_label = "Set Offset From Cursor"
bl_options = {'INTERNAL', 'UNDO'}
@@ -865,7 +864,7 @@ class DupliOffsetFromCursor(Operator):
scene = context.scene
collection = context.collection
- collection.dupli_offset = scene.cursor_location
+ collection.instance_offset = scene.cursor_location
return {'FINISHED'}
@@ -892,7 +891,7 @@ class LoadImageAsEmpty:
def execute(self, context):
scene = context.scene
space = context.space_data
- cursor = (space if space and space.type == 'VIEW_3D' else scene).cursor_location
+ cursor = scene.cursor_location
try:
image = bpy.data.images.load(self.filepath, check_existing=True)
diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py
index d4f8af1310d..cf6d796798b 100644
--- a/release/scripts/startup/bl_operators/object_align.py
+++ b/release/scripts/startup/bl_operators/object_align.py
@@ -129,9 +129,8 @@ def align_objects(context,
depsgraph = context.depsgraph
scene = context.scene
- space = context.space_data
- cursor = (space if space and space.type == 'VIEW_3D' else scene).cursor_location
+ cursor = scene.cursor_location
# We are accessing runtime data such as evaluated bounding box, so we need to
# be sure it is properly updated and valid (bounding box might be lost on operator
diff --git a/release/scripts/startup/bl_operators/rigidbody.py b/release/scripts/startup/bl_operators/rigidbody.py
index e7ce89f34ac..d945423cbe1 100644
--- a/release/scripts/startup/bl_operators/rigidbody.py
+++ b/release/scripts/startup/bl_operators/rigidbody.py
@@ -47,7 +47,7 @@ class CopyRigidbodySettings(Operator):
"deactivate_angular_velocity",
"linear_damping",
"angular_damping",
- "collision_groups",
+ "collision_collections",
"mesh_source",
"use_deform",
"enabled",
diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py
index b43f4446802..58ddc50c808 100644
--- a/release/scripts/startup/bl_operators/view3d.py
+++ b/release/scripts/startup/bl_operators/view3d.py
@@ -141,88 +141,97 @@ class VIEW3D_OT_select_or_deselect_all(Operator):
"""Select element under the mouse, deselect everything is there's nothing under the mouse"""
bl_label = "Select or Deselect All"
bl_idname = "view3d.select_or_deselect_all"
- bl_options = {'UNDO'}
extend: BoolProperty(
name="Extend",
description="Extend selection instead of deselecting everything first",
default=False,
+ options={'SKIP_SAVE'},
)
toggle: BoolProperty(
name="Toggle",
description="Toggle the selection",
default=False,
+ options={'SKIP_SAVE'},
)
deselect: BoolProperty(
name="Deselect",
description="Remove from selection",
default=False,
+ options={'SKIP_SAVE'},
)
center: BoolProperty(
name="Center",
description="Use the object center when selecting, in editmode used to extend object selection",
default=False,
+ options={'SKIP_SAVE'},
)
enumerate: BoolProperty(
name="Enumerate",
description="List objects under the mouse (object mode only)",
default=False,
+ options={'SKIP_SAVE'},
)
object: BoolProperty(
name="Object",
description="Use object selection (editmode only)",
default=False,
+ options={'SKIP_SAVE'},
)
- @classmethod
- def poll(cls, context):
+ def invoke(self, context, event):
+ retval = bpy.ops.view3d.select(
+ 'INVOKE_DEFAULT',
+ True, # undo push
+ extend=self.extend,
+ deselect=self.deselect,
+ toggle=self.toggle,
+ center=self.center,
+ enumerate=self.enumerate,
+ object=self.object,
+ )
+
+ # Finished means something was selected.
+ if 'FINISHED' in retval:
+ return retval
+ if self.extend or self.toggle or self.deselect:
+ return retval
+
active_object = context.active_object
if active_object:
- return active_object.mode in {'EDIT', 'OBJECT', 'POSE'}
- return True
-
- def invoke(self, context, event):
- x = event.mouse_region_x
- y = event.mouse_region_y
-
- if self.extend is False and self.toggle is False and self.deselect is False:
- active_object = context.active_object
-
- if active_object:
- if active_object.mode == 'EDIT':
- if active_object.type == 'MESH':
- bpy.ops.mesh.select_all(action='DESELECT')
- elif active_object.type == 'CURVE':
- bpy.ops.curve.select_all(action='DESELECT')
- elif active_object.type == 'SURFACE':
- bpy.ops.curve.select_all(action='DESELECT')
- elif active_object.type == 'LATTICE':
- bpy.ops.lattice.select_all(action='DESELECT')
- elif active_object.type == 'META':
- bpy.ops.mball.select_all(action='DESELECT')
- elif active_object.type == 'ARMATURE':
- bpy.ops.armature.select_all(action='DESELECT')
- elif active_object.mode == 'POSE':
- bpy.ops.pose.select_all(action='DESELECT')
- elif active_object.mode == 'PARTICLE_EDIT':
- bpy.ops.particle.select_all(action='DESELECT')
+ if active_object.mode == 'OBJECT':
+ select_all = bpy.ops.object.select_all
+ elif active_object.mode == 'EDIT':
+ if active_object.type == 'MESH':
+ select_all = bpy.ops.mesh.select_all
+ elif active_object.type == 'CURVE':
+ select_all = bpy.ops.curve.select_all
+ elif active_object.type == 'SURFACE':
+ select_all = bpy.ops.curve.select_all
+ elif active_object.type == 'LATTICE':
+ select_all = bpy.ops.lattice.select_all
+ elif active_object.type == 'META':
+ select_all = bpy.ops.mball.select_all
+ elif active_object.type == 'ARMATURE':
+ select_all = bpy.ops.armature.select_all
else:
- bpy.ops.object.select_all(action='DESELECT')
+ return retval
+ elif active_object.mode == 'POSE':
+ select_all = bpy.ops.pose.select_all
+ elif active_object.mode == 'PARTICLE_EDIT':
+ select_all = bpy.ops.particle.select_all
else:
- bpy.ops.object.select_all(action='DESELECT')
-
- return bpy.ops.view3d.select(extend=self.extend,
- deselect=self.deselect,
- toggle=self.toggle,
- center=self.center,
- enumerate=self.enumerate,
- object=self.object,
- location=(x, y))
+ # Don nothing in paint and sculpt modes.
+ return retval
+ else:
+ select_all = bpy.ops.object.select_all
+
+ return select_all('INVOKE_DEFAULT', True, action='DESELECT')
classes = (
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 8c0174d8f58..164f1100e83 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -162,42 +162,6 @@ def module_filesystem_remove(path_base, module_name):
os.remove(f_full)
-class BRUSH_OT_active_index_set(Operator):
- """Set active sculpt/paint brush from it's number"""
- bl_idname = "brush.active_index_set"
- bl_label = "Set Brush Number"
-
- mode: StringProperty(
- name="Mode",
- description="Paint mode to set brush for",
- maxlen=1024,
- )
- index: IntProperty(
- name="Number",
- description="Brush number",
- )
-
- _attr_dict = {
- "sculpt": "use_paint_sculpt",
- "vertex_paint": "use_paint_vertex",
- "weight_paint": "use_paint_weight",
- "image_paint": "use_paint_image",
- }
-
- def execute(self, context):
- attr = self._attr_dict.get(self.mode)
- if attr is None:
- return {'CANCELLED'}
-
- toolsettings = context.tool_settings
- for i, brush in enumerate((cur for cur in bpy.data.brushes if getattr(cur, attr))):
- if i == self.index:
- getattr(toolsettings, self.mode).brush = brush
- return {'FINISHED'}
-
- return {'CANCELLED'}
-
-
class WM_OT_context_set_boolean(Operator):
"""Set a context value"""
bl_idname = "wm.context_set_boolean"
@@ -2212,7 +2176,7 @@ class WM_OT_addon_userpref_show(Operator):
module_name = self.module
- modules = addon_utils.modules(refresh=False)
+ _modules = addon_utils.modules(refresh=False)
mod = addon_utils.addons_fake_modules.get(module_name)
if mod is not None:
info = addon_utils.module_bl_info(mod)
@@ -2432,11 +2396,11 @@ class WM_OT_studiolight_install(Operator):
default="*.png;*.jpg;*.hdr;*.exr",
options={'HIDDEN'},
)
- orientation: EnumProperty(
+ type: EnumProperty(
items=(
('MATCAP', "MatCap", ""),
('WORLD', "World", ""),
- ('CAMERA', "Camera", ""),
+ ('STUDIO', "Studio", ""),
)
)
@@ -2453,7 +2417,7 @@ class WM_OT_studiolight_install(Operator):
self.report({'ERROR'}, "Failed to get Studio Light path")
return {'CANCELLED'}
- path_studiolights = pathlib.Path(path_studiolights, "studiolights", self.orientation.lower())
+ path_studiolights = pathlib.Path(path_studiolights, "studiolights", self.type.lower())
if not path_studiolights.exists():
try:
path_studiolights.mkdir(parents=True, exist_ok=True)
@@ -2462,7 +2426,7 @@ class WM_OT_studiolight_install(Operator):
for filepath in filepaths:
shutil.copy(str(filepath), str(path_studiolights))
- userpref.studio_lights.new(str(path_studiolights.joinpath(filepath.name)), self.orientation)
+ userpref.studio_lights.load(str(path_studiolights.joinpath(filepath.name)), self.type)
# print message
msg = (
@@ -2479,7 +2443,71 @@ class WM_OT_studiolight_install(Operator):
return {'RUNNING_MODAL'}
+class WM_OT_studiolight_new(Operator):
+ """Save custom studio light from the studio light editor settings"""
+ bl_idname = 'wm.studiolight_new'
+ bl_label = "Save custom Studio light"
+
+ filename: StringProperty(
+ name="Name",
+ default="StudioLight",
+ )
+
+ ask_overide = False
+
+ def execute(self, context):
+ import pathlib
+ userpref = context.user_preferences
+ wm = context.window_manager
+
+ path_studiolights = bpy.utils.user_resource('DATAFILES')
+
+ if not path_studiolights:
+ self.report({'ERROR'}, "Failed to get Studio Light path")
+ return {'CANCELLED'}
+
+ path_studiolights = pathlib.Path(path_studiolights, "studiolights", "studio")
+ if not path_studiolights.exists():
+ try:
+ path_studiolights.mkdir(parents=True, exist_ok=True)
+ except:
+ traceback.print_exc()
+
+ finalpath = str(path_studiolights.joinpath(self.filename));
+ if pathlib.Path(finalpath + ".sl").is_file():
+ if not self.ask_overide:
+ self.ask_overide = True
+ return wm.invoke_props_dialog(self, width=600)
+ else:
+ for studio_light in userpref.studio_lights:
+ if studio_light.name == self.filename + ".sl":
+ bpy.ops.wm.studiolight_uninstall(index=studio_light.index)
+
+ userpref.studio_lights.new(path=finalpath)
+
+ # print message
+ msg = (
+ tip_("StudioLight Installed %r into %r") %
+ (self.filename, str(path_studiolights))
+ )
+ print(msg)
+ self.report({'INFO'}, msg)
+ return {'FINISHED'}
+
+ def draw(self, context):
+ layout = self.layout
+ if self.ask_overide:
+ layout.label(text="Warning, file already exists. Overwrite existing file?")
+ else:
+ layout.prop(self, "filename")
+
+ def invoke(self, context, event):
+ wm = context.window_manager
+ return wm.invoke_props_dialog(self, width=600)
+
+
class WM_OT_studiolight_uninstall(Operator):
+ """Delete Studio Light"""
bl_idname = 'wm.studiolight_uninstall'
bl_label = "Uninstall Studio Light"
index: bpy.props.IntProperty()
@@ -2504,6 +2532,28 @@ class WM_OT_studiolight_uninstall(Operator):
return {'CANCELLED'}
+class WM_OT_studiolight_copy_settings(Operator):
+ """Copy Studio Light settings to the Studio light editor"""
+ bl_idname = 'wm.studiolight_copy_settings'
+ bl_label = "Copy Studio Light settings"
+ index: bpy.props.IntProperty()
+
+ def execute(self, context):
+ userpref = context.user_preferences
+ system = userpref.system
+ for studio_light in userpref.studio_lights:
+ if studio_light.index == self.index:
+ system.light_ambient = studio_light.light_ambient
+ for sys_light, light in zip(system.solid_lights, studio_light.solid_lights):
+ sys_light.use = light.use
+ sys_light.diffuse_color = light.diffuse_color
+ sys_light.specular_color = light.specular_color
+ sys_light.smooth = light.smooth
+ sys_light.direction = light.direction
+ return {'FINISHED'}
+ return {'CANCELLED'}
+
+
class WM_OT_studiolight_userpref_show(Operator):
"""Show light user preferences"""
bl_idname = "wm.studiolight_userpref_show"
@@ -2521,7 +2571,7 @@ class WM_MT_splash(Menu):
def draw_setup(self, context):
wm = context.window_manager
- userpref = context.user_preferences
+ # userpref = context.user_preferences
layout = self.layout
@@ -2554,9 +2604,17 @@ class WM_MT_splash(Menu):
row = sub.row()
row.alignment = 'RIGHT'
row.label(text="Select With")
- sub.row().prop(kc_prefs, 'select_mouse', expand=True)
+ sub.row().prop(kc_prefs, "select_mouse", expand=True)
has_select_mouse = True
+ has_spacebar_action = hasattr(kc_prefs, "spacebar_action")
+ if has_spacebar_action:
+ sub = col.split(factor=0.35)
+ row = sub.row()
+ row.alignment = 'RIGHT'
+ row.label(text="Spacebar")
+ sub.row().prop(kc_prefs, "spacebar_action", expand=True)
+ has_select_mouse = True
col.separator()
@@ -2580,6 +2638,8 @@ class WM_MT_splash(Menu):
# Keep height constant
if not has_select_mouse:
col.label()
+ if not has_spacebar_action:
+ col.label()
layout.label()
@@ -2596,6 +2656,7 @@ class WM_MT_splash(Menu):
sub.operator("wm.save_userpref", text="Next")
layout.separator()
+ layout.separator()
def draw(self, context):
# Draw setup screen if no user preferences have been saved yet.
@@ -2673,6 +2734,7 @@ class WM_MT_splash(Menu):
).url = "https://www.blender.org/foundation/donation-payment/"
layout.separator()
+ layout.separator()
class WM_OT_drop_blend_file(Operator):
@@ -2700,7 +2762,6 @@ class WM_OT_drop_blend_file(Operator):
col.operator("wm.append", text="Append...", icon='APPEND_BLEND').filepath = self.filepath
classes = (
- BRUSH_OT_active_index_set,
WM_OT_addon_disable,
WM_OT_addon_enable,
WM_OT_addon_expand,
@@ -2753,7 +2814,9 @@ classes = (
WM_OT_owner_enable,
WM_OT_url_open,
WM_OT_studiolight_install,
+ WM_OT_studiolight_new,
WM_OT_studiolight_uninstall,
+ WM_OT_studiolight_copy_settings,
WM_OT_studiolight_userpref_show,
WM_OT_tool_set_by_name,
WM_OT_toolbar,
diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py
index 16d40e25324..6df338dbc00 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -356,7 +356,7 @@ class DATA_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit from
class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "object.data"
_property_type = bpy.types.Armature
diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py
index 4fafadc0559..781729e0594 100644
--- a/release/scripts/startup/bl_ui/properties_data_bone.py
+++ b/release/scripts/startup/bl_ui/properties_data_bone.py
@@ -401,7 +401,7 @@ class BONE_PT_deform(BoneButtonsPanel, Panel):
class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_property_type = bpy.types.Bone, bpy.types.EditBone, bpy.types.PoseBone
@property
diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py
index a66e82c7f74..c09f9d8b4ee 100644
--- a/release/scripts/startup/bl_ui/properties_data_camera.py
+++ b/release/scripts/startup/bl_ui/properties_data_camera.py
@@ -39,7 +39,7 @@ class CAMERA_PT_presets(PresetMenu):
preset_subdir = "camera"
preset_operator = "script.execute_preset"
preset_add_operator = "camera.preset_add"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
class SAFE_AREAS_PT_presets(PresetMenu):
@@ -47,13 +47,13 @@ class SAFE_AREAS_PT_presets(PresetMenu):
preset_subdir = "safe_areas"
preset_operator = "script.execute_preset"
preset_add_operator = "safe_areas.preset_add"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
class DATA_PT_context_camera(CameraButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -70,7 +70,7 @@ class DATA_PT_context_camera(CameraButtonsPanel, Panel):
class DATA_PT_lens(CameraButtonsPanel, Panel):
bl_label = "Lens"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -111,7 +111,7 @@ class DATA_PT_lens(CameraButtonsPanel, Panel):
sub = col.column(align=True)
sub.prop(ccam, "longitude_min", text="Longiture Min")
sub.prop(ccam, "longitude_max", text="Max")
- elif engine in {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}:
+ elif engine in {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}:
if cam.lens_unit == 'MILLIMETERS':
col.prop(cam, "lens")
elif cam.lens_unit == 'FOV':
@@ -133,7 +133,7 @@ class DATA_PT_lens(CameraButtonsPanel, Panel):
class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel):
bl_label = "Stereoscopy"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -182,7 +182,7 @@ class DATA_PT_camera_stereoscopy(CameraButtonsPanel, Panel):
class DATA_PT_camera(CameraButtonsPanel, Panel):
bl_label = "Camera"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header_preset(self, context):
CAMERA_PT_presets.draw_panel_header(self.layout)
@@ -259,7 +259,7 @@ class DATA_PT_camera_dof_aperture(CameraButtonsPanel, Panel):
class DATA_PT_camera_background_image(CameraButtonsPanel, Panel):
bl_label = "Background Images"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
cam = context.camera
@@ -365,7 +365,7 @@ class DATA_PT_camera_background_image(CameraButtonsPanel, Panel):
class DATA_PT_camera_display(CameraButtonsPanel, Panel):
bl_label = "Viewport Display"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -398,7 +398,7 @@ class DATA_PT_camera_display(CameraButtonsPanel, Panel):
class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel):
bl_label = "Safe Areas"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
cam = context.camera
@@ -417,7 +417,7 @@ class DATA_PT_camera_safe_areas(CameraButtonsPanel, Panel):
class DATA_PT_custom_props_camera(CameraButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "object.data"
_property_type = bpy.types.Camera
diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py
index 9155da14c6b..e7f9de5dc20 100644
--- a/release/scripts/startup/bl_ui/properties_data_curve.py
+++ b/release/scripts/startup/bl_ui/properties_data_curve.py
@@ -135,7 +135,7 @@ class DATA_PT_shape_curve(CurveButtonsPanel, Panel):
class DATA_PT_curve_texture_space(CurveButtonsPanel, Panel):
bl_label = "Texture Space"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -441,6 +441,7 @@ class DATA_PT_text_boxes(CurveButtonsPanelText, Panel):
text = context.curve
layout.operator("font.textbox_add", icon='ADD')
+ layout.prop(text, "overflow", text="Overflow")
for i, box in enumerate(text.text_boxes):
@@ -463,7 +464,7 @@ class DATA_PT_text_boxes(CurveButtonsPanelText, Panel):
class DATA_PT_custom_props_curve(CurveButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "object.data"
_property_type = bpy.types.Curve
diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index 949a48ed7f1..558c3c190b6 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -135,13 +135,22 @@ class DATA_PT_gpencil_datapanel(Panel):
col.template_list("GPENCIL_UL_layer", "", gpd, "layers", gpd.layers, "active_index",
rows=layer_rows, reverse=True)
+ gpl = context.active_gpencil_layer
+ if gpl:
+ srow = col.row(align=True)
+ srow.prop(gpl, "blend_mode", text="Blend")
+
+ srow = col.row(align=True)
+ srow.prop(gpl, "opacity", text="Opacity", slider=True)
+ srow.prop(gpl, "clamp_layer", text="",
+ icon='MOD_MASK' if gpl.clamp_layer else 'ONIONSKIN_OFF')
+
col = row.column()
sub = col.column(align=True)
sub.operator("gpencil.layer_add", icon='ADD', text="")
sub.operator("gpencil.layer_remove", icon='REMOVE', text="")
- gpl = context.active_gpencil_layer
if gpl:
sub.menu("GPENCIL_MT_layer_specials", icon='DOWNARROW_HLT', text="")
@@ -158,10 +167,6 @@ class DATA_PT_gpencil_datapanel(Panel):
sub.operator("gpencil.layer_isolate", icon='LOCKED', text="").affect_visibility = False
sub.operator("gpencil.layer_isolate", icon='RESTRICT_VIEW_ON', text="").affect_visibility = True
- row = layout.row(align=True)
- if gpl:
- row.prop(gpl, "opacity", text="Opacity", slider=True)
-
class DATA_PT_gpencil_layer_optionpanel(LayerDataButtonsPanel, Panel):
bl_space_type = 'PROPERTIES'
diff --git a/release/scripts/startup/bl_ui/properties_data_lattice.py b/release/scripts/startup/bl_ui/properties_data_lattice.py
index c18fd30b128..330844440d0 100644
--- a/release/scripts/startup/bl_ui/properties_data_lattice.py
+++ b/release/scripts/startup/bl_ui/properties_data_lattice.py
@@ -85,7 +85,7 @@ class DATA_PT_lattice(DataButtonsPanel, Panel):
class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "object.data"
_property_type = bpy.types.Lattice
diff --git a/release/scripts/startup/bl_ui/properties_data_light.py b/release/scripts/startup/bl_ui/properties_data_light.py
index 7d21ecb99b3..c35b3b35a88 100644
--- a/release/scripts/startup/bl_ui/properties_data_light.py
+++ b/release/scripts/startup/bl_ui/properties_data_light.py
@@ -36,7 +36,7 @@ class DataButtonsPanel:
class DATA_PT_context_light(DataButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -62,7 +62,7 @@ class DATA_PT_preview(DataButtonsPanel, Panel):
class DATA_PT_light(DataButtonsPanel, Panel):
bl_label = "Light"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -234,7 +234,7 @@ class DATA_PT_EEVEE_shadow_contact(DataButtonsPanel, Panel):
class DATA_PT_area(DataButtonsPanel, Panel):
bl_label = "Area Shape"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -261,7 +261,7 @@ class DATA_PT_area(DataButtonsPanel, Panel):
class DATA_PT_spot(DataButtonsPanel, Panel):
bl_label = "Spot Shape"
bl_parent_id = "DATA_PT_EEVEE_light"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -302,7 +302,7 @@ class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
class DATA_PT_custom_props_light(DataButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "object.data"
_property_type = bpy.types.Light
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index dd828c7a8c6..bbeb0904daf 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -154,7 +154,7 @@ class MeshButtonsPanel:
class DATA_PT_context_mesh(MeshButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -172,7 +172,7 @@ class DATA_PT_context_mesh(MeshButtonsPanel, Panel):
class DATA_PT_normals(MeshButtonsPanel, Panel):
bl_label = "Normals"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -192,7 +192,7 @@ class DATA_PT_normals(MeshButtonsPanel, Panel):
class DATA_PT_texture_space(MeshButtonsPanel, Panel):
bl_label = "Texture Space"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -212,7 +212,7 @@ class DATA_PT_texture_space(MeshButtonsPanel, Panel):
class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
bl_label = "Vertex Groups"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -265,7 +265,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
class DATA_PT_face_maps(MeshButtonsPanel, Panel):
bl_label = "Face Maps"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -308,7 +308,7 @@ class DATA_PT_face_maps(MeshButtonsPanel, Panel):
class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
bl_label = "Shape Keys"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -402,7 +402,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
bl_label = "UV Maps"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -422,7 +422,7 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
bl_label = "Vertex Colors"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -442,7 +442,7 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
class DATA_PT_customdata(MeshButtonsPanel, Panel):
bl_label = "Geometry Data"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -469,7 +469,7 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel):
class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "object.data"
_property_type = bpy.types.Mesh
diff --git a/release/scripts/startup/bl_ui/properties_data_metaball.py b/release/scripts/startup/bl_ui/properties_data_metaball.py
index 267577ae3b4..4b6e648e62d 100644
--- a/release/scripts/startup/bl_ui/properties_data_metaball.py
+++ b/release/scripts/startup/bl_ui/properties_data_metaball.py
@@ -71,7 +71,7 @@ class DATA_PT_metaball(DataButtonsPanel, Panel):
class DATA_PT_mball_texture_space(DataButtonsPanel, Panel):
bl_label = "Texture Space"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -126,7 +126,7 @@ class DATA_PT_metaball_element(DataButtonsPanel, Panel):
class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "object.data"
_property_type = bpy.types.MetaBall
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index b7ef78ab7a6..3091421aa2b 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -651,8 +651,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.prop(md, "levels", text="Preview")
col.prop(md, "sculpt_levels", text="Sculpt")
col.prop(md, "render_levels", text="Render")
- if hasattr(md, "quality"):
- col.prop(md, "quality")
+ col.prop(md, "quality")
col = split.column()
@@ -1030,8 +1029,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.label(text="Subdivisions:")
col.prop(md, "levels", text="View")
col.prop(md, "render_levels", text="Render")
- if hasattr(md, "quality"):
- col.prop(md, "quality")
+ col.prop(md, "quality")
col = split.column()
col.label(text="Options:")
diff --git a/release/scripts/startup/bl_ui/properties_data_speaker.py b/release/scripts/startup/bl_ui/properties_data_speaker.py
index cd2b9934aaf..5de133f184a 100644
--- a/release/scripts/startup/bl_ui/properties_data_speaker.py
+++ b/release/scripts/startup/bl_ui/properties_data_speaker.py
@@ -36,7 +36,7 @@ class DataButtonsPanel:
class DATA_PT_context_speaker(DataButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -55,7 +55,7 @@ class DATA_PT_context_speaker(DataButtonsPanel, Panel):
class DATA_PT_speaker(DataButtonsPanel, Panel):
bl_label = "Sound"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -77,7 +77,7 @@ class DATA_PT_speaker(DataButtonsPanel, Panel):
class DATA_PT_distance(DataButtonsPanel, Panel):
bl_label = "Distance"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -101,7 +101,7 @@ class DATA_PT_distance(DataButtonsPanel, Panel):
class DATA_PT_cone(DataButtonsPanel, Panel):
bl_label = "Cone"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -123,7 +123,7 @@ class DATA_PT_cone(DataButtonsPanel, Panel):
class DATA_PT_custom_props_speaker(DataButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "object.data"
_property_type = bpy.types.Speaker
diff --git a/release/scripts/startup/bl_ui/properties_freestyle.py b/release/scripts/startup/bl_ui/properties_freestyle.py
index f5f15c7ca58..c67ea2d4b8b 100644
--- a/release/scripts/startup/bl_ui/properties_freestyle.py
+++ b/release/scripts/startup/bl_ui/properties_freestyle.py
@@ -208,7 +208,7 @@ class VIEWLAYER_PT_freestyle_lineset(ViewLayerFreestyleEditorButtonsPanel, Panel
row.prop(lineset, "select_by_visibility", text="Visibility", toggle=True)
row.prop(lineset, "select_by_edge_types", text="Edge Types", toggle=True)
row.prop(lineset, "select_by_face_marks", text="Face Marks", toggle=True)
- row.prop(lineset, "select_by_group", text="Group", toggle=True)
+ row.prop(lineset, "select_by_collection", text="Collection", toggle=True)
row.prop(lineset, "select_by_image_border", text="Image Border", toggle=True)
if lineset.select_by_visibility:
@@ -247,11 +247,11 @@ class VIEWLAYER_PT_freestyle_lineset(ViewLayerFreestyleEditorButtonsPanel, Panel
row.prop(lineset, "face_mark_negation", expand=True)
row.prop(lineset, "face_mark_condition", expand=True)
- if lineset.select_by_group:
- col.label(text="Group:")
+ if lineset.select_by_collection:
+ col.label(text="Collection:")
row = col.row()
- row.prop(lineset, "group", text="")
- row.prop(lineset, "group_negation", expand=True)
+ row.prop(lineset, "collection", text="")
+ row.prop(lineset, "collection_negation", expand=True)
class VIEWLAYER_PT_freestyle_linestyle(ViewLayerFreestyleEditorButtonsPanel, Panel):
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 296e05a709d..5a0c2bd1e43 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -644,6 +644,7 @@ class GPENCIL_MT_gpencil_draw_specials(Menu):
layout.operator("gpencil.primitive", text="Line", icon='IPO_CONSTANT').type = 'LINE'
layout.operator("gpencil.primitive", text="Rectangle", icon='UV_FACESEL').type = 'BOX'
layout.operator("gpencil.primitive", text="Circle", icon='ANTIALIASED').type = 'CIRCLE'
+ layout.operator("gpencil.primitive", text="Arc", icon='SPHERECURVE').type = 'ARC'
class GPENCIL_MT_gpencil_draw_delete(Menu):
@@ -766,7 +767,6 @@ class AnnotationDataPanel:
layout.prop(tool_settings, "annotation_thickness", text="Thickness")
if gpl:
- # layout.prop(gpl, "opacity", text="Opacity", slider=True)
# Full-Row - Frame Locking (and Delete Frame)
row = layout.row(align=True)
row.active = not gpl.lock
@@ -780,6 +780,54 @@ class AnnotationDataPanel:
row.operator("gpencil.active_frame_delete", text="", icon='X')
+class AnnotationOnionSkin:
+ bl_label = "Onion Skin"
+ bl_region_type = 'UI'
+ bl_options = {'DEFAULT_CLOSED'}
+
+ @classmethod
+ def poll(cls, context):
+ # Show this panel as long as someone that might own this exists
+ # AND the owner isn't an object (e.g. GP Object)
+ if context.gpencil_data_owner is None:
+ return False
+ elif type(context.gpencil_data_owner) is bpy.types.Object:
+ return False
+ else:
+ gpl = context.active_gpencil_layer
+ if gpl is None:
+ return False
+
+ return True
+
+ @staticmethod
+ def draw_header(self, context):
+ gpl = context.active_gpencil_layer
+ self.layout.prop(gpl, "use_annotation_onion_skinning", text="")
+
+ @staticmethod
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_decorate = False
+
+ gpl = context.active_gpencil_layer
+ col = layout.column()
+ split = col.split(factor=0.5)
+ split.active = gpl.use_annotation_onion_skinning
+
+ # - Before Frames
+ sub = split.column(align=True)
+ row = sub.row(align=True)
+ row.prop(gpl, "annotation_onion_before_color", text="")
+ sub.prop(gpl, "annotation_onion_before_range", text="Before")
+
+ # - After Frames
+ sub = split.column(align=True)
+ row = sub.row(align=True)
+ row.prop(gpl, "annotation_onion_after_color", text="")
+ sub.prop(gpl, "annotation_onion_after_range", text="After")
+
+
class GreasePencilOnionPanel:
@staticmethod
def draw_settings(layout, gp):
@@ -855,6 +903,66 @@ class GreasePencilToolsPanel:
gpencil_stroke_placement_settings(context, layout)
+class GreasePencilMaterialsPanel:
+ # Mix-in, use for properties editor and top-bar.
+
+ @classmethod
+ def poll(cls, context):
+ ob = context.object
+ return ob and ob.type == 'GPENCIL'
+
+ @staticmethod
+ def draw(self, context):
+ layout = self.layout
+ show_full_ui = (self.bl_space_type == 'PROPERTIES')
+
+ gpd = context.gpencil_data
+
+ ob = context.object
+
+ is_sortable = len(ob.material_slots) > 1
+ rows = 7
+
+ row = layout.row()
+
+ row.template_list("GPENCIL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
+
+ col = row.column(align=True)
+ if show_full_ui:
+ col.operator("object.material_slot_add", icon='ADD', text="")
+ col.operator("object.material_slot_remove", icon='REMOVE', text="")
+
+ col.menu("GPENCIL_MT_color_specials", icon='DOWNARROW_HLT', text="")
+
+ if is_sortable:
+ col.separator()
+
+ col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
+ col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
+
+ col.separator()
+
+ sub = col.column(align=True)
+ sub.operator("gpencil.color_isolate", icon='LOCKED', text="").affect_visibility = False
+ sub.operator("gpencil.color_isolate", icon='RESTRICT_VIEW_ON', text="").affect_visibility = True
+
+ if show_full_ui:
+ row = layout.row()
+
+ row.template_ID(ob, "active_material", new="material.new", live_icon=True)
+
+ slot = context.material_slot
+ if slot:
+ icon_link = 'MESH_DATA' if slot.link == 'DATA' else 'OBJECT_DATA'
+ row.prop(slot, "link", icon=icon_link, icon_only=True)
+
+ if gpd.use_stroke_edit_mode:
+ row = layout.row(align=True)
+ row.operator("gpencil.stroke_change_color", text="Assign")
+ row.operator("gpencil.color_select", text="Select").deselect = False
+ row.operator("gpencil.color_select", text="Deselect").deselect = True
+
+
class GPENCIL_UL_layer(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
# assert(isinstance(item, bpy.types.GPencilLayer)
@@ -873,6 +981,10 @@ class GPENCIL_UL_layer(UIList):
row.prop(gpl, "info", text="", emboss=False)
row = layout.row(align=True)
+ row.prop(gpl, "clamp_layer", text="",
+ icon='MOD_MASK' if gpl.clamp_layer else 'ONIONSKIN_OFF',
+ emboss=False)
+
row.prop(gpl, "lock", text="", emboss=False)
row.prop(gpl, "hide", text="", emboss=False)
subrow = row.row(align=True)
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index 4f28b14e3b5..aa3166febee 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -73,7 +73,7 @@ class MATERIAL_PT_preview(MaterialButtonsPanel, Panel):
class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "material"
_property_type = bpy.types.Material
@@ -82,7 +82,7 @@ class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel):
bl_label = ""
bl_context = "material"
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -204,8 +204,8 @@ class EEVEE_MATERIAL_PT_volume(MaterialButtonsPanel, Panel):
panel_node_draw(layout, mat.node_tree, 'OUTPUT_MATERIAL', "Volume")
-class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel):
- bl_label = "Options"
+class EEVEE_MATERIAL_PT_settings(MaterialButtonsPanel, Panel):
+ bl_label = "Settings"
bl_context = "material"
COMPAT_ENGINES = {'BLENDER_EEVEE'}
@@ -214,12 +214,11 @@ class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel):
engine = context.engine
return context.material and (engine in cls.COMPAT_ENGINES)
- def draw(self, context):
+ @staticmethod
+ def draw_shared(self, mat):
layout = self.layout
layout.use_property_split = True
- mat = context.material
-
layout.prop(mat, "blend_method")
if mat.blend_method != 'OPAQUE':
@@ -236,6 +235,9 @@ class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel):
layout.prop(mat, "refraction_depth")
layout.prop(mat, "use_sss_translucency")
+ def draw(self, context):
+ self.draw_shared(self, context.material)
+
class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel):
bl_label = "Viewport Display"
@@ -246,17 +248,19 @@ class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel):
def poll(cls, context):
return context.material
- def draw(self, context):
- mat = context.material
-
+ @staticmethod
+ def draw_shared(self, mat):
layout = self.layout
layout.use_property_split = True
col = layout.column()
- col.prop(mat, "diffuse_color")
- col.prop(mat, "specular_color")
+ col.prop(mat, "diffuse_color", text="Color")
+ col.prop(mat, "metallic")
col.prop(mat, "roughness")
+ def draw(self, context):
+ self.draw_shared(self, context.material)
+
classes = (
MATERIAL_MT_specials,
@@ -265,7 +269,7 @@ classes = (
EEVEE_MATERIAL_PT_context_material,
EEVEE_MATERIAL_PT_surface,
EEVEE_MATERIAL_PT_volume,
- EEVEE_MATERIAL_PT_options,
+ EEVEE_MATERIAL_PT_settings,
MATERIAL_PT_viewport,
MATERIAL_PT_custom_props,
)
diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index a3fdd37e029..282f8d77515 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -22,6 +22,10 @@ from bpy.types import Menu, Panel, UIList
from rna_prop_ui import PropertyPanel
from bl_operators.presets import PresetMenu
+from .properties_grease_pencil_common import (
+ GreasePencilMaterialsPanel,
+)
+
class GPENCIL_MT_color_specials(Menu):
bl_label = "Layer"
@@ -83,72 +87,13 @@ class GPMaterialButtonsPanel:
ob.active_material.grease_pencil)
-class MATERIAL_PT_gpencil_slots(Panel):
+class MATERIAL_PT_gpencil_slots(GreasePencilMaterialsPanel, Panel):
bl_label = "Grease Pencil Material Slots"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "material"
bl_options = {'HIDE_HEADER'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- return ob and ob.type == 'GPENCIL'
-
- @staticmethod
- def draw(self, context):
- layout = self.layout
- gpd = context.gpencil_data
-
- mat = context.object.active_material
- ob = context.object
- slot = context.material_slot
- space = context.space_data
-
- if ob:
- is_sortable = len(ob.material_slots) > 1
- rows = 7
-
- row = layout.row()
-
- row.template_list("GPENCIL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
-
- col = row.column(align=True)
- col.operator("object.material_slot_add", icon='ADD', text="")
- col.operator("object.material_slot_remove", icon='REMOVE', text="")
-
- col.menu("GPENCIL_MT_color_specials", icon='DOWNARROW_HLT', text="")
-
- if is_sortable:
- col.separator()
-
- col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
- col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
-
- col.separator()
-
- sub = col.column(align=True)
- sub.operator("gpencil.color_isolate", icon='LOCKED', text="").affect_visibility = False
- sub.operator("gpencil.color_isolate", icon='RESTRICT_VIEW_ON', text="").affect_visibility = True
-
- row = layout.row()
-
- if ob:
- row.template_ID(ob, "active_material", new="material.new", live_icon=True)
-
- if slot:
- icon_link = 'MESH_DATA' if slot.link == 'DATA' else 'OBJECT_DATA'
- row.prop(slot, "link", icon=icon_link, icon_only=True)
-
- if gpd.use_stroke_edit_mode:
- row = layout.row(align=True)
- row.operator("gpencil.stroke_change_color", text="Assign")
- row.operator("gpencil.color_select", text="Select").deselect = False
- row.operator("gpencil.color_select", text="Deselect").deselect = True
-
- elif mat:
- row.template_ID(space, "pin_id")
-
# Used as parent for "Stroke" and "Fill" panels
class MATERIAL_PT_gpencil_surface(GPMaterialButtonsPanel, Panel):
@@ -157,14 +102,14 @@ class MATERIAL_PT_gpencil_surface(GPMaterialButtonsPanel, Panel):
@classmethod
def poll(cls, context):
ob = context.object
- if ob is None:
+ if not (ob and ob.type == 'GPENCIL'):
return False
- ma = context.object.active_material
- if ma is None or ma.grease_pencil is None:
+ ma = ob.active_material
+ if not (ma and ma.grease_pencil):
return False
- return ob.type == 'GPENCIL'
+ return True
def draw_header_preset(self, context):
MATERIAL_PT_gpencil_material_presets.draw_panel_header(self.layout)
@@ -299,7 +244,7 @@ class MATERIAL_PT_gpencil_preview(GPMaterialButtonsPanel, Panel):
class MATERIAL_PT_gpencil_custom_props(GPMaterialButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "object.active_material"
_property_type = bpy.types.Material
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index d25d3c1f86e..5740239fc12 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -176,7 +176,7 @@ class COLLECTION_MT_specials(Menu):
layout.operator("object.collection_unlink", icon='X')
layout.operator("object.collection_objects_select")
- layout.operator("object.dupli_offset_from_cursor")
+ layout.operator("object.instance_offset_from_cursor")
class OBJECT_PT_collections(ObjectButtonsPanel, Panel):
@@ -212,7 +212,7 @@ class OBJECT_PT_collections(ObjectButtonsPanel, Panel):
row.menu("COLLECTION_MT_specials", icon='DOWNARROW_HLT', text="")
row = col.box().row()
- row.prop(collection, "dupli_offset", text="")
+ row.prop(collection, "instance_offset", text="")
class OBJECT_PT_display(ObjectButtonsPanel, Panel):
@@ -230,7 +230,7 @@ class OBJECT_PT_display(ObjectButtonsPanel, Panel):
is_geometry = (obj_type in {'MESH', 'CURVE', 'SURFACE', 'META', 'FONT'})
is_wire = (obj_type in {'CAMERA', 'EMPTY'})
is_empty_image = (obj_type == 'EMPTY' and obj.empty_display_type == 'IMAGE')
- is_dupli = (obj.dupli_type != 'NONE')
+ is_dupli = (obj.instance_type != 'NONE')
col = flow.column()
col.prop(obj, "show_name", text="Name")
@@ -279,7 +279,7 @@ class OBJECT_PT_display(ObjectButtonsPanel, Panel):
class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
- bl_label = "Duplication"
+ bl_label = "Instancing"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
@@ -288,42 +288,42 @@ class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
ob = context.object
row = layout.row()
- row.prop(ob, "dupli_type", expand=True)
+ row.prop(ob, "instance_type", expand=True)
layout.use_property_split = True
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
- if ob.dupli_type == 'FRAMES':
+ if ob.instance_type == 'FRAMES':
col = flow.column(align=True)
- col.prop(ob, "dupli_frames_start", text="Start")
- col.prop(ob, "dupli_frames_end", text="End")
+ col.prop(ob, "instance_frames_start", text="Start")
+ col.prop(ob, "instance_frames_end", text="End")
col = flow.column(align=True)
- col.prop(ob, "dupli_frames_on", text="On")
- col.prop(ob, "dupli_frames_off", text="Off")
+ col.prop(ob, "instance_frames_on", text="On")
+ col.prop(ob, "instance_frames_off", text="Off")
col = flow.column(align=True)
- col.prop(ob, "use_dupli_frames_speed", text="Speed")
+ col.prop(ob, "use_instance_frames_speed", text="Speed")
- elif ob.dupli_type == 'VERTS':
- layout.prop(ob, "use_dupli_vertices_rotation", text="Rotation")
+ elif ob.instance_type == 'VERTS':
+ layout.prop(ob, "use_instance_vertices_rotation", text="Rotation")
- elif ob.dupli_type == 'FACES':
+ elif ob.instance_type == 'FACES':
col = flow.column()
- col.prop(ob, "use_dupli_faces_scale", text="Scale")
+ col.prop(ob, "use_instance_faces_scale", text="Scale")
sub = col.column()
- sub.active = ob.use_dupli_faces_scale
- sub.prop(ob, "dupli_faces_scale", text="Inherit Scale")
+ sub.active = ob.use_instance_faces_scale
+ sub.prop(ob, "instance_faces_scale", text="Inherit Scale")
- elif ob.dupli_type == 'COLLECTION':
+ elif ob.instance_type == 'COLLECTION':
col = flow.column()
- col.prop(ob, "dupli_group", text="Collection")
+ col.prop(ob, "instance_collection", text="Collection")
- if ob.dupli_type != 'NONE' or len(ob.particle_systems):
+ if ob.instance_type != 'NONE' or len(ob.particle_systems):
col = flow.column(align=True)
- col.prop(ob, "show_duplicator_for_viewport")
- col.prop(ob, "show_duplicator_for_render")
+ col.prop(ob, "show_instancer_for_viewport")
+ col.prop(ob, "show_instancer_for_render")
from .properties_animviz import (
@@ -387,7 +387,7 @@ class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit fr
class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "object"
_property_type = bpy.types.Object
diff --git a/release/scripts/startup/bl_ui/properties_output.py b/release/scripts/startup/bl_ui/properties_output.py
index cf5f65738c8..d7b482c4dc5 100644
--- a/release/scripts/startup/bl_ui/properties_output.py
+++ b/release/scripts/startup/bl_ui/properties_output.py
@@ -56,7 +56,7 @@ class RenderOutputButtonsPanel:
class RENDER_PT_dimensions(RenderOutputButtonsPanel, Panel):
bl_label = "Dimensions"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_frame_rate_args_prev = None
_preset_class = None
@@ -144,7 +144,7 @@ class RENDER_PT_frame_remapping(RenderOutputButtonsPanel, Panel):
bl_label = "Time Remapping"
bl_parent_id = "RENDER_PT_dimensions"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -161,7 +161,7 @@ class RENDER_PT_frame_remapping(RenderOutputButtonsPanel, Panel):
class RENDER_PT_post_processing(RenderOutputButtonsPanel, Panel):
bl_label = "Post Processing"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -181,7 +181,7 @@ class RENDER_PT_post_processing(RenderOutputButtonsPanel, Panel):
class RENDER_PT_stamp(RenderOutputButtonsPanel, Panel):
bl_label = "Metadata"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -205,6 +205,8 @@ class RENDER_PT_stamp(RenderOutputButtonsPanel, Panel):
col.prop(rd, "use_stamp_frame_range", text="Frame Range")
col = flow.column()
col.prop(rd, "use_stamp_memory", text="Memory")
+ col = flow.column()
+ col.prop(rd, "use_stamp_hostname", text="Hostname")
col = flow.column()
col.prop(rd, "use_stamp_camera", text="Camera")
@@ -231,7 +233,7 @@ class RENDER_PT_stamp_note(RenderOutputButtonsPanel, Panel):
bl_label = "Note"
bl_parent_id = "RENDER_PT_stamp"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
rd = context.scene.render
@@ -251,7 +253,7 @@ class RENDER_PT_stamp_burn(RenderOutputButtonsPanel, Panel):
bl_label = "Burn Into Image"
bl_parent_id = "RENDER_PT_stamp"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
rd = context.scene.render
@@ -275,7 +277,7 @@ class RENDER_PT_stamp_burn(RenderOutputButtonsPanel, Panel):
class RENDER_PT_output(RenderOutputButtonsPanel, Panel):
bl_label = "Output"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -308,7 +310,7 @@ class RENDER_PT_output(RenderOutputButtonsPanel, Panel):
class RENDER_PT_output_views(RenderOutputButtonsPanel, Panel):
bl_label = "Views"
bl_parent_id = "RENDER_PT_output"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(self, context):
@@ -328,7 +330,7 @@ class RENDER_PT_encoding(RenderOutputButtonsPanel, Panel):
bl_label = "Encoding"
bl_parent_id = "RENDER_PT_output"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header_preset(self, context):
RENDER_PT_ffmpeg_presets.draw_panel_header(self.layout)
@@ -353,7 +355,7 @@ class RENDER_PT_encoding(RenderOutputButtonsPanel, Panel):
class RENDER_PT_encoding_video(RenderOutputButtonsPanel, Panel):
bl_label = "Video"
bl_parent_id = "RENDER_PT_encoding"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -417,7 +419,7 @@ class RENDER_PT_encoding_video(RenderOutputButtonsPanel, Panel):
class RENDER_PT_encoding_audio(RenderOutputButtonsPanel, Panel):
bl_label = "Audio"
bl_parent_id = "RENDER_PT_encoding"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -457,7 +459,7 @@ class RENDER_UL_renderviews(UIList):
class RENDER_PT_stereoscopy(RenderOutputButtonsPanel, Panel):
bl_label = "Stereoscopy"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
bl_options = {'DEFAULT_CLOSED'}
def draw_header(self, context):
diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 26cb263a1d1..c7b97836267 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -67,7 +67,7 @@ def particle_get_settings(context):
class PARTICLE_MT_specials(Menu):
bl_label = "Particle Specials"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -100,7 +100,7 @@ class PARTICLE_PT_hair_dynamics_presets(PresetMenu):
preset_subdir = "hair_dynamics"
preset_operator = "script.execute_preset"
preset_add_operator = "particle.hair_dynamics_preset_add"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
class ParticleButtonsPanel:
@@ -152,7 +152,7 @@ class PARTICLE_UL_particle_systems(bpy.types.UIList):
class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -244,7 +244,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
class PARTICLE_PT_emission(ParticleButtonsPanel, Panel):
bl_label = "Emission"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -298,7 +298,7 @@ class PARTICLE_PT_emission_source(ParticleButtonsPanel, Panel):
bl_label = "Source"
bl_parent_id = "PARTICLE_PT_emission"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -336,7 +336,7 @@ class PARTICLE_PT_emission_source(ParticleButtonsPanel, Panel):
class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
bl_label = "Hair Dynamics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -417,7 +417,7 @@ class PARTICLE_PT_hair_dynamics_structure(ParticleButtonsPanel, Panel):
bl_label = "Structure"
bl_parent_id = "PARTICLE_PT_hair_dynamics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -448,7 +448,7 @@ class PARTICLE_PT_hair_dynamics_volume(ParticleButtonsPanel, Panel):
bl_label = "Volume"
bl_parent_id = "PARTICLE_PT_hair_dynamics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -479,7 +479,7 @@ class PARTICLE_PT_hair_dynamics_volume(ParticleButtonsPanel, Panel):
class PARTICLE_PT_cache(ParticleButtonsPanel, Panel):
bl_label = "Cache"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -510,7 +510,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', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -559,7 +559,7 @@ class PARTICLE_PT_velocity(ParticleButtonsPanel, Panel):
class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
bl_label = "Rotation"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -612,7 +612,7 @@ class PARTICLE_PT_rotation_angular_velocity(ParticleButtonsPanel, Panel):
bl_label = "Angular Velocity"
bl_parent_id = "PARTICLE_PT_rotation"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -637,7 +637,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', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -692,7 +692,7 @@ class PARTICLE_PT_physics_fluid_advanced(ParticleButtonsPanel, Panel):
bl_label = "Advanced"
bl_parent_id = "PARTICLE_PT_physics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -740,7 +740,7 @@ class PARTICLE_PT_physics_fluid_springs(ParticleButtonsPanel, Panel):
bl_label = "Springs"
bl_parent_id = "PARTICLE_PT_physics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -767,7 +767,7 @@ class PARTICLE_PT_physics_fluid_springs_viscoelastic(ParticleButtonsPanel, Panel
bl_label = "Viscoelastic Springs"
bl_parent_id = "PARTICLE_PT_physics_fluid_springs"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -806,7 +806,7 @@ class PARTICLE_PT_physics_fluid_springs_advanced(ParticleButtonsPanel, Panel):
bl_label = "Advanced"
bl_parent_id = "PARTICLE_PT_physics_fluid_springs"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -833,7 +833,7 @@ class PARTICLE_PT_physics_boids_movement(ParticleButtonsPanel, Panel):
bl_label = "Movement"
bl_parent_id = "PARTICLE_PT_physics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -879,14 +879,14 @@ class PARTICLE_PT_physics_boids_movement(ParticleButtonsPanel, Panel):
layout.separator()
- layout.prop(part, "collision_group")
+ layout.prop(part, "collision_collection")
class PARTICLE_PT_physics_boids_battle(ParticleButtonsPanel, Panel):
bl_label = "Battle"
bl_parent_id = "PARTICLE_PT_physics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -913,7 +913,7 @@ class PARTICLE_PT_physics_boids_misc(ParticleButtonsPanel, Panel):
bl_label = "Misc"
bl_parent_id = "PARTICLE_PT_physics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -938,7 +938,7 @@ class PARTICLE_PT_physics_relations(ParticleButtonsPanel, Panel):
bl_label = "Relations"
bl_parent_id = "PARTICLE_PT_physics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -998,7 +998,7 @@ class PARTICLE_PT_physics_deflection(ParticleButtonsPanel, Panel):
bl_label = "Deflection"
bl_parent_id = "PARTICLE_PT_physics"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1018,13 +1018,13 @@ class PARTICLE_PT_physics_deflection(ParticleButtonsPanel, Panel):
col.prop(part, "use_size_deflect")
col.prop(part, "use_die_on_collision")
- col.prop(part, "collision_group")
+ col.prop(part, "collision_collection")
class PARTICLE_PT_physics_forces(ParticleButtonsPanel, Panel):
bl_label = "Forces"
bl_parent_id = "PARTICLE_PT_physics"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1051,7 +1051,7 @@ class PARTICLE_PT_physics_integration(ParticleButtonsPanel, Panel):
bl_label = "Integration"
bl_options = {'DEFAULT_CLOSED'}
bl_parent_id = "PARTICLE_PT_physics"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1086,7 +1086,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
bl_options = {'DEFAULT_CLOSED'}
bl_parent_id = "PARTICLE_PT_physics"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1190,7 +1190,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', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1229,14 +1229,14 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
if context.object:
layout.separator()
- layout.prop(context.object, "show_duplicator_for_render", text="Show Emitter")
+ layout.prop(context.object, "show_instancer_for_render", text="Show Emitter")
class PARTICLE_PT_render_extra(ParticleButtonsPanel, Panel):
bl_label = "Extra"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1261,7 +1261,7 @@ class PARTICLE_PT_render_line(ParticleButtonsPanel, Panel):
bl_label = "Line"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1287,7 +1287,7 @@ class PARTICLE_PT_render_path(ParticleButtonsPanel, Panel):
bl_label = "Path"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1320,7 +1320,7 @@ class PARTICLE_PT_render_path_timing(ParticleButtonsPanel, Panel):
bl_label = "Timing"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1351,7 +1351,7 @@ class PARTICLE_PT_render_object(ParticleButtonsPanel, Panel):
bl_label = "Object"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1366,18 +1366,18 @@ class PARTICLE_PT_render_object(ParticleButtonsPanel, Panel):
col = layout.column()
- col.prop(part, "dupli_object", text="Instance Object")
+ col.prop(part, "instance_object", text="Instance Object")
sub = col.column()
- sub.prop(part, "use_global_dupli", text="Global Coordinates")
- sub.prop(part, "use_rotation_dupli", text="Object Rotation")
- sub.prop(part, "use_scale_dupli", text="Object Scale")
+ sub.prop(part, "use_global_instance", text="Global Coordinates")
+ sub.prop(part, "use_rotation_instance", text="Object Rotation")
+ sub.prop(part, "use_scale_instance", text="Object Scale")
class PARTICLE_PT_render_collection(ParticleButtonsPanel, Panel):
bl_label = "Collection"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1392,22 +1392,22 @@ class PARTICLE_PT_render_collection(ParticleButtonsPanel, Panel):
col = layout.column()
- col.prop(part, "dupli_group")
+ col.prop(part, "instance_collection")
- col.prop(part, "use_whole_group")
+ col.prop(part, "use_whole_collection")
sub = col.column()
- sub.active = (part.use_whole_group is False)
- sub.prop(part, "use_group_pick_random")
- sub.prop(part, "use_global_dupli", text="Global Coordinates")
- sub.prop(part, "use_rotation_dupli", text="Object Rotation")
- sub.prop(part, "use_scale_dupli", text="Object Scale")
+ sub.active = (part.use_whole_collection is False)
+ sub.prop(part, "use_collection_pick_random")
+ sub.prop(part, "use_global_instance", text="Global Coordinates")
+ sub.prop(part, "use_rotation_instance", text="Object Rotation")
+ sub.prop(part, "use_scale_instance", text="Object Scale")
class PARTICLE_PT_render_collection_use_count(ParticleButtonsPanel, Panel):
bl_label = "Use Count"
bl_parent_id = "PARTICLE_PT_render_collection"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1418,9 +1418,9 @@ class PARTICLE_PT_render_collection_use_count(ParticleButtonsPanel, Panel):
layout = self.layout
part = particle_get_settings(context)
- layout.active = not part.use_whole_group
+ layout.active = not part.use_whole_collection
- layout.prop(part, "use_group_count", text="")
+ layout.prop(part, "use_collection_count", text="")
def draw(self, context):
layout = self.layout
@@ -1430,11 +1430,11 @@ class PARTICLE_PT_render_collection_use_count(ParticleButtonsPanel, Panel):
col = layout.column()
- layout.active = part.use_group_count and not part.use_whole_group
+ layout.active = part.use_collection_count and not part.use_whole_collection
row = layout.row()
- row.template_list("UI_UL_list", "particle_dupli_weights", part, "dupli_weights",
- part, "active_dupliweight_index")
+ row.template_list("UI_UL_list", "particle_instance_weights", part, "instance_weights",
+ part, "active_instanceweight_index")
col = row.column()
sub = col.row()
@@ -1446,7 +1446,7 @@ class PARTICLE_PT_render_collection_use_count(ParticleButtonsPanel, Panel):
subsub.separator()
subsub.operator("particle.dupliob_refresh", icon='FILE_REFRESH', text="")
- weight = part.active_dupliweight
+ weight = part.active_instanceweight
if weight:
row = layout.row()
row.prop(weight, "count")
@@ -1456,7 +1456,7 @@ class PARTICLE_PT_render_billboards_alignment(ParticleButtonsPanel, Panel):
bl_label = "Billboard Alignment"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1480,7 +1480,7 @@ class PARTICLE_PT_render_billboards_tilt(ParticleButtonsPanel, Panel):
bl_label = "Billboard Tilt"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1512,7 +1512,7 @@ class PARTICLE_PT_render_billboards_uv(ParticleButtonsPanel, Panel):
bl_label = "Billboard UVs"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1548,7 +1548,7 @@ class PARTICLE_PT_render_trails(ParticleButtonsPanel, Panel):
bl_label = "Trails"
bl_parent_id = "PARTICLE_PT_render"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1575,7 +1575,7 @@ class PARTICLE_PT_render_trails(ParticleButtonsPanel, Panel):
class PARTICLE_PT_draw(ParticleButtonsPanel, Panel):
bl_label = "Viewport Display"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1635,13 +1635,13 @@ class PARTICLE_PT_draw(ParticleButtonsPanel, Panel):
if context.object:
layout.separator()
- layout.prop(context.object, "show_duplicator_for_viewport", text="Show Emitter")
+ layout.prop(context.object, "show_instancer_for_viewport", text="Show Emitter")
class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
bl_label = "Children"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1697,7 +1697,7 @@ class PARTICLE_PT_children_parting(ParticleButtonsPanel, Panel):
bl_label = "Parting"
bl_parent_id = "PARTICLE_PT_children"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1721,7 +1721,7 @@ class PARTICLE_PT_children_clumping(ParticleButtonsPanel, Panel):
bl_label = "Clumping"
bl_parent_id = "PARTICLE_PT_children"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1762,7 +1762,7 @@ class PARTICLE_PT_children_roughness(ParticleButtonsPanel, Panel):
bl_label = "Roughness"
bl_parent_id = "PARTICLE_PT_children"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1803,7 +1803,7 @@ class PARTICLE_PT_children_kink(ParticleButtonsPanel, Panel):
bl_label = "Kink"
bl_parent_id = "PARTICLE_PT_children"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1853,7 +1853,7 @@ class PARTICLE_PT_children_kink(ParticleButtonsPanel, Panel):
class PARTICLE_PT_field_weights(ParticleButtonsPanel, Panel):
bl_label = "Field Weights"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -1874,7 +1874,7 @@ class PARTICLE_PT_field_weights(ParticleButtonsPanel, Panel):
class PARTICLE_PT_force_fields(ParticleButtonsPanel, Panel):
bl_label = "Force Field Settings"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -1890,7 +1890,7 @@ class PARTICLE_PT_force_fields(ParticleButtonsPanel, Panel):
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', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -1906,7 +1906,7 @@ class PARTICLE_PT_force_fields_type1(ParticleButtonsPanel, Panel):
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', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -1923,7 +1923,7 @@ 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', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -1938,7 +1938,7 @@ 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', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -1952,7 +1952,7 @@ class PARTICLE_PT_force_fields_type2_falloff(ParticleButtonsPanel, Panel):
class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
bl_label = "Vertex Groups"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -2025,7 +2025,7 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
class PARTICLE_PT_textures(ParticleButtonsPanel, Panel):
bl_label = "Textures"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -2057,7 +2057,7 @@ class PARTICLE_PT_textures(ParticleButtonsPanel, Panel):
class PARTICLE_PT_hair_shape(ParticleButtonsPanel, Panel):
bl_label = "Hair Shape"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -2084,7 +2084,7 @@ class PARTICLE_PT_hair_shape(ParticleButtonsPanel, Panel):
class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "particle_system.settings"
_property_type = bpy.types.ParticleSettings
diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index ab281ef64d6..71731644caf 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -54,7 +54,7 @@ class PhysicButtonsPanel:
class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
bl_label = "Cloth"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header_preset(self, context):
CLOTH_PT_presets.draw_panel_header(self.layout)
@@ -79,7 +79,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
class PHYSICS_PT_cloth_physical_properties(PhysicButtonsPanel, Panel):
bl_label = "Physical Properties"
bl_parent_id = 'PHYSICS_PT_cloth'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -103,7 +103,7 @@ class PHYSICS_PT_cloth_physical_properties(PhysicButtonsPanel, Panel):
class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
bl_label = "Stiffness"
bl_parent_id = 'PHYSICS_PT_cloth_physical_properties'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -134,7 +134,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
class PHYSICS_PT_cloth_damping(PhysicButtonsPanel, Panel):
bl_label = "Damping"
bl_parent_id = 'PHYSICS_PT_cloth_physical_properties'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -166,7 +166,7 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel):
bl_label = "Cache"
bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
md = context.cloth
@@ -177,7 +177,7 @@ class PHYSICS_PT_cloth_shape(PhysicButtonsPanel, Panel):
bl_label = "Shape"
bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -227,7 +227,7 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
bl_label = "Collision"
bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -247,7 +247,7 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
class PHYSICS_PT_cloth_object_collision(PhysicButtonsPanel, Panel):
bl_label = "Object Collision"
bl_parent_id = 'PHYSICS_PT_cloth_collision'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
cloth = context.cloth.collision_settings
@@ -273,13 +273,13 @@ class PHYSICS_PT_cloth_object_collision(PhysicButtonsPanel, Panel):
col.prop(cloth, "impulse_clamp")
col = flow.column()
- col.prop(cloth, "group")
+ col.prop(cloth, "collection")
class PHYSICS_PT_cloth_self_collision(PhysicButtonsPanel, Panel):
bl_label = "Self Collision"
bl_parent_id = 'PHYSICS_PT_cloth_collision'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
cloth = context.cloth.collision_settings
@@ -316,7 +316,7 @@ class PHYSICS_PT_cloth_property_weights(PhysicButtonsPanel, Panel):
bl_label = "Property Weights"
bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -370,7 +370,7 @@ class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel):
bl_label = "Field Weights"
bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
cloth = context.cloth.settings
diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py
index 0f7d7dd5afd..d958b780977 100644
--- a/release/scripts/startup/bl_ui/properties_physics_common.py
+++ b/release/scripts/startup/bl_ui/properties_physics_common.py
@@ -60,7 +60,7 @@ def physics_add_special(self, layout, data, name, addop, removeop, typeicon):
class PHYSICS_PT_add(PhysicButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -243,7 +243,7 @@ def effector_weights_ui(self, context, weights, weight_type):
# NOTE: TODO temporarly used until the animate properties are properly skipped.
layout.use_property_decorate = False # No animation (remove this later on).
- layout.prop(weights, "group")
+ layout.prop(weights, "collection")
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
index 1b06af294b7..1d3866bb142 100644
--- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
@@ -105,7 +105,7 @@ class PhysicButtonsPanel:
class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel):
bl_label = "Dynamic Paint"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -126,7 +126,7 @@ class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dynamic_paint_settings(PhysicButtonsPanel, Panel):
bl_label = "Settings"
bl_parent_id = 'PHYSICS_PT_dynamic_paint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -210,7 +210,7 @@ class PHYSICS_PT_dynamic_paint_settings(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel):
bl_label = "Advanced"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -260,7 +260,7 @@ class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel):
col.separator()
col = flow.column()
- col.prop(surface, "brush_group")
+ col.prop(surface, "brush_collection")
if surface_type not in {'DISPLACE', 'WAVE'}:
col = flow.column() # flow the layout otherwise.
@@ -273,7 +273,7 @@ class PHYSICS_PT_dp_advanced_canvas_paint_dry(PhysicButtonsPanel, Panel):
bl_label = "Dry"
bl_parent_id = "PHYSICS_PT_dp_advanced_canvas"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -309,7 +309,7 @@ class PHYSICS_PT_dp_advanced_canvas_paint_dissolve(PhysicButtonsPanel, Panel):
bl_label = "Dissolve"
bl_parent_id = "PHYSICS_PT_dp_advanced_canvas"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -346,7 +346,7 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
bl_label = "Output"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -422,7 +422,7 @@ class PHYSICS_PT_dp_canvas_output_paintmaps(PhysicButtonsPanel, Panel):
bl_label = "Paintmaps"
bl_parent_id = "PHYSICS_PT_dp_canvas_output"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -452,7 +452,7 @@ class PHYSICS_PT_dp_canvas_output_bake(PhysicButtonsPanel, Panel):
bl_label = "Bake"
bl_parent_id = "PHYSICS_PT_dp_canvas_output"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -479,7 +479,7 @@ class PHYSICS_PT_dp_canvas_output_wetmaps(PhysicButtonsPanel, Panel):
bl_label = "Wetmaps"
bl_parent_id = "PHYSICS_PT_dp_canvas_output"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -509,7 +509,7 @@ class PHYSICS_PT_dp_canvas_initial_color(PhysicButtonsPanel, Panel):
bl_label = "Initial Color"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -549,7 +549,7 @@ class PHYSICS_PT_dp_effects(PhysicButtonsPanel, Panel):
bl_label = "Effects"
bl_parent_id = 'PHYSICS_PT_dynamic_paint'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -566,7 +566,7 @@ class PHYSICS_PT_dp_effects_spread(PhysicButtonsPanel, Panel):
bl_label = "Spread"
bl_parent_id = "PHYSICS_PT_dp_effects"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -601,7 +601,7 @@ class PHYSICS_PT_dp_effects_drip(PhysicButtonsPanel, Panel):
bl_label = "Drip"
bl_parent_id = "PHYSICS_PT_dp_effects"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -637,7 +637,7 @@ class PHYSICS_PT_dp_effects_drip_weights(PhysicButtonsPanel, Panel):
bl_label = "Weights"
bl_parent_id = "PHYSICS_PT_dp_effects_drip"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -661,7 +661,7 @@ class PHYSICS_PT_dp_effects_shrink(PhysicButtonsPanel, Panel):
bl_label = "Shrink"
bl_parent_id = "PHYSICS_PT_dp_effects"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -691,7 +691,7 @@ class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel):
bl_label = "Cache"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -711,7 +711,7 @@ class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, Panel):
bl_label = "Source"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -774,7 +774,7 @@ class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, Panel):
class PHYSICS_PT_dp_brush_source_color_ramp(PhysicButtonsPanel, Panel):
bl_label = "Falloff Ramp"
bl_parent_id = "PHYSICS_PT_dp_brush_source"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -801,7 +801,7 @@ class PHYSICS_PT_dp_brush_velocity(PhysicButtonsPanel, Panel):
bl_label = "Velocity"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -832,7 +832,7 @@ class PHYSICS_PT_dp_brush_velocity_color_ramp(PhysicButtonsPanel, Panel):
bl_label = "Ramp"
bl_parent_id = "PHYSICS_PT_dp_brush_velocity"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -853,7 +853,7 @@ class PHYSICS_PT_dp_brush_velocity_smudge(PhysicButtonsPanel, Panel):
bl_label = "Smudge"
bl_parent_id = "PHYSICS_PT_dp_brush_velocity"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -881,7 +881,7 @@ class PHYSICS_PT_dp_brush_wave(PhysicButtonsPanel, Panel):
bl_label = "Waves"
bl_parent_id = "PHYSICS_PT_dynamic_paint"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py b/release/scripts/startup/bl_ui/properties_physics_field.py
index 394f42190c4..b69a4fcc769 100644
--- a/release/scripts/startup/bl_ui/properties_physics_field.py
+++ b/release/scripts/startup/bl_ui/properties_physics_field.py
@@ -44,7 +44,7 @@ class PhysicButtonsPanel:
class PHYSICS_PT_field(PhysicButtonsPanel, Panel):
bl_label = "Force Fields"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -66,7 +66,7 @@ class PHYSICS_PT_field(PhysicButtonsPanel, Panel):
class PHYSICS_PT_field_settings(PhysicButtonsPanel, Panel):
bl_label = "Settings"
bl_parent_id = 'PHYSICS_PT_field'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -138,7 +138,7 @@ class PHYSICS_PT_field_settings(PhysicButtonsPanel, Panel):
class PHYSICS_PT_field_settings_kink(PhysicButtonsPanel, Panel):
bl_label = "Kink"
bl_parent_id = 'PHYSICS_PT_field_settings'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -172,7 +172,7 @@ class PHYSICS_PT_field_settings_kink(PhysicButtonsPanel, Panel):
class PHYSICS_PT_field_settings_texture_select(PhysicButtonsPanel, Panel):
bl_label = "Texture"
bl_parent_id = 'PHYSICS_PT_field_settings'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -194,7 +194,7 @@ class PHYSICS_PT_field_settings_texture_select(PhysicButtonsPanel, Panel):
class PHYSICS_PT_field_falloff(PhysicButtonsPanel, Panel):
bl_label = "Falloff"
bl_parent_id = "PHYSICS_PT_field"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -219,7 +219,7 @@ class PHYSICS_PT_field_falloff(PhysicButtonsPanel, Panel):
class PHYSICS_PT_field_falloff_angular(PhysicButtonsPanel, Panel):
bl_label = "Angular"
bl_parent_id = "PHYSICS_PT_field_falloff"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -258,7 +258,7 @@ class PHYSICS_PT_field_falloff_angular(PhysicButtonsPanel, Panel):
class PHYSICS_PT_field_falloff_radial(PhysicButtonsPanel, Panel):
bl_label = "Radial"
bl_parent_id = "PHYSICS_PT_field_falloff"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -302,7 +302,7 @@ def collision_warning(layout):
class PHYSICS_PT_collision(PhysicButtonsPanel, Panel):
bl_label = "Collision"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -333,7 +333,7 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, Panel):
class PHYSICS_PT_collision_particle(PhysicButtonsPanel, Panel):
bl_label = "Particle"
bl_parent_id = "PHYSICS_PT_collision"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -379,7 +379,7 @@ class PHYSICS_PT_collision_particle(PhysicButtonsPanel, Panel):
class PHYSICS_PT_collision_softbody(PhysicButtonsPanel, Panel):
bl_label = "Softbody And Cloth"
bl_parent_id = "PHYSICS_PT_collision"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
index 082abb75f58..47be7da4ef0 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
@@ -38,7 +38,7 @@ class PHYSICS_PT_rigidbody_panel:
class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel):
bl_label = "Rigid Body"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -62,7 +62,7 @@ class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel):
class PHYSICS_PT_rigid_body_settings(PHYSICS_PT_rigidbody_panel, Panel):
bl_label = "Settings"
bl_parent_id = 'PHYSICS_PT_rigid_body'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -106,7 +106,7 @@ class PHYSICS_PT_rigid_body_settings(PHYSICS_PT_rigidbody_panel, Panel):
class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
bl_label = "Collisions"
bl_parent_id = 'PHYSICS_PT_rigid_body'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -133,7 +133,7 @@ class PHYSICS_PT_rigid_body_collisions_surface(PHYSICS_PT_rigidbody_panel, Panel
bl_label = "Surface Response"
bl_parent_id = 'PHYSICS_PT_rigid_body_collisions'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -159,7 +159,7 @@ class PHYSICS_PT_rigid_body_collisions_sensitivity(PHYSICS_PT_rigidbody_panel, P
bl_label = "Sensitivity"
bl_parent_id = 'PHYSICS_PT_rigid_body_collisions'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -190,7 +190,7 @@ class PHYSICS_PT_rigid_body_collisions_collections(PHYSICS_PT_rigidbody_panel, P
bl_label = "Collections"
bl_parent_id = 'PHYSICS_PT_rigid_body_collisions'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -203,14 +203,14 @@ class PHYSICS_PT_rigid_body_collisions_collections(PHYSICS_PT_rigidbody_panel, P
ob = context.object
rbo = ob.rigid_body
- layout.prop(rbo, "collision_groups", text="")
+ layout.prop(rbo, "collision_collections", text="")
class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel):
bl_label = "Dynamics"
bl_parent_id = 'PHYSICS_PT_rigid_body'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -241,7 +241,7 @@ class PHYSICS_PT_rigid_body_dynamics_deactivation(PHYSICS_PT_rigidbody_panel, Pa
bl_label = "Deactivation"
bl_parent_id = 'PHYSICS_PT_rigid_body_dynamics'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
index 2c2d92be372..3ddf464390a 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
@@ -32,7 +32,7 @@ class PHYSICS_PT_rigidbody_constraint_panel:
class PHYSICS_PT_rigid_body_constraint(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Rigid Body Constraint"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -52,7 +52,7 @@ class PHYSICS_PT_rigid_body_constraint(PHYSICS_PT_rigidbody_constraint_panel, Pa
class PHYSICS_PT_rigid_body_constraint_settings(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Settings"
bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -83,7 +83,7 @@ class PHYSICS_PT_rigid_body_constraint_settings(PHYSICS_PT_rigidbody_constraint_
class PHYSICS_PT_rigid_body_constraint_objects(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Objects"
bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -104,7 +104,7 @@ class PHYSICS_PT_rigid_body_constraint_objects(PHYSICS_PT_rigidbody_constraint_p
class PHYSICS_PT_rigid_body_constraint_override_iterations(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Override Iterations"
bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -130,7 +130,7 @@ class PHYSICS_PT_rigid_body_constraint_override_iterations(PHYSICS_PT_rigidbody_
class PHYSICS_PT_rigid_body_constraint_limits(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Limits"
bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -147,7 +147,7 @@ class PHYSICS_PT_rigid_body_constraint_limits(PHYSICS_PT_rigidbody_constraint_pa
class PHYSICS_PT_rigid_body_constraint_limits_linear(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Linear"
bl_parent_id = 'PHYSICS_PT_rigid_body_constraint_limits'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -204,7 +204,7 @@ class PHYSICS_PT_rigid_body_constraint_limits_linear(PHYSICS_PT_rigidbody_constr
class PHYSICS_PT_rigid_body_constraint_limits_angular(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Angular"
bl_parent_id = 'PHYSICS_PT_rigid_body_constraint_limits'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -270,7 +270,7 @@ class PHYSICS_PT_rigid_body_constraint_limits_angular(PHYSICS_PT_rigidbody_const
class PHYSICS_PT_rigid_body_constraint_motor(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Motor"
bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -287,7 +287,7 @@ class PHYSICS_PT_rigid_body_constraint_motor(PHYSICS_PT_rigidbody_constraint_pan
class PHYSICS_PT_rigid_body_constraint_motor_angular(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Angular"
bl_parent_id = 'PHYSICS_PT_rigid_body_constraint_motor'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -323,7 +323,7 @@ class PHYSICS_PT_rigid_body_constraint_motor_angular(PHYSICS_PT_rigidbody_constr
class PHYSICS_PT_rigid_body_constraint_motor_linear(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Linear"
bl_parent_id = 'PHYSICS_PT_rigid_body_constraint_motor'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -359,7 +359,7 @@ class PHYSICS_PT_rigid_body_constraint_motor_linear(PHYSICS_PT_rigidbody_constra
class PHYSICS_PT_rigid_body_constraint_springs(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Springs"
bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -383,7 +383,7 @@ class PHYSICS_PT_rigid_body_constraint_springs(PHYSICS_PT_rigidbody_constraint_p
class PHYSICS_PT_rigid_body_constraint_springs_angular(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Angular"
bl_parent_id = 'PHYSICS_PT_rigid_body_constraint_springs'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -431,7 +431,7 @@ class PHYSICS_PT_rigid_body_constraint_springs_angular(PHYSICS_PT_rigidbody_cons
class PHYSICS_PT_rigid_body_constraint_springs_linear(PHYSICS_PT_rigidbody_constraint_panel, Panel):
bl_label = "Linear"
bl_parent_id = 'PHYSICS_PT_rigid_body_constraint_springs'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index 2e698ffb58d..4fd79f26b0b 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -51,7 +51,7 @@ class PhysicButtonsPanel:
class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
bl_label = "Smoke"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -76,7 +76,7 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
class PHYSICS_PT_smoke_settings(PhysicButtonsPanel, Panel):
bl_label = "Settings"
bl_parent_id = 'PHYSICS_PT_smoke'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -162,7 +162,7 @@ class PHYSICS_PT_smoke_settings(PhysicButtonsPanel, Panel):
class PHYSICS_PT_smoke_settings_initial_velocity(PhysicButtonsPanel, Panel):
bl_label = "Initial Velocity"
bl_parent_id = 'PHYSICS_PT_smoke_settings'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -202,7 +202,7 @@ class PHYSICS_PT_smoke_settings_initial_velocity(PhysicButtonsPanel, Panel):
class PHYSICS_PT_smoke_settings_particle_size(PhysicButtonsPanel, Panel):
bl_label = "Particle Size"
bl_parent_id = 'PHYSICS_PT_smoke_settings'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -236,7 +236,7 @@ class PHYSICS_PT_smoke_settings_particle_size(PhysicButtonsPanel, Panel):
class PHYSICS_PT_smoke_behavior(PhysicButtonsPanel, Panel):
bl_label = "Behavior"
bl_parent_id = 'PHYSICS_PT_smoke_settings'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -266,7 +266,7 @@ class PHYSICS_PT_smoke_behavior_dissolve(PhysicButtonsPanel, Panel):
bl_label = "Dissolve"
bl_parent_id = 'PHYSICS_PT_smoke_behavior'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -304,7 +304,7 @@ class PHYSICS_PT_smoke_flow_texture(PhysicButtonsPanel, Panel):
bl_label = "Texture"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -352,7 +352,7 @@ class PHYSICS_PT_smoke_fire(PhysicButtonsPanel, Panel):
bl_label = "Flames"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -391,7 +391,7 @@ class PHYSICS_PT_smoke_adaptive_domain(PhysicButtonsPanel, Panel):
bl_label = "Adaptive Domain"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -429,7 +429,7 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel):
bl_label = "High Resolution"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -471,7 +471,7 @@ class PHYSICS_PT_smoke_collections(PhysicButtonsPanel, Panel):
bl_label = "Collections"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -487,18 +487,18 @@ class PHYSICS_PT_smoke_collections(PhysicButtonsPanel, Panel):
domain = context.smoke.domain_settings
col = layout.column()
- col.prop(domain, "fluid_group", text="Flow")
+ col.prop(domain, "fluid_collection", text="Flow")
# col = layout.column()
- # col.prop(domain, "effector_group", text="Effector")
- col.prop(domain, "collision_group", text="Collision")
+ # col.prop(domain, "effector_collection", text="Effector")
+ col.prop(domain, "collision_collection", text="Collision")
class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel):
bl_label = "Cache"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -543,7 +543,7 @@ class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, Panel):
bl_label = "Field Weights"
bl_parent_id = 'PHYSICS_PT_smoke'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
diff --git a/release/scripts/startup/bl_ui/properties_physics_softbody.py b/release/scripts/startup/bl_ui/properties_physics_softbody.py
index 7f1da6a4acb..12fb2973b4f 100644
--- a/release/scripts/startup/bl_ui/properties_physics_softbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_softbody.py
@@ -47,7 +47,7 @@ class PhysicButtonsPanel:
class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
bl_label = "Soft Body"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -56,14 +56,14 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
md = context.soft_body
softbody = md.settings
- layout.prop(softbody, "collision_group")
+ layout.prop(softbody, "collision_collection")
class PHYSICS_PT_softbody_object(PhysicButtonsPanel, Panel):
bl_label = "Object"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -91,7 +91,7 @@ class PHYSICS_PT_softbody_simulation(PhysicButtonsPanel, Panel):
bl_label = "Simulation"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -109,7 +109,7 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, Panel):
bl_label = "Cache"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
md = context.soft_body
@@ -120,7 +120,7 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel):
bl_label = "Goal"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
softbody = context.soft_body.settings
@@ -145,7 +145,7 @@ class PHYSICS_PT_softbody_goal_strenghts(PhysicButtonsPanel, Panel):
bl_label = "Strengths"
bl_parent_id = 'PHYSICS_PT_softbody_goal'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -171,7 +171,7 @@ class PHYSICS_PT_softbody_goal_settings(PhysicButtonsPanel, Panel):
bl_label = "Settings"
bl_parent_id = 'PHYSICS_PT_softbody_goal'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -194,7 +194,7 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel):
bl_label = "Edges"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
softbody = context.soft_body.settings
@@ -241,7 +241,7 @@ class PHYSICS_PT_softbody_edge_aerodynamics(PhysicButtonsPanel, Panel):
bl_label = "Aerodynamics"
bl_parent_id = 'PHYSICS_PT_softbody_edge'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -264,7 +264,7 @@ class PHYSICS_PT_softbody_edge_stiffness(PhysicButtonsPanel, Panel):
bl_label = "Stiffness"
bl_parent_id = 'PHYSICS_PT_softbody_edge'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
softbody = context.soft_body.settings
@@ -288,7 +288,7 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel):
bl_label = "Self Collision"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
softbody = context.soft_body.settings
@@ -323,7 +323,7 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, Panel):
bl_label = "Solver"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -348,7 +348,7 @@ class PHYSICS_PT_softbody_solver_diagnostics(PhysicButtonsPanel, Panel):
bl_label = "Diagnostics"
bl_parent_id = 'PHYSICS_PT_softbody_solver'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -367,7 +367,7 @@ class PHYSICS_PT_softbody_solver_helpers(PhysicButtonsPanel, Panel):
bl_label = "Helpers"
bl_parent_id = 'PHYSICS_PT_softbody_solver'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -390,7 +390,7 @@ class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, Panel):
bl_label = "Field Weights"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
md = context.soft_body
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 026b306b49e..9f24945573b 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -64,7 +64,7 @@ class RENDER_PT_context(Panel):
class RENDER_PT_color_management(RenderButtonsPanel, Panel):
bl_label = "Color Management"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -97,7 +97,7 @@ class RENDER_PT_color_management_curves(RenderButtonsPanel, Panel):
bl_label = "Use Curves"
bl_parent_id = "RENDER_PT_color_management"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
@@ -529,7 +529,7 @@ class RENDER_PT_eevee_hair(RenderButtonsPanel, Panel):
class RENDER_PT_opengl_film(RenderButtonsPanel, Panel):
bl_label = "Film"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -546,7 +546,7 @@ class RENDER_PT_opengl_film(RenderButtonsPanel, Panel):
class RENDER_PT_opengl_lighting(RenderButtonsPanel, Panel):
bl_label = "Lighting"
- COMPAT_ENGINES = {'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -558,7 +558,7 @@ class RENDER_PT_opengl_lighting(RenderButtonsPanel, Panel):
class RENDER_PT_opengl_color(RenderButtonsPanel, Panel):
bl_label = "Color"
- COMPAT_ENGINES = {'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -570,7 +570,7 @@ class RENDER_PT_opengl_color(RenderButtonsPanel, Panel):
class RENDER_PT_opengl_options(RenderButtonsPanel, Panel):
bl_label = "Options"
- COMPAT_ENGINES = {'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -583,7 +583,7 @@ class RENDER_PT_opengl_options(RenderButtonsPanel, Panel):
class RENDER_PT_simplify(RenderButtonsPanel, Panel):
bl_label = "Simplify"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
rd = context.scene.render
@@ -596,7 +596,7 @@ class RENDER_PT_simplify(RenderButtonsPanel, Panel):
class RENDER_PT_simplify_viewport(RenderButtonsPanel, Panel):
bl_label = "Viewport"
bl_parent_id = "RENDER_PT_simplify"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -618,7 +618,7 @@ class RENDER_PT_simplify_viewport(RenderButtonsPanel, Panel):
class RENDER_PT_simplify_render(RenderButtonsPanel, Panel):
bl_label = "Render"
bl_parent_id = "RENDER_PT_simplify"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -650,6 +650,7 @@ class RENDER_PT_simplify_greasepencil(RenderButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
layout.use_property_split = True
+ layout.use_property_decorate = False
rd = context.scene.render
@@ -659,8 +660,8 @@ class RENDER_PT_simplify_greasepencil(RenderButtonsPanel, Panel):
col.prop(rd, "simplify_gpencil_onplay", text="Playback Only")
col.prop(rd, "simplify_gpencil_view_modifier", text="Modifiers")
col.prop(rd, "simplify_gpencil_shader_fx", text="ShaderFX")
+ col.prop(rd, "simplify_gpencil_blend", text="Layers Blending")
- col = layout.column(align=True)
col.prop(rd, "simplify_gpencil_view_fill")
sub = col.column()
sub.active = rd.simplify_gpencil_view_fill
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index 7602c5eca2e..fdaac18fdab 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -58,7 +58,7 @@ class SceneButtonsPanel:
class SCENE_PT_scene(SceneButtonsPanel, Panel):
bl_label = "Scene"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -75,7 +75,7 @@ class SCENE_PT_scene(SceneButtonsPanel, Panel):
class SCENE_PT_unit(SceneButtonsPanel, Panel):
bl_label = "Units"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -159,7 +159,7 @@ class SceneKeyingSetsPanel:
class SCENE_PT_keying_sets(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
bl_label = "Keying Sets"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -230,7 +230,7 @@ class SCENE_PT_keyframing_settings(SceneButtonsPanel, SceneKeyingSetsPanel, Pane
class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
bl_label = "Active Keying Set"
bl_parent_id = "SCENE_PT_keying_sets"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -293,7 +293,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
class SCENE_PT_audio(SceneButtonsPanel, Panel):
bl_label = "Audio"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -332,7 +332,7 @@ class SCENE_PT_audio(SceneButtonsPanel, Panel):
class SCENE_PT_physics(SceneButtonsPanel, Panel):
bl_label = "Gravity"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
self.layout.prop(context.scene, "use_gravity", text="")
@@ -351,7 +351,7 @@ class SCENE_PT_physics(SceneButtonsPanel, Panel):
class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
bl_label = "Rigid Body World"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -400,7 +400,7 @@ class SCENE_PT_rigid_body_world_settings(SceneButtonsPanel, Panel):
col.active = rbw.enabled
col = col.column()
- col.prop(rbw, "group")
+ col.prop(rbw, "collection")
col.prop(rbw, "constraints")
col = col.column()
@@ -421,7 +421,7 @@ class SCENE_PT_rigid_body_cache(SceneButtonsPanel, Panel):
bl_label = "Cache"
bl_parent_id = "SCENE_PT_rigid_body_world"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -439,7 +439,7 @@ class SCENE_PT_rigid_body_field_weights(SceneButtonsPanel, Panel):
bl_label = "Field Weights"
bl_parent_id = "SCENE_PT_rigid_body_world"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -454,7 +454,7 @@ class SCENE_PT_rigid_body_field_weights(SceneButtonsPanel, Panel):
class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "scene"
_property_type = bpy.types.Scene
diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py
index f1407672e0d..10983d1faaa 100644
--- a/release/scripts/startup/bl_ui/properties_texture.py
+++ b/release/scripts/startup/bl_ui/properties_texture.py
@@ -85,7 +85,7 @@ class TextureButtonsPanel:
class TEXTURE_PT_preview(TextureButtonsPanel, Panel):
bl_label = "Preview"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -114,7 +114,7 @@ class TEXTURE_PT_context(TextureButtonsPanel, Panel):
bl_label = ""
bl_context = "texture"
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -153,7 +153,7 @@ class TEXTURE_PT_context(TextureButtonsPanel, Panel):
class TEXTURE_PT_node(TextureButtonsPanel, Panel):
bl_label = "Node"
bl_context = "texture"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -171,7 +171,7 @@ class TEXTURE_PT_node(TextureButtonsPanel, Panel):
class TEXTURE_PT_node_mapping(TextureButtonsPanel, Panel):
bl_label = "Mapping"
bl_context = "texture"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -224,7 +224,7 @@ class TextureTypePanel(TextureButtonsPanel):
class TEXTURE_PT_clouds(TextureTypePanel, Panel):
bl_label = "Clouds"
tex_type = 'CLOUDS'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -256,7 +256,7 @@ class TEXTURE_PT_clouds(TextureTypePanel, Panel):
class TEXTURE_PT_wood(TextureTypePanel, Panel):
bl_label = "Wood"
tex_type = 'WOOD'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -293,7 +293,7 @@ class TEXTURE_PT_wood(TextureTypePanel, Panel):
class TEXTURE_PT_marble(TextureTypePanel, Panel):
bl_label = "Marble"
tex_type = 'MARBLE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -327,7 +327,7 @@ class TEXTURE_PT_marble(TextureTypePanel, Panel):
class TEXTURE_PT_magic(TextureTypePanel, Panel):
bl_label = "Magic"
tex_type = 'MAGIC'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -346,7 +346,7 @@ class TEXTURE_PT_magic(TextureTypePanel, Panel):
class TEXTURE_PT_blend(TextureTypePanel, Panel):
bl_label = "Blend"
tex_type = 'BLEND'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -368,7 +368,7 @@ class TEXTURE_PT_blend(TextureTypePanel, Panel):
class TEXTURE_PT_stucci(TextureTypePanel, Panel):
bl_label = "Stucci"
tex_type = 'STUCCI'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -399,7 +399,7 @@ class TEXTURE_PT_stucci(TextureTypePanel, Panel):
class TEXTURE_PT_image(TextureTypePanel, Panel):
bl_label = "Image"
tex_type = 'IMAGE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
# TODO: maybe expose the template_ID from the template image here.
@@ -411,7 +411,7 @@ class TEXTURE_PT_image_settings(TextureTypePanel, Panel):
bl_label = "Settings"
bl_parent_id = 'TEXTURE_PT_image'
tex_type = 'IMAGE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -566,7 +566,7 @@ class TEXTURE_PT_image_mapping_crop(TextureTypePanel, Panel):
class TEXTURE_PT_musgrave(TextureTypePanel, Panel):
bl_label = "Musgrave"
tex_type = 'MUSGRAVE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -611,7 +611,7 @@ class TEXTURE_PT_musgrave(TextureTypePanel, Panel):
class TEXTURE_PT_voronoi(TextureTypePanel, Panel):
bl_label = "Voronoi"
tex_type = 'VORONOI'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -644,7 +644,7 @@ class TEXTURE_PT_voronoi_feature_weights(TextureTypePanel, Panel):
bl_label = "Feature Weights"
bl_parent_id = "TEXTURE_PT_voronoi"
tex_type = 'VORONOI'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -665,7 +665,7 @@ class TEXTURE_PT_voronoi_feature_weights(TextureTypePanel, Panel):
class TEXTURE_PT_distortednoise(TextureTypePanel, Panel):
bl_label = "Distorted Noise"
tex_type = 'DISTORTED_NOISE'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -690,7 +690,7 @@ class TEXTURE_PT_distortednoise(TextureTypePanel, Panel):
class TextureSlotPanel(TextureButtonsPanel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -702,7 +702,7 @@ class TextureSlotPanel(TextureButtonsPanel):
class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
bl_label = "Mapping"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -773,7 +773,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
class TEXTURE_PT_influence(TextureSlotPanel, Panel):
bl_label = "Influence"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -860,7 +860,7 @@ class TextureColorsPoll:
class TEXTURE_PT_colors(TextureButtonsPanel, TextureColorsPoll, Panel):
bl_label = "Colors"
bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
@@ -889,7 +889,7 @@ class TEXTURE_PT_colors_ramp(TextureButtonsPanel, TextureColorsPoll, Panel):
bl_label = "Color Ramp"
bl_options = {'DEFAULT_CLOSED'}
bl_parent_id = 'TEXTURE_PT_colors'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw_header(self, context):
tex = context.texture
@@ -911,7 +911,7 @@ class TEXTURE_PT_colors_ramp(TextureButtonsPanel, TextureColorsPoll, Panel):
class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "texture"
_property_type = Texture
diff --git a/release/scripts/startup/bl_ui/properties_view_layer.py b/release/scripts/startup/bl_ui/properties_view_layer.py
index b9e6b5ded43..0dea2d04d47 100644
--- a/release/scripts/startup/bl_ui/properties_view_layer.py
+++ b/release/scripts/startup/bl_ui/properties_view_layer.py
@@ -34,7 +34,7 @@ class ViewLayerButtonsPanel:
class VIEWLAYER_PT_layer(ViewLayerButtonsPanel, Panel):
bl_label = "View Layer"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py
index 7395fa13d9a..fc1e718ea1e 100644
--- a/release/scripts/startup/bl_ui/properties_world.py
+++ b/release/scripts/startup/bl_ui/properties_world.py
@@ -37,7 +37,7 @@ class WorldButtonsPanel:
class WORLD_PT_context_world(WorldButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
@@ -83,7 +83,7 @@ class EEVEE_WORLD_PT_mist(WorldButtonsPanel, Panel):
class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "world"
_property_type = bpy.types.World
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index 5870d344a7d..1ef4cf64680 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -964,7 +964,6 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel):
bl_region_type = 'UI'
bl_label = "2D Stabilization"
bl_category = "Stabilization"
- bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
@@ -1177,7 +1176,6 @@ class CLIP_PT_footage(CLIP_PT_clip_view_panel, Panel):
bl_region_type = 'UI'
bl_category = "Footage"
bl_label = "Footage Settings"
- bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
@@ -1219,8 +1217,8 @@ class CLIP_PT_tools_scenesetup(Panel):
class CLIP_PT_grease_pencil(AnnotationDataPanel, CLIP_PT_clip_view_panel, Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
- bl_category = "Track"
- bl_options = {'DEFAULT_CLOSED'}
+ bl_category = "Annotation"
+ bl_options = set()
# NOTE: this is just a wrapper around the generic GP Panel
# But, this should only be visible in "clip" view
@@ -1551,15 +1549,15 @@ classes = (
CLIP_PT_tracking_camera,
CLIP_PT_tracking_lens,
CLIP_PT_marker,
- CLIP_PT_stabilization,
CLIP_PT_proxy,
+ CLIP_PT_footage,
+ CLIP_PT_stabilization,
CLIP_PT_mask,
CLIP_PT_mask_layers,
CLIP_PT_mask_display,
CLIP_PT_active_mask_spline,
CLIP_PT_active_mask_point,
CLIP_PT_tools_mask_transforms,
- CLIP_PT_footage,
CLIP_PT_tools_scenesetup,
CLIP_PT_grease_pencil,
CLIP_PT_tools_grease_pencil_draw,
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index 5ef42dcd129..b57a0b69539 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -352,6 +352,12 @@ class DOPESHEET_MT_view(Menu):
layout.operator("action.view_selected")
layout.operator("action.view_frame")
+ # Add this to show key-binding (reverse action in dope-sheet).
+ layout.separator()
+ props = layout.operator("wm.context_set_enum", text="Toggle Graph Editor")
+ props.data_path = "area.type"
+ props.value = 'GRAPH_EDITOR'
+
layout.separator()
layout.menu("INFO_MT_area")
diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py
index d668bb7ec25..ea418f37d47 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -148,6 +148,12 @@ class GRAPH_MT_view(Menu):
layout.operator("graph.view_selected")
layout.operator("graph.view_frame")
+ # Add this to show key-binding (reverse action in dope-sheet).
+ layout.separator()
+ props = layout.operator("wm.context_set_enum", text="Toggle Dope Sheet")
+ props.data_path = "area.type"
+ props.value = 'DOPESHEET_EDITOR'
+
layout.separator()
layout.menu("INFO_MT_area")
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 836e15ef07b..d2bd2e11842 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -523,7 +523,8 @@ class IMAGE_HT_header(Header):
row = layout.row(align=True)
row.template_header()
- layout.prop(sima, "mode", text="")
+ if sima.mode != 'UV':
+ layout.prop(sima, "ui_mode", text="")
# UV editing.
if show_uvedit:
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index 789fc1b0a31..1674940b77f 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -27,6 +27,10 @@ from .properties_grease_pencil_common import (
AnnotationDataPanel,
GreasePencilToolsPanel,
)
+from .properties_material import (
+ EEVEE_MATERIAL_PT_settings,
+ MATERIAL_PT_viewport
+)
class NODE_HT_header(Header):
@@ -220,7 +224,7 @@ class NODE_MT_view(Menu):
layout.operator("node.backimage_move", text="Backdrop Move")
layout.operator("node.backimage_zoom", text="Backdrop Zoom In").factor = 1.2
- layout.operator("node.backimage_zoom", text="Backdrop Zoom Out").factor = 0.83333
+ layout.operator("node.backimage_zoom", text="Backdrop Zoom Out").factor = 1.0 / 1.2
layout.operator("node.backimage_fit", text="Fit Backdrop to Available Space")
layout.separator()
@@ -302,7 +306,6 @@ class NODE_MT_node(Menu):
layout.separator()
layout.operator("node.read_viewlayers")
- layout.operator("node.read_fullsamplelayers")
class NODE_PT_node_color_presets(PresetMenu):
@@ -553,16 +556,39 @@ class NODE_PT_grease_pencil_tools(GreasePencilToolsPanel, Panel):
# toolbar, but which may not necessarily be open
-# Tool Shelf ------------------
+class EEVEE_NODE_PT_material_settings(Panel):
+ bl_space_type = 'NODE_EDITOR'
+ bl_region_type = 'UI'
+ bl_category = "Node"
+ bl_label = "Settings"
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
+ @classmethod
+ def poll(cls, context):
+ snode = context.space_data
+ return (context.engine in cls.COMPAT_ENGINES) and \
+ snode.tree_type == 'ShaderNodeTree' and snode.id
+
+ def draw(self, context):
+ material = context.space_data.id
+ EEVEE_MATERIAL_PT_settings.draw_shared(self, material)
-# Grease Pencil drawing tools
-class NODE_PT_tools_grease_pencil_draw(AnnotationDrawingToolsPanel, Panel):
+
+class NODE_PT_material_viewport(Panel):
bl_space_type = 'NODE_EDITOR'
- bl_region_type = 'TOOLS'
+ bl_region_type = 'UI'
+ bl_category = "Node"
+ bl_label = "Viewport Display"
+ bl_options = {'DEFAULT_CLOSED'}
+ @classmethod
+ def poll(cls, context):
+ snode = context.space_data
+ return snode.tree_type == 'ShaderNodeTree' and snode.id
-# -----------------------------
+ def draw(self, context):
+ material = context.space_data.id
+ MATERIAL_PT_viewport.draw_shared(self, material)
def node_draw_tree_view(layout, context):
@@ -587,7 +613,8 @@ classes = (
NODE_UL_interface_sockets,
NODE_PT_grease_pencil,
NODE_PT_grease_pencil_tools,
- NODE_PT_tools_grease_pencil_draw,
+ EEVEE_NODE_PT_material_settings,
+ NODE_PT_material_viewport,
)
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 46b0e26cda2..199b1f98fa9 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -22,6 +22,7 @@ from bpy.types import Header, Menu, Panel
from rna_prop_ui import PropertyPanel
from .properties_grease_pencil_common import (
AnnotationDataPanel,
+ AnnotationOnionSkin,
GreasePencilToolsPanel,
)
from bpy.app.translations import pgettext_iface as iface_
@@ -1335,6 +1336,16 @@ class SEQUENCER_PT_grease_pencil(AnnotationDataPanel, SequencerButtonsPanel_Outp
# But, it should only show up when there are images in the preview region
+class SEQUENCER_PT_annotation_onion(AnnotationOnionSkin, SequencerButtonsPanel_Output, Panel):
+ bl_space_type = 'SEQUENCE_EDITOR'
+ bl_region_type = 'UI'
+ bl_category = "Strip"
+ bl_parent_id = 'SEQUENCER_PT_grease_pencil'
+
+ # NOTE: this is just a wrapper around the generic GP Panel
+ # But, it should only show up when there are images in the preview region
+
+
class SEQUENCER_PT_grease_pencil_tools(GreasePencilToolsPanel, SequencerButtonsPanel_Output, Panel):
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
@@ -1346,7 +1357,7 @@ class SEQUENCER_PT_grease_pencil_tools(GreasePencilToolsPanel, SequencerButtonsP
class SEQUENCER_PT_custom_props(SequencerButtonsPanel, PropertyPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
_context_path = "scene.sequence_editor.active_strip"
_property_type = (bpy.types.Sequence,)
bl_category = "Strip"
@@ -1381,6 +1392,7 @@ classes = (
SEQUENCER_PT_view_safe_areas,
SEQUENCER_PT_modifiers,
SEQUENCER_PT_grease_pencil,
+ SEQUENCER_PT_annotation_onion,
SEQUENCER_PT_grease_pencil_tools,
SEQUENCER_PT_custom_props,
)
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index 2ff5c9692ec..a52b9d07c2a 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -64,7 +64,8 @@ ToolDef = namedtuple(
(
# The name to display in the interface.
"text",
- # Description (for tooltip), when not set, use the description of 'operator'.
+ # Description (for tooltip), when not set, use the description of 'operator',
+ # may be a string or a 'function(context, item, keymap) -> string'.
"description",
# The name of the icon to use (found in ``release/datafiles/icons``) or None for no icon.
"icon",
@@ -293,6 +294,12 @@ class ToolSelectPanelHelper:
if tool is not None:
tool.refresh_from_context()
return tool
+ elif space_type == 'NODE_EDITOR':
+ space_data = context.space_data
+ tool = context.workspace.tools.from_space_node(create=create)
+ if tool is not None:
+ tool.refresh_from_context()
+ return tool
return None
@staticmethod
@@ -679,17 +686,17 @@ def description_from_name(context, space_type, text, *, use_operator=True):
# Custom description.
description = item.description
if description is not None:
+ if callable(description):
+ km = _keymap_from_item(context, item)
+ return description(context, item, km)
return description
# Extract from the operator.
if use_operator:
operator = item.operator
-
if operator is None:
if item.keymap is not None:
- wm = context.window_manager
- keyconf = wm.keyconfigs.active
- km = keyconf.keymaps.get(item.keymap[0])
+ km = _keymap_from_item(context, item)
if km is not None:
for kmi in km.keymap_items:
if kmi.active:
@@ -715,6 +722,14 @@ def keymap_from_name(context, space_type, text):
return ""
+def _keymap_from_item(context, item):
+ if item.keymap is not None:
+ wm = context.window_manager
+ keyconf = wm.keyconfigs.active
+ return keyconf.keymaps.get(item.keymap[0])
+ return None
+
+
classes = (
WM_MT_toolsystem_submenu,
)
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 53b6a7d0956..5c930b68dd9 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -31,13 +31,6 @@ from .space_toolsystem_common import (
ToolSelectPanelHelper,
ToolDef,
)
-from .properties_material_gpencil import (
- GPENCIL_UL_matslots,
-)
-from .properties_grease_pencil_common import (
- AnnotationDataPanel,
-)
-
def generate_from_enum_ex(
context, *,
@@ -99,115 +92,110 @@ class _defs_view3d_generic:
@ToolDef.from_fn
def ruler():
- return dict(
- text="Measure",
- description=(
+ def description(context, item, km):
+ return (
"Measure distance and angles.\n"
- "\u2022 Drag anywhere for new measurement.\n"
+ "\u2022 {} anywhere for new measurement.\n"
"\u2022 Drag ruler segment to measure an angle.\n"
"\u2022 Drag ruler outside the view to remove.\n"
"\u2022 Ctrl to snap.\n"
"\u2022 Shift to measure surface thickness"
- ),
+ ).format(
+ km.keymap_items[0].to_string()
+ )
+ return dict(
+ text="Measure",
+ description=description,
icon="ops.view3d.ruler",
widget="VIEW3D_GGT_ruler",
keymap=(),
)
-def _defs_annotate_factory():
+class _defs_annotate:
- class _defs_annotate:
+ def draw_settings_common(context, layout, tool):
+ if type(context.gpencil_data_owner) is bpy.types.Object:
+ gpd = context.scene.grease_pencil
+ else:
+ gpd = context.gpencil_data
- def draw_settings_common(context, layout, tool):
- if type(context.gpencil_data_owner) is bpy.types.Object:
- gpd = context.scene.grease_pencil
+ if gpd is not None:
+ if gpd.layers.active_note is not None:
+ text = gpd.layers.active_note
+ maxw = 25
+ if len(text) > maxw:
+ text = text[:maxw - 5] + '..' + text[-3:]
else:
- gpd = context.gpencil_data
-
- if gpd is not None:
- if gpd.layers.active_note is not None:
- text = gpd.layers.active_note
- maxw = 25
- if len(text) > maxw:
- text = text[:maxw - 5] + '..' + text[-3:]
- else:
- text = ""
-
- layout.label(text="Annotation:")
- gpl = context.active_gpencil_layer
- if gpl is not None:
- sub = layout.row(align=True)
- sub.ui_units_x = 8
-
- sub.prop(gpl, "color", text="")
- sub.popover(
- panel="TOPBAR_PT_annotation_layers",
- text=text,
- )
-
- tool_settings = context.tool_settings
- space_type = tool.space_type
- if space_type == 'VIEW_3D':
- layout.separator()
-
- row = layout.row(align=True)
- row.prop(tool_settings, "annotation_stroke_placement_view3d", text="Placement")
- if tool_settings.gpencil_stroke_placement_view3d == 'CURSOR':
- row.prop(tool_settings.gpencil_sculpt, "lockaxis")
- elif tool_settings.gpencil_stroke_placement_view3d in {'SURFACE', 'STROKE'}:
- row.prop(tool_settings, "use_gpencil_stroke_endpoints")
-
- @ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
- def scribble(*, draw_settings):
- return dict(
- text="Annotate",
- icon="ops.gpencil.draw",
- cursor='PAINT_BRUSH',
- keymap=(),
- draw_settings=draw_settings,
- )
+ text = ""
+
+ layout.label(text="Annotation:")
+ gpl = context.active_gpencil_layer
+ if gpl is not None:
+ sub = layout.row(align=True)
+ sub.ui_units_x = 8
+
+ sub.prop(gpl, "color", text="")
+ sub.popover(
+ panel="TOPBAR_PT_annotation_layers",
+ text=text,
+ )
- @ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
- def line(*, draw_settings):
- return dict(
- text="Annotate Line",
- icon="ops.gpencil.draw.line",
- cursor='CROSSHAIR',
- keymap=(),
- draw_settings=draw_settings,
- )
+ tool_settings = context.tool_settings
+ space_type = tool.space_type
+ if space_type == 'VIEW_3D':
+ layout.separator()
- @ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
- def poly(*, draw_settings):
- return dict(
- text="Annotate Polygon",
- icon="ops.gpencil.draw.poly",
- cursor='CROSSHAIR',
- keymap=(),
- draw_settings=draw_settings,
- )
+ row = layout.row(align=True)
+ row.prop(tool_settings, "annotation_stroke_placement_view3d", text="Placement")
+ if tool_settings.gpencil_stroke_placement_view3d == 'CURSOR':
+ row.prop(tool_settings.gpencil_sculpt, "lockaxis")
+ elif tool_settings.gpencil_stroke_placement_view3d in {'SURFACE', 'STROKE'}:
+ row.prop(tool_settings, "use_gpencil_stroke_endpoints")
- @ToolDef.from_fn
- def eraser():
- def draw_settings(context, layout, tool):
- # TODO: Move this setting to tool_settings
- user_prefs = context.user_preferences
- layout.prop(user_prefs.edit, "grease_pencil_eraser_radius", text="Radius")
- return dict(
- text="Annotate Eraser",
- icon="ops.gpencil.draw.eraser",
- cursor='CROSSHAIR', # XXX: Always show brush circle when enabled
- keymap=(),
- draw_settings=draw_settings,
- )
+ @ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
+ def scribble(*, draw_settings):
+ return dict(
+ text="Annotate",
+ icon="ops.gpencil.draw",
+ cursor='PAINT_BRUSH',
+ keymap="Generic Tool: Annotate",
+ draw_settings=draw_settings,
+ )
- return _defs_annotate
+ @ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
+ def line(*, draw_settings):
+ return dict(
+ text="Annotate Line",
+ icon="ops.gpencil.draw.line",
+ cursor='CROSSHAIR',
+ keymap="Generic Tool: Annotate Line",
+ draw_settings=draw_settings,
+ )
+ @ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
+ def poly(*, draw_settings):
+ return dict(
+ text="Annotate Polygon",
+ icon="ops.gpencil.draw.poly",
+ cursor='CROSSHAIR',
+ keymap="Generic Tool: Annotate Polygon",
+ draw_settings=draw_settings,
+ )
-# Needed so annotation gets a keymap per space type.
-_defs_annotate_image = _defs_annotate_factory()
-_defs_annotate_view3d = _defs_annotate_factory()
+ @ToolDef.from_fn
+ def eraser():
+ def draw_settings(context, layout, tool):
+ # TODO: Move this setting to tool_settings
+ user_prefs = context.user_preferences
+ layout.prop(user_prefs.edit, "grease_pencil_eraser_radius", text="Radius")
+ return dict(
+ text="Annotate Eraser",
+ icon="ops.gpencil.draw.eraser",
+ cursor='CROSSHAIR', # XXX: Always show brush circle when enabled
+ keymap="Generic Tool: Annotate Eraser",
+ draw_settings=draw_settings,
+ )
class _defs_transform:
@@ -279,7 +267,19 @@ class _defs_transform:
class _defs_view3d_select:
@ToolDef.from_fn
- def border():
+ def select():
+ def draw_settings(context, layout, tool):
+ pass
+ return dict(
+ text="Select",
+ icon="ops.generic.select",
+ widget=None,
+ keymap=(),
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def box():
def draw_settings(context, layout, tool):
props = tool.operator_properties("view3d.select_box")
layout.prop(props, "mode", expand=True)
@@ -960,7 +960,19 @@ class _defs_image_uv_transform:
class _defs_image_uv_select:
@ToolDef.from_fn
- def border():
+ def select():
+ def draw_settings(context, layout, tool):
+ pass
+ return dict(
+ text="Select",
+ icon="ops.generic.select",
+ widget=None,
+ keymap=(),
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def box():
def draw_settings(context, layout, tool):
props = tool.operator_properties("uv.select_box")
layout.prop(props, "mode", expand=True)
@@ -1055,6 +1067,15 @@ class _defs_gpencil_paint:
keymap=(),
)
+ @ToolDef.from_fn
+ def arc():
+ return dict(
+ text="Arc",
+ icon="ops.gpencil.primitive_arc",
+ cursor='CROSSHAIR',
+ widget=None,
+ keymap=(),
+ )
class _defs_gpencil_edit:
@ToolDef.from_fn
@@ -1067,6 +1088,18 @@ class _defs_gpencil_edit:
)
@ToolDef.from_fn
+ def select():
+ def draw_settings(context, layout, tool):
+ pass
+ return dict(
+ text="Select",
+ icon="ops.generic.select",
+ widget=None,
+ keymap=(),
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
def box_select():
def draw_settings(context, layout, tool):
props = tool.operator_properties("gpencil.select_box")
@@ -1144,46 +1177,59 @@ class _defs_gpencil_weight:
)
-class TOPBAR_PT_gpencil_materials(Panel):
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'HEADER'
- bl_label = "Materials"
- bl_ui_units_x = 14
-
- @classmethod
- def poll(cls, context):
- ob = context.object
- return ob and ob.type == 'GPENCIL'
-
- @staticmethod
- def draw(self, context):
- layout = self.layout
- ob = context.object
-
- if ob:
- is_sortable = len(ob.material_slots) > 1
- rows = 1
- if (is_sortable):
- rows = 10
+class _defs_node_select:
- row = layout.row()
-
- row.template_list("GPENCIL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
+ @ToolDef.from_fn
+ def select():
+ def draw_settings(context, layout, tool):
+ pass
+ return dict(
+ text="Select",
+ icon="ops.generic.select",
+ widget=None,
+ keymap="Node Tool: Select",
+ draw_settings=draw_settings,
+ )
- col = row.column(align=True)
- col.menu("GPENCIL_MT_color_specials", icon='DOWNARROW_HLT', text="")
+ @ToolDef.from_fn
+ def box():
+ def draw_settings(context, layout, tool):
+ props = tool.operator_properties("node.select_box")
+ layout.prop(props, "deselect")
+ pass
+ return dict(
+ text="Select Box",
+ icon="ops.generic.select_box",
+ widget=None,
+ keymap="Node Tool: Select Box",
+ draw_settings=draw_settings,
+ )
- if is_sortable:
- col.separator()
+ @ToolDef.from_fn
+ def lasso():
+ def draw_settings(context, layout, tool):
+ props = tool.operator_properties("node.select_lasso")
+ layout.prop(props, "deselect")
+ pass
+ return dict(
+ text="Select Lasso",
+ icon="ops.generic.select_lasso",
+ widget=None,
+ keymap="Node Tool: Select Lasso",
+ draw_settings=draw_settings,
+ )
- col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
- col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
- col.separator()
+class _defs_node_edit:
- sub = col.column(align=True)
- sub.operator("gpencil.color_isolate", icon='LOCKED', text="").affect_visibility = False
- sub.operator("gpencil.color_isolate", icon='HIDE_OFF', text="").affect_visibility = True
+ @ToolDef.from_fn
+ def links_cut():
+ return dict(
+ text="Links Cut",
+ icon="ops.mesh.knife_tool",
+ widget=None,
+ keymap="Node Tool: Links Cut",
+ )
class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
@@ -1220,7 +1266,8 @@ class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
_tools_select = (
(
- _defs_image_uv_select.border,
+ _defs_image_uv_select.select,
+ _defs_image_uv_select.box,
_defs_image_uv_select.circle,
_defs_image_uv_select.lasso,
),
@@ -1228,10 +1275,10 @@ class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
_tools_annotate = (
(
- _defs_annotate_image.scribble,
- _defs_annotate_image.line,
- _defs_annotate_image.poly,
- _defs_annotate_image.eraser,
+ _defs_annotate.scribble,
+ _defs_annotate.line,
+ _defs_annotate.poly,
+ _defs_annotate.eraser,
),
)
@@ -1264,6 +1311,61 @@ class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
}
+class NODE_PT_tools_active(ToolSelectPanelHelper, Panel):
+ bl_space_type = 'NODE_EDITOR'
+ bl_region_type = 'TOOLS'
+ bl_label = "Tools" # not visible
+ bl_options = {'HIDE_HEADER'}
+
+ # Satisfy the 'ToolSelectPanelHelper' API.
+ keymap_prefix = "Node Editor Tool:"
+
+ @classmethod
+ def tools_from_context(cls, context, mode=None):
+ if mode is None:
+ if context.space_data is None:
+ mode = None
+ else:
+ mode = context.space_data.tree_type
+ for tools in (cls._tools[None], cls._tools.get(mode, ())):
+ for item in tools:
+ if not (type(item) is ToolDef) and callable(item):
+ yield from item(context)
+ else:
+ yield item
+
+ @classmethod
+ def tools_all(cls):
+ yield from cls._tools.items()
+
+ _tools_select = (
+ (
+ _defs_node_select.select,
+ _defs_node_select.box,
+ _defs_node_select.lasso,
+ ),
+ )
+
+ _tools_annotate = (
+ (
+ _defs_annotate.scribble,
+ _defs_annotate.line,
+ _defs_annotate.poly,
+ _defs_annotate.eraser,
+ ),
+ )
+
+ _tools = {
+ None: [
+ *_tools_select,
+ None,
+ *_tools_annotate,
+ None,
+ _defs_node_edit.links_cut,
+ ],
+ }
+
+
class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
@@ -1301,7 +1403,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
_tools_select = (
(
- _defs_view3d_select.border,
+ _defs_view3d_select.select,
+ _defs_view3d_select.box,
_defs_view3d_select.circle,
_defs_view3d_select.lasso,
),
@@ -1309,22 +1412,32 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
_tools_annotate = (
(
- _defs_annotate_view3d.scribble,
- _defs_annotate_view3d.line,
- _defs_annotate_view3d.poly,
- _defs_annotate_view3d.eraser,
+ _defs_annotate.scribble,
+ _defs_annotate.line,
+ _defs_annotate.poly,
+ _defs_annotate.eraser,
),
_defs_view3d_generic.ruler,
)
_tools_gpencil_select = (
(
+ _defs_gpencil_edit.select,
_defs_gpencil_edit.box_select,
_defs_gpencil_edit.circle_select,
_defs_gpencil_edit.lasso_select,
),
)
+ _tools_default = (
+ *_tools_select,
+ _defs_view3d_generic.cursor,
+ None,
+ *_tools_transform,
+ None,
+ *_tools_annotate,
+ )
+
_tools = {
None: [
# Don't use this! because of paint modes.
@@ -1332,20 +1445,10 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
# End group.
],
'OBJECT': [
- *_tools_select,
- _defs_view3d_generic.cursor,
- None,
- *_tools_transform,
- None,
- *_tools_annotate,
+ *_tools_default,
],
'POSE': [
- *_tools_select,
- _defs_view3d_generic.cursor,
- None,
- *_tools_transform,
- None,
- *_tools_annotate,
+ *_tools_default,
None,
(
_defs_pose.breakdown,
@@ -1354,12 +1457,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
),
],
'EDIT_ARMATURE': [
- *_tools_select,
- _defs_view3d_generic.cursor,
+ *_tools_default,
None,
- *_tools_transform,
- None,
- *_tools_annotate,
_defs_edit_armature.roll,
(
_defs_edit_armature.bone_size,
@@ -1372,12 +1471,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
),
],
'EDIT_MESH': [
- *_tools_select,
- _defs_view3d_generic.cursor,
- None,
- *_tools_transform,
- None,
- *_tools_annotate,
+ *_tools_default,
None,
_defs_edit_mesh.cube_add,
None,
@@ -1424,12 +1518,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
),
],
'EDIT_CURVE': [
- *_tools_select,
- _defs_view3d_generic.cursor,
- None,
- *_tools_transform,
- None,
- *_tools_annotate,
+ *_tools_default,
None,
_defs_edit_curve.tilt,
_defs_edit_curve.draw,
@@ -1438,23 +1527,14 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
_defs_edit_curve.extrude_cursor,
),
],
+ 'EDIT_SURFACE': [
+ *_tools_default,
+ ],
'EDIT_METABALL': [
- *_tools_select,
- _defs_view3d_generic.cursor,
- None,
- *_tools_transform,
- None,
- *_tools_annotate,
- None,
+ *_tools_default,
],
'EDIT_LATTICE': [
- *_tools_select,
- _defs_view3d_generic.cursor,
- None,
- *_tools_transform,
- None,
- *_tools_annotate,
- None,
+ *_tools_default,
],
'PARTICLE': [
_defs_view3d_generic.cursor,
@@ -1502,6 +1582,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
_defs_gpencil_paint.line,
_defs_gpencil_paint.box,
_defs_gpencil_paint.circle,
+ _defs_gpencil_paint.arc,
],
'GPENCIL_EDIT': [
*_tools_gpencil_select,
@@ -1524,18 +1605,10 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
}
-class TOPBAR_PT_annotation_layers(Panel, AnnotationDataPanel):
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'HEADER'
- bl_label = "Layers"
- bl_ui_units_x = 14
-
-
classes = (
IMAGE_PT_tools_active,
+ NODE_PT_tools_active,
VIEW3D_PT_tools_active,
- TOPBAR_PT_gpencil_materials,
- TOPBAR_PT_annotation_layers,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 8b9c47839e9..a74683d2849 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -301,7 +301,7 @@ class _draw_left_context_mode:
return
is_paint = True
- if (tool.name in {"Line", "Box", "Circle"}):
+ if (tool.name in {"Line", "Box", "Circle", "Arc"}):
is_paint = False
elif (not tool.has_datablock):
return
@@ -384,7 +384,11 @@ class _draw_left_context_mode:
tool = settings.sculpt_tool
brush = settings.brush
- layout.prop(brush, "size", slider=True)
+ row = layout.row(align=True)
+ row.prop(brush, "size", slider=True)
+ sub = row.row(align=True)
+ sub.enabled = tool not in {'GRAB', 'CLONE'}
+ sub.prop(brush, "use_pressure_radius", text="")
row = layout.row(align=True)
row.prop(brush, "strength", slider=True)
@@ -516,6 +520,16 @@ class TOPBAR_PT_gpencil_layers(Panel):
col.template_list("GPENCIL_UL_layer", "", gpd, "layers", gpd.layers, "active_index",
rows=layer_rows, reverse=True)
+ gpl = context.active_gpencil_layer
+ if gpl:
+ srow = col.row(align=True)
+ srow.prop(gpl, "blend_mode", text="Blend")
+
+ srow = col.row(align=True)
+ srow.prop(gpl, "opacity", text="Opacity", slider=True)
+ srow.prop(gpl, "clamp_layer", text="",
+ icon='MOD_MASK' if gpl.clamp_layer else 'ONIONSKIN_OFF')
+
col = row.column()
sub = col.column(align=True)
@@ -539,10 +553,6 @@ class TOPBAR_PT_gpencil_layers(Panel):
sub.operator("gpencil.layer_isolate", icon='LOCKED', text="").affect_visibility = False
sub.operator("gpencil.layer_isolate", icon='HIDE_OFF', text="").affect_visibility = True
- row = layout.row(align=True)
- if gpl:
- row.prop(gpl, "opacity", text="Opacity", slider=True)
-
class TOPBAR_MT_editor_menus(Menu):
bl_idname = "TOPBAR_MT_editor_menus"
@@ -828,7 +838,7 @@ class TOPBAR_MT_edit(Menu):
layout.separator()
- layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES')
+ layout.operator("screen.userpref_show", text="Preferences...", icon='PREFERENCES')
class TOPBAR_MT_window(Menu):
@@ -981,7 +991,7 @@ class TOPBAR_MT_window_specials(Menu):
layout.separator()
- layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES')
+ layout.operator("screen.userpref_show", text="Preferences...", icon='PREFERENCES')
class TOPBAR_MT_workspace_menu(Menu):
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 954326f8899..76bb14b4b73 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -33,8 +33,7 @@ class USERPREF_HT_header(Header):
def draw(self, context):
layout = self.layout
- # No need to show type selector.
- # layout.template_header()
+ layout.template_header()
userpref = context.user_preferences
@@ -46,9 +45,11 @@ 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="Add MatCap").orientation = 'MATCAP'
- layout.operator('wm.studiolight_install', text="Add World HDRI").orientation = 'WORLD'
- layout.operator('wm.studiolight_install', text="Add Camera HDRI").orientation = 'CAMERA'
+ layout.operator('wm.studiolight_install', text="Add MatCap").type = 'MATCAP'
+ layout.operator('wm.studiolight_install', text="Add LookDev HDRI").type = 'WORLD'
+ op = layout.operator('wm.studiolight_install', text="Add Studio Light")
+ op.type = 'STUDIO'
+ op.filter_glob = ".sl"
elif userpref.active_section == 'THEMES':
layout.operator("wm.theme_install", icon='FILEBROWSER')
layout.operator("ui.reset_default_theme", icon='LOOP_BACK')
@@ -59,10 +60,10 @@ class USERPREF_HT_header(Header):
layout.operator("wm.save_userpref")
-class USERPREF_PT_tabs(Panel):
+class USERPREF_PT_navigation(Panel):
bl_label = ""
bl_space_type = 'USER_PREFERENCES'
- bl_region_type = 'WINDOW'
+ bl_region_type = 'NAVIGATION_BAR'
bl_options = {'HIDE_HEADER'}
def draw(self, context):
@@ -70,7 +71,11 @@ class USERPREF_PT_tabs(Panel):
userpref = context.user_preferences
- layout.row().prop(userpref, "active_section", expand=True)
+ col = layout.column()
+
+ col.scale_x = 1.3
+ col.scale_y = 1.3
+ col.prop(userpref, "active_section", expand=True)
class USERPREF_PT_interface(Panel):
@@ -199,7 +204,6 @@ class USERPREF_PT_interface(Panel):
col.label(text="App Template:")
col.label(text="Options intended for use with app-templates only.")
col.prop(view, "show_layout_ui")
- col.prop(view, "show_view3d_cursor")
class USERPREF_PT_edit(Panel):
@@ -331,16 +335,16 @@ class USERPREF_PT_edit(Panel):
col.prop(edit, "use_duplicate_particle", text="Particle")
-class USERPREF_PT_system(Panel):
+class USERPREF_PT_system_general(Panel):
bl_space_type = 'USER_PREFERENCES'
- bl_label = "System"
+ bl_label = "System General"
bl_region_type = 'WINDOW'
bl_options = {'HIDE_HEADER'}
@classmethod
def poll(cls, context):
userpref = context.user_preferences
- return (userpref.active_section == 'SYSTEM')
+ return (userpref.active_section == 'SYSTEM_GENERAL')
def draw(self, context):
import sys
@@ -380,9 +384,10 @@ class USERPREF_PT_system(Panel):
addon.preferences.draw_impl(col, context)
del addon
- if hasattr(system, "opensubdiv_compute_type"):
- col.label(text="OpenSubdiv compute:")
- col.row().prop(system, "opensubdiv_compute_type", text="")
+ # NOTE: Disabled for until GPU side of OpenSubdiv is brought back.
+ # if hasattr(system, "opensubdiv_compute_type"):
+ # col.label(text="OpenSubdiv compute:")
+ # col.row().prop(system, "opensubdiv_compute_type", text="")
# 2. Column
column = split.column()
@@ -749,6 +754,8 @@ class USERPREF_PT_theme(Panel):
colsub.row().prop(ui_state, "inner_key_sel")
colsub.row().prop(ui_state, "inner_overridden")
colsub.row().prop(ui_state, "inner_overridden_sel")
+ colsub.row().prop(ui_state, "inner_changed")
+ colsub.row().prop(ui_state, "inner_changed_sel")
col.separator()
col.separator()
@@ -880,7 +887,7 @@ class USERPREF_PT_file(Panel):
@classmethod
def poll(cls, context):
userpref = context.user_preferences
- return (userpref.active_section == 'FILES')
+ return (userpref.active_section == 'SYSTEM_FILES')
def draw(self, context):
layout = self.layout
@@ -1489,12 +1496,16 @@ class StudioLightPanelMixin():
return (userpref.active_section == 'LIGHTS')
def _get_lights(self, userpref):
- return [light for light in userpref.studio_lights if light.is_user_defined and light.orientation == self.sl_orientation]
+ return [light for light in userpref.studio_lights if light.is_user_defined and light.type == self.sl_type]
def draw(self, context):
layout = self.layout
userpref = context.user_preferences
lights = self._get_lights(userpref)
+
+ self.draw_light_list(layout, lights)
+
+ def draw_light_list(self, layout, lights):
if lights:
flow = layout.column_flow(columns=4)
for studio_light in lights:
@@ -1507,57 +1518,65 @@ class StudioLightPanelMixin():
row = box.row()
row.template_icon(layout.icon(studio_light), scale=6.0)
- op = row.operator('wm.studiolight_uninstall', text="", icon='REMOVE')
+ col = row.column()
+ op = col.operator('wm.studiolight_uninstall', text="", icon='REMOVE')
op.index = studio_light.index
+ if studio_light.type == 'STUDIO':
+ op = col.operator('wm.studiolight_copy_settings', text="", icon='IMPORT')
+ op.index = studio_light.index
+
box.label(text=studio_light.name)
class USERPREF_PT_studiolight_matcaps(Panel, StudioLightPanelMixin):
bl_label = "MatCaps"
- sl_orientation = 'MATCAP'
+ sl_type = 'MATCAP'
class USERPREF_PT_studiolight_world(Panel, StudioLightPanelMixin):
- bl_label = "World HDRI"
- sl_orientation = 'WORLD'
-
-
-class USERPREF_PT_studiolight_camera(Panel, StudioLightPanelMixin):
- bl_label = "Camera HDRI"
- sl_orientation = 'CAMERA'
+ bl_label = "LookDev HDRIs"
+ sl_type = 'WORLD'
-class USERPREF_PT_studiolight_specular(Panel, StudioLightPanelMixin):
- bl_label = "Specular Lights"
- sl_orientation = 'CAMERA'
+class USERPREF_PT_studiolight_lights(Panel, StudioLightPanelMixin):
+ bl_label = "Studio Lights"
+ sl_type = 'STUDIO'
- @classmethod
- def poll(cls, context):
- userpref = context.user_preferences
- return (userpref.active_section == 'LIGHTS')
- def opengl_light_buttons(self, column, light):
- split = column.split()
-
- col = split.column()
- col.prop(light, "use", text="Use", icon='OUTLINER_OB_LIGHT' if light.use else 'LIGHT_DATA')
+class USERPREF_PT_studiolight_light_editor(Panel):
+ bl_label = "Studio Light Editor"
+ bl_parent_id = "USERPREF_PT_studiolight_lights"
+ bl_space_type = 'USER_PREFERENCES'
+ bl_region_type = 'WINDOW'
- sub = col.column()
- sub.active = light.use
- sub.prop(light, "specular_color")
+ def opengl_light_buttons(self, layout, light):
- col = split.column()
+ col = layout.column()
col.active = light.use
- col.prop(light, "direction", text="")
+
+ col.prop(light, "use", text="Use Light")
+ col.prop(light, "diffuse_color", text="Diffuse")
+ col.prop(light, "specular_color", text="Specular")
+ col.prop(light, "smooth")
+ col.prop(light, "direction")
def draw(self, context):
layout = self.layout
- column = layout.split()
userpref = context.user_preferences
system = userpref.system
+ row = layout.row()
+ row.prop(system, "edit_studio_light", toggle=True)
+ row.operator('wm.studiolight_new', text="Save as Studio light", icon="FILE_TICK")
+
+ layout.separator()
+
+ layout.use_property_split = True
+ column = layout.split()
+ column.active = system.edit_studio_light
+
light = system.solid_lights[0]
colsplit = column.split(factor=0.85)
self.opengl_light_buttons(colsplit, light)
@@ -1567,15 +1586,23 @@ class USERPREF_PT_studiolight_specular(Panel, StudioLightPanelMixin):
self.opengl_light_buttons(colsplit, light)
light = system.solid_lights[2]
+ colsplit = column.split(factor=0.85)
+ self.opengl_light_buttons(colsplit, light)
+
+ light = system.solid_lights[3]
self.opengl_light_buttons(column, light)
+ layout.separator()
+
+ layout.prop(system, "light_ambient")
+
classes = (
USERPREF_HT_header,
- USERPREF_PT_tabs,
+ USERPREF_PT_navigation,
USERPREF_PT_interface,
USERPREF_PT_edit,
- USERPREF_PT_system,
+ USERPREF_PT_system_general,
USERPREF_MT_interface_theme_presets,
USERPREF_PT_theme,
USERPREF_PT_file,
@@ -1584,10 +1611,10 @@ classes = (
USERPREF_PT_input,
USERPREF_MT_addons_online_resources,
USERPREF_PT_addons,
+ USERPREF_PT_studiolight_lights,
+ USERPREF_PT_studiolight_light_editor,
USERPREF_PT_studiolight_matcaps,
USERPREF_PT_studiolight_world,
- USERPREF_PT_studiolight_camera,
- USERPREF_PT_studiolight_specular,
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 8b4028386ff..4fc247cc8f5 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -18,9 +18,19 @@
# <pep8 compliant>
import bpy
-from bpy.types import Header, Menu, Panel
-from .properties_paint_common import UnifiedPaintPanel
-from .properties_grease_pencil_common import AnnotationDataPanel
+from bpy.types import (
+ Header,
+ Menu,
+ Panel,
+)
+from .properties_paint_common import (
+ UnifiedPaintPanel,
+)
+from .properties_grease_pencil_common import (
+ AnnotationDataPanel,
+ AnnotationOnionSkin,
+ GreasePencilMaterialsPanel,
+)
from bpy.app.translations import contexts as i18n_contexts
@@ -176,16 +186,7 @@ class VIEW3D_HT_header(Header):
# Proportional editing
if obj:
gpd = context.gpencil_data
- if gpd is not None and obj.type == 'GPENCIL':
- if gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode:
- row = layout.row(align=True)
- row.prop(tool_settings, "proportional_edit", icon_only=True)
-
- sub = row.row(align=True)
- sub.active = tool_settings.proportional_edit != 'DISABLED'
- sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
-
- elif object_mode in {'EDIT', 'PARTICLE_EDIT'}:
+ if object_mode in {'EDIT', 'PARTICLE_EDIT'}:
row = layout.row(align=True)
row.prop(tool_settings, "proportional_edit", icon_only=True)
sub = row.row(align=True)
@@ -198,6 +199,15 @@ class VIEW3D_HT_header(Header):
sub = row.row(align=True)
sub.active = tool_settings.use_proportional_edit_objects
sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
+
+ elif gpd is not None and obj.type == 'GPENCIL':
+ if gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode:
+ row = layout.row(align=True)
+ row.prop(tool_settings, "proportional_edit", icon_only=True)
+
+ sub = row.row(align=True)
+ sub.active = tool_settings.proportional_edit != 'DISABLED'
+ sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
else:
if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
row = layout.row(align=True)
@@ -340,6 +350,9 @@ class VIEW3D_MT_editor_menus(Menu):
layout.menu("VIEW3D_MT_edit_mesh_edges")
layout.menu("VIEW3D_MT_edit_mesh_faces")
layout.menu("VIEW3D_MT_uv_map", text="UV")
+ elif mode_string in {'EDIT_CURVE', 'EDIT_SURFACE'}:
+ layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
+ layout.menu("VIEW3D_MT_edit_curve_segments")
elif obj:
if mode_string != 'PAINT_TEXTURE':
@@ -438,22 +451,6 @@ class VIEW3D_MT_transform_object(VIEW3D_MT_transform_base):
"""
-class VIEW3D_MT_transform_origin(Menu):
- bl_label = "Origin"
-
- def draw(self, context):
-
- layout = self.layout
-
- layout.operator_context = 'EXEC_AREA'
-
- layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
- layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
- layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
- layout.operator("object.origin_set", text="Origin to Center of Mass (Surface)").type = 'ORIGIN_CENTER_OF_MASS'
- layout.operator("object.origin_set", text="Origin to Center of Mass (Volume)").type = 'ORIGIN_CENTER_OF_VOLUME'
-
-
# Armature EditMode extensions to Transform menu
class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base):
def draw(self, context):
@@ -609,6 +606,7 @@ class VIEW3D_MT_view(Menu):
layout.operator("view3d.view_all", text="Frame All").center = False
layout.operator("view3d.view_persportho", text="Perspective/Orthographic")
+ layout.menu("VIEW3D_MT_view_local")
layout.separator()
@@ -638,6 +636,17 @@ class VIEW3D_MT_view(Menu):
layout.menu("INFO_MT_area")
+class VIEW3D_MT_view_local(Menu):
+ bl_label = "Local View"
+
+ def draw(self, context):
+ layout = self.layout
+ view = context.space_data
+
+ layout.operator("view3d.localview", text="Toggle Local View")
+ layout.operator("view3d.localview_remove_from")
+
+
class VIEW3D_MT_view_cameras(Menu):
bl_label = "Cameras"
@@ -1403,10 +1412,6 @@ class VIEW3D_MT_curve_add(Menu):
layout.operator("curve.primitive_nurbs_circle_add", text="Nurbs Circle", icon='CURVE_NCIRCLE')
layout.operator("curve.primitive_nurbs_path_add", text="Path", icon='CURVE_PATH')
- layout.separator()
-
- layout.operator("curve.draw", icon='LINE_DATA')
-
class VIEW3D_MT_surface_add(Menu):
bl_idname = "VIEW3D_MT_surface_add"
@@ -1612,7 +1617,7 @@ class VIEW3D_MT_object(Menu):
layout = self.layout
layout.menu("VIEW3D_MT_transform_object")
- layout.menu("VIEW3D_MT_transform_origin")
+ layout.operator_menu_enum("object.origin_set", text="Set Origin...", property="type")
layout.menu("VIEW3D_MT_mirror")
layout.menu("VIEW3D_MT_object_clear")
layout.menu("VIEW3D_MT_object_apply")
@@ -1735,18 +1740,22 @@ class VIEW3D_MT_object_specials(Menu):
def draw(self, context):
layout = self.layout
+ view = context.space_data
obj = context.object
is_eevee = context.scene.render.engine == 'BLENDER_EEVEE'
if obj.type == 'MESH':
- layout.operator("object.shade_smooth", text="Smooth Shading")
- layout.operator("object.shade_flat", text="Flat Shading")
+ layout.operator("object.shade_smooth", text="Shade Smooth")
+ layout.operator("object.shade_flat", text="Shade Flat")
layout.separator()
- layout.operator("object.origin_set")
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.operator_menu_enum("object.origin_set", text="Set Origin...", property="type")
+
+ layout.operator_context = 'INVOKE_DEFAULT'
layout.operator("object.join")
layout.operator_menu_enum("object.convert", "target")
@@ -1771,7 +1780,6 @@ class VIEW3D_MT_object_specials(Menu):
props.header_text = "Camera Lens Scale: %.3f"
if not obj.data.dof_object:
- view = context.space_data
if view and view.camera == obj and view.region_3d.view_perspective == 'CAMERA':
props = layout.operator("ui.eyedropper_depth", text="DOF Distance (Pick)")
else:
@@ -1780,7 +1788,6 @@ class VIEW3D_MT_object_specials(Menu):
props.data_path_item = "data.dof_distance"
props.input_scale = 0.02
props.header_text = "DOF Distance: %.3f"
- del view
if obj.type in {'CURVE', 'FONT'}:
layout.operator_context = 'INVOKE_REGION_WIN'
@@ -1883,7 +1890,11 @@ class VIEW3D_MT_object_specials(Menu):
layout.menu("VIEW3D_MT_snap")
layout.menu("VIEW3D_MT_object_parent")
layout.operator_context = 'INVOKE_REGION_WIN'
- layout.operator("object.move_to_collection")
+
+ if view and view.local_view:
+ layout.operator("view3d.localview_remove_from")
+ else:
+ layout.operator("object.move_to_collection")
layout.separator()
@@ -2743,6 +2754,7 @@ class VIEW3D_MT_edit_mesh(Menu):
layout.menu("VIEW3D_MT_edit_mesh_extrude")
layout.operator("mesh.split")
layout.operator("mesh.bisect")
+ layout.operator("mesh.knife_project")
if with_bullet:
layout.operator("mesh.convex_hull")
@@ -3276,7 +3288,6 @@ def draw_curve(self, context):
layout.separator()
- layout.operator("curve.extrude_move")
layout.operator("curve.spin")
layout.operator("curve.duplicate_move")
@@ -3284,13 +3295,8 @@ def draw_curve(self, context):
layout.operator("curve.split")
layout.operator("curve.separate")
- layout.operator("curve.make_segment")
layout.operator("curve.cyclic_toggle")
-
- layout.separator()
-
- layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
- layout.menu("VIEW3D_MT_edit_curve_segments")
+ layout.operator_menu_enum("curve.spline_type_set", "type")
layout.separator()
@@ -3313,14 +3319,31 @@ class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
edit_object = context.edit_object
- if edit_object.type == 'CURVE':
- layout.operator("transform.tilt")
- layout.operator("curve.tilt_clear")
+ if edit_object.type in {'CURVE', 'SURFACE'}:
+ layout.operator("curve.extrude_move")
+
+ layout.separator()
+
+ layout.operator("curve.make_segment")
layout.separator()
- layout.operator_menu_enum("curve.handle_type_set", "type")
- layout.operator("curve.normals_make_consistent")
+ if edit_object.type == 'CURVE':
+ layout.operator("transform.tilt")
+ layout.operator("curve.tilt_clear")
+
+ layout.separator()
+
+ layout.operator_menu_enum("curve.handle_type_set", "type")
+ layout.operator("curve.normals_make_consistent")
+
+ layout.separator()
+
+ layout.operator("curve.smooth")
+ if edit_object.type == 'CURVE':
+ layout.operator("curve.smooth_weight")
+ layout.operator("curve.smooth_radius")
+ layout.operator("curve.smooth_tilt")
layout.separator()
@@ -3354,6 +3377,7 @@ class VIEW3D_MT_edit_curve_specials(Menu):
bl_label = "Curve Context Menu"
def draw(self, context):
+ # TODO(campbell): match mesh vertex menu.
layout = self.layout
layout.operator("curve.subdivide")
@@ -3865,21 +3889,33 @@ class VIEW3D_MT_shading_ex_pie(Menu):
view = context.space_data
pie.prop_enum(view.shading, "type", value='WIREFRAME')
+ pie.prop_enum(view.shading, "type", value='SOLID')
- xray_active = (
- (context.mode in {'POSE', 'EDIT_MESH'}) or
- (view.shading.type in {'SOLID', 'WIREFRAME'})
- )
- if xray_active:
- sub = pie
+ # Note this duplicates 'view3d.toggle_xray' logic, so we can see the active item: T58661.
+ if (
+ (context.mode == 'POSE') or
+ ((context.mode == 'WEIGHT_PAINT') and (context.active_object.find_armature()))
+ ):
+ pie.prop(view.overlay, "show_xray_bone", icon='XRAY')
else:
- sub = pie.row()
- sub.active = False
- sub.operator("view3d.toggle_xray", text="Toggle X-Ray", icon='XRAY')
+ xray_active = (
+ (context.mode == 'EDIT_MESH') or
+ (view.shading.type in {'SOLID', 'WIREFRAME'})
+ )
+ if xray_active:
+ sub = pie
+ else:
+ sub = pie.row()
+ sub.active = False
+ sub.prop(
+ view.shading,
+ "show_xray_wireframe" if (view.shading.type == 'WIREFRAME') else "show_xray",
+ text="Toggle X-Ray",
+ icon='XRAY',
+ )
pie.prop(view.overlay, "show_overlays", text="Toggle Overlays", icon='OVERLAY')
- pie.prop_enum(view.shading, "type", value='SOLID')
pie.prop_enum(view.shading, "type", value='MATERIAL')
pie.prop_enum(view.shading, "type", value='RENDERED')
@@ -3899,7 +3935,7 @@ class VIEW3D_MT_pivot_pie(Menu):
pie.prop_enum(context.scene.tool_settings, "transform_pivot_point", value='MEDIAN_POINT')
pie.prop_enum(context.scene.tool_settings, "transform_pivot_point", value='ACTIVE_ELEMENT')
if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}):
- pie.prop(context.scene.tool_settings, "use_transform_pivot_point_align", text="Center Points Only")
+ pie.prop(context.scene.tool_settings, "use_transform_pivot_point_align", text="Only Origins")
class VIEW3D_MT_orientations_pie(Menu):
@@ -4027,9 +4063,9 @@ class VIEW3D_PT_view3d_cursor(Panel):
layout = self.layout
layout.use_property_split = True
- view = context.space_data
+ scene = context.scene
- layout.column().prop(view, "cursor_location", text="Location")
+ layout.column().prop(scene, "cursor_location", text="Location")
class VIEW3D_PT_collections(Panel):
@@ -4198,18 +4234,33 @@ class VIEW3D_PT_shading_lighting(Panel):
split = layout.split(factor=0.9)
col = split.column()
sub = col.row()
- sub.scale_y = 0.6 # smaller matcap/hdri preview
if shading.light == 'STUDIO':
- sub.template_icon_view(shading, "studio_light", scale=3)
+ userpref = context.user_preferences
+ system = userpref.system
- if shading.selected_studio_light.orientation == 'WORLD':
- col.prop(shading, "studiolight_rotate_z", text="Rotation")
+ if not system.edit_studio_light:
+ sub.scale_y = 0.6 # smaller studiolight preview
+ sub.template_icon_view(shading, "studio_light", scale=3)
+ else:
+ sub.prop(system, "edit_studio_light", text="Disable Studio Light Edit", icon="NONE", toggle=True)
col = split.column()
col.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES')
+ split = layout.split(factor=0.9)
+ col = split.column()
+
+ row = col.row()
+ row.prop(shading, "use_world_space_lighting", text="", icon="WORLD", toggle=True)
+ row = row.row()
+ row.active = shading.use_world_space_lighting
+ row.prop(shading, "studiolight_rotate_z", text="Rotation")
+ col = split.column() # to align properly with above
+
elif shading.light == 'MATCAP':
+ sub.scale_y = 0.6 # smaller matcap preview
+
sub.template_icon_view(shading, "studio_light", scale=3)
col = split.column()
@@ -4232,7 +4283,7 @@ class VIEW3D_PT_shading_lighting(Panel):
col = split.column()
col.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='PREFERENCES')
- if shading.selected_studio_light.orientation == 'WORLD':
+ if shading.selected_studio_light.type == 'WORLD':
split = layout.split(factor=0.9)
col = split.column()
col.prop(shading, "studiolight_rotate_z", text="Rotation")
@@ -4324,16 +4375,25 @@ class VIEW3D_PT_shading_options(Panel):
row.active = not shading.show_xray
row.prop(shading, "show_cavity")
- if shading.show_cavity:
- sub = col.row(align=True)
- sub.active = not shading.show_xray and shading.show_cavity
- sub.prop(shading, "cavity_ridge_factor")
- sub.prop(shading, "cavity_valley_factor")
- sub.popover(
- panel="VIEW3D_PT_shading_options_ssao",
- icon='PREFERENCES',
- text=""
- )
+ if shading.show_cavity and not shading.show_xray:
+ row.prop(shading, "cavity_type", text="Type")
+
+ if shading.cavity_type in {'WORLD', 'BOTH'}:
+ col.label(text="World Space")
+ sub = col.row(align=True)
+ sub.prop(shading, "cavity_ridge_factor", text="Ridge")
+ sub.prop(shading, "cavity_valley_factor", text="Valley")
+ sub.popover(
+ panel="VIEW3D_PT_shading_options_ssao",
+ icon='PREFERENCES',
+ text=""
+ )
+
+ if shading.cavity_type in {'SCREEN', 'BOTH'}:
+ col.label(text="Screen Space")
+ sub = col.row(align=True)
+ sub.prop(shading, "curvature_ridge_factor", text="Ridge")
+ sub.prop(shading, "curvature_valley_factor", text="Valley")
row = layout.split()
row.prop(shading, "show_object_outline")
@@ -4342,8 +4402,8 @@ class VIEW3D_PT_shading_options(Panel):
sub.prop(shading, "object_outline_color", text="")
col = layout.column()
- if (shading.light is not 'MATCAP') and (shading.type is not 'WIREFRAME'):
- col.prop(shading, "show_specular_highlight")
+ if (shading.light == 'STUDIO') and (shading.type is not 'WIREFRAME'):
+ col.prop(shading, "show_specular_highlight", text="Specular Lighting")
class VIEW3D_PT_shading_options_shadow(Panel):
@@ -4363,6 +4423,7 @@ class VIEW3D_PT_shading_options_shadow(Panel):
col = layout.column()
col.prop(scene.display, "light_direction")
col.prop(scene.display, "shadow_shift")
+ col.prop(scene.display, "shadow_focus")
class VIEW3D_PT_shading_options_ssao(Panel):
@@ -4958,7 +5019,7 @@ class VIEW3D_PT_pivot_point(Panel):
col.prop(
toolsettings,
"use_transform_pivot_point_align",
- text="Center Points Only",
+ text="Only Origins",
)
@@ -5157,6 +5218,22 @@ class VIEW3D_PT_grease_pencil(AnnotationDataPanel, Panel):
# NOTE: this is just a wrapper around the generic GP Panel
+class VIEW3D_PT_annotation_onion(AnnotationOnionSkin, Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'UI'
+ bl_category = "View"
+ bl_parent_id = 'VIEW3D_PT_grease_pencil'
+
+ # NOTE: this is just a wrapper around the generic GP Panel
+
+
+class TOPBAR_PT_annotation_layers(Panel, AnnotationDataPanel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "Layers"
+ bl_ui_units_x = 14
+
+
class VIEW3D_PT_view3d_stereo(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
@@ -5325,19 +5402,26 @@ class VIEW3D_MT_gpencil_sculpt_specials(Menu):
layout.menu("VIEW3D_MT_gpencil_autoweights")
+class TOPBAR_PT_gpencil_materials(GreasePencilMaterialsPanel, Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "Materials"
+ bl_ui_units_x = 14
+
+
classes = (
VIEW3D_HT_header,
VIEW3D_MT_editor_menus,
VIEW3D_MT_transform,
VIEW3D_MT_transform_base,
VIEW3D_MT_transform_object,
- VIEW3D_MT_transform_origin,
VIEW3D_MT_transform_armature,
VIEW3D_MT_mirror,
VIEW3D_MT_snap,
VIEW3D_MT_uv_map,
VIEW3D_MT_edit_proportional,
VIEW3D_MT_view,
+ VIEW3D_MT_view_local,
VIEW3D_MT_view_cameras,
VIEW3D_MT_view_navigation,
VIEW3D_MT_view_align,
@@ -5375,6 +5459,7 @@ classes = (
VIEW3D_MT_lightprobe_add,
VIEW3D_MT_camera_add,
VIEW3D_MT_add,
+ VIEW3D_MT_image_add,
VIEW3D_MT_object,
VIEW3D_MT_object_animation,
VIEW3D_MT_object_rigid_body,
@@ -5475,6 +5560,7 @@ classes = (
VIEW3D_PT_collections,
VIEW3D_PT_object_type_visibility,
VIEW3D_PT_grease_pencil,
+ VIEW3D_PT_annotation_onion,
VIEW3D_PT_gpencil_multi_frame,
VIEW3D_MT_gpencil_autoweights,
VIEW3D_MT_gpencil_edit_specials,
@@ -5511,7 +5597,8 @@ classes = (
VIEW3D_PT_transform_orientations,
VIEW3D_PT_overlay_gpencil_options,
VIEW3D_PT_context_properties,
- VIEW3D_MT_image_add,
+ TOPBAR_PT_gpencil_materials,
+ TOPBAR_PT_annotation_layers,
)
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 2fb056cdfb7..3f6518e80a6 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -637,7 +637,7 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
sub = row.row(align=True)
sub.prop(brush, "cursor_overlay_alpha", text="Curve Alpha")
sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
- row.prop(brush,"use_cursor_overlay", text="", toggle=True, icon='HIDE_ON' if brush.use_cursor_overlay else 'HIDE_OFF')
+ row.prop(brush,"use_cursor_overlay", text="", toggle=True, icon='HIDE_OFF' if brush.use_cursor_overlay else 'HIDE_ON')
col.active = brush.brush_capabilities.has_overlay
@@ -648,7 +648,7 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
sub.prop(brush, "texture_overlay_alpha", text="Texture Alpha")
sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
if tex_slot.map_mode != 'STENCIL':
- row.prop(brush, "use_primary_overlay", text="", toggle=True, icon='HIDE_ON' if brush.use_primary_overlay else 'HIDE_OFF')
+ row.prop(brush, "use_primary_overlay", text="", toggle=True, icon='HIDE_OFF' if brush.use_primary_overlay else 'HIDE_ON')
if context.image_paint_object:
row = col.row(align=True)
@@ -657,7 +657,7 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
sub.prop(brush, "mask_overlay_alpha", text="Mask Texture Alpha")
sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
if tex_slot_mask.map_mode != 'STENCIL':
- row.prop(brush, "use_secondary_overlay", text="", toggle=True, icon='HIDE_ON' if brush.use_secondary_overlay else 'HIDE_OFF')
+ row.prop(brush, "use_secondary_overlay", text="", toggle=True, icon='HIDE_OFF' if brush.use_secondary_overlay else 'HIDE_ON')
# TODO, move to space_view3d.py
diff --git a/release/scripts/templates_py/gizmo_operator.py b/release/scripts/templates_py/gizmo_operator.py
index 524dd1dd20e..96f4f4de940 100644
--- a/release/scripts/templates_py/gizmo_operator.py
+++ b/release/scripts/templates_py/gizmo_operator.py
@@ -68,7 +68,7 @@ class SelectSideOfPlane(Operator):
if context.space_data.type == 'VIEW_3D':
wm = context.window_manager
- wm.gizmo_group_type_add(SelectSideOfPlaneGizmoGroup.bl_idname)
+ wm.gizmo_group_type_ensure(SelectSideOfPlaneGizmoGroup.bl_idname)
return {'FINISHED'}
@@ -106,7 +106,7 @@ class SelectSideOfPlaneGizmoGroup(GizmoGroup):
op = cls.my_target_operator(context)
if op is None:
wm = context.window_manager
- wm.gizmo_group_type_remove(SelectSideOfPlaneGizmoGroup.bl_idname)
+ wm.gizmo_group_type_unlink_delayed(SelectSideOfPlaneGizmoGroup.bl_idname)
return False
return True
diff --git a/release/scripts/templates_py/operator_modal_view3d_raycast.py b/release/scripts/templates_py/operator_modal_view3d_raycast.py
index 4b9700dd3fe..e5467228dfa 100644
--- a/release/scripts/templates_py/operator_modal_view3d_raycast.py
+++ b/release/scripts/templates_py/operator_modal_view3d_raycast.py
@@ -23,7 +23,7 @@ def main(context, event):
if obj.type == 'MESH':
yield (obj, obj.matrix_world.copy())
- if obj.dupli_type != 'NONE':
+ if obj.instance_type != 'NONE':
obj.dupli_list_create(scene)
for dob in obj.dupli_list:
obj_dupli = dob.object
diff --git a/release/scripts/templates_py/ui_tool_simple.py b/release/scripts/templates_py/ui_tool_simple.py
deleted file mode 100644
index d9aeb294c68..00000000000
--- a/release/scripts/templates_py/ui_tool_simple.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# This example adds an object mode tool to the toolbar.
-# This is just the circle-select tool.
-import bpy
-from bpy.utils.toolsystem import ToolDef
-
-@ToolDef.from_fn
-def my_tool():
- def draw_settings(context, layout, tool):
- props = tool.operator_properties("view3d.select_circle")
- layout.prop(props, "radius")
- return dict(
- text="My Circle Select",
- description=(
- "This is a tooltip\n"
- "with multiple lines"
- ),
- icon="ops.generic.select_circle",
- widget=None,
- keymap=(
- ("view3d.select_circle", dict(deselect=False), dict(type='LEFTMOUSE', value='PRESS')),
- ("view3d.select_circle", dict(deselect=True), dict(type='LEFTMOUSE', value='PRESS', ctrl=True)),
- ),
- draw_settings=draw_settings,
- )
-
-
-def register():
- bpy.utils.register_tool('VIEW_3D', 'OBJECT', my_tool)
-
-
-def unregister():
- bpy.utils.unregister_tool('VIEW_3D', 'OBJECT', my_tool)
-
-if __name__ == "__main__":
- register()
diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc
index 424475dc61b..96685b6ac3a 100644
--- a/source/blender/alembic/intern/abc_customdata.cc
+++ b/source/blender/alembic/intern/abc_customdata.cc
@@ -52,29 +52,6 @@ using Alembic::Abc::V2fArraySample;
using Alembic::AbcGeom::OV2fGeomParam;
using Alembic::AbcGeom::OC4fGeomParam;
-
-typedef std::unordered_map<uint64_t, int> uv_index_map;
-
-static inline uint64_t uv_to_hash_key(Imath::V2f v)
-{
- /* Convert -0.0f to 0.0f, so bitwise comparison works. */
- if (v.x == 0.0f) {
- v.x = 0.0f;
- }
- if (v.y == 0.0f) {
- v.y = 0.0f;
- }
-
- /* Pack floats in 64bit. */
- union {
- float xy[2];
- uint64_t key;
- } tmp;
- tmp.xy[0] = v.x;
- tmp.xy[1] = v.y;
- return tmp.key;
-}
-
static void get_uvs(const CDStreamConfig &config,
std::vector<Imath::V2f> &uvs,
std::vector<uint32_t> &uvidx,
@@ -88,45 +65,59 @@ static void get_uvs(const CDStreamConfig &config,
const int num_poly = config.totpoly;
MPoly *polygons = config.mpoly;
+ MLoop *mloop = config.mloop;
if (!config.pack_uvs) {
int cnt = 0;
uvidx.resize(config.totloop);
uvs.resize(config.totloop);
+ /* Iterate in reverse order to match exported polygons. */
for (int i = 0; i < num_poly; ++i) {
MPoly &current_poly = polygons[i];
- MLoopUV *loopuvpoly = mloopuv_array + current_poly.loopstart + current_poly.totloop;
+ MLoopUV *loopuv = mloopuv_array + current_poly.loopstart + current_poly.totloop;
for (int j = 0; j < current_poly.totloop; ++j, ++cnt) {
- --loopuvpoly;
+ --loopuv;
uvidx[cnt] = cnt;
- uvs[cnt][0] = loopuvpoly->uv[0];
- uvs[cnt][1] = loopuvpoly->uv[1];
+ uvs[cnt][0] = loopuv->uv[0];
+ uvs[cnt][1] = loopuv->uv[1];
}
}
}
else {
- uv_index_map idx_map;
+ /* Mapping for indexed UVs, deduplicating UV coordinates at vertices. */
+ std::vector<std::vector<uint32_t>> idx_map(config.totvert);
int idx_count = 0;
for (int i = 0; i < num_poly; ++i) {
MPoly &current_poly = polygons[i];
- MLoopUV *loopuvpoly = mloopuv_array + current_poly.loopstart + current_poly.totloop;
+ MLoop *looppoly = mloop + current_poly.loopstart + current_poly.totloop;
+ MLoopUV *loopuv = mloopuv_array + current_poly.loopstart + current_poly.totloop;
for (int j = 0; j < current_poly.totloop; ++j) {
- loopuvpoly--;
- Imath::V2f uv(loopuvpoly->uv[0], loopuvpoly->uv[1]);
- uint64_t k = uv_to_hash_key(uv);
- uv_index_map::iterator it = idx_map.find(k);
- if (it == idx_map.end()) {
- idx_map[k] = idx_count;
- uvs.push_back(uv);
- uvidx.push_back(idx_count++);
+ --looppoly;
+ --loopuv;
+
+ Imath::V2f uv(loopuv->uv[0], loopuv->uv[1]);
+ bool found_same = false;
+
+ /* Find UV already in uvs array. */
+ for (uint32_t uv_idx : idx_map[looppoly->v]) {
+ if (uvs[uv_idx] == uv) {
+ found_same = true;
+ uvidx.push_back(uv_idx);
+ break;
+ }
}
- else {
- uvidx.push_back(it->second);
+
+ /* UV doesn't exists for this vertex, add it. */
+ if (!found_same) {
+ uint32_t uv_idx = idx_count++;
+ idx_map[looppoly->v].push_back(uv_idx);
+ uvidx.push_back(uv_idx);
+ uvs.push_back(uv);
}
}
}
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index e1d4eb3490b..c0daf9c3346 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -818,12 +818,12 @@ static void import_endjob(void *user_data)
/* TODO: is setting active needed? */
BKE_view_layer_base_select_and_set_active(view_layer, base);
- DEG_id_tag_update(&lc->collection->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&lc->collection->id, ID_RECALC_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);
+ ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION | ID_RECALC_BASE_FLAGS);
}
- DEG_id_tag_update(&data->scene->id, DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_id_tag_update(&data->scene->id, ID_RECALC_BASE_FLAGS);
DEG_relations_tag_update(data->bmain);
}
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index baec7e77328..c9ea8b3174c 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -504,18 +504,13 @@ DerivedMesh *mesh_create_derived_render(
/* same as above but wont use render settings */
DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]);
-DerivedMesh *mesh_create_derived_no_deform(
- struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask);
-DerivedMesh *mesh_create_derived_no_deform_render(
- struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask);
struct Mesh *editbmesh_get_eval_cage(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *,
struct BMEditMesh *em, CustomDataMask dataMask);
+struct Mesh *editbmesh_get_eval_cage_from_orig(
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *,
+ struct BMEditMesh *em, CustomDataMask dataMask);
struct Mesh *editbmesh_get_eval_cage_and_final(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *,
struct BMEditMesh *em, CustomDataMask dataMask,
diff --git a/source/blender/blenkernel/BKE_appdir.h b/source/blender/blenkernel/BKE_appdir.h
index 6162c7b6bf6..8496c56a9c7 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -34,6 +34,7 @@ const char *BKE_appdir_folder_id_create(const int folder_id, const char *subfold
const char *BKE_appdir_folder_id_user_notest(const int folder_id, const char *subfolder);
const char *BKE_appdir_folder_id_version(const int folder_id, const int ver, const bool do_check);
+bool BKE_appdir_app_is_portable_install(void);
bool BKE_appdir_app_template_any(void);
bool BKE_appdir_app_template_id_search(const char *app_template, char *path, size_t path_len);
void BKE_appdir_app_templates(struct ListBase *templates);
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 1831e93cccb..bc91ffeb504 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -164,14 +164,26 @@ typedef struct BBoneSplineParameters {
float curveInX, curveInY, curveOutX, curveOutY;
} BBoneSplineParameters;
-void BKE_pchan_get_bbone_handles(struct bPoseChannel *pchan, struct bPoseChannel **r_prev, struct bPoseChannel **r_next);
-
-void b_bone_spline_setup(struct bPoseChannel *pchan, const bool rest, Mat4 result_array[MAX_BBONE_SUBDIV]);
-
-int BKE_compute_b_bone_spline(struct BBoneSplineParameters *param, Mat4 result_array[MAX_BBONE_SUBDIV]);
-
-void BKE_pchan_cache_bbone_segments(struct bPoseChannel *pchan);
-void BKE_pchan_copy_bbone_segments_cache(struct bPoseChannel *pchan, struct bPoseChannel *pchan_from);
+void BKE_pchan_bbone_handles_get(
+ struct bPoseChannel *pchan, struct bPoseChannel **r_prev, struct bPoseChannel **r_next);
+void BKE_pchan_bbone_spline_params_get(
+ struct bPoseChannel *pchan, const bool rest, struct BBoneSplineParameters *r_param);
+
+void BKE_pchan_bbone_spline_setup(
+ struct bPoseChannel *pchan, const bool rest, Mat4 result_array[MAX_BBONE_SUBDIV]);
+
+void BKE_pchan_bbone_handles_compute(
+ const BBoneSplineParameters *param,
+ float h1[3], float *r_roll1,
+ float h2[3], float *r_roll2,
+ bool ease, bool offsets);
+int BKE_pchan_bbone_spline_compute(
+ struct BBoneSplineParameters *param, Mat4 result_array[MAX_BBONE_SUBDIV]);
+
+void BKE_pchan_bbone_segments_cache_compute(
+ struct bPoseChannel *pchan);
+void BKE_pchan_bbone_segments_cache_copy(
+ struct bPoseChannel *pchan, struct bPoseChannel *pchan_from);
/* like EBONE_VISIBLE */
#define PBONE_VISIBLE(arm, bone) ( \
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 32b9508a679..3415a57a740 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -28,7 +28,7 @@
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 280
-#define BLENDER_SUBVERSION 33
+#define BLENDER_SUBVERSION 35
/* Several breakages with 280, e.g. collections vs layers */
#define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0
@@ -37,7 +37,7 @@
/* can be left blank, otherwise a,b,c... etc with no quotes */
#define BLENDER_VERSION_CHAR
/* alpha/beta/rc/release, docs use this */
-#define BLENDER_VERSION_CYCLE alpha
+#define BLENDER_VERSION_CYCLE beta
extern char versionstr[]; /* from blender.c */
diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h
index 5332b3acd72..aa3721d7a14 100644
--- a/source/blender/blenkernel/BKE_colortools.h
+++ b/source/blender/blenkernel/BKE_colortools.h
@@ -95,18 +95,35 @@ void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, con
void scopes_free(struct Scopes *scopes);
void scopes_new(struct Scopes *scopes);
-void BKE_color_managed_display_settings_init(struct ColorManagedDisplaySettings *settings);
-void BKE_color_managed_display_settings_copy(struct ColorManagedDisplaySettings *new_settings,
- const struct ColorManagedDisplaySettings *settings);
+void BKE_color_managed_display_settings_init(
+ struct ColorManagedDisplaySettings *settings);
+void BKE_color_managed_display_settings_copy(
+ struct ColorManagedDisplaySettings *new_settings,
+ const struct ColorManagedDisplaySettings *settings);
-void BKE_color_managed_view_settings_init(struct ColorManagedViewSettings *settings);
-void BKE_color_managed_view_settings_copy(struct ColorManagedViewSettings *new_settings,
- const struct ColorManagedViewSettings *settings);
+/* Initialize view settings to be best suitable for render type of viewing.
+ * This will use default view transform from the OCIO configuration. */
+void BKE_color_managed_view_settings_init_render(
+ struct ColorManagedViewSettings *settings,
+ const struct ColorManagedDisplaySettings *display_settings);
+
+/* Initialize view settings which are best suitable for viewing non-render
+ * images. For example,s movie clips while tracking. */
+void BKE_color_managed_view_settings_init_default(
+ struct ColorManagedViewSettings *settings,
+ const struct ColorManagedDisplaySettings *display_settings);
+
+void BKE_color_managed_view_settings_copy(
+ struct ColorManagedViewSettings *new_settings,
+ const struct ColorManagedViewSettings *settings);
void BKE_color_managed_view_settings_free(struct ColorManagedViewSettings *settings);
-void BKE_color_managed_colorspace_settings_init(struct ColorManagedColorspaceSettings *colorspace_settings);
-void BKE_color_managed_colorspace_settings_copy(struct ColorManagedColorspaceSettings *colorspace_settings,
- const struct ColorManagedColorspaceSettings *settings);
-bool BKE_color_managed_colorspace_settings_equals(const struct ColorManagedColorspaceSettings *settings1,
- const struct ColorManagedColorspaceSettings *settings2);
+void BKE_color_managed_colorspace_settings_init(
+ struct ColorManagedColorspaceSettings *colorspace_settings);
+void BKE_color_managed_colorspace_settings_copy(
+ struct ColorManagedColorspaceSettings *colorspace_settings,
+ const struct ColorManagedColorspaceSettings *settings);
+bool BKE_color_managed_colorspace_settings_equals(
+ const struct ColorManagedColorspaceSettings *settings1,
+ const struct ColorManagedColorspaceSettings *settings2);
#endif
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 50e3abdbd0c..6cd4ab0bec3 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -82,6 +82,7 @@ void customData_mask_layers__print(CustomDataMask mask);
typedef void (*cd_interp)(const void **sources, const float *weights, const float *sub_weights, int count, void *dest);
typedef void (*cd_copy)(const void *source, void *dest, int count);
+typedef bool (*cd_validate)(void *item, const uint totitems, const bool do_fixes);
/**
* Checks if the layer at physical offset \a layer_n (in data->layers) support math
@@ -405,6 +406,9 @@ void CustomData_bmesh_init_pool(struct CustomData *data, int totelem, const char
bool CustomData_from_bmeshpoly_test(CustomData *fdata, CustomData *ldata, bool fallback);
#endif
+/* Layer data validation. */
+bool CustomData_layer_validate(struct CustomDataLayer *layer, const uint totitems, const bool do_fixes);
+
/* External file storage */
void CustomData_external_add(struct CustomData *data,
diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h
index 02c86642b11..e6b08a8a063 100644
--- a/source/blender/blenkernel/BKE_displist.h
+++ b/source/blender/blenkernel/BKE_displist.h
@@ -91,7 +91,8 @@ void BKE_displist_make_surf(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
struct Mesh **r_final, const bool for_render, const bool for_orco, const bool use_render_resolution);
void BKE_displist_make_curveTypes(
- struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const bool for_orco);
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
+ const bool for_render, const bool for_orco);
void BKE_displist_make_curveTypes_forRender(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
struct Mesh **r_final, const bool for_orco, const bool use_render_resolution);
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index 3d4154c572b..9ba1bbdee07 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -47,8 +47,7 @@ struct ParticleKey;
struct Depsgraph;
struct ViewLayer;
-struct EffectorWeights *BKE_add_effector_weights(struct Collection *collection);
-struct PartDeflect *object_add_collision_fields(int type);
+struct EffectorWeights *BKE_effector_add_weights(struct Collection *collection);
/* Input to effector code */
typedef struct EffectedPoint {
@@ -120,7 +119,9 @@ typedef struct EffectorRelation {
struct PartDeflect *pd;
} EffectorRelation;
-void free_partdeflect(struct PartDeflect *pd);
+
+struct PartDeflect *BKE_partdeflect_new(int type);
+void BKE_partdeflect_free(struct PartDeflect *pd);
struct ListBase *BKE_effector_relations_create(
struct Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 0b7ffb338d8..f6490930530 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -72,14 +72,14 @@ void bezt_add_to_cfra_elem(ListBase *lb, struct BezTriple *bezt);
*/
/* convenience looper over ALL driver targets for a given variable (even the unused ones) */
-#define DRIVER_TARGETS_LOOPER(dvar) \
+#define DRIVER_TARGETS_LOOPER_BEGIN(dvar) \
{ \
DriverTarget *dtar = &dvar->targets[0]; \
int tarIndex = 0; \
for (; tarIndex < MAX_DRIVER_TARGETS; tarIndex++, dtar++)
/* convenience looper over USED driver targets only */
-#define DRIVER_TARGETS_USED_LOOPER(dvar) \
+#define DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar) \
{ \
DriverTarget *dtar = &dvar->targets[0]; \
int tarIndex = 0; \
@@ -87,7 +87,7 @@ void bezt_add_to_cfra_elem(ListBase *lb, struct BezTriple *bezt);
/* tidy up for driver targets loopers */
#define DRIVER_TARGETS_LOOPER_END \
-}
+} ((void)0)
/* ---------------------- */
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 410c8bb3a65..b2991679775 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -143,6 +143,7 @@ enum {
G_DEBUG_GPU = (1 << 16), /* gpu debug */
G_DEBUG_IO = (1 << 17), /* IO Debugging (for Collada, ...)*/
G_DEBUG_GPU_SHADERS = (1 << 18), /* GLSL shaders */
+ G_DEBUG_GPU_FORCE_WORKAROUNDS = (1 << 19), /* force gpu workarounds bypassing detections. */
};
#define G_DEBUG_ALL (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM | G_DEBUG_JOBS | \
@@ -206,6 +207,7 @@ enum {
#define G_TRANSFORM_EDIT 2
#define G_TRANSFORM_SEQ 4
#define G_TRANSFORM_FCURVES 8
+#define G_TRANSFORM_WM 16
/* Memory is allocated where? blender.c */
extern Global G;
diff --git a/source/blender/blenkernel/BKE_keyconfig.h b/source/blender/blenkernel/BKE_keyconfig.h
index a086930fe34..94d00b19d42 100644
--- a/source/blender/blenkernel/BKE_keyconfig.h
+++ b/source/blender/blenkernel/BKE_keyconfig.h
@@ -50,6 +50,8 @@ struct wmKeyConfigPrefType_Runtime *BKE_keyconfig_pref_type_find(const char *idn
void BKE_keyconfig_pref_type_add(struct wmKeyConfigPrefType_Runtime *kpt_rt);
void BKE_keyconfig_pref_type_remove(const struct wmKeyConfigPrefType_Runtime *kpt_rt);
+void BKE_keyconfig_pref_set_select_mouse(struct UserDef *userdef, int value, bool override);
+
void BKE_keyconfig_pref_type_init(void);
void BKE_keyconfig_pref_type_free(void);
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index 2e093ba11a2..b2911129525 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -63,9 +63,8 @@ bool object_deform_mball(struct Object *ob, struct ListBase *dispbase);
void outside_lattice(struct Lattice *lt);
void curve_deform_verts(
- struct Object *cuOb, struct Object *target,
- struct Mesh *mesh, float (*vertexCos)[3],
- int numVerts, const char *vgroup, short defaxis);
+ struct Object *cuOb, struct Object *target, float (*vertexCos)[3],
+ int numVerts, struct MDeformVert *dvert, const int defgrp_index, short defaxis);
void curve_deform_vector(
struct Object *cuOb, struct Object *target,
float orco[3], float vec[3], float mat[3][3], int no_rot_axis);
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 2d736b41d1a..db363148bc8 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -53,6 +53,7 @@ struct Main;
struct Object;
struct RenderEngine;
struct Scene;
+struct View3D;
struct ViewLayer;
struct WorkSpace;
@@ -140,6 +141,11 @@ void BKE_layer_eval_view_layer_indexed(
/* iterators */
+typedef struct ObjectsVisibleIteratorData {
+ struct ViewLayer *view_layer;
+ struct View3D *v3d;
+} ObjectsVisibleIteratorData;
+
void BKE_view_layer_selected_objects_iterator_begin(BLI_Iterator *iter, void *data_in);
void BKE_view_layer_selected_objects_iterator_next(BLI_Iterator *iter);
void BKE_view_layer_selected_objects_iterator_end(BLI_Iterator *iter);
@@ -154,7 +160,9 @@ void BKE_view_layer_selected_editable_objects_iterator_end(BLI_Iterator *iter);
struct ObjectsInModeIteratorData {
int object_mode;
+ int object_type;
struct ViewLayer *view_layer;
+ struct View3D *v3d;
struct Base *base_active;
};
@@ -174,39 +182,58 @@ void BKE_view_layer_visible_bases_iterator_begin(BLI_Iterator *iter, void *data_
void BKE_view_layer_visible_bases_iterator_next(BLI_Iterator *iter);
void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
-#define FOREACH_SELECTED_OBJECT_BEGIN(view_layer, _instance) \
+#define FOREACH_SELECTED_OBJECT_BEGIN(_view_layer, _v3d, _instance) \
+{ \
+ struct ObjectsVisibleIteratorData data_ = { \
+ .view_layer = _view_layer, \
+ .v3d = _v3d, \
+ }; \
ITER_BEGIN(BKE_view_layer_selected_objects_iterator_begin, \
BKE_view_layer_selected_objects_iterator_next, \
BKE_view_layer_selected_objects_iterator_end, \
- view_layer, Object *, _instance)
+ &data_, Object *, _instance)
#define FOREACH_SELECTED_OBJECT_END \
- ITER_END
+ ITER_END; \
+} ((void)0)
-#define FOREACH_SELECTED_EDITABLE_OBJECT_BEGIN(view_layer, _instance) \
+#define FOREACH_SELECTED_EDITABLE_OBJECT_BEGIN(_view_layer, _v3d, _instance) \
+{ \
+ struct ObjectsVisibleIteratorData data_ = { \
+ .view_layer = _view_layer, \
+ .v3d = _v3d, \
+ }; \
ITER_BEGIN(BKE_view_layer_selected_editable_objects_iterator_begin, \
BKE_view_layer_selected_editable_objects_iterator_next, \
BKE_view_layer_selected_editable_objects_iterator_end, \
- view_layer, Object *, _instance)
+ &data_, Object *, _instance)
#define FOREACH_SELECTED_EDITABLE_OBJECT_END \
- ITER_END
+ ITER_END; \
+} ((void)0)
-#define FOREACH_VISIBLE_OBJECT_BEGIN(view_layer, _instance) \
+#define FOREACH_VISIBLE_OBJECT_BEGIN(_view_layer, _v3d, _instance) \
+{ \
+ struct ObjectsVisibleIteratorData data_ = { \
+ .view_layer = _view_layer, \
+ .v3d = _v3d, \
+ }; \
ITER_BEGIN(BKE_view_layer_visible_objects_iterator_begin, \
BKE_view_layer_visible_objects_iterator_next, \
BKE_view_layer_visible_objects_iterator_end, \
- view_layer, Object *, _instance)
+ &data_, Object *, _instance)
#define FOREACH_VISIBLE_OBJECT_END \
- ITER_END
-
+ ITER_END; \
+} ((void)0)
-#define FOREACH_BASE_IN_MODE_BEGIN(_view_layer, _object_mode, _instance) \
+#define FOREACH_BASE_IN_MODE_BEGIN(_view_layer, _v3d, _object_type, _object_mode, _instance) \
{ \
struct ObjectsInModeIteratorData data_ = { \
.object_mode = _object_mode, \
+ .object_type = _object_type, \
.view_layer = _view_layer, \
+ .v3d = _v3d, \
.base_active = _view_layer->basact, \
}; \
ITER_BEGIN(BKE_view_layer_bases_in_mode_iterator_begin, \
@@ -218,21 +245,21 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
ITER_END; \
} ((void)0)
-#define FOREACH_BASE_IN_EDIT_MODE_BEGIN(_view_layer, _instance) \
- FOREACH_BASE_IN_MODE_BEGIN(_view_layer, OB_MODE_EDIT, _instance)
+#define FOREACH_BASE_IN_EDIT_MODE_BEGIN(_view_layer, _v3d, _instance) \
+ FOREACH_BASE_IN_MODE_BEGIN(_view_layer, _v3d, -1, OB_MODE_EDIT, _instance)
#define FOREACH_BASE_IN_EDIT_MODE_END \
FOREACH_BASE_IN_MODE_END
-#define FOREACH_OBJECT_IN_MODE_BEGIN(_view_layer, _object_mode, _instance) \
- FOREACH_BASE_IN_MODE_BEGIN(_view_layer, _object_mode, _base) { \
+#define FOREACH_OBJECT_IN_MODE_BEGIN(_view_layer, _v3d, _object_type, _object_mode, _instance) \
+ FOREACH_BASE_IN_MODE_BEGIN(_view_layer, _v3d, _object_type, _object_mode, _base) { \
Object *_instance = _base->object;
#define FOREACH_OBJECT_IN_MODE_END \
} FOREACH_BASE_IN_MODE_END
-#define FOREACH_OBJECT_IN_EDIT_MODE_BEGIN(_view_layer, _instance) \
- FOREACH_BASE_IN_EDIT_MODE_BEGIN(_view_layer, _base) { \
+#define FOREACH_OBJECT_IN_EDIT_MODE_BEGIN(_view_layer, _v3d, _instance) \
+ FOREACH_BASE_IN_EDIT_MODE_BEGIN(_view_layer, _v3d, _base) { \
Object *_instance = _base->object;
#define FOREACH_OBJECT_IN_EDIT_MODE_END \
@@ -247,14 +274,20 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
#define FOREACH_SELECTED_BASE_END \
ITER_END
-#define FOREACH_VISIBLE_BASE_BEGIN(view_layer, _instance) \
+#define FOREACH_VISIBLE_BASE_BEGIN(_view_layer, _v3d, _instance) \
+{ \
+ struct ObjectsVisibleIteratorData data_ = { \
+ .view_layer = _view_layer, \
+ .v3d = _v3d, \
+ }; \
ITER_BEGIN(BKE_view_layer_visible_bases_iterator_begin, \
BKE_view_layer_visible_bases_iterator_next, \
BKE_view_layer_visible_bases_iterator_end, \
- view_layer, Base *, _instance)
+ &data_, Base *, _instance)
#define FOREACH_VISIBLE_BASE_END \
- ITER_END
+ ITER_END; \
+} ((void)0)
#define FOREACH_OBJECT_BEGIN(view_layer, _instance) \
@@ -332,21 +365,21 @@ struct ObjectsInModeParams {
};
Base **BKE_view_layer_array_from_bases_in_mode_params(
- struct ViewLayer *view_layer, uint *r_len,
+ struct ViewLayer *view_layer, struct View3D *v3d, uint *r_len,
const struct ObjectsInModeParams *params);
struct Object **BKE_view_layer_array_from_objects_in_mode_params(
- struct ViewLayer *view_layer, uint *len,
+ struct ViewLayer *view_layer, struct View3D *v3d, uint *len,
const struct ObjectsInModeParams *params);
-#define BKE_view_layer_array_from_objects_in_mode(view_layer, r_len, ...) \
+#define BKE_view_layer_array_from_objects_in_mode(view_layer, v3d, r_len, ...) \
BKE_view_layer_array_from_objects_in_mode_params( \
- view_layer, r_len, \
+ view_layer, v3d, r_len, \
&(const struct ObjectsInModeParams)__VA_ARGS__)
-#define BKE_view_layer_array_from_bases_in_mode(view_layer, r_len, ...) \
+#define BKE_view_layer_array_from_bases_in_mode(view_layer, v3d, r_len, ...) \
BKE_view_layer_array_from_bases_in_mode_params( \
- view_layer, r_len, \
+ view_layer, v3d, r_len, \
&(const struct ObjectsInModeParams)__VA_ARGS__)
bool BKE_view_layer_filter_edit_mesh_has_uvs(struct Object *ob, void *user_data);
@@ -354,38 +387,38 @@ bool BKE_view_layer_filter_edit_mesh_has_edges(struct Object *ob, void *user_dat
/* Utility macros that wrap common args (add more as needed). */
-#define BKE_view_layer_array_from_objects_in_edit_mode(view_layer, r_len) \
+#define BKE_view_layer_array_from_objects_in_edit_mode(view_layer, v3d, r_len) \
BKE_view_layer_array_from_objects_in_mode( \
- view_layer, r_len, { \
+ view_layer, v3d, r_len, { \
.object_mode = OB_MODE_EDIT});
-#define BKE_view_layer_array_from_bases_in_edit_mode(view_layer, r_len) \
+#define BKE_view_layer_array_from_bases_in_edit_mode(view_layer, v3d, r_len) \
BKE_view_layer_array_from_bases_in_mode( \
- view_layer, r_len, { \
+ view_layer, v3d, r_len, { \
.object_mode = OB_MODE_EDIT});
-#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, r_len) \
+#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, r_len) \
BKE_view_layer_array_from_objects_in_mode( \
- view_layer, r_len, { \
+ view_layer, v3d, r_len, { \
.object_mode = OB_MODE_EDIT, \
.no_dup_data = true});
-#define BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, r_len) \
+#define BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, v3d, r_len) \
BKE_view_layer_array_from_bases_in_mode( \
- view_layer, r_len, { \
+ view_layer, v3d, r_len, { \
.object_mode = OB_MODE_EDIT, \
.no_dup_data = true});
-#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, r_len) \
+#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, v3d, r_len) \
BKE_view_layer_array_from_objects_in_mode( \
- view_layer, r_len, { \
+ view_layer, v3d, r_len, { \
.object_mode = OB_MODE_EDIT, \
.no_dup_data = true, \
.filter_fn = BKE_view_layer_filter_edit_mesh_has_uvs});
-#define BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, r_len, mode) \
+#define BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, v3d, r_len, mode) \
BKE_view_layer_array_from_objects_in_mode( \
- view_layer, r_len, { \
+ view_layer, v3d, r_len, { \
.object_mode = mode, \
.no_dup_data = true});
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 273f074777a..7e260b34e36 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -93,6 +93,8 @@ void BKE_libblock_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r
void *BKE_libblock_copy(struct Main *bmain, const struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
/* "Deprecated" old API. */
void *BKE_libblock_copy_nolib(const struct ID *id, const bool do_action) ATTR_NONNULL();
+/* Special version. sued by datablock localization. */
+void *BKE_libblock_copy_for_localize(const struct ID *id);
void BKE_libblock_rename(struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL();
void BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_NONNULL();
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index aba42820519..1e0474fc933 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -487,8 +487,10 @@ bool BKE_mesh_validate_arrays(
bool *r_change);
bool BKE_mesh_validate_all_customdata(
- struct CustomData *vdata, struct CustomData *edata,
- struct CustomData *ldata, struct CustomData *pdata,
+ struct CustomData *vdata, const uint totvert,
+ struct CustomData *edata, const uint totedge,
+ struct CustomData *ldata, const uint totloop,
+ struct CustomData *pdata, const uint totpoly,
const bool check_meshmask,
const bool do_verbose, const bool do_fixes,
bool *r_change);
diff --git a/source/blender/blenkernel/BKE_mesh_runtime.h b/source/blender/blenkernel/BKE_mesh_runtime.h
index 5d35f798ad7..8f9de85a302 100644
--- a/source/blender/blenkernel/BKE_mesh_runtime.h
+++ b/source/blender/blenkernel/BKE_mesh_runtime.h
@@ -109,6 +109,16 @@ struct Mesh *mesh_create_eval_final_view(
struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, CustomDataMask dataMask);
+struct Mesh *mesh_create_eval_no_deform(
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ struct Object *ob, float (*vertCos)[3],
+ CustomDataMask dataMask);
+struct Mesh *mesh_create_eval_no_deform_render(
+ struct Depsgraph *depsgraph, struct Scene *scene,
+ struct Object *ob, float (*vertCos)[3],
+ CustomDataMask dataMask);
+
+
void BKE_mesh_runtime_eval_to_meshkey(struct Mesh *me_deformed, struct Mesh *me, struct KeyBlock *kb);
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 6b64b1663d8..6f3150880fa 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -273,7 +273,7 @@ typedef struct ModifierTypeInfo {
/* True when a deform modifier uses normals, the requiredDataMask
- * cant be used here because that refers to a normal layer where as
+ * cant be used here because that refers to a normal layer whereas
* in this case we need to know if the deform modifier uses normals.
*
* this is needed because applying 2 deform modifiers will give the
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 07a50a782c5..5f0635037c2 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -37,7 +37,7 @@
#include "DNA_listBase.h"
-/* for FOREACH_NODETREE */
+/* for FOREACH_NODETREE_BEGIN */
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_node_types.h"
@@ -410,7 +410,7 @@ struct GHashIterator *nodeTypeGetIterator(void);
#define NODE_TYPES_END \
} \
BLI_ghashIterator_free(__node_type_iter__); \
-}
+} ((void)0)
struct bNodeSocketType *nodeSocketTypeFind(const char *idname);
void nodeRegisterSocketType(struct bNodeSocketType *stype);
@@ -646,17 +646,17 @@ void BKE_node_tree_unlink_id(ID *id, struct bNodeTree *ntree);
* Examples:
*
* \code{.c}
- * FOREACH_NODETREE(bmain, nodetree, id) {
+ * FOREACH_NODETREE_BEGIN(bmain, nodetree, id) {
* if (id == nodetree)
* printf("This is a linkable node tree");
- * } FOREACH_NODETREE_END
+ * } FOREACH_NODETREE_END;
*
- * FOREACH_NODETREE(bmain, nodetree, id) {
+ * FOREACH_NODETREE_BEGIN(bmain, nodetree, id) {
* if (nodetree->idname == "ShaderNodeTree")
* printf("This is a shader node tree);
* if (GS(id) == ID_MA)
* printf(" and it's owned by a material");
- * } FOREACH_NODETREE_END
+ * } FOREACH_NODETREE_END;
* \endcode
*
* \{
@@ -677,7 +677,7 @@ void BKE_node_tree_iter_init(struct NodeTreeIterStore *ntreeiter, struct Main *b
bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter,
struct bNodeTree **r_nodetree, struct ID **r_id);
-#define FOREACH_NODETREE(bmain, _nodetree, _id) \
+#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id) \
{ \
struct NodeTreeIterStore _nstore; \
bNodeTree *_nodetree; \
@@ -690,7 +690,7 @@ bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter,
#define FOREACH_NODETREE_END \
} \
} \
-}
+} ((void)0)
/** \} */
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 066a9ecfaca..c3be3237c6f 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -148,13 +148,13 @@ bool BKE_object_pose_context_check(const struct Object *ob);
struct Object *BKE_object_pose_armature_get(struct Object *ob);
struct Object *BKE_object_pose_armature_get_visible(struct Object *ob, struct ViewLayer *view_layer, struct View3D *v3d);
-struct Object **BKE_object_pose_array_get_ex(struct ViewLayer *view_layer, unsigned int *r_objects_len, bool unique);
-struct Object **BKE_object_pose_array_get_unique(struct ViewLayer *view_layer, unsigned int *r_objects_len);
-struct Object **BKE_object_pose_array_get(struct ViewLayer *view_layer, unsigned int *r_objects_len);
+struct Object **BKE_object_pose_array_get_ex(struct ViewLayer *view_layer, struct View3D *v3d, unsigned int *r_objects_len, bool unique);
+struct Object **BKE_object_pose_array_get_unique(struct ViewLayer *view_layer, struct View3D *v3d, unsigned int *r_objects_len);
+struct Object **BKE_object_pose_array_get(struct ViewLayer *view_layer, struct View3D *v3d, unsigned int *r_objects_len);
-struct Base **BKE_object_pose_base_array_get_ex(struct ViewLayer *view_layer, unsigned int *r_bases_len, bool unique);
-struct Base **BKE_object_pose_base_array_get_unique(struct ViewLayer *view_layer, unsigned int *r_bases_len);
-struct Base **BKE_object_pose_base_array_get(struct ViewLayer *view_layer, unsigned int *r_bases_len);
+struct Base **BKE_object_pose_base_array_get_ex(struct ViewLayer *view_layer, struct View3D *v3d, unsigned int *r_bases_len, bool unique);
+struct Base **BKE_object_pose_base_array_get_unique(struct ViewLayer *view_layer, struct View3D *v3d, unsigned int *r_bases_len);
+struct Base **BKE_object_pose_base_array_get(struct ViewLayer *view_layer, struct View3D *v3d, unsigned int *r_bases_len);
void BKE_object_get_parent_matrix(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
@@ -247,7 +247,10 @@ void BKE_object_eval_uber_data(
struct Scene *scene,
struct Object *ob);
-void BKE_object_eval_boundbox(struct Depsgraph *depsgraph, struct Object *object);
+void BKE_object_eval_boundbox(struct Depsgraph *depsgraph,
+ struct Object *object);
+void BKE_object_synchronize_to_original(struct Depsgraph *depsgraph,
+ struct Object *object);
void BKE_object_eval_ptcache_reset(
struct Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index e7a26afadf5..6344d29a2a0 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -161,7 +161,7 @@ bool BKE_scene_use_shading_nodes_custom(struct Scene *scene);
bool BKE_scene_use_spherical_stereo(struct Scene *scene);
bool BKE_scene_uses_blender_eevee(const struct Scene *scene);
-bool BKE_scene_uses_blender_opengl(const struct Scene *scene);
+bool BKE_scene_uses_blender_workbench(const struct Scene *scene);
bool BKE_scene_uses_cycles(const struct Scene *scene);
void BKE_scene_disable_color_management(struct Scene *scene);
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 0d766e83299..75d2ed0d0bc 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -319,6 +319,10 @@ void BKE_spacedata_freelist(ListBase *lb);
void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2);
void BKE_spacedata_draw_locks(int set);
+struct ARegion *BKE_spacedata_find_region_type(
+ const struct SpaceLink *slink, const struct ScrArea *sa,
+ int region_type) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+
void BKE_spacedata_callback_id_remap_set(
void (*func)(struct ScrArea *sa, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id));
void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID *id);
@@ -332,7 +336,7 @@ void BKE_screen_area_free(struct ScrArea *sa);
void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *));
void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizmoMap *));
-struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type);
+struct ARegion *BKE_area_find_region_type(const struct ScrArea *sa, int type);
struct ARegion *BKE_area_find_region_active_win(struct ScrArea *sa);
struct ARegion *BKE_area_find_region_xy(struct ScrArea *sa, const int regiontype, int x, int y);
struct ScrArea *BKE_screen_find_area_from_space(struct bScreen *sc, struct SpaceLink *sl) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2);
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index 00fd4ded8c6..ebe732d2336 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -90,7 +90,7 @@ void BKE_sequence_iterator_end(SeqIterator *iter);
#define SEQ_END \
} \
BKE_sequence_iterator_end(&iter_macro); \
- }
+ } ((void)0)
typedef struct SeqRenderData {
struct Main *bmain;
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index caba7a6f284..0959e8a72f0 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -90,6 +90,7 @@ typedef struct ShrinkwrapTreeData {
BVHTree *bvh;
BVHTreeFromMesh treeData;
+ float (*pnors)[3];
float (*clnors)[3];
ShrinkwrapBoundaryData *boundary;
} ShrinkwrapTreeData;
@@ -104,8 +105,10 @@ bool BKE_shrinkwrap_init_tree(struct ShrinkwrapTreeData *data, Mesh *mesh, int s
void BKE_shrinkwrap_free_tree(struct ShrinkwrapTreeData *data);
/* Implementation of the Shrinkwrap modifier */
-void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Scene *scene, struct Object *ob, struct Mesh *mesh,
- float (*vertexCos)[3], int numVerts);
+void shrinkwrapModifier_deform(
+ struct ShrinkwrapModifierData *smd, const struct ModifierEvalContext *ctx,
+ struct Scene *scene, struct Object *ob, struct Mesh *mesh,
+ struct MDeformVert *dvert, const int defgrp_index, float (*vertexCos)[3], int numVerts);
/*
* This function casts a ray in the given BVHTree.. but it takes into consideration the space_transform, that is:
diff --git a/source/blender/blenkernel/BKE_studiolight.h b/source/blender/blenkernel/BKE_studiolight.h
index 7ec98c99c3f..25931e2bbf5 100644
--- a/source/blender/blenkernel/BKE_studiolight.h
+++ b/source/blender/blenkernel/BKE_studiolight.h
@@ -39,6 +39,7 @@
#include "BLI_sys_types.h"
#include "DNA_space_types.h"
+#include "DNA_userdef_types.h"
#include "IMB_imbuf_types.h"
@@ -59,6 +60,8 @@
#define STUDIOLIGHT_ICON_ID_TYPE_MATCAP (1 << 2)
#define STUDIOLIGHT_ICON_ID_TYPE_MATCAP_FLIPPED (1 << 3)
+#define STUDIOLIGHT_MAX_LIGHT 4
+
#define STUDIOLIGHT_ICON_SIZE 96
/* Only 1 - 5 is supported */
@@ -82,9 +85,9 @@ enum StudioLightFlag {
/* STUDIOLIGHT_LIGHT_DIRECTION_CALCULATED = (1 << 1), */
STUDIOLIGHT_INTERNAL = (1 << 2),
STUDIOLIGHT_EXTERNAL_FILE = (1 << 3),
- STUDIOLIGHT_ORIENTATION_CAMERA = (1 << 4),
- STUDIOLIGHT_ORIENTATION_WORLD = (1 << 5),
- STUDIOLIGHT_ORIENTATION_VIEWNORMAL = (1 << 6),
+ STUDIOLIGHT_TYPE_STUDIO = (1 << 4),
+ STUDIOLIGHT_TYPE_WORLD = (1 << 5),
+ STUDIOLIGHT_TYPE_MATCAP = (1 << 6),
STUDIOLIGHT_EXTERNAL_IMAGE_LOADED = (1 << 7),
STUDIOLIGHT_EQUIRECT_IRRADIANCE_IMAGE_CALCULATED = (1 << 8),
STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE = (1 << 9),
@@ -95,9 +98,9 @@ enum StudioLightFlag {
};
#define STUDIOLIGHT_FLAG_ALL (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_EXTERNAL_FILE)
-#define STUDIOLIGHT_FLAG_ORIENTATIONS (STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_VIEWNORMAL)
-#define STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE (STUDIOLIGHT_ORIENTATION_WORLD)
-#define STUDIOLIGHT_ORIENTATIONS_SOLID (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD)
+#define STUDIOLIGHT_FLAG_ORIENTATIONS (STUDIOLIGHT_TYPE_STUDIO | STUDIOLIGHT_TYPE_WORLD | STUDIOLIGHT_TYPE_MATCAP)
+#define STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE (STUDIOLIGHT_TYPE_WORLD)
+#define STUDIOLIGHT_ORIENTATIONS_SOLID (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_TYPE_STUDIO)
typedef void StudioLightFreeFunction(struct StudioLight *, void *data);
@@ -121,6 +124,8 @@ typedef struct StudioLight {
ImBuf *radiance_cubemap_buffers[6];
struct GPUTexture *equirect_radiance_gputexture;
struct GPUTexture *equirect_irradiance_gputexture;
+ SolidLight light[STUDIOLIGHT_MAX_LIGHT];
+ float light_ambient[3];
/*
* Free function to clean up the running icons previews (wmJob) the usage is in
@@ -140,7 +145,9 @@ void BKE_studiolight_preview(uint *icon_buffer, StudioLight *sl, int icon_id_typ
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);
+StudioLight *BKE_studiolight_load(const char *path, int orientation);
+StudioLight *BKE_studiolight_create(const char *path, const SolidLight light[4], const float light_ambient[3]);
+StudioLight *BKE_studiolight_studio_edit_get(void);
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_subdiv_mesh.h b/source/blender/blenkernel/BKE_subdiv_mesh.h
index f719527eed8..6f1ffb2555b 100644
--- a/source/blender/blenkernel/BKE_subdiv_mesh.h
+++ b/source/blender/blenkernel/BKE_subdiv_mesh.h
@@ -45,6 +45,8 @@ typedef struct SubdivToMeshSettings {
* `resolution - 1`.
*/
int resolution;
+ /* When true, only edges emitted from coarse ones will be displayed. */
+ bool use_optimal_display;
} SubdivToMeshSettings;
/* Create real hi-res mesh from subdivision, all geometry is "real". */
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index ce1fcdb54be..bb6fd5ebc43 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -359,14 +359,16 @@ set(SRC
BKE_writeavi.h
nla_private.h
- tracking_private.h
particle_private.h
+ tracking_private.h
intern/CCGSubSurf.h
intern/CCGSubSurf_inline.h
intern/CCGSubSurf_intern.h
intern/data_transfer_intern.h
+ intern/multires_inline.h
intern/pbvh_intern.h
intern/subdiv_converter.h
+ intern/subdiv_inline.h
)
if(WITH_BINRELOC)
@@ -567,9 +569,6 @@ if(WITH_OPENSUBDIV)
list(APPEND INC_SYS
${OPENSUBDIV_INCLUDE_DIRS}
)
- if(WITH_OPENSUBDIV_MODIFIER)
- add_definitions(-DWITH_OPENSUBDIV_MODIFIER)
- endif()
endif()
if(WITH_OPENVDB)
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 54aa46d8b85..a29b0011216 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1151,6 +1151,14 @@ static void add_shapekey_layers(Mesh *me_dst, Mesh *me_src, Object *UNUSED(ob))
}
}
+static void mesh_copy_autosmooth(Mesh *me, Mesh *me_orig)
+{
+ if (me_orig->flag & ME_AUTOSMOOTH) {
+ me->flag |= ME_AUTOSMOOTH;
+ me->smoothresh = me_orig->smoothresh;
+ }
+}
+
static void mesh_calc_modifiers(
struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (*inputVertexCos)[3],
int useDeform,
@@ -1460,6 +1468,8 @@ static void mesh_calc_modifiers(
}
deformedVerts = NULL;
}
+
+ mesh_copy_autosmooth(me, ob->data);
}
/* create an orco mesh in parallel */
@@ -1608,6 +1618,8 @@ static void mesh_calc_modifiers(
BLI_linklist_free((LinkNode *)datamasks, NULL);
}
+
+#ifdef USE_DERIVEDMESH
static void mesh_calc_modifiers_dm(
struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (*inputVertexCos)[3],
int useDeform,
@@ -1631,6 +1643,7 @@ static void mesh_calc_modifiers_dm(
*r_finaldm = CDDM_from_mesh_ex(final_mesh, CD_DUPLICATE, CD_MASK_MESH);
BKE_id_free(NULL, final_mesh);
}
+#endif
float (*editbmesh_get_vertex_cos(BMEditMesh *em, int *r_numVerts))[3]
{
@@ -1693,6 +1706,7 @@ static void editbmesh_calc_modifiers(
if (r_cage && cageIndex == -1) {
*r_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, dataMask, NULL);
+ mesh_copy_autosmooth(*r_cage, ob->data);
}
md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
@@ -1769,6 +1783,8 @@ static void editbmesh_calc_modifiers(
me = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, 0);
ASSERT_IS_VALID_MESH(me);
+ mesh_copy_autosmooth(me, ob->data);
+
if (deformedVerts) {
BKE_mesh_apply_vert_coords(me, deformedVerts);
}
@@ -1822,6 +1838,8 @@ static void editbmesh_calc_modifiers(
MEM_freeN(deformedVerts);
deformedVerts = NULL;
}
+
+ mesh_copy_autosmooth(me, ob->data);
}
me->runtime.deformed_only = false;
}
@@ -1843,6 +1861,7 @@ static void editbmesh_calc_modifiers(
*r_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(
em, mask,
deformedVerts ? MEM_dupallocN(deformedVerts) : NULL);
+ mesh_copy_autosmooth(*r_cage, ob->data);
}
}
}
@@ -1878,6 +1897,8 @@ static void editbmesh_calc_modifiers(
*r_final = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, dataMask, deformedVerts);
deformedVerts = NULL;
+ mesh_copy_autosmooth(*r_final, ob->data);
+
/* In this case, we should never have weight-modifying modifiers in stack... */
if (do_init_statvis) {
editmesh_update_statvis_color(scene, ob);
@@ -1916,6 +1937,10 @@ static void editbmesh_calc_modifiers(
if (!do_loop_normals) {
BKE_mesh_ensure_normals_for_display(*r_final);
+ if (r_cage && *r_cage && (*r_cage != *r_final)) {
+ BKE_mesh_ensure_normals_for_display(*r_cage);
+ }
+
/* Some modifiers, like datatransfer, may generate those data, we do not want to keep them,
* as they are used by display code when available (i.e. even if autosmooth is disabled). */
if (CustomData_has_layer(&(*r_final)->ldata, CD_NORMAL)) {
@@ -2004,15 +2029,22 @@ static void mesh_build_data(
{
BLI_assert(ob->type == OB_MESH);
+ /* Evaluated meshes aren't supposed to be created on original instances. If you do,
+ * they aren't cleaned up properly on mode switch, causing crashes, e.g T58150. */
+ BLI_assert(ob->id.tag & LIB_TAG_COPIED_ON_WRITE);
+
BKE_object_free_derived_caches(ob);
BKE_object_sculpt_modifiers_changed(ob);
+ if (need_mapping) {
+ /* Also add the flag so that it is recorded in lastDataMask. */
+ dataMask |= CD_MASK_ORIGINDEX;
+ }
+
mesh_calc_modifiers(
depsgraph, scene, ob, NULL, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
&ob->runtime.mesh_deform_eval, &ob->runtime.mesh_eval);
- mesh_finalize_eval(ob);
-
#ifdef USE_DERIVEDMESH
/* TODO(campbell): remove these copies, they are expected in various places over the code. */
ob->derivedDeform = CDDM_from_mesh_ex(ob->runtime.mesh_deform_eval, CD_REFERENCE, CD_MASK_MESH);
@@ -2022,12 +2054,14 @@ static void mesh_build_data(
BKE_object_boundbox_calc_from_mesh(ob, ob->runtime.mesh_eval);
BKE_mesh_texspace_copy_from_object(ob->runtime.mesh_eval, ob);
+ mesh_finalize_eval(ob);
+
#ifdef USE_DERIVEDMESH
ob->derivedFinal->needsFree = 0;
ob->derivedDeform->needsFree = 0;
#endif
- ob->lastDataMask = dataMask;
- ob->lastNeedMapping = need_mapping;
+ ob->runtime.last_data_mask = dataMask;
+ ob->runtime.last_need_mapping = need_mapping;
if ((ob->mode & OB_MODE_ALL_SCULPT) && ob->sculpt) {
/* create PBVH immediately (would be created on the fly too,
@@ -2045,6 +2079,8 @@ static void editbmesh_build_data(
struct Depsgraph *depsgraph, Scene *scene,
Object *obedit, BMEditMesh *em, CustomDataMask dataMask)
{
+ BLI_assert(em->ob->id.tag & LIB_TAG_COPIED_ON_WRITE);
+
BKE_object_free_derived_caches(obedit);
BKE_object_sculpt_modifiers_changed(obedit);
@@ -2071,14 +2107,14 @@ static CustomDataMask object_get_datamask(const Depsgraph *depsgraph, Object *ob
{
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
Object *actob = view_layer->basact ? DEG_get_original_object(view_layer->basact->object) : NULL;
- CustomDataMask mask = ob->customdata_mask;
+ CustomDataMask mask = DEG_get_customdata_mask_for_object(depsgraph, ob);
if (r_need_mapping) {
*r_need_mapping = false;
}
if (DEG_get_original_object(ob) == actob) {
- bool editing = BKE_paint_select_face_test(ob);
+ bool editing = BKE_paint_select_face_test(actob);
/* weight paint and face select need original indices because of selection buffer drawing */
if (r_need_mapping) {
@@ -2087,7 +2123,7 @@ static CustomDataMask object_get_datamask(const Depsgraph *depsgraph, Object *ob
/* check if we need tfaces & mcols due to face select or texture paint */
if ((ob->mode & OB_MODE_TEXTURE_PAINT) || editing) {
- mask |= CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL;
+ mask |= CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTFACE;
}
/* check if we need mcols due to vertex paint or weightpaint */
@@ -2148,6 +2184,13 @@ DerivedMesh *mesh_get_derived_final(
Mesh *mesh_get_eval_final(
struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
{
+ /* This function isn't thread-safe and can't be used during evaluation. */
+ BLI_assert(DEG_debug_is_evaluating(depsgraph) == false);
+
+ /* Evaluated meshes aren't supposed to be created on original instances. If you do,
+ * they aren't cleaned up properly on mode switch, causing crashes, e.g T58150. */
+ BLI_assert(ob->id.tag & LIB_TAG_COPIED_ON_WRITE);
+
/* if there's no evaluated mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
@@ -2155,10 +2198,11 @@ Mesh *mesh_get_eval_final(
dataMask |= object_get_datamask(depsgraph, ob, &need_mapping);
if (!ob->runtime.mesh_eval ||
- ((dataMask & ob->lastDataMask) != dataMask) ||
- (need_mapping != ob->lastNeedMapping))
+ ((dataMask & ob->runtime.last_data_mask) != dataMask) ||
+ (need_mapping && !ob->runtime.last_need_mapping))
{
- mesh_build_data(depsgraph, scene, ob, dataMask, false, need_mapping);
+ mesh_build_data(depsgraph, scene, ob, dataMask | ob->runtime.last_data_mask,
+ false, need_mapping || ob->runtime.last_need_mapping);
}
if (ob->runtime.mesh_eval) { BLI_assert(!(ob->runtime.mesh_eval->runtime.cd_dirty_vert & CD_MASK_NORMAL)); }
@@ -2188,6 +2232,13 @@ DerivedMesh *mesh_get_derived_deform(struct Depsgraph *depsgraph, Scene *scene,
#endif
Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
{
+ /* This function isn't thread-safe and can't be used during evaluation. */
+ BLI_assert(DEG_debug_is_evaluating(depsgraph) == false);
+
+ /* Evaluated meshes aren't supposed to be created on original instances. If you do,
+ * they aren't cleaned up properly on mode switch, causing crashes, e.g T58150. */
+ BLI_assert(ob->id.tag & LIB_TAG_COPIED_ON_WRITE);
+
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
@@ -2196,10 +2247,11 @@ Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob
dataMask |= object_get_datamask(depsgraph, ob, &need_mapping);
if (!ob->runtime.mesh_deform_eval ||
- ((dataMask & ob->lastDataMask) != dataMask) ||
- (need_mapping != ob->lastNeedMapping))
+ ((dataMask & ob->runtime.last_data_mask) != dataMask) ||
+ (need_mapping && !ob->runtime.last_need_mapping))
{
- mesh_build_data(depsgraph, scene, ob, dataMask, false, need_mapping);
+ mesh_build_data(depsgraph, scene, ob, dataMask | ob->runtime.last_data_mask,
+ false, need_mapping || ob->runtime.last_need_mapping);
}
return ob->runtime.mesh_deform_eval;
@@ -2301,13 +2353,26 @@ Mesh *mesh_create_eval_final_view(
return final;
}
-DerivedMesh *mesh_create_derived_no_deform(
+Mesh *mesh_create_eval_no_deform(
struct Depsgraph *depsgraph, Scene *scene, Object *ob,
float (*vertCos)[3], CustomDataMask dataMask)
{
- DerivedMesh *final;
+ Mesh *final;
- mesh_calc_modifiers_dm(
+ mesh_calc_modifiers(
+ depsgraph, scene, ob, vertCos, 0, false, dataMask, -1, false, false,
+ NULL, &final);
+
+ return final;
+}
+
+Mesh *mesh_create_eval_no_deform_render(
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob,
+ float (*vertCos)[3], CustomDataMask dataMask)
+{
+ Mesh *final;
+
+ mesh_calc_modifiers(
depsgraph, scene, ob, vertCos, 0, false, dataMask, -1, false, false,
NULL, &final);
@@ -2356,6 +2421,17 @@ Mesh *editbmesh_get_eval_cage(
return em->mesh_eval_cage;
}
+Mesh *editbmesh_get_eval_cage_from_orig(
+ struct Depsgraph *depsgraph, Scene *scene, Object *obedit, BMEditMesh *UNUSED(em),
+ CustomDataMask dataMask)
+{
+ BLI_assert((obedit->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0);
+ Scene *scene_eval = (Scene *)DEG_get_evaluated_id(depsgraph, &scene->id);
+ Object *obedit_eval = (Object *)DEG_get_evaluated_id(depsgraph, &obedit->id);
+ BMEditMesh *em_eval = BKE_editmesh_from_object(obedit_eval);
+ return editbmesh_get_eval_cage(depsgraph, scene_eval, obedit_eval, em_eval, dataMask);
+}
+
/***/
/* UNUSED */
@@ -2747,10 +2823,10 @@ bool DM_is_valid(DerivedMesh *dm)
bool changed = true;
is_valid &= BKE_mesh_validate_all_customdata(
- dm->getVertDataLayout(dm),
- dm->getEdgeDataLayout(dm),
- dm->getLoopDataLayout(dm),
- dm->getPolyDataLayout(dm),
+ dm->getVertDataLayout(dm), dm->getNumVerts(dm),
+ dm->getEdgeDataLayout(dm), dm->getNumEdges(dm),
+ dm->getLoopDataLayout(dm), dm->getNumLoops(dm),
+ dm->getPolyDataLayout(dm), dm->getNumPolys(dm),
false, /* setting mask here isn't useful, gives false positives */
do_verbose, do_fixes, &changed);
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 7693485e042..8e8000f3ea0 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -405,13 +405,13 @@ void BKE_animdata_merge_copy(
DriverVar *dvar;
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
if (dtar->id == src_id) {
dtar->id = dst_id;
}
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
}
@@ -754,7 +754,7 @@ static void drivers_path_rename_fix(ID *owner_id, ID *ref_id, const char *prefix
/* driver variables */
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
/* only change the used targets, since the others will need fixing manually anyway */
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
/* rename RNA path */
if (dtar->rna_path && dtar->id)
@@ -769,7 +769,7 @@ static void drivers_path_rename_fix(ID *owner_id, ID *ref_id, const char *prefix
}
}
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
}
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 2848c245553..3643bf54e48 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -229,7 +229,7 @@ static bool get_path_local(
* Is this an install with user files kept together with the Blender executable and its
* installation files.
*/
-static bool is_portable_install(void)
+bool BKE_appdir_app_is_portable_install(void)
{
/* detect portable install by the existence of config folder */
const int ver = BLENDER_VERSION;
@@ -289,7 +289,7 @@ static bool get_path_user(
const char *user_base_path;
/* for portable install, user path is always local */
- if (is_portable_install()) {
+ if (BKE_appdir_app_is_portable_install()) {
return get_path_local(targetpath, targetpath_len, folder_name, subfolder_name, ver);
}
user_path[0] = '\0';
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 2004b66c1ef..de4f89fe146 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -436,7 +436,7 @@ static void equalize_bbone_bezier(float *data, int desired)
}
/* Get "next" and "prev" bones - these are used for handle calculations. */
-void BKE_pchan_get_bbone_handles(bPoseChannel *pchan, bPoseChannel **r_prev, bPoseChannel **r_next)
+void BKE_pchan_bbone_handles_get(bPoseChannel *pchan, bPoseChannel **r_prev, bPoseChannel **r_next)
{
if (pchan->bone->bbone_prev_type == BBONE_HANDLE_AUTO) {
/* Use connected parent. */
@@ -462,20 +462,18 @@ void BKE_pchan_get_bbone_handles(bPoseChannel *pchan, bPoseChannel **r_prev, bPo
}
}
-/* Fills the array with the desired amount of bone->segments elements.
- * This calculation is done within unit bone space. */
-void b_bone_spline_setup(bPoseChannel *pchan, const bool rest, Mat4 result_array[MAX_BBONE_SUBDIV])
+/* Compute B-Bone spline parameters for the given channel. */
+void BKE_pchan_bbone_spline_params_get(struct bPoseChannel *pchan, const bool rest, struct BBoneSplineParameters *param)
{
bPoseChannel *next, *prev;
Bone *bone = pchan->bone;
- BBoneSplineParameters param;
float imat[4][4], posemat[4][4];
float delta[3];
- memset(&param, 0, sizeof(param));
+ memset(param, 0, sizeof(*param));
- param.segments = bone->segments;
- param.length = bone->length;
+ param->segments = bone->segments;
+ param->length = bone->length;
if (!rest) {
float scale[3];
@@ -484,12 +482,12 @@ void b_bone_spline_setup(bPoseChannel *pchan, const bool rest, Mat4 result_array
mat4_to_size(scale, pchan->pose_mat);
if (fabsf(scale[0] - scale[1]) > 1e-6f || fabsf(scale[1] - scale[2]) > 1e-6f) {
- param.do_scale = true;
- copy_v3_v3(param.scale, scale);
+ param->do_scale = true;
+ copy_v3_v3(param->scale, scale);
}
}
- BKE_pchan_get_bbone_handles(pchan, &prev, &next);
+ BKE_pchan_bbone_handles_get(pchan, &prev, &next);
/* Find the handle points, since this is inside bone space, the
* first point = (0, 0, 0)
@@ -497,7 +495,7 @@ void b_bone_spline_setup(bPoseChannel *pchan, const bool rest, Mat4 result_array
if (rest) {
invert_m4_m4(imat, pchan->bone->arm_mat);
}
- else if (param.do_scale) {
+ else if (param->do_scale) {
copy_m4_m4(posemat, pchan->pose_mat);
normalize_m4(posemat);
invert_m4_m4(imat, posemat);
@@ -510,14 +508,14 @@ void b_bone_spline_setup(bPoseChannel *pchan, const bool rest, Mat4 result_array
float h1[3];
bool done = false;
- param.use_prev = true;
+ param->use_prev = true;
/* Transform previous point inside this bone space. */
if (bone->bbone_prev_type == BBONE_HANDLE_RELATIVE) {
/* Use delta movement (from restpose), and apply this relative to the current bone's head. */
if (rest) {
/* In restpose, arm_head == pose_head */
- zero_v3(param.prev_h);
+ zero_v3(param->prev_h);
done = true;
}
else {
@@ -538,19 +536,19 @@ void b_bone_spline_setup(bPoseChannel *pchan, const bool rest, Mat4 result_array
}
else {
/* Apply special handling for smoothly joining B-Bone chains */
- param.prev_bbone = (prev->bone->segments > 1);
+ param->prev_bbone = (prev->bone->segments > 1);
/* Use bone head as absolute position. */
copy_v3_v3(h1, rest ? prev->bone->arm_head : prev->pose_head);
}
if (!done) {
- mul_v3_m4v3(param.prev_h, imat, h1);
+ mul_v3_m4v3(param->prev_h, imat, h1);
}
- if (!param.prev_bbone) {
+ if (!param->prev_bbone) {
/* Find the previous roll to interpolate. */
- mul_m4_m4m4(param.prev_mat, imat, rest ? prev->bone->arm_mat : prev->pose_mat);
+ mul_m4_m4m4(param->prev_mat, imat, rest ? prev->bone->arm_mat : prev->pose_mat);
}
}
@@ -558,14 +556,14 @@ void b_bone_spline_setup(bPoseChannel *pchan, const bool rest, Mat4 result_array
float h2[3];
bool done = false;
- param.use_next = true;
+ param->use_next = true;
/* Transform next point inside this bone space. */
if (bone->bbone_next_type == BBONE_HANDLE_RELATIVE) {
/* Use delta movement (from restpose), and apply this relative to the current bone's tail. */
if (rest) {
/* In restpose, arm_head == pose_head */
- copy_v3_fl3(param.next_h, 0.0f, param.length, 0.0);
+ copy_v3_fl3(param->next_h, 0.0f, param->length, 0.0);
done = true;
}
else {
@@ -586,18 +584,18 @@ void b_bone_spline_setup(bPoseChannel *pchan, const bool rest, Mat4 result_array
}
else {
/* Apply special handling for smoothly joining B-Bone chains */
- param.next_bbone = (next->bone->segments > 1);
+ param->next_bbone = (next->bone->segments > 1);
/* Use bone tail as absolute position. */
copy_v3_v3(h2, rest ? next->bone->arm_tail : next->pose_tail);
}
if (!done) {
- mul_v3_m4v3(param.next_h, imat, h2);
+ mul_v3_m4v3(param->next_h, imat, h2);
}
/* Find the next roll to interpolate as well. */
- mul_m4_m4m4(param.next_mat, imat, rest ? next->bone->arm_mat : next->pose_mat);
+ mul_m4_m4m4(param->next_mat, imat, rest ? next->bone->arm_mat : next->pose_mat);
}
/* Add effects from bbone properties over the top
@@ -615,64 +613,65 @@ void b_bone_spline_setup(bPoseChannel *pchan, const bool rest, Mat4 result_array
* end up animating
*/
{
- param.ease1 = bone->ease1 + (!rest ? pchan->ease1 : 0.0f);
- param.ease2 = bone->ease2 + (!rest ? pchan->ease2 : 0.0f);
+ param->ease1 = bone->ease1 + (!rest ? pchan->ease1 : 0.0f);
+ param->ease2 = bone->ease2 + (!rest ? pchan->ease2 : 0.0f);
- param.roll1 = bone->roll1 + (!rest ? pchan->roll1 : 0.0f);
- param.roll2 = bone->roll2 + (!rest ? pchan->roll2 : 0.0f);
+ param->roll1 = bone->roll1 + (!rest ? pchan->roll1 : 0.0f);
+ param->roll2 = bone->roll2 + (!rest ? pchan->roll2 : 0.0f);
if (bone->flag & BONE_ADD_PARENT_END_ROLL) {
if (prev) {
if (prev->bone) {
- param.roll1 += prev->bone->roll2;
+ param->roll1 += prev->bone->roll2;
}
if (!rest) {
- param.roll1 += prev->roll2;
+ param->roll1 += prev->roll2;
}
}
}
- param.scaleIn = bone->scaleIn * (!rest ? pchan->scaleIn : 1.0f);
- param.scaleOut = bone->scaleOut * (!rest ? pchan->scaleOut : 1.0f);
+ param->scaleIn = bone->scaleIn * (!rest ? pchan->scaleIn : 1.0f);
+ param->scaleOut = bone->scaleOut * (!rest ? pchan->scaleOut : 1.0f);
/* Extra curve x / y */
- param.curveInX = bone->curveInX + (!rest ? pchan->curveInX : 0.0f);
- param.curveInY = bone->curveInY + (!rest ? pchan->curveInY : 0.0f);
+ param->curveInX = bone->curveInX + (!rest ? pchan->curveInX : 0.0f);
+ param->curveInY = bone->curveInY + (!rest ? pchan->curveInY : 0.0f);
- param.curveOutX = bone->curveOutX + (!rest ? pchan->curveOutX : 0.0f);
- param.curveOutY = bone->curveOutY + (!rest ? pchan->curveOutY : 0.0f);
+ param->curveOutX = bone->curveOutX + (!rest ? pchan->curveOutX : 0.0f);
+ param->curveOutY = bone->curveOutY + (!rest ? pchan->curveOutY : 0.0f);
}
-
- bone->segments = BKE_compute_b_bone_spline(&param, result_array);
}
/* Fills the array with the desired amount of bone->segments elements.
* This calculation is done within unit bone space. */
-int BKE_compute_b_bone_spline(BBoneSplineParameters *param, Mat4 result_array[MAX_BBONE_SUBDIV])
+void BKE_pchan_bbone_spline_setup(bPoseChannel *pchan, const bool rest, Mat4 result_array[MAX_BBONE_SUBDIV])
{
- float scalemat[4][4], iscalemat[4][4];
- float mat3[3][3];
- float h1[3], roll1, h2[3], roll2;
- float data[MAX_BBONE_SUBDIV + 1][4], *fp;
- int a;
+ BBoneSplineParameters param;
+ BKE_pchan_bbone_spline_params_get(pchan, rest, &param);
+
+ pchan->bone->segments = BKE_pchan_bbone_spline_compute(&param, result_array);
+}
+
+/* Computes the bezier handle vectors and rolls coming from custom handles. */
+void BKE_pchan_bbone_handles_compute(const BBoneSplineParameters *param, float h1[3], float *r_roll1, float h2[3], float *r_roll2, bool ease, bool offsets)
+{
+ float mat3[3][3];
float length = param->length;
if (param->do_scale) {
- size_to_mat4(scalemat, param->scale);
- invert_m4_m4(iscalemat, scalemat);
-
length *= param->scale[1];
}
+ *r_roll1 = *r_roll2 = 0.0f;
+
if (param->use_prev) {
copy_v3_v3(h1, param->prev_h);
if (param->prev_bbone) {
/* If previous bone is B-bone too, use average handle direction. */
h1[1] -= length;
- roll1 = 0.0f;
}
normalize_v3(h1);
@@ -681,12 +680,11 @@ int BKE_compute_b_bone_spline(BBoneSplineParameters *param, Mat4 result_array[MA
if (!param->prev_bbone) {
/* Find the previous roll to interpolate. */
copy_m3_m4(mat3, param->prev_mat);
- mat3_vec_to_roll(mat3, h1, &roll1);
+ mat3_vec_to_roll(mat3, h1, r_roll1);
}
}
else {
h1[0] = 0.0f; h1[1] = 1.0; h1[2] = 0.0f;
- roll1 = 0.0f;
}
if (param->use_next) {
@@ -704,14 +702,13 @@ int BKE_compute_b_bone_spline(BBoneSplineParameters *param, Mat4 result_array[MA
/* Find the next roll to interpolate as well. */
copy_m3_m4(mat3, param->next_mat);
- mat3_vec_to_roll(mat3, h2, &roll2);
+ mat3_vec_to_roll(mat3, h2, r_roll2);
}
else {
h2[0] = 0.0f; h2[1] = 1.0f; h2[2] = 0.0f;
- roll2 = 0.0;
}
- {
+ if (ease) {
const float circle_factor = length * (cubic_tangent_factor_circle_v3(h1, h2) / 0.75f);
const float hlength1 = param->ease1 * circle_factor;
@@ -736,10 +733,10 @@ int BKE_compute_b_bone_spline(BBoneSplineParameters *param, Mat4 result_array[MA
* - The "pchan" level offsets are the ones that animators actually
* end up animating
*/
- {
+ if (offsets) {
/* Add extra rolls. */
- roll1 += param->roll1;
- roll2 += param->roll2;
+ *r_roll1 += param->roll1;
+ *r_roll2 += param->roll2;
/* Extra curve x / y */
/* NOTE: Scale correction factors here are to compensate for some random floating-point glitches
@@ -755,6 +752,27 @@ int BKE_compute_b_bone_spline(BBoneSplineParameters *param, Mat4 result_array[MA
h2[0] += param->curveOutX * xscale_correction;
h2[2] += param->curveOutY * yscale_correction;
}
+}
+
+/* Fills the array with the desired amount of bone->segments elements.
+ * This calculation is done within unit bone space. */
+int BKE_pchan_bbone_spline_compute(BBoneSplineParameters *param, Mat4 result_array[MAX_BBONE_SUBDIV])
+{
+ float scalemat[4][4], iscalemat[4][4];
+ float mat3[3][3];
+ float h1[3], roll1, h2[3], roll2;
+ float data[MAX_BBONE_SUBDIV + 1][4], *fp;
+ float length = param->length;
+ int a;
+
+ if (param->do_scale) {
+ size_to_mat4(scalemat, param->scale);
+ invert_m4_m4(iscalemat, scalemat);
+
+ length *= param->scale[1];
+ }
+
+ BKE_pchan_bbone_handles_compute(param, h1, &roll1, h2, &roll2, true, true);
/* Make curve. */
CLAMP_MAX(param->segments, MAX_BBONE_SUBDIV);
@@ -840,7 +858,7 @@ static void allocate_bbone_cache(bPoseChannel *pchan, int segments)
}
/** Compute and cache the B-Bone shape in the channel runtime struct. */
-void BKE_pchan_cache_bbone_segments(bPoseChannel *pchan)
+void BKE_pchan_bbone_segments_cache_compute(bPoseChannel *pchan)
{
bPoseChannelRuntime *runtime = &pchan->runtime;
Bone *bone = pchan->bone;
@@ -858,8 +876,8 @@ void BKE_pchan_cache_bbone_segments(bPoseChannel *pchan)
DualQuat *b_bone_dual_quats = runtime->bbone_dual_quats;
int a;
- b_bone_spline_setup(pchan, false, b_bone);
- b_bone_spline_setup(pchan, true, b_bone_rest);
+ BKE_pchan_bbone_spline_setup(pchan, false, b_bone);
+ BKE_pchan_bbone_spline_setup(pchan, true, b_bone_rest);
/* Compute deform matrices. */
/* first matrix is the inverse arm_mat, to bring points in local bone space
@@ -883,7 +901,7 @@ void BKE_pchan_cache_bbone_segments(bPoseChannel *pchan)
}
/** Copy cached B-Bone segments from one channel to another */
-void BKE_pchan_copy_bbone_segments_cache(bPoseChannel *pchan, bPoseChannel *pchan_from)
+void BKE_pchan_bbone_segments_cache_copy(bPoseChannel *pchan, bPoseChannel *pchan_from)
{
bPoseChannelRuntime *runtime = &pchan->runtime;
bPoseChannelRuntime *runtime_from = &pchan_from->runtime;
@@ -1150,7 +1168,7 @@ void armature_deform_verts(
*
* TODO(sergey): Make this code robust somehow when there are dependency
* cycles involved. */
- ObjectBBoneDeform * bbone_deform =
+ ObjectBBoneDeform *bbone_deform =
BKE_armature_cached_bbone_deformation_get(armOb);
if (bbone_deform == NULL || bbone_deform->pdef_info_array == NULL) {
fprintf(stderr,
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index b917aae08de..1460a3cb205 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -715,17 +715,24 @@ void BKE_pose_bone_done(struct Depsgraph *depsgraph,
copy_v3_v3(pchan_orig->pose_head, pchan->pose_mat[3]);
copy_m4_m4(pchan_orig->constinv, pchan->constinv);
BKE_pose_where_is_bone_tail(pchan_orig);
+ if (pchan->bone == NULL || pchan->bone->segments <= 1) {
+ BKE_pose_channel_free_bbone_cache(pchan_orig);
+ }
}
}
void BKE_pose_eval_bbone_segments(struct Depsgraph *depsgraph,
- struct Object *ob,
- int pchan_index)
+ struct Object *ob,
+ int pchan_index)
{
bPoseChannel *pchan = pose_pchan_get_indexed(ob, pchan_index);
DEG_debug_print_eval(depsgraph, __func__, pchan->name, pchan);
if (pchan->bone != NULL && pchan->bone->segments > 1) {
- BKE_pchan_cache_bbone_segments(pchan);
+ BKE_pchan_bbone_segments_cache_compute(pchan);
+ bArmature *arm = (bArmature *)ob->data;
+ if (DEG_is_active(depsgraph) && arm->edbo == NULL) {
+ BKE_pchan_bbone_segments_cache_copy(pchan->orig_pchan, pchan);
+ }
}
}
@@ -850,5 +857,5 @@ void BKE_pose_eval_proxy_copy_bone(
BLI_assert(pchan != NULL);
BLI_assert(pchan_from != NULL);
BKE_pose_copyesult_pchan_result(pchan, pchan_from);
- BKE_pchan_copy_bbone_segments_cache(pchan, pchan_from);
+ BKE_pchan_bbone_segments_cache_copy(pchan, pchan_from);
}
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index f1b1aa548d2..0ba19d5b4da 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -307,8 +307,6 @@ void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *use
LIST_SWAP(addons);
LIST_SWAP(user_keymaps);
- DATA_SWAP(light);
-
DATA_SWAP(font_path_ui);
DATA_SWAP(font_path_ui_mono);
DATA_SWAP(keyconfigstr);
diff --git a/source/blender/blenkernel/intern/boolean.c b/source/blender/blenkernel/intern/boolean.c
index 3e70de314f4..f9f4de563fa 100644
--- a/source/blender/blenkernel/intern/boolean.c
+++ b/source/blender/blenkernel/intern/boolean.c
@@ -67,210 +67,211 @@ static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data))
static Mesh *get_quick_mesh(
- Object *ob_self, Mesh *mesh_self,
- Object *ob_other, Mesh *mesh_other,
- int operation)
+ Object *ob_self, Mesh *mesh_self,
+ Object *ob_other, Mesh *mesh_other,
+ int operation)
{
- Mesh *result = NULL;
-
- if (mesh_self->totpoly == 0 || mesh_other->totpoly == 0) {
- switch (operation) {
- case eBooleanModifierOp_Intersect:
- result = BKE_mesh_new_nomain(0, 0, 0, 0, 0);
- break;
-
- case eBooleanModifierOp_Union:
- if (mesh_self->totpoly != 0) {
- result = mesh_self;
- }
- else {
- BKE_id_copy_ex(NULL, &mesh_other->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);
-
- float imat[4][4];
- float omat[4][4];
-
- invert_m4_m4(imat, ob_self->obmat);
- mul_m4_m4m4(omat, imat, ob_other->obmat);
-
- const int mverts_len = result->totvert;
- MVert *mv = result->mvert;
-
- for (int i = 0; i < mverts_len; i++, mv++) {
- mul_m4_v3(omat, mv->co);
- }
-
- result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
- }
-
- break;
-
- case eBooleanModifierOp_Difference:
- result = mesh_self;
- break;
- }
- }
-
- return result;
+ Mesh *result = NULL;
+
+ if (mesh_self->totpoly == 0 || mesh_other->totpoly == 0) {
+ switch (operation) {
+ case eBooleanModifierOp_Intersect:
+ result = BKE_mesh_new_nomain(0, 0, 0, 0, 0);
+ break;
+
+ case eBooleanModifierOp_Union:
+ if (mesh_self->totpoly != 0) {
+ result = mesh_self;
+ }
+ else {
+ BKE_id_copy_ex(NULL, &mesh_other->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);
+
+ float imat[4][4];
+ float omat[4][4];
+
+ invert_m4_m4(imat, ob_self->obmat);
+ mul_m4_m4m4(omat, imat, ob_other->obmat);
+
+ const int mverts_len = result->totvert;
+ MVert *mv = result->mvert;
+
+ for (int i = 0; i < mverts_len; i++, mv++) {
+ mul_m4_v3(omat, mv->co);
+ }
+
+ result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
+ }
+
+ break;
+
+ case eBooleanModifierOp_Difference:
+ result = mesh_self;
+ break;
+ }
+ }
+
+ return result;
}
Mesh *BKE_boolean_operation(Mesh *mesh, struct Object *ob,
- Mesh *mesh_other, struct Object *ob_other, int op_type,
- float double_threshold, struct BooleanModifierData *bmd)
+ Mesh *mesh_other, struct Object *ob_other, int op_type,
+ float double_threshold, struct BooleanModifierData *bmd)
{
- Mesh *result = mesh;
+ Mesh *result = mesh;
- if (mesh_other) {
- Object *object = ob;
- Object *other = ob_other;
+ if (mesh_other) {
+ Object *object = ob;
+ Object *other = ob_other;
- /* when one of objects is empty (has got no faces) we could speed up
- * calculation a bit returning one of objects' derived meshes (or empty one)
- * Returning mesh is depended on modifiers operation (sergey) */
- result = get_quick_mesh(object, mesh, other, mesh_other, op_type);
+ /* when one of objects is empty (has got no faces) we could speed up
+ * calculation a bit returning one of objects' derived meshes (or empty one)
+ * Returning mesh is depended on modifiers operation (sergey) */
+ result = get_quick_mesh(object, mesh, other, mesh_other, op_type);
- if (result == NULL) {
- const bool is_flip = (is_negative_m4(object->obmat) != is_negative_m4(other->obmat));
+ if (result == NULL) {
+ const bool is_flip = (is_negative_m4(object->obmat) != is_negative_m4(other->obmat));
- BMesh *bm;
- const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh, mesh_other);
+ BMesh *bm;
+ const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh, mesh_other);
#ifdef DEBUG_TIME
- TIMEIT_START(boolean_bmesh);
+ TIMEIT_START(boolean_bmesh);
#endif
- bm = BM_mesh_create(
- &allocsize,
- &((struct BMeshCreateParams){.use_toolflags = false,}));
-
- BM_mesh_bm_from_me(bm, mesh_other, &((struct BMeshFromMeshParams){.calc_face_normal = true,}));
-
- if (UNLIKELY(is_flip)) {
- const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
- BMIter iter;
- BMFace *efa;
- BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- BM_face_normal_flip_ex(bm, efa, cd_loop_mdisp_offset, true);
- }
- }
-
- BM_mesh_bm_from_me(bm, mesh, &((struct BMeshFromMeshParams){.calc_face_normal = true,}));
-
- /* main bmesh intersection setup */
- {
- /* create tessface & intersect */
- const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
- int tottri;
- BMLoop *(*looptris)[3];
-
- looptris = MEM_malloc_arrayN(looptris_tot, sizeof(*looptris), __func__);
-
- BM_mesh_calc_tessellation_beauty(bm, looptris, &tottri);
-
- /* postpone this until after tessellating
- * so we can use the original normals before the vertex are moved */
- {
- BMIter iter;
- int i;
- const int i_verts_end = mesh_other->totvert;
- const int i_faces_end = mesh_other->totpoly;
-
- float imat[4][4];
- float omat[4][4];
-
- invert_m4_m4(imat, object->obmat);
- mul_m4_m4m4(omat, imat, other->obmat);
-
- BMVert *eve;
- i = 0;
- BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- mul_m4_v3(omat, eve->co);
- if (++i == i_verts_end) {
- break;
- }
- }
-
- /* we need face normals because of 'BM_face_split_edgenet'
- * we could calculate on the fly too (before calling split). */
- {
- float nmat[3][3];
- copy_m3_m4(nmat, omat);
- invert_m3(nmat);
-
- if (UNLIKELY(is_flip)) {
- negate_m3(nmat);
- }
-
- const short ob_src_totcol = other->totcol;
- short *material_remap = BLI_array_alloca(material_remap, ob_src_totcol ? ob_src_totcol : 1);
-
- /* Using original (not evaluated) object here since we are writing to it. */
- BKE_material_remap_object_calc(ob, other, material_remap);
-
- BMFace *efa;
- i = 0;
- BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- mul_transposed_m3_v3(nmat, efa->no);
- normalize_v3(efa->no);
- BM_elem_flag_enable(efa, BM_FACE_TAG); /* temp tag to test which side split faces are from */
-
- /* remap material */
- if (LIKELY(efa->mat_nr < ob_src_totcol)) {
- efa->mat_nr = material_remap[efa->mat_nr];
- }
-
- if (++i == i_faces_end) {
- break;
- }
- }
- }
- }
-
- /* not needed, but normals for 'dm' will be invalid,
- * currently this is ok for 'BM_mesh_intersect' */
- // BM_mesh_normals_update(bm);
-
- bool use_separate = false;
- bool use_dissolve = true;
- bool use_island_connect = true;
-
- /* change for testing */
- if (G.debug & G_DEBUG && bmd) {
- use_separate = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_Separate) != 0;
- use_dissolve = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_NoDissolve) == 0;
- use_island_connect = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_NoConnectRegions) == 0;
- }
-
- BM_mesh_intersect(
- bm,
- looptris, tottri,
- bm_face_isect_pair, NULL,
- false,
- use_separate,
- use_dissolve,
- use_island_connect,
- false,
- false,
- op_type,
- double_threshold);
-
- MEM_freeN(looptris);
- }
-
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
-
- BM_mesh_free(bm);
-
- result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
+ bm = BM_mesh_create(
+ &allocsize,
+ &((struct BMeshCreateParams){.use_toolflags = false,}));
+
+ BM_mesh_bm_from_me(bm, mesh_other, &((struct BMeshFromMeshParams){.calc_face_normal = true,}));
+
+ if (UNLIKELY(is_flip)) {
+ const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
+ BMIter iter;
+ BMFace *efa;
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+ BM_face_normal_flip_ex(bm, efa, cd_loop_mdisp_offset, true);
+ }
+ }
+
+ BM_mesh_bm_from_me(bm, mesh, &((struct BMeshFromMeshParams){.calc_face_normal = true,}));
+
+ /* main bmesh intersection setup */
+ {
+ /* create tessface & intersect */
+ const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
+ int tottri;
+ BMLoop *(*looptris)[3];
+
+ looptris = MEM_malloc_arrayN(looptris_tot, sizeof(*looptris), __func__);
+
+ BM_mesh_calc_tessellation_beauty(bm, looptris, &tottri);
+
+ /* postpone this until after tessellating
+ * so we can use the original normals before the vertex are moved */
+ {
+ BMIter iter;
+ int i;
+ const int i_verts_end = mesh_other->totvert;
+ const int i_faces_end = mesh_other->totpoly;
+
+ float imat[4][4];
+ float omat[4][4];
+
+ invert_m4_m4(imat, object->obmat);
+ mul_m4_m4m4(omat, imat, other->obmat);
+
+ BMVert *eve;
+ i = 0;
+ BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+ mul_m4_v3(omat, eve->co);
+ if (++i == i_verts_end) {
+ break;
+ }
+ }
+
+ /* we need face normals because of 'BM_face_split_edgenet'
+ * we could calculate on the fly too (before calling split). */
+ {
+ float nmat[3][3];
+ copy_m3_m4(nmat, omat);
+ invert_m3(nmat);
+
+ if (UNLIKELY(is_flip)) {
+ negate_m3(nmat);
+ }
+
+ const short ob_src_totcol = other->totcol;
+ short *material_remap = BLI_array_alloca(material_remap, ob_src_totcol ? ob_src_totcol : 1);
+
+ /* Using original (not evaluated) object here since we are writing to it. */
+ /* XXX Pretty sure comment above is fully wrong now with CoW & co ? */
+ BKE_material_remap_object_calc(ob, other, material_remap);
+
+ BMFace *efa;
+ i = 0;
+ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+ mul_transposed_m3_v3(nmat, efa->no);
+ normalize_v3(efa->no);
+ BM_elem_flag_enable(efa, BM_FACE_TAG); /* temp tag to test which side split faces are from */
+
+ /* remap material */
+ if (LIKELY(efa->mat_nr < ob_src_totcol)) {
+ efa->mat_nr = material_remap[efa->mat_nr];
+ }
+
+ if (++i == i_faces_end) {
+ break;
+ }
+ }
+ }
+ }
+
+ /* not needed, but normals for 'dm' will be invalid,
+ * currently this is ok for 'BM_mesh_intersect' */
+ // BM_mesh_normals_update(bm);
+
+ bool use_separate = false;
+ bool use_dissolve = true;
+ bool use_island_connect = true;
+
+ /* change for testing */
+ if (G.debug & G_DEBUG && bmd) {
+ use_separate = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_Separate) != 0;
+ use_dissolve = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_NoDissolve) == 0;
+ use_island_connect = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_NoConnectRegions) == 0;
+ }
+
+ BM_mesh_intersect(
+ bm,
+ looptris, tottri,
+ bm_face_isect_pair, NULL,
+ false,
+ use_separate,
+ use_dissolve,
+ use_island_connect,
+ false,
+ false,
+ op_type,
+ double_threshold);
+
+ MEM_freeN(looptris);
+ }
+
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+
+ BM_mesh_free(bm);
+
+ result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
#ifdef DEBUG_TIME
- TIMEIT_END(boolean_bmesh);
+ TIMEIT_END(boolean_bmesh);
#endif
- }
- }
+ }
+ }
- return result;
+ return result;
}
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index 88a4b7905ef..0ada712a855 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -616,9 +616,7 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
rewrite_path_fixed(seq->strip->dir, visit_cb, absbase, bpath_user_data);
}
}
-
- }
- SEQ_END
+ } SEQ_END;
}
break;
}
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index e10cfc38164..75e1884f9a3 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -146,7 +146,7 @@ void cloth_init(ClothModifierData *clmd )
clmd->sim_parms->bending_model = CLOTH_BENDING_ANGULAR;
if (!clmd->sim_parms->effector_weights)
- clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL);
+ clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL);
if (clmd->point_cache)
clmd->point_cache->step = 1;
@@ -804,7 +804,6 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, Mesh *mesh, fl
if ( !cloth_build_springs ( clmd, mesh ) ) {
cloth_free_modifier ( clmd );
modifier_setError(&(clmd->modifier), "Cannot build springs");
- printf("cloth_free_modifier cloth_build_springs\n");
return 0;
}
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 7b7898392d4..763c0d51cb5 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -512,7 +512,7 @@ static bool collection_object_add(Main *bmain, Collection *collection, Object *o
}
if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
- DEG_id_tag_update_ex(bmain, &collection->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, &collection->id, ID_RECALC_COPY_ON_WRITE);
}
return true;
@@ -535,7 +535,7 @@ static bool collection_object_remove(Main *bmain, Collection *collection, Object
id_us_min(&ob->id);
}
- DEG_id_tag_update_ex(bmain, &collection->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, &collection->id, ID_RECALC_COPY_ON_WRITE);
return true;
}
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 108e188fe92..60a7653cd1a 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -1569,17 +1569,33 @@ void BKE_color_managed_display_settings_copy(ColorManagedDisplaySettings *new_se
BLI_strncpy(new_settings->display_device, settings->display_device, sizeof(new_settings->display_device));
}
-void BKE_color_managed_view_settings_init(ColorManagedViewSettings *settings)
+void BKE_color_managed_view_settings_init_render(
+ ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings)
{
- /* OCIO_TODO: use default view transform here when OCIO is completely integrated
- * and proper versioning stuff is added.
- * for now use NONE to be compatible with all current files
- */
- BLI_strncpy(settings->view_transform, "Default", sizeof(settings->view_transform));
- BLI_strncpy(settings->look, "None", sizeof(settings->look));
-
- settings->gamma = 1.0f;
- settings->exposure = 0.0f;
+ struct ColorManagedDisplay *display =
+ IMB_colormanagement_display_get_named(
+ display_settings->display_device);
+ BLI_strncpy(
+ view_settings->view_transform,
+ IMB_colormanagement_display_get_default_view_transform_name(display),
+ sizeof(view_settings->view_transform));
+ /* TODO(sergey): Find a way to make look query more reliable with non
+ * default configuration. */
+ BLI_strncpy(view_settings->look, "None", sizeof(view_settings->look));
+
+ view_settings->flag = 0;
+ view_settings->gamma = 1.0f;
+ view_settings->exposure = 0.0f;
+ view_settings->curve_mapping = NULL;
+}
+
+void BKE_color_managed_view_settings_init_default(
+ struct ColorManagedViewSettings *view_settings,
+ const struct ColorManagedDisplaySettings *display_settings)
+{
+ IMB_colormanagement_init_default_view_settings(
+ view_settings, display_settings);
}
void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings,
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 8c31b830ff7..a1bc7aca6e1 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -110,6 +110,7 @@
static void damptrack_do_transform(float matrix[4][4], const float tarvec[3], int track_axis);
static bConstraint *constraint_find_original(Object *ob, bPoseChannel *pchan, bConstraint *con, Object **r_orig_ob);
+static bConstraint *constraint_find_original_for_update(bConstraintOb *cob, bConstraint *con);
/* -------------- Naming -------------- */
@@ -2819,9 +2820,19 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
dist = len_v3v3(cob->matrix[3], ct->matrix[3]);
/* set distance (flag is only set when user demands it) */
- if (data->dist == 0)
+ if (data->dist == 0) {
data->dist = dist;
+ /* Write the computed distance back to the master copy if in COW evaluation. */
+ bConstraint *orig_con = constraint_find_original_for_update(cob, con);
+
+ if (orig_con != NULL) {
+ bDistLimitConstraint *orig_data = orig_con->data;
+
+ orig_data->dist = data->dist;
+ }
+ }
+
/* check if we're which way to clamp from, and calculate interpolation factor (if needed) */
if (data->mode == LIMITDIST_OUTSIDE) {
/* if inside, then move to surface */
@@ -2973,17 +2984,12 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
data->orglength = dist;
/* Write the computed length back to the master copy if in COW evaluation. */
- if (DEG_is_active(cob->depsgraph)) {
- Object *orig_ob = NULL;
- bConstraint *orig_con = constraint_find_original(cob->ob, cob->pchan, con, &orig_ob);
-
- if (orig_con != NULL) {
- bStretchToConstraint *orig_data = orig_con->data;
+ bConstraint *orig_con = constraint_find_original_for_update(cob, con);
- orig_data->orglength = data->orglength;
+ if (orig_con != NULL) {
+ bStretchToConstraint *orig_data = orig_con->data;
- DEG_id_tag_update(&orig_ob->id, DEG_TAG_COPY_ON_WRITE | DEG_TAG_TRANSFORM);
- }
+ orig_data->orglength = data->orglength;
}
}
@@ -5140,6 +5146,23 @@ static bConstraint *constraint_find_original(Object *ob, bPoseChannel *pchan, bC
return NULL;
}
+static bConstraint *constraint_find_original_for_update(bConstraintOb *cob, bConstraint *con)
+{
+ /* Write the computed distance back to the master copy if in COW evaluation. */
+ if (!DEG_is_active(cob->depsgraph)) {
+ return NULL;
+ }
+
+ Object *orig_ob = NULL;
+ bConstraint *orig_con = constraint_find_original(cob->ob, cob->pchan, con, &orig_ob);
+
+ if (orig_con != NULL) {
+ DEG_id_tag_update(&orig_ob->id, ID_RECALC_COPY_ON_WRITE | ID_RECALC_TRANSFORM);
+ }
+
+ return orig_con;
+}
+
/* -------- Constraints and Proxies ------- */
/* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL (i.e. added to bone that's proxy-synced in this file) */
diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index 354cc4926f1..da4f14b5014 100644
--- a/source/blender/blenkernel/intern/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -50,6 +50,8 @@
#include "BKE_editmesh.h"
#include "BKE_library.h"
+#include "DEG_depsgraph_query.h"
+
BLI_INLINE void tan_calc_quat_v3(
float r_quat[4],
const float co_1[3], const float co_2[3], const float co_3[3])
@@ -117,7 +119,7 @@ float (*BKE_crazyspace_get_mapped_editverts(
/* now get the cage */
vertexcos = MEM_mallocN(sizeof(*vertexcos) * nverts, "vertexcos map");
- me_eval = editbmesh_get_eval_cage(depsgraph, scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH);
+ me_eval = editbmesh_get_eval_cage_from_orig(depsgraph, scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH);
mesh_get_mapped_verts_coords(me_eval, vertexcos, nverts);
@@ -313,17 +315,18 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
int BKE_sculpt_get_first_deform_matrices(
struct Depsgraph *depsgraph, Scene *scene,
- Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
+ Object *object, float (**deformmats)[3][3], float (**deformcos)[3])
{
ModifierData *md;
Mesh *me_eval;
int a, numVerts = 0;
float (*defmats)[3][3] = NULL, (*deformedVerts)[3] = NULL;
- MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
- const bool has_multires = mmd != NULL && mmd->sculptlvl > 0;
int numleft = 0;
VirtualModifierData virtualModifierData;
- const ModifierEvalContext mectx = {depsgraph, ob, 0};
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
+ MultiresModifierData *mmd = get_multires_modifier(scene, object_eval, 0);
+ const bool has_multires = mmd != NULL && mmd->sculptlvl > 0;
+ const ModifierEvalContext mectx = {depsgraph, object_eval, 0};
if (has_multires) {
*deformmats = NULL;
@@ -332,7 +335,7 @@ int BKE_sculpt_get_first_deform_matrices(
}
me_eval = NULL;
- md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
+ md = modifiers_getVirtualModifierList(object_eval, &virtualModifierData);
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -341,7 +344,8 @@ int BKE_sculpt_get_first_deform_matrices(
if (mti->type == eModifierTypeType_OnlyDeform) {
if (!defmats) {
- Mesh *me = ob->data;
+ /* NOTE: Need to start with original undeformed mesh. */
+ Mesh *me = object->data;
me_eval = BKE_mesh_copy_for_eval(me, true);
deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
defmats = MEM_callocN(sizeof(*defmats) * numVerts, "defmats");
@@ -376,9 +380,11 @@ int BKE_sculpt_get_first_deform_matrices(
return numleft;
}
-void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
+void BKE_crazyspace_build_sculpt(
+ struct Depsgraph *depsgraph, Scene *scene, Object *object,
+ float (**deformmats)[3][3], float (**deformcos)[3])
{
- int totleft = BKE_sculpt_get_first_deform_matrices(depsgraph, scene, ob, deformmats, deformcos);
+ int totleft = BKE_sculpt_get_first_deform_matrices(depsgraph, scene, object, deformmats, deformcos);
if (totleft) {
/* there are deformation modifier which doesn't support deformation matrices
@@ -389,9 +395,10 @@ void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph, Scene *scene, Obje
float (*quats)[4];
int i, deformed = 0;
VirtualModifierData virtualModifierData;
- ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
- const ModifierEvalContext mectx = {depsgraph, ob, 0};
- Mesh *me = (Mesh *)ob->data;
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
+ ModifierData *md = modifiers_getVirtualModifierList(object_eval, &virtualModifierData);
+ const ModifierEvalContext mectx = {depsgraph, object_eval, 0};
+ Mesh *mesh = (Mesh *)object->data;
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -404,16 +411,16 @@ void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph, Scene *scene, Obje
if (mti->deformMatrices && !deformed)
continue;
- mti->deformVerts(md, &mectx, NULL, deformedVerts, me->totvert);
+ mti->deformVerts(md, &mectx, NULL, deformedVerts, mesh->totvert);
deformed = 1;
}
}
- quats = MEM_mallocN(me->totvert * sizeof(*quats), "crazy quats");
+ quats = MEM_mallocN(mesh->totvert * sizeof(*quats), "crazy quats");
- BKE_crazyspace_set_quats_mesh(me, origVerts, deformedVerts, quats);
+ BKE_crazyspace_set_quats_mesh(mesh, origVerts, deformedVerts, quats);
- for (i = 0; i < me->totvert; i++) {
+ for (i = 0; i < mesh->totvert; i++) {
float qmat[3][3], tmat[3][3];
quat_to_mat3(qmat, quats[i]);
@@ -427,9 +434,9 @@ void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph, Scene *scene, Obje
if (*deformmats == NULL) {
int a, numVerts;
- Mesh *me = (Mesh *)ob->data;
+ Mesh *mesh = (Mesh *)object->data;
- *deformcos = BKE_mesh_vertexCos_get(me, &numVerts);
+ *deformcos = BKE_mesh_vertexCos_get(mesh, &numVerts);
*deformmats = MEM_callocN(sizeof(*(*deformmats)) * numVerts, "defmats");
for (a = 0; a < numVerts; a++)
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 872b5074e4e..527b950406b 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -325,16 +325,22 @@ void BKE_curve_boundbox_calc(Curve *cu, float r_loc[3], float r_size[3])
BoundBox *BKE_curve_boundbox_get(Object *ob)
{
- Curve *cu = ob->data;
+ /* This is Object-level data access, DO NOT touch to Mesh's bb, would be totally thread-unsafe. */
+ if (ob->bb == NULL || ob->bb->flag & BOUNDBOX_DIRTY) {
+ Curve *cu = ob->data;
+ float min[3], max[3];
- if (ob->bb)
- return ob->bb;
+ INIT_MINMAX(min, max);
+ BKE_curve_minmax(cu, true, min, max);
- if (cu->bb == NULL || (cu->bb->flag & BOUNDBOX_DIRTY)) {
- BKE_curve_texspace_calc(cu);
+ if (ob->bb == NULL) {
+ ob->bb = MEM_mallocN(sizeof(*ob->bb), __func__);
+ }
+ BKE_boundbox_init_from_minmax(ob->bb, min, max);
+ ob->bb->flag &= ~BOUNDBOX_DIRTY;
}
- return cu->bb;
+ return ob->bb;
}
void BKE_curve_texspace_calc(Curve *cu)
@@ -5290,7 +5296,7 @@ bool BKE_curve_material_index_validate(Curve *cu)
}
if (!is_valid) {
- DEG_id_tag_update(&cu->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&cu->id, ID_RECALC_GEOMETRY);
return true;
}
else {
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 745d5b9d509..aec471ef661 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -126,6 +126,9 @@ typedef struct LayerTypeInfo {
* default is assumed to be all zeros */
void (*set_default)(void *data, int count);
+ /** A function used by mesh validating code, must ensures passed item has valid data. */
+ cd_validate validate;
+
/** functions necessary for geometry collapse */
bool (*equal)(const void *data1, const void *data2);
void (*multiply)(void *data, float fac);
@@ -313,6 +316,30 @@ static void layerInterp_normal(
normalize_v3_v3((float *)dest, no);
}
+static bool layerValidate_normal(void *data, const uint totitems, const bool do_fixes)
+{
+ static const float no_default[3] = {0.0f, 0.0f, 1.0f}; /* Z-up default normal... */
+ float (*no)[3] = data;
+ bool has_errors = false;
+
+ for (int i = 0; i < totitems; i++, no++) {
+ if (!is_finite_v3((float *)no)) {
+ has_errors = true;
+ if (do_fixes) {
+ copy_v3_v3((float *)no, no_default);
+ }
+ }
+ else if (!compare_ff(len_squared_v3((float *)no), 1.0f, 1e-6f)) {
+ has_errors = true;
+ if (do_fixes) {
+ normalize_v3((float *)no);
+ }
+ }
+ }
+
+ return has_errors;
+}
+
static void layerCopyValue_normal(const void *source, void *dest, const int mixmode, const float mixfactor)
{
const float *no_src = source;
@@ -422,6 +449,23 @@ static void layerCopy_propFloat(const void *source, void *dest,
memcpy(dest, source, sizeof(MFloatProperty) * count);
}
+static bool layerValidate_propFloat(void *data, const uint totitems, const bool do_fixes)
+{
+ MFloatProperty *fp = data;
+ bool has_errors = false;
+
+ for (int i = 0; i < totitems; i++, fp++) {
+ if (!isfinite(fp->f)) {
+ if (do_fixes) {
+ fp->f = 0.0f;
+ }
+ has_errors = true;
+ }
+ }
+
+ return has_errors;
+}
+
static void layerCopy_propInt(const void *source, void *dest,
int count)
{
@@ -909,6 +953,23 @@ static void layerInterp_mloopuv(
((MLoopUV *)dest)->flag = flag;
}
+static bool layerValidate_mloopuv(void *data, const uint totitems, const bool do_fixes)
+{
+ MLoopUV *uv = data;
+ bool has_errors = false;
+
+ for (int i = 0; i < totitems; i++, uv++) {
+ if (!is_finite_v2(uv->uv)) {
+ if (do_fixes) {
+ zero_v2(uv->uv);
+ }
+ has_errors = true;
+ }
+ }
+
+ return has_errors;
+}
+
/* origspace is almost exact copy of mloopuv's, keep in sync */
static void layerCopyValue_mloop_origspace(const void *source, void *dest,
const int UNUSED(mixmode), const float UNUSED(mixfactor))
@@ -1193,21 +1254,22 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
{sizeof(MFace), "MFace", 1, NULL, NULL, NULL, NULL, NULL, NULL},
/* 5: CD_MTFACE */
{sizeof(MTFace), "MTFace", 1, N_("UVMap"), layerCopy_tface, NULL, layerInterp_tface, layerSwap_tface,
- layerDefault_tface, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, layerMaxNum_tface},
+ layerDefault_tface, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, layerMaxNum_tface},
/* 6: CD_MCOL */
/* 4 MCol structs per face */
- {sizeof(MCol) * 4, "MCol", 4, N_("Col"), NULL, NULL, layerInterp_mcol,
- layerSwap_mcol, layerDefault_mcol, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, layerMaxNum_mloopcol},
+ {sizeof(MCol) * 4, "MCol", 4, N_("Col"), NULL, NULL, layerInterp_mcol, layerSwap_mcol,
+ layerDefault_mcol, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, layerMaxNum_mloopcol},
/* 7: CD_ORIGINDEX */
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, layerDefault_origindex},
/* 8: CD_NORMAL */
/* 3 floats per normal vector */
{sizeof(float) * 3, "vec3f", 1, NULL, NULL, NULL, layerInterp_normal, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, layerCopyValue_normal},
+ layerValidate_normal, NULL, NULL, NULL, NULL, NULL, layerCopyValue_normal},
/* 9: CD_FACEMAP */
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, layerDefault_fmap, NULL},
/* 10: CD_PROP_FLT */
- {sizeof(MFloatProperty), "MFloatProperty", 1, N_("Float"), layerCopy_propFloat, NULL, NULL, NULL},
+ {sizeof(MFloatProperty), "MFloatProperty", 1, N_("Float"), layerCopy_propFloat, NULL, NULL, NULL, NULL,
+ layerValidate_propFloat},
/* 11: CD_PROP_INT */
{sizeof(MIntProperty), "MIntProperty", 1, N_("Int"), layerCopy_propInt, NULL, NULL, NULL},
/* 12: CD_PROP_STR */
@@ -1222,18 +1284,18 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 16: CD_MLOOPUV */
{sizeof(MLoopUV), "MLoopUV", 1, N_("UVMap"), NULL, NULL, layerInterp_mloopuv, NULL, NULL,
- layerEqual_mloopuv, layerMultiply_mloopuv, layerInitMinMax_mloopuv,
+ layerValidate_mloopuv, layerEqual_mloopuv, layerMultiply_mloopuv, layerInitMinMax_mloopuv,
layerAdd_mloopuv, layerDoMinMax_mloopuv, layerCopyValue_mloopuv, NULL, NULL, NULL, layerMaxNum_tface},
/* 17: CD_MLOOPCOL */
{sizeof(MLoopCol), "MLoopCol", 1, N_("Col"), NULL, NULL, layerInterp_mloopcol, NULL,
- layerDefault_mloopcol, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol,
+ layerDefault_mloopcol, NULL, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol,
layerAdd_mloopcol, layerDoMinMax_mloopcol, layerCopyValue_mloopcol, NULL, NULL, NULL, layerMaxNum_mloopcol},
/* 18: CD_TANGENT */
{sizeof(float) * 4 * 4, "", 0, N_("Tangent"), NULL, NULL, NULL, NULL, NULL},
/* 19: CD_MDISPS */
{sizeof(MDisps), "MDisps", 1, NULL, layerCopy_mdisps,
layerFree_mdisps, NULL, layerSwap_mdisps, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL,
layerRead_mdisps, layerWrite_mdisps, layerFilesize_mdisps},
/* 20: CD_PREVIEW_MCOL */
{sizeof(MCol) * 4, "MCol", 4, N_("PreviewCol"), NULL, NULL, layerInterp_mcol,
@@ -1262,12 +1324,12 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
/* 30: CD_CREASE */
{sizeof(float), "", 0, N_("SubSurfCrease"), NULL, NULL, layerInterp_bweight},
/* 31: CD_ORIGSPACE_MLOOP */
- {sizeof(OrigSpaceLoop), "OrigSpaceLoop", 1, N_("OS Loop"), NULL, NULL, layerInterp_mloop_origspace, NULL, NULL,
+ {sizeof(OrigSpaceLoop), "OrigSpaceLoop", 1, N_("OS Loop"), NULL, NULL, layerInterp_mloop_origspace, NULL, NULL, NULL,
layerEqual_mloop_origspace, layerMultiply_mloop_origspace, layerInitMinMax_mloop_origspace,
layerAdd_mloop_origspace, layerDoMinMax_mloop_origspace, layerCopyValue_mloop_origspace},
/* 32: CD_PREVIEW_MLOOPCOL */
{sizeof(MLoopCol), "MLoopCol", 1, N_("PreviewLoopCol"), NULL, NULL, layerInterp_mloopcol, NULL,
- layerDefault_mloopcol, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol,
+ layerDefault_mloopcol, NULL, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol,
layerAdd_mloopcol, layerDoMinMax_mloopcol, layerCopyValue_mloopcol},
/* 33: CD_BM_ELEM_PYPTR */
{sizeof(void *), "", 1, NULL, layerCopy_bmesh_elem_py_ptr,
@@ -3521,6 +3583,22 @@ bool CustomData_verify_versions(struct CustomData *data, int index)
return keeplayer;
}
+/**
+ * Validate and fix data of \a layer, if possible (needs relevant callback in layer's type to be defined).
+ *
+ * \return True if some errors were found.
+ */
+bool CustomData_layer_validate(CustomDataLayer *layer, const uint totitems, const bool do_fixes)
+{
+ const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
+
+ if (typeInfo->validate != NULL) {
+ return typeInfo->validate(layer->data, totitems, do_fixes);
+ }
+
+ return false;
+}
+
/****************************** External Files *******************************/
static void customdata_external_filename(char filename[FILE_MAX], ID *id, CustomDataExternal *external)
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index 73c5f6cecdf..9ee27a29c8b 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -1087,6 +1087,7 @@ bool BKE_object_data_transfer_ex(
bool geom_map_init[DATAMAX] = {0};
ListBase lay_map = {NULL};
bool changed = false;
+ bool is_modifier = false;
const bool use_delete = false; /* We never delete data layers from destination here. */
@@ -1099,6 +1100,7 @@ bool BKE_object_data_transfer_ex(
/* Never create needed custom layers on passed destination mesh
* (assumed to *not* be ob_dst->data, aka modifier case). */
use_create = false;
+ is_modifier = true;
}
else {
me_dst = ob_dst->data;
@@ -1113,7 +1115,17 @@ bool BKE_object_data_transfer_ex(
/* 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 (is_modifier) {
+ me_src = ob_src->runtime.mesh_eval;
+
+ if (me_src == NULL || (me_src_mask & ~ob_src->runtime.last_data_mask) != 0) {
+ printf("Data Transfer: source mesh data is not ready - dependency cycle?\n");
+ return changed;
+ }
+ }
+ else {
+ me_src = mesh_get_eval_final(depsgraph, scene, ob_src, me_src_mask);
+ }
if (!me_src) {
return changed;
}
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index bbb7fc4b3bd..e61b8f71ffa 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -479,12 +479,12 @@ void defvert_flip_merged(MDeformVert *dvert, const int *flip_map, const int flip
bDeformGroup *defgroup_find_name(Object *ob, const char *name)
{
- return BLI_findstring(&ob->defbase, name, offsetof(bDeformGroup, name));
+ return (name && name[0] != '\0') ? BLI_findstring(&ob->defbase, name, offsetof(bDeformGroup, name)) : NULL;
}
int defgroup_name_index(Object *ob, const char *name)
{
- return (name) ? BLI_findstringindex(&ob->defbase, name, offsetof(bDeformGroup, name)) : -1;
+ return (name && name[0] != '\0') ? BLI_findstringindex(&ob->defbase, name, offsetof(bDeformGroup, name)) : -1;
}
/**
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 8d49521831f..182c3204ccb 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -694,7 +694,7 @@ static float displist_calc_taper(Depsgraph *depsgraph, Scene *scene, Object *tap
dl = taperobj->runtime.curve_cache ? taperobj->runtime.curve_cache->disp.first : NULL;
if (dl == NULL) {
- BKE_displist_make_curveTypes(depsgraph, scene, taperobj, 0);
+ BKE_displist_make_curveTypes(depsgraph, scene, taperobj, false, false);
dl = taperobj->runtime.curve_cache->disp.first;
}
if (dl) {
@@ -1578,7 +1578,7 @@ static void do_makeDispListCurveTypes(
if (!for_orco)
curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, for_render, use_render_resolution);
- BKE_curve_bevelList_make(ob, &nubase, for_render != false);
+ BKE_curve_bevelList_make(ob, &nubase, use_render_resolution);
/* If curve has no bevel will return nothing */
BKE_curve_bevel_make(depsgraph, scene, ob, &dlbev, for_render, use_render_resolution);
@@ -1788,7 +1788,8 @@ static void do_makeDispListCurveTypes(
}
}
-void BKE_displist_make_curveTypes(Depsgraph *depsgraph, Scene *scene, Object *ob, const bool for_orco)
+void BKE_displist_make_curveTypes(
+ Depsgraph *depsgraph, Scene *scene, Object *ob, const bool for_render, const bool for_orco)
{
ListBase *dispbase;
@@ -1806,7 +1807,7 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph, Scene *scene, Object *ob
dispbase = &(ob->runtime.curve_cache->disp);
- do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, &ob->runtime.mesh_eval, 0, for_orco, 0);
+ do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, &ob->runtime.mesh_eval, for_render, for_orco, false);
boundbox_displist_object(ob);
}
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 5453982b070..590fe559ff0 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -1039,7 +1039,7 @@ DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *c
/* Using ID_BRUSH i18n context, as we have no physics/dpaint one for now... */
dynamicPaintSurface_setUniqueName(surface, CTX_DATA_(BLT_I18NCONTEXT_ID_BRUSH, "Surface"));
- surface->effector_weights = BKE_add_effector_weights(NULL);
+ surface->effector_weights = BKE_effector_add_weights(NULL);
dynamicPaintSurface_updateType(surface);
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index e6873e66c91..faac56ad161 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -529,12 +529,12 @@ static void cage_mapped_verts_callback(
float (*BKE_editmesh_vertexCos_get(struct Depsgraph *depsgraph, BMEditMesh *em, Scene *scene, int *r_numVerts))[3]
{
- Mesh *cage, *final;
+ Mesh *cage;
BLI_bitmap *visit_bitmap;
struct CageUserData data;
float (*cos_cage)[3];
- cage = editbmesh_get_eval_cage_and_final(depsgraph, scene, em->ob, em, CD_MASK_BAREMESH, &final);
+ cage = editbmesh_get_eval_cage(depsgraph, scene, em->ob, em, CD_MASK_BAREMESH);
cos_cage = MEM_callocN(sizeof(*cos_cage) * em->bm->totvert, "bmbvh cos_cage");
/* when initializing cage verts, we only want the first cage coordinate for each vertex,
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 7c86c0722dc..0c8a47be4b4 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -87,7 +87,7 @@
#include <string.h>
#endif // WITH_MOD_FLUID
-EffectorWeights *BKE_add_effector_weights(Collection *collection)
+EffectorWeights *BKE_effector_add_weights(Collection *collection)
{
EffectorWeights *weights = MEM_callocN(sizeof(EffectorWeights), "EffectorWeights");
int i;
@@ -102,7 +102,7 @@ EffectorWeights *BKE_add_effector_weights(Collection *collection)
return weights;
}
-PartDeflect *object_add_collision_fields(int type)
+PartDeflect *BKE_partdeflect_new(int type)
{
PartDeflect *pd;
@@ -140,7 +140,7 @@ PartDeflect *object_add_collision_fields(int type)
/************************ PARTICLES ***************************/
-void free_partdeflect(PartDeflect *pd)
+void BKE_partdeflect_free(PartDeflect *pd)
{
if (!pd) {
return;
@@ -168,7 +168,7 @@ static void precalculate_effector(struct Depsgraph *depsgraph, EffectorCache *ef
Curve *cu = eff->ob->data;
if (cu->flag & CU_PATH) {
if (eff->ob->runtime.curve_cache == NULL || eff->ob->runtime.curve_cache->path == NULL || eff->ob->runtime.curve_cache->path->data == NULL)
- BKE_displist_make_curveTypes(depsgraph, eff->scene, eff->ob, 0);
+ BKE_displist_make_curveTypes(depsgraph, eff->scene, eff->ob, false, false);
if (eff->ob->runtime.curve_cache->path && eff->ob->runtime.curve_cache->path->data) {
where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL);
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index ed3874ae1c2..2f0c70a4e12 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1315,7 +1315,7 @@ static short driver_check_valid_targets(ChannelDriver *driver, DriverVar *dvar)
{
short valid_targets = 0;
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
Object *ob = (Object *)dtar_id_ensure_proxy_from(dtar->id);
@@ -1331,7 +1331,7 @@ static short driver_check_valid_targets(ChannelDriver *driver, DriverVar *dvar)
valid_targets++;
}
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
return valid_targets;
}
@@ -1418,7 +1418,7 @@ static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar)
/* SECOND PASS: get two location values */
/* NOTE: for now, these are all just worldspace */
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
/* get pointer to loc values to store in */
Object *ob = (Object *)dtar_id_ensure_proxy_from(dtar->id);
@@ -1489,7 +1489,7 @@ static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar)
copy_v3_v3(loc1, tmp_loc);
}
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
/* if we're still here, there should now be two targets to use,
@@ -1674,13 +1674,13 @@ void driver_free_variable(ListBase *variables, DriverVar *dvar)
* currently, since there may be some lingering RNA paths from
* previous users needing freeing
*/
- DRIVER_TARGETS_LOOPER(dvar)
+ DRIVER_TARGETS_LOOPER_BEGIN(dvar)
{
/* free RNA path if applicable */
if (dtar->rna_path)
MEM_freeN(dtar->rna_path);
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
/* remove the variable from the driver */
BLI_freelinkN(variables, dvar);
@@ -1704,13 +1704,13 @@ void driver_variables_copy(ListBase *dst_vars, const ListBase *src_vars)
for (DriverVar *dvar = dst_vars->first; dvar; dvar = dvar->next) {
/* need to go over all targets so that we don't leave any dangling paths */
- DRIVER_TARGETS_LOOPER(dvar)
+ DRIVER_TARGETS_LOOPER_BEGIN(dvar)
{
/* make a copy of target's rna path if available */
if (dtar->rna_path)
dtar->rna_path = MEM_dupallocN(dtar->rna_path);
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
@@ -1730,7 +1730,7 @@ void driver_change_variable_type(DriverVar *dvar, int type)
/* make changes to the targets based on the defines for these types
* NOTE: only need to make sure the ones we're using here are valid...
*/
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
short flags = dvti->target_flags[tarIndex];
@@ -1741,7 +1741,7 @@ void driver_change_variable_type(DriverVar *dvar, int type)
if ((flags & DTAR_FLAG_ID_OB_ONLY) || (dtar->idtype == 0))
dtar->idtype = ID_OB;
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
/* Validate driver name (after being renamed) */
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index f6e1fabc6c0..1b6061d5b04 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -364,7 +364,8 @@ static VChar *find_vfont_char(VFontData *vfd, unsigned int character)
}
static void build_underline(Curve *cu, ListBase *nubase, const rctf *rect,
- float yofs, float rot, int charidx, short mat_nr)
+ float yofs, float rot, int charidx, short mat_nr,
+ const float font_size)
{
Nurb *nu2;
BPoint *bp;
@@ -417,18 +418,19 @@ static void build_underline(Curve *cu, ListBase *nubase, const rctf *rect,
bp = nu2->bp;
}
- mul_v2_fl(bp[0].vec, cu->fsize);
- mul_v2_fl(bp[1].vec, cu->fsize);
- mul_v2_fl(bp[2].vec, cu->fsize);
- mul_v2_fl(bp[3].vec, cu->fsize);
+ mul_v2_fl(bp[0].vec, font_size);
+ mul_v2_fl(bp[1].vec, font_size);
+ mul_v2_fl(bp[2].vec, font_size);
+ mul_v2_fl(bp[3].vec, font_size);
}
static void buildchar(Curve *cu, ListBase *nubase, unsigned int character, CharInfo *info,
- float ofsx, float ofsy, float rot, int charidx)
+ float ofsx, float ofsy, float rot, int charidx,
+ const float fsize)
{
BezTriple *bezt1, *bezt2;
Nurb *nu1 = NULL, *nu2 = NULL;
- float *fp, fsize, shear, x, si, co;
+ float *fp, shear, x, si, co;
VFontData *vfd = NULL;
VChar *che = NULL;
int i;
@@ -448,7 +450,6 @@ static void buildchar(Curve *cu, ListBase *nubase, unsigned int character, CharI
#endif
/* make a copy at distance ofsx, ofsy with shear */
- fsize = cu->fsize;
shear = cu->shear;
si = sinf(rot);
co = cosf(rot);
@@ -635,6 +636,27 @@ struct TempLineInfo {
int wspace_nr; /* number of whitespaces of line */
};
+typedef struct VFontToCurveIter {
+ int iteraction;
+ float scale_to_fit;
+ struct {
+ float min;
+ float max;
+ } bisect;
+ bool ok;
+ int status;
+} VFontToCurveIter;
+
+enum {
+ VFONT_TO_CURVE_INIT = 0,
+ VFONT_TO_CURVE_BISECT,
+ VFONT_TO_CURVE_SCALE_ONCE,
+ VFONT_TO_CURVE_DONE,
+};
+
+#define FONT_TO_CURVE_SCALE_ITERATIONS 20
+#define FONT_TO_CURVE_SCALE_THRESHOLD 0.0001f
+
/**
* Font metric values explained:
*
@@ -651,7 +673,9 @@ struct TempLineInfo {
#define ASCENT(vfd) ((vfd)->ascender * (vfd)->em_height)
#define DESCENT(vfd) ((vfd)->em_height - ASCENT(vfd))
-bool BKE_vfont_to_curve_ex(Object *ob, Curve *cu, int mode, ListBase *r_nubase,
+static bool vfont_to_curve(Object *ob, Curve *cu, int mode,
+ VFontToCurveIter *iter_data,
+ ListBase *r_nubase,
const wchar_t **r_text, int *r_text_len, bool *r_text_free,
struct CharTrans **r_chartransdata)
{
@@ -666,16 +690,21 @@ bool BKE_vfont_to_curve_ex(Object *ob, Curve *cu, int mode, ListBase *r_nubase,
struct CharTrans *chartransdata = NULL, *ct;
struct TempLineInfo *lineinfo;
float *f, xof, yof, xtrax, linedist;
- float twidth, maxlen = 0;
+ float twidth = 0, maxlen = 0;
int i, slen, j;
int curbox;
int selstart, selend;
int cnr = 0, lnr = 0, wsnr = 0;
- const wchar_t *mem;
+ const wchar_t *mem = NULL;
wchar_t ascii;
bool ok = false;
- const float xof_scale = cu->xof / cu->fsize;
- const float yof_scale = cu->yof / cu->fsize;
+ const float font_size = cu->fsize * iter_data->scale_to_fit;
+ const float xof_scale = cu->xof / font_size;
+ const float yof_scale = cu->yof / font_size;
+ int last_line = -1;
+ /* Length of the text disregarding \n breaks. */
+ float current_line_length = 0.0f;
+ float longest_line_length = 0.0f;
/* Text at the beginning of the last used text-box (use for y-axis alignment).
* We overallocate by one to simplify logic of getting last char. */
@@ -756,7 +785,7 @@ bool BKE_vfont_to_curve_ex(Object *ob, Curve *cu, int mode, ListBase *r_nubase,
linedist = cu->linedist;
curbox = 0;
- textbox_scale(&tb_scale, &cu->tb[curbox], 1.0f / cu->fsize);
+ textbox_scale(&tb_scale, &cu->tb[curbox], 1.0f / font_size);
use_textbox = (tb_scale.w != 0.0f);
@@ -768,7 +797,7 @@ bool BKE_vfont_to_curve_ex(Object *ob, Curve *cu, int mode, ListBase *r_nubase,
oldvfont = NULL;
for (i = 0; i < slen; i++) {
- custrinfo[i].flag &= ~(CU_CHINFO_WRAP | CU_CHINFO_SMALLCAPS_CHECK);
+ custrinfo[i].flag &= ~(CU_CHINFO_WRAP | CU_CHINFO_SMALLCAPS_CHECK | CU_CHINFO_OVERFLOW);
}
for (i = 0; i <= slen; i++) {
@@ -837,6 +866,7 @@ makebreak:
{
// fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]);
for (j = i; j && (mem[j] != '\n') && (chartransdata[j].dobreak == 0); j--) {
+ bool dobreak = false;
if (mem[j] == ' ' || mem[j] == '-') {
ct -= (i - (j - 1));
cnr -= (i - (j - 1));
@@ -846,9 +876,9 @@ makebreak:
xof = ct->xof;
ct[1].dobreak = 1;
custrinfo[i + 1].flag |= CU_CHINFO_WRAP;
- goto makebreak;
+ dobreak = true;
}
- if (chartransdata[j].dobreak) {
+ else if (chartransdata[j].dobreak) {
// fprintf(stderr, "word too long: %c%c%c...\n", mem[j], mem[j+1], mem[j+2]);
ct->dobreak = 1;
custrinfo[i + 1].flag |= CU_CHINFO_WRAP;
@@ -856,6 +886,13 @@ makebreak:
cnr -= 1;
i--;
xof = ct->xof;
+ dobreak = true;
+ }
+ if (dobreak) {
+ if (tb_scale.h == 0.0f) {
+ /* Note: If underlined text is truncated away, the extra space is also truncated. */
+ custrinfo[i + 1].flag |= CU_CHINFO_OVERFLOW;
+ }
goto makebreak;
}
}
@@ -877,16 +914,30 @@ makebreak:
CLAMP_MIN(maxlen, lineinfo[lnr].x_min);
if ((tb_scale.h != 0.0f) &&
- (cu->totbox > (curbox + 1)) &&
((-(yof - tb_scale.y)) > (tb_scale.h - linedist) - yof_scale))
{
- maxlen = 0;
- curbox++;
- i_textbox_array[curbox] = i + 1;
+ if (cu->totbox > (curbox + 1)) {
+ maxlen = 0;
+ curbox++;
+ i_textbox_array[curbox] = i + 1;
- textbox_scale(&tb_scale, &cu->tb[curbox], 1.0f / cu->fsize);
+ textbox_scale(&tb_scale, &cu->tb[curbox], 1.0f / font_size);
- yof = MARGIN_Y_MIN;
+ yof = MARGIN_Y_MIN;
+ }
+ else if (last_line == -1) {
+ last_line = lnr + 1;
+ info->flag |= CU_CHINFO_OVERFLOW;
+ }
+ }
+
+ current_line_length += xof;
+ if (ct->dobreak) {
+ current_line_length += twidth;
+ }
+ else {
+ longest_line_length = MAX2(current_line_length, longest_line_length);
+ current_line_length = 0.0f;
}
/* XXX, has been unused for years, need to check if this is useful, r4613 r5282 - campbell */
@@ -925,9 +976,9 @@ makebreak:
if (selboxes && (i >= selstart) && (i <= selend)) {
sb = &selboxes[i - selstart];
- sb->y = yof * cu->fsize - linedist * cu->fsize * 0.1f;
- sb->h = linedist * cu->fsize;
- sb->w = xof * cu->fsize;
+ sb->y = yof * font_size - linedist * font_size * 0.1f;
+ sb->h = linedist * font_size;
+ sb->w = xof * font_size;
}
if (ascii == 32) {
@@ -944,11 +995,13 @@ makebreak:
xof += (twidth * wsfac * (1.0f + (info->kern / 40.0f)) ) + xtrax;
if (sb) {
- sb->w = (xof * cu->fsize) - sb->w;
+ sb->w = (xof * font_size) - sb->w;
}
}
ct++;
}
+ current_line_length += xof + twidth;
+ longest_line_length = MAX2(current_line_length, longest_line_length);
cu->lines = 1;
for (i = 0; i <= slen; i++) {
@@ -1050,7 +1103,7 @@ makebreak:
ct_last = chartransdata + (is_last_filled_textbox ? slen: i_textbox_next - 1);
lines = ct_last->linenr - ct_first->linenr + 1;
- textbox_scale(&tb_scale, &cu->tb[tb_index], 1.0f / cu->fsize);
+ textbox_scale(&tb_scale, &cu->tb[tb_index], 1.0f / font_size);
/* The initial Y origin of the textbox is hardcoded to 1.0f * text scale. */
const float textbox_y_origin = 1.0f;
float yoff = 0.0f;
@@ -1133,7 +1186,7 @@ makebreak:
copy_m3_m4(cmat, cu->textoncurve->obmat);
mul_m3_m3m3(cmat, cmat, imat3);
- sizefac = normalize_v3(cmat[0]) / cu->fsize;
+ sizefac = normalize_v3(cmat[0]) / font_size;
minx = miny = 1.0e20f;
maxx = maxy = -1.0e20f;
@@ -1226,13 +1279,15 @@ makebreak:
ct = chartransdata;
for (i = 0; i <= selend; i++, ct++) {
if (i >= selstart) {
- selboxes[i - selstart].x = ct->xof * cu->fsize;
- selboxes[i - selstart].y = ct->yof * cu->fsize;
+ selboxes[i - selstart].x = ct->xof * font_size;
+ selboxes[i - selstart].y = ct->yof * font_size;
}
}
}
- if (ELEM(mode, FO_CURSUP, FO_CURSDOWN, FO_PAGEUP, FO_PAGEDOWN)) {
+ if (ELEM(mode, FO_CURSUP, FO_CURSDOWN, FO_PAGEUP, FO_PAGEDOWN) &&
+ iter_data->status == VFONT_TO_CURVE_INIT)
+ {
ct = &chartransdata[ef->pos];
if (ELEM(mode, FO_CURSUP, FO_PAGEUP) && ct->linenr == 0) {
@@ -1277,27 +1332,25 @@ makebreak:
f = ef->textcurs[0];
- f[0] = cu->fsize * (-0.1f * co + ct->xof);
- f[1] = cu->fsize * ( 0.1f * si + ct->yof);
+ f[0] = font_size * (-0.1f * co + ct->xof);
+ f[1] = font_size * ( 0.1f * si + ct->yof);
- f[2] = cu->fsize * ( 0.1f * co + ct->xof);
- f[3] = cu->fsize * (-0.1f * si + ct->yof);
+ f[2] = font_size * ( 0.1f * co + ct->xof);
+ f[3] = font_size * (-0.1f * si + ct->yof);
- f[4] = cu->fsize * ( 0.1f * co + 0.8f * si + ct->xof);
- f[5] = cu->fsize * (-0.1f * si + 0.8f * co + ct->yof);
+ f[4] = font_size * ( 0.1f * co + 0.8f * si + ct->xof);
+ f[5] = font_size * (-0.1f * si + 0.8f * co + ct->yof);
- f[6] = cu->fsize * (-0.1f * co + 0.8f * si + ct->xof);
- f[7] = cu->fsize * ( 0.1f * si + 0.8f * co + ct->yof);
+ f[6] = font_size * (-0.1f * co + 0.8f * si + ct->xof);
+ f[7] = font_size * ( 0.1f * si + 0.8f * co + ct->yof);
}
if (mode == FO_SELCHANGE) {
MEM_freeN(chartransdata);
chartransdata = NULL;
- goto finally;
}
-
- if (mode == FO_EDIT) {
+ else if (mode == FO_EDIT) {
/* make nurbdata */
BKE_nurbList_free(r_nubase);
@@ -1306,6 +1359,13 @@ makebreak:
unsigned int cha = (unsigned int) mem[i];
info = &(custrinfo[i]);
+ if ((cu->overflow == CU_OVERFLOW_TRUNCATE) &&
+ (ob && ob->mode != OB_MODE_EDIT) &&
+ (info->flag & CU_CHINFO_OVERFLOW))
+ {
+ break;
+ }
+
if (info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
cha = towupper(cha);
}
@@ -1316,7 +1376,7 @@ makebreak:
}
/* We do not want to see any character for \n or \r */
if (cha != '\n')
- buildchar(cu, r_nubase, cha, info, ct->xof, ct->yof, ct->rot, i);
+ buildchar(cu, r_nubase, cha, info, ct->xof, ct->yof, ct->rot, i, font_size);
if ((info->flag & CU_CHINFO_UNDERLINE) && (cha != '\n')) {
float ulwidth, uloverlap = 0.0f;
@@ -1343,17 +1403,134 @@ makebreak:
build_underline(cu, r_nubase,
&rect, cu->ulpos - 0.05f,
- ct->rot, i, info->mat_nr);
+ ct->rot, i, info->mat_nr,
+ font_size);
}
ct++;
}
}
- ok = true;
+ if (iter_data->status == VFONT_TO_CURVE_SCALE_ONCE) {
+ /* That means we were in a final run, just exit. */
+ BLI_assert(cu->overflow == CU_OVERFLOW_SCALE);
+ iter_data->status = VFONT_TO_CURVE_DONE;
+ }
+ else if (cu->overflow == CU_OVERFLOW_NONE) {
+ /* Do nothing. */
+ }
+ else if ((tb_scale.h == 0.0f) && (tb_scale.w == 0.0f)) {
+ /* Do nothing. */
+ }
+ else if (cu->overflow == CU_OVERFLOW_SCALE) {
+ if ((cu->totbox == 1) && ((tb_scale.w == 0.0f) || (tb_scale.h == 0.0f))) {
+ /* These are special cases, simpler to deal with. */
+ if (tb_scale.w == 0.0f) {
+ /* This is a potential vertical overflow.
+ * Since there is no width limit, all the new lines are from line breaks. */
+ if ((last_line != -1) && (lnr > last_line)) {
+ const float total_text_height = lnr * linedist;
+ iter_data->scale_to_fit = tb_scale.h / total_text_height;
+ iter_data->status = VFONT_TO_CURVE_SCALE_ONCE;
+ }
+ }
+ else if (tb_scale.h == 0.0f) {
+ /* This is a horizontal overflow. */
+ if (lnr > 1) {
+ /* We make sure longest line before it broke can fit here. */
+ float scale_to_fit = tb_scale.w / (longest_line_length);
+ scale_to_fit -= FLT_EPSILON;
+
+ iter_data->scale_to_fit = scale_to_fit;
+ iter_data->status = VFONT_TO_CURVE_SCALE_ONCE;
+ }
+ }
+ }
+ else {
+ /* This is the really complicated case, the best we can do is to iterate over
+ * this function a few times until we get an acceptable result.
+ *
+ * Keep in mind that there is no single number that will make all fit to the end.
+ * In a way, our ultimate goal is to get the highest scale that still leads to the
+ * number of extra lines to zero.
+ */
+ if (iter_data->status == VFONT_TO_CURVE_INIT) {
+ bool valid = true;
-finally:
+ for (int tb_index = 0; tb_index <= curbox; tb_index++) {
+ TextBox *tb = &cu->tb[tb_index];
+ if ((tb->w == 0.0f) || (tb->h == 0.0f)) {
+ valid = false;
+ break;
+ }
+ }
+
+ if (valid && (last_line != -1) && (lnr > last_line)) {
+ const float total_text_height = lnr * linedist;
+ float scale_to_fit = tb_scale.h / total_text_height;
+ iter_data->bisect.max = 1.0f;
+ iter_data->bisect.min = scale_to_fit;
+
+ iter_data->status = VFONT_TO_CURVE_BISECT;
+ }
+ }
+ else {
+ BLI_assert(iter_data->status == VFONT_TO_CURVE_BISECT);
+ /* Try to get the highest scale that gives us the exactly
+ * number of lines we need. */
+ bool valid = false;
+
+ if ((last_line != -1) && (lnr > last_line)) {
+ /* It is overflowing, scale it down. */
+ iter_data->bisect.max = iter_data->scale_to_fit;
+ }
+ else {
+ /* It fits inside the textbox, scale it up. */
+ iter_data->bisect.min = iter_data->scale_to_fit;
+ valid = true;
+ }
+
+ /* Bisecting to try to find the best fit. */
+ iter_data->scale_to_fit = (iter_data->bisect.max + iter_data->bisect.min) * 0.5f;
+
+ /* We iterated enough or got a good enough result. */
+ if ((!iter_data->iteraction--) ||
+ ((iter_data->bisect.max - iter_data->bisect.min) < (cu->fsize * FONT_TO_CURVE_SCALE_THRESHOLD)))
+ {
+ if (valid) {
+ iter_data->status = VFONT_TO_CURVE_DONE;
+ }
+ else {
+ iter_data->scale_to_fit = iter_data->bisect.min;
+ iter_data->status = VFONT_TO_CURVE_SCALE_ONCE;
+ }
+ }
+ }
+ }
+ }
+
+ /* Scale to fit only works for single text box layouts. */
+ if (ELEM(iter_data->status,
+ VFONT_TO_CURVE_SCALE_ONCE,
+ VFONT_TO_CURVE_BISECT))
{
+ /* Always cleanup before going to the scale-to-fit repetition. */
+ if (r_nubase != NULL) {
+ BKE_nurbList_free(r_nubase);
+ }
+
+ if (chartransdata != NULL) {
+ MEM_freeN(chartransdata);
+ }
+
+ if (ef == NULL) {
+ MEM_freeN((void *)mem);
+ }
+ return true;
+ }
+ else {
+ ok = true;
+finally:
if (r_text) {
*r_text = mem;
*r_text_len = slen;
@@ -1364,17 +1541,19 @@ finally:
MEM_freeN((void *)mem);
}
}
- }
- if (chartransdata) {
- if (ok && r_chartransdata) {
- *r_chartransdata = chartransdata;
- }
- else {
- MEM_freeN(chartransdata);
+ if (chartransdata) {
+ if (ok && r_chartransdata) {
+ *r_chartransdata = chartransdata;
+ }
+ else {
+ MEM_freeN(chartransdata);
+ }
}
- }
+ /* Store the effective scale, to use for the textbox lines. */
+ cu->fsize_realtime = font_size;
+ }
return ok;
#undef MARGIN_X_MIN
@@ -1384,6 +1563,37 @@ finally:
#undef DESCENT
#undef ASCENT
+bool BKE_vfont_to_curve_ex(Object *ob, Curve *cu, int mode, ListBase *r_nubase,
+ const wchar_t **r_text, int *r_text_len, bool *r_text_free,
+ struct CharTrans **r_chartransdata)
+{
+ VFontToCurveIter data = {
+ .iteraction = cu->totbox * FONT_TO_CURVE_SCALE_ITERATIONS,
+ .scale_to_fit = 1.0f,
+ .ok = true,
+ .status = VFONT_TO_CURVE_INIT,
+ };
+
+ do {
+ data.ok &= vfont_to_curve(ob,
+ cu,
+ mode,
+ &data,
+ r_nubase,
+ r_text,
+ r_text_len,
+ r_text_free,
+ r_chartransdata);
+ } while (data.ok && ELEM(data.status,
+ VFONT_TO_CURVE_SCALE_ONCE,
+ VFONT_TO_CURVE_BISECT));
+
+ return data.ok;
+}
+
+#undef FONT_TO_CURVE_SCALE_ITERATIONS
+#undef FONT_TO_CURVE_SCALE_THRESHOLD
+
bool BKE_vfont_to_curve_nubase(Object *ob, int mode, ListBase *r_nubase)
{
BLI_assert(ob->type == OB_FONT);
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 98d255df080..dd1a2520991 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -78,7 +78,7 @@ void(*BKE_gpencil_batch_cache_free_cb)(bGPdata *gpd) = NULL;
void BKE_gpencil_batch_cache_dirty_tag(bGPdata *gpd)
{
if (gpd) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
BKE_gpencil_batch_cache_dirty_tag_cb(gpd);
}
}
@@ -373,6 +373,9 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
/* set default thickness of new strokes for this layer */
gpl->thickness = 3;
+ /* Onion colors */
+ ARRAY_SET_ITEMS(gpl->gcolor_prev, 0.302f, 0.851f, 0.302f);
+ ARRAY_SET_ITEMS(gpl->gcolor_next, 0.250f, 0.1f, 1.0f);
}
else {
/* thickness parameter represents "thickness change", not absolute thickness */
@@ -1216,7 +1219,7 @@ void BKE_gpencil_vgroup_remove(Object *ob, bDeformGroup *defgroup)
/* Remove the group */
BLI_freelinkN(&ob->defbase, defgroup);
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index f1a921650f0..f8e28f680c1 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -64,6 +64,7 @@
#include "BLI_blenlib.h"
#include "BLI_math_vector.h"
#include "BLI_mempool.h"
+#include "BLI_system.h"
#include "BLI_threads.h"
#include "BLI_timecode.h" /* for stamp timecode format */
#include "BLI_utildefines.h"
@@ -1402,7 +1403,8 @@ void BKE_imformat_defaults(ImageFormatData *im_format)
im_format->compress = 15;
BKE_color_managed_display_settings_init(&im_format->display_settings);
- BKE_color_managed_view_settings_init(&im_format->view_settings);
+ BKE_color_managed_view_settings_init_default(&im_format->view_settings,
+ &im_format->display_settings);
}
void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *imbuf)
@@ -1544,6 +1546,7 @@ typedef struct StampData {
char strip[STAMP_NAME_SIZE];
char rendertime[STAMP_NAME_SIZE];
char memory[STAMP_NAME_SIZE];
+ char hostname[512];
/* Custom fields are used to put extra meta information header from render
* engine to the result image.
@@ -1703,6 +1706,16 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
else {
stamp_data->frame_range[0] = '\0';
}
+
+ if (scene->r.stamp & R_STAMP_HOSTNAME) {
+ char hostname[500]; /* sizeof(stamp_data->hostname) minus some bytes for a label. */
+ BLI_hostname_get(hostname, sizeof(hostname));
+ SNPRINTF(stamp_data->hostname, do_prefix ? "Hostname %s" : "%s", hostname);
+ }
+ else {
+ stamp_data->hostname[0] = '\0';
+ }
+
}
/* Will always add prefix. */
@@ -1782,6 +1795,12 @@ static void stampdata_from_template(StampData *stamp_data,
else {
stamp_data->memory[0] = '\0';
}
+ if (scene->r.stamp & R_STAMP_HOSTNAME) {
+ SNPRINTF(stamp_data->hostname, "Hostname %s", stamp_data_template->hostname);
+ }
+ else {
+ stamp_data->hostname[0] = '\0';
+ }
}
void BKE_image_stamp_buf(
@@ -1909,7 +1928,22 @@ void BKE_image_stamp_buf(
y -= BUFF_MARGIN_Y * 2;
}
- /* Top left corner, below File, Date, Memory, Rendertime */
+ /* Top left corner, below File, Date, Rendertime, Memory */
+ if (TEXT_SIZE_CHECK(stamp_data.hostname, w, h)) {
+ y -= h;
+
+ /* and space for background. */
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
+ 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+
+ BLF_position(mono, x, y + y_ofs, 0.0);
+ BLF_draw_buffer(mono, stamp_data.hostname, BLF_DRAW_STR_DUMMY_MAX);
+
+ /* the extra pixel for background. */
+ y -= BUFF_MARGIN_Y * 2;
+ }
+
+ /* Top left corner, below File, Date, Memory, Rendertime, Hostname */
BLF_enable(mono, BLF_WORD_WRAP);
if (TEXT_SIZE_CHECK_WORD_WRAP(stamp_data.note, w, h)) {
y -= h;
@@ -2090,6 +2124,7 @@ void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCall
CALL(strip, "Strip");
CALL(rendertime, "RenderTime");
CALL(memory, "Memory");
+ CALL(hostname, "Hostname");
LISTBASE_FOREACH(StampDataCustomField *, custom_field, &stamp_data->custom_fields) {
if (noskip || custom_field->value[0]) {
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index d3ac5a39c9f..aae208dd967 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -1944,8 +1944,7 @@ void do_versions_ipos_to_animato(Main *bmain)
id_us_min(&seq->ipo->id);
seq->ipo = NULL;
- }
- SEQ_END
+ } SEQ_END;
}
}
diff --git a/source/blender/blenkernel/intern/keyconfig.c b/source/blender/blenkernel/intern/keyconfig.c
index 755c9e1582d..f2db375f3ec 100644
--- a/source/blender/blenkernel/intern/keyconfig.c
+++ b/source/blender/blenkernel/intern/keyconfig.c
@@ -120,4 +120,18 @@ void BKE_keyconfig_pref_type_free(void)
global_keyconfigpreftype_hash = NULL;
}
+/* Set select mouse, for versioning code. */
+void BKE_keyconfig_pref_set_select_mouse(UserDef *userdef, int value, bool override)
+{
+ wmKeyConfigPref *kpt = BKE_keyconfig_pref_ensure(userdef, WM_KEYCONFIG_STR_DEFAULT);
+ IDProperty *idprop = IDP_GetPropertyFromGroup(kpt->prop, "select_mouse");
+ if (!idprop) {
+ IDPropertyTemplate tmp = { .i = value };
+ IDP_AddToGroup(kpt->prop, IDP_New(IDP_INT, &tmp, "select_mouse"));
+ }
+ else if (override) {
+ IDP_Int(idprop) = value;
+ }
+}
+
/** \} */
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 681ff3b619f..29f62519350 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -150,7 +150,7 @@ Lamp *BKE_lamp_localize(Lamp *la)
*
* NOTE: Only possible once nested node trees are fully converted to that too. */
- Lamp *lan = BKE_libblock_copy_nolib(&la->id, false);
+ Lamp *lan = BKE_libblock_copy_for_localize(&la->id);
lan->curfalloff = curvemapping_copy(la->curfalloff);
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index a04f32adece..0fa675639ea 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -704,14 +704,12 @@ static bool calc_curve_deform(Object *par, float co[3],
}
void curve_deform_verts(
- Object *cuOb, Object *target, Mesh *mesh, float (*vertexCos)[3],
- int numVerts, const char *vgroup, short defaxis)
+ Object *cuOb, Object *target, float (*vertexCos)[3],
+ int numVerts, MDeformVert *dvert, const int defgrp_index, short defaxis)
{
Curve *cu;
int a;
CurveDeform cd;
- MDeformVert *dvert = NULL;
- int defgrp_index = -1;
const bool is_neg_axis = (defaxis > 2);
if (cuOb->type != OB_CURVE)
@@ -732,26 +730,6 @@ void curve_deform_verts(
cd.dmax[0] = cd.dmax[1] = cd.dmax[2] = 0.0f;
}
- /* Check whether to use vertex groups (only possible if target is a Mesh or Lattice).
- * We want either a Mesh/Lattice with no derived data, or derived data with deformverts.
- */
- if (vgroup && vgroup[0] && ELEM(target->type, OB_MESH, OB_LATTICE)) {
- defgrp_index = defgroup_name_index(target, vgroup);
-
- if (defgrp_index != -1) {
- /* if there's derived data without deformverts, don't use vgroups */
- if (mesh) {
- dvert = CustomData_get_layer(&mesh->vdata, CD_MDEFORMVERT);
- }
- else if (target->type == OB_LATTICE) {
- dvert = ((Lattice *)target->data)->dvert;
- }
- else {
- dvert = ((Mesh *)target->data)->dvert;
- }
- }
- }
-
if (dvert) {
MDeformVert *dvert_iter;
float vec[3];
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 2f9c818934f..bee915567bd 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -45,6 +45,7 @@
#include "BKE_object.h"
#include "DNA_ID.h"
+#include "DNA_space_types.h"
#include "DNA_collection_types.h"
#include "DNA_layer_types.h"
#include "DNA_object_types.h"
@@ -680,12 +681,13 @@ static short layer_collection_sync(
continue;
}
- Base *base = BLI_ghash_lookup(view_layer->object_bases_hash, cob->ob);
-
- if (base) {
+ void **base_p;
+ Base *base;
+ if (BLI_ghash_ensure_p(view_layer->object_bases_hash, cob->ob, &base_p)) {
/* Move from old base list to new base list. Base might have already
* been moved to the new base list and the first/last test ensure that
* case also works. */
+ base = *base_p;
if (!ELEM(base, new_object_bases->first, new_object_bases->last)) {
BLI_remlink(&view_layer->object_bases, base);
BLI_addtail(new_object_bases, base);
@@ -694,8 +696,8 @@ static short layer_collection_sync(
else {
/* Create new base. */
base = object_base_new(cob->ob);
+ *base_p = base;
BLI_addtail(new_object_bases, base);
- BLI_ghash_insert(view_layer->object_bases_hash, base->object, base);
}
int object_restrict = base->object->restrictflag;
@@ -859,7 +861,7 @@ void BKE_main_collection_sync_remap(const Main *bmain)
for (Collection *collection = bmain->collection.first; collection; collection = collection->id.next) {
BKE_collection_object_cache_free(collection);
- DEG_id_tag_update_ex((Main *)bmain, &collection->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex((Main *)bmain, &collection->id, ID_RECALC_COPY_ON_WRITE);
}
BKE_main_collection_sync(bmain);
@@ -1096,20 +1098,57 @@ void BKE_override_layer_collection_boolean_add(
/** \name Private Iterator Helpers
* \{ */
-static void object_bases_iterator_begin(BLI_Iterator *iter, void *data_in, const int flag)
+typedef struct LayerObjectBaseIteratorData {
+ View3D *v3d;
+ Base *base;
+} LayerObjectBaseIteratorData;
+
+static bool object_bases_iterator_is_valid_ex(View3D *v3d, Base *base, const int flag)
{
- ViewLayer *view_layer = data_in;
+ if (v3d != NULL) {
+ BLI_assert(v3d->spacetype == SPACE_VIEW3D);
+ if ((v3d->object_type_exclude_viewport & (1 << base->object->type)) != 0) {
+ return false;
+ }
+
+ if (v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
+ return false;
+ }
+ }
+
+ if ((base->flag & flag) == 0) {
+ return false;
+ }
+
+ return true;
+}
+
+static bool object_bases_iterator_is_valid(View3D *v3d, Base *base)
+{
+ return object_bases_iterator_is_valid_ex(v3d, base, ~(0));
+}
+
+static void object_bases_iterator_begin(BLI_Iterator *iter, void *data_in_v, const int flag)
+{
+ ObjectsVisibleIteratorData *data_in = data_in_v;
+ ViewLayer *view_layer = data_in->view_layer;
+ View3D *v3d = data_in->v3d;
Base *base = view_layer->object_bases.first;
/* when there are no objects */
if (base == NULL) {
+ iter->data = NULL;
iter->valid = false;
return;
}
- iter->data = base;
+ LayerObjectBaseIteratorData *data = MEM_callocN(sizeof(LayerObjectBaseIteratorData), __func__);
+ iter->data = data;
- if ((base->flag & flag) == 0) {
+ data->v3d = v3d;
+ data->base = base;
+
+ if (object_bases_iterator_is_valid_ex(v3d, base, flag) == false) {
object_bases_iterator_next(iter, flag);
}
else {
@@ -1119,12 +1158,13 @@ static void object_bases_iterator_begin(BLI_Iterator *iter, void *data_in, const
static void object_bases_iterator_next(BLI_Iterator *iter, const int flag)
{
- Base *base = ((Base *)iter->data)->next;
+ LayerObjectBaseIteratorData *data = iter->data;
+ Base *base = data->base->next;
while (base) {
- if ((base->flag & flag) != 0) {
+ if (object_bases_iterator_is_valid_ex(data->v3d, base, flag)) {
iter->current = base;
- iter->data = base;
+ data->base = base;
return;
}
base = base->next;
@@ -1133,6 +1173,11 @@ static void object_bases_iterator_next(BLI_Iterator *iter, const int flag)
iter->valid = false;
}
+static void object_bases_iterator_end(BLI_Iterator *iter)
+{
+ MEM_SAFE_FREE(iter->data);
+}
+
static void objects_iterator_begin(BLI_Iterator *iter, void *data_in, const int flag)
{
object_bases_iterator_begin(iter, data_in, flag);
@@ -1151,6 +1196,11 @@ static void objects_iterator_next(BLI_Iterator *iter, const int flag)
}
}
+static void objects_iterator_end(BLI_Iterator *iter)
+{
+ object_bases_iterator_end(iter);
+}
+
/* -------------------------------------------------------------------- */
/** \name BKE_view_layer_selected_objects_iterator
* See: #FOREACH_SELECTED_OBJECT_BEGIN
@@ -1166,9 +1216,9 @@ void BKE_view_layer_selected_objects_iterator_next(BLI_Iterator *iter)
objects_iterator_next(iter, BASE_SELECTED);
}
-void BKE_view_layer_selected_objects_iterator_end(BLI_Iterator *UNUSED(iter))
+void BKE_view_layer_selected_objects_iterator_end(BLI_Iterator *iter)
{
- /* do nothing */
+ objects_iterator_end(iter);
}
/** \} */
@@ -1187,9 +1237,9 @@ void BKE_view_layer_visible_objects_iterator_next(BLI_Iterator *iter)
objects_iterator_next(iter, BASE_VISIBLE);
}
-void BKE_view_layer_visible_objects_iterator_end(BLI_Iterator *UNUSED(iter))
+void BKE_view_layer_visible_objects_iterator_end(BLI_Iterator *iter)
{
- /* do nothing */
+ objects_iterator_end(iter);
}
/** \} */
@@ -1221,9 +1271,9 @@ void BKE_view_layer_selected_editable_objects_iterator_next(BLI_Iterator *iter)
} while (iter->valid && BKE_object_is_libdata((Object *)iter->current) != false);
}
-void BKE_view_layer_selected_editable_objects_iterator_end(BLI_Iterator *UNUSED(iter))
+void BKE_view_layer_selected_editable_objects_iterator_end(BLI_Iterator *iter)
{
- /* do nothing */
+ objects_iterator_end(iter);
}
/** \} */
@@ -1234,7 +1284,7 @@ void BKE_view_layer_selected_editable_objects_iterator_end(BLI_Iterator *UNUSED(
void BKE_view_layer_selected_bases_iterator_begin(BLI_Iterator *iter, void *data_in)
{
- object_bases_iterator_begin(iter, data_in, BASE_SELECTED);
+ objects_iterator_begin(iter, data_in, BASE_SELECTED);
}
void BKE_view_layer_selected_bases_iterator_next(BLI_Iterator *iter)
@@ -1242,9 +1292,9 @@ void BKE_view_layer_selected_bases_iterator_next(BLI_Iterator *iter)
object_bases_iterator_next(iter, BASE_SELECTED);
}
-void BKE_view_layer_selected_bases_iterator_end(BLI_Iterator *UNUSED(iter))
+void BKE_view_layer_selected_bases_iterator_end(BLI_Iterator *iter)
{
- /* do nothing */
+ object_bases_iterator_end(iter);
}
/** \} */
@@ -1263,9 +1313,9 @@ void BKE_view_layer_visible_bases_iterator_next(BLI_Iterator *iter)
object_bases_iterator_next(iter, BASE_VISIBLE);
}
-void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *UNUSED(iter))
+void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter)
{
- /* do nothing */
+ object_bases_iterator_end(iter);
}
/** \} */
@@ -1365,6 +1415,11 @@ void BKE_view_layer_renderable_objects_iterator_end(BLI_Iterator *UNUSED(iter))
/** \name BKE_view_layer_bases_in_mode_iterator
* \{ */
+static bool base_is_in_mode(struct ObjectsInModeIteratorData *data, Base *base)
+{
+ return (base->object->type == data->object_type) && (base->object->mode & data->object_mode) != 0;
+}
+
void BKE_view_layer_bases_in_mode_iterator_begin(BLI_Iterator *iter, void *data_in)
{
struct ObjectsInModeIteratorData *data = data_in;
@@ -1377,6 +1432,15 @@ void BKE_view_layer_bases_in_mode_iterator_begin(BLI_Iterator *iter, void *data_
}
iter->data = data_in;
iter->current = base;
+
+ /* default type is active object type */
+ if (data->object_type < 0) {
+ data->object_type = base->object->type;
+ }
+
+ if (object_bases_iterator_is_valid(data->v3d, base) == false || !base_is_in_mode(data, base)) {
+ BKE_view_layer_bases_in_mode_iterator_next(iter);
+ }
}
void BKE_view_layer_bases_in_mode_iterator_next(BLI_Iterator *iter)
@@ -1396,9 +1460,9 @@ void BKE_view_layer_bases_in_mode_iterator_next(BLI_Iterator *iter)
}
while (base) {
- if ((base->object->type == data->base_active->object->type) &&
- (base != data->base_active) &&
- (base->object->mode & data->object_mode))
+ if ((base != data->base_active) &&
+ base_is_in_mode(data, base) &&
+ object_bases_iterator_is_valid(data->v3d, base))
{
iter->current = base;
return;
diff --git a/source/blender/blenkernel/intern/layer_utils.c b/source/blender/blenkernel/intern/layer_utils.c
index 94bac8a33d6..fb25ca3ece4 100644
--- a/source/blender/blenkernel/intern/layer_utils.c
+++ b/source/blender/blenkernel/intern/layer_utils.c
@@ -40,11 +40,11 @@
#include "MEM_guardedalloc.h"
Base **BKE_view_layer_array_from_bases_in_mode_params(
- ViewLayer *view_layer, uint *r_len,
+ ViewLayer *view_layer, View3D *v3d, uint *r_len,
const struct ObjectsInModeParams *params)
{
if (params->no_dup_data) {
- FOREACH_BASE_IN_MODE_BEGIN(view_layer, params->object_mode, base_iter) {
+ FOREACH_BASE_IN_MODE_BEGIN(view_layer, v3d, -1, params->object_mode, base_iter) {
ID *id = base_iter->object->data;
if (id) {
id->tag |= LIB_TAG_DOIT;
@@ -55,7 +55,7 @@ Base **BKE_view_layer_array_from_bases_in_mode_params(
Base **base_array = NULL;
BLI_array_declare(base_array);
- FOREACH_BASE_IN_MODE_BEGIN(view_layer, params->object_mode, base_iter) {
+ FOREACH_BASE_IN_MODE_BEGIN(view_layer, v3d, -1, params->object_mode, base_iter) {
if (params->filter_fn) {
if (!params->filter_fn(base_iter->object, params->filter_userdata)) {
continue;
@@ -75,19 +75,21 @@ Base **BKE_view_layer_array_from_bases_in_mode_params(
BLI_array_append(base_array, base_iter);
} FOREACH_BASE_IN_MODE_END;
- if (base_array != NULL) {
- base_array = MEM_reallocN(base_array, sizeof(*base_array) * BLI_array_len(base_array));
+ base_array = MEM_reallocN(base_array, sizeof(*base_array) * BLI_array_len(base_array));
+ /* We always need a valid allocation (prevent crash on free). */
+ if (base_array == NULL) {
+ base_array = MEM_mallocN(0, __func__);
}
*r_len = BLI_array_len(base_array);
return base_array;
}
Object **BKE_view_layer_array_from_objects_in_mode_params(
- ViewLayer *view_layer, uint *r_len,
+ ViewLayer *view_layer, View3D *v3d, uint *r_len,
const struct ObjectsInModeParams *params)
{
Base **base_array = BKE_view_layer_array_from_bases_in_mode_params(
- view_layer, r_len, params);
+ view_layer, v3d, r_len, params);
if (base_array != NULL) {
for (uint i = 0; i < *r_len; i++) {
((Object **)base_array)[i] = base_array[i]->object;
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index aa6cbcc343e..b77b2f18b77 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -787,8 +787,8 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
/* tag grease pencil datablock and disable onion */
if (GS(id->name) == ID_GD) {
- DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA);
- DEG_id_tag_update(newid, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(newid, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
bGPdata *gpd = (bGPdata *)newid;
gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS;
}
@@ -979,7 +979,7 @@ void BKE_main_lib_objects_recalc_all(Main *bmain)
/* flag for full recalc */
for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ID_IS_LINKED(ob)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
}
}
@@ -1362,6 +1362,16 @@ void *BKE_libblock_copy_nolib(const ID *id, const bool do_action)
return idn;
}
+void *BKE_libblock_copy_for_localize(const ID *id)
+{
+ ID *idn;
+ BKE_libblock_copy_ex(NULL, id, &idn, (LIB_ID_CREATE_NO_MAIN |
+ LIB_ID_CREATE_NO_USER_REFCOUNT |
+ LIB_ID_COPY_ACTIONS |
+ LIB_ID_COPY_NO_ANIMDATA));
+ return idn;
+}
+
void BKE_library_free(Library *lib)
{
if (lib->packedfile)
@@ -2124,7 +2134,7 @@ void BKE_libblock_rename(Main *bmain, ID *id, const char *name)
}
/**
- * Generate full name of the data-block (without ID code, but with library is any)
+ * Generate full name of the data-block (without ID code, but with library if any).
*
* \note Result is unique to a given ID type in a given Main database.
*
@@ -2147,7 +2157,7 @@ void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id)
}
/**
- * Generate full name of the data-block (without ID code, but with library is any), with a 3-character prefix prepended
+ * Generate full name of the data-block (without ID code, but with library if any), with a 3-character prefix prepended
* indicating whether it comes from a library, is overriding, has a fake or no user, etc.
*
* \note Result is unique to a given ID type in a given Main database.
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index ea1b35e4c1e..a06be37f41d 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -101,8 +101,7 @@
BLI_assert(*(id_pp) == old_id); \
} \
if (old_id && (_flag & IDWALK_RECURSE)) { \
- if (!BLI_gset_haskey((_data)->ids_handled, old_id)) { \
- BLI_gset_add((_data)->ids_handled, old_id); \
+ if (BLI_gset_add((_data)->ids_handled, old_id)) { \
if (!(callback_return & IDWALK_RET_STOP_RECURSION)) { \
BLI_LINKSTACK_PUSH((_data)->ids_todo, old_id); \
} \
@@ -249,11 +248,11 @@ static void library_foreach_animationData(LibraryForeachIDData *data, AnimData *
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
/* only used targets */
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
FOREACH_CALLBACK_INVOKE_ID(data, dtar->id, IDWALK_CB_NOP);
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
@@ -320,8 +319,7 @@ static void library_foreach_ID_as_subdata_link(
if (flag & IDWALK_RECURSE) {
/* Defer handling into main loop, recursively calling BKE_library_foreach_ID_link in IDWALK_RECURSE case is
* troublesome, see T49553. */
- if (!BLI_gset_haskey(data->ids_handled, id)) {
- BLI_gset_add(data->ids_handled, id);
+ if (BLI_gset_add(data->ids_handled, id)) {
BLI_LINKSTACK_PUSH(data->ids_todo, id);
}
}
@@ -409,6 +407,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
CALLBACK_INVOKE(scene->world, IDWALK_CB_USER);
CALLBACK_INVOKE(scene->set, IDWALK_CB_NOP);
CALLBACK_INVOKE(scene->clip, IDWALK_CB_USER);
+ CALLBACK_INVOKE(scene->r.bake.cage_object, IDWALK_CB_NOP);
if (scene->nodetree) {
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
library_foreach_ID_as_subdata_link((ID **)&scene->nodetree, callback, user_data, flag, &data);
@@ -426,8 +425,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
for (SequenceModifierData *smd = seq->modifiers.first; smd; smd = smd->next) {
CALLBACK_INVOKE(smd->mask_id, IDWALK_CB_USER);
}
- }
- SEQ_END
+ } SEQ_END;
}
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 8b51fd43da3..3145d40dbdf 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -242,7 +242,7 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
if (!is_never_null) {
*id_p = new_id;
DEG_id_tag_update_ex(id_remap_data->bmain, id_self,
- DEG_TAG_COPY_ON_WRITE | DEG_TAG_TRANSFORM | DEG_TAG_GEOMETRY);
+ ID_RECALC_COPY_ON_WRITE | ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
if (cb_flag & IDWALK_CB_USER) {
id_us_min(old_id);
@@ -307,14 +307,14 @@ static void libblock_remap_data_postprocess_object_update(Main *bmain, Object *o
if (old_ob == NULL) {
for (Object *ob = bmain->object.first; ob != NULL; ob = ob->id.next) {
if (ob->type == OB_MBALL && BKE_mball_is_basis(ob)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
}
else {
for (Object *ob = bmain->object.first; ob != NULL; ob = ob->id.next) {
if (ob->type == OB_MBALL && BKE_mball_is_basis_for(ob, old_ob)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
break; /* There is only one basis... */
}
}
@@ -361,10 +361,10 @@ static void libblock_remap_data_postprocess_nodetree_update(Main *bmain, ID *new
ntreeVerifyNodes(bmain, new_id);
/* Update node trees as necessary. */
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
/* make an update call for the tree */
ntreeUpdateTree(bmain, ntree);
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
/**
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 6741ebf39d2..166408336ac 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -235,7 +235,7 @@ Material *BKE_material_localize(Material *ma)
*
* NOTE: Only possible once nested node trees are fully converted to that too. */
- Material *man = BKE_libblock_copy_nolib(&ma->id, false);
+ Material *man = BKE_libblock_copy_for_localize(&ma->id);
man->texpaintslot = NULL;
man->preview = NULL;
@@ -425,7 +425,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_id_tag_update(id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
}
@@ -444,7 +444,7 @@ 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_id_tag_update(id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
}
}
@@ -479,7 +479,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_id_tag_update(id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
}
}
@@ -507,7 +507,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_id_tag_update(id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
}
}
@@ -618,7 +618,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_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE | ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
}
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 0942cb071a3..608c9780beb 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -662,6 +662,8 @@ static Mesh *mesh_new_nomain_from_template_ex(
me_dst->totloop = loops_len;
me_dst->totpoly = polys_len;
+ me_dst->cd_flag = me_src->cd_flag;
+
CustomData_copy(&me_src->vdata, &me_dst->vdata, mask, CD_CALLOC, verts_len);
CustomData_copy(&me_src->edata, &me_dst->edata, mask, CD_CALLOC, edges_len);
CustomData_copy(&me_src->ldata, &me_dst->ldata, mask, CD_CALLOC, loops_len);
@@ -914,16 +916,25 @@ void BKE_mesh_texspace_calc(Mesh *me)
BoundBox *BKE_mesh_boundbox_get(Object *ob)
{
- Mesh *me = ob->data;
+ /* This is Object-level data access, DO NOT touch to Mesh's bb, would be totally thread-unsafe. */
+ if (ob->bb == NULL || ob->bb->flag & BOUNDBOX_DIRTY) {
+ Mesh *me = ob->data;
+ float min[3], max[3];
- if (ob->bb)
- return ob->bb;
+ INIT_MINMAX(min, max);
+ if (!BKE_mesh_minmax(me, min, max)) {
+ min[0] = min[1] = min[2] = -1.0f;
+ max[0] = max[1] = max[2] = 1.0f;
+ }
- if (me->bb == NULL || (me->bb->flag & BOUNDBOX_DIRTY)) {
- BKE_mesh_texspace_calc(me);
+ if (ob->bb == NULL) {
+ ob->bb = MEM_mallocN(sizeof(*ob->bb), __func__);
+ }
+ BKE_boundbox_init_from_minmax(ob->bb, min, max);
+ ob->bb->flag &= ~BOUNDBOX_DIRTY;
}
- return me->bb;
+ return ob->bb;
}
BoundBox *BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float r_size[3])
@@ -1910,5 +1921,8 @@ void BKE_mesh_eval_geometry(
DEG_debug_print_eval(depsgraph, __func__, mesh->id.name, mesh);
if (mesh->bb == NULL || (mesh->bb->flag & BOUNDBOX_DIRTY)) {
BKE_mesh_texspace_calc(mesh);
+ /* Clear autospace flag in evaluated mesh, so that texspace does not get recomputed when bbox is
+ * (e.g. after modifiers, etc.) */
+ mesh->texflag &= ~ME_AUTOSPACE;
}
}
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index eed02dae824..de131b9be47 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -815,10 +815,12 @@ void BKE_mesh_to_curve_nurblist(const Mesh *me, ListBase *nurblist, const int ed
}
}
-void BKE_mesh_to_curve(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
+void BKE_mesh_to_curve(Main *bmain, Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob)
{
/* make new mesh data from the original copy */
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_MESH);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_MESH);
ListBase nurblist = {NULL, NULL};
BKE_mesh_to_curve_nurblist(me_eval, &nurblist, 0);
diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c
index 0931318f17a..14d77b5288b 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.c
+++ b/source/blender/blenkernel/intern/mesh_runtime.c
@@ -354,7 +354,10 @@ bool BKE_mesh_runtime_is_valid(Mesh *me_eval)
}
is_valid &= BKE_mesh_validate_all_customdata(
- &me_eval->vdata, &me_eval->edata, &me_eval->ldata, &me_eval->pdata,
+ &me_eval->vdata, me_eval->totvert,
+ &me_eval->edata, me_eval->totedge,
+ &me_eval->ldata, me_eval->totloop,
+ &me_eval->pdata, me_eval->totpoly,
false, /* setting mask here isn't useful, gives false positives */
do_verbose, do_fixes,
&changed);
diff --git a/source/blender/blenkernel/intern/mesh_tangent.c b/source/blender/blenkernel/intern/mesh_tangent.c
index b8d260e6922..a222c681a5e 100644
--- a/source/blender/blenkernel/intern/mesh_tangent.c
+++ b/source/blender/blenkernel/intern/mesh_tangent.c
@@ -45,6 +45,7 @@
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_mesh_tangent.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_report.h"
#include "BLI_strict_flags.h"
@@ -695,6 +696,8 @@ void BKE_mesh_calc_loop_tangents(
Mesh *me_eval, bool calc_active_tangent,
const char (*tangent_names)[MAX_NAME], int tangent_names_len)
{
+ BKE_mesh_runtime_looptri_ensure(me_eval);
+
/* TODO(campbell): store in Mesh.runtime to avoid recalculation. */
short tangent_mask = 0;
BKE_mesh_calc_loop_tangent_ex(
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index af4d1265cfd..8ecb47c8591 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -820,7 +820,7 @@ bool BKE_mesh_validate_arrays(
}
static bool mesh_validate_customdata(
- CustomData *data, CustomDataMask mask,
+ CustomData *data, CustomDataMask mask, const uint totitems,
const bool do_verbose, const bool do_fixes,
bool *r_change)
{
@@ -859,8 +859,13 @@ static bool mesh_validate_customdata(
}
}
- if (ok)
+ if (ok) {
+ if (CustomData_layer_validate(layer, totitems, do_fixes)) {
+ PRINT_ERR("\tCustomDataLayer type %d has some invalid data\n", layer->type);
+ has_fixes = do_fixes;
+ }
i++;
+ }
}
PRINT_MSG("%s: Finished (is_valid=%d)\n\n", __func__, (int)!has_fixes);
@@ -874,8 +879,10 @@ static bool mesh_validate_customdata(
* \returns is_valid.
*/
bool BKE_mesh_validate_all_customdata(
- CustomData *vdata, CustomData *edata,
- CustomData *ldata, CustomData *pdata,
+ CustomData *vdata, const uint totvert,
+ CustomData *edata, const uint totedge,
+ CustomData *ldata, const uint totloop,
+ CustomData *pdata, const uint totpoly,
const bool check_meshmask,
const bool do_verbose, const bool do_fixes,
bool *r_change)
@@ -885,10 +892,10 @@ bool BKE_mesh_validate_all_customdata(
int tot_uvloop, tot_vcolloop;
CustomDataMask mask = check_meshmask ? CD_MASK_MESH : 0;
- is_valid &= mesh_validate_customdata(vdata, mask, do_verbose, do_fixes, &is_change_v);
- is_valid &= mesh_validate_customdata(edata, mask, do_verbose, do_fixes, &is_change_e);
- is_valid &= mesh_validate_customdata(ldata, mask, do_verbose, do_fixes, &is_change_l);
- is_valid &= mesh_validate_customdata(pdata, mask, do_verbose, do_fixes, &is_change_p);
+ is_valid &= mesh_validate_customdata(vdata, mask, totvert, do_verbose, do_fixes, &is_change_v);
+ is_valid &= mesh_validate_customdata(edata, mask, totedge, do_verbose, do_fixes, &is_change_e);
+ is_valid &= mesh_validate_customdata(ldata, mask, totloop, do_verbose, do_fixes, &is_change_l);
+ is_valid &= mesh_validate_customdata(pdata, mask, totpoly, do_verbose, do_fixes, &is_change_p);
tot_uvloop = CustomData_number_of_layers(ldata, CD_MLOOPUV);
tot_vcolloop = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
@@ -931,7 +938,10 @@ bool BKE_mesh_validate(Mesh *me, const bool do_verbose, const bool cddata_check_
}
is_valid &= BKE_mesh_validate_all_customdata(
- &me->vdata, &me->edata, &me->ldata, &me->pdata,
+ &me->vdata, me->totvert,
+ &me->edata, me->totedge,
+ &me->ldata, me->totloop,
+ &me->pdata, me->totpoly,
cddata_check_mask,
do_verbose, true,
&changed);
@@ -948,7 +958,7 @@ bool BKE_mesh_validate(Mesh *me, const bool do_verbose, const bool cddata_check_
&changed);
if (changed) {
- DEG_id_tag_update(&me->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
return true;
}
else {
@@ -972,7 +982,10 @@ bool BKE_mesh_is_valid(Mesh *me)
bool changed = true;
is_valid &= BKE_mesh_validate_all_customdata(
- &me->vdata, &me->edata, &me->ldata, &me->pdata,
+ &me->vdata, me->totvert,
+ &me->edata, me->totedge,
+ &me->ldata, me->totloop,
+ &me->pdata, me->totpoly,
false, /* setting mask here isn't useful, gives false positives */
do_verbose, do_fixes, &changed);
@@ -1012,7 +1025,7 @@ bool BKE_mesh_validate_material_indices(Mesh *me)
}
if (!is_valid) {
- DEG_id_tag_update(&me->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
return true;
}
else {
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 1ffeacbfd4e..166c915420f 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -916,20 +916,22 @@ struct DerivedMesh *modifier_applyModifier_DM_deprecated(
/**
* Get evaluated mesh for other evaluated object, which is used as an operand for the modifier,
* e.g. second operand for boolean modifier.
- * Note thqt modifiers in stack always get fully evaluated COW ID pointers, never original ones. Makes things simpler.
+ * Note that modifiers in stack always get fully evaluated COW ID pointers, never original ones. Makes things simpler.
*/
Mesh *BKE_modifier_get_evaluated_mesh_from_evaluated_object(Object *ob_eval, bool *r_free_mesh)
{
- Mesh *me;
+ Mesh *me = NULL;
if ((ob_eval->type == OB_MESH) && (ob_eval->mode & OB_MODE_EDIT)) {
/* Note: currently we have no equivalent to derived cagemesh or even final dm in BMEditMesh...
* This is TODO in core depsgraph/modifier stack code still. */
BMEditMesh *em = BKE_editmesh_from_object(ob_eval);
- me = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, 0);
- *r_free_mesh = true;
+ if (em != NULL) { /* em might not exist yet in some cases, just after loading a .blend file, see T57878. */
+ me = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, 0);
+ *r_free_mesh = true;
+ }
}
- else {
+ if (me == NULL) {
me = ob_eval->runtime.mesh_eval;
*r_free_mesh = false;
}
diff --git a/source/blender/blenkernel/intern/multires_reshape.c b/source/blender/blenkernel/intern/multires_reshape.c
index 72be2617798..af3219ca06c 100644
--- a/source/blender/blenkernel/intern/multires_reshape.c
+++ b/source/blender/blenkernel/intern/multires_reshape.c
@@ -1163,6 +1163,11 @@ bool multiresModifier_reshapeFromCCG(
return false;
}
MDisps *mdisps = CustomData_get_layer(&coarse_mesh->ldata, CD_MDISPS);
+ if (mdisps == NULL) {
+ /* Multires displacement has been removed before current changes were
+ * applies to all the levels. */
+ return false;
+ }
GridPaintMask *grid_paint_mask =
CustomData_get_layer(&coarse_mesh->ldata, CD_GRID_PAINT_MASK);
Subdiv *subdiv = subdiv_ccg->subdiv;
diff --git a/source/blender/blenkernel/intern/multires_subdiv.c b/source/blender/blenkernel/intern/multires_subdiv.c
index e0b316d49de..150e7192934 100644
--- a/source/blender/blenkernel/intern/multires_subdiv.c
+++ b/source/blender/blenkernel/intern/multires_subdiv.c
@@ -46,8 +46,8 @@ void BKE_multires_subdiv_settings_init(
const MultiresModifierData *mmd)
{
settings->is_simple = (mmd->simple != 0);
- settings->is_adaptive = !settings->is_simple;
- settings->level = mmd->quality;
+ settings->is_adaptive = true;
+ settings->level = settings->is_simple ? 1 : mmd->quality;
settings->vtx_boundary_interpolation = SUBDIV_VTX_BOUNDARY_EDGE_ONLY;
settings->fvar_linear_interpolation =
BKE_subdiv_fvar_interpolation_from_uv_smooth(mmd->uv_smooth);
@@ -64,4 +64,6 @@ void BKE_multires_subdiv_mesh_settings_init(
const int level = multires_get_level(
scene, object, mmd, use_render_params, ignore_simplify);
mesh_settings->resolution = (1 << level) + 1;
+ mesh_settings->use_optimal_display =
+ (mmd->flags & eMultiresModifierFlag_ControlEdges);
}
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 183fa37f84b..04cc58f373f 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -229,7 +229,7 @@ static void update_typeinfo(Main *bmain, const struct bContext *C, bNodeTreeType
if (!bmain)
return;
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
bNode *node;
bNodeSocket *sock;
@@ -260,7 +260,7 @@ static void update_typeinfo(Main *bmain, const struct bContext *C, bNodeTreeType
if (socktype && STREQ(sock->idname, socktype->idname))
node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
}
- FOREACH_NODETREE_END
+ FOREACH_NODETREE_END;
}
/* Try to initialize all typeinfo in a node tree.
@@ -921,7 +921,7 @@ bNode *nodeAddStaticNode(const struct bContext *C, bNodeTree *ntree, int type)
{
const char *idname = NULL;
- NODE_TYPES_BEGIN(ntype)
+ NODE_TYPES_BEGIN(ntype) {
/* do an extra poll here, because some int types are used
* for multiple node types, this helps find the desired type
*/
@@ -929,7 +929,7 @@ bNode *nodeAddStaticNode(const struct bContext *C, bNodeTree *ntree, int type)
idname = ntype->idname;
break;
}
- NODE_TYPES_END
+ } NODE_TYPES_END;
if (!idname) {
printf("Error: static node type %d undefined\n", type);
return NULL;
@@ -2991,13 +2991,13 @@ static void ntree_validate_links(bNodeTree *ntree)
void ntreeVerifyNodes(struct Main *main, struct ID *id)
{
- FOREACH_NODETREE(main, ntree, owner_id) {
+ FOREACH_NODETREE_BEGIN(main, ntree, owner_id) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next)
if (node->typeinfo->verifyfunc)
node->typeinfo->verifyfunc(ntree, node, id);
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
void ntreeUpdateTree(Main *bmain, bNodeTree *ntree)
@@ -3645,23 +3645,23 @@ void init_nodesystem(void)
void free_nodesystem(void)
{
if (nodetypes_hash) {
- NODE_TYPES_BEGIN(nt)
+ NODE_TYPES_BEGIN(nt) {
if (nt->ext.free) {
nt->ext.free(nt->ext.data);
}
- NODE_TYPES_END
+ } NODE_TYPES_END;
BLI_ghash_free(nodetypes_hash, NULL, node_free_type);
nodetypes_hash = NULL;
}
if (nodesockettypes_hash) {
- NODE_SOCKET_TYPES_BEGIN(st)
+ NODE_SOCKET_TYPES_BEGIN(st) {
if (st->ext_socket.free)
st->ext_socket.free(st->ext_socket.data);
if (st->ext_interface.free)
st->ext_interface.free(st->ext_interface.data);
- NODE_SOCKET_TYPES_END
+ } NODE_SOCKET_TYPES_END;
BLI_ghash_free(nodesockettypes_hash, NULL, node_free_socket_type);
nodesockettypes_hash = NULL;
@@ -3683,7 +3683,7 @@ void free_nodesystem(void)
/* -------------------------------------------------------------------- */
-/* NodeTree Iterator Helpers (FOREACH_NODETREE) */
+/* NodeTree Iterator Helpers (FOREACH_NODETREE_BEGIN) */
void BKE_node_tree_iter_init(struct NodeTreeIterStore *ntreeiter, struct Main *bmain)
{
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index cc131ca895e..3d990ca5a77 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -425,6 +425,9 @@ static void object_update_from_subsurf_ccg(Object *object)
Mesh *mesh_cow = object->runtime.mesh_orig;
copy_ccg_data(mesh_cow, mesh_orig, CD_MDISPS);
copy_ccg_data(mesh_cow, mesh_orig, CD_GRID_PAINT_MASK);
+ /* Everything is now up-to-date. */
+ subdiv_ccg->dirty.coords = false;
+ subdiv_ccg->dirty.hidden = false;
}
/* free data derived from mesh, called when mesh changes or is freed */
@@ -514,7 +517,7 @@ void BKE_object_free_caches(Object *object)
psys = psys->next)
{
psys_free_path_cache(psys, psys->edit);
- update_flag |= PSYS_RECALC_REDO;
+ update_flag |= ID_RECALC_PSYS_REDO;
}
}
@@ -530,7 +533,7 @@ void BKE_object_free_caches(Object *object)
psmd->mesh_original = NULL;
}
psmd->flag |= eParticleSystemFlag_file_loaded;
- update_flag |= OB_RECALC_DATA;
+ update_flag |= ID_RECALC_GEOMETRY;
}
}
}
@@ -541,7 +544,7 @@ void BKE_object_free_caches(Object *object)
*/
if ((object->base_flag & BASE_FROMDUPLI) == 0) {
BKE_object_free_derived_caches(object);
- update_flag |= OB_RECALC_DATA;
+ update_flag |= ID_RECALC_GEOMETRY;
}
/* Tag object for update, so once memory critical operation is over and
@@ -582,7 +585,7 @@ void BKE_object_free(Object *ob, const int flag)
BKE_constraints_free_ex(&ob->constraints, false);
- free_partdeflect(ob->pd);
+ BKE_partdeflect_free(ob->pd);
BKE_rigidbody_free_object(ob, NULL);
BKE_rigidbody_free_constraint(ob);
@@ -901,7 +904,7 @@ static Object *object_add_common(Main *bmain, ViewLayer *view_layer, int type, c
ob->data = BKE_object_obdata_add_from_type(bmain, type, name);
BKE_view_layer_base_deselect_all(view_layer);
- DEG_id_tag_update_ex(bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update_ex(bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
return ob;
}
@@ -975,7 +978,7 @@ Object *BKE_object_add_for_data(
if (do_id_user) id_us_plus(data);
BKE_view_layer_base_deselect_all(view_layer);
- DEG_id_tag_update_ex(bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update_ex(bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
layer_collection = BKE_layer_collection_get_active(view_layer);
BKE_collection_object_add(bmain, layer_collection->collection, ob);
@@ -1224,14 +1227,14 @@ Object *BKE_object_pose_armature_get_visible(Object *ob, ViewLayer *view_layer,
/**
* Access pose array with special check to get pose object when in weight paint mode.
*/
-Object **BKE_object_pose_array_get_ex(ViewLayer *view_layer, uint *r_objects_len, bool unique)
+Object **BKE_object_pose_array_get_ex(ViewLayer *view_layer, View3D *v3d, uint *r_objects_len, bool unique)
{
Object *ob_active = OBACT(view_layer);
Object *ob_pose = BKE_object_pose_armature_get(ob_active);
Object **objects = NULL;
if (ob_pose == ob_active) {
objects = BKE_view_layer_array_from_objects_in_mode(
- view_layer, r_objects_len, {
+ view_layer, v3d, r_objects_len, {
.object_mode = OB_MODE_POSE,
.no_dup_data = unique});
}
@@ -1246,16 +1249,16 @@ Object **BKE_object_pose_array_get_ex(ViewLayer *view_layer, uint *r_objects_len
}
return objects;
}
-Object **BKE_object_pose_array_get_unique(ViewLayer *view_layer, uint *r_objects_len)
+Object **BKE_object_pose_array_get_unique(ViewLayer *view_layer, View3D *v3d, uint *r_objects_len)
{
- return BKE_object_pose_array_get_ex(view_layer, r_objects_len, true);
+ return BKE_object_pose_array_get_ex(view_layer, v3d, r_objects_len, true);
}
-Object **BKE_object_pose_array_get(ViewLayer *view_layer, uint *r_objects_len)
+Object **BKE_object_pose_array_get(ViewLayer *view_layer, View3D *v3d, uint *r_objects_len)
{
- return BKE_object_pose_array_get_ex(view_layer, r_objects_len, false);
+ return BKE_object_pose_array_get_ex(view_layer, v3d, r_objects_len, false);
}
-Base **BKE_object_pose_base_array_get_ex(ViewLayer *view_layer, uint *r_bases_len, bool unique)
+Base **BKE_object_pose_base_array_get_ex(ViewLayer *view_layer, View3D *v3d, uint *r_bases_len, bool unique)
{
Base *base_active = BASACT(view_layer);
Object *ob_pose = base_active ? BKE_object_pose_armature_get(base_active->object) : NULL;
@@ -1273,7 +1276,7 @@ Base **BKE_object_pose_base_array_get_ex(ViewLayer *view_layer, uint *r_bases_le
if (base_active && (base_pose == base_active)) {
bases = BKE_view_layer_array_from_bases_in_mode(
- view_layer, r_bases_len, {
+ view_layer, v3d, r_bases_len, {
.object_mode = OB_MODE_POSE,
.no_dup_data = unique});
}
@@ -1288,13 +1291,13 @@ Base **BKE_object_pose_base_array_get_ex(ViewLayer *view_layer, uint *r_bases_le
}
return bases;
}
-Base **BKE_object_pose_base_array_get_unique(ViewLayer *view_layer, uint *r_bases_len)
+Base **BKE_object_pose_base_array_get_unique(ViewLayer *view_layer, View3D *v3d, uint *r_bases_len)
{
- return BKE_object_pose_base_array_get_ex(view_layer, r_bases_len, true);
+ return BKE_object_pose_base_array_get_ex(view_layer, v3d, r_bases_len, true);
}
-Base **BKE_object_pose_base_array_get(ViewLayer *view_layer, uint *r_bases_len)
+Base **BKE_object_pose_base_array_get(ViewLayer *view_layer, View3D *v3d, uint *r_bases_len)
{
- return BKE_object_pose_base_array_get_ex(view_layer, r_bases_len, false);
+ return BKE_object_pose_base_array_get_ex(view_layer, v3d, r_bases_len, false);
}
void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src)
@@ -1528,7 +1531,7 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
/* all drivers */
- DRIVER_TARGETS_LOOPER(dvar)
+ DRIVER_TARGETS_LOOPER_BEGIN(dvar)
{
if (dtar->id) {
if ((Object *)dtar->id == target)
@@ -1542,7 +1545,7 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
}
}
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
}
@@ -1564,8 +1567,8 @@ void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob)
ob->proxy_group = cob;
id_lib_extern(&target->id);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
- DEG_id_tag_update(&target->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
+ DEG_id_tag_update(&target->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
/* copy transform
* - cob means this proxy comes from a collection, just apply the matrix
@@ -2513,7 +2516,10 @@ void BKE_object_boundbox_calc_from_mesh(struct Object *ob, struct Mesh *me_eval)
INIT_MINMAX(min, max);
- BKE_mesh_minmax(me_eval, min, max);
+ if (!BKE_mesh_minmax(me_eval, min, max)) {
+ zero_v3(min);
+ zero_v3(max);
+ }
if (ob->bb == NULL) {
ob->bb = MEM_callocN(sizeof(BoundBox), "DM-BoundBox");
@@ -2853,7 +2859,7 @@ void BKE_object_handle_update_ex(Depsgraph *depsgraph,
const bool do_proxy_update)
{
const ID *object_data = ob->data;
- const bool recalc_object = (ob->id.recalc & ID_RECALC) != 0;
+ const bool recalc_object = (ob->id.recalc & ID_RECALC_ALL) != 0;
const bool recalc_data =
(object_data != NULL) ? ((object_data->recalc & ID_RECALC_ALL) != 0)
: 0;
@@ -2880,9 +2886,9 @@ void BKE_object_handle_update_ex(Depsgraph *depsgraph,
}
}
}
- /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers,
+ /* XXX new animsys warning: depsgraph tag ID_RECALC_GEOMETRY should not skip drivers,
* which is only in BKE_object_where_is_calc now */
- /* XXX: should this case be OB_RECALC_OB instead? */
+ /* XXX: should this case be ID_RECALC_TRANSFORM instead? */
if (recalc_object || recalc_data) {
if (G.debug & G_DEBUG_DEPSGRAPH_EVAL) {
printf("recalcob %s\n", ob->id.name + 2);
@@ -3693,7 +3699,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);
+ DEG_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
}
}
@@ -4014,7 +4020,7 @@ bool BKE_object_modifier_update_subframe(
}
}
- /* was originally OB_RECALC_ALL - TODO - which flags are really needed??? */
+ /* was originally ID_RECALC_ALL - TODO - which flags are really needed??? */
/* TODO(sergey): What about animation? */
ob->id.recalc |= ID_RECALC_ALL;
BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, frame, ADT_RECALC_ANIM);
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index dc144f48b05..10bf6aed898 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -142,14 +142,6 @@ void BKE_object_eval_transform_final(Depsgraph *depsgraph, Object *ob)
/* Set negative scale flag in object. */
if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
else ob->transflag &= ~OB_NEG_SCALE;
-
- if (DEG_is_active(depsgraph)) {
- Object *ob_orig = DEG_get_original_object(ob);
- copy_m4_m4(ob_orig->obmat, ob->obmat);
- copy_m4_m4(ob_orig->constinv, ob->constinv);
- ob_orig->transflag = ob->transflag;
- ob_orig->flag = ob->flag;
- }
}
void BKE_object_handle_data_update(
@@ -225,7 +217,7 @@ void BKE_object_handle_data_update(
case OB_CURVE:
case OB_SURF:
case OB_FONT:
- BKE_displist_make_curveTypes(depsgraph, scene, ob, 0);
+ BKE_displist_make_curveTypes(depsgraph, scene, ob, false, false);
break;
case OB_LATTICE:
@@ -271,6 +263,8 @@ void BKE_object_handle_data_update(
BKE_object_eval_boundbox(depsgraph, ob);
}
+/* TODO(sergey): Ensure that bounding box is already calculated, and move this
+ * into BKE_object_synchronize_to_original(). */
void BKE_object_eval_boundbox(Depsgraph *depsgraph, Object *object)
{
if (!DEG_is_active(depsgraph)) {
@@ -286,6 +280,33 @@ void BKE_object_eval_boundbox(Depsgraph *depsgraph, Object *object)
}
}
+void BKE_object_synchronize_to_original(Depsgraph *depsgraph, Object *object)
+{
+ if (!DEG_is_active(depsgraph)) {
+ return;
+ }
+ Object *object_orig = DEG_get_original_object(object);
+ /* Base flags. */
+ object_orig->base_flag = object->base_flag;
+ /* Transformation flags. */
+ copy_m4_m4(object_orig->obmat, object->obmat);
+ copy_m4_m4(object_orig->constinv, object->constinv);
+ object_orig->transflag = object->transflag;
+ object_orig->flag = object->flag;
+
+ /* Copy back error messages from modifiers. */
+ for (ModifierData *md = object->modifiers.first, *md_orig = object_orig->modifiers.first;
+ md != NULL && md_orig != NULL;
+ md = md->next, md_orig = md_orig->next)
+ {
+ BLI_assert(md->type == md_orig->type && STREQ(md->name, md_orig->name));
+ MEM_SAFE_FREE(md_orig->error);
+ if (md->error != NULL) {
+ md_orig->error = BLI_strdup(md->error);
+ }
+ }
+}
+
bool BKE_object_eval_proxy_copy(Depsgraph *depsgraph,
Object *object)
{
@@ -428,12 +449,7 @@ void BKE_object_eval_flush_base_flags(Depsgraph *depsgraph,
object->base_flag |= BASE_FROM_SET;
object->base_flag &= ~(BASE_SELECTED | BASE_SELECTABLE);
}
-
- /* Copy to original object datablock if needed. */
- if (DEG_is_active(depsgraph)) {
- Object *object_orig = DEG_get_original_object(object);
- object_orig->base_flag = object->base_flag;
- }
+ object->base_local_view_bits = base->local_view_bits;
if (object->mode == OB_MODE_PARTICLE_EDIT) {
for (ParticleSystem *psys = object->particlesystem.first;
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 9445981538e..e7c10f070dc 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -664,11 +664,13 @@ bool BKE_paint_ensure(const ToolSettings *ts, struct Paint **r_paint)
return true;
}
- if (ELEM(*r_paint, &ts->vpaint->paint, &ts->wpaint->paint)) {
+ if (((VPaint **)r_paint == &ts->vpaint) ||
+ ((VPaint **)r_paint == &ts->wpaint))
+ {
VPaint *data = MEM_callocN(sizeof(*data), __func__);
paint = &data->paint;
}
- else if (*r_paint == &ts->sculpt->paint) {
+ else if ((Sculpt **)r_paint == &ts->sculpt) {
Sculpt *data = MEM_callocN(sizeof(*data), __func__);
paint = &data->paint;
@@ -678,11 +680,11 @@ bool BKE_paint_ensure(const ToolSettings *ts, struct Paint **r_paint)
/* Make sure at least dyntopo subdivision is enabled */
data->flags |= SCULPT_DYNTOPO_SUBDIVIDE | SCULPT_DYNTOPO_COLLAPSE;
}
- else if (*r_paint == &ts->gp_paint->paint) {
+ else if ((GpPaint **)r_paint == &ts->gp_paint) {
GpPaint *data = MEM_callocN(sizeof(*data), __func__);
paint = &data->paint;
}
- else if (*r_paint == &ts->uvsculpt->paint) {
+ else if ((UvSculpt **)r_paint == &ts->uvsculpt) {
UvSculpt *data = MEM_callocN(sizeof(*data), __func__);
paint = &data->paint;
}
@@ -919,7 +921,7 @@ void BKE_sculptsession_bm_to_me(Object *ob, bool reorder)
sculptsession_bm_to_me_update_data_only(ob, reorder);
/* 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);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
@@ -1096,7 +1098,7 @@ void BKE_sculpt_update_mesh_elements(
#else /* if we wanted to support adding mask data while multi-res painting, we would need to do this */
if ((ED_sculpt_mask_layers_ensure(ob, mmd) & ED_SCULPT_MASK_LAYER_CALC_LOOP)) {
/* remake the derived mesh */
- ob->recalc |= OB_RECALC_DATA;
+ ob->recalc |= ID_RECALC_GEOMETRY;
BKE_object_handle_update(scene, ob);
}
#endif
@@ -1406,7 +1408,7 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob)
}
else if (ob->type == OB_MESH) {
Mesh *me_eval_deform = mesh_get_eval_deform(
- depsgraph, DEG_get_evaluated_scene(depsgraph), ob, CD_MASK_BAREMESH);
+ depsgraph, DEG_get_evaluated_scene(depsgraph), object_eval, CD_MASK_BAREMESH);
pbvh = build_pbvh_from_regular_mesh(ob, me_eval_deform);
}
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 360dcd7b26a..5bfadd9b277 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -442,8 +442,8 @@ void BKE_particlesettings_free(ParticleSettings *part)
if (part->twistcurve)
curvemapping_free(part->twistcurve);
- free_partdeflect(part->pd);
- free_partdeflect(part->pd2);
+ BKE_partdeflect_free(part->pd);
+ BKE_partdeflect_free(part->pd2);
MEM_SAFE_FREE(part->effector_weights);
@@ -469,6 +469,7 @@ void free_hair(Object *object, ParticleSystem *psys, int dynamics)
if (psys->clmd) {
if (dynamics) {
modifier_free((ModifierData *)psys->clmd);
+ psys->clmd = NULL;
PTCacheID pid;
BKE_ptcache_id_from_particles(&pid, object, psys);
BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0);
@@ -3087,7 +3088,7 @@ ModifierData *object_add_particle_system(Main *bmain, Scene *scene, Object *ob,
psys->cfra = BKE_scene_frame_get_from_ctime(scene, CFRA + 1);
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
return md;
}
@@ -3133,10 +3134,10 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob
ob->mode &= ~OB_MODE_PARTICLE_EDIT;
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
/* Flush object mode. */
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
static void default_particle_settings(ParticleSettings *part)
@@ -3212,7 +3213,7 @@ static void default_particle_settings(ParticleSettings *part)
part->draw_col = PART_DRAW_COL_MAT;
if (!part->effector_weights)
- part->effector_weights = BKE_add_effector_weights(NULL);
+ part->effector_weights = BKE_effector_add_weights(NULL);
part->omat = 1;
part->use_modifier_stack = false;
@@ -3246,6 +3247,8 @@ void BKE_particlesettings_clump_curve_init(ParticleSettings *part)
cumap->cm[0].curve[1].x = 1.0f;
cumap->cm[0].curve[1].y = 1.0f;
+ curvemapping_initialize(cumap);
+
part->clumpcurve = cumap;
}
@@ -3258,6 +3261,8 @@ void BKE_particlesettings_rough_curve_init(ParticleSettings *part)
cumap->cm[0].curve[1].x = 1.0f;
cumap->cm[0].curve[1].y = 1.0f;
+ curvemapping_initialize(cumap);
+
part->roughcurve = cumap;
}
@@ -3270,6 +3275,8 @@ void BKE_particlesettings_twist_curve_init(ParticleSettings *part)
cumap->cm[0].curve[1].x = 1.0f;
cumap->cm[0].curve[1].y = 1.0f;
+ curvemapping_initialize(cumap);
+
part->twistcurve = cumap;
}
@@ -4207,9 +4214,7 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3]
/* can happen with bad pointcache or physics calculation
* since this becomes geometry, nan's and inf's crash raytrace code.
* better not allow this. */
- if ((!isfinite(bb->vec[0])) || (!isfinite(bb->vec[1])) || (!isfinite(bb->vec[2])) ||
- (!isfinite(bb->vel[0])) || (!isfinite(bb->vel[1])) || (!isfinite(bb->vel[2])) )
- {
+ if (!is_finite_v3(bb->vec) || !is_finite_v3(bb->vec)) {
zero_v3(bb->vec);
zero_v3(bb->vel);
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index 6c5a9085e71..bbb8a96dd4d 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -487,7 +487,7 @@ static void distribute_from_verts_exec(ParticleTask *thread, ParticleData *pa, i
}
#endif
- BLI_assert(rng_skip_tot > 0); /* should never be below zero */
+ BLI_assert(rng_skip_tot >= 0); /* should never be below zero */
if (rng_skip_tot > 0) {
BLI_rng_skip(thread->rng, rng_skip_tot);
}
@@ -531,7 +531,7 @@ static void distribute_from_faces_exec(ParticleTask *thread, ParticleData *pa, i
}
pa->foffset= 0.0f;
- BLI_assert(rng_skip_tot > 0); /* should never be below zero */
+ BLI_assert(rng_skip_tot >= 0); /* should never be below zero */
if (rng_skip_tot > 0) {
BLI_rng_skip(thread->rng, rng_skip_tot);
}
@@ -628,7 +628,7 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
}
}
- BLI_assert(rng_skip_tot > 0); /* should never be below zero */
+ BLI_assert(rng_skip_tot >= 0); /* should never be below zero */
if (rng_skip_tot > 0) {
BLI_rng_skip(thread->rng, rng_skip_tot);
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index bcaebc9bf15..2cb9dd0e6f7 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -2916,10 +2916,10 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra, cons
ParticleEditSettings *pset = &sim->scene->toolsettings->particle;
int distr=0, alloc=0, skip=0;
- if ((psys->part->childtype && psys->totchild != psys_get_tot_child(sim->scene, psys, use_render_params)) || psys->recalc&PSYS_RECALC_RESET)
+ if ((psys->part->childtype && psys->totchild != psys_get_tot_child(sim->scene, psys, use_render_params)) || psys->recalc&ID_RECALC_PSYS_RESET)
alloc=1;
- if (alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT)))
+ if (alloc || psys->recalc&ID_RECALC_PSYS_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT)))
distr=1;
if (distr) {
@@ -3248,7 +3248,7 @@ static void hair_step(ParticleSimulationData *sim, float cfra, const bool use_re
pa->flag &= ~PARS_NO_DISP;
}
- if (psys->recalc & PSYS_RECALC_RESET) {
+ if (psys->recalc & ID_RECALC_PSYS_RESET) {
/* need this for changing subsurf levels */
psys_calc_dmcache(sim->ob, sim->psmd->mesh_final, sim->psmd->mesh_original, psys);
@@ -3964,7 +3964,7 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
BKE_ptcache_id_time(pid, sim->scene, 0.0f, &startframe, &endframe, NULL);
/* clear everything on start frame, or when psys needs full reset! */
- if ((cfra == startframe) || (psys->recalc & PSYS_RECALC_RESET)) {
+ if ((cfra == startframe) || (psys->recalc & ID_RECALC_PSYS_RESET)) {
BKE_ptcache_id_reset(sim->scene, pid, PTCACHE_RESET_OUTDATED);
BKE_ptcache_validate(cache, startframe);
cache->flag &= ~PTCACHE_REDO_NEEDED;
@@ -3975,7 +3975,7 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
/* 1. emit particles and redo particles if needed */
oldtotpart = psys->totpart;
- if (emit_particles(sim, pid, cfra) || psys->recalc & PSYS_RECALC_RESET) {
+ if (emit_particles(sim, pid, cfra) || psys->recalc & ID_RECALC_PSYS_RESET) {
distribute_particles(sim, part->from);
initialize_all_particles(sim);
/* reset only just created particles (on startframe all particles are recreated) */
@@ -4200,7 +4200,7 @@ static void psys_prepare_physics(ParticleSimulationData *sim)
static int hair_needs_recalc(ParticleSystem *psys)
{
if (!(psys->flag & PSYS_EDITED) && (!psys->edit || !psys->edit->edited) &&
- ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_RESET || (psys->part->flag & PART_HAIR_REGROW && !psys->edit)))
+ ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & ID_RECALC_PSYS_RESET || (psys->part->flag & PART_HAIR_REGROW && !psys->edit)))
{
return 1;
}
@@ -4253,7 +4253,7 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o
/* to verify if we need to restore object afterwards */
psys->flag &= ~PSYS_OB_ANIM_RESTORE;
- if (psys->recalc & PSYS_RECALC_RESET)
+ if (psys->recalc & ID_RECALC_PSYS_RESET)
psys->totunexist = 0;
/* setup necessary physics type dependent additional data if it doesn't yet exist */
@@ -4320,10 +4320,10 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o
bool free_unexisting = false;
/* Particles without dynamics haven't been reset yet because they don't use pointcache */
- if (psys->recalc & PSYS_RECALC_RESET)
+ if (psys->recalc & ID_RECALC_PSYS_RESET)
psys_reset(psys, PSYS_RESET_ALL);
- if (emit_particles(&sim, NULL, cfra) || (psys->recalc & PSYS_RECALC_RESET)) {
+ if (emit_particles(&sim, NULL, cfra) || (psys->recalc & ID_RECALC_PSYS_RESET)) {
free_keyed_keys(psys);
distribute_particles(&sim, part->from);
initialize_all_particles(&sim);
@@ -4436,7 +4436,7 @@ void BKE_particle_system_eval_init(struct Depsgraph *depsgraph,
psys != NULL;
psys = psys->next)
{
- psys->recalc |= (psys->part->id.recalc & DEG_TAG_PSYS_ALL);
+ psys->recalc |= (psys->part->id.recalc & ID_RECALC_PSYS_ALL);
}
BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH);
}
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index fab561177af..5f79f266418 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -78,8 +78,6 @@
#include "BIK_api.h"
-#include "DEG_depsgraph.h"
-
#ifdef WITH_BULLET
# include "RBI_api.h"
#endif
@@ -3560,7 +3558,7 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
/* children or just redo can be calculated without resetting anything */
- if (psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD)
+ if (psys->recalc & ID_RECALC_PSYS_REDO || psys->recalc & ID_RECALC_PSYS_CHILD)
skip = 1;
/* Baked cloth hair has to be checked too, because we don't want to reset */
/* particles or cloth in that case -jahka */
@@ -3627,7 +3625,6 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
if (ob->type == OB_ARMATURE)
BIK_clear_cache(ob->pose);
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
return reset;
}
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 0cfaa34f9da..71fa09ed31e 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -171,7 +171,7 @@ void BKE_rigidbody_free_world(Scene *scene)
void BKE_rigidbody_free_object(Object *ob, RigidBodyWorld *rbw)
{
bool is_orig = (ob->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0;
- RigidBodyOb *rbo = (ob) ? ob->rigidbody_object : NULL;
+ RigidBodyOb *rbo = ob->rigidbody_object;
/* sanity check */
if (rbo == NULL)
@@ -1043,7 +1043,7 @@ RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene)
rbw->shared = MEM_callocN(sizeof(*rbw->shared), "RigidBodyWorld_Shared");
/* set default settings */
- rbw->effector_weights = BKE_add_effector_weights(NULL);
+ rbw->effector_weights = BKE_effector_add_weights(NULL);
rbw->ltime = PSFRA;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 73b800076d1..36b75d993a9 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -113,7 +113,7 @@
#include "bmesh.h"
const char *RE_engine_id_BLENDER_EEVEE = "BLENDER_EEVEE";
-const char *RE_engine_id_BLENDER_OPENGL = "BLENDER_OPENGL";
+const char *RE_engine_id_BLENDER_WORKBENCH = "BLENDER_WORKBENCH";
const char *RE_engine_id_CYCLES = "CYCLES";
void free_avicodecdata(AviCodecData *acd)
@@ -550,6 +550,8 @@ void BKE_scene_init(Scene *sce)
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(sce, id));
+ unit_qt(sce->cursor.rotation);
+
sce->r.mode = R_OSA;
sce->r.cfra = 1;
sce->r.sfra = 1;
@@ -761,7 +763,8 @@ void BKE_scene_init(Scene *sce)
colorspace_name = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_SEQUENCER);
BKE_color_managed_display_settings_init(&sce->display_settings);
- BKE_color_managed_view_settings_init(&sce->view_settings);
+ BKE_color_managed_view_settings_init_render(&sce->view_settings,
+ &sce->display_settings);
BLI_strncpy(sce->sequencer_colorspace_settings.name, colorspace_name,
sizeof(sce->sequencer_colorspace_settings.name));
@@ -856,8 +859,9 @@ void BKE_scene_init(Scene *sce)
BKE_view_layer_add(sce, "View Layer");
/* SceneDisplay */
- copy_v3_v3(sce->display.light_direction, (float[3]){-M_SQRT1_3, -M_SQRT1_3, M_SQRT1_3});
- sce->display.shadow_shift = 0.1;
+ copy_v3_v3(sce->display.light_direction, (float[3]){M_SQRT1_3, M_SQRT1_3, M_SQRT1_3});
+ sce->display.shadow_shift = 0.1f;
+ sce->display.shadow_focus = 0.0f;
sce->display.matcap_ssao_distance = 0.2f;
sce->display.matcap_ssao_attenuation = 1.0f;
@@ -1197,7 +1201,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);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
return 1;
}
#else
@@ -1617,9 +1621,9 @@ bool BKE_scene_uses_blender_eevee(const Scene *scene)
return STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE);
}
-bool BKE_scene_uses_blender_opengl(const Scene *scene)
+bool BKE_scene_uses_blender_workbench(const Scene *scene)
{
- return STREQ(scene->r.engine, RE_engine_id_BLENDER_OPENGL);
+ return STREQ(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH);
}
bool BKE_scene_uses_cycles(const Scene *scene)
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 0c93281bf84..225f74616cf 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -309,6 +309,30 @@ void BKE_spacedata_draw_locks(int set)
}
}
+/**
+ * Version of #BKE_area_find_region_type that also works if \a slink is not the active space of \a sa.
+ */
+ARegion *BKE_spacedata_find_region_type(const SpaceLink *slink, const ScrArea *sa, int region_type)
+{
+ const bool is_slink_active = slink == sa->spacedata.first;
+ const ListBase *regionbase = (is_slink_active) ?
+ &sa->regionbase : &slink->regionbase;
+ ARegion *ar = NULL;
+
+ BLI_assert(BLI_findindex(&sa->spacedata, slink) != -1);
+ for (ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == region_type) {
+ break;
+ }
+ }
+
+ /* Should really unit test this instead. */
+ BLI_assert(!is_slink_active || ar == BKE_area_find_region_type(sa, region_type));
+
+ return ar;
+}
+
+
static void (*spacedata_id_remap_cb)(struct ScrArea *sa, struct SpaceLink *sl, ID *old_id, ID *new_id) = NULL;
void BKE_spacedata_callback_id_remap_set(void (*func)(ScrArea *sa, SpaceLink *sl, ID *, ID *))
@@ -644,17 +668,21 @@ void BKE_screen_remove_unused_scrverts(bScreen *sc)
/* ***************** Utilities ********************** */
-/* Find a region of the specified type from the given area */
-ARegion *BKE_area_find_region_type(ScrArea *sa, int type)
+/**
+ * Find a region of type \a region_type in the currently active space of \a sa.
+ *
+ * \note This does _not_ work if the region to look up is not in the active
+ * space. Use #BKE_spacedata_find_region_type if that may be the case.
+ */
+ARegion *BKE_area_find_region_type(const ScrArea *sa, int region_type)
{
if (sa) {
- ARegion *ar;
-
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == type)
+ for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == region_type)
return ar;
}
}
+
return NULL;
}
@@ -794,6 +822,8 @@ void BKE_screen_view3d_shading_init(View3DShading *shading)
shading->xray_alpha_wire = 0.5f;
shading->cavity_valley_factor = 1.0f;
shading->cavity_ridge_factor = 1.0f;
+ shading->curvature_ridge_factor = 1.0f;
+ shading->curvature_valley_factor = 1.0f;
copy_v3_fl(shading->single_color, 0.8f);
copy_v3_fl(shading->background_color, 0.05f);
}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 0d506effae6..c02a47db321 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -474,8 +474,7 @@ void BKE_sequencer_editing_free(Scene *scene, const bool do_id_user)
{
/* handle cache freeing above */
BKE_sequence_free_ex(scene, seq, false, do_id_user);
- }
- SEQ_END
+ } SEQ_END;
BLI_freelistN(&ed->metastack);
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 0da60b92f4b..06e5cc9e849 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -60,6 +60,8 @@
#include "BKE_subsurf.h"
#include "BKE_mesh_runtime.h"
+#include "DEG_depsgraph_query.h"
+
#include "MEM_guardedalloc.h"
#include "BLI_strict_flags.h"
@@ -91,8 +93,9 @@ typedef struct ShrinkwrapCalcData {
struct SpaceTransform local2target; //transform to move between local and target space
struct ShrinkwrapTreeData *tree; // mesh BVH tree data
- float keepDist; //Distance to keep above target surface (units are in local space)
+ struct Object *aux_target;
+ float keepDist; //Distance to keep above target surface (units are in local space)
} ShrinkwrapCalcData;
typedef struct ShrinkwrapCalcCBData {
@@ -141,6 +144,7 @@ bool BKE_shrinkwrap_init_tree(ShrinkwrapTreeData *data, Mesh *mesh, int shrinkTy
}
if (force_normals || BKE_shrinkwrap_needs_normals(shrinkType, shrinkMode)) {
+ data->pnors = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
if ((mesh->flag & ME_AUTOSMOOTH) != 0) {
data->clnors = CustomData_get_layer(&mesh->ldata, CD_NORMAL);
}
@@ -527,25 +531,18 @@ static void shrinkwrap_calc_normal_projection_cb_ex(
return;
}
- if (calc->vert) {
+ if (calc->vert != NULL && calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
/* 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) {
- copy_v3_v3(tmp_co, calc->vert[i].co);
- normal_short_to_float_v3(tmp_no, calc->vert[i].no);
- }
- else {
- copy_v3_v3(tmp_co, co);
- copy_v3_v3(tmp_no, proj_axis);
- }
+ /* These coordinates are deformed by vertexCos only for normal projection (to get correct normals) */
+ /* for other cases calc->verts contains undeformed coordinates and vertexCos should be used */
+ copy_v3_v3(tmp_co, calc->vert[i].co);
+ normal_short_to_float_v3(tmp_no, calc->vert[i].no);
}
else {
copy_v3_v3(tmp_co, co);
copy_v3_v3(tmp_no, proj_axis);
}
-
hit->index = -1;
hit->dist = BVH_RAYCAST_DIST_MAX; /* TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that */
@@ -665,11 +662,11 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
}
}
- if (calc->smd->auxTarget) {
- auxMesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(calc->smd->auxTarget, &auxMesh_free);
+ if (calc->aux_target) {
+ auxMesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(calc->aux_target, &auxMesh_free);
if (!auxMesh)
return;
- BLI_SPACE_TRANSFORM_SETUP(&local2aux, calc->ob, calc->smd->auxTarget);
+ BLI_SPACE_TRANSFORM_SETUP(&local2aux, calc->ob, calc->aux_target);
}
if (BKE_shrinkwrap_init_tree(&aux_tree_stack, auxMesh, calc->smd->shrinkType, calc->smd->shrinkMode, false)) {
@@ -1168,7 +1165,11 @@ void BKE_shrinkwrap_compute_smooth_normal(
normalize_v3(r_no);
}
}
- /* Use the looptri normal if flat. */
+ /* Use the polygon normal if flat. */
+ else if (tree->pnors != NULL) {
+ copy_v3_v3(r_no, tree->pnors[tri->poly]);
+ }
+ /* Finally fallback to the looptri normal. */
else {
copy_v3_v3(r_no, hit_no);
}
@@ -1280,8 +1281,10 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
}
/* Main shrinkwrap function */
-void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, struct Scene *scene, Object *ob, Mesh *mesh,
- float (*vertexCos)[3], int numVerts)
+void shrinkwrapModifier_deform(
+ ShrinkwrapModifierData *smd, const ModifierEvalContext *ctx,
+ struct Scene *scene, Object *ob, Mesh *mesh,
+ MDeformVert *dvert, const int defgrp_index, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *ss_mesh = NULL;
@@ -1298,38 +1301,27 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, struct Scene *scene,
calc.ob = ob;
calc.numVerts = numVerts;
calc.vertexCos = vertexCos;
+ calc.dvert = dvert;
+ calc.vgroup = defgrp_index;
calc.invert_vgroup = (smd->shrinkOpts & MOD_SHRINKWRAP_INVERT_VGROUP) != 0;
- /* DeformVertex */
- calc.vgroup = defgroup_name_index(calc.ob, calc.smd->vgroup_name);
- if (mesh) {
- calc.dvert = mesh->dvert;
- }
- else if (calc.ob->type == OB_LATTICE) {
- calc.dvert = BKE_lattice_deform_verts_get(calc.ob);
- }
-
-
- if (smd->target) {
- calc.target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(smd->target, &target_free);
+ if (smd->target != NULL) {
+ Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, smd->target);
+ calc.target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, &target_free);
/* TODO there might be several "bugs" on non-uniform scales matrixs
* because it will no longer be nearest surface, not sphere projection
* because space has been deformed */
- BLI_SPACE_TRANSFORM_SETUP(&calc.local2target, ob, smd->target);
+ BLI_SPACE_TRANSFORM_SETUP(&calc.local2target, ob, ob_target);
/* TODO: smd->keepDist is in global units.. must change to local */
calc.keepDist = smd->keepDist;
}
-
-
-
- calc.vgroup = defgroup_name_index(calc.ob, smd->vgroup_name);
+ calc.aux_target = DEG_get_evaluated_object(ctx->depsgraph, smd->auxTarget);
if (mesh != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) {
/* Setup arrays to get vertexs positions, normals and deform weights */
- calc.vert = mesh->mvert;
- calc.dvert = mesh->dvert;
+ calc.vert = mesh->mvert;
/* Using vertexs positions/normals as if a subsurface was applied */
if (smd->subsurfLevels) {
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 26d9f59853c..506725c89e8 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -538,7 +538,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->flame_smoke_color[2] = 0.7f;
smd->domain->viewsettings = MOD_SMOKE_VIEW_SHOWBIG;
- smd->domain->effector_weights = BKE_add_effector_weights(NULL);
+ smd->domain->effector_weights = BKE_effector_add_weights(NULL);
#ifdef WITH_OPENVDB_BLOSC
smd->domain->openvdb_comp = VDB_COMPRESSION_BLOSC;
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 4c1555e9451..2707e4eebd7 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -3280,7 +3280,7 @@ SoftBody *sbNew(Scene *scene)
sb->shared->pointcache = BKE_ptcache_add(&sb->shared->ptcaches);
if (!sb->effector_weights)
- sb->effector_weights = BKE_add_effector_weights(NULL);
+ sb->effector_weights = BKE_effector_add_weights(NULL);
sb->last_frame= MINFRAME-1;
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index f949fcaea07..070b94e35a9 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -35,9 +35,11 @@
#include "BKE_appdir.h"
#include "BKE_icons.h"
+#include "BLI_dynstr.h"
#include "BLI_fileops.h"
#include "BLI_fileops_types.h"
#include "BLI_listbase.h"
+#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLI_math_color.h"
#include "BLI_path_util.h"
@@ -82,7 +84,7 @@ static int last_studiolight_id = 0;
*/
#define STUDIOLIGHT_LOAD_CACHED_FILES
-static const char *STUDIOLIGHT_CAMERA_FOLDER = "studiolights/camera/";
+static const char *STUDIOLIGHT_LIGHTS_FOLDER = "studiolights/studio/";
static const char *STUDIOLIGHT_WORLD_FOLDER = "studiolights/world/";
static const char *STUDIOLIGHT_MATCAP_FOLDER = "studiolights/matcap/";
@@ -168,13 +170,15 @@ static struct StudioLight *studiolight_create(int flag)
sl->free_function = NULL;
sl->flag = flag;
sl->index = ++last_studiolight_id;
- if (flag & STUDIOLIGHT_ORIENTATION_VIEWNORMAL) {
+ if (flag & STUDIOLIGHT_TYPE_STUDIO) {
+ sl->icon_id_irradiance = BKE_icon_ensure_studio_light(sl, STUDIOLIGHT_ICON_ID_TYPE_IRRADIANCE);
+ }
+ else if (flag & STUDIOLIGHT_TYPE_MATCAP) {
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);
}
else {
sl->icon_id_radiance = BKE_icon_ensure_studio_light(sl, STUDIOLIGHT_ICON_ID_TYPE_RADIANCE);
- sl->icon_id_irradiance = BKE_icon_ensure_studio_light(sl, STUDIOLIGHT_ICON_ID_TYPE_IRRADIANCE);
}
for (int index = 0; index < 6; index++) {
@@ -184,6 +188,99 @@ static struct StudioLight *studiolight_create(int flag)
return sl;
}
+#define STUDIOLIGHT_FILE_VERSION 1
+
+#define READ_VAL(type, parser, id, val, lines) do { \
+ for (LinkNode *line = lines; line; line = line->next) { \
+ char *val_str, *str = line->link; \
+ if ((val_str = strstr(str, id " "))) { \
+ val_str += sizeof(id); /* Skip id + spacer. */ \
+ val = parser(val_str); \
+ } \
+ } \
+} while (0)
+
+#define READ_FVAL(id, val, lines) READ_VAL(float, atof, id, val, lines)
+#define READ_IVAL(id, val, lines) READ_VAL(int, atoi, id, val, lines)
+
+#define READ_VEC3(id, val, lines) do { \
+ READ_FVAL(id ".x", val[0], lines); \
+ READ_FVAL(id ".y", val[1], lines); \
+ READ_FVAL(id ".z", val[2], lines); \
+} while (0)
+
+#define READ_SOLIDLIGHT(sl, i, lines) do { \
+ READ_IVAL("light[" STRINGIFY(i) "].flag", sl[i].flag, lines); \
+ READ_FVAL("light[" STRINGIFY(i) "].smooth", sl[i].smooth, lines); \
+ READ_VEC3("light[" STRINGIFY(i) "].col", sl[i].col, lines); \
+ READ_VEC3("light[" STRINGIFY(i) "].spec", sl[i].spec, lines); \
+ READ_VEC3("light[" STRINGIFY(i) "].vec", sl[i].vec, lines); \
+} while (0)
+
+static void studiolight_load_solid_light(StudioLight *sl)
+{
+ LinkNode *lines = BLI_file_read_as_lines(sl->path);
+ if (lines) {
+ READ_VEC3("light_ambient", sl->light_ambient, lines);
+ READ_SOLIDLIGHT(sl->light, 0, lines);
+ READ_SOLIDLIGHT(sl->light, 1, lines);
+ READ_SOLIDLIGHT(sl->light, 2, lines);
+ READ_SOLIDLIGHT(sl->light, 3, lines);
+ }
+ BLI_file_free_lines(lines);
+}
+
+#undef READ_SOLIDLIGHT
+#undef READ_VEC3
+#undef READ_IVAL
+#undef READ_FVAL
+
+#define WRITE_FVAL(str, id, val) (BLI_dynstr_appendf(str, id " %f\n", val))
+#define WRITE_IVAL(str, id, val) (BLI_dynstr_appendf(str, id " %d\n", val))
+
+#define WRITE_VEC3(str, id, val) do { \
+ WRITE_FVAL(str, id ".x", val[0]); \
+ WRITE_FVAL(str, id ".y", val[1]); \
+ WRITE_FVAL(str, id ".z", val[2]); \
+} while (0)
+
+#define WRITE_SOLIDLIGHT(str, sl, i) do { \
+ WRITE_IVAL(str, "light[" STRINGIFY(i) "].flag", sl[i].flag); \
+ WRITE_FVAL(str, "light[" STRINGIFY(i) "].smooth", sl[i].smooth); \
+ WRITE_VEC3(str, "light[" STRINGIFY(i) "].col", sl[i].col); \
+ WRITE_VEC3(str, "light[" STRINGIFY(i) "].spec", sl[i].spec); \
+ WRITE_VEC3(str, "light[" STRINGIFY(i) "].vec", sl[i].vec); \
+} while (0)
+
+static void studiolight_write_solid_light(StudioLight *sl)
+{
+ FILE *fp = BLI_fopen(sl->path, "wb");
+ if (fp) {
+ DynStr *str = BLI_dynstr_new();
+
+ /* Very dumb ascii format. One value per line separated by a space. */
+ WRITE_IVAL(str, "version", STUDIOLIGHT_FILE_VERSION);
+ WRITE_VEC3(str, "light_ambient", sl->light_ambient);
+ WRITE_SOLIDLIGHT(str, sl->light, 0);
+ WRITE_SOLIDLIGHT(str, sl->light, 1);
+ WRITE_SOLIDLIGHT(str, sl->light, 2);
+ WRITE_SOLIDLIGHT(str, sl->light, 3);
+
+ char *cstr = BLI_dynstr_get_cstring(str);
+
+ fwrite(cstr, BLI_dynstr_get_len(str), 1, fp);
+ fclose(fp);
+
+ MEM_freeN(cstr);
+ BLI_dynstr_free(str);
+ }
+}
+
+#undef WRITE_SOLIDLIGHT
+#undef WRITE_VEC3
+#undef WRITE_IVAL
+#undef WRITE_FVAL
+
static void direction_to_equirect(float r[2], const float dir[3])
{
r[0] = (atan2f(dir[1], dir[0]) - M_PI) / -(M_PI * 2);
@@ -263,7 +360,7 @@ static void studiolight_create_equirect_radiance_gputexture(StudioLight *sl)
BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED);
ImBuf *ibuf = sl->equirect_radiance_buffer;
- if (sl->flag & STUDIOLIGHT_ORIENTATION_VIEWNORMAL) {
+ if (sl->flag & STUDIOLIGHT_TYPE_MATCAP) {
float *gpu_matcap_3components = MEM_callocN(sizeof(float[3]) * ibuf->x * ibuf->y, __func__);
float (*offset4)[4] = (float (*)[4])ibuf->rect_float;
@@ -732,6 +829,83 @@ static void studiolight_irradiance_eval(StudioLight *sl, float color[3], const f
}
#endif
+static float brdf_approx(float spec_color, float roughness, float NV)
+{
+ /* Very rough own approx. We don't need it to be correct, just fast.
+ * Just simulate fresnel effect with roughness attenuation. */
+ float fresnel = exp2(-8.35f * NV) * (1.0f - roughness);
+ return spec_color * (1.0f - fresnel) + fresnel;
+}
+
+/* NL need to be unclamped. w in [0..1] range. */
+static float wrapped_lighting(float NL, float w)
+{
+ float w_1 = w + 1.0f;
+ return max_ff((NL + w) / (w_1 * w_1), 0.0f);
+}
+
+static float blinn_specular(
+ const float L[3], const float I[3], const float N[3], float R[3], float NL, float roughness, float wrap)
+{
+ float half_dir[3];
+ float wrapped_NL = dot_v3v3(L, R);
+ add_v3_v3v3(half_dir, L, I);
+ normalize_v3(half_dir);
+ float spec_angle = max_ff(dot_v3v3(half_dir, N), 0.0f);
+
+ float gloss = 1.0f - roughness;
+ /* Reduce gloss for smooth light. (simulate bigger light) */
+ gloss *= 1.0f - wrap;
+ float shininess = exp2(10.0f * gloss + 1.0f);
+
+ /* Pi is already divided in the lamp power.
+ * normalization_factor = (shininess + 8.0) / (8.0 * M_PI) */
+ float normalization_factor = shininess * 0.125f + 1.0f;
+ float spec_light = powf(spec_angle, shininess) * max_ff(NL, 0.0f) * normalization_factor;
+
+ /* Simulate Env. light. */
+ float w = wrap * (1.0 - roughness) + roughness;
+ float spec_env = wrapped_lighting(wrapped_NL, w);
+
+ float w2 = wrap * wrap;
+
+ return spec_light * (1.0 - w2) + spec_env * w2;
+}
+
+/* Keep in sync with the glsl shader function get_world_lighting() */
+static void studiolight_lights_eval(StudioLight *sl, float color[3], const float normal[3])
+{
+ float R[3], I[3] = {0.0f, 0.0f, 1.0f}, N[3] = {normal[0], normal[2], -normal[1]};
+ const float roughness = 0.5f;
+ const float diffuse_color = 0.8f;
+ const float specular_color = brdf_approx(0.05f, roughness, N[2]);
+ float diff_light[3], spec_light[3];
+
+ /* Ambient lighting */
+ copy_v3_v3(diff_light, sl->light_ambient);
+ copy_v3_v3(spec_light, sl->light_ambient);
+
+ reflect_v3_v3v3(R, I, N);
+ for (int i = 0; i < 3; ++i) {
+ SolidLight *light = &sl->light[i];
+ if (light->flag) {
+ /* Diffuse lighting */
+ float NL = dot_v3v3(light->vec, N);
+ float diff = wrapped_lighting(NL, light->smooth);
+ madd_v3_v3fl(diff_light, light->col, diff);
+ /* Specular lighting */
+ float spec = blinn_specular(light->vec, I, N, R, NL, roughness, light->smooth);
+ madd_v3_v3fl(spec_light, light->spec, spec);
+ }
+ }
+
+ /* Multiply result by surface colors. */
+ mul_v3_fl(diff_light, diffuse_color * (1.0 - specular_color));
+ mul_v3_fl(spec_light, specular_color);
+
+ add_v3_v3v3(color, diff_light, spec_light);
+}
+
static bool studiolight_load_irradiance_equirect_image(StudioLight *sl)
{
#ifdef STUDIOLIGHT_LOAD_CACHED_FILES
@@ -819,12 +993,21 @@ 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)) {
+
+ if ((((flag & STUDIOLIGHT_TYPE_STUDIO) != 0) && BLI_path_extension_check(filename, ".sl")) ||
+ 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");
+
+ if ((flag & STUDIOLIGHT_TYPE_STUDIO) != 0) {
+ studiolight_load_solid_light(sl);
+ }
+ else {
+ sl->path_irr_cache = BLI_string_joinN(path, ".irr");
+ sl->path_sh_cache = BLI_string_joinN(path, ".sh2");
+ }
BLI_addtail(&studiolights, sl);
return sl;
}
@@ -971,8 +1154,6 @@ static void studiolight_matcap_preview(uint *icon_buffer, StudioLight *sl, bool
static void studiolight_irradiance_preview(uint *icon_buffer, StudioLight *sl)
{
- BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED);
-
ITER_PIXELS(uint, icon_buffer, 1,
STUDIOLIGHT_ICON_SIZE,
STUDIOLIGHT_ICON_SIZE)
@@ -988,7 +1169,7 @@ static void studiolight_irradiance_preview(uint *icon_buffer, StudioLight *sl)
SWAP(float, normal[1], normal[2]);
normal[1] = -normal[1];
- studiolight_spherical_harmonics_eval(sl, color, normal);
+ studiolight_lights_eval(sl, color, normal);
*pixel = rgb_to_cpack(
linearrgb_to_srgb(color[0]),
@@ -1005,37 +1186,56 @@ static void studiolight_irradiance_preview(uint *icon_buffer, StudioLight *sl)
/* API */
void BKE_studiolight_init(void)
{
- StudioLight *sl;
- /* go over the preset folder and add a studiolight for every image with its path */
- /* order studio lights by name */
- /* Also reserve icon space for it. */
/* Add default studio light */
- sl = studiolight_create(STUDIOLIGHT_INTERNAL | STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED | STUDIOLIGHT_ORIENTATION_CAMERA);
+ StudioLight *sl = studiolight_create(
+ STUDIOLIGHT_INTERNAL | STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED | STUDIOLIGHT_TYPE_STUDIO);
BLI_strncpy(sl->name, "Default", FILE_MAXFILE);
- int i = 0;
- copy_v3_fl3(sl->spherical_harmonics_coefs[i++], 1.03271556f, 1.07163882f, 1.11193657f);
-#if STUDIOLIGHT_SH_BANDS > 1
- copy_v3_fl3(sl->spherical_harmonics_coefs[i++], -0.00480952f, 0.05290511f, 0.16394117f);
- copy_v3_fl3(sl->spherical_harmonics_coefs[i++], -0.29686999f, -0.27378261f, -0.24797194f);
- copy_v3_fl3(sl->spherical_harmonics_coefs[i++], 0.47932500f, 0.48242140f, 0.47190312f);
-#endif
-#if STUDIOLIGHT_SH_BANDS > 2
- copy_v3_fl3(sl->spherical_harmonics_coefs[i++], -0.00576984f, 0.00504886f, 0.01640534f);
- copy_v3_fl3(sl->spherical_harmonics_coefs[i++], 0.15500379f, 0.15415503f, 0.16244425f);
- copy_v3_fl3(sl->spherical_harmonics_coefs[i++], -0.02483751f, -0.02245096f, -0.00536885f);
- copy_v3_fl3(sl->spherical_harmonics_coefs[i++], 0.11155496f, 0.11005443f, 0.10839636f);
- copy_v3_fl3(sl->spherical_harmonics_coefs[i++], 0.01363425f, 0.01278363f, -0.00159006f);
-#endif
+ copy_v4_fl4(sl->light_ambient, 0.025000, 0.025000, 0.025000, 1.000000);
+
+ copy_v4_fl4(sl->light[0].vec, -0.580952, 0.228571, 0.781185, 0.0);
+ copy_v4_fl4(sl->light[0].col, 0.900000, 0.900000, 0.900000, 1.000000);
+ copy_v4_fl4(sl->light[0].spec, 0.318547, 0.318547, 0.318547, 1.000000);
+ sl->light[0].flag = 1;
+ sl->light[0].smooth = 0.1;
+
+ copy_v4_fl4(sl->light[1].vec, 0.788218, 0.593482, -0.162765, 0.0);
+ copy_v4_fl4(sl->light[1].col, 0.267115, 0.269928, 0.358840, 1.000000);
+ copy_v4_fl4(sl->light[1].spec, 0.090838, 0.090838, 0.090838, 1.000000);
+ sl->light[1].flag = 1;
+ sl->light[1].smooth = 0.25;
+
+ copy_v4_fl4(sl->light[2].vec, 0.696472, -0.696472, -0.172785, 0.0);
+ copy_v4_fl4(sl->light[2].col, 0.293216, 0.304662, 0.401968, 1.000000);
+ copy_v4_fl4(sl->light[2].spec, 0.069399, 0.020331, 0.020331, 1.000000);
+ sl->light[2].flag = 1;
+ sl->light[2].smooth = 0.5;
+
+ copy_v4_fl4(sl->light[3].vec, 0.021053, -0.989474, 0.143173, 0.0);
+ copy_v4_fl4(sl->light[3].col, 0.0, 0.0, 0.0, 1.0);
+ copy_v4_fl4(sl->light[3].spec, 0.072234, 0.082253, 0.162642, 1.000000);
+ sl->light[3].flag = 1;
+ sl->light[3].smooth = 0.7;
BLI_addtail(&studiolights, sl);
- studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, STUDIOLIGHT_CAMERA_FOLDER, STUDIOLIGHT_ORIENTATION_CAMERA);
- studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES, STUDIOLIGHT_CAMERA_FOLDER, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_USER_DEFINED);
- studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, STUDIOLIGHT_WORLD_FOLDER, STUDIOLIGHT_ORIENTATION_WORLD);
- studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES, STUDIOLIGHT_WORLD_FOLDER, STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_USER_DEFINED);
- studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, STUDIOLIGHT_MATCAP_FOLDER, STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
- studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES, STUDIOLIGHT_MATCAP_FOLDER, STUDIOLIGHT_ORIENTATION_VIEWNORMAL | STUDIOLIGHT_USER_DEFINED);
+ /* go over the preset folder and add a studiolight for every image with its path */
+ /* for portable installs (where USER and SYSTEM paths are the same), only go over LOCAL datafiles once */
+ /* Also reserve icon space for it. */
+ if (!BKE_appdir_app_is_portable_install()) {
+ studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES,
+ STUDIOLIGHT_LIGHTS_FOLDER,
+ STUDIOLIGHT_TYPE_STUDIO | STUDIOLIGHT_USER_DEFINED);
+ studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES,
+ STUDIOLIGHT_WORLD_FOLDER,
+ STUDIOLIGHT_TYPE_WORLD | STUDIOLIGHT_USER_DEFINED);
+ studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES,
+ STUDIOLIGHT_MATCAP_FOLDER,
+ STUDIOLIGHT_TYPE_MATCAP | STUDIOLIGHT_USER_DEFINED);
+ }
+ studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, STUDIOLIGHT_LIGHTS_FOLDER, STUDIOLIGHT_TYPE_STUDIO);
+ studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, STUDIOLIGHT_WORLD_FOLDER, STUDIOLIGHT_TYPE_WORLD);
+ studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, STUDIOLIGHT_MATCAP_FOLDER, STUDIOLIGHT_TYPE_MATCAP);
/* sort studio lights on filename. */
BLI_listbase_sort(&studiolights, studiolight_cmp);
@@ -1161,12 +1361,42 @@ void BKE_studiolight_remove(StudioLight *sl)
}
}
-StudioLight *BKE_studiolight_new(const char *path, int orientation)
+StudioLight *BKE_studiolight_load(const char *path, int type)
{
- StudioLight *sl = studiolight_add_file(path, orientation | STUDIOLIGHT_USER_DEFINED);
+ StudioLight *sl = studiolight_add_file(path, type | STUDIOLIGHT_USER_DEFINED);
+ return sl;
+}
+
+StudioLight *BKE_studiolight_create(const char *path, const SolidLight light[4], const float light_ambient[3])
+{
+ StudioLight *sl = studiolight_create(STUDIOLIGHT_EXTERNAL_FILE | STUDIOLIGHT_USER_DEFINED | STUDIOLIGHT_TYPE_STUDIO);
+
+ char filename[FILE_MAXFILE];
+ BLI_split_file_part(path, filename, FILE_MAXFILE);
+ BLI_snprintf(sl->path, FILE_MAXFILE, "%s%s", path, ".sl");
+ BLI_snprintf(sl->name, FILE_MAXFILE, "%s%s", filename, ".sl");
+
+ memcpy(sl->light, light, sizeof(*light) * 4);
+ memcpy(sl->light_ambient, light_ambient, sizeof(*light_ambient) * 3);
+
+ studiolight_write_solid_light(sl);
+
+ BLI_addtail(&studiolights, sl);
return sl;
}
+/* Only useful for workbench while editing the userprefs. */
+StudioLight *BKE_studiolight_studio_edit_get(void)
+{
+ static StudioLight sl = {0};
+ sl.flag = STUDIOLIGHT_TYPE_STUDIO;
+
+ memcpy(sl.light, U.light_param, sizeof(*sl.light) * 4);
+ memcpy(sl.light_ambient, U.light_ambient, sizeof(*sl.light_ambient) * 3);
+
+ return &sl;
+}
+
void BKE_studiolight_refresh(void)
{
BKE_studiolight_free();
diff --git a/source/blender/blenkernel/intern/subdiv_converter_mesh.c b/source/blender/blenkernel/intern/subdiv_converter_mesh.c
index 5941de682f4..0dad259b001 100644
--- a/source/blender/blenkernel/intern/subdiv_converter_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_converter_mesh.c
@@ -47,6 +47,10 @@
#include "opensubdiv_capi.h"
#include "opensubdiv_converter_capi.h"
+/* Enable work-around for non-working CPU evaluator when using bilinear scheme.
+ * This forces Catmark scheme with all edges marked as infinitely sharp. */
+#define BUGGY_SIMPLE_SCHEME_WORKAROUND 1
+
typedef struct ConverterStorage {
SubdivSettings settings;
const Mesh *mesh;
@@ -78,6 +82,10 @@ typedef struct ConverterStorage {
static OpenSubdiv_SchemeType get_scheme_type(
const OpenSubdiv_Converter *converter)
{
+#if BUGGY_SIMPLE_SCHEME_WORKAROUND
+ (void) converter;
+ return OSD_SCHEME_CATMARK;
+#else
ConverterStorage *storage = converter->user_data;
if (storage->settings.is_simple) {
return OSD_SCHEME_BILINEAR;
@@ -85,6 +93,7 @@ static OpenSubdiv_SchemeType get_scheme_type(
else {
return OSD_SCHEME_CATMARK;
}
+#endif
}
static OpenSubdiv_VtxBoundaryInterpolation get_vtx_boundary_interpolation(
@@ -161,6 +170,11 @@ static float get_edge_sharpness(const OpenSubdiv_Converter *converter,
int manifold_edge_index)
{
ConverterStorage *storage = converter->user_data;
+#if BUGGY_SIMPLE_SCHEME_WORKAROUND
+ if (storage->settings.is_simple) {
+ return 10.0f;
+ }
+#endif
const int edge_index =
storage->manifold_edge_index_reverse[manifold_edge_index];
const MEdge *medge = storage->mesh->medge;
@@ -168,11 +182,15 @@ static float get_edge_sharpness(const OpenSubdiv_Converter *converter,
return edge_crease * edge_crease * 10.0f;
}
-
static bool is_infinite_sharp_vertex(const OpenSubdiv_Converter *converter,
int manifold_vertex_index)
{
ConverterStorage *storage = converter->user_data;
+#if BUGGY_SIMPLE_SCHEME_WORKAROUND
+ if (storage->settings.is_simple) {
+ return true;
+ }
+#endif
const int vertex_index =
storage->manifold_vertex_index_reverse[manifold_vertex_index];
return BLI_BITMAP_TEST_BOOL(storage->infinite_sharp_vertices_map,
diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c
index d8d4014b3cd..4d9e8998cf0 100644
--- a/source/blender/blenkernel/intern/subdiv_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_mesh.c
@@ -53,6 +53,7 @@
*/
typedef struct SubdivMeshContext {
+ const SubdivToMeshSettings *settings;
const Mesh *coarse_mesh;
Subdiv *subdiv;
Mesh *subdiv_mesh;
@@ -766,6 +767,9 @@ static void subdiv_copy_edge_data(
subdiv_edge->crease = 0;
subdiv_edge->bweight = 0;
subdiv_edge->flag = 0;
+ if (!ctx->settings->use_optimal_display) {
+ subdiv_edge->flag |= ME_EDGERENDER;
+ }
if (ctx->edge_origindex != NULL) {
ctx->edge_origindex[subdiv_edge_index] = ORIGINDEX_NONE;
}
@@ -777,6 +781,7 @@ static void subdiv_copy_edge_data(
coarse_edge_index,
subdiv_edge_index,
1);
+ subdiv_edge->flag |= ME_EDGERENDER;
}
static void subdiv_mesh_edge(
@@ -790,12 +795,13 @@ static void subdiv_mesh_edge(
Mesh *subdiv_mesh = ctx->subdiv_mesh;
MEdge *subdiv_medge = subdiv_mesh->medge;
MEdge *subdiv_edge = &subdiv_medge[subdiv_edge_index];
+ const MEdge *coarse_edge = NULL;
if (coarse_edge_index != ORIGINDEX_NONE) {
const Mesh *coarse_mesh = ctx->coarse_mesh;
const MEdge *coarse_medge = coarse_mesh->medge;
- const MEdge *coarse_edge = &coarse_medge[coarse_edge_index];
- subdiv_copy_edge_data(ctx, subdiv_edge, coarse_edge);
+ coarse_edge = &coarse_medge[coarse_edge_index];
}
+ subdiv_copy_edge_data(ctx, subdiv_edge, coarse_edge);
subdiv_edge->v1 = subdiv_v1;
subdiv_edge->v2 = subdiv_v2;
}
@@ -1122,6 +1128,7 @@ Mesh *BKE_subdiv_to_mesh(
}
/* Initialize subdivion mesh creation context/ */
SubdivMeshContext subdiv_context = {0};
+ subdiv_context.settings = settings;
subdiv_context.coarse_mesh = coarse_mesh;
subdiv_context.subdiv = subdiv;
/* Multi-threaded traversal/evaluation. */
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 5031b2de462..bd527ed8a44 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -476,7 +476,7 @@ Tex *BKE_texture_localize(Tex *tex)
Tex *texn;
- texn = BKE_libblock_copy_nolib(&tex->id, false);
+ texn = BKE_libblock_copy_for_localize(&tex->id);
/* image texture: BKE_texture_free also doesn't decrease */
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index f4c32987117..e7a4167087b 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -154,7 +154,7 @@ World *BKE_world_localize(World *wrld)
World *wrldn;
- wrldn = BKE_libblock_copy_nolib(&wrld->id, false);
+ wrldn = BKE_libblock_copy_for_localize(&wrld->id);
if (wrld->nodetree)
wrldn->nodetree = ntreeLocalize(wrld->nodetree);
diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h
index c888152001e..2bbd82f6db8 100644
--- a/source/blender/blenlib/BLI_callbacks.h
+++ b/source/blender/blenlib/BLI_callbacks.h
@@ -56,6 +56,7 @@ typedef enum {
BLI_CB_EVT_DEPSGRAPH_UPDATE_PRE,
BLI_CB_EVT_DEPSGRAPH_UPDATE_POST,
BLI_CB_EVT_VERSION_UPDATE,
+ BLI_CB_EVT_LOAD_FACTORY_STARTUP_POST,
BLI_CB_EVT_TOT
} eCbEvent;
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index 72d29164988..3653191232c 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -112,7 +112,7 @@ void BLI_init_srgb_conversion(void);
MINLINE void premul_to_straight_v4_v4(float straight[4], const float premul[4]);
MINLINE void premul_to_straight_v4(float color[4]);
-MINLINE void straight_to_premul_v4_v4(float straight[4], const float premul[4]);
+MINLINE void straight_to_premul_v4_v4(float premul[4], const float straight[4]);
MINLINE void straight_to_premul_v4(float color[4]);
MINLINE void straight_uchar_to_premul_float(float result[4], const unsigned char color[4]);
MINLINE void premul_float_to_straight_uchar(unsigned char *result, const float color[4]);
diff --git a/source/blender/blenlib/BLI_system.h b/source/blender/blenlib/BLI_system.h
index f51b9623803..3bb47a4a5b7 100644
--- a/source/blender/blenlib/BLI_system.h
+++ b/source/blender/blenlib/BLI_system.h
@@ -30,6 +30,22 @@
int BLI_cpu_support_sse2(void);
void BLI_system_backtrace(FILE *fp);
+
+/* Get CPU brand, result is to be MEM_freeN()-ed. */
+char *BLI_cpu_brand_string(void);
+
+/**
+ * Obtain the hostname from the system.
+ *
+ * This simply determines the host's name, and doesn't do any DNS lookup of any
+ * IP address of the machine. As such, it's only usable for identification
+ * purposes, and not for reachability over a network.
+ *
+ * @param buffer Character buffer to write the hostname into.
+ * @param bufsize Size of the character buffer, including trailing '\0'.
+ */
+void BLI_hostname_get(char *buffer, size_t bufsize);
+
/* getpid */
#ifdef WIN32
# define BLI_SYSTEM_PID_H <process.h>
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h
index 9194caca007..8300f6242db 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -98,6 +98,8 @@ void BLI_task_pool_push_from_thread(TaskPool *pool, TaskRunFunction run,
/* work and wait until all tasks are done */
void BLI_task_pool_work_and_wait(TaskPool *pool);
+/* work and wait until all tasks are done, then reset to the initial suspended state */
+void BLI_task_pool_work_wait_and_reset(TaskPool *pool);
/* cancel all tasks, keep worker threads running */
void BLI_task_pool_cancel(TaskPool *pool);
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index 81f8445783b..631a65ccade 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -204,6 +204,12 @@ void BLI_thread_queue_nowait(ThreadQueue *queue);
# define BLI_thread_local_set(name, value) name = value
#endif /* defined(__APPLE__) */
+/* **** Special functions to help performance on crazy NUMA setups. **** */
+
+/* Make sure process/thread is using NUMA node with fast memory access. */
+void BLI_thread_put_process_on_fast_node(void);
+void BLI_thread_put_thread_on_fast_node(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenlib/BLI_timer.h b/source/blender/blenlib/BLI_timer.h
new file mode 100644
index 00000000000..8f18d4fb3f4
--- /dev/null
+++ b/source/blender/blenlib/BLI_timer.h
@@ -0,0 +1,58 @@
+/*
+ * ***** 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 *****
+ */
+
+#ifndef __BLI_TIMER_H__
+#define __BLI_TIMER_H__
+
+#include "BLI_sys_types.h"
+
+/** \file BLI_timer.h
+ * \ingroup BLI
+ */
+
+/* ret < 0: the timer will be removed.
+ * ret >= 0: the timer will be called again in ret seconds */
+typedef double (*BLI_timer_func)(uintptr_t uuid, void *user_data);
+typedef void (*BLI_timer_data_free)(uintptr_t uuid, void *user_data);
+
+/* `func(...) < 0`: The timer will be removed.
+ * `func(...) >= 0`: The function will be called again in that many seconds. */
+void BLI_timer_register(
+ uintptr_t uuid,
+ BLI_timer_func func,
+ void *user_data,
+ BLI_timer_data_free user_data_free,
+ double first_interval,
+ bool persistent);
+
+bool BLI_timer_is_registered(uintptr_t uuid);
+
+/* Returns False when the timer does not exist (anymore). */
+bool BLI_timer_unregister(uintptr_t uuid);
+
+/* Execute all registered functions that are due. */
+void BLI_timer_execute(void);
+
+void BLI_timer_free(void);
+
+#endif /* __BLI_TIMER_H__ */
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 5e6764a5c0e..921ecc29e18 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -30,6 +30,7 @@ set(INC
../../../intern/guardedalloc
../../../intern/atomic
../../../intern/eigen
+ ../../../intern/numaapi/include
../../../extern/wcwidth
)
@@ -55,6 +56,7 @@ set(SRC
intern/BLI_memarena.c
intern/BLI_memiter.c
intern/BLI_mempool.c
+ intern/BLI_timer.c
intern/DLRB_tree.c
intern/array_store.c
intern/array_store_utils.c
@@ -214,6 +216,7 @@ set(SRC
BLI_task.h
BLI_threads.h
BLI_timecode.h
+ BLI_timer.h
BLI_utildefines.h
BLI_utildefines_iter.h
BLI_utildefines_stack.h
diff --git a/source/blender/blenlib/intern/BLI_timer.c b/source/blender/blenlib/intern/BLI_timer.c
new file mode 100644
index 00000000000..7bb919d47e0
--- /dev/null
+++ b/source/blender/blenlib/intern/BLI_timer.c
@@ -0,0 +1,184 @@
+/*
+ * ***** 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/blenlib/intern/BLI_timer.c
+ * \ingroup bli
+ */
+
+#include "BLI_timer.h"
+#include "BLI_listbase.h"
+#include "BLI_callbacks.h"
+
+#include "MEM_guardedalloc.h"
+#include "PIL_time.h"
+
+#define GET_TIME() PIL_check_seconds_timer()
+
+typedef struct TimedFunction {
+ struct TimedFunction *next, *prev;
+ BLI_timer_func func;
+ BLI_timer_data_free user_data_free;
+ void *user_data;
+ double next_time;
+ uintptr_t uuid;
+ bool tag_removal;
+ bool persistent;
+} TimedFunction;
+
+typedef struct TimerContainer {
+ ListBase funcs;
+ bool file_load_cb_registered;
+} TimerContainer;
+
+static TimerContainer GlobalTimer = { 0 };
+
+static void ensure_callback_is_registered(void);
+
+void BLI_timer_register(
+ uintptr_t uuid,
+ BLI_timer_func func,
+ void *user_data,
+ BLI_timer_data_free user_data_free,
+ double first_interval,
+ bool persistent)
+{
+ ensure_callback_is_registered();
+
+ TimedFunction *timed_func = MEM_callocN(sizeof(TimedFunction), __func__);
+ timed_func->func = func;
+ timed_func->user_data_free = user_data_free;
+ timed_func->user_data = user_data;
+ timed_func->next_time = GET_TIME() + first_interval;
+ timed_func->tag_removal = false;
+ timed_func->persistent = persistent;
+ timed_func->uuid = uuid;
+
+ BLI_addtail(&GlobalTimer.funcs, timed_func);
+}
+
+static void clear_user_data(TimedFunction *timed_func)
+{
+ if (timed_func->user_data_free) {
+ timed_func->user_data_free(timed_func->uuid, timed_func->user_data);
+ timed_func->user_data_free = NULL;
+ }
+}
+
+bool BLI_timer_unregister(uintptr_t uuid)
+{
+ LISTBASE_FOREACH(TimedFunction *, timed_func, &GlobalTimer.funcs) {
+ if (timed_func->uuid == uuid) {
+ if (timed_func->tag_removal) {
+ return false;
+ }
+ else {
+ timed_func->tag_removal = true;
+ clear_user_data(timed_func);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool BLI_timer_is_registered(uintptr_t uuid)
+{
+ LISTBASE_FOREACH(TimedFunction *, timed_func, &GlobalTimer.funcs) {
+ if (timed_func->uuid == uuid && !timed_func->tag_removal) {
+ return true;
+ }
+ }
+ return false;
+}
+
+static void execute_functions_if_necessary(void)
+{
+ double current_time = GET_TIME();
+
+ LISTBASE_FOREACH(TimedFunction *, timed_func, &GlobalTimer.funcs) {
+ if (timed_func->tag_removal) continue;
+ if (timed_func->next_time > current_time) continue;
+
+ double ret = timed_func->func(timed_func->uuid, timed_func->user_data);
+
+ if (ret < 0) {
+ timed_func->tag_removal = true;
+ }
+ else {
+ timed_func->next_time = current_time + ret;
+ }
+ }
+}
+
+static void remove_tagged_functions(void)
+{
+ for (TimedFunction *timed_func = GlobalTimer.funcs.first; timed_func; ) {
+ TimedFunction *next = timed_func->next;
+ if (timed_func->tag_removal) {
+ clear_user_data(timed_func);
+ BLI_freelinkN(&GlobalTimer.funcs, timed_func);
+ }
+ timed_func = next;
+ }
+}
+
+void BLI_timer_execute()
+{
+ execute_functions_if_necessary();
+ remove_tagged_functions();
+}
+
+void BLI_timer_free()
+{
+ LISTBASE_FOREACH(TimedFunction *, timed_func, &GlobalTimer.funcs) {
+ timed_func->tag_removal = true;
+ }
+
+ remove_tagged_functions();
+}
+
+struct Main;
+struct ID;
+static void remove_non_persistent_functions(struct Main *UNUSED(_1), struct ID *UNUSED(_2), void *UNUSED(_3))
+{
+ LISTBASE_FOREACH(TimedFunction *, timed_func, &GlobalTimer.funcs) {
+ if (!timed_func->persistent) {
+ timed_func->tag_removal = true;
+ }
+ }
+}
+
+static bCallbackFuncStore load_post_callback = {
+ NULL, NULL, /* next, prev */
+ remove_non_persistent_functions, /* func */
+ NULL, /* arg */
+ 0 /* alloc */
+};
+
+static void ensure_callback_is_registered()
+{
+ if (!GlobalTimer.file_load_cb_registered) {
+ BLI_callback_add(&load_post_callback, BLI_CB_EVT_LOAD_POST);
+ GlobalTimer.file_load_cb_registered = true;
+ }
+}
diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c
index ecb977c6e61..82c42c42d9d 100644
--- a/source/blender/blenlib/intern/system.c
+++ b/source/blender/blenlib/intern/system.c
@@ -27,15 +27,17 @@
#include "BLI_utildefines.h"
#include "BLI_system.h"
+#include "BLI_string.h"
#include "MEM_guardedalloc.h"
-/* for backtrace */
-#if defined(__linux__) || defined(__APPLE__)
-# include <execinfo.h>
-#elif defined(WIN32)
+/* for backtrace and gethostname/GetComputerName */
+#if defined(WIN32)
# include <windows.h>
# include <dbghelp.h>
+#else
+# include <execinfo.h>
+# include <unistd.h>
#endif
int BLI_cpu_support_sse2(void)
@@ -138,3 +140,56 @@ void BLI_system_backtrace(FILE *fp)
}
/* end BLI_system_backtrace */
+
+/* NOTE: The code for CPU brand string is adopted from Cycles. */
+
+#if !defined(_WIN32) || defined(FREE_WINDOWS)
+static void __cpuid(int data[4], int selector)
+{
+#if defined(__x86_64__)
+ asm("cpuid" : "=a" (data[0]), "=b" (data[1]), "=c" (data[2]), "=d" (data[3]) : "a"(selector));
+#elif defined(__i386__)
+ asm("pushl %%ebx \n\t"
+ "cpuid \n\t"
+ "movl %%ebx, %1 \n\t"
+ "popl %%ebx \n\t"
+ : "=a" (data[0]), "=r" (data[1]), "=c" (data[2]), "=d" (data[3])
+ : "a"(selector)
+ : "ebx");
+#else
+ data[0] = data[1] = data[2] = data[3] = 0;
+#endif
+}
+#endif
+
+char *BLI_cpu_brand_string(void)
+{
+ char buf[48] = { 0 };
+ int result[4] = { 0 };
+ __cpuid(result, 0x80000000);
+ if (result[0] >= (int)0x80000004) {
+ __cpuid((int *)(buf + 0), 0x80000002);
+ __cpuid((int *)(buf + 16), 0x80000003);
+ __cpuid((int *)(buf + 32), 0x80000004);
+ char *brand = BLI_strdup(buf);
+ /* TODO(sergey): Make it a bit more presentable by removing trademark. */
+ return brand;
+ }
+ return NULL;
+}
+
+void BLI_hostname_get(char *buffer, size_t bufsize)
+{
+#ifndef WIN32
+ if (gethostname(buffer, bufsize - 1) < 0) {
+ BLI_strncpy(buffer, "-unknown-", bufsize);
+ }
+ /* When gethostname() truncates, it doesn't guarantee the trailing \0. */
+ buffer[bufsize - 1] = '\0';
+#else
+ DWORD bufsize_inout = bufsize;
+ if (!GetComputerName(buffer, &bufsize_inout)) {
+ strncpy(buffer, "-unknown-", bufsize);
+ }
+#endif
+}
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index b8b54e192b4..edd588bd68b 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -175,6 +175,7 @@ struct TaskPool {
volatile bool do_work;
volatile bool is_suspended;
+ bool start_suspended;
ListBase suspended_queue;
size_t num_suspended;
@@ -650,6 +651,7 @@ static TaskPool *task_pool_create_ex(TaskScheduler *scheduler,
pool->do_cancel = false;
pool->do_work = false;
pool->is_suspended = is_suspended;
+ pool->start_suspended = is_suspended;
pool->num_suspended = 0;
pool->suspended_queue.first = pool->suspended_queue.last = NULL;
pool->run_in_background = is_background;
@@ -855,6 +857,8 @@ void BLI_task_pool_work_and_wait(TaskPool *pool)
BLI_condition_notify_all(&scheduler->queue_cond);
BLI_mutex_unlock(&scheduler->queue_mutex);
+
+ pool->num_suspended = 0;
}
}
@@ -862,6 +866,8 @@ void BLI_task_pool_work_and_wait(TaskPool *pool)
ASSERT_THREAD_ID(pool->scheduler, pool->thread_id);
+ handle_local_queue(tls, pool->thread_id);
+
BLI_mutex_lock(&pool->num_mutex);
while (pool->num != 0) {
@@ -913,7 +919,15 @@ void BLI_task_pool_work_and_wait(TaskPool *pool)
BLI_mutex_unlock(&pool->num_mutex);
- handle_local_queue(tls, pool->thread_id);
+ BLI_assert(tls->num_local_queue == 0);
+}
+
+void BLI_task_pool_work_wait_and_reset(TaskPool *pool)
+{
+ BLI_task_pool_work_and_wait(pool);
+
+ pool->do_work = false;
+ pool->is_suspended = pool->start_suspended;
}
void BLI_task_pool_cancel(TaskPool *pool)
@@ -1029,7 +1043,7 @@ static void parallel_range_func(
}
}
-static void palallel_range_single_thread(const int start, int const stop,
+static void parallel_range_single_thread(const int start, int const stop,
void *userdata,
TaskParallelRangeFunc func,
const ParallelRangeSettings *settings)
@@ -1089,7 +1103,7 @@ void BLI_task_parallel_range(const int start, const int stop,
* do everything from the main thread.
*/
if (!settings->use_threading) {
- palallel_range_single_thread(start, stop,
+ parallel_range_single_thread(start, stop,
userdata,
func,
settings);
@@ -1126,7 +1140,7 @@ void BLI_task_parallel_range(const int start, const int stop,
max_ii(1, (stop - start) / state.chunk_size));
if (num_tasks == 1) {
- palallel_range_single_thread(start, stop,
+ parallel_range_single_thread(start, stop,
userdata,
func,
settings);
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 862ce391109..f8c67705fd7 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -37,6 +37,7 @@
#include "BLI_listbase.h"
#include "BLI_gsqueue.h"
+#include "BLI_system.h"
#include "BLI_task.h"
#include "BLI_threads.h"
@@ -55,6 +56,7 @@
#endif
#include "atomic_ops.h"
+#include "numaapi.h"
#if defined(__APPLE__) && defined(_OPENMP) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) && !defined(__clang__)
# define USE_APPLE_OMP_FIX
@@ -126,6 +128,7 @@ static pthread_mutex_t _colormanage_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t _fftw_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t _view3d_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_t mainid;
+static bool is_numa_available = false;
static unsigned int thread_levels = 0; /* threads can be invoked inside threads */
static int num_threads_override = 0;
@@ -155,6 +158,9 @@ void BLI_threadapi_init(void)
mainid = pthread_self();
BLI_spin_init(&_malloc_lock);
+ if (numaAPI_Initialize() == NUMAAPI_SUCCESS) {
+ is_numa_available = true;
+ }
}
void BLI_threadapi_exit(void)
@@ -840,3 +846,99 @@ void BLI_threaded_malloc_end(void)
MEM_set_lock_callback(NULL, NULL);
}
}
+
+/* **** Special functions to help performance on crazy NUMA setups. **** */
+
+static bool check_is_threadripper2_alike_topology(void)
+{
+ /* NOTE: We hope operating system does not support CPU hotswap to
+ * a different brand. And that SMP of different types is also not
+ * encouraged by the system. */
+ static bool is_initialized = false;
+ static bool is_threadripper2 = false;
+ if (is_initialized) {
+ return is_threadripper2;
+ }
+ is_initialized = true;
+ char *cpu_brand = BLI_cpu_brand_string();
+ if (cpu_brand == NULL) {
+ return false;
+ }
+ if (strstr(cpu_brand, "Threadripper")) {
+ /* NOTE: We consinder all Threadrippers having similar topology to
+ * the second one. This is because we are trying to utilize NUMA node
+ * 0 as much as possible. This node does exist on earlier versions of
+ * threadripper and setting affinity to it should not have negative
+ * effect.
+ * This allows us to avoid per-model check, making the code more
+ * reliable for the CPUs which are not yet released.
+ */
+ if (strstr(cpu_brand, "2990WX") || strstr(cpu_brand, "2950X")) {
+ is_threadripper2 = true;
+ }
+ }
+ /* NOTE: While all dies of EPYC has memory controller, only two f them
+ * has access to a lower-indexed DDR slots. Those dies are same as on
+ * Threadripper2 with the memory controller.
+ * Now, it is rather likely that reasonable amount of users don't max
+ * up their DR slots, making it only two dies connected to a DDR slot
+ * with actual memory in it. */
+ if (strstr(cpu_brand, "EPYC")) {
+ /* NOTE: Similarly to Threadripper we do not do model check. */
+ is_threadripper2 = true;
+ }
+ MEM_freeN(cpu_brand);
+ return is_threadripper2;
+}
+
+static void threadripper_put_process_on_fast_node(void)
+{
+ if (!is_numa_available) {
+ return;
+ }
+ /* NOTE: Technically, we can use NUMA nodes 0 and 2 and usning both of
+ * them in the affinity mask will allow OS to schedule threads more
+ * flexible,possibly increasing overall performance when multiple apps
+ * are crunching numbers.
+ *
+ * However, if scene fits into memory adjacent to a single die we don't
+ * want OS to re-schedule the process to another die since that will make
+ * it further away from memory allocated for .blend file. */
+ /* NOTE: Even if NUMA is avasilable in the API but is disabled in BIOS on
+ * this workstation we still process here. If NUMA is disabled it will be a
+ * single node, so our action is no-visible-changes, but allows to keep
+ * things simple and unified. */
+ numaAPI_RunProcessOnNode(0);
+}
+
+static void threadripper_put_thread_on_fast_node(void)
+{
+ if (!is_numa_available) {
+ return;
+ }
+ /* NOTE: This is where things becomes more interesting. On the one hand
+ * we can use nodes 0 and 2 and allow operating system to do balancing
+ * of processes/threads for the maximum performance when multiple apps
+ * are running.
+ * On another hand, however, we probably want to use same node as the
+ * main thread since that's where the memory of .blend file is likely
+ * to be allocated.
+ * Since the main thread is currently on node 0, we also put thread on
+ * same node. */
+ /* See additional note about NUMA disabled in BIOS above. */
+ numaAPI_RunThreadOnNode(0);
+}
+
+void BLI_thread_put_process_on_fast_node(void)
+{
+ if (check_is_threadripper2_alike_topology()) {
+ threadripper_put_process_on_fast_node();
+ }
+}
+
+void BLI_thread_put_thread_on_fast_node(void)
+{
+ if (check_is_threadripper2_alike_topology()) {
+ threadripper_put_thread_on_fast_node();
+ }
+}
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 4d294870fb1..6bf0e7bf809 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -106,7 +106,7 @@ BlendHandle *BLO_blendhandle_from_memory(const void *mem, int memsize)
void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
{
- FileData *fd = (FileData *) bh;
+ FileData *fd = (FileData *)bh;
BHead *bhead;
fprintf(fp, "[\n");
@@ -144,7 +144,7 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
*/
LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, int *tot_names)
{
- FileData *fd = (FileData *) bh;
+ FileData *fd = (FileData *)bh;
LinkNode *names = NULL;
BHead *bhead;
int tot = 0;
@@ -174,7 +174,7 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype,
*/
LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *tot_prev)
{
- FileData *fd = (FileData *) bh;
+ FileData *fd = (FileData *)bh;
LinkNode *previews = NULL;
BHead *bhead;
int looking = 0;
@@ -210,11 +210,11 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
if (prv) {
memcpy(new_prv, prv, sizeof(PreviewImage));
if (prv->rect[0] && prv->w[0] && prv->h[0]) {
- unsigned int *rect = NULL;
- size_t len = new_prv->w[0] * new_prv->h[0] * sizeof(unsigned int);
+ uint *rect = NULL;
+ size_t len = new_prv->w[0] * new_prv->h[0] * sizeof(uint);
new_prv->rect[0] = MEM_callocN(len, __func__);
bhead = blo_nextbhead(fd, bhead);
- rect = (unsigned int *)(bhead + 1);
+ rect = (uint *)(bhead + 1);
BLI_assert(len == bhead->len);
memcpy(new_prv->rect[0], rect, len);
}
@@ -227,11 +227,11 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
}
if (prv->rect[1] && prv->w[1] && prv->h[1]) {
- unsigned int *rect = NULL;
- size_t len = new_prv->w[1] * new_prv->h[1] * sizeof(unsigned int);
+ uint *rect = NULL;
+ size_t len = new_prv->w[1] * new_prv->h[1] * sizeof(uint);
new_prv->rect[1] = MEM_callocN(len, __func__);
bhead = blo_nextbhead(fd, bhead);
- rect = (unsigned int *)(bhead + 1);
+ rect = (uint *)(bhead + 1);
BLI_assert(len == bhead->len);
memcpy(new_prv->rect[1], rect, len);
}
@@ -270,7 +270,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
*/
LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
{
- FileData *fd = (FileData *) bh;
+ FileData *fd = (FileData *)bh;
GSet *gathered = BLI_gset_ptr_new("linkable_groups gh");
LinkNode *names = NULL;
BHead *bhead;
@@ -302,7 +302,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
*/
void BLO_blendhandle_close(BlendHandle *bh)
{
- FileData *fd = (FileData *) bh;
+ FileData *fd = (FileData *)bh;
blo_freefiledata(fd);
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index ece0fcbe9df..f12570dc64f 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -309,7 +309,7 @@ static const char *library_parent_filepath(Library *lib)
static OldNewMap *oldnewmap_new(void)
{
- OldNewMap *onm= MEM_callocN(sizeof(*onm), "OldNewMap");
+ OldNewMap *onm = MEM_callocN(sizeof(*onm), "OldNewMap");
onm->entriessize = 1024;
onm->entries = MEM_malloc_arrayN(onm->entriessize, sizeof(*onm->entries), "OldNewMap.entries");
@@ -319,7 +319,7 @@ static OldNewMap *oldnewmap_new(void)
static int verg_oldnewmap(const void *v1, const void *v2)
{
- const struct OldNew *x1=v1, *x2=v2;
+ const struct OldNew *x1 = v1, *x2 = v2;
if (x1->old > x2->old) return 1;
else if (x1->old < x2->old) return -1;
@@ -339,7 +339,7 @@ static void oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr,
{
OldNew *entry;
- if (oldaddr==NULL || newaddr==NULL) return;
+ if (oldaddr == NULL || newaddr == NULL) return;
if (UNLIKELY(onm->nentries == onm->entriessize)) {
onm->entriessize *= 2;
@@ -413,7 +413,7 @@ static void *oldnewmap_lookup_and_inc(OldNewMap *onm, const void *addr, bool inc
if (addr == NULL) return NULL;
- if (onm->lasthit < onm->nentries-1) {
+ if (onm->lasthit < onm->nentries - 1) {
OldNew *entry = &onm->entries[++onm->lasthit];
if (entry->old == addr) {
@@ -526,13 +526,13 @@ void blo_join_main(ListBase *mainlist)
}
}
-static void split_libdata(ListBase *lb_src, Main **lib_main_array, const unsigned int lib_main_array_len)
+static void split_libdata(ListBase *lb_src, Main **lib_main_array, const uint lib_main_array_len)
{
for (ID *id = lb_src->first, *idnext; id; id = idnext) {
idnext = id->next;
if (id->lib) {
- if (((unsigned int)id->lib->temp_index < lib_main_array_len) &&
+ if (((uint)id->lib->temp_index < lib_main_array_len) &&
/* this check should never fail, just incase 'id->lib' is a dangling pointer. */
(lib_main_array[id->lib->temp_index]->curlib == id->lib))
{
@@ -558,8 +558,8 @@ void blo_split_main(ListBase *mainlist, Main *main)
return;
/* (Library.temp_index -> Main), lookup table */
- const unsigned int lib_main_array_len = BLI_listbase_count(&main->library);
- Main **lib_main_array = MEM_malloc_arrayN(lib_main_array_len, sizeof(*lib_main_array), __func__);
+ const uint lib_main_array_len = BLI_listbase_count(&main->library);
+ Main **lib_main_array = MEM_malloc_arrayN(lib_main_array_len, sizeof(*lib_main_array), __func__);
int i = 0;
for (Library *lib = main->library.first; lib; lib = lib->id.next, i++) {
@@ -589,13 +589,13 @@ static void read_file_version(FileData *fd, Main *main)
{
BHead *bhead;
- for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) {
+ for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
if (bhead->code == GLOB) {
- FileGlobal *fg= read_struct(fd, bhead, "Global");
+ FileGlobal *fg = read_struct(fd, bhead, "Global");
if (fg) {
- main->subversionfile= fg->subversion;
- main->minversionfile= fg->minversion;
- main->minsubversionfile= fg->minsubversion;
+ main->subversionfile = fg->subversion;
+ main->minversionfile = fg->minversion;
+ main->minsubversionfile = fg->minsubversion;
MEM_freeN(fg);
}
else if (bhead->code == ENDB)
@@ -616,7 +616,7 @@ static void read_file_bhead_idname_map_create(FileData *fd)
/* dummy values */
bool is_link = false;
int code_prev = ENDB;
- unsigned int reserve = 0;
+ uint reserve = 0;
for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
if (code_prev != bhead->code) {
@@ -694,7 +694,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
static void switch_endian_bh4(BHead4 *bhead)
{
/* the ID_.. codes */
- if ((bhead->code & 0xFFFF)==0) bhead->code >>= 16;
+ if ((bhead->code & 0xFFFF) == 0) bhead->code >>= 16;
if (bhead->code != ENDB) {
BLI_endian_switch_int32(&bhead->len);
@@ -706,7 +706,7 @@ static void switch_endian_bh4(BHead4 *bhead)
static void switch_endian_bh8(BHead8 *bhead)
{
/* the ID_.. codes */
- if ((bhead->code & 0xFFFF)==0) bhead->code >>= 16;
+ if ((bhead->code & 0xFFFF) == 0) bhead->code >>= 16;
if (bhead->code != ENDB) {
BLI_endian_switch_int32(&bhead->len);
@@ -717,7 +717,7 @@ static void switch_endian_bh8(BHead8 *bhead)
static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap)
{
- BHead4 *bhead4 = (BHead4 *) bhead;
+ BHead4 *bhead4 = (BHead4 *)bhead;
int64_t old;
bhead4->code = bhead8->code;
@@ -734,7 +734,7 @@ static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap)
/* this patch is to avoid a long long being read from not-eight aligned positions
* is necessary on any modern 64bit architecture) */
memcpy(&old, &bhead8->old, 8);
- bhead4->old = (int) (old >> 3);
+ bhead4->old = (int)(old >> 3);
bhead4->SDNAnr = bhead8->SDNAnr;
bhead4->nr = bhead8->nr;
@@ -743,7 +743,7 @@ static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap)
static void bh8_from_bh4(BHead *bhead, BHead4 *bhead4)
{
- BHead8 *bhead8 = (BHead8 *) bhead;
+ BHead8 *bhead8 = (BHead8 *)bhead;
bhead8->code = bhead4->code;
bhead8->len = bhead4->len;
@@ -751,7 +751,7 @@ static void bh8_from_bh4(BHead *bhead, BHead4 *bhead4)
if (bhead8->code != ENDB) {
bhead8->old = bhead4->old;
bhead8->SDNAnr = bhead4->SDNAnr;
- bhead8->nr= bhead4->nr;
+ bhead8->nr = bhead4->nr;
}
}
@@ -766,7 +766,7 @@ static BHeadN *get_bhead(FileData *fd)
* since uninitialized memory gets compared */
BHead8 bhead8 = {0};
BHead4 bhead4 = {0};
- BHead bhead = {0};
+ BHead bhead = {0};
/* First read the bhead structure.
* Depending on the platform the file was written on this can
@@ -795,7 +795,7 @@ static BHeadN *get_bhead(FileData *fd)
}
else {
fd->eof = 1;
- bhead.len= 0;
+ bhead.len = 0;
}
}
else {
@@ -818,7 +818,7 @@ static BHeadN *get_bhead(FileData *fd)
}
else {
fd->eof = 1;
- bhead.len= 0;
+ bhead.len = 0;
}
}
@@ -1035,7 +1035,7 @@ static int *read_file_thumbnail(FileData *fd)
return blend_thumb;
}
-static int fd_read_gzip_from_file(FileData *filedata, void *buffer, unsigned int size)
+static int fd_read_gzip_from_file(FileData *filedata, void *buffer, uint size)
{
int readsize = gzread(filedata->gzfiledes, buffer, size);
@@ -1049,10 +1049,10 @@ static int fd_read_gzip_from_file(FileData *filedata, void *buffer, unsigned int
return (readsize);
}
-static int fd_read_from_memory(FileData *filedata, void *buffer, unsigned int size)
+static int fd_read_from_memory(FileData *filedata, void *buffer, uint size)
{
/* don't read more bytes then there are available in the buffer */
- int readsize = (int)MIN2(size, (unsigned int)(filedata->buffersize - filedata->seek));
+ int readsize = (int)MIN2(size, (uint)(filedata->buffersize - filedata->seek));
memcpy(buffer, filedata->buffer + filedata->seek, readsize);
filedata->seek += readsize;
@@ -1060,21 +1060,23 @@ static int fd_read_from_memory(FileData *filedata, void *buffer, unsigned int si
return (readsize);
}
-static int fd_read_from_memfile(FileData *filedata, void *buffer, unsigned int size)
+static int fd_read_from_memfile(FileData *filedata, void *buffer, uint size)
{
- static unsigned int seek = (1<<30); /* the current position */
- static unsigned int offset = 0; /* size of previous chunks */
+ static uint seek = (1 << 30); /* the current position */
+ static uint offset = 0; /* size of previous chunks */
static MemFileChunk *chunk = NULL;
- unsigned int chunkoffset, readsize, totread;
+ uint chunkoffset, readsize, totread;
if (size == 0) return 0;
- if (seek != (unsigned int)filedata->seek) {
+ if (seek != (uint)filedata->seek) {
chunk = filedata->memfile->chunks.first;
seek = 0;
while (chunk) {
- if (seek + chunk->size > (unsigned) filedata->seek) break;
+ if (seek + chunk->size > (uint)filedata->seek) {
+ break;
+ }
seek += chunk->size;
chunk = chunk->next;
}
@@ -1087,7 +1089,7 @@ static int fd_read_from_memfile(FileData *filedata, void *buffer, unsigned int s
do {
/* first check if it's on the end if current chunk */
- if (seek-offset == chunk->size) {
+ if (seek - offset == chunk->size) {
offset += chunk->size;
chunk = chunk->next;
}
@@ -1098,14 +1100,14 @@ static int fd_read_from_memfile(FileData *filedata, void *buffer, unsigned int s
return 0;
}
- chunkoffset = seek-offset;
- readsize = size-totread;
+ chunkoffset = seek - offset;
+ readsize = size - totread;
/* data can be spread over multiple chunks, so clamp size
* to within this chunk, and then it will read further in
* the next chunk */
- if (chunkoffset+readsize > chunk->size)
- readsize= chunk->size-chunkoffset;
+ if (chunkoffset + readsize > chunk->size)
+ readsize = chunk->size - chunkoffset;
memcpy(POINTER_OFFSET(buffer, totread), chunk->buf + chunkoffset, readsize);
totread += readsize;
@@ -1210,15 +1212,15 @@ static FileData *blo_openblenderfile_minimal(const char *filepath)
return NULL;
}
-static int fd_read_gzip_from_memory(FileData *filedata, void *buffer, unsigned int size)
+static int fd_read_gzip_from_memory(FileData *filedata, void *buffer, uint size)
{
int err;
- filedata->strm.next_out = (Bytef *) buffer;
+ filedata->strm.next_out = (Bytef *)buffer;
filedata->strm.avail_out = size;
// Inflate another chunk.
- err = inflate (&filedata->strm, Z_SYNC_FLUSH);
+ err = inflate(&filedata->strm, Z_SYNC_FLUSH);
if (err == Z_STREAM_END) {
return 0;
@@ -1236,13 +1238,13 @@ static int fd_read_gzip_from_memory(FileData *filedata, void *buffer, unsigned i
static int fd_read_gzip_from_memory_init(FileData *fd)
{
- fd->strm.next_in = (Bytef *) fd->buffer;
+ fd->strm.next_in = (Bytef *)fd->buffer;
fd->strm.avail_in = fd->buffersize;
fd->strm.total_out = 0;
fd->strm.zalloc = Z_NULL;
fd->strm.zfree = Z_NULL;
- if (inflateInit2(&fd->strm, (16+MAX_WBITS)) != Z_OK)
+ if (inflateInit2(&fd->strm, (16 + MAX_WBITS)) != Z_OK)
return 0;
fd->read = fd_read_gzip_from_memory;
@@ -1252,8 +1254,8 @@ static int fd_read_gzip_from_memory_init(FileData *fd)
FileData *blo_openblendermemory(const void *mem, int memsize, ReportList *reports)
{
- if (!mem || memsize<SIZEOFBLENDERHEADER) {
- BKE_report(reports, RPT_WARNING, (mem) ? TIP_("Unable to read"): TIP_("Unable to open"));
+ if (!mem || memsize < SIZEOFBLENDERHEADER) {
+ BKE_report(reports, RPT_WARNING, (mem) ? TIP_("Unable to read") : TIP_("Unable to open"));
return NULL;
}
else {
@@ -1480,7 +1482,7 @@ BlendThumbnail *BLO_thumbnail_from_file(const char *filepath)
/* ************** OLD POINTERS ******************* */
-static void *newdataadr(FileData *fd, const void *adr) /* only direct databocks */
+static void *newdataadr(FileData *fd, const void *adr) /* only direct databocks */
{
return oldnewmap_lookup_and_inc(fd->datamap, adr, true);
}
@@ -1497,7 +1499,7 @@ static void *newdataadr(FileData *fd, const void *adr) /* only direct databocks
* fcurve group pointer and keeps lasthit optimal for linking all further
* fcurves.
*/
-static void *newdataadr_ex(FileData *fd, const void *adr, bool increase_lasthit) /* only direct databocks */
+static void *newdataadr_ex(FileData *fd, const void *adr, bool increase_lasthit) /* only direct databocks */
{
if (increase_lasthit) {
return newdataadr(fd, adr);
@@ -1510,24 +1512,24 @@ static void *newdataadr_ex(FileData *fd, const void *adr, bool increase_lasthit)
}
}
-static void *newdataadr_no_us(FileData *fd, const void *adr) /* only direct databocks */
+static void *newdataadr_no_us(FileData *fd, const void *adr) /* only direct databocks */
{
return oldnewmap_lookup_and_inc(fd->datamap, adr, false);
}
-static void *newglobadr(FileData *fd, const void *adr) /* direct datablocks with global linking */
+static void *newglobadr(FileData *fd, const void *adr) /* direct datablocks with global linking */
{
return oldnewmap_lookup_and_inc(fd->globmap, adr, true);
}
-static void *newimaadr(FileData *fd, const void *adr) /* used to restore image data after undo */
+static void *newimaadr(FileData *fd, const void *adr) /* used to restore image data after undo */
{
if (fd->imamap && adr)
return oldnewmap_lookup_and_inc(fd->imamap, adr, true);
return NULL;
}
-static void *newsceadr(FileData *fd, const void *adr) /* used to restore scene data after undo */
+static void *newsceadr(FileData *fd, const void *adr) /* used to restore scene data after undo */
{
if (fd->scenemap && adr)
return oldnewmap_lookup_and_inc(fd->scenemap, adr, true);
@@ -1557,17 +1559,17 @@ static void *newpackedadr(FileData *fd, const void *adr) /* used to restore
}
-static void *newlibadr(FileData *fd, const void *lib, const void *adr) /* only lib data */
+static void *newlibadr(FileData *fd, const void *lib, const void *adr) /* only lib data */
{
return oldnewmap_liblookup(fd->libmap, adr, lib);
}
-void *blo_do_versions_newlibadr(FileData *fd, const void *lib, const void *adr) /* only lib data */
+void *blo_do_versions_newlibadr(FileData *fd, const void *lib, const void *adr) /* only lib data */
{
return newlibadr(fd, lib, adr);
}
-static void *newlibadr_us(FileData *fd, const void *lib, const void *adr) /* increases user number */
+static void *newlibadr_us(FileData *fd, const void *lib, const void *adr) /* increases user number */
{
ID *id = newlibadr(fd, lib, adr);
@@ -1576,12 +1578,12 @@ static void *newlibadr_us(FileData *fd, const void *lib, const void *adr) /* inc
return id;
}
-void *blo_do_versions_newlibadr_us(FileData *fd, const void *lib, const void *adr) /* increases user number */
+void *blo_do_versions_newlibadr_us(FileData *fd, const void *lib, const void *adr) /* increases user number */
{
return newlibadr_us(fd, lib, adr);
}
-static void *newlibadr_real_us(FileData *fd, const void *lib, const void *adr) /* ensures real user */
+static void *newlibadr_real_us(FileData *fd, const void *lib, const void *adr) /* ensures real user */
{
ID *id = newlibadr(fd, lib, adr);
@@ -1600,9 +1602,9 @@ static void change_idid_adr_fd(FileData *fd, const void *old, void *new)
for (i = 0; i < fd->libmap->nentries; i++) {
OldNew *entry = &fd->libmap->entries[i];
- if (old==entry->newp && entry->nr==ID_ID) {
+ if (old == entry->newp && entry->nr == ID_ID) {
entry->newp = new;
- if (new) entry->nr = GS( ((ID *)new)->name );
+ if (new) entry->nr = GS( ((ID *)new)->name);
}
}
}
@@ -1633,7 +1635,7 @@ void blo_clear_proxy_pointers_from_lib(Main *oldmain)
{
Object *ob = oldmain->object.first;
- for (; ob; ob= ob->id.next) {
+ for (; ob; ob = ob->id.next) {
if (ob->id.lib)
ob->proxy_from = NULL;
}
@@ -1679,16 +1681,22 @@ void blo_make_image_pointer_map(FileData *fd, Main *oldmain)
fd->imamap = oldnewmap_new();
for (; ima; ima = ima->id.next) {
- if (ima->cache)
+ if (ima->cache) {
oldnewmap_insert(fd->imamap, ima->cache, ima->cache, 0);
- for (a = 0; a < TEXTARGET_COUNT; a++)
- if (ima->gputexture[a])
+ }
+ for (a = 0; a < TEXTARGET_COUNT; a++) {
+ if (ima->gputexture[a]) {
oldnewmap_insert(fd->imamap, ima->gputexture[a], ima->gputexture[a], 0);
- if (ima->rr)
+ }
+ }
+ if (ima->rr) {
oldnewmap_insert(fd->imamap, ima->rr, ima->rr, 0);
- LISTBASE_FOREACH(RenderSlot *, slot, &ima->renderslots)
- if (slot->render)
- oldnewmap_insert(fd->imamap, slot->render, slot->render, 0);
+ }
+ LISTBASE_FOREACH(RenderSlot *, slot, &ima->renderslots) {
+ if (slot->render) {
+ oldnewmap_insert(fd->imamap, slot->render, slot->render, 0);
+ }
+ }
}
for (; sce; sce = sce->id.next) {
if (sce->nodetree && sce->nodetree->previews) {
@@ -1725,8 +1733,9 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain)
}
ima->rr = NULL;
}
- LISTBASE_FOREACH(RenderSlot *, slot, &ima->renderslots)
+ LISTBASE_FOREACH(RenderSlot *, slot, &ima->renderslots) {
slot->render = newimaadr(fd, slot->render);
+ }
for (i = 0; i < TEXTARGET_COUNT; i++)
ima->gputexture[i] = newimaadr(fd, ima->gputexture[i]);
@@ -1789,7 +1798,7 @@ void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain)
int i;
/* used entries were restored, so we put them to zero */
- for (i=0; i < fd->movieclipmap->nentries; i++, entry++) {
+ for (i = 0; i < fd->movieclipmap->nentries; i++, entry++) {
if (entry->nr > 0)
entry->newp = NULL;
}
@@ -1894,7 +1903,7 @@ void blo_end_packed_pointer_map(FileData *fd, Main *oldmain)
int i;
/* used entries were restored, so we put them to zero */
- for (i=0; i < fd->packedmap->nentries; i++, entry++) {
+ for (i = 0; i < fd->packedmap->nentries; i++, entry++) {
if (entry->nr > 0)
entry->newp = NULL;
}
@@ -1946,8 +1955,8 @@ static void switch_endian_structs(const struct SDNA *filesdna, BHead *bhead)
int blocksize, nblocks;
char *data;
- data = (char *)(bhead+1);
- blocksize = filesdna->typelens[ filesdna->structs[bhead->SDNAnr][0] ];
+ data = (char *)(bhead + 1);
+ blocksize = filesdna->typelens[filesdna->structs[bhead->SDNAnr][0]];
nblocks = bhead->nr;
while (nblocks--) {
@@ -1968,12 +1977,12 @@ static void *read_struct(FileData *fd, BHead *bh, const char *blockname)
if (fd->compflags[bh->SDNAnr] != SDNA_CMP_REMOVED) {
if (fd->compflags[bh->SDNAnr] == SDNA_CMP_NOT_EQUAL) {
- temp = DNA_struct_reconstruct(fd->memsdna, fd->filesdna, fd->compflags, bh->SDNAnr, bh->nr, (bh+1));
+ temp = DNA_struct_reconstruct(fd->memsdna, fd->filesdna, fd->compflags, bh->SDNAnr, bh->nr, (bh + 1));
}
else {
/* SDNA_CMP_EQUAL */
temp = MEM_mallocN(bh->len, blockname);
- memcpy(temp, (bh+1), bh->len);
+ memcpy(temp, (bh + 1), bh->len);
}
}
}
@@ -1983,7 +1992,7 @@ static void *read_struct(FileData *fd, BHead *bh, const char *blockname)
typedef void (*link_list_cb)(FileData *fd, void *data);
-static void link_list_ex(FileData *fd, ListBase *lb, link_list_cb callback) /* only direct data */
+static void link_list_ex(FileData *fd, ListBase *lb, link_list_cb callback) /* only direct data */
{
Link *ln, *prev;
@@ -2007,12 +2016,12 @@ static void link_list_ex(FileData *fd, ListBase *lb, link_list_cb callback) /*
lb->last = prev;
}
-static void link_list(FileData *fd, ListBase *lb) /* only direct data */
+static void link_list(FileData *fd, ListBase *lb) /* only direct data */
{
link_list_ex(fd, lb, NULL);
}
-static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */
+static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */
{
Link *ln, *prev;
void *poin;
@@ -2045,16 +2054,16 @@ static void test_pointer_array(FileData *fd, void **mat)
int *ipoin, *imat;
size_t len;
- /* manually convert the pointer array in
- * the old dna format to a pointer array in
- * the new dna format.
- */
+ /* manually convert the pointer array in
+ * the old dna format to a pointer array in
+ * the new dna format.
+ */
if (*mat) {
- len = MEM_allocN_len(*mat)/fd->filesdna->pointerlen;
+ len = MEM_allocN_len(*mat) / fd->filesdna->pointerlen;
- if (fd->filesdna->pointerlen==8 && fd->memsdna->pointerlen==4) {
- ipoin=imat= MEM_malloc_arrayN(len, 4, "newmatar");
- lpoin= *mat;
+ if (fd->filesdna->pointerlen == 8 && fd->memsdna->pointerlen == 4) {
+ ipoin = imat = MEM_malloc_arrayN(len, 4, "newmatar");
+ lpoin = *mat;
while (len-- > 0) {
if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN))
@@ -2067,7 +2076,7 @@ static void test_pointer_array(FileData *fd, void **mat)
*mat = imat;
}
- if (fd->filesdna->pointerlen==4 && fd->memsdna->pointerlen==8) {
+ if (fd->filesdna->pointerlen == 4 && fd->memsdna->pointerlen == 8) {
lpoin = lmat = MEM_malloc_arrayN(len, 8, "newmatar");
ipoin = *mat;
@@ -2077,7 +2086,7 @@ static void test_pointer_array(FileData *fd, void **mat)
lpoin++;
}
MEM_freeN(*mat);
- *mat= lmat;
+ *mat = lmat;
}
}
}
@@ -2154,7 +2163,7 @@ static void IDP_DirectLinkGroup(IDProperty *prop, int switch_endian, FileData *f
link_list(fd, lb);
/*Link child id properties now*/
- for (loop=prop->data.group.first; loop; loop=loop->next) {
+ for (loop = prop->data.group.first; loop; loop = loop->next) {
IDP_DirectLinkProperty(loop, switch_endian, fd);
}
}
@@ -2518,7 +2527,7 @@ static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist)
bActionStrip *strip;
bActionModifier *amod;
- for (strip=striplist->first; strip; strip=strip->next) {
+ for (strip = striplist->first; strip; strip = strip->next) {
strip->object = newlibadr(fd, id->lib, strip->object);
strip->act = newlibadr_us(fd, id->lib, strip->act);
strip->ipo = newlibadr(fd, id->lib, strip->ipo);
@@ -2543,7 +2552,7 @@ static void lib_link_constraint_channels(FileData *fd, ID *id, ListBase *chanbas
{
bConstraintChannel *chan;
- for (chan=chanbase->first; chan; chan=chan->next) {
+ for (chan = chanbase->first; chan; chan = chan->next) {
chan->ipo = newlibadr_us(fd, id->lib, chan->ipo);
}
}
@@ -2582,8 +2591,8 @@ static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list)
ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
- for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
- DRIVER_TARGETS_LOOPER(dvar)
+ for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
+ DRIVER_TARGETS_LOOPER_BEGIN(dvar)
{
/* only relink if still used */
if (tarIndex < dvar->num_targets)
@@ -2591,7 +2600,7 @@ static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list)
else
dtar->id = NULL;
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
@@ -2627,9 +2636,9 @@ static void direct_link_fmodifiers(FileData *fd, ListBase *list, FCurve *curve)
}
case FMODIFIER_TYPE_ENVELOPE:
{
- FMod_Envelope *data= (FMod_Envelope *)fcm->data;
+ FMod_Envelope *data = (FMod_Envelope *)fcm->data;
- data->data= newdataadr(fd, data->data);
+ data->data = newdataadr(fd, data->data);
break;
}
@@ -2669,9 +2678,9 @@ static void direct_link_fcurves(FileData *fd, ListBase *list)
fcu->flag &= ~FCURVE_DISABLED;
/* driver */
- fcu->driver= newdataadr(fd, fcu->driver);
+ fcu->driver = newdataadr(fd, fcu->driver);
if (fcu->driver) {
- ChannelDriver *driver= fcu->driver;
+ ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
/* compiled expression data will need to be regenerated (old pointer may still be set here) */
@@ -2685,8 +2694,8 @@ static void direct_link_fcurves(FileData *fd, ListBase *list)
/* relink variables, targets and their paths */
link_list(fd, &driver->variables);
- for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
- DRIVER_TARGETS_LOOPER(dvar)
+ for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
+ DRIVER_TARGETS_LOOPER_BEGIN(dvar)
{
/* only relink the targets being used */
if (tarIndex < dvar->num_targets)
@@ -2694,7 +2703,7 @@ static void direct_link_fcurves(FileData *fd, ListBase *list)
else
dtar->rna_path = NULL;
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
@@ -2742,7 +2751,7 @@ static void direct_link_action(FileData *fd, bAction *act)
link_list(fd, &act->markers);
// XXX deprecated - old animation system <<<
- for (achan = act->chanbase.first; achan; achan=achan->next) {
+ for (achan = act->chanbase.first; achan; achan = achan->next) {
achan->grp = newdataadr(fd, achan->grp);
link_list(fd, &achan->constraintChannels);
@@ -2751,9 +2760,9 @@ static void direct_link_action(FileData *fd, bAction *act)
direct_link_fcurves(fd, &act->curves);
- for (agrp = act->groups.first; agrp; agrp= agrp->next) {
- agrp->channels.first= newdataadr(fd, agrp->channels.first);
- agrp->channels.last= newdataadr(fd, agrp->channels.last);
+ for (agrp = act->groups.first; agrp; agrp = agrp->next) {
+ agrp->channels.first = newdataadr(fd, agrp->channels.first);
+ agrp->channels.last = newdataadr(fd, agrp->channels.last);
}
}
@@ -2833,7 +2842,7 @@ static void lib_link_keyingsets(FileData *fd, ID *id, ListBase *list)
/* here, we're only interested in the ID pointer stored in some of the paths */
for (ks = list->first; ks; ks = ks->next) {
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
- ksp->id= newlibadr(fd, id->lib, ksp->id);
+ ksp->id = newlibadr(fd, id->lib, ksp->id);
}
}
}
@@ -2851,7 +2860,7 @@ static void direct_link_keyingsets(FileData *fd, ListBase *list)
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
/* rna path */
- ksp->rna_path= newdataadr(fd, ksp->rna_path);
+ ksp->rna_path = newdataadr(fd, ksp->rna_path);
}
}
}
@@ -2864,8 +2873,8 @@ static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt)
return;
/* link action data */
- adt->action= newlibadr_us(fd, id->lib, adt->action);
- adt->tmpact= newlibadr_us(fd, id->lib, adt->tmpact);
+ adt->action = newlibadr_us(fd, id->lib, adt->action);
+ adt->tmpact = newlibadr_us(fd, id->lib, adt->tmpact);
/* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */
if ((adt->action) && (adt->action->idroot == 0))
@@ -3082,11 +3091,11 @@ static void lib_link_nodetree(FileData *fd, Main *main)
*/
static void lib_node_do_versions_group_indices(bNode *gnode)
{
- bNodeTree *ngroup = (bNodeTree*)gnode->id;
+ bNodeTree *ngroup = (bNodeTree *)gnode->id;
bNodeSocket *sock;
bNodeLink *link;
- for (sock=gnode->outputs.first; sock; sock = sock->next) {
+ for (sock = gnode->outputs.first; sock; sock = sock->next) {
int old_index = sock->to_index;
for (link = ngroup->links.first; link; link = link->next) {
@@ -3099,7 +3108,7 @@ static void lib_node_do_versions_group_indices(bNode *gnode)
}
}
}
- for (sock=gnode->inputs.first; sock; sock = sock->next) {
+ for (sock = gnode->inputs.first; sock; sock = sock->next) {
int old_index = sock->to_index;
for (link = ngroup->links.first; link; link = link->next) {
@@ -3121,22 +3130,22 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
{
/* this crashes blender on undo/redo */
#if 0
- if (open == 1) {
- reinit_nodesystem();
- }
+ if (open == 1) {
+ reinit_nodesystem();
+ }
#endif
/* set node->typeinfo pointers */
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE_BEGIN (main, ntree, id) {
ntreeSetTypes(NULL, ntree);
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
/* verify static socket templates */
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE_BEGIN (main, ntree, id) {
bNode *node;
- for (node=ntree->nodes.first; node; node=node->next)
+ for (node = ntree->nodes.first; node; node = node->next)
node_verify_socket_templates(ntree, node);
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
{
bool has_old_groups = false;
@@ -3152,17 +3161,17 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
}
if (has_old_groups) {
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE_BEGIN (main, ntree, id) {
/* updates external links for all group nodes in a tree */
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP) {
- bNodeTree *ngroup = (bNodeTree*)node->id;
+ bNodeTree *ngroup = (bNodeTree *)node->id;
if (ngroup && (ngroup->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2))
lib_node_do_versions_group_indices(node);
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
for (bNodeTree *ntree = main->nodetree.first; ntree; ntree = ntree->id.next) {
@@ -3183,7 +3192,7 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
* so have to clean up all of them ...
*/
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE_BEGIN(main, ntree, id) {
if (ntree->flag & NTREE_DO_VERSIONS_CUSTOMNODES_GROUP) {
bNode *input_node = NULL, *output_node = NULL;
int num_inputs = 0, num_outputs = 0;
@@ -3197,7 +3206,7 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
float input_locx = 1000000.0f, input_locy = 0.0f;
float output_locx = -1000000.0f, output_locy = 0.0f;
/* rough guess, not nice but we don't have access to UI constants here ... */
- static const float offsetx = 42 + 3*20 + 20;
+ static const float offsetx = 42 + 3 * 20 + 20;
/*static const float offsety = 0.0f;*/
if (create_io_nodes) {
@@ -3269,7 +3278,7 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
ntree->flag &= ~(NTREE_DO_VERSIONS_CUSTOMNODES_GROUP | NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE);
}
}
- FOREACH_NODETREE_END
+ FOREACH_NODETREE_END;
}
/* verify all group user nodes */
@@ -3279,10 +3288,10 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
/* make update calls where necessary */
{
- FOREACH_NODETREE(main, ntree, id) {
+ FOREACH_NODETREE_BEGIN(main, ntree, id) {
/* make an update call for the tree */
ntreeUpdateTree(main, ntree);
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
}
@@ -3306,9 +3315,9 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
bNodeSocket *sock;
bNodeLink *link;
- ntree->init = 0; /* to set callbacks and force setting types */
+ ntree->init = 0; /* to set callbacks and force setting types */
ntree->is_updating = false;
- ntree->typeinfo= NULL;
+ ntree->typeinfo = NULL;
ntree->interface_type = NULL;
ntree->progress = NULL;
@@ -3347,33 +3356,33 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
if (node->storage) {
/* could be handlerized at some point */
- if (ntree->type==NTREE_SHADER) {
- if (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB) {
+ if (ntree->type == NTREE_SHADER) {
+ if (node->type == SH_NODE_CURVE_VEC || node->type == SH_NODE_CURVE_RGB) {
direct_link_curvemapping(fd, node->storage);
}
- else if (node->type==SH_NODE_SCRIPT) {
- NodeShaderScript *nss = (NodeShaderScript *) node->storage;
+ else if (node->type == SH_NODE_SCRIPT) {
+ NodeShaderScript *nss = (NodeShaderScript *)node->storage;
nss->bytecode = newdataadr(fd, nss->bytecode);
}
- else if (node->type==SH_NODE_TEX_POINTDENSITY) {
- NodeShaderTexPointDensity *npd = (NodeShaderTexPointDensity *) node->storage;
+ else if (node->type == SH_NODE_TEX_POINTDENSITY) {
+ NodeShaderTexPointDensity *npd = (NodeShaderTexPointDensity *)node->storage;
memset(&npd->pd, 0, sizeof(npd->pd));
}
}
- else if (ntree->type==NTREE_COMPOSIT) {
+ else if (ntree->type == NTREE_COMPOSIT) {
if (ELEM(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT))
direct_link_curvemapping(fd, node->storage);
else if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
((ImageUser *)node->storage)->ok = 1;
- else if (node->type==CMP_NODE_CRYPTOMATTE) {
- NodeCryptomatte *nc = (NodeCryptomatte *) node->storage;
+ else if (node->type == CMP_NODE_CRYPTOMATTE) {
+ NodeCryptomatte *nc = (NodeCryptomatte *)node->storage;
nc->matte_id = newdataadr(fd, nc->matte_id);
}
}
- else if ( ntree->type==NTREE_TEXTURE) {
- if (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME)
+ else if (ntree->type == NTREE_TEXTURE) {
+ if (node->type == TEX_NODE_CURVE_RGB || node->type == TEX_NODE_CURVE_TIME)
direct_link_curvemapping(fd, node->storage);
- else if (node->type==TEX_NODE_IMAGE)
+ else if (node->type == TEX_NODE_IMAGE)
((ImageUser *)node->storage)->ok = 1;
}
}
@@ -3399,7 +3408,7 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
for (sock = ntree->outputs.first; sock; sock = sock->next)
direct_link_node_socket(fd, sock);
- for (link = ntree->links.first; link; link= link->next) {
+ for (link = ntree->links.first; link; link = link->next) {
link->fromnode = newdataadr(fd, link->fromnode);
link->tonode = newdataadr(fd, link->tonode);
link->fromsock = newdataadr(fd, link->fromsock);
@@ -3442,7 +3451,7 @@ typedef struct tConstraintLinkData {
/* callback function used to relink constraint ID-links */
static void lib_link_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, bool is_reference, void *userdata)
{
- tConstraintLinkData *cld= (tConstraintLinkData *)userdata;
+ tConstraintLinkData *cld = (tConstraintLinkData *)userdata;
/* for reference types, we need to increment the usercounts on load... */
if (is_reference) {
@@ -3461,7 +3470,7 @@ static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist)
bConstraint *con;
/* legacy fixes */
- for (con = conlist->first; con; con=con->next) {
+ for (con = conlist->first; con; con = con->next) {
/* patch for error introduced by changing constraints (dunno how) */
/* if con->data type changes, dna cannot resolve the pointer! (ton) */
if (con->data == NULL) {
@@ -3488,13 +3497,13 @@ static void direct_link_constraints(FileData *fd, ListBase *lb)
bConstraint *con;
link_list(fd, lb);
- for (con=lb->first; con; con=con->next) {
+ for (con = lb->first; con; con = con->next) {
con->data = newdataadr(fd, con->data);
switch (con->type) {
case CONSTRAINT_TYPE_PYTHON:
{
- bPythonConstraint *data= con->data;
+ bPythonConstraint *data = con->data;
link_list(fd, &data->targets);
@@ -3504,7 +3513,7 @@ static void direct_link_constraints(FileData *fd, ListBase *lb)
}
case CONSTRAINT_TYPE_ARMATURE:
{
- bArmatureConstraint *data= con->data;
+ bArmatureConstraint *data = con->data;
link_list(fd, &data->targets);
@@ -3512,9 +3521,9 @@ static void direct_link_constraints(FileData *fd, ListBase *lb)
}
case CONSTRAINT_TYPE_SPLINEIK:
{
- bSplineIKConstraint *data= con->data;
+ bSplineIKConstraint *data = con->data;
- data->points= newdataadr(fd, data->points);
+ data->points = newdataadr(fd, data->points);
break;
}
case CONSTRAINT_TYPE_KINEMATIC:
@@ -3599,7 +3608,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
if (rebuild) {
- DEG_id_tag_update_ex(bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update_ex(bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
BKE_pose_tag_recalc(bmain, pose);
}
}
@@ -3644,7 +3653,7 @@ static void direct_link_bones(FileData *fd, Bone *bone)
link_list(fd, &bone->childbase);
- for (child=bone->childbase.first; child; child=child->next)
+ for (child = bone->childbase.first; child; child = child->next)
direct_link_bones(fd, child);
}
@@ -3732,7 +3741,7 @@ static void direct_link_lamp(FileData *fd, Lamp *la)
if (la->curfalloff)
direct_link_curvemapping(fd, la->curfalloff);
- la->nodetree= newdataadr(fd, la->nodetree);
+ la->nodetree = newdataadr(fd, la->nodetree);
if (la->nodetree) {
direct_link_id(fd, &la->nodetree->id);
direct_link_nodetree(fd, la->nodetree);
@@ -3808,7 +3817,7 @@ static void direct_link_key(FileData *fd, Key *key)
key->adt = newdataadr(fd, key->adt);
direct_link_animdata(fd, key->adt);
- key->refkey= newdataadr(fd, key->refkey);
+ key->refkey = newdataadr(fd, key->refkey);
for (kb = key->block.first; kb; kb = kb->next) {
kb->data = newdataadr(fd, kb->data);
@@ -3949,7 +3958,7 @@ static void direct_link_text(FileData *fd, Text *text)
ln->line = newdataadr(fd, ln->line);
ln->format = NULL;
- if (ln->len != (int) strlen(ln->line)) {
+ if (ln->len != (int)strlen(ln->line)) {
printf("Error loading text, line lengths differ\n");
ln->len = strlen(ln->line);
}
@@ -4071,7 +4080,7 @@ static void direct_link_curve(FileData *fd, Curve *cu)
Nurb *nu;
TextBox *tb;
- cu->adt= newdataadr(fd, cu->adt);
+ cu->adt = newdataadr(fd, cu->adt);
direct_link_animdata(fd, cu->adt);
/* Protect against integer overflow vulnerability. */
@@ -4080,18 +4089,18 @@ static void direct_link_curve(FileData *fd, Curve *cu)
cu->mat = newdataadr(fd, cu->mat);
test_pointer_array(fd, (void **)&cu->mat);
cu->str = newdataadr(fd, cu->str);
- cu->strinfo= newdataadr(fd, cu->strinfo);
+ cu->strinfo = newdataadr(fd, cu->strinfo);
cu->tb = newdataadr(fd, cu->tb);
if (cu->vfont == NULL) {
link_list(fd, &(cu->nurb));
}
else {
- cu->nurb.first=cu->nurb.last= NULL;
+ cu->nurb.first = cu->nurb.last = NULL;
tb = MEM_calloc_arrayN(MAXTEXTBOX, sizeof(TextBox), "TextBoxread");
if (cu->tb) {
- memcpy(tb, cu->tb, cu->totbox*sizeof(TextBox));
+ memcpy(tb, cu->tb, cu->totbox * sizeof(TextBox));
MEM_freeN(cu->tb);
cu->tb = tb;
}
@@ -4237,7 +4246,7 @@ static void direct_link_pointcache_cb(FileData *fd, void *data)
pm->data[i] = newdataadr(fd, pm->data[i]);
/* the cache saves non-struct data without DNA */
- if (pm->data[i] && ptcache_data_struct[i][0]=='\0' && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) {
+ if (pm->data[i] && ptcache_data_struct[i][0] == '\0' && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) {
int tot = (BKE_ptcache_data_size(i) * pm->totpoint) / sizeof(int); /* data_size returns bytes */
int *poin = pm->data[i];
@@ -4247,13 +4256,13 @@ static void direct_link_pointcache_cb(FileData *fd, void *data)
link_list(fd, &pm->extradata);
- for (extra=pm->extradata.first; extra; extra=extra->next)
+ for (extra = pm->extradata.first; extra; extra = extra->next)
extra->data = newdataadr(fd, extra->data);
}
static void direct_link_pointcache(FileData *fd, PointCache *cache)
{
- if ((cache->flag & PTCACHE_DISK_CACHE)==0) {
+ if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
link_list_ex(fd, &cache->mem_cache, direct_link_pointcache_cb);
}
else
@@ -4269,9 +4278,9 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache)
static void direct_link_pointcache_list(FileData *fd, ListBase *ptcaches, PointCache **ocache, int force_disk)
{
if (ptcaches->first) {
- PointCache *cache= NULL;
+ PointCache *cache = NULL;
link_list(fd, ptcaches);
- for (cache=ptcaches->first; cache; cache=cache->next) {
+ for (cache = ptcaches->first; cache; cache = cache->next) {
direct_link_pointcache(fd, cache);
if (force_disk) {
cache->flag |= PTCACHE_DISK_CACHE;
@@ -4324,7 +4333,7 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group);
}
else {
- part->effector_weights = BKE_add_effector_weights(part->eff_group);
+ part->effector_weights = BKE_effector_add_weights(part->eff_group);
}
if (part->dupliweights.first && part->dup_group) {
@@ -4339,20 +4348,20 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
if (part->boids) {
BoidState *state = part->boids->states.first;
BoidRule *rule;
- for (; state; state=state->next) {
+ for (; state; state = state->next) {
rule = state->rules.first;
- for (; rule; rule=rule->next) {
+ for (; rule; rule = rule->next) {
switch (rule->type) {
case eBoidRuleType_Goal:
case eBoidRuleType_Avoid:
{
- BoidRuleGoalAvoid *brga = (BoidRuleGoalAvoid*)rule;
+ BoidRuleGoalAvoid *brga = (BoidRuleGoalAvoid *)rule;
brga->ob = newlibadr(fd, part->id.lib, brga->ob);
break;
}
case eBoidRuleType_FollowLeader:
{
- BoidRuleFollowLeader *brfl = (BoidRuleFollowLeader*)rule;
+ BoidRuleFollowLeader *brfl = (BoidRuleFollowLeader *)rule;
brfl->ob = newlibadr(fd, part->id.lib, brfl->ob);
break;
}
@@ -4362,7 +4371,7 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
}
for (int a = 0; a < MAX_MTEX; a++) {
- MTex *mtex= part->mtex[a];
+ MTex *mtex = part->mtex[a];
if (mtex) {
mtex->tex = newlibadr_us(fd, part->id.lib, mtex->tex);
mtex->object = newlibadr(fd, part->id.lib, mtex->object);
@@ -4403,7 +4412,7 @@ static void direct_link_particlesettings(FileData *fd, ParticleSettings *part)
part->effector_weights = newdataadr(fd, part->effector_weights);
if (!part->effector_weights)
- part->effector_weights = BKE_add_effector_weights(part->eff_group);
+ part->effector_weights = BKE_effector_add_weights(part->eff_group);
link_list(fd, &part->dupliweights);
@@ -4414,7 +4423,7 @@ static void direct_link_particlesettings(FileData *fd, ParticleSettings *part)
BoidState *state;
link_list(fd, &part->boids->states);
- for (state=part->boids->states.first; state; state=state->next) {
+ for (state = part->boids->states.first; state; state = state->next) {
link_list(fd, &state->rules);
link_list(fd, &state->conditions);
link_list(fd, &state->actions);
@@ -4432,15 +4441,15 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase
{
ParticleSystem *psys, *psysnext;
- for (psys=particles->first; psys; psys=psysnext) {
+ for (psys = particles->first; psys; psys = psysnext) {
psysnext = psys->next;
psys->part = newlibadr_us(fd, id->lib, psys->part);
if (psys->part) {
ParticleTarget *pt = psys->targets.first;
- for (; pt; pt=pt->next)
- pt->ob=newlibadr(fd, id->lib, pt->ob);
+ for (; pt; pt = pt->next)
+ pt->ob = newlibadr(fd, id->lib, pt->ob);
psys->parent = newlibadr(fd, id->lib, psys->parent);
psys->target_ob = newlibadr(fd, id->lib, psys->target_ob);
@@ -4449,7 +4458,7 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase
/* XXX - from reading existing code this seems correct but intended usage of
* pointcache /w cloth should be added in 'ParticleSystem' - campbell */
psys->clmd->point_cache = psys->pointcache;
- psys->clmd->ptcaches.first = psys->clmd->ptcaches.last= NULL;
+ psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL;
psys->clmd->coll_parms->group = newlibadr(fd, id->lib, psys->clmd->coll_parms->group);
psys->clmd->modifier.error = NULL;
}
@@ -4471,18 +4480,18 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
ParticleData *pa;
int a;
- for (psys=particles->first; psys; psys=psys->next) {
- psys->particles=newdataadr(fd, psys->particles);
+ for (psys = particles->first; psys; psys = psys->next) {
+ psys->particles = newdataadr(fd, psys->particles);
if (psys->particles && psys->particles->hair) {
- for (a=0, pa=psys->particles; a<psys->totpart; a++, pa++)
- pa->hair=newdataadr(fd, pa->hair);
+ for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++)
+ pa->hair = newdataadr(fd, pa->hair);
}
if (psys->particles && psys->particles->keys) {
- for (a=0, pa=psys->particles; a<psys->totpart; a++, pa++) {
- pa->keys= NULL;
- pa->totkey= 0;
+ for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
+ pa->keys = NULL;
+ pa->totkey = 0;
}
psys->flag &= ~PSYS_KEYED;
@@ -4498,7 +4507,7 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
}
}
else if (psys->particles) {
- for (a=0, pa=psys->particles; a<psys->totpart; a++, pa++)
+ for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++)
pa->boid = NULL;
}
@@ -4522,8 +4531,8 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
psys->clmd->clothObject = NULL;
psys->clmd->hairdata = NULL;
- psys->clmd->sim_parms= newdataadr(fd, psys->clmd->sim_parms);
- psys->clmd->coll_parms= newdataadr(fd, psys->clmd->coll_parms);
+ psys->clmd->sim_parms = newdataadr(fd, psys->clmd->sim_parms);
+ psys->clmd->coll_parms = newdataadr(fd, psys->clmd->coll_parms);
if (psys->clmd->sim_parms) {
psys->clmd->sim_parms->effector_weights = NULL;
@@ -4721,7 +4730,7 @@ static void direct_link_customdata(FileData *fd, CustomData *data, int count)
static void direct_link_mesh(FileData *fd, Mesh *mesh)
{
- mesh->mat= newdataadr(fd, mesh->mat);
+ mesh->mat = newdataadr(fd, mesh->mat);
test_pointer_array(fd, (void **)&mesh->mat);
mesh->mvert = newdataadr(fd, mesh->mvert);
@@ -4761,7 +4770,7 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
}
/* Multires data */
- mesh->mr= newdataadr(fd, mesh->mr);
+ mesh->mr = newdataadr(fd, mesh->mr);
if (mesh->mr) {
MultiresLevel *lvl;
@@ -4783,7 +4792,7 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
* because some saved files either do not have a verts
* array, or the verts array contains out-of-date
* data. */
- if (mesh->totvert == ((MultiresLevel*)mesh->mr->levels.last)->totvert) {
+ if (mesh->totvert == ((MultiresLevel *)mesh->mr->levels.last)->totvert) {
if (mesh->mr->verts)
MEM_freeN(mesh->mr->verts);
mesh->mr->verts = MEM_dupallocN(mesh->mvert);
@@ -4836,7 +4845,7 @@ static void direct_link_latt(FileData *fd, Lattice *lt)
lt->def = newdataadr(fd, lt->def);
lt->dvert = newdataadr(fd, lt->dvert);
- direct_link_dverts(fd, lt->pntsu*lt->pntsv*lt->pntsw, lt->dvert);
+ direct_link_dverts(fd, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
lt->editlatt = NULL;
lt->batch_cache = NULL;
@@ -4967,11 +4976,11 @@ static void lib_link_object(FileData *fd, Main *main)
#else
MEM_freeN(ob->pose);
#endif
- ob->pose= NULL;
+ ob->pose = NULL;
ob->mode &= ~OB_MODE_POSE;
}
}
- for (a=0; a < ob->totcol; a++)
+ for (a = 0; a < ob->totcol; a++)
ob->mat[a] = newlibadr_us(fd, ob->id.lib, ob->mat[a]);
/* When the object is local and the data is library its possible
@@ -5071,7 +5080,7 @@ static void direct_link_pose(FileData *fd, bPose *pose)
pose->chanhash = NULL;
pose->chan_array = NULL;
- for (pchan = pose->chanbase.first; pchan; pchan=pchan->next) {
+ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
pchan->bone = NULL;
pchan->parent = newdataadr(fd, pchan->parent);
pchan->child = newdataadr(fd, pchan->child);
@@ -5110,7 +5119,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
link_list(fd, lb);
- for (md=lb->first; md; md=md->next) {
+ for (md = lb->first; md; md = md->next) {
md->error = NULL;
/* if modifiers disappear, or for upward compatibility */
@@ -5133,8 +5142,8 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
clmd->clothObject = NULL;
clmd->hairdata = NULL;
- clmd->sim_parms= newdataadr(fd, clmd->sim_parms);
- clmd->coll_parms= newdataadr(fd, clmd->coll_parms);
+ clmd->sim_parms = newdataadr(fd, clmd->sim_parms);
+ clmd->coll_parms = newdataadr(fd, clmd->coll_parms);
direct_link_pointcache_list(fd, &clmd->ptcaches, &clmd->point_cache, 0);
@@ -5147,7 +5156,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
clmd->sim_parms->effector_weights = newdataadr(fd, clmd->sim_parms->effector_weights);
if (!clmd->sim_parms->effector_weights) {
- clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL);
+ clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL);
}
}
@@ -5189,7 +5198,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
smd->domain->effector_weights = newdataadr(fd, smd->domain->effector_weights);
if (!smd->domain->effector_weights)
- smd->domain->effector_weights = BKE_add_effector_weights(NULL);
+ smd->domain->effector_weights = BKE_effector_add_weights(NULL);
direct_link_pointcache_list(fd, &(smd->domain->ptcaches[0]), &(smd->domain->point_cache[0]), 1);
@@ -5250,13 +5259,13 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
DynamicPaintSurface *surface;
link_list(fd, &pmd->canvas->surfaces);
- for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next) {
+ for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
surface->canvas = pmd->canvas;
surface->data = NULL;
direct_link_pointcache_list(fd, &(surface->ptcaches), &(surface->pointcache), 1);
if (!(surface->effector_weights = newdataadr(fd, surface->effector_weights)))
- surface->effector_weights = BKE_add_effector_weights(NULL);
+ surface->effector_weights = BKE_effector_add_weights(NULL);
}
}
}
@@ -5323,7 +5332,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
psmd->mesh_final = NULL;
psmd->mesh_original = NULL;
- psmd->psys= newdataadr(fd, psmd->psys);
+ psmd->psys = newdataadr(fd, psmd->psys);
psmd->flag &= ~eParticleSystemFlag_psys_updated;
psmd->flag |= eParticleSystemFlag_file_loaded;
}
@@ -5361,7 +5370,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
else if (md->type == eModifierType_Warp) {
WarpModifierData *tmd = (WarpModifierData *)md;
- tmd->curfalloff= newdataadr(fd, tmd->curfalloff);
+ tmd->curfalloff = newdataadr(fd, tmd->curfalloff);
if (tmd->curfalloff)
direct_link_curvemapping(fd, tmd->curfalloff);
}
@@ -5382,7 +5391,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
lmd->cache_system = NULL;
}
else if (md->type == eModifierType_CorrectiveSmooth) {
- CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData*)md;
+ CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
if (csmd->bind_coords) {
csmd->bind_coords = newdataadr(fd, csmd->bind_coords);
@@ -5415,14 +5424,20 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
if (smd->verts[i].binds[j].vert_inds)
- BLI_endian_switch_uint32_array(smd->verts[i].binds[j].vert_inds, smd->verts[i].binds[j].numverts);
+ BLI_endian_switch_uint32_array(
+ smd->verts[i].binds[j].vert_inds, smd->verts[i].binds[j].numverts);
if (smd->verts[i].binds[j].vert_weights) {
if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
smd->verts[i].binds[j].mode == MOD_SDEF_MODE_LOOPTRI)
- BLI_endian_switch_float_array(smd->verts[i].binds[j].vert_weights, 3);
- else
- BLI_endian_switch_float_array(smd->verts[i].binds[j].vert_weights, smd->verts[i].binds[j].numverts);
+ {
+ BLI_endian_switch_float_array(
+ smd->verts[i].binds[j].vert_weights, 3);
+ }
+ else {
+ BLI_endian_switch_float_array(
+ smd->verts[i].binds[j].vert_weights, smd->verts[i].binds[j].numverts);
+ }
}
}
}
@@ -5465,7 +5480,7 @@ static void direct_link_gpencil_modifiers(FileData *fd, ListBase *lb)
md->type = eModifierType_None;
if (md->type == eGpencilModifierType_Lattice) {
- LatticeGpencilModifierData *gpmd = (LatticeGpencilModifierData*)md;
+ LatticeGpencilModifierData *gpmd = (LatticeGpencilModifierData *)md;
gpmd->cache_data = NULL;
}
else if (md->type == eGpencilModifierType_Hook) {
@@ -5543,9 +5558,9 @@ static void direct_link_object(FileData *fd, Object *ob)
link_list(fd, &ob->constraintChannels);
// >>> XXX deprecated - old animation system
- ob->mat= newdataadr(fd, ob->mat);
+ ob->mat = newdataadr(fd, ob->mat);
test_pointer_array(fd, (void **)&ob->mat);
- ob->matbits= newdataadr(fd, ob->matbits);
+ ob->matbits = newdataadr(fd, ob->matbits);
/* do it here, below old data gets converted */
direct_link_modifiers(fd, &ob->modifiers);
@@ -5553,15 +5568,15 @@ static void direct_link_object(FileData *fd, Object *ob)
direct_link_shaderfxs(fd, &ob->shader_fx);
link_list(fd, &ob->effect);
- paf= ob->effect.first;
+ paf = ob->effect.first;
while (paf) {
if (paf->type == EFF_PARTICLE) {
paf->keys = NULL;
}
if (paf->type == EFF_WAVE) {
- WaveEff *wav = (WaveEff*) paf;
+ WaveEff *wav = (WaveEff *)paf;
PartEff *next = paf->next;
- WaveModifierData *wmd = (WaveModifierData*) modifier_new(eModifierType_Wave);
+ WaveModifierData *wmd = (WaveModifierData *)modifier_new(eModifierType_Wave);
wmd->damp = wav->damp;
wmd->flag = wav->flag;
@@ -5583,9 +5598,9 @@ static void direct_link_object(FileData *fd, Object *ob)
continue;
}
if (paf->type == EFF_BUILD) {
- BuildEff *baf = (BuildEff*) paf;
+ BuildEff *baf = (BuildEff *)paf;
PartEff *next = paf->next;
- BuildModifierData *bmd = (BuildModifierData*) modifier_new(eModifierType_Build);
+ BuildModifierData *bmd = (BuildModifierData *)modifier_new(eModifierType_Build);
bmd->start = baf->sfra;
bmd->length = baf->len;
@@ -5603,13 +5618,13 @@ static void direct_link_object(FileData *fd, Object *ob)
paf = paf->next;
}
- ob->pd= newdataadr(fd, ob->pd);
+ ob->pd = newdataadr(fd, ob->pd);
direct_link_partdeflect(ob->pd);
- ob->soft= newdataadr(fd, ob->soft);
+ ob->soft = newdataadr(fd, ob->soft);
if (ob->soft) {
SoftBody *sb = ob->soft;
- sb->bpoint = NULL; // init pointers so it gets rebuilt nicely
+ sb->bpoint = NULL; // init pointers so it gets rebuilt nicely
sb->bspring = NULL;
sb->scratch = NULL;
/* although not used anymore */
@@ -5625,7 +5640,7 @@ static void direct_link_object(FileData *fd, Object *ob)
sb->effector_weights = newdataadr(fd, sb->effector_weights);
if (!sb->effector_weights)
- sb->effector_weights = BKE_add_effector_weights(NULL);
+ sb->effector_weights = BKE_effector_add_weights(NULL);
sb->shared = newdataadr(fd, sb->shared);
if (sb->shared == NULL) {
@@ -5640,7 +5655,7 @@ static void direct_link_object(FileData *fd, Object *ob)
direct_link_pointcache_list(fd, &sb->shared->ptcaches, &sb->shared->pointcache, false);
}
}
- ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */
+ ob->fluidsimSettings = newdataadr(fd, ob->fluidsimSettings); /* NT */
ob->rigidbody_object = newdataadr(fd, ob->rigidbody_object);
if (ob->rigidbody_object) {
@@ -5662,7 +5677,7 @@ static void direct_link_object(FileData *fd, Object *ob)
ObHook *hook = ob->hooks.first;
HookModifierData *hmd = (HookModifierData *)modifier_new(eModifierType_Hook);
- hook->indexar= newdataadr(fd, hook->indexar);
+ hook->indexar = newdataadr(fd, hook->indexar);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
BLI_endian_switch_int32_array(hook->indexar, hook->totindex);
}
@@ -5682,7 +5697,7 @@ static void direct_link_object(FileData *fd, Object *ob)
BLI_addhead(&ob->modifiers, hmd);
BLI_remlink(&ob->hooks, hook);
- modifier_unique_name(&ob->modifiers, (ModifierData*)hmd);
+ modifier_unique_name(&ob->modifiers, (ModifierData *)hmd);
MEM_freeN(hook);
}
@@ -5692,7 +5707,6 @@ static void direct_link_object(FileData *fd, Object *ob)
BKE_object_empty_draw_type_set(ob, ob->empty_drawtype);
}
- ob->customdata_mask = 0;
ob->bb = NULL;
ob->derivedDeform = NULL;
ob->derivedFinal = NULL;
@@ -5925,7 +5939,7 @@ static void composite_patch(bNodeTree *ntree, Scene *scene)
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
- if (node->id==NULL && node->type == CMP_NODE_R_LAYERS)
+ if (node->id == NULL && node->type == CMP_NODE_R_LAYERS)
node->id = &scene->id;
}
}
@@ -5969,7 +5983,7 @@ static void direct_link_lightcache_texture(FileData *fd, LightCacheTexture *lcte
BLI_endian_switch_float_array((float *)lctex->data, data_size * sizeof(float));
}
else if (lctex->data_type == LIGHTCACHETEX_UINT) {
- BLI_endian_switch_uint32_array((unsigned int *)lctex->data, data_size * sizeof(unsigned int));
+ BLI_endian_switch_uint32_array((uint *)lctex->data, data_size * sizeof(uint));
}
}
}
@@ -6051,7 +6065,7 @@ static void lib_link_scene(FileData *fd, Main *main)
if (sce->toolsettings->sculpt)
sce->toolsettings->sculpt->gravity_object =
- newlibadr(fd, sce->id.lib, sce->toolsettings->sculpt->gravity_object);
+ newlibadr(fd, sce->id.lib, sce->toolsettings->sculpt->gravity_object);
if (sce->toolsettings->imapaint.stencil)
sce->toolsettings->imapaint.stencil =
@@ -6119,8 +6133,7 @@ static void lib_link_scene(FileData *fd, Main *main)
BLI_listbase_clear(&seq->anims);
lib_link_sequence_modifiers(fd, sce, &seq->modifiers);
- }
- SEQ_END
+ } SEQ_END;
for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) {
if (marker->camera) {
@@ -6176,6 +6189,10 @@ static void lib_link_scene(FileData *fd, Main *main)
lib_link_view_layer(fd, sce->id.lib, view_layer);
}
+ if (sce->r.bake.cage_object) {
+ sce->r.bake.cage_object = newlibadr(fd, sce->id.lib, sce->r.bake.cage_object);
+ }
+
#ifdef USE_SETSCENE_CHECK
if (sce->set != NULL) {
/* link flag for scenes with set would be reset later,
@@ -6263,12 +6280,12 @@ static void direct_link_sequence_modifiers(FileData *fd, ListBase *lb)
smd->mask_sequence = newdataadr(fd, smd->mask_sequence);
if (smd->type == seqModifierType_Curves) {
- CurvesModifierData *cmd = (CurvesModifierData *) smd;
+ CurvesModifierData *cmd = (CurvesModifierData *)smd;
direct_link_curvemapping(fd, &cmd->curve_mapping);
}
else if (smd->type == seqModifierType_HueCorrect) {
- HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd;
+ HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
direct_link_curvemapping(fd, &hcmd->curve_mapping);
}
@@ -6303,13 +6320,13 @@ static void direct_link_scene(FileData *fd, Scene *sce)
sce->basact = newdataadr(fd, sce->basact);
- sce->toolsettings= newdataadr(fd, sce->toolsettings);
+ sce->toolsettings = newdataadr(fd, sce->toolsettings);
if (sce->toolsettings) {
- direct_link_paint_helper(fd, sce, (Paint**)&sce->toolsettings->sculpt);
- direct_link_paint_helper(fd, sce, (Paint**)&sce->toolsettings->vpaint);
- direct_link_paint_helper(fd, sce, (Paint**)&sce->toolsettings->wpaint);
- direct_link_paint_helper(fd, sce, (Paint**)&sce->toolsettings->uvsculpt);
- direct_link_paint_helper(fd, sce, (Paint**)&sce->toolsettings->gp_paint);
+ direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->sculpt);
+ direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->vpaint);
+ direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->wpaint);
+ direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->uvsculpt);
+ direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->gp_paint);
direct_link_paint(fd, sce, &sce->toolsettings->imapaint.paint);
@@ -6341,11 +6358,11 @@ static void direct_link_scene(FileData *fd, Scene *sce)
/* recursive link sequences, lb will be correctly initialized */
link_recurs_seq(fd, &ed->seqbase);
- SEQ_BEGIN (ed, seq)
+ SEQ_BEGIN(ed, seq)
{
- seq->seq1= newdataadr(fd, seq->seq1);
- seq->seq2= newdataadr(fd, seq->seq2);
- seq->seq3= newdataadr(fd, seq->seq3);
+ seq->seq1 = newdataadr(fd, seq->seq1);
+ seq->seq2 = newdataadr(fd, seq->seq2);
+ seq->seq3 = newdataadr(fd, seq->seq3);
/* a patch: after introduction of effects with 3 input strips */
if (seq->seq3 == NULL) seq->seq3 = seq->seq2;
@@ -6365,7 +6382,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
IDP_DirectLinkGroup_OrFree(&seq->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
seq->strip = newdataadr(fd, seq->strip);
- if (seq->strip && seq->strip->done==0) {
+ if (seq->strip && seq->strip->done == 0) {
seq->strip->done = true;
if (ELEM(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
@@ -6406,8 +6423,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
}
direct_link_sequence_modifiers(fd, &seq->modifiers);
- }
- SEQ_END
+ } SEQ_END;
/* link metastack, slight abuse of structs here, have to restore pointer to internal part in struct */
{
@@ -6433,11 +6449,11 @@ static void direct_link_scene(FileData *fd, Scene *sce)
/* stack */
link_list(fd, &(ed->metastack));
- for (ms = ed->metastack.first; ms; ms= ms->next) {
+ for (ms = ed->metastack.first; ms; ms = ms->next) {
ms->parseq = newdataadr(fd, ms->parseq);
if (ms->oldbasep == old_seqbasep)
- ms->oldbasep= &ed->seqbase;
+ ms->oldbasep = &ed->seqbase;
else {
poin = POINTER_OFFSET(ms->oldbasep, -offset);
poin = newdataadr(fd, poin);
@@ -6518,7 +6534,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
/* set effector weights */
rbw->effector_weights = newdataadr(fd, rbw->effector_weights);
if (!rbw->effector_weights)
- rbw->effector_weights = BKE_add_effector_weights(NULL);
+ rbw->effector_weights = BKE_effector_add_weights(NULL);
}
sce->preview = direct_link_preview_image(fd, sce->preview);
@@ -6552,9 +6568,9 @@ static void direct_link_scene(FileData *fd, Scene *sce)
else sce->eevee.light_cache = NULL;
}
else {
- /* else read the cache from file. */
+ /* else try to read the cache from file. */
+ sce->eevee.light_cache = newdataadr(fd, sce->eevee.light_cache);
if (sce->eevee.light_cache) {
- sce->eevee.light_cache = newdataadr(fd, sce->eevee.light_cache);
direct_link_lightcache(fd, sce->eevee.light_cache);
}
}
@@ -6740,10 +6756,12 @@ static void direct_link_area(FileData *fd, ScrArea *area)
link_list(fd, &(area->regionbase));
BLI_listbase_clear(&area->handlers);
- area->type = NULL; /* spacetype callbacks */
+ area->type = NULL; /* spacetype callbacks */
area->butspacetype = SPACE_EMPTY; /* Should always be unset so that rna_Area_type_get works correctly */
area->region_active_win = -1;
+ area->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE;
+
area->global = newdataadr(fd, area->global);
/* if we do not have the spacetype registered we cannot
@@ -6760,8 +6778,8 @@ static void direct_link_area(FileData *fd, ScrArea *area)
/* accident can happen when read/save new file with older version */
/* 2.50: we now always add spacedata for info */
if (area->spacedata.first == NULL) {
- SpaceInfo *sinfo= MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
- area->spacetype= sinfo->spacetype= SPACE_INFO;
+ SpaceInfo *sinfo = MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
+ area->spacetype = sinfo->spacetype = SPACE_INFO;
BLI_addtail(&area->spacedata, sinfo);
}
/* add local view3d too */
@@ -6781,7 +6799,7 @@ static void direct_link_area(FileData *fd, ScrArea *area)
direct_link_region(fd, ar, sl->spacetype);
if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d= (View3D*) sl;
+ View3D *v3d = (View3D *)sl;
v3d->flag |= V3D_INVALID_BACKBUF;
@@ -6809,7 +6827,7 @@ static void direct_link_area(FileData *fd, ScrArea *area)
SpaceIpo *sipo = (SpaceIpo *)sl;
sipo->ads = newdataadr(fd, sipo->ads);
- BLI_listbase_clear(&sipo->ghostCurves);
+ BLI_listbase_clear(&sipo->runtime.ghost_curves);
}
else if (sl->spacetype == SPACE_NLA) {
SpaceNla *snla = (SpaceNla *)sl;
@@ -6817,7 +6835,7 @@ static void direct_link_area(FileData *fd, ScrArea *area)
snla->ads = newdataadr(fd, snla->ads);
}
else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOops *soops = (SpaceOops *) sl;
+ SpaceOops *soops = (SpaceOops *)sl;
/* use newdataadr_no_us and do not free old memory avoiding double
* frees and use of freed memory. this could happen because of a
@@ -6838,10 +6856,10 @@ static void direct_link_area(FileData *fd, ScrArea *area)
}
}
/* we only saved what was used */
- soops->storeflag |= SO_TREESTORE_CLEANUP; // at first draw
+ soops->storeflag |= SO_TREESTORE_CLEANUP; // at first draw
}
soops->treehash = NULL;
- soops->tree.first = soops->tree.last= NULL;
+ soops->tree.first = soops->tree.last = NULL;
}
else if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
@@ -6877,7 +6895,7 @@ static void direct_link_area(FileData *fd, ScrArea *area)
BLI_listbase_clear(&snode->linkdrag);
}
else if (sl->spacetype == SPACE_TEXT) {
- SpaceText *st= (SpaceText *)sl;
+ SpaceText *st = (SpaceText *)sl;
st->drawcache = NULL;
st->scroll_accum[0] = 0.0f;
@@ -6910,8 +6928,8 @@ static void direct_link_area(FileData *fd, ScrArea *area)
else if (sl->spacetype == SPACE_BUTS) {
SpaceButs *sbuts = (SpaceButs *)sl;
- sbuts->path= NULL;
- sbuts->texuser= NULL;
+ sbuts->path = NULL;
+ sbuts->texuser = NULL;
sbuts->mainbo = sbuts->mainb;
sbuts->mainbuser = sbuts->mainb;
}
@@ -6977,14 +6995,14 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
memset(&area->runtime, 0x0, sizeof(area->runtime));
- for (SpaceLink *sl = area->spacedata.first; sl; sl= sl->next) {
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
switch (sl->spacetype) {
case SPACE_VIEW3D:
{
- View3D *v3d = (View3D*) sl;
+ View3D *v3d = (View3D *)sl;
- v3d->camera= newlibadr(fd, parent_id->lib, v3d->camera);
- v3d->ob_centre= newlibadr(fd, parent_id->lib, v3d->ob_centre);
+ v3d->camera = newlibadr(fd, parent_id->lib, v3d->camera);
+ v3d->ob_centre = newlibadr(fd, parent_id->lib, v3d->ob_centre);
if (v3d->localvd) {
v3d->localvd->camera = newlibadr(fd, parent_id->lib, v3d->localvd->camera);
@@ -7051,8 +7069,8 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
}
case SPACE_NLA:
{
- SpaceNla *snla= (SpaceNla *)sl;
- bDopeSheet *ads= snla->ads;
+ SpaceNla *snla = (SpaceNla *)sl;
+ bDopeSheet *ads = snla->ads;
if (ads) {
ads->source = newlibadr(fd, parent_id->lib, ads->source);
@@ -7062,9 +7080,9 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
}
case SPACE_TEXT:
{
- SpaceText *st= (SpaceText *)sl;
+ SpaceText *st = (SpaceText *)sl;
- st->text= newlibadr(fd, parent_id->lib, st->text);
+ st->text = newlibadr(fd, parent_id->lib, st->text);
break;
}
case SPACE_SCRIPT:
@@ -7081,7 +7099,7 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
}
case SPACE_OUTLINER:
{
- SpaceOops *so= (SpaceOops *)sl;
+ SpaceOops *so = (SpaceOops *)sl;
so->search_tse.id = newlibadr(fd, NULL, so->search_tse.id);
if (so->treestore) {
@@ -7407,7 +7425,7 @@ static void lib_link_clipboard_restore(struct IDNameLib_Map *id_map)
BKE_sequencer_base_recursive_apply(&seqbase_clipboard, lib_link_seq_clipboard_cb, id_map);
}
-static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene)
+static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, ViewLayer *view_layer)
{
bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
@@ -7421,25 +7439,31 @@ static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene)
}
if (v3d->localvd) {
- /*Base *base;*/
+ Base *base = NULL;
v3d->localvd->camera = scene->camera;
- /* localview can become invalid during undo/redo steps, so we exit it when no could be found */
-#if 0 /* XXX regionlocalview ? */
- for (base= sc->scene->base.first; base; base= base->next) {
- if (base->lay & v3d->lay) break;
+ /* Localview can become invalid during undo/redo steps, so we exit it when no could be found. */
+ for (base = view_layer->object_bases.first; base; base = base->next) {
+ if (base->local_view_bits & v3d->local_view_uuid) {
+ break;
+ }
}
- if (base==NULL) {
- v3d->lay= v3d->localvd->lay;
- v3d->layact= v3d->localvd->layact;
+ if (base == NULL) {
MEM_freeN(v3d->localvd);
- v3d->localvd= NULL;
+ v3d->localvd = NULL;
+ v3d->local_view_uuid = 0;
+
+ for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ RegionView3D *rv3d = ar->regiondata;
+ if (rv3d->localvd) {
+ MEM_freeN(rv3d->localvd);
+ rv3d->localvd = NULL;
+ }
+ }
+ }
}
-#endif
- }
- else if (v3d->scenelock) {
- v3d->lay = scene->lay;
}
}
}
@@ -7461,9 +7485,6 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main
v3d->camera = restore_pointer_by_name(id_map, (ID *)v3d->camera, USER_REAL);
v3d->ob_centre = restore_pointer_by_name(id_map, (ID *)v3d->ob_centre, USER_REAL);
- /* not very nice, but could help */
- if ((v3d->layact & v3d->lay) == 0) v3d->layact = v3d->lay;
-
/* free render engines for now */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
@@ -7489,7 +7510,7 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main
/* force recalc of list of channels (i.e. includes calculating F-Curve colors)
* thus preventing the "black curves" problem post-undo
*/
- sipo->flag |= SIPO_TEMP_NEEDCHANSYNC;
+ sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR;
}
else if (sl->spacetype == SPACE_BUTS) {
SpaceButs *sbuts = (SpaceButs *)sl;
@@ -7520,7 +7541,7 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main
/* force recalc of list of channels, potentially updating the active action
* while we're at it (as it can only be updated that way) [#28962]
*/
- saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
}
else if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
@@ -7582,7 +7603,7 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main
}
}
else if (sl->spacetype == SPACE_OUTLINER) {
- SpaceOops *so= (SpaceOops *)sl;
+ SpaceOops *so = (SpaceOops *)sl;
so->search_tse.id = restore_pointer_by_name(id_map, so->search_tse.id, USER_IGNORE);
@@ -7607,7 +7628,7 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main
}
}
else if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode= (SpaceNode *)sl;
+ SpaceNode *snode = (SpaceNode *)sl;
bNodeTreePath *path, *path_next;
bNodeTree *ntree;
@@ -7624,7 +7645,7 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, Main
path->nodetree = snode->nodetree;
}
else
- path->nodetree= restore_pointer_by_name(id_map, (ID*)path->nodetree, USER_REAL);
+ path->nodetree = restore_pointer_by_name(id_map, (ID *)path->nodetree, USER_REAL);
if (!path->nodetree)
break;
@@ -7695,7 +7716,7 @@ void blo_lib_link_restore(Main *newmain, wmWindowManager *curwm, Scene *curscene
/* keep cursor location through undo */
copy_v3_v3(win->scene->cursor.location, oldscene->cursor.location);
copy_qt_qt(win->scene->cursor.rotation, oldscene->cursor.rotation);
- lib_link_window_scene_data_restore(win, win->scene);
+ lib_link_window_scene_data_restore(win, win->scene, cur_view_layer);
BLI_assert(win->screen == NULL);
}
@@ -7713,7 +7734,7 @@ void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions)
ARegion *ar;
for (ar = regions->first; ar; ar = ar->next) {
- if (ar->regiontype==RGN_TYPE_WINDOW && ar->regiondata==NULL) {
+ if (ar->regiontype == RGN_TYPE_WINDOW && ar->regiondata == NULL) {
RegionView3D *rv3d;
rv3d = ar->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch");
@@ -7734,7 +7755,7 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
{
bool wrong_id = false;
- sc->regionbase.first = sc->regionbase.last= NULL;
+ sc->regionbase.first = sc->regionbase.last = NULL;
sc->context = NULL;
sc->active_region = NULL;
@@ -7813,7 +7834,7 @@ static void fix_relpaths_library(const char *basepath, Main *main)
Library *lib;
/* BLO_read_from_memory uses a blank filename */
if (basepath == NULL || basepath[0] == '\0') {
- for (lib = main->library.first; lib; lib= lib->id.next) {
+ for (lib = main->library.first; lib; lib = lib->id.next) {
/* when loading a linked lib into a file which has not been saved,
* there is nothing we can be relative to, so instead we need to make
* it absolute. This can happen when appending an object with a relative
@@ -7978,7 +7999,7 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip)
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *object;
- clip->adt= newdataadr(fd, clip->adt);
+ clip->adt = newdataadr(fd, clip->adt);
if (fd->movieclipmap) clip->cache = newmclipadr(fd, clip->cache);
else clip->cache = NULL;
@@ -8165,31 +8186,31 @@ static void lib_link_linestyle(FileData *fd, Main *main)
for (m = linestyle->color_modifiers.first; m; m = m->next) {
switch (m->type) {
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- {
- LineStyleColorModifier_DistanceFromObject *cm = (LineStyleColorModifier_DistanceFromObject *)m;
- cm->target = newlibadr(fd, linestyle->id.lib, cm->target);
- }
+ {
+ LineStyleColorModifier_DistanceFromObject *cm = (LineStyleColorModifier_DistanceFromObject *)m;
+ cm->target = newlibadr(fd, linestyle->id.lib, cm->target);
break;
+ }
}
}
for (m = linestyle->alpha_modifiers.first; m; m = m->next) {
switch (m->type) {
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- {
- LineStyleAlphaModifier_DistanceFromObject *am = (LineStyleAlphaModifier_DistanceFromObject *)m;
- am->target = newlibadr(fd, linestyle->id.lib, am->target);
- }
+ {
+ LineStyleAlphaModifier_DistanceFromObject *am = (LineStyleAlphaModifier_DistanceFromObject *)m;
+ am->target = newlibadr(fd, linestyle->id.lib, am->target);
break;
+ }
}
}
for (m = linestyle->thickness_modifiers.first; m; m = m->next) {
switch (m->type) {
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- {
- LineStyleThicknessModifier_DistanceFromObject *tm = (LineStyleThicknessModifier_DistanceFromObject *)m;
- tm->target = newlibadr(fd, linestyle->id.lib, tm->target);
- }
+ {
+ LineStyleThicknessModifier_DistanceFromObject *tm = (LineStyleThicknessModifier_DistanceFromObject *)m;
+ tm->target = newlibadr(fd, linestyle->id.lib, tm->target);
break;
+ }
}
}
for (int a = 0; a < MAX_MTEX; a++) {
@@ -8213,53 +8234,53 @@ static void direct_link_linestyle_color_modifier(FileData *fd, LineStyleModifier
{
switch (modifier->type) {
case LS_MODIFIER_ALONG_STROKE:
- {
- LineStyleColorModifier_AlongStroke *m = (LineStyleColorModifier_AlongStroke *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- }
+ {
+ LineStyleColorModifier_AlongStroke *m = (LineStyleColorModifier_AlongStroke *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
break;
+ }
case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- {
- LineStyleColorModifier_DistanceFromCamera *m = (LineStyleColorModifier_DistanceFromCamera *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- }
+ {
+ LineStyleColorModifier_DistanceFromCamera *m = (LineStyleColorModifier_DistanceFromCamera *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
break;
+ }
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- {
- LineStyleColorModifier_DistanceFromObject *m = (LineStyleColorModifier_DistanceFromObject *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- }
+ {
+ LineStyleColorModifier_DistanceFromObject *m = (LineStyleColorModifier_DistanceFromObject *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
break;
+ }
case LS_MODIFIER_MATERIAL:
- {
- LineStyleColorModifier_Material *m = (LineStyleColorModifier_Material *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- }
+ {
+ LineStyleColorModifier_Material *m = (LineStyleColorModifier_Material *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
break;
+ }
case LS_MODIFIER_TANGENT:
- {
- LineStyleColorModifier_Tangent *m = (LineStyleColorModifier_Tangent *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- }
+ {
+ LineStyleColorModifier_Tangent *m = (LineStyleColorModifier_Tangent *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
break;
+ }
case LS_MODIFIER_NOISE:
- {
- LineStyleColorModifier_Noise *m = (LineStyleColorModifier_Noise *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- }
+ {
+ LineStyleColorModifier_Noise *m = (LineStyleColorModifier_Noise *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
break;
+ }
case LS_MODIFIER_CREASE_ANGLE:
- {
- LineStyleColorModifier_CreaseAngle *m = (LineStyleColorModifier_CreaseAngle *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- }
+ {
+ LineStyleColorModifier_CreaseAngle *m = (LineStyleColorModifier_CreaseAngle *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
break;
+ }
case LS_MODIFIER_CURVATURE_3D:
- {
- LineStyleColorModifier_Curvature_3D *m = (LineStyleColorModifier_Curvature_3D *)modifier;
- m->color_ramp = newdataadr(fd, m->color_ramp);
- }
+ {
+ LineStyleColorModifier_Curvature_3D *m = (LineStyleColorModifier_Curvature_3D *)modifier;
+ m->color_ramp = newdataadr(fd, m->color_ramp);
break;
+ }
}
}
@@ -8267,61 +8288,61 @@ static void direct_link_linestyle_alpha_modifier(FileData *fd, LineStyleModifier
{
switch (modifier->type) {
case LS_MODIFIER_ALONG_STROKE:
- {
- LineStyleAlphaModifier_AlongStroke *m = (LineStyleAlphaModifier_AlongStroke *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleAlphaModifier_AlongStroke *m = (LineStyleAlphaModifier_AlongStroke *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- {
- LineStyleAlphaModifier_DistanceFromCamera *m = (LineStyleAlphaModifier_DistanceFromCamera *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleAlphaModifier_DistanceFromCamera *m = (LineStyleAlphaModifier_DistanceFromCamera *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- {
- LineStyleAlphaModifier_DistanceFromObject *m = (LineStyleAlphaModifier_DistanceFromObject *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleAlphaModifier_DistanceFromObject *m = (LineStyleAlphaModifier_DistanceFromObject *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_MATERIAL:
- {
- LineStyleAlphaModifier_Material *m = (LineStyleAlphaModifier_Material *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleAlphaModifier_Material *m = (LineStyleAlphaModifier_Material *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_TANGENT:
- {
- LineStyleAlphaModifier_Tangent *m = (LineStyleAlphaModifier_Tangent *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleAlphaModifier_Tangent *m = (LineStyleAlphaModifier_Tangent *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_NOISE:
- {
- LineStyleAlphaModifier_Noise *m = (LineStyleAlphaModifier_Noise *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleAlphaModifier_Noise *m = (LineStyleAlphaModifier_Noise *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_CREASE_ANGLE:
- {
- LineStyleAlphaModifier_CreaseAngle *m = (LineStyleAlphaModifier_CreaseAngle *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleAlphaModifier_CreaseAngle *m = (LineStyleAlphaModifier_CreaseAngle *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_CURVATURE_3D:
- {
- LineStyleAlphaModifier_Curvature_3D *m = (LineStyleAlphaModifier_Curvature_3D *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleAlphaModifier_Curvature_3D *m = (LineStyleAlphaModifier_Curvature_3D *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
}
}
@@ -8329,54 +8350,54 @@ static void direct_link_linestyle_thickness_modifier(FileData *fd, LineStyleModi
{
switch (modifier->type) {
case LS_MODIFIER_ALONG_STROKE:
- {
- LineStyleThicknessModifier_AlongStroke *m = (LineStyleThicknessModifier_AlongStroke *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleThicknessModifier_AlongStroke *m = (LineStyleThicknessModifier_AlongStroke *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- {
- LineStyleThicknessModifier_DistanceFromCamera *m = (LineStyleThicknessModifier_DistanceFromCamera *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleThicknessModifier_DistanceFromCamera *m = (LineStyleThicknessModifier_DistanceFromCamera *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- {
- LineStyleThicknessModifier_DistanceFromObject *m = (LineStyleThicknessModifier_DistanceFromObject *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleThicknessModifier_DistanceFromObject *m = (LineStyleThicknessModifier_DistanceFromObject *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_MATERIAL:
- {
- LineStyleThicknessModifier_Material *m = (LineStyleThicknessModifier_Material *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleThicknessModifier_Material *m = (LineStyleThicknessModifier_Material *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_TANGENT:
- {
- LineStyleThicknessModifier_Tangent *m = (LineStyleThicknessModifier_Tangent *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleThicknessModifier_Tangent *m = (LineStyleThicknessModifier_Tangent *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_CREASE_ANGLE:
- {
- LineStyleThicknessModifier_CreaseAngle *m = (LineStyleThicknessModifier_CreaseAngle *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleThicknessModifier_CreaseAngle *m = (LineStyleThicknessModifier_CreaseAngle *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
case LS_MODIFIER_CURVATURE_3D:
- {
- LineStyleThicknessModifier_Curvature_3D *m = (LineStyleThicknessModifier_Curvature_3D *)modifier;
- m->curve = newdataadr(fd, m->curve);
- direct_link_curvemapping(fd, m->curve);
- }
+ {
+ LineStyleThicknessModifier_Curvature_3D *m = (LineStyleThicknessModifier_Curvature_3D *)modifier;
+ m->curve = newdataadr(fd, m->curve);
+ direct_link_curvemapping(fd, m->curve);
break;
+ }
}
}
@@ -8389,7 +8410,7 @@ static void direct_link_linestyle(FileData *fd, FreestyleLineStyle *linestyle)
int a;
LineStyleModifier *modifier;
- linestyle->adt= newdataadr(fd, linestyle->adt);
+ linestyle->adt = newdataadr(fd, linestyle->adt);
direct_link_animdata(fd, linestyle->adt);
link_list(fd, &linestyle->color_modifiers);
for (modifier = linestyle->color_modifiers.first; modifier; modifier = modifier->next)
@@ -8464,13 +8485,13 @@ static BHead *read_data_into_oldnewmap(FileData *fd, BHead *bhead, const char *a
{
bhead = blo_nextbhead(fd, bhead);
- while (bhead && bhead->code==DATA) {
+ while (bhead && bhead->code == DATA) {
void *data;
#if 0
/* XXX DUMB DEBUGGING OPTION TO GIVE NAMES for guarded malloc errors */
short *sp = fd->filesdna->structs[bhead->SDNAnr];
char *tmp = malloc(100);
- allocname = fd->filesdna->types[ sp[0] ];
+ allocname = fd->filesdna->types[sp[0]];
strcpy(tmp, allocname);
data = read_struct(fd, bhead, tmp);
#else
@@ -8557,7 +8578,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short
/* do after read_struct, for dna reconstruct */
lb = which_libbase(main, idcode);
if (lb) {
- oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code); /* for ID_ID check */
+ oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code); /* for ID_ID check */
BLI_addtail(lb, id);
}
else {
@@ -8672,19 +8693,19 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short
direct_link_collection(fd, (Collection *)id);
break;
case ID_AR:
- direct_link_armature(fd, (bArmature*)id);
+ direct_link_armature(fd, (bArmature *)id);
break;
case ID_AC:
- direct_link_action(fd, (bAction*)id);
+ direct_link_action(fd, (bAction *)id);
break;
case ID_NT:
- direct_link_nodetree(fd, (bNodeTree*)id);
+ direct_link_nodetree(fd, (bNodeTree *)id);
break;
case ID_BR:
- direct_link_brush(fd, (Brush*)id);
+ direct_link_brush(fd, (Brush *)id);
break;
case ID_PA:
- direct_link_particlesettings(fd, (ParticleSettings*)id);
+ direct_link_particlesettings(fd, (ParticleSettings *)id);
break;
case ID_GD:
direct_link_gpencil(fd, (bGPdata *)id);
@@ -8742,7 +8763,7 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
/* error in 2.65 and older: main->name was not set if you save from startup (not after loading file) */
if (bfd->filename[0] == 0) {
if (fd->fileversion < 265 || (fd->fileversion == 265 && fg->subversion < 1))
- if ((G.fileflags & G_FILE_RECOVER)==0)
+ if ((G.fileflags & G_FILE_RECOVER) == 0)
BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
/* early 2.50 version patch - filename not in FileGlobal struct at all */
@@ -8922,7 +8943,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
wmKeyMapDiffItem *kmdi;
bAddon *addon;
- bfd->user = user= read_struct(fd, bhead, "user def");
+ bfd->user = user = read_struct(fd, bhead, "user def");
/* User struct has separate do-version handling */
user->versionfile = bfd->main->versionfile;
@@ -8938,17 +8959,17 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
link_list(fd, &user->addons);
link_list(fd, &user->autoexec_paths);
- for (keymap=user->user_keymaps.first; keymap; keymap=keymap->next) {
- keymap->modal_items= NULL;
+ for (keymap = user->user_keymaps.first; keymap; keymap = keymap->next) {
+ keymap->modal_items = NULL;
keymap->poll = NULL;
keymap->flag &= ~KEYMAP_UPDATE;
link_list(fd, &keymap->diff_items);
link_list(fd, &keymap->items);
- for (kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
- kmdi->remove_item= newdataadr(fd, kmdi->remove_item);
- kmdi->add_item= newdataadr(fd, kmdi->add_item);
+ for (kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
+ kmdi->remove_item = newdataadr(fd, kmdi->remove_item);
+ kmdi->add_item = newdataadr(fd, kmdi->add_item);
if (kmdi->remove_item)
direct_link_keymapitem(fd, kmdi->remove_item);
@@ -8956,7 +8977,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
direct_link_keymapitem(fd, kmdi->add_item);
}
- for (kmi=keymap->items.first; kmi; kmi=kmi->next)
+ for (kmi = keymap->items.first; kmi; kmi = kmi->next)
direct_link_keymapitem(fd, kmi);
}
@@ -8982,7 +9003,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
}
// XXX
- user->uifonts.first = user->uifonts.last= NULL;
+ user->uifonts.first = user->uifonts.last = NULL;
link_list(fd, &user->uistyles);
@@ -9069,7 +9090,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
bhead = read_libblock(fd, mainlist.last, bhead, LIB_TAG_READ | LIB_TAG_EXTERN, NULL);
}
break;
- /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
+ /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
case ID_SCRN:
bhead->code = ID_SCR;
/* pass on to default */
@@ -9120,7 +9141,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
lib_verify_nodetree(bfd->main, true);
fix_relpaths_library(fd->relabase, bfd->main); /* make all relative paths, relative to the open blend file */
- link_global(fd, bfd); /* as last */
+ link_global(fd, bfd); /* as last */
fd->mainlist = NULL; /* Safety, this is local variable, shall not be used afterward. */
@@ -9136,7 +9157,7 @@ struct BHeadSort {
static int verg_bheadsort(const void *v1, const void *v2)
{
- const struct BHeadSort *x1=v1, *x2=v2;
+ const struct BHeadSort *x1 = v1, *x2 = v2;
if (x1->old > x2->old) return 1;
else if (x1->old < x2->old) return -1;
@@ -9199,7 +9220,7 @@ static BHead *find_bhead(FileData *fd, void *old)
return bhs->bhead;
#if 0
- for (bhead = blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) {
+ for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
if (bhead->old == old)
return bhead;
}
@@ -9249,7 +9270,7 @@ static BHead *find_bhead_from_idname(FileData *fd, const char *idname)
static ID *is_yet_read(FileData *fd, Main *mainvar, BHead *bhead)
{
- const char *idname= bhead_id_name(fd, bhead);
+ const char *idname = bhead_id_name(fd, bhead);
/* which_libbase can be NULL, intentionally not using idname+2 */
return BLI_findstring(which_libbase(mainvar, GS(idname)), idname, offsetof(ID, name));
}
@@ -9264,14 +9285,14 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
if (bhead) {
/* from another library? */
if (bhead->code == ID_ID) {
- BHead *bheadlib= find_previous_lib(fd, bhead);
+ BHead *bheadlib = find_previous_lib(fd, bhead);
if (bheadlib) {
Library *lib = read_struct(fd, bheadlib, "Library");
Main *ptr = blo_find_main(fd, lib->name, fd->relabase);
if (ptr->curlib == NULL) {
- const char *idname= bhead_id_name(fd, bhead);
+ const char *idname = bhead_id_name(fd, bhead);
blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB: Data refers to main .blend file: '%s' from %s"),
idname, mainvar->curlib->filepath);
@@ -9421,12 +9442,12 @@ static void expand_fcurves(FileData *fd, Main *mainvar, ListBase *list)
DriverVar *dvar;
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
- DRIVER_TARGETS_LOOPER(dvar)
+ DRIVER_TARGETS_LOOPER_BEGIN(dvar)
{
// TODO: only expand those that are going to get used?
expand_doit(fd, mainvar, dtar->id);
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
@@ -9440,7 +9461,7 @@ static void expand_action(FileData *fd, Main *mainvar, bAction *act)
bActionChannel *chan;
// XXX deprecated - old animation system --------------
- for (chan=act->chanbase.first; chan; chan=chan->next) {
+ for (chan = act->chanbase.first; chan; chan = chan->next) {
expand_doit(fd, mainvar, chan->ipo);
expand_constraint_channels(fd, mainvar, &chan->constraintChannels);
}
@@ -9473,7 +9494,7 @@ static void expand_animdata_nlastrips(FileData *fd, Main *mainvar, ListBase *lis
{
NlaStrip *strip;
- for (strip= list->first; strip; strip= strip->next) {
+ for (strip = list->first; strip; strip = strip->next) {
/* check child strips */
expand_animdata_nlastrips(fd, mainvar, &strip->strips);
@@ -9803,7 +9824,7 @@ static void expand_armature(FileData *fd, Main *mainvar, bArmature *arm)
static void expand_object_expandModifiers(
void *userData, Object *UNUSED(ob), ID **idpoin, int UNUSED(cb_flag))
{
- struct { FileData *fd; Main *mainvar; } *data= userData;
+ struct { FileData *fd; Main *mainvar; } *data = userData;
FileData *fd = data->fd;
Main *mainvar = data->mainvar;
@@ -9859,7 +9880,7 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
expand_constraint_channels(fd, mainvar, &ob->constraintChannels);
- for (strip=ob->nlastrips.first; strip; strip=strip->next) {
+ for (strip = ob->nlastrips.first; strip; strip = strip->next) {
expand_doit(fd, mainvar, strip->object);
expand_doit(fd, mainvar, strip->act);
expand_doit(fd, mainvar, strip->ipo);
@@ -9985,7 +10006,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
if (sce->ed) {
Sequence *seq;
- SEQ_BEGIN (sce->ed, seq)
+ SEQ_BEGIN(sce->ed, seq)
{
expand_idprops(fd, mainvar, seq->prop);
@@ -9994,8 +10015,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
if (seq->clip) expand_doit(fd, mainvar, seq->clip);
if (seq->mask) expand_doit(fd, mainvar, seq->mask);
if (seq->sound) expand_doit(fd, mainvar, seq->sound);
- }
- SEQ_END
+ } SEQ_END;
}
if (sce->rigidbody_world) {
@@ -10020,6 +10040,10 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
if (sce->master_collection) {
expand_collection(fd, mainvar, sce->master_collection);
}
+
+ if (sce->r.bake.cage_object) {
+ expand_doit(fd, mainvar, sce->r.bake.cage_object);
+ }
}
static void expand_camera(FileData *fd, Main *mainvar, Camera *ca)
@@ -10300,7 +10324,7 @@ static bool object_in_any_scene(Main *bmain, Object *ob)
}
static Collection *get_collection_active(
- Main *bmain, Scene *scene, ViewLayer *view_layer, const int flag)
+ Main *bmain, Scene *scene, ViewLayer *view_layer, const int flag)
{
if (flag & FILE_ACTIVE_COLLECTION) {
LayerCollection *lc = BKE_layer_collection_get_active(view_layer);
@@ -10383,7 +10407,7 @@ static void add_collections_to_scene(
}
BKE_scene_object_base_flag_sync_from_base(base);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
view_layer->basact = base;
/* Assign the collection. */
@@ -10539,7 +10563,7 @@ static ID *link_named_part_ex(
{
ID *id = link_named_part(mainl, fd, idcode, name, flag);
- if (id && (GS(id->name) == ID_OB)) { /* loose object: give a base */
+ if (id && (GS(id->name) == ID_OB)) { /* loose object: give a base */
link_object_postprocess(id, bmain, scene, view_layer, flag);
}
else if (id && (GS(id->name) == ID_GR)) {
@@ -10561,7 +10585,7 @@ static ID *link_named_part_ex(
*/
ID *BLO_library_link_named_part(Main *mainl, BlendHandle **bh, const short idcode, const char *name)
{
- FileData *fd = (FileData*)(*bh);
+ FileData *fd = (FileData *)(*bh);
return link_named_part(mainl, fd, idcode, name, 0);
}
@@ -10583,7 +10607,7 @@ ID *BLO_library_link_named_part_ex(
const short idcode, const char *name, const int flag,
Main *bmain, Scene *scene, ViewLayer *view_layer)
{
- FileData *fd = (FileData*)(*bh);
+ FileData *fd = (FileData *)(*bh);
return link_named_part_ex(mainl, fd, idcode, name, flag, bmain, scene, view_layer);
}
@@ -10666,7 +10690,7 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa
*/
Main *BLO_library_link_begin(Main *mainvar, BlendHandle **bh, const char *filepath)
{
- FileData *fd = (FileData*)(*bh);
+ FileData *fd = (FileData *)(*bh);
return library_link_begin(mainvar, &fd, filepath);
}
@@ -10786,9 +10810,9 @@ static void library_link_end(Main *mainl, FileData **fd, const short flag, Main
*/
void BLO_library_link_end(Main *mainl, BlendHandle **bh, int flag, Main *bmain, Scene *scene, ViewLayer *view_layer)
{
- FileData *fd = (FileData*)(*bh);
+ FileData *fd = (FileData *)(*bh);
library_link_end(mainl, &fd, flag, bmain, scene, view_layer);
- *bh = (BlendHandle*)fd;
+ *bh = (BlendHandle *)fd;
}
void *BLO_library_read_struct(FileData *fd, BHead *bh, const char *blockname)
@@ -10832,7 +10856,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
do_it = false;
/* test 1: read libdata */
- mainptr= mainl->next;
+ mainptr = mainl->next;
while (mainptr) {
if (mainvar_id_tag_any_check(mainptr, LIB_TAG_READ)) {
// printf("found LIB_TAG_READ %s (%s)\n", mainptr->curlib->id.name, mainptr->curlib->name);
@@ -10905,7 +10929,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
fd->libmap = oldnewmap_new();
mainptr->curlib->filedata = fd;
- mainptr->versionfile= fd->fileversion;
+ mainptr->versionfile = fd->fileversion;
/* subversion */
read_file_version(fd, mainptr);
@@ -10976,34 +11000,6 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
BLI_ghash_free(loaded_ids, NULL, NULL);
loaded_ids = NULL;
- /* test if there are unread libblocks */
- /* XXX This code block is kept for 2.77, until we are sure it never gets reached anymore. Can be removed later. */
- for (mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
- a = set_listbasepointers(mainptr, lbarray);
- while (a--) {
- ID *id, *idn = NULL;
-
- for (id = lbarray[a]->first; id; id = idn) {
- idn = id->next;
- if (id->tag & LIB_TAG_READ) {
- BLI_assert(0);
- BLI_remlink(lbarray[a], id);
- blo_reportf_wrap(
- basefd->reports, RPT_ERROR,
- TIP_("LIB: %s: '%s' unread lib block missing from '%s', parent '%s' - "
- "Please file a bug report if you see this message"),
- BKE_idcode_to_name(GS(id->name)),
- id->name + 2,
- mainptr->curlib->filepath,
- library_parent_filepath(mainptr->curlib));
- change_idid_adr(mainlist, basefd, id, NULL);
-
- MEM_freeN(id);
- }
- }
- }
- }
-
/* do versions, link, and free */
Main *main_newid = BKE_main_new();
for (mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c
index 5ceab1ca2cc..8ee40da13c7 100644
--- a/source/blender/blenloader/intern/undofile.c
+++ b/source/blender/blenloader/intern/undofile.c
@@ -98,7 +98,7 @@ void BLO_memfile_merge(MemFile *first, MemFile *second)
}
void memfile_chunk_add(
- MemFile *memfile, const char *buf, unsigned int size,
+ MemFile *memfile, const char *buf, uint size,
MemFileChunk **compchunk_step)
{
MemFileChunk *curchunk = MEM_mallocN(sizeof(MemFileChunk), "MemFileChunk");
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index ff56875e8fd..54e1512c953 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -106,11 +106,11 @@ static void area_add_header_region(ScrArea *sa, ListBase *lb)
/* initialize view2d data for header region, to allow panning */
/* is copy from ui_view2d.c */
- ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
+ ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
ar->v2d.keepofs = V2D_LOCKOFS_Y;
ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
- ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y;
- ar->v2d.flag = (V2D_PIXELOFS_X|V2D_PIXELOFS_Y);
+ ar->v2d.align = V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y;
+ ar->v2d.flag = (V2D_PIXELOFS_X | V2D_PIXELOFS_Y);
}
static void sequencer_init_preview_region(ARegion *ar)
@@ -149,7 +149,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
BLI_addtail(lb, ar);
ar->regiontype = RGN_TYPE_CHANNELS;
ar->alignment = RGN_ALIGN_LEFT;
- ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
/* for some reason, this doesn't seem to go auto like for NLA... */
ar = MEM_callocN(sizeof(ARegion), "area region from do_versions");
@@ -191,7 +191,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
BLI_addtail(lb, ar);
ar->regiontype = RGN_TYPE_UI;
ar->alignment = RGN_ALIGN_LEFT;
- ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
/* temporarily hide it */
ar->flag = RGN_FLAG_HIDDEN;
@@ -208,7 +208,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
ar->alignment = RGN_ALIGN_TOP;
break;
case SPACE_SEQ:
- ar_main = (ARegion*) lb->first;
+ ar_main = (ARegion *)lb->first;
for (; ar_main; ar_main = ar_main->next) {
if (ar_main->regiontype == RGN_TYPE_WINDOW)
break;
@@ -231,7 +231,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
BLI_addtail(lb, ar);
ar->regiontype = RGN_TYPE_TOOL_PROPS;
- ar->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
+ ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
ar->flag = RGN_FLAG_HIDDEN;
/* buttons/list view */
@@ -271,132 +271,132 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
break;
case SPACE_OUTLINER:
- {
- SpaceOops *soops = (SpaceOops *)sl;
+ {
+ SpaceOops *soops = (SpaceOops *)sl;
- memcpy(&ar->v2d, &soops->v2d, sizeof(View2D));
+ memcpy(&ar->v2d, &soops->v2d, sizeof(View2D));
- ar->v2d.scroll &= ~V2D_SCROLL_LEFT;
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
- ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
- ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPASPECT);
- ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
- ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
- //ar->v2d.flag |= V2D_IS_INITIALISED;
- }
+ ar->v2d.scroll &= ~V2D_SCROLL_LEFT;
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+ ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
+ ar->v2d.keepzoom |= (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_KEEPASPECT);
+ ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
+ ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
+ //ar->v2d.flag |= V2D_IS_INITIALISED;
break;
+ }
case SPACE_IPO:
- {
- SpaceIpo *sipo = (SpaceIpo *)sl;
- memcpy(&ar->v2d, &sipo->v2d, sizeof(View2D));
+ {
+ SpaceIpo *sipo = (SpaceIpo *)sl;
+ memcpy(&ar->v2d, &sipo->v2d, sizeof(View2D));
- /* init mainarea view2d */
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
+ /* init mainarea view2d */
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL);
- ar->v2d.min[0] = FLT_MIN;
- ar->v2d.min[1] = FLT_MIN;
+ ar->v2d.min[0] = FLT_MIN;
+ ar->v2d.min[1] = FLT_MIN;
- ar->v2d.max[0] = MAXFRAMEF;
- ar->v2d.max[1] = FLT_MAX;
+ ar->v2d.max[0] = MAXFRAMEF;
+ ar->v2d.max[1] = FLT_MAX;
- //ar->v2d.flag |= V2D_IS_INITIALISED;
- break;
- }
+ //ar->v2d.flag |= V2D_IS_INITIALISED;
+ break;
+ }
case SPACE_NLA:
- {
- SpaceNla *snla = (SpaceNla *)sl;
- memcpy(&ar->v2d, &snla->v2d, sizeof(View2D));
+ {
+ SpaceNla *snla = (SpaceNla *)sl;
+ memcpy(&ar->v2d, &snla->v2d, sizeof(View2D));
- ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
- ar->v2d.tot.ymax = 0.0f;
+ ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
+ ar->v2d.tot.ymax = 0.0f;
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
- ar->v2d.align = V2D_ALIGN_NO_POS_Y;
- ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
- break;
- }
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
+ ar->v2d.align = V2D_ALIGN_NO_POS_Y;
+ ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
+ break;
+ }
case SPACE_ACTION:
- {
- SpaceAction *saction = (SpaceAction *) sl;
-
- /* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */
- ar->v2d.tot.xmin = -20.0f;
- ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
- ar->v2d.tot.xmax = (float)((sa->winx > 120) ? (sa->winx) : 120);
- ar->v2d.tot.ymax = 0.0f;
-
- ar->v2d.cur = ar->v2d.tot;
-
- ar->v2d.min[0] = 0.0f;
- ar->v2d.min[1] = 0.0f;
-
- ar->v2d.max[0] = MAXFRAMEF;
- ar->v2d.max[1] = FLT_MAX;
-
- ar->v2d.minzoom = 0.01f;
- ar->v2d.maxzoom = 50;
- ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
- ar->v2d.keepzoom = V2D_LOCKZOOM_Y;
- ar->v2d.align = V2D_ALIGN_NO_POS_Y;
- ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
-
- /* for old files with ShapeKey editors open + an action set, clear the action as
- * it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit
- * only shows ShapeKey-rooted actions only)
- */
- if (saction->mode == SACTCONT_SHAPEKEY)
- saction->action = NULL;
- break;
- }
+ {
+ SpaceAction *saction = (SpaceAction *)sl;
+
+ /* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */
+ ar->v2d.tot.xmin = -20.0f;
+ ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
+ ar->v2d.tot.xmax = (float)((sa->winx > 120) ? (sa->winx) : 120);
+ ar->v2d.tot.ymax = 0.0f;
+
+ ar->v2d.cur = ar->v2d.tot;
+
+ ar->v2d.min[0] = 0.0f;
+ ar->v2d.min[1] = 0.0f;
+
+ ar->v2d.max[0] = MAXFRAMEF;
+ ar->v2d.max[1] = FLT_MAX;
+
+ ar->v2d.minzoom = 0.01f;
+ ar->v2d.maxzoom = 50;
+ ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
+ ar->v2d.keepzoom = V2D_LOCKZOOM_Y;
+ ar->v2d.align = V2D_ALIGN_NO_POS_Y;
+ ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
+
+ /* for old files with ShapeKey editors open + an action set, clear the action as
+ * it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit
+ * only shows ShapeKey-rooted actions only)
+ */
+ if (saction->mode == SACTCONT_SHAPEKEY)
+ saction->action = NULL;
+ break;
+ }
case SPACE_SEQ:
- {
- SpaceSeq *sseq = (SpaceSeq *)sl;
- memcpy(&ar->v2d, &sseq->v2d, sizeof(View2D));
+ {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+ memcpy(&ar->v2d, &sseq->v2d, sizeof(View2D));
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
- ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
- ar->v2d.flag |= V2D_IS_INITIALISED;
- break;
- }
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL);
+ ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
+ ar->v2d.flag |= V2D_IS_INITIALISED;
+ break;
+ }
case SPACE_NODE:
- {
- SpaceNode *snode = (SpaceNode *)sl;
- memcpy(&ar->v2d, &snode->v2d, sizeof(View2D));
+ {
+ SpaceNode *snode = (SpaceNode *)sl;
+ memcpy(&ar->v2d, &snode->v2d, sizeof(View2D));
- ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
- ar->v2d.keepzoom = V2D_LIMITZOOM|V2D_KEEPASPECT;
- break;
- }
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+ ar->v2d.keepzoom = V2D_LIMITZOOM | V2D_KEEPASPECT;
+ break;
+ }
case SPACE_BUTS:
- {
- SpaceButs *sbuts = (SpaceButs *)sl;
- memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D));
+ {
+ SpaceButs *sbuts = (SpaceButs *)sl;
+ memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D));
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
- break;
- }
+ ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+ break;
+ }
case SPACE_FILE:
- {
- // SpaceFile *sfile = (SpaceFile *)sl;
- ar->v2d.tot.xmin = ar->v2d.tot.ymin = 0;
- ar->v2d.tot.xmax = ar->winx;
- ar->v2d.tot.ymax = ar->winy;
- ar->v2d.cur = ar->v2d.tot;
- ar->regiontype = RGN_TYPE_WINDOW;
- ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
- ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
- ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
- break;
- }
+ {
+ // SpaceFile *sfile = (SpaceFile *)sl;
+ ar->v2d.tot.xmin = ar->v2d.tot.ymin = 0;
+ ar->v2d.tot.xmax = ar->winx;
+ ar->v2d.tot.ymax = ar->winy;
+ ar->v2d.cur = ar->v2d.tot;
+ ar->regiontype = RGN_TYPE_WINDOW;
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
+ ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
+ ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
+ break;
+ }
case SPACE_TEXT:
- {
- SpaceText *st = (SpaceText *)sl;
- st->flags |= ST_FIND_WRAP;
- }
+ {
+ SpaceText *st = (SpaceText *)sl;
+ st->flags |= ST_FIND_WRAP;
+ }
//case SPACE_XXX: // FIXME... add other ones
// memcpy(&ar->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D));
// break;
@@ -420,13 +420,13 @@ static void do_versions_windowmanager_2_50(bScreen *screen)
/* space imageselect is deprecated */
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_IMASEL)
- sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
+ sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
}
/* space sound is deprecated */
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_SOUND)
- sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
+ sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
}
/* pushed back spaces also need regions! */
@@ -446,7 +446,7 @@ static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name)
BLI_addtail(lb, id);
id->us = 1;
id->flag = LIB_FAKEUSER;
- *( (short *)id->name )= ID_GD;
+ *( (short *)id->name) = ID_GD;
new_id(lb, id, name);
/* alphabetic insertion: is in new_id */
@@ -464,29 +464,29 @@ static void do_versions_gpencil_2_50(Main *main, bScreen *screen)
for (sa = screen->areabase.first; sa; sa = sa->next) {
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D*) sl;
+ View3D *v3d = (View3D *)sl;
if (v3d->gpd) {
versions_gpencil_add_main(&main->gpencil, (ID *)v3d->gpd, "GPencil View3D");
v3d->gpd = NULL;
}
}
else if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *) sl;
+ SpaceNode *snode = (SpaceNode *)sl;
if (snode->gpd) {
versions_gpencil_add_main(&main->gpencil, (ID *)snode->gpd, "GPencil Node");
snode->gpd = NULL;
}
}
else if (sl->spacetype == SPACE_SEQ) {
- SpaceSeq *sseq = (SpaceSeq *) sl;
+ SpaceSeq *sseq = (SpaceSeq *)sl;
if (sseq->gpd) {
versions_gpencil_add_main(&main->gpencil, (ID *)sseq->gpd, "GPencil Node");
sseq->gpd = NULL;
}
}
else if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *) sl;
-#if 0 /* see comment on r28002 */
+ SpaceImage *sima = (SpaceImage *)sl;
+#if 0 /* see comment on r28002 */
if (sima->gpd) {
versions_gpencil_add_main(&main->gpencil, (ID *)sima->gpd, "GPencil Image");
sima->gpd = NULL;
@@ -508,7 +508,7 @@ static void do_version_mdef_250(Main *main)
for (ob = main->object.first; ob; ob = ob->id.next) {
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_MeshDeform) {
- mmd = (MeshDeformModifierData*) md;
+ mmd = (MeshDeformModifierData *)md;
if (mmd->bindcos) {
/* make bindcos NULL in order to trick older versions
@@ -577,14 +577,14 @@ static bNodeSocket *do_versions_node_group_add_socket_2_56_2(bNodeTree *ngroup,
gsock->link = NULL;
/* assign new unique index */
gsock->own_index = ngroup->cur_index++;
- gsock->limit = (in_out==SOCK_IN ? 0xFFF : 1);
+ gsock->limit = (in_out == SOCK_IN ? 0xFFF : 1);
// if (stype->value_structsize > 0)
// gsock->default_value = MEM_callocN(stype->value_structsize, "default socket value");
- BLI_addtail(in_out==SOCK_IN ? &ngroup->inputs : &ngroup->outputs, gsock);
+ BLI_addtail(in_out == SOCK_IN ? &ngroup->inputs : &ngroup->outputs, gsock);
- ngroup->update |= (in_out==SOCK_IN ? NTREE_UPDATE_GROUP_IN : NTREE_UPDATE_GROUP_OUT);
+ ngroup->update |= (in_out == SOCK_IN ? NTREE_UPDATE_GROUP_IN : NTREE_UPDATE_GROUP_OUT);
return gsock;
}
@@ -657,7 +657,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene->ed && scene->ed->seqbasep) {
- SEQ_BEGIN (scene->ed, seq)
+ SEQ_BEGIN(scene->ed, seq)
{
if (seq->type == SEQ_TYPE_SOUND_HD) {
char str[FILE_MAX];
@@ -669,14 +669,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
/* don't know, if anybody used that this way, but just in case, upgrade to new way... */
if ((seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) &&
- !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR))
+ !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR))
{
BLI_snprintf(seq->strip->proxy->dir, FILE_MAXDIR, "%s/BL_proxy", seq->strip->dir);
}
#undef SEQ_USE_PROXY_CUSTOM_DIR
#undef SEQ_USE_PROXY_CUSTOM_FILE
- }
- SEQ_END
+ } SEQ_END;
}
}
@@ -813,7 +812,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
ob->matbits = MEM_calloc_arrayN(ob->totcol, sizeof(char), "ob->matbits");
for (a = 0; a < ob->totcol; a++)
- ob->matbits[a] = (ob->colbits & (1<<a)) != 0;
+ ob->matbits[a] = (ob->colbits & (1 << a)) != 0;
}
}
@@ -862,7 +861,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (ob = bmain->object.first; ob; ob = ob->id.next) {
/* fluid-sim stuff */
- FluidsimModifierData *fluidmd = (FluidsimModifierData *) modifiers_findByType(ob, eModifierType_Fluidsim);
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
if (fluidmd)
fluidmd->fss->fmd = fluidmd;
@@ -896,7 +895,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
/* Assign proper global gravity weights for dynamics (only z-coordinate is taken into account) */
if (do_gravity) {
for (part = bmain->particle.first; part; part = part->id.next)
- part->effector_weights->global_gravity = part->acc[2]/-9.81f;
+ part->effector_weights->global_gravity = part->acc[2] / -9.81f;
}
for (ob = bmain->object.first; ob; ob = ob->id.next) {
@@ -904,13 +903,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
if (do_gravity) {
for (md = ob->modifiers.first; md; md = md->next) {
- ClothModifierData *clmd = (ClothModifierData *) modifiers_findByType(ob, eModifierType_Cloth);
+ ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
if (clmd)
- clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2]/-9.81f;
+ clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2] / -9.81f;
}
if (ob->soft)
- ob->soft->effector_weights->global_gravity = ob->soft->grav/9.81f;
+ ob->soft->effector_weights->global_gravity = ob->soft->grav / 9.81f;
}
/* Normal wind shape is plane */
@@ -974,7 +973,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (lt = bmain->latt.first; lt; lt = lt->id.next) {
if ((key = blo_do_versions_newlibadr(fd, lib, lt->key)) && key->refkey) {
data = key->refkey->data;
- tot = MIN2(lt->pntsu*lt->pntsv*lt->pntsw, key->refkey->totelem);
+ tot = MIN2(lt->pntsu * lt->pntsv * lt->pntsw, key->refkey->totelem);
for (a = 0; a < tot; a++, data += 3)
copy_v3_v3(lt->def[a].vec, data);
@@ -990,16 +989,16 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
BezTriple *bezt = nu->bezt;
for (a = 0; a < nu->pntsu; a++, bezt++) {
- copy_v3_v3(bezt->vec[0], data); data+=3;
- copy_v3_v3(bezt->vec[1], data); data+=3;
- copy_v3_v3(bezt->vec[2], data); data+=3;
+ copy_v3_v3(bezt->vec[0], data); data += 3;
+ copy_v3_v3(bezt->vec[1], data); data += 3;
+ copy_v3_v3(bezt->vec[2], data); data += 3;
bezt->alfa = *data; data++;
}
}
else if (nu->bp) {
BPoint *bp = nu->bp;
- for (a = 0; a < nu->pntsu*nu->pntsv; a++, bp++) {
+ for (a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
copy_v3_v3(bp->vec, data); data += 3;
bp->alfa = *data; data++;
}
@@ -1054,7 +1053,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (sa = screen->areabase.first; sa; sa = sa->next) {
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *) sl;
+ View3D *v3d = (View3D *)sl;
if (v3d->drawtype == OB_MATERIAL)
v3d->drawtype = OB_SOLID;
}
@@ -1117,7 +1116,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
multires_load_old_250(me);
for (ob = bmain->object.first; ob; ob = ob->id.next) {
- MultiresModifierData *mmd = (MultiresModifierData *) modifiers_findByType(ob, eModifierType_Multires);
+ MultiresModifierData *mmd = (MultiresModifierData *)modifiers_findByType(ob, eModifierType_Multires);
if (mmd) {
mmd->totlvl--;
@@ -1211,7 +1210,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
if (sseq->mainb == 0)
sseq->mainb = SEQ_DRAW_IMG_IMBUF;
- ar_main = (ARegion*)regionbase->first;
+ ar_main = (ARegion *)regionbase->first;
for (; ar_main; ar_main = ar_main->next) {
if (ar_main->regiontype == RGN_TYPE_WINDOW)
break;
@@ -1356,7 +1355,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
regionbase = &sl->regionbase;
if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_NLA)) {
- for (ar = (ARegion*) regionbase->first; ar; ar = ar->next) {
+ for (ar = (ARegion *)regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
ar->v2d.cur.ymax = ar->v2d.tot.ymax = 0.0f;
ar->v2d.cur.ymin = ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
@@ -1386,11 +1385,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0)
sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE
- SEQ_BEGIN (sce->ed, seq)
+ SEQ_BEGIN(sce->ed, seq)
{
seq->volume = 1.0f;
- }
- SEQ_END
+ } SEQ_END;
}
/* particle brush strength factor was changed from int to float */
@@ -1422,7 +1420,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
regionbase = &sl->regionbase;
}
- ar_preview = (ARegion*) regionbase->first;
+ ar_preview = (ARegion *)regionbase->first;
for (; ar_preview; ar_preview = ar_preview->next) {
if (ar_preview->regiontype == RGN_TYPE_PREVIEW)
break;
@@ -1437,7 +1435,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
} /* sequencer changes */
}
- if (bmain->versionfile <= 251) { /* 2.5.1 had no subversions */
+ if (bmain->versionfile <= 251) { /* 2.5.1 had no subversions */
bScreen *sc;
/* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_RENDER_OVERRIDE.
@@ -1474,7 +1472,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Fluidsim) {
- FluidsimModifierData *fmd = (FluidsimModifierData *) md;
+ FluidsimModifierData *fmd = (FluidsimModifierData *)md;
fmd->fss->flag |= OB_FLUIDSIM_ACTIVE;
fmd->fss->flag |= OB_FLUIDSIM_OVERRIDE_TIME;
}
@@ -1488,7 +1486,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
while (node) {
if (node->type == CMP_NODE_COLORBALANCE) {
- NodeColorBalance *n = (NodeColorBalance *) node->storage;
+ NodeColorBalance *n = (NodeColorBalance *)node->storage;
n->lift[0] += 1.f;
n->lift[1] += 1.f;
n->lift[2] += 1.f;
@@ -1503,7 +1501,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
while (node) {
if (node->type == CMP_NODE_COLORBALANCE) {
- NodeColorBalance *n = (NodeColorBalance *) node->storage;
+ NodeColorBalance *n = (NodeColorBalance *)node->storage;
n->lift[0] += 1.f;
n->lift[1] += 1.f;
n->lift[2] += 1.f;
@@ -1534,7 +1532,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *) sl;
+ SpaceImage *sima = (SpaceImage *)sl;
scopes_new(&sima->scopes);
}
}
@@ -1556,7 +1554,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_NODE) {
- SpaceNode *snode = (SpaceNode *) sl;
+ SpaceNode *snode = (SpaceNode *)sl;
ListBase *regionbase;
ARegion *ar;
@@ -1588,32 +1586,32 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
/* parent type to modifier */
for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->parent) {
- Object *parent = (Object *) blo_do_versions_newlibadr(fd, lib, ob->parent);
+ Object *parent = (Object *)blo_do_versions_newlibadr(fd, lib, ob->parent);
if (parent) { /* parent may not be in group */
if (parent->type == OB_ARMATURE && ob->partype == PARSKEL) {
ArmatureModifierData *amd;
- bArmature *arm = (bArmature *) blo_do_versions_newlibadr(fd, lib, parent->data);
+ bArmature *arm = (bArmature *)blo_do_versions_newlibadr(fd, lib, parent->data);
- amd = (ArmatureModifierData*) modifier_new(eModifierType_Armature);
+ amd = (ArmatureModifierData *)modifier_new(eModifierType_Armature);
amd->object = ob->parent;
- BLI_addtail((ListBase*)&ob->modifiers, amd);
+ BLI_addtail((ListBase *)&ob->modifiers, amd);
amd->deformflag = arm->deformflag;
ob->partype = PAROBJECT;
}
else if (parent->type == OB_LATTICE && ob->partype == PARSKEL) {
LatticeModifierData *lmd;
- lmd = (LatticeModifierData*) modifier_new(eModifierType_Lattice);
+ lmd = (LatticeModifierData *)modifier_new(eModifierType_Lattice);
lmd->object = ob->parent;
- BLI_addtail((ListBase*)&ob->modifiers, lmd);
+ BLI_addtail((ListBase *)&ob->modifiers, lmd);
ob->partype = PAROBJECT;
}
else if (parent->type == OB_CURVE && ob->partype == PARCURVE) {
CurveModifierData *cmd;
- cmd = (CurveModifierData*) modifier_new(eModifierType_Curve);
+ cmd = (CurveModifierData *)modifier_new(eModifierType_Curve);
cmd->object = ob->parent;
- BLI_addtail((ListBase*)&ob->modifiers, cmd);
+ BLI_addtail((ListBase *)&ob->modifiers, cmd);
ob->partype = PAROBJECT;
}
}
@@ -1624,8 +1622,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (scene = bmain->scene.first; scene; scene = scene->id.next) {
int i;
for (i = 0; i < 20; i++) {
- if (scene->lay & (1<<i)) {
- scene->layact = 1<<i;
+ if (scene->lay & (1 << i)) {
+ scene->layact = 1 << i;
break;
}
}
@@ -1648,13 +1646,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene) {
Sequence *seq;
- SEQ_BEGIN (scene->ed, seq)
+ SEQ_BEGIN(scene->ed, seq)
{
if (seq->sat == 0.0f) {
seq->sat = 1.0f;
}
- }
- SEQ_END
+ } SEQ_END;
}
}
@@ -1710,11 +1707,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
/* spacing was originally in pixels, convert it to percentage for new version
* size should not be zero due to sanity check above
*/
- brush->spacing = (int)(100 * ((float)brush->spacing) / ((float) brush->size));
+ brush->spacing = (int)(100 * ((float)brush->spacing) / ((float)brush->size));
if (brush->add_col[0] == 0 &&
- brush->add_col[1] == 0 &&
- brush->add_col[2] == 0)
+ brush->add_col[1] == 0 &&
+ brush->add_col[2] == 0)
{
brush->add_col[0] = 1.00f;
brush->add_col[1] = 0.39f;
@@ -1722,8 +1719,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
if (brush->sub_col[0] == 0 &&
- brush->sub_col[1] == 0 &&
- brush->sub_col[2] == 0)
+ brush->sub_col[1] == 0 &&
+ brush->sub_col[2] == 0)
{
brush->sub_col[0] = 0.39f;
brush->sub_col[1] = 0.39f;
@@ -1762,11 +1759,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
smd->domain->vorticity = 2.0f;
smd->domain->time_scale = 1.0f;
- if (!(smd->domain->flags & (1<<4)))
+ if (!(smd->domain->flags & (1 << 4)))
continue;
/* delete old MOD_SMOKE_INITVELOCITY flag */
- smd->domain->flags &= ~(1<<4);
+ smd->domain->flags &= ~(1 << 4);
/* for now just add it to all flow objects in the scene */
{
@@ -1818,7 +1815,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_INFO) {
- SpaceInfo *sinfo = (SpaceInfo *) sl;
+ SpaceInfo *sinfo = (SpaceInfo *)sl;
ARegion *ar;
sinfo->rpt_mask = INFO_RPT_OP;
@@ -1826,9 +1823,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
ar->v2d.scroll = (V2D_SCROLL_RIGHT);
- ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */
+ ar->v2d.align = V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y; /* align bottom left */
ar->v2d.keepofs = V2D_LOCKOFS_X;
- ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
+ ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
}
@@ -1867,7 +1864,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *) sl;
+ SpaceImage *sima = (SpaceImage *)sl;
if (sima->sample_line_hist.height == 0)
sima->sample_line_hist.height = 100;
}
@@ -1921,21 +1918,21 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
/* node sockets are not exposed automatically any more,
* this mimics the old behavior by adding all unlinked sockets to groups.
*/
- for (ntree=bmain->nodetree.first; ntree; ntree=ntree->id.next) {
+ for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) {
/* this adds copies and links from all unlinked internal sockets to group inputs/outputs. */
/* first make sure the own_index for new sockets is valid */
- for (node=ntree->nodes.first; node; node=node->next) {
+ for (node = ntree->nodes.first; node; node = node->next) {
for (sock = node->inputs.first; sock; sock = sock->next)
if (sock->own_index >= ntree->cur_index)
- ntree->cur_index = sock->own_index+1;
+ ntree->cur_index = sock->own_index + 1;
for (sock = node->outputs.first; sock; sock = sock->next)
if (sock->own_index >= ntree->cur_index)
- ntree->cur_index = sock->own_index+1;
+ ntree->cur_index = sock->own_index + 1;
}
/* add ntree->inputs/ntree->outputs sockets for all unlinked sockets in the group tree. */
- for (node=ntree->nodes.first; node; node=node->next) {
+ for (node = ntree->nodes.first; node; node = node->next) {
for (sock = node->inputs.first; sock; sock = sock->next) {
if (!sock->link && !nodeSocketIsHidden(sock)) {
@@ -1959,7 +1956,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
for (sock = node->outputs.first; sock; sock = sock->next) {
- if (nodeCountSocketLinks(ntree, sock)==0 && !nodeSocketIsHidden(sock)) {
+ if (nodeCountSocketLinks(ntree, sock) == 0 && !nodeSocketIsHidden(sock)) {
gsock = do_versions_node_group_add_socket_2_56_2(ntree, sock->name, sock->type, SOCK_OUT);
/* initialize the default socket value */
@@ -2001,7 +1998,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
if (sc->redraws_flag == 0) {
/* just initialize to default? */
/* XXX: we could also have iterated through areas, and taken them from the first timeline available... */
- sc->redraws_flag = TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN;
+ sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
}
}
@@ -2015,7 +2012,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Solidify) {
- SolidifyModifierData *smd = (SolidifyModifierData *) md;
+ SolidifyModifierData *smd = (SolidifyModifierData *)md;
if (smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) {
smd->mat_ofs_rim = 1;
smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL;
@@ -2104,11 +2101,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (scene = bmain->scene.first; scene; scene = scene->id.next) {
scene->r.ffcodecdata.audio_channels = 2;
scene->audio.volume = 1.0f;
- SEQ_BEGIN (scene->ed, seq)
+ SEQ_BEGIN(scene->ed, seq)
{
seq->pitch = 1.0f;
- }
- SEQ_END
+ } SEQ_END;
}
}
@@ -2158,7 +2154,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (act = bmain->action.first; act; act = act->id.next) {
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
BezTriple *bezt;
- unsigned int i = 0;
+ uint i = 0;
/* only need to touch curves that had this flag set */
if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0)
@@ -2183,11 +2179,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 2)) {
{
/* Convert default socket values from bNodeStack */
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
bNode *node;
bNodeSocket *sock;
- for (node=ntree->nodes.first; node; node=node->next) {
+ for (node = ntree->nodes.first; node; node = node->next) {
for (sock = node->inputs.first; sock; sock = sock->next)
do_versions_socket_default_value_259(sock);
for (sock = node->outputs.first; sock; sock = sock->next)
@@ -2200,8 +2196,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
do_versions_socket_default_value_259(sock);
ntree->update |= NTREE_UPDATE;
- }
- FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
{
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 9efaca83126..d1589aa0d5e 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -340,7 +340,7 @@ static void do_versions_mesh_mloopcol_swap_2_62_1(Mesh *me)
if (layer->type == CD_MLOOPCOL) {
mloopcol = (MLoopCol *)layer->data;
for (i = 0; i < me->totloop; i++, mloopcol++) {
- SWAP(unsigned char, mloopcol->r, mloopcol->b);
+ SWAP(uchar, mloopcol->r, mloopcol->b);
}
}
}
@@ -424,7 +424,7 @@ static void do_versions_nodetree_frame_2_64_6(bNodeTree *ntree)
}
/* initialize custom node color */
- node->color[0] = node->color[1] = node->color[2] = 0.608f; /* default theme color */
+ node->color[0] = node->color[1] = node->color[2] = 0.608f; /* default theme color */
}
}
@@ -665,7 +665,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 2)) {
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -679,7 +679,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 4)) {
@@ -979,7 +979,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *) md;
+ ClothModifierData *clmd = (ClothModifierData *)md;
if (clmd->sim_parms)
clmd->sim_parms->vel_damping = 1.0f;
}
@@ -1245,7 +1245,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 9)) {
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1258,7 +1258,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 10)) {
@@ -1273,7 +1273,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1285,7 +1285,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
{
@@ -1335,7 +1335,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 13)) {
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1348,13 +1348,13 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 14)) {
ParticleSettings *part;
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1367,7 +1367,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
/* keep compatibility for dupliobject particle size */
for (part = bmain->particle.first; part; part = part->id.next)
@@ -1377,7 +1377,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 17)) {
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1393,7 +1393,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 18)) {
@@ -1412,7 +1412,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
ColorBalanceModifierData *cbmd;
smd = BKE_sequence_modifier_new(seq, NULL, seqModifierType_ColorBalance);
- cbmd = (ColorBalanceModifierData *) smd;
+ cbmd = (ColorBalanceModifierData *)smd;
cbmd->color_balance = *strip->color_balance;
@@ -1426,8 +1426,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
MEM_freeN(strip->color_balance);
strip->color_balance = NULL;
}
- }
- SEQ_END
+ } SEQ_END;
}
}
}
@@ -1507,14 +1506,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 1)) {
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next)
if (node->type == SH_NODE_TEX_COORD)
node->flag |= NODE_OPTIONS;
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 2)) {
@@ -1616,7 +1615,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Fix for bug #32982, internal_links list could get corrupted from r51630 onward.
* Simply remove bad internal_links lists to avoid NULL pointers.
*/
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
bNode *node;
bNodeLink *link, *nextlink;
@@ -1628,7 +1627,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) {
@@ -1733,8 +1732,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
else {
BKE_sequence_alpha_mode_from_extension(seq);
}
- }
- SEQ_END
+ } SEQ_END;
if (scene->r.bake_samples == 0)
scene->r.bake_samples = 256;
@@ -1758,7 +1756,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1772,7 +1770,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
else if (bmain->versionfile < 266 || (bmain->versionfile == 266 && bmain->subversionfile < 1)) {
/* texture use alpha was removed for 2.66 but added back again for 2.66a,
@@ -1789,7 +1787,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (cu = bmain->curve.first; cu; cu = cu->id.next) {
if (cu->flag & (CU_FRONT | CU_BACK)) {
- if ( cu->ext1 != 0.0f || cu->ext2 != 0.0f) {
+ if (cu->ext1 != 0.0f || cu->ext2 != 0.0f) {
Nurb *nu;
for (nu = cu->nurb.first; nu; nu = nu->next) {
@@ -1837,7 +1835,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
// add storage for compositor translate nodes when not existing
if (MAIN_VERSION_OLDER(bmain, 265, 11)) {
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -1846,13 +1844,13 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
do_versions_nodetree_customnodes(ntree, ((ID *)ntree == id));
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
@@ -1891,7 +1889,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Set flag for delayed do_versions in lib_verify_nodetree. It needs valid typeinfo pointers ... */
{
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
/* XXX This should be kept without version check for now!
* As long as USE_NODE_COMPAT_CUSTOMNODES is active, files will write links
* to tree interface sockets for forward compatibility. These links need to be removed again
@@ -1906,7 +1904,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (MAIN_VERSION_OLDER(bmain, 266, 2))
ntree->flag |= NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE;
}
- FOREACH_NODETREE_END
+ FOREACH_NODETREE_END;
}
if (MAIN_VERSION_OLDER(bmain, 266, 3)) {
@@ -1918,14 +1916,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
* so do this now to ensure old files don't break.
*/
bNode *node;
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (id == &ntree->id)
- continue; /* already fixed for node groups */
+ continue; /* already fixed for node groups */
for (node = ntree->nodes.first; node; node = node->next)
nodeUniqueName(ntree, node);
}
- FOREACH_NODETREE_END
+ FOREACH_NODETREE_END;
}
}
@@ -2208,7 +2206,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 269, 1)) {
/* Removal of Cycles SSS Compatible falloff */
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -2219,12 +2217,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (!MAIN_VERSION_ATLEAST(bmain, 269, 2)) {
/* Initialize CDL settings for Color Balance nodes */
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -2246,7 +2244,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (!MAIN_VERSION_ATLEAST(bmain, 269, 3)) {
@@ -2369,11 +2367,10 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
WipeVars *wv = seq->effectdata;
wv->angle = DEG2RADF(wv->angle);
}
- }
- SEQ_END
+ } SEQ_END;
}
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -2391,7 +2388,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingPlaneTrack", "float", "image_opacity")) {
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index e446e268e61..8613ffc97fb 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -113,7 +113,7 @@ static bGPDpalette *BKE_gpencil_palette_addnew(bGPdata *gpd, const char *name)
/* auto-name */
BLI_strncpy(palette->info, name, sizeof(palette->info));
BLI_uniquename(&gpd->palettes, palette, DATA_("GP_Palette"), '.', offsetof(bGPDpalette, info),
- sizeof(palette->info));
+ sizeof(palette->info));
/* return palette */
return palette;
@@ -142,7 +142,7 @@ static bGPDpalettecolor *BKE_gpencil_palettecolor_addnew(bGPDpalette *palette, c
/* auto-name */
BLI_strncpy(palcolor->info, name, sizeof(palcolor->info));
BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info),
- sizeof(palcolor->info));
+ sizeof(palcolor->info));
/* return palette color */
return palcolor;
@@ -378,7 +378,7 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), FCurve *fcu, void
/* Driver -> Driver Vars (for bbone_in/out) */
if (fcu->driver) {
for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) {
- DRIVER_TARGETS_LOOPER(dvar)
+ DRIVER_TARGETS_LOOPER_BEGIN(dvar)
{
if (dtar->rna_path) {
dtar->rna_path = replace_bbone_easing_rnapath(dtar->rna_path);
@@ -427,7 +427,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
/* nodes don't use fixed node->id any more, clean up */
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -436,7 +436,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
{
bScreen *screen;
@@ -447,7 +447,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
SpaceLink *space_link;
for (space_link = area->spacedata.first; space_link; space_link = space_link->next) {
if (space_link->spacetype == SPACE_CLIP) {
- SpaceClip *space_clip = (SpaceClip *) space_link;
+ SpaceClip *space_clip = (SpaceClip *)space_link;
if (space_clip->mode != SC_MODE_MASKEDIT) {
space_clip->mode = SC_MODE_TRACKING;
}
@@ -682,7 +682,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (!MAIN_VERSION_ATLEAST(bmain, 273, 1)) {
-#define BRUSH_RAKE (1 << 7)
+#define BRUSH_RAKE (1 << 7)
#define BRUSH_RANDOM_ROTATION (1 << 25)
Brush *br;
@@ -790,7 +790,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (!DNA_struct_elem_find(fd->filesdna, "NodePlaneTrackDeformData", "char", "flag")) {
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -803,7 +803,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- FOREACH_NODETREE_END
+ FOREACH_NODETREE_END;
}
if (!DNA_struct_elem_find(fd->filesdna, "Camera", "GPUDOFSettings", "gpu_dof")) {
@@ -864,7 +864,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (ob = bmain->object.first; ob; ob = ob->id.next) {
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
if ((psys->pointcache->flag & PTCACHE_BAKED) == 0) {
- psys->recalc |= PSYS_RECALC_RESET;
+ psys->recalc |= ID_RECALC_PSYS_RESET;
}
}
}
@@ -917,8 +917,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
#undef SEQ_USE_PROXY_CUSTOM_DIR
#undef SEQ_USE_PROXY_CUSTOM_FILE
- }
- SEQ_END
+ } SEQ_END;
}
for (screen = bmain->screen.first; screen; screen = screen->id.next) {
@@ -939,7 +938,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
case SPACE_IMAGE:
{
- SpaceImage *sima = (SpaceImage *) sl;
+ SpaceImage *sima = (SpaceImage *)sl;
sima->iuser.flag |= IMA_SHOW_STEREO;
break;
}
@@ -1044,7 +1043,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
bScreen *screen;
-#define RV3D_VIEW_PERSPORTHO 7
+#define RV3D_VIEW_PERSPORTHO 7
for (screen = bmain->screen.first; screen; screen = screen->id.next) {
ScrArea *sa;
for (sa = screen->areabase.first; sa; sa = sa->next) {
@@ -1073,7 +1072,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
Lamp *lamp;
-#define LA_YF_PHOTON 5
+#define LA_YF_PHOTON 5
for (lamp = bmain->lamp.first; lamp; lamp = lamp->id.next) {
if (lamp->type == LA_YF_PHOTON) {
lamp->type = LA_LOCAL;
@@ -1286,8 +1285,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
copy_v4_fl(data->color, 1.0f);
data->shadow_color[3] = 1.0f;
}
- }
- SEQ_END
+ } SEQ_END;
}
/* Adding "Properties" region to DopeSheet */
@@ -1635,7 +1633,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Fix for T50736, Glare comp node using same var for two different things. */
if (!DNA_struct_elem_find(fd->filesdna, "NodeGlare", "char", "star_45")) {
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
ntreeSetTypes(NULL, ntree);
for (bNode *node = ntree->nodes.first; node; node = node->next) {
@@ -1654,7 +1652,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "float", "mat[4][4]")) {
@@ -1668,11 +1666,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
do_versions_compositor_render_passes(ntree);
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (!MAIN_VERSION_ATLEAST(bmain, 279, 0)) {
@@ -1785,7 +1783,7 @@ void do_versions_after_linking_270(Main *bmain)
{
/* To be added to next subversion bump! */
if (!MAIN_VERSION_ATLEAST(bmain, 279, 0)) {
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
ntreeSetTypes(NULL, ntree);
for (bNode *node = ntree->nodes.first; node; node = node->next) {
@@ -1794,7 +1792,7 @@ void do_versions_after_linking_270(Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (!MAIN_VERSION_ATLEAST(bmain, 279, 2)) {
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 2cf00bfe2c1..17859d257d0 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -723,24 +723,12 @@ void do_versions_after_linking_280(Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 4)) {
for (Object *object = bmain->object.first; object; object = object->id.next) {
-#ifndef VERSION_280_SUBVERSION_4
- /* If any object already has an initialized value for
- * duplicator_visibility_flag it means we've already doversioned it.
- * TODO(all) remove the VERSION_280_SUBVERSION_4 code once the subversion was bumped. */
- if (object->duplicator_visibility_flag != 0) {
- break;
- }
-#endif
if (object->particlesystem.first) {
object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT;
for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) {
if (psys->part->draw & PART_DRAW_EMITTER) {
object->duplicator_visibility_flag |= OB_DUPLI_FLAG_RENDER;
-#ifndef VERSION_280_SUBVERSION_4
- psys->part->draw &= ~PART_DRAW_EMITTER;
-#else
break;
-#endif
}
}
}
@@ -751,6 +739,11 @@ void do_versions_after_linking_280(Main *bmain)
object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT | OB_DUPLI_FLAG_RENDER;
}
}
+
+ /* Cleanup deprecated flag from particlesettings data-blocks. */
+ for (ParticleSettings *part = bmain->particle.first; part; part = part->id.next) {
+ part->draw &= ~PART_DRAW_EMITTER;
+ }
}
/* SpaceTime & SpaceLogic removal/replacing */
@@ -1015,7 +1008,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
* Also, metallic node is now unified into the principled node. */
eNTreeDoVersionErrors error = NTREE_DOVERSION_NO_ERROR;
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
for (bNode *node = ntree->nodes.first; node; node = node->next) {
if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ &&
@@ -1047,12 +1040,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
- if (error & NTREE_DOVERSION_NEED_OUTPUT) {
- BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
- printf("You need to connect Principled and Eevee Specular shader nodes to new material output nodes.\n");
- }
+ if (error & NTREE_DOVERSION_NEED_OUTPUT) {
+ BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
+ printf("You need to connect Principled and Eevee Specular shader nodes to new material output nodes.\n");
+ }
if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) {
BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console");
@@ -1116,7 +1109,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
/* Init grease pencil pixel size factor */
- if (!DNA_struct_elem_find(fd->filesdna, "bGPDdata", "int", "pixfactor")) {
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "int", "pixfactor")) {
for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
}
@@ -1131,9 +1124,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
gset->cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
curvemapping_initialize(gset->cur_falloff);
curvemap_reset(gset->cur_falloff->cm,
- &gset->cur_falloff->clipr,
- CURVE_PRESET_GAUSS,
- CURVEMAP_SLOPE_POSITIVE);
+ &gset->cur_falloff->clipr,
+ CURVE_PRESET_GAUSS,
+ CURVEMAP_SLOPE_POSITIVE);
}
}
}
@@ -1374,16 +1367,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
unit_qt(scene->cursor.rotation);
}
- 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;
- unit_qt(v3d->cursor.rotation);
- }
- }
- }
- }
}
}
@@ -1687,7 +1670,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "matcap[256]")) {
- StudioLight *default_matcap = BKE_studiolight_find_first(STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
+ StudioLight *default_matcap = BKE_studiolight_find_first(STUDIOLIGHT_TYPE_MATCAP);
/* when loading the internal file is loaded before the matcaps */
if (default_matcap) {
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
@@ -2424,11 +2407,88 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
#undef PAINT_BLEND_HUE
#undef PAINT_BLEND_ALPHA_SUB
#undef PAINT_BLEND_ALPHA_ADD
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 34)) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ for (SpaceLink *slink = area->spacedata.first; slink; slink = slink->next) {
+ if (slink->spacetype == SPACE_USERPREF) {
+ ARegion *navigation_region = BKE_spacedata_find_region_type(slink, area, RGN_TYPE_NAV_BAR);
+
+ if (!navigation_region) {
+ ListBase *regionbase = (slink == area->spacedata.first) ?
+ &area->regionbase : &slink->regionbase;
+ navigation_region = MEM_callocN(sizeof(ARegion), "userpref navigation-region do_versions");
+
+ BLI_addhead(regionbase, navigation_region); /* order matters, addhead not addtail! */
+ navigation_region->regiontype = RGN_TYPE_NAV_BAR;
+ navigation_region->alignment = RGN_ALIGN_LEFT;
+ }
+ }
+ }
+ }
}
}
{
/* Versioning code until next subversion bump goes here. */
+
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "curvature_ridge_factor")) {
+ 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;
+ v3d->shading.curvature_ridge_factor = 1.0f;
+ v3d->shading.curvature_valley_factor = 1.0f;
+ }
+ }
+ }
+ }
+ }
+
+ /* Rename OpenGL to Workbench. */
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ if (STREQ(scene->r.engine, "BLENDER_OPENGL")) {
+ STRNCPY(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH);
+ }
+ }
+
+ /* init Annotations onion skin */
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPDlayer", "int", "gstep")) {
+ for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ ARRAY_SET_ITEMS(gpl->gcolor_prev, 0.302f, 0.851f, 0.302f);
+ ARRAY_SET_ITEMS(gpl->gcolor_next, 0.250f, 0.1f, 1.0f);
+ }
+ }
+ }
+
+ /* Move studio_light selection to lookdev_light. */
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "lookdev_light[256]")) {
+ 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;
+ memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char) * 256);
+ }
+ }
+ }
+ }
+ }
+
+ /* Change Solid mode shadow orientation. */
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "float", "shadow_focus")) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ float *dir = scene->display.light_direction;
+ SWAP(float, dir[2], dir[1]);
+ dir[2] = -dir[2];
+ dir[0] = -dir[0];
+ }
+ }
}
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index b084de01d52..25946a9fb31 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -44,6 +44,7 @@
#include "BKE_brush.h"
#include "BKE_colortools.h"
+#include "BKE_keyconfig.h"
#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -71,6 +72,9 @@ void BLO_update_defaults_userpref_blend(void)
U.flag &= ~USER_SCRIPT_AUTOEXEC_DISABLE;
#endif
+ /* Transform tweak with single click and drag. */
+ U.flag |= USER_RELEASECONFIRM;
+
/* Ignore the theme saved in the blend file,
* instead use the theme from 'userdef_default_theme.c' */
{
@@ -84,6 +88,9 @@ void BLO_update_defaults_userpref_blend(void)
/* Only enable tooltips translation by default, without actually enabling translation itself, for now. */
U.transopts = USER_TR_TOOLTIPS;
U.memcachelimit = 4096;
+
+ /* Default to left click select. */
+ BKE_keyconfig_pref_set_select_mouse(&U, 0, true);
}
/**
@@ -175,9 +182,9 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff;
curvemapping_initialize(gp_falloff_curve);
curvemap_reset(gp_falloff_curve->cm,
- &gp_falloff_curve->clipr,
- CURVE_PRESET_GAUSS,
- CURVEMAP_SLOPE_POSITIVE);
+ &gp_falloff_curve->clipr,
+ CURVE_PRESET_GAUSS,
+ CURVEMAP_SLOPE_POSITIVE);
}
}
}
@@ -236,14 +243,24 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
BKE_view_layer_rename(bmain, scene, scene->view_layers.first, "View Layer");
}
+ /* Rename lamp objects. */
+ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
+ if (STREQ(ob->id.name, "OBLamp")) {
+ STRNCPY(ob->id.name, "OBLight");
+ }
+ }
+ for (Lamp *lamp = bmain->lamp.first; lamp; lamp = lamp->id.next) {
+ if (STREQ(lamp->id.name, "LALamp")) {
+ STRNCPY(lamp->id.name, "LALight");
+ }
+ }
+
for (Mesh *mesh = bmain->mesh.first; mesh; mesh = mesh->id.next) {
/* Match default for new meshes. */
mesh->smoothresh = DEG2RADF(30);
}
- }
- /* Grease Pencil New Eraser Brush */
- if (builtin_template) {
+ /* Grease Pencil New Eraser Brush */
Brush *br;
/* Rename old Hard Eraser */
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Eraser Hard");
@@ -273,4 +290,19 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
}
}
}
+
+ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
+ for (ScrArea *sa = sc->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;
+ v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT;
+ }
+ }
+ }
+ }
+
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ copy_v3_v3(scene->display.light_direction, (float[3]){M_SQRT1_3, M_SQRT1_3, M_SQRT1_3});
+ }
}
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 61966ec49b7..3b4e35149aa 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -103,14 +103,14 @@
static void vcol_to_fcol(Mesh *me)
{
MFace *mface;
- unsigned int *mcol, *mcoln, *mcolmain;
+ uint *mcol, *mcoln, *mcolmain;
int a;
if (me->totface == 0 || me->mcol == NULL)
return;
mcoln = mcolmain = MEM_malloc_arrayN(me->totface, 4 * sizeof(int), "mcoln");
- mcol = (unsigned int *)me->mcol;
+ mcol = (uint *)me->mcol;
mface = me->mface;
for (a = me->totface; a > 0; a--, mface++) {
mcoln[0] = mcol[mface->v1];
@@ -147,11 +147,11 @@ static void bone_version_238(ListBase *lb)
for (bone = lb->first; bone; bone = bone->next) {
if (bone->rad_tail == 0.0f && bone->rad_head == 0.0f) {
- bone->rad_head = 0.25f*bone->length;
- bone->rad_tail = 0.1f*bone->length;
+ bone->rad_head = 0.25f * bone->length;
+ bone->rad_tail = 0.1f * bone->length;
- bone->dist-= bone->rad_head;
- if (bone->dist<=0.0f)
+ bone->dist -= bone->rad_head;
+ if (bone->dist <= 0.0f)
bone->dist = 0.0f;
}
bone_version_238(&bone->childbase);
@@ -236,7 +236,7 @@ static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree)
/* fix for temporary flag changes during 245 cycle */
nodeid = blo_do_versions_newlibadr(fd, lib, node->id);
if (node->storage && nodeid && GS(nodeid->name) == ID_IM) {
- image = (Image*)nodeid;
+ image = (Image *)nodeid;
iuser = node->storage;
if (iuser->flag & IMA_OLD_PREMUL) {
iuser->flag &= ~IMA_OLD_PREMUL;
@@ -378,7 +378,7 @@ static void do_version_ntree_242_2(bNodeTree *ntree)
iuser->frames = nia->frames;
iuser->sfra = nia->sfra;
- iuser->offset = nia->nr-1;
+ iuser->offset = nia->nr - 1;
iuser->cycl = nia->cyclic;
iuser->ok = 1;
@@ -526,7 +526,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (ob->totcol) {
for (a = 0; a < ob->totcol; a++) {
if (ob->mat[a])
- ob->colbits |= (1<<a);
+ ob->colbits |= (1 << a);
}
}
ob = ob->id.next;
@@ -586,7 +586,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
SpaceLink *sl = sa->spacedata.first;
while (sl) {
if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D*) sl;
+ View3D *v3d = (View3D *)sl;
if (v3d->gridlines == 0)
v3d->gridlines = 20;
@@ -603,8 +603,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
Tex *tex = bmain->tex.first;
while (tex) {
if ((tex->rfac == 0.0f) &&
- (tex->gfac == 0.0f) &&
- (tex->bfac == 0.0f))
+ (tex->gfac == 0.0f) &&
+ (tex->bfac == 0.0f))
{
tex->rfac = 1.0f;
tex->gfac = 1.0f;
@@ -620,8 +620,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
Tex *tex = bmain->tex.first;
while (tex) {
if ((tex->rfac == 0.0f) &&
- (tex->gfac == 0.0f) &&
- (tex->bfac == 0.0f))
+ (tex->gfac == 0.0f) &&
+ (tex->bfac == 0.0f))
{
tex->rfac = 1.0f;
tex->gfac = 1.0f;
@@ -702,7 +702,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
SpaceLink *sl = sa->spacedata.first;
while (sl) {
if (sl->spacetype == SPACE_IPO) {
- SpaceIpo *sipo = (SpaceIpo*) sl;
+ SpaceIpo *sipo = (SpaceIpo *)sl;
sipo->v2d.max[0] = 15000.0;
}
sl = sl->next;
@@ -735,7 +735,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
SpaceLink *sl = sa->spacedata.first;
while (sl) {
if (sl->spacetype == SPACE_TEXT) {
- SpaceText *st = (SpaceText*) sl;
+ SpaceText *st = (SpaceText *)sl;
st->lheight = 12;
}
sl = sl->next;
@@ -834,10 +834,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
int i, j;
for (i = 0; i < me->totface; i++) {
- TFace *tf = &((TFace*) me->tface)[i];
+ TFace *tf = &((TFace *)me->tface)[i];
for (j = 0; j < 4; j++) {
- char *col = (char *) &tf->col[j];
+ char *col = (char *)&tf->col[j];
col[0] = 255;
}
@@ -888,7 +888,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_IPO) {
- SpaceSeq *sseq = (SpaceSeq*) sl;
+ SpaceSeq *sseq = (SpaceSeq *)sl;
sseq->v2d.keeptot = 0;
}
}
@@ -961,11 +961,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_ACTION) {
- SpaceAction *sac = (SpaceAction *) sl;
+ SpaceAction *sac = (SpaceAction *)sl;
sac->v2d.max[0] = 32000;
}
else if (sl->spacetype == SPACE_NLA) {
- SpaceNla *sla = (SpaceNla *) sl;
+ SpaceNla *sla = (SpaceNla *)sl;
sla->v2d.max[0] = 32000;
}
}
@@ -1028,7 +1028,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_BUTS) {
- SpaceButs *sbuts = (SpaceButs *) sl;
+ SpaceButs *sbuts = (SpaceButs *)sl;
sbuts->v2d.maxzoom = 1.2f;
@@ -1118,7 +1118,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
SpaceLink *sl = sa->spacedata.first;
while (sl) {
if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D*) sl;
+ View3D *v3d = (View3D *)sl;
if (v3d->gridflag == 0) {
v3d->gridflag |= V3D_SHOW_X;
@@ -1141,7 +1141,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
bScreen *sc;
while (tex) {
- if ((tex->flag & (TEX_CHECKER_ODD+TEX_CHECKER_EVEN))==0) {
+ if ((tex->flag & (TEX_CHECKER_ODD + TEX_CHECKER_EVEN)) == 0) {
tex->flag |= TEX_CHECKER_ODD;
}
/* copied from kernel texture.c */
@@ -1181,7 +1181,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
/* added: 5x better zoom in for nla */
if (sl->spacetype == SPACE_NLA) {
- SpaceNla *snla = (SpaceNla *) sl;
+ SpaceNla *snla = (SpaceNla *)sl;
snla->v2d.maxzoom = 50;
}
}
@@ -1206,7 +1206,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *) sl;
+ View3D *v3d = (View3D *)sl;
v3d->flag |= V3D_SELECT_OUTLINE;
}
}
@@ -1223,7 +1223,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *) sl;
+ View3D *v3d = (View3D *)sl;
v3d->flag |= V3D_ZBUF_SELECT;
}
else if (sl->spacetype == SPACE_TEXT) {
@@ -1250,12 +1250,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
while (sce) {
ed = sce->ed;
if (ed) {
- SEQ_BEGIN (sce->ed, seq)
+ SEQ_BEGIN(sce->ed, seq)
{
if (seq->type == SEQ_TYPE_IMAGE || seq->type == SEQ_TYPE_MOVIE)
seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
- }
- SEQ_END
+ } SEQ_END;
}
sce = sce->id.next;
@@ -1338,8 +1337,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
else if (ob->type == OB_MESH) {
Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data);
- if ((me->flag&ME_SUBSURF)) {
- SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf);
+ if ((me->flag & ME_SUBSURF)) {
+ SubsurfModifierData *smd = (SubsurfModifierData *)modifier_new(eModifierType_Subsurf);
smd->levels = MAX2(1, me->subdiv);
smd->renderLevels = MAX2(1, me->subdivr);
@@ -1355,7 +1354,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
BLI_addtail(&ob->modifiers, smd);
- modifier_unique_name(&ob->modifiers, (ModifierData*)smd);
+ modifier_unique_name(&ob->modifiers, (ModifierData *)smd);
}
}
@@ -1405,9 +1404,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Subsurf) {
- SubsurfModifierData *smd = (SubsurfModifierData*) md;
+ SubsurfModifierData *smd = (SubsurfModifierData *)md;
- smd->flags &= ~(eSubsurfModifierFlag_Incremental|eSubsurfModifierFlag_DebugIncr);
+ smd->flags &= ~(eSubsurfModifierFlag_Incremental | eSubsurfModifierFlag_DebugIncr);
}
}
@@ -1439,7 +1438,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (con = pchan->constraints.first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
- bKinematicConstraint *data = (bKinematicConstraint*)con->data;
+ bKinematicConstraint *data = (bKinematicConstraint *)con->data;
data->weight = 1.0f;
data->orientweight = 1.0f;
data->flag &= ~CONSTRAINT_IK_ROT;
@@ -1512,7 +1511,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Armature) {
- ArmatureModifierData *amd = (ArmatureModifierData*) md;
+ ArmatureModifierData *amd = (ArmatureModifierData *)md;
if (amd->object && amd->deformflag == 0) {
Object *oba = blo_do_versions_newlibadr(fd, lib, amd->object);
arm = blo_do_versions_newlibadr(fd, lib, oba->data);
@@ -1578,7 +1577,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (srl = sce->r.layers.first; srl; srl = srl->next) {
if (srl->layflag & SCE_LAY_SOLID)
srl->layflag |= SCE_LAY_SKY;
- srl->passflag &= (SCE_PASS_COMBINED|SCE_PASS_Z|SCE_PASS_NORMAL|SCE_PASS_VECTOR);
+ srl->passflag &= (SCE_PASS_COMBINED | SCE_PASS_Z | SCE_PASS_NORMAL | SCE_PASS_VECTOR);
}
/* node version changes */
@@ -1641,7 +1640,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D*) sl;
+ View3D *v3d = (View3D *)sl;
if (v3d->gridsubdiv == 0)
v3d->gridsubdiv = 10;
}
@@ -1715,7 +1714,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* version patch from buttons_object.c */
if (data->flag == 0)
- data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z;
+ data->flag = ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z;
break;
}
@@ -1731,32 +1730,32 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) {
switch (curcon->type) {
case CONSTRAINT_TYPE_MINMAX:
- {
- bMinMaxConstraint *data = curcon->data;
- if (data->sticky == 1)
- data->flag |= MINMAX_STICKY;
- else
- data->flag &= ~MINMAX_STICKY;
- }
+ {
+ bMinMaxConstraint *data = curcon->data;
+ if (data->sticky == 1)
+ data->flag |= MINMAX_STICKY;
+ else
+ data->flag &= ~MINMAX_STICKY;
break;
+ }
case CONSTRAINT_TYPE_KINEMATIC:
- {
- bKinematicConstraint *data = curcon->data;
- if (!(data->flag & CONSTRAINT_IK_POS)) {
- data->flag |= CONSTRAINT_IK_POS;
- data->flag |= CONSTRAINT_IK_STRETCH;
- }
+ {
+ bKinematicConstraint *data = curcon->data;
+ if (!(data->flag & CONSTRAINT_IK_POS)) {
+ data->flag |= CONSTRAINT_IK_POS;
+ data->flag |= CONSTRAINT_IK_STRETCH;
}
break;
+ }
case CONSTRAINT_TYPE_ROTLIKE:
- {
- bRotateLikeConstraint *data = curcon->data;
+ {
+ bRotateLikeConstraint *data = curcon->data;
- /* version patch from buttons_object.c */
- if (data->flag == 0)
- data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z;
- }
+ /* version patch from buttons_object.c */
+ if (data->flag == 0)
+ data->flag = ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z;
break;
+ }
}
}
}
@@ -1766,10 +1765,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* copy old object level track settings to curve modifers */
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Curve) {
- CurveModifierData *cmd = (CurveModifierData*) md;
+ CurveModifierData *cmd = (CurveModifierData *)md;
if (cmd->defaxis == 0)
- cmd->defaxis = ob->trackflag+1;
+ cmd->defaxis = ob->trackflag + 1;
}
}
@@ -1819,7 +1818,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
tex->iuser.frames = tex->frames;
tex->iuser.offset = tex->offset;
tex->iuser.sfra = tex->sfra;
- tex->iuser.cycl = (tex->imaflag & TEX_ANIMCYCLIC_)!=0;
+ tex->iuser.cycl = (tex->imaflag & TEX_ANIMCYCLIC_) != 0;
}
for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->nodetree)
@@ -1834,7 +1833,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (bmain->subversionfile < 4) {
for (sce = bmain->scene.first; sce; sce = sce->id.next) {
- sce->r.bake_mode = 1; /* prevent to include render stuff here */
+ sce->r.bake_mode = 1; /* prevent to include render stuff here */
sce->r.bake_filter = 16;
sce->r.bake_flag = R_BAKE_CLEAR;
}
@@ -1860,7 +1859,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* translate old mirror modifier axis values to new flags */
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Mirror) {
- MirrorModifierData *mmd = (MirrorModifierData*) md;
+ MirrorModifierData *mmd = (MirrorModifierData *)md;
switch (mmd->axis) {
case 0:
@@ -1902,7 +1901,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction*) sl;
+ SpaceAction *saction = (SpaceAction *)sl;
saction->v2d.tot.ymin = -1000.0;
saction->v2d.tot.ymax = 0.0;
@@ -1932,7 +1931,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* unless the file was created 2.44.3 but not 2.45, update the constraints */
if (!(bmain->versionfile == 244 && bmain->subversionfile == 3) &&
- ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile == 0)) )
+ ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile == 0)) )
{
for (ob = bmain->object.first; ob; ob = ob->id.next) {
ListBase *list;
@@ -1951,13 +1950,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
switch (curcon->type) {
case CONSTRAINT_TYPE_LOCLIMIT:
{
- bLocLimitConstraint *data = (bLocLimitConstraint *) curcon->data;
+ bLocLimitConstraint *data = (bLocLimitConstraint *)curcon->data;
/* old limit without parent option for objects */
if (data->flag2)
curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
+ break;
}
- break;
}
}
}
@@ -1982,13 +1981,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
switch (curcon->type) {
case CONSTRAINT_TYPE_ACTION:
{
- bActionConstraint *data = (bActionConstraint *) curcon->data;
+ bActionConstraint *data = (bActionConstraint *)curcon->data;
/* 'data->local' used to mean that target was in local-space */
if (data->local)
curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
+ break;
}
- break;
}
}
@@ -2027,7 +2026,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData*) md;
+ ClothModifierData *clmd = (ClothModifierData *)md;
if (!clmd->point_cache) {
clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches);
clmd->point_cache->step = 1;
@@ -2129,7 +2128,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (ob = bmain->object.first; ob; ob = ob->id.next) {
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Armature)
- ((ArmatureModifierData*) md)->deformflag |= ARM_DEF_B_BONE_REST;
+ ((ArmatureModifierData *)md)->deformflag |= ARM_DEF_B_BONE_REST;
}
}
}
@@ -2232,7 +2231,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
md = modifier_new(eModifierType_ParticleSystem);
BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_listbase_count(&ob->particlesystem));
- psmd = (ParticleSystemModifierData*) md;
+ psmd = (ParticleSystemModifierData *)md;
psmd->psys = psys;
BLI_addtail(&ob->modifiers, md);
@@ -2268,7 +2267,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
part->draw_as = PART_DRAW_PATH;
part->type = PART_HAIR;
- psys->recalc |= PSYS_RECALC_REDO;
+ psys->recalc |= ID_RECALC_PSYS_REDO;
part->normfac *= fac;
part->randfac *= fac;
@@ -2329,7 +2328,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
int a;
if (pset->brush[0].size == 0) {
- pset->flag = PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER;
+ pset->flag = PE_KEEP_LENGTHS | PE_LOCK_FIRST | PE_DEFLECT_EMITTER;
pset->emitterdist = 0.25f;
pset->totrekey = 5;
pset->totaddkey = 5;
@@ -2368,10 +2367,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
else
repeat = strip->repeat;
- length = strip->end-strip->start;
+ length = strip->end - strip->start;
if (length == 0.0f)
length = 1.0f;
- actlength = strip->actend-strip->actstart;
+ actlength = strip->actend - strip->actstart;
strip->scale = length / (repeat * actlength);
if (strip->scale == 0.0f)
@@ -2393,8 +2392,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
{
if (seq->blend_mode == 0)
seq->blend_opacity = 100.0f;
- }
- SEQ_END
+ } SEQ_END;
}
}
@@ -2471,8 +2469,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
* use it for the number of divisions per segment
*/
if (nu->pntsv > 1) {
- nu->resolu = MAX2( 1, (int)(((float)nu->resolu / (float)nu->pntsu)+0.5f) );
- nu->resolv = MAX2( 1, (int)(((float)nu->resolv / (float)nu->pntsv)+0.5f) );
+ nu->resolu = MAX2(1, (int)(((float)nu->resolu / (float)nu->pntsu) + 0.5f) );
+ nu->resolv = MAX2(1, (int)(((float)nu->resolv / (float)nu->pntsv) + 0.5f) );
}
}
}
@@ -2502,25 +2500,25 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
switch (sl->spacetype) {
case SPACE_ACTION:
- {
- SpaceAction *sact = (SpaceAction *)sl;
+ {
+ SpaceAction *sact = (SpaceAction *)sl;
- sact->mode = SACTCONT_DOPESHEET;
- sact->autosnap = SACTSNAP_FRAME;
- }
+ sact->mode = SACTCONT_DOPESHEET;
+ sact->autosnap = SACTSNAP_FRAME;
break;
+ }
case SPACE_IPO:
- {
- SpaceIpo *sipo = (SpaceIpo *)sl;
- sipo->autosnap = SACTSNAP_FRAME;
- }
+ {
+ SpaceIpo *sipo = (SpaceIpo *)sl;
+ sipo->autosnap = SACTSNAP_FRAME;
break;
+ }
case SPACE_NLA:
- {
- SpaceNla *snla = (SpaceNla *)sl;
- snla->autosnap = SACTSNAP_FRAME;
- }
+ {
+ SpaceNla *snla = (SpaceNla *)sl;
+ snla->autosnap = SACTSNAP_FRAME;
break;
+ }
}
}
}
@@ -2532,7 +2530,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
Object *ob;
for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->pd)
- ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer())) + 1) % 128;
+ ob->pd->seed = ((uint)(ceil(PIL_check_seconds_timer())) + 1) % 128;
}
}
@@ -2548,10 +2546,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
SEQP_BEGIN (ed, seq)
{
if (seq->strip && seq->strip->proxy) {
- seq->strip->proxy->quality =90;
+ seq->strip->proxy->quality = 90;
}
- }
- SEQ_END
+ } SEQ_END;
}
sce = sce->id.next;
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 729b668c4ec..8e8f42bdf10 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -93,6 +93,15 @@ static void do_versions_theme(UserDef *userdef, bTheme *btheme)
copy_v4_v4_char(btheme->tclip.list_text, U_theme_default.tclip.list_text);
}
+ if (!USER_VERSION_ATLEAST(280, 33)) {
+ copy_v4_v4_char(btheme->tuserpref.navigation_bar, U_theme_default.tuserpref.navigation_bar);
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 36)) {
+ copy_v4_v4_char(btheme->tui.wcol_state.inner_changed, U_theme_default.tui.wcol_state.inner_changed);
+ copy_v4_v4_char(btheme->tui.wcol_state.inner_changed_sel, U_theme_default.tui.wcol_state.inner_changed_sel);
+ }
+
#undef USER_VERSION_ATLEAST
}
@@ -398,24 +407,50 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
}
}
- if (!USER_VERSION_ATLEAST(280, 32)) {
- if ((userdef->flag & USER_LMOUSESELECT) ) {
- userdef->flag &= ~USER_LMOUSESELECT;
- wmKeyConfigPref *kpt = BKE_keyconfig_pref_ensure(userdef, WM_KEYCONFIG_STR_DEFAULT);
- IDP_AddToGroup(kpt->prop, IDP_New(IDP_INT, &(IDPropertyTemplate){ .i = 0, }, "select_mouse"));
- }
- }
-
if (!USER_VERSION_ATLEAST(280, 33)) {
/* Enable GLTF addon by default. */
BKE_addon_ensure(&userdef->addons, "io_scene_gltf2");
}
+ if (!USER_VERSION_ATLEAST(280, 35)) {
+ /* Preserve RMB select setting after moving to Python and changing default value. */
+ if (USER_VERSION_ATLEAST(280, 32) || !(userdef->flag & USER_LMOUSESELECT)) {
+ BKE_keyconfig_pref_set_select_mouse(userdef, 1, false);
+ }
+
+ userdef->flag &= ~USER_LMOUSESELECT;
+ }
+
/**
* Include next version bump.
*/
{
/* (keep this block even if it becomes empty). */
+ copy_v4_fl4(userdef->light_param[0].vec, -0.580952, 0.228571, 0.781185, 0.0);
+ copy_v4_fl4(userdef->light_param[0].col, 0.900000, 0.900000, 0.900000, 1.000000);
+ copy_v4_fl4(userdef->light_param[0].spec, 0.318547, 0.318547, 0.318547, 1.000000);
+ userdef->light_param[0].flag = 1;
+ userdef->light_param[0].smooth = 0.1;
+
+ copy_v4_fl4(userdef->light_param[1].vec, 0.788218, 0.593482, -0.162765, 0.0);
+ copy_v4_fl4(userdef->light_param[1].col, 0.267115, 0.269928, 0.358840, 1.000000);
+ copy_v4_fl4(userdef->light_param[1].spec, 0.090838, 0.090838, 0.090838, 1.000000);
+ userdef->light_param[1].flag = 1;
+ userdef->light_param[1].smooth = 0.25;
+
+ copy_v4_fl4(userdef->light_param[2].vec, 0.696472, -0.696472, -0.172785, 0.0);
+ copy_v4_fl4(userdef->light_param[2].col, 0.293216, 0.304662, 0.401968, 1.000000);
+ copy_v4_fl4(userdef->light_param[2].spec, 0.069399, 0.020331, 0.020331, 1.000000);
+ userdef->light_param[2].flag = 1;
+ userdef->light_param[2].smooth = 0.4;
+
+ copy_v4_fl4(userdef->light_param[3].vec, 0.021053, -0.989474, 0.143173, 0.0);
+ copy_v4_fl4(userdef->light_param[3].col, 0.0, 0.0, 0.0, 1.0);
+ copy_v4_fl4(userdef->light_param[3].spec, 0.072234, 0.082253, 0.162642, 1.000000);
+ userdef->light_param[3].flag = 1;
+ userdef->light_param[3].smooth = 0.7;
+
+ copy_v4_fl4(userdef->light_ambient, 0.025000, 0.025000, 0.025000, 1.000000);
}
if (userdef->pixelsize == 0.0f)
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 99cd9b805bf..a45de6b48dc 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -755,10 +755,10 @@ static void write_previews(WriteData *wd, const PreviewImage *prv_orig)
}
writestruct_at_address(wd, DATA, PreviewImage, 1, prv_orig, &prv);
if (prv.rect[0]) {
- writedata(wd, DATA, prv.w[0] * prv.h[0] * sizeof(unsigned int), prv.rect[0]);
+ writedata(wd, DATA, prv.w[0] * prv.h[0] * sizeof(uint), prv.rect[0]);
}
if (prv.rect[1]) {
- writedata(wd, DATA, prv.w[1] * prv.h[1] * sizeof(unsigned int), prv.rect[1]);
+ writedata(wd, DATA, prv.w[1] * prv.h[1] * sizeof(uint), prv.rect[1]);
}
}
}
@@ -846,13 +846,13 @@ static void write_fcurves(WriteData *wd, ListBase *fcurves)
/* variables */
writelist(wd, DATA, DriverVar, &driver->variables);
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
if (dtar->rna_path) {
writedata(wd, DATA, strlen(dtar->rna_path) + 1, dtar->rna_path);
}
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
@@ -2491,7 +2491,7 @@ static void write_lightcache_texture(WriteData *wd, LightCacheTexture *tex)
data_size *= sizeof(float);
}
else if (tex->data_type == LIGHTCACHETEX_UINT) {
- data_size *= sizeof(unsigned int);
+ data_size *= sizeof(uint);
}
writedata(wd, DATA, data_size, tex->data);
}
@@ -2572,8 +2572,7 @@ static void write_scene(WriteData *wd, Scene *sce)
seq->strip->done = false;
}
writestruct(wd, DATA, Sequence, 1, seq);
- }
- SEQ_END
+ } SEQ_END;
SEQ_BEGIN(ed, seq)
{
@@ -2639,8 +2638,7 @@ static void write_scene(WriteData *wd, Scene *sce)
}
write_sequence_modifiers(wd, &seq->modifiers);
- }
- SEQ_END
+ } SEQ_END;
/* new; meta stack too, even when its nasty restore code */
for (MetaStack *ms = ed->metastack.first; ms; ms = ms->next) {
@@ -2880,10 +2878,10 @@ static void write_area_regions(WriteData *wd, ScrArea *area)
}
else if (sl->spacetype == SPACE_IPO) {
SpaceIpo *sipo = (SpaceIpo *)sl;
- ListBase tmpGhosts = sipo->ghostCurves;
+ ListBase tmpGhosts = sipo->runtime.ghost_curves;
/* temporarily disable ghost curves when saving */
- sipo->ghostCurves.first = sipo->ghostCurves.last = NULL;
+ BLI_listbase_clear(&sipo->runtime.ghost_curves);
writestruct(wd, DATA, SpaceIpo, 1, sl);
if (sipo->ads) {
@@ -2891,7 +2889,7 @@ static void write_area_regions(WriteData *wd, ScrArea *area)
}
/* reenable ghost curves */
- sipo->ghostCurves = tmpGhosts;
+ sipo->runtime.ghost_curves = tmpGhosts;
}
else if (sl->spacetype == SPACE_BUTS) {
writestruct(wd, DATA, SpaceButs, 1, sl);
@@ -3157,7 +3155,7 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree)
#ifdef USE_NODE_COMPAT_CUSTOMNODES
static void customnodes_add_deprecated_data(Main *mainvar)
{
- FOREACH_NODETREE(mainvar, ntree, id) {
+ FOREACH_NODETREE_BEGIN(mainvar, ntree, id) {
bNodeLink *link, *last_link = ntree->links.last;
/* only do this for node groups */
@@ -3204,13 +3202,12 @@ static void customnodes_add_deprecated_data(Main *mainvar)
break;
}
}
- }
- FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
static void customnodes_free_deprecated_data(Main *mainvar)
{
- FOREACH_NODETREE(mainvar, ntree, id) {
+ FOREACH_NODETREE_BEGIN(mainvar, ntree, id) {
bNodeLink *link, *next_link;
for (link = ntree->links.first; link; link = next_link) {
@@ -3219,8 +3216,7 @@ static void customnodes_free_deprecated_data(Main *mainvar)
nodeRemLink(ntree, link);
}
}
- }
- FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
#endif
@@ -3817,7 +3813,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
}
/* preview image, first 2 values are width and height
- * second are an RGBA image (unsigned char)
+ * second are an RGBA image (uchar)
* note, this uses 'TEST' since new types will segfault on file load for older blender versions.
*/
static void write_thumb(WriteData *wd, const BlendThumbnail *thumb)
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index 1b300b24808..8f124afc55b 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -99,7 +99,7 @@ void BM_edges_from_verts_ensure(BMesh *bm, BMEdge **edge_arr, BMVert **vert_arr,
/* prototypes */
static void bm_loop_attrs_copy(
BMesh *source_mesh, BMesh *target_mesh,
- const BMLoop *source_loop, BMLoop *target_loop);
+ const BMLoop *source_loop, BMLoop *target_loop, uint64_t cd_mask);
/**
* \brief Make Quad/Triangle
@@ -169,7 +169,7 @@ void BM_face_copy_shared(
BLI_assert(l_dst[j]->v == l_src[j]->v);
if (BM_ELEM_API_FLAG_TEST(l_dst[j], _FLAG_OVERLAP) == 0) {
if ((filter_fn == NULL) || filter_fn(l_src[j], user_data)) {
- bm_loop_attrs_copy(bm, bm, l_src[j], l_dst[j]);
+ bm_loop_attrs_copy(bm, bm, l_src[j], l_dst[j], 0x0);
BM_ELEM_API_FLAG_ENABLE(l_dst[j], _FLAG_OVERLAP);
}
}
@@ -486,13 +486,15 @@ void BM_verts_sort_radial_plane(BMVert **vert_arr, int len)
static void bm_vert_attrs_copy(
BMesh *source_mesh, BMesh *target_mesh,
- const BMVert *source_vertex, BMVert *target_vertex)
+ const BMVert *source_vertex, BMVert *target_vertex, uint64_t cd_mask)
{
if ((source_mesh == target_mesh) && (source_vertex == target_vertex)) {
BLI_assert(!"BMVert: source and targer match");
return;
}
- copy_v3_v3(target_vertex->no, source_vertex->no);
+ if ((cd_mask & CD_MASK_NORMAL) == 0) {
+ copy_v3_v3(target_vertex->no, source_vertex->no);
+ }
CustomData_bmesh_free_block_data(&target_mesh->vdata, target_vertex->head.data);
CustomData_bmesh_copy_data(&source_mesh->vdata, &target_mesh->vdata,
source_vertex->head.data, &target_vertex->head.data);
@@ -500,7 +502,7 @@ static void bm_vert_attrs_copy(
static void bm_edge_attrs_copy(
BMesh *source_mesh, BMesh *target_mesh,
- const BMEdge *source_edge, BMEdge *target_edge)
+ const BMEdge *source_edge, BMEdge *target_edge, uint64_t UNUSED(cd_mask))
{
if ((source_mesh == target_mesh) && (source_edge == target_edge)) {
BLI_assert(!"BMEdge: source and targer match");
@@ -513,7 +515,7 @@ static void bm_edge_attrs_copy(
static void bm_loop_attrs_copy(
BMesh *source_mesh, BMesh *target_mesh,
- const BMLoop *source_loop, BMLoop *target_loop)
+ const BMLoop *source_loop, BMLoop *target_loop, uint64_t UNUSED(cd_mask))
{
if ((source_mesh == target_mesh) && (source_loop == target_loop)) {
BLI_assert(!"BMLoop: source and targer match");
@@ -526,13 +528,15 @@ static void bm_loop_attrs_copy(
static void bm_face_attrs_copy(
BMesh *source_mesh, BMesh *target_mesh,
- const BMFace *source_face, BMFace *target_face)
+ const BMFace *source_face, BMFace *target_face, uint64_t cd_mask)
{
if ((source_mesh == target_mesh) && (source_face == target_face)) {
BLI_assert(!"BMFace: source and targer match");
return;
}
- copy_v3_v3(target_face->no, source_face->no);
+ if ((cd_mask & CD_MASK_NORMAL) == 0) {
+ copy_v3_v3(target_face->no, source_face->no);
+ }
CustomData_bmesh_free_block_data(&target_mesh->pdata, target_face->head.data);
CustomData_bmesh_copy_data(&source_mesh->pdata, &target_mesh->pdata,
source_face->head.data, &target_face->head.data);
@@ -548,7 +552,7 @@ static void bm_face_attrs_copy(
*/
void BM_elem_attrs_copy_ex(
BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v,
- const char hflag_mask)
+ const char hflag_mask, const uint64_t cd_mask)
{
const BMHeader *ele_src = ele_src_v;
BMHeader *ele_dst = ele_dst_v;
@@ -556,6 +560,9 @@ void BM_elem_attrs_copy_ex(
BLI_assert(ele_src->htype == ele_dst->htype);
BLI_assert(ele_src != ele_dst);
+ /* Only support normal layer at the moment. */
+ BLI_assert((cd_mask & ~CD_MASK_NORMAL) == 0);
+
if ((hflag_mask & BM_ELEM_SELECT) == 0) {
/* First we copy select */
if (BM_elem_flag_test((BMElem *)ele_src, BM_ELEM_SELECT)) {
@@ -577,16 +584,16 @@ void BM_elem_attrs_copy_ex(
/* Copy specific attributes */
switch (ele_dst->htype) {
case BM_VERT:
- bm_vert_attrs_copy(bm_src, bm_dst, (const BMVert *)ele_src, (BMVert *)ele_dst);
+ bm_vert_attrs_copy(bm_src, bm_dst, (const BMVert *)ele_src, (BMVert *)ele_dst, cd_mask);
break;
case BM_EDGE:
- bm_edge_attrs_copy(bm_src, bm_dst, (const BMEdge *)ele_src, (BMEdge *)ele_dst);
+ bm_edge_attrs_copy(bm_src, bm_dst, (const BMEdge *)ele_src, (BMEdge *)ele_dst, cd_mask);
break;
case BM_LOOP:
- bm_loop_attrs_copy(bm_src, bm_dst, (const BMLoop *)ele_src, (BMLoop *)ele_dst);
+ bm_loop_attrs_copy(bm_src, bm_dst, (const BMLoop *)ele_src, (BMLoop *)ele_dst, cd_mask);
break;
case BM_FACE:
- bm_face_attrs_copy(bm_src, bm_dst, (const BMFace *)ele_src, (BMFace *)ele_dst);
+ bm_face_attrs_copy(bm_src, bm_dst, (const BMFace *)ele_src, (BMFace *)ele_dst, cd_mask);
break;
default:
BLI_assert(0);
@@ -597,7 +604,7 @@ void BM_elem_attrs_copy_ex(
void BM_elem_attrs_copy(BMesh *bm_src, BMesh *bm_dst, const void *ele_src, void *ele_dst)
{
/* BMESH_TODO, default 'use_flags' to false */
- BM_elem_attrs_copy_ex(bm_src, bm_dst, ele_src, ele_dst, BM_ELEM_SELECT);
+ BM_elem_attrs_copy_ex(bm_src, bm_dst, ele_src, ele_dst, BM_ELEM_SELECT, 0x0);
}
void BM_elem_select_copy(BMesh *bm_dst, void *ele_dst_v, const void *ele_src_v)
@@ -644,7 +651,7 @@ static BMFace *bm_mesh_copy_new_face(
/* use totface in case adding some faces fails */
BM_elem_index_set(f_new, (bm_new->totface - 1)); /* set_inline */
- BM_elem_attrs_copy_ex(bm_old, bm_new, f, f_new, 0xff);
+ BM_elem_attrs_copy_ex(bm_old, bm_new, f, f_new, 0xff, 0x0);
f_new->head.hflag = f->head.hflag; /* low level! don't do this for normal api use */
j = 0;
@@ -701,7 +708,7 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
BM_ITER_MESH_INDEX (v, &iter, bm_old, BM_VERTS_OF_MESH, i) {
/* copy between meshes so cant use 'example' argument */
v_new = BM_vert_create(bm_new, v->co, NULL, BM_CREATE_SKIP_CD);
- BM_elem_attrs_copy_ex(bm_old, bm_new, v, v_new, 0xff);
+ BM_elem_attrs_copy_ex(bm_old, bm_new, v, v_new, 0xff, 0x0);
v_new->head.hflag = v->head.hflag; /* low level! don't do this for normal api use */
vtable[i] = v_new;
BM_elem_index_set(v, i); /* set_inline */
@@ -719,7 +726,7 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
vtable[BM_elem_index_get(e->v2)],
e, BM_CREATE_SKIP_CD);
- BM_elem_attrs_copy_ex(bm_old, bm_new, e, e_new, 0xff);
+ BM_elem_attrs_copy_ex(bm_old, bm_new, e, e_new, 0xff, 0x0);
e_new->head.hflag = e->head.hflag; /* low level! don't do this for normal api use */
etable[i] = e_new;
BM_elem_index_set(e, i); /* set_inline */
diff --git a/source/blender/bmesh/intern/bmesh_construct.h b/source/blender/bmesh/intern/bmesh_construct.h
index a52a17cd2f3..1a2b6e46c39 100644
--- a/source/blender/bmesh/intern/bmesh_construct.h
+++ b/source/blender/bmesh/intern/bmesh_construct.h
@@ -55,7 +55,7 @@ BMFace *BM_face_create_ngon_verts(
void BM_elem_attrs_copy_ex(
BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v,
- const char hflag_mask);
+ const char hflag_mask, const uint64_t cd_mask);
void BM_elem_attrs_copy(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v);
void BM_elem_select_copy(BMesh *bm_dst, void *ele_dst_v, const void *ele_src_v);
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index cc023be3004..408f1e83ff5 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1854,7 +1854,7 @@ static BMOpDefine bmo_bevel_def = {
{{"faces.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* output faces */
{"edges.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* output edges */
{"verts.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, /* output verts */
- {"normals.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}}, /* output normals per vertex for beveled edges */
+ {"normals.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL}}, /* output normals per vertex for beveled edges */
{{'\0'}},
},
diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c
index c446ce5ab49..cc042bd001c 100644
--- a/source/blender/bmesh/intern/bmesh_query.c
+++ b/source/blender/bmesh/intern/bmesh_query.c
@@ -2063,6 +2063,40 @@ BMFace *BM_face_exists(BMVert **varr, int len)
return NULL;
}
+/**
+ * Check if the face has an exact duplicate (both winding directions).
+ */
+BMFace *BM_face_find_double(BMFace *f)
+{
+ BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
+ for (BMLoop *l_iter = l_first->radial_next; l_first != l_iter; l_iter = l_iter->radial_next) {
+ if (l_iter->f->len == l_first->f->len) {
+ if (l_iter->v == l_first->v) {
+ BMLoop *l_a = l_first, *l_b = l_iter, *l_b_init = l_iter;
+ do {
+ if (l_a->e != l_b->e) {
+ break;
+ }
+ } while (((void)(l_a = l_a->next), (l_b = l_b->next)) != l_b_init);
+ if (l_b == l_b_init) {
+ return l_iter->f;
+ }
+ }
+ else {
+ BMLoop *l_a = l_first, *l_b = l_iter, *l_b_init = l_iter;
+ do {
+ if (l_a->e != l_b->e) {
+ break;
+ }
+ } while (((void)(l_a = l_a->prev), (l_b = l_b->next)) != l_b_init);
+ if (l_b == l_b_init) {
+ return l_iter->f;
+ }
+ }
+ }
+ }
+ return NULL;
+}
/**
* Given a set of vertices and edges (\a varr, \a earr), find out if
diff --git a/source/blender/bmesh/intern/bmesh_query.h b/source/blender/bmesh/intern/bmesh_query.h
index 7c087a5150f..e5830a25312 100644
--- a/source/blender/bmesh/intern/bmesh_query.h
+++ b/source/blender/bmesh/intern/bmesh_query.h
@@ -141,6 +141,7 @@ BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2) ATTR_WARN_UNUSED_RESULT ATTR_NONN
BMEdge *BM_edge_find_double(BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
BMFace *BM_face_exists(BMVert **varr, int len) ATTR_NONNULL(1);
+BMFace *BM_face_find_double(BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BM_face_exists_multi_edge(BMEdge **earr, int len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c
index 8bc219d8421..656a446d5ab 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -63,6 +63,9 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
BMO_ITER (e, &siter, op->slots_in, "geom", BM_EDGE) {
if (BM_edge_is_manifold(e)) {
BM_elem_flag_enable(e, BM_ELEM_TAG);
+ /* in case verts were not also included in the geom */
+ BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
+ BM_elem_flag_enable(e->v2, BM_ELEM_TAG);
}
}
diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c
index c50c7657deb..77019e13969 100644
--- a/source/blender/bmesh/operators/bmo_dupe.c
+++ b/source/blender/bmesh/operators/bmo_dupe.c
@@ -564,6 +564,21 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op)
i++;
}
}
+ /* Full copies of faces may cause overlap. */
+ for (int i = 0; i < elem_array_len; ) {
+ if (elem_array[i]->head.htype == BM_FACE) {
+ BMFace *f_src = (BMFace *)elem_array[i];
+ BMFace *f_dst = BM_face_find_double(f_src);
+ if (f_dst != NULL) {
+ BM_face_kill(bm, f_src);
+ elem_array_len--;
+ elem_array[i] = elem_array[elem_array_len];
+ }
+ }
+ else {
+ i++;
+ }
+ }
slot_geom_out->len = elem_array_len;
}
BMO_op_finish(bm, &extop);
diff --git a/source/blender/collada/AnimationCurveCache.cpp b/source/blender/collada/AnimationCurveCache.cpp
deleted file mode 100644
index f580ffce7bb..00000000000
--- a/source/blender/collada/AnimationCurveCache.cpp
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
-* ***** 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): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed.
-*
-* ***** END GPL LICENSE BLOCK *****
-*/
-
-#include "AnimationCurveCache.h"
-
-extern "C" {
-#include "BKE_action.h"
-#include "BLI_listbase.h"
-}
-
-AnimationCurveCache::AnimationCurveCache(bContext *C):
- mContext(C)
-{
-}
-
-AnimationCurveCache::~AnimationCurveCache()
-{
- clear_cache();
-}
-
-void AnimationCurveCache::clear_cache()
-{
-
-}
-
-void AnimationCurveCache::clear_cache(Object *ob)
-{
-
-}
-
-void AnimationCurveCache::create_curves(Object *ob)
-{
-
-}
-
-void AnimationCurveCache::addObject(Object *ob)
-{
- cached_objects.push_back(ob);
-}
-
-bool AnimationCurveCache::bone_matrix_local_get(Object *ob, Bone *bone, float(&mat)[4][4], bool for_opensim)
-{
-
- /* Ok, lets be super cautious and check if the bone exists */
- bPose *pose = ob->pose;
- bPoseChannel *pchan = BKE_pose_channel_find_name(pose, bone->name);
- if (!pchan) {
- return false;
- }
-
- bAction *action = bc_getSceneObjectAction(ob);
- bPoseChannel *parchan = pchan->parent;
- enable_fcurves(action, bone->name);
- float ipar[4][4];
-
- if (bone->parent) {
- invert_m4_m4(ipar, parchan->pose_mat);
- mul_m4_m4m4(mat, ipar, pchan->pose_mat);
- }
- else
- copy_m4_m4(mat, pchan->pose_mat);
-
- /* OPEN_SIM_COMPATIBILITY
- * AFAIK animation to second life is via BVH, but no
- * reason to not have the collada-animation be correct
- */
- if (for_opensim) {
- float temp[4][4];
- copy_m4_m4(temp, bone->arm_mat);
- temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
- invert_m4(temp);
-
- mul_m4_m4m4(mat, mat, temp);
-
- if (bone->parent) {
- copy_m4_m4(temp, bone->parent->arm_mat);
- temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
-
- mul_m4_m4m4(mat, temp, mat);
- }
- }
-
- return true;
-}
-
-void AnimationCurveCache::sampleMain(Scene *scene, BC_export_transformation_type atm_type, bool for_opensim)
-{
- std::map<int, std::vector<SamplePoint>>::iterator frame;
- for (frame = sample_frames.begin(); frame != sample_frames.end(); frame++) {
- int frame_index = frame->first;
- std::vector<SamplePoint> sample_points = frame->second;
-
- bc_update_scene(mContext, scene, frame_index);
-
- for (int spi = 0; spi < sample_points.size(); spi++) {
- SamplePoint &point = sample_points[spi];
- Object *ob = point.get_object();
- float mat[4][4];
-
- if (ob->type == OB_ARMATURE) {
- /* For Armatures we need to check if this maybe is a pose sample point*/
- Bone *bone = point.get_bone();
- if (bone) {
- if (bone_matrix_local_get(ob, bone, mat, for_opensim)) {
- point.set_matrix(mat);
- }
- continue;
- }
- }
-
- /* When this SamplePoint is not for a Bone,
- * then we just store the Object local matrix here
- */
-
- BKE_object_matrix_local_get(ob, mat);
- point.set_matrix(mat);
-
- }
- }
-}
-
-/*
-* enable fcurves driving a specific bone, disable all the rest
-* if bone_name = NULL enable all fcurves
-*/
-void AnimationCurveCache::enable_fcurves(bAction *act, char *bone_name)
-{
- FCurve *fcu;
- char prefix[200];
-
- if (bone_name)
- BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone_name);
-
- for (fcu = (FCurve *)act->curves.first; fcu; fcu = fcu->next) {
- if (bone_name) {
- if (STREQLEN(fcu->rna_path, prefix, strlen(prefix)))
- fcu->flag &= ~FCURVE_DISABLED;
- else
- fcu->flag |= FCURVE_DISABLED;
- }
- else {
- fcu->flag &= ~FCURVE_DISABLED;
- }
- }
-}
-/*
-* Sample the scene at frames where object fcurves
-* have defined keys.
-*/
-void AnimationCurveCache::sampleScene(Scene *scene, BC_export_transformation_type atm_type, bool for_opensim, bool keyframe_at_end)
-{
- create_sample_frames_from_keyframes();
- sampleMain(scene, atm_type, for_opensim);
-}
-
-void AnimationCurveCache::sampleScene(Scene *scene, BC_export_transformation_type atm_type, int sampling_rate, bool for_opensim, bool keyframe_at_end)
-{
- create_sample_frames_generated(scene->r.sfra, scene->r.efra, sampling_rate, keyframe_at_end);
- sampleMain(scene, atm_type, for_opensim);
-}
-
-std::vector<FCurve *> *AnimationCurveCache::getSampledCurves(Object *ob)
-{
- std::map<Object *, std::vector<FCurve *>>::iterator fcurves;
- fcurves = cached_curves.find(ob);
- return (fcurves == cached_curves.end()) ? NULL : &fcurves->second;
-}
-
-std::vector<SamplePoint> &AnimationCurveCache::getFrameInfos(int frame_index)
-{
- std::map<int, std::vector<SamplePoint>>::iterator frames = sample_frames.find(frame_index);
- if (frames == sample_frames.end()) {
- std::vector<SamplePoint> sample_points;
- sample_frames[frame_index] = sample_points;
- }
- return sample_frames[frame_index];
-}
-
-
-void AnimationCurveCache::add_sample_point(SamplePoint &point)
-{
- int frame_index = point.get_frame();
- std::vector<SamplePoint> &frame_infos = getFrameInfos(frame_index);
- frame_infos.push_back(point);
-}
-
-/*
-* loop over all cached objects
-* loop over all fcurves
-* record all keyframes
-*
-* The vector sample_frames finally contains a list of vectors
-* where each vector contains a list of SamplePoints which
-* need to be processed when evaluating the animation.
-*/
-void AnimationCurveCache::create_sample_frames_from_keyframes()
-{
- sample_frames.clear();
- for (int i = 0; i < cached_objects.size(); i++) {
- Object *ob = cached_objects[i];
- bAction *action = bc_getSceneObjectAction(ob);
- FCurve *fcu = (FCurve *)action->curves.first;
-
- for (; fcu; fcu = fcu->next) {
- for (unsigned int i = 0; i < fcu->totvert; i++) {
- float f = fcu->bezt[i].vec[1][0];
- int frame_index = int(f);
- SamplePoint sample_point(frame_index, ob, fcu, i);
- add_sample_point(sample_point);
- }
- }
- }
-}
-
-/*
-* loop over all cached objects
-* loop over active action using a stesize of sampling_rate
-* record all frames
-*
-* The vector sample_frames finally contains a list of vectors
-* where each vector contains a list of SamplePoints which
-* need to be processed when evaluating the animation.
-* Note: The FCurves of the objects will not be used here.
-*/
-void AnimationCurveCache::create_sample_frames_generated(float sfra, float efra, int sampling_rate, int keyframe_at_end)
-{
- sample_frames.clear();
-
- for (int i = 0; i < cached_objects.size(); i++) {
-
- Object *ob = cached_objects[i];
- float f = sfra;
-
- do {
- int frame_index = int(f);
- SamplePoint sample_point(frame_index, ob);
- add_sample_point(sample_point);
-
- /* Depending on the Object type add more sample points here
- */
-
- if (ob && ob->type == OB_ARMATURE) {
- LISTBASE_FOREACH(bPoseChannel *, pchan, &ob->pose->chanbase) {
- SamplePoint point(frame_index, ob, pchan->bone);
- add_sample_point(sample_point);
- }
- }
-
- if (f == efra)
- break;
- f += sampling_rate;
- if (f > efra)
- if (keyframe_at_end)
- f = efra; // make sure the last frame is always exported
- else
- break;
- } while (true);
- }
-}
-
-Matrix::Matrix()
-{
- unit_m4(matrix);
-}
-
-Matrix::Matrix(float (&mat)[4][4])
-{
- set_matrix(mat);
-}
-
-void Matrix::set_matrix(float(&mat)[4][4])
-{
- copy_m4_m4(matrix, mat);
-}
-
-void Matrix::set_matrix(Matrix &mat)
-{
- copy_m4_m4(matrix, mat.matrix);
-}
-
-void Matrix::get_matrix(float(&mat)[4][4])
-{
- copy_m4_m4(mat, matrix);
-}
-
-SamplePoint::SamplePoint(int frame, Object *ob)
-{
- this->frame = frame;
- this->fcu = NULL;
- this->ob = ob;
- this->pose_bone = NULL;
- this->index = -1;
-}
-
-SamplePoint::SamplePoint(int frame, Object *ob, FCurve *fcu, int index)
-{
- this->frame = frame;
- this->fcu = fcu;
- this->ob = ob;
- this->pose_bone = NULL;
- this->index = index;
- this->path = std::string(fcu->rna_path);
-
- /* Further elaborate on what this Fcurve is doing by checking
- * its rna_path
- */
-
- if (ob && ob->type == OB_ARMATURE) {
- char *boneName = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
- bPose *pose = ob->pose;
- if (boneName) {
- bPoseChannel *pchan = BKE_pose_channel_find_name(pose, boneName);
- this->pose_bone = pchan->bone;
- }
- }
-}
-
-
-SamplePoint::SamplePoint(int frame, Object *ob, Bone *bone)
-{
- this->frame = frame;
- this->fcu = NULL;
- this->ob = ob;
- this->pose_bone = bone;
- this->index = -1;
- this->path = "pose.bones[\"" + id_name(bone) + "\"].matrix";
-}
-
-Matrix &SamplePoint::get_matrix()
-{
- return matrix;
-}
-
-void SamplePoint::set_matrix(Matrix &mat)
-{
- this->matrix.set_matrix(mat);
-}
-
-void SamplePoint::set_matrix(float(&mat)[4][4])
-{
-
-}
-
-Object *SamplePoint::get_object()
-{
- return this->ob;
-}
-
-Bone *SamplePoint::get_bone()
-{
- return this->pose_bone;
-}
-
-FCurve *SamplePoint::get_fcurve()
-{
- return this->fcu;
-}
-
-int SamplePoint::get_frame()
-{
- return this->frame;
-}
-
-int SamplePoint::get_fcurve_index()
-{
- return this->index;
-}
-
-std::string &SamplePoint::get_path()
-{
- return path;
-}
diff --git a/source/blender/collada/AnimationCurveCache.h b/source/blender/collada/AnimationCurveCache.h
deleted file mode 100644
index 3d74e93758e..00000000000
--- a/source/blender/collada/AnimationCurveCache.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
-* ***** 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): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed.
-*
-* ***** END GPL LICENSE BLOCK *****
-*/
-
-#ifndef __ANIMATION_CURVE_CACHE_H__
-#define __ANIMATION_CURVE_CACHE_H__
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include <vector>
-#include <map>
-#include <algorithm> // std::find
-
-#include "exportSettings.h"
-#include "collada_utils.h"
-
-extern "C"
-{
-#include "DNA_object_types.h"
-#include "DNA_anim_types.h"
-}
-
-class Matrix {
-private:
- float matrix[4][4];
-public:
- Matrix();
- Matrix(float (&mat)[4][4]);
- void set_matrix(float (&mat)[4][4]);
- void set_matrix(Matrix &mat);
- void get_matrix(float (&mat)[4][4]);
-};
-
-class SamplePoint {
-
-private:
-
- Object * ob;
- Bone *pose_bone;
- FCurve *fcu;
- int frame; /* frame in timeline (not sure if we actually should store a float here) */
- int index; /* Keyframe index in fcurve (makes sense only when fcu is also set) */
- std::string path; /* Do not mixup with rna_path. It is used for different purposes! */
-
- Matrix matrix; /* Local matrix, by default unit matrix, will be set when sampling */
-
-public:
-
- SamplePoint(int frame, Object *ob);
- SamplePoint(int frame, Object *ob, FCurve *fcu, int index);
- SamplePoint(int frame, Object *ob, Bone *bone);
-
- Object *get_object();
- Bone *get_bone();
- FCurve *get_fcurve();
- int get_frame();
- int get_fcurve_index();
- Matrix &get_matrix();
- std::string &get_path();
-
- void set_matrix(Matrix &matrix);
- void set_matrix(float(&mat)[4][4]);
-};
-
-
-class AnimationCurveCache {
-private:
- void clear_cache(); // remove all sampled FCurves
- void clear_cache(Object *ob); //remove sampled FCurves for single object
- void create_curves(Object *ob);
-
- std::vector<Object *> cached_objects; // list of objects for caching
- std::map<Object *, std::vector<FCurve *>> cached_curves; //map of cached FCurves
- std::map<int, std::vector<SamplePoint>> sample_frames; // list of frames where objects need to be sampled
-
- std::vector<SamplePoint> &getFrameInfos(int frame_index);
- void add_sample_point(SamplePoint &point);
- void enable_fcurves(bAction *act, char *bone_name);
- bool bone_matrix_local_get(Object *ob, Bone *bone, float (&mat)[4][4], bool for_opensim);
-
- bContext *mContext;
-
-public:
-
- AnimationCurveCache(bContext *C);
- ~AnimationCurveCache();
-
- void addObject(Object *obj);
-
- void sampleMain(Scene *scene,
- BC_export_transformation_type atm_type,
- bool for_opensim);
-
- void sampleScene(Scene *scene,
- BC_export_transformation_type atm_type,
- bool for_opensim,
- bool keyframe_at_end = true); // use keys from FCurves, use timeline boundaries
-
- void sampleScene(Scene *scene,
- BC_export_transformation_type atm_type,
- int sampling_rate, bool for_opensim,
- bool keyframe_at_end = true ); // generate keyframes for frames use timeline boundaries
-
- std::vector<FCurve *> *getSampledCurves(Object *ob);
-
- void create_sample_frames_from_keyframes();
- void create_sample_frames_generated(float sfra, float efra, int sampling_rate, int keyframe_at_end);
-};
-
-
-#endif
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index e3a8e517352..a4b14d9d175 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -1945,7 +1945,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No
job->lay = BKE_scene_base_find(scene, job)->lay = 2;
mul_v3_fl(job->size, 0.5f);
- DEG_id_tag_update(&job->id, OB_RECALC_OB);
+ DEG_id_tag_update(&job->id, ID_RECALC_TRANSFORM);
verify_adt_action((ID *)&job->id, 1);
@@ -1966,7 +1966,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No
if (par_job) {
job->parent = par_job;
- DEG_id_tag_update(&par_job->id, OB_RECALC_OB);
+ DEG_id_tag_update(&par_job->id, ID_RECALC_TRANSFORM);
job->parsubstr[0] = 0;
}
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index 2aa7b483110..055ffc39e9a 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -304,7 +304,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW:
}
if (this->export_settings->limit_precision)
- bc_sanitize_mat(mat, 6);
+ bc_sanitize_mat(mat, LIMITTED_PRECISION);
TransformWriter::add_node_transform(node, mat, NULL);
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index 32c7363a994..cfafa5016ec 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -172,7 +172,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon
}
copy_v3_v3(bone->head, mat[3]);
- if (bone_is_skinned)
+ if (bone_is_skinned && this->import_settings->keep_bind_info)
{
float rest_mat[4][4];
get_node_mat(rest_mat, node, NULL, NULL, NULL);
@@ -499,7 +499,7 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *>
ob_arms.push_back(ob_arm);
}
- DEG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_arm->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
}
@@ -632,7 +632,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo& skin)
ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
- DEG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_arm->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
return ob_arm;
}
diff --git a/source/blender/collada/BCAnimationCurve.cpp b/source/blender/collada/BCAnimationCurve.cpp
index 87cf07cc21c..74d852ae980 100644
--- a/source/blender/collada/BCAnimationCurve.cpp
+++ b/source/blender/collada/BCAnimationCurve.cpp
@@ -69,7 +69,7 @@ void BCAnimationCurve::init_pointer_rna(Object *ob)
switch (this->curve_key.get_animation_type()) {
case BC_ANIMATION_TYPE_BONE:
{
- bArmature * arm = (bArmature *)ob->data;
+ bArmature *arm = (bArmature *)ob->data;
RNA_id_pointer_create(&arm->id, &id_ptr);
}
break;
@@ -86,13 +86,13 @@ void BCAnimationCurve::init_pointer_rna(Object *ob)
break;
case BC_ANIMATION_TYPE_CAMERA:
{
- Camera * camera = (Camera *)ob->data;
+ Camera *camera = (Camera *)ob->data;
RNA_id_pointer_create(&camera->id, &id_ptr);
}
break;
case BC_ANIMATION_TYPE_LIGHT:
{
- Lamp * lamp = (Lamp *)ob->data;
+ Lamp *lamp = (Lamp *)ob->data;
RNA_id_pointer_create(&lamp->id, &id_ptr);
}
break;
@@ -188,7 +188,7 @@ const std::string BCAnimationCurve::get_animation_name(Object *ob) const
case BC_ANIMATION_TYPE_MATERIAL:
{
- Material * ma = give_current_material(ob, this->curve_key.get_subindex() + 1);
+ Material *ma = give_current_material(ob, this->curve_key.get_subindex() + 1);
name = id_name(ob) + "-" + id_name(ma) + "-material";
}
break;
diff --git a/source/blender/collada/BCAnimationSampler.h b/source/blender/collada/BCAnimationSampler.h
index 8bf2967a44f..ae0a04a706c 100644
--- a/source/blender/collada/BCAnimationSampler.h
+++ b/source/blender/collada/BCAnimationSampler.h
@@ -150,7 +150,7 @@ public:
}
BCSample &add(Object *ob, int frame_index);
- BCSampleFrame * get_frame(int frame_index); // returns NULL if frame does not exist
+ BCSampleFrame *get_frame(int frame_index); // returns NULL if frame does not exist
const int get_frames(std::vector<int> &frames) const;
const int get_frames(Object *ob, BCFrames &frames) const;
diff --git a/source/blender/collada/BlenderContext.cpp b/source/blender/collada/BlenderContext.cpp
index 536d517bd6e..2281b3dd529 100644
--- a/source/blender/collada/BlenderContext.cpp
+++ b/source/blender/collada/BlenderContext.cpp
@@ -25,14 +25,15 @@
*/
#include "BlenderContext.h"
+#include "BKE_scene.h"
BlenderContext::BlenderContext(bContext *C)
{
context = C;
main = CTX_data_main(C);
- depsgraph = CTX_data_depsgraph(C);
scene = CTX_data_scene(C);
- view_layer = DEG_get_evaluated_view_layer(depsgraph);
+ view_layer = CTX_data_view_layer(C);
+ depsgraph = nullptr; // create only when needed
}
bContext *BlenderContext::get_context()
@@ -42,6 +43,9 @@ bContext *BlenderContext::get_context()
Depsgraph *BlenderContext::get_depsgraph()
{
+ if (!depsgraph) {
+ depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+ }
return depsgraph;
}
@@ -50,6 +54,18 @@ Scene *BlenderContext::get_scene()
return scene;
}
+Scene *BlenderContext::get_evaluated_scene()
+{
+ Scene *scene_eval = DEG_get_evaluated_scene(get_depsgraph());
+ return scene_eval;
+}
+
+Object *BlenderContext::get_evaluated_object(Object *ob)
+{
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+ return ob_eval;
+}
+
ViewLayer *BlenderContext::get_view_layer()
{
return view_layer;
diff --git a/source/blender/collada/BlenderContext.h b/source/blender/collada/BlenderContext.h
index 648d97a7e86..e6157a5a7f2 100644
--- a/source/blender/collada/BlenderContext.h
+++ b/source/blender/collada/BlenderContext.h
@@ -49,6 +49,8 @@ public:
bContext *get_context();
Depsgraph *get_depsgraph();
Scene *get_scene();
+ Scene *get_evaluated_scene();
+ Object *get_evaluated_object(Object *ob);
ViewLayer *get_view_layer();
Main *get_main();
};
diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt
index f860dfac08b..8c2339497bf 100644
--- a/source/blender/collada/CMakeLists.txt
+++ b/source/blender/collada/CMakeLists.txt
@@ -24,6 +24,20 @@
# ***** END GPL LICENSE BLOCK *****
remove_strict_flags()
+FIND_FILE(OPENCOLLADA_ANIMATION_CLIP
+ NAMES
+ COLLADAFWAnimationClip.h
+ PATHS
+ ${OPENCOLLADA_INCLUDE_DIRS}
+ NO_DEFAULT_PATH
+ )
+
+IF(OPENCOLLADA_ANIMATION_CLIP)
+ message(STATUS "Found opencollada: ${OPENCOLLADA_ANIMATION_CLIP} ")
+ add_definitions(-DWITH_OPENCOLLADA_ANIMATION_CLIP)
+ELSE()
+ message(STATUS "opencollada: Build without animation clip support")
+ENDIF()
set(INC
.
diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp
index 7685a2b09a0..5ec199f086b 100644
--- a/source/blender/collada/ControllerExporter.cpp
+++ b/source/blender/collada/ControllerExporter.cpp
@@ -421,7 +421,13 @@ void ControllerExporter::add_joints_element(ListBase *defbase,
void ControllerExporter::add_bind_shape_mat(Object *ob)
{
double bind_mat[4][4];
- UnitConverter::mat4_to_dae_double(bind_mat, ob->obmat);
+ float f_obmat[4][4];
+ BKE_object_matrix_local_get(ob, f_obmat);
+
+ //UnitConverter::mat4_to_dae_double(bind_mat, ob->obmat);
+ UnitConverter::mat4_to_dae_double(bind_mat, f_obmat);
+ if (this->export_settings->limit_precision)
+ bc_sanitize_mat(bind_mat, LIMITTED_PRECISION);
addBindShapeTransform(bind_mat);
}
@@ -533,7 +539,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas
invert_m4_m4(mat, world);
UnitConverter::mat4_to_dae(inv_bind_mat, mat);
if (this->export_settings->limit_precision)
- bc_sanitize_mat(inv_bind_mat, 6);
+ bc_sanitize_mat(inv_bind_mat, LIMITTED_PRECISION);
source.appendValues(inv_bind_mat);
}
}
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 8eb9e5c969e..e59483fa93c 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -269,7 +269,7 @@ void DocumentImporter::finish()
delete objects_to_scale;
// update scene
- DEG_id_tag_update(&sce->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&sce->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(mContext, NC_OBJECT | ND_TRANSFORM, NULL);
}
@@ -406,7 +406,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod
Main *bmain = CTX_data_main(mContext);
Object *obn = BKE_object_copy(bmain, source_ob);
- DEG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
BKE_collection_object_add_from(bmain, sce, source_ob, obn);
if (instance_node) {
@@ -1148,6 +1148,19 @@ bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animat
return anim_importer.write_animation_list(animationList);
}
+#if WITH_OPENCOLLADA_ANIMATION_CLIP
+// Since opencollada 1.6.68
+// called on post-process stage after writeVisualScenes
+bool DocumentImporter::writeAnimationClip(const COLLADAFW::AnimationClip *animationClip)
+{
+ if (mImportStage == Fetching_Controller_data)
+ return true;
+
+ return true;
+ //return animation_clip_importer.write_animation_clip(animationClip); // TODO: implement import of AnimationClips
+}
+#endif
+
/** When this method is called, the writer must write the skin controller data.
* \return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeSkinControllerData(const COLLADAFW::SkinControllerData *skin)
diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h
index 26ded417aa6..58aed43600f 100644
--- a/source/blender/collada/DocumentImporter.h
+++ b/source/blender/collada/DocumentImporter.h
@@ -49,8 +49,6 @@
#include "MeshImporter.h"
#include "ImportSettings.h"
-
-
struct bContext;
/** Importer class. */
@@ -107,6 +105,11 @@ public:
bool writeAnimationList(const COLLADAFW::AnimationList*);
+#if WITH_OPENCOLLADA_ANIMATION_CLIP
+ // Please enable this when building with Collada 1.6.65 or newer (also in DocumentImporter.cpp)
+ bool writeAnimationClip(const COLLADAFW::AnimationClip *animationClip);
+#endif
+
bool writeGeometry(const COLLADAFW::Geometry*);
bool writeMaterial(const COLLADAFW::Material*);
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
index 5c702304e27..f16392cdc1c 100644
--- a/source/blender/collada/EffectExporter.cpp
+++ b/source/blender/collada/EffectExporter.cpp
@@ -53,9 +53,9 @@ static std::string getActiveUVLayerName(Object *ob)
{
Mesh *me = (Mesh *)ob->data;
- int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
+ int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
if (num_layers)
- return std::string(bc_CustomData_get_active_layer_name(&me->fdata, CD_MTFACE));
+ return std::string(bc_CustomData_get_active_layer_name(&me->ldata, CD_MLOOPUV));
return "";
}
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
index 8b4302f3470..bb69c3fc653 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -101,7 +101,7 @@ void GeometryExporter::operator()(Object *ob)
// writes <source> for normal coords
createNormalsSource(geom_id, me, nor);
- bool has_uvs = (bool)CustomData_has_layer(&me->fdata, CD_MTFACE);
+ bool has_uvs = (bool)CustomData_has_layer(&me->ldata, CD_MLOOPUV);
// writes <source> for uv coords if mesh has uv coords
if (has_uvs) {
@@ -187,7 +187,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
// writes <source> for normal coords
createNormalsSource(geom_id, me, nor);
- bool has_uvs = (bool)CustomData_has_layer(&me->fdata, CD_MTFACE);
+ bool has_uvs = (bool)CustomData_has_layer(&me->ldata, CD_MLOOPUV);
// writes <source> for uv coords if mesh has uv coords
if (has_uvs) {
@@ -346,16 +346,17 @@ void GeometryExporter::createPolylist(short material_index,
til.push_back(input2);
// if mesh has uv coords writes <input> for TEXCOORD
- int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
- int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE)-1;
+ int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
+ int active_uv_index = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV);
for (i = 0; i < num_layers; i++) {
- if (!this->export_settings->active_uv_only || i == active_uv_index) {
+ int layer_index = CustomData_get_layer_index_n(&me->ldata, CD_MLOOPUV, i);
+ if (!this->export_settings->active_uv_only || layer_index == active_uv_index) {
- // char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i);
+ // char *name = CustomData_get_layer_name(&me->ldata, CD_MLOOPUV, i);
COLLADASW::Input input3(COLLADASW::InputSemantic::TEXCOORD,
makeUrl(makeTexcoordSourceId(geom_id, i, this->export_settings->active_uv_only)),
2, // this is only until we have optimized UV sets
- (this->export_settings->active_uv_only) ? 0 : i // only_active_uv exported -> we have only one set
+ (this->export_settings->active_uv_only) ? 0 : layer_index // only_active_uv exported -> we have only one set
);
til.push_back(input3);
}
diff --git a/source/blender/collada/InstanceWriter.cpp b/source/blender/collada/InstanceWriter.cpp
index 68842596550..0c0b1a15653 100644
--- a/source/blender/collada/InstanceWriter.cpp
+++ b/source/blender/collada/InstanceWriter.cpp
@@ -57,13 +57,14 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia
// create <bind_vertex_input> for each uv map
Mesh *me = (Mesh *)ob->data;
- int totlayer = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
+
+ int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
int map_index = 0;
- int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE) -1;
- for (int b = 0; b < totlayer; b++) {
+ int active_uv_index = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV);
+ for (int b = 0; b < num_layers; b++) {
if (!active_uv_only || b == active_uv_index) {
- char *name = bc_CustomData_get_layer_name(&me->fdata, CD_MTFACE, b);
+ char *name = bc_CustomData_get_layer_name(&me->ldata, CD_MLOOPUV, b);
im.push_back(COLLADASW::BindVertexInput(name, "TEXCOORD", map_index++));
}
}
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index 9a7a3aa673d..3e375b14e44 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -36,10 +36,10 @@ extern "C" {
void SceneExporter::exportScene()
{
- ViewLayer *view_layer = blender_context.get_view_layer();
+ Scene *scene = blender_context.get_scene();
// <library_visual_scenes> <visual_scene>
- std::string name = id_name(view_layer);
+ std::string name = id_name(scene);
openVisualScene(translate_id(name), encode_xml(name));
exportHierarchy();
closeVisualScene();
@@ -136,7 +136,12 @@ void SceneExporter::writeNodes(Object *ob)
TransformWriter::add_node_transform_identity(colladaNode);
}
else {
- TransformWriter::add_node_transform_ob(colladaNode, ob, this->export_settings->export_transformation_type);
+ TransformWriter::add_node_transform_ob(
+ colladaNode,
+ ob,
+ this->export_settings->export_transformation_type,
+ this->export_settings->limit_precision
+ );
}
// <instance_geometry>
diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp
index c55aca7976f..317d39c015b 100644
--- a/source/blender/collada/SkinInfo.cpp
+++ b/source/blender/collada/SkinInfo.cpp
@@ -244,7 +244,7 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
BKE_object_workob_calc_parent(scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
- DEG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
#endif
copy_m4_m4(ob->obmat, bind_shape_matrix);
BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp
index 9f75a604f96..4ff9e0af50f 100644
--- a/source/blender/collada/TransformWriter.cpp
+++ b/source/blender/collada/TransformWriter.cpp
@@ -33,7 +33,7 @@
#include "TransformWriter.h"
-void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[4][4], float parent_mat[4][4])
+void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[4][4], float parent_mat[4][4], bool limit_precision)
{
float loc[3], rot[3], scale[3];
float local[4][4];
@@ -63,8 +63,11 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[4][4],
}
}
-void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob,
- BC_export_transformation_type transformation_type)
+void TransformWriter::add_node_transform_ob(
+ COLLADASW::Node& node,
+ Object *ob,
+ BC_export_transformation_type transformation_type,
+ bool limit_precision)
{
#if 0
float rot[3], loc[3], scale[3];
@@ -101,17 +104,18 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob,
add_transform(node, loc, rot, scale);
#endif
- UnitConverter converter;
- double d_obmat[4][4];
- float f_obmat[4][4];
-
/* Export the local Matrix (relative to the object parent, be it an object, bone or vertex(-tices)) */
+ float f_obmat[4][4];
BKE_object_matrix_local_get(ob, f_obmat);
- converter.mat4_to_dae_double(d_obmat, f_obmat);
switch (transformation_type) {
case BC_TRANSFORMATION_TYPE_MATRIX:
{
+ UnitConverter converter;
+ double d_obmat[4][4];
+ converter.mat4_to_dae_double(d_obmat, f_obmat);
+ if (limit_precision)
+ bc_sanitize_mat(d_obmat, LIMITTED_PRECISION);
node.addMatrix("transform",d_obmat);
break;
}
@@ -119,6 +123,11 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob,
{
float loc[3], rot[3], scale[3];
bc_decompose(f_obmat, loc, rot, NULL, scale);
+ if (limit_precision) {
+ bc_sanitize_v3(loc, LIMITTED_PRECISION);
+ bc_sanitize_v3(rot, LIMITTED_PRECISION);
+ bc_sanitize_v3(scale, LIMITTED_PRECISION);
+ }
add_transform(node, loc, rot, scale);
break;
}
diff --git a/source/blender/collada/TransformWriter.h b/source/blender/collada/TransformWriter.h
index 580430911f7..2c7fedb9f34 100644
--- a/source/blender/collada/TransformWriter.h
+++ b/source/blender/collada/TransformWriter.h
@@ -39,10 +39,17 @@
class TransformWriter
{
protected:
- void add_node_transform(COLLADASW::Node& node, float mat[4][4], float parent_mat[4][4]);
-
- void add_node_transform_ob(COLLADASW::Node& node, Object *ob,
- BC_export_transformation_type transformation_type);
+ void add_node_transform(
+ COLLADASW::Node& node,
+ float mat[4][4],
+ float parent_mat[4][4],
+ bool limit_precision=false);
+
+ void add_node_transform_ob(
+ COLLADASW::Node& node,
+ Object *ob,
+ BC_export_transformation_type transformation_type,
+ bool limit_precision = false);
void add_node_transform_identity(COLLADASW::Node& node);
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 41e661ffd40..3716f334d5b 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -183,8 +183,8 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
BKE_object_workob_calc_parent(depsgraph, sce, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
- DEG_id_tag_update(&par->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&par->id, ID_RECALC_TRANSFORM);
return true;
}
@@ -243,7 +243,7 @@ Object *bc_add_object(Main *bmain, Scene *scene, ViewLayer *view_layer, int type
ob->data = BKE_object_obdata_add_from_type(bmain, type, name);
ob->lay = scene->lay;
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
LayerCollection *layer_collection = BKE_layer_collection_get_active(view_layer);
BKE_collection_object_add(bmain, layer_collection->collection, ob);
@@ -263,7 +263,6 @@ Mesh *bc_get_mesh_copy(
bool triangulate)
{
CustomDataMask mask = CD_MASK_MESH;
- Mesh *mesh = (Mesh *)ob->data;
Mesh *tmpmesh = NULL;
if (apply_modifiers) {
#if 0 /* Not supported by new system currently... */
@@ -281,12 +280,13 @@ Mesh *bc_get_mesh_copy(
}
#else
Depsgraph *depsgraph = blender_context.get_depsgraph();
- Scene *scene = blender_context.get_scene();
- tmpmesh = mesh_get_eval_final(depsgraph, scene, ob, mask);
+ Scene *scene_eval = blender_context.get_evaluated_scene();
+ Object *ob_eval = blender_context.get_evaluated_object(ob);
+ tmpmesh = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, mask);
#endif
}
else {
- tmpmesh = mesh;
+ tmpmesh = (Mesh *)ob->data;
}
BKE_id_copy_ex(NULL, &tmpmesh->id, (ID **)&tmpmesh,
@@ -443,7 +443,7 @@ bool bc_is_root_bone(Bone *aBone, bool deform_bones_only)
int bc_get_active_UVLayer(Object *ob)
{
Mesh *me = (Mesh *)ob->data;
- return CustomData_get_active_layer_index(&me->fdata, CD_MTFACE);
+ return CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV);
}
std::string bc_url_encode(std::string data)
@@ -1135,6 +1135,15 @@ void bc_sanitize_mat(float mat[4][4], int precision)
}
}
+void bc_sanitize_v3(float v[3], int precision)
+{
+ for (int i = 0; i < 3; i++) {
+ double val = (double)v[i];
+ val = double_round(val, precision);
+ v[i] = (float)val;
+ }
+}
+
void bc_sanitize_mat(double mat[4][4], int precision)
{
for (int i = 0; i < 4; i++)
@@ -1142,6 +1151,13 @@ void bc_sanitize_mat(double mat[4][4], int precision)
mat[i][j] = double_round(mat[i][j], precision);
}
+void bc_sanitize_v3(double v[3], int precision)
+{
+ for (int i = 0; i < 3; i++) {
+ v[i] = double_round(v[i], precision);
+ }
+}
+
void bc_copy_m4_farray(float r[4][4], float *a)
{
for (int i = 0; i < 4; i++)
@@ -1186,9 +1202,9 @@ void bc_copy_m4d_v44(double (&r)[4][4], std::vector<std::vector<double>> &a)
*/
std::string bc_get_active_uvlayer_name(Mesh *me)
{
- int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
+ int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
if (num_layers) {
- char *layer_name = bc_CustomData_get_active_layer_name(&me->fdata, CD_MTFACE);
+ char *layer_name = bc_CustomData_get_active_layer_name(&me->ldata, CD_MLOOPUV);
if (layer_name) {
return std::string(layer_name);
}
@@ -1211,9 +1227,9 @@ std::string bc_get_active_uvlayer_name(Object *ob)
*/
std::string bc_get_uvlayer_name(Mesh *me, int layer)
{
- int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
+ int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
if (num_layers && layer < num_layers) {
- char *layer_name = bc_CustomData_get_layer_name(&me->fdata, CD_MTFACE, layer);
+ char *layer_name = bc_CustomData_get_layer_name(&me->ldata, CD_MLOOPUV, layer);
if (layer_name) {
return std::string(layer_name);
}
@@ -1298,7 +1314,7 @@ static bNodeSocket *bc_group_add_output_socket(bNodeTree *ntree, bNode *from_nod
void bc_make_group(bContext *C, bNodeTree *ntree, std::map<std::string, bNode *> nmap)
{
- bNode * gnode = node_group_make_from_selected(C, ntree, "ShaderNodeGroup", "ShaderNodeTree");
+ bNode *gnode = node_group_make_from_selected(C, ntree, "ShaderNodeGroup", "ShaderNodeTree");
bNodeTree *gtree = (bNodeTree *)gnode->id;
bc_group_add_input_socket(gtree, nmap["main"], 0, "Diffuse");
diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h
index 14d1948a42b..a79085f0282 100644
--- a/source/blender/collada/collada_utils.h
+++ b/source/blender/collada/collada_utils.h
@@ -74,6 +74,8 @@ extern "C" {
#include "BCSampleData.h"
#include "BlenderContext.h"
+constexpr int LIMITTED_PRECISION = 6;
+
struct Depsgraph;
typedef std::map<COLLADAFW::UniqueId, Image*> UidImageMap;
@@ -209,6 +211,8 @@ void bc_copy_v44_m4d(std::vector<std::vector<double>> &a, double(&r)[4][4]);
void bc_sanitize_mat(float mat[4][4], int precision);
void bc_sanitize_mat(double mat[4][4], int precision);
+void bc_sanitize_v3(double v[3], int precision);
+void bc_sanitize_v3(float v[3], int precision);
extern IDProperty *bc_get_IDProperty(Bone *bone, std::string key);
extern void bc_set_IDProperty(EditBone *ebone, const char *key, float value);
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index c87ba188677..410f5554069 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -55,6 +55,8 @@
#ifndef __DEG_DEPSGRAPH_H__
#define __DEG_DEPSGRAPH_H__
+#include "DNA_ID.h"
+
/* Dependency Graph */
typedef struct Depsgraph Depsgraph;
@@ -122,39 +124,7 @@ void DEG_graph_on_visible_update(struct Main *bmain, Depsgraph *depsgraph);
/* Update all dependency graphs when visible scenes/layers changes. */
void DEG_on_visible_update(struct Main *bmain, const bool do_time);
-/* Tag given ID for an update in all the dependency graphs. */
-typedef enum eDepsgraph_Tag {
- /* Object transformation changed, corresponds to OB_RECALC_OB. */
- DEG_TAG_TRANSFORM = (1 << 0),
- /* Object geometry changed, corresponds to OB_RECALC_DATA. */
- DEG_TAG_GEOMETRY = (1 << 1),
- /* Time changed and animation is to be re-evaluated, OB_RECALC_TIME. */
- DEG_TAG_TIME = (1 << 2),
- /* Particle system changed; values are aligned with PSYS_RECALC_xxx. */
- DEG_TAG_PSYS_REDO = (1 << 3),
- DEG_TAG_PSYS_RESET = (1 << 4),
- DEG_TAG_PSYS_TYPE = (1 << 5),
- DEG_TAG_PSYS_CHILD = (1 << 6),
- DEG_TAG_PSYS_PHYS = (1 << 7),
- DEG_TAG_PSYS_ALL = (DEG_TAG_PSYS_REDO |
- DEG_TAG_PSYS_RESET |
- DEG_TAG_PSYS_TYPE |
- DEG_TAG_PSYS_CHILD |
- DEG_TAG_PSYS_PHYS),
- /* Update copy on write component without flushing down the road. */
- DEG_TAG_COPY_ON_WRITE = (1 << 8),
- /* Tag shading components for update.
- * Only parameters of material changed).
- */
- DEG_TAG_SHADING_UPDATE = (1 << 9),
- DEG_TAG_SELECT_UPDATE = (1 << 10),
- DEG_TAG_BASE_FLAGS_UPDATE = (1 << 11),
- DEG_TAG_POINT_CACHE_UPDATE = (1 << 12),
- /* Only inform editors about the change. Don't modify datablock itself. */
- DEG_TAG_EDITORS_UPDATE = (1 << 13),
-} eDepsgraph_Tag;
-
-const char *DEG_update_tag_as_string(eDepsgraph_Tag flag);
+const char *DEG_update_tag_as_string(IDRecalcFlag flag);
void DEG_id_tag_update(struct ID *id, int flag);
void DEG_id_tag_update_ex(struct Main *bmain, struct ID *id, int flag);
@@ -166,8 +136,7 @@ void DEG_graph_id_tag_update(struct Main *bmain,
/* Mark a particular datablock type as having changing. This does
* not cause any updates but is used by external render engines to detect if for
- * example a datablock was removed.
- */
+ * example a datablock was removed. */
void DEG_id_type_tag(struct Main *bmain, short id_type);
void DEG_ids_clear_recalc(struct Main *bmain, Depsgraph *depsgraph);
@@ -237,6 +206,8 @@ void DEG_make_inactive(struct Depsgraph *depsgraph);
/* Evaluation Debug ------------------------------ */
+bool DEG_debug_is_evaluating(struct Depsgraph *depsgraph);
+
void DEG_debug_print_begin(struct Depsgraph *depsgraph);
void DEG_debug_print_eval(struct Depsgraph *depsgraph,
diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 93e9b5be2cc..a81dd4c8852 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -43,6 +43,7 @@ struct Depsgraph;
struct CacheFile;
struct EffectorWeights;
struct Collection;
+struct ID;
struct Main;
struct ModifierData;
struct Object;
@@ -139,11 +140,6 @@ void DEG_add_object_relation(struct DepsNodeHandle *node_handle,
struct Object *object,
eDepsObjectComponentType component,
const char *description);
-void DEG_add_object_relation_with_customdata(struct DepsNodeHandle *node_handle,
- struct Object *object,
- eDepsObjectComponentType component,
- uint64_t customdata_mask,
- const char *description);
void DEG_add_bone_relation(struct DepsNodeHandle *handle,
struct Object *object,
const char *bone_name,
@@ -153,6 +149,11 @@ void DEG_add_object_cache_relation(struct DepsNodeHandle *handle,
struct CacheFile *cache_file,
eDepsObjectComponentType component,
const char *description);
+/* Adds relation from DEG_OPCODE_GENERIC_DATABLOCK_UPDATE of a given ID.
+ * Is used for such entities as textures and images. */
+void DEG_add_generic_id_relation(struct DepsNodeHandle *node_handle,
+ struct ID *id,
+ const char *description);
/* Adds relations from the given component of a given object to the given node
* handle AND the component to the point cache component of the node's ID.
@@ -163,6 +164,7 @@ void DEG_add_object_pointcache_relation(struct DepsNodeHandle *node_handle,
const char *description);
void DEG_add_special_eval_flag(struct DepsNodeHandle *handle, struct ID *id, uint32_t flag);
+void DEG_add_customdata_mask(struct DepsNodeHandle *handle, struct Object *object, uint64_t mask);
struct ID *DEG_get_id_from_handle(struct DepsNodeHandle *node_handle);
struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *node_handle);
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index e3fa30cf688..c9fa6b0a035 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -73,6 +73,10 @@ bool DEG_id_type_any_updated(const struct Depsgraph *depsgraph);
/* Get additional evaluation flags for the given ID. */
uint32_t DEG_get_eval_flags_for_id(const struct Depsgraph *graph, struct ID *id);
+/* Get additional mesh CustomDataMask flags for the given object. */
+uint64_t DEG_get_customdata_mask_for_object(const struct Depsgraph *graph,
+ struct Object *object);
+
/* Get scene the despgraph is created for. */
struct Scene *DEG_get_evaluated_scene(const struct Depsgraph *graph);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index f7b2b482b1f..ab3ca9f70cf 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -135,20 +135,24 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
if ((id->recalc & ID_RECALC_ALL)) {
AnimData *adt = BKE_animdata_from_id(id);
if (adt != NULL && (adt->recalc & ADT_RECALC_ANIM) != 0) {
- flag |= DEG_TAG_TIME;
+ flag |= ID_RECALC_ANIMATION;
}
}
/* Tag rebuild if special evaluation flags changed. */
if (id_node->eval_flags != id_node->previous_eval_flags) {
- flag |= DEG_TAG_TRANSFORM | DEG_TAG_GEOMETRY;
+ flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY;
+ }
+ /* Tag rebuild if the custom data mask changed. */
+ if (id_node->customdata_mask != id_node->previous_customdata_mask) {
+ flag |= ID_RECALC_GEOMETRY;
}
if (!deg_copy_on_write_is_expanded(id_node->id_cow)) {
- flag |= DEG_TAG_COPY_ON_WRITE;
+ flag |= ID_RECALC_COPY_ON_WRITE;
/* This means ID is being added to the dependency graph first
* time, which is similar to "ob-visible-change"
*/
if (GS(id->name) == ID_OB) {
- flag |= OB_RECALC_OB | OB_RECALC_DATA;
+ flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY;
}
}
if (flag != 0) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index e59de4224c0..3fcaa12f036 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -163,12 +163,14 @@ IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
ID *id_cow = NULL;
IDComponentsMask previously_visible_components_mask = 0;
uint32_t previous_eval_flags = 0;
+ uint64_t previous_customdata_mask = 0;
IDInfo *id_info = (IDInfo *)BLI_ghash_lookup(id_info_hash_, id);
if (id_info != NULL) {
id_cow = id_info->id_cow;
previously_visible_components_mask =
id_info->previously_visible_components_mask;
previous_eval_flags = id_info->previous_eval_flags;
+ previous_customdata_mask = id_info->previous_customdata_mask;
/* Tag ID info to not free the CoW ID pointer. */
id_info->id_cow = NULL;
}
@@ -176,6 +178,7 @@ IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
id_node->previously_visible_components_mask =
previously_visible_components_mask;
id_node->previous_eval_flags = previous_eval_flags;
+ id_node->previous_customdata_mask = previous_customdata_mask;
/* Currently all ID nodes are supposed to have copy-on-write logic.
*
* NOTE: Zero number of components indicates that ID node was just created.
@@ -358,6 +361,7 @@ void DepsgraphNodeBuilder::begin_build()
id_info->previously_visible_components_mask =
id_node->visible_components_mask;
id_info->previous_eval_flags = id_node->eval_flags;
+ id_info->previous_customdata_mask = id_node->customdata_mask;
BLI_ghash_insert(id_info_hash_, id_node->id_orig, id_info);
id_node->id_cow = NULL;
}
@@ -485,6 +489,9 @@ void DepsgraphNodeBuilder::build_id(ID *id)
case ID_TXT:
/* Not a part of dependency graph. */
break;
+ case ID_CF:
+ build_cachefile((CacheFile *)id);
+ break;
default:
fprintf(stderr, "Unhandled ID %s\n", id->name);
BLI_assert(!"Should never happen");
@@ -572,6 +579,7 @@ void DepsgraphNodeBuilder::build_object(int base_index,
}
/* Create ID node for object and begin init. */
IDDepsNode *id_node = add_id_node(&object->id);
+ Object *object_cow = get_cow_datablock(object);
id_node->linked_state = linked_state;
if (object == scene_->camera) {
id_node->is_directly_visible = true;
@@ -579,7 +587,6 @@ void DepsgraphNodeBuilder::build_object(int base_index,
else {
id_node->is_directly_visible = is_visible;
}
- object->customdata_mask = 0;
/* Various flags, flushing from bases/collections. */
build_object_flags(base_index, object, linked_state);
/* Transform. */
@@ -657,6 +664,13 @@ void DepsgraphNodeBuilder::build_object(int base_index,
DEG_OPCODE_PLACEHOLDER,
"Dupli");
}
+ /* Syncronization back to original object. */
+ add_operation_node(&object->id,
+ DEG_NODE_TYPE_SYNCHRONIZE,
+ function_bind(BKE_object_synchronize_to_original,
+ _1,
+ object_cow),
+ DEG_OPCODE_SYNCHRONIZE_TO_ORIGINAL);
}
void DepsgraphNodeBuilder::build_object_flags(
@@ -956,7 +970,7 @@ void DepsgraphNodeBuilder::build_driver_variables(ID * id, FCurve *fcurve)
{
build_driver_id_property(id, fcurve->rna_path);
LISTBASE_FOREACH (DriverVar *, dvar, &fcurve->driver->variables) {
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
if (dtar->id == NULL) {
continue;
@@ -972,7 +986,7 @@ void DepsgraphNodeBuilder::build_driver_variables(ID * id, FCurve *fcurve)
build_driver_id_property(&proxy_from->id, dtar->rna_path);
}
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
@@ -1520,23 +1534,20 @@ void DepsgraphNodeBuilder::build_texture(Tex *texture)
build_image(texture->ima);
}
}
- /* Placeholder so we can add relations and tag ID node for update. */
add_operation_node(&texture->id,
- DEG_NODE_TYPE_PARAMETERS,
+ DEG_NODE_TYPE_GENERIC_DATABLOCK,
NULL,
- DEG_OPCODE_PLACEHOLDER);
+ DEG_OPCODE_GENERIC_DATABLOCK_UPDATE);
}
void DepsgraphNodeBuilder::build_image(Image *image) {
if (built_map_.checkIsBuiltAndTag(image)) {
return;
}
- /* Placeholder so we can add relations and tag ID node for update. */
add_operation_node(&image->id,
- DEG_NODE_TYPE_PARAMETERS,
+ DEG_NODE_TYPE_GENERIC_DATABLOCK,
NULL,
- DEG_OPCODE_PLACEHOLDER,
- "Image Eval");
+ DEG_OPCODE_GENERIC_DATABLOCK_UPDATE);
}
void DepsgraphNodeBuilder::build_compositor(Scene *scene)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index 3b795bf9d58..cdf1f6ed03d 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -235,6 +235,8 @@ struct DepsgraphNodeBuilder {
IDComponentsMask previously_visible_components_mask;
/* Special evaluation flag mask from the previous depsgraph. */
uint32_t previous_eval_flags;
+ /* Mesh CustomData mask from the previous depsgraph. */
+ uint64_t previous_customdata_mask;
};
protected:
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 8b3f35f7519..cb7349e5480 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -289,13 +289,16 @@ bool DepsgraphRelationBuilder::has_node(const OperationKey &key) const
return find_node(key) != NULL;
}
-void DepsgraphRelationBuilder::add_customdata_mask(const ComponentKey &key, uint64_t mask)
+void DepsgraphRelationBuilder::add_customdata_mask(Object *object, uint64_t mask)
{
- if (mask != 0) {
- OperationDepsNode *node = find_operation_node(key);
+ if (mask != 0 && object != NULL && object->type == OB_MESH) {
+ DEG::IDDepsNode *id_node = graph_->find_id_node(&object->id);
- if (node != NULL) {
- node->customdata_mask |= mask;
+ if (id_node == NULL) {
+ BLI_assert(!"ID should always be valid");
+ }
+ else {
+ id_node->customdata_mask |= mask;
}
}
}
@@ -497,6 +500,9 @@ void DepsgraphRelationBuilder::build_id(ID *id)
case ID_TXT:
/* Not a part of dependency graph. */
break;
+ case ID_CF:
+ build_cachefile((CacheFile *)id);
+ break;
default:
fprintf(stderr, "Unhandled ID %s\n", id->name);
BLI_assert(!"Should never happen");
@@ -677,6 +683,12 @@ void DepsgraphRelationBuilder::build_object(Base *base, Object *object)
}
/* Point caches. */
build_object_pointcache(object);
+ /* Syncronization back to original object. */
+ OperationKey synchronize_key(&object->id,
+ DEG_NODE_TYPE_SYNCHRONIZE,
+ DEG_OPCODE_SYNCHRONIZE_TO_ORIGINAL);
+ add_relation(
+ final_transform_key, synchronize_key, "Synchronize to Original");
}
void DepsgraphRelationBuilder::build_object_flags(Base *base, Object *object)
@@ -691,6 +703,12 @@ void DepsgraphRelationBuilder::build_object_flags(Base *base, Object *object)
DEG_NODE_TYPE_OBJECT_FROM_LAYER,
DEG_OPCODE_OBJECT_BASE_FLAGS);
add_relation(view_layer_done_key, object_flags_key, "Base flags flush");
+ /* Syncronization back to original object. */
+ OperationKey synchronize_key(&object->id,
+ DEG_NODE_TYPE_SYNCHRONIZE,
+ DEG_OPCODE_SYNCHRONIZE_TO_ORIGINAL);
+ add_relation(
+ object_flags_key, synchronize_key, "Synchronize to Original");
}
void DepsgraphRelationBuilder::build_object_data(Object *object)
@@ -825,7 +843,7 @@ void DepsgraphRelationBuilder::build_object_parent(Object *object)
add_relation(parent_key, ob_key, "Vertex Parent");
/* XXX not sure what this is for or how you could be done properly - lukas */
- add_customdata_mask(parent_key, CD_MASK_ORIGINDEX);
+ add_customdata_mask(object->parent, CD_MASK_ORIGINDEX);
ComponentKey transform_key(&object->parent->id, DEG_NODE_TYPE_TRANSFORM);
add_relation(transform_key, ob_key, "Vertex Parent TFM");
@@ -1034,7 +1052,8 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
}
/* if needs bbone shape, reference the segment computation */
if (BKE_constraint_target_uses_bbone(con, ct) &&
- bone_has_segments(ct->tar, ct->subtarget)) {
+ bone_has_segments(ct->tar, ct->subtarget))
+ {
opcode = DEG_OPCODE_BONE_SEGMENTS;
}
OperationKey target_key(&ct->tar->id,
@@ -1052,9 +1071,7 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
*/
ComponentKey target_key(&ct->tar->id, DEG_NODE_TYPE_GEOMETRY);
add_relation(target_key, constraint_op_key, cti->name);
- if (ct->tar->type == OB_MESH) {
- add_customdata_mask(target_key, CD_MASK_MDEFORMVERT);
- }
+ add_customdata_mask(ct->tar, CD_MASK_MDEFORMVERT);
}
else if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
@@ -1067,7 +1084,7 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
if (ct->tar->type == OB_MESH && scon->shrinkType != MOD_SHRINKWRAP_NEAREST_VERTEX) {
bool track = (scon->flag & CON_SHRINKWRAP_TRACK_NORMAL) != 0;
if (track || BKE_shrinkwrap_needs_normals(scon->shrinkType, scon->shrinkMode)) {
- add_customdata_mask(target_key, CD_MASK_NORMAL | CD_MASK_CUSTOMLOOPNORMAL);
+ add_customdata_mask(ct->tar, CD_MASK_NORMAL | CD_MASK_CUSTOMLOOPNORMAL);
}
if (scon->shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
add_special_eval_flag(&ct->tar->id, DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY);
@@ -1468,7 +1485,7 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
/* Only used targets. */
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
if (dtar->id == NULL) {
continue;
@@ -1542,7 +1559,7 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
* is an incomplete target reference, so nothing to do here. */
}
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
@@ -2034,6 +2051,13 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
}
}
}
+ /* Syncronization back to original object. */
+ ComponentKey final_geometry_jey(&object->id, DEG_NODE_TYPE_GEOMETRY);
+ OperationKey synchronize_key(&object->id,
+ DEG_NODE_TYPE_SYNCHRONIZE,
+ DEG_OPCODE_SYNCHRONIZE_TO_ORIGINAL);
+ add_relation(
+ final_geometry_jey, synchronize_key, "Synchronize to Original");
}
void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index c6db975c6c2..face2a1d43f 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -210,7 +210,7 @@ struct DepsgraphRelationBuilder
bool check_unique = false,
int flags = 0);
- void add_customdata_mask(const ComponentKey &key, uint64_t mask);
+ void add_customdata_mask(Object *object, uint64_t mask);
void add_special_eval_flag(ID *object, uint32_t flag);
void build_id(ID *id);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
index 1260ce013ea..efedf847515 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -140,9 +140,7 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object,
* separately. */
ComponentKey target_key(&data->tar->id, DEG_NODE_TYPE_GEOMETRY);
add_relation(target_key, solver_key, con->name);
- if (data->tar->type == OB_MESH) {
- add_customdata_mask(target_key, CD_MASK_MDEFORMVERT);
- }
+ add_customdata_mask(data->tar, CD_MASK_MDEFORMVERT);
}
else {
/* Standard Object Target. */
@@ -172,9 +170,7 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object,
* separately. */
ComponentKey target_key(&data->poletar->id, DEG_NODE_TYPE_GEOMETRY);
add_relation(target_key, solver_key, con->name);
- if (data->poletar->type == OB_MESH) {
- add_customdata_mask(target_key, CD_MASK_MDEFORMVERT);
- }
+ add_customdata_mask(data->poletar, CD_MASK_MDEFORMVERT);
}
else {
ComponentKey target_key(&data->poletar->id, DEG_NODE_TYPE_TRANSFORM);
@@ -495,33 +491,48 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
pchan->name,
DEG_OPCODE_BONE_SEGMENTS);
/* B-Bone shape depends on the final position of the bone. */
- add_relation(bone_done_key, bone_segments_key, "Done -> B-Bone Segments");
+ add_relation(bone_done_key,
+ bone_segments_key,
+ "Done -> B-Bone Segments");
/* B-Bone shape depends on final position of handle bones. */
bPoseChannel *prev, *next;
- BKE_pchan_get_bbone_handles(pchan, &prev, &next);
+ BKE_pchan_bbone_handles_get(pchan, &prev, &next);
if (prev) {
OperationKey prev_key(&object->id,
DEG_NODE_TYPE_BONE,
prev->name,
DEG_OPCODE_BONE_DONE);
- add_relation(prev_key, bone_segments_key, "Prev Handle -> B-Bone Segments");
+ add_relation(prev_key,
+ bone_segments_key,
+ "Prev Handle -> B-Bone Segments");
}
if (next) {
OperationKey next_key(&object->id,
DEG_NODE_TYPE_BONE,
next->name,
DEG_OPCODE_BONE_DONE);
- add_relation(next_key, bone_segments_key, "Next Handle -> B-Bone Segments");
+ add_relation(next_key,
+ bone_segments_key,
+ "Next Handle -> B-Bone Segments");
}
/* Pose requires the B-Bone shape. */
- add_relation(bone_segments_key, pose_done_key, "PoseEval Result-Bone Link");
- add_relation(bone_segments_key, pose_cleanup_key, "Cleanup dependency");
+ add_relation(bone_segments_key,
+ pose_done_key,
+ "PoseEval Result-Bone Link",
+ DEPSREL_FLAG_GODMODE);
+ add_relation(bone_segments_key,
+ pose_cleanup_key,
+ "Cleanup dependency");
}
else {
/* Assume that all bones must be done for the pose to be ready
* (for deformers). */
- add_relation(bone_done_key, pose_done_key, "PoseEval Result-Bone Link");
- add_relation(bone_done_key, pose_cleanup_key, "Cleanup dependency");
+ add_relation(bone_done_key,
+ pose_done_key,
+ "PoseEval Result-Bone Link");
+ add_relation(bone_done_key,
+ pose_cleanup_key,
+ "Cleanup dependency");
}
/* Custom shape. */
if (pchan->custom != NULL) {
@@ -565,7 +576,10 @@ void DepsgraphRelationBuilder::build_proxy_rig(Object *object)
add_relation(bone_ready_key, bone_done_key, "Ready -> Done");
add_relation(
bone_done_key, pose_cleanup_key, "Bone Done -> Pose Cleanup");
- add_relation(bone_done_key, pose_done_key, "Bone Done -> Pose Done");
+ add_relation(bone_done_key,
+ pose_done_key,
+ "Bone Done -> Pose Done",
+ DEPSREL_FLAG_GODMODE);
/* Make sure bone in the proxy is not done before it's FROM is done. */
if (pchan->bone && pchan->bone->segments > 1) {
@@ -575,12 +589,13 @@ void DepsgraphRelationBuilder::build_proxy_rig(Object *object)
DEG_OPCODE_BONE_SEGMENTS);
add_relation(from_bone_segments_key,
bone_done_key,
- "From Bone Segments -> Bone Done");
+ "Bone Segments -> Bone Done",
+ DEPSREL_FLAG_GODMODE);
}
else {
add_relation(from_bone_done_key,
bone_done_key,
- "From Bone Done -> Bone Done");
+ "Bone Done -> Bone Done");
}
if (pchan->prop != NULL) {
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 999508cffed..866b5e63031 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
@@ -132,15 +132,6 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, ViewLayer *view_la
LISTBASE_FOREACH (MovieClip *, clip, &bmain_->movieclip) {
build_movieclip(clip);
}
- /* TODO(sergey): Do this flush on CoW object? */
- foreach (OperationDepsNode *node, graph_->operations) {
- IDDepsNode *id_node = node->owner->owner;
- ID *id = id_node->id_orig;
- if (GS(id->name) == ID_OB) {
- Object *object = (Object *)id;
- object->customdata_mask |= node->customdata_mask;
- }
- }
/* Build all set scenes. */
if (scene->set != NULL) {
ViewLayer *set_view_layer = BKE_view_layer_default_render(scene->set);
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
index ec1ea1e02b2..15744ff614f 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
@@ -421,6 +421,8 @@ static void deg_debug_graphviz_node(const DebugContext &ctx,
case DEG_NODE_TYPE_OBJECT_FROM_LAYER:
case DEG_NODE_TYPE_BATCH_CACHE:
case DEG_NODE_TYPE_DUPLI:
+ case DEG_NODE_TYPE_SYNCHRONIZE:
+ case DEG_NODE_TYPE_GENERIC_DATABLOCK:
{
ComponentDepsNode *comp_node = (ComponentDepsNode *)node;
if (!comp_node->operations.empty()) {
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index 6dd7ae97073..f3f4d788da2 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -94,7 +94,8 @@ Depsgraph::Depsgraph(Scene *scene,
mode(mode),
ctime(BKE_scene_frame_get(scene)),
scene_cow(NULL),
- is_active(false)
+ is_active(false),
+ debug_is_evaluating(false)
{
BLI_spin_init(&lock);
id_hash = BLI_ghash_ptr_new("Depsgraph id hash");
@@ -404,6 +405,9 @@ DepsRelation *Depsgraph::add_new_relation(OperationDepsNode *from,
rel->flag |= flags;
return rel;
}
+ /* COW nodes can only depend on other COW nodes. */
+ BLI_assert(to->owner->type != DEG_NODE_TYPE_COPY_ON_WRITE ||
+ from->owner->type == DEG_NODE_TYPE_COPY_ON_WRITE);
/* Create new relation, and add it to the graph. */
rel = OBJECT_GUARDED_NEW(DepsRelation, from, to, description);
rel->flag |= flags;
@@ -645,6 +649,13 @@ void DEG_make_inactive(struct Depsgraph *depsgraph)
/* Evaluation and debug */
+bool DEG_debug_is_evaluating(struct Depsgraph *depsgraph)
+{
+ DEG::Depsgraph *deg_graph =
+ reinterpret_cast<DEG::Depsgraph *>(depsgraph);
+ return deg_graph->debug_is_evaluating;
+}
+
static DEG::string depsgraph_name_for_logging(struct Depsgraph *depsgraph)
{
const char *name = DEG_debug_name_get(depsgraph);
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index fd45c482bb5..f3c4b52828f 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -234,6 +234,8 @@ struct Depsgraph {
int debug_flags;
string debug_name;
+ bool debug_is_evaluating;
+
/* 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];
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index d56c47a0d2a..5ff504bc8c6 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -130,23 +130,6 @@ void DEG_add_object_relation(DepsNodeHandle *node_handle,
description);
}
-void DEG_add_object_relation_with_customdata(DepsNodeHandle *node_handle,
- Object *object,
- eDepsObjectComponentType component,
- uint64_t customdata_mask,
- const char *description)
-{
- DEG::eDepsNode_Type type = deg_build_object_component_type(component);
- DEG::ComponentKey comp_key(&object->id, type);
- DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
- deg_node_handle->builder->add_node_handle_relation(comp_key,
- deg_node_handle,
- description);
- if (object->type == OB_MESH) {
- deg_node_handle->builder->add_customdata_mask(comp_key, customdata_mask);
- }
-}
-
void DEG_add_object_cache_relation(DepsNodeHandle *node_handle,
CacheFile *cache_file,
eDepsObjectComponentType component,
@@ -202,6 +185,20 @@ void DEG_add_object_pointcache_relation(struct DepsNodeHandle *node_handle,
}
}
+void DEG_add_generic_id_relation(struct DepsNodeHandle *node_handle,
+ struct ID *id,
+ const char *description)
+{
+ DEG::OperationKey operation_key(
+ id,
+ DEG::DEG_NODE_TYPE_GENERIC_DATABLOCK,
+ DEG::DEG_OPCODE_GENERIC_DATABLOCK_UPDATE);
+ DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
+ deg_node_handle->builder->add_node_handle_relation(operation_key,
+ deg_node_handle,
+ description);
+}
+
void DEG_add_special_eval_flag(struct DepsNodeHandle *node_handle,
ID *id,
uint32_t flag)
@@ -210,6 +207,14 @@ void DEG_add_special_eval_flag(struct DepsNodeHandle *node_handle,
deg_node_handle->builder->add_special_eval_flag(id, flag);
}
+void DEG_add_customdata_mask(struct DepsNodeHandle *node_handle,
+ struct Object *object,
+ uint64_t mask)
+{
+ DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
+ deg_node_handle->builder->add_customdata_mask(object, mask);
+}
+
struct ID *DEG_get_id_from_handle(struct DepsNodeHandle *node_handle)
{
DEG::DepsNodeHandle *deg_handle = get_node_handle(node_handle);
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index 946917afb26..c6ade6ac4c3 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -122,6 +122,28 @@ uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, ID *id)
return id_node->eval_flags;
}
+uint64_t DEG_get_customdata_mask_for_object(const Depsgraph *graph, Object *ob)
+{
+ if (graph == NULL) {
+ /* Happens when converting objects to mesh from a python script
+ * after modifying scene graph.
+ *
+ * Currently harmless because it's only called for temporary
+ * objects which are out of the DAG anyway.
+ */
+ return 0;
+ }
+
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+ const DEG::IDDepsNode *id_node = deg_graph->find_id_node(DEG_get_original_id(&ob->id));
+ if (id_node == NULL) {
+ /* TODO(sergey): Does it mean we need to check set scene? */
+ return 0;
+ }
+
+ return id_node->customdata_mask;
+}
+
Scene *DEG_get_evaluated_scene(const Depsgraph *graph)
{
const DEG::Depsgraph *deg_graph =
diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
index 8bba92c262c..52c4ab33dc6 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
@@ -137,6 +137,7 @@ bool deg_objects_dupli_iterator_next(BLI_Iterator *iter)
*temp_dupli_object = *dob->ob;
temp_dupli_object->select_color = dupli_parent->select_color;
temp_dupli_object->base_flag = dupli_parent->base_flag | BASE_FROMDUPLI;
+ temp_dupli_object->base_local_view_bits = dupli_parent->base_local_view_bits;
/* Duplicated elements shouldn't care whether their original collection is visible or not. */
temp_dupli_object->base_flag |= BASE_VISIBLE;
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 6374354a154..69c6d17cc7e 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -143,7 +143,7 @@ void depsgraph_base_flags_tag_to_component_opcode(
}
void depsgraph_tag_to_component_opcode(const ID *id,
- eDepsgraph_Tag tag,
+ IDRecalcFlag tag,
eDepsNode_Type *component_type,
eDepsOperation_Code *operation_code)
{
@@ -157,20 +157,19 @@ void depsgraph_tag_to_component_opcode(const ID *id,
return;
}
switch (tag) {
- case DEG_TAG_TRANSFORM:
+ case ID_RECALC_TRANSFORM:
*component_type = DEG_NODE_TYPE_TRANSFORM;
break;
- case DEG_TAG_GEOMETRY:
+ case ID_RECALC_GEOMETRY:
depsgraph_geometry_tag_to_component(id, component_type);
break;
- case DEG_TAG_TIME:
+ case ID_RECALC_ANIMATION:
*component_type = DEG_NODE_TYPE_ANIMATION;
break;
- case DEG_TAG_PSYS_REDO:
- case DEG_TAG_PSYS_RESET:
- case DEG_TAG_PSYS_TYPE:
- case DEG_TAG_PSYS_CHILD:
- case DEG_TAG_PSYS_PHYS:
+ case ID_RECALC_PSYS_REDO:
+ case ID_RECALC_PSYS_RESET:
+ case ID_RECALC_PSYS_CHILD:
+ case ID_RECALC_PSYS_PHYS:
if (id_type == ID_PA) {
/* NOTES:
* - For particle settings node we need to use different
@@ -184,10 +183,10 @@ void depsgraph_tag_to_component_opcode(const ID *id,
*component_type = DEG_NODE_TYPE_EVAL_PARTICLES;
}
break;
- case DEG_TAG_COPY_ON_WRITE:
+ case ID_RECALC_COPY_ON_WRITE:
*component_type = DEG_NODE_TYPE_COPY_ON_WRITE;
break;
- case DEG_TAG_SHADING_UPDATE:
+ case ID_RECALC_SHADING:
if (id_type == ID_NT) {
*component_type = DEG_NODE_TYPE_SHADING_PARAMETERS;
}
@@ -195,25 +194,26 @@ void depsgraph_tag_to_component_opcode(const ID *id,
*component_type = DEG_NODE_TYPE_SHADING;
}
break;
- case DEG_TAG_SELECT_UPDATE:
+ case ID_RECALC_SELECT:
depsgraph_select_tag_to_component_opcode(id,
component_type,
operation_code);
break;
- case DEG_TAG_BASE_FLAGS_UPDATE:
+ case ID_RECALC_BASE_FLAGS:
depsgraph_base_flags_tag_to_component_opcode(id,
component_type,
operation_code);
break;
- case DEG_TAG_POINT_CACHE_UPDATE:
+ case ID_RECALC_POINT_CACHE:
*component_type = DEG_NODE_TYPE_POINT_CACHE;
break;
- case DEG_TAG_EDITORS_UPDATE:
+ case ID_RECALC_EDITORS:
/* There is no such node in depsgraph, this tag is to be handled
* separately.
*/
break;
- case DEG_TAG_PSYS_ALL:
+ case ID_RECALC_ALL:
+ case ID_RECALC_PSYS_ALL:
BLI_assert(!"Should not happen");
break;
}
@@ -273,16 +273,16 @@ void depsgraph_tag_component(Depsgraph *graph,
/* This is a tag compatibility with legacy code.
*
- * Mainly, old code was tagging object with OB_RECALC_DATA tag to inform
+ * Mainly, old code was tagging object with ID_RECALC_GEOMETRY tag to inform
* that object's data datablock changed. Now API expects that ID is given
* explicitly, but not all areas are aware of this yet.
*/
void deg_graph_id_tag_legacy_compat(Main *bmain,
Depsgraph *depsgraph,
ID *id,
- eDepsgraph_Tag tag)
+ IDRecalcFlag tag)
{
- if (tag == DEG_TAG_GEOMETRY || tag == 0) {
+ if (tag == ID_RECALC_GEOMETRY || tag == 0) {
switch (GS(id->name)) {
case ID_OB:
{
@@ -334,9 +334,9 @@ static void deg_graph_id_tag_update_single_flag(Main *bmain,
Depsgraph *graph,
ID *id,
IDDepsNode *id_node,
- eDepsgraph_Tag tag)
+ IDRecalcFlag tag)
{
- if (tag == DEG_TAG_EDITORS_UPDATE) {
+ if (tag == ID_RECALC_EDITORS) {
if (graph != NULL) {
depsgraph_update_editors_tag(bmain, graph, id);
}
@@ -380,7 +380,7 @@ static void deg_graph_id_tag_update_single_flag(Main *bmain,
}
-string stringify_append_bit(const string& str, eDepsgraph_Tag tag)
+string stringify_append_bit(const string& str, IDRecalcFlag tag)
{
string result = str;
if (!result.empty()) {
@@ -400,13 +400,13 @@ string stringify_update_bitfield(int flag)
/* Special cases to avoid ALL flags form being split into
* individual bits.
*/
- if ((current_flag & DEG_TAG_PSYS_ALL) == DEG_TAG_PSYS_ALL) {
- result = stringify_append_bit(result, DEG_TAG_PSYS_ALL);
+ if ((current_flag & ID_RECALC_PSYS_ALL) == ID_RECALC_PSYS_ALL) {
+ result = stringify_append_bit(result, ID_RECALC_PSYS_ALL);
}
/* Handle all the rest of the flags. */
while (current_flag != 0) {
- eDepsgraph_Tag tag =
- (eDepsgraph_Tag)(1 << bitscan_forward_clear_i(&current_flag));
+ IDRecalcFlag tag =
+ (IDRecalcFlag)(1 << bitscan_forward_clear_i(&current_flag));
result = stringify_append_bit(result, tag);
}
return result;
@@ -425,7 +425,7 @@ void deg_graph_node_tag_zero(Main *bmain, Depsgraph *graph, IDDepsNode *id_node)
}
ID *id = id_node->id_orig;
/* TODO(sergey): Which recalc flags to set here? */
- id->recalc |= ID_RECALC_ALL & ~(DEG_TAG_PSYS_ALL | ID_RECALC_ANIMATION);
+ id->recalc |= ID_RECALC_ALL & ~(ID_RECALC_PSYS_ALL | ID_RECALC_ANIMATION);
GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, id_node->components)
{
if (comp_node->type == DEG_NODE_TYPE_ANIMATION) {
@@ -434,7 +434,7 @@ void deg_graph_node_tag_zero(Main *bmain, Depsgraph *graph, IDDepsNode *id_node)
comp_node->tag_update(graph, DEG_UPDATE_SOURCE_USER_EDIT);
}
GHASH_FOREACH_END();
- deg_graph_id_tag_legacy_compat(bmain, graph, id, (eDepsgraph_Tag)0);
+ deg_graph_id_tag_legacy_compat(bmain, graph, id, (IDRecalcFlag)0);
}
void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
@@ -454,11 +454,11 @@ void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
if (flag == 0) {
deg_graph_node_tag_zero(bmain, graph, id_node);
}
- id->recalc |= (flag & PSYS_RECALC);
+ id->recalc |= flag;
int current_flag = flag;
while (current_flag != 0) {
- eDepsgraph_Tag tag =
- (eDepsgraph_Tag)(1 << bitscan_forward_clear_i(&current_flag));
+ IDRecalcFlag tag =
+ (IDRecalcFlag)(1 << bitscan_forward_clear_i(&current_flag));
deg_graph_id_tag_update_single_flag(bmain,
graph,
id,
@@ -471,7 +471,7 @@ void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
* physics did change and that cache is to be invalidated.
*/
deg_graph_id_tag_update_single_flag(
- bmain, graph, id, id_node, DEG_TAG_POINT_CACHE_UPDATE);
+ bmain, graph, id, id_node, ID_RECALC_POINT_CACHE);
}
void deg_id_tag_update(Main *bmain, ID *id, int flag)
@@ -509,7 +509,7 @@ void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph)
}
int flag = 0;
if (!DEG::deg_copy_on_write_is_expanded(id_node->id_cow)) {
- flag |= DEG_TAG_COPY_ON_WRITE;
+ flag |= ID_RECALC_COPY_ON_WRITE;
}
/* We only tag components which needs an update. Tagging everything is
* not a good idea because that might reset particles cache (or any
@@ -519,7 +519,7 @@ void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph)
*/
const ID_Type id_type = GS(id_node->id_orig->name);
if (id_type == ID_OB) {
- flag |= OB_RECALC_OB | OB_RECALC_DATA;
+ flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY;
}
deg_graph_id_tag_update(bmain, graph, id_node->id_orig, flag);
if (id_type == ID_SCE) {
@@ -583,24 +583,24 @@ eDepsNode_Type deg_geometry_tag_to_component(const ID *id)
} // namespace DEG
-const char *DEG_update_tag_as_string(eDepsgraph_Tag flag)
+const char *DEG_update_tag_as_string(IDRecalcFlag flag)
{
switch (flag) {
- case DEG_TAG_TRANSFORM: return "TRANSFORM";
- case DEG_TAG_GEOMETRY: return "GEOMETRY";
- case DEG_TAG_TIME: return "TIME";
- case DEG_TAG_PSYS_REDO: return "PSYS_REDO";
- case DEG_TAG_PSYS_RESET: return "PSYS_RESET";
- case DEG_TAG_PSYS_TYPE: return "PSYS_TYPE";
- case DEG_TAG_PSYS_CHILD: return "PSYS_CHILD";
- case DEG_TAG_PSYS_PHYS: return "PSYS_PHYS";
- case DEG_TAG_PSYS_ALL: return "PSYS_ALL";
- case DEG_TAG_COPY_ON_WRITE: return "COPY_ON_WRITE";
- case DEG_TAG_SHADING_UPDATE: return "SHADING_UPDATE";
- case DEG_TAG_SELECT_UPDATE: return "SELECT_UPDATE";
- case DEG_TAG_BASE_FLAGS_UPDATE: return "BASE_FLAGS_UPDATE";
- case DEG_TAG_POINT_CACHE_UPDATE: return "POINT_CACHE_UPDATE";
- case DEG_TAG_EDITORS_UPDATE: return "EDITORS_UPDATE";
+ case ID_RECALC_TRANSFORM: return "TRANSFORM";
+ case ID_RECALC_GEOMETRY: return "GEOMETRY";
+ case ID_RECALC_ANIMATION: return "ANIMATION";
+ case ID_RECALC_PSYS_REDO: return "PSYS_REDO";
+ case ID_RECALC_PSYS_RESET: return "PSYS_RESET";
+ case ID_RECALC_PSYS_CHILD: return "PSYS_CHILD";
+ case ID_RECALC_PSYS_PHYS: return "PSYS_PHYS";
+ case ID_RECALC_PSYS_ALL: return "PSYS_ALL";
+ case ID_RECALC_COPY_ON_WRITE: return "COPY_ON_WRITE";
+ case ID_RECALC_SHADING: return "SHADING";
+ case ID_RECALC_SELECT: return "SELECT";
+ case ID_RECALC_BASE_FLAGS: return "BASE_FLAGS";
+ case ID_RECALC_POINT_CACHE: return "POINT_CACHE";
+ case ID_RECALC_EDITORS: return "EDITORS";
+ case ID_RECALC_ALL: return "ALL";
}
BLI_assert(!"Unhandled update flag, should never happen!");
return "UNKNOWN";
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cc b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
index 3f36b9f7831..4edf616961c 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cc
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
@@ -104,6 +104,10 @@ const char *nodeTypeAsString(eDepsNode_Type type)
STRINGIFY_TYPE(BATCH_CACHE);
/* Duplication. */
STRINGIFY_TYPE(DUPLI);
+ /* Synchronization. */
+ STRINGIFY_TYPE(SYNCHRONIZE);
+ /* Generic datablock. */
+ STRINGIFY_TYPE(GENERIC_DATABLOCK);
/* Total number of meaningful node types. */
case NUM_DEG_NODE_TYPES: return "SpecialCase";
@@ -180,6 +184,10 @@ const char *operationCodeAsString(eDepsOperation_Code opcode)
/* Movie clip. */
STRINGIFY_OPCODE(MOVIECLIP_EVAL);
STRINGIFY_OPCODE(MOVIECLIP_SELECT_UPDATE);
+ /* Synchronization. */
+ STRINGIFY_OPCODE(SYNCHRONIZE_TO_ORIGINAL);
+ /* Generic datablock. */
+ STRINGIFY_OPCODE(GENERIC_DATABLOCK_UPDATE);
case DEG_NUM_OPCODES: return "SpecialCase";
#undef STRINGIFY_OPCODE
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index f8b519cb1aa..2de614ff8ad 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -138,6 +138,9 @@ typedef enum eDepsNode_Type {
* changed in view layer.
*/
DEG_NODE_TYPE_OBJECT_FROM_LAYER,
+ /* Un-interestying datablock, which is a part of dependency graph, but does
+ * not have very distinctive update procedure. */
+ DEG_NODE_TYPE_GENERIC_DATABLOCK,
/* **** Evaluation-Related Outer Types (with Subdata) **** */
@@ -157,11 +160,12 @@ typedef enum eDepsNode_Type {
DEG_NODE_TYPE_CACHE,
/* Batch Cache Component - TODO (dfelinto/sergey) rename to make it more generic. */
DEG_NODE_TYPE_BATCH_CACHE,
-
/* Duplication system. Used to force duplicated objects visible when
* when duplicator is visible.
*/
DEG_NODE_TYPE_DUPLI,
+ /* Synchronization back to original datablock. */
+ DEG_NODE_TYPE_SYNCHRONIZE,
/* Total number of meaningful node types. */
NUM_DEG_NODE_TYPES,
@@ -170,7 +174,7 @@ const char *nodeTypeAsString(eDepsNode_Type type);
/* Identifiers for common operations (as an enum). */
typedef enum eDepsOperation_Code {
- /* Generic Operations. ------------------------------ */
+ /* Generic Operations. -------------------------------------------------- */
/* Placeholder for operations which don't need special mention */
DEG_OPCODE_OPERATION = 0,
@@ -182,16 +186,16 @@ typedef enum eDepsOperation_Code {
// XXX: Placeholder while porting depsgraph code
DEG_OPCODE_PLACEHOLDER,
- /* Animation, Drivers, etc. ------------------------ */
+ /* Animation, Drivers, etc. --------------------------------------------- */
/* NLA + Action */
DEG_OPCODE_ANIMATION,
/* Driver */
DEG_OPCODE_DRIVER,
- /* Object related. --------------------------------- */
+ /* Object related. ------------------------------------------------------ */
DEG_OPCODE_OBJECT_BASE_FLAGS,
- /* Transform. -------------------------------------- */
+ /* Transform. ----------------------------------------------------------- */
/* Transform entry point - local transforms only */
DEG_OPCODE_TRANSFORM_LOCAL,
/* Parenting */
@@ -203,25 +207,25 @@ typedef enum eDepsOperation_Code {
/* Handle object-level updates, mainly proxies hacks and recalc flags. */
DEG_OPCODE_TRANSFORM_OBJECT_UBEREVAL,
- /* Rigid body. -------------------------------------- */
+ /* Rigid body. ---------------------------------------------------------- */
/* Perform Simulation */
DEG_OPCODE_RIGIDBODY_REBUILD,
DEG_OPCODE_RIGIDBODY_SIM,
/* Copy results to object */
DEG_OPCODE_RIGIDBODY_TRANSFORM_COPY,
- /* Geometry. ---------------------------------------- */
+ /* Geometry. ------------------------------------------------------------ */
/* Evaluate the whole geometry, including modifiers. */
DEG_OPCODE_GEOMETRY_UBEREVAL,
/* Evaluation of a shape key. */
DEG_OPCODE_GEOMETRY_SHAPEKEY,
- /* Object data. ------------------------------------- */
+ /* Object data. --------------------------------------------------------- */
DEG_OPCODE_LIGHT_PROBE_EVAL,
DEG_OPCODE_SPEAKER_EVAL,
- /* Pose. -------------------------------------------- */
+ /* Pose. ---------------------------------------------------------------- */
/* Init pose, clear flags, etc. */
DEG_OPCODE_POSE_INIT,
/* Initialize IK solver related pose stuff. */
@@ -234,7 +238,7 @@ typedef enum eDepsOperation_Code {
DEG_OPCODE_POSE_IK_SOLVER,
DEG_OPCODE_POSE_SPLINE_IK_SOLVER,
- /* Bone. -------------------------------------------- */
+ /* Bone. ---------------------------------------------------------------- */
/* Bone local transforms - entry point */
DEG_OPCODE_BONE_LOCAL,
/* Pose-space conversion (includes parent + restpose, */
@@ -257,37 +261,43 @@ typedef enum eDepsOperation_Code {
/* B-Bone segment shape computation (after DONE) */
DEG_OPCODE_BONE_SEGMENTS,
- /* Particles. --------------------------------------- */
+ /* Particles. ----------------------------------------------------------- */
/* Particle System evaluation. */
DEG_OPCODE_PARTICLE_SYSTEM_EVAL_INIT,
DEG_OPCODE_PARTICLE_SYSTEM_EVAL,
DEG_OPCODE_PARTICLE_SETTINGS_EVAL,
- /* Point Cache. ------------------------------------- */
+ /* Point Cache. --------------------------------------------------------- */
DEG_OPCODE_POINT_CACHE_RESET,
- /* Collections. ------------------------------------- */
+ /* Collections. --------------------------------------------------------- */
DEG_OPCODE_VIEW_LAYER_EVAL,
- /* Copy on Write. ------------------------------------ */
+ /* Copy on Write. ------------------------------------------------------- */
DEG_OPCODE_COPY_ON_WRITE,
- /* Shading. ------------------------------------------- */
+ /* Shading. ------------------------------------------------------------- */
DEG_OPCODE_SHADING,
DEG_OPCODE_MATERIAL_UPDATE,
DEG_OPCODE_WORLD_UPDATE,
- /* Batch caches. -------------------------------------- */
+ /* Batch caches. -------------------------------------------------------- */
DEG_OPCODE_GEOMETRY_SELECT_UPDATE,
- /* Masks. ------------------------------------------ */
+ /* Masks. --------------------------------------------------------------- */
DEG_OPCODE_MASK_ANIMATION,
DEG_OPCODE_MASK_EVAL,
- /* Movie clips. ------------------------------------ */
+ /* Movie clips. --------------------------------------------------------- */
DEG_OPCODE_MOVIECLIP_EVAL,
DEG_OPCODE_MOVIECLIP_SELECT_UPDATE,
+ /* Synchronization clips. ----------------------------------------------- */
+ DEG_OPCODE_SYNCHRONIZE_TO_ORIGINAL,
+
+ /* Generic datablock ---------------------------------------------------- */
+ DEG_OPCODE_GENERIC_DATABLOCK_UPDATE,
+
DEG_NUM_OPCODES,
} eDepsOperation_Code;
const char *operationCodeAsString(eDepsOperation_Code opcode);
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index 0097fc95948..02d286c3bd1 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -73,6 +73,7 @@ static void schedule_children(TaskPool *pool,
struct DepsgraphEvalState {
Depsgraph *graph;
bool do_stats;
+ bool is_cow_stage;
};
static void deg_task_run_func(TaskPool *pool,
@@ -214,6 +215,17 @@ static void schedule_node(TaskPool *pool, Depsgraph *graph,
if (node->num_links_pending != 0) {
return;
}
+ /* During the COW stage only schedule COW nodes. */
+ DepsgraphEvalState *state = (DepsgraphEvalState *)BLI_task_pool_userdata(pool);
+ if (state->is_cow_stage) {
+ if (node->owner->type != DEG_NODE_TYPE_COPY_ON_WRITE) {
+ return;
+ }
+ }
+ else {
+ BLI_assert(node->scheduled || node->owner->type != DEG_NODE_TYPE_COPY_ON_WRITE);
+ }
+ /* Actually schedule the node. */
bool is_scheduled = atomic_fetch_and_or_uint8(
(uint8_t *)&node->scheduled, (uint8_t)true);
if (!is_scheduled) {
@@ -291,6 +303,7 @@ void deg_evaluate_on_refresh(Depsgraph *graph)
}
const bool do_time_debug = ((G.debug & G_DEBUG_DEPSGRAPH_TIME) != 0);
const double start_time = do_time_debug ? PIL_check_seconds_timer() : 0;
+ graph->debug_is_evaluating = true;
depsgraph_ensure_view_layer(graph);
/* Set up evaluation state. */
DepsgraphEvalState state;
@@ -311,6 +324,12 @@ void deg_evaluate_on_refresh(Depsgraph *graph)
/* Prepare all nodes for evaluation. */
initialize_execution(&state, graph);
/* Do actual evaluation now. */
+ /* First, process all Copy-On-Write nodes. */
+ state.is_cow_stage = true;
+ schedule_graph(task_pool, graph);
+ BLI_task_pool_work_wait_and_reset(task_pool);
+ /* After that, process all other nodes. */
+ state.is_cow_stage = false;
schedule_graph(task_pool, graph);
BLI_task_pool_work_and_wait(task_pool);
BLI_task_pool_free(task_pool);
@@ -326,6 +345,7 @@ void deg_evaluate_on_refresh(Depsgraph *graph)
if (need_free_scheduler) {
BLI_task_scheduler_free(task_scheduler);
}
+ graph->debug_is_evaluating = false;
if (do_time_debug) {
printf("Depsgraph updated in %f seconds.\n",
PIL_check_seconds_timer() - start_time);
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index bacf9f5fad3..30e8048c6c9 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -131,7 +131,6 @@ void nested_id_hack_discard_pointers(ID *id_cow)
SPECIAL_CASE(ID_LS, FreestyleLineStyle, nodetree)
SPECIAL_CASE(ID_LA, Lamp, nodetree)
SPECIAL_CASE(ID_MA, Material, nodetree)
- SPECIAL_CASE(ID_SCE, Scene, nodetree)
SPECIAL_CASE(ID_TE, Tex, nodetree)
SPECIAL_CASE(ID_WO, World, nodetree)
@@ -139,6 +138,17 @@ void nested_id_hack_discard_pointers(ID *id_cow)
SPECIAL_CASE(ID_LT, Lattice, key)
SPECIAL_CASE(ID_ME, Mesh, key)
+ case ID_SCE:
+ {
+ Scene *scene_cow = (Scene *)id_cow;
+ /* Node trees always have their own ID node in the graph, and are
+ * being copied as part of their copy-on-write process. */
+ scene_cow->nodetree = NULL;
+ /* Tool settings pointer is shared with the original scene. */
+ scene_cow->toolsettings = NULL;
+ break;
+ }
+
case ID_OB:
{
/* Clear the ParticleSettings pointer to prevent doubly-freeing it. */
@@ -174,7 +184,6 @@ const ID *nested_id_hack_get_discarded_pointers(NestedIDHackTempStorage *storage
SPECIAL_CASE(ID_LS, FreestyleLineStyle, nodetree, linestyle)
SPECIAL_CASE(ID_LA, Lamp, nodetree, lamp)
SPECIAL_CASE(ID_MA, Material, nodetree, material)
- SPECIAL_CASE(ID_SCE, Scene, nodetree, scene)
SPECIAL_CASE(ID_TE, Tex, nodetree, tex)
SPECIAL_CASE(ID_WO, World, nodetree, world)
@@ -182,6 +191,14 @@ const ID *nested_id_hack_get_discarded_pointers(NestedIDHackTempStorage *storage
SPECIAL_CASE(ID_LT, Lattice, key, lattice)
SPECIAL_CASE(ID_ME, Mesh, key, mesh)
+ case ID_SCE:
+ {
+ storage->scene = *(Scene *)id;
+ storage->scene.toolsettings = NULL;
+ storage->scene.nodetree = NULL;
+ return &storage->scene.id;
+ }
+
# undef SPECIAL_CASE
default:
@@ -629,6 +646,7 @@ void update_special_pointers(const Depsgraph *depsgraph,
{
Scene *scene_cow = (Scene *)id_cow;
const Scene *scene_orig = (const Scene *)id_orig;
+ scene_cow->toolsettings = scene_orig->toolsettings;
scene_cow->eevee.light_cache = scene_orig->eevee.light_cache;
break;
}
@@ -794,7 +812,7 @@ static void deg_update_copy_on_write_animation(const Depsgraph *depsgraph,
typedef struct ObjectRuntimeBackup {
Object_Runtime runtime;
short base_flag;
- CustomDataMask lastDataMask;
+ unsigned short base_local_view_bits;
} ObjectRuntimeBackup;
/* Make a backup of object's evaluation runtime data, additionally
@@ -818,7 +836,7 @@ static void deg_backup_object_runtime(
}
/* Make a backup of base flags. */
object_runtime_backup->base_flag = object->base_flag;
- object_runtime_backup->lastDataMask = object->lastDataMask;
+ object_runtime_backup->base_local_view_bits = object->base_local_view_bits;
}
static void deg_restore_object_runtime(
@@ -838,6 +856,9 @@ static void deg_restore_object_runtime(
* that datablock.
*/
object->data = mesh_orig;
+
+ /* After that, immediately free the invalidated caches. */
+ BKE_object_free_derived_caches(object);
}
else {
Mesh *mesh_eval = object->runtime.mesh_eval;
@@ -853,7 +874,7 @@ static void deg_restore_object_runtime(
}
}
object->base_flag = object_runtime_backup->base_flag;
- object->lastDataMask = object_runtime_backup->lastDataMask;
+ object->base_local_view_bits = object_runtime_backup->base_local_view_bits;
}
ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
@@ -909,7 +930,7 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
* everything is done by node tree update function which
* only copies socket values.
*/
- const int ignore_flag = (ID_RECALC_DRAW |
+ const int ignore_flag = (ID_RECALC_SHADING |
ID_RECALC_ANIMATION |
ID_RECALC_COPY_ON_WRITE);
if ((id_cow->recalc & ~ignore_flag) == 0) {
@@ -1003,6 +1024,7 @@ void discard_mesh_edit_mode_pointers(ID *id_cow)
void discard_scene_pointers(ID *id_cow)
{
Scene *scene_cow = (Scene *)id_cow;
+ scene_cow->toolsettings = NULL;
scene_cow->eevee.light_cache = NULL;
}
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index 61edc1e3795..fef3282cfcc 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -345,10 +345,10 @@ void invalidate_tagged_evaluated_data(Depsgraph *graph)
continue;
}
switch (comp_node->type) {
- case DEG_TAG_TRANSFORM:
+ case ID_RECALC_TRANSFORM:
invalidate_tagged_evaluated_transform(id_cow);
break;
- case DEG_TAG_GEOMETRY:
+ case ID_RECALC_GEOMETRY:
invalidate_tagged_evaluated_geometry(id_cow);
break;
default:
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
index 4bb9b9d17b3..6840aa0e7e5 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
@@ -384,23 +384,26 @@ void BoneComponentDepsNode::init(const ID *id, const char *subdata)
/* Register all components. =============================== */
DEG_COMPONENT_NODE_DEFINE(Animation, ANIMATION, ID_RECALC_ANIMATION);
-DEG_COMPONENT_NODE_DEFINE(BatchCache, BATCH_CACHE, ID_RECALC_DRAW_CACHE);
+/* TODO(sergey): Is this a correct tag? */
+DEG_COMPONENT_NODE_DEFINE(BatchCache, BATCH_CACHE, ID_RECALC_SHADING);
DEG_COMPONENT_NODE_DEFINE(Bone, BONE, ID_RECALC_GEOMETRY);
-DEG_COMPONENT_NODE_DEFINE(Cache, CACHE, ID_RECALC);
+DEG_COMPONENT_NODE_DEFINE(Cache, CACHE, 0);
DEG_COMPONENT_NODE_DEFINE(CopyOnWrite, COPY_ON_WRITE, ID_RECALC_COPY_ON_WRITE);
DEG_COMPONENT_NODE_DEFINE(Geometry, GEOMETRY, ID_RECALC_GEOMETRY);
DEG_COMPONENT_NODE_DEFINE(LayerCollections, LAYER_COLLECTIONS, 0);
-DEG_COMPONENT_NODE_DEFINE(Parameters, PARAMETERS, ID_RECALC);
+DEG_COMPONENT_NODE_DEFINE(Parameters, PARAMETERS, 0);
DEG_COMPONENT_NODE_DEFINE(Particles, EVAL_PARTICLES, ID_RECALC_GEOMETRY);
DEG_COMPONENT_NODE_DEFINE(PointCache, POINT_CACHE, 0);
DEG_COMPONENT_NODE_DEFINE(Pose, EVAL_POSE, ID_RECALC_GEOMETRY);
DEG_COMPONENT_NODE_DEFINE(Proxy, PROXY, ID_RECALC_GEOMETRY);
-DEG_COMPONENT_NODE_DEFINE(Sequencer, SEQUENCER, ID_RECALC);
-DEG_COMPONENT_NODE_DEFINE(Shading, SHADING, ID_RECALC_DRAW);
-DEG_COMPONENT_NODE_DEFINE(ShadingParameters, SHADING_PARAMETERS, ID_RECALC_DRAW);
+DEG_COMPONENT_NODE_DEFINE(Sequencer, SEQUENCER, 0);
+DEG_COMPONENT_NODE_DEFINE(Shading, SHADING, ID_RECALC_SHADING);
+DEG_COMPONENT_NODE_DEFINE(ShadingParameters, SHADING_PARAMETERS, ID_RECALC_SHADING);
DEG_COMPONENT_NODE_DEFINE(Transform, TRANSFORM, ID_RECALC_TRANSFORM);
-DEG_COMPONENT_NODE_DEFINE(ObjectFromLayer, OBJECT_FROM_LAYER, ID_RECALC);
+DEG_COMPONENT_NODE_DEFINE(ObjectFromLayer, OBJECT_FROM_LAYER, 0);
DEG_COMPONENT_NODE_DEFINE(Dupli, DUPLI, 0);
+DEG_COMPONENT_NODE_DEFINE(Synchronize, SYNCHRONIZE, 0);
+DEG_COMPONENT_NODE_DEFINE(GenericDatablock, GENERIC_DATABLOCK, 0);
/* Node Types Register =================================== */
@@ -424,6 +427,8 @@ void deg_register_component_depsnodes()
deg_register_node_typeinfo(&DNTI_TRANSFORM);
deg_register_node_typeinfo(&DNTI_OBJECT_FROM_LAYER);
deg_register_node_typeinfo(&DNTI_DUPLI);
+ deg_register_node_typeinfo(&DNTI_SYNCHRONIZE);
+ deg_register_node_typeinfo(&DNTI_GENERIC_DATABLOCK);
}
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h
index e3057e1d3ce..0852d886ae4 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h
@@ -200,6 +200,8 @@ DEG_COMPONENT_NODE_DECLARE_GENERIC(ShadingParameters);
DEG_COMPONENT_NODE_DECLARE_GENERIC(Transform);
DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(ObjectFromLayer);
DEG_COMPONENT_NODE_DECLARE_GENERIC(Dupli);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Synchronize);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(GenericDatablock);
/* Bone Component */
struct BoneComponentDepsNode : public ComponentDepsNode {
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_id.cc b/source/blender/depsgraph/intern/nodes/deg_node_id.cc
index b194e304e99..d431e68f904 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_id.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_id.cc
@@ -104,6 +104,8 @@ void IDDepsNode::init(const ID *id, const char *UNUSED(subdata))
id_orig = (ID *)id;
eval_flags = 0;
previous_eval_flags = 0;
+ customdata_mask = 0;
+ previous_customdata_mask = 0;
linked_state = DEG_ID_LINKED_INDIRECTLY;
is_directly_visible = true;
is_collection_fully_expanded = false;
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_id.h b/source/blender/depsgraph/intern/nodes/deg_node_id.h
index f8d05eddffd..a968794e3b2 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_id.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_id.h
@@ -81,6 +81,10 @@ struct IDDepsNode : public DepsNode {
uint32_t eval_flags;
uint32_t previous_eval_flags;
+ /* Extra customdata mask which needs to be evaluated for the mesh object. */
+ uint64_t customdata_mask;
+ uint64_t previous_customdata_mask;
+
eDepsNode_LinkedState_Type linked_state;
/* Indicates the datablock is visible in the evaluated scene. */
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc
index ef1882dd715..f6fee6acf23 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc
@@ -46,8 +46,7 @@ namespace DEG {
OperationDepsNode::OperationDepsNode() :
name_tag(-1),
- flag(0),
- customdata_mask(0)
+ flag(0)
{
}
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.h b/source/blender/depsgraph/intern/nodes/deg_node_operation.h
index 71c03945d48..9ba3a0b4864 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_operation.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.h
@@ -93,9 +93,6 @@ struct OperationDepsNode : public DepsNode {
/* (eDepsOperation_Flag) extra settings affecting evaluation. */
int flag;
- /* Extra customdata mask which needs to be evaluated for the object. */
- uint64_t customdata_mask;
-
DEG_DEPSNODE_DECLARE;
};
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 2097fb66c8b..9c1ca46175e 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -224,6 +224,7 @@ data_to_c_simple(engines/workbench/shaders/workbench_checkerboard_depth_frag.gls
data_to_c_simple(engines/workbench/shaders/workbench_common_lib.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_data_lib.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_deferred_composite_frag.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/workbench_deferred_background_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_effect_fxaa_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_effect_taa_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_forward_composite_frag.glsl SRC)
@@ -231,6 +232,7 @@ data_to_c_simple(engines/workbench/shaders/workbench_forward_depth_frag.glsl SRC
data_to_c_simple(engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_ghost_resolve_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_object_outline_lib.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/workbench_curvature_lib.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_prepass_vert.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_prepass_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_shadow_vert.glsl SRC)
@@ -273,7 +275,6 @@ data_to_c_simple(modes/shaders/edit_mesh_overlay_geom_edge.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_points_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_facedot_frag.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_facedot_vert.glsl SRC)
-data_to_c_simple(modes/shaders/edit_mesh_overlay_ghost_clear_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_mix_frag.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_facefill_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_facefill_frag.glsl SRC)
@@ -326,6 +327,7 @@ data_to_c_simple(engines/gpencil/shaders/gpencil_stroke_geom.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_stroke_frag.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_zdepth_mix_frag.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_simple_mix_frag.glsl SRC)
+data_to_c_simple(engines/gpencil/shaders/gpencil_blend_frag.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_point_vert.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_point_geom.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_point_frag.glsl SRC)
diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c
index 9dc8c8f2f34..8356838a885 100644
--- a/source/blender/draw/engines/basic/basic_engine.c
+++ b/source/blender/draw/engines/basic/basic_engine.c
@@ -157,7 +157,10 @@ static void basic_cache_populate(void *vedata, Object *ob)
}
}
- struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
+ const bool is_active = (ob == draw_ctx->obact);
+ const bool use_hide = is_active && DRW_object_use_hide_faces(ob);
+
+ struct GPUBatch *geom = DRW_cache_object_surface_get_ex(ob, use_hide);
if (geom) {
const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING));
/* Depth Prepass */
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
index 451e7174a94..71082268f10 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -1050,7 +1050,7 @@ void EEVEE_lightbake_update(void *custom_data)
EEVEE_lightcache_info_update(&lbake->scene->eevee);
- DEG_id_tag_update(&scene_orig->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene_orig->id, ID_RECALC_COPY_ON_WRITE);
}
static bool lightbake_do_sample(EEVEE_LightBake *lbake, void (*render_callback)(void *ved, void *user_data))
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index e46526ce6af..aa2f480597b 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -62,8 +62,8 @@ void EEVEE_lookdev_cache_init(
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) {
- StudioLight *sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE);
- if (sl && (sl->flag & STUDIOLIGHT_ORIENTATION_WORLD)) {
+ StudioLight *sl = BKE_studiolight_find(v3d->shading.lookdev_light, STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE);
+ if (sl && (sl->flag & STUDIOLIGHT_TYPE_WORLD)) {
GPUShader *shader = EEVEE_shaders_default_studiolight_sh_get();
struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
GPUTexture *tex = NULL;
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index a87b4626628..6736d4c4110 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -1450,6 +1450,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
is_sculpt_mode &&
((ob->sculpt && ob->sculpt->pbvh) && (BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_FACES));
#endif
+ const bool use_hide = is_active && DRW_object_use_hide_faces(ob);
const bool is_default_mode_shader = is_sculpt_mode;
/* First get materials for this mesh. */
@@ -1526,7 +1527,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
int *auto_layer_is_srgb;
int auto_layer_count;
struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get(
- ob, gpumat_array, materials_len,
+ ob, gpumat_array, materials_len, use_hide,
&auto_layer_names,
&auto_layer_is_srgb,
&auto_layer_count);
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 15ac3f37add..5478c4a60b9 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -83,8 +83,12 @@ tGPencilObjectCache *gpencil_object_cache_add(
cache_elem->pixfactor = cache_elem->gpd->pixfactor;
cache_elem->shader_fx = ob_orig->shader_fx;
- cache_elem->init_grp = NULL;
- cache_elem->end_grp = NULL;
+ /* shgrp array */
+ cache_elem->tot_layers = 0;
+ int totgpl = BLI_listbase_count(&cache_elem->gpd->layers);
+ if (totgpl > 0) {
+ cache_elem->shgrp_array = MEM_callocN(sizeof(tGPencilObjectCache_shgrp) * totgpl, __func__);
+ }
/* calculate zdepth from point of view */
float zdepth = 0.0;
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 6289e76664d..1afb5daa912 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -245,7 +245,6 @@ GPUBatch *DRW_gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
- View3D *v3d = draw_ctx->v3d;
ARegion *ar = draw_ctx->ar;
RegionView3D *rv3d = draw_ctx->rv3d;
ToolSettings *ts = scene->toolsettings;
@@ -274,7 +273,7 @@ GPUBatch *DRW_gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
/* get origin to reproject point */
float origin[3];
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
- ED_gp_get_drawing_reference(v3d, scene, ob, gpl, ts->gpencil_v3d_align, origin);
+ ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, origin);
for (int i = 0; i < totpoints; i++, tpt++) {
ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt);
@@ -323,7 +322,6 @@ GPUBatch *DRW_gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
- View3D *v3d = draw_ctx->v3d;
ARegion *ar = draw_ctx->ar;
RegionView3D *rv3d = draw_ctx->rv3d;
ToolSettings *ts = scene->toolsettings;
@@ -352,7 +350,7 @@ GPUBatch *DRW_gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness)
/* get origin to reproject point */
float origin[3];
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
- ED_gp_get_drawing_reference(v3d, scene, ob, gpl, ts->gpencil_v3d_align, origin);
+ ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, origin);
for (int i = 0; i < totpoints; i++, tpt++) {
ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt);
@@ -384,7 +382,6 @@ GPUBatch *DRW_gpencil_get_buffer_fill_geom(bGPdata *gpd)
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
- View3D *v3d = draw_ctx->v3d;
ARegion *ar = draw_ctx->ar;
ToolSettings *ts = scene->toolsettings;
Object *ob = draw_ctx->obact;
@@ -392,7 +389,7 @@ GPUBatch *DRW_gpencil_get_buffer_fill_geom(bGPdata *gpd)
/* get origin to reproject point */
float origin[3];
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
- ED_gp_get_drawing_reference(v3d, scene, ob, gpl, ts->gpencil_v3d_align, origin);
+ ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, origin);
int tot_triangles = totpoints - 2;
/* allocate memory for temporary areas */
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index c8b70953f87..eaae8033b8b 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -244,13 +244,15 @@ static void gpencil_stroke_2d_flat(const bGPDspoint *points, int totpoints, floa
}
/* recalc the internal geometry caches for fill and uvs */
-static void DRW_gpencil_recalc_geometry_caches(Object *ob, MaterialGPencilStyle *gp_style, bGPDstroke *gps)
+static void DRW_gpencil_recalc_geometry_caches(
+ Object *ob, bGPDlayer *gpl, MaterialGPencilStyle *gp_style, bGPDstroke *gps)
{
if (gps->flag & GP_STROKE_RECALC_CACHES) {
/* Calculate triangles cache for filling area (must be done only after changes) */
if ((gps->tot_triangles == 0) || (gps->triangles == NULL)) {
if ((gps->totpoints > 2) &&
- ((gp_style->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (gp_style->fill_style > 0)))
+ ((gp_style->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) ||
+ (gp_style->fill_style > 0) || (gpl->blend_mode != eGplBlendMode_Normal)))
{
DRW_gpencil_triangulate_stroke_fill(ob, gps);
}
@@ -559,7 +561,10 @@ static void gpencil_add_fill_vertexdata(
/* set color using material, tint color and opacity */
interp_v3_v3v3(tfill, gps->runtime.tmp_fill_rgba, tintcolor, tintcolor[3]);
tfill[3] = gps->runtime.tmp_fill_rgba[3] * opacity;
- if ((tfill[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (gp_style->fill_style > 0)) {
+ if ((tfill[3] > GPENCIL_ALPHA_OPACITY_THRESH) ||
+ (gp_style->fill_style > 0) ||
+ (gpl->blend_mode != eGplBlendMode_Normal))
+ {
if (cache->is_dirty) {
const float *color;
if (!onion) {
@@ -581,7 +586,8 @@ static void gpencil_add_fill_vertexdata(
/* add to list of groups */
if (old_len < cache->b_fill.vbo_len) {
cache->grp_cache = gpencil_group_cache_add(
- cache->grp_cache, gpl, gpf, gps, eGpencilBatchGroupType_Fill, onion,
+ cache->grp_cache, gpl, gpf, gps,
+ eGpencilBatchGroupType_Fill, onion,
cache->b_fill.vbo_len,
&cache->grp_size, &cache->grp_used);
}
@@ -637,7 +643,8 @@ static void gpencil_add_stroke_vertexdata(
/* add to list of groups */
if (old_len < cache->b_stroke.vbo_len) {
cache->grp_cache = gpencil_group_cache_add(
- cache->grp_cache, gpl, gpf, gps, eGpencilBatchGroupType_Stroke, onion,
+ cache->grp_cache, gpl, gpf, gps,
+ eGpencilBatchGroupType_Stroke, onion,
cache->b_stroke.vbo_len,
&cache->grp_size, &cache->grp_used);
}
@@ -687,7 +694,8 @@ static void gpencil_add_editpoints_vertexdata(
/* add to list of groups */
cache->grp_cache = gpencil_group_cache_add(
- cache->grp_cache, gpl, gpf, gps, eGpencilBatchGroupType_Edlin, false,
+ cache->grp_cache, gpl, gpf, gps,
+ eGpencilBatchGroupType_Edlin, false,
cache->b_edlin.vbo_len,
&cache->grp_size, &cache->grp_used);
}
@@ -699,7 +707,8 @@ static void gpencil_add_editpoints_vertexdata(
/* add to list of groups */
cache->grp_cache = gpencil_group_cache_add(
- cache->grp_cache, gpl, gpf, gps, eGpencilBatchGroupType_Edit, false,
+ cache->grp_cache, gpl, gpf, gps,
+ eGpencilBatchGroupType_Edit, false,
cache->b_edit.vbo_len,
&cache->grp_size, &cache->grp_used);
}
@@ -771,13 +780,14 @@ static void gpencil_draw_strokes(
/* be sure recalc all cache in source stroke to avoid recalculation when frame change
* and improve fps */
if (src_gps) {
- DRW_gpencil_recalc_geometry_caches(ob, gp_style, src_gps);
+ DRW_gpencil_recalc_geometry_caches(ob, gpl, gp_style, src_gps);
}
/* if the fill has any value, it's considered a fill and is not drawn if simplify fill is enabled */
if ((stl->storage->simplify_fill) && (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_REMOVE_FILL_LINE)) {
if ((gp_style->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) ||
- (gp_style->fill_style > GP_STYLE_FILL_STYLE_SOLID))
+ (gp_style->fill_style > GP_STYLE_FILL_STYLE_SOLID) ||
+ (gpl->blend_mode != eGplBlendMode_Normal))
{
GP_SET_SRC_GPS(src_gps);
continue;
@@ -798,21 +808,28 @@ static void gpencil_draw_strokes(
}
}
- /* fill */
- if ((gp_style->flag & GP_STYLE_FILL_SHOW) &&
- (!stl->storage->simplify_fill))
- {
- gpencil_add_fill_vertexdata(
- cache, ob, gpl, derived_gpf, gps,
- opacity, tintcolor, false, custonion);
- }
- /* stroke */
- if ((gp_style->flag & GP_STYLE_STROKE_SHOW) &&
- (gp_style->stroke_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH))
+ /* hide any blend layer */
+ if ((!stl->storage->simplify_blend) ||
+ (gpl->blend_mode == eGplBlendMode_Normal))
{
- gpencil_add_stroke_vertexdata(
- cache, ob, gpl, derived_gpf, gps,
- opacity, tintcolor, false, custonion);
+ /* fill */
+ if ((gp_style->flag & GP_STYLE_FILL_SHOW) &&
+ (!stl->storage->simplify_fill) &&
+ ((gps->flag & GP_STROKE_NOFILL) == 0))
+ {
+ gpencil_add_fill_vertexdata(
+ cache, ob, gpl, derived_gpf, gps,
+ opacity, tintcolor, false, custonion);
+ }
+ /* stroke */
+ if ((gp_style->flag & GP_STYLE_STROKE_SHOW) &&
+ ((gp_style->stroke_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) ||
+ (gpl->blend_mode == eGplBlendMode_Normal)))
+ {
+ gpencil_add_stroke_vertexdata(
+ cache, ob, gpl, derived_gpf, gps,
+ opacity, tintcolor, false, custonion);
+ }
}
}
@@ -1253,12 +1270,21 @@ static void DRW_gpencil_create_batches(GpencilBatchCache *cache)
/* create all shading groups */
static void DRW_gpencil_shgroups_create(
GPENCIL_e_data *e_data, void *vedata,
- Object *ob, bGPdata *gpd,
+ Object *ob,
GpencilBatchCache *cache, tGPencilObjectCache *cache_ob)
{
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
+ bGPdata *gpd = (bGPdata *)ob->data;
+
+ GpencilBatchGroup *elm = NULL;
DRWShadingGroup *shgrp = NULL;
+ tGPencilObjectCache_shgrp *array_elm = NULL;
+
+ bGPDlayer *gpl = NULL;
+ bGPDlayer *gpl_prev = NULL;
+ int idx = 0;
+ bool tag_first = false;
int start_stroke = 0;
int start_point = 0;
@@ -1266,12 +1292,27 @@ static void DRW_gpencil_shgroups_create(
int start_edit = 0;
int start_edlin = 0;
- cache_ob->init_grp = NULL;
- cache_ob->end_grp = NULL;
-
for (int i = 0; i < cache->grp_used; i++) {
- GpencilBatchGroup *elm = &cache->grp_cache[i];
- bGPDlayer *gpl = elm->gpl;
+ elm = &cache->grp_cache[i];
+ array_elm = &cache_ob->shgrp_array[idx];
+
+ /* save last group when change */
+ if (gpl_prev == NULL) {
+ gpl_prev = elm->gpl;
+ tag_first = true;
+ }
+ else {
+ if (elm->gpl != gpl_prev) {
+ /* first layer is always blend Normal */
+ array_elm->mode = idx == 0 ? eGplBlendMode_Normal: gpl->blend_mode;
+ array_elm->end_shgrp = shgrp;
+ gpl_prev = elm->gpl;
+ tag_first = true;
+ idx++;
+ }
+ }
+
+ gpl = elm->gpl;
bGPDframe *gpf = elm->gpf;
bGPDstroke *gps = elm->gps;
MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
@@ -1365,14 +1406,22 @@ static void DRW_gpencil_shgroups_create(
}
}
/* save first group */
- if ((shgrp != NULL) && (cache_ob->init_grp == NULL)) {
- cache_ob->init_grp = shgrp;
+ if ((shgrp != NULL) && (tag_first)) {
+ array_elm = &cache_ob->shgrp_array[idx];
+ array_elm->mode = idx == 0 ? eGplBlendMode_Normal: gpl->blend_mode;
+ array_elm->clamp_layer = gpl->flag & GP_LAYER_USE_MASK;
+ array_elm->blend_opacity = gpl->opacity;
+ array_elm->init_shgrp = shgrp;
+ cache_ob->tot_layers++;
+
+ tag_first = false;
}
}
/* save last group */
if (shgrp != NULL) {
- cache_ob->end_grp = shgrp;
+ array_elm->mode = idx == 0 ? eGplBlendMode_Normal : gpl->blend_mode;
+ array_elm->end_shgrp = shgrp;
}
}
/* populate a datablock for multiedit (no onions, no modifiers) */
@@ -1425,7 +1474,7 @@ void DRW_gpencil_populate_multiedit(
/* create batchs and shading groups */
DRW_gpencil_create_batches(cache);
- DRW_gpencil_shgroups_create(e_data, vedata, ob, gpd, cache, cache_ob);
+ DRW_gpencil_shgroups_create(e_data, vedata, ob, cache, cache_ob);
cache->is_dirty = false;
}
@@ -1465,7 +1514,7 @@ void DRW_gpencil_populate_datablock(
/* if object is duplicate, only create shading groups */
if (cache_ob->is_dup_ob) {
- DRW_gpencil_shgroups_create(e_data, vedata, ob, gpd, cache, cache_ob);
+ DRW_gpencil_shgroups_create(e_data, vedata, ob, cache, cache_ob);
return;
}
@@ -1481,8 +1530,9 @@ void DRW_gpencil_populate_datablock(
/* draw normal strokes */
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* don't draw layer if hidden */
- if (gpl->flag & GP_LAYER_HIDE)
+ if (gpl->flag & GP_LAYER_HIDE) {
continue;
+ }
/* filter view layer to gp layers in the same view layer (for compo) */
if ((stl->storage->is_render) && (gpl->viewlayername[0] != '\0')) {
@@ -1560,7 +1610,7 @@ void DRW_gpencil_populate_datablock(
/* create batchs and shading groups */
DRW_gpencil_create_batches(cache);
- DRW_gpencil_shgroups_create(e_data, vedata, ob, gpd, cache, cache_ob);
+ DRW_gpencil_shgroups_create(e_data, vedata, ob, cache, cache_ob);
cache->is_dirty = false;
}
@@ -1574,9 +1624,10 @@ void DRW_gpencil_populate_particles(GPENCIL_e_data *e_data, void *vedata)
tGPencilObjectCache *cache_ob = &stl->g_data->gp_object_cache[i];
Object *ob = cache_ob->ob;
if (cache_ob->is_dup_ob) {
- bGPdata *gpd = (bGPdata *)ob->data;
GpencilBatchCache *cache = ob->runtime.gpencil_cache;
- DRW_gpencil_shgroups_create(e_data, vedata, ob, gpd, cache, cache_ob);
+ if (cache != NULL) {
+ DRW_gpencil_shgroups_create(e_data, vedata, ob, cache, cache_ob);
+ }
}
}
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 7be06d501f1..483d6a80991 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -64,6 +64,7 @@ extern char datatoc_gpencil_paper_frag_glsl[];
extern char datatoc_gpencil_edit_point_vert_glsl[];
extern char datatoc_gpencil_edit_point_geom_glsl[];
extern char datatoc_gpencil_edit_point_frag_glsl[];
+extern char datatoc_gpencil_blend_frag_glsl[];
/* *********** STATIC *********** */
static GPENCIL_e_data e_data = {NULL}; /* Engine data */
@@ -221,6 +222,11 @@ static void GPENCIL_create_shaders(void)
e_data.gpencil_simple_fullscreen_sh = DRW_shader_create_fullscreen(datatoc_gpencil_simple_mix_frag_glsl, NULL);
}
+ /* blend */
+ if (!e_data.gpencil_blend_fullscreen_sh) {
+ e_data.gpencil_blend_fullscreen_sh = DRW_shader_create_fullscreen(datatoc_gpencil_blend_frag_glsl, NULL);
+ }
+
/* shaders for use when drawing */
if (!e_data.gpencil_background_sh) {
e_data.gpencil_background_sh = DRW_shader_create_fullscreen(datatoc_gpencil_background_frag_glsl, NULL);
@@ -266,6 +272,7 @@ static void GPENCIL_engine_free(void)
DRW_SHADER_FREE_SAFE(e_data.gpencil_edit_point_sh);
DRW_SHADER_FREE_SAFE(e_data.gpencil_fullscreen_sh);
DRW_SHADER_FREE_SAFE(e_data.gpencil_simple_fullscreen_sh);
+ DRW_SHADER_FREE_SAFE(e_data.gpencil_blend_fullscreen_sh);
DRW_SHADER_FREE_SAFE(e_data.gpencil_background_sh);
DRW_SHADER_FREE_SAFE(e_data.gpencil_paper_sh);
@@ -371,6 +378,7 @@ void GPENCIL_cache_init(void *vedata)
stl->storage->simplify_fill = GP_SIMPLIFY_FILL(scene, stl->storage->is_playing);
stl->storage->simplify_modif = GP_SIMPLIFY_MODIF(scene, stl->storage->is_playing);
stl->storage->simplify_fx = GP_SIMPLIFY_FX(scene, stl->storage->is_playing);
+ stl->storage->simplify_blend = GP_SIMPLIFY_BLEND(scene, stl->storage->is_playing);
/* save pixsize */
stl->storage->pixsize = DRW_viewport_pixelsize_get();
@@ -485,6 +493,21 @@ void GPENCIL_cache_init(void *vedata)
stl->g_data->shgrps_grid = DRW_shgroup_create(e_data.gpencil_line_sh, psl->grid_pass);
}
+ /* blend layers pass */
+ psl->blend_pass = DRW_pass_create(
+ "GPencil Blend Layers Pass",
+ DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
+ DRWShadingGroup *blend_shgrp = DRW_shgroup_create(e_data.gpencil_blend_fullscreen_sh, psl->blend_pass);
+ DRW_shgroup_call_add(blend_shgrp, quad, NULL);
+ DRW_shgroup_uniform_texture_ref(blend_shgrp, "strokeColor", &e_data.temp_color_tx_a);
+ DRW_shgroup_uniform_texture_ref(blend_shgrp, "strokeDepth", &e_data.temp_depth_tx_a);
+ DRW_shgroup_uniform_texture_ref(blend_shgrp, "blendColor", &e_data.temp_color_tx_fx);
+ DRW_shgroup_uniform_texture_ref(blend_shgrp, "blendDepth", &e_data.temp_depth_tx_fx);
+ DRW_shgroup_uniform_int(blend_shgrp, "mode", &stl->storage->blend_mode, 1);
+ DRW_shgroup_uniform_int(blend_shgrp, "clamp_layer", &stl->storage->clamp_layer, 1);
+ DRW_shgroup_uniform_float(blend_shgrp, "blend_opacity", &stl->storage->blend_opacity, 1);
+ DRW_shgroup_uniform_int(mix_shgrp, "tonemapping", &stl->storage->tonemapping, 1);
+
/* create effects passes */
if (!stl->storage->simplify_fx) {
GPENCIL_create_fx_passes(psl);
@@ -639,12 +662,40 @@ static void gpencil_free_obj_runtime(GPENCIL_StorageList *stl)
tGPencilObjectCache *cache_ob = &stl->g_data->gp_object_cache[i];
bGPdata *gpd = cache_ob->gpd;
gpd->flag &= ~GP_DATA_CACHE_IS_DIRTY;
+
+ /* free shgrp array */
+ cache_ob->tot_layers = 0;
+ MEM_SAFE_FREE(cache_ob->shgrp_array);
}
/* free the cache itself */
MEM_SAFE_FREE(stl->g_data->gp_object_cache);
}
+static void gpencil_draw_pass_range(
+ GPENCIL_FramebufferList *fbl, GPENCIL_StorageList *stl,
+ GPENCIL_PassList *psl, GPENCIL_TextureList *txl,
+ GPUFrameBuffer *fb,
+ DRWShadingGroup *init_shgrp, DRWShadingGroup *end_shgrp, bool multi)
+{
+ if (init_shgrp == NULL) {
+ return;
+ }
+
+ /* previews don't use AA */
+ if ((!stl->storage->is_mat_preview) && (multi)) {
+ MULTISAMPLE_GP_SYNC_ENABLE(stl->storage->multisamples, fbl);
+ }
+
+ DRW_draw_pass_subset(
+ psl->stroke_pass, init_shgrp, end_shgrp);
+
+ if ((!stl->storage->is_mat_preview) && (multi)) {
+ MULTISAMPLE_GP_SYNC_DISABLE(stl->storage->multisamples, fbl, fb, txl);
+ }
+
+}
+
/* draw scene */
void GPENCIL_draw_scene(void *ved)
{
@@ -657,6 +708,10 @@ void GPENCIL_draw_scene(void *ved)
GPENCIL_TextureList *txl = ((GPENCIL_Data *)vedata)->txl;
tGPencilObjectCache *cache_ob;
+ tGPencilObjectCache_shgrp *array_elm = NULL;
+ DRWShadingGroup *init_shgrp = NULL;
+ DRWShadingGroup *end_shgrp = NULL;
+
const float clearcol[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -712,7 +767,7 @@ void GPENCIL_draw_scene(void *ved)
for (int i = 0; i < stl->g_data->gp_cache_used; i++) {
cache_ob = &stl->g_data->gp_object_cache[i];
bGPdata *gpd = cache_ob->gpd;
-
+ init_shgrp = NULL;
/* Render stroke in separated framebuffer */
GPU_framebuffer_bind(fbl->temp_fb_a);
GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
@@ -720,19 +775,69 @@ void GPENCIL_draw_scene(void *ved)
/* Stroke Pass:
* draw only a subset that usually starts with a fill and ends with stroke
*/
- if (cache_ob->init_grp) {
- /* previews don't use AA */
- if (!stl->storage->is_mat_preview) {
- MULTISAMPLE_GP_SYNC_ENABLE(stl->storage->multisamples, fbl);
- }
+ bool use_blend = false;
+ if (cache_ob->tot_layers > 0) {
+ for (int e = 0; e < cache_ob->tot_layers; e++) {
+ bool is_last = e == cache_ob->tot_layers - 1 ? true : false;
+ array_elm = &cache_ob->shgrp_array[e];
+
+ if (((array_elm->mode == eGplBlendMode_Normal) &&
+ (!use_blend) && (!array_elm->clamp_layer)) ||
+ (e == 0))
+ {
+ if (init_shgrp == NULL) {
+ init_shgrp = array_elm->init_shgrp;
+ }
+ end_shgrp = array_elm->end_shgrp;
+ }
+ else {
+ use_blend = true;
+ /* draw pending groups */
+ gpencil_draw_pass_range(
+ fbl, stl, psl, txl, fbl->temp_fb_a,
+ init_shgrp, end_shgrp, is_last);
+
+ /* draw current group in separated texture */
+ init_shgrp = array_elm->init_shgrp;
+ end_shgrp = array_elm->end_shgrp;
+
+ GPU_framebuffer_bind(fbl->temp_fb_fx);
+ GPU_framebuffer_clear_color_depth(fbl->temp_fb_fx, clearcol, 1.0f);
+ gpencil_draw_pass_range(
+ fbl, stl, psl, txl, fbl->temp_fb_fx,
+ init_shgrp, end_shgrp,
+ is_last);
+
+ /* Blend A texture and FX texture */
+ GPU_framebuffer_bind(fbl->temp_fb_b);
+ GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
+ stl->storage->blend_mode = array_elm->mode;
+ stl->storage->clamp_layer = (int)array_elm->clamp_layer;
+ stl->storage->blend_opacity = array_elm->blend_opacity;
+ stl->storage->tonemapping = stl->storage->is_render ? 1 : 0;
+ DRW_draw_pass(psl->blend_pass);
+ stl->storage->tonemapping = 0;
+
+ /* Copy B texture to A texture to follow loop */
+ e_data.input_depth_tx = e_data.temp_depth_tx_b;
+ e_data.input_color_tx = e_data.temp_color_tx_b;
+
+ GPU_framebuffer_bind(fbl->temp_fb_a);
+ GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
+ DRW_draw_pass(psl->mix_pass_noblend);
+
+ /* prepare next group */
+ init_shgrp = NULL;
+ }
- DRW_draw_pass_subset(
- psl->stroke_pass, cache_ob->init_grp, cache_ob->end_grp);
-
- if (!stl->storage->is_mat_preview) {
- MULTISAMPLE_GP_SYNC_DISABLE(stl->storage->multisamples, fbl, fbl->temp_fb_a, txl);
}
+ /* last group */
+ gpencil_draw_pass_range(
+ fbl, stl, psl, txl, fbl->temp_fb_a,
+ init_shgrp, end_shgrp,
+ true);
}
+
/* Current buffer drawing */
if ((!is_render) && (cache_ob->is_dup_ob == false)) {
DRW_draw_pass(psl->drawing_pass);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 0fe25ba9f0f..b8b526cb873 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -54,17 +54,23 @@ struct RenderLayer;
#define GP_SIMPLIFY_FILL(scene, playing) ((GP_SIMPLIFY_ONPLAY(playing) && (GP_SIMPLIFY(scene)) && (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_FILL)))
#define GP_SIMPLIFY_MODIF(scene, playing) ((GP_SIMPLIFY_ONPLAY(playing) && (GP_SIMPLIFY(scene)) && (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_MODIFIER)))
#define GP_SIMPLIFY_FX(scene, playing) ((GP_SIMPLIFY_ONPLAY(playing) && (GP_SIMPLIFY(scene)) && (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_FX)))
+#define GP_SIMPLIFY_BLEND(scene, playing) ((GP_SIMPLIFY_ONPLAY(playing) && (GP_SIMPLIFY(scene)) && (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_BLEND)))
#define GP_IS_CAMERAVIEW ((rv3d != NULL) && (rv3d->persp == RV3D_CAMOB && v3d->camera))
/* *********** OBJECTS CACHE *********** */
+typedef struct tGPencilObjectCache_shgrp {
+ int mode;
+ bool clamp_layer;
+ float blend_opacity;
+ DRWShadingGroup *init_shgrp;
+ DRWShadingGroup *end_shgrp;
+} tGPencilObjectCache_shgrp;
/* used to save gpencil object data for drawing */
typedef struct tGPencilObjectCache {
struct Object *ob;
struct bGPdata *gpd;
- DRWShadingGroup *init_grp;
- DRWShadingGroup *end_grp;
int idx; /*original index, can change after sort */
/* effects */
@@ -90,6 +96,11 @@ typedef struct tGPencilObjectCache {
/* GPU data size */
int tot_vertex;
int tot_triangles;
+
+ /* Save shader groups by layer */
+ int tot_layers;
+ tGPencilObjectCache_shgrp *shgrp_array;
+
} tGPencilObjectCache;
/* *********** LISTS *********** */
@@ -127,10 +138,15 @@ typedef struct GPENCIL_Storage {
int tonemapping;
short multisamples;
+ int blend_mode;
+ int clamp_layer;
+ float blend_opacity;
+
/* simplify settings*/
bool simplify_fill;
bool simplify_modif;
bool simplify_fx;
+ bool simplify_blend;
/* Render Matrices and data */
float persmat[4][4], persinv[4][4];
@@ -158,6 +174,7 @@ typedef struct GPENCIL_PassList {
struct DRWPass *background_pass;
struct DRWPass *paper_pass;
struct DRWPass *grid_pass;
+ struct DRWPass *blend_pass;
/* effects */
struct DRWPass *fx_shader_pass;
@@ -232,6 +249,7 @@ typedef struct GPENCIL_e_data {
struct GPUShader *gpencil_drawing_fill_sh;
struct GPUShader *gpencil_fullscreen_sh;
struct GPUShader *gpencil_simple_fullscreen_sh;
+ struct GPUShader *gpencil_blend_fullscreen_sh;
struct GPUShader *gpencil_background_sh;
struct GPUShader *gpencil_paper_sh;
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index fcadf296253..673b47ff052 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -443,6 +443,9 @@ static void DRW_gpencil_fx_shadow(
}
ShadowShaderFxData *fxd = (ShadowShaderFxData *)fx;
if ((!fxd->object) && (fxd->flag & FX_SHADOW_USE_OBJECT)) {
+ fxd->runtime.fx_sh = NULL;
+ fxd->runtime.fx_sh_b = NULL;
+ fxd->runtime.fx_sh_c = NULL;
return;
}
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
new file mode 100644
index 00000000000..f5696116eea
--- /dev/null
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
@@ -0,0 +1,155 @@
+in vec4 uvcoordsvar;
+
+out vec4 FragColor;
+
+uniform sampler2D strokeColor;
+uniform sampler2D strokeDepth;
+uniform sampler2D blendColor;
+uniform sampler2D blendDepth;
+uniform int mode;
+uniform int clamp_layer;
+uniform float blend_opacity;
+uniform int tonemapping;
+
+#define ON 1
+#define OFF 0
+
+#define MODE_NORMAL 0
+#define MODE_OVERLAY 1
+#define MODE_ADD 2
+#define MODE_SUB 3
+#define MODE_MULTIPLY 4
+#define MODE_DIVIDE 5
+
+float overlay_color(float a, float b)
+{
+ float rtn;
+ if (a < 0.5) {
+ rtn = 2.0 * a * b;
+ }
+ else {
+ rtn = 1.0 - 2.0 * (1.0 - a) * (1.0 - b);
+ }
+
+ return rtn;
+}
+
+vec4 get_blend_color(int mode, vec4 src_color, vec4 blend_color)
+{
+ vec4 mix_color = blend_color;
+ vec4 outcolor;
+
+ if (mix_color.a == 0) {
+ outcolor = src_color;
+ }
+ else if (mode == MODE_OVERLAY) {
+ mix_color.rgb = mix_color.rgb * mix_color.a * blend_opacity;
+ outcolor.r = overlay_color(src_color.r, mix_color.r);
+ outcolor.g = overlay_color(src_color.g, mix_color.g);
+ outcolor.b = overlay_color(src_color.b, mix_color.b);
+ outcolor.a = src_color.a;
+ }
+ else if (mode == MODE_ADD){
+ mix_color.rgb = mix_color.rgb * mix_color.a * blend_opacity;
+ outcolor = src_color + mix_color;
+ outcolor.a = src_color.a;
+ }
+ else if (mode == MODE_SUB){
+ outcolor = src_color - mix_color;
+ outcolor.a = clamp(src_color.a - (mix_color.a * blend_opacity), 0.0, 1.0);
+ }
+ else if (mode == MODE_MULTIPLY) {
+ /* interpolate between 1 and color using opacity */
+ mix_color.rgb = mix(vec3(1,1,1), mix_color.rgb * mix_color.a, blend_opacity);
+ outcolor = src_color * mix_color;
+ outcolor.a = src_color.a;
+ }
+ else if (mode == MODE_DIVIDE) {
+ mix_color.rgb = mix_color.rgb * mix_color.a * blend_opacity;
+ outcolor = src_color / mix_color;
+ outcolor.a = src_color.a;
+ }
+ else {
+ outcolor = mix_color * blend_opacity;;
+ outcolor.a = src_color.a;
+ }
+
+ return outcolor;
+}
+
+float linearrgb_to_srgb(float c)
+{
+ if (c < 0.0031308)
+ return (c < 0.0) ? 0.0 : c * 12.92;
+ else
+ return 1.055 * pow(c, 1.0 / 2.4) - 0.055;
+}
+
+vec4 tone(vec4 stroke_color)
+{
+ if (tonemapping == 1) {
+ vec4 color = vec4(0, 0, 0, stroke_color.a);
+ color.r = linearrgb_to_srgb(stroke_color.r);
+ color.g = linearrgb_to_srgb(stroke_color.g);
+ color.b = linearrgb_to_srgb(stroke_color.b);
+ return color;
+ }
+ else {
+ return stroke_color;
+ }
+}
+
+void main()
+{
+ vec4 outcolor;
+ ivec2 uv = ivec2(gl_FragCoord.xy);
+ vec4 stroke_color = texelFetch(strokeColor, uv, 0).rgba;
+ float stroke_depth = texelFetch(strokeDepth, uv, 0).r;
+
+ vec4 mix_color = texelFetch(blendColor, uv, 0).rgba;
+ float mix_depth = texelFetch(blendDepth, uv, 0).r;
+
+ /* premult alpha factor to remove double blend effects */
+ if (stroke_color.a > 0) {
+ stroke_color = vec4(vec3(stroke_color.rgb / stroke_color.a), stroke_color.a);
+ }
+ if (mix_color.a > 0) {
+ mix_color = vec4(vec3(mix_color.rgb / mix_color.a), mix_color.a);
+ }
+
+ /* Normal mode */
+ if (mode == MODE_NORMAL) {
+ if (stroke_color.a > 0) {
+ if (mix_color.a > 0) {
+ FragColor = vec4(mix(stroke_color.rgb, mix_color.rgb, mix_color.a), stroke_color.a);
+ gl_FragDepth = mix_depth;
+ }
+ else {
+ FragColor = stroke_color;
+ gl_FragDepth = stroke_depth;
+ }
+ }
+ else {
+ if (clamp_layer == ON) {
+ discard;
+ }
+ else {
+ FragColor = mix_color;
+ gl_FragDepth = mix_depth;
+ }
+ }
+ FragColor = tone(FragColor);
+ return;
+ }
+
+ /* if not using mask, return mix color */
+ if ((stroke_color.a == 0) && (clamp_layer == OFF)) {
+ FragColor = tone(mix_color);
+ gl_FragDepth = mix_depth;
+ return;
+ }
+
+ /* apply blend mode */
+ FragColor = tone(get_blend_color(mode, stroke_color, mix_color));
+ gl_FragDepth = stroke_depth;
+}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl
index fafb164a694..769d453bb18 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_cavity_frag.glsl
@@ -3,6 +3,7 @@ out vec4 fragColor;
uniform sampler2D depthBuffer;
uniform sampler2D colorBuffer;
uniform sampler2D normalBuffer;
+uniform usampler2D objectId;
uniform vec2 invertedViewportSize;
uniform mat4 WinMatrix; /* inverse WinMatrix */
@@ -10,6 +11,7 @@ uniform mat4 WinMatrix; /* inverse WinMatrix */
uniform vec4 viewvecs[3];
uniform vec4 ssao_params;
uniform vec4 ssao_settings;
+uniform vec2 curvature_settings;
uniform sampler2D ssao_jitter;
layout(std140) uniform samples_block {
@@ -23,7 +25,7 @@ layout(std140) uniform samples_block {
#define ssao_distance ssao_settings.x
#define ssao_factor_cavity ssao_settings.y
#define ssao_factor_edge ssao_settings.z
-#define ssao_attenuation ssao_settings.a
+#define ssao_attenuation ssao_settings.w
vec3 get_view_space_from_depth(in vec2 uvcoords, in float depth)
{
@@ -54,17 +56,22 @@ void main()
vec2 screenco = vec2(gl_FragCoord.xy) * invertedViewportSize;
ivec2 texel = ivec2(gl_FragCoord.xy);
+ float cavity = 0.0, edges = 0.0, curvature = 0.0;
+
+#ifdef USE_CAVITY
float depth = texelFetch(depthBuffer, texel, 0).x;
vec3 position = get_view_space_from_depth(screenco, depth);
+ vec3 normal_viewport = workbench_normal_decode(texelFetch(normalBuffer, texel, 0).rg);
- vec4 diffuse_color = texelFetch(colorBuffer, texel, 0);
- vec3 normal_viewport = normal_decode(texelFetch(normalBuffer, texel, 0).rg);
- if (diffuse_color.a == 0.0) {
- normal_viewport = -normal_viewport;
- }
-
- float cavity = 0.0, edges = 0.0;
ssao_factors(depth, normal_viewport, position, screenco, cavity, edges);
+#endif
+
+#ifdef USE_CURVATURE
+ curvature = calculate_curvature(objectId, normalBuffer, texel, curvature_settings.x, curvature_settings.y);
+#endif
+
+ float final_cavity_factor = clamp((1.0 - cavity) * (1.0 + edges) * (1.0 + curvature), 0.0, 4.0);
- fragColor = vec4(cavity, edges, 0.0, 1.0);
+ /* Using UNORM render target so compress the range. */
+ fragColor = vec4(final_cavity_factor / CAVITY_BUFFER_RANGE);
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
index c56e02e72d6..1b9b29b8ca2 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
@@ -2,6 +2,8 @@
#define EPSILON 0.00001
#define M_PI 3.14159265358979323846
+#define CAVITY_BUFFER_RANGE 4.0
+
/* 4x4 bayer matrix prepared for 8bit UNORM precision error. */
#define P(x) (((x + 0.5) * (1.0 / 16.0) - 0.5) * (1.0 / 255.0))
const vec4 dither_mat4x4[4] = vec4[4](
@@ -17,9 +19,13 @@ float bayer_dither_noise() {
return dither_mat4x4[tx1.x][tx1.y];
}
+#ifdef WORKBENCH_ENCODE_NORMALS
+
+#define WB_Normal vec2
+
/* From http://aras-p.info/texts/CompactNormalStorage.html
* Using Method #4: Spheremap Transform */
-vec3 normal_decode(vec2 enc)
+vec3 workbench_normal_decode(WB_Normal enc)
{
vec2 fenc = enc.xy * 4.0 - 2.0;
float f = dot(fenc, fenc);
@@ -32,37 +38,45 @@ vec3 normal_decode(vec2 enc)
/* From http://aras-p.info/texts/CompactNormalStorage.html
* Using Method #4: Spheremap Transform */
-vec2 normal_encode(vec3 n)
+WB_Normal workbench_normal_encode(vec3 n)
{
float p = sqrt(n.z * 8.0 + 8.0);
- return vec2(n.xy / p + 0.5);
+ n.xy = clamp(n.xy / p + 0.5, 0.0, 1.0);
+ return n.xy;
}
-void fresnel(vec3 I, vec3 N, float ior, out float kr)
+#else
+#define WB_Normal vec3
+/* Well just do nothing... */
+# define workbench_normal_encode(a) (a)
+# define workbench_normal_decode(a) (a)
+#endif /* WORKBENCH_ENCODE_NORMALS */
+
+/* Encoding into the alpha of a RGBA8 UNORM texture. */
+#define TARGET_BITCOUNT 8u
+#define METALLIC_BITS 3u /* Metallic channel is less important. */
+#define ROUGHNESS_BITS (TARGET_BITCOUNT - METALLIC_BITS)
+#define TOTAL_BITS (METALLIC_BITS + ROUGHNESS_BITS)
+
+/* Encode 2 float into 1 with the desired precision. */
+float workbench_float_pair_encode(float v1, float v2)
{
- float cosi = clamp(dot(I, N), -1.0, 1.0);
- float etai = 1.0;
- float etat = ior;
- if (cosi > 0) {
- etat = 1.0;
- etai = ior;
- }
+ const uint total_mask = ~(0xFFFFFFFFu << TOTAL_BITS);
+ const uint v1_mask = ~(0xFFFFFFFFu << ROUGHNESS_BITS);
+ const uint v2_mask = ~(0xFFFFFFFFu << METALLIC_BITS);
+ int iv1 = int(v1 * float(v1_mask));
+ int iv2 = int(v2 * float(v2_mask)) << ROUGHNESS_BITS;
+ return float(iv1 | iv2) * (1.0 / float(total_mask));
+}
- // Compute sini using Snell's law
- float sint = etai / etat * sqrt(max(0.0, 1.0 - cosi * cosi));
- // Total internal reflection
- if (sint >= 1) {
- kr = 1;
- }
- else {
- float cost = sqrt(max(0.0, 1.0 - sint * sint));
- cosi = abs(cosi);
- float Rs = ((etat * cosi) - (etai * cost)) / ((etat * cosi) + (etai * cost));
- float Rp = ((etai * cosi) - (etat * cost)) / ((etai * cosi) + (etat * cost));
- kr = (Rs * Rs + Rp * Rp) / 2;
- }
- // As a consequence of the conservation of energy, transmittance is given by:
- // kt = 1 - kr;
+void workbench_float_pair_decode(float data, out float v1, out float v2)
+{
+ const uint total_mask = ~(0xFFFFFFFFu << TOTAL_BITS);
+ const uint v1_mask = ~(0xFFFFFFFFu << ROUGHNESS_BITS);
+ const uint v2_mask = ~(0xFFFFFFFFu << METALLIC_BITS);
+ uint idata = uint(data * float(total_mask));
+ v1 = float(idata & v1_mask) * (1.0 / float(v1_mask));
+ v2 = float(idata >> ROUGHNESS_BITS) * (1.0 / float(v2_mask));
}
float calculate_transparent_weight(float z, float alpha)
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_curvature_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_curvature_lib.glsl
new file mode 100644
index 00000000000..d0281f6c85c
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_curvature_lib.glsl
@@ -0,0 +1,41 @@
+#ifndef CURVATURE_OFFSET
+# define CURVATURE_OFFSET 1
+#endif
+
+float curvature_soft_clamp(float curvature, float control)
+{
+ if (curvature < 0.5 / control) {
+ return curvature * (1.0 - curvature * control);
+ }
+ return 0.25 / control;
+}
+
+float calculate_curvature(usampler2D objectId, sampler2D normalBuffer, ivec2 texel, float ridge, float valley)
+{
+ uint object_up = texelFetchOffset(objectId, texel, 0, ivec2(0, CURVATURE_OFFSET)).r;
+ uint object_down = texelFetchOffset(objectId, texel, 0, ivec2(0, -CURVATURE_OFFSET)).r;
+ uint object_left = texelFetchOffset(objectId, texel, 0, ivec2(-CURVATURE_OFFSET, 0)).r;
+ uint object_right = texelFetchOffset(objectId, texel, 0, ivec2( CURVATURE_OFFSET, 0)).r;
+
+ if((object_up != object_down) || (object_right != object_left)) {
+ return 0.0;
+ }
+
+ vec2 normal_up = texelFetchOffset(normalBuffer, texel, 0, ivec2(0, CURVATURE_OFFSET)).rg;
+ vec2 normal_down = texelFetchOffset(normalBuffer, texel, 0, ivec2(0, -CURVATURE_OFFSET)).rg;
+ vec2 normal_left = texelFetchOffset(normalBuffer, texel, 0, ivec2(-CURVATURE_OFFSET, 0)).rg;
+ vec2 normal_right = texelFetchOffset(normalBuffer, texel, 0, ivec2( CURVATURE_OFFSET, 0)).rg;
+
+ normal_up = workbench_normal_decode(normal_up ).rg;
+ normal_down = workbench_normal_decode(normal_down ).rg;
+ normal_left = workbench_normal_decode(normal_left ).rg;
+ normal_right = workbench_normal_decode(normal_right).rg;
+
+ float normal_diff = ((normal_up.g - normal_down.g) + (normal_right.r - normal_left.r));
+
+ if (normal_diff < 0) {
+ return -2.0 * curvature_soft_clamp(-normal_diff, valley);
+ }
+
+ return 2.0 * curvature_soft_clamp(normal_diff, ridge);
+}
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 7ba6b3a5193..6deb29f6bca 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
@@ -1,17 +1,20 @@
struct LightData {
- vec4 light_direction_vs;
+ vec4 direction;
vec4 specular_color;
+ vec4 diffuse_color_wrap; /* rgb: diffuse col a: wrapped lighting factor */
};
struct WorldData {
- vec3 spherical_harmonics_coefs[STUDIOLIGHT_SH_MAX_COMPONENTS];
vec4 background_color_low;
vec4 background_color_high;
vec4 object_outline_color;
vec4 shadow_direction_vs;
- LightData lights[3];
+ LightData lights[4];
+ vec4 ambient_color;
int num_lights;
int matcap_orientation;
float background_alpha;
- int pad[1];
+ float curvature_ridge;
+ float curvature_valley;
+ int pad[3];
};
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_deferred_background_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_deferred_background_frag.glsl
new file mode 100644
index 00000000000..9e4394238ff
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_deferred_background_frag.glsl
@@ -0,0 +1,39 @@
+
+uniform usampler2D objectId;
+
+uniform vec2 invertedViewportSize;
+
+out vec4 fragColor;
+
+layout(std140) uniform world_block {
+ WorldData world_data;
+};
+
+void main()
+{
+ vec2 uv_viewport = gl_FragCoord.xy * invertedViewportSize;
+ vec3 background = background_color(world_data, uv_viewport.y);
+
+#ifndef V3D_SHADING_OBJECT_OUTLINE
+
+ fragColor = vec4(background, world_data.background_alpha);
+
+#else /* !V3D_SHADING_OBJECT_OUTLINE */
+
+ ivec2 texel = ivec2(gl_FragCoord.xy);
+ uint object_id = texelFetch(objectId, texel, 0).r;
+ float object_outline = calculate_object_outline(objectId, texel, object_id);
+
+ if (object_outline == 0.0) {
+ fragColor = vec4(background, world_data.background_alpha);
+ }
+ else {
+ /* Do correct alpha blending. */
+ vec4 background_color = vec4(background, 1.0) * world_data.background_alpha;
+ vec4 outline_color = vec4(world_data.object_outline_color.rgb, 1.0);
+ fragColor = mix(outline_color, background_color, object_outline);
+ fragColor = vec4(fragColor.rgb / max(1e-8, fragColor.a), fragColor.a);
+ }
+
+#endif /* !V3D_SHADING_OBJECT_OUTLINE */
+}
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 508aeb1f0c1..40e166bc7ac 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
@@ -1,24 +1,23 @@
out vec4 fragColor;
uniform mat4 ProjectionMatrix;
+uniform mat4 ViewMatrixInverse;
uniform usampler2D objectId;
-uniform sampler2D colorBuffer;
-uniform sampler2D specularBuffer;
+uniform sampler2D materialBuffer;
uniform sampler2D normalBuffer;
/* normalBuffer contains viewport normals */
uniform sampler2D cavityBuffer;
+uniform sampler2D matcapImage;
uniform vec2 invertedViewportSize;
uniform vec4 viewvecs[3];
uniform float shadowMultiplier;
uniform float lightMultiplier;
uniform float shadowShift = 0.1;
-uniform mat3 normalWorldMatrix;
+uniform float shadowFocus = 1.0;
-#ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL
-uniform sampler2D matcapImage;
-#endif
+uniform vec3 materialSingleColor;
layout(std140) uniform world_block {
WorldData world_data;
@@ -28,102 +27,72 @@ void main()
{
ivec2 texel = ivec2(gl_FragCoord.xy);
vec2 uv_viewport = gl_FragCoord.xy * invertedViewportSize;
- uint object_id = texelFetch(objectId, texel, 0).r;
-#ifndef V3D_SHADING_OBJECT_OUTLINE
- if (object_id == NO_OBJECT_ID) {
- fragColor = vec4(background_color(world_data, uv_viewport.y), world_data.background_alpha);
- return;
- }
-#else /* !V3D_SHADING_OBJECT_OUTLINE */
- float object_outline = calculate_object_outline(objectId, texel, object_id);
+ float roughness, metallic;
+ vec3 base_color;
- if (object_id == NO_OBJECT_ID) {
- vec3 background = background_color(world_data, uv_viewport.y);
- if (object_outline == 0.0) {
- fragColor = vec4(background, world_data.background_alpha);
- }
- else {
- /* Do correct alpha blending. */
- vec4 background_color = vec4(background, 1.0) * world_data.background_alpha;
- vec4 outline_color = vec4(world_data.object_outline_color.rgb, 1.0);
- fragColor = mix(outline_color, background_color, object_outline);
- fragColor = vec4(fragColor.rgb / max(1e-8, fragColor.a), fragColor.a);
- }
- return;
- }
-#endif /* !V3D_SHADING_OBJECT_OUTLINE */
-
- vec4 diffuse_color = texelFetch(colorBuffer, texel, 0);
+#ifndef MATDATA_PASS_ENABLED
+ base_color = materialSingleColor;
+ metallic = 0.0;
+ roughness = 0.5;
+#else
+ vec4 material_data = texelFetch(materialBuffer, texel, 0);
+ base_color = material_data.rgb;
+ workbench_float_pair_decode(material_data.a, roughness, metallic);
+#endif
/* Do we need normals */
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
-# ifdef WORKBENCH_ENCODE_NORMALS
- vec3 normal_viewport = normal_decode(texelFetch(normalBuffer, texel, 0).rg);
- if (diffuse_color.a == 0.0) {
- normal_viewport = -normal_viewport;
- }
-# else /* WORKBENCH_ENCODE_NORMALS */
- vec3 normal_viewport = texelFetch(normalBuffer, texel, 0).rgb;
-# endif /* WORKBENCH_ENCODE_NORMALS */
+ vec3 normal_viewport = workbench_normal_decode(texelFetch(normalBuffer, texel, 0).rg);
#endif
vec3 I_vs = view_vector_from_screen_uv(uv_viewport, viewvecs, ProjectionMatrix);
-#ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL
+ /* -------- SHADING --------- */
+#ifdef V3D_LIGHTING_FLAT
+ vec3 shaded_color = base_color;
+
+#elif defined(V3D_LIGHTING_MATCAP)
+ /* When using matcaps, the metallic is the backface sign. */
+ normal_viewport = (metallic > 0.0) ? normal_viewport : -normal_viewport;
bool flipped = world_data.matcap_orientation != 0;
vec2 matcap_uv = matcap_uv_compute(I_vs, normal_viewport, flipped);
- diffuse_color = textureLod(matcapImage, matcap_uv, 0.0);
-#endif
+ vec3 matcap = textureLod(matcapImage, matcap_uv, 0.0).rgb;
+ vec3 shaded_color = matcap * base_color;
-#ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
- vec4 specular_data = texelFetch(specularBuffer, texel, 0);
- vec3 specular_color = get_world_specular_lights(world_data, specular_data, normal_viewport, I_vs);
-#else
- vec3 specular_color = vec3(0.0);
-#endif
+#elif defined(V3D_LIGHTING_STUDIO)
-#ifdef V3D_LIGHTING_FLAT
- vec3 diffuse_light = vec3(1.0);
-#endif
-
-#ifdef V3D_LIGHTING_MATCAP
- vec3 diffuse_light = texelFetch(specularBuffer, texel, 0).rgb;
-#endif
-
-#ifdef V3D_LIGHTING_STUDIO
-# ifdef STUDIOLIGHT_ORIENTATION_CAMERA
- vec3 diffuse_light = get_camera_diffuse_light(world_data, normal_viewport);
+# ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
+ vec3 specular_color = mix(vec3(0.05), base_color, metallic);
+ vec3 diffuse_color = mix(base_color, vec3(0.0), metallic);
+# else
+ roughness = 0.0;
+ vec3 specular_color = vec3(0.0);
+ vec3 diffuse_color = base_color;
# endif
-# ifdef STUDIOLIGHT_ORIENTATION_WORLD
- vec3 normal_world = normalWorldMatrix * normal_viewport;
- vec3 diffuse_light = get_world_diffuse_light(world_data, normal_world);
-# endif
+ vec3 shaded_color = get_world_lighting(world_data,
+ diffuse_color, specular_color, roughness,
+ normal_viewport, I_vs);
#endif
- vec3 shaded_color = diffuse_light * diffuse_color.rgb + specular_color;
-#ifdef V3D_SHADING_CAVITY
- vec2 cavity = texelFetch(cavityBuffer, texel, 0).rg;
- shaded_color *= 1.0 - cavity.x;
- shaded_color *= 1.0 + cavity.y;
+ /* -------- POST EFFECTS --------- */
+#ifdef WB_CAVITY
+ /* Using UNORM texture so decompress the range */
+ shaded_color *= texelFetch(cavityBuffer, texel, 0).r * CAVITY_BUFFER_RANGE;
#endif
#ifdef V3D_SHADING_SHADOW
float light_factor = -dot(normal_viewport, world_data.shadow_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 = smoothstep(1.0, shadowShift, light_factor);
- float light_multiplier = mix(lightMultiplier, shadowMultiplier, shadow_mix);
-
-#else /* V3D_SHADING_SHADOW */
- float light_multiplier = 1.0;
-#endif /* V3D_SHADING_SHADOW */
-
- shaded_color *= light_multiplier;
+ float shadow_mix = smoothstep(shadowFocus, shadowShift, light_factor);
+ shaded_color *= mix(lightMultiplier, shadowMultiplier, shadow_mix);
+#endif
#ifdef V3D_SHADING_OBJECT_OUTLINE
+ uint object_id = texelFetch(objectId, texel, 0).r;
+ float object_outline = calculate_object_outline(objectId, texel, object_id);
shaded_color = mix(world_data.object_outline_color.rgb, shaded_color, object_outline);
-#endif /* V3D_SHADING_OBJECT_OUTLINE */
+#endif
+
fragColor = vec4(shaded_color, 1.0);
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl
index 1d9f37274bd..cb5516ca34f 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl
@@ -13,25 +13,23 @@ void main()
{
ivec2 texel = ivec2(gl_FragCoord.xy);
vec2 uv_viewport = gl_FragCoord.xy * invertedViewportSize;
- uint object_id = texelFetch(objectId, texel, 0).r;
/* Listing 4 */
vec4 trans_accum = texelFetch(transparentAccum, texel, 0);
float trans_revealage = trans_accum.a;
trans_accum.a = texelFetch(transparentRevealage, texel, 0).r;
-#ifdef V3D_SHADING_OBJECT_OUTLINE
- float outline = calculate_object_outline(objectId, texel, object_id);
-#else /* V3D_SHADING_OBJECT_OUTLINE */
- float outline = 1.0;
-#endif /* V3D_SHADING_OBJECT_OUTLINE */
vec3 bg_color = background_color(world_data, uv_viewport.y);
/* TODO: Bypass the whole shader if there is no xray pass and no outline pass. */
vec3 trans_color = trans_accum.rgb / clamp(trans_accum.a, 1e-4, 5e4);
vec3 color = mix(trans_color, bg_color, trans_revealage);
+#ifdef V3D_SHADING_OBJECT_OUTLINE
+ uint object_id = texelFetch(objectId, texel, 0).r;
+ float outline = calculate_object_outline(objectId, texel, object_id);
color = mix(world_data.object_outline_color.rgb, color, outline);
+#endif
fragColor = vec4(color, 1.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 67a22073a4b..d42b6bde791 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
@@ -4,13 +4,13 @@ uniform float ImageTransparencyCutoff = 0.1;
#endif
uniform mat4 ProjectionMatrix;
-uniform mat3 normalWorldMatrix;
+uniform mat4 ViewMatrixInverse;
uniform float alpha = 0.5;
uniform vec2 invertedViewportSize;
uniform vec4 viewvecs[3];
-uniform vec4 materialDiffuseColor;
-uniform vec4 materialSpecularColor;
+uniform vec3 materialDiffuseColor;
+uniform vec3 materialSpecularColor;
uniform float materialRoughness;
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
@@ -33,7 +33,6 @@ layout(location=1) out float revealageAccum; /* revealage actually stored in tra
void main()
{
vec4 diffuse_color;
- vec3 diffuse_light = vec3(1.0);
#ifdef V3D_SHADING_TEXTURE_COLOR
diffuse_color = texture(image, uv_interp);
@@ -41,7 +40,7 @@ void main()
discard;
}
#else
- diffuse_color = materialDiffuseColor;
+ diffuse_color = vec4(materialDiffuseColor, 1.0);
#endif /* V3D_SHADING_TEXTURE_COLOR */
vec2 uv_viewport = gl_FragCoord.xy * invertedViewportSize;
@@ -51,30 +50,22 @@ void main()
vec3 nor = normalize(normal_viewport);
#endif
-#ifdef V3D_LIGHTING_MATCAP
+ /* -------- SHADING --------- */
+#ifdef V3D_LIGHTING_FLAT
+ vec3 shaded_color = diffuse_color.rgb;
+
+#elif defined(V3D_LIGHTING_MATCAP)
bool flipped = world_data.matcap_orientation != 0;
vec2 matcap_uv = matcap_uv_compute(I_vs, nor, flipped);
- diffuse_light = texture(matcapImage, matcap_uv).rgb;
-#endif
+ vec3 matcap = textureLod(matcapImage, matcap_uv, 0.0).rgb;
+ vec3 shaded_color = matcap * diffuse_color.rgb;
-#ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
- vec3 specular_color = get_world_specular_lights(world_data, vec4(materialSpecularColor.rgb, materialRoughness), nor, I_vs);
-#else
- vec3 specular_color = vec3(0.0);
+#elif defined(V3D_LIGHTING_STUDIO)
+ vec3 shaded_color = get_world_lighting(world_data,
+ diffuse_color.rgb, materialSpecularColor, materialRoughness,
+ nor, I_vs);
#endif
-#ifdef V3D_LIGHTING_STUDIO
-# ifdef STUDIOLIGHT_ORIENTATION_CAMERA
- diffuse_light = get_camera_diffuse_light(world_data, nor);
-# endif
-# ifdef STUDIOLIGHT_ORIENTATION_WORLD
- vec3 normal_world = normalWorldMatrix * nor;
- diffuse_light = get_world_diffuse_light(world_data, normal_world);
-# endif
-#endif
-
- vec3 shaded_color = diffuse_light * diffuse_color.rgb + specular_color;
-
/* Based on :
* McGuire and Bavoil, Weighted Blended Order-Independent Transparency, Journal of
* Computer Graphics Techniques (JCGT), vol. 2, no. 2, 122–141, 2013
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 62c7e4515cd..722add22a89 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
@@ -1,81 +1,77 @@
uniform int object_id = 0;
-uniform vec4 materialDiffuseColor;
-uniform vec4 materialSpecularColor;
+uniform vec3 materialDiffuseColor;
+uniform float materialMetallic;
uniform float materialRoughness;
-#ifdef V3D_SHADING_TEXTURE_COLOR
uniform sampler2D image;
uniform float ImageTransparencyCutoff = 0.1;
-#endif
-
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
in vec3 normal_viewport;
-#endif /* NORMAL_VIEWPORT_PASS_ENABLED */
+#endif
#ifdef V3D_SHADING_TEXTURE_COLOR
in vec2 uv_interp;
-#endif /* V3D_SHADING_TEXTURE_COLOR */
+#endif
#ifdef HAIR_SHADER
flat in float hair_rand;
#endif
-layout(location=0) out uint objectId;
-layout(location=1) out vec4 diffuseColor;
-layout(location=2) out vec4 specularColor;
+#ifdef MATDATA_PASS_ENABLED
+layout(location=0) out vec4 materialData;
+#endif
+#ifdef OBJECT_ID_PASS_ENABLED
+layout(location=1) out uint objectId;
+#endif
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
-# ifdef WORKBENCH_ENCODE_NORMALS
-layout(location=3) out vec2 normalViewport;
-# else /* WORKBENCH_ENCODE_NORMALS */
-layout(location=3) out vec3 normalViewport;
-# endif /* WORKBENCH_ENCODE_NORMALS */
-#endif /* NORMAL_VIEWPORT_PASS_ENABLED */
+layout(location=2) out WB_Normal normalViewport;
+#endif
void main()
{
- objectId = uint(object_id);
-
-#ifdef NORMAL_VIEWPORT_PASS_ENABLED
- vec3 n = (gl_FrontFacing) ? normal_viewport : -normal_viewport;
- n = normalize(n);
-#endif
+#ifdef MATDATA_PASS_ENABLED
+ float metallic, roughness;
+ vec4 color;
-#ifdef V3D_SHADING_TEXTURE_COLOR
- diffuseColor = texture(image, uv_interp);
- if (diffuseColor.a < ImageTransparencyCutoff) {
+# ifdef V3D_SHADING_TEXTURE_COLOR
+ color = texture(image, uv_interp);
+ if (color.a < ImageTransparencyCutoff) {
discard;
}
-#else
- diffuseColor = vec4(materialDiffuseColor.rgb, 0.0);
-# ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL
- specularColor = vec4(materialDiffuseColor.rgb, 0.0);
-
+# else
+ color.rgb = materialDiffuseColor;
# endif
-#endif /* V3D_SHADING_TEXTURE_COLOR */
-#ifdef HAIR_SHADER
- float hair_color_variation = hair_rand * 0.1;
- diffuseColor.rgb = clamp(diffuseColor.rgb - hair_color_variation, 0.0, 1.0);
-#endif
+# ifdef V3D_LIGHTING_MATCAP
+ /* Encode front facing in metallic channel. */
+ metallic = float(gl_FrontFacing);
+ roughness = 0.0;
+# else
+ metallic = materialMetallic;
+ roughness = materialRoughness;
+# endif
-#ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
- specularColor = vec4(materialSpecularColor.rgb, materialRoughness);
# ifdef HAIR_SHADER
- specularColor.rgb = clamp(specularColor.rgb - hair_color_variation, 0.0, 1.0);
+ /* Add some variation to the hairs to avoid uniform look. */
+ float hair_variation = hair_rand * 0.1;
+ color = clamp(color - hair_variation, 0.0, 1.0);
+ metallic = clamp(materialMetallic - hair_variation, 0.0, 1.0);
+ roughness = clamp(materialRoughness - hair_variation, 0.0, 1.0);
# endif
+
+ materialData.rgb = color.rgb;
+ materialData.a = workbench_float_pair_encode(roughness, metallic);
+#endif /* MATDATA_PASS_ENABLED */
+
+#ifdef OBJECT_ID_PASS_ENABLED
+ objectId = uint(object_id);
#endif
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
-# ifdef WORKBENCH_ENCODE_NORMALS
- diffuseColor.a = float(gl_FrontFacing);
- normalViewport = normal_encode(n);
-# else /* WORKBENCH_ENCODE_NORMALS */
- normalViewport = n;
-# endif /* WORKBENCH_ENCODE_NORMALS */
-# ifdef HAIR_SHADER
- diffuseColor.a = 0.5;
-# endif
-#endif /* NORMAL_VIEWPORT_PASS_ENABLED */
+ vec3 n = (gl_FrontFacing) ? normal_viewport : -normal_viewport;
+ n = normalize(n);
+ normalViewport = workbench_normal_encode(n);
+#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 ab48aa5fa03..dbc29299fdc 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,129 +1,114 @@
-#define BLINN
-#if STUDIOLIGHT_SH_BANDS == 2
-vec3 spherical_harmonics(vec3 N, vec3 sh_coefs[STUDIOLIGHT_SH_MAX_COMPONENTS])
+/* [Drobot2014a] Low Level Optimizations for GCN */
+vec4 fast_rcp(vec4 v)
{
- /* http://www.geomerics.com/wp-content/uploads/2015/08/CEDEC_Geomerics_ReconstructingDiffuseLighting1.pdf */
- /* Highly optimized form, precompute as much as we can. */
- /**
- * R1 = 0.5 * vec3(L3.r, L2.r, L1.r);
- * sh_coefs[0..2] = R1 / length(R1);
- **/
- vec3 q;
- q.x = dot(sh_coefs[1], N);
- q.y = dot(sh_coefs[2], N);
- q.z = dot(sh_coefs[3], N);
- q = 0.5 * q + 0.5;
-
- /**
- * R0 = L0.r;
- * lr1_r0 = lenR1 / R0;
- * p = 1.0 + 2.0 * lr1_r0;
- * a = (1.0 - lr1_r0) / (1.0 + lr1_r0);
- * return R0 * (a + (1.0 - a) * (p + 1.0) * pow(q, p));
- *
- * sh_coefs[4] = p;
- * sh_coefs[5] = R0 * a;
- * sh_coefs[0] = R0 * (1.0 - a) * (p + 1.0);
- **/
- q = pow(q, sh_coefs[4]);
- return sh_coefs[0] * q + sh_coefs[5];
+ return intBitsToFloat(0x7eef370b - floatBitsToInt(v));
}
-#else
-
-vec3 spherical_harmonics(vec3 N, vec3 sh_coefs[STUDIOLIGHT_SH_MAX_COMPONENTS])
+vec3 brdf_approx(vec3 spec_color, float roughness, float NV)
{
- vec3 sh = 0.282095 * sh_coefs[0];
-
-# if STUDIOLIGHT_SH_BANDS > 1
- float nx = N.x;
- float ny = N.y;
- float nz = N.z;
- sh += -0.488603 * nz * sh_coefs[1];
- sh += 0.488603 * ny * sh_coefs[2];
- sh += -0.488603 * nx * sh_coefs[3];
-# endif
-# if STUDIOLIGHT_SH_BANDS > 2
- float nx2 = nx * nx;
- float ny2 = ny * ny;
- float nz2 = nz * nz;
- sh += 1.092548 * nx * nz * sh_coefs[4];
- sh += -1.092548 * nz * ny * sh_coefs[5];
- sh += 0.315392 * (3.0 * ny2 - 1.0) * sh_coefs[6];
- sh += -1.092548 * nx * ny * sh_coefs[7];
- sh += 0.546274 * (nx2 - nz2) * sh_coefs[8];
-# endif
-# if STUDIOLIGHT_SH_BANDS > 4
- float nx4 = nx2 * nx2;
- float ny4 = ny2 * ny2;
- float nz4 = nz2 * nz2;
- sh += (2.5033429417967046 * nx * nz * (nx2 - nz2)) * sh_coefs[9];
- sh += (-1.7701307697799304 * nz * ny * (3.0 * nx2 - nz2)) * sh_coefs[10];
- sh += (0.9461746957575601 * nz * nx * (-1.0 +7.0*ny2)) * sh_coefs[11];
- sh += (-0.6690465435572892 * nz * ny * (-3.0 + 7.0 * ny2)) * sh_coefs[12];
- sh += ((105.0*ny4-90.0*ny2+9.0)/28.359261614) * sh_coefs[13];
- sh += (-0.6690465435572892 * nx * ny * (-3.0 + 7.0 * ny2)) * sh_coefs[14];
- sh += (0.9461746957575601 * (nx2 - nz2) * (-1.0 + 7.0 * ny2)) * sh_coefs[15];
- sh += (-1.7701307697799304 * nx * ny * (nx2 - 3.0 * nz2)) * sh_coefs[16];
- sh += (0.6258357354491761 * (nx4 - 6.0 * nz2 * nx2 + nz4)) * sh_coefs[17];
-# endif
- return sh;
+ /* Very rough own approx. We don't need it to be correct, just fast.
+ * Just simulate fresnel effect with roughness attenuation. */
+ float fresnel = exp2(-8.35 * NV) * (1.0 - roughness);
+ return mix(spec_color, vec3(1.0), fresnel);
}
-#endif
-vec3 get_world_diffuse_light(WorldData world_data, vec3 N)
+void prep_specular(
+ vec3 L, vec3 I, vec3 N, vec3 R,
+ out float NL, out float wrapped_NL, out float spec_angle)
{
- return spherical_harmonics(N, world_data.spherical_harmonics_coefs);
+ wrapped_NL = dot(L, R);
+ vec3 half_dir = normalize(L + I);
+ spec_angle = clamp(dot(half_dir, N), 0.0, 1.0);
+ NL = clamp(dot(L, N), 0.0, 1.0);
}
-vec3 get_camera_diffuse_light(WorldData world_data, vec3 N)
+/* Normalized Blinn shading */
+vec4 blinn_specular(vec4 shininess, vec4 spec_angle, vec4 NL)
{
- return spherical_harmonics(vec3(N.x, -N.z, N.y), world_data.spherical_harmonics_coefs);
+ /* Pi is already divided in the lamp power.
+ * normalization_factor = (shininess + 8.0) / (8.0 * M_PI) */
+ vec4 normalization_factor = shininess * 0.125 + 1.0;
+ vec4 spec_light = pow(spec_angle, shininess) * NL * normalization_factor;
+
+ return spec_light;
}
-/* N And I are in View Space. */
-vec3 get_world_specular_light(vec4 specular_data, LightData light_data, vec3 N, vec3 I)
+/* NL need to be unclamped. w in [0..1] range. */
+vec4 wrapped_lighting(vec4 NL, vec4 w)
{
-#ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
- vec3 specular_light = specular_data.rgb * light_data.specular_color.rgb * light_data.specular_color.a;
-
- float shininess = exp2(10.0 * (1.0 - specular_data.a) + 1);
-
-# ifdef BLINN
- float normalization_factor = (shininess + 8.0) / (8.0 * M_PI);
- vec3 L = -light_data.light_direction_vs.xyz;
- vec3 halfDir = normalize(L + I);
- float spec_angle = max(dot(halfDir, N), 0.0);
- float NL = max(dot(L, N), 0.0);
- float specular_influence = pow(spec_angle, shininess) * NL * normalization_factor;
-
-# else
- vec3 reflection_vector = reflect(I, N);
- float spec_angle = max(dot(light_data.light_direction_vs.xyz, reflection_vector), 0.0);
- float specular_influence = pow(spec_angle, shininess);
-# endif
-
- vec3 specular_color = specular_light * specular_influence;
-
-#else /* V3D_SHADING_SPECULAR_HIGHLIGHT */
- vec3 specular_color = vec3(0.0);
-#endif /* V3D_SHADING_SPECULAR_HIGHLIGHT */
- return specular_color;
+ vec4 w_1 = w + 1.0;
+ vec4 denom = fast_rcp(w_1 * w_1);
+ return clamp((NL + w) * denom, 0.0, 1.0);
}
-vec3 get_world_specular_lights(WorldData world_data, vec4 specular_data, vec3 N, vec3 I)
+vec3 get_world_lighting(
+ WorldData world_data,
+ vec3 diffuse_color, vec3 specular_color, float roughness,
+ vec3 N, vec3 I)
{
- vec3 specular_light = vec3(0.0);
- /* Manual loop unrolling provide much better perf. */
- if (world_data.num_lights > 0) {
- specular_light += get_world_specular_light(specular_data, world_data.lights[0], N, I);
- }
- if (world_data.num_lights > 1) {
- specular_light += get_world_specular_light(specular_data, world_data.lights[1], N, I);
- }
- if (world_data.num_lights > 2) {
- specular_light += get_world_specular_light(specular_data, world_data.lights[2], N, I);
- }
- return specular_light;
+ vec3 specular_light = world_data.ambient_color.rgb;
+ vec3 diffuse_light = world_data.ambient_color.rgb;
+ vec4 wrap = vec4(
+ world_data.lights[0].diffuse_color_wrap.a,
+ world_data.lights[1].diffuse_color_wrap.a,
+ world_data.lights[2].diffuse_color_wrap.a,
+ world_data.lights[3].diffuse_color_wrap.a
+ );
+
+#ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
+ /* Prepare Specular computation. Eval 4 lights at once. */
+ vec3 R = -reflect(I, N);
+ vec4 spec_angle, spec_NL, wrap_NL;
+ prep_specular(world_data.lights[0].direction.xyz, I, N, R, spec_NL.x, wrap_NL.x, spec_angle.x);
+ prep_specular(world_data.lights[1].direction.xyz, I, N, R, spec_NL.y, wrap_NL.y, spec_angle.y);
+ prep_specular(world_data.lights[2].direction.xyz, I, N, R, spec_NL.z, wrap_NL.z, spec_angle.z);
+ prep_specular(world_data.lights[3].direction.xyz, I, N, R, spec_NL.w, wrap_NL.w, spec_angle.w);
+
+ vec4 gloss = vec4(1.0 - roughness);
+ /* Reduce gloss for smooth light. (simulate bigger light) */
+ gloss *= 1.0 - wrap;
+ vec4 shininess = exp2(10.0 * gloss + 1.0);
+
+ vec4 spec_light = blinn_specular(shininess, spec_angle, spec_NL);
+
+ /* Simulate Env. light. */
+ vec4 w = mix(wrap, vec4(1.0), roughness);
+ vec4 spec_env = wrapped_lighting(wrap_NL, w);
+
+ spec_light = mix(spec_light, spec_env, wrap * wrap);
+
+ /* Multiply result by lights specular colors. */
+ specular_light += spec_light.x * world_data.lights[0].specular_color.rgb;
+ specular_light += spec_light.y * world_data.lights[1].specular_color.rgb;
+ specular_light += spec_light.z * world_data.lights[2].specular_color.rgb;
+ specular_light += spec_light.w * world_data.lights[3].specular_color.rgb;
+
+ float NV = clamp(dot(N, I), 0.0, 1.0);
+ specular_color = brdf_approx(specular_color, roughness, NV);
+#endif
+ specular_light *= specular_color;
+
+ /* Prepare diffuse computation. Eval 4 lights at once. */
+ vec4 diff_NL;
+ diff_NL.x = dot(world_data.lights[0].direction.xyz, N);
+ diff_NL.y = dot(world_data.lights[1].direction.xyz, N);
+ diff_NL.z = dot(world_data.lights[2].direction.xyz, N);
+ diff_NL.w = dot(world_data.lights[3].direction.xyz, N);
+
+ vec4 diff_light = wrapped_lighting(diff_NL, wrap);
+
+ /* Multiply result by lights diffuse colors. */
+ diffuse_light += diff_light.x * world_data.lights[0].diffuse_color_wrap.rgb;
+ diffuse_light += diff_light.y * world_data.lights[1].diffuse_color_wrap.rgb;
+ diffuse_light += diff_light.z * world_data.lights[2].diffuse_color_wrap.rgb;
+ diffuse_light += diff_light.w * world_data.lights[3].diffuse_color_wrap.rgb;
+
+ /* Energy conservation with colored specular look strange.
+ * Limit this strangeness by using mono-chromatic specular intensity. */
+ float spec_energy = dot(specular_color, vec3(0.33333));
+
+ diffuse_light *= diffuse_color * (1.0 - spec_energy);
+
+ return diffuse_light + specular_light;
}
diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c
index aa99883bb6b..04e760f1909 100644
--- a/source/blender/draw/engines/workbench/workbench_data.c
+++ b/source/blender/draw/engines/workbench/workbench_data.c
@@ -24,7 +24,7 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
wpd->use_color_view_settings = true;
}
else if (v3d->shading.type == OB_RENDER &&
- BKE_scene_uses_blender_opengl(scene))
+ BKE_scene_uses_blender_workbench(scene))
{
wpd->shading = scene->display.shading;
wpd->use_color_view_settings = true;
@@ -36,17 +36,17 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
if (wpd->shading.light == V3D_LIGHTING_MATCAP) {
wpd->studio_light = BKE_studiolight_find(
- wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
+ wpd->shading.matcap, STUDIOLIGHT_TYPE_MATCAP);
}
else {
wpd->studio_light = BKE_studiolight_find(
- wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD);
+ wpd->shading.studio_light, STUDIOLIGHT_TYPE_STUDIO);
}
/* If matcaps are missing, use this as fallback. */
if (UNLIKELY(wpd->studio_light == NULL)) {
wpd->studio_light = BKE_studiolight_find(
- wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD);
+ wpd->shading.studio_light, STUDIOLIGHT_TYPE_STUDIO);
}
wpd->shadow_multiplier = 1.0 - wpd->shading.shadow_intensity;
@@ -79,11 +79,14 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
zero_v3(wd->background_color_high);
}
- studiolight_update_world(wpd->studio_light, wd);
+ studiolight_update_world(wpd, wpd->studio_light, wd);
copy_v3_v3(wd->object_outline_color, wpd->shading.object_outline_color);
wd->object_outline_color[3] = 1.0f;
+ wd->curvature_ridge = 0.5f / max_ff(SQUARE(wpd->shading.curvature_ridge_factor), 1e-4f);
+ wd->curvature_valley = 0.7f / max_ff(SQUARE(wpd->shading.curvature_valley_factor), 1e-4f);
+
wpd->world_ubo = DRW_uniformbuffer_create(sizeof(WORKBENCH_UBO_World), &wpd->world_data);
/* Cavity settings */
@@ -108,7 +111,12 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
wpd->ssao_params[3] = 0;
/* distance, factor, factor, attenuation */
- copy_v4_fl4(wpd->ssao_settings, scene->display.matcap_ssao_distance, wpd->shading.cavity_valley_factor, wpd->shading.cavity_ridge_factor, scene->display.matcap_ssao_attenuation);
+ copy_v4_fl4(
+ wpd->ssao_settings,
+ scene->display.matcap_ssao_distance,
+ wpd->shading.cavity_valley_factor,
+ wpd->shading.cavity_ridge_factor,
+ scene->display.matcap_ssao_attenuation);
/* invert the view matrix */
DRW_viewport_matrix_get(wpd->winmat, DRW_MAT_WIN);
@@ -153,32 +161,12 @@ void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, floa
DRW_viewport_matrix_get(view_matrix, DRW_MAT_VIEW);
copy_v3_v3(r_light_direction, scene->display.light_direction);
- negate_v3(r_light_direction);
-
- {
- WORKBENCH_UBO_Light *light = &wd->lights[0];
- mul_v3_mat3_m4v3(light->light_direction_vs, view_matrix, r_light_direction);
- light->light_direction_vs[3] = 0.0f;
- copy_v3_fl(light->specular_color, 1.0f);
- light->energy = 1.0f;
- copy_v4_v4(wd->shadow_direction_vs, light->light_direction_vs);
- wd->num_lights = 1;
- }
+ SWAP(float, r_light_direction[2], r_light_direction[1]);
+ r_light_direction[2] = -r_light_direction[2];
+ r_light_direction[0] = -r_light_direction[0];
- if (!STUDIOLIGHT_ORIENTATION_WORLD_ENABLED(wpd)) {
- int light_index = 0;
- for (int index = 0 ; index < 3; index++) {
- SolidLight *sl = &U.light[index];
- if (sl->flag) {
- WORKBENCH_UBO_Light *light = &wd->lights[light_index++];
- copy_v4_v4(light->light_direction_vs, sl->vec);
- negate_v3(light->light_direction_vs);
- copy_v4_v4(light->specular_color, sl->spec);
- light->energy = 1.0f;
- }
- }
- wd->num_lights = light_index;
- }
+ /* Shadow direction. */
+ mul_v3_mat3_m4v3(wd->shadow_direction_vs, view_matrix, r_light_direction);
DRW_uniformbuffer_update(wpd->world_ubo, wd);
}
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c
index 66dcfdd66d0..0d82cab283e 100644
--- a/source/blender/draw/engines/workbench/workbench_deferred.c
+++ b/source/blender/draw/engines/workbench/workbench_deferred.c
@@ -31,6 +31,7 @@
#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
#include "BLI_rand.h"
+#include "BLI_string_utils.h"
#include "BKE_node.h"
#include "BKE_modifier.h"
@@ -45,6 +46,7 @@
#include "GPU_shader.h"
#include "GPU_texture.h"
+#include "GPU_extensions.h"
#include "../eevee/eevee_lut.h" /* TODO find somewhere to share blue noise Table */
@@ -57,9 +59,10 @@
#endif
static struct {
- struct GPUShader *prepass_sh_cache[MAX_SHADERS];
- struct GPUShader *composite_sh_cache[MAX_SHADERS];
- struct GPUShader *cavity_sh;
+ struct GPUShader *prepass_sh_cache[MAX_PREPASS_SHADERS];
+ struct GPUShader *composite_sh_cache[MAX_COMPOSITE_SHADERS];
+ struct GPUShader *cavity_sh[MAX_CAVITY_SHADERS];
+ struct GPUShader *background_sh[2];
struct GPUShader *ghost_resolve_sh;
struct GPUShader *shadow_fail_sh;
struct GPUShader *shadow_fail_manifold_sh;
@@ -72,13 +75,12 @@ static struct {
struct GPUTexture *object_id_tx; /* ref only, not alloced */
struct GPUTexture *color_buffer_tx; /* ref only, not alloced */
struct GPUTexture *cavity_buffer_tx; /* ref only, not alloced */
- struct GPUTexture *specular_buffer_tx; /* ref only, not alloced */
+ struct GPUTexture *metallic_buffer_tx; /* ref only, not alloced */
struct GPUTexture *normal_buffer_tx; /* ref only, not alloced */
struct GPUTexture *composite_buffer_tx; /* ref only, not alloced */
SceneDisplay display; /* world light direction for shadows */
int next_object_id;
- float normal_world_matrix[3][3];
struct GPUUniformBuffer *sampling_ubo;
struct GPUTexture *jitter_tx;
@@ -92,6 +94,7 @@ extern char datatoc_workbench_prepass_vert_glsl[];
extern char datatoc_workbench_prepass_frag_glsl[];
extern char datatoc_workbench_cavity_frag_glsl[];
extern char datatoc_workbench_deferred_composite_frag_glsl[];
+extern char datatoc_workbench_deferred_background_frag_glsl[];
extern char datatoc_workbench_ghost_resolve_frag_glsl[];
extern char datatoc_workbench_shadow_vert_glsl[];
@@ -104,6 +107,7 @@ extern char datatoc_workbench_cavity_lib_glsl[];
extern char datatoc_workbench_common_lib_glsl[];
extern char datatoc_workbench_data_lib_glsl[];
extern char datatoc_workbench_object_outline_lib_glsl[];
+extern char datatoc_workbench_curvature_lib_glsl[];
extern char datatoc_workbench_world_light_lib_glsl[];
extern char datatoc_gpu_shader_depth_only_frag_glsl[];
@@ -118,12 +122,15 @@ static char *workbench_build_composite_frag(WORKBENCH_PrivateData *wpd)
BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_background_lib_glsl);
- if ((wpd->shading.light & V3D_LIGHTING_MATCAP) || (wpd->shading.light & V3D_LIGHTING_STUDIO) || (wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT)) {
+ if (!FLAT_ENABLED(wpd)) {
BLI_dynstr_append(ds, datatoc_workbench_world_light_lib_glsl);
}
- if (wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE) {
+ if (OBJECT_OUTLINE_ENABLED(wpd)) {
BLI_dynstr_append(ds, datatoc_workbench_object_outline_lib_glsl);
}
+ if (CURVATURE_ENABLED(wpd)) {
+ BLI_dynstr_append(ds, datatoc_workbench_curvature_lib_glsl);
+ }
BLI_dynstr_append(ds, datatoc_workbench_deferred_composite_frag_glsl);
@@ -164,13 +171,26 @@ static char *workbench_build_prepass_vert(bool is_hair)
return str;
}
-static char *workbench_build_cavity_frag(void)
+static char *workbench_build_cavity_frag(bool cavity, bool curvature, bool high_dpi)
{
char *str = NULL;
DynStr *ds = BLI_dynstr_new();
+ if (cavity) {
+ BLI_dynstr_append(ds, "#define USE_CAVITY\n");
+ }
+ if (curvature) {
+ BLI_dynstr_append(ds, "#define USE_CURVATURE\n");
+ }
+ if (high_dpi) {
+ BLI_dynstr_append(ds, "#define CURVATURE_OFFSET 2\n");
+ }
+ if (NORMAL_ENCODING_ENABLED()) {
+ BLI_dynstr_append(ds, "#define WORKBENCH_ENCODE_NORMALS\n");
+ }
BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl);
+ BLI_dynstr_append(ds, datatoc_workbench_curvature_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_cavity_frag_glsl);
BLI_dynstr_append(ds, datatoc_workbench_cavity_lib_glsl);
@@ -179,45 +199,79 @@ static char *workbench_build_cavity_frag(void)
return str;
}
-static void ensure_deferred_shaders(WORKBENCH_PrivateData *wpd, int index, bool use_textures, bool is_hair)
+static GPUShader *workbench_cavity_shader_get(bool cavity, bool curvature)
+{
+ const bool high_dpi = (U.pixelsize > 1.5f);
+ int index = 0;
+ SET_FLAG_FROM_TEST(index, cavity, 1 << 0);
+ SET_FLAG_FROM_TEST(index, curvature, 1 << 1);
+ SET_FLAG_FROM_TEST(index, high_dpi, 1 << 2);
+
+ GPUShader **sh = &e_data.cavity_sh[index];
+ if (*sh == NULL) {
+ char *cavity_frag = workbench_build_cavity_frag(cavity, curvature, high_dpi);
+ *sh = DRW_shader_create_fullscreen(cavity_frag, NULL);
+ MEM_freeN(cavity_frag);
+ }
+ return *sh;
+}
+
+static GPUShader *ensure_deferred_prepass_shader(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair)
{
+ int index = workbench_material_get_prepass_shader_index(wpd, use_textures, is_hair);
if (e_data.prepass_sh_cache[index] == NULL) {
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(is_hair);
char *prepass_frag = workbench_build_prepass_frag();
e_data.prepass_sh_cache[index] = DRW_shader_create(
prepass_vert, NULL,
prepass_frag, defines);
- if (!use_textures && !is_hair) {
- e_data.composite_sh_cache[index] = DRW_shader_create_fullscreen(composite_frag, defines);
- }
MEM_freeN(prepass_vert);
MEM_freeN(prepass_frag);
+ MEM_freeN(defines);
+ }
+ return e_data.prepass_sh_cache[index];
+}
+
+static GPUShader *ensure_deferred_composite_shader(WORKBENCH_PrivateData *wpd)
+{
+ int index = workbench_material_get_composite_shader_index(wpd);
+ if (e_data.composite_sh_cache[index] == NULL) {
+ char *defines = workbench_material_build_defines(wpd, false, false);
+ char *composite_frag = workbench_build_composite_frag(wpd);
+ e_data.composite_sh_cache[index] = DRW_shader_create_fullscreen(composite_frag, defines);
MEM_freeN(composite_frag);
MEM_freeN(defines);
}
+ return e_data.composite_sh_cache[index];
}
-static void select_deferred_shaders(WORKBENCH_PrivateData *wpd)
+static GPUShader *ensure_background_shader(WORKBENCH_PrivateData *wpd)
{
- 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, 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];
- wpd->prepass_texture_sh = e_data.prepass_sh_cache[index_texture];
- wpd->prepass_texture_hair_sh = e_data.prepass_sh_cache[index_texture_hair];
- wpd->composite_sh = e_data.composite_sh_cache[index_solid];
+ const int index = OBJECT_OUTLINE_ENABLED(wpd) ? 1 : 0;
+ if (e_data.background_sh[index] == NULL) {
+ const char *defines = (index) ? "#define V3D_SHADING_OBJECT_OUTLINE\n" : NULL;
+ char *frag = BLI_string_joinN(
+ datatoc_workbench_data_lib_glsl,
+ datatoc_workbench_common_lib_glsl,
+ datatoc_workbench_background_lib_glsl,
+ datatoc_workbench_object_outline_lib_glsl,
+ datatoc_workbench_deferred_background_frag_glsl);
+ e_data.background_sh[index] = DRW_shader_create_fullscreen(frag, defines);
+ MEM_freeN(frag);
+ }
+ return e_data.background_sh[index];
}
+static void select_deferred_shaders(WORKBENCH_PrivateData *wpd)
+{
+ wpd->prepass_solid_sh = ensure_deferred_prepass_shader(wpd, false, false);
+ wpd->prepass_solid_hair_sh = ensure_deferred_prepass_shader(wpd, false, true);
+ wpd->prepass_texture_sh = ensure_deferred_prepass_shader(wpd, true, false);
+ wpd->prepass_texture_hair_sh = ensure_deferred_prepass_shader(wpd, true, true);
+ wpd->composite_sh = ensure_deferred_composite_shader(wpd);
+ wpd->background_sh = ensure_background_shader(wpd);
+}
/* Using Hammersley distribution */
static float *create_disk_samples(int num_samples, int num_iterations)
@@ -292,14 +346,15 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
}
if (!e_data.next_object_id) {
- memset(e_data.prepass_sh_cache, 0x00, sizeof(struct GPUShader *) * MAX_SHADERS);
- memset(e_data.composite_sh_cache, 0x00, sizeof(struct GPUShader *) * MAX_SHADERS);
+ memset(e_data.prepass_sh_cache, 0, sizeof(e_data.prepass_sh_cache));
+ memset(e_data.composite_sh_cache, 0, sizeof(e_data.composite_sh_cache));
e_data.next_object_id = 1;
#ifdef DEBUG_SHADOW_VOLUME
const char *shadow_frag = datatoc_workbench_shadow_debug_frag_glsl;
#else
const char *shadow_frag = datatoc_gpu_shader_depth_only_frag_glsl;
#endif
+ /* TODO only compile on demand */
e_data.shadow_pass_sh = DRW_shader_create(
datatoc_workbench_shadow_vert_glsl,
datatoc_workbench_shadow_geom_glsl,
@@ -334,10 +389,6 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
shadow_frag,
"#define SHADOW_FAIL\n");
- char *cavity_frag = workbench_build_cavity_frag();
- e_data.cavity_sh = DRW_shader_create_fullscreen(cavity_frag, NULL);
- MEM_freeN(cavity_frag);
-
e_data.ghost_resolve_sh = DRW_shader_create_fullscreen(datatoc_workbench_ghost_resolve_frag_glsl, NULL);
}
workbench_volume_engine_init();
@@ -350,27 +401,35 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
{
const float *viewport_size = DRW_viewport_size_get();
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
- e_data.object_id_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R32UI, &draw_engine_workbench_solid);
- e_data.color_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8, &draw_engine_workbench_solid);
- e_data.cavity_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RG16, &draw_engine_workbench_solid);
- e_data.specular_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8, &draw_engine_workbench_solid);
- e_data.composite_buffer_tx = DRW_texture_pool_query_2D(
- size[0], size[1], GPU_RGBA16F, &draw_engine_workbench_solid);
-
- if (NORMAL_ENCODING_ENABLED()) {
- e_data.normal_buffer_tx = DRW_texture_pool_query_2D(
- size[0], size[1], GPU_RG16, &draw_engine_workbench_solid);
+ const GPUTextureFormat nor_tex_format = NORMAL_ENCODING_ENABLED() ? GPU_RG16 : GPU_RGBA32F;
+ const GPUTextureFormat comp_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_R11F_G11F_B10F;
+ const GPUTextureFormat id_tex_format = OBJECT_ID_PASS_ENABLED(wpd) ? GPU_R32UI : GPU_R8;
+
+ e_data.object_id_tx = NULL;
+ e_data.color_buffer_tx = NULL;
+ e_data.composite_buffer_tx = NULL;
+ e_data.normal_buffer_tx = NULL;
+ e_data.cavity_buffer_tx = NULL;
+
+ e_data.composite_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], comp_tex_format, &draw_engine_workbench_solid);
+
+ if (MATDATA_PASS_ENABLED(wpd) || GPU_unused_fb_slot_workaround()) {
+ e_data.color_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8, &draw_engine_workbench_solid);
}
- else {
- e_data.normal_buffer_tx = DRW_texture_pool_query_2D(
- size[0], size[1], GPU_RGBA32F, &draw_engine_workbench_solid);
+ if (OBJECT_ID_PASS_ENABLED(wpd) || GPU_unused_fb_slot_workaround()) {
+ e_data.object_id_tx = DRW_texture_pool_query_2D(size[0], size[1], id_tex_format, &draw_engine_workbench_solid);
+ }
+ if (NORMAL_VIEWPORT_PASS_ENABLED(wpd)) {
+ e_data.normal_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], nor_tex_format, &draw_engine_workbench_solid);
+ }
+ if (CAVITY_ENABLED(wpd)) {
+ e_data.cavity_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R16, &draw_engine_workbench_solid);
}
GPU_framebuffer_ensure_config(&fbl->prepass_fb, {
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
- GPU_ATTACHMENT_TEXTURE(e_data.object_id_tx),
GPU_ATTACHMENT_TEXTURE(e_data.color_buffer_tx),
- GPU_ATTACHMENT_TEXTURE(e_data.specular_buffer_tx),
+ GPU_ATTACHMENT_TEXTURE(e_data.object_id_tx),
GPU_ATTACHMENT_TEXTURE(e_data.normal_buffer_tx),
});
GPU_framebuffer_ensure_config(&fbl->cavity_fb, {
@@ -385,10 +444,22 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
GPU_ATTACHMENT_NONE,
GPU_ATTACHMENT_TEXTURE(e_data.composite_buffer_tx),
});
+
+ if (!MATDATA_PASS_ENABLED(wpd) && !GPU_unused_fb_slot_workaround()) {
+ e_data.color_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8, &draw_engine_workbench_solid);
+ }
+
GPU_framebuffer_ensure_config(&fbl->effect_fb, {
GPU_ATTACHMENT_NONE,
GPU_ATTACHMENT_TEXTURE(e_data.color_buffer_tx),
});
+
+ if (OBJECT_ID_PASS_ENABLED(wpd)) {
+ GPU_framebuffer_ensure_config(&fbl->id_clear_fb, {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_TEXTURE(e_data.object_id_tx),
+ });
+ }
}
{
@@ -435,21 +506,29 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
workbench_aa_create_pass(vedata, &e_data.color_buffer_tx);
}
- {
+ if (CAVITY_ENABLED(wpd)) {
int state = DRW_STATE_WRITE_COLOR;
+ GPUShader *shader = workbench_cavity_shader_get(SSAO_ENABLED(wpd), CURVATURE_ENABLED(wpd));
psl->cavity_pass = DRW_pass_create("Cavity", state);
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.cavity_sh, psl->cavity_pass);
- DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
- DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &e_data.color_buffer_tx);
+ DRWShadingGroup *grp = DRW_shgroup_create(shader, psl->cavity_pass);
DRW_shgroup_uniform_texture_ref(grp, "normalBuffer", &e_data.normal_buffer_tx);
-
- DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
- DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)wpd->viewvecs, 3);
- DRW_shgroup_uniform_vec4(grp, "ssao_params", wpd->ssao_params, 1);
- DRW_shgroup_uniform_vec4(grp, "ssao_settings", wpd->ssao_settings, 1);
- DRW_shgroup_uniform_mat4(grp, "WinMatrix", wpd->winmat);
- DRW_shgroup_uniform_texture(grp, "ssao_jitter", e_data.jitter_tx);
DRW_shgroup_uniform_block(grp, "samples_block", e_data.sampling_ubo);
+
+ if (SSAO_ENABLED(wpd)) {
+ DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
+ DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
+ DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)wpd->viewvecs, 3);
+ DRW_shgroup_uniform_vec4(grp, "ssao_params", wpd->ssao_params, 1);
+ DRW_shgroup_uniform_vec4(grp, "ssao_settings", wpd->ssao_settings, 1);
+ DRW_shgroup_uniform_mat4(grp, "WinMatrix", wpd->winmat);
+ DRW_shgroup_uniform_texture(grp, "ssao_jitter", e_data.jitter_tx);
+ }
+
+ if (CURVATURE_ENABLED(wpd)) {
+ DRW_shgroup_uniform_texture_ref(grp, "objectId", &e_data.object_id_tx);
+ DRW_shgroup_uniform_vec2(grp, "curvature_settings", &wpd->world_data.curvature_ridge, 1);
+ }
+
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
}
}
@@ -460,25 +539,31 @@ static void workbench_setup_ghost_framebuffer(WORKBENCH_FramebufferList *fbl)
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
e_data.ghost_depth_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_DEPTH_COMPONENT24, &draw_engine_workbench_solid);
+
GPU_framebuffer_ensure_config(&fbl->ghost_prepass_fb, {
GPU_ATTACHMENT_TEXTURE(e_data.ghost_depth_tx),
- GPU_ATTACHMENT_TEXTURE(e_data.object_id_tx),
GPU_ATTACHMENT_TEXTURE(e_data.color_buffer_tx),
- GPU_ATTACHMENT_TEXTURE(e_data.specular_buffer_tx),
+ GPU_ATTACHMENT_TEXTURE(e_data.object_id_tx),
GPU_ATTACHMENT_TEXTURE(e_data.normal_buffer_tx),
});
}
void workbench_deferred_engine_free(void)
{
- for (int index = 0; index < MAX_SHADERS; index++) {
+ for (int index = 0; index < MAX_PREPASS_SHADERS; index++) {
DRW_SHADER_FREE_SAFE(e_data.prepass_sh_cache[index]);
+ }
+ for (int index = 0; index < MAX_COMPOSITE_SHADERS; index++) {
DRW_SHADER_FREE_SAFE(e_data.composite_sh_cache[index]);
}
- DRW_SHADER_FREE_SAFE(e_data.cavity_sh);
+ for (int index = 0; index < MAX_CAVITY_SHADERS; ++index) {
+ DRW_SHADER_FREE_SAFE(e_data.cavity_sh[index]);
+ }
DRW_SHADER_FREE_SAFE(e_data.ghost_resolve_sh);
DRW_UBO_FREE_SAFE(e_data.sampling_ubo);
DRW_TEXTURE_FREE_SAFE(e_data.jitter_tx);
+ DRW_SHADER_FREE_SAFE(e_data.background_sh[0]);
+ DRW_SHADER_FREE_SAFE(e_data.background_sh[1]);
DRW_SHADER_FREE_SAFE(e_data.shadow_pass_sh);
DRW_SHADER_FREE_SAFE(e_data.shadow_pass_manifold_sh);
@@ -494,27 +579,32 @@ void workbench_deferred_engine_free(void)
static void workbench_composite_uniforms(WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp)
{
- DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &e_data.color_buffer_tx);
- DRW_shgroup_uniform_texture_ref(grp, "objectId", &e_data.object_id_tx);
+ DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo);
+ if (MATDATA_PASS_ENABLED(wpd)) {
+ DRW_shgroup_uniform_texture_ref(grp, "materialBuffer", &e_data.color_buffer_tx);
+ }
+ else {
+ DRW_shgroup_uniform_vec3(grp, "materialSingleColor", wpd->shading.single_color, 1);
+ }
+ if (OBJECT_OUTLINE_ENABLED(wpd)) {
+ DRW_shgroup_uniform_texture_ref(grp, "objectId", &e_data.object_id_tx);
+ }
if (NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd)) {
DRW_shgroup_uniform_texture_ref(grp, "normalBuffer", &e_data.normal_buffer_tx);
}
if (CAVITY_ENABLED(wpd)) {
DRW_shgroup_uniform_texture_ref(grp, "cavityBuffer", &e_data.cavity_buffer_tx);
}
- if (SPECULAR_HIGHLIGHT_ENABLED(wpd) || MATCAP_ENABLED(wpd)) {
- DRW_shgroup_uniform_texture_ref(grp, "specularBuffer", &e_data.specular_buffer_tx);
+ if (SPECULAR_HIGHLIGHT_ENABLED(wpd) || STUDIOLIGHT_TYPE_MATCAP_ENABLED(wpd)) {
DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)wpd->viewvecs, 3);
}
- DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo);
- DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
-
- if (STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)) {
+ if (SPECULAR_HIGHLIGHT_ENABLED(wpd) || STUDIOLIGHT_TYPE_MATCAP_ENABLED(wpd)) {
+ DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
+ }
+ if (STUDIOLIGHT_TYPE_MATCAP_ENABLED(wpd)) {
BKE_studiolight_ensure_flag(wpd->studio_light, STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE);
- DRW_shgroup_uniform_texture(grp, "matcapImage", wpd->studio_light->equirect_radiance_gputexture );
+ DRW_shgroup_uniform_texture(grp, "matcapImage", wpd->studio_light->equirect_radiance_gputexture);
}
-
- workbench_material_set_normal_world_matrix(grp, wpd, e_data.normal_world_matrix);
}
void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
@@ -531,22 +621,39 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
select_deferred_shaders(wpd);
+ /* Background Pass */
+ {
+ psl->background_pass = DRW_pass_create(
+ "Background", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
+ grp = DRW_shgroup_create(wpd->background_sh, psl->background_pass);
+ DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo);
+ DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
+ if (OBJECT_OUTLINE_ENABLED(wpd)) {
+ DRW_shgroup_uniform_texture_ref(grp, "objectId", &e_data.object_id_tx);
+ }
+ DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
+ }
+
/* 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;
+ float shadow_focus = scene->display.shadow_focus;
+ /* Clamp to avoid overshadowing and shading errors. */
+ CLAMP(shadow_focus, 0.0001f, 0.99999f);
+ shadow_focus = 1.0f - shadow_focus * (1.0f - scene->display.shadow_shift);
if (SHADOW_ENABLED(wpd)) {
psl->composite_pass = DRW_pass_create(
- "Composite", DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_EQUAL);
+ "Composite", DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_EQUAL | DRW_STATE_DEPTH_GREATER);
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_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_uniform_float_copy(grp, "shadowShift", scene->display.shadow_shift);
+ DRW_shgroup_uniform_float_copy(grp, "shadowFocus", shadow_focus);
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
/* Stencil Shadow passes. */
@@ -578,20 +685,21 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
grp = DRW_shgroup_create(e_data.shadow_caps_manifold_sh, psl->shadow_depth_fail_caps_mani_pass);
DRW_shgroup_stencil_mask(grp, 0xFF);
- psl->composite_shadow_pass = DRW_pass_create("Composite Shadow", DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_NEQUAL);
+ psl->composite_shadow_pass = DRW_pass_create(
+ "Composite Shadow", DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_NEQUAL | DRW_STATE_DEPTH_GREATER);
grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_shadow_pass);
DRW_shgroup_stencil_mask(grp, 0x00);
workbench_composite_uniforms(wpd, grp);
DRW_shgroup_uniform_float(grp, "lightMultiplier", &wpd->shadow_multiplier, 1);
DRW_shgroup_uniform_float(grp, "shadowMultiplier", &wpd->shadow_multiplier, 1);
- DRW_shgroup_uniform_float(grp, "shadowShift", &scene->display.shadow_shift, 1);
+ DRW_shgroup_uniform_float_copy(grp, "shadowShift", scene->display.shadow_shift);
+ DRW_shgroup_uniform_float_copy(grp, "shadowFocus", shadow_focus);
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
#endif
-
}
else {
psl->composite_pass = DRW_pass_create(
- "Composite", DRW_STATE_WRITE_COLOR);
+ "Composite", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_GREATER);
grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_pass);
workbench_composite_uniforms(wpd, grp);
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
@@ -627,7 +735,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
workbench_material_copy(material, &material_template);
DRW_shgroup_stencil_mask(material->shgrp, (ob->dtx & OB_DRAWXRAY) ? 0x00 : 0xFF);
DRW_shgroup_uniform_int(material->shgrp, "object_id", &material->object_id, 1);
- workbench_material_shgroup_uniform(wpd, material->shgrp, material, ob);
+ workbench_material_shgroup_uniform(wpd, material->shgrp, material, ob, true, true);
BLI_ghash_insert(wpd->material_hash, POINTER_FROM_UINT(hash), material);
}
@@ -639,10 +747,7 @@ static void workbench_cache_populate_particles(WORKBENCH_Data *vedata, Object *o
WORKBENCH_StorageList *stl = vedata->stl;
WORKBENCH_PassList *psl = vedata->psl;
WORKBENCH_PrivateData *wpd = stl->g_data;
- const DRWContextState *draw_ctx = DRW_context_state_get();
- if (ob == draw_ctx->object_edit) {
- return;
- }
+
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type != eModifierType_ParticleSystem) {
continue;
@@ -673,7 +778,7 @@ static void workbench_cache_populate_particles(WORKBENCH_Data *vedata, Object *o
shader);
DRW_shgroup_stencil_mask(shgrp, (ob->dtx & OB_DRAWXRAY) ? 0x00 : 0xFF);
DRW_shgroup_uniform_int(shgrp, "object_id", &material->object_id, 1);
- workbench_material_shgroup_uniform(wpd, shgrp, material, ob);
+ workbench_material_shgroup_uniform(wpd, shgrp, material, ob, true, true);
}
}
}
@@ -711,13 +816,14 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
const bool is_active = (ob == draw_ctx->obact);
const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
+ const bool use_hide = is_active && DRW_object_use_hide_faces(ob);
bool is_drawn = false;
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));
struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len);
- struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
+ struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob, use_hide) : NULL;
if (materials_len > 0 && geom_array) {
for (int i = 0; i < materials_len; i++) {
if (geom_array[i] == NULL) {
@@ -740,7 +846,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (!is_drawn) {
if (ELEM(wpd->shading.color_type, V3D_SHADING_SINGLE_COLOR, V3D_SHADING_RANDOM_COLOR)) {
/* No material split needed */
- struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_object_surface_get_ex(ob, use_hide);
if (geom) {
material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type);
if (is_sculpt_mode) {
@@ -759,7 +865,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
}
struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get(
- ob, gpumat_array, materials_len, NULL, NULL, NULL);
+ ob, gpumat_array, materials_len, use_hide, NULL, NULL, NULL);
if (mat_geom) {
for (int i = 0; i < materials_len; ++i) {
if (mat_geom[i] == NULL) {
@@ -783,7 +889,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
bool is_manifold;
struct GPUBatch *geom_shadow = DRW_cache_object_edge_detection_get(ob, &is_manifold);
if (geom_shadow) {
- if (is_sculpt_mode) {
+ if (is_sculpt_mode || use_hide) {
/* Currently unsupported in sculpt mode. We could revert to the slow
* method in this case but I'm not sure if it's a good idea given that
* sculpted meshes are heavy to begin with. */
@@ -866,8 +972,15 @@ void workbench_deferred_draw_background(WORKBENCH_Data *vedata)
uint clear_stencil = 0x00;
DRW_stats_group_start("Clear Background");
+
+ if (OBJECT_ID_PASS_ENABLED(wpd)) {
+ /* From all the color buffers, only object id needs to be cleared. */
+ GPU_framebuffer_bind(fbl->id_clear_fb);
+ GPU_framebuffer_clear_color(fbl->id_clear_fb, clear_color);
+ }
+
GPU_framebuffer_bind(fbl->prepass_fb);
- int clear_bits = GPU_DEPTH_BIT | GPU_COLOR_BIT;
+ int clear_bits = GPU_DEPTH_BIT;
SET_FLAG_FROM_TEST(clear_bits, SHADOW_ENABLED(wpd), GPU_STENCIL_BIT);
GPU_framebuffer_clear(fbl->prepass_fb, clear_bits, clear_color, clear_depth, clear_stencil);
DRW_stats_group_end();
@@ -957,6 +1070,9 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata)
DRW_draw_pass(psl->ghost_prepass_hair_pass);
}
+ GPU_framebuffer_bind(fbl->composite_fb);
+ DRW_draw_pass(psl->background_pass);
+
if (wpd->volumes_do) {
GPU_framebuffer_bind(fbl->volume_fb);
DRW_draw_pass(psl->volume_pass);
diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c
index 403338d55c4..929281daaf4 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_taa.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c
@@ -171,7 +171,8 @@ DRWPass *workbench_taa_create_pass(WORKBENCH_Data *vedata, GPUTexture **color_bu
int previous_jitter_index = effect_info->jitter_index;
{
- DRW_texture_ensure_fullscreen_2D(&txl->history_buffer_tx, GPU_RGBA16F, 0);
+ const GPUTextureFormat hist_buffer_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_RGBA8;
+ DRW_texture_ensure_fullscreen_2D(&txl->history_buffer_tx, hist_buffer_format, 0);
DRW_texture_ensure_fullscreen_2D(&txl->depth_buffer_tx, GPU_DEPTH24_STENCIL8, 0);
}
diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c
index 642c5820895..180932b9b64 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.c
+++ b/source/blender/draw/engines/workbench/workbench_engine.c
@@ -31,12 +31,12 @@
#include "workbench_engine.h"
#include "workbench_private.h"
-#define OPENGL_ENGINE "BLENDER_OPENGL"
+#define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
/* Note: currently unused, we may want to register so we can see this when debugging the view. */
-RenderEngineType DRW_engine_viewport_opengl_type = {
+RenderEngineType DRW_engine_viewport_workbench_type = {
NULL, NULL,
- OPENGL_ENGINE, N_("OpenGL"), RE_INTERNAL,
+ WORKBENCH_ENGINE, N_("Workbench"), RE_INTERNAL,
NULL, &DRW_render_to_image, NULL, NULL, NULL, NULL,
&workbench_render_update_passes,
&draw_engine_workbench_solid,
diff --git a/source/blender/draw/engines/workbench/workbench_engine.h b/source/blender/draw/engines/workbench/workbench_engine.h
index 24f68cacd21..a7f168db093 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.h
+++ b/source/blender/draw/engines/workbench/workbench_engine.h
@@ -28,6 +28,6 @@
extern DrawEngineType draw_engine_workbench_solid;
extern DrawEngineType draw_engine_workbench_transparent;
-extern RenderEngineType DRW_engine_viewport_opengl_type;
+extern RenderEngineType DRW_engine_viewport_workbench_type;
#endif /* __WORKBENCH_ENGINE_H__ */
diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c
index aa75e1746c7..70e26f79076 100644
--- a/source/blender/draw/engines/workbench/workbench_forward.c
+++ b/source/blender/draw/engines/workbench/workbench_forward.c
@@ -49,8 +49,8 @@
/* *********** STATIC *********** */
static struct {
- struct GPUShader *composite_sh_cache[MAX_SHADERS];
- struct GPUShader *transparent_accum_sh_cache[MAX_SHADERS];
+ struct GPUShader *composite_sh_cache[2];
+ struct GPUShader *transparent_accum_sh_cache[MAX_ACCUM_SHADERS];
struct GPUShader *object_outline_sh;
struct GPUShader *object_outline_texture_sh;
struct GPUShader *object_outline_hair_sh;
@@ -62,7 +62,6 @@ static struct {
struct GPUTexture *composite_buffer_tx; /* ref only, not alloced */
int next_object_id;
- float normal_world_matrix[3][3];
} e_data = {{NULL}};
/* Shaders */
@@ -75,6 +74,7 @@ extern char datatoc_workbench_data_lib_glsl[];
extern char datatoc_workbench_background_lib_glsl[];
extern char datatoc_workbench_checkerboard_depth_frag_glsl[];
extern char datatoc_workbench_object_outline_lib_glsl[];
+extern char datatoc_workbench_curvature_lib_glsl[];
extern char datatoc_workbench_prepass_vert_glsl[];
extern char datatoc_workbench_common_lib_glsl[];
extern char datatoc_workbench_world_light_lib_glsl[];
@@ -123,6 +123,7 @@ static char *workbench_build_forward_composite_frag(void)
BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_background_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_object_outline_lib_glsl);
+ BLI_dynstr_append(ds, datatoc_workbench_curvature_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_forward_composite_frag_glsl);
str = BLI_dynstr_get_cstring(ds);
@@ -166,9 +167,8 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo);
DRW_shgroup_uniform_float(grp, "alpha", &wpd->shading.xray_alpha, 1);
DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)wpd->viewvecs, 3);
- workbench_material_set_normal_world_matrix(grp, wpd, e_data.normal_world_matrix);
workbench_material_copy(material, &material_template);
- if (STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)) {
+ if (STUDIOLIGHT_TYPE_MATCAP_ENABLED(wpd)) {
BKE_studiolight_ensure_flag(wpd->studio_light, STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE);
DRW_shgroup_uniform_texture(grp, "matcapImage", wpd->studio_light->equirect_radiance_gputexture );
}
@@ -176,7 +176,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
}
- workbench_material_shgroup_uniform(wpd, grp, material, ob);
+ workbench_material_shgroup_uniform(wpd, grp, material, ob, false, false);
material->shgrp = grp;
/* Depth */
@@ -197,16 +197,9 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
return material;
}
-static void ensure_forward_shaders(WORKBENCH_PrivateData *wpd, int index, bool use_textures, bool is_hair)
+static GPUShader *ensure_forward_accum_shaders(WORKBENCH_PrivateData *wpd, bool use_textures, bool 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);
- MEM_freeN(defines);
- }
-
+ int index = workbench_material_get_accum_shader_index(wpd, use_textures, is_hair);
if (e_data.transparent_accum_sh_cache[index] == NULL) {
char *defines = workbench_material_build_defines(wpd, use_textures, is_hair);
char *transparent_accum_vert = workbench_build_forward_vert(is_hair);
@@ -218,25 +211,29 @@ static void ensure_forward_shaders(WORKBENCH_PrivateData *wpd, int index, bool u
MEM_freeN(transparent_accum_frag);
MEM_freeN(defines);
}
+ return e_data.transparent_accum_sh_cache[index];
+}
+
+static GPUShader *ensure_forward_composite_shaders(WORKBENCH_PrivateData *wpd)
+{
+ int index = OBJECT_OUTLINE_ENABLED(wpd) ? 1 : 0;
+ if (e_data.composite_sh_cache[index] == NULL) {
+ char *defines = workbench_material_build_defines(wpd, false, false);
+ 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);
+ MEM_freeN(defines);
+ }
+ return e_data.composite_sh_cache[index];
}
static void select_forward_shaders(WORKBENCH_PrivateData *wpd)
{
- 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, 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];
- wpd->transparent_accum_hair_sh = e_data.transparent_accum_sh_cache[index_solid_hair];
- wpd->transparent_accum_texture_sh = e_data.transparent_accum_sh_cache[index_texture];
- wpd->transparent_accum_texture_hair_sh = e_data.transparent_accum_sh_cache[index_texture_hair];
+ wpd->composite_sh = ensure_forward_composite_shaders(wpd);
+ wpd->transparent_accum_sh = ensure_forward_accum_shaders(wpd, false, false);
+ wpd->transparent_accum_hair_sh = ensure_forward_accum_shaders(wpd, false, true);
+ wpd->transparent_accum_texture_sh = ensure_forward_accum_shaders(wpd, true, false);
+ wpd->transparent_accum_texture_hair_sh = ensure_forward_accum_shaders(wpd, true, true);
}
/* public functions */
@@ -264,8 +261,8 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
if (!e_data.next_object_id) {
e_data.next_object_id = 1;
- memset(e_data.composite_sh_cache, 0x00, sizeof(struct GPUShader *) * MAX_SHADERS);
- memset(e_data.transparent_accum_sh_cache, 0x00, sizeof(struct GPUShader *) * MAX_SHADERS);
+ memset(e_data.composite_sh_cache, 0x00, sizeof(e_data.composite_sh_cache));
+ memset(e_data.transparent_accum_sh_cache, 0x00, sizeof(e_data.transparent_accum_sh_cache));
char *defines = workbench_material_build_defines(wpd, false, false);
char *defines_texture = workbench_material_build_defines(wpd, true, false);
@@ -391,8 +388,10 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
void workbench_forward_engine_free()
{
- for (int index = 0; index < MAX_SHADERS; index++) {
+ for (int index = 0; index < 2; index++) {
DRW_SHADER_FREE_SAFE(e_data.composite_sh_cache[index]);
+ }
+ for (int index = 0; index < MAX_ACCUM_SHADERS; index++) {
DRW_SHADER_FREE_SAFE(e_data.transparent_accum_sh_cache[index]);
}
DRW_SHADER_FREE_SAFE(e_data.object_outline_sh);
@@ -414,11 +413,7 @@ static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, O
WORKBENCH_StorageList *stl = vedata->stl;
WORKBENCH_PassList *psl = vedata->psl;
WORKBENCH_PrivateData *wpd = stl->g_data;
- const DRWContextState *draw_ctx = DRW_context_state_get();
- if (ob == draw_ctx->object_edit) {
- return;
- }
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type != eModifierType_ParticleSystem) {
continue;
@@ -447,15 +442,14 @@ static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, O
ob, psys, md,
psl->transparent_accum_pass,
shader);
- workbench_material_set_normal_world_matrix(shgrp, wpd, e_data.normal_world_matrix);
DRW_shgroup_uniform_block(shgrp, "world_block", wpd->world_ubo);
- workbench_material_shgroup_uniform(wpd, shgrp, material, ob);
+ workbench_material_shgroup_uniform(wpd, shgrp, material, ob, false, false);
DRW_shgroup_uniform_vec4(shgrp, "viewvecs[0]", (float *)wpd->viewvecs, 3);
/* Hairs have lots of layer and can rapidly become the most prominent surface.
* So lower their alpha artificially. */
float hair_alpha = XRAY_ALPHA(wpd) * 0.33f;
DRW_shgroup_uniform_float_copy(shgrp, "alpha", hair_alpha);
- if (STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)) {
+ if (STUDIOLIGHT_TYPE_MATCAP_ENABLED(wpd)) {
BKE_studiolight_ensure_flag(wpd->studio_light, STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE);
DRW_shgroup_uniform_texture(shgrp, "matcapImage", wpd->studio_light->equirect_radiance_gputexture );
}
@@ -503,6 +497,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
const bool is_active = (ob == draw_ctx->obact);
const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
+ const bool use_hide = is_active && DRW_object_use_hide_faces(ob);
bool is_drawn = false;
if (!is_sculpt_mode && TEXTURE_DRAWING_ENABLED(wpd) && ELEM(ob->type, OB_MESH)) {
@@ -510,7 +505,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (me->mloopuv) {
const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol));
struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len);
- struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
+ struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob, use_hide) : NULL;
if (materials_len > 0 && geom_array) {
for (int i = 0; i < materials_len; i++) {
if (geom_array[i] == NULL) {
@@ -543,7 +538,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (!is_drawn) {
if (ELEM(wpd->shading.color_type, V3D_SHADING_SINGLE_COLOR, V3D_SHADING_RANDOM_COLOR)) {
/* No material split needed */
- struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_object_surface_get_ex(ob, use_hide);
if (geom) {
material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type);
if (is_sculpt_mode) {
@@ -568,7 +563,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
}
struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get(
- ob, gpumat_array, materials_len, NULL, NULL, NULL);
+ ob, gpumat_array, materials_len, use_hide, NULL, NULL, NULL);
if (mat_geom) {
for (int i = 0; i < materials_len; ++i) {
if (mat_geom[i] == NULL) {
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index 2faa9e288f8..c4ab39897f3 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -8,20 +8,21 @@
#include "BLI_hash.h"
#define HSV_SATURATION 0.5
-#define HSV_VALUE 0.9
+#define HSV_VALUE 0.8
void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Material *mat, WORKBENCH_MaterialData *data)
{
/* 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->diffuse_color, default_diffuse_color);
- copy_v4_v4(data->specular_color, default_specular_color);
- data->roughness = 0.5f;
+ copy_v3_fl3(data->diffuse_color, 0.8f, 0.8f, 0.8f);
+ copy_v3_v3(data->base_color, data->diffuse_color);
+ copy_v3_fl3(data->specular_color, 0.05f, 0.05f, 0.05f); /* Dielectric: 5% reflective. */
+ data->metallic = 0.0f;
+ data->roughness = 0.5f; /* sqrtf(0.25f); */
if (color_type == V3D_SHADING_SINGLE_COLOR) {
copy_v3_v3(data->diffuse_color, wpd->shading.single_color);
+ copy_v3_v3(data->base_color, data->diffuse_color);
}
else if (color_type == V3D_SHADING_RANDOM_COLOR) {
uint hash = BLI_ghashutil_strhash_p_murmur(ob->id.name);
@@ -32,13 +33,23 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Mate
float hue = BLI_hash_int_01(hash);
float hsv[3] = {hue, HSV_SATURATION, HSV_VALUE};
hsv_to_rgb_v(hsv, data->diffuse_color);
+ copy_v3_v3(data->base_color, data->diffuse_color);
}
else {
/* V3D_SHADING_MATERIAL_COLOR */
if (mat) {
- copy_v3_v3(data->diffuse_color, &mat->r);
- copy_v3_v3(data->specular_color, &mat->specr);
- data->roughness = mat->roughness;
+ if (SPECULAR_HIGHLIGHT_ENABLED(wpd)) {
+ copy_v3_v3(data->base_color, &mat->r);
+ mul_v3_v3fl(data->diffuse_color, &mat->r, 1.0f - mat->metallic);
+ mul_v3_v3fl(data->specular_color, &mat->r, mat->metallic);
+ add_v3_fl(data->specular_color, 0.05f * (1.0f - mat->metallic));
+ data->metallic = mat->metallic;
+ data->roughness = sqrtf(mat->roughness); /* Remap to disney roughness. */
+ }
+ else {
+ copy_v3_v3(data->base_color, &mat->r);
+ copy_v3_v3(data->diffuse_color, &mat->r);
+ }
}
}
}
@@ -55,8 +66,8 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool use_text
if (wpd->shading.flag & V3D_SHADING_SHADOW) {
BLI_dynstr_appendf(ds, "#define V3D_SHADING_SHADOW\n");
}
- if (CAVITY_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define V3D_SHADING_CAVITY\n");
+ if (SSAO_ENABLED(wpd) || CURVATURE_ENABLED(wpd)) {
+ BLI_dynstr_appendf(ds, "#define WB_CAVITY\n");
}
if (SPECULAR_HIGHLIGHT_ENABLED(wpd)) {
BLI_dynstr_appendf(ds, "#define V3D_SHADING_SPECULAR_HIGHLIGHT\n");
@@ -70,14 +81,11 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool use_text
if (MATCAP_ENABLED(wpd)) {
BLI_dynstr_appendf(ds, "#define V3D_LIGHTING_MATCAP\n");
}
- if (STUDIOLIGHT_ORIENTATION_WORLD_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_ORIENTATION_WORLD\n");
+ if (OBJECT_ID_PASS_ENABLED(wpd)) {
+ BLI_dynstr_appendf(ds, "#define OBJECT_ID_PASS_ENABLED\n");
}
- if (STUDIOLIGHT_ORIENTATION_CAMERA_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_ORIENTATION_CAMERA\n");
- }
- if (STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_ORIENTATION_VIEWNORMAL\n");
+ if (MATDATA_PASS_ENABLED(wpd)) {
+ BLI_dynstr_appendf(ds, "#define MATDATA_PASS_ENABLED\n");
}
if (NORMAL_VIEWPORT_PASS_ENABLED(wpd)) {
BLI_dynstr_appendf(ds, "#define NORMAL_VIEWPORT_PASS_ENABLED\n");
@@ -92,9 +100,6 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool use_text
BLI_dynstr_appendf(ds, "#define HAIR_SHADER\n");
}
- BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_SH_BANDS %d\n", STUDIOLIGHT_SH_BANDS);
- BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_SH_MAX_COMPONENTS %d\n", WORKBENCH_SH_DATA_LEN);
-
str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return str;
@@ -128,40 +133,42 @@ uint workbench_material_get_hash(WORKBENCH_MaterialData *material_template, bool
return result;
}
-int workbench_material_get_shader_index(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair)
+int workbench_material_get_composite_shader_index(WORKBENCH_PrivateData *wpd)
{
- /* NOTE: change MAX_SHADERS accordingly when modifying this function. */
+ /* NOTE: change MAX_COMPOSITE_SHADERS accordingly when modifying this function. */
int index = 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 */
- SET_FLAG_FROM_TEST(index, wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT, 1 << 3);
- SET_FLAG_FROM_TEST(index, wpd->shading.flag & V3D_SHADING_SHADOW, 1 << 4);
- SET_FLAG_FROM_TEST(index, wpd->shading.flag & V3D_SHADING_CAVITY, 1 << 5);
- SET_FLAG_FROM_TEST(index, wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE, 1 << 6);
- /* 2 bits STUDIOLIGHT_ORIENTATION */
- SET_FLAG_FROM_TEST(index, wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_WORLD, 1 << 7);
- SET_FLAG_FROM_TEST(index, wpd->studio_light->flag & STUDIOLIGHT_ORIENTATION_VIEWNORMAL, 1 << 8);
- /* 1 bit for hair */
- SET_FLAG_FROM_TEST(index, is_hair, 1 << 9);
+ /* 2 bits FLAT/STUDIO/MATCAP + Specular highlight */
+ index = SPECULAR_HIGHLIGHT_ENABLED(wpd) ? 3 : wpd->shading.light;
+ SET_FLAG_FROM_TEST(index, wpd->shading.flag & V3D_SHADING_SHADOW, 1 << 2);
+ SET_FLAG_FROM_TEST(index, wpd->shading.flag & V3D_SHADING_CAVITY, 1 << 3);
+ SET_FLAG_FROM_TEST(index, wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE, 1 << 4);
+ SET_FLAG_FROM_TEST(index, MATDATA_PASS_ENABLED(wpd), 1 << 5);
return index;
}
-void workbench_material_set_normal_world_matrix(
- DRWShadingGroup *grp, WORKBENCH_PrivateData *wpd, float persistent_matrix[3][3])
+int workbench_material_get_prepass_shader_index(
+ WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair)
{
- if (STUDIOLIGHT_ORIENTATION_WORLD_ENABLED(wpd)) {
- float view_matrix_inverse[4][4];
- float rot_matrix[4][4];
- float matrix[4][4];
- axis_angle_to_mat4_single(rot_matrix, 'Z', -wpd->shading.studiolight_rot_z);
- DRW_viewport_matrix_get(view_matrix_inverse, DRW_MAT_VIEWINV);
- mul_m4_m4m4(matrix, rot_matrix, view_matrix_inverse);
- copy_m3_m4(persistent_matrix, matrix);
- DRW_shgroup_uniform_mat3(grp, "normalWorldMatrix", persistent_matrix);
- }
+ /* NOTE: change MAX_PREPASS_SHADERS accordingly when modifying this function. */
+ int index = 0;
+ SET_FLAG_FROM_TEST(index, is_hair, 1 << 0);
+ SET_FLAG_FROM_TEST(index, MATDATA_PASS_ENABLED(wpd), 1 << 1);
+ SET_FLAG_FROM_TEST(index, OBJECT_ID_PASS_ENABLED(wpd), 1 << 2);
+ SET_FLAG_FROM_TEST(index, NORMAL_VIEWPORT_PASS_ENABLED(wpd), 1 << 3);
+ SET_FLAG_FROM_TEST(index, MATCAP_ENABLED(wpd), 1 << 4);
+ SET_FLAG_FROM_TEST(index, use_textures, 1 << 5);
+ return index;
+}
+
+int workbench_material_get_accum_shader_index(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair)
+{
+ /* NOTE: change MAX_ACCUM_SHADERS accordingly when modifying this function. */
+ int index = 0;
+ /* 2 bits FLAT/STUDIO/MATCAP + Specular highlight */
+ index = SPECULAR_HIGHLIGHT_ENABLED(wpd) ? 3 : wpd->shading.light;
+ SET_FLAG_FROM_TEST(index, use_textures, 1 << 2);
+ SET_FLAG_FROM_TEST(index, is_hair, 1 << 3);
+ return index;
}
int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *ima, Object *ob)
@@ -174,18 +181,28 @@ int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *i
}
void workbench_material_shgroup_uniform(
- WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp, WORKBENCH_MaterialData *material, Object *ob)
+ WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp, WORKBENCH_MaterialData *material, Object *ob,
+ const bool use_metallic, const bool deferred)
{
+ if (deferred && !MATDATA_PASS_ENABLED(wpd)) {
+ return;
+ }
+
if (workbench_material_determine_color_type(wpd, material->ima, ob) == V3D_SHADING_TEXTURE_COLOR) {
GPUTexture *tex = GPU_texture_from_blender(material->ima, NULL, GL_TEXTURE_2D, false, 0.0f);
DRW_shgroup_uniform_texture(grp, "image", tex);
}
else {
- DRW_shgroup_uniform_vec4(grp, "materialDiffuseColor", material->diffuse_color, 1);
+ DRW_shgroup_uniform_vec3(grp, "materialDiffuseColor", (use_metallic) ? material->base_color : material->diffuse_color, 1);
}
if (SPECULAR_HIGHLIGHT_ENABLED(wpd)) {
- DRW_shgroup_uniform_vec4(grp, "materialSpecularColor", material->specular_color, 1);
+ if (use_metallic) {
+ DRW_shgroup_uniform_float(grp, "materialMetallic", &material->metallic, 1);
+ }
+ else {
+ DRW_shgroup_uniform_vec3(grp, "materialSpecularColor", material->specular_color, 1);
+ }
DRW_shgroup_uniform_float(grp, "materialRoughness", &material->roughness, 1);
}
}
@@ -193,8 +210,10 @@ void workbench_material_shgroup_uniform(
void workbench_material_copy(WORKBENCH_MaterialData *dest_material, const WORKBENCH_MaterialData *source_material)
{
dest_material->object_id = source_material->object_id;
- copy_v4_v4(dest_material->diffuse_color, source_material->diffuse_color);
- copy_v4_v4(dest_material->specular_color, source_material->specular_color);
+ copy_v3_v3(dest_material->base_color, source_material->base_color);
+ copy_v3_v3(dest_material->diffuse_color, source_material->diffuse_color);
+ copy_v3_v3(dest_material->specular_color, source_material->specular_color);
+ dest_material->metallic = source_material->metallic;
dest_material->roughness = source_material->roughness;
dest_material->ima = source_material->ima;
}
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index 93b3bddfb72..080817c7f53 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -40,16 +40,22 @@
#define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
#define M_GOLDEN_RATION_CONJUGATE 0.618033988749895
-#define MAX_SHADERS (1 << 10)
+#define MAX_COMPOSITE_SHADERS (1 << 6)
+#define MAX_PREPASS_SHADERS (1 << 6)
+#define MAX_ACCUM_SHADERS (1 << 4)
+#define MAX_CAVITY_SHADERS (1 << 3)
#define TEXTURE_DRAWING_ENABLED(wpd) (wpd->shading.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)
-#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))
-#define CAVITY_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_CAVITY)
+#define USE_WORLD_ORIENTATION(wpd) ((wpd->shading.flag & V3D_SHADING_WORLD_ORIENTATION) != 0)
+#define STUDIOLIGHT_TYPE_WORLD_ENABLED(wpd) (STUDIOLIGHT_ENABLED(wpd) && (wpd->studio_light->flag & STUDIOLIGHT_TYPE_WORLD))
+#define STUDIOLIGHT_TYPE_STUDIO_ENABLED(wpd) (STUDIOLIGHT_ENABLED(wpd) && (wpd->studio_light->flag & STUDIOLIGHT_TYPE_STUDIO))
+#define STUDIOLIGHT_TYPE_MATCAP_ENABLED(wpd) (MATCAP_ENABLED(wpd) && (wpd->studio_light->flag & STUDIOLIGHT_TYPE_MATCAP))
+#define SSAO_ENABLED(wpd) ((wpd->shading.flag & V3D_SHADING_CAVITY) && ((wpd->shading.cavity_type == V3D_SHADING_CAVITY_SSAO) || (wpd->shading.cavity_type == V3D_SHADING_CAVITY_BOTH)))
+#define CURVATURE_ENABLED(wpd) ((wpd->shading.flag & V3D_SHADING_CAVITY) && ((wpd->shading.cavity_type == V3D_SHADING_CAVITY_CURVATURE) || (wpd->shading.cavity_type == V3D_SHADING_CAVITY_BOTH)))
+#define CAVITY_ENABLED(wpd) (CURVATURE_ENABLED(wpd) || SSAO_ENABLED(wpd))
#define SHADOW_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_SHADOW)
#define GHOST_ENABLED(psl) (!DRW_pass_is_empty(psl->ghost_prepass_pass) || !DRW_pass_is_empty(psl->ghost_prepass_hair_pass))
@@ -58,10 +64,12 @@
(IN_RANGE(wpd->user_preferences->gpu_viewport_quality, GPU_VIEWPORT_QUALITY_FXAA, GPU_VIEWPORT_QUALITY_TAA8) || \
((IS_NAVIGATING(wpd) || wpd->is_playback) && (wpd->user_preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8))))
#define TAA_ENABLED(wpd) (DRW_state_is_image_render() || (wpd->user_preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8 && !IS_NAVIGATING(wpd) && !wpd->is_playback))
-#define SPECULAR_HIGHLIGHT_ENABLED(wpd) ((wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT) && (!STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)))
-#define OBJECT_ID_PASS_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE)
-#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 SPECULAR_HIGHLIGHT_ENABLED(wpd) (STUDIOLIGHT_ENABLED(wpd) && (wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT) && (!STUDIOLIGHT_TYPE_MATCAP_ENABLED(wpd)))
+#define OBJECT_OUTLINE_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE)
+#define OBJECT_ID_PASS_ENABLED(wpd) (OBJECT_OUTLINE_ENABLED(wpd) || CURVATURE_ENABLED(wpd))
+#define MATDATA_PASS_ENABLED(wpd) (wpd->shading.color_type != V3D_SHADING_SINGLE_COLOR || MATCAP_ENABLED(wpd))
+#define NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) (MATCAP_ENABLED(wpd) || STUDIOLIGHT_ENABLED(wpd) || SHADOW_ENABLED(wpd))
+#define NORMAL_VIEWPORT_PASS_ENABLED(wpd) (NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) || SSAO_ENABLED(wpd) || CURVATURE_ENABLED(wpd))
#define NORMAL_ENCODING_ENABLED() (true)
@@ -76,6 +84,7 @@ typedef struct WORKBENCH_FramebufferList {
struct GPUFrameBuffer *ghost_prepass_fb;
struct GPUFrameBuffer *cavity_fb;
struct GPUFrameBuffer *composite_fb;
+ struct GPUFrameBuffer *id_clear_fb;
struct GPUFrameBuffer *effect_fb;
struct GPUFrameBuffer *effect_taa_fb;
@@ -113,6 +122,7 @@ typedef struct WORKBENCH_PassList {
struct DRWPass *shadow_depth_fail_caps_mani_pass;
struct DRWPass *composite_pass;
struct DRWPass *composite_shadow_pass;
+ struct DRWPass *background_pass;
struct DRWPass *ghost_resolve_pass;
struct DRWPass *effect_aa_pass;
struct DRWPass *volume_pass;
@@ -133,24 +143,24 @@ typedef struct WORKBENCH_Data {
} WORKBENCH_Data;
typedef struct WORKBENCH_UBO_Light {
- float light_direction_vs[4];
- float specular_color[3];
- float energy;
+ float light_direction[4];
+ float specular_color[3], pad;
+ float diffuse_color[3], wrapped;
} WORKBENCH_UBO_Light;
-#define WORKBENCH_SH_DATA_LEN ((STUDIOLIGHT_SH_BANDS == 2) ? 6 : STUDIOLIGHT_SH_EFFECTIVE_COEFS_LEN)
-
typedef struct WORKBENCH_UBO_World {
- float spherical_harmonics_coefs[WORKBENCH_SH_DATA_LEN][4];
float background_color_low[4];
float background_color_high[4];
float object_outline_color[4];
float shadow_direction_vs[4];
- WORKBENCH_UBO_Light lights[3];
+ WORKBENCH_UBO_Light lights[4];
+ float ambient_color[4];
int num_lights;
int matcap_orientation;
float background_alpha;
- int pad[1];
+ float curvature_ridge;
+ float curvature_valley;
+ int pad[3];
} WORKBENCH_UBO_World;
BLI_STATIC_ASSERT_ALIGN(WORKBENCH_UBO_World, 16)
@@ -162,6 +172,7 @@ typedef struct WORKBENCH_PrivateData {
struct GPUShader *prepass_texture_sh;
struct GPUShader *prepass_texture_hair_sh;
struct GPUShader *composite_sh;
+ struct GPUShader *background_sh;
struct GPUShader *transparent_accum_sh;
struct GPUShader *transparent_accum_hair_sh;
struct GPUShader *transparent_accum_texture_sh;
@@ -212,8 +223,10 @@ typedef struct WORKBENCH_EffectInfo {
} WORKBENCH_EffectInfo;
typedef struct WORKBENCH_MaterialData {
- float diffuse_color[4];
- float specular_color[4];
+ float base_color[3];
+ float diffuse_color[3];
+ float specular_color[3];
+ float metallic;
float roughness;
int object_id;
int color_type;
@@ -288,15 +301,16 @@ int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *i
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, bool is_ghost);
-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]);
+int workbench_material_get_composite_shader_index(WORKBENCH_PrivateData *wpd);
+int workbench_material_get_prepass_shader_index(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair);
+int workbench_material_get_accum_shader_index(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair);
void workbench_material_shgroup_uniform(
- WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp, WORKBENCH_MaterialData *material, Object *ob);
+ WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp, WORKBENCH_MaterialData *material, Object *ob,
+ const bool use_metallic, const bool deferred);
void workbench_material_copy(WORKBENCH_MaterialData *dest_material, const WORKBENCH_MaterialData *source_material);
/* workbench_studiolight.c */
-void studiolight_update_world(StudioLight *sl, WORKBENCH_UBO_World *wd);
+void studiolight_update_world(WORKBENCH_PrivateData *wpd, StudioLight *sl, WORKBENCH_UBO_World *wd);
void studiolight_update_light(WORKBENCH_PrivateData *wpd, const float light_direction[3]);
bool studiolight_object_cast_visible_shadow(WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed);
float studiolight_object_shadow_distance(WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed);
diff --git a/source/blender/draw/engines/workbench/workbench_studiolight.c b/source/blender/draw/engines/workbench/workbench_studiolight.c
index 901260d0660..52a0e6045c6 100644
--- a/source/blender/draw/engines/workbench/workbench_studiolight.c
+++ b/source/blender/draw/engines/workbench/workbench_studiolight.c
@@ -32,8 +32,48 @@
#include "BLI_math.h"
#include "BKE_global.h"
-void studiolight_update_world(StudioLight *sl, WORKBENCH_UBO_World *wd)
+void studiolight_update_world(WORKBENCH_PrivateData *wpd, StudioLight *studiolight, WORKBENCH_UBO_World *wd)
{
+ float view_matrix[4][4], rot_matrix[4][4];
+ DRW_viewport_matrix_get(view_matrix, DRW_MAT_VIEW);
+
+ if (USE_WORLD_ORIENTATION(wpd)) {
+ axis_angle_to_mat4_single(rot_matrix, 'Z', -wpd->shading.studiolight_rot_z);
+ mul_m4_m4m4(rot_matrix, view_matrix, rot_matrix);
+ swap_v3_v3(rot_matrix[2], rot_matrix[1]);
+ negate_v3(rot_matrix[2]);
+ }
+ else {
+ unit_m4(rot_matrix);
+ }
+
+ if (U.edit_studio_light) {
+ studiolight = BKE_studiolight_studio_edit_get();
+ }
+
+ /* Studio Lights. */
+ for (int i = 0; i < 4; i++) {
+ WORKBENCH_UBO_Light *light = &wd->lights[i];
+
+ SolidLight *sl = &studiolight->light[i];
+ if (sl->flag) {
+ copy_v3_v3(light->light_direction, sl->vec);
+ mul_mat3_m4_v3(rot_matrix, light->light_direction);
+ /* We should predivide the power by PI but that makes the lights really dim. */
+ copy_v3_v3(light->specular_color, sl->spec);
+ copy_v3_v3(light->diffuse_color, sl->col);
+ light->wrapped = sl->smooth;
+ }
+ else {
+ copy_v3_fl3(light->light_direction, 1.0f, 0.0f, 0.0f);
+ copy_v3_fl(light->specular_color, 0.0f);
+ copy_v3_fl(light->diffuse_color, 0.0f);
+ }
+ }
+
+ copy_v3_v3(wd->ambient_color, studiolight->light_ambient);
+
+#if 0
BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED);
#if STUDIOLIGHT_SH_BANDS == 2
@@ -87,6 +127,7 @@ void studiolight_update_world(StudioLight *sl, WORKBENCH_UBO_World *wd)
copy_v3_v3(wd->spherical_harmonics_coefs[i], sl->spherical_harmonics_coefs[i]);
}
#endif
+#endif
}
static void compute_parallel_lines_nor_and_dist(const float v1[2], const float v2[2], const float v3[2], float r_line[2])
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index faba85c9b46..d3d4a35cf18 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -296,6 +296,7 @@ typedef enum {
DRW_STATE_WIRE_SMOOTH = (1 << 22),
DRW_STATE_TRANS_FEEDBACK = (1 << 23),
DRW_STATE_BLEND_OIT = (1 << 24),
+ DRW_STATE_FIRST_VERTEX_CONVENTION = (1 << 25),
DRW_STATE_WRITE_STENCIL = (1 << 27),
DRW_STATE_WRITE_STENCIL_SHADOW_PASS = (1 << 28),
@@ -512,9 +513,13 @@ DrawData *DRW_drawdata_ensure(
bool DRW_object_is_renderable(const struct Object *ob);
bool DRW_object_is_visible_in_active_context(const struct Object *ob);
bool DRW_object_is_flat_normal(const struct Object *ob);
+bool DRW_object_use_hide_faces(const struct Object *ob);
bool DRW_object_is_visible_psys_in_active_context(const struct Object *object, const struct ParticleSystem *psys);
+struct Object *DRW_object_get_dupli_parent(const struct Object *ob);
+struct DupliObject *DRW_object_get_dupli(const struct Object *ob);
+
/* Draw commands */
void DRW_draw_pass(DRWPass *pass);
void DRW_draw_pass_subset(DRWPass *pass, DRWShadingGroup *start_group, DRWShadingGroup *end_group);
@@ -552,6 +557,7 @@ bool DRW_state_is_depth(void);
bool DRW_state_is_image_render(void);
bool DRW_state_is_scene_render(void);
bool DRW_state_is_opengl_render(void);
+bool DRW_state_is_playback(void);
bool DRW_state_show_text(void);
bool DRW_state_draw_support(void);
bool DRW_state_draw_background(void);
diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index aec25274ab1..b8b53fbbb78 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -940,7 +940,7 @@ static void edbo_compute_bbone_child(bArmature *arm)
}
}
-/* A version of b_bone_spline_setup() for previewing editmode curve settings. */
+/* A version of BKE_pchan_bbone_spline_setup() for previewing editmode curve settings. */
static void ebone_spline_preview(EditBone *ebone, float result_array[MAX_BBONE_SUBDIV][4][4])
{
BBoneSplineParameters param;
@@ -1043,7 +1043,7 @@ static void ebone_spline_preview(EditBone *ebone, float result_array[MAX_BBONE_S
param.curveOutX = ebone->curveOutX;
param.curveOutY = ebone->curveOutY;
- ebone->segments = BKE_compute_b_bone_spline(&param, (Mat4 *)result_array);
+ ebone->segments = BKE_pchan_bbone_spline_compute(&param, (Mat4 *)result_array);
}
static void draw_bone_update_disp_matrix_bbone(EditBone *eBone, bPoseChannel *pchan)
@@ -1086,7 +1086,7 @@ static void draw_bone_update_disp_matrix_bbone(EditBone *eBone, bPoseChannel *pc
memcpy(bbones_mat, pchan->runtime.bbone_pose_mats, sizeof(Mat4) * bbone_segments);
}
else {
- b_bone_spline_setup(pchan, false, bbones_mat);
+ BKE_pchan_bbone_spline_setup(pchan, false, bbones_mat);
}
for (int i = bbone_segments; i--; bbones_mat++) {
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index d6caabcb203..70d9f960265 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -39,6 +39,7 @@
#include "BLI_math.h"
#include "BLI_listbase.h"
+#include "BKE_object.h"
#include "BKE_object_deform.h"
#include "GPU_batch.h"
@@ -47,6 +48,8 @@
#include "MEM_guardedalloc.h"
+#include "DRW_render.h"
+
#include "draw_cache.h"
#include "draw_cache_impl.h"
@@ -693,25 +696,21 @@ GPUBatch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold)
}
/* Returns a buffer texture. */
-void DRW_cache_object_face_wireframe_get(
- Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count)
+GPUBatch *DRW_cache_object_face_wireframe_get(Object *ob)
{
switch (ob->type) {
case OB_MESH:
- DRW_cache_mesh_face_wireframe_get(ob, r_vert_tx, r_faceid_tx, r_tri_count);
- break;
+ return DRW_cache_mesh_face_wireframe_get(ob);
case OB_CURVE:
- DRW_cache_curve_face_wireframe_get(ob, r_vert_tx, r_faceid_tx, r_tri_count);
- break;
+ return DRW_cache_curve_face_wireframe_get(ob);
case OB_SURF:
- DRW_cache_surf_face_wireframe_get(ob, r_vert_tx, r_faceid_tx, r_tri_count);
- break;
+ return DRW_cache_surf_face_wireframe_get(ob);
case OB_FONT:
- DRW_cache_text_face_wireframe_get(ob, r_vert_tx, r_faceid_tx, r_tri_count);
- break;
+ return DRW_cache_text_face_wireframe_get(ob);
case OB_MBALL:
- DRW_cache_mball_face_wireframe_get(ob, r_vert_tx, r_faceid_tx, r_tri_count);
- break;
+ return DRW_cache_mball_face_wireframe_get(ob);
+ default:
+ return NULL;
}
}
@@ -729,9 +728,14 @@ GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob)
GPUBatch *DRW_cache_object_surface_get(Object *ob)
{
+ return DRW_cache_object_surface_get_ex(ob, false);
+}
+
+GPUBatch *DRW_cache_object_surface_get_ex(Object *ob, bool use_hide)
+{
switch (ob->type) {
case OB_MESH:
- return DRW_cache_mesh_surface_get(ob);
+ return DRW_cache_mesh_surface_get(ob, use_hide);
case OB_CURVE:
return DRW_cache_curve_surface_get(ob);
case OB_SURF:
@@ -746,7 +750,7 @@ GPUBatch *DRW_cache_object_surface_get(Object *ob)
}
GPUBatch **DRW_cache_object_surface_material_get(
- struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
+ struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, bool use_hide,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count)
{
if (auto_layer_names != NULL) {
@@ -757,7 +761,7 @@ GPUBatch **DRW_cache_object_surface_material_get(
switch (ob->type) {
case OB_MESH:
- return DRW_cache_mesh_surface_shaded_get(ob, gpumat_array, gpumat_array_len,
+ return DRW_cache_mesh_surface_shaded_get(ob, gpumat_array, gpumat_array_len, use_hide,
auto_layer_names, auto_layer_is_srgb, auto_layer_count);
case OB_CURVE:
return DRW_cache_curve_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
@@ -2997,8 +3001,7 @@ GPUBatch *DRW_cache_mesh_surface_overlay_get(Object *ob)
void DRW_cache_mesh_wire_overlay_get(
Object *ob,
- GPUBatch **r_tris, GPUBatch **r_ledges, GPUBatch **r_lverts,
- struct GPUTexture **r_data_tex)
+ GPUBatch **r_tris, GPUBatch **r_ledges, GPUBatch **r_lverts)
{
BLI_assert(ob->type == OB_MESH);
@@ -3007,7 +3010,6 @@ void DRW_cache_mesh_wire_overlay_get(
*r_tris = DRW_mesh_batch_cache_get_overlay_triangles(me);
*r_ledges = DRW_mesh_batch_cache_get_overlay_loose_edges(me);
*r_lverts = DRW_mesh_batch_cache_get_overlay_loose_verts(me);
- *r_data_tex = DRW_mesh_batch_cache_get_overlay_data_tex(me);
}
void DRW_cache_mesh_normals_overlay_get(
@@ -3049,21 +3051,20 @@ GPUBatch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold)
return DRW_mesh_batch_cache_get_edge_detection(me, r_is_manifold);
}
-GPUBatch *DRW_cache_mesh_surface_get(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_get(Object *ob, bool use_hide)
{
BLI_assert(ob->type == OB_MESH);
Mesh *me = ob->data;
- return DRW_mesh_batch_cache_get_triangles_with_normals(me);
+ return DRW_mesh_batch_cache_get_triangles_with_normals(me, use_hide);
}
-void DRW_cache_mesh_face_wireframe_get(
- Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count)
+GPUBatch *DRW_cache_mesh_face_wireframe_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
Mesh *me = ob->data;
- DRW_mesh_batch_cache_get_wireframes_face_texbuf(me, r_vert_tx, r_faceid_tx, r_tri_count);
+ return DRW_mesh_batch_cache_get_wireframes_face(me);
}
GPUBatch *DRW_cache_mesh_loose_edges_get(Object *ob)
@@ -3127,23 +3128,23 @@ GPUBatch *DRW_cache_mesh_surface_vert_colors_get(Object *ob)
/* Return list of batches */
GPUBatch **DRW_cache_mesh_surface_shaded_get(
- Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
+ Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, bool use_hide,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count)
{
BLI_assert(ob->type == OB_MESH);
Mesh *me = ob->data;
- return DRW_mesh_batch_cache_get_surface_shaded(me, gpumat_array, gpumat_array_len,
+ return DRW_mesh_batch_cache_get_surface_shaded(me, gpumat_array, gpumat_array_len, use_hide,
auto_layer_names, auto_layer_is_srgb, auto_layer_count);
}
/* Return list of batches */
-GPUBatch **DRW_cache_mesh_surface_texpaint_get(Object *ob)
+GPUBatch **DRW_cache_mesh_surface_texpaint_get(Object *ob, bool use_hide)
{
BLI_assert(ob->type == OB_MESH);
Mesh *me = ob->data;
- return DRW_mesh_batch_cache_get_surface_texpaint(me);
+ return DRW_mesh_batch_cache_get_surface_texpaint(me, use_hide);
}
GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
@@ -3183,7 +3184,7 @@ GPUBatch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, bool
BLI_assert(ob->type == OB_MESH);
Mesh *me = ob->data;
- return DRW_mesh_batch_cache_get_weight_overlay_edges(me, use_wire, use_sel);
+ return DRW_mesh_batch_cache_get_weight_overlay_edges(me, use_wire, use_sel, use_sel);
}
GPUBatch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob)
@@ -3257,13 +3258,12 @@ GPUBatch *DRW_cache_curve_surface_get(Object *ob)
return DRW_curve_batch_cache_get_triangles_with_normals(cu, ob->runtime.curve_cache);
}
-void DRW_cache_curve_face_wireframe_get(
- Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count)
+GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob)
{
BLI_assert(ob->type == OB_CURVE);
struct Curve *cu = ob->data;
- DRW_curve_batch_cache_get_wireframes_face_texbuf(cu, ob->runtime.curve_cache, r_vert_tx, r_faceid_tx, r_tri_count);
+ return DRW_curve_batch_cache_get_wireframes_face(cu, ob->runtime.curve_cache);
}
/* Return list of batches */
@@ -3289,11 +3289,10 @@ GPUBatch *DRW_cache_mball_surface_get(Object *ob)
return DRW_metaball_batch_cache_get_triangles_with_normals(ob);
}
-void DRW_cache_mball_face_wireframe_get(
- Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count)
+GPUBatch *DRW_cache_mball_face_wireframe_get(Object *ob)
{
BLI_assert(ob->type == OB_MBALL);
- return DRW_metaball_batch_cache_get_wireframes_face_texbuf(ob, r_vert_tx, r_faceid_tx, r_tri_count);
+ return DRW_metaball_batch_cache_get_wireframes_face(ob);
}
GPUBatch **DRW_cache_mball_surface_shaded_get(
@@ -3329,19 +3328,14 @@ GPUBatch *DRW_cache_text_surface_get(Object *ob)
return DRW_curve_batch_cache_get_triangles_with_normals(cu, ob->runtime.curve_cache);
}
-void DRW_cache_text_face_wireframe_get(
- Object *ob,
- struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count)
+GPUBatch *DRW_cache_text_face_wireframe_get(Object *ob)
{
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
if (cu->editfont && (cu->flag & CU_FAST)) {
- *r_vert_tx = NULL;
- *r_faceid_tx = NULL;
- *r_tri_count = 0;
- return;
+ return NULL;
}
- DRW_curve_batch_cache_get_wireframes_face_texbuf(cu, ob->runtime.curve_cache, r_vert_tx, r_faceid_tx, r_tri_count);
+ return DRW_curve_batch_cache_get_wireframes_face(cu, ob->runtime.curve_cache);
}
GPUBatch **DRW_cache_text_surface_shaded_get(
@@ -3384,13 +3378,12 @@ GPUBatch *DRW_cache_surf_surface_get(Object *ob)
return DRW_curve_batch_cache_get_triangles_with_normals(cu, ob->runtime.curve_cache);
}
-void DRW_cache_surf_face_wireframe_get(
- Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count)
+GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob)
{
BLI_assert(ob->type == OB_SURF);
struct Curve *cu = ob->data;
- DRW_curve_batch_cache_get_wireframes_face_texbuf(cu, ob->runtime.curve_cache, r_vert_tx, r_faceid_tx, r_tri_count);
+ return DRW_curve_batch_cache_get_wireframes_face(cu, ob->runtime.curve_cache);
}
/* Return list of batches */
@@ -3460,9 +3453,10 @@ GPUBatch *DRW_cache_particles_get_dots(Object *object, ParticleSystem *psys)
GPUBatch *DRW_cache_particles_get_edit_strands(
Object *object,
ParticleSystem *psys,
- struct PTCacheEdit *edit)
+ struct PTCacheEdit *edit,
+ bool use_weight)
{
- return DRW_particles_batch_cache_get_edit_strands(object, psys, edit);
+ return DRW_particles_batch_cache_get_edit_strands(object, psys, edit, use_weight);
}
GPUBatch *DRW_cache_particles_get_edit_inner_points(
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index d2aa2622246..e69c29a7375 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -53,12 +53,12 @@ struct GPUBatch *DRW_cache_screenspace_circle_get(void);
struct GPUBatch *DRW_cache_object_wire_outline_get(struct Object *ob);
struct GPUBatch *DRW_cache_object_edge_detection_get(struct Object *ob, bool *r_is_manifold);
struct GPUBatch *DRW_cache_object_surface_get(struct Object *ob);
+struct GPUBatch *DRW_cache_object_surface_get_ex(struct Object *ob, bool use_hide);
struct GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob);
struct GPUBatch **DRW_cache_object_surface_material_get(
- struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
+ struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, bool use_hide,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count);
-void DRW_cache_object_face_wireframe_get(
- Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count);
+struct GPUBatch *DRW_cache_object_face_wireframe_get(Object *ob);
/* Empties */
struct GPUBatch *DRW_cache_plain_axes_get(void);
@@ -128,8 +128,7 @@ struct GPUBatch *DRW_cache_bone_dof_lines_get(void);
struct GPUBatch *DRW_cache_mesh_surface_overlay_get(struct Object *ob);
void DRW_cache_mesh_wire_overlay_get(
struct Object *ob,
- struct GPUBatch **r_tris, struct GPUBatch **r_ledges, struct GPUBatch **r_lverts,
- struct GPUTexture **r_data_tex);
+ struct GPUBatch **r_tris, struct GPUBatch **r_ledges, struct GPUBatch **r_lverts);
void DRW_cache_mesh_normals_overlay_get(
struct Object *ob,
struct GPUBatch **r_tris, struct GPUBatch **r_tris_lnor,
@@ -137,7 +136,7 @@ void DRW_cache_mesh_normals_overlay_get(
struct GPUBatch *DRW_cache_face_centers_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_wire_outline_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is_manifold);
-struct GPUBatch *DRW_cache_mesh_surface_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_surface_get(struct Object *ob, bool use_hide);
struct GPUBatch *DRW_cache_mesh_loose_edges_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_surface_weights_get(struct Object *ob, struct ToolSettings *ts, bool paint_mode);
struct GPUBatch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob);
@@ -148,12 +147,11 @@ struct GPUBatch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool
struct GPUBatch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob);
struct GPUBatch **DRW_cache_mesh_surface_shaded_get(
- struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
+ struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, bool use_hide,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count);
-struct GPUBatch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob);
+struct GPUBatch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob, bool use_hide);
struct GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob);
-void DRW_cache_mesh_face_wireframe_get(
- Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count);
+struct GPUBatch *DRW_cache_mesh_face_wireframe_get(struct Object *ob);
void DRW_cache_mesh_sculpt_coords_ensure(struct Object *ob);
@@ -163,8 +161,7 @@ struct GPUBatch **DRW_cache_curve_surface_shaded_get(
struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
struct GPUBatch *DRW_cache_curve_surface_verts_get(struct Object *ob);
struct GPUBatch *DRW_cache_curve_edge_wire_get(struct Object *ob);
-void DRW_cache_curve_face_wireframe_get(
- Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count);
+struct GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob);
/* edit-mode */
struct GPUBatch *DRW_cache_curve_edge_normal_get(struct Object *ob, float normal_size);
struct GPUBatch *DRW_cache_curve_edge_overlay_get(struct Object *ob);
@@ -175,8 +172,7 @@ struct GPUBatch *DRW_cache_text_edge_wire_get(struct Object *ob);
struct GPUBatch *DRW_cache_text_surface_get(struct Object *ob);
struct GPUBatch **DRW_cache_text_surface_shaded_get(
struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
-void DRW_cache_text_face_wireframe_get(
- Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count);
+struct GPUBatch *DRW_cache_text_face_wireframe_get(Object *ob);
/* edit-mode */
struct GPUBatch *DRW_cache_text_cursor_overlay_get(struct Object *ob);
struct GPUBatch *DRW_cache_text_select_overlay_get(struct Object *ob);
@@ -185,8 +181,7 @@ struct GPUBatch *DRW_cache_text_select_overlay_get(struct Object *ob);
struct GPUBatch *DRW_cache_surf_surface_get(struct Object *ob);
struct GPUBatch **DRW_cache_surf_surface_shaded_get(
struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
-void DRW_cache_surf_face_wireframe_get(
- Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count);
+struct GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob);
/* Lattice */
struct GPUBatch *DRW_cache_lattice_verts_get(struct Object *ob);
@@ -199,7 +194,7 @@ struct GPUBatch *DRW_cache_particles_get_hair(
struct GPUBatch *DRW_cache_particles_get_dots(
struct Object *object, struct ParticleSystem *psys);
struct GPUBatch *DRW_cache_particles_get_edit_strands(
- struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit);
+ struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit, bool use_weight);
struct GPUBatch *DRW_cache_particles_get_edit_inner_points(
struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit);
struct GPUBatch *DRW_cache_particles_get_edit_tip_points(
@@ -209,7 +204,6 @@ struct GPUBatch *DRW_cache_particles_get_prim(int type);
/* Metaball */
struct GPUBatch *DRW_cache_mball_surface_get(struct Object *ob);
struct GPUBatch **DRW_cache_mball_surface_shaded_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
-void DRW_cache_mball_face_wireframe_get(
- Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count);
+struct GPUBatch *DRW_cache_mball_face_wireframe_get(Object *ob);
#endif /* __DRAW_CACHE_H__ */
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 9dc735807c0..287b29ff1ba 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -75,15 +75,12 @@ struct GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals(
struct GPUBatch **DRW_curve_batch_cache_get_surface_shaded(
struct Curve *cu, struct CurveCache *ob_curve_cache,
struct GPUMaterial **gpumat_array, uint gpumat_array_len);
-void DRW_curve_batch_cache_get_wireframes_face_texbuf(
- struct Curve *cu, struct CurveCache *ob_curve_cache,
- struct GPUTexture **verts_data, struct GPUTexture **face_indices, int *tri_count);
+struct GPUBatch *DRW_curve_batch_cache_get_wireframes_face(struct Curve *cu, struct CurveCache *ob_curve_cache);
/* Metaball */
struct GPUBatch *DRW_metaball_batch_cache_get_triangles_with_normals(struct Object *ob);
struct GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(struct Object *ob, struct MetaBall *mb, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
-void DRW_metaball_batch_cache_get_wireframes_face_texbuf(
- struct Object *ob, struct GPUTexture **verts_data, struct GPUTexture **face_indices, int *tri_count);
+struct GPUBatch *DRW_metaball_batch_cache_get_wireframes_face(struct Object *ob);
/* Curve (Font) */
struct GPUBatch *DRW_curve_batch_cache_get_overlay_cursor(struct Curve *cu);
@@ -96,7 +93,7 @@ struct GPUIndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_mate
struct ListBase *lb, uint gpumat_array_len);
struct GPUBatch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(
struct ListBase *lb, uint gpumat_array_len);
-struct GPUVertBuf *DRW_displist_create_edges_overlay_texture_buf(ListBase *lb);
+struct GPUBatch *DRW_displist_create_edges_overlay_batch(ListBase *lb);
/* Lattice */
struct GPUBatch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt, bool use_weight, const int actdef);
@@ -128,16 +125,16 @@ bool DRW_mesh_weight_state_compare(const struct DRW_MeshWeightState *a, const st
/* Mesh */
struct GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(
- struct Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
+ struct Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len, bool use_hide,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count);
-struct GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me);
+struct GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me, bool use_hide);
struct GPUBatch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel);
+struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel, bool use_hide);
struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me, bool use_hide);
struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, const struct DRW_MeshWeightState *wstate);
struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide, uint select_id_offset);
@@ -155,14 +152,12 @@ struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me);
-struct GPUTexture *DRW_mesh_batch_cache_get_overlay_data_tex(struct Mesh *me);
/* edit-mesh selection (use generic function for faces) */
struct GPUBatch *DRW_mesh_batch_cache_get_facedots_with_select_id(struct Mesh *me, uint select_id_offset);
struct GPUBatch *DRW_mesh_batch_cache_get_edges_with_select_id(struct Mesh *me, uint select_id_offset);
struct GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(struct Mesh *me, uint select_id_offset);
/* Object mode Wireframe overlays */
-void DRW_mesh_batch_cache_get_wireframes_face_texbuf(
- struct Mesh *me, struct GPUTexture **verts_data, struct GPUTexture **face_indices, int *tri_count);
+struct GPUBatch *DRW_mesh_batch_cache_get_wireframes_face(struct Mesh *me);
void DRW_mesh_cache_sculpt_coords_ensure(struct Mesh *me);
@@ -212,7 +207,7 @@ struct GPUBatch *DRW_particles_batch_cache_get_hair(
struct GPUBatch *DRW_particles_batch_cache_get_dots(
struct Object *object, struct ParticleSystem *psys);
struct GPUBatch *DRW_particles_batch_cache_get_edit_strands(
- struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit);
+ struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit, bool use_weight);
struct GPUBatch *DRW_particles_batch_cache_get_edit_inner_points(
struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit);
struct GPUBatch *DRW_particles_batch_cache_get_edit_tip_points(
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index f214f722c0b..6f5fb177a64 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -325,10 +325,7 @@ typedef struct CurveBatchCache {
/* Wireframes */
struct {
- GPUVertBuf *elem_vbo;
- GPUTexture *elem_tx;
- GPUTexture *verts_tx;
- uint tri_count;
+ GPUBatch *batch;
} face_wire;
/* 3d text */
@@ -450,10 +447,7 @@ static void curve_batch_cache_clear(Curve *cu)
GPU_BATCH_DISCARD_ARRAY_SAFE(cache->surface.shaded_triangles, cache->surface.mat_len);
GPU_BATCH_DISCARD_SAFE(cache->surface.batch);
- GPU_VERTBUF_DISCARD_SAFE(cache->face_wire.elem_vbo);
- DRW_TEXTURE_FREE_SAFE(cache->face_wire.elem_tx);
- DRW_TEXTURE_FREE_SAFE(cache->face_wire.verts_tx);
- cache->face_wire.tri_count = 0;
+ GPU_BATCH_DISCARD_SAFE(cache->face_wire.batch);
/* don't own vbo & elems */
GPU_BATCH_DISCARD_SAFE(cache->wire.batch);
@@ -801,40 +795,6 @@ static GPUBatch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, C
return cache->surface.batch;
}
-static GPUTexture *curve_batch_cache_get_edges_overlay_texture_buf(CurveRenderData *rdata, CurveBatchCache *cache)
-{
- BLI_assert(rdata->types & CU_DATATYPE_SURFACE);
-
- if (cache->face_wire.elem_tx != NULL) {
- return cache->face_wire.elem_tx;
- }
-
- ListBase *lb = &rdata->ob_curve_cache->disp;
-
- /* We need a special index buffer. */
- GPUVertBuf *vbo = cache->face_wire.elem_vbo = DRW_displist_create_edges_overlay_texture_buf(lb);
-
- /* Upload data early because we need to create the texture for it. */
- GPU_vertbuf_use(vbo);
- cache->face_wire.elem_tx = GPU_texture_create_from_vertbuf(vbo);
- cache->face_wire.tri_count = vbo->vertex_alloc / 3;
-
- return cache->face_wire.elem_tx;
-}
-
-static GPUTexture *curve_batch_cache_get_vert_pos_and_nor_in_order_buf(CurveRenderData *rdata, CurveBatchCache *cache)
-{
- BLI_assert(rdata->types & CU_DATATYPE_SURFACE);
-
- if (cache->face_wire.verts_tx == NULL) {
- curve_batch_cache_get_pos_and_normals(rdata, cache);
- GPU_vertbuf_use(cache->surface.verts); /* Upload early for buffer texture creation. */
- cache->face_wire.verts_tx = GPU_texture_create_buffer(GPU_R32F, cache->surface.verts->vbo_id);
- }
-
- return cache->face_wire.verts_tx;
-}
-
/** \} */
@@ -1074,24 +1034,21 @@ GPUBatch **DRW_curve_batch_cache_get_surface_shaded(
return cache->surface.shaded_triangles;
}
-void DRW_curve_batch_cache_get_wireframes_face_texbuf(
- Curve *cu, CurveCache *ob_curve_cache,
- GPUTexture **verts_data, GPUTexture **face_indices, int *tri_count)
+GPUBatch *DRW_curve_batch_cache_get_wireframes_face(Curve *cu, CurveCache *ob_curve_cache)
{
CurveBatchCache *cache = curve_batch_cache_get(cu);
- if (cache->face_wire.elem_tx == NULL || cache->face_wire.verts_tx == NULL) {
+ if (cache->face_wire.batch == NULL) {
CurveRenderData *rdata = curve_render_data_create(cu, ob_curve_cache, CU_DATATYPE_SURFACE);
- curve_batch_cache_get_edges_overlay_texture_buf(rdata, cache);
- curve_batch_cache_get_vert_pos_and_nor_in_order_buf(rdata, cache);
+ ListBase *lb = &rdata->ob_curve_cache->disp;
+
+ cache->face_wire.batch = DRW_displist_create_edges_overlay_batch(lb);
curve_render_data_free(rdata);
}
- *tri_count = cache->face_wire.tri_count;
- *face_indices = cache->face_wire.elem_tx;
- *verts_data = cache->face_wire.verts_tx;
+ return cache->face_wire.batch;
}
/* -------------------------------------------------------------------- */
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c
index d6a57676a8d..2f9fa73b7e6 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -218,55 +218,89 @@ GPUIndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(Li
}
typedef struct DRWDisplistWireThunk {
- uint index_id, vidx;
- short dl_type;
+ uint wd_id, pos_id, nor_id, vidx, ofs;
+ const DispList *dl;
GPUVertBuf *vbo;
} DRWDisplistWireThunk;
static void set_overlay_wires_tri_indices(void *thunk, uint v1, uint v2, uint v3)
{
DRWDisplistWireThunk *dwt = (DRWDisplistWireThunk *)thunk;
- /* Tag real edges. */
- v1 |= (1 << 30);
- v2 |= (1 << 30);
- v3 |= (1 << 30);
- GPU_vertbuf_attr_set(dwt->vbo, dwt->index_id, dwt->vidx++, &v1);
- GPU_vertbuf_attr_set(dwt->vbo, dwt->index_id, dwt->vidx++, &v2);
- GPU_vertbuf_attr_set(dwt->vbo, dwt->index_id, dwt->vidx++, &v3);
+ const DispList *dl = dwt->dl;
+ uint indices[3] = {v1, v2, v3};
+ const bool ndata_is_single = dl->type == DL_INDEX3;
+
+ for (int i = 0; i < 3; ++i) {
+ uint v = indices[i] - dwt->ofs;
+ /* TODO: Compute sharpness. For now, only tag real egdes. */
+ uchar sharpness = 0xFF;
+ short short_no[3];
+ const float(*verts)[3] = (float(*)[3])dl->verts;
+ const float(*nors)[3] = (float(*)[3])dl->nors;
+ normal_float_to_short_v3(short_no, nors[(ndata_is_single) ? 0 : v]);
+ GPU_vertbuf_attr_set(dwt->vbo, dwt->wd_id, dwt->vidx, &sharpness);
+ GPU_vertbuf_attr_set(dwt->vbo, dwt->pos_id, dwt->vidx, verts[v]);
+ GPU_vertbuf_attr_set(dwt->vbo, dwt->nor_id, dwt->vidx, short_no);
+ dwt->vidx++;
+ }
}
static void set_overlay_wires_quad_tri_indices(void *thunk, uint v1, uint v2, uint v3)
{
DRWDisplistWireThunk *dwt = (DRWDisplistWireThunk *)thunk;
- /* Tag real edges. */
- v2 |= (1 << 30);
- v3 |= (1 << 30);
- GPU_vertbuf_attr_set(dwt->vbo, dwt->index_id, dwt->vidx++, &v1);
- GPU_vertbuf_attr_set(dwt->vbo, dwt->index_id, dwt->vidx++, &v2);
- GPU_vertbuf_attr_set(dwt->vbo, dwt->index_id, dwt->vidx++, &v3);
+ const DispList *dl = dwt->dl;
+ uint indices[3] = {v1, v2, v3};
+ const bool ndata_is_single = dl->type == DL_INDEX3;
+
+ for (int i = 0; i < 3; ++i) {
+ uint v = indices[i] - dwt->ofs;
+ /* TODO: Compute sharpness. For now, only tag real egdes. */
+ uchar sharpness = (i == 0) ? 0x00 : 0xFF;
+ short short_no[3];
+ const float(*verts)[3] = (float(*)[3])dl->verts;
+ const float(*nors)[3] = (float(*)[3])dl->nors;
+ normal_float_to_short_v3(short_no, nors[(ndata_is_single) ? 0 : v]);
+ GPU_vertbuf_attr_set(dwt->vbo, dwt->wd_id, dwt->vidx, &sharpness);
+ GPU_vertbuf_attr_set(dwt->vbo, dwt->pos_id, dwt->vidx, verts[v]);
+ GPU_vertbuf_attr_set(dwt->vbo, dwt->nor_id, dwt->vidx, short_no);
+ dwt->vidx++;
+ }
}
-GPUVertBuf *DRW_displist_create_edges_overlay_texture_buf(ListBase *lb)
+GPUBatch *DRW_displist_create_edges_overlay_batch(ListBase *lb)
{
- GPUVertFormat format = {0};
- uint index_id = GPU_vertformat_attr_add(&format, "index", GPU_COMP_U32, 1, GPU_FETCH_INT);
- GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ static DRWDisplistWireThunk thunk;
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ thunk.wd_id = GPU_vertformat_attr_add(&format, "wd", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ thunk.pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ thunk.nor_id = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ GPU_vertformat_triple_load(&format);
+ }
- GPU_vertbuf_data_alloc(vbo, curve_render_surface_tri_len_get(lb) * 3);
+ thunk.vbo = GPU_vertbuf_create_with_format(&format);
- DRWDisplistWireThunk thunk = {.index_id = index_id, .vbo = vbo, .vidx = 0};
+ int vert_len = curve_render_surface_tri_len_get(lb) * 3;
+ GPU_vertbuf_data_alloc(thunk.vbo, vert_len);
- int ofs = 0;
+ thunk.vidx = 0;
+ thunk.ofs = 0;
for (const DispList *dl = lb->first; dl; dl = dl->next) {
- thunk.dl_type = dl->type;
+ thunk.dl = dl;
+ BKE_displist_normals_add(lb);
+
/* TODO consider non-manifold edges correctly. */
displist_indexbufbuilder_set(set_overlay_wires_tri_indices,
set_overlay_wires_quad_tri_indices,
- &thunk, dl, ofs);
- ofs += dl_vert_len(dl);
+ &thunk, dl, thunk.ofs);
+ thunk.ofs += dl_vert_len(dl);
}
- return vbo;
+ if (thunk.vidx < vert_len) {
+ GPU_vertbuf_data_resize(thunk.vbo, thunk.vidx);
+ }
+
+ return GPU_batch_create_ex(GPU_PRIM_TRIS, thunk.vbo, NULL, GPU_BATCH_OWNS_VBO);
}
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index a24702368de..f3bb7875a2e 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -62,7 +62,6 @@
#include "GPU_batch_presets.h"
#include "GPU_draw.h"
#include "GPU_material.h"
-#include "GPU_texture.h"
#include "DRW_render.h"
@@ -72,6 +71,7 @@
#include "draw_cache_impl.h" /* own include */
+
static void mesh_batch_cache_clear(Mesh *me);
/* ---------------------------------------------------------------------- */
@@ -175,6 +175,8 @@ typedef struct MeshRenderData {
BMEditMesh *edit_bmesh;
struct EditMeshData *edit_data;
+ Mesh *me;
+
MVert *mvert;
const MEdge *medge;
const MLoop *mloop;
@@ -247,6 +249,7 @@ typedef struct MeshRenderData {
GPUPackedNormal *poly_normals_pack;
GPUPackedNormal *vert_normals_pack;
bool *edge_select_bool;
+ bool *edge_visible_bool;
} MeshRenderData;
enum {
@@ -615,6 +618,8 @@ static MeshRenderData *mesh_render_data_create_ex(
}
}
else {
+ rdata->me = me;
+
if (types & (MR_DATATYPE_VERT)) {
rdata->vert_len = me->totvert;
rdata->mvert = CustomData_get_layer(&me->vdata, CD_MVERT);
@@ -967,6 +972,7 @@ static void mesh_render_data_free(MeshRenderData *rdata)
MEM_SAFE_FREE(rdata->vert_normals_pack);
MEM_SAFE_FREE(rdata->vert_weight);
MEM_SAFE_FREE(rdata->edge_select_bool);
+ MEM_SAFE_FREE(rdata->edge_visible_bool);
MEM_SAFE_FREE(rdata->vert_color);
MEM_SAFE_FREE(rdata->mapped.loose_verts);
@@ -1350,6 +1356,66 @@ static void mesh_render_data_ensure_edge_select_bool(MeshRenderData *rdata, bool
}
}
+/** Ensure #MeshRenderData.edge_visible_bool */
+static void mesh_render_data_ensure_edge_visible_bool(MeshRenderData *rdata)
+{
+ bool *edge_visible_bool = rdata->edge_visible_bool;
+ if (edge_visible_bool == NULL) {
+ edge_visible_bool = rdata->edge_visible_bool =
+ MEM_callocN(sizeof(*edge_visible_bool) * rdata->edge_len, __func__);
+
+ /* If original index is available, hide edges within the same original poly. */
+ const int *p_origindex = NULL;
+ int *index_table = NULL;
+
+ if (rdata->me != NULL) {
+ p_origindex = CustomData_get_layer(&rdata->me->pdata, CD_ORIGINDEX);
+ if (p_origindex != NULL) {
+ index_table = MEM_malloc_arrayN(sizeof(int), rdata->edge_len, __func__);
+ memset(index_table, -1, sizeof(int) * rdata->edge_len);
+ }
+ }
+
+ for (int i = 0; i < rdata->poly_len; i++) {
+ const MPoly *poly = &rdata->mpoly[i];
+ int p_orig = p_origindex ? p_origindex[i] : ORIGINDEX_NONE;
+
+ if (!(poly->flag & ME_HIDE)) {
+ for (int j = 0; j < poly->totloop; j++) {
+ const MLoop *loop = &rdata->mloop[poly->loopstart + j];
+
+ if (p_orig != ORIGINDEX_NONE) {
+ /* Boundary edge is visible. */
+ if (index_table[loop->e] == -1) {
+ index_table[loop->e] = p_orig;
+ edge_visible_bool[loop->e] = true;
+ }
+ /* Edge between two faces with the same original is hidden. */
+ else if (index_table[loop->e] == p_orig) {
+ edge_visible_bool[loop->e] = false;
+ }
+ /* Edge between two different original faces is visible. */
+ else {
+ index_table[loop->e] = -2;
+ edge_visible_bool[loop->e] = true;
+ }
+ }
+ else {
+ if (index_table != NULL) {
+ index_table[loop->e] = -2;
+ }
+ edge_visible_bool[loop->e] = true;
+ }
+ }
+ }
+ }
+
+ if (index_table != NULL) {
+ MEM_freeN(index_table);
+ }
+ }
+}
+
/** \} */
/* ---------------------------------------------------------------------- */
@@ -1676,7 +1742,7 @@ static void add_overlay_tri(
static void add_overlay_tri_mapped(
MeshRenderData *rdata, GPUVertBuf *vbo_pos, GPUVertBuf *vbo_nor, GPUVertBuf *vbo_data, GPUIndexBufBuilder *elb,
const uint pos_id, const uint vnor_id, const uint lnor_id, const uint data_id,
- BMFace *efa, const MLoopTri *mlt, const float poly_normal[3], const int base_vert_idx)
+ BMFace *efa, const MLoopTri *mlt, const float poly_normal[3], const float (*loop_normals)[3], const int base_vert_idx)
{
BMEditMesh *embm = rdata->edit_bmesh;
BMesh *bm = embm->bm;
@@ -1721,9 +1787,8 @@ static void add_overlay_tri_mapped(
}
if (vbo_nor) {
- float (*lnors)[3] = rdata->loop_normals;
for (uint i = 0; i < 3; i++) {
- const float *nor = (lnors) ? lnors[mlt->tri[i]] : poly_normal;
+ const float *nor = loop_normals ? loop_normals[mlt->tri[i]] : poly_normal;
GPUPackedNormal lnor = GPU_normal_convert_i10_v3(nor);
GPU_vertbuf_attr_set(vbo_nor, lnor_id, base_vert_idx + i, &lnor);
GPUPackedNormal vnor = GPU_normal_convert_i10_s3(mvert[mloop[mlt->tri[i]].v].no);
@@ -1942,13 +2007,14 @@ typedef struct MeshBatchCache {
GPUIndexBuf *triangles_in_order;
GPUIndexBuf *ledges_in_order;
- GPUTexture *pos_in_order_tx; /* Depending on pos_in_order */
-
GPUBatch *all_verts;
GPUBatch *all_edges;
GPUBatch *all_triangles;
GPUVertBuf *pos_with_normals;
+ GPUVertBuf *pos_with_normals_visible_only;
+ GPUVertBuf *pos_with_normals_edit;
+ GPUVertBuf *pos_with_normals_visible_only_edit;
GPUVertBuf *tri_aligned_uv; /* Active UV layer (mloopuv) */
/**
@@ -1983,9 +2049,8 @@ typedef struct MeshBatchCache {
GPUBatch *edge_detection;
- GPUVertBuf *edges_face_overlay;
- GPUTexture *edges_face_overlay_tx;
- int edges_face_overlay_tri_count; /* Number of tri in edges_face_overlay(_adj)_tx */
+ GPUVertBuf *edges_face_overlay_data;
+ GPUBatch *edges_face_overlay;
/* Maybe have shaded_triangles_data split into pos_nor and uv_tangent
* to minimize data transfer for skinned mesh. */
@@ -2003,7 +2068,6 @@ typedef struct MeshBatchCache {
GPUVertBuf *ed_tri_pos;
GPUVertBuf *ed_tri_nor; /* LoopNor, VertNor */
GPUVertBuf *ed_tri_data;
- GPUTexture *ed_tri_data_tx;
GPUIndexBuf *ed_tri_verts;
GPUVertBuf *ed_ledge_pos;
@@ -2248,8 +2312,6 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode)
GPU_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos);
GPU_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos);
GPU_INDEXBUF_DISCARD_SAFE(cache->ed_tri_verts);
- DRW_TEXTURE_FREE_SAFE(cache->ed_tri_data_tx);
-
GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles);
GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_verts);
GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges);
@@ -2261,6 +2323,10 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode)
GPU_BATCH_DISCARD_SAFE(cache->facedot_with_select_id);
GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id);
GPU_BATCH_DISCARD_SAFE(cache->verts_with_select_id);
+ /* Paint mode selection */
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_paint_edges);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_weight_faces);
+ GPU_BATCH_DISCARD_SAFE(cache->overlay_weight_verts);
/* Because visible UVs depends on edit mode selection, discard everything. */
mesh_batch_cache_discard_uvedit(cache);
break;
@@ -2298,7 +2364,9 @@ static void mesh_batch_cache_clear_selective(Mesh *me, GPUVertBuf *vert)
BLI_assert(vert != NULL);
- if (cache->pos_with_normals == vert) {
+ if (ELEM(vert, cache->pos_with_normals, cache->pos_with_normals_visible_only,
+ cache->pos_with_normals_edit, cache->pos_with_normals_visible_only_edit))
+ {
GPU_BATCH_DISCARD_SAFE(cache->triangles_with_normals);
GPU_BATCH_DISCARD_SAFE(cache->triangles_with_weights);
GPU_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors);
@@ -2339,7 +2407,6 @@ static void mesh_batch_cache_clear(Mesh *me)
GPU_BATCH_DISCARD_SAFE(cache->all_triangles);
GPU_VERTBUF_DISCARD_SAFE(cache->pos_in_order);
- DRW_TEXTURE_FREE_SAFE(cache->pos_in_order_tx);
GPU_INDEXBUF_DISCARD_SAFE(cache->edges_in_order);
GPU_INDEXBUF_DISCARD_SAFE(cache->triangles_in_order);
GPU_INDEXBUF_DISCARD_SAFE(cache->ledges_in_order);
@@ -2360,7 +2427,6 @@ static void mesh_batch_cache_clear(Mesh *me)
GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_verts);
GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges);
GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges_nor);
- DRW_TEXTURE_FREE_SAFE(cache->ed_tri_data_tx);
GPU_BATCH_DISCARD_SAFE(cache->overlay_weight_faces);
GPU_BATCH_DISCARD_SAFE(cache->overlay_weight_verts);
@@ -2371,6 +2437,9 @@ static void mesh_batch_cache_clear(Mesh *me)
GPU_BATCH_DISCARD_SAFE(cache->points_with_normals);
GPU_BATCH_DISCARD_SAFE(cache->ledges_with_normals);
GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals);
+ GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals_visible_only);
+ GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals_edit);
+ GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals_visible_only_edit);
GPU_BATCH_DISCARD_SAFE(cache->triangles_with_weights);
GPU_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors);
GPU_VERTBUF_DISCARD_SAFE(cache->tri_aligned_uv);
@@ -2388,8 +2457,8 @@ static void mesh_batch_cache_clear(Mesh *me)
GPU_INDEXBUF_DISCARD_SAFE(cache->edges_adjacency);
GPU_BATCH_DISCARD_SAFE(cache->edge_detection);
- GPU_VERTBUF_DISCARD_SAFE(cache->edges_face_overlay);
- DRW_TEXTURE_FREE_SAFE(cache->edges_face_overlay_tx);
+ GPU_VERTBUF_DISCARD_SAFE(cache->edges_face_overlay_data);
+ GPU_BATCH_DISCARD_SAFE(cache->edges_face_overlay);
mesh_batch_cache_discard_shaded_tri(cache);
@@ -2656,7 +2725,18 @@ static GPUVertBuf *mesh_batch_cache_get_tri_uv_active(
if (cache->tri_aligned_uv == NULL) {
const MLoopUV *mloopuv = rdata->mloopuv;
- if (mloopuv == NULL) {
+ int layer_offset;
+ BMEditMesh *embm = rdata->edit_bmesh;
+
+ /* edit mode */
+ if (rdata->edit_bmesh) {
+ BMesh *bm = embm->bm;
+ layer_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
+ if (layer_offset == -1) {
+ return NULL;
+ }
+ }
+ else if (mloopuv == NULL) {
return NULL;
}
@@ -2676,14 +2756,8 @@ static GPUVertBuf *mesh_batch_cache_get_tri_uv_active(
int vbo_len_used = 0;
GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
-
- BMEditMesh *embm = rdata->edit_bmesh;
/* get uv's from active UVMap */
if (rdata->edit_bmesh) {
- /* edit mode */
- BMesh *bm = embm->bm;
-
- const int layer_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
for (uint i = 0; i < tri_len; i++) {
const BMLoop **bm_looptri = (const BMLoop **)embm->looptris[i];
if (BM_elem_flag_test(bm_looptri[0]->f, BM_ELEM_HIDDEN)) {
@@ -2711,7 +2785,10 @@ static GPUVertBuf *mesh_batch_cache_get_tri_uv_active(
vbo_len_used = vidx;
- BLI_assert(vbo_len_capacity == vbo_len_used);
+ if (vbo_len_capacity != vbo_len_used) {
+ GPU_vertbuf_data_resize(vbo, vbo_len_used);
+ }
+
UNUSED_VARS_NDEBUG(vbo_len_used);
}
@@ -2730,6 +2807,7 @@ static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex(
if (format.attr_len == 0) {
attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ GPU_vertformat_triple_load(&format);
}
const int tri_len = mesh_render_data_looptri_len_get_maybe_mapped(rdata);
@@ -2922,20 +3000,20 @@ static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex(
return *r_vbo;
}
-static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals(
- MeshRenderData *rdata, MeshBatchCache *cache)
+static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals_edit(
+ MeshRenderData *rdata, MeshBatchCache *cache, bool use_hide)
{
return mesh_batch_cache_get_tri_pos_and_normals_ex(
- rdata, false,
- &cache->pos_with_normals);
+ rdata, use_hide,
+ use_hide ? &cache->pos_with_normals_visible_only_edit : &cache->pos_with_normals_edit);
}
-static GPUVertBuf *mesh_create_tri_pos_and_normals_visible_only(
- MeshRenderData *rdata)
+
+static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals_final(
+ MeshRenderData *rdata, MeshBatchCache *cache, bool use_hide)
{
- GPUVertBuf *vbo_dummy = NULL;
return mesh_batch_cache_get_tri_pos_and_normals_ex(
- rdata, true,
- &vbo_dummy);
+ rdata, use_hide,
+ use_hide ? &cache->pos_with_normals_visible_only : &cache->pos_with_normals);
}
static GPUVertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag(
@@ -3489,14 +3567,22 @@ static GPUVertBuf *mesh_create_tri_select_id(
}
}
else {
+ const int *p_origindex = NULL;
+ if (rdata->me != NULL) {
+ p_origindex = CustomData_get_layer(&rdata->me->pdata, CD_ORIGINDEX);
+ }
+
for (int i = 0; i < tri_len; i++) {
const MLoopTri *mlt = &rdata->mlooptri[i];
const int poly_index = mlt->poly;
if (!(use_hide && (rdata->mpoly[poly_index].flag & ME_HIDE))) {
- int select_id;
- GPU_select_index_get(poly_index + select_id_offset, &select_id);
- for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
- GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id);
+ int orig_index = p_origindex ? p_origindex[poly_index] : poly_index;
+ if (orig_index != ORIGINDEX_NONE) {
+ int select_id;
+ GPU_select_index_get(orig_index + select_id_offset, &select_id);
+ for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
+ GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id);
+ }
}
}
}
@@ -3627,6 +3713,7 @@ static GPUVertFormat *edit_mesh_overlay_data_format(uint *r_data_id)
static uint data_id;
if (format_flag.attr_len == 0) {
data_id = GPU_vertformat_attr_add(&format_flag, "data", GPU_COMP_U8, 4, GPU_FETCH_INT);
+ GPU_vertformat_triple_load(&format_flag);
}
*r_data_id = data_id;
return &format_flag;
@@ -3703,6 +3790,7 @@ static void mesh_batch_cache_create_overlay_tri_buffers(
BKE_mesh_ensure_normals_for_display(me_cage);
}
const float (*polynors)[3] = CustomData_get_layer(&me_cage->pdata, CD_NORMAL);
+ const float (*loopnors)[3] = CustomData_get_layer(&me_cage->ldata, CD_NORMAL);
for (int i = 0; i < tri_len; i++) {
const MLoopTri *mlt = &mlooptri[i];
const int p_orig = rdata->mapped.p_origindex[mlt->poly];
@@ -3712,7 +3800,7 @@ static void mesh_batch_cache_create_overlay_tri_buffers(
add_overlay_tri_mapped(
rdata, vbo_pos, vbo_nor, vbo_data, elbp,
attr_id.pos, attr_id.vnor, attr_id.lnor, attr_id.data,
- efa, mlt, polynors[mlt->poly], vbo_len_used);
+ efa, mlt, polynors[mlt->poly], loopnors, vbo_len_used);
vbo_len_used += 3;
}
}
@@ -3735,10 +3823,6 @@ static void mesh_batch_cache_create_overlay_tri_buffers(
GPU_vertbuf_data_resize(vbo_data, vbo_len_used);
}
}
-
- /* Upload data early because we need to create the texture for it. */
- GPU_vertbuf_use(vbo_data);
- cache->ed_tri_data_tx = GPU_texture_create_from_vertbuf(vbo_data);
}
static void mesh_batch_cache_create_overlay_ledge_buffers(
@@ -4173,11 +4257,14 @@ static GPUIndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata,
}
#undef NO_EDGE
-static EdgeHash *create_looptri_edge_adjacency_hash(MeshRenderData *rdata)
+static EdgeHash *create_looptri_edge_adjacency_hash(MeshRenderData *rdata, EdgeAdjacentVerts **r_adj_data)
{
const int tri_len = mesh_render_data_looptri_len_get(rdata);
/* Create adjacency info in looptri */
EdgeHash *eh = BLI_edgehash_new_ex(__func__, tri_len * 3);
+ /* TODO allocate less memory (based on edge count) */
+ EdgeAdjacentVerts *adj_data = MEM_mallocN(tri_len * 3 * sizeof(EdgeAdjacentVerts), __func__);
+ *r_adj_data = adj_data;
/* Create edges for each pair of triangles sharing an edge. */
for (int i = 0; i < tri_len; i++) {
for (int e = 0; e < 3; e++) {
@@ -4202,7 +4289,7 @@ static EdgeHash *create_looptri_edge_adjacency_hash(MeshRenderData *rdata)
EdgeAdjacentVerts **eav;
bool value_is_init = BLI_edgehash_ensure_p(eh, v1, v2, (void ***)&eav);
if (!value_is_init) {
- *eav = MEM_mallocN(sizeof(**eav), "EdgeAdjacentVerts");
+ *eav = adj_data++;
(*eav)->vert_index[0] = v0;
(*eav)->vert_index[1] = -1;
}
@@ -4219,24 +4306,32 @@ static EdgeHash *create_looptri_edge_adjacency_hash(MeshRenderData *rdata)
return eh;
}
-static GPUVertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRenderData *rdata)
+static GPUVertBuf *mesh_batch_cache_create_edges_wireframe_data(MeshRenderData *rdata, MeshBatchCache *cache)
{
+ if (cache->edges_face_overlay_data != NULL) {
+ return cache->edges_face_overlay_data;
+ }
+
const int tri_len = mesh_render_data_looptri_len_get(rdata);
GPUVertFormat format = {0};
- uint index_id = GPU_vertformat_attr_add(&format, "index", GPU_COMP_U32, 1, GPU_FETCH_INT);
- GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+ uint index_id = GPU_vertformat_attr_add(&format, "wd", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ GPU_vertformat_triple_load(&format);
+
+ GPUVertBuf *vbo = cache->edges_face_overlay_data = GPU_vertbuf_create_with_format(&format);
int vbo_len_capacity = tri_len * 3;
GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
int vidx = 0;
EdgeHash *eh = NULL;
- eh = create_looptri_edge_adjacency_hash(rdata);
+ EdgeAdjacentVerts *adj_data = NULL;
+ eh = create_looptri_edge_adjacency_hash(rdata, &adj_data);
for (int i = 0; i < tri_len; i++) {
- bool edge_is_real[3];
+ uchar vdata[3] = {0, 0, 0};
+ const MVert *mvert = rdata->mvert;
const MEdge *medge = rdata->medge;
const MLoop *mloop = rdata->mloop;
const MLoopTri *mlt = rdata->mlooptri + i;
@@ -4244,74 +4339,70 @@ static GPUVertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRenderD
int j, j_next;
for (j = 2, j_next = 0; j_next < 3; j = j_next++) {
const MEdge *ed = &medge[mloop[mlt->tri[j]].e];
- const uint tri_edge[2] = {mloop[mlt->tri[j]].v, mloop[mlt->tri[j_next]].v};
- const bool is_edge_real = (
- ((ed->v1 == tri_edge[0]) && (ed->v2 == tri_edge[1])) ||
- ((ed->v1 == tri_edge[1]) && (ed->v2 == tri_edge[0])));
- edge_is_real[j] = is_edge_real;
- }
+ const uint tri_edge[2] = {mloop[mlt->tri[j]].v, mloop[mlt->tri[j_next]].v};
- for (int e = 0; e < 3; e++) {
- int v0 = mloop[mlt->tri[e]].v;
- int v1 = mloop[mlt->tri[(e + 1) % 3]].v;
- EdgeAdjacentVerts *eav = BLI_edgehash_lookup(eh, v0, v1);
- uint value = (uint)v0;
- /* Real edge */
- if (edge_is_real[e]) {
- value |= (1 << 30);
- }
- /* Non-manifold edge */
- if (eav->vert_index[1] == -1) {
- value |= (1u << 31);
+ if ((((ed->v1 == tri_edge[0]) && (ed->v2 == tri_edge[1])) ||
+ ((ed->v1 == tri_edge[1]) && (ed->v2 == tri_edge[0]))))
+ {
+ /* Real edge. */
+ /* Temp Workaround. If a mesh has a subdiv mod we should not
+ * compute the edge sharpness. Instead, we just mix both for now. */
+ vdata[j] = ((ed->flag & ME_EDGERENDER) != 0) ? 0xFD : 0xFE;
}
- GPU_vertbuf_attr_set(vbo, index_id, vidx++, &value);
}
- }
- BLI_edgehash_free(eh, MEM_freeN);
+ /* If at least one edge is real. */
+ if (vdata[0] || vdata[1] || vdata[2]) {
+ float fnor[3];
+ normal_tri_v3(fnor,
+ mvert[mloop[mlt->tri[0]].v].co,
+ mvert[mloop[mlt->tri[1]].v].co,
+ mvert[mloop[mlt->tri[2]].v].co);
- int vbo_len_used = vidx;
+ for (int e = 0; e < 3; e++) {
+ /* Non-real edge. */
+ if (vdata[e] == 0) {
+ continue;
+ }
+ int v0 = mloop[mlt->tri[e]].v;
+ int v1 = mloop[mlt->tri[(e + 1) % 3]].v;
+ EdgeAdjacentVerts *eav = BLI_edgehash_lookup(eh, v0, v1);
+ /* If Non Manifold. */
+ if (eav->vert_index[1] == -1) {
+ vdata[e] = 0xFF;
+ }
+ else if (vdata[e] == 0xFD) {
+ int v2 = mloop[mlt->tri[(e + 2) % 3]].v;
+ /* Select the right opposite vertex */
+ v2 = (eav->vert_index[1] == v2) ? eav->vert_index[0] : eav->vert_index[1];
+ float fnor_adj[3];
+ normal_tri_v3(fnor_adj,
+ mvert[v1].co,
+ mvert[v0].co,
+ mvert[v2].co);
+ float fac = dot_v3v3(fnor_adj, fnor);
+ fac = fac * fac * 50.0f - 49.0f;
+ CLAMP(fac, 0.0f, 0.999f);
+ /* Shorten the range to make the non-ME_EDGERENDER fade first.
+ * Add one because 0x0 is no edges. */
+ vdata[e] = (uchar)(0xDF * fac) + 1;
+ if (vdata[e] < 0.999f) {
+ /* TODO construct fast face wire index buffer. */
+ }
+ }
+ }
+ }
- if (vbo_len_capacity != vbo_len_used) {
- GPU_vertbuf_data_resize(vbo, vbo_len_used);
+ for (int e = 0; e < 3; e++) {
+ GPU_vertbuf_attr_set(vbo, index_id, vidx++, &vdata[e]);
+ }
}
+ BLI_edgehash_free(eh, NULL);
+ MEM_freeN(adj_data);
return vbo;
}
-static GPUTexture *mesh_batch_cache_get_edges_overlay_texture_buf(MeshRenderData *rdata, MeshBatchCache *cache)
-{
- BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI));
-
- BLI_assert(rdata->edit_bmesh == NULL); /* Not supported in edit mode */
-
- if (cache->edges_face_overlay_tx != NULL) {
- return cache->edges_face_overlay_tx;
- }
-
- GPUVertBuf *vbo = cache->edges_face_overlay = mesh_batch_cache_create_edges_overlay_texture_buf(rdata);
-
- /* Upload data early because we need to create the texture for it. */
- GPU_vertbuf_use(vbo);
- cache->edges_face_overlay_tx = GPU_texture_create_from_vertbuf(vbo);
- cache->edges_face_overlay_tri_count = vbo->vertex_alloc / 3;
-
- return cache->edges_face_overlay_tx;
-}
-
-static GPUTexture *mesh_batch_cache_get_vert_pos_and_nor_in_order_buf(MeshRenderData *rdata, MeshBatchCache *cache)
-{
- BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI));
-
- if (cache->pos_in_order_tx == NULL) {
- GPUVertBuf *pos_in_order = mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache);
- GPU_vertbuf_use(pos_in_order); /* Upload early for buffer texture creation. */
- cache->pos_in_order_tx = GPU_texture_create_buffer(GPU_R32F, pos_in_order->vbo_id);
- }
-
- return cache->pos_in_order_tx;
-}
-
static GPUIndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI));
@@ -4402,7 +4493,7 @@ static GPUIndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, Mesh
static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
MeshRenderData *rdata, MeshBatchCache *cache,
/* Special case when drawing final evaluated mesh in editmode, so hidden faces are ignored. */
- BMesh *bm_mapped, const int *p_origindex_mapped)
+ BMesh *bm_mapped, const int *p_origindex_mapped, bool use_hide)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_POLY));
@@ -4431,9 +4522,11 @@ static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
}
else if (bm_mapped == NULL) {
for (uint i = 0; i < poly_len; i++) {
- const MPoly *mp = &rdata->mpoly[i]; ;
- const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0;
- mat_tri_len[ma_id] += (mp->totloop - 2);
+ const MPoly *mp = &rdata->mpoly[i];
+ if (!use_hide || !(mp->flag & ME_HIDE)) {
+ const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0;
+ mat_tri_len[ma_id] += (mp->totloop - 2);
+ }
}
}
else {
@@ -4475,11 +4568,16 @@ static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
}
else if (bm_mapped == NULL) {
for (uint i = 0; i < poly_len; i++) {
- const MPoly *mp = &rdata->mpoly[i]; ;
- const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0;
- for (int j = 2; j < mp->totloop; j++) {
- GPU_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2);
- nidx += 3;
+ const MPoly *mp = &rdata->mpoly[i];
+ if (!use_hide || !(mp->flag & ME_HIDE)) {
+ const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0;
+ for (int j = 2; j < mp->totloop; j++) {
+ GPU_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2);
+ nidx += 3;
+ }
+ }
+ else {
+ nidx += 3 * (mp->totloop - 2);
}
}
}
@@ -4515,7 +4613,7 @@ static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
}
static GPUVertBuf *mesh_create_edge_pos_with_sel(
- MeshRenderData *rdata, bool use_wire, bool use_select_bool)
+ MeshRenderData *rdata, bool use_wire, bool use_select_bool, bool use_visible_bool)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP));
BLI_assert(rdata->edit_bmesh == NULL);
@@ -4543,10 +4641,18 @@ static GPUVertBuf *mesh_create_edge_pos_with_sel(
mesh_render_data_ensure_edge_select_bool(rdata, use_wire);
}
bool *edge_select_bool = use_select_bool ? rdata->edge_select_bool : NULL;
+ if (use_visible_bool) {
+ mesh_render_data_ensure_edge_visible_bool(rdata);
+ }
+ bool *edge_visible_bool = use_visible_bool ? rdata->edge_visible_bool : NULL;
for (int i = 0; i < edge_len; i++) {
const MEdge *ed = &rdata->medge[i];
+ if (use_visible_bool && !edge_visible_bool[i]) {
+ continue;
+ }
+
uchar edge_vert_sel;
if (use_select_bool && edge_select_bool[i]) {
edge_vert_sel = true;
@@ -4685,16 +4791,30 @@ GPUBatch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me)
return cache->all_triangles;
}
-GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me, bool use_hide)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
if (cache->triangles_with_normals == NULL) {
const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY;
+
+ /* Hack to show the final result. */
+ const bool use_em_final = (
+ me->edit_btmesh &&
+ me->edit_btmesh->mesh_eval_final &&
+ (me->edit_btmesh->mesh_eval_final->runtime.is_original == false));
+ Mesh me_fake;
+ if (use_em_final) {
+ me_fake = *me->edit_btmesh->mesh_eval_final;
+ me_fake.mat = me->mat;
+ me_fake.totcol = me->totcol;
+ me = &me_fake;
+ }
+
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
cache->triangles_with_normals = GPU_batch_create(
- GPU_PRIM_TRIS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL);
+ GPU_PRIM_TRIS, mesh_batch_cache_get_tri_pos_and_normals_final(rdata, cache, use_hide), NULL);
mesh_render_data_free(rdata);
}
@@ -4741,11 +4861,9 @@ GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(
DRW_mesh_weight_state_copy(&cache->weight_state, wstate);
- GPUVertBuf *vbo_tris = use_hide ?
- mesh_create_tri_pos_and_normals_visible_only(rdata) :
- mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
+ GPUVertBuf *vbo_tris = mesh_batch_cache_get_tri_pos_and_normals_final(rdata, cache, use_hide);
- GPU_batch_vertbuf_add_ex(cache->triangles_with_weights, vbo_tris, use_hide);
+ GPU_batch_vertbuf_add(cache->triangles_with_weights, vbo_tris);
mesh_render_data_free(rdata);
}
@@ -4766,10 +4884,8 @@ GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh *
cache->triangles_with_vert_colors = GPU_batch_create_ex(
GPU_PRIM_TRIS, mesh_create_tri_vert_colors(rdata, use_hide), NULL, GPU_BATCH_OWNS_VBO);
- GPUVertBuf *vbo_tris = use_hide ?
- mesh_create_tri_pos_and_normals_visible_only(rdata) :
- mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
- GPU_batch_vertbuf_add_ex(cache->triangles_with_vert_colors, vbo_tris, use_hide);
+ GPUVertBuf *vbo_tris = mesh_batch_cache_get_tri_pos_and_normals_final(rdata, cache, use_hide);
+ GPU_batch_vertbuf_add(cache->triangles_with_vert_colors, vbo_tris);
mesh_render_data_free(rdata);
}
@@ -4799,10 +4915,8 @@ struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_id(
cache->triangles_with_select_id = GPU_batch_create_ex(
GPU_PRIM_TRIS, mesh_create_tri_select_id(rdata, use_hide, select_id_offset), NULL, GPU_BATCH_OWNS_VBO);
- GPUVertBuf *vbo_tris = use_hide ?
- mesh_create_tri_pos_and_normals_visible_only(rdata) :
- mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
- GPU_batch_vertbuf_add_ex(cache->triangles_with_select_id, vbo_tris, use_hide);
+ GPUVertBuf *vbo_tris = mesh_batch_cache_get_tri_pos_and_normals_edit(rdata, cache, use_hide);
+ GPU_batch_vertbuf_add(cache->triangles_with_select_id, vbo_tris);
mesh_render_data_free(rdata);
}
@@ -4825,12 +4939,10 @@ struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh
rdata->mapped.use = true;
}
- GPUVertBuf *vbo_tris = use_hide ?
- mesh_create_tri_pos_and_normals_visible_only(rdata) :
- mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
+ GPUVertBuf *vbo_tris = mesh_batch_cache_get_tri_pos_and_normals_edit(rdata, cache, use_hide);
- cache->triangles_with_select_mask = GPU_batch_create_ex(
- GPU_PRIM_TRIS, vbo_tris, NULL, use_hide ? GPU_BATCH_OWNS_VBO : 0);
+ cache->triangles_with_select_mask = GPU_batch_create(
+ GPU_PRIM_TRIS, vbo_tris, NULL);
mesh_render_data_free(rdata);
}
@@ -4847,7 +4959,7 @@ GPUBatch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me)
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
cache->points_with_normals = GPU_batch_create(
- GPU_PRIM_POINTS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL);
+ GPU_PRIM_POINTS, mesh_batch_cache_get_tri_pos_and_normals_edit(rdata, cache, false), NULL);
mesh_render_data_free(rdata);
}
@@ -4960,25 +5072,36 @@ GPUBatch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold)
return cache->edge_detection;
}
-void DRW_mesh_batch_cache_get_wireframes_face_texbuf(
- Mesh *me, GPUTexture **verts_data, GPUTexture **face_indices, int *tri_count)
+GPUBatch *DRW_mesh_batch_cache_get_wireframes_face(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
- if (cache->edges_face_overlay_tx == NULL || cache->pos_in_order_tx == NULL) {
- const int options = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI;
+ if (cache->edges_face_overlay == NULL) {
+ const int options = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI | MR_DATATYPE_POLY;
+
+ /* Hack to show the final result. */
+ const bool use_em_final = (
+ me->edit_btmesh &&
+ me->edit_btmesh->mesh_eval_final &&
+ (me->edit_btmesh->mesh_eval_final->runtime.is_original == false));
+ Mesh me_fake;
+ if (use_em_final) {
+ me_fake = *me->edit_btmesh->mesh_eval_final;
+ me_fake.mat = me->mat;
+ me_fake.totcol = me->totcol;
+ me = &me_fake;
+ }
MeshRenderData *rdata = mesh_render_data_create(me, options);
- mesh_batch_cache_get_edges_overlay_texture_buf(rdata, cache);
- mesh_batch_cache_get_vert_pos_and_nor_in_order_buf(rdata, cache);
+ cache->edges_face_overlay = GPU_batch_create(
+ GPU_PRIM_TRIS, mesh_batch_cache_create_edges_wireframe_data(rdata, cache), NULL);
+ GPU_batch_vertbuf_add(cache->edges_face_overlay, mesh_batch_cache_get_tri_pos_and_normals_final(rdata, cache, false));
mesh_render_data_free(rdata);
}
- *tri_count = cache->edges_face_overlay_tri_count;
- *face_indices = cache->edges_face_overlay_tx;
- *verts_data = cache->pos_in_order_tx;
+ return cache->edges_face_overlay;
}
static void mesh_batch_cache_create_overlay_batches(Mesh *me)
@@ -5055,17 +5178,6 @@ GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles(Mesh *me)
return cache->overlay_triangles;
}
-GPUTexture *DRW_mesh_batch_cache_get_overlay_data_tex(Mesh *me)
-{
- MeshBatchCache *cache = mesh_batch_cache_get(me);
-
- if (cache->ed_tri_data_tx == NULL) {
- mesh_batch_cache_create_overlay_batches(me);
- }
-
- return cache->ed_tri_data_tx;
-}
-
GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -5221,7 +5333,7 @@ GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me, uint select_id
}
GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(
- Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
+ Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len, bool use_hide,
char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -5262,9 +5374,9 @@ GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(
GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(
rdata, cache,
- bm_mapped, p_origindex);
+ bm_mapped, p_origindex, use_hide);
- GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
+ GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals_final(rdata, cache, false);
GPUVertBuf *vbo_shading = mesh_batch_cache_get_tri_shading_data(rdata, cache);
for (int i = 0; i < mat_len; i++) {
@@ -5287,7 +5399,7 @@ GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(
return cache->shaded_triangles;
}
-GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me)
+GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me, bool use_hide)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -5295,15 +5407,30 @@ GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me)
/* create batch from DM */
const int datatype =
MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOPUV;
+
+ /* Hack to show the final result. */
+ const bool use_em_final = (
+ me->edit_btmesh &&
+ me->edit_btmesh->mesh_eval_final &&
+ (me->edit_btmesh->mesh_eval_final->runtime.is_original == false));
+ Mesh me_fake;
+ if (use_em_final) {
+ me_fake = *me->edit_btmesh->mesh_eval_final;
+ me_fake.mat = me->mat;
+ me_fake.totcol = me->totcol;
+ me = &me_fake;
+ }
+
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
const int mat_len = mesh_render_data_mat_len_get(rdata);
cache->texpaint_triangles = MEM_callocN(sizeof(*cache->texpaint_triangles) * mat_len, __func__);
- GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache, NULL, NULL);
+ GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache, NULL, NULL, use_hide);
+
+ GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals_final(rdata, cache, false);
- GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
for (int i = 0; i < mat_len; i++) {
cache->texpaint_triangles[i] = GPU_batch_create(
GPU_PRIM_TRIS, vbo, el[i]);
@@ -5328,7 +5455,7 @@ GPUBatch *DRW_mesh_batch_cache_get_surface_texpaint_single(Mesh *me)
MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOPUV;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
- GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
+ GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals_final(rdata, cache, false);
cache->texpaint_triangles_single = GPU_batch_create(
GPU_PRIM_TRIS, vbo, NULL);
@@ -5392,7 +5519,7 @@ GPUBatch *DRW_mesh_batch_cache_get_texpaint_loop_wire(Mesh *me)
return cache->texpaint_uv_loops;
}
-GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bool use_sel)
+GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bool use_sel, bool use_hide)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -5402,7 +5529,7 @@ GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire,
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
cache->overlay_paint_edges = GPU_batch_create_ex(
- GPU_PRIM_LINES, mesh_create_edge_pos_with_sel(rdata, use_wire, use_sel), NULL, GPU_BATCH_OWNS_VBO);
+ GPU_PRIM_LINES, mesh_create_edge_pos_with_sel(rdata, use_wire, use_sel, use_hide), NULL, GPU_BATCH_OWNS_VBO);
mesh_render_data_free(rdata);
}
diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c
index 841cb73d9c7..10f5db42bf1 100644
--- a/source/blender/draw/intern/draw_cache_impl_metaball.c
+++ b/source/blender/draw/intern/draw_cache_impl_metaball.c
@@ -59,10 +59,7 @@ typedef struct MetaBallBatchCache {
/* Wireframe */
struct {
- GPUVertBuf *elem_vbo;
- GPUTexture *elem_tx;
- GPUTexture *verts_tx;
- int tri_count;
+ GPUBatch *batch;
} face_wire;
/* settings to determine if cache is invalid */
@@ -94,10 +91,7 @@ static void metaball_batch_cache_init(MetaBall *mb)
cache->shaded_triangles = NULL;
cache->is_dirty = false;
cache->pos_nor_in_order = NULL;
- cache->face_wire.elem_vbo = NULL;
- cache->face_wire.elem_tx = NULL;
- cache->face_wire.verts_tx = NULL;
- cache->face_wire.tri_count = 0;
+ cache->face_wire.batch = NULL;
}
static MetaBallBatchCache *metaball_batch_cache_get(MetaBall *mb)
@@ -131,10 +125,7 @@ static void metaball_batch_cache_clear(MetaBall *mb)
return;
}
- GPU_VERTBUF_DISCARD_SAFE(cache->face_wire.elem_vbo);
- DRW_TEXTURE_FREE_SAFE(cache->face_wire.elem_tx);
- DRW_TEXTURE_FREE_SAFE(cache->face_wire.verts_tx);
-
+ GPU_BATCH_DISCARD_SAFE(cache->face_wire.batch);
GPU_BATCH_DISCARD_SAFE(cache->batch);
GPU_VERTBUF_DISCARD_SAFE(cache->pos_nor_in_order);
/* Note: shaded_triangles[0] is already freed by cache->batch */
@@ -157,36 +148,6 @@ static GPUVertBuf *mball_batch_cache_get_pos_and_normals(Object *ob, MetaBallBat
return cache->pos_nor_in_order;
}
-static GPUTexture *mball_batch_cache_get_edges_overlay_texture_buf(Object *ob, MetaBallBatchCache *cache)
-{
- if (cache->face_wire.elem_tx != NULL) {
- return cache->face_wire.elem_tx;
- }
-
- ListBase *lb = &ob->runtime.curve_cache->disp;
-
- /* We need a special index buffer. */
- GPUVertBuf *vbo = cache->face_wire.elem_vbo = DRW_displist_create_edges_overlay_texture_buf(lb);
-
- /* Upload data early because we need to create the texture for it. */
- GPU_vertbuf_use(vbo);
- cache->face_wire.elem_tx = GPU_texture_create_from_vertbuf(vbo);
- cache->face_wire.tri_count = vbo->vertex_alloc / 3;
-
- return cache->face_wire.elem_tx;
-}
-
-static GPUTexture *mball_batch_cache_get_vert_pos_and_nor_in_order_buf(Object *ob, MetaBallBatchCache *cache)
-{
- if (cache->face_wire.verts_tx == NULL) {
- GPUVertBuf *vbo = mball_batch_cache_get_pos_and_normals(ob, cache);
- GPU_vertbuf_use(vbo); /* Upload early for buffer texture creation. */
- cache->face_wire.verts_tx = GPU_texture_create_buffer(GPU_R32F, vbo->vbo_id);
- }
-
- return cache->face_wire.verts_tx;
-}
-
/* -------------------------------------------------------------------- */
/** \name Public Object/MetaBall API
@@ -232,26 +193,19 @@ GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(Object *ob, MetaBall *mb,
}
-void DRW_metaball_batch_cache_get_wireframes_face_texbuf(
- Object *ob, struct GPUTexture **verts_data, struct GPUTexture **face_indices, int *tri_count)
+GPUBatch *DRW_metaball_batch_cache_get_wireframes_face(Object *ob)
{
if (!BKE_mball_is_basis(ob)) {
- *verts_data = NULL;
- *face_indices = NULL;
- *tri_count = 0;
- return;
+ return NULL;
}
MetaBall *mb = ob->data;
MetaBallBatchCache *cache = metaball_batch_cache_get(mb);
- if (cache->face_wire.verts_tx == NULL) {
- *verts_data = mball_batch_cache_get_vert_pos_and_nor_in_order_buf(ob, cache);
- *face_indices = mball_batch_cache_get_edges_overlay_texture_buf(ob, cache);
- }
- else {
- *verts_data = cache->face_wire.verts_tx;
- *face_indices = cache->face_wire.elem_tx;
+ if (cache->face_wire.batch == NULL) {
+ ListBase *lb = &ob->runtime.curve_cache->disp;
+ cache->face_wire.batch = DRW_displist_create_edges_overlay_batch(lb);
}
- *tri_count = cache->face_wire.tri_count;
+
+ return cache->face_wire.batch;
}
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 263aaa1ffdf..d83f8fb660b 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -80,6 +80,9 @@ typedef struct ParticleBatchCache {
/* Control points when in edit mode. */
ParticleHairCache edit_hair;
+ GPUVertBuf *edit_pos;
+ GPUBatch *edit_strands;
+
GPUVertBuf *edit_inner_pos;
GPUBatch *edit_inner_points;
int edit_inner_point_len;
@@ -90,6 +93,7 @@ typedef struct ParticleBatchCache {
/* Settings to determine if cache is invalid. */
bool is_dirty;
+ bool edit_is_weight;
} ParticleBatchCache;
/* GPUBatch cache management. */
@@ -100,6 +104,25 @@ typedef struct HairAttributeID {
uint ind;
} HairAttributeID;
+typedef struct EditStrandData {
+ float pos[3];
+ uchar color;
+} EditStrandData;
+
+static GPUVertFormat *edit_points_vert_format_get(uint *r_pos_id, uint *r_color_id)
+{
+ static GPUVertFormat edit_point_format = { 0 };
+ static uint pos_id, color_id;
+ if (edit_point_format.attr_len == 0) {
+ /* Keep in sync with EditStrandData */
+ pos_id = GPU_vertformat_attr_add(&edit_point_format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ color_id = GPU_vertformat_attr_add(&edit_point_format, "color", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ }
+ *r_pos_id = pos_id;
+ *r_color_id = color_id;
+ return &edit_point_format;
+}
+
static bool particle_batch_cache_valid(ParticleSystem *psys)
{
ParticleBatchCache *cache = psys->batch_cache;
@@ -653,6 +676,78 @@ static void particle_batch_cache_fill_segments_proc_pos(
}
}
+static float particle_key_select_ratio(const PTCacheEdit *edit, int strand, float t)
+{
+ const PTCacheEditPoint *point = &edit->points[strand];
+ float edit_key_seg_t = 1.0f / (point->totkey - 1);
+ if (t == 1.0) {
+ return (point->keys[point->totkey - 1].flag & PEK_SELECT) ? 1.0f : 0.0;
+ }
+ else {
+ float interp = t / edit_key_seg_t;
+ int index = (int)interp;
+ interp -= floorf(interp); /* Time between 2 edit key */
+ float s1 = (point->keys[index].flag & PEK_SELECT) ? 1.0f : 0.0;
+ float s2 = (point->keys[index + 1].flag & PEK_SELECT) ? 1.0f : 0.0;
+ return s1 + interp * (s2 - s1);
+ }
+}
+
+static float particle_key_weight(const ParticleData *particle, int strand, float t)
+{
+ const ParticleData *part = particle + strand;
+ const HairKey *hkeys = part->hair;
+ float edit_key_seg_t = 1.0f / (part->totkey - 1);
+ if (t == 1.0) {
+ return hkeys[part->totkey - 1].weight;
+ }
+ else {
+ float interp = t / edit_key_seg_t;
+ int index = (int)interp;
+ interp -= floorf(interp); /* Time between 2 edit key */
+ float s1 = hkeys[index].weight;
+ float s2 = hkeys[index + 1].weight;
+ return s1 + interp * (s2 - s1);
+ }
+}
+
+static int particle_batch_cache_fill_segments_edit(
+ const PTCacheEdit *edit, /* NULL for weight data */
+ const ParticleData *particle, /* NULL for select data */
+ ParticleCacheKey **path_cache,
+ const int start_index,
+ const int num_path_keys,
+ GPUIndexBufBuilder *elb,
+ GPUVertBufRaw *attr_step)
+{
+ int curr_point = start_index;
+ for (int i = 0; i < num_path_keys; i++) {
+ ParticleCacheKey *path = path_cache[i];
+ if (path->segments <= 0) {
+ continue;
+ }
+ for (int j = 0; j <= path->segments; j++) {
+ EditStrandData *seg_data = (EditStrandData *)GPU_vertbuf_raw_step(attr_step);
+ copy_v3_v3(seg_data->pos, path[j].co);
+ float strand_t = (float)(j) / path->segments;
+ if (particle) {
+ float weight = particle_key_weight(particle, i, strand_t);
+ /* NaN or unclamped become 0xFF */
+ seg_data->color = (uchar)((weight <= 1.0f) ? 0xFE * weight : 0xFF);
+ }
+ else {
+ float selected = particle_key_select_ratio(edit, i, strand_t);
+ seg_data->color = (uchar)(0xFF * selected);
+ }
+ GPU_indexbuf_add_generic_vert(elb, curr_point);
+ curr_point++;
+ }
+ /* Finish the segment and add restart primitive. */
+ GPU_indexbuf_add_primitive_restart(elb);
+ }
+ return curr_point;
+}
+
static int particle_batch_cache_fill_segments_indices(
ParticleCacheKey **path_cache,
const int start_index,
@@ -1366,22 +1461,71 @@ GPUBatch *DRW_particles_batch_cache_get_dots(Object *object, ParticleSystem *psy
return cache->point.points;
}
+static void particle_batch_cache_ensure_edit_pos_and_seg(
+ PTCacheEdit *edit,
+ ParticleSystem *psys,
+ ModifierData *UNUSED(md),
+ ParticleHairCache *hair_cache,
+ bool use_weight)
+{
+ if (hair_cache->pos != NULL && hair_cache->indices != NULL) {
+ return;
+ }
+
+ ParticleData *particle = (use_weight) ? psys->particles : NULL;
+
+ GPU_VERTBUF_DISCARD_SAFE(hair_cache->pos);
+ GPU_INDEXBUF_DISCARD_SAFE(hair_cache->indices);
+
+ GPUVertBufRaw data_step;
+ GPUIndexBufBuilder elb;
+ uint pos_id, color_id;
+ GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &color_id);
+
+ hair_cache->pos = GPU_vertbuf_create_with_format(edit_point_format);
+ GPU_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_len);
+ GPU_vertbuf_attr_get_raw_data(hair_cache->pos, pos_id, &data_step);
+
+ GPU_indexbuf_init_ex(
+ &elb,
+ GPU_PRIM_LINE_STRIP,
+ hair_cache->elems_len, hair_cache->point_len,
+ true);
+
+ if (edit != NULL && edit->pathcache != NULL) {
+ particle_batch_cache_fill_segments_edit(
+ edit, particle, edit->pathcache,
+ 0, edit->totcached,
+ &elb, &data_step);
+ }
+ else {
+ BLI_assert(!"Hairs are not in edit mode!");
+ }
+ hair_cache->indices = GPU_indexbuf_build(&elb);
+}
+
GPUBatch *DRW_particles_batch_cache_get_edit_strands(
Object *object,
ParticleSystem *psys,
- PTCacheEdit *edit)
+ PTCacheEdit *edit,
+ bool use_weight)
{
ParticleBatchCache *cache = particle_batch_cache_get(psys);
+ if (cache->edit_is_weight != use_weight) {
+ GPU_VERTBUF_DISCARD_SAFE(cache->edit_hair.pos);
+ GPU_BATCH_DISCARD_SAFE(cache->edit_hair.hairs);
+ }
if (cache->edit_hair.hairs != NULL) {
return cache->edit_hair.hairs;
}
drw_particle_update_ptcache_edit(object, psys, edit);
ensure_seg_pt_count(edit, psys, &cache->edit_hair);
- particle_batch_cache_ensure_pos_and_seg(edit, psys, NULL, &cache->edit_hair);
+ particle_batch_cache_ensure_edit_pos_and_seg(edit, psys, NULL, &cache->edit_hair, use_weight);
cache->edit_hair.hairs = GPU_batch_create(
GPU_PRIM_LINE_STRIP,
cache->edit_hair.pos,
cache->edit_hair.indices);
+ cache->edit_is_weight = use_weight;
return cache->edit_hair.hairs;
}
@@ -1400,17 +1544,6 @@ static void ensure_edit_inner_points_count(
}
}
-static void edit_colors_get(
- PTCacheEdit *edit,
- float selected_color[4],
- float normal_color[4])
-{
- rgb_uchar_to_float(selected_color, edit->sel_col);
- rgb_uchar_to_float(normal_color, edit->nosel_col);
- selected_color[3] = 1.0f;
- normal_color[3] = 1.0f;
-}
-
static void particle_batch_cache_ensure_edit_inner_pos(
PTCacheEdit *edit,
ParticleBatchCache *cache)
@@ -1419,35 +1552,20 @@ static void particle_batch_cache_ensure_edit_inner_pos(
return;
}
- static GPUVertFormat format = { 0 };
- static uint pos_id, color_id;
+ uint pos_id, color_id;
+ GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &color_id);
- GPU_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos);
-
- if (format.attr_len == 0) {
- /* initialize vertex format */
- pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- color_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
- }
-
- cache->edit_inner_pos = GPU_vertbuf_create_with_format(&format);
+ cache->edit_inner_pos = GPU_vertbuf_create_with_format(edit_point_format);
GPU_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_len);
- float selected_color[4], normal_color[4];
- edit_colors_get(edit, selected_color, normal_color);
-
int global_key_index = 0;
for (int point_index = 0; point_index < edit->totpoint; point_index++) {
const PTCacheEditPoint *point = &edit->points[point_index];
for (int key_index = 0; key_index < point->totkey - 1; key_index++) {
PTCacheEditKey *key = &point->keys[key_index];
+ uchar color = (key->flag & PEK_SELECT) ? 0xFF : 0x00;
GPU_vertbuf_attr_set(cache->edit_inner_pos, pos_id, global_key_index, key->world_co);
- if (key->flag & PEK_SELECT) {
- GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, selected_color);
- }
- else {
- GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, normal_color);
- }
+ GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, &color);
global_key_index++;
}
}
@@ -1490,33 +1608,18 @@ static void particle_batch_cache_ensure_edit_tip_pos(
return;
}
- static GPUVertFormat format = { 0 };
- static uint pos_id, color_id;
-
- GPU_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos);
+ uint pos_id, color_id;
+ GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &color_id);
- if (format.attr_len == 0) {
- /* initialize vertex format */
- pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- color_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
- }
-
- cache->edit_tip_pos = GPU_vertbuf_create_with_format(&format);
+ cache->edit_tip_pos = GPU_vertbuf_create_with_format(edit_point_format);
GPU_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_len);
- float selected_color[4], normal_color[4];
- edit_colors_get(edit, selected_color, normal_color);
-
for (int point_index = 0; point_index < edit->totpoint; point_index++) {
const PTCacheEditPoint *point = &edit->points[point_index];
PTCacheEditKey *key = &point->keys[point->totkey - 1];
+ uchar color = (key->flag & PEK_SELECT) ? 0xFF : 0x00;
GPU_vertbuf_attr_set(cache->edit_tip_pos, pos_id, point_index, key->world_co);
- if (key->flag & PEK_SELECT) {
- GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, selected_color);
- }
- else {
- GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, normal_color);
- }
+ GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, &color);
}
}
@@ -1582,6 +1685,5 @@ bool particles_ensure_procedural_data(
particle_batch_cache_ensure_procedural_indices(source.edit, source.psys, &cache->hair, thickness_res, subdiv);
}
-
return need_ft_update;
}
diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c
index ebdb4c72d09..f6891563dbb 100644
--- a/source/blender/draw/intern/draw_hair.c
+++ b/source/blender/draw/intern/draw_hair.c
@@ -40,6 +40,7 @@
#include "DNA_particle_types.h"
#include "DNA_customdata_types.h"
+#include "BKE_anim.h"
#include "BKE_mesh.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
@@ -85,6 +86,12 @@ void DRW_hair_init(void)
g_tf_pass = DRW_pass_create("Update Hair Pass", DRW_STATE_TRANS_FEEDBACK);
}
+typedef struct DRWHairInstanceData {
+ DrawData dd;
+
+ float mat[4][4];
+} DRWHairInstanceData;
+
static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(
Object *object, ParticleSystem *psys, ModifierData *md,
DRWPass *hair_pass,
@@ -93,6 +100,15 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(
/* TODO(fclem): Pass the scene as parameter */
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
+ static float unit_mat[4][4] = {
+ {1, 0, 0, 0},
+ {0, 1, 0, 0},
+ {0, 0, 1, 0},
+ {0, 0, 0, 1},
+ };
+ float (*dupli_mat)[4];
+ Object *dupli_parent = DRW_object_get_dupli_parent(object);
+ DupliObject *dupli_object = DRW_object_get_dupli(object);
int subdiv = scene->r.hair_subdiv;
int thickness_res = (scene->r.hair_type == SCE_HAIR_SHAPE_STRAND) ? 1 : 2;
@@ -125,10 +141,29 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(
}
}
+ if (dupli_parent) {
+ DRWHairInstanceData *hair_inst_data = (DRWHairInstanceData *)DRW_drawdata_ensure(
+ &object->id, (DrawEngineType *)&drw_shgroup_create_hair_procedural_ex,
+ sizeof(DRWHairInstanceData), NULL, NULL);
+ dupli_mat = hair_inst_data->mat;
+ if (dupli_object->type & OB_DUPLICOLLECTION) {
+ copy_m4_m4(dupli_mat, dupli_parent->obmat);
+ }
+ else {
+ copy_m4_m4(dupli_mat, dupli_object->ob->obmat);
+ invert_m4(dupli_mat);
+ mul_m4_m4m4(dupli_mat, object->obmat, dupli_mat);
+ }
+ }
+ else {
+ dupli_mat = unit_mat;
+ }
+
DRW_shgroup_uniform_texture(shgrp, "hairPointBuffer", hair_cache->final[subdiv].proc_tex);
DRW_shgroup_uniform_int(shgrp, "hairStrandsRes", &hair_cache->final[subdiv].strands_res, 1);
DRW_shgroup_uniform_int_copy(shgrp, "hairThicknessRes", thickness_res);
DRW_shgroup_uniform_float(shgrp, "hairRadShape", &part->shape, 1);
+ DRW_shgroup_uniform_mat4(shgrp, "hairDupliMatrix", dupli_mat);
DRW_shgroup_uniform_float_copy(shgrp, "hairRadRoot", part->rad_root * part->rad_scale * 0.5f);
DRW_shgroup_uniform_float_copy(shgrp, "hairRadTip", part->rad_tip * part->rad_scale * 0.5f);
DRW_shgroup_uniform_bool_copy(shgrp, "hairCloseTip", (part->shape_flag & PART_SHAPE_CLOSE_TIP) != 0);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 4266e232bb9..d6e92e60576 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -33,6 +33,7 @@
#include "BLF_api.h"
+#include "BKE_colortools.h"
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
@@ -190,6 +191,24 @@ bool DRW_object_is_flat_normal(const Object *ob)
return true;
}
+bool DRW_object_use_hide_faces(const struct Object *ob)
+{
+ if (ob->type == OB_MESH) {
+ const Mesh *me = DEG_get_original_object((Object *)ob)->data;
+
+ switch (ob->mode) {
+ case OB_MODE_TEXTURE_PAINT:
+ case OB_MODE_VERTEX_PAINT:
+ return (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+
+ case OB_MODE_WEIGHT_PAINT:
+ return (me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) != 0;
+ }
+ }
+
+ return false;
+}
+
bool DRW_object_is_visible_psys_in_active_context(
const Object *object,
const ParticleSystem *psys)
@@ -217,6 +236,16 @@ bool DRW_object_is_visible_psys_in_active_context(
return true;
}
+struct Object *DRW_object_get_dupli_parent(const Object *UNUSED(ob))
+{
+ return DST.dupli_parent;
+}
+
+struct DupliObject *DRW_object_get_dupli(const Object *UNUSED(ob))
+{
+ return DST.dupli_source;
+}
+
/** \} */
@@ -242,10 +271,19 @@ void DRW_transform_to_display(GPUTexture *tex, bool use_view_settings)
if (!(DST.options.is_image_render && !DST.options.is_scene_render)) {
Scene *scene = DST.draw_ctx.scene;
ColorManagedDisplaySettings *display_settings = &scene->display_settings;
- ColorManagedViewSettings *view_settings = (use_view_settings) ? &scene->view_settings : NULL;
-
+ ColorManagedViewSettings *active_view_settings;
+ ColorManagedViewSettings default_view_settings;
+ if (use_view_settings) {
+ active_view_settings = &scene->view_settings;
+ }
+ else {
+ BKE_color_managed_view_settings_init_render(
+ &default_view_settings,
+ display_settings);
+ active_view_settings = &default_view_settings;
+ }
use_ocio = IMB_colormanagement_setup_glsl_draw_from_space(
- view_settings, display_settings, NULL, dither, false);
+ active_view_settings, display_settings, NULL, dither, false);
}
if (!use_ocio) {
@@ -1425,13 +1463,23 @@ void DRW_draw_render_loop_ex(
drw_engines_world_update(scene);
const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
- DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
+ DEG_OBJECT_ITER_BEGIN(depsgraph, ob,
+ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
+ DEG_ITER_OBJECT_FLAG_VISIBLE |
+ DEG_ITER_OBJECT_FLAG_DUPLI)
{
- if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
- drw_engines_cache_populate(ob);
+ if ((object_type_exclude_viewport & (1 << ob->type)) != 0) {
+ continue;
+ }
+ if (v3d->localvd && ((v3d->local_view_uuid & ob->base_local_view_bits) == 0)) {
+ continue;
}
+ DST.dupli_parent = data_.dupli_parent;
+ DST.dupli_source = data_.dupli_object_current;
+ drw_engines_cache_populate(ob);
}
- DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
+ DEG_OBJECT_ITER_END;
drw_engines_cache_finish();
@@ -1479,6 +1527,11 @@ void DRW_draw_render_loop_ex(
drw_engines_draw_scene();
+#ifdef __APPLE__
+ /* Fix 3D view being "laggy" on macos. (See T56996) */
+ GPU_flush();
+#endif
+
/* annotations - temporary drawing buffer (3d space) */
/* XXX: Or should we use a proper draw/overlay engine for this case? */
if (do_annotations) {
@@ -1852,14 +1905,20 @@ void DRW_render_object_iter(
DRW_hair_init();
const int object_type_exclude_viewport = draw_ctx->v3d ? draw_ctx->v3d->object_type_exclude_viewport : 0;
- DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
+ DEG_OBJECT_ITER_BEGIN(depsgraph, ob,
+ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
+ DEG_ITER_OBJECT_FLAG_VISIBLE |
+ DEG_ITER_OBJECT_FLAG_DUPLI)
{
if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
+ DST.dupli_parent = data_.dupli_parent;
+ DST.dupli_source = data_.dupli_object_current;
DST.ob_state = NULL;
callback(vedata, ob, engine, depsgraph);
}
}
- DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END
+ DEG_OBJECT_ITER_END
}
/* Assume a valid gl context is bound (and that the gl_context_mutex has been acquired).
@@ -2046,7 +2105,7 @@ void DRW_draw_select_loop(
#if 0
drw_engines_cache_populate(obact);
#else
- FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, obact->mode, ob_iter) {
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, obact->type, obact->mode, ob_iter) {
drw_engines_cache_populate(ob_iter);
}
FOREACH_OBJECT_IN_MODE_END;
@@ -2057,12 +2116,16 @@ void DRW_draw_select_loop(
v3d->object_type_exclude_viewport | v3d->object_type_exclude_select
);
bool filter_exclude = false;
- DEG_OBJECT_ITER_BEGIN(
- depsgraph, ob,
+ DEG_OBJECT_ITER_BEGIN(depsgraph, ob,
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
DEG_ITER_OBJECT_FLAG_VISIBLE |
DEG_ITER_OBJECT_FLAG_DUPLI)
{
+ if (v3d->localvd && ((v3d->local_view_uuid & ob->base_local_view_bits) == 0)) {
+ continue;
+ }
+
if ((ob->base_flag & BASE_SELECTABLE) &&
(object_type_exclude_select & (1 << ob->type)) == 0)
{
@@ -2083,6 +2146,8 @@ void DRW_draw_select_loop(
Object *ob_orig = DEG_get_original_object(ob);
DRW_select_load_id(ob_orig->select_color);
}
+ DST.dupli_parent = data_.dupli_parent;
+ DST.dupli_source = data_.dupli_object_current;
drw_engines_cache_populate(ob);
}
}
@@ -2238,13 +2303,25 @@ void DRW_draw_depth_loop(
drw_engines_world_update(scene);
const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
- DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
+ DEG_OBJECT_ITER_BEGIN(depsgraph, ob,
+ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
+ DEG_ITER_OBJECT_FLAG_VISIBLE |
+ DEG_ITER_OBJECT_FLAG_DUPLI)
{
- if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
- drw_engines_cache_populate(ob);
+ if ((object_type_exclude_viewport & (1 << ob->type)) != 0) {
+ continue;
}
+
+ if (v3d->localvd && ((v3d->local_view_uuid & ob->base_local_view_bits) == 0)) {
+ continue;
+ }
+
+ DST.dupli_parent = data_.dupli_parent;
+ DST.dupli_source = data_.dupli_object_current;
+ drw_engines_cache_populate(ob);
}
- DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
+ DEG_OBJECT_ITER_END;
drw_engines_cache_finish();
@@ -2355,6 +2432,16 @@ bool DRW_state_is_opengl_render(void)
return DST.options.is_image_render && !DST.options.is_scene_render;
}
+bool DRW_state_is_playback(void)
+{
+ if (DST.draw_ctx.evil_C != NULL) {
+ struct wmWindowManager *wm = CTX_wm_manager(DST.draw_ctx.evil_C);
+ return ED_screen_animation_playing(wm) != NULL;
+ }
+ return false;
+}
+
+
/**
* Should text draw in this mode?
*/
@@ -2423,7 +2510,7 @@ void DRW_engine_register(DrawEngineType *draw_engine_type)
void DRW_engines_register(void)
{
RE_engines_register(&DRW_engine_viewport_eevee_type);
- RE_engines_register(&DRW_engine_viewport_opengl_type);
+ RE_engines_register(&DRW_engine_viewport_workbench_type);
DRW_engine_register(&draw_engine_workbench_solid);
DRW_engine_register(&draw_engine_workbench_transparent);
@@ -2594,7 +2681,7 @@ void DRW_opengl_context_disable_ex(bool restore)
#ifdef __APPLE__
/* Need to flush before disabling draw context, otherwise it does not
* always finish drawing and viewport can be empty or partially drawn */
- glFlush();
+ GPU_flush();
#endif
if (BLI_thread_is_main() && restore) {
@@ -2631,7 +2718,7 @@ void DRW_opengl_render_context_enable(void *re_gl_context)
void DRW_opengl_render_context_disable(void *re_gl_context)
{
- glFlush();
+ GPU_flush();
WM_opengl_context_release(re_gl_context);
/* TODO get rid of the blocking. */
BLI_ticket_mutex_unlock(DST.gl_context_mutex);
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index c8a7816c402..07a8f5647a7 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -319,6 +319,8 @@ typedef struct DRWManager {
/* State of the object being evaluated if already allocated. */
DRWCallState *ob_state;
uchar state_cache_id; /* Could be larger but 254 view changes is already a lot! */
+ struct DupliObject *dupli_source;
+ struct Object *dupli_parent;
/* Rendering state */
GPUShader *shader;
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index e9d874bd1ee..5863eb57745 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -122,8 +122,8 @@ static void drw_shgroup_uniform(DRWShadingGroup *shgroup, const char *name,
}
if (location == -1) {
- if (G.debug & G_DEBUG)
- fprintf(stderr, "Pass : %s, Uniform '%s' not found!\n", shgroup->pass_parent->name, name);
+ if (G.debug & G_DEBUG_GPU)
+ fprintf(stderr, "Warning: Pass : %s, Uniform '%s' not found!\n", shgroup->pass_parent->name, name);
/* Nice to enable eventually, for now eevee uses uniforms that might not exist. */
// BLI_assert(0);
return;
@@ -1040,7 +1040,7 @@ DRWShadingGroup *DRW_shgroup_create_sub(DRWShadingGroup *shgroup)
DRWShadingGroup *shgroup_new = BLI_mempool_alloc(DST.vmempool->shgroups);
*shgroup_new = *shgroup;
- shgroup_new->uniforms = NULL; /* Not sure about that.. Should we copy them instead? */
+ shgroup_new->uniforms = NULL;
shgroup_new->calls.first = NULL;
shgroup_new->calls.last = NULL;
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 2d56c7e0cfe..65f3f38c0f1 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -356,6 +356,19 @@ void drw_state_set(DRWState state)
}
}
+ /* Provoking Vertex */
+ {
+ int test;
+ if ((test = CHANGED_TO(DRW_STATE_FIRST_VERTEX_CONVENTION))) {
+ if (test == 1) {
+ glProvokingVertex(GL_FIRST_VERTEX_CONVENTION);
+ }
+ else {
+ glProvokingVertex(GL_LAST_VERTEX_CONVENTION);
+ }
+ }
+ }
+
#undef CHANGED_TO
#undef CHANGED_ANY
#undef CHANGED_ANY_STORE_VAR
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index bb580695865..e8d693aa7c0 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -47,6 +47,7 @@
extern char datatoc_gpu_shader_2D_vert_glsl[];
extern char datatoc_gpu_shader_3D_vert_glsl[];
+extern char datatoc_gpu_shader_depth_only_frag_glsl[];
extern char datatoc_common_fullscreen_vert_glsl[];
#define USE_DEFERRED_COMPILATION 1
@@ -131,7 +132,7 @@ static void drw_deferred_shader_compilation_exec(void *custom_data, short *stop,
*progress = (float)comp->shaders_done / (float)total;
*do_update = true;
- glFlush();
+ GPU_flush();
BLI_mutex_unlock(&comp->compilation_lock);
BLI_spin_lock(&comp->list_lock);
@@ -295,7 +296,9 @@ GPUShader *DRW_shader_create_with_transform_feedback(
const char *vert, const char *geom, const char *defines,
const GPUShaderTFBType prim_type, const char **varying_names, const int varying_count)
{
- return GPU_shader_create_ex(vert, NULL, geom, NULL, defines,
+ return GPU_shader_create_ex(vert,
+ datatoc_gpu_shader_depth_only_frag_glsl,
+ geom, NULL, defines,
prim_type, varying_names, varying_count, __func__);
}
diff --git a/source/blender/draw/intern/draw_manager_texture.c b/source/blender/draw/intern/draw_manager_texture.c
index 607b5e19745..be6e66c339f 100644
--- a/source/blender/draw/intern/draw_manager_texture.c
+++ b/source/blender/draw/intern/draw_manager_texture.c
@@ -33,9 +33,12 @@ static bool drw_texture_format_supports_framebuffer(GPUTextureFormat format)
switch (format) {
/* Only add formats that are COMPATIBLE with FB.
* Generally they are multiple of 16bit. */
+ case GPU_R8:
+ case GPU_R8UI:
case GPU_R16F:
case GPU_R16I:
case GPU_R16UI:
+ case GPU_R16:
case GPU_R32F:
case GPU_R32UI:
case GPU_RG8:
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 70049a5c345..8867c85ac2f 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -165,7 +165,6 @@ static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, Vie
void DRW_draw_cursor(void)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
- View3D *v3d = draw_ctx->v3d;
ARegion *ar = draw_ctx->ar;
Scene *scene = draw_ctx->scene;
ViewLayer *view_layer = draw_ctx->view_layer;
@@ -176,7 +175,7 @@ void DRW_draw_cursor(void)
if (is_cursor_visible(draw_ctx, scene, view_layer)) {
int co[2];
- const View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
+ const View3DCursor *cursor = &scene->cursor;
if (ED_view3d_project_int_global(
ar, cursor->location, co, V3D_PROJ_TEST_NOP | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
{
diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c
index e5fd199b69a..3d716d77405 100644
--- a/source/blender/draw/modes/edit_curve_mode.c
+++ b/source/blender/draw/modes/edit_curve_mode.c
@@ -169,7 +169,6 @@ static void EDIT_CURVE_cache_init(void *vedata)
grp = DRW_shgroup_create(e_data.overlay_vert_sh, psl->overlay_vert_pass);
DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo);
- DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
stl->g_data->overlay_vert_shgrp = grp;
}
}
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index fabff950c60..7245d9bafab 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -59,7 +59,6 @@ extern char datatoc_edit_mesh_overlay_geom_edge_glsl[];
extern char datatoc_edit_mesh_overlay_points_vert_glsl[];
extern char datatoc_edit_mesh_overlay_facedot_frag_glsl[];
extern char datatoc_edit_mesh_overlay_facedot_vert_glsl[];
-extern char datatoc_edit_mesh_overlay_ghost_clear_vert_glsl[];
extern char datatoc_edit_mesh_overlay_mix_frag_glsl[];
extern char datatoc_edit_mesh_overlay_facefill_vert_glsl[];
extern char datatoc_edit_mesh_overlay_facefill_frag_glsl[];
@@ -70,6 +69,7 @@ extern char datatoc_common_globals_lib_glsl[];
extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
extern char datatoc_gpu_shader_flat_color_frag_glsl[];
extern char datatoc_gpu_shader_point_varying_color_frag_glsl[];
+extern char datatoc_gpu_shader_depth_only_frag_glsl[];
/* *********** LISTS *********** */
typedef struct EDIT_MESH_PassList {
@@ -329,8 +329,7 @@ static void EDIT_MESH_engine_init(void *vedata)
e_data.depth_sh = DRW_shader_create_3D_depth_only();
}
if (!e_data.ghost_clear_depth_sh) {
- e_data.ghost_clear_depth_sh = DRW_shader_create(datatoc_edit_mesh_overlay_ghost_clear_vert_glsl,
- NULL, NULL, NULL);
+ e_data.ghost_clear_depth_sh = DRW_shader_create_fullscreen(datatoc_gpu_shader_depth_only_frag_glsl, NULL);
}
}
@@ -386,6 +385,10 @@ static DRWPass *edit_mesh_create_overlay_pass(
if (!fast_mode) {
DRW_shgroup_uniform_bool_copy(*r_face_shgrp, "isXray", xray);
}
+ else {
+ /* To be able to use triple load. */
+ DRW_shgroup_state_enable(*r_face_shgrp, DRW_STATE_FIRST_VERTEX_CONVENTION);
+ }
*r_ledges_shgrp = DRW_shgroup_create(ledge_sh, pass);
DRW_shgroup_uniform_block(*r_ledges_shgrp, "globalsBlock", globals_ubo);
@@ -572,13 +575,10 @@ static void edit_mesh_add_ob_to_pass(
DRWShadingGroup *facefill_shgrp)
{
struct GPUBatch *geo_ovl_tris, *geo_ovl_verts, *geo_ovl_lnor, *geo_ovl_ledges, *geo_ovl_lverts, *geo_ovl_fcenter;
- struct GPUTexture *data_texture;
ToolSettings *tsettings = scene->toolsettings;
- DRW_cache_mesh_wire_overlay_get(ob, &geo_ovl_tris, &geo_ovl_ledges, &geo_ovl_lverts, &data_texture);
+ DRW_cache_mesh_wire_overlay_get(ob, &geo_ovl_tris, &geo_ovl_ledges, &geo_ovl_lverts);
- face_shgrp = DRW_shgroup_create_sub(face_shgrp);
- DRW_shgroup_uniform_texture(face_shgrp, "dataBuffer", data_texture);
DRW_shgroup_call_add(face_shgrp, geo_ovl_tris, ob->obmat);
DRW_shgroup_call_add(ledges_shgrp, geo_ovl_ledges, ob->obmat);
@@ -645,7 +645,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
}
if (do_occlude_wire) {
- geom = DRW_cache_mesh_surface_get(ob);
+ geom = DRW_cache_mesh_surface_get(ob, false);
DRW_shgroup_call_add(stl->g_data->depth_shgrp_hidden_wire, geom, ob->obmat);
}
diff --git a/source/blender/draw/modes/edit_text_mode.c b/source/blender/draw/modes/edit_text_mode.c
index d186ee967e5..7d6aa5b560c 100644
--- a/source/blender/draw/modes/edit_text_mode.c
+++ b/source/blender/draw/modes/edit_text_mode.c
@@ -215,7 +215,7 @@ static void edit_text_cache_populate_boxes(void *vedata, Object *ob)
DRWShadingGroup *shading_group = shading_groups[is_active ? 0 : 1];
vec[0] = cu->xof + tb->x;
- vec[1] = cu->yof + tb->y + cu->fsize;
+ vec[1] = cu->yof + tb->y + cu->fsize_realtime;
vec[2] = 0.001;
mul_v3_m4v3(vec1, ob->obmat, vec);
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index c794ae3c433..90d499aebd6 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -895,7 +895,7 @@ static void DRW_shgroup_empty_image(
DRW_shgroup_uniform_int_copy(grp, "depthMode", ob->empty_image_depth);
DRW_shgroup_uniform_float(grp, "size", &ob->empty_drawsize, 1);
DRW_shgroup_uniform_vec2(grp, "offset", ob->ima_ofs, 1);
- DRW_shgroup_uniform_vec4(grp, "color", color, 1);
+ DRW_shgroup_uniform_vec3(grp, "color", color, 1);
DRW_shgroup_call_add(grp, DRW_cache_image_plane_wire_get(), ob->obmat);
}
}
@@ -2379,31 +2379,30 @@ static void DRW_shgroup_texture_space(OBJECT_ShadingGroupList *sgl, Object *ob,
ID *ob_data = ob->data;
float *texcoloc = NULL;
float *texcosize = NULL;
- if (ob->data != NULL) {
- switch (GS(ob_data->name)) {
- case ID_ME:
- BKE_mesh_texspace_get_reference((Mesh *)ob_data, NULL, &texcoloc, NULL, &texcosize);
- break;
- case ID_CU:
- {
- Curve *cu = (Curve *)ob_data;
- if (cu->bb == NULL || (cu->bb->flag & BOUNDBOX_DIRTY)) {
- BKE_curve_texspace_calc(cu);
- }
- texcoloc = cu->loc;
- texcosize = cu->size;
- break;
- }
- case ID_MB:
- {
- MetaBall *mb = (MetaBall *)ob_data;
- texcoloc = mb->loc;
- texcosize = mb->size;
- break;
+
+ switch (GS(ob_data->name)) {
+ case ID_ME:
+ BKE_mesh_texspace_get_reference((Mesh *)ob_data, NULL, &texcoloc, NULL, &texcosize);
+ break;
+ case ID_CU:
+ {
+ Curve *cu = (Curve *)ob_data;
+ if (cu->bb == NULL || (cu->bb->flag & BOUNDBOX_DIRTY)) {
+ BKE_curve_texspace_calc(cu);
}
- default:
- BLI_assert(0);
+ texcoloc = cu->loc;
+ texcosize = cu->size;
+ break;
}
+ case ID_MB:
+ {
+ MetaBall *mb = (MetaBall *)ob_data;
+ texcoloc = mb->loc;
+ texcosize = mb->size;
+ break;
+ }
+ default:
+ BLI_assert(0);
}
float tmp[4][4] = {{0.0f}}, one = 1.0f;
@@ -2743,7 +2742,9 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
break;
case OB_ARMATURE:
{
- if (v3d->overlay.flag & V3D_OVERLAY_HIDE_BONES) {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) ||
+ (v3d->overlay.flag & V3D_OVERLAY_HIDE_BONES))
+ {
break;
}
bArmature *arm = ob->data;
@@ -2863,18 +2864,18 @@ static void OBJECT_draw_scene(void *vedata)
MULTISAMPLE_SYNC_ENABLE(dfbl, dtxl);
- /* This needs to be drawn after the oultine */
DRW_draw_pass(stl->g_data->sgl.spot_shapes);
DRW_draw_pass(stl->g_data->sgl.bone_solid);
DRW_draw_pass(stl->g_data->sgl.bone_wire);
DRW_draw_pass(stl->g_data->sgl.bone_outline);
DRW_draw_pass(stl->g_data->sgl.non_meshes);
DRW_draw_pass(psl->particle);
- DRW_draw_pass(stl->g_data->sgl.image_empties);
DRW_draw_pass(stl->g_data->sgl.bone_axes);
MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl)
+ DRW_draw_pass(stl->g_data->sgl.image_empties);
+
if (DRW_state_is_fbo() && outline_calls > 0) {
DRW_stats_group_start("Outlines");
diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c
index 460b3d4240a..cf12daf604b 100644
--- a/source/blender/draw/modes/overlay_mode.c
+++ b/source/blender/draw/modes/overlay_mode.c
@@ -23,8 +23,10 @@
* \ingroup draw_engine
*/
+#include "DNA_mesh_types.h"
#include "DNA_view3d_types.h"
+#include "BKE_editmesh.h"
#include "BKE_object.h"
#include "GPU_shader.h"
@@ -40,9 +42,7 @@ typedef struct OVERLAY_StorageList {
typedef struct OVERLAY_PassList {
struct DRWPass *face_orientation_pass;
- struct DRWPass *flat_wireframe_pass;
struct DRWPass *face_wireframe_pass;
- struct DRWPass *face_wireframe_full_pass;
} OVERLAY_PassList;
typedef struct OVERLAY_Data {
@@ -55,7 +55,8 @@ typedef struct OVERLAY_Data {
typedef struct OVERLAY_PrivateData {
DRWShadingGroup *face_orientation_shgrp;
- DRWShadingGroup *sculpt_wires_full;
+ DRWShadingGroup *face_wires;
+ DRWShadingGroup *flat_wires;
DRWShadingGroup *sculpt_wires;
View3DOverlay overlay;
float wire_step_param[2];
@@ -70,9 +71,7 @@ static struct {
/* Wireframe shader */
struct GPUShader *select_wireframe_sh;
struct GPUShader *face_wireframe_sh;
- struct GPUShader *face_wireframe_pretty_sh;
struct GPUShader *face_wireframe_sculpt_sh;
- struct GPUShader *face_wireframe_sculpt_pretty_sh;
} e_data = {NULL};
/* Shaders */
@@ -82,6 +81,7 @@ extern char datatoc_overlay_face_orientation_vert_glsl[];
extern char datatoc_overlay_face_wireframe_vert_glsl[];
extern char datatoc_overlay_face_wireframe_geom_glsl[];
extern char datatoc_overlay_face_wireframe_frag_glsl[];
+extern char datatoc_gpu_shader_depth_only_frag_glsl[];
extern struct GlobalsUboStorage ts; /* draw_common.c */
@@ -105,45 +105,23 @@ static void overlay_engine_init(void *vedata)
}
if (!e_data.face_wireframe_sh) {
- bool use_geom = GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY);
-
e_data.select_wireframe_sh = DRW_shader_create(
datatoc_overlay_face_wireframe_vert_glsl,
datatoc_overlay_face_wireframe_geom_glsl,
- datatoc_overlay_face_wireframe_frag_glsl,
- "#define SELECT_EDGES\n"
- "#define LIGHT_EDGES\n"
- "#define USE_GEOM_SHADER\n");
+ datatoc_gpu_shader_depth_only_frag_glsl,
+ "#define SELECT_EDGES\n");
e_data.face_wireframe_sh = DRW_shader_create(
datatoc_overlay_face_wireframe_vert_glsl,
- use_geom ? datatoc_overlay_face_wireframe_geom_glsl : NULL,
+ NULL,
datatoc_overlay_face_wireframe_frag_glsl,
- use_geom ? "#define USE_GEOM_SHADER\n"
- : NULL);
-
- e_data.face_wireframe_pretty_sh = DRW_shader_create(
- datatoc_overlay_face_wireframe_vert_glsl,
- use_geom ? datatoc_overlay_face_wireframe_geom_glsl : NULL,
- datatoc_overlay_face_wireframe_frag_glsl,
- use_geom ? "#define USE_GEOM_SHADER\n"
- "#define LIGHT_EDGES\n"
- : "#define LIGHT_EDGES\n");
+ NULL);
e_data.face_wireframe_sculpt_sh = DRW_shader_create(
datatoc_overlay_face_wireframe_vert_glsl,
datatoc_overlay_face_wireframe_geom_glsl,
datatoc_overlay_face_wireframe_frag_glsl,
- "#define USE_SCULPT\n"
- "#define USE_GEOM_SHADER\n");
-
- e_data.face_wireframe_sculpt_pretty_sh = DRW_shader_create(
- datatoc_overlay_face_wireframe_vert_glsl,
- datatoc_overlay_face_wireframe_geom_glsl,
- datatoc_overlay_face_wireframe_frag_glsl,
- "#define USE_SCULPT\n"
- "#define USE_GEOM_SHADER\n"
- "#define LIGHT_EDGES\n");
+ "#define USE_SCULPT\n");
}
}
@@ -152,73 +130,68 @@ static void overlay_cache_init(void *vedata)
OVERLAY_Data *data = vedata;
OVERLAY_PassList *psl = data->psl;
OVERLAY_StorageList *stl = data->stl;
+ OVERLAY_PrivateData *g_data = stl->g_data;
const DRWContextState *DCS = DRW_context_state_get();
View3D *v3d = DCS->v3d;
if (v3d) {
- stl->g_data->overlay = v3d->overlay;
- stl->g_data->show_overlays = (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0;
+ g_data->overlay = v3d->overlay;
+ g_data->show_overlays = (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0;
}
else {
- memset(&stl->g_data->overlay, 0, sizeof(stl->g_data->overlay));
- stl->g_data->show_overlays = false;
+ memset(&g_data->overlay, 0, sizeof(g_data->overlay));
+ g_data->show_overlays = false;
}
- if (stl->g_data->show_overlays == false) {
- stl->g_data->overlay.flag = 0;
+ if (g_data->show_overlays == false) {
+ g_data->overlay.flag = 0;
}
if (v3d->shading.type == OB_WIRE) {
- stl->g_data->overlay.flag |= V3D_OVERLAY_WIREFRAMES;
- stl->g_data->show_overlays = true;
+ g_data->overlay.flag |= V3D_OVERLAY_WIREFRAMES;
+ g_data->show_overlays = true;
}
{
/* Face Orientation Pass */
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND;
psl->face_orientation_pass = DRW_pass_create("Face Orientation", state);
- stl->g_data->face_orientation_shgrp = DRW_shgroup_create(
+ g_data->face_orientation_shgrp = DRW_shgroup_create(
e_data.face_orientation_sh, psl->face_orientation_pass);
}
{
/* Wireframe */
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND;
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND | DRW_STATE_FIRST_VERTEX_CONVENTION;
float wire_size = max_ff(0.0f, U.pixelsize - 1.0f) * 0.5f;
- psl->flat_wireframe_pass = DRW_pass_create("Flat Object Wires", state | DRW_STATE_WRITE_DEPTH);
+ const bool use_select = (DRW_state_is_select() || DRW_state_is_depth());
+ GPUShader *sculpt_wire_sh = use_select ? e_data.select_wireframe_sh : e_data.face_wireframe_sculpt_sh;
+ GPUShader *face_wires_sh = use_select ? e_data.select_wireframe_sh : e_data.face_wireframe_sh;
+ GPUShader *flat_wires_sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
- psl->face_wireframe_full_pass = DRW_pass_create("All Face Wires", state);
+ psl->face_wireframe_pass = DRW_pass_create("Face Wires", state);
- stl->g_data->sculpt_wires_full = DRW_shgroup_create(e_data.face_wireframe_sculpt_sh, psl->face_wireframe_full_pass);
- DRW_shgroup_uniform_float_copy(stl->g_data->sculpt_wires_full, "wireSize", wire_size);
+ g_data->flat_wires = DRW_shgroup_create(flat_wires_sh, psl->face_wireframe_pass);
+ DRW_shgroup_uniform_vec4(g_data->flat_wires, "color", ts.colorWire, 1);
- DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.face_wireframe_sh, psl->face_wireframe_full_pass);
- DRW_shgroup_uniform_float_copy(shgrp, "wireSize", wire_size);
+ g_data->sculpt_wires = DRW_shgroup_create(sculpt_wire_sh, psl->face_wireframe_pass);
- psl->face_wireframe_pass = DRW_pass_create("Face Wires", state);
+ g_data->face_wires = DRW_shgroup_create(face_wires_sh, psl->face_wireframe_pass);
+ DRW_shgroup_uniform_vec2(g_data->face_wires, "wireStepParam", g_data->wire_step_param, 1);
- stl->g_data->sculpt_wires = DRW_shgroup_create(e_data.face_wireframe_sculpt_pretty_sh, psl->face_wireframe_pass);
- DRW_shgroup_uniform_vec2(stl->g_data->sculpt_wires, "wireStepParam", stl->g_data->wire_step_param, 1);
- DRW_shgroup_uniform_float_copy(stl->g_data->sculpt_wires, "wireSize", wire_size);
-
- shgrp = DRW_shgroup_create(e_data.face_wireframe_pretty_sh, psl->face_wireframe_pass);
- DRW_shgroup_uniform_vec2(shgrp, "wireStepParam", stl->g_data->wire_step_param, 1);
- DRW_shgroup_uniform_float_copy(shgrp, "wireSize", wire_size);
-
- /**
- * The wireframe threshold ranges from 0.0 to 1.0
- * When 1.0 we show all the edges, when 0.5 we show as many as 2.7.
- *
- * If we wanted 0.0 to match 2.7, factor would need to be 0.003f.
- * The range controls the falloff effect. If range was 0.0f we would get a hard cut (as in 2.7).
- * That said we are using a different algorithm so the results will always differ.
- */
- const float factor = 0.0045f;
- const float range = 0.00125f;
- stl->g_data->wire_step_param[1] = (1.0f - factor) + stl->g_data->overlay.wireframe_threshold * factor;
- stl->g_data->wire_step_param[0] = stl->g_data->wire_step_param[1] + range;
+ if (!use_select) {
+ DRW_shgroup_uniform_float_copy(g_data->sculpt_wires, "wireSize", wire_size);
+ DRW_shgroup_uniform_float_copy(g_data->face_wires, "wireSize", wire_size);
+ }
+
+ /* Control aspect of the falloff. */
+ const float sharpness = 4.0f;
+ /* Scale and bias: Adjust with wiredata encoding. (see mesh_batch_cache_create_edges_wireframe_data) */
+ const float decompress = (0xFF / (float)(0xFF - 0x20));
+ g_data->wire_step_param[0] = -sharpness * decompress;
+ g_data->wire_step_param[1] = decompress + sharpness * stl->g_data->overlay.wireframe_threshold;
}
}
@@ -227,35 +200,46 @@ static void overlay_cache_populate(void *vedata, Object *ob)
OVERLAY_Data *data = vedata;
OVERLAY_StorageList *stl = data->stl;
OVERLAY_PrivateData *pd = stl->g_data;
- OVERLAY_PassList *psl = data->psl;
const DRWContextState *draw_ctx = DRW_context_state_get();
RegionView3D *rv3d = draw_ctx->rv3d;
View3D *v3d = draw_ctx->v3d;
- if ((!stl->g_data->show_overlays) ||
+ if ((!pd->show_overlays) ||
(ob->dt < OB_WIRE) ||
(!DRW_object_is_renderable(ob) && (ob->dt != OB_WIRE)))
{
return;
}
- if (DRW_object_is_renderable(ob) && stl->g_data->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) {
+ if (DRW_object_is_renderable(ob) && pd->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) {
struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
DRW_shgroup_call_add(pd->face_orientation_shgrp, geom, ob->obmat);
}
}
- if ((stl->g_data->overlay.flag & V3D_OVERLAY_WIREFRAMES) ||
+ if ((pd->overlay.flag & V3D_OVERLAY_WIREFRAMES) ||
(v3d->shading.type == OB_WIRE) ||
(ob->dtx & OB_DRAWWIRE) ||
(ob->dt == OB_WIRE))
{
- /* Don't do that in edit Mesh mode. */
- if (((ob != draw_ctx->object_edit) && !BKE_object_is_in_editmode(ob)) || ob->type != OB_MESH) {
+ bool has_edit_mesh_cage = false;
+ if (ob->type == OB_MESH) {
+ /* TODO: Should be its own function. */
+ Mesh *me = (Mesh *)ob->data;
+ BMEditMesh *embm = me->edit_btmesh;
+ if (embm) {
+ has_edit_mesh_cage = embm->mesh_eval_cage && (embm->mesh_eval_cage != embm->mesh_eval_final);
+ }
+ }
+
+ /* Don't do that in edit Mesh mode, unless there is a modifier preview. */
+ if ((((ob != draw_ctx->object_edit) && !BKE_object_is_in_editmode(ob)) || has_edit_mesh_cage) ||
+ ob->type != OB_MESH)
+ {
const bool is_active = (ob == draw_ctx->obact);
const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
- const bool all_wires = (stl->g_data->overlay.wireframe_threshold == 1.0f) ||
+ const bool all_wires = (pd->overlay.wireframe_threshold == 1.0f) ||
(ob->dtx & OB_DRAW_ALL_EDGES);
const bool is_wire = (ob->dt < OB_SOLID);
const int stencil_mask = (ob->dtx & OB_DRAWXRAY) ? 0x00 : 0xFF;
@@ -267,62 +251,46 @@ static void overlay_cache_populate(void *vedata, Object *ob)
DRW_object_is_flat(ob, &flat_axis) &&
DRW_object_axis_orthogonal_to_view(ob, flat_axis);
- if (is_sculpt_mode) {
- shgrp = (all_wires || DRW_object_is_flat_normal(ob))
- ? stl->g_data->sculpt_wires_full
- : stl->g_data->sculpt_wires;
- if (is_wire) {
- shgrp = DRW_shgroup_create_sub(shgrp);
- }
- DRW_shgroup_call_sculpt_add(shgrp, ob, ob->obmat);
- }
- else if (is_flat_object_viewed_from_side) {
+ if (is_flat_object_viewed_from_side && !is_sculpt_mode) {
/* Avoid losing flat objects when in ortho views (see T56549) */
struct GPUBatch *geom = DRW_cache_object_wire_outline_get(ob);
if (geom) {
- GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
- shgrp = DRW_shgroup_create(sh, psl->flat_wireframe_pass);
+ shgrp = pd->flat_wires;
+ shgrp = DRW_shgroup_create_sub(shgrp);
DRW_shgroup_stencil_mask(shgrp, stencil_mask);
- DRW_shgroup_uniform_vec4(shgrp, "color", ts.colorWire, 1);
DRW_shgroup_call_object_add(shgrp, geom, ob);
}
}
else {
- int tri_count;
- GPUTexture *verts = NULL, *faceids;
- DRW_cache_object_face_wireframe_get(ob, &verts, &faceids, &tri_count);
- if (verts) {
+ struct GPUBatch *geom = DRW_cache_object_face_wireframe_get(ob);
+ if (geom || is_sculpt_mode) {
float *rim_col = ts.colorWire;
- if ((ob->base_flag & BASE_SELECTED) != 0) {
+ if (!is_sculpt_mode && !has_edit_mesh_cage && ((ob->base_flag & BASE_SELECTED) != 0)) {
rim_col = (ob == draw_ctx->obact) ? ts.colorActive : ts.colorSelect;
}
- DRWPass *pass = (all_wires) ? psl->face_wireframe_full_pass : psl->face_wireframe_pass;
- GPUShader *sh = (all_wires) ? e_data.face_wireframe_sh : e_data.face_wireframe_pretty_sh;
+ shgrp = (is_sculpt_mode) ? pd->sculpt_wires : pd->face_wires;
+ shgrp = DRW_shgroup_create_sub(shgrp);
if ((DRW_state_is_select() || DRW_state_is_depth())) {
static float params[2] = {1.2f, 1.0f}; /* Parameters for all wires */
-
- sh = e_data.select_wireframe_sh;
- shgrp = DRW_shgroup_create(sh, pass);
DRW_shgroup_uniform_vec2(shgrp, "wireStepParam", (all_wires)
? params
- : stl->g_data->wire_step_param, 1);
- DRW_shgroup_uniform_texture(shgrp, "vertData", verts);
- DRW_shgroup_uniform_texture(shgrp, "faceIds", faceids);
- DRW_shgroup_call_object_procedural_triangles_culled_add(shgrp, tri_count, ob);
+ : pd->wire_step_param, 1);
}
else {
- shgrp = DRW_shgroup_create(sh, pass);
DRW_shgroup_stencil_mask(shgrp, stencil_mask);
- DRW_shgroup_uniform_texture(shgrp, "vertData", verts);
- DRW_shgroup_uniform_texture(shgrp, "faceIds", faceids);
DRW_shgroup_uniform_vec3(shgrp, "wireColor", ts.colorWire, 1);
DRW_shgroup_uniform_vec3(shgrp, "rimColor", rim_col, 1);
- DRW_shgroup_call_object_procedural_triangles_culled_add(shgrp, tri_count, ob);
+ }
+
+ if (is_sculpt_mode) {
+ DRW_shgroup_call_sculpt_add(shgrp, ob, ob->obmat);
+ }
+ else {
+ DRW_shgroup_call_add(shgrp, geom, ob->obmat);
}
}
}
-
if (is_wire && shgrp != NULL) {
/* If object is wireframe, don't try to use stencil test. */
DRW_shgroup_state_disable(shgrp, DRW_STATE_STENCIL_EQUAL);
@@ -332,7 +300,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
}
}
else if ((ob->dtx & OB_DRAWXRAY) && shgrp != NULL) {
- stl->g_data->ghost_stencil_test = true;
+ pd->ghost_stencil_test = true;
}
}
}
@@ -351,7 +319,6 @@ static void overlay_cache_finish(void *vedata)
if (v3d->shading.type == OB_SOLID && (v3d->shading.flag & XRAY_FLAG(v3d)) == 0) {
if (stl->g_data->ghost_stencil_test) {
DRW_pass_state_add(psl->face_wireframe_pass, DRW_STATE_STENCIL_EQUAL);
- DRW_pass_state_add(psl->face_wireframe_full_pass, DRW_STATE_STENCIL_EQUAL);
}
}
}
@@ -366,9 +333,7 @@ static void overlay_draw_scene(void *vedata)
GPU_framebuffer_bind(dfbl->default_fb);
}
DRW_draw_pass(psl->face_orientation_pass);
- DRW_draw_pass(psl->flat_wireframe_pass);
DRW_draw_pass(psl->face_wireframe_pass);
- DRW_draw_pass(psl->face_wireframe_full_pass);
}
static void overlay_engine_free(void)
@@ -376,9 +341,7 @@ static void overlay_engine_free(void)
DRW_SHADER_FREE_SAFE(e_data.face_orientation_sh);
DRW_SHADER_FREE_SAFE(e_data.select_wireframe_sh);
DRW_SHADER_FREE_SAFE(e_data.face_wireframe_sh);
- DRW_SHADER_FREE_SAFE(e_data.face_wireframe_pretty_sh);
DRW_SHADER_FREE_SAFE(e_data.face_wireframe_sculpt_sh);
- DRW_SHADER_FREE_SAFE(e_data.face_wireframe_sculpt_pretty_sh);
}
static const DrawEngineDataSize overlay_data_size = DRW_VIEWPORT_DATA_SIZE(OVERLAY_Data);
diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c
index 2792c59b805..3be44a425f7 100644
--- a/source/blender/draw/modes/paint_texture_mode.c
+++ b/source/blender/draw/modes/paint_texture_mode.c
@@ -38,6 +38,8 @@
#include "DNA_mesh_types.h"
+#include "DEG_depsgraph_query.h"
+
extern char datatoc_common_globals_lib_glsl[];
extern char datatoc_paint_texture_vert_glsl[];
extern char datatoc_paint_texture_frag_glsl[];
@@ -288,24 +290,27 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
if ((ob->type == OB_MESH) && (draw_ctx->obact == ob)) {
/* Get geometry cache */
const Mesh *me = ob->data;
+ const Mesh *me_orig = DEG_get_original_object(ob)->data;
Scene *scene = draw_ctx->scene;
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);
+ const bool use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
bool ok = false;
if (use_surface) {
if (me->mloopuv != NULL) {
- if (use_material_slots) {
- struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
+ if (use_material_slots || use_face_sel) {
+ struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob, use_face_sel) : NULL;
if ((me->totcol == 0) || (geom_array == NULL)) {
- struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob, use_face_sel);
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
ok = true;
}
else {
for (int i = 0; i < me->totcol; i++) {
- if (stl->g_data->shgroup_image_array[i]) {
- DRW_shgroup_call_add(stl->g_data->shgroup_image_array[i], geom_array[i], ob->obmat);
+ const int index = use_material_slots ? i : 0;
+ if (stl->g_data->shgroup_image_array[index]) {
+ DRW_shgroup_call_add(stl->g_data->shgroup_image_array[index], geom_array[i], ob->obmat);
}
else {
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom_array[i], ob->obmat);
@@ -324,13 +329,12 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
}
if (!ok) {
- struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob);
+ struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob, use_face_sel);
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
}
}
/* Face Mask */
- const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
if (use_face_sel) {
struct GPUBatch *geom;
/* Note: ideally selected faces wouldn't show interior wire. */
diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c
index 9060a97f412..935c236410e 100644
--- a/source/blender/draw/modes/paint_weight_mode.c
+++ b/source/blender/draw/modes/paint_weight_mode.c
@@ -184,11 +184,11 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob)
const View3D *v3d = draw_ctx->v3d;
if ((ob->type == OB_MESH) && (ob == draw_ctx->obact)) {
- const Mesh *me = ob->data;
+ const Mesh *me_orig = DEG_get_original_object(ob)->data;
const bool use_wire = (v3d->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0;
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;
+ const bool use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ const bool use_vert_sel = (me_orig->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
struct GPUBatch *geom;
if (use_surface) {
diff --git a/source/blender/draw/modes/particle_mode.c b/source/blender/draw/modes/particle_mode.c
index f4879483540..758218fe329 100644
--- a/source/blender/draw/modes/particle_mode.c
+++ b/source/blender/draw/modes/particle_mode.c
@@ -48,6 +48,9 @@
extern char datatoc_particle_strand_vert_glsl[];
extern char datatoc_particle_strand_frag_glsl[];
+extern char datatoc_common_globals_lib_glsl[];
+
+extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
/* *********** LISTS *********** */
@@ -80,6 +83,7 @@ typedef struct PARTICLE_Data {
static struct {
struct GPUShader *strands_shader;
+ struct GPUShader *strands_weight_shader;
struct GPUShader *points_shader;
} e_data = {NULL}; /* Engine data */
@@ -94,15 +98,26 @@ typedef struct PARTICLE_PrivateData {
static void particle_engine_init(void *UNUSED(vedata))
{
if (!e_data.strands_shader) {
- e_data.strands_shader = DRW_shader_create(
+ e_data.strands_shader = DRW_shader_create_with_lib(
datatoc_particle_strand_vert_glsl,
NULL,
datatoc_particle_strand_frag_glsl,
+ datatoc_common_globals_lib_glsl,
"");
- }
- if (!e_data.points_shader) {
- e_data.points_shader = GPU_shader_get_builtin_shader(
- GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR);
+
+ e_data.strands_weight_shader = DRW_shader_create_with_lib(
+ datatoc_particle_strand_vert_glsl,
+ NULL,
+ datatoc_particle_strand_frag_glsl,
+ datatoc_common_globals_lib_glsl,
+ "#define USE_WEIGHT");
+
+ e_data.points_shader = DRW_shader_create_with_lib(
+ datatoc_particle_strand_vert_glsl,
+ NULL,
+ datatoc_particle_strand_frag_glsl,
+ datatoc_common_globals_lib_glsl,
+ "#define USE_POINTS");
}
}
@@ -110,6 +125,9 @@ static void particle_cache_init(void *vedata)
{
PARTICLE_PassList *psl = ((PARTICLE_Data *)vedata)->psl;
PARTICLE_StorageList *stl = ((PARTICLE_Data *)vedata)->stl;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ ParticleEditSettings *pset = PE_settings(draw_ctx->scene);
+ const bool use_weight = (pset->brushtype == PE_BRUSH_WEIGHT);
if (!stl->g_data) {
/* Alloc transient pointers */
@@ -124,19 +142,14 @@ static void particle_cache_init(void *vedata)
DRW_STATE_WIRE |
DRW_STATE_POINT));
- stl->g_data->strands_group = DRW_shgroup_create(
- e_data.strands_shader, psl->psys_edit_pass);
- stl->g_data->inner_points_group = DRW_shgroup_create(
- e_data.points_shader, psl->psys_edit_pass);
- stl->g_data->tip_points_group = DRW_shgroup_create(
- e_data.points_shader, psl->psys_edit_pass);
-
- static float size = 5.0f;
- static float outline_width = 1.0f;
- DRW_shgroup_uniform_float(stl->g_data->inner_points_group, "size", &size, 1);
- DRW_shgroup_uniform_float(stl->g_data->inner_points_group, "outlineWidth", &outline_width, 1);
- DRW_shgroup_uniform_float(stl->g_data->tip_points_group, "size", &size, 1);
- DRW_shgroup_uniform_float(stl->g_data->tip_points_group, "outlineWidth", &outline_width, 1);
+ GPUShader *strand_shader = (use_weight) ? e_data.strands_weight_shader : e_data.strands_shader;
+ stl->g_data->strands_group = DRW_shgroup_create(strand_shader, psl->psys_edit_pass);
+ stl->g_data->inner_points_group = DRW_shgroup_create(e_data.points_shader, psl->psys_edit_pass);
+ stl->g_data->tip_points_group = DRW_shgroup_create(e_data.points_shader, psl->psys_edit_pass);
+
+ DRW_shgroup_uniform_block(stl->g_data->strands_group, "globalsBlock", globals_ubo);
+ DRW_shgroup_uniform_block(stl->g_data->inner_points_group, "globalsBlock", globals_ubo);
+ DRW_shgroup_uniform_block(stl->g_data->tip_points_group, "globalsBlock", globals_ubo);
}
static void particle_edit_cache_populate(void *vedata,
@@ -147,9 +160,10 @@ static void particle_edit_cache_populate(void *vedata,
PARTICLE_StorageList *stl = ((PARTICLE_Data *)vedata)->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
ParticleEditSettings *pset = PE_settings(draw_ctx->scene);
+ const bool use_weight = (pset->brushtype == PE_BRUSH_WEIGHT);
{
struct GPUBatch *strands =
- DRW_cache_particles_get_edit_strands(object, psys, edit);
+ DRW_cache_particles_get_edit_strands(object, psys, edit, use_weight);
DRW_shgroup_call_add(stl->g_data->strands_group, strands, NULL);
}
if (pset->selectmode == SCE_SELECT_POINT) {
@@ -225,6 +239,8 @@ static void particle_draw_scene(void *vedata)
static void particle_engine_free(void)
{
DRW_SHADER_FREE_SAFE(e_data.strands_shader);
+ DRW_SHADER_FREE_SAFE(e_data.strands_weight_shader);
+ DRW_SHADER_FREE_SAFE(e_data.points_shader);
}
static const DrawEngineDataSize particle_data_size =
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index 3c0a8048c9e..6ee6f59e5fa 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -195,7 +195,9 @@ static void POSE_cache_populate(void *vedata, Object *ob)
* and similar functionalities. For now we handle only pose bones. */
if (ob->type == OB_ARMATURE) {
- if (draw_ctx->v3d->overlay.flag & V3D_OVERLAY_HIDE_BONES) {
+ if ((draw_ctx->v3d->flag2 & V3D_RENDER_OVERRIDE) ||
+ (draw_ctx->v3d->overlay.flag & V3D_OVERLAY_HIDE_BONES))
+ {
return;
}
if (DRW_pose_mode_armature(ob, draw_ctx->obact)) {
diff --git a/source/blender/draw/modes/shaders/common_fullscreen_vert.glsl b/source/blender/draw/modes/shaders/common_fullscreen_vert.glsl
index fc5cc1cdcc3..e5c5ccc97bf 100644
--- a/source/blender/draw/modes/shaders/common_fullscreen_vert.glsl
+++ b/source/blender/draw/modes/shaders/common_fullscreen_vert.glsl
@@ -6,5 +6,5 @@ out vec4 uvcoordsvar;
void main()
{
uvcoordsvar = vec4(uvs, 0.0, 0.0);
- gl_Position = vec4(pos, 0.0, 1.0);
+ gl_Position = vec4(pos, 1.0, 1.0);
}
diff --git a/source/blender/draw/modes/shaders/common_hair_lib.glsl b/source/blender/draw/modes/shaders/common_hair_lib.glsl
index c0c5f84d166..594a7b31f0b 100644
--- a/source/blender/draw/modes/shaders/common_hair_lib.glsl
+++ b/source/blender/draw/modes/shaders/common_hair_lib.glsl
@@ -26,6 +26,8 @@ uniform float hairRadTip = 0.0;
uniform float hairRadShape = 0.5;
uniform bool hairCloseTip = true;
+uniform mat4 hairDupliMatrix;
+
/* -- Per control points -- */
uniform samplerBuffer hairPointBuffer; /* RGBA32F */
#define point_position xyz
@@ -150,6 +152,9 @@ void hair_get_pos_tan_binor_time(
wtan = wpos - texelFetch(hairPointBuffer, id - 1).point_position;
}
+ wpos = (hairDupliMatrix * vec4(wpos, 1.0)).xyz;
+ wtan = mat3(hairDupliMatrix) * wtan;
+
vec3 camera_vec = (is_persp) ? wpos - camera_pos : -camera_z;
wbinor = normalize(cross(camera_vec, wtan));
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
index e4268188e09..aea1eb55644 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
@@ -10,8 +10,6 @@ uniform ivec4 dataMask = ivec4(0xFF);
uniform float ofs = 1e-5;
-uniform isamplerBuffer dataBuffer;
-
in vec3 pos;
#ifdef VERTEX_FACING
in vec3 vnor;
@@ -43,6 +41,13 @@ void main()
#else /* EDGE_FIX */
+/* Consecutive data of the nth vertex.
+ * Only valid for first vertex in the triangle.
+ * Assuming GL_FRIST_VERTEX_CONVENTION. */
+in ivec4 data0;
+in ivec4 data1;
+in ivec4 data2;
+
flat out vec3 edgesCrease;
flat out vec3 edgesBweight;
flat out vec4 faceColor;
@@ -66,11 +71,10 @@ void main()
barycentric = vec3(equal(ivec3(0, 1, 2), ivec3(vidx)));
/* Edge */
- ivec4 vData[3], data = ivec4(0);
+ ivec4 vData[3] = ivec4[3](data0, data1, data2);
ivec3 eflag;
for (int v = 0; v < 3; ++v) {
- data = texelFetch(dataBuffer, v_0 + v);
- vData[v] = data & dataMask;
+ vData[v] = vData[v] & dataMask;
flag[v] = eflag[v] = vData[v].y | (vData[v].x << 8);
edgesCrease[v] = vData[v].z / 255.0;
edgesBweight[v] = vData[v].w / 255.0;
@@ -87,7 +91,7 @@ void main()
faceColor = colorFace;
# ifdef VERTEX_SELECTION
- vertexColor = EDIT_MESH_vertex_color(vData[vidx].x).rgb;
+ vertexColor = EDIT_MESH_vertex_color(data0.x).rgb;
# endif
# ifdef VERTEX_FACING
vec4 vPos = ModelViewMatrix * vec4(pos, 1.0);
diff --git a/source/blender/draw/modes/shaders/object_empty_image_vert.glsl b/source/blender/draw/modes/shaders/object_empty_image_vert.glsl
index 3469e37358e..1c1525696fb 100644
--- a/source/blender/draw/modes/shaders/object_empty_image_vert.glsl
+++ b/source/blender/draw/modes/shaders/object_empty_image_vert.glsl
@@ -24,6 +24,7 @@ void main()
(pos + offset) * (size * vec2(aspectX, aspectY)),
0.0, 1.0);
#ifdef USE_WIRE
+ gl_Position.z -= 1e-5;
finalColor = vec4(color, 1.0);
#else
texCoord_interp = texCoord;
diff --git a/source/blender/draw/modes/shaders/object_grid_vert.glsl b/source/blender/draw/modes/shaders/object_grid_vert.glsl
index a346973a597..15b37bb289d 100644
--- a/source/blender/draw/modes/shaders/object_grid_vert.glsl
+++ b/source/blender/draw/modes/shaders/object_grid_vert.glsl
@@ -53,10 +53,10 @@ void main()
/* Used for additional Z axis */
if ((gridFlag & CLIP_Z_POS) != 0) {
- realPos.z = max(realPos.z, 0.0);
+ realPos.z = clamp(realPos.z, 0.0, 1e30);
}
if ((gridFlag & CLIP_Z_NEG) != 0) {
- realPos.z = min(-realPos.z, 0.0);
+ realPos.z = clamp(realPos.z, -1e30, 0.0);
}
gl_Position = ViewProjectionMatrix * vec4(realPos, 1.0);
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 69af4858a48..cefd4eab2e3 100644
--- a/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl
+++ b/source/blender/draw/modes/shaders/overlay_face_wireframe_frag.glsl
@@ -1,18 +1,12 @@
-#ifndef SELECT_EDGES
uniform vec3 wireColor;
uniform vec3 rimColor;
in float facing;
in vec3 barycentric;
-
-# ifdef LIGHT_EDGES
flat in vec3 edgeSharpness;
-# endif
out vec4 fragColor;
-#endif
-float min_v3(vec3 v) { return min(v.x, min(v.y, v.z)); }
float max_v3(vec3 v) { return max(v.x, max(v.y, v.z)); }
/* In pixels */
@@ -25,7 +19,6 @@ const float rim_alpha = 0.75;
void main()
{
-#ifndef SELECT_EDGES
vec3 dx = dFdx(barycentric);
vec3 dy = dFdy(barycentric);
vec3 d = vec3(
@@ -35,11 +28,7 @@ void main()
);
vec3 dist_to_edge = barycentric / d;
-# ifdef LIGHT_EDGES
vec3 fac = abs(dist_to_edge);
-# else
- float fac = min_v3(abs(dist_to_edge));
-# endif
fac = smoothstep(wireSize + wire_smooth, wireSize, fac);
@@ -48,10 +37,5 @@ void main()
vec3 final_front_col = mix(rimColor, wireColor, 0.05);
fragColor = mix(vec4(rimColor, rim_alpha), vec4(final_front_col, front_alpha), facing_clamped);
-# ifdef LIGHT_EDGES
fragColor.a *= max_v3(fac * edgeSharpness);
-# else
- fragColor.a *= fac;
-# endif
-#endif
}
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 8abb6ecc737..7a40dd59571 100644
--- a/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl
+++ b/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl
@@ -1,6 +1,5 @@
-/* This shader is only used for intel GPU where the Geom shader is faster
- * than doing everything thrice in the vertex shader. */
+/* This shader is only used for edge selection & sculpt mode wires (because of indexed drawing). */
layout(triangles) in;
#ifdef SELECT_EDGES
@@ -9,119 +8,53 @@ layout(line_strip, max_vertices = 6) out;
layout(triangle_strip, max_vertices = 3) out;
#endif
-uniform vec2 wireStepParam;
-
-in vec2 ssPos[];
-in float facingOut[];
+in float facing_g[];
+in float edgeSharpness_g[];
#ifndef SELECT_EDGES
-out vec3 barycentric;
out float facing;
-#endif
-
-#ifdef LIGHT_EDGES
-in vec3 obPos[];
-in vec3 vNor[];
-in float forceEdge[];
-
-# ifndef SELECT_EDGES
+out vec3 barycentric;
flat out vec3 edgeSharpness;
-# endif
#endif
-#define NO_EDGE vec3(10000.0);
-
-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));
- return smoothstep(wireStepParam.x, wireStepParam.y, sharpness);
-}
-
-vec3 get_barycentric(bvec3 do_edge, const int v)
-{
- int v_n = v;
- int v_n1 = (v + 1) % 3;
- int v_n2 = (v + 2) % 3;
- vec3 bary;
- bary[v_n] = do_edge[v_n] ? 0.0 : 1.0;
- bary[v_n1] = 1.0;
- bary[v_n2] = do_edge[v_n2] ? 0.0 : 1.0;
- return bary;
-}
-
void main(void)
{
- vec3 facings = vec3(facingOut[0], facingOut[1], facingOut[2]);
- bvec3 do_edge = greaterThan(abs(facings), vec3(1.0));
- facings = fract(facings) - clamp(-sign(facings), 0.0, 1.0);
-
-#ifdef SELECT_EDGES
- vec3 edgeSharpness;
-#endif
-
-#ifdef LIGHT_EDGES
- 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
-
#ifdef SELECT_EDGES
const float edge_select_threshold = 0.3;
- if (edgeSharpness.x > edge_select_threshold) {
- gl_Position = gl_in[0].gl_Position;
- EmitVertex();
- gl_Position = gl_in[1].gl_Position;
- EmitVertex();
+ if (edgeSharpness_g[0] > edge_select_threshold) {
+ gl_Position = gl_in[0].gl_Position; EmitVertex();
+ gl_Position = gl_in[1].gl_Position; EmitVertex();
EndPrimitive();
}
- if (edgeSharpness.y > edge_select_threshold) {
- gl_Position = gl_in[1].gl_Position;
- EmitVertex();
- gl_Position = gl_in[2].gl_Position;
- EmitVertex();
+ if (edgeSharpness_g[1] > edge_select_threshold) {
+ gl_Position = gl_in[1].gl_Position; EmitVertex();
+ gl_Position = gl_in[2].gl_Position; EmitVertex();
EndPrimitive();
}
- if (edgeSharpness.z > edge_select_threshold) {
- gl_Position = gl_in[2].gl_Position;
- EmitVertex();
- gl_Position = gl_in[0].gl_Position;
- EmitVertex();
+ if (edgeSharpness_g[2] > edge_select_threshold) {
+ gl_Position = gl_in[2].gl_Position; EmitVertex();
+ gl_Position = gl_in[0].gl_Position; EmitVertex();
EndPrimitive();
}
#else
- barycentric = get_barycentric(do_edge, 0);
+ edgeSharpness = vec3(edgeSharpness_g[0], edgeSharpness_g[1], edgeSharpness_g[2]);
+
+ barycentric = vec3(1.0, 0.0, 0.0);
gl_Position = gl_in[0].gl_Position;
- facing = facings.x;
+ facing = facing_g[0];
EmitVertex();
- barycentric = get_barycentric(do_edge, 1);
+ barycentric = vec3(0.0, 1.0, 0.0);
gl_Position = gl_in[1].gl_Position;
- facing = facings.y;
+ facing = facing_g[1];
EmitVertex();
- barycentric = get_barycentric(do_edge, 2);
+ barycentric = vec3(0.0, 0.0, 1.0);
gl_Position = gl_in[2].gl_Position;
- facing = facings.z;
+ facing = facing_g[2];
EmitVertex();
EndPrimitive();
-#endif
+#endif /* SELECT_EDGES */
}
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 828bc551cad..d5c2bdeefea 100644
--- a/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl
+++ b/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl
@@ -1,177 +1,81 @@
uniform mat4 ModelViewProjectionMatrix;
-uniform mat4 ModelViewMatrix;
-uniform mat4 ProjectionMatrix;
uniform mat3 NormalMatrix;
uniform vec2 wireStepParam;
-uniform float nearDist;
-uniform samplerBuffer vertData;
-uniform usamplerBuffer faceIds;
-
-#ifdef USE_SCULPT
-in vec3 pos;
-in vec3 nor;
-#endif
-
-float short_to_unit_float(uint s)
+vec3 get_edge_sharpness(vec3 wd)
{
- int value = int(s) & 0x7FFF;
- if ((s & 0x8000u) != 0u) {
- value |= ~0x7FFF;
- }
- return float(value) / float(0x7FFF);
+ bvec3 do_edge = greaterThan(wd, vec3(0.0));
+ bvec3 force_edge = equal(wd, vec3(1.0));
+ wd = clamp(wireStepParam.x * wd + wireStepParam.y, 0.0, 1.0);
+ return clamp(wd * vec3(do_edge) + vec3(force_edge), 0.0, 1.0);
}
-vec3 get_vertex_nor(uint id)
+float get_edge_sharpness(float wd)
{
- int v_id = int(id) * 5; /* See vertex format for explanation. */
- /* Fetch compressed normal as float and unpack them. */
- vec2 data;
- data.x = texelFetch(vertData, v_id + 3).r;
- data.y = texelFetch(vertData, v_id + 4).r;
-
- uvec2 udata = floatBitsToUint(data);
-
- vec3 nor;
- nor.x = short_to_unit_float(udata.x & 0xFFFFu);
- nor.y = short_to_unit_float(udata.x >> 16u);
- nor.z = short_to_unit_float(udata.y & 0xFFFFu);
- return nor;
+ bool do_edge = (wd > 0.0);
+ bool force_edge = (wd == 1.0);
+ wd = (wireStepParam.x * wd + wireStepParam.y);
+ return clamp(wd * float(do_edge) + float(force_edge), 0.0, 1.0);
}
-vec3 get_vertex_pos(uint id)
-{
- int v_id = int(id) * 5; /* See vertex format for explanation. */
- vec3 pos;
- pos.x = texelFetch(vertData, v_id).r;
- pos.y = texelFetch(vertData, v_id + 1).r;
- pos.z = texelFetch(vertData, v_id + 2).r;
- return pos;
-}
+/* Geometry shader version */
+#if defined(SELECT_EDGES) || defined(USE_SCULPT)
-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));
- return smoothstep(wireStepParam.x, wireStepParam.y, sharpness);
-}
-
-#ifdef USE_GEOM_SHADER
+in vec3 pos;
+in vec3 nor;
+in float wd; /* wiredata */
-# ifdef LIGHT_EDGES
-out vec3 obPos;
-out vec3 vNor;
-out float forceEdge;
-# endif
-out float facingOut; /* abs(facing) > 1.0 if we do edge */
+out float facing_g;
+out float edgeSharpness_g;
void main()
{
# ifndef USE_SCULPT
- uint v_id = texelFetch(faceIds, gl_VertexID).r;
-
- bool do_edge = (v_id & (1u << 30u)) != 0u;
- bool force_edge = (v_id & (1u << 31u)) != 0u;
- v_id = (v_id << 2u) >> 2u;
-
- vec3 pos = get_vertex_pos(v_id);
- vec3 nor = get_vertex_nor(v_id);
+ edgeSharpness_g = get_edge_sharpness(wd);
# else
- const bool do_edge = true;
- const bool force_edge = false;
+ /* TODO approximation using normals. */
+ edgeSharpness_g = 1.0;
# endif
- facingOut = normalize(NormalMatrix * nor).z;
- facingOut += (do_edge) ? ((facingOut > 0.0) ? 2.0 : -2.0) : 0.0;
-
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
-# ifdef LIGHT_EDGES
- obPos = pos;
- vNor = nor;
- forceEdge = float(force_edge); /* meh, could try to also encode it in facingOut */
-# endif
+ facing_g = normalize(NormalMatrix * nor).z;
}
-#else /* USE_GEOM_SHADER */
+#else /* SELECT_EDGES */
+
+/* Consecutive pos of the nth vertex
+ * Only valid for first vertex in the triangle.
+ * Assuming GL_FRIST_VERTEX_CONVENTION. */
+in vec3 pos0;
+in vec3 pos1;
+in vec3 pos2;
+in float wd0; /* wiredata */
+in float wd1;
+in float wd2;
+in vec3 nor;
-# ifdef LIGHT_EDGES
-flat out vec3 edgeSharpness;
-# endif
out float facing;
out vec3 barycentric;
+flat out vec3 edgeSharpness;
void main()
{
- int v_0 = (gl_VertexID / 3) * 3;
int v_n = gl_VertexID % 3;
- int v_n1 = (gl_VertexID + 1) % 3;
- int v_n2 = (gl_VertexID + 2) % 3;
-
- /* Getting the same positions for each of the 3 verts. */
- uvec3 v_id;
- v_id.x = texelFetch(faceIds, v_0).r;
- v_id.y = texelFetch(faceIds, v_0 + 1).r;
- v_id.z = texelFetch(faceIds, v_0 + 2).r;
-
- bvec3 do_edge, force_edge;
- do_edge.x = (v_id.x & (1u << 30u)) != 0u;
- do_edge.y = (v_id.y & (1u << 30u)) != 0u;
- do_edge.z = (v_id.z & (1u << 30u)) != 0u;
- force_edge.x = (v_id.x & (1u << 31u)) != 0u;
- force_edge.y = (v_id.y & (1u << 31u)) != 0u;
- force_edge.z = (v_id.z & (1u << 31u)) != 0u;
- v_id = (v_id << 2u) >> 2u;
-
- vec3 pos[3];
- vec4 p_pos[3];
-
- pos[v_n] = get_vertex_pos(v_id[v_n]);
- gl_Position = p_pos[v_n] = ModelViewProjectionMatrix * vec4(pos[v_n], 1.0);
-
- bvec3 bary = equal(ivec3(0, 1, 2), ivec3(v_n1));
- /* This is equivalent to component wise : (do_edge ? bary : 1.0) */
- barycentric = vec3(lessThanEqual(ivec3(do_edge), ivec3(bary)));
-
-# ifndef LIGHT_EDGES
- vec3 nor = get_vertex_nor(v_id[v_n]);
-# else
- p_pos[v_n1] = ModelViewProjectionMatrix * vec4(pos[v_n1], 1.0);
- p_pos[v_n2] = ModelViewProjectionMatrix * vec4(pos[v_n2], 1.0);
-
- pos[v_n1] = get_vertex_pos(v_id[v_n1]);
- pos[v_n2] = get_vertex_pos(v_id[v_n2]);
-
- 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
+
+ barycentric = vec3(equal(ivec3(2, 0, 1), ivec3(v_n)));
+
+ vec3 wb = vec3(wd0, wd1, wd2);
+ edgeSharpness = get_edge_sharpness(wb);
+
+ /* Don't generate any fragment if there is no edge to draw. */
+ vec3 pos = (!any(greaterThan(edgeSharpness, vec3(0.04))) && (v_n == 0)) ? pos1 : pos0;
+
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
facing = normalize(NormalMatrix * nor).z;
}
-#endif /* USE_GEOM_SHADER */
+#endif /* SELECT_EDGES */
diff --git a/source/blender/draw/modes/shaders/paint_wire_frag.glsl b/source/blender/draw/modes/shaders/paint_wire_frag.glsl
index b6637fea308..c5d6198fc21 100644
--- a/source/blender/draw/modes/shaders/paint_wire_frag.glsl
+++ b/source/blender/draw/modes/shaders/paint_wire_frag.glsl
@@ -11,6 +11,9 @@ void main()
discard;
}
+ /* Apply depth offset by taking slope and distance into account. */
+ gl_FragDepth = gl_FragCoord.z - mix(exp2(-10), exp2(-23), gl_FragCoord.z) - 2.0 * fwidth(gl_FragCoord.z);
+
#ifdef VERTEX_MODE
vec4 colSel = colorEdgeSelect;
colSel.rgb = clamp(colSel.rgb - 0.2, 0.0, 1.0);
diff --git a/source/blender/draw/modes/shaders/paint_wire_vert.glsl b/source/blender/draw/modes/shaders/paint_wire_vert.glsl
index 6a800e56d94..253c21745e2 100644
--- a/source/blender/draw/modes/shaders/paint_wire_vert.glsl
+++ b/source/blender/draw/modes/shaders/paint_wire_vert.glsl
@@ -10,8 +10,5 @@ void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
- /* Temp hack for william to start using blender 2.8 for icons. Will be removed by T54910 */
- gl_Position.z -= 0.0001;
-
finalFlag = data;
}
diff --git a/source/blender/draw/modes/shaders/particle_strand_frag.glsl b/source/blender/draw/modes/shaders/particle_strand_frag.glsl
index 7053ca43ae7..8bb213dbd30 100644
--- a/source/blender/draw/modes/shaders/particle_strand_frag.glsl
+++ b/source/blender/draw/modes/shaders/particle_strand_frag.glsl
@@ -1,12 +1,23 @@
-uniform mat4 ProjectionMatrix;
+uniform mat4 ModelViewProjectionMatrix;
+
+in vec4 finalColor;
+#ifdef USE_POINTS
+in vec2 radii;
+#endif
-in vec3 tangent;
-in vec3 viewPosition;
-flat in float colRand;
out vec4 fragColor;
void main()
{
- fragColor.rgb = tangent;
- fragColor.a = 1.0;
+ fragColor = finalColor;
+
+#ifdef USE_POINTS
+ float dist = length(gl_PointCoord - vec2(0.5));
+
+ fragColor.a = mix(finalColor.a, 0.0, smoothstep(radii[1], radii[0], dist));
+
+ if (fragColor.a == 0.0) {
+ discard;
+ }
+#endif
}
diff --git a/source/blender/draw/modes/shaders/particle_strand_vert.glsl b/source/blender/draw/modes/shaders/particle_strand_vert.glsl
index d4c35d14182..9db62a581cb 100644
--- a/source/blender/draw/modes/shaders/particle_strand_vert.glsl
+++ b/source/blender/draw/modes/shaders/particle_strand_vert.glsl
@@ -1,34 +1,73 @@
uniform mat4 ModelViewProjectionMatrix;
-uniform mat3 NormalMatrix;
-uniform mat4 ModelViewMatrix;
in vec3 pos;
-in vec3 nor;
-in int ind;
-out vec3 tangent;
-out vec3 viewPosition;
-flat out float colRand;
+in float color;
-float rand(int s)
+out vec4 finalColor;
+#ifdef USE_POINTS
+out vec2 radii;
+#endif
+
+vec3 weight_to_rgb(float weight)
{
- int seed = s * 1023423;
+ vec3 r_rgb;
+ float blend = ((weight / 2.0) + 0.5);
- seed = (seed ^ 61) ^ (seed >> 16);
- seed *= 9;
- seed = seed ^ (seed >> 4);
- seed *= 0x27d4eb2d;
- seed = seed ^ (seed >> 15);
+ if (weight <= 0.25) { /* blue->cyan */
+ r_rgb[0] = 0.0;
+ r_rgb[1] = blend * weight * 4.0;
+ r_rgb[2] = blend;
+ }
+ else if (weight <= 0.50) { /* cyan->green */
+ r_rgb[0] = 0.0;
+ r_rgb[1] = blend;
+ r_rgb[2] = blend * (1.0 - ((weight - 0.25) * 4.0));
+ }
+ else if (weight <= 0.75) { /* green->yellow */
+ r_rgb[0] = blend * ((weight - 0.50) * 4.0);
+ r_rgb[1] = blend;
+ r_rgb[2] = 0.0;
+ }
+ else if (weight <= 1.0) { /* yellow->red */
+ r_rgb[0] = blend;
+ r_rgb[1] = blend * (1.0 - ((weight - 0.75) * 4.0));
+ r_rgb[2] = 0.0;
+ }
+ else {
+ /* exceptional value, unclamped or nan,
+ * avoid uninitialized memory use */
+ r_rgb[0] = 1.0;
+ r_rgb[1] = 0.0;
+ r_rgb[2] = 1.0;
+ }
- float value = float(seed);
- value *= 1.0 / 42596.0;
- return fract(value);
+ return r_rgb;
}
+#define DECOMPRESS_RANGE 1.0039
+
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
- tangent = normalize(NormalMatrix * nor);
- viewPosition = (ModelViewMatrix * vec4(pos, 1.0)).xyz;
- colRand = rand(ind);
+
+#ifdef USE_WEIGHT
+ finalColor = vec4(weight_to_rgb(color * DECOMPRESS_RANGE), 1.0);
+#else
+ finalColor = mix(colorWire, colorEdgeSelect, color);
+#endif
+
+#ifdef USE_POINTS
+ gl_PointSize = sizeVertex;
+
+ /* calculate concentric radii in pixels */
+ float radius = 0.5 * sizeVertex;
+
+ /* start at the outside and progress toward the center */
+ radii[0] = radius;
+ radii[1] = radius - 1.0;
+
+ /* convert to PointCoord units */
+ radii /= sizeVertex;
+#endif
}
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 8896de75472..9bd7e277098 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -4055,7 +4055,7 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void
/* draw cache updates for settings that affect the visible strokes */
if (setting == ACHANNEL_SETTING_VISIBLE) {
bGPdata *gpd = (bGPdata *)ale_setting->id;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
/* UI updates */
@@ -4064,11 +4064,11 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void
/* tag copy-on-write flushing (so that the settings will have an effect) */
if (ale_setting->id) {
- DEG_id_tag_update(ale_setting->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(ale_setting->id, ID_RECALC_COPY_ON_WRITE);
}
if (ale_setting->adt && ale_setting->adt->action) {
/* action is it's own datablock, so has to be tagged specifically... */
- DEG_id_tag_update(&ale_setting->adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ale_setting->adt->action->id, ID_RECALC_COPY_ON_WRITE);
}
/* verify animation context */
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index c9b393601b2..b69d93aaacf 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -78,15 +78,15 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
adt = BKE_animdata_from_id(id);
if (adt) {
adt->recalc |= ADT_RECALC_ANIM;
- DEG_id_tag_update(id, OB_RECALC_TIME);
+ DEG_id_tag_update(id, ID_RECALC_ANIMATION);
if (adt->action != NULL) {
- DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE);
}
}
/* Tag copy on the main object if updating anything directly inside AnimData */
if (ELEM(ale->type, ANIMTYPE_ANIMDATA, ANIMTYPE_NLAACTION, ANIMTYPE_NLATRACK, ANIMTYPE_NLACURVE)) {
- DEG_id_tag_update(id, DEG_TAG_TIME | DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(id, ID_RECALC_ANIMATION | ID_RECALC_COPY_ON_WRITE);
return;
}
@@ -108,7 +108,7 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
else {
/* in other case we do standard depsgraph update, ideally
* we'd be calling property update functions here too ... */
- DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); // XXX or do we want something more restrictive?
+ DEG_id_tag_update(id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); // XXX or do we want something more restrictive?
}
}
@@ -124,7 +124,7 @@ void ANIM_id_update(Main *bmain, ID *id)
adt->recalc |= ADT_RECALC_ANIM;
/* set recalc flags */
- DEG_id_tag_update_ex(bmain, id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); // XXX or do we want something more restrictive?
+ DEG_id_tag_update_ex(bmain, id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); // XXX or do we want something more restrictive?
}
}
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 5f23762386e..2d528a0f0b9 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -1173,12 +1173,12 @@ static bool fcurve_has_errors(FCurve *fcu)
/* check variables for other things that need linting... */
// TODO: maybe it would be more efficient just to have a quick flag for this?
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
if (dtar->flag & DTAR_FLAG_INVALID)
return true;
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index f82250df4d3..9144c0b3dcc 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -1201,7 +1201,7 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
}
}
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
#else
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 85e58521493..ac57f77bac9 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -944,7 +944,7 @@ static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *
if (success) {
/* send updates */
UI_context_update_anim_flag(C);
- DEG_id_tag_update(ptr.id.data, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(ptr.id.data, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL);
}
@@ -1126,7 +1126,7 @@ static int paste_driver_button_exec(bContext *C, wmOperator *op)
UI_context_update_anim_flag(C);
DEG_relations_tag_update(CTX_data_main(C));
- DEG_id_tag_update(ptr.id.data, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(ptr.id.data, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); // XXX
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 4bf6c43e348..77dcc17c42a 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -165,7 +165,7 @@ bAction *verify_adt_action(Main *bmain, ID *id, short add)
DEG_relations_tag_update(bmain);
}
- DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE);
/* return the action */
return adt->action;
@@ -1178,10 +1178,10 @@ short insert_keyframe(
if (ret) {
if (act != NULL) {
- DEG_id_tag_update(&act->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&act->id, ID_RECALC_COPY_ON_WRITE);
}
if (adt != NULL && adt->action != NULL && adt->action != act) {
- DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE);
}
}
@@ -1302,7 +1302,13 @@ short delete_keyframe(Main *bmain, ReportList *reports, ID *id, bAction *act,
ret += delete_keyframe_fcurve(adt, fcu, cfra);
}
-
+ /* In the case last f-curve wes removed need to inform dependency graph
+ * about relations update, since it needs to get rid of animation operation
+ * for this datablock. */
+ if (ret && adt->action == NULL) {
+ DEG_id_tag_update_ex(bmain, id, ID_RECALC_COPY_ON_WRITE);
+ DEG_relations_tag_update(bmain);
+ }
/* return success/failure */
return ret;
}
@@ -1392,7 +1398,13 @@ static short clear_keyframe(Main *bmain, ReportList *reports, ID *id, bAction *a
/* return success */
ret++;
}
-
+ /* In the case last f-curve wes removed need to inform dependency graph
+ * about relations update, since it needs to get rid of animation operation
+ * for this datablock. */
+ if (ret && adt->action == NULL) {
+ DEG_id_tag_update_ex(bmain, id, ID_RECALC_COPY_ON_WRITE);
+ DEG_relations_tag_update(bmain);
+ }
/* return success/failure */
return ret;
}
@@ -1719,7 +1731,7 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
/* delete F-Curve completely */
if (can_delete) {
ANIM_fcurve_delete_from_animdata(NULL, adt, fcu);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
changed = true;
}
}
@@ -1826,7 +1838,7 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
else
BKE_reportf(op->reports, RPT_ERROR, "No keyframes removed from Object '%s'", id->name + 2);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
CTX_DATA_END;
@@ -2230,6 +2242,20 @@ bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
return false;
}
+/* Returns whether the current value of a given property differs from the interpolated value. */
+bool fcurve_is_changed(PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float frame)
+{
+ PathResolvedRNA anim_rna;
+ anim_rna.ptr = ptr;
+ anim_rna.prop = prop;
+ anim_rna.prop_index = fcu->array_index;
+
+ float fcurve_val = calculate_fcurve(&anim_rna, fcu, frame);
+ float cur_val = setting_get_rna_value(NULL, &ptr, prop, fcu->array_index, false);
+
+ return !compare_ff_relative(fcurve_val, cur_val, FLT_EPSILON, 64);
+}
+
/* Checks whether an Action has a keyframe for a given frame
* Since we're only concerned whether a keyframe exists, we can simply loop until a match is found...
*/
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index d8e9c5a7790..1fe8a34d166 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -1051,11 +1051,11 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
Object *ob = (Object *)ksp->id;
// XXX: only object transforms?
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
break;
}
default:
- DEG_id_tag_update(ksp->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(ksp->id, ID_RECALC_COPY_ON_WRITE);
break;
}
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index 4ddbb9fb9c5..0b39fe22e47 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -131,7 +131,6 @@ EditBone *ED_armature_ebone_add_primitive(Object *obedit_arm, float length, bool
*/
static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
{
- View3D *v3d;
bArmature *arm;
EditBone *ebone, *newbone, *flipbone;
float mat[3][3], imat[3][3];
@@ -140,7 +139,6 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene;
scene = CTX_data_scene(C);
- v3d = CTX_wm_view3d(C);
obedit = CTX_data_edit_object(C);
arm = obedit->data;
@@ -196,7 +194,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
newbone->flag |= BONE_CONNECTED;
}
- const View3DCursor *curs = ED_view3d_cursor3d_get(scene, v3d);
+ const View3DCursor *curs = &scene->cursor;
copy_v3_v3(newbone->tail, curs->location);
sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);
@@ -236,7 +234,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, const wmEv
ar = CTX_wm_region(C);
v3d = CTX_wm_view3d(C);
- View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
+ View3DCursor *cursor = &scene->cursor;
copy_v3_v3(oldcurs, cursor->location);
@@ -490,7 +488,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
EditBone *ebone_iter;
EditBone *ebone_first_dupe = NULL; /* The beginning of the duplicated bones in the edbo list */
@@ -645,7 +643,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op)
}
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
bArmature *arm = obedit->data;
@@ -872,7 +870,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
bool changed_multi = false;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
@@ -1063,7 +1061,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "name", name);
- copy_v3_v3(curs, ED_view3d_cursor3d_get(CTX_data_scene(C), CTX_wm_view3d(C))->location);
+ copy_v3_v3(curs, CTX_data_scene(C)->cursor.location);
/* Get inverse point for head and orientation for tail */
invert_m4_m4(obedit->imat, obedit->obmat);
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 6d624f6746e..e44c1b02f22 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -306,7 +306,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
(type >= CALC_ROLL_TAN_NEG_X) ? true : false);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
@@ -325,9 +325,8 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
if (type == CALC_ROLL_CURSOR) { /* Cursor */
Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
float cursor_local[3];
- const View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
+ const View3DCursor *cursor = &scene->cursor;
invert_m4_m4(ob->imat, ob->obmat);
copy_v3_v3(cursor_local, cursor->location);
@@ -490,7 +489,7 @@ static int armature_roll_clear_exec(bContext *C, wmOperator *op)
const float roll = RNA_float_get(op->ptr, "roll");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
@@ -710,7 +709,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
Object *obedit = NULL;
{
ViewLayer *view_layer = CTX_data_view_layer(C);
- FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_EDIT, ob_iter) {
+ FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (view_layer, v3d, ob_iter) {
if (ob_iter->data == arm) {
obedit = ob_iter;
}
@@ -728,7 +727,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
/* Get points - cursor (tail) */
invert_m4_m4(obedit->imat, obedit->obmat);
- mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d)->location);
+ mul_v3_m4v3(curs, obedit->imat, scene->cursor.location);
/* Create a bone */
newbone = add_points_bone(obedit, ebp->vec, curs);
@@ -766,7 +765,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
/* get cursor location */
invert_m4_m4(obedit->imat, obedit->obmat);
- mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d)->location);
+ mul_v3_m4v3(curs, obedit->imat, scene->cursor.location);
/* get distances */
dist_sq_a = len_squared_v3v3(ebp_a->vec, curs);
@@ -948,7 +947,7 @@ static int armature_merge_exec(bContext *C, wmOperator *op)
const short type = RNA_enum_get(op->ptr, "type");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -1072,7 +1071,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
@@ -1326,7 +1325,7 @@ static int armature_split_exec(bContext *C, wmOperator *UNUSED(op))
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
@@ -1387,7 +1386,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
bArmature *arm = obedit->data;
@@ -1458,7 +1457,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op))
bool changed_multi = false;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
bArmature *arm = obedit->data;
@@ -1626,7 +1625,7 @@ static int armature_hide_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
bArmature *arm = obedit->data;
@@ -1677,7 +1676,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
const bool select = RNA_boolean_get(op->ptr, "select");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
bArmature *arm = obedit->data;
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index 3d5ed47655c..a027b00f3e1 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -182,7 +182,7 @@ void ED_armature_bone_rename(Main *bmain, bArmature *arm, const char *oldnamep,
}
/* force copy on write to update database */
- DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE);
/* do entire dbase - objects */
for (ob = bmain->object.first; ob; ob = ob->id.next) {
@@ -313,7 +313,7 @@ void ED_armature_bone_rename(Main *bmain, bArmature *arm, const char *oldnamep,
}
}
}
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
/* Fix all animdata that may refer to this bone - we can't just do the ones attached to objects, since
@@ -411,7 +411,7 @@ static int armature_flip_names_exec(bContext *C, wmOperator *op)
const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
@@ -447,7 +447,7 @@ static int armature_flip_names_exec(bContext *C, wmOperator *op)
BLI_freelistN(&bones_names);
/* since we renamed stuff... */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
/* copied from #rna_Bone_update_renamed */
/* redraw view */
@@ -490,7 +490,7 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op)
bool changed_multi = false;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
@@ -532,7 +532,7 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op)
changed_multi = true;
/* Since we renamed stuff... */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
/* Note, notifier might evolve. */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 28bab00e665..aadb805feda 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -166,7 +166,7 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data
/* Fix driver references to invalid ID's */
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
/* only change the used targets, since the others will need fixing manually anyway */
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
/* change the ID's used... */
if (dtar->id == src_id) {
@@ -199,7 +199,7 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data
}
}
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
}
@@ -403,7 +403,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
return OPERATOR_FINISHED;
@@ -587,7 +587,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
WM_cursor_wait(1);
uint bases_len = 0;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, &bases_len);
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &bases_len);
CTX_DATA_BEGIN(C, Base *, base, visible_bases)
{
@@ -638,8 +638,8 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
/* 4) fix links before depsgraph flushes */ // err... or after?
separated_armature_fix_links(bmain, oldob, newob);
- DEG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */
- DEG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */
+ DEG_id_tag_update(&oldob->id, ID_RECALC_GEOMETRY); /* this is the original one */
+ DEG_id_tag_update(&newob->id, ID_RECALC_GEOMETRY); /* this is the separated one */
/* 5) restore original conditions */
@@ -897,7 +897,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 216d068558d..d817fbf5229 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -268,11 +268,11 @@ void *get_nearest_bone(
if (vc.obedit != NULL) {
bases = BKE_view_layer_array_from_bases_in_mode(
- vc.view_layer, &bases_len, {
+ vc.view_layer, vc.v3d, &bases_len, {
.object_mode = OB_MODE_EDIT});
}
else {
- bases = BKE_object_pose_base_array_get(vc.view_layer, &bases_len);
+ bases = BKE_object_pose_base_array_get(vc.view_layer, vc.v3d, &bases_len);
}
void *bone = get_bone_from_selectbuffer(
@@ -286,12 +286,11 @@ void *get_nearest_bone(
/* **************** EditMode stuff ********************** */
-/* called in space.c */
-/* previously "selectconnected_armature" */
-static int armature_select_linked_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
bArmature *arm;
EditBone *bone, *curBone, *next;
+ const bool sel = !RNA_boolean_get(op->ptr, "deselect");
view3d_operator_needs_opengl(C);
@@ -306,7 +305,12 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *UNUSED(op), co
/* Select parents */
for (curBone = bone; curBone; curBone = next) {
if ((curBone->flag & BONE_UNSELECTABLE) == 0) {
- curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ if (sel) {
+ curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ }
+ else {
+ curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ }
}
if (curBone->flag & BONE_CONNECTED)
@@ -321,7 +325,12 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *UNUSED(op), co
next = curBone->next;
if ((curBone->parent == bone) && (curBone->flag & BONE_UNSELECTABLE) == 0) {
if (curBone->flag & BONE_CONNECTED) {
- curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ if (sel) {
+ curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ }
+ else {
+ curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ }
bone = curBone;
break;
}
@@ -361,6 +370,8 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "");
}
/* utility function for get_nearest_editbonepoint */
@@ -470,7 +481,7 @@ cache_end:
view3d_opengl_select_cache_end();
uint bases_len;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc->view_layer, &bases_len);
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc->view_layer, vc->v3d, &bases_len);
/* See if there are any selected bones in this group */
if (hits > 0) {
@@ -630,7 +641,7 @@ bool ED_armature_edit_select_pick(bContext *C, const int mval[2], bool extend, b
if (!extend && !deselect && !toggle) {
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &objects_len);
ED_armature_edit_deselect_all_multi(objects, objects_len);
MEM_freeN(objects);
}
@@ -886,7 +897,7 @@ static int armature_de_select_more_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
armature_select_more_less(ob, true);
@@ -915,7 +926,7 @@ static int armature_de_select_less_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
armature_select_more_less(ob, false);
@@ -987,7 +998,7 @@ static void select_similar_length(bContext *C, const float thresh)
const float len_max = len * (1.0f + (thresh + FLT_EPSILON));
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
@@ -1035,7 +1046,7 @@ static void select_similar_direction(bContext *C, const float thresh)
bone_direction_worldspace_get(ob_act, ebone_act, dir_act);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
@@ -1066,7 +1077,7 @@ static void select_similar_layer(bContext *C)
EditBone *ebone_act = CTX_data_active_bone(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
@@ -1103,7 +1114,7 @@ static void select_similar_prefix(bContext *C)
}
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
@@ -1142,7 +1153,7 @@ static void select_similar_suffix(bContext *C)
return;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
@@ -1452,7 +1463,7 @@ static int armature_select_mirror_exec(bContext *C, wmOperator *op)
const bool extend = RNA_boolean_get(op->ptr, "extend");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index c68c2720b0b..462c17e9008 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -53,6 +53,7 @@
#include "BKE_subsurf.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "ED_armature.h"
#include "ED_mesh.h"
@@ -249,7 +250,7 @@ static void envelope_bone_weighting(
}
static void add_verts_to_dgroups(
- ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, Object *par,
+ ReportList *reports, Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob, Object *par,
int heat, const bool mirror)
{
/* This functions implements the automatic computation of vertex group
@@ -325,7 +326,7 @@ static void add_verts_to_dgroups(
if ((par->pose) && (pchan = BKE_pose_channel_find_name(par->pose, bone->name))) {
if (bone->segments > 1) {
segments = bone->segments;
- b_bone_spline_setup(pchan, true, bbone_array);
+ BKE_pchan_bbone_spline_setup(pchan, true, bbone_array);
bbone = bbone_array;
}
}
@@ -375,7 +376,9 @@ static void add_verts_to_dgroups(
if (wpmode) {
/* if in weight paint mode, use final verts from evaluated mesh */
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
BKE_mesh_foreach_mapped_vert_coords_get(me_eval, verts, mesh->totvert);
vertsfilled = 1;
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
deleted file mode 100644
index 0c770bcbcc4..00000000000
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ /dev/null
@@ -1,2644 +0,0 @@
-/*
- * ***** 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): Martin Poirier
- *
- * ***** END GPL LICENSE BLOCK *****
- * autoarmature.c: Interface for automagically manipulating armature (retarget, created, ...)
- */
-
-/** \file blender/editors/armature/editarmature_retarget.c
- * \ingroup edarmature
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "PIL_time.h"
-
-#include "DNA_armature_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_object_types.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-
-#include "BKE_constraint.h"
-#include "BKE_armature.h"
-#include "BKE_context.h"
-#include "BKE_main.h"
-
-#include "ED_armature.h"
-#include "ED_undo.h"
-
-#include "BIF_retarget.h"
-
-#include "armature_intern.h"
-
-/************ RIG RETARGET DATA STRUCTURES ***************/
-
-typedef struct MemoNode {
- float weight;
- int next;
-} MemoNode;
-
-typedef struct RetargetParam {
- RigGraph *rigg;
- RigArc *iarc;
- RigNode *inode_start;
- bContext *context;
-} RetargetParam;
-
-typedef enum {
- RETARGET_LENGTH,
- RETARGET_AGGRESSIVE
-} RetargetMode;
-
-typedef enum {
- METHOD_BRUTE_FORCE = 0,
- METHOD_MEMOIZE = 1
-} RetargetMethod;
-
-typedef enum {
- ARC_FREE = 0,
- ARC_TAKEN = 1,
- ARC_USED = 2
-} ArcUsageFlags;
-
-static RigGraph *GLOBAL_RIGG = NULL;
-
-/*******************************************************************************************************/
-
-void exec_retargetArctoArc(TaskPool * __restrict pool, void *taskdata, int threadid);
-
-static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second);
-float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]);
-
-/* two levels */
-#define SHAPE_LEVELS (SHAPE_RADIX * SHAPE_RADIX)
-
-/*********************************** EDITBONE UTILS ****************************************************/
-
-static int countEditBoneChildren(ListBase *list, EditBone *parent)
-{
- EditBone *ebone;
- int count = 0;
-
- for (ebone = list->first; ebone; ebone = ebone->next) {
- if (ebone->parent == parent) {
- count++;
- }
- }
-
- return count;
-}
-
-static EditBone *nextEditBoneChild(ListBase *list, EditBone *parent, int n)
-{
- EditBone *ebone;
-
- for (ebone = list->first; ebone; ebone = ebone->next) {
- if (ebone->parent == parent) {
- if (n == 0) {
- return ebone;
- }
- n--;
- }
- }
-
- return NULL;
-}
-
-static void getEditBoneRollUpAxis(EditBone *bone, float roll, float up_axis[3])
-{
- float mat[3][3], nor[3];
-
- sub_v3_v3v3(nor, bone->tail, bone->head);
-
- vec_roll_to_mat3(nor, roll, mat);
- copy_v3_v3(up_axis, mat[2]);
-}
-
-static float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float qrot[4], float qroll[4], float aligned_axis[3])
-{
- float nor[3], new_up_axis[3], x_axis[3], z_axis[3];
-
- copy_v3_v3(new_up_axis, old_up_axis);
- mul_qt_v3(qrot, new_up_axis);
-
- sub_v3_v3v3(nor, bone->tail, bone->head);
-
- cross_v3_v3v3(x_axis, nor, aligned_axis);
- cross_v3_v3v3(z_axis, x_axis, nor);
-
- normalize_v3(new_up_axis);
- normalize_v3(x_axis);
- normalize_v3(z_axis);
-
- if (dot_v3v3(new_up_axis, x_axis) < 0) {
- negate_v3(x_axis);
- }
-
- if (dot_v3v3(new_up_axis, z_axis) < 0) {
- negate_v3(z_axis);
- }
-
- if (angle_normalized_v3v3(x_axis, new_up_axis) < angle_normalized_v3v3(z_axis, new_up_axis)) {
- rotation_between_vecs_to_quat(qroll, new_up_axis, x_axis); /* set roll rotation quat */
- return ED_armature_ebone_roll_to_vector(bone, x_axis, false);
- }
- else {
- rotation_between_vecs_to_quat(qroll, new_up_axis, z_axis); /* set roll rotation quat */
- return ED_armature_ebone_roll_to_vector(bone, z_axis, false);
- }
-}
-
-static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4], float qroll[4], float up_axis[3])
-{
- if (previous == NULL) {
- /* default to up_axis if no previous */
- return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis);
- }
- else {
- float new_up_axis[3];
- float vec_first[3], vec_second[3], normal[3];
-
- if (previous->bone) {
- sub_v3_v3v3(vec_first, previous->bone->tail, previous->bone->head);
- }
- else if (previous->prev->bone) {
- sub_v3_v3v3(vec_first, edge->bone->head, previous->prev->bone->tail);
- }
- else {
- /* default to up_axis if first bone in the chain is an offset */
- return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis);
- }
-
- sub_v3_v3v3(vec_second, edge->bone->tail, edge->bone->head);
-
- normalize_v3(vec_first);
- normalize_v3(vec_second);
-
- cross_v3_v3v3(normal, vec_first, vec_second);
- normalize_v3(normal);
-
- axis_angle_to_quat(qroll, vec_second, edge->up_angle);
-
- mul_qt_v3(qroll, normal);
-
- copy_v3_v3(new_up_axis, edge->up_axis);
- mul_qt_v3(qrot, new_up_axis);
-
- normalize_v3(new_up_axis);
-
- /* real qroll between normal and up_axis */
- rotation_between_vecs_to_quat(qroll, new_up_axis, normal);
-
- return ED_armature_ebone_roll_to_vector(edge->bone, normal, false);
- }
-}
-
-float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4])
-{
- float new_up_axis[3];
-
- copy_v3_v3(new_up_axis, old_up_axis);
- mul_qt_v3(qrot, new_up_axis);
-
- return ED_armature_ebone_roll_to_vector(bone, new_up_axis, false);
-}
-
-/************************************ DESTRUCTORS ******************************************************/
-
-static void RIG_freeRigArc(BArc *arc)
-{
- BLI_freelistN(&((RigArc *)arc)->edges);
-}
-
-void RIG_freeRigGraph(BGraph *rg)
-{
- RigGraph *rigg = (RigGraph *)rg;
- BNode *node;
- BArc *arc;
-
- BLI_task_pool_free(rigg->task_pool);
- BLI_task_scheduler_free(rigg->task_scheduler);
-
- if (rigg->link_mesh) {
- REEB_freeGraph(rigg->link_mesh);
- }
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RIG_freeRigArc(arc);
- }
- BLI_freelistN(&rg->arcs);
-
- for (node = rg->nodes.first; node; node = node->next) {
- BLI_freeNode(rg, (BNode *)node);
- }
- BLI_freelistN(&rg->nodes);
-
- BLI_freelistN(&rigg->controls);
-
- BLI_ghash_free(rigg->bones_map, NULL, NULL);
- BLI_ghash_free(rigg->controls_map, NULL, NULL);
-
- if (rigg->flag & RIG_FREE_BONELIST) {
- BLI_freelistN(rigg->editbones);
- MEM_freeN(rigg->editbones);
- }
-
- MEM_freeN(rg);
-}
-
-/************************************* ALLOCATORS ******************************************************/
-
-static RigGraph *newRigGraph(void)
-{
- RigGraph *rg;
- int totthread;
-
- rg = MEM_callocN(sizeof(RigGraph), "rig graph");
-
- rg->head = NULL;
-
- rg->bones_map = BLI_ghash_str_new("newRigGraph bones gh");
- rg->controls_map = BLI_ghash_str_new("newRigGraph cont gh");
-
- rg->free_arc = RIG_freeRigArc;
- rg->free_node = NULL;
-
-#ifdef USE_THREADS
- totthread = TASK_SCHEDULER_AUTO_THREADS;
-#else
- totthread = TASK_SCHEDULER_SINGLE_THREAD;
-#endif
-
- rg->task_scheduler = BLI_task_scheduler_create(totthread);
- rg->task_pool = BLI_task_pool_create(rg->task_scheduler, NULL);
-
- return rg;
-}
-
-static RigArc *newRigArc(RigGraph *rg)
-{
- RigArc *arc;
-
- arc = MEM_callocN(sizeof(RigArc), "rig arc");
- arc->count = 0;
- BLI_addtail(&rg->arcs, arc);
-
- return arc;
-}
-
-static RigControl *newRigControl(RigGraph *rg)
-{
- RigControl *ctrl;
-
- ctrl = MEM_callocN(sizeof(RigControl), "rig control");
-
- BLI_addtail(&rg->controls, ctrl);
-
- return ctrl;
-}
-
-static RigNode *newRigNodeHead(RigGraph *rg, RigArc *arc, float p[3])
-{
- RigNode *node;
- node = MEM_callocN(sizeof(RigNode), "rig node");
- BLI_addtail(&rg->nodes, node);
-
- copy_v3_v3(node->p, p);
- node->degree = 1;
- node->arcs = NULL;
-
- arc->head = node;
-
- return node;
-}
-
-static void addRigNodeHead(RigGraph *UNUSED(rg), RigArc *arc, RigNode *node)
-{
- node->degree++;
-
- arc->head = node;
-}
-
-static RigNode *newRigNode(RigGraph *rg, float p[3])
-{
- RigNode *node;
- node = MEM_callocN(sizeof(RigNode), "rig node");
- BLI_addtail(&rg->nodes, node);
-
- copy_v3_v3(node->p, p);
- node->degree = 0;
- node->arcs = NULL;
-
- return node;
-}
-
-static RigNode *newRigNodeTail(RigGraph *rg, RigArc *arc, float p[3])
-{
- RigNode *node = newRigNode(rg, p);
-
- node->degree = 1;
- arc->tail = node;
-
- return node;
-}
-
-static void RIG_appendEdgeToArc(RigArc *arc, RigEdge *edge)
-{
- BLI_addtail(&arc->edges, edge);
-
- if (edge->prev == NULL) {
- copy_v3_v3(edge->head, arc->head->p);
- }
- else {
- RigEdge *last_edge = edge->prev;
- copy_v3_v3(edge->head, last_edge->tail);
- RIG_calculateEdgeAngles(last_edge, edge);
- }
-
- edge->length = len_v3v3(edge->head, edge->tail);
-
- arc->length += edge->length;
-
- arc->count += 1;
-}
-
-static void RIG_addEdgeToArc(RigArc *arc, float tail[3], EditBone *bone)
-{
- RigEdge *edge;
-
- edge = MEM_callocN(sizeof(RigEdge), "rig edge");
-
- copy_v3_v3(edge->tail, tail);
- edge->bone = bone;
-
- if (bone) {
- getEditBoneRollUpAxis(bone, bone->roll, edge->up_axis);
- }
-
- RIG_appendEdgeToArc(arc, edge);
-}
-/************************************** CLONING TEMPLATES **********************************************/
-
-static void renameTemplateBone(char *name, char *template_name, ListBase *editbones, char *side_string, char *num_string)
-{
- int i, j;
-
- for (i = 0, j = 0; i < (MAXBONENAME - 1) && j < (MAXBONENAME - 1) && template_name[i] != '\0'; i++) {
- if (template_name[i] == '&') {
- if (template_name[i + 1] == 'S' || template_name[i + 1] == 's') {
- j += BLI_strncpy_rlen(name + j, side_string, MAXBONENAME);
- i++;
- }
- else if (template_name[i + 1] == 'N' || template_name[i + 1] == 'n') {
- j += BLI_strncpy_rlen(name + j, num_string, MAXBONENAME);
- i++;
- }
- else {
- name[j] = template_name[i];
- j++;
- }
- }
- else {
- name[j] = template_name[i];
- j++;
- }
- }
-
- name[j] = '\0';
-
- ED_armature_ebone_unique_name(editbones, name, NULL);
-}
-
-static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_ctrl, GHash *ptr_hash, char *side_string, char *num_string)
-{
- RigControl *ctrl;
- char name[MAXBONENAME];
-
- ctrl = newRigControl(rg);
-
- copy_v3_v3(ctrl->head, src_ctrl->head);
- copy_v3_v3(ctrl->tail, src_ctrl->tail);
- copy_v3_v3(ctrl->up_axis, src_ctrl->up_axis);
- copy_v3_v3(ctrl->offset, src_ctrl->offset);
-
- ctrl->tail_mode = src_ctrl->tail_mode;
- ctrl->flag = src_ctrl->flag;
-
- renameTemplateBone(name, src_ctrl->bone->name, rg->editbones, side_string, num_string);
- ctrl->bone = duplicateEditBoneObjects(src_ctrl->bone, name, rg->editbones, src_rg->ob, rg->ob);
- ctrl->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
- BLI_ghash_insert(ptr_hash, src_ctrl->bone, ctrl->bone);
-
- ctrl->link = src_ctrl->link;
- ctrl->link_tail = src_ctrl->link_tail;
-
- return ctrl;
-}
-
-static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash *ptr_hash, char *side_string, char *num_string)
-{
- RigEdge *src_edge;
- RigArc *arc;
-
- arc = newRigArc(rg);
-
- arc->head = BLI_ghash_lookup(ptr_hash, src_arc->head);
- arc->tail = BLI_ghash_lookup(ptr_hash, src_arc->tail);
-
- arc->head->degree++;
- arc->tail->degree++;
-
- arc->length = src_arc->length;
-
- arc->count = src_arc->count;
-
- for (src_edge = src_arc->edges.first; src_edge; src_edge = src_edge->next) {
- RigEdge *edge;
-
- edge = MEM_callocN(sizeof(RigEdge), "rig edge");
-
- copy_v3_v3(edge->head, src_edge->head);
- copy_v3_v3(edge->tail, src_edge->tail);
- copy_v3_v3(edge->up_axis, src_edge->up_axis);
-
- edge->length = src_edge->length;
- edge->angle = src_edge->angle;
- edge->up_angle = src_edge->up_angle;
-
- if (src_edge->bone != NULL) {
- char name[MAXBONENAME];
- renameTemplateBone(name, src_edge->bone->name, rg->editbones, side_string, num_string);
- edge->bone = duplicateEditBoneObjects(src_edge->bone, name, rg->editbones, src_rg->ob, rg->ob);
- edge->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
- BLI_ghash_insert(ptr_hash, src_edge->bone, edge->bone);
- }
-
- BLI_addtail(&arc->edges, edge);
- }
-
- return arc;
-}
-
-static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, char *side_string, char *num_string)
-{
- GHash *ptr_hash;
- RigNode *node;
- RigArc *arc;
- RigControl *ctrl;
- RigGraph *rg;
-
- ptr_hash = BLI_ghash_ptr_new("cloneRigGraph gh");
-
- rg = newRigGraph();
-
- rg->ob = ob;
- rg->editbones = editbones;
-
- preEditBoneDuplicate(rg->editbones); /* prime bones for duplication */
- preEditBoneDuplicate(src->editbones); /* prime bones for duplication */
-
- /* Clone nodes */
- for (node = src->nodes.first; node; node = node->next) {
- RigNode *cloned_node = newRigNode(rg, node->p);
- BLI_ghash_insert(ptr_hash, node, cloned_node);
- }
-
- rg->head = BLI_ghash_lookup(ptr_hash, src->head);
-
- /* Clone arcs */
- for (arc = src->arcs.first; arc; arc = arc->next) {
- cloneArc(rg, src, arc, ptr_hash, side_string, num_string);
- }
-
- /* Clone controls */
- for (ctrl = src->controls.first; ctrl; ctrl = ctrl->next) {
- cloneControl(rg, src, ctrl, ptr_hash, side_string, num_string);
- }
-
- /* Relink bones properly */
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RigEdge *edge;
-
- for (edge = arc->edges.first; edge; edge = edge->next) {
- if (edge->bone != NULL) {
- EditBone *bone;
-
- updateDuplicateSubtargetObjects(edge->bone, src->editbones, src->ob, rg->ob);
-
- if (edge->bone->parent) {
- bone = BLI_ghash_lookup(ptr_hash, edge->bone->parent);
-
- if (bone != NULL) {
- edge->bone->parent = bone;
- }
- else {
- /* disconnect since parent isn't cloned
- * this will only happen when cloning from selected bones
- * */
- edge->bone->flag &= ~BONE_CONNECTED;
- }
- }
- }
- }
- }
-
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
- EditBone *bone;
-
- updateDuplicateSubtargetObjects(ctrl->bone, src->editbones, src->ob, rg->ob);
-
- if (ctrl->bone->parent) {
- bone = BLI_ghash_lookup(ptr_hash, ctrl->bone->parent);
-
- if (bone != NULL) {
- ctrl->bone->parent = bone;
- }
- else {
- /* disconnect since parent isn't cloned
- * this will only happen when cloning from selected bones
- * */
- ctrl->bone->flag &= ~BONE_CONNECTED;
- }
- }
-
- ctrl->link = BLI_ghash_lookup(ptr_hash, ctrl->link);
- ctrl->link_tail = BLI_ghash_lookup(ptr_hash, ctrl->link_tail);
- }
-
- BLI_ghash_free(ptr_hash, NULL, NULL);
-
- return rg;
-}
-
-
-/*******************************************************************************************************/
-
-static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second)
-{
- float vec_first[3], vec_second[3];
-
- sub_v3_v3v3(vec_first, edge_first->tail, edge_first->head);
- sub_v3_v3v3(vec_second, edge_second->tail, edge_second->head);
-
- normalize_v3(vec_first);
- normalize_v3(vec_second);
-
- edge_first->angle = angle_normalized_v3v3(vec_first, vec_second);
-
- if (edge_second->bone != NULL) {
- float normal[3];
-
- cross_v3_v3v3(normal, vec_first, vec_second);
- normalize_v3(normal);
-
- edge_second->up_angle = angle_normalized_v3v3(normal, edge_second->up_axis);
- }
-}
-
-/************************************ CONTROL BONES ****************************************************/
-
-static void RIG_addControlBone(RigGraph *rg, EditBone *bone)
-{
- RigControl *ctrl = newRigControl(rg);
- ctrl->bone = bone;
- copy_v3_v3(ctrl->head, bone->head);
- copy_v3_v3(ctrl->tail, bone->tail);
- getEditBoneRollUpAxis(bone, bone->roll, ctrl->up_axis);
- ctrl->tail_mode = TL_NONE;
-
- BLI_ghash_insert(rg->controls_map, bone->name, ctrl);
-}
-
-static int RIG_parentControl(RigControl *ctrl, EditBone *link)
-{
- if (link) {
- float offset[3];
- int flag = 0;
-
- sub_v3_v3v3(offset, ctrl->bone->head, link->head);
-
- /* if root matches, check for direction too */
- if (dot_v3v3(offset, offset) < 0.0001f) {
- float vbone[3], vparent[3];
-
- flag |= RIG_CTRL_FIT_ROOT;
-
- sub_v3_v3v3(vbone, ctrl->bone->tail, ctrl->bone->head);
- sub_v3_v3v3(vparent, link->tail, link->head);
-
- /* test for opposite direction */
- if (dot_v3v3(vbone, vparent) > 0) {
- float nor[3];
- float len;
-
- cross_v3_v3v3(nor, vbone, vparent);
-
- len = dot_v3v3(nor, nor);
- if (len < 0.0001f) {
- flag |= RIG_CTRL_FIT_BONE;
- }
- }
- }
-
- /* Bail out if old one is automatically better */
- if (flag < ctrl->flag) {
- return 0;
- }
-
- /* if there's already a link
- * overwrite only if new link is higher in the chain */
- if (ctrl->link && flag == ctrl->flag) {
- EditBone *bone = NULL;
-
- for (bone = ctrl->link; bone; bone = bone->parent) {
- /* if link is in the chain, break and use that one */
- if (bone == link) {
- break;
- }
- }
-
- /* not in chain, don't update link */
- if (bone == NULL) {
- return 0;
- }
- }
-
-
- ctrl->link = link;
- ctrl->flag = flag;
-
- copy_v3_v3(ctrl->offset, offset);
-
- return 1;
- }
-
- return 0;
-}
-
-static void RIG_reconnectControlBones(RigGraph *rg)
-{
- RigControl *ctrl;
- bool changed = true;
-
- /* first pass, link to deform bones */
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
- bPoseChannel *pchan;
- bConstraint *con;
- int found = 0;
-
- /* DO SOME MAGIC HERE */
- for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- for (con = pchan->constraints.first; con; con = con->next) {
- const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
- ListBase targets = {NULL, NULL};
- bConstraintTarget *ct;
-
- /* constraint targets */
- if (cti && cti->get_constraint_targets) {
- int target_index;
-
- cti->get_constraint_targets(con, &targets);
-
- for (target_index = 0, ct = targets.first; ct; target_index++, ct = ct->next) {
- if ((ct->tar == rg->ob) && STREQ(ct->subtarget, ctrl->bone->name)) {
- /* SET bone link to bone corresponding to pchan */
- EditBone *link = BLI_ghash_lookup(rg->bones_map, pchan->name);
-
- /* Making sure bone is in this armature */
- if (link != NULL) {
- /* for pole targets, link to parent bone instead, if possible */
- if (con->type == CONSTRAINT_TYPE_KINEMATIC && target_index == 1) {
- if (link->parent && BLI_ghash_haskey(rg->bones_map, link->parent->name)) {
- link = link->parent;
- }
- }
-
- found = RIG_parentControl(ctrl, link);
- }
- }
- }
-
- if (cti->flush_constraint_targets)
- cti->flush_constraint_targets(con, &targets, 0);
- }
- }
- }
-
- /* if not found yet, check parent */
- if (found == 0) {
- if (ctrl->bone->parent) {
- /* make sure parent is a deforming bone
- * NULL if not
- * */
- EditBone *link = BLI_ghash_lookup(rg->bones_map, ctrl->bone->parent->name);
-
- found = RIG_parentControl(ctrl, link);
- }
-
- /* check if bone is not superposed on another one */
- {
- RigArc *arc;
- RigArc *best_arc = NULL;
- EditBone *link = NULL;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RigEdge *edge;
- for (edge = arc->edges.first; edge; edge = edge->next) {
- if (edge->bone) {
- int fit = 0;
-
- fit = len_v3v3(ctrl->bone->head, edge->bone->head) < 0.0001f;
- fit = fit || len_v3v3(ctrl->bone->tail, edge->bone->tail) < 0.0001f;
-
- if (fit) {
- /* pick the bone on the arc with the lowest symmetry level
- * means you connect control to the trunk of the skeleton */
- if (best_arc == NULL || arc->symmetry_level < best_arc->symmetry_level) {
- best_arc = arc;
- link = edge->bone;
- }
- }
- }
- }
- }
-
- found = RIG_parentControl(ctrl, link);
- }
- }
-
- /* if not found yet, check child */
- if (found == 0) {
- RigArc *arc;
- RigArc *best_arc = NULL;
- EditBone *link = NULL;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RigEdge *edge;
- for (edge = arc->edges.first; edge; edge = edge->next) {
- if (edge->bone && edge->bone->parent == ctrl->bone) {
- /* pick the bone on the arc with the lowest symmetry level
- * means you connect control to the trunk of the skeleton */
- if (best_arc == NULL || arc->symmetry_level < best_arc->symmetry_level) {
- best_arc = arc;
- link = edge->bone;
- }
- }
- }
- }
-
- found = RIG_parentControl(ctrl, link);
- }
-
- }
-
-
- /* second pass, make chains in control bones */
- while (changed) {
- changed = false;
-
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
- /* if control is not linked yet */
- if (ctrl->link == NULL) {
- bPoseChannel *pchan;
- bConstraint *con;
- RigControl *ctrl_parent = NULL;
- RigControl *ctrl_child;
- int found = 0;
-
- if (ctrl->bone->parent) {
- ctrl_parent = BLI_ghash_lookup(rg->controls_map, ctrl->bone->parent->name);
- }
-
- /* check constraints first */
-
- /* DO SOME MAGIC HERE */
- for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- for (con = pchan->constraints.first; con; con = con->next) {
- const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
- ListBase targets = {NULL, NULL};
- bConstraintTarget *ct;
-
- /* constraint targets */
- if (cti && cti->get_constraint_targets) {
- cti->get_constraint_targets(con, &targets);
-
- for (ct = targets.first; ct; ct = ct->next) {
- if ((ct->tar == rg->ob) && STREQ(ct->subtarget, ctrl->bone->name)) {
- /* SET bone link to ctrl corresponding to pchan */
- RigControl *link = BLI_ghash_lookup(rg->controls_map, pchan->name);
-
- /* if owner is a control bone, link with it */
- if (link && link->link) {
- RIG_parentControl(ctrl, link->bone);
- found = 1;
- break;
- }
- }
- }
-
- if (cti->flush_constraint_targets)
- cti->flush_constraint_targets(con, &targets, 0);
- }
- }
- }
-
- if (found == 0) {
- /* check if parent is already linked */
- if (ctrl_parent && ctrl_parent->link) {
- RIG_parentControl(ctrl, ctrl_parent->bone);
- changed = true;
- }
- else {
- /* check childs */
- for (ctrl_child = rg->controls.first; ctrl_child; ctrl_child = ctrl_child->next) {
- /* if a child is linked, link to that one */
- if (ctrl_child->link && ctrl_child->bone->parent == ctrl->bone) {
- RIG_parentControl(ctrl, ctrl_child->bone);
- changed = true;
- break;
- }
- }
- }
- }
- }
- }
- }
-
- /* third pass, link control tails */
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
- /* fit bone already means full match, so skip those */
- if ((ctrl->flag & RIG_CTRL_FIT_BONE) == 0) {
- GHashIterator ghi;
-
- /* look on deform bones first */
- BLI_ghashIterator_init(&ghi, rg->bones_map);
-
- for (; !BLI_ghashIterator_done(&ghi); BLI_ghashIterator_step(&ghi)) {
- EditBone *bone = (EditBone *)BLI_ghashIterator_getValue(&ghi);
-
- /* don't link with parent */
- if (bone->parent != ctrl->bone) {
- if (len_v3v3(ctrl->bone->tail, bone->head) < 0.01f) {
- ctrl->tail_mode = TL_HEAD;
- ctrl->link_tail = bone;
- break;
- }
- else if (len_v3v3(ctrl->bone->tail, bone->tail) < 0.01f) {
- ctrl->tail_mode = TL_TAIL;
- ctrl->link_tail = bone;
- break;
- }
- }
- }
-
- /* if we haven't found one yet, look in control bones */
- if (ctrl->tail_mode == TL_NONE) {
- /* pass */
- }
- }
- }
-
-}
-
-/*******************************************************************************************************/
-
-static void RIG_joinArcs(RigGraph *rg, RigNode *node, RigArc *joined_arc1, RigArc *joined_arc2)
-{
- RigEdge *edge, *next_edge;
-
- /* ignore cases where joint is at start or end */
- if (joined_arc1->head == joined_arc2->head || joined_arc1->tail == joined_arc2->tail) {
- return;
- }
-
- /* swap arcs to make sure arc1 is before arc2 */
- if (joined_arc1->head == joined_arc2->tail) {
- RigArc *tmp = joined_arc1;
- joined_arc1 = joined_arc2;
- joined_arc2 = tmp;
- }
-
- for (edge = joined_arc2->edges.first; edge; edge = next_edge) {
- next_edge = edge->next;
-
- RIG_appendEdgeToArc(joined_arc1, edge);
- }
-
- joined_arc1->tail = joined_arc2->tail;
-
- BLI_listbase_clear(&joined_arc2->edges);
-
- BLI_removeArc((BGraph *)rg, (BArc *)joined_arc2);
-
- BLI_removeNode((BGraph *)rg, (BNode *)node);
-}
-
-static void RIG_removeNormalNodes(RigGraph *rg)
-{
- RigNode *node, *next_node;
-
- for (node = rg->nodes.first; node; node = next_node) {
- next_node = node->next;
-
- if (node->degree == 2) {
- RigArc *arc, *joined_arc1 = NULL, *joined_arc2 = NULL;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- if (arc->head == node || arc->tail == node) {
- if (joined_arc1 == NULL) {
- joined_arc1 = arc;
- }
- else {
- joined_arc2 = arc;
- break;
- }
- }
- }
-
- RIG_joinArcs(rg, node, joined_arc1, joined_arc2);
- }
- }
-}
-
-static void RIG_removeUneededOffsets(RigGraph *rg)
-{
- RigArc *arc;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RigEdge *first_edge, *last_edge;
-
- first_edge = arc->edges.first;
- last_edge = arc->edges.last;
-
- if (first_edge->bone == NULL) {
- if (first_edge->bone == NULL && len_v3v3(first_edge->tail, arc->head->p) <= 0.001f) {
- BLI_remlink(&arc->edges, first_edge);
- MEM_freeN(first_edge);
- }
- else if (arc->head->degree == 1) {
- RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001f);
-
- if (new_node) {
- BLI_remlink(&arc->edges, first_edge);
- MEM_freeN(first_edge);
- BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head);
- }
- else {
- RigEdge *next_edge = first_edge->next;
-
- if (next_edge) {
- BLI_remlink(&arc->edges, first_edge);
- MEM_freeN(first_edge);
-
- copy_v3_v3(arc->head->p, next_edge->head);
- }
- }
- }
- else {
- /* check if all arc connected start with a null edge */
- RigArc *other_arc;
- for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
- if (other_arc != arc) {
- RigEdge *test_edge;
- if (other_arc->head == arc->head) {
- test_edge = other_arc->edges.first;
-
- if (test_edge->bone != NULL) {
- break;
- }
- }
- else if (other_arc->tail == arc->head) {
- test_edge = other_arc->edges.last;
-
- if (test_edge->bone != NULL) {
- break;
- }
- }
- }
- }
-
- if (other_arc == NULL) {
- RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001);
-
- if (new_node) {
- /* remove null edge in other arcs too */
- for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
- if (other_arc != arc) {
- RigEdge *test_edge;
- if (other_arc->head == arc->head) {
- BLI_replaceNodeInArc((BGraph *)rg, (BArc *)other_arc, (BNode *)new_node, (BNode *)other_arc->head);
- test_edge = other_arc->edges.first;
- BLI_remlink(&other_arc->edges, test_edge);
- MEM_freeN(test_edge);
- }
- else if (other_arc->tail == arc->head) {
- BLI_replaceNodeInArc((BGraph *)rg, (BArc *)other_arc, (BNode *)new_node, (BNode *)other_arc->tail);
- test_edge = other_arc->edges.last;
- BLI_remlink(&other_arc->edges, test_edge);
- MEM_freeN(test_edge);
- }
- }
- }
-
- BLI_remlink(&arc->edges, first_edge);
- MEM_freeN(first_edge);
- BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head);
- }
- else {
- RigEdge *next_edge = first_edge->next;
-
- if (next_edge) {
- BLI_remlink(&arc->edges, first_edge);
- MEM_freeN(first_edge);
-
- copy_v3_v3(arc->head->p, next_edge->head);
-
- /* remove null edge in other arcs too */
- for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
- if (other_arc != arc) {
- RigEdge *test_edge;
- if (other_arc->head == arc->head) {
- test_edge = other_arc->edges.first;
- BLI_remlink(&other_arc->edges, test_edge);
- MEM_freeN(test_edge);
- }
- else if (other_arc->tail == arc->head) {
- test_edge = other_arc->edges.last;
- BLI_remlink(&other_arc->edges, test_edge);
- MEM_freeN(test_edge);
- }
- }
- }
- }
- }
- }
- }
- }
-
- if (last_edge->bone == NULL) {
- if (len_v3v3(last_edge->head, arc->tail->p) <= 0.001f) {
- BLI_remlink(&arc->edges, last_edge);
- MEM_freeN(last_edge);
- }
- else if (arc->tail->degree == 1) {
- RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, last_edge->head, 0.001f);
-
- if (new_node) {
- RigEdge *previous_edge = last_edge->prev;
-
- BLI_remlink(&arc->edges, last_edge);
- MEM_freeN(last_edge);
- BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->tail);
-
- /* set previous angle to 0, since there's no following edges */
- if (previous_edge) {
- previous_edge->angle = 0;
- }
- }
- else {
- RigEdge *previous_edge = last_edge->prev;
-
- if (previous_edge) {
- BLI_remlink(&arc->edges, last_edge);
- MEM_freeN(last_edge);
-
- copy_v3_v3(arc->tail->p, previous_edge->tail);
- previous_edge->angle = 0;
- }
- }
- }
- }
- }
-}
-
-static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bone, RigNode *starting_node, bool selected)
-{
- EditBone *bone, *last_bone = root_bone;
- RigArc *arc = NULL;
- int contain_head = 0;
-
- for (bone = root_bone; bone; bone = nextEditBoneChild(list, bone, 0)) {
- int nb_children;
-
- if (selected == 0 || (bone->flag & BONE_SELECTED)) {
- if ((bone->flag & BONE_NO_DEFORM) == 0) {
- BLI_ghash_insert(rg->bones_map, bone->name, bone);
-
- if (arc == NULL) {
- arc = newRigArc(rg);
-
- if (starting_node == NULL) {
- starting_node = newRigNodeHead(rg, arc, root_bone->head);
- }
- else {
- addRigNodeHead(rg, arc, starting_node);
- }
- }
-
- if (bone->parent && (bone->flag & BONE_CONNECTED) == 0) {
- RIG_addEdgeToArc(arc, bone->head, NULL);
- }
-
- RIG_addEdgeToArc(arc, bone->tail, bone);
-
- last_bone = bone;
-
- if (STREQ(bone->name, "head")) {
- contain_head = 1;
- }
- }
- else if ((bone->flag & BONE_EDITMODE_LOCKED) == 0) { /* ignore locked bones */
- RIG_addControlBone(rg, bone);
- }
- }
-
- nb_children = countEditBoneChildren(list, bone);
- if (nb_children > 1) {
- RigNode *end_node = NULL;
- int i;
-
- if (arc != NULL) {
- end_node = newRigNodeTail(rg, arc, bone->tail);
- }
- else {
- end_node = newRigNode(rg, bone->tail);
- }
-
- for (i = 0; i < nb_children; i++) {
- root_bone = nextEditBoneChild(list, bone, i);
- RIG_arcFromBoneChain(rg, list, root_bone, end_node, selected);
- }
-
- /* arc ends here, break */
- break;
- }
- }
-
- /* If the loop exited without forking */
- if (arc != NULL && bone == NULL) {
- newRigNodeTail(rg, arc, last_bone->tail);
- }
-
- if (contain_head) {
- rg->head = arc->tail;
- }
-}
-
-/*******************************************************************************************************/
-static void RIG_findHead(RigGraph *rg)
-{
- if (rg->head == NULL) {
- if (BLI_listbase_is_single(&rg->arcs)) {
- RigArc *arc = rg->arcs.first;
-
- rg->head = (RigNode *)arc->head;
- }
- else {
- RigArc *arc;
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RigEdge *edge = arc->edges.last;
-
- if (edge->bone->flag & (BONE_TIPSEL | BONE_SELECTED)) {
- rg->head = arc->tail;
- break;
- }
- }
- }
-
- if (rg->head == NULL) {
- rg->head = rg->nodes.first;
- }
- }
-}
-
-/*******************************************************************************************************/
-
-static void RIG_printNode(RigNode *node, const char name[])
-{
- printf("%s %p %i <%0.3f, %0.3f, %0.3f>\n", name, (void *)node, node->degree, node->p[0], node->p[1], node->p[2]);
-
- if (node->symmetry_flag & SYM_TOPOLOGICAL) {
- if (node->symmetry_flag & SYM_AXIAL)
- printf("Symmetry AXIAL\n");
- else if (node->symmetry_flag & SYM_RADIAL)
- printf("Symmetry RADIAL\n");
-
- print_v3("symmetry axis", node->symmetry_axis);
- }
-}
-
-void RIG_printArcBones(RigArc *arc)
-{
- RigEdge *edge;
-
- for (edge = arc->edges.first; edge; edge = edge->next) {
- if (edge->bone)
- printf("%s ", edge->bone->name);
- else
- printf("---- ");
- }
- printf("\n");
-}
-
-static void RIG_printCtrl(RigControl *ctrl, char *indent)
-{
- char text[128];
-
- printf("%sBone: %s\n", indent, ctrl->bone->name);
- printf("%sLink: %s\n", indent, ctrl->link ? ctrl->link->name : "!NONE!");
-
- BLI_snprintf(text, sizeof(text), "%soffset", indent);
- print_v3(text, ctrl->offset);
-
- printf("%sFlag: %i\n", indent, ctrl->flag);
-}
-
-static void RIG_printLinkedCtrl(RigGraph *rg, EditBone *bone, int tabs)
-{
- RigControl *ctrl;
- char indent[64];
- char *s = indent;
- int i;
-
- for (i = 0; i < tabs; i++) {
- s[0] = '\t';
- s++;
- }
- s[0] = 0;
-
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
- if (ctrl->link == bone) {
- RIG_printCtrl(ctrl, indent);
- RIG_printLinkedCtrl(rg, ctrl->bone, tabs + 1);
- }
- }
-}
-
-void RIG_printArc(RigGraph *rg, RigArc *arc)
-{
- RigEdge *edge;
-
- RIG_printNode((RigNode *)arc->head, "head");
-
- for (edge = arc->edges.first; edge; edge = edge->next) {
- printf("\tinner joints %0.3f %0.3f %0.3f\n", edge->tail[0], edge->tail[1], edge->tail[2]);
- printf("\t\tlength %f\n", edge->length);
- printf("\t\tangle %f\n", edge->angle * (float)(180 / M_PI));
- if (edge->bone) {
- printf("\t\t%s\n", edge->bone->name);
- RIG_printLinkedCtrl(rg, edge->bone, 3);
- }
- }
- printf("symmetry level: %i flag: %i group %i\n", arc->symmetry_level, arc->symmetry_flag, arc->symmetry_group);
-
- RIG_printNode((RigNode *)arc->tail, "tail");
-}
-
-void RIG_printGraph(RigGraph *rg)
-{
- RigArc *arc;
-
- printf("---- ARCS ----\n");
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- RIG_printArc(rg, arc);
- printf("\n");
- }
-
- if (rg->head) {
- RIG_printNode(rg->head, "HEAD NODE:");
- }
- else {
- printf("HEAD NODE: NONE\n");
- }
-}
-
-/*******************************************************************************************************/
-
-RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm)
-{
- Object *obedit = CTX_data_edit_object(C);
- Scene *scene = CTX_data_scene(C);
- EditBone *ebone;
- RigGraph *rg;
-
- rg = newRigGraph();
-
- if (obedit == ob) {
- rg->editbones = ((bArmature *)obedit->data)->edbo;
- }
- else {
- rg->editbones = MEM_callocN(sizeof(ListBase), "EditBones");
- make_boneList(rg->editbones, &arm->bonebase, NULL);
- rg->flag |= RIG_FREE_BONELIST;
- }
-
- rg->ob = ob;
-
- /* Do the rotations */
- for (ebone = rg->editbones->first; ebone; ebone = ebone->next) {
- if (ebone->parent == NULL) {
- RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 0);
- }
- }
-
- BLI_removeDoubleNodes((BGraph *)rg, 0.001);
-
- RIG_removeNormalNodes(rg);
-
- RIG_removeUneededOffsets(rg);
-
- BLI_buildAdjacencyList((BGraph *)rg);
-
- RIG_findHead(rg);
-
- BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit);
-
- RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */
-
- if (BLI_isGraphCyclic((BGraph *)rg)) {
- printf("armature cyclic\n");
- }
-
- return rg;
-}
-
-static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm)
-{
- Object *obedit = CTX_data_edit_object(C);
- Scene *scene = CTX_data_scene(C);
- EditBone *ebone;
- RigGraph *rg;
-
- rg = newRigGraph();
-
- if (obedit == ob) {
- rg->editbones = arm->edbo;
- }
- else {
- rg->editbones = MEM_callocN(sizeof(ListBase), "EditBones");
- make_boneList(rg->editbones, &arm->bonebase, NULL);
- rg->flag |= RIG_FREE_BONELIST;
- }
-
- rg->ob = ob;
-
- /* Do the rotations */
- for (ebone = rg->editbones->first; ebone; ebone = ebone->next) {
- if (ebone->parent == NULL) {
- RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 1);
- }
- }
-
- BLI_removeDoubleNodes((BGraph *)rg, 0.001);
-
- RIG_removeNormalNodes(rg);
-
- RIG_removeUneededOffsets(rg);
-
- BLI_buildAdjacencyList((BGraph *)rg);
-
- RIG_findHead(rg);
-
- BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit);
-
- RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */
-
- if (BLI_isGraphCyclic((BGraph *)rg)) {
- printf("armature cyclic\n");
- }
-
- return rg;
-}
-/************************************ GENERATING *****************************************************/
-
-#if 0
-static EditBone *add_editbonetolist(char *name, ListBase *list)
-{
- EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone");
-
- BLI_strncpy(bone->name, name, sizeof(bone->name));
- ED_armature_ebone_unique_name(list, bone->name, NULL);
-
- BLI_addtail(list, bone);
-
- bone->flag |= BONE_TIPSEL;
- bone->weight = 1.0F;
- bone->dist = 0.25F;
- bone->xwidth = 0.1;
- bone->zwidth = 0.1;
- bone->rad_head = 0.10;
- bone->rad_tail = 0.05;
- bone->segments = 1;
- bone->layer = 1; //arm->layer;
-
- /* Bendy-Bone parameters */
- bone->roll1 = 0.0f;
- bone->roll2 = 0.0f;
- bone->curveInX = 0.0f;
- bone->curveInY = 0.0f;
- bone->curveOutX = 0.0f;
- bone->curveOutY = 0.0f;
- bone->ease1 = 1.0f;
- bone->ease2 = 1.0f;
- bone->scaleIn = 1.0f;
- bone->scaleOut = 1.0f;
-
- return bone;
-}
-#endif
-
-#if 0 /* UNUSED */
-static void generateMissingArcsFromNode(RigGraph *rigg, ReebNode *node, int multi_level_limit)
-{
- while (node->multi_level > multi_level_limit && node->link_up)
- {
- node = node->link_up;
- }
-
- while (node->multi_level < multi_level_limit && node->link_down)
- {
- node = node->link_down;
- }
-
- if (node->multi_level == multi_level_limit)
- {
- int i;
-
- for (i = 0; i < node->degree; i++)
- {
- ReebArc *earc = node->arcs[i];
-
- if (earc->flag == ARC_FREE && earc->head == node)
- {
- ReebNode *other = BIF_otherNodeFromIndex(earc, node);
-
- earc->flag = ARC_USED;
-
- //generateBonesForArc(rigg, earc, node, other);
- generateMissingArcsFromNode(rigg, other, multi_level_limit);
- }
- }
- }
-}
-
-static void generateMissingArcs(RigGraph *rigg)
-{
- ReebGraph *reebg;
- int multi_level_limit = 5;
-
- for (reebg = rigg->link_mesh; reebg; reebg = reebg->link_up)
- {
- ReebArc *earc;
-
- for (earc = reebg->arcs.first; earc; earc = earc->next)
- {
- if (earc->flag == ARC_USED)
- {
- generateMissingArcsFromNode(rigg, earc->head, multi_level_limit);
- generateMissingArcsFromNode(rigg, earc->tail, multi_level_limit);
- }
- }
- }
-}
-#endif
-
-/************************************ RETARGETTING *****************************************************/
-
-static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], float tail[3], float qrot[4], float resize);
-
-static void repositionTailControl(RigGraph *rigg, RigControl *ctrl);
-
-static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize)
-{
- if ((ctrl->flag & RIG_CTRL_DONE) == RIG_CTRL_DONE) {
- RigControl *ctrl_child;
-
-#if 0
- printf("CTRL: %s LINK: %s", ctrl->bone->name, ctrl->link->name);
-
- if (ctrl->link_tail)
- {
- printf(" TAIL: %s", ctrl->link_tail->name);
- }
-
- printf("\n");
-#endif
-
- /* if there was a tail link: apply link, recalc resize factor and qrot */
- if (ctrl->tail_mode != TL_NONE) {
- float *tail_vec = NULL;
- float v1[3], v2[3], qtail[4];
-
- if (ctrl->tail_mode == TL_TAIL) {
- tail_vec = ctrl->link_tail->tail;
- }
- else if (ctrl->tail_mode == TL_HEAD) {
- tail_vec = ctrl->link_tail->head;
- }
-
- sub_v3_v3v3(v1, ctrl->bone->tail, ctrl->bone->head);
- sub_v3_v3v3(v2, tail_vec, ctrl->bone->head);
-
- copy_v3_v3(ctrl->bone->tail, tail_vec);
-
- rotation_between_vecs_to_quat(qtail, v1, v2);
- mul_qt_qtqt(ctrl->qrot, qtail, ctrl->qrot);
-
- resize = len_v3(v2) / len_v3v3(ctrl->head, ctrl->tail);
- }
-
- ctrl->bone->roll = rollBoneByQuat(ctrl->bone, ctrl->up_axis, ctrl->qrot);
-
- /* Cascade to connected control bones */
- for (ctrl_child = rigg->controls.first; ctrl_child; ctrl_child = ctrl_child->next) {
- if (ctrl_child->link == ctrl->bone) {
- repositionControl(rigg, ctrl_child, ctrl->bone->head, ctrl->bone->tail, ctrl->qrot, resize);
- }
- if (ctrl_child->link_tail == ctrl->bone) {
- repositionTailControl(rigg, ctrl_child);
- }
- }
- }
-}
-
-static void repositionTailControl(RigGraph *rigg, RigControl *ctrl)
-{
- ctrl->flag |= RIG_CTRL_TAIL_DONE;
-
- finalizeControl(rigg, ctrl, 1); /* resize will be recalculated anyway so we don't need it */
-}
-
-static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], float UNUSED(tail[3]), float qrot[4], float resize)
-{
- float parent_offset[3], tail_offset[3];
-
- copy_v3_v3(parent_offset, ctrl->offset);
- mul_v3_fl(parent_offset, resize);
- mul_qt_v3(qrot, parent_offset);
-
- add_v3_v3v3(ctrl->bone->head, head, parent_offset);
-
- ctrl->flag |= RIG_CTRL_HEAD_DONE;
-
- copy_qt_qt(ctrl->qrot, qrot);
-
- if (ctrl->tail_mode == TL_NONE) {
- sub_v3_v3v3(tail_offset, ctrl->tail, ctrl->head);
- mul_v3_fl(tail_offset, resize);
- mul_qt_v3(qrot, tail_offset);
-
- add_v3_v3v3(ctrl->bone->tail, ctrl->bone->head, tail_offset);
-
- ctrl->flag |= RIG_CTRL_TAIL_DONE;
- }
-
- finalizeControl(rigg, ctrl, resize);
-}
-
-static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec0[3], float vec1[3], float up_axis[3])
-{
- Scene *scene = CTX_data_scene(C);
- EditBone *bone;
- RigControl *ctrl;
- float qrot[4], resize;
- float v1[3], v2[3];
- float l1, l2;
-
- bone = edge->bone;
-
- sub_v3_v3v3(v1, edge->tail, edge->head);
- sub_v3_v3v3(v2, vec1, vec0);
-
- l1 = normalize_v3(v1);
- l2 = normalize_v3(v2);
-
- resize = l2 / l1;
-
- rotation_between_vecs_to_quat(qrot, v1, v2);
-
- copy_v3_v3(bone->head, vec0);
- copy_v3_v3(bone->tail, vec1);
-
- if (!is_zero_v3(up_axis)) {
- float qroll[4];
-
- if (scene->toolsettings->skgen_retarget_roll == SK_RETARGET_ROLL_VIEW) {
- bone->roll = rollBoneByQuatAligned(bone, edge->up_axis, qrot, qroll, up_axis);
- }
- else if (scene->toolsettings->skgen_retarget_roll == SK_RETARGET_ROLL_JOINT) {
- bone->roll = rollBoneByQuatJoint(edge, edge->prev, qrot, qroll, up_axis);
- }
- else {
- unit_qt(qroll);
- }
-
- mul_qt_qtqt(qrot, qroll, qrot);
- }
- else {
- bone->roll = rollBoneByQuat(bone, edge->up_axis, qrot);
- }
-
- for (ctrl = rigg->controls.first; ctrl; ctrl = ctrl->next) {
- if (ctrl->link == bone) {
- repositionControl(rigg, ctrl, vec0, vec1, qrot, resize);
- }
- if (ctrl->link_tail == bone) {
- repositionTailControl(rigg, ctrl);
- }
- }
-}
-
-static RetargetMode detectArcRetargetMode(RigArc *arc);
-static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start);
-
-
-static RetargetMode detectArcRetargetMode(RigArc *iarc)
-{
- RetargetMode mode = RETARGET_AGGRESSIVE;
- ReebArc *earc = iarc->link_mesh;
- RigEdge *edge;
- int large_angle = 0;
- float avg_angle = 0;
- /* float avg_length = 0; */ /* UNUSED */
- int nb_edges = 0;
-
-
- for (edge = iarc->edges.first; edge; edge = edge->next) {
- avg_angle += edge->angle;
- nb_edges++;
- }
-
- avg_angle /= nb_edges - 1; /* -1 because last edge doesn't have an angle */
-
- /* avg_length = iarc->length / nb_edges; */ /* UNUSED */
-
-
- if (nb_edges > 2) {
- for (edge = iarc->edges.first; edge; edge = edge->next) {
- if (fabsf(edge->angle - avg_angle) > (float)(M_PI / 6)) {
- large_angle = 1;
- }
- }
- }
- else if (nb_edges == 2 && avg_angle > 0) {
- large_angle = 1;
- }
-
-
- if (large_angle == 0) {
- mode = RETARGET_LENGTH;
- }
-
- if (earc->bcount <= (iarc->count - 1)) {
- mode = RETARGET_LENGTH;
- }
-
- return mode;
-}
-
-#ifndef USE_THREADS
-static void printMovesNeeded(int *positions, int nb_positions)
-{
- int moves = 0;
- int i;
-
- for (i = 0; i < nb_positions; i++) {
- moves += positions[i] - (i + 1);
- }
-
- printf("%i moves needed\n", moves);
-}
-
-static void printPositions(int *positions, int nb_positions)
-{
- int i;
-
- for (i = 0; i < nb_positions; i++) {
- printf("%i ", positions[i]);
- }
- printf("\n");
-}
-#endif
-
-#define MAX_COST FLT_MAX /* FIX ME */
-
-static float costDistance(BArcIterator *iter, float *vec0, float *vec1, int i0, int i1, float distance_weight)
-{
- EmbedBucket *bucket = NULL;
- float max_dist = 0;
- float v1[3], v2[3], c[3];
- float v1_inpf;
-
- if (distance_weight > 0) {
- sub_v3_v3v3(v1, vec0, vec1);
-
- v1_inpf = dot_v3v3(v1, v1);
-
- if (v1_inpf > 0) {
- int j;
- for (j = i0 + 1; j < i1 - 1; j++) {
- float dist;
-
- bucket = IT_peek(iter, j);
-
- sub_v3_v3v3(v2, bucket->p, vec1);
-
- cross_v3_v3v3(c, v1, v2);
-
- dist = dot_v3v3(c, c) / v1_inpf;
-
- max_dist = dist > max_dist ? dist : max_dist;
- }
-
- return distance_weight * max_dist;
- }
- else {
- return MAX_COST;
- }
- }
- else {
- return 0;
- }
-}
-
-static float costAngle(float original_angle, float vec_first[3], float vec_second[3], float angle_weight)
-{
- if (angle_weight > 0) {
- float current_angle;
-
- if (!is_zero_v3(vec_first) && !is_zero_v3(vec_second)) {
- current_angle = saacos(dot_v3v3(vec_first, vec_second));
-
- return angle_weight * fabsf(current_angle - original_angle);
- }
- else {
- return angle_weight * (float)M_PI;
- }
- }
- else {
- return 0;
- }
-}
-
-static float costLength(float original_length, float current_length, float length_weight)
-{
- if (current_length == 0) {
- return MAX_COST;
- }
- else {
- float length_ratio = fabsf((current_length - original_length) / original_length);
- return length_weight * length_ratio * length_ratio;
- }
-}
-
-#if 0
-static float calcCostLengthDistance(BArcIterator *iter, float **vec_cache, RigEdge *edge, float *vec1, float *vec2, int i1, int i2)
-{
- float vec[3];
- float length;
-
- sub_v3_v3v3(vec, vec2, vec1);
- length = normalize_v3(vec);
-
- return costLength(edge->length, length) + costDistance(iter, vec1, vec2, i1, i2);
-}
-#endif
-
-static float calcCostAngleLengthDistance(BArcIterator *iter, float **UNUSED(vec_cache), RigEdge *edge,
- float *vec0, float *vec1, float *vec2, int i1, int i2,
- float angle_weight, float length_weight, float distance_weight)
-{
- float vec_second[3], vec_first[3];
- float length2;
- float new_cost = 0;
-
- sub_v3_v3v3(vec_second, vec2, vec1);
- length2 = normalize_v3(vec_second);
-
-
- /* Angle cost */
- if (edge->prev) {
- sub_v3_v3v3(vec_first, vec1, vec0);
- normalize_v3(vec_first);
-
- new_cost += costAngle(edge->prev->angle, vec_first, vec_second, angle_weight);
- }
-
- /* Length cost */
- new_cost += costLength(edge->length, length2, length_weight);
-
- /* Distance cost */
- new_cost += costDistance(iter, vec1, vec2, i1, i2, distance_weight);
-
- return new_cost;
-}
-
-static int indexMemoNode(int nb_positions, int previous, int current, int joints_left)
-{
- return joints_left * nb_positions * nb_positions + current * nb_positions + previous;
-}
-
-static void copyMemoPositions(int *positions, MemoNode *table, int nb_positions, int joints_left)
-{
- int previous = 0, current = 0;
- int i = 0;
-
- for (i = 0; joints_left > 0; joints_left--, i++) {
- MemoNode *node;
- node = table + indexMemoNode(nb_positions, previous, current, joints_left);
-
- positions[i] = node->next;
-
- previous = current;
- current = node->next;
- }
-}
-
-static MemoNode *solveJoints(MemoNode *table, BArcIterator *iter, float **vec_cache,
- int nb_joints, int nb_positions, int previous, int current, RigEdge *edge,
- int joints_left, float angle_weight, float length_weight, float distance_weight)
-{
- MemoNode *node;
- int index = indexMemoNode(nb_positions, previous, current, joints_left);
-
- node = table + index;
-
- if (node->weight != 0) {
- return node;
- }
- else if (joints_left == 0) {
- float *vec0 = vec_cache[previous];
- float *vec1 = vec_cache[current];
- float *vec2 = vec_cache[nb_positions + 1];
-
- node->weight = calcCostAngleLengthDistance(iter, vec_cache, edge, vec0, vec1, vec2, current, iter->length, angle_weight, length_weight, distance_weight);
-
- return node;
- }
- else {
- MemoNode *min_node = NULL;
- float *vec0 = vec_cache[previous];
- float *vec1 = vec_cache[current];
- float min_weight = 0.0f;
- int min_next = 0;
- int next;
-
- for (next = current + 1; next <= nb_positions - (joints_left - 1); next++) {
- MemoNode *next_node;
- float *vec2 = vec_cache[next];
- float weight = 0.0f;
-
- /* ADD WEIGHT OF PREVIOUS - CURRENT - NEXT triple */
- weight = calcCostAngleLengthDistance(iter, vec_cache, edge, vec0, vec1, vec2, current, next, angle_weight, length_weight, distance_weight);
-
- if (weight >= MAX_COST) {
- continue;
- }
-
- /* add node weight */
- next_node = solveJoints(table, iter, vec_cache, nb_joints, nb_positions, current, next, edge->next, joints_left - 1, angle_weight, length_weight, distance_weight);
- weight += next_node->weight;
-
- if (min_node == NULL || weight < min_weight) {
- min_weight = weight;
- min_node = next_node;
- min_next = next;
- }
- }
-
- if (min_node) {
- node->weight = min_weight;
- node->next = min_next;
- return node;
- }
- else {
- node->weight = MAX_COST;
- return node;
- }
- }
-
-}
-
-static int testFlipArc(RigArc *iarc, RigNode *inode_start)
-{
- ReebArc *earc = iarc->link_mesh;
- ReebNode *enode_start = BIF_NodeFromIndex(earc, inode_start->link_mesh);
-
- /* no flip needed if both nodes are the same */
- if ((enode_start == earc->head && inode_start == iarc->head) ||
- (enode_start == earc->tail && inode_start == iarc->tail))
- {
- return 0;
- }
- else {
- return 1;
- }
-}
-
-static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
-{
- ReebArcIterator arc_iter;
- BArcIterator *iter = (BArcIterator *)&arc_iter;
- RigEdge *edge;
- ReebNode *node_start, *node_end;
- ReebArc *earc = iarc->link_mesh;
- float angle_weight = 1.0; // GET FROM CONTEXT
- float length_weight = 1.0;
- float distance_weight = 1.0;
-#ifndef USE_THREADS
- float min_cost = FLT_MAX;
-#endif
- float *vec0, *vec1;
- int *best_positions;
- int nb_edges = BLI_listbase_count(&iarc->edges);
- int nb_joints = nb_edges - 1;
- RetargetMethod method = METHOD_MEMOIZE;
- int i;
-
- if (nb_joints > earc->bcount) {
- printf("NOT ENOUGH BUCKETS!\n");
- return;
- }
-
- best_positions = MEM_callocN(sizeof(int) * nb_joints, "Best positions");
-
- if (testFlipArc(iarc, inode_start)) {
- node_start = earc->tail;
- node_end = earc->head;
- }
- else {
- node_start = earc->head;
- node_end = earc->tail;
- }
-
- /* equal number of joints and potential position, just fill them in */
- if (nb_joints == earc->bcount) {
- /* init with first values */
- for (i = 0; i < nb_joints; i++) {
- best_positions[i] = i + 1;
- }
- }
- if (method == METHOD_MEMOIZE) {
- int nb_positions = earc->bcount;
- int nb_memo_nodes = nb_positions * nb_positions * (nb_joints + 1);
- MemoNode *table = MEM_callocN(nb_memo_nodes * sizeof(MemoNode), "memoization table");
-#ifndef USE_THREADS
- MemoNode *result;
-#endif
- float **positions_cache = MEM_callocN(sizeof(float *) * (nb_positions + 2), "positions cache");
-
- positions_cache[0] = node_start->p;
- positions_cache[nb_positions + 1] = node_end->p;
-
- initArcIterator(iter, earc, node_start);
-
- for (i = 1; i <= nb_positions; i++) {
- EmbedBucket *bucket = IT_peek(iter, i);
- positions_cache[i] = bucket->p;
- }
-
-#ifndef USE_THREADS
- result = solveJoints(table, iter, positions_cache, nb_joints, earc->bcount, 0, 0, iarc->edges.first, nb_joints, angle_weight, length_weight, distance_weight);
- min_cost = result->weight;
-#else
- solveJoints(table, iter, positions_cache, nb_joints, earc->bcount, 0, 0, iarc->edges.first, nb_joints, angle_weight, length_weight, distance_weight);
-#endif
-
- copyMemoPositions(best_positions, table, earc->bcount, nb_joints);
-
- MEM_freeN(table);
- MEM_freeN(positions_cache);
- }
-
- vec0 = node_start->p;
- initArcIterator(iter, earc, node_start);
-
-#ifndef USE_THREADS
- printPositions(best_positions, nb_joints);
- printMovesNeeded(best_positions, nb_joints);
- printf("min_cost %f\n", min_cost);
- printf("buckets: %i\n", earc->bcount);
-#endif
-
- /* set joints to best position */
- for (edge = iarc->edges.first, i = 0;
- edge;
- edge = edge->next, i++)
- {
- float *no = NULL;
- if (i < nb_joints) {
- EmbedBucket *bucket = IT_peek(iter, best_positions[i]);
- vec1 = bucket->p;
- no = bucket->no;
- }
- else {
- vec1 = node_end->p;
- no = node_end->no;
- }
-
- if (edge->bone) {
- repositionBone(C, rigg, edge, vec0, vec1, no);
- }
-
- vec0 = vec1;
- }
-
- MEM_freeN(best_positions);
-}
-
-static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
-{
- ReebArcIterator arc_iter;
- BArcIterator *iter = (BArcIterator *)&arc_iter;
- ReebArc *earc = iarc->link_mesh;
- ReebNode *node_start, *node_end;
- RigEdge *edge;
- EmbedBucket *bucket = NULL;
- float embedding_length = 0;
- float *vec0 = NULL;
- float *vec1 = NULL;
- float *previous_vec = NULL;
-
-
- if (testFlipArc(iarc, inode_start)) {
- node_start = (ReebNode *)earc->tail;
- node_end = (ReebNode *)earc->head;
- }
- else {
- node_start = (ReebNode *)earc->head;
- node_end = (ReebNode *)earc->tail;
- }
-
- initArcIterator(iter, earc, node_start);
-
- bucket = IT_next(iter);
-
- vec0 = node_start->p;
-
- while (bucket != NULL) {
- vec1 = bucket->p;
-
- embedding_length += len_v3v3(vec0, vec1);
-
- vec0 = vec1;
- bucket = IT_next(iter);
- }
-
- embedding_length += len_v3v3(node_end->p, vec1);
-
- /* fit bones */
- initArcIterator(iter, earc, node_start);
-
- bucket = IT_next(iter);
-
- vec0 = node_start->p;
- previous_vec = vec0;
- vec1 = bucket->p;
-
- for (edge = iarc->edges.first; edge; edge = edge->next) {
- float new_bone_length = edge->length / iarc->length * embedding_length;
- float *no = NULL;
- float length = 0;
-
- while (bucket && new_bone_length > length) {
- length += len_v3v3(previous_vec, vec1);
- bucket = IT_next(iter);
- previous_vec = vec1;
- vec1 = bucket->p;
- no = bucket->no;
- }
-
- if (bucket == NULL) {
- vec1 = node_end->p;
- no = node_end->no;
- }
-
- /* no need to move virtual edges (space between unconnected bones) */
- if (edge->bone) {
- repositionBone(C, rigg, edge, vec0, vec1, no);
- }
-
- vec0 = vec1;
- previous_vec = vec1;
- }
-}
-
-static void retargetArctoArc(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
-{
- RetargetParam *p = MEM_callocN(sizeof(RetargetParam), "RetargetParam");
-
- p->rigg = rigg;
- p->iarc = iarc;
- p->inode_start = inode_start;
- p->context = C;
-
- BLI_task_pool_push(rigg->task_pool, exec_retargetArctoArc, p, true, TASK_PRIORITY_HIGH);
-}
-
-void exec_retargetArctoArc(TaskPool * __restrict UNUSED(pool), void *taskdata, int UNUSED(threadid))
-{
- RetargetParam *p = (RetargetParam *)taskdata;
- RigGraph *rigg = p->rigg;
- RigArc *iarc = p->iarc;
- bContext *C = p->context;
- RigNode *inode_start = p->inode_start;
- ReebArc *earc = iarc->link_mesh;
-
- if (BLI_listbase_is_single(&iarc->edges)) {
- RigEdge *edge = iarc->edges.first;
-
- if (testFlipArc(iarc, inode_start)) {
- repositionBone(C, rigg, edge, earc->tail->p, earc->head->p, earc->head->no);
- }
- else {
- repositionBone(C, rigg, edge, earc->head->p, earc->tail->p, earc->tail->no);
- }
- }
- else {
- RetargetMode mode = detectArcRetargetMode(iarc);
-
- if (mode == RETARGET_AGGRESSIVE) {
- retargetArctoArcAggresive(C, rigg, iarc, inode_start);
- }
- else {
- retargetArctoArcLength(C, rigg, iarc, inode_start);
- }
- }
-}
-
-static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *top_node)
-{
- ReebNode *enode = top_node;
- ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode);
- int ishape, eshape;
-
- ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS;
- eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
-
- inode->link_mesh = enode;
-
- while (ishape == eshape && enode->link_down) {
- inode->link_mesh = enode;
-
- enode = enode->link_down;
- reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); /* replace with call to link_down once that exists */
- eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
- }
-}
-
-static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode)
-{
- int i;
-
- for (i = 0; i < enode->degree; i++) {
- ReebArc *earc = (ReebArc *)enode->arcs[i];
-
- if (earc->flag == ARC_FREE) {
- earc->flag = ARC_TAKEN;
-
- if (earc->tail->degree > 1 && earc->tail != end_enode) {
- markMultiResolutionChildArc(end_enode, earc->tail);
- }
- break;
- }
- }
-}
-
-static void markMultiResolutionArc(ReebArc *start_earc)
-{
- if (start_earc->link_up) {
- ReebArc *earc;
- for (earc = start_earc->link_up; earc; earc = earc->link_up) {
- earc->flag = ARC_TAKEN;
-
- if (earc->tail->index != start_earc->tail->index) {
- markMultiResolutionChildArc(earc->tail, earc->tail);
- }
- }
- }
-}
-
-static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc *next_iarc, ReebArc *next_earc)
-{
- ReebNode *enode = next_earc->head;
- ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode);
- int ishape, eshape;
-
- ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)start_node, (BArc *)next_iarc, 1) % SHAPE_LEVELS;
- eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS;
-
- while (ishape != eshape && next_earc->link_up) {
- next_earc->flag = ARC_TAKEN; // mark previous as taken, to prevent backtrack on lower levels
-
- next_earc = next_earc->link_up;
- reebg = reebg->link_up;
- enode = next_earc->head;
- eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS;
- }
-
- next_earc->flag = ARC_USED;
- next_iarc->link_mesh = next_earc;
-
- /* mark all higher levels as taken too */
- markMultiResolutionArc(next_earc);
-// while (next_earc->link_up)
-// {
-// next_earc = next_earc->link_up;
-// next_earc->flag = ARC_TAKEN;
-// }
-}
-
-static void matchMultiResolutionStartingNode(RigGraph *rigg, ReebGraph *reebg, RigNode *inode)
-{
- ReebNode *enode;
- int ishape, eshape;
-
- enode = reebg->nodes.first;
-
- ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS;
- eshape = BLI_subtreeShape((BGraph *)rigg->link_mesh, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
-
- while (ishape != eshape && reebg->link_up) {
- reebg = reebg->link_up;
-
- enode = reebg->nodes.first;
-
- eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
- }
-
- inode->link_mesh = enode;
-}
-
-static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *start_node, RigArc *next_iarc, int root)
-{
- ReebNode *enode = start_node->link_mesh;
- ReebArc *next_earc;
- int symmetry_level = next_iarc->symmetry_level;
- int symmetry_group = next_iarc->symmetry_group;
- int symmetry_flag = next_iarc->symmetry_flag;
- int i;
-
- next_iarc->link_mesh = NULL;
-
-// if (root)
-// {
-// printf("-----------------------\n");
-// printf("MATCHING LIMB\n");
-// RIG_printArcBones(next_iarc);
-// }
-
- for (i = 0; i < enode->degree; i++) {
- next_earc = (ReebArc *)enode->arcs[i];
-
-// if (next_earc->flag == ARC_FREE)
-// {
-// printf("candidate (level %i ?= %i) (flag %i ?= %i) (group %i ?= %i)\n",
-// symmetry_level, next_earc->symmetry_level,
-// symmetry_flag, next_earc->symmetry_flag,
-// symmetry_group, next_earc->symmetry_flag);
-// }
-
- if (next_earc->flag == ARC_FREE &&
- next_earc->symmetry_flag == symmetry_flag &&
- next_earc->symmetry_group == symmetry_group &&
- next_earc->symmetry_level == symmetry_level)
- {
-// printf("CORRESPONDING ARC FOUND\n");
-// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
-
- matchMultiResolutionArc(rigg, start_node, next_iarc, next_earc);
- break;
- }
- }
-
- /* not found, try at higher nodes (lower node might have filtered internal arcs, messing shape of tree */
- if (next_iarc->link_mesh == NULL) {
-// printf("NO CORRESPONDING ARC FOUND - GOING TO HIGHER LEVELS\n");
-
- if (enode->link_up) {
- start_node->link_mesh = enode->link_up;
- findCorrespondingArc(rigg, start_arc, start_node, next_iarc, 0);
- }
- }
-
- /* still not found, print debug info */
- if (root && next_iarc->link_mesh == NULL) {
- start_node->link_mesh = enode; /* linking back with root node */
-
-// printf("NO CORRESPONDING ARC FOUND\n");
-// RIG_printArcBones(next_iarc);
-//
-// printf("ON NODE %i, multilevel %i\n", enode->index, enode->multi_level);
-//
-// printf("LOOKING FOR\n");
-// printf("flag %i -- level %i -- flag %i -- group %i\n", ARC_FREE, symmetry_level, symmetry_flag, symmetry_group);
-//
-// printf("CANDIDATES\n");
-// for (i = 0; i < enode->degree; i++)
-// {
-// next_earc = (ReebArc *)enode->arcs[i];
-// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
-// }
-
- /* Emergency matching */
- for (i = 0; i < enode->degree; i++) {
- next_earc = (ReebArc *)enode->arcs[i];
-
- if (next_earc->flag == ARC_FREE && next_earc->symmetry_level == symmetry_level) {
-// printf("USING:\n");
-// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
- matchMultiResolutionArc(rigg, start_node, next_iarc, next_earc);
- break;
- }
- }
- }
-
-}
-
-static void retargetSubgraph(bContext *C, RigGraph *rigg, RigArc *start_arc, RigNode *start_node)
-{
- RigNode *inode = start_node;
- int i;
-
- /* no start arc on first node */
- if (start_arc) {
- ReebNode *enode = start_node->link_mesh;
- ReebArc *earc = start_arc->link_mesh;
-
- retargetArctoArc(C, rigg, start_arc, start_node);
-
- enode = BIF_otherNodeFromIndex(earc, enode);
- inode = (RigNode *)BLI_otherNode((BArc *)start_arc, (BNode *)inode);
-
- /* match with lowest node with correct shape */
- matchMultiResolutionNode(rigg, inode, enode);
- }
-
- for (i = 0; i < inode->degree; i++) {
- RigArc *next_iarc = (RigArc *)inode->arcs[i];
-
- /* no back tracking */
- if (next_iarc != start_arc) {
- findCorrespondingArc(rigg, start_arc, inode, next_iarc, 1);
- if (next_iarc->link_mesh) {
- retargetSubgraph(C, rigg, next_iarc, inode);
- }
- }
- }
-}
-
-static void finishRetarget(RigGraph *rigg)
-{
- BLI_task_pool_work_and_wait(rigg->task_pool);
-}
-
-static void adjustGraphs(bContext *C, RigGraph *rigg)
-{
- Main *bmain = CTX_data_main(C);
- bArmature *arm = rigg->ob->data;
- RigArc *arc;
-
- for (arc = rigg->arcs.first; arc; arc = arc->next) {
- if (arc->link_mesh) {
- retargetArctoArc(C, rigg, arc, arc->head);
- }
- }
-
- finishRetarget(rigg);
-
- /* Turn the list into an armature */
- arm->edbo = rigg->editbones;
- ED_armature_from_edit(bmain, arm);
-
- ED_undo_push(C, "Retarget Skeleton");
-}
-
-static void retargetGraphs(bContext *C, RigGraph *rigg)
-{
- Main *bmain = CTX_data_main(C);
- bArmature *arm = rigg->ob->data;
- ReebGraph *reebg = rigg->link_mesh;
- RigNode *inode;
-
- /* flag all ReebArcs as free */
- BIF_flagMultiArcs(reebg, ARC_FREE);
-
- /* return to first level */
- inode = rigg->head;
-
- matchMultiResolutionStartingNode(rigg, reebg, inode);
-
- retargetSubgraph(C, rigg, NULL, inode);
-
- //generateMissingArcs(rigg);
-
- finishRetarget(rigg);
-
- /* Turn the list into an armature */
- arm->edbo = rigg->editbones;
- ED_armature_from_edit(bmain, arm);
-}
-
-const char *RIG_nameBone(RigGraph *rg, int arc_index, int bone_index)
-{
- RigArc *arc = BLI_findlink(&rg->arcs, arc_index);
- RigEdge *iedge;
-
- if (arc == NULL) {
- return "None";
- }
-
- if (bone_index == BLI_listbase_count(&arc->edges)) {
- return "Last joint";
- }
-
- iedge = BLI_findlink(&arc->edges, bone_index);
-
- if (iedge == NULL) {
- return "Done";
- }
-
- if (iedge->bone == NULL) {
- return "Bone offset";
- }
-
- return iedge->bone->name;
-}
-
-int RIG_nbJoints(RigGraph *rg)
-{
- RigArc *arc;
- int total = 0;
-
- total += BLI_listbase_count(&rg->nodes);
-
- for (arc = rg->arcs.first; arc; arc = arc->next) {
- total += BLI_listbase_count(&arc->edges) - 1; /* -1 because end nodes are already counted */
- }
-
- return total;
-}
-
-static void BIF_freeRetarget(void)
-{
- if (GLOBAL_RIGG) {
- RIG_freeRigGraph((BGraph *)GLOBAL_RIGG);
- GLOBAL_RIGG = NULL;
- }
-}
-
-void BIF_retargetArmature(bContext *C)
-{
- ReebGraph *reebg;
- double start_time, end_time;
- double gstart_time, gend_time;
- double reeb_time, rig_time = 0.0, retarget_time = 0.0, total_time;
-
- gstart_time = start_time = PIL_check_seconds_timer();
-
- reebg = BIF_ReebGraphMultiFromEditMesh(C);
-
- end_time = PIL_check_seconds_timer();
- reeb_time = end_time - start_time;
-
- printf("Reeb Graph created\n");
-
- CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
- {
- Object *ob = base->object;
-
- if (ob->type == OB_ARMATURE) {
- RigGraph *rigg;
- bArmature *arm;
-
- arm = ob->data;
-
- /* Put the armature into editmode */
-
-
- start_time = PIL_check_seconds_timer();
-
- rigg = RIG_graphFromArmature(C, ob, arm);
-
- end_time = PIL_check_seconds_timer();
- rig_time = end_time - start_time;
-
- printf("Armature graph created\n");
-
- //RIG_printGraph(rigg);
-
- rigg->link_mesh = reebg;
-
- printf("retargetting %s\n", ob->id.name);
-
- start_time = PIL_check_seconds_timer();
-
- retargetGraphs(C, rigg);
-
- end_time = PIL_check_seconds_timer();
- retarget_time = end_time - start_time;
-
- BIF_freeRetarget();
-
- GLOBAL_RIGG = rigg;
-
- break; /* only one armature at a time */
- }
- }
- CTX_DATA_END;
-
-
- gend_time = PIL_check_seconds_timer();
-
- total_time = gend_time - gstart_time;
-
- printf("-----------\n");
- printf("runtime: \t%.3f\n", total_time);
- printf("reeb: \t\t%.3f (%.1f%%)\n", reeb_time, reeb_time / total_time * 100);
- printf("rig: \t\t%.3f (%.1f%%)\n", rig_time, rig_time / total_time * 100);
- printf("retarget: \t%.3f (%.1f%%)\n", retarget_time, retarget_time / total_time * 100);
- printf("-----------\n");
-
- ED_undo_push(C, "Retarget Skeleton");
-
- // XXX
-// allqueue(REDRAWVIEW3D, 0);
-}
-
-void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg)
-{
- Object *obedit = CTX_data_edit_object(C);
- Scene *scene = CTX_data_scene(C);
- bArmature *armedit = obedit->data;
- Object *ob;
- RigGraph *rigg;
- RigArc *iarc;
- char *side_string = scene->toolsettings->skgen_side_string;
- char *num_string = scene->toolsettings->skgen_num_string;
- int free_template = 0;
-
- if (template_rigg) {
- ob = template_rigg->ob;
- }
- else {
- free_template = 1;
- ob = obedit;
- template_rigg = armatureSelectedToGraph(C, ob, ob->data);
- }
-
- if (BLI_listbase_is_empty(&template_rigg->arcs)) {
-// XXX
-// error("No Template and no deforming bones selected");
- return;
- }
-
- rigg = cloneRigGraph(template_rigg, armedit->edbo, obedit, side_string, num_string);
-
- iarc = rigg->arcs.first;
-
- iarc->link_mesh = earc;
- iarc->head->link_mesh = earc->head;
- iarc->tail->link_mesh = earc->tail;
-
- retargetArctoArc(C, rigg, iarc, iarc->head);
-
- finishRetarget(rigg);
-
- /* free template if it comes from the edit armature */
- if (free_template) {
- RIG_freeRigGraph((BGraph *)template_rigg);
- }
- RIG_freeRigGraph((BGraph *)rigg);
-
- ED_armature_edit_validate_active(armedit);
-
-// XXX
-// allqueue(REDRAWVIEW3D, 0);
-}
-
-void BIF_adjustRetarget(bContext *C)
-{
- if (GLOBAL_RIGG) {
- adjustGraphs(C, GLOBAL_RIGG);
- }
-}
diff --git a/source/blender/editors/armature/editarmature_undo.c b/source/blender/editors/armature/editarmature_undo.c
index f6f97af32b9..0fd94f664ab 100644
--- a/source/blender/editors/armature/editarmature_undo.c
+++ b/source/blender/editors/armature/editarmature_undo.c
@@ -156,7 +156,7 @@ static bool armature_undosys_step_encode(struct bContext *C, UndoStep *us_p)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
us->elems_len = objects_len;
@@ -192,7 +192,7 @@ static void armature_undosys_step_decode(struct bContext *C, UndoStep *us_p, int
continue;
}
undoarm_to_editarm(&elem->data, arm);
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
/* The first element is always active */
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index 001c8ce215f..96799304845 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -1427,7 +1427,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
EIG_linear_solver_delete(context);
}
-static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierData *mmd, MeshDeformBind *mdb)
+static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBind *mdb)
{
MDefBindInfluence *inf;
MDefInfluence *mdinf;
@@ -1578,7 +1578,7 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa
}
void ED_mesh_deform_bind_callback(
- Scene *scene, MeshDeformModifierData *mmd, Mesh *cagemesh,
+ MeshDeformModifierData *mmd, Mesh *cagemesh,
float *vertexcos, int totvert, float cagemat[4][4])
{
MeshDeformBind mdb;
@@ -1606,7 +1606,7 @@ void ED_mesh_deform_bind_callback(
mul_v3_m4v3(mdb.vertexcos[a], mdb.cagemat, vertexcos + a * 3);
/* solve */
- harmonic_coordinates_bind(scene, mmd, &mdb);
+ harmonic_coordinates_bind(mmd, &mdb);
/* assign bind variables */
mmd->bindcagecos = (float *)mdb.cagecos;
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index b10afa3a6de..4b069deefa3 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -110,7 +110,7 @@ bool ED_object_posemode_enter_ex(struct Main *bmain, Object *ob)
ob->restore_mode = ob->mode;
ob->mode |= OB_MODE_POSE;
/* Inform all CoW versions that we changed the mode. */
- DEG_id_tag_update_ex(bmain, &ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, &ob->id, ID_RECALC_COPY_ON_WRITE);
ok = true;
break;
@@ -143,7 +143,7 @@ bool ED_object_posemode_exit_ex(struct Main *bmain, Object *ob)
ob->mode &= ~OB_MODE_POSE;
/* Inform all CoW versions that we changed the mode. */
- DEG_id_tag_update_ex(bmain, &ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, &ob->id, ID_RECALC_COPY_ON_WRITE);
ok = true;
}
return ok;
@@ -257,7 +257,7 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, bool curre
if (!current_frame_only) {
/* Tag armature object for copy on write - so paths will draw/redraw.
* For currently frame only we update evaluated object directly. */
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
/* Free temporary depsgraph instance */
@@ -442,7 +442,7 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected)
ob->pose->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
/* tag armature object for copy on write - so removed paths don't still show */
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
/* operator callback - wrapper for the backend function */
@@ -510,7 +510,7 @@ static int pose_update_paths_range_exec(bContext *C, wmOperator *UNUSED(op))
ob->pose->avs.path_ef = PEFRA;
/* tag for updates */
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
return OPERATOR_FINISHED;
@@ -728,7 +728,7 @@ static void pose_copy_menu(Scene *scene)
BKE_pose_tag_recalc(bmain, ob->pose);
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA); // and all its relations
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); // and all its relations
BIF_undo_push("Copy Pose Attributes");
@@ -741,9 +741,10 @@ static int pose_flip_names_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers");
- FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob)
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob)
{
bArmature *arm = ob->data;
ListBase bones_names = {NULL};
@@ -759,7 +760,7 @@ static int pose_flip_names_exec(bContext *C, wmOperator *op)
BLI_freelistN(&bones_names);
/* since we renamed stuff... */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
@@ -808,7 +809,7 @@ static int pose_autoside_names_exec(bContext *C, wmOperator *op)
if (ob_prev != ob) {
/* since we renamed stuff... */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
@@ -860,7 +861,7 @@ static int pose_bone_rotmode_exec(bContext *C, wmOperator *op)
if (prev_ob != ob) {
/* Notifiers and updates. */
- DEG_id_tag_update((ID *)ob, OB_RECALC_DATA);
+ DEG_id_tag_update((ID *)ob, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
prev_ob = ob;
@@ -945,7 +946,7 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op)
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
- DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE);
/* done */
return OPERATOR_FINISHED;
@@ -1013,7 +1014,7 @@ static int armature_layers_exec(bContext *C, wmOperator *op)
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
- DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE);
return OPERATOR_FINISHED;
}
@@ -1084,7 +1085,7 @@ static int pose_bone_layers_exec(bContext *C, wmOperator *op)
if (prev_ob != ob) {
/* Note, notifier might evolve. */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
- DEG_id_tag_update((ID *)ob->data, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update((ID *)ob->data, ID_RECALC_COPY_ON_WRITE);
prev_ob = ob;
}
}
@@ -1210,7 +1211,7 @@ static int pose_hide_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len;
- Object **objects = BKE_object_pose_array_get_unique(view_layer, &objects_len);
+ Object **objects = BKE_object_pose_array_get_unique(view_layer, CTX_wm_view3d(C), &objects_len);
bool changed_multi = false;
const int hide_select = !RNA_boolean_get(op->ptr, "unselected");
@@ -1228,7 +1229,7 @@ static int pose_hide_exec(bContext *C, wmOperator *op)
if (changed) {
changed_multi = true;
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob_iter);
- DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE);
}
}
MEM_freeN(objects);
@@ -1278,7 +1279,7 @@ static int pose_reveal_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len;
- Object **objects = BKE_object_pose_array_get_unique(view_layer, &objects_len);
+ Object **objects = BKE_object_pose_array_get_unique(view_layer, CTX_wm_view3d(C), &objects_len);
bool changed_multi = false;
const bool select = RNA_boolean_get(op->ptr, "select");
void *select_p = POINTER_FROM_INT(select);
@@ -1291,7 +1292,7 @@ static int pose_reveal_exec(bContext *C, wmOperator *op)
if (changed) {
changed_multi = true;
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob_iter);
- DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE);
}
}
MEM_freeN(objects);
@@ -1327,7 +1328,8 @@ static int pose_flip_quats_exec(bContext *C, wmOperator *UNUSED(op))
bool changed_multi = false;
ViewLayer *view_layer = CTX_data_view_layer(C);
- FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob_iter) {
+ View3D *v3d = CTX_wm_view3d(C);
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) {
bool changed = false;
/* loop through all selected pchans, flipping and keying (as needed) */
FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob_iter, pchan) {
@@ -1344,7 +1346,7 @@ static int pose_flip_quats_exec(bContext *C, wmOperator *UNUSED(op))
if (changed) {
changed_multi = true;
/* notifiers and updates */
- DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_iter->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob_iter);
}
} FOREACH_OBJECT_IN_MODE_END;
diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c
index 3a619f771bd..543645b5c1f 100644
--- a/source/blender/editors/armature/pose_group.c
+++ b/source/blender/editors/armature/pose_group.c
@@ -107,7 +107,7 @@ static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op))
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
return OPERATOR_FINISHED;
}
@@ -217,7 +217,7 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op)
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
/* report done status */
if (done)
@@ -267,7 +267,7 @@ static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
/* report done status */
if (done)
@@ -419,7 +419,7 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op))
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 18ce6476105..14706f89607 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -503,7 +503,7 @@ static int poselib_add_exec(bContext *C, wmOperator *op)
/* store new 'active' pose number */
act->active_marker = BLI_listbase_count(&act->markers);
- DEG_id_tag_update(&act->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&act->id, ID_RECALC_COPY_ON_WRITE);
/* done */
return OPERATOR_FINISHED;
@@ -618,7 +618,7 @@ static int poselib_remove_exec(bContext *C, wmOperator *op)
* may be being shown in anim editors as active action
*/
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
- DEG_id_tag_update(&act->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&act->id, ID_RECALC_COPY_ON_WRITE);
/* done */
return OPERATOR_FINISHED;
@@ -1106,7 +1106,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
*/
// FIXME: shouldn't this use the builtin stuff?
if ((pld->arm->flag & ARM_DELAYDEFORM) == 0)
- DEG_id_tag_update(&pld->ob->id, OB_RECALC_DATA); /* sets recalc flags */
+ DEG_id_tag_update(&pld->ob->id, ID_RECALC_GEOMETRY); /* sets recalc flags */
else
BKE_pose_where_is(CTX_data_depsgraph(C), pld->scene, pld->ob);
}
@@ -1613,7 +1613,7 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
* - note: code copied from transform_generics.c -> recalcData()
*/
if ((arm->flag & ARM_DELAYDEFORM) == 0)
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); /* sets recalc flags */
else
BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob);
}
@@ -1626,7 +1626,7 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
action_set_activemarker(act, marker, NULL);
/* Update event for pose and deformation children */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
/* updates */
if (IS_AUTOKEY_MODE(scene, NORMAL)) {
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index 3947fc7388e..184c09f5b10 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -104,11 +104,11 @@ void ED_pose_bone_select_tag_update(Object *ob)
if (arm->flag & ARM_HAS_VIZ_DEPS) {
/* mask modifier ('armature' mode), etc. */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
/* copy on write tag is needed (for the armature), or else no refresh happens */
- DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE);
}
@@ -144,7 +144,7 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
/* called from editview.c, for mode-less pose selection */
/* assumes scene obact and basact is still on old situation */
bool ED_armature_pose_select_pick_with_buffer(
- ViewLayer *view_layer, Base *base, const unsigned int *buffer, short hits,
+ ViewLayer *view_layer, View3D *v3d, Base *base, const unsigned int *buffer, short hits,
bool extend, bool deselect, bool toggle, bool do_nearest)
{
Object *ob = base->object;
@@ -180,7 +180,7 @@ bool ED_armature_pose_select_pick_with_buffer(
if (!extend && !deselect && !toggle) {
{
uint objects_len = 0;
- Object **objects = BKE_object_pose_array_get_unique(view_layer, &objects_len);
+ Object **objects = BKE_object_pose_array_get_unique(view_layer, v3d, &objects_len);
ED_pose_deselect_all_multi(objects, objects_len, SEL_DESELECT, true);
MEM_freeN(objects);
}
@@ -217,7 +217,7 @@ bool ED_armature_pose_select_pick_with_buffer(
if (ob_act->mode & OB_MODE_WEIGHT_PAINT) {
if (nearBone == arm->act_bone) {
ED_vgroup_select_by_name(ob_act, nearBone->name);
- DEG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_act->id, ID_RECALC_GEOMETRY);
}
}
/* if there are some dependencies for visualizing armature state
@@ -227,11 +227,11 @@ bool ED_armature_pose_select_pick_with_buffer(
/* NOTE: ob not ob_act here is intentional - it's the source of the
* bones being selected [T37247]
*/
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
/* tag armature for copy-on-write update (since act_bone is in armature not object) */
- DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE);
}
}
@@ -424,10 +424,10 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
if (ob_prev != ob) {
/* weightpaint or mask modifiers need depsgraph updates */
if (multipaint || (arm->flag & ARM_HAS_VIZ_DEPS)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
/* need to tag armature for cow updates, or else selection doesn't update */
- DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE);
ob_prev = ob;
}
}
@@ -683,7 +683,7 @@ static bool pose_select_same_group(bContext *C, bool extend)
uint ob_index;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, &objects_len, OB_MODE_POSE);
+ Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len, OB_MODE_POSE);
for (ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = BKE_object_pose_armature_get(objects[ob_index]);
bArmature *arm = (ob) ? ob->data : NULL;
@@ -784,7 +784,7 @@ static bool pose_select_same_layer(bContext *C, bool extend)
bool changed = false;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, &objects_len, OB_MODE_POSE);
+ Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len, OB_MODE_POSE);
for (ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
ob->id.tag &= ~LIB_TAG_DOIT;
@@ -896,7 +896,7 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool ex
}
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, &objects_len, OB_MODE_POSE);
+ Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len, OB_MODE_POSE);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = BKE_object_pose_armature_get(objects[ob_index]);
bArmature *arm = (ob) ? ob->data : NULL;
@@ -1024,7 +1024,7 @@ static int pose_select_mirror_exec(bContext *C, wmOperator *op)
const bool extend = RNA_boolean_get(op->ptr, "extend");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, &objects_len, OB_MODE_POSE);
+ Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len, OB_MODE_POSE);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
@@ -1066,14 +1066,14 @@ static int pose_select_mirror_exec(bContext *C, wmOperator *op)
/* In weightpaint we select the associated vertex group too. */
if (is_weight_paint) {
ED_vgroup_select_by_name(ob, pchan_mirror_act->name);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
/* Need to tag armature for cow updates, or else selection doesn't update. */
- DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE);
}
MEM_freeN(objects);
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 75090a656ae..52e580a94af 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -203,6 +203,7 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode)
poseAnim_mapping_get(C, &pso->pfLinks);
Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(CTX_data_view_layer(C),
+ CTX_wm_view3d(C),
&pso->objects_len,
OB_MODE_POSE);
pso->ob_data_array = MEM_callocN(pso->objects_len * sizeof(tPoseSlideObject), "pose slide objects data");
@@ -1567,6 +1568,7 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
ListBase pflinks = {NULL, NULL};
tPChanFCurveLink *pfl;
@@ -1619,7 +1621,7 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
BLI_freelistN(&modeData.sel_markers);
/* updates + notifiers */
- FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, OB_MODE_POSE, ob) {
+ FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) {
poseAnim_mapping_refresh(C, scene, ob);
} FOREACH_OBJECT_IN_MODE_END;
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index 5960c2d3c81..18a9b546e83 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -207,7 +207,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
return OPERATOR_FINISHED;
}
@@ -232,9 +232,10 @@ void POSE_OT_armature_apply(wmOperatorType *ot)
static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
- FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, OB_MODE_POSE, ob)
+ FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob)
{
/* loop over all selected pchans
*
@@ -260,7 +261,7 @@ static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
}
FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
@@ -580,7 +581,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
BKE_main_free(tmp_bmain);
/* Update event for pose and deformation children. */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
/* Recalculate paths if any of the bones have paths... */
if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
@@ -779,7 +780,8 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
/* only clear relevant transforms for selected bones */
ViewLayer *view_layer = CTX_data_view_layer(C);
- FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob_iter)
+ View3D *v3d = CTX_wm_view3d(C);
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter)
{
Object *ob_eval = DEG_get_evaluated_object(CTX_data_depsgraph(C), ob_iter); // XXX: UGLY HACK (for autokey + clear transforms)
ListBase dsources = {NULL, NULL};
@@ -833,7 +835,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
BLI_freelistN(&dsources);
}
- DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_iter->id, ID_RECALC_GEOMETRY);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob_iter);
@@ -935,11 +937,12 @@ void POSE_OT_transforms_clear(wmOperatorType *ot)
static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
float cframe = (float)CFRA;
const bool only_select = RNA_boolean_get(op->ptr, "only_selected");
- FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob)
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob)
{
if ((ob->adt) && (ob->adt->action)) {
/* XXX: this is just like this to avoid contaminating anything else;
@@ -985,7 +988,7 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
}
/* notifiers and updates */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
}
FOREACH_OBJECT_IN_MODE_END;
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index b891a181cfc..051940d69ec 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -240,11 +240,11 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
*/
/* FIXME: shouldn't this use the builtin stuff? */
if ((arm->flag & ARM_DELAYDEFORM) == 0)
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); /* sets recalc flags */
else
BKE_pose_where_is(depsgraph, scene, ob);
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE); /* otherwise animation doesn't get updated */
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); /* otherwise animation doesn't get updated */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
}
@@ -287,9 +287,10 @@ void poseAnim_mapping_reset(ListBase *pfLinks)
void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks, float cframe)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
bool skip = true;
- FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, OB_MODE_POSE, ob) {
+ FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) {
ob->id.tag &= ~LIB_TAG_DOIT;
ob = poseAnim_object_get(ob);
@@ -341,7 +342,7 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks,
* - only do this if keyframes should have been added
* - do not calculate unless there are paths already to update...
*/
- FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, OB_MODE_POSE, ob) {
+ FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) {
if (ob->id.tag & LIB_TAG_DOIT) {
if (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) {
//ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 73cebd257f4..8c725dc8b9c 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1305,7 +1305,7 @@ static int separate_exec(bContext *C, wmOperator *op)
WM_cursor_wait(1);
uint bases_len = 0;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, &bases_len);
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &bases_len);
for (uint b_index = 0; b_index < bases_len; b_index++) {
Base *oldbase = bases[b_index];
Base *newbase;
@@ -1356,8 +1356,8 @@ static int separate_exec(bContext *C, wmOperator *op)
ED_curve_editnurb_free(newob);
curve_delete_segments(oldob, v3d, true);
- DEG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* This is the original one. */
- DEG_id_tag_update(&newob->id, OB_RECALC_DATA); /* This is the separated one. */
+ DEG_id_tag_update(&oldob->id, ID_RECALC_GEOMETRY); /* This is the original one. */
+ DEG_id_tag_update(&newob->id, ID_RECALC_GEOMETRY); /* This is the separated one. */
WM_event_add_notifier(C, NC_GEOM | ND_DATA, oldob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, newob);
@@ -1431,7 +1431,7 @@ static int curve_split_exec(bContext *C, wmOperator *op)
int ok = -1;
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -2394,7 +2394,7 @@ static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
View3D *v3d = CTX_wm_view3d(C);
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -2952,7 +2952,7 @@ static int hide_exec(bContext *C, wmOperator *op)
const bool invert = RNA_boolean_get(op->ptr, "unselected");
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -3006,7 +3006,7 @@ static int hide_exec(bContext *C, wmOperator *op)
}
}
- DEG_id_tag_update(obedit->data, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(obedit->data);
}
@@ -3041,7 +3041,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
bool changed_multi = false;
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
ListBase *editnurb = object_editcurve_get(obedit);
@@ -3080,7 +3080,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
}
if (changed) {
- DEG_id_tag_update(obedit->data, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
changed_multi = true;
}
@@ -3501,7 +3501,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -3600,7 +3600,7 @@ bool ED_curve_pick_vert(
data.mval_fl[1] = vc->mval[1];
uint bases_len;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc->view_layer, &bases_len);
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc->view_layer, vc->v3d, &bases_len);
for (uint base_index = 0; base_index < bases_len; base_index++) {
Base *base = bases[base_index];
data.is_changed = false;
@@ -3782,7 +3782,7 @@ static int set_handle_type_exec(bContext *C, wmOperator *op)
const int handle_type = RNA_enum_get(op->ptr, "type");
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -3840,7 +3840,7 @@ static int curve_normals_make_consistent_exec(bContext *C, wmOperator *op)
const bool calc_length = RNA_boolean_get(op->ptr, "calc_length");
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -4263,7 +4263,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
} status = {0};
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -4573,13 +4573,13 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
if (!extend && !deselect && !toggle) {
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob_iter = objects[ob_index];
ED_curve_deselect_all(((Curve *)ob_iter->data)->editnurb);
- DEG_id_tag_update(ob_iter->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
}
MEM_freeN(objects);
@@ -4678,7 +4678,7 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
ED_object_base_activate(C, basact);
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return true;
@@ -4783,7 +4783,7 @@ static int spin_exec(bContext *C, wmOperator *op)
unit_m4(viewmat);
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = (Curve *)obedit->data;
@@ -4819,14 +4819,13 @@ static int spin_exec(bContext *C, wmOperator *op)
static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
float axis[3] = {0.0f, 0.0f, 1.0f};
if (rv3d)
copy_v3_v3(axis, rv3d->viewinv[2]);
- RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d)->location);
+ RNA_float_set_array(op->ptr, "center", scene->cursor.location);
RNA_float_set_array(op->ptr, "axis", axis);
return spin_exec(C, op);
@@ -5303,7 +5302,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
mul_v3_m4v3(location, vc.obedit->obmat, bp->vec);
}
else {
- copy_v3_v3(location, ED_view3d_cursor3d_get(vc.scene, vc.v3d)->location);
+ copy_v3_v3(location, vc.scene->cursor.location);
}
ED_view3d_win_to_3d_int(vc.v3d, vc.ar, location, event->mval, location);
@@ -5393,7 +5392,7 @@ static int curve_extrude_exec(bContext *C, wmOperator *UNUSED(op))
View3D *v3d = CTX_wm_view3d(C);
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -5542,7 +5541,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
bool changed_multi = false;
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -5622,7 +5621,7 @@ static int duplicate_exec(bContext *C, wmOperator *op)
int ok = -1;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -5641,7 +5640,7 @@ static int duplicate_exec(bContext *C, wmOperator *op)
ok = 1;
BLI_movelisttolist(object_editcurve_get(obedit), &newnurb);
- DEG_id_tag_update(&cu->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&cu->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, &cu->id);
}
MEM_freeN(objects);
@@ -6084,7 +6083,7 @@ static int curve_delete_exec(bContext *C, wmOperator *op)
eCurveElem_Types type = RNA_enum_get(op->ptr, "type");
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
bool changed_multi = false;
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -6188,7 +6187,7 @@ static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op))
View3D *v3d = CTX_wm_view3d(C);
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = (Curve *)obedit->data;
@@ -6314,7 +6313,7 @@ static int curve_decimate_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = (Curve *)obedit->data;
@@ -6535,8 +6534,8 @@ int join_curve_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain); // because we removed object(s), call before editmode!
- DEG_id_tag_update(&ob_active->id, OB_RECALC_OB | OB_RECALC_DATA);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&ob_active->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
@@ -6552,7 +6551,7 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
View3D *v3d = CTX_wm_view3d(C);
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -6659,7 +6658,7 @@ static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
int a;
if (object->runtime.curve_cache == NULL) {
- BKE_displist_make_curveTypes(depsgraph, scene, object, false);
+ BKE_displist_make_curveTypes(depsgraph, scene, object, false, false);
}
INIT_MINMAX(min, max);
diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c
index 7eabd9c96e8..5308660ddee 100644
--- a/source/blender/editors/curve/editcurve_add.c
+++ b/source/blender/editors/curve/editcurve_add.c
@@ -477,13 +477,14 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
Nurb *nu;
bool newob = false;
bool enter_editmode;
+ ushort local_view_bits;
float dia;
float loc[3], rot[3];
float mat[4][4];
WM_operator_view3d_unit_defaults(C, op);
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL))
return OPERATOR_CANCELLED;
if (!isSurf) { /* adding curve */
@@ -491,7 +492,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
const char *name = get_curve_defname(type);
Curve *cu;
- obedit = ED_object_add_type(C, OB_CURVE, name, loc, rot, true);
+ obedit = ED_object_add_type(C, OB_CURVE, name, loc, rot, true, local_view_bits);
newob = true;
cu = (Curve *)obedit->data;
@@ -501,17 +502,17 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
cu->flag |= CU_PATH | CU_3D;
}
else {
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
}
else { /* adding surface */
if (obedit == NULL || obedit->type != OB_SURF) {
const char *name = get_surf_defname(type);
- obedit = ED_object_add_type(C, OB_SURF, name, loc, rot, true);
+ obedit = ED_object_add_type(C, OB_SURF, name, loc, rot, true, local_view_bits);
newob = true;
}
else {
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
}
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 7f8091d66a7..3fe880865bb 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -796,7 +796,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
ED_curve_deselect_all_multi(objects, objects_len);
MEM_freeN(objects);
}
@@ -1121,7 +1121,7 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* use view plane (when set or as fallback when surface can't be found) */
if (cdd->project.use_depth == false) {
- plane_co = ED_view3d_cursor3d_get(cdd->vc.scene, v3d)->location;
+ plane_co = cdd->vc.scene->cursor.location;
plane_no = rv3d->viewinv[2];
cdd->project.use_plane = true;
}
diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c
index 8bd19d42193..cafc3cb076f 100644
--- a/source/blender/editors/curve/editcurve_select.c
+++ b/source/blender/editors/curve/editcurve_select.c
@@ -429,12 +429,12 @@ static int de_select_first_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
selectend_nurb(obedit, FIRST, true, DESELECT);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(obedit->data);
}
@@ -461,12 +461,12 @@ static int de_select_last_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
selectend_nurb(obedit, LAST, true, DESELECT);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(obedit->data);
}
@@ -497,7 +497,7 @@ static int de_select_all_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
View3D *v3d = CTX_wm_view3d(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
@@ -528,7 +528,7 @@ static int de_select_all_exec(bContext *C, wmOperator *op)
break;
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(cu);
}
@@ -565,7 +565,7 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
View3D *v3d = CTX_wm_view3d(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -582,7 +582,7 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
}
if (changed) {
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
}
@@ -654,7 +654,7 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent
Object *obedit = basact->object;
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
if (!select) {
@@ -718,7 +718,7 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
@@ -745,13 +745,13 @@ static int select_next_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
ListBase *editnurb = object_editcurve_get(obedit);
select_adjacent_cp(editnurb, 1, 0, SELECT);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -779,13 +779,13 @@ static int select_previous_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
ListBase *editnurb = object_editcurve_get(obedit);
select_adjacent_cp(editnurb, -1, 0, SELECT);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -879,11 +879,11 @@ static int curve_select_more_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
curve_select_more(obedit);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -1076,11 +1076,11 @@ static int curve_select_less_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
curve_select_less(obedit);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -1152,7 +1152,7 @@ static int curve_select_random_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -1167,7 +1167,7 @@ static int curve_select_random_exec(bContext *C, wmOperator *op)
curve_select_random(editnurb, randfac, seed_iter, select);
BKE_curve_nurb_vert_active_validate(obedit->data);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -1271,7 +1271,7 @@ static int select_nth_exec(bContext *C, wmOperator *op)
WM_operator_properties_checker_interval_from_op(op, &op_params);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
@@ -1282,7 +1282,7 @@ static int select_nth_exec(bContext *C, wmOperator *op)
if (ed_curve_select_nth(obedit->data, &op_params) == true) {
changed = true;
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
}
@@ -1555,7 +1555,7 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
int tot_nurbs_selected_all = 0;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -1637,7 +1637,7 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
}
if (changed) {
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
}
@@ -1890,7 +1890,7 @@ static int edcu_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
ED_object_base_activate(C, basact);
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/curve/editcurve_undo.c b/source/blender/editors/curve/editcurve_undo.c
index ebf24446afc..9163272fbf2 100644
--- a/source/blender/editors/curve/editcurve_undo.c
+++ b/source/blender/editors/curve/editcurve_undo.c
@@ -220,7 +220,7 @@ static bool curve_undosys_step_encode(struct bContext *C, UndoStep *us_p)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
us->elems_len = objects_len;
@@ -256,7 +256,7 @@ static void curve_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UN
continue;
}
undocurve_to_editcurve(&elem->data, obedit->data, &obedit->shapenr);
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
/* The first element is always active */
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index b87584dc8b7..b6b0100773d 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -276,7 +276,7 @@ static void text_update_edited(bContext *C, Object *obedit, int mode)
}
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
}
diff --git a/source/blender/editors/curve/editfont_undo.c b/source/blender/editors/curve/editfont_undo.c
index d4d48e93f43..85e361b495f 100644
--- a/source/blender/editors/curve/editfont_undo.c
+++ b/source/blender/editors/curve/editfont_undo.c
@@ -359,7 +359,7 @@ static void font_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNU
Object *obedit = us->obedit_ref.ptr;
Curve *cu = obedit->data;
undofont_to_editfont(&us->data, cu);
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
}
diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt
index a9f60328288..66e40f16cc2 100644
--- a/source/blender/editors/datafiles/CMakeLists.txt
+++ b/source/blender/editors/datafiles/CMakeLists.txt
@@ -661,6 +661,9 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
brush.sculpt.smooth
brush.sculpt.snake_hook
brush.sculpt.thumb
+ brush.uv_sculpt.grab
+ brush.uv_sculpt.pinch
+ brush.uv_sculpt.relax
none
ops.armature.bone.roll
ops.armature.extrude_cursor
@@ -681,6 +684,7 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
ops.gpencil.edit_mirror
ops.gpencil.edit_shear
ops.gpencil.edit_to_sphere
+ ops.gpencil.primitive_arc
ops.gpencil.primitive_box
ops.gpencil.primitive_circle
ops.gpencil.primitive_line
diff --git a/source/blender/editors/gizmo_library/gizmo_library_intern.h b/source/blender/editors/gizmo_library/gizmo_library_intern.h
index db88a52f087..f58935e1fba 100644
--- a/source/blender/editors/gizmo_library/gizmo_library_intern.h
+++ b/source/blender/editors/gizmo_library/gizmo_library_intern.h
@@ -37,8 +37,6 @@
* Data for common interactions. Used in gizmo_library_utils.c functions.
*/
typedef struct GizmoCommonData {
- int flag;
-
float range_fac; /* factor for arrow min/max distance */
float offset;
@@ -46,6 +44,8 @@ typedef struct GizmoCommonData {
float range;
/* min/max value for constrained gizmos */
float min, max;
+
+ uint is_custom_range_set : 1;
} GizmoCommonData;
typedef struct GizmoInteraction {
@@ -62,12 +62,6 @@ typedef struct GizmoInteraction {
float precision_offset;
} GizmoInteraction;
-/* GizmoCommonData->flag */
-enum {
- GIZMO_CUSTOM_RANGE_SET = (1 << 0),
-};
-
-
float gizmo_offset_from_value(
GizmoCommonData *data, const float value,
const bool constrained, const bool inverted);
diff --git a/source/blender/editors/gizmo_library/gizmo_library_utils.c b/source/blender/editors/gizmo_library/gizmo_library_utils.c
index 25364652785..d8c29eb6675 100644
--- a/source/blender/editors/gizmo_library/gizmo_library_utils.c
+++ b/source/blender/editors/gizmo_library/gizmo_library_utils.c
@@ -99,7 +99,7 @@ float gizmo_value_from_offset(
}
/* clamp to custom range */
- if (data->flag & GIZMO_CUSTOM_RANGE_SET) {
+ if (data->is_custom_range_set) {
CLAMP(value, data->min, max);
}
@@ -124,7 +124,7 @@ void gizmo_property_data_update(
float value = WM_gizmo_target_property_float_get(gz, gz_prop);
if (constrained) {
- if ((data->flag & GIZMO_CUSTOM_RANGE_SET) == 0) {
+ if (data->is_custom_range_set == false) {
float range[2];
if (WM_gizmo_target_property_float_range_get(gz, gz_prop, range)) {
data->range = range[1] - range[0];
diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
index 4e41f95a063..e02d4b8470c 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
@@ -379,7 +379,11 @@ static void gizmo_arrow_exit(bContext *C, wmGizmo *gz, const bool cancel)
/* Assign incase applying the opetration needs an updated offset
* editmesh bisect needs this. */
if (is_prop_valid) {
- data->offset = WM_gizmo_target_property_float_get(gz, gz_prop);
+ const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
+ const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
+ const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
+ const float value = WM_gizmo_target_property_float_get(gz, gz_prop);
+ data->offset = gizmo_offset_from_value(data, value, constrained, inverted);
}
return;
}
@@ -412,7 +416,8 @@ void ED_gizmo_arrow3d_set_ui_range(wmGizmo *gz, const float min, const float max
arrow->data.range = max - min;
arrow->data.min = min;
- arrow->data.flag |= GIZMO_CUSTOM_RANGE_SET;
+ arrow->data.max = max;
+ arrow->data.is_custom_range_set = true;
}
/**
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index c83015675a0..e6747856d1e 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -113,7 +113,7 @@ static void gp_draw_stroke_buffer(
}
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
const tGPspoint *pt = points;
@@ -123,7 +123,7 @@ static void gp_draw_stroke_buffer(
immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
immUniformColor3fvAlpha(ink, ink[3]);
immBegin(GPU_PRIM_POINTS, 1);
- immVertex2iv(pos, &pt->x);
+ immVertex2fv(pos, &pt->x);
}
else {
float oldpressure = points[0].pressure;
@@ -143,7 +143,7 @@ static void gp_draw_stroke_buffer(
if (fabsf(pt->pressure - oldpressure) > 0.2f) {
/* need to have 2 points to avoid immEnd assert error */
if (draw_points < 2) {
- immVertex2iv(pos, &(pt - 1)->x);
+ immVertex2fv(pos, &(pt - 1)->x);
}
immEnd();
@@ -154,7 +154,7 @@ static void gp_draw_stroke_buffer(
/* need to roll-back one point to ensure that there are no gaps in the stroke */
if (i != 0) {
- immVertex2iv(pos, &(pt - 1)->x);
+ immVertex2fv(pos, &(pt - 1)->x);
draw_points++;
}
@@ -162,12 +162,12 @@ static void gp_draw_stroke_buffer(
}
/* now the point we want */
- immVertex2iv(pos, &pt->x);
+ immVertex2fv(pos, &pt->x);
draw_points++;
}
/* need to have 2 points to avoid immEnd assert error */
if (draw_points < 2) {
- immVertex2iv(pos, &(pt - 1)->x);
+ immVertex2fv(pos, &(pt - 1)->x);
}
}
@@ -242,7 +242,7 @@ static void gp_draw_stroke_point(
/* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */
static void gp_draw_stroke_3d(
- const bGPDspoint *points, int totpoints, short thickness, bool UNUSED(debug),
+ const bGPDspoint *points, int totpoints, short thickness,
short UNUSED(sflag), const float ink[4], bool cyclic)
{
float curpressure = points[0].pressure;
@@ -323,7 +323,7 @@ static void gp_draw_stroke_3d(
/* draw a given stroke in 2d */
static void gp_draw_stroke_2d(
const bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag,
- bool UNUSED(debug), int offsx, int offsy, int winx, int winy, const float ink[4])
+ int offsx, int offsy, int winx, int winy, const float ink[4])
{
/* otherwise thickness is twice that of the 3D view */
float thickness = (float)thickness_s * 0.5f;
@@ -521,7 +521,7 @@ static bool gp_can_draw_stroke(const bGPDstroke *gps, const int dflag)
/* draw a set of strokes */
static void gp_draw_strokes(
bGPdata *UNUSED(gpd), bGPDlayer *UNUSED(gpl), const bGPDframe *gpf, int offsx, int offsy, int winx, int winy,
- int dflag, bool debug, short lthick, const float color[4])
+ int dflag, short lthick, const float color[4])
{
GPU_enable_program_point_size();
@@ -552,7 +552,7 @@ static void gp_draw_strokes(
}
else {
gp_draw_stroke_3d(
- gps->points, gps->totpoints, lthick, debug, gps->flag,
+ gps->points, gps->totpoints, lthick, gps->flag,
color, gps->flag & GP_STROKE_CYCLIC);
}
@@ -570,7 +570,7 @@ static void gp_draw_strokes(
}
else {
gp_draw_stroke_2d(
- gps->points, gps->totpoints, lthick, dflag, gps->flag, debug,
+ gps->points, gps->totpoints, lthick, dflag, gps->flag,
offsx, offsy, winx, winy, color);
}
}
@@ -714,6 +714,86 @@ static void gp_draw_strokes_edit(
}
/* ----- General Drawing ------ */
+/* draw onion-skinning for a layer */
+static void gp_draw_onionskins(
+ bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, int offsx, int offsy, int winx, int winy,
+ int UNUSED(cfra), int dflag)
+{
+ const float alpha = 1.0f;
+ float color[4];
+
+ /* 1) Draw Previous Frames First */
+ copy_v3_v3(color, gpl->gcolor_prev);
+
+ if (gpl->gstep > 0) {
+ bGPDframe *gf;
+ float fac;
+
+ /* draw previous frames first */
+ for (gf = gpf->prev; gf; gf = gf->prev) {
+ /* check if frame is drawable */
+ if ((gpf->framenum - gf->framenum) <= gpl->gstep) {
+ /* alpha decreases with distance from curframe index */
+ fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
+ color[3] = alpha * fac * 0.66f;
+ gp_draw_strokes(
+ gpd, gpl, gf, offsx, offsy, winx, winy, dflag,
+ gpl->thickness, color);
+ }
+ else
+ break;
+ }
+ }
+ else if (gpl->gstep == 0) {
+ /* draw the strokes for the ghost frames (at half of the alpha set by user) */
+ if (gpf->prev) {
+ color[3] = (alpha / 7);
+ gp_draw_strokes(
+ gpd, gpl, gpf->prev, offsx, offsy, winx, winy, dflag,
+ gpl->thickness, color);
+ }
+ }
+ else {
+ /* don't draw - disabled */
+ }
+
+
+ /* 2) Now draw next frames */
+ copy_v3_v3(color, gpl->gcolor_next);
+
+ if (gpl->gstep_next > 0) {
+ bGPDframe *gf;
+ float fac;
+
+ /* now draw next frames */
+ for (gf = gpf->next; gf; gf = gf->next) {
+ /* check if frame is drawable */
+ if ((gf->framenum - gpf->framenum) <= gpl->gstep_next) {
+ /* alpha decreases with distance from curframe index */
+ fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1));
+ color[3] = alpha * fac * 0.66f;
+ gp_draw_strokes(
+ gpd, gpl, gf, offsx, offsy, winx, winy, dflag,
+ gpl->thickness, color);
+ }
+ else
+ break;
+ }
+ }
+ else if (gpl->gstep_next == 0) {
+ /* draw the strokes for the ghost frames (at half of the alpha set by user) */
+ if (gpf->next) {
+ color[3] = (alpha / 4);
+ gp_draw_strokes(
+ gpd, gpl, gpf->next, offsx, offsy, winx, winy, dflag,
+ gpl->thickness, color);
+ }
+ }
+ else {
+ /* don't draw - disabled */
+ }
+
+}
/* loop over gpencil data layers, drawing them */
static void gp_draw_data_layers(
@@ -723,7 +803,8 @@ static void gp_draw_data_layers(
float ink[4];
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- bool debug = (gpl->flag & GP_LAYER_DRAWDEBUG);
+ /* verify never thickness is less than 1 */
+ CLAMP_MIN(gpl->thickness, 1.0f);
short lthick = gpl->thickness;
/* apply layer opacity */
@@ -750,8 +831,13 @@ static void gp_draw_data_layers(
/* xray... */
SET_FLAG_FROM_TEST(dflag, gpl->flag & GP_LAYER_NO_XRAY, GP_DRAWDATA_NO_XRAY);
+ /* Draw 'onionskins' (frame left + right) */
+ if (gpl->onion_flag & GP_LAYER_ONIONSKIN) {
+ gp_draw_onionskins(gpd, gpl, gpf, offsx, offsy, winx, winy, cfra, dflag);
+ }
+
/* draw the strokes already in active frame */
- gp_draw_strokes(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, debug, lthick, ink);
+ gp_draw_strokes(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, lthick, ink);
/* Draw verts of selected strokes
* - when doing OpenGL renders, we don't want to be showing these, as that ends up flickering
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 5a8641ed0a7..f03141c3513 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -49,6 +49,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_gpencil.h"
+#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_screen.h"
@@ -140,8 +141,8 @@ typedef struct tGPsdata {
short radius; /* radius of influence for eraser */
- int mval[2]; /* current mouse-position */
- int mvalo[2]; /* previous recorded mouse-position */
+ float mval[2]; /* current mouse-position */
+ float mvalo[2]; /* previous recorded mouse-position */
float pressure; /* current stylus pressure */
float opressure; /* previous stylus pressure */
@@ -232,8 +233,7 @@ static bool gpencil_project_check(tGPsdata *p)
/* get the reference point for stroke-point conversions */
static void gp_get_3d_reference(tGPsdata *p, float vec[3])
{
- View3D *v3d = p->sa->spacedata.first;
- const float *fp = ED_view3d_cursor3d_get(p->scene, v3d)->location;
+ const float *fp = p->scene->cursor.location;
/* use 3D-cursor */
copy_v3_v3(vec, fp);
@@ -242,10 +242,10 @@ static void gp_get_3d_reference(tGPsdata *p, float vec[3])
/* Stroke Editing ---------------------------- */
/* check if the current mouse position is suitable for adding a new point */
-static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2])
+static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float pmval[2])
{
- int dx = abs(mval[0] - pmval[0]);
- int dy = abs(mval[1] - pmval[1]);
+ int dx = (int)fabsf(mval[0] - pmval[0]);
+ int dy = (int)fabsf(mval[1] - pmval[1]);
/* if buffer is empty, just let this go through (i.e. so that dots will work) */
if (p->gpd->runtime.sbuffer_size == 0)
@@ -270,13 +270,15 @@ static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2])
}
/* convert screen-coordinates to buffer-coordinates */
-static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3], float *depth)
+static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[3], float *depth)
{
bGPdata *gpd = p->gpd;
/* in 3d-space - pt->x/y/z are 3 side-by-side floats */
if (gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) {
- if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval, out, 0, depth))) {
+ int mval_i[2];
+ round_v2i_v2fl(mval_i, mval);
+ if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval_i, out, 0, depth))) {
/* projecting onto 3D-Geometry
* - nothing more needs to be done here, since view_autodist_simple() has already done it
*/
@@ -284,7 +286,6 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
else {
float mval_prj[2];
float rvec[3], dvec[3];
- float mval_f[2] = {UNPACK2(mval)};
float zfac;
/* Current method just converts each point in screen-coordinates to
@@ -300,7 +301,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL);
if (ED_view3d_project_float_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- sub_v2_v2v2(mval_f, mval_prj, mval_f);
+ float mval_f[2];
+ sub_v2_v2v2(mval_f, mval_prj, mval);
ED_view3d_win_to_delta(p->ar, mval_f, dvec, zfac);
sub_v3_v3v3(out, rvec, dvec);
}
@@ -331,7 +333,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
/* add current stroke-point to buffer (returns whether point was successfully added) */
static short gp_stroke_addpoint(
- tGPsdata *p, const int mval[2], float pressure, double curtime)
+ tGPsdata *p, const float mval[2], float pressure, double curtime)
{
bGPdata *gpd = p->gpd;
tGPspoint *pt;
@@ -345,7 +347,7 @@ static short gp_stroke_addpoint(
pt = (tGPspoint *)(gpd->runtime.sbuffer);
/* store settings */
- copy_v2_v2_int(&pt->x, mval);
+ copy_v2_v2(&pt->x, mval);
pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */
pt->strength = 1.0f;
pt->time = (float)(curtime - p->inittime);
@@ -360,7 +362,7 @@ static short gp_stroke_addpoint(
pt = ((tGPspoint *)(gpd->runtime.sbuffer) + 1);
/* store settings */
- copy_v2_v2_int(&pt->x, mval);
+ copy_v2_v2(&pt->x, mval);
pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */
pt->strength = 1.0f;
pt->time = (float)(curtime - p->inittime);
@@ -381,7 +383,7 @@ static short gp_stroke_addpoint(
pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_size);
/* store settings */
- copy_v2_v2_int(&pt->x, mval);
+ copy_v2_v2(&pt->x, mval);
pt->pressure = pressure;
pt->strength = 1.0f; /* unused for annotations, but initialise for easier conversions to GP Object */
@@ -402,7 +404,7 @@ static short gp_stroke_addpoint(
pt = (tGPspoint *)(gpd->runtime.sbuffer);
/* store settings */
- copy_v2_v2_int(&pt->x, mval);
+ copy_v2_v2(&pt->x, mval);
pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */
pt->strength = 1.0f;
pt->time = (float)(curtime - p->inittime);
@@ -503,7 +505,7 @@ static void gp_stroke_simplify(tGPsdata *p)
for (i = 0, j = 0; i < num_points; i++) {
if (i - j == 3) {
float co[2], pressure, time;
- int mco[2];
+ float mco[2];
/* initialize values */
co[0] = 0.0f;
@@ -518,8 +520,8 @@ static void gp_stroke_simplify(tGPsdata *p)
GP_SIMPLIFY_AVPOINT(j + 3, -0.25f);
/* set values for adding */
- mco[0] = (int)co[0];
- mco[1] = (int)co[1];
+ mco[0] = co[0];
+ mco[1] = co[1];
/* ignore return values on this... assume to be ok for now */
gp_stroke_addpoint(p, mco, pressure, p->inittime + (double)time);
@@ -643,17 +645,17 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
/* get an array of depths, far depths are blended */
if (gpencil_project_check(p)) {
- int mval[2], mval_prev[2] = { 0 };
+ int mval_i[2], mval_prev[2] = { 0 };
int interp_depth = 0;
int found_depth = 0;
depth_arr = MEM_mallocN(sizeof(float) * gpd->runtime.sbuffer_size, "depth_points");
for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_size; i++, ptc++, pt++) {
- copy_v2_v2_int(mval, &ptc->x);
+ round_v2i_v2fl(mval_i, &ptc->x);
- if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr + i) == 0) &&
- (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr + i) == 0)))
+ if ((ED_view3d_autodist_depth(p->ar, mval_i, depth_margin, depth_arr + i) == 0) &&
+ (i && (ED_view3d_autodist_depth_seg(p->ar, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0)))
{
interp_depth = true;
}
@@ -661,7 +663,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
found_depth = true;
}
- copy_v2_v2_int(mval_prev, mval);
+ copy_v2_v2_int(mval_prev, mval_i);
}
if (found_depth == false) {
@@ -766,10 +768,10 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons
(p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH))
{
RegionView3D *rv3d = p->ar->regiondata;
- const int mval[2] = {x, y};
+ const int mval_i[2] = {x, y};
float mval_3d[3];
- if (ED_view3d_autodist_simple(p->ar, mval, mval_3d, 0, NULL)) {
+ if (ED_view3d_autodist_simple(p->ar, mval_i, mval_3d, 0, NULL)) {
const float depth_mval = view3d_point_depth(rv3d, mval_3d);
const float depth_pt = view3d_point_depth(rv3d, &pt->x);
@@ -786,13 +788,15 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons
static void gp_stroke_eraser_dostroke(
tGPsdata *p,
bGPDframe *gpf, bGPDstroke *gps,
- const int mval[2], const int mvalo[2],
+ const float mval[2], const float mvalo[2],
const int radius, const rcti *rect)
{
bGPDspoint *pt1, *pt2;
int pc1[2] = {0};
int pc2[2] = {0};
int i;
+ int mval_i[2];
+ round_v2i_v2fl(mval_i, mval);
if (gps->totpoints == 0) {
/* just free stroke */
@@ -806,7 +810,7 @@ static void gp_stroke_eraser_dostroke(
/* do boundbox check first */
if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) {
/* only check if point is inside */
- if (len_v2v2_int(mval, pc1) <= radius) {
+ if (len_v2v2_int(mval_i, pc1) <= radius) {
/* free stroke */
gp_free_stroke(gpf, gps);
}
@@ -857,10 +861,10 @@ static void gp_stroke_eraser_dostroke(
(gp_stroke_eraser_is_occluded(p, pt2, pc2[0], pc2[1]) == false))
{
/* Edge is affected - Check individual points now */
- if (len_v2v2_int(mval, pc1) <= radius) {
+ if (len_v2v2_int(mval_i, pc1) <= radius) {
pt1->flag |= GP_SPOINT_TAG;
}
- if (len_v2v2_int(mval, pc2) <= radius) {
+ if (len_v2v2_int(mval_i, pc2) <= radius) {
pt2->flag |= GP_SPOINT_TAG;
}
do_cull = true;
@@ -1185,6 +1189,8 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* get active layer (or add a new one if non-existent) */
p->gpl = BKE_gpencil_layer_getactive(p->gpd);
if (p->gpl == NULL) {
+ /* tag for annotations */
+ p->gpd->flag |= GP_DATA_ANNOTATIONS;
p->gpl = BKE_gpencil_layer_addnew(p->gpd, DATA_("Note"), true);
if (p->custom_color[3])
@@ -1757,7 +1763,7 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event, Depsg
}
/* check if alt key is pressed and limit to straight lines */
- if (p->straight[0] != 0) {
+ if ((p->paintmode != GP_PAINTMODE_ERASER) && (p->straight[0] != 0)) {
if (p->straight[0] == 1) {
/* horizontal */
p->mval[1] = p->straight[1]; /* replace y */
@@ -1868,15 +1874,29 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
{
Object *ob = CTX_data_active_object(C);
ScrArea *sa = CTX_wm_area(C);
+ Scene *scene = CTX_data_scene(C);
tGPsdata *p = NULL;
- /* GPXX Need a better solution */
+ /* if try to do annotations with a gp object selected, first
+ * unselect the object to avoid conflicts.
+ * The solution is not perfect but we can keep running the annotations while
+ * found a better solution.
+ */
if (sa && sa->spacetype == SPACE_VIEW3D) {
if ((ob != NULL) && (ob->type == OB_GPENCIL)) {
- BKE_report(op->reports, RPT_ERROR, "Cannot draw annotation with a Grease Pencil object active");
- return OPERATOR_CANCELLED;
+ ob->mode = OB_MODE_OBJECT;
+ bGPdata *gpd = (bGPdata *)ob->data;
+ ED_gpencil_setup_modes(C, gpd, 0);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ BKE_view_layer_base_deselect_all(view_layer);
+ view_layer->basact = NULL;
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
}
+
if (G.debug & G_DEBUG)
printf("GPencil - Starting Drawing\n");
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 7f67caf91ca..b44c9105e10 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -174,15 +174,15 @@ static void gp_draw_stroke_buffer_fill(const tGPspoint *points, int totpoints, f
/* vertex 1 */
pt = &points[tmp_triangles[i][0]];
gp_set_tpoint_varying_color(pt, ink, color);
- immVertex2iv(pos, &pt->x);
+ immVertex2fv(pos, &pt->x);
/* vertex 2 */
pt = &points[tmp_triangles[i][1]];
gp_set_tpoint_varying_color(pt, ink, color);
- immVertex2iv(pos, &pt->x);
+ immVertex2fv(pos, &pt->x);
/* vertex 3 */
pt = &points[tmp_triangles[i][2]];
gp_set_tpoint_varying_color(pt, ink, color);
- immVertex2iv(pos, &pt->x);
+ immVertex2fv(pos, &pt->x);
}
immEnd();
@@ -219,7 +219,7 @@ static void gp_draw_stroke_buffer(
}
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
const tGPspoint *pt = points;
@@ -230,7 +230,7 @@ static void gp_draw_stroke_buffer(
immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR);
immBegin(GPU_PRIM_POINTS, 1);
gp_set_tpoint_varying_color(pt, ink, color);
- immVertex2iv(pos, &pt->x);
+ immVertex2fv(pos, &pt->x);
}
else {
float oldpressure = points[0].pressure;
@@ -250,7 +250,7 @@ static void gp_draw_stroke_buffer(
/* need to have 2 points to avoid immEnd assert error */
if (draw_points < 2) {
gp_set_tpoint_varying_color(pt - 1, ink, color);
- immVertex2iv(pos, &(pt - 1)->x);
+ immVertex2fv(pos, &(pt - 1)->x);
}
immEnd();
@@ -262,7 +262,7 @@ static void gp_draw_stroke_buffer(
/* need to roll-back one point to ensure that there are no gaps in the stroke */
if (i != 0) {
gp_set_tpoint_varying_color(pt - 1, ink, color);
- immVertex2iv(pos, &(pt - 1)->x);
+ immVertex2fv(pos, &(pt - 1)->x);
draw_points++;
}
@@ -271,13 +271,13 @@ static void gp_draw_stroke_buffer(
/* now the point we want */
gp_set_tpoint_varying_color(pt, ink, color);
- immVertex2iv(pos, &pt->x);
+ immVertex2fv(pos, &pt->x);
draw_points++;
}
/* need to have 2 points to avoid immEnd assert error */
if (draw_points < 2) {
gp_set_tpoint_varying_color(pt - 1, ink, color);
- immVertex2iv(pos, &(pt - 1)->x);
+ immVertex2fv(pos, &(pt - 1)->x);
}
}
@@ -660,8 +660,8 @@ static void gp_draw_stroke_fill(
immUniform2fv("texture_scale", gp_style->texture_scale);
immUniform2fv("texture_offset", gp_style->texture_offset);
immUniform1f("texture_opacity", gp_style->texture_opacity);
- immUniform1i("t_mix", gp_style->flag & GP_STYLE_COLOR_TEX_MIX ? 1 : 0);
- immUniform1i("t_flip", gp_style->flag & GP_STYLE_COLOR_FLIP_FILL ? 1 : 0);
+ immUniform1i("t_mix", (gp_style->flag & GP_STYLE_COLOR_TEX_MIX) != 0);
+ immUniform1i("t_flip", (gp_style->flag & GP_STYLE_COLOR_FLIP_FILL) != 0);
#if 0 /* GPXX disabled, not used in annotations */
/* image texture */
if ((gp_style->fill_style == GP_STYLE_FILL_STYLE_TEXTURE) || (gp_style->flag & GP_STYLE_COLOR_TEX_MIX)) {
diff --git a/source/blender/editors/gpencil/gpencil_add_monkey.c b/source/blender/editors/gpencil/gpencil_add_monkey.c
index 048e933db9a..f2967190406 100644
--- a/source/blender/editors/gpencil/gpencil_add_monkey.c
+++ b/source/blender/editors/gpencil/gpencil_add_monkey.c
@@ -1561,7 +1561,7 @@ void ED_gpencil_create_monkey(bContext *C, float mat[4][4])
BKE_gpencil_stroke_add_points(gps, data35, 261, mat);
/* update depsgraph */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
}
diff --git a/source/blender/editors/gpencil/gpencil_add_stroke.c b/source/blender/editors/gpencil/gpencil_add_stroke.c
index 6c3107c602b..ccab4e3336c 100644
--- a/source/blender/editors/gpencil/gpencil_add_stroke.c
+++ b/source/blender/editors/gpencil/gpencil_add_stroke.c
@@ -246,6 +246,6 @@ void ED_gpencil_create_stroke(bContext *C, float mat[4][4])
BKE_gpencil_stroke_add_points(gps, data0, 175, mat);
/* update depsgraph */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
}
diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index d69f64f3eaf..85c175d03d7 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -323,7 +323,7 @@ static void gpencil_add_verts_to_dgroups(
{
if (bone->segments > 1) {
segments = bone->segments;
- b_bone_spline_setup(pchan, true, bbone_array);
+ BKE_pchan_bbone_spline_setup(pchan, true, bbone_array);
bbone = bbone_array;
}
}
@@ -502,7 +502,7 @@ bool ED_gpencil_add_armature_weights(
"Unable to add a new Armature modifier to object");
return false;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
/* verify armature */
@@ -600,7 +600,7 @@ static int gpencil_generate_weights_exec(bContext *C, wmOperator *op)
gpencil_object_vgroup_calc_from_armature(C, ob, ob_arm, mode, ratio, decay);
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 657c3c8b9b6..9feea61c672 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -109,8 +109,10 @@ typedef struct tGP_BrushEditData {
/* Brush Settings */
GP_Sculpt_Settings *settings;
GP_Sculpt_Data *gp_brush;
+ GP_Sculpt_Data *gp_brush_old;
eGP_Sculpt_Types brush_type;
+ eGP_Sculpt_Types brush_type_old;
eGP_Sculpt_Flag flag;
/* Space Conversion Data */
@@ -119,6 +121,7 @@ typedef struct tGP_BrushEditData {
/* Is the brush currently painting? */
bool is_painting;
+ bool is_weight_mode;
/* Start of new sculpt stroke */
bool first;
@@ -135,7 +138,7 @@ typedef struct tGP_BrushEditData {
/* - position and pressure
* - the *_prev variants are the previous values
*/
- int mval[2], mval_prev[2];
+ float mval[2], mval_prev[2];
float pressure, pressure_prev;
/* - effect vector (e.g. 2D/3D translation for grab brush) */
@@ -258,7 +261,9 @@ static float gp_brush_influence_calc(tGP_BrushEditData *gso, const int radius, c
/* distance fading */
if (gp_brush->flag & GP_SCULPT_FLAG_USE_FALLOFF) {
- float distance = (float)len_v2v2_int(gso->mval, co);
+ int mval_i[2];
+ round_v2i_v2fl(mval_i, gso->mval);
+ float distance = (float)len_v2v2_int(mval_i, co);
float fac;
CLAMP(distance, 0.0f, (float)radius);
@@ -479,9 +484,8 @@ static void gp_brush_grab_calc_dvec(tGP_BrushEditData *gso)
// TODO: incorporate pressure into this?
// XXX: screen-space strokes in 3D space will suffer!
if (gso->sa->spacetype == SPACE_VIEW3D) {
- View3D *v3d = gso->sa->spacedata.first;
RegionView3D *rv3d = gso->ar->regiondata;
- float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d)->location;
+ float *rvec = gso->scene->cursor.location;
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
float mval_f[2];
@@ -587,13 +591,12 @@ static void gp_brush_calc_midpoint(tGP_BrushEditData *gso)
/* Convert mouse position to 3D space
* See: gpencil_paint.c :: gp_stroke_convertcoords()
*/
- View3D *v3d = gso->sa->spacedata.first;
RegionView3D *rv3d = gso->ar->regiondata;
- float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d)->location;
+ const float *rvec = gso->scene->cursor.location;
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
float mval_f[2];
- copy_v2fl_v2i(mval_f, gso->mval);
+ copy_v2_v2(mval_f, gso->mval);
float mval_prj[2];
float dvec[3];
@@ -1205,6 +1208,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
/* store state */
gso->settings = gpsculpt_get_settings(scene);
gso->gp_brush = gpsculpt_get_brush(scene, is_weight_mode);
+ gso->is_weight_mode = is_weight_mode;
if (is_weight_mode) {
gso->brush_type = gso->settings->weighttype;
@@ -1433,7 +1437,9 @@ static bool gpsculpt_brush_do_stroke(
/* do boundbox check first */
if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) {
/* only check if point is inside */
- if (len_v2v2_int(gso->mval, pc1) <= radius) {
+ int mval_i[2];
+ round_v2i_v2fl(mval_i, gso->mval);
+ if (len_v2v2_int(mval_i, pc1) <= radius) {
/* apply operation to this point */
changed = apply(gso, gps, 0, radius, pc1);
}
@@ -1754,7 +1760,7 @@ static void gpsculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA *itempt
/* Updates */
if (changed) {
- DEG_id_tag_update(&gso->gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gso->gpd->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
@@ -1771,6 +1777,8 @@ static void gpsculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA *itempt
static void gpsculpt_brush_apply_event(bContext *C, wmOperator *op, const wmEvent *event)
{
tGP_BrushEditData *gso = op->customdata;
+ ToolSettings *ts = CTX_data_tool_settings(C);
+ GP_Sculpt_Settings *gset = &ts->gp_sculpt;
PointerRNA itemptr;
float mouse[2];
int tablet = 0;
@@ -1804,6 +1812,22 @@ static void gpsculpt_brush_apply_event(bContext *C, wmOperator *op, const wmEven
RNA_float_set(&itemptr, "pressure", 1.0f);
}
+ if (!gso->is_weight_mode) {
+ if (event->shift) {
+ gso->gp_brush_old = gso->gp_brush;
+ gso->brush_type_old = gso->brush_type;
+
+ gso->gp_brush = &gset->brush[GP_SCULPT_TYPE_SMOOTH];
+ gso->brush_type = GP_SCULPT_TYPE_SMOOTH;
+ }
+ else {
+ if (gso->gp_brush_old != NULL) {
+ gso->gp_brush = gso->gp_brush_old;
+ gso->brush_type = gso->brush_type_old;
+ }
+ }
+ }
+
/* apply */
gpsculpt_brush_apply(C, op, &itemptr);
}
@@ -2087,7 +2111,7 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
/* Redraw toolsettings (brush settings)? */
if (redraw_toolsettings) {
- DEG_id_tag_update(&gso->gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gso->gpd->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index fc0464af430..915e678ee34 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -174,7 +174,7 @@ static void gp_strokepoint_convertcoords(
copy_v3_v3(p3d, &pt->x);
}
else {
- const float *fp = ED_view3d_cursor3d_get(scene, v3d)->location;
+ const float *fp = scene->cursor.location;
float mvalf[2];
/* get screen coordinate */
@@ -1395,7 +1395,7 @@ static int gp_convert_layer_exec(bContext *C, wmOperator *op)
}
/* notifiers */
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index e9b65009781..a2cb9612e43 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -259,7 +259,7 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op)
/* notifiers */
bGPdata *gpd = *gpd_ptr;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA | DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -308,7 +308,7 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op)
BKE_gpencil_layer_delete(gpd, gpl);
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -348,7 +348,7 @@ static int gp_layer_move_exec(bContext *C, wmOperator *op)
BLI_assert(ELEM(direction, -1, 0, 1)); /* we use value below */
if (BLI_listbase_link_move(&gpd->layers, gpl, direction)) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
@@ -399,7 +399,7 @@ static int gp_layer_copy_exec(bContext *C, wmOperator *UNUSED(op))
BKE_gpencil_layer_setactive(gpd, new_layer);
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -524,8 +524,8 @@ static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op)
}
/* notifiers */
- DEG_id_tag_update(&gpd_dst->id, OB_RECALC_OB | OB_RECALC_DATA | DEG_TAG_COPY_ON_WRITE);
- DEG_id_tag_update(&ob_dst->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd_dst->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -588,7 +588,7 @@ static int gp_frame_duplicate_exec(bContext *C, wmOperator *op)
}
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -674,7 +674,7 @@ static int gp_frame_clean_fill_exec(bContext *C, wmOperator *op)
/* notifiers */
if (changed) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
@@ -762,7 +762,7 @@ static int gp_frame_clean_loose_exec(bContext *C, wmOperator *op)
/* notifiers */
if (changed) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
@@ -814,7 +814,7 @@ static int gp_hide_exec(bContext *C, wmOperator *op)
}
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -902,7 +902,7 @@ static int gp_reveal_exec(bContext *C, wmOperator *op)
}
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -943,7 +943,7 @@ static int gp_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
}
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -981,7 +981,7 @@ static int gp_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
}
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1054,7 +1054,7 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
}
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1119,7 +1119,7 @@ static int gp_merge_layer_exec(bContext *C, wmOperator *op)
BLI_ghash_free(gh_frames_cur, NULL, NULL);
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1181,7 +1181,7 @@ static int gp_layer_change_exec(bContext *C, wmOperator *op)
BKE_gpencil_layer_setactive(gpd, gpl);
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1318,7 +1318,7 @@ static int gp_stroke_arrange_exec(bContext *C, wmOperator *op)
}
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1424,7 +1424,7 @@ static int gp_stroke_change_color_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1466,7 +1466,7 @@ static int gp_stroke_lock_color_exec(bContext *C, wmOperator *UNUSED(op))
for (short i = 0; i < *totcol; i++) {
Material *tmp_ma = give_current_material(ob, i + 1);
tmp_ma->gp_style->flag |= GP_STYLE_COLOR_LOCKED;
- DEG_id_tag_update(&tmp_ma->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&tmp_ma->id, ID_RECALC_COPY_ON_WRITE);
}
/* loop all selected strokes and unlock any color */
@@ -1484,19 +1484,19 @@ static int gp_stroke_lock_color_exec(bContext *C, wmOperator *UNUSED(op))
Material *tmp_ma = give_current_material(ob, gps->mat_nr + 1);
tmp_ma->gp_style->flag &= ~GP_STYLE_COLOR_LOCKED;
- DEG_id_tag_update(&tmp_ma->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&tmp_ma->id, ID_RECALC_COPY_ON_WRITE);
}
}
}
}
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1594,7 +1594,7 @@ static int gpencil_vertex_group_assign_exec(bContext *C, wmOperator *UNUSED(op))
/* notifiers */
bGPdata *gpd = ob->data;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
return OPERATOR_FINISHED;
@@ -1628,7 +1628,7 @@ static int gpencil_vertex_group_remove_from_exec(bContext *C, wmOperator *UNUSED
/* notifiers */
bGPdata *gpd = ob->data;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
return OPERATOR_FINISHED;
@@ -1662,7 +1662,7 @@ static int gpencil_vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op))
/* notifiers */
bGPdata *gpd = ob->data;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
return OPERATOR_FINISHED;
@@ -1695,7 +1695,7 @@ static int gpencil_vertex_group_deselect_exec(bContext *C, wmOperator *UNUSED(op
/* notifiers */
bGPdata *gpd = ob->data;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
return OPERATOR_FINISHED;
@@ -1751,7 +1751,7 @@ static int gpencil_vertex_group_invert_exec(bContext *C, wmOperator *UNUSED(op))
/* notifiers */
bGPdata *gpd = ob->data;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
return OPERATOR_FINISHED;
@@ -1836,7 +1836,7 @@ static int gpencil_vertex_group_smooth_exec(bContext *C, wmOperator *op)
/* notifiers */
bGPdata *gpd = ob->data;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
return OPERATOR_FINISHED;
@@ -1904,7 +1904,7 @@ static void joined_gpencil_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data)
/* Fix driver references to invalid ID's */
for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) {
/* only change the used targets, since the others will need fixing manually anyway */
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
/* change the ID's used... */
if (dtar->id == src_id) {
@@ -1933,7 +1933,7 @@ static void joined_gpencil_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data)
}
}
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
}
@@ -2189,7 +2189,7 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op))
gp_style = ma->gp_style;
gp_style->flag |= GP_STYLE_COLOR_LOCKED;
gp_style->flag |= GP_STYLE_COLOR_HIDE;
- DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
/* loop all selected strokes and unlock any color used in active layer */
@@ -2202,7 +2202,7 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op))
continue;
ma = give_current_material(ob, gps->mat_nr + 1);
- DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
gp_style = ma->gp_style;
/* unlock/unhide color if not unlocked before */
@@ -2214,13 +2214,13 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op))
}
}
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -2288,7 +2288,7 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op)
continue;
else
gp_style->flag |= flags;
- DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
}
else {
@@ -2297,15 +2297,15 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op)
ma = give_current_material(ob, i + 1);
gp_style = ma->gp_style;
gp_style->flag &= ~flags;
- DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
}
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
@@ -2354,7 +2354,7 @@ static int gpencil_color_hide_exec(bContext *C, wmOperator *op)
color = ma->gp_style;
if (active_color != color) {
color->flag |= GP_STYLE_COLOR_HIDE;
- DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
}
}
@@ -2364,10 +2364,10 @@ static int gpencil_color_hide_exec(bContext *C, wmOperator *op)
}
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
@@ -2412,14 +2412,14 @@ static int gpencil_color_reveal_exec(bContext *C, wmOperator *UNUSED(op))
ma = give_current_material(ob, i + 1);
gp_style = ma->gp_style;
gp_style->flag &= ~GP_STYLE_COLOR_HIDE;
- DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
@@ -2462,14 +2462,14 @@ static int gpencil_color_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
ma = give_current_material(ob, i + 1);
gp_style = ma->gp_style;
gp_style->flag |= GP_STYLE_COLOR_LOCKED;
- DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
@@ -2511,14 +2511,14 @@ static int gpencil_color_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
ma = give_current_material(ob, i + 1);
gp_style = ma->gp_style;
gp_style->flag &= ~GP_STYLE_COLOR_LOCKED;
- DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
@@ -2607,7 +2607,7 @@ static int gpencil_color_select_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index b56d46fdc1e..57fac1d27dc 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -190,7 +190,7 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op)
/* setup other modes */
ED_gpencil_setup_modes(C, gpd, mode);
/* set cache as dirty */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL);
WM_event_add_notifier(C, NC_GPENCIL | ND_GPENCIL_EDITMODE, NULL);
@@ -238,7 +238,7 @@ static int gpencil_selectmode_toggle_exec(bContext *C, wmOperator *op)
ts->gpencil_selectmode = mode;
WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL);
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
return OPERATOR_FINISHED;
}
@@ -330,7 +330,7 @@ static int gpencil_paintmode_toggle_exec(bContext *C, wmOperator *op)
/* setup other modes */
ED_gpencil_setup_modes(C, gpd, mode);
/* set cache as dirty */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_MODE, NULL);
@@ -418,7 +418,7 @@ static int gpencil_sculptmode_toggle_exec(bContext *C, wmOperator *op)
/* setup other modes */
ED_gpencil_setup_modes(C, gpd, mode);
/* set cache as dirty */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_MODE, NULL);
@@ -506,7 +506,7 @@ static int gpencil_weightmode_toggle_exec(bContext *C, wmOperator *op)
/* setup other modes */
ED_gpencil_setup_modes(C, gpd, mode);
/* set cache as dirty */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_MODE, NULL);
@@ -739,7 +739,7 @@ static int gp_duplicate_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1135,7 +1135,7 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
BLI_ghash_free(new_colors, NULL, NULL);
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1250,7 +1250,7 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
}
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1337,7 +1337,7 @@ static int gp_blank_frame_add_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1396,7 +1396,7 @@ static int gp_actframe_delete_exec(bContext *C, wmOperator *op)
BKE_gpencil_layer_delframe(gpl, gpf);
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1454,7 +1454,7 @@ static int gp_actframe_delete_all_exec(bContext *C, wmOperator *op)
/* updates */
if (success) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
@@ -1551,7 +1551,7 @@ static int gp_delete_selected_strokes(bContext *C)
CTX_DATA_END;
if (changed) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
@@ -1665,7 +1665,7 @@ static int gp_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
MEM_freeN(gps->triangles);
}
BLI_freelinkN(&gpf->strokes, gps);
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
else {
/* just copy all points to keep into a smaller buffer */
@@ -1794,7 +1794,7 @@ static int gp_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
CTX_DATA_END;
if (changed) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
@@ -2004,7 +2004,7 @@ static int gp_delete_selected_points(bContext *C)
CTX_DATA_END;
if (changed) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
@@ -2168,8 +2168,8 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
}
}
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
- DEG_id_tag_update(&obact->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&obact->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
@@ -2196,12 +2196,11 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
bGPdata *gpd = ED_gpencil_data_get_active(C);
Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *obact = CTX_data_active_object(C);
const bool use_offset = RNA_boolean_get(op->ptr, "use_offset");
- const float *cursor_global = ED_view3d_cursor3d_get(scene, v3d)->location;
+ const float *cursor_global = scene->cursor.location;
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* only editable and visible layers are considered */
@@ -2252,8 +2251,8 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
}
}
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
- DEG_id_tag_update(&obact->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&obact->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
@@ -2288,7 +2287,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *obact = CTX_data_active_object(C);
- float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
+ float *cursor = scene->cursor.location;
float centroid[3] = {0.0f};
float min[3], max[3];
size_t count = 0;
@@ -2345,7 +2344,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
}
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
return OPERATOR_FINISHED;
@@ -2394,7 +2393,7 @@ static int gp_stroke_apply_thickness_exec(bContext *C, wmOperator *UNUSED(op))
gpl->line_change = 0;
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -2469,7 +2468,7 @@ static int gp_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -2748,7 +2747,7 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
}
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -2816,7 +2815,7 @@ static int gp_stroke_flip_exec(bContext *C, wmOperator *UNUSED(op))
CTX_DATA_END;
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -2857,10 +2856,8 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
ToolSettings *ts = CTX_data_tool_settings(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob = CTX_data_active_object(C);
- ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ar->regiondata;
- View3D *v3d = sa->spacedata.first;
GP_SpaceConversion gsc = {NULL};
eGP_ReprojectModes mode = RNA_enum_get(op->ptr, "type");
@@ -2905,7 +2902,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
/* Project stroke in one axis */
if (ELEM(mode, GP_REPROJECT_FRONT, GP_REPROJECT_SIDE, GP_REPROJECT_TOP)) {
- ED_gp_get_drawing_reference(v3d, scene, ob, gpl,
+ ED_gp_get_drawing_reference(scene, ob, gpl,
ts->gpencil_v3d_align, origin);
int axis = 0;
@@ -2974,7 +2971,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
}
GP_EDITABLE_STROKES_END(gpstroke_iter);
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
@@ -3155,7 +3152,7 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op)
GP_EDITABLE_STROKES_END(gpstroke_iter);
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -3205,7 +3202,7 @@ static int gp_stroke_simplify_exec(bContext *C, wmOperator *op)
GP_EDITABLE_STROKES_END(gpstroke_iter);
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -3255,7 +3252,7 @@ static int gp_stroke_simplify_fixed_exec(bContext *C, wmOperator *op)
GP_EDITABLE_STROKES_END(gpstroke_iter);
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -3456,8 +3453,8 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op)
BLI_addtail(&gpd_dst->layers, gpl);
}
}
- DEG_id_tag_update(&gpd_src->id, OB_RECALC_OB | OB_RECALC_DATA);
- DEG_id_tag_update(&gpd_dst->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd_src->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&gpd_dst->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
@@ -3573,7 +3570,7 @@ static int gp_stroke_split_exec(bContext *C, wmOperator *UNUSED(op))
}
CTX_DATA_END;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 1cdc8274d32..6105a6b2523 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -748,19 +748,21 @@ static void gpencil_get_depth_array(tGPDfill *tgpf)
int depth_margin = 0;
/* get an array of depths, far depths are blended */
- int mval[2], mval_prev[2] = { 0 };
+ int mval_prev[2] = { 0 };
int interp_depth = 0;
int found_depth = 0;
tgpf->depth_arr = MEM_mallocN(sizeof(float) * totpoints, "depth_points");
for (i = 0, ptc = tgpf->sbuffer; i < totpoints; i++, ptc++) {
- copy_v2_v2_int(mval, &ptc->x);
+
+ int mval_i[2];
+ round_v2i_v2fl(mval_i, &ptc->x);
if ((ED_view3d_autodist_depth(
- tgpf->ar, mval, depth_margin, tgpf->depth_arr + i) == 0) &&
+ tgpf->ar, mval_i, depth_margin, tgpf->depth_arr + i) == 0) &&
(i && (ED_view3d_autodist_depth_seg(
- tgpf->ar, mval, mval_prev, depth_margin + 1, tgpf->depth_arr + i) == 0)))
+ tgpf->ar, mval_i, mval_prev, depth_margin + 1, tgpf->depth_arr + i) == 0)))
{
interp_depth = true;
}
@@ -768,7 +770,7 @@ static void gpencil_get_depth_array(tGPDfill *tgpf)
found_depth = true;
}
- copy_v2_v2_int(mval_prev, mval);
+ copy_v2_v2_int(mval_prev, mval_i);
}
if (found_depth == false) {
@@ -880,10 +882,10 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
for (int i = 0; i < tgpf->sbuffer_size && point2D; i++, point2D++, pt++) {
/* convert screen-coordinates to 3D coordinates */
gp_stroke_convertcoords_tpoint(
- tgpf->scene, tgpf->ar, tgpf->v3d, tgpf->ob,
- tgpf->gpl, point2D,
- tgpf->depth_arr ? tgpf->depth_arr + i : NULL,
- &pt->x);
+ tgpf->scene, tgpf->ar, tgpf->ob,
+ tgpf->gpl, point2D,
+ tgpf->depth_arr ? tgpf->depth_arr + i : NULL,
+ &pt->x);
pt->pressure = 1.0f;
pt->strength = 1.0f;
@@ -920,7 +922,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
if ((tgpf->lock_axis > GP_LOCKAXIS_VIEW) && ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_VIEW) == 0)) {
float origin[3];
ED_gp_get_drawing_reference(
- tgpf->v3d, tgpf->scene, tgpf->ob, tgpf->gpl,
+ tgpf->scene, tgpf->ob, tgpf->gpl,
ts->gpencil_v3d_align, origin);
ED_gp_project_stroke_to_plane(
tgpf->ob, tgpf->rv3d, gps, origin,
@@ -1099,7 +1101,7 @@ static void gpencil_fill_exit(bContext *C, wmOperator *op)
/* drawing batch cache is dirty now */
if ((ob) && (ob->type == OB_GPENCIL) && (ob->data)) {
bGPdata *gpd2 = ob->data;
- DEG_id_tag_update(&gpd2->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd2->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
gpd2->flag |= GP_DATA_CACHE_IS_DIRTY;
}
@@ -1160,7 +1162,7 @@ static int gpencil_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
gpencil_fill_status_indicators(C, tgpf);
- DEG_id_tag_update(&tgpf->gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&tgpf->gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
/* add a modal handler for this operator*/
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index d737d34a017..50ae61209cc 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -154,9 +154,12 @@ typedef struct tGPDprimitive {
struct bGPDlayer *gpl; /* layer */
struct bGPDframe *gpf; /* frame */
int type; /* type of primitive */
+ short cyclic; /* cyclic option */
+ short flip; /* flip option */
int tot_edges; /* number of polygon edges */
int top[2]; /* first box corner */
int bottom[2]; /* last box corner */
+ int origin[2]; /* initial box corner */
int flag; /* flag to determine operations in progress */
int lock_axis; /* lock to viewport axis */
@@ -193,7 +196,7 @@ typedef struct GP_SpaceConversion {
} GP_SpaceConversion;
bool gp_stroke_inside_circle(
- const int mval[2], const int UNUSED(mvalo[2]),
+ const float mval[2], const float UNUSED(mvalo[2]),
int rad, int x0, int y0, int x1, int y1);
void gp_point_conversion_init(struct bContext *C, GP_SpaceConversion *r_gsc);
@@ -221,7 +224,7 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, struct Scene *scene, const float
/* helper to convert 2d to 3d */
void gp_stroke_convertcoords_tpoint(
struct Scene *scene, struct ARegion *ar,
- struct View3D *v3d, struct Object *ob,
+ struct Object *ob,
bGPDlayer *gpl, const struct tGPspoint *point2D,
float *depth, float out[3]);
@@ -368,7 +371,8 @@ enum {
enum {
GP_STROKE_BOX = -1,
GP_STROKE_LINE = 1,
- GP_STROKE_CIRCLE = 2
+ GP_STROKE_CIRCLE = 2,
+ GP_STROKE_ARC = 3
};
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index ae1d1454eae..06659a69b82 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -167,7 +167,7 @@ static void gp_interpolate_update_strokes(bContext *C, tGPDinterpolate *tgpi)
}
}
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
}
@@ -433,7 +433,7 @@ static void gpencil_interpolate_exit(bContext *C, wmOperator *op)
BLI_freelistN(&tgpi->ilayers);
MEM_freeN(tgpi);
}
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
/* clear pointer */
@@ -548,7 +548,7 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent
/* update shift indicator in header */
gpencil_interpolate_status_indicators(C, tgpi);
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
/* add a modal handler for this operator */
@@ -1046,7 +1046,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
}
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
@@ -1158,7 +1158,7 @@ static int gpencil_interpolate_reverse_exec(bContext *C, wmOperator *UNUSED(op))
CTX_DATA_END;
/* notifiers */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 3941c757a50..be92f8ab74a 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -156,8 +156,8 @@ typedef struct tGPsdata {
short radius; /* radius of influence for eraser */
- int mval[2]; /* current mouse-position */
- int mvalo[2]; /* previous recorded mouse-position */
+ float mval[2]; /* current mouse-position */
+ float mvalo[2]; /* previous recorded mouse-position */
float pressure; /* current stylus pressure */
float opressure; /* previous stylus pressure */
@@ -208,7 +208,7 @@ typedef struct tGPsdata {
static void gp_update_cache(bGPdata *gpd)
{
if (gpd) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
}
}
@@ -285,21 +285,20 @@ static bool gpencil_project_check(tGPsdata *p)
/* get the reference point for stroke-point conversions */
static void gp_get_3d_reference(tGPsdata *p, float vec[3])
{
- View3D *v3d = p->sa->spacedata.first;
Object *ob = NULL;
if (p->ownerPtr.type == &RNA_Object) {
ob = (Object *)p->ownerPtr.data;
}
- ED_gp_get_drawing_reference(v3d, p->scene, ob, p->gpl, *p->align_flag, vec);
+ ED_gp_get_drawing_reference(p->scene, ob, p->gpl, *p->align_flag, vec);
}
/* Stroke Editing ---------------------------- */
/* check if the current mouse position is suitable for adding a new point */
-static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2])
+static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float pmval[2])
{
Brush *brush = p->brush;
- int dx = abs(mval[0] - pmval[0]);
- int dy = abs(mval[1] - pmval[1]);
+ int dx = (int)fabsf(mval[0] - pmval[0]);
+ int dy = (int)fabsf(mval[1] - pmval[1]);
brush->gpencil_settings->flag &= ~GP_BRUSH_STABILIZE_MOUSE_TEMP;
/* if buffer is empty, just let this go through (i.e. so that dots will work) */
@@ -315,7 +314,7 @@ static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2])
else {
/* If the mouse is moving within the radius of the last move,
* don't update the mouse position. This allows sharp turns. */
- copy_v2_v2_int(p->mval, p->mvalo);
+ copy_v2_v2(p->mval, p->mvalo);
return false;
}
}
@@ -364,7 +363,7 @@ static void gp_reproject_toplane(tGPsdata *p, bGPDstroke *gps)
/* convert screen-coordinates to buffer-coordinates */
/* XXX this method needs a total overhaul! */
-static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3], float *depth)
+static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[3], float *depth)
{
bGPdata *gpd = p->gpd;
@@ -376,7 +375,10 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
*depth *= (1.0f - gpd->zdepth_offset);
}
- if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval, out, 0, depth))) {
+ int mval_i[2];
+ round_v2i_v2fl(mval_i, mval);
+
+ if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval_i, out, 0, depth))) {
/* projecting onto 3D-Geometry
* - nothing more needs to be done here, since view_autodist_simple() has already done it
*/
@@ -391,7 +393,6 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
float mval_prj[2];
float rvec[3], dvec[3];
float mval_f[2];
- copy_v2fl_v2i(mval_f, mval);
float zfac;
/* Current method just converts each point in screen-coordinates to
@@ -407,7 +408,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL);
if (ED_view3d_project_float_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- sub_v2_v2v2(mval_f, mval_prj, mval_f);
+ sub_v2_v2v2(mval_f, mval_prj, mval);
ED_view3d_win_to_delta(p->ar, mval_f, dvec, zfac);
sub_v3_v3v3(out, rvec, dvec);
}
@@ -419,8 +420,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
/* apply jitter to stroke */
static void gp_brush_jitter(
- bGPdata *gpd, Brush *brush, tGPspoint *pt, const int mval[2],
- const float pressure, int r_mval[2], RNG *rng)
+ bGPdata *gpd, Brush *brush, tGPspoint *pt, const float mval[2],
+ const float pressure, float r_mval[2], RNG *rng)
{
float tmp_pressure = pressure;
if (brush->gpencil_settings->draw_jitter > 0.0f) {
@@ -433,8 +434,8 @@ static void gp_brush_jitter(
float mvec[2], svec[2];
/* mouse movement in ints -> floats */
if (gpd->runtime.sbuffer_size > 1) {
- mvec[0] = (float)(mval[0] - (pt - 1)->x);
- mvec[1] = (float)(mval[1] - (pt - 1)->y);
+ mvec[0] = (mval[0] - (pt - 1)->x);
+ mvec[1] = (mval[1] - (pt - 1)->y);
normalize_v2(mvec);
}
else {
@@ -458,7 +459,7 @@ static void gp_brush_jitter(
}
/* apply pressure change depending of the angle of the stroke to simulate a pen with shape */
-static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const int mval[2])
+static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const float mval[2])
{
float mvec[2];
float sen = brush->gpencil_settings->draw_angle_factor; /* sensitivity */;
@@ -470,8 +471,8 @@ static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const int
/* Apply to first point (only if there are 2 points because before no data to do it ) */
if (gpd->runtime.sbuffer_size == 1) {
- mvec[0] = (float)(mval[0] - (pt - 1)->x);
- mvec[1] = (float)(mval[1] - (pt - 1)->y);
+ mvec[0] = (mval[0] - (pt - 1)->x);
+ mvec[1] = (mval[1] - (pt - 1)->y);
normalize_v2(mvec);
/* uses > 1.0f to get a smooth transition in first point */
@@ -483,8 +484,8 @@ static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const int
/* apply from second point */
if (gpd->runtime.sbuffer_size >= 1) {
- mvec[0] = (float)(mval[0] - (pt - 1)->x);
- mvec[1] = (float)(mval[1] - (pt - 1)->y);
+ mvec[0] = (mval[0] - (pt - 1)->x);
+ mvec[1] = (mval[1] - (pt - 1)->y);
normalize_v2(mvec);
fac = 1.0f - fabs(dot_v2v2(v0, mvec)); /* 0.0 to 1.0 */
@@ -533,30 +534,30 @@ static void gp_smooth_buffer(tGPsdata *p, float inf, int idx)
/* Compute smoothed coordinate by taking the ones nearby */
if (pta) {
- copy_v2fl_v2i(a, &pta->x);
+ copy_v2_v2(a, &pta->x);
madd_v2_v2fl(sco, a, average_fac);
}
if (ptb) {
- copy_v2fl_v2i(b, &ptb->x);
+ copy_v2_v2(b, &ptb->x);
madd_v2_v2fl(sco, b, average_fac);
}
if (ptc) {
- copy_v2fl_v2i(c, &ptc->x);
+ copy_v2_v2(c, &ptc->x);
madd_v2_v2fl(sco, c, average_fac);
}
if (ptd) {
- copy_v2fl_v2i(d, &ptd->x);
+ copy_v2_v2(d, &ptd->x);
madd_v2_v2fl(sco, d, average_fac);
}
/* Based on influence factor, blend between original and optimal smoothed coordinate */
interp_v2_v2v2(c, c, sco, inf);
- round_v2i_v2fl(&ptc->x, c);
+ copy_v2_v2(&ptc->x, c);
}
/* add current stroke-point to buffer (returns whether point was successfully added) */
static short gp_stroke_addpoint(
- tGPsdata *p, const int mval[2], float pressure, double curtime)
+ tGPsdata *p, const float mval[2], float pressure, double curtime)
{
bGPdata *gpd = p->gpd;
Brush *brush = p->brush;
@@ -578,7 +579,7 @@ static short gp_stroke_addpoint(
pt = (tGPspoint *)(gpd->runtime.sbuffer);
/* store settings */
- copy_v2_v2_int(&pt->x, mval);
+ copy_v2_v2(&pt->x, mval);
pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */
pt->strength = 1.0f;
pt->time = (float)(curtime - p->inittime);
@@ -593,7 +594,7 @@ static short gp_stroke_addpoint(
pt = ((tGPspoint *)(gpd->runtime.sbuffer) + 1);
/* store settings */
- copy_v2_v2_int(&pt->x, mval);
+ copy_v2_v2(&pt->x, mval);
pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */
pt->strength = 1.0f;
pt->time = (float)(curtime - p->inittime);
@@ -627,13 +628,13 @@ static short gp_stroke_addpoint(
if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) &&
(brush->gpencil_settings->draw_jitter > 0.0f))
{
- int r_mval[2];
+ float r_mval[2];
const float jitpress = (brush->gpencil_settings->flag & GP_BRUSH_USE_JITTER_PRESSURE) ? pressure : 1.0f;
gp_brush_jitter(gpd, brush, pt, mval, jitpress, r_mval, p->rng);
- copy_v2_v2_int(&pt->x, r_mval);
+ copy_v2_v2(&pt->x, r_mval);
}
else {
- copy_v2_v2_int(&pt->x, mval);
+ copy_v2_v2(&pt->x, mval);
}
/* apply randomness to pressure */
if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) &&
@@ -750,7 +751,7 @@ static short gp_stroke_addpoint(
pt = (tGPspoint *)(gpd->runtime.sbuffer);
/* store settings */
- copy_v2_v2_int(&pt->x, mval);
+ copy_v2_v2(&pt->x, mval);
pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */
pt->strength = 1.0f;
pt->time = (float)(curtime - p->inittime);
@@ -1013,17 +1014,18 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
/* get an array of depths, far depths are blended */
if (gpencil_project_check(p)) {
- int mval[2], mval_prev[2] = { 0 };
+ int mval_i[2], mval_prev[2] = { 0 };
int interp_depth = 0;
int found_depth = 0;
depth_arr = MEM_mallocN(sizeof(float) * gpd->runtime.sbuffer_size, "depth_points");
for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_size; i++, ptc++, pt++) {
- copy_v2_v2_int(mval, &ptc->x);
+
+ round_v2i_v2fl(mval_i, &ptc->x);
- if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr + i) == 0) &&
- (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr + i) == 0)))
+ if ((ED_view3d_autodist_depth(p->ar, mval_i, depth_margin, depth_arr + i) == 0) &&
+ (i && (ED_view3d_autodist_depth_seg(p->ar, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0)))
{
interp_depth = true;
}
@@ -1031,7 +1033,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
found_depth = true;
}
- copy_v2_v2_int(mval_prev, mval);
+ copy_v2_v2_int(mval_prev, mval_i);
}
if (found_depth == false) {
@@ -1205,7 +1207,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons
RegionView3D *rv3d = p->ar->regiondata;
bGPDlayer *gpl = p->gpl;
- const int mval[2] = {x, y};
+ const int mval_i[2] = {x, y};
float mval_3d[3];
float fpt[3];
@@ -1213,7 +1215,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons
/* calculate difference matrix if parent object */
ED_gpencil_parent_location(p->depsgraph, obact, p->gpd, gpl, diff_mat);
- if (ED_view3d_autodist_simple(p->ar, mval, mval_3d, 0, NULL)) {
+ if (ED_view3d_autodist_simple(p->ar, mval_i, mval_3d, 0, NULL)) {
const float depth_mval = view3d_point_depth(rv3d, mval_3d);
mul_v3_m4v3(fpt, diff_mat, &pt->x);
@@ -1228,11 +1230,13 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons
}
/* apply a falloff effect to brush strength, based on distance */
-static float gp_stroke_eraser_calc_influence(tGPsdata *p, const int mval[2], const int radius, const int co[2])
+static float gp_stroke_eraser_calc_influence(tGPsdata *p, const float mval[2], const int radius, const int co[2])
{
Brush *brush = p->brush;
/* Linear Falloff... */
- float distance = (float)len_v2v2_int(mval, co);
+ int mval_i[2];
+ round_v2i_v2fl(mval_i, mval);
+ float distance = (float)len_v2v2_int(mval_i, co);
float fac;
CLAMP(distance, 0.0f, (float)radius);
@@ -1326,7 +1330,7 @@ static void gp_stroke_soft_refine(bGPDstroke *gps, const float cull_thresh)
/* TODO: this could really do with some optimization (KD-Tree/BVH?) */
static void gp_stroke_eraser_dostroke(tGPsdata *p,
bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps,
- const int mval[2], const int mvalo[2],
+ const float mval[2], const float mvalo[2],
const int radius, const rcti *rect)
{
Depsgraph *depsgraph = p->depsgraph;
@@ -1338,6 +1342,8 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
int pc2[2] = {0};
int i;
float diff_mat[4][4];
+ int mval_i[2];
+ round_v2i_v2fl(mval_i, mval);
/* calculate difference matrix */
ED_gpencil_parent_location(depsgraph, obact, p->gpd, gpl, diff_mat);
@@ -1355,7 +1361,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
/* do boundbox check first */
if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) {
/* only check if point is inside */
- if (len_v2v2_int(mval, pc1) <= radius) {
+ if (len_v2v2_int(mval_i, pc1) <= radius) {
/* free stroke */
gp_free_stroke(p->gpd, gpf, gps);
}
@@ -1378,7 +1384,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
/* do boundbox check first */
if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) {
/* only check if point is inside */
- if (len_v2v2_int(mval, pc1) <= radius) {
+ if (len_v2v2_int(mval_i, pc1) <= radius) {
/* free stroke */
gp_free_stroke(p->gpd, gpf, gps);
return;
@@ -1711,7 +1717,7 @@ static void gp_init_drawing_brush(bContext *C, tGPsdata *p)
* Maybe this update can be removed when the new tool system
* will be in place, but while, we need this to keep drawing working.
*/
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
}
@@ -1774,7 +1780,6 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
ARegion *ar = CTX_wm_region(C);
ToolSettings *ts = CTX_data_tool_settings(C);
Object *obact = CTX_data_active_object(C);
- View3D *v3d = curarea->spacedata.first;
/* make sure the active view (at the starting time) is a 3d-view */
if (curarea == NULL) {
@@ -1817,11 +1822,17 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
return 0;
}
- /* if active object doesn't exist or isn't a GP Object, create one */
- float *cur = ED_view3d_cursor3d_get(p->scene, v3d)->location;
if ((!obact) || (obact->type != OB_GPENCIL)) {
+ View3D *v3d = p->sa->spacedata.first;
+ /* if active object doesn't exist or isn't a GP Object, create one */
+ const float *cur = p->scene->cursor.location;
+
+ ushort local_view_bits = 0;
+ if (v3d->localvd) {
+ local_view_bits = v3d->local_view_uuid;
+ }
/* create new default object */
- obact = ED_add_gpencil_object(C, p->scene, cur);
+ obact = ED_add_gpencil_object(C, p->scene, cur, local_view_bits);
}
/* assign object after all checks to be sure we have one active */
p->ob = obact;
@@ -2446,10 +2457,10 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra
if (GPENCIL_LAZY_MODE(p->brush, p->shift)) {
float now_mouse[2];
float last_mouse[2];
- copy_v2fl_v2i(now_mouse, p->mval);
- copy_v2fl_v2i(last_mouse, p->mvalo);
+ copy_v2_v2(now_mouse, p->mval);
+ copy_v2_v2(last_mouse, p->mvalo);
interp_v2_v2v2(now_mouse, now_mouse, last_mouse, p->brush->smooth_stroke_factor);
- round_v2i_v2fl(p->mval, now_mouse);
+ copy_v2_v2(p->mval, now_mouse);
}
/* try to add point */
@@ -2506,7 +2517,7 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra
}
/* handle draw event */
-static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent *event, Depsgraph *depsgraph, int x, int y)
+static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent *event, Depsgraph *depsgraph, float x, float y)
{
tGPsdata *p = op->customdata;
PointerRNA itemptr;
@@ -2517,15 +2528,15 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
* add any x,y override position for fake events
* NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding...
*/
- p->mval[0] = event->mval[0] + 1 - x;
- p->mval[1] = event->mval[1] + 1 - y;
+ p->mval[0] = event->mval[0] + 1.0f - x;
+ p->mval[1] = event->mval[1] + 1.0f - y;
p->shift = event->shift;
/* verify key status for straight lines */
if ((event->alt > 0) && (RNA_boolean_get(op->ptr, "disable_straight") == false)) {
if (p->straight[0] == 0) {
- int dx = abs(p->mval[0] - p->mvalo[0]);
- int dy = abs(p->mval[1] - p->mvalo[1]);
+ int dx = (int)fabsf(p->mval[0] - p->mvalo[0]);
+ int dy = (int)fabsf(p->mval[1] - p->mvalo[1]);
if ((dx > 0) || (dy > 0)) {
/* check mouse direction to replace the other coordinate with previous values */
if (dx >= dy) {
@@ -2606,7 +2617,7 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
}
/* check if alt key is pressed and limit to straight lines */
- if (p->straight[0] != 0) {
+ if ((p->paintmode != GP_PAINTMODE_ERASER) && (p->straight[0] != 0)) {
if (p->straight[0] == 1) {
/* horizontal */
p->mval[1] = p->straight[1]; /* replace y */
@@ -2915,7 +2926,7 @@ static void gpencil_add_missing_events(bContext *C, wmOperator *op, const wmEven
}
float factor = ((thickness * dot_factor) / scale) * samples;
- copy_v2fl_v2i(a, p->mvalo);
+ copy_v2_v2(a, p->mvalo);
b[0] = event->mval[0] + 1;
b[1] = event->mval[1] + 1;
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index a9c52741e61..029db23499e 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -84,7 +84,7 @@
#include "gpencil_intern.h"
#define MIN_EDGES 2
-#define MAX_EDGES 100
+#define MAX_EDGES 128
#define IDLE 0
#define IN_PROGRESS 1
@@ -168,7 +168,7 @@ static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
/* enable recalculation flag by default */
gps->flag |= GP_STROKE_RECALC_CACHES;
/* the polygon must be closed, so enabled cyclic */
- if (tgpi->type != GP_STROKE_LINE) {
+ if (tgpi->type != GP_STROKE_LINE && tgpi->type != GP_STROKE_ARC) {
gps->flag |= GP_STROKE_CYCLIC;
}
else {
@@ -210,16 +210,19 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi
char msg_str[UI_MAX_DRAW_STR];
if (tgpi->type == GP_STROKE_BOX) {
- BLI_strncpy(msg_str, IFACE_("Rectangle: ESC/RMB to cancel, LMB set origin, Enter/LMB to confirm, Shift to square"), UI_MAX_DRAW_STR);
+ BLI_strncpy(msg_str, IFACE_("Rectangle: ESC/RMB to cancel, LMB set origin, Enter/LMB to confirm, Shift to square, Alt to center"), UI_MAX_DRAW_STR);
}
else if (tgpi->type == GP_STROKE_LINE) {
- BLI_strncpy(msg_str, IFACE_("Line: ESC/RMB to cancel, LMB set origin, Enter/LMB to confirm"), UI_MAX_DRAW_STR);
+ BLI_strncpy(msg_str, IFACE_("Line: ESC/RMB to cancel, LMB set origin, Enter/LMB to confirm, Alt to center"), UI_MAX_DRAW_STR);
+ }
+ else if (tgpi->type == GP_STROKE_ARC) {
+ BLI_strncpy(msg_str, IFACE_("Arc: ESC/RMB to cancel, Enter/LMB to confirm, WHEEL/+- to adjust edge number, Shift to square, Alt to center, F to flip, C to Close"), UI_MAX_DRAW_STR);
}
else {
- BLI_strncpy(msg_str, IFACE_("Circle: ESC/RMB to cancel, Enter/LMB to confirm, WHEEL to adjust edge number, Shift to square"), UI_MAX_DRAW_STR);
+ BLI_strncpy(msg_str, IFACE_("Circle: ESC/RMB to cancel, Enter/LMB to confirm, WHEEL/+- to adjust edge number, Shift to square, Alt to center"), UI_MAX_DRAW_STR);
}
- if (tgpi->type == GP_STROKE_CIRCLE) {
+ if (tgpi->type == GP_STROKE_CIRCLE || tgpi->type == GP_STROKE_ARC) {
if (hasNumInput(&tgpi->num)) {
char str_offs[NUM_STR_REP_LEN];
@@ -261,17 +264,17 @@ static void gp_primitive_rectangle(tGPDprimitive *tgpi, tGPspoint *points2D)
{
BLI_assert(tgpi->tot_edges == 4);
- points2D[0].x = tgpi->top[0];
- points2D[0].y = tgpi->top[1];
+ points2D[0].x = (float)tgpi->top[0];
+ points2D[0].y = (float)tgpi->top[1];
- points2D[1].x = tgpi->bottom[0];
- points2D[1].y = tgpi->top[1];
+ points2D[1].x = (float)tgpi->bottom[0];
+ points2D[1].y = (float)tgpi->top[1];
- points2D[2].x = tgpi->bottom[0];
- points2D[2].y = tgpi->bottom[1];
+ points2D[2].x = (float)tgpi->bottom[0];
+ points2D[2].y = (float)tgpi->bottom[1];
- points2D[3].x = tgpi->top[0];
- points2D[3].y = tgpi->bottom[1];
+ points2D[3].x = (float)tgpi->top[0];
+ points2D[3].y = (float)tgpi->bottom[1];
}
/* create a line */
@@ -279,11 +282,42 @@ static void gp_primitive_line(tGPDprimitive *tgpi, tGPspoint *points2D)
{
BLI_assert(tgpi->tot_edges == 2);
- points2D[0].x = tgpi->top[0];
- points2D[0].y = tgpi->top[1];
+ points2D[0].x = (float)tgpi->top[0];
+ points2D[0].y = (float)tgpi->top[1];
- points2D[1].x = tgpi->bottom[0];
- points2D[1].y = tgpi->bottom[1];
+ points2D[1].x = (float)tgpi->bottom[0];
+ points2D[1].y = (float)tgpi->bottom[1];
+}
+
+/* create an arc */
+static void gp_primitive_arc(tGPDprimitive *tgpi, tGPspoint *points2D)
+{
+ const int totpoints = tgpi->tot_edges;
+ const float step = M_PI_2 / (float)(totpoints - 1);
+ float length[2];
+ int start[2];
+ int end[2];
+ float a = 0.0f;
+
+ start[0] = tgpi->top[0];
+ start[1] = tgpi->top[1];
+ end[0] = tgpi->bottom[0];
+ end[1] = tgpi->bottom[1];
+
+ if (tgpi->flip) {
+ SWAP(int, end[0], start[0]);
+ SWAP(int, end[1], start[1]);
+ }
+
+ length[0] = end[0] - start[0];
+ length[1] = end[1] - start[1];
+
+ for (int i = 0; i < totpoints; i++) {
+ tGPspoint *p2d = &points2D[i];
+ p2d->x = (start[0] + sinf(a) * length[0]);
+ p2d->y = (end[1] - cosf(a) * length[1]);
+ a += step;
+ }
}
/* create a circle */
@@ -303,9 +337,8 @@ static void gp_primitive_circle(tGPDprimitive *tgpi, tGPspoint *points2D)
for (int i = 0; i < totpoints; i++) {
tGPspoint *p2d = &points2D[i];
-
- p2d->x = (int)(center[0] + cosf(a) * radius[0]);
- p2d->y = (int)(center[1] + sinf(a) * radius[1]);
+ p2d->x = (center[0] + cosf(a) * radius[0]);
+ p2d->y = (center[1] + sinf(a) * radius[1]);
a += step;
}
}
@@ -337,6 +370,13 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
case GP_STROKE_CIRCLE:
gp_primitive_circle(tgpi, points2D);
break;
+ case GP_STROKE_ARC:
+ gp_primitive_arc(tgpi, points2D);
+ if (tgpi->cyclic)
+ gps->flag |= GP_STROKE_CYCLIC;
+ else
+ gps->flag &= ~GP_STROKE_CYCLIC;
+ break;
default:
break;
}
@@ -346,9 +386,8 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
bGPDspoint *pt = &gps->points[i];
tGPspoint *p2d = &points2D[i];
-
/* convert screen-coordinates to 3D coordinates */
- gp_stroke_convertcoords_tpoint(tgpi->scene, tgpi->ar, tgpi->v3d, tgpi->ob, tgpi->gpl, p2d, NULL, &pt->x);
+ gp_stroke_convertcoords_tpoint(tgpi->scene, tgpi->ar, tgpi->ob, tgpi->gpl, p2d, NULL, &pt->x);
pt->pressure = 1.0f;
pt->strength = tgpi->brush->gpencil_settings->draw_strength;
@@ -365,7 +404,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
if (tgpi->lock_axis > GP_LOCKAXIS_VIEW) {
bGPDspoint *tpt = gps->points;
float origin[3];
- ED_gp_get_drawing_reference(tgpi->v3d, tgpi->scene, tgpi->ob, tgpi->gpl,
+ ED_gp_get_drawing_reference(tgpi->scene, tgpi->ob, tgpi->gpl,
ts->gpencil_v3d_align, origin);
for (int i = 0; i < gps->totpoints; i++, tpt++) {
@@ -387,8 +426,8 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
/* free temp data */
MEM_SAFE_FREE(points2D);
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
}
@@ -408,6 +447,9 @@ static void gpencil_primitive_update(bContext *C, wmOperator *op, tGPDprimitive
static void gpencil_primitive_interaction_begin(tGPDprimitive *tgpi, const wmEvent *event)
{
+ tgpi->origin[0] = event->mval[0];
+ tgpi->origin[1] = event->mval[1];
+
tgpi->top[0] = event->mval[0];
tgpi->top[1] = event->mval[1];
@@ -436,7 +478,7 @@ static void gpencil_primitive_exit(bContext *C, wmOperator *op)
MEM_freeN(tgpi->gpf);
MEM_freeN(tgpi);
}
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
/* clear pointer */
@@ -479,8 +521,11 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
/* set parameters */
tgpi->type = RNA_enum_get(op->ptr, "type");
- /* if circle set default to 32 */
+ /* set default edge count */
if (tgpi->type == GP_STROKE_CIRCLE) {
+ RNA_int_set(op->ptr, "edges", 64);
+ }
+ else if (tgpi->type == GP_STROKE_ARC) {
RNA_int_set(op->ptr, "edges", 32);
}
else if (tgpi->type == GP_STROKE_BOX) {
@@ -531,7 +576,7 @@ static int gpencil_primitive_invoke(bContext *C, wmOperator *op, const wmEvent *
/* update sindicator in header */
gpencil_primitive_status_indicators(C, tgpi);
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
/* add a modal handler for this operator */
@@ -583,13 +628,32 @@ static void gpencil_primitive_interaction_end(bContext *C, wmOperator *op, wmWin
}
}
- DEG_id_tag_update(&tgpi->gpd->id, DEG_TAG_COPY_ON_WRITE);
- DEG_id_tag_update(&tgpi->gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&tgpi->gpd->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&tgpi->gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
/* clean up temp data */
gpencil_primitive_exit(C, op);
}
+/* Helper to square a primitive */
+static void gpencil_primitive_to_square(tGPDprimitive *tgpi, const int x, const int y)
+{
+ int w = abs(x);
+ int h = abs(y);
+ if ((x > 0 && y > 0) || (x < 0 && y < 0)) {
+ if (w > h)
+ tgpi->bottom[1] = tgpi->origin[1] + x;
+ else
+ tgpi->bottom[0] = tgpi->origin[0] + y;
+ }
+ else {
+ if (w > h)
+ tgpi->bottom[1] = tgpi->origin[1] - x;
+ else
+ tgpi->bottom[0] = tgpi->origin[0] - y;
+ }
+}
+
/* Modal handler: Events handling during interactive part */
static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
@@ -625,7 +689,6 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
/* done! */
return OPERATOR_FINISHED;
}
-
case ESCKEY: /* cancel */
case RIGHTMOUSE:
{
@@ -639,10 +702,30 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
/* canceled! */
return OPERATOR_CANCELLED;
}
+ case CKEY:
+ {
+ if ((event->val == KM_RELEASE) && tgpi->type == GP_STROKE_ARC) {
+ tgpi->cyclic ^= 1;
+ /* update screen */
+ gpencil_primitive_update(C, op, tgpi);
+ }
+ break;
+ }
+ case FKEY:
+ {
+ if ((event->val == KM_RELEASE) && tgpi->type == GP_STROKE_ARC) {
+ tgpi->flip ^= 1;
+
+ /* update screen */
+ gpencil_primitive_update(C, op, tgpi);
+ }
+ break;
+ }
+ case PADPLUSKEY:
case WHEELUPMOUSE:
{
- if (tgpi->type == GP_STROKE_CIRCLE) {
+ if ((event->val != KM_RELEASE) && (tgpi->type == GP_STROKE_CIRCLE || tgpi->type == GP_STROKE_ARC)) {
tgpi->tot_edges = tgpi->tot_edges + 1;
CLAMP(tgpi->tot_edges, MIN_EDGES, MAX_EDGES);
RNA_int_set(op->ptr, "edges", tgpi->tot_edges);
@@ -652,9 +735,10 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
}
break;
}
+ case PADMINUS:
case WHEELDOWNMOUSE:
{
- if (tgpi->type == GP_STROKE_CIRCLE) {
+ if ((event->val != KM_RELEASE) && (tgpi->type == GP_STROKE_CIRCLE || tgpi->type == GP_STROKE_ARC)) {
tgpi->tot_edges = tgpi->tot_edges - 1;
CLAMP(tgpi->tot_edges, MIN_EDGES, MAX_EDGES);
RNA_int_set(op->ptr, "edges", tgpi->tot_edges);
@@ -671,13 +755,36 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
/* update position of mouse */
tgpi->bottom[0] = event->mval[0];
tgpi->bottom[1] = event->mval[1];
+ tgpi->top[0] = tgpi->origin[0];
+ tgpi->top[1] = tgpi->origin[1];
if (tgpi->flag == IDLE) {
- tgpi->top[0] = event->mval[0];
- tgpi->top[1] = event->mval[1];
+ tgpi->origin[0] = event->mval[0];
+ tgpi->origin[1] = event->mval[1];
}
/* Keep square if shift key */
if (event->shift) {
- tgpi->bottom[1] = tgpi->top[1] - (tgpi->bottom[0] - tgpi->top[0]);
+ int x = tgpi->bottom[0] - tgpi->origin[0];
+ int y = tgpi->bottom[1] - tgpi->origin[1];
+ if (tgpi->type == GP_STROKE_LINE) {
+ float angle = fabsf(atan2f((float)y, (float)x));
+ if (angle < 0.4f || angle > (M_PI - 0.4f)) {
+ tgpi->bottom[1] = tgpi->origin[1];
+ }
+ else if (angle > (M_PI_2 - 0.4f) && angle < (M_PI_2 + 0.4f)) {
+ tgpi->bottom[0] = tgpi->origin[0];
+ }
+ else {
+ gpencil_primitive_to_square(tgpi, x, y);
+ }
+ }
+ else {
+ gpencil_primitive_to_square(tgpi, x, y);
+ }
+ }
+ /* Center primitive if alt key */
+ if (event->alt) {
+ tgpi->top[0] = tgpi->origin[0] - (tgpi->bottom[0] - tgpi->origin[0]);
+ tgpi->top[1] = tgpi->origin[1] - (tgpi->bottom[1] - tgpi->origin[1]);
}
/* update screen */
gpencil_primitive_update(C, op, tgpi);
@@ -726,6 +833,7 @@ void GPENCIL_OT_primitive(wmOperatorType *ot)
{GP_STROKE_BOX, "BOX", 0, "Box", ""},
{GP_STROKE_LINE, "LINE", 0, "Line", ""},
{GP_STROKE_CIRCLE, "CIRCLE", 0, "Circle", ""},
+ {GP_STROKE_ARC, "ARC", 0, "Arc", ""},
{0, NULL, 0, NULL, NULL}
};
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index b3606d26bee..cbe9d7e547a 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -194,10 +194,10 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op)
}
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -255,10 +255,10 @@ static int gpencil_select_linked_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -335,10 +335,10 @@ static int gpencil_select_alternate_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -491,10 +491,10 @@ static int gpencil_select_grouped_exec(bContext *C, wmOperator *op)
}
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -569,10 +569,10 @@ static int gpencil_select_first_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -643,10 +643,10 @@ static int gpencil_select_last_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -733,10 +733,10 @@ static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op))
CTX_DATA_END;
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -818,10 +818,10 @@ static int gpencil_select_less_exec(bContext *C, wmOperator *UNUSED(op))
CTX_DATA_END;
/* updates */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
@@ -905,8 +905,8 @@ static bool gp_stroke_do_circle_sel(
if (((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) ||
((!ELEM(V2D_IS_CLIPPED, x1, y1)) && BLI_rcti_isect_pt(rect, x1, y1)))
{
- int mval[2] = {mx, my};
- int mvalo[2] = {mx, my}; /* dummy - this isn't used... */
+ float mval[2] = {(float)mx, (float)my};
+ float mvalo[2] = {(float)mx, (float)my}; /* dummy - this isn't used... */
/* check if point segment of stroke had anything to do with
* eraser region (either within stroke painted, or on its lines)
@@ -1010,10 +1010,10 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
/* updates */
if (changed) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
}
@@ -1152,15 +1152,15 @@ static int gpencil_generic_select_exec(
if (gpd->flag & GP_DATA_STROKE_PAINTMODE) {
gp_delete_selected_point_wrap(C);
changed = true;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
/* updates */
if (changed) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
}
@@ -1299,6 +1299,28 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot)
/** \name Mouse Pick Select Operator
* \{ */
+/* helper to deselect all selected strokes/points */
+static void deselect_all_selected(bContext *C)
+{
+ CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
+ {
+ /* deselect stroke and its points if selected */
+ if (gps->flag & GP_STROKE_SELECT) {
+ bGPDspoint *pt;
+ int i;
+
+ /* deselect points */
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ pt->flag &= ~GP_SPOINT_SELECT;
+ }
+
+ /* deselect stroke itself too */
+ gps->flag &= ~GP_STROKE_SELECT;
+ }
+ }
+ CTX_DATA_END;
+}
+
static int gpencil_select_exec(bContext *C, wmOperator *op)
{
ScrArea *sa = CTX_wm_area(C);
@@ -1306,7 +1328,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
ToolSettings *ts = CTX_data_tool_settings(C);
/* "radius" is simply a threshold (screen space) to make it easier to test with a tolerance */
- const float radius = 0.75f * U.widget_unit;
+ const float radius = 0.50f * U.widget_unit;
const int radius_squared = (int)(radius * radius);
bool extend = RNA_boolean_get(op->ptr, "extend");
@@ -1374,6 +1396,15 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* Abort if nothing hit... */
if (ELEM(NULL, hit_stroke, hit_point)) {
+
+ /* since left mouse select change, deselect all if click outside any hit */
+ deselect_all_selected(C);
+
+ /* copy on write tag is needed, or else no refresh happens */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+
return OPERATOR_CANCELLED;
}
@@ -1384,23 +1415,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* If not extending selection, deselect everything else */
if (extend == false) {
- CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
- {
- /* deselect stroke and its points if selected */
- if (gps->flag & GP_STROKE_SELECT) {
- bGPDspoint *pt;
- int i;
-
- /* deselect points */
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- pt->flag &= ~GP_SPOINT_SELECT;
- }
-
- /* deselect stroke itself too */
- gps->flag &= ~GP_STROKE_SELECT;
- }
- }
- CTX_DATA_END;
+ deselect_all_selected(C);
}
/* Perform selection operations... */
@@ -1440,10 +1455,10 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* updates */
if (hit_point != NULL) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
/* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
}
diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c
index 1dc46d2850d..212a119facb 100644
--- a/source/blender/editors/gpencil/gpencil_undo.c
+++ b/source/blender/editors/gpencil/gpencil_undo.c
@@ -115,7 +115,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name)
}
}
/* drawing batch cache is dirty now */
- DEG_id_tag_update(&new_gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&new_gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
new_gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
}
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index aff026955d1..7aabe546ce6 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -435,15 +435,14 @@ const EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf(
* \param x1, y1 The screen-space x and y coordinates of the end of the stroke segment
*/
bool gp_stroke_inside_circle(
- const int mval[2], const int UNUSED(mvalo[2]),
+ const float mval[2], const float UNUSED(mvalo[2]),
int rad, int x0, int y0, int x1, int y1)
{
/* simple within-radius check for now */
- const float mval_fl[2] = {mval[0], mval[1]};
const float screen_co_a[2] = {x0, y0};
const float screen_co_b[2] = {x1, y1};
- if (edge_inside_circle(mval_fl, rad, screen_co_a, screen_co_b)) {
+ if (edge_inside_circle(mval, rad, screen_co_a, screen_co_b)) {
return true;
}
@@ -737,9 +736,8 @@ void gp_point_to_xy_fl(
*/
bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen_co[2], float r_out[3])
{
- View3D *v3d = gsc->sa->spacedata.first;
- RegionView3D *rv3d = gsc->ar->regiondata;
- float *rvec = ED_view3d_cursor3d_get(scene, v3d)->location;
+ const RegionView3D *rv3d = gsc->ar->regiondata;
+ float *rvec = scene->cursor.location;
float ref[3] = {rvec[0], rvec[1], rvec[2]};
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
@@ -771,21 +769,23 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen
* \param[out] r_out: The resulting 2D point data
*/
void gp_stroke_convertcoords_tpoint(
- Scene *scene, ARegion *ar, View3D *v3d,
+ Scene *scene, ARegion *ar,
Object *ob, bGPDlayer *gpl,
const tGPspoint *point2D, float *depth,
float r_out[3])
{
ToolSettings *ts = scene->toolsettings;
- const int mval[2] = {point2D->x, point2D->y};
- if ((depth != NULL) && (ED_view3d_autodist_simple(ar, mval, r_out, 0, depth))) {
+ int mval_i[2];
+ round_v2i_v2fl(mval_i, &point2D->x);
+
+ if ((depth != NULL) && (ED_view3d_autodist_simple(ar, mval_i, r_out, 0, depth))) {
/* projecting onto 3D-Geometry
* - nothing more needs to be done here, since view_autodist_simple() has already done it
*/
}
else {
- float mval_f[2] = {(float)point2D->x, (float)point2D->y};
+ float mval_f[2] = {point2D->x, point2D->y};
float mval_prj[2];
float rvec[3], dvec[3];
float zfac;
@@ -793,7 +793,7 @@ void gp_stroke_convertcoords_tpoint(
/* Current method just converts each point in screen-coordinates to
* 3D-coordinates using the 3D-cursor as reference.
*/
- ED_gp_get_drawing_reference(v3d, scene, ob, gpl, ts->gpencil_v3d_align, rvec);
+ ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, rvec);
zfac = ED_view3d_calc_zfac(ar->regiondata, rvec, NULL);
if (ED_view3d_project_float_global(ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
@@ -812,10 +812,10 @@ void gp_stroke_convertcoords_tpoint(
* \param[out] r_vec : Reference point found
*/
void ED_gp_get_drawing_reference(
- View3D *v3d, Scene *scene, Object *ob, bGPDlayer *UNUSED(gpl),
+ const Scene *scene, const Object *ob, bGPDlayer *UNUSED(gpl),
char align_flag, float r_vec[3])
{
- const float *fp = ED_view3d_cursor3d_get(scene, v3d)->location;
+ const float *fp = scene->cursor.location;
/* if using a gpencil object at cursor mode, can use the location of the object */
if (align_flag & GP_PROJECT_VIEWSPACE) {
@@ -841,7 +841,8 @@ void ED_gp_get_drawing_reference(
/**
* Reproject all points of the stroke to a plane locked to axis to avoid stroke offset
*/
-void ED_gp_project_stroke_to_plane(Object *ob, RegionView3D *rv3d, bGPDstroke *gps, const float origin[3], const int axis)
+void ED_gp_project_stroke_to_plane(
+ const Object *ob, const RegionView3D *rv3d, bGPDstroke *gps, const float origin[3], const int axis)
{
float plane_normal[3];
float vn[3];
@@ -887,7 +888,8 @@ void ED_gp_project_stroke_to_plane(Object *ob, RegionView3D *rv3d, bGPDstroke *g
* Reproject given point to a plane locked to axis to avoid stroke offset
* \param[in, out] pt : Point to affect
*/
-void ED_gp_project_point_to_plane(Object *ob, RegionView3D *rv3d, const float origin[3], const int axis, bGPDspoint *pt)
+void ED_gp_project_point_to_plane(
+ const Object *ob, const RegionView3D *rv3d, const float origin[3], const int axis, bGPDspoint *pt)
{
float plane_normal[3];
float vn[3];
@@ -1169,11 +1171,11 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata
/* GP Object Stuff */
/* Helper function to create new OB_GPENCIL Object */
-Object *ED_add_gpencil_object(bContext *C, Scene *UNUSED(scene), const float loc[3])
+Object *ED_add_gpencil_object(bContext *C, Scene *UNUSED(scene), const float loc[3], ushort local_view_bits)
{
float rot[3] = {0.0f};
- Object *ob = ED_object_add_type(C, OB_GPENCIL, NULL, loc, rot, false);
+ Object *ob = ED_object_add_type(C, OB_GPENCIL, NULL, loc, rot, false, local_view_bits);
/* define size */
BKE_object_obdata_size_init(ob, GP_OBGPENCIL_DEFAULT_SIZE);
@@ -1440,7 +1442,7 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob)
/* Cursor drawing */
/* check if cursor is in drawing region */
-static bool gp_check_cursor_region(bContext *C, int mval[2])
+static bool gp_check_cursor_region(bContext *C, int mval_i[2])
{
ARegion *ar = CTX_wm_region(C);
ScrArea *sa = CTX_wm_area(C);
@@ -1460,7 +1462,7 @@ static bool gp_check_cursor_region(bContext *C, int mval[2])
return false;
}
else if (ar) {
- return BLI_rcti_isect_pt_v(&ar->winrct, mval);
+ return BLI_rcti_isect_pt_v(&ar->winrct, mval_i);
}
else {
return false;
@@ -1522,7 +1524,7 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata)
Brush *brush = NULL;
Material *ma = NULL;
MaterialGPencilStyle *gp_style = NULL;
- int *last_mouse_position = customdata;
+ float *last_mouse_position = customdata;
if ((gpd) && (gpd->flag & GP_DATA_STROKE_WEIGHTMODE)) {
gp_brush = &gset->brush[gset->weighttype];
@@ -1536,9 +1538,9 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata)
float darkcolor[3];
float radius = 3.0f;
- int mval[2] = {x, y};
+ int mval_i[2] = {x, y};
/* check if cursor is in drawing region and has valid datablock */
- if ((!gp_check_cursor_region(C, mval)) || (gpd == NULL)) {
+ if ((!gp_check_cursor_region(C, mval_i)) || (gpd == NULL)) {
return;
}
@@ -1672,7 +1674,7 @@ void ED_gpencil_toggle_brush_cursor(bContext *C, bool enable, void *customdata)
{
Scene *scene = CTX_data_scene(C);
GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
- int *lastpost = customdata;
+ float *lastpost = customdata;
if (gset->paintcursor && !enable) {
/* clear cursor */
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 48bf390ee71..3131e5221d8 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -48,6 +48,7 @@ struct Mesh;
struct Object;
struct ReportList;
struct Scene;
+struct View3D;
struct ViewLayer;
struct ViewContext;
struct wmKeyConfig;
@@ -154,7 +155,7 @@ void ED_armature_edit_deselect_all_multi(struct Object **objects, uint objects_l
void ED_armature_edit_deselect_all_visible_multi(struct Object **objects, uint objects_len);
bool ED_armature_pose_select_pick_with_buffer(
- struct ViewLayer *view_layer, struct Base *base, const unsigned int *buffer, short hits,
+ struct ViewLayer *view_layer, struct View3D *v3d, struct Base *base, const unsigned int *buffer, short hits,
bool extend, bool deselect, bool toggle, bool do_nearest);
bool ED_armature_edit_select_pick(
struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
@@ -237,7 +238,6 @@ struct Object *ED_pose_object_from_context(struct bContext *C);
/* meshlaplacian.c */
void ED_mesh_deform_bind_callback(
- struct Scene *scene,
struct MeshDeformModifierData *mmd,
struct Mesh *cagemesh,
float *vertexcos, int totvert, float cagemat[4][4]);
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 8b29c208863..e4e047305c6 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -73,7 +73,7 @@ struct wmWindowManager;
* Used as part of the 'stroke cache' used during drawing of new strokes
*/
typedef struct tGPspoint {
- int x, y; /* x and y coordinates of cursor (in relative to area) */
+ float x, y; /* x and y coordinates of cursor (in relative to area) */
float pressure; /* pressure of tablet at this point */
float strength; /* pressure of tablet at this point for alpha factor */
float time; /* Time relative to stroke start (used when converting to path) */
@@ -222,14 +222,21 @@ void ED_gpencil_create_monkey(struct bContext *C, float mat[4][4]);
void ED_gpencil_create_stroke(struct bContext *C, float mat[4][4]);
/* ------------ Object Utilities ------------ */
-struct Object *ED_add_gpencil_object(struct bContext *C, struct Scene *scene, const float loc[3]);
+struct Object *ED_add_gpencil_object(
+ struct bContext *C, struct Scene *scene, const float loc[3], unsigned short local_view_bits);
void ED_gpencil_add_defaults(struct bContext *C);
/* set object modes */
void ED_gpencil_setup_modes(struct bContext *C, struct bGPdata *gpd, int newmode);
-void ED_gp_project_stroke_to_plane(struct Object *ob, struct RegionView3D *rv3d, struct bGPDstroke *gps, const float origin[3], const int axis);
-void ED_gp_project_point_to_plane(struct Object *ob, struct RegionView3D *rv3d, const float origin[3], const int axis, struct bGPDspoint *pt);
-void ED_gp_get_drawing_reference(struct View3D *v3d, struct Scene *scene, struct Object *ob, struct bGPDlayer *gpl, char align_flag, float vec[3]);
+void ED_gp_project_stroke_to_plane(
+ const struct Object *ob, const struct RegionView3D *rv3d,
+ struct bGPDstroke *gps, const float origin[3], const int axis);
+void ED_gp_project_point_to_plane(
+ const struct Object *ob, const struct RegionView3D *rv3d,
+ const float origin[3], const int axis, struct bGPDspoint *pt);
+void ED_gp_get_drawing_reference(
+ const struct Scene *scene, const struct Object *ob,
+ struct bGPDlayer *gpl, char align_flag, float vec[3]);
/* set sculpt cursor */
void ED_gpencil_toggle_brush_cursor(struct bContext *C, bool enable, void *customdata);
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index ed38e9cae58..b42fdf456e0 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -360,6 +360,12 @@ bool autokeyframe_cfra_can_key(struct Scene *scene, struct ID *id);
*/
bool fcurve_frame_has_keyframe(struct FCurve *fcu, float frame, short filter);
+/* Lesser Keyframe Checking API call:
+ * - Returns whether the current value of a given property differs from the interpolated value.
+ * - Used for button drawing.
+ */
+bool fcurve_is_changed(struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float frame);
+
/* Main Keyframe Checking API call:
* Checks whether a keyframe exists for the given ID-block one the given frame.
* - It is recommended to call this method over the other keyframe-checkers directly,
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index d427454cd7b..a2f034589f6 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -202,7 +202,7 @@ bool EDBM_selectmode_disable(struct Scene *scene, struct BMEditMesh *em,
const short selectmode_disable,
const short selectmode_fallback);
-void EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const bool select);
+bool EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const bool select);
void EDBM_select_toggle_all(struct BMEditMesh *em);
@@ -242,16 +242,15 @@ void EDBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEd
/* editface.c */
-void paintface_flush_flags(struct Object *ob, short flag);
-void paintface_tag_select_update(struct bContext *C, struct Object *ob);
+void paintface_flush_flags(struct bContext *C, struct Object *ob, short flag);
bool paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], bool extend, bool deselect, bool toggle);
int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, int sel_op);
-void paintface_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
+void paintface_deselect_all_visible(struct bContext *C, struct Object *ob, int action, bool flush_flags);
void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], const bool select);
bool paintface_minmax(struct Object *ob, float r_min[3], float r_max[3]);
-void paintface_hide(struct Object *ob, const bool unselected);
-void paintface_reveal(struct Object *ob, const bool select);
+void paintface_hide(struct bContext *C, struct Object *ob, const bool unselected);
+void paintface_reveal(struct bContext *C, struct Object *ob, const bool select);
void paintvert_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
void paintvert_select_ungrouped(struct Object *ob, bool extend, bool flush_flags);
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 1101c966118..58a7e5a1203 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -46,6 +46,7 @@ struct ShaderFxData;
struct Object;
struct ReportList;
struct Scene;
+struct View3D;
struct ViewLayer;
struct bConstraint;
struct bContext;
@@ -111,8 +112,8 @@ void ED_object_parent_clear(struct Object *ob, const int type);
void ED_object_base_select(struct Base *base, eObjectSelect_Mode mode);
void ED_object_base_activate(struct bContext *C, struct Base *base);
void ED_object_base_free_and_unlink(struct Main *bmain, struct Scene *scene, struct Object *ob);
-bool ED_object_base_deselect_all_ex(struct ViewLayer *view_layer, int action, bool *r_any_visible);
-bool ED_object_base_deselect_all(struct ViewLayer *view_layer, int action);
+bool ED_object_base_deselect_all_ex(struct ViewLayer *view_layer, struct View3D *v3d, int action, bool *r_any_visible);
+bool ED_object_base_deselect_all(struct ViewLayer *view_layer, struct View3D *v3d, int action);
/* single object duplicate, if (dupflag == 0), fully linked, else it uses the flags given */
struct Base *ED_object_add_duplicate(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, struct Base *base, int dupflag);
@@ -177,14 +178,15 @@ void ED_object_add_unit_props_size(struct wmOperatorType *ot);
void ED_object_add_unit_props_radius(struct wmOperatorType *ot);
void ED_object_add_generic_props(struct wmOperatorType *ot, bool do_editmode);
void ED_object_add_mesh_props(struct wmOperatorType *ot);
-bool ED_object_add_generic_get_opts(struct bContext *C, struct wmOperator *op, const char view_align_axis,
- float loc[3], float rot[3],
- bool *enter_editmode, bool *is_view_aligned);
+bool ED_object_add_generic_get_opts(
+ struct bContext *C, struct wmOperator *op, const char view_align_axis,
+ float loc[3], float rot[3],
+ bool *enter_editmode, unsigned short *local_view_bits, bool *is_view_aligned);
struct Object *ED_object_add_type(
struct bContext *C,
int type, const char *name, const float loc[3], const float rot[3],
- bool enter_editmode)
+ bool enter_editmode, unsigned short local_view_bits)
ATTR_NONNULL(1) ATTR_RETURNS_NONNULL;
void ED_object_single_users(struct Main *bmain, struct Scene *scene, const bool full, const bool copy_groups);
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index dd17fa6f434..718c8a48300 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -209,7 +209,7 @@ void ED_transform_calc_orientation_from_type(
void ED_transform_calc_orientation_from_type_ex(
const struct bContext *C, float r_mat[3][3],
/* extra args */
- struct Scene *scene, struct View3D *v3d, struct RegionView3D *rv3d, struct Object *ob, struct Object *obedit,
+ struct Scene *scene, struct RegionView3D *rv3d, struct Object *ob, struct Object *obedit,
const short orientation_type, const int pivot_point);
struct TransformBounds {
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index 433c7c7fa48..2fc15f72fca 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -41,6 +41,7 @@ struct ImageUser;
struct Main;
struct Object;
struct Scene;
+struct View3D;
struct ViewLayer;
struct SpaceImage;
struct bNode;
@@ -126,10 +127,11 @@ void ED_uvedit_live_unwrap_end(short cancel);
void ED_uvedit_live_unwrap(struct Scene *scene, struct Object *obedit);
void ED_uvedit_pack_islands(
- struct Scene *scene, struct Object *ob, struct BMesh *bm, bool selected, bool correct_aspect, bool do_rotate);
+ struct Scene *scene, struct Object *ob, struct BMesh *bm,
+ bool selected, bool correct_aspect, bool do_rotate);
void ED_uvedit_pack_islands_multi(
struct Scene *scene, struct Object **objects, const uint objects_len,
- bool selected, bool correct_aspect, bool do_rotate);
+ bool selected, bool correct_aspect, bool do_rotate, bool implicit);
void ED_uvedit_unwrap_cube_project(
struct BMesh *bm, float cube_size, bool use_select, const float center[3]);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index b1d450e2dd9..0e9c2cf3759 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -109,9 +109,8 @@ enum eV3DCursorOrient {
};
void ED_view3d_background_color_get(const struct Scene *scene, const struct View3D *v3d, float r_color[3]);
-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_calc_mat3(const struct Scene *scene, float mat[3][3]);
+void ED_view3d_cursor3d_calc_mat4(const struct Scene *scene, float mat[4][4]);
void ED_view3d_cursor3d_position(
struct bContext *C, const int mval[2],
const bool use_depth,
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index dd0070b3b37..bb45fbd4615 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -195,11 +195,12 @@ enum {
UI_BUT_TEXTEDIT_UPDATE = (1 << 29), /* when widget is in textedit mode, update value on each char stroke */
UI_BUT_VALUE_CLEAR = (1 << 30), /* show 'x' icon to clear/unlink value of text or search button */
- UI_BUT_OVERRIDEN = (1 << 31), /* RNA property of the button is overridden from linked reference data. */
+ UI_BUT_OVERRIDEN = (1u << 31u), /* RNA property of the button is overridden from linked reference data. */
};
#define UI_PANEL_WIDTH 340
#define UI_COMPACT_PANEL_WIDTH 160
+#define UI_NAVIGATION_REGION_WIDTH UI_COMPACT_PANEL_WIDTH
#define UI_PANEL_CATEGORY_MARGIN_WIDTH (U.widget_unit * 1.0f)
@@ -239,6 +240,8 @@ enum {
UI_BUT_HAS_SHORTCUT = (1 << 23), /* Button has shortcut text. */
UI_BUT_ICON_REVERSE = (1 << 24), /* Reverse order of consecutive off/on icons */
+
+ UI_BUT_ANIMATED_CHANGED = (1 << 25), /* Value is animated, but the current value differs from the animated one. */
};
/* scale fixed button widths by this to account for DPI */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 6fc627d3847..f9d17386be6 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -90,6 +90,7 @@
/* prototypes. */
static void ui_but_to_pixelrect(struct rcti *rect, const struct ARegion *ar, struct uiBlock *block, struct uiBut *but);
+static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *but_p);
/* avoid unneeded calls to ui_but_value_get */
#define UI_BUT_VALUE_UNSET DBL_MAX
@@ -1058,6 +1059,11 @@ static bool ui_but_event_property_operator_string(
char *buf, const size_t buf_len)
{
/* context toggle operator names to check... */
+
+ /* This function could use a refactor to generalize button type to operator relationship
+ * as well as which operators use properties.
+ * - Campbell
+ * */
const char *ctx_toggle_opnames[] = {
"WM_OT_context_toggle",
"WM_OT_context_toggle_enum",
@@ -1067,54 +1073,110 @@ static bool ui_but_event_property_operator_string(
"WM_OT_context_menu_enum",
NULL
};
- const size_t num_ops = sizeof(ctx_toggle_opnames) / sizeof(const char *);
+
+ const char *ctx_enum_opnames[] = {
+ "WM_OT_context_set_enum",
+ NULL
+ };
+
+ const char *ctx_enum_opnames_for_Area_ui_type[] = {
+ "SCREEN_OT_space_type_set_or_cycle",
+ NULL
+ };
+
+ const char **opnames = ctx_toggle_opnames;
+ int opnames_len = ARRAY_SIZE(ctx_toggle_opnames);
+
+
+ int prop_enum_value = -1;
+ bool prop_enum_value_ok = false;
+ bool prop_enum_value_is_int = false;
+ const char *prop_enum_value_id = "value";
+ PointerRNA *ptr = &but->rnapoin;
+ PropertyRNA *prop = but->rnaprop;
+ if ((but->type == UI_BTYPE_BUT_MENU) && (but->block->handle != NULL)) {
+ uiBut *but_parent = but->block->handle->popup_create_vars.but;
+ if ((but->type == UI_BTYPE_BUT_MENU) &&
+ (but_parent && but_parent->rnaprop) &&
+ (RNA_property_type(but_parent->rnaprop) == PROP_ENUM) &&
+ (but_parent->menu_create_func == ui_def_but_rna__menu))
+ {
+ prop_enum_value = (int)but->hardmin;
+ ptr = &but_parent->rnapoin;
+ prop = but_parent->rnaprop;
+ prop_enum_value_ok = true;
+
+ opnames = ctx_enum_opnames;
+ opnames_len = ARRAY_SIZE(ctx_enum_opnames);
+ }
+ }
bool found = false;
+ /* Don't use the button again. */
+ but = NULL;
+
/* this version is only for finding hotkeys for properties (which get set via context using operators) */
- if (but->rnaprop) {
+ if (prop) {
/* to avoid massive slowdowns on property panels, for now, we only check the
* hotkeys for Editor / Scene settings...
*
* TODO: userpref settings?
*/
- // TODO: value (for enum stuff)?
char *data_path = NULL;
- if (but->rnapoin.id.data) {
- ID *id = but->rnapoin.id.data;
+ if (ptr->id.data) {
+ ID *id = ptr->id.data;
if (GS(id->name) == ID_SCR) {
/* screen/editor property
* NOTE: in most cases, there is actually no info for backwards tracing
* how to get back to ID from the editor data we may be dealing with
*/
- if (RNA_struct_is_a(but->rnapoin.type, &RNA_Space)) {
+ if (RNA_struct_is_a(ptr->type, &RNA_Space)) {
/* data should be directly on here... */
- data_path = BLI_sprintfN("space_data.%s", RNA_property_identifier(but->rnaprop));
+ data_path = BLI_sprintfN("space_data.%s", RNA_property_identifier(prop));
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_Area)) {
+ /* data should be directly on here... */
+ const char *prop_id = RNA_property_identifier(prop);
+ /* Hack since keys access 'type', UI shows 'ui_type'. */
+ if (STREQ(prop_id, "ui_type")) {
+ prop_id = "type";
+ prop_enum_value >>= 16;
+ prop = RNA_struct_find_property(ptr, prop_id);
+
+ opnames = ctx_enum_opnames_for_Area_ui_type;
+ opnames_len = ARRAY_SIZE(ctx_enum_opnames_for_Area_ui_type);
+ prop_enum_value_id = "space_type";
+ prop_enum_value_is_int = true;
+ }
+ else {
+ data_path = BLI_sprintfN("area.%s", prop_id);
+ }
}
else {
/* special exceptions for common nested data in editors... */
- if (RNA_struct_is_a(but->rnapoin.type, &RNA_DopeSheet)) {
+ if (RNA_struct_is_a(ptr->type, &RNA_DopeSheet)) {
/* dopesheet filtering options... */
- data_path = BLI_sprintfN("space_data.dopesheet.%s", RNA_property_identifier(but->rnaprop));
+ data_path = BLI_sprintfN("space_data.dopesheet.%s", RNA_property_identifier(prop));
}
- else if (RNA_struct_is_a(but->rnapoin.type, &RNA_FileSelectParams)) {
+ else if (RNA_struct_is_a(ptr->type, &RNA_FileSelectParams)) {
/* Filebrowser options... */
- data_path = BLI_sprintfN("space_data.params.%s", RNA_property_identifier(but->rnaprop));
+ data_path = BLI_sprintfN("space_data.params.%s", RNA_property_identifier(prop));
}
}
}
else if (GS(id->name) == ID_SCE) {
- if (RNA_struct_is_a(but->rnapoin.type, &RNA_ToolSettings)) {
+ if (RNA_struct_is_a(ptr->type, &RNA_ToolSettings)) {
/* toolsettings property
* NOTE: toolsettings is usually accessed directly (i.e. not through scene)
*/
- data_path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
+ data_path = RNA_path_from_ID_to_property(ptr, prop);
}
else {
/* scene property */
- char *path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
+ char *path = RNA_path_from_ID_to_property(ptr, prop);
if (path) {
data_path = BLI_sprintfN("scene.%s", path);
@@ -1123,7 +1185,7 @@ static bool ui_but_event_property_operator_string(
#if 0
else {
printf("ERROR in %s(): Couldn't get path for scene property - %s\n",
- __func__, RNA_property_identifier(but->rnaprop));
+ __func__, RNA_property_identifier(prop));
}
#endif
}
@@ -1132,26 +1194,49 @@ static bool ui_but_event_property_operator_string(
//puts("other id");
}
- //printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(but->rnaprop), data_path);
+ //printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(prop), data_path);
}
/* we have a datapath! */
- if (data_path) {
- size_t i;
-
+ if (data_path || (prop_enum_value_ok && prop_enum_value_id)) {
/* create a property to host the "datapath" property we're sending to the operators */
IDProperty *prop_path;
- IDProperty *prop_path_value;
IDPropertyTemplate val = {0};
prop_path = IDP_New(IDP_GROUP, &val, __func__);
- prop_path_value = IDP_NewString(data_path, "data_path", strlen(data_path) + 1);
- IDP_AddToGroup(prop_path, prop_path_value);
+ if (data_path) {
+ IDP_AddToGroup(prop_path, IDP_NewString(data_path, "data_path", strlen(data_path) + 1));
+ }
+ if (prop_enum_value_ok) {
+ const EnumPropertyItem *item;
+ bool free;
+ RNA_property_enum_items((bContext *)C, ptr, prop, &item, NULL, &free);
+ int index = RNA_enum_from_value(item, prop_enum_value);
+ if (index != -1) {
+ IDProperty *prop_value;
+ if (prop_enum_value_is_int) {
+ int value = item[index].value;
+ prop_value = IDP_New(IDP_INT, &(IDPropertyTemplate){ .i = value, }, prop_enum_value_id);
+ }
+ else {
+ const char *id = item[index].identifier;
+ prop_value = IDP_NewString(id, prop_enum_value_id, strlen(id) + 1);
+ }
+ IDP_AddToGroup(prop_path, prop_value);
+ }
+ else {
+ opnames_len = 0; /* Do nothing. */
+ }
+ if (free) {
+ MEM_freeN((void *)item);
+ }
+ }
/* check each until one works... */
- for (i = 0; (i < num_ops) && (ctx_toggle_opnames[i]); i++) {
+
+ for (int i = 0; (i < opnames_len) && (opnames[i]); i++) {
if (WM_key_event_operator_string(
- C, ctx_toggle_opnames[i], WM_OP_INVOKE_REGION_WIN, prop_path, false,
+ C, opnames[i], WM_OP_INVOKE_REGION_WIN, prop_path, false,
buf, buf_len))
{
found = true;
@@ -1162,7 +1247,9 @@ static bool ui_but_event_property_operator_string(
/* cleanup */
IDP_FreeProperty(prop_path);
MEM_freeN(prop_path);
- MEM_freeN(data_path);
+ if (data_path) {
+ MEM_freeN(data_path);
+ }
}
}
@@ -3662,8 +3749,16 @@ static uiBut *ui_def_but_rna(
ui_def_but_icon(but, icon, UI_HAS_ICON);
}
- if ((type == UI_BTYPE_MENU) && (but->dt == UI_EMBOSS_PULLDOWN)) {
- ui_but_submenu_enable(block, but);
+ if (type == UI_BTYPE_MENU) {
+ if (but->dt == UI_EMBOSS_PULLDOWN) {
+ ui_but_submenu_enable(block, but);
+ }
+ }
+ else if (type == UI_BTYPE_SEARCH_MENU) {
+ if (proptype == PROP_POINTER) {
+ /* Search buttons normally don't get undo, see: T54580. */
+ but->flag |= UI_BUT_UNDO;
+ }
}
const char *info;
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 4fe555615c2..42615821ee0 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -76,6 +76,7 @@ void ui_but_anim_flag(uiBut *but, float cfra)
bool special;
but->flag &= ~(UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN);
+ but->drawflag &= ~UI_BUT_ANIMATED_CHANGED;
/* NOTE: "special" is reserved for special F-Curves stored on the animation data
* itself (which are used to animate properties of the animation data).
@@ -96,6 +97,9 @@ void ui_but_anim_flag(uiBut *but, float cfra)
if (fcurve_frame_has_keyframe(fcu, cfra, 0))
but->flag |= UI_BUT_ANIMATED_KEY;
+
+ if (fcurve_is_changed(but->rnapoin, but->rnaprop, fcu, cfra))
+ but->drawflag |= UI_BUT_ANIMATED_CHANGED;
}
else {
but->flag |= UI_BUT_DRIVEN;
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index 0ffc97444e1..bbc0f66605c 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -235,9 +235,21 @@ static bUserMenuItem *ui_but_user_menu_find(bContext *C, uiBut *but, bUserMenu *
}
else if (but->rnaprop) {
const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin);
+ const char *data_path = RNA_path_from_ID_to_struct(&but->rnapoin);
+ const char *member_id_data_path = member_id;
+ if (data_path) {
+ member_id_data_path = BLI_sprintfN("%s.%s", member_id, data_path);
+ }
const char *prop_id = RNA_property_identifier(but->rnaprop);
- return (bUserMenuItem *)ED_screen_user_menu_item_find_prop(
- &um->items, member_id, prop_id, but->rnaindex);
+ bUserMenuItem *umi = (bUserMenuItem *)ED_screen_user_menu_item_find_prop(
+ &um->items, member_id_data_path, prop_id, but->rnaindex);
+ if (data_path) {
+ MEM_freeN((void *)data_path);
+ }
+ if (member_id != member_id_data_path) {
+ MEM_freeN((void *)member_id_data_path);
+ }
+ return umi;
}
else if ((mt = UI_but_menutype_get(but))) {
return (bUserMenuItem *)ED_screen_user_menu_item_find_menu(
@@ -263,6 +275,12 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
MenuType *mt = NULL;
if (but->optype) {
+ if (drawstr[0] == '\0') {
+ /* Hard code overrides for generic operators. */
+ if (UI_but_is_tool(but)) {
+ RNA_string_get(but->opptr, "name", drawstr);
+ }
+ }
ED_screen_user_menu_item_add_operator(
&um->items, drawstr,
but->optype, but->opptr ? but->opptr->data : NULL, but->opcontext);
@@ -394,11 +412,11 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
const int override_status = RNA_property_static_override_status(ptr, prop, -1);
const bool is_overridable = (override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE) != 0;
+ /* Set the (button_pointer, button_prop) and pointer data for Python access to the hovered ui element. */
+ uiLayoutSetContextFromBut(layout, but);
+
/* 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(
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 8c785f63978..59f8cfdb562 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -628,7 +628,7 @@ void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highligh
immAttr3ubv(col, highlight);
/* back to corner left-top */
- immVertex2f(pos, minx, roundboxtype & UI_CNR_TOP_LEFT ? maxy - rad : maxy);
+ immVertex2f(pos, minx, (roundboxtype & UI_CNR_TOP_LEFT) ? (maxy - rad) : maxy);
immEnd();
immUnbindProgram();
diff --git a/source/blender/editors/interface/interface_eyedropper_driver.c b/source/blender/editors/interface/interface_eyedropper_driver.c
index 852f7ea71b6..93719527380 100644
--- a/source/blender/editors/interface/interface_eyedropper_driver.c
+++ b/source/blender/editors/interface/interface_eyedropper_driver.c
@@ -133,7 +133,7 @@ static void driverdropper_sample(bContext *C, wmOperator *op, const wmEvent *eve
/* send updates */
UI_context_update_anim_flag(C);
DEG_relations_tag_update(CTX_data_main(C));
- DEG_id_tag_update(ddr->ptr.id.data, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(ddr->ptr.id.data, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX
}
}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index b8355b31ff0..baf472deb28 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4381,7 +4381,7 @@ static void ui_numedit_set_active(uiBut *but)
/* we can click on the side arrows to increment/decrement,
* or click inside to edit the value directly */
int mx = data->window->eventstate->x;
- int my = data->window->eventstate->x;
+ int my = data->window->eventstate->y;
ui_window_to_block(data->region, but->block, &mx, &my);
if (mx < (but->rect.xmin + handle_width)) {
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index d8bdeaa8159..36624f475ce 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1842,12 +1842,12 @@ int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big
else if (RNA_struct_is_a(ptr->type, &RNA_StudioLight)) {
StudioLight *sl = ptr->data;
switch (sl->flag & STUDIOLIGHT_FLAG_ORIENTATIONS) {
- case STUDIOLIGHT_ORIENTATION_CAMERA:
+ case STUDIOLIGHT_TYPE_STUDIO:
return sl->icon_id_irradiance;
- case STUDIOLIGHT_ORIENTATION_WORLD:
+ case STUDIOLIGHT_TYPE_WORLD:
default:
return sl->icon_id_radiance;
- case STUDIOLIGHT_ORIENTATION_VIEWNORMAL:
+ case STUDIOLIGHT_TYPE_MATCAP:
return sl->icon_id_matcap;
}
}
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 306fa89a062..8a27fd55d37 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -655,6 +655,7 @@ static void ui_item_enum_expand_exec(
uiLayout *layout_radial = NULL;
const EnumPropertyItem *item, *item_array;
const char *name;
+ char group_name[UI_MAX_NAME_STR];
int itemw, icon, value;
bool free;
bool radial = (layout->root->type == UI_LAYOUT_PIEMENU);
@@ -687,10 +688,22 @@ static void ui_item_enum_expand_exec(
}
for (item = item_array; item->identifier; item++) {
+ const bool is_first = item == item_array;
+
if (!item->identifier[0]) {
const EnumPropertyItem *next_item = item + 1;
+
+ /* Separate items, potentially with a label. */
if (next_item->identifier) {
- if (radial && layout_radial) {
+ /* Item without identifier but with name: Add group label for the following items. */
+ if (item->name) {
+ if (!is_first) {
+ uiItemS(block->curlayout);
+ }
+ BLI_snprintf(group_name, sizeof(group_name), "%s:", item->name);
+ uiItemL(block->curlayout, group_name, item->icon);
+ }
+ else if (radial && layout_radial) {
uiItemS(layout_radial);
}
else {
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 3197c4a2cbf..58dc5617202 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1914,10 +1914,6 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
ui_fontscale(&fstyle_points, aspect / (U.pixelsize * 1.1f));
BLF_size(fontid, fstyle_points, U.dpi);
- BLF_enable(fontid, BLF_SHADOW);
- BLF_shadow(fontid, 3, (const float[4]){1.0f, 1.0f, 1.0f, 0.25f});
- BLF_shadow_offset(fontid, -1, -1);
-
BLI_assert(UI_panel_category_is_visible(ar));
@@ -2100,8 +2096,6 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
BLF_disable(fontid, BLF_ROTATION);
- BLF_disable(fontid, BLF_SHADOW);
-
if (fstyle->kerning == 1) {
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
}
diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c
index 4b3d1980189..0a5a88f2cb6 100644
--- a/source/blender/editors/interface/interface_region_hud.c
+++ b/source/blender/editors/interface/interface_region_hud.c
@@ -134,6 +134,7 @@ static void hud_panels_register(ARegionType *art, int space_type, int region_typ
pt->poll = hud_panel_operator_redo_poll;
pt->space_type = space_type;
pt->region_type = region_type;
+ pt->flag |= PNL_DEFAULT_CLOSED;
BLI_addtail(&art->paneltypes, pt);
}
@@ -212,20 +213,7 @@ static void hud_region_draw(const bContext *C, ARegion *ar)
GPU_clear(GPU_COLOR_BIT);
if ((ar->flag & RGN_FLAG_HIDDEN) == 0) {
- if (0) {
- /* Has alpha flickering glitch, see T56752. */
- ui_draw_menu_back(NULL, NULL, &(rcti){.xmax = ar->winx, .ymax = ar->winy});
- }
- else {
- /* Use basic drawing instead. */
- bTheme *btheme = UI_GetTheme();
- float color[4];
- rgba_uchar_to_float(color, (const uchar *)btheme->tui.wcol_menu_back.inner);
- const float radius = U.widget_unit * btheme->tui.wcol_menu_back.roundness;
- UI_draw_roundbox_corner_set(UI_CNR_ALL);
- UI_draw_roundbox_4fv(true, 0, 0, ar->winx, ar->winy, radius, color);
- }
-
+ ui_draw_menu_back(NULL, NULL, &(rcti){.xmax = ar->winx, .ymax = ar->winy});
ED_region_panels_draw(C, ar);
}
}
@@ -294,8 +282,9 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa)
return;
}
- bool init = false;
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_HUD);
+ bool init = false;
+ bool was_hidden = ar == NULL || ar->visible == false;
if (!last_redo_poll(C)) {
if (ar) {
ED_region_tag_redraw(ar);
@@ -352,16 +341,23 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa)
ar->v2d.minzoom = 1.0f;
ar->v2d.maxzoom = 1.0f;
- /* XXX, should be handled in more general way. */
- ar->visible = !((ar->flag & RGN_FLAG_HIDDEN) || (ar->flag & RGN_FLAG_TOO_SMALL));
+ ar->visible = !(ar->flag & RGN_FLAG_HIDDEN);
/* 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);
+ if (ar->visible) {
+ ARegion *ar_prev = CTX_wm_region(C);
+ CTX_wm_region_set((bContext *)C, ar);
+ hud_region_layout(C, ar);
+ if (was_hidden) {
+ ar->winx = ar->v2d.winx;
+ ar->winy = ar->v2d.winy;
+ ar->v2d.cur = ar->v2d.tot = (rctf){.xmax = ar->winx, .ymax = ar->winy};
+ }
+ CTX_wm_region_set((bContext *)C, ar_prev);
+ }
+ ar->visible = !((ar->flag & RGN_FLAG_HIDDEN) || (ar->flag & RGN_FLAG_TOO_SMALL));
}
/** \} */
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index b8cbf7950b7..1a167b3fd72 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -228,18 +228,12 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
uiFontStyle fstyle_header = data->fstyle;
/* override text-style */
- fstyle_header.shadow = 1;
- fstyle_header.shadowcolor = rgb_to_grayscale(tip_colors[UI_TIP_LC_MAIN]);
- fstyle_header.shadx = fstyle_header.shady = 0;
- fstyle_header.shadowalpha = 1.0f;
fstyle_header.word_wrap = true;
rgb_float_to_uchar(drawcol, tip_colors[UI_TIP_LC_MAIN]);
UI_fontstyle_set(&fstyle_header);
UI_fontstyle_draw(&fstyle_header, &bbox, field->text, drawcol);
- fstyle_header.shadow = 0;
-
/* offset to the end of the last line */
if (field->text_suffix) {
float xofs = field->geom.x_pos;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 1651dd77308..10e7d4fb68e 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -504,7 +504,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ED_object_single_user(bmain, scene, (struct Object *)id);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
DEG_relations_tag_update(bmain);
}
@@ -1335,7 +1335,7 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
ob->partype = PAROBJECT;
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
ED_undo_push(C, "Modifier convert to real");
}
@@ -1942,8 +1942,8 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event)
* object_test_constraints(ob);
* if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); */
- if (ob->type == OB_ARMATURE) DEG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
- else DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ if (ob->type == OB_ARMATURE) DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
+ else DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 0ffc40bdf9d..b358f87bb26 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -146,7 +146,7 @@ typedef struct uiWidgetType {
/* converted colors for state */
uiWidgetColors wcol;
- void (*state)(struct uiWidgetType *, int state);
+ void (*state)(struct uiWidgetType *, int state, int drawflag);
void (*draw)(uiWidgetColors *, rcti *, int state, int roundboxalign);
void (*custom)(uiBut *, uiWidgetColors *, rcti *, int state, int roundboxalign);
void (*text)(uiFontStyle *, uiWidgetColors *, uiBut *, rcti *);
@@ -2231,7 +2231,7 @@ static void widget_active_color(char cp[3])
}
/* copy colors from theme, and set changes in it based on state */
-static void widget_state(uiWidgetType *wt, int state)
+static void widget_state(uiWidgetType *wt, int state, int drawflag)
{
uiWidgetStateColors *wcol_state = wt->wcol_state;
@@ -2249,8 +2249,9 @@ static void widget_state(uiWidgetType *wt, int state)
if (state & UI_SELECT) {
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
-
- if (state & UI_BUT_ANIMATED_KEY)
+ if (drawflag & UI_BUT_ANIMATED_CHANGED)
+ widget_state_blend(wt->wcol.inner, wcol_state->inner_changed_sel, wcol_state->blend);
+ else if (state & UI_BUT_ANIMATED_KEY)
widget_state_blend(wt->wcol.inner, wcol_state->inner_key_sel, wcol_state->blend);
else if (state & UI_BUT_ANIMATED)
widget_state_blend(wt->wcol.inner, wcol_state->inner_anim_sel, wcol_state->blend);
@@ -2265,7 +2266,9 @@ static void widget_state(uiWidgetType *wt, int state)
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
}
else {
- if (state & UI_BUT_ANIMATED_KEY)
+ if (drawflag & UI_BUT_ANIMATED_CHANGED)
+ widget_state_blend(wt->wcol.inner, wcol_state->inner_changed, wcol_state->blend);
+ else if (state & UI_BUT_ANIMATED_KEY)
widget_state_blend(wt->wcol.inner, wcol_state->inner_key, wcol_state->blend);
else if (state & UI_BUT_ANIMATED)
widget_state_blend(wt->wcol.inner, wcol_state->inner_anim, wcol_state->blend);
@@ -2303,19 +2306,21 @@ static void widget_state(uiWidgetType *wt, int state)
}
/* sliders use special hack which sets 'item' as inner when drawing filling */
-static void widget_state_numslider(uiWidgetType *wt, int state)
+static void widget_state_numslider(uiWidgetType *wt, int state, int drawflag)
{
uiWidgetStateColors *wcol_state = wt->wcol_state;
float blend = wcol_state->blend - 0.2f; /* XXX special tweak to make sure that bar will still be visible */
/* call this for option button */
- widget_state(wt, state);
+ widget_state(wt, state, drawflag);
/* now, set the inner-part so that it reflects state settings too */
/* TODO: maybe we should have separate settings for the blending colors used for this case? */
if (state & UI_SELECT) {
- if (state & UI_BUT_ANIMATED_KEY)
+ if (drawflag & UI_BUT_ANIMATED_CHANGED)
+ widget_state_blend(wt->wcol.item, wcol_state->inner_changed_sel, blend);
+ else if (state & UI_BUT_ANIMATED_KEY)
widget_state_blend(wt->wcol.item, wcol_state->inner_key_sel, blend);
else if (state & UI_BUT_ANIMATED)
widget_state_blend(wt->wcol.item, wcol_state->inner_anim_sel, blend);
@@ -2328,7 +2333,9 @@ static void widget_state_numslider(uiWidgetType *wt, int state)
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
}
else {
- if (state & UI_BUT_ANIMATED_KEY)
+ if (drawflag & UI_BUT_ANIMATED_CHANGED)
+ widget_state_blend(wt->wcol.item, wcol_state->inner_changed, blend);
+ else if (state & UI_BUT_ANIMATED_KEY)
widget_state_blend(wt->wcol.item, wcol_state->inner_key, blend);
else if (state & UI_BUT_ANIMATED)
widget_state_blend(wt->wcol.item, wcol_state->inner_anim, blend);
@@ -2340,12 +2347,12 @@ static void widget_state_numslider(uiWidgetType *wt, int state)
}
/* labels use theme colors for text */
-static void widget_state_option_menu(uiWidgetType *wt, int state)
+static void widget_state_option_menu(uiWidgetType *wt, int state, int drawflag)
{
bTheme *btheme = UI_GetTheme(); /* XXX */
/* call this for option button */
- widget_state(wt, state);
+ widget_state(wt, state, drawflag);
/* if not selected we get theme from menu back */
if (state & UI_SELECT)
@@ -2355,19 +2362,19 @@ static void widget_state_option_menu(uiWidgetType *wt, int state)
}
-static void widget_state_nothing(uiWidgetType *wt, int UNUSED(state))
+static void widget_state_nothing(uiWidgetType *wt, int UNUSED(state), int UNUSED(drawflag))
{
wt->wcol = *(wt->wcol_theme);
}
/* special case, button that calls pulldown */
-static void widget_state_pulldown(uiWidgetType *wt, int UNUSED(state))
+static void widget_state_pulldown(uiWidgetType *wt, int UNUSED(state), int UNUSED(drawflag))
{
wt->wcol = *(wt->wcol_theme);
}
/* special case, pie menu items */
-static void widget_state_pie_menu_item(uiWidgetType *wt, int state)
+static void widget_state_pie_menu_item(uiWidgetType *wt, int state, int UNUSED(drawflag))
{
wt->wcol = *(wt->wcol_theme);
@@ -2399,7 +2406,7 @@ static void widget_state_pie_menu_item(uiWidgetType *wt, int state)
}
/* special case, menu items */
-static void widget_state_menu_item(uiWidgetType *wt, int state)
+static void widget_state_menu_item(uiWidgetType *wt, int state, int UNUSED(drawflag))
{
wt->wcol = *(wt->wcol_theme);
@@ -3393,7 +3400,8 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
ui_but_v3_get(but, col);
- if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_OVERRIDEN | UI_BUT_REDALERT)) {
+ if ((state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_OVERRIDEN | UI_BUT_REDALERT)) ||
+ (but->drawflag & UI_BUT_ANIMATED_CHANGED)) {
/* draw based on state - color for keyed etc */
widgetbase_draw(&wtb, wcol);
@@ -3642,18 +3650,18 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
}
/* labels use Editor theme colors for text */
-static void widget_state_label(uiWidgetType *wt, int state)
+static void widget_state_label(uiWidgetType *wt, int state, int drawflag)
{
if (state & UI_BUT_LIST_ITEM) {
/* Override default label theme's colors. */
bTheme *btheme = UI_GetTheme();
wt->wcol_theme = &btheme->tui.wcol_list_item;
/* call this for option button */
- widget_state(wt, state);
+ widget_state(wt, state, drawflag);
}
else {
/* call this for option button */
- widget_state(wt, state);
+ widget_state(wt, state, drawflag);
if (state & UI_SELECT)
UI_GetThemeColor3ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text);
else
@@ -3753,9 +3761,7 @@ static void widget_roundbut_exec(uiWidgetColors *wcol, rcti *rect, int state, in
static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
- const uiStyle *style = UI_style_get();
const float rad = wcol->roundness * U.widget_unit;
- const int fontid = style->widget.uifont_id;
const bool is_active = (state & UI_SELECT);
/* Draw shaded outline - Disabled for now, seems incorrect and also looks nicer without it imho ;) */
@@ -3797,11 +3803,6 @@ static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundbox
ui_draw_but_TAB_outline(rect, rad, theme_col_tab_highlight, (unsigned char *)wcol->inner);
#endif
- /* text shadow */
- BLF_enable(fontid, BLF_SHADOW);
- BLF_shadow(fontid, 3, (const float[4]){1.0f, 1.0f, 1.0f, 0.25f});
- BLF_shadow_offset(fontid, 0, -1);
-
#ifndef USE_TAB_SHADED_HIGHLIGHT
UNUSED_VARS(is_active, theme_col_tab_highlight);
#endif
@@ -4321,13 +4322,14 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
if (wt) {
//rcti disablerect = *rect; /* rect gets clipped smaller for text */
- int roundboxalign, state;
+ int roundboxalign, state, drawflag;
bool disabled = false;
roundboxalign = widget_roundbox_set(but, rect);
/* Mask out flags re-used for local state. */
state = but->flag & ~UI_STATE_FLAGS_ALL;
+ drawflag = but->drawflag;
if (state & UI_SELECT_DRAW) {
state |= UI_SELECT;
@@ -4359,7 +4361,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
if (disabled)
ui_widget_color_disabled(wt);
- wt->state(wt, state);
+ wt->state(wt, state, drawflag);
if (wt->custom)
wt->custom(but, &wt->wcol, rect, state, roundboxalign);
else if (wt->draw)
@@ -4373,7 +4375,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
if ((state & UI_ACTIVE) && ui_but_is_popover_once_compat(but)) {
uiWidgetType wt_back = *wt;
uiWidgetType *wt_temp = widget_type(UI_WTYPE_MENU_ITEM);
- wt_temp->state(wt_temp, state);
+ wt_temp->state(wt_temp, state, drawflag);
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
wt->wcol.inner[3] = 128;
wt->wcol.roundness = 0.5f;
@@ -4422,7 +4424,7 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
{
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK);
- wt->state(wt, 0);
+ wt->state(wt, 0, 0);
if (block)
wt->draw(&wt->wcol, rect, block->flag, block->direction);
else
@@ -4496,7 +4498,7 @@ void ui_draw_popover_back(ARegion *ar, uiStyle *UNUSED(style), uiBlock *block, r
ui_draw_popover_back_impl(wt->wcol_theme, rect, block->direction, U.widget_unit / block->aspect, mval_origin);
}
else {
- wt->state(wt, 0);
+ wt->state(wt, 0, 0);
wt->draw(&wt->wcol, rect, 0, 0);
}
@@ -4648,7 +4650,7 @@ void ui_draw_widget_back_color(
}
rcti rect_copy = *rect;
- wt->state(wt, 0);
+ wt->state(wt, 0, 0);
if (color) {
rgba_float_to_uchar((unsigned char *)wt->wcol.inner, color);
}
@@ -4662,7 +4664,7 @@ void ui_draw_widget_back(uiWidgetTypeEnum type, bool use_shadow, const rcti *rec
void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *UNUSED(block), rcti *rect)
{
uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP);
- wt->state(wt, 0);
+ wt->state(wt, 0, 0);
/* wt->draw ends up using same function to draw the tooltip as menu_back */
wt->draw(&wt->wcol, rect, 0, 0);
}
@@ -4675,7 +4677,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
rcti _rect = *rect;
char *cpoin = NULL;
- wt->state(wt, state);
+ wt->state(wt, state, 0);
wt->draw(&wt->wcol, rect, 0, 0);
UI_fontstyle_set(fstyle);
@@ -4755,7 +4757,7 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
/* drawing button background */
- wt->state(wt, state);
+ wt->state(wt, state, 0);
wt->draw(&wt->wcol, rect, 0, 0);
/* draw icon in rect above the space reserved for the label */
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index 2ddf5e2584e..a022d750000 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -99,7 +99,6 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
int keep_smooth_curves;
int keep_keyframes;
- int include_material_textures;
int export_animation_type;
int use_texture_copies;
int active_uv_only;
@@ -155,13 +154,12 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
include_all_actions = RNA_boolean_get(op->ptr, "include_all_actions");
export_animation_type = RNA_enum_get(op->ptr, "export_animation_type_selection");
sample_animations = (export_animation_type == BC_ANIMATION_EXPORT_SAMPLES);
- sampling_rate = (sample_animations)? RNA_int_get(op->ptr, "sampling_rate") : 0;
+ sampling_rate = (sample_animations) ? RNA_int_get(op->ptr, "sampling_rate") : 0;
keep_smooth_curves = RNA_boolean_get(op->ptr, "keep_smooth_curves");
keep_keyframes = RNA_boolean_get(op->ptr, "keep_keyframes");
deform_bones_only = RNA_boolean_get(op->ptr, "deform_bones_only");
- include_material_textures = RNA_boolean_get(op->ptr, "include_material_textures");
use_texture_copies = RNA_boolean_get(op->ptr, "use_texture_copies");
active_uv_only = RNA_boolean_get(op->ptr, "active_uv_only");
@@ -508,9 +506,6 @@ void WM_OT_collada_export(wmOperatorType *ot)
RNA_def_boolean(func, "active_uv_only", 0, "Only Selected UV Map",
"Export only the selected UV Map");
- RNA_def_boolean(func, "include_material_textures", 0, "Include Material Textures",
- "Export textures assigned to the object Materials");
-
RNA_def_boolean(func, "use_texture_copies", 1, "Copy",
"Copy textures to same folder where the .dae file is exported");
@@ -584,7 +579,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
import_settings.keep_bind_info = keep_bind_info != 0;
if (collada_import(C, &import_settings)) {
- DEG_id_tag_update(&CTX_data_scene(C)->id, DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_id_tag_update(&CTX_data_scene(C)->id, ID_RECALC_BASE_FLAGS);
return OPERATOR_FINISHED;
}
else {
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c
index f342cefa362..9a50c5ba908 100644
--- a/source/blender/editors/lattice/editlattice_select.c
+++ b/source/blender/editors/lattice/editlattice_select.c
@@ -95,7 +95,7 @@ static int lattice_select_random_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
@@ -122,7 +122,7 @@ static int lattice_select_random_exec(bContext *C, wmOperator *op)
BLI_rng_free(rng);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -201,7 +201,7 @@ static int lattice_select_mirror_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -214,7 +214,7 @@ static int lattice_select_mirror_exec(bContext *C, wmOperator *op)
}
/* TODO, only notify changes */
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -271,7 +271,7 @@ static int lattice_select_more_less(bContext *C, const bool select)
uint objects_len;
bool changed = false;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
@@ -308,7 +308,7 @@ static int lattice_select_more_less(bContext *C, const bool select)
MEM_freeN(selpoints);
changed = true;
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -387,7 +387,7 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op)
int action = RNA_enum_get(op->ptr, "action");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
@@ -428,7 +428,7 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op)
}
break;
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -467,7 +467,7 @@ static int lattice_select_ungrouped_exec(bContext *C, wmOperator *op)
const bool is_extend = RNA_boolean_get(op->ptr, "extend");
bool changed = false;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
@@ -495,7 +495,7 @@ static int lattice_select_ungrouped_exec(bContext *C, wmOperator *op)
}
changed = true;
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -566,7 +566,7 @@ static BPoint *findnearestLattvert(ViewContext *vc, int sel, Base **r_base)
data.mval_fl[1] = vc->mval[1];
uint bases_len;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc->view_layer, &bases_len);
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc->view_layer, vc->v3d, &bases_len);
for (uint base_index = 0; base_index < bases_len; base_index++) {
Base *base = bases[base_index];
data.is_changed = false;
@@ -600,12 +600,12 @@ bool ED_lattice_select_pick(bContext *C, const int mval[2], bool extend, bool de
if (!extend && !deselect && !toggle) {
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
ED_lattice_flags_set(ob, 0);
- DEG_id_tag_update(ob->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
}
MEM_freeN(objects);
@@ -636,7 +636,7 @@ bool ED_lattice_select_pick(bContext *C, const int mval[2], bool extend, bool de
ED_object_base_activate(C, basact);
}
- DEG_id_tag_update(vc.obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
return true;
diff --git a/source/blender/editors/lattice/editlattice_tools.c b/source/blender/editors/lattice/editlattice_tools.c
index 01211a436a4..2f8dc37a2f6 100644
--- a/source/blender/editors/lattice/editlattice_tools.c
+++ b/source/blender/editors/lattice/editlattice_tools.c
@@ -73,11 +73,12 @@ static bool make_regular_poll(bContext *C)
static int make_regular_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
const bool is_editmode = CTX_data_edit_object(C) != NULL;
if (is_editmode) {
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
Lattice *lt = ob->data;
@@ -88,13 +89,13 @@ static int make_regular_exec(bContext *C, wmOperator *UNUSED(op))
BKE_lattice_resize(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
}
MEM_freeN(objects);
}
else {
- FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob) {
+ FOREACH_SELECTED_OBJECT_BEGIN(view_layer, v3d, ob) {
if (ob->type != OB_LATTICE) {
continue;
}
@@ -102,7 +103,7 @@ static int make_regular_exec(bContext *C, wmOperator *UNUSED(op))
Lattice *lt = ob->data;
BKE_lattice_resize(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
} FOREACH_SELECTED_OBJECT_END;
}
@@ -218,7 +219,7 @@ static int lattice_flip_exec(bContext *C, wmOperator *op)
bool changed = false;
const eLattice_FlipAxes axis = RNA_enum_get(op->ptr, "axis");
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Lattice *lt;
@@ -335,7 +336,7 @@ static int lattice_flip_exec(bContext *C, wmOperator *op)
}
/* updates */
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
changed = true;
}
diff --git a/source/blender/editors/lattice/editlattice_undo.c b/source/blender/editors/lattice/editlattice_undo.c
index cbd89016b44..744f353f129 100644
--- a/source/blender/editors/lattice/editlattice_undo.c
+++ b/source/blender/editors/lattice/editlattice_undo.c
@@ -157,7 +157,7 @@ static bool lattice_undosys_step_encode(struct bContext *C, UndoStep *us_p)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
us->elems_len = objects_len;
@@ -194,7 +194,7 @@ static void lattice_undosys_step_decode(struct bContext *C, UndoStep *us_p, int
continue;
}
undolatt_to_editlatt(&elem->data, lt->editlatt);
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
/* The first element is always active */
diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c
index 4337ff705b6..d64963d4347 100644
--- a/source/blender/editors/mask/mask_shapekey.c
+++ b/source/blender/editors/mask/mask_shapekey.c
@@ -124,7 +124,7 @@ static int mask_shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
if (changed) {
WM_event_add_notifier(C, NC_MASK | ND_DATA, mask);
- DEG_id_tag_update(&mask->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&mask->id, ID_RECALC_GEOMETRY);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 2beb9303a2e..8e64ed93842 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -55,15 +55,15 @@
#include "GPU_draw.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
/* own include */
/* copy the face flags, most importantly selection from the mesh to the final derived mesh,
* use in object mode when selecting faces (while painting) */
-void paintface_flush_flags(Object *ob, short flag)
+void paintface_flush_flags(struct bContext *C, Object *ob, short flag)
{
Mesh *me = BKE_mesh_from_object(ob);
- Mesh *me_eval = ob->runtime.mesh_eval;
MPoly *polys, *mp_orig;
const int *index_array = NULL;
int totpoly;
@@ -82,36 +82,64 @@ void paintface_flush_flags(Object *ob, short flag)
BKE_mesh_flush_select_from_polys(me);
}
- if (me_eval == NULL)
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+
+ if (ob_eval == NULL) {
return;
+ }
- /* Mesh polys => Final derived polys */
+ Mesh *me_orig = ob_eval->runtime.mesh_orig;
+ Mesh *me_eval = ob_eval->runtime.mesh_eval;
+ bool updated = false;
- if ((index_array = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX))) {
- polys = me_eval->mpoly;
- totpoly = me_eval->totpoly;
+ if (me_orig != NULL && me_eval != NULL && me_orig->totpoly == me->totpoly) {
+ /* Update the COW copy of the mesh. */
+ for (i = 0; i < me->totpoly; i++) {
+ me_orig->mpoly[i].flag = me->mpoly[i].flag;
+ }
- /* loop over final derived polys */
- for (i = 0; i < totpoly; i++) {
- if (index_array[i] != ORIGINDEX_NONE) {
- /* Copy flags onto the final derived poly from the original mesh poly */
- mp_orig = me->mpoly + index_array[i];
- polys[i].flag = mp_orig->flag;
+ /* If the mesh has only deform modifiers, the evaluated mesh shares arrays. */
+ if (me_eval->mpoly == me_orig->mpoly) {
+ updated = true;
+ }
+ /* Mesh polys => Final derived polys */
+ else 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++) {
+ if (index_array[i] != ORIGINDEX_NONE) {
+ /* Copy flags onto the final derived poly from the original mesh poly */
+ mp_orig = me->mpoly + index_array[i];
+ polys[i].flag = mp_orig->flag;
+ }
}
+
+ updated = true;
}
}
- BKE_mesh_batch_cache_dirty_tag(me, BKE_MESH_BATCH_DIRTY_ALL);
-}
+ if (updated) {
+ if (flag & ME_HIDE) {
+ BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_ALL);
+ }
+ else {
+ BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_SELECT);
+ }
+
+ DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
+ }
+ else {
+ DEG_id_tag_update(ob->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
+ }
-void paintface_tag_select_update(struct bContext *C, struct Object *ob)
-{
- DEG_id_tag_update(ob->data, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
}
-void paintface_hide(Object *ob, const bool unselected)
+void paintface_hide(bContext *C, Object *ob, const bool unselected)
{
Mesh *me;
MPoly *mpoly;
@@ -138,11 +166,11 @@ void paintface_hide(Object *ob, const bool unselected)
BKE_mesh_flush_hidden_from_polys(me);
- paintface_flush_flags(ob, SELECT | ME_HIDE);
+ paintface_flush_flags(C, ob, SELECT | ME_HIDE);
}
-void paintface_reveal(Object *ob, const bool select)
+void paintface_reveal(bContext *C, Object *ob, const bool select)
{
Mesh *me;
MPoly *mpoly;
@@ -163,7 +191,7 @@ void paintface_reveal(Object *ob, const bool select)
BKE_mesh_flush_hidden_from_polys(me);
- paintface_flush_flags(ob, SELECT | ME_HIDE);
+ paintface_flush_flags(C, ob, SELECT | ME_HIDE);
}
/* Set tface seams based on edge data, uses hash table to find seam edges. */
@@ -257,11 +285,10 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b
select_linked_tfaces_with_seams(me, index, select);
- paintface_flush_flags(ob, SELECT);
- paintface_tag_select_update(C, ob);
+ paintface_flush_flags(C, ob, SELECT);
}
-void paintface_deselect_all_visible(Object *ob, int action, bool flush_flags)
+void paintface_deselect_all_visible(bContext *C, Object *ob, int action, bool flush_flags)
{
Mesh *me;
MPoly *mpoly;
@@ -304,7 +331,7 @@ void paintface_deselect_all_visible(Object *ob, int action, bool flush_flags)
}
if (flush_flags) {
- paintface_flush_flags(ob, SELECT);
+ paintface_flush_flags(C, ob, SELECT);
}
}
@@ -392,8 +419,7 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b
/* image window redraw */
- paintface_flush_flags(ob, SELECT);
- paintface_tag_select_update(C, ob);
+ paintface_flush_flags(C, ob, SELECT);
ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views
return true;
}
@@ -420,7 +446,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int sel_op)
selar = MEM_callocN(me->totpoly + 1, "selar");
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- paintface_deselect_all_visible(vc->obact, SEL_DESELECT, false);
+ paintface_deselect_all_visible(vc->C, vc->obact, SEL_DESELECT, false);
}
ED_view3d_backbuf_validate(vc);
@@ -463,8 +489,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int sel_op)
glReadBuffer(GL_BACK);
#endif
- paintface_flush_flags(vc->obact, SELECT);
- paintface_tag_select_update(vc->C, vc->obact);
+ paintface_flush_flags(vc->C, vc->obact, SELECT);
return OPERATOR_FINISHED;
}
@@ -519,7 +544,7 @@ void paintvert_flush_flags(Object *ob)
void paintvert_tag_select_update(struct bContext *C, struct Object *ob)
{
- DEG_id_tag_update(ob->data, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
}
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index dd16cb9e4ec..bcde2411899 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -66,14 +66,14 @@ typedef struct MakePrimitiveData {
static Object *make_prim_init(
bContext *C, const char *idname,
- const float loc[3], const float rot[3],
+ const float loc[3], const float rot[3], ushort local_view_bits,
MakePrimitiveData *r_creation_data)
{
Object *obedit = CTX_data_edit_object(C);
r_creation_data->was_editmode = false;
if (obedit == NULL || obedit->type != OB_MESH) {
- obedit = ED_object_add_type(C, OB_MESH, idname, loc, rot, false);
+ obedit = ED_object_add_type(C, OB_MESH, idname, loc, rot, false, local_view_bits);
/* create editmode */
ED_object_editmode_enter(C, EM_IGNORE_LAYER); /* rare cases the active layer is messed up */
@@ -111,11 +111,14 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op)
BMEditMesh *em;
float loc[3], rot[3];
bool enter_editmode;
+ ushort local_view_bits;
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
WM_operator_view3d_unit_defaults(C, op);
- ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL);
- obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Plane"), loc, rot, &creation_data);
+ ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL);
+ obedit = make_prim_init(
+ C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Plane"),
+ loc, rot, local_view_bits, &creation_data);
em = BKE_editmesh_from_object(obedit);
if (calc_uvs) {
@@ -161,11 +164,14 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op)
BMEditMesh *em;
float loc[3], rot[3];
bool enter_editmode;
+ ushort local_view_bits;
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
WM_operator_view3d_unit_defaults(C, op);
- ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL);
- obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Cube"), loc, rot, &creation_data);
+ ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL);
+ obedit = make_prim_init(
+ C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Cube"),
+ loc, rot, local_view_bits, &creation_data);
em = BKE_editmesh_from_object(obedit);
if (calc_uvs) {
@@ -218,6 +224,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op)
BMEditMesh *em;
float loc[3], rot[3];
bool enter_editmode;
+ ushort local_view_bits;
int cap_end, cap_tri;
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
@@ -225,8 +232,10 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op)
cap_tri = (cap_end == 2);
WM_operator_view3d_unit_defaults(C, op);
- ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL);
- obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Circle"), loc, rot, &creation_data);
+ ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL);
+ obedit = make_prim_init(
+ C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Circle"),
+ loc, rot, local_view_bits, &creation_data);
em = BKE_editmesh_from_object(obedit);
if (calc_uvs) {
@@ -277,14 +286,17 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
BMEditMesh *em;
float loc[3], rot[3];
bool enter_editmode;
+ ushort local_view_bits;
const int end_fill_type = RNA_enum_get(op->ptr, "end_fill_type");
const bool cap_end = (end_fill_type != 0);
const bool cap_tri = (end_fill_type == 2);
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
WM_operator_view3d_unit_defaults(C, op);
- ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL);
- obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Cylinder"), loc, rot, &creation_data);
+ ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL);
+ obedit = make_prim_init(
+ C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Cylinder"),
+ loc, rot, local_view_bits, &creation_data);
em = BKE_editmesh_from_object(obedit);
if (calc_uvs) {
@@ -339,14 +351,17 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op)
BMEditMesh *em;
float loc[3], rot[3];
bool enter_editmode;
+ ushort local_view_bits;
const int end_fill_type = RNA_enum_get(op->ptr, "end_fill_type");
const bool cap_end = (end_fill_type != 0);
const bool cap_tri = (end_fill_type == 2);
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
WM_operator_view3d_unit_defaults(C, op);
- ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL);
- obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Cone"), loc, rot, &creation_data);
+ ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL);
+ obedit = make_prim_init(
+ C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Cone"),
+ loc, rot, local_view_bits, &creation_data);
em = BKE_editmesh_from_object(obedit);
if (calc_uvs) {
@@ -400,11 +415,14 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op)
BMEditMesh *em;
float loc[3], rot[3];
bool enter_editmode;
+ ushort local_view_bits;
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
WM_operator_view3d_unit_defaults(C, op);
- ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL);
- obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Grid"), loc, rot, &creation_data);
+ ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL);
+ obedit = make_prim_init(
+ C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Grid"),
+ loc, rot, local_view_bits, &creation_data);
em = BKE_editmesh_from_object(obedit);
if (calc_uvs) {
@@ -459,12 +477,15 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
float loc[3], rot[3];
float dia;
bool enter_editmode;
+ ushort local_view_bits;
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
WM_operator_view3d_unit_defaults(C, op);
- ED_object_add_generic_get_opts(C, op, 'Y', loc, rot, &enter_editmode, NULL);
+ ED_object_add_generic_get_opts(C, op, 'Y', loc, rot, &enter_editmode, &local_view_bits, NULL);
- obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Suzanne"), loc, rot, &creation_data);
+ obedit = make_prim_init(
+ C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Suzanne"),
+ loc, rot, local_view_bits, &creation_data);
dia = RNA_float_get(op->ptr, "size") / 2.0f;
mul_mat3_m4_fl(creation_data.mat, dia);
@@ -513,11 +534,14 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
BMEditMesh *em;
float loc[3], rot[3];
bool enter_editmode;
+ ushort local_view_bits;
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
WM_operator_view3d_unit_defaults(C, op);
- ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL);
- obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Sphere"), loc, rot, &creation_data);
+ ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL);
+ obedit = make_prim_init(
+ C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Sphere"),
+ loc, rot, local_view_bits, &creation_data);
em = BKE_editmesh_from_object(obedit);
if (calc_uvs) {
@@ -568,11 +592,14 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
BMEditMesh *em;
float loc[3], rot[3];
bool enter_editmode;
+ ushort local_view_bits;
const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs");
WM_operator_view3d_unit_defaults(C, op);
- ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL);
- obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Icosphere"), loc, rot, &creation_data);
+ ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL);
+ obedit = make_prim_init(
+ C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Icosphere"),
+ loc, rot, local_view_bits, &creation_data);
em = BKE_editmesh_from_object(obedit);
if (calc_uvs) {
diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.c b/source/blender/editors/mesh/editmesh_add_gizmo.c
index 7437d86e6b5..d3a81a3f9ed 100644
--- a/source/blender/editors/mesh/editmesh_add_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_add_gizmo.c
@@ -70,7 +70,6 @@ static void calc_initial_placement_point_from_view(
{
Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ar->regiondata;
@@ -78,7 +77,7 @@ static void calc_initial_placement_point_from_view(
float cursor_matrix[4][4];
float orient_matrix[3][3];
- ED_view3d_cursor3d_calc_mat4(scene, v3d, cursor_matrix);
+ ED_view3d_cursor3d_calc_mat4(scene, cursor_matrix);
float dots[3] = {
dot_v3v3(rv3d->viewinv[2], cursor_matrix[0]),
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 39bebc9a980..0202d52a263 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -245,7 +245,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
{
uint ob_store_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &ob_store_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &ob_store_len);
opdata->ob_store = MEM_malloc_arrayN(ob_store_len, sizeof(*opdata->ob_store), __func__);
for (uint ob_index = 0; ob_index < ob_store_len; ob_index++) {
Object *obedit = objects[ob_index];
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c
index aaa46847495..5b59f1aa5f9 100644
--- a/source/blender/editors/mesh/editmesh_bisect.c
+++ b/source/blender/editors/mesh/editmesh_bisect.c
@@ -130,7 +130,7 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -242,7 +242,6 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
/* both can be NULL, fallbacks values are used */
- View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
int ret = OPERATOR_CANCELLED;
@@ -264,7 +263,7 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op)
RNA_property_float_get_array(op->ptr, prop_plane_co, plane_co);
}
else {
- copy_v3_v3(plane_co, ED_view3d_cursor3d_get(scene, v3d)->location);
+ copy_v3_v3(plane_co, scene->cursor.location);
RNA_property_float_set_array(op->ptr, prop_plane_co, plane_co);
}
@@ -299,7 +298,7 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op)
/* -------------------------------------------------------------------- */
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(CTX_data_view_layer(C), &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(CTX_data_view_layer(C), CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index a25b296830a..fad8d39e665 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -296,7 +296,7 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -407,7 +407,7 @@ static int edbm_extrude_region_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -462,7 +462,7 @@ static int edbm_extrude_context_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -512,7 +512,7 @@ static int edbm_extrude_verts_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -559,7 +559,7 @@ static int edbm_extrude_edges_exec(bContext *C, wmOperator *op)
const bool use_normal_flip = RNA_boolean_get(op->ptr, "use_normal_flip");
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -606,7 +606,7 @@ static int edbm_extrude_faces_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -669,7 +669,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
verts_len = 0;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
ED_view3d_viewcontext_init_object(&vc, obedit);
@@ -823,7 +823,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
}
else {
/* This only runs for the active object. */
- const float *cursor = ED_view3d_cursor3d_get(vc.scene, vc.v3d)->location;
+ const float *cursor = vc.scene->cursor.location;
BMOperator bmop;
BMOIter oiter;
diff --git a/source/blender/editors/mesh/editmesh_extrude_screw.c b/source/blender/editors/mesh/editmesh_extrude_screw.c
index 3214f28412a..589e3987050 100644
--- a/source/blender/editors/mesh/editmesh_extrude_screw.c
+++ b/source/blender/editors/mesh/editmesh_extrude_screw.c
@@ -76,7 +76,7 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
uint objects_len = 0;
ViewLayer *view_layer = CTX_data_view_layer(C);
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -171,13 +171,12 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
static int edbm_screw_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
PropertyRNA *prop;
prop = RNA_struct_find_property(op->ptr, "center");
if (!RNA_property_is_set(op->ptr, prop)) {
- RNA_property_float_set_array(op->ptr, prop, ED_view3d_cursor3d_get(scene, v3d)->location);
+ RNA_property_float_set_array(op->ptr, prop, scene->cursor.location);
}
if (rv3d) {
prop = RNA_struct_find_property(op->ptr, "axis");
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c
index 848fe63cf8e..e9758cb1a5a 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin.c
@@ -85,7 +85,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op)
}
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -130,7 +130,7 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
PropertyRNA *prop;
prop = RNA_struct_find_property(op->ptr, "center");
if (!RNA_property_is_set(op->ptr, prop)) {
- RNA_property_float_set_array(op->ptr, prop, ED_view3d_cursor3d_get(scene, v3d)->location);
+ RNA_property_float_set_array(op->ptr, prop, scene->cursor.location);
}
if (rv3d) {
prop = RNA_struct_find_property(op->ptr, "axis");
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
index db2bb3bc66d..92b655b6d8d 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
@@ -316,8 +316,7 @@ static void gizmo_mesh_spin_init_refresh(const bContext *C, wmGizmoGroup *gzgrou
const float *gizmo_center = NULL;
{
Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- const View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
+ const View3DCursor *cursor = &scene->cursor;
gizmo_center = cursor->location;
}
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c
index 486203462a0..78c0c45576d 100644
--- a/source/blender/editors/mesh/editmesh_inset.c
+++ b/source/blender/editors/mesh/editmesh_inset.c
@@ -134,7 +134,7 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal)
{
uint ob_store_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &ob_store_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &ob_store_len);
opdata->ob_store = MEM_malloc_arrayN(ob_store_len, sizeof(*opdata->ob_store), __func__);
for (uint ob_index = 0; ob_index < ob_store_len; ob_index++) {
Object *obedit = objects[ob_index];
diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c
index 044e1b8c9d0..a625d8949a6 100644
--- a/source/blender/editors/mesh/editmesh_intersect.c
+++ b/source/blender/editors/mesh/editmesh_intersect.c
@@ -187,7 +187,7 @@ static int edbm_intersect_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
uint isect_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -290,7 +290,7 @@ static int edbm_intersect_boolean_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
uint isect_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -686,7 +686,7 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op))
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 2e442d97fad..7313469eda9 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -54,8 +54,6 @@
#include "BKE_editmesh_bvh.h"
#include "BKE_report.h"
-#include "DEG_depsgraph.h"
-
#include "GPU_immediate.h"
#include "GPU_matrix.h"
#include "GPU_state.h"
@@ -76,6 +74,9 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
+
#include "mesh_intern.h" /* own include */
/* detect isolated holes and fill them */
@@ -2601,7 +2602,12 @@ static void knifetool_init_bmbvh(KnifeTool_OpData *kcd)
{
BM_mesh_elem_index_ensure(kcd->em->bm, BM_VERT);
- kcd->cagecos = (const float (*)[3])BKE_editmesh_vertexCos_get(kcd->vc.depsgraph, kcd->em, kcd->scene, NULL);
+ Scene *scene_eval = (Scene *)DEG_get_evaluated_id(kcd->vc.depsgraph, &kcd->scene->id);
+ Object *obedit_eval = (Object *)DEG_get_evaluated_id(kcd->vc.depsgraph, &kcd->em->ob->id);
+ BMEditMesh *em_eval = BKE_editmesh_from_object(obedit_eval);
+
+ kcd->cagecos = (const float (*)[3])BKE_editmesh_vertexCos_get(
+ kcd->vc.depsgraph, em_eval, scene_eval, NULL);
kcd->bmbvh = BKE_bmbvh_new_from_editmesh(
kcd->em,
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c
index da8b8d217d7..a3396f75eaf 100644
--- a/source/blender/editors/mesh/editmesh_knife_project.c
+++ b/source/blender/editors/mesh/editmesh_knife_project.c
@@ -44,6 +44,7 @@
#include "BKE_report.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "RNA_define.h"
#include "RNA_access.h"
@@ -67,8 +68,12 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C, Scene *scene,
bool me_eval_needs_free;
if (ob->type == OB_MESH || ob->runtime.mesh_eval) {
- me_eval = (ob->runtime.mesh_eval ?
- ob->runtime.mesh_eval : mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH));
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+ me_eval = ob_eval->runtime.mesh_eval;
+ if (me_eval == NULL) {
+ Scene *scene_eval = (Scene *)DEG_get_evaluated_id(depsgraph, &scene->id);
+ me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
+ }
me_eval_needs_free = false;
}
else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
@@ -173,7 +178,7 @@ void MESH_OT_knife_project(wmOperatorType *ot)
ot->poll = ED_operator_editmesh_region_view3d;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
/* parameters */
RNA_def_boolean(ot->srna, "cut_through", false, "Cut through", "Cut through all faces, not just visible ones");
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index b69609a9fa8..9c5372cafd8 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -123,7 +123,7 @@ static void edgering_select(RingSelOpData *lcd)
Object *ob_iter = lcd->objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(ob_iter);
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- DEG_id_tag_update(ob_iter->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT);
WM_main_add_notifier(NC_GEOM | ND_SELECT, ob_iter->data);
}
}
@@ -227,7 +227,7 @@ static void ringsel_finish(bContext *C, wmOperator *op)
BM_select_history_store(em->bm, lcd->eed);
EDBM_selectmode_flush(lcd->em);
- DEG_id_tag_update(lcd->ob->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(lcd->ob->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, lcd->ob->data);
}
}
@@ -359,7 +359,7 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(view_layer, CTX_wm_view3d(C), &objects_len);
if (is_interactive) {
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c
index c7f82a36eed..7f47d1b3dcc 100644
--- a/source/blender/editors/mesh/editmesh_path.c
+++ b/source/blender/editors/mesh/editmesh_path.c
@@ -614,7 +614,7 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
{
int base_index = -1;
uint bases_len = 0;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(vc.view_layer, &bases_len);
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(vc.view_layer, vc.v3d, &bases_len);
if (EDBM_unified_findnearest(&vc, bases, bases_len, &base_index, &eve, &eed, &efa)) {
basact = bases[base_index];
ED_view3d_viewcontext_init_object(&vc, basact->object);
@@ -744,7 +744,7 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
diff --git a/source/blender/editors/mesh/editmesh_polybuild.c b/source/blender/editors/mesh/editmesh_polybuild.c
index c175102511a..1d0521ec777 100644
--- a/source/blender/editors/mesh/editmesh_polybuild.c
+++ b/source/blender/editors/mesh/editmesh_polybuild.c
@@ -71,17 +71,17 @@ static void edbm_selectmode_ensure(Scene *scene, BMEditMesh *em, short selectmod
}
/* Could make public, for now just keep here. */
-static void edbm_flag_disable_all_multi(ViewLayer *view_layer, const char hflag)
+static void edbm_flag_disable_all_multi(ViewLayer *view_layer, View3D *v3d, const char hflag)
{
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob_iter = objects[ob_index];
BMEditMesh *em_iter = BKE_editmesh_from_object(ob_iter);
BMesh *bm_iter = em_iter->bm;
if (bm_iter->totvertsel) {
EDBM_flag_disable_all(em_iter, hflag);
- DEG_id_tag_update(ob_iter->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT);
}
}
MEM_freeN(objects);
@@ -106,7 +106,7 @@ static bool edbm_preselect_or_active(
Object *obedit = NULL;
{
uint bases_len;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(view_layer, &bases_len);
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(view_layer, CTX_wm_view3d(C), &bases_len);
if (object_index < bases_len) {
base = bases[object_index];
obedit = base->object;
@@ -185,13 +185,13 @@ static int edbm_polybuild_face_at_cursor_invoke(
if (ele_act == NULL || ele_act->head.htype == BM_FACE) {
/* Just add vert */
- copy_v3_v3(center, ED_view3d_cursor3d_get(vc.scene, vc.v3d)->location);
+ copy_v3_v3(center, vc.scene->cursor.location);
mul_v3_m4v3(center, vc.obedit->obmat, center);
ED_view3d_win_to_3d_int(vc.v3d, vc.ar, center, event->mval, center);
mul_m4_v3(vc.obedit->imat, center);
BMVert *v_new = BM_vert_create(bm, center, NULL, BM_CREATE_NOP);
- edbm_flag_disable_all_multi(vc.view_layer, BM_ELEM_SELECT);
+ edbm_flag_disable_all_multi(vc.view_layer, vc.v3d, BM_ELEM_SELECT);
BM_vert_select_set(bm, v_new, true);
BM_select_history_store(bm, v_new);
changed = true;
@@ -215,7 +215,7 @@ static int edbm_polybuild_face_at_cursor_invoke(
// BMFace *f_new =
BM_face_create_verts(bm, v_tri, 3, f_reference, BM_CREATE_NOP, true);
- edbm_flag_disable_all_multi(vc.view_layer, BM_ELEM_SELECT);
+ edbm_flag_disable_all_multi(vc.view_layer, vc.v3d, BM_ELEM_SELECT);
BM_vert_select_set(bm, v_tri[2], true);
BM_select_history_store(bm, v_tri[2]);
changed = true;
@@ -267,7 +267,7 @@ static int edbm_polybuild_face_at_cursor_invoke(
// BMFace *f_new =
BM_face_create_verts(bm, v_quad, 4, f_reference, BM_CREATE_NOP, true);
- edbm_flag_disable_all_multi(vc.view_layer, BM_ELEM_SELECT);
+ edbm_flag_disable_all_multi(vc.view_layer, vc.v3d, BM_ELEM_SELECT);
BM_vert_select_set(bm, v_quad[2], true);
BM_select_history_store(bm, v_quad[2]);
changed = true;
@@ -362,7 +362,7 @@ static int edbm_polybuild_split_at_cursor_invoke(
BMVert *v_new = BM_edge_split(bm, e_act, e_act->v1, NULL, CLAMPIS(fac, 0.0f, 1.0f));
copy_v3_v3(v_new->co, center);
- edbm_flag_disable_all_multi(vc.view_layer, BM_ELEM_SELECT);
+ edbm_flag_disable_all_multi(vc.view_layer, vc.v3d, BM_ELEM_SELECT);
BM_vert_select_set(bm, v_new, true);
BM_select_history_store(bm, v_new);
changed = true;
@@ -464,7 +464,7 @@ static int edbm_polybuild_dissolve_at_cursor_invoke(
}
if (changed) {
- edbm_flag_disable_all_multi(vc.view_layer, BM_ELEM_SELECT);
+ edbm_flag_disable_all_multi(vc.view_layer, vc.v3d, BM_ELEM_SELECT);
EDBM_mesh_normals_update(em);
EDBM_update_generic(em, true, true);
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 9d6c0267cc2..fb380dfaaa9 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -1011,7 +1011,7 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
const bool do_fill = RNA_boolean_get(op->ptr, "use_fill");
bool no_vertex_selected = true;
diff --git a/source/blender/editors/mesh/editmesh_rip_edge.c b/source/blender/editors/mesh/editmesh_rip_edge.c
index c4a1ee9134d..ef07aac0ab2 100644
--- a/source/blender/editors/mesh/editmesh_rip_edge.c
+++ b/source/blender/editors/mesh/editmesh_rip_edge.c
@@ -55,7 +55,7 @@ static int edbm_rip_edge_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve
RegionView3D *rv3d = CTX_wm_region_view3d(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 1a32a36bdb4..3e97a73eade 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -1381,7 +1381,7 @@ static int edbm_select_similar_region_exec(bContext *C, wmOperator *op)
MEM_freeN(group_index);
if (changed) {
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
else {
@@ -1555,7 +1555,7 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op)
const bool is_ring = RNA_boolean_get(op->ptr, "ring");
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -1603,7 +1603,7 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op)
MEM_freeN(edarray);
// if (EM_texFaceCheck())
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -1711,7 +1711,7 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de
em_original->selectmode = SCE_SELECT_EDGE;
uint bases_len;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(vc.view_layer, &bases_len);
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(vc.view_layer, vc.v3d, &bases_len);
{
int base_index = -1;
@@ -1765,7 +1765,7 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de
}
EDBM_flag_disable_all(em_iter, BM_ELEM_SELECT);
- DEG_id_tag_update(ob_iter->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT);
}
}
@@ -1852,7 +1852,7 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de
MEM_freeN(bases);
- DEG_id_tag_update(vc.obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
return true;
@@ -1930,7 +1930,7 @@ static int edbm_select_all_exec(bContext *C, wmOperator *op)
int action = RNA_enum_get(op->ptr, "action");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
@@ -1959,7 +1959,7 @@ static int edbm_select_all_exec(bContext *C, wmOperator *op)
EDBM_selectmode_flush(em);
break;
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -1995,7 +1995,7 @@ static int edbm_faces_select_interior_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -2005,7 +2005,7 @@ static int edbm_faces_select_interior_exec(bContext *C, wmOperator *UNUSED(op))
continue;
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -2052,7 +2052,7 @@ bool EDBM_select_pick(bContext *C, const int mval[2], bool extend, bool deselect
vc.mval[1] = mval[1];
uint bases_len = 0;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(vc.view_layer, &bases_len);
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(vc.view_layer, vc.v3d, &bases_len);
bool ok = false;
@@ -2067,7 +2067,7 @@ bool EDBM_select_pick(bContext *C, const int mval[2], bool extend, bool deselect
Object *ob_iter = base_iter->object;
EDBM_flag_disable_all(BKE_editmesh_from_object(ob_iter), BM_ELEM_SELECT);
if (basact->object != ob_iter) {
- DEG_id_tag_update(ob_iter->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
}
}
@@ -2187,7 +2187,7 @@ bool EDBM_select_pick(bContext *C, const int mval[2], bool extend, bool deselect
ED_object_base_activate(C, basact);
}
- DEG_id_tag_update(vc.obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
ok = true;
@@ -2463,7 +2463,7 @@ bool EDBM_selectmode_toggle(
}
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob_iter = objects[ob_index];
@@ -2521,11 +2521,11 @@ bool EDBM_selectmode_toggle(
BMEditMesh *em_iter = BKE_editmesh_from_object(ob_iter);
em_iter->selectmode = ts->selectmode;
EDBM_selectmode_set(em_iter);
- DEG_id_tag_update(ob_iter->data, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob_iter->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
}
WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL);
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
}
MEM_freeN(objects);
@@ -2570,18 +2570,21 @@ bool EDBM_selectmode_disable(
/** \name Select Toggle
* \{ */
-void EDBM_deselect_by_material(BMEditMesh *em, const short index, const bool select)
+bool EDBM_deselect_by_material(BMEditMesh *em, const short index, const bool select)
{
BMIter iter;
BMFace *efa;
+ bool changed = false;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
continue;
if (efa->mat_nr == index) {
+ changed = true;
BM_face_select_set(em->bm, efa, select);
}
}
+ return changed;
}
void EDBM_select_toggle_all(BMEditMesh *em) /* exported for UV */
@@ -2806,7 +2809,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op)
#endif
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -2971,7 +2974,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op)
select_linked_delimit_end(em);
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -3138,7 +3141,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
em_setup_viewcontext(C, &vc);
uint bases_len;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(vc.view_layer, &bases_len);
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(vc.view_layer, vc.v3d, &bases_len);
{
bool has_edges = false;
@@ -3191,7 +3194,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
* index selections isn't very common. */
RNA_int_set(op->ptr, "index", index);
- DEG_id_tag_update(basact->object->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(basact->object->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, basact->object->data);
MEM_freeN(bases);
@@ -3222,7 +3225,7 @@ static int edbm_select_linked_pick_exec(bContext *C, wmOperator *op)
edbm_select_linked_pick_ex(em, ele, sel, delimit);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
@@ -3270,7 +3273,7 @@ static int edbm_select_face_by_sides_exec(bContext *C, wmOperator *op)
const bool extend = RNA_boolean_get(op->ptr, "extend");
const int numverts = RNA_int_get(op->ptr, "number");
const int type = RNA_enum_get(op->ptr, "type");
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -3311,7 +3314,7 @@ static int edbm_select_face_by_sides_exec(bContext *C, wmOperator *op)
EDBM_selectmode_flush(em);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -3359,7 +3362,7 @@ static int edbm_select_loose_exec(bContext *C, wmOperator *op)
const bool extend = RNA_boolean_get(op->ptr, "extend");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -3409,7 +3412,7 @@ static int edbm_select_loose_exec(bContext *C, wmOperator *op)
EDBM_selectmode_flush(em);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -3453,7 +3456,7 @@ static int edbm_select_mirror_exec(bContext *C, wmOperator *op)
int tot_mirr = 0, tot_fail = 0;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -3474,7 +3477,7 @@ static int edbm_select_mirror_exec(bContext *C, wmOperator *op)
if (tot_mirr_iter) {
EDBM_selectmode_flush(em);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -3521,7 +3524,7 @@ static int edbm_select_more_exec(bContext *C, wmOperator *op)
const bool use_face_step = RNA_boolean_get(op->ptr, "use_face_step");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -3535,7 +3538,7 @@ static int edbm_select_more_exec(bContext *C, wmOperator *op)
}
EDBM_select_more(em, use_face_step);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -3572,7 +3575,7 @@ static int edbm_select_less_exec(bContext *C, wmOperator *op)
const bool use_face_step = RNA_boolean_get(op->ptr, "use_face_step");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -3586,7 +3589,7 @@ static int edbm_select_less_exec(bContext *C, wmOperator *op)
}
EDBM_select_less(em, use_face_step);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -3809,7 +3812,7 @@ static int edbm_select_nth_exec(bContext *C, wmOperator *op)
bool found_active_elt = false;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -3883,7 +3886,7 @@ static int edbm_select_sharp_edges_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -3912,7 +3915,7 @@ static int edbm_select_sharp_edges_exec(bContext *C, wmOperator *op)
else {
EDBM_selectmode_flush(em);
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -3952,7 +3955,7 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
const float angle_limit_cos = cosf(RNA_float_get(op->ptr, "sharpness"));
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -4011,7 +4014,7 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op)
BLI_LINKSTACK_FREE(stack);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -4058,7 +4061,7 @@ static int edbm_select_non_manifold_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -4108,7 +4111,7 @@ static int edbm_select_non_manifold_exec(bContext *C, wmOperator *op)
}
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
EDBM_selectmode_flush(em);
@@ -4163,7 +4166,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -4212,7 +4215,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op)
EDBM_deselect_flush(em);
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -4270,7 +4273,7 @@ static int edbm_select_ungrouped_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -4307,7 +4310,7 @@ static int edbm_select_ungrouped_exec(bContext *C, wmOperator *op)
if (changed) {
EDBM_selectmode_flush(em);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
}
@@ -4368,7 +4371,7 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op)
/* 3D view variables may be NULL, (no need to check in poll function). */
ED_transform_calc_orientation_from_type_ex(
C, axis_mat,
- scene, CTX_wm_view3d(C), CTX_wm_region_view3d(C), obedit, obedit,
+ scene, CTX_wm_region_view3d(C), obedit, obedit,
orientation, V3D_AROUND_ACTIVE);
const float *axis_vector = axis_mat[axis];
@@ -4387,7 +4390,7 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op)
}
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit_iter = objects[ob_index];
BMEditMesh *em_iter = BKE_editmesh_from_object(obedit_iter);
@@ -4431,7 +4434,7 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op)
if (changed) {
EDBM_selectmode_flush(em_iter);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit_iter->data);
- DEG_id_tag_update(obedit_iter->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit_iter->data, ID_RECALC_SELECT);
}
}
MEM_freeN(objects);
@@ -4476,7 +4479,7 @@ static int edbm_region_to_loop_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -4523,7 +4526,7 @@ static int edbm_region_to_loop_exec(bContext *C, wmOperator *UNUSED(op))
EDBM_selectmode_to_scene(C);
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
@@ -4701,7 +4704,7 @@ static int edbm_loop_to_region_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -4731,7 +4734,7 @@ static int edbm_loop_to_region_exec(bContext *C, wmOperator *op)
EDBM_selectmode_flush(em);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
MEM_freeN(objects);
diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c
index 1124b58e116..304d1b81eab 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -197,7 +197,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
int tot_faces_selected_all = 0;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
@@ -307,7 +307,6 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
float dummy[3] = {perimeter, 0.0f, 0.0f};
BLI_kdtree_insert(tree, tree_index++, dummy);
break;
- break;
}
case SIMFACE_NORMAL:
{
@@ -683,7 +682,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
int tot_edges_selected_all = 0;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
@@ -1038,7 +1037,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
int tot_verts_selected_all = 0;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 72cde69b0bc..9775125af07 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -117,7 +117,7 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -254,7 +254,7 @@ static int edbm_subdivide_edge_ring_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
struct EdgeRingOpSubdProps op_props;
mesh_operator_edgering_props_get(op, &op_props);
@@ -312,7 +312,7 @@ static int edbm_unsubdivide_exec(bContext *C, wmOperator *op)
const int iterations = RNA_int_get(op->ptr, "iterations");
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -428,7 +428,7 @@ static int edbm_delete_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
bool changed_multi = false;
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -549,7 +549,7 @@ static int edbm_delete_loose_exec(bContext *C, wmOperator *op)
int totelem_old[3];
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
EDBM_mesh_stats_multi(objects, objects_len, totelem_old, totelem_old_sel);
@@ -649,7 +649,7 @@ static int edbm_collapse_edge_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -871,7 +871,7 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -978,7 +978,7 @@ static int edbm_mark_seam_exec(bContext *C, wmOperator *op)
const bool clear = RNA_boolean_get(op->ptr, "clear");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -1051,7 +1051,7 @@ static int edbm_mark_sharp_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -1188,7 +1188,7 @@ static int edbm_vert_connect_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
uint failed_objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -1442,7 +1442,7 @@ static int edbm_vert_connect_path_exec(bContext *C, wmOperator *op)
uint objects_len = 0;
uint failed_selection_order_len = 0;
uint failed_connect_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -1519,7 +1519,7 @@ static int edbm_vert_connect_concave_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -1569,7 +1569,7 @@ static int edbm_vert_connect_nonplaner_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
const float angle_limit = RNA_float_get(op->ptr, "angle_limit");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -1627,7 +1627,7 @@ static int edbm_face_make_planar_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
const int repeat = RNA_int_get(op->ptr, "repeat");
const float fac = RNA_float_get(op->ptr, "factor");
@@ -1682,7 +1682,7 @@ static int edbm_edge_split_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -1735,7 +1735,7 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -1809,7 +1809,7 @@ static int edbm_flip_normals_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -1868,7 +1868,7 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -1986,7 +1986,7 @@ static int edbm_hide_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -2037,7 +2037,7 @@ static int edbm_reveal_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -2078,7 +2078,7 @@ static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -2139,7 +2139,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Mesh *me = obedit->data;
@@ -2254,7 +2254,7 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op)
}
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -2377,7 +2377,7 @@ static int edbm_faces_shade_smooth_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -2419,7 +2419,7 @@ static int edbm_faces_shade_flat_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -2464,7 +2464,7 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -2496,7 +2496,7 @@ static int edbm_reverse_uvs_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -2531,7 +2531,7 @@ static int edbm_rotate_colors_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
@@ -2567,7 +2567,7 @@ static int edbm_reverse_colors_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
@@ -2723,7 +2723,7 @@ static bool merge_firstlast(BMEditMesh *em, const bool use_first, const bool use
}
static bool merge_target(
- BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob,
+ BMEditMesh *em, Scene *scene, Object *ob,
const bool use_cursor, const bool use_uvmerge, wmOperator *wmop)
{
BMIter iter;
@@ -2732,7 +2732,7 @@ static bool merge_target(
const float *vco = NULL;
if (use_cursor) {
- vco = ED_view3d_cursor3d_get(scene, v3d)->location;
+ vco = scene->cursor.location;
copy_v3_v3(co, vco);
invert_m4_m4(ob->imat, ob->obmat);
mul_m4_v3(ob->imat, co);
@@ -2773,10 +2773,9 @@ static bool merge_target(
static int edbm_merge_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
const int type = RNA_enum_get(op->ptr, "type");
const bool uvs = RNA_boolean_get(op->ptr, "uvs");
@@ -2791,10 +2790,10 @@ static int edbm_merge_exec(bContext *C, wmOperator *op)
bool ok = false;
switch (type) {
case MESH_MERGE_CENTER:
- ok = merge_target(em, scene, v3d, obedit, false, uvs, op);
+ ok = merge_target(em, scene, obedit, false, uvs, op);
break;
case MESH_MERGE_CURSOR:
- ok = merge_target(em, scene, v3d, obedit, true, uvs, op);
+ ok = merge_target(em, scene, obedit, true, uvs, op);
break;
case MESH_MERGE_LAST:
ok = merge_firstlast(em, false, uvs, op);
@@ -2924,7 +2923,7 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -3052,7 +3051,7 @@ static int edbm_shape_propagate_to_all_exec(bContext *C, wmOperator *op)
int tot_selected_verts_objects = 0;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Mesh *me = obedit->data;
@@ -3147,7 +3146,7 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
int tot_selected_verts_objects = 0;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Mesh *me = obedit->data;
@@ -3292,7 +3291,7 @@ static int edbm_solidify_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -3978,7 +3977,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
if (ED_operator_editmesh(C)) {
uint bases_len = 0;
uint empty_selection_len = 0;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, &bases_len);
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &bases_len);
for (uint bs_index = 0; bs_index < bases_len; bs_index++) {
Base *base = bases[bs_index];
BMEditMesh *em = BKE_editmesh_from_object(base->object);
@@ -4059,7 +4058,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
.calc_object_remap = true,
}));
- DEG_id_tag_update(&me->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
}
@@ -4122,7 +4121,7 @@ static int edbm_fill_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -4352,7 +4351,7 @@ static int edbm_fill_grid_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -4474,7 +4473,7 @@ static int edbm_fill_holes_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -4529,7 +4528,7 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
const float angle_max = M_PI;
const float angle_limit = RNA_float_get(op->ptr, "angle_limit");
@@ -4612,7 +4611,7 @@ static int edbm_poke_face_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -4685,7 +4684,7 @@ static int edbm_quads_convert_to_tris_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -4758,7 +4757,7 @@ static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
bool is_face_pair;
@@ -4888,7 +4887,7 @@ static int edbm_decimate_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -5091,7 +5090,7 @@ static int edbm_dissolve_verts_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -5146,7 +5145,7 @@ static int edbm_dissolve_edges_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -5200,7 +5199,7 @@ static int edbm_dissolve_faces_exec(bContext *C, wmOperator *op)
const bool use_verts = RNA_boolean_get(op->ptr, "use_verts");
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -5307,7 +5306,7 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -5401,7 +5400,7 @@ static int edbm_dissolve_degenerate_exec(bContext *C, wmOperator *op)
int totelem_new[3] = {0, 0, 0};
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -5474,7 +5473,7 @@ static int edbm_delete_edgeloop_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -5547,7 +5546,7 @@ static int edbm_split_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -5628,7 +5627,7 @@ static int bmelemsort_comp(const void *v1, const void *v2)
static void sort_bmelem_flag(
bContext *C,
Scene *scene, Object *ob,
- View3D *v3d, RegionView3D *rv3d,
+ RegionView3D *rv3d,
const int types, const int flag, const int action,
const int reverse, const unsigned int seed)
{
@@ -5730,10 +5729,8 @@ static void sort_bmelem_flag(
float mat[4][4];
float fact = reverse ? -1.0 : 1.0;
- if (v3d && v3d->localvd)
- copy_v3_v3(cur, v3d->cursor.location);
- else
- copy_v3_v3(cur, scene->cursor.location);
+ copy_v3_v3(cur, scene->cursor.location);
+
invert_m4_m4(mat, ob->obmat);
mul_m4_v3(mat, cur);
@@ -6051,7 +6048,7 @@ static void sort_bmelem_flag(
}
BM_mesh_remap(em->bm, map[0], map[1], map[2]);
- DEG_id_tag_update(ob->data, OB_RECALC_DATA);
+ DEG_id_tag_update(ob->data, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
for (j = 3; j--; ) {
@@ -6067,7 +6064,6 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op)
Object *ob_active = CTX_data_edit_object(C);
/* may be NULL */
- View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
const int action = RNA_enum_get(op->ptr, "type");
@@ -6099,7 +6095,7 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op)
}
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
@@ -6121,8 +6117,8 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op)
}
sort_bmelem_flag(
- C, scene, ob, v3d, rv3d,
- elem_types, BM_ELEM_SELECT, action, use_reverse, seed_iter);
+ C, scene, ob, rv3d,
+ elem_types, BM_ELEM_SELECT, action, use_reverse, seed_iter);
}
MEM_freeN(objects);
return OPERATOR_FINISHED;
@@ -6362,7 +6358,7 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -6433,7 +6429,7 @@ static int edbm_wireframe_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -6521,7 +6517,7 @@ static int edbm_offset_edgeloop_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -6602,7 +6598,7 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -6723,7 +6719,7 @@ static int mesh_symmetrize_exec(bContext *C, wmOperator *op)
const float thresh = RNA_float_get(op->ptr, "threshold");
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -6805,7 +6801,7 @@ static int mesh_symmetry_snap_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -6942,7 +6938,7 @@ static int edbm_mark_freestyle_edge_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -6978,7 +6974,7 @@ static int edbm_mark_freestyle_edge_exec(bContext *C, wmOperator *op)
}
}
- DEG_id_tag_update(obedit->data, OB_RECALC_DATA);
+ DEG_id_tag_update(obedit->data, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
}
MEM_freeN(objects);
@@ -7021,7 +7017,7 @@ static int edbm_mark_freestyle_face_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -7055,7 +7051,7 @@ static int edbm_mark_freestyle_face_exec(bContext *C, wmOperator *op)
}
}
- DEG_id_tag_update(obedit->data, OB_RECALC_DATA);
+ DEG_id_tag_update(obedit->data, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
}
MEM_freeN(objects);
@@ -7363,7 +7359,7 @@ static int edbm_point_normals_modal(bContext *C, wmOperator *op, const wmEvent *
case EDBM_CLNOR_MODAL_POINTTO_SET_USE_3DCURSOR:
new_mode = EDBM_CLNOR_POINTTO_MODE_COORDINATES;
ED_view3d_cursor3d_update(C, event->mval, false, V3D_CURSOR_ORIENT_NONE);
- copy_v3_v3(target, ED_view3d_cursor3d_get(scene, v3d)->location);
+ copy_v3_v3(target, scene->cursor.location);
ret = OPERATOR_RUNNING_MODAL;
break;
@@ -7412,7 +7408,7 @@ static int edbm_point_normals_modal(bContext *C, wmOperator *op, const wmEvent *
}
case V3D_AROUND_CURSOR:
- copy_v3_v3(target, ED_view3d_cursor3d_get(scene, v3d)->location);
+ copy_v3_v3(target, scene->cursor.location);
break;
case V3D_AROUND_ACTIVE:
@@ -7558,7 +7554,7 @@ void MESH_OT_point_normals(struct wmOperatorType *ot)
RNA_def_boolean(ot->srna, "align", false, "Align", "Make all affected normals parallel");
- RNA_def_float_vector(ot->srna, "target_location", 3, (float[3]){0.0f, 0.0f, 0.0f}, -FLT_MAX, FLT_MAX,
+ RNA_def_float_vector(ot->srna, "target_location", 3, NULL, -FLT_MAX, FLT_MAX,
"Target", "Target location to which normals will point", -1000.0f, 1000.0f);
RNA_def_boolean(ot->srna, "spherize", false,
@@ -8142,7 +8138,7 @@ static int edbm_set_normals_from_faces_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index 26f3c17a97c..9b24157e4d9 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -706,7 +706,7 @@ static bool mesh_undosys_step_encode(struct bContext *C, UndoStep *us_p)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
us->elems_len = objects_len;
@@ -744,7 +744,7 @@ static void mesh_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UNU
}
BMEditMesh *em = me->edit_btmesh;
undomesh_to_editmesh(&elem->data, em, obedit->data);
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
/* The first element is always active */
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 7fdef86f7e5..cb8d4f8d00e 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -174,7 +174,7 @@ bool EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const bool
}
if (em->ob) {
- DEG_id_tag_update(&((Mesh *)em->ob->data)->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&((Mesh *)em->ob->data)->id, ID_RECALC_COPY_ON_WRITE);
}
return false;
@@ -1333,7 +1333,7 @@ void EDBM_update_generic(BMEditMesh *em, const bool do_tessface, const bool is_d
{
Object *ob = em->ob;
/* order of calling isn't important */
- DEG_id_tag_update(ob->data, OB_RECALC_DATA);
+ DEG_id_tag_update(ob->data, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GEOM | ND_DATA, ob->data);
if (do_tessface) {
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index c9ce8ed54fc..cc49beb17b8 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -66,6 +66,7 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "ED_mesh.h"
#include "ED_object.h"
@@ -592,9 +593,9 @@ int join_mesh_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain); /* removed objects, need to rebuild dag */
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
return OPERATOR_FINISHED;
@@ -663,7 +664,10 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
selme = (Mesh *)ob_iter->data;
if (selme->totvert == me->totvert) {
- me_deformed = mesh_get_eval_deform(depsgraph, scene, ob_iter, CD_MASK_BAREMESH);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter);
+
+ me_deformed = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
if (!me_deformed) {
continue;
@@ -677,7 +681,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
return OPERATOR_FINISHED;
@@ -1080,11 +1084,12 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned
BLI_assert(me && GS(me->id.name) == ID_ME);
if (ED_mesh_pick_face(C, ob, mval, &poly_index, size)) {
- Scene *scene = CTX_data_scene(C);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
struct ARegion *ar = CTX_wm_region(C);
/* derived mesh to find deformed locations */
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
int v_idx_best = ORIGINDEX_NONE;
@@ -1209,8 +1214,11 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int
(*index)--;
}
else {
+ Scene *scene_eval = DEG_get_evaluated_scene(vc.depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(vc.depsgraph, ob);
+
/* derived mesh to find deformed locations */
- Mesh *me_eval = mesh_get_eval_final(vc.depsgraph, vc.scene, ob, CD_MASK_BAREMESH);
+ Mesh *me_eval = mesh_get_eval_final(vc.depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
ARegion *ar = vc.ar;
RegionView3D *rv3d = ar->regiondata;
diff --git a/source/blender/editors/metaball/editmball_undo.c b/source/blender/editors/metaball/editmball_undo.c
index 7045025e227..ebf056f71db 100644
--- a/source/blender/editors/metaball/editmball_undo.c
+++ b/source/blender/editors/metaball/editmball_undo.c
@@ -163,7 +163,7 @@ static bool mball_undosys_step_encode(struct bContext *C, UndoStep *us_p)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
us->elems_len = objects_len;
@@ -199,7 +199,7 @@ static void mball_undosys_step_decode(struct bContext *C, UndoStep *us_p, int UN
continue;
}
undomball_to_editmball(&elem->data, mb);
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
/* The first element is always active */
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index 6d1ba2d3fe0..aedb182dceb 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -132,7 +132,7 @@ static int mball_select_all_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
if (action == SEL_TOGGLE) {
action = BKE_mball_is_any_selected_multi(objects, objects_len) ?
@@ -155,7 +155,7 @@ static int mball_select_all_exec(bContext *C, wmOperator *op)
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
MetaBall *mb = (MetaBall *)obedit->data;
- DEG_id_tag_update(&mb->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&mb->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb);
}
@@ -312,7 +312,7 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
tot_mball_selected_all = BKE_mball_select_count_multi(objects, objects_len);
@@ -384,7 +384,7 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op)
}
if (changed) {
- DEG_id_tag_update(&mb->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&mb->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb);
}
}
@@ -429,7 +429,7 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
MetaBall *mb = (MetaBall *)obedit->data;
@@ -458,7 +458,7 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op)
BLI_rng_free(rng);
- DEG_id_tag_update(&mb->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&mb->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb);
}
MEM_freeN(objects);
@@ -490,7 +490,7 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
MetaBall *mb = (MetaBall *)obedit->data;
@@ -541,7 +541,7 @@ static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
MetaBall *mb = (MetaBall *)obedit->data;
@@ -690,7 +690,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
&vc, buffer, MAXPICKBUF, &rect,
VIEW3D_SELECT_PICK_NEAREST, VIEW3D_SELECT_FILTER_NOP);
- FOREACH_BASE_IN_EDIT_MODE_BEGIN (vc.view_layer, base) {
+ FOREACH_BASE_IN_EDIT_MODE_BEGIN (vc.view_layer, vc.v3d, base) {
ED_view3d_viewcontext_init_object(&vc, base->object);
MetaBall *mb = (MetaBall *)base->object->data;
MetaElem *ml, *ml_act = NULL;
@@ -752,7 +752,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
if (ml_act) {
if (!extend && !deselect && !toggle) {
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob_iter = objects[ob_index];
@@ -761,7 +761,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
}
BKE_mball_deselect_all((MetaBall *)ob_iter->data);
- DEG_id_tag_update(ob_iter->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
}
MEM_freeN(objects);
@@ -789,7 +789,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
mb->lastelem = ml_act;
- DEG_id_tag_update(&mb->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&mb->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb);
if (vc.view_layer->basact != base) {
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index c4eb0aad337..a760086abae 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -95,6 +95,7 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -163,13 +164,8 @@ static EnumPropertyItem lightprobe_type_items[] = {
void ED_object_location_from_view(bContext *C, float loc[3])
{
- View3D *v3d = CTX_wm_view3d(C);
- Scene *scene = CTX_data_scene(C);
- const float *cursor;
-
- cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
-
- copy_v3_v3(loc, cursor);
+ const Scene *scene = CTX_data_scene(C);
+ copy_v3_v3(loc, scene->cursor.location);
}
void ED_object_rotation_from_quat(float rot[3], const float viewquat[4], const char align_axis)
@@ -313,9 +309,10 @@ void ED_object_add_mesh_props(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "calc_uvs", true, "Generate UVs", "Generate a default UV map");
}
-bool ED_object_add_generic_get_opts(bContext *C, wmOperator *op, const char view_align_axis,
- float loc[3], float rot[3],
- bool *enter_editmode, bool *is_view_aligned)
+bool ED_object_add_generic_get_opts(
+ bContext *C, wmOperator *op, const char view_align_axis,
+ float loc[3], float rot[3],
+ bool *enter_editmode, ushort *local_view_bits, bool *is_view_aligned)
{
PropertyRNA *prop;
@@ -333,6 +330,13 @@ bool ED_object_add_generic_get_opts(bContext *C, wmOperator *op, const char view
}
}
+ if (local_view_bits) {
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d && v3d->localvd) {
+ *local_view_bits = v3d->local_view_uuid;
+ }
+ }
+
/* Location! */
{
float _loc[3];
@@ -383,7 +387,7 @@ Object *ED_object_add_type(
bContext *C,
int type, const char *name,
const float loc[3], const float rot[3],
- bool enter_editmode)
+ bool enter_editmode, ushort local_view_bits)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -397,6 +401,7 @@ Object *ED_object_add_type(
/* deselects all, sets active object */
ob = BKE_object_add(bmain, scene, view_layer, type, name);
+ BASACT(view_layer)->local_view_bits = local_view_bits;
/* editor level activate, notifiers */
ED_object_base_activate(C, view_layer->basact);
@@ -409,7 +414,7 @@ Object *ED_object_add_type(
DEG_id_type_tag(bmain, ID_OB);
DEG_relations_tag_update(bmain);
if (ob->data != NULL) {
- DEG_id_tag_update_ex(bmain, (ID *)ob->data, DEG_TAG_EDITORS_UPDATE);
+ DEG_id_tag_update_ex(bmain, (ID *)ob->data, ID_RECALC_EDITORS);
}
if (enter_editmode)
@@ -428,14 +433,15 @@ static int object_add_exec(bContext *C, wmOperator *op)
{
Object *ob;
bool enter_editmode;
+ ushort local_view_bits;
float loc[3], rot[3], radius;
WM_operator_view3d_unit_defaults(C, op);
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
-
+ }
radius = RNA_float_get(op->ptr, "radius");
- ob = ED_object_add_type(C, RNA_enum_get(op->ptr, "type"), NULL, loc, rot, enter_editmode);
+ ob = ED_object_add_type(C, RNA_enum_get(op->ptr, "type"), NULL, loc, rot, enter_editmode, local_view_bits);
if (ob->type == OB_LATTICE) {
/* lattice is a special case!
@@ -490,17 +496,18 @@ static int lightprobe_add_exec(bContext *C, wmOperator *op)
LightProbe *probe;
int type;
bool enter_editmode;
+ ushort local_view_bits;
float loc[3], rot[3];
float radius;
WM_operator_view3d_unit_defaults(C, op);
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
-
+ }
type = RNA_enum_get(op->ptr, "type");
radius = RNA_float_get(op->ptr, "radius");
- ob = ED_object_add_type(C, OB_LIGHTPROBE, get_lightprobe_defname(type), loc, rot, false);
+ ob = ED_object_add_type(C, OB_LIGHTPROBE, get_lightprobe_defname(type), loc, rot, false, local_view_bits);
BKE_object_obdata_size_init(ob, radius);
probe = (LightProbe *)ob->data;
@@ -560,21 +567,22 @@ static int effector_add_exec(bContext *C, wmOperator *op)
Object *ob;
int type;
bool enter_editmode;
+ ushort local_view_bits;
float loc[3], rot[3];
float mat[4][4];
float dia;
WM_operator_view3d_unit_defaults(C, op);
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
-
+ }
type = RNA_enum_get(op->ptr, "type");
dia = RNA_float_get(op->ptr, "radius");
if (type == PFIELD_GUIDE) {
Curve *cu;
const char *name = CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "CurveGuide");
- ob = ED_object_add_type(C, OB_CURVE, name, loc, rot, false);
+ ob = ED_object_add_type(C, OB_CURVE, name, loc, rot, false, local_view_bits);
cu = ob->data;
cu->flag |= CU_PATH | CU_3D;
@@ -586,13 +594,13 @@ static int effector_add_exec(bContext *C, wmOperator *op)
}
else {
const char *name = CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Field");
- ob = ED_object_add_type(C, OB_EMPTY, name, loc, rot, false);
+ ob = ED_object_add_type(C, OB_EMPTY, name, loc, rot, false, local_view_bits);
BKE_object_obdata_size_init(ob, dia);
if (ELEM(type, PFIELD_WIND, PFIELD_VORTEX))
ob->empty_drawtype = OB_SINGLE_ARROW;
}
- ob->pd = object_add_collision_fields(type);
+ ob->pd = BKE_partdeflect_new(type);
DEG_relations_tag_update(CTX_data_main(C));
@@ -629,15 +637,16 @@ static int object_camera_add_exec(bContext *C, wmOperator *op)
Object *ob;
Camera *cam;
bool enter_editmode;
+ ushort local_view_bits;
float loc[3], rot[3];
/* force view align for cameras */
RNA_boolean_set(op->ptr, "view_align", true);
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
-
- ob = ED_object_add_type(C, OB_CAMERA, NULL, loc, rot, false);
+ }
+ ob = ED_object_add_type(C, OB_CAMERA, NULL, loc, rot, false, local_view_bits);
if (v3d) {
if (v3d->camera == NULL)
@@ -684,20 +693,21 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
bool newob = false;
bool enter_editmode;
+ ushort local_view_bits;
float loc[3], rot[3];
float mat[4][4];
float dia;
WM_operator_view3d_unit_defaults(C, op);
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
-
+ }
if (obedit == NULL || obedit->type != OB_MBALL) {
- obedit = ED_object_add_type(C, OB_MBALL, NULL, loc, rot, true);
+ obedit = ED_object_add_type(C, OB_MBALL, NULL, loc, rot, true, local_view_bits);
newob = true;
}
else {
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
@@ -742,16 +752,17 @@ static int object_add_text_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
bool enter_editmode;
+ ushort local_view_bits;
float loc[3], rot[3];
WM_operator_view3d_unit_defaults(C, op);
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
-
+ }
if (obedit && obedit->type == OB_FONT)
return OPERATOR_CANCELLED;
- obedit = ED_object_add_type(C, OB_FONT, NULL, loc, rot, enter_editmode);
+ obedit = ED_object_add_type(C, OB_FONT, NULL, loc, rot, enter_editmode, local_view_bits);
BKE_object_obdata_size_init(obedit, RNA_float_get(op->ptr, "radius"));
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
@@ -786,20 +797,21 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
RegionView3D *rv3d = CTX_wm_region_view3d(C);
bool newob = false;
bool enter_editmode;
+ ushort local_view_bits;
float loc[3], rot[3], dia;
bool view_aligned = rv3d && (U.flag & USER_ADD_VIEWALIGNED);
WM_operator_view3d_unit_defaults(C, op);
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
-
+ }
if ((obedit == NULL) || (obedit->type != OB_ARMATURE)) {
- obedit = ED_object_add_type(C, OB_ARMATURE, NULL, loc, rot, true);
+ obedit = ED_object_add_type(C, OB_ARMATURE, NULL, loc, rot, true, local_view_bits);
ED_object_editmode_enter(C, 0);
newob = true;
}
else {
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
if (obedit == NULL) {
@@ -844,13 +856,14 @@ static int object_empty_add_exec(bContext *C, wmOperator *op)
{
Object *ob;
int type = RNA_enum_get(op->ptr, "type");
+ ushort local_view_bits;
float loc[3], rot[3];
WM_operator_view3d_unit_defaults(C, op);
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
-
- ob = ED_object_add_type(C, OB_EMPTY, NULL, loc, rot, false);
+ }
+ ob = ED_object_add_type(C, OB_EMPTY, NULL, loc, rot, false, local_view_bits);
BKE_object_empty_draw_type_set(ob, type);
BKE_object_obdata_size_init(ob, RNA_float_get(op->ptr, "radius"));
@@ -899,11 +912,18 @@ static int empty_drop_named_image_invoke(bContext *C, wmOperator *op, const wmEv
/* either change empty under cursor or create a new empty */
if (ob_cursor && ob_cursor->type == OB_EMPTY) {
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
- DEG_id_tag_update((ID *)ob_cursor, DEG_TAG_TRANSFORM);
+ DEG_id_tag_update((ID *)ob_cursor, ID_RECALC_TRANSFORM);
ob = ob_cursor;
}
else {
- ob = ED_object_add_type(C, OB_EMPTY, NULL, NULL, NULL, false);
+ /* add new empty */
+ ushort local_view_bits;
+ float rot[3];
+
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', NULL, rot, NULL, &local_view_bits, NULL)) {
+ return OPERATOR_CANCELLED;
+ }
+ ob = ED_object_add_type(C, OB_EMPTY, NULL, NULL, rot, false, local_view_bits);
ED_object_location_from_view(C, ob->loc);
ED_view3d_cursor3d_position(C, event->mval, false, ob->loc);
@@ -955,14 +975,15 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op)
const int type = RNA_enum_get(op->ptr, "type");
+ ushort local_view_bits;
float loc[3], rot[3];
bool newob = false;
/* Note: We use 'Y' here (not 'Z'), as */
WM_operator_view3d_unit_defaults(C, op);
- if (!ED_object_add_generic_get_opts(C, op, 'Y', loc, rot, NULL, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Y', loc, rot, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
-
+ }
/* add new object if not currently editing a GP object,
* or if "empty" was chosen (i.e. user wants a blank GP canvas)
*/
@@ -986,14 +1007,14 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op)
}
float radius = RNA_float_get(op->ptr, "radius");
- ob = ED_object_add_type(C, OB_GPENCIL, ob_name, loc, rot, true);
+ ob = ED_object_add_type(C, OB_GPENCIL, ob_name, loc, rot, true, local_view_bits);
gpd = ob->data;
newob = true;
BKE_object_obdata_size_init(ob, GP_OBGPENCIL_DEFAULT_SIZE * radius);
}
else {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_ADDED, NULL);
}
@@ -1084,13 +1105,14 @@ static int object_light_add_exec(bContext *C, wmOperator *op)
Object *ob;
Lamp *la;
int type = RNA_enum_get(op->ptr, "type");
+ ushort local_view_bits;
float loc[3], rot[3];
WM_operator_view3d_unit_defaults(C, op);
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
-
- ob = ED_object_add_type(C, OB_LAMP, get_light_defname(type), loc, rot, false);
+ }
+ ob = ED_object_add_type(C, OB_LAMP, get_light_defname(type), loc, rot, false, local_view_bits);
float size = RNA_float_get(op->ptr, "radius");
/* Better defaults for light size. */
@@ -1147,6 +1169,7 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Collection *collection;
+ ushort local_view_bits;
float loc[3], rot[3];
if (RNA_struct_property_is_set(op->ptr, "name")) {
@@ -1168,9 +1191,9 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op)
else
collection = BLI_findlink(&CTX_data_main(C)->collection, RNA_enum_get(op->ptr, "collection"));
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
-
+ }
if (collection) {
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -1181,14 +1204,14 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op)
active_lc = BKE_layer_collection_activate_parent(view_layer, active_lc);
}
- Object *ob = ED_object_add_type(C, OB_EMPTY, collection->id.name + 2, loc, rot, false);
+ Object *ob = ED_object_add_type(C, OB_EMPTY, collection->id.name + 2, loc, rot, false, local_view_bits);
ob->dup_group = collection;
ob->transflag |= OB_DUPLICOLLECTION;
id_us_plus(&collection->id);
/* works without this except if you try render right after, see: 22027 */
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
return OPERATOR_FINISHED;
@@ -1229,13 +1252,14 @@ void OBJECT_OT_collection_instance_add(wmOperatorType *ot)
static int object_speaker_add_exec(bContext *C, wmOperator *op)
{
Object *ob;
+ ushort local_view_bits;
float loc[3], rot[3];
Scene *scene = CTX_data_scene(C);
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
-
- ob = ED_object_add_type(C, OB_SPEAKER, NULL, loc, rot, false);
+ }
+ ob = ED_object_add_type(C, OB_SPEAKER, NULL, loc, rot, false, local_view_bits);
/* to make it easier to start using this immediately in NLA, a default sound clip is created
* ready to be moved around to retime the sound and/or make new sound clips
@@ -1293,7 +1317,7 @@ void ED_object_base_free_and_unlink(Main *bmain, Scene *scene, Object *ob)
return;
}
- DEG_id_tag_update_ex(bmain, &ob->id, DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_id_tag_update_ex(bmain, &ob->id, ID_RECALC_BASE_FLAGS);
BKE_scene_collections_object_remove(bmain, scene, ob, true);
}
@@ -1328,7 +1352,7 @@ static int object_delete_exec(bContext *C, wmOperator *op)
/* if grease pencil object, set cache as dirty */
if (ob->type == OB_GPENCIL) {
bGPdata *gpd = (bGPdata *)ob->data;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
/* This is sort of a quick hack to address T51243 - Proper thing to do here would be to nuke most of all this
@@ -1393,7 +1417,7 @@ static int object_delete_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
}
@@ -1525,7 +1549,8 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
return;
}
- lb_duplis = object_duplilist(depsgraph, scene, base->object);
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, base->object);
+ lb_duplis = object_duplilist(depsgraph, scene, object_eval);
dupli_gh = BLI_ghash_ptr_new(__func__);
if (use_hierarchy) {
@@ -1538,7 +1563,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
}
for (dob = lb_duplis->first; dob; dob = dob->next) {
- Object *ob_src = dob->ob;
+ Object *ob_src = DEG_get_original_object(dob->ob);
Object *ob_dst = ID_NEW_SET(dob->ob, BKE_object_copy(bmain, ob_src));
Base *base_dst;
@@ -1584,13 +1609,13 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
}
for (dob = lb_duplis->first; dob; dob = dob->next) {
- Object *ob_src = dob->ob;
+ Object *ob_src = DEG_get_original_object(dob->ob);
Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob);
/* Remap new object to itself, and clear again newid pointer of orig object. */
BKE_libblock_relink_to_newid(&ob_dst->id);
- DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
if (use_hierarchy) {
/* original parents */
@@ -1644,7 +1669,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
BKE_object_apply_mat4(ob_dst, dob->mat, false, true);
/* to set ob_dst->orig and in case there's any other discrepancies */
- DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_TRANSFORM);
}
}
@@ -1653,7 +1678,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
if (ob->proxy_group == base->object) {
ob->proxy = NULL;
ob->proxy_from = NULL;
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
}
}
@@ -1668,6 +1693,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
BKE_main_id_clear_newpoins(bmain);
base->object->transflag &= ~OB_DUPLI;
+ DEG_id_tag_update(&base->object->id, ID_RECALC_COPY_ON_WRITE);
}
static int object_duplicates_make_real_exec(bContext *C, wmOperator *op)
@@ -1709,7 +1735,7 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot)
ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
RNA_def_boolean(ot->srna, "use_base_parent", 0, "Parent", "Parent newly created objects to the original duplicator");
RNA_def_boolean(ot->srna, "use_hierarchy", 0, "Keep Hierarchy", "Maintain parent child relationships");
@@ -1728,9 +1754,12 @@ static void convert_ensure_curve_cache(Depsgraph *depsgraph, Scene *scene, Objec
if (ob->runtime.curve_cache == NULL) {
/* Force creation. This is normally not needed but on operator
* redo we might end up with an object which isn't evaluated yet.
+ * Also happens in case we are working on a copy of the object (all its caches have been nuked then).
*/
if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
- BKE_displist_make_curveTypes(depsgraph, scene, ob, false);
+ /* We need 'for render' ON here, to enable computing bevel dipslist if needed.
+ * Also makes sense anyway, we would not want e.g. to loose hidden parts etc. */
+ BKE_displist_make_curveTypes(depsgraph, scene, ob, true, false);
}
else if (ob->type == OB_MBALL) {
BKE_displist_make_mball(depsgraph, scene, ob);
@@ -1769,7 +1798,7 @@ static Base *duplibase_for_convert(Main *bmain, Scene *scene, ViewLayer *view_la
}
obn = BKE_object_copy(bmain, ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
BKE_collection_object_add_from(bmain, scene, ob, obn);
basen = BKE_view_layer_base_find(view_layer, obn);
@@ -1841,7 +1870,7 @@ static int convert_exec(bContext *C, wmOperator *op)
"Converting some linked object/object data, enforcing 'Keep Original' option to True");
}
- DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY);
}
uint64_t customdata_mask_prev = scene->customdata_mask;
@@ -1915,17 +1944,17 @@ static int convert_exec(bContext *C, wmOperator *op)
}
else {
newob = ob;
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
}
/* make new mesh data from the original copy */
/* note: get the mesh from the original, not from the copy in some
* cases this doesn't give correct results (when MDEF is used for eg)
*/
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, newob, CD_MASK_MESH);
- if (newob->runtime.mesh_eval == me_eval) {
- newob->runtime.mesh_eval = NULL;
- }
+ Scene *scene_eval = (Scene *)DEG_get_evaluated_id(depsgraph, &scene->id);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_MESH);
+ me_eval = BKE_mesh_copy_for_eval(me_eval, false);
BKE_mesh_nomain_to_mesh(me_eval, newob->data, newob, CD_MASK_MESH, true);
BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */
}
@@ -1981,7 +2010,7 @@ static int convert_exec(bContext *C, wmOperator *op)
for (ob1 = bmain->object.first; ob1; ob1 = ob1->id.next) {
if (ob1->data == ob->data) {
ob1->type = OB_CURVE;
- DEG_id_tag_update(&ob1->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob1->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
}
}
}
@@ -2088,7 +2117,7 @@ static int convert_exec(bContext *C, wmOperator *op)
}
if (!keep_original && (ob->flag & OB_DONE)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
((ID *)ob->data)->tag &= ~LIB_TAG_DOIT; /* flag not to convert this datablock again */
}
}
@@ -2127,7 +2156,7 @@ static int convert_exec(bContext *C, wmOperator *op)
}
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
@@ -2182,7 +2211,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer
}
else {
obn = ID_NEW_SET(ob, BKE_object_copy(bmain, ob));
- DEG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
base = BKE_view_layer_base_find(view_layer, ob);
if ((base != NULL) && (base->flag & BASE_VISIBLE)) {
@@ -2193,6 +2222,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer
BKE_collection_object_add(bmain, layer_collection->collection, obn);
}
basen = BKE_view_layer_base_find(view_layer, obn);
+ basen->local_view_bits = base->local_view_bits;
/* 1) duplis should end up in same collection as the original
* 2) Rigid Body sim participants MUST always be part of a collection...
@@ -2315,7 +2345,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer
}
break;
case OB_ARMATURE:
- DEG_id_tag_update(&obn->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obn->id, ID_RECALC_GEOMETRY);
if (obn->pose)
BKE_pose_tag_recalc(bmain, obn->pose);
if (dupflag & USER_DUP_ARM) {
@@ -2442,7 +2472,7 @@ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, ViewLayer *view_layer,
/* DAG_relations_tag_update(bmain); */ /* caller must do */
if (ob->data != NULL) {
- DEG_id_tag_update_ex(bmain, (ID *)ob->data, DEG_TAG_EDITORS_UPDATE);
+ DEG_id_tag_update_ex(bmain, (ID *)ob->data, ID_RECALC_EDITORS);
}
BKE_main_id_clear_newpoins(bmain);
@@ -2487,7 +2517,7 @@ static int duplicate_exec(bContext *C, wmOperator *op)
BKE_main_id_clear_newpoins(bmain);
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
@@ -2569,7 +2599,7 @@ static int add_named_exec(bContext *C, wmOperator *op)
/* TODO(sergey): Only update relations for the current scene. */
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 2f879937f7a..90bb853e9d4 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -856,7 +856,6 @@ static int bake(
/* populate highpoly array */
for (link = selected_objects->first; link; link = link->next) {
- TriangulateModifierData *tmd;
Object *ob_iter = link->ptr.data;
if (ob_iter == ob_low)
@@ -866,14 +865,6 @@ static int bake(
highpoly[i].ob = ob_iter;
highpoly[i].restrict_flag = ob_iter->restrictflag;
- /* triangulating so BVH returns the primitive_id that will be used for rendering */
- highpoly[i].tri_mod = ED_object_modifier_add(
- reports, bmain, scene, highpoly[i].ob,
- "TmpTriangulate", eModifierType_Triangulate);
- tmd = (TriangulateModifierData *)highpoly[i].tri_mod;
- tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED;
- tmd->ngon_method = MOD_TRIANGULATE_NGON_EARCLIP;
-
highpoly[i].me = bake_mesh_new_from_object(depsgraph, bmain, scene, highpoly[i].ob);
highpoly[i].ob->restrictflag &= ~OB_RESTRICT_RENDER;
@@ -1091,9 +1082,6 @@ cleanup:
for (i = 0; i < tot_highpoly; i++) {
highpoly[i].ob->restrictflag = highpoly[i].restrict_flag;
- if (highpoly[i].tri_mod)
- ED_object_modifier_remove(reports, bmain, highpoly[i].ob, highpoly[i].tri_mod);
-
if (highpoly[i].me)
BKE_libblock_free(bmain, highpoly[i].me);
}
@@ -1358,7 +1346,9 @@ static void bake_set_props(wmOperator *op, Scene *scene)
prop = RNA_struct_find_property(op->ptr, "cage_object");
if (!RNA_property_is_set(op->ptr, prop)) {
- RNA_property_string_set(op->ptr, prop, bake->cage);
+ if (bake->cage_object) {
+ RNA_property_string_set(op->ptr, prop, bake->cage_object->id.name + 2);
+ }
}
prop = RNA_struct_find_property(op->ptr, "normal_space");
diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.c
index 57f1ad7dea1..5e1773bf3c2 100644
--- a/source/blender/editors/object/object_collection.c
+++ b/source/blender/editors/object/object_collection.c
@@ -154,7 +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);
+ DEG_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
updated = true;
}
else {
@@ -225,7 +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);
+ DEG_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
ok = 1;
}
CTX_DATA_END;
@@ -318,7 +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);
+ DEG_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
updated = true;
}
CTX_DATA_END;
@@ -370,7 +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);
+ DEG_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
}
CTX_DATA_END;
@@ -411,7 +411,7 @@ static int collection_add_exec(bContext *C, wmOperator *UNUSED(op))
id_fake_user_set(&collection->id);
BKE_collection_object_add(bmain, collection, ob);
- DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -463,7 +463,7 @@ static int collection_link_exec(bContext *C, wmOperator *op)
BKE_collection_object_add(bmain, collection, ob);
- DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -506,7 +506,7 @@ static int collection_remove_exec(bContext *C, wmOperator *UNUSED(op))
BKE_collection_object_remove(bmain, collection, ob, false);
- DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -564,6 +564,7 @@ void OBJECT_OT_collection_unlink(wmOperatorType *ot)
static int select_grouped_exec(bContext *C, wmOperator *UNUSED(op)) /* Select objects in the same collection as the active */
{
+ Scene *scene = CTX_data_scene(C);
Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data;
if (!collection)
@@ -579,7 +580,8 @@ static int select_grouped_exec(bContext *C, wmOperator *UNUSED(op)) /* Select o
}
CTX_DATA_END;
- WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
+ WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 4aedd6a55d4..93ff94edc75 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1228,9 +1228,9 @@ void ED_object_constraint_update(Main *bmain, Object *ob)
object_test_constraints(bmain, ob);
if (ob->type == OB_ARMATURE)
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
else
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
static void object_pose_tag_update(Main *bmain, Object *ob)
@@ -1267,14 +1267,14 @@ void ED_object_constraint_tag_update(Main *bmain, Object *ob, bConstraint *con)
}
if (ob->type == OB_ARMATURE)
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
else
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
/* Do Copy-on-Write tag here too, otherwise constraint
* influence/mute buttons in UI have no effect
*/
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
void ED_object_constraint_dependency_tag_update(Main *bmain, Object *ob, bConstraint *con)
@@ -1449,7 +1449,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_SPLINEIK | PCHAN_HAS_CONST);
if (prev_ob != ob) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob);
prev_ob = ob;
}
@@ -1485,7 +1485,7 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
BKE_constraints_free(&ob->constraints);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
CTX_DATA_END;
@@ -1536,7 +1536,7 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
if (prev_ob != ob) {
BKE_pose_tag_recalc(bmain, ob->pose);
- DEG_id_tag_update((ID *)ob, OB_RECALC_DATA);
+ DEG_id_tag_update((ID *)ob, ID_RECALC_GEOMETRY);
prev_ob = ob;
}
}
@@ -1577,7 +1577,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op))
/* if we're not handling the object we're copying from, copy all constraints over */
if (obact != ob) {
BKE_constraints_copy(&ob->constraints, &obact->constraints, true);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
CTX_DATA_END;
@@ -1856,10 +1856,10 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
* XXX Temp hack until new depsgraph hopefully solves this. */
ob->adt->recalc |= ADT_RECALC_ANIM;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
}
else
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, ob);
@@ -2100,7 +2100,7 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op))
prev_ob = ob;
/* Refresh depsgraph. */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
/* Note, notifier might evolve. */
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob);
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index 7b65d4c4f47..ad47e07b2e9 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -47,6 +47,7 @@
#include "BKE_report.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -133,13 +134,15 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(
}
else if (data_type == DT_TYPE_UV) {
Object *ob_src = CTX_data_active_object(C);
- Scene *scene = CTX_data_scene(C);
if (ob_src) {
Mesh *me_eval;
int num_data, i;
- me_eval = mesh_get_eval_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPUV);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
+
+ me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, CD_MASK_BAREMESH | CD_MLOOPUV);
num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPUV);
RNA_enum_item_add_separator(&item, &totitem);
@@ -153,13 +156,15 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(
}
else if (data_type == DT_TYPE_VCOL) {
Object *ob_src = CTX_data_active_object(C);
- Scene *scene = CTX_data_scene(C);
if (ob_src) {
Mesh *me_eval;
int num_data, i;
- me_eval = mesh_get_eval_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPCOL);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
+
+ me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, CD_MASK_BAREMESH | CD_MLOOPCOL);
num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPCOL);
RNA_enum_item_add_separator(&item, &totitem);
@@ -338,9 +343,9 @@ static bool data_transfer_exec_is_object_valid(
static int data_transfer_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
Object *ob_src = ED_object_active_context(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
ListBase ctx_objects;
CollectionPointerLink *ctx_ob_dst;
@@ -404,12 +409,15 @@ static int data_transfer_exec(bContext *C, wmOperator *op)
}
if (data_transfer_exec_is_object_valid(op, ob_src, ob_dst, reverse_transfer)) {
+ Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
+
if (space_transform) {
- BLI_SPACE_TRANSFORM_SETUP(space_transform, ob_dst, ob_src);
+ Object *ob_dst_eval = DEG_get_evaluated_object(depsgraph, ob_dst);
+ BLI_SPACE_TRANSFORM_SETUP(space_transform, ob_dst_eval, ob_src_eval);
}
if (BKE_object_data_transfer_mesh(
- depsgraph, scene, ob_src, ob_dst, data_type, use_create,
+ depsgraph, scene_eval, ob_src_eval, ob_dst, data_type, use_create,
map_vert_mode, map_edge_mode, map_loop_mode, map_poly_mode,
space_transform, use_auto_transform,
max_distance, ray_radius, islands_precision,
@@ -420,7 +428,7 @@ static int data_transfer_exec(bContext *C, wmOperator *op)
}
}
- DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
if (reverse_transfer) {
SWAP(Object *, ob_src, ob_dst);
@@ -605,9 +613,9 @@ static bool datalayout_transfer_poll(bContext *C)
static int datalayout_transfer_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
Object *ob_act = ED_object_active_context(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
DataTransferModifierData *dtmd;
dtmd = (DataTransferModifierData *)edit_modifier_property_get(op, ob_act, eModifierType_DataTransfer);
@@ -624,10 +632,12 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BKE_object_data_transfer_layout(depsgraph, scene, ob_src, ob_dst, dtmd->data_types, use_delete,
+ Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
+
+ BKE_object_data_transfer_layout(depsgraph, scene_eval, ob_src_eval, ob_dst, dtmd->data_types, use_delete,
dtmd->layers_select_src, dtmd->layers_select_dst);
- DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
}
else {
Object *ob_src = ob_act;
@@ -649,16 +659,18 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
layers_select_dst[fromto_idx] = layers_dst;
}
+ Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
+
data_transfer_exec_preprocess_objects(C, op, ob_src, &ctx_objects, false);
for (ctx_ob_dst = ctx_objects.first; ctx_ob_dst; ctx_ob_dst = ctx_ob_dst->next) {
Object *ob_dst = ctx_ob_dst->ptr.data;
if (data_transfer_exec_is_object_valid(op, ob_src, ob_dst, false)) {
- BKE_object_data_transfer_layout(depsgraph, scene, ob_src, ob_dst, data_type, use_delete,
+ BKE_object_data_transfer_layout(depsgraph, scene_eval, ob_src_eval, ob_dst, data_type, use_delete,
layers_select_src, layers_select_dst);
}
- DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
}
BLI_freelistN(&ctx_objects);
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index c376b0cf78f..efbea1ee30e 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -182,7 +182,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op)
}
BKE_layer_collection_sync(scene, view_layer);
- DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
@@ -202,7 +202,7 @@ void OBJECT_OT_hide_view_clear(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- PropertyRNA *prop = RNA_def_boolean(ot->srna, "select", false, "Select", "");
+ PropertyRNA *prop = RNA_def_boolean(ot->srna, "select", true, "Select", "");
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
}
@@ -248,7 +248,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
}
BKE_layer_collection_sync(scene, view_layer);
- DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
@@ -295,7 +295,7 @@ static int object_hide_collection_exec(bContext *C, wmOperator *op)
BKE_layer_collection_set_visible(scene, view_layer, lc, extend);
- DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
@@ -546,7 +546,7 @@ bool ED_object_editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int f
BKE_ptcache_object_reset(scene, obedit, PTCACHE_RESET_OUTDATED);
/* also flush ob recalc, doesn't take much overhead, but used for particles */
- DEG_id_tag_update(&obedit->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
@@ -611,7 +611,7 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag
ok = 1;
ED_armature_to_edit(ob->data);
/* to ensure all goes in restposition and without striding */
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* XXX: should this be OB_RECALC_DATA? */
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); /* XXX: should this be ID_RECALC_GEOMETRY? */
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_ARMATURE, scene);
}
@@ -641,7 +641,7 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag
}
if (ok) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else {
if ((flag & EM_NO_CONTEXT) == 0) {
@@ -682,6 +682,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
Object *obact = OBACT(view_layer);
if (!is_mode_set) {
@@ -693,7 +694,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
if (!is_mode_set) {
ED_object_editmode_enter(C, EM_WAITCURSOR);
if (obact->mode & mode_flag) {
- FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob)
+ FOREACH_SELECTED_OBJECT_BEGIN(view_layer, v3d, ob)
{
if ((ob != obact) && (ob->type == obact->type)) {
ED_object_editmode_enter_ex(bmain, scene, ob, EM_WAITCURSOR | EM_NO_CONTEXT);
@@ -805,7 +806,8 @@ static int posemode_exec(bContext *C, wmOperator *op)
if (ok) {
struct Main *bmain = CTX_data_main(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob)
+ View3D *v3d = CTX_wm_view3d(C);
+ FOREACH_SELECTED_OBJECT_BEGIN(view_layer, v3d, ob)
{
if ((ob != obact) &&
(ob->type == OB_ARMATURE) &&
@@ -919,7 +921,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *
for (base = FIRSTBASE(view_layer); base; base = base->next) {
if (base != BASACT(view_layer)) {
if (TESTBASELIB(v3d, base)) {
- DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY);
if (event == 1) { /* loc */
copy_v3_v3(base->object->loc, ob->loc);
@@ -998,7 +1000,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *
BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family));
- DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY);
}
}
else if (event == 19) { /* bevel settings */
@@ -1014,7 +1016,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *
cu1->ext1 = cu->ext1;
cu1->ext2 = cu->ext2;
- DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY);
}
}
else if (event == 25) { /* curve resolution */
@@ -1033,7 +1035,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *
nu = nu->next;
}
- DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY);
}
}
else if (event == 21) {
@@ -1049,14 +1051,14 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *
}
modifier_copyData(md, tmd);
- DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY);
}
}
}
else if (event == 22) {
/* Copy the constraint channels over */
BKE_constraints_copy(&base->object->constraints, &ob->constraints, true);
- DEG_id_tag_update(&base->object->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&base->object->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
}
else if (event == 23) {
@@ -1067,7 +1069,7 @@ static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *
BLI_addhead(&base->object->modifiers, modifier_new(eModifierType_Softbody));
}
- DEG_id_tag_update(&base->object->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&base->object->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
}
else if (event == 26) {
@@ -1195,7 +1197,7 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_active_object(C);
if (ob->pd == NULL)
- ob->pd = object_add_collision_fields(PFIELD_FORCE);
+ ob->pd = BKE_partdeflect_new(PFIELD_FORCE);
else if (ob->pd->forcefield == 0)
ob->pd->forcefield = PFIELD_FORCE;
else
@@ -1262,7 +1264,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene, bool current_frame_
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
{
if (ob->mpath) {
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
}
CTX_DATA_END;
@@ -1397,7 +1399,7 @@ static void object_clear_mpath(Object *ob)
ob->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
/* tag object for copy on write - so removed paths don't still show */
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
}
@@ -1480,7 +1482,7 @@ static int object_update_paths_range_exec(bContext *C, wmOperator *UNUSED(op))
ob->avs.path_ef = PEFRA;
/* tag for updates */
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
}
CTX_DATA_END;
@@ -1527,7 +1529,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
BKE_mesh_smooth_flag_set(ob, !clear);
BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
done = true;
@@ -1540,7 +1542,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
else nu->flag &= ~ME_SMOOTH;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
done = true;
@@ -1832,6 +1834,12 @@ static bool move_to_collection_poll(bContext *C)
return ED_outliner_collections_editor_poll(C);
}
else {
+ View3D *v3d = CTX_wm_view3d(C);
+
+ if (v3d && v3d->localvd) {
+ return false;
+ }
+
return ED_operator_object_active_editable(C);
}
}
@@ -1907,7 +1915,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
collection->id.name + 2);
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
diff --git a/source/blender/editors/object/object_facemap_ops.c b/source/blender/editors/object/object_facemap_ops.c
index ab710b21817..a111a73a42c 100644
--- a/source/blender/editors/object/object_facemap_ops.c
+++ b/source/blender/editors/object/object_facemap_ops.c
@@ -190,7 +190,7 @@ static int face_map_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
BKE_object_facemap_add(ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -219,7 +219,7 @@ static int face_map_remove_exec(bContext *C, wmOperator *UNUSED(op))
if (fmap) {
BKE_object_facemap_remove(ob, fmap);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
@@ -267,7 +267,7 @@ static int face_map_assign_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
@@ -316,7 +316,7 @@ static int face_map_remove_from_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
@@ -370,7 +370,7 @@ static int face_map_select_exec(bContext *C, wmOperator *UNUSED(op))
if (fmap) {
fmap_select(ob, true);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
@@ -400,7 +400,7 @@ static int face_map_deselect_exec(bContext *C, wmOperator *UNUSED(op))
if (fmap) {
fmap_select(ob, false);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
@@ -470,7 +470,7 @@ static int face_map_move_exec(bContext *C, wmOperator *op)
ob->actfmap = pos2 + 1;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.c
index d67b79375e2..1523cafa928 100644
--- a/source/blender/editors/object/object_gpencil_modifier.c
+++ b/source/blender/editors/object/object_gpencil_modifier.c
@@ -102,9 +102,9 @@ GpencilModifierData *ED_object_gpencil_modifier_add(
bGPdata *gpd = ob->data;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
return new_md;
@@ -158,7 +158,7 @@ bool ED_object_gpencil_modifier_remove(ReportList *reports, Main *bmain, Object
return 0;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
return 1;
@@ -182,7 +182,7 @@ void ED_object_gpencil_modifier_clear(Main *bmain, Object *ob)
md = next_md;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
}
@@ -225,7 +225,7 @@ static int gpencil_modifier_apply_obdata(
return 0;
}
mti->bakeModifier(bmain, depsgraph, md, ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else {
BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type");
@@ -488,7 +488,7 @@ static int gpencil_modifier_move_up_exec(bContext *C, wmOperator *op)
if (!md || !ED_object_gpencil_modifier_move_up(op->reports, ob, md))
return OPERATOR_CANCELLED;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -527,7 +527,7 @@ static int gpencil_modifier_move_down_exec(bContext *C, wmOperator *op)
if (!md || !ED_object_gpencil_modifier_move_down(op->reports, ob, md))
return OPERATOR_CANCELLED;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -570,7 +570,7 @@ static int gpencil_modifier_apply_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -617,7 +617,7 @@ static int gpencil_modifier_copy_exec(bContext *C, wmOperator *op)
if (!md || !ED_object_gpencil_modifier_copy(op->reports, ob, md))
return OPERATOR_CANCELLED;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index ff9cc65180b..995f62f3cd8 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -617,7 +617,7 @@ static int object_add_hook_newob_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
if (add_hook_object(C, bmain, scene, view_layer, obedit, NULL, OBJECT_ADDHOOK_NEWOB, op->reports)) {
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit);
return OPERATOR_FINISHED;
@@ -659,7 +659,7 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op)
BLI_remlink(&ob->modifiers, (ModifierData *)hmd);
modifier_free((ModifierData *)hmd);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -733,7 +733,7 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op)
BKE_object_modifier_hook_reset(ob, hmd);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -783,7 +783,7 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op)
sub_v3_v3v3(hmd->cent, scene->cursor.location, ob->obmat[3]);
mul_m3_v3(imat, hmd->cent);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -842,7 +842,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op)
hmd->indexar = indexar;
hmd->totindex = tot;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -888,7 +888,7 @@ static int object_hook_select_exec(bContext *C, wmOperator *op)
/* select functionality */
object_hook_select(ob, hmd);
- DEG_id_tag_update(ob->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c
index ee075a94d29..4c625a4d33c 100644
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@ -35,10 +35,11 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
+#include "BKE_layer.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_report.h"
-#include "BKE_layer.h"
+#include "BKE_scene.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -161,7 +162,16 @@ void ED_object_mode_toggle(bContext *C, eObjectMode mode)
const char *opstring = object_mode_op_string(mode);
if (opstring) {
- WM_operator_name_call(C, opstring, WM_OP_EXEC_REGION_WIN, NULL);
+ wmOperatorType *ot = WM_operatortype_find(opstring, false);
+ if (ot->flag & OPTYPE_USE_EVAL_DATA) {
+ /* We need to force refresh of depsgraph after undo step,
+ * redoing the operator *may* rely on some valid evaluated data. */
+ struct Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer);
+ }
+ WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_REGION_WIN, NULL);
}
}
}
@@ -205,7 +215,8 @@ void ED_object_mode_exit(bContext *C)
bool ED_object_mode_generic_enter(
struct bContext *C, eObjectMode object_mode)
{
- Object *ob = CTX_data_active_object(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob = OBACT(view_layer);
if (ob == NULL) {
return (object_mode == OB_MODE_OBJECT);
}
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 45e0ea62258..cf8549a9fcc 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -131,7 +131,7 @@ static void object_force_modifier_update_for_bind(Depsgraph *depsgraph, Scene *s
BKE_displist_make_mball(depsgraph, scene, ob);
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
- BKE_displist_make_curveTypes(depsgraph, scene, ob, 0);
+ BKE_displist_make_curveTypes(depsgraph, scene, ob, false, false);
}
}
@@ -191,7 +191,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
}
else if (type == eModifierType_Collision) {
if (!ob->pd)
- ob->pd = object_add_collision_fields(0);
+ ob->pd = BKE_partdeflect_new(0);
ob->pd->deflect = 1;
}
@@ -213,7 +213,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
}
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
return new_md;
@@ -296,7 +296,7 @@ bool ED_object_multires_update_totlevels_cb(Object *ob, void *totlevel_v)
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Multires) {
multires_set_tot_level(ob, (MultiresModifierData *)md, totlevel);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
return false;
@@ -381,7 +381,7 @@ bool ED_object_modifier_remove(ReportList *reports, Main *bmain, Object *ob, Mod
return 0;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
return 1;
@@ -405,7 +405,7 @@ void ED_object_modifier_clear(Main *bmain, Object *ob)
md = next_md;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
}
@@ -681,7 +681,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen
MEM_freeN(vertexCos);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else {
BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type");
@@ -980,7 +980,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op)
if (!md || !ED_object_modifier_move_up(op->reports, ob, md))
return OPERATOR_CANCELLED;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -1019,7 +1019,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op)
if (!md || !ED_object_modifier_move_down(op->reports, ob, md))
return OPERATOR_CANCELLED;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -1063,7 +1063,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -1113,7 +1113,7 @@ static int modifier_convert_exec(bContext *C, wmOperator *op)
if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, view_layer, ob, md))
return OPERATOR_CANCELLED;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -1152,7 +1152,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
if (!md || !ED_object_modifier_copy(op->reports, ob, md))
return OPERATOR_CANCELLED;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -1248,7 +1248,7 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
ED_object_multires_update_totlevels_cb,
&mmd->totlvl);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
if (ob->mode & OB_MODE_SCULPT) {
@@ -1317,7 +1317,7 @@ static int multires_reshape_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -1467,7 +1467,7 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op)
multiresModifier_base_apply(mmd, scene, ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -1573,7 +1573,7 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op))
BLI_gset_free(visited, NULL);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -1628,7 +1628,7 @@ static int skin_loose_mark_clear_exec(bContext *C, wmOperator *op)
}
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -1678,7 +1678,7 @@ static int skin_radii_equalize_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -1760,7 +1760,10 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
int *emap_mem;
int v;
- me_eval_deform = mesh_get_eval_deform(depsgraph, scene, skin_ob, CD_MASK_BAREMESH);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, skin_ob);
+
+ me_eval_deform = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
mvert = me_eval_deform->mvert;
/* add vertex weights to original mesh */
@@ -1853,7 +1856,7 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op)
arm_md->object = arm_ob;
arm_md->deformflag = ARM_DEF_VGROUP | ARM_DEF_QUATERNION;
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1920,7 +1923,7 @@ static int correctivesmooth_bind_exec(bContext *C, wmOperator *op)
csmd->bind_coords_num = (unsigned int)-1;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -1960,52 +1963,41 @@ static bool meshdeform_poll(bContext *C)
static int meshdeform_bind_exec(bContext *C, wmOperator *op)
{
- Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_MeshDeform);
- if (!mmd)
+ if (mmd == NULL) {
return OPERATOR_CANCELLED;
+ }
- if (mmd->bindcagecos) {
- MEM_freeN(mmd->bindcagecos);
- if (mmd->dyngrid) MEM_freeN(mmd->dyngrid);
- if (mmd->dyninfluences) MEM_freeN(mmd->dyninfluences);
- if (mmd->bindinfluences) MEM_freeN(mmd->bindinfluences);
- if (mmd->bindoffsets) MEM_freeN(mmd->bindoffsets);
- if (mmd->dynverts) MEM_freeN(mmd->dynverts);
- if (mmd->bindweights) MEM_freeN(mmd->bindweights); /* deprecated */
- if (mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */
-
- mmd->bindcagecos = NULL;
- mmd->dyngrid = NULL;
- mmd->dyninfluences = NULL;
- mmd->bindinfluences = NULL;
- mmd->bindoffsets = NULL;
- mmd->dynverts = NULL;
- mmd->bindweights = NULL; /* deprecated */
- mmd->bindcos = NULL; /* deprecated */
+ if (mmd->bindcagecos != NULL) {
+ MEM_SAFE_FREE(mmd->bindcagecos);
+ MEM_SAFE_FREE(mmd->dyngrid);
+ MEM_SAFE_FREE(mmd->dyninfluences);
+ MEM_SAFE_FREE(mmd->bindinfluences);
+ MEM_SAFE_FREE(mmd->bindoffsets);
+ MEM_SAFE_FREE(mmd->dynverts);
+ MEM_SAFE_FREE(mmd->bindweights); /* Deprecated */
+ MEM_SAFE_FREE(mmd->bindcos); /* Deprecated */
mmd->totvert = 0;
mmd->totcagevert = 0;
mmd->totinfluence = 0;
}
else {
- int mode = mmd->modifier.mode;
- mmd->bindfunc = ED_mesh_deform_bind_callback;
+ /* Force modifier to run, it will call binding routine (this has to happen outside of depsgraph evaluation). */
+ const int mode = mmd->modifier.mode;
mmd->modifier.mode |= eModifierMode_Realtime;
-
- /* Force depsgraph update, this will do binding. */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- BKE_scene_graph_update_tagged(depsgraph, bmain);
-
- mmd->bindfunc = NULL;
+ mmd->bindfunc = ED_mesh_deform_bind_callback;
+ object_force_modifier_update_for_bind(depsgraph, scene, ob);
mmd->modifier.mode = mode;
+ mmd->bindfunc = NULL;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ /* We need ID_RECALC_COPY_ON_WRITE to ensure (un)binding is flushed to CoW copies of the object... */
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
return OPERATOR_FINISHED;
}
@@ -2051,7 +2043,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op)
emd->flag |= eExplodeFlag_CalcFaces;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -2159,7 +2151,7 @@ static void oceanbake_endjob(void *customdata)
oj->omd->cached = true;
Object *ob = oj->owner;
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
static int ocean_bake_exec(bContext *C, wmOperator *op)
@@ -2181,7 +2173,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
if (free) {
BKE_ocean_free_modifier_cache(omd);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA | DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
}
@@ -2231,7 +2223,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
scene->r.cfra = cfra;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
#endif
@@ -2299,25 +2291,25 @@ static int laplaciandeform_bind_exec(bContext *C, wmOperator *op)
Depsgraph *depsgraph = CTX_data_depsgraph(C);
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_LaplacianDeform);
- if (!lmd)
+ if (lmd == NULL) {
return OPERATOR_CANCELLED;
+ }
+
if (lmd->flag & MOD_LAPLACIANDEFORM_BIND) {
- /* Un-binding happens inside the modifier when it's evaluated. */
lmd->flag &= ~MOD_LAPLACIANDEFORM_BIND;
}
else {
- int mode = lmd->modifier.mode;
-
- /* Force modifier to run, it will call binding routine. */
- lmd->modifier.mode |= eModifierMode_Realtime;
lmd->flag |= MOD_LAPLACIANDEFORM_BIND;
-
- object_force_modifier_update_for_bind(depsgraph, scene, ob);
-
- lmd->modifier.mode = mode;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ /* Force modifier to run, it will call binding routine (this has to happen outside of depsgraph evaluation). */
+ const int mode = lmd->modifier.mode;
+ lmd->modifier.mode |= eModifierMode_Realtime;
+ object_force_modifier_update_for_bind(depsgraph, scene, ob);
+ lmd->modifier.mode = mode;
+
+ /* We need ID_RECALC_COPY_ON_WRITE to ensure (un)binding is flushed to CoW copies of the object... */
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
}
@@ -2361,25 +2353,25 @@ static int surfacedeform_bind_exec(bContext *C, wmOperator *op)
Depsgraph *depsgraph = CTX_data_depsgraph(C);
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_SurfaceDeform);
- if (!smd)
+ if (smd == NULL) {
return OPERATOR_CANCELLED;
+ }
+
if (smd->flags & MOD_SDEF_BIND) {
- /* Un-binding happens inside the modifier when it's evaluated. */
smd->flags &= ~MOD_SDEF_BIND;
}
else if (smd->target) {
- int mode = smd->modifier.mode;
-
- /* Force modifier to run, it will call binding routine. */
- smd->modifier.mode |= eModifierMode_Realtime;
smd->flags |= MOD_SDEF_BIND;
-
- object_force_modifier_update_for_bind(depsgraph, scene, ob);
-
- smd->modifier.mode = mode;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ /* Force modifier to run, it will call binding routine (this has to happen outside of depsgraph evaluation). */
+ const int mode = smd->modifier.mode;
+ smd->modifier.mode |= eModifierMode_Realtime;
+ object_force_modifier_update_for_bind(depsgraph, scene, ob);
+ smd->modifier.mode = mode;
+
+ /* We need ID_RECALC_COPY_ON_WRITE to ensure (un)binding is flushed to CoW copies of the object... */
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
}
@@ -2470,9 +2462,9 @@ static int fracture_refresh_exec(bContext *C, wmOperator *op)
rmd->shared->flag |= MOD_FRACTURE_REFRESH;
rmd->last_frame = 0;
- DEG_id_tag_update(&obact->id, OB_RECALC_DATA | OB_RECALC_OB | OB_RECALC_TIME |
- DEG_TAG_COPY_ON_WRITE | DEG_TAG_BASE_FLAGS_UPDATE);
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE | DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_id_tag_update(&obact->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM | ID_RECALC_ANIMATION |
+ ID_RECALC_COPY_ON_WRITE | ID_RECALC_BASE_FLAGS);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE | ID_RECALC_BASE_FLAGS);
//DEG_id_tag_update(&obact->id, OB_RECALC_DATA | DEG_TAG_COPY_ON_WRITE);
//DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
@@ -2587,7 +2579,7 @@ static int fracture_anim_bind_exec(bContext *C, wmOperator *UNUSED(op))
WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, NULL);
- DEG_id_tag_update(&obact->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obact->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obact);
return OPERATOR_FINISHED;
@@ -2653,7 +2645,7 @@ static bool do_unchecked_constraint_add(Main *bmain, Scene *scene, Object *ob, R
/* add constraint to rigid body constraint group */
do_add_group_unchecked(bmain, rbw->constraints, ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
return true;
}
@@ -2694,7 +2686,7 @@ static Object* do_convert_meshisland_to_object(Main* bmain, Shard *mi, Scene* sc
/* add object to rigid body group */
do_add_group_unchecked(bmain, rbw->group, ob_new);
- DEG_id_tag_update(&ob_new->id, OB_RECALC_ALL);
+ DEG_id_tag_update(&ob_new->id, ID_RECALC_ALL);
}
do_add_group_unchecked(bmain, g, ob_new);
@@ -2778,7 +2770,7 @@ static Object* do_convert_constraints(Main* bmain, FractureModifierData *fmd, Ri
Object* rbcon;
int iterations;
- if (con->name)
+ if (con->name[0] != '\0')
{
name = BLI_strdupn(con->name, MAX_ID_NAME);
}
diff --git a/source/blender/editors/object/object_random.c b/source/blender/editors/object/object_random.c
index 918c1c8d8e7..8291b68f15f 100644
--- a/source/blender/editors/object/object_random.c
+++ b/source/blender/editors/object/object_random.c
@@ -109,7 +109,7 @@ static int object_rand_verts_exec(bContext *C, wmOperator *op)
bool changed_multi = false;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, &objects_len, ob_mode);
+ Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len, ob_mode);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob_iter = objects[ob_index];
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 352597c603d..ead000819b7 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -236,7 +236,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
if (ob != obedit) {
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
par = obedit->parent;
if (BKE_object_parent_loop_check(par, ob)) {
@@ -373,7 +373,7 @@ static int make_proxy_exec(bContext *C, wmOperator *op)
/* depsgraph flushes are needed for the new data */
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&newob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&newob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, newob);
}
else {
@@ -529,7 +529,7 @@ void ED_object_parent_clear(Object *ob, const int type)
/* Always clear parentinv matrix for sake of consistency, see T41950. */
unit_m4(ob->parentinv);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
}
/* note, poll should check for editable scene */
@@ -620,7 +620,7 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
bPoseChannel *pchan = NULL;
const bool pararm = ELEM(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO);
- DEG_id_tag_update(&par->id, OB_RECALC_OB);
+ DEG_id_tag_update(&par->id, ID_RECALC_TRANSFORM);
/* preconditions */
if (partype == PAR_FOLLOW || partype == PAR_PATH_CONST) {
@@ -631,7 +631,7 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
if ((cu->flag & CU_PATH) == 0) {
cu->flag |= CU_PATH | CU_FOLLOW;
- BKE_displist_make_curveTypes(depsgraph, scene, par, 0); /* force creation of path data */
+ BKE_displist_make_curveTypes(depsgraph, scene, par, false, false); /* force creation of path data */
}
else {
cu->flag |= CU_FOLLOW;
@@ -717,7 +717,7 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
((CurveModifierData *)md)->object = par;
}
if (par->runtime.curve_cache && par->runtime.curve_cache->path == NULL) {
- DEG_id_tag_update(&par->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&par->id, ID_RECALC_GEOMETRY);
}
}
break;
@@ -819,7 +819,7 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
invert_m4_m4(ob->parentinv, workob.obmat);
}
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
}
@@ -1010,7 +1010,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Object *par = ED_object_active_context(C);
- DEG_id_tag_update(&par->id, OB_RECALC_OB);
+ DEG_id_tag_update(&par->id, ID_RECALC_TRANSFORM);
/* context iterator */
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
@@ -1025,7 +1025,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op)
memset(ob->loc, 0, 3 * sizeof(float));
/* set recalc flags */
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
/* set parenting type for object - object only... */
ob->parent = par;
@@ -1071,7 +1071,7 @@ static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op))
ob->partype -= PARSLOW;
BKE_object_where_is_calc(depsgraph, scene, ob);
ob->partype |= PARSLOW;
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
}
}
@@ -1109,7 +1109,7 @@ static int object_slow_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
if (ob->parent)
ob->partype |= PARSLOW;
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
CTX_DATA_END;
@@ -1163,7 +1163,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
/* remove track-object for old track */
ob->track = NULL;
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
/* also remove all tracking constraints */
for (con = ob->constraints.last; con; con = pcon) {
@@ -1237,7 +1237,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
data = con->data;
data->tar = obact;
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
/* Lamp, Camera and Speaker track differently by default */
if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) {
@@ -1260,7 +1260,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
data = con->data;
data->tar = obact;
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
/* Lamp, Camera and Speaker track differently by default */
if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) {
@@ -1284,7 +1284,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
data = con->data;
data->tar = obact;
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
/* Lamp, Camera and Speaker track differently by default */
if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) {
@@ -1462,7 +1462,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
/* if amount of material indices changed: */
test_object_materials(bmain, ob_dst, ob_dst->data);
- DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
break;
case MAKE_LINKS_MATERIALS:
/* new approach, using functions from kernel */
@@ -1470,7 +1470,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
Material *ma = give_current_material(ob_src, a + 1);
assign_material(bmain, ob_dst, ma, a + 1, BKE_MAT_ASSIGN_USERPREF); /* also works with ma==NULL */
}
- DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
break;
case MAKE_LINKS_ANIMDATA:
BKE_animdata_copy_id(bmain, (ID *)ob_dst, (ID *)ob_src, 0);
@@ -1481,7 +1481,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
}
BKE_animdata_copy_id(bmain, (ID *)ob_dst->data, (ID *)ob_src->data, 0);
}
- DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
break;
case MAKE_LINKS_GROUP:
{
@@ -1510,7 +1510,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
break;
case MAKE_LINKS_MODIFIERS:
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);
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
break;
case MAKE_LINKS_FONTS:
{
@@ -1539,7 +1539,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
cu_dst->vfontbi = cu_src->vfontbi;
id_us_plus((ID *)cu_dst->vfontbi);
- DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
break;
}
}
@@ -1769,7 +1769,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer
id = ob->data;
if (id && id->us > 1 && !ID_IS_LINKED(id)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
switch (ob->type) {
case OB_LAMP:
@@ -1802,7 +1802,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer
BKE_animdata_copy_id_action(bmain, (ID *)lat->key, false);
break;
case OB_ARMATURE:
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
ob->data = ID_NEW_SET(ob->data, BKE_armature_copy(bmain, ob->data));
BKE_pose_rebuild(bmain, ob, ob->data, true);
break;
@@ -1849,7 +1849,7 @@ static void single_object_action_users(Main *bmain, Scene *scene, ViewLayer *vie
FOREACH_OBJECT_FLAG_BEGIN(scene, view_layer, flag, ob)
{
if (!ID_IS_LINKED(ob)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
BKE_animdata_copy_id_action(bmain, &ob->id, false);
}
}
@@ -1925,7 +1925,7 @@ void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bo
}
/* Relink nodetrees' pointers that have been duplicated. */
- FOREACH_NODETREE(bmain, ntree, id)
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id)
{
/* This is a bit convoluted, we want to root ntree of copied IDs and only those,
* so we first check that old ID has been copied and that ntree is root tree of old ID,
@@ -1934,7 +1934,7 @@ void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bo
ntree = ntreeFromID(id->newid);
BKE_libblock_relink_to_newid(&ntree->id);
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
/* Relink datablock pointer properties */
{
@@ -2046,7 +2046,7 @@ static bool make_local_all__instance_indirect_unused(Main *bmain, ViewLayer *vie
base = BKE_view_layer_base_find(view_layer, ob);
base->flag |= BASE_SELECTED;
BKE_scene_object_base_flag_sync_from_base(base);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
changed = true;
}
@@ -2333,7 +2333,7 @@ static int make_override_static_exec(bContext *C, wmOperator *op)
if ((base = BKE_view_layer_base_find(view_layer, new_ob)) == NULL) {
BKE_collection_object_add_from(bmain, scene, obcollection, new_ob);
base = BKE_view_layer_base_find(view_layer, new_ob);
- DEG_id_tag_update_ex(bmain, &new_ob->id, DEG_TAG_TRANSFORM | DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_id_tag_update_ex(bmain, &new_ob->id, ID_RECALC_TRANSFORM | ID_RECALC_BASE_FLAGS);
}
/* parent to 'collection' empty */
if (new_ob->parent == NULL) {
@@ -2521,7 +2521,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent
assign_material(CTX_data_main(C), base->object, ma, 1, BKE_MAT_ASSIGN_USERPREF);
- DEG_id_tag_update(&base->object->id, OB_RECALC_OB);
+ DEG_id_tag_update(&base->object->id, ID_RECALC_TRANSFORM);
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, base->object);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 10e9b58b38b..0b032a3111a 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -126,23 +126,22 @@ void ED_object_base_select(Base *base, eObjectSelect_Mode mode)
*/
void ED_object_base_activate(bContext *C, Base *base)
{
+ Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
view_layer->basact = base;
- if (base) {
- WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, view_layer);
- }
- else {
- WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, NULL);
- }
- DEG_id_tag_update(&CTX_data_scene(C)->id, DEG_TAG_SELECT_UPDATE);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
+ DEG_id_tag_update(&CTX_data_scene(C)->id, ID_RECALC_SELECT);
}
-bool ED_object_base_deselect_all_ex(ViewLayer *view_layer, int action, bool *r_any_visible)
+bool ED_object_base_deselect_all_ex(ViewLayer *view_layer, View3D *v3d, int action, bool *r_any_visible)
{
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
- FOREACH_VISIBLE_BASE_BEGIN(view_layer, base) {
+ FOREACH_VISIBLE_BASE_BEGIN(view_layer, v3d, base) {
+ if (v3d && ((v3d->object_type_exclude_select & (1 << base->object->type)) != 0)) {
+ continue;
+ }
if ((base->flag & BASE_SELECTED) != 0) {
action = SEL_DESELECT;
break;
@@ -153,7 +152,10 @@ bool ED_object_base_deselect_all_ex(ViewLayer *view_layer, int action, bool *r_a
bool any_visible = false;
bool changed = false;
- FOREACH_VISIBLE_BASE_BEGIN(view_layer, base) {
+ FOREACH_VISIBLE_BASE_BEGIN(view_layer, v3d, base) {
+ if (v3d && ((v3d->object_type_exclude_select & (1 << base->object->type)) != 0)) {
+ continue;
+ }
switch (action) {
case SEL_SELECT:
if ((base->flag & BASE_SELECTED) == 0) {
@@ -188,9 +190,9 @@ bool ED_object_base_deselect_all_ex(ViewLayer *view_layer, int action, bool *r_a
}
-bool ED_object_base_deselect_all(ViewLayer *view_layer, int action)
+bool ED_object_base_deselect_all(ViewLayer *view_layer, View3D *v3d, int action)
{
- return ED_object_base_deselect_all_ex(view_layer, action, NULL);
+ return ED_object_base_deselect_all_ex(view_layer, v3d, action, NULL);
}
/********************** Jump To Object Utilities **********************/
@@ -258,6 +260,7 @@ bool ED_object_jump_to_object(
bContext *C, Object *ob, const bool UNUSED(reveal_hidden))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (base == NULL) {
@@ -269,7 +272,7 @@ bool ED_object_jump_to_object(
if (view_layer->basact != base || !(base->flag & BASE_SELECTED)) {
/* Select if not selected. */
if (!(base->flag & BASE_SELECTED)) {
- ED_object_base_deselect_all(view_layer, SEL_DESELECT);
+ ED_object_base_deselect_all(view_layer, v3d, SEL_DESELECT);
if (base->flag & BASE_VISIBLE) {
ED_object_base_select(base, BA_SELECT);
@@ -388,13 +391,14 @@ static bool objects_selectable_poll(bContext *C)
static int object_select_by_type_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
short obtype, extend;
obtype = RNA_enum_get(op->ptr, "type");
extend = RNA_boolean_get(op->ptr, "extend");
if (extend == 0) {
- ED_object_base_deselect_all(view_layer, SEL_DESELECT);
+ ED_object_base_deselect_all(view_layer, v3d, SEL_DESELECT);
}
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
@@ -406,7 +410,7 @@ static int object_select_by_type_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
Scene *scene = CTX_data_scene(C);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
@@ -448,7 +452,7 @@ static const EnumPropertyItem prop_select_linked_types[] = {
//{OBJECT_SELECT_LINKED_IPO, "IPO", 0, "Object IPO", ""}, // XXX deprecated animation system stuff...
{OBJECT_SELECT_LINKED_OBDATA, "OBDATA", 0, "Object Data", ""},
{OBJECT_SELECT_LINKED_MATERIAL, "MATERIAL", 0, "Material", ""},
- {OBJECT_SELECT_LINKED_DUPGROUP, "DUPGROUP", 0, "Dupligroup", ""},
+ {OBJECT_SELECT_LINKED_DUPGROUP, "DUPGROUP", 0, "Instanced Collection", ""},
{OBJECT_SELECT_LINKED_PARTICLE, "PARTICLE", 0, "Particle System", ""},
{OBJECT_SELECT_LINKED_LIBRARY, "LIBRARY", 0, "Library", ""},
{OBJECT_SELECT_LINKED_LIBRARY_OBDATA, "LIBRARY_OBDATA", 0, "Library (Object Data)", ""},
@@ -601,7 +605,7 @@ void ED_object_select_linked_by_id(bContext *C, ID *id)
if (changed) {
Scene *scene = CTX_data_scene(C);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
}
@@ -610,6 +614,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
Object *ob;
int nr = RNA_enum_get(op->ptr, "type");
bool changed = false, extend;
@@ -617,7 +622,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
extend = RNA_boolean_get(op->ptr, "extend");
if (extend == 0) {
- ED_object_base_deselect_all(view_layer, SEL_DESELECT);
+ ED_object_base_deselect_all(view_layer, v3d, SEL_DESELECT);
}
ob = OBACT(view_layer);
@@ -672,7 +677,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
if (changed) {
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
}
@@ -981,6 +986,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
Object *ob;
const int type = RNA_enum_get(op->ptr, "type");
bool changed = false, extend;
@@ -988,7 +994,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
extend = RNA_boolean_get(op->ptr, "extend");
if (extend == 0) {
- changed = ED_object_base_deselect_all(view_layer, SEL_DESELECT);
+ changed = ED_object_base_deselect_all(view_layer, v3d, SEL_DESELECT);
}
ob = OBACT(view_layer);
@@ -1040,7 +1046,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
}
if (changed) {
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
}
@@ -1073,14 +1079,15 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot)
static int object_select_all_exec(bContext *C, wmOperator *op)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
int action = RNA_enum_get(op->ptr, "action");
bool any_visible = false;
- bool changed = ED_object_base_deselect_all_ex(view_layer, action, &any_visible);
+ bool changed = ED_object_base_deselect_all_ex(view_layer, v3d, action, &any_visible);
if (changed) {
Scene *scene = CTX_data_scene(C);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
@@ -1143,7 +1150,7 @@ static int object_select_same_collection_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
Scene *scene = CTX_data_scene(C);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
@@ -1200,7 +1207,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* undo? */
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
@@ -1289,7 +1296,7 @@ static int object_select_more_exec(bContext *C, wmOperator *UNUSED(op))
if (changed) {
Scene *scene = CTX_data_scene(C);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
}
@@ -1319,7 +1326,7 @@ static int object_select_less_exec(bContext *C, wmOperator *UNUSED(op))
if (changed) {
Scene *scene = CTX_data_scene(C);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
}
@@ -1367,7 +1374,7 @@ static int object_select_random_exec(bContext *C, wmOperator *op)
BLI_rng_free(rng);
Scene *scene = CTX_data_scene(C);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_shader_fx.c b/source/blender/editors/object/object_shader_fx.c
index 47cf9f6c20b..a7505c4b2cc 100644
--- a/source/blender/editors/object/object_shader_fx.c
+++ b/source/blender/editors/object/object_shader_fx.c
@@ -99,9 +99,9 @@ ShaderFxData *ED_object_shaderfx_add(ReportList *reports, Main *bmain, Scene *UN
BKE_shaderfx_unique_name(&ob->shader_fx, new_fx);
bGPdata *gpd = ob->data;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
return new_fx;
@@ -155,7 +155,7 @@ bool ED_object_shaderfx_remove(ReportList *reports, Main *bmain, Object *ob, Sha
return 0;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
return 1;
@@ -179,7 +179,7 @@ void ED_object_shaderfx_clear(Main *bmain, Object *ob)
fx = next_fx;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
}
@@ -401,7 +401,7 @@ static int shaderfx_move_up_exec(bContext *C, wmOperator *op)
if (!fx || !ED_object_shaderfx_move_up(op->reports, ob, fx))
return OPERATOR_CANCELLED;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -440,7 +440,7 @@ static int shaderfx_move_down_exec(bContext *C, wmOperator *op)
if (!fx || !ED_object_shaderfx_move_down(op->reports, ob, fx))
return OPERATOR_CANCELLED;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index 7d16898c2a2..cafb3a50202 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -215,7 +215,7 @@ static bool object_shape_key_mirror(bContext *C, Object *ob,
*r_totmirr = totmirr;
*r_totfail = totfail;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return 1;
@@ -266,7 +266,7 @@ static int shape_key_add_exec(bContext *C, wmOperator *op)
ED_object_shape_key_add(C, ob, from_mix);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(CTX_data_main(C));
return OPERATOR_FINISHED;
@@ -304,7 +304,7 @@ static int shape_key_remove_exec(bContext *C, wmOperator *op)
}
if (changed) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -345,7 +345,7 @@ static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
for (kb = key->block.first; kb; kb = kb->next)
kb->curval = 0.0f;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return OPERATOR_FINISHED;
@@ -382,7 +382,7 @@ static int shape_key_retime_exec(bContext *C, wmOperator *UNUSED(op))
cfra += 0.1f;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return OPERATOR_FINISHED;
@@ -473,7 +473,7 @@ static int shape_key_move_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 65ac910a237..5c0bd51bcca 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -273,7 +273,7 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
ED_autokeyframe_object(C, scene, ob, ks);
/* tag for updates */
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
}
CTX_DATA_END;
@@ -379,7 +379,7 @@ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op))
mul_m3_v3(mat, v3);
}
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
CTX_DATA_END;
@@ -699,7 +699,7 @@ static int apply_objects_internal(
ignore_parent_tx(C, bmain, scene, ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
changed = true;
}
@@ -727,7 +727,7 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
BKE_object_where_is_calc(depsgraph, scene, ob);
/* update for any children that may get moved */
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
changed = true;
}
@@ -828,7 +828,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
else {
/* get the view settings if 'around' isn't set and the view is available */
View3D *v3d = CTX_wm_view3d(C);
- copy_v3_v3(cursor, ED_view3d_cursor3d_get(scene, v3d)->location);
+ copy_v3_v3(cursor, scene->cursor.location);
if (v3d && !RNA_struct_property_is_set(op->ptr, "center"))
around = scene->toolsettings->transform_pivot_point;
}
@@ -872,7 +872,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
EDBM_mesh_normals_update(em);
tot_change++;
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
}
@@ -997,7 +997,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
if (obedit) {
if (centermode == GEOMETRY_TO_ORIGIN) {
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
break;
}
@@ -1075,7 +1075,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
if (obedit) {
if (centermode == GEOMETRY_TO_ORIGIN) {
- DEG_id_tag_update(&obedit->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
}
break;
}
@@ -1143,7 +1143,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
}
}
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
tot_change++;
if (centermode == ORIGIN_TO_GEOMETRY) {
@@ -1196,7 +1196,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
(ob->transflag | ob_other->transflag) & OB_DUPLICOLLECTION)))
{
ob_other->flag |= OB_DONE;
- DEG_id_tag_update(&ob_other->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_other->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
mul_v3_mat3_m4v3(centn, ob_other->obmat, cent); /* omit translation part */
add_v3_v3(ob_other->loc, centn);
@@ -1217,7 +1217,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
for (tob = bmain->object.first; tob; tob = tob->id.next) {
if (tob->data && (((ID *)tob->data)->tag & LIB_TAG_DOIT)) {
BKE_object_batch_cache_dirty_tag(tob);
- DEG_id_tag_update(&tob->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&tob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
}
@@ -1389,7 +1389,7 @@ static void object_orient_to_location(
object_apply_rotation(ob, final_rot);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
}
}
@@ -1400,7 +1400,7 @@ static void object_transform_axis_target_cancel(bContext *C, wmOperator *op)
struct XFormAxisItem *item = xfd->object_data;
for (int i = 0; i < xfd->object_data_len; i++, item++) {
BKE_object_tfm_restore(item->ob, item->obtfm);
- DEG_id_tag_update(&item->ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&item->ob->id, ID_RECALC_TRANSFORM);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, item->ob);
}
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 1c7375c08b1..599ab0d7301 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -2621,7 +2621,7 @@ static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
BKE_object_defgroup_add(ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -2654,7 +2654,7 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op)
else
vgroup_delete_active(ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -2689,7 +2689,7 @@ static int vertex_group_assign_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
vgroup_assign_verts(ob, ts->vgroup_weight);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
return OPERATOR_FINISHED;
@@ -2762,7 +2762,7 @@ static int vertex_group_remove_from_exec(bContext *C, wmOperator *op)
}
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
return OPERATOR_FINISHED;
@@ -2801,7 +2801,7 @@ static int vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
vgroup_select_verts(ob, 1);
- DEG_id_tag_update(ob->data, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
return OPERATOR_FINISHED;
@@ -2827,7 +2827,7 @@ static int vertex_group_deselect_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
vgroup_select_verts(ob, 0);
- DEG_id_tag_update(ob->data, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(ob->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
return OPERATOR_FINISHED;
@@ -2853,7 +2853,7 @@ static int vertex_group_copy_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
vgroup_duplicate(ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
@@ -2889,7 +2889,7 @@ static int vertex_group_levels_exec(bContext *C, wmOperator *op)
vgroup_levels_subset(ob, vgroup_validmap, vgroup_tot, subset_count, offset, gain);
MEM_freeN((void *)vgroup_validmap);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -2923,7 +2923,7 @@ static int vertex_group_normalize_exec(bContext *C, wmOperator *UNUSED(op))
changed = vgroup_normalize(ob);
if (changed) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -2962,7 +2962,7 @@ static int vertex_group_normalize_all_exec(bContext *C, wmOperator *op)
MEM_freeN((void *)vgroup_validmap);
if (changed) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -3017,7 +3017,7 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op)
}
vgroup_fix(C, scene, ob, distToBe, strength, cp);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -3089,7 +3089,7 @@ static int vertex_group_invert_exec(bContext *C, wmOperator *op)
vgroup_invert_subset(ob, vgroup_validmap, vgroup_tot, subset_count, auto_assign, auto_remove);
MEM_freeN((void *)vgroup_validmap);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -3126,7 +3126,7 @@ static int vertex_group_smooth_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
@@ -3140,7 +3140,7 @@ static int vertex_group_smooth_exec(bContext *C, wmOperator *op)
vgroup_smooth_subset(ob, vgroup_validmap, vgroup_tot, subset_count, fac, repeat, fac_expand);
MEM_freeN((void *)vgroup_validmap);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
}
@@ -3184,7 +3184,7 @@ static int vertex_group_clean_exec(bContext *C, wmOperator *op)
vgroup_clean_subset(ob, vgroup_validmap, vgroup_tot, subset_count, limit, keep_single);
MEM_freeN((void *)vgroup_validmap);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -3225,7 +3225,7 @@ static int vertex_group_quantize_exec(bContext *C, wmOperator *op)
vgroup_quantize_subset(ob, vgroup_validmap, vgroup_tot, subset_count, steps);
MEM_freeN((void *)vgroup_validmap);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -3266,7 +3266,7 @@ static int vertex_group_limit_total_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports, remove_tot ? RPT_INFO : RPT_WARNING, "%d vertex weights limited", remove_tot);
if (remove_tot) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -3312,7 +3312,7 @@ static int vertex_group_mirror_exec(bContext *C, wmOperator *op)
ED_mesh_report_mirror(op, totmirr, totfail);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -3356,7 +3356,7 @@ static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *UNUSED(op))
BLI_duplicatelist(&ob_iter->defbase, &ob_active->defbase);
ob_iter->actdef = ob_active->actdef;
- DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_iter->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_iter);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob_iter->data);
@@ -3394,7 +3394,7 @@ static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op)
{
if (obact != ob) {
if (ED_vgroup_array_copy(ob, obact)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob);
changed_tot++;
}
@@ -3437,7 +3437,7 @@ static int set_active_group_exec(bContext *C, wmOperator *op)
BLI_assert(nr + 1 >= 0);
ob->actdef = nr + 1;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob);
return OPERATOR_FINISHED;
@@ -3651,7 +3651,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op)
ret = vgroup_do_remap(ob, name_array, op);
if (ret != OPERATOR_CANCELLED) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob);
}
@@ -3701,7 +3701,7 @@ static int vgroup_move_exec(bContext *C, wmOperator *op)
ret = vgroup_do_remap(ob, name_array, op);
if (ret != OPERATOR_CANCELLED) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob);
}
}
@@ -3830,7 +3830,7 @@ static int vertex_weight_paste_exec(bContext *C, wmOperator *op)
vgroup_copy_active_to_sel_single(ob, def_nr);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return OPERATOR_FINISHED;
@@ -3867,7 +3867,7 @@ static int vertex_weight_delete_exec(bContext *C, wmOperator *op)
vgroup_remove_weight(ob, def_nr);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return OPERATOR_FINISHED;
@@ -3900,7 +3900,7 @@ static int vertex_weight_set_active_exec(bContext *C, wmOperator *op)
if (wg_index != -1) {
ob->actdef = wg_index + 1;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
@@ -3937,7 +3937,7 @@ static int vertex_weight_normalize_active_vertex_exec(bContext *C, wmOperator *U
changed = vgroup_normalize_active_vertex(ob, subset_type);
if (changed) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return OPERATOR_FINISHED;
@@ -3970,7 +3970,7 @@ static int vertex_weight_copy_exec(bContext *C, wmOperator *UNUSED(op))
vgroup_copy_active_to_sel(ob, subset_type);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_warp.c b/source/blender/editors/object/object_warp.c
index 008593739ba..d28ed71c382 100644
--- a/source/blender/editors/object/object_warp.c
+++ b/source/blender/editors/object/object_warp.c
@@ -223,12 +223,8 @@ static int object_warp_verts_exec(bContext *C, wmOperator *op)
RNA_property_float_get_array(op->ptr, prop_center, center);
}
else {
- Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- const float *cursor;
-
- cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
- copy_v3_v3(center, cursor);
+ const Scene *scene = CTX_data_scene(C);
+ copy_v3_v3(center, scene->cursor.location);
RNA_property_float_set_array(op->ptr, prop_center, center);
}
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 5fb03b628b2..dc38cc76604 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -137,7 +137,7 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
}
dynamicPaint_resetPreview(canvas);
- DEG_id_tag_update(&obj_ctx->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&obj_ctx->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obj_ctx);
return OPERATOR_FINISHED;
@@ -183,7 +183,7 @@ static int type_toggle_exec(bContext *C, wmOperator *op)
}
/* update dependency */
- DEG_id_tag_update(&cObject->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&cObject->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, cObject);
diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c
index f1e0fd39014..9f85ed08244 100644
--- a/source/blender/editors/physics/particle_boids.c
+++ b/source/blender/editors/physics/particle_boids.c
@@ -77,7 +77,7 @@ static int rule_add_exec(bContext *C, wmOperator *op)
BLI_addtail(&state->rules, rule);
- DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_RESET);
+ DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
return OPERATOR_FINISHED;
}
@@ -124,7 +124,7 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
rule->flag |= BOIDRULE_CURRENT;
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_RESET);
+ DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
return OPERATOR_FINISHED;
}
@@ -160,7 +160,7 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op))
BLI_remlink(&state->rules, rule);
BLI_insertlinkbefore(&state->rules, rule->prev, rule);
- DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_RESET);
+ DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
break;
}
}
@@ -196,7 +196,7 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op))
BLI_remlink(&state->rules, rule);
BLI_insertlinkafter(&state->rules, rule->next, rule);
- DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_RESET);
+ DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
break;
}
}
@@ -280,7 +280,7 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
state->flag |= BOIDSTATE_CURRENT;
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_RESET);
+ DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
return OPERATOR_FINISHED;
}
@@ -351,7 +351,7 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op))
if (state->flag & BOIDSTATE_CURRENT && state->next) {
BLI_remlink(&boids->states, state);
BLI_insertlinkafter(&boids->states, state->next, state);
- DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_RESET);
+ DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
break;
}
}
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 09d3beadb2a..d5daaaa3812 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -1385,7 +1385,7 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob,
point->flag &= ~PEP_EDIT_RECALC;
}
- DEG_id_tag_update(&ob->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_SELECT);
}
void update_world_cos(Depsgraph *UNUSED(depsgraph), Object *ob, PTCacheEdit *edit)
@@ -2827,7 +2827,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports, RPT_INFO, "Removed %d double particles", totremoved);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
return OPERATOR_FINISHED;
@@ -2879,7 +2879,7 @@ static int weight_set_exec(bContext *C, wmOperator *op)
}
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
return OPERATOR_FINISHED;
@@ -2994,7 +2994,7 @@ static int delete_exec(bContext *C, wmOperator *op)
recalc_lengths(data.edit);
}
- DEG_id_tag_update(&data.ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&data.ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, data.ob);
return OPERATOR_FINISHED;
@@ -3180,7 +3180,7 @@ static int mirror_exec(bContext *C, wmOperator *UNUSED(op))
update_world_cos(CTX_data_depsgraph(C), ob, edit);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
return OPERATOR_FINISHED;
}
@@ -3564,7 +3564,7 @@ static void intersect_dm_quad_weights(const float v1[3], const float v2[3], cons
}
/** Check intersection with an evaluated mesh. */
-static int particle_intersect_mesh(Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *mesh,
+static int particle_intersect_mesh(Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob, Mesh *mesh,
float *vert_cos,
const float co1[3], const float co2[3],
float *min_d, int *min_face, float *min_w,
@@ -3580,9 +3580,12 @@ static int particle_intersect_mesh(Depsgraph *depsgraph, Scene *scene, Object *o
if (mesh == NULL) {
psys_disable_all(ob);
- mesh = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+
+ mesh = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
if (mesh == NULL) {
- mesh = mesh_get_eval_deform(depsgraph, scene, ob, CD_MASK_BAREMESH);
+ mesh = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
}
psys_enable_all(ob);
@@ -4297,7 +4300,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
update_world_cos(depsgraph, ob, edit);
psys_free_path_cache(NULL, edit);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else {
PE_update_object(depsgraph, scene, ob, 1);
@@ -4307,10 +4310,10 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
if (edit->psys) {
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
BKE_particle_batch_cache_dirty_tag(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
- DEG_id_tag_update(&ob->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_SELECT);
}
else {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
}
@@ -4567,7 +4570,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
if (removed) {
update_world_cos(depsgraph, ob, edit);
psys_free_path_cache(NULL, edit);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else {
PE_update_object(data.depsgraph, scene, ob, 1);
@@ -4576,10 +4579,10 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
if (edit->psys) {
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
BKE_particle_batch_cache_dirty_tag(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
- DEG_id_tag_update(&ob->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_SELECT);
}
else {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
}
@@ -4851,7 +4854,7 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA | DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode);
@@ -4890,21 +4893,21 @@ static int clear_edited_exec(bContext *C, wmOperator *UNUSED(op))
psys->edit = NULL;
psys->free_edit = NULL;
- psys->recalc |= PSYS_RECALC_RESET;
+ psys->recalc |= ID_RECALC_PSYS_RESET;
psys->flag &= ~PSYS_GLOBAL_HAIR;
psys->flag &= ~PSYS_EDITED;
psys_reset(psys, PSYS_RESET_DEPSGRAPH);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
else { /* some operation might have protected hair from editing so let's clear the flag */
- psys->recalc |= PSYS_RECALC_RESET;
+ psys->recalc |= ID_RECALC_PSYS_RESET;
psys->flag &= ~PSYS_GLOBAL_HAIR;
psys->flag &= ~PSYS_EDITED;
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
return OPERATOR_FINISHED;
@@ -5022,7 +5025,7 @@ static int unify_length_exec(bContext *C, wmOperator *UNUSED(op))
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
}
else {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
}
diff --git a/source/blender/editors/physics/particle_edit_undo.c b/source/blender/editors/physics/particle_edit_undo.c
index 56b683e1ab8..911a1ce0676 100644
--- a/source/blender/editors/physics/particle_edit_undo.c
+++ b/source/blender/editors/physics/particle_edit_undo.c
@@ -260,7 +260,7 @@ static void particle_undosys_step_decode(struct bContext *C, UndoStep *us_p, int
PTCacheEdit *edit = PE_get_current(scene, ob);
if (edit) {
undoptcache_to_editcache(&us->data, edit);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else {
BLI_assert(0);
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 228bf2c648f..4619e063dd1 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -193,7 +193,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op))
psys_check_boid_data(psys);
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, ob);
@@ -241,7 +241,7 @@ static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
BLI_addtail(&psys->targets, pt);
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, ob);
@@ -289,7 +289,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
pt->flag |= PTARGET_CURRENT;
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, ob);
@@ -328,7 +328,7 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op))
BLI_remlink(&psys->targets, pt);
BLI_insertlinkbefore(&psys->targets, pt->prev, pt);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, ob);
break;
}
@@ -366,7 +366,7 @@ static int target_move_down_exec(bContext *C, wmOperator *UNUSED(op))
BLI_remlink(&psys->targets, pt);
BLI_insertlinkafter(&psys->targets, pt->next, pt);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, ob);
break;
}
@@ -398,7 +398,7 @@ static int dupliob_refresh_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
psys_check_group_weights(psys->part);
- DEG_id_tag_update(&psys->part->id, OB_RECALC_DATA | PSYS_RECALC_REDO);
+ DEG_id_tag_update(&psys->part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
return OPERATOR_FINISHED;
@@ -434,7 +434,7 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op))
BLI_remlink(&part->dupliweights, dw);
BLI_insertlinkbefore(&part->dupliweights, dw->prev, dw);
- DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO);
+ DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
break;
}
@@ -474,7 +474,7 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
dw->flag |= PART_DUPLIW_CURRENT;
BLI_addhead(&part->dupliweights, dw);
- DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO);
+ DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
break;
}
@@ -521,7 +521,7 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
if (dw)
dw->flag |= PART_DUPLIW_CURRENT;
- DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO);
+ DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
return OPERATOR_FINISHED;
@@ -559,7 +559,7 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op))
BLI_remlink(&part->dupliweights, dw);
BLI_insertlinkafter(&part->dupliweights, dw->next, dw);
- DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO);
+ DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
break;
}
@@ -654,7 +654,7 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op)
disconnect_hair(depsgraph, scene, ob, psys);
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, ob);
return OPERATOR_FINISHED;
@@ -920,7 +920,7 @@ static int connect_hair_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, ob);
return OPERATOR_FINISHED;
@@ -1156,13 +1156,13 @@ static bool copy_particle_systems_to_object(const bContext *C,
}
/* tag for recalc */
-// psys->recalc |= PSYS_RECALC_RESET;
+// psys->recalc |= ID_RECALC_PSYS_RESET;
}
#undef PSYS_FROM_FIRST
#undef PSYS_FROM_NEXT
- DEG_id_tag_update(&ob_to->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_to->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, ob_to);
return true;
}
diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c
index a98faf82c3b..9583e754f29 100644
--- a/source/blender/editors/physics/rigidbody_constraint.c
+++ b/source/blender/editors/physics/rigidbody_constraint.c
@@ -95,8 +95,8 @@ bool ED_rigidbody_constraint_add(Main *bmain, Scene *scene, Object *ob, int type
BKE_collection_object_add(bmain, rbw->constraints, ob);
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);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
+ DEG_id_tag_update(&rbw->constraints->id, ID_RECALC_COPY_ON_WRITE);
return true;
}
@@ -108,11 +108,11 @@ void ED_rigidbody_constraint_remove(Main *bmain, Scene *scene, Object *ob)
BKE_rigidbody_remove_constraint(scene, ob);
if (rbw) {
BKE_collection_object_remove(bmain, rbw->constraints, ob, false);
- DEG_id_tag_update(&rbw->constraints->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&rbw->constraints->id, ID_RECALC_COPY_ON_WRITE);
}
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
/* ********************************************** */
diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c
index a36b430d8ac..c8533c2127b 100644
--- a/source/blender/editors/physics/rigidbody_object.c
+++ b/source/blender/editors/physics/rigidbody_object.c
@@ -135,8 +135,8 @@ bool ED_rigidbody_object_add(Main *bmain, Scene *scene, Object *ob, int type, Re
BKE_collection_object_add(bmain, rbw->group, ob);
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);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
+ DEG_id_tag_update(&rbw->group->id, ID_RECALC_COPY_ON_WRITE);
return true;
}
@@ -146,7 +146,7 @@ void ED_rigidbody_object_remove(Main *bmain, Scene *scene, Object *ob)
BKE_rigidbody_remove_object(bmain, scene, ob);
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
/* ********************************************** */
@@ -363,7 +363,7 @@ static int rigidbody_objects_shape_change_exec(bContext *C, wmOperator *op)
RNA_pointer_create(&ob->id, &RNA_RigidBodyObject, ob->rigidbody_object, &ptr);
RNA_enum_set(&ptr, "collision_shape", shape);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
changed = true;
}
@@ -560,7 +560,7 @@ static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
RNA_pointer_create(&ob->id, &RNA_RigidBodyObject, ob->rigidbody_object, &ptr);
RNA_float_set(&ptr, "mass", mass);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
changed = true;
}
diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c
index 6ef3e03f8da..d6ffbb638e0 100644
--- a/source/blender/editors/physics/rigidbody_world.c
+++ b/source/blender/editors/physics/rigidbody_world.c
@@ -90,7 +90,7 @@ static int rigidbody_world_add_exec(bContext *C, wmOperator *UNUSED(op))
/* Full rebuild of DEG! */
DEG_relations_tag_update(bmain);
- DEG_id_tag_update_ex(bmain, &scene->id, DEG_TAG_TIME);
+ DEG_id_tag_update_ex(bmain, &scene->id, ID_RECALC_ANIMATION);
return OPERATOR_FINISHED;
}
@@ -128,7 +128,7 @@ static int rigidbody_world_remove_exec(bContext *C, wmOperator *op)
/* Full rebuild of DEG! */
DEG_relations_tag_update(bmain);
- DEG_id_tag_update_ex(bmain, &scene->id, DEG_TAG_TIME);
+ DEG_id_tag_update_ex(bmain, &scene->id, ID_RECALC_ANIMATION);
/* done */
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 99abb8b61c7..c4effd3a523 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -99,6 +99,35 @@
#include "render_intern.h" // own include
+/**
+ * Object list for material operations.
+ * has exception for pinned object.
+ */
+static Object **object_array_for_shading(bContext *C, uint *r_objects_len)
+{
+ ScrArea *sa = CTX_wm_area(C);
+ SpaceButs *sbuts = NULL;
+ View3D *v3d = NULL;
+ if (sa->spacetype == SPACE_BUTS) {
+ sbuts = sa->spacedata.first;
+ }
+ else if (sa->spacetype == SPACE_VIEW3D) {
+ v3d = sa->spacedata.first;
+ }
+
+ Object **objects;
+ if (sbuts && sbuts->pinid && GS(sbuts->pinid->name) == ID_OB) {
+ objects = MEM_mallocN(sizeof(*objects), __func__);
+ objects[0] = (Object *)sbuts->pinid;
+ *r_objects_len = 1;
+ }
+ else {
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, r_objects_len);
+ }
+ return objects;
+}
+
/********************** material slot operators *********************/
static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
@@ -160,7 +189,7 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob);
@@ -185,13 +214,17 @@ void OBJECT_OT_material_slot_remove(wmOperatorType *ot)
static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob = ED_object_context(C);
View3D *v3d = CTX_wm_view3d(C);
-
- if (!ob)
- return OPERATOR_CANCELLED;
-
- if (ob && ob->actcol > 0) {
+ bool changed_multi = false;
+
+ uint objects_len = 0;
+ Object **objects = object_array_for_shading(C, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob = objects[ob_index];
+ if (ob->actcol <= 0) {
+ continue;
+ }
+ bool changed = false;
if (ob->type == OB_MESH) {
BMEditMesh *em = BKE_editmesh_from_object(ob);
BMFace *efa;
@@ -199,8 +232,10 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
if (em) {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
+ changed = true;
efa->mat_nr = ob->actcol - 1;
+ }
}
}
}
@@ -211,6 +246,7 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
if (nurbs) {
for (nu = nurbs->first; nu; nu = nu->next) {
if (ED_curve_nurb_select_check(v3d, nu)) {
+ changed = true;
nu->mat_nr = ob->actcol - 1;
}
}
@@ -221,16 +257,22 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
int i, selstart, selend;
if (ef && BKE_vfont_select_get(ob, &selstart, &selend)) {
- for (i = selstart; i <= selend; i++)
+ for (i = selstart; i <= selend; i++) {
+ changed = true;
ef->textbufinfo[i].mat_nr = ob->actcol;
+ }
}
}
- }
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
+ if (changed) {
+ changed_multi = true;
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
+ }
+ }
+ MEM_freeN(objects);
- return OPERATOR_FINISHED;
+ return (changed_multi) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
void OBJECT_OT_material_slot_assign(wmOperatorType *ot)
@@ -250,67 +292,78 @@ void OBJECT_OT_material_slot_assign(wmOperatorType *ot)
static int material_slot_de_select(bContext *C, bool select)
{
- Object *ob = ED_object_context(C);
+ bool changed_multi = false;
- if (!ob)
- return OPERATOR_CANCELLED;
+ uint objects_len = 0;
+ Object **objects = object_array_for_shading(C, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob = objects[ob_index];
+ bool changed = false;
- if (ob->type == OB_MESH) {
- BMEditMesh *em = BKE_editmesh_from_object(ob);
+ if (ob->type == OB_MESH) {
+ BMEditMesh *em = BKE_editmesh_from_object(ob);
- if (em) {
- EDBM_deselect_by_material(em, ob->actcol - 1, select);
+ if (em) {
+ changed = EDBM_deselect_by_material(em, ob->actcol - 1, select);
+ }
}
- }
- else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
- ListBase *nurbs = BKE_curve_editNurbs_get((Curve *)ob->data);
- Nurb *nu;
- BPoint *bp;
- BezTriple *bezt;
- int a;
-
- if (nurbs) {
- for (nu = nurbs->first; nu; nu = nu->next) {
- if (nu->mat_nr == ob->actcol - 1) {
- if (nu->bezt) {
- a = nu->pntsu;
- bezt = nu->bezt;
- while (a--) {
- if (bezt->hide == 0) {
- if (select) {
- bezt->f1 |= SELECT;
- bezt->f2 |= SELECT;
- bezt->f3 |= SELECT;
- }
- else {
- bezt->f1 &= ~SELECT;
- bezt->f2 &= ~SELECT;
- bezt->f3 &= ~SELECT;
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ ListBase *nurbs = BKE_curve_editNurbs_get((Curve *)ob->data);
+ Nurb *nu;
+ BPoint *bp;
+ BezTriple *bezt;
+ int a;
+
+ if (nurbs) {
+ for (nu = nurbs->first; nu; nu = nu->next) {
+ if (nu->mat_nr == ob->actcol - 1) {
+ if (nu->bezt) {
+ a = nu->pntsu;
+ bezt = nu->bezt;
+ while (a--) {
+ if (bezt->hide == 0) {
+ changed = true;
+ if (select) {
+ bezt->f1 |= SELECT;
+ bezt->f2 |= SELECT;
+ bezt->f3 |= SELECT;
+ }
+ else {
+ bezt->f1 &= ~SELECT;
+ bezt->f2 &= ~SELECT;
+ bezt->f3 &= ~SELECT;
+ }
}
+ bezt++;
}
- bezt++;
}
- }
- else if (nu->bp) {
- a = nu->pntsu * nu->pntsv;
- bp = nu->bp;
- while (a--) {
- if (bp->hide == 0) {
- if (select) bp->f1 |= SELECT;
- else bp->f1 &= ~SELECT;
+ else if (nu->bp) {
+ a = nu->pntsu * nu->pntsv;
+ bp = nu->bp;
+ while (a--) {
+ if (bp->hide == 0) {
+ changed = true;
+ if (select) bp->f1 |= SELECT;
+ else bp->f1 &= ~SELECT;
+ }
+ bp++;
}
- bp++;
}
}
}
}
}
+
+ if (changed) {
+ changed_multi = true;
+ DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+ }
}
- DEG_id_tag_update(ob->data, DEG_TAG_SELECT_UPDATE);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+ MEM_freeN(objects);
- return OPERATOR_FINISHED;
+ return (changed_multi) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
static int material_slot_select_exec(bContext *C, wmOperator *UNUSED(op))
@@ -369,7 +422,7 @@ static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op))
if (ob_iter->totcol == ob->totcol) {
ob_iter->actcol = ob->actcol;
- DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob_iter->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_iter);
}
}
@@ -434,7 +487,7 @@ static int material_slot_move_exec(bContext *C, wmOperator *op)
MEM_freeN(slot_remap);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob);
@@ -846,7 +899,7 @@ static int light_cache_free_exec(bContext *C, wmOperator *UNUSED(op))
EEVEE_lightcache_info_update(&scene->eevee);
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 0a69a53e6fa..c6af7cda220 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -778,20 +778,20 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea
sa->totrct.xmin + (AZONESPOT - 1),
sa->totrct.ymin + (AZONESPOT - 1)},
/* Bottom-right. */
- {sa->totrct.xmax,
+ {sa->totrct.xmax - (AZONESPOT - 1),
sa->totrct.ymin,
- sa->totrct.xmax - (AZONESPOT - 1),
+ sa->totrct.xmax,
sa->totrct.ymin + (AZONESPOT - 1)},
/* Top-left. */
{sa->totrct.xmin,
- sa->totrct.ymax,
+ sa->totrct.ymax - (AZONESPOT - 1),
sa->totrct.xmin + (AZONESPOT - 1),
- sa->totrct.ymax - (AZONESPOT - 1)},
+ sa->totrct.ymax},
/* Top-right. */
- {sa->totrct.xmax,
- sa->totrct.ymax,
- sa->totrct.xmax - (AZONESPOT - 1),
- sa->totrct.ymax - (AZONESPOT - 1)}};
+ {sa->totrct.xmax - (AZONESPOT - 1),
+ sa->totrct.ymax - (AZONESPOT - 1),
+ sa->totrct.xmax,
+ sa->totrct.ymax}};
for (int i = 0; i < 4; i++) {
/* can't click on bottom corners on OS X, already used for resizing */
@@ -1104,21 +1104,28 @@ static void region_overlap_fix(ScrArea *sa, ARegion *ar)
bool ED_region_is_overlap(int spacetype, int regiontype)
{
if (regiontype == RGN_TYPE_HUD) {
- return 1;
+ return true;
}
if (U.uiflag2 & USER_REGION_OVERLAP) {
- if (ELEM(spacetype, SPACE_VIEW3D, SPACE_SEQ, SPACE_IMAGE)) {
- if (ELEM(regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS))
- return 1;
+ if (spacetype == SPACE_NODE) {
+ if (regiontype == RGN_TYPE_TOOLS) {
+ return true;
+ }
+ }
+ else if (ELEM(spacetype, SPACE_VIEW3D, SPACE_SEQ, SPACE_IMAGE)) {
+ if (ELEM(regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS)) {
+ return true;
+ }
if (ELEM(spacetype, SPACE_VIEW3D, SPACE_IMAGE)) {
- if (regiontype == RGN_TYPE_HEADER)
- return 1;
+ if (regiontype == RGN_TYPE_HEADER) {
+ return true;
+ }
}
}
}
- return 0;
+ return false;
}
static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, rcti *overlap_remainder, int quad)
@@ -1347,7 +1354,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, rct
if (ar->winy > 1) ar->sizey = (ar->winy + 0.5f) / UI_DPI_FAC;
/* exception for multiple overlapping regions on same spot */
- if (ar->overlap & (alignment != RGN_ALIGN_FLOAT)) {
+ if (ar->overlap && (alignment != RGN_ALIGN_FLOAT)) {
region_overlap_fix(sa, ar);
}
@@ -1632,7 +1639,18 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
region_azones_add(screen, sa, ar, ar->alignment & ~RGN_SPLIT_PREV);
}
- WM_toolsystem_refresh_screen_area(workspace, view_layer, sa);
+
+ /* Avoid re-initializing tools while resizing the window. */
+ if ((G.moving & G_TRANSFORM_WM) == 0) {
+ if ((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) {
+ WM_toolsystem_refresh_screen_area(workspace, view_layer, sa);
+ sa->flag |= AREA_FLAG_ACTIVE_TOOL_UPDATE;
+ }
+ else {
+ sa->runtime.tool = NULL;
+ sa->runtime.is_tool_set = true;
+ }
+ }
}
static void region_update_rect(ARegion *ar)
@@ -2099,7 +2117,9 @@ void ED_region_panels_layout_ex(
int scroll;
/* XXX, should use some better check? */
- bool use_category_tabs = (1 << ar->regiontype) & RGN_TYPE_HAS_CATEGORY_MASK;
+ /* For now also has hardcoded check for clip editor until it supports actual toolbar. */
+ bool use_category_tabs = ((1 << ar->regiontype) & RGN_TYPE_HAS_CATEGORY_MASK) ||
+ (ar->regiontype == RGN_TYPE_TOOLS && sa->spacetype == SPACE_CLIP);
/* offset panels for small vertical tab area */
const char *category = NULL;
const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH;
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 1cfe34c86a1..287d0ad37b9 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -93,6 +93,7 @@ const char *screen_context_dir[] = {
int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result)
{
wmWindow *win = CTX_wm_window(C);
+ View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
bScreen *sc = CTX_wm_screen(C);
ScrArea *sa = CTX_wm_area(C);
Scene *scene = WM_window_get_active_scene(win);
@@ -109,7 +110,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "visible_objects")) {
- FOREACH_VISIBLE_OBJECT_BEGIN(view_layer, ob)
+ FOREACH_VISIBLE_OBJECT_BEGIN(view_layer, v3d, ob)
{
CTX_data_id_list_add(result, &ob->id);
}
@@ -119,6 +120,15 @@ 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 (v3d && v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
+ continue;
+ }
+ if (v3d && ((v3d->object_type_exclude_viewport & (1 << base->object->type)) != 0)) {
+ continue;
+ }
+ if (v3d && ((v3d->object_type_exclude_select & (1 << base->object->type)) != 0)) {
+ continue;
+ }
if (((base->flag & BASE_VISIBLE) != 0) && ((base->flag & BASE_SELECTABLE) != 0)) {
CTX_data_id_list_add(result, &base->object->id);
}
@@ -127,7 +137,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "selected_objects")) {
- FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob)
+ FOREACH_SELECTED_OBJECT_BEGIN(view_layer, v3d, ob)
{
CTX_data_id_list_add(result, &ob->id);
}
@@ -136,7 +146,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "selected_editable_objects")) {
- FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob)
+ FOREACH_SELECTED_OBJECT_BEGIN(view_layer, v3d, ob)
{
if (0 == BKE_object_is_libdata(ob)) {
CTX_data_id_list_add(result, &ob->id);
@@ -148,7 +158,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if (CTX_data_equals(member, "editable_objects")) {
/* Visible + Editable, but not necessarily selected */
- FOREACH_VISIBLE_OBJECT_BEGIN(view_layer, ob)
+ FOREACH_VISIBLE_OBJECT_BEGIN(view_layer, v3d, ob)
{
if (0 == BKE_object_is_libdata(ob)) {
CTX_data_id_list_add(result, &ob->id);
@@ -159,7 +169,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if ( CTX_data_equals(member, "visible_bases")) {
- FOREACH_VISIBLE_BASE_BEGIN(view_layer, base)
+ FOREACH_VISIBLE_BASE_BEGIN(view_layer, v3d, base)
{
CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
}
@@ -169,6 +179,15 @@ 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 (v3d && v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
+ continue;
+ }
+ if (v3d && ((v3d->object_type_exclude_viewport & (1 << base->object->type)) != 0)) {
+ continue;
+ }
+ if (v3d && ((v3d->object_type_exclude_select & (1 << base->object->type)) != 0)) {
+ continue;
+ }
if ((base->flag & BASE_VISIBLE) && (base->flag & BASE_SELECTABLE) != 0) {
CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
}
@@ -178,6 +197,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if (CTX_data_equals(member, "selected_bases")) {
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ if (v3d && v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
+ continue;
+ }
+ if (v3d && ((v3d->object_type_exclude_viewport & (1 << base->object->type)) != 0)) {
+ continue;
+ }
if ((base->flag & BASE_SELECTED) != 0) {
CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
}
@@ -187,6 +212,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if (CTX_data_equals(member, "selected_editable_bases")) {
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ if (v3d && v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
+ continue;
+ }
+ if (v3d && ((v3d->object_type_exclude_viewport & (1 << base->object->type)) != 0)) {
+ continue;
+ }
if ((base->flag & BASE_SELECTED) != 0) {
if (0 == BKE_object_is_libdata(base->object)) {
CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
@@ -199,6 +230,12 @@ 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 (v3d && v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
+ continue;
+ }
+ if (v3d && ((v3d->object_type_exclude_viewport & (1 << base->object->type)) != 0)) {
+ continue;
+ }
if ((base->flag & BASE_VISIBLE) != 0) {
if (0 == BKE_object_is_libdata(base->object)) {
CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
@@ -215,7 +252,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
if (arm && arm->edbo) {
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint i = 0; i < objects_len; i++) {
Object *ob = objects[i];
arm = ob->data;
@@ -266,7 +303,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
if (arm && arm->edbo) {
uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint i = 0; i < objects_len; i++) {
Object *ob = objects[i];
arm = ob->data;
@@ -319,7 +356,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
} FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
}
else if (obact->mode & OB_MODE_POSE) {
- FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob_iter) {
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) {
FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN (ob_iter, pchan) {
CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan);
} FOREACH_PCHAN_VISIBLE_IN_OBJECT_END;
@@ -338,7 +375,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
} FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
}
else if (obact->mode & OB_MODE_POSE) {
- FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob_iter) {
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) {
FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob_iter, pchan) {
CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan);
} FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c
index af6f9acfa47..679bd66753b 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -25,6 +25,7 @@
#include "ED_screen.h"
#include "GPU_batch_presets.h"
+#include "GPU_extensions.h"
#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_matrix.h"
@@ -216,7 +217,7 @@ static void draw_join_shape(ScrArea *sa, char dir, unsigned int pos)
}
}
-#define CORNER_RESOLUTION 9
+#define CORNER_RESOLUTION 3
static void do_vert_pair(GPUVertBuf *vbo, uint pos, uint *vidx, int corner, int i)
{
@@ -235,7 +236,7 @@ static void do_vert_pair(GPUVertBuf *vbo, uint pos, uint *vidx, int corner, int
}
/* Line width is 20% of the entire corner size. */
- const float line_width = 0.2f;
+ const float line_width = 0.2f; /* Keep in sync with shader */
mul_v2_fl(inter, 1.0f - line_width);
mul_v2_fl(exter, 1.0f + line_width);
@@ -271,15 +272,12 @@ static GPUBatch *batch_screen_edges_get(int *corner_len)
uint pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
- GPU_vertbuf_data_alloc(vbo, CORNER_RESOLUTION * 2 * 4 * 8 + 2);
+ GPU_vertbuf_data_alloc(vbo, CORNER_RESOLUTION * 2 * 4 + 2);
uint vidx = 0;
- /* Note jitter is applied in the shader. */
- for (int jit = 0; jit < 8; ++jit) {
- for (int corner = 0; corner < 4; ++corner) {
- for (int c = 0; c < CORNER_RESOLUTION; ++c) {
- do_vert_pair(vbo, pos, &vidx, corner, c);
- }
+ for (int corner = 0; corner < 4; ++corner) {
+ for (int c = 0; c < CORNER_RESOLUTION; ++c) {
+ do_vert_pair(vbo, pos, &vidx, corner, c);
}
}
/* close the loop */
@@ -390,21 +388,30 @@ void ED_screen_draw_edges(wmWindow *win)
BLI_rcti_do_minmax_v(&scissor_rect, (int[2]){sa->v3->vec.x, sa->v3->vec.y});
}
+ if (GPU_type_matches(GPU_DEVICE_INTEL_UHD, GPU_OS_UNIX, GPU_DRIVER_ANY)) {
+ /* For some reason, on linux + Intel UHD Graphics 620 the driver
+ * hangs if we don't flush before this. (See T57455) */
+ GPU_flush();
+ }
+
GPU_scissor(scissor_rect.xmin,
scissor_rect.ymin,
BLI_rcti_size_x(&scissor_rect) + 1,
BLI_rcti_size_y(&scissor_rect) + 1);
- glEnable(GL_SCISSOR_TEST);
+ /* It seems that all areas gets smaller when pixelsize is > 1.
+ * So in order to avoid missing pixels we just disable de scissors. */
+ if (U.pixelsize <= 1.0f) {
+ glEnable(GL_SCISSOR_TEST);
+ }
UI_GetThemeColor4fv(TH_EDITOR_OUTLINE, col);
- col[3] = 1.0f / 8.0f;
+ col[3] = 1.0f;
corner_scale = U.pixelsize * 8.0f;
edge_thickness = corner_scale * 0.21f;
GPU_blend(true);
- /* Transparent pass (for AA). */
GPUBatch *batch = batch_screen_edges_get(&verts_per_corner);
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_AREA_EDGES);
GPU_batch_uniform_1i(batch, "cornerLen", verts_per_corner);
@@ -417,16 +424,9 @@ void ED_screen_draw_edges(wmWindow *win)
GPU_blend(false);
- /* Opaque pass. */
- corner_scale -= 2.0f;
- edge_thickness = corner_scale * 0.2f;
- GPU_batch_uniform_1f(batch, "scale", corner_scale);
-
- for (sa = screen->areabase.first; sa; sa = sa->next) {
- drawscredge_area(sa, winsize_x, winsize_y, edge_thickness);
+ if (U.pixelsize <= 1.0f) {
+ glDisable(GL_SCISSOR_TEST);
}
-
- glDisable(GL_SCISSOR_TEST);
}
/**
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index b4c639e51b6..62d60c39c0c 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1409,7 +1409,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);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
}
#endif
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index 9f845bf04ba..87bcd1b7006 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -37,7 +37,7 @@ struct Main;
/* internal exports only */
-#define AZONESPOT (0.8f * U.widget_unit)
+#define AZONESPOT (0.4f * U.widget_unit)
#define AZONEFADEIN (5.0f * U.widget_unit) /* when azone is totally visible */
#define AZONEFADEOUT (6.5f * U.widget_unit) /* when we start seeing the azone */
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 6a9f1e13aea..20d83b0a64b 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -89,6 +89,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "RNA_enum_types.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -1541,6 +1542,8 @@ static void area_move_exit(bContext *C, wmOperator *op)
/* this makes sure aligned edges will result in aligned grabbing */
BKE_screen_remove_double_scrverts(CTX_wm_screen(C));
BKE_screen_remove_double_scredges(CTX_wm_screen(C));
+
+ G.moving &= ~G_TRANSFORM_WM;
}
static int area_move_exec(bContext *C, wmOperator *op)
@@ -1563,6 +1566,8 @@ static int area_move_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (!area_move_init(C, op))
return OPERATOR_PASS_THROUGH;
+ G.moving |= G_TRANSFORM_WM;
+
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -1895,19 +1900,33 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (CTX_wm_area(C) != sad->sa1 || sad->sa1 != sad->sa2)
return OPERATOR_PASS_THROUGH;
- /* prepare operator state vars */
- if (sad->gesture_dir == 'n' || sad->gesture_dir == 's') {
+ /* The factor will be close to 1.0f when near the top-left and the bottom-right corners. */
+ const float factor_v = ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy;
+ const float factor_h = ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx;
+ const bool is_left = factor_v < 0.5f;
+ const bool is_bottom = factor_h < 0.5f;
+ const bool is_right = !is_left;
+ const bool is_top = !is_bottom;
+ float factor;
+
+ /* Prepare operator state vars. */
+ if (ELEM(sad->gesture_dir, 'n', 's')) {
dir = 'h';
- RNA_property_float_set(
- op->ptr, prop_factor,
- ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx);
+ factor = factor_h;
}
else {
dir = 'v';
- RNA_property_float_set(
- op->ptr, prop_factor,
- ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy);
+ factor = factor_v;
+ }
+
+ if ((is_top && is_left) ||
+ (is_bottom && is_right))
+ {
+ factor = 1.0f - factor;
}
+
+ RNA_property_float_set(op->ptr, prop_factor, factor);
+
RNA_property_enum_set(op->ptr, prop_dir, dir);
/* general init, also non-UI case, adds customdata, sets area and defaults */
@@ -4334,7 +4353,7 @@ static void SCREEN_OT_back_to_previous(struct wmOperatorType *ot)
static int userpref_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- int sizex = 800 * UI_DPI_FAC;
+ int sizex = (800 + UI_NAVIGATION_REGION_WIDTH) * UI_DPI_FAC;
int sizey = 500 * UI_DPI_FAC;
/* changes context! */
@@ -4351,8 +4370,8 @@ static int userpref_show_invoke(bContext *C, wmOperator *op, const wmEvent *even
static void SCREEN_OT_userpref_show(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Show User Preferences";
- ot->description = "Show user preferences";
+ ot->name = "Show Preferences";
+ ot->description = "Edit user preferences and system settings";
ot->idname = "SCREEN_OT_userpref_show";
/* api callbacks */
@@ -4636,6 +4655,69 @@ static void SCREEN_OT_region_blend(wmOperatorType *ot)
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Space Type Set or Cycle Operator
+ * \{ */
+
+static int space_type_set_or_cycle_exec(bContext *C, wmOperator *op)
+{
+ const int space_type = RNA_enum_get(op->ptr, "space_type");
+
+ PointerRNA ptr;
+ ScrArea *sa = CTX_wm_area(C);
+ RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Area, sa, &ptr);
+ PropertyRNA *prop_type = RNA_struct_find_property(&ptr, "type");
+ PropertyRNA *prop_ui_type = RNA_struct_find_property(&ptr, "ui_type");
+
+ if (sa->spacetype != space_type) {
+ /* Set the type. */
+ RNA_property_enum_set(&ptr, prop_type, space_type);
+ RNA_property_update(C, &ptr, prop_type);
+ }
+ else {
+ /* Types match, cycle the subtype. */
+ const int space_type_ui = RNA_property_enum_get(&ptr, prop_ui_type);
+ const EnumPropertyItem *item;
+ int item_len;
+ bool free;
+ RNA_property_enum_items(C, &ptr, prop_ui_type, &item, &item_len, &free);
+ int index = RNA_enum_from_value(item, space_type_ui);
+ for (int i = 1; i < item_len; i++) {
+ const EnumPropertyItem *item_test = &item[(index + i) % item_len];
+ if ((item_test->value >> 16) == space_type) {
+ RNA_property_enum_set(&ptr, prop_ui_type, item_test->value);
+ RNA_property_update(C, &ptr, prop_ui_type);
+ break;
+ }
+ }
+ if (free) {
+ MEM_freeN((void *)item);
+ }
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+static void SCREEN_OT_space_type_set_or_cycle(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Cycle Space Type Set";
+ ot->description = "Set the space type or cycle subtype";
+ ot->idname = "SCREEN_OT_space_type_set_or_cycle";
+
+ /* api callbacks */
+ ot->exec = space_type_set_or_cycle_exec;
+ ot->poll = ED_operator_areaactive;
+
+ ot->flag = 0;
+
+ RNA_def_enum(ot->srna, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Type", "");
+}
+
+/** \} */
+
+
/* -------------------------------------------------------------------- */
/** \name Space Context Cycle Operator
* \{ */
@@ -4817,6 +4899,7 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(SCREEN_OT_userpref_show);
WM_operatortype_append(SCREEN_OT_drivers_editor_show);
WM_operatortype_append(SCREEN_OT_region_blend);
+ WM_operatortype_append(SCREEN_OT_space_type_set_or_cycle);
WM_operatortype_append(SCREEN_OT_space_context_cycle);
WM_operatortype_append(SCREEN_OT_workspace_cycle);
diff --git a/source/blender/editors/screen/screen_user_menu.c b/source/blender/editors/screen/screen_user_menu.c
index e945a5ae291..45f82618d2e 100644
--- a/source/blender/editors/screen/screen_user_menu.c
+++ b/source/blender/editors/screen/screen_user_menu.c
@@ -189,6 +189,7 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
(sl->spacetype != SPACE_TOPBAR) ? BKE_blender_user_menu_find(&U.user_menus, SPACE_TOPBAR, context) : NULL,
(sl->spacetype == SPACE_VIEW3D) ? BKE_blender_user_menu_find(&U.user_menus, SPACE_BUTS, context) : NULL,
};
+ bool is_empty = true;
for (int um_index = 0; um_index < ARRAY_SIZE(um_array); um_index++) {
bUserMenu *um = um_array[um_index];
if (um == NULL) {
@@ -202,11 +203,13 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
uiItemFullO(
menu->layout, umi_op->op_idname, ui_name,
ICON_NONE, prop, umi_op->opcontext, 0, NULL);
+ is_empty = false;
}
else if (umi->type == USER_MENU_TYPE_MENU) {
bUserMenuItem_Menu *umi_mt = (bUserMenuItem_Menu *)umi;
uiItemM(menu->layout, umi_mt->mt_idname, ui_name,
ICON_NONE);
+ is_empty = false;
}
else if (umi->type == USER_MENU_TYPE_PROP) {
bUserMenuItem_Prop *umi_pr = (bUserMenuItem_Prop *)umi;
@@ -240,6 +243,7 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
menu->layout,
&prop_ptr, prop, umi_pr->prop_index,
0, 0, ui_name, ICON_NONE);
+ is_empty = false;
}
}
}
@@ -254,6 +258,11 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
}
}
}
+
+ if (is_empty) {
+ uiItemL(menu->layout, IFACE_("No menu items found."), ICON_NONE);
+ uiItemL(menu->layout, IFACE_("Right click on buttons to add them to this menu."), ICON_NONE);
+ }
}
void ED_screen_user_menu_register(void)
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 6c836c9fc08..d8e0945eb25 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -187,7 +187,7 @@ bool ED_workspace_change(
BLI_assert(CTX_wm_workspace(C) == workspace_new);
WM_toolsystem_unlink_all(C, workspace_old);
- WM_toolsystem_reinit_all(C, win);
+ /* Area initialization will initialize based on the new workspace. */
/* Automatic mode switching. */
if (workspace_new->object_mode != workspace_old->object_mode) {
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index f9b2e0bbb01..30efcd2cb9a 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -1143,7 +1143,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
Mesh *me = BKE_mesh_from_object(ob);
BLI_assert(me != NULL);
- DEG_id_tag_update(&me->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&me->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene);
@@ -1166,7 +1166,7 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
ot->poll = texture_paint_toggle_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 6ef4a230a57..5275d899a56 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -1461,6 +1461,11 @@ static float project_paint_uvpixel_mask(
angle_cos = dot_v3v3(viewDirPersp, no);
}
+ /* If backface culling is disabled, allow painting on back faces. */
+ if (!ps->do_backfacecull) {
+ angle_cos = fabsf(angle_cos);
+ }
+
if (angle_cos <= ps->normal_angle__cos) {
return 0.0f; /* outsize the normal limit*/
}
@@ -3071,8 +3076,7 @@ static void project_paint_delayed_face_init(ProjPaintState *ps, const MLoopTri *
#endif
}
-static void proj_paint_state_viewport_init(
- ProjPaintState *ps, const Depsgraph *depsgraph, const char symmetry_flag)
+static void proj_paint_state_viewport_init(ProjPaintState *ps, const char symmetry_flag)
{
float mat[3][3];
float viewmat[4][4];
@@ -3133,7 +3137,7 @@ static void proj_paint_state_viewport_init(
invert_m4_m4(viewinv, viewmat);
}
else if (ps->source == PROJ_SRC_IMAGE_CAM) {
- Object *cam_ob_eval = DEG_get_evaluated_object(depsgraph, ps->scene->camera);
+ Object *cam_ob_eval = DEG_get_evaluated_object(ps->depsgraph, ps->scene->camera);
CameraParams params;
/* viewmat & viewinv */
@@ -3400,17 +3404,24 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob = ps->ob;
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+
+ if (scene_eval == NULL || ob_eval == NULL) {
+ return false;
+ }
+
/* Workaround for subsurf selection, try the display mesh first */
if (ps->source == PROJ_SRC_IMAGE_CAM) {
/* using render mesh, assume only camera was rendered from */
ps->me_eval = mesh_create_eval_final_render(
- depsgraph, ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MLOOPUV | CD_MASK_MTFACE);
+ depsgraph, scene_eval, ob_eval, scene_eval->customdata_mask | CD_MASK_MLOOPUV | CD_MASK_MTFACE);
ps->me_eval_free = true;
}
else {
ps->me_eval = mesh_get_eval_final(
- depsgraph, ps->scene, ps->ob,
- ps->scene->customdata_mask | CD_MASK_MLOOPUV | CD_MASK_MTFACE | (ps->do_face_sel ? CD_MASK_ORIGINDEX : 0));
+ depsgraph, scene_eval, ob_eval,
+ scene_eval->customdata_mask | CD_MASK_MLOOPUV | CD_MASK_MTFACE | (ps->do_face_sel ? CD_MASK_ORIGINDEX : 0));
ps->me_eval_free = false;
}
@@ -3847,7 +3858,7 @@ static void project_paint_begin(
proj_paint_state_cavity_init(ps);
}
- proj_paint_state_viewport_init(ps, CTX_data_depsgraph(C), symmetry_flag);
+ proj_paint_state_viewport_init(ps, symmetry_flag);
/* calculate vert screen coords
* run this early so we can calculate the x/y resolution of our bucket rect */
@@ -3894,7 +3905,7 @@ static void paint_proj_begin_clone(ProjPaintState *ps, const float mouse[2])
/* setup clone offset */
if (ps->tool == PAINT_TOOL_CLONE) {
float projCo[4];
- copy_v3_v3(projCo, ED_view3d_cursor3d_get(ps->scene, ps->v3d)->location);
+ copy_v3_v3(projCo, ps->scene->cursor.location);
mul_m4_v3(ps->obmat_imat, projCo);
projCo[3] = 1.0f;
@@ -4674,6 +4685,41 @@ static void *do_projectpaint_thread(void *ph_v)
float texrgb[3];
float mask;
+ /* Extra mask for normal, layer stencil, .. */
+ float custom_mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
+
+ /* Mask texture. */
+ if (ps->is_maskbrush) {
+ float texmask = BKE_brush_sample_masktex(ps->scene, ps->brush, projPixel->projCoSS, thread_index, pool);
+ CLAMP(texmask, 0.0f, 1.0f);
+ custom_mask *= texmask;
+ }
+
+ /* Color texture (alpha used as mask). */
+ if (ps->is_texbrush) {
+ MTex *mtex = &brush->mtex;
+ float samplecos[3];
+ float texrgba[4];
+
+ /* taking 3d copy to account for 3D mapping too. It gets concatenated during sampling */
+ if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) {
+ copy_v3_v3(samplecos, projPixel->worldCoSS);
+ }
+ else {
+ copy_v2_v2(samplecos, projPixel->projCoSS);
+ samplecos[2] = 0.0f;
+ }
+
+ /* note, for clone and smear, we only use the alpha, could be a special function */
+ BKE_brush_sample_tex_3d(ps->scene, brush, samplecos, texrgba, thread_index, pool);
+
+ copy_v3_v3(texrgb, texrgba);
+ custom_mask *= texrgba[3];
+ }
+ else {
+ zero_v3(texrgb);
+ }
+
if (ps->do_masking) {
/* masking to keep brush contribution to a pixel limited. note we do not do
* a simple max(mask, mask_accum), as this is very sensitive to spacing and
@@ -4682,12 +4728,7 @@ static void *do_projectpaint_thread(void *ph_v)
* Instead we use a formula that adds up but approaches brush_alpha slowly
* and never exceeds it, which gives nice smooth results. */
float mask_accum = *projPixel->mask_accum;
- float max_mask = brush_alpha * falloff * 65535.0f;
-
- if (ps->is_maskbrush) {
- float texmask = BKE_brush_sample_masktex(ps->scene, ps->brush, projPixel->projCoSS, thread_index, pool);
- max_mask *= texmask;
- }
+ float max_mask = brush_alpha * custom_mask * falloff * 65535.0f;
if (brush->flag & BRUSH_ACCUMULATE)
mask = mask_accum + max_mask;
@@ -4707,41 +4748,9 @@ static void *do_projectpaint_thread(void *ph_v)
}
}
else {
- mask = brush_alpha * falloff;
- if (ps->is_maskbrush) {
- float texmask = BKE_brush_sample_masktex(ps->scene, ps->brush, projPixel->projCoSS, thread_index, pool);
- CLAMP(texmask, 0.0f, 1.0f);
- mask *= texmask;
- }
+ mask = brush_alpha * custom_mask * falloff;
}
- if (ps->is_texbrush) {
- MTex *mtex = &brush->mtex;
- float samplecos[3];
- float texrgba[4];
-
- /* taking 3d copy to account for 3D mapping too. It gets concatenated during sampling */
- if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) {
- copy_v3_v3(samplecos, projPixel->worldCoSS);
- }
- else {
- copy_v2_v2(samplecos, projPixel->projCoSS);
- samplecos[2] = 0.0f;
- }
-
- /* note, for clone and smear, we only use the alpha, could be a special function */
- BKE_brush_sample_tex_3d(ps->scene, brush, samplecos, texrgba, thread_index, pool);
-
- copy_v3_v3(texrgb, texrgba);
- mask *= texrgba[3];
- }
- else {
- zero_v3(texrgb);
- }
-
- /* extra mask for normal, layer stencil, .. */
- mask *= ((float)projPixel->mask) * (1.0f / 65535.0f);
-
if (mask > 0.0f) {
/* copy of code above */
@@ -5008,7 +5017,7 @@ void paint_proj_stroke(
struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
- float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
+ float *cursor = scene->cursor.location;
int mval_i[2] = {(int)pos[0], (int)pos[1]};
view3d_operator_needs_opengl(C);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 85dc37b9838..11565d665b1 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -50,7 +50,6 @@
#include "ED_paint.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
-#include "ED_keymap_templates.h"
#include "ED_image.h"
#include "ED_gpencil.h"
#include "UI_resources.h"
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 45200924790..923fc097f43 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -655,8 +655,7 @@ void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
static int face_select_all_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
- paintface_deselect_all_visible(ob, RNA_enum_get(op->ptr, "action"), true);
- paintface_tag_select_update(C, ob);
+ paintface_deselect_all_visible(C, ob, RNA_enum_get(op->ptr, "action"), true);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
}
@@ -739,8 +738,7 @@ static int face_select_hide_exec(bContext *C, wmOperator *op)
{
const bool unselected = RNA_boolean_get(op->ptr, "unselected");
Object *ob = CTX_data_active_object(C);
- paintface_hide(ob, unselected);
- paintface_tag_select_update(C, ob);
+ paintface_hide(C, ob, unselected);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
}
@@ -763,8 +761,7 @@ static int face_select_reveal_exec(bContext *C, wmOperator *op)
{
const bool select = RNA_boolean_get(op->ptr, "select");
Object *ob = CTX_data_active_object(C);
- paintface_reveal(ob, select);
- paintface_tag_select_update(C, ob);
+ paintface_reveal(C, ob, select);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index a604bd5feb6..f5c49c4b7e1 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1117,7 +1117,7 @@ static void ed_vwpaintmode_enter_generic(
vertex_paint_init_session(depsgraph, scene, ob, mode_flag);
/* Flush object mode. */
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
void ED_object_vpaintmode_enter_ex(
@@ -1205,7 +1205,7 @@ static void ed_vwpaintmode_exit_generic(
BKE_object_free_derived_caches(ob);
/* Flush object mode. */
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
void ED_object_vpaintmode_exit_ex(Object *ob)
@@ -1320,7 +1320,7 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot)
ot->poll = paint_poll_test;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
}
/* ************ weight paint operator ********** */
@@ -2308,7 +2308,7 @@ static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
for (i = 0; i < PSYS_TOT_VG; i++) {
if (psys->vgroup[i] == ob->actdef) {
- psys->recalc |= PSYS_RECALC_RESET;
+ psys->recalc |= ID_RECALC_PSYS_RESET;
break;
}
}
@@ -2450,7 +2450,7 @@ void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot)
ot->poll = paint_poll_test;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
}
@@ -3170,7 +3170,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
- if (vp->paint.brush->vertexpaint_tool == PAINT_TOOL_SMEAR) {
+ if (vp->paint.brush->vertexpaint_tool == VPAINT_TOOL_SMEAR) {
memcpy(vpd->smear.color_prev, vpd->smear.color_curr, sizeof(uint) * ((Mesh *)ob->data)->totloop);
}
@@ -3187,7 +3187,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
}
else {
/* Flush changes through DEG. */
- DEG_id_tag_update(ob->data, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(ob->data, ID_RECALC_COPY_ON_WRITE);
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
index ba3bc5501e3..1ce57868e3a 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
@@ -57,6 +57,15 @@ static bool vertex_weight_paint_mode_poll(bContext *C)
(me && me->totpoly && me->dvert);
}
+static void tag_object_after_update(Object *object)
+{
+ BLI_assert(object->type == OB_MESH);
+ Mesh *mesh = object->data;
+ DEG_id_tag_update(&mesh->id, ID_RECALC_COPY_ON_WRITE);
+ /* NOTE: Original mesh is used for display, so tag it directly here. */
+ BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL);
+}
+
/* -------------------------------------------------------------------- */
/** \name Set Vertex Colors Operator
* \{ */
@@ -98,7 +107,7 @@ static bool vertex_color_set(Object *ob, uint paintcol)
/* remove stale me->mcol, will be added later */
BKE_mesh_tessface_clear(me);
- DEG_id_tag_update(&me->id, 0);
+ tag_object_after_update(ob);
return true;
}
@@ -170,7 +179,7 @@ static bool vertex_paint_from_weight(Object *ob)
} while (j < mp->totloop);
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ tag_object_after_update(ob);
return true;
}
@@ -306,7 +315,7 @@ static bool vertex_color_smooth(Object *ob)
MEM_freeN(mlooptag);
- DEG_id_tag_update(&me->id, 0);
+ tag_object_after_update(ob);
return true;
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
index 31ae12c112a..5fe96483044 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
@@ -44,6 +44,7 @@
#include "BKE_mesh_runtime.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "ED_screen.h"
#include "ED_view3d.h"
@@ -103,11 +104,13 @@ static void vpaint_proj_dm_map_cosnos_init__map_cb(
}
static void vpaint_proj_dm_map_cosnos_init(
- struct Depsgraph *depsgraph, Scene *scene, Object *ob,
+ struct Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob,
struct VertProjHandle *vp_handle)
{
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
Mesh *me = ob->data;
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
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);
@@ -168,10 +171,11 @@ static void vpaint_proj_dm_map_cosnos_update(
{
struct VertProjUpdate vp_update = {vp_handle, ar, mval_fl};
- Scene *scene = vp_handle->scene;
Object *ob = vp_handle->ob;
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
Mesh *me = ob->data;
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, 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);
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 46eb3995ea3..fe326ad7337 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -60,6 +60,7 @@
#include "BKE_colortools.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -370,7 +371,7 @@ static int weight_sample_group_exec(bContext *C, wmOperator *op)
BLI_assert(type + 1 >= 0);
vc.obact->actdef = type + 1;
- DEG_id_tag_update(&vc.obact->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&vc.obact->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, vc.obact);
return OPERATOR_FINISHED;
}
@@ -691,15 +692,17 @@ static int paint_weight_gradient_modal(bContext *C, wmOperator *op, const wmEven
if (ret & OPERATOR_CANCELLED) {
Object *ob = CTX_data_active_object(C);
- Mesh *me = ob->data;
- if (vert_cache->wpp.wpaint_prev) {
- BKE_defvert_array_free_elems(me->dvert, me->totvert);
- BKE_defvert_array_copy(me->dvert, vert_cache->wpp.wpaint_prev, me->totvert);
- wpaint_prev_destroy(&vert_cache->wpp);
+ if (vert_cache != NULL) {
+ Mesh *me = ob->data;
+ if (vert_cache->wpp.wpaint_prev) {
+ BKE_defvert_array_free_elems(me->dvert, me->totvert);
+ BKE_defvert_array_copy(me->dvert, vert_cache->wpp.wpaint_prev, me->totvert);
+ wpaint_prev_destroy(&vert_cache->wpp);
+ }
+ MEM_freeN(vert_cache);
}
- MEM_freeN(vert_cache);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
else if (ret & OPERATOR_FINISHED) {
@@ -786,7 +789,10 @@ 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);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, scene->customdata_mask | CD_MASK_ORIGINDEX);
if (data.is_init) {
data.vert_visit = BLI_BITMAP_NEW(me->totvert, __func__);
@@ -799,7 +805,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
BKE_mesh_foreach_mapped_vert(me_eval, gradientVertUpdate__mapFunc, &data, MESH_FOREACH_NOP);
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
if (is_interactive == false) {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index fd1b331d76e..5a0b53945ac 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3954,8 +3954,9 @@ static void do_tiled(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSettings
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
const float radius = cache->radius;
- const float *bbMin = ob->bb->vec[0];
- const float *bbMax = ob->bb->vec[6];
+ BoundBox *bb = BKE_object_boundbox_get(ob);
+ const float *bbMin = bb->vec[0];
+ const float *bbMax = bb->vec[6];
const float *step = sd->paint.tile_offset;
int dim;
@@ -4876,10 +4877,10 @@ static void sculpt_flush_update(bContext *C)
multires_mark_as_modified(ob_eval, MULTIRES_COORDS_MODIFIED);
}
- DEG_id_tag_update(&ob->id, DEG_TAG_SHADING_UPDATE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
if (ss->kb || ss->modifiers_active) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
ED_region_tag_redraw(ar);
}
else {
@@ -5070,7 +5071,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
/* try to avoid calling this, only for e.g. linked duplicates now */
if (((Mesh *)ob->data)->id.us > 1)
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
@@ -5663,7 +5664,7 @@ void ED_object_sculptmode_enter_ex(
const int flush_recalc = ed_object_sculptmode_flush_recalc_flag(scene, ob, mmd);
if (flush_recalc)
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
/* Create sculpt mode session data */
if (ob->sculpt) {
@@ -5745,14 +5746,15 @@ void ED_object_sculptmode_enter_ex(
}
/* Flush object mode. */
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
void ED_object_sculptmode_enter(struct bContext *C, ReportList *reports)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- Object *ob = CTX_data_active_object(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob = OBACT(view_layer);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, reports);
}
@@ -5778,7 +5780,7 @@ void ED_object_sculptmode_exit_ex(
* a consistent state.
*/
if (true || /* flush_recalc || */ (ob->sculpt && ob->sculpt->bm)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
if (me->flag & ME_SCULPT_DYNAMIC_TOPOLOGY) {
@@ -5802,14 +5804,15 @@ void ED_object_sculptmode_exit_ex(
BKE_object_free_derived_caches(ob);
/* Flush object mode. */
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
void ED_object_sculptmode_exit(bContext *C)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
- Object *ob = CTX_data_active_object(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob = OBACT(view_layer);
ED_object_sculptmode_exit_ex(depsgraph, scene, ob);
}
@@ -5820,7 +5823,8 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
Depsgraph *depsgraph = CTX_data_depsgraph_on_load(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
- Object *ob = CTX_data_active_object(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob = OBACT(view_layer);
const int mode_flag = OB_MODE_SCULPT;
const bool is_mode_set = (ob->mode & mode_flag) != 0;
@@ -5858,7 +5862,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot)
ot->exec = sculpt_mode_toggle_exec;
ot->poll = ED_operator_object_active_editable_mesh;
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
}
static bool sculpt_and_constant_or_manual_detail_poll(bContext *C)
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index d79c6b81fd7..090bc335d66 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -141,7 +141,8 @@ static bool sculpt_undo_restore_coords(bContext *C, SculptUndoNode *unode)
{
Scene *scene = CTX_data_scene(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- Object *ob = CTX_data_active_object(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob = OBACT(view_layer);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
SculptSession *ss = ob->sculpt;
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
@@ -258,7 +259,8 @@ static bool sculpt_undo_restore_hidden(
bContext *C,
SculptUndoNode *unode)
{
- Object *ob = CTX_data_active_object(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob = OBACT(view_layer);
SculptSession *ss = ob->sculpt;
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
int i;
@@ -291,7 +293,8 @@ static bool sculpt_undo_restore_hidden(
static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
{
- Object *ob = CTX_data_active_object(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob = OBACT(view_layer);
SculptSession *ss = ob->sculpt;
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
MVert *mvert;
@@ -477,7 +480,8 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
{
Scene *scene = CTX_data_scene(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- Object *ob = CTX_data_active_object(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob = OBACT(view_layer);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
SculptSession *ss = ob->sculpt;
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
@@ -497,7 +501,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
}
}
- DEG_id_tag_update(&ob->id, DEG_TAG_SHADING_UPDATE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, need_mask);
@@ -582,7 +586,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
}
if (tag_update) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else {
sculpt_update_object_bounding_box(ob);
@@ -640,7 +644,9 @@ static void sculpt_undo_free_list(ListBase *lb)
#if 0
static bool sculpt_undo_cleanup(bContext *C, ListBase *lb)
{
- Object *ob = CTX_data_active_object(C);
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob = OBACT(view_layer);
SculptUndoNode *unode;
unode = lb->first;
@@ -1021,7 +1027,8 @@ static bool sculpt_undosys_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
if (sa && (sa->spacetype == SPACE_VIEW3D)) {
- Object *obact = CTX_data_active_object(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *obact = OBACT(view_layer);
if (obact && (obact->mode & OB_MODE_SCULPT)) {
return true;
}
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index 7f51f9e4149..3ce4965b284 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -267,8 +267,7 @@ static void sound_update_animation_flags(Scene *scene)
SEQ_BEGIN(scene->ed, seq)
{
BKE_sequencer_recursive_apply(seq, sound_update_animation_flags_cb, scene);
- }
- SEQ_END
+ } SEQ_END;
fcu = id_data_find_fcurve(&scene->id, scene, &RNA_Scene, "audio_volume", 0, &driven);
if (fcu || driven)
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 15587a5f39d..0a7db803acc 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -182,8 +182,7 @@ static void action_free(SpaceLink *UNUSED(sl))
static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
{
SpaceAction *saction = sa->spacedata.first;
-
- saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
}
static SpaceLink *action_duplicate(SpaceLink *sl)
@@ -542,7 +541,7 @@ static void action_listener(
ED_area_tag_redraw(sa);
}
else if (wmn->action == NA_SELECTED) {
- saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
ED_area_tag_refresh(sa);
}
}
@@ -550,7 +549,7 @@ static void action_listener(
case NC_ANIMATION:
/* for NLA tweakmode enter/exit, need complete refresh */
if (wmn->data == ND_NLA_ACTCHANGE) {
- saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
ED_area_tag_refresh(sa);
}
/* autocolor only really needs to change when channels are added/removed, or previously hidden stuff appears
@@ -598,7 +597,7 @@ static void action_listener(
switch (wmn->data) {
case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
case ND_OB_SELECT:
- saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
ED_area_tag_refresh(sa);
break;
@@ -612,7 +611,7 @@ static void action_listener(
switch (wmn->data) {
case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
case ND_BONE_ACTIVE:
- saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
ED_area_tag_refresh(sa);
break;
case ND_TRANSFORM:
@@ -648,7 +647,7 @@ static void action_listener(
case NC_NODE:
if (wmn->action == NA_SELECTED) {
/* selection changed, so force refresh to flush (needs flag set to do syncing) */
- saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
ED_area_tag_refresh(sa);
}
break;
@@ -661,13 +660,13 @@ static void action_listener(
ED_area_tag_redraw(sa);
break;
case ND_SPACE_CHANGED:
- saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
ED_area_tag_refresh(sa);
break;
}
break;
case NC_WINDOW:
- if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) {
+ if (saction->runtime.flag & SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC) {
/* force redraw/refresh after undo/redo - [#28962] */
ED_area_tag_refresh(sa);
}
@@ -797,14 +796,14 @@ static void action_refresh(const bContext *C, ScrArea *sa)
/* update the state of the animchannels in response to changes from the data they represent
* NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled
*/
- if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) {
+ if (saction->runtime.flag & SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC) {
ARegion *ar;
/* Perform syncing of channel state incl. selection
* Active action setting also occurs here (as part of anim channel filtering in anim_filter.c)
*/
ANIM_sync_animchannels_to_data(C);
- saction->flag &= ~SACTION_TEMP_NEEDCHANSYNC;
+ saction->runtime.flag &= ~SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
/* Tag everything for redraw
* - Regions (such as header) need to be manually tagged for redraw too
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 1f1f238daf6..159757139fa 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -431,6 +431,21 @@ static void buttons_navigation_bar_region_draw(const bContext *C, ARegion *ar)
ED_region_panels_draw(C, ar);
}
+static void buttons_navigation_bar_region_message_subscribe(
+ const bContext *UNUSED(C),
+ WorkSpace *UNUSED(workspace), Scene *UNUSED(scene),
+ bScreen *UNUSED(screen), ScrArea *UNUSED(sa), ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+
+ WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_region_tag_redraw);
+}
+
/* draw a certain button set only if properties area is currently
* showing that button set, to reduce unnecessary drawing. */
static void buttons_area_redraw(ScrArea *sa, short buttons)
@@ -732,6 +747,7 @@ void ED_spacetype_buttons(void)
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
art->init = buttons_navigation_bar_region_init;
art->draw = buttons_navigation_bar_region_draw;
+ art->message_subscribe = buttons_navigation_bar_region_message_subscribe;
BLI_addhead(&st->regiontypes, art);
BKE_spacetype_register(st);
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index e56ec98a232..e907fdfc570 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -322,6 +322,7 @@ static int reload_exec(bContext *C, wmOperator *UNUSED(op))
if (!clip)
return OPERATOR_CANCELLED;
+ WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_CLIP_PREFETCH);
BKE_movieclip_reload(CTX_data_main(C), clip);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c
index 4d1c3e0b137..d3fffaa3254 100644
--- a/source/blender/editors/space_clip/tracking_ops_orient.c
+++ b/source/blender/editors/space_clip/tracking_ops_orient.c
@@ -251,7 +251,7 @@ static int set_origin_exec(bContext *C, wmOperator *op)
}
DEG_id_tag_update(&clip->id, 0);
- DEG_id_tag_update(&object->id, OB_RECALC_OB);
+ DEG_id_tag_update(&object->id, ID_RECALC_TRANSFORM);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -499,7 +499,7 @@ static int set_plane_exec(bContext *C, wmOperator *op)
set_axis(depsgraph, scene, object, clip, tracking_object, axis_track, 'X');
DEG_id_tag_update(&clip->id, 0);
- DEG_id_tag_update(&object->id, OB_RECALC_OB);
+ DEG_id_tag_update(&object->id, ID_RECALC_TRANSFORM);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -574,7 +574,7 @@ static int set_axis_exec(bContext *C, wmOperator *op)
set_axis(depsgraph, scene, object, clip, tracking_object, track, axis == 0 ? 'X' : 'Y');
DEG_id_tag_update(&clip->id, 0);
- DEG_id_tag_update(&object->id, OB_RECALC_OB);
+ DEG_id_tag_update(&object->id, ID_RECALC_TRANSFORM);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -704,7 +704,7 @@ static int do_set_scale(bContext *C,
DEG_id_tag_update(&clip->id, 0);
if (object)
- DEG_id_tag_update(&object->id, OB_RECALC_OB);
+ DEG_id_tag_update(&object->id, ID_RECALC_TRANSFORM);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c
index 162948c8e64..c9901bd81bb 100644
--- a/source/blender/editors/space_clip/tracking_select.c
+++ b/source/blender/editors/space_clip/tracking_select.c
@@ -349,7 +349,7 @@ static int mouse_select(bContext *C, float co[2], int extend)
BKE_tracking_dopesheet_tag_update(tracking);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
- DEG_id_tag_update(&clip->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
return OPERATOR_FINISHED;
}
@@ -393,7 +393,7 @@ static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
clip->tracking.act_track = track;
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
- DEG_id_tag_update(&clip->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
return OPERATOR_PASS_THROUGH;
}
@@ -511,7 +511,7 @@ static int box_select_exec(bContext *C, wmOperator *op)
BKE_tracking_dopesheet_tag_update(tracking);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
- DEG_id_tag_update(&clip->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
return OPERATOR_FINISHED;
}
@@ -622,7 +622,7 @@ static int do_lasso_select_marker(bContext *C, const int mcords[][2], const shor
BKE_tracking_dopesheet_tag_update(tracking);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
- DEG_id_tag_update(&clip->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
}
return changed;
@@ -765,7 +765,7 @@ static int circle_select_exec(bContext *C, wmOperator *op)
BKE_tracking_dopesheet_tag_update(tracking);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
- DEG_id_tag_update(&clip->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
return OPERATOR_FINISHED;
}
@@ -891,7 +891,7 @@ static int select_all_exec(bContext *C, wmOperator *op)
BKE_tracking_dopesheet_tag_update(tracking);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
- DEG_id_tag_update(&clip->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
return OPERATOR_FINISHED;
}
@@ -975,7 +975,7 @@ static int select_grouped_exec(bContext *C, wmOperator *op)
BKE_tracking_dopesheet_tag_update(tracking);
WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip);
- DEG_id_tag_update(&clip->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index a9fcbf7ec89..ea73026020d 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1147,11 +1147,11 @@ static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv
SpaceFile *sfile = CTX_wm_space_file(C);
if (!file_highlight_set(sfile, ar, event->x, event->y))
- return OPERATOR_CANCELLED;
+ return OPERATOR_PASS_THROUGH;
ED_area_tag_redraw(CTX_wm_area(C));
- return OPERATOR_FINISHED;
+ return OPERATOR_PASS_THROUGH;
}
void FILE_OT_highlight(struct wmOperatorType *ot)
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index a9e5ee67cc9..c3d6c1f6435 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -495,13 +495,13 @@ static void do_graph_region_driver_buttons(bContext *C, void *id_v, int event)
/* rebuild depsgraph for the new deps, and ensure COW copies get flushed. */
DEG_relations_tag_update(bmain);
- DEG_id_tag_update_ex(bmain, id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, id, ID_RECALC_COPY_ON_WRITE);
if (adt != NULL) {
if (adt->action != NULL) {
- DEG_id_tag_update_ex(bmain, &adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, &adt->action->id, ID_RECALC_COPY_ON_WRITE);
}
if (adt->tmpact != NULL) {
- DEG_id_tag_update_ex(bmain, &adt->tmpact->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, &adt->tmpact->id, ID_RECALC_COPY_ON_WRITE);
}
}
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 65bf8af70e8..d4f6824ccdf 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -981,8 +981,8 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
immUniform1f("dash_width", 20.0f);
immUniform1f("dash_factor", 0.5f);
- /* the ghost curves are simply sampled F-Curves stored in sipo->ghostCurves */
- for (fcu = sipo->ghostCurves.first; fcu; fcu = fcu->next) {
+ /* the ghost curves are simply sampled F-Curves stored in sipo->runtime.ghost_curves */
+ for (fcu = sipo->runtime.ghost_curves.first; fcu; fcu = fcu->next) {
/* set whatever color the curve has set
* - this is set by the function which creates these
* - draw with a fixed opacity of 2
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 08a5a6aeedd..e610aee4810 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -345,7 +345,7 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end)
int filter;
/* free existing ghost curves */
- free_fcurves(&sipo->ghostCurves);
+ free_fcurves(&sipo->runtime.ghost_curves);
/* sanity check */
if (start >= end) {
@@ -396,7 +396,7 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end)
gcu->color[2] = fcu->color[2] - 0.07f;
/* store new ghost curve */
- BLI_addtail(&sipo->ghostCurves, gcu);
+ BLI_addtail(&sipo->runtime.ghost_curves, gcu);
/* restore driver */
fcu->driver = driver;
@@ -463,11 +463,11 @@ static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op))
sipo = (SpaceIpo *)ac.sl;
/* if no ghost curves, don't do anything */
- if (BLI_listbase_is_empty(&sipo->ghostCurves))
+ if (BLI_listbase_is_empty(&sipo->runtime.ghost_curves)) {
return OPERATOR_CANCELLED;
-
+ }
/* free ghost curves */
- free_fcurves(&sipo->ghostCurves);
+ free_fcurves(&sipo->runtime.ghost_curves);
/* update this editor only */
ED_area_tag_redraw(CTX_wm_area(C));
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 1fa6cb9b3de..9a825715e18 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -179,8 +179,9 @@ static void graph_free(SpaceLink *sl)
MEM_freeN(si->ads);
}
- if (si->ghostCurves.first)
- free_fcurves(&si->ghostCurves);
+ if (si->runtime.ghost_curves.first) {
+ free_fcurves(&si->runtime.ghost_curves);
+ }
}
@@ -208,7 +209,7 @@ static SpaceLink *graph_duplicate(SpaceLink *sl)
SpaceIpo *sipon = MEM_dupallocN(sl);
/* clear or remove stuff from old */
- BLI_duplicatelist(&sipon->ghostCurves, &((SpaceIpo *)sl)->ghostCurves);
+ BLI_duplicatelist(&sipon->runtime.ghost_curves, &((SpaceIpo *)sl)->runtime.ghost_curves);
sipon->ads = MEM_dupallocN(sipon->ads);
return (SpaceLink *)sipon;
@@ -585,7 +586,7 @@ static void graph_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn,
switch (wmn->data) {
case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
case ND_OB_SELECT:
- sipo->flag |= SIPO_TEMP_NEEDCHANSYNC;
+ sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC;
ED_area_tag_refresh(sa);
break;
@@ -598,7 +599,7 @@ static void graph_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn,
switch (wmn->data) {
case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
case ND_BONE_ACTIVE:
- sipo->flag |= SIPO_TEMP_NEEDCHANSYNC;
+ sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC;
ED_area_tag_refresh(sa);
break;
case ND_TRANSFORM:
@@ -612,7 +613,7 @@ static void graph_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn,
case NC_NODE:
if (wmn->action == NA_SELECTED) {
/* selection changed, so force refresh to flush (needs flag set to do syncing) */
- sipo->flag |= SIPO_TEMP_NEEDCHANSYNC;
+ sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC;
ED_area_tag_refresh(sa);
}
break;
@@ -621,7 +622,7 @@ static void graph_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn,
ED_area_tag_redraw(sa);
break;
case NC_WINDOW:
- if (sipo->flag & SIPO_TEMP_NEEDCHANSYNC) {
+ if (sipo->runtime.flag & (SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC | SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR)) {
/* force redraw/refresh after undo/redo - prevents "black curve" problem */
ED_area_tag_refresh(sa);
}
@@ -778,9 +779,18 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
/* update the state of the animchannels in response to changes from the data they represent
* NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled
*/
- if (sipo->flag & SIPO_TEMP_NEEDCHANSYNC) {
+ if (sipo->runtime.flag & SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC) {
ANIM_sync_animchannels_to_data(C);
- sipo->flag &= ~SIPO_TEMP_NEEDCHANSYNC;
+ sipo->runtime.flag &= ~SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC;
+ ED_area_tag_redraw(sa);
+ }
+
+ /* We could check 'SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR', but color is recalculated anyway. */
+ if (sipo->runtime.flag & SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR) {
+ sipo->runtime.flag &= ~SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR;
+#if 0 /* Done below. */
+ graph_refresh_fcurve_colors(C);
+#endif
ED_area_tag_redraw(sa);
}
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 4cbe25462af..a46767495dd 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -549,6 +549,26 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
}
}
+static void draw_image_buffer_repeated(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, ImBuf *ibuf, float zoomx, float zoomy)
+{
+ const double time_current = PIL_check_seconds_timer();
+
+ const int xmax = ceil(ar->v2d.cur.xmax);
+ const int ymax = ceil(ar->v2d.cur.ymax);
+ const int xmin = floor(ar->v2d.cur.xmin);
+ const int ymin = floor(ar->v2d.cur.ymin);
+
+ for (int x = xmin; x < xmax; x++) {
+ for (int y = ymin; y < ymax; y++) {
+ draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy);
+
+ /* only draw until running out of time */
+ if ((PIL_check_seconds_timer() - time_current) > 0.25)
+ return;
+ }
+ }
+}
+
/* draw uv edit */
/* draw grease pencil */
@@ -699,7 +719,10 @@ void draw_image_main(const bContext *C, ARegion *ar)
ED_region_grid_draw(ar, zoomx, zoomy);
}
else {
- draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy);
+ if (sima->flag & SI_DRAW_TILE)
+ draw_image_buffer_repeated(C, sima, ar, scene, ibuf, zoomx, zoomy);
+ else
+ draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy);
if (sima->flag & SI_DRAW_METADATA) {
int x, y;
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index b161de9f472..edf0c67ca7d 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1136,7 +1136,7 @@ static void image_sequence_get_frame_ranges(PointerRNA *ptr, ListBase *frames_al
BLI_addtail(&frame_range->frames, frame);
MEM_freeN(filename);
}
- RNA_END
+ RNA_END;
}
static int image_cmp_frame(const void *a, const void *b)
@@ -1777,7 +1777,7 @@ static void save_image_post(
BKE_color_managed_colorspace_settings_copy(&old_colorspace_settings,
&ima->colorspace_settings);
- IMB_colormanagment_colorspace_from_ibuf_ftype(&ima->colorspace_settings, ibuf);
+ IMB_colormanagement_colorspace_from_ibuf_ftype(&ima->colorspace_settings, ibuf);
if (!BKE_color_managed_colorspace_settings_equals(&old_colorspace_settings,
&ima->colorspace_settings))
{
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 01d2fc28c6b..b5c7657d890 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -53,6 +53,10 @@
#include "BKE_screen.h"
#include "BKE_workspace.h"
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
#include "DEG_depsgraph.h"
#include "IMB_imbuf_types.h"
@@ -69,8 +73,6 @@
#include "BIF_gl.h"
-#include "RNA_access.h"
-
#include "WM_api.h"
#include "WM_types.h"
#include "WM_message.h"
@@ -954,6 +956,37 @@ static void image_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID
}
}
+/**
+ * \note Used for splitting out a subset of modes is more involved,
+ * The previous non-uv-edit mode is stored so switching back to the
+ * image doesn't always reset the sub-mode.
+ */
+static int image_space_subtype_get(ScrArea *sa)
+{
+ SpaceImage *sima = sa->spacedata.first;
+ return sima->mode == SI_MODE_UV ? SI_MODE_UV : SI_MODE_VIEW;
+}
+
+static void image_space_subtype_set(ScrArea *sa, int value)
+{
+ SpaceImage *sima = sa->spacedata.first;
+ if (value == SI_MODE_UV) {
+ if (sima->mode != SI_MODE_UV) {
+ sima->mode_prev = sima->mode;
+ }
+ sima->mode = value;
+ }
+ else {
+ sima->mode = sima->mode_prev;
+ }
+}
+
+static void image_space_subtype_item_extend(
+ bContext *UNUSED(C), EnumPropertyItem **item, int *totitem)
+{
+ RNA_enum_items_add(item, totitem, rna_enum_space_image_mode_items);
+}
+
/**************************** spacetype *****************************/
/* only called once, from space/spacetypes.c */
@@ -977,6 +1010,9 @@ void ED_spacetype_image(void)
st->context = image_context;
st->gizmos = image_widgets;
st->id_remap = image_id_remap;
+ st->space_subtype_item_extend = image_space_subtype_item_extend;
+ st->space_subtype_get = image_space_subtype_get;
+ st->space_subtype_set = image_space_subtype_set;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index c842ac07eef..e1823010e0d 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -95,6 +95,30 @@ typedef struct SceneStatsFmt {
char totgpstroke[MAX_INFO_NUM_LEN], totgppoint[MAX_INFO_NUM_LEN];
} SceneStatsFmt;
+static bool stats_mesheval(Mesh *me_eval, int sel, int totob, SceneStats *stats)
+{
+ int totvert, totedge, totface, totloop;
+
+ 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;
+ stats->totface += totface * totob;
+ stats->tottri += poly_to_tri_count(totface, totloop) * totob;
+
+ if (sel) {
+ stats->totvertsel += totvert;
+ stats->totfacesel += totface;
+ }
+ return true;
+ }
+ return false;
+}
+
static void stats_object(Object *ob, int sel, int totob, SceneStats *stats)
{
switch (ob->type) {
@@ -102,24 +126,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats)
{
/* 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 (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;
- stats->totface += totface * totob;
- stats->tottri += poly_to_tri_count(totface, totloop) * totob;
-
- if (sel) {
- stats->totvertsel += totvert;
- stats->totfacesel += totface;
- }
- }
+ stats_mesheval(me_eval, sel, totob, stats);
break;
}
case OB_LAMP:
@@ -131,6 +138,13 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats)
case OB_SURF:
case OB_CURVE:
case OB_FONT:
+ {
+ Mesh *me_eval = ob->runtime.mesh_eval;
+ if (stats_mesheval(me_eval, sel, totob, stats)) {
+ break;
+ }
+ ATTR_FALLTHROUGH; /* Falltrough to displist. */
+ }
case OB_MBALL:
{
int totv = 0, totf = 0, tottri = 0;
@@ -398,7 +412,7 @@ static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer)
if (obedit) {
/* Edit Mode */
- FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, ob->mode, ob_iter)
+ FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, ((View3D *)NULL), ob->type, ob->mode, ob_iter)
{
stats_object_edit(ob_iter, &stats);
}
diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c
deleted file mode 100644
index 1896d7ec3a2..00000000000
--- a/source/blender/editors/space_logic/space_logic.c
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * ***** 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/space_logic/space_logic.c
- * \ingroup splogic
- */
-
-
-#include <string.h>
-#include <stdio.h>
-
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_utildefines.h"
-
-#include "DNA_gpencil_types.h"
-
-#include "BKE_context.h"
-#include "BKE_screen.h"
-
-#include "ED_space_api.h"
-#include "ED_screen.h"
-
-#include "BIF_gl.h"
-
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "UI_resources.h"
-#include "UI_view2d.h"
-
-#include "logic_intern.h"
-
-/* ******************** manage regions ********************* */
-
-ARegion *logic_has_buttons_region(ScrArea *sa)
-{
- ARegion *ar, *arnew;
-
- ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar) return ar;
-
- /* add subdiv level; after header */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
-
- /* is error! */
- if (ar == NULL) return NULL;
-
- arnew= MEM_callocN(sizeof(ARegion), "buttons for image");
-
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_UI;
- arnew->alignment = RGN_ALIGN_RIGHT;
-
- arnew->flag = RGN_FLAG_HIDDEN;
-
- return arnew;
-}
-
-/* ******************** default callbacks for image space ***************** */
-
-static SpaceLink *logic_new(const bContext *C)
-{
- ScrArea *sa= CTX_wm_area(C);
- ARegion *ar;
- SpaceLogic *slogic;
-
- slogic= MEM_callocN(sizeof(SpaceLogic), "initlogic");
- slogic->spacetype= SPACE_LOGIC;
-
- /* default options */
- slogic->scaflag = ((BUTS_SENS_SEL|BUTS_SENS_ACT|BUTS_SENS_LINK) |
- (BUTS_CONT_SEL|BUTS_CONT_ACT|BUTS_CONT_LINK) |
- (BUTS_ACT_SEL|BUTS_ACT_ACT|BUTS_ACT_LINK) |
- (BUTS_SENS_STATE|BUTS_ACT_STATE));
-
-
- /* header */
- ar= MEM_callocN(sizeof(ARegion), "header for logic");
-
- BLI_addtail(&slogic->regionbase, ar);
- ar->regiontype= RGN_TYPE_HEADER;
- ar->alignment= RGN_ALIGN_BOTTOM;
-
- /* buttons/list view */
- ar= MEM_callocN(sizeof(ARegion), "buttons for logic");
-
- BLI_addtail(&slogic->regionbase, ar);
- ar->regiontype= RGN_TYPE_UI;
- ar->alignment= RGN_ALIGN_RIGHT;
-
- /* main region */
- ar= MEM_callocN(sizeof(ARegion), "main region for logic");
-
- BLI_addtail(&slogic->regionbase, ar);
- ar->regiontype= RGN_TYPE_WINDOW;
-
- ar->v2d.tot.xmin = 0.0f;
- ar->v2d.tot.ymax = 0.0f;
- ar->v2d.tot.xmax = 1150.0f;
- ar->v2d.tot.ymin = ( 1150.0f/(float)sa->winx ) * (float)-sa->winy;
-
- ar->v2d.cur = ar->v2d.tot;
-
- ar->v2d.min[0] = 1.0f;
- ar->v2d.min[1] = 1.0f;
-
- ar->v2d.max[0] = 32000.0f;
- ar->v2d.max[1] = 32000.0f;
-
- ar->v2d.minzoom = 0.5f;
- ar->v2d.maxzoom = 1.5f;
-
- ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
- ar->v2d.keepzoom = V2D_KEEPZOOM | V2D_LIMITZOOM | V2D_KEEPASPECT;
- ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
- ar->v2d.align = V2D_ALIGN_NO_POS_Y | V2D_ALIGN_NO_NEG_X;
- ar->v2d.keepofs = V2D_KEEPOFS_Y;
-
- return (SpaceLink *)slogic;
-}
-
-/* not spacelink itself */
-static void logic_free(SpaceLink *UNUSED(sl))
-{
-// Spacelogic *slogic= (SpaceLogic *) sl;
-
-// if (slogic->gpd)
-// XXX BKE_gpencil_free(slogic->gpd);
-
-}
-
-
-/* spacetype; init callback */
-static void logic_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
-{
-
-}
-
-static SpaceLink *logic_duplicate(SpaceLink *sl)
-{
- SpaceLogic *slogicn= MEM_dupallocN(sl);
-
- return (SpaceLink *)slogicn;
-}
-
-static void logic_operatortypes(void)
-{
- WM_operatortype_append(LOGIC_OT_properties);
- WM_operatortype_append(LOGIC_OT_links_cut);
-}
-
-static void logic_keymap(struct wmKeyConfig *keyconf)
-{
- WM_keymap_ensure(keyconf, "Logic Editor", SPACE_LOGIC, 0);
-}
-
-static void logic_refresh(const bContext *UNUSED(C), ScrArea *UNUSED(sa))
-{
-// SpaceLogic *slogic= CTX_wm_space_logic(C);
-// Object *obedit= CTX_data_edit_object(C);
-
-}
-
-static void logic_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
-{
- /* context changes */
- switch (wmn->category) {
- case NC_LOGIC:
- ED_region_tag_redraw(ar);
- break;
- case NC_SCENE:
- switch (wmn->data) {
- case ND_FRAME:
- ED_region_tag_redraw(ar);
- break;
-
- case ND_OB_ACTIVE:
- ED_region_tag_redraw(ar);
- break;
- }
- break;
- case NC_OBJECT:
- break;
- case NC_ID:
- if (wmn->action == NA_RENAME)
- ED_region_tag_redraw(ar);
- break;
- }
-}
-
-static int logic_context(const bContext *UNUSED(C), const char *UNUSED(member), bContextDataResult *UNUSED(result))
-{
-// SpaceLogic *slogic= CTX_wm_space_logic(C);
- return 0;
-}
-
-/************************** main region ***************************/
-
-
-/* add handlers, stuff you only do once or on area/region changes */
-static void logic_main_region_init(wmWindowManager *wm, ARegion *ar)
-{
- wmKeyMap *keymap;
-
- UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
-
- /* own keymaps */
- keymap = WM_keymap_ensure(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0);
- WM_event_add_keymap_handler(&ar->handlers, keymap);
-}
-
-static void logic_main_region_draw(const bContext *C, ARegion *ar)
-{
- /* draw entirely, view changes should be handled here */
-// SpaceLogic *slogic= CTX_wm_space_logic(C);
- View2D *v2d= &ar->v2d;
- View2DScrollers *scrollers;
-
- /* clear and setup matrix */
- UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
-
- UI_view2d_view_ortho(v2d);
-
- logic_buttons((bContext *)C, ar);
-
- /* reset view matrix */
- UI_view2d_view_restore(C);
-
- /* scrollers */
- scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
- UI_view2d_scrollers_free(scrollers);
-
-}
-
-
-/* *********************** buttons region ************************ */
-
-/* add handlers, stuff you only do once or on area/region changes */
-static void logic_buttons_region_init(wmWindowManager *wm, ARegion *ar)
-{
- wmKeyMap *keymap;
-
- ED_region_panels_init(wm, ar);
-
- keymap = WM_keymap_ensure(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0);
- WM_event_add_keymap_handler(&ar->handlers, keymap);
-}
-
-static void logic_buttons_region_draw(const bContext *C, ARegion *ar)
-{
- ED_region_panels(C, ar, NULL, -1, true);
-}
-
-/************************* header region **************************/
-
-/* add handlers, stuff you only do once or on area/region changes */
-static void logic_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
-{
- ED_region_header_init(ar);
-}
-
-static void logic_header_region_draw(const bContext *C, ARegion *ar)
-{
- ED_region_header(C, ar);
-}
-
-/**************************** spacetype *****************************/
-
-static void logic_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
-{
- SpaceLogic *slog = (SpaceLogic *)slink;
-
- if (!ELEM(GS(old_id->name), ID_GD)) {
- return;
- }
-
- if ((ID *)slog->gpd == old_id) {
- slog->gpd = (bGPdata *)new_id;
- id_us_min(old_id);
- id_us_plus(new_id);
- }
-}
-
-/* only called once, from space/spacetypes.c */
-void ED_spacetype_logic(void)
-{
- SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype logic");
- ARegionType *art;
-
- st->spaceid = SPACE_LOGIC;
- strncpy(st->name, "Logic", BKE_ST_MAXNAME);
-
- st->new = logic_new;
- st->free = logic_free;
- st->init = logic_init;
- st->duplicate = logic_duplicate;
- st->operatortypes = logic_operatortypes;
- st->keymap = logic_keymap;
- st->refresh = logic_refresh;
- st->context = logic_context;
- st->id_remap = logic_id_remap;
-
- /* regions: main window */
- art = MEM_callocN(sizeof(ARegionType), "spacetype logic region");
- art->regionid = RGN_TYPE_WINDOW;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES | ED_KEYMAP_VIEW2D;
- art->init = logic_main_region_init;
- art->draw = logic_main_region_draw;
- art->listener = logic_listener;
-
- BLI_addhead(&st->regiontypes, art);
-
- /* regions: listview/buttons */
- art = MEM_callocN(sizeof(ARegionType), "spacetype logic region");
- art->regionid = RGN_TYPE_UI;
- art->prefsizex= 220; // XXX
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
- art->listener = logic_listener;
- art->init = logic_buttons_region_init;
- art->draw = logic_buttons_region_draw;
- BLI_addhead(&st->regiontypes, art);
-
- /* regions: header */
- art= MEM_callocN(sizeof(ARegionType), "spacetype logic region");
- art->regionid = RGN_TYPE_HEADER;
- art->prefsizey = HEADERY;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
- art->init = logic_header_region_init;
- art->draw = logic_header_region_draw;
-
- BLI_addhead(&st->regiontypes, art);
-
- BKE_spacetype_register(st);
-}
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index 9f634851c81..0dae0e20319 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -491,7 +491,7 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
/* 'push-down' action - only usable when not in TweakMode */
BKE_nla_action_pushdown(adt);
- DEG_id_tag_update_ex(CTX_data_main(C), id, DEG_TAG_TIME | DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(CTX_data_main(C), id, ID_RECALC_ANIMATION | ID_RECALC_COPY_ON_WRITE);
}
/* set notifier that things have changed */
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 65170c7c203..10ec293082f 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -921,7 +921,7 @@ static void node_shader_buts_tex_pointdensity(uiLayout *layout, bContext *UNUSED
static void node_shader_buts_tex_coord(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "object", 0, NULL, 0);
- uiItemR(layout, ptr, "from_dupli", 0, NULL, 0);
+ uiItemR(layout, ptr, "from_instancer", 0, NULL, 0);
}
static void node_shader_buts_bump(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -931,9 +931,9 @@ static void node_shader_buts_bump(uiLayout *layout, bContext *UNUSED(C), Pointer
static void node_shader_buts_uvmap(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
- uiItemR(layout, ptr, "from_dupli", 0, NULL, 0);
+ uiItemR(layout, ptr, "from_instancer", 0, NULL, 0);
- if (!RNA_boolean_get(ptr, "from_dupli")) {
+ if (!RNA_boolean_get(ptr, "from_instancer")) {
PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
@@ -2986,7 +2986,7 @@ void ED_node_init_butfuncs(void)
NodeSocketTypeUndefined.interface_draw_color = node_socket_undefined_interface_draw_color;
/* node type ui functions */
- NODE_TYPES_BEGIN(ntype)
+ NODE_TYPES_BEGIN(ntype) {
/* default ui functions */
ntype->draw_nodetype = node_draw_default;
ntype->draw_nodetype_prepare = node_update_default;
@@ -3004,7 +3004,7 @@ void ED_node_init_butfuncs(void)
/* define update callbacks for socket properties */
node_template_properties_update(ntype);
- NODE_TYPES_END
+ } NODE_TYPES_END;
/* tree type icons */
ntreeType_Composite->ui_icon = ICON_NODE_COMPOSITING;
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index f00b745a317..8ec6d9332d3 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -174,11 +174,11 @@ void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node)
/* look through all datablocks, to support groups */
if (do_tag_update) {
- FOREACH_NODETREE(bmain, tntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, tntree, id) {
/* check if nodetree uses the group */
if (ntreeHasTree(tntree, ntree))
ED_node_tag_update_id(id);
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
if (ntree->type == NTREE_TEXTURE)
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 746a37fe565..86b7ebf46b4 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -330,10 +330,10 @@ void snode_dag_update(bContext *C, SpaceNode *snode)
/* for groups, update all ID's using this */
if (snode->edittree != snode->nodetree) {
- FOREACH_NODETREE(bmain, tntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, tntree, id) {
if (ntreeHasTree(tntree, snode->edittree))
DEG_id_tag_update(id, 0);
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
}
DEG_id_tag_update(snode->id, 0);
@@ -2390,17 +2390,17 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
if (text) {
/* clear flags for recursion check */
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER)
ntree->done = false;
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
- FOREACH_NODETREE(bmain, ntree, id) {
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
if (!ntree->done)
found |= node_shader_script_update_text_recursive(engine, type, ntree, text);
}
- } FOREACH_NODETREE_END
+ } FOREACH_NODETREE_END;
if (!found)
BKE_report(op->reports, RPT_INFO, "Text not used by any node, no update done");
diff --git a/source/blender/editors/space_node/node_gizmo.c b/source/blender/editors/space_node/node_gizmo.c
index 6778ba8fb04..303962138a8 100644
--- a/source/blender/editors/space_node/node_gizmo.c
+++ b/source/blender/editors/space_node/node_gizmo.c
@@ -270,8 +270,8 @@ static void gizmo_node_crop_prop_matrix_get(
bool is_relative = (bool)node->custom2;
rctf rct;
two_xy_to_rect(nxy, &rct, dims, is_relative);
- matrix[0][0] = BLI_rctf_size_x(&rct);
- matrix[1][1] = BLI_rctf_size_y(&rct);
+ matrix[0][0] = fabsf(BLI_rctf_size_x(&rct));
+ matrix[1][1] = fabsf(BLI_rctf_size_y(&rct));
matrix[3][0] = (BLI_rctf_cent_x(&rct) - 0.5f) * dims[0];
matrix[3][1] = (BLI_rctf_cent_y(&rct) - 0.5f) * dims[1];
}
@@ -289,9 +289,17 @@ static void gizmo_node_crop_prop_matrix_set(
bool is_relative = (bool)node->custom2;
rctf rct;
two_xy_to_rect(nxy, &rct, dims, is_relative);
- BLI_rctf_resize(&rct, matrix[0][0], matrix[1][1]);
+ const bool nx = rct.xmin > rct.xmax;
+ const bool ny = rct.ymin > rct.ymax;
+ BLI_rctf_resize(&rct, fabsf(matrix[0][0]), fabsf(matrix[1][1]));
BLI_rctf_recenter(&rct, (matrix[3][0] / dims[0]) + 0.5f, (matrix[3][1] / dims[1]) + 0.5f);
BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, &rct, &rct);
+ if (nx) {
+ SWAP(float, rct.xmin, rct.xmax);
+ }
+ if (ny) {
+ SWAP(float, rct.ymin, rct.ymax);
+ }
two_xy_from_rect(nxy, &rct, dims, is_relative);
gizmo_node_crop_update(crop_group);
}
@@ -309,7 +317,7 @@ static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmGizmoGroupType *UNUS
if (node && ELEM(node->type, CMP_NODE_CROP)) {
/* ignore 'use_crop_size', we can't usefully edit the crop in this case. */
- if ((node->custom1 & (0 << 1)) == 0) {
+ if ((node->custom1 & (1 << 0)) == 0) {
return true;
}
}
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 3407c17bc67..78d01123d0c 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -200,7 +200,6 @@ void NODE_OT_preview_toggle(struct wmOperatorType *ot);
void NODE_OT_options_toggle(struct wmOperatorType *ot);
void NODE_OT_node_copy_color(struct wmOperatorType *ot);
-void NODE_OT_read_fullsamplelayers(struct wmOperatorType *ot);
void NODE_OT_read_viewlayers(struct wmOperatorType *ot);
void NODE_OT_render_changed(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index eb233f3fea1..465b7a6d789 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -560,16 +560,25 @@ static int node_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *ev
const bool tweak = RNA_boolean_get(op->ptr, "tweak");
if (tweak) {
- /* prevent initiating the box select if the mouse is over a node */
- /* this allows box select on empty space, but drag-translate on nodes */
+ /* prevent initiating the box select if the mouse is over a node or
+ * node socket. this allows box select on empty space, but drag-translate
+ * on nodes */
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
- float mx, my;
+ float mouse[2];
- UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my);
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mouse[0], &mouse[1]);
- if (node_under_mouse_tweak(snode->edittree, mx, my))
+ if (node_under_mouse_tweak(snode->edittree, mouse[0], mouse[1])) {
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
+ }
+
+ bNode *node;
+ bNodeSocket *sock;
+
+ if (node_find_indicated_socket(snode, &node, &sock, mouse, SOCK_IN | SOCK_OUT)) {
+ return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
+ }
}
return WM_gesture_box_invoke(C, op, event);
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index 47e9bc7fa26..e7a9db20103 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -460,8 +460,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
}
BLI_array_append(sorted_ntypes, ntype);
- }
- NODE_TYPES_END
+ } NODE_TYPES_END;
qsort(sorted_ntypes, BLI_array_len(sorted_ntypes), sizeof(bNodeType *), ui_node_item_name_compare);
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 85820ec3e13..8af5fe1b3a1 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -1014,10 +1014,12 @@ void ED_spacetype_node(void)
/* regions: toolbar */
art = MEM_callocN(sizeof(ARegionType), "spacetype view3d tools region");
art->regionid = RGN_TYPE_TOOLS;
- art->prefsizex = 160; /* XXX */
+ art->prefsizex = 58; /* XXX */
art->prefsizey = 50; /* XXX */
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
art->listener = node_region_listener;
+ art->message_subscribe = ED_region_generic_tools_region_message_subscribe;
+ art->snap_size = ED_region_generic_tools_region_snap_size;
art->init = node_toolbar_region_init;
art->draw = node_toolbar_region_draw;
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 460ba8b89fb..6b4a7e10e63 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -195,7 +195,7 @@ static int collection_new_exec(bContext *C, wmOperator *op)
}
}
- if (!data.collection && (soops->outlinevis == SO_VIEW_LAYER)) {
+ if (data.collection == NULL) {
data.collection = BKE_collection_master(scene);
}
@@ -204,7 +204,7 @@ static int collection_new_exec(bContext *C, wmOperator *op)
data.collection,
NULL);
- DEG_id_tag_update(&data.collection->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&data.collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
outliner_cleanup_tree(soops);
@@ -288,7 +288,7 @@ static int collection_delete_exec(bContext *C, wmOperator *op)
BLI_gset_free(data.collections_to_edit, NULL);
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
@@ -365,7 +365,7 @@ static int collection_objects_select_exec(bContext *C, wmOperator *op)
BKE_layer_collection_objects_select(view_layer, layer_collection, deselect);
Scene *scene = CTX_data_scene(C);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
@@ -505,7 +505,7 @@ 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_id_tag_update(&active_collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
@@ -558,7 +558,7 @@ static int collection_instance_exec(bContext *C, wmOperator *UNUSED(op))
/* Effectively instance the collections. */
GSET_ITER(collections_to_edit_iter, data.collections_to_edit) {
Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter);
- Object *ob = ED_object_add_type(C, OB_EMPTY, collection->id.name + 2, scene->cursor.location, NULL, false);
+ Object *ob = ED_object_add_type(C, OB_EMPTY, collection->id.name + 2, scene->cursor.location, NULL, false, 0);
ob->dup_group = collection;
ob->transflag |= OB_DUPLICOLLECTION;
id_lib_extern(&collection->id);
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index 2217048aca7..6dd12571448 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -588,7 +588,7 @@ static int scene_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
@@ -854,12 +854,12 @@ static int collection_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmE
}
if (from) {
- DEG_id_tag_update(&from->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&from->id, ID_RECALC_COPY_ON_WRITE);
}
}
/* Update dependency graph. */
- DEG_id_tag_update(&data.to->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&data.to->id, ID_RECALC_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_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 29864ac3680..c117c17f6be 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -292,7 +292,7 @@ static void hidebutton_base_flag_cb(bContext *C, void *poin, void *poin2)
view_layer->basact = base;
}
- DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
@@ -308,7 +308,7 @@ static void hidebutton_layer_collection_flag_cb(bContext *C, void *poin, void *p
BKE_layer_collection_set_visible(scene, view_layer, lc, extend);
- DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
@@ -339,7 +339,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
{
Object *ob = (Object *)tselem->id;
if (ob->type == OB_MBALL) {
- DEG_id_tag_update(&ob->id, DEG_TAG_GEOMETRY);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); break;
}
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index ce89e7e6d66..b5059cf6bb3 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -99,7 +99,7 @@ static int outliner_highlight_update(bContext *C, wmOperator *UNUSED(op), const
/* Drag and drop does own highlighting. */
wmWindowManager *wm = CTX_wm_manager(C);
if (wm->drags.first) {
- return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
+ return OPERATOR_PASS_THROUGH;
}
ARegion *ar = CTX_wm_region(C);
@@ -121,7 +121,7 @@ static int outliner_highlight_update(bContext *C, wmOperator *UNUSED(op), const
ED_region_tag_redraw_no_rebuild(ar);
}
- return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
+ return OPERATOR_PASS_THROUGH;
}
void OUTLINER_OT_highlight_update(wmOperatorType *ot)
@@ -921,7 +921,7 @@ static int outliner_select_all_exec(bContext *C, wmOperator *op)
break;
}
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
ED_region_tag_redraw_no_rebuild(ar);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index efe27b5be89..d9e069f75c2 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -85,7 +85,7 @@ static void do_outliner_activate_obdata(bContext *C, Scene *scene, ViewLayer *vi
if (obact == NULL) {
ED_object_base_activate(C, base);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
obact = base->object;
use_all = true;
@@ -109,7 +109,7 @@ static void do_outliner_activate_obdata(bContext *C, Scene *scene, ViewLayer *vi
}
if (ok) {
ED_object_base_select(base, (ob->mode & OB_MODE_EDIT) ? BA_SELECT : BA_DESELECT);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
}
@@ -124,7 +124,7 @@ static void do_outliner_activate_pose(bContext *C, ViewLayer *view_layer, Base *
if (obact == NULL) {
ED_object_base_activate(C, base);
Scene *scene = CTX_data_scene(C);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
obact = base->object;
use_all = true;
@@ -151,7 +151,7 @@ static void do_outliner_activate_pose(bContext *C, ViewLayer *view_layer, Base *
ED_object_base_select(base, (ob->mode & OB_MODE_POSE) ? BA_SELECT : BA_DESELECT);
Scene *scene = CTX_data_scene(C);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
@@ -318,7 +318,7 @@ static eOLDrawState tree_element_set_active_object(
if (set != OL_SETSEL_NONE) {
ED_object_base_activate(C, base); /* adds notifier */
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
@@ -376,7 +376,7 @@ static eOLDrawState tree_element_active_material(
/* Tagging object for update seems a bit stupid here, but looks like we have to do it
* for render views to update. See T42973.
* Note that RNA material update does it too, see e.g. rna_MaterialSlot_update(). */
- DEG_id_tag_update((ID *)ob, OB_RECALC_OB);
+ DEG_id_tag_update((ID *)ob, ID_RECALC_TRANSFORM);
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, NULL);
}
return OL_DRAWSEL_NONE;
@@ -462,7 +462,7 @@ static eOLDrawState tree_element_active_defgroup(
BLI_assert(te->index + 1 >= 0);
ob->actdef = te->index + 1;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
}
else {
@@ -1020,7 +1020,7 @@ static void do_outliner_item_activate_tree_element(
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
else if (OB_DATA_SUPPORT_EDITMODE(te->idcode)) {
@@ -1225,7 +1225,7 @@ static int outliner_box_select_exec(bContext *C, wmOperator *op)
outliner_item_box_select(scene, &rectf, te, select);
}
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
ED_region_tag_redraw(ar);
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index a9212a99eb8..5806cf28fa8 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -230,14 +230,14 @@ 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_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
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_id_tag_update(&parent->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
}
else if (GS(tsep->id->name) == ID_SCE) {
@@ -245,7 +245,7 @@ static void unlink_collection_cb(
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_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
}
}
@@ -262,14 +262,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_id_tag_update(&parent->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
}
else if (GS(tsep->id->name) == ID_SCE) {
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_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
}
}
@@ -796,12 +796,12 @@ static void modifier_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem
if (event == OL_MODIFIER_OP_TOGVIS) {
md->mode ^= eModifierMode_Realtime;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
}
else if (event == OL_MODIFIER_OP_TOGREN) {
md->mode ^= eModifierMode_Render;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
}
else if (event == OL_MODIFIER_OP_DELETE) {
@@ -894,7 +894,7 @@ static void object_delete_hierarchy_cb(
#endif
}
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
}
@@ -953,7 +953,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
}
str = "Select Objects";
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
else if (event == OL_OP_SELECT_HIERARCHY) {
@@ -963,13 +963,13 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
WM_window_set_active_scene(bmain, C, win, sce);
}
str = "Select Object Hierarchy";
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
else if (event == OL_OP_DESELECT) {
outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_deselect_cb);
str = "Deselect Objects";
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
else if (event == OL_OP_DELETE) {
@@ -984,7 +984,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain);
str = "Delete Objects";
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
}
else if (event == OL_OP_DELETE_HIERARCHY) {
@@ -995,7 +995,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain);
str = "Delete Object Hierarchy";
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
}
else if (event == OL_OP_REMAP) {
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 902235779cf..60467854e73 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -831,7 +831,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
/* loop over all targets used here */
- DRIVER_TARGETS_USED_LOOPER(dvar)
+ DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
{
if (lastadded != dtar->id) {
// XXX this lastadded check is rather lame, and also fails quite badly...
@@ -839,7 +839,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
lastadded = dtar->id;
}
}
- DRIVER_TARGETS_LOOPER_END
+ DRIVER_TARGETS_LOOPER_END;
}
}
}
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 74744f63321..e55b8d17cd4 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -219,8 +219,7 @@ static void seq_proxy_build_job(const bContext *C)
if ((seq->flag & SELECT)) {
BKE_sequencer_proxy_rebuild_context(pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue);
}
- }
- SEQ_END
+ } SEQ_END;
BLI_gset_free(file_list, MEM_freeN);
@@ -457,8 +456,7 @@ void ED_sequencer_deselect_all(Scene *scene)
SEQP_BEGIN (ed, seq)
{
seq->flag &= ~SEQ_ALLSEL;
- }
- SEQ_END
+ } SEQ_END;
}
@@ -647,8 +645,7 @@ static void del_seq_clear_modifiers_recurs(Scene *scene, Sequence *deleting_sequ
}
}
}
- }
- SEQ_END
+ } SEQ_END;
}
static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short deleteall)
@@ -995,8 +992,7 @@ static void set_filter_seq(Scene *scene)
}
}
- }
- SEQ_END
+ } SEQ_END;
}
#endif
@@ -1036,8 +1032,7 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene)
printf("new %s\n", seq->strip->dir);
}
}
- }
- SEQ_END
+ } SEQ_END;
}
@@ -3498,8 +3493,7 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
}
BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
}
- }
- SEQ_END
+ } SEQ_END;
BLI_gset_free(file_list, MEM_freeN);
@@ -3577,8 +3571,7 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
seq->strip->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING;
}
}
- }
- SEQ_END
+ } SEQ_END;
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
@@ -3926,8 +3919,7 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
if (seq->type == SEQ_TYPE_TEXT) {
BLI_addtail(&text_seq, MEM_dupallocN(seq));
}
- }
- SEQ_END
+ } SEQ_END;
if (BLI_listbase_is_empty(&text_seq)) {
BKE_report(op->reports, RPT_ERROR, "No subtitles (text strips) to export");
diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c
index 3c4481b32cb..1b2357ef6a5 100644
--- a/source/blender/editors/space_sequencer/sequencer_modifier.c
+++ b/source/blender/editors/space_sequencer/sequencer_modifier.c
@@ -247,8 +247,7 @@ static int strip_modifier_copy_exec(bContext *C, wmOperator *op)
BKE_sequence_modifier_list_copy(seq_iter, seq);
}
- }
- SEQ_END
+ } SEQ_END;
BKE_sequence_invalidate_cache(scene, seq);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 5fbe134b301..433f1ca8ee5 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -382,8 +382,8 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
seq->flag |= SELECT;
recurs_sel_seq(seq);
}
- }
- SEQ_END
+ } SEQ_END;
+
{
SpaceSeq *sseq = CTX_wm_space_seq(C);
if (sseq && sseq->flag & SEQ_MARKER_TRANS) {
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 61c7b479826..d1dd2f4affd 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -698,7 +698,7 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS
}
if (update) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
#endif
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
deleted file mode 100644
index 29cc5bafb17..00000000000
--- a/source/blender/editors/space_time/space_time.c
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * ***** 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) 2008 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_time/space_time.c
- * \ingroup sptime
- */
-
-
-#include <string.h>
-#include <stdio.h>
-
-#include "DNA_cachefile_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_gpencil_types.h"
-#include "DNA_modifier_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_dlrbTree.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_constraint.h"
-#include "BKE_context.h"
-#include "BKE_main.h"
-#include "BKE_modifier.h"
-#include "BKE_screen.h"
-#include "BKE_pointcache.h"
-
-#include "ED_anim_api.h"
-#include "ED_keyframes_draw.h"
-#include "ED_screen.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
-
-#include "UI_resources.h"
-#include "UI_view2d.h"
-#include "UI_interface.h"
-
-#include "ED_space_api.h"
-#include "ED_markers.h"
-
-#include "time_intern.h"
-
-/* ************************ main time area region *********************** */
-
-static void time_draw_sfra_efra(Scene *scene, View2D *v2d)
-{
- /* draw darkened area outside of active timeline
- * frame range used is preview range or scene range
- */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
-
- if (PSFRA < PEFRA) {
- glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
- glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
- }
- else {
- glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
- }
- glDisable(GL_BLEND);
-
- UI_ThemeColorShade(TH_BACK, -60);
- /* thin lines where the actual frames are */
- fdrawline((float)PSFRA, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
- fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax);
-}
-
-static void time_draw_cache(Main *bmain, SpaceTime *stime, Object *ob, Scene *scene)
-{
- PTCacheID *pid;
- ListBase pidlist;
- SpaceTimeCache *stc = stime->caches.first;
- const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize);
- float yoffs = 0.f;
-
- if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob))
- return;
-
- BKE_ptcache_ids_from_object(bmain, &pidlist, ob, scene, 0);
-
- /* iterate over pointcaches on the active object,
- * add spacetimecache and vertex array for each */
- for (pid = pidlist.first; pid; pid = pid->next) {
- float col[4], *fp;
- int i, sta = pid->cache->startframe, end = pid->cache->endframe;
- int len = (end - sta + 1) * 4;
-
- switch (pid->type) {
- case PTCACHE_TYPE_SOFTBODY:
- if (!(stime->cache_display & TIME_CACHE_SOFTBODY)) continue;
- break;
- case PTCACHE_TYPE_PARTICLES:
- if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue;
- break;
- case PTCACHE_TYPE_CLOTH:
- if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue;
- break;
- case PTCACHE_TYPE_SMOKE_DOMAIN:
- case PTCACHE_TYPE_SMOKE_HIGHRES:
- if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue;
- break;
- case PTCACHE_TYPE_DYNAMICPAINT:
- if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue;
- break;
- case PTCACHE_TYPE_RIGIDBODY:
- if (!(stime->cache_display & TIME_CACHE_RIGIDBODY)) continue;
- break;
- }
-
- if (pid->cache->cached_frames == NULL)
- continue;
-
- /* make sure we have stc with correct array length */
- if (stc == NULL || MEM_allocN_len(stc->array) != len * 2 * sizeof(float)) {
- if (stc) {
- MEM_freeN(stc->array);
- }
- else {
- stc = MEM_callocN(sizeof(SpaceTimeCache), "spacetimecache");
- BLI_addtail(&stime->caches, stc);
- }
-
- stc->array = MEM_callocN(len * 2 * sizeof(float), "SpaceTimeCache array");
- }
-
- /* fill the vertex array with a quad for each cached frame */
- for (i = sta, fp = stc->array; i <= end; i++) {
- if (pid->cache->cached_frames[i - sta]) {
- fp[0] = (float)i - 0.5f;
- fp[1] = 0.0;
- fp += 2;
-
- fp[0] = (float)i - 0.5f;
- fp[1] = 1.0;
- fp += 2;
-
- fp[0] = (float)i + 0.5f;
- fp[1] = 1.0;
- fp += 2;
-
- fp[0] = (float)i + 0.5f;
- fp[1] = 0.0;
- fp += 2;
- }
- }
-
- glPushMatrix();
- glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0);
- glScalef(1.0, cache_draw_height, 0.0);
-
- switch (pid->type) {
- case PTCACHE_TYPE_SOFTBODY:
- col[0] = 1.0; col[1] = 0.4; col[2] = 0.02;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_PARTICLES:
- col[0] = 1.0; col[1] = 0.1; col[2] = 0.02;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_CLOTH:
- col[0] = 0.1; col[1] = 0.1; col[2] = 0.75;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_SMOKE_DOMAIN:
- case PTCACHE_TYPE_SMOKE_HIGHRES:
- col[0] = 0.2; col[1] = 0.2; col[2] = 0.2;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_DYNAMICPAINT:
- col[0] = 1.0; col[1] = 0.1; col[2] = 0.75;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_RIGIDBODY:
- col[0] = 1.0; col[1] = 0.6; col[2] = 0.0;
- col[3] = 0.1;
- break;
- default:
- col[0] = 1.0; col[1] = 0.0; col[2] = 1.0;
- col[3] = 0.1;
- BLI_assert(0);
- break;
- }
- glColor4fv(col);
-
- glEnable(GL_BLEND);
-
- glRectf((float)sta, 0.0, (float)end, 1.0);
-
- col[3] = 0.4f;
- if (pid->cache->flag & PTCACHE_BAKED) {
- col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f;
- }
- else if (pid->cache->flag & PTCACHE_OUTDATED) {
- col[0] += 0.4f; col[1] += 0.4f; col[2] += 0.4f;
- }
- glColor4fv(col);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, stc->array);
- glDrawArrays(GL_QUADS, 0, (fp - stc->array) / 2);
- glDisableClientState(GL_VERTEX_ARRAY);
-
- glDisable(GL_BLEND);
-
- glPopMatrix();
-
- yoffs += cache_draw_height;
-
- stc = stc->next;
- }
-
- BLI_freelistN(&pidlist);
-
- /* free excessive caches */
- while (stc) {
- SpaceTimeCache *tmp = stc->next;
- BLI_remlink(&stime->caches, stc);
- MEM_freeN(stc->array);
- MEM_freeN(stc);
- stc = tmp;
- }
-}
-
-static void time_cache_free(SpaceTime *stime)
-{
- SpaceTimeCache *stc;
-
- for (stc = stime->caches.first; stc; stc = stc->next) {
- if (stc->array) {
- MEM_freeN(stc->array);
- stc->array = NULL;
- }
- }
-
- BLI_freelistN(&stime->caches);
-}
-
-static void time_cache_refresh(SpaceTime *stime)
-{
- /* Free previous caches to indicate full refresh */
- time_cache_free(stime);
-}
-
-/* helper function - find actkeycolumn that occurs on cframe, or the nearest one if not found */
-static ActKeyColumn *time_cfra_find_ak(ActKeyColumn *ak, float cframe)
-{
- ActKeyColumn *akn = NULL;
-
- /* sanity checks */
- if (ak == NULL)
- return NULL;
-
- /* check if this is a match, or whether it is in some subtree */
- if (cframe < ak->cfra)
- akn = time_cfra_find_ak(ak->left, cframe);
- else if (cframe > ak->cfra)
- akn = time_cfra_find_ak(ak->right, cframe);
-
- /* if no match found (or found match), just use the current one */
- if (akn == NULL)
- return ak;
- else
- return akn;
-}
-
-/* helper for time_draw_keyframes() */
-static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel)
-{
- bDopeSheet ads = {NULL};
- DLRBT_Tree keys;
- ActKeyColumn *ak;
-
- float fac1 = (GS(id->name) == ID_GD) ? 0.8f : 0.6f; /* draw GPencil keys taller, to help distinguish them */
- float fac2 = 1.0f - fac1;
-
- float ymin = v2d->tot.ymin;
- float ymax = v2d->tot.ymax * fac1 + ymin * fac2;
-
- /* init binarytree-list for getting keyframes */
- BLI_dlrbTree_init(&keys);
-
- /* init dopesheet settings */
- if (onlysel)
- ads.filterflag |= ADS_FILTER_ONLYSEL;
-
- /* populate tree with keyframe nodes */
- switch (GS(id->name)) {
- case ID_SCE:
- scene_to_keylist(&ads, (Scene *)id, &keys, NULL);
- break;
- case ID_OB:
- ob_to_keylist(&ads, (Object *)id, &keys, NULL);
- break;
- case ID_GD:
- gpencil_to_keylist(&ads, (bGPdata *)id, &keys);
- break;
- case ID_CF:
- cachefile_to_keylist(&ads, (CacheFile *)id, &keys, NULL);
- break;
- default:
- break;
- }
-
- /* build linked-list for searching */
- BLI_dlrbTree_linkedlist_sync(&keys);
-
- /* start drawing keyframes
- * - we use the binary-search capabilities of the tree to only start from
- * the first visible keyframe (last one can then be easily checked)
- * - draw within a single GL block to be faster
- */
- glBegin(GL_LINES);
- for (ak = time_cfra_find_ak(keys.root, v2d->cur.xmin);
- (ak) && (ak->cfra <= v2d->cur.xmax);
- ak = ak->next)
- {
- glVertex2f(ak->cfra, ymin);
- glVertex2f(ak->cfra, ymax);
- }
- glEnd(); // GL_LINES
-
- /* free temp stuff */
- BLI_dlrbTree_free(&keys);
-}
-
-static void time_draw_caches_keyframes(Main *bmain, Scene *scene, View2D *v2d, bool onlysel)
-{
- CacheFile *cache_file;
-
- for (cache_file = bmain->cachefiles.first;
- cache_file;
- cache_file = cache_file->id.next)
- {
- cache_file->draw_flag &= ~CACHEFILE_KEYFRAME_DRAWN;
- }
-
- for (Base *base = scene->base.first; base; base = base->next) {
- Object *ob = base->object;
-
- ModifierData *md = modifiers_findByType(ob, eModifierType_MeshSequenceCache);
-
- if (md) {
- MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
-
- cache_file = mcmd->cache_file;
-
- if (!cache_file || (cache_file->draw_flag & CACHEFILE_KEYFRAME_DRAWN) != 0) {
- continue;
- }
-
- cache_file->draw_flag |= CACHEFILE_KEYFRAME_DRAWN;
-
- time_draw_idblock_keyframes(v2d, (ID *)cache_file, onlysel);
- }
-
- for (bConstraint *con = ob->constraints.first; con; con = con->next) {
- if (con->type != CONSTRAINT_TYPE_TRANSFORM_CACHE) {
- continue;
- }
-
- bTransformCacheConstraint *data = con->data;
-
- cache_file = data->cache_file;
-
- if (!cache_file || (cache_file->draw_flag & CACHEFILE_KEYFRAME_DRAWN) != 0) {
- continue;
- }
-
- cache_file->draw_flag |= CACHEFILE_KEYFRAME_DRAWN;
-
- time_draw_idblock_keyframes(v2d, (ID *)cache_file, onlysel);
- }
- }
-}
-
-/* draw keyframe lines for timeline */
-static void time_draw_keyframes(const bContext *C, ARegion *ar)
-{
- Scene *scene = CTX_data_scene(C);
- Object *ob = CTX_data_active_object(C);
- View2D *v2d = &ar->v2d;
- bool onlysel = ((scene->flag & SCE_KEYS_NO_SELONLY) == 0);
-
- /* set this for all keyframe lines once and for all */
- glLineWidth(1.0);
-
- /* draw cache files keyframes (if available) */
- UI_ThemeColor(TH_TIME_KEYFRAME);
- time_draw_caches_keyframes(CTX_data_main(C), scene, v2d, onlysel);
-
- /* draw grease pencil keyframes (if available) */
- UI_ThemeColor(TH_TIME_GP_KEYFRAME);
- if (scene->gpd) {
- time_draw_idblock_keyframes(v2d, (ID *)scene->gpd, onlysel);
- }
- if (ob && ob->gpd) {
- time_draw_idblock_keyframes(v2d, (ID *)ob->gpd, onlysel);
- }
-
- /* draw scene keyframes first
- * - don't try to do this when only drawing active/selected data keyframes,
- * since this can become quite slow
- */
- if (onlysel == 0) {
- /* set draw color */
- UI_ThemeColorShade(TH_TIME_KEYFRAME, -50);
- time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel);
- }
-
- /* draw keyframes from selected objects
- * - only do the active object if in posemode (i.e. showing only keyframes for the bones)
- * OR the onlysel flag was set, which means that only active object's keyframes should
- * be considered
- */
- UI_ThemeColor(TH_TIME_KEYFRAME);
-
- if (ob && ((ob->mode == OB_MODE_POSE) || onlysel)) {
- /* draw keyframes for active object only */
- time_draw_idblock_keyframes(v2d, (ID *)ob, onlysel);
- }
- else {
- bool active_done = false;
-
- /* draw keyframes from all selected objects */
- CTX_DATA_BEGIN (C, Object *, obsel, selected_objects)
- {
- /* last arg is 0, since onlysel doesn't apply here... */
- time_draw_idblock_keyframes(v2d, (ID *)obsel, 0);
-
- /* if this object is the active one, set flag so that we don't draw again */
- if (obsel == ob)
- active_done = true;
- }
- CTX_DATA_END;
-
- /* if active object hasn't been done yet, draw it... */
- if (ob && (active_done == 0))
- time_draw_idblock_keyframes(v2d, (ID *)ob, 0);
- }
-}
-
-/* ---------------- */
-
-static void time_refresh(const bContext *UNUSED(C), ScrArea *sa)
-{
- /* find the main timeline region and refresh cache display*/
- ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
- if (ar) {
- SpaceTime *stime = (SpaceTime *)sa->spacedata.first;
- time_cache_refresh(stime);
- }
-}
-
-/* editor level listener */
-static void time_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn)
-{
-
- /* mainly for updating cache display */
- switch (wmn->category) {
- case NC_OBJECT:
- {
- switch (wmn->data) {
- case ND_BONE_SELECT:
- case ND_BONE_ACTIVE:
- case ND_POINTCACHE:
- case ND_MODIFIER:
- case ND_PARTICLE:
- case ND_KEYS:
- ED_area_tag_refresh(sa);
- ED_area_tag_redraw(sa);
- break;
- }
- break;
- }
- case NC_SCENE:
- {
- switch (wmn->data) {
- case ND_RENDER_RESULT:
- ED_area_tag_redraw(sa);
- break;
- case ND_OB_ACTIVE:
- case ND_FRAME:
- ED_area_tag_refresh(sa);
- break;
- case ND_FRAME_RANGE:
- {
- ARegion *ar;
- Scene *scene = wmn->reference;
-
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- ar->v2d.tot.xmin = (float)(SFRA - 4);
- ar->v2d.tot.xmax = (float)(EFRA + 4);
- break;
- }
- }
- break;
- }
- }
- break;
- }
- case NC_SPACE:
- {
- switch (wmn->data) {
- case ND_SPACE_CHANGED:
- ED_area_tag_refresh(sa);
- break;
- }
- break;
- }
- case NC_WM:
- {
- switch (wmn->data) {
- case ND_FILEREAD:
- ED_area_tag_refresh(sa);
- break;
- }
- break;
- }
- }
-}
-
-/* ---------------- */
-
-/* add handlers, stuff you only do once or on area/region changes */
-static void time_main_region_init(wmWindowManager *wm, ARegion *ar)
-{
- wmKeyMap *keymap;
-
- UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
-
- /* own keymap */
- keymap = WM_keymap_ensure(wm->defaultconf, "Timeline", SPACE_TIME, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-}
-
-static void time_main_region_draw(const bContext *C, ARegion *ar)
-{
- /* draw entirely, view changes should be handled here */
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
- SpaceTime *stime = CTX_wm_space_time(C);
- Object *obact = CTX_data_active_object(C);
- View2D *v2d = &ar->v2d;
- View2DGrid *grid;
- View2DScrollers *scrollers;
- int unit, flag = 0;
-
- /* clear and setup matrix */
- UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
-
- UI_view2d_view_ortho(v2d);
-
- /* grid */
- unit = (stime->flag & TIME_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS;
- grid = UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
- UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS));
- UI_view2d_grid_free(grid);
-
- ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
- /* start and end frame */
- time_draw_sfra_efra(scene, v2d);
-
- /* current frame */
- flag = DRAWCFRA_WIDE; /* this is only really needed on frames where there's a keyframe, but this will do... */
- if ((stime->flag & TIME_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS;
- if (stime->flag & TIME_CFRA_NUM) flag |= DRAWCFRA_SHOW_NUMBOX;
- ANIM_draw_cfra(C, v2d, flag);
-
- UI_view2d_view_ortho(v2d);
-
- /* keyframes */
- time_draw_keyframes(C, ar);
-
- /* markers */
- UI_view2d_view_orthoSpecial(ar, v2d, 1);
- ED_markers_draw(C, 0);
-
- /* caches */
- time_draw_cache(bmain, stime, obact, scene);
-
- /* callback */
- UI_view2d_view_ortho(v2d);
- ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
-
- /* reset view matrix */
- UI_view2d_view_restore(C);
-
- /* scrollers */
- scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
- UI_view2d_scrollers_free(scrollers);
-}
-
-static void time_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
-{
- /* context changes */
- switch (wmn->category) {
- case NC_SPACE:
- if (wmn->data == ND_SPACE_TIME)
- ED_region_tag_redraw(ar);
- break;
-
- case NC_ANIMATION:
- ED_region_tag_redraw(ar);
- break;
-
- case NC_SCENE:
- switch (wmn->data) {
- case ND_OB_SELECT:
- case ND_OB_ACTIVE:
- case ND_FRAME:
- case ND_FRAME_RANGE:
- case ND_KEYINGSET:
- case ND_RENDER_OPTIONS:
- ED_region_tag_redraw(ar);
- break;
- }
- break;
- case NC_GPENCIL:
- if (wmn->data == ND_DATA)
- ED_region_tag_redraw(ar);
- break;
- }
-}
-
-/* ************************ header time area region *********************** */
-
-/* add handlers, stuff you only do once or on area/region changes */
-static void time_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
-{
- ED_region_header_init(ar);
-}
-
-static void time_header_region_draw(const bContext *C, ARegion *ar)
-{
- ED_region_header(C, ar);
-}
-
-static void time_header_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
-{
- /* context changes */
- switch (wmn->category) {
- case NC_SCREEN:
- {
- if (wmn->data == ND_ANIMPLAY)
- ED_region_tag_redraw(ar);
- break;
- }
- case NC_SCENE:
- {
- switch (wmn->data) {
- case ND_RENDER_RESULT:
- case ND_OB_SELECT:
- case ND_FRAME:
- case ND_FRAME_RANGE:
- case ND_KEYINGSET:
- case ND_RENDER_OPTIONS:
- ED_region_tag_redraw(ar);
- break;
- }
- break;
- }
- case NC_SPACE:
- {
- if (wmn->data == ND_SPACE_TIME)
- ED_region_tag_redraw(ar);
- break;
- }
- }
-}
-
-/* ******************** default callbacks for time space ***************** */
-
-static SpaceLink *time_new(const bContext *C)
-{
- Scene *scene = CTX_data_scene(C);
- ARegion *ar;
- SpaceTime *stime;
-
- stime = MEM_callocN(sizeof(SpaceTime), "inittime");
-
- stime->spacetype = SPACE_TIME;
- stime->flag |= TIME_DRAWFRAMES;
-
- /* header */
- ar = MEM_callocN(sizeof(ARegion), "header for time");
-
- BLI_addtail(&stime->regionbase, ar);
- ar->regiontype = RGN_TYPE_HEADER;
- ar->alignment = RGN_ALIGN_BOTTOM;
-
- /* main region */
- ar = MEM_callocN(sizeof(ARegion), "main region for time");
-
- BLI_addtail(&stime->regionbase, ar);
- ar->regiontype = RGN_TYPE_WINDOW;
-
- ar->v2d.tot.xmin = (float)(SFRA - 4);
- ar->v2d.tot.ymin = 0.0f;
- ar->v2d.tot.xmax = (float)(EFRA + 4);
- ar->v2d.tot.ymax = 50.0f;
-
- ar->v2d.cur = ar->v2d.tot;
-
- ar->v2d.min[0] = 1.0f;
- ar->v2d.min[1] = 50.0f;
-
- ar->v2d.max[0] = MAXFRAMEF;
- ar->v2d.max[1] = 50.0;
-
- ar->v2d.minzoom = 0.1f;
- ar->v2d.maxzoom = 10.0;
-
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
- ar->v2d.keepofs |= V2D_LOCKOFS_Y;
- ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
-
-
- return (SpaceLink *)stime;
-}
-
-/* not spacelink itself */
-static void time_free(SpaceLink *sl)
-{
- SpaceTime *stime = (SpaceTime *)sl;
-
- time_cache_free(stime);
-}
-/* spacetype; init callback in ED_area_initialize() */
-/* init is called to (re)initialize an existing editor (file read, screen changes) */
-/* validate spacedata, add own area level handlers */
-static void time_init(wmWindowManager *UNUSED(wm), ScrArea *sa)
-{
- SpaceTime *stime = (SpaceTime *)sa->spacedata.first;
-
- time_cache_free(stime);
-
- /* enable all cache display */
- stime->cache_display |= TIME_CACHE_DISPLAY;
- stime->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES);
- stime->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT);
- stime->cache_display |= TIME_CACHE_RIGIDBODY;
-}
-
-static SpaceLink *time_duplicate(SpaceLink *sl)
-{
- SpaceTime *stime = (SpaceTime *)sl;
- SpaceTime *stimen = MEM_dupallocN(stime);
-
- BLI_listbase_clear(&stimen->caches);
-
- return (SpaceLink *)stimen;
-}
-
-/* only called once, from space_api/spacetypes.c */
-/* it defines all callbacks to maintain spaces */
-void ED_spacetype_time(void)
-{
- SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time");
- ARegionType *art;
-
- st->spaceid = SPACE_TIME;
- strncpy(st->name, "Timeline", BKE_ST_MAXNAME);
-
- st->new = time_new;
- st->free = time_free;
- st->init = time_init;
- st->duplicate = time_duplicate;
- st->operatortypes = time_operatortypes;
- st->keymap = NULL;
- st->listener = time_listener;
- st->refresh = time_refresh;
-
- /* regions: main window */
- art = MEM_callocN(sizeof(ARegionType), "spacetype time region");
- art->regionid = RGN_TYPE_WINDOW;
- art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
-
- art->init = time_main_region_init;
- art->draw = time_main_region_draw;
- art->listener = time_main_region_listener;
- art->keymap = time_keymap;
- art->lock = 1; /* Due to pointcache, see T4960. */
- BLI_addhead(&st->regiontypes, art);
-
- /* regions: header */
- art = MEM_callocN(sizeof(ARegionType), "spacetype time region");
- art->regionid = RGN_TYPE_HEADER;
- art->prefsizey = HEADERY;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
-
- art->init = time_header_region_init;
- art->draw = time_header_region_draw;
- art->listener = time_header_region_listener;
- BLI_addhead(&st->regiontypes, art);
-
- BKE_spacetype_register(st);
-}
diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c
deleted file mode 100644
index 6962af52bb1..00000000000
--- a/source/blender/editors/space_time/time_ops.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * ***** 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) 2008 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_time/time_ops.c
- * \ingroup sptime
- */
-
-
-#include <stdlib.h>
-#include <math.h>
-
-#include "DNA_scene_types.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_context.h"
-
-#include "ED_anim_api.h"
-#include "ED_screen.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "time_intern.h"
-
-/* ****************** Start/End Frame Operators *******************************/
-static int time_set_sfra_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Scene *scene = CTX_data_scene(C);
- int frame;
-
- if (scene == NULL)
- return OPERATOR_CANCELLED;
-
- frame = CFRA;
-
- /* if Preview Range is defined, set the 'start' frame for that */
- if (PRVRANGEON)
- scene->r.psfra = frame;
- else
- scene->r.sfra = frame;
-
- if (PEFRA < frame) {
- if (PRVRANGEON)
- scene->r.pefra = frame;
- else
- scene->r.efra = frame;
- }
-
- WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
-
- return OPERATOR_FINISHED;
-}
-
-static void TIME_OT_start_frame_set(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Set Start Frame";
- ot->idname = "TIME_OT_start_frame_set";
- ot->description = "Set the start frame";
-
- /* api callbacks */
- ot->exec = time_set_sfra_exec;
- ot->poll = ED_operator_timeline_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-
-static int time_set_efra_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Scene *scene = CTX_data_scene(C);
- int frame;
-
- if (scene == NULL)
- return OPERATOR_CANCELLED;
-
- frame = CFRA;
-
- /* if Preview Range is defined, set the 'end' frame for that */
- if (PRVRANGEON)
- scene->r.pefra = frame;
- else
- scene->r.efra = frame;
-
- if (PSFRA > frame) {
- if (PRVRANGEON)
- scene->r.psfra = frame;
- else
- scene->r.sfra = frame;
- }
-
- WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
-
- return OPERATOR_FINISHED;
-}
-
-static void TIME_OT_end_frame_set(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Set End Frame";
- ot->idname = "TIME_OT_end_frame_set";
- ot->description = "Set the end frame";
-
- /* api callbacks */
- ot->exec = time_set_efra_exec;
- ot->poll = ED_operator_timeline_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-/* ************************ View All Operator *******************************/
-
-static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Scene *scene = CTX_data_scene(C);
- ARegion *ar = CTX_wm_region(C);
-
- if (ELEM(NULL, scene, ar))
- return OPERATOR_CANCELLED;
-
- View2D *v2d = &ar->v2d;
-
- /* set extents of view to start/end frames (Preview Range too) */
- v2d->cur.xmin = (float)PSFRA;
- v2d->cur.xmax = (float)PEFRA;
-
- /* we need an extra "buffer" factor on either side so that the endpoints are visible */
- const float extra = 0.01f * BLI_rctf_size_x(&v2d->cur);
- v2d->cur.xmin -= extra;
- v2d->cur.xmax += extra;
-
- /* this only affects this TimeLine instance, so just force redraw of this region */
- ED_region_tag_redraw(ar);
-
- return OPERATOR_FINISHED;
-}
-
-static void TIME_OT_view_all(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "View All";
- ot->idname = "TIME_OT_view_all";
- ot->description = "Show the entire playable frame range";
-
- /* api callbacks */
- ot->exec = time_view_all_exec;
- ot->poll = ED_operator_timeline_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-/* ************************ View Frame Operator *******************************/
-
-static int time_view_frame_exec(bContext *C, wmOperator *op)
-{
- const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
- ANIM_center_frame(C, smooth_viewtx);
-
- return OPERATOR_FINISHED;
-}
-
-static void TIME_OT_view_frame(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "View Frame";
- ot->idname = "TIME_OT_view_frame";
- ot->description = "Reset viewable area to show range around current frame";
-
- /* api callbacks */
- ot->exec = time_view_frame_exec;
- ot->poll = ED_operator_timeline_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-/* ************************** registration **********************************/
-
-void time_operatortypes(void)
-{
- WM_operatortype_append(TIME_OT_start_frame_set);
- WM_operatortype_append(TIME_OT_end_frame_set);
- WM_operatortype_append(TIME_OT_view_all);
- WM_operatortype_append(TIME_OT_view_frame);
-}
-
-void time_keymap(wmKeyConfig *keyconf)
-{
- WM_keymap_ensure(keyconf, "Timeline", SPACE_TIME, 0);
-}
diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c
index 06c6e612f13..87da461f269 100644
--- a/source/blender/editors/space_userpref/space_userpref.c
+++ b/source/blender/editors/space_userpref/space_userpref.c
@@ -47,6 +47,8 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "UI_interface.h"
+
/* ******************** default callbacks for userpref space ***************** */
@@ -59,6 +61,13 @@ static SpaceLink *userpref_new(const ScrArea *UNUSED(area), const Scene *UNUSED(
spref = MEM_callocN(sizeof(SpaceUserPref), "inituserpref");
spref->spacetype = SPACE_USERPREF;
+ /* navigation region */
+ ar = MEM_callocN(sizeof(ARegion), "navigation region for userpref");
+
+ BLI_addtail(&spref->regionbase, ar);
+ ar->regiontype = RGN_TYPE_NAV_BAR;
+ ar->alignment = RGN_ALIGN_LEFT;
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for userpref");
@@ -136,6 +145,19 @@ static void userpref_header_region_draw(const bContext *C, ARegion *ar)
ED_region_header(C, ar);
}
+/* add handlers, stuff you only do once or on area/region changes */
+static void userpref_navigation_region_init(wmWindowManager *wm, ARegion *ar)
+{
+ ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
+
+ ED_region_panels_init(wm, ar);
+}
+
+static void userpref_navigation_region_draw(const bContext *C, ARegion *ar)
+{
+ ED_region_panels(C, ar);
+}
+
static void userpref_main_region_listener(
wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
@@ -156,6 +178,13 @@ static void userpref_header_listener(
#endif
}
+static void userpref_navigation_region_listener(
+ wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
+ wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
+{
+ /* context changes */
+}
+
/* only called once, from space/spacetypes.c */
void ED_spacetype_userpref(void)
{
@@ -193,6 +222,17 @@ void ED_spacetype_userpref(void)
BLI_addhead(&st->regiontypes, art);
+ /* regions: navigation window */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype userpref region");
+ art->regionid = RGN_TYPE_NAV_BAR;
+ art->prefsizex = UI_NAVIGATION_REGION_WIDTH;
+ art->init = userpref_navigation_region_init;
+ art->draw = userpref_navigation_region_draw;
+ art->listener = userpref_navigation_region_listener;
+ art->keymapflag = ED_KEYMAP_UI;
+
+ BLI_addhead(&st->regiontypes, art);
+
BKE_spacetype_register(st);
}
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index 0d30d623b8d..44089734e83 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -66,7 +66,6 @@ set(SRC
view3d_gizmo_preselect_type.c
view3d_ops.c
view3d_project.c
- view3d_ruler.c
view3d_select.c
view3d_snap.c
view3d_toolbar.c
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 9a73ef25819..bb574874cad 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -295,8 +295,9 @@ static void bbs_mesh_solid_verts(Depsgraph *UNUSED(depsgraph), Scene *UNUSED(sce
static void bbs_mesh_solid_faces(Scene *UNUSED(scene), Object *ob)
{
Mesh *me = ob->data;
+ Mesh *me_orig = DEG_get_original_object(ob)->data;
GPUBatch *batch;
- if ((me->editflag & ME_EDIT_PAINT_FACE_SEL)) {
+ if ((me_orig->editflag & ME_EDIT_PAINT_FACE_SEL)) {
batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, true, 1);
}
else {
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index 0c4e370ef8c..357d04e0ce9 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -782,7 +782,7 @@ static void do_view3d_vgroup_buttons(bContext *C, void *UNUSED(arg), int event)
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = view_layer->basact->object;
ED_vgroup_vert_active_mirror(ob, event - B_VGRP_PNL_EDIT_SINGLE);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
}
}
@@ -1117,7 +1117,7 @@ static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event
case B_OBJECTPANELMEDIAN:
if (ob) {
v3d_editvertex_buts(NULL, v3d, ob, 1.0);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
break;
}
diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c
index 24871e16db6..15edce3fc87 100644
--- a/source/blender/editors/space_view3d/view3d_camera_control.c
+++ b/source/blender/editors/space_view3d/view3d_camera_control.c
@@ -243,7 +243,7 @@ void ED_view3d_cameracontrol_update(
ob_update = v3d->camera->parent;
while (ob_update) {
- DEG_id_tag_update(&ob_update->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob_update->id, ID_RECALC_TRANSFORM);
ob_update = ob_update->parent;
}
@@ -265,7 +265,7 @@ void ED_view3d_cameracontrol_update(
BKE_object_apply_mat4(v3d->camera, view_mat, true, true);
- DEG_id_tag_update(&v3d->camera->id, OB_RECALC_OB);
+ DEG_id_tag_update(&v3d->camera->id, ID_RECALC_TRANSFORM);
copy_v3_v3(v3d->camera->size, size_back);
@@ -300,7 +300,7 @@ void ED_view3d_cameracontrol_release(
/* store the original camera loc and rot */
BKE_object_tfm_restore(ob_back, vctrl->obtfm);
- DEG_id_tag_update(&ob_back->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob_back->id, ID_RECALC_TRANSFORM);
}
else {
/* Non Camera we need to reset the view back to the original location because the user canceled*/
@@ -312,7 +312,7 @@ void ED_view3d_cameracontrol_release(
rv3d->dist = vctrl->dist_backup;
}
else if (vctrl->persp_backup == RV3D_CAMOB) { /* camera */
- DEG_id_tag_update((ID *)view3d_cameracontrol_object(vctrl), OB_RECALC_OB);
+ DEG_id_tag_update((ID *)view3d_cameracontrol_object(vctrl), ID_RECALC_TRANSFORM);
/* always, is set to zero otherwise */
copy_v3_v3(rv3d->ofs, vctrl->ofs_backup);
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 4f572e3a337..b9db773aaee 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -802,7 +802,7 @@ float ED_view3d_grid_view_scale(
}
}
- return v3d->grid * grid_scale;
+ return grid_scale;
}
static void draw_view_axis(RegionView3D *rv3d, const rcti *rect)
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index abb6fed965e..2bc680bcbeb 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -2712,7 +2712,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op)
if (center) {
/* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */
- View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
+ View3DCursor *cursor = &scene->cursor;
zero_v3(min);
zero_v3(max);
zero_v3(cursor->location);
@@ -2734,6 +2734,11 @@ static int view3d_all_exec(bContext *C, wmOperator *op)
BKE_object_minmax(base_eval->object, min, max, false);
}
}
+
+ if (center) {
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
+ }
+
if (!changed) {
ED_region_tag_redraw(ar);
/* TODO - should this be cancel?
@@ -2753,10 +2758,6 @@ static int view3d_all_exec(bContext *C, wmOperator *op)
view3d_from_minmax(C, v3d, ar, min, max, true, smooth_viewtx);
}
- if (center) {
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
- }
-
return OPERATOR_FINISHED;
}
@@ -2847,19 +2848,25 @@ static int viewselected_exec(bContext *C, wmOperator *op)
}
else if (ob_eval && (ob_eval->type == OB_GPENCIL)) {
ok |= BKE_gpencil_data_minmax(ob_eval, gpd, min, max);
+ /* if no strokes, use object location */
+ if ((ob_eval) && (!ok)) {
+ copy_v3_v3(min, ob_eval->obmat[3]);
+ copy_v3_v3(max, ob_eval->obmat[3]);
+ ok = true;
+ }
}
else if (is_face_map) {
ok = WM_gizmomap_minmax(ar->gizmo_map, true, true, min, max);
}
else if (obedit) {
/* only selected */
- FOREACH_OBJECT_IN_MODE_BEGIN (view_layer_eval, obedit->mode, ob_eval_iter) {
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer_eval, v3d, obedit->type, obedit->mode, ob_eval_iter) {
ok |= ED_view3d_minmax_verts(ob_eval_iter, min, max);
}
FOREACH_OBJECT_IN_MODE_END;
}
else if (ob_eval && (ob_eval->mode & OB_MODE_POSE)) {
- FOREACH_OBJECT_IN_MODE_BEGIN (view_layer_eval, ob_eval->mode, ob_eval_iter) {
+ FOREACH_OBJECT_IN_MODE_BEGIN (view_layer_eval, v3d, ob_eval->type, ob_eval->mode, ob_eval_iter) {
ok |= BKE_pose_minmax(ob_eval_iter, min, max, true, true);
}
FOREACH_OBJECT_IN_MODE_END;
@@ -3043,7 +3050,7 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *op)
/* non camera center */
float new_ofs[3];
- negate_v3_v3(new_ofs, ED_view3d_cursor3d_get(scene, v3d)->location);
+ negate_v3_v3(new_ofs, scene->cursor.location);
ED_view3d_smooth_view(
C, v3d, ar, smooth_viewtx,
&(const V3D_SmoothParams) {.ofs = new_ofs});
@@ -3276,7 +3283,7 @@ static int render_border_exec(bContext *C, wmOperator *op)
}
if (rv3d->persp == RV3D_CAMOB) {
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
}
return OPERATOR_FINISHED;
}
@@ -3336,7 +3343,7 @@ static int clear_render_border_exec(bContext *C, wmOperator *UNUSED(op))
border->ymax = 1.0f;
if (rv3d->persp == RV3D_CAMOB) {
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
}
return OPERATOR_FINISHED;
}
@@ -4755,7 +4762,7 @@ void ED_view3d_cursor3d_update(
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ar->regiondata;
- View3DCursor *cursor_curr = ED_view3d_cursor3d_get(scene, v3d);
+ View3DCursor *cursor_curr = &scene->cursor;
View3DCursor cursor_prev = *cursor_curr;
ED_view3d_cursor3d_position_rotation(
@@ -4795,7 +4802,7 @@ void ED_view3d_cursor3d_update(
mbus, &scene->id, scene, Scene, cursor_location);
}
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
}
static int view3d_cursor3d_invoke(bContext *C, wmOperator *op, const wmEvent *event)
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 345d9fe39de..de5d5d29e52 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -195,7 +195,7 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar),
int xoff, yoff;
float x1, x2, y1, y2;
- if (fly->scene->camera) {
+ if (ED_view3d_cameracontrol_object_get(fly->v3d_camera_control)) {
ED_view3d_calc_camera_border(fly->scene, fly->depsgraph, fly->ar, fly->v3d, fly->rv3d, &viewborder, false);
xoff = viewborder.xmin;
yoff = viewborder.ymin;
@@ -297,7 +297,6 @@ enum {
static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent *event)
{
wmWindow *win = CTX_wm_window(C);
-
rctf viewborder;
float upvec[3]; /* tmp */
@@ -377,7 +376,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
(U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);
/* calculate center */
- if (fly->scene->camera) {
+ if (ED_view3d_cameracontrol_object_get(fly->v3d_camera_control)) {
ED_view3d_calc_camera_border(fly->scene, fly->depsgraph, fly->ar, fly->v3d, fly->rv3d, &viewborder, false);
fly->width = BLI_rctf_size_x(&viewborder);
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_armature.c b/source/blender/editors/space_view3d/view3d_gizmo_armature.c
index eea906620a6..0a3d20979a0 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_armature.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_armature.c
@@ -59,7 +59,7 @@
/*
* TODO(campbell): Current conversion is a approximation (usable not correct),
* we'll need to take the next/previous bones into account to get the tangent directions.
- * First last matrices from 'b_bone_spline_setup' are close but also not quite accurate
+ * First last matrices from 'BKE_pchan_bbone_spline_setup' are close but also not quite accurate
* since they're not at either end-points on the curve.
*
* Likely we'll need a function especially to get the first/last orientations.
@@ -133,7 +133,8 @@ static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType
if (ob != NULL) {
const bArmature *arm = ob->data;
if (arm->drawtype == ARM_B_BONE) {
- if (arm->act_bone && arm->act_bone->segments > 1) {
+ bPoseChannel *pchan = BKE_pose_channel_active(ob);
+ if (pchan && pchan->bone->segments > 1) {
View3D *v3d = CTX_wm_view3d(C);
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c
index 0878bef98f2..c80a11cbf16 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c
@@ -224,7 +224,7 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup)
(ca->drawsize * range) :
(scale_matrix * range /
/* Half sensor, intentionally use sensor from camera and not calculated above. */
- (0.5f * ((ca->sensor_fit == CAMERA_SENSOR_FIT_HOR) ? ca->sensor_x : ca->sensor_x))));
+ (0.5f * ((sensor_fit == CAMERA_SENSOR_FIT_HOR) ? ca->sensor_x : ca->sensor_y))));
WM_gizmo_target_property_def_rna_ptr(widget, gz_prop_type, &camera_ptr, prop, -1);
}
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_empty.c b/source/blender/editors/space_view3d/view3d_gizmo_empty.c
index 9ce0041c76c..58cfeba0480 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_empty.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_empty.c
@@ -96,7 +96,7 @@ static void gizmo_empty_image_prop_matrix_set(
Object *ob = igzgroup->state.ob;
ob->empty_drawsize = matrix[0][0];
- DEG_id_tag_update(&ob->id, DEG_TAG_TRANSFORM);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
float dims[2];
RNA_float_get_array(gz->ptr, "dimensions", dims);
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
index 6cd94830fe9..be07928d5fc 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
@@ -107,12 +107,13 @@ static int gizmo_preselect_elem_test_select(
{
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
if (((gz_ele->bases)) == NULL ||
(gz_ele->bases[0] != view_layer->basact))
{
MEM_SAFE_FREE(gz_ele->bases);
gz_ele->bases = BKE_view_layer_array_from_bases_in_edit_mode(
- view_layer, &gz_ele->bases_len);
+ view_layer, v3d, &gz_ele->bases_len);
}
}
@@ -298,12 +299,13 @@ static int gizmo_preselect_edgering_test_select(
{
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
if (((gz_ring->bases)) == NULL ||
(gz_ring->bases[0] != view_layer->basact))
{
MEM_SAFE_FREE(gz_ring->bases);
gz_ring->bases = BKE_view_layer_array_from_bases_in_edit_mode(
- view_layer, &gz_ring->bases_len);
+ view_layer, v3d, &gz_ring->bases_len);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
index 96fbe1d48a6..83db61f9e5a 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
@@ -306,13 +306,13 @@ static bool view3d_ruler_item_mousemove(
RulerInfo *ruler_info, RulerItem *ruler_item, const int mval[2],
const bool do_thickness, const bool do_snap)
{
- RulerInteraction *inter = ruler_item->gz.interaction_data;
const float eps_bias = 0.0002f;
float dist_px = MVAL_MAX_PX_DIST * U.pixelsize; /* snap dist */
ruler_info->snap_flag &= ~RULER_SNAP_OK;
if (ruler_item) {
+ RulerInteraction *inter = ruler_item->gz.interaction_data;
float *co = ruler_item->co[inter->co_index];
/* restore the initial depth */
copy_v3_v3(co, inter->drag_start_co);
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 05f2d8f67e1..164c444d9a5 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -171,10 +171,13 @@ void VIEW3D_OT_select_box(struct wmOperatorType *ot);
void VIEW3D_OT_select_lasso(struct wmOperatorType *ot);
void VIEW3D_OT_select_menu(struct wmOperatorType *ot);
+/* view3d_view.c */
void VIEW3D_OT_smoothview(struct wmOperatorType *ot);
void VIEW3D_OT_camera_to_view(struct wmOperatorType *ot);
void VIEW3D_OT_camera_to_view_selected(struct wmOperatorType *ot);
void VIEW3D_OT_object_as_camera(struct wmOperatorType *ot);
+void VIEW3D_OT_localview(struct wmOperatorType *ot);
+void VIEW3D_OT_localview_remove_from(struct wmOperatorType *ot);
bool ED_view3d_boundbox_clip_ex(const RegionView3D *rv3d, const struct BoundBox *bb, float obmat[4][4]);
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const struct BoundBox *bb);
diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c
index 3d0b0a7a348..9ee7cbabd2a 100644
--- a/source/blender/editors/space_view3d/view3d_iterators.c
+++ b/source/blender/editors/space_view3d/view3d_iterators.c
@@ -119,7 +119,10 @@ void meshobject_foreachScreenVert(
foreachScreenObjectVert_userData data;
Mesh *me;
- me = mesh_get_eval_deform(vc->depsgraph, vc->scene, vc->obact, CD_MASK_BAREMESH);
+ Scene *scene_eval = DEG_get_evaluated_scene(vc->depsgraph);
+ Object *ob_eval = DEG_get_evaluated_object(vc->depsgraph, vc->obact);
+
+ me = mesh_get_eval_deform(vc->depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
@@ -159,7 +162,7 @@ void mesh_foreachScreenVert(
{
foreachScreenVert_userData data;
- Mesh *me = editbmesh_get_eval_cage(vc->depsgraph, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+ Mesh *me = editbmesh_get_eval_cage_from_orig(vc->depsgraph, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
@@ -212,7 +215,7 @@ void mesh_foreachScreenEdge(
{
foreachScreenEdge_userData data;
- Mesh *me = editbmesh_get_eval_cage(vc->depsgraph, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+ Mesh *me = editbmesh_get_eval_cage_from_orig(vc->depsgraph, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
@@ -257,7 +260,7 @@ void mesh_foreachScreenFace(
{
foreachScreenFace_userData data;
- Mesh *me = editbmesh_get_eval_cage(vc->depsgraph, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+ Mesh *me = editbmesh_get_eval_cage_from_orig(vc->depsgraph, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
data.vc = *vc;
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 2dbe0a0b843..46a00ffeacf 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -204,10 +204,11 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_camera_to_view);
WM_operatortype_append(VIEW3D_OT_camera_to_view_selected);
WM_operatortype_append(VIEW3D_OT_object_as_camera);
+ WM_operatortype_append(VIEW3D_OT_localview);
+ WM_operatortype_append(VIEW3D_OT_localview_remove_from);
WM_operatortype_append(VIEW3D_OT_fly);
WM_operatortype_append(VIEW3D_OT_walk);
WM_operatortype_append(VIEW3D_OT_navigate);
- WM_operatortype_append(VIEW3D_OT_ruler);
WM_operatortype_append(VIEW3D_OT_copybuffer);
WM_operatortype_append(VIEW3D_OT_pastebuffer);
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
deleted file mode 100644
index 208f147f943..00000000000
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ /dev/null
@@ -1,1123 +0,0 @@
-/*
- * ***** 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): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_view3d/view3d_ruler.c
- * \ingroup spview3d
- */
-
-/* defines VIEW3D_OT_ruler modal operator */
-
-#include "DNA_meshdata_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_object_types.h"
-#include "DNA_gpencil_types.h"
-#include "DNA_brush_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
-
-#include "BLT_translation.h"
-
-#include "BKE_context.h"
-#include "BKE_gpencil.h"
-#include "BKE_main.h"
-#include "BKE_material.h"
-#include "BKE_unit.h"
-
-#include "BIF_gl.h"
-
-#include "GPU_immediate.h"
-#include "GPU_immediate_util.h"
-#include "GPU_state.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "ED_gpencil.h"
-#include "ED_screen.h"
-#include "ED_view3d.h"
-#include "ED_transform_snap_object_context.h"
-#include "ED_space_api.h"
-
-#include "BLF_api.h"
-#include "BIF_glutil.h"
-
-#include "UI_resources.h"
-#include "UI_interface.h"
-
-#include "view3d_intern.h" /* own include */
-
-#define MVAL_MAX_PX_DIST 12.0f
-
-
-/* -------------------------------------------------------------------- */
-/* Ruler Item (we can have many) */
-enum {
- RULERITEM_USE_ANGLE = (1 << 0), /* use protractor */
- RULERITEM_USE_RAYCAST = (1 << 1)
-};
-
-enum {
- RULERITEM_DIRECTION_IN = 0,
- RULERITEM_DIRECTION_OUT
-};
-
-/* keep smaller then selection, since we may want click elsewhere without selecting a ruler */
-#define RULER_PICK_DIST 12.0f
-#define RULER_PICK_DIST_SQ (RULER_PICK_DIST * RULER_PICK_DIST)
-
-typedef struct RulerItem {
- struct RulerItem *next, *prev;
-
- /* worldspace coords, middle being optional */
- float co[3][3];
-
- /* selected coord */
- char co_index; /* 0 -> 2*/
-
- int flag;
- int raycast_dir; /* RULER_DIRECTION_* */
-} RulerItem;
-
-
-/* -------------------------------------------------------------------- */
-/* Ruler Info (one per session) */
-
-enum {
- RULER_STATE_NORMAL = 0,
- RULER_STATE_DRAG
-};
-
-enum {
- RULER_SNAP_OK = (1 << 0),
-};
-
-typedef struct RulerInfo {
- ListBase items;
- int item_active;
- int flag;
- int snap_flag;
- int state;
- float drag_start_co[3];
-
- struct SnapObjectContext *snap_context;
-
- /* wm state */
- wmWindow *win;
- ScrArea *sa;
- void *draw_handle_pixel;
- ARegion *ar; /* re-assigned every modal update */
-} RulerInfo;
-
-/* -------------------------------------------------------------------- */
-/* local functions */
-static RulerItem *ruler_item_add(RulerInfo *ruler_info)
-{
- RulerItem *ruler_item = MEM_callocN(sizeof(RulerItem), "RulerItem");
- BLI_addtail(&ruler_info->items, ruler_item);
- return ruler_item;
-}
-
-static void ruler_item_remove(RulerInfo *ruler_info, RulerItem *ruler_item)
-{
- BLI_remlink(&ruler_info->items, ruler_item);
-
- MEM_freeN(ruler_item);
-}
-
-static RulerItem *ruler_item_active_get(RulerInfo *ruler_info)
-{
- return BLI_findlink(&ruler_info->items, ruler_info->item_active);
-}
-
-static void ruler_item_active_set(RulerInfo *ruler_info, RulerItem *ruler_item)
-{
- ruler_info->item_active = BLI_findindex(&ruler_info->items, ruler_item);
-}
-
-static void ruler_item_as_string(RulerItem *ruler_item, UnitSettings *unit,
- char *numstr, size_t numstr_size, int prec)
-{
-
- if (ruler_item->flag & RULERITEM_USE_ANGLE) {
- const float ruler_angle = angle_v3v3v3(ruler_item->co[0],
- ruler_item->co[1],
- ruler_item->co[2]);
-
- if (unit->system == USER_UNIT_NONE) {
- BLI_snprintf(numstr, numstr_size, "%.*f°", prec, RAD2DEGF(ruler_angle));
- }
- else {
- bUnit_AsString2(
- numstr, numstr_size, (double)ruler_angle,
- prec, B_UNIT_ROTATION, unit, false);
- }
- }
- else {
- const float ruler_len = len_v3v3(ruler_item->co[0],
- ruler_item->co[2]);
-
- if (unit->system == USER_UNIT_NONE) {
- BLI_snprintf(numstr, numstr_size, "%.*f", prec, ruler_len);
- }
- else {
- bUnit_AsString2(
- numstr, numstr_size, (double)(ruler_len * unit->scale_length),
- prec, B_UNIT_LENGTH, unit, false);
- }
- }
-
-}
-
-static bool view3d_ruler_pick(RulerInfo *ruler_info, const float mval[2],
- RulerItem **r_ruler_item, int *r_co_index)
-{
- ARegion *ar = ruler_info->ar;
- RulerItem *ruler_item;
-
- float dist_best = RULER_PICK_DIST_SQ;
- RulerItem *ruler_item_best = NULL;
- int co_index_best = -1;
-
- for (ruler_item = ruler_info->items.first; ruler_item; ruler_item = ruler_item->next) {
- float co_ss[3][2];
- float dist;
- int j;
-
- /* should these be checked? - ok for now not to */
- for (j = 0; j < 3; j++) {
- ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP);
- }
-
- if (ruler_item->flag & RULERITEM_USE_ANGLE) {
- dist = min_ff(dist_squared_to_line_segment_v2(mval, co_ss[0], co_ss[1]),
- dist_squared_to_line_segment_v2(mval, co_ss[1], co_ss[2]));
- if (dist < dist_best) {
- dist_best = dist;
- ruler_item_best = ruler_item;
-
- {
- const float dist_points[3] = {
- len_squared_v2v2(co_ss[0], mval),
- len_squared_v2v2(co_ss[1], mval),
- len_squared_v2v2(co_ss[2], mval),
- };
- if (min_fff(UNPACK3(dist_points)) < RULER_PICK_DIST_SQ) {
- co_index_best = min_axis_v3(dist_points);
- }
- else {
- co_index_best = -1;
- }
- }
- }
- }
- else {
- dist = dist_squared_to_line_segment_v2(mval, co_ss[0], co_ss[2]);
- if (dist < dist_best) {
- dist_best = dist;
- ruler_item_best = ruler_item;
-
- {
- const float dist_points[2] = {
- len_squared_v2v2(co_ss[0], mval),
- len_squared_v2v2(co_ss[2], mval),
- };
- if (min_ff(UNPACK2(dist_points)) < RULER_PICK_DIST_SQ) {
- co_index_best = (dist_points[0] < dist_points[1]) ? 0 : 2;
- }
- else {
- co_index_best = -1;
- }
- }
- }
- }
- }
-
- if (ruler_item_best) {
- *r_ruler_item = ruler_item_best;
- *r_co_index = co_index_best;
- return true;
- }
- else {
- *r_ruler_item = NULL;
- *r_co_index = -1;
- return false;
- }
-}
-
-/**
- * Ensure the 'snap_context' is only cached while dragging,
- * needed since the user may toggle modes between tool use.
- */
-static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
-{
- Main *bmain = CTX_data_main(C);
- if (state == ruler_info->state) {
- return;
- }
-
- /* always remove */
- if (ruler_info->snap_context) {
- ED_transform_snap_object_context_destroy(ruler_info->snap_context);
- ruler_info->snap_context = NULL;
- }
-
- if (state == RULER_STATE_NORMAL) {
- /* pass */
- }
- else if (state == RULER_STATE_DRAG) {
- ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
- bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0,
- ruler_info->ar, CTX_wm_view3d(C));
- }
- else {
- BLI_assert(0);
- }
-
- ruler_info->state = state;
-}
-
-#define RULER_ID "RulerData3D"
-static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info)
-{
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
-
- bGPDlayer *gpl;
- bGPDframe *gpf;
- bGPDstroke *gps;
- RulerItem *ruler_item;
- const char *ruler_name = RULER_ID;
- bool changed = false;
-
- /* FIXME: This needs to be reviewed. Should it keep being done like this? */
- if (scene->gpd == NULL) {
- scene->gpd = BKE_gpencil_data_addnew(bmain, "Annotations");
- }
- bGPdata *gpd = scene->gpd;
-
- gpl = BLI_findstring(&gpd->layers, ruler_name, offsetof(bGPDlayer, info));
- if (gpl == NULL) {
- gpl = BKE_gpencil_layer_addnew(gpd, ruler_name, false);
- copy_v4_v4(gpl->color, U.gpencil_new_layer_col);
- gpl->thickness = 1;
- gpl->flag |= GP_LAYER_HIDE;
- }
-
- gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_NEW);
- BKE_gpencil_free_strokes(gpf);
-
- for (ruler_item = ruler_info->items.first; ruler_item; ruler_item = ruler_item->next) {
- bGPDspoint *pt;
- int j;
-
- /* allocate memory for a new stroke */
- gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke");
- if (ruler_item->flag & RULERITEM_USE_ANGLE) {
- gps->totpoints = 3;
- pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points");
- for (j = 0; j < 3; j++) {
- copy_v3_v3(&pt->x, ruler_item->co[j]);
- pt->pressure = 1.0f;
- pt->strength = 1.0f;
- pt++;
- }
- }
- else {
- gps->totpoints = 2;
- pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points");
- for (j = 0; j < 3; j += 2) {
- copy_v3_v3(&pt->x, ruler_item->co[j]);
- pt->pressure = 1.0f;
- pt->strength = 1.0f;
- pt++;
- }
- }
- gps->flag = GP_STROKE_3DSPACE;
- gps->thickness = 3;
-
- BLI_addtail(&gpf->strokes, gps);
- changed = true;
- }
-
- return changed;
-}
-
-static bool view3d_ruler_from_gpencil(bContext *C, RulerInfo *ruler_info)
-{
- Scene *scene = CTX_data_scene(C);
- bool changed = false;
-
- if (scene->gpd) {
- bGPDlayer *gpl;
- const char *ruler_name = RULER_ID;
- gpl = BLI_findstring(&scene->gpd->layers, ruler_name, offsetof(bGPDlayer, info));
- if (gpl) {
- bGPDframe *gpf;
- gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_USE_PREV);
- if (gpf) {
- bGPDstroke *gps;
- for (gps = gpf->strokes.first; gps; gps = gps->next) {
- bGPDspoint *pt = gps->points;
- int j;
- if (gps->totpoints == 3) {
- RulerItem *ruler_item = ruler_item_add(ruler_info);
- for (j = 0; j < 3; j++) {
- copy_v3_v3(ruler_item->co[j], &pt->x);
- pt++;
- }
- ruler_item->flag |= RULERITEM_USE_ANGLE;
- changed = true;
- }
- else if (gps->totpoints == 2) {
- RulerItem *ruler_item = ruler_item_add(ruler_info);
- for (j = 0; j < 3; j += 2) {
- copy_v3_v3(ruler_item->co[j], &pt->x);
- pt++;
- }
- changed = true;
- }
- }
- }
- }
- }
-
- return changed;
-}
-
-/* -------------------------------------------------------------------- */
-/* local callbacks */
-
-static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *arg)
-{
- Scene *scene = CTX_data_scene(C);
- UnitSettings *unit = &scene->unit;
- RulerItem *ruler_item;
- RulerInfo *ruler_info = arg;
- RegionView3D *rv3d = ar->regiondata;
-// ARegion *ar = ruler_info->ar;
- const float cap_size = 4.0f;
- const float bg_margin = 4.0f * U.pixelsize;
- const float arc_size = 64.0f * U.pixelsize;
-#define ARC_STEPS 24
- const int arc_steps = ARC_STEPS;
- int i;
- const float color_act[4] = {1.0f, 1.0f, 1.0f, 1.0f};
- const float color_base[4] = {0.0f, 0.0f, 0.0f, 1.0f};
- unsigned char color_text[3];
- unsigned char color_wire[3];
- float color_back[4] = {1.0f, 1.0f, 1.0f, 0.5f};
-
- /* anti-aliased lines for more consistent appearance */
- GPU_line_smooth(true);
- GPU_line_width(1.0f);
-
- BLF_enable(blf_mono_font, BLF_ROTATION);
- BLF_size(blf_mono_font, 14 * U.pixelsize, U.dpi);
- BLF_rotation(blf_mono_font, 0.0f);
-
- UI_GetThemeColor3ubv(TH_TEXT, color_text);
- UI_GetThemeColor3ubv(TH_WIRE, color_wire);
-
- /* Avoid white on white text. (TODO Fix by using theme) */
- if ((int)color_text[0] + (int)color_text[1] + (int)color_text[2] > 127 * 3 * 0.6f) {
- copy_v3_fl(color_back, 0.0f);
- }
-
- for (ruler_item = ruler_info->items.first, i = 0; ruler_item; ruler_item = ruler_item->next, i++) {
- const bool is_act = (i == ruler_info->item_active);
- float dir_ruler[2];
- float co_ss[3][2];
- int j;
-
- /* should these be checked? - ok for now not to */
- for (j = 0; j < 3; j++) {
- ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP);
- }
-
- GPU_blend(true);
-
- const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-
- if (ruler_item->flag & RULERITEM_USE_ANGLE) {
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
-
- float viewport_size[4];
- GPU_viewport_size_get_f(viewport_size);
- immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
-
- immUniform1i("colors_len", 2); /* "advanced" mode */
- const float *col = is_act ? color_act : color_base;
- immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2);
- immUniform1f("dash_width", 6.0f);
-
- immBegin(GPU_PRIM_LINE_STRIP, 3);
-
- immVertex2fv(shdr_pos, co_ss[0]);
- immVertex2fv(shdr_pos, co_ss[1]);
- immVertex2fv(shdr_pos, co_ss[2]);
-
- immEnd();
-
- immUnbindProgram();
-
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- /* arc */
- {
- float dir_tmp[3];
- float co_tmp[3];
- float arc_ss_coord[2];
-
- float dir_a[3];
- float dir_b[3];
- float quat[4];
- float axis[3];
- float angle;
- const float px_scale = (ED_view3d_pixel_size_no_ui_scale(rv3d, ruler_item->co[1]) *
- min_fff(arc_size,
- len_v2v2(co_ss[0], co_ss[1]) / 2.0f,
- len_v2v2(co_ss[2], co_ss[1]) / 2.0f));
-
- sub_v3_v3v3(dir_a, ruler_item->co[0], ruler_item->co[1]);
- sub_v3_v3v3(dir_b, ruler_item->co[2], ruler_item->co[1]);
- normalize_v3(dir_a);
- normalize_v3(dir_b);
-
- cross_v3_v3v3(axis, dir_a, dir_b);
- angle = angle_normalized_v3v3(dir_a, dir_b);
-
- axis_angle_to_quat(quat, axis, angle / arc_steps);
-
- copy_v3_v3(dir_tmp, dir_a);
-
- immUniformColor3ubv(color_wire);
-
- immBegin(GPU_PRIM_LINE_STRIP, arc_steps + 1);
-
- for (j = 0; j <= arc_steps; j++) {
- madd_v3_v3v3fl(co_tmp, ruler_item->co[1], dir_tmp, px_scale);
- ED_view3d_project_float_global(ar, co_tmp, arc_ss_coord, V3D_PROJ_TEST_NOP);
- mul_qt_v3(quat, dir_tmp);
-
- immVertex2fv(shdr_pos, arc_ss_coord);
- }
-
- immEnd();
- }
-
- /* capping */
- {
- float rot_90_vec_a[2];
- float rot_90_vec_b[2];
- float cap[2];
-
- sub_v2_v2v2(dir_ruler, co_ss[0], co_ss[1]);
- rot_90_vec_a[0] = -dir_ruler[1];
- rot_90_vec_a[1] = dir_ruler[0];
- normalize_v2(rot_90_vec_a);
-
- sub_v2_v2v2(dir_ruler, co_ss[1], co_ss[2]);
- rot_90_vec_b[0] = -dir_ruler[1];
- rot_90_vec_b[1] = dir_ruler[0];
- normalize_v2(rot_90_vec_b);
-
- GPU_blend(true);
-
- immUniformColor3ubv(color_wire);
-
- immBegin(GPU_PRIM_LINES, 8);
-
- madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, cap_size);
- immVertex2fv(shdr_pos, cap);
- madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, -cap_size);
- immVertex2fv(shdr_pos, cap);
-
- madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec_b, cap_size);
- immVertex2fv(shdr_pos, cap);
- madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec_b, -cap_size);
- immVertex2fv(shdr_pos, cap);
-
- /* angle vertex */
- immVertex2f(shdr_pos, co_ss[1][0] - cap_size, co_ss[1][1] - cap_size);
- immVertex2f(shdr_pos, co_ss[1][0] + cap_size, co_ss[1][1] + cap_size);
- immVertex2f(shdr_pos, co_ss[1][0] - cap_size, co_ss[1][1] + cap_size);
- immVertex2f(shdr_pos, co_ss[1][0] + cap_size, co_ss[1][1] - cap_size);
-
- immEnd();
-
- GPU_blend(false);
- }
-
- char numstr[256];
- float numstr_size[2];
- float posit[2];
- const int prec = 2; /* XXX, todo, make optional */
-
- ruler_item_as_string(ruler_item, unit, numstr, sizeof(numstr), prec);
-
- BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]);
-
- posit[0] = co_ss[1][0] + (cap_size * 2.0f);
- posit[1] = co_ss[1][1] - (numstr_size[1] / 2.0f);
-
- /* draw text (bg) */
- {
- immUniformColor4fv(color_back);
- GPU_blend(true);
- immRectf(shdr_pos,
- posit[0] - bg_margin, posit[1] - bg_margin,
- posit[0] + bg_margin + numstr_size[0], posit[1] + bg_margin + numstr_size[1]);
- GPU_blend(false);
- }
-
- immUnbindProgram();
-
- /* text */
- {
- /* draw text */
- BLF_color3ubv(blf_mono_font, color_text);
- BLF_position(blf_mono_font, posit[0], posit[1], 0.0f);
- BLF_rotation(blf_mono_font, 0.0f);
- BLF_draw(blf_mono_font, numstr, sizeof(numstr));
- }
- }
- else {
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
-
- float viewport_size[4];
- GPU_viewport_size_get_f(viewport_size);
- immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
-
- immUniform1i("colors_len", 2); /* "advanced" mode */
- const float *col = is_act ? color_act : color_base;
- immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2);
- immUniform1f("dash_width", 6.0f);
-
- immBegin(GPU_PRIM_LINES, 2);
-
- immVertex2fv(shdr_pos, co_ss[0]);
- immVertex2fv(shdr_pos, co_ss[2]);
-
- immEnd();
-
- immUnbindProgram();
-
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- sub_v2_v2v2(dir_ruler, co_ss[0], co_ss[2]);
-
- /* capping */
- {
- float rot_90_vec[2] = {-dir_ruler[1], dir_ruler[0]};
- float cap[2];
-
- normalize_v2(rot_90_vec);
-
- GPU_blend(true);
-
- immUniformColor3ubv(color_wire);
-
- immBegin(GPU_PRIM_LINES, 4);
-
- madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, cap_size);
- immVertex2fv(shdr_pos, cap);
- madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, -cap_size);
- immVertex2fv(shdr_pos, cap);
-
- madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec, cap_size);
- immVertex2fv(shdr_pos, cap);
- madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec, -cap_size);
- immVertex2fv(shdr_pos, cap);
-
- immEnd();
-
- GPU_blend(false);
- }
-
- char numstr[256];
- float numstr_size[2];
- const int prec = 6; /* XXX, todo, make optional */
- float posit[2];
-
- ruler_item_as_string(ruler_item, unit, numstr, sizeof(numstr), prec);
-
- BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]);
-
- mid_v2_v2v2(posit, co_ss[0], co_ss[2]);
-
- /* center text */
- posit[0] -= numstr_size[0] / 2.0f;
- posit[1] -= numstr_size[1] / 2.0f;
-
- /* draw text (bg) */
- {
- immUniformColor4fv(color_back);
- GPU_blend(true);
- immRectf(shdr_pos,
- posit[0] - bg_margin, posit[1] - bg_margin,
- posit[0] + bg_margin + numstr_size[0], posit[1] + bg_margin + numstr_size[1]);
- GPU_blend(false);
- }
-
- immUnbindProgram();
-
- /* text */
- {
- /* draw text */
- BLF_color3ubv(blf_mono_font, color_text);
- BLF_position(blf_mono_font, posit[0], posit[1], 0.0f);
- BLF_draw(blf_mono_font, numstr, sizeof(numstr));
- }
- }
- }
-
- GPU_line_smooth(false);
-
- BLF_disable(blf_mono_font, BLF_ROTATION);
-
-#undef ARC_STEPS
-
- /* draw snap */
- if ((ruler_info->snap_flag & RULER_SNAP_OK) && (ruler_info->state == RULER_STATE_DRAG)) {
- ruler_item = ruler_item_active_get(ruler_info);
- if (ruler_item) {
- /* size from drawSnapping */
- const float size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
- float co_ss[3];
- ED_view3d_project_float_global(ar, ruler_item->co[ruler_item->co_index], co_ss, V3D_PROJ_TEST_NOP);
-
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformColor4fv(color_act);
-
- imm_draw_circle_wire_2d(pos, co_ss[0], co_ss[1], size * U.pixelsize, 32);
-
- immUnbindProgram();
- }
- }
-
-}
-
-/* free, use for both cancel and finish */
-static void view3d_ruler_end(const struct bContext *UNUSED(C), RulerInfo *ruler_info)
-{
- ED_region_draw_cb_exit(ruler_info->ar->type, ruler_info->draw_handle_pixel);
-}
-
-static void view3d_ruler_free(RulerInfo *ruler_info)
-{
- BLI_freelistN(&ruler_info->items);
-
- if (ruler_info->snap_context) {
- ED_transform_snap_object_context_destroy(ruler_info->snap_context);
- }
-
- MEM_freeN(ruler_info);
-}
-
-static void view3d_ruler_item_project(RulerInfo *ruler_info, float r_co[3],
- const int xy[2])
-{
- ED_view3d_win_to_3d_int(ruler_info->sa->spacedata.first, ruler_info->ar, r_co, xy, r_co);
-}
-
-/* use for mousemove events */
-static bool view3d_ruler_item_mousemove(
- RulerInfo *ruler_info, const int mval[2],
- const bool do_thickness, const bool do_snap)
-{
- const float eps_bias = 0.0002f;
- float dist_px = MVAL_MAX_PX_DIST * U.pixelsize; /* snap dist */
- RulerItem *ruler_item = ruler_item_active_get(ruler_info);
-
- ruler_info->snap_flag &= ~RULER_SNAP_OK;
-
- if (ruler_item) {
- float *co = ruler_item->co[ruler_item->co_index];
- /* restore the initial depth */
- copy_v3_v3(co, ruler_info->drag_start_co);
- view3d_ruler_item_project(ruler_info, co, mval);
- if (do_thickness && ruler_item->co_index != 1) {
- // Scene *scene = CTX_data_scene(C);
- // View3D *v3d = ruler_info->sa->spacedata.first;
- const float mval_fl[2] = {UNPACK2(mval)};
- float ray_normal[3];
- float ray_start[3];
- float *co_other;
-
- co_other = ruler_item->co[ruler_item->co_index == 0 ? 2 : 0];
-
- if (ED_transform_snap_object_project_view3d(
- ruler_info->snap_context,
- SCE_SNAP_MODE_FACE,
- &(const struct SnapObjectParams){
- .snap_select = SNAP_ALL,
- .use_object_edit_cage = true,
- },
- mval_fl, &dist_px,
- co, ray_normal))
- {
- negate_v3(ray_normal);
- /* add some bias */
- madd_v3_v3v3fl(ray_start, co, ray_normal, eps_bias);
- ED_transform_snap_object_project_ray(
- ruler_info->snap_context,
- &(const struct SnapObjectParams){
- .snap_select = SNAP_ALL,
- .use_object_edit_cage = true,
- },
- ray_start, ray_normal, NULL,
- co_other, NULL);
- }
- }
- else if (do_snap) {
- const float mval_fl[2] = {UNPACK2(mval)};
-
- if (ED_transform_snap_object_project_view3d(
- ruler_info->snap_context,
- (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE),
- &(const struct SnapObjectParams){
- .snap_select = SNAP_ALL,
- .use_object_edit_cage = true,
- .use_occlusion_test = true,
- },
- mval_fl, &dist_px,
- co, NULL))
- {
- ruler_info->snap_flag |= RULER_SNAP_OK;
- }
- }
- return true;
- }
- else {
- return false;
- }
-}
-
-static void view3d_ruler_header_update(bContext *C)
-{
- const char *text = IFACE_("Ctrl+LMB: Add, "
- "Del: Remove, "
- "Ctrl+Drag: Snap, "
- "Shift+Drag: Thickness, "
- "Ctrl+C: Copy Value, "
- "Enter: Store, "
- "Esc: Cancel");
-
- ED_workspace_status_text(C, text);
-}
-
-/* -------------------------------------------------------------------- */
-/* Operator callbacks */
-
-static int view3d_ruler_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- wmWindow *win = CTX_wm_window(C);
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = CTX_wm_region(C);
- RulerInfo *ruler_info;
-
- ruler_info = MEM_callocN(sizeof(RulerInfo), "RulerInfo");
-
- if (view3d_ruler_from_gpencil(C, ruler_info)) {
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- }
-
- op->customdata = ruler_info;
-
- ruler_info->win = win;
- ruler_info->sa = sa;
- ruler_info->draw_handle_pixel = ED_region_draw_cb_activate(ar->type, ruler_info_draw_pixel,
- ruler_info, REGION_DRAW_POST_PIXEL);
-
- view3d_ruler_header_update(C);
-
- op->flag |= OP_IS_MODAL_CURSOR_REGION;
-
- WM_cursor_modal_set(win, BC_CROSSCURSOR);
- WM_event_add_modal_handler(C, op);
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-static void view3d_ruler_cancel(bContext *C, wmOperator *op)
-{
- RulerInfo *ruler_info = op->customdata;
-
- view3d_ruler_end(C, ruler_info);
- view3d_ruler_free(ruler_info);
- op->customdata = NULL;
-}
-
-static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
- bool do_draw = false;
- int exit_code = OPERATOR_RUNNING_MODAL;
- RulerInfo *ruler_info = op->customdata;
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = CTX_wm_region(C);
- RegionView3D *rv3d = ar->regiondata;
-
- /* its possible to change spaces while running the operator [#34894] */
- if (UNLIKELY(sa != ruler_info->sa)) {
- exit_code = OPERATOR_FINISHED;
- goto exit;
- }
-
- ruler_info->ar = ar;
-
- switch (event->type) {
- case LEFTMOUSE:
- if (event->val == KM_RELEASE) {
- if (ruler_info->state == RULER_STATE_DRAG) {
- /* rubber-band angle removal */
- RulerItem *ruler_item = ruler_item_active_get(ruler_info);
- if (ruler_item && (ruler_item->co_index == 1) && (ruler_item->flag & RULERITEM_USE_ANGLE)) {
- if (!BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) {
- ruler_item->flag &= ~RULERITEM_USE_ANGLE;
- do_draw = true;
- }
- }
- if (ruler_info->snap_flag & RULER_SNAP_OK) {
- ruler_info->snap_flag &= ~RULER_SNAP_OK;
- do_draw = true;
- }
- ruler_state_set(C, ruler_info, RULER_STATE_NORMAL);
- }
- }
- else {
- if (ruler_info->state == RULER_STATE_NORMAL) {
-
- if (event->ctrl ||
- /* weak - but user friendly */
- BLI_listbase_is_empty(&ruler_info->items))
- {
- View3D *v3d = CTX_wm_view3d(C);
- const bool use_depth = (v3d->shading.type >= OB_SOLID);
-
- /* Create new line */
- RulerItem *ruler_item_prev = ruler_item_active_get(ruler_info);
- RulerItem *ruler_item;
- /* check if we want to drag an existing point or add a new one */
- ruler_state_set(C, ruler_info, RULER_STATE_DRAG);
-
- ruler_item = ruler_item_add(ruler_info);
- ruler_item_active_set(ruler_info, ruler_item);
-
- if (use_depth) {
- /* snap the first point added, not essential but handy */
- ruler_item->co_index = 0;
- view3d_ruler_item_mousemove(ruler_info, event->mval, false, true);
- copy_v3_v3(ruler_info->drag_start_co, ruler_item->co[ruler_item->co_index]);
- }
- else {
- /* initial depth either previous ruler, view offset */
- if (ruler_item_prev) {
- copy_v3_v3(ruler_info->drag_start_co, ruler_item_prev->co[ruler_item_prev->co_index]);
- }
- else {
- negate_v3_v3(ruler_info->drag_start_co, rv3d->ofs);
- }
-
- copy_v3_v3(ruler_item->co[0], ruler_info->drag_start_co);
- view3d_ruler_item_project(ruler_info, ruler_item->co[0], event->mval);
- }
-
- copy_v3_v3(ruler_item->co[2], ruler_item->co[0]);
- ruler_item->co_index = 2;
-
- do_draw = true;
- }
- else {
- float mval_fl[2] = {UNPACK2(event->mval)};
- RulerItem *ruler_item_pick;
- int co_index;
-
- /* select and drag */
- if (view3d_ruler_pick(ruler_info, mval_fl, &ruler_item_pick, &co_index)) {
- if (co_index == -1) {
- if ((ruler_item_pick->flag & RULERITEM_USE_ANGLE) == 0) {
- /* Add Center Point */
- ruler_item_active_set(ruler_info, ruler_item_pick);
- ruler_item_pick->flag |= RULERITEM_USE_ANGLE;
- ruler_item_pick->co_index = 1;
- ruler_state_set(C, ruler_info, RULER_STATE_DRAG);
-
- /* find the factor */
- {
- float co_ss[2][2];
- float fac;
-
- ED_view3d_project_float_global(ar, ruler_item_pick->co[0], co_ss[0], V3D_PROJ_TEST_NOP);
- ED_view3d_project_float_global(ar, ruler_item_pick->co[2], co_ss[1], V3D_PROJ_TEST_NOP);
-
- fac = line_point_factor_v2(mval_fl, co_ss[0], co_ss[1]);
- CLAMP(fac, 0.0f, 1.0f);
-
- interp_v3_v3v3(ruler_item_pick->co[1],
- ruler_item_pick->co[0],
- ruler_item_pick->co[2], fac);
- }
-
- /* update the new location */
- view3d_ruler_item_mousemove(ruler_info, event->mval,
- event->shift != 0, event->ctrl != 0);
- do_draw = true;
- }
- }
- else {
- ruler_item_active_set(ruler_info, ruler_item_pick);
- ruler_item_pick->co_index = co_index;
- ruler_state_set(C, ruler_info, RULER_STATE_DRAG);
-
- /* store the initial depth */
- copy_v3_v3(ruler_info->drag_start_co, ruler_item_pick->co[ruler_item_pick->co_index]);
-
- do_draw = true;
- }
- }
- else {
- exit_code = OPERATOR_PASS_THROUGH;
- }
-
- }
- }
- }
- break;
- case CKEY:
- {
- if (event->ctrl) {
- RulerItem *ruler_item = ruler_item_active_get(ruler_info);
- if (ruler_item) {
- const int prec = 8;
- char numstr[256];
- Scene *scene = CTX_data_scene(C);
- UnitSettings *unit = &scene->unit;
-
- ruler_item_as_string(ruler_item, unit, numstr, sizeof(numstr), prec);
- WM_clipboard_text_set((void *) numstr, false);
- }
- }
- break;
- }
- case RIGHTCTRLKEY:
- case LEFTCTRLKEY:
- {
- WM_event_add_mousemove(C);
- break;
- }
- case MOUSEMOVE:
- {
- if (ruler_info->state == RULER_STATE_DRAG) {
- if (view3d_ruler_item_mousemove(ruler_info, event->mval,
- event->shift != 0, event->ctrl != 0))
- {
- do_draw = true;
- }
- }
- break;
- }
- case ESCKEY:
- {
- do_draw = true;
- exit_code = OPERATOR_CANCELLED;
- break;
- }
- case RETKEY:
- {
- /* Enter may be used to invoke from search. */
- if (event->val == KM_PRESS) {
- view3d_ruler_to_gpencil(C, ruler_info);
- do_draw = true;
- exit_code = OPERATOR_FINISHED;
- }
- break;
- }
- case DELKEY:
- {
- if (event->val == KM_PRESS) {
- if (ruler_info->state == RULER_STATE_NORMAL) {
- RulerItem *ruler_item = ruler_item_active_get(ruler_info);
- if (ruler_item) {
- RulerItem *ruler_item_other = ruler_item->prev ? ruler_item->prev : ruler_item->next;
- ruler_item_remove(ruler_info, ruler_item);
- ruler_item_active_set(ruler_info, ruler_item_other);
- do_draw = true;
- }
- }
- }
- break;
- }
- default:
- exit_code = OPERATOR_PASS_THROUGH;
- break;
-
- }
-
- if (ruler_info->state == RULER_STATE_DRAG) {
- op->flag &= ~OP_IS_MODAL_CURSOR_REGION;
- }
- else {
- op->flag |= OP_IS_MODAL_CURSOR_REGION;
- }
-
- if (do_draw) {
- view3d_ruler_header_update(C);
-
- /* all 3d views draw rulers */
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- }
-
-exit:
- if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED)) {
- WM_cursor_modal_restore(ruler_info->win);
-
- view3d_ruler_end(C, ruler_info);
- view3d_ruler_free(ruler_info);
- op->customdata = NULL;
-
- ED_workspace_status_text(C, NULL);
- }
-
- return exit_code;
-}
-
-void VIEW3D_OT_ruler(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Ruler/Protractor";
- ot->description = "Interactive ruler";
- ot->idname = "VIEW3D_OT_ruler";
-
- /* api callbacks */
- ot->invoke = view3d_ruler_invoke;
- ot->cancel = view3d_ruler_cancel;
- ot->modal = view3d_ruler_modal;
- ot->poll = ED_operator_view3d_active;
-
- /* flags */
- ot->flag = 0;
-}
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index f973f84cf6f..b2fbdbad31c 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -443,7 +443,7 @@ static void do_lasso_select_objects(
}
if (changed) {
- DEG_id_tag_update(&vc->scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&vc->scene->id, ID_RECALC_SELECT);
WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, vc->scene);
}
}
@@ -456,7 +456,7 @@ static Base **do_pose_tag_select_op_prepare(ViewContext *vc, uint *r_bases_len)
{
Base **bases = NULL;
BLI_array_declare(bases);
- FOREACH_BASE_IN_MODE_BEGIN (vc->view_layer, OB_MODE_POSE, base_iter) {
+ FOREACH_BASE_IN_MODE_BEGIN (vc->view_layer, vc->v3d, OB_ARMATURE, OB_MODE_POSE, base_iter) {
Object *ob_iter = base_iter->object;
bArmature *arm = ob_iter->data;
for (bPoseChannel *pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -541,7 +541,7 @@ static void do_lasso_select_pose(
const bool changed_multi = do_pose_tag_select_op_exec(bases, bases_len, sel_op);
if (changed_multi) {
- DEG_id_tag_update(&vc->scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&vc->scene->id, ID_RECALC_SELECT);
WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, vc->scene);
}
@@ -925,7 +925,7 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh
return;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- paintface_deselect_all_visible(ob, SEL_DESELECT, false); /* flush selection at the end */
+ paintface_deselect_all_visible(vc->C, ob, SEL_DESELECT, false); /* flush selection at the end */
}
bm_vertoffs = me->totpoly + 1; /* max index array */
@@ -937,8 +937,7 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh
EDBM_backbuf_free();
- paintface_flush_flags(ob, SELECT);
- paintface_tag_select_update(vc->C, ob);
+ paintface_flush_flags(vc->C, ob, SELECT);
}
#if 0
@@ -1001,7 +1000,7 @@ static void view3d_lasso_select(
}
else { /* Edit Mode */
- FOREACH_OBJECT_IN_MODE_BEGIN (vc->view_layer, ob->mode, ob_iter) {
+ FOREACH_OBJECT_IN_MODE_BEGIN (vc->view_layer, vc->v3d, ob->type, ob->mode, ob_iter) {
ED_view3d_viewcontext_init_object(vc, ob_iter);
switch (vc->obedit->type) {
@@ -1026,7 +1025,7 @@ static void view3d_lasso_select(
break;
}
- DEG_id_tag_update(vc->obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(vc->obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc->obedit->data);
}
FOREACH_OBJECT_IN_MODE_END;
@@ -1151,7 +1150,7 @@ static int object_select_menu_exec(bContext *C, wmOperator *op)
/* undo? */
if (changed) {
Scene *scene = CTX_data_scene(C);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_FINISHED;
}
@@ -1309,41 +1308,17 @@ static int selectbuffer_ret_hits_5(unsigned int *buffer, const int hits15, const
return hits5;
}
-/* we want a select buffer with bones, if there are... */
-/* so check three selection levels and compare */
+/**
+ * Populate a select buffer with objects and bones, if there are any.
+ * Checks three selection levels and compare.
+ */
static int mixed_bones_object_selectbuffer(
- ViewContext *vc, unsigned int *buffer, const int mval[2],
- bool use_cycle, bool enumerate, eV3DSelectObjectFilter select_filter,
- bool *r_do_nearest)
+ ViewContext *vc, unsigned int *buffer, const int mval[2], eV3DSelectObjectFilter select_filter,
+ bool do_nearest)
{
rcti rect;
int hits15, hits9 = 0, hits5 = 0;
bool has_bones15 = false, has_bones9 = false, has_bones5 = false;
- static int last_mval[2] = {-100, -100};
- bool do_nearest = false;
- View3D *v3d = vc->v3d;
-
- /* define if we use solid nearest select or not */
- if (use_cycle) {
- if (v3d->shading.type > OB_WIRE) {
- do_nearest = true;
- if (len_manhattan_v2v2_int(mval, last_mval) < 3) {
- do_nearest = false;
- }
- }
- copy_v2_v2_int(last_mval, mval);
- }
- else {
- if (v3d->shading.type > OB_WIRE) {
- do_nearest = true;
- }
- }
-
- if (r_do_nearest) {
- *r_do_nearest = do_nearest;
- }
-
- do_nearest = do_nearest && !enumerate;
const int select_mode = (do_nearest ? VIEW3D_SELECT_PICK_NEAREST : VIEW3D_SELECT_PICK_ALL);
int hits = 0;
@@ -1394,6 +1369,40 @@ static int mixed_bones_object_selectbuffer(
finally:
view3d_opengl_select_cache_end();
+ return hits;
+}
+
+static int mixed_bones_object_selectbuffer_extended(
+ ViewContext *vc, unsigned int *buffer, const int mval[2], eV3DSelectObjectFilter select_filter,
+ bool use_cycle, bool enumerate, bool *r_do_nearest)
+{
+ static int last_mval[2] = {-100, -100};
+ bool do_nearest = false;
+ View3D *v3d = vc->v3d;
+
+ /* define if we use solid nearest select or not */
+ if (use_cycle) {
+ if (v3d->shading.type > OB_WIRE) {
+ do_nearest = true;
+ if (len_manhattan_v2v2_int(mval, last_mval) < 3) {
+ do_nearest = false;
+ }
+ }
+ copy_v2_v2_int(last_mval, mval);
+ }
+ else {
+ if (v3d->shading.type > OB_WIRE) {
+ do_nearest = true;
+ }
+ }
+
+ if (r_do_nearest) {
+ *r_do_nearest = do_nearest;
+ }
+
+ do_nearest = do_nearest && !enumerate;
+
+ int hits = mixed_bones_object_selectbuffer(vc, buffer, mval, select_filter, do_nearest);
if (vc->scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) {
const bool is_pose_mode = (
@@ -1509,18 +1518,15 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2])
ViewContext vc;
Base *basact = NULL;
unsigned int buffer[MAXPICKBUF];
- int hits;
- bool do_nearest;
/* setup view context for argument to callbacks */
view3d_operator_needs_opengl(C);
ED_view3d_viewcontext_init(C, &vc);
- hits = mixed_bones_object_selectbuffer(
- &vc, buffer, mval,
- false, false, VIEW3D_SELECT_FILTER_NOP,
- &do_nearest);
+ const bool do_nearest = (vc.v3d->shading.type > OB_WIRE);
+ const int hits = mixed_bones_object_selectbuffer(
+ &vc, buffer, mval, VIEW3D_SELECT_FILTER_NOP, do_nearest);
if (hits > 0) {
const bool has_bones = selectbuffer_has_bones(buffer, hits);
@@ -1647,10 +1653,11 @@ static bool ed_object_select_pick(
// TIMEIT_START(select_time);
/* if objects have posemode set, the bones are in the same selection buffer */
- const eV3DSelectObjectFilter select_filter = ED_view3d_select_filter_from_mode(scene, vc.obact);
- hits = mixed_bones_object_selectbuffer(
- &vc, buffer, mval,
- true, enumerate, select_filter,
+ const eV3DSelectObjectFilter select_filter = (
+ (object == false) ? ED_view3d_select_filter_from_mode(scene, vc.obact) : VIEW3D_SELECT_FILTER_NOP);
+ hits = mixed_bones_object_selectbuffer_extended(
+ &vc, buffer, mval, select_filter,
+ true, enumerate,
&do_nearest);
// TIMEIT_END(select_time);
@@ -1712,8 +1719,8 @@ static bool ed_object_select_pick(
retval = true;
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
- DEG_id_tag_update(&clip->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
+ DEG_id_tag_update(&clip->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_MOVIECLIP | ND_SELECT, track);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
@@ -1729,7 +1736,7 @@ static bool ed_object_select_pick(
}
}
else if (ED_armature_pose_select_pick_with_buffer(
- view_layer, basact, buffer, hits, extend, deselect, toggle, do_nearest))
+ view_layer, v3d, basact, buffer, hits, extend, deselect, toggle, do_nearest))
{
/* then bone is found */
@@ -1846,7 +1853,7 @@ static bool ed_object_select_pick(
}
}
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
@@ -2252,7 +2259,7 @@ static int do_armature_box_select(
VIEW3D_SELECT_ALL, VIEW3D_SELECT_FILTER_NOP);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc->view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc->view_layer, vc->v3d, &objects_len);
/* clear flag we use to detect point was affected */
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -2430,7 +2437,7 @@ finally:
MEM_freeN(vbuffer);
if (changed) {
- DEG_id_tag_update(&vc->scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&vc->scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene);
return OPERATOR_FINISHED;
}
@@ -2503,7 +2510,7 @@ static int do_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, const eS
const bool changed_multi = do_pose_tag_select_op_exec(bases, bases_len, sel_op);
if (changed_multi) {
- DEG_id_tag_update(&vc->scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&vc->scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene);
}
@@ -2531,7 +2538,7 @@ static int view3d_box_select_exec(bContext *C, wmOperator *op)
if (vc.obedit) {
- FOREACH_OBJECT_IN_MODE_BEGIN (vc.view_layer, vc.obedit->mode, ob_iter) {
+ FOREACH_OBJECT_IN_MODE_BEGIN (vc.view_layer, vc.v3d, vc.obedit->type, vc.obedit->mode, ob_iter) {
ED_view3d_viewcontext_init_object(&vc, ob_iter);
switch (vc.obedit->type) {
@@ -2539,7 +2546,7 @@ static int view3d_box_select_exec(bContext *C, wmOperator *op)
vc.em = BKE_editmesh_from_object(vc.obedit);
ret |= do_mesh_box_select(&vc, &rect, sel_op);
if (ret & OPERATOR_FINISHED) {
- DEG_id_tag_update(vc.obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
}
break;
@@ -2547,28 +2554,28 @@ static int view3d_box_select_exec(bContext *C, wmOperator *op)
case OB_SURF:
ret |= do_nurbs_box_select(&vc, &rect, sel_op);
if (ret & OPERATOR_FINISHED) {
- DEG_id_tag_update(vc.obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
}
break;
case OB_MBALL:
ret |= do_meta_box_select(&vc, &rect, sel_op);
if (ret & OPERATOR_FINISHED) {
- DEG_id_tag_update(vc.obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
}
break;
case OB_ARMATURE:
ret |= do_armature_box_select(&vc, &rect, sel_op);
if (ret & OPERATOR_FINISHED) {
- DEG_id_tag_update(&vc.obedit->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&vc.obedit->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit);
}
break;
case OB_LATTICE:
ret |= do_lattice_box_select(&vc, &rect, sel_op);
if (ret & OPERATOR_FINISHED) {
- DEG_id_tag_update(vc.obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
}
break;
@@ -2904,8 +2911,7 @@ static void paint_facesel_circle_select(ViewContext *vc, const bool select, cons
if (bbsel) {
edbm_backbuf_check_and_select_tfaces(me, select ? SEL_OP_ADD : SEL_OP_SUB);
EDBM_backbuf_free();
- paintface_flush_flags(ob, SELECT);
- paintface_tag_select_update(vc->C, ob);
+ paintface_flush_flags(vc->C, ob, SELECT);
}
}
@@ -3264,7 +3270,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
{
view3d_operator_needs_opengl(C);
- FOREACH_OBJECT_IN_MODE_BEGIN (vc.view_layer, obact->mode, ob_iter) {
+ FOREACH_OBJECT_IN_MODE_BEGIN (vc.view_layer, vc.v3d, obact->type, obact->mode, ob_iter) {
ED_view3d_viewcontext_init_object(&vc, ob_iter);
obact = vc.obact;
@@ -3272,7 +3278,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
if (CTX_data_edit_object(C)) {
obedit_circle_select(&vc, select, mval, (float)radius);
- DEG_id_tag_update(obact->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obact->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data);
}
else if (BKE_paint_select_face_test(obact)) {
@@ -3295,7 +3301,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
}
else {
if (object_circle_select(&vc, select, mval, (float)radius)) {
- DEG_id_tag_update(&vc.scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&vc.scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc.scene);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 9089a34ecaf..1bff52e7950 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -90,7 +90,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
if (obedit) {
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
obedit = objects[ob_index];
@@ -132,7 +132,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
else {
struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID);
- FOREACH_SELECTED_EDITABLE_OBJECT_BEGIN(view_layer_eval, ob_eval)
+ FOREACH_SELECTED_EDITABLE_OBJECT_BEGIN(view_layer_eval, v3d, ob_eval)
{
Object *ob = DEG_get_original_object(ob_eval);
if (ob->mode & OB_MODE_POSE) {
@@ -180,7 +180,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
}
ob->pose->flag |= (POSE_LOCKED | POSE_DO_UNLOCK);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else {
vec[0] = -ob_eval->obmat[3][0] + gridf * floorf(0.5f + ob_eval->obmat[3][0] / gridf);
@@ -204,7 +204,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
/* auto-keyframing */
ED_autokeyframe_object(C, scene, ob, ks);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
}
FOREACH_SELECTED_EDITABLE_OBJECT_END;
@@ -268,7 +268,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
float snap_target_local[3];
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
obedit = objects[ob_index];
@@ -379,7 +379,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
ob->pose->flag |= (POSE_LOCKED | POSE_DO_UNLOCK);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
CTX_DATA_END;
}
@@ -437,7 +437,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
/* auto-keyframing */
ED_autokeyframe_object(C, scene, ob, ks);
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
}
@@ -454,9 +454,8 @@ static int snap_selected_to_cursor_exec(bContext *C, wmOperator *op)
const bool use_offset = RNA_boolean_get(op->ptr, "use_offset");
Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- const float *snap_target_global = ED_view3d_cursor3d_get(scene, v3d)->location;
+ const float *snap_target_global = scene->cursor.location;
return snap_selected_to_location(C, snap_target_global, use_offset);
}
@@ -521,14 +520,14 @@ static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
float gridf, *curs;
gridf = ED_view3d_grid_scale(scene, v3d, NULL);
- curs = ED_view3d_cursor3d_get(scene, v3d)->location;
+ curs = scene->cursor.location;
curs[0] = gridf * floorf(0.5f + curs[0] / gridf);
curs[1] = gridf * floorf(0.5f + curs[1] / gridf);
curs[2] = gridf * floorf(0.5f + curs[2] / gridf);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); /* hrm */
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
return OPERATOR_FINISHED;
}
@@ -624,7 +623,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
int global_transverts_tot = 0;
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
obedit = objects[ob_index];
@@ -687,7 +686,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
}
}
else {
- FOREACH_SELECTED_OBJECT_BEGIN(view_layer_eval, ob_eval)
+ FOREACH_SELECTED_OBJECT_BEGIN(view_layer_eval, v3d, ob_eval)
{
copy_v3_v3(vec, ob_eval->obmat[3]);
@@ -724,14 +723,9 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
static int snap_curs_to_sel_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- float *curs;
-
- curs = ED_view3d_cursor3d_get(scene, v3d)->location;
-
- if (snap_curs_to_sel_ex(C, curs)) {
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ if (snap_curs_to_sel_ex(C, scene->cursor.location)) {
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
return OPERATOR_FINISHED;
}
@@ -805,13 +799,10 @@ static int snap_curs_to_active_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
- float *curs;
-
- curs = ED_view3d_cursor3d_get(scene, v3d)->location;
- if (snap_calc_active_center(C, false, curs)) {
+ if (snap_calc_active_center(C, false, scene->cursor.location)) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
return OPERATOR_FINISHED;
}
@@ -841,15 +832,12 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot)
static int snap_curs_to_center_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- float *curs;
- curs = ED_view3d_cursor3d_get(scene, v3d)->location;
- zero_v3(curs);
+ zero_v3(scene->cursor.location);
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index 022fccd7ce7..a5be2a8cc83 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -91,25 +91,15 @@ void ED_view3d_background_color_get(const Scene *scene, const View3D *v3d, float
}
}
-View3DCursor *ED_view3d_cursor3d_get(Scene *scene, View3D *v3d)
+void ED_view3d_cursor3d_calc_mat3(const Scene *scene, float mat[3][3])
{
- if (v3d && v3d->localvd) {
- return &v3d->cursor;
- }
- else {
- return &scene->cursor;
- }
-}
-
-void ED_view3d_cursor3d_calc_mat3(const Scene *scene, const View3D *v3d, float mat[3][3])
-{
- const View3DCursor *cursor = ED_view3d_cursor3d_get((Scene *)scene, (View3D *)v3d);
+ const View3DCursor *cursor = &scene->cursor;
quat_to_mat3(mat, cursor->rotation);
}
-void ED_view3d_cursor3d_calc_mat4(const Scene *scene, const View3D *v3d, float mat[4][4])
+void ED_view3d_cursor3d_calc_mat4(const Scene *scene, float mat[4][4])
{
- const View3DCursor *cursor = ED_view3d_cursor3d_get((Scene *)scene, (View3D *)v3d);
+ const View3DCursor *cursor = &scene->cursor;
quat_to_mat4(mat, cursor->rotation);
copy_v3_v3(mat[3], cursor->location);
}
@@ -541,7 +531,7 @@ bool ED_view3d_camera_lock_sync(const Depsgraph *depsgraph, View3D *v3d, RegionV
ob_update = v3d->camera;
while (ob_update) {
- DEG_id_tag_update(&ob_update->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob_update->id, ID_RECALC_TRANSFORM);
WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, ob_update);
ob_update = ob_update->parent;
}
@@ -553,7 +543,7 @@ bool ED_view3d_camera_lock_sync(const Depsgraph *depsgraph, View3D *v3d, RegionV
ED_view3d_to_object(depsgraph, v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist);
BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag | protect_scale_all);
- DEG_id_tag_update(&v3d->camera->id, OB_RECALC_OB);
+ DEG_id_tag_update(&v3d->camera->id, ID_RECALC_TRANSFORM);
WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, v3d->camera);
}
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index f8f2e9635e4..d99fa5e8760 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -43,6 +43,7 @@
#include "BKE_context.h"
#include "BKE_object.h"
#include "BKE_global.h"
+#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_scene.h"
@@ -60,6 +61,7 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "ED_object.h"
#include "ED_screen.h"
#include "DRW_engine.h"
@@ -454,7 +456,7 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op))
BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag);
- DEG_id_tag_update(&v3d->camera->id, OB_RECALC_OB);
+ DEG_id_tag_update(&v3d->camera->id, ID_RECALC_TRANSFORM);
rv3d->persp = RV3D_CAMOB;
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, v3d->camera);
@@ -539,7 +541,7 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
BKE_object_tfm_protected_restore(camera_ob, &obtfm, OB_LOCK_SCALE | OB_LOCK_ROT4D);
/* notifiers */
- DEG_id_tag_update(&camera_ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&camera_ob->id, ID_RECALC_TRANSFORM);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, camera_ob);
return OPERATOR_FINISHED;
}
@@ -797,7 +799,7 @@ void view3d_viewmatrix_set(
}
else if (v3d->ob_centre_cursor) {
float vec[3];
- copy_v3_v3(vec, ED_view3d_cursor3d_get(scene, (View3D *)v3d)->location);
+ copy_v3_v3(vec, scene->cursor.location);
translate_m4(rv3d->viewmat, -vec[0], -vec[1], -vec[2]);
use_lock_ofs = true;
}
@@ -1106,6 +1108,367 @@ finally:
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Local View Operators
+ * \{ */
+
+static unsigned int free_localbit(Main *bmain)
+{
+ ScrArea *sa;
+ bScreen *sc;
+
+ unsigned short local_view_bits = 0;
+
+ /* sometimes we loose a localview: when an area is closed */
+ /* check all areas: which localviews are in use? */
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl = sa->spacedata.first;
+ for (; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *) sl;
+ if (v3d->localvd) {
+ local_view_bits |= v3d->local_view_uuid;
+ }
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < 16; i++) {
+ if ((local_view_bits & (1 << i)) == 0) {
+ return (1 << i);
+ }
+ }
+
+ return 0;
+}
+
+static bool view3d_localview_init(
+ const Depsgraph *depsgraph,
+ wmWindowManager *wm,
+ wmWindow *win,
+ Main *bmain,
+ ViewLayer *view_layer,
+ ScrArea *sa,
+ const int smooth_viewtx,
+ ReportList *reports)
+{
+ View3D *v3d = sa->spacedata.first;
+ Base *base;
+ float min[3], max[3], box[3], mid[3];
+ float size = 0.0f;
+ unsigned int local_view_bit;
+ bool ok = false;
+
+ if (v3d->localvd) {
+ return ok;
+ }
+
+ INIT_MINMAX(min, max);
+
+ local_view_bit = free_localbit(bmain);
+
+ if (local_view_bit == 0) {
+ /* TODO(dfelinto): We can kick one of the other 3D views out of local view
+ specially if it is not being used. */
+ BKE_report(reports, RPT_ERROR, "No more than 16 local views");
+ ok = false;
+ }
+ else {
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
+ if (obedit) {
+ FOREACH_BASE_IN_EDIT_MODE_BEGIN(view_layer, v3d, base_iter) {
+ BKE_object_minmax(base_iter->object, min, max, false);
+ base_iter->local_view_bits |= local_view_bit;
+ ok = true;
+ } FOREACH_BASE_IN_EDIT_MODE_END;
+ }
+ else {
+ for (base = FIRSTBASE(view_layer); base; base = base->next) {
+ if (TESTBASE(v3d, base)) {
+ BKE_object_minmax(base->object, min, max, false);
+ base->local_view_bits |= local_view_bit;
+ ok = true;
+ }
+ }
+ }
+
+ sub_v3_v3v3(box, max, min);
+ size = max_fff(box[0], box[1], box[2]);
+ }
+
+ if (ok == true) {
+ ARegion *ar;
+
+ v3d->localvd = MEM_mallocN(sizeof(View3D), "localview");
+
+ memcpy(v3d->localvd, v3d, sizeof(View3D));
+
+ mid_v3_v3v3(mid, min, max);
+
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ RegionView3D *rv3d = ar->regiondata;
+ bool ok_dist = true;
+
+ /* New view values. */
+ Object *camera_old = NULL;
+ float dist_new, ofs_new[3];
+
+ rv3d->localvd = MEM_mallocN(sizeof(RegionView3D), "localview region");
+ memcpy(rv3d->localvd, rv3d, sizeof(RegionView3D));
+
+ negate_v3_v3(ofs_new, mid);
+
+ if (rv3d->persp == RV3D_CAMOB) {
+ rv3d->persp = RV3D_PERSP;
+ camera_old = v3d->camera;
+ }
+
+ if (rv3d->persp == RV3D_ORTHO) {
+ if (size < 0.0001f) {
+ ok_dist = false;
+ }
+ }
+
+ if (ok_dist) {
+ dist_new = ED_view3d_radius_to_dist(v3d, ar, depsgraph, rv3d->persp, true, (size / 2) * VIEW3D_MARGIN);
+
+ if (rv3d->persp == RV3D_PERSP) {
+ /* Don't zoom closer than the near clipping plane. */
+ dist_new = max_ff(dist_new, v3d->near * 1.5f);
+ }
+ }
+
+ ED_view3d_smooth_view_ex(
+ depsgraph,
+ wm, win, sa, v3d, ar, smooth_viewtx,
+ &(const V3D_SmoothParams) {
+ .camera_old = camera_old,
+ .ofs = ofs_new, .quat = rv3d->viewquat,
+ .dist = ok_dist ? &dist_new : NULL, .lens = &v3d->lens});
+ }
+ }
+
+ v3d->local_view_uuid = local_view_bit;
+ }
+
+ DEG_on_visible_update(bmain, false);
+ return ok;
+}
+
+static void restore_localviewdata(
+ const Depsgraph *depsgraph,
+ wmWindowManager *wm,
+ wmWindow *win,
+ Main *bmain,
+ ScrArea *sa,
+ const int smooth_viewtx)
+{
+ const bool free = true;
+ ARegion *ar;
+ View3D *v3d = sa->spacedata.first;
+ Object *camera_old, *camera_new;
+
+ if (v3d->localvd == NULL) return;
+
+ camera_old = v3d->camera;
+ camera_new = v3d->localvd->camera;
+
+ v3d->local_view_uuid = 0;
+ v3d->camera = v3d->localvd->camera;
+
+ if (free) {
+ MEM_freeN(v3d->localvd);
+ v3d->localvd = NULL;
+ }
+
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ RegionView3D *rv3d = ar->regiondata;
+
+ if (rv3d->localvd) {
+ Object *camera_old_rv3d, *camera_new_rv3d;
+
+ camera_old_rv3d = (rv3d->persp == RV3D_CAMOB) ? camera_old : NULL;
+ camera_new_rv3d = (rv3d->localvd->persp == RV3D_CAMOB) ? camera_new : NULL;
+
+ rv3d->view = rv3d->localvd->view;
+ rv3d->persp = rv3d->localvd->persp;
+ rv3d->camzoom = rv3d->localvd->camzoom;
+
+ ED_view3d_smooth_view_ex(
+ depsgraph,
+ wm, win, sa,
+ v3d, ar, smooth_viewtx,
+ &(const V3D_SmoothParams) {
+ .camera_old = camera_old_rv3d, .camera = camera_new_rv3d,
+ .ofs = rv3d->localvd->ofs, .quat = rv3d->localvd->viewquat,
+ .dist = &rv3d->localvd->dist});
+
+ if (free) {
+ MEM_freeN(rv3d->localvd);
+ rv3d->localvd = NULL;
+ }
+ }
+
+ ED_view3d_shade_update(bmain, v3d, sa);
+ }
+ }
+}
+
+static bool view3d_localview_exit(
+ const Depsgraph *depsgraph,
+ wmWindowManager *wm,
+ wmWindow *win,
+ Main *bmain,
+ ViewLayer *view_layer,
+ ScrArea *sa,
+ const int smooth_viewtx)
+{
+ View3D *v3d = sa->spacedata.first;
+ struct Base *base;
+ unsigned int local_view_bit;
+
+ if (v3d->localvd) {
+
+ local_view_bit = v3d->local_view_uuid;
+
+ restore_localviewdata(depsgraph, wm, win, bmain, sa, smooth_viewtx);
+
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
+ for (base = FIRSTBASE(view_layer); base; base = base->next) {
+ if (base->local_view_bits & local_view_bit) {
+ base->local_view_bits &= ~local_view_bit;
+ if (base->object != obedit) {
+ ED_object_base_select(base, BA_SELECT);
+ }
+ }
+ }
+
+ DEG_on_visible_update(bmain, false);
+
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+static int localview_exec(bContext *C, wmOperator *op)
+{
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win = CTX_wm_window(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ ScrArea *sa = CTX_wm_area(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ bool changed;
+
+ if (v3d->localvd) {
+ changed = view3d_localview_exit(depsgraph, wm, win, bmain, view_layer, sa, smooth_viewtx);
+ }
+ else {
+ changed = view3d_localview_init(depsgraph, wm, win, bmain, view_layer, sa, smooth_viewtx, op->reports);
+ }
+
+ if (changed) {
+ DEG_id_type_tag(bmain, ID_OB);
+ ED_area_tag_redraw(sa);
+
+ /* Unselected objects become selected when exiting. */
+ if (v3d->localvd == NULL) {
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ }
+ else {
+ DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
+ }
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void VIEW3D_OT_localview(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Local View";
+ ot->description = "Toggle display of selected object(s) separately and centered in view";
+ ot->idname = "VIEW3D_OT_localview";
+
+ /* api callbacks */
+ ot->exec = localview_exec;
+ ot->flag = OPTYPE_UNDO; /* localview changes object layer bitflags */
+
+ ot->poll = ED_operator_view3d_active;
+}
+
+static int localview_remove_from_exec(bContext *C, wmOperator *op)
+{
+ View3D *v3d = CTX_wm_view3d(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ bool changed = false;
+
+ for (Base *base = FIRSTBASE(view_layer); base; base = base->next) {
+ if (TESTBASE(v3d, base)) {
+ base->local_view_bits &= ~v3d->local_view_uuid;
+ ED_object_base_select(base, BA_DESELECT);
+
+ if (base == BASACT(view_layer)) {
+ view_layer->basact = NULL;
+ }
+ changed = true;
+ }
+ }
+
+ if (changed) {
+ DEG_on_visible_update(bmain, false);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ BKE_report(op->reports, RPT_ERROR, "No object selected");
+ return OPERATOR_CANCELLED;
+ }
+}
+
+static bool localview_remove_from_poll(bContext *C)
+{
+ if (CTX_data_edit_object(C) != NULL) {
+ return false;
+ }
+
+ View3D *v3d = CTX_wm_view3d(C);
+ return v3d && v3d->localvd;
+}
+
+void VIEW3D_OT_localview_remove_from(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Remove from Local View";
+ ot->description = "Move selected objects out of local view";
+ ot->idname = "VIEW3D_OT_localview_remove_from";
+
+ /* api callbacks */
+ ot->exec = localview_remove_from_exec;
+ ot->invoke = WM_operator_confirm;
+ ot->poll = localview_remove_from_poll;
+ ot->flag = OPTYPE_UNDO;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name View Layer Utilities
* \{ */
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 68a40f33368..d4bb213e5c7 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -280,7 +280,7 @@ static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *ar, void *a
int xoff, yoff;
rctf viewborder;
- if (walk->scene->camera) {
+ if (ED_view3d_cameracontrol_object_get(walk->v3d_camera_control)) {
ED_view3d_calc_camera_border(walk->scene, walk->depsgraph, ar, walk->v3d, walk->rv3d, &viewborder, false);
xoff = viewborder.xmin + BLI_rctf_size_x(&viewborder) * 0.5f;
yoff = viewborder.ymin + BLI_rctf_size_y(&viewborder) * 0.5f;
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 29ac5a92def..324cd26a54f 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -582,7 +582,7 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
if (t->options & CTX_GPENCIL_STROKES) {
bGPdata *gpd = ED_gpencil_data_get_active(C);
if (gpd) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
}
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
}
@@ -992,13 +992,28 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
}
}
else if (!edit_2d) {
- if (cmode == axis) {
- if (t->con.orientation != V3D_MANIP_GLOBAL) {
+ if (cmode != axis) {
+ /* First press, constraint to an axis. */
+ t->orientation.index = 0;
+ const short *orientation_ptr = t->orientation.types[t->orientation.index];
+ const short orientation = orientation_ptr ? *orientation_ptr : V3D_MANIP_GLOBAL;
+ if (is_plane == false) {
+ setUserConstraint(t, orientation, constraint_axis, msg2);
+ }
+ else {
+ setUserConstraint(t, orientation, constraint_plane, msg3);
+ }
+ }
+ else {
+ /* Successive presses on existing axis, cycle orientation modes. */
+ t->orientation.index = (t->orientation.index + 1) % ARRAY_SIZE(t->orientation.types);
+
+ if (t->orientation.index == 0) {
stopConstraint(t);
}
else {
- short orientation = (t->current_orientation != V3D_MANIP_GLOBAL ?
- t->current_orientation : V3D_MANIP_LOCAL);
+ const short *orientation_ptr = t->orientation.types[t->orientation.index];
+ const short orientation = orientation_ptr ? *orientation_ptr : V3D_MANIP_GLOBAL;
if (is_plane == false) {
setUserConstraint(t, orientation, constraint_axis, msg2);
}
@@ -1007,14 +1022,6 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
}
}
}
- else {
- if (is_plane == false) {
- setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_axis, msg2);
- }
- else {
- setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_plane, msg3);
- }
- }
}
t->redraw |= TREDRAW_HARD;
}
@@ -1753,7 +1760,7 @@ static bool helpline_poll(bContext *C)
return 0;
}
-static void drawHelpline(bContext *C, int x, int y, void *customdata)
+static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
{
TransInfo *t = (TransInfo *)customdata;
@@ -1769,32 +1776,7 @@ static void drawHelpline(bContext *C, int x, int y, void *customdata)
(float)t->mval[1],
};
- /* grease pencil only can edit one object at time because GP has
- * multiframe edition that replaces multiobject edition.
- * If multiobject edition is added, maybe this code will need
- * an update
- */
- if ((t->flag & T_POINTS) && (t->options & CTX_GPENCIL_STROKES) &&
- (t->around != V3D_AROUND_ACTIVE))
- {
- Object *ob = CTX_data_active_object(C);
- if ((ob) && (ob->type == OB_GPENCIL)) {
- FOREACH_TRANS_DATA_CONTAINER(t, tc) {
- float vecrot[3];
- copy_v3_v3(vecrot, t->center_global);
- mul_m4_v3(ob->obmat, vecrot);
- projectFloatViewEx(t, vecrot, cent, V3D_PROJ_TEST_CLIP_ZERO);
- }
- }
- else {
- /* normally, never must be used */
- projectFloatViewEx(t, t->center_global, cent, V3D_PROJ_TEST_CLIP_ZERO);
- }
- }
- else {
- projectFloatViewEx(t, t->center_global, cent, V3D_PROJ_TEST_CLIP_ZERO);
- }
-
+ projectFloatViewEx(t, t->center_global, cent, V3D_PROJ_TEST_CLIP_ZERO);
/* Offset the values for the area region. */
const float offset[2] = {
t->ar->winrct.xmin,
@@ -2122,12 +2104,12 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
if (t->spacetype == SPACE_VIEW3D) {
if ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
!RNA_property_is_set(op->ptr, prop) &&
- (t->current_orientation != V3D_MANIP_CUSTOM_MATRIX))
+ (t->orientation.user != V3D_MANIP_CUSTOM_MATRIX))
{
- t->scene->orientation_type = t->current_orientation;
- BLI_assert(((t->scene->orientation_index_custom == -1) && (t->custom_orientation == NULL)) ||
+ t->scene->orientation_type = t->orientation.user;
+ BLI_assert(((t->scene->orientation_index_custom == -1) && (t->orientation.custom == NULL)) ||
(BKE_scene_transform_orientation_get_index(
- t->scene, t->custom_orientation) == t->scene->orientation_index_custom));
+ t->scene, t->orientation.custom) == t->scene->orientation_index_custom));
}
}
}
@@ -2153,13 +2135,13 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
/* constraint orientation can be global, even if user selects something else
* so use the orientation in the constraint if set */
- short orientation = (t->con.mode & CON_APPLY) ? t->con.orientation : t->current_orientation;
+ short orientation = (t->con.mode & CON_APPLY) ? t->con.orientation : t->orientation.user;
if (orientation == V3D_MANIP_CUSTOM) {
const int orientation_index_custom = BKE_scene_transform_orientation_get_index(
- t->scene, t->custom_orientation);
+ t->scene, t->orientation.custom);
- /* Maybe we need a t->con.custom_orientation? Seems like it would always match t->custom_orientation. */
+ /* Maybe we need a t->con.custom_orientation? Seems like it would always match t->orientation.custom. */
orientation = V3D_MANIP_CUSTOM + orientation_index_custom;
BLI_assert(orientation >= V3D_MANIP_CUSTOM);
}
@@ -2420,7 +2402,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->con.mode |= CON_AXIS2;
}
- setUserConstraint(t, t->current_orientation, t->con.mode, "%s");
+ setUserConstraint(t, t->orientation.user, t->con.mode, "%s");
}
}
@@ -3134,7 +3116,7 @@ static void initBend(TransInfo *t)
data = MEM_callocN(sizeof(*data), __func__);
- curs = ED_view3d_cursor3d_get(t->scene, t->view)->location;
+ curs = t->scene->cursor.location;
copy_v3_v3(data->warp_sta, curs);
ED_view3d_win_to_3d(t->sa->spacedata.first, t->ar, curs, mval_fl, data->warp_end);
@@ -6064,7 +6046,7 @@ static void slide_origdata_interp_data_vert(
BM_loop_interp_from_face(bm, l, f_copy, false, false);
/* make sure face-attributes are correct (e.g. MTexPoly) */
- BM_elem_attrs_copy(sod->bm_origfaces, bm, f_copy, l->f);
+ BM_elem_attrs_copy_ex(sod->bm_origfaces, bm, f_copy, l->f, 0x0, CD_MASK_NORMAL);
/* weight the loop */
if (do_loop_weight) {
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index d777b034e76..ca341fc8738 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -503,8 +503,15 @@ typedef struct TransInfo {
/*************** NEW STUFF *********************/
short launch_event; /* event type used to launch transform */
- short current_orientation;
- TransformOrientation *custom_orientation; /* this gets used when current_orientation is V3D_MANIP_CUSTOM */
+ struct {
+ short user;
+ /* Used when user is global. */
+ short user_alt;
+ short index;
+ short *types[2];
+ /* this gets used when current_orientation is V3D_MANIP_CUSTOM */
+ TransformOrientation *custom;
+ } orientation;
short gizmo_flag; /* backup from view3d, to restore on end */
short prop_mode;
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 22d616572c1..fe997b77a31 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -709,7 +709,7 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
{
char orientation_str[128];
BLI_snprintf(orientation_str, sizeof(orientation_str), "%s \"%s\"",
- IFACE_("custom orientation"), t->custom_orientation->name);
+ IFACE_("custom orientation"), t->orientation.custom->name);
BLI_snprintf(text, sizeof(text), ftext, orientation_str);
setConstraint(t, t->spacemtx, mode, text);
break;
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 877407b888a..30b460d6677 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -170,52 +170,62 @@ static int trans_data_compare_rdist(const void *a, const void *b)
else return 0;
}
+static void sort_trans_data_dist_container(const TransInfo *t, TransDataContainer *tc)
+{
+ TransData *start = tc->data;
+ int i;
+
+ for (i = 0; i < tc->data_len && start->flag & TD_SELECTED; i++) {
+ start++;
+ }
+
+ if (i < tc->data_len) {
+ if (t->flag & T_PROP_CONNECTED) {
+ qsort(start, tc->data_len - i, sizeof(TransData), trans_data_compare_dist);
+ }
+ else {
+ qsort(start, tc->data_len - i, sizeof(TransData), trans_data_compare_rdist);
+ }
+ }
+}
void sort_trans_data_dist(TransInfo *t)
{
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *start = tc->data;
- int i;
+ sort_trans_data_dist_container(t, tc);
+ }
+}
- for (i = 0; i < tc->data_len && start->flag & TD_SELECTED; i++) {
- start++;
+static void sort_trans_data_container(TransDataContainer *tc)
+{
+ TransData *sel, *unsel;
+ TransData temp;
+ unsel = tc->data;
+ sel = tc->data;
+ sel += tc->data_len - 1;
+ while (sel > unsel) {
+ while (unsel->flag & TD_SELECTED) {
+ unsel++;
+ if (unsel == sel) {
+ return;
+ }
}
-
- if (i < tc->data_len) {
- if (t->flag & T_PROP_CONNECTED)
- qsort(start, tc->data_len - i, sizeof(TransData), trans_data_compare_dist);
- else
- qsort(start, tc->data_len - i, sizeof(TransData), trans_data_compare_rdist);
+ while (!(sel->flag & TD_SELECTED)) {
+ sel--;
+ if (unsel == sel) {
+ return;
+ }
}
+ temp = *unsel;
+ *unsel = *sel;
+ *sel = temp;
+ sel--;
+ unsel++;
}
}
-
static void sort_trans_data(TransInfo *t)
{
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- TransData *sel, *unsel;
- TransData temp;
- unsel = tc->data;
- sel = tc->data;
- sel += tc->data_len - 1;
- while (sel > unsel) {
- while (unsel->flag & TD_SELECTED) {
- unsel++;
- if (unsel == sel) {
- return;
- }
- }
- while (!(sel->flag & TD_SELECTED)) {
- sel--;
- if (unsel == sel) {
- return;
- }
- }
- temp = *unsel;
- *unsel = *sel;
- *sel = temp;
- sel--;
- unsel++;
- }
+ sort_trans_data_container(tc);
}
}
@@ -384,14 +394,12 @@ static void createTransCursor_view3d(TransInfo *t)
TransData *td;
Scene *scene = t->scene;
- View3D *v3d = ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) ? t->view : NULL;
- View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
-
- if ((cursor == &scene->cursor) && ID_IS_LINKED(scene)) {
+ if (ID_IS_LINKED(scene)) {
BKE_report(t->reports, RPT_ERROR, "Linked data can't text-space transform");
return;
}
+ View3DCursor *cursor = &scene->cursor;
{
BLI_assert(t->data_container_len == 1);
TransDataContainer *tc = t->data_container;
@@ -1271,20 +1279,18 @@ void restoreBones(TransDataContainer *tc)
/* ********************* armature ************** */
static void createTransArmatureVerts(TransInfo *t)
{
+ t->data_len_all = 0;
+
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
EditBone *ebo, *eboflip;
bArmature *arm = tc->obedit->data;
ListBase *edbo = arm->edbo;
- TransData *td, *td_old;
- float mtx[3][3], smtx[3][3], bonemat[3][3];
bool mirror = ((arm->flag & ARM_MIRROR_EDIT) != 0);
- int total_mirrored = 0, i;
- int oldtot;
- BoneInitData *bid = NULL;
+ int total_mirrored = 0;
tc->data_len = 0;
for (ebo = edbo->first; ebo; ebo = ebo->next) {
- oldtot = tc->data_len;
+ const int data_len_prev = tc->data_len;
if (EBONE_VISIBLE(arm, ebo) && !(ebo->flag & BONE_EDITMODE_LOCKED)) {
if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
@@ -1303,30 +1309,49 @@ static void createTransArmatureVerts(TransInfo *t)
}
}
- if (mirror && (oldtot < tc->data_len)) {
+ if (mirror && (data_len_prev < tc->data_len)) {
eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo);
if (eboflip)
total_mirrored++;
}
}
+ if (!tc->data_len) {
+ continue;
+ }
+
+ if (mirror) {
+ BoneInitData *bid = MEM_mallocN((total_mirrored + 1) * sizeof(BoneInitData), "BoneInitData");
+
+ /* trick to terminate iteration */
+ bid[total_mirrored].bone = NULL;
+
+ tc->custom.type.data = bid;
+ tc->custom.type.use_free = true;
+ }
+ t->data_len_all += tc->data_len;
+ }
+
+ transform_around_single_fallback(t);
+ t->data_len_all = -1;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (!tc->data_len) {
continue;
}
- transform_around_single_fallback(t);
+ EditBone *ebo, *eboflip;
+ bArmature *arm = tc->obedit->data;
+ ListBase *edbo = arm->edbo;
+ TransData *td, *td_old;
+ float mtx[3][3], smtx[3][3], bonemat[3][3];
+ bool mirror = ((arm->flag & ARM_MIRROR_EDIT) != 0);
+ BoneInitData *bid = tc->custom.type.data;
copy_m3_m4(mtx, tc->obedit->obmat);
pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransEditBone");
-
- if (mirror) {
- tc->custom.type.data = bid = MEM_mallocN((total_mirrored + 1) * sizeof(BoneInitData), "BoneInitData");
- tc->custom.type.use_free = true;
- }
-
- i = 0;
+ int i = 0;
for (ebo = edbo->first; ebo; ebo = ebo->next) {
td_old = td;
@@ -1493,7 +1518,8 @@ static void createTransArmatureVerts(TransInfo *t)
if (mirror) {
/* trick to terminate iteration */
- bid[total_mirrored].bone = NULL;
+ BLI_assert(i + 1 == (MEM_allocN_len(bid) / sizeof(*bid)));
+ bid[i].bone = NULL;
}
}
}
@@ -1685,27 +1711,22 @@ static void createTransCurveVerts(TransInfo *t)
#define SEL_F2 (1 << 1)
#define SEL_F3 (1 << 2)
- FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ t->data_len_all = 0;
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
Curve *cu = tc->obedit->data;
- TransData *td = NULL;
- Nurb *nu;
+ BLI_assert(cu->editnurb != NULL);
BezTriple *bezt;
BPoint *bp;
- float mtx[3][3], smtx[3][3];
int a;
int count = 0, countsel = 0;
const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
View3D *v3d = t->view;
short hide_handles = (v3d != NULL) ? ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0) : false;
- ListBase *nurbs;
-
- /* to be sure */
- if (cu->editnurb == NULL) return;
/* count total of vertices, check identical as in 2nd loop for making transdata! */
- nurbs = BKE_curve_editNurbs_get(cu);
- for (nu = nurbs->first; nu; nu = nu->next) {
+ ListBase *nurbs = BKE_curve_editNurbs_get(cu);
+ for (Nurb *nu = nurbs->first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
if (bezt->hide == 0) {
@@ -1737,13 +1758,33 @@ static void createTransCurveVerts(TransInfo *t)
else tc->data_len = countsel;
tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Curve EditMode)");
- transform_around_single_fallback(t);
+ t->data_len_all += tc->data_len;
+ }
+
+ transform_around_single_fallback(t);
+ t->data_len_all = -1;
+
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ if (tc->data_len == 0) {
+ continue;
+ }
+
+ Curve *cu = tc->obedit->data;
+ BezTriple *bezt;
+ BPoint *bp;
+ int a;
+ const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
+ View3D *v3d = t->view;
+ short hide_handles = (v3d != NULL) ? ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0) : false;
+
+ float mtx[3][3], smtx[3][3];
copy_m3_m4(mtx, tc->obedit->obmat);
pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
- td = tc->data;
- for (nu = nurbs->first; nu; nu = nu->next) {
+ TransData *td = tc->data;
+ ListBase *nurbs = BKE_curve_editNurbs_get(cu);
+ for (Nurb *nu = nurbs->first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
TransData *head, *tail;
head = tail = td;
@@ -1797,7 +1838,6 @@ static void createTransCurveVerts(TransInfo *t)
}
td++;
- count++;
tail++;
}
@@ -1835,7 +1875,6 @@ static void createTransCurveVerts(TransInfo *t)
}
td++;
- count++;
tail++;
}
if (is_prop_edit || bezt_tx & SEL_F3) {
@@ -1866,7 +1905,6 @@ static void createTransCurveVerts(TransInfo *t)
}
td++;
- count++;
tail++;
}
@@ -1938,7 +1976,6 @@ static void createTransCurveVerts(TransInfo *t)
}
td++;
- count++;
tail++;
}
}
@@ -2013,7 +2050,6 @@ static void createTransLatticeVerts(TransInfo *t)
td->val = NULL;
td++;
- count++;
}
}
bp++;
@@ -2704,9 +2740,15 @@ static void createTransEditVerts(TransInfo *t)
if (modifiers_getCageIndex(t->scene, tc->obedit, NULL, 1) != -1) {
int totleft = -1;
if (modifiers_isCorrectableDeformed(t->scene, tc->obedit)) {
+ /* Use evaluated state because we need b-bone cache. */
+ Scene *scene_eval = (Scene *)DEG_get_evaluated_id(t->depsgraph, &t->scene->id);
+ Object *obedit_eval = (Object *)DEG_get_evaluated_id(t->depsgraph, &tc->obedit->id);
+ BMEditMesh *em_eval = BKE_editmesh_from_object(obedit_eval);
/* check if we can use deform matrices for modifier from the
* start up to stack, they are more accurate than quats */
- totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(t->depsgraph, t->scene, tc->obedit, em, &defmats, &defcos);
+ totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(
+ t->depsgraph, scene_eval, obedit_eval, em_eval,
+ &defmats, &defcos);
}
/* if we still have more modifiers, also do crazyspace
@@ -3633,7 +3675,7 @@ static void posttrans_gpd_clean(bGPdata *gpd)
#endif
}
/* set cache flag to dirty */
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
static void posttrans_mask_clean(Mask *mask)
@@ -6516,9 +6558,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
// fixme... some of this stuff is not good
if (ob) {
if (ob->pose || BKE_key_from_object(ob))
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
else
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
/* 3 cases here for curve cleanups:
@@ -6700,7 +6742,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
* in pose mode (to use bone orientation matrix), in that case we don't do operations like autokeyframing. */
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
ob = tc->poseobj;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
else if (t->flag & T_POSE) {
@@ -6745,7 +6787,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* automatic inserting of keys and unkeyed tagging - only if transform wasn't canceled (or TFM_DUMMY) */
if (!canceled && (t->mode != TFM_DUMMY)) {
autokeyframe_pose(C, t->scene, ob, t->mode, targetless_ik);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else if (arm->flag & ARM_DELAYDEFORM) {
/* TODO(sergey): Armature is already updated by recalcData(), so we
@@ -6753,10 +6795,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
* possible yet within new dependency graph, and also other contexts
* might need to update their CoW copies.
*/
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
if (t->mode != TFM_DUMMY && motionpath_need_update_pose(t->scene, ob)) {
@@ -6814,13 +6856,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* pointcache refresh */
if (BKE_ptcache_object_reset(t->scene, ob, PTCACHE_RESET_OUTDATED))
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
/* Needed for proper updating of "quick cached" dynamics. */
/* Creates troubles for moving animated objects without */
/* autokey though, probably needed is an anim sys override? */
/* Please remove if some other solution is found. -jahka */
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
/* Set autokey if necessary */
if (!canceled) {
@@ -8148,7 +8190,7 @@ void flushTransPaintCurve(TransInfo *t)
static void createTransGPencil(bContext *C, TransInfo *t)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C); \
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
ToolSettings *ts = CTX_data_tool_settings(C);
@@ -8371,8 +8413,9 @@ static void createTransGPencil(bContext *C, TransInfo *t)
td->flag = 0;
- if (pt->flag & GP_SPOINT_SELECT)
+ if (pt->flag & GP_SPOINT_SELECT) {
td->flag |= TD_SELECTED;
+ }
/* for other transform modes (e.g. shrink-fatten), need to additional data
* but never for scale or mirror
@@ -8386,24 +8429,18 @@ static void createTransGPencil(bContext *C, TransInfo *t)
if ((gps->flag & (GP_STROKE_3DSPACE | GP_STROKE_2DSPACE | GP_STROKE_2DIMAGE)) == 0) {
/* screenspace */
td->protectflag = OB_LOCK_LOCZ | OB_LOCK_ROTZ | OB_LOCK_SCALEZ;
-
- /* apply matrix transformation relative to parent */
- copy_m3_m4(td->smtx, inverse_diff_mat); /* final position */
- copy_m3_m4(td->mtx, diff_mat); /* display position */
- copy_m3_m4(td->axismtx, diff_mat); /* axis orientation */
}
else {
/* configure 2D dataspace points so that they don't play up... */
if (gps->flag & (GP_STROKE_2DSPACE | GP_STROKE_2DIMAGE)) {
td->protectflag = OB_LOCK_LOCZ | OB_LOCK_ROTZ | OB_LOCK_SCALEZ;
- // XXX: matrices may need to be different?
}
-
- /* apply parent transformations */
- copy_m3_m4(td->smtx, inverse_diff_mat); /* final position */
- copy_m3_m4(td->mtx, diff_mat); /* display position */
- copy_m3_m4(td->axismtx, diff_mat); /* axis orientation */
}
+ /* apply parent transformations */
+ copy_m3_m4(td->smtx, inverse_diff_mat); /* final position */
+ copy_m3_m4(td->mtx, diff_mat); /* display position */
+ copy_m3_m4(td->axismtx, diff_mat); /* axis orientation */
+
/* Triangulation must be calculated again, so save the stroke for recalc function */
td->extra = gps;
@@ -8505,6 +8542,7 @@ void createTransData(bContext *C, TransInfo *t)
t->options |= CTX_GPENCIL_STROKES;
t->flag |= T_POINTS;
+ initTransDataContainers_FromObjectData(t, ob, NULL, 0);
createTransGPencil(C, t);
countAndCleanTransDataContainer(t);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index adf4d5bec4b..c566bcb7266 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -962,7 +962,7 @@ static void recalcData_objects(TransInfo *t)
/* old optimize trick... this enforces to bypass the depgraph */
if (!(arm->flag & ARM_DELAYDEFORM)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); /* sets recalc flags */
/* transformation of pose may affect IK tree, make sure it is rebuilt */
BIK_clear_data(ob->pose);
}
@@ -1021,10 +1021,10 @@ static void recalcData_objects(TransInfo *t)
/* sets recalc flags fully, instead of flushing existing ones
* otherwise proxies don't function correctly
*/
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
if (t->flag & T_TEXTURE)
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
@@ -1037,7 +1037,7 @@ static void recalcData_objects(TransInfo *t)
static void recalcData_cursor(TransInfo *t)
{
- DEG_id_tag_update(&t->scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&t->scene->id, ID_RECALC_COPY_ON_WRITE);
}
/* helper for recalcData() - for sequencer transforms */
@@ -1203,7 +1203,7 @@ void initTransDataContainers_FromObjectData(TransInfo *t, Object *obact, Object
const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT;
const short object_type = obact ? obact->type : -1;
- if ((object_mode & OB_MODE_EDIT) ||
+ if ((object_mode & OB_MODE_EDIT) || (t->options & CTX_GPENCIL_STROKES) ||
((object_mode & OB_MODE_POSE) && (object_type == OB_ARMATURE)))
{
if (t->data_container) {
@@ -1213,9 +1213,12 @@ void initTransDataContainers_FromObjectData(TransInfo *t, Object *obact, Object
bool free_objects = false;
if (objects == NULL) {
objects = BKE_view_layer_array_from_objects_in_mode(
- t->view_layer, &objects_len, {
+ t->view_layer,
+ (t->spacetype == SPACE_VIEW3D) ? t->view : NULL,
+ &objects_len, {
.object_mode = object_mode,
- .no_dup_data = true});
+ .no_dup_data = true,
+ });
free_objects = true;
}
@@ -1235,6 +1238,9 @@ void initTransDataContainers_FromObjectData(TransInfo *t, Object *obact, Object
tc->poseobj = objects[i];
tc->use_local_mat = true;
}
+ else if (t->options & CTX_GPENCIL_STROKES) {
+ tc->use_local_mat = true;
+ }
if (tc->use_local_mat) {
BLI_assert((t->flag & T_2D_EDIT) == 0);
@@ -1368,7 +1374,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
if (prop_id && (prop = RNA_struct_find_property(op->ptr, prop_id))) {
- SET_FLAG_FROM_TEST(t->flag, RNA_property_boolean_get(op->ptr, prop), T_ALT_TRANSFORM);
+ SET_FLAG_FROM_TEST(t->flag, !RNA_property_boolean_get(op->ptr, prop), T_ALT_TRANSFORM);
}
}
@@ -1395,10 +1401,22 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->around = V3D_AROUND_CURSOR;
}
- t->current_orientation = t->scene->orientation_type;
- t->custom_orientation = BKE_scene_transform_orientation_find(
+ t->orientation.user = t->scene->orientation_type;
+ t->orientation.custom = BKE_scene_transform_orientation_find(
t->scene, t->scene->orientation_index_custom);
+ t->orientation.index = 0;
+ ARRAY_SET_ITEMS(
+ t->orientation.types,
+ NULL,
+ &t->orientation.user);
+
+ /* Make second orientation local if both are global. */
+ if (t->orientation.user == V3D_MANIP_GLOBAL) {
+ t->orientation.user_alt = V3D_MANIP_LOCAL;
+ t->orientation.types[1] = &t->orientation.user_alt;
+ }
+
/* exceptional case */
if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) {
@@ -1489,8 +1507,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
RNA_property_is_set(op->ptr, prop)))
{
RNA_property_float_get_array(op->ptr, prop, &t->spacemtx[0][0]);
- t->current_orientation = V3D_MANIP_CUSTOM_MATRIX;
- t->custom_orientation = 0;
+ t->orientation.user = V3D_MANIP_CUSTOM_MATRIX;
+ t->orientation.custom = 0;
}
else if (op && ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
RNA_property_is_set(op->ptr, prop)))
@@ -1509,8 +1527,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
- t->current_orientation = orientation;
- t->custom_orientation = custom_orientation;
+ t->orientation.user = orientation;
+ t->orientation.custom = custom_orientation;
}
if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) &&
@@ -1848,9 +1866,7 @@ void calculateCenterLocal(
void calculateCenterCursor(TransInfo *t, float r_center[3])
{
- const float *cursor;
-
- cursor = ED_view3d_cursor3d_get(t->scene, t->view)->location;
+ const float *cursor = t->scene->cursor.location;
copy_v3_v3(r_center, cursor);
/* If edit or pose mode, move cursor in local space */
@@ -1861,22 +1877,6 @@ void calculateCenterCursor(TransInfo *t, float r_center[3])
}
r_center[2] = 0.0f;
}
- else if (t->options & CTX_GPENCIL_STROKES) {
- /* move cursor in local space */
- TransData *td = NULL;
- FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- float mat[3][3], imat[3][3];
-
- td = tc->data;
- Object *ob = td->ob;
- if (ob) {
- sub_v3_v3v3(r_center, r_center, ob->obmat[3]);
- copy_m3_m4(mat, ob->obmat);
- invert_m3_m3(imat, mat);
- mul_m3_v3(imat, r_center);
- }
- }
- }
}
void calculateCenterCursor2D(TransInfo *t, float r_center[2])
diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c
index 48c18ef2d8a..7d0584e3571 100644
--- a/source/blender/editors/transform/transform_gizmo_2d.c
+++ b/source/blender/editors/transform/transform_gizmo_2d.c
@@ -168,7 +168,7 @@ static void gizmo2d_calc_bounds(const bContext *C, float *r_center, float *r_min
Image *ima = ED_space_image(sima);
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
- view_layer, &objects_len);
+ view_layer, NULL, &objects_len);
if (!ED_uvedit_minmax_multi(CTX_data_scene(C), ima, objects, objects_len, r_min, r_max)) {
zero_v2(r_min);
zero_v2(r_max);
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 8872fe91ae3..74ab3867c5c 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -175,6 +175,11 @@ typedef struct GizmoGroup {
int twtype_prev;
int use_twtype_refresh;
+ /* Only for view orientation. */
+ struct {
+ float viewinv_m3[3][3];
+ } prev;
+
struct wmGizmo *gizmos[MAN_AXIS_LAST];
} GizmoGroup;
@@ -615,12 +620,10 @@ bool gimbal_axis(Object *ob, float gmat[3][3])
void ED_transform_calc_orientation_from_type(
const bContext *C, float r_mat[3][3])
{
- ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *obedit = CTX_data_edit_object(C);
- View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
Object *ob = OBACT(view_layer);
const short orientation_type = scene->orientation_type;
@@ -628,13 +631,13 @@ void ED_transform_calc_orientation_from_type(
ED_transform_calc_orientation_from_type_ex(
C, r_mat,
- scene, v3d, rv3d, ob, obedit, orientation_type, pivot_point);
+ scene, rv3d, ob, obedit, orientation_type, pivot_point);
}
void ED_transform_calc_orientation_from_type_ex(
const bContext *C, float r_mat[3][3],
/* extra args (can be accessed from context) */
- Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, Object *obedit,
+ Scene *scene, RegionView3D *rv3d, Object *ob, Object *obedit,
const short orientation_type, const int pivot_point)
{
bool ok = false;
@@ -690,7 +693,7 @@ void ED_transform_calc_orientation_from_type_ex(
}
case V3D_MANIP_CURSOR:
{
- ED_view3d_cursor3d_calc_mat3(scene, v3d, r_mat);
+ ED_view3d_cursor3d_calc_mat3(scene, r_mat);
ok = true;
break;
}
@@ -748,7 +751,7 @@ int ED_transform_calc_gizmo_stats(
float mat[3][3];
ED_transform_calc_orientation_from_type_ex(
C, mat,
- scene, v3d, rv3d, ob, obedit, orientation_type, pivot_point);
+ scene, rv3d, ob, obedit, orientation_type, pivot_point);
copy_m4_m3(rv3d->twmat, mat);
}
@@ -816,7 +819,7 @@ int ED_transform_calc_gizmo_stats(
{ \
invert_m4_m4(obedit->imat, obedit->obmat); \
uint objects_len = 0; \
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(view_layer, &objects_len); \
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode(view_layer, CTX_wm_view3d(C), &objects_len); \
for (uint ob_index = 0; ob_index < objects_len; ob_index++) { \
Object *ob_iter = objects[ob_index]; \
const bool use_mat_local = (ob_iter != obedit);
@@ -1184,7 +1187,7 @@ static void gizmo_get_idot(RegionView3D *rv3d, float r_idot[3])
}
static void gizmo_prepare_mat(
- const bContext *C, View3D *v3d, RegionView3D *rv3d, const struct TransformBounds *tbounds)
+ const bContext *C, RegionView3D *rv3d, const struct TransformBounds *tbounds)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -1213,7 +1216,7 @@ static void gizmo_prepare_mat(
copy_v3_v3(rv3d->twmat[3], tbounds->center);
break;
case V3D_AROUND_CURSOR:
- copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d)->location);
+ copy_v3_v3(rv3d->twmat[3], scene->cursor.location);
break;
}
}
@@ -1478,9 +1481,7 @@ static int gizmo_modal(
return OPERATOR_RUNNING_MODAL;
}
- const ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
struct TransformBounds tbounds;
@@ -1490,7 +1491,7 @@ static int gizmo_modal(
.use_only_center = true,
}, &tbounds))
{
- gizmo_prepare_mat(C, v3d, rv3d, &tbounds);
+ gizmo_prepare_mat(C, rv3d, &tbounds);
WM_gizmo_set_matrix_location(widget, rv3d->twmat[3]);
}
@@ -1658,9 +1659,7 @@ static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *gzgroup)
static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
GizmoGroup *ggd = gzgroup->customdata;
- ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
struct TransformBounds tbounds;
@@ -1683,7 +1682,7 @@ static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup)
return;
}
- gizmo_prepare_mat(C, v3d, rv3d, &tbounds);
+ gizmo_prepare_mat(C, rv3d, &tbounds);
/* *** set properties for axes *** */
@@ -1759,6 +1758,8 @@ static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgr
ARegion *ar = CTX_wm_region(C);
// View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
+ float viewinv_m3[3][3];
+ copy_m3_m4(viewinv_m3, rv3d->viewinv);
float idot[3];
/* when looking through a selected camera, the gizmo can be at the
@@ -1774,9 +1775,7 @@ static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgr
gizmo_get_idot(rv3d, idot);
/* *** set properties for axes *** */
-
- MAN_ITER_AXES_BEGIN(axis, axis_idx)
- {
+ MAN_ITER_AXES_BEGIN(axis, axis_idx) {
const short axis_type = gizmo_get_axis_type(axis_idx);
/* XXX maybe unset _HIDDEN flag on redraw? */
@@ -1801,8 +1800,23 @@ static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgr
WM_gizmo_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]);
break;
}
+ } MAN_ITER_AXES_END;
+
+ /* Refresh handled above when using view orientation. */
+ if (!equals_m3m3(viewinv_m3, ggd->prev.viewinv_m3)) {
+ {
+ Scene *scene = CTX_data_scene(C);
+ switch (scene->orientation_type) {
+ case V3D_MANIP_VIEW:
+ {
+ WIDGETGROUP_gizmo_refresh(C, gzgroup);
+ break;
+ }
+ }
+ }
+ copy_m3_m4(ggd->prev.viewinv_m3, rv3d->viewinv);
}
- MAN_ITER_AXES_END;
+
}
static bool WIDGETGROUP_gizmo_poll(const struct bContext *C, struct wmGizmoGroupType *gzgt)
@@ -1915,8 +1929,6 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmGizmoGroup
static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
- ScrArea *sa = CTX_wm_area(C);
- View3D *v3d = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ar->regiondata;
@@ -1934,7 +1946,7 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *gzgr
WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true);
}
else {
- gizmo_prepare_mat(C, v3d, rv3d, &tbounds);
+ gizmo_prepare_mat(C, rv3d, &tbounds);
WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
WM_gizmo_set_flag(gz, WM_GIZMO_MOVE_CURSOR, true);
@@ -2093,8 +2105,6 @@ static void WIDGETGROUP_xform_shear_setup(const bContext *UNUSED(C), wmGizmoGrou
static void WIDGETGROUP_xform_shear_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
- ScrArea *sa = CTX_wm_area(C);
- View3D *v3d = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ar->regiondata;
@@ -2114,7 +2124,7 @@ static void WIDGETGROUP_xform_shear_refresh(const bContext *C, wmGizmoGroup *gzg
}
}
else {
- gizmo_prepare_mat(C, v3d, rv3d, &tbounds);
+ gizmo_prepare_mat(C, rv3d, &tbounds);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
wmGizmo *gz = xgzgroup->gizmo[i][j];
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index f230841ddd2..5be23594afd 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -432,7 +432,7 @@ void initTransformOrientation(bContext *C, TransInfo *t)
Object *ob = CTX_data_active_object(C);
Object *obedit = CTX_data_active_object(C);
- switch (t->current_orientation) {
+ switch (t->orientation.user) {
case V3D_MANIP_GLOBAL:
unit_m3(t->spacemtx);
BLI_strncpy(t->spacename, IFACE_("global"), sizeof(t->spacename));
@@ -484,7 +484,7 @@ void initTransformOrientation(bContext *C, TransInfo *t)
case V3D_MANIP_CURSOR:
{
BLI_strncpy(t->spacename, IFACE_("cursor"), sizeof(t->spacename));
- ED_view3d_cursor3d_calc_mat3(t->scene, CTX_wm_view3d(C), t->spacemtx);
+ ED_view3d_cursor3d_calc_mat3(t->scene, t->spacemtx);
break;
}
case V3D_MANIP_CUSTOM_MATRIX:
@@ -492,9 +492,9 @@ void initTransformOrientation(bContext *C, TransInfo *t)
BLI_strncpy(t->spacename, IFACE_("custom"), sizeof(t->spacename));
break;
case V3D_MANIP_CUSTOM:
- BLI_strncpy(t->spacename, t->custom_orientation->name, sizeof(t->spacename));
+ BLI_strncpy(t->spacename, t->orientation.custom->name, sizeof(t->spacename));
- if (applyTransformOrientation(t->custom_orientation, t->spacemtx, t->spacename)) {
+ if (applyTransformOrientation(t->orientation.custom, t->spacemtx, t->spacename)) {
/* pass */
}
else {
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 22eb817c2b1..eb8bdb26450 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -994,7 +994,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
- t->view_layer, &objects_len);
+ t->view_layer, NULL, &objects_len);
float dist_sq = FLT_MAX;
if (ED_uvedit_nearest_uv_multi(t->scene, ima, objects, objects_len, co, &dist_sq, t->tsnap.snapPoint)) {
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 64ae9d4c018..64facb19f09 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -111,6 +111,7 @@ typedef struct SnapObjectData_Mesh {
typedef struct SnapObjectData_EditMesh {
SnapObjectData sd;
BVHTreeFromEditMesh *bvh_trees[3];
+ float min[3], max[3];
} SnapObjectData_EditMesh;
@@ -154,8 +155,19 @@ struct SnapObjectContext {
/** Common Utilities
* \{ */
+/**
+ * Calculate the minimum and maximum coordinates of the box that encompasses this mesh.
+ */
+static void bm_mesh_minmax(BMesh *bm, float r_min[3], float r_max[3])
+{
+ INIT_MINMAX(r_min, r_max);
+ BMIter iter;
+ BMVert *v;
-typedef void(*IterSnapObjsCallback)(SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data);
+ BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) {
+ minmax_v3v3_v3(r_min, r_max, v->co);
+ }
+}
static SnapObjectData_Mesh *snap_object_data_mesh_get(SnapObjectContext *sctx, Object *ob)
{
@@ -186,11 +198,14 @@ static SnapObjectData_EditMesh *snap_object_data_editmesh_get(SnapObjectContext
else {
SnapObjectData_EditMesh *sod = *sod_p = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(*sod));
sod->sd.type = SNAP_EDIT_MESH;
+ bm_mesh_minmax(em->bm, sod->min, sod->max);
}
return *sod_p;
}
+typedef void(*IterSnapObjsCallback)(SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data);
+
/**
* Walks through all objects in the scene to create the list of objects to snap.
*
@@ -211,7 +226,7 @@ static void iter_snap_objects(
Base *base_act = view_layer->basact;
for (Base *base = view_layer->object_bases.first; base != NULL; base = base->next) {
- if ((BASE_VISIBLE(v3d, base)) && (base->flag_legacy & BA_SNAP_FIX_DEPS_FIASCO) == 0 &&
+ if ((BASE_VISIBLE_BGMODE(v3d, base)) && (base->flag_legacy & BA_SNAP_FIX_DEPS_FIASCO) == 0 &&
!((snap_select == SNAP_NOT_SELECTED && ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL))) ||
(snap_select == SNAP_NOT_ACTIVE && base == base_act)))
{
@@ -230,36 +245,6 @@ static void iter_snap_objects(
}
}
-
-static bool walk_parent_bvhroot_cb(const BVHTreeAxisRange *bounds, void *userdata)
-{
- BVHTreeRay *ray = userdata;
- const float bbmin[3] = {bounds[0].min, bounds[1].min, bounds[2].min};
- const float bbmax[3] = {bounds[0].max, bounds[1].max, bounds[2].max};
- if (!isect_ray_aabb_v3_simple(ray->origin, ray->direction, bbmin, bbmax, &ray->radius, NULL)) {
- ray->radius = -1;
- }
- return false;
-}
-
-
-static bool isect_ray_bvhroot_v3(struct BVHTree *tree, const float ray_start[3], const float ray_dir[3], float *depth)
-{
- BVHTreeRay ray;
- copy_v3_v3(ray.origin, ray_start);
- copy_v3_v3(ray.direction, ray_dir);
-
- BLI_bvhtree_walk_dfs(tree, walk_parent_bvhroot_cb, NULL, NULL, &ray);
-
- if (ray.radius > 0) {
- *depth = ray.radius;
- return true;
- }
- else {
- return false;
- }
-}
-
/** \} */
/* -------------------------------------------------------------------- */
@@ -395,6 +380,17 @@ static bool raycastMesh(
return retval;
}
}
+ /* We pass a temp ray_start, set from object's boundbox, to avoid precision issues with
+ * very far away ray_start values (as returned in case of ortho view3d), see T50486, T38358.
+ */
+ if (len_diff > 400.0f) {
+ len_diff -= local_scale; /* make temp start point a bit away from bbox hit point. */
+ madd_v3_v3fl(ray_start_local, ray_normal_local, len_diff);
+ local_depth -= len_diff;
+ }
+ else {
+ len_diff = 0.0f;
+ }
SnapObjectData_Mesh *sod = snap_object_data_mesh_get(sctx, ob);
@@ -435,32 +431,6 @@ static bool raycastMesh(
}
}
- /* Only use closer ray_start in case of ortho view! In perspective one, ray_start may already
- * been *inside* boundbox, leading to snap failures (see T38409).
- * Note also ar might be null (see T38435), in this case we assume ray_start is ok!
- */
- if (len_diff == 0.0f) { /* do_ray_start_correction */
- /* We *need* a reasonably valid len_diff in this case.
- * Get the distance to bvhtree root */
- if (!isect_ray_bvhroot_v3(treedata->tree, ray_start_local, ray_normal_local, &len_diff)) {
- return retval;
- }
- }
- /* You need to make sure that ray_start is really far away,
- * because even in the Orthografic view, in some cases,
- * the ray can start inside the object (see T50486) */
- if (len_diff > 400.0f) {
- /* We pass a temp ray_start, set from object's boundbox, to avoid precision issues with
- * very far away ray_start values (as returned in case of ortho view3d), see T38358.
- */
- len_diff -= local_scale; /* make temp start point a bit away from bbox hit point. */
- madd_v3_v3fl(ray_start_local, ray_normal_local, len_diff);
- local_depth -= len_diff;
- }
- else {
- len_diff = 0.0f;
- }
-
float timat[3][3]; /* transpose inverse matrix for normals */
transpose_m3_m4(timat, imat);
@@ -533,7 +503,7 @@ static bool raycastEditMesh(
return retval;
}
- BLI_assert(em->ob->data == BKE_object_get_pre_modified_mesh(ob));
+ BLI_assert(BKE_object_get_pre_modified_mesh(em->ob) == BKE_object_get_pre_modified_mesh(ob));
float imat[4][4];
float ray_start_local[3], ray_normal_local[3];
@@ -554,18 +524,28 @@ static bool raycastEditMesh(
local_depth *= local_scale;
}
+ SnapObjectData_EditMesh *sod = snap_object_data_editmesh_get(sctx, em);
+
/* Test BoundBox */
- BoundBox *bb = BKE_mesh_texspace_get(em->ob->data, NULL, NULL, NULL);
- if (bb) {
- /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */
- if (!isect_ray_aabb_v3_simple(
- ray_start_local, ray_normal_local, bb->vec[0], bb->vec[6], &len_diff, NULL))
- {
- return retval;
- }
+
+ /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */
+ if (!isect_ray_aabb_v3_simple(
+ ray_start_local, ray_normal_local, sod->min, sod->max, &len_diff, NULL))
+ {
+ return retval;
}
- SnapObjectData_EditMesh *sod = snap_object_data_editmesh_get(sctx, em);
+ /* We pass a temp ray_start, set from object's boundbox, to avoid precision issues with
+ * very far away ray_start values (as returned in case of ortho view3d), see T50486, T38358.
+ */
+ if (len_diff > 400.0f) {
+ len_diff -= local_scale; /* make temp start point a bit away from bbox hit point. */
+ madd_v3_v3fl(ray_start_local, ray_normal_local, len_diff);
+ local_depth -= len_diff;
+ }
+ else {
+ len_diff = 0.0f;
+ }
if (sod->bvh_trees[2] == NULL) {
sod->bvh_trees[2] = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(BVHTreeFromEditMesh));
@@ -599,8 +579,11 @@ static bool raycastEditMesh(
bvh_cache = &em_bvh_cache;
}
+ /* Get original version of the edit_btmesh. */
+ BMEditMesh *em_orig = BKE_editmesh_from_object(DEG_get_original_object(ob));
+
bvhtree_from_editmesh_looptri_ex(
- treedata, em, elem_mask, looptri_num_active,
+ treedata, em_orig, elem_mask, looptri_num_active,
0.0f, 4, 6, bvh_cache);
if (elem_mask) {
@@ -610,34 +593,6 @@ static bool raycastEditMesh(
return retval;
}
}
- else {
- /* COW hack: Update pointers */
- treedata->em = em;
- }
-
- /* Only use closer ray_start in case of ortho view! In perspective one, ray_start
- * may already been *inside* boundbox, leading to snap failures (see T38409).
- * Note also ar might be null (see T38435), in this case we assume ray_start is ok!
- */
- if (sctx->use_v3d && !((RegionView3D *)sctx->v3d_data.ar->regiondata)->is_persp) { /* do_ray_start_correction */
- /* We *need* a reasonably valid len_diff in this case.
- * Get the distance to bvhtree root */
- if (!isect_ray_bvhroot_v3(treedata->tree, ray_start_local, ray_normal_local, &len_diff)) {
- return retval;
- }
- /* You need to make sure that ray_start is really far away,
- * because even in the Orthografic view, in some cases,
- * the ray can start inside the object (see T50486) */
- if (len_diff > 400.0f) {
- /* We pass a temp ray_start, set from object's boundbox, to avoid precision issues with
- * very far away ray_start values (as returned in case of ortho view3d), see T38358.
- */
- len_diff -= local_scale; /* make temp start point a bit away from bbox hit point. */
- madd_v3_v3fl(ray_start_local, ray_normal_local, len_diff);
- local_depth -= len_diff;
- }
- else len_diff = 0.0f;
- }
float timat[3][3]; /* transpose inverse matrix for normals */
transpose_m3_m4(timat, imat);
@@ -687,7 +642,10 @@ static bool raycastEditMesh(
retval = true;
if (r_index) {
- *r_index = BM_elem_index_get(em->looptris[hit.index][0]->f);
+ /* Get original version of the edit_btmesh. */
+ BMEditMesh *em_orig = BKE_editmesh_from_object(DEG_get_original_object(ob));
+
+ *r_index = BM_elem_index_get(em_orig->looptris[hit.index][0]->f);
}
}
}
@@ -865,7 +823,9 @@ static bool raycastObjects(
* \{ */
/* Test BoundBox */
-static bool snap_bound_box_check_dist(BoundBox *bb, float lpmat[4][4], float win_size[2], float mval[2], float dist_px_sq)
+static bool snap_bound_box_check_dist(
+ float min[3], float max[3], float lpmat[4][4],
+ float win_size[2], float mval[2], float dist_px_sq)
{
/* In vertex and edges you need to get the pixel distance from ray to BoundBox, see: T46099, T46816 */
@@ -875,7 +835,7 @@ static bool snap_bound_box_check_dist(BoundBox *bb, float lpmat[4][4], float win
bool dummy[3];
float bb_dist_px_sq = dist_squared_to_projected_aabb(
- &data_precalc, bb->vec[0], bb->vec[6], dummy);
+ &data_precalc, min, max, dummy);
if (bb_dist_px_sq > dist_px_sq) {
return false;
@@ -1293,10 +1253,7 @@ static short snap_mesh_polygon(
normalize_v3(r_no);
}
- if (r_index) {
- *r_index = nearest.index;
- }
-
+ *r_index = nearest.index;
return elem;
}
@@ -1395,9 +1352,7 @@ static short snap_mesh_edge_verts_mixed(
normalize_v3(r_no);
}
- if (r_index) {
- *r_index = nearest.index;
- }
+ *r_index = nearest.index;
}
return elem;
@@ -1429,7 +1384,10 @@ static short snapArmature(
if (use_obedit == false) {
/* Test BoundBox */
BoundBox *bb = BKE_armature_boundbox_get(ob);
- if (bb && !snap_bound_box_check_dist(bb, lpmat, snapdata->win_size, snapdata->mval, dist_px_sq)) {
+ if (bb && !snap_bound_box_check_dist(
+ bb->vec[0], bb->vec[6], lpmat,
+ snapdata->win_size, snapdata->mval, dist_px_sq))
+ {
return retval;
}
}
@@ -1558,7 +1516,10 @@ static short snapCurve(
if (use_obedit == false) {
/* Test BoundBox */
BoundBox *bb = BKE_curve_texspace_get(cu, NULL, NULL, NULL);
- if (bb && !snap_bound_box_check_dist(bb, lpmat, snapdata->win_size, snapdata->mval, dist_px_sq)) {
+ if (bb && !snap_bound_box_check_dist(
+ bb->vec[0], bb->vec[6], lpmat,
+ snapdata->win_size, snapdata->mval, dist_px_sq))
+ {
return 0;
}
}
@@ -1835,7 +1796,10 @@ static short snapMesh(
/* Test BoundBox */
BoundBox *bb = BKE_mesh_boundbox_get(ob);
- if (bb && !snap_bound_box_check_dist(bb, lpmat, snapdata->win_size, snapdata->mval, dist_px_sq)) {
+ if (bb && !snap_bound_box_check_dist(
+ bb->vec[0], bb->vec[6], lpmat, snapdata->win_size,
+ snapdata->mval, dist_px_sq))
+ {
return 0;
}
@@ -2036,7 +2000,7 @@ static short snapEditMesh(
BVHTreeFromEditMesh *treedata_vert = NULL, *treedata_edge = NULL;
- BLI_assert(em->ob->data == BKE_object_get_pre_modified_mesh(ob));
+ BLI_assert(BKE_object_get_pre_modified_mesh(ob) == BKE_object_get_pre_modified_mesh(ob));
UNUSED_VARS_NDEBUG(ob);
float lpmat[4][4];
@@ -2044,14 +2008,17 @@ static short snapEditMesh(
float dist_px_sq = SQUARE(*dist_px);
+ SnapObjectData_EditMesh *sod = snap_object_data_editmesh_get(sctx, em);
+
/* Test BoundBox */
- BoundBox *bb = BKE_mesh_texspace_get(em->ob->data, NULL, NULL, NULL);
- if (bb && !snap_bound_box_check_dist(bb, lpmat, snapdata->win_size, snapdata->mval, dist_px_sq)) {
+
+ /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */
+ if (!snap_bound_box_check_dist(
+ sod->min, sod->max, lpmat, snapdata->win_size, snapdata->mval, dist_px_sq))
+ {
return 0;
}
- SnapObjectData_EditMesh *sod = snap_object_data_editmesh_get(sctx, em);
-
BVHCache *em_bvh_cache = ((Mesh *)em->ob->data)->runtime.bvh_cache;
if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index f316b1a61cb..8de46442fe9 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -91,6 +91,7 @@
void ED_editors_init(bContext *C)
{
Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
wmWindowManager *wm = CTX_wm_manager(C);
if (wm->undo_stack == NULL) {
@@ -122,7 +123,15 @@ void ED_editors_init(bContext *C)
ID *data = ob->data;
ob->mode = OB_MODE_OBJECT;
if ((ob == obact) && !ID_IS_LINKED(ob) && !(data && ID_IS_LINKED(data))) {
- ED_object_mode_toggle(C, mode);
+ if (mode == OB_MODE_EDIT) {
+ ED_object_editmode_enter_ex(bmain, scene, ob, 0);
+ }
+ else if (mode == OB_MODE_POSE) {
+ ED_object_posemode_enter_ex(bmain, ob);
+ }
+ else {
+ ED_object_mode_toggle(C, mode);
+ }
}
}
}
@@ -130,11 +139,8 @@ void ED_editors_init(bContext *C)
}
/* image editor paint mode */
- {
- Scene *sce = CTX_data_scene(C);
- if (sce) {
- ED_space_image_paint_update(bmain, wm, sce);
- }
+ if (scene) {
+ ED_space_image_paint_update(bmain, wm, scene);
}
SWAP(int, reports->flag, reports_flag_prev);
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index d9805214964..dcdcc50db6e 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -481,7 +481,7 @@ void ED_uvedit_draw_main(
}
else if (show_uvedit) {
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob_iter = objects[ob_index];
draw_uvs(sima, scene, ob_iter, depsgraph);
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 50b7290e8fb..db8a9986880 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -1374,7 +1374,7 @@ static int uv_select_more_less(bContext *C, const bool select)
ToolSettings *ts = scene->toolsettings;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -1392,7 +1392,7 @@ static int uv_select_more_less(bContext *C, const bool select)
EDBM_select_less(em, true);
}
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
continue;
}
@@ -1463,7 +1463,7 @@ static int uv_select_more_less(bContext *C, const bool select)
if (changed) {
/* Select tagged loops. */
uv_select_flush_from_tag_loop(sima, scene, obedit, select);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
}
@@ -1537,7 +1537,7 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
INIT_MINMAX2(min, max);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
if (tool == UV_ALIGN_AUTO) {
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -1566,7 +1566,7 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
}
}
}
- tool = (max[0] - min[0] >= max[1] - min[1]) ? 'y' : 'x';
+ tool = (max[0] - min[0] >= max[1] - min[1]) ? UV_ALIGN_Y : UV_ALIGN_X;
}
ED_uvedit_center_multi(scene, ima, objects, objects_len, cent, 0);
@@ -1825,7 +1825,7 @@ static int uv_remove_doubles_to_selected(bContext *C, wmOperator *op)
const bool synced_selection = (ts->uv_flag & UV_SYNC_SELECTION) != 0;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
bool *changed = MEM_callocN(sizeof(bool) * objects_len, "uv_remove_doubles_selected.changed");
@@ -1971,7 +1971,7 @@ static int uv_remove_doubles_to_unselected(bContext *C, wmOperator *op)
const bool synced_selection = (ts->uv_flag & UV_SYNC_SELECTION) != 0;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
/* Calculate max possible number of kdtree nodes. */
int uv_maxlen = 0;
@@ -2254,7 +2254,7 @@ static int uv_select_all_exec(bContext *C, wmOperator *op)
int action = RNA_enum_get(op->ptr, "action");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
uv_select_all_perform_multi(scene, ima, objects, objects_len, action);
@@ -2585,7 +2585,7 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
int ret = uv_mouse_select_multi(C, objects, objects_len, co, extend, loop);
MEM_freeN(objects);
return ret;
@@ -2712,7 +2712,7 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
uvedit_pixel_to_float(sima, limit, 0.05f);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
if (pick) {
float co[2];
@@ -2752,7 +2752,7 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
- DEG_id_tag_update(obedit->data, DEG_TAG_COPY_ON_WRITE | DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -2839,7 +2839,7 @@ static int uv_select_split_exec(bContext *C, wmOperator *op)
bool changed_multi = false;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -2930,7 +2930,7 @@ static void uv_select_sync_flush(ToolSettings *ts, BMEditMesh *em, const short s
static void uv_select_tag_update_for_object(Depsgraph *depsgraph, const ToolSettings *ts, Object *obedit)
{
if (ts->uv_flag & UV_SYNC_SELECTION) {
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_main_add_notifier(NC_GEOM | ND_SELECT, obedit->data);
}
else {
@@ -3203,7 +3203,7 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
bool changed_multi = false;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
uv_select_all_perform_multi(scene, ima, objects, objects_len, SEL_DESELECT);
@@ -3367,7 +3367,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op)
bool changed_multi = false;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -3484,7 +3484,7 @@ static bool do_lasso_select_mesh_uv(
BLI_lasso_boundbox(&rect, mcords, moves);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
uv_select_all_perform_multi(scene, ima, objects, objects_len, SEL_DESELECT);
@@ -3645,7 +3645,7 @@ static int uv_snap_cursor_exec(bContext *C, wmOperator *op)
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
- view_layer, &objects_len);
+ view_layer, ((View3D *)NULL), &objects_len);
changed = uv_snap_cursor_to_selection(scene, ima, objects, objects_len, sima);
MEM_freeN(objects);
break;
@@ -3843,7 +3843,7 @@ static int uv_snap_selection_exec(bContext *C, wmOperator *op)
float offset[2] = {0};
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
if (target == 2) {
float center[2];
@@ -3934,7 +3934,7 @@ static int uv_pin_exec(bContext *C, wmOperator *op)
const bool synced_selection = (ts->uv_flag & UV_SYNC_SELECTION) != 0;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -4011,7 +4011,7 @@ static int uv_select_pinned_exec(bContext *C, wmOperator *UNUSED(op))
MLoopUV *luv;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -4106,7 +4106,7 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
if (ts->uv_flag & UV_SYNC_SELECTION) {
EDBM_mesh_hide(em, swap);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
@@ -4176,7 +4176,7 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
BM_select_history_validate(em->bm);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
@@ -4230,7 +4230,7 @@ static int uv_reveal_exec(bContext *C, wmOperator *op)
/* call the mesh function if we are in mesh sync sel */
if (ts->uv_flag & UV_SYNC_SELECTION) {
EDBM_mesh_reveal(em, select);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
@@ -4320,7 +4320,7 @@ static int uv_reveal_exec(bContext *C, wmOperator *op)
/* re-select tagged faces */
BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG);
- DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
@@ -4420,7 +4420,7 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
const bool mark_sharp = RNA_boolean_get(op->ptr, "mark_sharp");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
@@ -4564,7 +4564,7 @@ static int uv_mark_seam_exec(bContext *C, wmOperator *op)
const bool synced_selection = (ts->uv_flag & UV_SYNC_SELECTION) != 0;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, ((View3D *)NULL), &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index ffdd371dfdb..07184249d2c 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -2241,8 +2241,9 @@ static int stitch_init_all(bContext *C, wmOperator *op)
ssc->states = NULL;
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, v3d, &objects_len);
if (objects_len == 0) {
MEM_freeN(objects);
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index b344bb42318..ee637d4ae5e 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -617,7 +617,7 @@ static bool minimize_stretch_init(bContext *C, wmOperator *op)
bool implicit = true;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, CTX_wm_view3d(C), &objects_len);
if (!uvedit_have_selection_multi(scene, objects, objects_len, implicit)) {
MEM_freeN(objects);
@@ -849,11 +849,11 @@ void ED_uvedit_pack_islands(Scene *scene, Object *ob, BMesh *bm, bool selected,
void ED_uvedit_pack_islands_multi(
Scene *scene, Object **objects, const uint objects_len,
- bool selected, bool correct_aspect, bool do_rotate)
+ bool selected, bool correct_aspect, bool do_rotate, bool implicit)
{
ParamHandle *handle;
handle = construct_param_handle_multi(
- scene, objects, objects_len, true, false, selected, correct_aspect);
+ scene, objects, objects_len, implicit, false, selected, correct_aspect);
param_pack(handle, scene->toolsettings->uvcalc_margin, do_rotate);
param_flush(handle);
param_delete(handle);
@@ -866,7 +866,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
bool do_rotate = RNA_boolean_get(op->ptr, "rotate");
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, CTX_wm_view3d(C), &objects_len);
if (!uvedit_have_selection_multi(scene, objects, objects_len, true)) {
MEM_freeN(objects);
@@ -878,7 +878,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
else
RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin);
- ED_uvedit_pack_islands_multi(scene, objects, objects_len, true, true, do_rotate);
+ ED_uvedit_pack_islands_multi(scene, objects, objects_len, true, true, do_rotate, true);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -921,7 +921,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op))
ParamHandle *handle;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, CTX_wm_view3d(C), &objects_len);
if (!uvedit_have_selection_multi(scene, objects, objects_len, implicit)) {
MEM_freeN(objects);
@@ -1107,7 +1107,7 @@ static void uv_map_transform_center(
case V3D_AROUND_CURSOR: /* cursor center */
{
invert_m4_m4(ob->imat, ob->obmat);
- mul_v3_m4v3(r_center, ob->imat, ED_view3d_cursor3d_get(scene, v3d)->location);
+ mul_v3_m4v3(r_center, ob->imat, scene->cursor.location);
break;
}
case V3D_AROUND_ACTIVE:
@@ -1436,7 +1436,7 @@ static int unwrap_exec(bContext *C, wmOperator *op)
bool subsurf_error = use_subsurf;
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
if (!uvedit_have_selection_multi(scene, objects, objects_len, implicit)) {
MEM_freeN(objects);
@@ -1516,7 +1516,7 @@ static int unwrap_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
}
- ED_uvedit_pack_islands_multi(scene, objects, objects_len, true, true, true);
+ ED_uvedit_pack_islands_multi(scene, objects, objects_len, true, true, true, implicit);
MEM_freeN(objects);
@@ -1591,7 +1591,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
/* Note: objects that aren't touched are set to NULL (to skip clipping). */
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, &objects_len);
if (use_orthographic) {
/* Calculate average object position. */
@@ -1731,10 +1731,11 @@ void UV_OT_project_from_view(wmOperatorType *ot)
static int reset_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
-
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
+
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Mesh *me = (Mesh *)obedit->data;
@@ -1825,7 +1826,7 @@ static int sphere_project_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -1913,7 +1914,7 @@ static int cylinder_project_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -2028,7 +2029,7 @@ static int cube_project_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index 14b638da545..28f188158a3 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -869,7 +869,7 @@ Object *BlenderStrokeRenderer::NewMesh() const
DEG_graph_id_tag_update(freestyle_bmain,
freestyle_depsgraph,
&ob->id,
- OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
return ob;
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
index 2551d9a216d..d7828632ebf 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -193,7 +193,7 @@ void gpencil_apply_modifier_material(
copy_v4_v4(newmat->gp_style->fill_rgba, gps->runtime.tmp_fill_rgba);
BLI_ghash_insert(gh_color, mat->id.name, newmat);
- DEG_id_tag_update(&newmat->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&newmat->id, ID_RECALC_COPY_ON_WRITE);
}
/* reasign color index */
int idx = BKE_gpencil_get_material_index(ob, newmat);
@@ -211,6 +211,6 @@ void gpencil_apply_modifier_material(
mat->preview->flag[ICON_SIZE_ICON] |= PRV_CHANGED;
mat->preview->flag[ICON_SIZE_PREVIEW] |= PRV_CHANGED;
}
- DEG_id_tag_update(&mat->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&mat->id, ID_RECALC_COPY_ON_WRITE);
}
}
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 2eb24f08227..02e5d4ac479 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -140,6 +140,7 @@ data_to_c_simple(shaders/gpu_shader_flat_color_alpha_test_0_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_flat_id_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_area_borders_vert.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_2D_area_borders_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_widget_base_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_widget_base_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_2D_widget_shadow_vert.glsl SRC)
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index cf69af11aa6..5f87523829a 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -95,7 +95,7 @@ enum {
GPU_BATCH_OWNS_VBO = (1 << 0),
/* each vbo index gets bit-shifted */
GPU_BATCH_OWNS_INSTANCES = (1 << 30),
- GPU_BATCH_OWNS_INDEX = (1 << 31),
+ GPU_BATCH_OWNS_INDEX = (1u << 31u),
};
GPUBatch *GPU_batch_create_ex(GPUPrimType, GPUVertBuf *, GPUIndexBuf *, uint owns_flag);
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index 07d8a5f8c8b..22eb917f0bd 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -54,6 +54,7 @@ int GPU_color_depth(void);
void GPU_get_dfdy_factors(float fac[2]);
bool GPU_mip_render_workaround(void);
bool GPU_depth_blitting_workaround(void);
+bool GPU_unused_fb_slot_workaround(void);
bool GPU_mem_stats_supported(void);
void GPU_mem_stats_get(int *totalmem, int *freemem);
@@ -66,8 +67,9 @@ typedef enum GPUDeviceType {
GPU_DEVICE_NVIDIA = (1 << 0),
GPU_DEVICE_ATI = (1 << 1),
GPU_DEVICE_INTEL = (1 << 2),
- GPU_DEVICE_SOFTWARE = (1 << 3),
- GPU_DEVICE_UNKNOWN = (1 << 4),
+ GPU_DEVICE_INTEL_UHD = (1 << 3),
+ GPU_DEVICE_SOFTWARE = (1 << 4),
+ GPU_DEVICE_UNKNOWN = (1 << 5),
GPU_DEVICE_ANY = (0xff)
} GPUDeviceType;
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index 846adc44cee..a57ce674b77 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -76,7 +76,7 @@ void immAttr4fv(uint attr_id, const float data[4]);
void immAttr3ub(uint attr_id, unsigned char r, unsigned char g, unsigned char b);
void immAttr4ub(uint attr_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
-void immAttr3ubv(uint attr_id, const unsigned char data[4]);
+void immAttr3ubv(uint attr_id, const unsigned char data[3]);
void immAttr4ubv(uint attr_id, const unsigned char data[4]);
/* Explicitly skip an attribute. */
diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h
index 113a3e894d0..7a271caf079 100644
--- a/source/blender/gpu/GPU_vertex_format.h
+++ b/source/blender/gpu/GPU_vertex_format.h
@@ -92,6 +92,16 @@ uint GPU_vertformat_attr_add(
void GPU_vertformat_alias_add(GPUVertFormat *, const char *alias);
int GPU_vertformat_attr_id_get(const GPUVertFormat *, const char *name);
+/**
+ * This makes the "virtual" attribs with suffixes "0", "1", "2" to access triangle data in the vertex
+ * shader.
+ *
+ * IMPORTANT:
+ * - Call this before creating the vertex buffer and after creating all attributes
+ * - Only first vertex out of 3 has the correct information. Use flat output with GL_FIRST_VERTEX_CONVENTION.
+ **/
+void GPU_vertformat_triple_load(GPUVertFormat *format);
+
/* format conversion */
typedef struct GPUPackedNormal {
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 2237a6ea49c..8fcc69b31bc 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -95,6 +95,9 @@ static struct GPUGlobal {
* GPU_DEPTH32F_STENCIL8. Then Blitting depth will work but blitting stencil will
* still be broken. */
bool depth_blitting_workaround;
+ /* Crappy driver don't know how to map framebuffer slot to output vars...
+ * We need to have no "holes" in the output buffer slots. */
+ bool unused_fb_slot_workaround;
} GG = {1, 0};
@@ -211,6 +214,11 @@ bool GPU_depth_blitting_workaround(void)
return GG.depth_blitting_workaround;
}
+bool GPU_unused_fb_slot_workaround(void)
+{
+ return GG.unused_fb_slot_workaround;
+}
+
void gpu_extensions_init(void)
{
/* during 2.8 development each platform has its own OpenGL minimum requirements
@@ -262,8 +270,26 @@ void gpu_extensions_init(void)
GG.device = GPU_DEVICE_ATI;
GG.driver = GPU_DRIVER_OFFICIAL;
+#ifdef _WIN32
+ if (strstr(version, "4.5.13399") ||
+ strstr(version, "4.5.13417"))
+ {
+ /* The renderers include:
+ * Mobility Radeon HD 5000;
+ * Radeon HD 7500M;
+ * Radeon HD 7570M;
+ * Radeon HD 7600M;
+ * And many others... */
+
+ GG.unused_fb_slot_workaround = true;
+ }
+#endif
+
#if defined(__APPLE__)
- if (strstr(renderer, "AMD Radeon Pro") || strstr(renderer, "AMD Radeon R9")) {
+ if (strstr(renderer, "AMD Radeon Pro") ||
+ strstr(renderer, "AMD Radeon R9") ||
+ strstr(renderer, "AMD Radeon RX"))
+ {
GG.depth_blitting_workaround = true;
}
#endif
@@ -279,6 +305,12 @@ void gpu_extensions_init(void)
{
GG.device = GPU_DEVICE_INTEL;
GG.driver = GPU_DRIVER_OFFICIAL;
+
+ if (strstr(renderer, "UHD Graphics") ||
+ strstr(renderer, "Kaby Lake GT2"))
+ {
+ GG.device |= GPU_DEVICE_INTEL_UHD;
+ }
}
else if ((strstr(renderer, "Mesa DRI R")) ||
(strstr(renderer, "Radeon") && strstr(vendor, "X.Org")) ||
@@ -320,6 +352,18 @@ void gpu_extensions_init(void)
gpu_detect_mip_render_workaround();
+ if (G.debug & G_DEBUG_GPU_FORCE_WORKAROUNDS) {
+ printf("\n");
+ printf("GPU: Bypassing workaround detection.\n");
+ printf("GPU: OpenGL indentification strings\n");
+ printf("GPU: vendor: %s\n", vendor);
+ printf("GPU: renderer: %s\n", renderer);
+ printf("GPU: version: %s\n\n", version);
+ GG.mip_render_workaround = true;
+ GG.depth_blitting_workaround = true;
+ GG.unused_fb_slot_workaround = true;
+ }
+
/* df/dy calculation factors, those are dependent on driver */
if ((strstr(vendor, "ATI") && strstr(version, "3.3.10750"))) {
GG.dfdyfactors[0] = 1.0;
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index f92899f91a0..8714c72686c 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -416,6 +416,63 @@ static void gpu_framebuffer_update_attachments(GPUFrameBuffer *fb)
glDrawBuffer(GL_NONE);
}
+/**
+ * Hack to solve the problem of some bugged AMD GPUs (see `GPU_unused_fb_slot_workaround`).
+ * If there is an empty color slot between the color slots,
+ * all textures after this slot are apparently skipped/discarded.
+ **/
+static void gpu_framebuffer_update_attachments_and_fill_empty_slots(GPUFrameBuffer *fb)
+{
+ GLenum gl_attachments[GPU_FB_MAX_COLOR_ATTACHMENT];
+ int dummy_tex = 0;
+
+ BLI_assert(GPU_framebuffer_active_get() == fb);
+
+ /* Update attachments */
+ for (GPUAttachmentType type = GPU_FB_MAX_ATTACHEMENT; type--;) {
+ GPUTexture *tex = fb->attachments[type].tex;
+
+ if (type >= GPU_FB_COLOR_ATTACHMENT0) {
+ int slot = type - GPU_FB_COLOR_ATTACHMENT0;
+ if (tex != NULL || (dummy_tex != 0)) {
+ gl_attachments[slot] = convert_attachment_type_to_gl(type);
+
+ if (dummy_tex == 0) {
+ dummy_tex = GPU_texture_opengl_bindcode(tex);
+ }
+ }
+ else {
+ gl_attachments[slot] = GL_NONE;
+ }
+ }
+ else {
+ dummy_tex = 0;
+ }
+
+ if ((dummy_tex != 0) && tex == NULL) {
+ /* Fill empty slot */
+ glFramebufferTexture(GL_FRAMEBUFFER, convert_attachment_type_to_gl(type), dummy_tex, 0);
+ }
+ else if (GPU_FB_ATTACHEMENT_IS_DIRTY(fb->dirty_flag, type)) {
+ if (tex != NULL) {
+ gpu_framebuffer_attachment_attach(&fb->attachments[type], type);
+
+ fb->multisample = (GPU_texture_samples(tex) > 0);
+ fb->width = GPU_texture_width(tex);
+ fb->height = GPU_texture_height(tex);
+ }
+ else {
+ gpu_framebuffer_attachment_detach(&fb->attachments[type], type);
+ }
+ }
+ }
+ fb->dirty_flag = 0;
+
+ /* Update draw buffers (color targets)
+ * This state is saved in the FBO */
+ glDrawBuffers(GPU_FB_MAX_COLOR_ATTACHMENT, gl_attachments);
+}
+
#define FRAMEBUFFER_STACK_DEPTH 16
@@ -451,8 +508,15 @@ void GPU_framebuffer_bind(GPUFrameBuffer *fb)
gpu_framebuffer_current_set(fb);
- if (fb->dirty_flag != 0)
- gpu_framebuffer_update_attachments(fb);
+ if (fb->dirty_flag != 0) {
+ if (GPU_unused_fb_slot_workaround()) {
+ /* XXX: Please AMD, fix this. */
+ gpu_framebuffer_update_attachments_and_fill_empty_slots(fb);
+ }
+ else {
+ gpu_framebuffer_update_attachments(fb);
+ }
+ }
/* TODO manually check for errors? */
#if 0
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index fecac55087f..9b64d48fe50 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -86,7 +86,7 @@ static void rect_subregion_stride_calc(const rcti *src, const rcti *dst, SubRect
const int y = dst->ymin - src->ymin;
BLI_assert(src->xmin <= dst->xmin && src->ymin <= dst->ymin &&
- src->ymax >= dst->ymax && src->ymax >= dst->ymax);
+ src->xmax >= dst->xmax && src->ymax >= dst->ymax);
BLI_assert(x >= 0 && y >= 0);
r_sub->start = (uint)((src_x * y) + x);
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index d428e2f9bd9..5aec6b17218 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -68,6 +68,7 @@ extern char datatoc_gpu_shader_flat_color_frag_glsl[];
extern char datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl[];
extern char datatoc_gpu_shader_flat_id_frag_glsl[];
extern char datatoc_gpu_shader_2D_area_borders_vert_glsl[];
+extern char datatoc_gpu_shader_2D_area_borders_frag_glsl[];
extern char datatoc_gpu_shader_2D_vert_glsl[];
extern char datatoc_gpu_shader_2D_flat_color_vert_glsl[];
extern char datatoc_gpu_shader_2D_smooth_color_uniform_alpha_vert_glsl[];
@@ -356,12 +357,15 @@ GPUShader *GPU_shader_create_ex(
UNUSED_VARS(shname);
#endif
+ /* At least a vertex shader and a fragment shader are required. */
+ BLI_assert((fragcode != NULL) && (vertexcode != NULL));
+
if (vertexcode)
shader->vertex = glCreateShader(GL_VERTEX_SHADER);
if (fragcode)
shader->fragment = glCreateShader(GL_FRAGMENT_SHADER);
if (geocode)
- shader->geometry = glCreateShader(GL_GEOMETRY_SHADER_EXT);
+ shader->geometry = glCreateShader(GL_GEOMETRY_SHADER);
shader->program = glCreateProgram();
@@ -900,7 +904,7 @@ static const GPUShaderStages builtin_shader_stages[GPU_NUM_BUILTIN_SHADERS] = {
[GPU_SHADER_2D_AREA_EDGES] =
{ datatoc_gpu_shader_2D_area_borders_vert_glsl,
- datatoc_gpu_shader_uniform_color_frag_glsl},
+ datatoc_gpu_shader_2D_area_borders_frag_glsl},
[GPU_SHADER_2D_WIDGET_BASE] =
{ datatoc_gpu_shader_2D_widget_base_vert_glsl,
datatoc_gpu_shader_2D_widget_base_frag_glsl},
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index 4641bde74b9..0944e5e4e44 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -178,8 +178,8 @@ static void gpu_validate_data_format(GPUTextureFormat tex_format, GPUDataFormat
}
else {
/* Integer formats */
- if (ELEM(tex_format, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) {
- if (ELEM(tex_format, GPU_R16UI, GPU_RG16UI, GPU_R32UI)) {
+ if (ELEM(tex_format, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R8UI, GPU_R32UI)) {
+ if (ELEM(tex_format, GPU_R8UI, GPU_R16UI, GPU_RG16UI, GPU_R32UI)) {
BLI_assert(data_format == GPU_DATA_UNSIGNED_INT);
}
else {
@@ -218,8 +218,8 @@ static GPUDataFormat gpu_get_data_format_from_tex_format(GPUTextureFormat tex_fo
}
else {
/* Integer formats */
- if (ELEM(tex_format, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) {
- if (ELEM(tex_format, GPU_R16UI, GPU_RG16UI, GPU_R32UI)) {
+ if (ELEM(tex_format, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R8UI, GPU_R16UI, GPU_R32UI)) {
+ if (ELEM(tex_format, GPU_R8UI, GPU_R16UI, GPU_RG16UI, GPU_R32UI)) {
return GPU_DATA_UNSIGNED_INT;
}
else {
@@ -260,7 +260,7 @@ static GLenum gpu_get_gl_dataformat(GPUTextureFormat data_type, GPUTextureFormat
}
else {
/* Integer formats */
- if (ELEM(data_type, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) {
+ if (ELEM(data_type, GPU_R8UI, GPU_RG16I, GPU_R16I, GPU_RG16UI, GPU_R16UI, GPU_R32UI)) {
*format_flag |= GPU_FORMAT_INTEGER;
switch (gpu_get_component_count(data_type)) {
@@ -324,8 +324,10 @@ static uint gpu_get_bytesize(GPUTextureFormat data_type)
case GPU_R16UI:
case GPU_R16I:
case GPU_RG8:
+ case GPU_R16:
return 2;
case GPU_R8:
+ case GPU_R8UI:
return 1;
default:
BLI_assert(!"Texture format incorrect or unsupported\n");
@@ -357,7 +359,9 @@ static GLenum gpu_get_gl_internalformat(GPUTextureFormat format)
case GPU_R16UI: return GL_R16UI;
case GPU_RG8: return GL_RG8;
case GPU_RG16UI: return GL_RG16UI;
+ case GPU_R16: return GL_R16;
case GPU_R8: return GL_R8;
+ case GPU_R8UI: return GL_R8UI;
/* Special formats texture & renderbuffer */
case GPU_R11F_G11F_B10F: return GL_R11F_G11F_B10F;
case GPU_DEPTH24_STENCIL8: return GL_DEPTH24_STENCIL8;
diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c
index c3de3d52b47..ca636d2e231 100644
--- a/source/blender/gpu/intern/gpu_vertex_format.c
+++ b/source/blender/gpu/intern/gpu_vertex_format.c
@@ -128,7 +128,7 @@ uint vertex_buffer_size(const GPUVertFormat *format, uint vertex_len)
return format->stride * vertex_len;
}
-static const char *copy_attrib_name(GPUVertFormat *format, const char *name)
+static const char *copy_attrib_name(GPUVertFormat *format, const char *name, const char *suffix)
{
/* strncpy does 110% of what we need; let's do exactly 100% */
char *name_copy = format->names + format->name_offset;
@@ -139,8 +139,21 @@ static const char *copy_attrib_name(GPUVertFormat *format, const char *name)
const char c = name[i];
name_copy[i] = c;
if (c == '\0') {
- terminated = true;
- format->name_offset += (i + 1);
+ if (suffix) {
+ for (uint j = 0; j < available; ++j) {
+ const char s = suffix[j];
+ name_copy[i + j] = s;
+ if (s == '\0') {
+ terminated = true;
+ format->name_offset += (i + j + 1);
+ break;
+ }
+ }
+ }
+ else {
+ terminated = true;
+ format->name_offset += (i + 1);
+ }
break;
}
}
@@ -186,7 +199,7 @@ uint GPU_vertformat_attr_add(
const uint attrib_id = format->attr_len++;
GPUVertAttr *attrib = format->attribs + attrib_id;
- attrib->name[attrib->name_len++] = copy_attrib_name(format, name);
+ attrib->name[attrib->name_len++] = copy_attrib_name(format, name, NULL);
attrib->comp_type = comp_type;
attrib->gl_comp_type = convert_comp_type_to_gl(comp_type);
attrib->comp_len = (comp_type == GPU_COMP_I10) ? 4 : comp_len; /* system needs 10_10_10_2 to be 4 or BGRA */
@@ -205,7 +218,7 @@ void GPU_vertformat_alias_add(GPUVertFormat *format, const char *alias)
assert(attrib->name_len < GPU_VERT_ATTR_MAX_NAMES);
#endif
format->name_len++; /* multiname support */
- attrib->name[attrib->name_len++] = copy_attrib_name(format, alias);
+ attrib->name[attrib->name_len++] = copy_attrib_name(format, alias, NULL);
}
int GPU_vertformat_attr_id_get(const GPUVertFormat *format, const char *name)
@@ -221,6 +234,40 @@ int GPU_vertformat_attr_id_get(const GPUVertFormat *format, const char *name)
return -1;
}
+void GPU_vertformat_triple_load(GPUVertFormat *format)
+{
+#if TRUST_NO_ONE
+ assert(!format->packed);
+ assert(format->attr_len * 3 < GPU_VERT_ATTR_MAX_LEN);
+ assert(format->name_len + format->attr_len * 3 < GPU_VERT_ATTR_MAX_LEN);
+#endif
+
+ VertexFormat_pack(format);
+
+ uint old_attr_len = format->attr_len;
+ for (uint a_idx = 0; a_idx < old_attr_len; ++a_idx) {
+ GPUVertAttr *attrib = format->attribs + a_idx;
+ /* Duplicate attrib twice */
+ for (int i = 1; i < 3; ++i) {
+ GPUVertAttr *dst_attrib = format->attribs + format->attr_len;
+ memcpy(dst_attrib, attrib, sizeof(GPUVertAttr));
+ /* Increase offset to the next vertex. */
+ dst_attrib->offset += format->stride * i;
+ /* Only copy first name for now. */
+ dst_attrib->name_len = 0;
+ dst_attrib->name[dst_attrib->name_len++] = copy_attrib_name(format, attrib->name[0], (i == 1) ? "1" : "2");
+ format->attr_len++;
+ }
+
+#if TRUST_NO_ONE
+ assert(attrib->name_len < GPU_VERT_ATTR_MAX_NAMES);
+#endif
+ /* Add alias to first attrib. */
+ format->name_len++;
+ attrib->name[attrib->name_len++] = copy_attrib_name(format, attrib->name[0], "0");
+ }
+}
+
uint padding(uint offset, uint alignment)
{
const uint mod = offset % alignment;
@@ -380,7 +427,7 @@ void GPU_vertformat_from_interface(GPUVertFormat *format, const GPUShaderInterfa
GPUVertAttr *attrib = format->attribs + input->location;
- attrib->name[attrib->name_len++] = copy_attrib_name(format, name_buffer + input->name_offset);
+ attrib->name[attrib->name_len++] = copy_attrib_name(format, name_buffer + input->name_offset, NULL);
attrib->offset = 0; /* offsets & stride are calculated later (during pack) */
attrib->comp_len = calc_input_component_size(input);
attrib->sz = attrib->comp_len * 4;
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_area_borders_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_area_borders_frag.glsl
new file mode 100644
index 00000000000..620568db500
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_2D_area_borders_frag.glsl
@@ -0,0 +1,16 @@
+
+uniform vec4 color;
+uniform float scale;
+
+in vec2 uv;
+
+out vec4 fragColor;
+
+void main()
+{
+ /* Should be 0.8 but minimize the AA on the edges. */
+ float dist = (length(uv) - 0.78) * scale;
+
+ fragColor = color;
+ fragColor.a *= smoothstep(-0.09, 1.09, dist);
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_area_borders_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_area_borders_vert.glsl
index 5326076e269..816e12342a1 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_area_borders_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_area_borders_vert.glsl
@@ -7,35 +7,30 @@ uniform float scale;
in vec2 pos;
-const vec2 jitter_ofs[8] = vec2[8](
- vec2( 0.468813, -0.481430), vec2(-0.155755, -0.352820),
- vec2( 0.219306, -0.238501), vec2(-0.393286, -0.110949),
- vec2(-0.024699, 0.013908), vec2( 0.343805, 0.147431),
- vec2(-0.272855, 0.269918), vec2( 0.095909, 0.388710)
-);
+out vec2 uv;
+
void main()
{
int corner_id = (gl_VertexID / cornerLen) % 4;
- int jitter_id = gl_VertexID / (cornerLen * 4) % 8;
vec2 final_pos = pos * scale;
- if (corner_id == 0)
+ if (corner_id == 0) {
+ uv = pos + vec2(1.0, 1.0);
final_pos += rect.yw; /* top right */
- else if (corner_id == 1)
+ }
+ else if (corner_id == 1) {
+ uv = pos + vec2(-1.0, 1.0);
final_pos += rect.xw; /* top left */
- else if (corner_id == 2)
+ }
+ else if (corner_id == 2) {
+ uv = pos + vec2(-1.0, -1.0);
final_pos += rect.xz; /* bottom left */
- else
+ }
+ else {
+ uv = pos + vec2(1.0, -1.0);
final_pos += rect.yz; /* bottom right */
-
- /* Only jitter verts inside the corner (not the one shared with the edges). */
- if ((gl_VertexID % cornerLen) % (cornerLen - 2) != 0) {
- /* Only jitter intern verts not boundaries. */
- if ((gl_VertexID % 2) == 0) {
- final_pos += jitter_ofs[jitter_id];
- }
}
gl_Position = (ModelViewProjectionMatrix * vec4(final_pos, 0.0, 1.0));
diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h
index ff1784c54dd..8c903af2420 100644
--- a/source/blender/imbuf/IMB_colormanagement.h
+++ b/source/blender/imbuf/IMB_colormanagement.h
@@ -137,18 +137,20 @@ void IMB_display_buffer_transform_apply(unsigned char *display_buffer, float *li
void IMB_display_buffer_release(void *cache_handle);
-/* ** Display funcrions ** */
+/* ** Display functions ** */
int IMB_colormanagement_display_get_named_index(const char *name);
const char *IMB_colormanagement_display_get_indexed_name(int index);
const char *IMB_colormanagement_display_get_default_name(void);
struct ColorManagedDisplay *IMB_colormanagement_display_get_named(const char *name);
const char *IMB_colormanagement_display_get_none_name(void);
+const char *IMB_colormanagement_display_get_default_view_transform_name(
+ struct ColorManagedDisplay *display);
-/* ** View funcrions ** */
+/* ** View functions ** */
int IMB_colormanagement_view_get_named_index(const char *name);
const char *IMB_colormanagement_view_get_indexed_name(int index);
-/* ** Look funcrions ** */
+/* ** Look functions ** */
int IMB_colormanagement_look_get_named_index(const char *name);
const char *IMB_colormanagement_look_get_indexed_name(int index);
@@ -157,7 +159,7 @@ int IMB_colormanagement_colorspace_get_named_index(const char *name);
const char *IMB_colormanagement_colorspace_get_indexed_name(int index);
const char *IMB_colormanagement_view_get_default_name(const char *display_name);
-void IMB_colormanagment_colorspace_from_ibuf_ftype(struct ColorManagedColorspaceSettings *colorspace_settings, struct ImBuf *ibuf);
+void IMB_colormanagement_colorspace_from_ibuf_ftype(struct ColorManagedColorspaceSettings *colorspace_settings, struct ImBuf *ibuf);
/* ** RNA helper functions ** */
void IMB_colormanagement_display_items_add(struct EnumPropertyItem **items, int *totitem);
@@ -220,6 +222,11 @@ bool IMB_colormanagement_setup_glsl_draw_from_space_ctx(const struct bContext *C
/* Finish GLSL-based display space conversion */
void IMB_colormanagement_finish_glsl_draw(void);
+/* ** View transform ** */
+void IMB_colormanagement_init_default_view_settings(
+ struct ColorManagedViewSettings *view_settings,
+ const struct ColorManagedDisplaySettings *display_settings);
+
/* Roles */
enum {
COLOR_ROLE_SCENE_LINEAR = 0,
diff --git a/source/blender/imbuf/intern/IMB_colormanagement_intern.h b/source/blender/imbuf/intern/IMB_colormanagement_intern.h
index 0b4557e7bef..84e0bd6c599 100644
--- a/source/blender/imbuf/intern/IMB_colormanagement_intern.h
+++ b/source/blender/imbuf/intern/IMB_colormanagement_intern.h
@@ -103,6 +103,8 @@ struct ColorManagedView *colormanage_view_get_default(const ColorManagedDisplay
struct ColorManagedView *colormanage_view_add(const char *name);
struct ColorManagedView *colormanage_view_get_indexed(int index);
struct ColorManagedView *colormanage_view_get_named(const char *name);
+struct ColorManagedView *colormanage_view_get_named_for_display(
+ const char *display_name, const char *name);
struct ColorSpace *colormanage_colorspace_add(const char *name, const char *description, bool is_invertible, bool is_data);
struct ColorSpace *colormanage_colorspace_get_named(const char *name);
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index 1d287025a4e..5d0e59e1788 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -930,23 +930,33 @@ static OCIO_ConstProcessorRcPtr *display_to_scene_linear_processor(ColorManagedD
return (OCIO_ConstProcessorRcPtr *) display->to_scene_linear;
}
-static void init_default_view_settings(const ColorManagedDisplaySettings *display_settings,
- ColorManagedViewSettings *view_settings)
-{
- ColorManagedDisplay *display;
- ColorManagedView *default_view = NULL;
-
- display = colormanage_display_get_named(display_settings->display_device);
-
- if (display)
- default_view = colormanage_view_get_default(display);
-
- if (default_view)
- BLI_strncpy(view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform));
- else
+void IMB_colormanagement_init_default_view_settings(
+ ColorManagedViewSettings *view_settings,
+ const ColorManagedDisplaySettings *display_settings)
+{
+ /* First, try use "Default" view transform of the requested device. */
+ ColorManagedView *default_view = colormanage_view_get_named_for_display(
+ display_settings->display_device, "Default");
+ /* If that fails, we fall back to the default view transform of the display
+ * as per OCIO configuration. */
+ if (default_view == NULL) {
+ ColorManagedDisplay *display = colormanage_display_get_named(
+ display_settings->display_device);
+ if (display != NULL) {
+ default_view = colormanage_view_get_default(display);
+ }
+ }
+ if (default_view != NULL) {
+ BLI_strncpy(view_settings->view_transform,
+ default_view->name,
+ sizeof(view_settings->view_transform));
+ }
+ else {
view_settings->view_transform[0] = '\0';
-
+ }
+ /* TODO(sergey): Find a way to safely/reliable un-hardcode this. */
BLI_strncpy(view_settings->look, "None", sizeof(view_settings->look));
+ /* Initialize rest of the settings. */
view_settings->flag = 0;
view_settings->gamma = 1.0f;
view_settings->exposure = 0.0f;
@@ -1133,8 +1143,7 @@ void IMB_colormanagement_check_file_config(Main *bmain)
if (seq->strip) {
colormanage_check_colorspace_settings(&seq->strip->colorspace_settings, "sequencer strip");
}
- }
- SEQ_END
+ } SEQ_END;
}
/* ** check input color space settings ** */
@@ -2139,11 +2148,10 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSet
applied_view_settings = view_settings;
}
else {
- /* if no view settings were specified, use default display transformation
- * this happens for images which don't want to be displayed with render settings
- */
-
- init_default_view_settings(display_settings, &default_view_settings);
+ /* If no view settings were specified, use default ones, which will
+ * attempt not to do any extra color correction. */
+ IMB_colormanagement_init_default_view_settings(
+ &default_view_settings, display_settings);
applied_view_settings = &default_view_settings;
}
@@ -2364,6 +2372,12 @@ const char *IMB_colormanagement_display_get_none_name(void)
return colormanage_display_get_default_name();
}
+const char *IMB_colormanagement_display_get_default_view_transform_name(
+ struct ColorManagedDisplay *display)
+{
+ return colormanage_view_get_default_name(display);
+}
+
/*********************** View functions *************************/
const char *colormanage_view_get_default_name(const ColorManagedDisplay *display)
@@ -2422,6 +2436,22 @@ ColorManagedView *colormanage_view_get_indexed(int index)
return BLI_findlink(&global_views, index - 1);
}
+ColorManagedView *colormanage_view_get_named_for_display(
+ const char *display_name, const char *name)
+{
+ ColorManagedDisplay *display = colormanage_display_get_named(display_name);
+ if (display == NULL) {
+ return NULL;
+ }
+ LISTBASE_FOREACH(LinkData *, view_link, &display->views) {
+ ColorManagedView *view = view_link->data;
+ if (STRCASEEQ(name, view->name)) {
+ return view;
+ }
+ }
+ return NULL;
+}
+
int IMB_colormanagement_view_get_named_index(const char *name)
{
ColorManagedView *view = colormanage_view_get_named(name);
@@ -2571,7 +2601,7 @@ const char *IMB_colormanagement_colorspace_get_indexed_name(int index)
return "";
}
-void IMB_colormanagment_colorspace_from_ibuf_ftype(ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf)
+void IMB_colormanagement_colorspace_from_ibuf_ftype(ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf)
{
/* Don't modify non-color data space, it does not change with file type. */
ColorSpace *colorspace = colormanage_colorspace_get_named(colorspace_settings->name);
@@ -3139,7 +3169,8 @@ ColormanageProcessor *IMB_colormanagement_display_processor_new(const ColorManag
applied_view_settings = view_settings;
}
else {
- init_default_view_settings(display_settings, &default_view_settings);
+ IMB_colormanagement_init_default_view_settings(
+ &default_view_settings, display_settings);
applied_view_settings = &default_view_settings;
}
@@ -3436,11 +3467,10 @@ bool IMB_colormanagement_setup_glsl_draw_from_space(const ColorManagedViewSettin
applied_view_settings = view_settings;
}
else {
- /* if no view settings were specified, use default display transformation
- * this happens for images which don't want to be displayed with render settings
- */
-
- init_default_view_settings(display_settings, &default_view_settings);
+ /* If no view settings were specified, use default ones, which will
+ * attempt not to do any extra color correction. */
+ IMB_colormanagement_init_default_view_settings(
+ &default_view_settings, display_settings);
applied_view_settings = &default_view_settings;
}
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 9e5e822c4d5..28ba5c95020 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -502,22 +502,59 @@ enum {
LIB_TAG_NOT_ALLOCATED = 1 << 17,
};
-/* WARNING - when adding flags check on PSYS_RECALC */
-enum {
- /* RESET_AFTER_USE, used by update code (depsgraph). */
- ID_RECALC_NONE = 0,
- /* Generic recalc flag, when nothing else matches. */
- ID_RECALC = 1 << 0,
- /* Per-component update flags. */
- ID_RECALC_ANIMATION = 1 << 1,
- ID_RECALC_DRAW = 1 << 2,
- ID_RECALC_DRAW_CACHE = 1 << 3,
- ID_RECALC_GEOMETRY = 1 << 4,
- ID_RECALC_TRANSFORM = 1 << 5,
- ID_RECALC_COPY_ON_WRITE = 1 << 6,
- /* Special flag to check if SOMETHING was changed. */
- ID_RECALC_ALL = (~(int)0),
-};
+/* Tag given ID for an update in all the dependency graphs. */
+typedef enum IDRecalcFlag {
+ /* Individual update tags, this is what ID gets tagged for update with. */
+
+ /* Object transformation changed. */
+ ID_RECALC_TRANSFORM = (1 << 0),
+ /* Object geometry changed.
+ *
+ * When object of armature type gets tagged with this flag, it's pose is
+ * re-evaluated.
+ * When object of other type is tagged with this flag it makes the modifier
+ * stack to be re-evaluated.
+ * When object data type (mesh, curve, ...) gets tagged with this flag it
+ * makes all objects which shares this datablock to be updated. */
+ ID_RECALC_GEOMETRY = (1 << 1),
+ /* Animation or time changed and animation is to be re-evaluated. */
+ ID_RECALC_ANIMATION = (1 << 2),
+ /* Particle system changed; values are aligned with ID_RECALC_PSYS_xxx. */
+ ID_RECALC_PSYS_REDO = (1 << 3), /* Only do pathcache etc */
+ ID_RECALC_PSYS_RESET = (1 << 4), /* Reset everything including pointcache. */
+ ID_RECALC_PSYS_CHILD = (1 << 5), /* Only child settings changed. */
+ ID_RECALC_PSYS_PHYS = (1 << 6), /* Physics type changed. */
+ /* Update copy on write component without flushing down the road. */
+ ID_RECALC_COPY_ON_WRITE = (1 << 7),
+ /* Tag shading components for update. Only parameters of material changed).
+ */
+ ID_RECALC_SHADING = (1 << 8),
+ /* Selection of the ID itself or its components (for example, vertices) did
+ * change, and all the drawing data is to eb updated. */
+ ID_RECALC_SELECT = (1 << 9),
+ /* Flags on the base did change, and is to be compied onto all the copies of
+ * corresponding objects. */
+ ID_RECALC_BASE_FLAGS = (1 << 10),
+ ID_RECALC_POINT_CACHE = (1 << 11),
+ /* Only inform editors about the change. Is used to force update of editors
+ * when datablock which is not a part of dependency graph did change.
+ *
+ * For example, brush texture did change and the preview is to be
+ * re-rendered. */
+ ID_RECALC_EDITORS = (1 << 12),
+
+ /* Aggregate flags, use only for checks on runtime.
+ * Do NOT use those for tagging. */
+
+ /* Identifies that SOMETHING has been changed in this ID. */
+ ID_RECALC_ALL = ~(0),
+ /* Identifies that something in particle system did change. */
+ ID_RECALC_PSYS_ALL = (ID_RECALC_PSYS_REDO |
+ ID_RECALC_PSYS_RESET |
+ ID_RECALC_PSYS_CHILD |
+ ID_RECALC_PSYS_PHYS),
+
+} IDRecalcFlag;
/* To filter ID types (filter_id) */
/* XXX We cannot put all needed IDs inside an enum...
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 4d0f4ef1b0f..538604f46d0 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -692,6 +692,11 @@ typedef enum eDopeSheet_Flag {
+typedef struct SpaceAction_Runtime {
+ char flag;
+ char _pad0[7];
+} SpaceAction_Runtime;
+
/* Action Editor Space. This is defined here instead of in DNA_space_types.h */
typedef struct SpaceAction {
struct SpaceLink *next, *prev;
@@ -716,6 +721,8 @@ typedef struct SpaceAction {
char autosnap; /* automatic keyframe snapping mode */
char cache_display; /* (eTimeline_Cache_Flag) */
char _pad1[6];
+
+ SpaceAction_Runtime runtime;
} SpaceAction;
/* SpaceAction flag */
@@ -738,8 +745,6 @@ typedef enum eSAction_Flag {
SACTION_NODRAWGCOLORS = (1 << 7),
/* don't draw current frame number beside frame indicator */
SACTION_NODRAWCFRANUM = (1 << 8),
- /* temporary flag to force channel selections to be synced with main */
- SACTION_TEMP_NEEDCHANSYNC = (1 << 9),
/* don't perform realtime updates */
SACTION_NOREALTIMEUPDATES = (1 << 10),
/* move markers as well as keyframes */
@@ -750,6 +755,13 @@ typedef enum eSAction_Flag {
SACTION_SHOW_EXTREMES = (1 << 13),
} eSAction_Flag;
+
+/* SpaceAction_Runtime.flag */
+typedef enum eSAction_Runtime_Flag {
+ /** Temporary flag to force channel selections to be synced with main */
+ SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC = (1 << 0),
+} eSAction_Runtime_Flag;
+
/* SpaceAction Mode Settings */
typedef enum eAnimEdit_Context {
/* action on the active object */
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index b8b1066e1a9..0cf60a98376 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -225,11 +225,12 @@ typedef struct Curve {
/* edit, index in active nurb (BPoint or BezTriple) */
int actvert;
- char pad[4];
+ char overflow;
+ char spacemode, align_y;
+ char pad[3];
/* font part */
short lines;
- char spacemode, align_y;
float spacing, linedist, shear, fsize, wordspace, ulpos, ulheight;
float xof, yof;
float linewidth;
@@ -264,6 +265,8 @@ typedef struct Curve {
char bevfac1_mapping, bevfac2_mapping;
char pad2[2];
+ float fsize_realtime;
+ float pad3;
void *batch_cache;
} Curve;
@@ -340,6 +343,13 @@ enum {
CU_ALIGN_Y_BOTTOM = 4,
};
+/* Curve.overflow. */
+enum {
+ CU_OVERFLOW_NONE = 0,
+ CU_OVERFLOW_SCALE = 1,
+ CU_OVERFLOW_TRUNCATE = 2,
+};
+
/* Nurb.flag */
enum {
CU_SMOOTH = 1 << 0,
@@ -457,13 +467,14 @@ typedef enum eBezTriple_KeyframeType {
/* CharInfo.flag */
enum {
- /* note: CU_CHINFO_WRAP and CU_CHINFO_SMALLCAPS_TEST are set dynamically */
+ /* note: CU_CHINFO_WRAP, CU_CHINFO_SMALLCAPS_TEST and CU_CHINFO_TRUNCATE are set dynamically */
CU_CHINFO_BOLD = 1 << 0,
CU_CHINFO_ITALIC = 1 << 1,
CU_CHINFO_UNDERLINE = 1 << 2,
CU_CHINFO_WRAP = 1 << 3, /* wordwrap occurred here */
CU_CHINFO_SMALLCAPS = 1 << 4,
CU_CHINFO_SMALLCAPS_CHECK = 1 << 5, /* set at runtime, checks if case switching is needed */
+ CU_CHINFO_OVERFLOW = 1 << 6, /* Set at runtime, indicates char that doesn't fit in text boxes. */
};
/* mixed with KEY_LINEAR but define here since only curve supports */
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 8a1bccc6957..43ce3649db3 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -269,6 +269,17 @@ typedef struct bGPDlayer {
float opacity; /* Opacity of the layer */
char viewlayername[64]; /* Name of the layer used to filter render output */
+ int blend_mode; /* blend modes */
+ char pad_[4];
+
+ /* annotation onion skin */
+ short gstep; /* Ghosts Before: max number of ghost frames to show between active frame and the one before it (0 = only the ghost itself) */
+ short gstep_next; /* Ghosts After: max number of ghost frames to show after active frame and the following it (0 = only the ghost itself) */
+
+ float gcolor_prev[3]; /* color for ghosts before the active frame */
+ float gcolor_next[3]; /* color for ghosts after the active frame */
+ char pad_1[4];
+
bGPDlayer_Runtime runtime;
} bGPDlayer;
@@ -292,6 +303,8 @@ typedef enum eGPDlayer_Flag {
GP_LAYER_VOLUMETRIC = (1 << 10),
/* Unlock color */
GP_LAYER_UNLOCK_COLOR = (1 << 12),
+ /* Mask Layer */
+ GP_LAYER_USE_MASK = (1 << 13),
} eGPDlayer_Flag;
/* bGPDlayer->onion_flag */
@@ -300,6 +313,16 @@ typedef enum eGPDlayer_OnionFlag {
GP_LAYER_ONIONSKIN = (1 << 0),
} eGPDlayer_OnionFlag;
+/* layer blend_mode */
+typedef enum eGPLayerBlendModes {
+ eGplBlendMode_Normal = 0,
+ eGplBlendMode_Overlay = 1,
+ eGplBlendMode_Add = 2,
+ eGplBlendMode_Subtract = 3,
+ eGplBlendMode_Multiply = 4,
+ eGplBlendMode_Divide = 5,
+} eGPLayerBlendModes;
+
/* ***************************************** */
/* GP Datablock */
diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h
index e363c0c54b2..c3e819c5538 100644
--- a/source/blender/makesdna/DNA_layer_types.h
+++ b/source/blender/makesdna/DNA_layer_types.h
@@ -37,7 +37,7 @@ extern "C" {
typedef struct Base {
struct Base *next, *prev;
short flag;
- short pad;
+ unsigned short local_view_bits;
short sx, sy;
struct Object *object;
unsigned int lay DNA_DEPRECATED;
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index e13d79fb562..b7ca261c121 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -771,7 +771,7 @@ typedef struct MeshDeformModifierData {
float *bindcos; /* deprecated storage of cage coords */
/* runtime */
- void (*bindfunc)(struct Scene *scene, struct MeshDeformModifierData *mmd, struct Mesh *cagemesh,
+ void (*bindfunc)(struct MeshDeformModifierData *mmd, struct Mesh *cagemesh,
float *vertexcos, int totvert, float cagemat[4][4]);
} MeshDeformModifierData;
@@ -1540,9 +1540,9 @@ typedef struct LaplacianDeformModifierData {
} LaplacianDeformModifierData;
-/* Smooth modifier flags */
+/* Laplacian Deform modifier flags */
enum {
- MOD_LAPLACIANDEFORM_BIND = 1,
+ MOD_LAPLACIANDEFORM_BIND = 1 << 0,
};
/* many of these options match 'solidify' */
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index a776fbbc3a6..fe921cf96ac 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -221,7 +221,7 @@ typedef struct bNode {
* and replacing all uses with per-instance data.
*/
short preview_xsize, preview_ysize; /* reserved size of the preview rect */
- short pad2[2];
+ short tmp_flag, pad2; /* Used at runtime when going through the tree. Initialize before use. */
struct uiBlock *block; /* runtime during drawing */
float ssr_id; /* XXX: eevee only, id of screen space reflection layer, needs to be a float to feed GPU_uniform. */
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 22b878ebac6..639b68b141d 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -156,6 +156,13 @@ typedef struct Object_Runtime {
struct GpencilBatchCache *gpencil_cache;
struct ObjectBBoneDeform *cached_bbone_deformation;
+
+ /* The custom data layer mask that was last used to calculate mesh_eval and mesh_deform_eval. */
+ uint64_t last_data_mask;
+
+ /* Did last modifier stack generation need mapping support? */
+ char last_need_mapping;
+ char pad[7];
} Object_Runtime;
typedef struct Object {
@@ -236,8 +243,7 @@ typedef struct Object {
short nlaflag; /* used for DopeSheet filtering settings (expanded/collapsed) */
short pad[2];
- /* did last modifier stack generation need mapping support? */
- char lastNeedMapping; /* bool */
+ char pad12;
char duplicator_visibility_flag;
/* dupli-frame settings */
@@ -245,7 +251,7 @@ typedef struct Object {
/* Depsgraph */
short base_flag; /* used by depsgraph, flushed from base */
- short pad8;
+ unsigned short base_local_view_bits; /* used by viewport, synced from base */
/** Collision mask settings */
unsigned short col_group, col_mask;
@@ -293,8 +299,6 @@ typedef struct Object {
struct DerivedMesh *derivedDeform, *derivedFinal;
void *pad7;
- uint64_t lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */
- uint64_t customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */
ListBase pc_ids;
@@ -520,7 +524,7 @@ enum {
/* NOTE: BA_HAS_RECALC_DATA can be re-used later if freed in readfile.c. */
// BA_HAS_RECALC_OB = (1 << 2), /* DEPRECATED */
// BA_HAS_RECALC_DATA = (1 << 3), /* DEPRECATED */
- BA_SNAP_FIX_DEPS_FIASCO = (1 << 2), /* Yes, re-use deprecated bit, all fine since it's runtime only. */
+ BA_SNAP_FIX_DEPS_FIASCO = (1 << 2), /* DEPRECATED, was runtime only, but was reusing an older flag. */
};
/* NOTE: this was used as a proper setting in past, so nullify before using */
@@ -536,17 +540,6 @@ enum {
/* #define OB_RADIO (1 << 11) */ /* deprecated */
/* #define OB_FROMGROUP (1 << 12) */ /* deprecated */
-/* WARNING - when adding flags check on PSYS_RECALC */
-/* ob->recalc (flag bits!) */
-enum {
- OB_RECALC_OB = 1 << 0,
- OB_RECALC_DATA = 1 << 1,
-/* time flag is set when time changes need recalc, so baked systems can ignore it */
- OB_RECALC_TIME = 1 << 2,
-/* only use for matching any flag, NOT as an argument since more flags may be added. */
- OB_RECALC_ALL = OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME,
-};
-
/* controller state */
#define OB_MAX_STATES 30
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index ebccb36a671..fce6d6512a7 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -306,7 +306,14 @@ typedef struct ParticleSystem {
float cfra, tree_frame, bvhtree_frame;
int seed, child_seed;
int flag, totpart, totunexist, totchild, totcached, totchildcache;
- short recalc, target_psys, totkeyed, bakespace;
+ /* NOTE: Recalc is one of ID_RECALC_PSYS_ALL flags.
+ *
+ * TODO(sergey): Use part->id.recalc instead of this duplicated flag
+ * somehow. */
+ int recalc;
+ int pad1;
+ short target_psys, totkeyed, bakespace;
+ short pad2;
char bb_uvname[3][64]; /* billboard uv name, MAX_CUSTOMDATA_LAYER_NAME */
@@ -347,7 +354,9 @@ typedef enum eParticleDrawFlag {
PART_DRAW_VEL = (1 << 0),
PART_DRAW_GLOBAL_OB = (1 << 1),
PART_DRAW_SIZE = (1 << 2),
- PART_DRAW_EMITTER = (1 << 3), /* render emitter also */
+#ifdef DNA_DEPRECATED
+ PART_DRAW_EMITTER = (1 << 3), /* render emitter also */ /* DEPRECATED */
+#endif
PART_DRAW_HEALTH = (1 << 4),
PART_ABS_PATH_TIME = (1 << 5),
PART_DRAW_COUNT_GR = (1 << 6),
@@ -542,15 +551,6 @@ typedef enum eParticleShapeFlag {
#define PART_CHILD_PARTICLES 1
#define PART_CHILD_FACES 2
-/* psys->recalc */
-/* starts from (1 << 3) so that the first bits can be ob->recalc */
-#define PSYS_RECALC_REDO (1 << 3) /* only do pathcache etc */
-#define PSYS_RECALC_RESET (1 << 4) /* reset everything including pointcache */
-#define PSYS_RECALC_TYPE (1 << 5) /* handle system type change */
-#define PSYS_RECALC_CHILD (1 << 6) /* only child settings changed */
-#define PSYS_RECALC_PHYS (1 << 7) /* physics type changed */
-#define PSYS_RECALC (PSYS_RECALC_REDO | PSYS_RECALC_RESET | PSYS_RECALC_TYPE | PSYS_RECALC_CHILD | PSYS_RECALC_PHYS)
-
/* psys->flag */
#define PSYS_CURRENT 1
#define PSYS_GLOBAL_HAIR 2
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index cb72d83e10b..c1853ce1745 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -263,7 +263,7 @@ typedef enum eScenePassType {
SCE_PASS_SUBSURFACE_DIRECT = (1 << 28),
SCE_PASS_SUBSURFACE_INDIRECT = (1 << 29),
SCE_PASS_SUBSURFACE_COLOR = (1 << 30),
- SCE_PASS_ROUGHNESS = (1 << 31),
+ SCE_PASS_ROUGHNESS = (1u << 31u),
} eScenePassType;
#define RE_PASSNAME_COMBINED "Combined"
@@ -521,7 +521,7 @@ typedef struct BakeData {
char save_mode;
char pad[3];
- char cage[64]; /* MAX_NAME */
+ struct Object *cage_object;
} BakeData;
/* BakeData.normal_swizzle (char) */
@@ -1441,13 +1441,12 @@ typedef struct DisplaySafeAreas {
/* Scene Display - used for store scene specific display settings for the 3d view */
typedef struct SceneDisplay {
float light_direction[3]; /* light direction for shadows/highlight */
- float shadow_shift;
+ float shadow_shift, shadow_focus;
/* Settings for Cavity Shader */
float matcap_ssao_distance;
float matcap_ssao_attenuation;
int matcap_ssao_samples;
- int pad;
/* OpenGL render engine settings. */
View3DShading shading;
@@ -1586,6 +1585,7 @@ typedef struct Scene {
/* Physics simulation settings */
struct PhysicsSettings physics_settings;
+ void *pad8;
uint64_t customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by BKE_object_handle_update() */
uint64_t customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */
@@ -1724,10 +1724,11 @@ enum {
#define R_STAMP_MEMORY 0x2000
#define R_STAMP_HIDE_LABELS 0x4000
#define R_STAMP_FRAME_RANGE 0x8000
+#define R_STAMP_HOSTNAME 0x10000
#define R_STAMP_ALL (R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_CAMERA|R_STAMP_SCENE| \
R_STAMP_NOTE|R_STAMP_MARKER|R_STAMP_FILENAME|R_STAMP_SEQSTRIP| \
R_STAMP_RENDERTIME|R_STAMP_CAMERALENS|R_STAMP_MEMORY| \
- R_STAMP_HIDE_LABELS|R_STAMP_FRAME_RANGE)
+ R_STAMP_HIDE_LABELS|R_STAMP_FRAME_RANGE|R_STAMP_HOSTNAME)
/* RenderData.alphamode */
#define R_ADDSKY 0
@@ -1785,7 +1786,7 @@ enum {
/* RenderData.engine (scene.c) */
extern const char *RE_engine_id_BLENDER_EEVEE;
-extern const char *RE_engine_id_BLENDER_OPENGL;
+extern const char *RE_engine_id_BLENDER_WORKBENCH;
extern const char *RE_engine_id_CYCLES;
/* **************** SCENE ********************* */
@@ -1806,30 +1807,40 @@ extern const char *RE_engine_id_CYCLES;
/* deprecate this! */
#define TESTBASE(v3d, base) ( \
+ (((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
(((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0) && \
(((base)->flag & BASE_SELECTED) != 0) && \
(((base)->flag & BASE_VISIBLE) != 0))
#define TESTBASELIB(v3d, base) ( \
+ (((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
(((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0) && \
(((base)->flag & BASE_SELECTED) != 0) && \
((base)->object->id.lib == NULL) && \
(((base)->flag & BASE_VISIBLE) != 0))
#define TESTBASELIB_BGMODE(v3d, base) ( \
+ ((v3d == NULL) || ((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
((v3d == NULL) || (((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0)) && \
(((base)->flag & BASE_SELECTED) != 0) && \
((base)->object->id.lib == NULL) && \
(((base)->flag & BASE_VISIBLE) != 0))
#define BASE_EDITABLE_BGMODE(v3d, base) ( \
+ ((v3d == NULL) || ((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
((v3d == NULL) || (((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0)) && \
((base)->object->id.lib == NULL) && \
(((base)->flag & BASE_VISIBLE) != 0))
#define BASE_SELECTABLE(v3d, base) ( \
+ (((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
(((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0) && \
(((1 << (base)->object->type) & (v3d)->object_type_exclude_select) == 0) && \
(((base)->flag & BASE_SELECTABLE) != 0))
#define BASE_VISIBLE(v3d, base) ( \
+ (((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
(((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0) && \
(((base)->flag & BASE_VISIBLE) != 0))
+#define BASE_VISIBLE_BGMODE(v3d, base) ( \
+ ((v3d == NULL) || ((v3d)->localvd == NULL) || ((v3d)->local_view_uuid & (base)->local_view_bits)) && \
+ ((v3d == NULL) || (((1 << (base)->object->type) & (v3d)->object_type_exclude_viewport) == 0)) && \
+ (((base)->flag & BASE_VISIBLE) != 0))
#define FIRSTBASE(_view_layer) ((_view_layer)->object_bases.first)
#define LASTBASE(_view_layer) ((_view_layer)->object_bases.last)
@@ -2134,7 +2145,9 @@ typedef enum eGPencil_SimplifyFlags {
/* Remove fill external line */
SIMPLIFY_GPENCIL_REMOVE_FILL_LINE = (1 << 4),
/* Simplify Shader FX */
- SIMPLIFY_GPENCIL_FX = (1 << 5)
+ SIMPLIFY_GPENCIL_FX = (1 << 5),
+ /* Simplify layer blending */
+ SIMPLIFY_GPENCIL_BLEND = (1 << 6),
} eGPencil_SimplifyFlags;
/* ToolSettings.gpencil_*_align - Stroke Placement mode flags */
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 99404fbf057..a62e7bc5036 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -368,7 +368,7 @@ enum {
#endif
/* update size of regions within the area */
AREA_FLAG_REGION_SIZE_UPDATE = (1 << 3),
-// AREA_FLAG_DEPRECATED_4 = (1 << 4),
+ AREA_FLAG_ACTIVE_TOOL_UPDATE = (1 << 4),
// AREA_FLAG_DEPRECATED_5 = (1 << 5),
/* used to check if we should switch back to prevspace (of a different type) */
AREA_FLAG_TEMP_TYPE = (1 << 6),
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 6e2fd412445..2e6aa25ad9b 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -391,8 +391,8 @@ typedef struct SequencerScopes {
#define SEQ_EDIT_OVERLAY_SHOW 1
#define SEQ_EDIT_OVERLAY_ABS 2
-#define SEQ_STRIP_OFSBOTTOM 0.2f
-#define SEQ_STRIP_OFSTOP 0.8f
+#define SEQ_STRIP_OFSBOTTOM 0.05f
+#define SEQ_STRIP_OFSTOP 0.95f
/* Editor->proxy_storage */
/* store proxies in project directory */
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 43781c47828..fd977a7dafb 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -358,6 +358,14 @@ typedef enum eSpaceOutliner_Search_Flags {
/** \name Graph Editor
* \{ */
+typedef struct SpaceIpo_Runtime {
+ /** #eGraphEdit_Runtime_Flag */
+ char flag;
+ char _pad[7];
+ /** Sampled snapshots of F-Curves used as in-session guides */
+ ListBase ghost_curves;
+} SpaceIpo_Runtime;
+
/* 'Graph' Editor (formerly known as the IPO Editor) */
typedef struct SpaceIpo {
SpaceLink *next, *prev;
@@ -371,8 +379,6 @@ typedef struct SpaceIpo {
struct bDopeSheet *ads; /* settings for filtering animation data (NOTE: we use a pointer due to code-linking issues) */
- ListBase ghostCurves; /* sampled snapshots of F-Curves used as in-session guides */
-
short mode; /* mode for the Graph editor (eGraphEdit_Mode) */
short autosnap; /* time-transform autosnapping settings for Graph editor (eAnimEdit_AutoSnap in DNA_action_types.h) */
int flag; /* settings for Graph editor (eGraphEdit_Flag) */
@@ -381,6 +387,8 @@ typedef struct SpaceIpo {
float cursorVal; /* cursor value (y-value, x-value is current frame) */
int around; /* pivot point for transforms */
int pad;
+
+ SpaceIpo_Runtime runtime;
} SpaceIpo;
@@ -408,8 +416,6 @@ typedef enum eGraphEdit_Flag {
SIPO_NODRAWCURSOR = (1 << 8),
/* only show handles of selected keyframes */
SIPO_SELVHANDLESONLY = (1 << 9),
- /* temporary flag to force channel selections to be synced with main */
- SIPO_TEMP_NEEDCHANSYNC = (1 << 10),
/* don't perform realtime updates */
SIPO_NOREALTIMEUPDATES = (1 << 11),
/* don't draw curves with AA ("beauty-draw") for performance */
@@ -429,6 +435,13 @@ typedef enum eGraphEdit_Mode {
SIPO_MODE_DRIVERS = 1,
} eGraphEdit_Mode;
+typedef enum eGraphEdit_Runtime_Flag {
+ /** Temporary flag to force channel selections to be synced with main. */
+ SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC = (1 << 0),
+ /** Temporary flag to force fcurves to recalculate colors. */
+ SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR = (1 << 1),
+} eGraphEdit_Runtime_Flag;
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -909,8 +922,11 @@ typedef struct SpaceImage {
float centx, centy; /* storage for offset while render drawing */
char mode; /* view/paint/mask */
+ /* Storage for sub-space types. */
+ char mode_prev;
+
char pin;
- short pad;
+ char _pad;
short curtile; /* the currently active tile of the image when tile is enabled, is kept in sync with the active faces tile */
short lock;
char dt_uv; /* UV draw type */
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index c9d16351635..a846e8f6468 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -148,6 +148,8 @@ typedef struct uiWidgetStateColors {
char inner_driven_sel[4];
char inner_overridden[4];
char inner_overridden_sel[4];
+ char inner_changed[4];
+ char inner_changed_sel[4];
float blend, pad;
} uiWidgetStateColors;
@@ -492,7 +494,9 @@ enum {
};
typedef struct SolidLight {
- int flag, pad;
+ int flag;
+ float smooth;
+ float pad[2];
float col[4], spec[4], vec[4];
} SolidLight;
@@ -585,9 +589,12 @@ typedef struct UserDef {
short gp_manhattendist, gp_euclideandist, gp_eraser;
short gp_settings; /* eGP_UserdefSettings */
short tb_leftmouse, tb_rightmouse;
- struct SolidLight light[3];
+ /* struct SolidLight light[3] DNA_DEPRECATED; */ /* Was using non-aligned struct! */
+ struct SolidLight light_param[4];
+ float light_ambient[3], pad7;
short gizmo_flag, gizmo_size;
- short pad6[3];
+ short edit_studio_light;
+ short pad6[2];
short textimeout, texcollectrate;
short dragthreshold;
int memcachelimit;
@@ -677,16 +684,29 @@ extern UserDef U; /* from blenkernel blender.c */
/* ***************** USERDEF ****************** */
+/* Toggles for unfinished 2.8 UserPref design. */
+//#define WITH_USERDEF_WORKSPACES
+//#define WITH_USERDEF_SYSTEM_SPLIT
+
/* UserDef.userpref (UI active_section) */
typedef enum eUserPref_Section {
- USER_SECTION_INTERFACE = 0,
- USER_SECTION_EDIT = 1,
- USER_SECTION_FILE = 2,
- USER_SECTION_SYSTEM = 3,
- USER_SECTION_THEME = 4,
- USER_SECTION_INPUT = 5,
- USER_SECTION_ADDONS = 6,
- USER_SECTION_LIGHT = 7,
+ USER_SECTION_INTERFACE = 0,
+ USER_SECTION_EDIT = 1,
+ USER_SECTION_SYSTEM_FILES = 2,
+ USER_SECTION_SYSTEM_GENERAL = 3,
+ USER_SECTION_THEME = 4,
+ USER_SECTION_INPUT = 5,
+ USER_SECTION_ADDONS = 6,
+ USER_SECTION_LIGHT = 7,
+#ifdef WITH_USERDEF_WORKSPACES
+ USER_SECTION_WORKSPACE_CONFIG = 8,
+ USER_SECTION_WORKSPACE_ADDONS = 9,
+ USER_SECTION_WORKSPACE_KEYMAPS = 10,
+#endif
+#ifdef WITH_USERDEF_SYSTEM_SPLIT
+ USER_SECTION_SYSTEM_DISPLAY = 11,
+ USER_SECTION_SYSTEM_DEVICES = 12,
+#endif
} eUserPref_Section;
/* UserDef.userpref_flag (State of the user preferences UI). */
@@ -803,7 +823,6 @@ typedef enum eUserpref_UI_Flag2 {
/* UserDef.app_flag */
typedef enum eUserpref_APP_Flag {
USER_APP_LOCK_UI_LAYOUT = (1 << 0),
- USER_APP_VIEW3D_HIDE_CURSOR = (1 << 1),
} eUserpref_APP_Flag;
/* Auto-Keying mode.
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index e778edff52e..79d2c230fdc 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -144,8 +144,11 @@ typedef struct View3DShading {
char light;
char background_type;
+ char cavity_type;
+ char pad[7];
char studio_light[256]; /* FILE_MAXFILE */
+ char lookdev_light[256]; /* FILE_MAXFILE */
char matcap[256]; /* FILE_MAXFILE */
float shadow_intensity;
@@ -163,6 +166,9 @@ typedef struct View3DShading {
float background_color[3];
+ float curvature_ridge_factor;
+ float curvature_valley_factor;
+
} View3DShading;
/* 3D Viewport Overlay settings */
@@ -232,7 +238,8 @@ typedef struct View3D {
char ob_centre_bone[64]; /* optional string for armature bone to define center, MAXBONENAME */
- unsigned int lay DNA_DEPRECATED;
+ unsigned short local_view_uuid;
+ short _pad6;
int layact DNA_DEPRECATED;
short ob_centre_cursor; /* optional bool for 3d cursor to define center */
@@ -245,8 +252,6 @@ typedef struct View3D {
float near, far;
float ofs[3] DNA_DEPRECATED; /* XXX deprecated */
- View3DCursor cursor;
-
char _pad[4];
short matcap_icon; /* icon id */
@@ -390,6 +395,7 @@ enum {
V3D_SHADING_MATCAP_FLIP_X = (1 << 6),
V3D_SHADING_SCENE_WORLD = (1 << 7),
V3D_SHADING_XRAY_BONE = (1 << 8),
+ V3D_SHADING_WORLD_ORIENTATION = (1 << 9),
};
/* View3DShading->color_type */
@@ -407,6 +413,13 @@ enum {
V3D_SHADING_BACKGROUND_VIEWPORT = 2,
};
+/* View3DShading->cavity_type */
+enum {
+ V3D_SHADING_CAVITY_SSAO = 0,
+ V3D_SHADING_CAVITY_CURVATURE = 1,
+ V3D_SHADING_CAVITY_BOTH = 2,
+};
+
/* View3DOverlay->flag */
enum {
V3D_OVERLAY_FACE_ORIENTATION = (1 << 0),
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index 2881f3138b2..ef9c27be196 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -139,23 +139,39 @@
/* allowed duplicate code from makesdna.c */
/**
- * parses the "[n]" on the end of an array name and returns the number of array elements n.
+ * parses the "[n1][n2]..." on the end of an array name and returns the number of array elements n1*n2*...
*/
int DNA_elem_array_size(const char *str)
{
- int a, mul = 1;
- const char *cp = NULL;
-
- for (a = 0; str[a]; a++) {
- if (str[a] == '[') {
- cp = &(str[a + 1]);
- }
- else if (str[a] == ']' && cp) {
- mul *= atoi(cp);
+ int result = 1;
+ int current = 0;
+ while (true) {
+ char c = *str++;
+ switch (c) {
+ case '\0':
+ return result;
+ case '[':
+ current = 0;
+ break;
+ case ']':
+ result *= current;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ current = current * 10 + (c - '0');
+ break;
+ default:
+ break;
}
}
-
- return mul;
}
/* ************************* END MAKE DNA ********************** */
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 99cff1d3d28..ee3a01d0669 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -1142,7 +1142,7 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name);
#define RNA_END \
} \
RNA_property_collection_end(&rna_macro_iter); \
- }
+ } ((void)0)
#define RNA_PROP_BEGIN(sptr, itemptr, prop) \
{ \
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index bf6e1d28cb2..6504cf8914b 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -61,6 +61,7 @@ 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_image_mode_all_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[];
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index 1b06077b1ea..0859d14a764 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -307,10 +307,6 @@ if(WITH_OPENSUBDIV)
add_definitions(-DWITH_OPENSUBDIV)
endif()
-if(WITH_OPENSUBDIV_MODIFIER)
- add_definitions(-DWITH_OPENSUBDIV_MODIFIER)
-endif()
-
if(WITH_OPENVDB)
add_definitions(-DWITH_OPENVDB)
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index b550b4043e3..2221c63d6b7 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -157,7 +157,7 @@ void rna_ID_name_set(PointerRNA *ptr, const char *value)
if (GS(id->name) == ID_OB) {
Object *ob = (Object *)id;
if (ob->type == OB_MBALL) {
- DEG_id_tag_update(&ob->id, DEG_TAG_GEOMETRY);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
}
@@ -404,7 +404,11 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag)
/* ensure flag us correct for the type */
switch (GS(id->name)) {
case ID_OB:
- if (flag & ~(OB_RECALC_ALL)) {
+ /* TODO(sergey): This is kind of difficult to predict since different
+ * object types supports different flags. Maybe does not worth checking
+ * for this at all. Or maybe let dependency graph to return whether
+ * the tag was valid or not. */
+ if (flag & ~(ID_RECALC_ALL)) {
BKE_report(reports, RPT_ERROR, "'Refresh' incompatible with Object ID type");
return;
}
@@ -536,7 +540,7 @@ static Material *rna_IDMaterials_pop_id(
return NULL;
}
- DEG_id_tag_update(id, OB_RECALC_DATA);
+ DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, id);
WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id);
@@ -547,7 +551,7 @@ static void rna_IDMaterials_clear_id(ID *id, Main *bmain, bool remove_material_s
{
BKE_material_clear_id(bmain, id, remove_material_slot);
- DEG_id_tag_update(id, OB_RECALC_DATA);
+ DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, id);
WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id);
}
@@ -1154,9 +1158,9 @@ static void rna_def_ID(BlenderRNA *brna)
PropertyRNA *prop, *parm;
static const EnumPropertyItem update_flag_items[] = {
- {OB_RECALC_OB, "OBJECT", 0, "Object", ""},
- {OB_RECALC_DATA, "DATA", 0, "Data", ""},
- {OB_RECALC_TIME, "TIME", 0, "Time", ""},
+ {ID_RECALC_TRANSFORM, "OBJECT", 0, "Object", ""},
+ {ID_RECALC_GEOMETRY, "DATA", 0, "Data", ""},
+ {ID_RECALC_ANIMATION, "TIME", 0, "Time", ""},
{0, NULL, 0, NULL, NULL}
};
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index cb6f62d35eb..98f9f37418f 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -2102,7 +2102,7 @@ static void rna_property_update(bContext *C, Main *bmain, Scene *scene, PointerR
if (ptr->id.data != NULL) {
const short id_type = GS(((ID *)ptr->id.data)->name);
if (ID_TYPE_IS_COW(id_type)) {
- DEG_id_tag_update(ptr->id.data, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_COPY_ON_WRITE);
}
}
/* End message bus. */
@@ -2111,7 +2111,7 @@ static void rna_property_update(bContext *C, Main *bmain, Scene *scene, PointerR
if (!is_rna || (prop->flag & PROP_IDPROPERTY)) {
/* WARNING! This is so property drivers update the display!
* not especially nice */
- DEG_id_tag_update(ptr->id.data, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_WINDOW, NULL);
/* Not nice as well, but the only way to make sure material preview
* is updated with custom nodes.
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 6c0ce6b124e..e43b62e8a75 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -524,7 +524,7 @@ static NlaTrack *rna_NlaTrack_new(ID *id, AnimData *adt, Main *bmain, bContext *
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
DEG_relations_tag_update(bmain);
- DEG_id_tag_update_ex(bmain, id, DEG_TAG_TIME | DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, id, ID_RECALC_ANIMATION | ID_RECALC_COPY_ON_WRITE);
return new_track;
}
@@ -544,7 +544,7 @@ static void rna_NlaTrack_remove(ID *id, AnimData *adt, Main *bmain, bContext *C,
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
DEG_relations_tag_update(bmain);
- DEG_id_tag_update_ex(bmain, id, DEG_TAG_TIME | DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, id, ID_RECALC_ANIMATION | ID_RECALC_COPY_ON_WRITE);
}
static PointerRNA rna_NlaTrack_active_get(PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index c3e68cf0869..e07271f3009 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -152,7 +152,7 @@ static void rna_Armature_update_layers(Main *bmain, Scene *UNUSED(scene), Pointe
ob->pose->proxy_layer = arm->layer;
}
- DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_GEOM | ND_DATA, arm);
}
@@ -160,7 +160,7 @@ static void rna_Armature_redraw_data(Main *UNUSED(bmain), Scene *UNUSED(scene),
{
ID *id = ptr->id.data;
- DEG_id_tag_update(id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
}
@@ -190,20 +190,20 @@ static void rna_Bone_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
bArmature *arm = (bArmature *)id;
if (arm->flag & ARM_HAS_VIZ_DEPS) {
- DEG_id_tag_update(id, OB_RECALC_DATA);
+ DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
}
- DEG_id_tag_update(id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE);
}
else if (GS(id->name) == ID_OB) {
Object *ob = (Object *)id;
bArmature *arm = (bArmature *)ob->data;
if (arm->flag & ARM_HAS_VIZ_DEPS) {
- DEG_id_tag_update(id, OB_RECALC_DATA);
+ DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
}
- DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE);
}
}
@@ -462,7 +462,7 @@ static void rna_Bone_bbone_handle_update(Main *bmain, Scene *scene, PointerRNA *
if (pchan && pchan->bone == bone) {
BKE_pchan_rebuild_bbone_handles(obt->pose, pchan);
- DEG_id_tag_update(&obt->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&obt->id, ID_RECALC_COPY_ON_WRITE);
}
}
}
diff --git a/source/blender/makesrna/intern/rna_armature_api.c b/source/blender/makesrna/intern/rna_armature_api.c
index 222baf99afd..55caac973d8 100644
--- a/source/blender/makesrna/intern/rna_armature_api.c
+++ b/source/blender/makesrna/intern/rna_armature_api.c
@@ -42,6 +42,7 @@
#include <stddef.h>
+#include "BLI_math_vector.h"
#include "BKE_armature.h"
static void rna_EditBone_align_roll(EditBone *ebo, float no[3])
@@ -56,6 +57,24 @@ static float rna_Bone_do_envelope(Bone *bone, float *vec)
bone->rad_tail * scale, bone->dist * scale);
}
+static void rna_Bone_MatrixFromAxisRoll(float *axis, float roll, float *r_matrix)
+{
+ vec_roll_to_mat3(axis, roll, (float (*)[3])r_matrix);
+}
+
+static void rna_Bone_AxisRollFromMatrix(float *matrix, float *axis_override, float *r_axis, float *r_roll)
+{
+ float mat[3][3];
+
+ normalize_m3_m3(mat, (float (*)[3])matrix);
+
+ if (normalize_v3_v3(r_axis, axis_override) != 0.0f) {
+ mat3_vec_to_roll(mat, r_axis, r_roll);
+ }
+ else {
+ mat3_to_vec_roll(mat, r_axis, r_roll);
+ }
+}
#else
void RNA_api_armature_edit_bone(StructRNA *srna)
@@ -83,6 +102,40 @@ void RNA_api_bone(StructRNA *srna)
/* return value */
parm = RNA_def_float(func, "factor", 0, -FLT_MAX, FLT_MAX, "Factor", "Envelope factor", -FLT_MAX, FLT_MAX);
RNA_def_function_return(func, parm);
+
+ /* Conversions between Matrix and Axis + Roll representations. */
+ func = RNA_def_function(srna, "MatrixFromAxisRoll", "rna_Bone_MatrixFromAxisRoll");
+ RNA_def_function_ui_description(func, "Convert the axis + roll representation to a matrix");
+ RNA_def_function_flag(func, FUNC_NO_SELF);
+ parm = RNA_def_property(func, "axis", PROP_FLOAT, PROP_XYZ);
+ RNA_def_property_array(parm, 3);
+ RNA_def_property_ui_text(parm, "", "The main axis of the bone (tail - head)");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_property(func, "roll", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_ui_text(parm, "", "The roll of the bone");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_property(func, "result_matrix", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_3x3);
+ RNA_def_property_ui_text(parm, "", "The resulting orientation matrix");
+ RNA_def_function_output(func, parm);
+
+ func = RNA_def_function(srna, "AxisRollFromMatrix", "rna_Bone_AxisRollFromMatrix");
+ RNA_def_function_ui_description(func, "Convert a rotational matrix to the axis + roll representation");
+ RNA_def_function_flag(func, FUNC_NO_SELF);
+ parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_3x3);
+ RNA_def_property_ui_text(parm, "", "The orientation matrix of the bone");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_property(func, "axis", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_array(parm, 3);
+ RNA_def_property_ui_text(parm, "", "The optional override for the axis (finds closest approximation for the matrix)");
+ parm = RNA_def_property(func, "result_axis", PROP_FLOAT, PROP_XYZ);
+ RNA_def_property_array(parm, 3);
+ RNA_def_property_ui_text(parm, "", "The main axis of the bone");
+ RNA_def_function_output(func, parm);
+ parm = RNA_def_property(func, "result_roll", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_ui_text(parm, "", "The roll of the bone");
+ RNA_def_function_output(func, parm);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c
index 413cb10422a..3f472055087 100644
--- a/source/blender/makesrna/intern/rna_boid.c
+++ b/source/blender/makesrna/intern/rna_boid.c
@@ -97,12 +97,12 @@ static void rna_Boids_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN
if (ptr->type == &RNA_ParticleSystem) {
ParticleSystem *psys = (ParticleSystem *)ptr->data;
- psys->recalc = PSYS_RECALC_RESET;
+ psys->recalc = ID_RECALC_PSYS_RESET;
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
}
else
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA | PSYS_RECALC_RESET);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
}
@@ -111,12 +111,12 @@ static void rna_Boids_reset_deps(Main *bmain, Scene *UNUSED(scene), PointerRNA *
if (ptr->type == &RNA_ParticleSystem) {
ParticleSystem *psys = (ParticleSystem *)ptr->data;
- psys->recalc = PSYS_RECALC_RESET;
+ psys->recalc = ID_RECALC_PSYS_RESET;
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
}
else
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA | PSYS_RECALC_RESET);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
DEG_relations_tag_update(bmain);
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index c178f0b7389..53efbcb56fa 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -55,7 +55,7 @@ static void rna_cloth_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
{
Object *ob = (Object *)ptr->id.data;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}
@@ -73,7 +73,7 @@ static void rna_cloth_pinning_changed(Main *UNUSED(bmain), Scene *UNUSED(scene),
cloth_free_modifier(clmd);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}
@@ -825,9 +825,10 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Self Friction", "Friction with self contact");
RNA_def_property_update(prop, 0, "rna_cloth_update");
- prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "group");
RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Collision Group", "Limit colliders to this Group");
+ RNA_def_property_ui_text(prop, "Collision Collection", "Limit colliders to this Collection");
RNA_def_property_update(prop, 0, "rna_cloth_dependency_update");
prop = RNA_def_property(srna, "vertex_group_self_collisions", PROP_STRING, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c
index 03e00708738..1506d3e649a 100644
--- a/source/blender/makesrna/intern/rna_collection.c
+++ b/source/blender/makesrna/intern/rna_collection.c
@@ -90,7 +90,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_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, &object->id);
}
@@ -102,7 +102,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_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, &object->id);
}
@@ -174,7 +174,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_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, &child->id);
}
@@ -186,7 +186,7 @@ static void rna_Collection_children_unlink(Collection *collection, Main *bmain,
return;
}
- DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, &child->id);
}
@@ -241,7 +241,7 @@ 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_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene);
}
@@ -309,15 +309,16 @@ void RNA_def_collections(BlenderRNA *brna)
PropertyRNA *prop;
srna = RNA_def_struct(brna, "Collection", "ID");
+ /* XXX: CAN WE RENAME TO Collection? */
RNA_def_struct_sdna(srna, "Group"); /* it is actually Collection but for 2.8 the dna is patched! */
RNA_def_struct_ui_text(srna, "Collection", "Collection of Object data-blocks");
RNA_def_struct_ui_icon(srna, ICON_GROUP);
/* this is done on save/load in readfile.c, removed if no objects are in the collection and not in a scene */
RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
- prop = RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_TRANSLATION);
+ prop = RNA_def_property(srna, "instance_offset", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "dupli_ofs");
- RNA_def_property_ui_text(prop, "Dupli Offset", "Offset from the origin to use when instancing");
+ RNA_def_property_ui_text(prop, "Instance Offset", "Offset from the origin to use when instancing");
RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index fded3d32cc1..780e275a46d 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -330,7 +330,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
{
ParticleSettings *part = ptr->id.data;
- DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO);
+ DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, part);
}
default:
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index e9671754288..17159d15dde 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -640,7 +640,7 @@ static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, PointerRNA *
BKE_nurb_free(nu);
RNA_POINTER_INVALIDATE(nu_ptr);
- DEG_id_tag_update(&cu->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&cu->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GEOM | ND_DATA, NULL);
}
@@ -650,7 +650,7 @@ static void rna_Curve_spline_clear(Curve *cu)
BKE_nurbList_free(nurbs);
- DEG_id_tag_update(&cu->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&cu->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GEOM | ND_DATA, NULL);
}
@@ -974,6 +974,13 @@ static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna)
{0, NULL, 0, NULL, NULL}
};
+ static const EnumPropertyItem prop_overflow_items[] = {
+ {CU_OVERFLOW_NONE, "NONE", 0, "Overflow", "Let the text overflow outside the text boxes"},
+ {CU_OVERFLOW_SCALE, "SCALE", 0, "Scale to Fit", "Scale down the text to fit inside the text boxes"},
+ {CU_OVERFLOW_TRUNCATE, "TRUNCATE", 0, "Truncate", "Truncate the text that would go outside the text boxes"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
/* Enums */
prop = RNA_def_property(srna, "align_x", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "spacemode");
@@ -987,6 +994,14 @@ static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna)
RNA_def_property_ui_text(prop, "Text Vertical Align", "Text vertical align from the object center");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+ prop = RNA_def_property(srna, "overflow", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "overflow");
+ RNA_def_property_enum_items(prop, prop_overflow_items);
+ RNA_def_property_enum_default(prop, CU_OVERFLOW_NONE);
+ RNA_def_property_ui_text(prop, "Textbox Overflow",
+ "Handle the text behaviour when it doesn't fit in the text boxes");
+ RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+
/* number values */
prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "fsize");
diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c
index 523a4e4ad6e..c15740305a8 100644
--- a/source/blender/makesrna/intern/rna_dynamicpaint.c
+++ b/source/blender/makesrna/intern/rna_dynamicpaint.c
@@ -99,7 +99,7 @@ static char *rna_DynamicPaintSurface_path(PointerRNA *ptr)
static void rna_DynamicPaint_redoModifier(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
}
static void rna_DynamicPaintSurfaces_updateFrames(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -158,12 +158,17 @@ static void rna_DynamicPaintSurfaces_changeFormat(Main *bmain, Scene *scene, Poi
rna_DynamicPaintSurface_reset(bmain, scene, ptr);
}
-static void rna_DynamicPaint_reset_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_DynamicPaint_reset_dependency(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
{
- rna_DynamicPaintSurface_reset(bmain, scene, ptr);
DEG_relations_tag_update(bmain);
}
+static void rna_DynamicPaintSurface_reset_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ rna_DynamicPaintSurface_reset(bmain, scene, ptr);
+ rna_DynamicPaint_reset_dependency(bmain, scene, ptr);
+}
+
static PointerRNA rna_PaintSurface_active_get(PointerRNA *ptr)
{
DynamicPaintCanvasSettings *canvas = (DynamicPaintCanvasSettings *)ptr->data;
@@ -424,11 +429,12 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT, "rna_DynamicPaintSurface_uniqueName");
RNA_def_struct_name_property(srna, prop);
- prop = RNA_def_property(srna, "brush_group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "brush_collection", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Collection");
+ RNA_def_property_pointer_sdna(prop, NULL, "brush_group");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Brush Collection", "Only use brush objects from this collection");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_reset_dependency");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurface_reset_dependency");
/*
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index ef573079116..220b57bff39 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -150,7 +150,7 @@ static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA
/* TODO: this really needs an update guard... */
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_SCENE | ND_FRAME, scene);
}
@@ -497,7 +497,7 @@ static void rna_FCurve_update_eval(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
IdAdtTemplate *iat = (IdAdtTemplate *)ptr->id.data;
if (iat && iat->adt && iat->adt->action) {
/* action is separate datablock, needs separate tag */
- DEG_id_tag_update(&iat->adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&iat->adt->action->id, ID_RECALC_COPY_ON_WRITE);
}
}
@@ -611,18 +611,18 @@ static void rna_FModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin
FModifier *fcm = (FModifier *)ptr->data;
AnimData *adt = BKE_animdata_from_id(id);
- DEG_id_tag_update(id, (GS(id->name) == ID_OB) ? OB_RECALC_OB : OB_RECALC_DATA);
+ DEG_id_tag_update(id, (GS(id->name) == ID_OB) ? ID_RECALC_TRANSFORM : ID_RECALC_GEOMETRY);
/* tag datablock for time update so that animation is recalculated,
* as FModifiers affect how animation plays...
*/
- DEG_id_tag_update(id, DEG_TAG_TIME);
+ DEG_id_tag_update(id, ID_RECALC_ANIMATION);
if (adt != NULL) {
adt->recalc |= ADT_RECALC_ANIM;
if (adt->action != NULL) {
/* action is separate datablock, needs separate tag */
- DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE);
}
}
diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c
index 23d9155fccd..c6b9277ea8f 100644
--- a/source/blender/makesrna/intern/rna_fluidsim.c
+++ b/source/blender/makesrna/intern/rna_fluidsim.c
@@ -83,7 +83,7 @@ static void rna_fluid_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
{
Object *ob = ptr->id.data;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}
diff --git a/source/blender/makesrna/intern/rna_fracture.c b/source/blender/makesrna/intern/rna_fracture.c
index b6ccc922d1a..7046e63d762 100644
--- a/source/blender/makesrna/intern/rna_fracture.c
+++ b/source/blender/makesrna/intern/rna_fracture.c
@@ -565,9 +565,9 @@ static void rna_Modifier_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *p
{
BKE_rigidbody_cache_reset(scene);
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA | OB_RECALC_OB | OB_RECALC_TIME |
- DEG_TAG_COPY_ON_WRITE | DEG_TAG_BASE_FLAGS_UPDATE);
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE | DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM | ID_RECALC_ANIMATION |
+ ID_RECALC_COPY_ON_WRITE | ID_RECALC_BASE_FLAGS);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE | ID_RECALC_BASE_FLAGS);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ptr->id.data);
WM_main_add_notifier(NC_OBJECT | ND_POINTCACHE, NULL);
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 8c11909d022..a54d41c8f03 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -78,6 +78,15 @@ const EnumPropertyItem rna_enum_gplayer_move_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
+static const EnumPropertyItem rna_enum_layer_blend_modes_items[] = {
+ {eGplBlendMode_Normal, "NORMAL", 0, "Normal", "" },
+ {eGplBlendMode_Overlay, "OVERLAY", 0, "Overlay", "" },
+ {eGplBlendMode_Add, "ADD", 0, "Add", "" },
+ {eGplBlendMode_Subtract, "SUBTRACT", 0, "Subtract", "" },
+ {eGplBlendMode_Multiply, "MULTIPLY", 0, "Multiply", "" },
+ {eGplBlendMode_Divide, "DIVIDE", 0, "Divide", "" },
+ {0, NULL, 0, NULL, NULL }
+};
#endif
#ifdef RNA_RUNTIME
@@ -96,7 +105,7 @@ const EnumPropertyItem rna_enum_gplayer_move_type_items[] = {
static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
}
@@ -135,7 +144,7 @@ static void rna_GPencil_autolock(Main *bmain, Scene *scene, PointerRNA *ptr)
static void rna_GPencil_editmode_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
bGPdata *gpd = (bGPdata *)ptr->id.data;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
/* Notify all places where GPencil data lives that the editing state is different */
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
@@ -373,7 +382,7 @@ static void rna_GPencil_active_layer_index_set(PointerRNA *ptr, int value)
BKE_gpencil_layer_setactive(gpd, gpl);
/* Now do standard updates... */
- DEG_id_tag_update(&gpd->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
}
@@ -689,7 +698,7 @@ static void rna_GPencil_layer_move(bGPdata *gpd, ReportList *reports, PointerRNA
const int direction = type * -1;
if (BLI_listbase_link_move(&gpd->layers, gpl, direction)) {
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
@@ -1067,6 +1076,8 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
PropertyRNA *prop;
FunctionRNA *func;
+ static const float default_onion_color_b[] = { 0.302f, 0.851f, 0.302f };
+ static const float default_onion_color_a[] = { 0.250f, 0.1f, 1.0f };
srna = RNA_def_struct(brna, "GPencilLayer", NULL);
RNA_def_struct_sdna(srna, "bGPDlayer");
@@ -1148,6 +1159,42 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Onion Skinning", "Display onion skins before and after the current frame");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ prop = RNA_def_property(srna, "use_annotation_onion_skinning", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_LAYER_ONIONSKIN);
+ RNA_def_property_ui_text(prop, "Onion Skinning",
+ "Display annotation onion skins before and after the current frame");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+ prop = RNA_def_property(srna, "annotation_onion_before_range", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "gstep");
+ RNA_def_property_range(prop, -1, 120);
+ RNA_def_property_ui_text(prop, "Frames Before",
+ "Maximum number of frames to show before current frame");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+ prop = RNA_def_property(srna, "annotation_onion_after_range", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "gstep_next");
+ RNA_def_property_range(prop, -1, 120);
+ RNA_def_property_ui_text(prop, "Frames After",
+ "Maximum number of frames to show after current frame");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+ prop = RNA_def_property(srna, "annotation_onion_before_color", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "gcolor_prev");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_float_array_default(prop, default_onion_color_b);
+ RNA_def_property_ui_text(prop, "Before Color", "Base color for ghosts before the active frame");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+ prop = RNA_def_property(srna, "annotation_onion_after_color", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "gcolor_next");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_float_array_default(prop, default_onion_color_a);
+ RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
/* pass index for compositing and modifiers */
prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "pass_index");
@@ -1159,6 +1206,13 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "ViewLayer",
"Only include Layer in this View Layer render output (leave blank to include always)");
+ /* blend mode */
+ prop = RNA_def_property(srna, "blend_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "blend_mode");
+ RNA_def_property_enum_items(prop, rna_enum_layer_blend_modes_items);
+ RNA_def_property_ui_text(prop, "Blend Mode", "Blend mode");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
/* Flags */
prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_HIDE);
@@ -1184,6 +1238,12 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Lock Material", "Disable Material editing");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+ prop = RNA_def_property(srna, "clamp_layer", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_USE_MASK);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Clamp Layer",
+ "Clamp any pixel outside underlying layers drawing");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* exposed as layers.active */
#if 0
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index beba47f33b4..aa1517a96d8 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -205,7 +205,7 @@ static char *rna_GpencilModifier_path(PointerRNA *ptr)
static void rna_GpencilModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ptr->id.data);
}
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 9d3699e220e..3da9625eda2 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -96,6 +96,7 @@ static void rna_Image_source_set(PointerRNA *ptr, int value)
BLI_assert(BKE_id_is_in_global_main(&ima->id));
BKE_image_signal(G_MAIN, ima, NULL, IMA_SIGNAL_SRC_CHANGE);
DEG_id_tag_update(&ima->id, 0);
+ DEG_id_tag_update(&ima->id, ID_RECALC_EDITORS);
}
}
@@ -105,6 +106,7 @@ static void rna_Image_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRN
BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD);
WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id);
DEG_id_tag_update(&ima->id, 0);
+ DEG_id_tag_update(&ima->id, ID_RECALC_EDITORS);
}
static void rna_Image_generated_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
@@ -118,6 +120,7 @@ static void rna_Image_colormanage_update(Main *bmain, Scene *UNUSED(scene), Poin
Image *ima = ptr->id.data;
BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE);
DEG_id_tag_update(&ima->id, 0);
+ DEG_id_tag_update(&ima->id, ID_RECALC_EDITORS);
WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id);
WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id);
}
@@ -148,6 +151,7 @@ static void rna_ImageUser_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *
if (ptr->id.data) {
/* Update material or texture for render preview. */
DEG_id_tag_update(ptr->id.data, 0);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_EDITORS);
}
}
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index d6b7cabc335..e554dd650a9 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -132,7 +132,7 @@ static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *r
if (image->source == IMA_SRC_GENERATED)
image->source = IMA_SRC_FILE;
- IMB_colormanagment_colorspace_from_ibuf_ftype(&image->colorspace_settings, ibuf);
+ IMB_colormanagement_colorspace_from_ibuf_ftype(&image->colorspace_settings, ibuf);
ibuf->userflags &= ~IB_BITMAPDIRTY;
}
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index ed1e0d2690e..5181912f4eb 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -35,6 +35,7 @@
#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
+#include "BLI_math.h"
#include "BLT_translation.h"
@@ -42,6 +43,8 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
+#include "MEM_guardedalloc.h"
+
#include "rna_internal.h"
#ifdef RNA_RUNTIME
@@ -336,6 +339,19 @@ static void rna_ShapeKeyCurvePoint_tilt_set(PointerRNA *ptr, float value)
vec[3] = value;
}
+static float rna_ShapeKeyCurvePoint_radius_get(PointerRNA *ptr)
+{
+ float *vec = (float *)ptr->data;
+ return vec[4];
+}
+
+static void rna_ShapeKeyCurvePoint_radius_set(PointerRNA *ptr, float value)
+{
+ float *vec = (float *)ptr->data;
+ CLAMP_MIN(value, 0.0f);
+ vec[4] = value;
+}
+
static void rna_ShapeKeyBezierPoint_co_get(PointerRNA *ptr, float *values)
{
float *vec = (float *)ptr->data;
@@ -390,35 +406,166 @@ static void rna_ShapeKeyBezierPoint_handle_2_co_set(PointerRNA *ptr, const float
vec[6 + 2] = values[2];
}
-#if 0
static float rna_ShapeKeyBezierPoint_tilt_get(PointerRNA *ptr)
{
float *vec = (float *)ptr->data;
- return vec[10];
+ return vec[9];
}
static void rna_ShapeKeyBezierPoint_tilt_set(PointerRNA *ptr, float value)
{
float *vec = (float *)ptr->data;
+ vec[9] = value;
+}
+
+static float rna_ShapeKeyBezierPoint_radius_get(PointerRNA *ptr)
+{
+ float *vec = (float *)ptr->data;
+ return vec[10];
+}
+
+static void rna_ShapeKeyBezierPoint_radius_set(PointerRNA *ptr, float value)
+{
+ float *vec = (float *)ptr->data;
+ CLAMP_MIN(value, 0.0f);
vec[10] = value;
}
-#endif
+
+/* Indexing and iteration of Curve points through sub-curves. */
+typedef struct NurbInfo {
+ Nurb *nu;
+ int nurb_size, nurb_elem_step;
+
+ /* Current index in the Nurb */
+ int nurb_index;
+
+ /* Total index as item and element. */
+ int item_index, elem_index;
+} NurbInfo;
+
+StructRNA *rna_ShapeKey_curve_point_type(Nurb *nu)
+{
+ if (nu->bezt) {
+ return &RNA_ShapeKeyBezierPoint;
+ }
+ else {
+ return &RNA_ShapeKeyCurvePoint;
+ }
+}
+
+static void rna_ShapeKey_NurbInfo_init(NurbInfo *r_info, Nurb *nu)
+{
+ r_info->nu = nu;
+
+ if (nu->bezt) {
+ r_info->nurb_size = nu->pntsu;
+ r_info->nurb_elem_step = KEYELEM_ELEM_LEN_BEZTRIPLE;
+ }
+ else {
+ r_info->nurb_size = nu->pntsu * nu->pntsv;
+ r_info->nurb_elem_step = KEYELEM_ELEM_LEN_BPOINT;
+ }
+}
+
+static void rna_ShapeKey_NurbInfo_step(NurbInfo *r_info, Nurb *nu, int *p_raw_index, bool input_elem)
+{
+ rna_ShapeKey_NurbInfo_init(r_info, nu);
+
+ if (input_elem) {
+ r_info->nurb_index = MIN2(r_info->nurb_size, *p_raw_index / r_info->nurb_elem_step);
+ *p_raw_index -= r_info->nurb_size * r_info->nurb_elem_step;
+ }
+ else {
+ r_info->nurb_index = MIN2(r_info->nurb_size, *p_raw_index);
+ *p_raw_index -= r_info->nurb_size;
+ }
+
+ r_info->item_index += r_info->nurb_index;
+ r_info->elem_index += r_info->nurb_index * r_info->nurb_elem_step;
+}
+
+static void rna_ShapeKey_NurbInfo_find_index(Key *key, int raw_index, bool input_elem, NurbInfo *r_info)
+{
+ Curve *cu = (Curve *)key->from;
+
+ memset(r_info, 0, sizeof(*r_info));
+
+ for (Nurb *nu = cu->nurb.first; nu && raw_index >= 0; nu = nu->next) {
+ rna_ShapeKey_NurbInfo_step(r_info, nu, &raw_index, input_elem);
+ }
+}
+
+static int rna_ShapeKey_curve_find_index(Key *key, int elem_index)
+{
+ NurbInfo info;
+ rna_ShapeKey_NurbInfo_find_index(key, elem_index, true, &info);
+ return info.item_index;
+}
+
+typedef struct ShapeKeyCurvePoint {
+ StructRNA *type;
+ void *data;
+} ShapeKeyCurvePoint;
+
+/* Build a mapping array for Curve objects with mixed sub-curve types. */
+static void rna_ShapeKey_data_begin_mixed(CollectionPropertyIterator *iter, Key *key, KeyBlock *kb, Curve *cu)
+{
+ int point_count = rna_ShapeKey_curve_find_index(key, kb->totelem);
+
+ ShapeKeyCurvePoint *points = MEM_malloc_arrayN(sizeof(ShapeKeyCurvePoint), point_count, __func__);
+
+ char *databuf = kb->data;
+ int items_left = point_count;
+ NurbInfo info = { NULL };
+
+ for (Nurb *nu = cu->nurb.first; nu && items_left > 0; nu = nu->next) {
+ ShapeKeyCurvePoint *nurb_points = points + info.item_index;
+ char *nurb_data = databuf + info.elem_index * key->elemsize;
+
+ rna_ShapeKey_NurbInfo_step(&info, nu, &items_left, false);
+
+ StructRNA *type = rna_ShapeKey_curve_point_type(nu);
+
+ for (int i = 0; i < info.nurb_index; i++) {
+ nurb_points[i].type = type;
+ nurb_points[i].data = nurb_data + i * info.nurb_elem_step * key->elemsize;
+ }
+ }
+
+ rna_iterator_array_begin(iter, points, sizeof(*points), point_count, true, NULL);
+}
static void rna_ShapeKey_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Key *key = rna_ShapeKey_find_key(ptr->id.data);
KeyBlock *kb = (KeyBlock *)ptr->data;
- Curve *cu;
- Nurb *nu;
int tot = kb->totelem, size = key->elemsize;
- if (GS(key->from->name) == ID_CU) {
- cu = (Curve *)key->from;
- nu = cu->nurb.first;
+ if (GS(key->from->name) == ID_CU && tot > 0) {
+ Curve *cu = (Curve *)key->from;
+ StructRNA *type = NULL;
+ NurbInfo info = { 0 };
+
+ /* Check if all sub-curves have the same type. */
+ for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
+ if (type == NULL) {
+ type = rna_ShapeKey_curve_point_type(nu);
+ rna_ShapeKey_NurbInfo_init(&info, nu);
+ }
+ else if (type != rna_ShapeKey_curve_point_type(nu)) {
+ type = NULL;
+ break;
+ }
+ }
- if (nu->bezt) {
- tot /= 3;
- size *= 3;
+ /* If types are mixed, build a mapping array. */
+ if (type == NULL) {
+ rna_ShapeKey_data_begin_mixed(iter, key, kb, cu);
+ return;
+ }
+ else {
+ tot /= info.nurb_elem_step;
+ size *= info.nurb_elem_step;
}
}
@@ -429,16 +576,10 @@ static int rna_ShapeKey_data_length(PointerRNA *ptr)
{
Key *key = rna_ShapeKey_find_key(ptr->id.data);
KeyBlock *kb = (KeyBlock *)ptr->data;
- Curve *cu;
- Nurb *nu;
int tot = kb->totelem;
if (GS(key->from->name) == ID_CU) {
- cu = (Curve *)key->from;
- nu = cu->nurb.first;
-
- if (nu->bezt)
- tot /= 3;
+ tot = rna_ShapeKey_curve_find_index(key, tot);
}
return tot;
@@ -447,23 +588,57 @@ static int rna_ShapeKey_data_length(PointerRNA *ptr)
static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter)
{
Key *key = rna_ShapeKey_find_key(iter->parent.id.data);
- StructRNA *type;
- Curve *cu;
- Nurb *nu;
+ void *ptr = rna_iterator_array_get(iter);
+ StructRNA *type = &RNA_ShapeKeyPoint;
+
+ /* If data_begin allocated a mapping array, access it. */
+ if (iter->internal.array.free_ptr) {
+ ShapeKeyCurvePoint *point = ptr;
+
+ return rna_pointer_inherit_refine(&iter->parent, point->type, point->data);
+ }
if (GS(key->from->name) == ID_CU) {
- cu = (Curve *)key->from;
- nu = cu->nurb.first;
+ Curve *cu = (Curve *)key->from;
- if (nu->bezt)
- type = &RNA_ShapeKeyBezierPoint;
- else
- type = &RNA_ShapeKeyCurvePoint;
+ type = rna_ShapeKey_curve_point_type(cu->nurb.first);
+ }
+
+ return rna_pointer_inherit_refine(&iter->parent, type, ptr);
+}
+
+int rna_ShapeKey_data_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
+{
+ Key *key = rna_ShapeKey_find_key(ptr->id.data);
+ KeyBlock *kb = (KeyBlock *)ptr->data;
+ int elemsize = key->elemsize;
+ char *databuf = kb->data;
+
+ memset(r_ptr, 0, sizeof(*r_ptr));
+
+ if (index < 0) {
+ return false;
+ }
+
+ if (GS(key->from->name) == ID_CU) {
+ NurbInfo info;
+ rna_ShapeKey_NurbInfo_find_index(key, index, false, &info);
+
+ if (info.nu && info.nurb_index < info.nurb_size) {
+ StructRNA *type = rna_ShapeKey_curve_point_type(info.nu);
+
+ *r_ptr = rna_pointer_inherit_refine(ptr, type, databuf + elemsize * info.elem_index);
+ return true;
+ }
+ }
+ else {
+ if (index < kb->totelem) {
+ *r_ptr = rna_pointer_inherit_refine(ptr, &RNA_ShapeKeyPoint, databuf + elemsize * index);
+ return true;
+ }
}
- else
- type = &RNA_ShapeKeyPoint;
- return rna_pointer_inherit_refine(&iter->parent, type, rna_iterator_array_get(iter));
+ return false;
}
static char *rna_ShapeKey_path(PointerRNA *ptr)
@@ -487,7 +662,7 @@ static void rna_Key_update_data(Main *bmain, Scene *UNUSED(scene), PointerRNA *p
for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (BKE_key_from_object(ob) == key) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}
}
@@ -547,19 +722,6 @@ static int rna_ShapeKeyPoint_get_index(Key *key, KeyBlock *kb, float *point)
return (int)(pt - start) / key->elemsize;
}
-static int rna_ShapeKeyBezierPoint_get_index(KeyBlock *kb, float *point)
-{
- float *start = (float *)kb->data;
-
- /* Unlike with rna_ShapeKeyPoint_get_index(), we cannot use key->elemsize here
- * since the default value for curves (16) is actually designed for BPoints
- * (i.e. NURBS Surfaces). The magic number "12" here was found by empirical
- * testing on a 64-bit system, and is similar to what's used for meshes and
- * lattices. For more details, see T38013
- */
- return (int)(point - start) / 12;
-}
-
static char *rna_ShapeKeyPoint_path(PointerRNA *ptr)
{
ID *id = (ID *)ptr->id.data;
@@ -574,10 +736,11 @@ static char *rna_ShapeKeyPoint_path(PointerRNA *ptr)
char name_esc_kb[sizeof(kb->name) * 2];
int index;
- if (ptr->type == &RNA_ShapeKeyBezierPoint)
- index = rna_ShapeKeyBezierPoint_get_index(kb, point);
- else
- index = rna_ShapeKeyPoint_get_index(key, kb, point);
+ index = rna_ShapeKeyPoint_get_index(key, kb, point);
+
+ if (ELEM(ptr->type, &RNA_ShapeKeyBezierPoint, &RNA_ShapeKeyCurvePoint)) {
+ index = rna_ShapeKey_curve_find_index(key, index);
+ }
BLI_strescape(name_esc_kb, kb->name, sizeof(name_esc_kb));
@@ -600,6 +763,8 @@ const EnumPropertyItem rna_enum_keyblock_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
+static const float tilt_limit = DEG2RADF(21600.0f);
+
static void rna_def_keydata(BlenderRNA *brna)
{
StructRNA *srna;
@@ -626,9 +791,17 @@ static void rna_def_keydata(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Location", "");
RNA_def_property_update(prop, 0, "rna_Key_update_data");
- prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_funcs(prop, "rna_ShapeKeyCurvePoint_tilt_get", "rna_ShapeKeyCurvePoint_tilt_set", NULL);
- RNA_def_property_ui_text(prop, "Tilt", "");
+ RNA_def_property_range(prop, -tilt_limit, tilt_limit);
+ RNA_def_property_ui_range(prop, -tilt_limit, tilt_limit, 10, 3);
+ RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View");
+ RNA_def_property_update(prop, 0, "rna_Key_update_data");
+
+ prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_funcs(prop, "rna_ShapeKeyCurvePoint_radius_get", "rna_ShapeKeyCurvePoint_radius_set", NULL);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_ui_text(prop, "Radius", "Radius for beveling");
RNA_def_property_update(prop, 0, "rna_Key_update_data");
srna = RNA_def_struct(brna, "ShapeKeyBezierPoint", NULL);
@@ -656,13 +829,18 @@ static void rna_def_keydata(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Handle 2 Location", "");
RNA_def_property_update(prop, 0, "rna_Key_update_data");
- /* appears to be unused currently */
-#if 0
- prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_tilt_get", "rna_ShapeKeyBezierPoint_tilt_set", NULL);
- RNA_def_property_ui_text(prop, "Tilt", "");
+ RNA_def_property_range(prop, -tilt_limit, tilt_limit);
+ RNA_def_property_ui_range(prop, -tilt_limit, tilt_limit, 10, 3);
+ RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View");
+ RNA_def_property_update(prop, 0, "rna_Key_update_data");
+
+ prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_radius_get", "rna_ShapeKeyBezierPoint_radius_set", NULL);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_ui_text(prop, "Radius", "Radius for beveling");
RNA_def_property_update(prop, 0, "rna_Key_update_data");
-#endif
}
static void rna_def_keyblock(BlenderRNA *brna)
@@ -743,7 +921,7 @@ static void rna_def_keyblock(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "UnknownType");
RNA_def_property_ui_text(prop, "Data", "");
RNA_def_property_collection_funcs(prop, "rna_ShapeKey_data_begin", NULL, NULL, "rna_ShapeKey_data_get",
- "rna_ShapeKey_data_length", NULL, NULL, NULL);
+ "rna_ShapeKey_data_length", "rna_ShapeKey_data_lookup_int", NULL, NULL);
/* XXX multi-dim dynamic arrays are very badly supported by (py)rna currently, those are defined for the day
* it works better, for now user will get a 1D tuple...
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index 46d1f5bef7d..28b0b686bfc 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -212,7 +212,7 @@ static void rna_LayerCollection_use_update(Main *bmain, Scene *UNUSED(scene), Po
BKE_layer_collection_sync(scene, view_layer);
- DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, NULL);
}
diff --git a/source/blender/makesrna/intern/rna_lightprobe.c b/source/blender/makesrna/intern/rna_lightprobe.c
index 85df1c5ba72..96a8b53cf29 100644
--- a/source/blender/makesrna/intern/rna_lightprobe.c
+++ b/source/blender/makesrna/intern/rna_lightprobe.c
@@ -49,7 +49,7 @@
static void rna_LightProbe_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
}
#else
diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c
index 2cd427fbbd8..31d195ebdbd 100644
--- a/source/blender/makesrna/intern/rna_mask.c
+++ b/source/blender/makesrna/intern/rna_mask.c
@@ -449,7 +449,7 @@ static void rna_MaskLayer_spline_remove(ID *id, MaskLayer *mask_layer, ReportLis
RNA_POINTER_INVALIDATE(spline_ptr);
- DEG_id_tag_update(&mask->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&mask->id, ID_RECALC_GEOMETRY);
}
static void rna_Mask_start_frame_set(PointerRNA *ptr, int value)
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 2ad379f60eb..fb7c0be7c77 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -97,7 +97,7 @@ static void rna_Material_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point
{
Material *ma = ptr->id.data;
- DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_MATERIAL | ND_SHADING, ma);
}
@@ -131,7 +131,7 @@ static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
{
Material *ma = ptr->id.data;
- DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma);
}
@@ -202,7 +202,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_id_tag_update(&ma->id, ID_RECALC_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 8797816798c..11702a99ced 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -313,6 +313,7 @@ const EnumPropertyItem rna_enum_axis_flag_xyz_items[] = {
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#ifdef WITH_ALEMBIC
# include "ABC_alembic.h"
@@ -479,7 +480,7 @@ static char *rna_Modifier_path(PointerRNA *ptr)
static void rna_Modifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ptr->id.data);
}
@@ -783,7 +784,7 @@ static void rna_OceanModifier_ocean_chop_set(PointerRNA *ptr, float value)
static bool rna_LaplacianDeformModifier_is_bind_get(PointerRNA *ptr)
{
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)ptr->data;
- return ((lmd->flag & MOD_LAPLACIANDEFORM_BIND) && (lmd->cache_system != NULL));
+ return ((lmd->flag & MOD_LAPLACIANDEFORM_BIND) && (lmd->vertexco != NULL));
}
/* NOTE: Curve and array modifiers requires curve path to be evaluated,
@@ -802,7 +803,7 @@ static void rna_CurveModifier_dependency_update(Main *bmain, Scene *scene, Point
if (cmd->object != NULL) {
Curve *curve = cmd->object->data;
if ((curve->flag & CU_PATH) == 0) {
- DEG_id_tag_update(&curve->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&curve->id, ID_RECALC_GEOMETRY);
}
}
}
@@ -815,7 +816,7 @@ static void rna_ArrayModifier_dependency_update(Main *bmain, Scene *scene, Point
if (amd->curve_ob != NULL) {
Curve *curve = amd->curve_ob->data;
if ((curve->flag & CU_PATH) == 0) {
- DEG_id_tag_update(&curve->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&curve->id, ID_RECALC_GEOMETRY);
}
}
}
@@ -905,7 +906,6 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf(
}
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);
@@ -943,7 +943,10 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf(
Mesh *me_eval;
int num_data, i;
- me_eval = mesh_get_eval_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPUV);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
+
+ me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, CD_MASK_BAREMESH | CD_MLOOPUV);
num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPUV);
RNA_enum_item_add_separator(&item, &totitem);
@@ -962,7 +965,10 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf(
Mesh *me_eval;
int num_data, i;
- me_eval = mesh_get_eval_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPCOL);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
+
+ me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, CD_MASK_BAREMESH | CD_MLOOPCOL);
num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPCOL);
RNA_enum_item_add_separator(&item, &totitem);
@@ -1231,14 +1237,12 @@ static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const c
RNA_def_property_ui_text(prop, "UV Smooth", "Controls how smoothing is applied to UVs");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-#ifdef WITH_OPENSUBDIV_MODIFIER
prop = RNA_def_property(srna, "quality", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "quality");
RNA_def_property_range(prop, 1, 10);
RNA_def_property_ui_range(prop, 1, 6, 1, -1);
RNA_def_property_ui_text(prop, "Quality", "Accuracy of vertex positions, lower value is faster but less precise");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
-#endif
prop = RNA_def_property(srna, "subdivision_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, type);
@@ -1297,7 +1301,7 @@ static void rna_def_modifier_generic_map_info(StructRNA *srna)
prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Texture", "");
RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "texmapping");
diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c
index 121a21293f0..7b5b2f13eef 100644
--- a/source/blender/makesrna/intern/rna_nla.c
+++ b/source/blender/makesrna/intern/rna_nla.c
@@ -424,7 +424,7 @@ static NlaStrip *rna_NlaStrip_new(ID *id, NlaTrack *track, Main *bmain, bContext
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, NULL);
DEG_relations_tag_update(bmain);
- DEG_id_tag_update_ex(bmain, id, DEG_TAG_TIME | DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, id, ID_RECALC_ANIMATION | ID_RECALC_COPY_ON_WRITE);
return strip;
}
@@ -443,7 +443,7 @@ static void rna_NlaStrip_remove(ID *id, NlaTrack *track, Main *bmain, bContext *
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
DEG_relations_tag_update(bmain);
- DEG_id_tag_update_ex(bmain, id, DEG_TAG_TIME | DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, id, ID_RECALC_ANIMATION | ID_RECALC_COPY_ON_WRITE);
}
/* Set the 'solo' setting for the given NLA-track, making sure that it is the only one
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 8169e88cac0..ca532b16bc3 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -292,26 +292,26 @@ const EnumPropertyItem *rna_node_tree_type_itemf(void *data, bool (*poll)(void *
int rna_node_type_to_enum(bNodeType *typeinfo)
{
int i = 0, result = -1;
- NODE_TYPES_BEGIN(ntype)
+ NODE_TYPES_BEGIN(ntype) {
if (ntype == typeinfo) {
result = i;
break;
}
++i;
- NODE_TYPES_END
+ } NODE_TYPES_END;
return result;
}
int rna_node_idname_to_enum(const char *idname)
{
int i = 0, result = -1;
- NODE_TYPES_BEGIN(ntype)
+ NODE_TYPES_BEGIN(ntype) {
if (STREQ(ntype->idname, idname)) {
result = i;
break;
}
++i;
- NODE_TYPES_END
+ } NODE_TYPES_END;
return result;
}
@@ -319,13 +319,13 @@ bNodeType *rna_node_type_from_enum(int value)
{
int i = 0;
bNodeType *result = NULL;
- NODE_TYPES_BEGIN(ntype)
+ NODE_TYPES_BEGIN(ntype) {
if (i == value) {
result = ntype;
break;
}
++i;
- NODE_TYPES_END
+ } NODE_TYPES_END;
return result;
}
@@ -335,7 +335,7 @@ const EnumPropertyItem *rna_node_type_itemf(void *data, bool (*poll)(void *data,
EnumPropertyItem tmp = {0};
int totitem = 0, i = 0;
- NODE_TYPES_BEGIN(ntype)
+ NODE_TYPES_BEGIN(ntype) {
if (poll && !poll(data, ntype)) {
++i;
continue;
@@ -350,7 +350,7 @@ const EnumPropertyItem *rna_node_type_itemf(void *data, bool (*poll)(void *data,
RNA_enum_item_add(&item, &totitem, &tmp);
++i;
- NODE_TYPES_END
+ } NODE_TYPES_END;
if (totitem == 0) {
*r_free = false;
@@ -366,26 +366,26 @@ const EnumPropertyItem *rna_node_type_itemf(void *data, bool (*poll)(void *data,
int rna_node_socket_type_to_enum(bNodeSocketType *typeinfo)
{
int i = 0, result = -1;
- NODE_SOCKET_TYPES_BEGIN(stype)
+ NODE_SOCKET_TYPES_BEGIN(stype) {
if (stype == typeinfo) {
result = i;
break;
}
++i;
- NODE_SOCKET_TYPES_END
+ } NODE_SOCKET_TYPES_END;
return result;
}
int rna_node_socket_idname_to_enum(const char *idname)
{
int i = 0, result = -1;
- NODE_SOCKET_TYPES_BEGIN(stype)
+ NODE_SOCKET_TYPES_BEGIN(stype) {
if (STREQ(stype->idname, idname)) {
result = i;
break;
}
++i;
- NODE_SOCKET_TYPES_END
+ } NODE_SOCKET_TYPES_END;
return result;
}
@@ -393,13 +393,13 @@ bNodeSocketType *rna_node_socket_type_from_enum(int value)
{
int i = 0;
bNodeSocketType *result = NULL;
- NODE_SOCKET_TYPES_BEGIN(stype)
+ NODE_SOCKET_TYPES_BEGIN(stype) {
if (i == value) {
result = stype;
break;
}
++i;
- NODE_SOCKET_TYPES_END
+ } NODE_SOCKET_TYPES_END;
return result;
}
@@ -411,7 +411,7 @@ const EnumPropertyItem *rna_node_socket_type_itemf(
int totitem = 0, i = 0;
StructRNA *srna;
- NODE_SOCKET_TYPES_BEGIN(stype)
+ NODE_SOCKET_TYPES_BEGIN(stype) {
if (poll && !poll(data, stype)) {
++i;
continue;
@@ -427,7 +427,8 @@ const EnumPropertyItem *rna_node_socket_type_itemf(
RNA_enum_item_add(&item, &totitem, &tmp);
++i;
- NODE_SOCKET_TYPES_END
+ }
+ NODE_SOCKET_TYPES_END;
if (totitem == 0) {
*r_free = false;
@@ -4057,9 +4058,9 @@ static void def_sh_tex_coord(StructRNA *srna)
RNA_def_property_ui_text(prop, "Object", "Use coordinates from this object (for object texture coordinates output)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
- prop = RNA_def_property(srna, "from_dupli", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "from_instancer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1);
- RNA_def_property_ui_text(prop, "From Dupli", "Use the parent of the dupli object if possible");
+ RNA_def_property_ui_text(prop, "From Instancer", "Use the parent of the dupli object if possible");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
@@ -4355,9 +4356,9 @@ static void def_sh_uvmap(StructRNA *srna)
{
PropertyRNA *prop;
- prop = RNA_def_property(srna, "from_dupli", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "from_instancer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1);
- RNA_def_property_ui_text(prop, "From Dupli", "Use the parent of the dupli object if possible");
+ RNA_def_property_ui_text(prop, "From Instancer", "Use the parent of the dupli object if possible");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
RNA_def_struct_sdna_from(srna, "NodeShaderUVMap", "storage");
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 96def17bc3e..19d758a90e7 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -134,27 +134,27 @@ static const EnumPropertyItem parent_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
-#define DUPLI_ITEMS_SHARED \
+#define INSTANCE_ITEMS_SHARED \
{0, "NONE", 0, "None", ""}, \
- {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"}, \
- {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"}, \
- {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"}
+ {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make instance of object for every frame"}, \
+ {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Instantiate child objects on all vertices"}, \
+ {OB_DUPLIFACES, "FACES", 0, "Faces", "Instantiate child objects on all faces"}
-#define DUPLI_ITEM_COLLECTION \
+#define INSTANCE_ITEM_COLLECTION \
{OB_DUPLICOLLECTION, "COLLECTION", 0, "Collection", "Enable collection instancing"}
-static const EnumPropertyItem dupli_items[] = {
- DUPLI_ITEMS_SHARED,
- DUPLI_ITEM_COLLECTION,
+static const EnumPropertyItem instance_items[] = {
+ INSTANCE_ITEMS_SHARED,
+ INSTANCE_ITEM_COLLECTION,
{0, NULL, 0, NULL, NULL}
};
#ifdef RNA_RUNTIME
-static EnumPropertyItem dupli_items_nogroup[] = {
- DUPLI_ITEMS_SHARED,
+static EnumPropertyItem instance_items_nogroup[] = {
+ INSTANCE_ITEMS_SHARED,
{0, NULL, 0, NULL, NULL}
};
#endif
-#undef DUPLI_ITEMS_SHARED
-#undef DUPLI_ITEM_COLLECTION
+#undef INSTANCE_ITEMS_SHARED
+#undef INSTANCE_ITEM_COLLECTION
const EnumPropertyItem rna_enum_metaelem_type_items[] = {
{MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
@@ -243,12 +243,12 @@ const EnumPropertyItem rna_enum_object_axis_items[] = {
static void rna_Object_internal_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- DEG_id_tag_update(ptr->id.data, OB_RECALC_OB);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_TRANSFORM);
}
static void rna_Object_internal_update_draw(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- DEG_id_tag_update(ptr->id.data, OB_RECALC_OB);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_TRANSFORM);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
}
@@ -263,7 +263,7 @@ static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA
{
Object *ob = ptr->id.data;
BKE_main_collection_sync(bmain);
- DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id);
}
@@ -322,7 +322,7 @@ static void rna_Object_matrix_basis_set(PointerRNA *ptr, const float values[16])
void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
}
@@ -361,7 +361,7 @@ static void rna_Object_active_shape_update(bContext *C, PointerRNA *ptr)
static void rna_Object_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
- DEG_id_tag_update(ptr->id.data, OB_RECALC_OB);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_TRANSFORM);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_PARENT, ptr->id.data);
}
@@ -519,7 +519,7 @@ static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
ED_object_parent(ob, ob->parent, ob->partype, value);
}
-static const EnumPropertyItem *rna_Object_dupli_type_itemf(
+static const EnumPropertyItem *rna_Object_instance_type_itemf(
bContext *UNUSED(C), PointerRNA *ptr,
PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
{
@@ -527,16 +527,16 @@ static const EnumPropertyItem *rna_Object_dupli_type_itemf(
const EnumPropertyItem *item;
if (ob->type == OB_EMPTY) {
- item = dupli_items;
+ item = instance_items;
}
else {
- item = dupli_items_nogroup;
+ item = instance_items_nogroup;
}
return item;
}
-static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Object_dup_collection_set(PointerRNA *ptr, PointerRNA value)
{
Object *ob = (Object *)ptr->data;
Collection *grp = (Collection *)value.data;
@@ -557,7 +557,7 @@ static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value)
}
else {
BKE_report(NULL, RPT_ERROR,
- "Cannot set dupli-group as object belongs in group being instanced, thus causing a cycle");
+ "Cannot set instance-collection as object belongs in group being instanced, thus causing a cycle");
}
}
@@ -1161,7 +1161,7 @@ static PointerRNA rna_Object_field_get(PointerRNA *ptr)
/* weak */
if (!ob->pd)
- ob->pd = object_add_collision_fields(0);
+ ob->pd = BKE_partdeflect_new(0);
return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, ob->pd);
}
@@ -1175,7 +1175,7 @@ static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
/* weak */
if (!ob->pd)
- ob->pd = object_add_collision_fields(0);
+ ob->pd = BKE_partdeflect_new(0);
return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd);
}
@@ -2203,7 +2203,7 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "trackflag");
RNA_def_property_enum_items(prop, rna_enum_object_axis_items);
RNA_def_property_ui_text(prop, "Track Axis",
- "Axis that points in 'forward' direction (applies to DupliFrame when "
+ "Axis that points in 'forward' direction (applies to InstanceFrame when "
"parent 'Follow' is enabled)");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
@@ -2211,7 +2211,7 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "upflag");
RNA_def_property_enum_items(prop, up_items);
RNA_def_property_ui_text(prop, "Up Axis",
- "Axis that points in the upward direction (applies to DupliFrame when "
+ "Axis that points in the upward direction (applies to InstanceFrame when "
"parent 'Follow' is enabled)");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
@@ -2219,7 +2219,8 @@ static void rna_def_object(BlenderRNA *brna)
prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Proxy", "Library object this proxy object controls");
- prop = RNA_def_property(srna, "proxy_group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "proxy_collection", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "proxy_group");
RNA_def_property_ui_text(prop, "Proxy Collection", "Library collection duplicator object this proxy object controls");
/* materials */
@@ -2403,7 +2404,7 @@ static void rna_def_object(BlenderRNA *brna)
"WARNING: Only takes into account 'Object' parenting, so e.g. in case of bone parenting "
"you get a matrix relative to the Armature object, not to the actual parent bone");
RNA_def_property_float_funcs(prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", NULL);
- RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, NULL);
+ RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
@@ -2584,13 +2585,13 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1);
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
- prop = RNA_def_property(srna, "show_duplicator_for_render", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "show_instancer_for_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_RENDER);
- RNA_def_property_ui_text(prop, "Render Duplicator", "Make duplicator visible when rendering");
+ RNA_def_property_ui_text(prop, "Render Instancer", "Make instancer visible when rendering");
- prop = RNA_def_property(srna, "show_duplicator_for_viewport", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "show_instancer_for_viewport", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_VIEWPORT);
- RNA_def_property_ui_text(prop, "Display Duplicator", "Make duplicator visible in the viewport");
+ RNA_def_property_ui_text(prop, "Display Instancer", "Make instancer visible in the viewport");
/* anim */
rna_def_animdata_common(srna);
@@ -2613,71 +2614,71 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Slow Parent Offset", "Delay in the parent relationship");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
- /* duplicates */
- prop = RNA_def_property(srna, "dupli_type", PROP_ENUM, PROP_NONE);
+ /* instancing */
+ prop = RNA_def_property(srna, "instance_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag");
- RNA_def_property_enum_items(prop, dupli_items);
- RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_dupli_type_itemf");
- RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use");
+ RNA_def_property_enum_items(prop, instance_items);
+ RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_instance_type_itemf");
+ RNA_def_property_ui_text(prop, "Instance Type", "If not None, object instancing method to use");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
- prop = RNA_def_property(srna, "use_dupli_frames_speed", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_instance_frames_speed", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED);
- RNA_def_property_ui_text(prop, "Dupli Frames Speed",
- "Set dupliframes to use the current frame instead of parent curve's evaluation time");
+ RNA_def_property_ui_text(prop, "Instance Frames Speed",
+ "Set frames instancing to use the current frame instead of parent curve's evaluation time");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
- prop = RNA_def_property(srna, "use_dupli_vertices_rotation", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_instance_vertices_rotation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIROT);
- RNA_def_property_ui_text(prop, "Dupli Verts Rotation", "Rotate dupli according to vertex normal");
+ RNA_def_property_ui_text(prop, "Instance Verts Rotation", "Rotate instance according to vertex normal");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
- prop = RNA_def_property(srna, "use_dupli_faces_scale", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_instance_faces_scale", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFACES_SCALE);
- RNA_def_property_ui_text(prop, "Dupli Faces Inherit Scale", "Scale dupli based on face size");
+ RNA_def_property_ui_text(prop, "Instance Faces Inherit Scale", "Scale instance based on face size");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
- prop = RNA_def_property(srna, "dupli_faces_scale", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "instance_faces_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "dupfacesca");
RNA_def_property_range(prop, 0.001f, 10000.0f);
- RNA_def_property_ui_text(prop, "Dupli Faces Scale", "Scale the DupliFace objects");
+ RNA_def_property_ui_text(prop, "Instance Faces Scale", "Scale the face instance objects");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
- prop = RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "instance_collection", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Collection");
RNA_def_property_pointer_sdna(prop, NULL, "dup_group");
RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_dup_group_set", NULL, NULL);
- RNA_def_property_ui_text(prop, "Dupli Collection", "Instance an existing collection");
+ RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_dup_collection_set", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Instance Collection", "Instance an existing collection");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
- prop = RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
+ prop = RNA_def_property(srna, "instance_frames_start", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
RNA_def_property_int_sdna(prop, NULL, "dupsta");
RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
- RNA_def_property_ui_text(prop, "Dupli Frames Start", "Start frame for DupliFrames");
+ RNA_def_property_ui_text(prop, "Instance Frames Start", "Start frame for frame instances");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
- prop = RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
+ prop = RNA_def_property(srna, "instance_frames_end", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
RNA_def_property_int_sdna(prop, NULL, "dupend");
RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
- RNA_def_property_ui_text(prop, "Dupli Frames End", "End frame for DupliFrames");
+ RNA_def_property_ui_text(prop, "Instance Frames End", "End frame for frame instances");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
- prop = RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
+ prop = RNA_def_property(srna, "instance_frames_on", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
RNA_def_property_int_sdna(prop, NULL, "dupon");
RNA_def_property_range(prop, 1, MAXFRAME);
RNA_def_property_ui_range(prop, 1, 1500, 1, -1);
- RNA_def_property_ui_text(prop, "Dupli Frames On", "Number of frames to use between DupOff frames");
+ RNA_def_property_ui_text(prop, "Instance Frames On", "Number of frames to use between DupOff frames");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
- prop = RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
+ prop = RNA_def_property(srna, "instance_frames_off", PROP_INT, PROP_NONE | PROP_UNIT_TIME);
RNA_def_property_int_sdna(prop, NULL, "dupoff");
RNA_def_property_range(prop, 0, MAXFRAME);
RNA_def_property_ui_range(prop, 0, 1500, 1, -1);
- RNA_def_property_ui_text(prop, "Dupli Frames Off", "Recurring frames to exclude from the Dupliframes");
+ RNA_def_property_ui_text(prop, "Instance Frames Off", "Recurring frames to exclude from the frame instances");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
- prop = RNA_def_property(srna, "is_duplicator", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "is_instancer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLI);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -2794,9 +2795,9 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Dynamic Topology Sculpting", NULL);
/* Base Settings */
- prop = RNA_def_property(srna, "is_from_duplicator", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "is_from_instancer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "base_flag", BASE_FROMDUPLI);
- RNA_def_property_ui_text(prop, "Base from Duplicator", "Object comes from a duplicator");
+ RNA_def_property_ui_text(prop, "Base from Instancer", "Object comes from a instancer");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "is_from_set", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 17233b100c8..4c8a3db42a2 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -114,7 +114,7 @@ static void rna_Object_select_set(
}
Scene *scene = CTX_data_scene(C);
- DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene);
}
@@ -134,6 +134,7 @@ static bool rna_Object_select_get(Object *ob, bContext *C, ReportList *reports)
static bool rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (!base) {
@@ -141,6 +142,10 @@ static bool rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports)
return false;
}
+ if (v3d && v3d->localvd && ((base->local_view_bits & v3d->local_view_uuid) == 0)) {
+ return false;
+ }
+
return ((base->flag & BASE_VISIBLE) != 0);
}
@@ -264,7 +269,7 @@ static void rna_Object_shape_key_remove(
return;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
RNA_POINTER_INVALIDATE(kb_ptr);
@@ -503,7 +508,7 @@ void RNA_api_object(StructRNA *srna)
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "visible_get", "rna_Object_visible_get");
- RNA_def_function_ui_description(func, "Get the object visibility for the active view layer");
+ RNA_def_function_ui_description(func, "Get the object visibility for the active view layer and viewport");
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
parm = RNA_def_boolean(func, "result", 0, "", "Object visible");
RNA_def_function_return(func, parm);
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index e1090a3ded5..ee58fff2e78 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -119,7 +119,7 @@ static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
PTCacheID pid = BKE_ptcache_id_find(ob, NULL, cache);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
if (pid.cache) {
/* Just make sure this wasn't changed. */
@@ -164,7 +164,7 @@ static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), P
BKE_ptcache_load_external(&pid);
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_POINTCACHE, ob);
}
else {
@@ -452,7 +452,7 @@ static void rna_FieldSettings_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
part->pd2->tex = NULL;
}
- DEG_id_tag_update(&part->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME | PSYS_RECALC_RESET);
+ DEG_id_tag_update(&part->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION | ID_RECALC_PSYS_RESET);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
}
@@ -464,7 +464,7 @@ static void rna_FieldSettings_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
ob->pd->tex = NULL;
}
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
}
@@ -500,7 +500,7 @@ static void rna_FieldSettings_type_set(PointerRNA *ptr, int value)
static void rna_FieldSettings_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
if (particle_id_check(ptr)) {
- DEG_id_tag_update((ID *)ptr->id.data, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME | PSYS_RECALC_RESET);
+ DEG_id_tag_update((ID *)ptr->id.data, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION | ID_RECALC_PSYS_RESET);
}
else {
Object *ob = (Object *)ptr->id.data;
@@ -519,9 +519,9 @@ static void rna_FieldSettings_dependency_update(Main *bmain, Scene *scene, Point
DEG_relations_tag_update(bmain);
if (ob->type == OB_CURVE && ob->pd->forcefield == PFIELD_GUIDE)
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
else
- DEG_id_tag_update(&ob->id, OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
@@ -565,7 +565,7 @@ static void rna_EffectorWeight_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
FOREACH_SCENE_OBJECT_END;
}
else {
- DEG_id_tag_update(id, OB_RECALC_DATA | PSYS_RECALC_RESET);
+ DEG_id_tag_update(id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
}
}
@@ -574,7 +574,7 @@ static void rna_EffectorWeight_dependency_update(Main *bmain, Scene *UNUSED(scen
{
DEG_relations_tag_update(bmain);
- DEG_id_tag_update((ID *)ptr->id.data, OB_RECALC_DATA | PSYS_RECALC_RESET);
+ DEG_id_tag_update((ID *)ptr->id.data, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
}
@@ -671,7 +671,7 @@ static void rna_CollisionSettings_update(Main *UNUSED(bmain), Scene *UNUSED(scen
{
Object *ob = (Object *)ptr->id.data;
- DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
@@ -679,7 +679,7 @@ static void rna_softbody_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point
{
Object *ob = (Object *)ptr->id.data;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}
@@ -994,8 +994,9 @@ static void rna_def_effector_weight(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
/* General */
- prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Collection");
+ RNA_def_property_pointer_sdna(prop, NULL, "group");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Effector Collection", "Limit effectors to this collection");
RNA_def_property_update(prop, 0, "rna_EffectorWeight_dependency_update");
@@ -1265,7 +1266,7 @@ static void rna_def_field(BlenderRNA *brna)
prop = RNA_def_property(srna, "falloff_power", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "f_power");
RNA_def_property_range(prop, 0.0f, 10.0f);
- RNA_def_property_ui_text(prop, "Falloff Power", "");
+ RNA_def_property_ui_text(prop, "Falloff Power", "How quickly strength falls off with distance from the force field");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
prop = RNA_def_property(srna, "distance_min", PROP_FLOAT, PROP_NONE);
@@ -1781,8 +1782,9 @@ static void rna_def_softbody(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Self Collision", "Enable naive vertex ball self collision");
RNA_def_property_update(prop, 0, "rna_softbody_update");
- prop = RNA_def_property(srna, "collision_group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "collision_collection", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Collection");
+ RNA_def_property_pointer_sdna(prop, NULL, "collision_group");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Collision Collection", "Limit colliders to this collection");
RNA_def_property_update(prop, 0, "rna_softbody_dependency_update");
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 1abba3979f0..bc6c6917ed3 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -589,16 +589,16 @@ static void particle_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN
psys->recalc = flag;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
else
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA | flag);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY | flag);
WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
}
static void rna_Particle_redo(Main *bmain, Scene *scene, PointerRNA *ptr)
{
- particle_recalc(bmain, scene, ptr, PSYS_RECALC_REDO);
+ particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_REDO);
}
static void rna_Particle_redo_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
@@ -612,12 +612,12 @@ static void rna_Particle_redo_count(Main *bmain, Scene *scene, PointerRNA *ptr)
ParticleSettings *part = (ParticleSettings *)ptr->data;
DEG_relations_tag_update(bmain);
psys_check_group_weights(part);
- particle_recalc(bmain, scene, ptr, PSYS_RECALC_REDO);
+ particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_REDO);
}
static void rna_Particle_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
{
- particle_recalc(bmain, scene, ptr, PSYS_RECALC_RESET);
+ particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_RESET);
}
static void rna_Particle_reset_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
@@ -635,8 +635,8 @@ static void rna_Particle_change_type(Main *bmain, Scene *UNUSED(scene), PointerR
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
if (psys->part == part) {
psys_changed_type(ob, psys);
- psys->recalc |= PSYS_RECALC_RESET;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ psys->recalc |= ID_RECALC_PSYS_RESET;
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
}
@@ -647,7 +647,7 @@ static void rna_Particle_change_type(Main *bmain, Scene *UNUSED(scene), PointerR
static void rna_Particle_change_physics_type(Main *bmain, Scene *scene, PointerRNA *ptr)
{
- particle_recalc(bmain, scene, ptr, PSYS_RECALC_RESET | PSYS_RECALC_PHYS);
+ particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_RESET | ID_RECALC_PSYS_PHYS);
ParticleSettings *part = (ParticleSettings *)ptr->data;
@@ -674,14 +674,14 @@ static void rna_Particle_change_physics_type(Main *bmain, Scene *scene, PointerR
static void rna_Particle_redo_child(Main *bmain, Scene *scene, PointerRNA *ptr)
{
- particle_recalc(bmain, scene, ptr, PSYS_RECALC_CHILD);
+ particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_CHILD);
}
static void rna_Particle_cloth_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
}
@@ -724,9 +724,9 @@ static void rna_Particle_target_reset(Main *bmain, Scene *UNUSED(scene), Pointer
pt->flag &= ~PTARGET_VALID;
}
- psys->recalc = PSYS_RECALC_RESET;
+ psys->recalc = ID_RECALC_PSYS_RESET;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
}
@@ -740,9 +740,9 @@ static void rna_Particle_target_redo(Main *UNUSED(bmain), Scene *UNUSED(scene),
ParticleTarget *pt = (ParticleTarget *)ptr->data;
ParticleSystem *psys = rna_particle_system_for_target(ob, pt);
- psys->recalc = PSYS_RECALC_REDO;
+ psys->recalc = ID_RECALC_PSYS_REDO;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
}
}
@@ -763,7 +763,7 @@ static void rna_Particle_hair_dynamics_update(Main *bmain, Scene *scene, Pointer
WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
}
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
}
@@ -1200,7 +1200,7 @@ static PointerRNA rna_Particle_field1_get(PointerRNA *ptr)
/* weak */
if (!part->pd)
- part->pd = object_add_collision_fields(0);
+ part->pd = BKE_partdeflect_new(0);
return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, part->pd);
}
@@ -1211,7 +1211,7 @@ static PointerRNA rna_Particle_field2_get(PointerRNA *ptr)
/* weak */
if (!part->pd2)
- part->pd2 = object_add_collision_fields(0);
+ part->pd2 = BKE_partdeflect_new(0);
return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, part->pd2);
}
@@ -1562,7 +1562,7 @@ static void rna_def_particle_dupliweight(BlenderRNA *brna)
PropertyRNA *prop;
srna = RNA_def_struct(brna, "ParticleDupliWeight", NULL);
- RNA_def_struct_ui_text(srna, "Particle Dupliobject Weight", "Weight of a particle dupliobject in a group");
+ RNA_def_struct_ui_text(srna, "Particle Dupliobject Weight", "Weight of a particle dupliobject in a collection");
RNA_def_struct_sdna(srna, "ParticleDupliWeight");
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
@@ -2324,29 +2324,29 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Number", "Show particle number");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
- prop = RNA_def_property(srna, "use_group_pick_random", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_collection_pick_random", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_RAND_GR);
- RNA_def_property_ui_text(prop, "Pick Random", "Pick objects from group randomly");
+ RNA_def_property_ui_text(prop, "Pick Random", "Pick objects from collection randomly");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
- prop = RNA_def_property(srna, "use_group_count", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_collection_count", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_COUNT_GR);
RNA_def_property_ui_text(prop, "Use Count", "Use object multiple times in the same collection");
RNA_def_property_update(prop, 0, "rna_Particle_redo_count");
- prop = RNA_def_property(srna, "use_global_dupli", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_global_instance", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_GLOBAL_OB);
RNA_def_property_ui_text(prop, "Global", "Use object's global coordinates for duplication");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
- prop = RNA_def_property(srna, "use_rotation_dupli", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_rotation_instance", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_ROTATE_OB);
RNA_def_property_ui_text(prop, "Rotation",
"Use object's rotation for duplication (global x-axis is aligned "
"particle rotation axis)");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
- prop = RNA_def_property(srna, "use_scale_dupli", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_scale_instance", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "draw", PART_DRAW_NO_SCALE_OB);
RNA_def_property_ui_text(prop, "Scale", "Use object's scale for duplication");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
@@ -2361,9 +2361,9 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Speed", "Multiply line length by particle speed");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
- prop = RNA_def_property(srna, "use_whole_group", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_whole_collection", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_WHOLE_GR);
- RNA_def_property_ui_text(prop, "Whole Group", "Use whole group at once");
+ RNA_def_property_ui_text(prop, "Whole Collection", "Use whole collection at once");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
prop = RNA_def_property(srna, "use_strand_primitive", PROP_BOOLEAN, PROP_NONE);
@@ -2780,8 +2780,9 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Random Size", "Give the particle size a random variation");
RNA_def_property_update(prop, 0, "rna_Particle_reset");
- prop = RNA_def_property(srna, "collision_group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "collision_collection", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Collection");
+ RNA_def_property_pointer_sdna(prop, NULL, "collision_group");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Collision Collection", "Limit colliders to this collection");
RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency");
@@ -3092,35 +3093,35 @@ static void rna_def_particle_settings(BlenderRNA *brna)
"(must use same subsurf level for viewport and render for correct results)");
RNA_def_property_update(prop, 0, "rna_Particle_change_type");
- /* draw objects & groups */
- prop = RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE);
+ /* draw objects & collections */
+ prop = RNA_def_property(srna, "instance_collection", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "dup_group");
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_count");
- prop = RNA_def_property(srna, "dupli_weights", PROP_COLLECTION, PROP_NONE);
+ prop = RNA_def_property(srna, "instance_weights", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "dupliweights", NULL);
RNA_def_property_struct_type(prop, "ParticleDupliWeight");
- RNA_def_property_ui_text(prop, "Dupli Group Weights", "Weights for all of the objects in the dupli group");
+ RNA_def_property_ui_text(prop, "Dupli Collection Weights", "Weights for all of the objects in the dupli collection");
- prop = RNA_def_property(srna, "active_dupliweight", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "active_instanceweight", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "ParticleDupliWeight");
RNA_def_property_pointer_funcs(prop, "rna_ParticleDupliWeight_active_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Active Dupli Object", "");
- prop = RNA_def_property(srna, "active_dupliweight_index", PROP_INT, PROP_UNSIGNED);
+ prop = RNA_def_property(srna, "active_instanceweight_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_funcs(prop, "rna_ParticleDupliWeight_active_index_get",
"rna_ParticleDupliWeight_active_index_set",
"rna_ParticleDupliWeight_active_index_range");
RNA_def_property_ui_text(prop, "Active Dupli Object Index", "");
- prop = RNA_def_property(srna, "dupli_object", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "instance_object", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "dup_ob");
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Dupli Object", "Show this Object in place of particles");
+ RNA_def_property_ui_text(prop, "Instance Object", "Show this Object in place of particles");
RNA_def_property_update(prop, 0, "rna_Particle_redo_dependency");
prop = RNA_def_property(srna, "billboard_object", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 4b6a19ab063..d86e87f2a1f 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -123,7 +123,7 @@ static void rna_Pose_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN
{
/* XXX when to use this? ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK); */
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_POSE, ptr->id.data);
}
@@ -131,7 +131,7 @@ static void rna_Pose_dependency_update(Main *bmain, Scene *UNUSED(scene), Pointe
{
DEG_relations_tag_update(bmain);
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_POSE, ptr->id.data);
}
@@ -140,7 +140,7 @@ static void rna_Pose_IK_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe
/* XXX when to use this? ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK); */
Object *ob = ptr->id.data;
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_POSE, ptr->id.data);
BIK_clear_data(ob->pose);
@@ -253,7 +253,7 @@ static void rna_Pose_ik_solver_update(Main *bmain, Scene *UNUSED(scene), Pointer
object_test_constraints(bmain, ob);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
}
/* rotation - axis-angle */
@@ -365,7 +365,7 @@ static void rna_Itasc_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
itasc->maxvel = 100.f;
BIK_update_param(ob->pose);
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
static void rna_Itasc_update_rebuild(Main *bmain, Scene *scene, PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_pose_api.c b/source/blender/makesrna/intern/rna_pose_api.c
index 04ecdd497f6..6b7a8e4e2ff 100644
--- a/source/blender/makesrna/intern/rna_pose_api.c
+++ b/source/blender/makesrna/intern/rna_pose_api.c
@@ -59,6 +59,45 @@ static float rna_PoseBone_do_envelope(bPoseChannel *chan, float *vec)
return distfactor_to_bone(vec, chan->pose_head, chan->pose_tail, bone->rad_head * scale,
bone->rad_tail * scale, bone->dist * scale);
}
+
+static void rna_PoseBone_bbone_segment_matrix(bPoseChannel *pchan, ReportList *reports, float mat_ret[16], int index, bool rest)
+{
+ if (!pchan->bone || pchan->bone->segments <= 1) {
+ BKE_reportf(reports, RPT_ERROR, "Bone '%s' is not a B-Bone!", pchan->name);
+ return;
+ }
+ if (pchan->runtime.bbone_segments != pchan->bone->segments) {
+ BKE_reportf(reports, RPT_ERROR, "Bone '%s' has out of date B-Bone segment data!", pchan->name);
+ return;
+ }
+ if (index < 0 || index >= pchan->runtime.bbone_segments) {
+ BKE_reportf(reports, RPT_ERROR, "Invalid index %d for B-Bone segments of '%s'!", index, pchan->name);
+ return;
+ }
+
+ if (rest) {
+ copy_m4_m4((float (*)[4])mat_ret, pchan->runtime.bbone_rest_mats[index].mat);
+ }
+ else {
+ copy_m4_m4((float (*)[4])mat_ret, pchan->runtime.bbone_pose_mats[index].mat);
+ }
+}
+
+static void rna_PoseBone_compute_bbone_handles(
+ bPoseChannel *pchan, ReportList *reports,
+ float ret_h1[3], float *ret_roll1, float ret_h2[3], float *ret_roll2,
+ bool rest, bool ease, bool offsets)
+{
+ if (!pchan->bone || pchan->bone->segments <= 1) {
+ BKE_reportf(reports, RPT_ERROR, "Bone '%s' is not a B-Bone!", pchan->name);
+ return;
+ }
+
+ BBoneSplineParameters params;
+
+ BKE_pchan_bbone_spline_params_get(pchan, rest, &params);
+ BKE_pchan_bbone_handles_compute(&params, ret_h1, ret_roll1, ret_h2, ret_roll2, ease || offsets, offsets);
+}
#else
void RNA_api_pose(StructRNA *UNUSED(srna))
@@ -80,6 +119,38 @@ void RNA_api_pose_channel(StructRNA *srna)
/* return value */
parm = RNA_def_float(func, "factor", 0, -FLT_MAX, FLT_MAX, "Factor", "Envelope factor", -FLT_MAX, FLT_MAX);
RNA_def_function_return(func, parm);
+
+ /* B-Bone segment matrices */
+ func = RNA_def_function(srna, "bbone_segment_matrix", "rna_PoseBone_bbone_segment_matrix");
+ RNA_def_function_ui_description(func, "Retrieve the matrix of the B-Bone segment if available");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_property(func, "matrix_return", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4);
+ RNA_def_property_ui_text(parm, "", "The resulting matrix in bone local space");
+ RNA_def_function_output(func, parm);
+ parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "", "Index of the segment", 0, 10000);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_boolean(func, "rest", false, "", "Return the rest pose matrix");
+
+ /* B-Bone custom handle positions */
+ func = RNA_def_function(srna, "compute_bbone_handles", "rna_PoseBone_compute_bbone_handles");
+ RNA_def_function_ui_description(func, "Retrieve the vectors and rolls coming from B-Bone custom handles");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_property(func, "handle1", PROP_FLOAT, PROP_XYZ);
+ RNA_def_property_array(parm, 3);
+ RNA_def_property_ui_text(parm, "", "The direction vector of the start handle in bone local space");
+ RNA_def_function_output(func, parm);
+ parm = RNA_def_float(func, "roll1", 0, -FLT_MAX, FLT_MAX, "", "Roll of the start handle", -FLT_MAX, FLT_MAX);
+ RNA_def_function_output(func, parm);
+ parm = RNA_def_property(func, "handle2", PROP_FLOAT, PROP_XYZ);
+ RNA_def_property_array(parm, 3);
+ RNA_def_property_ui_text(parm, "", "The direction vector of the end handle in bone local space");
+ RNA_def_function_output(func, parm);
+ parm = RNA_def_float(func, "roll2", 0, -FLT_MAX, FLT_MAX, "", "Roll of the end handle", -FLT_MAX, FLT_MAX);
+ RNA_def_function_output(func, parm);
+ parm = RNA_def_boolean(func, "rest", false, "", "Return the rest pose state");
+ parm = RNA_def_boolean(func, "ease", false, "", "Apply scale from ease values");
+ parm = RNA_def_boolean(func, "offsets", false, "", "Apply roll and curve offsets from bone properties");
}
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index 2b4cadc41af..a19ecb9f9e5 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -453,7 +453,7 @@ void set_collision_groups(RigidBodyOb* rbo, const bool *values)
rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
}
-static void rna_RigidBodyOb_collision_groups_set(PointerRNA *ptr, const bool *values)
+static void rna_RigidBodyOb_collision_collections_set(PointerRNA *ptr, const bool *values)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
Object *ob = ptr->id.data;
@@ -1059,8 +1059,9 @@ static void rna_def_rigidbody_world(BlenderRNA *brna)
RNA_def_struct_path_func(srna, "rna_RigidBodyWorld_path");
/* groups */
- prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Collection");
+ RNA_def_property_pointer_sdna(prop, NULL, "group");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
RNA_def_property_ui_text(prop, "Collection", "Collection containing objects participating in this simulation");
RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
@@ -1361,10 +1362,10 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
"(best results when non-zero)");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_reset");
- prop = RNA_def_property(srna, "collision_groups", PROP_BOOLEAN, PROP_LAYER_MEMBER);
+ prop = RNA_def_property(srna, "collision_collections", PROP_BOOLEAN, PROP_LAYER_MEMBER);
RNA_def_property_boolean_sdna(prop, NULL, "col_groups", 1);
RNA_def_property_array(prop, 20);
- RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyOb_collision_groups_set");
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyOb_collision_collections_set");
RNA_def_property_ui_text(prop, "Collision Collections", "Collision collections rigid body belongs to");
RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index eeb48b67d28..6c9d6b4d8e3 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -551,7 +551,7 @@ static void rna_GPencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UN
if (ob->type == OB_GPENCIL) {
bGPdata *gpd = (bGPdata *)ob->data;
gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
@@ -1325,7 +1325,7 @@ static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value)
if (type) {
BLI_strncpy_utf8(rd->engine, type->idname, sizeof(rd->engine));
- DEG_id_tag_update(ptr->id.data, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_COPY_ON_WRITE);
}
}
@@ -1458,7 +1458,7 @@ static void rna_Physics_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe
}
FOREACH_SCENE_OBJECT_END;
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
}
static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const bool *value)
@@ -1497,7 +1497,7 @@ static void rna_Scene_editmesh_select_mode_update(bContext *C, PointerRNA *UNUSE
}
if (me) {
- DEG_id_tag_update(&me->id, DEG_TAG_SELECT_UPDATE);
+ DEG_id_tag_update(&me->id, ID_RECALC_SELECT);
WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL);
}
}
@@ -1515,12 +1515,12 @@ static void object_simplify_update(Object *ob)
for (md = ob->modifiers.first; md; md = md->next) {
if (ELEM(md->type, eModifierType_Subsurf, eModifierType_Multires, eModifierType_ParticleSystem)) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
for (psys = ob->particlesystem.first; psys; psys = psys->next)
- psys->recalc |= PSYS_RECALC_CHILD;
+ psys->recalc |= ID_RECALC_PSYS_CHILD;
if (ob->dup_group) {
CollectionObject *cob;
@@ -1724,7 +1724,7 @@ static void rna_EditMesh_update(bContext *C, PointerRNA *UNUSED(ptr))
}
if (me) {
- DEG_id_tag_update(&me->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GEOM | ND_DATA, me);
}
}
@@ -1745,7 +1745,7 @@ static void rna_Scene_update_active_object_data(bContext *C, PointerRNA *UNUSED(
Object *ob = OBACT(view_layer);
if (ob) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id);
}
}
@@ -1756,7 +1756,7 @@ static void rna_SceneCamera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
Object *camera = scene->camera;
if (camera && (camera->type == OB_CAMERA)) {
- DEG_id_tag_update(&camera->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&camera->id, ID_RECALC_GEOMETRY);
}
}
@@ -2088,6 +2088,11 @@ static void rna_unit_system_update(Main *UNUSED(bmain), Scene *scene, PointerRNA
}
}
+static char *rna_UnitSettings_path(PointerRNA *UNUSED(ptr))
+{
+ return BLI_sprintfN("unit_settings");
+}
+
#else
/* Grease Pencil Interpolation tool settings */
@@ -3015,6 +3020,8 @@ static void rna_def_unit_settings(BlenderRNA *brna)
srna = RNA_def_struct(brna, "UnitSettings", NULL);
RNA_def_struct_ui_text(srna, "Unit Settings", "");
+ RNA_def_struct_nested(brna, srna, "Scene");
+ RNA_def_struct_path_func(srna, "rna_UnitSettings_path");
/* Units */
prop = RNA_def_property(srna, "system", PROP_ENUM, PROP_NONE);
@@ -3384,7 +3391,7 @@ void rna_def_freestyle_settings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
- static const EnumPropertyItem group_negation_items[] = {
+ static const EnumPropertyItem collection_negation_items[] = {
{0, "INCLUSIVE", 0, "Inclusive", "Select feature edges belonging to some object in the group"},
{FREESTYLE_LINESET_GR_NOT, "EXCLUSIVE", 0, "Exclusive",
"Select feature edges not belonging to any object in the group"},
@@ -3458,9 +3465,9 @@ void rna_def_freestyle_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Selection by Edge Types", "Select feature edges based on edge types");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_freestyle_update");
- prop = RNA_def_property(srna, "select_by_group", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "select_by_collection", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_GROUP);
- RNA_def_property_ui_text(prop, "Selection by Group", "Select feature edges based on a group of objects");
+ RNA_def_property_ui_text(prop, "Selection by Collection", "Select feature edges based on a collection of objects");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_freestyle_update");
prop = RNA_def_property(srna, "select_by_image_border", PROP_BOOLEAN, PROP_NONE);
@@ -3488,16 +3495,16 @@ void rna_def_freestyle_settings(BlenderRNA *brna)
"Specify a logical combination of selection conditions on feature edge types");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_freestyle_update");
- prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "group");
RNA_def_property_struct_type(prop, "Collection");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Collection", "A collection of objects based on which feature edges are selected");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_freestyle_update");
- prop = RNA_def_property(srna, "group_negation", PROP_ENUM, PROP_NONE);
+ prop = RNA_def_property(srna, "collection_negation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
- RNA_def_property_enum_items(prop, group_negation_items);
+ RNA_def_property_enum_items(prop, collection_negation_items);
RNA_def_property_ui_text(prop, "Collection Negation",
"Specify either inclusion or exclusion of feature edges belonging to a collection of objects");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_freestyle_update");
@@ -3746,10 +3753,10 @@ static void rna_def_bake_data(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Bake Data", "Bake data for a Scene data-block");
RNA_def_struct_path_func(srna, "rna_BakeSettings_path");
- prop = RNA_def_property(srna, "cage_object", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "cage");
+ prop = RNA_def_property(srna, "cage_object", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Cage Object", "Object to use as cage "
"instead of calculating the cage from the active object with cage extrusion");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
@@ -5182,6 +5189,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Stamp Peak Memory", "Include the peak memory usage in image metadata");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+ prop = RNA_def_property(srna, "use_stamp_hostname", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_HOSTNAME);
+ RNA_def_property_ui_text(prop, "Stamp Hostname", "Include the hostname of the machine that rendered the frame");
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
prop = RNA_def_property(srna, "stamp_font_size", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "stamp_font_id");
RNA_def_property_range(prop, 8, 64);
@@ -5344,6 +5356,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Simplify Shaders", "Do not apply shader fx");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ prop = RNA_def_property(srna, "simplify_gpencil_blend", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_BLEND);
+ RNA_def_property_ui_text(prop, "Layers Blending", "Do not display blend layers");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
/* persistent data */
prop = RNA_def_property(srna, "use_persistent_data", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_PERSISTENT_DATA);
@@ -5586,7 +5603,6 @@ static void rna_def_scene_display(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_set_update");
prop = RNA_def_property(srna, "shadow_shift", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "shadow_shift");
RNA_def_property_float_default(prop, 0.1);
RNA_def_property_ui_text(prop, "Shadow Shift", "Shadow termination angle");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -5594,6 +5610,14 @@ static void rna_def_scene_display(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_set_update");
+ prop = RNA_def_property(srna, "shadow_focus", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_default(prop, 0.0);
+ RNA_def_property_ui_text(prop, "Shadow Focus", "Shadow factor hardness");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 2);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_set_update");
+
prop = RNA_def_property(srna, "matcap_ssao_distance", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_ui_text(prop, "Distance", "Distance of object that contribute to the Cavity/Edge effect");
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index f4311f820ce..0a7c71a683e 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -153,7 +153,7 @@ static const EnumPropertyItem *rna_Area_type_itemf(bContext *UNUSED(C), PointerR
/* +1 to skip SPACE_EMPTY */
for (const EnumPropertyItem *item_from = rna_enum_space_type_items + 1; item_from->identifier; item_from++) {
- if (ELEM(item_from->value, SPACE_TOPBAR, SPACE_STATUSBAR, SPACE_USERPREF)) {
+ if (ELEM(item_from->value, SPACE_TOPBAR, SPACE_STATUSBAR)) {
continue;
}
RNA_enum_item_add(&item, &totitem, item_from);
@@ -174,7 +174,7 @@ static int rna_Area_type_get(PointerRNA *ptr)
static void rna_Area_type_set(PointerRNA *ptr, int value)
{
- if (ELEM(value, SPACE_TOPBAR, SPACE_STATUSBAR, SPACE_USERPREF)) {
+ if (ELEM(value, SPACE_TOPBAR, SPACE_STATUSBAR)) {
/* Special case: An area can not be set to show the top-bar editor (or
* other global areas). However it should still be possible to identify
* its type from Python. */
@@ -232,7 +232,7 @@ static const EnumPropertyItem *rna_Area_ui_type_itemf(
/* +1 to skip SPACE_EMPTY */
for (const EnumPropertyItem *item_from = rna_enum_space_type_items + 1; item_from->identifier; item_from++) {
- if (ELEM(item_from->value, SPACE_TOPBAR, SPACE_STATUSBAR, SPACE_USERPREF)) {
+ if (ELEM(item_from->value, SPACE_TOPBAR, SPACE_STATUSBAR)) {
continue;
}
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index d106e2db6eb..8cda9677057 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -131,7 +131,7 @@ static void rna_GPencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UN
if (ob->type == OB_GPENCIL) {
bGPdata *gpd = (bGPdata *)ob->data;
gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
- DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
@@ -185,11 +185,11 @@ static void rna_ParticleEdit_redo(bContext *C, PointerRNA *UNUSED(ptr))
if (!edit)
return;
- if (ob) DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ if (ob) DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
BKE_particle_batch_cache_dirty_tag(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
psys_free_path_cache(edit->psys, edit);
- DEG_id_tag_update(&CTX_data_scene(C)->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&CTX_data_scene(C)->id, ID_RECALC_COPY_ON_WRITE);
}
static void rna_ParticleEdit_update(bContext *C, PointerRNA *UNUSED(ptr))
@@ -197,10 +197,10 @@ static void rna_ParticleEdit_update(bContext *C, PointerRNA *UNUSED(ptr))
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
- if (ob) DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ if (ob) DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
/* Sync tool setting changes from original to evaluated scenes. */
- DEG_id_tag_update(&CTX_data_scene(C)->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_id_tag_update(&CTX_data_scene(C)->id, ID_RECALC_COPY_ON_WRITE);
}
static void rna_ParticleEdit_tool_set(PointerRNA *ptr, int value)
@@ -211,7 +211,7 @@ static void rna_ParticleEdit_tool_set(PointerRNA *ptr, int value)
if ((pset->brushtype == PE_BRUSH_WEIGHT || value == PE_BRUSH_WEIGHT) && pset->object) {
Object *ob = pset->object;
if (ob) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
}
}
@@ -355,7 +355,7 @@ static void rna_Sculpt_update(bContext *C, PointerRNA *UNUSED(ptr))
Object *ob = OBACT(view_layer);
if (ob) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
if (ob->sculpt) {
diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c
deleted file mode 100644
index e04e78f3ac7..00000000000
--- a/source/blender/makesrna/intern/rna_sensor.c
+++ /dev/null
@@ -1,939 +0,0 @@
-/*
- * ***** 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 (2008).
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/makesrna/intern/rna_sensor.c
- * \ingroup RNA
- */
-
-#include <stdlib.h>
-
-#include "DNA_constraint_types.h"
-#include "DNA_object_types.h"
-#include "DNA_sensor_types.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_math.h"
-#include "BLI_string_utils.h"
-
-#include "BLT_translation.h"
-
-#include "RNA_define.h"
-#include "RNA_enum_types.h"
-#include "RNA_access.h"
-
-#include "rna_internal.h"
-
-#include "WM_types.h"
-
-/* Always keep in alphabetical order */
-static const EnumPropertyItem sensor_type_items[] = {
- {SENS_ACTUATOR, "ACTUATOR", 0, "Actuator", ""},
- {SENS_ALWAYS, "ALWAYS", 0, "Always", ""},
- {SENS_ARMATURE, "ARMATURE", 0, "Armature", ""},
- {SENS_COLLISION, "COLLISION", 0, "Collision", ""},
- {SENS_DELAY, "DELAY", 0, "Delay", ""},
- {SENS_JOYSTICK, "JOYSTICK", 0, "Joystick", ""},
- {SENS_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
- {SENS_MESSAGE, "MESSAGE", 0, "Message", ""},
- {SENS_MOUSE, "MOUSE", 0, "Mouse", ""},
- {SENS_NEAR, "NEAR", 0, "Near", ""},
- {SENS_PROPERTY, "PROPERTY", 0, "Property", ""},
- {SENS_RADAR, "RADAR", 0, "Radar", ""},
- {SENS_RANDOM, "RANDOM", 0, "Random", ""},
- {SENS_RAY, "RAY", 0, "Ray", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
-#ifdef RNA_RUNTIME
-
-#include "BKE_sca.h"
-#include "DNA_controller_types.h"
-
-static StructRNA *rna_Sensor_refine(struct PointerRNA *ptr)
-{
- bSensor *sensor = (bSensor *)ptr->data;
-
- switch (sensor->type) {
- case SENS_ALWAYS:
- return &RNA_AlwaysSensor;
- case SENS_NEAR:
- return &RNA_NearSensor;
- case SENS_KEYBOARD:
- return &RNA_KeyboardSensor;
- case SENS_PROPERTY:
- return &RNA_PropertySensor;
- case SENS_ARMATURE:
- return &RNA_ArmatureSensor;
- case SENS_MOUSE:
- return &RNA_MouseSensor;
- case SENS_COLLISION:
- return &RNA_CollisionSensor;
- case SENS_RADAR:
- return &RNA_RadarSensor;
- case SENS_RANDOM:
- return &RNA_RandomSensor;
- case SENS_RAY:
- return &RNA_RaySensor;
- case SENS_MESSAGE:
- return &RNA_MessageSensor;
- case SENS_JOYSTICK:
- return &RNA_JoystickSensor;
- case SENS_ACTUATOR:
- return &RNA_ActuatorSensor;
- case SENS_DELAY:
- return &RNA_DelaySensor;
- default:
- return &RNA_Sensor;
- }
-}
-
-static void rna_Sensor_name_set(PointerRNA *ptr, const char *value)
-{
- Object *ob = ptr->id.data;
- bSensor *sens = ptr->data;
- BLI_strncpy_utf8(sens->name, value, sizeof(sens->name));
- BLI_uniquename(&ob->sensors, sens, DATA_("Sensor"), '.', offsetof(bSensor, name), sizeof(sens->name));
-}
-
-static void rna_Sensor_type_set(struct PointerRNA *ptr, int value)
-{
- bSensor *sens = (bSensor *)ptr->data;
- if (value != sens->type) {
- sens->type = value;
- init_sensor(sens);
- }
-}
-
-/* Always keep in alphabetical order */
-
-static void rna_Sensor_controllers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
-{
- bSensor *sens = (bSensor *)ptr->data;
- rna_iterator_array_begin(iter, sens->links, sizeof(bController *), (int)sens->totlinks, 0, NULL);
-}
-
-static int rna_Sensor_controllers_length(PointerRNA *ptr)
-{
- bSensor *sens = (bSensor *)ptr->data;
- return (int) sens->totlinks;
-}
-
-const EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
-{
- EnumPropertyItem *item = NULL;
- Object *ob = NULL;
- int totitem = 0;
-
- if (ptr->type == &RNA_Sensor || RNA_struct_is_a(ptr->type, &RNA_Sensor)) {
- ob = (Object *)ptr->id.data;
- }
- else {
- /* can't use ob from ptr->id.data because that enum is also used by operators */
- ob = CTX_data_active_object(C);
- }
-
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ACTUATOR);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ALWAYS);
-
- if (ob != NULL) {
- if (ob->type == OB_ARMATURE) {
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ARMATURE);
- }
- }
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_COLLISION);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_DELAY);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_JOYSTICK);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_KEYBOARD);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MESSAGE);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MOUSE);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_NEAR);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_PROPERTY);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RADAR);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RANDOM);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RAY);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_TOUCH);
-
- RNA_enum_item_end(&item, &totitem);
- *r_free = true;
-
- return item;
-}
-
-static void rna_Sensor_keyboard_key_set(struct PointerRNA *ptr, int value)
-{
- bSensor *sens = (bSensor *)ptr->data;
- bKeyboardSensor *ks = (bKeyboardSensor *)sens->data;
-
- if (ISKEYBOARD(value))
- ks->key = value;
- else
- ks->key = 0;
-}
-
-static void rna_Sensor_keyboard_modifier_set(struct PointerRNA *ptr, int value)
-{
- bSensor *sens = (bSensor *)ptr->data;
- bKeyboardSensor *ks = (bKeyboardSensor *)sens->data;
-
- if (ISKEYBOARD(value))
- ks->qual = value;
- else
- ks->qual = 0;
-}
-
-static void rna_Sensor_keyboard_modifier2_set(struct PointerRNA *ptr, int value)
-{
- bSensor *sens = (bSensor *)ptr->data;
- bKeyboardSensor *ks = (bKeyboardSensor *)sens->data;
-
- if (ISKEYBOARD(value))
- ks->qual2 = value;
- else
- ks->qual2 = 0;
-}
-
-static void rna_Sensor_tap_set(struct PointerRNA *ptr, bool value)
-{
- bSensor *sens = (bSensor *)ptr->data;
-
- sens->tap = value;
- if (sens->tap == 1)
- sens->level = 0;
-}
-
-static void rna_Sensor_level_set(struct PointerRNA *ptr, bool value)
-{
- bSensor *sens = (bSensor *)ptr->data;
-
- sens->level = value;
- if (sens->level == 1)
- sens->tap = 0;
-}
-
-static void rna_Sensor_Armature_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- bSensor *sens = (bSensor *)ptr->data;
- bArmatureSensor *as = sens->data;
- Object *ob = (Object *)ptr->id.data;
-
- char *posechannel = as->posechannel;
- char *constraint = as->constraint;
-
- /* check that bone exist in the active object */
- if (ob->type == OB_ARMATURE && ob->pose) {
- bPoseChannel *pchan;
- bPose *pose = ob->pose;
- for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- if (STREQ(pchan->name, posechannel)) {
- /* found it, now look for constraint channel */
- bConstraint *con;
- for (con = pchan->constraints.first; con; con = con->next) {
- if (STREQ(con->name, constraint)) {
- /* found it, all ok */
- return;
- }
- }
- /* didn't find constraint, make empty */
- constraint[0] = 0;
- return;
- }
- }
- }
- /* didn't find any */
- posechannel[0] = 0;
- constraint[0] = 0;
-}
-#else
-
-static void rna_def_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "Sensor", NULL);
- RNA_def_struct_ui_text(srna, "Sensor", "Game engine logic brick to detect events");
- RNA_def_struct_sdna(srna, "bSensor");
- RNA_def_struct_refine_func(srna, "rna_Sensor_refine");
-
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(prop, "Name", "Sensor name");
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Sensor_name_set");
- RNA_def_struct_name_property(srna, prop);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_enum_items(prop, sensor_type_items);
- RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_type_set", "rna_Sensor_type_itemf");
- RNA_def_property_ui_text(prop, "Type", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "pin", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_PIN);
- RNA_def_property_ui_text(prop, "Pinned", "Display when not linked to a visible states controller");
- RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SENS_DEACTIVATE);
- RNA_def_property_ui_text(prop, "Active", "Set active state of the sensor");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_SHOW);
- RNA_def_property_ui_text(prop, "Expanded", "Set sensor expanded in the user interface");
- RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_ui_text(prop, "Invert Output", "Invert the level(output) of this sensor");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_level", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "level", 1);
- RNA_def_property_ui_text(prop, "Level",
- "Level detector, trigger controllers of new states "
- "(only applicable upon logic state transition)");
- RNA_def_property_boolean_funcs(prop, NULL, "rna_Sensor_level_set");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_pulse_true_level", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "pulse", SENS_PULSE_REPEAT);
- RNA_def_property_ui_text(prop, "Pulse True Level", "Activate TRUE level triggering (pulse mode)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_pulse_false_level", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "pulse", SENS_NEG_PULSE_MODE);
- RNA_def_property_ui_text(prop, "Pulse False Level", "Activate FALSE level triggering (pulse mode)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "tick_skip", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "freq");
- RNA_def_property_ui_text(prop, "Skip",
- "Number of logic ticks skipped between 2 active pulses "
- "(0 = pulse every logic tick, 1 = skip 1 logic tick between pulses, etc.)");
- RNA_def_property_range(prop, 0, 10000);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_tap", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "tap", 1);
- RNA_def_property_boolean_funcs(prop, NULL, "rna_Sensor_tap_set");
- RNA_def_property_ui_text(prop, "Tap",
- "Trigger controllers only for an instant, even while the sensor remains true");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "controllers", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "links", NULL);
- RNA_def_property_struct_type(prop, "Controller");
- RNA_def_property_ui_text(prop, "Controllers", "The list containing the controllers connected to the sensor");
- RNA_def_property_collection_funcs(prop, "rna_Sensor_controllers_begin", "rna_iterator_array_next",
- "rna_iterator_array_end", "rna_iterator_array_dereference_get",
- "rna_Sensor_controllers_length", NULL, NULL, NULL);
-
-
- RNA_api_sensor(srna);
-}
-
-static void rna_def_always_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- srna = RNA_def_struct(brna, "AlwaysSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Always Sensor", "Sensor to generate continuous pulses");
-}
-
-static void rna_def_near_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "NearSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Near Sensor", "Sensor to detect nearby objects");
- RNA_def_struct_sdna_from(srna, "bNearSensor", "data");
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "dist");
- RNA_def_property_ui_text(prop, "Distance", "Trigger distance");
- RNA_def_property_range(prop, 0.0f, 10000.0f);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "reset_distance", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "resetdist");
- RNA_def_property_ui_text(prop, "Reset Distance", "The distance where the sensor forgets the actor");
- RNA_def_property_range(prop, 0.0f, 10000.0f);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_mouse_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem mouse_event_items[] = {
- {BL_SENS_MOUSE_LEFT_BUTTON, "LEFTCLICK", 0, "Left Button", ""},
- {BL_SENS_MOUSE_MIDDLE_BUTTON, "MIDDLECLICK", 0, "Middle Button", ""},
- {BL_SENS_MOUSE_RIGHT_BUTTON, "RIGHTCLICK", 0, "Right Button", ""},
- {BL_SENS_MOUSE_WHEEL_UP, "WHEELUP", 0, "Wheel Up", ""},
- {BL_SENS_MOUSE_WHEEL_DOWN, "WHEELDOWN", 0, "Wheel Down", ""},
- {BL_SENS_MOUSE_MOVEMENT, "MOVEMENT", 0, "Movement", ""},
- {BL_SENS_MOUSE_MOUSEOVER, "MOUSEOVER", 0, "Mouse Over", ""},
- {BL_SENS_MOUSE_MOUSEOVER_ANY, "MOUSEOVERANY", 0, "Mouse Over Any", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_mouse_type_items[] = {
- {SENS_COLLISION_PROPERTY, "PROPERTY", ICON_LOGIC, "Property", "Use a property for ray intersections"},
- {SENS_COLLISION_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "Material", "Use a material for ray intersections"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "MouseSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Mouse Sensor", "Sensor to detect mouse events");
- RNA_def_struct_sdna_from(srna, "bMouseSensor", "data");
-
- prop = RNA_def_property(srna, "mouse_event", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, mouse_event_items);
- RNA_def_property_ui_text(prop, "Mouse Event", "Type of event this mouse sensor should trigger on");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_pulse", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_MOUSE_FOCUS_PULSE);
- RNA_def_property_ui_text(prop, "Pulse", "Moving the mouse over a different object generates a pulse");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_material", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, prop_mouse_type_items);
- RNA_def_property_ui_text(prop, "M/P", "Toggle collision on material or property");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "propname");
- RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "material", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "matname");
- RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_x_ray", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_RAY_XRAY);
- RNA_def_property_ui_text(prop, "X-Ray", "Toggle X-Ray option (see through objects that don't have the property)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_keyboard_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "KeyboardSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Keyboard Sensor", "Sensor to detect keyboard events");
- RNA_def_struct_sdna_from(srna, "bKeyboardSensor", "data");
-
- prop = RNA_def_property(srna, "key", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "key");
- RNA_def_property_enum_items(prop, rna_enum_event_type_items);
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
- RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_key_set", NULL);
- RNA_def_property_ui_text(prop, "Key", "");
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_WINDOWMANAGER);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "modifier_key_1", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "qual");
- RNA_def_property_enum_items(prop, rna_enum_event_type_items);
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
- RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_modifier_set", NULL);
- RNA_def_property_ui_text(prop, "Modifier Key", "Modifier key code");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "modifier_key_2", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "qual2");
- RNA_def_property_enum_items(prop, rna_enum_event_type_items);
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
- RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_modifier2_set", NULL);
- RNA_def_property_ui_text(prop, "Second Modifier Key", "Modifier key code");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "target", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "targetName");
- RNA_def_property_ui_text(prop, "Target", "Property that receives the keystrokes in case a string is logged");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "log", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "toggleName");
- RNA_def_property_ui_text(prop, "Log Toggle", "Property that indicates whether to log keystrokes as a string");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_all_keys", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "type", 1);
- RNA_def_property_ui_text(prop, "All Keys", "Trigger this sensor on any keystroke");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_property_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
- static const EnumPropertyItem prop_type_items[] = {
- {SENS_PROP_EQUAL, "PROPEQUAL", 0, "Equal", ""},
- {SENS_PROP_NEQUAL, "PROPNEQUAL", 0, "Not Equal", ""},
- {SENS_PROP_INTERVAL, "PROPINTERVAL", 0, "Interval", ""},
- {SENS_PROP_CHANGED, "PROPCHANGED", 0, "Changed", ""},
- /* {SENS_PROP_EXPRESSION, "PROPEXPRESSION", 0, "Expression", ""}, NOT_USED_IN_UI */
- {SENS_PROP_LESSTHAN, "PROPLESSTHAN", 0, "Less Than", ""},
- {SENS_PROP_GREATERTHAN, "PROPGREATERTHAN", 0, "Greater Than", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "PropertySensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Property Sensor", "Sensor to detect values and changes in values of properties");
- RNA_def_struct_sdna_from(srna, "bPropertySensor", "data");
-
- prop = RNA_def_property(srna, "evaluation_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Evaluation Type", "Type of property evaluation");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Property", "");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "value", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "value");
- RNA_def_property_ui_text(prop, "Value", "Check for this value in types in Equal, Not Equal, Less Than and Greater Than types");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "value_min", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "value");
- RNA_def_property_ui_text(prop, "Minimum Value", "Minimum value in Interval type");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "value_max", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "maxvalue");
- RNA_def_property_ui_text(prop, "Maximum Value", "Maximum value in Interval type");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_armature_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
- static const EnumPropertyItem prop_type_items[] = {
- {SENS_ARM_STATE_CHANGED, "STATECHG", 0, "State Changed", ""},
- {SENS_ARM_LIN_ERROR_BELOW, "LINERRORBELOW", 0, "Lin error below", ""},
- {SENS_ARM_LIN_ERROR_ABOVE, "LINERRORABOVE", 0, "Lin error above", ""},
- {SENS_ARM_ROT_ERROR_BELOW, "ROTERRORBELOW", 0, "Rot error below", ""},
- {SENS_ARM_ROT_ERROR_ABOVE, "ROTERRORABOVE", 0, "Rot error above", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "ArmatureSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Armature Sensor", "Sensor to detect values and changes in values of IK solver");
- RNA_def_struct_sdna_from(srna, "bArmatureSensor", "data");
-
- prop = RNA_def_property(srna, "test_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, prop_type_items);
- RNA_def_property_ui_text(prop, "Test", "Type of value and test");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "bone", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "posechannel");
- RNA_def_property_ui_text(prop, "Bone Name", "Identify the bone to check value from");
- RNA_def_property_update(prop, NC_LOGIC, "rna_Sensor_Armature_update");
-
- prop = RNA_def_property(srna, "constraint", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "constraint");
- RNA_def_property_ui_text(prop, "Constraint Name", "Identify the bone constraint to check value from");
- RNA_def_property_update(prop, NC_LOGIC, "rna_Sensor_Armature_update");
-
- prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "value");
- RNA_def_property_ui_text(prop, "Compare Value", "Value to be used in comparison");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_actuator_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "ActuatorSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Actuator Sensor", "Sensor to detect state modifications of actuators");
- RNA_def_struct_sdna_from(srna, "bActuatorSensor", "data");
-
- /* XXX if eventually have Logics using RNA 100%, we could use the actuator data-block isntead of its name */
- prop = RNA_def_property(srna, "actuator", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Actuator", "Actuator name, actuator active state modifications will be detected");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_delay_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "DelaySensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Delay Sensor", "Sensor to send delayed events");
- RNA_def_struct_sdna_from(srna, "bDelaySensor", "data");
-
- prop = RNA_def_property(srna, "delay", PROP_INT, PROP_NONE);
- RNA_def_property_ui_text(prop, "Delay",
- "Delay in number of logic tics before the positive trigger (default 60 per second)");
- RNA_def_property_range(prop, 0, 5000);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "duration", PROP_INT, PROP_NONE);
- RNA_def_property_ui_text(prop, "Duration",
- "If >0, delay in number of logic tics before the negative trigger following "
- "the positive trigger");
- RNA_def_property_range(prop, 0, 5000);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_repeat", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_DELAY_REPEAT);
- RNA_def_property_ui_text(prop, "Repeat",
- "Toggle repeat option (if selected, the sensor restarts after Delay+Duration "
- "logic tics)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_collision_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "CollisionSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Collision Sensor",
- "Sensor to detect objects colliding with the current object, with more settings than "
- "the Touch sensor");
- RNA_def_struct_sdna_from(srna, "bCollisionSensor", "data");
-
- prop = RNA_def_property(srna, "use_pulse", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_COLLISION_PULSE);
- RNA_def_property_ui_text(prop, "Pulse", "Change to the set of colliding objects generates pulse");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_material", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_COLLISION_MATERIAL);
- RNA_def_property_ui_text(prop, "M/P", "Toggle collision on material or property");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /*XXX to make a setFunction to create a lookup with all materials in Blend File (not only this object mat.) */
- prop = RNA_def_property(srna, "material", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "materialName");
- RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
-#if 0
- /* XXX either use a data-block look up to store the string name (material)
- * or to do a doversion and use a material pointer. */
- prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Material");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_pointer_sdna(prop, NULL, "ma");
- RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
-#endif
-}
-
-static void rna_def_radar_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
- static const EnumPropertyItem axis_items[] = {
- {SENS_RADAR_X_AXIS, "XAXIS", 0, "+X axis", ""},
- {SENS_RADAR_Y_AXIS, "YAXIS", 0, "+Y axis", ""},
- {SENS_RADAR_Z_AXIS, "ZAXIS", 0, "+Z axis", ""},
- {SENS_RADAR_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", ""},
- {SENS_RADAR_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""},
- {SENS_RADAR_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "RadarSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Radar Sensor",
- "Sensor to detect objects in a cone shaped radar emanating from the current object");
- RNA_def_struct_sdna_from(srna, "bRadarSensor", "data");
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, axis_items);
- RNA_def_property_ui_text(prop, "Axis", "Along which axis the radar cone is cast");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_range(prop, 0.0, DEG2RADF(179.9f));
- RNA_def_property_ui_text(prop, "Angle", "Opening angle of the radar cone");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "range");
- RNA_def_property_range(prop, 0.0, 10000.0);
- RNA_def_property_ui_text(prop, "Distance", "Depth of the radar cone");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_random_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "RandomSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Random Sensor", "Sensor to send random events");
- RNA_def_struct_sdna_from(srna, "bRandomSensor", "data");
-
- prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 0, 1000);
- RNA_def_property_ui_text(prop, "Seed", "Initial seed of the generator (choose 0 for not random)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_ray_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
- static const EnumPropertyItem axis_items[] = {
- {SENS_RAY_X_AXIS, "XAXIS", 0, "+X axis", ""},
- {SENS_RAY_Y_AXIS, "YAXIS", 0, "+Y axis", ""},
- {SENS_RAY_Z_AXIS, "ZAXIS", 0, "+Z axis", ""},
- {SENS_RAY_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", ""},
- {SENS_RAY_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""},
- {SENS_RAY_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem prop_ray_type_items[] = {
- {SENS_COLLISION_PROPERTY, "PROPERTY", ICON_LOGIC, "Property", "Use a property for ray intersections"},
- {SENS_COLLISION_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "Material", "Use a material for ray intersections"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "RaySensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Ray Sensor",
- "Sensor to detect intersections with a ray emanating from the current object");
- RNA_def_struct_sdna_from(srna, "bRaySensor", "data");
-
- prop = RNA_def_property(srna, "ray_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, prop_ray_type_items);
- RNA_def_property_ui_text(prop, "Ray Type", "Toggle collision on material or property");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "propname");
- RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "material", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "matname");
- RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
-#if 0
- /* XXX either use a data-block look up to store the string name (material)
- * or to do a doversion and use a material pointer. */
- prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Material");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_pointer_sdna(prop, NULL, "ma");
- RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material (blank = all objects)");
-#endif
-
- prop = RNA_def_property(srna, "use_x_ray", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_RAY_XRAY);
- RNA_def_property_ui_text(prop, "X-Ray Mode",
- "Toggle X-Ray option (see through objects that don't have the property)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "range", PROP_FLOAT, PROP_NONE);
- RNA_def_property_range(prop, 0.01, 10000.0);
- RNA_def_property_ui_text(prop, "Range", "Sense objects no farther than this distance");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "axisflag");
- RNA_def_property_enum_items(prop, axis_items);
- RNA_def_property_ui_text(prop, "Axis", "Along which axis the ray is cast");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_message_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "MessageSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Message Sensor", "Sensor to detect incoming messages");
- RNA_def_struct_sdna_from(srna, "bMessageSensor", "data");
-
- prop = RNA_def_property(srna, "subject", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(prop, "Subject",
- "Optional subject filter: only accept messages with this subject, "
- "or empty to accept all");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-static void rna_def_joystick_sensor(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static const EnumPropertyItem event_type_joystick_items[] = {
- {SENS_JOY_BUTTON, "BUTTON", 0, "Button", ""},
- {SENS_JOY_AXIS, "AXIS", 0, "Axis", ""},
- {SENS_JOY_HAT, "HAT", 0, "Hat", ""},
- {SENS_JOY_AXIS_SINGLE, "AXIS_SINGLE", 0, "Single Axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem axis_direction_items[] = {
- {SENS_JOY_X_AXIS, "RIGHTAXIS", 0, "Right Axis", ""},
- {SENS_JOY_Y_AXIS, "UPAXIS", 0, "Up Axis", ""},
- {SENS_JOY_NEG_X_AXIS, "LEFTAXIS", 0, "Left Axis", ""},
- {SENS_JOY_NEG_Y_AXIS, "DOWNAXIS", 0, "Down Axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static const EnumPropertyItem hat_direction_items[] = {
- {SENS_JOY_HAT_UP, "UP", 0, "Up", ""},
- {SENS_JOY_HAT_DOWN, "DOWN", 0, "Down", ""},
- {SENS_JOY_HAT_LEFT, "LEFT", 0, "Left", ""},
- {SENS_JOY_HAT_RIGHT, "RIGHT", 0, "Right", ""},
-
- {SENS_JOY_HAT_UP_RIGHT, "UPRIGHT", 0, "Up/Right", ""},
- {SENS_JOY_HAT_DOWN_LEFT, "DOWNLEFT", 0, "Down/Left", ""},
- {SENS_JOY_HAT_UP_LEFT, "UPLEFT", 0, "Up/Left", ""},
- {SENS_JOY_HAT_DOWN_RIGHT, "DOWNRIGHT", 0, "Down/Right", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "JoystickSensor", "Sensor");
- RNA_def_struct_ui_text(srna, "Joystick Sensor", "Sensor to detect joystick events");
- RNA_def_struct_sdna_from(srna, "bJoystickSensor", "data");
-
- prop = RNA_def_property(srna, "joystick_index", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "joyindex");
- RNA_def_property_ui_text(prop, "Index", "Which joystick to use");
- RNA_def_property_range(prop, 0, SENS_JOY_MAXINDEX - 1);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "event_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "type");
- RNA_def_property_enum_items(prop, event_type_joystick_items);
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
- RNA_def_property_ui_text(prop, "Event Type", "The type of event this joystick sensor is triggered on");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "use_all_events", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_JOY_ANY_EVENT);
- RNA_def_property_ui_text(prop, "All Events",
- "Triggered by all events on this joystick's current type (axis/button/hat)");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Button */
- prop = RNA_def_property(srna, "button_number", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "button");
- RNA_def_property_ui_text(prop, "Button Number", "Which button to use");
- RNA_def_property_range(prop, 0, 18);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Axis */
- prop = RNA_def_property(srna, "axis_number", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "axis");
- RNA_def_property_ui_text(prop, "Axis Number", "Which axis pair to use, 1 is usually the main direction input");
- RNA_def_property_range(prop, 1, 8);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "axis_threshold", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "precision");
- RNA_def_property_ui_text(prop, "Axis Threshold", "Precision of the axis");
- RNA_def_property_range(prop, 0, 32768);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "axis_direction", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "axisf");
- RNA_def_property_enum_items(prop, axis_direction_items);
- RNA_def_property_ui_text(prop, "Axis Direction", "The direction of the axis");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Single Axis */
- prop = RNA_def_property(srna, "single_axis_number", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "axis_single");
- RNA_def_property_ui_text(prop, "Axis Number", "Single axis (vertical/horizontal/other) to detect");
- RNA_def_property_range(prop, 1, 16);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /* Hat */
- prop = RNA_def_property(srna, "hat_number", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "hat");
- RNA_def_property_ui_text(prop, "Hat Number", "Which hat to use");
- RNA_def_property_range(prop, 1, 2);
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- prop = RNA_def_property(srna, "hat_direction", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "hatf");
- RNA_def_property_enum_items(prop, hat_direction_items);
- RNA_def_property_ui_text(prop, "Hat Direction", "Hat direction");
- RNA_def_property_update(prop, NC_LOGIC, NULL);
-}
-
-void RNA_def_sensor(BlenderRNA *brna)
-{
- rna_def_sensor(brna);
-
- rna_def_always_sensor(brna);
- rna_def_near_sensor(brna);
- rna_def_mouse_sensor(brna);
- rna_def_keyboard_sensor(brna);
- rna_def_property_sensor(brna);
- rna_def_armature_sensor(brna);
- rna_def_actuator_sensor(brna);
- rna_def_delay_sensor(brna);
- rna_def_collision_sensor(brna);
- rna_def_radar_sensor(brna);
- rna_def_random_sensor(brna);
- rna_def_ray_sensor(brna);
- rna_def_message_sensor(brna);
- rna_def_joystick_sensor(brna);
-}
-
-#endif
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index 4ccd1305d76..433ca729c65 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -1516,6 +1516,7 @@ static void rna_def_sequence(BlenderRNA *brna)
prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_LOCK);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
RNA_def_property_ui_text(prop, "Lock", "Lock strip so that it cannot be transformed");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
@@ -1595,6 +1596,7 @@ static void rna_def_sequence(BlenderRNA *brna)
prop = RNA_def_property(srna, "channel", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "machine");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 1, MAXSEQ);
RNA_def_property_ui_text(prop, "Channel", "Y position of the sequence strip");
RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_channel_set", NULL); /* overlap test */
diff --git a/source/blender/makesrna/intern/rna_shader_fx.c b/source/blender/makesrna/intern/rna_shader_fx.c
index ef045be82ca..5c6e2addfc2 100644
--- a/source/blender/makesrna/intern/rna_shader_fx.c
+++ b/source/blender/makesrna/intern/rna_shader_fx.c
@@ -160,7 +160,7 @@ static char *rna_ShaderFx_path(PointerRNA *ptr)
static void rna_ShaderFx_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ptr->id.data);
}
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index b601843e388..7d03fe5f279 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -64,7 +64,7 @@
static void rna_Smoke_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
}
static void rna_Smoke_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
@@ -78,7 +78,7 @@ static void rna_Smoke_resetCache(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin
SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
if (settings->smd && settings->smd->domain)
settings->point_cache[0]->flag |= PTCACHE_OUTDATED;
- DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
}
static void rna_Smoke_cachetype_set(struct PointerRNA *ptr, int value)
@@ -589,21 +589,21 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
"How much heat affects smoke motion (higher value results in faster rising smoke)");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
- prop = RNA_def_property(srna, "collision_group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "collision_collection", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "coll_group");
RNA_def_property_struct_type(prop, "Collection");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Collision Collection", "Limit collisions to this collection");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset_dependency");
- prop = RNA_def_property(srna, "fluid_group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "fluid_collection", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "fluid_group");
RNA_def_property_struct_type(prop, "Collection");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Fluid Collection", "Limit fluid objects to this collection");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset_dependency");
- prop = RNA_def_property(srna, "effector_group", PROP_POINTER, PROP_NONE);
+ prop = RNA_def_property(srna, "effector_collection", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "eff_group");
RNA_def_property_struct_type(prop, "Collection");
RNA_def_property_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 774fbe1f7ba..dad521b56cf 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -167,14 +167,42 @@ const EnumPropertyItem rna_enum_space_action_mode_items[] = {
#undef SACT_ITEM_MASK
#undef SACT_ITEM_CACHEFILE
+
+#define SI_ITEM_VIEW(name, icon) \
+ {SI_MODE_VIEW, "VIEW", icon, name, "View the image"}
+#define SI_ITEM_UV \
+ {SI_MODE_UV, "UV", ICON_GROUP_UVS, "UV Editor", "UV edit in mesh editmode"}
+#define SI_ITEM_PAINT \
+ {SI_MODE_PAINT, "PAINT", ICON_TPAINT_HLT, "Paint", "2D image painting mode"}
+#define SI_ITEM_MASK \
+ {SI_MODE_MASK, "MASK", ICON_MOD_MASK, "Mask", "Mask editing"}
+
+const EnumPropertyItem rna_enum_space_image_mode_all_items[] = {
+ SI_ITEM_VIEW("View", ICON_FILE_IMAGE),
+ SI_ITEM_UV,
+ SI_ITEM_PAINT,
+ SI_ITEM_MASK,
+ {0, NULL, 0, NULL, NULL}
+};
+
+static const EnumPropertyItem rna_enum_space_image_mode_ui_items[] = {
+ SI_ITEM_VIEW("View", ICON_FILE_IMAGE),
+ SI_ITEM_PAINT,
+ SI_ITEM_MASK,
+ {0, NULL, 0, NULL, NULL}
+};
+
const EnumPropertyItem rna_enum_space_image_mode_items[] = {
- {SI_MODE_VIEW, "VIEW", ICON_FILE_IMAGE, "View", "View the image"},
- {SI_MODE_UV, "UV", ICON_GROUP_UVS, "UV Edit", "UV edit in mesh editmode"},
- {SI_MODE_PAINT, "PAINT", ICON_TPAINT_HLT, "Paint", "2D image painting mode"},
- {SI_MODE_MASK, "MASK", ICON_MOD_MASK, "Mask", "Mask editing"},
+ SI_ITEM_VIEW("Image Editor", ICON_IMAGE),
+ SI_ITEM_UV,
{0, NULL, 0, NULL, NULL}
};
+#undef SI_ITEM_VIEW
+#undef SI_ITEM_UV
+#undef SI_ITEM_PAINT
+#undef SI_ITEM_MASK
+
#define V3D_S3D_CAMERA_LEFT {STEREO_LEFT_ID, "LEFT", ICON_RESTRICT_RENDER_OFF, "Left", ""},
#define V3D_S3D_CAMERA_RIGHT {STEREO_RIGHT_ID, "RIGHT", ICON_RESTRICT_RENDER_OFF, "Right", ""},
#define V3D_S3D_CAMERA_S3D {STEREO_3D_ID, "S3D", ICON_CAMERA_STEREO, "3D", ""},
@@ -484,7 +512,7 @@ static void rna_GPencil_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UN
/* need set all caches as dirty to recalculate onion skinning */
for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->type == OB_GPENCIL) {
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
@@ -531,47 +559,6 @@ static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, bool val
}
}
-
-static View3DCursor *rna_View3D_Cursor_get_from_scene_or_localview(PointerRNA *ptr)
-{
- View3D *v3d = (View3D *)(ptr->data);
- bScreen *screen = ptr->id.data;
- Scene *scene = ED_screen_scene_find(screen, G_MAIN->wm.first);
- return ED_view3d_cursor3d_get(scene, v3d);
-}
-
-static void rna_View3D_Cursor_location_get(PointerRNA *ptr, float *values)
-{
- const View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr);
- copy_v3_v3(values, cursor->location);
-}
-
-static void rna_View3D_Cursor_location_set(PointerRNA *ptr, const float *values)
-{
- View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr);
- copy_v3_v3(cursor->location, values);
-}
-
-static void rna_View3D_Cursor_rotation_get(PointerRNA *ptr, float *values)
-{
- const View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr);
- copy_qt_qt(values, cursor->rotation);
-}
-
-static void rna_View3D_Cursor_rotation_set(PointerRNA *ptr, const float *values)
-{
- View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr);
- copy_qt_qt(cursor->rotation, values);
-}
-
-static void rna_View3D_Cursor_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
-{
- View3D *v3d = ptr->data;
- if (v3d->localvd == NULL) {
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
- }
-}
-
static float rna_View3DOverlay_GridScaleUnit_get(PointerRNA *ptr)
{
View3D *v3d = (View3D *)(ptr->data);
@@ -692,7 +679,7 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), Poi
* the meshes itself.
* This hack just tag BKE_MESH_BATCH_DIRTY_SHADING for every mesh that
* have a material. (see T55059) */
- DEG_id_tag_update(&ma->id, DEG_TAG_SHADING_UPDATE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_SHADING);
}
bScreen *screen = ptr->id.data;
@@ -726,13 +713,13 @@ static int rna_3DViewShading_type_get(PointerRNA *ptr)
{
/* Available shading types depend on render engine. */
Scene *scene = rna_3DViewShading_scene(ptr);
- RenderEngineType *type = RE_engines_find(scene->r.engine);
+ RenderEngineType *type = (scene) ? RE_engines_find(scene->r.engine) : NULL;
View3DShading *shading = (View3DShading *)ptr->data;
- if (BKE_scene_uses_blender_eevee(scene)) {
+ if (scene == NULL || BKE_scene_uses_blender_eevee(scene)) {
return shading->type;
}
- else if (BKE_scene_uses_blender_opengl(scene)) {
+ else if (BKE_scene_uses_blender_workbench(scene)) {
return (shading->type == OB_MATERIAL) ? OB_RENDER : shading->type;
}
else {
@@ -759,7 +746,7 @@ static const EnumPropertyItem *rna_3DViewShading_type_itemf(
PropertyRNA *UNUSED(prop), bool *r_free)
{
Scene *scene = rna_3DViewShading_scene(ptr);
- RenderEngineType *type = RE_engines_find(scene->r.engine);
+ RenderEngineType *type = (scene) ? RE_engines_find(scene->r.engine) : NULL;
EnumPropertyItem *item = NULL;
int totitem = 0;
@@ -767,11 +754,11 @@ static const EnumPropertyItem *rna_3DViewShading_type_itemf(
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_WIRE);
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_SOLID);
- if (BKE_scene_uses_blender_eevee(scene)) {
+ if (scene == NULL || BKE_scene_uses_blender_eevee(scene)) {
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_MATERIAL);
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_RENDER);
}
- else if (BKE_scene_uses_blender_opengl(scene)) {
+ else if (BKE_scene_uses_blender_workbench(scene)) {
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_RENDER);
}
else {
@@ -795,9 +782,12 @@ static PointerRNA rna_View3DShading_selected_studio_light_get(PointerRNA *ptr)
if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) {
sl = BKE_studiolight_find(shading->matcap, STUDIOLIGHT_FLAG_ALL);
}
- else {
+ else if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_STUDIO) {
sl = BKE_studiolight_find(shading->studio_light, STUDIOLIGHT_FLAG_ALL);
}
+ else {
+ sl = BKE_studiolight_find(shading->lookdev_light, STUDIOLIGHT_FLAG_ALL);
+ }
return rna_pointer_inherit_refine(ptr, &RNA_StudioLight, sl);
}
@@ -846,13 +836,14 @@ static int rna_View3DShading_studio_light_get(PointerRNA *ptr)
View3DShading *shading = (View3DShading *)ptr->data;
char *dna_storage = shading->studio_light;
- int flag = STUDIOLIGHT_ORIENTATIONS_SOLID;
+ int flag = STUDIOLIGHT_TYPE_STUDIO;
if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) {
- flag = STUDIOLIGHT_ORIENTATION_VIEWNORMAL;
+ flag = STUDIOLIGHT_TYPE_MATCAP;
dna_storage = shading->matcap;
}
else if (shading->type == OB_MATERIAL) {
- flag = STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE;
+ flag = STUDIOLIGHT_TYPE_WORLD;
+ dna_storage = shading->lookdev_light;
}
StudioLight *sl = BKE_studiolight_find(dna_storage, flag);
if (sl) {
@@ -869,13 +860,14 @@ static void rna_View3DShading_studio_light_set(PointerRNA *ptr, int value)
View3DShading *shading = (View3DShading *)ptr->data;
char *dna_storage = shading->studio_light;
- int flag = STUDIOLIGHT_ORIENTATIONS_SOLID;
+ int flag = STUDIOLIGHT_TYPE_STUDIO;
if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) {
- flag = STUDIOLIGHT_ORIENTATION_VIEWNORMAL;
+ flag = STUDIOLIGHT_TYPE_MATCAP;
dna_storage = shading->matcap;
}
else if (shading->type == OB_MATERIAL) {
- flag = STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE;
+ flag = STUDIOLIGHT_TYPE_WORLD;
+ dna_storage = shading->lookdev_light;
}
StudioLight *sl = BKE_studiolight_findindex(value, flag);
if (sl) {
@@ -892,7 +884,7 @@ static const EnumPropertyItem *rna_View3DShading_studio_light_itemf(
int totitem = 0;
if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) {
- const int flags = (STUDIOLIGHT_EXTERNAL_FILE | STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
+ const int flags = (STUDIOLIGHT_EXTERNAL_FILE | STUDIOLIGHT_TYPE_MATCAP);
LISTBASE_FOREACH(StudioLight *, sl, BKE_studiolight_listbase()) {
int icon_id = (shading->flag & V3D_SHADING_MATCAP_FLIP_X) ? sl->icon_id_matcap_flipped: sl->icon_id_matcap;
@@ -917,12 +909,11 @@ static const EnumPropertyItem *rna_View3DShading_studio_light_itemf(
switch (shading->type) {
case OB_SOLID:
case OB_TEXTURE:
- show_studiolight = (
- (sl->flag & (STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_CAMERA)) != 0);
+ show_studiolight = ((sl->flag & STUDIOLIGHT_TYPE_STUDIO) != 0);
break;
case OB_MATERIAL:
- show_studiolight = ((sl->flag & STUDIOLIGHT_ORIENTATION_WORLD) != 0);
+ show_studiolight = ((sl->flag & STUDIOLIGHT_TYPE_WORLD) != 0);
icon_id = sl->icon_id_radiance;
break;
}
@@ -1543,7 +1534,7 @@ static void rna_SpaceDopeSheetEditor_action_update(bContext *C, PointerRNA *ptr)
}
/* force depsgraph flush too */
- DEG_id_tag_update(&obact->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&obact->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
/* Update relations as well, so new time source dependency is added. */
DEG_relations_tag_update(bmain);
}
@@ -1602,7 +1593,7 @@ static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr)
}
/* recalculate extents of channel list */
- saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
/* store current mode as "old mode", so that returning from other editors doesn't always reset to "Action Editor" */
if (saction->mode != SACTCONT_TIMELINE) {
@@ -1632,7 +1623,7 @@ static void rna_SpaceGraphEditor_display_mode_update(bContext *C, PointerRNA *pt
static bool rna_SpaceGraphEditor_has_ghost_curves_get(PointerRNA *ptr)
{
SpaceIpo *sipo = (SpaceIpo *)(ptr->data);
- return (BLI_listbase_is_empty(&sipo->ghostCurves) == false);
+ return (BLI_listbase_is_empty(&sipo->runtime.ghost_curves) == false);
}
static void rna_SpaceConsole_rect_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -2437,6 +2428,13 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
};
static const float default_background_color[] = {0.05f, 0.05f, 0.05f};
+ static const EnumPropertyItem cavity_type_items[] = {
+ {V3D_SHADING_CAVITY_SSAO, "WORLD", 0, "World", "Cavity shading computed in world space, useful for larger-scale occlusion"},
+ {V3D_SHADING_CAVITY_CURVATURE, "SCREEN", 0, "Screen", "Curvature-based shading, useful for making fine details more visible"},
+ {V3D_SHADING_CAVITY_BOTH, "BOTH", 0, "Both", "Use both effects simultaneously"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
/* Note these settings are used for both 3D viewport and the OpenGL render
* engine in the scene, so can't assume to always be part of a screen. */
@@ -2471,16 +2469,43 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Studiolight", "Studio lighting setup");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "use_world_space_lighting", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_WORLD_ORIENTATION);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "World Space Lighting", "Make the lighting fixed and not follow the camera");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "show_cavity", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_CAVITY);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Cavity", "Show Cavity");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "cavity_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, cavity_type_items);
+ RNA_def_property_ui_text(prop, "Cavity Type", "Way to draw the cavity shading");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "curvature_ridge_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "curvature_ridge_factor");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_ui_text(prop, "Curvature Ridge", "Factor for the curvature ridges");
+ RNA_def_property_range(prop, 0.0f, 2.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "curvature_valley_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "curvature_valley_factor");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_ui_text(prop, "Curvature Valley", "Factor for the curvature valleys");
+ RNA_def_property_range(prop, 0.0f, 2.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "cavity_ridge_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "cavity_ridge_factor");
RNA_def_property_float_default(prop, 1.0f);
- RNA_def_property_ui_text(prop, "Ridge", "Factor for the ridges");
+ RNA_def_property_ui_text(prop, "Cavity Ridge", "Factor for the cavity ridges");
RNA_def_property_range(prop, 0.0f, 250.0f);
RNA_def_property_ui_range(prop, 0.00f, 2.5f, 1, 3);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -2489,7 +2514,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "cavity_valley_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "cavity_valley_factor");
RNA_def_property_float_default(prop, 1.0);
- RNA_def_property_ui_text(prop, "Valley", "Factor for the valleys");
+ RNA_def_property_ui_text(prop, "Cavity Valley", "Factor for the cavity valleys");
RNA_def_property_range(prop, 0.0f, 250.0f);
RNA_def_property_ui_range(prop, 0.00f, 2.5f, 1, 3);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -2724,7 +2749,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_bones", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_BONES);
- RNA_def_property_ui_text(prop, "Show Bones", "Display bones");
+ RNA_def_property_ui_text(prop, "Show Bones", "Display bones (disable to show motion paths only)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_face_orientation", PROP_BOOLEAN, PROP_NONE);
@@ -3108,21 +3133,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Local View",
"Display an isolated sub-set of objects, apart from the scene visibility");
- prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ_LENGTH);
- RNA_def_property_array(prop, 3);
- RNA_def_property_float_funcs(prop, "rna_View3D_Cursor_location_get", "rna_View3D_Cursor_location_set", NULL);
- RNA_def_property_ui_text(prop, "3D Cursor Location",
- "3D cursor location for this view (dependent on local view setting)");
- RNA_def_property_ui_range(prop, -10000.0, 10000.0, 1, RNA_TRANSLATION_PREC_DEFAULT);
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_View3D_Cursor_update");
-
- prop = RNA_def_property(srna, "cursor_rotation", PROP_FLOAT, PROP_QUATERNION);
- RNA_def_property_array(prop, 4);
- RNA_def_property_float_funcs(prop, "rna_View3D_Cursor_rotation_get", "rna_View3D_Cursor_rotation_set", NULL);
- RNA_def_property_ui_text(prop, "3D Cursor Rotation",
- "Rotation in quaternions (keep normalized)");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_View3D_Cursor_update");
-
prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_UNIT_CAMERA);
RNA_def_property_float_sdna(prop, NULL, "lens");
RNA_def_property_ui_text(prop, "Lens", "Viewport lens angle");
@@ -3557,10 +3567,16 @@ static void rna_def_space_image(BlenderRNA *brna)
RNA_def_property_pointer_funcs(prop, "rna_SpaceImageEditor_uvedit_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "UV Editor", "UV editor settings");
- /* 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, rna_enum_space_image_mode_items);
+ RNA_def_property_enum_items(prop, rna_enum_space_image_mode_all_items);
+ RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_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_image_mode_ui_items);
RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_mode_update");
@@ -4358,7 +4374,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
{FILTER_ID_CF, "CACHEFILE", ICON_FILE, "Cache Files", "Show/hide Cache File data-blocks"},
{FILTER_ID_CU, "CURVE", ICON_CURVE_DATA, "Curves", "Show/hide Curve data-blocks"},
{FILTER_ID_GD, "GREASE_PENCIL", ICON_GREASEPENCIL, "Grease Pencil", "Show/hide Grease pencil data-blocks"},
- {FILTER_ID_GR, "GROUP", ICON_GROUP, "Groups", "Show/hide Group data-blocks"},
+ {FILTER_ID_GR, "GROUP", ICON_GROUP, "Collections", "Show/hide Collection data-blocks"},
{FILTER_ID_IM, "IMAGE", ICON_IMAGE_DATA, "Images", "Show/hide Image data-blocks"},
{FILTER_ID_LA, "LIGHT", ICON_LIGHT_DATA, "Lights", "Show/hide Light data-blocks"},
{FILTER_ID_LS, "LINESTYLE", ICON_LINE_DATA,
@@ -4393,7 +4409,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
{FILTER_ID_AC,
"ANIMATION", ICON_ANIM_DATA, "Animations", "Show/hide animation data"},
{FILTER_ID_OB | FILTER_ID_GR,
- "OBJECT", ICON_GROUP, "Objects & Groups", "Show/hide objects and groups"},
+ "OBJECT", ICON_GROUP, "Objects & Collections", "Show/hide objects and groups"},
{FILTER_ID_AR | FILTER_ID_CU | FILTER_ID_LT | FILTER_ID_MB | FILTER_ID_ME,
"GEOMETRY", ICON_MESH_DATA, "Geometry", "Show/hide meshes, curves, lattice, armatures and metaballs data"},
{FILTER_ID_LS | FILTER_ID_MA | FILTER_ID_NT | FILTER_ID_TE,
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index e9ef4bf7a8c..6a305ce23bb 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -163,6 +163,7 @@ static void rna_Texture_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *pt
Tex *tex = ptr->id.data;
DEG_id_tag_update(&tex->id, 0);
+ DEG_id_tag_update(&tex->id, ID_RECALC_EDITORS);
WM_main_add_notifier(NC_TEXTURE, tex);
WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, NULL);
}
@@ -190,6 +191,7 @@ static void rna_Texture_nodes_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
Tex *tex = ptr->id.data;
DEG_id_tag_update(&tex->id, 0);
+ DEG_id_tag_update(&tex->id, ID_RECALC_EDITORS);
WM_main_add_notifier(NC_TEXTURE | ND_NODES, tex);
}
@@ -233,12 +235,12 @@ void rna_TextureSlot_update(bContext *C, PointerRNA *ptr)
case ID_PA:
{
MTex *mtex = ptr->data;
- int recalc = OB_RECALC_DATA;
+ int recalc = ID_RECALC_GEOMETRY;
if (mtex->mapto & PAMAP_INIT)
- recalc |= PSYS_RECALC_RESET;
+ recalc |= ID_RECALC_PSYS_RESET;
if (mtex->mapto & PAMAP_CHILD)
- recalc |= PSYS_RECALC_CHILD;
+ recalc |= ID_RECALC_PSYS_CHILD;
DEG_id_tag_update(id, recalc);
WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 03f86eba601..84ce946ce19 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -87,10 +87,10 @@ 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", ""},
+static const EnumPropertyItem rna_enum_studio_light_type_items[] = {
+ {STUDIOLIGHT_TYPE_STUDIO, "STUDIO", 0, "Studio", ""},
+ {STUDIOLIGHT_TYPE_WORLD, "WORLD", 0, "World", ""},
+ {STUDIOLIGHT_TYPE_MATCAP, "MATCAP", 0, "MatCap", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -244,6 +244,11 @@ static void rna_userdef_ndof_deadzone_update(Main *UNUSED(bmain), Scene *UNUSED(
}
#endif
+static void rna_userdef_keyconfig_reload_update(bContext *C, Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+{
+ WM_keyconfig_reload(C);
+}
+
static void rna_userdef_timecode_style_set(PointerRNA *ptr, int value)
{
UserDef *userdef = (UserDef *)ptr->data;
@@ -319,7 +324,7 @@ static void rna_UserDef_weight_color_update(Main *bmain, Scene *scene, PointerRN
for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->mode & OB_MODE_WEIGHT_PAINT)
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
rna_userdef_update(bmain, scene, ptr);
@@ -329,7 +334,11 @@ static void rna_UserDef_viewport_lights_update(Main *bmain, Scene *scene, Pointe
{
/* if all lights are off gpu_draw resets them all, [#27627]
* so disallow them all to be disabled */
- if (U.light[0].flag == 0 && U.light[1].flag == 0 && U.light[2].flag == 0) {
+ if (U.light_param[0].flag == 0 &&
+ U.light_param[1].flag == 0 &&
+ U.light_param[2].flag == 0 &&
+ U.light_param[3].flag == 0)
+ {
SolidLight *light = ptr->data;
light->flag |= 1;
}
@@ -453,7 +462,7 @@ static void rna_userdef_opensubdiv_update(Main *bmain, Scene *UNUSED(scene), Poi
object;
object = object->id.next)
{
- DEG_id_tag_update(&object->id, OB_RECALC_OB);
+ DEG_id_tag_update(&object->id, ID_RECALC_TRANSFORM);
}
}
@@ -628,9 +637,15 @@ static void rna_StudioLights_remove(UserDef *UNUSED(userdef), StudioLight *studi
BKE_studiolight_remove(studio_light);
}
-static StudioLight *rna_StudioLights_new(UserDef *UNUSED(userdef), const char *path, int orientation)
+static StudioLight *rna_StudioLights_load(UserDef *UNUSED(userdef), const char *path, int type)
+{
+ return BKE_studiolight_load(path, type);
+}
+
+/* TODO: Make it accept arguments. */
+static StudioLight *rna_StudioLights_new(UserDef *userdef, const char *name)
{
- return BKE_studiolight_new(path, orientation);
+ return BKE_studiolight_create(name, userdef->light_param, userdef->light_ambient);
}
/* StudioLight.name */
@@ -715,9 +730,9 @@ static bool rna_UserDef_studiolight_is_user_defined_get(PointerRNA *ptr)
return (sl->flag & STUDIOLIGHT_USER_DEFINED) != 0;
}
-/* StudioLight.orientation */
+/* StudioLight.type */
-static int rna_UserDef_studiolight_orientation_get(PointerRNA *ptr)
+static int rna_UserDef_studiolight_type_get(PointerRNA *ptr)
{
StudioLight *sl = (StudioLight *)ptr->data;
return sl->flag & STUDIOLIGHT_FLAG_ORIENTATIONS;
@@ -733,6 +748,28 @@ static void rna_UserDef_studiolight_spherical_harmonics_coefficients_get(Pointer
}
}
+/* StudioLight.solid_lights */
+
+static void rna_UserDef_studiolight_solid_lights_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ rna_iterator_array_begin(iter, sl->light, sizeof(*sl->light), ARRAY_SIZE(sl->light), 0, NULL);
+}
+
+static int rna_UserDef_studiolight_solid_lights_length(PointerRNA *ptr)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ return ARRAY_SIZE(sl->light);
+}
+
+/* StudioLight.light_ambient */
+
+static void rna_UserDef_studiolight_light_ambient_get(PointerRNA *ptr, float *values)
+{
+ StudioLight *sl = (StudioLight *)ptr->data;
+ copy_v3_v3(values, sl->light_ambient);
+}
+
#else
/* TODO(sergey): This technically belongs to blenlib, but we don't link
@@ -960,6 +997,16 @@ static void rna_def_userdef_theme_ui_wcol_state(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Overridden Selected", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
+ prop = RNA_def_property(srna, "inner_changed", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Changed", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+ prop = RNA_def_property(srna, "inner_changed_sel", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Changed Selected", "");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
+
prop = RNA_def_property(srna, "blend", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_ui_text(prop, "Blend", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
@@ -3315,11 +3362,18 @@ static void rna_def_userdef_studiolights(BlenderRNA *brna)
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");
+ func = RNA_def_function(srna, "load", "rna_StudioLights_load");
+ RNA_def_function_ui_description(func, "Load studiolight from file");
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");
+ parm = RNA_def_enum(func, "type", rna_enum_studio_light_type_items, STUDIOLIGHT_TYPE_WORLD, "Type", "The type 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, "new", "rna_StudioLights_new");
+ RNA_def_function_ui_description(func, "Create studiolight from default lighting");
+ parm = RNA_def_string(func, "path", NULL, 0, "Path", "Path to the file that will contain the lighing info (without extension)");
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);
@@ -3353,11 +3407,11 @@ static void rna_def_userdef_studiolight(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "User Defined", "");
- 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", NULL, NULL);
+ prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, rna_enum_studio_light_type_items);
+ RNA_def_property_enum_funcs(prop, "rna_UserDef_studiolight_type_get", NULL, NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Orientation", "");
+ RNA_def_property_ui_text(prop, "Type", "");
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_name_get", "rna_UserDef_studiolight_name_length", NULL);
@@ -3370,6 +3424,21 @@ static void rna_def_userdef_studiolight(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Path", "");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ prop = RNA_def_property(srna, "solid_lights", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "light_param", "");
+ RNA_def_property_struct_type(prop, "UserSolidLight");
+ RNA_def_property_collection_funcs(prop, "rna_UserDef_studiolight_solid_lights_begin", "rna_iterator_array_next",
+ "rna_iterator_array_end", "rna_iterator_array_get",
+ "rna_UserDef_studiolight_solid_lights_length", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "Solid Lights", "Lights user to display objects in solid draw mode");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ prop = RNA_def_property(srna, "light_ambient", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_float_funcs(prop, "rna_UserDef_studiolight_light_ambient_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Ambient Color", "Color of the ambient light that uniformly lit the scene");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
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");
@@ -3466,30 +3535,47 @@ static void rna_def_userdef_solidlight(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
- static float default_dir[3] = {0.f, 1.f, 0.f};
+ static float default_dir[3] = {0.f, 0.f, 1.f};
+ static float default_col[3] = {0.8f, 0.8f, 0.8f};
srna = RNA_def_struct(brna, "UserSolidLight", NULL);
RNA_def_struct_sdna(srna, "SolidLight");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
- RNA_def_struct_ui_text(srna, "Solid Light", "Light used for OpenGL lighting in solid draw mode");
+ RNA_def_struct_ui_text(srna, "Solid Light", "Light used for Studio lighting in solid draw mode");
prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", 1);
- RNA_def_property_ui_text(prop, "Enabled", "Enable this OpenGL light in solid draw mode");
+ RNA_def_property_boolean_default(prop, true);
+ RNA_def_property_ui_text(prop, "Enabled", "Enable this light in solid draw mode");
+ RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update");
+
+ prop = RNA_def_property(srna, "smooth", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "smooth");
+ RNA_def_property_float_default(prop, 0.5f);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Smooth", "Smooth the lighting from this light");
RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update");
prop = RNA_def_property(srna, "direction", PROP_FLOAT, PROP_DIRECTION);
RNA_def_property_float_sdna(prop, NULL, "vec");
RNA_def_property_array(prop, 3);
RNA_def_property_float_array_default(prop, default_dir);
- RNA_def_property_ui_text(prop, "Direction", "Direction that the OpenGL light is shining");
+ RNA_def_property_ui_text(prop, "Direction", "Direction that the light is shining");
RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update");
prop = RNA_def_property(srna, "specular_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "spec");
RNA_def_property_array(prop, 3);
+ RNA_def_property_float_array_default(prop, default_col);
RNA_def_property_ui_text(prop, "Specular Color", "Color of the light's specular highlight");
RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update");
+
+ prop = RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_float_sdna(prop, NULL, "col");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_float_array_default(prop, default_col);
+ RNA_def_property_ui_text(prop, "Diffuse Color", "Color of the light's diffuse highlight");
+ RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update");
}
static void rna_def_userdef_walk_navigation(BlenderRNA *brna)
@@ -3639,11 +3725,6 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Layout Widgets", "Show screen layout editing UI");
RNA_def_property_update(prop, 0, "rna_userdef_update_ui");
- prop = RNA_def_property(srna, "show_view3d_cursor", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "app_flag", USER_APP_VIEW3D_HIDE_CURSOR);
- RNA_def_property_ui_text(prop, "Show 3D View Cursor", "");
- RNA_def_property_update(prop, 0, "rna_userdef_update");
-
/* menus */
prop = RNA_def_property(srna, "use_mouse_over_open", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_MENUOPENAUTO);
@@ -4279,10 +4360,22 @@ static void rna_def_userdef_system(BlenderRNA *brna)
/* System & OpenGL */
prop = RNA_def_property(srna, "solid_lights", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "light", "");
+ RNA_def_property_collection_sdna(prop, NULL, "light_param", "");
RNA_def_property_struct_type(prop, "UserSolidLight");
RNA_def_property_ui_text(prop, "Solid Lights", "Lights user to display objects in solid draw mode");
+ prop = RNA_def_property(srna, "light_ambient", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_float_sdna(prop, NULL, "light_ambient");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Ambient Color", "Color of the ambient light that uniformly lit the scene");
+ RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update");
+
+ prop = RNA_def_property(srna, "edit_studio_light", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "edit_studio_light", 1);
+ RNA_def_property_ui_text(prop, "Edit Studio Light",
+ "View the result of the studio light editor in the viewport");
+ RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update");
+
prop = RNA_def_property(srna, "use_weight_color_range", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_CUSTOM_RANGE);
RNA_def_property_ui_text(prop, "Use Weight Color Range",
@@ -4694,6 +4787,8 @@ static void rna_def_userdef_input(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_TWOBUTTONMOUSE);
RNA_def_property_ui_text(prop, "Emulate 3 Button Mouse",
"Emulate Middle Mouse with Alt+Left Mouse (doesn't work with Left Mouse Select option)");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, 0, "rna_userdef_keyconfig_reload_update");
prop = RNA_def_property(srna, "use_emulate_numpad", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_NONUMPAD);
@@ -4925,14 +5020,26 @@ void RNA_def_userdef(BlenderRNA *brna)
PropertyRNA *prop;
static const EnumPropertyItem user_pref_sections[] = {
+ {0, "", ICON_USER, "User Preferences", ""},
{USER_SECTION_INTERFACE, "INTERFACE", 0, "Interface", ""},
{USER_SECTION_EDIT, "EDITING", 0, "Editing", ""},
{USER_SECTION_INPUT, "INPUT", 0, "Input", ""},
{USER_SECTION_ADDONS, "ADDONS", 0, "Add-ons", ""},
{USER_SECTION_THEME, "THEMES", 0, "Themes", ""},
{USER_SECTION_LIGHT, "LIGHTS", 0, "Lights", ""},
- {USER_SECTION_FILE, "FILES", 0, "File", ""},
- {USER_SECTION_SYSTEM, "SYSTEM", 0, "System", ""},
+#ifdef WITH_USERDEF_WORKSPACES
+ {0, "", ICON_WORKSPACE, "Workspaces", ""},
+ {USER_SECTION_WORKSPACE_CONFIG, "WORKSPACE_CONFIG", 0, "Configuration File", ""},
+ {USER_SECTION_WORKSPACE_ADDONS, "WORKSPACE_ADDONS", 0, "Add-on Overrides", ""},
+ {USER_SECTION_WORKSPACE_KEYMAPS, "WORKSPACE_KEYMAPS", 0, "Keymap Overrides", ""},
+#endif
+ {0, "", ICON_SYSTEM, "System", ""},
+ {USER_SECTION_SYSTEM_GENERAL, "SYSTEM_GENERAL", 0, "General", ""},
+ {USER_SECTION_SYSTEM_FILES, "SYSTEM_FILES", 0, "Files", ""},
+#ifdef WITH_USERDEF_SYSTEM_SPLIT
+ {USER_SECTION_SYSTEM_DISPLAY, "SYSTEM_DISPLAY", 0, "Display", ""},
+ {USER_SECTION_SYSTEM_DEVICES, "SYSTEM_DEVICES", 0, "Devices", ""},
+#endif
{0, NULL, 0, NULL, NULL}
};
diff --git a/source/blender/makesrna/intern/rna_vfont.c b/source/blender/makesrna/intern/rna_vfont.c
index 487b5220c86..f01f095066e 100644
--- a/source/blender/makesrna/intern/rna_vfont.c
+++ b/source/blender/makesrna/intern/rna_vfont.c
@@ -61,7 +61,7 @@ static void rna_VectorFont_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scen
/* update */
WM_main_add_notifier(NC_GEOM | ND_DATA, NULL);
- DEG_id_tag_update(&vf->id, OB_RECALC_OB | OB_RECALC_DATA);
+ DEG_id_tag_update(&vf->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
#else
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index ef8607018d7..92a396c22b9 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -41,6 +41,8 @@
#include "DNA_space_types.h"
#include "DNA_windowmanager_types.h"
+#include "UI_interface.h"
+
#include "wm_cursors.h"
#include "rna_internal.h" /* own include */
@@ -68,11 +70,15 @@ const EnumPropertyItem rna_enum_window_cursor_items[] = {
#ifdef RNA_RUNTIME
-#include "UI_interface.h"
#include "BKE_context.h"
#include "WM_types.h"
+static void rna_KeyMapItem_to_string(wmKeyMapItem *kmi, bool compact, char *result)
+{
+ WM_keymap_item_to_string(kmi, compact, result, UI_MAX_SHORTCUT_STR);
+}
+
static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@ -132,19 +138,19 @@ static wmGizmoGroupType *wm_gizmogrouptype_find_for_add_remove(ReportList *repor
return gzgt;
}
-static void rna_gizmo_group_type_add(ReportList *reports, const char *idname)
+static void rna_gizmo_group_type_ensure(ReportList *reports, const char *idname)
{
wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname);
if (gzgt != NULL) {
- WM_gizmo_group_type_add_ptr(gzgt);
+ WM_gizmo_group_type_ensure_ptr(gzgt);
}
}
-static void rna_gizmo_group_type_remove(Main *bmain, ReportList *reports, const char *idname)
+static void rna_gizmo_group_type_unlink_delayed(ReportList *reports, const char *idname)
{
wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname);
if (gzgt != NULL) {
- WM_gizmo_group_type_remove_ptr(bmain, gzgt);
+ WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
}
}
@@ -543,15 +549,15 @@ void RNA_api_wm(StructRNA *srna)
parm = RNA_def_pointer(func, "timer", "Timer", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- func = RNA_def_function(srna, "gizmo_group_type_add", "rna_gizmo_group_type_add");
+ func = RNA_def_function(srna, "gizmo_group_type_ensure", "rna_gizmo_group_type_ensure");
RNA_def_function_ui_description(func, "Activate an existing widget group (when the persistent option isn't set)");
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS);
parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- func = RNA_def_function(srna, "gizmo_group_type_remove", "rna_gizmo_group_type_remove");
- RNA_def_function_ui_description(func, "De-activate a widget group (when the persistent option isn't set)");
- RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_MAIN | FUNC_USE_REPORTS);
+ func = RNA_def_function(srna, "gizmo_group_type_unlink_delayed", "rna_gizmo_group_type_unlink_delayed");
+ RNA_def_function_ui_description(func, "Unlink a widget group (when the persistent option is set)");
+ RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS);
parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -830,6 +836,12 @@ void RNA_api_keymapitem(StructRNA *srna)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_boolean(func, "result", 0, "Comparison result", "");
RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "to_string", "rna_KeyMapItem_to_string");
+ RNA_def_boolean(func, "compact", false, "Compact", "");
+ parm = RNA_def_string(func, "result", NULL, UI_MAX_SHORTCUT_STR, "result", "");
+ RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
+ RNA_def_function_output(func, parm);
}
void RNA_api_keymapitems(StructRNA *srna)
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index 59b1086e17e..f0c00bd1940 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -132,6 +132,12 @@ static bToolRef *rna_WorkSpace_tools_from_space_image_mode(
return rna_WorkSpace_tools_from_tkey(workspace, &(bToolKey){ .space_type = SPACE_IMAGE, .mode = mode}, create);
}
+static bToolRef *rna_WorkSpace_tools_from_space_node(
+ WorkSpace *workspace, bool create)
+{
+ return rna_WorkSpace_tools_from_tkey(workspace, &(bToolKey){ .space_type = SPACE_NODE, .mode = 0}, create);
+}
+
const EnumPropertyItem *rna_WorkSpace_tools_mode_itemf(
bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
{
@@ -295,12 +301,19 @@ static void rna_def_workspace_tools(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "from_space_image_mode", "rna_WorkSpace_tools_from_space_image_mode");
RNA_def_function_ui_description(func, "");
- parm = RNA_def_enum(func, "mode", rna_enum_space_image_mode_items, 0, "", "");
+ parm = RNA_def_enum(func, "mode", rna_enum_space_image_mode_all_items, 0, "", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_boolean(func, "create", false, "Create", "");
/* return type */
parm = RNA_def_pointer(func, "result", "WorkspaceTool", "", "");
RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "from_space_node", "rna_WorkSpace_tools_from_space_node");
+ RNA_def_function_ui_description(func, "");
+ RNA_def_boolean(func, "create", false, "Create", "");
+ /* return type */
+ parm = RNA_def_pointer(func, "result", "WorkspaceTool", "", "");
+ RNA_def_function_return(func, parm);
}
static void rna_def_workspace(BlenderRNA *brna)
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index e517d4a25ec..040949198f5 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -145,10 +145,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
-if(WITH_OPENSUBDIV_MODIFIER)
- add_definitions(-DWITH_OPENSUBDIV_MODIFIER)
-endif()
-
# So we can have special tricks in modifier system.
add_definitions(${GL_DEFINITIONS})
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index 3209391d4bc..fcd54639f9f 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -49,6 +49,8 @@
#include "BKE_mesh.h"
#include "BKE_modifier.h"
+#include "DEG_depsgraph_query.h"
+
#include "bmesh.h"
#include "bmesh_tools.h"
@@ -121,7 +123,7 @@ static void deformVerts(
MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */
- armature_deform_verts(amd->object, ctx->object, mesh, vertexCos, NULL,
+ armature_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, amd->object), ctx->object, mesh, vertexCos, NULL,
numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name, NULL);
/* free cache */
@@ -136,11 +138,11 @@ static void deformVertsEM(
Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, em, mesh, NULL, false, false);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, numVerts, false, false);
MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */
- armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, NULL,
+ armature_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, amd->object), ctx->object, mesh_src, vertexCos, NULL,
numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name, NULL);
/* free cache */
@@ -160,10 +162,10 @@ static void deformMatricesEM(
float (*defMats)[3][3], int numVerts)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, em, mesh, NULL, false, false);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, numVerts, false, false);
- armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats, numVerts,
- amd->deformflag, NULL, amd->defgrp_name, NULL);
+ armature_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, amd->object), ctx->object, mesh_src, vertexCos, defMats,
+ numVerts, amd->deformflag, NULL, amd->defgrp_name, NULL);
if (mesh_src != mesh) {
BKE_id_free(NULL, mesh_src);
@@ -175,10 +177,10 @@ static void deformMatrices(
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
- armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats, numVerts,
- amd->deformflag, NULL, amd->defgrp_name, NULL);
+ armature_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, amd->object), ctx->object, mesh_src, vertexCos, defMats,
+ numVerts, amd->deformflag, NULL, amd->defgrp_name, NULL);
if (mesh_src != mesh) {
BKE_id_free(NULL, mesh_src);
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index cd2f7cc364b..597320c3887 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -57,6 +57,7 @@
#include "MOD_util.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
static void initData(ModifierData *md)
{
@@ -107,6 +108,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
if (amd->offset_ob != NULL) {
DEG_add_object_relation(ctx->node, amd->offset_ob, DEG_OB_COMP_TRANSFORM, "Array Modifier Offset");
}
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Array Modifier");
}
BLI_INLINE float sum_v3(const float v[3])
@@ -363,7 +365,7 @@ static Mesh *arrayModifier_doArray(
const bool use_merge = (amd->flags & MOD_ARR_MERGE) != 0;
const bool use_recalc_normals = (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) || use_merge;
- const bool use_offset_ob = ((amd->offset_type & MOD_ARR_OFF_OBJ) && amd->offset_ob);
+ const bool use_offset_ob = ((amd->offset_type & MOD_ARR_OFF_OBJ) && amd->offset_ob != NULL);
int start_cap_nverts = 0, start_cap_nedges = 0, start_cap_npolys = 0, start_cap_nloops = 0;
int end_cap_nverts = 0, end_cap_nedges = 0, end_cap_npolys = 0, end_cap_nloops = 0;
@@ -386,11 +388,12 @@ static Mesh *arrayModifier_doArray(
count = amd->count;
- if (amd->start_cap && amd->start_cap != ctx->object && amd->start_cap->type == OB_MESH) {
+ Object *start_cap_ob = DEG_get_evaluated_object(ctx->depsgraph, amd->start_cap);
+ if (start_cap_ob && start_cap_ob != ctx->object && start_cap_ob->type == OB_MESH) {
vgroup_start_cap_remap = BKE_object_defgroup_index_map_create(
- amd->start_cap, ctx->object, &vgroup_start_cap_remap_len);
+ start_cap_ob, ctx->object, &vgroup_start_cap_remap_len);
- start_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(amd->start_cap, &start_cap_mesh_free);
+ start_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(start_cap_ob, &start_cap_mesh_free);
if (start_cap_mesh) {
start_cap_nverts = start_cap_mesh->totvert;
start_cap_nedges = start_cap_mesh->totedge;
@@ -398,11 +401,12 @@ static Mesh *arrayModifier_doArray(
start_cap_npolys = start_cap_mesh->totpoly;
}
}
- if (amd->end_cap && amd->end_cap != ctx->object && amd->end_cap->type == OB_MESH) {
+ Object *end_cap_ob = DEG_get_evaluated_object(ctx->depsgraph, amd->end_cap);
+ if (end_cap_ob && end_cap_ob != ctx->object && end_cap_ob->type == OB_MESH) {
vgroup_end_cap_remap = BKE_object_defgroup_index_map_create(
- amd->end_cap, ctx->object, &vgroup_end_cap_remap_len);
+ end_cap_ob, ctx->object, &vgroup_end_cap_remap_len);
- end_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(amd->end_cap, &end_cap_mesh_free);
+ end_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(end_cap_ob, &end_cap_mesh_free);
if (end_cap_mesh) {
end_cap_nverts = end_cap_mesh->totvert;
end_cap_nedges = end_cap_mesh->totedge;
@@ -443,8 +447,7 @@ static Mesh *arrayModifier_doArray(
else
unit_m4(obinv);
- mul_m4_series(result_mat, offset,
- obinv, amd->offset_ob->obmat);
+ mul_m4_series(result_mat, offset, obinv, DEG_get_evaluated_object(ctx->depsgraph, amd->offset_ob)->obmat);
copy_m4_m4(offset, result_mat);
}
@@ -452,12 +455,13 @@ static Mesh *arrayModifier_doArray(
mat4_to_size(scale, offset);
offset_has_scale = !is_one_v3(scale);
- if (amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) {
- Curve *cu = amd->curve_ob->data;
+ if (amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob != NULL) {
+ Object *curve_ob = DEG_get_evaluated_object(ctx->depsgraph, amd->curve_ob);
+ Curve *cu = curve_ob->data;
if (cu) {
- CurveCache *curve_cache = amd->curve_ob->runtime.curve_cache;
+ CurveCache *curve_cache = curve_ob->runtime.curve_cache;
if (curve_cache != NULL && curve_cache->path != NULL) {
- float scale_fac = mat4_to_scale(amd->curve_ob->obmat);
+ float scale_fac = mat4_to_scale(curve_ob->obmat);
length = scale_fac * curve_cache->path->totdist;
}
}
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index d9b6cfa1ac5..ee2b08fe824 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -214,7 +214,7 @@ static void bevel_mod_harden_normals(
add_v3_v3(cn_wght, cur);
}
if (!BLI_ghash_haskey(faceHash, lfan_pivot->f)) {
- recon_face = f;
+ recon_face = lfan_pivot->f;
recon_face_count++;
}
if (!BM_elem_flag_test(e_next, BM_ELEM_TAG) || (e_next == e_org)) {
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index bb454f65f90..97e0d68d184 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -114,20 +114,21 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
Mesh *mesh_other;
bool mesh_other_free;
- if (!bmd->object) {
+ if (bmd->object == NULL) {
return result;
}
- Object *ob_eval = DEG_get_evaluated_object(ctx->depsgraph, bmd->object);
- mesh_other = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_eval, &mesh_other_free);
+ Object *other = DEG_get_evaluated_object(ctx->depsgraph, bmd->object);
+ mesh_other = BKE_modifier_get_evaluated_mesh_from_evaluated_object(other, &mesh_other_free);
result = BKE_boolean_operation(mesh, ctx->object, mesh_other, bmd->object, bmd->operation,
bmd->double_threshold, bmd);
/* if new mesh returned, return it; otherwise there was
* an error, so delete the modifier object */
- if (result == NULL)
+ if (result == NULL) {
modifier_setError(md, "Cannot execute boolean operation");
+ }
if (mesh_other != NULL && mesh_other_free) {
BKE_id_free(NULL, mesh_other);
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index 74e19f3254a..59ffe11d614 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -48,6 +48,8 @@
#include "BKE_mesh.h"
#include "BKE_modifier.h"
+#include "DEG_depsgraph_query.h"
+
#include "MOD_util.h"
static void initData(ModifierData *md)
@@ -105,7 +107,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
static void sphere_do(
- CastModifierData *cmd, Object *ob, Mesh *mesh,
+ CastModifierData *cmd, const ModifierEvalContext *ctx,
+ Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
MDeformVert *dvert = NULL;
@@ -128,7 +131,7 @@ static void sphere_do(
if (type == MOD_CAST_TYPE_CYLINDER)
flag &= ~MOD_CAST_Z;
- ctrl_ob = cmd->object;
+ ctrl_ob = DEG_get_evaluated_object(ctx->depsgraph, cmd->object);
/* spherify's center is {0, 0, 0} (the ob's own center in its local
* space), by default, but if the user defined a control object,
@@ -226,7 +229,8 @@ static void sphere_do(
}
static void cuboid_do(
- CastModifierData *cmd, Object *ob, Mesh *mesh,
+ CastModifierData *cmd, const ModifierEvalContext *ctx,
+ Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
MDeformVert *dvert = NULL;
@@ -244,7 +248,7 @@ static void cuboid_do(
flag = cmd->flag;
- ctrl_ob = cmd->object;
+ ctrl_ob = DEG_get_evaluated_object(ctx->depsgraph, cmd->object);
/* now we check which options the user wants */
@@ -429,18 +433,21 @@ static void deformVerts(
int numVerts)
{
CastModifierData *cmd = (CastModifierData *)md;
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ Mesh *mesh_src = NULL;
- BLI_assert(mesh_src->totvert == numVerts);
+ if (ctx->object->type == OB_MESH && cmd->defgrp_name[0] != '\0') {
+ /* mesh_src is only needed for vgroups. */
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
+ }
if (cmd->type == MOD_CAST_TYPE_CUBOID) {
- cuboid_do(cmd, ctx->object, mesh_src, vertexCos, numVerts);
+ cuboid_do(cmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
}
else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */
- sphere_do(cmd, ctx->object, mesh_src, vertexCos, numVerts);
+ sphere_do(cmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
}
- if (mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
@@ -451,15 +458,15 @@ static void deformVertsEM(
Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
CastModifierData *cmd = (CastModifierData *)md;
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, editData, mesh, NULL, false, false);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
BLI_assert(mesh_src->totvert == numVerts);
if (cmd->type == MOD_CAST_TYPE_CUBOID) {
- cuboid_do(cmd, ctx->object, mesh_src, vertexCos, numVerts);
+ cuboid_do(cmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
}
else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */
- sphere_do(cmd, ctx->object, mesh_src, vertexCos, numVerts);
+ sphere_do(cmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
}
if (mesh_src != mesh) {
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 55af0f04bac..636c465d304 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -93,7 +93,7 @@ static void deformVerts(
}
if (mesh == NULL) {
- mesh_src = MOD_get_mesh_eval(ctx->object, NULL, NULL, NULL, false, false);
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, numVerts, false, false);
}
else {
/* Not possible to use get_mesh() in this case as we'll modify its vertices
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index 2fddef21996..011635e3012 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -105,7 +105,7 @@ static void deformVerts(
ModifierData *md, const ModifierEvalContext *ctx,
Mesh *mesh,
float (*vertexCos)[3],
- int UNUSED(numVerts))
+ int numVerts)
{
CollisionModifierData *collmd = (CollisionModifierData *) md;
Mesh *mesh_src;
@@ -113,7 +113,7 @@ static void deformVerts(
Object *ob = ctx->object;
if (mesh == NULL) {
- mesh_src = MOD_get_mesh_eval(ob, NULL, NULL, NULL, false, false);
+ mesh_src = MOD_deform_mesh_eval_get(ob, NULL, NULL, NULL, numVerts, false, false);
}
else {
/* Not possible to use get_mesh() in this case as we'll modify its vertices
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c
index 777e1cbf21b..79702517991 100644
--- a/source/blender/modifiers/intern/MOD_correctivesmooth.c
+++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c
@@ -575,7 +575,7 @@ static void correctivesmooth_modifier_do(
const bool force_delta_cache_update =
/* XXX, take care! if mesh data its self changes we need to forcefully recalculate deltas */
((csmd->rest_source == MOD_CORRECTIVESMOOTH_RESTSOURCE_ORCO) &&
- (((ID *)ob->data)->recalc & ID_RECALC));
+ (((ID *)ob->data)->recalc & ID_RECALC_ALL));
bool use_only_smooth = (csmd->flag & MOD_CORRECTIVESMOOTH_ONLY_SMOOTH) != 0;
MDeformVert *dvert = NULL;
@@ -717,7 +717,7 @@ static void deformVerts(
ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
correctivesmooth_modifier_do(md, ctx->object, mesh_src, vertexCos, (unsigned int)numVerts, NULL);
@@ -731,7 +731,7 @@ static void deformVertsEM(
ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData,
Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, editData, mesh, NULL, false, false);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
correctivesmooth_modifier_do(md, ctx->object, mesh_src, vertexCos, (unsigned int)numVerts, editData);
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index 73a541090e8..42dd8ebb32b 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -49,6 +49,7 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "MOD_modifiertypes.h"
#include "MOD_util.h"
@@ -112,15 +113,23 @@ static void deformVerts(
int numVerts)
{
CurveModifierData *cmd = (CurveModifierData *) md;
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ Mesh *mesh_src = NULL;
- BLI_assert(mesh_src->totvert == numVerts);
+ if (ctx->object->type == OB_MESH && cmd->name[0] != '\0') {
+ /* mesh_src is only needed for vgroups. */
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
+ }
+
+ struct MDeformVert *dvert = NULL;
+ int defgrp_index = -1;
+ MOD_get_vgroup(ctx->object, mesh_src, cmd->name, &dvert, &defgrp_index);
/* silly that defaxis and curve_deform_verts are off by 1
* but leave for now to save having to call do_versions */
- curve_deform_verts(cmd->object, ctx->object, mesh_src, vertexCos, numVerts, cmd->name, cmd->defaxis - 1);
+ curve_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, cmd->object), ctx->object,
+ vertexCos, numVerts, dvert, defgrp_index, cmd->defaxis - 1);
- if (mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
@@ -133,13 +142,11 @@ static void deformVertsEM(
float (*vertexCos)[3],
int numVerts)
{
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, em, mesh, NULL, false, false);
-
- BLI_assert(mesh_src->totvert == numVerts);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, numVerts, false, false);
deformVerts(md, ctx, mesh_src, vertexCos, numVerts);
- if (mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index d3f573ec4b6..6e823a8518a 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -131,7 +131,13 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
if (dtmd->ob_source != NULL) {
CustomDataMask mask = BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types);
- DEG_add_object_relation_with_customdata(ctx->node, dtmd->ob_source, DEG_OB_COMP_GEOMETRY, mask, "DataTransfer Modifier");
+ DEG_add_object_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_GEOMETRY, "DataTransfer Modifier");
+ DEG_add_customdata_mask(ctx->node, dtmd->ob_source, mask);
+
+ if (dtmd->flags & MOD_DATATRANSFER_OBSRC_TRANSFORM) {
+ DEG_add_object_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_TRANSFORM, "DataTransfer Modifier");
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "DataTransfer Modifier");
+ }
}
}
@@ -160,6 +166,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/* Only used to check wehther we are operating on org data or not... */
Mesh *me = ctx->object->data;
+ Object *ob_source = DEG_get_evaluated_object(ctx->depsgraph, dtmd->ob_source);
+
const bool invert_vgroup = (dtmd->flags & MOD_DATATRANSFER_INVERT_VGROUP) != 0;
const float max_dist = (dtmd->flags & MOD_DATATRANSFER_MAP_MAXDIST) ? dtmd->map_max_distance : FLT_MAX;
@@ -168,10 +176,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
SpaceTransform *space_transform = (dtmd->flags & MOD_DATATRANSFER_OBSRC_TRANSFORM) ? &space_transform_data : NULL;
if (space_transform) {
- BLI_SPACE_TRANSFORM_SETUP(space_transform, ctx->object, dtmd->ob_source);
+ BLI_SPACE_TRANSFORM_SETUP(space_transform, ctx->object, ob_source);
}
- if ((result == me_mod || (me->mvert == result->mvert) || (me->medge == result->medge)) &&
+ if (((result == me) || (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
@@ -188,7 +196,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
BKE_reports_init(&reports, RPT_STORE);
/* Note: no islands precision for now here. */
- BKE_object_data_transfer_ex(ctx->depsgraph, scene, dtmd->ob_source, ctx->object, result, dtmd->data_types, false,
+ BKE_object_data_transfer_ex(ctx->depsgraph, scene, 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,
@@ -200,7 +208,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
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 (result->totvert > HIGH_POLY_WARNING || ((Mesh *)(dtmd->ob_source->data))->totvert > HIGH_POLY_WARNING) {
+ else if (result->totvert > HIGH_POLY_WARNING || ((Mesh *)(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");
}
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 8f9ce544330..7cad6af6d34 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -148,6 +148,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
DisplaceModifierData *dmd = (DisplaceModifierData *)md;
if (dmd->map_object != NULL && dmd->texmapping == MOD_DISP_MAP_OBJECT) {
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Displace Modifier");
DEG_add_object_relation(ctx->node, dmd->map_object, DEG_OB_COMP_TRANSFORM, "Displace Modifier");
}
if (dmd->texmapping == MOD_DISP_MAP_GLOBAL ||
@@ -156,6 +157,9 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Displace Modifier");
}
+ if (dmd->texture != NULL) {
+ DEG_add_generic_id_relation(ctx->node, &dmd->texture->id, "Displace Modifier");
+ }
}
typedef struct DisplaceUserdata {
@@ -167,6 +171,7 @@ typedef struct DisplaceUserdata {
int defgrp_index;
int direction;
bool use_global_direction;
+ Tex *tex_target;
float (*tex_co)[3];
float (*vertexCos)[3];
float local_mat[4][4];
@@ -205,9 +210,9 @@ static void displaceModifier_do_task(
}
}
- if (dmd->texture) {
+ if (data->tex_target) {
texres.nor = NULL;
- BKE_texture_get_value_ex(data->scene, dmd->texture, tex_co[iter], &texres, data->pool, false);
+ BKE_texture_get_value_ex(data->scene, data->tex_target, tex_co[iter], &texres, data->pool, false);
delta = texres.tin - dmd->midlevel;
}
else {
@@ -278,7 +283,6 @@ static void displaceModifier_do(
Mesh *mesh, float (*vertexCos)[3], const int numVerts)
{
Object *ob = ctx->object;
- Depsgraph *depsgraph = ctx->depsgraph;
MVert *mvert;
MDeformVert *dvert;
int direction = dmd->direction;
@@ -289,18 +293,19 @@ static void displaceModifier_do(
float local_mat[4][4] = {{0}};
const bool use_global_direction = dmd->space == MOD_DISP_SPACE_GLOBAL;
- if (!dmd->texture && dmd->direction == MOD_DISP_DIR_RGB_XYZ) return;
+ if (dmd->texture == NULL && dmd->direction == MOD_DISP_DIR_RGB_XYZ) return;
if (dmd->strength == 0.0f) return;
mvert = mesh->mvert;
MOD_get_vgroup(ob, mesh, dmd->defgrp_name, &dvert, &defgrp_index);
- if (dmd->texture) {
+ Tex *tex_target = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &dmd->texture->id);
+ if (tex_target != NULL) {
tex_co = MEM_calloc_arrayN((size_t)numVerts, sizeof(*tex_co),
"displaceModifier_do tex_co");
- MOD_get_texture_coords((MappingInfoModifierData *)dmd, ob, mesh, vertexCos, tex_co);
+ MOD_get_texture_coords((MappingInfoModifierData *)dmd, ctx, ob, mesh, vertexCos, tex_co);
- MOD_init_texture(depsgraph, dmd->texture);
+ MOD_init_texture((MappingInfoModifierData *)dmd, ctx);
}
else {
tex_co = NULL;
@@ -339,14 +344,15 @@ static void displaceModifier_do(
data.defgrp_index = defgrp_index;
data.direction = direction;
data.use_global_direction = use_global_direction;
+ data.tex_target = tex_target;
data.tex_co = tex_co;
data.vertexCos = vertexCos;
copy_m4_m4(data.local_mat, local_mat);
data.mvert = mvert;
data.vert_clnors = vert_clnors;
- if (dmd->texture != NULL) {
+ if (tex_target != NULL) {
data.pool = BKE_image_pool_new();
- BKE_texture_fetch_images_for_pool(dmd->texture, data.pool);
+ BKE_texture_fetch_images_for_pool(tex_target, data.pool);
}
ParallelRangeSettings settings;
BLI_parallel_range_settings_defaults(&settings);
@@ -376,13 +382,11 @@ static void deformVerts(
float (*vertexCos)[3],
int numVerts)
{
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
-
- BLI_assert(mesh_src->totvert == numVerts);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
displaceModifier_do((DisplaceModifierData *)md, ctx, mesh_src, vertexCos, numVerts);
- if (mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
@@ -391,13 +395,11 @@ static void deformVertsEM(
ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData,
Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, editData, mesh, NULL, false, false);
-
- BLI_assert(mesh_src->totvert == numVerts);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
displaceModifier_do((DisplaceModifierData *)md, ctx, mesh_src, vertexCos, numVerts);
- if (mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index f52632cdcc9..8db8da3fc81 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -58,8 +58,10 @@ static Mesh *doEdgeSplit(Mesh *mesh, EdgeSplitModifierData *emd, const ModifierE
BMesh *bm;
BMIter iter;
BMEdge *e;
- float threshold = cosf(emd->split_angle + 0.000000175f);
- const bool calc_face_normals = (emd->flags & MOD_EDGESPLIT_FROMANGLE) != 0;
+ const float threshold = cosf(emd->split_angle + 0.000000175f);
+ const bool do_split_angle = (emd->flags & MOD_EDGESPLIT_FROMANGLE) != 0 && emd->split_angle < (float)M_PI;
+ const bool do_split_all = do_split_angle && emd->split_angle < FLT_EPSILON;
+ const bool calc_face_normals = do_split_angle && !do_split_all;
bm = BKE_mesh_to_bmesh_ex(
mesh,
@@ -72,7 +74,7 @@ static Mesh *doEdgeSplit(Mesh *mesh, EdgeSplitModifierData *emd, const ModifierE
.cd_mask_extra = CD_MASK_ORIGINDEX,
});
- if (emd->flags & MOD_EDGESPLIT_FROMANGLE) {
+ if (do_split_angle) {
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
/* check for 1 edge having 2 face users */
BMLoop *l1, *l2;
@@ -81,6 +83,8 @@ static Mesh *doEdgeSplit(Mesh *mesh, EdgeSplitModifierData *emd, const ModifierE
{
if (/* 3+ faces on this edge, always split */
UNLIKELY(l1 != l2->radial_next) ||
+ /* O° angle setting, we want to split on all edges. */
+ do_split_all ||
/* 2 face edge - check angle*/
(dot_v3v3(l1->f->no, l2->f->no) < threshold))
{
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index 0764bba6a14..24400b5a309 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -49,6 +49,8 @@
#include "BKE_deform.h"
#include "BKE_colortools.h"
+#include "DEG_depsgraph_query.h"
+
#include "MEM_guardedalloc.h"
#include "MOD_util.h"
@@ -252,10 +254,12 @@ static void hook_co_apply(struct HookData_cb *hd, const int j)
}
static void deformVerts_do(
- HookModifierData *hmd, Object *ob, Mesh *mesh,
+ HookModifierData *hmd, const ModifierEvalContext *ctx,
+ Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
- bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget);
+ Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, hmd->object);
+ bPoseChannel *pchan = BKE_pose_channel_find_name(ob_target->pose, hmd->subtarget);
float dmat[4][4];
int i, *index_pt;
struct HookData_cb hd;
@@ -295,11 +299,11 @@ static void deformVerts_do(
/* get world-space matrix of target, corrected for the space the verts are in */
if (hmd->subtarget[0] && pchan) {
/* bone target if there's a matching pose-channel */
- mul_m4_m4m4(dmat, hmd->object->obmat, pchan->pose_mat);
+ mul_m4_m4m4(dmat, ob_target->obmat, pchan->pose_mat);
}
else {
/* just object target */
- copy_m4_m4(dmat, hmd->object->obmat);
+ copy_m4_m4(dmat, ob_target->obmat);
}
invert_m4_m4(ob->imat, ob->obmat);
mul_m4_series(hd.mat, ob->imat, dmat, hmd->parentinv);
@@ -354,11 +358,11 @@ static void deformVerts(
float (*vertexCos)[3], int numVerts)
{
HookModifierData *hmd = (HookModifierData *)md;
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
- deformVerts_do(hmd, ctx->object, mesh_src, vertexCos, numVerts);
+ deformVerts_do(hmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
- if (mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
@@ -369,11 +373,11 @@ static void deformVertsEM(
struct Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
HookModifierData *hmd = (HookModifierData *)md;
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, editData, mesh, NULL, false, false);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
- deformVerts_do(hmd, ctx->object, mesh_src, vertexCos, numVerts);
+ deformVerts_do(hmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
- if (mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index ad6c6e0163d..ba45e6bf848 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -734,10 +734,11 @@ static void deformVerts(
ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
LaplacianDeformModifier_do((LaplacianDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts);
- if (mesh_src != mesh) {
+
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
@@ -746,10 +747,12 @@ static void deformVertsEM(
ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData,
Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, editData, mesh, NULL, false, false);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
+
LaplacianDeformModifier_do((LaplacianDeformModifierData *)md, ctx->object, mesh_src,
vertexCos, numVerts);
- if (mesh_src != mesh) {
+
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index fba4ac5d9e5..1acec1d8b7a 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -507,13 +507,14 @@ static void deformVerts(
if (numVerts == 0)
return;
- mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
laplaciansmoothModifier_do((LaplacianSmoothModifierData *)md, ctx->object, mesh_src,
vertexCos, numVerts);
- if (mesh_src != mesh)
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
+ }
}
static void deformVertsEM(
@@ -525,13 +526,14 @@ static void deformVertsEM(
if (numVerts == 0)
return;
- mesh_src = MOD_get_mesh_eval(ctx->object, editData, mesh, NULL, false, false);
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
laplaciansmoothModifier_do((LaplacianSmoothModifierData *)md, ctx->object, mesh_src,
vertexCos, numVerts);
- if (mesh_src != mesh)
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
+ }
}
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index 7937d1611f9..9fbd4629629 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -46,6 +46,8 @@
#include "BKE_mesh.h"
#include "BKE_modifier.h"
+#include "DEG_depsgraph_query.h"
+
#include "MEM_guardedalloc.h"
#include "MOD_util.h"
@@ -100,26 +102,27 @@ static void deformVerts(
int numVerts)
{
LatticeModifierData *lmd = (LatticeModifierData *) md;
- struct Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ struct Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */
- lattice_deform_verts(lmd->object, ctx->object, mesh_src,
+ lattice_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, lmd->object), ctx->object, mesh_src,
vertexCos, numVerts, lmd->name, lmd->strength);
- if (mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
- }}
+ }
+}
static void deformVertsEM(
ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *em,
struct Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
- struct Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, em, mesh, NULL, false, false);
+ struct Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, numVerts, false, false);
deformVerts(md, ctx, mesh_src, vertexCos, numVerts);
- if (mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index 1a8027e6697..555fe29978f 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -54,6 +54,7 @@
#include "BKE_deform.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "MOD_modifiertypes.h"
@@ -81,6 +82,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
/* TODO(sergey): Is it a proper relation here? */
DEG_add_object_relation(ctx->node, mmd->ob_arm, DEG_OB_COMP_TRANSFORM, "Mask Modifier");
arm->flag |= ARM_HAS_VIZ_DEPS;
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Mask Modifier");
}
}
@@ -136,7 +138,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/* if mode is to use selected armature bones, aggregate the bone groups */
if (mmd->mode == MOD_MASK_MODE_ARM) { /* --- using selected bones --- */
- Object *oba = mmd->ob_arm;
+ Object *oba = DEG_get_evaluated_object(ctx->depsgraph, mmd->ob_arm);
bPoseChannel *pchan;
bDeformGroup *def;
bool *bone_select_array;
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index aaf6c532de0..ae027c64626 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -45,6 +45,7 @@
#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_deform.h"
#include "BKE_editmesh.h"
@@ -286,13 +287,15 @@ static void meshdeformModifier_do(
Mesh *cagemesh;
MDeformVert *dvert = NULL;
float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4];
- float co[3], (*dco)[3], (*bindcagecos)[3];
+ float co[3], (*dco)[3] = NULL, (*bindcagecos)[3];
int a, totvert, totcagevert, defgrp_index;
- float (*cagecos)[3];
+ float (*cagecos)[3] = NULL;
MeshdeformUserdata data;
bool free_cagemesh = false;
- if (!mmd->object || (!mmd->bindcagecos && !mmd->bindfunc))
+ static int recursive_bind_sentinel = 0;
+
+ if (mmd->object == NULL || (mmd->bindcagecos == NULL && mmd->bindfunc == NULL))
return;
/* Get cage mesh.
@@ -305,15 +308,23 @@ static void meshdeformModifier_do(
*
* We'll support this case once granular dependency graph is landed.
*/
- cagemesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(mmd->object, &free_cagemesh);
-
+ Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, mmd->object);
+ cagemesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, &free_cagemesh);
+#if 0 /* This shall not be needed if we always get evaluated target object... */
+ if (cagemesh == NULL && mmd->bindcagecos == NULL && ob == DEG_get_original_object(ob)) {
+ /* Special case, binding happens outside of depsgraph evaluation, so we can build our own
+ * target mesh if needed. */
+ cagemesh = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), mmd->object, 0);
+ free_cagemesh = cagemesh != NULL;
+ }
+#endif
if (cagemesh == NULL) {
modifier_setError(md, "Cannot get mesh from cage object");
return;
}
/* compute matrices to go in and out of cage object space */
- invert_m4_m4(imat, mmd->object->obmat);
+ invert_m4_m4(imat, ob_target->obmat);
mul_m4_m4m4(cagemat, imat, ob->obmat);
mul_m4_m4m4(cmat, mmd->bindmat, cagemat);
invert_m4_m4(iobmat, cmat);
@@ -321,22 +332,20 @@ static void meshdeformModifier_do(
/* bind weights if needed */
if (!mmd->bindcagecos) {
- static int recursive = 0;
-
/* progress bar redraw can make this recursive .. */
- if (!recursive) {
- /* Write binding data to original modifier. */
- Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
- Object *ob_orig = DEG_get_original_object(ob);
- MeshDeformModifierData *mmd_orig = (MeshDeformModifierData *)modifiers_findByName(
- ob_orig, mmd->modifier.name);
-
- recursive = 1;
- mmd->bindfunc(scene, mmd_orig, cagemesh, (float *)vertexCos, numVerts, cagemat);
- recursive = 0;
+ if (!recursive_bind_sentinel) {
+ if (ob != DEG_get_original_object(ob)) {
+ BLI_assert(!"Trying to bind inside of depsgraph evaluation");
+ modifier_setError(md, "Trying to bind inside of depsgraph evaluation");
+ goto finally;
+ }
+
+ recursive_bind_sentinel = 1;
+ mmd->bindfunc(mmd, cagemesh, (float *)vertexCos, numVerts, cagemat);
+ recursive_bind_sentinel = 0;
}
- return;
+ goto finally;
}
/* verify we have compatible weights */
@@ -345,18 +354,15 @@ static void meshdeformModifier_do(
if (mmd->totvert != totvert) {
modifier_setError(md, "Verts changed from %d to %d", mmd->totvert, totvert);
- if (free_cagemesh) BKE_id_free(NULL, cagemesh);
- return;
+ goto finally;
}
else if (mmd->totcagevert != totcagevert) {
modifier_setError(md, "Cage verts changed from %d to %d", mmd->totcagevert, totcagevert);
- if (free_cagemesh) BKE_id_free(NULL, cagemesh);
- return;
+ goto finally;
}
else if (mmd->bindcagecos == NULL) {
modifier_setError(md, "Bind data missing");
- if (free_cagemesh) BKE_id_free(NULL, cagemesh);
- return;
+ goto finally;
}
/* setup deformation data */
@@ -377,8 +383,9 @@ static void meshdeformModifier_do(
/* compute difference with world space bind coord */
sub_v3_v3v3(dco[a], co, bindcagecos[a]);
}
- else
+ else {
copy_v3_v3(dco[a], co);
+ }
}
MOD_get_vgroup(ob, mesh, mmd->defgrp_name, &dvert, &defgrp_index);
@@ -401,9 +408,9 @@ static void meshdeformModifier_do(
meshdeform_vert_task,
&settings);
- /* release cage mesh */
- MEM_freeN(dco);
- MEM_freeN(cagecos);
+finally:
+ MEM_SAFE_FREE(dco);
+ MEM_SAFE_FREE(cagecos);
if (cagemesh != NULL && free_cagemesh) {
BKE_id_free(NULL, cagemesh);
}
@@ -415,29 +422,29 @@ static void deformVerts(
float (*vertexCos)[3],
int numVerts)
{
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */
meshdeformModifier_do(md, ctx, mesh_src, vertexCos, numVerts);
- if (mesh_src && mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
static void deformVertsEM(
ModifierData *md, const ModifierEvalContext *ctx,
- struct BMEditMesh *UNUSED(editData),
+ struct BMEditMesh *editData,
Mesh *mesh,
float (*vertexCos)[3],
int numVerts)
{
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
meshdeformModifier_do(md, ctx, mesh_src, vertexCos, numVerts);
- if (mesh_src && mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index 6db78731683..771ccd31e22 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -151,8 +151,8 @@ static Mesh *applyModifier(
return result ? result : mesh;
#else
- return mesh;
UNUSED_VARS(ctx, md);
+ return mesh;
#endif
}
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index 659ac0dee30..d24f32accf8 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -51,6 +51,7 @@
#include "MEM_guardedalloc.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "MOD_modifiertypes.h"
@@ -85,6 +86,7 @@ static Mesh *doBiscetOnMirrorPlane(
MirrorModifierData *mmd,
Object *ob,
const Mesh *mesh,
+ Object *mirror_ob,
int axis,
float mirrormat[4][4])
{
@@ -114,10 +116,10 @@ static Mesh *doBiscetOnMirrorPlane(
float plane_no[3];
copy_v3_v3(plane_no, mirrormat[axis]);
- if (mmd->mirror_ob) {
+ if (mirror_ob != NULL) {
float tmp[4][4];
invert_m4_m4(tmp, ob->obmat);
- mul_m4_m4m4(tmp, tmp, mmd->mirror_ob->obmat);
+ mul_m4_m4m4(tmp, tmp, mirror_ob->obmat);
copy_v3_v3(plane_no, tmp[axis]);
copy_v3_v3(plane_co, tmp[3]);
@@ -151,6 +153,7 @@ static Mesh *doBiscetOnMirrorPlane(
static Mesh *doMirrorOnAxis(
MirrorModifierData *mmd,
+ const ModifierEvalContext *ctx,
Object *ob,
const Mesh *mesh,
int axis)
@@ -178,13 +181,14 @@ static Mesh *doMirrorOnAxis(
unit_m4(mtx);
mtx[axis][axis] = -1.0f;
- if (mmd->mirror_ob) {
+ Object *mirror_ob = DEG_get_evaluated_object(ctx->depsgraph, mmd->mirror_ob);
+ if (mirror_ob != NULL) {
float tmp[4][4];
float itmp[4][4];
/* tmp is a transform from coords relative to the object's own origin,
* to coords relative to the mirror object origin */
- invert_m4_m4(tmp, mmd->mirror_ob->obmat);
+ invert_m4_m4(tmp, mirror_ob->obmat);
mul_m4_m4m4(tmp, tmp, ob->obmat);
/* itmp is the reverse transform back to origin-relative coordinates */
@@ -200,7 +204,7 @@ static Mesh *doMirrorOnAxis(
Mesh *mesh_bisect = NULL;
if (do_bisect) {
- mesh_bisect = doBiscetOnMirrorPlane(mmd, ob, mesh, axis, mtx);
+ mesh_bisect = doBiscetOnMirrorPlane(mmd, ob, mesh, mirror_ob, axis, mtx);
mesh = mesh_bisect;
}
@@ -382,18 +386,18 @@ static Mesh *doMirrorOnAxis(
}
static Mesh *mirrorModifier__doMirror(
- MirrorModifierData *mmd,
+ MirrorModifierData *mmd, const ModifierEvalContext *ctx,
Object *ob, Mesh *mesh)
{
Mesh *result = mesh;
/* check which axes have been toggled and mirror accordingly */
if (mmd->flag & MOD_MIR_AXIS_X) {
- result = doMirrorOnAxis(mmd, ob, result, 0);
+ result = doMirrorOnAxis(mmd, ctx, ob, result, 0);
}
if (mmd->flag & MOD_MIR_AXIS_Y) {
Mesh *tmp = result;
- result = doMirrorOnAxis(mmd, ob, result, 1);
+ result = doMirrorOnAxis(mmd, ctx, ob, result, 1);
if (tmp != mesh) {
/* free intermediate results */
BKE_id_free(NULL, tmp);
@@ -401,7 +405,7 @@ static Mesh *mirrorModifier__doMirror(
}
if (mmd->flag & MOD_MIR_AXIS_Z) {
Mesh *tmp = result;
- result = doMirrorOnAxis(mmd, ob, result, 2);
+ result = doMirrorOnAxis(mmd, ctx, ob, result, 2);
if (tmp != mesh) {
/* free intermediate results */
BKE_id_free(NULL, tmp);
@@ -418,7 +422,7 @@ static Mesh *applyModifier(
Mesh *result;
MirrorModifierData *mmd = (MirrorModifierData *) md;
- result = mirrorModifier__doMirror(mmd, ctx->object, mesh);
+ result = mirrorModifier__doMirror(mmd, ctx, ctx->object, mesh);
if (result != mesh) {
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index 73fa7aa0e0d..fc8a376d2d7 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -67,91 +67,6 @@ static void initData(ModifierData *md)
mmd->quality = 3;
}
-#ifndef WITH_OPENSUBDIV_MODIFIER
-
-static DerivedMesh *applyModifier_DM(
- ModifierData *md, const ModifierEvalContext *ctx,
- 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;
- const bool ignore_simplify = (ctx->flag & MOD_APPLY_IGNORE_SIMPLIFY) != 0;
- MultiresFlags flags = 0;
- const bool has_mask = CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK);
-
- if (mmd->totlvl) {
- if (!CustomData_get_layer(&me->ldata, CD_MDISPS)) {
- /* multires always needs a displacement layer */
- CustomData_add_layer(&me->ldata, CD_MDISPS, CD_CALLOC, NULL, me->totloop);
- }
- }
-
- if (has_mask)
- flags |= MULTIRES_ALLOC_PAINT_MASK;
-
- if (useRenderParams)
- flags |= MULTIRES_USE_RENDER_PARAMS;
-
- if (ignore_simplify)
- flags |= MULTIRES_IGNORE_SIMPLIFY;
-
- result = multires_make_derived_from_derived(dm, mmd, scene, ctx->object, flags);
-
- if (result == dm)
- return dm;
-
- if (useRenderParams || !(ctx->flag & MOD_APPLY_USECACHE)) {
- DerivedMesh *cddm;
-
- cddm = CDDM_copy(result);
-
- /* copy hidden/masks to vertices */
- if (!useRenderParams) {
- struct MDisps *mdisps;
- struct GridPaintMask *grid_paint_mask;
-
- mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
- grid_paint_mask = CustomData_get_layer(&me->ldata, CD_GRID_PAINT_MASK);
-
- if (mdisps) {
- subsurf_copy_grid_hidden(result, me->mpoly,
- cddm->getVertArray(cddm),
- mdisps);
-
- BKE_mesh_flush_hidden_from_verts_ex(cddm->getVertArray(cddm),
- cddm->getLoopArray(cddm),
- cddm->getEdgeArray(cddm),
- cddm->getNumEdges(cddm),
- cddm->getPolyArray(cddm),
- cddm->getNumPolys(cddm));
- }
- if (grid_paint_mask) {
- float *paint_mask = CustomData_add_layer(&cddm->vertData,
- CD_PAINT_MASK,
- CD_CALLOC, NULL,
- cddm->getNumVerts(cddm));
-
- subsurf_copy_grid_paint_mask(result, me->mpoly,
- paint_mask, grid_paint_mask);
- }
- }
-
- result->release(result);
- result = cddm;
- }
-
- return result;
-}
-
-applyModifier_DM_wrapper(applyModifier, applyModifier_DM)
-
-#endif
-
-#ifdef WITH_OPENSUBDIV_MODIFIER
-
/* Subdivide into fully qualified mesh. */
static Mesh *multires_as_mesh(MultiresModifierData *mmd,
@@ -211,9 +126,9 @@ static Mesh *multires_as_ccg(MultiresModifierData *mmd,
return result;
}
-static Mesh *applyModifier_subdiv(ModifierData *md,
- const ModifierEvalContext *ctx,
- Mesh *mesh)
+static Mesh *applyModifier(ModifierData *md,
+ const ModifierEvalContext *ctx,
+ Mesh *mesh)
{
Mesh *result = mesh;
MultiresModifierData *mmd = (MultiresModifierData *)md;
@@ -247,7 +162,6 @@ static Mesh *applyModifier_subdiv(ModifierData *md,
}
return result;
}
-#endif
ModifierTypeInfo modifierType_Multires = {
/* name */ "Multires",
@@ -270,11 +184,7 @@ ModifierTypeInfo modifierType_Multires = {
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
-#ifdef WITH_OPENSUBDIV_MODIFIER
- /* applyModifier */ applyModifier_subdiv,
-#else
/* applyModifier */ applyModifier,
-#endif
/* initData */ initData,
/* requiredDataMask */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index f76acd3983d..5e5621ae717 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -42,6 +42,8 @@
#include "BKE_mesh.h"
#include "BKE_deform.h"
+#include "DEG_depsgraph_query.h"
+
#include "MOD_util.h"
@@ -193,13 +195,16 @@ static bool polygons_check_flip(
}
static void normalEditModifier_do_radial(
- NormalEditModifierData *enmd, Object *ob, Mesh *mesh,
+ NormalEditModifierData *enmd, const ModifierEvalContext *ctx,
+ Object *ob, Mesh *mesh,
short (*clnors)[2], float (*loopnors)[3], float (*polynors)[3],
const short mix_mode, const float mix_factor, const float mix_limit,
MDeformVert *dvert, const int defgrp_index, const bool use_invert_vgroup,
MVert *mvert, const int num_verts, MEdge *medge, const int num_edges,
MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys)
{
+ Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, enmd->target);
+
const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0;
int i;
@@ -209,7 +214,7 @@ static void normalEditModifier_do_radial(
BLI_bitmap *done_verts = BLI_BITMAP_NEW((size_t)num_verts, __func__);
- generate_vert_coordinates(mesh, ob, enmd->target, enmd->offset, num_verts, cos, size);
+ generate_vert_coordinates(mesh, ob, ob_target, enmd->offset, num_verts, cos, size);
/**
* size gives us our spheroid coefficients ``(A, B, C)``.
@@ -294,13 +299,16 @@ static void normalEditModifier_do_radial(
}
static void normalEditModifier_do_directional(
- NormalEditModifierData *enmd, Object *ob, Mesh *mesh,
+ NormalEditModifierData *enmd, const ModifierEvalContext *ctx,
+ Object *ob, Mesh *mesh,
short (*clnors)[2], float (*loopnors)[3], float (*polynors)[3],
const short mix_mode, const float mix_factor, const float mix_limit,
MDeformVert *dvert, const int defgrp_index, const bool use_invert_vgroup,
MVert *mvert, const int num_verts, MEdge *medge, const int num_edges,
MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys)
{
+ Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, enmd->target);
+
const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0;
const bool use_parallel_normals = (enmd->flag & MOD_NORMALEDIT_USE_DIRECTION_PARALLEL) != 0;
@@ -313,7 +321,7 @@ static void normalEditModifier_do_directional(
float mat[4][4];
invert_m4_m4(mat, ob->obmat);
- mul_m4_m4m4(mat, mat, enmd->target->obmat);
+ mul_m4_m4m4(mat, mat, ob_target->obmat);
copy_v3_v3(target_co, mat[3]);
if (use_parallel_normals) {
@@ -328,7 +336,7 @@ static void normalEditModifier_do_directional(
}
else {
float (*cos)[3] = MEM_malloc_arrayN((size_t)num_verts, sizeof(*cos), __func__);
- generate_vert_coordinates(mesh, ob, enmd->target, NULL, num_verts, cos, NULL);
+ generate_vert_coordinates(mesh, ob, ob_target, NULL, num_verts, cos, NULL);
BLI_bitmap *done_verts = BLI_BITMAP_NEW((size_t)num_verts, __func__);
MLoop *ml;
@@ -380,7 +388,8 @@ static bool is_valid_target(NormalEditModifierData *enmd)
return false;
}
-static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, Object *ob, Mesh *mesh)
+static Mesh *normalEditModifier_do(
+ NormalEditModifierData *enmd, const ModifierEvalContext *ctx, Object *ob, Mesh *mesh)
{
const bool use_invert_vgroup = ((enmd->flag & MOD_NORMALEDIT_INVERT_VGROUP) != 0);
const bool use_current_clnors = !((enmd->mix_mode == MOD_NORMALEDIT_MIX_COPY) &&
@@ -474,13 +483,13 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, Object *ob, Mes
if (enmd->mode == MOD_NORMALEDIT_MODE_RADIAL) {
normalEditModifier_do_radial(
- enmd, ob, result, clnors, loopnors, polynors,
+ enmd, ctx, ob, result, clnors, loopnors, polynors,
enmd->mix_mode, enmd->mix_factor, enmd->mix_limit, dvert, defgrp_index, use_invert_vgroup,
mvert, num_verts, medge, num_edges, mloop, num_loops, mpoly, num_polys);
}
else if (enmd->mode == MOD_NORMALEDIT_MODE_DIRECTIONAL) {
normalEditModifier_do_directional(
- enmd, ob, result, clnors, loopnors, polynors,
+ enmd, ctx, ob, result, clnors, loopnors, polynors,
enmd->mix_mode, enmd->mix_factor, enmd->mix_limit, dvert, defgrp_index, use_invert_vgroup,
mvert, num_verts, medge, num_edges, mloop, num_loops, mpoly, num_polys);
}
@@ -536,12 +545,13 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
NormalEditModifierData *enmd = (NormalEditModifierData *) md;
if (enmd->target) {
DEG_add_object_relation(ctx->node, enmd->target, DEG_OB_COMP_TRANSFORM, "NormalEdit Modifier");
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "NormalEdit Modifier");
}
}
static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
{
- return normalEditModifier_do((NormalEditModifierData *)md, ctx->object, mesh);
+ return normalEditModifier_do((NormalEditModifierData *)md, ctx, ctx->object, mesh);
}
ModifierTypeInfo modifierType_NormalEdit = {
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index 2d5b520e9ca..0a5b34c90ee 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -499,7 +499,7 @@ static Mesh *applyModifier(
const int ml_index = (ml - mloop);
if (mloopcols_index != NULL) {
const int part_index = vert_part_index[ml->v];
- store_float_in_vcol(&mloopcols_index[ml_index], (float)part_index / psys->totpart);
+ store_float_in_vcol(&mloopcols_index[ml_index], (float)part_index / (float)(psys->totpart - 1));
}
if (mloopcols_value != NULL) {
const float part_value = vert_part_value[ml->v];
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 1c967d4ead3..bc1fb300cac 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -104,7 +104,7 @@ static void deformVerts(
ModifierData *md, const ModifierEvalContext *ctx,
Mesh *mesh,
float (*vertexCos)[3],
- int UNUSED(numVerts))
+ int numVerts)
{
Mesh *mesh_src = mesh;
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
@@ -120,7 +120,7 @@ static void deformVerts(
return;
if (mesh_src == NULL) {
- mesh_src = MOD_get_mesh_eval(ctx->object, NULL, NULL, vertexCos, false, true);
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, vertexCos, numVerts, false, true);
if (mesh_src == NULL) {
return;
}
@@ -141,7 +141,7 @@ static void deformVerts(
}
else {
/* no dm before, so recalc particles fully */
- psys->recalc |= PSYS_RECALC_RESET;
+ psys->recalc |= ID_RECALC_PSYS_RESET;
}
/* make new mesh */
@@ -192,7 +192,7 @@ static void deformVerts(
psmd->mesh_final->totedge != psmd->totdmedge ||
psmd->mesh_final->totface != psmd->totdmface)
{
- psys->recalc |= PSYS_RECALC_RESET;
+ psys->recalc |= ID_RECALC_PSYS_RESET;
psmd->totdmvert = psmd->mesh_final->totvert;
psmd->totdmedge = psmd->mesh_final->totedge;
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index c59be8151d4..2c795a8d9ad 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -49,6 +49,7 @@
#include "BKE_mesh.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "MOD_modifiertypes.h"
#include "MEM_guardedalloc.h"
@@ -245,6 +246,8 @@ static Mesh *applyModifier(
MEdge *medge_orig, *med_orig, *med_new, *med_new_firstloop, *medge_new;
MVert *mvert_new, *mvert_orig, *mv_orig, *mv_new, *mv_new_base;
+ Object *ob_axis = DEG_get_evaluated_object(ctx->depsgraph, ltmd->ob_axis);
+
ScrewVertConnect *vc, *vc_tmp, *vert_connect = NULL;
const char mpoly_flag = (ltmd->flag & MOD_SCREW_SMOOTH_SHADING) ? ME_SMOOTH : 0;
@@ -270,10 +273,10 @@ static Mesh *applyModifier(
axis_vec[ltmd->axis] = 1.0f;
- if (ltmd->ob_axis) {
+ if (ob_axis != NULL) {
/* calc the matrix relative to the axis object */
invert_m4_m4(mtx_tmp_a, ctx->object->obmat);
- copy_m4_m4(mtx_tx_inv, ltmd->ob_axis->obmat);
+ copy_m4_m4(mtx_tx_inv, ob_axis->obmat);
mul_m4_m4m4(mtx_tx, mtx_tmp_a, mtx_tx_inv);
/* calc the axis vec */
@@ -508,7 +511,7 @@ static Mesh *applyModifier(
med_new = medge_new;
mv_new = mvert_new;
- if (ltmd->ob_axis) {
+ if (ob_axis != NULL) {
/*mtx_tx is initialized early on */
for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) {
vc->co[0] = mv_new->co[0] = mv_orig->co[0];
@@ -839,7 +842,7 @@ static Mesh *applyModifier(
/* Rotation Matrix */
step_angle = (angle / (float)(step_tot - (!close))) * (float)step;
- if (ltmd->ob_axis) {
+ if (ob_axis != NULL) {
axis_angle_normalized_to_mat3(mat3, axis_vec, step_angle);
}
else {
@@ -871,7 +874,7 @@ static Mesh *applyModifier(
/* only need to set these if using non cleared memory */
/*mv_new->mat_nr = mv_new->flag = 0;*/
- if (ltmd->ob_axis) {
+ if (ob_axis != NULL) {
sub_v3_v3(mv_new->co, mtx_tx[3]);
mul_m4_v3(mat, mv_new->co);
@@ -1098,7 +1101,7 @@ static Mesh *applyModifier(
Mesh *result_prev = result;
result = mesh_remove_doubles_on_axis(
result, mvert_new, totvert, step_tot,
- axis_vec, ltmd->ob_axis ? mtx_tx[3] : NULL, ltmd->merge_dist);
+ axis_vec, ob_axis != NULL ? mtx_tx[3] : NULL, ltmd->merge_dist);
if (result != result_prev) {
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
}
@@ -1116,6 +1119,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
ScrewModifierData *ltmd = (ScrewModifierData *)md;
if (ltmd->ob_axis != NULL) {
DEG_add_object_relation(ctx->node, ltmd->ob_axis, DEG_OB_COMP_TRANSFORM, "Screw Modifier");
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Screw Modifier");
}
}
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index 477c11039db..92cbbaa78ca 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -105,16 +105,24 @@ static void deformVerts(
float (*vertexCos)[3],
int numVerts)
{
+ ShrinkwrapModifierData *swmd = (ShrinkwrapModifierData *)md;
struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
- Mesh *mesh_src = mesh;
+ Mesh *mesh_src = NULL;
- if (mesh_src == NULL && ctx->object->type == OB_MESH) {
- mesh_src = ctx->object->data;
+ if (ctx->object->type == OB_MESH) {
+ /* mesh_src is only needed for vgroups. */
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
}
- BLI_assert(mesh_src == NULL || mesh_src->totvert == numVerts);
+ struct MDeformVert *dvert = NULL;
+ int defgrp_index = -1;
+ MOD_get_vgroup(ctx->object, mesh_src, swmd->vgroup_name, &dvert, &defgrp_index);
- shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, scene, ctx->object, mesh_src, vertexCos, numVerts);
+ shrinkwrapModifier_deform(swmd, ctx, scene, ctx->object, mesh_src, dvert, defgrp_index, vertexCos, numVerts);
+
+ if (!ELEM(mesh_src, NULL, mesh)) {
+ BKE_id_free(NULL, mesh_src);
+ }
}
static void deformVertsEM(
@@ -122,18 +130,17 @@ static void deformVertsEM(
struct BMEditMesh *editData, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
+ ShrinkwrapModifierData *swmd = (ShrinkwrapModifierData *)md;
struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
- Mesh *mesh_src = mesh;
-
- if (mesh_src == NULL) {
- mesh_src = BKE_mesh_from_bmesh_for_eval_nomain(editData->bm, 0);
- }
+ Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
- BLI_assert(mesh_src->totvert == numVerts);
+ struct MDeformVert *dvert = NULL;
+ int defgrp_index = -1;
+ MOD_get_vgroup(ctx->object, mesh_src, swmd->vgroup_name, &dvert, &defgrp_index);
- shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, scene, ctx->object, mesh_src, vertexCos, numVerts);
+ shrinkwrapModifier_deform(swmd, ctx, scene, ctx->object, mesh_src, dvert, defgrp_index, vertexCos, numVerts);
- if (!mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
@@ -149,14 +156,16 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
if (smd->target != NULL) {
DEG_add_object_relation(ctx->node, smd->target, DEG_OB_COMP_TRANSFORM, "Shrinkwrap Modifier");
- DEG_add_object_relation_with_customdata(ctx->node, smd->target, DEG_OB_COMP_GEOMETRY, mask, "Shrinkwrap Modifier");
+ DEG_add_object_relation(ctx->node, smd->target, DEG_OB_COMP_GEOMETRY, "Shrinkwrap Modifier");
+ DEG_add_customdata_mask(ctx->node, smd->target, mask);
if (smd->shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
DEG_add_special_eval_flag(ctx->node, &smd->target->id, DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY);
}
}
if (smd->auxTarget != NULL) {
DEG_add_object_relation(ctx->node, smd->auxTarget, DEG_OB_COMP_TRANSFORM, "Shrinkwrap Modifier");
- DEG_add_object_relation_with_customdata(ctx->node, smd->auxTarget, DEG_OB_COMP_GEOMETRY, mask, "Shrinkwrap Modifier");
+ DEG_add_object_relation(ctx->node, smd->auxTarget, DEG_OB_COMP_GEOMETRY, "Shrinkwrap Modifier");
+ DEG_add_customdata_mask(ctx->node, smd->auxTarget, mask);
if (smd->shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
DEG_add_special_eval_flag(ctx->node, &smd->auxTarget->id, DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY);
}
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index 86791e5bcbe..33a585e5324 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -46,6 +46,8 @@
#include "BKE_modifier.h"
#include "BKE_deform.h"
+#include "DEG_depsgraph_query.h"
+
#include "MOD_util.h"
#include "bmesh.h"
@@ -186,7 +188,8 @@ static void simpleDeform_bend(const float factor, const int axis, const float dc
/* simple deform modifier */
static void SimpleDeformModifier_do(
- SimpleDeformModifierData *smd, struct Object *ob, struct Mesh *mesh,
+ SimpleDeformModifierData *smd, const ModifierEvalContext *ctx,
+ struct Object *ob, struct Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
const float base_limit[2] = {0.0f, 0.0f};
@@ -227,9 +230,9 @@ static void SimpleDeformModifier_do(
smd->limit[0] = min_ff(smd->limit[0], smd->limit[1]); /* Upper limit >= than lower limit */
/* Calculate matrixs do convert between coordinate spaces */
- if (smd->origin) {
+ if (smd->origin != NULL) {
transf = &tmp_transf;
- BLI_SPACE_TRANSFORM_SETUP(transf, ob, smd->origin);
+ BLI_SPACE_TRANSFORM_SETUP(transf, ob, DEG_get_evaluated_object(ctx->depsgraph, smd->origin));
}
/* Update limits if needed */
@@ -376,6 +379,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md;
if (smd->origin != NULL) {
DEG_add_object_relation(ctx->node, smd->origin, DEG_OB_COMP_TRANSFORM, "SimpleDeform Modifier");
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "SimpleDeform Modifier");
}
}
@@ -385,11 +389,17 @@ static void deformVerts(
float (*vertexCos)[3],
int numVerts)
{
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ SimpleDeformModifierData *sdmd = (SimpleDeformModifierData *)md;
+ Mesh *mesh_src = NULL;
+
+ if (ctx->object->type == OB_MESH && sdmd->vgroup_name[0] != '\0') {
+ /* mesh_src is only needed for vgroups. */
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
+ }
- SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts);
+ SimpleDeformModifier_do(sdmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
- if (mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
@@ -401,11 +411,17 @@ static void deformVertsEM(
float (*vertexCos)[3],
int numVerts)
{
- Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, editData, mesh, NULL, false, false);
+ SimpleDeformModifierData *sdmd = (SimpleDeformModifierData *)md;
+ Mesh *mesh_src = NULL;
+
+ if (ctx->object->type == OB_MESH && sdmd->vgroup_name[0] != '\0') {
+ /* mesh_src is only needed for vgroups. */
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
+ }
- SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts);
+ SimpleDeformModifier_do(sdmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
- if (mesh_src != mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index 100d49f1c89..8b62c2c1d7d 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -109,7 +109,7 @@ static void smoothModifier_do(
fac = smd->fac;
facm = 1 - fac;
- if (mesh->totvert == numVerts) {
+ if (mesh != NULL) {
medges = mesh->medge;
numDMEdges = mesh->totedge;
}
@@ -213,34 +213,32 @@ static void deformVerts(
ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
- Mesh *mesh_src = mesh;
+ SmoothModifierData *smd = (SmoothModifierData *)md;
+ Mesh *mesh_src = NULL;
- if (mesh_src == NULL) {
- mesh_src = ctx->object->data;
- }
+ /* mesh_src is needed for vgroups, and taking edges into account. */
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
- BLI_assert(mesh_src->totvert == numVerts);
+ smoothModifier_do(smd, ctx->object, mesh_src, vertexCos, numVerts);
- smoothModifier_do((SmoothModifierData *)md, ctx->object, mesh_src,
- vertexCos, numVerts);
+ if (!ELEM(mesh_src, NULL, mesh)) {
+ BKE_id_free(NULL, mesh_src);
+ }
}
static void deformVertsEM(
ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData,
Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
- Mesh *mesh_src = mesh;
-
- if (mesh_src == NULL) {
- mesh_src = BKE_mesh_from_bmesh_for_eval_nomain(editData->bm, 0);
- }
+ SmoothModifierData *smd = (SmoothModifierData *)md;
+ Mesh *mesh_src = NULL;
- BLI_assert(mesh_src->totvert == numVerts);
+ /* mesh_src is needed for vgroups, and taking edges into account. */
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
- smoothModifier_do((SmoothModifierData *)md, ctx->object, mesh_src,
- vertexCos, numVerts);
+ smoothModifier_do(smd, ctx->object, mesh_src, vertexCos, numVerts);
- if (!mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index dee9089d7d3..e66b3fdbafb 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -99,47 +99,6 @@ static bool isDisabled(const Scene *scene, ModifierData *md, bool useRenderParam
return get_render_subsurf_level(&scene->r, levels, useRenderParams != 0) == 0;
}
-#ifndef WITH_OPENSUBDIV_MODIFIER
-
-static DerivedMesh *applyModifier_DM(
- ModifierData *md, const ModifierEvalContext *ctx,
- 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;
- const bool isFinalCalc = (ctx->flag & MOD_APPLY_USECACHE) != 0;
-
- bool do_cddm_convert = useRenderParams || !isFinalCalc;
-
- if (useRenderParams)
- subsurf_flags |= SUBSURF_USE_RENDER_PARAMS;
- if (isFinalCalc)
- subsurf_flags |= SUBSURF_IS_FINAL_CALC;
- if (ctx->object->mode & OB_MODE_EDIT)
- subsurf_flags |= SUBSURF_IN_EDIT_MODE;
-
- result = subsurf_make_derived_from_derived(derivedData, smd, scene, NULL, subsurf_flags);
- result->cd_flag = derivedData->cd_flag;
-
- {
- DerivedMesh *cddm = CDDM_copy(result);
- result->release(result);
- result = cddm;
- }
-
- (void) do_cddm_convert;
-
- return result;
-}
-
-applyModifier_DM_wrapper(applyModifier, applyModifier_DM)
-
-#endif
-
-#ifdef WITH_OPENSUBDIV_MODIFIER
static int subdiv_levels_for_modifier_get(const SubsurfModifierData *smd,
const ModifierEvalContext *ctx)
{
@@ -156,8 +115,8 @@ static void subdiv_settings_init(SubdivSettings *settings,
const SubsurfModifierData *smd)
{
settings->is_simple = (smd->subdivType == SUBSURF_TYPE_SIMPLE);
- settings->is_adaptive = !settings->is_simple;
- settings->level = smd->quality;
+ settings->is_adaptive = true;
+ settings->level = settings->is_simple ? 1 : smd->quality;
settings->vtx_boundary_interpolation = SUBDIV_VTX_BOUNDARY_EDGE_ONLY;
settings->fvar_linear_interpolation =
BKE_subdiv_fvar_interpolation_from_uv_smooth(smd->uv_smooth);
@@ -171,6 +130,8 @@ static void subdiv_mesh_settings_init(SubdivToMeshSettings *settings,
{
const int level = subdiv_levels_for_modifier_get(smd, ctx);
settings->resolution = (1 << level) + 1;
+ settings->use_optimal_display =
+ (smd->flags & eSubsurfModifierFlag_ControlEdges);
}
static Mesh *subdiv_as_mesh(SubsurfModifierData *smd,
@@ -217,9 +178,9 @@ static Mesh *subdiv_as_ccg(SubsurfModifierData *smd,
/* Modifier itself. */
-static Mesh *applyModifier_subdiv(ModifierData *md,
- const ModifierEvalContext *ctx,
- Mesh *mesh)
+static Mesh *applyModifier(ModifierData *md,
+ const ModifierEvalContext *ctx,
+ Mesh *mesh)
{
Mesh *result = mesh;
SubsurfModifierData *smd = (SubsurfModifierData *) md;
@@ -248,7 +209,6 @@ static Mesh *applyModifier_subdiv(ModifierData *md,
BKE_subdiv_free(subdiv);
return result;
}
-#endif
ModifierTypeInfo modifierType_Subsurf = {
/* name */ "Subdivision",
@@ -273,11 +233,7 @@ ModifierTypeInfo modifierType_Subsurf = {
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
-#ifdef WITH_OPENSUBDIV_MODIFIER
- /* applyModifier */ applyModifier_subdiv,
-#else
/* applyModifier */ applyModifier,
-#endif
/* initData */ initData,
/* requiredDataMask */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c
index f445e8d9de9..c5fa510f2e0 100644
--- a/source/blender/modifiers/intern/MOD_surface.c
+++ b/source/blender/modifiers/intern/MOD_surface.c
@@ -91,7 +91,7 @@ static void deformVerts(
ModifierData *md, const ModifierEvalContext *ctx,
Mesh *mesh,
float (*vertexCos)[3],
- int UNUSED(numVerts))
+ int numVerts)
{
SurfaceModifierData *surmd = (SurfaceModifierData *) md;
const int cfra = (int)DEG_get_ctime(ctx->depsgraph);
@@ -111,7 +111,9 @@ static void deformVerts(
LIB_ID_COPY_NO_PREVIEW,
false);
}
- else surmd->mesh = MOD_get_mesh_eval(ctx->object, NULL, NULL, NULL, false, false);
+ else {
+ surmd->mesh = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, numVerts, false, false);
+ }
if (!ctx->object->pd) {
printf("SurfaceModifier deformVerts: Should not happen!\n");
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 18bee0d2d59..d4781e419cf 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -16,6 +16,7 @@
#include "BKE_modifier.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "MEM_guardedalloc.h"
@@ -1100,7 +1101,7 @@ static void deformVert(
static void surfacedeformModifier_do(
ModifierData *md,
- const ModifierEvalContext *UNUSED(ctx),
+ const ModifierEvalContext *ctx,
float (*vertexCos)[3], unsigned int numverts, Object *ob)
{
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
@@ -1108,13 +1109,32 @@ static void surfacedeformModifier_do(
Mesh *target;
unsigned int tnumverts, tnumpoly;
- /* Exit function if bind flag is not set (free bind data if any) */
+ /* Exit function if bind flag is not set (free bind data if any). */
if (!(smd->flags & MOD_SDEF_BIND)) {
- freeData(md);
+ /* Note: with new CoW system, we expect unbinding to be done by a special call from main thread,
+ * outside of depsgraph evaluation (see object_force_modifier_update_for_bind() in object_modifier.c). */
+ if (smd->verts != NULL) {
+ if (ob != DEG_get_original_object(ob)) {
+ BLI_assert(!"Trying to unbind inside of depsgraph evaluation");
+ modifier_setError(md, "Trying to unbind inside of depsgraph evaluation");
+ }
+ else {
+ freeData(md);
+ }
+ }
return;
}
- target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(smd->target, &free_target);
+ Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, smd->target);
+ target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, &free_target);
+#if 0 /* Should not be needed anymore since we always get that mesh from eval object ? */
+ if (target == NULL && smd->verts == NULL && ob == DEG_get_original_object(ob)) {
+ /* Special case, binding happens outside of depsgraph evaluation, so we can build our own
+ * target mesh if needed. */
+ target = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), smd->target, 0);
+ free_target = target != NULL;
+ }
+#endif
if (!target) {
modifier_setError(md, "No valid target mesh");
return;
@@ -1123,29 +1143,35 @@ static void surfacedeformModifier_do(
tnumverts = target->totvert;
tnumpoly = target->totpoly;
- /* If not bound, execute bind */
- if (!(smd->verts)) {
+ /* If not bound, execute bind. */
+ /* Note: with new CoW system, we expect binding to be done by a special call from main thread,
+ * outside of depsgraph evaluation (see object_force_modifier_update_for_bind() in object_modifier.c). */
+ if (smd->verts == NULL) {
+ if (ob != DEG_get_original_object(ob)) {
+ BLI_assert(!"Trying to bind inside of depsgraph evaluation");
+ modifier_setError(md, "Trying to bind inside of depsgraph evaluation");
+ goto finally;
+ }
float tmp_mat[4][4];
invert_m4_m4(tmp_mat, ob->obmat);
- mul_m4_m4m4(smd->mat, tmp_mat, smd->target->obmat);
+ mul_m4_m4m4(smd->mat, tmp_mat, ob_target->obmat);
if (!surfacedeformBind(smd, vertexCos, numverts, tnumpoly, tnumverts, target)) {
smd->flags &= ~MOD_SDEF_BIND;
- return;
}
+ /* Early abort, this is binding 'call', no need to perform whole evaluation. */
+ goto finally;
}
/* Poly count checks */
if (smd->numverts != numverts) {
modifier_setError(md, "Verts changed from %u to %u", smd->numverts, numverts);
- if (free_target) BKE_id_free(NULL, target);
- return;
+ goto finally;
}
else if (smd->numpoly != tnumpoly) {
modifier_setError(md, "Target polygons changed from %u to %u", smd->numpoly, tnumpoly);
- if (free_target) BKE_id_free(NULL, target);
- return;
+ goto finally;
}
/* Actual vertex location update starts here */
@@ -1173,6 +1199,7 @@ static void surfacedeformModifier_do(
MEM_freeN(data.targetCos);
}
+finally:
if (target != NULL && free_target) {
BKE_id_free(NULL, target);
}
@@ -1199,7 +1226,7 @@ static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED
{
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
- return !smd->target && !(smd->verts && !(smd->flags & MOD_SDEF_BIND));
+ return smd->target == NULL && !(smd->verts != NULL && !(smd->flags & MOD_SDEF_BIND));
}
ModifierTypeInfo modifierType_SurfaceDeform = {
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index be79ed0d129..ffd75e98ab5 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -63,13 +63,16 @@
#include "bmesh.h"
-void MOD_init_texture(const Depsgraph *depsgraph, Tex *tex)
+void MOD_init_texture(MappingInfoModifierData *dmd, const ModifierEvalContext *ctx)
{
- if (!tex)
+ Tex *tex = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &dmd->texture->id);
+
+ if (tex == NULL) {
return;
+ }
if (tex->ima && BKE_image_is_animated(tex->ima)) {
- BKE_image_user_frame_calc(&tex->iuser, DEG_get_ctime(depsgraph));
+ BKE_image_user_frame_calc(&tex->iuser, DEG_get_ctime(ctx->depsgraph));
}
}
@@ -77,6 +80,7 @@ void MOD_init_texture(const Depsgraph *depsgraph, Tex *tex)
/** \param cos may be NULL, in which case we use directly mesh vertices' coordinates. */
void MOD_get_texture_coords(
MappingInfoModifierData *dmd,
+ const ModifierEvalContext *ctx,
Object *ob,
Mesh *mesh,
float (*cos)[3],
@@ -88,10 +92,13 @@ void MOD_get_texture_coords(
float mapob_imat[4][4];
if (texmapping == MOD_DISP_MAP_OBJECT) {
- if (dmd->map_object)
- invert_m4_m4(mapob_imat, dmd->map_object->obmat);
- else /* if there is no map object, default to local */
+ if (dmd->map_object != NULL) {
+ Object *map_object = DEG_get_evaluated_object(ctx->depsgraph, dmd->map_object);
+ invert_m4_m4(mapob_imat, map_object->obmat);
+ }
+ else {/* if there is no map object, default to local */
texmapping = MOD_DISP_MAP_LOCAL;
+ }
}
/* UVs need special handling, since they come from faces */
@@ -168,11 +175,12 @@ void MOD_previous_vcos_store(ModifierData *md, float (*vertexCos)[3])
}
/* returns a mesh if mesh == NULL, for deforming modifiers that need it */
-Mesh *MOD_get_mesh_eval(
+Mesh *MOD_deform_mesh_eval_get(
Object *ob, struct BMEditMesh *em, Mesh *mesh,
- float (*vertexCos)[3], bool use_normals, bool use_orco)
+ float (*vertexCos)[3], const int num_verts,
+ const bool use_normals, const bool use_orco)
{
- if (mesh) {
+ if (mesh != NULL) {
/* pass */
}
else if (ob->type == OB_MESH) {
@@ -207,6 +215,13 @@ Mesh *MOD_get_mesh_eval(
else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
/* TODO(sybren): get evaluated mesh from depsgraph once that's properly generated for curves. */
mesh = BKE_mesh_new_nomain_from_curve(ob);
+
+ /* Currently, that may not be the case everytime
+ * (texts e.g. tend to give issues, also when deforming curve points instead of generated curve geometry... ). */
+ if (mesh != NULL && mesh->totvert != num_verts) {
+ BKE_id_free(NULL, mesh);
+ mesh = NULL;
+ }
}
if (use_normals) {
@@ -215,6 +230,8 @@ Mesh *MOD_get_mesh_eval(
}
}
+ BLI_assert(mesh == NULL || mesh->totvert == num_verts);
+
return mesh;
}
diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h
index bb15fc32b6b..9a444046bd9 100644
--- a/source/blender/modifiers/intern/MOD_util.h
+++ b/source/blender/modifiers/intern/MOD_util.h
@@ -33,17 +33,18 @@
#include "DEG_depsgraph_build.h"
-struct Depsgraph;
struct MDeformVert;
struct Mesh;
struct ModifierData;
+struct ModifierEvalContext;
struct Object;
struct Scene;
struct Tex;
-void MOD_init_texture(const struct Depsgraph *depsgraph, struct Tex *texture);
+void MOD_init_texture(struct MappingInfoModifierData *dmd, const struct ModifierEvalContext *ctx);
void MOD_get_texture_coords(
struct MappingInfoModifierData *dmd,
+ const struct ModifierEvalContext *ctx,
struct Object *ob,
struct Mesh *mesh,
float (*cos)[3],
@@ -51,9 +52,10 @@ void MOD_get_texture_coords(
void MOD_previous_vcos_store(struct ModifierData *md, float (*vertexCos)[3]);
-struct Mesh *MOD_get_mesh_eval(
+struct Mesh *MOD_deform_mesh_eval_get(
struct Object *ob, struct BMEditMesh *em, struct Mesh *mesh,
- float (*vertexCos)[3], bool use_normals, bool use_orco);
+ float (*vertexCos)[3], const int num_verts,
+ const bool use_normals, const bool use_orco);
void MOD_get_vgroup(
struct Object *ob, struct Mesh *mesh,
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 3aaf67792c6..0da96ba1a38 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -104,12 +104,16 @@ static void foreachIDLink(
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
{
UVProjectModifierData *umd = (UVProjectModifierData *)md;
- int i;
- for (i = 0; i < umd->num_projectors; ++i) {
+ bool do_add_own_transform = false;
+ for (int i = 0; i < umd->num_projectors; ++i) {
if (umd->projectors[i] != NULL) {
DEG_add_object_relation(ctx->node, umd->projectors[i], DEG_OB_COMP_TRANSFORM, "UV Project Modifier");
+ do_add_own_transform = true;
}
}
+ if (do_add_own_transform) {
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "UV Project Modifier");
+ }
}
typedef struct Projector {
@@ -121,6 +125,7 @@ typedef struct Projector {
static Mesh *uvprojectModifier_do(
UVProjectModifierData *umd,
+ const ModifierEvalContext *ctx,
Object *ob, Mesh *mesh)
{
float (*coords)[3], (*co)[3];
@@ -137,11 +142,14 @@ static Mesh *uvprojectModifier_do(
float scay = umd->scaley ? umd->scaley : 1.0f;
int free_uci = 0;
- for (i = 0; i < umd->num_projectors; ++i)
- if (umd->projectors[i])
- projectors[num_projectors++].ob = umd->projectors[i];
+ for (i = 0; i < umd->num_projectors; ++i) {
+ if (umd->projectors[i] != NULL) {
+ projectors[num_projectors++].ob = DEG_get_evaluated_object(ctx->depsgraph, umd->projectors[i]);
+ }
+ }
- if (num_projectors == 0) return mesh;
+ if (num_projectors == 0)
+ return mesh;
/* make sure there are UV Maps available */
@@ -313,7 +321,7 @@ static Mesh *applyModifier(
Mesh *result;
UVProjectModifierData *umd = (UVProjectModifierData *) md;
- result = uvprojectModifier_do(umd, ctx->object, mesh);
+ result = uvprojectModifier_do(umd, ctx, ctx->object, mesh);
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index f92056d503f..c051f51facc 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -40,6 +40,8 @@
#include "BKE_library_query.h"
#include "BKE_modifier.h"
+#include "DEG_depsgraph_query.h"
+
#include "MOD_util.h"
@@ -167,8 +169,8 @@ static Mesh *applyModifier(
}
/* make sure anything moving UVs is available */
- matrix_from_obj_pchan(mat_src, umd->object_src, umd->bone_src);
- matrix_from_obj_pchan(mat_dst, umd->object_dst, umd->bone_dst);
+ matrix_from_obj_pchan(mat_src, DEG_get_evaluated_object(ctx->depsgraph, umd->object_src), umd->bone_src);
+ matrix_from_obj_pchan(mat_dst, DEG_get_evaluated_object(ctx->depsgraph, umd->object_dst), umd->bone_dst);
invert_m4_m4(imat_dst, mat_dst);
mul_m4_m4m4(warp_mat, imat_dst, mat_src);
@@ -244,6 +246,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
uv_warp_deps_object_bone_new(ctx->node, umd->object_src, umd->bone_src);
uv_warp_deps_object_bone_new(ctx->node, umd->object_dst, umd->bone_dst);
+
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "UVWarp Modifier");
}
ModifierTypeInfo modifierType_UVWarp = {
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index bc516b8e798..cf59c81dcf4 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -143,12 +143,16 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
WarpModifierData *wmd = (WarpModifierData *) md;
if (wmd->object_from != NULL && wmd->object_to != NULL) {
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Warplace Modifier");
DEG_add_object_relation(ctx->node, wmd->object_from, DEG_OB_COMP_TRANSFORM, "Warp Modifier from");
DEG_add_object_relation(ctx->node, wmd->object_to, DEG_OB_COMP_TRANSFORM, "Warp Modifier to");
}
if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != NULL) {
DEG_add_object_relation(ctx->node, wmd->map_object, DEG_OB_COMP_TRANSFORM, "Warp Modifier map");
}
+ if (wmd->texture != NULL) {
+ DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Warp Modifier");
+ }
}
static void warpModifier_do(
@@ -156,7 +160,6 @@ static void warpModifier_do(
Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
Object *ob = ctx->object;
- Depsgraph *depsgraph = ctx->depsgraph;
float obinv[4][4];
float mat_from[4][4];
float mat_from_inv[4][4];
@@ -192,8 +195,8 @@ static void warpModifier_do(
invert_m4_m4(obinv, ob->obmat);
- mul_m4_m4m4(mat_from, obinv, wmd->object_from->obmat);
- mul_m4_m4m4(mat_to, obinv, wmd->object_to->obmat);
+ mul_m4_m4m4(mat_from, obinv, DEG_get_evaluated_object(ctx->depsgraph, wmd->object_from)->obmat);
+ mul_m4_m4m4(mat_to, obinv, DEG_get_evaluated_object(ctx->depsgraph, wmd->object_to)->obmat);
invert_m4_m4(tmat, mat_from); // swap?
mul_m4_m4m4(mat_final, tmat, mat_to);
@@ -214,11 +217,12 @@ static void warpModifier_do(
}
weight = strength;
- if (wmd->texture) {
+ Tex *tex_target = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &wmd->texture->id);
+ if (mesh != NULL && tex_target != NULL) {
tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co), "warpModifier_do tex_co");
- MOD_get_texture_coords((MappingInfoModifierData *)wmd, ob, mesh, vertexCos, tex_co);
+ MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co);
- MOD_init_texture(depsgraph, wmd->texture);
+ MOD_init_texture((MappingInfoModifierData *)wmd, ctx);
}
for (i = 0; i < numVerts; i++) {
@@ -275,7 +279,7 @@ static void warpModifier_do(
struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
TexResult texres;
texres.nor = NULL;
- BKE_texture_get_value(scene, wmd->texture, tex_co[i], &texres, false);
+ BKE_texture_get_value(scene, tex_target, tex_co[i], &texres, false);
fac *= texres.tin;
}
@@ -314,32 +318,36 @@ static void deformVerts(
ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
- Mesh *mesh_src = mesh;
+ WarpModifierData *wmd = (WarpModifierData *)md;
+ Mesh *mesh_src = NULL;
- if (mesh_src == NULL) {
- mesh_src = ctx->object->data;
+ if (wmd->defgrp_name[0] != '\0' || wmd->texture != NULL) {
+ /* mesh_src is only needed for vgroups and textures. */
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
}
- BLI_assert(mesh_src->totvert == numVerts);
+ warpModifier_do(wmd, ctx, mesh_src, vertexCos, numVerts);
- warpModifier_do((WarpModifierData *)md, ctx, mesh_src, vertexCos, numVerts);
+ if (!ELEM(mesh_src, NULL, mesh)) {
+ BKE_id_free(NULL, mesh_src);
+ }
}
static void deformVertsEM(
ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *em,
Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
- Mesh *mesh_src = mesh;
+ WarpModifierData *wmd = (WarpModifierData *)md;
+ Mesh *mesh_src = NULL;
- if (mesh_src == NULL) {
- mesh_src = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, 0);
+ if (wmd->defgrp_name[0] != '\0' || wmd->texture != NULL) {
+ /* mesh_src is only needed for vgroups and textures. */
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, numVerts, false, false);
}
- BLI_assert(mesh_src->totvert == numVerts);
-
- warpModifier_do((WarpModifierData *)md, ctx, mesh_src, vertexCos, numVerts);
+ warpModifier_do(wmd, ctx, mesh_src, vertexCos, numVerts);
- if (!mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index ea09b6400cf..cc3035d3d9b 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -123,6 +123,12 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
if (wmd->map_object != NULL) {
DEG_add_object_relation(ctx->node, wmd->map_object, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
}
+ if (wmd->objectcenter != NULL || wmd->map_object != NULL) {
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
+ }
+ if (wmd->texture != NULL) {
+ DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Wave Modifier");
+ }
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
@@ -142,9 +148,16 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
+static bool dependsOnNormals(ModifierData *md)
+{
+ WaveModifierData *wmd = (WaveModifierData *)md;
+
+ return (wmd->flag & MOD_WAVE_NORM) != 0;
+}
+
static void waveModifier_do(
WaveModifierData *md,
- Depsgraph *depsgraph,
+ const ModifierEvalContext *ctx,
Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
@@ -152,7 +165,7 @@ static void waveModifier_do(
MVert *mvert = NULL;
MDeformVert *dvert;
int defgrp_index;
- float ctime = DEG_get_ctime(depsgraph);
+ float ctime = DEG_get_ctime(ctx->depsgraph);
float minfac = (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow));
float lifefac = wmd->height;
float (*tex_co)[3] = NULL;
@@ -160,14 +173,15 @@ static void waveModifier_do(
const float falloff = wmd->falloff;
float falloff_fac = 1.0f; /* when falloff == 0.0f this stays at 1.0f */
- if ((wmd->flag & MOD_WAVE_NORM) && (ob->type == OB_MESH))
+ if ((wmd->flag & MOD_WAVE_NORM) && (mesh != NULL)) {
mvert = mesh->mvert;
+ }
- if (wmd->objectcenter) {
+ if (wmd->objectcenter != NULL) {
float mat[4][4];
/* get the control object's location in local coordinates */
invert_m4_m4(ob->imat, ob->obmat);
- mul_m4_m4m4(mat, ob->imat, wmd->objectcenter->obmat);
+ mul_m4_m4m4(mat, ob->imat, DEG_get_evaluated_object(ctx->depsgraph, wmd->objectcenter)->obmat);
wmd->startx = mat[3][0];
wmd->starty = mat[3][1];
@@ -176,7 +190,9 @@ static void waveModifier_do(
/* get the index of the deform group */
MOD_get_vgroup(ob, mesh, wmd->defgrp_name, &dvert, &defgrp_index);
- if (wmd->damp == 0) wmd->damp = 10.0f;
+ if (wmd->damp == 0.0f) {
+ wmd->damp = 10.0f;
+ }
if (wmd->lifetime != 0.0f) {
float x = ctime - wmd->timeoffs;
@@ -189,17 +205,17 @@ static void waveModifier_do(
}
}
- if (wmd->texture) {
- tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co),
- "waveModifier_do tex_co");
- MOD_get_texture_coords((MappingInfoModifierData *)wmd, ob, mesh, vertexCos, tex_co);
+ Tex *tex_target = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &wmd->texture->id);
+ if (mesh != NULL && tex_target != NULL) {
+ tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co), "waveModifier_do tex_co");
+ MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co);
- MOD_init_texture(depsgraph, wmd->texture);
+ MOD_init_texture((MappingInfoModifierData *)wmd, ctx);
}
if (lifefac != 0.0f) {
/* avoid divide by zero checks within the loop */
- float falloff_inv = falloff ? 1.0f / falloff : 1.0f;
+ float falloff_inv = falloff != 0.0f ? 1.0f / falloff : 1.0f;
int i;
for (i = 0; i < numVerts; i++) {
@@ -264,11 +280,11 @@ static void waveModifier_do(
amplit = (float)(1.0f / expf(amplit * amplit) - minfac);
/*apply texture*/
- if (wmd->texture) {
- Scene *scene = DEG_get_evaluated_scene(depsgraph);
+ if (tex_target) {
+ Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
TexResult texres;
texres.nor = NULL;
- BKE_texture_get_value(scene, wmd->texture, tex_co[i], &texres, false);
+ BKE_texture_get_value(scene, tex_target, tex_co[i], &texres, false);
amplit *= texres.tin;
}
@@ -295,7 +311,7 @@ static void waveModifier_do(
}
}
- if (wmd->texture) MEM_freeN(tex_co);
+ MEM_SAFE_FREE(tex_co);
}
static void deformVerts(
@@ -304,18 +320,21 @@ static void deformVerts(
float (*vertexCos)[3],
int numVerts)
{
- Mesh *mesh_src = mesh;
WaveModifierData *wmd = (WaveModifierData *)md;
+ Mesh *mesh_src = NULL;
- if (wmd->flag & MOD_WAVE_NORM)
- mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, vertexCos, true, false);
- else if (wmd->texture || wmd->defgrp_name[0])
- mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ if (wmd->flag & MOD_WAVE_NORM) {
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, vertexCos, numVerts, true, false);
+ }
+ else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') {
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
+ }
- waveModifier_do(wmd, ctx->depsgraph, ctx->object, mesh_src, vertexCos, numVerts);
+ waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
- if (mesh_src != mesh)
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
+ }
}
static void deformVertsEM(
@@ -323,18 +342,21 @@ static void deformVertsEM(
struct BMEditMesh *editData,
Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
- Mesh *mesh_src = mesh;
WaveModifierData *wmd = (WaveModifierData *)md;
+ Mesh *mesh_src = NULL;
- if (wmd->flag & MOD_WAVE_NORM)
- mesh_src = MOD_get_mesh_eval(ctx->object, editData, mesh, vertexCos, true, false);
- else if (wmd->texture || wmd->defgrp_name[0])
- mesh_src = MOD_get_mesh_eval(ctx->object, editData, mesh, NULL, false, false);
+ if (wmd->flag & MOD_WAVE_NORM) {
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, vertexCos, numVerts, true, false);
+ }
+ else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') {
+ mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
+ }
- waveModifier_do(wmd, ctx->depsgraph, ctx->object, mesh_src, vertexCos, numVerts);
+ waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
- if (mesh_src != mesh)
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
+ }
}
@@ -367,7 +389,7 @@ ModifierTypeInfo modifierType_Wave = {
/* isDisabled */ NULL,
/* updateDepsgraph */ updateDepsgraph,
/* dependsOnTime */ dependsOnTime,
- /* dependsOnNormals */ NULL,
+ /* dependsOnNormals */ dependsOnNormals,
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index eed0c41e374..60537e51e22 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -47,6 +47,7 @@
#include "BKE_texture.h" /* Texture masking. */
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "MEM_guardedalloc.h"
#include "MOD_util.h"
@@ -124,7 +125,6 @@ void weightvg_do_mask(
Scene *scene, Tex *texture, const int tex_use_channel, const int tex_mapping,
Object *tex_map_object, const char *tex_uvlayer_name)
{
- Depsgraph *depsgraph = ctx->depsgraph;
int ref_didx;
int i;
@@ -132,7 +132,8 @@ void weightvg_do_mask(
if (fact == 0.0f) return;
/* If we want to mask vgroup weights from a texture. */
- if (texture) {
+ if (texture != NULL) {
+ texture = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &texture->id);
/* The texture coordinates. */
float (*tex_co)[3];
/* See mapping note below... */
@@ -150,9 +151,9 @@ void weightvg_do_mask(
t_map.texmapping = tex_mapping;
tex_co = MEM_calloc_arrayN(numVerts, sizeof(*tex_co), "WeightVG Modifier, TEX mode, tex_co");
- MOD_get_texture_coords(&t_map, ob, mesh, NULL, tex_co);
+ MOD_get_texture_coords(&t_map, ctx, ob, mesh, NULL, tex_co);
- MOD_init_texture(depsgraph, texture);
+ MOD_init_texture(&t_map, ctx);
/* For each weight (vertex), make the mix between org and new weights. */
for (i = 0; i < num; ++i) {
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 4bbf73caf92..bf7517ee634 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -142,8 +142,9 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
DEG_add_object_relation(ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGEdit Modifier");
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "WeightVGEdit Modifier");
}
- if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) {
+ else if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) {
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "WeightVGEdit Modifier");
}
}
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index c7a5d4dc70d..674ef106737 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -178,8 +178,10 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
DEG_add_object_relation(ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGMix Modifier");
DEG_add_object_relation(ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_GEOMETRY, "WeightVGMix Modifier");
+
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "WeightVGMix Modifier");
}
- if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) {
+ else if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) {
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "WeightVGMix Modifier");
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_GEOMETRY, "WeightVGMix Modifier");
}
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index bf220517342..cee5c266e59 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -352,10 +352,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGProximity Modifier");
DEG_add_object_relation(ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_GEOMETRY, "WeightVGProximity Modifier");
}
- if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) {
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "WeightVGProximity Modifier");
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_GEOMETRY, "WeightVGProximity Modifier");
- }
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "WeightVGProximity Modifier");
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_GEOMETRY, "WeightVGProximity Modifier");
}
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
@@ -404,7 +402,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
/* Get our target object. */
- obr = wmd->proximity_ob_target;
+ obr = DEG_get_evaluated_object(ctx->depsgraph, wmd->proximity_ob_target);
if (obr == NULL) {
return mesh;
}
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index 2c69da2d9cd..6a8fce76fa7 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -66,8 +66,11 @@
#include "node_shader_util.h"
-static void ntree_shader_tag_ssr_node(bNodeTree *ntree, bNode *output_node);
-static void ntree_shader_tag_sss_node(bNodeTree *ntree, bNode *output_node);
+typedef struct nTreeTags {
+ float ssr_id, sss_id;
+} nTreeTags;
+
+static void ntree_shader_tag_nodes(bNodeTree *ntree, bNode *output_node, nTreeTags *tags);
static bool shader_tree_poll(const bContext *C, bNodeTreeType *UNUSED(treetype))
{
@@ -633,29 +636,42 @@ static void ntree_shader_relink_displacement(bNodeTree *ntree, bNode *output_nod
ntreeUpdateTree(G.main, ntree);
}
-static bool ntree_tag_ssr_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void *userdata, const bool UNUSED(reversed))
+static bool ntree_tag_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void *userdata, const bool UNUSED(reversed))
{
+ /* Don't evaluate nodes more than once. */
+ if (fromnode->tmp_flag) {
+ return true;
+ }
+ fromnode->tmp_flag = 1;
+
switch (fromnode->type) {
case NODE_GROUP:
/* Recursive */
if (fromnode->id != NULL) {
bNodeTree *ntree = (bNodeTree *)fromnode->id;
bNode *group_output = ntree_group_output_node(ntree);
- if (fromnode) {
- ntree_shader_tag_ssr_node(ntree, group_output);
- }
+ ntree_shader_tag_nodes(ntree, group_output, (nTreeTags *)userdata);
}
break;
case SH_NODE_BSDF_ANISOTROPIC:
case SH_NODE_EEVEE_SPECULAR:
- case SH_NODE_BSDF_PRINCIPLED:
case SH_NODE_BSDF_GLOSSY:
case SH_NODE_BSDF_GLASS:
- fromnode->ssr_id = (*(float *)userdata);
- (*(float *)userdata) += 1;
+ fromnode->ssr_id = ((nTreeTags *)userdata)->ssr_id;
+ ((nTreeTags *)userdata)->ssr_id += 1;
+ break;
+ case SH_NODE_SUBSURFACE_SCATTERING:
+ fromnode->sss_id = ((nTreeTags *)userdata)->sss_id;
+ ((nTreeTags *)userdata)->sss_id += 1;
+ break;
+ case SH_NODE_BSDF_PRINCIPLED:
+ fromnode->ssr_id = ((nTreeTags *)userdata)->ssr_id;
+ fromnode->sss_id = ((nTreeTags *)userdata)->sss_id;
+ ((nTreeTags *)userdata)->sss_id += 1;
+ ((nTreeTags *)userdata)->ssr_id += 1;
break;
default:
- /* We could return false here but since we (will)
+ /* We could return false here but since we
* allow the use of Closure as RGBA, we can have
* Bsdf nodes linked to other Bsdf nodes. */
break;
@@ -665,9 +681,9 @@ static bool ntree_tag_ssr_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void *
}
/* EEVEE: Scan the ntree to set the Screen Space Reflection
- * layer id of every specular node.
+ * layer id of every specular node AND the Subsurface Scattering id of every SSS node.
*/
-void ntree_shader_tag_ssr_node(bNodeTree *ntree, bNode *output_node)
+void ntree_shader_tag_nodes(bNodeTree *ntree, bNode *output_node, nTreeTags *tags)
{
if (output_node == NULL) {
return;
@@ -675,47 +691,12 @@ void ntree_shader_tag_ssr_node(bNodeTree *ntree, bNode *output_node)
/* Make sure sockets links pointers are correct. */
ntreeUpdateTree(G.main, ntree);
- float lobe_id = 1;
- nodeChainIter(ntree, output_node, ntree_tag_ssr_bsdf_cb, &lobe_id, true);
-}
-
-static bool ntree_tag_sss_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void *userdata, const bool UNUSED(reversed))
-{
- switch (fromnode->type) {
- case NODE_GROUP:
- /* Recursive */
- if (fromnode->id != NULL) {
- bNodeTree *ntree = (bNodeTree *)fromnode->id;
- bNode *group_output = ntree_group_output_node(ntree);
- if (fromnode) {
- ntree_shader_tag_sss_node(ntree, group_output);
- }
- }
- break;
- case SH_NODE_BSDF_PRINCIPLED:
- case SH_NODE_SUBSURFACE_SCATTERING:
- fromnode->sss_id = (*(float *)userdata);
- (*(float *)userdata) += 1;
- break;
- default:
- break;
- }
-
- return true;
-}
-
-/* EEVEE: Scan the ntree to set the Subsurface Scattering id of every SSS node.
- */
-void ntree_shader_tag_sss_node(bNodeTree *ntree, bNode *output_node)
-{
- if (output_node == NULL) {
- return;
+ /* Reset visit flag. */
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ node->tmp_flag = 0;
}
- /* Make sure sockets links pointers are correct. */
- ntreeUpdateTree(G.main, ntree);
- float sss_id = 1;
- nodeChainIter(ntree, output_node, ntree_tag_sss_bsdf_cb, &sss_id, true);
+ nodeChainIter(ntree, output_node, ntree_tag_bsdf_cb, tags, true);
}
/* This one needs to work on a local tree. */
@@ -731,8 +712,12 @@ void ntreeGPUMaterialNodes(bNodeTree *localtree, GPUMaterial *mat, bool *has_sur
*/
ntree_shader_relink_displacement(localtree, output);
- ntree_shader_tag_ssr_node(localtree, output);
- ntree_shader_tag_sss_node(localtree, output);
+ /* TODO(fclem): consider moving this to the gpu shader tree evaluation. */
+ nTreeTags tags = {
+ .ssr_id = 1.0,
+ .sss_id = 1.0
+ };
+ ntree_shader_tag_nodes(localtree, output, &tags);
exec = ntreeShaderBeginExecTree(localtree);
ntreeExecGPUNodes(exec, mat, 1);
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index d43ce37cbfe..111d5c5b68f 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -152,7 +152,7 @@ static bool collision_response(ClothModifierData *clmd, CollisionModifierData *c
return false; /* XXX tested before already? */
/* only handle static collisions here */
- if ( collpair->flag & COLLISION_IN_FUTURE )
+ if (collpair->flag & COLLISION_IN_FUTURE)
return false;
/* velocity */
@@ -263,8 +263,8 @@ static void cloth_setup_constraints(ClothModifierData *clmd, ColliderContacts *c
* collisions*/
static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothModifierData *clmd, float (*initial_cos)[3], float UNUSED(step), float dt)
{
- Cloth *cloth= clmd->clothObject;
- float (*cos)[3] = (float (*)[3])MEM_callocN(sizeof(float[3]) * cloth->mvert_num, "cos cloth_calc_helper_forces");
+ Cloth *cloth = clmd->clothObject;
+ float(*cos)[3] = (float(*)[3])MEM_callocN(sizeof(float[3]) * cloth->mvert_num, "cos cloth_calc_helper_forces");
float *masses = (float *)MEM_callocN(sizeof(float) * cloth->mvert_num, "cos cloth_calc_helper_forces");
LinkNode *node;
ClothSpring *spring;
@@ -284,8 +284,8 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo
}
steps = 55;
- for (i=0; i<steps; i++) {
- for (node=cloth->springs; node; node=node->next) {
+ for (i = 0; i < steps; i++) {
+ for (node = cloth->springs; node; node = node->next) {
/* ClothVertex *cv1, *cv2; */ /* UNUSED */
int v1, v2;
float len, c, l, vec[3];
@@ -325,7 +325,7 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo
/*compute forces*/
sub_v3_v3v3(vec, cos[i], cv->tx);
- mul_v3_fl(vec, cv->mass*dt*20.0f);
+ mul_v3_fl(vec, cv->mass * dt * 20.0f);
add_v3_v3(cv->tv, vec);
//copy_v3_v3(cv->tx, cos[i]);
}
@@ -478,10 +478,10 @@ static void cloth_calc_force(Scene *scene, ClothModifierData *clmd, float UNUSED
/* Collect forces and derivatives: F, dFdX, dFdV */
Cloth *cloth = clmd->clothObject;
Implicit_Data *data = cloth->implicit;
- unsigned int i = 0;
- float drag = clmd->sim_parms->Cvi * 0.01f; /* viscosity of air scaled in percent */
- float gravity[3] = {0.0f, 0.0f, 0.0f};
- const MVertTri *tri = cloth->tri;
+ unsigned int i = 0;
+ float drag = clmd->sim_parms->Cvi * 0.01f; /* viscosity of air scaled in percent */
+ float gravity[3] = {0.0f, 0.0f, 0.0f};
+ const MVertTri *tri = cloth->tri;
unsigned int mvert_num = cloth->mvert_num;
ClothVertex *vert;
@@ -521,7 +521,7 @@ static void cloth_calc_force(Scene *scene, ClothModifierData *clmd, float UNUSED
/* handle external forces like wind */
if (effectors) {
/* cache per-vertex forces to avoid redundant calculation */
- float (*winvec)[3] = (float (*)[3])MEM_callocN(sizeof(float[3]) * mvert_num, "effector forces");
+ float(*winvec)[3] = (float(*)[3])MEM_callocN(sizeof(float[3]) * mvert_num, "effector forces");
for (i = 0; i < cloth->mvert_num; i++) {
float x[3], v[3];
EffectedPoint epoint;
@@ -566,8 +566,8 @@ static void cloth_calc_force(Scene *scene, ClothModifierData *clmd, float UNUSED
else
BPH_mass_spring_force_vertex_wind(data, i, 1.0f, winvec);
}
- }
#endif
+ }
MEM_freeN(winvec);
}
@@ -616,7 +616,7 @@ BLI_INLINE LinkNode *hair_spring_next(LinkNode *spring_link)
static LinkNode *cloth_continuum_add_hair_segments(HairGrid *grid, const float cell_scale, const float cell_offset[3], Cloth *cloth, LinkNode *spring_link)
{
Implicit_Data *data = cloth->implicit;
- LinkNode *next_spring_link = NULL; /* return value */
+ LinkNode *next_spring_link = NULL; /* return value */
ClothSpring *spring1, *spring2, *spring3;
// ClothVertex *verts = cloth->verts;
// ClothVertex *vert3, *vert4;
@@ -726,7 +726,7 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
int mvert_num = cloth->mvert_num;
ClothVertex *vert;
- const float fluid_factor = 0.95f; /* blend between PIC and FLIP methods */
+ const float fluid_factor = 0.95f; /* blend between PIC and FLIP methods */
float smoothfac = parms->velocity_smooth;
/* XXX FIXME arbitrary factor!!! this should be based on some intuitive value instead,
* like number of hairs per cell and time decay instead of "strength"
@@ -784,16 +784,16 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
zero_v3(b);
offset[axis] = shift * clmd->hair_grid_cellsize;
- a[(axis+1) % 3] = clmd->hair_grid_max[(axis+1) % 3] - clmd->hair_grid_min[(axis+1) % 3];
- b[(axis+2) % 3] = clmd->hair_grid_max[(axis+2) % 3] - clmd->hair_grid_min[(axis+2) % 3];
+ a[(axis + 1) % 3] = clmd->hair_grid_max[(axis + 1) % 3] - clmd->hair_grid_min[(axis + 1) % 3];
+ b[(axis + 2) % 3] = clmd->hair_grid_max[(axis + 2) % 3] - clmd->hair_grid_min[(axis + 2) % 3];
BKE_sim_debug_data_clear_category(clmd->debug_data, "grid velocity");
for (j = 0; j < size; ++j) {
for (i = 0; i < size; ++i) {
float x[3], v[3], gvel[3], gvel_smooth[3], gdensity;
- madd_v3_v3v3fl(x, offset, a, (float)i / (float)(size-1));
- madd_v3_v3fl(x, b, (float)j / (float)(size-1));
+ madd_v3_v3v3fl(x, offset, a, (float)i / (float)(size - 1));
+ madd_v3_v3fl(x, b, (float)j / (float)(size - 1));
zero_v3(v);
BPH_hair_volume_grid_interpolate(grid, x, &gdensity, gvel, gvel_smooth, NULL, NULL);
@@ -935,7 +935,7 @@ static void cloth_record_result(ClothModifierData *clmd, ImplicitSolverResult *r
{
ClothSolverResult *sres = clmd->solver_result;
- if (sres->status) { /* already initialized ? */
+ if (sres->status) { /* already initialized ? */
/* error only makes sense for successful iterations */
if (result->status == BPH_SOLVER_SUCCESS) {
sres->min_error = min_ff(sres->min_error, result->error);
@@ -970,10 +970,10 @@ int BPH_cloth_solve(Depsgraph *depsgraph, Object *ob, float frame, ClothModifier
Scene *scene = DEG_get_evaluated_scene(depsgraph);
const bool is_hair = (clmd->hairdata != NULL);
- unsigned int i=0;
- float step=0.0f, tf=clmd->sim_parms->timescale;
+ unsigned int i = 0;
+ float step = 0.0f, tf = clmd->sim_parms->timescale;
Cloth *cloth = clmd->clothObject;
- ClothVertex *verts = cloth->verts/*, *cv*/;
+ ClothVertex *verts = cloth->verts /*, *cv*/;
unsigned int mvert_num = cloth->mvert_num;
float dt = clmd->sim_parms->dt * clmd->sim_parms->timescale;
Implicit_Data *id = cloth->implicit;
diff --git a/source/blender/physics/intern/eigen_utils.h b/source/blender/physics/intern/eigen_utils.h
index 4598d3ad3a7..511e2cea3b1 100644
--- a/source/blender/physics/intern/eigen_utils.h
+++ b/source/blender/physics/intern/eigen_utils.h
@@ -67,7 +67,7 @@ public:
coeffRef(k) = v[k];
}
- Vector3& operator = (const ctype &v)
+ Vector3& operator =(const ctype &v)
{
for (int k = 0; k < 3; ++k)
coeffRef(k) = v[k];
@@ -98,7 +98,7 @@ public:
coeffRef(l, k) = v[k][l];
}
- Matrix3& operator = (const ctype &v)
+ Matrix3& operator =(const ctype &v)
{
for (int k = 0; k < 3; ++k)
for (int l = 0; l < 3; ++l)
@@ -126,18 +126,18 @@ public:
}
template <typename T>
- lVector3f& operator = (T rhs)
+ lVector3f& operator =(T rhs)
{
base_t::operator=(rhs);
return *this;
}
- float* v3(int vertex)
+ float *v3(int vertex)
{
return &coeffRef(3 * vertex);
}
- const float* v3(int vertex) const
+ const float *v3(int vertex) const
{
return &coeffRef(3 * vertex);
}
diff --git a/source/blender/physics/intern/hair_volume.cpp b/source/blender/physics/intern/hair_volume.cpp
index d2d43882a2d..5746bc123ea 100644
--- a/source/blender/physics/intern/hair_volume.cpp
+++ b/source/blender/physics/intern/hair_volume.cpp
@@ -93,7 +93,7 @@ typedef struct HairGrid {
float cellsize, inv_cellsize;
} HairGrid;
-#define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis) ( min_ii( max_ii( (int)((vec[axis] - gmin[axis]) * scale), 0), res[axis]-2 ) )
+#define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis) (min_ii(max_ii( (int)((vec[axis] - gmin[axis]) * scale), 0), res[axis] - 2) )
BLI_INLINE int hair_grid_offset(const float vec[3], const int res[3], const float gmin[3], float scale)
{
@@ -101,7 +101,7 @@ BLI_INLINE int hair_grid_offset(const float vec[3], const int res[3], const floa
i = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 0);
j = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 1);
k = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 2);
- return i + (j + k*res[1])*res[0];
+ return i + (j + k * res[1]) * res[0];
}
BLI_INLINE int hair_grid_interp_weights(const int res[3], const float gmin[3], float scale, const float vec[3], float uvw[3])
@@ -111,7 +111,7 @@ BLI_INLINE int hair_grid_interp_weights(const int res[3], const float gmin[3], f
i = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 0);
j = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 1);
k = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 2);
- offset = i + (j + k*res[1])*res[0];
+ offset = i + (j + k * res[1]) * res[0];
uvw[0] = (vec[0] - gmin[0]) * scale - (float)i;
uvw[1] = (vec[1] - gmin[1]) * scale - (float)j;
@@ -124,8 +124,9 @@ BLI_INLINE int hair_grid_interp_weights(const int res[3], const float gmin[3], f
return offset;
}
-BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid, const int res[3], const float gmin[3], float scale, const float vec[3],
- float *density, float velocity[3], float vel_smooth[3], float density_gradient[3], float velocity_gradient[3][3])
+BLI_INLINE void hair_grid_interpolate(
+ const HairGridVert *grid, const int res[3], const float gmin[3], float scale, const float vec[3],
+ float *density, float velocity[3], float vel_smooth[3], float density_gradient[3], float velocity_gradient[3][3])
{
HairGridVert data[8];
float uvw[3], muvw[3];
@@ -137,57 +138,57 @@ BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid, const int res[3]
muvw[1] = 1.0f - uvw[1];
muvw[2] = 1.0f - uvw[2];
- data[0] = grid[offset ];
- data[1] = grid[offset +1];
- data[2] = grid[offset +res[0] ];
- data[3] = grid[offset +res[0]+1];
- data[4] = grid[offset+res2 ];
- data[5] = grid[offset+res2 +1];
- data[6] = grid[offset+res2+res[0] ];
- data[7] = grid[offset+res2+res[0]+1];
+ data[0] = grid[offset ];
+ data[1] = grid[offset + 1];
+ data[2] = grid[offset + res[0] ];
+ data[3] = grid[offset + res[0] + 1];
+ data[4] = grid[offset + res2 ];
+ data[5] = grid[offset + res2 + 1];
+ data[6] = grid[offset + res2 + res[0] ];
+ data[7] = grid[offset + res2 + res[0] + 1];
if (density) {
- *density = muvw[2]*( muvw[1]*( muvw[0]*data[0].density + uvw[0]*data[1].density ) +
- uvw[1]*( muvw[0]*data[2].density + uvw[0]*data[3].density ) ) +
- uvw[2]*( muvw[1]*( muvw[0]*data[4].density + uvw[0]*data[5].density ) +
- uvw[1]*( muvw[0]*data[6].density + uvw[0]*data[7].density ) );
+ *density = muvw[2] * (muvw[1] * (muvw[0] * data[0].density + uvw[0] * data[1].density) +
+ uvw[1] * (muvw[0] * data[2].density + uvw[0] * data[3].density)) +
+ uvw[2] * (muvw[1] * (muvw[0] * data[4].density + uvw[0] * data[5].density) +
+ uvw[1] * (muvw[0] * data[6].density + uvw[0] * data[7].density));
}
if (velocity) {
int k;
for (k = 0; k < 3; ++k) {
- velocity[k] = muvw[2]*( muvw[1]*( muvw[0]*data[0].velocity[k] + uvw[0]*data[1].velocity[k] ) +
- uvw[1]*( muvw[0]*data[2].velocity[k] + uvw[0]*data[3].velocity[k] ) ) +
- uvw[2]*( muvw[1]*( muvw[0]*data[4].velocity[k] + uvw[0]*data[5].velocity[k] ) +
- uvw[1]*( muvw[0]*data[6].velocity[k] + uvw[0]*data[7].velocity[k] ) );
+ velocity[k] = muvw[2] * (muvw[1] * (muvw[0] * data[0].velocity[k] + uvw[0] * data[1].velocity[k]) +
+ uvw[1] * (muvw[0] * data[2].velocity[k] + uvw[0] * data[3].velocity[k]) ) +
+ uvw[2] * (muvw[1] * (muvw[0] * data[4].velocity[k] + uvw[0] * data[5].velocity[k]) +
+ uvw[1] * (muvw[0] * data[6].velocity[k] + uvw[0] * data[7].velocity[k]) );
}
}
if (vel_smooth) {
int k;
for (k = 0; k < 3; ++k) {
- vel_smooth[k] = muvw[2]*( muvw[1]*( muvw[0]*data[0].velocity_smooth[k] + uvw[0]*data[1].velocity_smooth[k] ) +
- uvw[1]*( muvw[0]*data[2].velocity_smooth[k] + uvw[0]*data[3].velocity_smooth[k] ) ) +
- uvw[2]*( muvw[1]*( muvw[0]*data[4].velocity_smooth[k] + uvw[0]*data[5].velocity_smooth[k] ) +
- uvw[1]*( muvw[0]*data[6].velocity_smooth[k] + uvw[0]*data[7].velocity_smooth[k] ) );
+ vel_smooth[k] = muvw[2] * (muvw[1] * (muvw[0] * data[0].velocity_smooth[k] + uvw[0] * data[1].velocity_smooth[k]) +
+ uvw[1] * (muvw[0] * data[2].velocity_smooth[k] + uvw[0] * data[3].velocity_smooth[k]) ) +
+ uvw[2] * (muvw[1] * (muvw[0] * data[4].velocity_smooth[k] + uvw[0] * data[5].velocity_smooth[k]) +
+ uvw[1] * (muvw[0] * data[6].velocity_smooth[k] + uvw[0] * data[7].velocity_smooth[k]) );
}
}
if (density_gradient) {
- density_gradient[0] = muvw[1] * muvw[2] * ( data[0].density - data[1].density ) +
- uvw[1] * muvw[2] * ( data[2].density - data[3].density ) +
- muvw[1] * uvw[2] * ( data[4].density - data[5].density ) +
- uvw[1] * uvw[2] * ( data[6].density - data[7].density );
-
- density_gradient[1] = muvw[2] * muvw[0] * ( data[0].density - data[2].density ) +
- uvw[2] * muvw[0] * ( data[4].density - data[6].density ) +
- muvw[2] * uvw[0] * ( data[1].density - data[3].density ) +
- uvw[2] * uvw[0] * ( data[5].density - data[7].density );
-
- density_gradient[2] = muvw[2] * muvw[0] * ( data[0].density - data[4].density ) +
- uvw[2] * muvw[0] * ( data[1].density - data[5].density ) +
- muvw[2] * uvw[0] * ( data[2].density - data[6].density ) +
- uvw[2] * uvw[0] * ( data[3].density - data[7].density );
+ density_gradient[0] = muvw[1] * muvw[2] * (data[0].density - data[1].density) +
+ uvw[1] * muvw[2] * (data[2].density - data[3].density) +
+ muvw[1] * uvw[2] * (data[4].density - data[5].density) +
+ uvw[1] * uvw[2] * (data[6].density - data[7].density);
+
+ density_gradient[1] = muvw[2] * muvw[0] * (data[0].density - data[2].density) +
+ uvw[2] * muvw[0] * (data[4].density - data[6].density) +
+ muvw[2] * uvw[0] * (data[1].density - data[3].density) +
+ uvw[2] * uvw[0] * (data[5].density - data[7].density);
+
+ density_gradient[2] = muvw[2] * muvw[0] * (data[0].density - data[4].density) +
+ uvw[2] * muvw[0] * (data[1].density - data[5].density) +
+ muvw[2] * uvw[0] * (data[2].density - data[6].density) +
+ uvw[2] * uvw[0] * (data[3].density - data[7].density);
}
if (velocity_gradient) {
@@ -196,9 +197,10 @@ BLI_INLINE void hair_grid_interpolate(const HairGridVert *grid, const int res[3]
}
}
-void BPH_hair_volume_vertex_grid_forces(HairGrid *grid, const float x[3], const float v[3],
- float smoothfac, float pressurefac, float minpressure,
- float f[3], float dfdx[3][3], float dfdv[3][3])
+void BPH_hair_volume_vertex_grid_forces(
+ HairGrid *grid, const float x[3], const float v[3],
+ float smoothfac, float pressurefac, float minpressure,
+ float f[3], float dfdx[3][3], float dfdv[3][3])
{
float gdensity, gvelocity[3], ggrad[3], gvelgrad[3][3], gradlen;
@@ -220,15 +222,17 @@ void BPH_hair_volume_vertex_grid_forces(HairGrid *grid, const float x[3], const
mul_m3_fl(dfdv, smoothfac);
}
-void BPH_hair_volume_grid_interpolate(HairGrid *grid, const float x[3],
- float *density, float velocity[3], float velocity_smooth[3], float density_gradient[3], float velocity_gradient[3][3])
+void BPH_hair_volume_grid_interpolate(
+ HairGrid *grid, const float x[3],
+ float *density, float velocity[3], float velocity_smooth[3], float density_gradient[3], float velocity_gradient[3][3])
{
hair_grid_interpolate(grid->verts, grid->res, grid->gmin, grid->inv_cellsize, x, density, velocity, velocity_smooth, density_gradient, velocity_gradient);
}
-void BPH_hair_volume_grid_velocity(HairGrid *grid, const float x[3], const float v[3],
- float fluid_factor,
- float r_v[3])
+void BPH_hair_volume_grid_velocity(
+ HairGrid *grid, const float x[3], const float v[3],
+ float fluid_factor,
+ float r_v[3])
{
float gdensity, gvelocity[3], gvel_smooth[3], ggrad[3], gvelgrad[3][3];
float v_pic[3], v_flip[3];
@@ -287,20 +291,20 @@ BLI_INLINE int hair_grid_weights(const int res[3], const float gmin[3], float sc
i = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 0);
j = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 1);
k = HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, 2);
- offset = i + (j + k*res[1])*res[0];
+ offset = i + (j + k * res[1]) * res[0];
uvw[0] = (vec[0] - gmin[0]) * scale;
uvw[1] = (vec[1] - gmin[1]) * scale;
uvw[2] = (vec[2] - gmin[2]) * scale;
- weights[0] = dist_tent_v3f3(uvw, (float)i , (float)j , (float)k );
- weights[1] = dist_tent_v3f3(uvw, (float)(i+1), (float)j , (float)k );
- weights[2] = dist_tent_v3f3(uvw, (float)i , (float)(j+1), (float)k );
- weights[3] = dist_tent_v3f3(uvw, (float)(i+1), (float)(j+1), (float)k );
- weights[4] = dist_tent_v3f3(uvw, (float)i , (float)j , (float)(k+1));
- weights[5] = dist_tent_v3f3(uvw, (float)(i+1), (float)j , (float)(k+1));
- weights[6] = dist_tent_v3f3(uvw, (float)i , (float)(j+1), (float)(k+1));
- weights[7] = dist_tent_v3f3(uvw, (float)(i+1), (float)(j+1), (float)(k+1));
+ weights[0] = dist_tent_v3f3(uvw, (float)i , (float)j , (float)k );
+ weights[1] = dist_tent_v3f3(uvw, (float)(i + 1), (float)j , (float)k );
+ weights[2] = dist_tent_v3f3(uvw, (float)i , (float)(j + 1), (float)k );
+ weights[3] = dist_tent_v3f3(uvw, (float)(i + 1), (float)(j + 1), (float)k );
+ weights[4] = dist_tent_v3f3(uvw, (float)i , (float)j , (float)(k + 1));
+ weights[5] = dist_tent_v3f3(uvw, (float)(i + 1), (float)j , (float)(k + 1));
+ weights[6] = dist_tent_v3f3(uvw, (float)i , (float)(j + 1), (float)(k + 1));
+ weights[7] = dist_tent_v3f3(uvw, (float)(i + 1), (float)(j + 1), (float)(k + 1));
// BLI_assert(fabsf(weights_sum(weights) - 1.0f) < 0.0001f);
@@ -329,8 +333,8 @@ void BPH_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[
for (di = 0; di < 2; ++di) {
for (dj = 0; dj < 2; ++dj) {
for (dk = 0; dk < 2; ++dk) {
- int voffset = offset + di + (dj + dk*res[1])*res[0];
- int iw = di + dj*2 + dk*4;
+ int voffset = offset + di + (dj + dk * res[1]) * res[0];
+ int iw = di + dj * 2 + dk * 4;
grid->verts[voffset].density += weights[iw];
madd_v3_v3fl(grid->verts[voffset].velocity, v, weights[iw]);
@@ -340,8 +344,9 @@ void BPH_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[
}
#if 0
-BLI_INLINE void hair_volume_eval_grid_vertex(HairGridVert *vert, const float loc[3], float radius, float dist_scale,
- const float x2[3], const float v2[3], const float x3[3], const float v3[3])
+BLI_INLINE void hair_volume_eval_grid_vertex(
+ HairGridVert *vert, const float loc[3], float radius, float dist_scale,
+ const float x2[3], const float v2[3], const float x3[3], const float v3[3])
{
float closest[3], lambda, dist, weight;
@@ -368,13 +373,14 @@ BLI_INLINE int major_axis_v3(const float v[3])
return a > b ? (a > c ? 0 : 2) : (b > c ? 1 : 2);
}
-BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
- const float UNUSED(x1[3]), const float UNUSED(v1[3]), const float x2[3], const float v2[3],
- const float x3[3], const float v3[3], const float UNUSED(x4[3]), const float UNUSED(v4[3]),
- const float UNUSED(dir1[3]), const float dir2[3], const float UNUSED(dir3[3]),
- int resj, int resk, int jmin, int jmax, int kmin, int kmax,
- HairGridVert *vert, int stride_j, int stride_k, const float loc[3], int axis_j, int axis_k,
- int debug_i)
+BLI_INLINE void hair_volume_add_segment_2D(
+ HairGrid *grid,
+ const float UNUSED(x1[3]), const float UNUSED(v1[3]), const float x2[3], const float v2[3],
+ const float x3[3], const float v3[3], const float UNUSED(x4[3]), const float UNUSED(v4[3]),
+ const float UNUSED(dir1[3]), const float dir2[3], const float UNUSED(dir3[3]),
+ int resj, int resk, int jmin, int jmax, int kmin, int kmax,
+ HairGridVert *vert, int stride_j, int stride_k, const float loc[3], int axis_j, int axis_k,
+ int debug_i)
{
const float radius = 1.5f;
const float dist_scale = grid->inv_cellsize;
@@ -383,9 +389,9 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
/* boundary checks to be safe */
CLAMP_MIN(jmin, 0);
- CLAMP_MAX(jmax, resj-1);
+ CLAMP_MAX(jmax, resj - 1);
CLAMP_MIN(kmin, 0);
- CLAMP_MAX(kmax, resk-1);
+ CLAMP_MAX(kmax, resk - 1);
HairGridVert *vert_j = vert + jmin * stride_j;
float loc_j[3] = { loc[0], loc[1], loc[2] };
@@ -429,10 +435,11 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
*
*
*/
-void BPH_hair_volume_add_segment(HairGrid *grid,
- const float x1[3], const float v1[3], const float x2[3], const float v2[3],
- const float x3[3], const float v3[3], const float x4[3], const float v4[3],
- const float dir1[3], const float dir2[3], const float dir3[3])
+void BPH_hair_volume_add_segment(
+ HairGrid *grid,
+ const float x1[3], const float v1[3], const float x2[3], const float v2[3],
+ const float x3[3], const float v3[3], const float x4[3], const float v4[3],
+ const float dir1[3], const float dir2[3], const float dir3[3])
{
const int res[3] = { grid->res[0], grid->res[1], grid->res[2] };
@@ -461,7 +468,7 @@ void BPH_hair_volume_add_segment(HairGrid *grid,
/* range along primary direction */
const int imin = max_ii(floor_int(start[axis0]) - 1, 0);
- const int imax = min_ii(floor_int(end[axis0]) + 2, res[axis0]-1);
+ const int imax = min_ii(floor_int(end[axis0]) + 2, res[axis0] - 1);
float h = 0.0f;
HairGridVert *vert0;
@@ -500,15 +507,17 @@ void BPH_hair_volume_add_segment(HairGrid *grid,
loc0[axis1] = 0.0f;
loc0[axis2] = 0.0f;
- hair_volume_add_segment_2D(grid, x1, v1, x2, v2, x3, v3, x4, v4, dir1, dir2, dir3,
- res[axis1], res[axis2], jmin-1, jmax+2, kmin-1, kmax+2,
- vert0, stride1, stride2, loc0, axis1, axis2,
- i);
+ hair_volume_add_segment_2D(
+ grid, x1, v1, x2, v2, x3, v3, x4, v4, dir1, dir2, dir3,
+ res[axis1], res[axis2], jmin - 1, jmax + 2, kmin - 1, kmax + 2,
+ vert0, stride1, stride2, loc0, axis1, axis2,
+ i);
}
}
#else
-BLI_INLINE void hair_volume_eval_grid_vertex_sample(HairGridVert *vert, const float loc[3], float radius, float dist_scale,
- const float x[3], const float v[3])
+BLI_INLINE void hair_volume_eval_grid_vertex_sample(
+ HairGridVert *vert, const float loc[3], float radius, float dist_scale,
+ const float x[3], const float v[3])
{
float dist, weight;
@@ -526,10 +535,11 @@ BLI_INLINE void hair_volume_eval_grid_vertex_sample(HairGridVert *vert, const fl
/* XXX simplified test implementation using a series of discrete sample along the segment,
* instead of finding the closest point for all affected grid vertices.
*/
-void BPH_hair_volume_add_segment(HairGrid *grid,
- const float UNUSED(x1[3]), const float UNUSED(v1[3]), const float x2[3], const float v2[3],
- const float x3[3], const float v3[3], const float UNUSED(x4[3]), const float UNUSED(v4[3]),
- const float UNUSED(dir1[3]), const float UNUSED(dir2[3]), const float UNUSED(dir3[3]))
+void BPH_hair_volume_add_segment(
+ HairGrid *grid,
+ const float UNUSED(x1[3]), const float UNUSED(v1[3]), const float x2[3], const float v2[3],
+ const float x3[3], const float v3[3], const float UNUSED(x4[3]), const float UNUSED(v4[3]),
+ const float UNUSED(dir1[3]), const float UNUSED(dir2[3]), const float UNUSED(dir3[3]))
{
const float radius = 1.5f;
const float dist_scale = grid->inv_cellsize;
@@ -544,16 +554,16 @@ void BPH_hair_volume_add_segment(HairGrid *grid,
float x[3], v[3];
int i, j, k;
- float f = (float)s / (float)(num_samples-1);
+ float f = (float)s / (float)(num_samples - 1);
interp_v3_v3v3(x, x2, x3, f);
interp_v3_v3v3(v, v2, v3, f);
int imin = max_ii(floor_int(x[0]) - 2, 0);
- int imax = min_ii(floor_int(x[0]) + 2, res[0]-1);
+ int imax = min_ii(floor_int(x[0]) + 2, res[0] - 1);
int jmin = max_ii(floor_int(x[1]) - 2, 0);
- int jmax = min_ii(floor_int(x[1]) + 2, res[1]-1);
+ int jmax = min_ii(floor_int(x[1]) + 2, res[1] - 1);
int kmin = max_ii(floor_int(x[2]) - 2, 0);
- int kmax = min_ii(floor_int(x[2]) + 2, res[2]-1);
+ int kmax = min_ii(floor_int(x[2]) + 2, res[2] - 1);
for (k = kmin; k <= kmax; ++k) {
for (j = jmin; j <= jmax; ++j) {
@@ -576,7 +586,7 @@ void BPH_hair_volume_normalize_vertex_grid(HairGrid *grid)
for (i = 0; i < size; i++) {
float density = grid->verts[i].density;
if (density > 0.0f)
- mul_v3_fl(grid->verts[i].velocity, 1.0f/density);
+ mul_v3_fl(grid->verts[i].velocity, 1.0f / density);
}
}
@@ -620,16 +630,16 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid, float /*dt*/, float target
#define MARGIN_i0 (i < 1)
#define MARGIN_j0 (j < 1)
#define MARGIN_k0 (k < 1)
-#define MARGIN_i1 (i >= resA[0]-1)
-#define MARGIN_j1 (j >= resA[1]-1)
-#define MARGIN_k1 (k >= resA[2]-1)
+#define MARGIN_i1 (i >= resA[0] - 1)
+#define MARGIN_j1 (j >= resA[1] - 1)
+#define MARGIN_k1 (k >= resA[2] - 1)
#define NEIGHBOR_MARGIN_i0 (i < 2)
#define NEIGHBOR_MARGIN_j0 (j < 2)
#define NEIGHBOR_MARGIN_k0 (k < 2)
-#define NEIGHBOR_MARGIN_i1 (i >= resA[0]-2)
-#define NEIGHBOR_MARGIN_j1 (j >= resA[1]-2)
-#define NEIGHBOR_MARGIN_k1 (k >= resA[2]-2)
+#define NEIGHBOR_MARGIN_i1 (i >= resA[0] - 2)
+#define NEIGHBOR_MARGIN_j1 (j >= resA[1] - 2)
+#define NEIGHBOR_MARGIN_k1 (k >= resA[2] - 2)
BLI_assert(num_cells >= 1);
@@ -895,18 +905,18 @@ BLI_INLINE void hair_volume_filter_box_convolute(HairVertexGrid *grid, float inv
{
int res = grid->res;
int p, q, r;
- int minp = max_ii(i - kernel_size[0], 0), maxp = min_ii(i + kernel_size[0], res-1);
- int minq = max_ii(j - kernel_size[1], 0), maxq = min_ii(j + kernel_size[1], res-1);
- int minr = max_ii(k - kernel_size[2], 0), maxr = min_ii(k + kernel_size[2], res-1);
+ int minp = max_ii(i - kernel_size[0], 0), maxp = min_ii(i + kernel_size[0], res - 1);
+ int minq = max_ii(j - kernel_size[1], 0), maxq = min_ii(j + kernel_size[1], res - 1);
+ int minr = max_ii(k - kernel_size[2], 0), maxr = min_ii(k + kernel_size[2], res - 1);
int offset, kernel_offset, kernel_dq, kernel_dr;
HairGridVert *verts;
float *vel_smooth;
- offset = i + (j + k*res)*res;
+ offset = i + (j + k * res) * res;
verts = grid->verts;
vel_smooth = verts[offset].velocity_smooth;
- kernel_offset = minp + (minq + minr*res)*res;
+ kernel_offset = minp + (minq + minr * res) * res;
kernel_dq = res;
kernel_dr = res * res;
for (r = minr; r <= maxr; ++r) {
@@ -935,7 +945,7 @@ void BPH_hair_volume_vertex_grid_filter_box(HairVertexGrid *grid, int kernel_siz
return;
tot = kernel_size * 2 + 1;
- invD = 1.0f / (float)(tot*tot*tot);
+ invD = 1.0f / (float)(tot * tot * tot);
/* clear values for convolution */
for (i = 0; i < size; ++i) {
@@ -1039,8 +1049,8 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
float gmin[3], gmax[3], scale[3];
/* 2.0f is an experimental value that seems to give good results */
float collfac = 2.0f * clmd->sim_parms->collider_friction;
- unsigned int v = 0;
- int i = 0;
+ unsigned int v = 0;
+ int i = 0;
hair_volume_get_boundbox(lX, numverts, gmin, gmax);
hair_grid_get_scale(res, gmin, gmax, scale);
@@ -1063,7 +1073,7 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
float weights[8];
int di, dj, dk;
- for (v=0; v < col->collmd->numverts; v++, loc0++, loc1++) {
+ for (v = 0; v < col->collmd->numverts; v++, loc0++, loc1++) {
int offset;
if (!hair_grid_point_valid(loc1->co, gmin, gmax))
@@ -1076,8 +1086,8 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
for (di = 0; di < 2; ++di) {
for (dj = 0; dj < 2; ++dj) {
for (dk = 0; dk < 2; ++dk) {
- int voffset = offset + di + (dj + dk*res)*res;
- int iw = di + dj*2 + dk*4;
+ int voffset = offset + di + (dj + dk * res) * res;
+ int iw = di + dj * 2 + dk * 4;
collgrid[voffset].density += weights[iw];
madd_v3_v3fl(collgrid[voffset].velocity, vel, weights[iw]);
@@ -1093,7 +1103,7 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
for (i = 0; i < size; i++) {
float density = collgrid[i].density;
if (density > 0.0f)
- mul_v3_fl(collgrid[i].velocity, 1.0f/density);
+ mul_v3_fl(collgrid[i].velocity, 1.0f / density);
}
return collgrid;
diff --git a/source/blender/physics/intern/implicit.h b/source/blender/physics/intern/implicit.h
index f99812a8aa9..11621ac812c 100644
--- a/source/blender/physics/intern/implicit.h
+++ b/source/blender/physics/intern/implicit.h
@@ -70,7 +70,7 @@ typedef struct ImplicitSolverResult {
BLI_INLINE void implicit_print_matrix_elem(float v)
{
- printf("%-8.3f", v);
+ printf("%-8.3f", v);
}
void BPH_mass_spring_set_vertex_mass(struct Implicit_Data *data, int index, float mass);
@@ -108,11 +108,11 @@ void BPH_mass_spring_force_drag(struct Implicit_Data *data, float drag);
/* Custom external force */
void BPH_mass_spring_force_extern(struct Implicit_Data *data, int i, const float f[3], float dfdx[3][3], float dfdv[3][3]);
/* Wind force, acting on a face */
-void BPH_mass_spring_force_face_wind(struct Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3]);
+void BPH_mass_spring_force_face_wind(struct Implicit_Data *data, int v1, int v2, int v3, const float(*winvec)[3]);
/* Wind force, acting on an edge */
-void BPH_mass_spring_force_edge_wind(struct Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float (*winvec)[3]);
+void BPH_mass_spring_force_edge_wind(struct Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float(*winvec)[3]);
/* Wind force, acting on a vertex */
-void BPH_mass_spring_force_vertex_wind(struct Implicit_Data *data, int v, float radius, const float (*winvec)[3]);
+void BPH_mass_spring_force_vertex_wind(struct Implicit_Data *data, int v, float radius, const float(*winvec)[3]);
/* Linear spring force between two points */
bool BPH_mass_spring_force_spring_linear(struct Implicit_Data *data, int i, int j, float restlen,
float stiffness_tension, float damping_tension,
@@ -125,7 +125,7 @@ bool BPH_mass_spring_force_spring_angular(struct Implicit_Data *data, int i, int
bool BPH_mass_spring_force_spring_bending(struct Implicit_Data *data, int i, int j, float restlen, float kb, float cb);
/* Angular bending force based on local target vectors */
bool BPH_mass_spring_force_spring_bending_hair(struct Implicit_Data *data, int i, int j, int k,
- const float target[3], float stiffness, float damping);
+ const float target[3], float stiffness, float damping);
/* Global goal spring */
bool BPH_mass_spring_force_spring_goal(struct Implicit_Data *data, int i, const float goal_x[3], const float goal_v[3],
float stiffness, float damping);
diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c
index 20f4a9f3163..28546f8ca0d 100644
--- a/source/blender/physics/intern/implicit_blender.c
+++ b/source/blender/physics/intern/implicit_blender.c
@@ -62,7 +62,7 @@
//#define DEBUG_TIME
#ifdef DEBUG_TIME
-# include "PIL_time.h"
+# include "PIL_time.h"
#endif
static float I[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
@@ -135,7 +135,7 @@ static void print_fvector(float m3[3])
// long float vector float (*)[3]
///////////////////////////
/* print long vector on console: for debug output */
-DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts)
+DO_INLINE void print_lfvector(float(*fLongVector)[3], unsigned int verts)
{
unsigned int i = 0;
for (i = 0; i < verts; i++) {
@@ -148,11 +148,11 @@ DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts)
DO_INLINE lfVector *create_lfvector(unsigned int verts)
{
/* TODO: check if memory allocation was successful */
- return (lfVector *)MEM_callocN(verts * sizeof(lfVector), "cloth_implicit_alloc_vector");
+ return (lfVector *)MEM_callocN(verts * sizeof(lfVector), "cloth_implicit_alloc_vector");
// return (lfVector *)cloth_aligned_malloc(&MEMORY_BASE, verts * sizeof(lfVector));
}
/* delete long vector */
-DO_INLINE void del_lfvector(float (*fLongVector)[3])
+DO_INLINE void del_lfvector(float(*fLongVector)[3])
{
if (fLongVector != NULL) {
MEM_freeN(fLongVector);
@@ -160,12 +160,12 @@ DO_INLINE void del_lfvector(float (*fLongVector)[3])
}
}
/* copy long vector */
-DO_INLINE void cp_lfvector(float (*to)[3], float (*from)[3], unsigned int verts)
+DO_INLINE void cp_lfvector(float(*to)[3], float(*from)[3], unsigned int verts)
{
memcpy(to, from, verts * sizeof(lfVector));
}
/* init long vector with float[3] */
-DO_INLINE void init_lfvector(float (*fLongVector)[3], float vector[3], unsigned int verts)
+DO_INLINE void init_lfvector(float(*fLongVector)[3], float vector[3], unsigned int verts)
{
unsigned int i = 0;
for (i = 0; i < verts; i++) {
@@ -173,12 +173,12 @@ DO_INLINE void init_lfvector(float (*fLongVector)[3], float vector[3], unsigned
}
}
/* zero long vector with float[3] */
-DO_INLINE void zero_lfvector(float (*to)[3], unsigned int verts)
+DO_INLINE void zero_lfvector(float(*to)[3], unsigned int verts)
{
memset(to, 0.0f, verts * sizeof(lfVector));
}
/* multiply long vector with scalar*/
-DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scalar, unsigned int verts)
+DO_INLINE void mul_lfvectorS(float(*to)[3], float(*fLongVector)[3], float scalar, unsigned int verts)
{
unsigned int i = 0;
@@ -188,7 +188,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scal
}
/* multiply long vector with scalar*/
/* A -= B * float */
-DO_INLINE void submul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scalar, unsigned int verts)
+DO_INLINE void submul_lfvectorS(float(*to)[3], float(*fLongVector)[3], float scalar, unsigned int verts)
{
unsigned int i = 0;
for (i = 0; i < verts; i++) {
@@ -196,7 +196,7 @@ DO_INLINE void submul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float s
}
}
/* dot product for big vector */
-DO_INLINE float dot_lfvector(float (*fLongVectorA)[3], float (*fLongVectorB)[3], unsigned int verts)
+DO_INLINE float dot_lfvector(float(*fLongVectorA)[3], float(*fLongVectorB)[3], unsigned int verts)
{
long i = 0;
float temp = 0.0;
@@ -211,7 +211,7 @@ DO_INLINE float dot_lfvector(float (*fLongVectorA)[3], float (*fLongVectorB)[3],
return temp;
}
/* A = B + C --> for big vector */
-DO_INLINE void add_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], unsigned int verts)
+DO_INLINE void add_lfvector_lfvector(float(*to)[3], float(*fLongVectorA)[3], float(*fLongVectorB)[3], unsigned int verts)
{
unsigned int i = 0;
@@ -221,7 +221,7 @@ DO_INLINE void add_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f
}
/* A = B + C * float --> for big vector */
-DO_INLINE void add_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], float bS, unsigned int verts)
+DO_INLINE void add_lfvector_lfvectorS(float(*to)[3], float(*fLongVectorA)[3], float(*fLongVectorB)[3], float bS, unsigned int verts)
{
unsigned int i = 0;
@@ -231,7 +231,7 @@ DO_INLINE void add_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
}
}
/* A = B * float + C * float --> for big vector */
-DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], float aS, float (*fLongVectorB)[3], float bS, unsigned int verts)
+DO_INLINE void add_lfvectorS_lfvectorS(float(*to)[3], float(*fLongVectorA)[3], float aS, float(*fLongVectorB)[3], float bS, unsigned int verts)
{
unsigned int i = 0;
@@ -240,7 +240,7 @@ DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
}
}
/* A = B - C * float --> for big vector */
-DO_INLINE void sub_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], float bS, unsigned int verts)
+DO_INLINE void sub_lfvector_lfvectorS(float(*to)[3], float(*fLongVectorA)[3], float(*fLongVectorB)[3], float bS, unsigned int verts)
{
unsigned int i = 0;
for (i = 0; i < verts; i++) {
@@ -249,7 +249,7 @@ DO_INLINE void sub_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
}
/* A = B - C --> for big vector */
-DO_INLINE void sub_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], unsigned int verts)
+DO_INLINE void sub_lfvector_lfvector(float(*to)[3], float(*fLongVectorA)[3], float(*fLongVectorB)[3], unsigned int verts)
{
unsigned int i = 0;
@@ -302,7 +302,7 @@ static void print_bfmatrix(fmatrix3x3 *m)
{
int tot = m[0].vcount + m[0].scount;
int size = m[0].vcount * 3;
- float *t = MEM_callocN(sizeof(float) * size*size, "bfmatrix");
+ float *t = MEM_callocN(sizeof(float) * size * size, "bfmatrix");
int q, i, j;
for (q = 0; q < tot; ++q) {
@@ -365,8 +365,8 @@ DO_INLINE void initdiag_fmatrixS(float to[3][3], float aS)
/* calculate determinant of 3x3 matrix */
DO_INLINE float det_fmatrix(float m[3][3])
{
- return m[0][0]*m[1][1]*m[2][2] + m[1][0]*m[2][1]*m[0][2] + m[0][1]*m[1][2]*m[2][0] -
- m[0][0]*m[1][2]*m[2][1] - m[0][1]*m[1][0]*m[2][2] - m[2][0]*m[1][1]*m[0][2];
+ return m[0][0] * m[1][1] * m[2][2] + m[1][0] * m[2][1] * m[0][2] + m[0][1] * m[1][2] * m[2][0] -
+ m[0][0] * m[1][2] * m[2][1] - m[0][1] * m[1][0] * m[2][2] - m[2][0] * m[1][1] * m[0][2];
}
DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3])
@@ -374,18 +374,18 @@ DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3])
unsigned int i, j;
float d;
- if ((d=det_fmatrix(from)) == 0) {
+ if ((d = det_fmatrix(from)) == 0) {
printf("can't build inverse");
exit(0);
}
- for (i=0;i<3;i++) {
- for (j=0;j<3;j++) {
- int i1=(i+1)%3;
- int i2=(i+2)%3;
- int j1=(j+1)%3;
- int j2=(j+2)%3;
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 3; j++) {
+ int i1 = (i + 1) % 3;
+ int i2 = (i + 2) % 3;
+ int j1 = (j + 1) % 3;
+ int j2 = (j + 2) % 3;
/** Reverse indexes i&j to take transpose. */
- to[j][i] = (from[i1][j1]*from[i2][j2]-from[i1][j2]*from[i2][j1])/d;
+ to[j][i] = (from[i1][j1] * from[i2][j2] - from[i1][j2] * from[i2][j1]) / d;
/**
* <pre>
* if (i == j) {
@@ -415,9 +415,9 @@ DO_INLINE void mul_fmatrix_S(float matrix[3][3], float scalar)
/* STATUS: verified */
DO_INLINE void mul_fvector_fmatrix(float *to, float *from, float matrix[3][3])
{
- to[0] = matrix[0][0]*from[0] + matrix[1][0]*from[1] + matrix[2][0]*from[2];
- to[1] = matrix[0][1]*from[0] + matrix[1][1]*from[1] + matrix[2][1]*from[2];
- to[2] = matrix[0][2]*from[0] + matrix[1][2]*from[1] + matrix[2][2]*from[2];
+ to[0] = matrix[0][0] * from[0] + matrix[1][0] * from[1] + matrix[2][0] * from[2];
+ to[1] = matrix[0][1] * from[0] + matrix[1][1] * from[1] + matrix[2][1] * from[2];
+ to[2] = matrix[0][2] * from[0] + matrix[1][2] * from[1] + matrix[2][2] * from[2];
}
/* 3x3 matrix multiplied by a vector */
@@ -484,9 +484,9 @@ BLI_INLINE void cross_m3_v3m3(float r[3][3], const float v[3], float m[3][3])
BLI_INLINE void cross_v3_identity(float r[3][3], const float v[3])
{
- r[0][0] = 0.0f; r[1][0] = v[2]; r[2][0] = -v[1];
- r[0][1] = -v[2]; r[1][1] = 0.0f; r[2][1] = v[0];
- r[0][2] = v[1]; r[1][2] = -v[0]; r[2][2] = 0.0f;
+ r[0][0] = 0.0f; r[1][0] = v[2]; r[2][0] = -v[1];
+ r[0][1] = -v[2]; r[1][1] = 0.0f; r[2][1] = v[0];
+ r[0][2] = v[1]; r[1][2] = -v[0]; r[2][2] = 0.0f;
}
BLI_INLINE void madd_m3_m3fl(float r[3][3], float m[3][3], float f)
@@ -567,7 +567,7 @@ DO_INLINE void del_bfmatrix(fmatrix3x3 *matrix)
DO_INLINE void cp_bfmatrix(fmatrix3x3 *to, fmatrix3x3 *from)
{
// TODO bounds checking
- memcpy(to, from, sizeof(fmatrix3x3) * (from[0].vcount+from[0].scount));
+ memcpy(to, from, sizeof(fmatrix3x3) * (from[0].vcount + from[0].scount));
}
/* init big matrix */
@@ -576,7 +576,7 @@ DO_INLINE void init_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
{
unsigned int i;
- for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
+ for (i = 0; i < matrix[0].vcount + matrix[0].scount; i++) {
cp_fmatrix(matrix[i].m, m3);
}
}
@@ -591,14 +591,14 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
for (i = 0; i < matrix[0].vcount; i++) {
cp_fmatrix(matrix[i].m, m3);
}
- for (j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++) {
+ for (j = matrix[0].vcount; j < matrix[0].vcount + matrix[0].scount; j++) {
cp_fmatrix(matrix[j].m, tmatrix);
}
}
/* SPARSE SYMMETRIC multiply big matrix with long vector*/
/* STATUS: verified */
-DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector *fLongVector)
+DO_INLINE void mul_bfmatrix_lfvector(float(*to)[3], fmatrix3x3 *from, lfVector *fLongVector)
{
unsigned int i = 0;
unsigned int vcount = from[0].vcount;
@@ -610,7 +610,7 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
{
#pragma omp section
{
- for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++) {
+ for (i = from[0].vcount; i < from[0].vcount + from[0].scount; i++) {
/* This is the lower triangle of the sparse matrix,
* therefore multiplication occurs with transposed submatrices. */
muladd_fmatrixT_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]);
@@ -618,7 +618,7 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
}
#pragma omp section
{
- for (i = 0; i < from[0].vcount+from[0].scount; i++) {
+ for (i = 0; i < from[0].vcount + from[0].scount; i++) {
muladd_fmatrix_fvector(temp[from[i].r], from[i].m, fLongVector[from[i].c]);
}
}
@@ -631,12 +631,12 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
/* SPARSE SYMMETRIC sub big matrix with big matrix*/
/* A -= B * float + C * float --> for big matrix */
/* VERIFIED */
-DO_INLINE void subadd_bfmatrixS_bfmatrixS( fmatrix3x3 *to, fmatrix3x3 *from, float aS, fmatrix3x3 *matrix, float bS)
+DO_INLINE void subadd_bfmatrixS_bfmatrixS(fmatrix3x3 *to, fmatrix3x3 *from, float aS, fmatrix3x3 *matrix, float bS)
{
unsigned int i = 0;
/* process diagonal elements */
- for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) {
+ for (i = 0; i < matrix[0].vcount + matrix[0].scount; i++) {
subadd_fmatrixS_fmatrixS(to[i].m, from[i].m, aS, matrix[i].m, bS);
}
@@ -646,27 +646,27 @@ DO_INLINE void subadd_bfmatrixS_bfmatrixS( fmatrix3x3 *to, fmatrix3x3 *from, flo
// simulator start
///////////////////////////////////////////////////////////////////
-typedef struct Implicit_Data {
+typedef struct Implicit_Data {
/* inputs */
- fmatrix3x3 *bigI; /* identity (constant) */
- fmatrix3x3 *tfm; /* local coordinate transform */
- fmatrix3x3 *M; /* masses */
- lfVector *F; /* forces */
- fmatrix3x3 *dFdV, *dFdX; /* force jacobians */
- int num_blocks; /* number of off-diagonal blocks (springs) */
+ fmatrix3x3 *bigI; /* identity (constant) */
+ fmatrix3x3 *tfm; /* local coordinate transform */
+ fmatrix3x3 *M; /* masses */
+ lfVector *F; /* forces */
+ fmatrix3x3 *dFdV, *dFdX; /* force jacobians */
+ int num_blocks; /* number of off-diagonal blocks (springs) */
/* motion state data */
- lfVector *X, *Xnew; /* positions */
- lfVector *V, *Vnew; /* velocities */
+ lfVector *X, *Xnew; /* positions */
+ lfVector *V, *Vnew; /* velocities */
/* internal solver data */
- lfVector *B; /* B for A*dV = B */
- fmatrix3x3 *A; /* A for A*dV = B */
+ lfVector *B; /* B for A*dV = B */
+ fmatrix3x3 *A; /* A for A*dV = B */
- lfVector *dV; /* velocity change (solution of A*dV = B) */
- lfVector *z; /* target velocity in constrained directions */
- fmatrix3x3 *S; /* filtering matrix for constraints */
- fmatrix3x3 *P, *Pinv; /* pre-conditioning matrix */
+ lfVector *dV; /* velocity change (solution of A*dV = B) */
+ lfVector *z; /* target velocity in constrained directions */
+ fmatrix3x3 *S; /* filtering matrix for constraints */
+ fmatrix3x3 *P, *Pinv; /* pre-conditioning matrix */
} Implicit_Data;
Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings)
@@ -751,7 +751,7 @@ BLI_INLINE void root_to_world_m3(Implicit_Data *data, int index, float r[3][3],
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
{
- unsigned int i=0;
+ unsigned int i = 0;
for (i = 0; i < S[0].vcount; i++) {
mul_m3_v3(S[i].m, V[S[i].r]);
@@ -762,8 +762,8 @@ DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S)
{
// Solves for unknown X in equation AX=B
- unsigned int conjgrad_loopcount=0, conjgrad_looplimit=100;
- float conjgrad_epsilon=0.0001f /* , conjgrad_lasterror=0 */ /* UNUSED */;
+ unsigned int conjgrad_loopcount = 0, conjgrad_looplimit = 100;
+ float conjgrad_epsilon = 0.0001f /* , conjgrad_lasterror=0 */ /* UNUSED */;
lfVector *q, *d, *tmp, *r;
float s, starget, a, s_prev;
unsigned int numverts = lA[0].vcount;
@@ -789,13 +789,13 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
s = dot_lfvector(r, r, numverts);
starget = s * sqrtf(conjgrad_epsilon);
- while (s>starget && conjgrad_loopcount < conjgrad_looplimit) {
+ while (s > starget && conjgrad_loopcount < conjgrad_looplimit) {
// Mul(q, A, d); // q = A*d;
mul_bfmatrix_lfvector(q, lA, d);
filter(q, S);
- a = s/dot_lfvector(d, q, numverts);
+ a = s / dot_lfvector(d, q, numverts);
// X = X + d*a;
add_lfvector_lfvectorS(ldV, ldV, d, a, numverts);
@@ -807,7 +807,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
s = dot_lfvector(r, r, numverts);
//d = r+d*(s/s_prev);
- add_lfvector_lfvectorS(d, r, d, (s/s_prev), numverts);
+ add_lfvector_lfvectorS(d, r, d, (s / s_prev), numverts);
filter(d, S);
@@ -821,15 +821,15 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
del_lfvector(r);
// printf("W/O conjgrad_loopcount: %d\n", conjgrad_loopcount);
- return conjgrad_loopcount<conjgrad_looplimit; // true means we reached desired accuracy in given time - ie stable
+ return conjgrad_loopcount < conjgrad_looplimit; // true means we reached desired accuracy in given time - ie stable
}
#endif
static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, ImplicitSolverResult *result)
{
// Solves for unknown X in equation AX=B
- unsigned int conjgrad_loopcount=0, conjgrad_looplimit=100;
- float conjgrad_epsilon=0.01f;
+ unsigned int conjgrad_loopcount = 0, conjgrad_looplimit = 100;
+ float conjgrad_epsilon = 0.01f;
unsigned int numverts = lA[0].vcount;
lfVector *fB = create_lfvector(numverts);
@@ -846,7 +846,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z,
cp_lfvector(fB, lB, numverts);
filter(fB, S);
bnorm2 = dot_lfvector(fB, fB, numverts);
- delta_target = conjgrad_epsilon*conjgrad_epsilon * bnorm2;
+ delta_target = conjgrad_epsilon * conjgrad_epsilon * bnorm2;
/* r = filter(B - A * dV) */
mul_bfmatrix_lfvector(AdV, lA, ldV);
@@ -921,7 +921,7 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
// Take only the diagonal blocks of A
// #pragma omp parallel for private(i) if (lA[0].vcount > CLOTH_OPENMP_LIMIT)
- for (i = 0; i<lA[0].vcount; i++) {
+ for (i = 0; i < lA[0].vcount; i++) {
// block diagonalizer
cp_fmatrix(P[i].m, lA[i].m);
inverse_fmatrix(Pinv[i].m, P[i].m);
@@ -933,9 +933,9 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
// version 1.3
static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, fmatrix3x3 *P, fmatrix3x3 *Pinv)
{
- unsigned int numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit=100;
+ unsigned int numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit = 100;
float delta0 = 0, deltaNew = 0, deltaOld = 0, alpha = 0;
- float conjgrad_epsilon=0.0001; // 0.2 is dt for steps=5
+ float conjgrad_epsilon = 0.0001; // 0.2 is dt for steps=5
lfVector *r = create_lfvector(numverts);
lfVector *p = create_lfvector(numverts);
lfVector *s = create_lfvector(numverts);
@@ -999,14 +999,14 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
printf("iterations: %d\n", iterations);
- return iterations<conjgrad_looplimit;
+ return iterations < conjgrad_looplimit;
}
#endif
// version 1.4
static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, fmatrix3x3 *P, fmatrix3x3 *Pinv, fmatrix3x3 *bigI)
{
- unsigned int numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit=100;
+ unsigned int numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit = 100;
float delta0 = 0, deltaNew = 0, deltaOld = 0, alpha = 0, tol = 0;
lfVector *r = create_lfvector(numverts);
lfVector *p = create_lfvector(numverts);
@@ -1065,9 +1065,9 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
double start = PIL_check_seconds_timer();
#endif
- tol = (0.01*0.2);
+ tol = (0.01 * 0.2);
- while ((deltaNew > delta0*tol*tol) && (iterations < conjgrad_looplimit))
+ while ((deltaNew > delta0 * tol * tol) && (iterations < conjgrad_looplimit))
{
iterations++;
@@ -1107,7 +1107,7 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
// printf("iterations: %d\n", iterations);
- return iterations<conjgrad_looplimit;
+ return iterations < conjgrad_looplimit;
}
#endif
@@ -1120,11 +1120,11 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
cp_bfmatrix(data->A, data->M);
- subadd_bfmatrixS_bfmatrixS(data->A, data->dFdV, dt, data->dFdX, (dt*dt));
+ subadd_bfmatrixS_bfmatrixS(data->A, data->dFdV, dt, data->dFdX, (dt * dt));
mul_bfmatrix_lfvector(dFdXmV, data->dFdX, data->V);
- add_lfvectorS_lfvectorS(data->B, data->F, dt, dFdXmV, (dt*dt), numverts);
+ add_lfvectorS_lfvectorS(data->B, data->F, dt, dFdXmV, (dt * dt), numverts);
#ifdef DEBUG_TIME
double start = PIL_check_seconds_timer();
@@ -1406,7 +1406,7 @@ static float calc_nor_area_tri(float nor[3], const float v1[3], const float v2[3
}
/* XXX does not support force jacobians yet, since the effector system does not provide them either */
-void BPH_mass_spring_force_face_wind(Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3])
+void BPH_mass_spring_force_face_wind(Implicit_Data *data, int v1, int v2, int v3, const float(*winvec)[3])
{
const float effector_scale = 0.02f;
float win[3], nor[3], area;
@@ -1445,7 +1445,7 @@ static void edge_wind_vertex(const float dir[3], float length, float radius, con
mul_v3_v3fl(f, wind, density * cross_section);
}
-void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float (*winvec)[3])
+void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, float radius1, float radius2, const float(*winvec)[3])
{
float win[3], dir[3], length;
float f[3], dfdx[3][3], dfdv[3][3];
@@ -1462,7 +1462,7 @@ void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, float
add_v3_v3(data->F[v2], f);
}
-void BPH_mass_spring_force_vertex_wind(Implicit_Data *data, int v, float UNUSED(radius), const float (*winvec)[3])
+void BPH_mass_spring_force_vertex_wind(Implicit_Data *data, int v, float UNUSED(radius), const float(*winvec)[3])
{
const float density = 0.01f; /* XXX arbitrary value, corresponds to effect of air density */
@@ -1481,7 +1481,7 @@ BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, fl
outerproduct(to, dir, dir);
sub_m3_m3m3(to, I, to);
- mul_m3_fl(to, (L/length));
+ mul_m3_fl(to, (L / length));
sub_m3_m3m3(to, to, I);
mul_m3_fl(to, k);
}
@@ -1491,10 +1491,10 @@ BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, fl
BLI_INLINE void dfdx_damp(float to[3][3], const float dir[3], float length, const float vel[3], float rest, float damping)
{
// inner spring damping vel is the relative velocity of the endpoints.
- // return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
+ // return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
mul_fvectorT_fvector(to, dir, dir);
sub_fmatrix_fmatrix(to, I, to);
- mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel)/MAX2(length, rest))));
+ mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel) / MAX2(length, rest))));
}
#endif
@@ -1516,7 +1516,7 @@ BLI_INLINE float fb(float length, float L)
BLI_INLINE float fbderiv(float length, float L)
{
- float x = length/L;
+ float x = length / L;
float xx = x * x;
float xxx = xx * x;
return (-46.164f * xxx + 102.579f * xx - 78.166f * x + 23.116f);
@@ -1543,7 +1543,7 @@ BLI_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
return -cb;
}
else {
- return -kb * fbderiv(length, L);
+ return -kb *fbderiv(length, L);
}
}
@@ -1558,7 +1558,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[
#if 0
if (length > L) {
if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
- ( ((length-L)*100.0f/L) > clmd->sim_parms->maxspringlen ))
+ ( ((length - L) * 100.0f / L) > clmd->sim_parms->maxspringlen))
{
// cut spring!
s->flags |= CSPRING_FLAG_DEACTIVATE;
@@ -1566,7 +1566,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[
}
}
#endif
- mul_v3_v3fl(r_dir, r_extent, 1.0f/(*r_length));
+ mul_v3_v3fl(r_dir, r_extent, 1.0f / (*r_length));
}
else {
zero_v3(r_dir);
@@ -1803,10 +1803,10 @@ BLI_INLINE void spring_grad_dir(Implicit_Data *data, int i, int j, float edge[3]
}
BLI_INLINE void spring_hairbend_forces(Implicit_Data *data, int i, int j, int k,
- const float goal[3],
- float stiffness, float damping,
- int q, const float dx[3], const float dv[3],
- float r_f[3])
+ const float goal[3],
+ float stiffness, float damping,
+ int q, const float dx[3], const float dv[3],
+ float r_f[3])
{
float edge_ij[3], dir_ij[3];
float edge_jk[3], dir_jk[3];
@@ -1852,9 +1852,9 @@ BLI_INLINE void spring_hairbend_forces(Implicit_Data *data, int i, int j, int k,
/* Finite Differences method for estimating the jacobian of the force */
BLI_INLINE void spring_hairbend_estimate_dfdx(Implicit_Data *data, int i, int j, int k,
- const float goal[3],
- float stiffness, float damping,
- int q, float dfdx[3][3])
+ const float goal[3],
+ float stiffness, float damping,
+ int q, float dfdx[3][3])
{
const float delta = 0.00001f; // TODO find a good heuristic for this
float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
@@ -1871,11 +1871,11 @@ BLI_INLINE void spring_hairbend_estimate_dfdx(Implicit_Data *data, int i, int j,
for (a = 0; a < 3; ++a) {
spring_hairbend_forces(data, i, j, k, goal, stiffness, damping,
- q, dvec_pos[a], dvec_null[a], f);
+ q, dvec_pos[a], dvec_null[a], f);
copy_v3_v3(dfdx[a], f);
spring_hairbend_forces(data, i, j, k, goal, stiffness, damping,
- q, dvec_neg[a], dvec_null[a], f);
+ q, dvec_neg[a], dvec_null[a], f);
sub_v3_v3(dfdx[a], f);
for (b = 0; b < 3; ++b) {
@@ -1886,9 +1886,9 @@ BLI_INLINE void spring_hairbend_estimate_dfdx(Implicit_Data *data, int i, int j,
/* Finite Differences method for estimating the jacobian of the force */
BLI_INLINE void spring_hairbend_estimate_dfdv(Implicit_Data *data, int i, int j, int k,
- const float goal[3],
- float stiffness, float damping,
- int q, float dfdv[3][3])
+ const float goal[3],
+ float stiffness, float damping,
+ int q, float dfdv[3][3])
{
const float delta = 0.00001f; // TODO find a good heuristic for this
float dvec_null[3][3], dvec_pos[3][3], dvec_neg[3][3];
@@ -1905,11 +1905,11 @@ BLI_INLINE void spring_hairbend_estimate_dfdv(Implicit_Data *data, int i, int j,
for (a = 0; a < 3; ++a) {
spring_hairbend_forces(data, i, j, k, goal, stiffness, damping,
- q, dvec_null[a], dvec_pos[a], f);
+ q, dvec_null[a], dvec_pos[a], f);
copy_v3_v3(dfdv[a], f);
spring_hairbend_forces(data, i, j, k, goal, stiffness, damping,
- q, dvec_null[a], dvec_neg[a], f);
+ q, dvec_null[a], dvec_neg[a], f);
sub_v3_v3(dfdv[a], f);
for (b = 0; b < 3; ++b) {
@@ -1922,7 +1922,7 @@ BLI_INLINE void spring_hairbend_estimate_dfdv(Implicit_Data *data, int i, int j,
* See "Artistic Simulation of Curly Hair" (Pixar technical memo #12-03a)
*/
bool BPH_mass_spring_force_spring_bending_hair(Implicit_Data *data, int i, int j, int k,
- const float target[3], float stiffness, float damping)
+ const float target[3], float stiffness, float damping)
{
float goal[3];
float fj[3], fk[3];
diff --git a/source/blender/physics/intern/implicit_eigen.cpp b/source/blender/physics/intern/implicit_eigen.cpp
index fd91df9c769..012764d5ff5 100644
--- a/source/blender/physics/intern/implicit_eigen.cpp
+++ b/source/blender/physics/intern/implicit_eigen.cpp
@@ -110,7 +110,7 @@ public:
coeffRef(k) = v[k];
}
- fVector& operator = (const ctype &v)
+ fVector& operator =(const ctype &v)
{
for (int k = 0; k < 3; ++k)
coeffRef(k) = v[k];
@@ -141,7 +141,7 @@ public:
coeffRef(l, k) = v[k][l];
}
- fMatrix& operator = (const ctype &v)
+ fMatrix& operator =(const ctype &v)
{
for (int k = 0; k < 3; ++k)
for (int l = 0; l < 3; ++l)
@@ -167,18 +167,18 @@ public:
}
template <typename T>
- lVector& operator = (T rhs)
+ lVector& operator =(T rhs)
{
base_t::operator=(rhs);
return *this;
}
- float* v3(int vertex)
+ float *v3(int vertex)
{
return &coeffRef(3 * vertex);
}
- const float* v3(int vertex) const
+ const float *v3(int vertex) const
{
return &coeffRef(3 * vertex);
}
@@ -244,7 +244,7 @@ typedef Eigen::ConjugateGradient<lMatrix, Eigen::Lower, Eigen::DiagonalPrecondit
#ifdef USE_EIGEN_CONSTRAINED_CG
typedef Eigen::ConstrainedConjugateGradient<lMatrix, Eigen::Lower, lMatrix,
Eigen::DiagonalPreconditioner<Scalar> >
- ConstraintConjGrad;
+ ConstraintConjGrad;
#endif
using Eigen::ComputationInfo;
@@ -350,9 +350,9 @@ BLI_INLINE void cross_m3_v3m3(float r[3][3], const float v[3], float m[3][3])
BLI_INLINE void cross_v3_identity(float r[3][3], const float v[3])
{
- r[0][0] = 0.0f; r[1][0] = v[2]; r[2][0] = -v[1];
- r[0][1] = -v[2]; r[1][1] = 0.0f; r[2][1] = v[0];
- r[0][2] = v[1]; r[1][2] = -v[0]; r[2][2] = 0.0f;
+ r[0][0] = 0.0f; r[1][0] = v[2]; r[2][0] = -v[1];
+ r[0][1] = -v[2]; r[1][1] = 0.0f; r[2][1] = v[0];
+ r[0][2] = v[1]; r[1][2] = -v[0]; r[2][2] = 0.0f;
}
BLI_INLINE void madd_m3_m3fl(float r[3][3], float m[3][3], float f)
@@ -422,28 +422,28 @@ struct Implicit_Data {
int numverts;
/* inputs */
- lMatrix M; /* masses */
- lVector F; /* forces */
- lMatrix dFdX, dFdV; /* force jacobians */
+ lMatrix M; /* masses */
+ lVector F; /* forces */
+ lMatrix dFdX, dFdV; /* force jacobians */
- fMatrixVector tfm; /* local coordinate transform */
+ fMatrixVector tfm; /* local coordinate transform */
/* motion state data */
- lVector X, Xnew; /* positions */
- lVector V, Vnew; /* velocities */
+ lVector X, Xnew; /* positions */
+ lVector V, Vnew; /* velocities */
/* internal solver data */
- lVector B; /* B for A*dV = B */
- lMatrix A; /* A for A*dV = B */
+ lVector B; /* B for A*dV = B */
+ lMatrix A; /* A for A*dV = B */
- lVector dV; /* velocity change (solution of A*dV = B) */
- lVector z; /* target velocity in constrained directions */
- lMatrix S; /* filtering matrix for constraints */
+ lVector dV; /* velocity change (solution of A*dV = B) */
+ lVector z; /* target velocity in constrained directions */
+ lMatrix S; /* filtering matrix for constraints */
/* temporary constructors */
- lMatrixCtor iM; /* masses */
- lMatrixCtor idFdX, idFdV; /* force jacobians */
- lMatrixCtor iS; /* filtering matrix for constraints */
+ lMatrixCtor iM; /* masses */
+ lMatrixCtor idFdX, idFdV; /* force jacobians */
+ lMatrixCtor iS; /* filtering matrix for constraints */
};
Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings)
@@ -516,10 +516,10 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
cg.filter() = data->S;
#endif
- data->A = data->M - dt * data->dFdV - dt*dt * data->dFdX;
+ data->A = data->M - dt * data->dFdV - dt * dt * data->dFdX;
cg.compute(data->A);
- data->B = dt * data->F + dt*dt * data->dFdX * data->V;
+ data->B = dt * data->F + dt * dt * data->dFdX * data->V;
#ifdef IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
printf("==== A ====\n");
@@ -786,7 +786,7 @@ static float calc_nor_area_tri(float nor[3], const float v1[3], const float v2[3
}
/* XXX does not support force jacobians yet, since the effector system does not provide them either */
-void BPH_mass_spring_force_face_wind(Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3])
+void BPH_mass_spring_force_face_wind(Implicit_Data *data, int v1, int v2, int v3, const float(*winvec)[3])
{
const float effector_scale = 0.02f;
float win[3], nor[3], area;
@@ -806,7 +806,7 @@ void BPH_mass_spring_force_face_wind(Implicit_Data *data, int v1, int v2, int v3
madd_v3_v3fl(data->F.v3(v3), nor, factor * dot_v3v3(win, nor));
}
-void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, const float (*winvec)[3])
+void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, const float(*winvec)[3])
{
const float effector_scale = 0.01;
float win[3], dir[3], nor[3], length;
@@ -830,7 +830,7 @@ BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, fl
outerproduct(to, dir, dir);
sub_m3_m3m3(to, I, to);
- mul_m3_fl(to, (L/length));
+ mul_m3_fl(to, (L / length));
sub_m3_m3m3(to, to, I);
mul_m3_fl(to, k);
}
@@ -840,10 +840,10 @@ BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, fl
BLI_INLINE void dfdx_damp(float to[3][3], const float dir[3], float length, const float vel[3], float rest, float damping)
{
// inner spring damping vel is the relative velocity of the endpoints.
- // return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
+ // return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
mul_fvectorT_fvector(to, dir, dir);
sub_fmatrix_fmatrix(to, I, to);
- mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel)/MAX2(length, rest))));
+ mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel) / MAX2(length, rest))));
}
#endif
@@ -862,7 +862,7 @@ BLI_INLINE float fb(float length, float L)
BLI_INLINE float fbderiv(float length, float L)
{
- float x = length/L;
+ float x = length / L;
return (-46.164f * powf(x, 3) + 102.579f * powf(x, 2) - 78.166f * x + 23.116f);
}
@@ -888,7 +888,7 @@ BLI_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
return -cb;
}
else {
- return -kb * fbderiv(length, L);
+ return -kb *fbderiv(length, L);
}
}
@@ -903,7 +903,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[
#if 0
if (length > L) {
if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
- ( ((length-L)*100.0f/L) > clmd->sim_parms->maxspringlen ))
+ ( ((length - L) * 100.0f / L) > clmd->sim_parms->maxspringlen))
{
// cut spring!
s->flags |= CSPRING_FLAG_DEACTIVATE;
@@ -911,7 +911,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data, int i, int j, float r_extent[
}
}
#endif
- mul_v3_v3fl(r_dir, r_extent, 1.0f/(*r_length));
+ mul_v3_v3fl(r_dir, r_extent, 1.0f / (*r_length));
}
else {
zero_v3(r_dir);
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 3950f623f54..ba2167e74a5 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -913,7 +913,7 @@ static PyObject *bpy_bmesh_to_mesh(BPy_BMesh *self, PyObject *args)
/* we could have the user do this but if they forget blender can easy crash
* since the references arrays for the objects derived meshes are now invalid */
- DEG_id_tag_update(&me->id, OB_RECALC_DATA);
+ DEG_id_tag_update(&me->id, ID_RECALC_GEOMETRY);
Py_RETURN_NONE;
}
diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt
index b561504505b..bd7306cddf2 100644
--- a/source/blender/python/intern/CMakeLists.txt
+++ b/source/blender/python/intern/CMakeLists.txt
@@ -58,6 +58,7 @@ set(SRC
bpy_app_opensubdiv.c
bpy_app_openvdb.c
bpy_app_sdl.c
+ bpy_app_timers.c
bpy_app_translations.c
bpy_capi_utils.c
bpy_driver.c
@@ -96,6 +97,7 @@ set(SRC
bpy_app_opensubdiv.h
bpy_app_openvdb.h
bpy_app_sdl.h
+ bpy_app_timers.h
bpy_app_translations.h
bpy_capi_utils.h
bpy_driver.h
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index d8c74bdf565..bba9eee0316 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -49,6 +49,7 @@
/* modules */
#include "bpy_app_icons.h"
+#include "bpy_app_timers.h"
#include "BLI_utildefines.h"
@@ -124,6 +125,7 @@ static PyStructSequence_Field app_info_fields[] = {
/* Modules (not struct sequence). */
{(char *)"icons", (char *)"Manage custom icons"},
+ {(char *)"timers", (char *)"Manage timers"},
{NULL},
};
@@ -137,6 +139,7 @@ PyDoc_STRVAR(bpy_app_doc,
"\n"
" bpy.app.handlers.rst\n"
" bpy.app.icons.rst\n"
+" bpy.app.timers.rst\n"
" bpy.app.translations.rst\n"
);
@@ -220,6 +223,7 @@ static PyObject *make_app_info(void)
/* modules */
SetObjItem(BPY_app_icons_module());
+ SetObjItem(BPY_app_timers_module());
#undef SetIntItem
#undef SetStrItem
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index 44647eb21a0..a251bdeb15b 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -66,6 +66,7 @@ static PyStructSequence_Field app_cb_info_fields[] = {
{(char *)"depsgraph_update_pre", (char *)"on depsgraph update (pre)"},
{(char *)"depsgraph_update_post", (char *)"on depsgraph update (post)"},
{(char *)"version_update", (char *)"on ending the versioning code"},
+ {(char *)"load_factory_startup_post", (char *)"on loading factory startup (after)"},
/* sets the permanent tag */
# define APP_CB_OTHER_FIELDS 1
diff --git a/source/blender/python/intern/bpy_app_timers.c b/source/blender/python/intern/bpy_app_timers.c
new file mode 100644
index 00000000000..cd0e57200ec
--- /dev/null
+++ b/source/blender/python/intern/bpy_app_timers.c
@@ -0,0 +1,199 @@
+/*
+ * ***** 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/python/intern/bpy_app_timers.c
+ * \ingroup pythonintern
+ */
+
+#include <Python.h>
+#include "BLI_utildefines.h"
+#include "BLI_timer.h"
+#include "PIL_time.h"
+
+#include "BPY_extern.h"
+#include "bpy_app_timers.h"
+
+#include "../generic/py_capi_utils.h"
+#include "../generic/python_utildefines.h"
+
+
+static double handle_returned_value(PyObject *function, PyObject *ret)
+{
+ if (ret == NULL) {
+ PyErr_PrintEx(0);
+ PyErr_Clear();
+ return -1;
+ }
+
+ if (ret == Py_None) {
+ return -1;
+ }
+
+ double value = PyFloat_AsDouble(ret);
+ if (value == -1.0f && PyErr_Occurred()) {
+ PyErr_Clear();
+ printf("Error: 'bpy.app.timers' callback ");
+ PyObject_Print(function, stdout, Py_PRINT_RAW);
+ printf(" did not return None or float.\n");
+ return -1;
+ }
+
+ if (value < 0.0) {
+ value = 0.0;
+ }
+
+ return value;
+}
+
+static double py_timer_execute(uintptr_t UNUSED(uuid), void *user_data)
+{
+ PyObject *function = user_data;
+
+ PyGILState_STATE gilstate;
+ gilstate = PyGILState_Ensure();
+
+ PyObject *py_ret = PyObject_CallObject(function, NULL);
+ double ret = handle_returned_value(function, py_ret);
+
+ PyGILState_Release(gilstate);
+
+ return ret;
+}
+
+static void py_timer_free(uintptr_t UNUSED(uuid), void *user_data)
+{
+ PyObject *function = user_data;
+
+ PyGILState_STATE gilstate;
+ gilstate = PyGILState_Ensure();
+
+ Py_DECREF(function);
+
+ PyGILState_Release(gilstate);
+}
+
+
+PyDoc_STRVAR(bpy_app_timers_register_doc,
+".. function:: register(function, first_interval=0, persistent=False)\n"
+"\n"
+" Add a new function that will be called after the specified amount of seconds.\n"
+" The function gets no arguments and is expected to return either None or a float.\n"
+" If ``None`` is returned, the timer will be unregistered.\n"
+" A returned number specifies the delay until the function is called again.\n"
+" ``functools.partial`` can be used to assign some parameters.\n"
+"\n"
+" :arg function: The function that should called.\n"
+" :type function: Callable[[], Union[float, None]]\n"
+" :arg first_interval: Seconds until the callback should be called the first time.\n"
+" :type first_interval: float\n"
+" :arg persistent: Don't remove timer when a new file is loaded.\n"
+" :type persistent: bool\n"
+);
+static PyObject *bpy_app_timers_register(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
+{
+ PyObject *function;
+ double first_interval = 0;
+ int persistent = false;
+
+ static const char *_keywords[] = {"function", "first_interval", "persistent", NULL};
+ static _PyArg_Parser _parser = {"O|$dp:register", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(
+ args, kw, &_parser,
+ &function, &first_interval, &persistent))
+ {
+ return NULL;
+ }
+
+ if (!PyCallable_Check(function)) {
+ PyErr_SetString(PyExc_TypeError, "function is not callable");
+ return NULL;
+ }
+
+ Py_INCREF(function);
+ BLI_timer_register(
+ (intptr_t)function,
+ py_timer_execute, function, py_timer_free,
+ first_interval, persistent);
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(bpy_app_timers_unregister_doc,
+".. function:: unregister(function)\n"
+"\n"
+" Unregister timer.\n"
+"\n"
+" :arg function: Function to unregister.\n"
+" :type function: function\n"
+);
+static PyObject *bpy_app_timers_unregister(PyObject *UNUSED(self), PyObject *function)
+{
+ if (!BLI_timer_unregister((intptr_t)function)) {
+ PyErr_SetString(PyExc_ValueError, "Error: function is not registered");
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(bpy_app_timers_is_registered_doc,
+".. function:: is_registered(function)\n"
+"\n"
+" Check if this function is registered as a timer.\n"
+"\n"
+" :arg function: Function to check.\n"
+" :type function: int\n"
+" :return: True when this function is registered, otherwise False.\n"
+" :rtype: bool\n"
+);
+static PyObject *bpy_app_timers_is_registered(PyObject *UNUSED(self), PyObject *function)
+{
+ bool ret = BLI_timer_is_registered((intptr_t)function);
+ return PyBool_FromLong(ret);
+}
+
+
+static struct PyMethodDef M_AppTimers_methods[] = {
+ {"register", (PyCFunction)bpy_app_timers_register,
+ METH_VARARGS | METH_KEYWORDS, bpy_app_timers_register_doc},
+ {"unregister", (PyCFunction)bpy_app_timers_unregister,
+ METH_O, bpy_app_timers_unregister_doc},
+ {"is_registered", (PyCFunction)bpy_app_timers_is_registered,
+ METH_O, bpy_app_timers_is_registered_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+static struct PyModuleDef M_AppTimers_module_def = {
+ PyModuleDef_HEAD_INIT,
+ "bpy.app.timers", /* m_name */
+ NULL, /* m_doc */
+ 0, /* m_size */
+ M_AppTimers_methods, /* m_methods */
+ NULL, /* m_reload */
+ NULL, /* m_traverse */
+ NULL, /* m_clear */
+ NULL, /* m_free */
+};
+
+PyObject *BPY_app_timers_module(void)
+{
+ PyObject *sys_modules = PyImport_GetModuleDict();
+ PyObject *mod = PyModule_Create(&M_AppTimers_module_def);
+ PyDict_SetItem(sys_modules, PyModule_GetNameObject(mod), mod);
+ return mod;
+}
diff --git a/source/blender/editors/include/ED_keymap_templates.h b/source/blender/python/intern/bpy_app_timers.h
index 0a1882d005a..ddf0e258e67 100644
--- a/source/blender/editors/include/ED_keymap_templates.h
+++ b/source/blender/python/intern/bpy_app_timers.h
@@ -18,15 +18,13 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file ED_keymap_templates.h
- * \ingroup editors
+/** \file blender/python/intern/bpy_app_timers.h
+ * \ingroup pythonintern
*/
-#ifndef __ED_KEYMAP_TEMPLATES_H__
-#define __ED_KEYMAP_TEMPLATES_H__
+#ifndef __BPY_APP_TIMERS_H__
+#define __BPY_APP_TIMERS_H__
-struct wmKeyMap;
+PyObject *BPY_app_timers_module(void);
-void ED_keymap_template_select_all(struct wmKeyMap *keymap, const char *idname);
-
-#endif /* __ED_KEYMAP_TEMPLATES_H__ */
+#endif /* __BPY_APP_TIMERS_H__ */
diff --git a/source/blender/python/mathutils/CMakeLists.txt b/source/blender/python/mathutils/CMakeLists.txt
index adf7c85d7c9..811cc1acbab 100644
--- a/source/blender/python/mathutils/CMakeLists.txt
+++ b/source/blender/python/mathutils/CMakeLists.txt
@@ -23,6 +23,7 @@ set(INC
../../blenlib
../../blenkernel
../../bmesh
+ ../../depsgraph
../../makesdna
../../../../intern/guardedalloc
)
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c
index dba5d52846b..b247123ecff 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -57,6 +57,8 @@
#include "BKE_mesh.h"
#include "BKE_mesh_runtime.h"
+#include "DEG_depsgraph_query.h"
+
#include "bmesh.h"
#include "../bmesh/bmesh_py_types.h"
@@ -1050,32 +1052,31 @@ static PyObject *C_BVHTree_FromBMesh(PyObject *UNUSED(cls), PyObject *args, PyOb
/* return various derived meshes based on requested settings */
static Mesh *bvh_get_mesh(
- const char *funcname, struct Scene *scene, Object *ob,
- bool use_deform, bool use_render, bool use_cage)
+ const char *funcname, struct Depsgraph *depsgraph, struct Scene *scene, Object *ob,
+ bool use_deform, bool use_cage)
{
- /* TODO: This doesn't work currently because of missing depsgraph. */
-#if 0
/* we only need minimum mesh data for topology and vertex locations */
CustomDataMask mask = CD_MASK_BAREMESH;
+ const bool use_render = DEG_get_mode(depsgraph) == DAG_EVAL_RENDER;
/* Write the display mesh into the dummy mesh */
if (use_deform) {
if (use_render) {
if (use_cage) {
PyErr_Format(PyExc_ValueError,
- "%s(...): cage arg is unsupported when (render=True)", funcname);
+ "%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER", funcname);
return NULL;
}
else {
- return mesh_create_derived_render(scene, ob, mask);
+ return mesh_create_eval_final_render(depsgraph, scene, ob, mask);
}
}
else {
if (use_cage) {
- return mesh_get_derived_deform(scene, ob, mask); /* ob->derivedDeform */
+ return mesh_get_eval_deform(depsgraph, scene, ob, mask); /* ob->derivedDeform */
}
else {
- return mesh_get_derived_final(scene, ob, mask); /* ob->derivedFinal */
+ return mesh_get_eval_final(depsgraph, scene, ob, mask); /* ob->derivedFinal */
}
}
}
@@ -1084,59 +1085,52 @@ static Mesh *bvh_get_mesh(
if (use_render) {
if (use_cage) {
PyErr_Format(PyExc_ValueError,
- "%s(...): cage arg is unsupported when (render=True)", funcname);
+ "%s(...): cage arg is unsupported when dependency graph evaluation mode is RENDER", funcname);
return NULL;
}
else {
- return mesh_create_derived_no_deform_render(scene, ob, NULL, mask);
+ return mesh_create_eval_no_deform_render(depsgraph, scene, ob, NULL, mask);
}
}
else {
if (use_cage) {
PyErr_Format(PyExc_ValueError,
- "%s(...): cage arg is unsupported when (deform=False, render=False)", funcname);
+ "%s(...): cage arg is unsupported when deform=False and dependency graph evaluation mode is not RENDER", funcname);
return NULL;
}
else {
- return mesh_create_derived_no_deform(scene, ob, NULL, mask);
+ return mesh_create_eval_no_deform(depsgraph, scene, ob, NULL, mask);
}
}
}
-#else
- UNUSED_VARS(funcname, scene, ob, use_deform, use_render, use_cage);
-#endif
-
- return NULL;
}
PyDoc_STRVAR(C_BVHTree_FromObject_doc,
-".. classmethod:: FromObject(object, scene, deform=True, render=False, cage=False, epsilon=0.0)\n"
+".. classmethod:: FromObject(object, depsgraph, deform=True, render=False, cage=False, epsilon=0.0)\n"
"\n"
" BVH tree based on :class:`Object` data.\n"
"\n"
" :arg object: Object data.\n"
" :type object: :class:`Object`\n"
-" :arg scene: Scene data to use for evaluating the mesh.\n"
-" :type scene: :class:`Scene`\n"
+" :arg depsgraph: Depsgraph to use for evaluating the mesh.\n"
+" :type depsgraph: :class:`Depsgraph`\n"
" :arg deform: Use mesh with deformations.\n"
" :type deform: bool\n"
-" :arg render: Use render settings.\n"
-" :type render: bool\n"
-" :arg cage: Use render settings.\n"
+" :arg cage: Use modifiers cage.\n"
" :type cage: bool\n"
PYBVH_FROM_GENERIC_EPSILON_DOC
);
static PyObject *C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyObject *kwargs)
{
/* note, options here match 'bpy_bmesh_from_object' */
- const char *keywords[] = {"object", "scene", "deform", "render", "cage", "epsilon", NULL};
+ const char *keywords[] = {"object", "depsgraph", "deform", "cage", "epsilon", NULL};
- PyObject *py_ob, *py_scene;
+ PyObject *py_ob, *py_depsgraph;
Object *ob;
+ struct Depsgraph *depsgraph;
struct Scene *scene;
Mesh *mesh;
bool use_deform = true;
- bool use_render = false;
bool use_cage = false;
const MLoopTri *lt;
@@ -1148,19 +1142,20 @@ static PyObject *C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyO
float epsilon = 0.0f;
if (!PyArg_ParseTupleAndKeywords(
- args, kwargs, (char *)"OO|$O&O&O&f:BVHTree.FromObject", (char **)keywords,
- &py_ob, &py_scene,
+ args, kwargs, (char *)"OO|$O&O&f:BVHTree.FromObject", (char **)keywords,
+ &py_ob, &py_depsgraph,
PyC_ParseBool, &use_deform,
- PyC_ParseBool, &use_render,
PyC_ParseBool, &use_cage,
&epsilon) ||
((ob = PyC_RNA_AsPointer(py_ob, "Object")) == NULL) ||
- ((scene = PyC_RNA_AsPointer(py_scene, "Scene")) == NULL))
+ ((depsgraph = PyC_RNA_AsPointer(py_depsgraph, "Depsgraph")) == NULL))
{
return NULL;
}
- mesh = bvh_get_mesh("BVHTree", scene, ob, use_deform, use_render, use_cage);
+ scene = DEG_get_evaluated_scene(depsgraph);
+ mesh = bvh_get_mesh("BVHTree", depsgraph, scene, ob, use_deform, use_cage);
+
if (mesh == NULL) {
return NULL;
}
diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c
index 05a1cd43530..5e3e86c8ddf 100644
--- a/source/blender/python/mathutils/mathutils_noise.c
+++ b/source/blender/python/mathutils/mathutils_noise.c
@@ -970,7 +970,6 @@ static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args, PyObjec
for (i = 0; i < 4; i++) {
PyObject *v = Vector_CreatePyObject(pa + 3 * i, 3, NULL);
PyList_SET_ITEM(list, i, v);
- Py_DECREF(v);
}
ret = Py_BuildValue("[[ffff]O]", da[0], da[1], da[2], da[3], list);
diff --git a/source/blender/render/extern/include/RE_bake.h b/source/blender/render/extern/include/RE_bake.h
index e7f446f07a7..298bb72a02c 100644
--- a/source/blender/render/extern/include/RE_bake.h
+++ b/source/blender/render/extern/include/RE_bake.h
@@ -59,7 +59,6 @@ typedef struct BakePixel {
typedef struct BakeHighPolyData {
struct Object *ob;
- struct ModifierData *tri_mod;
struct Mesh *me;
char restrict_flag;
bool is_flip_object;
diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/source/bake_api.c
index ca3907e8b73..c906413d7d7 100644
--- a/source/blender/render/intern/source/bake_api.c
+++ b/source/blender/render/intern/source/bake_api.c
@@ -432,8 +432,7 @@ static TriTessFace *mesh_calc_tri_tessface(
me->totloop, me->totpoly,
looptri);
-
- const float *precomputed_normals = me_eval ? CustomData_get_layer(&me_eval->pdata, CD_NORMAL) : NULL;
+ const float *precomputed_normals = CustomData_get_layer(&me->pdata, CD_NORMAL);
const bool calculate_normal = precomputed_normals ? false : true;
for (i = 0; i < tottri; i++) {
@@ -514,11 +513,11 @@ bool RE_bake_pixels_populate_from_objects(
tris_high[i] = mesh_calc_tri_tessface(highpoly[i].me, false, NULL);
me_highpoly[i] = highpoly[i].me;
- BKE_mesh_tessface_ensure(me_highpoly[i]);
+ BKE_mesh_runtime_looptri_ensure(me_highpoly[i]);
- if (me_highpoly[i]->totface != 0) {
+ if (me_highpoly[i]->runtime.looptris.len != 0) {
/* Create a bvh-tree for each highpoly object */
- BKE_bvhtree_from_mesh_get(&treeData[i], me_highpoly[i], BVHTREE_FROM_FACES, 2);
+ BKE_bvhtree_from_mesh_get(&treeData[i], me_highpoly[i], BVHTREE_FROM_LOOPTRI, 2);
if (treeData[i].tree == NULL) {
printf("Baking: out of memory while creating BHVTree for object \"%s\"\n", highpoly[i].ob->id.name + 2);
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index a30a72d9dc8..f3b1cc0d529 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -1517,16 +1517,6 @@ static void do_render_seq(Render *re)
re->i.cfra = cfra;
- if (recurs_depth == 0) {
- /* otherwise sequencer animation isn't updated */
- /* TODO(sergey): Currently depsgraph is only used to check whether it is an active
- * edit window or not to deal with unkeyed changes. We don't have depsgraph here yet,
- * but we also dont' deal with unkeyed changes. But still nice to get proper depsgraph
- * within tjhe render pipeline, somehow.
- */
- BKE_animsys_evaluate_all_animation(re->main, NULL, re->scene, (float)cfra); // XXX, was BKE_scene_frame_get(re->scene)
- }
-
recurs_depth++;
if ((re->r.mode & R_BORDER) && (re->r.mode & R_CROP) == 0) {
@@ -1631,6 +1621,7 @@ static void do_render_all_options(Render *re)
{
Object *camera;
bool render_seq = false;
+ int cfra = re->r.cfra;
re->current_scene_update(re->suh, re->scene);
@@ -1642,6 +1633,12 @@ static void do_render_all_options(Render *re)
BKE_image_all_free_anim_ibufs(re->main, re->r.cfra);
BKE_sequencer_all_free_anim_ibufs(re->main, re->r.cfra);
+ /* Update for sequencer and compositing animation.
+ * TODO: ideally we would create a depsgraph with a copy of the scene
+ * like the render engine, but sequencer and compositing do not (yet?)
+ * work with copy-on-write. */
+ BKE_animsys_evaluate_all_animation(re->main, NULL, re->scene, (float)cfra);
+
if (RE_engine_render(re, 1)) {
/* in this case external render overrides all */
}
@@ -2080,7 +2077,7 @@ void RE_RenderFreestyleExternal(Render *re)
RE_SetView(re, mat);
/* force correct matrix for scaled cameras */
- DEG_id_tag_update_ex(re->main, &camera->id, OB_RECALC_OB);
+ DEG_id_tag_update_ex(re->main, &camera->id, ID_RECALC_TRANSFORM);
}
printf("add freestyle\n");
diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c
deleted file mode 100644
index 2daa4123536..00000000000
--- a/source/blender/render/intern/source/voxeldata.c
+++ /dev/null
@@ -1,571 +0,0 @@
-/*
- * ***** 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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Raul Fernandez Hernandez (Farsthary), Matt Ebb.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/render/intern/source/voxeldata.c
- * \ingroup render
- */
-
-
-#include <math.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef WIN32
-#include "BLI_winstuff.h"
-#endif
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_blenlib.h"
-#include "BLI_threads.h"
-#include "BLI_voxel.h"
-#include "BLI_utildefines.h"
-
-#include "BLT_translation.h"
-
-#include "IMB_imbuf.h"
-#include "IMB_imbuf_types.h"
-
-#include "BKE_cloth.h"
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_main.h"
-#include "BKE_modifier.h"
-
-#include "smoke_API.h"
-#include "BPH_mass_spring.h"
-
-#include "DNA_texture_types.h"
-#include "DNA_object_force_types.h"
-#include "DNA_object_types.h"
-#include "DNA_particle_types.h"
-#include "DNA_modifier_types.h"
-#include "DNA_smoke_types.h"
-
-
-#include "render_types.h"
-#include "texture.h"
-#include "voxeldata.h"
-
-static bool is_vd_res_ok(VoxelData *vd)
-{
- /* arbitrary large value so corrupt headers don't break */
- const int min = 1, max = 100000;
- return (vd->resol[0] >= min && vd->resol[0] <= max) &&
- (vd->resol[1] >= min && vd->resol[1] <= max) &&
- (vd->resol[2] >= min && vd->resol[2] <= max);
-}
-
-/* use size_t because the result may exceed INT_MAX */
-static size_t vd_resol_size(VoxelData *vd)
-{
- return (size_t)vd->resol[0] * (size_t)vd->resol[1] * (size_t)vd->resol[2];
-}
-
-static int load_frame_blendervoxel(VoxelData *vd, FILE *fp, int frame)
-{
- const size_t size = vd_resol_size(vd);
- size_t offset = sizeof(VoxelDataHeader);
-
- if (is_vd_res_ok(vd) == false)
- return 0;
-
- vd->dataset = MEM_mapallocN(sizeof(float) * size, "voxel dataset");
- if (vd->dataset == NULL) return 0;
-
- if (fseek(fp, frame * size * sizeof(float) + offset, 0) == -1)
- return 0;
- if (fread(vd->dataset, sizeof(float), size, fp) != size)
- return 0;
-
- vd->cachedframe = frame;
- vd->ok = 1;
- return 1;
-}
-
-static int load_frame_raw8(VoxelData *vd, FILE *fp, int frame)
-{
- const size_t size = vd_resol_size(vd);
- size_t i;
- char *data_c;
-
- if (is_vd_res_ok(vd) == false)
- return 0;
-
- vd->dataset = MEM_mapallocN(sizeof(float) * size, "voxel dataset");
- if (vd->dataset == NULL) return 0;
- data_c = (char *)MEM_mallocN(sizeof(char) * size, "temporary voxel file reading storage");
- if (data_c == NULL) {
- MEM_freeN(vd->dataset);
- vd->dataset = NULL;
- return 0;
- }
-
- if (fseek(fp, (frame - 1) * size * sizeof(char), 0) == -1) {
- MEM_freeN(data_c);
- MEM_freeN(vd->dataset);
- vd->dataset = NULL;
- return 0;
- }
- if (fread(data_c, sizeof(char), size, fp) != size) {
- MEM_freeN(data_c);
- MEM_freeN(vd->dataset);
- vd->dataset = NULL;
- return 0;
- }
-
- for (i = 0; i < size; i++) {
- vd->dataset[i] = (float)data_c[i] / 255.f;
- }
- MEM_freeN(data_c);
-
- vd->cachedframe = frame;
- vd->ok = 1;
- return 1;
-}
-
-static void load_frame_image_sequence(VoxelData *vd, Tex *tex)
-{
- ImBuf *ibuf;
- Image *ima = tex->ima;
- ImageUser *tiuser = &tex->iuser;
- ImageUser iuser = *(tiuser);
- int x = 0, y = 0, z = 0;
- const float *rf;
-
- if (!ima) return;
- if (iuser.frames == 0) return;
-
- ima->source = IMA_SRC_SEQUENCE;
- iuser.framenr = 1 + iuser.offset;
-
- /* find the first valid ibuf and use it to initialize the resolution of the data set */
- /* need to do this in advance so we know how much memory to allocate */
- ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
- while (!ibuf && (iuser.framenr < iuser.frames)) {
- iuser.framenr++;
- ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
- }
- if (!ibuf) return;
- if (!ibuf->rect_float) IMB_float_from_rect(ibuf);
-
- vd->flag |= TEX_VD_STILL;
- vd->resol[0] = ibuf->x;
- vd->resol[1] = ibuf->y;
- vd->resol[2] = iuser.frames;
- vd->dataset = MEM_mapallocN(sizeof(float) * vd_resol_size(vd), "voxel dataset");
-
- for (z = 0; z < iuser.frames; z++) {
- /* get a new ibuf for each frame */
- if (z > 0) {
- iuser.framenr++;
- BKE_image_release_ibuf(ima, ibuf, NULL);
- ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
- if (!ibuf) break;
- if (!ibuf->rect_float) IMB_float_from_rect(ibuf);
- }
- rf = ibuf->rect_float;
-
- for (y = 0; y < ibuf->y; y++) {
- for (x = 0; x < ibuf->x; x++) {
- /* currently averaged to monchrome */
- vd->dataset[BLI_VOXEL_INDEX(x, y, z, vd->resol)] = (rf[0] + rf[1] + rf[2]) / 3.0f;
- rf += 4;
- }
- }
-
- BKE_image_free_anim_ibufs(ima, iuser.framenr);
- }
-
- BKE_image_release_ibuf(ima, ibuf, NULL);
-
- vd->ok = 1;
- return;
-}
-
-static int read_voxeldata_header(FILE *fp, struct VoxelData *vd)
-{
- VoxelDataHeader *h = (VoxelDataHeader *)MEM_mallocN(sizeof(VoxelDataHeader), "voxel data header");
-
- rewind(fp);
- if (fread(h, sizeof(VoxelDataHeader), 1, fp) != 1) {
- MEM_freeN(h);
- return 0;
- }
-
- vd->resol[0] = h->resolX;
- vd->resol[1] = h->resolY;
- vd->resol[2] = h->resolZ;
-
- MEM_freeN(h);
- return 1;
-}
-
-static void init_frame_smoke(VoxelData *vd, int cfra)
-{
-#ifdef WITH_SMOKE
- Object *ob;
- ModifierData *md;
-
- vd->dataset = NULL;
- if (vd->object == NULL) return;
- ob = vd->object;
-
- /* draw code for smoke */
- if ((md = (ModifierData *)modifiers_findByType(ob, eModifierType_Smoke))) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
- SmokeDomainSettings *sds = smd->domain;
-
- if (sds && sds->fluid) {
- BLI_rw_mutex_lock(sds->fluid_mutex, THREAD_LOCK_READ);
-
- if (!sds->fluid) {
- BLI_rw_mutex_unlock(sds->fluid_mutex);
- return;
- }
-
- if (cfra < sds->point_cache[0]->startframe)
- ; /* don't show smoke before simulation starts, this could be made an option in the future */
- else if (vd->smoked_type == TEX_VD_SMOKEHEAT) {
- size_t totRes;
- size_t i;
- float *heat;
-
- if (!smoke_has_heat(sds->fluid)) {
- BLI_rw_mutex_unlock(sds->fluid_mutex);
- return;
- }
-
- copy_v3_v3_int(vd->resol, sds->res);
- totRes = vd_resol_size(vd);
- vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
- /* get heat data */
- heat = smoke_get_heat(sds->fluid);
-
- /* scale heat values from -2.0-2.0 to 0.0-1.0 */
- for (i = 0; i < totRes; i++) {
- vd->dataset[i] = (heat[i] + 2.0f) / 4.0f;
- }
- }
- else if (vd->smoked_type == TEX_VD_SMOKEVEL) {
- size_t totRes;
- size_t i;
- float *xvel, *yvel, *zvel;
-
- copy_v3_v3_int(vd->resol, sds->res);
- totRes = vd_resol_size(vd);
- vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
- /* get velocity data */
- xvel = smoke_get_velocity_x(sds->fluid);
- yvel = smoke_get_velocity_y(sds->fluid);
- zvel = smoke_get_velocity_z(sds->fluid);
-
- /* map velocities between 0 and 0.3f */
- for (i = 0; i < totRes; i++) {
- vd->dataset[i] = sqrtf(xvel[i] * xvel[i] + yvel[i] * yvel[i] + zvel[i] * zvel[i]) * 3.0f;
- }
-
- }
- else if (vd->smoked_type == TEX_VD_SMOKEFLAME) {
- size_t totRes;
- float *flame;
-
- if (sds->flags & MOD_SMOKE_HIGHRES) {
- if (!smoke_turbulence_has_fuel(sds->wt)) {
- BLI_rw_mutex_unlock(sds->fluid_mutex);
- return;
- }
- smoke_turbulence_get_res(sds->wt, vd->resol);
- flame = smoke_turbulence_get_flame(sds->wt);
- }
- else {
- if (!smoke_has_fuel(sds->fluid)) {
- BLI_rw_mutex_unlock(sds->fluid_mutex);
- return;
- }
- copy_v3_v3_int(vd->resol, sds->res);
- flame = smoke_get_flame(sds->fluid);
- }
-
- /* always store copy, as smoke internal data can change */
- totRes = vd_resol_size(vd);
- vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data");
- memcpy(vd->dataset, flame, sizeof(float)*totRes);
- }
- else {
- size_t totCells;
- int depth = 4;
- vd->data_type = TEX_VD_RGBA_PREMUL;
-
- /* data resolution */
- if (sds->flags & MOD_SMOKE_HIGHRES) {
- smoke_turbulence_get_res(sds->wt, vd->resol);
- }
- else {
- copy_v3_v3_int(vd->resol, sds->res);
- }
-
- /* TODO: is_vd_res_ok(rvd) doesnt check this resolution */
- totCells = vd_resol_size(vd) * depth;
- /* always store copy, as smoke internal data can change */
- vd->dataset = MEM_mapallocN(sizeof(float) * totCells, "smoke data");
-
- if (sds->flags & MOD_SMOKE_HIGHRES) {
- if (smoke_turbulence_has_colors(sds->wt)) {
- smoke_turbulence_get_rgba(sds->wt, vd->dataset, 1);
- }
- else {
- smoke_turbulence_get_rgba_from_density(sds->wt, sds->active_color, vd->dataset, 1);
- }
- }
- else {
- if (smoke_has_colors(sds->fluid)) {
- smoke_get_rgba(sds->fluid, vd->dataset, 1);
- }
- else {
- smoke_get_rgba_from_density(sds->fluid, sds->active_color, vd->dataset, 1);
- }
- }
- } /* end of fluid condition */
-
- BLI_rw_mutex_unlock(sds->fluid_mutex);
- }
- }
-
- vd->ok = 1;
-
-#else // WITH_SMOKE
- (void)vd;
- (void)cfra;
-
- vd->dataset = NULL;
-#endif
-}
-
-static void init_frame_hair(VoxelData *vd, int UNUSED(cfra))
-{
- Object *ob;
- ModifierData *md;
-
- vd->dataset = NULL;
- if (vd->object == NULL) return;
- ob = vd->object;
-
- if ((md = (ModifierData *)modifiers_findByType(ob, eModifierType_ParticleSystem))) {
- ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
-
- if (pmd->psys && pmd->psys->clmd) {
- vd->ok |= BPH_cloth_solver_get_texture_data(ob, pmd->psys->clmd, vd);
- }
- }
-}
-
-void cache_voxeldata(Tex *tex, int scene_frame)
-{
- VoxelData *vd = tex->vd;
- FILE *fp;
- int curframe;
- char path[sizeof(vd->source_path)];
-
- /* only re-cache if dataset needs updating */
- if ((vd->flag & TEX_VD_STILL) || (vd->cachedframe == scene_frame))
- if (vd->ok) return;
-
- /* clear out old cache, ready for new */
- if (vd->dataset) {
- MEM_freeN(vd->dataset);
- vd->dataset = NULL;
- }
- /* reset data_type */
- vd->data_type = TEX_VD_INTENSITY;
-
- if (vd->flag & TEX_VD_STILL)
- curframe = vd->still_frame;
- else
- curframe = scene_frame;
-
- BLI_strncpy(path, vd->source_path, sizeof(path));
-
- /* each type is responsible for setting to true */
- vd->ok = false;
-
- switch (vd->file_format) {
- case TEX_VD_IMAGE_SEQUENCE:
- load_frame_image_sequence(vd, tex);
- return;
- case TEX_VD_SMOKE:
- init_frame_smoke(vd, scene_frame);
- return;
- case TEX_VD_HAIR:
- init_frame_hair(vd, scene_frame);
- return;
- case TEX_VD_BLENDERVOXEL:
- BLI_path_abs(path, BKE_main_blendfile_path_from_global());
- fp = BLI_fopen(path, "rb");
- if (!fp) return;
-
- if (read_voxeldata_header(fp, vd))
- load_frame_blendervoxel(vd, fp, curframe - 1);
-
- fclose(fp);
- return;
- case TEX_VD_RAW_8BIT:
- BLI_path_abs(path, BKE_main_blendfile_path_from_global());
- fp = BLI_fopen(path, "rb");
- if (!fp) return;
-
- load_frame_raw8(vd, fp, curframe);
- fclose(fp);
- return;
- }
-}
-
-void make_voxeldata(struct Render *re)
-{
- Tex *tex;
-
- re->i.infostr = IFACE_("Loading voxel datasets");
- re->stats_draw(re->sdh, &re->i);
-
- /* XXX: should be doing only textures used in this render */
- for (tex = re->main->tex.first; tex; tex = tex->id.next) {
- if (tex->id.us && tex->type == TEX_VOXELDATA) {
- cache_voxeldata(tex, re->r.cfra);
- }
- }
-
- re->i.infostr = NULL;
- re->stats_draw(re->sdh, &re->i);
-
-}
-
-int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texres)
-{
- VoxelData *vd = tex->vd;
- float co[3], offset[3] = {0.5, 0.5, 0.5}, a;
- int retval = (vd->data_type == TEX_VD_RGBA_PREMUL) ? TEX_RGB : TEX_INT;
- int depth = (vd->data_type == TEX_VD_RGBA_PREMUL) ? 4 : 1;
- int ch;
-
- if (vd->dataset == NULL) {
- texres->tin = 0.0f;
- return 0;
- }
-
- /* scale lookup from 0.0-1.0 (original location) to -1.0, 1.0, consistent with image texture tex coords */
- /* in implementation this works backwards, bringing sample locations from -1.0, 1.0
- * to the range 0.0, 1.0, before looking up in the voxel structure. */
- copy_v3_v3(co, texvec);
- mul_v3_fl(co, 0.5f);
- add_v3_v3(co, offset);
-
- /* co is now in the range 0.0, 1.0 */
- switch (vd->extend) {
- case TEX_CLIP:
- {
- if ((co[0] < 0.f || co[0] > 1.f) || (co[1] < 0.f || co[1] > 1.f) || (co[2] < 0.f || co[2] > 1.f)) {
- texres->tin = 0.f;
- return retval;
- }
- break;
- }
- case TEX_REPEAT:
- {
- co[0] = co[0] - floorf(co[0]);
- co[1] = co[1] - floorf(co[1]);
- co[2] = co[2] - floorf(co[2]);
- break;
- }
- case TEX_EXTEND:
- {
- CLAMP(co[0], 0.f, 1.f);
- CLAMP(co[1], 0.f, 1.f);
- CLAMP(co[2], 0.f, 1.f);
- break;
- }
- }
-
- for (ch = 0; ch < depth; ch++) {
- float *dataset = vd->dataset + ch*vd->resol[0]*vd->resol[1]*vd->resol[2];
- float *result = &texres->tin;
-
- if (vd->data_type == TEX_VD_RGBA_PREMUL) {
- switch (ch) {
- case 0:
- result = &texres->tr;
- break;
- case 1:
- result = &texres->tg;
- break;
- case 2:
- result = &texres->tb;
- break;
- }
- }
-
- switch (vd->interp_type) {
- case TEX_VD_NEARESTNEIGHBOR:
- *result = BLI_voxel_sample_nearest(dataset, vd->resol, co);
- break;
- case TEX_VD_LINEAR:
- *result = BLI_voxel_sample_trilinear(dataset, vd->resol, co);
- break;
- case TEX_VD_QUADRATIC:
- *result = BLI_voxel_sample_triquadratic(dataset, vd->resol, co);
- break;
- case TEX_VD_TRICUBIC_CATROM:
- case TEX_VD_TRICUBIC_BSPLINE:
- *result = BLI_voxel_sample_tricubic(dataset, vd->resol, co, (vd->interp_type == TEX_VD_TRICUBIC_BSPLINE));
- break;
- }
- }
-
- a = texres->tin;
- texres->tin *= vd->int_multiplier;
- BRICONT;
-
- if (vd->data_type == TEX_VD_RGBA_PREMUL) {
- /* unmultiply */
- if (a>0.001f) {
- texres->tr /= a;
- texres->tg /= a;
- texres->tb /= a;
- }
- texres->talpha = 1;
- }
- else {
- texres->tr = texres->tin;
- texres->tg = texres->tin;
- texres->tb = texres->tin;
- }
-
- texres->ta = texres->tin;
- BRICONTRGB;
-
- return retval;
-}
diff --git a/source/blender/shader_fx/intern/FX_shader_shadow.c b/source/blender/shader_fx/intern/FX_shader_shadow.c
index e3a9543fcb4..ba1bd4fe907 100644
--- a/source/blender/shader_fx/intern/FX_shader_shadow.c
+++ b/source/blender/shader_fx/intern/FX_shader_shadow.c
@@ -61,6 +61,8 @@ static void initData(ShaderFxData *md)
ARRAY_SET_ITEMS(gpfx->blur, 5, 5);
gpfx->samples = 2;
+
+ gpfx->object = NULL;
}
static void copyData(const ShaderFxData *md, ShaderFxData *target)
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index 0e8a468192c..7f7612cea35 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -74,8 +74,10 @@ bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *
int WM_keymap_item_to_string(wmKeyMapItem *kmi, const bool compact, char *result, const int result_len);
wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid);
+wmKeyMap *WM_keymap_list_find_spaceid_or_empty(ListBase *lb, const char *idname, int spaceid, int regionid);
wmKeyMap *WM_keymap_ensure(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid);
wmKeyMap *WM_keymap_find_all(const struct bContext *C, const char *idname, int spaceid, int regionid);
+wmKeyMap *WM_keymap_find_all_spaceid_or_empty(const struct bContext *C, const char *idname, int spaceid, int regionid);
wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap);
bool WM_keymap_remove(struct wmKeyConfig *keyconfig, struct wmKeyMap *keymap);
bool WM_keymap_poll(struct bContext *C, struct wmKeyMap *keymap);
diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h
index 7410bf4ab09..4318179c203 100644
--- a/source/blender/windowmanager/WM_toolsystem.h
+++ b/source/blender/windowmanager/WM_toolsystem.h
@@ -46,9 +46,9 @@ struct WorkSpace;
/* wm_toolsystem.c */
#define WM_TOOLSYSTEM_SPACE_MASK ( \
- (1 << SPACE_VIEW3D) | \
- (1 << SPACE_IMAGE) \
-)
+ (1 << SPACE_IMAGE) | \
+ (1 << SPACE_NODE) | \
+ (1 << SPACE_VIEW3D) )
/* Values that define a categoey of active tool. */
typedef struct bToolKey { int space_type; int mode; } bToolKey;
@@ -86,11 +86,11 @@ int WM_toolsystem_mode_from_spacetype(
struct ViewLayer *view_layer, struct ScrArea *sa, int space_type);
bool WM_toolsystem_key_from_context(
struct ViewLayer *view_layer, struct ScrArea *sa, bToolKey *tkey);
-void WM_toolsystem_update_from_context(
- struct bContext *C,
- struct WorkSpace *workspace, struct Scene *scene, struct ScrArea *sa);
void WM_toolsystem_update_from_context_view3d(struct bContext *C);
+void WM_toolsystem_update_from_context(
+ struct bContext *C, struct WorkSpace *workspace, struct ViewLayer *view_layer,
+ struct ScrArea *sa);
bool WM_toolsystem_active_tool_is_brush(const struct bContext *C);
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
index 517f92491f0..67b7149c0bd 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
@@ -67,6 +67,7 @@
/* Allow gizmo part's to be single click only,
* dragging falls back to activating their 'drag_part' action. */
#define USE_DRAG_DETECT
+#define DRAG_THRESHOLD (U.tweak_threshold * U.dpi_fac)
/* -------------------------------------------------------------------- */
/** \name wmGizmoGroup
@@ -445,7 +446,7 @@ static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event)
wmGizmoMap *gzmap = mtweak->gzmap;
if (mtweak->drag_state == DRAG_DETECT) {
if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
- if (len_manhattan_v2v2_int(&event->x, gzmap->gzmap_context.event_xy) > 2) {
+ if (len_manhattan_v2v2_int(&event->x, gzmap->gzmap_context.event_xy) >= DRAG_THRESHOLD) {
mtweak->drag_state = DRAG_IDLE;
gz->highlight_part = gz->drag_part;
}
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index ec8e012b1a7..00ffc3de861 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -1039,7 +1039,9 @@ void WM_gizmomap_message_subscribe(
bContext *C, wmGizmoMap *gzmap, ARegion *ar, struct wmMsgBus *mbus)
{
for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
- if (!WM_gizmo_group_type_poll(C, gzgroup->type)) {
+ if ((gzgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0 ||
+ !WM_gizmo_group_type_poll(C, gzgroup->type))
+ {
continue;
}
for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index d760780beb8..d6058ac0d28 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -73,6 +73,7 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "WM_toolsystem.h"
#include "wm.h"
#include "wm_draw.h"
#include "wm_window.h"
@@ -542,6 +543,13 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
ED_area_update_region_sizes(wm, win, sa);
+ if (sa->flag & AREA_FLAG_ACTIVE_TOOL_UPDATE) {
+ if ((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) {
+ WM_toolsystem_update_from_context(C, CTX_wm_workspace(C), CTX_data_view_layer(C), sa);
+ }
+ sa->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE;
+ }
+
/* Then do actual drawing of regions. */
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->visible && ar->do_draw) {
@@ -614,8 +622,14 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
/* Draw into the window framebuffer, in full window coordinates. */
wmWindowViewport(win);
+
+ /* We draw on all pixels of the windows so we don't need to clear them before.
+ * Actually this is only a problem when resizing the window.
+ * If it becomes a problem we should clear only when window size changes. */
+#if 0
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
+#endif
/* Blit non-overlapping area regions. */
ED_screen_areas_iter(win, screen, sa) {
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index a9a248f027b..9df05d307cc 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -51,6 +51,7 @@
#include "BLI_dynstr.h"
#include "BLI_utildefines.h"
#include "BLI_math.h"
+#include "BLI_timer.h"
#include "BKE_context.h"
#include "BKE_idprop.h"
@@ -372,6 +373,8 @@ void wm_event_do_notifiers(bContext *C)
if (wm == NULL)
return;
+ BLI_timer_execute();
+
/* disable? - keep for now since its used for window level notifiers. */
#if 1
/* cache & catch WM level notifiers, such as frame change, scene/screen set */
@@ -2635,15 +2638,15 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
event->x = x;
event->y = y;
- win->eventstate->check_click = 0;
- win->eventstate->check_drag = 0;
+ win->eventstate->check_click = false;
+ win->eventstate->check_drag = false;
}
}
}
else {
wmWindow *win = CTX_wm_window(C);
if (win) {
- win->eventstate->check_drag = 0;
+ win->eventstate->check_drag = false;
}
}
}
@@ -2851,15 +2854,17 @@ static bool wm_event_pie_filter(wmWindow *win, const wmEvent *event)
}
#ifdef USE_WORKSPACE_TOOL
-static void wm_event_gizmo_temp_handler_apply(
+static void wm_event_temp_tool_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(
+ wmKeyMap *km = WM_keymap_find_all_spaceid_or_empty(
C, tref_rt->keymap, sa->spacetype, RGN_TYPE_WINDOW);
+ /* We shouldn't use keymaps from unrelated spaces. */
if (km != NULL) {
+ // printf("Keymap: '%s' -> '%s'\n", tref_rt->keymap, sa->runtime.tool->idname);
sneaky_handler->keymap = km;
sneaky_handler->keymap_tool = sa->runtime.tool;
@@ -2871,11 +2876,14 @@ static void wm_event_gizmo_temp_handler_apply(
/* Head of list or after last gizmo. */
BLI_insertlinkafter(&ar->handlers, handler_last, sneaky_handler);
}
+ else {
+ printf("Keymap: '%s' not found for tool '%s'\n", tref_rt->keymap, sa->runtime.tool->idname);
+ }
}
}
}
-static void wm_event_gizmo_temp_handler_clear(
+static void wm_event_temp_tool_handler_clear(
bContext *UNUSED(C), ScrArea *UNUSED(sa), ARegion *ar, wmEventHandler *sneaky_handler)
{
if (sneaky_handler->keymap) {
@@ -3068,13 +3076,13 @@ void wm_event_do_handlers(bContext *C)
* to fetch its current keymap.
*/
wmEventHandler sneaky_handler = {NULL};
- wm_event_gizmo_temp_handler_apply(C, sa, ar, &sneaky_handler);
+ wm_event_temp_tool_handler_apply(C, sa, ar, &sneaky_handler);
#endif /* USE_WORKSPACE_TOOL */
action |= wm_handlers_do(C, event, &ar->handlers);
#ifdef USE_WORKSPACE_TOOL
- wm_event_gizmo_temp_handler_clear(C, sa, ar, &sneaky_handler);
+ wm_event_temp_tool_handler_clear(C, sa, ar, &sneaky_handler);
#endif /* USE_WORKSPACE_TOOL */
/* fileread case (python), [#29489] */
@@ -3115,6 +3123,15 @@ void wm_event_do_handlers(bContext *C)
}
+ /* If press was handled, we don't want to do click. This way
+ * press in tool keymap can override click in editor keymap.*/
+ if (ISMOUSE_BUTTON(event->type) &&
+ event->val == KM_PRESS &&
+ !wm_action_not_handled(action))
+ {
+ win->eventstate->check_click = false;
+ }
+
/* update previous mouse position for following events to use */
win->eventstate->prevx = event->x;
win->eventstate->prevy = event->y;
@@ -4539,7 +4556,7 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win)
#ifdef USE_WORKSPACE_TOOL
wmEventHandler sneaky_handler = {NULL};
- wm_event_gizmo_temp_handler_apply(C, sa, ar, &sneaky_handler);
+ wm_event_temp_tool_handler_apply(C, sa, ar, &sneaky_handler);
#endif
ListBase *handlers[] = {
@@ -4572,7 +4589,7 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win)
}
#ifdef USE_WORKSPACE_TOOL
- wm_event_gizmo_temp_handler_clear(C, sa, ar, &sneaky_handler);
+ wm_event_temp_tool_handler_clear(C, sa, ar, &sneaky_handler);
#endif
if (memcmp(&cd_prev.text, &cd->text, sizeof(cd_prev.text)) != 0) {
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index d90ad24dc16..0bf24b3e615 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -475,7 +475,8 @@ void wm_file_read_report(bContext *C, Main *bmain)
* Logic shared between #WM_file_read & #wm_homefile_read,
* updates to make after reading a file.
*/
-static void wm_file_read_post(bContext *C, const bool is_startup_file, const bool reset_app_template)
+static void wm_file_read_post(
+ bContext *C, const bool is_startup_file, const bool is_factory_startup, const bool reset_app_template)
{
bool addons_loaded = false;
wmWindowManager *wm = CTX_wm_manager(C);
@@ -527,6 +528,9 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
/* important to do before NULL'ing the context */
BLI_callback_exec(bmain, NULL, BLI_CB_EVT_VERSION_UPDATE);
BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_POST);
+ if (is_factory_startup) {
+ BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_FACTORY_STARTUP_POST);
+ }
#if 1
WM_event_add_notifier(C, NC_WM | ND_FILEREAD, NULL);
@@ -603,7 +607,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
Main *bmain = CTX_data_main(C);
/* when loading startup.blend's, we can be left with a blank path */
- if (BKE_main_blendfile_path(bmain)) {
+ if (BKE_main_blendfile_path(bmain)[0] != '\0') {
G.save_over = 1;
}
else {
@@ -633,7 +637,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
}
}
- wm_file_read_post(C, false, false);
+ wm_file_read_post(C, false, false, false);
success = true;
}
@@ -733,15 +737,17 @@ static bool wm_app_template_has_userpref(const char *app_template)
* \param app_template_override: Template to use instead of the template defined in user-preferences.
* When not-null, this is written into the user preferences.
*/
-int wm_homefile_read(
+void wm_homefile_read(
bContext *C, ReportList *reports,
bool use_factory_settings, bool use_empty_data, bool use_userdef,
- const char *filepath_startup_override, const char *app_template_override)
+ const char *filepath_startup_override, const char *app_template_override,
+ bool *r_is_factory_startup)
{
Main *bmain = G_MAIN; /* Context does not always have valid main pointer here... */
ListBase wmbase;
bool success = false;
+ bool filepath_startup_is_factory = true;
char filepath_startup[FILE_MAX];
char filepath_userdef[FILE_MAX];
@@ -762,6 +768,9 @@ int wm_homefile_read(
bool read_userdef_from_memory = false;
eBLOReadSkip skip_flags = use_userdef ? 0 : BLO_READ_SKIP_USERDEF;
+ /* True if we load startup.blend from memory or use app-template startup.blend which the user hasn't saved. */
+ bool is_factory_startup = true;
+
/* options exclude eachother */
BLI_assert((use_factory_settings && filepath_startup_override) == 0);
@@ -787,6 +796,7 @@ int wm_homefile_read(
if (!use_factory_settings) {
if (cfgdir) {
BLI_path_join(filepath_startup, sizeof(filepath_startup), cfgdir, BLENDER_STARTUP_FILE, NULL);
+ filepath_startup_is_factory = false;
if (use_userdef) {
BLI_path_join(filepath_userdef, sizeof(filepath_startup), cfgdir, BLENDER_USERPREF_FILE, NULL);
}
@@ -797,6 +807,7 @@ int wm_homefile_read(
if (filepath_startup_override) {
BLI_strncpy(filepath_startup, filepath_startup_override, FILE_MAX);
+ filepath_startup_is_factory = false;
}
}
@@ -838,7 +849,9 @@ int wm_homefile_read(
}
if ((app_template != NULL) && (app_template[0] != '\0')) {
- if (!BKE_appdir_app_template_id_search(app_template, app_template_system, sizeof(app_template_system))) {
+ if (!BKE_appdir_app_template_id_search(
+ app_template, app_template_system, sizeof(app_template_system)))
+ {
/* Can safely continue with code below, just warn it's not found. */
BKE_reportf(reports, RPT_WARNING, "Application Template '%s' not found.", app_template);
}
@@ -850,6 +863,7 @@ int wm_homefile_read(
if (!use_factory_settings) {
BLI_path_join(app_template_config, sizeof(app_template_config), cfgdir, app_template, NULL);
BLI_path_join(filepath_startup, sizeof(filepath_startup), app_template_config, BLENDER_STARTUP_FILE, NULL);
+ filepath_startup_is_factory = false;
if (BLI_access(filepath_startup, R_OK) != 0) {
filepath_startup[0] = '\0';
}
@@ -860,6 +874,7 @@ int wm_homefile_read(
if (filepath_startup[0] == '\0') {
BLI_path_join(filepath_startup, sizeof(filepath_startup), app_template_system, BLENDER_STARTUP_FILE, NULL);
+ filepath_startup_is_factory = true;
/* Update defaults only for system templates. */
update_defaults = true;
@@ -881,8 +896,11 @@ int wm_homefile_read(
printf("\nNote: No (valid) '%s' found, fall back to built-in default.\n\n", filepath_startup);
success = false;
}
- if (success && update_defaults) {
- BLO_update_defaults_startup_blend(CTX_data_main(C), app_template);
+ if (success) {
+ if (update_defaults) {
+ BLO_update_defaults_startup_blend(CTX_data_main(C), app_template);
+ }
+ is_factory_startup = filepath_startup_is_factory;
}
}
@@ -987,9 +1005,11 @@ int wm_homefile_read(
/* start with save preference untitled.blend */
G.save_over = 0;
- wm_file_read_post(C, true, reset_app_template);
+ wm_file_read_post(C, true, is_factory_startup, reset_app_template);
- return true;
+ if (r_is_factory_startup) {
+ *r_is_factory_startup = is_factory_startup;
+ }
}
/** \name WM History File API
@@ -1529,7 +1549,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op)
BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_STARTUP_FILE, NULL);
- printf("trying to save homefile at %s ", filepath);
+ printf("Writing homefile: '%s' ", filepath);
ED_editors_flush_edits(C, false);
@@ -1617,6 +1637,7 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op)
bool ok_write;
BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL);
+ printf("Writing userprefs: '%s' ", filepath);
if (use_template_userpref) {
ok_write = BKE_blendfile_userdef_write_app_template(filepath, op->reports);
}
@@ -1640,6 +1661,8 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op)
if ((cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, U.app_template))) {
/* Also save app-template prefs */
BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL);
+
+ printf("Writing userprefs app-template: '%s' ", filepath);
if (BKE_blendfile_userdef_write(filepath, op->reports) != 0) {
printf("ok\n");
}
@@ -1659,7 +1682,7 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op)
void WM_OT_save_userpref(wmOperatorType *ot)
{
- ot->name = "Save User Preferences";
+ ot->name = "Save Preferences";
ot->idname = "WM_OT_save_userpref";
ot->description = "Save user preferences separately, overrides startup file preferences";
@@ -1740,15 +1763,11 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op)
app_template = WM_init_state_app_template_get();
}
- if (wm_homefile_read(C, op->reports, use_factory_settings, use_empty_data, use_userdef, filepath, app_template)) {
- if (use_splash) {
- WM_init_splash(C);
- }
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
+ wm_homefile_read(C, op->reports, use_factory_settings, use_empty_data, use_userdef, filepath, app_template, NULL);
+ if (use_splash) {
+ WM_init_splash(C);
}
+ return OPERATOR_FINISHED;
}
static int wm_homefile_read_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
@@ -2043,7 +2062,6 @@ void WM_OT_revert_mainfile(wmOperatorType *ot)
void WM_recover_last_session(bContext *C, ReportList *reports)
{
- Main *bmain = CTX_data_main(C);
char filepath[FILE_MAX];
BLI_make_file_string("/", filepath, BKE_tempdir_base(), BLENDER_QUIT_FILE);
@@ -2056,6 +2074,7 @@ void WM_recover_last_session(bContext *C, ReportList *reports)
G.fileflags &= ~G_FILE_RECOVER;
/* XXX bad global... fixme */
+ Main *bmain = CTX_data_main(C);
if (BKE_main_blendfile_path(bmain)[0] != '\0') {
G.file_loaded = 1; /* prevents splash to show */
}
diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c
index b29da15a334..faaf5f61421 100644
--- a/source/blender/windowmanager/intern/wm_gesture_ops.c
+++ b/source/blender/windowmanager/intern/wm_gesture_ops.c
@@ -79,7 +79,7 @@ static void gesture_modal_end(bContext *C, wmOperator *op)
}
}
-static void gesture_modal_state_to_operator(wmOperator *op, int modal_state)
+static void gesture_modal_state_to_operator(wmOperator *op, int modal_state, bool check_is_set)
{
PropertyRNA *prop;
@@ -87,12 +87,12 @@ static void gesture_modal_state_to_operator(wmOperator *op, int modal_state)
case GESTURE_MODAL_SELECT:
case GESTURE_MODAL_DESELECT:
if ((prop = RNA_struct_find_property(op->ptr, "deselect"))) {
- if (!RNA_property_is_set(op->ptr, prop)) {
+ if (!check_is_set || !RNA_property_is_set(op->ptr, prop)) {
RNA_property_boolean_set(op->ptr, prop, (modal_state == GESTURE_MODAL_DESELECT));
}
}
if ((prop = RNA_struct_find_property(op->ptr, "mode"))) {
- if (!RNA_property_is_set(op->ptr, prop)) {
+ if (!check_is_set || !RNA_property_is_set(op->ptr, prop)) {
RNA_property_enum_set(op->ptr, prop, (modal_state == GESTURE_MODAL_DESELECT) ? SEL_OP_SUB : SEL_OP_ADD);
}
}
@@ -100,7 +100,7 @@ static void gesture_modal_state_to_operator(wmOperator *op, int modal_state)
case GESTURE_MODAL_IN:
case GESTURE_MODAL_OUT:
if ((prop = RNA_struct_find_property(op->ptr, "zoom_out"))) {
- if (!RNA_property_is_set(op->ptr, prop)) {
+ if (!check_is_set || !RNA_property_is_set(op->ptr, prop)) {
RNA_property_boolean_set(op->ptr, prop, (modal_state == GESTURE_MODAL_OUT));
}
}
@@ -171,7 +171,7 @@ static bool gesture_box_apply(bContext *C, wmOperator *op)
return 0;
}
- gesture_modal_state_to_operator(op, gesture->modal_state);
+ gesture_modal_state_to_operator(op, gesture->modal_state, true);
retval = op->type->exec(C, op);
OPERATOR_RETVAL_CHECK(retval);
@@ -331,7 +331,9 @@ static void gesture_circle_apply(bContext *C, wmOperator *op)
RNA_int_set(op->ptr, "y", rect->ymin);
RNA_int_set(op->ptr, "radius", rect->xmax);
- gesture_modal_state_to_operator(op, gesture->modal_state);
+ /* When 'wait_for_input' is false, use properties to get the selection state.
+ * typically tool settings. This is done so executing as a mode can select & de-select, see: T58594. */
+ gesture_modal_state_to_operator(op, gesture->modal_state, !gesture->wait_for_input);
if (op->type->exec) {
int retval;
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index e6114b44221..e4ae9495c61 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -54,6 +54,7 @@
#include "BLI_string.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
+#include "BLI_timer.h"
#include "BLO_writefile.h"
#include "BLO_undofile.h"
@@ -254,7 +255,10 @@ void WM_init(bContext *C, int argc, const char **argv)
WM_msgbus_types_init();
/* get the default database, plus a wm */
- wm_homefile_read(C, NULL, G.factory_startup, false, true, NULL, WM_init_state_app_template_get());
+ bool is_factory_startup = true;
+ wm_homefile_read(
+ C, NULL, G.factory_startup, false, true, NULL, WM_init_state_app_template_get(),
+ &is_factory_startup);
/* Call again to set from userpreferences... */
BLT_lang_set(NULL);
@@ -335,6 +339,9 @@ void WM_init(bContext *C, int argc, const char **argv)
BLI_callback_exec(bmain, NULL, BLI_CB_EVT_VERSION_UPDATE);
BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_POST);
+ if (is_factory_startup) {
+ BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_FACTORY_STARTUP_POST);
+ }
wm_file_read_report(C, bmain);
@@ -460,6 +467,8 @@ void WM_exit_ext(bContext *C, const bool do_python)
}
}
+ BLI_timer_free();
+
WM_paneltype_clear();
BKE_addon_pref_type_free();
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 92d51c9a400..cb627b465f4 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -334,6 +334,7 @@ static void *do_job_thread(void *job_v)
{
wmJob *wm_job = job_v;
+ BLI_thread_put_thread_on_fast_node();
wm_job->startjob(wm_job->run_customdata, &wm_job->stop, &wm_job->do_update, &wm_job->progress);
wm_job->ready = true;
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 27c816a4d7d..4c00b99e13e 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -806,6 +806,18 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int
return NULL;
}
+wmKeyMap *WM_keymap_list_find_spaceid_or_empty(ListBase *lb, const char *idname, int spaceid, int regionid)
+{
+ wmKeyMap *km;
+
+ for (km = lb->first; km; km = km->next)
+ if (ELEM(km->spaceid, spaceid, SPACE_EMPTY) && km->regionid == regionid)
+ if (STREQLEN(idname, km->idname, KMAP_MAX_NAME))
+ return km;
+
+ return NULL;
+}
+
wmKeyMap *WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
{
wmKeyMap *km = WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
@@ -827,6 +839,13 @@ wmKeyMap *WM_keymap_find_all(const bContext *C, const char *idname, int spaceid,
return WM_keymap_list_find(&wm->userconf->keymaps, idname, spaceid, regionid);
}
+wmKeyMap *WM_keymap_find_all_spaceid_or_empty(const bContext *C, const char *idname, int spaceid, int regionid)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+
+ return WM_keymap_list_find_spaceid_or_empty(&wm->userconf->keymaps, idname, spaceid, regionid);
+}
+
/* ****************** modal keymaps ************ */
/* modal maps get linked to a running operator, and filter the keys before sending to modal() callback */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index e0bd48dfec1..bdfa13c3ac3 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1397,7 +1397,6 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
uiBlock *block;
uiBut *but;
uiStyle *style = UI_style_get();
- const char *version_suffix = NULL;
#ifndef WITH_HEADLESS
extern char datatoc_splash_png[];
@@ -1453,7 +1452,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
ibuf_template = IMB_loadiffname(splash_filepath, IB_rect, NULL);
if (ibuf_template) {
const int x_expect = ibuf->x;
- const int y_expect = 282 * (int)U.dpi_fac;
+ const int y_expect = 250 * (int)U.dpi_fac;
/* don't cover the header text */
if (ibuf_template->x == x_expect && ibuf_template->y == y_expect) {
memcpy(ibuf->rect, ibuf_template->rect, ibuf_template->x * ibuf_template->y * sizeof(char[4]));
@@ -1477,55 +1476,63 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
- but = uiDefBut(block, UI_BTYPE_IMAGE, 0, "", 0, 0.5f * U.widget_unit, U.dpi_fac * 501, U.dpi_fac * 282, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */
+ but = uiDefBut(block, UI_BTYPE_IMAGE, 0, "", 0, 0.5f * U.widget_unit, U.dpi_fac * 501, U.dpi_fac * 250, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */
UI_but_func_set(but, wm_block_splash_close, block, NULL);
UI_block_func_set(block, wm_block_splash_refreshmenu, block, NULL);
/* label for 'a' bugfix releases, or 'Release Candidate 1'...
* avoids recreating splash for version updates */
+ const char *version_suffix = NULL;
+
if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "alpha")) {
- version_suffix = "Alpha 2";
+ version_suffix = " Alpha";
}
else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "beta")) {
- version_suffix = "Beta";
+ version_suffix = " Beta";
}
else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "rc")) {
- version_suffix = "Release Candidate";
+ version_suffix = " Release Candidate";
}
else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "release")) {
version_suffix = STRINGIFY(BLENDER_VERSION_CHAR);
}
- if (version_suffix != NULL && version_suffix[0]) {
+
+ char *version = BLI_sprintfN("Version %d.%d%s", BLENDER_VERSION / 100, BLENDER_VERSION % 100, version_suffix);
+
+ if (version != NULL && version[0]) {
/* placed after the version number in the image,
* placing y is tricky to match baseline */
- int x = 234 * U.dpi_fac;
- int y = 235 * U.dpi_fac;
- int w = 240 * U.dpi_fac;
-
/* hack to have text draw 'text_sel' */
UI_block_emboss_set(block, UI_EMBOSS_NONE);
- but = uiDefBut(block, UI_BTYPE_LABEL, 0, version_suffix, x, y, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ int x = 202 * U.dpi_fac;
+ int y = 130 * U.dpi_fac;
+ int w = 240 * U.dpi_fac;
+
+
+ but = uiDefBut(block, UI_BTYPE_LABEL, 0, version, x, y, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
/* XXX, set internal flag - UI_SELECT */
UI_but_flag_enable(but, 1);
UI_block_emboss_set(block, UI_EMBOSS);
}
+ MEM_freeN(version);
+
#ifdef WITH_BUILDINFO
if (build_commit_timestamp != 0) {
but = uiDefBut(
block, UI_BTYPE_LABEL, 0, date_buf,
- U.dpi_fac * 502 - date_width, U.dpi_fac * 267,
+ U.dpi_fac * 502 - date_width, U.dpi_fac * 237,
date_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
/* XXX, set internal flag - UI_SELECT */
- UI_but_flag_enable(but, 1);
+ UI_but_flag_enable(but, 0);
label_delta = 12;
}
but = uiDefBut(
block, UI_BTYPE_LABEL, 0, hash_buf,
- U.dpi_fac * 502 - hash_width, U.dpi_fac * (267 - label_delta),
+ U.dpi_fac * 502 - hash_width, U.dpi_fac * (237 - label_delta),
hash_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
/* XXX, set internal flag - UI_SELECT */
- UI_but_flag_enable(but, 1);
+ UI_but_flag_enable(but, 0);
if (!STREQ(build_branch, "master")) {
char branch_buf[128] = "\0";
@@ -1534,16 +1541,16 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
branch_width = (int)BLF_width(style->widgetlabel.uifont_id, branch_buf, sizeof(branch_buf)) + U.widget_unit;
but = uiDefBut(
block, UI_BTYPE_LABEL, 0, branch_buf,
- U.dpi_fac * 502 - branch_width, U.dpi_fac * (255 - label_delta),
+ U.dpi_fac * 502 - branch_width, U.dpi_fac * (225 - label_delta),
branch_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
/* XXX, set internal flag - UI_SELECT */
- UI_but_flag_enable(but, 1);
+ UI_but_flag_enable(but, 0);
}
#endif /* WITH_BUILDINFO */
uiLayout *layout = UI_block_layout(
- block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2,
- U.dpi_fac * 480, U.dpi_fac * 110, 0, style);
+ block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, U.dpi_fac * 40, 0,
+ U.dpi_fac * 450, U.dpi_fac * 110, 0, style);
MenuType *mt = WM_menutype_find("WM_MT_splash", true);
if (mt) {
@@ -1616,8 +1623,35 @@ static int wm_search_menu_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
-static int wm_search_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
+static int wm_search_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
+ /* Exception for launching via spacebar */
+ if (event->type == SPACEKEY) {
+ bool ok = true;
+ ScrArea *sa = CTX_wm_area(C);
+ if (sa) {
+ if (sa->spacetype == SPACE_CONSOLE) {
+ /* So we can use the shortcut in the console. */
+ ok = false;
+ }
+ else if (sa->spacetype == SPACE_TEXT) {
+ /* So we can use the spacebar in the text editor. */
+ ok = false;
+ }
+ }
+ else {
+ Object *editob = CTX_data_edit_object(C);
+ if (editob && editob->type == OB_FONT) {
+ /* So we can use the spacebar for entering text. */
+ ok = false;
+ }
+ }
+ if (!ok) {
+ return OPERATOR_PASS_THROUGH;
+ }
+ }
+
+
struct SearchPopupInit_Data data = {
.size = {
UI_searchbox_size_x() * 2,
@@ -1630,26 +1664,6 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv
return OPERATOR_INTERFACE;
}
-/* op->poll */
-static bool wm_search_menu_poll(bContext *C)
-{
- if (CTX_wm_window(C) == NULL) {
- return 0;
- }
- else {
- ScrArea *sa = CTX_wm_area(C);
- if (sa) {
- if (sa->spacetype == SPACE_CONSOLE) return 0; /* XXX - so we can use the shortcut in the console */
- if (sa->spacetype == SPACE_TEXT) return 0; /* XXX - so we can use the spacebar in the text editor */
- }
- else {
- Object *editob = CTX_data_edit_object(C);
- if (editob && editob->type == OB_FONT) return 0; /* XXX - so we can use the spacebar for entering text */
- }
- }
- return 1;
-}
-
static void WM_OT_search_menu(wmOperatorType *ot)
{
ot->name = "Search Menu";
@@ -1658,7 +1672,7 @@ static void WM_OT_search_menu(wmOperatorType *ot)
ot->invoke = wm_search_menu_invoke;
ot->exec = wm_search_menu_exec;
- ot->poll = wm_search_menu_poll;
+ ot->poll = WM_operator_winactive;
}
static int wm_call_menu_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index d1173fccff8..4b3b5695a8e 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -553,40 +553,26 @@ void WM_toolsystem_init(bContext *C)
LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) {
LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
MEM_SAFE_FREE(tref->runtime);
- tref->tag = 0;
}
}
- for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- CTX_wm_window_set(C, win);
- WorkSpace *workspace = WM_window_get_active_workspace(win);
- bScreen *screen = WM_window_get_active_screen(win);
- ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- if (((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) {
- continue;
- }
- const bToolKey tkey = {
- .space_type = sa->spacetype,
- .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype),
- };
- bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey);
- if (tref) {
- if (tref->tag == 0) {
- toolsystem_reinit_ref(C, workspace, tref);
- tref->tag = 1;
- }
- }
- else {
- /* Without this we may load a file without a default tool. */
- tref = toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL);
- tref->tag = 1;
- }
+ /* Rely on screen initialization for gizmos. */
+}
+
+static bool toolsystem_key_ensure_check(const bToolKey *tkey)
+{
+ switch (tkey->space_type) {
+ case SPACE_VIEW3D:
+ return true;
+ case SPACE_IMAGE:
+ if (ELEM(tkey->mode, SI_MODE_PAINT, SI_MODE_UV)) {
+ return true;
}
- CTX_wm_window_set(C, NULL);
- }
+ break;
+ case SPACE_NODE:
+ return true;
}
+ return false;
}
int WM_toolsystem_mode_from_spacetype(
@@ -613,6 +599,11 @@ int WM_toolsystem_mode_from_spacetype(
mode = sima->mode;
break;
}
+ case SPACE_NODE:
+ {
+ mode = 0;
+ break;
+ }
}
return mode;
}
@@ -812,6 +803,12 @@ static const char *toolsystem_default_tool(const bToolKey *tkey)
return "Comb";
}
break;
+ case SPACE_IMAGE:
+ switch (tkey->mode) {
+ case SI_MODE_PAINT:
+ return "Draw";
+ }
+ break;
}
return "Select Box";
@@ -846,6 +843,20 @@ void WM_toolsystem_update_from_context_view3d(bContext *C)
toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL);
}
+void WM_toolsystem_update_from_context(
+ bContext *C, WorkSpace *workspace, ViewLayer *view_layer,
+ ScrArea *sa)
+{
+ const bToolKey tkey = {
+ .space_type = sa->spacetype,
+ .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype),
+ };
+ if (toolsystem_key_ensure_check(&tkey)) {
+ toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL);
+ }
+}
+
+
/**
* For paint modes to support non-brush tools.
*/
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index b644457e593..53db8f931a5 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -954,7 +954,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
if (sa->spacetype == SPACE_IMAGE)
title = IFACE_("Blender Render");
else if (ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF))
- title = IFACE_("Blender User Preferences");
+ title = IFACE_("Blender Preferences");
else if (sa->spacetype == SPACE_FILE)
title = IFACE_("Blender File View");
else if (sa->spacetype == SPACE_IPO)
@@ -2196,7 +2196,7 @@ void WM_window_set_active_view_layer(wmWindow *win, ViewLayer *view_layer)
wmWindow *win_parent = (win->parent) ? win->parent : win;
/* Set view layer in parent and child windows. */
- STRNCPY(win->view_layer_name, view_layer->name);
+ STRNCPY(win_parent->view_layer_name, view_layer->name);
for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) {
if (win_child->parent == win_parent) {
diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h
index 147ed882966..f6f43c3d856 100644
--- a/source/blender/windowmanager/wm_files.h
+++ b/source/blender/windowmanager/wm_files.h
@@ -35,11 +35,12 @@ struct Main;
struct wmOperatorType;
/* wm_files.c */
-void wm_history_file_read(void);
-int wm_homefile_read(
+void wm_history_file_read(void);
+void wm_homefile_read(
struct bContext *C, struct ReportList *reports,
bool use_factory_settings, bool use_empty_data, bool use_userdef,
- const char *filepath_startup_override, const char *app_template_override);
+ const char *filepath_startup_override, const char *app_template_override,
+ bool *r_is_factory_startup);
void wm_file_read_report(bContext *C, struct Main *bmain);
void WM_OT_save_homefile(struct wmOperatorType *ot);
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 5bc266427d5..a32acc75248 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -364,6 +364,7 @@ int main(
BKE_appdir_program_path_init(argv[0]);
BLI_threadapi_init();
+ BLI_thread_put_process_on_fast_node();
DNA_sdna_current_init();
@@ -467,11 +468,6 @@ int main(
CTX_py_init_set(C, 1);
WM_keyconfig_init(C);
- /* Called on load, however Python is not yet initialized, so call again here. */
- if (!G.background) {
- WM_toolsystem_init(C);
- }
-
#ifdef WITH_FREESTYLE
/* initialize Freestyle */
FRS_initialize();
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index 12d8cd1d5b8..5b976515dd8 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -1933,6 +1933,8 @@ void main_args_setup(bContext *C, bArgs *ba)
CB_EX(arg_handle_debug_mode_generic_set, gpumem), (void *)G_DEBUG_GPU_MEM);
BLI_argsAdd(ba, 1, NULL, "--debug-gpu-shaders",
CB_EX(arg_handle_debug_mode_generic_set, gpumem), (void *)G_DEBUG_GPU_SHADERS);
+ BLI_argsAdd(ba, 1, NULL, "--debug-gpu-force-workarounds",
+ CB_EX(arg_handle_debug_mode_generic_set, gpumem), (void *)G_DEBUG_GPU_FORCE_WORKAROUNDS);
BLI_argsAdd(ba, 1, NULL, "--verbose", CB(arg_handle_verbosity_set), NULL);
diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt
index e652fbecb36..e399d4651f5 100644
--- a/tests/gtests/blenlib/CMakeLists.txt
+++ b/tests/gtests/blenlib/CMakeLists.txt
@@ -48,8 +48,8 @@ BLENDER_TEST(BLI_ghash "bf_blenlib")
BLENDER_TEST(BLI_hash_mm2a "bf_blenlib")
BLENDER_TEST(BLI_heap "bf_blenlib")
BLENDER_TEST(BLI_heap_simple "bf_blenlib")
-BLENDER_TEST(BLI_kdopbvh "bf_blenlib")
-BLENDER_TEST(BLI_linklist_lockfree "bf_blenlib")
+BLENDER_TEST(BLI_kdopbvh "bf_blenlib;bf_intern_numaapi")
+BLENDER_TEST(BLI_linklist_lockfree "bf_blenlib;bf_intern_numaapi")
BLENDER_TEST(BLI_listbase "bf_blenlib")
BLENDER_TEST(BLI_math_base "bf_blenlib")
BLENDER_TEST(BLI_math_color "bf_blenlib")
@@ -60,7 +60,7 @@ BLENDER_TEST(BLI_polyfill_2d "bf_blenlib")
BLENDER_TEST(BLI_stack "bf_blenlib")
BLENDER_TEST(BLI_string "bf_blenlib")
BLENDER_TEST(BLI_string_utf8 "bf_blenlib")
-BLENDER_TEST(BLI_task "bf_blenlib")
+BLENDER_TEST(BLI_task "bf_blenlib;bf_intern_numaapi")
BLENDER_TEST_PERFORMANCE(BLI_ghash_performance "bf_blenlib")
diff --git a/tests/python/alembic_tests.py b/tests/python/alembic_tests.py
index d872e699cea..09e9b8981e3 100755
--- a/tests/python/alembic_tests.py
+++ b/tests/python/alembic_tests.py
@@ -20,17 +20,15 @@
# <pep8 compliant>
import argparse
-import functools
-import shutil
import pathlib
import subprocess
import sys
-import tempfile
import unittest
-from modules.test_utils import (with_tempdir,
- AbstractBlenderRunnerTest,
- )
+from modules.test_utils import (
+ with_tempdir,
+ AbstractBlenderRunnerTest,
+)
class AbcPropError(Exception):
diff --git a/tests/python/batch_import.py b/tests/python/batch_import.py
index a6e2469349b..20d96a69a79 100644
--- a/tests/python/batch_import.py
+++ b/tests/python/batch_import.py
@@ -157,7 +157,7 @@ def main():
parser.add_option("-S", "--start", dest="start", help="From collected files, start with this index", metavar='int')
parser.add_option("-E", "--end", dest="end", help="From collected files, end with this index", metavar='int')
- options, args = parser.parse_args(argv) # In this example we wont use the args
+ options, _args = parser.parse_args(argv) # In this example we wont use the args
if not argv:
parser.print_help()
diff --git a/tests/python/bl_alembic_import_test.py b/tests/python/bl_alembic_import_test.py
index 95afff53ed4..ad7d2fd398a 100644
--- a/tests/python/bl_alembic_import_test.py
+++ b/tests/python/bl_alembic_import_test.py
@@ -175,8 +175,6 @@ class SimpleImportTest(AbstractAlembicTest):
self.assertAlmostEqual(z, 0)
def test_change_path_modifier(self):
- import math
-
fname = 'animated-mesh.abc'
abc = self.testdir / fname
relpath = bpy.path.relpath(str(abc))
@@ -188,7 +186,6 @@ class SimpleImportTest(AbstractAlembicTest):
# Check that the file loaded ok.
bpy.context.scene.frame_set(6)
scene = bpy.context.scene
- layer = scene.view_layers[scene.active_layer]
mesh = plane.to_mesh(bpy.context.depsgraph, True, True, False)
self.assertAlmostEqual(-1, mesh.vertices[0].co.x)
self.assertAlmostEqual(-1, mesh.vertices[0].co.y)
diff --git a/tests/python/bl_load_addons.py b/tests/python/bl_load_addons.py
index 16ddea24756..e404e2340ce 100644
--- a/tests/python/bl_load_addons.py
+++ b/tests/python/bl_load_addons.py
@@ -102,7 +102,7 @@ def reload_addons(do_reload=True, do_reverse=True):
disable_addons()
# Run twice each time.
- for i in (0, 1):
+ for _ in (0, 1):
for mod in modules:
mod_name = mod.__name__
print("\tenabling:", mod_name)
diff --git a/tests/python/bl_load_py_modules.py b/tests/python/bl_load_py_modules.py
index 437a425a36d..b7b0db76b63 100644
--- a/tests/python/bl_load_py_modules.py
+++ b/tests/python/bl_load_py_modules.py
@@ -197,7 +197,7 @@ def load_modules():
assert(os.path.samefile(mod_imp.__file__, submod_full))
modules.append(mod_imp)
- except Exception as e:
+ except Exception:
import traceback
# Module might fail to import, but we don't want whole test to fail here.
# Reasoning:
diff --git a/tests/python/bl_mesh_validate.py b/tests/python/bl_mesh_validate.py
index e1dd097b2e0..47a5e5efe47 100644
--- a/tests/python/bl_mesh_validate.py
+++ b/tests/python/bl_mesh_validate.py
@@ -114,7 +114,7 @@ def test_builtins():
getattr(bpy.ops.mesh, func)(location=(x * 2.5, y * 2.5, 0))
data = bpy.context.active_object.data
try:
- for n in range(BUILTINS_NBRCHANGES):
+ for _ in range(BUILTINS_NBRCHANGES):
rnd = random.randint(1, 3)
if rnd == 1:
# Make fun with some edge.
diff --git a/tests/python/bl_run_operators.py b/tests/python/bl_run_operators.py
index f3b1ec2f4c2..5954f7d9381 100644
--- a/tests/python/bl_run_operators.py
+++ b/tests/python/bl_run_operators.py
@@ -141,7 +141,7 @@ def reset_blend():
if USE_RANDOM_SCREEN:
import random
- for i in range(random.randint(0, len(bpy.data.screens))):
+ for _ in range(random.randint(0, len(bpy.data.screens))):
bpy.ops.screen.delete()
print("Scree IS", bpy.context.screen)
@@ -237,7 +237,7 @@ if USE_ATTRSET:
seq = getattr(bpy.data, attr)
if seq.__class__.__name__ == 'bpy_prop_collection':
for id_data in seq:
- for val, prop, tp in id_walk(id_data, bpy.data):
+ for val, prop, _tp in id_walk(id_data, bpy.data):
# print(id_data)
for val_rnd in _random_values:
try:
diff --git a/tests/python/ffmpeg_tests.py b/tests/python/ffmpeg_tests.py
index 70677677667..3d38ebd5edc 100755
--- a/tests/python/ffmpeg_tests.py
+++ b/tests/python/ffmpeg_tests.py
@@ -20,12 +20,8 @@
# <pep8 compliant>
import argparse
-import functools
-import shutil
import pathlib
-import subprocess
import sys
-import tempfile
import unittest
from modules.test_utils import AbstractBlenderRunnerTest
diff --git a/tests/python/modules/test_utils.py b/tests/python/modules/test_utils.py
index 47d720684ba..46c1626493f 100755
--- a/tests/python/modules/test_utils.py
+++ b/tests/python/modules/test_utils.py
@@ -19,13 +19,10 @@
# <pep8 compliant>
-import argparse
import functools
import shutil
import pathlib
-import re
import subprocess
-import sys
import tempfile
import unittest
diff --git a/tests/python/pep8.py b/tests/python/pep8.py
index ccc2dddbbd9..78f0c82d00f 100644
--- a/tests/python/pep8.py
+++ b/tests/python/pep8.py
@@ -62,7 +62,7 @@ def is_pep8(path):
return 1
f = open(path, 'r', encoding="utf8")
- for i in range(PEP8_SEEK_COMMENT):
+ for _ in range(PEP8_SEEK_COMMENT):
line = f.readline()
if line.startswith("# <pep8"):
if line.startswith("# <pep8 compliant>"):
diff --git a/tests/python/rna_info_dump.py b/tests/python/rna_info_dump.py
index da228e52652..01cbe8d290b 100644
--- a/tests/python/rna_info_dump.py
+++ b/tests/python/rna_info_dump.py
@@ -71,7 +71,7 @@ def api_dump(use_properties=True, use_functions=True):
def dump_funcs():
data = []
- for struct_id, v in sorted(struct.items()):
+ for _struct_id, v in sorted(struct.items()):
struct_id_str = struct_full_id(v)
funcs = [(func.identifier, func) for func in v.functions]
@@ -90,7 +90,7 @@ def api_dump(use_properties=True, use_functions=True):
def dump_props():
data = []
- for struct_id, v in sorted(struct.items()):
+ for _struct_id, v in sorted(struct.items()):
struct_id_str = struct_full_id(v)
props = [(prop.identifier, prop) for prop in v.properties]
diff --git a/tests/python/view_layer/test_group_e.py b/tests/python/view_layer/test_group_e.py
index 14385411eca..7385d94f1f4 100644
--- a/tests/python/view_layer/test_group_e.py
+++ b/tests/python/view_layer/test_group_e.py
@@ -44,8 +44,8 @@ class UnitTesting(ViewLayerTesting):
empty = bpy.data.objects.new("Empty", None)
bpy.context.scene_collection.objects.link(empty)
layer_collection = bpy.context.layer_collection
- empty.dupli_type = 'GROUP'
- empty.dupli_group = group
+ empty.instance_type = 'GROUP'
+ empty.instance_collection = group
# prepare to delete the original object
# we could just pass an overridden context